@oim-media/core 1.28.0 → 1.29.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 +4 -3
- package/dist/v2/base-layer.d.ts +2 -1
- package/dist/v2/base-layer.js +10 -1
- package/dist/v2/resources.js +13 -0
- package/dist/v2/schema.d.ts +2 -0
- package/dist/v2/schema.js +7 -2
- 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.29.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.29.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,9 +41,10 @@
|
|
|
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.
|
|
45
|
-
// 1.
|
|
46
|
-
// 1.
|
|
44
|
+
export const CONTRACT_VERSION = "1.29.0";
|
|
45
|
+
// 1.29.0: a 2.0 image src can be { ref } to a resources entry of kind image.
|
|
46
|
+
// 1.29.0: the player reads 2.0 files and has a poster attribute; 2.0 conformance vectors ship in @oim-media/spec.
|
|
47
|
+
// 1.29.0: an SVG layer upgrades from its content, not svgRawXml; no format change.
|
|
47
48
|
// 1.27.11: fixes to the 2.0 upgrade (corner shorthand, hollow text, SVG icons, colour under a photo); no format change.
|
|
48
49
|
// 1.27.10: no format change; the player paints from 2.0 and a zone is a group without its flow.
|
|
49
50
|
// 1.27.9: numbers beyond +/-(2^53 - 1) have no canonical form; the Rust crate parses decimals exactly.
|
package/dist/v2/base-layer.d.ts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* Copyright (c) 2026 Xue Studios LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import type { Layer } from "./schema.js";
|
|
6
|
+
import type { Layer, Paint } from "./schema.js";
|
|
7
7
|
/**
|
|
8
8
|
* True when some image layer, nested ones included, shows the file's own picture (`oim:base`),
|
|
9
9
|
* in its principal picture or in any language. Such a document's PNG is its base, not a poster.
|
|
10
10
|
*/
|
|
11
11
|
export declare function hasBaseLayer(document: {
|
|
12
12
|
layers: Layer[];
|
|
13
|
+
resources?: Record<string, Paint>;
|
|
13
14
|
}): boolean;
|
package/dist/v2/base-layer.js
CHANGED
|
@@ -10,7 +10,16 @@ const BASE = "oim:base";
|
|
|
10
10
|
* in its principal picture or in any language. Such a document's PNG is its base, not a poster.
|
|
11
11
|
*/
|
|
12
12
|
export function hasBaseLayer(document) {
|
|
13
|
-
|
|
13
|
+
// A `{ ref }` is read through the resource it names, as resolveRefs would read it.
|
|
14
|
+
const shows = (src) => {
|
|
15
|
+
if (typeof src === "string")
|
|
16
|
+
return src === BASE;
|
|
17
|
+
if ("ref" in src) {
|
|
18
|
+
const paint = document.resources?.[src.ref];
|
|
19
|
+
return paint !== undefined && "kind" in paint && paint.kind === "image" && paint.src === BASE;
|
|
20
|
+
}
|
|
21
|
+
return src.value === BASE || Object.values(src.modes ?? {}).includes(BASE);
|
|
22
|
+
};
|
|
14
23
|
const walk = (layers) => layers.some((layer) => (layer.image !== undefined && shows(layer.image.src)) || walk(layer.children ?? []));
|
|
15
24
|
return walk(document.layers);
|
|
16
25
|
}
|
package/dist/v2/resources.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// Paints live in three places: `canvas.fills`, each layer's `fills`, and each
|
|
7
7
|
// stroke's `paint`. A `{ ref }` in any of them points at `document.resources`.
|
|
8
8
|
// A stroke whose ref is missing is dropped, since a stroke has no paint without it.
|
|
9
|
+
// An image layer's `src` may be a `{ ref }` to an image paint; if that is missing or
|
|
10
|
+
// not an image, the layer loses its `image` block rather than keeping a dead source.
|
|
9
11
|
/** A copy of the document with every `{ ref }` paint replaced by its resource. */
|
|
10
12
|
export function resolveRefs(document) {
|
|
11
13
|
const out = structuredClone(document);
|
|
@@ -31,6 +33,17 @@ export function resolveRefs(document) {
|
|
|
31
33
|
return paint ? [{ ...stroke, paint }] : [];
|
|
32
34
|
});
|
|
33
35
|
}
|
|
36
|
+
if (layer.image && typeof layer.image.src === "object" && "ref" in layer.image.src) {
|
|
37
|
+
const src = layer.image.src;
|
|
38
|
+
const resource = Object.prototype.hasOwnProperty.call(resources, src.ref) ? resources[src.ref] : undefined;
|
|
39
|
+
if (resource && "kind" in resource && resource.kind === "image")
|
|
40
|
+
layer.image = { ...layer.image, src: resource.src };
|
|
41
|
+
else {
|
|
42
|
+
delete layer.image;
|
|
43
|
+
if (!missing.includes(src.ref))
|
|
44
|
+
missing.push(src.ref);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
34
47
|
if (layer.children)
|
|
35
48
|
walk(layer.children);
|
|
36
49
|
}
|
package/dist/v2/schema.d.ts
CHANGED
|
@@ -670,6 +670,8 @@ export declare const imageSchema: z.ZodObject<{
|
|
|
670
670
|
src: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
671
671
|
value: z.ZodString;
|
|
672
672
|
modes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
673
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
674
|
+
ref: z.ZodString;
|
|
673
675
|
}, z.core.$strict>]>;
|
|
674
676
|
fit: z.ZodOptional<z.ZodEnum<{
|
|
675
677
|
cover: "cover";
|
package/dist/v2/schema.js
CHANGED
|
@@ -232,8 +232,13 @@ const corners = z.union([z.number().min(0), z.array(z.number().min(0)).length(4)
|
|
|
232
232
|
export const imageSchema = z
|
|
233
233
|
.object({
|
|
234
234
|
// "oim:base" is the PNG of the file itself. A language can have its own
|
|
235
|
-
// picture; an empty one means that language shows none.
|
|
236
|
-
|
|
235
|
+
// picture; an empty one means that language shows none. A `{ ref }` names an
|
|
236
|
+
// image paint in `document.resources` (resolved by resolveRefs).
|
|
237
|
+
src: z.union([
|
|
238
|
+
z.string().min(1),
|
|
239
|
+
z.object({ value: z.string().min(1), modes: z.record(z.string(), z.string()) }).strict(),
|
|
240
|
+
z.object({ ref: id }).strict(),
|
|
241
|
+
]),
|
|
237
242
|
fit: fit.optional(),
|
|
238
243
|
crop: crop.optional(),
|
|
239
244
|
filters: imageFiltersSchema.optional(),
|
package/package.json
CHANGED