@oim-media/player-oim 1.30.0 → 1.30.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/README.md +5 -5
- package/dist/esm/index.js +81 -10
- package/dist/oim-player.js +12 -35
- package/dist/vendor/oim-generative-788e5348ee7b.js +15 -0
- package/dist/vendor/oim-patterns-788e5348ee7b.js +10 -0
- package/dist/vendor/oim-upgrade-788e5348ee7b.js +1 -0
- package/package.json +4 -4
- package/dist/vendor/oim-upgrade-b492c30b670b.js +0 -1
package/README.md
CHANGED
|
@@ -26,9 +26,9 @@ import "@oim-media/player-oim";
|
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
The second form is also reachable as the subpath `@oim-media/player-oim/cdn`.
|
|
29
|
-
The single file is about **
|
|
30
|
-
in it:
|
|
31
|
-
file under a
|
|
29
|
+
The single file is about **53 KB gzip** and includes the verifier. Lottie, generative fills and pattern tiles are not
|
|
30
|
+
in it: each is loaded from `dist/vendor/`, next to the player, only when a file uses it. A test keeps the
|
|
31
|
+
file under a 55 KB budget.
|
|
32
32
|
|
|
33
33
|
## Usage
|
|
34
34
|
|
|
@@ -211,8 +211,8 @@ from `https://api.oim.media/v1/media/keys`. A page can point that at its own
|
|
|
211
211
|
backend with `window.OIM_PLAYER_CONFIG = { keysUrl: "..." }`, set before the
|
|
212
212
|
player loads. The player never holds a private key.
|
|
213
213
|
|
|
214
|
-
Network use: the `.oim` file itself, the key endpoint when needed, and the Lottie
|
|
215
|
-
|
|
214
|
+
Network use: the `.oim` file itself, the key endpoint when needed, and the optional parts (Lottie, generative fills, pattern tiles)
|
|
215
|
+
from the package's `dist/vendor/` when a file uses them. The player makes
|
|
216
216
|
no analytics requests.
|
|
217
217
|
|
|
218
218
|
A valid signature proves the file has not changed since it was signed. It does not
|
package/dist/esm/index.js
CHANGED
|
@@ -2244,12 +2244,16 @@ function imageSource(slot, value) {
|
|
|
2244
2244
|
modes
|
|
2245
2245
|
} : value;
|
|
2246
2246
|
}
|
|
2247
|
-
function pathsFromLayers(ctx, layers, viewBox) {
|
|
2247
|
+
function pathsFromLayers(ctx, layers, viewBox, original = []) {
|
|
2248
2248
|
const paths = [];
|
|
2249
2249
|
for (const item of layers) {
|
|
2250
2250
|
const part = asObject(item);
|
|
2251
2251
|
if (!part || typeof part.d !== "string" || !part.d) continue;
|
|
2252
2252
|
const entry = { d: part.d };
|
|
2253
|
+
if (part.fill === void 0 && part.stroke === void 0) {
|
|
2254
|
+
const { d: _, ...inherited } = original.find((path) => path.d === part.d) ?? { d: "" };
|
|
2255
|
+
Object.assign(entry, inherited);
|
|
2256
|
+
}
|
|
2253
2257
|
if (typeof part.fill === "string" && part.fill !== "none") entry.fill = part.fill;
|
|
2254
2258
|
if (typeof part.stroke === "string" && part.stroke !== "none") {
|
|
2255
2259
|
entry.stroke = part.stroke;
|
|
@@ -2273,11 +2277,20 @@ function shapeGeometry(ctx, slot, media) {
|
|
|
2273
2277
|
const viewBox = viewBoxOf(ctx.take(style, "svgViewBox"));
|
|
2274
2278
|
const rawXml = ctx.take(style, "svgRawXml");
|
|
2275
2279
|
const layers = ctx.take(style, "svgLayers");
|
|
2280
|
+
const content = drawsMarkup(slot) && typeof media === "string" && /<svg/i.test(media) ? media : void 0;
|
|
2281
|
+
if (content) {
|
|
2282
|
+
const parsed = svgToPaths(content);
|
|
2283
|
+
if (parsed.ok) return {
|
|
2284
|
+
kind: "paths",
|
|
2285
|
+
...parsed.value
|
|
2286
|
+
};
|
|
2287
|
+
}
|
|
2276
2288
|
if (Array.isArray(layers) && layers.length > 0) {
|
|
2277
|
-
const
|
|
2289
|
+
const original = typeof rawXml === "string" && rawXml ? svgToPaths(rawXml) : void 0;
|
|
2290
|
+
const fromLayers = pathsFromLayers(ctx, layers, viewBox, original?.ok ? original.value.paths : []);
|
|
2278
2291
|
if (fromLayers) return fromLayers;
|
|
2279
2292
|
}
|
|
2280
|
-
const xml =
|
|
2293
|
+
const xml = content ?? (typeof rawXml === "string" && rawXml ? rawXml : drawsMarkup(slot) ? media : void 0);
|
|
2281
2294
|
if (xml) {
|
|
2282
2295
|
const parsed = svgToPaths(xml);
|
|
2283
2296
|
if (parsed.ok) return {
|
|
@@ -3580,6 +3593,7 @@ function legacyView(document) {
|
|
|
3580
3593
|
languages: document.languages,
|
|
3581
3594
|
slots
|
|
3582
3595
|
};
|
|
3596
|
+
if (document.canvas.fills?.length) view.canvasFills = document.canvas.fills;
|
|
3583
3597
|
if (document.fonts) view.fonts = document.fonts;
|
|
3584
3598
|
const palettes = palettesOf(document.variables);
|
|
3585
3599
|
if (palettes) view.palettes = palettes;
|
|
@@ -4723,7 +4737,7 @@ function nextWheelZoom(zoom, deltaY, deltaMode, pinch) {
|
|
|
4723
4737
|
* the format can change without the player being touched. Tying both numbers
|
|
4724
4738
|
* together would make an internal fix look like a format break.
|
|
4725
4739
|
*/
|
|
4726
|
-
var CONTRACT_VERSION = "1.30.
|
|
4740
|
+
var CONTRACT_VERSION = "1.30.2";
|
|
4727
4741
|
/**
|
|
4728
4742
|
* What the player implements TODAY, measured and not assumed.
|
|
4729
4743
|
*
|
|
@@ -5284,6 +5298,47 @@ function loadLottie() {
|
|
|
5284
5298
|
return lib && lib.__oimExternal ? lib.load() : lib;
|
|
5285
5299
|
});
|
|
5286
5300
|
}
|
|
5301
|
+
// ../scene/src/legacy/features-entry.ts
|
|
5302
|
+
/**
|
|
5303
|
+
* @license
|
|
5304
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
5305
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5306
|
+
*/
|
|
5307
|
+
/** Resolves when every part in `needs` can be called. Here they already can. */
|
|
5308
|
+
function ensureFeatures(_needs) {
|
|
5309
|
+
return Promise.resolve();
|
|
5310
|
+
}
|
|
5311
|
+
// ../scene/src/legacy/features.ts
|
|
5312
|
+
/**
|
|
5313
|
+
* @license
|
|
5314
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
5315
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5316
|
+
*/
|
|
5317
|
+
var PATTERN_KEY = /^(fill|background)Pattern/;
|
|
5318
|
+
function featuresOf(doc) {
|
|
5319
|
+
const found = {
|
|
5320
|
+
generative: false,
|
|
5321
|
+
patterns: false
|
|
5322
|
+
};
|
|
5323
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5324
|
+
const walk = (v) => {
|
|
5325
|
+
if (!v || typeof v !== "object" || seen.has(v) || found.generative && found.patterns) return;
|
|
5326
|
+
seen.add(v);
|
|
5327
|
+
if (Array.isArray(v)) {
|
|
5328
|
+
v.forEach(walk);
|
|
5329
|
+
return;
|
|
5330
|
+
}
|
|
5331
|
+
const o = v;
|
|
5332
|
+
if (o.kind === "generative" || o.fillType === "generative" || o.fillGenerative) found.generative = true;
|
|
5333
|
+
if (o.kind === "pattern" || o.fillType === "pattern" || "drawing" in o) found.patterns = true;
|
|
5334
|
+
for (const k in o) {
|
|
5335
|
+
if (PATTERN_KEY.test(k) && o[k] != null) found.patterns = true;
|
|
5336
|
+
walk(o[k]);
|
|
5337
|
+
}
|
|
5338
|
+
};
|
|
5339
|
+
walk(doc);
|
|
5340
|
+
return found;
|
|
5341
|
+
}
|
|
5287
5342
|
// ../core/src/geoShapes.ts
|
|
5288
5343
|
/**
|
|
5289
5344
|
* @license
|
|
@@ -9771,11 +9826,16 @@ var LegacyRenderer = class {
|
|
|
9771
9826
|
} else if (existingGrain) existingGrain.remove();
|
|
9772
9827
|
const self = this;
|
|
9773
9828
|
const slots = this.metadata.slots || this.metadata.elements || [];
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9829
|
+
const report = (err) => {
|
|
9830
|
+
const message = String(err?.message ?? err);
|
|
9831
|
+
console.error("[OimPlayer] A part of the player did not load; the work is shown without it.", message);
|
|
9832
|
+
this.host.dispatchEvent(new CustomEvent("oim:error", { detail: {
|
|
9833
|
+
code: "chunk",
|
|
9834
|
+
message
|
|
9835
|
+
} }));
|
|
9836
|
+
};
|
|
9837
|
+
await ensureUpgrade().catch(report);
|
|
9838
|
+
await ensureFeatures(featuresOf([this.metadata, Array.from(v2LayersOf(this.metadata).values())])).catch(report);
|
|
9779
9839
|
const v2Masks = v2LayersOf(self.metadata);
|
|
9780
9840
|
slots.forEach(function(s) {
|
|
9781
9841
|
const v2Mask = s && s.type === "mask" ? v2Masks.get(String(s.id)) : void 0;
|
|
@@ -9837,6 +9897,15 @@ var LegacyRenderer = class {
|
|
|
9837
9897
|
const groupChildren = childrenByGroup(slots);
|
|
9838
9898
|
const v2Layers = v2LayersOf(self.metadata);
|
|
9839
9899
|
const v2Colors = paintColors(self.metadata);
|
|
9900
|
+
const canvasFill = self.metadata.canvasFills?.[0];
|
|
9901
|
+
if (canvasFill && self._overlay && !onlyIds) {
|
|
9902
|
+
const css = paintCss(canvasFill, {
|
|
9903
|
+
colors: v2Colors,
|
|
9904
|
+
width: self.metadata.canvas_width,
|
|
9905
|
+
height: self.metadata.canvas_height
|
|
9906
|
+
});
|
|
9907
|
+
for (const [prop, value] of Object.entries(css)) self._overlay.style[prop] = value;
|
|
9908
|
+
}
|
|
9840
9909
|
const v2Literal = (v) => v && typeof v === "object" && typeof v.fallback === "string" ? v2Colors.literal(v.fallback) : v2Colors.literal(v);
|
|
9841
9910
|
const slotPromises = slots.map(async (slot) => {
|
|
9842
9911
|
const slotType = slot.type;
|
|
@@ -10239,7 +10308,8 @@ var LegacyRenderer = class {
|
|
|
10239
10308
|
const underFill = v2Own.fills?.[1];
|
|
10240
10309
|
const underColor = fillKind === "image" && underFill?.kind === "color" ? v2Colors.css(underFill.value) : void 0;
|
|
10241
10310
|
const resolvedBgColor = fillKind === "color" ? v2Colors.css(v2Fill.value) : imageSrcSafe ? void 0 : underColor;
|
|
10242
|
-
|
|
10311
|
+
const isDrawing = v2Own?.type === "shape" && v2Own.geometry?.kind === "paths";
|
|
10312
|
+
if (resolvedBgColor && isGeoLike && !isWindowMask && slotType !== "text" && !isArtisticText && !hasComplexFill && !isDrawing) slotEl.style.setProperty("background-color", resolvedBgColor);
|
|
10243
10313
|
const hasVector = slotType === "svg" || isSvg || v2Own.geometry?.kind === "paths" || isGeoLike && !!shapeOutline.silhouette;
|
|
10244
10314
|
const v2Layer = v2Layers.get(String(slot.id));
|
|
10245
10315
|
const v2Stroke = v2Layer?.strokes?.find((s) => !s.align && "kind" in s.paint && s.paint.kind === "color" && typeof s.width === "number");
|
|
@@ -10361,6 +10431,7 @@ var LegacyRenderer = class {
|
|
|
10361
10431
|
transformX = duplicatedForInfinite || textAlign === "left" ? "0%" : textAlign === "right" ? "-100%" : "-50%";
|
|
10362
10432
|
const share = transformX === "0%" ? 0 : transformX === "-100%" ? 1 : .5;
|
|
10363
10433
|
slotEl.style.left = (box.x + box.width * share).toFixed(2) + "px";
|
|
10434
|
+
if (share > 0 && paintsText && !isArtisticText) slotEl.style.left = `calc(${slotEl.style.left} + ${.25 * share}em)`;
|
|
10364
10435
|
slotEl.style.top = (box.y + box.height / 2).toFixed(2) + "px";
|
|
10365
10436
|
} else {
|
|
10366
10437
|
[transformX, transformY] = anchorShift(box);
|