@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.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((acc, [key, value]) => {
466
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
467
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
468
- return {
469
- ...acc,
470
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
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)) continue;
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,77 @@ 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
+
1773
+ // src/enhancement/visibility/evaluatePropertyCriteria.ts
1774
+ function evaluatePropertyCriteria({
1775
+ baseValue,
1776
+ conditionalValues,
1777
+ keepIndeterminate,
1778
+ ...evaluateGroupOptions
1779
+ }) {
1780
+ let authoritative = true;
1781
+ const result = {
1782
+ currentValue: baseValue,
1783
+ remainingConditionalValues: evaluateGroupOptions.simplifyCriteria && conditionalValues ? [...conditionalValues] : conditionalValues,
1784
+ currentConditionIndex: -1
1785
+ };
1786
+ if (!conditionalValues) {
1787
+ return result;
1788
+ }
1789
+ const conditionIndexesToRemove = [];
1790
+ for (let i = 0; i < conditionalValues.length; i++) {
1791
+ const conditionalVariant = conditionalValues[i];
1792
+ if (result.matched) {
1793
+ conditionIndexesToRemove.push(i);
1794
+ continue;
1795
+ }
1796
+ const evaluationResult = evaluateVisibilityCriteriaGroup({
1797
+ ...evaluateGroupOptions,
1798
+ criteriaGroup: conditionalVariant.when
1799
+ });
1800
+ if (evaluationResult === null) {
1801
+ if (keepIndeterminate) {
1802
+ authoritative = false;
1803
+ } else {
1804
+ conditionIndexesToRemove.push(i);
1805
+ }
1806
+ } else if (evaluationResult === true) {
1807
+ result.matched = conditionalVariant;
1808
+ result.currentValue = conditionalVariant.value;
1809
+ result.currentConditionIndex = i;
1810
+ conditionIndexesToRemove.push(i);
1811
+ } else {
1812
+ conditionIndexesToRemove.push(i);
1813
+ }
1814
+ }
1815
+ if (evaluateGroupOptions.simplifyCriteria) {
1816
+ for (let i = conditionIndexesToRemove.length - 1; i >= 0; i--) {
1817
+ result.remainingConditionalValues.splice(conditionIndexesToRemove[i], 1);
1818
+ }
1819
+ }
1820
+ if (authoritative) {
1821
+ result.remainingConditionalValues = void 0;
1822
+ }
1823
+ return result;
1824
+ }
1825
+
1634
1826
  // src/enhancement/visibility/types.ts
1635
1827
  var CANVAS_VIZ_CONTROL_PARAM = "$viz";
1636
1828
 
@@ -1642,24 +1834,18 @@ function evaluateNodeVisibility({
1642
1834
  var _a;
1643
1835
  const properties = getPropertiesValue(node);
1644
1836
  const vizCriteria = (_a = properties == null ? void 0 : properties[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _a.value;
1645
- if (vizCriteria == null ? void 0 : vizCriteria.explicitlyHidden) {
1646
- return false;
1647
- }
1648
- if (!(vizCriteria == null ? void 0 : vizCriteria.criteria)) {
1649
- return true;
1650
- }
1651
- const result = evaluateVisibilityCriteriaGroup({
1837
+ const result = evaluateNodeVisibilityParameter({
1652
1838
  ...evaluateGroupOptions,
1653
- criteriaGroup: vizCriteria.criteria
1839
+ parameter: vizCriteria
1654
1840
  });
1655
- if (vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
1841
+ if ((vizCriteria == null ? void 0 : vizCriteria.criteria) && vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
1656
1842
  properties == null ? true : delete properties[CANVAS_VIZ_CONTROL_PARAM];
1657
1843
  }
1658
1844
  return result;
1659
1845
  }
1660
1846
 
1661
- // src/enhancement/visibility/evaluateWalkTreeVisibility.ts
1662
- function evaluateWalkTreeVisibility({
1847
+ // src/enhancement/visibility/evaluateWalkTreeNodeVisibility.ts
1848
+ function evaluateWalkTreeNodeVisibility({
1663
1849
  rules,
1664
1850
  showIndeterminate,
1665
1851
  context
@@ -1676,6 +1862,77 @@ function evaluateWalkTreeVisibility({
1676
1862
  return true;
1677
1863
  }
1678
1864
 
1865
+ // src/enhancement/visibility/evaluateWalkTreePropertyCriteria.ts
1866
+ function evaluateWalkTreePropertyCriteria({
1867
+ rules,
1868
+ node,
1869
+ keepIndeterminate
1870
+ }) {
1871
+ const properties = getPropertiesValue(node);
1872
+ if (!properties) {
1873
+ return;
1874
+ }
1875
+ Object.entries(properties).forEach(([propertyName, property]) => {
1876
+ var _a, _b, _c;
1877
+ if (property.locales || property.localesConditions) {
1878
+ const localesDefined = [
1879
+ ...Object.keys((_a = property.locales) != null ? _a : {}),
1880
+ ...Object.keys((_b = property.localesConditions) != null ? _b : {})
1881
+ ];
1882
+ localesDefined.forEach((locale) => {
1883
+ var _a2, _b2, _c2, _d, _e, _f;
1884
+ const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
1885
+ baseValue: (_a2 = property.locales) == null ? void 0 : _a2[locale],
1886
+ conditionalValues: (_b2 = property.localesConditions) == null ? void 0 : _b2[locale],
1887
+ rules,
1888
+ simplifyCriteria: true,
1889
+ keepIndeterminate
1890
+ });
1891
+ if (currentValue === null || currentValue === void 0) {
1892
+ (_c2 = property.locales) == null ? true : delete _c2[locale];
1893
+ } else {
1894
+ (_d = property.locales) != null ? _d : property.locales = {};
1895
+ property.locales[locale] = currentValue;
1896
+ }
1897
+ if (!(remainingConditionalValues == null ? void 0 : remainingConditionalValues.length)) {
1898
+ (_e = property.localesConditions) == null ? true : delete _e[locale];
1899
+ } else {
1900
+ (_f = property.localesConditions) != null ? _f : property.localesConditions = {};
1901
+ property.localesConditions[locale] = remainingConditionalValues;
1902
+ }
1903
+ });
1904
+ if (!Object.keys((_c = property.localesConditions) != null ? _c : {}).length) {
1905
+ delete property.localesConditions;
1906
+ }
1907
+ if (!property.locales && !property.localesConditions) {
1908
+ delete properties[propertyName];
1909
+ }
1910
+ } else {
1911
+ const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
1912
+ baseValue: property.value,
1913
+ conditionalValues: property.conditions,
1914
+ rules,
1915
+ simplifyCriteria: true,
1916
+ keepIndeterminate
1917
+ });
1918
+ if (currentValue === null) {
1919
+ delete properties[propertyName];
1920
+ } else {
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;
1931
+ }
1932
+ }
1933
+ });
1934
+ }
1935
+
1679
1936
  // src/enhancement/visibility/rules/evaluateStringMatch.ts
1680
1937
  var isEvaluator = (criteria, matchValue) => {
1681
1938
  if (Array.isArray(criteria)) {
@@ -1753,6 +2010,32 @@ function createDynamicInputVisibilityRule(dynamicInputs) {
1753
2010
  };
1754
2011
  }
1755
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
+
1756
2039
  // src/enhancement/visibility/rules/createLocaleVisibilityRule.ts
1757
2040
  var localeVisibilityOperators = /* @__PURE__ */ new Set(["is", "!is"]);
1758
2041
  var CANVAS_VIZ_LOCALE_RULE = "$locale";
@@ -1815,12 +2098,12 @@ function localize(options) {
1815
2098
  const { type, node, actions } = context;
1816
2099
  if (type !== "component") {
1817
2100
  if (isUsingModernOptions) {
1818
- localizeProperties(node.fields, locale);
2101
+ localizeProperties(node, locale, vizControlLocaleRule);
1819
2102
  }
1820
2103
  return;
1821
2104
  }
1822
2105
  if (isUsingModernOptions) {
1823
- const result = evaluateWalkTreeVisibility({
2106
+ const result = evaluateWalkTreeNodeVisibility({
1824
2107
  context,
1825
2108
  rules: vizControlLocaleRule,
1826
2109
  showIndeterminate: true
@@ -1840,7 +2123,7 @@ function localize(options) {
1840
2123
  replaceComponent.forEach((component) => {
1841
2124
  removeLocaleProperty(component);
1842
2125
  if (isUsingModernOptions) {
1843
- localizeProperties(getPropertiesValue(component), locale);
2126
+ localizeProperties(component, locale, vizControlLocaleRule);
1844
2127
  }
1845
2128
  });
1846
2129
  const [first, ...rest] = replaceComponent;
@@ -1852,7 +2135,7 @@ function localize(options) {
1852
2135
  actions.remove();
1853
2136
  }
1854
2137
  } else if (isUsingModernOptions) {
1855
- localizeProperties(getPropertiesValue(node), locale);
2138
+ localizeProperties(node, locale, vizControlLocaleRule);
1856
2139
  }
1857
2140
  });
1858
2141
  }
@@ -1871,36 +2154,51 @@ function removeLocaleProperty(component) {
1871
2154
  }
1872
2155
  }
1873
2156
  }
1874
- function localizeProperties(properties, locale) {
2157
+ function localizeProperties(node, locale, rules) {
2158
+ const properties = getPropertiesValue(node);
1875
2159
  if (!properties) {
1876
2160
  return void 0;
1877
2161
  }
1878
- Object.entries(properties).forEach(([key, property]) => {
1879
- var _a;
2162
+ Object.entries(properties).forEach(([propertyId, propertyValue]) => {
2163
+ var _a, _b;
1880
2164
  if (!locale) {
1881
- delete property.locales;
2165
+ delete propertyValue.locales;
2166
+ delete propertyValue.localesConditions;
1882
2167
  }
1883
- const currentLocaleValue = locale ? (_a = property.locales) == null ? void 0 : _a[locale] : void 0;
2168
+ const currentLocaleValue = locale ? (_a = propertyValue.locales) == null ? void 0 : _a[locale] : void 0;
1884
2169
  if (currentLocaleValue !== void 0) {
1885
- property.value = currentLocaleValue;
2170
+ propertyValue.value = currentLocaleValue;
1886
2171
  }
1887
- delete property.locales;
1888
- if (property.value === void 0) {
1889
- delete properties[key];
2172
+ const currentLocaleConditionalValues = locale ? (_b = propertyValue.localesConditions) == null ? void 0 : _b[locale] : void 0;
2173
+ if (currentLocaleConditionalValues !== void 0) {
2174
+ propertyValue.conditions = currentLocaleConditionalValues;
1890
2175
  }
2176
+ delete propertyValue.locales;
2177
+ delete propertyValue.localesConditions;
2178
+ if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
2179
+ delete properties[propertyId];
2180
+ }
2181
+ });
2182
+ evaluateWalkTreePropertyCriteria({
2183
+ node,
2184
+ rules,
2185
+ keepIndeterminate: true
1891
2186
  });
1892
2187
  }
1893
2188
 
1894
2189
  // src/enhancement/UniqueBatchEntries.ts
1895
2190
  var UniqueBatchEntries = class {
1896
2191
  constructor(entries, uniqueKeySelector) {
1897
- this.groups = entries.reduce((acc, task) => {
1898
- var _a;
1899
- const key = uniqueKeySelector(task.args);
1900
- acc[key] = (_a = acc[key]) != null ? _a : [];
1901
- acc[key].push(task);
1902
- return acc;
1903
- }, {});
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
+ );
1904
2202
  }
1905
2203
  /** Resolves all entries in a group key with the same result value. */
1906
2204
  resolveKey(key, result) {
@@ -2748,7 +3046,7 @@ var isComponentPlaceholderId = (id) => {
2748
3046
  return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
2749
3047
  };
2750
3048
  var generateComponentPlaceholderId = (randomId, sdkVersion, parent) => {
2751
- if (typeof sdkVersion === "undefined" || sdkVersion === 1) {
3049
+ if (sdkVersion === 1) {
2752
3050
  return PLACEHOLDER_ID;
2753
3051
  }
2754
3052
  let idParts = [PLACEHOLDER_ID, randomId];
@@ -2774,72 +3072,6 @@ var parseComponentPlaceholderId = (id) => {
2774
3072
  return result;
2775
3073
  };
2776
3074
 
2777
- // src/utils/variables/parseVariableExpression.ts
2778
- var escapeCharacter = "\\";
2779
- var variablePrefix = "${";
2780
- var variableSuffix = "}";
2781
- function parseVariableExpression(serialized, onToken) {
2782
- let bufferStartIndex = 0;
2783
- let bufferEndIndex = 0;
2784
- let tokenCount = 0;
2785
- const handleToken = (token, type) => {
2786
- tokenCount++;
2787
- return onToken == null ? void 0 : onToken(token, type);
2788
- };
2789
- let state = "text";
2790
- for (let index = 0; index < serialized.length; index++) {
2791
- const char = serialized[index];
2792
- if (bufferStartIndex > bufferEndIndex) {
2793
- bufferEndIndex = bufferStartIndex;
2794
- }
2795
- if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
2796
- if (serialized[index - 1] === escapeCharacter) {
2797
- bufferEndIndex -= escapeCharacter.length;
2798
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
2799
- return tokenCount;
2800
- }
2801
- bufferStartIndex = index;
2802
- bufferEndIndex = index + 1;
2803
- continue;
2804
- }
2805
- state = "variable";
2806
- if (bufferEndIndex > bufferStartIndex) {
2807
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
2808
- return tokenCount;
2809
- }
2810
- bufferStartIndex = bufferEndIndex;
2811
- }
2812
- index += variablePrefix.length - 1;
2813
- bufferStartIndex += variablePrefix.length;
2814
- continue;
2815
- }
2816
- if (char === variableSuffix && state === "variable") {
2817
- if (serialized[index - 1] === escapeCharacter) {
2818
- bufferEndIndex++;
2819
- continue;
2820
- }
2821
- state = "text";
2822
- if (bufferEndIndex > bufferStartIndex) {
2823
- const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
2824
- if (handleToken(unescapedVariableName, "variable") === false) {
2825
- return tokenCount;
2826
- }
2827
- bufferStartIndex = bufferEndIndex + variableSuffix.length;
2828
- }
2829
- continue;
2830
- }
2831
- bufferEndIndex++;
2832
- }
2833
- if (bufferEndIndex > bufferStartIndex) {
2834
- if (state === "variable") {
2835
- state = "text";
2836
- bufferStartIndex -= variablePrefix.length;
2837
- }
2838
- handleToken(serialized.substring(bufferStartIndex), state);
2839
- }
2840
- return tokenCount;
2841
- }
2842
-
2843
3075
  // src/utils/variables/bindVariables.ts
2844
3076
  function bindVariables({
2845
3077
  variables,
@@ -2877,7 +3109,7 @@ function bindVariables({
2877
3109
  }
2878
3110
 
2879
3111
  // src/utils/variables/bindVariablesToObject.ts
2880
- import { produce } from "immer";
3112
+ import { isDraft, produce } from "immer";
2881
3113
 
2882
3114
  // src/utils/variables/createVariableReference.ts
2883
3115
  function createVariableReference(variableName) {
@@ -2905,7 +3137,11 @@ function bindVariablesToObjectRecursive({
2905
3137
  if (richTextNodeResult !== void 0) {
2906
3138
  return richTextNodeResult;
2907
3139
  }
2908
- const result = produce(value, (draft) => {
3140
+ const produceToUse = !isDraft(value) ? produce : (produceValue, producer) => {
3141
+ producer(produceValue);
3142
+ return produceValue;
3143
+ };
3144
+ const result = produceToUse(value, (draft) => {
2909
3145
  Object.entries(draft).forEach(([property, oldValue]) => {
2910
3146
  const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
2911
3147
  if (typeof oldValue === "string") {
@@ -3011,6 +3247,7 @@ export {
3011
3247
  ATTRIBUTE_PLACEHOLDER,
3012
3248
  ApiClientError2 as ApiClientError,
3013
3249
  BatchEntry,
3250
+ BlockFormatError,
3014
3251
  CANVAS_BLOCK_PARAM_TYPE,
3015
3252
  CANVAS_DRAFT_STATE,
3016
3253
  CANVAS_EDITOR_STATE,
@@ -3030,6 +3267,7 @@ export {
3030
3267
  CANVAS_TEST_VARIANT_PARAM,
3031
3268
  CANVAS_VIZ_CONTROL_PARAM,
3032
3269
  CANVAS_VIZ_DI_RULE,
3270
+ CANVAS_VIZ_DYNAMIC_TOKEN_RULE,
3033
3271
  CANVAS_VIZ_LOCALE_RULE,
3034
3272
  CANVAS_VIZ_QUIRKS_RULE,
3035
3273
  CanvasClient,
@@ -3075,6 +3313,7 @@ export {
3075
3313
  createBatchEnhancer,
3076
3314
  createCanvasChannel,
3077
3315
  createDynamicInputVisibilityRule,
3316
+ createDynamicTokenVisibilityRule,
3078
3317
  createEventBus,
3079
3318
  createLimitPolicy,
3080
3319
  createLocaleVisibilityRule,
@@ -3082,8 +3321,11 @@ export {
3082
3321
  createUniformApiEnhancer,
3083
3322
  createVariableReference,
3084
3323
  enhance,
3324
+ evaluateNodeVisibilityParameter,
3325
+ evaluatePropertyCriteria,
3085
3326
  evaluateVisibilityCriteriaGroup,
3086
- evaluateWalkTreeVisibility,
3327
+ evaluateWalkTreeNodeVisibility,
3328
+ evaluateWalkTreePropertyCriteria,
3087
3329
  extractLocales,
3088
3330
  findParameterInNodeTree,
3089
3331
  flattenValues,
@@ -3099,6 +3341,7 @@ export {
3099
3341
  getParameterAttributes,
3100
3342
  getPropertiesValue,
3101
3343
  getPropertyValue,
3344
+ hasReferencedVariables,
3102
3345
  isAddComponentMessage,
3103
3346
  isAllowedReferrer,
3104
3347
  isAssetParamValue,
@@ -3108,6 +3351,7 @@ export {
3108
3351
  isContextStorageUpdatedMessage,
3109
3352
  isDismissPlaceholderMessage,
3110
3353
  isEntryData,
3354
+ isLinkParamValue,
3111
3355
  isMovingComponentMessage,
3112
3356
  isNestedNodeType,
3113
3357
  isOpenParameterEditorMessage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas",
3
- "version": "19.173.0",
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.16.1",
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.0",
42
- "@uniformdev/context": "19.173.0",
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": "d71596f8829efb4f28ef7213dd9c06421b5cc388"
52
+ "gitHead": "4f0f6ff104f46349c338fde461f063f22f04ce0e"
52
53
  }