@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
@@ -0,0 +1,115 @@
1
+ import { z } from 'zod';
2
+ import { canonicalJson } from './canonical-json.js';
3
+ import { SealpixelError } from './errors.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 const MANIFEST_VERSION = 1;
15
+ const sha256 = z.string().regex(/^[0-9a-f]{64}$/);
16
+ /**
17
+ * The manifest as untrusted input: the shape, the hashes and the numbers. The
18
+ * edit log inside it is only an object here; `verify()` parses it with the
19
+ * registry, and the core checks the plan when it renders.
20
+ */
21
+ export const RenderManifestSchema = z.object({
22
+ version: z.literal(1),
23
+ source: z.object({
24
+ width: z.number().int().positive(),
25
+ height: z.number().int().positive(),
26
+ hash: sha256,
27
+ mimeType: z.string().optional(),
28
+ }),
29
+ editLog: z
30
+ .object({
31
+ log: z.record(z.string(), z.unknown()),
32
+ index: z.number().int().nonnegative(),
33
+ })
34
+ .optional(),
35
+ editLogHash: sha256.optional(),
36
+ plan: z.record(z.string(), z.unknown()).optional(),
37
+ kernels: z.array(z.string()).optional(),
38
+ plugins: z.record(z.string(), z.number().int()),
39
+ renderer: z.object({
40
+ kind: z.enum(['wasm', 'native']),
41
+ version: z.string(),
42
+ binarySha256: sha256.nullable(),
43
+ }),
44
+ output: z.object({
45
+ options: z.record(z.string(), z.unknown()),
46
+ embedEditLog: z.boolean().optional(),
47
+ width: z.number().int().positive(),
48
+ height: z.number().int().positive(),
49
+ pixelHash: sha256,
50
+ byteHash: sha256,
51
+ }),
52
+ renderHash: sha256,
53
+ });
54
+ /** Parses an untrusted manifest. Throws `INVALID_REQUEST` with the first problem. */
55
+ export function parseRenderManifest(input) {
56
+ const result = RenderManifestSchema.safeParse(input);
57
+ if (!result.success) {
58
+ const issue = result.error.issues[0];
59
+ throw new SealpixelError('INVALID_REQUEST', `manifest: ${issue ? `${issue.path.join('.') || '(root)'}: ${issue.message}` : 'invalid'}`);
60
+ }
61
+ return result.data;
62
+ }
63
+ /**
64
+ * The id of a render: a sha256 over the facts the manifest states, in a
65
+ * fixed text form that every runtime builds with string operations alone,
66
+ * so no canonical-JSON rules are needed to agree on it. `verify` does not
67
+ * recompute it; it checks the facts.
68
+ *
69
+ * ```text
70
+ * sealpixel-render/1
71
+ * <source hash>
72
+ * <edit log hash, or the plan hash for a manifest without a log>
73
+ * <plugins as id@version, sorted by id, joined by ','>
74
+ * <renderer kind> <renderer version> <binary sha256 or '-'>
75
+ * <pixel hash>
76
+ * <byte hash>
77
+ * ```
78
+ */
79
+ export function renderHash(sha256Hex, facts) {
80
+ const plugins = Object.keys(facts.plugins)
81
+ .sort(byCodePoint)
82
+ .map((id) => `${id}@${facts.plugins[id]}`)
83
+ .join(',');
84
+ const renderer = `${facts.renderer.kind} ${facts.renderer.version} ${facts.renderer.binarySha256 ?? '-'}`;
85
+ const text = [
86
+ `sealpixel-render/${MANIFEST_VERSION}`,
87
+ facts.sourceHash,
88
+ facts.editsHash,
89
+ plugins,
90
+ renderer,
91
+ facts.pixelHash,
92
+ facts.byteHash,
93
+ ].join('\n');
94
+ return sha256Hex(new TextEncoder().encode(text));
95
+ }
96
+ /**
97
+ * Code point order, which is the byte order of UTF-8 and the order a Rust
98
+ * `BTreeMap<String, _>` iterates in. JavaScript's default sort compares
99
+ * UTF-16 code units, which differs for characters outside the basic plane.
100
+ */
101
+ function byCodePoint(a, b) {
102
+ const x = Array.from(a, (c) => c.codePointAt(0) ?? 0);
103
+ const y = Array.from(b, (c) => c.codePointAt(0) ?? 0);
104
+ for (let i = 0; i < Math.min(x.length, y.length); i++) {
105
+ const d = (x[i] ?? 0) - (y[i] ?? 0);
106
+ if (d !== 0)
107
+ return d;
108
+ }
109
+ return x.length - y.length;
110
+ }
111
+ /** The hash `editLogHash` and the embedded log share: canonical JSON of `{ log, index }`. */
112
+ export function editLogHash(sha256Hex, log, index) {
113
+ return sha256Hex(new TextEncoder().encode(canonicalJson({ log, index })));
114
+ }
115
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AC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACtD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;AAC7B,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,WAAW,CACzB,SAAwC,EACxC,GAAY,EACZ,KAAa;IAEb,OAAO,SAAS,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import { z } from 'zod';\nimport { canonicalJson } from './canonical-json.js';\nimport { SealpixelError } from './errors.js';\nimport type { RenderPlan } from './plan.js';\nimport type { EditLog } from './types.js';\n\n/**\n * The render manifest: what a render was made from and the hash of what it\n * produced, so that anyone with the original can check the result later.\n *\n * Version 1. `render({ manifest: true })` writes it, `verify()` in\n * `@sealpixel/render` and `sealpixel verify` in the native CLI read it. The\n * fields are public API: a field is added with a default, never renamed or\n * removed, and an incompatible change bumps `version`. The native CLI's\n * `sealpixel_core::manifest` is the same format.\n */\nexport const MANIFEST_VERSION = 1;\n\n/** Which build produced the pixels. `kind` is `wasm` here, `native` for the CLI. */\nexport interface RendererIdentity {\n kind: 'wasm' | 'native';\n version: string;\n /** sha256 of the WebAssembly binary or the native executable, when the loader saw its bytes. */\n binarySha256: string | null;\n}\n\nexport interface RenderManifest {\n version: 1;\n source: {\n /** The size after EXIF orientation, as the edit log states it. */\n width: number;\n height: number;\n /** sha256 of the original's bytes. */\n hash: string;\n mimeType?: string;\n };\n /** `{ log, index }` as the editor keeps it. Absent in a manifest the native CLI wrote. */\n editLog?: { log: EditLog; index: number };\n /** sha256 of `editLog` in canonical JSON: the text `embedEditLog` stores in a file. */\n editLogHash?: string;\n /** The core plan, when every stage of the render ran in the core. */\n plan?: RenderPlan;\n /** The stages that ran outside the core, when any did: then there is no `plan`. */\n kernels?: string[];\n /** The plugin versions the log was compiled with. */\n plugins: Record<string, number>;\n renderer: RendererIdentity;\n output: {\n /** The encoder options in the core's form: `{ \"format\": \"png\", ... }`, never with `embed`. */\n options: Record<string, unknown>;\n /** The file holds the edit log, as `embedEditLog: true` stores it. */\n embedEditLog?: boolean;\n width: number;\n height: number;\n /** sha256 over the rendered pixels, before encoding. Survives any change to the file. */\n pixelHash: string;\n /** sha256 of the encoded bytes as the renderer wrote them. */\n byteHash: string;\n };\n /** One id for this render. See `renderHash()`. */\n renderHash: string;\n}\n\nconst sha256 = z.string().regex(/^[0-9a-f]{64}$/);\n\n/**\n * The manifest as untrusted input: the shape, the hashes and the numbers. The\n * edit log inside it is only an object here; `verify()` parses it with the\n * registry, and the core checks the plan when it renders.\n */\nexport const RenderManifestSchema = z.object({\n version: z.literal(1),\n source: z.object({\n width: z.number().int().positive(),\n height: z.number().int().positive(),\n hash: sha256,\n mimeType: z.string().optional(),\n }),\n editLog: z\n .object({\n log: z.record(z.string(), z.unknown()),\n index: z.number().int().nonnegative(),\n })\n .optional(),\n editLogHash: sha256.optional(),\n plan: z.record(z.string(), z.unknown()).optional(),\n kernels: z.array(z.string()).optional(),\n plugins: z.record(z.string(), z.number().int()),\n renderer: z.object({\n kind: z.enum(['wasm', 'native']),\n version: z.string(),\n binarySha256: sha256.nullable(),\n }),\n output: z.object({\n options: z.record(z.string(), z.unknown()),\n embedEditLog: z.boolean().optional(),\n width: z.number().int().positive(),\n height: z.number().int().positive(),\n pixelHash: sha256,\n byteHash: sha256,\n }),\n renderHash: sha256,\n});\n\n/** Parses an untrusted manifest. Throws `INVALID_REQUEST` with the first problem. */\nexport function parseRenderManifest(input: unknown): RenderManifest {\n const result = RenderManifestSchema.safeParse(input);\n if (!result.success) {\n const issue = result.error.issues[0];\n throw new SealpixelError(\n 'INVALID_REQUEST',\n `manifest: ${issue ? `${issue.path.join('.') || '(root)'}: ${issue.message}` : 'invalid'}`,\n );\n }\n return result.data as unknown as RenderManifest;\n}\n\n/**\n * The id of a render: a sha256 over the facts the manifest states, in a\n * fixed text form that every runtime builds with string operations alone,\n * so no canonical-JSON rules are needed to agree on it. `verify` does not\n * recompute it; it checks the facts.\n *\n * ```text\n * sealpixel-render/1\n * <source hash>\n * <edit log hash, or the plan hash for a manifest without a log>\n * <plugins as id@version, sorted by id, joined by ','>\n * <renderer kind> <renderer version> <binary sha256 or '-'>\n * <pixel hash>\n * <byte hash>\n * ```\n */\nexport function renderHash(\n sha256Hex: (bytes: Uint8Array) => string,\n facts: {\n sourceHash: string;\n editsHash: string;\n plugins: Record<string, number>;\n renderer: RendererIdentity;\n pixelHash: string;\n byteHash: string;\n },\n): string {\n const plugins = Object.keys(facts.plugins)\n .sort(byCodePoint)\n .map((id) => `${id}@${facts.plugins[id]}`)\n .join(',');\n const renderer = `${facts.renderer.kind} ${facts.renderer.version} ${facts.renderer.binarySha256 ?? '-'}`;\n const text = [\n `sealpixel-render/${MANIFEST_VERSION}`,\n facts.sourceHash,\n facts.editsHash,\n plugins,\n renderer,\n facts.pixelHash,\n facts.byteHash,\n ].join('\\n');\n return sha256Hex(new TextEncoder().encode(text));\n}\n\n/**\n * Code point order, which is the byte order of UTF-8 and the order a Rust\n * `BTreeMap<String, _>` iterates in. JavaScript's default sort compares\n * UTF-16 code units, which differs for characters outside the basic plane.\n */\nfunction byCodePoint(a: string, b: string): number {\n const x = Array.from(a, (c) => c.codePointAt(0) ?? 0);\n const y = Array.from(b, (c) => c.codePointAt(0) ?? 0);\n for (let i = 0; i < Math.min(x.length, y.length); i++) {\n const d = (x[i] ?? 0) - (y[i] ?? 0);\n if (d !== 0) return d;\n }\n return x.length - y.length;\n}\n\n/** The hash `editLogHash` and the embedded log share: canonical JSON of `{ log, index }`. */\nexport function editLogHash(\n sha256Hex: (bytes: Uint8Array) => string,\n log: EditLog,\n index: number,\n): string {\n return sha256Hex(new TextEncoder().encode(canonicalJson({ log, index })));\n}\n"]}
package/dist/options.d.ts CHANGED
@@ -10,4 +10,3 @@ export type PluginOptionsMap = Readonly<Record<string, unknown>>;
10
10
  export declare function configurePlugins(plugins: readonly AnyPlugin[], options: PluginOptionsMap | null | undefined): readonly AnyPlugin[];
