@mapples/render 1.2.0 → 1.3.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/dist/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export * from './types';
2
2
  export * from './context';
3
3
  export * from './components';
4
4
  export * from './hooks';
5
+ export * from './utils/migrateLegacyIconNodes';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,gCAAgC,CAAC"}
package/dist/index.js CHANGED
@@ -2,4 +2,5 @@ export * from './types';
2
2
  export * from './context';
3
3
  export * from './components';
4
4
  export * from './hooks';
5
+ export * from './utils/migrateLegacyIconNodes';
5
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { RenderDom } from '../types';
2
+ /**
3
+ * Documents saved before the Icon → Vector rename persist uri-based nodes as
4
+ * `type: 'Icon'` — the type that now belongs to the font-glyph Icon component.
5
+ * Remap those legacy nodes to `Vector` so they keep rendering as SVGs.
6
+ *
7
+ * Only legacy nodes migrate: a node owned by the new Icon component always
8
+ * carries `iconName` in its props (its initialProps guarantee it), while the
9
+ * uri-based component never did.
10
+ *
11
+ * Mutates and returns the given dom — call it on a freshly cloned or fetched
12
+ * document, never on a live Form document.
13
+ *
14
+ * @public
15
+ */
16
+ export declare const migrateLegacyIconNodes: <T extends RenderDom>(dom: T) => T;
17
+ //# sourceMappingURL=migrateLegacyIconNodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrateLegacyIconNodes.d.ts","sourceRoot":"","sources":["../../src/utils/migrateLegacyIconNodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,SAAS,EAAE,KAAK,CAAC,KAAG,CAWpE,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Documents saved before the Icon → Vector rename persist uri-based nodes as
3
+ * `type: 'Icon'` — the type that now belongs to the font-glyph Icon component.
4
+ * Remap those legacy nodes to `Vector` so they keep rendering as SVGs.
5
+ *
6
+ * Only legacy nodes migrate: a node owned by the new Icon component always
7
+ * carries `iconName` in its props (its initialProps guarantee it), while the
8
+ * uri-based component never did.
9
+ *
10
+ * Mutates and returns the given dom — call it on a freshly cloned or fetched
11
+ * document, never on a live Form document.
12
+ *
13
+ * @public
14
+ */
15
+ export const migrateLegacyIconNodes = (dom) => {
16
+ const visit = (node) => {
17
+ if (node.type === 'Icon' && !(node.props && 'iconName' in node.props)) {
18
+ node.type = 'Vector';
19
+ }
20
+ Object.values(node.childComponents ?? {}).forEach(visit);
21
+ };
22
+ if (dom?.root) {
23
+ visit(dom.root);
24
+ }
25
+ return dom;
26
+ };
27
+ //# sourceMappingURL=migrateLegacyIconNodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrateLegacyIconNodes.js","sourceRoot":"","sources":["../../src/utils/migrateLegacyIconNodes.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAsB,GAAM,EAAK,EAAE;IACvE,MAAM,KAAK,GAAG,CAAC,IAAyB,EAAE,EAAE;QAC1C,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACtE,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QACvB,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC,CAAC;IACF,IAAI,GAAG,EAAE,IAAI,EAAE,CAAC;QACd,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapples/render",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {