@oim-media/player-oim 1.29.0 → 1.30.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
CHANGED
|
@@ -179,12 +179,159 @@ function getDeviceProfile(nav, win) {
|
|
|
179
179
|
saveData: Boolean(n?.connection?.saveData)
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
+
// src/render/poster-head.ts
|
|
183
|
+
/**
|
|
184
|
+
* @license
|
|
185
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
186
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
187
|
+
*/
|
|
188
|
+
/**
|
|
189
|
+
* The start of a .oim, enough to show its poster. Since 15 Nov the backend
|
|
190
|
+
* writes the image, then a small OIM_Seal (the image hash signed on its own),
|
|
191
|
+
* then the metadata. Reading up to the seal is enough to verify and paint the
|
|
192
|
+
* poster; the metadata is fetched only if the work animates.
|
|
193
|
+
*/
|
|
194
|
+
var SEAL_KEY = "OIM_Seal";
|
|
195
|
+
var DATA_KEYS = ["OIM_Data", "OIM_JSON_DATA"];
|
|
196
|
+
var IEND = new Uint8Array([
|
|
197
|
+
0,
|
|
198
|
+
0,
|
|
199
|
+
0,
|
|
200
|
+
0,
|
|
201
|
+
73,
|
|
202
|
+
69,
|
|
203
|
+
78,
|
|
204
|
+
68,
|
|
205
|
+
174,
|
|
206
|
+
66,
|
|
207
|
+
96,
|
|
208
|
+
130
|
|
209
|
+
]);
|
|
210
|
+
function keyOf$1(data) {
|
|
211
|
+
const nul = data.indexOf(0);
|
|
212
|
+
return nul === -1 ? "" : new TextDecoder("latin1").decode(data.subarray(0, nul));
|
|
213
|
+
}
|
|
214
|
+
/** Scans complete chunks of `buf` (the file's first bytes) for the poster seal. */
|
|
215
|
+
function scanPosterHead(buf) {
|
|
216
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
217
|
+
const idat = [];
|
|
218
|
+
for (let at = 8; at + 8 <= buf.length;) {
|
|
219
|
+
const length = view.getUint32(at);
|
|
220
|
+
const end = at + 12 + length;
|
|
221
|
+
if (end > buf.length) return { done: false };
|
|
222
|
+
const type = new TextDecoder("latin1").decode(buf.subarray(at + 4, at + 8));
|
|
223
|
+
const data = buf.subarray(at + 8, at + 8 + length);
|
|
224
|
+
if (type === "IDAT") idat.push(data);
|
|
225
|
+
else if (type === "IEND") return {
|
|
226
|
+
done: true,
|
|
227
|
+
seal: null,
|
|
228
|
+
idat,
|
|
229
|
+
sealStart: at,
|
|
230
|
+
end
|
|
231
|
+
};
|
|
232
|
+
else if (type === "tEXt" || type === "zTXt" || type === "iTXt") {
|
|
233
|
+
const key = keyOf$1(data);
|
|
234
|
+
if (key === SEAL_KEY) {
|
|
235
|
+
let seal = null;
|
|
236
|
+
try {
|
|
237
|
+
seal = JSON.parse(new TextDecoder().decode(data.subarray(key.length + 1)));
|
|
238
|
+
} catch {
|
|
239
|
+
seal = null;
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
done: true,
|
|
243
|
+
seal: seal && typeof seal === "object" ? seal : null,
|
|
244
|
+
idat,
|
|
245
|
+
sealStart: at,
|
|
246
|
+
end
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (DATA_KEYS.includes(key)) return {
|
|
250
|
+
done: true,
|
|
251
|
+
seal: null,
|
|
252
|
+
idat,
|
|
253
|
+
sealStart: at,
|
|
254
|
+
end
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
at = end;
|
|
258
|
+
}
|
|
259
|
+
return { done: false };
|
|
260
|
+
}
|
|
261
|
+
/** The poster as a standalone PNG: everything before the seal, then IEND. */
|
|
262
|
+
function posterPng(buf, sealStart) {
|
|
263
|
+
const out = new Uint8Array(sealStart + IEND.length);
|
|
264
|
+
out.set(buf.subarray(0, sealStart), 0);
|
|
265
|
+
out.set(IEND, sealStart);
|
|
266
|
+
return out;
|
|
267
|
+
}
|
|
182
268
|
// src/render/file-cache.ts
|
|
183
269
|
/**
|
|
184
270
|
* @license
|
|
185
271
|
* Copyright (c) 2026 Xue Studios LLC
|
|
186
272
|
* SPDX-License-Identifier: Apache-2.0
|
|
187
273
|
*/
|
|
274
|
+
function joined(parts, total) {
|
|
275
|
+
const out = new Uint8Array(total);
|
|
276
|
+
let at = 0;
|
|
277
|
+
for (const p of parts) {
|
|
278
|
+
out.set(p, at);
|
|
279
|
+
at += p.length;
|
|
280
|
+
}
|
|
281
|
+
return out;
|
|
282
|
+
}
|
|
283
|
+
async function sha256Hex(parts) {
|
|
284
|
+
const all = joined(parts, parts.reduce((n, p) => n + p.length, 0));
|
|
285
|
+
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", all));
|
|
286
|
+
return Array.from(digest, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
287
|
+
}
|
|
288
|
+
/** Reads the file until its poster seal. Without one, reads it all and caches it as the blob. */
|
|
289
|
+
async function readHead(src, e) {
|
|
290
|
+
const res = await fetch(src);
|
|
291
|
+
if (!res.ok) return null;
|
|
292
|
+
if (!res.body) {
|
|
293
|
+
const blob = await res.blob();
|
|
294
|
+
e.bytes = blob.size;
|
|
295
|
+
e.blob = Promise.resolve(blob);
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
const reader = res.body.getReader();
|
|
299
|
+
const parts = [];
|
|
300
|
+
let total = 0;
|
|
301
|
+
for (;;) {
|
|
302
|
+
const { value, done } = await reader.read();
|
|
303
|
+
if (value) {
|
|
304
|
+
parts.push(value);
|
|
305
|
+
total += value.length;
|
|
306
|
+
}
|
|
307
|
+
const buf = joined(parts, total);
|
|
308
|
+
const head = done ? {
|
|
309
|
+
done: true,
|
|
310
|
+
seal: null
|
|
311
|
+
} : scanPosterHead(buf);
|
|
312
|
+
if (head.done && head.seal && "idat" in head) {
|
|
313
|
+
await reader.cancel().catch(() => {});
|
|
314
|
+
e.head = buf;
|
|
315
|
+
return {
|
|
316
|
+
png: new Blob([posterPng(buf, head.sealStart)], { type: "image/png" }),
|
|
317
|
+
seal: head.seal,
|
|
318
|
+
imageHash: await sha256Hex(head.idat)
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
if (done || head.done) {
|
|
322
|
+
while (!done) {
|
|
323
|
+
const next = await reader.read();
|
|
324
|
+
if (next.done) break;
|
|
325
|
+
parts.push(next.value);
|
|
326
|
+
total += next.value.length;
|
|
327
|
+
}
|
|
328
|
+
const blob = new Blob([joined(parts, total)]);
|
|
329
|
+
e.bytes = blob.size;
|
|
330
|
+
e.blob = Promise.resolve(blob);
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
188
335
|
var MAX_ENTRIES = 20;
|
|
189
336
|
var MAX_BYTES = 52428800;
|
|
190
337
|
var byUrl = /* @__PURE__ */ new Map();
|
|
@@ -259,10 +406,15 @@ var fileCache = {
|
|
|
259
406
|
fetches++;
|
|
260
407
|
e.pending++;
|
|
261
408
|
evict();
|
|
262
|
-
|
|
409
|
+
const head = e.head;
|
|
410
|
+
e.head = void 0;
|
|
411
|
+
e.blob = (head ? fetch(src, { headers: { Range: "bytes=" + head.length + "-" } }).then(async (res) => {
|
|
412
|
+
if (!res.ok) throw new Error("HTTP " + res.status);
|
|
413
|
+
return res.status === 206 ? new Blob([head, await res.blob()]) : res.blob();
|
|
414
|
+
}) : fetch(src).then((res) => {
|
|
263
415
|
if (!res.ok) throw new Error("HTTP " + res.status);
|
|
264
416
|
return res.blob();
|
|
265
|
-
}).then((b) => {
|
|
417
|
+
})).then((b) => {
|
|
266
418
|
e.bytes = b.size;
|
|
267
419
|
e.lastUsed = ++tick;
|
|
268
420
|
evict();
|
|
@@ -290,8 +442,27 @@ var fileCache = {
|
|
|
290
442
|
}
|
|
291
443
|
return e.verified;
|
|
292
444
|
},
|
|
445
|
+
/** The verified-later poster from a partial read; null when the file has no seal or the read fails. */
|
|
446
|
+
readPoster(src) {
|
|
447
|
+
const e = entryFor(src);
|
|
448
|
+
if (!e.poster && e.blob) return Promise.resolve(null);
|
|
449
|
+
if (!e.poster) {
|
|
450
|
+
e.pending++;
|
|
451
|
+
e.poster = readHead(src, e).catch(() => null).finally(() => {
|
|
452
|
+
e.pending--;
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
return e.poster;
|
|
456
|
+
},
|
|
457
|
+
/** The first 16 bytes, from the partial read when there is one: never a second download. */
|
|
293
458
|
sniff(src) {
|
|
294
|
-
|
|
459
|
+
const fromBlob = (b) => b.then((x) => x.slice(0, 16).arrayBuffer()).then((buf) => new Uint8Array(buf));
|
|
460
|
+
if (typeof src !== "string") return fromBlob(Promise.resolve(src)).catch(() => null);
|
|
461
|
+
return fileCache.readPoster(src).then(() => {
|
|
462
|
+
const e = entryFor(src);
|
|
463
|
+
if (e.head) return e.head.slice(0, 16);
|
|
464
|
+
return fromBlob(fileCache.getBlob(src));
|
|
465
|
+
}).catch(() => null);
|
|
295
466
|
},
|
|
296
467
|
stats() {
|
|
297
468
|
return {
|
|
@@ -2532,6 +2703,7 @@ var TYPOGRAPHY_KEYS = [
|
|
|
2532
2703
|
];
|
|
2533
2704
|
function convertText(ctx, slot, layer) {
|
|
2534
2705
|
const { raw, style } = slot;
|
|
2706
|
+
ctx.retire(style, "textRole");
|
|
2535
2707
|
const align = ctx.take(style, "textAlign") ?? ctx.take(raw, "align");
|
|
2536
2708
|
ctx.take(raw, "align");
|
|
2537
2709
|
if (layer.type !== "text") {
|
|
@@ -3046,6 +3218,68 @@ var upgrade = upgrade$1;
|
|
|
3046
3218
|
function ensureUpgrade() {
|
|
3047
3219
|
return Promise.resolve();
|
|
3048
3220
|
}
|
|
3221
|
+
// ../core/src/v2/colors.ts
|
|
3222
|
+
/**
|
|
3223
|
+
* @license
|
|
3224
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
3225
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
3226
|
+
*/
|
|
3227
|
+
/** The named palettes of a document, read back from its variables: one role → colour map per palette name. */
|
|
3228
|
+
function palettesOf(variables) {
|
|
3229
|
+
const names = variables?.modes?.palette;
|
|
3230
|
+
if (!variables || !names) return void 0;
|
|
3231
|
+
const palettes = Object.fromEntries(names.map((name) => [name, {}]));
|
|
3232
|
+
for (const [role, byPalette] of Object.entries(variables.values ?? {})) for (const [name, color] of Object.entries(byPalette)) if (palettes[name] && typeof color === "string") palettes[name][role] = color;
|
|
3233
|
+
return palettes;
|
|
3234
|
+
}
|
|
3235
|
+
/**
|
|
3236
|
+
* How a renderer paints a 2.0 colour: a palette binding stays a `var()` so a
|
|
3237
|
+
* mode change needs no repaint; drawn-in paints (patterns) take the default
|
|
3238
|
+
* palette's value, since an image cannot hold a `var()`.
|
|
3239
|
+
*/
|
|
3240
|
+
function paintColors(metadata) {
|
|
3241
|
+
const isVar = (v) => !!v && typeof v === "object" && typeof v.var === "string";
|
|
3242
|
+
return {
|
|
3243
|
+
css: (v) => (isVar(v) ? resolveCssColor(v.var, v.fallback) : typeof v === "string" ? resolveCssColor(null, v) : "") || void 0,
|
|
3244
|
+
literal: (v) => (isVar(v) ? (resolvePalette(metadata)?.colors)?.[v.var] ?? resolveCssColor(null, v.fallback) : typeof v === "string" ? resolveCssColor(null, v) : "") || void 0
|
|
3245
|
+
};
|
|
3246
|
+
}
|
|
3247
|
+
// ../core/src/v2/typography.ts
|
|
3248
|
+
/**
|
|
3249
|
+
* @license
|
|
3250
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
3251
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
3252
|
+
*/
|
|
3253
|
+
/** A 2.0 scalar resolved for one language: its exception for that mode, else its value. */
|
|
3254
|
+
function forLanguage(value, lang) {
|
|
3255
|
+
if (typeof value === "number") return value;
|
|
3256
|
+
if (value && typeof value === "object" && "value" in value) {
|
|
3257
|
+
const { value: base, modes } = value;
|
|
3258
|
+
const own = modes?.[lang];
|
|
3259
|
+
return typeof own === "number" ? own : typeof base === "number" ? base : void 0;
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
/**
|
|
3263
|
+
* The CSS typography of a 2.0 text, for one language. Lengths are canvas units,
|
|
3264
|
+
* which the overlay paints 1:1 as px. Absent fields are absent: the caller
|
|
3265
|
+
* keeps its defaults.
|
|
3266
|
+
*/
|
|
3267
|
+
function typographyCss(layer, lang) {
|
|
3268
|
+
const text = layer?.text;
|
|
3269
|
+
if (!text) return void 0;
|
|
3270
|
+
const css = {};
|
|
3271
|
+
const size = forLanguage(text.font?.size, lang);
|
|
3272
|
+
if (size !== void 0) css.fontSize = `${+size.toFixed(4)}px`;
|
|
3273
|
+
const maxWidth = forLanguage(text.maxWidth, lang);
|
|
3274
|
+
if (maxWidth !== void 0) css.maxWidth = `${+maxWidth.toFixed(4)}px`;
|
|
3275
|
+
if (text.font?.family) css.fontFamily = text.font.family;
|
|
3276
|
+
if (text.font?.weight !== void 0) css.fontWeight = String(text.font.weight);
|
|
3277
|
+
if (text.font?.italic) css.fontStyle = "italic";
|
|
3278
|
+
if (text.letterSpacing !== void 0) css.letterSpacing = `${text.letterSpacing}px`;
|
|
3279
|
+
if (text.transform) css.textTransform = text.transform;
|
|
3280
|
+
if (text.decoration) css.textDecoration = text.decoration;
|
|
3281
|
+
return css;
|
|
3282
|
+
}
|
|
3049
3283
|
// ../scene/src/legacy/localizedEntries.ts
|
|
3050
3284
|
/**
|
|
3051
3285
|
* @license
|
|
@@ -3170,53 +3404,11 @@ function v2LayersOf(metadata) {
|
|
|
3170
3404
|
function rememberDocument(view, document) {
|
|
3171
3405
|
cache.set(view, indexLayers(document.layers));
|
|
3172
3406
|
}
|
|
3173
|
-
/**
|
|
3174
|
-
* How the renderer paints a 2.0 colour: a palette binding stays a `var()` so a
|
|
3175
|
-
* mode change needs no repaint; drawn-in paints (patterns) take the default
|
|
3176
|
-
* palette's value, since an image cannot hold a `var()`.
|
|
3177
|
-
*/
|
|
3178
|
-
function paintColors(metadata) {
|
|
3179
|
-
const isVar = (v) => !!v && typeof v === "object" && typeof v.var === "string";
|
|
3180
|
-
return {
|
|
3181
|
-
css: (v) => (isVar(v) ? resolveCssColor(v.var, v.fallback) : typeof v === "string" ? resolveCssColor(null, v) : "") || void 0,
|
|
3182
|
-
literal: (v) => (isVar(v) ? (resolvePalette(metadata)?.colors)?.[v.var] ?? resolveCssColor(null, v.fallback) : typeof v === "string" ? resolveCssColor(null, v) : "") || void 0
|
|
3183
|
-
};
|
|
3184
|
-
}
|
|
3185
3407
|
/** How far a box moves, as CSS translate shares of its own size, so its anchor lands on x, y. */
|
|
3186
3408
|
function anchorShift(box) {
|
|
3187
3409
|
const anchor = box.anchor ?? "top-left";
|
|
3188
3410
|
return [/left/.test(anchor) ? "0%" : /right/.test(anchor) ? "-100%" : "-50%", /^top/.test(anchor) ? "0%" : /^bottom/.test(anchor) ? "-100%" : "-50%"];
|
|
3189
3411
|
}
|
|
3190
|
-
/** A 2.0 scalar resolved for one language: its exception for that mode, else its value. */
|
|
3191
|
-
function forLanguage(value, lang) {
|
|
3192
|
-
if (typeof value === "number") return value;
|
|
3193
|
-
if (value && typeof value === "object" && "value" in value) {
|
|
3194
|
-
const { value: base, modes } = value;
|
|
3195
|
-
const own = modes?.[lang];
|
|
3196
|
-
return typeof own === "number" ? own : typeof base === "number" ? base : void 0;
|
|
3197
|
-
}
|
|
3198
|
-
}
|
|
3199
|
-
/**
|
|
3200
|
-
* The CSS typography of a 2.0 text, for one language. Lengths are canvas units,
|
|
3201
|
-
* which the overlay paints 1:1 as px. Absent fields are absent: the caller
|
|
3202
|
-
* keeps its defaults.
|
|
3203
|
-
*/
|
|
3204
|
-
function typographyCss(layer, lang) {
|
|
3205
|
-
const text = layer?.text;
|
|
3206
|
-
if (!text) return void 0;
|
|
3207
|
-
const css = {};
|
|
3208
|
-
const size = forLanguage(text.font?.size, lang);
|
|
3209
|
-
if (size !== void 0) css.fontSize = `${+size.toFixed(4)}px`;
|
|
3210
|
-
const maxWidth = forLanguage(text.maxWidth, lang);
|
|
3211
|
-
if (maxWidth !== void 0) css.maxWidth = `${+maxWidth.toFixed(4)}px`;
|
|
3212
|
-
if (text.font?.family) css.fontFamily = text.font.family;
|
|
3213
|
-
if (text.font?.weight !== void 0) css.fontWeight = String(text.font.weight);
|
|
3214
|
-
if (text.font?.italic) css.fontStyle = "italic";
|
|
3215
|
-
if (text.letterSpacing !== void 0) css.letterSpacing = `${text.letterSpacing}px`;
|
|
3216
|
-
if (text.transform) css.textTransform = text.transform;
|
|
3217
|
-
if (text.decoration) css.textDecoration = text.decoration;
|
|
3218
|
-
return css;
|
|
3219
|
-
}
|
|
3220
3412
|
/**
|
|
3221
3413
|
* A 2.0 filter set as the 1.x style fields, so the one function all three
|
|
3222
3414
|
* renderers share (`mediaFilterCss`) still writes the CSS. Every key is
|
|
@@ -3365,14 +3557,6 @@ function textFields(slot, text) {
|
|
|
3365
3557
|
if (width.px) slot.style.maxWidth = width.px;
|
|
3366
3558
|
if (width.byLang) slot.style.maxWidths = width.byLang;
|
|
3367
3559
|
}
|
|
3368
|
-
/** The named palettes of the 1.x file, read back from the variables: one role → colour map per palette name. */
|
|
3369
|
-
function palettesOf(variables) {
|
|
3370
|
-
const names = variables?.modes?.palette;
|
|
3371
|
-
if (!variables || !names) return void 0;
|
|
3372
|
-
const palettes = Object.fromEntries(names.map((name) => [name, {}]));
|
|
3373
|
-
for (const [role, byPalette] of Object.entries(variables.values ?? {})) for (const [name, color] of Object.entries(byPalette)) if (palettes[name] && typeof color === "string") palettes[name][role] = color;
|
|
3374
|
-
return palettes;
|
|
3375
|
-
}
|
|
3376
3560
|
/** Slots in paint order: a group, then its children right after it, nested ones included. */
|
|
3377
3561
|
function legacyView(document) {
|
|
3378
3562
|
const slots = [];
|
|
@@ -4436,6 +4620,47 @@ function validateOimMetadata(json) {
|
|
|
4436
4620
|
return errors;
|
|
4437
4621
|
}
|
|
4438
4622
|
/**
|
|
4623
|
+
* The poster seal (OIM_Seal, spec 15 Nov): the image hash signed on its own,
|
|
4624
|
+
* read before the metadata so the poster can be verified from a partial read.
|
|
4625
|
+
* Same rules as a full file: an altered image is refused, an expired key says so.
|
|
4626
|
+
*/
|
|
4627
|
+
async function verifyPosterSeal(seal, imageHash) {
|
|
4628
|
+
if (!seal || seal.v !== 1 || seal.alg !== "sha256-idat") return "invalid";
|
|
4629
|
+
if (typeof seal.image_hash !== "string" || typeof seal.signature !== "string" || typeof seal.key_version !== "string") return "invalid";
|
|
4630
|
+
if (!imageHash || seal.image_hash.toLowerCase() !== imageHash.toLowerCase()) return "invalid";
|
|
4631
|
+
const bytes = new TextEncoder().encode(JSON.stringify({
|
|
4632
|
+
alg: seal.alg,
|
|
4633
|
+
image_hash: seal.image_hash,
|
|
4634
|
+
key_version: seal.key_version,
|
|
4635
|
+
v: seal.v
|
|
4636
|
+
}));
|
|
4637
|
+
try {
|
|
4638
|
+
const raw = atob(seal.signature);
|
|
4639
|
+
const sig = new Uint8Array(raw.length);
|
|
4640
|
+
for (let i = 0; i < raw.length; i++) sig[i] = raw.charCodeAt(i);
|
|
4641
|
+
const check = async (jwk) => {
|
|
4642
|
+
const key = await crypto.subtle.importKey("jwk", jwk, {
|
|
4643
|
+
name: "ECDSA",
|
|
4644
|
+
namedCurve: "P-256"
|
|
4645
|
+
}, false, ["verify"]);
|
|
4646
|
+
return crypto.subtle.verify({
|
|
4647
|
+
name: "ECDSA",
|
|
4648
|
+
hash: { name: "SHA-256" }
|
|
4649
|
+
}, key, sig, bytes);
|
|
4650
|
+
};
|
|
4651
|
+
const jwk = await getPublicKey(seal.key_version);
|
|
4652
|
+
let valid = !!jwk && await check(jwk);
|
|
4653
|
+
if (!valid) {
|
|
4654
|
+
const serverJwk = await getServerPublicKey(seal.key_version).catch(() => null);
|
|
4655
|
+
if (serverJwk && (!jwk || serverJwk.x !== jwk.x || serverJwk.y !== jwk.y)) valid = await check(serverJwk);
|
|
4656
|
+
}
|
|
4657
|
+
if (!valid) return "invalid";
|
|
4658
|
+
} catch {
|
|
4659
|
+
return "invalid";
|
|
4660
|
+
}
|
|
4661
|
+
return await keyExpiredForFile({ key_version: seal.key_version }) ? "expired_key" : "ok";
|
|
4662
|
+
}
|
|
4663
|
+
/**
|
|
4439
4664
|
* @license
|
|
4440
4665
|
* Copyright (c) 2026 Xue Studios LLC
|
|
4441
4666
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -4498,7 +4723,7 @@ function nextWheelZoom(zoom, deltaY, deltaMode, pinch) {
|
|
|
4498
4723
|
* the format can change without the player being touched. Tying both numbers
|
|
4499
4724
|
* together would make an internal fix look like a format break.
|
|
4500
4725
|
*/
|
|
4501
|
-
var CONTRACT_VERSION = "1.
|
|
4726
|
+
var CONTRACT_VERSION = "1.30.0";
|
|
4502
4727
|
/**
|
|
4503
4728
|
* What the player implements TODAY, measured and not assumed.
|
|
4504
4729
|
*
|
|
@@ -11247,7 +11472,7 @@ var ImageEngine = class extends LegacyRenderer {
|
|
|
11247
11472
|
host.classList.add("oim-align-" + this.align);
|
|
11248
11473
|
host.classList.add("oim-tier-" + this._deviceProfile.tier);
|
|
11249
11474
|
if (this._deviceProfile.isMobile) host.classList.add("oim-mobile");
|
|
11250
|
-
shadow.innerHTML = "<div class=\"oim-player-viewport oim-fit-" + this.fit + "\" part=\"viewport\"><img class=\"oim-player-base\" crossorigin=\"anonymous\" src=\"" + this.imageUrl + "\" alt=\"\" aria-hidden=\"true\" part=\"base\" /><div class=\"oim-layer-overlay\" aria-hidden=\"true\" part=\"overlay\"></div></div>";
|
|
11475
|
+
shadow.innerHTML = "<div class=\"oim-player-viewport oim-fit-" + this.fit + "\" part=\"viewport\"><img class=\"oim-player-base\" crossorigin=\"anonymous\"" + (typeof src === "string" ? "" : " src=\"" + this.imageUrl + "\"") + " alt=\"\" aria-hidden=\"true\" part=\"base\" /><div class=\"oim-layer-overlay\" aria-hidden=\"true\" part=\"overlay\"></div></div>";
|
|
11251
11476
|
injectStyles(shadow);
|
|
11252
11477
|
this._viewport = shadow.querySelector(".oim-player-viewport");
|
|
11253
11478
|
this._baseImg = shadow.querySelector(".oim-player-base");
|
|
@@ -11292,6 +11517,35 @@ var ImageEngine = class extends LegacyRenderer {
|
|
|
11292
11517
|
this.updateViewportSize();
|
|
11293
11518
|
this.updateScale();
|
|
11294
11519
|
this._bindViewportEvents();
|
|
11520
|
+
if (typeof src === "string" && imgNode) {
|
|
11521
|
+
const poster = await fileCache.readPoster(src);
|
|
11522
|
+
if (poster) {
|
|
11523
|
+
const verdict = await verifyPosterSeal(poster.seal, poster.imageHash);
|
|
11524
|
+
if (verdict === "invalid") {
|
|
11525
|
+
shadow.innerHTML = "<div class=\"oim-player-error oim-player-refused\" part=\"error\"></div>";
|
|
11526
|
+
injectStyles(shadow);
|
|
11527
|
+
const box = shadow.querySelector(".oim-player-error");
|
|
11528
|
+
if (box) box.textContent = playerString("tampered", self.lang);
|
|
11529
|
+
host.dispatchEvent(new CustomEvent("error", { detail: new Error(ALTERED_FILE_ERROR) }));
|
|
11530
|
+
return false;
|
|
11531
|
+
}
|
|
11532
|
+
if (verdict === "expired_key") try {
|
|
11533
|
+
setFlag(host, "data-oim-key-retired", "data-oim-clave-retirada");
|
|
11534
|
+
} catch (e) {}
|
|
11535
|
+
this.imageUrl = URL.createObjectURL(poster.png);
|
|
11536
|
+
imgNode.src = this.imageUrl;
|
|
11537
|
+
if (this.poster === "only") {
|
|
11538
|
+
this.securityStatus = verdict === "ok" ? "verified" : "expired_key";
|
|
11539
|
+
viewportNode?.classList.add("oim-viewport--poster", "oim-viewport--ready");
|
|
11540
|
+
host.dispatchEvent(new CustomEvent("oim:loaded", { detail: {
|
|
11541
|
+
type: "image",
|
|
11542
|
+
metadata: null,
|
|
11543
|
+
security: this.securityStatus
|
|
11544
|
+
} }));
|
|
11545
|
+
return true;
|
|
11546
|
+
}
|
|
11547
|
+
} else imgNode.src = src;
|
|
11548
|
+
}
|
|
11295
11549
|
return fileCache.getBlob(src).then((blob) => {
|
|
11296
11550
|
return new Promise((resolve2, reject2) => {
|
|
11297
11551
|
OIMRegistry.requestRender(self, blob, src, resolve2, reject2);
|