11
11
  /** The resolved options of every plugin that has any, keyed by id. */
12
12
  export declare function pluginOptionsOf(plugins: readonly AnyPlugin[]): Record<string, unknown>;
13
- //# sourceMappingURL=options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7C;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAA6B,EAC7B,OAA4C;IAE5C,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAClE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9C,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACjB,MAAM,IAA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M,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACjB,MAAM,IAAI,cAAc,CACtB,iBAAiB,EACjB,0BAA0B,EAAE,qBAAqB,CAClD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC5B,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QACzC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,cAAc,CACtB,iBAAiB,EACjB,0BAA0B,MAAM,CAAC,EAAE,kBAAkB,CACtD,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,OAA2C,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,OAA6B;IAC3D,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,IAAI,OAAO;QAAE,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS;YAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;IAC5E,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { SealpixelError } from './errors.js';\nimport type { AnyPlugin } from './plugin.js';\n\n/** `{ pluginId: partialOptions }`, as accepted by the element, the wrappers and the server. */\nexport type PluginOptionsMap = Readonly<Record<string, unknown>>;\n\n/**\n * Applies `options[plugin.id]` to each plugin through its `configure()`.\n * Plugins without an entry are returned as they are. An entry for an unknown\n * plugin id, or for a plugin without options, is an error: silently ignoring\n * it would hide a typo in a security-relevant constraint.\n */\nexport function configurePlugins(\n plugins: readonly AnyPlugin[],\n options: PluginOptionsMap | null | undefined,\n): readonly AnyPlugin[] {\n if (!options || Object.keys(options).length === 0) return plugins;\n const ids = new Set(plugins.map((p) => p.id));\n for (const id of Object.keys(options)) {\n if (!ids.has(id)) {\n throw new SealpixelError(\n 'INVALID_REQUEST',\n `pluginOptions: plugin \"${id}\" is not registered`,\n );\n }\n }\n return plugins.map((plugin) => {\n const partial = options[plugin.id];\n if (partial === undefined) return plugin;\n if (!plugin.configure) {\n throw new SealpixelError(\n 'INVALID_REQUEST',\n `pluginOptions: plugin \"${plugin.id}\" has no options`,\n );\n }\n return plugin.configure(partial as Partial<Record<string, unknown>>);\n });\n}\n\n/** The resolved options of every plugin that has any, keyed by id. */\nexport function pluginOptionsOf(plugins: readonly AnyPlugin[]): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const p of plugins) if (p.options !== undefined) out[p.id] = p.options;\n return out;\n}\n"]}
package/dist/plan.d.ts CHANGED
@@ -13,4 +13,3 @@ export declare function toRenderPlan(log: EditLog, actual: {
13
13
  width: number;
14
14
  height: number;
15
15
  }, stages?: Stage[]): RenderPlan;
