@pixi-ui-editor/schema 0.18.0 → 0.20.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.
@@ -1 +1 @@
1
- {"version":3,"file":"nodeReferences.d.ts","sourceRoot":"","sources":["../src/nodeReferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAkB,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzD,mGAAmG;AACnG,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAe5E;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAiCxF;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,qBAAqB,GAAG,IAAI,CA6BxH"}
1
+ {"version":3,"file":"nodeReferences.d.ts","sourceRoot":"","sources":["../src/nodeReferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAkB,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzD,mGAAmG;AACnG,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAe5E;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAoCxF;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,qBAAqB,GAAG,IAAI,CA6BxH"}
@@ -29,6 +29,7 @@ export function rewriteNodeReferences(node, rewrite) {
29
29
  if (node.type === "pagination") {
30
30
  const prevButtonNodeId = rewriteAddress(node.prevButtonNodeId, rewrite);
31
31
  const nextButtonNodeId = rewriteAddress(node.nextButtonNodeId, rewrite);
32
+ const activeBackgroundNodeId = rewriteAddress(node.activeBackgroundNodeId, rewrite);
32
33
  if (prevButtonNodeId === undefined)
33
34
  delete node.prevButtonNodeId;
34
35
  else
@@ -37,6 +38,10 @@ export function rewriteNodeReferences(node, rewrite) {
37
38
  delete node.nextButtonNodeId;
38
39
  else
39
40
  node.nextButtonNodeId = nextButtonNodeId;
41
+ if (activeBackgroundNodeId === undefined)
42
+ delete node.activeBackgroundNodeId;
43
+ else
44
+ node.activeBackgroundNodeId = activeBackgroundNodeId;
40
45
  return;
41
46
  }
42
47
  if (node.type === "page-group") {
@@ -85,7 +90,7 @@ export function rewritePrefabInstanceReferencePatches(instance, rewrite) {
85
90
  else
86
91
  patch.connectors = connectors;
87
92
  }
88
- for (const field of ["prevButtonNodeId", "nextButtonNodeId", "pageUpButtonNodeId", "pageDownButtonNodeId"]) {
93
+ for (const field of ["prevButtonNodeId", "nextButtonNodeId", "activeBackgroundNodeId", "pageUpButtonNodeId", "pageDownButtonNodeId"]) {
89
94
  if (typeof patch[field] !== "string")
90
95
  continue;
91
96
  const mapped = rewrite(patch[field]);
@@ -1 +1 @@
1
- {"version":3,"file":"nodeReferences.js","sourceRoot":"","sources":["../src/nodeReferences.ts"],"names":[],"mappings":"AAMA,SAAS,cAAc,CAAC,KAAyB,EAAE,OAA8B;IAC/E,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAmC,EAAE,OAA8B;IAChG,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC7C,MAAM,YAAY,GAAG,OAAO,CA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,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;gBAC3E,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC7B,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YAC9C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACX,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC,KAAK,CAAC;;gBACtC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { PrefabInstanceNode } from \"./prefabs.js\";\nimport type { SpineConnector, UINode } from \"./index.js\";\n\n/** A reference can be rewritten, or removed when its target no longer belongs to the operation. */\nexport type NodeReferenceRewriter = (address: string) => string | undefined;\n\nfunction rewriteAddress(value: string | undefined, rewrite: NodeReferenceRewriter): string | undefined {\n return value === undefined ? undefined : rewrite(value);\n}\n\nfunction rewriteConnectorArray(value: SpineConnector[] | undefined, rewrite: NodeReferenceRewriter): SpineConnector[] | undefined {\n if (value === undefined) return undefined;\n const connectors = value.flatMap((connector) => {\n const targetNodeId = rewrite(connector.targetNodeId);\n return targetNodeId === undefined ? [] : [{ ...connector, targetNodeId }];\n });\n return connectors.length === 0 ? undefined : connectors;\n}\n\n/**\n * The sole inventory of semantic node-to-node reference fields.\n *\n * Structural hierarchy links (`parentId` and `children`) intentionally do not participate: their\n * remapping has different ownership rules. Every operation which copies, deletes, materializes or\n * unpacks semantic node references must call this helper instead of switching on node types itself.\n */\nexport function rewriteNodeReferences(node: UINode, rewrite: NodeReferenceRewriter): void {\n if (node.type === \"spine\") {\n const connectors = rewriteConnectorArray(node.connectors, rewrite);\n if (connectors === undefined) delete node.connectors;\n else node.connectors = connectors;\n return;\n }\n if (node.type === \"pagination\") {\n const prevButtonNodeId = rewriteAddress(node.prevButtonNodeId, rewrite);\n const nextButtonNodeId = rewriteAddress(node.nextButtonNodeId, rewrite);\n if (prevButtonNodeId === undefined) delete node.prevButtonNodeId;\n else node.prevButtonNodeId = prevButtonNodeId;\n if (nextButtonNodeId === undefined) delete node.nextButtonNodeId;\n else node.nextButtonNodeId = nextButtonNodeId;\n return;\n }\n if (node.type === \"page-group\") {\n const pageUpButtonNodeId = rewriteAddress(node.pageUpButtonNodeId, rewrite);\n const pageDownButtonNodeId = rewriteAddress(node.pageDownButtonNodeId, rewrite);\n if (pageUpButtonNodeId === undefined) delete node.pageUpButtonNodeId;\n else node.pageUpButtonNodeId = pageUpButtonNodeId;\n if (pageDownButtonNodeId === undefined) delete node.pageDownButtonNodeId;\n else node.pageDownButtonNodeId = pageDownButtonNodeId;\n return;\n }\n if (node.type === \"item-table\" && node.items !== undefined) {\n const items = node.items.flatMap((itemId) => {\n const mapped = rewrite(itemId);\n return mapped === undefined ? [] : [mapped];\n });\n if (items.length === 0) delete node.items;\n else node.items = items;\n }\n}\n\n/**\n * Applies the same inventory to sparse prefab patches. Patches are intentionally untyped records,\n * so this is the only permitted place to inspect their reference-shaped fields.\n */\nexport function rewritePrefabInstanceReferencePatches(instance: PrefabInstanceNode, rewrite: NodeReferenceRewriter): void {\n for (const override of instance.propertyOverrides ?? []) {\n const patch = override.patch as Record<string, unknown>;\n if (Array.isArray(patch.connectors)) {\n const connectors = patch.connectors.flatMap((value) => {\n if (typeof value !== \"object\" || value === null) return [];\n const connector = value as Partial<SpineConnector>;\n if ((connector.partType !== \"bone\" && connector.partType !== \"slot\") || typeof connector.partName !== \"string\" || typeof connector.targetNodeId !== \"string\") return [];\n const targetNodeId = rewrite(connector.targetNodeId);\n return targetNodeId === undefined ? [] : [{ ...connector, targetNodeId }];\n });\n if (connectors.length === 0) delete patch.connectors;\n else patch.connectors = connectors;\n }\n for (const field of [\"prevButtonNodeId\", \"nextButtonNodeId\", \"pageUpButtonNodeId\", \"pageDownButtonNodeId\"] as const) {\n if (typeof patch[field] !== \"string\") continue;\n const mapped = rewrite(patch[field]);\n if (mapped === undefined) delete patch[field];\n else patch[field] = mapped;\n }\n if (Array.isArray(patch.items)) {\n const items = patch.items.flatMap((item) => typeof item === \"string\" ? (() => {\n const mapped = rewrite(item);\n return mapped === undefined ? [] : [mapped];\n })() : []);\n if (items.length === 0) delete patch.items;\n else patch.items = items;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"nodeReferences.js","sourceRoot":"","sources":["../src/nodeReferences.ts"],"names":[],"mappings":"AAMA,SAAS,cAAc,CAAC,KAAyB,EAAE,OAA8B;IAC/E,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAmC,EAAE,OAA8B;IAChG,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC7C,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QACrD,OAAO,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,OAA8B;IAChF,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1B,MAAM,UAAU,GAAG,qBAAqB,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACnE,IAAI,UAAU,KAAK,SAAS;YAAE,OAAO,IAAI,CA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AAK,CAAC;;gBACtC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { PrefabInstanceNode } from \"./prefabs.js\";\nimport type { SpineConnector, UINode } from \"./index.js\";\n\n/** A reference can be rewritten, or removed when its target no longer belongs to the operation. */\nexport type NodeReferenceRewriter = (address: string) => string | undefined;\n\nfunction rewriteAddress(value: string | undefined, rewrite: NodeReferenceRewriter): string | undefined {\n return value === undefined ? undefined : rewrite(value);\n}\n\nfunction rewriteConnectorArray(value: SpineConnector[] | undefined, rewrite: NodeReferenceRewriter): SpineConnector[] | undefined {\n if (value === undefined) return undefined;\n const connectors = value.flatMap((connector) => {\n const targetNodeId = rewrite(connector.targetNodeId);\n return targetNodeId === undefined ? [] : [{ ...connector, targetNodeId }];\n });\n return connectors.length === 0 ? undefined : connectors;\n}\n\n/**\n * The sole inventory of semantic node-to-node reference fields.\n *\n * Structural hierarchy links (`parentId` and `children`) intentionally do not participate: their\n * remapping has different ownership rules. Every operation which copies, deletes, materializes or\n * unpacks semantic node references must call this helper instead of switching on node types itself.\n */\nexport function rewriteNodeReferences(node: UINode, rewrite: NodeReferenceRewriter): void {\n if (node.type === \"spine\") {\n const connectors = rewriteConnectorArray(node.connectors, rewrite);\n if (connectors === undefined) delete node.connectors;\n else node.connectors = connectors;\n return;\n }\n if (node.type === \"pagination\") {\n const prevButtonNodeId = rewriteAddress(node.prevButtonNodeId, rewrite);\n const nextButtonNodeId = rewriteAddress(node.nextButtonNodeId, rewrite);\n const activeBackgroundNodeId = rewriteAddress(node.activeBackgroundNodeId, rewrite);\n if (prevButtonNodeId === undefined) delete node.prevButtonNodeId;\n else node.prevButtonNodeId = prevButtonNodeId;\n if (nextButtonNodeId === undefined) delete node.nextButtonNodeId;\n else node.nextButtonNodeId = nextButtonNodeId;\n if (activeBackgroundNodeId === undefined) delete node.activeBackgroundNodeId;\n else node.activeBackgroundNodeId = activeBackgroundNodeId;\n return;\n }\n if (node.type === \"page-group\") {\n const pageUpButtonNodeId = rewriteAddress(node.pageUpButtonNodeId, rewrite);\n const pageDownButtonNodeId = rewriteAddress(node.pageDownButtonNodeId, rewrite);\n if (pageUpButtonNodeId === undefined) delete node.pageUpButtonNodeId;\n else node.pageUpButtonNodeId = pageUpButtonNodeId;\n if (pageDownButtonNodeId === undefined) delete node.pageDownButtonNodeId;\n else node.pageDownButtonNodeId = pageDownButtonNodeId;\n return;\n }\n if (node.type === \"item-table\" && node.items !== undefined) {\n const items = node.items.flatMap((itemId) => {\n const mapped = rewrite(itemId);\n return mapped === undefined ? [] : [mapped];\n });\n if (items.length === 0) delete node.items;\n else node.items = items;\n }\n}\n\n/**\n * Applies the same inventory to sparse prefab patches. Patches are intentionally untyped records,\n * so this is the only permitted place to inspect their reference-shaped fields.\n */\nexport function rewritePrefabInstanceReferencePatches(instance: PrefabInstanceNode, rewrite: NodeReferenceRewriter): void {\n for (const override of instance.propertyOverrides ?? []) {\n const patch = override.patch as Record<string, unknown>;\n if (Array.isArray(patch.connectors)) {\n const connectors = patch.connectors.flatMap((value) => {\n if (typeof value !== \"object\" || value === null) return [];\n const connector = value as Partial<SpineConnector>;\n if ((connector.partType !== \"bone\" && connector.partType !== \"slot\") || typeof connector.partName !== \"string\" || typeof connector.targetNodeId !== \"string\") return [];\n const targetNodeId = rewrite(connector.targetNodeId);\n return targetNodeId === undefined ? [] : [{ ...connector, targetNodeId }];\n });\n if (connectors.length === 0) delete patch.connectors;\n else patch.connectors = connectors;\n }\n for (const field of [\"prevButtonNodeId\", \"nextButtonNodeId\", \"activeBackgroundNodeId\", \"pageUpButtonNodeId\", \"pageDownButtonNodeId\"] as const) {\n if (typeof patch[field] !== \"string\") continue;\n const mapped = rewrite(patch[field]);\n if (mapped === undefined) delete patch[field];\n else patch[field] = mapped;\n }\n if (Array.isArray(patch.items)) {\n const items = patch.items.flatMap((item) => typeof item === \"string\" ? (() => {\n const mapped = rewrite(item);\n return mapped === undefined ? [] : [mapped];\n })() : []);\n if (items.length === 0) delete patch.items;\n else patch.items = items;\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixi-ui-editor/schema",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "Versioned document schema, validation and project-manifest format for Pixi UI Editor projects.",
5
5
  "type": "module",
6
6
  "repository": {