@uniformdev/canvas 19.173.1-alpha.17 → 19.173.2-alpha.210
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3031 -2823
- package/dist/index.d.ts +3031 -2823
- package/dist/index.esm.js +242 -121
- package/dist/index.js +247 -120
- package/dist/index.mjs +242 -121
- package/package.json +6 -5
package/dist/index.mjs
CHANGED
@@ -462,14 +462,17 @@ var nullLimitPolicy = async (func) => await func();
|
|
462
462
|
// src/utils/rewriteFilters.ts
|
463
463
|
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
464
464
|
function rewriteFilters(filters) {
|
465
|
-
return Object.entries(filters != null ? filters : {}).reduce(
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
465
|
+
return Object.entries(filters != null ? filters : {}).reduce(
|
466
|
+
(acc, [key, value]) => {
|
467
|
+
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
468
|
+
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
469
|
+
return {
|
470
|
+
...acc,
|
471
|
+
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
472
|
+
};
|
473
|
+
},
|
474
|
+
{}
|
475
|
+
);
|
473
476
|
}
|
474
477
|
|
475
478
|
// src/CanvasClient.ts
|
@@ -980,6 +983,9 @@ function isAssetParamValueItem(item) {
|
|
980
983
|
item instanceof Object && "_source" in item && "fields" in item && item.fields instanceof Object && "url" in item.fields && item.fields.url instanceof Object
|
981
984
|
);
|
982
985
|
}
|
986
|
+
function isLinkParamValue(value) {
|
987
|
+
return typeof value === "object" && value !== null && "type" in value && "path" in value;
|
988
|
+
}
|
983
989
|
|
984
990
|
// src/utils/properties.ts
|
985
991
|
function getPropertiesValue(entity) {
|
@@ -1031,6 +1037,86 @@ function flattenSingleNodeValues(data, options = {}) {
|
|
1031
1037
|
) : properties;
|
1032
1038
|
}
|
1033
1039
|
|
1040
|
+
// src/utils/variables/parseVariableExpression.ts
|
1041
|
+
var escapeCharacter = "\\";
|
1042
|
+
var variablePrefix = "${";
|
1043
|
+
var variableSuffix = "}";
|
1044
|
+
function parseVariableExpression(serialized, onToken) {
|
1045
|
+
let bufferStartIndex = 0;
|
1046
|
+
let bufferEndIndex = 0;
|
1047
|
+
let tokenCount = 0;
|
1048
|
+
const handleToken = (token, type) => {
|
1049
|
+
tokenCount++;
|
1050
|
+
return onToken == null ? void 0 : onToken(token, type);
|
1051
|
+
};
|
1052
|
+
let state = "text";
|
1053
|
+
for (let index = 0; index < serialized.length; index++) {
|
1054
|
+
const char = serialized[index];
|
1055
|
+
if (bufferStartIndex > bufferEndIndex) {
|
1056
|
+
bufferEndIndex = bufferStartIndex;
|
1057
|
+
}
|
1058
|
+
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
1059
|
+
if (serialized[index - 1] === escapeCharacter) {
|
1060
|
+
bufferEndIndex -= escapeCharacter.length;
|
1061
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
1062
|
+
return tokenCount;
|
1063
|
+
}
|
1064
|
+
bufferStartIndex = index;
|
1065
|
+
bufferEndIndex = index + 1;
|
1066
|
+
continue;
|
1067
|
+
}
|
1068
|
+
state = "variable";
|
1069
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1070
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
1071
|
+
return tokenCount;
|
1072
|
+
}
|
1073
|
+
bufferStartIndex = bufferEndIndex;
|
1074
|
+
}
|
1075
|
+
index += variablePrefix.length - 1;
|
1076
|
+
bufferStartIndex += variablePrefix.length;
|
1077
|
+
continue;
|
1078
|
+
}
|
1079
|
+
if (char === variableSuffix && state === "variable") {
|
1080
|
+
if (serialized[index - 1] === escapeCharacter) {
|
1081
|
+
bufferEndIndex++;
|
1082
|
+
continue;
|
1083
|
+
}
|
1084
|
+
state = "text";
|
1085
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1086
|
+
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
1087
|
+
if (handleToken(unescapedVariableName, "variable") === false) {
|
1088
|
+
return tokenCount;
|
1089
|
+
}
|
1090
|
+
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
1091
|
+
}
|
1092
|
+
continue;
|
1093
|
+
}
|
1094
|
+
bufferEndIndex++;
|
1095
|
+
}
|
1096
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1097
|
+
if (state === "variable") {
|
1098
|
+
state = "text";
|
1099
|
+
bufferStartIndex -= variablePrefix.length;
|
1100
|
+
}
|
1101
|
+
handleToken(serialized.substring(bufferStartIndex), state);
|
1102
|
+
}
|
1103
|
+
return tokenCount;
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
// src/utils/variables/hasReferencedVariables.ts
|
1107
|
+
function hasReferencedVariables(value) {
|
1108
|
+
if (value === void 0) {
|
1109
|
+
return 0;
|
1110
|
+
}
|
1111
|
+
let variableTokenCount = 0;
|
1112
|
+
parseVariableExpression(value, (_, tokenType) => {
|
1113
|
+
if (tokenType === "variable") {
|
1114
|
+
variableTokenCount++;
|
1115
|
+
}
|
1116
|
+
});
|
1117
|
+
return variableTokenCount;
|
1118
|
+
}
|
1119
|
+
|
1034
1120
|
// src/enhancement/walkNodeTree.ts
|
1035
1121
|
function walkNodeTree(node, visitor, options) {
|
1036
1122
|
var _a, _b;
|
@@ -1254,7 +1340,25 @@ function walkNodeTree(node, visitor, options) {
|
|
1254
1340
|
const propertyEntries = Object.entries(properties);
|
1255
1341
|
for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
|
1256
1342
|
const [propKey, propObject] = propertyEntries[propIndex];
|
1257
|
-
if (!isNestedNodeType(propObject.type))
|
1343
|
+
if (!isNestedNodeType(propObject.type)) {
|
1344
|
+
continue;
|
1345
|
+
}
|
1346
|
+
if (typeof propObject.value === "string" && hasReferencedVariables(propObject.value) > 0) {
|
1347
|
+
continue;
|
1348
|
+
}
|
1349
|
+
if (!Array.isArray(propObject.value)) {
|
1350
|
+
const error = new BlockFormatError(
|
1351
|
+
`${getComponentPath(currentQueueEntry.ancestorsAndSelf)}`,
|
1352
|
+
propKey,
|
1353
|
+
propObject.value
|
1354
|
+
);
|
1355
|
+
if (options == null ? void 0 : options.throwForInvalidBlockValues) {
|
1356
|
+
throw error;
|
1357
|
+
} else {
|
1358
|
+
console.warn(`Skipped invalid block value: ${error.message}}`);
|
1359
|
+
continue;
|
1360
|
+
}
|
1361
|
+
}
|
1258
1362
|
const blocks = (_b = propObject.value) != null ? _b : [];
|
1259
1363
|
for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
|
1260
1364
|
const enqueueingBlock = blocks[blockIndex];
|
@@ -1290,6 +1394,17 @@ function getBlockValue(component, parameterName) {
|
|
1290
1394
|
}
|
1291
1395
|
return [];
|
1292
1396
|
}
|
1397
|
+
var BlockFormatError = class _BlockFormatError extends Error {
|
1398
|
+
constructor(componentPath, propertyId, blockValue) {
|
1399
|
+
super(
|
1400
|
+
`${componentPath} has an invalid block property value on ${propertyId}. Block values must be arrays of blocks (BlockValue type), but received ${blockValue === null ? "null" : typeof blockValue}`
|
1401
|
+
);
|
1402
|
+
this.componentPath = componentPath;
|
1403
|
+
this.propertyId = propertyId;
|
1404
|
+
this.blockValue = blockValue;
|
1405
|
+
Object.setPrototypeOf(this, _BlockFormatError.prototype);
|
1406
|
+
}
|
1407
|
+
};
|
1293
1408
|
|
1294
1409
|
// src/enhancement/enhance.ts
|
1295
1410
|
async function enhance({
|
@@ -1618,12 +1733,18 @@ function evaluateVisibilityCriteriaGroup(options) {
|
|
1618
1733
|
return hasIndeterminateClauses ? null : !earlyExitResult;
|
1619
1734
|
}
|
1620
1735
|
function evaluateCriterion(clause, rootOptions) {
|
1736
|
+
var _a;
|
1621
1737
|
if ("clauses" in clause) {
|
1622
1738
|
return evaluateVisibilityCriteriaGroup({
|
1623
1739
|
...rootOptions,
|
1624
1740
|
criteriaGroup: clause
|
1625
1741
|
});
|
1626
1742
|
}
|
1743
|
+
const lhs = (_a = clause.source) != null ? _a : clause.rule;
|
1744
|
+
const rhs = Array.isArray(clause.value) ? clause.value : clause.value !== void 0 ? [clause.value] : void 0;
|
1745
|
+
if (hasReferencedVariables(lhs) > 0 || (rhs == null ? void 0 : rhs.some((rhv) => hasReferencedVariables(rhv) > 0))) {
|
1746
|
+
return null;
|
1747
|
+
}
|
1627
1748
|
const rule = rootOptions.rules[clause.rule];
|
1628
1749
|
if (rule) {
|
1629
1750
|
return rule(clause);
|
@@ -1631,6 +1752,24 @@ function evaluateCriterion(clause, rootOptions) {
|
|
1631
1752
|
return null;
|
1632
1753
|
}
|
1633
1754
|
|
1755
|
+
// src/enhancement/visibility/evaluateNodeVisibilityParameter.ts
|
1756
|
+
function evaluateNodeVisibilityParameter({
|
1757
|
+
parameter,
|
1758
|
+
...evaluateGroupOptions
|
1759
|
+
}) {
|
1760
|
+
if (parameter == null ? void 0 : parameter.explicitlyHidden) {
|
1761
|
+
return false;
|
1762
|
+
}
|
1763
|
+
if (!(parameter == null ? void 0 : parameter.criteria)) {
|
1764
|
+
return true;
|
1765
|
+
}
|
1766
|
+
const result = evaluateVisibilityCriteriaGroup({
|
1767
|
+
...evaluateGroupOptions,
|
1768
|
+
criteriaGroup: parameter.criteria
|
1769
|
+
});
|
1770
|
+
return result;
|
1771
|
+
}
|
1772
|
+
|
1634
1773
|
// src/enhancement/visibility/evaluatePropertyCriteria.ts
|
1635
1774
|
function evaluatePropertyCriteria({
|
1636
1775
|
baseValue,
|
@@ -1695,17 +1834,11 @@ function evaluateNodeVisibility({
|
|
1695
1834
|
var _a;
|
1696
1835
|
const properties = getPropertiesValue(node);
|
1697
1836
|
const vizCriteria = (_a = properties == null ? void 0 : properties[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _a.value;
|
1698
|
-
|
1699
|
-
return false;
|
1700
|
-
}
|
1701
|
-
if (!(vizCriteria == null ? void 0 : vizCriteria.criteria)) {
|
1702
|
-
return true;
|
1703
|
-
}
|
1704
|
-
const result = evaluateVisibilityCriteriaGroup({
|
1837
|
+
const result = evaluateNodeVisibilityParameter({
|
1705
1838
|
...evaluateGroupOptions,
|
1706
|
-
|
1839
|
+
parameter: vizCriteria
|
1707
1840
|
});
|
1708
|
-
if (vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
|
1841
|
+
if ((vizCriteria == null ? void 0 : vizCriteria.criteria) && vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
|
1709
1842
|
properties == null ? true : delete properties[CANVAS_VIZ_CONTROL_PARAM];
|
1710
1843
|
}
|
1711
1844
|
return result;
|
@@ -1747,7 +1880,7 @@ function evaluateWalkTreePropertyCriteria({
|
|
1747
1880
|
...Object.keys((_b = property.localesConditions) != null ? _b : {})
|
1748
1881
|
];
|
1749
1882
|
localesDefined.forEach((locale) => {
|
1750
|
-
var _a2, _b2, _c2, _d, _e, _f
|
1883
|
+
var _a2, _b2, _c2, _d, _e, _f;
|
1751
1884
|
const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
|
1752
1885
|
baseValue: (_a2 = property.locales) == null ? void 0 : _a2[locale],
|
1753
1886
|
conditionalValues: (_b2 = property.localesConditions) == null ? void 0 : _b2[locale],
|
@@ -1755,25 +1888,25 @@ function evaluateWalkTreePropertyCriteria({
|
|
1755
1888
|
simplifyCriteria: true,
|
1756
1889
|
keepIndeterminate
|
1757
1890
|
});
|
1758
|
-
if (currentValue === null) {
|
1891
|
+
if (currentValue === null || currentValue === void 0) {
|
1759
1892
|
(_c2 = property.locales) == null ? true : delete _c2[locale];
|
1760
|
-
if (!Object.keys((_d = property.locales) != null ? _d : {}).length) {
|
1761
|
-
delete properties[propertyName];
|
1762
|
-
}
|
1763
1893
|
} else {
|
1764
|
-
(
|
1894
|
+
(_d = property.locales) != null ? _d : property.locales = {};
|
1765
1895
|
property.locales[locale] = currentValue;
|
1766
1896
|
}
|
1767
1897
|
if (!(remainingConditionalValues == null ? void 0 : remainingConditionalValues.length)) {
|
1768
|
-
(
|
1898
|
+
(_e = property.localesConditions) == null ? true : delete _e[locale];
|
1769
1899
|
} else {
|
1770
|
-
(
|
1900
|
+
(_f = property.localesConditions) != null ? _f : property.localesConditions = {};
|
1771
1901
|
property.localesConditions[locale] = remainingConditionalValues;
|
1772
1902
|
}
|
1773
1903
|
});
|
1774
1904
|
if (!Object.keys((_c = property.localesConditions) != null ? _c : {}).length) {
|
1775
1905
|
delete property.localesConditions;
|
1776
1906
|
}
|
1907
|
+
if (!property.locales && !property.localesConditions) {
|
1908
|
+
delete properties[propertyName];
|
1909
|
+
}
|
1777
1910
|
} else {
|
1778
1911
|
const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
|
1779
1912
|
baseValue: property.value,
|
@@ -1785,9 +1918,17 @@ function evaluateWalkTreePropertyCriteria({
|
|
1785
1918
|
if (currentValue === null) {
|
1786
1919
|
delete properties[propertyName];
|
1787
1920
|
} else {
|
1788
|
-
|
1921
|
+
if (currentValue !== void 0) {
|
1922
|
+
property.value = currentValue;
|
1923
|
+
} else {
|
1924
|
+
delete property.value;
|
1925
|
+
}
|
1926
|
+
}
|
1927
|
+
if (remainingConditionalValues === void 0) {
|
1928
|
+
delete property.conditions;
|
1929
|
+
} else {
|
1930
|
+
property.conditions = remainingConditionalValues;
|
1789
1931
|
}
|
1790
|
-
property.conditions = remainingConditionalValues;
|
1791
1932
|
}
|
1792
1933
|
});
|
1793
1934
|
}
|
@@ -1869,6 +2010,32 @@ function createDynamicInputVisibilityRule(dynamicInputs) {
|
|
1869
2010
|
};
|
1870
2011
|
}
|
1871
2012
|
|
2013
|
+
// src/enhancement/visibility/rules/createDynamicTokenVisibilityRule.ts
|
2014
|
+
var dynamicTokenVisibilityOperators = /* @__PURE__ */ new Set([
|
2015
|
+
"is",
|
2016
|
+
"!is",
|
2017
|
+
"has",
|
2018
|
+
"!has",
|
2019
|
+
"startswith",
|
2020
|
+
"!startswith",
|
2021
|
+
"endswith",
|
2022
|
+
"!endswith",
|
2023
|
+
"empty",
|
2024
|
+
"!empty"
|
2025
|
+
]);
|
2026
|
+
var CANVAS_VIZ_DYNAMIC_TOKEN_RULE = "$dt";
|
2027
|
+
function createDynamicTokenVisibilityRule() {
|
2028
|
+
return {
|
2029
|
+
[CANVAS_VIZ_DYNAMIC_TOKEN_RULE]: (criterion) => {
|
2030
|
+
var _a;
|
2031
|
+
if (hasReferencedVariables(criterion.source)) {
|
2032
|
+
return null;
|
2033
|
+
}
|
2034
|
+
return evaluateStringMatch(criterion, (_a = criterion.source) != null ? _a : "", dynamicTokenVisibilityOperators);
|
2035
|
+
}
|
2036
|
+
};
|
2037
|
+
}
|
2038
|
+
|
1872
2039
|
// src/enhancement/visibility/rules/createLocaleVisibilityRule.ts
|
1873
2040
|
var localeVisibilityOperators = /* @__PURE__ */ new Set(["is", "!is"]);
|
1874
2041
|
var CANVAS_VIZ_LOCALE_RULE = "$locale";
|
@@ -1931,7 +2098,7 @@ function localize(options) {
|
|
1931
2098
|
const { type, node, actions } = context;
|
1932
2099
|
if (type !== "component") {
|
1933
2100
|
if (isUsingModernOptions) {
|
1934
|
-
localizeProperties(node
|
2101
|
+
localizeProperties(node, locale, vizControlLocaleRule);
|
1935
2102
|
}
|
1936
2103
|
return;
|
1937
2104
|
}
|
@@ -1944,11 +2111,6 @@ function localize(options) {
|
|
1944
2111
|
if (!result) {
|
1945
2112
|
return;
|
1946
2113
|
}
|
1947
|
-
evaluateWalkTreePropertyCriteria({
|
1948
|
-
node: context.node,
|
1949
|
-
rules: vizControlLocaleRule,
|
1950
|
-
keepIndeterminate: true
|
1951
|
-
});
|
1952
2114
|
}
|
1953
2115
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
1954
2116
|
const locales = extractLocales({ component: node });
|
@@ -1961,7 +2123,7 @@ function localize(options) {
|
|
1961
2123
|
replaceComponent.forEach((component) => {
|
1962
2124
|
removeLocaleProperty(component);
|
1963
2125
|
if (isUsingModernOptions) {
|
1964
|
-
localizeProperties(
|
2126
|
+
localizeProperties(component, locale, vizControlLocaleRule);
|
1965
2127
|
}
|
1966
2128
|
});
|
1967
2129
|
const [first, ...rest] = replaceComponent;
|
@@ -1973,7 +2135,7 @@ function localize(options) {
|
|
1973
2135
|
actions.remove();
|
1974
2136
|
}
|
1975
2137
|
} else if (isUsingModernOptions) {
|
1976
|
-
localizeProperties(
|
2138
|
+
localizeProperties(node, locale, vizControlLocaleRule);
|
1977
2139
|
}
|
1978
2140
|
});
|
1979
2141
|
}
|
@@ -1992,36 +2154,51 @@ function removeLocaleProperty(component) {
|
|
1992
2154
|
}
|
1993
2155
|
}
|
1994
2156
|
}
|
1995
|
-
function localizeProperties(
|
2157
|
+
function localizeProperties(node, locale, rules) {
|
2158
|
+
const properties = getPropertiesValue(node);
|
1996
2159
|
if (!properties) {
|
1997
2160
|
return void 0;
|
1998
2161
|
}
|
1999
|
-
Object.entries(properties).forEach(([
|
2000
|
-
var _a;
|
2162
|
+
Object.entries(properties).forEach(([propertyId, propertyValue]) => {
|
2163
|
+
var _a, _b;
|
2001
2164
|
if (!locale) {
|
2002
|
-
delete
|
2165
|
+
delete propertyValue.locales;
|
2166
|
+
delete propertyValue.localesConditions;
|
2003
2167
|
}
|
2004
|
-
const currentLocaleValue = locale ? (_a =
|
2168
|
+
const currentLocaleValue = locale ? (_a = propertyValue.locales) == null ? void 0 : _a[locale] : void 0;
|
2005
2169
|
if (currentLocaleValue !== void 0) {
|
2006
|
-
|
2170
|
+
propertyValue.value = currentLocaleValue;
|
2171
|
+
}
|
2172
|
+
const currentLocaleConditionalValues = locale ? (_b = propertyValue.localesConditions) == null ? void 0 : _b[locale] : void 0;
|
2173
|
+
if (currentLocaleConditionalValues !== void 0) {
|
2174
|
+
propertyValue.conditions = currentLocaleConditionalValues;
|
2007
2175
|
}
|
2008
|
-
delete
|
2009
|
-
|
2010
|
-
|
2176
|
+
delete propertyValue.locales;
|
2177
|
+
delete propertyValue.localesConditions;
|
2178
|
+
if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
|
2179
|
+
delete properties[propertyId];
|
2011
2180
|
}
|
2012
2181
|
});
|
2182
|
+
evaluateWalkTreePropertyCriteria({
|
2183
|
+
node,
|
2184
|
+
rules,
|
2185
|
+
keepIndeterminate: true
|
2186
|
+
});
|
2013
2187
|
}
|
2014
2188
|
|
2015
2189
|
// src/enhancement/UniqueBatchEntries.ts
|
2016
2190
|
var UniqueBatchEntries = class {
|
2017
2191
|
constructor(entries, uniqueKeySelector) {
|
2018
|
-
this.groups = entries.reduce(
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2192
|
+
this.groups = entries.reduce(
|
2193
|
+
(acc, task) => {
|
2194
|
+
var _a;
|
2195
|
+
const key = uniqueKeySelector(task.args);
|
2196
|
+
acc[key] = (_a = acc[key]) != null ? _a : [];
|
2197
|
+
acc[key].push(task);
|
2198
|
+
return acc;
|
2199
|
+
},
|
2200
|
+
{}
|
2201
|
+
);
|
2025
2202
|
}
|
2026
2203
|
/** Resolves all entries in a group key with the same result value. */
|
2027
2204
|
resolveKey(key, result) {
|
@@ -2869,7 +3046,7 @@ var isComponentPlaceholderId = (id) => {
|
|
2869
3046
|
return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
|
2870
3047
|
};
|
2871
3048
|
var generateComponentPlaceholderId = (randomId, sdkVersion, parent) => {
|
2872
|
-
if (
|
3049
|
+
if (sdkVersion === 1) {
|
2873
3050
|
return PLACEHOLDER_ID;
|
2874
3051
|
}
|
2875
3052
|
let idParts = [PLACEHOLDER_ID, randomId];
|
@@ -2895,72 +3072,6 @@ var parseComponentPlaceholderId = (id) => {
|
|
2895
3072
|
return result;
|
2896
3073
|
};
|
2897
3074
|
|
2898
|
-
// src/utils/variables/parseVariableExpression.ts
|
2899
|
-
var escapeCharacter = "\\";
|
2900
|
-
var variablePrefix = "${";
|
2901
|
-
var variableSuffix = "}";
|
2902
|
-
function parseVariableExpression(serialized, onToken) {
|
2903
|
-
let bufferStartIndex = 0;
|
2904
|
-
let bufferEndIndex = 0;
|
2905
|
-
let tokenCount = 0;
|
2906
|
-
const handleToken = (token, type) => {
|
2907
|
-
tokenCount++;
|
2908
|
-
return onToken == null ? void 0 : onToken(token, type);
|
2909
|
-
};
|
2910
|
-
let state = "text";
|
2911
|
-
for (let index = 0; index < serialized.length; index++) {
|
2912
|
-
const char = serialized[index];
|
2913
|
-
if (bufferStartIndex > bufferEndIndex) {
|
2914
|
-
bufferEndIndex = bufferStartIndex;
|
2915
|
-
}
|
2916
|
-
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
2917
|
-
if (serialized[index - 1] === escapeCharacter) {
|
2918
|
-
bufferEndIndex -= escapeCharacter.length;
|
2919
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
2920
|
-
return tokenCount;
|
2921
|
-
}
|
2922
|
-
bufferStartIndex = index;
|
2923
|
-
bufferEndIndex = index + 1;
|
2924
|
-
continue;
|
2925
|
-
}
|
2926
|
-
state = "variable";
|
2927
|
-
if (bufferEndIndex > bufferStartIndex) {
|
2928
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
2929
|
-
return tokenCount;
|
2930
|
-
}
|
2931
|
-
bufferStartIndex = bufferEndIndex;
|
2932
|
-
}
|
2933
|
-
index += variablePrefix.length - 1;
|
2934
|
-
bufferStartIndex += variablePrefix.length;
|
2935
|
-
continue;
|
2936
|
-
}
|
2937
|
-
if (char === variableSuffix && state === "variable") {
|
2938
|
-
if (serialized[index - 1] === escapeCharacter) {
|
2939
|
-
bufferEndIndex++;
|
2940
|
-
continue;
|
2941
|
-
}
|
2942
|
-
state = "text";
|
2943
|
-
if (bufferEndIndex > bufferStartIndex) {
|
2944
|
-
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
2945
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
2946
|
-
return tokenCount;
|
2947
|
-
}
|
2948
|
-
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
2949
|
-
}
|
2950
|
-
continue;
|
2951
|
-
}
|
2952
|
-
bufferEndIndex++;
|
2953
|
-
}
|
2954
|
-
if (bufferEndIndex > bufferStartIndex) {
|
2955
|
-
if (state === "variable") {
|
2956
|
-
state = "text";
|
2957
|
-
bufferStartIndex -= variablePrefix.length;
|
2958
|
-
}
|
2959
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
2960
|
-
}
|
2961
|
-
return tokenCount;
|
2962
|
-
}
|
2963
|
-
|
2964
3075
|
// src/utils/variables/bindVariables.ts
|
2965
3076
|
function bindVariables({
|
2966
3077
|
variables,
|
@@ -2998,7 +3109,7 @@ function bindVariables({
|
|
2998
3109
|
}
|
2999
3110
|
|
3000
3111
|
// src/utils/variables/bindVariablesToObject.ts
|
3001
|
-
import { produce } from "immer";
|
3112
|
+
import { isDraft, produce } from "immer";
|
3002
3113
|
|
3003
3114
|
// src/utils/variables/createVariableReference.ts
|
3004
3115
|
function createVariableReference(variableName) {
|
@@ -3026,7 +3137,11 @@ function bindVariablesToObjectRecursive({
|
|
3026
3137
|
if (richTextNodeResult !== void 0) {
|
3027
3138
|
return richTextNodeResult;
|
3028
3139
|
}
|
3029
|
-
const
|
3140
|
+
const produceToUse = !isDraft(value) ? produce : (produceValue, producer) => {
|
3141
|
+
producer(produceValue);
|
3142
|
+
return produceValue;
|
3143
|
+
};
|
3144
|
+
const result = produceToUse(value, (draft) => {
|
3030
3145
|
Object.entries(draft).forEach(([property, oldValue]) => {
|
3031
3146
|
const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
|
3032
3147
|
if (typeof oldValue === "string") {
|
@@ -3132,6 +3247,7 @@ export {
|
|
3132
3247
|
ATTRIBUTE_PLACEHOLDER,
|
3133
3248
|
ApiClientError2 as ApiClientError,
|
3134
3249
|
BatchEntry,
|
3250
|
+
BlockFormatError,
|
3135
3251
|
CANVAS_BLOCK_PARAM_TYPE,
|
3136
3252
|
CANVAS_DRAFT_STATE,
|
3137
3253
|
CANVAS_EDITOR_STATE,
|
@@ -3151,6 +3267,7 @@ export {
|
|
3151
3267
|
CANVAS_TEST_VARIANT_PARAM,
|
3152
3268
|
CANVAS_VIZ_CONTROL_PARAM,
|
3153
3269
|
CANVAS_VIZ_DI_RULE,
|
3270
|
+
CANVAS_VIZ_DYNAMIC_TOKEN_RULE,
|
3154
3271
|
CANVAS_VIZ_LOCALE_RULE,
|
3155
3272
|
CANVAS_VIZ_QUIRKS_RULE,
|
3156
3273
|
CanvasClient,
|
@@ -3196,6 +3313,7 @@ export {
|
|
3196
3313
|
createBatchEnhancer,
|
3197
3314
|
createCanvasChannel,
|
3198
3315
|
createDynamicInputVisibilityRule,
|
3316
|
+
createDynamicTokenVisibilityRule,
|
3199
3317
|
createEventBus,
|
3200
3318
|
createLimitPolicy,
|
3201
3319
|
createLocaleVisibilityRule,
|
@@ -3203,6 +3321,7 @@ export {
|
|
3203
3321
|
createUniformApiEnhancer,
|
3204
3322
|
createVariableReference,
|
3205
3323
|
enhance,
|
3324
|
+
evaluateNodeVisibilityParameter,
|
3206
3325
|
evaluatePropertyCriteria,
|
3207
3326
|
evaluateVisibilityCriteriaGroup,
|
3208
3327
|
evaluateWalkTreeNodeVisibility,
|
@@ -3222,6 +3341,7 @@ export {
|
|
3222
3341
|
getParameterAttributes,
|
3223
3342
|
getPropertiesValue,
|
3224
3343
|
getPropertyValue,
|
3344
|
+
hasReferencedVariables,
|
3225
3345
|
isAddComponentMessage,
|
3226
3346
|
isAllowedReferrer,
|
3227
3347
|
isAssetParamValue,
|
@@ -3231,6 +3351,7 @@ export {
|
|
3231
3351
|
isContextStorageUpdatedMessage,
|
3232
3352
|
isDismissPlaceholderMessage,
|
3233
3353
|
isEntryData,
|
3354
|
+
isLinkParamValue,
|
3234
3355
|
isMovingComponentMessage,
|
3235
3356
|
isNestedNodeType,
|
3236
3357
|
isOpenParameterEditorMessage,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/canvas",
|
3
|
-
"version": "19.173.
|
3
|
+
"version": "19.173.2-alpha.210+4f0f6ff104",
|
4
4
|
"description": "Common functionality and types for Uniform Canvas",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -32,14 +32,15 @@
|
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
34
34
|
"@types/retry": "0.12.5",
|
35
|
-
"lexical": "0.
|
35
|
+
"lexical": "0.17.1",
|
36
36
|
"p-retry": "5.1.2",
|
37
37
|
"p-throttle": "5.0.0",
|
38
38
|
"pusher-js": "8.2.0"
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@uniformdev/assets": "19.173.
|
42
|
-
"@uniformdev/context": "19.173.
|
41
|
+
"@uniformdev/assets": "19.173.2-alpha.210+4f0f6ff104",
|
42
|
+
"@uniformdev/context": "19.173.2-alpha.210+4f0f6ff104",
|
43
|
+
"@uniformdev/richtext": "19.173.2-alpha.210+4f0f6ff104",
|
43
44
|
"immer": "10.1.1"
|
44
45
|
},
|
45
46
|
"files": [
|
@@ -48,5 +49,5 @@
|
|
48
49
|
"publishConfig": {
|
49
50
|
"access": "public"
|
50
51
|
},
|
51
|
-
"gitHead": "
|
52
|
+
"gitHead": "4f0f6ff104f46349c338fde461f063f22f04ce0e"
|
52
53
|
}
|