@sealpixel/core 1.0.0-rc.22 → 1.0.0-rc.23

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.
package/dist/plan.d.ts CHANGED
@@ -7,7 +7,7 @@ export type { ColorStage, CropStage, Fit, Rect as PlanRect, RenderPlan, ResizeSt
7
7
  export declare const PLAN_VERSION = 1;
8
8
  /**
9
9
  * Builds the plan for `log` executed on a buffer of `actual` size. Until the
10
- * plugin registry lands (S1.9) every log compiles to the identity plan.
10
+ * plugin registry lands, every log compiles to the identity plan.
11
11
  */
12
12
  export declare function toRenderPlan(log: EditLog, actual: {
13
13
  width: number;
package/dist/plan.js CHANGED
@@ -2,7 +2,7 @@
2
2
  export const PLAN_VERSION = 1;
3
3
  /**
4
4
  * Builds the plan for `log` executed on a buffer of `actual` size. Until the
5
- * plugin registry lands (S1.9) every log compiles to the identity plan.
5
+ * plugin registry lands, every log compiles to the identity plan.
6
6
  */
7
7
  export function toRenderPlan(log, actual, stages = []) {
8
8
  return {
package/dist/plan.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAoBA,oDAAoD;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAE9B;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAY,EACZ,MAAyC,EACzC,SAAkB,EAAE;IAEpB,OAAO;QACL,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE;QAC9D,WAAW,EAAE,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK;QAC5C,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import type { RenderPlan, Stage } from './generated/plan.js';\nimport type { EditLog } from './types.js';\n\nexport type { Geometry, Size, StageGeometry } from './generated/geometry.js';\nexport type {\n ChromaSubsampling,\n Format as CoreFormat,\n OutputOptions as CoreOutputOptions,\n} from './generated/output.js';\nexport type {\n ColorStage,\n CropStage,\n Fit,\n Rect as PlanRect,\n RenderPlan,\n ResizeStage,\n SourceInfo,\n Stage,\n} from './generated/plan.js';\n\n/** Mirrors `sealpixel_core::plan::PLAN_VERSION`. */\nexport const PLAN_VERSION = 1;\n\n/**\n * Builds the plan for `log` executed on a buffer of `actual` size. Until the\n * plugin registry lands (S1.9) every log compiles to the identity plan.\n */\nexport function toRenderPlan(\n log: EditLog,\n actual: { width: number; height: number },\n stages: Stage[] = [],\n): RenderPlan {\n return {\n version: PLAN_VERSION,\n source: { width: log.source.width, height: log.source.height },\n bufferScale: actual.width / log.source.width,\n stages,\n };\n}\n"]}
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAoBA,oDAAoD;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAE9B;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAY,EACZ,MAAyC,EACzC,SAAkB,EAAE;IAEpB,OAAO;QACL,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE;QAC9D,WAAW,EAAE,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK;QAC5C,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import type { RenderPlan, Stage } from './generated/plan.js';\nimport type { EditLog } from './types.js';\n\nexport type { Geometry, Size, StageGeometry } from './generated/geometry.js';\nexport type {\n ChromaSubsampling,\n Format as CoreFormat,\n OutputOptions as CoreOutputOptions,\n} from './generated/output.js';\nexport type {\n ColorStage,\n CropStage,\n Fit,\n Rect as PlanRect,\n RenderPlan,\n ResizeStage,\n SourceInfo,\n Stage,\n} from './generated/plan.js';\n\n/** Mirrors `sealpixel_core::plan::PLAN_VERSION`. */\nexport const PLAN_VERSION = 1;\n\n/**\n * Builds the plan for `log` executed on a buffer of `actual` size. Until the\n * plugin registry lands, every log compiles to the identity plan.\n */\nexport function toRenderPlan(\n log: EditLog,\n actual: { width: number; height: number },\n stages: Stage[] = [],\n): RenderPlan {\n return {\n version: PLAN_VERSION,\n source: { width: log.source.width, height: log.source.height },\n bufferScale: actual.width / log.source.width,\n stages,\n };\n}\n"]}
package/dist/render.js CHANGED
@@ -213,7 +213,7 @@ async function executeStages(wasm, stages, image, logical, options) {
213
213
  scale: current.width / currentLogical.width,
214
214
  mode: options.mode,
215
215
  asset: (id) => {
216
- throw new SealpixelError('INVALID_EDIT_LOG', `asset "${id}" requested but assets are not supported yet (S3.3)`);
216
+ throw new SealpixelError('INVALID_EDIT_LOG', `asset "${id}" requested but assets are not supported yet`);
217
217
  },
218
218
  signal: options.signal ?? new AbortController().signal,
219
219
  };
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,GAGlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAsB,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAuB,UAAU,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAiB,YAAY,EAA+B,MAAM,WAAW,CAAC;AAErF,OAAO,EAAE,cAAc,EAAiB,MAAM,eAAe,CAAC;AAU9D,MAAM,cAAc,GAAiC;IAC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,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,GAAG;IACV,OAAO,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["import {\n type DecodedImage,\n loadSealpixelWasm,\n type RgbaBuffer,\n type SealpixelWasm,\n} from '@sealpixel/wasm';\nimport { withAssets } from './assets.js';\nimport { canonicalJson } from './canonical-json.js';\nimport { compile, type PipelineStage, toCoreStages, toPipeline } from './compile.js';\nimport { SealpixelError } from './errors.js';\nimport { runExternalKernel } from './external-kernel.js';\nimport { editLogHash, MANIFEST_VERSION, type RenderManifest, renderHash } from './manifest.js';\nimport { type Geometry, PLAN_VERSION, type RenderPlan, type Stage } from './plan.js';\nimport type { KernelContext, PlanContext } from './plugin.js';\nimport { createRegistry, type Registry } from './registry.js';\nimport type {\n EditLog,\n OutputFormat,\n OutputOptions,\n RenderOptions,\n RenderResult,\n RenderSource,\n} from './types.js';\n\nconst FORMAT_TO_CORE: Record<OutputFormat, string> = {\n 'image/png': 'png',\n 'image/jpeg': 'jpeg',\n 'image/webp': 'webp',\n};\n\nconst EMPTY_REGISTRY = createRegistry([]);\n\n/**\n * Renders `log` against `source` and encodes the result.\n *\n * Pure with respect to its inputs: same bytes, same log, same options, same\n * plugins and the same core version produce the same output bytes on every\n * runtime. Core stages run inside the wasm; JS kernels run between them\n * through the same orchestrator on every runtime.\n */\nexport async function render(\n source: RenderSource,\n log: EditLog,\n options: RenderOptions,\n): Promise<RenderResult> {\n const wasm = options.wasm ?? (await loadSealpixelWasm());\n const registry = options.registry ?? EMPTY_REGISTRY;\n throwIfAborted(options.signal);\n\n const mode = options.mode ?? 'truth';\n // What a manifest needs is checked before the hash and the decode, the\n // expensive steps. A buffer source names its hash explicitly: the log's\n // `source.hash` is a claim about bytes this call never saw.\n if (options.manifest && mode !== 'truth') {\n throw new SealpixelError(\n 'INVALID_REQUEST',\n 'a manifest describes a truth render; a preview cannot be verified',\n );\n }\n const sourceHash = !options.manifest\n ? undefined\n : source instanceof Uint8Array\n ? wasm.sha256Hex(source)\n : options.sourceHash;\n if (options.manifest && sourceHash === undefined) {\n throw new SealpixelError(\n 'INVALID_REQUEST',\n 'a manifest needs the hash of the original: pass the bytes as source, or sourceHash with a buffer',\n );\n }\n\n const t0 = now();\n const image = source instanceof Uint8Array ? tryCore(() => wasm.decode(source)) : source;\n const decodeMs = now() - t0;\n\n if (\n mode === 'truth' &&\n (image.width !== log.source.width || image.height !== log.source.height)\n ) {\n throw new SealpixelError(\n 'SOURCE_MISMATCH',\n `truth render expects ${log.source.width}x${log.source.height}, got ${image.width}x${image.height}`,\n );\n }\n if (log.ops.length > 0 && registry === EMPTY_REGISTRY) {\n throw new SealpixelError('INVALID_EDIT_LOG', 'log has ops but no registry was given');\n }\n throwIfAborted(options.signal);\n\n const t1 = now();\n const { stages, logical } = compileStages(registry, image, log, mode, options.upTo);\n const rendered = await withAssets(\n () =>\n executeStages(wasm, stages, image, logical, {\n mode,\n ...(options.manifest ? { pixelHash: true } : {}),\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n }),\n options.assets,\n (id, bytes) => wasm.assetPut(id, bytes),\n );\n const renderMs = now() - t1;\n throwIfAborted(options.signal);\n\n const t2 = now();\n const coreOutput = toCoreOutput(options.output);\n if (options.embedEditLog) {\n coreOutput['embed'] = canonicalJson({ log, index: options.upTo ?? log.ops.length });\n }\n // A decoded source carries its ICC profile; pixels given by the caller carry\n // what the caller attached, if anything. No `instanceof`: a typed array from\n // another realm is still a profile.\n const icc = (image as Partial<DecodedImage>).icc;\n const bytes = tryCore(() => wasm.encode(rendered, JSON.stringify(coreOutput), icc));\n const encodeMs = now() - t2;\n\n const result: RenderResult = {\n bytes,\n mimeType: options.output.format,\n width: rendered.width,\n height: rendered.height,\n hash: wasm.sha256Hex(bytes),\n coreVersion: wasm.version(),\n timings: { decode: decodeMs, render: renderMs, encode: encodeMs },\n };\n if (options.manifest && sourceHash !== undefined) {\n const t3 = now();\n result.manifest = buildManifest(wasm, registry, stages, logical, log, options, {\n sourceHash,\n rendered,\n bytes: result.hash,\n output: toCoreOutput(options.output),\n mimeType: (image as Partial<DecodedImage>).mimeType,\n });\n result.timings['manifest'] = now() - t3;\n }\n return result;\n}\n\n/**\n * The manifest of a finished render, from the stages that rendered. The plan\n * is the single core plan of a render whose stages all ran in the core; a\n * pipeline with a plugin kernel outside the core lists the kernels instead,\n * and only a JavaScript runtime can verify it. `output.options` never\n * carries `embed`: the log is in `editLog`, and `embedEditLog` says whether\n * the file holds it too.\n */\nfunction buildManifest(\n wasm: SealpixelWasm,\n registry: Registry,\n stages: readonly PipelineStage[],\n logical: { width: number; height: number },\n log: EditLog,\n options: RenderOptions,\n result: {\n sourceHash: string;\n rendered: RgbaBuffer & { pixelHash?: string };\n bytes: string;\n output: Record<string, unknown>;\n mimeType: string | undefined;\n },\n): RenderManifest {\n const index = options.upTo ?? log.ops.length;\n const kernels = stages.filter((s) => s.kind !== 'core').map((s) => s.name);\n const plan: RenderPlan | undefined =\n kernels.length === 0\n ? { version: PLAN_VERSION, source: logical, bufferScale: 1, stages: toCoreStages(stages) }\n : undefined;\n const plugins = registry.pluginVersions();\n const renderer = wasm.identity();\n // From the core when the last stage ran there; a kernel outside the core\n // leaves its buffer in JavaScript, which is then hashed from there.\n const pixelHash = result.rendered.pixelHash ?? wasm.pixelHash(result.rendered);\n const logHash = editLogHash(wasm.sha256Hex, log, index);\n return {\n version: MANIFEST_VERSION,\n source: {\n width: log.source.width,\n height: log.source.height,\n hash: result.sourceHash,\n ...(result.mimeType === undefined ? {} : { mimeType: result.mimeType }),\n },\n editLog: { log, index },\n editLogHash: logHash,\n ...(plan ? { plan } : { kernels }),\n plugins,\n renderer,\n output: {\n options: result.output,\n ...(options.embedEditLog ? { embedEditLog: true } : {}),\n width: result.rendered.width,\n height: result.rendered.height,\n pixelHash,\n byteHash: result.bytes,\n },\n renderHash: renderHash(wasm.sha256Hex, {\n sourceHash: result.sourceHash,\n editsHash: logHash,\n plugins,\n renderer,\n pixelHash,\n byteHash: result.bytes,\n }),\n };\n}\n\nexport interface PipelineOptions {\n mode: 'truth' | 'preview';\n upTo?: number;\n signal?: AbortSignal;\n}\n\n/**\n * Compiles the log and executes it: consecutive core stages become one wasm\n * call, every external kernel runs in between on the RGBA buffer.\n */\nexport async function runPipeline(\n wasm: SealpixelWasm,\n registry: Registry,\n image: RgbaBuffer,\n log: EditLog,\n options: PipelineOptions,\n): Promise<RgbaBuffer> {\n const { stages, logical } = compileStages(registry, image, log, options.mode, options.upTo);\n return executeStages(wasm, stages, image, logical, options);\n}\n\n/**\n * The core plan of a truth render of `ops[0..upTo)`, when every stage runs in\n * the core, and otherwise the stages that run outside it. What a render\n * manifest records, and what a C2PA manifest definition is made from.\n */\nexport function compileCorePlan(\n log: EditLog,\n registry: Registry,\n upTo?: number,\n): {\n /** The one core plan, when every stage runs in the core. */\n plan?: RenderPlan;\n /** The core stages in order, whatever runs between them. */\n coreStages: Stage[];\n kernels: { name: string; order: number }[];\n} {\n const logical = { width: log.source.width, height: log.source.height };\n const { stages } = compileStages(registry, { ...logical, data: EMPTY }, log, 'truth', upTo);\n const kernels = stages\n .filter((s) => s.kind !== 'core')\n .map((s) => ({ name: s.name, order: s.order }));\n const coreStages = toCoreStages(stages.filter((s) => s.kind === 'core'));\n return kernels.length === 0\n ? {\n plan: { version: PLAN_VERSION, source: logical, bufferScale: 1, stages: coreStages },\n coreStages,\n kernels,\n }\n : { coreStages, kernels };\n}\n\nconst EMPTY = new Uint8Array(0);\n\n/** Compiles `ops[0..upTo)` into the ordered stages for a buffer of `image`'s size. */\nfunction compileStages(\n registry: Registry,\n image: RgbaBuffer,\n log: EditLog,\n mode: 'truth' | 'preview',\n upTo: number | undefined,\n): { stages: PipelineStage[]; logical: { width: number; height: number } } {\n const doc = compile(log, registry, upTo);\n const logical = { width: log.source.width, height: log.source.height };\n const ctx: PlanContext = {\n logical,\n actual: { width: image.width, height: image.height },\n scale: image.width / log.source.width,\n mode,\n };\n return { stages: toPipeline(doc, registry, ctx), logical };\n}\n\n/** Runs the stages: consecutive core stages as one wasm call, every external kernel in between. */\nasync function executeStages(\n wasm: SealpixelWasm,\n stages: readonly PipelineStage[],\n image: RgbaBuffer,\n logical: { width: number; height: number },\n options: Pick<PipelineOptions, 'mode' | 'signal'> & { pixelHash?: boolean },\n): Promise<RgbaBuffer & { pixelHash?: string }> {\n let current: RgbaBuffer & { pixelHash?: string } = image;\n let currentLogical = logical;\n const all = [...segments(stages)];\n for (const [i, segment] of all.entries()) {\n throwIfAborted(options.signal);\n if (segment.kind === 'core') {\n const plan: RenderPlan = {\n version: PLAN_VERSION,\n source: currentLogical,\n bufferScale: current.width / currentLogical.width,\n stages: toCoreStages(segment.stages),\n };\n const planJson = JSON.stringify(plan);\n const geometry = JSON.parse(\n tryCore(() => wasm.resolveGeometry(planJson, current.width, current.height)),\n ) as Geometry;\n const last = i === all.length - 1;\n current = tryCore(() =>\n wasm.renderRgba(current, planJson, options.pixelHash && last ? { pixelHash: true } : {}),\n );\n currentLogical = geometry.logicalOut;\n } else {\n const stage = segment.stage;\n const kctx: KernelContext = {\n logical: currentLogical,\n actual: { width: current.width, height: current.height },\n scale: current.width / currentLogical.width,\n mode: options.mode,\n asset: (id) => {\n throw new SealpixelError(\n 'INVALID_EDIT_LOG',\n `asset \"${id}\" requested but assets are not supported yet (S3.3)`,\n );\n },\n signal: options.signal ?? new AbortController().signal,\n };\n const out = await runExternalKernel(stage.plugin, current, stage.params, kctx);\n if (out.width !== current.width || out.height !== current.height) {\n currentLogical = {\n width: Math.round(currentLogical.width * (out.width / current.width)),\n height: Math.round(currentLogical.height * (out.height / current.height)),\n };\n }\n current = out;\n }\n }\n return current;\n}\n\ntype Segment =\n | { kind: 'core'; stages: PipelineStage[] }\n | { kind: 'external'; stage: Extract<PipelineStage, { kind: 'js' | 'wasm' }> };\n\nfunction* segments(stages: readonly PipelineStage[]): Generator<Segment> {\n let run: PipelineStage[] = [];\n for (const stage of stages) {\n if (stage.kind === 'core') {\n run.push(stage);\n continue;\n }\n if (run.length > 0) {\n yield { kind: 'core', stages: run };\n run = [];\n }\n yield { kind: 'external', stage };\n }\n if (run.length > 0) yield { kind: 'core', stages: run };\n}\n\n/** Maps the public output options onto the Rust `OutputOptions` JSON. */\nexport function toCoreOutput(output: OutputOptions): Record<string, unknown> {\n const core: Record<string, unknown> = { format: FORMAT_TO_CORE[output.format] };\n if (output.quality !== undefined) core['quality'] = output.quality;\n if (output.progressive !== undefined) core['progressive'] = output.progressive;\n if (output.chromaSubsampling !== undefined) core['chromaSubsampling'] = output.chromaSubsampling;\n if (output.lossless !== undefined) core['lossless'] = output.lossless;\n if (output.background !== undefined) core['background'] = output.background;\n return core;\n}\n\n/**\n * The inverse of `toCoreOutput`, for the options a render manifest records.\n * `embed` is not an option here: `embedEditLog` regenerates it from the log.\n */\nexport function fromCoreOutput(core: Record<string, unknown>): OutputOptions {\n const format = (Object.keys(FORMAT_TO_CORE) as OutputFormat[]).find(\n (f) => FORMAT_TO_CORE[f] === core['format'],\n );\n if (format === undefined) {\n throw new SealpixelError('INVALID_REQUEST', `unknown output format ${String(core['format'])}`);\n }\n const output: OutputOptions = { format };\n if (typeof core['quality'] === 'number') output.quality = core['quality'];\n if (typeof core['progressive'] === 'boolean') output.progressive = core['progressive'];\n if (core['chromaSubsampling'] === '4:2:0' || core['chromaSubsampling'] === '4:4:4')\n output.chromaSubsampling = core['chromaSubsampling'];\n if (typeof core['lossless'] === 'boolean') output.lossless = core['lossless'];\n if (Array.isArray(core['background']) && core['background'].length === 3)\n output.background = core['background'] as [number, number, number];\n return output;\n}\n\nfunction tryCore<T>(fn: () => T): T {\n try {\n return fn();\n } catch (error) {\n throw SealpixelError.from(error);\n }\n}\n\nfunction throwIfAborted(signal: AbortSignal | undefined): void {\n if (signal?.aborted) throw new SealpixelError('ABORTED', 'render aborted');\n}\n\nfunction now(): number {\n return typeof performance === 'undefined' ? Date.now() : performance.now();\n}\n"]}
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,GAGlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAsB,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAuB,UAAU,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAiB,YAAY,EAA+B,MAAM,WAAW,CAAC;AAErF,OAAO,EAAE,cAAc,EAAiB,MAAM,eAAe,CAAC;AAU9D,MAAM,cAAc,GAAiC;IACnD,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,MAAM;IACpB,YAAY,EAAE,MAAM;CACrB,CAAC;AAEF,MAAM,cAAc,GAAG,cAAc,CAAC,EAAE,CAAC,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,MAAoB,EACpB,GAAY,EACZ,OAAsB;IAEtB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,MAAM,iBAAiB,EAAE,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,cAAc,CAAC;IACpD,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC;IACrC,uEAAuE;IACvE,wEAAwE;IACxE,4DAA4D;IAC5D,IAAI,OAAO,CAAC,Q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F,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACvD,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,SAAS;QAAE,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9E,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC;QACtE,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAA6B,CAAC;IACrE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAI,EAAW;IAC7B,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,MAA+B;IACrD,IAAI,MAAM,EAAE,OAAO;QAAE,MAAM,IAAI,cAAc,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,GAAG;IACV,OAAO,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["import {\n type DecodedImage,\n loadSealpixelWasm,\n type RgbaBuffer,\n type SealpixelWasm,\n} from '@sealpixel/wasm';\nimport { withAssets } from './assets.js';\nimport { canonicalJson } from './canonical-json.js';\nimport { compile, type PipelineStage, toCoreStages, toPipeline } from './compile.js';\nimport { SealpixelError } from './errors.js';\nimport { runExternalKernel } from './external-kernel.js';\nimport { editLogHash, MANIFEST_VERSION, type RenderManifest, renderHash } from './manifest.js';\nimport { type Geometry, PLAN_VERSION, type RenderPlan, type Stage } from './plan.js';\nimport type { KernelContext, PlanContext } from './plugin.js';\nimport { createRegistry, type Registry } from './registry.js';\nimport type {\n EditLog,\n OutputFormat,\n OutputOptions,\n RenderOptions,\n RenderResult,\n RenderSource,\n} from './types.js';\n\nconst FORMAT_TO_CORE: Record<OutputFormat, string> = {\n 'image/png': 'png',\n 'image/jpeg': 'jpeg',\n 'image/webp': 'webp',\n};\n\nconst EMPTY_REGISTRY = createRegistry([]);\n\n/**\n * Renders `log` against `source` and encodes the result.\n *\n * Pure with respect to its inputs: same bytes, same log, same options, same\n * plugins and the same core version produce the same output bytes on every\n * runtime. Core stages run inside the wasm; JS kernels run between them\n * through the same orchestrator on every runtime.\n */\nexport async function render(\n source: RenderSource,\n log: EditLog,\n options: RenderOptions,\n): Promise<RenderResult> {\n const wasm = options.wasm ?? (await loadSealpixelWasm());\n const registry = options.registry ?? EMPTY_REGISTRY;\n throwIfAborted(options.signal);\n\n const mode = options.mode ?? 'truth';\n // What a manifest needs is checked before the hash and the decode, the\n // expensive steps. A buffer source names its hash explicitly: the log's\n // `source.hash` is a claim about bytes this call never saw.\n if (options.manifest && mode !== 'truth') {\n throw new SealpixelError(\n 'INVALID_REQUEST',\n 'a manifest describes a truth render; a preview cannot be verified',\n );\n }\n const sourceHash = !options.manifest\n ? undefined\n : source instanceof Uint8Array\n ? wasm.sha256Hex(source)\n : options.sourceHash;\n if (options.manifest && sourceHash === undefined) {\n throw new SealpixelError(\n 'INVALID_REQUEST',\n 'a manifest needs the hash of the original: pass the bytes as source, or sourceHash with a buffer',\n );\n }\n\n const t0 = now();\n const image = source instanceof Uint8Array ? tryCore(() => wasm.decode(source)) : source;\n const decodeMs = now() - t0;\n\n if (\n mode === 'truth' &&\n (image.width !== log.source.width || image.height !== log.source.height)\n ) {\n throw new SealpixelError(\n 'SOURCE_MISMATCH',\n `truth render expects ${log.source.width}x${log.source.height}, got ${image.width}x${image.height}`,\n );\n }\n if (log.ops.length > 0 && registry === EMPTY_REGISTRY) {\n throw new SealpixelError('INVALID_EDIT_LOG', 'log has ops but no registry was given');\n }\n throwIfAborted(options.signal);\n\n const t1 = now();\n const { stages, logical } = compileStages(registry, image, log, mode, options.upTo);\n const rendered = await withAssets(\n () =>\n executeStages(wasm, stages, image, logical, {\n mode,\n ...(options.manifest ? { pixelHash: true } : {}),\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n }),\n options.assets,\n (id, bytes) => wasm.assetPut(id, bytes),\n );\n const renderMs = now() - t1;\n throwIfAborted(options.signal);\n\n const t2 = now();\n const coreOutput = toCoreOutput(options.output);\n if (options.embedEditLog) {\n coreOutput['embed'] = canonicalJson({ log, index: options.upTo ?? log.ops.length });\n }\n // A decoded source carries its ICC profile; pixels given by the caller carry\n // what the caller attached, if anything. No `instanceof`: a typed array from\n // another realm is still a profile.\n const icc = (image as Partial<DecodedImage>).icc;\n const bytes = tryCore(() => wasm.encode(rendered, JSON.stringify(coreOutput), icc));\n const encodeMs = now() - t2;\n\n const result: RenderResult = {\n bytes,\n mimeType: options.output.format,\n width: rendered.width,\n height: rendered.height,\n hash: wasm.sha256Hex(bytes),\n coreVersion: wasm.version(),\n timings: { decode: decodeMs, render: renderMs, encode: encodeMs },\n };\n if (options.manifest && sourceHash !== undefined) {\n const t3 = now();\n result.manifest = buildManifest(wasm, registry, stages, logical, log, options, {\n sourceHash,\n rendered,\n bytes: result.hash,\n output: toCoreOutput(options.output),\n mimeType: (image as Partial<DecodedImage>).mimeType,\n });\n result.timings['manifest'] = now() - t3;\n }\n return result;\n}\n\n/**\n * The manifest of a finished render, from the stages that rendered. The plan\n * is the single core plan of a render whose stages all ran in the core; a\n * pipeline with a plugin kernel outside the core lists the kernels instead,\n * and only a JavaScript runtime can verify it. `output.options` never\n * carries `embed`: the log is in `editLog`, and `embedEditLog` says whether\n * the file holds it too.\n */\nfunction buildManifest(\n wasm: SealpixelWasm,\n registry: Registry,\n stages: readonly PipelineStage[],\n logical: { width: number; height: number },\n log: EditLog,\n options: RenderOptions,\n result: {\n sourceHash: string;\n rendered: RgbaBuffer & { pixelHash?: string };\n bytes: string;\n output: Record<string, unknown>;\n mimeType: string | undefined;\n },\n): RenderManifest {\n const index = options.upTo ?? log.ops.length;\n const kernels = stages.filter((s) => s.kind !== 'core').map((s) => s.name);\n const plan: RenderPlan | undefined =\n kernels.length === 0\n ? { version: PLAN_VERSION, source: logical, bufferScale: 1, stages: toCoreStages(stages) }\n : undefined;\n const plugins = registry.pluginVersions();\n const renderer = wasm.identity();\n // From the core when the last stage ran there; a kernel outside the core\n // leaves its buffer in JavaScript, which is then hashed from there.\n const pixelHash = result.rendered.pixelHash ?? wasm.pixelHash(result.rendered);\n const logHash = editLogHash(wasm.sha256Hex, log, index);\n return {\n version: MANIFEST_VERSION,\n source: {\n width: log.source.width,\n height: log.source.height,\n hash: result.sourceHash,\n ...(result.mimeType === undefined ? {} : { mimeType: result.mimeType }),\n },\n editLog: { log, index },\n editLogHash: logHash,\n ...(plan ? { plan } : { kernels }),\n plugins,\n renderer,\n output: {\n options: result.output,\n ...(options.embedEditLog ? { embedEditLog: true } : {}),\n width: result.rendered.width,\n height: result.rendered.height,\n pixelHash,\n byteHash: result.bytes,\n },\n renderHash: renderHash(wasm.sha256Hex, {\n sourceHash: result.sourceHash,\n editsHash: logHash,\n plugins,\n renderer,\n pixelHash,\n byteHash: result.bytes,\n }),\n };\n}\n\nexport interface PipelineOptions {\n mode: 'truth' | 'preview';\n upTo?: number;\n signal?: AbortSignal;\n}\n\n/**\n * Compiles the log and executes it: consecutive core stages become one wasm\n * call, every external kernel runs in between on the RGBA buffer.\n */\nexport async function runPipeline(\n wasm: SealpixelWasm,\n registry: Registry,\n image: RgbaBuffer,\n log: EditLog,\n options: PipelineOptions,\n): Promise<RgbaBuffer> {\n const { stages, logical } = compileStages(registry, image, log, options.mode, options.upTo);\n return executeStages(wasm, stages, image, logical, options);\n}\n\n/**\n * The core plan of a truth render of `ops[0..upTo)`, when every stage runs in\n * the core, and otherwise the stages that run outside it. What a render\n * manifest records, and what a C2PA manifest definition is made from.\n */\nexport function compileCorePlan(\n log: EditLog,\n registry: Registry,\n upTo?: number,\n): {\n /** The one core plan, when every stage runs in the core. */\n plan?: RenderPlan;\n /** The core stages in order, whatever runs between them. */\n coreStages: Stage[];\n kernels: { name: string; order: number }[];\n} {\n const logical = { width: log.source.width, height: log.source.height };\n const { stages } = compileStages(registry, { ...logical, data: EMPTY }, log, 'truth', upTo);\n const kernels = stages\n .filter((s) => s.kind !== 'core')\n .map((s) => ({ name: s.name, order: s.order }));\n const coreStages = toCoreStages(stages.filter((s) => s.kind === 'core'));\n return kernels.length === 0\n ? {\n plan: { version: PLAN_VERSION, source: logical, bufferScale: 1, stages: coreStages },\n coreStages,\n kernels,\n }\n : { coreStages, kernels };\n}\n\nconst EMPTY = new Uint8Array(0);\n\n/** Compiles `ops[0..upTo)` into the ordered stages for a buffer of `image`'s size. */\nfunction compileStages(\n registry: Registry,\n image: RgbaBuffer,\n log: EditLog,\n mode: 'truth' | 'preview',\n upTo: number | undefined,\n): { stages: PipelineStage[]; logical: { width: number; height: number } } {\n const doc = compile(log, registry, upTo);\n const logical = { width: log.source.width, height: log.source.height };\n const ctx: PlanContext = {\n logical,\n actual: { width: image.width, height: image.height },\n scale: image.width / log.source.width,\n mode,\n };\n return { stages: toPipeline(doc, registry, ctx), logical };\n}\n\n/** Runs the stages: consecutive core stages as one wasm call, every external kernel in between. */\nasync function executeStages(\n wasm: SealpixelWasm,\n stages: readonly PipelineStage[],\n image: RgbaBuffer,\n logical: { width: number; height: number },\n options: Pick<PipelineOptions, 'mode' | 'signal'> & { pixelHash?: boolean },\n): Promise<RgbaBuffer & { pixelHash?: string }> {\n let current: RgbaBuffer & { pixelHash?: string } = image;\n let currentLogical = logical;\n const all = [...segments(stages)];\n for (const [i, segment] of all.entries()) {\n throwIfAborted(options.signal);\n if (segment.kind === 'core') {\n const plan: RenderPlan = {\n version: PLAN_VERSION,\n source: currentLogical,\n bufferScale: current.width / currentLogical.width,\n stages: toCoreStages(segment.stages),\n };\n const planJson = JSON.stringify(plan);\n const geometry = JSON.parse(\n tryCore(() => wasm.resolveGeometry(planJson, current.width, current.height)),\n ) as Geometry;\n const last = i === all.length - 1;\n current = tryCore(() =>\n wasm.renderRgba(current, planJson, options.pixelHash && last ? { pixelHash: true } : {}),\n );\n currentLogical = geometry.logicalOut;\n } else {\n const stage = segment.stage;\n const kctx: KernelContext = {\n logical: currentLogical,\n actual: { width: current.width, height: current.height },\n scale: current.width / currentLogical.width,\n mode: options.mode,\n asset: (id) => {\n throw new SealpixelError(\n 'INVALID_EDIT_LOG',\n `asset \"${id}\" requested but assets are not supported yet`,\n );\n },\n signal: options.signal ?? new AbortController().signal,\n };\n const out = await runExternalKernel(stage.plugin, current, stage.params, kctx);\n if (out.width !== current.width || out.height !== current.height) {\n currentLogical = {\n width: Math.round(currentLogical.width * (out.width / current.width)),\n height: Math.round(currentLogical.height * (out.height / current.height)),\n };\n }\n current = out;\n }\n }\n return current;\n}\n\ntype Segment =\n | { kind: 'core'; stages: PipelineStage[] }\n | { kind: 'external'; stage: Extract<PipelineStage, { kind: 'js' | 'wasm' }> };\n\nfunction* segments(stages: readonly PipelineStage[]): Generator<Segment> {\n let run: PipelineStage[] = [];\n for (const stage of stages) {\n if (stage.kind === 'core') {\n run.push(stage);\n continue;\n }\n if (run.length > 0) {\n yield { kind: 'core', stages: run };\n run = [];\n }\n yield { kind: 'external', stage };\n }\n if (run.length > 0) yield { kind: 'core', stages: run };\n}\n\n/** Maps the public output options onto the Rust `OutputOptions` JSON. */\nexport function toCoreOutput(output: OutputOptions): Record<string, unknown> {\n const core: Record<string, unknown> = { format: FORMAT_TO_CORE[output.format] };\n if (output.quality !== undefined) core['quality'] = output.quality;\n if (output.progressive !== undefined) core['progressive'] = output.progressive;\n if (output.chromaSubsampling !== undefined) core['chromaSubsampling'] = output.chromaSubsampling;\n if (output.lossless !== undefined) core['lossless'] = output.lossless;\n if (output.background !== undefined) core['background'] = output.background;\n return core;\n}\n\n/**\n * The inverse of `toCoreOutput`, for the options a render manifest records.\n * `embed` is not an option here: `embedEditLog` regenerates it from the log.\n */\nexport function fromCoreOutput(core: Record<string, unknown>): OutputOptions {\n const format = (Object.keys(FORMAT_TO_CORE) as OutputFormat[]).find(\n (f) => FORMAT_TO_CORE[f] === core['format'],\n );\n if (format === undefined) {\n throw new SealpixelError('INVALID_REQUEST', `unknown output format ${String(core['format'])}`);\n }\n const output: OutputOptions = { format };\n if (typeof core['quality'] === 'number') output.quality = core['quality'];\n if (typeof core['progressive'] === 'boolean') output.progressive = core['progressive'];\n if (core['chromaSubsampling'] === '4:2:0' || core['chromaSubsampling'] === '4:4:4')\n output.chromaSubsampling = core['chromaSubsampling'];\n if (typeof core['lossless'] === 'boolean') output.lossless = core['lossless'];\n if (Array.isArray(core['background']) && core['background'].length === 3)\n output.background = core['background'] as [number, number, number];\n return output;\n}\n\nfunction tryCore<T>(fn: () => T): T {\n try {\n return fn();\n } catch (error) {\n throw SealpixelError.from(error);\n }\n}\n\nfunction throwIfAborted(signal: AbortSignal | undefined): void {\n if (signal?.aborted) throw new SealpixelError('ABORTED', 'render aborted');\n}\n\nfunction now(): number {\n return typeof performance === 'undefined' ? Date.now() : performance.now();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealpixel/core",
3
- "version": "1.0.0-rc.22",
3
+ "version": "1.0.0-rc.23",
4
4
  "description": "Sealpixel headless core: edit log types, compile(), render(), editor session. Runtime-agnostic.",
5
5
  "license": "BUSL-1.1",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@sealpixel/wasm": "1.0.0-rc.22",
31
+ "@sealpixel/wasm": "1.0.0-rc.23",
32
32
  "zod": "^4.0.0"
33
33
  },
34
34
  "devDependencies": {