@sealpixel/core 1.0.0-rc.2 → 1.0.0-rc.21
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/LICENSE.md +2 -2
- package/dist/assets.d.ts +0 -1
- package/dist/assets.js.map +1 -1
- package/dist/canonical-json.d.ts +0 -1
- package/dist/canonical-json.js.map +1 -1
- package/dist/compile.d.ts +0 -1
- package/dist/compile.js.map +1 -1
- package/dist/embedded.d.ts +0 -1
- package/dist/embedded.js.map +1 -1
- package/dist/errors.d.ts +1 -2
- package/dist/errors.js.map +1 -1
- package/dist/external-kernel.d.ts +0 -1
- package/dist/external-kernel.js.map +1 -1
- package/dist/generated/geometry.d.ts +1 -2
- package/dist/generated/geometry.js.map +1 -1
- package/dist/generated/output.d.ts +0 -1
- package/dist/generated/output.js.map +1 -1
- package/dist/generated/plan.d.ts +18 -7
- package/dist/generated/plan.js.map +1 -1
- package/dist/history.d.ts +2 -1
- package/dist/history.js +5 -1
- package/dist/history.js.map +1 -1
- package/dist/image-size.d.ts +4 -3
- package/dist/image-size.js +5 -3
- package/dist/image-size.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/inline-renderer.d.ts +4 -5
- package/dist/inline-renderer.js +7 -7
- package/dist/inline-renderer.js.map +1 -1
- package/dist/manifest.d.ts +127 -0
- package/dist/manifest.js +115 -0
- package/dist/manifest.js.map +1 -0
- package/dist/options.d.ts +0 -1
- package/dist/options.js.map +1 -1
- package/dist/plan.d.ts +0 -1
- package/dist/plan.js +1 -1
- package/dist/plan.js.map +1 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/plugin.js.map +1 -1
- package/dist/registry.d.ts +0 -1
- package/dist/registry.js +10 -1
- package/dist/registry.js.map +1 -1
- package/dist/render.d.ts +21 -1
- package/dist/render.js +148 -12
- package/dist/render.js.map +1 -1
- package/dist/renderer-core.d.ts +24 -17
- package/dist/renderer-core.js +36 -22
- package/dist/renderer-core.js.map +1 -1
- package/dist/renderer.d.ts +5 -6
- package/dist/renderer.js.map +1 -1
- package/dist/session.d.ts +30 -50
- package/dist/session.js +142 -169
- package/dist/session.js.map +1 -1
- package/dist/types.d.ts +18 -3
- package/dist/types.js.map +1 -1
- package/dist/worker-protocol.d.ts +8 -8
- package/dist/worker-protocol.js.map +1 -1
- package/dist/worker-renderer.d.ts +4 -5
- package/dist/worker-renderer.js +15 -6
- package/dist/worker-renderer.js.map +1 -1
- package/dist/worker.d.ts +0 -1
- package/dist/worker.js +6 -6
- package/dist/worker.js.map +1 -1
- package/package.json +6 -6
- package/dist/assets.d.ts.map +0 -1
- package/dist/canonical-json.d.ts.map +0 -1
- package/dist/compile.d.ts.map +0 -1
- package/dist/embedded.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/external-kernel.d.ts.map +0 -1
- package/dist/generated/geometry.d.ts.map +0 -1
- package/dist/generated/output.d.ts.map +0 -1
- package/dist/generated/plan.d.ts.map +0 -1
- package/dist/history.d.ts.map +0 -1
- package/dist/image-size.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/inline-renderer.d.ts.map +0 -1
- package/dist/options.d.ts.map +0 -1
- package/dist/plan.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/registry.d.ts.map +0 -1
- package/dist/render.d.ts.map +0 -1
- package/dist/renderer-core.d.ts.map +0 -1
- package/dist/renderer.d.ts.map +0 -1
- package/dist/session.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/worker-protocol.d.ts.map +0 -1
- package/dist/worker-renderer.d.ts.map +0 -1
- package/dist/worker.d.ts.map +0 -1
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
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
74
|
+
const result = {
|
|
55
75
|
bytes,
|
|
56
76
|
mimeType: options.output.format,
|
|
57
77
|
width: rendered.width,
|
|
@@ -60,35 +80,129 @@ 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
|
|
152
|
+
const { stages, logical } = compileStages(registry, image, log, options.mode, options.upTo);
|
|
153
|
+
return executeStages(wasm, stages, image, logical, options);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The core plan of a truth render of `ops[0..upTo)`, when every stage runs in
|
|
157
|
+
* the core, and otherwise the stages that run outside it. What a render
|
|
158
|
+
* manifest records, and what a C2PA manifest definition is made from.
|
|
159
|
+
*/
|
|
160
|
+
export function compileCorePlan(log, registry, upTo) {
|
|
161
|
+
const logical = { width: log.source.width, height: log.source.height };
|
|
162
|
+
const { stages } = compileStages(registry, { ...logical, data: EMPTY }, log, 'truth', upTo);
|
|
163
|
+
const kernels = stages
|
|
164
|
+
.filter((s) => s.kind !== 'core')
|
|
165
|
+
.map((s) => ({ name: s.name, order: s.order }));
|
|
166
|
+
const coreStages = toCoreStages(stages.filter((s) => s.kind === 'core'));
|
|
167
|
+
return kernels.length === 0
|
|
168
|
+
? {
|
|
169
|
+
plan: { version: PLAN_VERSION, source: logical, bufferScale: 1, stages: coreStages },
|
|
170
|
+
coreStages,
|
|
171
|
+
kernels,
|
|
172
|
+
}
|
|
173
|
+
: { coreStages, kernels };
|
|
174
|
+
}
|
|
175
|
+
const EMPTY = new Uint8Array(0);
|
|
176
|
+
/** Compiles `ops[0..upTo)` into the ordered stages for a buffer of `image`'s size. */
|
|
177
|
+
function compileStages(registry, image, log, mode, upTo) {
|
|
178
|
+
const doc = compile(log, registry, upTo);
|
|
70
179
|
const logical = { width: log.source.width, height: log.source.height };
|
|
71
180
|
const ctx = {
|
|
72
181
|
logical,
|
|
73
182
|
actual: { width: image.width, height: image.height },
|
|
74
183
|
scale: image.width / log.source.width,
|
|
75
|
-
mode
|
|
184
|
+
mode,
|
|
76
185
|
};
|
|
77
|
-
|
|
186
|
+
return { stages: toPipeline(doc, registry, ctx), logical };
|
|
187
|
+
}
|
|
188
|
+
/** Runs the stages: consecutive core stages as one wasm call, every external kernel in between. */
|
|
189
|
+
async function executeStages(wasm, stages, image, logical, options) {
|
|
78
190
|
let current = image;
|
|
79
191
|
let currentLogical = logical;
|
|
80
|
-
|
|
192
|
+
const all = [...segments(stages)];
|
|
193
|
+
for (const [i, segment] of all.entries()) {
|
|
81
194
|
throwIfAborted(options.signal);
|
|
82
195
|
if (segment.kind === 'core') {
|
|
83
196
|
const plan = {
|
|
84
197
|
version: PLAN_VERSION,
|
|
85
198
|
source: currentLogical,
|
|
86
|
-
|
|
199
|
+
bufferScale: current.width / currentLogical.width,
|
|
87
200
|
stages: toCoreStages(segment.stages),
|
|
88
201
|
};
|
|
89
202
|
const planJson = JSON.stringify(plan);
|
|
90
203
|
const geometry = JSON.parse(tryCore(() => wasm.resolveGeometry(planJson, current.width, current.height)));
|
|
91
|
-
|
|
204
|
+
const last = i === all.length - 1;
|
|
205
|
+
current = tryCore(() => wasm.renderRgba(current, planJson, options.pixelHash && last ? { pixelHash: true } : {}));
|
|
92
206
|
currentLogical = geometry.logicalOut;
|
|
93
207
|
}
|
|
94
208
|
else {
|
|
@@ -146,6 +260,28 @@ export function toCoreOutput(output) {
|
|
|
146
260
|
core['background'] = output.background;
|
|
147
261
|
return core;
|
|
148
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* The inverse of `toCoreOutput`, for the options a render manifest records.
|
|
265
|
+
* `embed` is not an option here: `embedEditLog` regenerates it from the log.
|
|
266
|
+
*/
|
|
267
|
+
export function fromCoreOutput(core) {
|
|
268
|
+
const format = Object.keys(FORMAT_TO_CORE).find((f) => FORMAT_TO_CORE[f] === core['format']);
|
|
269
|
+
if (format === undefined) {
|
|
270
|
+
throw new SealpixelError('INVALID_REQUEST', `unknown output format ${String(core['format'])}`);
|
|
271
|
+
}
|
|
272
|
+
const output = { format };
|
|
273
|
+
if (typeof core['quality'] === 'number')
|
|
274
|
+
output.quality = core['quality'];
|
|
275
|
+
if (typeof core['progressive'] === 'boolean')
|
|
276
|
+
output.progressive = core['progressive'];
|
|
277
|
+
if (core['chromaSubsampling'] === '4:2:0' || core['chromaSubsampling'] === '4:4:4')
|
|
278
|
+
output.chromaSubsampling = core['chromaSubsampling'];
|
|
279
|
+
if (typeof core['lossless'] === 'boolean')
|
|
280
|
+
output.lossless = core['lossless'];
|
|
281
|
+
if (Array.isArray(core['background']) && core['background'].length === 3)
|
|
282
|
+
output.background = core['background'];
|
|
283
|
+
return output;
|
|
284
|
+
}
|
|
149
285
|
function tryCore(fn) {
|
|
150
286
|
try {
|
|
151
287
|
return fn();
|
package/dist/render.js.map
CHANGED
|
@@ -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,cA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KAAK,SAAS;QAAE,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, 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"]}
|
package/dist/renderer-core.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The renderer's logic, independent of where it runs. `startSealpixelWorker`
|
|
3
3
|
* wraps it behind a message protocol; `InlineRenderer` calls it directly.
|
|
4
|
-
* It owns the decoded source, the
|
|
4
|
+
* It owns the decoded source, the working copy, and a per-stage preview cache.
|
|
5
5
|
*/
|
|
6
6
|
import type { RgbaBuffer, SealpixelWasm } from '@sealpixel/wasm';
|
|
7
7
|
import { type Geometry } from './plan.js';
|
|
@@ -12,12 +12,12 @@ export interface LoadedSource {
|
|
|
12
12
|
descriptor: SourceDescriptor;
|
|
13
13
|
/** Full-resolution pixels are kept only when under the megapixel limit. */
|
|
14
14
|
resident: boolean;
|
|
15
|
-
|
|
15
|
+
workingCopy: RgbaBuffer;
|
|
16
16
|
}
|
|
17
17
|
export interface RenderRequest {
|
|
18
18
|
log: EditLog;
|
|
19
|
-
/** `
|
|
20
|
-
target: '
|
|
19
|
+
/** `workingCopy` renders on the working copy in preview mode; `full` renders the resident source in truth mode. */
|
|
20
|
+
target: 'workingCopy' | 'full';
|
|
21
21
|
upTo?: number;
|
|
22
22
|
signal?: AbortSignal;
|
|
23
23
|
}
|
|
@@ -28,7 +28,8 @@ export interface ExportRequest {
|
|
|
28
28
|
embedEditLog?: boolean;
|
|
29
29
|
}
|
|
30
30
|
export interface ExportResult {
|
|
31
|
-
|
|
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;
|
|
@@ -36,19 +37,26 @@ export interface ExportResult {
|
|
|
36
37
|
}
|
|
37
38
|
export interface RendererCoreOptions {
|
|
38
39
|
plugins: readonly AnyPlugin[];
|
|
39
|
-
/** Full-resolution pixels above this are not kept after loading. */
|
|
40
|
+
/** Full-resolution pixels above this are not kept after loading. `RendererLoadOptions` overrides it per load. */
|
|
40
41
|
maxClientMegapixels: number;
|
|
41
|
-
/** Longest side of the preview
|
|
42
|
-
|
|
42
|
+
/** Longest side of the preview working copy. */
|
|
43
|
+
workingCopyMaxSide: number;
|
|
43
44
|
/** Cached stage outputs kept for the preview pipeline. */
|
|
44
45
|
cacheEntries?: number;
|
|
45
46
|
}
|
|
47
|
+
/** Per-load overrides of `RendererCoreOptions`. The session passes its `limits` here. */
|
|
48
|
+
export interface RendererLoadOptions {
|
|
49
|
+
/** Full-resolution pixels above this are not kept after loading. Defaults to the renderer's option. */
|
|
50
|
+
maxClientMegapixels?: number;
|
|
51
|
+
}
|
|
46
52
|
export declare class RendererCore {
|
|
47
53
|
readonly wasm: SealpixelWasm;
|
|
48
54
|
readonly registry: Registry;
|
|
49
55
|
private readonly options;
|
|
50
56
|
private full;
|
|
51
|
-
|
|
57
|
+
/** The source's ICC profile, kept with the resident pixels for the export. */
|
|
58
|
+
private icc;
|
|
59
|
+
private workingCopy;
|
|
52
60
|
private descriptor;
|
|
53
61
|
private readonly cache;
|
|
54
62
|
constructor(wasm: SealpixelWasm, options: RendererCoreOptions);
|
|
@@ -58,19 +66,19 @@ export declare class RendererCore {
|
|
|
58
66
|
coreVersion: string;
|
|
59
67
|
plugins: Record<string, number>;
|
|
60
68
|
};
|
|
61
|
-
/** Decodes `bytes`, derives the descriptor and
|
|
62
|
-
load(bytes: Uint8Array, id: string): LoadedSource;
|
|
63
|
-
/** Decodes an encoded
|
|
64
|
-
|
|
65
|
-
/** Accepts pixels decoded elsewhere
|
|
66
|
-
|
|
69
|
+
/** Decodes `bytes`, derives the descriptor and working copy, and drops the full image when too large. */
|
|
70
|
+
load(bytes: Uint8Array, id: string, loadOptions?: RendererLoadOptions): LoadedSource;
|
|
71
|
+
/** Decodes an encoded working copy (for example one the host built elsewhere) and uses it as the preview source. */
|
|
72
|
+
loadWorkingCopyEncoded(bytes: Uint8Array, descriptor: SourceDescriptor): LoadedSource;
|
|
73
|
+
/** Accepts pixels decoded elsewhere, for example by a native decoder. Never resident. */
|
|
74
|
+
loadWorkingCopy(workingCopy: RgbaBuffer, descriptor: SourceDescriptor): LoadedSource;
|
|
67
75
|
hasSource(): boolean;
|
|
68
76
|
isResident(): boolean;
|
|
69
77
|
unload(): void;
|
|
70
78
|
/** Renders the log. Preview renders are split per stage and cached by prefix. */
|
|
71
79
|
render(req: RenderRequest): Promise<RgbaBuffer>;
|
|
72
80
|
export(req: ExportRequest): Promise<ExportResult>;
|
|
73
|
-
geometry(log: EditLog, target: '
|
|
81
|
+
geometry(log: EditLog, target: 'workingCopy' | 'full', upTo?: number): Geometry;
|
|
74
82
|
private require;
|
|
75
83
|
private runStages;
|
|
76
84
|
/** Recomputes the logical size after a cached stage by asking the core for its geometry. */
|
|
@@ -79,4 +87,3 @@ export declare class RendererCore {
|
|
|
79
87
|
/** For tests: number of cached stage outputs. */
|
|
80
88
|
cacheSize(): number;
|
|
81
89
|
}
|
|
82
|
-
//# sourceMappingURL=renderer-core.d.ts.map
|
package/dist/renderer-core.js
CHANGED
|
@@ -10,7 +10,9 @@ export class RendererCore {
|
|
|
10
10
|
registry;
|
|
11
11
|
options;
|
|
12
12
|
full = null;
|
|
13
|
-
|
|
13
|
+
/** The source's ICC profile, kept with the resident pixels for the export. */
|
|
14
|
+
icc;
|
|
15
|
+
workingCopy = null;
|
|
14
16
|
descriptor = null;
|
|
15
17
|
cache = new Map();
|
|
16
18
|
constructor(wasm, options) {
|
|
@@ -27,8 +29,8 @@ export class RendererCore {
|
|
|
27
29
|
info() {
|
|
28
30
|
return { coreVersion: this.wasm.version(), plugins: this.registry.pluginVersions() };
|
|
29
31
|
}
|
|
30
|
-
/** Decodes `bytes`, derives the descriptor and
|
|
31
|
-
load(bytes, id) {
|
|
32
|
+
/** Decodes `bytes`, derives the descriptor and working copy, and drops the full image when too large. */
|
|
33
|
+
load(bytes, id, loadOptions = {}) {
|
|
32
34
|
const decoded = this.wasm.decode(bytes);
|
|
33
35
|
const hash = this.wasm.sha256Hex(bytes);
|
|
34
36
|
const descriptor = {
|
|
@@ -39,25 +41,36 @@ export class RendererCore {
|
|
|
39
41
|
mimeType: decoded.mimeType,
|
|
40
42
|
};
|
|
41
43
|
const megapixels = (decoded.width * decoded.height) / 1e6;
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
+
const maxClientMegapixels = loadOptions.maxClientMegapixels ?? this.options.maxClientMegapixels;
|
|
45
|
+
const resident = megapixels <= maxClientMegapixels;
|
|
46
|
+
const workingCopy = this.wasm.resizeWorkingCopy(decoded, this.options.workingCopyMaxSide);
|
|
44
47
|
this.full = resident ? decoded : null;
|
|
45
|
-
this.
|
|
48
|
+
this.icc = resident ? decoded.icc : undefined;
|
|
49
|
+
this.workingCopy = workingCopy;
|
|
46
50
|
this.descriptor = descriptor;
|
|
47
51
|
this.cache.clear();
|
|
48
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
descriptor,
|
|
54
|
+
resident,
|
|
55
|
+
workingCopy: { ...workingCopy, data: new Uint8Array(workingCopy.data) },
|
|
56
|
+
};
|
|
49
57
|
}
|
|
50
|
-
/** Decodes an encoded
|
|
51
|
-
|
|
52
|
-
return this.
|
|
58
|
+
/** Decodes an encoded working copy (for example one the host built elsewhere) and uses it as the preview source. */
|
|
59
|
+
loadWorkingCopyEncoded(bytes, descriptor) {
|
|
60
|
+
return this.loadWorkingCopy(this.wasm.decode(bytes), descriptor);
|
|
53
61
|
}
|
|
54
|
-
/** Accepts pixels decoded elsewhere
|
|
55
|
-
|
|
62
|
+
/** Accepts pixels decoded elsewhere, for example by a native decoder. Never resident. */
|
|
63
|
+
loadWorkingCopy(workingCopy, descriptor) {
|
|
56
64
|
this.full = null;
|
|
57
|
-
this.
|
|
65
|
+
this.icc = undefined;
|
|
66
|
+
this.workingCopy = workingCopy;
|
|
58
67
|
this.descriptor = descriptor;
|
|
59
68
|
this.cache.clear();
|
|
60
|
-
return {
|
|
69
|
+
return {
|
|
70
|
+
descriptor,
|
|
71
|
+
resident: false,
|
|
72
|
+
workingCopy: { ...workingCopy, data: new Uint8Array(workingCopy.data) },
|
|
73
|
+
};
|
|
61
74
|
}
|
|
62
75
|
hasSource() {
|
|
63
76
|
return this.descriptor !== null;
|
|
@@ -67,17 +80,18 @@ export class RendererCore {
|
|
|
67
80
|
}
|
|
68
81
|
unload() {
|
|
69
82
|
this.full = null;
|
|
70
|
-
this.
|
|
83
|
+
this.icc = undefined;
|
|
84
|
+
this.workingCopy = null;
|
|
71
85
|
this.descriptor = null;
|
|
72
86
|
this.cache.clear();
|
|
73
87
|
}
|
|
74
88
|
/** Renders the log. Preview renders are split per stage and cached by prefix. */
|
|
75
89
|
async render(req) {
|
|
76
90
|
const { descriptor } = this.require();
|
|
77
|
-
const image = req.target === 'full' ? this.full : this.
|
|
91
|
+
const image = req.target === 'full' ? this.full : this.workingCopy;
|
|
78
92
|
if (!image) {
|
|
79
93
|
throw new SealpixelError('SOURCE_MISMATCH', req.target === 'full'
|
|
80
|
-
? 'full-resolution pixels are not resident;
|
|
94
|
+
? 'full-resolution pixels are not resident; render the original outside the browser'
|
|
81
95
|
: 'no source loaded');
|
|
82
96
|
}
|
|
83
97
|
const mode = req.target === 'full' ? 'truth' : 'preview';
|
|
@@ -102,7 +116,7 @@ export class RendererCore {
|
|
|
102
116
|
if (req.embedEditLog) {
|
|
103
117
|
coreOutput['embed'] = canonicalJson({ log: req.log, index: req.upTo ?? req.log.ops.length });
|
|
104
118
|
}
|
|
105
|
-
const bytes = this.wasm.encode(rendered, JSON.stringify(coreOutput));
|
|
119
|
+
const bytes = this.wasm.encode(rendered, JSON.stringify(coreOutput), this.icc);
|
|
106
120
|
return {
|
|
107
121
|
bytes,
|
|
108
122
|
mimeType: req.output.format,
|
|
@@ -113,7 +127,7 @@ export class RendererCore {
|
|
|
113
127
|
}
|
|
114
128
|
geometry(log, target, upTo) {
|
|
115
129
|
const { descriptor } = this.require();
|
|
116
|
-
const image = (target === 'full' ? this.full : this.
|
|
130
|
+
const image = (target === 'full' ? this.full : this.workingCopy) ?? this.workingCopy;
|
|
117
131
|
if (!image)
|
|
118
132
|
throw new SealpixelError('SOURCE_MISMATCH', 'no source loaded');
|
|
119
133
|
const logical = { width: descriptor.width, height: descriptor.height };
|
|
@@ -128,7 +142,7 @@ export class RendererCore {
|
|
|
128
142
|
const plan = {
|
|
129
143
|
version: PLAN_VERSION,
|
|
130
144
|
source: logical,
|
|
131
|
-
|
|
145
|
+
bufferScale: image.width / logical.width,
|
|
132
146
|
stages: toCoreStages(core),
|
|
133
147
|
};
|
|
134
148
|
return JSON.parse(this.wasm.resolveGeometry(JSON.stringify(plan), image.width, image.height));
|
|
@@ -156,7 +170,7 @@ export class RendererCore {
|
|
|
156
170
|
const plan = {
|
|
157
171
|
version: PLAN_VERSION,
|
|
158
172
|
source: currentLogical,
|
|
159
|
-
|
|
173
|
+
bufferScale: current.width / currentLogical.width,
|
|
160
174
|
stages: toCoreStages([stage]),
|
|
161
175
|
};
|
|
162
176
|
const planJson = JSON.stringify(plan);
|
|
@@ -202,7 +216,7 @@ export class RendererCore {
|
|
|
202
216
|
const plan = {
|
|
203
217
|
version: PLAN_VERSION,
|
|
204
218
|
source: logicalIn,
|
|
205
|
-
|
|
219
|
+
bufferScale: 1,
|
|
206
220
|
stages: toCoreStages([stage]),
|
|
207
221
|
};
|
|
208
222
|
const g = JSON.parse(this.wasm.resolveGeometry(JSON.stringify(plan), logicalIn.width, logicalIn.height));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer-core.js","sourceRoot":"","sources":["../src/renderer-core.ts"],"names":[],"mappings":"AAMA,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;AAEzE,OAAO,EAAE,cAAc,EAAiB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA2C3C,MAAM,OAAO,YAAY;IASZ;IARF,QAAQ,CAAW;IACX,OAAO,CAAsB;IACtC,IAAI,GAAsB,IAAI,CAAC;IAC/B,KAAK,GAAsB,IAAI,CAAC;IAChC,UAAU,GAA4B,IAAI,CAA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B,OAAO,EAAE,YAAY;YACrB,MAAM,EAAE,SAAS;YACjB,WAAW,EAAE,CAAC;YACd,MAAM,EAAE,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC;SAC9B,CAAC;QACF,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAClB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CACvE,CAAC;QACd,OAAO,CAAC,CAAC,UAAU,CAAC;IACtB,CAAC;IAEO,QAAQ,CAAC,GAAW,EAAE,KAAiB;QAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC;QAC7C,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YAC9C,IAAI,MAAM,KAAK,SAAS;gBAAE,MAAM;YAChC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,iDAAiD;IACjD,SAAS;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF","sourcesContent":["/**\n * The renderer's logic, independent of where it runs. `startSealpixelWorker`\n * wraps it behind a message protocol; `InlineRenderer` calls it directly.\n * It owns the decoded source, the working copy, and a per-stage preview cache.\n */\nimport type { RgbaBuffer, SealpixelWasm } from '@sealpixel/wasm';\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 { type Geometry, PLAN_VERSION, type RenderPlan } from './plan.js';\nimport type { AnyPlugin, KernelContext, PlanContext } from './plugin.js';\nimport { createRegistry, type Registry } from './registry.js';\nimport { toCoreOutput } from './render.js';\nimport type { EditLog, OutputOptions, SourceDescriptor } from './types.js';\n\nexport interface LoadedSource {\n descriptor: SourceDescriptor;\n /** Full-resolution pixels are kept only when under the megapixel limit. */\n resident: boolean;\n workingCopy: RgbaBuffer;\n}\n\nexport interface RenderRequest {\n log: EditLog;\n /** `workingCopy` renders on the working copy in preview mode; `full` renders the resident source in truth mode. */\n target: 'workingCopy' | 'full';\n upTo?: number;\n signal?: AbortSignal;\n}\n\nexport interface ExportRequest {\n log: EditLog;\n output: OutputOptions;\n upTo?: number;\n embedEditLog?: boolean;\n}\n\nexport interface ExportResult {\n /** Backed by a plain `ArrayBuffer`, so it is a `BlobPart`. */\n bytes: Uint8Array<ArrayBuffer>;\n mimeType: OutputOptions['format'];\n width: number;\n height: number;\n hash: string;\n}\n\nexport interface RendererCoreOptions {\n plugins: readonly AnyPlugin[];\n /** Full-resolution pixels above this are not kept after loading. `RendererLoadOptions` overrides it per load. */\n maxClientMegapixels: number;\n /** Longest side of the preview working copy. */\n workingCopyMaxSide: number;\n /** Cached stage outputs kept for the preview pipeline. */\n cacheEntries?: number;\n}\n\n/** Per-load overrides of `RendererCoreOptions`. The session passes its `limits` here. */\nexport interface RendererLoadOptions {\n /** Full-resolution pixels above this are not kept after loading. Defaults to the renderer's option. */\n maxClientMegapixels?: number;\n}\n\nexport class RendererCore {\n readonly registry: Registry;\n private readonly options: RendererCoreOptions;\n private full: RgbaBuffer | null = null;\n /** The source's ICC profile, kept with the resident pixels for the export. */\n private icc: Uint8Array | undefined;\n private workingCopy: RgbaBuffer | null = null;\n private descriptor: SourceDescriptor | null = null;\n private readonly cache = new Map<string, RgbaBuffer>();\n\n constructor(\n readonly wasm: SealpixelWasm,\n options: RendererCoreOptions,\n ) {\n this.options = options;\n this.registry = createRegistry(options.plugins);\n }\n\n putAsset(id: string, bytes: Uint8Array): void {\n this.wasm.assetPut(id, bytes);\n }\n\n hasAsset(id: string): boolean {\n return this.wasm.assetHas(id);\n }\n\n info(): { coreVersion: string; plugins: Record<string, number> } {\n return { coreVersion: this.wasm.version(), plugins: this.registry.pluginVersions() };\n }\n\n /** Decodes `bytes`, derives the descriptor and working copy, and drops the full image when too large. */\n load(bytes: Uint8Array, id: string, loadOptions: RendererLoadOptions = {}): LoadedSource {\n const decoded = this.wasm.decode(bytes);\n const hash = this.wasm.sha256Hex(bytes);\n const descriptor: SourceDescriptor = {\n id,\n width: decoded.width,\n height: decoded.height,\n hash,\n mimeType: decoded.mimeType,\n };\n const megapixels = (decoded.width * decoded.height) / 1e6;\n const maxClientMegapixels = loadOptions.maxClientMegapixels ?? this.options.maxClientMegapixels;\n const resident = megapixels <= maxClientMegapixels;\n const workingCopy = this.wasm.resizeWorkingCopy(decoded, this.options.workingCopyMaxSide);\n this.full = resident ? decoded : null;\n this.icc = resident ? decoded.icc : undefined;\n this.workingCopy = workingCopy;\n this.descriptor = descriptor;\n this.cache.clear();\n return {\n descriptor,\n resident,\n workingCopy: { ...workingCopy, data: new Uint8Array(workingCopy.data) },\n };\n }\n\n /** Decodes an encoded working copy (for example one the host built elsewhere) and uses it as the preview source. */\n loadWorkingCopyEncoded(bytes: Uint8Array, descriptor: SourceDescriptor): LoadedSource {\n return this.loadWorkingCopy(this.wasm.decode(bytes), descriptor);\n }\n\n /** Accepts pixels decoded elsewhere, for example by a native decoder. Never resident. */\n loadWorkingCopy(workingCopy: RgbaBuffer, descriptor: SourceDescriptor): LoadedSource {\n this.full = null;\n this.icc = undefined;\n this.workingCopy = workingCopy;\n this.descriptor = descriptor;\n this.cache.clear();\n return {\n descriptor,\n resident: false,\n workingCopy: { ...workingCopy, data: new Uint8Array(workingCopy.data) },\n };\n }\n\n hasSource(): boolean {\n return this.descriptor !== null;\n }\n\n isResident(): boolean {\n return this.full !== null;\n }\n\n unload(): void {\n this.full = null;\n this.icc = undefined;\n this.workingCopy = null;\n this.descriptor = null;\n this.cache.clear();\n }\n\n /** Renders the log. Preview renders are split per stage and cached by prefix. */\n async render(req: RenderRequest): Promise<RgbaBuffer> {\n const { descriptor } = this.require();\n const image = req.target === 'full' ? this.full : this.workingCopy;\n if (!image) {\n throw new SealpixelError(\n 'SOURCE_MISMATCH',\n req.target === 'full'\n ? 'full-resolution pixels are not resident; render the original outside the browser'\n : 'no source loaded',\n );\n }\n const mode = req.target === 'full' ? 'truth' : 'preview';\n const doc = compile(req.log, this.registry, req.upTo);\n const logical = { width: descriptor.width, height: descriptor.height };\n const ctx: PlanContext = {\n logical,\n actual: { width: image.width, height: image.height },\n scale: image.width / logical.width,\n mode,\n };\n const stages = toPipeline(doc, this.registry, ctx);\n return this.runStages(stages, image, logical, mode, req.signal, mode === 'preview');\n }\n\n async export(req: ExportRequest): Promise<ExportResult> {\n const rendered = await this.render({\n log: req.log,\n target: 'full',\n ...(req.upTo === undefined ? {} : { upTo: req.upTo }),\n });\n const coreOutput = toCoreOutput(req.output);\n if (req.embedEditLog) {\n coreOutput['embed'] = canonicalJson({ log: req.log, index: req.upTo ?? req.log.ops.length });\n }\n const bytes = this.wasm.encode(rendered, JSON.stringify(coreOutput), this.icc);\n return {\n bytes,\n mimeType: req.output.format,\n width: rendered.width,\n height: rendered.height,\n hash: this.wasm.sha256Hex(bytes),\n };\n }\n\n geometry(log: EditLog, target: 'workingCopy' | 'full', upTo?: number): Geometry {\n const { descriptor } = this.require();\n const image = (target === 'full' ? this.full : this.workingCopy) ?? this.workingCopy;\n if (!image) throw new SealpixelError('SOURCE_MISMATCH', 'no source loaded');\n const logical = { width: descriptor.width, height: descriptor.height };\n const doc = compile(log, this.registry, upTo);\n const stages = toPipeline(doc, this.registry, {\n logical,\n actual: { width: image.width, height: image.height },\n scale: image.width / logical.width,\n mode: target === 'full' ? 'truth' : 'preview',\n });\n const core = stages.filter((s) => s.kind === 'core');\n const plan: RenderPlan = {\n version: PLAN_VERSION,\n source: logical,\n bufferScale: image.width / logical.width,\n stages: toCoreStages(core),\n };\n return JSON.parse(\n this.wasm.resolveGeometry(JSON.stringify(plan), image.width, image.height),\n ) as Geometry;\n }\n\n private require(): { descriptor: SourceDescriptor } {\n if (!this.descriptor) throw new SealpixelError('SOURCE_MISMATCH', 'no source loaded');\n return { descriptor: this.descriptor };\n }\n\n private async runStages(\n stages: PipelineStage[],\n image: RgbaBuffer,\n logical: { width: number; height: number },\n mode: 'truth' | 'preview',\n signal: AbortSignal | undefined,\n useCache: boolean,\n ): Promise<RgbaBuffer> {\n let current = image;\n let currentLogical = logical;\n let prefix = `${image.width}x${image.height}`;\n for (const stage of stages) {\n if (signal?.aborted) throw new SealpixelError('ABORTED', 'render aborted');\n prefix += `|${canonicalJson({ n: stage.name, p: stage.params })}`;\n const cached = useCache ? this.cache.get(prefix) : undefined;\n if (cached) {\n current = cached;\n currentLogical = this.logicalAfter(stage, currentLogical, current, image, logical);\n continue;\n }\n if (stage.kind === 'core') {\n const plan: RenderPlan = {\n version: PLAN_VERSION,\n source: currentLogical,\n bufferScale: current.width / currentLogical.width,\n stages: toCoreStages([stage]),\n };\n const planJson = JSON.stringify(plan);\n const geometry = JSON.parse(\n this.wasm.resolveGeometry(planJson, current.width, current.height),\n ) as Geometry;\n current = this.wasm.renderRgba(current, planJson);\n currentLogical = geometry.logicalOut;\n } else {\n const kctx: KernelContext = {\n logical: currentLogical,\n actual: { width: current.width, height: current.height },\n scale: current.width / currentLogical.width,\n mode,\n asset: (id) => {\n throw new SealpixelError(\n 'MISSING_ASSET',\n `asset \"${id}\" is not available to JS kernels yet`,\n { assetId: id },\n );\n },\n signal: 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 if (useCache) this.remember(prefix, current);\n }\n return current;\n }\n\n /** Recomputes the logical size after a cached stage by asking the core for its geometry. */\n private logicalAfter(\n stage: PipelineStage,\n logicalIn: { width: number; height: number },\n out: RgbaBuffer,\n _image: RgbaBuffer,\n _sourceLogical: { width: number; height: number },\n ): { width: number; height: number } {\n if (stage.kind !== 'core') {\n return {\n width: Math.round(logicalIn.width * (out.width / out.width)),\n height: logicalIn.height,\n };\n }\n // The cached buffer already has the output size; the logical size is the\n // geometry of this single stage on a buffer with the input's logical size.\n const plan: RenderPlan = {\n version: PLAN_VERSION,\n source: logicalIn,\n bufferScale: 1,\n stages: toCoreStages([stage]),\n };\n const g = JSON.parse(\n this.wasm.resolveGeometry(JSON.stringify(plan), logicalIn.width, logicalIn.height),\n ) as Geometry;\n return g.logicalOut;\n }\n\n private remember(key: string, value: RgbaBuffer): void {\n const limit = this.options.cacheEntries ?? 6;\n if (this.cache.has(key)) this.cache.delete(key);\n this.cache.set(key, value);\n while (this.cache.size > limit) {\n const oldest = this.cache.keys().next().value;\n if (oldest === undefined) break;\n this.cache.delete(oldest);\n }\n }\n\n /** For tests: number of cached stage outputs. */\n cacheSize(): number {\n return this.cache.size;\n }\n}\n"]}
|