@oim-media/core 1.27.10 → 1.27.11
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/upgrade/geometry.js +10 -4
- package/dist/v2/upgrade/paints.js +9 -3
- 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.27.
|
|
29
|
+
- `CONTRACT_VERSION`: the contract version this build implements (`"1.27.11"`).
|
|
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.27.
|
|
44
|
+
export declare const CONTRACT_VERSION = "1.27.11";
|
|
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.27.
|
|
44
|
+
export const CONTRACT_VERSION = "1.27.11";
|
|
45
|
+
// 1.27.11: fixes to the 2.0 upgrade (corner shorthand, hollow text, SVG icons, colour under a photo); no format change.
|
|
45
46
|
// 1.27.10: no format change; the player paints from 2.0 and a zone is a group without its flow.
|
|
46
47
|
// 1.27.9: numbers beyond +/-(2^53 - 1) have no canonical form; the Rust crate parses decimals exactly.
|
|
47
48
|
// 1.27.8: Flutter stroke and effects scale with the canvas; packages on npm, pub.dev and crates.io.
|
|
@@ -104,11 +104,17 @@ const CORNER_KEYS = [
|
|
|
104
104
|
["borderRadiusBR", "borderBottomRightRadius"],
|
|
105
105
|
["borderRadiusBL", "borderBottomLeftRadius"],
|
|
106
106
|
];
|
|
107
|
+
// The CSS shorthand order: one value for all, two for TL/BR and TR/BL, three for TL, TR/BL, BR.
|
|
108
|
+
const SHORTHAND = [[0, 0, 0, 0], [0, 1, 0, 1], [0, 1, 2, 1], [0, 1, 2, 3]];
|
|
107
109
|
function cornersOf(ctx, style) {
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
const W = ctx.canvas.width;
|
|
111
|
+
const raw = ctx.take(style, "borderRadius");
|
|
112
|
+
const tokens = typeof raw === "string" ? raw.trim().split(/\s+/) : [];
|
|
113
|
+
const shorthand = tokens.length > 1 && tokens.length <= 4 ? SHORTHAND[tokens.length - 1].map((i) => toCanvasUnits(tokens[i], W)) : [];
|
|
114
|
+
const all = tokens.length > 1 ? 0 : (toCanvasUnits(raw, W) ?? 0);
|
|
115
|
+
const each = CORNER_KEYS.map((keys, corner) => {
|
|
116
|
+
const values = keys.map((key) => toCanvasUnits(ctx.take(style, key), W));
|
|
117
|
+
return values.find((v) => v !== undefined) ?? shorthand[corner];
|
|
112
118
|
});
|
|
113
119
|
if (each.some((v) => v !== undefined)) {
|
|
114
120
|
const four = each.map((v) => Math.max(0, v ?? all));
|
|
@@ -24,7 +24,7 @@ export function colorOf(ctx, owner, key, roleKey) {
|
|
|
24
24
|
}
|
|
25
25
|
const numbers = (value) => Array.isArray(value) && value.length > 0 && value.every((n) => typeof n === "number") ? value : undefined;
|
|
26
26
|
/** The pattern fields that share a prefix: `fillPattern*` on a layer, `backgroundPattern*` on a layer or the canvas. */
|
|
27
|
-
function patternOf(ctx, owner, prefix, cssAnimation) {
|
|
27
|
+
function patternOf(ctx, owner, prefix, cssAnimation, canvasBackground = false) {
|
|
28
28
|
const preset = ctx.take(owner, `${prefix}Type`);
|
|
29
29
|
const single = colorOf(ctx, owner, `${prefix}Color`, `${prefix}ColorRole`);
|
|
30
30
|
const bg = colorOf(ctx, owner, `${prefix}BgColor`, `${prefix}BgColorRole`);
|
|
@@ -39,7 +39,8 @@ function patternOf(ctx, owner, prefix, cssAnimation) {
|
|
|
39
39
|
const dispersions = numbers(ctx.take(owner, `${prefix}Dispersions`)) ?? numbers(ctx.take(owner, `${prefix}Dispersion`));
|
|
40
40
|
const colors = Array.isArray(list) ? list.filter(isColor) : [];
|
|
41
41
|
// A raw SVG tile carries no preset: only the colours it is recoloured with, its fit and its motion.
|
|
42
|
-
|
|
42
|
+
// Only the canvas background tiles its raw SVG; any other SVG layer is a drawing.
|
|
43
|
+
const tile = canvasBackground && prefix === "backgroundPattern" && typeof owner.svgRawXml === "string" && owner.svgRawXml !== "";
|
|
43
44
|
if ((typeof preset !== "string" || !preset) && !tile && single === undefined && bg === undefined && colors.length === 0)
|
|
44
45
|
return undefined;
|
|
45
46
|
const pattern = typeof preset === "string" && preset ? { preset } : {};
|
|
@@ -118,7 +119,8 @@ function fillOf(ctx, slot) {
|
|
|
118
119
|
const image = imageOf(ctx, style);
|
|
119
120
|
const cssAnimation = style.cssAnimation;
|
|
120
121
|
const fillPattern = patternOf(ctx, style, "fillPattern", cssAnimation);
|
|
121
|
-
const
|
|
122
|
+
const canvasBackground = slot.raw.is_background_pattern === true || slot.raw.id === "background-pattern-slot";
|
|
123
|
+
const backgroundPattern = patternOf(ctx, style, "backgroundPattern", cssAnimation, canvasBackground);
|
|
122
124
|
const generative = asObject(ctx.take(style, "fillGenerative")) ?? asObject(ctx.take(style, "backgroundGenerative"));
|
|
123
125
|
const backgroundFit = ctx.take(style, "backgroundFit");
|
|
124
126
|
const textGradient = ctx.take(style, "textGradientType");
|
|
@@ -169,6 +171,8 @@ function textStrokeOf(ctx, style) {
|
|
|
169
171
|
}
|
|
170
172
|
export function convertPaints(ctx, slot, layer) {
|
|
171
173
|
const { style } = slot;
|
|
174
|
+
// A text whose letter 1.x left transparent (only its stroke shows): no fill would paint it black.
|
|
175
|
+
const hollowText = layer.type === "text" && style.fillColor === "transparent" && (style.fillType === undefined || style.fillType === "solid" || style.fillType === "color");
|
|
172
176
|
const fills = fillOf(ctx, slot);
|
|
173
177
|
const fill = Array.isArray(fills) ? fills[0] : fills;
|
|
174
178
|
// 1.x painted no colour inside a custom path (only a photo, a gradient or a
|
|
@@ -178,6 +182,8 @@ export function convertPaints(ctx, slot, layer) {
|
|
|
178
182
|
const colourless = slot.type === "geo" && (customPath || shape === "scribble") && !!fill && "kind" in fill && fill.kind === "color";
|
|
179
183
|
if (fill && !colourless && admits(layer.type, "fills"))
|
|
180
184
|
layer.fills = Array.isArray(fills) ? fills : [fill];
|
|
185
|
+
else if (hollowText)
|
|
186
|
+
layer.fills = [{ kind: "color", value: "transparent" }];
|
|
181
187
|
const strokeStyle = ctx.take(style, "strokeStyle");
|
|
182
188
|
const dashed = strokeStyle === "dashed" || strokeStyle === "dotted" ? { style: strokeStyle } : {};
|
|
183
189
|
// 1.x passed borderColor and borderWidth to CSS without a border-style, so
|
package/package.json
CHANGED