@fragmentsx/render-react 1.2.1 → 1.2.3

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":"useFragmentCssChunks.d.ts","sourceRoot":"","sources":["../../../src/hooks/fragment/useFragmentCssChunks.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,eAAgB,MAAM,QAQtD,CAAC"}
1
+ {"version":3,"file":"useFragmentCssChunks.d.ts","sourceRoot":"","sources":["../../../src/hooks/fragment/useFragmentCssChunks.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,eAAgB,MAAM,QAStD,CAAC"}
@@ -7,5 +7,5 @@ export { useLayerScopes } from './useLayerScopes';
7
7
  export { useLayerLink } from './useLayerLink';
8
8
  export { useLayerCssVariable } from './useLayerCssVariable';
9
9
  export { useLayerVariableValue } from './useLayerVariableValue';
10
- export { useNormalizeLayer } from './useNormalizeLayer';
10
+ export { useNormalizeLayer, getNormalizeLayer } from './useNormalizeLayer';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLayerCssVariable.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useLayerCssVariable.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG5D,eAAO,MAAM,mBAAmB,YAAa,UAAU;;CAQtD,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAc/B,CAAC"}
1
+ {"version":3,"file":"useLayerCssVariable.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useLayerCssVariable.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,eAAO,MAAM,mBAAmB,YAAa,UAAU;;CAQtD,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAU/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/layer/useNormalizeLayer/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAY,eAAe,EAAE,MAAM,YAAY,CAAC;AAGvD,eAAO,MAAM,iBAAiB,aAClB,OAAO,WACR,OAAO,YACN,eAAe;;;;;;CAU1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAClB,OAAO,YACP,OAAO,YACP,eAAe;;;;;;CAM1B,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAClB,OAAO,EAAE,YACV,OAAO,YACP,eAAe;;;;;;GAQ1B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/layer/useNormalizeLayer/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAY,eAAe,EAAE,MAAM,YAAY,CAAC;AAGvD,eAAO,MAAM,iBAAiB,aAClB,OAAO,WACR,OAAO,YACN,eAAe;;;;;;CAU1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAClB,OAAO,YACP,OAAO,YACP,eAAe;;;;;;CAc1B,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAClB,OAAO,EAAE,YACV,OAAO,YACP,eAAe;;;;;;GAQ1B,CAAC"}
@@ -2,9 +2,13 @@ import { LinkKey } from '@graph-state/core';
2
2
  export declare const useReadVariable: (variableKey?: LinkKey | null, customScopes?: unknown[]) => {
3
3
  readVariable: (variableKey?: LinkKey) => {
4
4
  value: any;
5
- layer: any;
5
+ layer: {
6
+ [k: string]: any;
7
+ } | null;
6
8
  };
7
9
  value: any;
8
- layer: any;
10
+ layer: {
11
+ [k: string]: any;
12
+ } | null;
9
13
  };
10
14
  //# sourceMappingURL=useReadVariable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useReadVariable.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useReadVariable.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAgDrE,eAAO,MAAM,eAAe,iBACZ,OAAO,GAAG,IAAI,iBACb,OAAO,EAAE;iCA+EY,OAAO;;;;;;CAgI5C,CAAC"}
1
+ {"version":3,"file":"useReadVariable.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useReadVariable.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAiDrE,eAAO,MAAM,eAAe,iBACZ,OAAO,GAAG,IAAI,iBACb,OAAO,EAAE;iCAgFY,OAAO;;;;;;;;;;CAgI5C,CAAC"}
@@ -2,6 +2,7 @@ import { LinkKey } from '@graph-state/core';
2
2
  export declare const useLayerPaint: (paintLinkKey: LinkKey) => {
3
3
  type: any;
4
4
  solid: any;
5
+ solidCssValue: any;
5
6
  image: any;
6
7
  linearGradientLink: any;
7
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useLayerPaint.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer-styles/useLayerPaint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,eAAO,MAAM,aAAa,iBAAkB,OAAO;;;;;CAYlD,CAAC"}
1
+ {"version":3,"file":"useLayerPaint.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer-styles/useLayerPaint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,eAAO,MAAM,aAAa,iBAAkB,OAAO;;;;;;CAalD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { useRenderTarget } from './useRenderTarget';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLayerInteractions.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/useLayerInteractions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAM5C,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,oBAAoB,aACrB,OAAO,YACP,2BAA2B;;;;CAsEtC,CAAC"}
1
+ {"version":3,"file":"useLayerInteractions.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/useLayerInteractions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAQzD,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,oBAAoB,aACrB,OAAO,YACP,2BAA2B;;;;CAuFtC,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -92,6 +92,13 @@ const getNormalizeLayer = (layerKey, manager, options) => {
92
92
  const useNormalizeLayer = (layerKey, manager, options) => {
93
93
  const { manager: fragmentManager } = react.useContext(FragmentContext);
94
94
  const resultManager = manager ?? fragmentManager;
95
+ if (!resultManager) {
96
+ return {
97
+ layerKey,
98
+ rawLayer: null,
99
+ layer: null
100
+ };
101
+ }
95
102
  return getNormalizeLayer(layerKey, resultManager, options);
96
103
  };
97
104
  const useNormalizeLayers = (layerKeys, manager, options) => {
@@ -151,12 +158,12 @@ const useReadVariable = (variableKey, customScopes) => {
151
158
  );
152
159
  };
153
160
  const resolveVariableLayer = (manager, variableLink, customProps) => {
154
- var _a;
155
- const variableLayer = manager == null ? void 0 : manager.resolve(variableLink);
161
+ var _a, _b;
162
+ const variableLayer = (_a = getNormalizeLayer(variableLink, manager)) == null ? void 0 : _a.layer;
156
163
  if (!variableLayer) return null;
157
164
  if ((variableLayer == null ? void 0 : variableLayer.type) === definition.definition.variableType.Array) {
158
165
  const definitionLayer = manager.resolve(variableLayer == null ? void 0 : variableLayer.definition);
159
- if (!((_a = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== definition.definition.variableType.Object)
166
+ if (!((_b = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _b.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== definition.definition.variableType.Object)
160
167
  return variableLayer;
161
168
  const definitionDefaultValue = extractVariableDefaultValue(
162
169
  manager,
@@ -464,14 +471,12 @@ function makeSnapshot(globalManager, targetFragmentId) {
464
471
  ).filter(Boolean);
465
472
  const linkedGoals = Array.from(
466
473
  new Set(
467
- targetFragment.inspectFields(definition.definition.nodes.Variable).map(targetFragment == null ? void 0 : targetFragment.resolve).filter((graph) => {
468
- return (graph == null ? void 0 : graph.type) === definition.definition.variableType.Event && (graph == null ? void 0 : graph.mode) === definition.definition.eventMode.goal;
469
- }).map((graph) => {
474
+ targetFragment.inspectFields(definition.definition.nodes.GoalEvent).map((link) => {
470
475
  var _a2;
471
- return (_a2 = graph == null ? void 0 : graph.defaultValue) == null ? void 0 : _a2.goalId;
472
- }).filter(Boolean).values()
476
+ return (_a2 = targetFragment == null ? void 0 : targetFragment.resolve(link)) == null ? void 0 : _a2.goalId;
477
+ }).values()
473
478
  )
474
- );
479
+ ).filter(Boolean);
475
480
  const fonts = Array.from(
476
481
  new Set(
477
482
  targetFragment.inspectFields(definition.definition.nodes.Text).map((linkKey) => {
@@ -971,13 +976,9 @@ const getLayerCssVariable = (manager, inputValue) => {
971
976
  const useLayerCssVariable = (inputValue) => {
972
977
  const { manager } = react.useContext(FragmentContext);
973
978
  const isVariable = definition.isVariableLink(inputValue);
974
- const [variableValue] = react$1.useGraph(isVariable ? manager : null, inputValue, {
975
- selector: (graph) => utils.pick(graph, "defaultValue", "_id")
976
- });
979
+ const { layer } = useNormalizeLayer(inputValue, isVariable ? manager : null);
977
980
  return {
978
- value: isVariable ? `var(--${variableValue == null ? void 0 : variableValue._id}, ${transformCssValue(
979
- variableValue == null ? void 0 : variableValue.defaultValue
980
- )})` : null
981
+ value: isVariable ? `var(--${layer == null ? void 0 : layer._id}, ${transformCssValue(layer == null ? void 0 : layer.defaultValue)})` : null
981
982
  };
982
983
  };
983
984
  const useLayerValue = (layerKey, fieldKey, options) => {
@@ -1428,12 +1429,13 @@ const useLayerDisplay = (layerKey) => {
1428
1429
  };
1429
1430
  const useLayerPaint = (paintLinkKey) => {
1430
1431
  const [type] = useLayerValue(paintLinkKey, "type");
1431
- const [solid] = useLayerValue(paintLinkKey, "solid");
1432
+ const [solid, , solidInfo] = useLayerValue(paintLinkKey, "solid");
1432
1433
  const [image] = useLayerValue(paintLinkKey, "image");
1433
1434
  const [linearGradientLink] = useLayerValue(paintLinkKey, "linearGradient");
1434
1435
  return {
1435
1436
  type,
1436
1437
  solid,
1438
+ solidCssValue: solidInfo.cssVariableValue,
1437
1439
  image,
1438
1440
  linearGradientLink
1439
1441
  };
@@ -1473,7 +1475,7 @@ const useLayerBorder = (layerKey) => {
1473
1475
  };
1474
1476
  }
1475
1477
  if (borderPaint.type === definition.definition.paintMode.Solid) {
1476
- return calcBorderSides(type, width, borderPaint.solid);
1478
+ return calcBorderSides(type, width, borderPaint.solidCssValue);
1477
1479
  }
1478
1480
  return { border: null };
1479
1481
  };
@@ -1684,36 +1686,6 @@ const useStyleSheet = (manager) => {
1684
1686
  unmount: ((_b = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _b.unmount) ?? utils.noop
1685
1687
  };
1686
1688
  };
1687
- const useTextAttributes = (layerKey, options) => {
1688
- const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
1689
- const { manager: fragmentManager } = react.useContext(FragmentContext);
1690
- const styles = useLayerStyles(layerKey);
1691
- const content = useTextContent(layerKey);
1692
- const classnames = useClassnames(layerKey, fragmentManager);
1693
- const { addLayerStyle } = useStyleSheet(fragmentManager);
1694
- if (collectStyle) {
1695
- addLayerStyle(layerKey, styles, fragmentManager.resolve(layerKey));
1696
- }
1697
- return {
1698
- styles,
1699
- classnames,
1700
- content
1701
- };
1702
- };
1703
- const Text = ({
1704
- layerKey,
1705
- Tag = "div",
1706
- collectStyle,
1707
- ...restProps
1708
- }) => {
1709
- const { classnames, content } = useTextAttributes(layerKey, { collectStyle });
1710
- return /* @__PURE__ */ jsxRuntime.jsx(Tag, { className: classnames, "data-key": layerKey, ...restProps, children: /* @__PURE__ */ jsxRuntime.jsx(
1711
- "div",
1712
- {
1713
- dangerouslySetInnerHTML: { __html: content }
1714
- }
1715
- ) });
1716
- };
1717
1689
  const useLayerInteractions = (layerKey, options) => {
1718
1690
  const pause = (options == null ? void 0 : options.pauseInteractions) ?? false;
1719
1691
  const { manager: globalManager } = useGlobalManager();
@@ -1722,29 +1694,40 @@ const useLayerInteractions = (layerKey, options) => {
1722
1694
  const areaScope = scopes.find(
1723
1695
  (scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.AreaScope
1724
1696
  );
1725
- const [interactions] = useLayerValue(
1726
- layerKey,
1727
- "interactions",
1728
- fragmentManager
1697
+ const instanceScope = scopes.find(
1698
+ (scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.InstanceScope
1729
1699
  );
1730
- const { readVariable } = useReadVariable();
1700
+ const [interactionLinks] = useLayerValue(layerKey, "interactions");
1701
+ const interactionOns = useLayersValue(interactionLinks, "on");
1702
+ const interactionEvents = useLayersValue(interactionLinks, "event");
1703
+ const interactions = (interactionLinks ?? []).map((linkKey, index) => {
1704
+ var _a, _b;
1705
+ return {
1706
+ linkKey,
1707
+ on: (_a = interactionOns == null ? void 0 : interactionOns.at(index)) == null ? void 0 : _a.at(0),
1708
+ event: (_b = interactionEvents == null ? void 0 : interactionEvents.at(index)) == null ? void 0 : _b.at(0)
1709
+ };
1710
+ });
1731
1711
  const fireEvent = react.useCallback(
1732
1712
  (eventLink) => {
1733
- var _a, _b, _c, _d;
1734
- if (!areaScope) return null;
1735
- const event = fragmentManager.resolve(eventLink);
1736
- const { value: eventValue } = readVariable(eventLink);
1737
- if ((event == null ? void 0 : event.mode) === definition.definition.eventMode.goal && (eventValue == null ? void 0 : eventValue.goalId)) {
1738
- (_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, {
1713
+ var _a, _b, _c, _d, _e, _f, _g;
1714
+ const eventType = (_a = core.entityOfKey(eventLink)) == null ? void 0 : _a._type;
1715
+ const eventValue = (_b = getNormalizeLayer(eventLink, fragmentManager)) == null ? void 0 : _b.layer;
1716
+ if (eventType === definition.definition.nodes.GoalEvent && (eventValue == null ? void 0 : eventValue.goalId)) {
1717
+ if (!areaScope) return null;
1718
+ (_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.reachGoal) == null ? void 0 : _d.call(_c, {
1739
1719
  goalId: eventValue == null ? void 0 : eventValue.goalId,
1740
1720
  ...utils.pick(areaScope, "variantId", "campaignId", "areaId")
1741
1721
  });
1742
1722
  }
1743
- if ((event == null ? void 0 : event.mode) === definition.definition.eventMode.tracker && eventValue) {
1744
- (_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.trackAdPixel) == null ? void 0 : _d.call(_c, eventValue);
1745
- }
1746
- if ((event == null ? void 0 : event.mode) === definition.definition.eventMode.callback && typeof eventValue === "function") {
1747
- eventValue();
1723
+ if (eventType === definition.definition.nodes.MutateEvent) {
1724
+ const target = eventValue == null ? void 0 : eventValue.target;
1725
+ const targetLayer = getNormalizeLayer(target, fragmentManager);
1726
+ const value = (eventValue == null ? void 0 : eventValue.value) ?? ((_e = targetLayer == null ? void 0 : targetLayer.layer) == null ? void 0 : _e.defaultValue);
1727
+ if (definition.isVariableLink(target) && utils.isValue(value)) {
1728
+ const targetId = (_f = core.entityOfKey(target)) == null ? void 0 : _f._id;
1729
+ (_g = instanceScope == null ? void 0 : instanceScope.onChangeProps) == null ? void 0 : _g.call(instanceScope, targetId, value);
1730
+ }
1748
1731
  }
1749
1732
  },
1750
1733
  [globalManager, fragmentManager, areaScope]
@@ -1765,6 +1748,40 @@ const useLayerInteractions = (layerKey, options) => {
1765
1748
  };
1766
1749
  }, [interactions, fireEvent, pause]);
1767
1750
  };
1751
+ const useTextAttributes = (layerKey, options) => {
1752
+ const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
1753
+ const { manager: fragmentManager } = react.useContext(FragmentContext);
1754
+ const styles = useLayerStyles(layerKey);
1755
+ const content = useTextContent(layerKey);
1756
+ const classnames = useClassnames(layerKey, fragmentManager);
1757
+ const { addLayerStyle } = useStyleSheet(fragmentManager);
1758
+ const events = useLayerInteractions(layerKey, options);
1759
+ if (collectStyle) {
1760
+ addLayerStyle(layerKey, styles, fragmentManager.resolve(layerKey));
1761
+ }
1762
+ return {
1763
+ events,
1764
+ styles,
1765
+ classnames,
1766
+ content
1767
+ };
1768
+ };
1769
+ const Text = ({
1770
+ layerKey,
1771
+ Tag = "div",
1772
+ collectStyle,
1773
+ ...restProps
1774
+ }) => {
1775
+ const { classnames, content, events } = useTextAttributes(layerKey, {
1776
+ collectStyle
1777
+ });
1778
+ return /* @__PURE__ */ jsxRuntime.jsx(Tag, { className: classnames, "data-key": layerKey, ...events, ...restProps, children: /* @__PURE__ */ jsxRuntime.jsx(
1779
+ "div",
1780
+ {
1781
+ dangerouslySetInnerHTML: { __html: content }
1782
+ }
1783
+ ) });
1784
+ };
1768
1785
  const useFrame = (layerKey, options) => {
1769
1786
  const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
1770
1787
  const { manager: fragmentManager } = react.useContext(FragmentContext);
@@ -2141,26 +2158,42 @@ const useInstanceProps = (instanceProps) => {
2141
2158
  const fragmentManager = isTopInstance ? loadedManager : fragmentContextManager;
2142
2159
  const [instanceLayer] = react$1.useGraph(fragmentManager, instanceProps.layerKey);
2143
2160
  const instanceLayerProps = (instanceLayer == null ? void 0 : instanceLayer.props) ?? {};
2161
+ const [localProps, setLocalProps] = react.useState(instanceProps.props ?? {});
2144
2162
  const mergedProps = react.useMemo(() => {
2145
2163
  let base = instanceLayerProps;
2146
- if (isTopInstance && utils.isObject(base) && utils.isObject(instanceProps == null ? void 0 : instanceProps.props)) {
2164
+ if (isTopInstance && utils.isObject(base) && utils.isObject(localProps)) {
2147
2165
  base = {
2148
2166
  ...base,
2149
- ...instanceProps == null ? void 0 : instanceProps.props
2167
+ ...localProps
2150
2168
  };
2151
2169
  }
2152
2170
  if (isTopInstance && fragmentManager) {
2153
2171
  definitionsData.forEach((definition2) => {
2154
- var _a;
2155
2172
  const defId = definition2._id;
2156
- base[defId] = ((_a = instanceProps == null ? void 0 : instanceProps.props) == null ? void 0 : _a[defId]) ?? (definition2 == null ? void 0 : definition2.defaultValue);
2173
+ base[defId] = (localProps == null ? void 0 : localProps[defId]) ?? (definition2 == null ? void 0 : definition2.defaultValue);
2157
2174
  });
2158
2175
  }
2159
2176
  return utils.omit(base, "_type", "_id");
2160
- }, [isTopInstance, fragmentManager, instanceLayerProps, definitionsData]);
2177
+ }, [
2178
+ isTopInstance,
2179
+ fragmentManager,
2180
+ instanceLayerProps,
2181
+ definitionsData,
2182
+ localProps
2183
+ ]);
2184
+ react.useEffect(() => {
2185
+ if (utils.isValue(instanceProps == null ? void 0 : instanceProps.props)) {
2186
+ setLocalProps(instanceProps.props);
2187
+ }
2188
+ }, [instanceProps == null ? void 0 : instanceProps.props]);
2161
2189
  return {
2162
2190
  props: mergedProps,
2163
- cssProps: getCssVariables(mergedProps)
2191
+ cssProps: getCssVariables(mergedProps),
2192
+ onChangeProps: (variableId, value) => {
2193
+ var _a;
2194
+ setLocalProps((prev) => ({ ...prev, [variableId]: value }));
2195
+ (_a = instanceProps == null ? void 0 : instanceProps.onChangeProps) == null ? void 0 : _a.call(instanceProps, variableId, value);
2196
+ }
2164
2197
  };
2165
2198
  };
2166
2199
  const useInstance = (instanceProps) => {
@@ -2173,7 +2206,7 @@ const useInstance = (instanceProps) => {
2173
2206
  );
2174
2207
  const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
2175
2208
  const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(resultFragmentId);
2176
- const { props, cssProps } = useInstanceProps(instanceProps);
2209
+ const { props, cssProps, onChangeProps } = useInstanceProps(instanceProps);
2177
2210
  const classnames = useClassnames(
2178
2211
  instanceProps.layerKey,
2179
2212
  innerFragmentManager
@@ -2188,7 +2221,8 @@ const useInstance = (instanceProps) => {
2188
2221
  parentManager,
2189
2222
  innerManager: innerFragmentManager,
2190
2223
  fragmentId: resultFragmentId,
2191
- globalManager: resultGlobalManager
2224
+ globalManager: resultGlobalManager,
2225
+ onChangeProps
2192
2226
  };
2193
2227
  };
2194
2228
  const InstanceInitial = ({
@@ -2211,7 +2245,8 @@ const InstanceInitial = ({
2211
2245
  classnames,
2212
2246
  innerManager,
2213
2247
  definitions,
2214
- globalManager
2248
+ globalManager,
2249
+ onChangeProps
2215
2250
  } = useInstance({
2216
2251
  ...instanceProps,
2217
2252
  pauseInteractions
@@ -2230,7 +2265,8 @@ const InstanceInitial = ({
2230
2265
  definitions,
2231
2266
  fragmentId,
2232
2267
  documentManager: innerManager,
2233
- layerKey: instanceProps.layerKey
2268
+ layerKey: instanceProps.layerKey,
2269
+ onChangeProps
2234
2270
  },
2235
2271
  children: /* @__PURE__ */ jsxRuntime.jsx(
2236
2272
  InstanceContext$1.Provider,
@@ -2399,6 +2435,7 @@ exports.getAllParents = getAllParents;
2399
2435
  exports.getCssVariables = getCssVariables;
2400
2436
  exports.getHydratedData = getHydratedData;
2401
2437
  exports.getKey = getKey;
2438
+ exports.getNormalizeLayer = getNormalizeLayer;
2402
2439
  exports.getOverrider = getOverrider;
2403
2440
  exports.getOverriderByLayers = getOverriderByLayers;
2404
2441
  exports.getParent = getParent;
@@ -2457,6 +2494,7 @@ exports.useNormalizeLayer = useNormalizeLayer;
2457
2494
  exports.useOptionalSize = useOptionalSize;
2458
2495
  exports.useReadVariable = useReadVariable;
2459
2496
  exports.useReadVariables = useReadVariables;
2497
+ exports.useRenderTarget = useRenderTarget;
2460
2498
  exports.useTextAttributes = useTextAttributes;
2461
2499
  exports.useTextContent = useTextContent;
2462
2500
  exports.wrapTextInParagraphWithAttributes = wrapTextInParagraphWithAttributes;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './providers';
2
2
  export * from './nodes';
3
3
  export * from './utils';
4
+ export * from './hooks/render';
4
5
  export * from './hooks/layer';
5
6
  export * from './hooks/layer-styles';
6
7
  export * from './hooks/global';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
package/dist/index.es.js CHANGED
@@ -90,6 +90,13 @@ const getNormalizeLayer = (layerKey, manager, options) => {
90
90
  const useNormalizeLayer = (layerKey, manager, options) => {
91
91
  const { manager: fragmentManager } = useContext(FragmentContext);
92
92
  const resultManager = manager ?? fragmentManager;
93
+ if (!resultManager) {
94
+ return {
95
+ layerKey,
96
+ rawLayer: null,
97
+ layer: null
98
+ };
99
+ }
93
100
  return getNormalizeLayer(layerKey, resultManager, options);
94
101
  };
95
102
  const useNormalizeLayers = (layerKeys, manager, options) => {
@@ -149,12 +156,12 @@ const useReadVariable = (variableKey, customScopes) => {
149
156
  );
150
157
  };
151
158
  const resolveVariableLayer = (manager, variableLink, customProps) => {
152
- var _a;
153
- const variableLayer = manager == null ? void 0 : manager.resolve(variableLink);
159
+ var _a, _b;
160
+ const variableLayer = (_a = getNormalizeLayer(variableLink, manager)) == null ? void 0 : _a.layer;
154
161
  if (!variableLayer) return null;
155
162
  if ((variableLayer == null ? void 0 : variableLayer.type) === definition.variableType.Array) {
156
163
  const definitionLayer = manager.resolve(variableLayer == null ? void 0 : variableLayer.definition);
157
- if (!((_a = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== definition.variableType.Object)
164
+ if (!((_b = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _b.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== definition.variableType.Object)
158
165
  return variableLayer;
159
166
  const definitionDefaultValue = extractVariableDefaultValue(
160
167
  manager,
@@ -462,14 +469,12 @@ function makeSnapshot(globalManager, targetFragmentId) {
462
469
  ).filter(Boolean);
463
470
  const linkedGoals = Array.from(
464
471
  new Set(
465
- targetFragment.inspectFields(definition.nodes.Variable).map(targetFragment == null ? void 0 : targetFragment.resolve).filter((graph) => {
466
- return (graph == null ? void 0 : graph.type) === definition.variableType.Event && (graph == null ? void 0 : graph.mode) === definition.eventMode.goal;
467
- }).map((graph) => {
472
+ targetFragment.inspectFields(definition.nodes.GoalEvent).map((link) => {
468
473
  var _a2;
469
- return (_a2 = graph == null ? void 0 : graph.defaultValue) == null ? void 0 : _a2.goalId;
470
- }).filter(Boolean).values()
474
+ return (_a2 = targetFragment == null ? void 0 : targetFragment.resolve(link)) == null ? void 0 : _a2.goalId;
475
+ }).values()
471
476
  )
472
- );
477
+ ).filter(Boolean);
473
478
  const fonts = Array.from(
474
479
  new Set(
475
480
  targetFragment.inspectFields(definition.nodes.Text).map((linkKey) => {
@@ -969,13 +974,9 @@ const getLayerCssVariable = (manager, inputValue) => {
969
974
  const useLayerCssVariable = (inputValue) => {
970
975
  const { manager } = useContext(FragmentContext);
971
976
  const isVariable = isVariableLink$1(inputValue);
972
- const [variableValue] = useGraph(isVariable ? manager : null, inputValue, {
973
- selector: (graph) => pick(graph, "defaultValue", "_id")
974
- });
977
+ const { layer } = useNormalizeLayer(inputValue, isVariable ? manager : null);
975
978
  return {
976
- value: isVariable ? `var(--${variableValue == null ? void 0 : variableValue._id}, ${transformCssValue(
977
- variableValue == null ? void 0 : variableValue.defaultValue
978
- )})` : null
979
+ value: isVariable ? `var(--${layer == null ? void 0 : layer._id}, ${transformCssValue(layer == null ? void 0 : layer.defaultValue)})` : null
979
980
  };
980
981
  };
981
982
  const useLayerValue = (layerKey, fieldKey, options) => {
@@ -1426,12 +1427,13 @@ const useLayerDisplay = (layerKey) => {
1426
1427
  };
1427
1428
  const useLayerPaint = (paintLinkKey) => {
1428
1429
  const [type] = useLayerValue(paintLinkKey, "type");
1429
- const [solid] = useLayerValue(paintLinkKey, "solid");
1430
+ const [solid, , solidInfo] = useLayerValue(paintLinkKey, "solid");
1430
1431
  const [image] = useLayerValue(paintLinkKey, "image");
1431
1432
  const [linearGradientLink] = useLayerValue(paintLinkKey, "linearGradient");
1432
1433
  return {
1433
1434
  type,
1434
1435
  solid,
1436
+ solidCssValue: solidInfo.cssVariableValue,
1435
1437
  image,
1436
1438
  linearGradientLink
1437
1439
  };
@@ -1471,7 +1473,7 @@ const useLayerBorder = (layerKey) => {
1471
1473
  };
1472
1474
  }
1473
1475
  if (borderPaint.type === definition.paintMode.Solid) {
1474
- return calcBorderSides(type, width, borderPaint.solid);
1476
+ return calcBorderSides(type, width, borderPaint.solidCssValue);
1475
1477
  }
1476
1478
  return { border: null };
1477
1479
  };
@@ -1682,36 +1684,6 @@ const useStyleSheet = (manager) => {
1682
1684
  unmount: ((_b = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _b.unmount) ?? noop
1683
1685
  };
1684
1686
  };
1685
- const useTextAttributes = (layerKey, options) => {
1686
- const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
1687
- const { manager: fragmentManager } = useContext(FragmentContext);
1688
- const styles = useLayerStyles(layerKey);
1689
- const content = useTextContent(layerKey);
1690
- const classnames = useClassnames(layerKey, fragmentManager);
1691
- const { addLayerStyle } = useStyleSheet(fragmentManager);
1692
- if (collectStyle) {
1693
- addLayerStyle(layerKey, styles, fragmentManager.resolve(layerKey));
1694
- }
1695
- return {
1696
- styles,
1697
- classnames,
1698
- content
1699
- };
1700
- };
1701
- const Text = ({
1702
- layerKey,
1703
- Tag = "div",
1704
- collectStyle,
1705
- ...restProps
1706
- }) => {
1707
- const { classnames, content } = useTextAttributes(layerKey, { collectStyle });
1708
- return /* @__PURE__ */ jsx(Tag, { className: classnames, "data-key": layerKey, ...restProps, children: /* @__PURE__ */ jsx(
1709
- "div",
1710
- {
1711
- dangerouslySetInnerHTML: { __html: content }
1712
- }
1713
- ) });
1714
- };
1715
1687
  const useLayerInteractions = (layerKey, options) => {
1716
1688
  const pause = (options == null ? void 0 : options.pauseInteractions) ?? false;
1717
1689
  const { manager: globalManager } = useGlobalManager();
@@ -1720,29 +1692,40 @@ const useLayerInteractions = (layerKey, options) => {
1720
1692
  const areaScope = scopes.find(
1721
1693
  (scope) => (scope == null ? void 0 : scope.type) === definition.scopeTypes.AreaScope
1722
1694
  );
1723
- const [interactions] = useLayerValue(
1724
- layerKey,
1725
- "interactions",
1726
- fragmentManager
1695
+ const instanceScope = scopes.find(
1696
+ (scope) => (scope == null ? void 0 : scope.type) === definition.scopeTypes.InstanceScope
1727
1697
  );
1728
- const { readVariable } = useReadVariable();
1698
+ const [interactionLinks] = useLayerValue(layerKey, "interactions");
1699
+ const interactionOns = useLayersValue(interactionLinks, "on");
1700
+ const interactionEvents = useLayersValue(interactionLinks, "event");
1701
+ const interactions = (interactionLinks ?? []).map((linkKey, index) => {
1702
+ var _a, _b;
1703
+ return {
1704
+ linkKey,
1705
+ on: (_a = interactionOns == null ? void 0 : interactionOns.at(index)) == null ? void 0 : _a.at(0),
1706
+ event: (_b = interactionEvents == null ? void 0 : interactionEvents.at(index)) == null ? void 0 : _b.at(0)
1707
+ };
1708
+ });
1729
1709
  const fireEvent = useCallback(
1730
1710
  (eventLink) => {
1731
- var _a, _b, _c, _d;
1732
- if (!areaScope) return null;
1733
- const event = fragmentManager.resolve(eventLink);
1734
- const { value: eventValue } = readVariable(eventLink);
1735
- if ((event == null ? void 0 : event.mode) === definition.eventMode.goal && (eventValue == null ? void 0 : eventValue.goalId)) {
1736
- (_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, {
1711
+ var _a, _b, _c, _d, _e, _f, _g;
1712
+ const eventType = (_a = entityOfKey(eventLink)) == null ? void 0 : _a._type;
1713
+ const eventValue = (_b = getNormalizeLayer(eventLink, fragmentManager)) == null ? void 0 : _b.layer;
1714
+ if (eventType === definition.nodes.GoalEvent && (eventValue == null ? void 0 : eventValue.goalId)) {
1715
+ if (!areaScope) return null;
1716
+ (_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.reachGoal) == null ? void 0 : _d.call(_c, {
1737
1717
  goalId: eventValue == null ? void 0 : eventValue.goalId,
1738
1718
  ...pick(areaScope, "variantId", "campaignId", "areaId")
1739
1719
  });
1740
1720
  }
1741
- if ((event == null ? void 0 : event.mode) === definition.eventMode.tracker && eventValue) {
1742
- (_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.trackAdPixel) == null ? void 0 : _d.call(_c, eventValue);
1743
- }
1744
- if ((event == null ? void 0 : event.mode) === definition.eventMode.callback && typeof eventValue === "function") {
1745
- eventValue();
1721
+ if (eventType === definition.nodes.MutateEvent) {
1722
+ const target = eventValue == null ? void 0 : eventValue.target;
1723
+ const targetLayer = getNormalizeLayer(target, fragmentManager);
1724
+ const value = (eventValue == null ? void 0 : eventValue.value) ?? ((_e = targetLayer == null ? void 0 : targetLayer.layer) == null ? void 0 : _e.defaultValue);
1725
+ if (isVariableLink$1(target) && isValue(value)) {
1726
+ const targetId = (_f = entityOfKey(target)) == null ? void 0 : _f._id;
1727
+ (_g = instanceScope == null ? void 0 : instanceScope.onChangeProps) == null ? void 0 : _g.call(instanceScope, targetId, value);
1728
+ }
1746
1729
  }
1747
1730
  },
1748
1731
  [globalManager, fragmentManager, areaScope]
@@ -1763,6 +1746,40 @@ const useLayerInteractions = (layerKey, options) => {
1763
1746
  };
1764
1747
  }, [interactions, fireEvent, pause]);
1765
1748
  };
1749
+ const useTextAttributes = (layerKey, options) => {
1750
+ const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
1751
+ const { manager: fragmentManager } = useContext(FragmentContext);
1752
+ const styles = useLayerStyles(layerKey);
1753
+ const content = useTextContent(layerKey);
1754
+ const classnames = useClassnames(layerKey, fragmentManager);
1755
+ const { addLayerStyle } = useStyleSheet(fragmentManager);
1756
+ const events = useLayerInteractions(layerKey, options);
1757
+ if (collectStyle) {
1758
+ addLayerStyle(layerKey, styles, fragmentManager.resolve(layerKey));
1759
+ }
1760
+ return {
1761
+ events,
1762
+ styles,
1763
+ classnames,
1764
+ content
1765
+ };
1766
+ };
1767
+ const Text = ({
1768
+ layerKey,
1769
+ Tag = "div",
1770
+ collectStyle,
1771
+ ...restProps
1772
+ }) => {
1773
+ const { classnames, content, events } = useTextAttributes(layerKey, {
1774
+ collectStyle
1775
+ });
1776
+ return /* @__PURE__ */ jsx(Tag, { className: classnames, "data-key": layerKey, ...events, ...restProps, children: /* @__PURE__ */ jsx(
1777
+ "div",
1778
+ {
1779
+ dangerouslySetInnerHTML: { __html: content }
1780
+ }
1781
+ ) });
1782
+ };
1766
1783
  const useFrame = (layerKey, options) => {
1767
1784
  const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
1768
1785
  const { manager: fragmentManager } = useContext(FragmentContext);
@@ -2139,26 +2156,42 @@ const useInstanceProps = (instanceProps) => {
2139
2156
  const fragmentManager = isTopInstance ? loadedManager : fragmentContextManager;
2140
2157
  const [instanceLayer] = useGraph(fragmentManager, instanceProps.layerKey);
2141
2158
  const instanceLayerProps = (instanceLayer == null ? void 0 : instanceLayer.props) ?? {};
2159
+ const [localProps, setLocalProps] = useState(instanceProps.props ?? {});
2142
2160
  const mergedProps = useMemo(() => {
2143
2161
  let base = instanceLayerProps;
2144
- if (isTopInstance && isObject(base) && isObject(instanceProps == null ? void 0 : instanceProps.props)) {
2162
+ if (isTopInstance && isObject(base) && isObject(localProps)) {
2145
2163
  base = {
2146
2164
  ...base,
2147
- ...instanceProps == null ? void 0 : instanceProps.props
2165
+ ...localProps
2148
2166
  };
2149
2167
  }
2150
2168
  if (isTopInstance && fragmentManager) {
2151
2169
  definitionsData.forEach((definition2) => {
2152
- var _a;
2153
2170
  const defId = definition2._id;
2154
- base[defId] = ((_a = instanceProps == null ? void 0 : instanceProps.props) == null ? void 0 : _a[defId]) ?? (definition2 == null ? void 0 : definition2.defaultValue);
2171
+ base[defId] = (localProps == null ? void 0 : localProps[defId]) ?? (definition2 == null ? void 0 : definition2.defaultValue);
2155
2172
  });
2156
2173
  }
2157
2174
  return omit(base, "_type", "_id");
2158
- }, [isTopInstance, fragmentManager, instanceLayerProps, definitionsData]);
2175
+ }, [
2176
+ isTopInstance,
2177
+ fragmentManager,
2178
+ instanceLayerProps,
2179
+ definitionsData,
2180
+ localProps
2181
+ ]);
2182
+ useEffect(() => {
2183
+ if (isValue(instanceProps == null ? void 0 : instanceProps.props)) {
2184
+ setLocalProps(instanceProps.props);
2185
+ }
2186
+ }, [instanceProps == null ? void 0 : instanceProps.props]);
2159
2187
  return {
2160
2188
  props: mergedProps,
2161
- cssProps: getCssVariables(mergedProps)
2189
+ cssProps: getCssVariables(mergedProps),
2190
+ onChangeProps: (variableId, value) => {
2191
+ var _a;
2192
+ setLocalProps((prev) => ({ ...prev, [variableId]: value }));
2193
+ (_a = instanceProps == null ? void 0 : instanceProps.onChangeProps) == null ? void 0 : _a.call(instanceProps, variableId, value);
2194
+ }
2162
2195
  };
2163
2196
  };
2164
2197
  const useInstance = (instanceProps) => {
@@ -2171,7 +2204,7 @@ const useInstance = (instanceProps) => {
2171
2204
  );
2172
2205
  const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
2173
2206
  const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(resultFragmentId);
2174
- const { props, cssProps } = useInstanceProps(instanceProps);
2207
+ const { props, cssProps, onChangeProps } = useInstanceProps(instanceProps);
2175
2208
  const classnames = useClassnames(
2176
2209
  instanceProps.layerKey,
2177
2210
  innerFragmentManager
@@ -2186,7 +2219,8 @@ const useInstance = (instanceProps) => {
2186
2219
  parentManager,
2187
2220
  innerManager: innerFragmentManager,
2188
2221
  fragmentId: resultFragmentId,
2189
- globalManager: resultGlobalManager
2222
+ globalManager: resultGlobalManager,
2223
+ onChangeProps
2190
2224
  };
2191
2225
  };
2192
2226
  const InstanceInitial = ({
@@ -2209,7 +2243,8 @@ const InstanceInitial = ({
2209
2243
  classnames,
2210
2244
  innerManager,
2211
2245
  definitions,
2212
- globalManager
2246
+ globalManager,
2247
+ onChangeProps
2213
2248
  } = useInstance({
2214
2249
  ...instanceProps,
2215
2250
  pauseInteractions
@@ -2228,7 +2263,8 @@ const InstanceInitial = ({
2228
2263
  definitions,
2229
2264
  fragmentId,
2230
2265
  documentManager: innerManager,
2231
- layerKey: instanceProps.layerKey
2266
+ layerKey: instanceProps.layerKey,
2267
+ onChangeProps
2232
2268
  },
2233
2269
  children: /* @__PURE__ */ jsx(
2234
2270
  InstanceContext$1.Provider,
@@ -2398,6 +2434,7 @@ export {
2398
2434
  getCssVariables,
2399
2435
  getHydratedData,
2400
2436
  getKey,
2437
+ getNormalizeLayer,
2401
2438
  getOverrider,
2402
2439
  getOverriderByLayers,
2403
2440
  getParent,
@@ -2456,6 +2493,7 @@ export {
2456
2493
  useOptionalSize,
2457
2494
  useReadVariable,
2458
2495
  useReadVariables,
2496
+ useRenderTarget,
2459
2497
  useTextAttributes,
2460
2498
  useTextContent,
2461
2499
  wrapTextInParagraphWithAttributes
@@ -14,6 +14,7 @@ export interface InstanceProps extends ComponentPropsWithoutRef<"div"> {
14
14
  options?: InstanceOptions;
15
15
  globalManager?: unknown;
16
16
  Tag?: string | ElementType;
17
+ onChangeProps?: (variableId: string, value: unknown) => void;
17
18
  }
18
19
  export declare const Instance: (props: any) => import("react/jsx-runtime").JSX.Element;
19
20
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../../src/nodes/Instance/Instance.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAgB,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAS5C,UAAU,eAAe;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACpE,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,OAAO,UAAU,CAAC,YAAY,CAAC;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;CAC5B;AAoFD,eAAO,MAAM,QAAQ,yDAoBpB,CAAC"}
1
+ {"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../../src/nodes/Instance/Instance.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,WAAW,EAKZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAS5C,UAAU,eAAe;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACpE,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,OAAO,UAAU,CAAC,YAAY,CAAC;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9D;AAsFD,eAAO,MAAM,QAAQ,yDAoBpB,CAAC"}
@@ -15,6 +15,7 @@ export declare const useInstance: (instanceProps: UseInstanceOptions) => {
15
15
  innerManager: any;
16
16
  fragmentId: any;
17
17
  globalManager: import('@graph-state/core').GraphState<import('@graph-state/core').SystemFields, string> | null;
18
+ onChangeProps: (variableId: string, value: unknown) => void;
18
19
  };
19
20
  export {};
20
21
  //# sourceMappingURL=useInstance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInstance.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Instance/hooks/useInstance.ts"],"names":[],"mappings":"AAUA,UAAU,kBAAmB,SAAQ,2BAA2B;CAAG;AAEnE,eAAO,MAAM,WAAW,kBAAmB,kBAAkB;;;;;;;;;;;;;;;CAyC5D,CAAC"}
1
+ {"version":3,"file":"useInstance.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Instance/hooks/useInstance.ts"],"names":[],"mappings":"AAUA,UAAU,kBAAmB,SAAQ,2BAA2B;CAAG;AAEnE,eAAO,MAAM,WAAW,kBAAmB,kBAAkB;;;;;;;;;;;;;;;;CA0C5D,CAAC"}
@@ -1,6 +1,7 @@
1
- import { InstanceProps } from '../index';
1
+ import { InstanceProps } from '../Instance';
2
2
  export declare const useInstanceProps: (instanceProps: InstanceProps) => {
3
3
  props: Omit<any, "_type" | "_id">;
4
4
  cssProps: {};
5
+ onChangeProps: (variableId: string, value: unknown) => void;
5
6
  };
6
7
  //# sourceMappingURL=useInstanceProps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInstanceProps.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Instance/hooks/useInstanceProps.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAiBzC,eAAO,MAAM,gBAAgB,kBAAmB,aAAa;;;CAsE5D,CAAC"}
1
+ {"version":3,"file":"useInstanceProps.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Instance/hooks/useInstanceProps.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAc1D,eAAO,MAAM,gBAAgB,kBAAmB,aAAa;;;gCAyE7B,MAAM,SAAS,OAAO;CAKrD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/nodes/Text/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIlE,UAAU,SAAU,SAAQ,wBAAwB,CAAC,KAAK,CAAC,EAAE,iBAAiB;IAC5E,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAgB9B,CAAC"}
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/nodes/Text/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIlE,UAAU,SAAU,SAAQ,wBAAwB,CAAC,KAAK,CAAC,EAAE,iBAAiB;IAC5E,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAkB9B,CAAC"}
@@ -3,6 +3,11 @@ export interface UseTextAttributes {
3
3
  collectStyle?: boolean;
4
4
  }
5
5
  export declare const useTextAttributes: (layerKey: LinkKey, options?: UseTextAttributes) => {
6
+ events: {
7
+ onClick?: undefined;
8
+ } | {
9
+ onClick: () => void;
10
+ };
6
11
  styles: {};
7
12
  classnames: string | null;
8
13
  content: any;
@@ -1 +1 @@
1
- {"version":3,"file":"useTextAttributes.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Text/hooks/useTextAttributes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAO5C,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,iBAAiB,aAClB,OAAO,YACP,iBAAiB;;;;CAmB5B,CAAC"}
1
+ {"version":3,"file":"useTextAttributes.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Text/hooks/useTextAttributes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAQ5C,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,iBAAiB,aAClB,OAAO,YACP,iBAAiB;;;;;;;;;CAqB5B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"makeSnapshot.d.ts","sourceRoot":"","sources":["../../../src/utils/layer/makeSnapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,mBAAmB,CAAC;AAGxD,wBAAgB,YAAY,CAC1B,aAAa,EAAE,UAAU,EACzB,gBAAgB,EAAE,MAAM;;;;;;SA4EzB"}
1
+ {"version":3,"file":"makeSnapshot.d.ts","sourceRoot":"","sources":["../../../src/utils/layer/makeSnapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,mBAAmB,CAAC;AAGxD,wBAAgB,YAAY,CAC1B,aAAa,EAAE,UAAU,EACzB,gBAAgB,EAAE,MAAM;;;;;;SAoEzB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fragmentsx/render-react",
3
3
  "private": false,
4
- "version": "1.2.1",
4
+ "version": "1.2.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@graph-state/checkers": "^0.1.2",
27
- "@graph-state/core": "^0.13.1",
28
- "@graph-state/react": "^0.8.1",
27
+ "@graph-state/core": "^0.13.2",
28
+ "@graph-state/react": "^0.8.2",
29
29
  "react-use-measure": "^2.1.7",
30
30
  "@fragmentsx/definition": "0.2.0",
31
31
  "@fragmentsx/utils": "0.2.0"