@sealpixel/core 1.0.0-rc.13 → 1.0.0-rc.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/assets.d.ts +0 -1
  2. package/dist/assets.js.map +1 -1
  3. package/dist/canonical-json.d.ts +0 -1
  4. package/dist/canonical-json.js.map +1 -1
  5. package/dist/compile.d.ts +0 -1
  6. package/dist/compile.js.map +1 -1
  7. package/dist/embedded.d.ts +0 -1
  8. package/dist/embedded.js.map +1 -1
  9. package/dist/errors.d.ts +0 -1
  10. package/dist/errors.js.map +1 -1
  11. package/dist/external-kernel.d.ts +0 -1
  12. package/dist/external-kernel.js.map +1 -1
  13. package/dist/generated/geometry.d.ts +0 -1
  14. package/dist/generated/geometry.js.map +1 -1
  15. package/dist/generated/output.d.ts +0 -1
  16. package/dist/generated/output.js.map +1 -1
  17. package/dist/generated/plan.d.ts +0 -1
  18. package/dist/generated/plan.js.map +1 -1
  19. package/dist/history.d.ts +0 -1
  20. package/dist/history.js.map +1 -1
  21. package/dist/image-size.d.ts +0 -1
  22. package/dist/image-size.js.map +1 -1
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +2 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/inline-renderer.d.ts +0 -1
  27. package/dist/inline-renderer.js.map +1 -1
  28. package/dist/manifest.d.ts +127 -0
  29. package/dist/manifest.js +115 -0
  30. package/dist/manifest.js.map +1 -0
  31. package/dist/options.d.ts +0 -1
  32. package/dist/options.js.map +1 -1
  33. package/dist/plan.d.ts +0 -1
  34. package/dist/plan.js.map +1 -1
  35. package/dist/plugin.d.ts +0 -1
  36. package/dist/plugin.js.map +1 -1
  37. package/dist/registry.d.ts +0 -1
  38. package/dist/registry.js.map +1 -1
  39. package/dist/render.d.ts +5 -1
  40. package/dist/render.js +126 -11
  41. package/dist/render.js.map +1 -1
  42. package/dist/renderer-core.d.ts +4 -2
  43. package/dist/renderer-core.js +6 -1
  44. package/dist/renderer-core.js.map +1 -1
  45. package/dist/renderer.d.ts +0 -1
  46. package/dist/renderer.js.map +1 -1
  47. package/dist/session.d.ts +0 -1
  48. package/dist/session.js.map +1 -1
  49. package/dist/types.d.ts +17 -2
  50. package/dist/types.js.map +1 -1
  51. package/dist/worker-protocol.d.ts +0 -1
  52. package/dist/worker-protocol.js.map +1 -1
  53. package/dist/worker-renderer.d.ts +0 -1
  54. package/dist/worker-renderer.js.map +1 -1
  55. package/dist/worker.d.ts +0 -1
  56. package/dist/worker.js.map +1 -1
  57. package/package.json +2 -2
  58. package/dist/assets.d.ts.map +0 -1
  59. package/dist/canonical-json.d.ts.map +0 -1
  60. package/dist/compile.d.ts.map +0 -1
  61. package/dist/embedded.d.ts.map +0 -1
  62. package/dist/errors.d.ts.map +0 -1
  63. package/dist/external-kernel.d.ts.map +0 -1
  64. package/dist/generated/geometry.d.ts.map +0 -1
  65. package/dist/generated/output.d.ts.map +0 -1
  66. package/dist/generated/plan.d.ts.map +0 -1
  67. package/dist/history.d.ts.map +0 -1
  68. package/dist/image-size.d.ts.map +0 -1
  69. package/dist/index.d.ts.map +0 -1
  70. package/dist/inline-renderer.d.ts.map +0 -1
  71. package/dist/options.d.ts.map +0 -1
  72. package/dist/plan.d.ts.map +0 -1
  73. package/dist/plugin.d.ts.map +0 -1
  74. package/dist/registry.d.ts.map +0 -1
  75. package/dist/render.d.ts.map +0 -1
  76. package/dist/renderer-core.d.ts.map +0 -1
  77. package/dist/renderer.d.ts.map +0 -1
  78. package/dist/session.d.ts.map +0 -1
  79. package/dist/types.d.ts.map +0 -1
  80. package/dist/worker-protocol.d.ts.map +0 -1
  81. package/dist/worker-renderer.d.ts.map +0 -1
  82. package/dist/worker.d.ts.map +0 -1
package/dist/assets.d.ts CHANGED
@@ -34,4 +34,3 @@ export declare function missingAssetId(error: unknown): string | null;
34
34
  export declare function withAssets<T>(fn: () => Promise<T>, resolver: AssetResolver | undefined, put: (id: string, bytes: Uint8Array) => Promise<void> | void, limit?: number): Promise<T>;
35
35
  /** Uses a loaded core to hash, so the value equals the core's own sha256. */
36
36
  export declare function wasmSha256(wasm: SealpixelWasm): (bytes: Uint8Array) => string;
37
- //# sourceMappingURL=assets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assets.js","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAmB7C;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA6B;IAC/D,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,IAAI,GAAG,EAA+B,CAAC;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACvC,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,IAAI,eAAe,CAAC;IAC9C,OAAO;QACL,YAAY,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM;QAClC,OAAO,CAAC,EAAE;YACR,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC7B,IAAI,MAAM;gBAAE,OAAO,MAAM,CAAC;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC1B,IAAI,CAAC,IAAI;gBACP,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,eAAe,EAAE,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC;YAC9F,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,EAAE;gBAC1B,IAAI,CAAC,IAAI,CAAC,GAAG;oBAAE,MAAM,IAAI,cAAc,CAAC,eAAe,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;gBAC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ACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,EAAoB,EACpB,QAAmC,EACnC,GAA4D,EAC5D,KAAK,GAAG,EAAE;IAEV,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,SAAS,CAAC;QACR,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,EAAE,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;YACjC,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,IAAI,KAAK;gBAAE,MAAM,KAAK,CAAC;YAC5E,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACzC,MAAM,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YACrB,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,UAAU,CAAC,IAAmB;IAC5C,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { SealpixelWasm } from '@sealpixel/wasm';\nimport { SealpixelError } from './errors.js';\nimport type { AssetDeclaration } from './plugin.js';\n\n/** Supplies asset bytes by id. Implementations verify the declared hash. */\nexport interface AssetResolver {\n resolve(id: string): Promise<Uint8Array>;\n /** Declared assets, used to pre-load and to verify hashes. */\n declarations(): readonly AssetDeclaration[];\n}\n\nexport interface AssetResolverOptions {\n assets: readonly AssetDeclaration[];\n /** Resolves relative `url`s. Defaults to the document location in browsers. */\n baseUrl?: string | URL;\n fetch?: typeof fetch;\n /** Computes sha256 for verification. Defaults to WebCrypto. */\n sha256?: (bytes: Uint8Array) => Promise<string> | string;\n}\n\n/**\n * Fetch-based resolver. Every asset must be declared with a hash; bytes whose\n * hash differs are rejected, so client and server render the same glyphs.\n */\nexport function createAssetResolver(options: AssetResolverOptions): AssetResolver {\n const byId = new Map(options.assets.map((a) => [a.id, a]));\n const cache = new Map<string, Promise<Uint8Array>>();\n const doFetch = options.fetch ?? fetch;\n const sha = options.sha256 ?? webCryptoSha256;\n return {\n declarations: () => options.assets,\n resolve(id) {\n const cached = cache.get(id);\n if (cached) return cached;\n const decl = byId.get(id);\n if (!decl)\n return Promise.reject(new SealpixelError('MISSING_ASSET', `asset \"${id}\" is not declared`));\n const pending = (async () => {\n if (!decl.url) throw new SealpixelError('MISSING_ASSET', `asset \"${id}\" has no url`);\n const url = options.baseUrl ? new URL(decl.url, options.baseUrl).toString() : decl.url;\n const res = await doFetch(url);\n if (!res.ok)\n throw new SealpixelError(\n 'MISSING_ASSET',\n `asset \"${id}\": HTTP ${res.status} from ${url}`,\n );\n const bytes = new Uint8Array(await res.arrayBuffer());\n return verify(id, decl, bytes, sha);\n })().catch((error) => {\n cache.delete(id);\n throw error;\n });\n cache.set(id, pending);\n return pending;\n },\n };\n}\n\n/** Resolver over in-memory bytes (tests, servers with preloaded assets). */\nexport function staticAssetResolver(\n entries: readonly { declaration: AssetDeclaration; bytes: Uint8Array }[],\n sha256: (bytes: Uint8Array) => Promise<string> | string = webCryptoSha256,\n): AssetResolver {\n const map = new Map(entries.map((e) => [e.declaration.id, e]));\n return {\n declarations: () => entries.map((e) => e.declaration),\n async resolve(id) {\n const e = map.get(id);\n if (!e) throw new SealpixelError('MISSING_ASSET', `asset \"${id}\" is not declared`);\n return verify(id, e.declaration, e.bytes, sha256);\n },\n };\n}\n\nasync function verify(\n id: string,\n decl: AssetDeclaration,\n bytes: Uint8Array,\n sha256: (bytes: Uint8Array) => Promise<string> | string,\n): Promise<Uint8Array> {\n const actual = await sha256(bytes);\n if (actual !== decl.hash) {\n throw new SealpixelError(\n 'MISSING_ASSET',\n `asset \"${id}\" hash mismatch: expected ${decl.hash}, got ${actual}`,\n );\n }\n return bytes;\n}\n\nexport async function webCryptoSha256(bytes: Uint8Array): Promise<string> {\n const digest = await crypto.subtle.digest('SHA-256', bytes as BufferSource);\n return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('');\n}\n\n/** Id of the asset a `MISSING_ASSET` error refers to, if the error carries it. */\nexport function missingAssetId(error: unknown): string | null {\n if (!(error instanceof Error) || error.name !== 'MISSING_ASSET') return null;\n const details = (error as { details?: { assetId?: unknown } }).details;\n if (details && typeof details.assetId === 'string') return details.assetId;\n const m = /asset \"([^\"]+)\"/.exec(error.message);\n return m?.[1] ?? null;\n}\n\n/**\n * Runs `fn`, and whenever it fails with `MISSING_ASSET`, resolves that asset,\n * stores it with `put`, and retries. Gives up after `limit` distinct assets.\n */\nexport async function withAssets<T>(\n fn: () => Promise<T>,\n resolver: AssetResolver | undefined,\n put: (id: string, bytes: Uint8Array) => Promise<void> | void,\n limit = 16,\n): Promise<T> {\n const loaded = new Set<string>();\n for (;;) {\n try {\n return await fn();\n } catch (error) {\n const id = missingAssetId(error);\n if (!id || !resolver || loaded.has(id) || loaded.size >= limit) throw error;\n const bytes = await resolver.resolve(id);\n await put(id, bytes);\n loaded.add(id);\n }\n }\n}\n\n/** Uses a loaded core to hash, so the value equals the core's own sha256. */\nexport function wasmSha256(wasm: SealpixelWasm): (bytes: Uint8Array) => string {\n return (bytes) => wasm.sha256Hex(bytes);\n}\n"]}
@@ -8,4 +8,3 @@
8
8
  * `null`.
