@oim-media/player-oim 1.32.3 → 1.32.5

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
@@ -313,6 +313,7 @@ async function readHead(src, e) {
313
313
  if (head.done && head.seal && "idat" in head) {
314
314
  await reader.cancel().catch(() => {});
315
315
  e.head = buf;
316
+ e.validator = res.headers.get("ETag") ?? res.headers.get("Last-Modified") ?? void 0;
316
317
  return {
317
318
  png: new Blob([posterPng(buf, head.sealStart)], { type: "image/png" }),
318
319
  seal: head.seal,
@@ -408,8 +409,13 @@ var fileCache = {
408
409
  e.pending++;
409
410
  evict();
410
411
  const head = e.head;
412
+ const validator = e.validator;
411
413
  e.head = void 0;
412
- e.blob = (head ? fetch(src, { headers: { Range: "bytes=" + head.length + "-" } }).then(async (res) => {
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.status === 416) return new Blob([head]);
413
419
  if (!res.ok) throw new Error("HTTP " + res.status);
414
420
  return res.status === 206 ? new Blob([head, await res.blob()]) : res.blob();
415
421
  }) : fetch(src).then((res) => {
@@ -3133,6 +3139,11 @@ function upgrade$1(input) {
3133
3139
  if (typeof zone === "string" && zone) zoneOf.set(layers[i], zone);
3134
3140
  });
3135
3141
  document.layers = convertZones(ctx, meta, buildTree(ctx, slots, layers), zoneOf);
3142
+ 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)));
3143
+ if (backgroundIds.size) {
3144
+ const rank = (layer) => layer.id === "oim-base" ? 0 : backgroundIds.has(layer.id) ? 1 : 2;
3145
+ document.layers = [...document.layers].sort((a, b) => rank(a) - rank(b));
3146
+ }
3136
3147
  const variables = convertVariables(ctx, meta, document.languages);
3137
3148
  if (variables) document.variables = variables;
3138
3149
  const background = canvasFills(ctx, meta);
@@ -5844,6 +5855,24 @@ function compareLangs(slot, before, after) {
5844
5855
  if (a.size !== b.size || a.maxWidthValue !== b.maxWidthValue) return "style-only";
5845
5856
  return "none";
5846
5857
  }
5858
+ // ../scene/src/blocks/mask-outline-style.ts
5859
+ /**
5860
+ * @license
5861
+ * Copyright (c) 2026 Xue Studios LLC
5862
+ * SPDX-License-Identifier: Apache-2.0
5863
+ */
5864
+ /** A 2.0 geometry as the mask outline fields the composition reads: a named shape, or `custom` with its path. */
5865
+ function maskOutlineStyle(geometry) {
5866
+ const g = geometry;
5867
+ return {
5868
+ maskShape: g?.kind === "preset" ? g.name : g?.kind === "paths" ? "custom" : {
5869
+ rect: "rectangle",
5870
+ ellipse: "circle",
5871
+ line: "line"
5872
+ }[g?.kind ?? ""],
5873
+ maskSvgPath: g?.kind === "paths" ? g.paths?.map((p) => p.d).join(" ") : void 0
5874
+ };
5875
+ }
5847
5876
  // ../scene/src/legacy/shadow.ts
5848
5877
  /**
5849
5878
  * @license
@@ -5977,12 +6006,6 @@ function maskStyle(layer, colors) {
5977
6006
  const mask = layer.mask ?? {};
5978
6007
  const paint = layer.fills?.[0];
5979
6008
  const gradient = paint && "gradient" in paint && paint.gradient ? gradientCss(paint.gradient, colors) : void 0;
5980
- const geometry = layer.geometry;
5981
- const shape = geometry?.kind === "preset" ? geometry.name : geometry?.kind === "paths" ? "custom" : {
5982
- rect: "rectangle",
5983
- ellipse: "circle",
5984
- line: "line"
5985
- }[geometry?.kind ?? ""];
5986
6009
  const color = (value) => typeof value === "string" ? {
5987
6010
  role: void 0,
5988
6011
  literal: value
@@ -6001,8 +6024,7 @@ function maskStyle(layer, colors) {
6001
6024
  maskMode: mask.mode === "cutout" ? "cutout" : "window",
6002
6025
  maskFeather: mask.feather,
6003
6026
  maskCoverage: mask.scope === "group" ? "container" : "canvas",
6004
- maskShape: shape,
6005
- maskSvgPath: geometry?.kind === "paths" ? geometry.paths?.map((p) => p.d).join(" ") : void 0,
6027
+ ...maskOutlineStyle(layer.geometry),
6006
6028
  geoShape: void 0,
6007
6029
  svgPath: void 0,
6008
6030
  maskBgColor: bg.literal,
@@ -6157,7 +6179,7 @@ function legacyView(document) {
6157
6179
  languages: document.languages,
6158
6180
  slots
6159
6181
  };
6160
- if (document.canvas.fills?.length) view.canvasFills = document.canvas.fills;
6182
+ if (document.canvas.fills?.length && !hasBaseLayer(document)) view.canvasFills = document.canvas.fills;
6161
6183
  if (document.fonts) view.fonts = document.fonts;
6162
6184
  const palettes = palettesOf(document.variables);
6163
6185
  if (palettes) view.palettes = palettes;
@@ -7301,7 +7323,7 @@ function nextWheelZoom(zoom, deltaY, deltaMode, pinch) {
7301
7323
  * the format can change without the player being touched. Tying both numbers
7302
7324
  * together would make an internal fix look like a format break.
7303
7325
  */
7304
- var CONTRACT_VERSION = "1.32.3";
7326
+ var CONTRACT_VERSION = "1.32.5";
7305
7327
  /**
7306
7328
  * What the player implements TODAY, measured and not assumed.
7307
7329
  *
@@ -7396,7 +7418,7 @@ function describeMissing(missing) {
7396
7418
  */
7397
7419
  /** `oim-` + 8 hex of the SHA-256 of the family's variants + `-` + family. */
7398
7420
  var EMBEDDED_FONT_NAME = /^oim-[0-9a-f]{8}-[A-Za-z0-9 ]{1,64}$/;
7399
- // ../scene/src/legacy/embeddedFonts.ts
7421
+ // ../scene/src/blocks/fonts.ts
7400
7422
  /**
7401
7423
  * @license
7402
7424
  * Copyright (c) 2026 Xue Studios LLC
@@ -9229,7 +9251,7 @@ function flipScale(flipX, flipY) {
9229
9251
  if (!flipX && !flipY) return null;
9230
9252
  return [flipX ? -1 : 1, flipY ? -1 : 1];
9231
9253
  }
9232
- // ../scene/src/legacy/image-fill.ts
9254
+ // ../scene/src/blocks/silhouette-clip.ts
9233
9255
  /**
9234
9256
  * @license
9235
9257
  * Copyright (c) 2026 Xue Studios LLC
@@ -9237,48 +9259,70 @@ function flipScale(flipX, flipY) {
9237
9259
  */
9238
9260
  var SVG_NS = "http://www.w3.org/2000/svg";
9239
9261
  var sequence = 0;
9262
+ /** Path data for a silhouette given as polygon points or as a path. */
9263
+ var silhouettePath = (figure) => figure.d ?? "M " + figure.points.split(" ").join(" L ") + " Z";
9240
9264
  /**
9241
- * Image fill of a shape (contract 1.17.0). The photo sits in a box clipped by
9242
- * the silhouette, under the stroke drawing. The URL goes into the `src`
9243
- * property of an <img>, never into a CSS url(), so it cannot inject CSS.
9244
- * Built once when the slot is built: no per-frame work.
9265
+ * A zero-size <svg> holding a clipPath in objectBoundingBox units, so the silhouette
9266
+ * maps onto whatever box references it, at any size. Returns the svg and the
9267
+ * `clip-path` value that references it.
9245
9268
  */
9246
- function mountImageFill(slotEl, paint, silhouette, resolvedUrl, fallbackColor) {
9269
+ function silhouetteClip(doc, silhouette) {
9247
9270
  const id = `oim-image-fill-${++sequence}`;
9248
9271
  const [x0, y0, width, height] = silhouette.viewBox.trim().split(/\s+/).map(Number);
9249
9272
  const scale = width === height ? `scale(${1 / width})` : `scale(${1 / width} ${1 / height})`;
9250
9273
  const transform = x0 || y0 ? `${scale} translate(${-x0} ${-y0})` : scale;
9251
- const box = document.createElement("div");
9252
- box.className = "oim-image-fill";
9253
- box.style.position = "absolute";
9254
- box.style.left = "0";
9255
- box.style.top = "0";
9256
- box.style.width = "100%";
9257
- box.style.height = "100%";
9258
- box.style.overflow = "hidden";
9259
- box.style.pointerEvents = "none";
9260
- box.style.clipPath = `url(#${id})`;
9261
- const svg = document.createElementNS(SVG_NS, "svg");
9274
+ const svg = doc.createElementNS(SVG_NS, "svg");
9262
9275
  svg.setAttribute("width", "0");
9263
9276
  svg.setAttribute("height", "0");
9264
9277
  svg.style.position = "absolute";
9265
- const clip = document.createElementNS(SVG_NS, "clipPath");
9278
+ const clip = doc.createElementNS(SVG_NS, "clipPath");
9266
9279
  clip.setAttribute("id", id);
9267
9280
  clip.setAttribute("clipPathUnits", "objectBoundingBox");
9268
- const shape = document.createElementNS(SVG_NS, silhouette.rect ? "rect" : "path");
9269
- if (silhouette.rect) {
9270
- shape.setAttribute("x", "0");
9271
- shape.setAttribute("y", "0");
9272
- shape.setAttribute("width", "1");
9273
- shape.setAttribute("height", "1");
9274
- shape.setAttribute("rx", String(silhouette.rect.rx));
9275
- shape.setAttribute("ry", String(silhouette.rect.ry));
9276
- } else {
9281
+ const shape = doc.createElementNS(SVG_NS, silhouette.rect ? "rect" : "path");
9282
+ if (silhouette.rect) for (const [k, v] of [
9283
+ ["x", "0"],
9284
+ ["y", "0"],
9285
+ ["width", "1"],
9286
+ ["height", "1"],
9287
+ ["rx", String(silhouette.rect.rx)],
9288
+ ["ry", String(silhouette.rect.ry)]
9289
+ ]) shape.setAttribute(k, v);
9290
+ else {
9277
9291
  shape.setAttribute("d", silhouette.d);
9278
9292
  shape.setAttribute("transform", transform);
9293
+ if (silhouette.evenodd) shape.setAttribute("clip-rule", "evenodd");
9279
9294
  }
9280
9295
  clip.appendChild(shape);
9281
9296
  svg.appendChild(clip);
9297
+ return {
9298
+ svg,
9299
+ clipPath: `url(#${id})`
9300
+ };
9301
+ }
9302
+ // ../scene/src/legacy/image-fill.ts
9303
+ /**
9304
+ * @license
9305
+ * Copyright (c) 2026 Xue Studios LLC
9306
+ * SPDX-License-Identifier: Apache-2.0
9307
+ */
9308
+ /**
9309
+ * Image fill of a shape (contract 1.17.0). The photo sits in a box clipped by
9310
+ * the silhouette, under the stroke drawing. The URL goes into the `src`
9311
+ * property of an <img>, never into a CSS url(), so it cannot inject CSS.
9312
+ * Built once when the slot is built: no per-frame work.
9313
+ */
9314
+ function mountImageFill(slotEl, paint, silhouette, resolvedUrl, fallbackColor) {
9315
+ const { svg, clipPath } = silhouetteClip(document, silhouette);
9316
+ const box = document.createElement("div");
9317
+ box.className = "oim-image-fill";
9318
+ box.style.position = "absolute";
9319
+ box.style.left = "0";
9320
+ box.style.top = "0";
9321
+ box.style.width = "100%";
9322
+ box.style.height = "100%";
9323
+ box.style.overflow = "hidden";
9324
+ box.style.pointerEvents = "none";
9325
+ box.style.clipPath = clipPath;
9282
9326
  box.appendChild(svg);
9283
9327
  const crop = cropCss(paint.crop ?? {
9284
9328
  x: 50,
@@ -9313,6 +9357,42 @@ function mountImageFill(slotEl, paint, silhouette, resolvedUrl, fallbackColor) {
9313
9357
  box.appendChild(img);
9314
9358
  slotEl.insertBefore(box, slotEl.firstChild);
9315
9359
  }
9360
+ // ../scene/src/blocks/grain.ts
9361
+ /**
9362
+ * @license
9363
+ * Copyright (c) 2026 Xue Studios LLC
9364
+ * SPDX-License-Identifier: Apache-2.0
9365
+ */
9366
+ var SVG = "http://www.w3.org/2000/svg";
9367
+ /**
9368
+ * Puts the core's grain filter for one layer into `host`'s own defs, replacing an
9369
+ * earlier one with the same id. Parsed as SVG, never assigned as HTML: the markup
9370
+ * is built from a sanitised id, clamped numbers and a fixed list of blend modes.
9371
+ */
9372
+ function defineGrain(host, id, fx) {
9373
+ if (typeof DOMParser === "undefined") return;
9374
+ const doc = host.ownerDocument;
9375
+ let defs = host.querySelector(":scope > svg.oim-grain-defs > defs");
9376
+ if (!defs) {
9377
+ const svg = doc.createElementNS(SVG, "svg");
9378
+ svg.setAttribute("class", "oim-grain-defs");
9379
+ svg.setAttribute("width", "0");
9380
+ svg.setAttribute("height", "0");
9381
+ svg.setAttribute("aria-hidden", "true");
9382
+ svg.setAttribute("style", "position:absolute;pointer-events:none");
9383
+ defs = doc.createElementNS(SVG, "defs");
9384
+ svg.appendChild(defs);
9385
+ host.appendChild(svg);
9386
+ }
9387
+ defs.querySelector("#" + id)?.remove();
9388
+ const markup = buildLayerGrainFilter(id, {
9389
+ intensity: fx.intensity,
9390
+ size: fx.size,
9391
+ blend: fx.blend
9392
+ });
9393
+ const filter = new DOMParser().parseFromString(`<svg xmlns="${SVG}"><defs>${markup}</defs></svg>`, "image/svg+xml").querySelector("filter");
9394
+ if (filter) defs.appendChild(doc.importNode(filter, true));
9395
+ }
9316
9396
  // ../scene/src/legacy/groups.ts
9317
9397
  /**
9318
9398
  * @license
@@ -9484,6 +9564,37 @@ function applyMinHitArea(el) {
9484
9564
  el.style.minHeight = `24px`;
9485
9565
  }
9486
9566
  /**
9567
+ * Resolves a list of actions against the current visibility of the slots.
9568
+ * Pure function: it does not touch the DOM. Same semantics as the editor's visibility resolver.
9569
+ */
9570
+ function resolveActions(actions, currentVisibility) {
9571
+ const visibility = {};
9572
+ const texts = {};
9573
+ if (!actions || actions.length === 0) return {
9574
+ visibility,
9575
+ texts
9576
+ };
9577
+ for (const act of actions) {
9578
+ const targetId = act.target;
9579
+ if (!targetId) continue;
9580
+ const currentVis = currentVisibility[targetId] !== void 0 ? currentVisibility[targetId] : true;
9581
+ if (act.type === "show") visibility[targetId] = true;
9582
+ else if (act.type === "hide") visibility[targetId] = false;
9583
+ else if (act.type === "toggle") visibility[targetId] = !currentVis;
9584
+ else if (act.type === "setText") texts[targetId] = act.value !== void 0 && act.value !== null ? String(act.value) : "";
9585
+ }
9586
+ return {
9587
+ visibility,
9588
+ texts
9589
+ };
9590
+ }
9591
+ // ../scene/src/legacy/states.ts
9592
+ /**
9593
+ * @license
9594
+ * Copyright (c) 2026 Xue Studios LLC
9595
+ * SPDX-License-Identifier: Apache-2.0
9596
+ */
9597
+ /**
9487
9598
  * Hooks a slot's states up to its pointer events.
9488
9599
  *
9489
9600
  * It lives here and not inside `renderSlots` so that it can be tested: the hook-up
@@ -9560,31 +9671,6 @@ function stateStyles(e) {
9560
9671
  if (e.transitionDuration !== void 0) s["--oim-transition-duration"] = `${e.transitionDuration}s`;
9561
9672
  return s;
9562
9673
  }
9563
- /**
9564
- * Resolves a list of actions against the current visibility of the slots.
9565
- * Pure function: it does not touch the DOM. Same semantics as the editor's visibility resolver.
9566
- */
9567
- function resolveActions(actions, currentVisibility) {
9568
- const visibility = {};
9569
- const texts = {};
9570
- if (!actions || actions.length === 0) return {
9571
- visibility,
9572
- texts
9573
- };
9574
- for (const act of actions) {
9575
- const targetId = act.target;
9576
- if (!targetId) continue;
9577
- const currentVis = currentVisibility[targetId] !== void 0 ? currentVisibility[targetId] : true;
9578
- if (act.type === "show") visibility[targetId] = true;
9579
- else if (act.type === "hide") visibility[targetId] = false;
9580
- else if (act.type === "toggle") visibility[targetId] = !currentVis;
9581
- else if (act.type === "setText") texts[targetId] = act.value !== void 0 && act.value !== null ? String(act.value) : "";
9582
- }
9583
- return {
9584
- visibility,
9585
- texts
9586
- };
9587
- }
9588
9674
  // ../core/src/artisticTextCurve.ts
9589
9675
  /**
9590
9676
  * @license
@@ -9681,7 +9767,7 @@ function calculate3DExtrusionLayers(depth, angleDegrees, baseColor = "#111827",
9681
9767
  }
9682
9768
  return layers;
9683
9769
  }
9684
- // ../scene/src/legacy/artisticText.ts
9770
+ // ../scene/src/blocks/artisticText.ts
9685
9771
  /**
9686
9772
  * @license
9687
9773
  * Copyright (c) 2026 Xue Studios LLC
@@ -10896,7 +10982,7 @@ var LegacyRenderer = class {
10896
10982
  }
10897
10983
  } else slotEl.append(svg);
10898
10984
  if (imageFill) mountImageFill(slotEl, v2Fill, {
10899
- d: silhouette.d ?? "M " + silhouette.points.split(" ").join(" L ") + " Z",
10985
+ d: silhouettePath(silhouette),
10900
10986
  viewBox: silhouette.viewBox
10901
10987
  }, fillImageSrc, underColor);
10902
10988
  slotEl.style.backgroundColor = "transparent";
@@ -11446,36 +11532,10 @@ var LegacyRenderer = class {
11446
11532
  self.sceneReady();
11447
11533
  }
11448
11534
  }
11449
- /**
11450
- * Puts the core's grain filter for one layer into this player's own defs.
11451
- * Parsed as SVG, never assigned as HTML: the markup is built from a
11452
- * sanitised id, clamped numbers and a fixed list of blend modes.
11453
- */
11535
+ /** The grain filter of one layer, in the viewport (not the overlay: a full render empties the overlay and took the defs with it). */
11454
11536
  _defineLayerGrain(id, fx) {
11455
11537
  const layer = this._viewport || this._overlay;
11456
- if (!layer || typeof DOMParser === "undefined") return;
11457
- let defs = layer.querySelector(":scope > svg.oim-grain-defs > defs");
11458
- if (!defs) {
11459
- const svgNs = "http://www.w3.org/2000/svg";
11460
- const svg = document.createElementNS(svgNs, "svg");
11461
- svg.setAttribute("class", "oim-grain-defs");
11462
- svg.setAttribute("width", "0");
11463
- svg.setAttribute("height", "0");
11464
- svg.setAttribute("aria-hidden", "true");
11465
- svg.setAttribute("style", "position:absolute;pointer-events:none");
11466
- defs = document.createElementNS(svgNs, "defs");
11467
- svg.appendChild(defs);
11468
- layer.appendChild(svg);
11469
- }
11470
- const existing = defs.querySelector("#" + id);
11471
- if (existing) existing.remove();
11472
- const markup = buildLayerGrainFilter(id, {
11473
- intensity: fx.intensity,
11474
- size: fx.size,
11475
- blend: fx.blend
11476
- });
11477
- const filter = new DOMParser().parseFromString("<svg xmlns=\"http://www.w3.org/2000/svg\"><defs>" + markup + "</defs></svg>", "image/svg+xml").querySelector("filter");
11478
- if (filter) defs.appendChild(document.importNode(filter, true));
11538
+ if (layer) defineGrain(layer, id, fx);
11479
11539
  }
11480
11540
  /** True once the veil has lifted for the first time. */
11481
11541
  _revealed = false;