@graphics-i18n/core
v0.0.3
Published
Platform-agnostic pipeline for **LPKG** localized graphics packages: container reading (zip via fflate, plus `*.lpkg.json` debug bundles), manifest validation, locale negotiation, patch/locale application, deterministic text fitting, effective-scene build
Readme
@graphics-i18n/core
Platform-agnostic pipeline for LPKG localized graphics packages: container
reading (zip via fflate, plus *.lpkg.json debug bundles), manifest
validation, locale negotiation, patch/locale application, deterministic text
fitting, effective-scene building, caching and migration. No React, DOM or
native dependency — runs in Node, browsers, workers and SSR.
See spec.md at the repo root for the full format and runtime spec.
Renderers build on this package:
@graphics-i18n/react— web (SVG)@graphics-i18n/react-native— React Native (Skia)
Core API
import {
loadLocalizedGraphic,
validateLocalizedGraphicPackage,
} from '@graphics-i18n/core';
const { manifest, effectiveScene, container } = await loadLocalizedGraphic(
source,
'fr',
);effectiveScene is the backend-agnostic draw list (EffectiveNode[] with
resolved text, bounds, matrices and z-order) that renderers consume.
Text fitting runs against a TextMeasurer; the built-in approxTextMeasurer
is deterministic and font-agnostic, and renderers can pass a platform-accurate
measurer via LoadOptions.createMeasurer.
Authoring tools (Node only)
import {
packLpkgFromFiles,
packLpkgDir,
validateLpkg,
} from '@graphics-i18n/core/tools';CLI (after build):
lpkg pack ./my-banner -o banner.lpkg # zips a spec §3.2 directory, adds chunk hashes
lpkg validate banner.lpkg@graphics-i18n/core/testing exports the shared example-package fixtures used by
the lib test suites.
Behavior notes
- String fallback: requested pack → fallback pack → node
fallbackText→ empty string, each miss recorded as aSTRING_MISSINGdiagnostic ineffectiveScene.meta.diagnostics. - Badge text is literal unless prefixed with
@("@promo.discount"). - Override precedence for text nodes: scene patch → node
localeOverrides[locale]→ locale packnodeOverrides(last wins). - RTL: direction comes from the locale pack (or locale heuristic); text
nodes mirror alignment unless
rtlAware: false.
v1 limitations
fit.mode: 'scroll'renders as clip;resize-boxonly grows height.- Group
layout.justifyandalign: 'stretch'are ignored;clipPathandblendModeare not yet applied. - Path bounds are approximate (coordinate scan, curves overestimate).
