@oim-media/core 1.30.1 → 1.31.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 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.30.1"`).
29
+ - `CONTRACT_VERSION`: the contract version this build implements (`"1.31.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
 
@@ -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.30.1";
44
+ export declare const CONTRACT_VERSION = "1.31.0";
45
45
  /**
46
46
  * The first version of the format. Whatever requires nothing more requires this.
47
47
  *
@@ -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.30.1";
44
+ export const CONTRACT_VERSION = "1.31.0";
45
+ // 1.31.0: no format change; the 2.0 scene painter paints blur, shadow, glow and backdrop effects.
46
+ // 1.30.2: no format change; 2.0 canvas colour, drawings and icon paint, and text centred on its box despite the italic room.
45
47
  // 1.30.1: no format change; the CDN player loads generative fills and pattern tiles on demand.
46
48
  // 1.30.0: OIM_Seal, a signed poster seal after the image, before the metadata; readers that do not know it ignore it.
47
49
  // 1.29.1: the 1.x to 2.0 upgrade retires the editor-only textRole field; no format change.
@@ -42,13 +42,18 @@ function imageSource(slot, value) {
42
42
  modes[language] = own;
43
43
  return Object.keys(modes).length > 0 ? { value, modes } : value;
44
44
  }
45
- function pathsFromLayers(ctx, layers, viewBox) {
45
+ function pathsFromLayers(ctx, layers, viewBox, original = []) {
46
46
  const paths = [];
47
47
  for (const item of layers) {
48
48
  const part = asObject(item);
49
49
  if (!part || typeof part.d !== "string" || !part.d)
50
50
  continue;
51
51
  const entry = { d: part.d };
52
+ // The editor's layers keep only what was set on each path; paint inherited from <svg> lives in the original.
53
+ if (part.fill === undefined && part.stroke === undefined) {
54
+ const { d: _, ...inherited } = original.find((path) => path.d === part.d) ?? { d: "" };
55
+ Object.assign(entry, inherited);
56
+ }
52
57
  if (typeof part.fill === "string" && part.fill !== "none")
53
58
  entry.fill = part.fill;
54
59
  if (typeof part.stroke === "string" && part.stroke !== "none") {
@@ -72,14 +77,21 @@ function shapeGeometry(ctx, slot, media) {
72
77
  const viewBox = viewBoxOf(ctx.take(style, "svgViewBox"));
73
78
  const rawXml = ctx.take(style, "svgRawXml");
74
79
  const layers = ctx.take(style, "svgLayers");
75
- // The decomposed layers carry the colours the author edited; the raw XML is the original.
80
+ // 1.x painted the content of a markup layer; svgRawXml is the untouched original it was edited from.
81
+ const content = drawsMarkup(slot) && typeof media === "string" && /<svg/i.test(media) ? media : undefined;
82
+ // The editor writes every colour, its per-layer ones included, into that content.
83
+ if (content) {
84
+ const parsed = svgToPaths(content);
85
+ if (parsed.ok)
86
+ return { kind: "paths", ...parsed.value };
87
+ }
88
+ // Without content, the decomposed layers carry the colours the author edited; the raw XML is the original.
76
89
  if (Array.isArray(layers) && layers.length > 0) {
77
- const fromLayers = pathsFromLayers(ctx, layers, viewBox);
90
+ const original = typeof rawXml === "string" && rawXml ? svgToPaths(rawXml) : undefined;
91
+ const fromLayers = pathsFromLayers(ctx, layers, viewBox, original?.ok ? original.value.paths : []);
78
92
  if (fromLayers)
79
93
  return fromLayers;
80
94
  }
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
95
  const xml = content ?? (typeof rawXml === "string" && rawXml ? rawXml : drawsMarkup(slot) ? media : undefined);
84
96
  if (xml) {
85
97
  const parsed = svgToPaths(xml);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oim-media/core",
3
- "version": "1.30.1",
3
+ "version": "1.31.0",
4
4
  "description": "Core of the OIM format: the contract schema, binary extraction from PNG and the shared rendering logic used by every OIM player.",
5
5
  "keywords": [
6
6
  "oim",