@oim-media/player-oim 1.32.4 → 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
@@ -415,6 +415,7 @@ var fileCache = {
415
415
  const rangeHeaders = { Range: "bytes=" + (head?.length ?? 0) + "-" };
416
416
  if (validator) rangeHeaders["If-Range"] = validator;
417
417
  e.blob = (head ? fetch(src, { headers: rangeHeaders }).then(async (res) => {
418
+ if (res.status === 416) return new Blob([head]);
418
419
  if (!res.ok) throw new Error("HTTP " + res.status);
419
420
  return res.status === 206 ? new Blob([head, await res.blob()]) : res.blob();
420
421
  }) : fetch(src).then((res) => {
@@ -3138,6 +3139,11 @@ function upgrade$1(input) {
3138
3139
  if (typeof zone === "string" && zone) zoneOf.set(layers[i], zone);
3139
3140
  });
3140
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
+ }
3141
3147
  const variables = convertVariables(ctx, meta, document.languages);
3142
3148
  if (variables) document.variables = variables;
3143
3149
  const background = canvasFills(ctx, meta);
@@ -5849,6 +5855,24 @@ function compareLangs(slot, before, after) {
5849
5855
  if (a.size !== b.size || a.maxWidthValue !== b.maxWidthValue) return "style-only";
5850
5856
  return "none";
5851
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
+ }
5852
5876
  // ../scene/src/legacy/shadow.ts
5853
5877
  /**
5854
5878
  * @license
@@ -5982,12 +6006,6 @@ function maskStyle(layer, colors) {
5982
6006
  const mask = layer.mask ?? {};
5983
6007
  const paint = layer.fills?.[0];
5984
6008
  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
6009
  const color = (value) => typeof value === "string" ? {
5992
6010
  role: void 0,
5993
6011
  literal: value
@@ -6006,8 +6024,7 @@ function maskStyle(layer, colors) {
6006
6024
  maskMode: mask.mode === "cutout" ? "cutout" : "window",
6007
6025
  maskFeather: mask.feather,
6008
6026
  maskCoverage: mask.scope === "group" ? "container" : "canvas",
6009
- maskShape: shape,
6010
- maskSvgPath: geometry?.kind === "paths" ? geometry.paths?.map((p) => p.d).join(" ") : void 0,
6027
+ ...maskOutlineStyle(layer.geometry),
6011
6028
  geoShape: void 0,
6012
6029
  svgPath: void 0,
6013
6030
  maskBgColor: bg.literal,
@@ -6162,7 +6179,7 @@ function legacyView(document) {
6162
6179
  languages: document.languages,
6163
6180
  slots
6164
6181
  };
6165
- if (document.canvas.fills?.length) view.canvasFills = document.canvas.fills;
6182
+ if (document.canvas.fills?.length && !hasBaseLayer(document)) view.canvasFills = document.canvas.fills;
6166
6183
  if (document.fonts) view.fonts = document.fonts;
6167
6184
  const palettes = palettesOf(document.variables);
6168
6185
  if (palettes) view.palettes = palettes;
@@ -7306,7 +7323,7 @@ function nextWheelZoom(zoom, deltaY, deltaMode, pinch) {
7306
7323
  * the format can change without the player being touched. Tying both numbers
7307
7324
  * together would make an internal fix look like a format break.
7308
7325
  */
7309
- var CONTRACT_VERSION = "1.32.4";
7326
+ var CONTRACT_VERSION = "1.32.5";
7310
7327
  /**
7311
7328
  * What the player implements TODAY, measured and not assumed.
7312
7329
  *
@@ -7401,7 +7418,7 @@ function describeMissing(missing) {
7401
7418
  */
7402
7419
  /** `oim-` + 8 hex of the SHA-256 of the family's variants + `-` + family. */
7403
7420
  var EMBEDDED_FONT_NAME = /^oim-[0-9a-f]{8}-[A-Za-z0-9 ]{1,64}$/;
7404
- // ../scene/src/legacy/embeddedFonts.ts
7421
+ // ../scene/src/blocks/fonts.ts
7405
7422
  /**
7406
7423
  * @license
7407
7424
  * Copyright (c) 2026 Xue Studios LLC
@@ -9234,7 +9251,7 @@ function flipScale(flipX, flipY) {
9234
9251
  if (!flipX && !flipY) return null;
9235
9252
  return [flipX ? -1 : 1, flipY ? -1 : 1];
9236
9253
  }
9237
- // ../scene/src/legacy/image-fill.ts
9254
+ // ../scene/src/blocks/silhouette-clip.ts
9238
9255
  /**
9239
9256
  * @license
9240
9257
  * Copyright (c) 2026 Xue Studios LLC
@@ -9242,48 +9259,70 @@ function flipScale(flipX, flipY) {
9242
9259
  */
9243
9260
  var SVG_NS = "http://www.w3.org/2000/svg";
9244
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";
9245
9264
  /**
9246
- * Image fill of a shape (contract 1.17.0). The photo sits in a box clipped by
9247
- * the silhouette, under the stroke drawing. The URL goes into the `src`
9248
- * property of an <img>, never into a CSS url(), so it cannot inject CSS.
9249
- * 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.
9250
9268
  */
9251
- function mountImageFill(slotEl, paint, silhouette, resolvedUrl, fallbackColor) {
9269
+ function silhouetteClip(doc, silhouette) {
9252
9270
  const id = `oim-image-fill-${++sequence}`;
9253
9271
  const [x0, y0, width, height] = silhouette.viewBox.trim().split(/\s+/).map(Number);
9254
9272
  const scale = width === height ? `scale(${1 / width})` : `scale(${1 / width} ${1 / height})`;
9255
9273
  const transform = x0 || y0 ? `${scale} translate(${-x0} ${-y0})` : scale;
9256
- const box = document.createElement("div");
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");
9274
+ const svg = doc.createElementNS(SVG_NS, "svg");
9267
9275
  svg.setAttribute("width", "0");
9268
9276
  svg.setAttribute("height", "0");
9269
9277
  svg.style.position = "absolute";
9270
- const clip = document.createElementNS(SVG_NS, "clipPath");
9278
+ const clip = doc.createElementNS(SVG_NS, "clipPath");
9271
9279
  clip.setAttribute("id", id);
9272
9280
  clip.setAttribute("clipPathUnits", "objectBoundingBox");
9273
- const shape = document.createElementNS(SVG_NS, silhouette.rect ? "rect" : "path");
9274
- if (silhouette.rect) {
9275
- shape.setAttribute("x", "0");
9276
- shape.setAttribute("y", "0");
9277
- shape.setAttribute("width", "1");
9278
- shape.setAttribute("height", "1");
9279
- shape.setAttribute("rx", String(silhouette.rect.rx));
9280
- shape.setAttribute("ry", String(silhouette.rect.ry));
9281
- } 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 {
9282
9291
  shape.setAttribute("d", silhouette.d);
9283
9292
  shape.setAttribute("transform", transform);
9293
+ if (silhouette.evenodd) shape.setAttribute("clip-rule", "evenodd");
9284
9294
  }
9285
9295
  clip.appendChild(shape);
9286
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;
9287
9326
  box.appendChild(svg);
9288
9327
  const crop = cropCss(paint.crop ?? {
9289
9328
  x: 50,
@@ -9318,6 +9357,42 @@ function mountImageFill(slotEl, paint, silhouette, resolvedUrl, fallbackColor) {
9318
9357
  box.appendChild(img);
9319
9358
  slotEl.insertBefore(box, slotEl.firstChild);
9320
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
+ }
9321
9396
  // ../scene/src/legacy/groups.ts
9322
9397
  /**
9323
9398
  * @license
@@ -9489,6 +9564,37 @@ function applyMinHitArea(el) {
9489
9564
  el.style.minHeight = `24px`;
9490
9565
  }
9491
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
+ /**
9492
9598
  * Hooks a slot's states up to its pointer events.
9493
9599
  *
9494
9600
  * It lives here and not inside `renderSlots` so that it can be tested: the hook-up
@@ -9565,31 +9671,6 @@ function stateStyles(e) {
9565
9671
  if (e.transitionDuration !== void 0) s["--oim-transition-duration"] = `${e.transitionDuration}s`;
9566
9672
  return s;
9567
9673
  }
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
9674
  // ../core/src/artisticTextCurve.ts
9594
9675
  /**
9595
9676
  * @license
@@ -9686,7 +9767,7 @@ function calculate3DExtrusionLayers(depth, angleDegrees, baseColor = "#111827",
9686
9767
  }
9687
9768
  return layers;
9688
9769
  }
9689
- // ../scene/src/legacy/artisticText.ts
9770
+ // ../scene/src/blocks/artisticText.ts
9690
9771
  /**
9691
9772
  * @license
9692
9773
  * Copyright (c) 2026 Xue Studios LLC
@@ -10901,7 +10982,7 @@ var LegacyRenderer = class {
10901
10982
  }
10902
10983
  } else slotEl.append(svg);
10903
10984
  if (imageFill) mountImageFill(slotEl, v2Fill, {
10904
- d: silhouette.d ?? "M " + silhouette.points.split(" ").join(" L ") + " Z",
10985
+ d: silhouettePath(silhouette),
10905
10986
  viewBox: silhouette.viewBox
10906
10987
  }, fillImageSrc, underColor);
10907
10988
  slotEl.style.backgroundColor = "transparent";
@@ -11451,36 +11532,10 @@ var LegacyRenderer = class {
11451
11532
  self.sceneReady();
11452
11533
  }
11453
11534
  }
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
- */
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). */
11459
11536
  _defineLayerGrain(id, fx) {
11460
11537
  const layer = this._viewport || this._overlay;
11461
- if (!layer || typeof DOMParser === "undefined") return;
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));
11538
+ if (layer) defineGrain(layer, id, fx);
11484
11539
  }
11485
11540
  /** True once the veil has lifted for the first time. */
11486
11541
  _revealed = false;