@oim-media/player-oim 1.32.4 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +153 -343
- package/dist/oim-player.js +12 -12
- package/dist/vendor/{oim-upgrade-3f63168f9e35.js → oim-upgrade-fde035d434a6.js} +1 -1
- package/package.json +2 -2
- /package/dist/vendor/{oim-generative-3f63168f9e35.js → oim-generative-fde035d434a6.js} +0 -0
- /package/dist/vendor/{oim-patterns-3f63168f9e35.js → oim-patterns-fde035d434a6.js} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -180,160 +180,12 @@ function getDeviceProfile(nav, win) {
|
|
|
180
180
|
saveData: Boolean(n?.connection?.saveData)
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
|
-
// src/render/poster-head.ts
|
|
184
|
-
/**
|
|
185
|
-
* @license
|
|
186
|
-
* Copyright (c) 2026 Xue Studios LLC
|
|
187
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
188
|
-
*/
|
|
189
|
-
/**
|
|
190
|
-
* The start of a .oim, enough to show its poster. Since 15 Nov the backend
|
|
191
|
-
* writes the image, then a small OIM_Seal (the image hash signed on its own),
|
|
192
|
-
* then the metadata. Reading up to the seal is enough to verify and paint the
|
|
193
|
-
* poster; the metadata is fetched only if the work animates.
|
|
194
|
-
*/
|
|
195
|
-
var SEAL_KEY = "OIM_Seal";
|
|
196
|
-
var DATA_KEYS = ["OIM_Data", "OIM_JSON_DATA"];
|
|
197
|
-
var IEND = new Uint8Array([
|
|
198
|
-
0,
|
|
199
|
-
0,
|
|
200
|
-
0,
|
|
201
|
-
0,
|
|
202
|
-
73,
|
|
203
|
-
69,
|
|
204
|
-
78,
|
|
205
|
-
68,
|
|
206
|
-
174,
|
|
207
|
-
66,
|
|
208
|
-
96,
|
|
209
|
-
130
|
|
210
|
-
]);
|
|
211
|
-
function keyOf$1(data) {
|
|
212
|
-
const nul = data.indexOf(0);
|
|
213
|
-
return nul === -1 ? "" : new TextDecoder("latin1").decode(data.subarray(0, nul));
|
|
214
|
-
}
|
|
215
|
-
/** Scans complete chunks of `buf` (the file's first bytes) for the poster seal. */
|
|
216
|
-
function scanPosterHead(buf) {
|
|
217
|
-
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
218
|
-
const idat = [];
|
|
219
|
-
for (let at = 8; at + 8 <= buf.length;) {
|
|
220
|
-
const length = view.getUint32(at);
|
|
221
|
-
const end = at + 12 + length;
|
|
222
|
-
if (end > buf.length) return { done: false };
|
|
223
|
-
const type = new TextDecoder("latin1").decode(buf.subarray(at + 4, at + 8));
|
|
224
|
-
const data = buf.subarray(at + 8, at + 8 + length);
|
|
225
|
-
if (type === "IDAT") idat.push(data);
|
|
226
|
-
else if (type === "IEND") return {
|
|
227
|
-
done: true,
|
|
228
|
-
seal: null,
|
|
229
|
-
idat,
|
|
230
|
-
sealStart: at,
|
|
231
|
-
end
|
|
232
|
-
};
|
|
233
|
-
else if (type === "tEXt" || type === "zTXt" || type === "iTXt") {
|
|
234
|
-
const key = keyOf$1(data);
|
|
235
|
-
if (key === SEAL_KEY) {
|
|
236
|
-
let seal = null;
|
|
237
|
-
try {
|
|
238
|
-
seal = JSON.parse(new TextDecoder().decode(data.subarray(key.length + 1)));
|
|
239
|
-
} catch {
|
|
240
|
-
seal = null;
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
done: true,
|
|
244
|
-
seal: seal && typeof seal === "object" ? seal : null,
|
|
245
|
-
idat,
|
|
246
|
-
sealStart: at,
|
|
247
|
-
end
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
if (DATA_KEYS.includes(key)) return {
|
|
251
|
-
done: true,
|
|
252
|
-
seal: null,
|
|
253
|
-
idat,
|
|
254
|
-
sealStart: at,
|
|
255
|
-
end
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
at = end;
|
|
259
|
-
}
|
|
260
|
-
return { done: false };
|
|
261
|
-
}
|
|
262
|
-
/** The poster as a standalone PNG: everything before the seal, then IEND. */
|
|
263
|
-
function posterPng(buf, sealStart) {
|
|
264
|
-
const out = new Uint8Array(sealStart + IEND.length);
|
|
265
|
-
out.set(buf.subarray(0, sealStart), 0);
|
|
266
|
-
out.set(IEND, sealStart);
|
|
267
|
-
return out;
|
|
268
|
-
}
|
|
269
183
|
// src/render/file-cache.ts
|
|
270
184
|
/**
|
|
271
185
|
* @license
|
|
272
186
|
* Copyright (c) 2026 Xue Studios LLC
|
|
273
187
|
* SPDX-License-Identifier: Apache-2.0
|
|
274
188
|
*/
|
|
275
|
-
function joined(parts, total) {
|
|
276
|
-
const out = new Uint8Array(total);
|
|
277
|
-
let at = 0;
|
|
278
|
-
for (const p of parts) {
|
|
279
|
-
out.set(p, at);
|
|
280
|
-
at += p.length;
|
|
281
|
-
}
|
|
282
|
-
return out;
|
|
283
|
-
}
|
|
284
|
-
async function sha256Hex(parts) {
|
|
285
|
-
const all = joined(parts, parts.reduce((n, p) => n + p.length, 0));
|
|
286
|
-
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", all));
|
|
287
|
-
return Array.from(digest, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
288
|
-
}
|
|
289
|
-
/** Reads the file until its poster seal. Without one, reads it all and caches it as the blob. */
|
|
290
|
-
async function readHead(src, e) {
|
|
291
|
-
const res = await fetch(src);
|
|
292
|
-
if (!res.ok) return null;
|
|
293
|
-
if (!res.body) {
|
|
294
|
-
const blob = await res.blob();
|
|
295
|
-
e.bytes = blob.size;
|
|
296
|
-
e.blob = Promise.resolve(blob);
|
|
297
|
-
return null;
|
|
298
|
-
}
|
|
299
|
-
const reader = res.body.getReader();
|
|
300
|
-
const parts = [];
|
|
301
|
-
let total = 0;
|
|
302
|
-
for (;;) {
|
|
303
|
-
const { value, done } = await reader.read();
|
|
304
|
-
if (value) {
|
|
305
|
-
parts.push(value);
|
|
306
|
-
total += value.length;
|
|
307
|
-
}
|
|
308
|
-
const buf = joined(parts, total);
|
|
309
|
-
const head = done ? {
|
|
310
|
-
done: true,
|
|
311
|
-
seal: null
|
|
312
|
-
} : scanPosterHead(buf);
|
|
313
|
-
if (head.done && head.seal && "idat" in head) {
|
|
314
|
-
await reader.cancel().catch(() => {});
|
|
315
|
-
e.head = buf;
|
|
316
|
-
e.validator = res.headers.get("ETag") ?? res.headers.get("Last-Modified") ?? void 0;
|
|
317
|
-
return {
|
|
318
|
-
png: new Blob([posterPng(buf, head.sealStart)], { type: "image/png" }),
|
|
319
|
-
seal: head.seal,
|
|
320
|
-
imageHash: await sha256Hex(head.idat)
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
if (done || head.done) {
|
|
324
|
-
while (!done) {
|
|
325
|
-
const next = await reader.read();
|
|
326
|
-
if (next.done) break;
|
|
327
|
-
parts.push(next.value);
|
|
328
|
-
total += next.value.length;
|
|
329
|
-
}
|
|
330
|
-
const blob = new Blob([joined(parts, total)]);
|
|
331
|
-
e.bytes = blob.size;
|
|
332
|
-
e.blob = Promise.resolve(blob);
|
|
333
|
-
return null;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
189
|
var MAX_ENTRIES = 20;
|
|
338
190
|
var MAX_BYTES = 52428800;
|
|
339
191
|
var byUrl = /* @__PURE__ */ new Map();
|
|
@@ -408,19 +260,10 @@ var fileCache = {
|
|
|
408
260
|
fetches++;
|
|
409
261
|
e.pending++;
|
|
410
262
|
evict();
|
|
411
|
-
|
|
412
|
-
const validator = e.validator;
|
|
413
|
-
e.head = void 0;
|
|
414
|
-
e.validator = void 0;
|
|
415
|
-
const rangeHeaders = { Range: "bytes=" + (head?.length ?? 0) + "-" };
|
|
416
|
-
if (validator) rangeHeaders["If-Range"] = validator;
|
|
417
|
-
e.blob = (head ? fetch(src, { headers: rangeHeaders }).then(async (res) => {
|
|
418
|
-
if (!res.ok) throw new Error("HTTP " + res.status);
|
|
419
|
-
return res.status === 206 ? new Blob([head, await res.blob()]) : res.blob();
|
|
420
|
-
}) : fetch(src).then((res) => {
|
|
263
|
+
e.blob = fetch(src).then((res) => {
|
|
421
264
|
if (!res.ok) throw new Error("HTTP " + res.status);
|
|
422
265
|
return res.blob();
|
|
423
|
-
})
|
|
266
|
+
}).then((b) => {
|
|
424
267
|
e.bytes = b.size;
|
|
425
268
|
e.lastUsed = ++tick;
|
|
426
269
|
evict();
|
|
@@ -448,27 +291,9 @@ var fileCache = {
|
|
|
448
291
|
}
|
|
449
292
|
return e.verified;
|
|
450
293
|
},
|
|
451
|
-
/** The
|
|
452
|
-
readPoster(src) {
|
|
453
|
-
const e = entryFor(src);
|
|
454
|
-
if (!e.poster && e.blob) return Promise.resolve(null);
|
|
455
|
-
if (!e.poster) {
|
|
456
|
-
e.pending++;
|
|
457
|
-
e.poster = readHead(src, e).catch(() => null).finally(() => {
|
|
458
|
-
e.pending--;
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
return e.poster;
|
|
462
|
-
},
|
|
463
|
-
/** The first 16 bytes, from the partial read when there is one: never a second download. */
|
|
294
|
+
/** The first 16 bytes, from the one download. */
|
|
464
295
|
sniff(src) {
|
|
465
|
-
|
|
466
|
-
if (typeof src !== "string") return fromBlob(Promise.resolve(src)).catch(() => null);
|
|
467
|
-
return fileCache.readPoster(src).then(() => {
|
|
468
|
-
const e = entryFor(src);
|
|
469
|
-
if (e.head) return e.head.slice(0, 16);
|
|
470
|
-
return fromBlob(fileCache.getBlob(src));
|
|
471
|
-
}).catch(() => null);
|
|
296
|
+
return fileCache.getBlob(src).then((b) => b.slice(0, 16).arrayBuffer()).then((buf) => new Uint8Array(buf)).catch(() => null);
|
|
472
297
|
},
|
|
473
298
|
stats() {
|
|
474
299
|
return {
|
|
@@ -3138,6 +2963,11 @@ function upgrade$1(input) {
|
|
|
3138
2963
|
if (typeof zone === "string" && zone) zoneOf.set(layers[i], zone);
|
|
3139
2964
|
});
|
|
3140
2965
|
document.layers = convertZones(ctx, meta, buildTree(ctx, slots, layers), zoneOf);
|
|
2966
|
+
const backgroundIds = new Set(slots.filter((slot) => slot.raw.is_background_pattern === true || slot.raw.id === "background-pattern-slot").map((slot) => String(slot.raw.id)));
|
|
2967
|
+
if (backgroundIds.size) {
|
|
2968
|
+
const rank = (layer) => layer.id === "oim-base" ? 0 : backgroundIds.has(layer.id) ? 1 : 2;
|
|
2969
|
+
document.layers = [...document.layers].sort((a, b) => rank(a) - rank(b));
|
|
2970
|
+
}
|
|
3141
2971
|
const variables = convertVariables(ctx, meta, document.languages);
|
|
3142
2972
|
if (variables) document.variables = variables;
|
|
3143
2973
|
const background = canvasFills(ctx, meta);
|
|
@@ -5849,6 +5679,24 @@ function compareLangs(slot, before, after) {
|
|
|
5849
5679
|
if (a.size !== b.size || a.maxWidthValue !== b.maxWidthValue) return "style-only";
|
|
5850
5680
|
return "none";
|
|
5851
5681
|
}
|
|
5682
|
+
// ../scene/src/blocks/mask-outline-style.ts
|
|
5683
|
+
/**
|
|
5684
|
+
* @license
|
|
5685
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
5686
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5687
|
+
*/
|
|
5688
|
+
/** A 2.0 geometry as the mask outline fields the composition reads: a named shape, or `custom` with its path. */
|
|
5689
|
+
function maskOutlineStyle(geometry) {
|
|
5690
|
+
const g = geometry;
|
|
5691
|
+
return {
|
|
5692
|
+
maskShape: g?.kind === "preset" ? g.name : g?.kind === "paths" ? "custom" : {
|
|
5693
|
+
rect: "rectangle",
|
|
5694
|
+
ellipse: "circle",
|
|
5695
|
+
line: "line"
|
|
5696
|
+
}[g?.kind ?? ""],
|
|
5697
|
+
maskSvgPath: g?.kind === "paths" ? g.paths?.map((p) => p.d).join(" ") : void 0
|
|
5698
|
+
};
|
|
5699
|
+
}
|
|
5852
5700
|
// ../scene/src/legacy/shadow.ts
|
|
5853
5701
|
/**
|
|
5854
5702
|
* @license
|
|
@@ -5982,12 +5830,6 @@ function maskStyle(layer, colors) {
|
|
|
5982
5830
|
const mask = layer.mask ?? {};
|
|
5983
5831
|
const paint = layer.fills?.[0];
|
|
5984
5832
|
const gradient = paint && "gradient" in paint && paint.gradient ? gradientCss(paint.gradient, colors) : void 0;
|
|
5985
|
-
const geometry = layer.geometry;
|
|
5986
|
-
const shape = geometry?.kind === "preset" ? geometry.name : geometry?.kind === "paths" ? "custom" : {
|
|
5987
|
-
rect: "rectangle",
|
|
5988
|
-
ellipse: "circle",
|
|
5989
|
-
line: "line"
|
|
5990
|
-
}[geometry?.kind ?? ""];
|
|
5991
5833
|
const color = (value) => typeof value === "string" ? {
|
|
5992
5834
|
role: void 0,
|
|
5993
5835
|
literal: value
|
|
@@ -6006,8 +5848,7 @@ function maskStyle(layer, colors) {
|
|
|
6006
5848
|
maskMode: mask.mode === "cutout" ? "cutout" : "window",
|
|
6007
5849
|
maskFeather: mask.feather,
|
|
6008
5850
|
maskCoverage: mask.scope === "group" ? "container" : "canvas",
|
|
6009
|
-
|
|
6010
|
-
maskSvgPath: geometry?.kind === "paths" ? geometry.paths?.map((p) => p.d).join(" ") : void 0,
|
|
5851
|
+
...maskOutlineStyle(layer.geometry),
|
|
6011
5852
|
geoShape: void 0,
|
|
6012
5853
|
svgPath: void 0,
|
|
6013
5854
|
maskBgColor: bg.literal,
|
|
@@ -6162,7 +6003,7 @@ function legacyView(document) {
|
|
|
6162
6003
|
languages: document.languages,
|
|
6163
6004
|
slots
|
|
6164
6005
|
};
|
|
6165
|
-
if (document.canvas.fills?.length) view.canvasFills = document.canvas.fills;
|
|
6006
|
+
if (document.canvas.fills?.length && !hasBaseLayer(document)) view.canvasFills = document.canvas.fills;
|
|
6166
6007
|
if (document.fonts) view.fonts = document.fonts;
|
|
6167
6008
|
const palettes = palettesOf(document.variables);
|
|
6168
6009
|
if (palettes) view.palettes = palettes;
|
|
@@ -7203,47 +7044,6 @@ function validateOimMetadata(json) {
|
|
|
7203
7044
|
return errors;
|
|
7204
7045
|
}
|
|
7205
7046
|
/**
|
|
7206
|
-
* The poster seal (OIM_Seal, spec 15 Nov): the image hash signed on its own,
|
|
7207
|
-
* read before the metadata so the poster can be verified from a partial read.
|
|
7208
|
-
* Same rules as a full file: an altered image is refused, an expired key says so.
|
|
7209
|
-
*/
|
|
7210
|
-
async function verifyPosterSeal(seal, imageHash) {
|
|
7211
|
-
if (!seal || seal.v !== 1 || seal.alg !== "sha256-idat") return "invalid";
|
|
7212
|
-
if (typeof seal.image_hash !== "string" || typeof seal.signature !== "string" || typeof seal.key_version !== "string") return "invalid";
|
|
7213
|
-
if (!imageHash || seal.image_hash.toLowerCase() !== imageHash.toLowerCase()) return "invalid";
|
|
7214
|
-
const bytes = new TextEncoder().encode(JSON.stringify({
|
|
7215
|
-
alg: seal.alg,
|
|
7216
|
-
image_hash: seal.image_hash,
|
|
7217
|
-
key_version: seal.key_version,
|
|
7218
|
-
v: seal.v
|
|
7219
|
-
}));
|
|
7220
|
-
try {
|
|
7221
|
-
const raw = atob(seal.signature);
|
|
7222
|
-
const sig = new Uint8Array(raw.length);
|
|
7223
|
-
for (let i = 0; i < raw.length; i++) sig[i] = raw.charCodeAt(i);
|
|
7224
|
-
const check = async (jwk) => {
|
|
7225
|
-
const key = await crypto.subtle.importKey("jwk", jwk, {
|
|
7226
|
-
name: "ECDSA",
|
|
7227
|
-
namedCurve: "P-256"
|
|
7228
|
-
}, false, ["verify"]);
|
|
7229
|
-
return crypto.subtle.verify({
|
|
7230
|
-
name: "ECDSA",
|
|
7231
|
-
hash: { name: "SHA-256" }
|
|
7232
|
-
}, key, sig, bytes);
|
|
7233
|
-
};
|
|
7234
|
-
const jwk = await getPublicKey(seal.key_version);
|
|
7235
|
-
let valid = !!jwk && await check(jwk);
|
|
7236
|
-
if (!valid) {
|
|
7237
|
-
const serverJwk = await getServerPublicKey(seal.key_version).catch(() => null);
|
|
7238
|
-
if (serverJwk && (!jwk || serverJwk.x !== jwk.x || serverJwk.y !== jwk.y)) valid = await check(serverJwk);
|
|
7239
|
-
}
|
|
7240
|
-
if (!valid) return "invalid";
|
|
7241
|
-
} catch {
|
|
7242
|
-
return "invalid";
|
|
7243
|
-
}
|
|
7244
|
-
return await keyExpiredForFile({ key_version: seal.key_version }) ? "expired_key" : "ok";
|
|
7245
|
-
}
|
|
7246
|
-
/**
|
|
7247
7047
|
* @license
|
|
7248
7048
|
* Copyright (c) 2026 Xue Studios LLC
|
|
7249
7049
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -7306,7 +7106,7 @@ function nextWheelZoom(zoom, deltaY, deltaMode, pinch) {
|
|
|
7306
7106
|
* the format can change without the player being touched. Tying both numbers
|
|
7307
7107
|
* together would make an internal fix look like a format break.
|
|
7308
7108
|
*/
|
|
7309
|
-
var CONTRACT_VERSION = "1.
|
|
7109
|
+
var CONTRACT_VERSION = "1.33.0";
|
|
7310
7110
|
/**
|
|
7311
7111
|
* What the player implements TODAY, measured and not assumed.
|
|
7312
7112
|
*
|
|
@@ -7401,7 +7201,7 @@ function describeMissing(missing) {
|
|
|
7401
7201
|
*/
|
|
7402
7202
|
/** `oim-` + 8 hex of the SHA-256 of the family's variants + `-` + family. */
|
|
7403
7203
|
var EMBEDDED_FONT_NAME = /^oim-[0-9a-f]{8}-[A-Za-z0-9 ]{1,64}$/;
|
|
7404
|
-
// ../scene/src/
|
|
7204
|
+
// ../scene/src/blocks/fonts.ts
|
|
7405
7205
|
/**
|
|
7406
7206
|
* @license
|
|
7407
7207
|
* Copyright (c) 2026 Xue Studios LLC
|
|
@@ -9234,7 +9034,7 @@ function flipScale(flipX, flipY) {
|
|
|
9234
9034
|
if (!flipX && !flipY) return null;
|
|
9235
9035
|
return [flipX ? -1 : 1, flipY ? -1 : 1];
|
|
9236
9036
|
}
|
|
9237
|
-
// ../scene/src/
|
|
9037
|
+
// ../scene/src/blocks/silhouette-clip.ts
|
|
9238
9038
|
/**
|
|
9239
9039
|
* @license
|
|
9240
9040
|
* Copyright (c) 2026 Xue Studios LLC
|
|
@@ -9242,48 +9042,70 @@ function flipScale(flipX, flipY) {
|
|
|
9242
9042
|
*/
|
|
9243
9043
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
9244
9044
|
var sequence = 0;
|
|
9045
|
+
/** Path data for a silhouette given as polygon points or as a path. */
|
|
9046
|
+
var silhouettePath = (figure) => figure.d ?? "M " + figure.points.split(" ").join(" L ") + " Z";
|
|
9245
9047
|
/**
|
|
9246
|
-
*
|
|
9247
|
-
*
|
|
9248
|
-
*
|
|
9249
|
-
* Built once when the slot is built: no per-frame work.
|
|
9048
|
+
* A zero-size <svg> holding a clipPath in objectBoundingBox units, so the silhouette
|
|
9049
|
+
* maps onto whatever box references it, at any size. Returns the svg and the
|
|
9050
|
+
* `clip-path` value that references it.
|
|
9250
9051
|
*/
|
|
9251
|
-
function
|
|
9052
|
+
function silhouetteClip(doc, silhouette) {
|
|
9252
9053
|
const id = `oim-image-fill-${++sequence}`;
|
|
9253
9054
|
const [x0, y0, width, height] = silhouette.viewBox.trim().split(/\s+/).map(Number);
|
|
9254
9055
|
const scale = width === height ? `scale(${1 / width})` : `scale(${1 / width} ${1 / height})`;
|
|
9255
9056
|
const transform = x0 || y0 ? `${scale} translate(${-x0} ${-y0})` : scale;
|
|
9256
|
-
const
|
|
9257
|
-
box.className = "oim-image-fill";
|
|
9258
|
-
box.style.position = "absolute";
|
|
9259
|
-
box.style.left = "0";
|
|
9260
|
-
box.style.top = "0";
|
|
9261
|
-
box.style.width = "100%";
|
|
9262
|
-
box.style.height = "100%";
|
|
9263
|
-
box.style.overflow = "hidden";
|
|
9264
|
-
box.style.pointerEvents = "none";
|
|
9265
|
-
box.style.clipPath = `url(#${id})`;
|
|
9266
|
-
const svg = document.createElementNS(SVG_NS, "svg");
|
|
9057
|
+
const svg = doc.createElementNS(SVG_NS, "svg");
|
|
9267
9058
|
svg.setAttribute("width", "0");
|
|
9268
9059
|
svg.setAttribute("height", "0");
|
|
9269
9060
|
svg.style.position = "absolute";
|
|
9270
|
-
const clip =
|
|
9061
|
+
const clip = doc.createElementNS(SVG_NS, "clipPath");
|
|
9271
9062
|
clip.setAttribute("id", id);
|
|
9272
9063
|
clip.setAttribute("clipPathUnits", "objectBoundingBox");
|
|
9273
|
-
const shape =
|
|
9274
|
-
if (silhouette.rect)
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
9064
|
+
const shape = doc.createElementNS(SVG_NS, silhouette.rect ? "rect" : "path");
|
|
9065
|
+
if (silhouette.rect) for (const [k, v] of [
|
|
9066
|
+
["x", "0"],
|
|
9067
|
+
["y", "0"],
|
|
9068
|
+
["width", "1"],
|
|
9069
|
+
["height", "1"],
|
|
9070
|
+
["rx", String(silhouette.rect.rx)],
|
|
9071
|
+
["ry", String(silhouette.rect.ry)]
|
|
9072
|
+
]) shape.setAttribute(k, v);
|
|
9073
|
+
else {
|
|
9282
9074
|
shape.setAttribute("d", silhouette.d);
|
|
9283
9075
|
shape.setAttribute("transform", transform);
|
|
9076
|
+
if (silhouette.evenodd) shape.setAttribute("clip-rule", "evenodd");
|
|
9284
9077
|
}
|
|
9285
9078
|
clip.appendChild(shape);
|
|
9286
9079
|
svg.appendChild(clip);
|
|
9080
|
+
return {
|
|
9081
|
+
svg,
|
|
9082
|
+
clipPath: `url(#${id})`
|
|
9083
|
+
};
|
|
9084
|
+
}
|
|
9085
|
+
// ../scene/src/legacy/image-fill.ts
|
|
9086
|
+
/**
|
|
9087
|
+
* @license
|
|
9088
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
9089
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9090
|
+
*/
|
|
9091
|
+
/**
|
|
9092
|
+
* Image fill of a shape (contract 1.17.0). The photo sits in a box clipped by
|
|
9093
|
+
* the silhouette, under the stroke drawing. The URL goes into the `src`
|
|
9094
|
+
* property of an <img>, never into a CSS url(), so it cannot inject CSS.
|
|
9095
|
+
* Built once when the slot is built: no per-frame work.
|
|
9096
|
+
*/
|
|
9097
|
+
function mountImageFill(slotEl, paint, silhouette, resolvedUrl, fallbackColor) {
|
|
9098
|
+
const { svg, clipPath } = silhouetteClip(document, silhouette);
|
|
9099
|
+
const box = document.createElement("div");
|
|
9100
|
+
box.className = "oim-image-fill";
|
|
9101
|
+
box.style.position = "absolute";
|
|
9102
|
+
box.style.left = "0";
|
|
9103
|
+
box.style.top = "0";
|
|
9104
|
+
box.style.width = "100%";
|
|
9105
|
+
box.style.height = "100%";
|
|
9106
|
+
box.style.overflow = "hidden";
|
|
9107
|
+
box.style.pointerEvents = "none";
|
|
9108
|
+
box.style.clipPath = clipPath;
|
|
9287
9109
|
box.appendChild(svg);
|
|
9288
9110
|
const crop = cropCss(paint.crop ?? {
|
|
9289
9111
|
x: 50,
|
|
@@ -9318,6 +9140,42 @@ function mountImageFill(slotEl, paint, silhouette, resolvedUrl, fallbackColor) {
|
|
|
9318
9140
|
box.appendChild(img);
|
|
9319
9141
|
slotEl.insertBefore(box, slotEl.firstChild);
|
|
9320
9142
|
}
|
|
9143
|
+
// ../scene/src/blocks/grain.ts
|
|
9144
|
+
/**
|
|
9145
|
+
* @license
|
|
9146
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
9147
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9148
|
+
*/
|
|
9149
|
+
var SVG = "http://www.w3.org/2000/svg";
|
|
9150
|
+
/**
|
|
9151
|
+
* Puts the core's grain filter for one layer into `host`'s own defs, replacing an
|
|
9152
|
+
* earlier one with the same id. Parsed as SVG, never assigned as HTML: the markup
|
|
9153
|
+
* is built from a sanitised id, clamped numbers and a fixed list of blend modes.
|
|
9154
|
+
*/
|
|
9155
|
+
function defineGrain(host, id, fx) {
|
|
9156
|
+
if (typeof DOMParser === "undefined") return;
|
|
9157
|
+
const doc = host.ownerDocument;
|
|
9158
|
+
let defs = host.querySelector(":scope > svg.oim-grain-defs > defs");
|
|
9159
|
+
if (!defs) {
|
|
9160
|
+
const svg = doc.createElementNS(SVG, "svg");
|
|
9161
|
+
svg.setAttribute("class", "oim-grain-defs");
|
|
9162
|
+
svg.setAttribute("width", "0");
|
|
9163
|
+
svg.setAttribute("height", "0");
|
|
9164
|
+
svg.setAttribute("aria-hidden", "true");
|
|
9165
|
+
svg.setAttribute("style", "position:absolute;pointer-events:none");
|
|
9166
|
+
defs = doc.createElementNS(SVG, "defs");
|
|
9167
|
+
svg.appendChild(defs);
|
|
9168
|
+
host.appendChild(svg);
|
|
9169
|
+
}
|
|
9170
|
+
defs.querySelector("#" + id)?.remove();
|
|
9171
|
+
const markup = buildLayerGrainFilter(id, {
|
|
9172
|
+
intensity: fx.intensity,
|
|
9173
|
+
size: fx.size,
|
|
9174
|
+
blend: fx.blend
|
|
9175
|
+
});
|
|
9176
|
+
const filter = new DOMParser().parseFromString(`<svg xmlns="${SVG}"><defs>${markup}</defs></svg>`, "image/svg+xml").querySelector("filter");
|
|
9177
|
+
if (filter) defs.appendChild(doc.importNode(filter, true));
|
|
9178
|
+
}
|
|
9321
9179
|
// ../scene/src/legacy/groups.ts
|
|
9322
9180
|
/**
|
|
9323
9181
|
* @license
|
|
@@ -9489,6 +9347,37 @@ function applyMinHitArea(el) {
|
|
|
9489
9347
|
el.style.minHeight = `24px`;
|
|
9490
9348
|
}
|
|
9491
9349
|
/**
|
|
9350
|
+
* Resolves a list of actions against the current visibility of the slots.
|
|
9351
|
+
* Pure function: it does not touch the DOM. Same semantics as the editor's visibility resolver.
|
|
9352
|
+
*/
|
|
9353
|
+
function resolveActions(actions, currentVisibility) {
|
|
9354
|
+
const visibility = {};
|
|
9355
|
+
const texts = {};
|
|
9356
|
+
if (!actions || actions.length === 0) return {
|
|
9357
|
+
visibility,
|
|
9358
|
+
texts
|
|
9359
|
+
};
|
|
9360
|
+
for (const act of actions) {
|
|
9361
|
+
const targetId = act.target;
|
|
9362
|
+
if (!targetId) continue;
|
|
9363
|
+
const currentVis = currentVisibility[targetId] !== void 0 ? currentVisibility[targetId] : true;
|
|
9364
|
+
if (act.type === "show") visibility[targetId] = true;
|
|
9365
|
+
else if (act.type === "hide") visibility[targetId] = false;
|
|
9366
|
+
else if (act.type === "toggle") visibility[targetId] = !currentVis;
|
|
9367
|
+
else if (act.type === "setText") texts[targetId] = act.value !== void 0 && act.value !== null ? String(act.value) : "";
|
|
9368
|
+
}
|
|
9369
|
+
return {
|
|
9370
|
+
visibility,
|
|
9371
|
+
texts
|
|
9372
|
+
};
|
|
9373
|
+
}
|
|
9374
|
+
// ../scene/src/legacy/states.ts
|
|
9375
|
+
/**
|
|
9376
|
+
* @license
|
|
9377
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
9378
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9379
|
+
*/
|
|
9380
|
+
/**
|
|
9492
9381
|
* Hooks a slot's states up to its pointer events.
|
|
9493
9382
|
*
|
|
9494
9383
|
* It lives here and not inside `renderSlots` so that it can be tested: the hook-up
|
|
@@ -9565,31 +9454,6 @@ function stateStyles(e) {
|
|
|
9565
9454
|
if (e.transitionDuration !== void 0) s["--oim-transition-duration"] = `${e.transitionDuration}s`;
|
|
9566
9455
|
return s;
|
|
9567
9456
|
}
|
|
9568
|
-
/**
|
|
9569
|
-
* Resolves a list of actions against the current visibility of the slots.
|
|
9570
|
-
* Pure function: it does not touch the DOM. Same semantics as the editor's visibility resolver.
|
|
9571
|
-
*/
|
|
9572
|
-
function resolveActions(actions, currentVisibility) {
|
|
9573
|
-
const visibility = {};
|
|
9574
|
-
const texts = {};
|
|
9575
|
-
if (!actions || actions.length === 0) return {
|
|
9576
|
-
visibility,
|
|
9577
|
-
texts
|
|
9578
|
-
};
|
|
9579
|
-
for (const act of actions) {
|
|
9580
|
-
const targetId = act.target;
|
|
9581
|
-
if (!targetId) continue;
|
|
9582
|
-
const currentVis = currentVisibility[targetId] !== void 0 ? currentVisibility[targetId] : true;
|
|
9583
|
-
if (act.type === "show") visibility[targetId] = true;
|
|
9584
|
-
else if (act.type === "hide") visibility[targetId] = false;
|
|
9585
|
-
else if (act.type === "toggle") visibility[targetId] = !currentVis;
|
|
9586
|
-
else if (act.type === "setText") texts[targetId] = act.value !== void 0 && act.value !== null ? String(act.value) : "";
|
|
9587
|
-
}
|
|
9588
|
-
return {
|
|
9589
|
-
visibility,
|
|
9590
|
-
texts
|
|
9591
|
-
};
|
|
9592
|
-
}
|
|
9593
9457
|
// ../core/src/artisticTextCurve.ts
|
|
9594
9458
|
/**
|
|
9595
9459
|
* @license
|
|
@@ -9686,7 +9550,7 @@ function calculate3DExtrusionLayers(depth, angleDegrees, baseColor = "#111827",
|
|
|
9686
9550
|
}
|
|
9687
9551
|
return layers;
|
|
9688
9552
|
}
|
|
9689
|
-
// ../scene/src/
|
|
9553
|
+
// ../scene/src/blocks/artisticText.ts
|
|
9690
9554
|
/**
|
|
9691
9555
|
* @license
|
|
9692
9556
|
* Copyright (c) 2026 Xue Studios LLC
|
|
@@ -10901,7 +10765,7 @@ var LegacyRenderer = class {
|
|
|
10901
10765
|
}
|
|
10902
10766
|
} else slotEl.append(svg);
|
|
10903
10767
|
if (imageFill) mountImageFill(slotEl, v2Fill, {
|
|
10904
|
-
d: silhouette
|
|
10768
|
+
d: silhouettePath(silhouette),
|
|
10905
10769
|
viewBox: silhouette.viewBox
|
|
10906
10770
|
}, fillImageSrc, underColor);
|
|
10907
10771
|
slotEl.style.backgroundColor = "transparent";
|
|
@@ -11451,36 +11315,10 @@ var LegacyRenderer = class {
|
|
|
11451
11315
|
self.sceneReady();
|
|
11452
11316
|
}
|
|
11453
11317
|
}
|
|
11454
|
-
/**
|
|
11455
|
-
* Puts the core's grain filter for one layer into this player's own defs.
|
|
11456
|
-
* Parsed as SVG, never assigned as HTML: the markup is built from a
|
|
11457
|
-
* sanitised id, clamped numbers and a fixed list of blend modes.
|
|
11458
|
-
*/
|
|
11318
|
+
/** The grain filter of one layer, in the viewport (not the overlay: a full render empties the overlay and took the defs with it). */
|
|
11459
11319
|
_defineLayerGrain(id, fx) {
|
|
11460
11320
|
const layer = this._viewport || this._overlay;
|
|
11461
|
-
if (
|
|
11462
|
-
let defs = layer.querySelector(":scope > svg.oim-grain-defs > defs");
|
|
11463
|
-
if (!defs) {
|
|
11464
|
-
const svgNs = "http://www.w3.org/2000/svg";
|
|
11465
|
-
const svg = document.createElementNS(svgNs, "svg");
|
|
11466
|
-
svg.setAttribute("class", "oim-grain-defs");
|
|
11467
|
-
svg.setAttribute("width", "0");
|
|
11468
|
-
svg.setAttribute("height", "0");
|
|
11469
|
-
svg.setAttribute("aria-hidden", "true");
|
|
11470
|
-
svg.setAttribute("style", "position:absolute;pointer-events:none");
|
|
11471
|
-
defs = document.createElementNS(svgNs, "defs");
|
|
11472
|
-
svg.appendChild(defs);
|
|
11473
|
-
layer.appendChild(svg);
|
|
11474
|
-
}
|
|
11475
|
-
const existing = defs.querySelector("#" + id);
|
|
11476
|
-
if (existing) existing.remove();
|
|
11477
|
-
const markup = buildLayerGrainFilter(id, {
|
|
11478
|
-
intensity: fx.intensity,
|
|
11479
|
-
size: fx.size,
|
|
11480
|
-
blend: fx.blend
|
|
11481
|
-
});
|
|
11482
|
-
const filter = new DOMParser().parseFromString("<svg xmlns=\"http://www.w3.org/2000/svg\"><defs>" + markup + "</defs></svg>", "image/svg+xml").querySelector("filter");
|
|
11483
|
-
if (filter) defs.appendChild(document.importNode(filter, true));
|
|
11321
|
+
if (layer) defineGrain(layer, id, fx);
|
|
11484
11322
|
}
|
|
11485
11323
|
/** True once the veil has lifted for the first time. */
|
|
11486
11324
|
_revealed = false;
|
|
@@ -12097,7 +11935,7 @@ var ImageEngine = class extends LegacyRenderer {
|
|
|
12097
11935
|
host.classList.add("oim-align-" + this.align);
|
|
12098
11936
|
host.classList.add("oim-tier-" + this._deviceProfile.tier);
|
|
12099
11937
|
if (this._deviceProfile.isMobile) host.classList.add("oim-mobile");
|
|
12100
|
-
shadow.innerHTML = "<div class=\"oim-player-viewport oim-fit-" + this.fit + "\" part=\"viewport\"><img class=\"oim-player-base\" crossorigin=\"anonymous\"
|
|
11938
|
+
shadow.innerHTML = "<div class=\"oim-player-viewport oim-fit-" + this.fit + "\" part=\"viewport\"><img class=\"oim-player-base\" crossorigin=\"anonymous\" alt=\"\" aria-hidden=\"true\" part=\"base\" /><div class=\"oim-layer-overlay\" aria-hidden=\"true\" part=\"overlay\"></div></div>";
|
|
12101
11939
|
injectStyles(shadow);
|
|
12102
11940
|
this._viewport = shadow.querySelector(".oim-player-viewport");
|
|
12103
11941
|
this._baseImg = shadow.querySelector(".oim-player-base");
|
|
@@ -12142,35 +11980,7 @@ var ImageEngine = class extends LegacyRenderer {
|
|
|
12142
11980
|
this.updateViewportSize();
|
|
12143
11981
|
this.updateScale();
|
|
12144
11982
|
this._bindViewportEvents();
|
|
12145
|
-
if (
|
|
12146
|
-
const poster = await fileCache.readPoster(src);
|
|
12147
|
-
if (poster) {
|
|
12148
|
-
const verdict = await verifyPosterSeal(poster.seal, poster.imageHash);
|
|
12149
|
-
if (verdict === "invalid") {
|
|
12150
|
-
shadow.innerHTML = "<div class=\"oim-player-error oim-player-refused\" part=\"error\"></div>";
|
|
12151
|
-
injectStyles(shadow);
|
|
12152
|
-
const box = shadow.querySelector(".oim-player-error");
|
|
12153
|
-
if (box) box.textContent = playerString("tampered", self.lang);
|
|
12154
|
-
host.dispatchEvent(new CustomEvent("error", { detail: new Error(ALTERED_FILE_ERROR) }));
|
|
12155
|
-
return false;
|
|
12156
|
-
}
|
|
12157
|
-
if (verdict === "expired_key") try {
|
|
12158
|
-
setFlag(host, "data-oim-key-retired", "data-oim-clave-retirada");
|
|
12159
|
-
} catch (e) {}
|
|
12160
|
-
this.imageUrl = URL.createObjectURL(poster.png);
|
|
12161
|
-
imgNode.src = this.imageUrl;
|
|
12162
|
-
if (this.poster === "only") {
|
|
12163
|
-
this.securityStatus = verdict === "ok" ? "verified" : "expired_key";
|
|
12164
|
-
viewportNode?.classList.add("oim-viewport--poster", "oim-viewport--ready");
|
|
12165
|
-
host.dispatchEvent(new CustomEvent("oim:loaded", { detail: {
|
|
12166
|
-
type: "image",
|
|
12167
|
-
metadata: null,
|
|
12168
|
-
security: this.securityStatus
|
|
12169
|
-
} }));
|
|
12170
|
-
return true;
|
|
12171
|
-
}
|
|
12172
|
-
} else imgNode.src = src;
|
|
12173
|
-
}
|
|
11983
|
+
if (imgNode) imgNode.src = this.imageUrl ?? "";
|
|
12174
11984
|
return fileCache.getBlob(src).then((blob) => {
|
|
12175
11985
|
return new Promise((resolve2, reject2) => {
|
|
12176
11986
|
OIMRegistry.requestRender(self, blob, src, resolve2, reject2);
|