@uniformdev/canvas 19.173.0 → 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 +4113 -2467
- package/dist/index.d.ts +4113 -2467
- package/dist/index.esm.js +354 -110
- package/dist/index.js +362 -110
- package/dist/index.mjs +354 -110
- package/package.json +6 -5
package/dist/index.js
CHANGED
@@ -281,6 +281,7 @@ __export(src_exports, {
|
|
281
281
|
ATTRIBUTE_PLACEHOLDER: () => ATTRIBUTE_PLACEHOLDER,
|
282
282
|
ApiClientError: () => import_api15.ApiClientError,
|
283
283
|
BatchEntry: () => BatchEntry,
|
284
|
+
BlockFormatError: () => BlockFormatError,
|
284
285
|
CANVAS_BLOCK_PARAM_TYPE: () => CANVAS_BLOCK_PARAM_TYPE,
|
285
286
|
CANVAS_DRAFT_STATE: () => CANVAS_DRAFT_STATE,
|
286
287
|
CANVAS_EDITOR_STATE: () => CANVAS_EDITOR_STATE,
|
@@ -300,6 +301,7 @@ __export(src_exports, {
|
|
300
301
|
CANVAS_TEST_VARIANT_PARAM: () => CANVAS_TEST_VARIANT_PARAM,
|
301
302
|
CANVAS_VIZ_CONTROL_PARAM: () => CANVAS_VIZ_CONTROL_PARAM,
|
302
303
|
CANVAS_VIZ_DI_RULE: () => CANVAS_VIZ_DI_RULE,
|
304
|
+
CANVAS_VIZ_DYNAMIC_TOKEN_RULE: () => CANVAS_VIZ_DYNAMIC_TOKEN_RULE,
|
303
305
|
CANVAS_VIZ_LOCALE_RULE: () => CANVAS_VIZ_LOCALE_RULE,
|
304
306
|
CANVAS_VIZ_QUIRKS_RULE: () => CANVAS_VIZ_QUIRKS_RULE,
|
305
307
|
CanvasClient: () => CanvasClient,
|
@@ -345,6 +347,7 @@ __export(src_exports, {
|
|
345
347
|
createBatchEnhancer: () => createBatchEnhancer,
|
346
348
|
createCanvasChannel: () => createCanvasChannel,
|
347
349
|
createDynamicInputVisibilityRule: () => createDynamicInputVisibilityRule,
|
350
|
+
createDynamicTokenVisibilityRule: () => createDynamicTokenVisibilityRule,
|
348
351
|
createEventBus: () => createEventBus,
|
349
352
|
createLimitPolicy: () => createLimitPolicy,
|
350
353
|
createLocaleVisibilityRule: () => createLocaleVisibilityRule,
|
@@ -352,8 +355,11 @@ __export(src_exports, {
|
|
352
355
|
createUniformApiEnhancer: () => createUniformApiEnhancer,
|
353
356
|
createVariableReference: () => createVariableReference,
|
354
357
|
enhance: () => enhance,
|
358
|
+
evaluateNodeVisibilityParameter: () => evaluateNodeVisibilityParameter,
|
359
|
+
evaluatePropertyCriteria: () => evaluatePropertyCriteria,
|
355
360
|
evaluateVisibilityCriteriaGroup: () => evaluateVisibilityCriteriaGroup,
|
356
|
-
|
361
|
+
evaluateWalkTreeNodeVisibility: () => evaluateWalkTreeNodeVisibility,
|
362
|
+
evaluateWalkTreePropertyCriteria: () => evaluateWalkTreePropertyCriteria,
|
357
363
|
extractLocales: () => extractLocales,
|
358
364
|
findParameterInNodeTree: () => findParameterInNodeTree,
|
359
365
|
flattenValues: () => flattenValues,
|
@@ -369,6 +375,7 @@ __export(src_exports, {
|
|
369
375
|
getParameterAttributes: () => getParameterAttributes,
|
370
376
|
getPropertiesValue: () => getPropertiesValue,
|
371
377
|
getPropertyValue: () => getPropertyValue,
|
378
|
+
hasReferencedVariables: () => hasReferencedVariables,
|
372
379
|
isAddComponentMessage: () => isAddComponentMessage,
|
373
380
|
isAllowedReferrer: () => isAllowedReferrer,
|
374
381
|
isAssetParamValue: () => isAssetParamValue,
|
@@ -378,6 +385,7 @@ __export(src_exports, {
|
|
378
385
|
isContextStorageUpdatedMessage: () => isContextStorageUpdatedMessage,
|
379
386
|
isDismissPlaceholderMessage: () => isDismissPlaceholderMessage,
|
380
387
|
isEntryData: () => isEntryData,
|
388
|
+
isLinkParamValue: () => isLinkParamValue,
|
381
389
|
isMovingComponentMessage: () => isMovingComponentMessage,
|
382
390
|
isNestedNodeType: () => isNestedNodeType,
|
383
391
|
isOpenParameterEditorMessage: () => isOpenParameterEditorMessage,
|
@@ -610,14 +618,17 @@ var nullLimitPolicy = async (func) => await func();
|
|
610
618
|
// src/utils/rewriteFilters.ts
|
611
619
|
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
612
620
|
function rewriteFilters(filters) {
|
613
|
-
return Object.entries(filters != null ? filters : {}).reduce(
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
+
return Object.entries(filters != null ? filters : {}).reduce(
|
622
|
+
(acc, [key, value]) => {
|
623
|
+
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
624
|
+
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
625
|
+
return {
|
626
|
+
...acc,
|
627
|
+
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
628
|
+
};
|
629
|
+
},
|
630
|
+
{}
|
631
|
+
);
|
621
632
|
}
|
622
633
|
|
623
634
|
// src/CanvasClient.ts
|
@@ -1128,6 +1139,9 @@ function isAssetParamValueItem(item) {
|
|
1128
1139
|
item instanceof Object && "_source" in item && "fields" in item && item.fields instanceof Object && "url" in item.fields && item.fields.url instanceof Object
|
1129
1140
|
);
|
1130
1141
|
}
|
1142
|
+
function isLinkParamValue(value) {
|
1143
|
+
return typeof value === "object" && value !== null && "type" in value && "path" in value;
|
1144
|
+
}
|
1131
1145
|
|
1132
1146
|
// src/utils/properties.ts
|
1133
1147
|
function getPropertiesValue(entity) {
|
@@ -1179,6 +1193,86 @@ function flattenSingleNodeValues(data, options = {}) {
|
|
1179
1193
|
) : properties;
|
1180
1194
|
}
|
1181
1195
|
|
1196
|
+
// src/utils/variables/parseVariableExpression.ts
|
1197
|
+
var escapeCharacter = "\\";
|
1198
|
+
var variablePrefix = "${";
|
1199
|
+
var variableSuffix = "}";
|
1200
|
+
function parseVariableExpression(serialized, onToken) {
|
1201
|
+
let bufferStartIndex = 0;
|
1202
|
+
let bufferEndIndex = 0;
|
1203
|
+
let tokenCount = 0;
|
1204
|
+
const handleToken = (token, type) => {
|
1205
|
+
tokenCount++;
|
1206
|
+
return onToken == null ? void 0 : onToken(token, type);
|
1207
|
+
};
|
1208
|
+
let state = "text";
|
1209
|
+
for (let index = 0; index < serialized.length; index++) {
|
1210
|
+
const char = serialized[index];
|
1211
|
+
if (bufferStartIndex > bufferEndIndex) {
|
1212
|
+
bufferEndIndex = bufferStartIndex;
|
1213
|
+
}
|
1214
|
+
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
1215
|
+
if (serialized[index - 1] === escapeCharacter) {
|
1216
|
+
bufferEndIndex -= escapeCharacter.length;
|
1217
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
1218
|
+
return tokenCount;
|
1219
|
+
}
|
1220
|
+
bufferStartIndex = index;
|
1221
|
+
bufferEndIndex = index + 1;
|
1222
|
+
continue;
|
1223
|
+
}
|
1224
|
+
state = "variable";
|
1225
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1226
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
1227
|
+
return tokenCount;
|
1228
|
+
}
|
1229
|
+
bufferStartIndex = bufferEndIndex;
|
1230
|
+
}
|
1231
|
+
index += variablePrefix.length - 1;
|
1232
|
+
bufferStartIndex += variablePrefix.length;
|
1233
|
+
continue;
|
1234
|
+
}
|
1235
|
+
if (char === variableSuffix && state === "variable") {
|
1236
|
+
if (serialized[index - 1] === escapeCharacter) {
|
1237
|
+
bufferEndIndex++;
|
1238
|
+
continue;
|
1239
|
+
}
|
1240
|
+
state = "text";
|
1241
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1242
|
+
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
1243
|
+
if (handleToken(unescapedVariableName, "variable") === false) {
|
1244
|
+
return tokenCount;
|
1245
|
+
}
|
1246
|
+
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
1247
|
+
}
|
1248
|
+
continue;
|
1249
|
+
}
|
1250
|
+
bufferEndIndex++;
|
1251
|
+
}
|
1252
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1253
|
+
if (state === "variable") {
|
1254
|
+
state = "text";
|
1255
|
+
bufferStartIndex -= variablePrefix.length;
|
1256
|
+
}
|
1257
|
+
handleToken(serialized.substring(bufferStartIndex), state);
|
1258
|
+
}
|
1259
|
+
return tokenCount;
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
// src/utils/variables/hasReferencedVariables.ts
|
1263
|
+
function hasReferencedVariables(value) {
|
1264
|
+
if (value === void 0) {
|
1265
|
+
return 0;
|
1266
|
+
}
|
1267
|
+
let variableTokenCount = 0;
|
1268
|
+
parseVariableExpression(value, (_, tokenType) => {
|
1269
|
+
if (tokenType === "variable") {
|
1270
|
+
variableTokenCount++;
|
1271
|
+
}
|
1272
|
+
});
|
1273
|
+
return variableTokenCount;
|
1274
|
+
}
|
1275
|
+
|
1182
1276
|
// src/enhancement/walkNodeTree.ts
|
1183
1277
|
function walkNodeTree(node, visitor, options) {
|
1184
1278
|
var _a, _b;
|
@@ -1402,7 +1496,25 @@ function walkNodeTree(node, visitor, options) {
|
|
1402
1496
|
const propertyEntries = Object.entries(properties);
|
1403
1497
|
for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
|
1404
1498
|
const [propKey, propObject] = propertyEntries[propIndex];
|
1405
|
-
if (!isNestedNodeType(propObject.type))
|
1499
|
+
if (!isNestedNodeType(propObject.type)) {
|
1500
|
+
continue;
|
1501
|
+
}
|
1502
|
+
if (typeof propObject.value === "string" && hasReferencedVariables(propObject.value) > 0) {
|
1503
|
+
continue;
|
1504
|
+
}
|
1505
|
+
if (!Array.isArray(propObject.value)) {
|
1506
|
+
const error = new BlockFormatError(
|
1507
|
+
`${getComponentPath(currentQueueEntry.ancestorsAndSelf)}`,
|
1508
|
+
propKey,
|
1509
|
+
propObject.value
|
1510
|
+
);
|
1511
|
+
if (options == null ? void 0 : options.throwForInvalidBlockValues) {
|
1512
|
+
throw error;
|
1513
|
+
} else {
|
1514
|
+
console.warn(`Skipped invalid block value: ${error.message}}`);
|
1515
|
+
continue;
|
1516
|
+
}
|
1517
|
+
}
|
1406
1518
|
const blocks = (_b = propObject.value) != null ? _b : [];
|
1407
1519
|
for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
|
1408
1520
|
const enqueueingBlock = blocks[blockIndex];
|
@@ -1438,6 +1550,17 @@ function getBlockValue(component, parameterName) {
|
|
1438
1550
|
}
|
1439
1551
|
return [];
|
1440
1552
|
}
|
1553
|
+
var BlockFormatError = class _BlockFormatError extends Error {
|
1554
|
+
constructor(componentPath, propertyId, blockValue) {
|
1555
|
+
super(
|
1556
|
+
`${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}`
|
1557
|
+
);
|
1558
|
+
this.componentPath = componentPath;
|
1559
|
+
this.propertyId = propertyId;
|
1560
|
+
this.blockValue = blockValue;
|
1561
|
+
Object.setPrototypeOf(this, _BlockFormatError.prototype);
|
1562
|
+
}
|
1563
|
+
};
|
1441
1564
|
|
1442
1565
|
// src/enhancement/enhance.ts
|
1443
1566
|
async function enhance({
|
@@ -1766,12 +1889,18 @@ function evaluateVisibilityCriteriaGroup(options) {
|
|
1766
1889
|
return hasIndeterminateClauses ? null : !earlyExitResult;
|
1767
1890
|
}
|
1768
1891
|
function evaluateCriterion(clause, rootOptions) {
|
1892
|
+
var _a;
|
1769
1893
|
if ("clauses" in clause) {
|
1770
1894
|
return evaluateVisibilityCriteriaGroup({
|
1771
1895
|
...rootOptions,
|
1772
1896
|
criteriaGroup: clause
|
1773
1897
|
});
|
1774
1898
|
}
|
1899
|
+
const lhs = (_a = clause.source) != null ? _a : clause.rule;
|
1900
|
+
const rhs = Array.isArray(clause.value) ? clause.value : clause.value !== void 0 ? [clause.value] : void 0;
|
1901
|
+
if (hasReferencedVariables(lhs) > 0 || (rhs == null ? void 0 : rhs.some((rhv) => hasReferencedVariables(rhv) > 0))) {
|
1902
|
+
return null;
|
1903
|
+
}
|
1775
1904
|
const rule = rootOptions.rules[clause.rule];
|
1776
1905
|
if (rule) {
|
1777
1906
|
return rule(clause);
|
@@ -1779,6 +1908,77 @@ function evaluateCriterion(clause, rootOptions) {
|
|
1779
1908
|
return null;
|
1780
1909
|
}
|
1781
1910
|
|
1911
|
+
// src/enhancement/visibility/evaluateNodeVisibilityParameter.ts
|
1912
|
+
function evaluateNodeVisibilityParameter({
|
1913
|
+
parameter,
|
1914
|
+
...evaluateGroupOptions
|
1915
|
+
}) {
|
1916
|
+
if (parameter == null ? void 0 : parameter.explicitlyHidden) {
|
1917
|
+
return false;
|
1918
|
+
}
|
1919
|
+
if (!(parameter == null ? void 0 : parameter.criteria)) {
|
1920
|
+
return true;
|
1921
|
+
}
|
1922
|
+
const result = evaluateVisibilityCriteriaGroup({
|
1923
|
+
...evaluateGroupOptions,
|
1924
|
+
criteriaGroup: parameter.criteria
|
1925
|
+
});
|
1926
|
+
return result;
|
1927
|
+
}
|
1928
|
+
|
1929
|
+
// src/enhancement/visibility/evaluatePropertyCriteria.ts
|
1930
|
+
function evaluatePropertyCriteria({
|
1931
|
+
baseValue,
|
1932
|
+
conditionalValues,
|
1933
|
+
keepIndeterminate,
|
1934
|
+
...evaluateGroupOptions
|
1935
|
+
}) {
|
1936
|
+
let authoritative = true;
|
1937
|
+
const result = {
|
1938
|
+
currentValue: baseValue,
|
1939
|
+
remainingConditionalValues: evaluateGroupOptions.simplifyCriteria && conditionalValues ? [...conditionalValues] : conditionalValues,
|
1940
|
+
currentConditionIndex: -1
|
1941
|
+
};
|
1942
|
+
if (!conditionalValues) {
|
1943
|
+
return result;
|
1944
|
+
}
|
1945
|
+
const conditionIndexesToRemove = [];
|
1946
|
+
for (let i = 0; i < conditionalValues.length; i++) {
|
1947
|
+
const conditionalVariant = conditionalValues[i];
|
1948
|
+
if (result.matched) {
|
1949
|
+
conditionIndexesToRemove.push(i);
|
1950
|
+
continue;
|
1951
|
+
}
|
1952
|
+
const evaluationResult = evaluateVisibilityCriteriaGroup({
|
1953
|
+
...evaluateGroupOptions,
|
1954
|
+
criteriaGroup: conditionalVariant.when
|
1955
|
+
});
|
1956
|
+
if (evaluationResult === null) {
|
1957
|
+
if (keepIndeterminate) {
|
1958
|
+
authoritative = false;
|
1959
|
+
} else {
|
1960
|
+
conditionIndexesToRemove.push(i);
|
1961
|
+
}
|
1962
|
+
} else if (evaluationResult === true) {
|
1963
|
+
result.matched = conditionalVariant;
|
1964
|
+
result.currentValue = conditionalVariant.value;
|
1965
|
+
result.currentConditionIndex = i;
|
1966
|
+
conditionIndexesToRemove.push(i);
|
1967
|
+
} else {
|
1968
|
+
conditionIndexesToRemove.push(i);
|
1969
|
+
}
|
1970
|
+
}
|
1971
|
+
if (evaluateGroupOptions.simplifyCriteria) {
|
1972
|
+
for (let i = conditionIndexesToRemove.length - 1; i >= 0; i--) {
|
1973
|
+
result.remainingConditionalValues.splice(conditionIndexesToRemove[i], 1);
|
1974
|
+
}
|
1975
|
+
}
|
1976
|
+
if (authoritative) {
|
1977
|
+
result.remainingConditionalValues = void 0;
|
1978
|
+
}
|
1979
|
+
return result;
|
1980
|
+
}
|
1981
|
+
|
1782
1982
|
// src/enhancement/visibility/types.ts
|
1783
1983
|
var CANVAS_VIZ_CONTROL_PARAM = "$viz";
|
1784
1984
|
|
@@ -1790,24 +1990,18 @@ function evaluateNodeVisibility({
|
|
1790
1990
|
var _a;
|
1791
1991
|
const properties = getPropertiesValue(node);
|
1792
1992
|
const vizCriteria = (_a = properties == null ? void 0 : properties[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _a.value;
|
1793
|
-
|
1794
|
-
return false;
|
1795
|
-
}
|
1796
|
-
if (!(vizCriteria == null ? void 0 : vizCriteria.criteria)) {
|
1797
|
-
return true;
|
1798
|
-
}
|
1799
|
-
const result = evaluateVisibilityCriteriaGroup({
|
1993
|
+
const result = evaluateNodeVisibilityParameter({
|
1800
1994
|
...evaluateGroupOptions,
|
1801
|
-
|
1995
|
+
parameter: vizCriteria
|
1802
1996
|
});
|
1803
|
-
if (vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
|
1997
|
+
if ((vizCriteria == null ? void 0 : vizCriteria.criteria) && vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
|
1804
1998
|
properties == null ? true : delete properties[CANVAS_VIZ_CONTROL_PARAM];
|
1805
1999
|
}
|
1806
2000
|
return result;
|
1807
2001
|
}
|
1808
2002
|
|
1809
|
-
// src/enhancement/visibility/
|
1810
|
-
function
|
2003
|
+
// src/enhancement/visibility/evaluateWalkTreeNodeVisibility.ts
|
2004
|
+
function evaluateWalkTreeNodeVisibility({
|
1811
2005
|
rules,
|
1812
2006
|
showIndeterminate,
|
1813
2007
|
context
|
@@ -1824,6 +2018,77 @@ function evaluateWalkTreeVisibility({
|
|
1824
2018
|
return true;
|
1825
2019
|
}
|
1826
2020
|
|
2021
|
+
// src/enhancement/visibility/evaluateWalkTreePropertyCriteria.ts
|
2022
|
+
function evaluateWalkTreePropertyCriteria({
|
2023
|
+
rules,
|
2024
|
+
node,
|
2025
|
+
keepIndeterminate
|
2026
|
+
}) {
|
2027
|
+
const properties = getPropertiesValue(node);
|
2028
|
+
if (!properties) {
|
2029
|
+
return;
|
2030
|
+
}
|
2031
|
+
Object.entries(properties).forEach(([propertyName, property]) => {
|
2032
|
+
var _a, _b, _c;
|
2033
|
+
if (property.locales || property.localesConditions) {
|
2034
|
+
const localesDefined = [
|
2035
|
+
...Object.keys((_a = property.locales) != null ? _a : {}),
|
2036
|
+
...Object.keys((_b = property.localesConditions) != null ? _b : {})
|
2037
|
+
];
|
2038
|
+
localesDefined.forEach((locale) => {
|
2039
|
+
var _a2, _b2, _c2, _d, _e, _f;
|
2040
|
+
const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
|
2041
|
+
baseValue: (_a2 = property.locales) == null ? void 0 : _a2[locale],
|
2042
|
+
conditionalValues: (_b2 = property.localesConditions) == null ? void 0 : _b2[locale],
|
2043
|
+
rules,
|
2044
|
+
simplifyCriteria: true,
|
2045
|
+
keepIndeterminate
|
2046
|
+
});
|
2047
|
+
if (currentValue === null || currentValue === void 0) {
|
2048
|
+
(_c2 = property.locales) == null ? true : delete _c2[locale];
|
2049
|
+
} else {
|
2050
|
+
(_d = property.locales) != null ? _d : property.locales = {};
|
2051
|
+
property.locales[locale] = currentValue;
|
2052
|
+
}
|
2053
|
+
if (!(remainingConditionalValues == null ? void 0 : remainingConditionalValues.length)) {
|
2054
|
+
(_e = property.localesConditions) == null ? true : delete _e[locale];
|
2055
|
+
} else {
|
2056
|
+
(_f = property.localesConditions) != null ? _f : property.localesConditions = {};
|
2057
|
+
property.localesConditions[locale] = remainingConditionalValues;
|
2058
|
+
}
|
2059
|
+
});
|
2060
|
+
if (!Object.keys((_c = property.localesConditions) != null ? _c : {}).length) {
|
2061
|
+
delete property.localesConditions;
|
2062
|
+
}
|
2063
|
+
if (!property.locales && !property.localesConditions) {
|
2064
|
+
delete properties[propertyName];
|
2065
|
+
}
|
2066
|
+
} else {
|
2067
|
+
const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
|
2068
|
+
baseValue: property.value,
|
2069
|
+
conditionalValues: property.conditions,
|
2070
|
+
rules,
|
2071
|
+
simplifyCriteria: true,
|
2072
|
+
keepIndeterminate
|
2073
|
+
});
|
2074
|
+
if (currentValue === null) {
|
2075
|
+
delete properties[propertyName];
|
2076
|
+
} else {
|
2077
|
+
if (currentValue !== void 0) {
|
2078
|
+
property.value = currentValue;
|
2079
|
+
} else {
|
2080
|
+
delete property.value;
|
2081
|
+
}
|
2082
|
+
}
|
2083
|
+
if (remainingConditionalValues === void 0) {
|
2084
|
+
delete property.conditions;
|
2085
|
+
} else {
|
2086
|
+
property.conditions = remainingConditionalValues;
|
2087
|
+
}
|
2088
|
+
}
|
2089
|
+
});
|
2090
|
+
}
|
2091
|
+
|
1827
2092
|
// src/enhancement/visibility/rules/evaluateStringMatch.ts
|
1828
2093
|
var isEvaluator = (criteria, matchValue) => {
|
1829
2094
|
if (Array.isArray(criteria)) {
|
@@ -1901,6 +2166,32 @@ function createDynamicInputVisibilityRule(dynamicInputs) {
|
|
1901
2166
|
};
|
1902
2167
|
}
|
1903
2168
|
|
2169
|
+
// src/enhancement/visibility/rules/createDynamicTokenVisibilityRule.ts
|
2170
|
+
var dynamicTokenVisibilityOperators = /* @__PURE__ */ new Set([
|
2171
|
+
"is",
|
2172
|
+
"!is",
|
2173
|
+
"has",
|
2174
|
+
"!has",
|
2175
|
+
"startswith",
|
2176
|
+
"!startswith",
|
2177
|
+
"endswith",
|
2178
|
+
"!endswith",
|
2179
|
+
"empty",
|
2180
|
+
"!empty"
|
2181
|
+
]);
|
2182
|
+
var CANVAS_VIZ_DYNAMIC_TOKEN_RULE = "$dt";
|
2183
|
+
function createDynamicTokenVisibilityRule() {
|
2184
|
+
return {
|
2185
|
+
[CANVAS_VIZ_DYNAMIC_TOKEN_RULE]: (criterion) => {
|
2186
|
+
var _a;
|
2187
|
+
if (hasReferencedVariables(criterion.source)) {
|
2188
|
+
return null;
|
2189
|
+
}
|
2190
|
+
return evaluateStringMatch(criterion, (_a = criterion.source) != null ? _a : "", dynamicTokenVisibilityOperators);
|
2191
|
+
}
|
2192
|
+
};
|
2193
|
+
}
|
2194
|
+
|
1904
2195
|
// src/enhancement/visibility/rules/createLocaleVisibilityRule.ts
|
1905
2196
|
var localeVisibilityOperators = /* @__PURE__ */ new Set(["is", "!is"]);
|
1906
2197
|
var CANVAS_VIZ_LOCALE_RULE = "$locale";
|
@@ -1963,12 +2254,12 @@ function localize(options) {
|
|
1963
2254
|
const { type, node, actions } = context;
|
1964
2255
|
if (type !== "component") {
|
1965
2256
|
if (isUsingModernOptions) {
|
1966
|
-
localizeProperties(node
|
2257
|
+
localizeProperties(node, locale, vizControlLocaleRule);
|
1967
2258
|
}
|
1968
2259
|
return;
|
1969
2260
|
}
|
1970
2261
|
if (isUsingModernOptions) {
|
1971
|
-
const result =
|
2262
|
+
const result = evaluateWalkTreeNodeVisibility({
|
1972
2263
|
context,
|
1973
2264
|
rules: vizControlLocaleRule,
|
1974
2265
|
showIndeterminate: true
|
@@ -1988,7 +2279,7 @@ function localize(options) {
|
|
1988
2279
|
replaceComponent.forEach((component) => {
|
1989
2280
|
removeLocaleProperty(component);
|
1990
2281
|
if (isUsingModernOptions) {
|
1991
|
-
localizeProperties(
|
2282
|
+
localizeProperties(component, locale, vizControlLocaleRule);
|
1992
2283
|
}
|
1993
2284
|
});
|
1994
2285
|
const [first, ...rest] = replaceComponent;
|
@@ -2000,7 +2291,7 @@ function localize(options) {
|
|
2000
2291
|
actions.remove();
|
2001
2292
|
}
|
2002
2293
|
} else if (isUsingModernOptions) {
|
2003
|
-
localizeProperties(
|
2294
|
+
localizeProperties(node, locale, vizControlLocaleRule);
|
2004
2295
|
}
|
2005
2296
|
});
|
2006
2297
|
}
|
@@ -2019,36 +2310,51 @@ function removeLocaleProperty(component) {
|
|
2019
2310
|
}
|
2020
2311
|
}
|
2021
2312
|
}
|
2022
|
-
function localizeProperties(
|
2313
|
+
function localizeProperties(node, locale, rules) {
|
2314
|
+
const properties = getPropertiesValue(node);
|
2023
2315
|
if (!properties) {
|
2024
2316
|
return void 0;
|
2025
2317
|
}
|
2026
|
-
Object.entries(properties).forEach(([
|
2027
|
-
var _a;
|
2318
|
+
Object.entries(properties).forEach(([propertyId, propertyValue]) => {
|
2319
|
+
var _a, _b;
|
2028
2320
|
if (!locale) {
|
2029
|
-
delete
|
2321
|
+
delete propertyValue.locales;
|
2322
|
+
delete propertyValue.localesConditions;
|
2030
2323
|
}
|
2031
|
-
const currentLocaleValue = locale ? (_a =
|
2324
|
+
const currentLocaleValue = locale ? (_a = propertyValue.locales) == null ? void 0 : _a[locale] : void 0;
|
2032
2325
|
if (currentLocaleValue !== void 0) {
|
2033
|
-
|
2326
|
+
propertyValue.value = currentLocaleValue;
|
2034
2327
|
}
|
2035
|
-
|
2036
|
-
if (
|
2037
|
-
|
2328
|
+
const currentLocaleConditionalValues = locale ? (_b = propertyValue.localesConditions) == null ? void 0 : _b[locale] : void 0;
|
2329
|
+
if (currentLocaleConditionalValues !== void 0) {
|
2330
|
+
propertyValue.conditions = currentLocaleConditionalValues;
|
2038
2331
|
}
|
2332
|
+
delete propertyValue.locales;
|
2333
|
+
delete propertyValue.localesConditions;
|
2334
|
+
if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
|
2335
|
+
delete properties[propertyId];
|
2336
|
+
}
|
2337
|
+
});
|
2338
|
+
evaluateWalkTreePropertyCriteria({
|
2339
|
+
node,
|
2340
|
+
rules,
|
2341
|
+
keepIndeterminate: true
|
2039
2342
|
});
|
2040
2343
|
}
|
2041
2344
|
|
2042
2345
|
// src/enhancement/UniqueBatchEntries.ts
|
2043
2346
|
var UniqueBatchEntries = class {
|
2044
2347
|
constructor(entries, uniqueKeySelector) {
|
2045
|
-
this.groups = entries.reduce(
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2348
|
+
this.groups = entries.reduce(
|
2349
|
+
(acc, task) => {
|
2350
|
+
var _a;
|
2351
|
+
const key = uniqueKeySelector(task.args);
|
2352
|
+
acc[key] = (_a = acc[key]) != null ? _a : [];
|
2353
|
+
acc[key].push(task);
|
2354
|
+
return acc;
|
2355
|
+
},
|
2356
|
+
{}
|
2357
|
+
);
|
2052
2358
|
}
|
2053
2359
|
/** Resolves all entries in a group key with the same result value. */
|
2054
2360
|
resolveKey(key, result) {
|
@@ -2896,7 +3202,7 @@ var isComponentPlaceholderId = (id) => {
|
|
2896
3202
|
return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
|
2897
3203
|
};
|
2898
3204
|
var generateComponentPlaceholderId = (randomId, sdkVersion, parent) => {
|
2899
|
-
if (
|
3205
|
+
if (sdkVersion === 1) {
|
2900
3206
|
return PLACEHOLDER_ID;
|
2901
3207
|
}
|
2902
3208
|
let idParts = [PLACEHOLDER_ID, randomId];
|
@@ -2922,72 +3228,6 @@ var parseComponentPlaceholderId = (id) => {
|
|
2922
3228
|
return result;
|
2923
3229
|
};
|
2924
3230
|
|
2925
|
-
// src/utils/variables/parseVariableExpression.ts
|
2926
|
-
var escapeCharacter = "\\";
|
2927
|
-
var variablePrefix = "${";
|
2928
|
-
var variableSuffix = "}";
|
2929
|
-
function parseVariableExpression(serialized, onToken) {
|
2930
|
-
let bufferStartIndex = 0;
|
2931
|
-
let bufferEndIndex = 0;
|
2932
|
-
let tokenCount = 0;
|
2933
|
-
const handleToken = (token, type) => {
|
2934
|
-
tokenCount++;
|
2935
|
-
return onToken == null ? void 0 : onToken(token, type);
|
2936
|
-
};
|
2937
|
-
let state = "text";
|
2938
|
-
for (let index = 0; index < serialized.length; index++) {
|
2939
|
-
const char = serialized[index];
|
2940
|
-
if (bufferStartIndex > bufferEndIndex) {
|
2941
|
-
bufferEndIndex = bufferStartIndex;
|
2942
|
-
}
|
2943
|
-
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
2944
|
-
if (serialized[index - 1] === escapeCharacter) {
|
2945
|
-
bufferEndIndex -= escapeCharacter.length;
|
2946
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
2947
|
-
return tokenCount;
|
2948
|
-
}
|
2949
|
-
bufferStartIndex = index;
|
2950
|
-
bufferEndIndex = index + 1;
|
2951
|
-
continue;
|
2952
|
-
}
|
2953
|
-
state = "variable";
|
2954
|
-
if (bufferEndIndex > bufferStartIndex) {
|
2955
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
2956
|
-
return tokenCount;
|
2957
|
-
}
|
2958
|
-
bufferStartIndex = bufferEndIndex;
|
2959
|
-
}
|
2960
|
-
index += variablePrefix.length - 1;
|
2961
|
-
bufferStartIndex += variablePrefix.length;
|
2962
|
-
continue;
|
2963
|
-
}
|
2964
|
-
if (char === variableSuffix && state === "variable") {
|
2965
|
-
if (serialized[index - 1] === escapeCharacter) {
|
2966
|
-
bufferEndIndex++;
|
2967
|
-
continue;
|
2968
|
-
}
|
2969
|
-
state = "text";
|
2970
|
-
if (bufferEndIndex > bufferStartIndex) {
|
2971
|
-
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
2972
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
2973
|
-
return tokenCount;
|
2974
|
-
}
|
2975
|
-
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
2976
|
-
}
|
2977
|
-
continue;
|
2978
|
-
}
|
2979
|
-
bufferEndIndex++;
|
2980
|
-
}
|
2981
|
-
if (bufferEndIndex > bufferStartIndex) {
|
2982
|
-
if (state === "variable") {
|
2983
|
-
state = "text";
|
2984
|
-
bufferStartIndex -= variablePrefix.length;
|
2985
|
-
}
|
2986
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
2987
|
-
}
|
2988
|
-
return tokenCount;
|
2989
|
-
}
|
2990
|
-
|
2991
3231
|
// src/utils/variables/bindVariables.ts
|
2992
3232
|
function bindVariables({
|
2993
3233
|
variables,
|
@@ -3053,7 +3293,11 @@ function bindVariablesToObjectRecursive({
|
|
3053
3293
|
if (richTextNodeResult !== void 0) {
|
3054
3294
|
return richTextNodeResult;
|
3055
3295
|
}
|
3056
|
-
const
|
3296
|
+
const produceToUse = !(0, import_immer.isDraft)(value) ? import_immer.produce : (produceValue, producer) => {
|
3297
|
+
producer(produceValue);
|
3298
|
+
return produceValue;
|
3299
|
+
};
|
3300
|
+
const result = produceToUse(value, (draft) => {
|
3057
3301
|
Object.entries(draft).forEach(([property, oldValue]) => {
|
3058
3302
|
const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
|
3059
3303
|
if (typeof oldValue === "string") {
|
@@ -3160,6 +3404,7 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3160
3404
|
ATTRIBUTE_PLACEHOLDER,
|
3161
3405
|
ApiClientError,
|
3162
3406
|
BatchEntry,
|
3407
|
+
BlockFormatError,
|
3163
3408
|
CANVAS_BLOCK_PARAM_TYPE,
|
3164
3409
|
CANVAS_DRAFT_STATE,
|
3165
3410
|
CANVAS_EDITOR_STATE,
|
@@ -3179,6 +3424,7 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3179
3424
|
CANVAS_TEST_VARIANT_PARAM,
|
3180
3425
|
CANVAS_VIZ_CONTROL_PARAM,
|
3181
3426
|
CANVAS_VIZ_DI_RULE,
|
3427
|
+
CANVAS_VIZ_DYNAMIC_TOKEN_RULE,
|
3182
3428
|
CANVAS_VIZ_LOCALE_RULE,
|
3183
3429
|
CANVAS_VIZ_QUIRKS_RULE,
|
3184
3430
|
CanvasClient,
|
@@ -3224,6 +3470,7 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3224
3470
|
createBatchEnhancer,
|
3225
3471
|
createCanvasChannel,
|
3226
3472
|
createDynamicInputVisibilityRule,
|
3473
|
+
createDynamicTokenVisibilityRule,
|
3227
3474
|
createEventBus,
|
3228
3475
|
createLimitPolicy,
|
3229
3476
|
createLocaleVisibilityRule,
|
@@ -3231,8 +3478,11 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3231
3478
|
createUniformApiEnhancer,
|
3232
3479
|
createVariableReference,
|
3233
3480
|
enhance,
|
3481
|
+
evaluateNodeVisibilityParameter,
|
3482
|
+
evaluatePropertyCriteria,
|
3234
3483
|
evaluateVisibilityCriteriaGroup,
|
3235
|
-
|
3484
|
+
evaluateWalkTreeNodeVisibility,
|
3485
|
+
evaluateWalkTreePropertyCriteria,
|
3236
3486
|
extractLocales,
|
3237
3487
|
findParameterInNodeTree,
|
3238
3488
|
flattenValues,
|
@@ -3248,6 +3498,7 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3248
3498
|
getParameterAttributes,
|
3249
3499
|
getPropertiesValue,
|
3250
3500
|
getPropertyValue,
|
3501
|
+
hasReferencedVariables,
|
3251
3502
|
isAddComponentMessage,
|
3252
3503
|
isAllowedReferrer,
|
3253
3504
|
isAssetParamValue,
|
@@ -3257,6 +3508,7 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3257
3508
|
isContextStorageUpdatedMessage,
|
3258
3509
|
isDismissPlaceholderMessage,
|
3259
3510
|
isEntryData,
|
3511
|
+
isLinkParamValue,
|
3260
3512
|
isMovingComponentMessage,
|
3261
3513
|
isNestedNodeType,
|
3262
3514
|
isOpenParameterEditorMessage,
|