@fragmentsx/render-react 1.2.6 → 1.4.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/hooks/fragment/useFragment.d.ts.map +1 -1
- package/dist/hooks/fragment/useFragmentManager.d.ts +1 -1
- package/dist/hooks/fragment/useFragmentManager.d.ts.map +1 -1
- package/dist/hooks/layer/index.d.ts +2 -1
- package/dist/hooks/layer/index.d.ts.map +1 -1
- package/dist/hooks/layer/useLayerValue.d.ts.map +1 -1
- package/dist/hooks/layer/useLayersValue.d.ts.map +1 -1
- package/dist/hooks/layer/useReadVariable.d.ts +1 -0
- package/dist/hooks/layer/useReadVariable.d.ts.map +1 -1
- package/dist/hooks/layer/useResolvedLayer.d.ts +14 -0
- package/dist/hooks/layer/useResolvedLayer.d.ts.map +1 -0
- package/dist/hooks/layer/useResolvedLayerVariables.d.ts +7 -0
- package/dist/hooks/layer/useResolvedLayerVariables.d.ts.map +1 -0
- package/dist/hooks/layer-styles/useLayerPaint.d.ts +8 -0
- package/dist/hooks/layer-styles/useLayerPaint.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/index.d.ts +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/index.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useImagePaint.d.ts +6 -0
- package/dist/hooks/layer-styles/useLayerStyles/useImagePaint.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerBackground.d.ts +4 -2
- package/dist/hooks/layer-styles/useLayerStyles/useLayerBackground.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerBorder.d.ts +16 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerBorder.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerDisplay.d.ts +2 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerDisplay.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerFlex.d.ts +4 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerFlex.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerLayout.d.ts +10 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerLayout.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerPosition.d.ts +36 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerPosition.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerSize.d.ts +7 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerSize.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerSizeValue.d.ts +9 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerSizeValue.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerTextStyles.d.ts +4 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerTextStyles.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useOptionalSize.d.ts +2 -0
- package/dist/hooks/layer-styles/useLayerStyles/useOptionalSize.d.ts.map +1 -1
- package/dist/hooks/suspense/index.d.ts +3 -0
- package/dist/hooks/suspense/index.d.ts.map +1 -0
- package/dist/hooks/suspense/useSuspenseLoadArea.d.ts +6 -0
- package/dist/hooks/suspense/useSuspenseLoadArea.d.ts.map +1 -0
- package/dist/hooks/suspense/useSuspenseLoadFragment.d.ts +3 -0
- package/dist/hooks/suspense/useSuspenseLoadFragment.d.ts.map +1 -0
- package/dist/hooks/utils/useExtractProps.d.ts +16 -0
- package/dist/hooks/utils/useExtractProps.d.ts.map +1 -0
- package/dist/hooks/utils/useLayerInteractions.d.ts.map +1 -1
- package/dist/index.cjs.js +1471 -668
- package/dist/index.es.js +1474 -671
- package/dist/nodes/Area/Area.d.ts +8 -0
- package/dist/nodes/Area/Area.d.ts.map +1 -1
- package/dist/nodes/Area/hooks/useArea.d.ts +7 -2
- package/dist/nodes/Area/hooks/useArea.d.ts.map +1 -1
- package/dist/nodes/Area/index.d.ts +1 -0
- package/dist/nodes/Area/index.d.ts.map +1 -1
- package/dist/nodes/Collection/Collection.d.ts.map +1 -1
- package/dist/nodes/Collection/hooks/useCollection.d.ts +1 -1
- package/dist/nodes/Collection/hooks/useCollection.d.ts.map +1 -1
- package/dist/nodes/CollectionItem/CollectionItem.d.ts.map +1 -1
- package/dist/nodes/CollectionItem/hooks/useCollection.d.ts +1 -1
- package/dist/nodes/CollectionItem/hooks/useCollection.d.ts.map +1 -1
- package/dist/nodes/CssChunk/hooks/useCssChunk.d.ts.map +1 -1
- package/dist/nodes/Fragment/Fragment.d.ts.map +1 -1
- package/dist/nodes/Frame/hooks/useFrame.d.ts +1 -1
- package/dist/nodes/Instance/Instance.d.ts.map +1 -1
- package/dist/nodes/Instance/hooks/useInstance.d.ts +1 -2
- package/dist/nodes/Instance/hooks/useInstance.d.ts.map +1 -1
- package/dist/nodes/Instance/hooks/useInstanceProps.d.ts +0 -1
- package/dist/nodes/Instance/hooks/useInstanceProps.d.ts.map +1 -1
- package/dist/nodes/Instance/test/array-linking.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/array-linking.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/cardDocuments.d.ts +39 -0
- package/dist/nodes/Instance/test/cardDocuments.d.ts.map +1 -0
- package/dist/nodes/Instance/test/collection-props.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/collection-props.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/collection-schema.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/collection-schema.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/dual-instance.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/dual-instance.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/props-basic.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/props-basic.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/props-drilling.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/props-drilling.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/props-dynamic.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/props-dynamic.browser.test.d.ts.map +1 -0
- package/dist/nodes/Text/hooks/useTextAttributes.d.ts +1 -1
- package/dist/providers/AreaManager.d.ts +3 -0
- package/dist/providers/AreaManager.d.ts.map +1 -0
- package/dist/providers/Scope/index.d.ts.map +1 -1
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/utils/common/index.d.ts +0 -1
- package/dist/utils/common/index.d.ts.map +1 -1
- package/dist/utils/css/buildCssBlock.d.ts +6 -0
- package/dist/utils/css/buildCssBlock.d.ts.map +1 -0
- package/dist/utils/css/buildCssBlock.test.d.ts +2 -0
- package/dist/utils/css/buildCssBlock.test.d.ts.map +1 -0
- package/dist/utils/css/compareRules.d.ts +3 -0
- package/dist/utils/css/compareRules.d.ts.map +1 -0
- package/dist/utils/css/compareRules.test.d.ts +2 -0
- package/dist/utils/css/compareRules.test.d.ts.map +1 -0
- package/dist/utils/css/extractStyleSheet.d.ts +6 -0
- package/dist/utils/css/extractStyleSheet.d.ts.map +1 -0
- package/dist/utils/css/findGroups.d.ts +11 -0
- package/dist/utils/css/findGroups.d.ts.map +1 -0
- package/dist/utils/css/getAllChildren.d.ts +4 -0
- package/dist/utils/css/getAllChildren.d.ts.map +1 -0
- package/dist/utils/css/getAllChildren.test.d.ts +2 -0
- package/dist/utils/css/getAllChildren.test.d.ts.map +1 -0
- package/dist/utils/css/index.d.ts +12 -0
- package/dist/utils/css/index.d.ts.map +1 -0
- package/dist/utils/css/makeCss.d.ts +5 -0
- package/dist/utils/css/makeCss.d.ts.map +1 -0
- package/dist/utils/css/toCSS.d.ts +3 -0
- package/dist/utils/css/toCSS.d.ts.map +1 -0
- package/dist/utils/css/toCSS.test.d.ts +2 -0
- package/dist/utils/css/toCSS.test.d.ts.map +1 -0
- package/dist/utils/css/types.d.ts +5 -0
- package/dist/utils/css/types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/layer/cloneLayer.d.ts.map +1 -1
- package/dist/utils/layer/duplicateLayer.d.ts.map +1 -1
- package/dist/utils/suspense/createSuspenseResource.d.ts +5 -0
- package/dist/utils/suspense/createSuspenseResource.d.ts.map +1 -0
- package/dist/utils/suspense/createSuspenseResource.test.d.ts +2 -0
- package/dist/utils/suspense/createSuspenseResource.test.d.ts.map +1 -0
- package/dist/utils/suspense/index.d.ts +4 -0
- package/dist/utils/suspense/index.d.ts.map +1 -0
- package/dist/utils/suspense/suspenseCache.d.ts +4 -0
- package/dist/utils/suspense/suspenseCache.d.ts.map +1 -0
- package/dist/utils/suspense/suspenseCache.test.d.ts +2 -0
- package/dist/utils/suspense/suspenseCache.test.d.ts.map +1 -0
- package/dist/utils/variables/index.d.ts +1 -1
- package/dist/utils/variables/index.d.ts.map +1 -1
- package/dist/utils/variables/toCssCustomProperties.d.ts +7 -0
- package/dist/utils/variables/toCssCustomProperties.d.ts.map +1 -0
- package/package.json +6 -5
- package/dist/hooks/layer/useExtractProps.d.ts +0 -9
- package/dist/hooks/layer/useExtractProps.d.ts.map +0 -1
- package/dist/hooks/layer/useLayerCssVariable.d.ts +0 -8
- package/dist/hooks/layer/useLayerCssVariable.d.ts.map +0 -1
- package/dist/utils/common/loadFragmentManager.d.ts +0 -3
- package/dist/utils/common/loadFragmentManager.d.ts.map +0 -1
- package/dist/utils/variables/getCssVariables.d.ts +0 -3
- package/dist/utils/variables/getCssVariables.d.ts.map +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { createContext, useContext, useReducer, useRef, useEffect, useCallback,
|
|
2
|
-
import { definition, getNormalizeLayer as getNormalizeLayer$1, isVariableLink as isVariableLink$1, parseLayerField } from "@fragmentsx/definition";
|
|
1
|
+
import { createContext, useContext, useMemo, useReducer, useRef, useEffect, useCallback, useState, memo, Suspense } from "react";
|
|
2
|
+
import { definition, getNormalizeLayer as getNormalizeLayer$1, isVariableLink as isVariableLink$1, parseLayerField, isLink as isLink$1 } from "@fragmentsx/definition";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { cleanGraph, generateId, getKey as getKey$1, isValue, isObject, pick, toPx, setKey as setKey$1, toKebabCase, set, isPrimitive, get, omit, noop, isFiniteNumber, hashGenerator as hashGenerator$1, isBrowser as isBrowser$1 } from "@fragmentsx/utils";
|
|
5
|
+
import { keyOfEntity, isPartialKey, entityOfKey, isLinkKey } from "@graph-state/core";
|
|
4
6
|
import { useGraph, useGraphStack } from "@graph-state/react";
|
|
5
|
-
import {
|
|
6
|
-
import { entityOfKey, keyOfEntity, isPartialKey, isLinkKey } from "@graph-state/core";
|
|
7
|
+
import { createAreaManager } from "@fragmentsx/client-core";
|
|
7
8
|
const GlobalManagerContext = createContext(null);
|
|
8
9
|
const GlobalManagerProvider = GlobalManagerContext.Provider;
|
|
9
10
|
const FragmentContext = createContext({
|
|
@@ -22,35 +23,9 @@ const RenderTargetContext = createContext(
|
|
|
22
23
|
definition.renderTarget.document
|
|
23
24
|
);
|
|
24
25
|
const RenderTargetProvider = RenderTargetContext.Provider;
|
|
26
|
+
const AreaManagerContext = createContext(null);
|
|
27
|
+
const AreaManagerProvider = AreaManagerContext.Provider;
|
|
25
28
|
const ScopeContext = createContext([]);
|
|
26
|
-
const useGlobalManager = (globalManager) => {
|
|
27
|
-
var _a, _b;
|
|
28
|
-
const currentGlobalManager = useContext(GlobalManagerContext);
|
|
29
|
-
const resultManager = globalManager ?? currentGlobalManager;
|
|
30
|
-
const [fragmentsGraph] = useGraph(
|
|
31
|
-
resultManager,
|
|
32
|
-
(_a = resultManager == null ? void 0 : resultManager.$fragments) == null ? void 0 : _a.key
|
|
33
|
-
);
|
|
34
|
-
const queryFragmentManager = (id) => {
|
|
35
|
-
var _a2, _b2;
|
|
36
|
-
return (_b2 = (_a2 = resultManager == null ? void 0 : resultManager.$load) == null ? void 0 : _a2.loadFragment) == null ? void 0 : _b2.call(_a2, id);
|
|
37
|
-
};
|
|
38
|
-
const queryArea = (id) => {
|
|
39
|
-
var _a2, _b2;
|
|
40
|
-
return (_b2 = (_a2 = resultManager == null ? void 0 : resultManager.$load) == null ? void 0 : _a2.loadArea) == null ? void 0 : _b2.call(_a2, id);
|
|
41
|
-
};
|
|
42
|
-
const setRenderTarget = (value) => {
|
|
43
|
-
resultManager == null ? void 0 : resultManager.setRenderTarget(value);
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
46
|
-
fragmentsGraph,
|
|
47
|
-
manager: resultManager,
|
|
48
|
-
queryFragmentManager,
|
|
49
|
-
queryArea,
|
|
50
|
-
getFragmentManager: ((_b = resultManager == null ? void 0 : resultManager.$fragments) == null ? void 0 : _b.getManager) ?? noop,
|
|
51
|
-
setRenderTarget
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
29
|
const Scope = ({
|
|
55
30
|
value,
|
|
56
31
|
children,
|
|
@@ -58,9 +33,11 @@ const Scope = ({
|
|
|
58
33
|
layerKey
|
|
59
34
|
}) => {
|
|
60
35
|
var _a, _b;
|
|
61
|
-
const { manager: globalManager } = useGlobalManager();
|
|
62
36
|
const currentScope = useContext(ScopeContext) ?? [];
|
|
63
|
-
const nextScope =
|
|
37
|
+
const nextScope = useMemo(
|
|
38
|
+
() => [...currentScope, value],
|
|
39
|
+
[currentScope, value]
|
|
40
|
+
);
|
|
64
41
|
(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.registerScope) == null ? void 0 : _b.call(_a, layerKey, value);
|
|
65
42
|
return /* @__PURE__ */ jsx(ScopeContext.Provider, { value: nextScope, children });
|
|
66
43
|
};
|
|
@@ -71,191 +48,6 @@ const getOverrider = (manager, layerEntity) => {
|
|
|
71
48
|
const layer = manager.resolve(layerEntity);
|
|
72
49
|
return manager.resolve(getKey(layer == null ? void 0 : layer.overrideFrom) ?? layerEntity);
|
|
73
50
|
};
|
|
74
|
-
const getLayer = (manager, layer, options) => {
|
|
75
|
-
if (!manager || !layer) return null;
|
|
76
|
-
const layerKey = manager.keyOfEntity(layer);
|
|
77
|
-
const layerData = manager.resolve(layerKey);
|
|
78
|
-
const overrider = getOverrider(manager, layerKey);
|
|
79
|
-
return getNormalizeLayer$1(layerData, overrider, options == null ? void 0 : options.withFallback);
|
|
80
|
-
};
|
|
81
|
-
const getNormalizeLayer = (layerKey, manager, options) => {
|
|
82
|
-
const layer = manager == null ? void 0 : manager.resolve(layerKey);
|
|
83
|
-
const parsedLayer = getLayer(manager, layerKey, options);
|
|
84
|
-
return {
|
|
85
|
-
layerKey,
|
|
86
|
-
rawLayer: layer,
|
|
87
|
-
layer: parsedLayer
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
const useNormalizeLayer = (layerKey, manager, options) => {
|
|
91
|
-
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
92
|
-
const resultManager = manager ?? fragmentManager;
|
|
93
|
-
if (!resultManager) {
|
|
94
|
-
return {
|
|
95
|
-
layerKey,
|
|
96
|
-
rawLayer: null,
|
|
97
|
-
layer: null
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
return getNormalizeLayer(layerKey, resultManager, options);
|
|
101
|
-
};
|
|
102
|
-
const useNormalizeLayers = (layerKeys, manager, options) => {
|
|
103
|
-
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
104
|
-
const resultManager = manager ?? fragmentManager;
|
|
105
|
-
return layerKeys.map(
|
|
106
|
-
(layerKey) => getNormalizeLayer(layerKey, resultManager, options)
|
|
107
|
-
);
|
|
108
|
-
};
|
|
109
|
-
function useForceUpdate() {
|
|
110
|
-
return useReducer(() => ({}), {});
|
|
111
|
-
}
|
|
112
|
-
const extractVariableValue = (input, variableId) => {
|
|
113
|
-
if (isObject(input)) {
|
|
114
|
-
if (variableId in input) {
|
|
115
|
-
return input[variableId];
|
|
116
|
-
}
|
|
117
|
-
for (let key in input) {
|
|
118
|
-
if (input.hasOwnProperty(key)) {
|
|
119
|
-
const result = extractVariableValue(input[key], variableId);
|
|
120
|
-
if (result !== void 0) {
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return void 0;
|
|
127
|
-
};
|
|
128
|
-
function deepMerge(a, b) {
|
|
129
|
-
if (!isObject(a) || !isObject(b)) return a;
|
|
130
|
-
const result = { ...b };
|
|
131
|
-
for (const [key, value] of Object.entries(a)) {
|
|
132
|
-
if (key in result && typeof result[key] === "object" && typeof value === "object") {
|
|
133
|
-
result[key] = deepMerge(value, result[key]);
|
|
134
|
-
} else {
|
|
135
|
-
result[key] = value;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return result;
|
|
139
|
-
}
|
|
140
|
-
const useReadVariable = (variableKey, customScopes) => {
|
|
141
|
-
const contextScopes = useContext(ScopeContext);
|
|
142
|
-
const scopes = customScopes ?? contextScopes;
|
|
143
|
-
const unmountAbortController = useRef(new AbortController());
|
|
144
|
-
const [dep, forceUpdate] = useForceUpdate();
|
|
145
|
-
useEffect(
|
|
146
|
-
() => () => {
|
|
147
|
-
var _a;
|
|
148
|
-
(_a = unmountAbortController.current) == null ? void 0 : _a.abort("unmount");
|
|
149
|
-
},
|
|
150
|
-
[]
|
|
151
|
-
);
|
|
152
|
-
const extractVariableDefaultValue = (manager, variableEntity) => {
|
|
153
|
-
const variableLayer = manager.resolve(variableEntity);
|
|
154
|
-
if ((variableLayer == null ? void 0 : variableLayer.type) !== definition.variableType.Object)
|
|
155
|
-
return variableLayer == null ? void 0 : variableLayer.defaultValue;
|
|
156
|
-
return Object.values((variableLayer == null ? void 0 : variableLayer.fields) ?? {}).reduce(
|
|
157
|
-
(acc, fieldLink) => {
|
|
158
|
-
var _a;
|
|
159
|
-
if (!!fieldLink && isVariableLink$1(fieldLink)) {
|
|
160
|
-
const _id = (_a = entityOfKey(fieldLink)) == null ? void 0 : _a._id;
|
|
161
|
-
if (_id) {
|
|
162
|
-
acc[_id] = extractVariableDefaultValue(manager, fieldLink);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return acc;
|
|
166
|
-
},
|
|
167
|
-
{}
|
|
168
|
-
);
|
|
169
|
-
};
|
|
170
|
-
const resolveVariableLayer = (manager, variableLink, customProps) => {
|
|
171
|
-
var _a, _b;
|
|
172
|
-
const variableLayer = (_a = getNormalizeLayer(variableLink, manager)) == null ? void 0 : _a.layer;
|
|
173
|
-
if (!variableLayer) return null;
|
|
174
|
-
if ((variableLayer == null ? void 0 : variableLayer.type) === definition.variableType.Array) {
|
|
175
|
-
const definitionLayer = manager.resolve(variableLayer == null ? void 0 : variableLayer.definition);
|
|
176
|
-
if (!((_b = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _b.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== definition.variableType.Object)
|
|
177
|
-
return variableLayer;
|
|
178
|
-
const definitionDefaultValue = extractVariableDefaultValue(
|
|
179
|
-
manager,
|
|
180
|
-
definitionLayer
|
|
181
|
-
);
|
|
182
|
-
const customValue = customProps == null ? void 0 : customProps[variableLayer == null ? void 0 : variableLayer._id];
|
|
183
|
-
return {
|
|
184
|
-
...variableLayer,
|
|
185
|
-
defaultValue: (variableLayer == null ? void 0 : variableLayer.defaultValue).map((item, index) => {
|
|
186
|
-
const customItemValue = Array.isArray(customValue) ? customValue.at(index) : null;
|
|
187
|
-
return deepMerge(
|
|
188
|
-
customItemValue ? { ...item, ...customItemValue } : item,
|
|
189
|
-
definitionDefaultValue
|
|
190
|
-
);
|
|
191
|
-
})
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
return variableLayer;
|
|
195
|
-
};
|
|
196
|
-
const readVariable = (variableKey2) => {
|
|
197
|
-
var _a, _b, _c, _d, _e;
|
|
198
|
-
const variableId = (_a = entityOfKey(variableKey2)) == null ? void 0 : _a._id;
|
|
199
|
-
if (!isVariableLink$1(variableKey2)) {
|
|
200
|
-
return {
|
|
201
|
-
value: null,
|
|
202
|
-
layer: null
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
let instanceScope = scopes.findLast(
|
|
206
|
-
(scope) => {
|
|
207
|
-
var _a2;
|
|
208
|
-
return (scope == null ? void 0 : scope.type) === definition.scopeTypes.InstanceScope && !!((_a2 = scope.documentManager) == null ? void 0 : _a2.resolve(variableKey2));
|
|
209
|
-
}
|
|
210
|
-
);
|
|
211
|
-
if (!instanceScope) {
|
|
212
|
-
instanceScope = scopes.find(
|
|
213
|
-
(scope) => (scope == null ? void 0 : scope.type) === definition.scopeTypes.InstanceScope
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
const variableLayer = resolveVariableLayer(
|
|
217
|
-
instanceScope == null ? void 0 : instanceScope.documentManager,
|
|
218
|
-
variableKey2
|
|
219
|
-
);
|
|
220
|
-
(_c = instanceScope == null ? void 0 : instanceScope.documentManager) == null ? void 0 : _c.subscribe(variableKey2, forceUpdate, {
|
|
221
|
-
signal: (_b = unmountAbortController.current) == null ? void 0 : _b.signal
|
|
222
|
-
});
|
|
223
|
-
let instanceProp = (_d = instanceScope == null ? void 0 : instanceScope.props) == null ? void 0 : _d[variableId];
|
|
224
|
-
if (Array.isArray(instanceProp)) {
|
|
225
|
-
instanceProp = instanceProp.map(
|
|
226
|
-
(rawProp, index) => {
|
|
227
|
-
var _a2;
|
|
228
|
-
return deepMerge(rawProp, (_a2 = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a2.at(index));
|
|
229
|
-
}
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
const lastCollectionItem = scopes.findLast(
|
|
233
|
-
(scope) => (scope == null ? void 0 : scope.type) === definition.scopeTypes.CollectionItemScope
|
|
234
|
-
);
|
|
235
|
-
resolveVariableLayer(
|
|
236
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.manager,
|
|
237
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition,
|
|
238
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.value
|
|
239
|
-
);
|
|
240
|
-
const collectionItemProp = isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_e = entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _e._id) === variableId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue(lastCollectionItem == null ? void 0 : lastCollectionItem.value, variableId);
|
|
241
|
-
const currentValue = variableKey2 === instanceProp ? null : collectionItemProp ?? instanceProp ?? null;
|
|
242
|
-
const required = (variableLayer == null ? void 0 : variableLayer.required) ?? false;
|
|
243
|
-
const defaultValue = (variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
|
|
244
|
-
const resultValue = required ? currentValue : currentValue ?? collectionItemProp ?? defaultValue;
|
|
245
|
-
if (isVariableLink$1(resultValue)) {
|
|
246
|
-
return readVariable(resultValue);
|
|
247
|
-
}
|
|
248
|
-
return {
|
|
249
|
-
value: resultValue,
|
|
250
|
-
layer: variableLayer
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
|
-
const result = readVariable(variableKey);
|
|
254
|
-
return {
|
|
255
|
-
...result,
|
|
256
|
-
readVariable
|
|
257
|
-
};
|
|
258
|
-
};
|
|
259
51
|
const getParent = (manager, layerKey) => {
|
|
260
52
|
const layer = manager.resolve(layerKey);
|
|
261
53
|
return manager.resolve(getKey(layer == null ? void 0 : layer.parent) ?? null);
|
|
@@ -431,6 +223,9 @@ const cloneLayer = (manager, layer, externalProps = {}) => {
|
|
|
431
223
|
layerGraph,
|
|
432
224
|
(key, value, history) => {
|
|
433
225
|
const isRoot = history.length <= 2;
|
|
226
|
+
if ((value == null ? void 0 : value._type) === definition.nodes.Instance && key === "props") {
|
|
227
|
+
return cleanGraph(value);
|
|
228
|
+
}
|
|
434
229
|
if (!!value && n(value) && !IGNORE_TYPES.includes(value._type)) {
|
|
435
230
|
const nextId = generateId();
|
|
436
231
|
const parentFromValue = getKey$1(value.parent);
|
|
@@ -667,6 +462,41 @@ const moveChildren = (manager, targetKey, to, index) => {
|
|
|
667
462
|
spliceChildren(manager, targetParent, targetKey);
|
|
668
463
|
}
|
|
669
464
|
};
|
|
465
|
+
const getLayer = (manager, layer, options) => {
|
|
466
|
+
if (!manager || !layer) return null;
|
|
467
|
+
const layerKey = manager.keyOfEntity(layer);
|
|
468
|
+
const layerData = manager.resolve(layerKey);
|
|
469
|
+
const overrider = getOverrider(manager, layerKey);
|
|
470
|
+
return getNormalizeLayer$1(layerData, overrider, options == null ? void 0 : options.withFallback);
|
|
471
|
+
};
|
|
472
|
+
const getNormalizeLayer = (layerKey, manager, options) => {
|
|
473
|
+
const layer = manager == null ? void 0 : manager.resolve(layerKey);
|
|
474
|
+
const parsedLayer = getLayer(manager, layerKey, options);
|
|
475
|
+
return {
|
|
476
|
+
layerKey,
|
|
477
|
+
rawLayer: layer,
|
|
478
|
+
layer: parsedLayer
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
const useNormalizeLayer = (layerKey, manager, options) => {
|
|
482
|
+
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
483
|
+
const resultManager = manager ?? fragmentManager;
|
|
484
|
+
if (!resultManager) {
|
|
485
|
+
return {
|
|
486
|
+
layerKey,
|
|
487
|
+
rawLayer: null,
|
|
488
|
+
layer: null
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
return getNormalizeLayer(layerKey, resultManager, options);
|
|
492
|
+
};
|
|
493
|
+
const useNormalizeLayers = (layerKeys, manager, options) => {
|
|
494
|
+
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
495
|
+
const resultManager = manager ?? fragmentManager;
|
|
496
|
+
return layerKeys.map(
|
|
497
|
+
(layerKey) => getNormalizeLayer(layerKey, resultManager, options)
|
|
498
|
+
);
|
|
499
|
+
};
|
|
670
500
|
const calcBackground = (manager, layerKey) => {
|
|
671
501
|
manager.resolve(layerKey);
|
|
672
502
|
const { layer } = getNormalizeLayer(layerKey, manager);
|
|
@@ -779,23 +609,21 @@ const calcLinearGradient = (angle, values) => {
|
|
|
779
609
|
}
|
|
780
610
|
return `linear-gradient(${angle}deg, ${parts.join(", ")})`;
|
|
781
611
|
};
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
var _a, _b;
|
|
788
|
-
return value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
|
|
612
|
+
const getOverriderByLayers = (layerKey, layers) => {
|
|
613
|
+
return layers.find((l) => {
|
|
614
|
+
var _a;
|
|
615
|
+
return (_a = l == null ? void 0 : l.overrides) == null ? void 0 : _a.includes(layerKey);
|
|
616
|
+
});
|
|
789
617
|
};
|
|
790
|
-
const
|
|
791
|
-
return Object.entries(
|
|
618
|
+
const toCssCustomProperties = (props) => {
|
|
619
|
+
return Object.entries(props).reduce(
|
|
792
620
|
(acc, [key, value]) => {
|
|
793
621
|
var _a, _b;
|
|
794
|
-
if (isVariableLink(value)) {
|
|
622
|
+
if (isVariableLink$1(value)) {
|
|
795
623
|
const nestedVariableId = (_a = entityOfKey(value)) == null ? void 0 : _a._id;
|
|
796
624
|
value = `var(--${nestedVariableId})`;
|
|
797
625
|
}
|
|
798
|
-
if (
|
|
626
|
+
if (typeof value === "string" && ((_b = value.startsWith) == null ? void 0 : _b.call(value, "http"))) {
|
|
799
627
|
value = `url("${value}")`;
|
|
800
628
|
}
|
|
801
629
|
acc[`--${key}`] = value;
|
|
@@ -804,12 +632,6 @@ const getCssVariables = (props) => {
|
|
|
804
632
|
{}
|
|
805
633
|
);
|
|
806
634
|
};
|
|
807
|
-
const getOverriderByLayers = (layerKey, layers) => {
|
|
808
|
-
return layers.find((l) => {
|
|
809
|
-
var _a;
|
|
810
|
-
return (_a = l == null ? void 0 : l.overrides) == null ? void 0 : _a.includes(layerKey);
|
|
811
|
-
});
|
|
812
|
-
};
|
|
813
635
|
const declareFragmentProperty = (manager, property, fragmentLink = manager.$fragment.root) => {
|
|
814
636
|
const propertyLayer = createLayer(property);
|
|
815
637
|
if (propertyLayer && "type" in propertyLayer) {
|
|
@@ -861,21 +683,48 @@ function getHydratedData(id) {
|
|
|
861
683
|
return null;
|
|
862
684
|
}
|
|
863
685
|
}
|
|
864
|
-
const
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
686
|
+
const createSuspenseResource = (key, valueOrPromise, cache) => {
|
|
687
|
+
if (cache.has(key)) return cache.get(key);
|
|
688
|
+
if (!(valueOrPromise instanceof Promise)) {
|
|
689
|
+
const resource2 = {
|
|
690
|
+
read() {
|
|
691
|
+
return valueOrPromise;
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
cache.set(key, resource2);
|
|
695
|
+
return resource2;
|
|
696
|
+
}
|
|
697
|
+
let status = "pending";
|
|
698
|
+
let result;
|
|
699
|
+
let error;
|
|
700
|
+
const suspender = valueOrPromise.then(
|
|
701
|
+
(r) => {
|
|
702
|
+
status = "success";
|
|
703
|
+
result = r;
|
|
704
|
+
},
|
|
705
|
+
(e) => {
|
|
706
|
+
status = "error";
|
|
707
|
+
error = e;
|
|
872
708
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
709
|
+
);
|
|
710
|
+
const resource = {
|
|
711
|
+
read() {
|
|
712
|
+
if (status === "pending") throw suspender;
|
|
713
|
+
if (status === "error") throw error;
|
|
714
|
+
return result;
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
cache.set(key, resource);
|
|
718
|
+
return resource;
|
|
719
|
+
};
|
|
720
|
+
const globalCache = /* @__PURE__ */ new WeakMap();
|
|
721
|
+
const getSuspenseCache = (manager) => {
|
|
722
|
+
let cache = globalCache.get(manager);
|
|
723
|
+
if (!cache) {
|
|
724
|
+
cache = /* @__PURE__ */ new Map();
|
|
725
|
+
globalCache.set(manager, cache);
|
|
877
726
|
}
|
|
878
|
-
return
|
|
727
|
+
return cache;
|
|
879
728
|
};
|
|
880
729
|
const duplicateLayer = (manager, layer) => {
|
|
881
730
|
var _a;
|
|
@@ -884,6 +733,9 @@ const duplicateLayer = (manager, layer) => {
|
|
|
884
733
|
const linkedMap = {};
|
|
885
734
|
const nextLayer = nodeWalker(layerGraph, (key, value, history) => {
|
|
886
735
|
const nextId = generateId();
|
|
736
|
+
if ((value == null ? void 0 : value._type) === definition.nodes.Instance && key === "props") {
|
|
737
|
+
return cleanGraph(value);
|
|
738
|
+
}
|
|
887
739
|
if (!!value && n(value)) {
|
|
888
740
|
linkedMap[keyOfEntity(value)] = keyOfEntity({ ...value, _id: nextId });
|
|
889
741
|
const linkedParent = linkedMap == null ? void 0 : linkedMap[getKey$1(value.parent)];
|
|
@@ -950,6 +802,14 @@ const wrapTextInParagraphWithAttributes = (text, attributes) => {
|
|
|
950
802
|
).map(([key, value]) => `${toKebabCase(key)}: ${value}`).join("; ");
|
|
951
803
|
return `<p style="${style}">${text}</p>`;
|
|
952
804
|
};
|
|
805
|
+
const isVariableLink = (value) => {
|
|
806
|
+
var _a;
|
|
807
|
+
return isLink(value) && ((_a = value == null ? void 0 : value.split(":")) == null ? void 0 : _a.at(0)) === definition.nodes.Variable;
|
|
808
|
+
};
|
|
809
|
+
const isLink = (value) => {
|
|
810
|
+
var _a, _b;
|
|
811
|
+
return value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
|
|
812
|
+
};
|
|
953
813
|
const layerFieldSetter = (manager, layerKey, fieldKey, currentValue) => (value, options) => {
|
|
954
814
|
var _a;
|
|
955
815
|
const { success, output } = parseLayerField(
|
|
@@ -978,26 +838,474 @@ const layerFieldSetter = (manager, layerKey, fieldKey, currentValue) => (value,
|
|
|
978
838
|
);
|
|
979
839
|
}
|
|
980
840
|
};
|
|
981
|
-
const
|
|
841
|
+
const EMPTY_RESOLVED$1 = {
|
|
842
|
+
layerKey: null,
|
|
843
|
+
rawLayer: null,
|
|
844
|
+
layer: null,
|
|
845
|
+
isOverride: false
|
|
846
|
+
};
|
|
847
|
+
const useResolvedLayer = (layerKey, options) => {
|
|
848
|
+
const { manager } = useContext(FragmentContext);
|
|
849
|
+
const resultManager = (options == null ? void 0 : options.manager) ?? manager;
|
|
850
|
+
const key = keyOfEntity(layerKey);
|
|
851
|
+
useGraph(resultManager, key);
|
|
852
|
+
if (!resultManager || !key) {
|
|
853
|
+
return EMPTY_RESOLVED$1;
|
|
854
|
+
}
|
|
855
|
+
const rawLayer = resultManager.resolve(key);
|
|
856
|
+
const overrider = getOverrider(resultManager, key);
|
|
857
|
+
const layer = getNormalizeLayer$1(rawLayer, overrider, options == null ? void 0 : options.withFallback);
|
|
858
|
+
let isOverride = false;
|
|
859
|
+
if (!(options == null ? void 0 : options.skipOverrideCheck)) {
|
|
860
|
+
isOverride = !isPartOfPrimary(resultManager, key);
|
|
861
|
+
}
|
|
862
|
+
return { layerKey: key, rawLayer, layer, isOverride };
|
|
863
|
+
};
|
|
864
|
+
function useForceUpdate() {
|
|
865
|
+
return useReducer(() => ({}), {});
|
|
866
|
+
}
|
|
867
|
+
const EMPTY_RESOLVED = {
|
|
868
|
+
values: {},
|
|
869
|
+
cssVariableValues: {},
|
|
870
|
+
rawValues: {}
|
|
871
|
+
};
|
|
872
|
+
const extractVariableValue$1 = (input, variableId) => {
|
|
873
|
+
if (isObject(input)) {
|
|
874
|
+
if (variableId in input) return input[variableId];
|
|
875
|
+
for (const key in input) {
|
|
876
|
+
if (input.hasOwnProperty(key)) {
|
|
877
|
+
const result = extractVariableValue$1(input[key], variableId);
|
|
878
|
+
if (result !== void 0) return result;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return void 0;
|
|
883
|
+
};
|
|
884
|
+
function deepMerge$1(a, b) {
|
|
885
|
+
if (!isObject(a) || !isObject(b)) return a;
|
|
886
|
+
const result = { ...b };
|
|
887
|
+
for (const [key, value] of Object.entries(a)) {
|
|
888
|
+
if (key in result && typeof result[key] === "object" && typeof value === "object") {
|
|
889
|
+
result[key] = deepMerge$1(value, result[key]);
|
|
890
|
+
} else {
|
|
891
|
+
result[key] = value;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return result;
|
|
895
|
+
}
|
|
896
|
+
const useResolvedLayerVariables = (layer, rawLayer, customScopes) => {
|
|
982
897
|
var _a;
|
|
983
|
-
const
|
|
984
|
-
const
|
|
985
|
-
const
|
|
898
|
+
const contextScopes = useContext(ScopeContext);
|
|
899
|
+
const scopes = customScopes ?? contextScopes;
|
|
900
|
+
const subscriptions = useRef([]);
|
|
901
|
+
const [dep, forceUpdate] = useForceUpdate();
|
|
902
|
+
useEffect(() => {
|
|
903
|
+
const controller = new AbortController();
|
|
904
|
+
let ready = false;
|
|
905
|
+
const update = () => {
|
|
906
|
+
if (!ready) return;
|
|
907
|
+
forceUpdate();
|
|
908
|
+
};
|
|
909
|
+
for (const { manager, key } of subscriptions.current) {
|
|
910
|
+
manager.subscribe(key, update, { signal: controller.signal });
|
|
911
|
+
}
|
|
912
|
+
ready = true;
|
|
913
|
+
return () => controller.abort();
|
|
914
|
+
});
|
|
915
|
+
if (!layer) {
|
|
916
|
+
subscriptions.current = [];
|
|
917
|
+
return EMPTY_RESOLVED;
|
|
918
|
+
}
|
|
919
|
+
const values = {};
|
|
920
|
+
const cssVariableValues = {};
|
|
921
|
+
const rawValues = {};
|
|
922
|
+
const readVariable = (variableKey) => {
|
|
923
|
+
var _a2, _b, _c;
|
|
924
|
+
const variableId = (_a2 = entityOfKey(variableKey)) == null ? void 0 : _a2._id;
|
|
925
|
+
if (!isVariableLink$1(variableKey)) {
|
|
926
|
+
return { value: null, layer: null };
|
|
927
|
+
}
|
|
928
|
+
let instanceScope = scopes.findLast(
|
|
929
|
+
(scope) => {
|
|
930
|
+
var _a3;
|
|
931
|
+
return (scope == null ? void 0 : scope.type) === definition.scopeTypes.InstanceScope && !!((_a3 = scope.documentManager) == null ? void 0 : _a3.resolve(variableKey));
|
|
932
|
+
}
|
|
933
|
+
);
|
|
934
|
+
if (!instanceScope) {
|
|
935
|
+
instanceScope = scopes.find(
|
|
936
|
+
(scope) => (scope == null ? void 0 : scope.type) === definition.scopeTypes.InstanceScope
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
const resolveVariableLayer = (manager, variableLink, customProps) => {
|
|
940
|
+
var _a3, _b2;
|
|
941
|
+
const variableLayer2 = (_a3 = getNormalizeLayer(variableLink, manager)) == null ? void 0 : _a3.layer;
|
|
942
|
+
if (!variableLayer2) return null;
|
|
943
|
+
if ((variableLayer2 == null ? void 0 : variableLayer2.type) === definition.variableType.Array) {
|
|
944
|
+
const definitionLayer = manager.resolve(variableLayer2 == null ? void 0 : variableLayer2.definition);
|
|
945
|
+
if (!((_b2 = variableLayer2 == null ? void 0 : variableLayer2.defaultValue) == null ? void 0 : _b2.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== definition.variableType.Object)
|
|
946
|
+
return variableLayer2;
|
|
947
|
+
const extractVariableDefaultValue = (mgr, varEntity) => {
|
|
948
|
+
const varLayer = mgr.resolve(varEntity);
|
|
949
|
+
if ((varLayer == null ? void 0 : varLayer.type) !== definition.variableType.Object)
|
|
950
|
+
return varLayer == null ? void 0 : varLayer.defaultValue;
|
|
951
|
+
return Object.values((varLayer == null ? void 0 : varLayer.fields) ?? {}).reduce(
|
|
952
|
+
(acc, fieldLink) => {
|
|
953
|
+
var _a4;
|
|
954
|
+
if (!!fieldLink && isVariableLink$1(fieldLink)) {
|
|
955
|
+
const _id = (_a4 = entityOfKey(fieldLink)) == null ? void 0 : _a4._id;
|
|
956
|
+
if (_id) acc[_id] = extractVariableDefaultValue(mgr, fieldLink);
|
|
957
|
+
}
|
|
958
|
+
return acc;
|
|
959
|
+
},
|
|
960
|
+
{}
|
|
961
|
+
);
|
|
962
|
+
};
|
|
963
|
+
const definitionDefaultValue = extractVariableDefaultValue(
|
|
964
|
+
manager,
|
|
965
|
+
definitionLayer
|
|
966
|
+
);
|
|
967
|
+
const customValue = customProps == null ? void 0 : customProps[variableLayer2 == null ? void 0 : variableLayer2._id];
|
|
968
|
+
return {
|
|
969
|
+
...variableLayer2,
|
|
970
|
+
defaultValue: variableLayer2.defaultValue.map(
|
|
971
|
+
(item, index) => {
|
|
972
|
+
const customItemValue = Array.isArray(customValue) ? customValue.at(index) : null;
|
|
973
|
+
return deepMerge$1(
|
|
974
|
+
customItemValue ? { ...item, ...customItemValue } : item,
|
|
975
|
+
definitionDefaultValue
|
|
976
|
+
);
|
|
977
|
+
}
|
|
978
|
+
)
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
return variableLayer2;
|
|
982
|
+
};
|
|
983
|
+
const variableLayer = resolveVariableLayer(
|
|
984
|
+
instanceScope == null ? void 0 : instanceScope.documentManager,
|
|
985
|
+
variableKey
|
|
986
|
+
);
|
|
987
|
+
if ((instanceScope == null ? void 0 : instanceScope.documentManager) && variableKey) {
|
|
988
|
+
subscriptions.current.push({
|
|
989
|
+
manager: instanceScope.documentManager,
|
|
990
|
+
key: variableKey
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
let instanceProp = variableId ? (_b = instanceScope == null ? void 0 : instanceScope.props) == null ? void 0 : _b[variableId] : void 0;
|
|
994
|
+
if (Array.isArray(instanceProp)) {
|
|
995
|
+
instanceProp = instanceProp.map(
|
|
996
|
+
(rawProp, index) => {
|
|
997
|
+
var _a3;
|
|
998
|
+
return deepMerge$1(rawProp, (_a3 = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a3.at(index));
|
|
999
|
+
}
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
const lastCollectionItem = scopes.findLast(
|
|
1003
|
+
(scope) => (scope == null ? void 0 : scope.type) === definition.scopeTypes.CollectionItemScope
|
|
1004
|
+
);
|
|
1005
|
+
resolveVariableLayer(
|
|
1006
|
+
lastCollectionItem == null ? void 0 : lastCollectionItem.manager,
|
|
1007
|
+
lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition,
|
|
1008
|
+
lastCollectionItem == null ? void 0 : lastCollectionItem.value
|
|
1009
|
+
);
|
|
1010
|
+
const collectionItemProp = isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_c = entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _c._id) === variableId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue$1(lastCollectionItem == null ? void 0 : lastCollectionItem.value, variableId);
|
|
1011
|
+
const currentValue = variableKey === instanceProp ? null : collectionItemProp ?? instanceProp ?? null;
|
|
1012
|
+
const required = (variableLayer == null ? void 0 : variableLayer.required) ?? false;
|
|
1013
|
+
const defaultValue = (variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
|
|
1014
|
+
const resultValue = required ? currentValue : currentValue ?? collectionItemProp ?? defaultValue;
|
|
1015
|
+
if (isVariableLink$1(resultValue)) {
|
|
1016
|
+
return readVariable(resultValue);
|
|
1017
|
+
}
|
|
1018
|
+
return { value: resultValue, layer: variableLayer };
|
|
1019
|
+
};
|
|
1020
|
+
const resolveField = (fieldPath, value, raw) => {
|
|
1021
|
+
var _a2;
|
|
1022
|
+
rawValues[fieldPath] = raw;
|
|
1023
|
+
if (isVariableLink$1(value)) {
|
|
1024
|
+
const resolved = readVariable(value);
|
|
1025
|
+
values[fieldPath] = resolved.value ?? value;
|
|
1026
|
+
const variableId = (_a2 = entityOfKey(value)) == null ? void 0 : _a2._id;
|
|
1027
|
+
cssVariableValues[fieldPath] = `var(--${variableId}, ${transformCssValue(
|
|
1028
|
+
resolved.value ?? value
|
|
1029
|
+
)})`;
|
|
1030
|
+
} else {
|
|
1031
|
+
values[fieldPath] = value;
|
|
1032
|
+
cssVariableValues[fieldPath] = transformCssValue(value);
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
subscriptions.current = [];
|
|
1036
|
+
for (const [field, value] of Object.entries(layer)) {
|
|
1037
|
+
resolveField(field, value, rawLayer == null ? void 0 : rawLayer[field]);
|
|
1038
|
+
if (isObject(value) && !isVariableLink$1(value)) {
|
|
1039
|
+
for (const [nestedField, nestedValue] of Object.entries(
|
|
1040
|
+
value
|
|
1041
|
+
)) {
|
|
1042
|
+
resolveField(
|
|
1043
|
+
`${field}.${nestedField}`,
|
|
1044
|
+
nestedValue,
|
|
1045
|
+
(_a = rawLayer == null ? void 0 : rawLayer[field]) == null ? void 0 : _a[nestedField]
|
|
1046
|
+
);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
return { values, cssVariableValues, rawValues };
|
|
1051
|
+
};
|
|
1052
|
+
const useRenderTarget = () => {
|
|
1053
|
+
const renderTarget = useContext(RenderTargetContext);
|
|
986
1054
|
return {
|
|
987
|
-
|
|
1055
|
+
renderTarget,
|
|
1056
|
+
isCanvas: renderTarget === definition.renderTarget.canvas,
|
|
1057
|
+
isDocument: renderTarget === definition.renderTarget.document
|
|
988
1058
|
};
|
|
989
1059
|
};
|
|
990
|
-
const
|
|
991
|
-
|
|
992
|
-
const { manager } = useContext(FragmentContext);
|
|
993
|
-
const
|
|
994
|
-
const
|
|
995
|
-
const
|
|
1060
|
+
const useReadVariables = (variableKeys) => {
|
|
1061
|
+
const filterKeys = variableKeys.filter(isVariableLink$1);
|
|
1062
|
+
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1063
|
+
const { props, innerManager, layerKey } = useContext(InstanceContext);
|
|
1064
|
+
const resultManager = innerManager ?? fragmentManager;
|
|
1065
|
+
const variableLayers = useGraphStack(
|
|
1066
|
+
!!filterKeys.length ? resultManager : null,
|
|
1067
|
+
filterKeys,
|
|
1068
|
+
{
|
|
1069
|
+
selector: (graph) => graph ? pick(graph, "defaultValue", "required") : graph
|
|
1070
|
+
}
|
|
1071
|
+
);
|
|
1072
|
+
return variableLayers.map((layer) => {
|
|
1073
|
+
const { _id: propertyId } = layer ?? {};
|
|
1074
|
+
const currentValue = (props == null ? void 0 : props[propertyId]) ?? null;
|
|
1075
|
+
const required = (layer == null ? void 0 : layer.required) ?? false;
|
|
1076
|
+
const defaultValue = (layer == null ? void 0 : layer.defaultValue) ?? null;
|
|
1077
|
+
const resultValue = required ? currentValue : currentValue ?? defaultValue;
|
|
1078
|
+
return {
|
|
1079
|
+
value: resultValue,
|
|
1080
|
+
layer
|
|
1081
|
+
};
|
|
1082
|
+
});
|
|
1083
|
+
};
|
|
1084
|
+
const extractVariableValue = (input, variableId) => {
|
|
1085
|
+
if (isObject(input)) {
|
|
1086
|
+
if (variableId in input) {
|
|
1087
|
+
return input[variableId];
|
|
1088
|
+
}
|
|
1089
|
+
for (let key in input) {
|
|
1090
|
+
if (input.hasOwnProperty(key)) {
|
|
1091
|
+
const result = extractVariableValue(input[key], variableId);
|
|
1092
|
+
if (result !== void 0) {
|
|
1093
|
+
return result;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
return void 0;
|
|
1099
|
+
};
|
|
1100
|
+
function deepMerge(a, b) {
|
|
1101
|
+
if (!isObject(a) || !isObject(b)) return a;
|
|
1102
|
+
const result = { ...b };
|
|
1103
|
+
for (const [key, value] of Object.entries(a)) {
|
|
1104
|
+
if (key in result && typeof result[key] === "object" && typeof value === "object") {
|
|
1105
|
+
result[key] = deepMerge(value, result[key]);
|
|
1106
|
+
} else {
|
|
1107
|
+
result[key] = value;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
return result;
|
|
1111
|
+
}
|
|
1112
|
+
const useReadVariable = (variableKey, customScopes) => {
|
|
1113
|
+
const contextScopes = useContext(ScopeContext);
|
|
1114
|
+
const scopes = customScopes ?? contextScopes;
|
|
1115
|
+
const subscriptions = useRef([]);
|
|
1116
|
+
const [dep, forceUpdate] = useForceUpdate();
|
|
1117
|
+
useEffect(() => {
|
|
1118
|
+
const controller = new AbortController();
|
|
1119
|
+
let ready = false;
|
|
1120
|
+
const update = () => {
|
|
1121
|
+
if (!ready) return;
|
|
1122
|
+
forceUpdate();
|
|
1123
|
+
};
|
|
1124
|
+
for (const { manager, key } of subscriptions.current) {
|
|
1125
|
+
manager.subscribe(key, update, { signal: controller.signal });
|
|
1126
|
+
}
|
|
1127
|
+
ready = true;
|
|
1128
|
+
return () => controller.abort();
|
|
1129
|
+
});
|
|
1130
|
+
const extractVariableDefaultValue = (manager, variableEntity) => {
|
|
1131
|
+
const variableLayer = manager.resolve(variableEntity);
|
|
1132
|
+
if ((variableLayer == null ? void 0 : variableLayer.type) !== definition.variableType.Object)
|
|
1133
|
+
return variableLayer == null ? void 0 : variableLayer.defaultValue;
|
|
1134
|
+
return Object.values((variableLayer == null ? void 0 : variableLayer.fields) ?? {}).reduce(
|
|
1135
|
+
(acc, fieldLink) => {
|
|
1136
|
+
var _a;
|
|
1137
|
+
if (!!fieldLink && isVariableLink$1(fieldLink)) {
|
|
1138
|
+
const _id = (_a = entityOfKey(fieldLink)) == null ? void 0 : _a._id;
|
|
1139
|
+
if (_id) {
|
|
1140
|
+
acc[_id] = extractVariableDefaultValue(manager, fieldLink);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
return acc;
|
|
1144
|
+
},
|
|
1145
|
+
{}
|
|
1146
|
+
);
|
|
1147
|
+
};
|
|
1148
|
+
const resolveVariableLayer = (manager, variableLink, customProps) => {
|
|
1149
|
+
var _a, _b;
|
|
1150
|
+
const variableLayer = (_a = getNormalizeLayer(variableLink, manager)) == null ? void 0 : _a.layer;
|
|
1151
|
+
if (!variableLayer) return null;
|
|
1152
|
+
if ((variableLayer == null ? void 0 : variableLayer.type) === definition.variableType.Array) {
|
|
1153
|
+
const definitionLayer = manager.resolve(variableLayer == null ? void 0 : variableLayer.definition);
|
|
1154
|
+
if (!((_b = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _b.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== definition.variableType.Object)
|
|
1155
|
+
return variableLayer;
|
|
1156
|
+
const definitionDefaultValue = extractVariableDefaultValue(
|
|
1157
|
+
manager,
|
|
1158
|
+
definitionLayer
|
|
1159
|
+
);
|
|
1160
|
+
const customValue = customProps == null ? void 0 : customProps[variableLayer == null ? void 0 : variableLayer._id];
|
|
1161
|
+
return {
|
|
1162
|
+
...variableLayer,
|
|
1163
|
+
defaultValue: (variableLayer == null ? void 0 : variableLayer.defaultValue).map((item, index) => {
|
|
1164
|
+
const customItemValue = Array.isArray(customValue) ? customValue.at(index) : null;
|
|
1165
|
+
return deepMerge(
|
|
1166
|
+
customItemValue ? { ...item, ...customItemValue } : item,
|
|
1167
|
+
definitionDefaultValue
|
|
1168
|
+
);
|
|
1169
|
+
})
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
return variableLayer;
|
|
1173
|
+
};
|
|
1174
|
+
const readVariable = (variableKey2) => {
|
|
1175
|
+
var _a, _b, _c;
|
|
1176
|
+
const variableId = (_a = entityOfKey(variableKey2)) == null ? void 0 : _a._id;
|
|
1177
|
+
if (!isVariableLink$1(variableKey2)) {
|
|
1178
|
+
return {
|
|
1179
|
+
value: null,
|
|
1180
|
+
layer: null
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
let instanceScope = scopes.findLast(
|
|
1184
|
+
(scope) => {
|
|
1185
|
+
var _a2;
|
|
1186
|
+
return (scope == null ? void 0 : scope.type) === definition.scopeTypes.InstanceScope && !!((_a2 = scope.documentManager) == null ? void 0 : _a2.resolve(variableKey2));
|
|
1187
|
+
}
|
|
1188
|
+
);
|
|
1189
|
+
if (!instanceScope) {
|
|
1190
|
+
instanceScope = scopes.find(
|
|
1191
|
+
(scope) => (scope == null ? void 0 : scope.type) === definition.scopeTypes.InstanceScope
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
const variableLayer = resolveVariableLayer(
|
|
1195
|
+
instanceScope == null ? void 0 : instanceScope.documentManager,
|
|
1196
|
+
variableKey2
|
|
1197
|
+
);
|
|
1198
|
+
if ((instanceScope == null ? void 0 : instanceScope.documentManager) && variableKey2) {
|
|
1199
|
+
subscriptions.current.push({
|
|
1200
|
+
manager: instanceScope.documentManager,
|
|
1201
|
+
key: variableKey2
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
let instanceProp = (_b = instanceScope == null ? void 0 : instanceScope.props) == null ? void 0 : _b[variableId];
|
|
1205
|
+
if (Array.isArray(instanceProp)) {
|
|
1206
|
+
instanceProp = instanceProp.map(
|
|
1207
|
+
(rawProp, index) => {
|
|
1208
|
+
var _a2;
|
|
1209
|
+
return deepMerge(rawProp, (_a2 = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a2.at(index));
|
|
1210
|
+
}
|
|
1211
|
+
);
|
|
1212
|
+
}
|
|
1213
|
+
const lastCollectionItem = scopes.findLast(
|
|
1214
|
+
(scope) => (scope == null ? void 0 : scope.type) === definition.scopeTypes.CollectionItemScope
|
|
1215
|
+
);
|
|
1216
|
+
resolveVariableLayer(
|
|
1217
|
+
lastCollectionItem == null ? void 0 : lastCollectionItem.manager,
|
|
1218
|
+
lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition,
|
|
1219
|
+
lastCollectionItem == null ? void 0 : lastCollectionItem.value
|
|
1220
|
+
);
|
|
1221
|
+
const collectionItemProp = isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_c = entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _c._id) === variableId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue(lastCollectionItem == null ? void 0 : lastCollectionItem.value, variableId);
|
|
1222
|
+
const currentValue = variableKey2 === instanceProp ? null : collectionItemProp ?? instanceProp ?? null;
|
|
1223
|
+
const required = (variableLayer == null ? void 0 : variableLayer.required) ?? false;
|
|
1224
|
+
const defaultValue = (variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
|
|
1225
|
+
const resultValue = required ? currentValue : currentValue ?? collectionItemProp ?? defaultValue;
|
|
1226
|
+
if (isVariableLink$1(resultValue)) {
|
|
1227
|
+
return readVariable(resultValue);
|
|
1228
|
+
}
|
|
1229
|
+
return {
|
|
1230
|
+
value: resultValue,
|
|
1231
|
+
layer: variableLayer
|
|
1232
|
+
};
|
|
1233
|
+
};
|
|
1234
|
+
subscriptions.current = [];
|
|
1235
|
+
const result = readVariable(variableKey);
|
|
996
1236
|
return {
|
|
997
|
-
|
|
1237
|
+
...result,
|
|
1238
|
+
readVariable,
|
|
1239
|
+
_dep: dep
|
|
998
1240
|
};
|
|
999
1241
|
};
|
|
1242
|
+
const useLayersValue = (layerKeys, fieldKey, options) => {
|
|
1243
|
+
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1244
|
+
const resultManager = (options == null ? void 0 : options.manager) ?? fragmentManager;
|
|
1245
|
+
if (!resultManager) {
|
|
1246
|
+
return [];
|
|
1247
|
+
}
|
|
1248
|
+
const keys = (layerKeys == null ? void 0 : layerKeys.map(keyOfEntity)) ?? [];
|
|
1249
|
+
useGraphStack(resultManager, keys, {
|
|
1250
|
+
// selector: (data) => (data ? pick(data, fieldKey) : data),
|
|
1251
|
+
});
|
|
1252
|
+
const normalizeLayers = useNormalizeLayers(keys, resultManager, options);
|
|
1253
|
+
const { readVariable } = useReadVariable(null, options == null ? void 0 : options.scopes);
|
|
1254
|
+
return normalizeLayers.map((normalizedLayer) => {
|
|
1255
|
+
var _a, _b;
|
|
1256
|
+
const rawValue = get(normalizedLayer.rawLayer, fieldKey);
|
|
1257
|
+
const layerValue = get(normalizedLayer.layer, fieldKey);
|
|
1258
|
+
const variableValue = (_a = readVariable(layerValue)) == null ? void 0 : _a.value;
|
|
1259
|
+
const currentValue = variableValue ?? layerValue;
|
|
1260
|
+
const isInherit = isInheritField(
|
|
1261
|
+
resultManager,
|
|
1262
|
+
normalizedLayer.layerKey,
|
|
1263
|
+
fieldKey
|
|
1264
|
+
);
|
|
1265
|
+
const isOverride = !isInherit && !isPartOfPrimary(resultManager, normalizedLayer.layerKey);
|
|
1266
|
+
const setter = layerFieldSetter(
|
|
1267
|
+
resultManager,
|
|
1268
|
+
normalizedLayer.layerKey,
|
|
1269
|
+
fieldKey,
|
|
1270
|
+
currentValue
|
|
1271
|
+
);
|
|
1272
|
+
const resetOverride = () => {
|
|
1273
|
+
resultManager.mutate(
|
|
1274
|
+
normalizedLayer.layerKey,
|
|
1275
|
+
(prev) => {
|
|
1276
|
+
const r = omit(prev, fieldKey);
|
|
1277
|
+
return r;
|
|
1278
|
+
},
|
|
1279
|
+
{ replace: true }
|
|
1280
|
+
);
|
|
1281
|
+
};
|
|
1282
|
+
const restore = (fallbackValue) => {
|
|
1283
|
+
var _a2, _b2, _c;
|
|
1284
|
+
const tempValue = ((_c = (_b2 = resultManager.resolve((_a2 = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a2.temp)) == null ? void 0 : _b2[normalizedLayer.layerKey]) == null ? void 0 : _c[fieldKey]) ?? fallbackValue;
|
|
1285
|
+
return tempValue;
|
|
1286
|
+
};
|
|
1287
|
+
const updateValue = (value, options2) => {
|
|
1288
|
+
setter(value, options2);
|
|
1289
|
+
};
|
|
1290
|
+
const isVariable = isVariableLink$1(rawValue ?? layerValue);
|
|
1291
|
+
const variableId = isVariable ? (_b = entityOfKey(layerValue)) == null ? void 0 : _b._id : null;
|
|
1292
|
+
return [
|
|
1293
|
+
currentValue,
|
|
1294
|
+
updateValue,
|
|
1295
|
+
{
|
|
1296
|
+
isOverride,
|
|
1297
|
+
resetOverride,
|
|
1298
|
+
isVariable,
|
|
1299
|
+
cssVariableValue: isVariable ? `var(--${variableId}, ${transformCssValue(currentValue)})` : transformCssValue(currentValue),
|
|
1300
|
+
rawValue,
|
|
1301
|
+
restore,
|
|
1302
|
+
...resultManager.entityOfKey(normalizedLayer.layerKey)
|
|
1303
|
+
}
|
|
1304
|
+
];
|
|
1305
|
+
});
|
|
1306
|
+
};
|
|
1000
1307
|
const useLayerValue = (layerKey, fieldKey, options) => {
|
|
1308
|
+
var _a;
|
|
1001
1309
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1002
1310
|
const resultManager = (options == null ? void 0 : options.manager) ?? fragmentManager;
|
|
1003
1311
|
if (!resultManager) {
|
|
@@ -1027,8 +1335,8 @@ const useLayerValue = (layerKey, fieldKey, options) => {
|
|
|
1027
1335
|
}, [updateLayerData]);
|
|
1028
1336
|
const restore = useCallback(
|
|
1029
1337
|
(fallbackValue) => {
|
|
1030
|
-
var
|
|
1031
|
-
const tempValue = ((_c = (_b = resultManager.resolve((
|
|
1338
|
+
var _a2, _b, _c;
|
|
1339
|
+
const tempValue = ((_c = (_b = resultManager.resolve((_a2 = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a2.temp)) == null ? void 0 : _b[key]) == null ? void 0 : _c[fieldKey]) ?? fallbackValue;
|
|
1032
1340
|
updateLayerData({ [fieldKey]: tempValue });
|
|
1033
1341
|
return tempValue;
|
|
1034
1342
|
},
|
|
@@ -1040,27 +1348,123 @@ const useLayerValue = (layerKey, fieldKey, options) => {
|
|
|
1040
1348
|
},
|
|
1041
1349
|
[setter]
|
|
1042
1350
|
);
|
|
1043
|
-
const
|
|
1351
|
+
const isVariable = isVariableLink$1(rawValue ?? layerValue);
|
|
1352
|
+
const variableId = isVariable ? (_a = entityOfKey(layerValue)) == null ? void 0 : _a._id : null;
|
|
1044
1353
|
return [
|
|
1045
1354
|
currentValue,
|
|
1046
1355
|
updateValue,
|
|
1047
1356
|
{
|
|
1048
1357
|
isOverride,
|
|
1049
1358
|
resetOverride,
|
|
1050
|
-
isVariable
|
|
1051
|
-
cssVariableValue:
|
|
1359
|
+
isVariable,
|
|
1360
|
+
cssVariableValue: isVariable ? `var(--${variableId}, ${transformCssValue(currentValue)})` : transformCssValue(currentValue),
|
|
1052
1361
|
rawValue,
|
|
1053
1362
|
restore,
|
|
1054
1363
|
...resultManager.entityOfKey(key)
|
|
1055
1364
|
}
|
|
1056
1365
|
];
|
|
1057
1366
|
};
|
|
1367
|
+
const useLayerChildren = (layerKey, customManager) => {
|
|
1368
|
+
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1369
|
+
const [layerData] = useGraph(customManager ?? fragmentManager, layerKey, {
|
|
1370
|
+
selector: (data) => pick(data, "children")
|
|
1371
|
+
});
|
|
1372
|
+
return (layerData == null ? void 0 : layerData.children) ?? [];
|
|
1373
|
+
};
|
|
1374
|
+
const useLayerScopes = (fragmentManager, layerKey) => {
|
|
1375
|
+
var _a, _b, _c, _d;
|
|
1376
|
+
if (!fragmentManager || !layerKey) return [];
|
|
1377
|
+
const layerParents = getAllParents(fragmentManager, layerKey);
|
|
1378
|
+
const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
|
|
1379
|
+
layerParents.forEach((parent) => {
|
|
1380
|
+
var _a2, _b2, _c2, _d2;
|
|
1381
|
+
const parentLink = keyOfEntity(parent);
|
|
1382
|
+
if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
|
|
1383
|
+
resultScopes.push((_d2 = (_c2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c2.scopes) == null ? void 0 : _d2.get(parentLink));
|
|
1384
|
+
}
|
|
1385
|
+
});
|
|
1386
|
+
const areaScope = (_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get("Area");
|
|
1387
|
+
if (areaScope) {
|
|
1388
|
+
resultScopes.push(areaScope);
|
|
1389
|
+
}
|
|
1390
|
+
return resultScopes;
|
|
1391
|
+
};
|
|
1392
|
+
const useLayerLink = (layerKey) => {
|
|
1393
|
+
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1394
|
+
const [link] = useLayerValue(layerKey, "link", fragmentManager);
|
|
1395
|
+
const [href] = useLayerValue(link, "href", fragmentManager);
|
|
1396
|
+
const [isNewTab] = useLayerValue(link, "isNewTab", fragmentManager);
|
|
1397
|
+
const isLink2 = isValue(href) && typeof href === "string" && !!(href == null ? void 0 : href.length);
|
|
1398
|
+
const linkTarget = isNewTab ? "_blank" : "";
|
|
1399
|
+
const linkProps = useMemo(() => {
|
|
1400
|
+
if (isLink2) {
|
|
1401
|
+
return {
|
|
1402
|
+
target: linkTarget,
|
|
1403
|
+
href
|
|
1404
|
+
};
|
|
1405
|
+
}
|
|
1406
|
+
return {};
|
|
1407
|
+
}, [linkTarget, href, isLink2]);
|
|
1408
|
+
return {
|
|
1409
|
+
isLink: isLink2,
|
|
1410
|
+
linkHref: href,
|
|
1411
|
+
linkTarget,
|
|
1412
|
+
linkProps
|
|
1413
|
+
};
|
|
1414
|
+
};
|
|
1415
|
+
const useLayerVariableValue = (layerKey, fieldKey, manager) => {
|
|
1416
|
+
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1417
|
+
const resultManager = manager ?? fragmentManager;
|
|
1418
|
+
const [layerValue, updateValue, layerInfo] = useLayerValue(
|
|
1419
|
+
layerKey,
|
|
1420
|
+
fieldKey,
|
|
1421
|
+
resultManager
|
|
1422
|
+
);
|
|
1423
|
+
const { value: instanceValue } = useReadVariable(
|
|
1424
|
+
(layerInfo == null ? void 0 : layerInfo.isVariable) ? layerValue : null
|
|
1425
|
+
);
|
|
1426
|
+
return [
|
|
1427
|
+
(layerInfo == null ? void 0 : layerInfo.isVariable) ? instanceValue : layerValue,
|
|
1428
|
+
updateValue,
|
|
1429
|
+
{
|
|
1430
|
+
...layerInfo,
|
|
1431
|
+
rawValue: layerValue
|
|
1432
|
+
}
|
|
1433
|
+
];
|
|
1434
|
+
};
|
|
1435
|
+
const useLayerLinearGradient = (linearGradientLink) => {
|
|
1436
|
+
const [stops] = useLayerValue(linearGradientLink, "stops");
|
|
1437
|
+
const [angle] = useLayerValue(linearGradientLink, "angle");
|
|
1438
|
+
const stopsValue = useLayersValue(stops, "value");
|
|
1439
|
+
const stopsPosition = useLayersValue(stops, "position");
|
|
1440
|
+
const stopValues = useMemo(
|
|
1441
|
+
() => (stops == null ? void 0 : stops.flatMap((stop, index) => {
|
|
1442
|
+
var _a, _b, _c;
|
|
1443
|
+
return [
|
|
1444
|
+
(_b = (_a = stopsValue == null ? void 0 : stopsValue.at(index)) == null ? void 0 : _a.at(2)) == null ? void 0 : _b.cssVariableValue,
|
|
1445
|
+
(_c = stopsPosition == null ? void 0 : stopsPosition.at(index)) == null ? void 0 : _c.at(0)
|
|
1446
|
+
];
|
|
1447
|
+
})) ?? [],
|
|
1448
|
+
[stops, stopsValue, stopsPosition]
|
|
1449
|
+
);
|
|
1450
|
+
return useMemo(
|
|
1451
|
+
() => ({
|
|
1452
|
+
"background-image": calcLinearGradient(angle, stopValues)
|
|
1453
|
+
}),
|
|
1454
|
+
[angle, stopValues]
|
|
1455
|
+
);
|
|
1456
|
+
};
|
|
1058
1457
|
const processOptionalSize = (value, type) => {
|
|
1059
1458
|
if (value === -1) return "";
|
|
1060
1459
|
if (type === definition.sizing.Fixed) return toPx(value);
|
|
1061
1460
|
if (type === definition.sizing.Relative) return `${value}%`;
|
|
1062
1461
|
return "";
|
|
1063
1462
|
};
|
|
1463
|
+
const calcOptionalSize = (type, vars) => {
|
|
1464
|
+
const value = vars.values[type];
|
|
1465
|
+
const valueType = vars.values[`${type}Type`];
|
|
1466
|
+
return processOptionalSize(value, valueType);
|
|
1467
|
+
};
|
|
1064
1468
|
const useOptionalSize = (type, layerKey) => {
|
|
1065
1469
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1066
1470
|
const [value] = useLayerValue(layerKey, type, fragmentManager);
|
|
@@ -1070,6 +1474,14 @@ const useOptionalSize = (type, layerKey) => {
|
|
|
1070
1474
|
[valueType, value]
|
|
1071
1475
|
);
|
|
1072
1476
|
};
|
|
1477
|
+
const calcLayerSize = (vars) => {
|
|
1478
|
+
return {
|
|
1479
|
+
minWidth: calcOptionalSize("minWidth", vars),
|
|
1480
|
+
minHeight: calcOptionalSize("minHeight", vars),
|
|
1481
|
+
maxWidth: calcOptionalSize("maxWidth", vars),
|
|
1482
|
+
maxHeight: calcOptionalSize("maxHeight", vars)
|
|
1483
|
+
};
|
|
1484
|
+
};
|
|
1073
1485
|
const useLayerSize = (layerKey) => {
|
|
1074
1486
|
const { manager } = useContext(FragmentContext);
|
|
1075
1487
|
const minWidth = useOptionalSize("minWidth", layerKey);
|
|
@@ -1085,15 +1497,30 @@ const useLayerSize = (layerKey) => {
|
|
|
1085
1497
|
maxHeight
|
|
1086
1498
|
};
|
|
1087
1499
|
};
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1500
|
+
const autoSizes = [definition.sizing.Hug];
|
|
1501
|
+
const calcLayerSizeValue = (resolved, vars, sizeType, parentResolved, instanceVars, context) => {
|
|
1502
|
+
const { isDocument, isTopLevel: isTop, instanceLayerKey } = context;
|
|
1503
|
+
const isPartOfInstance = !!instanceLayerKey;
|
|
1504
|
+
const layerNode = resolved.rawLayer;
|
|
1505
|
+
const instanceType = instanceVars.values[`${sizeType}Type`];
|
|
1506
|
+
const valueType = vars.values[`${sizeType}Type`];
|
|
1507
|
+
const growType = sizeType === "width" ? "horizontalGrow" : "verticalGrow";
|
|
1508
|
+
return (value) => {
|
|
1509
|
+
var _a;
|
|
1510
|
+
if (isTop && isDocument && ((_a = parentResolved.layer) == null ? void 0 : _a[growType]) === definition.fragmentGrowingMode.fill) {
|
|
1511
|
+
return "100%";
|
|
1512
|
+
}
|
|
1513
|
+
if (isTop && isPartOfInstance && !autoSizes.includes(instanceType)) {
|
|
1514
|
+
return "100%";
|
|
1515
|
+
}
|
|
1516
|
+
if (autoSizes.includes(valueType)) {
|
|
1517
|
+
return (layerNode == null ? void 0 : layerNode._type) === definition.nodes.Instance ? "auto" : "fit-content";
|
|
1518
|
+
}
|
|
1519
|
+
if (valueType === definition.sizing.Relative) return `${value}%`;
|
|
1520
|
+
if (valueType === definition.sizing.Fill) return `100%`;
|
|
1521
|
+
return toPx(value);
|
|
1094
1522
|
};
|
|
1095
1523
|
};
|
|
1096
|
-
const autoSizes = [definition.sizing.Hug];
|
|
1097
1524
|
const useLayerSizeValue = (layerKey, sizeType) => {
|
|
1098
1525
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1099
1526
|
const { layerKey: instanceLayerKey } = useContext(InstanceContext$1);
|
|
@@ -1148,6 +1575,65 @@ const useLayerSizeValue = (layerKey, sizeType) => {
|
|
|
1148
1575
|
]
|
|
1149
1576
|
);
|
|
1150
1577
|
};
|
|
1578
|
+
const calcLayerPosition = (resolved, vars, parentResolved, instanceResolved, instanceVars, context) => {
|
|
1579
|
+
const { isDocument, isTopLevel: isTop, instanceLayerKey } = context;
|
|
1580
|
+
const width = vars.values.width;
|
|
1581
|
+
const height = vars.values.height;
|
|
1582
|
+
const widthCalc = calcLayerSizeValue(
|
|
1583
|
+
resolved,
|
|
1584
|
+
vars,
|
|
1585
|
+
"width",
|
|
1586
|
+
parentResolved,
|
|
1587
|
+
instanceVars,
|
|
1588
|
+
context
|
|
1589
|
+
);
|
|
1590
|
+
const heightCalc = calcLayerSizeValue(
|
|
1591
|
+
resolved,
|
|
1592
|
+
vars,
|
|
1593
|
+
"height",
|
|
1594
|
+
parentResolved,
|
|
1595
|
+
instanceVars,
|
|
1596
|
+
context
|
|
1597
|
+
);
|
|
1598
|
+
const position = vars.values.position;
|
|
1599
|
+
const centerAnchorX = vars.values.centerAnchorX;
|
|
1600
|
+
const centerAnchorY = vars.values.centerAnchorY;
|
|
1601
|
+
const top = vars.values.top;
|
|
1602
|
+
const left = vars.values.left;
|
|
1603
|
+
const right = vars.values.right;
|
|
1604
|
+
const bottom = vars.values.bottom;
|
|
1605
|
+
const skipPosition = isTop && isDocument || !!instanceLayerKey && isTop;
|
|
1606
|
+
if (isTop && !skipPosition) {
|
|
1607
|
+
return {
|
|
1608
|
+
position: definition.positionType.absolute,
|
|
1609
|
+
top: toPx(top),
|
|
1610
|
+
left: toPx(left),
|
|
1611
|
+
width,
|
|
1612
|
+
height
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
if (position === definition.positionType.relative || skipPosition) {
|
|
1616
|
+
return {
|
|
1617
|
+
position: definition.positionType.relative,
|
|
1618
|
+
width: widthCalc(width),
|
|
1619
|
+
height: heightCalc(height)
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
const hasConstrainX = isFiniteNumber(left) && isFiniteNumber(right);
|
|
1623
|
+
const hasConstrainY = isFiniteNumber(top) && isFiniteNumber(bottom);
|
|
1624
|
+
const hasAnyConstrainX = isFiniteNumber(left) || isFiniteNumber(right);
|
|
1625
|
+
const hasAnyConstrainY = isFiniteNumber(top) || isFiniteNumber(bottom);
|
|
1626
|
+
return {
|
|
1627
|
+
position,
|
|
1628
|
+
left: isFiniteNumber(left) ? toPx(left) : !isFiniteNumber(right) ? `${centerAnchorX * 100}%` : null,
|
|
1629
|
+
top: isFiniteNumber(top) ? toPx(top) : !isFiniteNumber(bottom) ? `${centerAnchorY * 100}%` : null,
|
|
1630
|
+
right: isFiniteNumber(right) ? toPx(right) : null,
|
|
1631
|
+
bottom: isFiniteNumber(bottom) ? toPx(bottom) : null,
|
|
1632
|
+
width: hasConstrainX ? null : widthCalc(width),
|
|
1633
|
+
height: hasConstrainY ? null : heightCalc(height),
|
|
1634
|
+
transform: !hasAnyConstrainX || !hasAnyConstrainY ? `translate3d(${!hasAnyConstrainX ? "-50%" : 0}, ${!hasAnyConstrainY ? "-50%" : 0}, 0px)` : null
|
|
1635
|
+
};
|
|
1636
|
+
};
|
|
1151
1637
|
const useLayerPosition = (layerKey) => {
|
|
1152
1638
|
const { layerKey: instanceLayerKey } = useContext(InstanceContext$1);
|
|
1153
1639
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
@@ -1196,6 +1682,14 @@ const useLayerPosition = (layerKey) => {
|
|
|
1196
1682
|
transform: !hasAnyConstrainX || !hasAnyConstrainY ? `translate3d(${!hasAnyConstrainX ? "-50%" : 0}, ${!hasAnyConstrainY ? "-50%" : 0}, 0px)` : null
|
|
1197
1683
|
};
|
|
1198
1684
|
};
|
|
1685
|
+
const calcImagePaint = (imageVars) => {
|
|
1686
|
+
var _a, _b;
|
|
1687
|
+
return {
|
|
1688
|
+
background: imageVars.cssVariableValues.src,
|
|
1689
|
+
backgroundRepeat: "no-repeat",
|
|
1690
|
+
backgroundSize: (_b = (_a = imageVars.values.scale) == null ? void 0 : _a.toLowerCase) == null ? void 0 : _b.call(_a)
|
|
1691
|
+
};
|
|
1692
|
+
};
|
|
1199
1693
|
const useImagePaint = (imageLinkKey) => {
|
|
1200
1694
|
var _a;
|
|
1201
1695
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
@@ -1207,186 +1701,24 @@ const useImagePaint = (imageLinkKey) => {
|
|
|
1207
1701
|
backgroundSize: (_a = scale == null ? void 0 : scale.toLowerCase) == null ? void 0 : _a.call(scale)
|
|
1208
1702
|
};
|
|
1209
1703
|
};
|
|
1210
|
-
const
|
|
1211
|
-
const
|
|
1212
|
-
const
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
selector: (graph) => graph ? pick(graph, "defaultValue", "required") : graph
|
|
1220
|
-
}
|
|
1221
|
-
);
|
|
1222
|
-
return variableLayers.map((layer) => {
|
|
1223
|
-
const { _id: propertyId } = layer ?? {};
|
|
1224
|
-
const currentValue = (props == null ? void 0 : props[propertyId]) ?? null;
|
|
1225
|
-
const required = (layer == null ? void 0 : layer.required) ?? false;
|
|
1226
|
-
const defaultValue = (layer == null ? void 0 : layer.defaultValue) ?? null;
|
|
1227
|
-
const resultValue = required ? currentValue : currentValue ?? defaultValue;
|
|
1704
|
+
const calcLayerBackground = (paintVars, imageVars, imageSizeVars, linearGradient) => {
|
|
1705
|
+
const fillType = paintVars.values.type;
|
|
1706
|
+
const cssSolidFill = paintVars.cssVariableValues.solid;
|
|
1707
|
+
const cssImageSize = imageSizeVars.cssVariableValues.imageSize;
|
|
1708
|
+
if (fillType === definition.paintMode.Solid) {
|
|
1709
|
+
return { background: cssSolidFill };
|
|
1710
|
+
}
|
|
1711
|
+
if (fillType === definition.paintMode.Image) {
|
|
1712
|
+
const image = calcImagePaint(imageVars);
|
|
1228
1713
|
return {
|
|
1229
|
-
|
|
1230
|
-
|
|
1714
|
+
...image,
|
|
1715
|
+
backgroundSize: cssImageSize ?? image.backgroundSize
|
|
1231
1716
|
};
|
|
1232
|
-
});
|
|
1233
|
-
};
|
|
1234
|
-
const useLayersValue = (layerKeys, fieldKey, options) => {
|
|
1235
|
-
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1236
|
-
const resultManager = (options == null ? void 0 : options.manager) ?? fragmentManager;
|
|
1237
|
-
if (!resultManager) {
|
|
1238
|
-
return [];
|
|
1239
1717
|
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
// selector: (data) => (data ? pick(data, fieldKey) : data),
|
|
1243
|
-
});
|
|
1244
|
-
const normalizeLayers = useNormalizeLayers(keys, resultManager, options);
|
|
1245
|
-
const { readVariable } = useReadVariable(null, options == null ? void 0 : options.scopes);
|
|
1246
|
-
return normalizeLayers.map((normalizedLayer) => {
|
|
1247
|
-
var _a, _b;
|
|
1248
|
-
const rawValue = get(normalizedLayer.rawLayer, fieldKey);
|
|
1249
|
-
const layerValue = get(normalizedLayer.layer, fieldKey);
|
|
1250
|
-
const variableValue = (_a = readVariable(layerValue)) == null ? void 0 : _a.value;
|
|
1251
|
-
const currentValue = variableValue ?? layerValue;
|
|
1252
|
-
const isInherit = isInheritField(
|
|
1253
|
-
resultManager,
|
|
1254
|
-
normalizedLayer.layerKey,
|
|
1255
|
-
fieldKey
|
|
1256
|
-
);
|
|
1257
|
-
const isOverride = !isInherit && !isPartOfPrimary(resultManager, normalizedLayer.layerKey);
|
|
1258
|
-
const setter = layerFieldSetter(
|
|
1259
|
-
resultManager,
|
|
1260
|
-
normalizedLayer.layerKey,
|
|
1261
|
-
fieldKey,
|
|
1262
|
-
currentValue
|
|
1263
|
-
);
|
|
1264
|
-
const resetOverride = () => {
|
|
1265
|
-
resultManager.mutate(
|
|
1266
|
-
normalizedLayer.layerKey,
|
|
1267
|
-
(prev) => {
|
|
1268
|
-
const r = omit(prev, fieldKey);
|
|
1269
|
-
return r;
|
|
1270
|
-
},
|
|
1271
|
-
{ replace: true }
|
|
1272
|
-
);
|
|
1273
|
-
};
|
|
1274
|
-
const restore = (fallbackValue) => {
|
|
1275
|
-
var _a2, _b2, _c;
|
|
1276
|
-
const tempValue = ((_c = (_b2 = resultManager.resolve((_a2 = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a2.temp)) == null ? void 0 : _b2[normalizedLayer.layerKey]) == null ? void 0 : _c[fieldKey]) ?? fallbackValue;
|
|
1277
|
-
return tempValue;
|
|
1278
|
-
};
|
|
1279
|
-
const updateValue = (value, options2) => {
|
|
1280
|
-
setter(value, options2);
|
|
1281
|
-
};
|
|
1282
|
-
const cssValue = (_b = getLayerCssVariable(
|
|
1283
|
-
resultManager,
|
|
1284
|
-
rawValue ?? layerValue
|
|
1285
|
-
)) == null ? void 0 : _b.value;
|
|
1286
|
-
return [
|
|
1287
|
-
currentValue,
|
|
1288
|
-
updateValue,
|
|
1289
|
-
{
|
|
1290
|
-
isOverride,
|
|
1291
|
-
resetOverride,
|
|
1292
|
-
isVariable: isVariableLink$1(rawValue ?? layerValue),
|
|
1293
|
-
cssVariableValue: cssValue ?? currentValue,
|
|
1294
|
-
rawValue,
|
|
1295
|
-
restore,
|
|
1296
|
-
...resultManager.entityOfKey(normalizedLayer.layerKey)
|
|
1297
|
-
}
|
|
1298
|
-
];
|
|
1299
|
-
});
|
|
1300
|
-
};
|
|
1301
|
-
const useLayerChildren = (layerKey, customManager) => {
|
|
1302
|
-
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1303
|
-
const [layerData] = useGraph(customManager ?? fragmentManager, layerKey, {
|
|
1304
|
-
selector: (data) => pick(data, "children")
|
|
1305
|
-
});
|
|
1306
|
-
return (layerData == null ? void 0 : layerData.children) ?? [];
|
|
1307
|
-
};
|
|
1308
|
-
const useLayerScopes = (fragmentManager, layerKey) => {
|
|
1309
|
-
var _a, _b, _c, _d;
|
|
1310
|
-
if (!fragmentManager || !layerKey) return [];
|
|
1311
|
-
const layerParents = getAllParents(fragmentManager, layerKey);
|
|
1312
|
-
const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
|
|
1313
|
-
layerParents.forEach((parent) => {
|
|
1314
|
-
var _a2, _b2, _c2, _d2;
|
|
1315
|
-
const parentLink = keyOfEntity(parent);
|
|
1316
|
-
if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
|
|
1317
|
-
resultScopes.push((_d2 = (_c2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c2.scopes) == null ? void 0 : _d2.get(parentLink));
|
|
1318
|
-
}
|
|
1319
|
-
});
|
|
1320
|
-
const areaScope = (_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get("Area");
|
|
1321
|
-
if (areaScope) {
|
|
1322
|
-
resultScopes.push(areaScope);
|
|
1718
|
+
if (fillType === definition.paintMode.LinearGradient) {
|
|
1719
|
+
return linearGradient;
|
|
1323
1720
|
}
|
|
1324
|
-
return
|
|
1325
|
-
};
|
|
1326
|
-
const useLayerLink = (layerKey) => {
|
|
1327
|
-
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1328
|
-
const [link] = useLayerValue(layerKey, "link", fragmentManager);
|
|
1329
|
-
const [href] = useLayerValue(link, "href", fragmentManager);
|
|
1330
|
-
const [isNewTab] = useLayerValue(link, "isNewTab", fragmentManager);
|
|
1331
|
-
const isLink2 = isValue(href) && typeof href === "string" && !!(href == null ? void 0 : href.length);
|
|
1332
|
-
const linkTarget = isNewTab ? "_blank" : "";
|
|
1333
|
-
const linkProps = useMemo(() => {
|
|
1334
|
-
if (isLink2) {
|
|
1335
|
-
return {
|
|
1336
|
-
target: linkTarget,
|
|
1337
|
-
href
|
|
1338
|
-
};
|
|
1339
|
-
}
|
|
1340
|
-
return {};
|
|
1341
|
-
}, [linkTarget, href, isLink2]);
|
|
1342
|
-
return {
|
|
1343
|
-
isLink: isLink2,
|
|
1344
|
-
linkHref: href,
|
|
1345
|
-
linkTarget,
|
|
1346
|
-
linkProps
|
|
1347
|
-
};
|
|
1348
|
-
};
|
|
1349
|
-
const useLayerVariableValue = (layerKey, fieldKey, manager) => {
|
|
1350
|
-
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1351
|
-
const resultManager = manager ?? fragmentManager;
|
|
1352
|
-
const [layerValue, updateValue, layerInfo] = useLayerValue(
|
|
1353
|
-
layerKey,
|
|
1354
|
-
fieldKey,
|
|
1355
|
-
resultManager
|
|
1356
|
-
);
|
|
1357
|
-
const { value: instanceValue } = useReadVariable(
|
|
1358
|
-
(layerInfo == null ? void 0 : layerInfo.isVariable) ? layerValue : null
|
|
1359
|
-
);
|
|
1360
|
-
return [
|
|
1361
|
-
(layerInfo == null ? void 0 : layerInfo.isVariable) ? instanceValue : layerValue,
|
|
1362
|
-
updateValue,
|
|
1363
|
-
{
|
|
1364
|
-
...layerInfo,
|
|
1365
|
-
rawValue: layerValue
|
|
1366
|
-
}
|
|
1367
|
-
];
|
|
1368
|
-
};
|
|
1369
|
-
const useLayerLinearGradient = (linearGradientLink) => {
|
|
1370
|
-
const [stops] = useLayerValue(linearGradientLink, "stops");
|
|
1371
|
-
const [angle] = useLayerValue(linearGradientLink, "angle");
|
|
1372
|
-
const stopsValue = useLayersValue(stops, "value");
|
|
1373
|
-
const stopsPosition = useLayersValue(stops, "position");
|
|
1374
|
-
const stopValues = useMemo(
|
|
1375
|
-
() => (stops == null ? void 0 : stops.flatMap((stop, index) => {
|
|
1376
|
-
var _a, _b, _c;
|
|
1377
|
-
return [
|
|
1378
|
-
(_b = (_a = stopsValue == null ? void 0 : stopsValue.at(index)) == null ? void 0 : _a.at(2)) == null ? void 0 : _b.cssVariableValue,
|
|
1379
|
-
(_c = stopsPosition == null ? void 0 : stopsPosition.at(index)) == null ? void 0 : _c.at(0)
|
|
1380
|
-
];
|
|
1381
|
-
})) ?? [],
|
|
1382
|
-
[stops, stopsValue, stopsPosition]
|
|
1383
|
-
);
|
|
1384
|
-
return useMemo(
|
|
1385
|
-
() => ({
|
|
1386
|
-
"background-image": calcLinearGradient(angle, stopValues)
|
|
1387
|
-
}),
|
|
1388
|
-
[angle, stopValues]
|
|
1389
|
-
);
|
|
1721
|
+
return { background: null };
|
|
1390
1722
|
};
|
|
1391
1723
|
const useLayerBackground = (layerKey) => {
|
|
1392
1724
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
@@ -1429,9 +1761,16 @@ const useLayerBackground = (layerKey) => {
|
|
|
1429
1761
|
cssImageFillOptions.cssVariableValue,
|
|
1430
1762
|
cssSolidFill,
|
|
1431
1763
|
cssImageSize,
|
|
1432
|
-
image
|
|
1764
|
+
image,
|
|
1765
|
+
linearGradient
|
|
1433
1766
|
]);
|
|
1434
1767
|
};
|
|
1768
|
+
const calcLayerDisplay = (vars) => {
|
|
1769
|
+
const layerModeValue = vars.values.layerMode;
|
|
1770
|
+
const visible = vars.values.visible;
|
|
1771
|
+
if (!visible) return "none";
|
|
1772
|
+
return layerModeValue === definition.layerMode.flex ? "flex" : null;
|
|
1773
|
+
};
|
|
1435
1774
|
const useLayerDisplay = (layerKey) => {
|
|
1436
1775
|
const { manager } = useContext(FragmentContext);
|
|
1437
1776
|
const [layerModeValue] = useLayerValue(layerKey, "layerMode", manager);
|
|
@@ -1443,6 +1782,15 @@ const useLayerDisplay = (layerKey) => {
|
|
|
1443
1782
|
return layerModeValue === definition.layerMode.flex ? "flex" : null;
|
|
1444
1783
|
}, [layerModeValue, visible]);
|
|
1445
1784
|
};
|
|
1785
|
+
const calcLayerPaint = (paintVars) => {
|
|
1786
|
+
return {
|
|
1787
|
+
type: paintVars.values.type,
|
|
1788
|
+
solid: paintVars.values.solid,
|
|
1789
|
+
solidCssValue: paintVars.cssVariableValues.solid,
|
|
1790
|
+
image: paintVars.values.image,
|
|
1791
|
+
linearGradientLink: paintVars.values.linearGradient
|
|
1792
|
+
};
|
|
1793
|
+
};
|
|
1446
1794
|
const useLayerPaint = (paintLinkKey) => {
|
|
1447
1795
|
const [type] = useLayerValue(paintLinkKey, "type");
|
|
1448
1796
|
const [solid, , solidInfo] = useLayerValue(paintLinkKey, "solid");
|
|
@@ -1456,18 +1804,49 @@ const useLayerPaint = (paintLinkKey) => {
|
|
|
1456
1804
|
linearGradientLink
|
|
1457
1805
|
};
|
|
1458
1806
|
};
|
|
1807
|
+
const calcLayerBorder = (borderVars, borderPaintVars, borderLinearGradient, paintVars, linearGradient) => {
|
|
1808
|
+
const type = borderVars.values.type;
|
|
1809
|
+
const width = borderVars.values.width;
|
|
1810
|
+
const borderPaint = calcLayerPaint(borderPaintVars);
|
|
1811
|
+
const paint = calcLayerPaint(paintVars);
|
|
1812
|
+
if (type === definition.borderType.None) {
|
|
1813
|
+
return { border: null };
|
|
1814
|
+
}
|
|
1815
|
+
if (borderPaint.type === definition.paintMode.LinearGradient) {
|
|
1816
|
+
let background = `linear-gradient(${paint.solid}, ${paint.solid}) padding-box, ${borderLinearGradient == null ? void 0 : borderLinearGradient["background-image"]} border-box`;
|
|
1817
|
+
if (paint.type === definition.paintMode.LinearGradient) {
|
|
1818
|
+
background = `${linearGradient == null ? void 0 : linearGradient["background-image"]} padding-box, ${borderLinearGradient == null ? void 0 : borderLinearGradient["background-image"]} border-box`;
|
|
1819
|
+
}
|
|
1820
|
+
if (paint.type === definition.paintMode.None) {
|
|
1821
|
+
background = `linear-gradient(transparent, transparent) padding-box, ${borderLinearGradient == null ? void 0 : borderLinearGradient["background-image"]} border-box`;
|
|
1822
|
+
}
|
|
1823
|
+
return {
|
|
1824
|
+
...calcBorderSides(
|
|
1825
|
+
type,
|
|
1826
|
+
width,
|
|
1827
|
+
borderPaint.type === definition.paintMode.Solid ? borderPaint.solid : "transparent"
|
|
1828
|
+
),
|
|
1829
|
+
background
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
if (borderPaint.type === definition.paintMode.Solid) {
|
|
1833
|
+
return calcBorderSides(type, width, borderPaint.solidCssValue);
|
|
1834
|
+
}
|
|
1835
|
+
return { border: null };
|
|
1836
|
+
};
|
|
1459
1837
|
const useLayerBorder = (layerKey) => {
|
|
1838
|
+
var _a, _b;
|
|
1460
1839
|
const [borderLinkKey] = useLayerValue(layerKey, "border");
|
|
1461
1840
|
const [type] = useLayerValue(borderLinkKey, "type");
|
|
1462
1841
|
const [width] = useLayerValue(borderLinkKey, "width");
|
|
1463
1842
|
const [borderPaintLink] = useLayerValue(borderLinkKey, "paint");
|
|
1464
1843
|
const borderPaint = useLayerPaint(borderPaintLink);
|
|
1465
|
-
const borderLinearGradient = useLayerLinearGradient(
|
|
1844
|
+
const borderLinearGradient = (_a = useLayerLinearGradient(
|
|
1466
1845
|
borderPaint.linearGradientLink
|
|
1467
|
-
);
|
|
1846
|
+
)) == null ? void 0 : _a["background-image"];
|
|
1468
1847
|
const [paintLinkKey] = useLayerValue(layerKey, "paint");
|
|
1469
1848
|
const paint = useLayerPaint(paintLinkKey);
|
|
1470
|
-
const linearGradient = useLayerLinearGradient(paint.linearGradientLink);
|
|
1849
|
+
const linearGradient = (_b = useLayerLinearGradient(paint.linearGradientLink)) == null ? void 0 : _b["background-image"];
|
|
1471
1850
|
if (type === definition.borderType.None) {
|
|
1472
1851
|
return {
|
|
1473
1852
|
border: null
|
|
@@ -1476,7 +1855,7 @@ const useLayerBorder = (layerKey) => {
|
|
|
1476
1855
|
if (borderPaint.type === definition.paintMode.LinearGradient) {
|
|
1477
1856
|
let background = `linear-gradient(${paint.solid}, ${paint.solid}) padding-box, ${borderLinearGradient} border-box`;
|
|
1478
1857
|
if (paint.type === definition.paintMode.LinearGradient) {
|
|
1479
|
-
background = `${linearGradient
|
|
1858
|
+
background = `${linearGradient} padding-box, ${borderLinearGradient} border-box`;
|
|
1480
1859
|
}
|
|
1481
1860
|
if (paint.type === definition.paintMode.None) {
|
|
1482
1861
|
background = `linear-gradient(transparent, transparent) padding-box, ${borderLinearGradient} border-box`;
|
|
@@ -1495,6 +1874,28 @@ const useLayerBorder = (layerKey) => {
|
|
|
1495
1874
|
}
|
|
1496
1875
|
return { border: null };
|
|
1497
1876
|
};
|
|
1877
|
+
const calcLayerLayout = (vars) => {
|
|
1878
|
+
const layerModeValue = vars.values.layerMode;
|
|
1879
|
+
const layerWrap = vars.values.layerWrap;
|
|
1880
|
+
const layerDistribute = vars.values.layerDistribute;
|
|
1881
|
+
const layerDirectionValue = vars.values.layerDirection;
|
|
1882
|
+
const layerAlign = vars.values.layerAlign;
|
|
1883
|
+
const padding = vars.values.padding;
|
|
1884
|
+
const gap = vars.values.layerGap;
|
|
1885
|
+
const isFlex = layerModeValue === definition.layerMode.flex;
|
|
1886
|
+
const baseFlow = layerDirectionValue === definition.layerDirection.vertical ? "column" : "row";
|
|
1887
|
+
const wrap = isFlex ? layerWrap ? "wrap" : null : null;
|
|
1888
|
+
const flexFlow = [baseFlow, wrap].filter(Boolean).join(" ");
|
|
1889
|
+
return {
|
|
1890
|
+
display: isFlex ? "flex" : null,
|
|
1891
|
+
gap: toPx(gap),
|
|
1892
|
+
flexWrap: isFlex ? layerWrap ? "wrap" : null : null,
|
|
1893
|
+
justifyContent: isFlex ? layerDistribute : null,
|
|
1894
|
+
flexFlow,
|
|
1895
|
+
alignItems: isFlex ? layerAlign : null,
|
|
1896
|
+
padding: isFlex ? padding : null
|
|
1897
|
+
};
|
|
1898
|
+
};
|
|
1498
1899
|
const useLayerLayout = (layerKey) => {
|
|
1499
1900
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1500
1901
|
const [layerModeValue] = useLayerValue(
|
|
@@ -1530,6 +1931,15 @@ const useLayerLayout = (layerKey) => {
|
|
|
1530
1931
|
padding: isFlex ? padding : null
|
|
1531
1932
|
};
|
|
1532
1933
|
};
|
|
1934
|
+
const calcLayerTextStyles = (vars) => {
|
|
1935
|
+
const attributes = vars.values.attributes;
|
|
1936
|
+
const color = vars.values["attributes.color"];
|
|
1937
|
+
const cleanAttributes = omit(attributes, "_id", "_type");
|
|
1938
|
+
return {
|
|
1939
|
+
...cleanAttributes,
|
|
1940
|
+
color
|
|
1941
|
+
};
|
|
1942
|
+
};
|
|
1533
1943
|
const useLayerTextStyles = (layerKey) => {
|
|
1534
1944
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1535
1945
|
const [attributes] = useLayerValue(layerKey, "attributes", fragmentManager);
|
|
@@ -1540,6 +1950,15 @@ const useLayerTextStyles = (layerKey) => {
|
|
|
1540
1950
|
color
|
|
1541
1951
|
};
|
|
1542
1952
|
};
|
|
1953
|
+
const calcLayerFlex = (vars, parentVars) => {
|
|
1954
|
+
const widthType = vars.values.widthType;
|
|
1955
|
+
const heightType = vars.values.heightType;
|
|
1956
|
+
const layerDirectionValue = parentVars.values.layerDirection;
|
|
1957
|
+
const type = layerDirectionValue === definition.layerDirection.horizontal ? widthType : heightType;
|
|
1958
|
+
return {
|
|
1959
|
+
flex: type === definition.sizing.Fill ? "1 0 0" : "0 0 auto"
|
|
1960
|
+
};
|
|
1961
|
+
};
|
|
1543
1962
|
const useLayerFlex = (layerKey) => {
|
|
1544
1963
|
const { manager } = useContext(FragmentContext);
|
|
1545
1964
|
const [widthType] = useLayerValue(layerKey, "widthType", manager);
|
|
@@ -1555,48 +1974,121 @@ const useLayerFlex = (layerKey) => {
|
|
|
1555
1974
|
flex: type === definition.sizing.Fill ? "1 0 0" : "0 0 auto"
|
|
1556
1975
|
};
|
|
1557
1976
|
};
|
|
1977
|
+
const SKIP_OVERRIDE = { skipOverrideCheck: true };
|
|
1558
1978
|
const useLayerStyles = (layerKey) => {
|
|
1559
1979
|
try {
|
|
1560
|
-
if (!layerKey)
|
|
1561
|
-
throw new Error("Empty layer key");
|
|
1562
|
-
}
|
|
1980
|
+
if (!layerKey) throw new Error("Empty layer key");
|
|
1563
1981
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1564
|
-
const
|
|
1565
|
-
const
|
|
1566
|
-
const
|
|
1567
|
-
const
|
|
1568
|
-
const
|
|
1569
|
-
const
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
const
|
|
1574
|
-
const
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1982
|
+
const { layerKey: instanceLayerKey } = useContext(InstanceContext$1);
|
|
1983
|
+
const { isDocument } = useRenderTarget();
|
|
1984
|
+
const resolved = useResolvedLayer(layerKey);
|
|
1985
|
+
const vars = useResolvedLayerVariables(resolved.layer, resolved.rawLayer);
|
|
1986
|
+
const paintResolved = useResolvedLayer(vars.values.paint, SKIP_OVERRIDE);
|
|
1987
|
+
const paintVars = useResolvedLayerVariables(
|
|
1988
|
+
paintResolved.layer,
|
|
1989
|
+
paintResolved.rawLayer
|
|
1990
|
+
);
|
|
1991
|
+
const borderResolved = useResolvedLayer(vars.values.border, SKIP_OVERRIDE);
|
|
1992
|
+
const borderVars = useResolvedLayerVariables(
|
|
1993
|
+
borderResolved.layer,
|
|
1994
|
+
borderResolved.rawLayer
|
|
1995
|
+
);
|
|
1996
|
+
const borderPaintResolved = useResolvedLayer(
|
|
1997
|
+
borderVars.values.paint,
|
|
1998
|
+
SKIP_OVERRIDE
|
|
1999
|
+
);
|
|
2000
|
+
const borderPaintVars = useResolvedLayerVariables(
|
|
2001
|
+
borderPaintResolved.layer,
|
|
2002
|
+
borderPaintResolved.rawLayer
|
|
2003
|
+
);
|
|
2004
|
+
const imageResolved = useResolvedLayer(
|
|
2005
|
+
paintVars.values.image,
|
|
2006
|
+
SKIP_OVERRIDE
|
|
2007
|
+
);
|
|
2008
|
+
const imageVars = useResolvedLayerVariables(
|
|
2009
|
+
imageResolved.layer,
|
|
2010
|
+
imageResolved.rawLayer
|
|
2011
|
+
);
|
|
2012
|
+
const imageSizeLayerKey = isVariableLink$1(paintVars.rawValues.image) ? paintVars.rawValues.image : layerKey;
|
|
2013
|
+
const imageSizeResolved = useResolvedLayer(
|
|
2014
|
+
imageSizeLayerKey,
|
|
2015
|
+
SKIP_OVERRIDE
|
|
2016
|
+
);
|
|
2017
|
+
const imageSizeVars = useResolvedLayerVariables(
|
|
2018
|
+
imageSizeResolved.layer,
|
|
2019
|
+
imageSizeResolved.rawLayer
|
|
2020
|
+
);
|
|
2021
|
+
const parentLayerKey = keyOfEntity(
|
|
2022
|
+
getParent(fragmentManager, layerKey)
|
|
2023
|
+
);
|
|
2024
|
+
const parentResolved = useResolvedLayer(
|
|
2025
|
+
parentLayerKey,
|
|
2026
|
+
SKIP_OVERRIDE
|
|
2027
|
+
);
|
|
2028
|
+
const parentVars = useResolvedLayerVariables(
|
|
2029
|
+
parentResolved.layer,
|
|
2030
|
+
parentResolved.rawLayer
|
|
2031
|
+
);
|
|
2032
|
+
const instanceResolved = useResolvedLayer(
|
|
2033
|
+
instanceLayerKey,
|
|
2034
|
+
SKIP_OVERRIDE
|
|
2035
|
+
);
|
|
2036
|
+
const instanceVars = useResolvedLayerVariables(
|
|
2037
|
+
instanceResolved.layer,
|
|
2038
|
+
instanceResolved.rawLayer
|
|
2039
|
+
);
|
|
2040
|
+
const paint = calcLayerPaint(paintVars);
|
|
2041
|
+
const borderPaint = calcLayerPaint(borderPaintVars);
|
|
2042
|
+
const linearGradient = useLayerLinearGradient(paint.linearGradientLink);
|
|
2043
|
+
const borderLinearGradient = useLayerLinearGradient(
|
|
2044
|
+
borderPaint.linearGradientLink
|
|
2045
|
+
);
|
|
2046
|
+
const context = {
|
|
2047
|
+
isDocument,
|
|
2048
|
+
isTopLevel: isTopLevel(fragmentManager, layerKey),
|
|
2049
|
+
instanceLayerKey
|
|
2050
|
+
};
|
|
2051
|
+
const layerSize = calcLayerSize(vars);
|
|
2052
|
+
const position = calcLayerPosition(
|
|
2053
|
+
resolved,
|
|
2054
|
+
vars,
|
|
2055
|
+
parentResolved,
|
|
2056
|
+
instanceResolved,
|
|
2057
|
+
instanceVars,
|
|
2058
|
+
context
|
|
2059
|
+
);
|
|
2060
|
+
const background = calcLayerBackground(
|
|
2061
|
+
paintVars,
|
|
2062
|
+
imageVars,
|
|
2063
|
+
imageSizeVars,
|
|
2064
|
+
linearGradient
|
|
1578
2065
|
);
|
|
1579
|
-
const
|
|
1580
|
-
const
|
|
1581
|
-
|
|
2066
|
+
const display = calcLayerDisplay(vars);
|
|
2067
|
+
const border = calcLayerBorder(
|
|
2068
|
+
borderVars,
|
|
2069
|
+
borderPaintVars,
|
|
2070
|
+
borderLinearGradient,
|
|
2071
|
+
paintVars,
|
|
2072
|
+
linearGradient
|
|
2073
|
+
);
|
|
2074
|
+
const layout = calcLayerLayout(vars);
|
|
2075
|
+
const textStyles = calcLayerTextStyles(vars);
|
|
2076
|
+
const layerFlex = calcLayerFlex(vars, parentVars);
|
|
1582
2077
|
return {
|
|
1583
|
-
// ...(props ?? {}),
|
|
1584
2078
|
...background,
|
|
1585
2079
|
...border,
|
|
1586
2080
|
...position,
|
|
1587
|
-
opacity,
|
|
1588
|
-
overflow,
|
|
1589
|
-
rotate: isValue(rotate) ? `${rotate}deg` : null,
|
|
1590
|
-
"border-radius": isValue(
|
|
1591
|
-
"white-space": whiteSpace,
|
|
1592
|
-
"z-index": zIndex !== -1 ? zIndex : null,
|
|
2081
|
+
opacity: vars.values.opacity,
|
|
2082
|
+
overflow: vars.values.overflow,
|
|
2083
|
+
rotate: isValue(vars.values.rotate) ? `${vars.values.rotate}deg` : null,
|
|
2084
|
+
"border-radius": isValue(vars.rawValues.borderRadius) ? vars.values.borderRadius : null,
|
|
2085
|
+
"white-space": vars.values.whiteSpace,
|
|
2086
|
+
"z-index": vars.values.zIndex !== -1 ? vars.values.zIndex : null,
|
|
1593
2087
|
...layout,
|
|
1594
2088
|
...layerSize,
|
|
1595
2089
|
...textStyles,
|
|
1596
2090
|
...layerFlex,
|
|
1597
2091
|
display
|
|
1598
|
-
// "user-select": "none",
|
|
1599
|
-
// ...cssOverride,
|
|
1600
2092
|
};
|
|
1601
2093
|
} catch (e) {
|
|
1602
2094
|
return {};
|
|
@@ -1701,6 +2193,34 @@ const useStyleSheet = (manager) => {
|
|
|
1701
2193
|
unmount: ((_b = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _b.unmount) ?? noop
|
|
1702
2194
|
};
|
|
1703
2195
|
};
|
|
2196
|
+
const useGlobalManager = (globalManager) => {
|
|
2197
|
+
var _a, _b;
|
|
2198
|
+
const currentGlobalManager = useContext(GlobalManagerContext);
|
|
2199
|
+
const resultManager = globalManager ?? currentGlobalManager;
|
|
2200
|
+
const [fragmentsGraph] = useGraph(
|
|
2201
|
+
resultManager,
|
|
2202
|
+
(_a = resultManager == null ? void 0 : resultManager.$fragments) == null ? void 0 : _a.key
|
|
2203
|
+
);
|
|
2204
|
+
const queryFragmentManager = (id) => {
|
|
2205
|
+
var _a2, _b2;
|
|
2206
|
+
return (_b2 = (_a2 = resultManager == null ? void 0 : resultManager.$load) == null ? void 0 : _a2.loadFragment) == null ? void 0 : _b2.call(_a2, id);
|
|
2207
|
+
};
|
|
2208
|
+
const queryArea = (id) => {
|
|
2209
|
+
var _a2, _b2;
|
|
2210
|
+
return (_b2 = (_a2 = resultManager == null ? void 0 : resultManager.$load) == null ? void 0 : _a2.loadArea) == null ? void 0 : _b2.call(_a2, id);
|
|
2211
|
+
};
|
|
2212
|
+
const setRenderTarget = (value) => {
|
|
2213
|
+
resultManager == null ? void 0 : resultManager.setRenderTarget(value);
|
|
2214
|
+
};
|
|
2215
|
+
return {
|
|
2216
|
+
fragmentsGraph,
|
|
2217
|
+
manager: resultManager,
|
|
2218
|
+
queryFragmentManager,
|
|
2219
|
+
queryArea,
|
|
2220
|
+
getFragmentManager: ((_b = resultManager == null ? void 0 : resultManager.$fragments) == null ? void 0 : _b.getManager) ?? noop,
|
|
2221
|
+
setRenderTarget
|
|
2222
|
+
};
|
|
2223
|
+
};
|
|
1704
2224
|
const useLayerInteractions = (layerKey, options) => {
|
|
1705
2225
|
const pause = (options == null ? void 0 : options.pauseInteractions) ?? false;
|
|
1706
2226
|
const { manager: globalManager } = useGlobalManager();
|
|
@@ -1725,12 +2245,14 @@ const useLayerInteractions = (layerKey, options) => {
|
|
|
1725
2245
|
});
|
|
1726
2246
|
const fireEvent = useCallback(
|
|
1727
2247
|
(eventLink) => {
|
|
1728
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2248
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1729
2249
|
const eventType = (_a = entityOfKey(eventLink)) == null ? void 0 : _a._type;
|
|
1730
2250
|
const eventValue = (_b = getNormalizeLayer(eventLink, fragmentManager)) == null ? void 0 : _b.layer;
|
|
2251
|
+
console.log(scopes, eventLink, eventType, eventValue);
|
|
1731
2252
|
if (eventType === definition.nodes.GoalEvent && (eventValue == null ? void 0 : eventValue.goalId)) {
|
|
1732
2253
|
if (!areaScope) return null;
|
|
1733
|
-
(
|
|
2254
|
+
console.log((_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.reachGoal);
|
|
2255
|
+
(_e = (_d = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _d.reachGoal) == null ? void 0 : _e.call(_d, {
|
|
1734
2256
|
goalId: eventValue == null ? void 0 : eventValue.goalId,
|
|
1735
2257
|
...pick(areaScope, "variantId", "campaignId", "areaId")
|
|
1736
2258
|
});
|
|
@@ -1738,10 +2260,10 @@ const useLayerInteractions = (layerKey, options) => {
|
|
|
1738
2260
|
if (eventType === definition.nodes.MutateEvent) {
|
|
1739
2261
|
const target = eventValue == null ? void 0 : eventValue.target;
|
|
1740
2262
|
const targetLayer = getNormalizeLayer(target, fragmentManager);
|
|
1741
|
-
const value = (eventValue == null ? void 0 : eventValue.value) ?? ((
|
|
2263
|
+
const value = (eventValue == null ? void 0 : eventValue.value) ?? ((_f = targetLayer == null ? void 0 : targetLayer.layer) == null ? void 0 : _f.defaultValue);
|
|
1742
2264
|
if (isVariableLink$1(target) && isValue(value)) {
|
|
1743
|
-
const targetId = (
|
|
1744
|
-
(
|
|
2265
|
+
const targetId = (_g = entityOfKey(target)) == null ? void 0 : _g._id;
|
|
2266
|
+
(_h = instanceScope == null ? void 0 : instanceScope.onChangeProps) == null ? void 0 : _h.call(instanceScope, targetId, value);
|
|
1745
2267
|
}
|
|
1746
2268
|
}
|
|
1747
2269
|
},
|
|
@@ -1948,41 +2470,250 @@ const useCollection = (layerKey, options) => {
|
|
|
1948
2470
|
...frame
|
|
1949
2471
|
};
|
|
1950
2472
|
};
|
|
1951
|
-
const
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
2473
|
+
const resolveFieldRef = (field, manager) => {
|
|
2474
|
+
if (isVariableLink$1(field)) {
|
|
2475
|
+
return manager.resolve(field);
|
|
2476
|
+
}
|
|
2477
|
+
if (isObject(field) && (field == null ? void 0 : field._id)) {
|
|
2478
|
+
return field;
|
|
2479
|
+
}
|
|
2480
|
+
return void 0;
|
|
2481
|
+
};
|
|
2482
|
+
const fieldRefToKey = (field) => {
|
|
2483
|
+
if (isVariableLink$1(field)) {
|
|
2484
|
+
return field;
|
|
2485
|
+
}
|
|
2486
|
+
if (isObject(field) && (field == null ? void 0 : field._type) && (field == null ? void 0 : field._id)) {
|
|
2487
|
+
return keyOfEntity(field);
|
|
2488
|
+
}
|
|
2489
|
+
return void 0;
|
|
2490
|
+
};
|
|
2491
|
+
const collectLeafKeys = (defVar, manager, keys) => {
|
|
2492
|
+
if (!(defVar == null ? void 0 : defVar.fields)) return;
|
|
2493
|
+
const fields = cleanGraph(defVar.fields);
|
|
2494
|
+
for (const fieldRef of Object.values(fields)) {
|
|
2495
|
+
const fieldVar = resolveFieldRef(fieldRef, manager);
|
|
2496
|
+
const fieldKey = fieldRefToKey(fieldRef);
|
|
2497
|
+
if (!fieldVar || !fieldKey) continue;
|
|
2498
|
+
if (fieldVar.type === definition.variableType.Object && fieldVar.fields) {
|
|
2499
|
+
collectLeafKeys(fieldVar, manager, keys);
|
|
2500
|
+
} else {
|
|
2501
|
+
keys.push(fieldKey);
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
};
|
|
2505
|
+
const flattenObjectFields = (defVar, valueObj, manager, result) => {
|
|
2506
|
+
if (!(defVar == null ? void 0 : defVar.fields)) return;
|
|
2507
|
+
const fields = cleanGraph(defVar.fields);
|
|
2508
|
+
for (const [fieldName, fieldRef] of Object.entries(fields)) {
|
|
2509
|
+
const fieldVar = resolveFieldRef(fieldRef, manager);
|
|
2510
|
+
if (!(fieldVar == null ? void 0 : fieldVar._id)) continue;
|
|
2511
|
+
const fieldValue = valueObj[fieldName] ?? valueObj[fieldVar._id];
|
|
2512
|
+
if (fieldValue === void 0) continue;
|
|
2513
|
+
if (fieldVar.type === definition.variableType.Object && fieldVar.fields && isObject(fieldValue)) {
|
|
2514
|
+
flattenObjectFields(
|
|
2515
|
+
fieldVar,
|
|
2516
|
+
fieldValue,
|
|
2517
|
+
manager,
|
|
2518
|
+
result
|
|
2519
|
+
);
|
|
2520
|
+
} else {
|
|
2521
|
+
result[fieldVar._id] = fieldValue;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
};
|
|
2525
|
+
const buildFieldIdMapping = (childDef, parentDef, childManager, parentManager) => {
|
|
2526
|
+
const mapping = {};
|
|
2527
|
+
if (!(childDef == null ? void 0 : childDef.fields) || !(parentDef == null ? void 0 : parentDef.fields)) return mapping;
|
|
2528
|
+
const childFields = cleanGraph(childDef.fields);
|
|
2529
|
+
const parentFields = cleanGraph(parentDef.fields);
|
|
2530
|
+
for (const [fieldName, childFieldRef] of Object.entries(childFields)) {
|
|
2531
|
+
const parentFieldRef = parentFields[fieldName];
|
|
2532
|
+
if (!parentFieldRef) continue;
|
|
2533
|
+
const childFieldVar = resolveFieldRef(childFieldRef, childManager);
|
|
2534
|
+
if (!(childFieldVar == null ? void 0 : childFieldVar._id)) continue;
|
|
2535
|
+
const parentFieldVar = resolveFieldRef(parentFieldRef, parentManager);
|
|
2536
|
+
if (!(parentFieldVar == null ? void 0 : parentFieldVar._id)) continue;
|
|
2537
|
+
if (childFieldVar.type === definition.variableType.Object && childFieldVar.fields && (parentFieldVar == null ? void 0 : parentFieldVar.type) === definition.variableType.Object && (parentFieldVar == null ? void 0 : parentFieldVar.fields)) {
|
|
2538
|
+
Object.assign(
|
|
2539
|
+
mapping,
|
|
2540
|
+
buildFieldIdMapping(
|
|
2541
|
+
childFieldVar,
|
|
2542
|
+
parentFieldVar,
|
|
2543
|
+
childManager,
|
|
2544
|
+
parentManager
|
|
2545
|
+
)
|
|
2546
|
+
);
|
|
2547
|
+
continue;
|
|
2548
|
+
}
|
|
2549
|
+
mapping[parentFieldVar._id] = childFieldVar._id;
|
|
2550
|
+
}
|
|
2551
|
+
return mapping;
|
|
2552
|
+
};
|
|
2553
|
+
const resolveArrayItems = (items, manager) => {
|
|
2554
|
+
const result = [];
|
|
2555
|
+
for (const item of items) {
|
|
2556
|
+
if (isLink$1(item)) {
|
|
2557
|
+
const resolved = manager.resolve(item);
|
|
2558
|
+
if (!resolved) continue;
|
|
2559
|
+
const payload = isObject(resolved.value) ? resolved.value : resolved;
|
|
2560
|
+
if (isObject(payload)) {
|
|
2561
|
+
result.push(cleanGraph(payload));
|
|
1967
2562
|
}
|
|
1968
|
-
}
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
...definitionProps
|
|
2563
|
+
} else if (isObject(item)) {
|
|
2564
|
+
const payload = isObject(item.value) ? item.value : item;
|
|
2565
|
+
result.push(cleanGraph(payload));
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
return result;
|
|
2569
|
+
};
|
|
2570
|
+
const remapArrayItems = (items, mapping) => {
|
|
2571
|
+
return items.map((item) => {
|
|
2572
|
+
const remapped = {};
|
|
2573
|
+
for (const [key, value] of Object.entries(item)) {
|
|
2574
|
+
const newKey = mapping[key] ?? key;
|
|
2575
|
+
remapped[newKey] = value;
|
|
2576
|
+
}
|
|
2577
|
+
return remapped;
|
|
1984
2578
|
});
|
|
1985
2579
|
};
|
|
2580
|
+
const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
2581
|
+
const { readVariable, _dep } = useReadVariable();
|
|
2582
|
+
const leafKeys = useMemo(() => {
|
|
2583
|
+
if (!manager || !(definitions == null ? void 0 : definitions.length)) return [];
|
|
2584
|
+
const keys = [];
|
|
2585
|
+
for (const defKey of definitions) {
|
|
2586
|
+
const defVar = manager.resolve(defKey);
|
|
2587
|
+
if (!defVar) continue;
|
|
2588
|
+
if (defVar.type === definition.variableType.Object && defVar.fields) {
|
|
2589
|
+
collectLeafKeys(defVar, manager, keys);
|
|
2590
|
+
} else if (defVar.type === definition.variableType.Array && defVar.definition) {
|
|
2591
|
+
const arrDef = resolveFieldRef(defVar.definition, manager);
|
|
2592
|
+
if ((arrDef == null ? void 0 : arrDef.type) === definition.variableType.Object && (arrDef == null ? void 0 : arrDef.fields)) {
|
|
2593
|
+
collectLeafKeys(arrDef, manager, keys);
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
return keys;
|
|
2598
|
+
}, [definitions, manager]);
|
|
2599
|
+
const leafLayers = useGraphStack(leafKeys.length ? manager : null, leafKeys);
|
|
2600
|
+
const arrayItemKeys = useMemo(() => {
|
|
2601
|
+
var _a;
|
|
2602
|
+
if (!manager || !(definitions == null ? void 0 : definitions.length)) return [];
|
|
2603
|
+
const resolveManager = parentManager ?? manager;
|
|
2604
|
+
if (!resolveManager) return [];
|
|
2605
|
+
const keys = [];
|
|
2606
|
+
for (const defKey of definitions) {
|
|
2607
|
+
const defVar = manager.resolve(defKey);
|
|
2608
|
+
if (!(defVar == null ? void 0 : defVar._id)) continue;
|
|
2609
|
+
if (defVar.type !== definition.variableType.Array || !defVar.definition)
|
|
2610
|
+
continue;
|
|
2611
|
+
const propValue = props[defVar._id];
|
|
2612
|
+
if (!isVariableLink$1(propValue)) continue;
|
|
2613
|
+
const parentVar = resolveManager.resolve(propValue);
|
|
2614
|
+
if ((parentVar == null ? void 0 : parentVar.type) !== definition.variableType.Array) continue;
|
|
2615
|
+
const items = parentVar.defaultValue;
|
|
2616
|
+
if (!Array.isArray(items)) continue;
|
|
2617
|
+
for (const item of items) {
|
|
2618
|
+
if (isLink$1(item)) {
|
|
2619
|
+
keys.push(item);
|
|
2620
|
+
const resolved = resolveManager.resolve(item);
|
|
2621
|
+
if ((resolved == null ? void 0 : resolved.value) && isObject(resolved.value) && ((_a = resolved.value) == null ? void 0 : _a._type)) {
|
|
2622
|
+
const valueKey = keyOfEntity(resolved.value);
|
|
2623
|
+
if (valueKey) keys.push(valueKey);
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
return keys;
|
|
2629
|
+
}, [definitions, manager, parentManager, props, _dep]);
|
|
2630
|
+
const arrayItemLayers = useGraphStack(
|
|
2631
|
+
arrayItemKeys.length ? parentManager ?? manager : null,
|
|
2632
|
+
arrayItemKeys
|
|
2633
|
+
);
|
|
2634
|
+
return useMemo(() => {
|
|
2635
|
+
if (!manager || !(definitions == null ? void 0 : definitions.length)) return props;
|
|
2636
|
+
const resolveManager = parentManager ?? manager;
|
|
2637
|
+
const base = {};
|
|
2638
|
+
for (const layer of leafLayers) {
|
|
2639
|
+
if ((layer == null ? void 0 : layer._id) && (layer == null ? void 0 : layer.defaultValue) != null) {
|
|
2640
|
+
base[layer._id] = layer.defaultValue;
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
const expanded = {};
|
|
2644
|
+
const handledPropKeys = /* @__PURE__ */ new Set();
|
|
2645
|
+
for (const defKey of definitions) {
|
|
2646
|
+
const defVar = manager.resolve(defKey);
|
|
2647
|
+
if (!(defVar == null ? void 0 : defVar._id)) continue;
|
|
2648
|
+
const propValue = props[defVar._id];
|
|
2649
|
+
handledPropKeys.add(defVar._id);
|
|
2650
|
+
if (propValue === void 0) continue;
|
|
2651
|
+
if (defVar.type === definition.variableType.Object && defVar.fields) {
|
|
2652
|
+
if (isObject(propValue)) {
|
|
2653
|
+
flattenObjectFields(
|
|
2654
|
+
defVar,
|
|
2655
|
+
propValue,
|
|
2656
|
+
manager,
|
|
2657
|
+
expanded
|
|
2658
|
+
);
|
|
2659
|
+
continue;
|
|
2660
|
+
}
|
|
2661
|
+
expanded[defVar._id] = propValue;
|
|
2662
|
+
continue;
|
|
2663
|
+
}
|
|
2664
|
+
if (defVar.type === definition.variableType.Array && defVar.definition) {
|
|
2665
|
+
if (isVariableLink$1(propValue) && resolveManager) {
|
|
2666
|
+
const parentVar = resolveManager.resolve(propValue);
|
|
2667
|
+
if ((parentVar == null ? void 0 : parentVar.type) === definition.variableType.Array && (parentVar == null ? void 0 : parentVar.definition)) {
|
|
2668
|
+
const { value: resolvedArray } = readVariable(propValue);
|
|
2669
|
+
if (Array.isArray(resolvedArray)) {
|
|
2670
|
+
const concreteItems = resolveArrayItems(
|
|
2671
|
+
resolvedArray,
|
|
2672
|
+
resolveManager
|
|
2673
|
+
);
|
|
2674
|
+
const childDef = resolveFieldRef(defVar.definition, manager);
|
|
2675
|
+
const parentDef = resolveFieldRef(
|
|
2676
|
+
parentVar.definition,
|
|
2677
|
+
resolveManager
|
|
2678
|
+
);
|
|
2679
|
+
if ((childDef == null ? void 0 : childDef.type) === definition.variableType.Object && (childDef == null ? void 0 : childDef.fields) && (parentDef == null ? void 0 : parentDef.type) === definition.variableType.Object && (parentDef == null ? void 0 : parentDef.fields)) {
|
|
2680
|
+
const mapping = buildFieldIdMapping(
|
|
2681
|
+
childDef,
|
|
2682
|
+
parentDef,
|
|
2683
|
+
manager,
|
|
2684
|
+
resolveManager
|
|
2685
|
+
);
|
|
2686
|
+
expanded[defVar._id] = remapArrayItems(concreteItems, mapping);
|
|
2687
|
+
} else {
|
|
2688
|
+
expanded[defVar._id] = concreteItems;
|
|
2689
|
+
}
|
|
2690
|
+
continue;
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
expanded[defVar._id] = propValue;
|
|
2694
|
+
continue;
|
|
2695
|
+
}
|
|
2696
|
+
expanded[defVar._id] = propValue;
|
|
2697
|
+
continue;
|
|
2698
|
+
}
|
|
2699
|
+
expanded[defVar._id] = propValue;
|
|
2700
|
+
}
|
|
2701
|
+
for (const [key, value] of Object.entries(props)) {
|
|
2702
|
+
if (!handledPropKeys.has(key) && !(key in expanded)) {
|
|
2703
|
+
expanded[key] = value;
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
return { ...base, ...expanded };
|
|
2707
|
+
}, [
|
|
2708
|
+
leafLayers,
|
|
2709
|
+
arrayItemLayers,
|
|
2710
|
+
props,
|
|
2711
|
+
manager,
|
|
2712
|
+
parentManager,
|
|
2713
|
+
definitions,
|
|
2714
|
+
_dep
|
|
2715
|
+
]);
|
|
2716
|
+
};
|
|
1986
2717
|
const CollectionItem = ({
|
|
1987
2718
|
layer,
|
|
1988
2719
|
manager,
|
|
@@ -1992,20 +2723,22 @@ const CollectionItem = ({
|
|
|
1992
2723
|
...restProps
|
|
1993
2724
|
}) => {
|
|
1994
2725
|
var _a;
|
|
1995
|
-
|
|
2726
|
+
keyOfEntity(layer);
|
|
1996
2727
|
const definitionId = ((_a = entityOfKey(sourceDefinition)) == null ? void 0 : _a._id) ?? "";
|
|
1997
2728
|
const value = layer.value ?? layer;
|
|
1998
|
-
const
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2729
|
+
const inputProps = {
|
|
2730
|
+
[definitionId]: value
|
|
2731
|
+
};
|
|
2732
|
+
const props = cleanGraph(inputProps);
|
|
2733
|
+
const definitions = useMemo(
|
|
2734
|
+
() => sourceDefinition ? [sourceDefinition] : [],
|
|
2735
|
+
[sourceDefinition]
|
|
2736
|
+
);
|
|
2737
|
+
const expandedProps = useExtractProps(props, manager, void 0, definitions);
|
|
2738
|
+
const cssVars = useMemo(
|
|
2739
|
+
() => toCssCustomProperties(expandedProps),
|
|
2740
|
+
[expandedProps]
|
|
2741
|
+
);
|
|
2009
2742
|
return /* @__PURE__ */ jsx(
|
|
2010
2743
|
Scope,
|
|
2011
2744
|
{
|
|
@@ -2015,7 +2748,7 @@ const CollectionItem = ({
|
|
|
2015
2748
|
type: definition.scopeTypes.CollectionItemScope,
|
|
2016
2749
|
...restProps,
|
|
2017
2750
|
sourceDefinition,
|
|
2018
|
-
value:
|
|
2751
|
+
value: expandedProps,
|
|
2019
2752
|
manager
|
|
2020
2753
|
},
|
|
2021
2754
|
children: children == null ? void 0 : children.map((child) => /* @__PURE__ */ jsx(
|
|
@@ -2023,7 +2756,7 @@ const CollectionItem = ({
|
|
|
2023
2756
|
{
|
|
2024
2757
|
style: {
|
|
2025
2758
|
display: "contents",
|
|
2026
|
-
...
|
|
2759
|
+
...cssVars
|
|
2027
2760
|
},
|
|
2028
2761
|
children: /* @__PURE__ */ jsx(FrameElement, { ...restProps, layerKey: child })
|
|
2029
2762
|
},
|
|
@@ -2139,24 +2872,18 @@ const Frame = ({
|
|
|
2139
2872
|
}
|
|
2140
2873
|
);
|
|
2141
2874
|
};
|
|
2142
|
-
const useIsomorphicEffect = (callback, deps) => {
|
|
2143
|
-
useEffect(callback, deps);
|
|
2144
|
-
if (!isBrowser$1) {
|
|
2145
|
-
callback();
|
|
2146
|
-
}
|
|
2147
|
-
};
|
|
2148
2875
|
const useCssChunk = (linkKey) => {
|
|
2149
2876
|
const { manager } = useContext(FragmentContext);
|
|
2150
2877
|
const [chunkId] = useLayerValue(linkKey, "chunkId", { manager });
|
|
2151
2878
|
const [enabled] = useLayerValue(linkKey, "enabled", { manager });
|
|
2152
|
-
const
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
}, [enabled]);
|
|
2879
|
+
const { addCssChunk } = useStyleSheet(manager);
|
|
2880
|
+
useEffect(() => {
|
|
2881
|
+
if (!enabled || !chunkId) return;
|
|
2882
|
+
const cleanup = addCssChunk(chunkId);
|
|
2883
|
+
return () => {
|
|
2884
|
+
cleanup();
|
|
2885
|
+
};
|
|
2886
|
+
}, [enabled, chunkId, addCssChunk]);
|
|
2160
2887
|
};
|
|
2161
2888
|
const CssChunk = ({ linkKey }) => {
|
|
2162
2889
|
useCssChunk(linkKey);
|
|
@@ -2170,23 +2897,18 @@ const useFragmentManager = (fragmentId, inputGlobalManager) => {
|
|
|
2170
2897
|
getFragmentManager,
|
|
2171
2898
|
queryFragmentManager
|
|
2172
2899
|
} = useGlobalManager(inputGlobalManager);
|
|
2173
|
-
const [loading, setLoading] = useState(false);
|
|
2174
2900
|
const manager = getFragmentManager(fragmentId);
|
|
2901
|
+
const loading = !!fragmentId && !manager;
|
|
2175
2902
|
useEffect(() => {
|
|
2176
|
-
(
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
await queryFragmentManager(fragmentId);
|
|
2180
|
-
setLoading(false);
|
|
2181
|
-
}
|
|
2182
|
-
})();
|
|
2903
|
+
if (fragmentsGraph && !getFragmentManager(fragmentId) && !!fragmentId) {
|
|
2904
|
+
queryFragmentManager(fragmentId);
|
|
2905
|
+
}
|
|
2183
2906
|
}, [fragmentId, fragmentsGraph]);
|
|
2184
2907
|
return {
|
|
2185
2908
|
loading,
|
|
2186
2909
|
manager,
|
|
2187
2910
|
fragmentLayerKey: (_a = manager == null ? void 0 : manager.$fragment) == null ? void 0 : _a.root,
|
|
2188
2911
|
queryFragmentManager
|
|
2189
|
-
// loadFragmentManager,
|
|
2190
2912
|
};
|
|
2191
2913
|
};
|
|
2192
2914
|
const useFragmentChildren = (fragmentId) => {
|
|
@@ -2244,7 +2966,7 @@ const useFragment = (fragmentId, globalManager) => {
|
|
|
2244
2966
|
const { properties: definitions } = useFragmentProperties(fragmentId);
|
|
2245
2967
|
const scopes = useContext(ScopeContext);
|
|
2246
2968
|
!(scopes == null ? void 0 : scopes.length);
|
|
2247
|
-
const { addLayerStyle,
|
|
2969
|
+
const { addLayerStyle, mount, unmount } = useStyleSheet(
|
|
2248
2970
|
fragmentContext.manager
|
|
2249
2971
|
);
|
|
2250
2972
|
if (fragmentContext.manager) {
|
|
@@ -2279,35 +3001,26 @@ const useFragment = (fragmentId, globalManager) => {
|
|
|
2279
3001
|
definitions
|
|
2280
3002
|
};
|
|
2281
3003
|
};
|
|
2282
|
-
const FragmentInternal = (
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
// fragmentManager={fragmentContext.manager}
|
|
2303
|
-
// layerKey={layerKey}
|
|
2304
|
-
// value={{
|
|
2305
|
-
// type: definition.scopeTypes.FragmentScope,
|
|
2306
|
-
// manager: fragmentContext.manager,
|
|
2307
|
-
// definitions,
|
|
2308
|
-
// }}
|
|
2309
|
-
// >
|
|
2310
|
-
/* @__PURE__ */ jsxs("div", { "data-key": layerKey, className: hash, children: [
|
|
3004
|
+
const FragmentInternal = memo(
|
|
3005
|
+
({
|
|
3006
|
+
fragmentId,
|
|
3007
|
+
globalManager,
|
|
3008
|
+
pauseInteractions,
|
|
3009
|
+
collectStyle,
|
|
3010
|
+
FrameElement = Frame
|
|
3011
|
+
}) => {
|
|
3012
|
+
const {
|
|
3013
|
+
children,
|
|
3014
|
+
fragmentContext,
|
|
3015
|
+
hash,
|
|
3016
|
+
chunkLinks,
|
|
3017
|
+
isResize,
|
|
3018
|
+
isTopFragment,
|
|
3019
|
+
definitions,
|
|
3020
|
+
layerKey
|
|
3021
|
+
} = useFragment(fragmentId);
|
|
3022
|
+
if (!fragmentContext.manager) return null;
|
|
3023
|
+
return /* @__PURE__ */ jsxs("div", { "data-key": layerKey, className: hash, children: [
|
|
2311
3024
|
chunkLinks.map((linkKey) => /* @__PURE__ */ jsx(CssChunk, { linkKey })),
|
|
2312
3025
|
children.map((childLink) => {
|
|
2313
3026
|
var _a;
|
|
@@ -2325,29 +3038,57 @@ const FragmentInternal = ({
|
|
|
2325
3038
|
childLink
|
|
2326
3039
|
);
|
|
2327
3040
|
})
|
|
2328
|
-
] })
|
|
2329
|
-
|
|
2330
|
-
|
|
3041
|
+
] });
|
|
3042
|
+
}
|
|
3043
|
+
);
|
|
2331
3044
|
const Fragment = (props) => {
|
|
2332
3045
|
const currentGlobalManager = useContext(GlobalManagerContext);
|
|
2333
3046
|
const { manager: resultGlobalManager } = useGlobalManager(
|
|
2334
3047
|
props.globalManager
|
|
2335
3048
|
);
|
|
2336
3049
|
const { manager } = useFragmentManager(props.fragmentId, resultGlobalManager);
|
|
2337
|
-
const
|
|
3050
|
+
const fragmentContextValue = useMemo(() => ({ manager }), [manager]);
|
|
3051
|
+
const Base = /* @__PURE__ */ jsx(FragmentContext.Provider, { value: fragmentContextValue, children: /* @__PURE__ */ jsx(FragmentInternal, { ...props }) });
|
|
2338
3052
|
if (!currentGlobalManager) {
|
|
2339
3053
|
return /* @__PURE__ */ jsx(GlobalManagerProvider, { value: resultGlobalManager, children: Base });
|
|
2340
3054
|
}
|
|
2341
3055
|
return Base;
|
|
2342
3056
|
};
|
|
3057
|
+
const resolveObjectToConcreteValue = (objectVar, manager, readVariable) => {
|
|
3058
|
+
const fields = cleanGraph(objectVar.fields);
|
|
3059
|
+
const result = {};
|
|
3060
|
+
for (const [fieldName, fieldRef] of Object.entries(fields)) {
|
|
3061
|
+
let fieldVar;
|
|
3062
|
+
let fieldKey;
|
|
3063
|
+
if (isVariableLink$1(fieldRef)) {
|
|
3064
|
+
fieldKey = fieldRef;
|
|
3065
|
+
fieldVar = manager == null ? void 0 : manager.resolve(fieldKey);
|
|
3066
|
+
} else if (isObject(fieldRef) && (fieldRef == null ? void 0 : fieldRef._id)) {
|
|
3067
|
+
fieldKey = keyOfEntity(fieldRef);
|
|
3068
|
+
fieldVar = fieldRef;
|
|
3069
|
+
}
|
|
3070
|
+
if (!fieldVar || !fieldKey) continue;
|
|
3071
|
+
if (fieldVar.type === definition.variableType.Object && fieldVar.fields) {
|
|
3072
|
+
result[fieldName] = resolveObjectToConcreteValue(
|
|
3073
|
+
fieldVar,
|
|
3074
|
+
manager,
|
|
3075
|
+
readVariable
|
|
3076
|
+
);
|
|
3077
|
+
} else {
|
|
3078
|
+
const { value } = readVariable(fieldKey);
|
|
3079
|
+
if (value != null) {
|
|
3080
|
+
result[fieldName] = value;
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
return result;
|
|
3085
|
+
};
|
|
2343
3086
|
const useInstanceProps = (instanceProps) => {
|
|
2344
3087
|
const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
|
|
2345
3088
|
const { manager: loadedManager } = useFragmentManager(
|
|
2346
3089
|
isTopInstance ? instanceProps == null ? void 0 : instanceProps.fragmentId : null
|
|
2347
3090
|
);
|
|
2348
3091
|
const { manager: fragmentContextManager } = useContext(FragmentContext);
|
|
2349
|
-
const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(instanceProps == null ? void 0 : instanceProps.fragmentId);
|
|
2350
|
-
const { readVariable } = useReadVariable();
|
|
2351
3092
|
const fragmentManager = isTopInstance ? loadedManager : fragmentContextManager;
|
|
2352
3093
|
const [instanceLayer] = useGraph(fragmentManager, instanceProps.layerKey);
|
|
2353
3094
|
const instanceLayerProps = (instanceLayer == null ? void 0 : instanceLayer.props) ?? {};
|
|
@@ -2359,19 +3100,40 @@ const useInstanceProps = (instanceProps) => {
|
|
|
2359
3100
|
...localProps
|
|
2360
3101
|
};
|
|
2361
3102
|
}
|
|
2362
|
-
const extractProps =
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
3103
|
+
const extractProps = cleanGraph(inputProps);
|
|
3104
|
+
const { readVariable } = useReadVariable();
|
|
3105
|
+
let resolvedProps = extractProps;
|
|
3106
|
+
if (!isTopInstance) {
|
|
3107
|
+
resolvedProps = {};
|
|
3108
|
+
for (const [key, value] of Object.entries(extractProps)) {
|
|
3109
|
+
if (!isVariableLink$1(value)) {
|
|
3110
|
+
resolvedProps[key] = value;
|
|
3111
|
+
continue;
|
|
3112
|
+
}
|
|
3113
|
+
const varLayer = fragmentManager == null ? void 0 : fragmentManager.resolve(value);
|
|
3114
|
+
if ((varLayer == null ? void 0 : varLayer.type) === definition.variableType.Array) {
|
|
3115
|
+
resolvedProps[key] = value;
|
|
3116
|
+
continue;
|
|
3117
|
+
}
|
|
3118
|
+
if ((varLayer == null ? void 0 : varLayer.type) === definition.variableType.Object && (varLayer == null ? void 0 : varLayer.fields)) {
|
|
3119
|
+
resolvedProps[key] = resolveObjectToConcreteValue(
|
|
3120
|
+
varLayer,
|
|
3121
|
+
fragmentManager,
|
|
3122
|
+
readVariable
|
|
3123
|
+
);
|
|
3124
|
+
continue;
|
|
3125
|
+
}
|
|
3126
|
+
const { value: resolved } = readVariable(value);
|
|
3127
|
+
resolvedProps[key] = resolved;
|
|
3128
|
+
}
|
|
3129
|
+
}
|
|
2367
3130
|
useEffect(() => {
|
|
2368
3131
|
if (isValue(instanceProps == null ? void 0 : instanceProps.props)) {
|
|
2369
3132
|
setLocalProps(instanceProps.props);
|
|
2370
3133
|
}
|
|
2371
3134
|
}, [instanceProps == null ? void 0 : instanceProps.props]);
|
|
2372
3135
|
return {
|
|
2373
|
-
props:
|
|
2374
|
-
cssProps: getCssVariables(extractProps),
|
|
3136
|
+
props: resolvedProps,
|
|
2375
3137
|
onChangeProps: (variableId, value) => {
|
|
2376
3138
|
var _a;
|
|
2377
3139
|
setLocalProps((prev) => ({ ...prev, [variableId]: value }));
|
|
@@ -2389,7 +3151,7 @@ const useInstance = (instanceProps) => {
|
|
|
2389
3151
|
);
|
|
2390
3152
|
const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
|
|
2391
3153
|
const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(resultFragmentId);
|
|
2392
|
-
const { props,
|
|
3154
|
+
const { props, onChangeProps } = useInstanceProps(instanceProps);
|
|
2393
3155
|
const classnames = useClassnames(
|
|
2394
3156
|
instanceProps.layerKey,
|
|
2395
3157
|
innerFragmentManager
|
|
@@ -2400,7 +3162,6 @@ const useInstance = (instanceProps) => {
|
|
|
2400
3162
|
events,
|
|
2401
3163
|
definitions,
|
|
2402
3164
|
props,
|
|
2403
|
-
cssProps,
|
|
2404
3165
|
parentManager,
|
|
2405
3166
|
innerManager: innerFragmentManager,
|
|
2406
3167
|
fragmentId: resultFragmentId,
|
|
@@ -2408,6 +3169,22 @@ const useInstance = (instanceProps) => {
|
|
|
2408
3169
|
onChangeProps
|
|
2409
3170
|
};
|
|
2410
3171
|
};
|
|
3172
|
+
const useSuspenseLoadFragment = (globalManager, fragmentId, skip) => {
|
|
3173
|
+
var _a, _b;
|
|
3174
|
+
if (skip || !globalManager || !fragmentId) return;
|
|
3175
|
+
const cache = getSuspenseCache(globalManager);
|
|
3176
|
+
const valueOrPromise = (_b = (_a = globalManager.$load) == null ? void 0 : _a.loadFragment) == null ? void 0 : _b.call(_a, fragmentId);
|
|
3177
|
+
if (valueOrPromise == null) return;
|
|
3178
|
+
createSuspenseResource(`fragment:${fragmentId}`, valueOrPromise, cache).read();
|
|
3179
|
+
};
|
|
3180
|
+
const useSuspenseLoadArea = (globalManager, areaCode, skip) => {
|
|
3181
|
+
var _a, _b;
|
|
3182
|
+
if (skip || !globalManager || !areaCode) return null;
|
|
3183
|
+
const cache = getSuspenseCache(globalManager);
|
|
3184
|
+
const valueOrPromise = (_b = (_a = globalManager.$load) == null ? void 0 : _a.loadArea) == null ? void 0 : _b.call(_a, areaCode);
|
|
3185
|
+
if (valueOrPromise == null) return null;
|
|
3186
|
+
return createSuspenseResource(`area:${areaCode}`, valueOrPromise, cache).read();
|
|
3187
|
+
};
|
|
2411
3188
|
const InstanceInitial = ({
|
|
2412
3189
|
Tag: inputTag,
|
|
2413
3190
|
style = {},
|
|
@@ -2415,13 +3192,12 @@ const InstanceInitial = ({
|
|
|
2415
3192
|
FrameElement,
|
|
2416
3193
|
...instanceProps
|
|
2417
3194
|
}) => {
|
|
2418
|
-
var _a
|
|
3195
|
+
var _a;
|
|
2419
3196
|
const ssr = ((_a = instanceProps == null ? void 0 : instanceProps.options) == null ? void 0 : _a.ssr) ?? true;
|
|
2420
3197
|
const link = useLayerLink(instanceProps.layerKey);
|
|
2421
3198
|
const Tag = (link == null ? void 0 : link.isLink) ? inputTag ?? "a" : inputTag ?? "div";
|
|
2422
3199
|
const {
|
|
2423
3200
|
fragmentId,
|
|
2424
|
-
cssProps,
|
|
2425
3201
|
parentManager,
|
|
2426
3202
|
events,
|
|
2427
3203
|
props,
|
|
@@ -2434,52 +3210,67 @@ const InstanceInitial = ({
|
|
|
2434
3210
|
...instanceProps,
|
|
2435
3211
|
pauseInteractions
|
|
2436
3212
|
});
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
3213
|
+
const expandedProps = useExtractProps(
|
|
3214
|
+
props,
|
|
3215
|
+
innerManager,
|
|
3216
|
+
parentManager,
|
|
3217
|
+
definitions
|
|
3218
|
+
);
|
|
3219
|
+
const cssVars = useMemo(
|
|
3220
|
+
() => toCssCustomProperties(expandedProps),
|
|
3221
|
+
[expandedProps]
|
|
3222
|
+
);
|
|
3223
|
+
useSuspenseLoadFragment(globalManager, fragmentId, !ssr);
|
|
3224
|
+
const scopeValue = useMemo(
|
|
3225
|
+
() => ({
|
|
3226
|
+
type: definition.scopeTypes.InstanceScope,
|
|
3227
|
+
props: expandedProps,
|
|
3228
|
+
definitions,
|
|
3229
|
+
fragmentId,
|
|
3230
|
+
documentManager: innerManager,
|
|
3231
|
+
layerKey: instanceProps.layerKey,
|
|
3232
|
+
onChangeProps
|
|
3233
|
+
}),
|
|
3234
|
+
[
|
|
3235
|
+
expandedProps,
|
|
3236
|
+
definitions,
|
|
3237
|
+
fragmentId,
|
|
3238
|
+
innerManager,
|
|
3239
|
+
instanceProps.layerKey,
|
|
3240
|
+
onChangeProps
|
|
3241
|
+
]
|
|
3242
|
+
);
|
|
3243
|
+
const instanceContextValue = useMemo(
|
|
3244
|
+
() => ({
|
|
3245
|
+
layerKey: instanceProps.layerKey,
|
|
3246
|
+
definitions,
|
|
3247
|
+
innerManager,
|
|
3248
|
+
parentManager,
|
|
3249
|
+
props: expandedProps
|
|
3250
|
+
}),
|
|
3251
|
+
[
|
|
3252
|
+
instanceProps.layerKey,
|
|
3253
|
+
definitions,
|
|
3254
|
+
innerManager,
|
|
3255
|
+
parentManager,
|
|
3256
|
+
expandedProps
|
|
3257
|
+
]
|
|
3258
|
+
);
|
|
2440
3259
|
return /* @__PURE__ */ jsx(
|
|
2441
3260
|
Scope,
|
|
2442
3261
|
{
|
|
2443
3262
|
fragmentManager: innerManager,
|
|
2444
3263
|
layerKey: instanceProps.layerKey,
|
|
2445
|
-
value:
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
definitions,
|
|
2449
|
-
fragmentId,
|
|
2450
|
-
documentManager: innerManager,
|
|
2451
|
-
layerKey: instanceProps.layerKey,
|
|
2452
|
-
onChangeProps
|
|
2453
|
-
},
|
|
2454
|
-
children: /* @__PURE__ */ jsx(
|
|
2455
|
-
InstanceContext$1.Provider,
|
|
3264
|
+
value: scopeValue,
|
|
3265
|
+
children: /* @__PURE__ */ jsx(InstanceContext$1.Provider, { value: instanceContextValue, children: parentManager ? /* @__PURE__ */ jsx(
|
|
3266
|
+
Tag,
|
|
2456
3267
|
{
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
},
|
|
2464
|
-
children: parentManager ? /* @__PURE__ */ jsx(
|
|
2465
|
-
Tag,
|
|
2466
|
-
{
|
|
2467
|
-
className: classnames,
|
|
2468
|
-
"data-key": instanceProps.layerKey,
|
|
2469
|
-
style: { ...style, ...cssProps },
|
|
2470
|
-
...link.linkProps,
|
|
2471
|
-
...events,
|
|
2472
|
-
children: /* @__PURE__ */ jsx(
|
|
2473
|
-
Fragment,
|
|
2474
|
-
{
|
|
2475
|
-
fragmentId,
|
|
2476
|
-
globalManager,
|
|
2477
|
-
FrameElement,
|
|
2478
|
-
pauseInteractions
|
|
2479
|
-
}
|
|
2480
|
-
)
|
|
2481
|
-
}
|
|
2482
|
-
) : /* @__PURE__ */ jsx(Tag, { style: { ...style, ...cssProps }, ...link.linkProps, children: /* @__PURE__ */ jsx(
|
|
3268
|
+
className: classnames,
|
|
3269
|
+
"data-key": instanceProps.layerKey,
|
|
3270
|
+
style: { ...style, ...cssVars },
|
|
3271
|
+
...link.linkProps,
|
|
3272
|
+
...events,
|
|
3273
|
+
children: /* @__PURE__ */ jsx(
|
|
2483
3274
|
Fragment,
|
|
2484
3275
|
{
|
|
2485
3276
|
fragmentId,
|
|
@@ -2487,9 +3278,17 @@ const InstanceInitial = ({
|
|
|
2487
3278
|
FrameElement,
|
|
2488
3279
|
pauseInteractions
|
|
2489
3280
|
}
|
|
2490
|
-
)
|
|
3281
|
+
)
|
|
2491
3282
|
}
|
|
2492
|
-
)
|
|
3283
|
+
) : /* @__PURE__ */ jsx(Tag, { style: { ...style, ...cssVars }, ...link.linkProps, children: /* @__PURE__ */ jsx(
|
|
3284
|
+
Fragment,
|
|
3285
|
+
{
|
|
3286
|
+
fragmentId,
|
|
3287
|
+
globalManager,
|
|
3288
|
+
FrameElement,
|
|
3289
|
+
pauseInteractions
|
|
3290
|
+
}
|
|
3291
|
+
) }) })
|
|
2493
3292
|
}
|
|
2494
3293
|
);
|
|
2495
3294
|
};
|
|
@@ -2509,26 +3308,24 @@ const Instance = (props) => {
|
|
|
2509
3308
|
) });
|
|
2510
3309
|
};
|
|
2511
3310
|
const useArea = (options) => {
|
|
2512
|
-
|
|
3311
|
+
var _a;
|
|
3312
|
+
const { manager: resultGlobalManager } = useGlobalManager(
|
|
2513
3313
|
options == null ? void 0 : options.globalManager
|
|
2514
3314
|
);
|
|
2515
|
-
const
|
|
3315
|
+
const ssr = ((_a = options == null ? void 0 : options.options) == null ? void 0 : _a.ssr) ?? true;
|
|
3316
|
+
const areaData = useSuspenseLoadArea(
|
|
3317
|
+
resultGlobalManager,
|
|
3318
|
+
options.areaCode,
|
|
3319
|
+
!(isBrowser || ssr)
|
|
3320
|
+
);
|
|
2516
3321
|
const { manager: fragmentManager } = useFragmentManager(
|
|
2517
|
-
areaData.fragmentId,
|
|
3322
|
+
areaData == null ? void 0 : areaData.fragmentId,
|
|
2518
3323
|
resultGlobalManager
|
|
2519
3324
|
);
|
|
2520
3325
|
const resultProps = useMemo(
|
|
2521
|
-
() => ({ ...(areaData == null ? void 0 : areaData.props) ?? {}, ...(options == null ? void 0 : options.props) ??
|
|
3326
|
+
() => ({ ...(areaData == null ? void 0 : areaData.props) ?? {}, ...(options == null ? void 0 : options.props) ?? {} }),
|
|
2522
3327
|
[areaData, options]
|
|
2523
3328
|
);
|
|
2524
|
-
useEffect(() => {
|
|
2525
|
-
(async () => {
|
|
2526
|
-
const response = await queryArea(options.areaCode);
|
|
2527
|
-
if (response) {
|
|
2528
|
-
setAreaData(response);
|
|
2529
|
-
}
|
|
2530
|
-
})();
|
|
2531
|
-
}, []);
|
|
2532
3329
|
return {
|
|
2533
3330
|
...areaData,
|
|
2534
3331
|
fragmentManager,
|
|
@@ -2537,28 +3334,30 @@ const useArea = (options) => {
|
|
|
2537
3334
|
};
|
|
2538
3335
|
};
|
|
2539
3336
|
const AreaInitial = (areaProps) => {
|
|
2540
|
-
var _a, _b, _c;
|
|
2541
|
-
const { manager: globalManager } = useGlobalManager(areaProps == null ? void 0 : areaProps.globalManager);
|
|
2542
|
-
const ssr = ((_a = areaProps == null ? void 0 : areaProps.options) == null ? void 0 : _a.ssr) ?? true;
|
|
2543
|
-
if (isBrowser || ssr) {
|
|
2544
|
-
(_c = (_b = globalManager == null ? void 0 : globalManager.$load) == null ? void 0 : _b.loadArea) == null ? void 0 : _c.call(_b, areaProps.areaCode, {
|
|
2545
|
-
suspense: true
|
|
2546
|
-
});
|
|
2547
|
-
}
|
|
2548
3337
|
const areaData = useArea(areaProps);
|
|
2549
3338
|
if (!areaData) return null;
|
|
2550
|
-
|
|
3339
|
+
const areaManager = useMemo(
|
|
3340
|
+
() => createAreaManager({
|
|
3341
|
+
areaId: areaData.areaId,
|
|
3342
|
+
campaignId: areaData.campaignId,
|
|
3343
|
+
variantId: areaData.variantId,
|
|
3344
|
+
areaProperties: areaData.areaProperties
|
|
3345
|
+
}),
|
|
3346
|
+
[areaData.areaId]
|
|
3347
|
+
);
|
|
3348
|
+
return /* @__PURE__ */ jsx(AreaManagerProvider, { value: areaManager, children: /* @__PURE__ */ jsx(
|
|
2551
3349
|
Scope,
|
|
2552
3350
|
{
|
|
2553
3351
|
fragmentManager: areaData.fragmentManager,
|
|
2554
3352
|
layerKey: "Area",
|
|
2555
3353
|
value: {
|
|
2556
3354
|
type: definition.scopeTypes.AreaScope,
|
|
3355
|
+
areaManager,
|
|
2557
3356
|
...areaData ?? {}
|
|
2558
3357
|
},
|
|
2559
3358
|
children: /* @__PURE__ */ jsx(Instance, { fragmentId: areaData.fragmentId, props: areaData == null ? void 0 : areaData.props })
|
|
2560
3359
|
}
|
|
2561
|
-
);
|
|
3360
|
+
) });
|
|
2562
3361
|
};
|
|
2563
3362
|
const Area = (props) => {
|
|
2564
3363
|
return "globalManager" in props ? /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(GlobalManagerProvider, { value: props.globalManager, children: /* @__PURE__ */ jsx(AreaInitial, { ...props }) }) }) : /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(AreaInitial, { ...props }) });
|
|
@@ -2585,6 +3384,8 @@ const useLayerCssOverride = (layerKey) => {
|
|
|
2585
3384
|
};
|
|
2586
3385
|
export {
|
|
2587
3386
|
Area,
|
|
3387
|
+
AreaManagerContext,
|
|
3388
|
+
AreaManagerProvider,
|
|
2588
3389
|
Collection,
|
|
2589
3390
|
CssChunk,
|
|
2590
3391
|
CustomRender,
|
|
@@ -2611,12 +3412,12 @@ export {
|
|
|
2611
3412
|
cloneLayer,
|
|
2612
3413
|
copyLayer,
|
|
2613
3414
|
createLayer,
|
|
3415
|
+
createSuspenseResource,
|
|
2614
3416
|
declareFragmentProperty,
|
|
2615
3417
|
defaultCustomRender,
|
|
2616
3418
|
duplicateLayer,
|
|
2617
3419
|
findBreakpoint,
|
|
2618
3420
|
getAllParents,
|
|
2619
|
-
getCssVariables,
|
|
2620
3421
|
getHydratedData,
|
|
2621
3422
|
getKey,
|
|
2622
3423
|
getNormalizeLayer,
|
|
@@ -2624,6 +3425,7 @@ export {
|
|
|
2624
3425
|
getOverriderByLayers,
|
|
2625
3426
|
getParent,
|
|
2626
3427
|
getStylesheetKey,
|
|
3428
|
+
getSuspenseCache,
|
|
2627
3429
|
hashGenerator,
|
|
2628
3430
|
insertChildren,
|
|
2629
3431
|
isBrowser,
|
|
@@ -2635,7 +3437,6 @@ export {
|
|
|
2635
3437
|
isTopLevel,
|
|
2636
3438
|
isVariableLink,
|
|
2637
3439
|
layerFieldSetter,
|
|
2638
|
-
loadFragmentManager,
|
|
2639
3440
|
makeSnapshot,
|
|
2640
3441
|
moveChildren,
|
|
2641
3442
|
nodeWalker,
|
|
@@ -2644,6 +3445,7 @@ export {
|
|
|
2644
3445
|
serializeData,
|
|
2645
3446
|
setKey,
|
|
2646
3447
|
spliceChildren,
|
|
3448
|
+
toCssCustomProperties,
|
|
2647
3449
|
transformCssValue,
|
|
2648
3450
|
useArea,
|
|
2649
3451
|
useCollection,
|
|
@@ -2661,7 +3463,6 @@ export {
|
|
|
2661
3463
|
useLayerBorder,
|
|
2662
3464
|
useLayerChildren,
|
|
2663
3465
|
useLayerCssOverride,
|
|
2664
|
-
useLayerCssVariable,
|
|
2665
3466
|
useLayerDisplay,
|
|
2666
3467
|
useLayerFlex,
|
|
2667
3468
|
useLayerLayout,
|
|
@@ -2679,6 +3480,8 @@ export {
|
|
|
2679
3480
|
useReadVariable,
|
|
2680
3481
|
useReadVariables,
|
|
2681
3482
|
useRenderTarget,
|
|
3483
|
+
useResolvedLayer,
|
|
3484
|
+
useResolvedLayerVariables,
|
|
2682
3485
|
useTextAttributes,
|
|
2683
3486
|
useTextContent,
|
|
2684
3487
|
useTextHighlight,
|