@fragmentsx/render-react 1.6.1 → 1.6.2
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/layer/useLayerValue.d.ts.map +1 -1
- package/dist/hooks/layer/useReadVariables.d.ts.map +1 -1
- package/dist/hooks/utils/useExtractProps.d.ts.map +1 -1
- package/dist/hooks/utils/useLayerInteractions.d.ts.map +1 -1
- package/dist/index.cjs.js +145 -32
- package/dist/index.es.js +146 -33
- package/dist/nodes/Area/Area.d.ts +2 -1
- package/dist/nodes/Area/Area.d.ts.map +1 -1
- package/dist/nodes/Area/Area.test.d.ts +2 -0
- package/dist/nodes/Area/Area.test.d.ts.map +1 -0
- package/dist/nodes/Area/index.d.ts +1 -1
- package/dist/nodes/Area/index.d.ts.map +1 -1
- package/dist/nodes/Collection/hooks/useCollection.d.ts.map +1 -1
- package/dist/nodes/Text/hooks/useTextAttributes.d.ts +1 -1
- package/dist/nodes/Text/hooks/useTextContent.d.ts +3 -1
- package/dist/nodes/Text/hooks/useTextContent.d.ts.map +1 -1
- package/dist/nodes/Text/hooks/useTextContent.test.d.ts +2 -0
- package/dist/nodes/Text/hooks/useTextContent.test.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayerValue.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useLayerValue.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,UAAU,EAGV,OAAO,EAER,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAI/D,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,aAAa,aACd,OAAO,YACP,MAAM,YACN,oBAAoB,
|
|
1
|
+
{"version":3,"file":"useLayerValue.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useLayerValue.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,UAAU,EAGV,OAAO,EAER,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAI/D,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,aAAa,aACd,OAAO,YACP,MAAM,YACN,oBAAoB,UAmF/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReadVariables.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useReadVariables.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"useReadVariables.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useReadVariables.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAwBrE,eAAO,MAAM,gBAAgB,iBACb,OAAO,EAAE,kBACP,UAAU,GAAG,IAAI;;;GAoHlC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExtractProps.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/useExtractProps.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAe,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"useExtractProps.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/useExtractProps.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAe,OAAO,EAAE,MAAM,mBAAmB,CAAC;AA0OrE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,UACnB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACpB,UAAU,kBACJ,UAAU,gBACZ,OAAO,EAAE,KACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAwQxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayerInteractions.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/useLayerInteractions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,OAAO,EAAE,MAAM,mBAAmB,CAAC;AASzD,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,oBAAoB,aACrB,OAAO,YACP,2BAA2B;;;;
|
|
1
|
+
{"version":3,"file":"useLayerInteractions.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/useLayerInteractions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,OAAO,EAAE,MAAM,mBAAmB,CAAC;AASzD,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,oBAAoB,aACrB,OAAO,YACP,2BAA2B;;;;CAiGtC,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
6
|
const react = require("react");
|
|
4
7
|
const definition = require("@fragmentsx/definition");
|
|
@@ -913,12 +916,13 @@ const useReadVariables = (variableKeys, customManager) => {
|
|
|
913
916
|
(scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.CollectionItemScope
|
|
914
917
|
);
|
|
915
918
|
return filterKeys.map((variableKey, index) => {
|
|
916
|
-
var _a2;
|
|
917
|
-
|
|
919
|
+
var _a2, _b2;
|
|
920
|
+
variableLayers[index];
|
|
921
|
+
const layer = ((_a2 = getNormalizeLayer(variableKey, resultManager)) == null ? void 0 : _a2.layer) ?? null;
|
|
918
922
|
const { _id: propertyId } = layer ?? {};
|
|
919
923
|
let collectionItemProp = void 0;
|
|
920
924
|
if (lastCollectionItem && propertyId) {
|
|
921
|
-
collectionItemProp = utils.isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((
|
|
925
|
+
collectionItemProp = utils.isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_b2 = core.entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _b2._id) === propertyId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue(lastCollectionItem == null ? void 0 : lastCollectionItem.value, propertyId);
|
|
922
926
|
}
|
|
923
927
|
const instanceProp = (instanceProps == null ? void 0 : instanceProps[propertyId]) ?? null;
|
|
924
928
|
const areaLayer = areaManager == null ? void 0 : areaManager.resolve(variableKey);
|
|
@@ -1906,6 +1910,7 @@ const useLayerStyles = (layerKey) => {
|
|
|
1906
1910
|
return {};
|
|
1907
1911
|
}
|
|
1908
1912
|
};
|
|
1913
|
+
const MAX_NESTING_DEPTH = 5;
|
|
1909
1914
|
function extractVariablesFromHtml(html) {
|
|
1910
1915
|
if (!html) return [];
|
|
1911
1916
|
const regex = /<span(?=\s)(?=(?:[^>]*?\s)?class="[^"]*variable[^"]*")(?=(?:[^>]*?\s)?data-type="mention")(?=(?:[^>]*?\s)?data-id="([^"]+)")[^>]*>.*?<\/span>/gi;
|
|
@@ -1924,24 +1929,75 @@ function extractVariablesFromHtml(html) {
|
|
|
1924
1929
|
}
|
|
1925
1930
|
return mentions;
|
|
1926
1931
|
}
|
|
1932
|
+
function collectNestedVariableKeys(content, instanceProps, fragmentManager, maxDepth = MAX_NESTING_DEPTH) {
|
|
1933
|
+
var _a, _b;
|
|
1934
|
+
const allKeys = [];
|
|
1935
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1936
|
+
let currentContents = [content];
|
|
1937
|
+
for (let depth = 0; depth < maxDepth; depth++) {
|
|
1938
|
+
const nextContents = [];
|
|
1939
|
+
for (const html of currentContents) {
|
|
1940
|
+
const variables = extractVariablesFromHtml(html);
|
|
1941
|
+
for (const variable of variables) {
|
|
1942
|
+
const keyStr = variable.variableKey;
|
|
1943
|
+
if (visited.has(keyStr)) continue;
|
|
1944
|
+
visited.add(keyStr);
|
|
1945
|
+
allKeys.push(variable.variableKey);
|
|
1946
|
+
const propertyId = (_a = core.entityOfKey(variable.variableKey)) == null ? void 0 : _a._id;
|
|
1947
|
+
const value = (instanceProps == null ? void 0 : instanceProps[propertyId]) ?? ((_b = fragmentManager == null ? void 0 : fragmentManager.resolve(variable.variableKey)) == null ? void 0 : _b.defaultValue) ?? null;
|
|
1948
|
+
if (typeof value === "string") {
|
|
1949
|
+
nextContents.push(value);
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
if (nextContents.length === 0) break;
|
|
1954
|
+
currentContents = nextContents;
|
|
1955
|
+
}
|
|
1956
|
+
return allKeys;
|
|
1957
|
+
}
|
|
1958
|
+
function resolveNestedContent(content, resolvedMap, maxDepth = MAX_NESTING_DEPTH) {
|
|
1959
|
+
let result = content;
|
|
1960
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1961
|
+
for (let depth = 0; depth < maxDepth; depth++) {
|
|
1962
|
+
const variables = extractVariablesFromHtml(result);
|
|
1963
|
+
if (variables.length === 0) break;
|
|
1964
|
+
let hasCycle = false;
|
|
1965
|
+
const depthKeys = /* @__PURE__ */ new Set();
|
|
1966
|
+
for (const variable of variables) {
|
|
1967
|
+
const key = variable.variableKey;
|
|
1968
|
+
if (visited.has(key)) {
|
|
1969
|
+
console.warn(`Circular variable reference detected: ${key}`);
|
|
1970
|
+
hasCycle = true;
|
|
1971
|
+
continue;
|
|
1972
|
+
}
|
|
1973
|
+
depthKeys.add(key);
|
|
1974
|
+
result = result.replace(
|
|
1975
|
+
variable.fullMatch,
|
|
1976
|
+
String(resolvedMap.get(key) ?? "")
|
|
1977
|
+
);
|
|
1978
|
+
}
|
|
1979
|
+
for (const key of depthKeys) {
|
|
1980
|
+
visited.add(key);
|
|
1981
|
+
}
|
|
1982
|
+
if (hasCycle) break;
|
|
1983
|
+
}
|
|
1984
|
+
return result;
|
|
1985
|
+
}
|
|
1927
1986
|
const useTextContent = (layerKey, manager) => {
|
|
1928
1987
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1929
|
-
const
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
fragmentManager
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
const
|
|
1936
|
-
const
|
|
1937
|
-
|
|
1938
|
-
variables.forEach((variable, index) => {
|
|
1988
|
+
const { props: instanceProps } = react.useContext(InstanceContext);
|
|
1989
|
+
const [content] = useLayerValue(layerKey, "content", fragmentManager);
|
|
1990
|
+
const allVariableKeys = react.useMemo(
|
|
1991
|
+
() => collectNestedVariableKeys(content, instanceProps, fragmentManager),
|
|
1992
|
+
[content, instanceProps, fragmentManager]
|
|
1993
|
+
);
|
|
1994
|
+
const allResolved = useReadVariables(allVariableKeys);
|
|
1995
|
+
const resolvedMap = /* @__PURE__ */ new Map();
|
|
1996
|
+
allVariableKeys.forEach((key, index) => {
|
|
1939
1997
|
var _a;
|
|
1940
|
-
|
|
1941
|
-
variable.fullMatch,
|
|
1942
|
-
((_a = resolvedVariables[index]) == null ? void 0 : _a.value) ?? ""
|
|
1943
|
-
);
|
|
1998
|
+
resolvedMap.set(key, ((_a = allResolved[index]) == null ? void 0 : _a.value) ?? "");
|
|
1944
1999
|
});
|
|
2000
|
+
let nextContent = resolveNestedContent(content, resolvedMap);
|
|
1945
2001
|
if (typeof nextContent === "string") {
|
|
1946
2002
|
nextContent = nextContent.replace(
|
|
1947
2003
|
/\{\{(.*?)}}/,
|
|
@@ -2050,14 +2106,21 @@ const useLayerInteractions = (layerKey, options) => {
|
|
|
2050
2106
|
});
|
|
2051
2107
|
const fireEvent = react.useCallback(
|
|
2052
2108
|
(eventLink) => {
|
|
2053
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
|
2054
|
-
const
|
|
2055
|
-
|
|
2056
|
-
|
|
2109
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
2110
|
+
const isVariableGoal = typeof eventLink === "number";
|
|
2111
|
+
if (isVariableGoal) {
|
|
2112
|
+
if (!areaScope) return null;
|
|
2113
|
+
(_b = (_a2 = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a2.reachGoal) == null ? void 0 : _b.call(_a2, {
|
|
2114
|
+
goalId: eventLink,
|
|
2115
|
+
...utils.pick(areaScope, "variantId", "campaignId", "areaId")
|
|
2116
|
+
});
|
|
2117
|
+
return;
|
|
2118
|
+
}
|
|
2119
|
+
const eventType = (_c = core.entityOfKey(eventLink)) == null ? void 0 : _c._type;
|
|
2120
|
+
const eventValue = (_d = getNormalizeLayer(eventLink, fragmentManager)) == null ? void 0 : _d.layer;
|
|
2057
2121
|
if (eventType === definition.definition.nodes.GoalEvent && (eventValue == null ? void 0 : eventValue.goalId)) {
|
|
2058
2122
|
if (!areaScope) return null;
|
|
2059
|
-
|
|
2060
|
-
(_e = (_d = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _d.reachGoal) == null ? void 0 : _e.call(_d, {
|
|
2123
|
+
(_f = (_e = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _e.reachGoal) == null ? void 0 : _f.call(_e, {
|
|
2061
2124
|
goalId: eventValue == null ? void 0 : eventValue.goalId,
|
|
2062
2125
|
...utils.pick(areaScope, "variantId", "campaignId", "areaId")
|
|
2063
2126
|
});
|
|
@@ -2065,9 +2128,9 @@ const useLayerInteractions = (layerKey, options) => {
|
|
|
2065
2128
|
if (eventType === definition.definition.nodes.MutateEvent) {
|
|
2066
2129
|
const target = eventValue == null ? void 0 : eventValue.target;
|
|
2067
2130
|
const targetLayer = getNormalizeLayer(target, fragmentManager);
|
|
2068
|
-
const value = (eventValue == null ? void 0 : eventValue.value) ?? ((
|
|
2131
|
+
const value = (eventValue == null ? void 0 : eventValue.value) ?? ((_g = targetLayer == null ? void 0 : targetLayer.layer) == null ? void 0 : _g.defaultValue);
|
|
2069
2132
|
if (definition.isVariableLink(target) && utils.isValue(value)) {
|
|
2070
|
-
const targetId = (
|
|
2133
|
+
const targetId = (_h = core.entityOfKey(target)) == null ? void 0 : _h._id;
|
|
2071
2134
|
onChangeProps == null ? void 0 : onChangeProps(targetId, value);
|
|
2072
2135
|
}
|
|
2073
2136
|
}
|
|
@@ -2264,7 +2327,12 @@ const useCollection = (layerKey, options) => {
|
|
|
2264
2327
|
});
|
|
2265
2328
|
const sourceValues = react$1.useGraphStack(fragmentManager, sourceValue ?? []);
|
|
2266
2329
|
const resultValues = (sourceValue ?? []).map(
|
|
2267
|
-
(initValue, index) => (
|
|
2330
|
+
(initValue, index) => (
|
|
2331
|
+
// Если initValue — объект (пришёл из пропсов через useReadVariables),
|
|
2332
|
+
// он уже содержит актуальные значения и имеет приоритет.
|
|
2333
|
+
// Если initValue — ссылка (строка), используем graph-версию для реактивности.
|
|
2334
|
+
utils.isObject(initValue) ? initValue : (sourceValues == null ? void 0 : sourceValues[index]) ?? initValue
|
|
2335
|
+
)
|
|
2268
2336
|
);
|
|
2269
2337
|
return {
|
|
2270
2338
|
source,
|
|
@@ -2383,6 +2451,25 @@ const remapArrayItems = (items, mapping) => {
|
|
|
2383
2451
|
return remapped;
|
|
2384
2452
|
});
|
|
2385
2453
|
};
|
|
2454
|
+
const fillArrayItemDefaults = (items, parentDef, manager) => {
|
|
2455
|
+
if (!(parentDef == null ? void 0 : parentDef.fields)) return items;
|
|
2456
|
+
const fields = utils.cleanGraph(parentDef.fields);
|
|
2457
|
+
return items.map((item) => {
|
|
2458
|
+
const filled = { ...item };
|
|
2459
|
+
let changed = false;
|
|
2460
|
+
for (const [fieldName, fieldRef] of Object.entries(fields)) {
|
|
2461
|
+
const fieldVar = resolveFieldRef(fieldRef, manager);
|
|
2462
|
+
if (!fieldVar) continue;
|
|
2463
|
+
if (filled[fieldName] !== void 0) continue;
|
|
2464
|
+
if (fieldVar._id && filled[fieldVar._id] !== void 0) continue;
|
|
2465
|
+
if (fieldVar.defaultValue !== void 0) {
|
|
2466
|
+
filled[fieldName] = fieldVar.defaultValue;
|
|
2467
|
+
changed = true;
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
return changed ? filled : item;
|
|
2471
|
+
});
|
|
2472
|
+
};
|
|
2386
2473
|
const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
2387
2474
|
const areaManager = react.useContext(AreaManagerContext);
|
|
2388
2475
|
const globalManager = react.useContext(GlobalManagerContext);
|
|
@@ -2506,13 +2593,18 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2506
2593
|
const childDef = resolveFieldRef(defVar.definition, manager);
|
|
2507
2594
|
const parentDef = parentVarManager ? resolveFieldRef(parentVar.definition, parentVarManager) : utils.isObject(parentVar.definition) && ((_a = parentVar.definition) == null ? void 0 : _a._id) ? parentVar.definition : null;
|
|
2508
2595
|
if ((childDef == null ? void 0 : childDef.type) === definition.definition.variableType.Object && (childDef == null ? void 0 : childDef.fields) && (parentDef == null ? void 0 : parentDef.type) === definition.definition.variableType.Object && (parentDef == null ? void 0 : parentDef.fields)) {
|
|
2596
|
+
const filledItems = fillArrayItemDefaults(
|
|
2597
|
+
concreteItems,
|
|
2598
|
+
parentDef,
|
|
2599
|
+
parentVarManager ?? resolveManager
|
|
2600
|
+
);
|
|
2509
2601
|
const mapping = buildFieldIdMapping(
|
|
2510
2602
|
childDef,
|
|
2511
2603
|
parentDef,
|
|
2512
2604
|
manager,
|
|
2513
2605
|
parentVarManager ?? resolveManager
|
|
2514
2606
|
);
|
|
2515
|
-
expanded[defVar._id] = remapArrayItems(
|
|
2607
|
+
expanded[defVar._id] = remapArrayItems(filledItems, mapping);
|
|
2516
2608
|
} else {
|
|
2517
2609
|
expanded[defVar._id] = concreteItems;
|
|
2518
2610
|
}
|
|
@@ -3387,6 +3479,24 @@ const useArea = (areaCode, options) => {
|
|
|
3387
3479
|
}
|
|
3388
3480
|
return asyncState;
|
|
3389
3481
|
};
|
|
3482
|
+
class AreaErrorBoundary extends react.Component {
|
|
3483
|
+
constructor() {
|
|
3484
|
+
super(...arguments);
|
|
3485
|
+
__publicField(this, "state", { hasError: false });
|
|
3486
|
+
}
|
|
3487
|
+
static getDerivedStateFromError() {
|
|
3488
|
+
return { hasError: true };
|
|
3489
|
+
}
|
|
3490
|
+
componentDidCatch(error, info) {
|
|
3491
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3492
|
+
console.error("[fragments] Area error:", error, info.componentStack);
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
render() {
|
|
3496
|
+
if (this.state.hasError) return null;
|
|
3497
|
+
return this.props.children;
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3390
3500
|
const AreaInitial = (areaProps) => {
|
|
3391
3501
|
var _a;
|
|
3392
3502
|
const { data: areaData } = useArea(areaProps.areaCode, {
|
|
@@ -3401,10 +3511,13 @@ const AreaInitial = (areaProps) => {
|
|
|
3401
3511
|
areaData == null ? void 0 : areaData.fragmentId,
|
|
3402
3512
|
globalManager
|
|
3403
3513
|
);
|
|
3404
|
-
const resultProps = react.useMemo(
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3514
|
+
const resultProps = react.useMemo(() => {
|
|
3515
|
+
const baseProps = (areaData == null ? void 0 : areaData.props) ?? {};
|
|
3516
|
+
if (typeof (areaProps == null ? void 0 : areaProps.props) === "function") {
|
|
3517
|
+
return { ...baseProps, ...areaProps.props(baseProps) };
|
|
3518
|
+
}
|
|
3519
|
+
return { ...baseProps, ...(areaProps == null ? void 0 : areaProps.props) ?? {} };
|
|
3520
|
+
}, [areaData, areaProps]);
|
|
3408
3521
|
const areaManager = react.useMemo(
|
|
3409
3522
|
() => clientCore.createAreaManager({
|
|
3410
3523
|
areaId: areaData == null ? void 0 : areaData.areaId,
|
|
@@ -3430,7 +3543,7 @@ const AreaInitial = (areaProps) => {
|
|
|
3430
3543
|
) });
|
|
3431
3544
|
};
|
|
3432
3545
|
const Area = (props) => {
|
|
3433
|
-
return "globalManager" in props ? /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(GlobalManagerProvider, { value: props.globalManager, children: /* @__PURE__ */ jsxRuntime.jsx(AreaInitial, { ...props }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(AreaInitial, { ...props }) });
|
|
3546
|
+
return "globalManager" in props ? /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(GlobalManagerProvider, { value: props.globalManager, children: /* @__PURE__ */ jsxRuntime.jsx(AreaErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsx(AreaInitial, { ...props }) }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(AreaErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsx(AreaInitial, { ...props }) }) });
|
|
3434
3547
|
};
|
|
3435
3548
|
function cssToJsStyle(cssKey) {
|
|
3436
3549
|
return cssKey.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { createContext, useContext, useMemo, useCallback, useEffect, useState, useRef, memo, Suspense, Component } from "react";
|
|
2
5
|
import { definition, getNormalizeLayer as getNormalizeLayer$1, isVariableLink as isVariableLink$1, parseLayerField, isLink as isLink$1 } from "@fragmentsx/definition";
|
|
3
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
7
|
import { useGraph, useGraphStack } from "@graph-state/react";
|
|
@@ -911,12 +914,13 @@ const useReadVariables = (variableKeys, customManager) => {
|
|
|
911
914
|
(scope) => (scope == null ? void 0 : scope.type) === definition.scopeTypes.CollectionItemScope
|
|
912
915
|
);
|
|
913
916
|
return filterKeys.map((variableKey, index) => {
|
|
914
|
-
var _a2;
|
|
915
|
-
|
|
917
|
+
var _a2, _b2;
|
|
918
|
+
variableLayers[index];
|
|
919
|
+
const layer = ((_a2 = getNormalizeLayer(variableKey, resultManager)) == null ? void 0 : _a2.layer) ?? null;
|
|
916
920
|
const { _id: propertyId } = layer ?? {};
|
|
917
921
|
let collectionItemProp = void 0;
|
|
918
922
|
if (lastCollectionItem && propertyId) {
|
|
919
|
-
collectionItemProp = isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((
|
|
923
|
+
collectionItemProp = isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_b2 = entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _b2._id) === propertyId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue(lastCollectionItem == null ? void 0 : lastCollectionItem.value, propertyId);
|
|
920
924
|
}
|
|
921
925
|
const instanceProp = (instanceProps == null ? void 0 : instanceProps[propertyId]) ?? null;
|
|
922
926
|
const areaLayer = areaManager == null ? void 0 : areaManager.resolve(variableKey);
|
|
@@ -1904,6 +1908,7 @@ const useLayerStyles = (layerKey) => {
|
|
|
1904
1908
|
return {};
|
|
1905
1909
|
}
|
|
1906
1910
|
};
|
|
1911
|
+
const MAX_NESTING_DEPTH = 5;
|
|
1907
1912
|
function extractVariablesFromHtml(html) {
|
|
1908
1913
|
if (!html) return [];
|
|
1909
1914
|
const regex = /<span(?=\s)(?=(?:[^>]*?\s)?class="[^"]*variable[^"]*")(?=(?:[^>]*?\s)?data-type="mention")(?=(?:[^>]*?\s)?data-id="([^"]+)")[^>]*>.*?<\/span>/gi;
|
|
@@ -1922,24 +1927,75 @@ function extractVariablesFromHtml(html) {
|
|
|
1922
1927
|
}
|
|
1923
1928
|
return mentions;
|
|
1924
1929
|
}
|
|
1930
|
+
function collectNestedVariableKeys(content, instanceProps, fragmentManager, maxDepth = MAX_NESTING_DEPTH) {
|
|
1931
|
+
var _a, _b;
|
|
1932
|
+
const allKeys = [];
|
|
1933
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1934
|
+
let currentContents = [content];
|
|
1935
|
+
for (let depth = 0; depth < maxDepth; depth++) {
|
|
1936
|
+
const nextContents = [];
|
|
1937
|
+
for (const html of currentContents) {
|
|
1938
|
+
const variables = extractVariablesFromHtml(html);
|
|
1939
|
+
for (const variable of variables) {
|
|
1940
|
+
const keyStr = variable.variableKey;
|
|
1941
|
+
if (visited.has(keyStr)) continue;
|
|
1942
|
+
visited.add(keyStr);
|
|
1943
|
+
allKeys.push(variable.variableKey);
|
|
1944
|
+
const propertyId = (_a = entityOfKey(variable.variableKey)) == null ? void 0 : _a._id;
|
|
1945
|
+
const value = (instanceProps == null ? void 0 : instanceProps[propertyId]) ?? ((_b = fragmentManager == null ? void 0 : fragmentManager.resolve(variable.variableKey)) == null ? void 0 : _b.defaultValue) ?? null;
|
|
1946
|
+
if (typeof value === "string") {
|
|
1947
|
+
nextContents.push(value);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
if (nextContents.length === 0) break;
|
|
1952
|
+
currentContents = nextContents;
|
|
1953
|
+
}
|
|
1954
|
+
return allKeys;
|
|
1955
|
+
}
|
|
1956
|
+
function resolveNestedContent(content, resolvedMap, maxDepth = MAX_NESTING_DEPTH) {
|
|
1957
|
+
let result = content;
|
|
1958
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1959
|
+
for (let depth = 0; depth < maxDepth; depth++) {
|
|
1960
|
+
const variables = extractVariablesFromHtml(result);
|
|
1961
|
+
if (variables.length === 0) break;
|
|
1962
|
+
let hasCycle = false;
|
|
1963
|
+
const depthKeys = /* @__PURE__ */ new Set();
|
|
1964
|
+
for (const variable of variables) {
|
|
1965
|
+
const key = variable.variableKey;
|
|
1966
|
+
if (visited.has(key)) {
|
|
1967
|
+
console.warn(`Circular variable reference detected: ${key}`);
|
|
1968
|
+
hasCycle = true;
|
|
1969
|
+
continue;
|
|
1970
|
+
}
|
|
1971
|
+
depthKeys.add(key);
|
|
1972
|
+
result = result.replace(
|
|
1973
|
+
variable.fullMatch,
|
|
1974
|
+
String(resolvedMap.get(key) ?? "")
|
|
1975
|
+
);
|
|
1976
|
+
}
|
|
1977
|
+
for (const key of depthKeys) {
|
|
1978
|
+
visited.add(key);
|
|
1979
|
+
}
|
|
1980
|
+
if (hasCycle) break;
|
|
1981
|
+
}
|
|
1982
|
+
return result;
|
|
1983
|
+
}
|
|
1925
1984
|
const useTextContent = (layerKey, manager) => {
|
|
1926
1985
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
1927
|
-
const
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
fragmentManager
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
const
|
|
1934
|
-
const
|
|
1935
|
-
|
|
1936
|
-
variables.forEach((variable, index) => {
|
|
1986
|
+
const { props: instanceProps } = useContext(InstanceContext);
|
|
1987
|
+
const [content] = useLayerValue(layerKey, "content", fragmentManager);
|
|
1988
|
+
const allVariableKeys = useMemo(
|
|
1989
|
+
() => collectNestedVariableKeys(content, instanceProps, fragmentManager),
|
|
1990
|
+
[content, instanceProps, fragmentManager]
|
|
1991
|
+
);
|
|
1992
|
+
const allResolved = useReadVariables(allVariableKeys);
|
|
1993
|
+
const resolvedMap = /* @__PURE__ */ new Map();
|
|
1994
|
+
allVariableKeys.forEach((key, index) => {
|
|
1937
1995
|
var _a;
|
|
1938
|
-
|
|
1939
|
-
variable.fullMatch,
|
|
1940
|
-
((_a = resolvedVariables[index]) == null ? void 0 : _a.value) ?? ""
|
|
1941
|
-
);
|
|
1996
|
+
resolvedMap.set(key, ((_a = allResolved[index]) == null ? void 0 : _a.value) ?? "");
|
|
1942
1997
|
});
|
|
1998
|
+
let nextContent = resolveNestedContent(content, resolvedMap);
|
|
1943
1999
|
if (typeof nextContent === "string") {
|
|
1944
2000
|
nextContent = nextContent.replace(
|
|
1945
2001
|
/\{\{(.*?)}}/,
|
|
@@ -2048,14 +2104,21 @@ const useLayerInteractions = (layerKey, options) => {
|
|
|
2048
2104
|
});
|
|
2049
2105
|
const fireEvent = useCallback(
|
|
2050
2106
|
(eventLink) => {
|
|
2051
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
|
2052
|
-
const
|
|
2053
|
-
|
|
2054
|
-
|
|
2107
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
2108
|
+
const isVariableGoal = typeof eventLink === "number";
|
|
2109
|
+
if (isVariableGoal) {
|
|
2110
|
+
if (!areaScope) return null;
|
|
2111
|
+
(_b = (_a2 = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a2.reachGoal) == null ? void 0 : _b.call(_a2, {
|
|
2112
|
+
goalId: eventLink,
|
|
2113
|
+
...pick(areaScope, "variantId", "campaignId", "areaId")
|
|
2114
|
+
});
|
|
2115
|
+
return;
|
|
2116
|
+
}
|
|
2117
|
+
const eventType = (_c = entityOfKey(eventLink)) == null ? void 0 : _c._type;
|
|
2118
|
+
const eventValue = (_d = getNormalizeLayer(eventLink, fragmentManager)) == null ? void 0 : _d.layer;
|
|
2055
2119
|
if (eventType === definition.nodes.GoalEvent && (eventValue == null ? void 0 : eventValue.goalId)) {
|
|
2056
2120
|
if (!areaScope) return null;
|
|
2057
|
-
|
|
2058
|
-
(_e = (_d = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _d.reachGoal) == null ? void 0 : _e.call(_d, {
|
|
2121
|
+
(_f = (_e = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _e.reachGoal) == null ? void 0 : _f.call(_e, {
|
|
2059
2122
|
goalId: eventValue == null ? void 0 : eventValue.goalId,
|
|
2060
2123
|
...pick(areaScope, "variantId", "campaignId", "areaId")
|
|
2061
2124
|
});
|
|
@@ -2063,9 +2126,9 @@ const useLayerInteractions = (layerKey, options) => {
|
|
|
2063
2126
|
if (eventType === definition.nodes.MutateEvent) {
|
|
2064
2127
|
const target = eventValue == null ? void 0 : eventValue.target;
|
|
2065
2128
|
const targetLayer = getNormalizeLayer(target, fragmentManager);
|
|
2066
|
-
const value = (eventValue == null ? void 0 : eventValue.value) ?? ((
|
|
2129
|
+
const value = (eventValue == null ? void 0 : eventValue.value) ?? ((_g = targetLayer == null ? void 0 : targetLayer.layer) == null ? void 0 : _g.defaultValue);
|
|
2067
2130
|
if (isVariableLink$1(target) && isValue(value)) {
|
|
2068
|
-
const targetId = (
|
|
2131
|
+
const targetId = (_h = entityOfKey(target)) == null ? void 0 : _h._id;
|
|
2069
2132
|
onChangeProps == null ? void 0 : onChangeProps(targetId, value);
|
|
2070
2133
|
}
|
|
2071
2134
|
}
|
|
@@ -2262,7 +2325,12 @@ const useCollection = (layerKey, options) => {
|
|
|
2262
2325
|
});
|
|
2263
2326
|
const sourceValues = useGraphStack(fragmentManager, sourceValue ?? []);
|
|
2264
2327
|
const resultValues = (sourceValue ?? []).map(
|
|
2265
|
-
(initValue, index) => (
|
|
2328
|
+
(initValue, index) => (
|
|
2329
|
+
// Если initValue — объект (пришёл из пропсов через useReadVariables),
|
|
2330
|
+
// он уже содержит актуальные значения и имеет приоритет.
|
|
2331
|
+
// Если initValue — ссылка (строка), используем graph-версию для реактивности.
|
|
2332
|
+
isObject(initValue) ? initValue : (sourceValues == null ? void 0 : sourceValues[index]) ?? initValue
|
|
2333
|
+
)
|
|
2266
2334
|
);
|
|
2267
2335
|
return {
|
|
2268
2336
|
source,
|
|
@@ -2381,6 +2449,25 @@ const remapArrayItems = (items, mapping) => {
|
|
|
2381
2449
|
return remapped;
|
|
2382
2450
|
});
|
|
2383
2451
|
};
|
|
2452
|
+
const fillArrayItemDefaults = (items, parentDef, manager) => {
|
|
2453
|
+
if (!(parentDef == null ? void 0 : parentDef.fields)) return items;
|
|
2454
|
+
const fields = cleanGraph(parentDef.fields);
|
|
2455
|
+
return items.map((item) => {
|
|
2456
|
+
const filled = { ...item };
|
|
2457
|
+
let changed = false;
|
|
2458
|
+
for (const [fieldName, fieldRef] of Object.entries(fields)) {
|
|
2459
|
+
const fieldVar = resolveFieldRef(fieldRef, manager);
|
|
2460
|
+
if (!fieldVar) continue;
|
|
2461
|
+
if (filled[fieldName] !== void 0) continue;
|
|
2462
|
+
if (fieldVar._id && filled[fieldVar._id] !== void 0) continue;
|
|
2463
|
+
if (fieldVar.defaultValue !== void 0) {
|
|
2464
|
+
filled[fieldName] = fieldVar.defaultValue;
|
|
2465
|
+
changed = true;
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
return changed ? filled : item;
|
|
2469
|
+
});
|
|
2470
|
+
};
|
|
2384
2471
|
const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
2385
2472
|
const areaManager = useContext(AreaManagerContext);
|
|
2386
2473
|
const globalManager = useContext(GlobalManagerContext);
|
|
@@ -2504,13 +2591,18 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2504
2591
|
const childDef = resolveFieldRef(defVar.definition, manager);
|
|
2505
2592
|
const parentDef = parentVarManager ? resolveFieldRef(parentVar.definition, parentVarManager) : isObject(parentVar.definition) && ((_a = parentVar.definition) == null ? void 0 : _a._id) ? parentVar.definition : null;
|
|
2506
2593
|
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)) {
|
|
2594
|
+
const filledItems = fillArrayItemDefaults(
|
|
2595
|
+
concreteItems,
|
|
2596
|
+
parentDef,
|
|
2597
|
+
parentVarManager ?? resolveManager
|
|
2598
|
+
);
|
|
2507
2599
|
const mapping = buildFieldIdMapping(
|
|
2508
2600
|
childDef,
|
|
2509
2601
|
parentDef,
|
|
2510
2602
|
manager,
|
|
2511
2603
|
parentVarManager ?? resolveManager
|
|
2512
2604
|
);
|
|
2513
|
-
expanded[defVar._id] = remapArrayItems(
|
|
2605
|
+
expanded[defVar._id] = remapArrayItems(filledItems, mapping);
|
|
2514
2606
|
} else {
|
|
2515
2607
|
expanded[defVar._id] = concreteItems;
|
|
2516
2608
|
}
|
|
@@ -3385,6 +3477,24 @@ const useArea = (areaCode, options) => {
|
|
|
3385
3477
|
}
|
|
3386
3478
|
return asyncState;
|
|
3387
3479
|
};
|
|
3480
|
+
class AreaErrorBoundary extends Component {
|
|
3481
|
+
constructor() {
|
|
3482
|
+
super(...arguments);
|
|
3483
|
+
__publicField(this, "state", { hasError: false });
|
|
3484
|
+
}
|
|
3485
|
+
static getDerivedStateFromError() {
|
|
3486
|
+
return { hasError: true };
|
|
3487
|
+
}
|
|
3488
|
+
componentDidCatch(error, info) {
|
|
3489
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3490
|
+
console.error("[fragments] Area error:", error, info.componentStack);
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
render() {
|
|
3494
|
+
if (this.state.hasError) return null;
|
|
3495
|
+
return this.props.children;
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3388
3498
|
const AreaInitial = (areaProps) => {
|
|
3389
3499
|
var _a;
|
|
3390
3500
|
const { data: areaData } = useArea(areaProps.areaCode, {
|
|
@@ -3399,10 +3509,13 @@ const AreaInitial = (areaProps) => {
|
|
|
3399
3509
|
areaData == null ? void 0 : areaData.fragmentId,
|
|
3400
3510
|
globalManager
|
|
3401
3511
|
);
|
|
3402
|
-
const resultProps = useMemo(
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3512
|
+
const resultProps = useMemo(() => {
|
|
3513
|
+
const baseProps = (areaData == null ? void 0 : areaData.props) ?? {};
|
|
3514
|
+
if (typeof (areaProps == null ? void 0 : areaProps.props) === "function") {
|
|
3515
|
+
return { ...baseProps, ...areaProps.props(baseProps) };
|
|
3516
|
+
}
|
|
3517
|
+
return { ...baseProps, ...(areaProps == null ? void 0 : areaProps.props) ?? {} };
|
|
3518
|
+
}, [areaData, areaProps]);
|
|
3406
3519
|
const areaManager = useMemo(
|
|
3407
3520
|
() => createAreaManager({
|
|
3408
3521
|
areaId: areaData == null ? void 0 : areaData.areaId,
|
|
@@ -3428,7 +3541,7 @@ const AreaInitial = (areaProps) => {
|
|
|
3428
3541
|
) });
|
|
3429
3542
|
};
|
|
3430
3543
|
const Area = (props) => {
|
|
3431
|
-
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 }) });
|
|
3544
|
+
return "globalManager" in props ? /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(GlobalManagerProvider, { value: props.globalManager, children: /* @__PURE__ */ jsx(AreaErrorBoundary, { children: /* @__PURE__ */ jsx(AreaInitial, { ...props }) }) }) }) : /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(AreaErrorBoundary, { children: /* @__PURE__ */ jsx(AreaInitial, { ...props }) }) });
|
|
3432
3545
|
};
|
|
3433
3546
|
function cssToJsStyle(cssKey) {
|
|
3434
3547
|
return cssKey.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export type AreaPropsFn = (variantProps: Record<string, unknown>) => Record<string, unknown>;
|
|
1
2
|
export interface AreaProps {
|
|
2
3
|
areaCode: string;
|
|
3
4
|
globalManager?: unknown;
|
|
4
|
-
props?: Record<string, unknown
|
|
5
|
+
props?: Record<string, unknown> | AreaPropsFn;
|
|
5
6
|
options?: {
|
|
6
7
|
ssr?: boolean;
|
|
7
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Area.d.ts","sourceRoot":"","sources":["../../../src/nodes/Area/Area.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Area.d.ts","sourceRoot":"","sources":["../../../src/nodes/Area/Area.tsx"],"names":[],"mappings":"AAuCA,MAAM,MAAM,WAAW,GAAG,CACxB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE7B,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC;IAC9C,OAAO,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,CAAC;CACH;AAwDD,eAAO,MAAM,IAAI,UAAW,SAAS,4CAgBpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Area.test.d.ts","sourceRoot":"","sources":["../../../src/nodes/Area/Area.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Area } from './Area';
|
|
2
|
-
export type { AreaProps } from './Area';
|
|
2
|
+
export type { AreaProps, AreaPropsFn } from './Area';
|
|
3
3
|
export { useArea } from './hooks/useArea';
|
|
4
4
|
export type { UseAreaOptions, UseAreaResult, AreaData, } from './hooks/useArea.types';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/nodes/Area/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/nodes/Area/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,YAAY,EACV,cAAc,EACd,aAAa,EACb,QAAQ,GACT,MAAM,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCollection.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Collection/hooks/useCollection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAY,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKzE,eAAO,MAAM,aAAa,aAAc,OAAO,YAAY,eAAe;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useCollection.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Collection/hooks/useCollection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAY,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKzE,eAAO,MAAM,aAAa,aAAc,OAAO,YAAY,eAAe;;;;;;;;;;;;;;;;;;;;;;CA8BzE,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { GraphState, LinkKey } from '@graph-state/core';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function collectNestedVariableKeys(content: string, instanceProps: Record<string, any>, fragmentManager: GraphState | null, maxDepth?: number): LinkKey[];
|
|
3
|
+
export declare function resolveNestedContent(content: string, resolvedMap: Map<string, any>, maxDepth?: number): string;
|
|
4
|
+
export declare const useTextContent: (layerKey: LinkKey, manager: GraphState) => string;
|
|
3
5
|
//# sourceMappingURL=useTextContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextContent.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Text/hooks/useTextContent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"useTextContent.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Text/hooks/useTextContent.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,UAAU,EAEV,OAAO,EACR,MAAM,mBAAmB,CAAC;AAgC3B,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAClC,eAAe,EAAE,UAAU,GAAG,IAAI,EAClC,QAAQ,GAAE,MAA0B,GACnC,OAAO,EAAE,CAkCX;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,QAAQ,GAAE,MAA0B,GACnC,MAAM,CAmCR;AAED,eAAO,MAAM,cAAc,aAAc,OAAO,WAAW,UAAU,WA0BpE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTextContent.test.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Text/hooks/useTextContent.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fragmentsx/render-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"@graph-state/core": "^0.13.2",
|
|
28
28
|
"@graph-state/react": "^0.8.3",
|
|
29
29
|
"react-use-measure": "^2.1.7",
|
|
30
|
-
"@fragmentsx/
|
|
30
|
+
"@fragmentsx/client-core": "0.4.2",
|
|
31
31
|
"@fragmentsx/utils": "0.2.0",
|
|
32
|
-
"@fragmentsx/
|
|
32
|
+
"@fragmentsx/definition": "0.2.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@testing-library/jest-dom": "^6.6.3",
|