9
9
  */
10
10
  export declare function canonicalJson(value: unknown): string;
11
- //# sourceMappingURL=canonical-json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"canonical-json.js","sourceRoot":"","sources":["../src/canonical-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AACrC,CA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/**\n * Deterministic JSON serialisation: object keys sorted, no whitespace,\n * `undefined` properties dropped. Used for hashes and server job keys so the\n * same logical value always yields the same string on every runtime.\n *\n * Throws on values JSON cannot represent (functions, symbols, bigint, cycles)\n * and on non-finite numbers, which `JSON.stringify` would silently turn into\n * `null`.\n */\nexport function canonicalJson(value: unknown): string {\n return serialize(value, new Set());\n}\n\nfunction serialize(value: unknown, seen: Set<object>): string {\n if (value === null) return 'null';\n switch (typeof value) {\n case 'string':\n return JSON.stringify(value);\n case 'boolean':\n return value ? 'true' : 'false';\n case 'number':\n if (!Number.isFinite(value)) throw new TypeError(`canonicalJson: non-finite number ${value}`);\n return Object.is(value, -0) ? '0' : JSON.stringify(value);\n case 'object':\n break;\n default:\n throw new TypeError(`canonicalJson: cannot serialise ${typeof value}`);\n }\n const obj = value as object;\n if (seen.has(obj)) throw new TypeError('canonicalJson: circular structure');\n seen.add(obj);\n try {\n if (Array.isArray(obj)) {\n return `[${obj.map((item) => (item === undefined ? 'null' : serialize(item, seen))).join(',')}]`;\n }\n const keys = Object.keys(obj)\n .filter((key) => (obj as Record<string, unknown>)[key] !== undefined)\n .sort();\n const parts = keys.map(\n (key) => `${JSON.stringify(key)}:${serialize((obj as Record<string, unknown>)[key], seen)}`,\n );\n return `{${parts.join(',')}}`;\n } finally {\n seen.delete(obj);\n }\n}\n"]}
package/dist/compile.d.ts CHANGED
@@ -27,4 +27,3 @@ export type PipelineStage = {
27
27
  export declare function toPipeline(doc: Document, registry: Registry, ctx: PlanContext): PipelineStage[];
28
28
  /** Converts a run of core pipeline stages into Rust `Stage` values. */
29
29
  export declare function toCoreStages(stages: readonly PipelineStage[]): Stage[];
30
- //# sourceMappingURL=compile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile.js","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7C;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,GAA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AAuE;AACvE,MAAM,UAAU,YAAY,CAAC,MAAgC;IAC3D,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACtB,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACtB,MAAM,IAAI,cAAc,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC,IAAI,uBAAuB,CAAC,CAAC;QACxF,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,MAAM,EAAW,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { SealpixelError } from './errors.js';\nimport type { Stage } from './plan.js';\nimport type { AnyPlugin, Document, PlanContext, StageParams } from './plugin.js';\nimport type { Registry } from './registry.js';\nimport type { EditLog } from './types.js';\n\n/**\n * Folds `ops[0..upTo)` into the derived document. Pure. Ops with unknown\n * types (only present when parsed with `tolerateUnknown`) are skipped.\n */\nexport function compile(log: EditLog, registry: Registry, upTo: number = log.ops.length): Document {\n const doc = registry.initialDocument() as Record<string, unknown>;\n const end = Math.max(0, Math.min(upTo, log.ops.length));\n for (let i = 0; i < end; i++) {\n const op = log.ops[i] as unknown as { type: string };\n const entry = registry.byOpType.get(op.type);\n if (!entry) continue;\n doc[entry.plugin.id] = entry.def.reduce(doc[entry.plugin.id], op);\n }\n return doc as Document;\n}\n\n/** A stage in the full pipeline, before it is split into core and external segments. */\nexport type PipelineStage =\n | { kind: 'core'; name: Stage['kind']; order: number; params: StageParams }\n | { kind: 'js' | 'wasm'; name: string; order: number; plugin: AnyPlugin; params: StageParams };\n\n/**\n * Asks every plugin for its stage parameters and produces the ordered stage\n * list. Core stages with the same name are shallow-merged in plugin order.\n */\nexport function toPipeline(doc: Document, registry: Registry, ctx: PlanContext): PipelineStage[] {\n const stages: PipelineStage[] = [];\n const coreByName = new Map<string, Extract<PipelineStage, { kind: 'core' }>>();\n for (const plugin of registry.plugins) {\n const params = plugin.toPlan((doc as Record<string, unknown>)[plugin.id], {\n ...ctx,\n options: plugin.options,\n });\n if (params === null) continue;\n if (plugin.kernel.kind === 'core') {\n const name = plugin.stage.name as Stage['kind'];\n const existing = coreByName.get(name);\n if (existing) {\n existing.params = { ...existing.params, ...params };\n continue;\n }\n const stage = { kind: 'core' as const, name, order: plugin.stage.order, params };\n coreByName.set(name, stage);\n stages.push(stage);\n } else {\n stages.push({\n kind: plugin.kernel.kind,\n name: plugin.stage.name,\n order: plugin.stage.order,\n plugin,\n params,\n });\n }\n }\n return stages.sort((a, b) => a.order - b.order);\n}\n\n/** Converts a run of core pipeline stages into Rust `Stage` values. */\nexport function toCoreStages(stages: readonly PipelineStage[]): Stage[] {\n return stages.map((s) => {\n if (s.kind !== 'core') {\n throw new SealpixelError('INVALID_EDIT_LOG', `stage \"${s.name}\" is not a core stage`);\n }\n return { kind: s.name, ...s.params } as Stage;\n });\n}\n"]}
@@ -10,4 +10,3 @@ export declare function readEmbeddedEditLog(bytes: Uint8Array): string | null;
10
10
  * Returns null when nothing is embedded.
11
11
  */
12
12
  export declare function readEmbeddedState(bytes: Uint8Array, registry: Registry): History | null;
13
- //# sourceMappingURL=embedded.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"embedded.js","sourceRoot":"","sources":["../src/embedded.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7C,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAC/C,mFAAmF;AACnF,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AACnD,MAAM,UAAU,GAAG,gCAAgC,CAAC;AACpD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAEvC,iEAAiE;AACjE,MAAM,UAAU,mBAAmB,CAAC,KAAiB;IACnD,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,IAA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W,CAAC;QACnB,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,EAAE,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;IAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,IAAI,GAAG,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,GAAG;SACP,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC;SACjB,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC;SACzB,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC;SACzB,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC;SACvB,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC;SACvB,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,UAAU,CAAC,KAAiB,EAAE,MAAgB;IACrD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,KAAK,CAAC,KAAiB,EAAE,KAAa,EAAE,GAAW;IAC1D,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;QAClD,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAW,CAAC,CAAC;IACjD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Reads the edit log Sealpixel embeds in exported files (PNG iTXt, JPEG APP1\n * XMP, WebP XMP chunk). A header scan only: no pixel decoding, no wasm.\n * Mirrors `sealpixel_core::codec::embedded`.\n */\nimport { SealpixelError } from './errors.js';\nimport type { Registry } from './registry.js';\nimport type { EditLog, History } from './types.js';\n\nexport const PNG_KEYWORD = 'sealpixel:editlog';\n/** Keyword written by releases before the rename (Pincel). Read, never written. */\nexport const PNG_KEYWORD_LEGACY = 'pincel:editlog';\nconst XMP_HEADER = 'http://ns.adobe.com/xap/1.0/\\0';\nconst ATTR = 'sealpixel:editLog=\"';\nconst ATTR_LEGACY = 'pincel:editLog=\"';\n\n/** The raw embedded text, or null when the file carries none. */\nexport function readEmbeddedEditLog(bytes: Uint8Array): string | null {\n if (startsWith(bytes, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])) return readPng(bytes);\n if (startsWith(bytes, [0xff, 0xd8, 0xff])) return readJpeg(bytes);\n if (bytes.length >= 12 && ascii(bytes, 0, 4) === 'RIFF' && ascii(bytes, 8, 12) === 'WEBP') {\n return readWebp(bytes);\n }\n throw new SealpixelError('UNSUPPORTED_FORMAT', 'unknown container');\n}\n\n/**\n * Parses and validates an embedded `{ log, index }` state through `registry`.\n * Returns null when nothing is embedded.\n */\nexport function readEmbeddedState(bytes: Uint8Array, registry: Registry): History | null {\n const text = readEmbeddedEditLog(bytes);\n if (text === null) return null;\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch (error) {\n throw new SealpixelError('INVALID_EDIT_LOG', `embedded edit log is not JSON: ${String(error)}`);\n }\n const state = value as { log?: unknown; index?: unknown };\n const log: EditLog = registry.parseEditLog(state.log);\n const index = typeof state.index === 'number' ? state.index : log.ops.length;\n return { log, index: Math.max(0, Math.min(Math.floor(index), log.ops.length)) };\n}\n\nfunction readPng(bytes: Uint8Array): string | null {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n let pos = 8;\n while (pos + 8 <= bytes.length) {\n const len = view.getUint32(pos);\n const kind = ascii(bytes, pos + 4, pos + 8);\n const start = pos + 8;\n const end = start + len;\n if (end > bytes.length) return null;\n if (kind === 'iTXt') {\n const data = bytes.subarray(start, end);\n const nul = data.indexOf(0);\n const keyword = nul > 0 ? ascii(data, 0, nul) : '';\n if (keyword === PNG_KEYWORD || keyword === PNG_KEYWORD_LEGACY) {\n let i = nul + 1;\n const compressed = data[i] !== 0;\n i += 2;\n i = data.indexOf(0, i) + 1; // language tag\n i = data.indexOf(0, i) + 1; // translated keyword\n if (compressed || i <= 0) return null;\n return new TextDecoder().decode(data.subarray(i));\n }\n }\n if (kind === 'IEND') return null;\n pos = end + 4;\n }\n return null;\n}\n\nfunction readJpeg(bytes: Uint8Array): string | null {\n let pos = 2;\n while (pos + 4 <= bytes.length) {\n if (bytes[pos] !== 0xff) return null;\n const marker = bytes[pos + 1];\n if (marker === 0xda || marker === 0xd9) return null;\n const len = ((bytes[pos + 2] as number) << 8) | (bytes[pos + 3] as number);\n const start = pos + 4;\n const end = pos + 2 + len;\n if (end > bytes.length) return null;\n if (marker === 0xe1 && ascii(bytes, start, start + XMP_HEADER.length) === XMP_HEADER) {\n const xmp = new TextDecoder().decode(bytes.subarray(start + XMP_HEADER.length, end));\n const payload = payloadFromXmp(xmp);\n if (payload !== null) return payload;\n }\n pos = end;\n }\n return null;\n}\n\nfunction readWebp(bytes: Uint8Array): string | null {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n let pos = 12;\n while (pos + 8 <= bytes.length) {\n const kind = ascii(bytes, pos, pos + 4);\n const len = view.getUint32(pos + 4, true);\n const start = pos + 8;\n const end = start + len;\n if (end > bytes.length) return null;\n if (kind === 'XMP ')\n return payloadFromXmp(new TextDecoder().decode(bytes.subarray(start, end)));\n pos = end + (len & 1);\n }\n return null;\n}\n\n/** Files written before the rename carry `pincel:editLog`; both attributes read back. */\nfunction payloadFromXmp(xmp: string): string | null {\n let attr = ATTR;\n let at = xmp.indexOf(attr);\n if (at < 0) {\n attr = ATTR_LEGACY;\n at = xmp.indexOf(attr);\n }\n if (at < 0) return null;\n const start = at + attr.length;\n const end = xmp.indexOf('\"', start);\n if (end < 0) return null;\n return xmp\n .slice(start, end)\n .replaceAll('&quot;', '\"')\n .replaceAll('&apos;', \"'\")\n .replaceAll('&lt;', '<')\n .replaceAll('&gt;', '>')\n .replaceAll('&amp;', '&');\n}\n\nfunction startsWith(bytes: Uint8Array, prefix: number[]): boolean {\n return prefix.every((b, i) => bytes[i] === b);\n}\n\nfunction ascii(bytes: Uint8Array, start: number, end: number): string {\n let out = '';\n for (let i = start; i < end && i < bytes.length; i++)\n out += String.fromCharCode(bytes[i] as number);\n return out;\n}\n"]}
package/dist/errors.d.ts CHANGED
@@ -6,4 +6,3 @@ export declare class SealpixelError extends Error {
6
6
  /** Re-throws core errors unchanged and wraps everything else. */
7
7
  static from(error: unknown): SealpixelError;
8
8
  }
9
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAiBA,MAAM,OAAO,cAAe,SAAQ,KAAK;IACrB,IAAI,CAAqB;IAClC,OAAO,CAAU;IAE1B,YAAY,IAAwB,EAAE,OAAe,EAAE,OAAiB;QACtE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,iEAAiE;IACjE,MAAM,CAAC,IAAI,CAAC,KAAc;QACxB,IAAI,KAAK,YAAY,cAAc;YAAE,OAAO,KAAK,CAAC;QAClD,IAAI,KAAK,YAAY,KAAK,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3D,OAAO,IAAI,cAAc,CACvB,KAAK,CAAC,IAA0B,EAChC,KAAK,CAAC,OAAO,EACZ,KAA+B,CAAC,OAAO,CACzC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,cAAc,CAAC,kBAAkB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAiBA,MAAM,OAAO,cAAe,SAAQ,KAAK;IACrB,IAAI,CAAqB;IAClC,OAAO,CAAU;IAE1B,YAAY,IAAwB,EAAE,OAAe,EAAE,OAAiB;QACtE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,iEAAiE;IACjE,MAAM,CAAC,IAAI,CAAC,KAAc;QACxB,IAAI,KAAK,YAAY,cAAc;YAAE,OAAO,KAAK,CAAC;QAClD,IAAI,KAAK,YAAY,KAAK,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3D,OAAO,IAAI,cAAc,CACvB,KAAK,CAAC,IAA0B,EAChC,KAAK,CAAC,OAAO,EACZ,KAA+B,CAAC,OAAO,CACzC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,cAAc,CAAC,kBAAkB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["export type SealpixelErrorCode =\n | 'SOURCE_MISMATCH'\n | 'INVALID_EDIT_LOG'\n | 'UNKNOWN_PLUGIN'\n | 'OPTION_VIOLATION'\n | 'ABORTED'\n | 'NO_SOURCE'\n | 'NOT_RESIDENT'\n | 'DOWNLOAD_UNSUPPORTED'\n | 'KERNEL_FAILED'\n | 'INVALID_REQUEST'\n | 'SOURCE_UNAVAILABLE'\n | 'FORBIDDEN_SOURCE'\n | 'FORBIDDEN_DESTINATION'\n | 'TIMEOUT'\n | import('@sealpixel/wasm').SealpixelErrorCode;\n\nexport class SealpixelError extends Error {\n override readonly name: SealpixelErrorCode;\n readonly details: unknown;\n\n constructor(code: SealpixelErrorCode, message: string, details?: unknown) {\n super(message);\n this.name = code;\n this.details = details;\n }\n\n /** Re-throws core errors unchanged and wraps everything else. */\n static from(error: unknown): SealpixelError {\n if (error instanceof SealpixelError) return error;\n if (error instanceof Error && /^[A-Z_]+$/.test(error.name)) {\n return new SealpixelError(\n error.name as SealpixelErrorCode,\n error.message,\n (error as { details?: unknown }).details,\n );\n }\n return new SealpixelError('INVALID_EDIT_LOG', String(error));\n }\n}\n"]}
@@ -10,4 +10,3 @@ import type { AnyPlugin, KernelContext, StageParams } from './plugin.js';
10
10
  export declare function runExternalKernel(plugin: AnyPlugin, image: RgbaBuffer, params: StageParams, ctx: KernelContext): Promise<RgbaBuffer>;