16
- //# sourceMappingURL=plan.d.ts.map
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"}
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"]}
package/dist/plugin.d.ts CHANGED
@@ -197,4 +197,3 @@ export interface SealpixelPlugin<Id extends string = string, Doc = unknown, Opti
197
197
  export type AnyPlugin = SealpixelPlugin<string, any, any>;
198
198
  /** Core stage kinds a `kernel: { kind: 'core' }` plugin may target. */
199
199
  export type CoreStageName = Stage['kind'];
200
- //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Plugin contract. These are types only; `@sealpixel/plugin-sdk` provides the\n * `definePlugin` / `defineOperation` helpers and deterministic math, and\n * `@sealpixel/core` provides the registry that consumes plugins.\n */\nimport type { RgbaBuffer } from '@sealpixel/wasm';\nimport type { Size, Stage } from './plan.js';\nimport type { Operation, OperationBase, SourceDescriptor } from './types.js';\n\n/** Augmented by plugins: `declare module '@sealpixel/core' { interface DocumentRegistry { finetune: FinetuneDoc } }`. */\n// biome-ignore lint/suspicious/noEmptyInterface: augmentation target\nexport interface DocumentRegistry {}\n/** Derived state: one slice per plugin, keyed by plugin id. */\nexport type Document = { [K in keyof DocumentRegistry]: DocumentRegistry[K] };\n\n/** Runtime validator for one operation. Structural so any zod-like schema works. */\nexport interface OperationSchema<Op> {\n /** Returns the parsed value or throws. */\n parse(value: unknown): Op;\n /** Optional non-throwing variant used for aggregated error reporting. */\n safeParse?(value: unknown): { success: true; data: Op } | { success: false; error: unknown };\n}\n\nexport interface OperationDef<Doc, Op extends OperationBase<string> = OperationBase<string>> {\n type: Op['type'];\n schema: OperationSchema<Op>;\n /** Pure: returns the plugin's next document slice. */\n reduce: (slice: Doc, op: Op) => Doc;\n /**\n * Upgrades an op written by an older plugin version. Called with the raw\n * value before validation. Return the op in the current shape.\n */\n migrate?: (fromVersion: number, op: unknown) => unknown;\n}\n\nexport interface PlanContext {\n /** The plugin's resolved options (see `SealpixelPlugin.options`). */\n options?: unknown;\n /** Logical (full-resolution) size at this stage's input. */\n logical: Size;\n /** Actual buffer size at this stage's input. */\n actual: Size;\n /** `actual.width / logical.width`. */\n scale: number;\n /** `truth` or `preview`. Plugins may cheapen work in preview. */\n mode: 'truth' | 'preview';\n}\n\n/**\n * Parameters a plugin contributes to its stage. For a core kernel this is the\n * core stage minus `kind`; stages with the same name are shallow-merged in\n * plugin order, which is how finetune and filter share one `color` stage.\n */\nexport type StageParams = Record<string, unknown>;\n\nexport interface KernelContext {\n logical: Size;\n actual: Size;\n scale: number;\n mode: 'truth' | 'preview';\n /** Resolves a declared asset by id; throws if unknown or hash mismatch. */\n asset: (id: string) => Uint8Array;\n signal: AbortSignal;\n}\n\nexport type KernelDef =\n /** First-party only: the kernel is compiled into the core wasm. */\n | { kind: 'core' }\n /** Plain JavaScript. Determinism is the author's responsibility. */\n | {\n kind: 'js';\n run: (\n image: RgbaBuffer,\n params: StageParams,\n ctx: KernelContext,\n ) => RgbaBuffer | Promise<RgbaBuffer>;\n }\n /** Separate WebAssembly module implementing the kernel ABI. */\n | { kind: 'wasm'; module: () => Promise<WebAssembly.Module>; export?: string };\n\nexport interface AssetDeclaration {\n id: string;\n /** sha256 of the bytes; the resolver verifies it on both client and server. */\n hash: string;\n /** Where the default resolver fetches it from. */\n url?: string;\n}\n\n/**\n * UI contribution. Consumed by `@sealpixel/ui`, which calls the functions with\n * its `UiToolContext`. Parameters are typed `never` here so a plugin can\n * declare the context shape it needs without depending on the UI package.\n */\nexport interface ToolDef {\n id?: string;\n icon: unknown;\n /** i18n key or literal label. */\n label: string;\n panel: (ctx: never) => unknown;\n overlay?: (ctx: never) => unknown;\n activate?: (ctx: never) => void;\n deactivate?: (ctx: never) => void;\n shortcuts?: Record<string, (ctx: never) => void>;\n preview?: (ctx: never) => PreviewHint;\n}\n\nexport type PreviewHint = { css: string } | { none: true };\n\nexport interface ToolContext {\n document: Document;\n dispatch: (op: Operation) => void;\n t: (key: string, params?: Record<string, string | number>) => string;\n}\n\n/** Runtime validator for a plugin's options. Structural so any zod-like schema works. */\nexport interface OptionsSchema<Options> {\n parse(value: unknown): Options;\n safeParse?(value: unknown): { success: true; data: Options } | { success: false; error: unknown };\n}\n\n/** Context handed to `validate`: the resolved options and the slice before the op. */\nexport interface ValidateContext<Doc, Options> {\n options: Options;\n slice: Doc;\n /** All slices as reduced so far. */\n document: Document;\n /** The source image the log belongs to (dimensions in pixels). */\n source: SourceDescriptor;\n}\n\nexport interface ValidateDocumentContext<Options> {\n options: Options;\n document: Document;\n source: SourceDescriptor;\n}\n\nexport interface SealpixelPlugin<Id extends string = string, Doc = unknown, Options = unknown> {\n /** Namespaced id such as `acme.invert`. Op types are `<id>.<verb>`. */\n id: Id;\n /** Bumped when the op schema or the kernel output changes. */\n version: number;\n // biome-ignore lint/suspicious/noExplicitAny: heterogeneous op types are erased at the registry boundary\n operations: ReadonlyArray<OperationDef<Doc, any>>;\n initialDocument: Doc;\n stage: { name: string; order: number };\n /** Returns this plugin's stage parameters, or `null` to contribute nothing. */\n toPlan: (slice: Doc, ctx: PlanContext) => StageParams | null;\n kernel: KernelDef;\n tool?: () => Promise<ToolDef>;\n assets?: AssetDeclaration[];\n /**\n * Resolved options: defaults merged with what `configure()` received.\n * Options tune behaviour and constrain edits; they never carry pixel data\n * so a render never depends on them.\n */\n options?: Options;\n /** Validates a full options object. Used by `configure()` and the docs generator. */\n optionsSchema?: OptionsSchema<Options>;\n /** One-line descriptions per top-level option key, for generated documentation. */\n optionsDescribe?: Readonly<Record<string, string>>;\n /** The defaults `configure()` merges over. */\n optionsDefaults?: Options;\n /** Returns a new plugin instance with `partial` merged over the current options. */\n configure?: (partial: Partial<Options>) => SealpixelPlugin<Id, Doc, Options>;\n /**\n * Constraint check for one operation against the options. Return a message\n * to reject the op (`OPTION_VIOLATION`), or null to accept. Runs in\n * `parseEditLog`, in `session.dispatch` and on the server.\n */\n validate?: (op: Operation, ctx: ValidateContext<Doc, Options>) => string | null;\n /**\n * Constraint check for the final state, for example a locked watermark that\n * must be present. Runs before export and before every server render.\n */\n validateDocument?: (slice: Doc, ctx: ValidateDocumentContext<Options>) => string | null;\n /**\n * Operations the editor dispatches when a source loads with an empty log,\n * so option defaults (a default preset, a locked watermark) become part of\n * the log instead of hidden state. Ids are assigned by the caller.\n */\n initialOps?: (ctx: { options: Options; source: SourceDescriptor }) => Omit<Operation, 'id'>[];\n}\n\n/**\n * A plugin with its document type erased. Registries accept this so plugins\n * with concrete `Doc` types can be mixed in one array.\n */\n// biome-ignore lint/suspicious/noExplicitAny: erased at the registry boundary\nexport type AnyPlugin = SealpixelPlugin<string, any, any>;\n\n/** Core stage kinds a `kernel: { kind: 'core' }` plugin may target. */\nexport type CoreStageName = Stage['kind'];\n"]}
@@ -55,4 +55,3 @@ export interface Registry {
55
55
  initialOps(source: SourceDescriptor): Omit<Operation, 'id'>[];
56
56
  }
