@oim-media/core 1.27.11 → 1.28.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/README.md +1 -1
- package/dist/compatibility.d.ts +1 -1
- package/dist/compatibility.js +3 -1
- package/dist/v2/base-layer.d.ts +13 -0
- package/dist/v2/base-layer.js +16 -0
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/index.js +1 -0
- package/dist/v2/resources.d.ts +11 -0
- package/dist/v2/resources.js +42 -0
- package/dist/v2/upgrade/geometry.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ URLs only) and `@oim-media/core/generative` and `@oim-media/core/generative/cata
|
|
|
26
26
|
|
|
27
27
|
- `OimMetadataSchema`, `OvmMetadataSchema`, `OIMOrOVMMetadata`: Zod schemas of the
|
|
28
28
|
metadata. Types `OIMMetadata`, `OVMMetadata`, `Slot`, `TextMark`, `Reveal`, ...
|
|
29
|
-
- `CONTRACT_VERSION`: the contract version this build implements (`"1.
|
|
29
|
+
- `CONTRACT_VERSION`: the contract version this build implements (`"1.28.0"`).
|
|
30
30
|
- `BASE_CONTRACT_VERSION`, `PLAYER_CAPABILITIES`, `VERSION_BY_CAPABILITY`, `minVersionFor`.
|
|
31
31
|
- `MAX_SLOTS`, `MAX_MARKS`, `MARK_NAME`, `PALETTE_NAME_PATTERN`, `CSS_GRADIENT_PATTERN`.
|
|
32
32
|
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* the format can change without the player being touched. Tying both numbers
|
|
42
42
|
* together would make an internal fix look like a format break.
|
|
43
43
|
*/
|
|
44
|
-
export declare const CONTRACT_VERSION = "1.
|
|
44
|
+
export declare const CONTRACT_VERSION = "1.28.0";
|
|
45
45
|
/**
|
|
46
46
|
* The first version of the format. Whatever requires nothing more requires this.
|
|
47
47
|
*
|
package/dist/compatibility.js
CHANGED
|
@@ -41,7 +41,9 @@
|
|
|
41
41
|
* the format can change without the player being touched. Tying both numbers
|
|
42
42
|
* together would make an internal fix look like a format break.
|
|
43
43
|
*/
|
|
44
|
-
export const CONTRACT_VERSION = "1.
|
|
44
|
+
export const CONTRACT_VERSION = "1.28.0";
|
|
45
|
+
// 1.28.0: the player reads 2.0 files and has a poster attribute; 2.0 conformance vectors ship in @oim-media/spec.
|
|
46
|
+
// 1.28.0: an SVG layer upgrades from its content, not svgRawXml; no format change.
|
|
45
47
|
// 1.27.11: fixes to the 2.0 upgrade (corner shorthand, hollow text, SVG icons, colour under a photo); no format change.
|
|
46
48
|
// 1.27.10: no format change; the player paints from 2.0 and a zone is a group without its flow.
|
|
47
49
|
// 1.27.9: numbers beyond +/-(2^53 - 1) have no canonical form; the Rust crate parses decimals exactly.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Layer } from "./schema.js";
|
|
7
|
+
/**
|
|
8
|
+
* True when some image layer, nested ones included, shows the file's own picture (`oim:base`),
|
|
9
|
+
* in its principal picture or in any language. Such a document's PNG is its base, not a poster.
|
|
10
|
+
*/
|
|
11
|
+
export declare function hasBaseLayer(document: {
|
|
12
|
+
layers: Layer[];
|
|
13
|
+
}): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/** The picture of the file itself: the player shows its base PNG, so an image layer never repaints it. */
|
|
7
|
+
const BASE = "oim:base";
|
|
8
|
+
/**
|
|
9
|
+
* True when some image layer, nested ones included, shows the file's own picture (`oim:base`),
|
|
10
|
+
* in its principal picture or in any language. Such a document's PNG is its base, not a poster.
|
|
11
|
+
*/
|
|
12
|
+
export function hasBaseLayer(document) {
|
|
13
|
+
const shows = (src) => typeof src === "string" ? src === BASE : src.value === BASE || Object.values(src.modes ?? {}).includes(BASE);
|
|
14
|
+
const walk = (layers) => layers.some((layer) => (layer.image !== undefined && shows(layer.image.src)) || walk(layer.children ?? []));
|
|
15
|
+
return walk(document.layers);
|
|
16
|
+
}
|
package/dist/v2/index.d.ts
CHANGED
package/dist/v2/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { OimDocument } from "./schema.js";
|
|
7
|
+
/** A copy of the document with every `{ ref }` paint replaced by its resource. */
|
|
8
|
+
export declare function resolveRefs(document: OimDocument): {
|
|
9
|
+
document: OimDocument;
|
|
10
|
+
missing: string[];
|
|
11
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
// Paints live in three places: `canvas.fills`, each layer's `fills`, and each
|
|
7
|
+
// stroke's `paint`. A `{ ref }` in any of them points at `document.resources`.
|
|
8
|
+
// A stroke whose ref is missing is dropped, since a stroke has no paint without it.
|
|
9
|
+
/** A copy of the document with every `{ ref }` paint replaced by its resource. */
|
|
10
|
+
export function resolveRefs(document) {
|
|
11
|
+
const out = structuredClone(document);
|
|
12
|
+
const missing = [];
|
|
13
|
+
const resources = document.resources ?? {};
|
|
14
|
+
const one = (paint) => {
|
|
15
|
+
if (!("ref" in paint))
|
|
16
|
+
return paint;
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(resources, paint.ref))
|
|
18
|
+
return structuredClone(resources[paint.ref]);
|
|
19
|
+
if (!missing.includes(paint.ref))
|
|
20
|
+
missing.push(paint.ref);
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
|
23
|
+
const list = (paints) => paints.flatMap((paint) => one(paint) ?? []);
|
|
24
|
+
const walk = (layers) => {
|
|
25
|
+
for (const layer of layers) {
|
|
26
|
+
if (layer.fills)
|
|
27
|
+
layer.fills = list(layer.fills);
|
|
28
|
+
if (layer.strokes) {
|
|
29
|
+
layer.strokes = layer.strokes.flatMap((stroke) => {
|
|
30
|
+
const paint = one(stroke.paint);
|
|
31
|
+
return paint ? [{ ...stroke, paint }] : [];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (layer.children)
|
|
35
|
+
walk(layer.children);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
if (out.canvas.fills)
|
|
39
|
+
out.canvas.fills = list(out.canvas.fills);
|
|
40
|
+
walk(out.layers);
|
|
41
|
+
return { document: out, missing };
|
|
42
|
+
}
|
|
@@ -78,7 +78,9 @@ function shapeGeometry(ctx, slot, media) {
|
|
|
78
78
|
if (fromLayers)
|
|
79
79
|
return fromLayers;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
// 1.x painted the content of a markup layer; svgRawXml is the untouched original it was edited from.
|
|
82
|
+
const content = drawsMarkup(slot) && typeof media === "string" && /<svg/i.test(media) ? media : undefined;
|
|
83
|
+
const xml = content ?? (typeof rawXml === "string" && rawXml ? rawXml : drawsMarkup(slot) ? media : undefined);
|
|
82
84
|
if (xml) {
|
|
83
85
|
const parsed = svgToPaths(xml);
|
|
84
86
|
if (parsed.ok)
|
package/package.json
CHANGED