11
11
  /** Drops cached kernel instances (tests, hot reload). */
12
12
  export declare function resetExternalKernels(): void;
13
- //# sourceMappingURL=external-kernel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-kernel.js","sourceRoot":"","sources":["../src/external-kernel.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAiB7C,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkC,CAAC;AAE5D,qDAAqD;AACrD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAiB,EACjB,KAAiB,EACjB,MAAmB,EACnB,GAAkB;IAElB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAChE,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,cAAc,CACtB,kBAAkB,EAClB,WAAW,MAAM,CAAC,EAAE,uCAAuC,CAC5D,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,WAAW,GAAG,IAAI,WA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MAAM,IAAI,EAAE,CAAC;YAC5B,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC3D,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAmC,CAAC;YAC7D,KAAK,MAAM,IAAI,IAAI;gBACjB,QAAQ;gBACR,iBAAiB;gBACjB,gBAAgB;gBAChB,eAAe;aACP,EAAE,CAAC;gBACX,IAAI,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE,CAAC;oBACvB,MAAM,IAAI,cAAc,CACtB,eAAe,EACf,WAAW,EAAE,iCAAiC,IAAI,GAAG,CACtD,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,EAAE,EAAE,IAAI,CAAC,CAAC;YAClD,IAAI,GAAG,KAAK,CAAC;gBACX,MAAM,IAAI,cAAc,CACtB,eAAe,EACf,WAAW,EAAE,gBAAgB,GAAG,mBAAmB,CACpD,CAAC;YACJ,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACnB,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACrB,MAAM,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QACH,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,oBAAoB;IAClC,SAAS,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC","sourcesContent":["/**\n * Runs third-party kernels between core segments: JavaScript functions, or\n * WebAssembly modules implementing the Sealpixel kernel ABI v1\n * (`sealpixel_alloc`, `sealpixel_free`, `sealpixel_run`, `sealpixel_kernel_abi`).\n * WASM kernels transform the RGBA buffer in place; dimensions never change.\n */\nimport type { RgbaBuffer } from '@sealpixel/wasm';\nimport { SealpixelError } from './errors.js';\nimport type { AnyPlugin, KernelContext, StageParams } from './plugin.js';\n\ninterface KernelExports {\n memory: WebAssembly.Memory;\n sealpixel_alloc(len: number): number;\n sealpixel_free(ptr: number, len: number): void;\n sealpixel_run(\n imgPtr: number,\n width: number,\n height: number,\n paramsPtr: number,\n paramsLen: number,\n ): number;\n sealpixel_kernel_abi?(): number;\n}\n\nconst instances = new Map<string, Promise<KernelExports>>();\n\n/** Runs `plugin.kernel` on `image` with `params`. */\nexport async function runExternalKernel(\n plugin: AnyPlugin,\n image: RgbaBuffer,\n params: StageParams,\n ctx: KernelContext,\n): Promise<RgbaBuffer> {\n const kernel = plugin.kernel;\n if (kernel.kind === 'js') return kernel.run(image, params, ctx);\n if (kernel.kind !== 'wasm') {\n throw new SealpixelError(\n 'INVALID_EDIT_LOG',\n `plugin \"${plugin.id}\" has a core kernel but no core stage`,\n );\n }\n const exports = await instantiate(plugin.id, kernel.module);\n const paramsBytes = new TextEncoder().encode(JSON.stringify(params));\n const len = image.data.byteLength;\n const imgPtr = exports.sealpixel_alloc(len);\n const paramsPtr = exports.sealpixel_alloc(paramsBytes.byteLength);\n try {\n new Uint8Array(exports.memory.buffer, imgPtr, len).set(image.data);\n new Uint8Array(exports.memory.buffer, paramsPtr, paramsBytes.byteLength).set(paramsBytes);\n const status = exports.sealpixel_run(\n imgPtr,\n image.width,\n image.height,\n paramsPtr,\n paramsBytes.byteLength,\n );\n if (status !== 0) {\n throw new SealpixelError('KERNEL_FAILED', `plugin \"${plugin.id}\" kernel returned ${status}`, {\n status,\n });\n }\n // Re-read the buffer: memory may have grown and detached the old view.\n const out = new Uint8Array(len);\n out.set(new Uint8Array(exports.memory.buffer, imgPtr, len));\n return { width: image.width, height: image.height, data: out };\n } finally {\n exports.sealpixel_free(imgPtr, len);\n exports.sealpixel_free(paramsPtr, paramsBytes.byteLength);\n }\n}\n\nfunction instantiate(id: string, load: () => Promise<WebAssembly.Module>): Promise<KernelExports> {\n let pending = instances.get(id);\n if (!pending) {\n pending = (async () => {\n const module = await load();\n const instance = await WebAssembly.instantiate(module, {});\n const exports = instance.exports as unknown as KernelExports;\n for (const name of [\n 'memory',\n 'sealpixel_alloc',\n 'sealpixel_free',\n 'sealpixel_run',\n ] as const) {\n if (!(name in exports)) {\n throw new SealpixelError(\n 'KERNEL_FAILED',\n `plugin \"${id}\" kernel module lacks export \"${name}\"`,\n );\n }\n }\n const abi = exports.sealpixel_kernel_abi?.() ?? 1;\n if (abi !== 1)\n throw new SealpixelError(\n 'KERNEL_FAILED',\n `plugin \"${id}\" kernel ABI ${abi} is not supported`,\n );\n return exports;\n })().catch((error) => {\n instances.delete(id);\n throw error;\n });\n instances.set(id, pending);\n }\n return pending;\n}\n\n/** Drops cached kernel instances (tests, hot reload). */\nexport function resetExternalKernels(): void {\n instances.clear();\n}\n"]}
@@ -30,4 +30,3 @@ export type StageGeometry = {
30
30
  */
31
31
  cropRect?: [number, number, number, number];
32
32
  };
