@uniformdev/canvas 19.135.0 → 19.135.1-alpha.11

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.esm.js CHANGED
@@ -4,6 +4,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __typeError = (msg) => {
8
+ throw TypeError(msg);
9
+ };
7
10
  var __commonJS = (cb, mod) => function __require() {
8
11
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
12
  };
@@ -23,19 +26,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
26
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
27
  mod
25
28
  ));
26
- var __accessCheck = (obj, member, msg) => {
27
- if (!member.has(obj))
28
- throw TypeError("Cannot " + msg);
29
- };
30
- var __privateGet = (obj, member, getter) => {
31
- __accessCheck(obj, member, "read from private field");
32
- return getter ? getter.call(obj) : member.get(obj);
33
- };
34
- var __privateAdd = (obj, member, value) => {
35
- if (member.has(obj))
36
- throw TypeError("Cannot add the same private member more than once");
37
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
38
- };
29
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
30
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
31
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
39
32
 
40
33
  // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
41
34
  var require_retry_operation = __commonJS({
@@ -466,6 +459,22 @@ function createLimitPolicy({
466
459
  }
467
460
  var nullLimitPolicy = async (func) => await func();
468
461
 
462
+ // src/utils/rewriteFilters.ts
463
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
464
+ function rewriteFilters(filters) {
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
+ );
476
+ }
477
+
469
478
  // src/CanvasClient.ts
470
479
  var CANVAS_URL = "/api/v1/canvas";
471
480
  var CanvasClient = class extends ApiClient {
@@ -482,12 +491,7 @@ var CanvasClient = class extends ApiClient {
482
491
  async getCompositionList(params = {}) {
483
492
  const { projectId } = this.options;
484
493
  const { resolveData, filters, ...originParams } = params;
485
- const rewrittenFilters = Object.entries(filters != null ? filters : {}).reduce((acc, [key, value]) => {
486
- const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
487
- let rhs = typeof value === "object" ? Object.values(value)[0] : value;
488
- rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
489
- return { ...acc, [lhs]: rhs };
490
- }, {});
494
+ const rewrittenFilters = rewriteFilters(filters);
491
495
  if (!resolveData) {
492
496
  const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
493
497
  return this.apiClient(fetchUri);
@@ -651,12 +655,7 @@ var _ContentClient = class _ContentClient extends ApiClient3 {
651
655
  getEntries(options) {
652
656
  const { projectId } = this.options;
653
657
  const { skipDataResolution, filters, ...params } = options;
654
- const rewrittenFilters = Object.entries(filters != null ? filters : {}).reduce((acc, [key, value]) => {
655
- const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
656
- let rhs = typeof value === "object" ? Object.values(value)[0] : value;
657
- rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
658
- return { ...acc, [lhs]: rhs };
659
- }, {});
658
+ const rewrittenFilters = rewriteFilters(filters);
660
659
  if (skipDataResolution) {
661
660
  const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
662
661
  return this.apiClient(url);
@@ -984,6 +983,9 @@ function isAssetParamValueItem(item) {
984
983
  item instanceof Object && "_source" in item && "fields" in item && item.fields instanceof Object && "url" in item.fields && item.fields.url instanceof Object
985
984
  );
986
985
  }
986
+ function isLinkParamValue(value) {
987
+ return typeof value === "object" && value !== null && "type" in value && "path" in value;
988
+ }
987
989
 
988
990
  // src/utils/properties.ts
989
991
  function getPropertiesValue(entity) {
@@ -992,6 +994,21 @@ function getPropertiesValue(entity) {
992
994
  function getPropertyValue(parameter) {
993
995
  return parameter ? parameter.value : parameter;
994
996
  }
997
+ function getLocalizedPropertyValues(parameter) {
998
+ if (!parameter) {
999
+ return parameter;
1000
+ }
1001
+ const localizedValues = /* @__PURE__ */ new Map();
1002
+ if (typeof parameter.value !== "undefined") {
1003
+ localizedValues.set(void 0, parameter.value);
1004
+ }
1005
+ if (parameter.locales !== void 0) {
1006
+ for (const [locale, localeValue] of Object.entries(parameter.locales)) {
1007
+ localizedValues.set(locale, localeValue);
1008
+ }
1009
+ }
1010
+ return localizedValues;
1011
+ }
995
1012
  function flattenValues(data, options = {}) {
996
1013
  if (!data) {
997
1014
  return data;
@@ -1020,6 +1037,86 @@ function flattenSingleNodeValues(data, options = {}) {
1020
1037
  ) : properties;
1021
1038
  }
1022
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
+
1023
1120
  // src/enhancement/walkNodeTree.ts
1024
1121
  function walkNodeTree(node, visitor, options) {
1025
1122
  var _a, _b;
@@ -1032,8 +1129,7 @@ function walkNodeTree(node, visitor, options) {
1032
1129
  const childContexts = /* @__PURE__ */ new Map();
1033
1130
  do {
1034
1131
  const currentQueueEntry = componentQueue.pop();
1035
- if (!currentQueueEntry)
1036
- continue;
1132
+ if (!currentQueueEntry) continue;
1037
1133
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1038
1134
  let visitDescendants = true;
1039
1135
  let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
@@ -1067,6 +1163,7 @@ function walkNodeTree(node, visitor, options) {
1067
1163
  } else {
1068
1164
  throw new Error("Unknown node type");
1069
1165
  }
1166
+ visitDescendants = false;
1070
1167
  },
1071
1168
  insertAfter: (nodes) => {
1072
1169
  const currentNodeInfo = currentQueueEntry.ancestorsAndSelf[0];
@@ -1152,6 +1249,7 @@ function walkNodeTree(node, visitor, options) {
1152
1249
  } else {
1153
1250
  throw new Error("Unknown node type");
1154
1251
  }
1252
+ visitDescendants = false;
1155
1253
  },
1156
1254
  insertAfter: (nodes) => {
1157
1255
  const nodesToInsert = Array.isArray(nodes) ? nodes : [nodes];
@@ -1242,8 +1340,25 @@ function walkNodeTree(node, visitor, options) {
1242
1340
  const propertyEntries = Object.entries(properties);
1243
1341
  for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
1244
1342
  const [propKey, propObject] = propertyEntries[propIndex];
1245
- if (!isNestedNodeType(propObject.type))
1343
+ if (!isNestedNodeType(propObject.type)) {
1344
+ continue;
1345
+ }
1346
+ if (typeof propObject.value === "string" && hasReferencedVariables(propObject.value) > 0) {
1246
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
+ }
1247
1362
  const blocks = (_b = propObject.value) != null ? _b : [];
1248
1363
  for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
1249
1364
  const enqueueingBlock = blocks[blockIndex];
@@ -1279,6 +1394,17 @@ function getBlockValue(component, parameterName) {
1279
1394
  }
1280
1395
  return [];
1281
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
+ };
1282
1408
 
1283
1409
  // src/enhancement/enhance.ts
1284
1410
  async function enhance({
@@ -1588,6 +1714,366 @@ function findParameterInNodeTree(data, predicate) {
1588
1714
  return results;
1589
1715
  }
1590
1716
 
1717
+ // src/enhancement/visibility/evaluateVisibilityCriteriaGroup.ts
1718
+ function evaluateVisibilityCriteriaGroup(options) {
1719
+ const { criteriaGroup, simplifyCriteria } = options;
1720
+ const earlyExitResult = criteriaGroup.op === "&" || !criteriaGroup.op ? false : true;
1721
+ let hasIndeterminateClauses = false;
1722
+ for (let index = criteriaGroup.clauses.length - 1; index >= 0; index--) {
1723
+ const clause = criteriaGroup.clauses[index];
1724
+ const criteriaResult = evaluateCriterion(clause, options);
1725
+ if (criteriaResult === null) {
1726
+ hasIndeterminateClauses = true;
1727
+ } else if (criteriaResult === earlyExitResult) {
1728
+ return earlyExitResult;
1729
+ } else if (criteriaResult !== null && simplifyCriteria) {
1730
+ criteriaGroup.clauses.splice(index, 1);
1731
+ }
1732
+ }
1733
+ return hasIndeterminateClauses ? null : !earlyExitResult;
1734
+ }
1735
+ function evaluateCriterion(clause, rootOptions) {
1736
+ var _a;
1737
+ if ("clauses" in clause) {
1738
+ return evaluateVisibilityCriteriaGroup({
1739
+ ...rootOptions,
1740
+ criteriaGroup: clause
1741
+ });
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
+ }
1748
+ const rule = rootOptions.rules[clause.rule];
1749
+ if (rule) {
1750
+ return rule(clause);
1751
+ }
1752
+ return null;
1753
+ }
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
+
1826
+ // src/enhancement/visibility/types.ts
1827
+ var CANVAS_VIZ_CONTROL_PARAM = "$viz";
1828
+
1829
+ // src/enhancement/visibility/evaluateNodeVisibility.ts
1830
+ function evaluateNodeVisibility({
1831
+ node,
1832
+ ...evaluateGroupOptions
1833
+ }) {
1834
+ var _a;
1835
+ const properties = getPropertiesValue(node);
1836
+ const vizCriteria = (_a = properties == null ? void 0 : properties[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _a.value;
1837
+ const result = evaluateNodeVisibilityParameter({
1838
+ ...evaluateGroupOptions,
1839
+ parameter: vizCriteria
1840
+ });
1841
+ if ((vizCriteria == null ? void 0 : vizCriteria.criteria) && vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
1842
+ properties == null ? true : delete properties[CANVAS_VIZ_CONTROL_PARAM];
1843
+ }
1844
+ return result;
1845
+ }
1846
+
1847
+ // src/enhancement/visibility/evaluateWalkTreeNodeVisibility.ts
1848
+ function evaluateWalkTreeNodeVisibility({
1849
+ rules,
1850
+ showIndeterminate,
1851
+ context
1852
+ }) {
1853
+ const { type, node, actions } = context;
1854
+ if (type !== "component") {
1855
+ return;
1856
+ }
1857
+ const result = evaluateNodeVisibility({ node, rules, simplifyCriteria: true });
1858
+ if (result === null && !showIndeterminate || result === false) {
1859
+ actions.remove();
1860
+ return false;
1861
+ }
1862
+ return true;
1863
+ }
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
+
1936
+ // src/enhancement/visibility/rules/evaluateStringMatch.ts
1937
+ var isEvaluator = (criteria, matchValue) => {
1938
+ if (Array.isArray(criteria)) {
1939
+ return criteria.includes(matchValue);
1940
+ }
1941
+ return criteria === matchValue;
1942
+ };
1943
+ var containsEvaluator = (criteria, matchValue) => {
1944
+ if (Array.isArray(criteria)) {
1945
+ return criteria.some((criterion) => matchValue.includes(criterion));
1946
+ }
1947
+ return matchValue.includes(criteria);
1948
+ };
1949
+ var startsWithEvaluator = (criteria, matchValue) => {
1950
+ if (Array.isArray(criteria)) {
1951
+ return criteria.some((criterion) => matchValue.startsWith(criterion));
1952
+ }
1953
+ return matchValue.startsWith(criteria);
1954
+ };
1955
+ var endsWithEvaluator = (criteria, matchValue) => {
1956
+ if (Array.isArray(criteria)) {
1957
+ return criteria.some((criterion) => matchValue.endsWith(criterion));
1958
+ }
1959
+ return matchValue.endsWith(criteria);
1960
+ };
1961
+ var emptyEvaluator = (_, matchValue) => {
1962
+ return matchValue === "";
1963
+ };
1964
+ var stringOperatorEvaluators = {
1965
+ is: isEvaluator,
1966
+ has: containsEvaluator,
1967
+ startswith: startsWithEvaluator,
1968
+ endswith: endsWithEvaluator,
1969
+ empty: emptyEvaluator
1970
+ };
1971
+ function evaluateStringMatch(criteria, matchValue, allow) {
1972
+ const { op, value } = criteria;
1973
+ if (allow && !allow.has(op)) {
1974
+ return null;
1975
+ }
1976
+ let opMatch = op;
1977
+ const negation = op.startsWith("!");
1978
+ if (negation) {
1979
+ opMatch = opMatch.slice(1);
1980
+ }
1981
+ const evaluator = stringOperatorEvaluators[opMatch];
1982
+ if (!evaluator) {
1983
+ return null;
1984
+ }
1985
+ const result = evaluator(value, matchValue);
1986
+ return negation ? !result : result;
1987
+ }
1988
+
1989
+ // src/enhancement/visibility/rules/createDynamicInputVisibilityRule.ts
1990
+ var dynamicInputVisibilityOperators = /* @__PURE__ */ new Set([
1991
+ "is",
1992
+ "!is",
1993
+ "has",
1994
+ "!has",
1995
+ "startswith",
1996
+ "!startswith",
1997
+ "endswith",
1998
+ "!endswith",
1999
+ "empty",
2000
+ "!empty"
2001
+ ]);
2002
+ var CANVAS_VIZ_DI_RULE = "$di";
2003
+ function createDynamicInputVisibilityRule(dynamicInputs) {
2004
+ return {
2005
+ [CANVAS_VIZ_DI_RULE]: (criterion) => {
2006
+ const { source } = criterion;
2007
+ const diValue = source ? dynamicInputs[source] : void 0;
2008
+ return evaluateStringMatch(criterion, diValue != null ? diValue : "", dynamicInputVisibilityOperators);
2009
+ }
2010
+ };
2011
+ }
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
+
2039
+ // src/enhancement/visibility/rules/createLocaleVisibilityRule.ts
2040
+ var localeVisibilityOperators = /* @__PURE__ */ new Set(["is", "!is"]);
2041
+ var CANVAS_VIZ_LOCALE_RULE = "$locale";
2042
+ function createLocaleVisibilityRule(currentLocale) {
2043
+ return {
2044
+ [CANVAS_VIZ_LOCALE_RULE]: (criterion) => {
2045
+ if (!currentLocale) {
2046
+ return false;
2047
+ }
2048
+ return evaluateStringMatch(criterion, currentLocale, localeVisibilityOperators);
2049
+ }
2050
+ };
2051
+ }
2052
+
2053
+ // src/enhancement/visibility/rules/createQuirksVisibilityRule.ts
2054
+ var quirksVisibilityOperators = /* @__PURE__ */ new Set([
2055
+ "is",
2056
+ "!is",
2057
+ "has",
2058
+ "!has",
2059
+ "startswith",
2060
+ "!startswith",
2061
+ "endswith",
2062
+ "!endswith",
2063
+ "empty",
2064
+ "!empty"
2065
+ ]);
2066
+ var CANVAS_VIZ_QUIRKS_RULE = "$qk";
2067
+ function createQuirksVisibilityRule(quirks) {
2068
+ return {
2069
+ [CANVAS_VIZ_QUIRKS_RULE]: (criterion) => {
2070
+ const { source } = criterion;
2071
+ const quirkValue = source ? quirks[source] : void 0;
2072
+ return evaluateStringMatch(criterion, quirkValue != null ? quirkValue : "", quirksVisibilityOperators);
2073
+ }
2074
+ };
2075
+ }
2076
+
1591
2077
  // src/enhancement/localize.ts
1592
2078
  function extractLocales({ component }) {
1593
2079
  var _a;
@@ -1606,17 +2092,29 @@ function extractLocales({ component }) {
1606
2092
  function localize(options) {
1607
2093
  const nodes = "nodes" in options ? options.nodes : options.composition;
1608
2094
  const locale = options.locale;
1609
- walkNodeTree(nodes, ({ type, node, actions }) => {
2095
+ const isUsingModernOptions = typeof locale === "string";
2096
+ const vizControlLocaleRule = isUsingModernOptions ? createLocaleVisibilityRule(locale) : {};
2097
+ walkNodeTree(nodes, (context) => {
2098
+ const { type, node, actions } = context;
1610
2099
  if (type !== "component") {
1611
- if (typeof locale === "string") {
1612
- localizeProperties(node.fields, locale);
2100
+ if (isUsingModernOptions) {
2101
+ localizeProperties(node, locale, vizControlLocaleRule);
1613
2102
  }
1614
2103
  return;
1615
2104
  }
1616
- const shouldRunPropertyLocalization = typeof locale === "string";
2105
+ if (isUsingModernOptions) {
2106
+ const result = evaluateWalkTreeNodeVisibility({
2107
+ context,
2108
+ rules: vizControlLocaleRule,
2109
+ showIndeterminate: true
2110
+ });
2111
+ if (!result) {
2112
+ return;
2113
+ }
2114
+ }
1617
2115
  if (node.type === CANVAS_LOCALIZATION_TYPE) {
1618
2116
  const locales = extractLocales({ component: node });
1619
- const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
2117
+ const resolvedLocale = isUsingModernOptions ? locale : locale == null ? void 0 : locale({ component: node, locales });
1620
2118
  let replaceComponent;
1621
2119
  if (resolvedLocale) {
1622
2120
  replaceComponent = locales[resolvedLocale];
@@ -1624,8 +2122,8 @@ function localize(options) {
1624
2122
  if (replaceComponent == null ? void 0 : replaceComponent.length) {
1625
2123
  replaceComponent.forEach((component) => {
1626
2124
  removeLocaleProperty(component);
1627
- if (shouldRunPropertyLocalization) {
1628
- localizeProperties(getPropertiesValue(component), locale);
2125
+ if (isUsingModernOptions) {
2126
+ localizeProperties(component, locale, vizControlLocaleRule);
1629
2127
  }
1630
2128
  });
1631
2129
  const [first, ...rest] = replaceComponent;
@@ -1636,8 +2134,8 @@ function localize(options) {
1636
2134
  } else {
1637
2135
  actions.remove();
1638
2136
  }
1639
- } else if (shouldRunPropertyLocalization) {
1640
- localizeProperties(getPropertiesValue(node), locale);
2137
+ } else if (isUsingModernOptions) {
2138
+ localizeProperties(node, locale, vizControlLocaleRule);
1641
2139
  }
1642
2140
  });
1643
2141
  }
@@ -1656,36 +2154,51 @@ function removeLocaleProperty(component) {
1656
2154
  }
1657
2155
  }
1658
2156
  }
1659
- function localizeProperties(properties, locale) {
2157
+ function localizeProperties(node, locale, rules) {
2158
+ const properties = getPropertiesValue(node);
1660
2159
  if (!properties) {
1661
2160
  return void 0;
1662
2161
  }
1663
- Object.entries(properties).forEach(([key, property]) => {
1664
- var _a;
2162
+ Object.entries(properties).forEach(([propertyId, propertyValue]) => {
2163
+ var _a, _b;
1665
2164
  if (!locale) {
1666
- delete property.locales;
2165
+ delete propertyValue.locales;
2166
+ delete propertyValue.localesConditions;
1667
2167
  }
1668
- 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;
1669
2169
  if (currentLocaleValue !== void 0) {
1670
- property.value = currentLocaleValue;
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;
1671
2175
  }
1672
- delete property.locales;
1673
- if (property.value === void 0) {
1674
- delete properties[key];
2176
+ delete propertyValue.locales;
2177
+ delete propertyValue.localesConditions;
2178
+ if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
2179
+ delete properties[propertyId];
1675
2180
  }
1676
2181
  });
2182
+ evaluateWalkTreePropertyCriteria({
2183
+ node,
2184
+ rules,
2185
+ keepIndeterminate: true
2186
+ });
1677
2187
  }
1678
2188
 
1679
2189
  // src/enhancement/UniqueBatchEntries.ts
1680
2190
  var UniqueBatchEntries = class {
1681
2191
  constructor(entries, uniqueKeySelector) {
1682
- this.groups = entries.reduce((acc, task) => {
1683
- var _a;
1684
- const key = uniqueKeySelector(task.args);
1685
- acc[key] = (_a = acc[key]) != null ? _a : [];
1686
- acc[key].push(task);
1687
- return acc;
1688
- }, {});
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
+ );
1689
2202
  }
1690
2203
  /** Resolves all entries in a group key with the same result value. */
1691
2204
  resolveKey(key, result) {
@@ -1715,8 +2228,7 @@ function walkComponentTree(component, visitor, initialContext) {
1715
2228
  const childContexts = /* @__PURE__ */ new Map();
1716
2229
  do {
1717
2230
  const currentQueueEntry = componentQueue.pop();
1718
- if (!currentQueueEntry)
1719
- continue;
2231
+ if (!currentQueueEntry) continue;
1720
2232
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1721
2233
  let visitDescendants = true;
1722
2234
  let descendantContext = (_a = childContexts.get(currentComponent.component)) != null ? _a : currentQueueEntry.context;
@@ -1821,10 +2333,25 @@ function walkComponentTree(component, visitor, initialContext) {
1821
2333
  } while (componentQueue.length > 0);
1822
2334
  }
1823
2335
 
1824
- // src/LocaleClient.ts
2336
+ // src/EntityReleasesClient.ts
1825
2337
  import { ApiClient as ApiClient6 } from "@uniformdev/context/api";
2338
+ var releaseContentsUrl = "/api/v1/entity-releases";
2339
+ var EntityReleasesClient = class extends ApiClient6 {
2340
+ constructor(options) {
2341
+ super(options);
2342
+ }
2343
+ /** Fetches entity across all releases (and base) */
2344
+ async get(options) {
2345
+ const { projectId } = this.options;
2346
+ const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
2347
+ return await this.apiClient(fetchUri);
2348
+ }
2349
+ };
2350
+
2351
+ // src/LocaleClient.ts
2352
+ import { ApiClient as ApiClient7 } from "@uniformdev/context/api";
1826
2353
  var localesUrl = "/api/v1/locales";
1827
- var LocaleClient = class extends ApiClient6 {
2354
+ var LocaleClient = class extends ApiClient7 {
1828
2355
  constructor(options) {
1829
2356
  super(options);
1830
2357
  }
@@ -1930,6 +2457,9 @@ var isRequestComponentSuggestionMessage = (message) => {
1930
2457
  var isSuggestComponentMessage = (message) => {
1931
2458
  return message.type === "suggest-component";
1932
2459
  };
2460
+ var isContextStorageUpdatedMessage = (message) => {
2461
+ return message.type === "context-storage-command-executed";
2462
+ };
1933
2463
  var createCanvasChannel = ({
1934
2464
  listenTo,
1935
2465
  broadcastTo
@@ -1939,6 +2469,12 @@ var createCanvasChannel = ({
1939
2469
  const broadcastToItems = [...broadcastTo];
1940
2470
  const postMessage = (message) => {
1941
2471
  broadcastToItems.forEach((item) => item == null ? void 0 : item.postMessage(JSON.stringify(message), "*"));
2472
+ for (const handlerId in handlers) {
2473
+ const handler = handlers[handlerId];
2474
+ if (handler.types.includes(message.type)) {
2475
+ handler.handler(message, new MessageEvent(message.type));
2476
+ }
2477
+ }
1942
2478
  };
1943
2479
  const selectComponent = (id) => {
1944
2480
  const message = {
@@ -1979,15 +2515,17 @@ var createCanvasChannel = ({
1979
2515
  hash: generateHash({
1980
2516
  composition,
1981
2517
  secret
1982
- })
2518
+ }),
2519
+ eventTimestamp: Date.now()
1983
2520
  };
1984
2521
  postMessage(message);
1985
2522
  };
1986
- const updateCompositionInternal = (composition, hash) => {
2523
+ const updateCompositionInternal = (composition, hash, eventTimestamp) => {
1987
2524
  const message = {
1988
2525
  type: "update-composition-internal",
1989
2526
  composition,
1990
- hash
2527
+ hash,
2528
+ eventTimestamp: eventTimestamp != null ? eventTimestamp : Date.now()
1991
2529
  };
1992
2530
  postMessage(message);
1993
2531
  };
@@ -2102,6 +2640,13 @@ var createCanvasChannel = ({
2102
2640
  };
2103
2641
  postMessage(message);
2104
2642
  };
2643
+ const contextStorageUpdated = (options) => {
2644
+ const message = {
2645
+ ...options,
2646
+ type: "context-storage-command-executed"
2647
+ };
2648
+ postMessage(message);
2649
+ };
2105
2650
  const messageEventListener = (event) => {
2106
2651
  if (typeof event.data !== "string") {
2107
2652
  return;
@@ -2129,6 +2674,7 @@ var createCanvasChannel = ({
2129
2674
  listenTo.forEach((item) => item.removeEventListener("message", messageEventListener));
2130
2675
  };
2131
2676
  return {
2677
+ broadcastTo,
2132
2678
  ready,
2133
2679
  destroy,
2134
2680
  triggerComponentAction,
@@ -2150,7 +2696,8 @@ var createCanvasChannel = ({
2150
2696
  editorStateUpdated,
2151
2697
  updateComponentReferences,
2152
2698
  requestComponentSuggestion,
2153
- suggestComponent
2699
+ suggestComponent,
2700
+ contextStorageUpdated
2154
2701
  };
2155
2702
  };
2156
2703
 
@@ -2233,9 +2780,9 @@ function subscribeToComposition({
2233
2780
  }
2234
2781
 
2235
2782
  // src/PromptClient.ts
2236
- import { ApiClient as ApiClient7 } from "@uniformdev/context/api";
2783
+ import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
2237
2784
  var PromptsUrl = "/api/v1/prompts";
2238
- var PromptClient = class extends ApiClient7 {
2785
+ var PromptClient = class extends ApiClient8 {
2239
2786
  constructor(options) {
2240
2787
  super(options);
2241
2788
  }
@@ -2266,9 +2813,9 @@ var PromptClient = class extends ApiClient7 {
2266
2813
  };
2267
2814
 
2268
2815
  // src/RelationshipClient.ts
2269
- import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
2816
+ import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
2270
2817
  var RELATIONSHIPS_URL = "/api/v1/relationships";
2271
- var RelationshipClient = class extends ApiClient8 {
2818
+ var RelationshipClient = class extends ApiClient9 {
2272
2819
  constructor(options) {
2273
2820
  super(options);
2274
2821
  this.get = async (options) => {
@@ -2276,56 +2823,13 @@ var RelationshipClient = class extends ApiClient8 {
2276
2823
  const url = this.createUrl(RELATIONSHIPS_URL, { ...options, projectId });
2277
2824
  return this.apiClient(url);
2278
2825
  };
2279
- this.clearProjectRelationships = async () => {
2280
- const { projectId } = this.options;
2281
- const url = this.createUrl(RELATIONSHIPS_URL);
2282
- return this.apiClient(url, {
2283
- method: "POST",
2284
- body: JSON.stringify({
2285
- action: "clear",
2286
- projectId
2287
- })
2288
- });
2289
- };
2290
- this.indexRelationships = async ({ state, id, type }) => {
2291
- const { projectId } = this.options;
2292
- const url = this.createUrl(RELATIONSHIPS_URL);
2293
- return this.apiClient(url, {
2294
- method: "POST",
2295
- body: JSON.stringify({
2296
- action: "index",
2297
- type,
2298
- projectId,
2299
- state,
2300
- id
2301
- })
2302
- });
2303
- };
2304
- this.getVersion = async () => {
2305
- const { projectId } = this.options;
2306
- const url = this.createUrl("/api/v1/usage-tracking", {
2307
- projectId
2308
- });
2309
- return this.apiClient(url).then((response) => response.version);
2310
- };
2311
- this.setVersion = async (version) => {
2312
- const { projectId } = this.options;
2313
- const url = this.createUrl("/api/v1/usage-tracking");
2314
- return this.apiClient(url, {
2315
- method: "POST",
2316
- body: JSON.stringify({
2317
- projectId,
2318
- version
2319
- })
2320
- });
2321
- };
2322
2826
  }
2323
2827
  };
2324
2828
 
2325
2829
  // src/ReleaseClient.ts
2326
- import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
2830
+ import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
2327
2831
  var releasesUrl = "/api/v1/releases";
2328
- var ReleaseClient = class extends ApiClient9 {
2832
+ var ReleaseClient = class extends ApiClient10 {
2329
2833
  constructor(options) {
2330
2834
  super(options);
2331
2835
  }
@@ -2365,21 +2869,21 @@ var ReleaseClient = class extends ApiClient9 {
2365
2869
  };
2366
2870
 
2367
2871
  // src/ReleaseContentsClient.ts
2368
- import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
2369
- var releaseContentsUrl = "/api/v1/release-contents";
2370
- var ReleaseContentsClient = class extends ApiClient10 {
2872
+ import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
2873
+ var releaseContentsUrl2 = "/api/v1/release-contents";
2874
+ var ReleaseContentsClient = class extends ApiClient11 {
2371
2875
  constructor(options) {
2372
2876
  super(options);
2373
2877
  }
2374
2878
  /** Fetches all entities added to a release */
2375
2879
  async get(options) {
2376
2880
  const { projectId } = this.options;
2377
- const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
2881
+ const fetchUri = this.createUrl(releaseContentsUrl2, { ...options, projectId });
2378
2882
  return await this.apiClient(fetchUri);
2379
2883
  }
2380
2884
  /** Removes a release content from a release */
2381
2885
  async remove(body) {
2382
- const fetchUri = this.createUrl(releaseContentsUrl);
2886
+ const fetchUri = this.createUrl(releaseContentsUrl2);
2383
2887
  await this.apiClient(fetchUri, {
2384
2888
  method: "DELETE",
2385
2889
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -2389,9 +2893,9 @@ var ReleaseContentsClient = class extends ApiClient10 {
2389
2893
  };
2390
2894
 
2391
2895
  // src/RouteClient.ts
2392
- import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
2896
+ import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
2393
2897
  var ROUTE_URL = "/api/v1/route";
2394
- var RouteClient = class extends ApiClient11 {
2898
+ var RouteClient = class extends ApiClient12 {
2395
2899
  constructor(options) {
2396
2900
  var _a;
2397
2901
  if (!options.limitPolicy) {
@@ -2454,7 +2958,9 @@ function convertEntryToPutEntry(entry) {
2454
2958
  pattern: entry.pattern,
2455
2959
  state: entry.state,
2456
2960
  projectId: entry.projectId,
2457
- releaseId: entry.releaseId
2961
+ releaseId: entry.releaseId,
2962
+ workflowId: entry.workflowId,
2963
+ workflowStageId: entry.workflowStageId
2458
2964
  };
2459
2965
  }
2460
2966
 
@@ -2500,8 +3006,7 @@ var isSystemComponentDefinition = (componentType) => {
2500
3006
 
2501
3007
  // src/utils/mapSlotToPersonalizedVariations.ts
2502
3008
  function mapSlotToPersonalizedVariations(slot) {
2503
- if (!slot)
2504
- return [];
3009
+ if (!slot) return [];
2505
3010
  return slot.map((v, i) => {
2506
3011
  var _a, _b;
2507
3012
  const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b.value;
@@ -2516,8 +3021,7 @@ function mapSlotToPersonalizedVariations(slot) {
2516
3021
 
2517
3022
  // src/utils/mapSlotToTestVariations.ts
2518
3023
  function mapSlotToTestVariations(slot) {
2519
- if (!slot)
2520
- return [];
3024
+ if (!slot) return [];
2521
3025
  return slot.map((v, i) => {
2522
3026
  var _a, _b, _c;
2523
3027
  const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b.value;
@@ -2542,7 +3046,7 @@ var isComponentPlaceholderId = (id) => {
2542
3046
  return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
2543
3047
  };
2544
3048
  var generateComponentPlaceholderId = (randomId, sdkVersion, parent) => {
2545
- if (typeof sdkVersion === "undefined" || sdkVersion === 1) {
3049
+ if (sdkVersion === 1) {
2546
3050
  return PLACEHOLDER_ID;
2547
3051
  }
2548
3052
  let idParts = [PLACEHOLDER_ID, randomId];
@@ -2568,72 +3072,6 @@ var parseComponentPlaceholderId = (id) => {
2568
3072
  return result;
2569
3073
  };
2570
3074
 
2571
- // src/utils/variables/parseVariableExpression.ts
2572
- var escapeCharacter = "\\";
2573
- var variablePrefix = "${";
2574
- var variableSuffix = "}";
2575
- function parseVariableExpression(serialized, onToken) {
2576
- let bufferStartIndex = 0;
2577
- let bufferEndIndex = 0;
2578
- let tokenCount = 0;
2579
- const handleToken = (token, type) => {
2580
- tokenCount++;
2581
- return onToken == null ? void 0 : onToken(token, type);
2582
- };
2583
- let state = "text";
2584
- for (let index = 0; index < serialized.length; index++) {
2585
- const char = serialized[index];
2586
- if (bufferStartIndex > bufferEndIndex) {
2587
- bufferEndIndex = bufferStartIndex;
2588
- }
2589
- if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
2590
- if (serialized[index - 1] === escapeCharacter) {
2591
- bufferEndIndex -= escapeCharacter.length;
2592
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
2593
- return tokenCount;
2594
- }
2595
- bufferStartIndex = index;
2596
- bufferEndIndex = index + 1;
2597
- continue;
2598
- }
2599
- state = "variable";
2600
- if (bufferEndIndex > bufferStartIndex) {
2601
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
2602
- return tokenCount;
2603
- }
2604
- bufferStartIndex = bufferEndIndex;
2605
- }
2606
- index += variablePrefix.length - 1;
2607
- bufferStartIndex += variablePrefix.length;
2608
- continue;
2609
- }
2610
- if (char === variableSuffix && state === "variable") {
2611
- if (serialized[index - 1] === escapeCharacter) {
2612
- bufferEndIndex++;
2613
- continue;
2614
- }
2615
- state = "text";
2616
- if (bufferEndIndex > bufferStartIndex) {
2617
- const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
2618
- if (handleToken(unescapedVariableName, "variable") === false) {
2619
- return tokenCount;
2620
- }
2621
- bufferStartIndex = bufferEndIndex + variableSuffix.length;
2622
- }
2623
- continue;
2624
- }
2625
- bufferEndIndex++;
2626
- }
2627
- if (bufferEndIndex > bufferStartIndex) {
2628
- if (state === "variable") {
2629
- state = "text";
2630
- bufferStartIndex -= variablePrefix.length;
2631
- }
2632
- handleToken(serialized.substring(bufferStartIndex), state);
2633
- }
2634
- return tokenCount;
2635
- }
2636
-
2637
3075
  // src/utils/variables/bindVariables.ts
2638
3076
  function bindVariables({
2639
3077
  variables,
@@ -2671,7 +3109,7 @@ function bindVariables({
2671
3109
  }
2672
3110
 
2673
3111
  // src/utils/variables/bindVariablesToObject.ts
2674
- import { produce } from "immer";
3112
+ import { isDraft, produce } from "immer";
2675
3113
 
2676
3114
  // src/utils/variables/createVariableReference.ts
2677
3115
  function createVariableReference(variableName) {
@@ -2699,7 +3137,11 @@ function bindVariablesToObjectRecursive({
2699
3137
  if (richTextNodeResult !== void 0) {
2700
3138
  return richTextNodeResult;
2701
3139
  }
2702
- 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) => {
2703
3145
  Object.entries(draft).forEach(([property, oldValue]) => {
2704
3146
  const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
2705
3147
  if (typeof oldValue === "string") {
@@ -2757,6 +3199,41 @@ function handleRichTextNodeBinding(object, options) {
2757
3199
 
2758
3200
  // src/index.ts
2759
3201
  import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
3202
+
3203
+ // src/WorkflowClient.ts
3204
+ import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
3205
+ var workflowsUrl = "/api/v1/workflows";
3206
+ var WorkflowClient = class extends ApiClient13 {
3207
+ constructor(options) {
3208
+ super(options);
3209
+ }
3210
+ /** Fetches workflows for a project */
3211
+ async get(options) {
3212
+ const { projectId } = this.options;
3213
+ const fetchUri = this.createUrl(workflowsUrl, { ...options, projectId });
3214
+ return await this.apiClient(fetchUri);
3215
+ }
3216
+ /** Updates or creates a workflow definition */
3217
+ async upsert(body) {
3218
+ const fetchUri = this.createUrl(workflowsUrl);
3219
+ await this.apiClient(fetchUri, {
3220
+ method: "PUT",
3221
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
3222
+ expectNoContent: true
3223
+ });
3224
+ }
3225
+ /** Deletes a workflow definition */
3226
+ async remove(body) {
3227
+ const fetchUri = this.createUrl(workflowsUrl);
3228
+ await this.apiClient(fetchUri, {
3229
+ method: "DELETE",
3230
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
3231
+ expectNoContent: true
3232
+ });
3233
+ }
3234
+ };
3235
+
3236
+ // src/index.ts
2760
3237
  var CanvasClientError = ApiClientError2;
2761
3238
  export {
2762
3239
  ASSETS_SOURCE_CUSTOM_URL,
@@ -2770,6 +3247,7 @@ export {
2770
3247
  ATTRIBUTE_PLACEHOLDER,
2771
3248
  ApiClientError2 as ApiClientError,
2772
3249
  BatchEntry,
3250
+ BlockFormatError,
2773
3251
  CANVAS_BLOCK_PARAM_TYPE,
2774
3252
  CANVAS_DRAFT_STATE,
2775
3253
  CANVAS_EDITOR_STATE,
@@ -2787,6 +3265,11 @@ export {
2787
3265
  CANVAS_TEST_SLOT,
2788
3266
  CANVAS_TEST_TYPE,
2789
3267
  CANVAS_TEST_VARIANT_PARAM,
3268
+ CANVAS_VIZ_CONTROL_PARAM,
3269
+ CANVAS_VIZ_DI_RULE,
3270
+ CANVAS_VIZ_DYNAMIC_TOKEN_RULE,
3271
+ CANVAS_VIZ_LOCALE_RULE,
3272
+ CANVAS_VIZ_QUIRKS_RULE,
2790
3273
  CanvasClient,
2791
3274
  CanvasClientError,
2792
3275
  CategoryClient,
@@ -2800,6 +3283,7 @@ export {
2800
3283
  EDGE_MIN_CACHE_TTL,
2801
3284
  EMPTY_COMPOSITION,
2802
3285
  EnhancerBuilder,
3286
+ EntityReleasesClient,
2803
3287
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
2804
3288
  IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
2805
3289
  IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
@@ -2821,17 +3305,27 @@ export {
2821
3305
  UncachedCategoryClient,
2822
3306
  UncachedContentClient,
2823
3307
  UniqueBatchEntries,
3308
+ WorkflowClient,
2824
3309
  bindVariables,
2825
3310
  bindVariablesToObject,
2826
3311
  compose,
2827
3312
  convertEntryToPutEntry,
2828
3313
  createBatchEnhancer,
2829
3314
  createCanvasChannel,
3315
+ createDynamicInputVisibilityRule,
3316
+ createDynamicTokenVisibilityRule,
2830
3317
  createEventBus,
2831
3318
  createLimitPolicy,
3319
+ createLocaleVisibilityRule,
3320
+ createQuirksVisibilityRule,
2832
3321
  createUniformApiEnhancer,
2833
3322
  createVariableReference,
2834
3323
  enhance,
3324
+ evaluateNodeVisibilityParameter,
3325
+ evaluatePropertyCriteria,
3326
+ evaluateVisibilityCriteriaGroup,
3327
+ evaluateWalkTreeNodeVisibility,
3328
+ evaluateWalkTreePropertyCriteria,
2835
3329
  extractLocales,
2836
3330
  findParameterInNodeTree,
2837
3331
  flattenValues,
@@ -2841,19 +3335,23 @@ export {
2841
3335
  getChannelName,
2842
3336
  getComponentJsonPointer,
2843
3337
  getComponentPath,
3338
+ getLocalizedPropertyValues,
2844
3339
  getNounForLocation,
2845
3340
  getNounForNode,
2846
3341
  getParameterAttributes,
2847
3342
  getPropertiesValue,
2848
3343
  getPropertyValue,
3344
+ hasReferencedVariables,
2849
3345
  isAddComponentMessage,
2850
3346
  isAllowedReferrer,
2851
3347
  isAssetParamValue,
2852
3348
  isAssetParamValueItem,
2853
3349
  isComponentActionMessage,
2854
3350
  isComponentPlaceholderId,
3351
+ isContextStorageUpdatedMessage,
2855
3352
  isDismissPlaceholderMessage,
2856
3353
  isEntryData,
3354
+ isLinkParamValue,
2857
3355
  isMovingComponentMessage,
2858
3356
  isNestedNodeType,
2859
3357
  isOpenParameterEditorMessage,