@oim-media/player-oim 1.32.0 → 1.32.2

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
@@ -1871,7 +1871,12 @@ function convertPaints(ctx, slot, layer) {
1871
1871
  const markup = drawsMarkup(slot);
1872
1872
  const tint = markup ? colorOf(ctx, style, "strokeColor", "strokeColorRole") : void 0;
1873
1873
  if (markup) ctx.take(style, "strokeWidth");
1874
- let outline = tint !== void 0 ? {
1874
+ const gradientStroke = markup && ctx.take(style, "strokePaint") === "gradient" ? gradientOf(ctx, style, "strokeGradient", "style") : void 0;
1875
+ if (markup) ctx.take(style, "strokeGradient");
1876
+ let outline = gradientStroke ? {
1877
+ paint: gradientStroke,
1878
+ width: 0
1879
+ } : tint !== void 0 ? {
1875
1880
  paint: {
1876
1881
  kind: "color",
1877
1882
  value: tint
@@ -2298,6 +2303,11 @@ function shapeGeometry(ctx, slot, media) {
2298
2303
  kind: "paths",
2299
2304
  ...parsed.value
2300
2305
  };
2306
+ const original = xml !== rawXml && typeof rawXml === "string" && rawXml ? svgToPaths(rawXml) : void 0;
2307
+ if (original?.ok) return {
2308
+ kind: "paths",
2309
+ ...original.value
2310
+ };
2301
2311
  ctx.note(`style.svgRawXml: ${parsed.reason}`);
2302
2312
  return { kind: "rect" };
2303
2313
  }
@@ -5700,6 +5710,52 @@ function typographyCss(layer, lang) {
5700
5710
  if (text.decoration) css.textDecoration = text.decoration;
5701
5711
  return css;
5702
5712
  }
5713
+ // ../core/src/v2/svg-gradient.ts
5714
+ /**
5715
+ * @license
5716
+ * Copyright (c) 2026 Xue Studios LLC
5717
+ * SPDX-License-Identifier: Apache-2.0
5718
+ */
5719
+ /**
5720
+ * A gradient as an SVG <linearGradient>/<radialGradient> in viewBox units
5721
+ * (`userSpaceOnUse`), so a multi-path drawing reads as one piece. The editor and
5722
+ * the player both draw with this, so they cannot disagree on the direction.
5723
+ * CSS angles: 0deg points up and turns clockwise; the line crosses the box centre.
5724
+ * A radial is centred and reaches the farthest corner (the CSS default).
5725
+ */
5726
+ function svgGradientAttrs(gradient, viewBox) {
5727
+ const [vx, vy, vw, vh] = viewBox;
5728
+ const cx = vx + vw / 2;
5729
+ const cy = vy + vh / 2;
5730
+ const n = gradient.stops.length;
5731
+ const stops = gradient.stops.map((s, i) => ({
5732
+ offset: `${Math.round((s.at ?? i / (n - 1)) * 1e4) / 100}%`,
5733
+ color: s.color
5734
+ }));
5735
+ if (gradient.type === "radial") return {
5736
+ tag: "radialGradient",
5737
+ attrs: {
5738
+ cx,
5739
+ cy,
5740
+ r: Math.hypot(vw / 2, vh / 2)
5741
+ },
5742
+ stops
5743
+ };
5744
+ const rad = ((gradient.angle ?? 180) - 90) * Math.PI / 180;
5745
+ const half = (Math.abs(vw * Math.cos(rad)) + Math.abs(vh * Math.sin(rad))) / 2;
5746
+ const dx = Math.cos(rad) * half;
5747
+ const dy = Math.sin(rad) * half;
5748
+ return {
5749
+ tag: "linearGradient",
5750
+ attrs: {
5751
+ x1: cx - dx,
5752
+ y1: cy - dy,
5753
+ x2: cx + dx,
5754
+ y2: cy + dy
5755
+ },
5756
+ stops
5757
+ };
5758
+ }
5703
5759
  // ../scene/src/legacy/localizedEntries.ts
5704
5760
  /**
5705
5761
  * @license
@@ -5975,6 +6031,7 @@ var safeColor = (c) => c && !/[;{}<>"]|url\(|expression\(/i.test(c) ? c : void 0
5975
6031
  * Colours go through CSSOM: a role is a var(), and an invalid value is dropped,
5976
6032
  * not injected into the markup.
5977
6033
  */
6034
+ var gradientIds = 0;
5978
6035
  function drawingSvg(geometry, link, tile = false) {
5979
6036
  const NS = "http://www.w3.org/2000/svg";
5980
6037
  const svg = document.createElementNS(NS, "svg");
@@ -5986,11 +6043,25 @@ function drawingSvg(geometry, link, tile = false) {
5986
6043
  svg.setAttribute("preserveAspectRatio", "xMidYMid meet");
5987
6044
  svg.style.setProperty("display", "block");
5988
6045
  }
6046
+ let strokeUrl;
6047
+ if (link.strokeGradient) {
6048
+ const { tag, attrs, stops } = svgGradientAttrs(link.strokeGradient, geometry.viewBox);
6049
+ const grad = svg.appendChild(document.createElementNS(NS, "defs")).appendChild(document.createElementNS(NS, tag));
6050
+ grad.id = `oim-sg-${++gradientIds}`;
6051
+ grad.setAttribute("gradientUnits", "userSpaceOnUse");
6052
+ for (const [k, v] of Object.entries(attrs)) grad.setAttribute(k, String(v));
6053
+ for (const st of stops) {
6054
+ const stop = grad.appendChild(document.createElementNS(NS, "stop"));
6055
+ stop.setAttribute("offset", st.offset);
6056
+ stop.setAttribute("stop-color", safeColor(st.color) ?? "#000");
6057
+ }
6058
+ strokeUrl = `url(#${grad.id})`;
6059
+ }
5989
6060
  for (const p of geometry.paths) {
5990
6061
  const el = document.createElementNS(NS, "path");
5991
6062
  el.setAttribute("d", p.d);
5992
6063
  const fill = safeColor(p.fill === "currentColor" ? link.fill ?? "currentColor" : p.fill);
5993
- const stroke = safeColor(p.stroke === "currentColor" ? link.stroke ?? "currentColor" : p.stroke);
6064
+ const stroke = strokeUrl ?? safeColor(p.stroke === "currentColor" ? link.stroke ?? "currentColor" : p.stroke);
5994
6065
  if (tile) {
5995
6066
  el.setAttribute("fill", fill ?? "none");
5996
6067
  if (stroke) el.setAttribute("stroke", stroke);
@@ -6009,14 +6080,28 @@ function drawingSvg(geometry, link, tile = false) {
6009
6080
  }
6010
6081
  return svg.outerHTML;
6011
6082
  }
6012
- /** The colour a drawing's `currentColor` takes, as CSS or as a literal for a baked tile. */
6083
+ /** A drawing whose first fill is not a flat colour: the fill layer paints it, cut to the paths. */
6084
+ function paintedByFillLayer(layer) {
6085
+ const kind = (layer.fills?.[0])?.kind;
6086
+ return kind === "gradient" || kind === "pattern" || kind === "generative";
6087
+ }
6013
6088
  function drawingLink(layer, color) {
6014
6089
  const flat = (paint) => paint && typeof paint === "object" && paint.kind === "color" ? color(paint.value) : void 0;
6015
6090
  const fill = flat(layer.fills?.[0]);
6016
- const stroke = flat(layer.strokes?.[0]?.paint);
6091
+ const paint = layer.strokes?.[0]?.paint;
6092
+ const stroke = flat(paint);
6093
+ const g = paint?.kind === "gradient" && paint.gradient?.type !== "conic" ? paint.gradient : void 0;
6094
+ const strokeGradient = g && {
6095
+ ...g,
6096
+ stops: g.stops.map((s) => ({
6097
+ ...s,
6098
+ color: color(s.color) ?? s.color
6099
+ }))
6100
+ };
6017
6101
  return {
6018
6102
  fill: fill ?? stroke,
6019
- stroke: stroke ?? fill
6103
+ stroke: stroke ?? fill,
6104
+ ...strokeGradient && { strokeGradient }
6020
6105
  };
6021
6106
  }
6022
6107
  // ../scene/src/legacy/legacy-view.ts
@@ -7216,7 +7301,7 @@ function nextWheelZoom(zoom, deltaY, deltaMode, pinch) {
7216
7301
  * the format can change without the player being touched. Tying both numbers
7217
7302
  * together would make an internal fix look like a format break.
7218
7303
  */
7219
- var CONTRACT_VERSION = "1.32.0";
7304
+ var CONTRACT_VERSION = "1.32.2";
7220
7305
  /**
7221
7306
  * What the player implements TODAY, measured and not assumed.
7222
7307
  *
@@ -10367,7 +10452,10 @@ var LegacyRenderer = class {
10367
10452
  const v2Words = v2Own.type === "text" ? v2Own.text?.content : void 0;
10368
10453
  const v2Image = slotType === "image" ? v2Own.image : void 0;
10369
10454
  const v2Drawing = v2Own.type === "shape" && v2Own.geometry?.kind === "paths" && !geometryOutline(v2Own.geometry).path ? v2Own.geometry : void 0;
10370
- let rawText = v2Words ? resolveContent(v2Words, self.lang) : v2Image ? imageSrc(v2Image.src, self.lang) : v2Drawing && !isBackground(slot) ? drawingSvg(v2Drawing, drawingLink(v2Own, v2Colors.css)) : v2Own.type === "lottie" ? v2Own.lottie?.src ?? "" : localized.content;
10455
+ let rawText = v2Words ? resolveContent(v2Words, self.lang) : v2Image ? imageSrc(v2Image.src, self.lang) : v2Drawing && !isBackground(slot) ? drawingSvg(v2Drawing, paintedByFillLayer(v2Own) ? {
10456
+ ...drawingLink(v2Own, v2Colors.css),
10457
+ fill: "none"
10458
+ } : drawingLink(v2Own, v2Colors.css)) : v2Own.type === "lottie" ? v2Own.lottie?.src ?? "" : localized.content;
10371
10459
  const isInteractiveSlot = !self.disableActions && (!!v2Own.interactions?.length || !!v2Own.animations?.some((a) => a.on === "hover" || a.on === "press"));
10372
10460
  const isWindowMask = slotType === "mask" && style.maskMode !== "cutout";
10373
10461
  const isArtisticText = slotType === "artistic-text";
@@ -10609,6 +10697,7 @@ var LegacyRenderer = class {
10609
10697
  pauseOnHover: !!v2Scroll.pauseOnHover
10610
10698
  } : void 0;
10611
10699
  let duplicatedForInfinite = false;
10700
+ let loopTrack;
10612
10701
  if (parallaxCfg && parallaxCfg.enabled) {
10613
10702
  const inf = parallaxCfg.infinite || {};
10614
10703
  const speedPxSec = inf.enabled === false || self._isStill() ? 0 : parallaxCfg.speedPxSec !== void 0 ? parallaxCfg.speedPxSec : inf.speedPxSec !== void 0 ? inf.speedPxSec : inf.speed_px_sec !== void 0 ? inf.speed_px_sec : parallaxCfg.mode === "infinite_horizontal" ? parallaxCfg.speed !== void 0 ? parallaxCfg.speed : 20 : 0;
@@ -10624,7 +10713,7 @@ var LegacyRenderer = class {
10624
10713
  if (plan.duplicate) {
10625
10714
  duplicatedForInfinite = true;
10626
10715
  ensureParallaxKeyframes(self.host.shadowRoot);
10627
- const track = document.createElement("div");
10716
+ const track = loopTrack = document.createElement("div");
10628
10717
  track.className = `${TRACK_CLASS} ${LEGACY_TRACK_CLASS}`;
10629
10718
  for (const [k, v] of Object.entries(plan.container)) track.style.setProperty(k, v);
10630
10719
  for (let i = 0; i < plan.copies; i++) {
@@ -10741,7 +10830,7 @@ var LegacyRenderer = class {
10741
10830
  const v2Fill = v2Own.fills?.[0];
10742
10831
  const fillKind = v2Fill && "kind" in v2Fill ? v2Fill.kind : void 0;
10743
10832
  const shapeOutline = geometryOutline(v2Own.type === "shape" ? v2Own.geometry : void 0);
10744
- const isVectorFill = (slotType === "svg" || isSvg) && !isWindowMask && (fillKind === "pattern" || fillKind === "generative");
10833
+ const isVectorFill = (slotType === "svg" || isSvg) && !isWindowMask && (fillKind === "pattern" || fillKind === "generative" || fillKind === "gradient" && !!v2Drawing);
10745
10834
  const fillImageSrc = isGeoLike && !isWindowMask && fillKind === "image" ? String(v2Fill.src || "").trim() : "";
10746
10835
  const imageSrcSafe = !!fillImageSrc && isSandboxImageSrc(fillImageSrc);
10747
10836
  const hasComplexFill = isVectorFill || (slotType === "geo" || slotType === "shape") && !isWindowMask && (imageSrcSafe || fillKind === "gradient" || fillKind === "generative" || fillKind === "pattern" && !isBackgroundSlot);
@@ -10799,7 +10888,13 @@ var LegacyRenderer = class {
10799
10888
  else if (outline.style === "dotted") figure.setAttribute("stroke-dasharray", "2,3");
10800
10889
  }
10801
10890
  svg.appendChild(figure);
10802
- slotEl.appendChild(svg);
10891
+ if (loopTrack) {
10892
+ loopTrack.style.height = "100%";
10893
+ for (const piece of loopTrack.children) {
10894
+ piece.style.cssText += "position:relative;height:100%";
10895
+ piece.append(svg.cloneNode(true));
10896
+ }
10897
+ } else slotEl.append(svg);
10803
10898
  if (imageFill) mountImageFill(slotEl, v2Fill, {
10804
10899
  d: silhouette.d ?? "M " + silhouette.points.split(" ").join(" L ") + " Z",
10805
10900
  viewBox: silhouette.viewBox
@@ -10826,13 +10921,7 @@ var LegacyRenderer = class {
10826
10921
  if (hasComplexFill) {
10827
10922
  const fillLayer = document.createElement("div");
10828
10923
  fillLayer.className = "oim-fill-layer";
10829
- fillLayer.style.position = "absolute";
10830
- fillLayer.style.left = "0";
10831
- fillLayer.style.top = "0";
10832
- fillLayer.style.width = "100%";
10833
- fillLayer.style.height = "100%";
10834
- fillLayer.style.pointerEvents = "none";
10835
- fillLayer.style.borderRadius = "inherit";
10924
+ fillLayer.style.cssText = "position:absolute;inset:0;pointer-events:none;border-radius:inherit";
10836
10925
  const fillCss = {
10837
10926
  ...v2Fill ? paintCss(v2Fill, {
10838
10927
  colors: v2Colors,
@@ -10846,8 +10935,14 @@ var LegacyRenderer = class {
10846
10935
  } : void 0)
10847
10936
  };
10848
10937
  if (isVectorFill && !loopWrap.style.position) loopWrap.style.position = "relative";
10849
- for (const [prop, value] of Object.entries(fillCss)) if (prop.startsWith("--")) fillLayer.style.setProperty(prop, value);
10850
- else fillLayer.style[prop] = value;
10938
+ const moves = fillCss.animation && fillCss.maskImage;
10939
+ const painted = moves ? fillLayer.appendChild(document.createElement("div")) : fillLayer;
10940
+ if (moves) painted.style.cssText = fillLayer.style.cssText;
10941
+ for (const [prop, value] of Object.entries(fillCss)) {
10942
+ const target = moves && /mask/i.test(prop) ? fillLayer : painted;
10943
+ if (prop.startsWith("--")) target.style.setProperty(prop, value);
10944
+ else target.style[prop] = value;
10945
+ }
10851
10946
  slotEl.insertBefore(fillLayer, slotEl.firstChild);
10852
10947
  }
10853
10948
  if (isWindowMask) {