33
- //# sourceMappingURL=geometry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/generated/geometry.ts"],"names":[],"mappings":"AAAA,kFAAkF"}
1
+ {"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/generated/geometry.ts"],"names":[],"mappings":"AAAA,kFAAkF","sourcesContent":["// Generated by scripts/gen-plan-types.sh from crates/sealpixel-core. Do not edit.\n\n// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n\nexport type Geometry = { stages: Array<StageGeometry>, logicalOut: Size, actualOut: Size, \n/**\n * `actual_in.width / logical_in.width` of the source: the buffer scale.\n */\nscale: number, };\n\nexport type Size = { width: number, height: number, };\n\n/**\n * Geometry of one stage in both coordinate systems.\n */\nexport type StageGeometry = { name: string, logicalIn: Size, logicalOut: Size, actualIn: Size, actualOut: Size, \n/**\n * Crop only: maps actual output pixel coordinates to actual input pixel\n * coordinates (inverse mapping, what the sampler needs).\n */\ntransform?: [number, number, number, number, number, number], \n/**\n * Resize with `cover`: the source rectangle (actual px) that is scaled to the output.\n */\ncropRect?: [number, number, number, number], };\n"]}
@@ -37,4 +37,3 @@ export type OutputOptions = {
37
37
  */
38
38
  embed?: string;
39
39
  };