57
57
  export declare function createRegistry(plugins: readonly AnyPlugin[]): Registry;
58
- //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA0D7C,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAClC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACnC,IAAI,EAAE,CAAC;SACJ,MAAM,EAAE;SACR,KAAK,CAAC,gBAAgB,CAAC;SACvB,QAAQ,EAAE;IACb,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,CAAC;KAClB,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,IAAI,EAAE,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AAC,CAAC,CAAC,kBAAkB,EAC/C,MAAM,CAAC,MAAM,CACd,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CACf,KAAwB,EACxB,KAAc;IAEd,IAAI,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IACnC,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC5D,MAAM,MAAM,GAAI,KAAgE,CAAC,MAAM,CAAC;QACxF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,cAAc,CAAmB,KAAQ;IAChD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAM,CAAC;AAC3F,CAAC","sourcesContent":["import { z } from 'zod';\nimport { SealpixelError } from './errors.js';\nimport type { AnyPlugin, AssetDeclaration, Document, OperationDef } from './plugin.js';\nimport type { EditLog, Operation, SourceDescriptor } from './types.js';\n\nexport interface ParseOptions {\n /**\n * Keep ops whose type is unknown instead of failing. They are ignored by\n * `compile`. Only for forward-compatible previews; servers must not set it.\n */\n tolerateUnknown?: boolean;\n}\n\nexport interface ParseIssue {\n /** Index into `ops`, or -1 for a top-level problem. */\n index: number;\n code: 'INVALID_EDIT_LOG' | 'UNKNOWN_PLUGIN' | 'UNKNOWN_OPERATION' | 'OPTION_VIOLATION';\n message: string;\n}\n\nexport type ParseResult = { ok: true; log: EditLog } | { ok: false; issues: ParseIssue[] };\n\nexport interface RegisteredOperation {\n plugin: AnyPlugin;\n // biome-ignore lint/suspicious/noExplicitAny: erased at the registry boundary\n def: OperationDef<any, any>;\n}\n\n/** Plugins plus everything derived from them: schemas, reducers, stage order. */\nexport interface Registry {\n /** Sorted by stage order, then id. */\n readonly plugins: readonly AnyPlugin[];\n readonly byId: ReadonlyMap<string, AnyPlugin>;\n readonly byOpType: ReadonlyMap<string, RegisteredOperation>;\n /** `{ pluginId: version }` for every registered plugin. */\n pluginVersions(): Record<string, number>;\n initialDocument(): Document;\n /** Validates and migrates an unknown value into an `EditLog`. Throws `SealpixelError`. */\n parseEditLog(value: unknown, options?: ParseOptions): EditLog;\n safeParseEditLog(value: unknown, options?: ParseOptions): ParseResult;\n /**\n * Runs the owning plugin's `validate` for one op against the document it\n * would apply to. Returns the violation message, or null.\n */\n validateOperation(op: Operation, document: Document, source: SourceDescriptor): string | null;\n /**\n * Runs every plugin's `validateDocument` over a compiled document. Returns\n * all violations; empty when the state satisfies the configured options.\n */\n validateDocument(\n document: Document,\n source: SourceDescriptor,\n ): { plugin: string; message: string }[];\n /** `{ pluginId: options }` for every plugin with options. */\n pluginOptions(): Record<string, unknown>;\n /** Ops that seed an empty log from option defaults, in stage order. */\n initialOps(source: SourceDescriptor): Omit<Operation, 'id'>[];\n}\n\nconst SourceSchema = z.object({\n id: z.string().min(1),\n width: z.number().int().positive(),\n height: z.number().int().positive(),\n hash: z\n .string()\n .regex(/^[0-9a-f]{64}$/)\n .optional(),\n mimeType: z.string().optional(),\n});\n\nconst AssetSchema = z\n .object({\n id: z.string().min(1),\n hash: z.string().regex(/^[0-9a-f]{64}$/),\n url: z.string().min(1).optional(),\n })\n .strict();\n\nconst LogShape = z.object({\n version: z.literal(1),\n source: SourceSchema,\n plugins: z.record(z.string(), z.number().int().positive()).default({}),\n assets: z.array(AssetSchema).max(1000).optional(),\n ops: z.array(z.unknown()).default([]),\n});\n\nexport function createRegistry(plugins: readonly AnyPlugin[]): Registry {\n const byId = new Map<string, AnyPlugin>();\n const byOpType = new Map<string, RegisteredOperation>();\n for (const plugin of plugins) {\n if (byId.has(plugin.id)) {\n throw new SealpixelError('INVALID_EDIT_LOG', `plugin \"${plugin.id}\" registered twice`);\n }\n byId.set(plugin.id, plugin);\n for (const def of plugin.operations) {\n if (byOpType.has(def.type)) {\n throw new SealpixelError('INVALID_EDIT_LOG', `operation \"${def.type}\" registered twice`);\n }\n byOpType.set(def.type, { plugin, def });\n }\n }\n const sorted = [...plugins].sort(\n (a, b) => a.stage.order - b.stage.order || a.id.localeCompare(b.id),\n );\n const initialDocument = () =>\n Object.fromEntries(sorted.map((p) => [p.id, p.initialDocument])) as Document;\n\n const validateOperation = (\n op: Operation,\n document: Document,\n source: SourceDescriptor,\n ): string | null => {\n const entry = byOpType.get(op.type);\n if (!entry?.plugin.validate) return null;\n const slice = (document as Record<string, unknown>)[entry.plugin.id];\n return entry.plugin.validate(op, { options: entry.plugin.options, slice, document, source });\n };\n\n const validateDocument = (document: Document, source: SourceDescriptor) => {\n const out: { plugin: string; message: string }[] = [];\n for (const plugin of sorted) {\n if (!plugin.validateDocument) continue;\n const slice = (document as Record<string, unknown>)[plugin.id];\n const message = plugin.validateDocument(slice, { options: plugin.options, document, source });\n if (message) out.push({ plugin: plugin.id, message });\n }\n return out;\n };\n\n const safeParseEditLog = (value: unknown, options: ParseOptions = {}): ParseResult => {\n const shape = LogShape.safeParse(value);\n if (!shape.success) {\n return {\n ok: false,\n issues: shape.error.issues.map((i) => ({\n index: -1,\n code: 'INVALID_EDIT_LOG',\n message: `${i.path.join('.') || '(root)'}: ${i.message}`,\n })),\n };\n }\n const issues: ParseIssue[] = [];\n const ops: Operation[] = [];\n // Slices reduced so far, so constraints can look at the state an op applies to.\n const document = initialDocument() as Record<string, unknown>;\n shape.data.ops.forEach((raw, index) => {\n const type =\n typeof raw === 'object' && raw !== null ? (raw as { type?: unknown }).type : undefined;\n if (typeof type !== 'string') {\n issues.push({ index, code: 'INVALID_EDIT_LOG', message: 'op has no string \"type\"' });\n return;\n }\n const entry = byOpType.get(type);\n if (!entry) {\n if (options.tolerateUnknown) {\n ops.push(raw as Operation);\n return;\n }\n const pluginId = type.slice(0, type.lastIndexOf('.'));\n issues.push(\n byId.has(pluginId)\n ? { index, code: 'UNKNOWN_OPERATION', message: `unknown operation \"${type}\"` }\n : { index, code: 'UNKNOWN_PLUGIN', message: `plugin \"${pluginId}\" is not registered` },\n );\n return;\n }\n const written = shape.data.plugins[entry.plugin.id];\n let candidate: unknown = raw;\n if (written !== undefined && written < entry.plugin.version) {\n if (!entry.def.migrate) {\n issues.push({\n index,\n code: 'INVALID_EDIT_LOG',\n message: `op \"${type}\" was written by ${entry.plugin.id} v${written}; v${entry.plugin.version} has no migration`,\n });\n return;\n }\n candidate = entry.def.migrate(written, raw);\n }\n const parsed = entry.def.schema.safeParse\n ? entry.def.schema.safeParse(candidate)\n : tryParse(entry.def.schema.parse, candidate);\n if (parsed.success) {\n const op = parsed.data as Operation;\n const violation = validateOperation(\n op,\n document as Document,\n stripUndefined(shape.data.source) as SourceDescriptor,\n );\n if (violation) {\n issues.push({ index, code: 'OPTION_VIOLATION', message: `op \"${type}\": ${violation}` });\n return;\n }\n ops.push(op);\n document[entry.plugin.id] = entry.def.reduce(document[entry.plugin.id], op);\n } else {\n issues.push({\n index,\n code: 'INVALID_EDIT_LOG',\n message: `op \"${type}\": ${describeError(parsed.error)}`,\n });\n }\n });\n if (issues.length > 0) return { ok: false, issues };\n // Every op of a registered plugin is now in its current schema. Record that\n // version, or the next parse migrates the ops again, including ops appended\n // since in the current schema.\n const plugins = { ...shape.data.plugins };\n for (const [id, written] of Object.entries(plugins)) {\n const plugin = byId.get(id);\n if (plugin && written < plugin.version) plugins[id] = plugin.version;\n }\n const log: EditLog = {\n version: 1,\n source: stripUndefined(shape.data.source) as SourceDescriptor,\n plugins,\n ...(shape.data.assets\n ? { assets: shape.data.assets.map((a) => stripUndefined(a) as AssetDeclaration) }\n : {}),\n ops,\n };\n return { ok: true, log };\n };\n\n return {\n plugins: sorted,\n byId,\n byOpType,\n pluginVersions: () => Object.fromEntries(sorted.map((p) => [p.id, p.version])),\n pluginOptions: () =>\n Object.fromEntries(\n sorted.filter((p) => p.options !== undefined).map((p) => [p.id, p.options]),\n ),\n initialDocument,\n initialOps: (source) =>\n sorted.flatMap((p) => p.initialOps?.({ options: p.options, source }) ?? []),\n validateOperation,\n validateDocument,\n safeParseEditLog,\n parseEditLog: (value, options) => {\n const result = safeParseEditLog(value, options);\n if (result.ok) return result.log;\n const first = result.issues[0];\n const code = result.issues.every((i) => i.code === 'UNKNOWN_PLUGIN')\n ? 'UNKNOWN_PLUGIN'\n : result.issues.some((i) => i.code === 'OPTION_VIOLATION')\n ? 'OPTION_VIOLATION'\n : 'INVALID_EDIT_LOG';\n throw new SealpixelError(\n code,\n first ? `${first.message}` : 'invalid edit log',\n result.issues,\n );\n },\n };\n}\n\nfunction tryParse<T>(\n parse: (v: unknown) => T,\n value: unknown,\n): { success: true; data: T } | { success: false; error: unknown } {\n try {\n return { success: true, data: parse(value) };\n } catch (error) {\n return { success: false, error };\n }\n}\n\nfunction describeError(error: unknown): string {\n if (error && typeof error === 'object' && 'issues' in error) {\n const issues = (error as { issues: { path: PropertyKey[]; message: string }[] }).issues;\n return issues.map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`).join('; ');\n }\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction stripUndefined<T extends object>(value: T): T {\n return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined)) as T;\n}\n"]}
package/dist/render.d.ts CHANGED
@@ -22,4 +22,8 @@ export interface PipelineOptions {
22
22
  export declare function runPipeline(wasm: SealpixelWasm, registry: Registry, image: RgbaBuffer, log: EditLog, options: PipelineOptions): Promise<RgbaBuffer>;
23
23
  /** Maps the public output options onto the Rust `OutputOptions` JSON. */
24
24
  export declare function toCoreOutput(output: OutputOptions): Record<string, unknown>;
25
- //# sourceMappingURL=render.d.ts.map
25
+ /**
26
+ * The inverse of `toCoreOutput`, for the options a render manifest records.
27
+ * `embed` is not an option here: `embedEditLog` regenerates it from the log.
28
+ */
29
+ export declare function fromCoreOutput(core: Record<string, unknown>): OutputOptions;
package/dist/render.js CHANGED
@@ -1,9 +1,10 @@
1
- import { loadSealpixelWasm } from '@sealpixel/wasm';
1
+ import { loadSealpixelWasm, } from '@sealpixel/wasm';
2
2
  import { withAssets } from './assets.js';
3
3
  import { canonicalJson } from './canonical-json.js';
4
4
  import { compile, toCoreStages, toPipeline } from './compile.js';
5
5
  import { SealpixelError } from './errors.js';
6
6
  import { runExternalKernel } from './external-kernel.js';
7
+ import { editLogHash, MANIFEST_VERSION, renderHash } from './manifest.js';
7
8
  import { PLAN_VERSION } from './plan.js';
8
9
  import { createRegistry } from './registry.js';
9
10
  const FORMAT_TO_CORE = {
@@ -24,10 +25,24 @@ export async function render(source, log, options) {
24
25
  const wasm = options.wasm ?? (await loadSealpixelWasm());
25
26
  const registry = options.registry ?? EMPTY_REGISTRY;
26
27
  throwIfAborted(options.signal);
28
+ const mode = options.mode ?? 'truth';
29
+ // What a manifest needs is checked before the hash and the decode, the
30
+ // expensive steps. A buffer source names its hash explicitly: the log's
31
+ // `source.hash` is a claim about bytes this call never saw.
32
+ if (options.manifest && mode !== 'truth') {
33
+ throw new SealpixelError('INVALID_REQUEST', 'a manifest describes a truth render; a preview cannot be verified');
34
+ }
35
+ const sourceHash = !options.manifest
36
+ ? undefined
37
+ : source instanceof Uint8Array
38
+ ? wasm.sha256Hex(source)
39
+ : options.sourceHash;
40
+ if (options.manifest && sourceHash === undefined) {
41
+ throw new SealpixelError('INVALID_REQUEST', 'a manifest needs the hash of the original: pass the bytes as source, or sourceHash with a buffer');
42
+ }
27
43
  const t0 = now();
28
44
  const image = source instanceof Uint8Array ? tryCore(() => wasm.decode(source)) : source;
29
45
  const decodeMs = now() - t0;
30
- const mode = options.mode ?? 'truth';
31
46
  if (mode === 'truth' &&
32
47
  (image.width !== log.source.width || image.height !== log.source.height)) {
33
48
  throw new SealpixelError('SOURCE_MISMATCH', `truth render expects ${log.source.width}x${log.source.height}, got ${image.width}x${image.height}`);
@@ -37,9 +52,10 @@ export async function render(source, log, options) {
37
52
  }
38
53
  throwIfAborted(options.signal);
39
54
  const t1 = now();
40
- const rendered = await withAssets(() => runPipeline(wasm, registry, image, log, {
55
+ const { stages, logical } = compileStages(registry, image, log, mode, options.upTo);
56
+ const rendered = await withAssets(() => executeStages(wasm, stages, image, logical, {
41
57
  mode,
42
- ...(options.upTo === undefined ? {} : { upTo: options.upTo }),
58
+ ...(options.manifest ? { pixelHash: true } : {}),
43
59
  ...(options.signal === undefined ? {} : { signal: options.signal }),
44
60
  }), options.assets, (id, bytes) => wasm.assetPut(id, bytes));
45
61
  const renderMs = now() - t1;
@@ -49,9 +65,13 @@ export async function render(source, log, options) {
49
65
  if (options.embedEditLog) {
50
66
  coreOutput['embed'] = canonicalJson({ log, index: options.upTo ?? log.ops.length });
51
67
  }
52
- const bytes = tryCore(() => wasm.encode(rendered, JSON.stringify(coreOutput)));
68
+ // A decoded source carries its ICC profile; pixels given by the caller carry
69
+ // what the caller attached, if anything. No `instanceof`: a typed array from
70
+ // another realm is still a profile.
71
+ const icc = image.icc;
72
+ const bytes = tryCore(() => wasm.encode(rendered, JSON.stringify(coreOutput), icc));
53
73
  const encodeMs = now() - t2;
54
- return {
74
+ const result = {
55
75
  bytes,
56
76
  mimeType: options.output.format,
57
77
  width: rendered.width,
@@ -60,24 +80,96 @@ export async function render(source, log, options) {
60
80
  coreVersion: wasm.version(),
61
81
  timings: { decode: decodeMs, render: renderMs, encode: encodeMs },
62
82
  };
83
+ if (options.manifest && sourceHash !== undefined) {
84
+ const t3 = now();
85
+ result.manifest = buildManifest(wasm, registry, stages, logical, log, options, {
86
+ sourceHash,
87
+ rendered,
88
+ bytes: result.hash,
89
+ output: toCoreOutput(options.output),
90
+ mimeType: image.mimeType,
91
+ });
92
+ result.timings['manifest'] = now() - t3;
93
+ }
94
+ return result;
95
+ }
96
+ /**
97
+ * The manifest of a finished render, from the stages that rendered. The plan
98
+ * is the single core plan of a render whose stages all ran in the core; a
99
+ * pipeline with a plugin kernel outside the core lists the kernels instead,
100
+ * and only a JavaScript runtime can verify it. `output.options` never
101
+ * carries `embed`: the log is in `editLog`, and `embedEditLog` says whether
102
+ * the file holds it too.
103
+ */
104
+ function buildManifest(wasm, registry, stages, logical, log, options, result) {
105
+ const index = options.upTo ?? log.ops.length;
106
+ const kernels = stages.filter((s) => s.kind !== 'core').map((s) => s.name);
107
+ const plan = kernels.length === 0
108
+ ? { version: PLAN_VERSION, source: logical, bufferScale: 1, stages: toCoreStages(stages) }
109
+ : undefined;
110
+ const plugins = registry.pluginVersions();
111
+ const renderer = wasm.identity();
112
+ // From the core when the last stage ran there; a kernel outside the core
113
+ // leaves its buffer in JavaScript, which is then hashed from there.
114
+ const pixelHash = result.rendered.pixelHash ?? wasm.pixelHash(result.rendered);
115
+ const logHash = editLogHash(wasm.sha256Hex, log, index);
116
+ return {
117
+ version: MANIFEST_VERSION,
118
+ source: {
119
+ width: log.source.width,
120
+ height: log.source.height,
121
+ hash: result.sourceHash,
122
+ ...(result.mimeType === undefined ? {} : { mimeType: result.mimeType }),
123
+ },
124
+ editLog: { log, index },
125
+ editLogHash: logHash,
126
+ ...(plan ? { plan } : { kernels }),
127
+ plugins,
128
+ renderer,
129
+ output: {
130
+ options: result.output,
131
+ ...(options.embedEditLog ? { embedEditLog: true } : {}),
132
+ width: result.rendered.width,
133
+ height: result.rendered.height,
134
+ pixelHash,
135
+ byteHash: result.bytes,
136
+ },
137
+ renderHash: renderHash(wasm.sha256Hex, {
138
+ sourceHash: result.sourceHash,
139
+ editsHash: logHash,
140
+ plugins,
141
+ renderer,
142
+ pixelHash,
143
+ byteHash: result.bytes,
144
+ }),
145
+ };
63
146
  }
64
147
  /**
65
148
  * Compiles the log and executes it: consecutive core stages become one wasm
66
149
  * call, every external kernel runs in between on the RGBA buffer.
67
150
  */
68
151
  export async function runPipeline(wasm, registry, image, log, options) {
69
- const doc = compile(log, registry, options.upTo);
152
+ const { stages, logical } = compileStages(registry, image, log, options.mode, options.upTo);
153
+ return executeStages(wasm, stages, image, logical, options);
154
+ }
155
+ /** Compiles `ops[0..upTo)` into the ordered stages for a buffer of `image`'s size. */
156
+ function compileStages(registry, image, log, mode, upTo) {
157
+ const doc = compile(log, registry, upTo);
70
158
  const logical = { width: log.source.width, height: log.source.height };
71
159
  const ctx = {
72
160
  logical,
73
161
  actual: { width: image.width, height: image.height },
74
162
  scale: image.width / log.source.width,
75
- mode: options.mode,
163
+ mode,
76
164
  };
77
- const stages = toPipeline(doc, registry, ctx);
165
+ return { stages: toPipeline(doc, registry, ctx), logical };
166
+ }
167
+ /** Runs the stages: consecutive core stages as one wasm call, every external kernel in between. */
168
+ async function executeStages(wasm, stages, image, logical, options) {
78
169
  let current = image;
79
170
  let currentLogical = logical;
80
- for (const segment of segments(stages)) {
171
+ const all = [...segments(stages)];
172
+ for (const [i, segment] of all.entries()) {
81
173
  throwIfAborted(options.signal);
82
174
  if (segment.kind === 'core') {
83
175
  const plan = {
@@ -88,7 +180,8 @@ export async function runPipeline(wasm, registry, image, log, options) {
88
180
  };
89
181
  const planJson = JSON.stringify(plan);
90
182
  const geometry = JSON.parse(tryCore(() => wasm.resolveGeometry(planJson, current.width, current.height)));
91
- current = tryCore(() => wasm.renderRgba(current, planJson));
183
+ const last = i === all.length - 1;
184
+ current = tryCore(() => wasm.renderRgba(current, planJson, options.pixelHash && last ? { pixelHash: true } : {}));
92
185
  currentLogical = geometry.logicalOut;
93
186
  }
94
187
  else {
@@ -146,6 +239,28 @@ export function toCoreOutput(output) {
146
239
  core['background'] = output.background;
147
240
  return core;
148
241
  }
242
+ /**
243
+ * The inverse of `toCoreOutput`, for the options a render manifest records.
244
+ * `embed` is not an option here: `embedEditLog` regenerates it from the log.
245
+ */
246
+ export function fromCoreOutput(core) {
247
+ const format = Object.keys(FORMAT_TO_CORE).find((f) => FORMAT_TO_CORE[f] === core['format']);
248
+ if (format === undefined) {
249
+ throw new SealpixelError('INVALID_REQUEST', `unknown output format ${String(core['format'])}`);
250
+ }
251
+ const output = { format };
252
+ if (typeof core['quality'] === 'number')
253
+ output.quality = core['quality'];
254
+ if (typeof core['progressive'] === 'boolean')
255
+ output.progressive = core['progressive'];
256
+ if (core['chromaSubsampling'] === '4:2:0' || core['chromaSubsampling'] === '4:4:4')
257
+ output.chromaSubsampling = core['chromaSubsampling'];
258
+ if (typeof core['lossless'] === 'boolean')
259
+ output.lossless = core['lossless'];
260
+ if (Array.isArray(core['background']) && core['background'].length === 3)
261
+ output.background = core['background'];
262
+ return output;
263
+ }
149
264
  function tryCore(fn) {
150
265
  try {
151
266
  return fn();
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAuC,MAAM,iBAAiB,CAAC;AACzF,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,EAAiB,YAAY,EAAmB,MAAM,WAAW,CAAC;AAEz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E,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;IACvF,IAAI,IAAI,CAAC,mBAAmB,CAAC,KAAK,OAAO,IAAI,IAAI,CAAC,mBAAmB,CAAC,KAAK,OAAO;QAChF,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 } 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/** 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"]}
@@ -28,7 +28,8 @@ export interface ExportRequest {
28
28
  embedEditLog?: boolean;
29
29
  }
30
30
  export interface ExportResult {
31
- bytes: Uint8Array;
31
+ /** Backed by a plain `ArrayBuffer`, so it is a `BlobPart`. */
32
+ bytes: Uint8Array<ArrayBuffer>;
32
33
  mimeType: OutputOptions['format'];
33
34
  width: number;
34
35
  height: number;
@@ -53,6 +54,8 @@ export declare class RendererCore {
53
54
  readonly registry: Registry;
54
55
  private readonly options;
55
56
  private full;
57
+ /** The source's ICC profile, kept with the resident pixels for the export. */
58
+ private icc;
56
59
  private workingCopy;
57
60
  private descriptor;
58
61
  private readonly cache;
@@ -84,4 +87,3 @@ export declare class RendererCore {
84
87
  /** For tests: number of cached stage outputs. */
85
88
  cacheSize(): number;
86
89
  }
87
- //# sourceMappingURL=renderer-core.d.ts.map