@oim-media/core 1.29.0 → 1.29.1
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 +2 -1
- package/dist/v2/colors.d.ts +19 -0
- package/dist/v2/colors.js +37 -0
- package/dist/v2/index.d.ts +4 -0
- package/dist/v2/index.js +5 -0
- package/dist/v2/typography.d.ts +12 -0
- package/dist/v2/typography.js +46 -0
- package/dist/v2/upgrade/text.js +2 -0
- 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.
|
|
29
|
+
- `CONTRACT_VERSION`: the contract version this build implements (`"1.29.1"`).
|
|
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.29.
|
|
44
|
+
export declare const CONTRACT_VERSION = "1.29.1";
|
|
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,8 @@
|
|
|
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.29.
|
|
44
|
+
export const CONTRACT_VERSION = "1.29.1";
|
|
45
|
+
// 1.29.1: the 1.x to 2.0 upgrade retires the editor-only textRole field; no format change.
|
|
45
46
|
// 1.29.0: a 2.0 image src can be { ref } to a resources entry of kind image.
|
|
46
47
|
// 1.29.0: the player reads 2.0 files and has a poster attribute; 2.0 conformance vectors ship in @oim-media/spec.
|
|
47
48
|
// 1.29.0: an SVG layer upgrades from its content, not svgRawXml; no format change.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { PaintColors } from "./paint-css.js";
|
|
7
|
+
import type { Variables } from "./schema.js";
|
|
8
|
+
export type PaletteMetadata = {
|
|
9
|
+
palettes?: Record<string, Record<string, string>>;
|
|
10
|
+
defaultPalette?: string;
|
|
11
|
+
};
|
|
12
|
+
/** The named palettes of a document, read back from its variables: one role → colour map per palette name. */
|
|
13
|
+
export declare function palettesOf(variables: Variables | undefined): Record<string, Record<string, string>> | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* How a renderer paints a 2.0 colour: a palette binding stays a `var()` so a
|
|
16
|
+
* mode change needs no repaint; drawn-in paints (patterns) take the default
|
|
17
|
+
* palette's value, since an image cannot hold a `var()`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function paintColors(metadata: PaletteMetadata): PaintColors;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
// How a 2.0 colour becomes paint: the palette a document's variables name, and
|
|
7
|
+
// the CSS a renderer writes for a colour. One copy, read by the scene and by the
|
|
8
|
+
// 1.x renderer's bridge, so both pick the same colour for the same palette.
|
|
9
|
+
import { resolveCssColor, resolvePalette } from "../dynamic-colors.js";
|
|
10
|
+
/** The named palettes of a document, read back from its variables: one role → colour map per palette name. */
|
|
11
|
+
export function palettesOf(variables) {
|
|
12
|
+
const names = variables?.modes?.palette;
|
|
13
|
+
if (!variables || !names)
|
|
14
|
+
return undefined;
|
|
15
|
+
const palettes = Object.fromEntries(names.map((name) => [name, {}]));
|
|
16
|
+
for (const [role, byPalette] of Object.entries(variables.values ?? {})) {
|
|
17
|
+
for (const [name, color] of Object.entries(byPalette)) {
|
|
18
|
+
if (palettes[name] && typeof color === "string")
|
|
19
|
+
palettes[name][role] = color;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return palettes;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* How a renderer paints a 2.0 colour: a palette binding stays a `var()` so a
|
|
26
|
+
* mode change needs no repaint; drawn-in paints (patterns) take the default
|
|
27
|
+
* palette's value, since an image cannot hold a `var()`.
|
|
28
|
+
*/
|
|
29
|
+
export function paintColors(metadata) {
|
|
30
|
+
const isVar = (v) => !!v && typeof v === "object" && typeof v.var === "string";
|
|
31
|
+
return {
|
|
32
|
+
css: (v) => (isVar(v) ? resolveCssColor(v.var, v.fallback) : typeof v === "string" ? resolveCssColor(null, v) : "") || undefined,
|
|
33
|
+
literal: (v) => (isVar(v)
|
|
34
|
+
? resolvePalette(metadata)?.colors?.[v.var] ?? resolveCssColor(null, v.fallback)
|
|
35
|
+
: typeof v === "string" ? resolveCssColor(null, v) : "") || undefined,
|
|
36
|
+
};
|
|
37
|
+
}
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -9,3 +9,7 @@ export * from "./upgrade.js";
|
|
|
9
9
|
export type { UpgradeContext } from "./upgrade/context.js";
|
|
10
10
|
export * from "./paint-css.js";
|
|
11
11
|
export * from "./resources.js";
|
|
12
|
+
export * from "./geometry-outline.js";
|
|
13
|
+
export * from "./base-layer.js";
|
|
14
|
+
export * from "./colors.js";
|
|
15
|
+
export * from "./typography.js";
|
package/dist/v2/index.js
CHANGED
|
@@ -10,3 +10,8 @@ export * from "./schema.js";
|
|
|
10
10
|
export * from "./upgrade.js";
|
|
11
11
|
export * from "./paint-css.js";
|
|
12
12
|
export * from "./resources.js";
|
|
13
|
+
// The shared outline of a shape and the test for a document that shows its base picture.
|
|
14
|
+
export * from "./geometry-outline.js";
|
|
15
|
+
export * from "./base-layer.js";
|
|
16
|
+
export * from "./colors.js";
|
|
17
|
+
export * from "./typography.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
* The CSS typography of a 2.0 text, for one language. Lengths are canvas units,
|
|
9
|
+
* which the overlay paints 1:1 as px. Absent fields are absent: the caller
|
|
10
|
+
* keeps its defaults.
|
|
11
|
+
*/
|
|
12
|
+
export declare function typographyCss(layer: Pick<Layer, "text"> | undefined, lang: string): Record<string, string> | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2026 Xue Studios LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/** A 2.0 scalar resolved for one language: its exception for that mode, else its value. */
|
|
7
|
+
function forLanguage(value, lang) {
|
|
8
|
+
if (typeof value === 'number')
|
|
9
|
+
return value;
|
|
10
|
+
if (value && typeof value === 'object' && 'value' in value) {
|
|
11
|
+
const { value: base, modes } = value;
|
|
12
|
+
const own = modes?.[lang];
|
|
13
|
+
return typeof own === 'number' ? own : typeof base === 'number' ? base : undefined;
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The CSS typography of a 2.0 text, for one language. Lengths are canvas units,
|
|
19
|
+
* which the overlay paints 1:1 as px. Absent fields are absent: the caller
|
|
20
|
+
* keeps its defaults.
|
|
21
|
+
*/
|
|
22
|
+
export function typographyCss(layer, lang) {
|
|
23
|
+
const text = layer?.text;
|
|
24
|
+
if (!text)
|
|
25
|
+
return undefined;
|
|
26
|
+
const css = {};
|
|
27
|
+
const size = forLanguage(text.font?.size, lang);
|
|
28
|
+
if (size !== undefined)
|
|
29
|
+
css.fontSize = `${+size.toFixed(4)}px`;
|
|
30
|
+
const maxWidth = forLanguage(text.maxWidth, lang);
|
|
31
|
+
if (maxWidth !== undefined)
|
|
32
|
+
css.maxWidth = `${+maxWidth.toFixed(4)}px`;
|
|
33
|
+
if (text.font?.family)
|
|
34
|
+
css.fontFamily = text.font.family;
|
|
35
|
+
if (text.font?.weight !== undefined)
|
|
36
|
+
css.fontWeight = String(text.font.weight);
|
|
37
|
+
if (text.font?.italic)
|
|
38
|
+
css.fontStyle = 'italic';
|
|
39
|
+
if (text.letterSpacing !== undefined)
|
|
40
|
+
css.letterSpacing = `${text.letterSpacing}px`;
|
|
41
|
+
if (text.transform)
|
|
42
|
+
css.textTransform = text.transform;
|
|
43
|
+
if (text.decoration)
|
|
44
|
+
css.textDecoration = text.decoration;
|
|
45
|
+
return css;
|
|
46
|
+
}
|
package/dist/v2/upgrade/text.js
CHANGED
|
@@ -32,6 +32,8 @@ const TYPOGRAPHY_KEYS = [
|
|
|
32
32
|
];
|
|
33
33
|
export function convertText(ctx, slot, layer) {
|
|
34
34
|
const { raw, style } = slot;
|
|
35
|
+
// The editor's hierarchy buttons; no player read it, on any layer type.
|
|
36
|
+
ctx.retire(style, "textRole");
|
|
35
37
|
const align = ctx.take(style, "textAlign") ?? ctx.take(raw, "align");
|
|
36
38
|
ctx.take(raw, "align");
|
|
37
39
|
if (layer.type !== "text") {
|
package/package.json
CHANGED