40
- //# sourceMappingURL=output.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/generated/output.ts"],"names":[],"mappings":"AAAA,kFAAkF"}
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/generated/output.ts"],"names":[],"mappings":"AAAA,kFAAkF","sourcesContent":["// Generated by scripts/gen-plan-types.sh from crates/sealpixel-core. Do not edit.\n\n// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n\n/**\n * JPEG chroma subsampling.\n */\nexport type ChromaSubsampling = \"4:2:0\" | \"4:4:4\";\n\n/**\n * Output container format.\n */\nexport type Format = \"png\" | \"jpeg\" | \"webp\";\n\n/**\n * Encoder parameters. Mirrors `RenderOptions.output` on the TypeScript side.\n */\nexport type OutputOptions = { format: Format, \n/**\n * 0.0..=1.0, lossy formats only. Ignored by PNG and lossless WebP.\n */\nquality?: number, \n/**\n * JPEG only.\n */\nprogressive?: boolean, \n/**\n * JPEG only.\n */\nchromaSubsampling?: ChromaSubsampling, \n/**\n * WebP only. V1 always encodes lossless; `false` is accepted and treated as lossless.\n */\nlossless?: boolean, \n/**\n * Opaque colour alpha is flattened onto for formats without alpha (JPEG).\n */\nbackground?: [number, number, number], \n/**\n * UTF-8 text stored in the container's metadata (PNG iTXt, JPEG XMP,\n * WebP XMP). Sealpixel stores the canonical edit log here. Pixels are unaffected.\n */\nembed?: string, };\n"]}
@@ -301,4 +301,3 @@ export type WatermarkStage = {
301
301
  opacity?: number;
302
302
  tile?: Tile;
303
303
  };
304
- //# sourceMappingURL=plan.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/generated/plan.ts"],"names":[],"mappings":"AAAA,kFAAkF"}
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/generated/plan.ts"],"names":[],"mappings":"AAAA,kFAAkF","sourcesContent":["// Generated by scripts/gen-plan-types.sh from crates/sealpixel-core. Do not edit.\n\n// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n\nexport type Anchor = \"tl\" | \"tc\" | \"tr\" | \"cl\" | \"c\" | \"cr\" | \"bl\" | \"bc\" | \"br\";\n\n/**\n * Draws shapes and text over the image in image space.\n */\nexport type AnnotateStage = { shapes?: Array<Shape>, };\n\n/**\n * Colour adjustments. All parameters are identity at their defaults.\n */\nexport type ColorStage = { brightness?: number, contrast?: number, saturation?: number, exposure?: number, gamma?: number, clarity?: number, vignette?: number, \n/**\n * 4x5 colour matrix (rows r, g, b, a; columns r, g, b, a, offset). Identity when absent.\n */\nmatrix?: [[number, number, number, number, number], [number, number, number, number, number], [number, number, number, number, number], [number, number, number, number, number]], \n/**\n * Blend between identity (0) and the matrix (1).\n */\nstrength?: number, };\n\n/**\n * Shape that keeps its interior; everything outside becomes transparent.\n */\nexport type CropMask = \"circle\";\n\n/**\n * Flip, rotate about the centre, then crop a rectangle of the rotated bounding box.\n */\nexport type CropStage = { \n/**\n * Radians, clockwise positive in image space (y down).\n */\nrotation?: number, flipX?: boolean, flipY?: boolean, \n/**\n * In rotated-bounding-box space, 0..1.\n */\nrect?: Rect, \n/**\n * Colour for areas outside the source. Transparent when absent.\n */\nfill?: [number, number, number, number], \n/**\n * Alpha mask applied to the crop output, for round avatars. Absent = none.\n */\nmask?: CropMask, };\n\nexport type Fit = \"contain\" | \"cover\" | \"fill\";\n\nexport type FrameKind = \"solid\" | \"inset\" | \"polaroid\";\n\n/**\n * Draws a frame inside the image bounds. Dimensions do not change.\n */\nexport type FrameStage = { \n/**\n * Named `style` because `kind` is the stage discriminator.\n */\nstyle: FrameKind, color: [number, number, number, number], \n/**\n * Logical pixels.\n */\nthickness: number, \n/**\n * Corner radius of the inner edge, logical pixels.\n */\nradius?: number, };\n\n/**\n * Normalised rectangle, 0..1 in the space named by the stage.\n */\nexport type Rect = { x: number, y: number, width: number, height: number, };\n\nexport type RedactMode = \"pixelate\" | \"blur\" | \"mosaic\";\n\n/**\n * Pixelate, blur or mosaic regions. Coordinates are in the stage input's image space.\n */\nexport type RedactStage = { regions?: Array<Redaction>, };\n\nexport type Redaction = { region: Region, mode: RedactMode, \n/**\n * Pixelate or mosaic cell size, or blur diameter, in logical source pixels.\n */\namount: number, };\n\n/**\n * A region in normalised image space.\n */\nexport type Region = { \"kind\": \"rect\", rect: Rect, } | { \"kind\": \"path\", points: Array<[number, number]>, };\n\n/**\n * The flat, versioned plan the executor runs. This is not the edit log: the\n * TypeScript `compile()` reduces the log to this structure.\n */\nexport type RenderPlan = { version: number, source: SourceInfo, \n/**\n * 1.0 for a truth render, below 1.0 when the buffer is a working copy.\n */\nbufferScale: number, stages?: Array<Stage>, };\n\n/**\n * Scale to a target size in logical output pixels.\n */\nexport type ResizeStage = { width?: number, height?: number, fit?: Fit, upscale?: boolean, };\n\n/**\n * A vector shape in normalised image space. Lengths are logical source pixels.\n */\nexport type Shape = { \"kind\": \"rect\", rect: Rect, stroke?: Stroke, fill?: [number, number, number, number], \n/**\n * Corner radius in logical pixels.\n */\nradius?: number, \n/**\n * Radians, clockwise, about the rect centre.\n */\nrotation?: number, } | { \"kind\": \"ellipse\", rect: Rect, stroke?: Stroke, fill?: [number, number, number, number], \n/**\n * Radians, clockwise, about the rect centre.\n */\nrotation?: number, } | { \"kind\": \"line\", from: [number, number], to: [number, number], stroke: Stroke, } | { \"kind\": \"arrow\", from: [number, number], to: [number, number], stroke: Stroke, \n/**\n * Head length in logical pixels; defaults to four stroke widths.\n */\nhead?: number, } | { \"kind\": \"path\", points: Array<[number, number]>, stroke: Stroke, closed?: boolean, fill?: [number, number, number, number], } | { \"kind\": \"text\", \n/**\n * Top-left anchor and wrap width. Height is advisory for the UI.\n */\nrect: Rect, text: string, \n/**\n * Asset id of a TrueType or OpenType font.\n */\nfont: string, \n/**\n * Font size in logical pixels.\n */\nsize: number, color: [number, number, number, number], align?: TextAlign, \n/**\n * Multiplier of the font size.\n */\nlineHeight?: number, background?: [number, number, number, number], \n/**\n * Background padding in logical pixels.\n */\npadding?: number, \n/**\n * Radians, clockwise, about the rect centre.\n */\nrotation?: number, };\n\n/**\n * Logical (full-resolution) dimensions of the source image after EXIF\n * orientation. The buffer handed to the executor may be a smaller working copy.\n */\nexport type SourceInfo = { width: number, height: number, };\n\n/**\n * One stage of the fixed-order pipeline. An absent stage is the identity.\n * Order is enforced by the TypeScript compiler, not by the executor.\n */\nexport type Stage = { \"kind\": \"color\" } & ColorStage | { \"kind\": \"redact\" } & RedactStage | { \"kind\": \"annotate\" } & AnnotateStage | { \"kind\": \"crop\" } & CropStage | { \"kind\": \"sticker\" } & StickerStage | { \"kind\": \"frame\" } & FrameStage | { \"kind\": \"watermark\" } & WatermarkStage | { \"kind\": \"resize\" } & ResizeStage;\n\n/**\n * An image asset placed in crop space.\n */\nexport type Sticker = { \n/**\n * Asset id of a PNG, JPEG or WebP.\n */\nasset: string, \n/**\n * Placement in crop space, 0..1.\n */\nrect: Rect, \n/**\n * Radians, clockwise, about the rect centre.\n */\nrotation?: number, opacity?: number, flipX?: boolean, flipY?: boolean, };\n\nexport type StickerStage = { items?: Array<Sticker>, };\n\n/**\n * Stroke style. Width is in logical source pixels.\n */\nexport type Stroke = { color: [number, number, number, number], width: number, };\n\nexport type TextAlign = \"left\" | \"center\" | \"right\";\n\nexport type Tile = { \n/**\n * Gaps between tiles, logical pixels.\n */\ngapX: number, gapY: number, \n/**\n * Radians, applied to every tile about its centre.\n */\nrotation?: number, };\n\nexport type WatermarkSource = { \"kind\": \"asset\", asset: string, } | { \"kind\": \"text\", text: string, font: string, color: [number, number, number, number], };\n\n/**\n * One stamp (image or text) at an anchor, or tiled across the image.\n */\nexport type WatermarkStage = { source: WatermarkSource, anchor?: Anchor, \n/**\n * Distance from the edges, logical pixels.\n */\nmargin?: number, \n/**\n * Stamp width as a fraction of the image width (text: font size as a fraction).\n */\nscale?: number, opacity?: number, tile?: Tile, };\n"]}
package/dist/history.d.ts CHANGED
@@ -15,4 +15,3 @@ export declare function undo(history: History): History;
15
15
  export declare function redo(history: History): History;
