npm.io
0.1.0 • Published 3 weeks ago

@sakia/template-format

Licence
MIT
Version
0.1.0
Deps
0
Size
40 kB
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

@sakia/template-format

Third-party format integration scaffold — copy this package to bootstrap a new Sakia format adapter.

Reference implementation: @sakia/loaders (DXF placeholder).

Package layout

File Role
templateDocument.ts IDocument + entities with typeId
parseTemplate.ts Text → document (IFormatParser candidate)
index.ts Loader plugin, Painter, mount helpers, RegisterTemplateLoaders()

Quick start

import { NullEngine, DocumentLoader } from "@sakia/core";
import {
    RegisterTemplateLoaders,
    loadAndMountTemplateDocument,
} from "@sakia/template-format";

RegisterTemplateLoaders();

const engine = new NullEngine();
await engine.setup();

const source = `# demo
LINE 0 0 10 5
LINE 10 5 20 0`;

await loadAndMountTemplateDocument(engine, source, "demo.template");
engine.render();

Customize

  1. Rename package and format string on your document class.
  2. Replace parseTemplate with real decoding; optionally export IFormatParser / IDocumentSerializer.
  3. Add ItemPainter subclasses per entity typeId (or rely on DocumentPainter constructor fallback during migration).
  4. Register loader via RegisterDocumentLoaderPlugin (idempotent Register* helper recommended).
  5. Export loadAndMount* using core loadAndMountDocument + your mount* function.

Sample .template syntax (placeholder)

# comment
LINE x1 y1 x2 y2

Coordinates are world mm, same unit system as Sakia scenes.

Keywords