16
16
  /** A non-finite `index`, such as `NaN` from a failed parse, leaves the history unchanged. */
17
17
  export declare function timeTravel(history: History, index: number): History;
18
- //# sourceMappingURL=history.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"history.js","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAEA,8FAA8F;AAC9F,MAAM,UAAU,aAAa,CAAC,GAAY,EAAE,QAAgB,GAAG,CAAC,GAAG,CAAC,MAAM;IACxE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;AAC1F,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,OAAO,CAAC,OAAgB;IACtC,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAgB,EAAE,EAAa;IACtD,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC/B,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAAE,OAAO,OAAO,CAAC;IACtE,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAA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AgB;IACtC,OAAO,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,OAAgB;IACtC,OAAO,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,OAAgB;IACnC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,OAAgB;IACnC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AAC/E,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,UAAU,CAAC,OAAgB,EAAE,KAAa;IACxD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAC5C,OAAO,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AAC/D,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,GAAY;IAC7C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import type { EditLog, History, Operation } from './types.js';\n\n/** A non-finite `index`, such as `NaN`, counts as no index: the history starts at the end. */\nexport function createHistory(log: EditLog, index: number = log.ops.length): History {\n return { log, index: clampIndex(Number.isFinite(index) ? index : log.ops.length, log) };\n}\n\n/** The log as of the current position: `ops[0..index)`. */\nexport function current(history: History): EditLog {\n return { ...history.log, ops: history.log.ops.slice(0, history.index) };\n}\n\n/**\n * Appends `op` at the current position, discarding any redo tail. An op whose\n * id already exists anywhere in the log is ignored, which makes retried\n * dispatches idempotent.\n */\nexport function dispatch(history: History, op: Operation): History {\n const { log, index } = history;\n if (log.ops.some((existing) => existing.id === op.id)) return history;\n const ops = [...log.ops.slice(0, index), op];\n return { log: { ...log, ops }, index: ops.length };\n}\n\nexport function canUndo(history: History): boolean {\n return history.index > 0;\n}\n\nexport function canRedo(history: History): boolean {\n return history.index < history.log.ops.length;\n}\n\nexport function undo(history: History): History {\n return canUndo(history) ? { ...history, index: history.index - 1 } : history;\n}\n\nexport function redo(history: History): History {\n return canRedo(history) ? { ...history, index: history.index + 1 } : history;\n}\n\n/** A non-finite `index`, such as `NaN` from a failed parse, leaves the history unchanged. */\nexport function timeTravel(history: History, index: number): History {\n if (!Number.isFinite(index)) return history;\n return { ...history, index: clampIndex(index, history.log) };\n}\n\nfunction clampIndex(index: number, log: EditLog): number {\n return Math.max(0, Math.min(Math.floor(index), log.ops.length));\n}\n"]}
@@ -11,4 +11,3 @@ export declare function readImageSize(bytes: Uint8Array): ImageSize;
11
11
  * encoder. Lambda sizes: 12 MP needs 1024 MB, 24 MP 1769 MB, 50 MP 2048 MB.
12
12
  */
13
13
  export declare function estimateMemoryMB(width: number, height: number): number;
14
- //# sourceMappingURL=image-size.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-size.js","sourceRoot":"","sources":["../src/image-size.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQ7C,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CA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Y,IAAI,CAAC,CAAC,GAAG,CAAE,KAAK,CAAC,EAAE,CAAY,IAAI,EAAE,CAAC,CAAC,CAAC;YAC7F,MAAM,MAAM,GACV,CAAC,GAAG,CAAE,KAAK,CAAC,EAAE,CAAY,GAAG,CAAE,KAAK,CAAC,EAAE,CAAY,IAAI,CAAC,CAAC,GAAG,CAAE,KAAK,CAAC,EAAE,CAAY,IAAI,EAAE,CAAC,CAAC,CAAC;YAC7F,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;QACnD,CAAC;IACH,CAAC;IACD,MAAM,IAAI,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,CAAC;AACtE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,MAAc;IAC5D,MAAM,UAAU,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,KAAK,CAAC,KAAiB,EAAE,KAAa,EAAE,GAAW;IAC1D,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE;QAAE,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAW,CAAC,CAAC;IAC/E,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/**\n * Reads width, height and container from the first bytes of a PNG, JPEG or\n * WebP without decoding pixels. Used to enforce size limits before decoding.\n * EXIF orientation is not applied; callers only need the pixel count.\n */\nimport { SealpixelError } from './errors.js';\n\nexport interface ImageSize {\n width: number;\n height: number;\n mimeType: 'image/png' | 'image/jpeg' | 'image/webp';\n}\n\nexport function readImageSize(bytes: Uint8Array): ImageSize {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n if (\n bytes.length >= 24 &&\n bytes[0] === 0x89 &&\n bytes[1] === 0x50 &&\n bytes[2] === 0x4e &&\n bytes[3] === 0x47\n ) {\n return { width: view.getUint32(16), height: view.getUint32(20), mimeType: 'image/png' };\n }\n if (bytes.length >= 4 && bytes[0] === 0xff && bytes[1] === 0xd8) {\n let pos = 2;\n while (pos + 9 < bytes.length) {\n if (bytes[pos] !== 0xff) {\n pos++;\n continue;\n }\n const marker = bytes[pos + 1] as number;\n if (\n marker === 0xd8 ||\n (marker >= 0xd0 && marker <= 0xd7) ||\n marker === 0x01 ||\n marker === 0xff\n ) {\n pos += marker === 0xff ? 1 : 2;\n continue;\n }\n const len = view.getUint16(pos + 2);\n const isSof =\n marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;\n if (isSof) {\n return {\n height: view.getUint16(pos + 5),\n width: view.getUint16(pos + 7),\n mimeType: 'image/jpeg',\n };\n }\n if (marker === 0xd9 || marker === 0xda) break;\n pos += 2 + len;\n }\n throw new SealpixelError('DECODE_FAILED', 'JPEG has no frame header');\n }\n if (bytes.length >= 30 && ascii(bytes, 0, 4) === 'RIFF' && ascii(bytes, 8, 12) === 'WEBP') {\n const chunk = ascii(bytes, 12, 16);\n if (chunk === 'VP8 ') {\n return {\n width: view.getUint16(26, true) & 0x3fff,\n height: view.getUint16(28, true) & 0x3fff,\n mimeType: 'image/webp',\n };\n }\n if (chunk === 'VP8L') {\n const b0 = bytes[21] as number;\n const b1 = bytes[22] as number;\n const b2 = bytes[23] as number;\n const b3 = bytes[24] as number;\n const width = 1 + (((b1 & 0x3f) << 8) | b0);\n const height = 1 + (((b3 & 0x0f) << 10) | (b2 << 2) | ((b1 & 0xc0) >> 6));\n return { width, height, mimeType: 'image/webp' };\n }\n if (chunk === 'VP8X') {\n const width =\n 1 + ((bytes[24] as number) | ((bytes[25] as number) << 8) | ((bytes[26] as number) << 16));\n const height =\n 1 + ((bytes[27] as number) | ((bytes[28] as number) << 8) | ((bytes[29] as number) << 16));\n return { width, height, mimeType: 'image/webp' };\n }\n }\n throw new SealpixelError('UNSUPPORTED_FORMAT', 'unknown container');\n}\n\n/**\n * Peak memory a server render needs: 24 bytes per pixel, six RGBA buffers of\n * the image, plus the runtime. Measured on Node 24: 12 wasm bytes per pixel\n * for the heaviest stage, the decoded and the rendered image in JS, and the\n * encoder. Lambda sizes: 12 MP needs 1024 MB, 24 MP 1769 MB, 50 MP 2048 MB.\n */\nexport function estimateMemoryMB(width: number, height: number): number {\n const megapixels = (width * height) / 1e6;\n return Math.ceil(megapixels * 6 * 4 + 256);\n}\n\nfunction ascii(bytes: Uint8Array, start: number, end: number): string {\n let s = '';\n for (let i = start; i < end; i++) s += String.fromCharCode(bytes[i] as number);\n return s;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -7,11 +7,12 @@ export { resetExternalKernels, runExternalKernel } from './external-kernel.js';
7
7
  export { canRedo, canUndo, createHistory, current, dispatch, redo, timeTravel, undo, } from './history.js';
8
8
  export { estimateMemoryMB, type ImageSize, readImageSize } from './image-size.js';
9
9
  export { InlineRenderer } from './inline-renderer.js';
10
+ export { editLogHash, MANIFEST_VERSION, parseRenderManifest, type RendererIdentity, type RenderManifest, RenderManifestSchema, renderHash, } from './manifest.js';
10
11
  export { configurePlugins, type PluginOptionsMap, pluginOptionsOf } from './options.js';
11
12
  export { type ChromaSubsampling, type ColorStage, type CoreFormat, type CoreOutputOptions, type CropStage, type Fit, type Geometry, PLAN_VERSION, type PlanRect, type RenderPlan, type ResizeStage, type Size, type SourceInfo, type Stage, type StageGeometry, toRenderPlan, } from './plan.js';
12
13
  export type * from './plugin.js';
13
14
  export { createRegistry, type ParseIssue, type ParseOptions, type ParseResult, type RegisteredOperation, type Registry, } from './registry.js';
14
- export { type PipelineOptions, render, runPipeline, toCoreOutput } from './render.js';
15
+ export { fromCoreOutput, type PipelineOptions, render, runPipeline, toCoreOutput, } from './render.js';
15
16
  export type { Renderer } from './renderer.js';
16
17
  export { type ExportRequest, type ExportResult, type LoadedSource, RendererCore, type RendererCoreOptions, type RendererLoadOptions, type RenderRequest, } from './renderer-core.js';
17
18
  export { browserSaveFile, createEditorSession, type DownloadOptions, type EditorSession, type ExportOptions, type LoadOptions, type LoadSource, type PreviewState, type SessionOptions, type SessionState, } from './session.js';
@@ -21,4 +22,3 @@ export { WorkerRenderer } from './worker-renderer.js';
21
22
  import type { EditLog, SourceDescriptor } from './types.js';
22
23
  /** Creates an empty edit log for `source`, recording the registered plugin versions. */
23
24
  export declare function createEditLog(source: SourceDescriptor, registry?: import('./registry.js').Registry): EditLog;
24
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -7,10 +7,11 @@ export { resetExternalKernels, runExternalKernel } from './external-kernel.js';
7
7
  export { canRedo, canUndo, createHistory, current, dispatch, redo, timeTravel, undo, } from './history.js';
8
8
  export { estimateMemoryMB, readImageSize } from './image-size.js';
9
9
  export { InlineRenderer } from './inline-renderer.js';
10
+ export { editLogHash, MANIFEST_VERSION, parseRenderManifest, RenderManifestSchema, renderHash, } from './manifest.js';
10
11
  export { configurePlugins, pluginOptionsOf } from './options.js';
11
12
  export { PLAN_VERSION, toRenderPlan, } from './plan.js';
12
13
  export { createRegistry, } from './registry.js';
13
- export { render, runPipeline, toCoreOutput } from './render.js';
14
+ export { fromCoreOutput, render, runPipeline, toCoreOutput, } from './render.js';
14
15
  export { RendererCore, } from './renderer-core.js';
15
16
  export { browserSaveFile, createEditorSession, } from './session.js';
16
17
  export { transferablesOf, webTransport, } from './worker-protocol.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,M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sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,wFAAwF;AACxF,MAAM,UAAU,aAAa,CAC3B,MAAwB,EACxB,QAA2C;IAE3C,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AACpF,CAAC","sourcesContent":["export {\n type AssetResolver,\n type AssetResolverOptions,\n createAssetResolver,\n missingAssetId,\n staticAssetResolver,\n wasmSha256,\n webCryptoSha256,\n withAssets,\n} from './assets.js';\nexport { canonicalJson } from './canonical-json.js';\nexport { compile, type PipelineStage, toCoreStages, toPipeline } from './compile.js';\nexport { PNG_KEYWORD, readEmbeddedEditLog, readEmbeddedState } from './embedded.js';\nexport { SealpixelError, type SealpixelErrorCode } from './errors.js';\nexport { resetExternalKernels, runExternalKernel } from './external-kernel.js';\nexport {\n canRedo,\n canUndo,\n createHistory,\n current,\n dispatch,\n redo,\n timeTravel,\n undo,\n} from './history.js';\nexport { estimateMemoryMB, type ImageSize, readImageSize } from './image-size.js';\nexport { InlineRenderer } from './inline-renderer.js';\nexport {\n editLogHash,\n MANIFEST_VERSION,\n parseRenderManifest,\n type RendererIdentity,\n type RenderManifest,\n RenderManifestSchema,\n renderHash,\n} from './manifest.js';\nexport { configurePlugins, type PluginOptionsMap, pluginOptionsOf } from './options.js';\nexport {\n type ChromaSubsampling,\n type ColorStage,\n type CoreFormat,\n type CoreOutputOptions,\n type CropStage,\n type Fit,\n type Geometry,\n PLAN_VERSION,\n type PlanRect,\n type RenderPlan,\n type ResizeStage,\n type Size,\n type SourceInfo,\n type Stage,\n type StageGeometry,\n toRenderPlan,\n} from './plan.js';\nexport type * from './plugin.js';\nexport {\n createRegistry,\n type ParseIssue,\n type ParseOptions,\n type ParseResult,\n type RegisteredOperation,\n type Registry,\n} from './registry.js';\nexport {\n fromCoreOutput,\n type PipelineOptions,\n render,\n runPipeline,\n toCoreOutput,\n} from './render.js';\nexport type { Renderer } from './renderer.js';\nexport {\n type ExportRequest,\n type ExportResult,\n type LoadedSource,\n RendererCore,\n type RendererCoreOptions,\n type RendererLoadOptions,\n type RenderRequest,\n} from './renderer-core.js';\nexport {\n browserSaveFile,\n createEditorSession,\n type DownloadOptions,\n type EditorSession,\n type ExportOptions,\n type LoadOptions,\n type LoadSource,\n type PreviewState,\n type SessionOptions,\n type SessionState,\n} from './session.js';\nexport type * from './types.js';\nexport {\n type Transport,\n transferablesOf,\n type WorkerRequest,\n type WorkerResponse,\n webTransport,\n} from './worker-protocol.js';\nexport { WorkerRenderer } from './worker-renderer.js';\n\nimport type { EditLog, SourceDescriptor } from './types.js';\n\n/** Creates an empty edit log for `source`, recording the registered plugin versions. */\nexport function createEditLog(\n source: SourceDescriptor,\n registry?: import('./registry.js').Registry,\n): EditLog {\n return { version: 1, source, plugins: registry?.pluginVersions() ?? {}, ops: [] };\n}\n"]}
@@ -25,4 +25,3 @@ export declare class InlineRenderer implements Renderer {
25
25
  /** For tests. */
26
26
  coreForTest(): Promise<RendererCore>;
27
27
  }
28
- //# sourceMappingURL=inline-renderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inline-renderer.js","sourceRoot":"","sources":["../src/inline-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAuC,MAAM,iBAAiB,CAAC;AAEzF,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAG5B,kHAAkH;AAClH,MAAM,OAAO,cAAc;IACjB,IAAI,GAAwB,IAAI,CAAC;IACxB,KAAK,CAAwB;IAE9C,YAAY,OAAuD;QACjE,IAAI,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CACpF,C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AAiB;IACjB,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { loadSealpixelWasm, type RgbaBuffer, type SealpixelWasm } from '@sealpixel/wasm';\nimport type { Renderer } from './renderer.js';\nimport {\n RendererCore,\n type RendererCoreOptions,\n type RendererLoadOptions,\n} from './renderer-core.js';\nimport type { SourceDescriptor } from './types.js';\n\n/** Runs the renderer on the calling thread. Fallback where Workers are unavailable, and the server's renderer. */\nexport class InlineRenderer implements Renderer {\n private core: RendererCore | null = null;\n private readonly ready: Promise<RendererCore>;\n\n constructor(options: RendererCoreOptions & { wasm?: SealpixelWasm }) {\n this.ready = (options.wasm ? Promise.resolve(options.wasm) : loadSealpixelWasm()).then(\n (wasm) => {\n this.core = new RendererCore(wasm, options);\n return this.core;\n },\n );\n }\n\n async init() {\n return (await this.ready).info();\n }\n async load(bytes: Uint8Array, id: string, options?: RendererLoadOptions) {\n return (await this.ready).load(bytes, id, options);\n }\n async loadWorkingCopy(workingCopy: RgbaBuffer, descriptor: SourceDescriptor) {\n return (await this.ready).loadWorkingCopy(workingCopy, descriptor);\n }\n async loadWorkingCopyEncoded(bytes: Uint8Array, descriptor: SourceDescriptor) {\n return (await this.ready).loadWorkingCopyEncoded(bytes, descriptor);\n }\n async render(req: Parameters<Renderer['render']>[0]) {\n return (await this.ready).render(req);\n }\n async export(req: Parameters<Renderer['export']>[0]) {\n return (await this.ready).export(req);\n }\n async geometry(req: Parameters<Renderer['geometry']>[0]) {\n return (await this.ready).geometry(req.log, req.target, req.upTo);\n }\n async unload() {\n (await this.ready).unload();\n }\n async putAsset(id: string, bytes: Uint8Array) {\n (await this.ready).putAsset(id, bytes);\n }\n dispose() {\n this.core?.unload();\n }\n /** For tests. */\n async coreForTest(): Promise<RendererCore> {\n return this.ready;\n }\n}\n"]}
@@ -0,0 +1,127 @@
1
+ import { z } from 'zod';
2
+ import type { RenderPlan } from './plan.js';
3
+ import type { EditLog } from './types.js';
4
+ /**
5
+ * The render manifest: what a render was made from and the hash of what it
6
+ * produced, so that anyone with the original can check the result later.
7
+ *
8
+ * Version 1. `render({ manifest: true })` writes it, `verify()` in
9
+ * `@sealpixel/render` and `sealpixel verify` in the native CLI read it. The
10
+ * fields are public API: a field is added with a default, never renamed or
11
+ * removed, and an incompatible change bumps `version`. The native CLI's
12
+ * `sealpixel_core::manifest` is the same format.
13
+ */
14
+ export declare const MANIFEST_VERSION = 1;
15
+ /** Which build produced the pixels. `kind` is `wasm` here, `native` for the CLI. */
16
+ export interface RendererIdentity {
17
+ kind: 'wasm' | 'native';
18
+ version: string;
19
+ /** sha256 of the WebAssembly binary or the native executable, when the loader saw its bytes. */
20
+ binarySha256: string | null;
21
+ }
22
+ export interface RenderManifest {
23
+ version: 1;
24
+ source: {
25
+ /** The size after EXIF orientation, as the edit log states it. */
26
+ width: number;
27
+ height: number;
28
+ /** sha256 of the original's bytes. */
29
+ hash: string;
30
+ mimeType?: string;
31
+ };
32
+ /** `{ log, index }` as the editor keeps it. Absent in a manifest the native CLI wrote. */
33
+ editLog?: {
34
+ log: EditLog;
35
+ index: number;
36
+ };
37
+ /** sha256 of `editLog` in canonical JSON: the text `embedEditLog` stores in a file. */
38
+ editLogHash?: string;
39
+ /** The core plan, when every stage of the render ran in the core. */
40
+ plan?: RenderPlan;
41
+ /** The stages that ran outside the core, when any did: then there is no `plan`. */
42
+ kernels?: string[];
43
+ /** The plugin versions the log was compiled with. */
44
+ plugins: Record<string, number>;
45
+ renderer: RendererIdentity;
46
+ output: {
47
+ /** The encoder options in the core's form: `{ "format": "png", ... }`, never with `embed`. */
48
+ options: Record<string, unknown>;
49
+ /** The file holds the edit log, as `embedEditLog: true` stores it. */
50
+ embedEditLog?: boolean;
51
+ width: number;
52
+ height: number;
53
+ /** sha256 over the rendered pixels, before encoding. Survives any change to the file. */
54
+ pixelHash: string;
55
+ /** sha256 of the encoded bytes as the renderer wrote them. */
56
+ byteHash: string;
57
+ };
58
+ /** One id for this render. See `renderHash()`. */
59
+ renderHash: string;
60
+ }
61
+ /**
62
+ * The manifest as untrusted input: the shape, the hashes and the numbers. The
63
+ * edit log inside it is only an object here; `verify()` parses it with the
64
+ * registry, and the core checks the plan when it renders.
65
+ */
66
+ export declare const RenderManifestSchema: z.ZodObject<{
67
+ version: z.ZodLiteral<1>;
68
+ source: z.ZodObject<{
69
+ width: z.ZodNumber;
70
+ height: z.ZodNumber;
71
+ hash: z.ZodString;
72
+ mimeType: z.ZodOptional<z.ZodString>;
73
+ }, z.core.$strip>;
74
+ editLog: z.ZodOptional<z.ZodObject<{
75
+ log: z.ZodRecord<z.ZodString, z.ZodUnknown>;
76
+ index: z.ZodNumber;
77
+ }, z.core.$strip>>;
78
+ editLogHash: z.ZodOptional<z.ZodString>;
79
+ plan: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
80
+ kernels: z.ZodOptional<z.ZodArray<z.ZodString>>;
81
+ plugins: z.ZodRecord<z.ZodString, z.ZodNumber>;
82
+ renderer: z.ZodObject<{
83
+ kind: z.ZodEnum<{
84
+ wasm: "wasm";
85
+ native: "native";
86
+ }>;
87
+ version: z.ZodString;
88
+ binarySha256: z.ZodNullable<z.ZodString>;
89
+ }, z.core.$strip>;
90
+ output: z.ZodObject<{
91
+ options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
92
+ embedEditLog: z.ZodOptional<z.ZodBoolean>;
93
+ width: z.ZodNumber;
94
+ height: z.ZodNumber;
95
+ pixelHash: z.ZodString;
96
+ byteHash: z.ZodString;
97
+ }, z.core.$strip>;
98
+ renderHash: z.ZodString;
99
+ }, z.core.$strip>;
100
+ /** Parses an untrusted manifest. Throws `INVALID_REQUEST` with the first problem. */
101
+ export declare function parseRenderManifest(input: unknown): RenderManifest;
102
+ /**
103
+ * The id of a render: a sha256 over the facts the manifest states, in a
104
+ * fixed text form that every runtime builds with string operations alone,
105
+ * so no canonical-JSON rules are needed to agree on it. `verify` does not
106
+ * recompute it; it checks the facts.
107
+ *
108
+ * ```text
109
+ * sealpixel-render/1
110
+ * <source hash>
111
+ * <edit log hash, or the plan hash for a manifest without a log>
112
+ * <plugins as id@version, sorted by id, joined by ','>
113
+ * <renderer kind> <renderer version> <binary sha256 or '-'>
114
+ * <pixel hash>
115
+ * <byte hash>
116
+ * ```
117
+ */
118
+ export declare function renderHash(sha256Hex: (bytes: Uint8Array) => string, facts: {
119
+ sourceHash: string;
120
+ editsHash: string;
121
+ plugins: Record<string, number>;
122
+ renderer: RendererIdentity;
123
+ pixelHash: string;
124
+ byteHash: string;
125
+ }): string;
126
+ /** The hash `editLogHash` and the embedded log share: canonical JSON of `{ log, index }`. */
127
+ export declare function editLogHash(sha256Hex: (bytes: Uint8Array) => string, log: EditLog, index: number): string;