@uniformdev/canvas 19.135.1-alpha.10 → 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.js CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
8
11
  var __commonJS = (cb, mod) => function __require() {
9
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
13
  };
@@ -29,19 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
32
  mod
30
33
  ));
31
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
- var __accessCheck = (obj, member, msg) => {
33
- if (!member.has(obj))
34
- throw TypeError("Cannot " + msg);
35
- };
36
- var __privateGet = (obj, member, getter) => {
37
- __accessCheck(obj, member, "read from private field");
38
- return getter ? getter.call(obj) : member.get(obj);
39
- };
40
- var __privateAdd = (obj, member, value) => {
41
- if (member.has(obj))
42
- throw TypeError("Cannot add the same private member more than once");
43
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
44
- };
35
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
36
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
37
+ 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);
45
38
 
46
39
  // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
47
40
  var require_retry_operation = __commonJS({
@@ -286,8 +279,9 @@ __export(src_exports, {
286
279
  ATTRIBUTE_PARAMETER_TYPE: () => ATTRIBUTE_PARAMETER_TYPE,
287
280
  ATTRIBUTE_PARAMETER_VALUE: () => ATTRIBUTE_PARAMETER_VALUE,
288
281
  ATTRIBUTE_PLACEHOLDER: () => ATTRIBUTE_PLACEHOLDER,
289
- ApiClientError: () => import_api14.ApiClientError,
282
+ ApiClientError: () => import_api15.ApiClientError,
290
283
  BatchEntry: () => BatchEntry,
284
+ BlockFormatError: () => BlockFormatError,
291
285
  CANVAS_BLOCK_PARAM_TYPE: () => CANVAS_BLOCK_PARAM_TYPE,
292
286
  CANVAS_DRAFT_STATE: () => CANVAS_DRAFT_STATE,
293
287
  CANVAS_EDITOR_STATE: () => CANVAS_EDITOR_STATE,
@@ -305,6 +299,11 @@ __export(src_exports, {
305
299
  CANVAS_TEST_SLOT: () => CANVAS_TEST_SLOT,
306
300
  CANVAS_TEST_TYPE: () => CANVAS_TEST_TYPE,
307
301
  CANVAS_TEST_VARIANT_PARAM: () => CANVAS_TEST_VARIANT_PARAM,
302
+ CANVAS_VIZ_CONTROL_PARAM: () => CANVAS_VIZ_CONTROL_PARAM,
303
+ CANVAS_VIZ_DI_RULE: () => CANVAS_VIZ_DI_RULE,
304
+ CANVAS_VIZ_DYNAMIC_TOKEN_RULE: () => CANVAS_VIZ_DYNAMIC_TOKEN_RULE,
305
+ CANVAS_VIZ_LOCALE_RULE: () => CANVAS_VIZ_LOCALE_RULE,
306
+ CANVAS_VIZ_QUIRKS_RULE: () => CANVAS_VIZ_QUIRKS_RULE,
308
307
  CanvasClient: () => CanvasClient,
309
308
  CanvasClientError: () => CanvasClientError,
310
309
  CategoryClient: () => CategoryClient,
@@ -318,6 +317,7 @@ __export(src_exports, {
318
317
  EDGE_MIN_CACHE_TTL: () => EDGE_MIN_CACHE_TTL,
319
318
  EMPTY_COMPOSITION: () => EMPTY_COMPOSITION,
320
319
  EnhancerBuilder: () => EnhancerBuilder,
320
+ EntityReleasesClient: () => EntityReleasesClient,
321
321
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE: () => IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
322
322
  IN_CONTEXT_EDITOR_COMPONENT_START_ROLE: () => IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
323
323
  IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM: () => IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
@@ -346,11 +346,20 @@ __export(src_exports, {
346
346
  convertEntryToPutEntry: () => convertEntryToPutEntry,
347
347
  createBatchEnhancer: () => createBatchEnhancer,
348
348
  createCanvasChannel: () => createCanvasChannel,
349
+ createDynamicInputVisibilityRule: () => createDynamicInputVisibilityRule,
350
+ createDynamicTokenVisibilityRule: () => createDynamicTokenVisibilityRule,
349
351
  createEventBus: () => createEventBus,
350
352
  createLimitPolicy: () => createLimitPolicy,
353
+ createLocaleVisibilityRule: () => createLocaleVisibilityRule,
354
+ createQuirksVisibilityRule: () => createQuirksVisibilityRule,
351
355
  createUniformApiEnhancer: () => createUniformApiEnhancer,
352
356
  createVariableReference: () => createVariableReference,
353
357
  enhance: () => enhance,
358
+ evaluateNodeVisibilityParameter: () => evaluateNodeVisibilityParameter,
359
+ evaluatePropertyCriteria: () => evaluatePropertyCriteria,
360
+ evaluateVisibilityCriteriaGroup: () => evaluateVisibilityCriteriaGroup,
361
+ evaluateWalkTreeNodeVisibility: () => evaluateWalkTreeNodeVisibility,
362
+ evaluateWalkTreePropertyCriteria: () => evaluateWalkTreePropertyCriteria,
354
363
  extractLocales: () => extractLocales,
355
364
  findParameterInNodeTree: () => findParameterInNodeTree,
356
365
  flattenValues: () => flattenValues,
@@ -366,14 +375,17 @@ __export(src_exports, {
366
375
  getParameterAttributes: () => getParameterAttributes,
367
376
  getPropertiesValue: () => getPropertiesValue,
368
377
  getPropertyValue: () => getPropertyValue,
378
+ hasReferencedVariables: () => hasReferencedVariables,
369
379
  isAddComponentMessage: () => isAddComponentMessage,
370
380
  isAllowedReferrer: () => isAllowedReferrer,
371
381
  isAssetParamValue: () => isAssetParamValue,
372
382
  isAssetParamValueItem: () => isAssetParamValueItem,
373
383
  isComponentActionMessage: () => isComponentActionMessage,
374
384
  isComponentPlaceholderId: () => isComponentPlaceholderId,
385
+ isContextStorageUpdatedMessage: () => isContextStorageUpdatedMessage,
375
386
  isDismissPlaceholderMessage: () => isDismissPlaceholderMessage,
376
387
  isEntryData: () => isEntryData,
388
+ isLinkParamValue: () => isLinkParamValue,
377
389
  isMovingComponentMessage: () => isMovingComponentMessage,
378
390
  isNestedNodeType: () => isNestedNodeType,
379
391
  isOpenParameterEditorMessage: () => isOpenParameterEditorMessage,
@@ -603,6 +615,22 @@ function createLimitPolicy({
603
615
  }
604
616
  var nullLimitPolicy = async (func) => await func();
605
617
 
618
+ // src/utils/rewriteFilters.ts
619
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
620
+ function rewriteFilters(filters) {
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
+ );
632
+ }
633
+
606
634
  // src/CanvasClient.ts
607
635
  var CANVAS_URL = "/api/v1/canvas";
608
636
  var CanvasClient = class extends import_api2.ApiClient {
@@ -619,12 +647,7 @@ var CanvasClient = class extends import_api2.ApiClient {
619
647
  async getCompositionList(params = {}) {
620
648
  const { projectId } = this.options;
621
649
  const { resolveData, filters, ...originParams } = params;
622
- const rewrittenFilters = Object.entries(filters != null ? filters : {}).reduce((acc, [key, value]) => {
623
- const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
624
- let rhs = typeof value === "object" ? Object.values(value)[0] : value;
625
- rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
626
- return { ...acc, [lhs]: rhs };
627
- }, {});
650
+ const rewrittenFilters = rewriteFilters(filters);
628
651
  if (!resolveData) {
629
652
  const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
630
653
  return this.apiClient(fetchUri);
@@ -788,12 +811,7 @@ var _ContentClient = class _ContentClient extends import_api4.ApiClient {
788
811
  getEntries(options) {
789
812
  const { projectId } = this.options;
790
813
  const { skipDataResolution, filters, ...params } = options;
791
- const rewrittenFilters = Object.entries(filters != null ? filters : {}).reduce((acc, [key, value]) => {
792
- const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
793
- let rhs = typeof value === "object" ? Object.values(value)[0] : value;
794
- rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
795
- return { ...acc, [lhs]: rhs };
796
- }, {});
814
+ const rewrittenFilters = rewriteFilters(filters);
797
815
  if (skipDataResolution) {
798
816
  const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
799
817
  return this.apiClient(url);
@@ -1121,6 +1139,9 @@ function isAssetParamValueItem(item) {
1121
1139
  item instanceof Object && "_source" in item && "fields" in item && item.fields instanceof Object && "url" in item.fields && item.fields.url instanceof Object
1122
1140
  );
1123
1141
  }
1142
+ function isLinkParamValue(value) {
1143
+ return typeof value === "object" && value !== null && "type" in value && "path" in value;
1144
+ }
1124
1145
 
1125
1146
  // src/utils/properties.ts
1126
1147
  function getPropertiesValue(entity) {
@@ -1172,6 +1193,86 @@ function flattenSingleNodeValues(data, options = {}) {
1172
1193
  ) : properties;
1173
1194
  }
1174
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
+
1175
1276
  // src/enhancement/walkNodeTree.ts
1176
1277
  function walkNodeTree(node, visitor, options) {
1177
1278
  var _a, _b;
@@ -1184,8 +1285,7 @@ function walkNodeTree(node, visitor, options) {
1184
1285
  const childContexts = /* @__PURE__ */ new Map();
1185
1286
  do {
1186
1287
  const currentQueueEntry = componentQueue.pop();
1187
- if (!currentQueueEntry)
1188
- continue;
1288
+ if (!currentQueueEntry) continue;
1189
1289
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1190
1290
  let visitDescendants = true;
1191
1291
  let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
@@ -1396,8 +1496,25 @@ function walkNodeTree(node, visitor, options) {
1396
1496
  const propertyEntries = Object.entries(properties);
1397
1497
  for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
1398
1498
  const [propKey, propObject] = propertyEntries[propIndex];
1399
- if (!isNestedNodeType(propObject.type))
1499
+ if (!isNestedNodeType(propObject.type)) {
1400
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
+ }
1401
1518
  const blocks = (_b = propObject.value) != null ? _b : [];
1402
1519
  for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
1403
1520
  const enqueueingBlock = blocks[blockIndex];
@@ -1433,6 +1550,17 @@ function getBlockValue(component, parameterName) {
1433
1550
  }
1434
1551
  return [];
1435
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
+ };
1436
1564
 
1437
1565
  // src/enhancement/enhance.ts
1438
1566
  async function enhance({
@@ -1742,6 +1870,366 @@ function findParameterInNodeTree(data, predicate) {
1742
1870
  return results;
1743
1871
  }
1744
1872
 
1873
+ // src/enhancement/visibility/evaluateVisibilityCriteriaGroup.ts
1874
+ function evaluateVisibilityCriteriaGroup(options) {
1875
+ const { criteriaGroup, simplifyCriteria } = options;
1876
+ const earlyExitResult = criteriaGroup.op === "&" || !criteriaGroup.op ? false : true;
1877
+ let hasIndeterminateClauses = false;
1878
+ for (let index = criteriaGroup.clauses.length - 1; index >= 0; index--) {
1879
+ const clause = criteriaGroup.clauses[index];
1880
+ const criteriaResult = evaluateCriterion(clause, options);
1881
+ if (criteriaResult === null) {
1882
+ hasIndeterminateClauses = true;
1883
+ } else if (criteriaResult === earlyExitResult) {
1884
+ return earlyExitResult;
1885
+ } else if (criteriaResult !== null && simplifyCriteria) {
1886
+ criteriaGroup.clauses.splice(index, 1);
1887
+ }
1888
+ }
1889
+ return hasIndeterminateClauses ? null : !earlyExitResult;
1890
+ }
1891
+ function evaluateCriterion(clause, rootOptions) {
1892
+ var _a;
1893
+ if ("clauses" in clause) {
1894
+ return evaluateVisibilityCriteriaGroup({
1895
+ ...rootOptions,
1896
+ criteriaGroup: clause
1897
+ });
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
+ }
1904
+ const rule = rootOptions.rules[clause.rule];
1905
+ if (rule) {
1906
+ return rule(clause);
1907
+ }
1908
+ return null;
1909
+ }
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
+
1982
+ // src/enhancement/visibility/types.ts
1983
+ var CANVAS_VIZ_CONTROL_PARAM = "$viz";
1984
+
1985
+ // src/enhancement/visibility/evaluateNodeVisibility.ts
1986
+ function evaluateNodeVisibility({
1987
+ node,
1988
+ ...evaluateGroupOptions
1989
+ }) {
1990
+ var _a;
1991
+ const properties = getPropertiesValue(node);
1992
+ const vizCriteria = (_a = properties == null ? void 0 : properties[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _a.value;
1993
+ const result = evaluateNodeVisibilityParameter({
1994
+ ...evaluateGroupOptions,
1995
+ parameter: vizCriteria
1996
+ });
1997
+ if ((vizCriteria == null ? void 0 : vizCriteria.criteria) && vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
1998
+ properties == null ? true : delete properties[CANVAS_VIZ_CONTROL_PARAM];
1999
+ }
2000
+ return result;
2001
+ }
2002
+
2003
+ // src/enhancement/visibility/evaluateWalkTreeNodeVisibility.ts
2004
+ function evaluateWalkTreeNodeVisibility({
2005
+ rules,
2006
+ showIndeterminate,
2007
+ context
2008
+ }) {
2009
+ const { type, node, actions } = context;
2010
+ if (type !== "component") {
2011
+ return;
2012
+ }
2013
+ const result = evaluateNodeVisibility({ node, rules, simplifyCriteria: true });
2014
+ if (result === null && !showIndeterminate || result === false) {
2015
+ actions.remove();
2016
+ return false;
2017
+ }
2018
+ return true;
2019
+ }
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
+
2092
+ // src/enhancement/visibility/rules/evaluateStringMatch.ts
2093
+ var isEvaluator = (criteria, matchValue) => {
2094
+ if (Array.isArray(criteria)) {
2095
+ return criteria.includes(matchValue);
2096
+ }
2097
+ return criteria === matchValue;
2098
+ };
2099
+ var containsEvaluator = (criteria, matchValue) => {
2100
+ if (Array.isArray(criteria)) {
2101
+ return criteria.some((criterion) => matchValue.includes(criterion));
2102
+ }
2103
+ return matchValue.includes(criteria);
2104
+ };
2105
+ var startsWithEvaluator = (criteria, matchValue) => {
2106
+ if (Array.isArray(criteria)) {
2107
+ return criteria.some((criterion) => matchValue.startsWith(criterion));
2108
+ }
2109
+ return matchValue.startsWith(criteria);
2110
+ };
2111
+ var endsWithEvaluator = (criteria, matchValue) => {
2112
+ if (Array.isArray(criteria)) {
2113
+ return criteria.some((criterion) => matchValue.endsWith(criterion));
2114
+ }
2115
+ return matchValue.endsWith(criteria);
2116
+ };
2117
+ var emptyEvaluator = (_, matchValue) => {
2118
+ return matchValue === "";
2119
+ };
2120
+ var stringOperatorEvaluators = {
2121
+ is: isEvaluator,
2122
+ has: containsEvaluator,
2123
+ startswith: startsWithEvaluator,
2124
+ endswith: endsWithEvaluator,
2125
+ empty: emptyEvaluator
2126
+ };
2127
+ function evaluateStringMatch(criteria, matchValue, allow) {
2128
+ const { op, value } = criteria;
2129
+ if (allow && !allow.has(op)) {
2130
+ return null;
2131
+ }
2132
+ let opMatch = op;
2133
+ const negation = op.startsWith("!");
2134
+ if (negation) {
2135
+ opMatch = opMatch.slice(1);
2136
+ }
2137
+ const evaluator = stringOperatorEvaluators[opMatch];
2138
+ if (!evaluator) {
2139
+ return null;
2140
+ }
2141
+ const result = evaluator(value, matchValue);
2142
+ return negation ? !result : result;
2143
+ }
2144
+
2145
+ // src/enhancement/visibility/rules/createDynamicInputVisibilityRule.ts
2146
+ var dynamicInputVisibilityOperators = /* @__PURE__ */ new Set([
2147
+ "is",
2148
+ "!is",
2149
+ "has",
2150
+ "!has",
2151
+ "startswith",
2152
+ "!startswith",
2153
+ "endswith",
2154
+ "!endswith",
2155
+ "empty",
2156
+ "!empty"
2157
+ ]);
2158
+ var CANVAS_VIZ_DI_RULE = "$di";
2159
+ function createDynamicInputVisibilityRule(dynamicInputs) {
2160
+ return {
2161
+ [CANVAS_VIZ_DI_RULE]: (criterion) => {
2162
+ const { source } = criterion;
2163
+ const diValue = source ? dynamicInputs[source] : void 0;
2164
+ return evaluateStringMatch(criterion, diValue != null ? diValue : "", dynamicInputVisibilityOperators);
2165
+ }
2166
+ };
2167
+ }
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
+
2195
+ // src/enhancement/visibility/rules/createLocaleVisibilityRule.ts
2196
+ var localeVisibilityOperators = /* @__PURE__ */ new Set(["is", "!is"]);
2197
+ var CANVAS_VIZ_LOCALE_RULE = "$locale";
2198
+ function createLocaleVisibilityRule(currentLocale) {
2199
+ return {
2200
+ [CANVAS_VIZ_LOCALE_RULE]: (criterion) => {
2201
+ if (!currentLocale) {
2202
+ return false;
2203
+ }
2204
+ return evaluateStringMatch(criterion, currentLocale, localeVisibilityOperators);
2205
+ }
2206
+ };
2207
+ }
2208
+
2209
+ // src/enhancement/visibility/rules/createQuirksVisibilityRule.ts
2210
+ var quirksVisibilityOperators = /* @__PURE__ */ new Set([
2211
+ "is",
2212
+ "!is",
2213
+ "has",
2214
+ "!has",
2215
+ "startswith",
2216
+ "!startswith",
2217
+ "endswith",
2218
+ "!endswith",
2219
+ "empty",
2220
+ "!empty"
2221
+ ]);
2222
+ var CANVAS_VIZ_QUIRKS_RULE = "$qk";
2223
+ function createQuirksVisibilityRule(quirks) {
2224
+ return {
2225
+ [CANVAS_VIZ_QUIRKS_RULE]: (criterion) => {
2226
+ const { source } = criterion;
2227
+ const quirkValue = source ? quirks[source] : void 0;
2228
+ return evaluateStringMatch(criterion, quirkValue != null ? quirkValue : "", quirksVisibilityOperators);
2229
+ }
2230
+ };
2231
+ }
2232
+
1745
2233
  // src/enhancement/localize.ts
1746
2234
  function extractLocales({ component }) {
1747
2235
  var _a;
@@ -1760,17 +2248,29 @@ function extractLocales({ component }) {
1760
2248
  function localize(options) {
1761
2249
  const nodes = "nodes" in options ? options.nodes : options.composition;
1762
2250
  const locale = options.locale;
1763
- walkNodeTree(nodes, ({ type, node, actions }) => {
2251
+ const isUsingModernOptions = typeof locale === "string";
2252
+ const vizControlLocaleRule = isUsingModernOptions ? createLocaleVisibilityRule(locale) : {};
2253
+ walkNodeTree(nodes, (context) => {
2254
+ const { type, node, actions } = context;
1764
2255
  if (type !== "component") {
1765
- if (typeof locale === "string") {
1766
- localizeProperties(node.fields, locale);
2256
+ if (isUsingModernOptions) {
2257
+ localizeProperties(node, locale, vizControlLocaleRule);
1767
2258
  }
1768
2259
  return;
1769
2260
  }
1770
- const shouldRunPropertyLocalization = typeof locale === "string";
2261
+ if (isUsingModernOptions) {
2262
+ const result = evaluateWalkTreeNodeVisibility({
2263
+ context,
2264
+ rules: vizControlLocaleRule,
2265
+ showIndeterminate: true
2266
+ });
2267
+ if (!result) {
2268
+ return;
2269
+ }
2270
+ }
1771
2271
  if (node.type === CANVAS_LOCALIZATION_TYPE) {
1772
2272
  const locales = extractLocales({ component: node });
1773
- const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
2273
+ const resolvedLocale = isUsingModernOptions ? locale : locale == null ? void 0 : locale({ component: node, locales });
1774
2274
  let replaceComponent;
1775
2275
  if (resolvedLocale) {
1776
2276
  replaceComponent = locales[resolvedLocale];
@@ -1778,8 +2278,8 @@ function localize(options) {
1778
2278
  if (replaceComponent == null ? void 0 : replaceComponent.length) {
1779
2279
  replaceComponent.forEach((component) => {
1780
2280
  removeLocaleProperty(component);
1781
- if (shouldRunPropertyLocalization) {
1782
- localizeProperties(getPropertiesValue(component), locale);
2281
+ if (isUsingModernOptions) {
2282
+ localizeProperties(component, locale, vizControlLocaleRule);
1783
2283
  }
1784
2284
  });
1785
2285
  const [first, ...rest] = replaceComponent;
@@ -1790,8 +2290,8 @@ function localize(options) {
1790
2290
  } else {
1791
2291
  actions.remove();
1792
2292
  }
1793
- } else if (shouldRunPropertyLocalization) {
1794
- localizeProperties(getPropertiesValue(node), locale);
2293
+ } else if (isUsingModernOptions) {
2294
+ localizeProperties(node, locale, vizControlLocaleRule);
1795
2295
  }
1796
2296
  });
1797
2297
  }
@@ -1810,36 +2310,51 @@ function removeLocaleProperty(component) {
1810
2310
  }
1811
2311
  }
1812
2312
  }
1813
- function localizeProperties(properties, locale) {
2313
+ function localizeProperties(node, locale, rules) {
2314
+ const properties = getPropertiesValue(node);
1814
2315
  if (!properties) {
1815
2316
  return void 0;
1816
2317
  }
1817
- Object.entries(properties).forEach(([key, property]) => {
1818
- var _a;
2318
+ Object.entries(properties).forEach(([propertyId, propertyValue]) => {
2319
+ var _a, _b;
1819
2320
  if (!locale) {
1820
- delete property.locales;
2321
+ delete propertyValue.locales;
2322
+ delete propertyValue.localesConditions;
1821
2323
  }
1822
- const currentLocaleValue = locale ? (_a = property.locales) == null ? void 0 : _a[locale] : void 0;
2324
+ const currentLocaleValue = locale ? (_a = propertyValue.locales) == null ? void 0 : _a[locale] : void 0;
1823
2325
  if (currentLocaleValue !== void 0) {
1824
- property.value = currentLocaleValue;
2326
+ propertyValue.value = currentLocaleValue;
2327
+ }
2328
+ const currentLocaleConditionalValues = locale ? (_b = propertyValue.localesConditions) == null ? void 0 : _b[locale] : void 0;
2329
+ if (currentLocaleConditionalValues !== void 0) {
2330
+ propertyValue.conditions = currentLocaleConditionalValues;
1825
2331
  }
1826
- delete property.locales;
1827
- if (property.value === void 0) {
1828
- delete properties[key];
2332
+ delete propertyValue.locales;
2333
+ delete propertyValue.localesConditions;
2334
+ if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
2335
+ delete properties[propertyId];
1829
2336
  }
1830
2337
  });
2338
+ evaluateWalkTreePropertyCriteria({
2339
+ node,
2340
+ rules,
2341
+ keepIndeterminate: true
2342
+ });
1831
2343
  }
1832
2344
 
1833
2345
  // src/enhancement/UniqueBatchEntries.ts
1834
2346
  var UniqueBatchEntries = class {
1835
2347
  constructor(entries, uniqueKeySelector) {
1836
- this.groups = entries.reduce((acc, task) => {
1837
- var _a;
1838
- const key = uniqueKeySelector(task.args);
1839
- acc[key] = (_a = acc[key]) != null ? _a : [];
1840
- acc[key].push(task);
1841
- return acc;
1842
- }, {});
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
+ );
1843
2358
  }
1844
2359
  /** Resolves all entries in a group key with the same result value. */
1845
2360
  resolveKey(key, result) {
@@ -1869,8 +2384,7 @@ function walkComponentTree(component, visitor, initialContext) {
1869
2384
  const childContexts = /* @__PURE__ */ new Map();
1870
2385
  do {
1871
2386
  const currentQueueEntry = componentQueue.pop();
1872
- if (!currentQueueEntry)
1873
- continue;
2387
+ if (!currentQueueEntry) continue;
1874
2388
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1875
2389
  let visitDescendants = true;
1876
2390
  let descendantContext = (_a = childContexts.get(currentComponent.component)) != null ? _a : currentQueueEntry.context;
@@ -1975,10 +2489,25 @@ function walkComponentTree(component, visitor, initialContext) {
1975
2489
  } while (componentQueue.length > 0);
1976
2490
  }
1977
2491
 
1978
- // src/LocaleClient.ts
2492
+ // src/EntityReleasesClient.ts
1979
2493
  var import_api7 = require("@uniformdev/context/api");
2494
+ var releaseContentsUrl = "/api/v1/entity-releases";
2495
+ var EntityReleasesClient = class extends import_api7.ApiClient {
2496
+ constructor(options) {
2497
+ super(options);
2498
+ }
2499
+ /** Fetches entity across all releases (and base) */
2500
+ async get(options) {
2501
+ const { projectId } = this.options;
2502
+ const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
2503
+ return await this.apiClient(fetchUri);
2504
+ }
2505
+ };
2506
+
2507
+ // src/LocaleClient.ts
2508
+ var import_api8 = require("@uniformdev/context/api");
1980
2509
  var localesUrl = "/api/v1/locales";
1981
- var LocaleClient = class extends import_api7.ApiClient {
2510
+ var LocaleClient = class extends import_api8.ApiClient {
1982
2511
  constructor(options) {
1983
2512
  super(options);
1984
2513
  }
@@ -2084,6 +2613,9 @@ var isRequestComponentSuggestionMessage = (message) => {
2084
2613
  var isSuggestComponentMessage = (message) => {
2085
2614
  return message.type === "suggest-component";
2086
2615
  };
2616
+ var isContextStorageUpdatedMessage = (message) => {
2617
+ return message.type === "context-storage-command-executed";
2618
+ };
2087
2619
  var createCanvasChannel = ({
2088
2620
  listenTo,
2089
2621
  broadcastTo
@@ -2264,6 +2796,13 @@ var createCanvasChannel = ({
2264
2796
  };
2265
2797
  postMessage(message);
2266
2798
  };
2799
+ const contextStorageUpdated = (options) => {
2800
+ const message = {
2801
+ ...options,
2802
+ type: "context-storage-command-executed"
2803
+ };
2804
+ postMessage(message);
2805
+ };
2267
2806
  const messageEventListener = (event) => {
2268
2807
  if (typeof event.data !== "string") {
2269
2808
  return;
@@ -2313,7 +2852,8 @@ var createCanvasChannel = ({
2313
2852
  editorStateUpdated,
2314
2853
  updateComponentReferences,
2315
2854
  requestComponentSuggestion,
2316
- suggestComponent
2855
+ suggestComponent,
2856
+ contextStorageUpdated
2317
2857
  };
2318
2858
  };
2319
2859
 
@@ -2396,9 +2936,9 @@ function subscribeToComposition({
2396
2936
  }
2397
2937
 
2398
2938
  // src/PromptClient.ts
2399
- var import_api8 = require("@uniformdev/context/api");
2939
+ var import_api9 = require("@uniformdev/context/api");
2400
2940
  var PromptsUrl = "/api/v1/prompts";
2401
- var PromptClient = class extends import_api8.ApiClient {
2941
+ var PromptClient = class extends import_api9.ApiClient {
2402
2942
  constructor(options) {
2403
2943
  super(options);
2404
2944
  }
@@ -2429,9 +2969,9 @@ var PromptClient = class extends import_api8.ApiClient {
2429
2969
  };
2430
2970
 
2431
2971
  // src/RelationshipClient.ts
2432
- var import_api9 = require("@uniformdev/context/api");
2972
+ var import_api10 = require("@uniformdev/context/api");
2433
2973
  var RELATIONSHIPS_URL = "/api/v1/relationships";
2434
- var RelationshipClient = class extends import_api9.ApiClient {
2974
+ var RelationshipClient = class extends import_api10.ApiClient {
2435
2975
  constructor(options) {
2436
2976
  super(options);
2437
2977
  this.get = async (options) => {
@@ -2439,56 +2979,13 @@ var RelationshipClient = class extends import_api9.ApiClient {
2439
2979
  const url = this.createUrl(RELATIONSHIPS_URL, { ...options, projectId });
2440
2980
  return this.apiClient(url);
2441
2981
  };
2442
- this.clearProjectRelationships = async () => {
2443
- const { projectId } = this.options;
2444
- const url = this.createUrl(RELATIONSHIPS_URL);
2445
- return this.apiClient(url, {
2446
- method: "POST",
2447
- body: JSON.stringify({
2448
- action: "clear",
2449
- projectId
2450
- })
2451
- });
2452
- };
2453
- this.indexRelationships = async ({ state, id, type }) => {
2454
- const { projectId } = this.options;
2455
- const url = this.createUrl(RELATIONSHIPS_URL);
2456
- return this.apiClient(url, {
2457
- method: "POST",
2458
- body: JSON.stringify({
2459
- action: "index",
2460
- type,
2461
- projectId,
2462
- state,
2463
- id
2464
- })
2465
- });
2466
- };
2467
- this.getVersion = async () => {
2468
- const { projectId } = this.options;
2469
- const url = this.createUrl("/api/v1/usage-tracking", {
2470
- projectId
2471
- });
2472
- return this.apiClient(url).then((response) => response.version);
2473
- };
2474
- this.setVersion = async (version) => {
2475
- const { projectId } = this.options;
2476
- const url = this.createUrl("/api/v1/usage-tracking");
2477
- return this.apiClient(url, {
2478
- method: "POST",
2479
- body: JSON.stringify({
2480
- projectId,
2481
- version
2482
- })
2483
- });
2484
- };
2485
2982
  }
2486
2983
  };
2487
2984
 
2488
2985
  // src/ReleaseClient.ts
2489
- var import_api10 = require("@uniformdev/context/api");
2986
+ var import_api11 = require("@uniformdev/context/api");
2490
2987
  var releasesUrl = "/api/v1/releases";
2491
- var ReleaseClient = class extends import_api10.ApiClient {
2988
+ var ReleaseClient = class extends import_api11.ApiClient {
2492
2989
  constructor(options) {
2493
2990
  super(options);
2494
2991
  }
@@ -2528,21 +3025,21 @@ var ReleaseClient = class extends import_api10.ApiClient {
2528
3025
  };
2529
3026
 
2530
3027
  // src/ReleaseContentsClient.ts
2531
- var import_api11 = require("@uniformdev/context/api");
2532
- var releaseContentsUrl = "/api/v1/release-contents";
2533
- var ReleaseContentsClient = class extends import_api11.ApiClient {
3028
+ var import_api12 = require("@uniformdev/context/api");
3029
+ var releaseContentsUrl2 = "/api/v1/release-contents";
3030
+ var ReleaseContentsClient = class extends import_api12.ApiClient {
2534
3031
  constructor(options) {
2535
3032
  super(options);
2536
3033
  }
2537
3034
  /** Fetches all entities added to a release */
2538
3035
  async get(options) {
2539
3036
  const { projectId } = this.options;
2540
- const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
3037
+ const fetchUri = this.createUrl(releaseContentsUrl2, { ...options, projectId });
2541
3038
  return await this.apiClient(fetchUri);
2542
3039
  }
2543
3040
  /** Removes a release content from a release */
2544
3041
  async remove(body) {
2545
- const fetchUri = this.createUrl(releaseContentsUrl);
3042
+ const fetchUri = this.createUrl(releaseContentsUrl2);
2546
3043
  await this.apiClient(fetchUri, {
2547
3044
  method: "DELETE",
2548
3045
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -2552,9 +3049,9 @@ var ReleaseContentsClient = class extends import_api11.ApiClient {
2552
3049
  };
2553
3050
 
2554
3051
  // src/RouteClient.ts
2555
- var import_api12 = require("@uniformdev/context/api");
3052
+ var import_api13 = require("@uniformdev/context/api");
2556
3053
  var ROUTE_URL = "/api/v1/route";
2557
- var RouteClient = class extends import_api12.ApiClient {
3054
+ var RouteClient = class extends import_api13.ApiClient {
2558
3055
  constructor(options) {
2559
3056
  var _a;
2560
3057
  if (!options.limitPolicy) {
@@ -2665,8 +3162,7 @@ var isSystemComponentDefinition = (componentType) => {
2665
3162
 
2666
3163
  // src/utils/mapSlotToPersonalizedVariations.ts
2667
3164
  function mapSlotToPersonalizedVariations(slot) {
2668
- if (!slot)
2669
- return [];
3165
+ if (!slot) return [];
2670
3166
  return slot.map((v, i) => {
2671
3167
  var _a, _b;
2672
3168
  const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b.value;
@@ -2681,8 +3177,7 @@ function mapSlotToPersonalizedVariations(slot) {
2681
3177
 
2682
3178
  // src/utils/mapSlotToTestVariations.ts
2683
3179
  function mapSlotToTestVariations(slot) {
2684
- if (!slot)
2685
- return [];
3180
+ if (!slot) return [];
2686
3181
  return slot.map((v, i) => {
2687
3182
  var _a, _b, _c;
2688
3183
  const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b.value;
@@ -2707,7 +3202,7 @@ var isComponentPlaceholderId = (id) => {
2707
3202
  return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
2708
3203
  };
2709
3204
  var generateComponentPlaceholderId = (randomId, sdkVersion, parent) => {
2710
- if (typeof sdkVersion === "undefined" || sdkVersion === 1) {
3205
+ if (sdkVersion === 1) {
2711
3206
  return PLACEHOLDER_ID;
2712
3207
  }
2713
3208
  let idParts = [PLACEHOLDER_ID, randomId];
@@ -2733,72 +3228,6 @@ var parseComponentPlaceholderId = (id) => {
2733
3228
  return result;
2734
3229
  };
2735
3230
 
2736
- // src/utils/variables/parseVariableExpression.ts
2737
- var escapeCharacter = "\\";
2738
- var variablePrefix = "${";
2739
- var variableSuffix = "}";
2740
- function parseVariableExpression(serialized, onToken) {
2741
- let bufferStartIndex = 0;
2742
- let bufferEndIndex = 0;
2743
- let tokenCount = 0;
2744
- const handleToken = (token, type) => {
2745
- tokenCount++;
2746
- return onToken == null ? void 0 : onToken(token, type);
2747
- };
2748
- let state = "text";
2749
- for (let index = 0; index < serialized.length; index++) {
2750
- const char = serialized[index];
2751
- if (bufferStartIndex > bufferEndIndex) {
2752
- bufferEndIndex = bufferStartIndex;
2753
- }
2754
- if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
2755
- if (serialized[index - 1] === escapeCharacter) {
2756
- bufferEndIndex -= escapeCharacter.length;
2757
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
2758
- return tokenCount;
2759
- }
2760
- bufferStartIndex = index;
2761
- bufferEndIndex = index + 1;
2762
- continue;
2763
- }
2764
- state = "variable";
2765
- if (bufferEndIndex > bufferStartIndex) {
2766
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
2767
- return tokenCount;
2768
- }
2769
- bufferStartIndex = bufferEndIndex;
2770
- }
2771
- index += variablePrefix.length - 1;
2772
- bufferStartIndex += variablePrefix.length;
2773
- continue;
2774
- }
2775
- if (char === variableSuffix && state === "variable") {
2776
- if (serialized[index - 1] === escapeCharacter) {
2777
- bufferEndIndex++;
2778
- continue;
2779
- }
2780
- state = "text";
2781
- if (bufferEndIndex > bufferStartIndex) {
2782
- const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
2783
- if (handleToken(unescapedVariableName, "variable") === false) {
2784
- return tokenCount;
2785
- }
2786
- bufferStartIndex = bufferEndIndex + variableSuffix.length;
2787
- }
2788
- continue;
2789
- }
2790
- bufferEndIndex++;
2791
- }
2792
- if (bufferEndIndex > bufferStartIndex) {
2793
- if (state === "variable") {
2794
- state = "text";
2795
- bufferStartIndex -= variablePrefix.length;
2796
- }
2797
- handleToken(serialized.substring(bufferStartIndex), state);
2798
- }
2799
- return tokenCount;
2800
- }
2801
-
2802
3231
  // src/utils/variables/bindVariables.ts
2803
3232
  function bindVariables({
2804
3233
  variables,
@@ -2864,7 +3293,11 @@ function bindVariablesToObjectRecursive({
2864
3293
  if (richTextNodeResult !== void 0) {
2865
3294
  return richTextNodeResult;
2866
3295
  }
2867
- const result = (0, import_immer.produce)(value, (draft) => {
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) => {
2868
3301
  Object.entries(draft).forEach(([property, oldValue]) => {
2869
3302
  const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
2870
3303
  if (typeof oldValue === "string") {
@@ -2921,12 +3354,12 @@ function handleRichTextNodeBinding(object, options) {
2921
3354
  }
2922
3355
 
2923
3356
  // src/index.ts
2924
- var import_api14 = require("@uniformdev/context/api");
3357
+ var import_api15 = require("@uniformdev/context/api");
2925
3358
 
2926
3359
  // src/WorkflowClient.ts
2927
- var import_api13 = require("@uniformdev/context/api");
3360
+ var import_api14 = require("@uniformdev/context/api");
2928
3361
  var workflowsUrl = "/api/v1/workflows";
2929
- var WorkflowClient = class extends import_api13.ApiClient {
3362
+ var WorkflowClient = class extends import_api14.ApiClient {
2930
3363
  constructor(options) {
2931
3364
  super(options);
2932
3365
  }
@@ -2957,7 +3390,7 @@ var WorkflowClient = class extends import_api13.ApiClient {
2957
3390
  };
2958
3391
 
2959
3392
  // src/index.ts
2960
- var CanvasClientError = import_api14.ApiClientError;
3393
+ var CanvasClientError = import_api15.ApiClientError;
2961
3394
  // Annotate the CommonJS export names for ESM import in node:
2962
3395
  0 && (module.exports = {
2963
3396
  ASSETS_SOURCE_CUSTOM_URL,
@@ -2971,6 +3404,7 @@ var CanvasClientError = import_api14.ApiClientError;
2971
3404
  ATTRIBUTE_PLACEHOLDER,
2972
3405
  ApiClientError,
2973
3406
  BatchEntry,
3407
+ BlockFormatError,
2974
3408
  CANVAS_BLOCK_PARAM_TYPE,
2975
3409
  CANVAS_DRAFT_STATE,
2976
3410
  CANVAS_EDITOR_STATE,
@@ -2988,6 +3422,11 @@ var CanvasClientError = import_api14.ApiClientError;
2988
3422
  CANVAS_TEST_SLOT,
2989
3423
  CANVAS_TEST_TYPE,
2990
3424
  CANVAS_TEST_VARIANT_PARAM,
3425
+ CANVAS_VIZ_CONTROL_PARAM,
3426
+ CANVAS_VIZ_DI_RULE,
3427
+ CANVAS_VIZ_DYNAMIC_TOKEN_RULE,
3428
+ CANVAS_VIZ_LOCALE_RULE,
3429
+ CANVAS_VIZ_QUIRKS_RULE,
2991
3430
  CanvasClient,
2992
3431
  CanvasClientError,
2993
3432
  CategoryClient,
@@ -3001,6 +3440,7 @@ var CanvasClientError = import_api14.ApiClientError;
3001
3440
  EDGE_MIN_CACHE_TTL,
3002
3441
  EMPTY_COMPOSITION,
3003
3442
  EnhancerBuilder,
3443
+ EntityReleasesClient,
3004
3444
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
3005
3445
  IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
3006
3446
  IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
@@ -3029,11 +3469,20 @@ var CanvasClientError = import_api14.ApiClientError;
3029
3469
  convertEntryToPutEntry,
3030
3470
  createBatchEnhancer,
3031
3471
  createCanvasChannel,
3472
+ createDynamicInputVisibilityRule,
3473
+ createDynamicTokenVisibilityRule,
3032
3474
  createEventBus,
3033
3475
  createLimitPolicy,
3476
+ createLocaleVisibilityRule,
3477
+ createQuirksVisibilityRule,
3034
3478
  createUniformApiEnhancer,
3035
3479
  createVariableReference,
3036
3480
  enhance,
3481
+ evaluateNodeVisibilityParameter,
3482
+ evaluatePropertyCriteria,
3483
+ evaluateVisibilityCriteriaGroup,
3484
+ evaluateWalkTreeNodeVisibility,
3485
+ evaluateWalkTreePropertyCriteria,
3037
3486
  extractLocales,
3038
3487
  findParameterInNodeTree,
3039
3488
  flattenValues,
@@ -3049,14 +3498,17 @@ var CanvasClientError = import_api14.ApiClientError;
3049
3498
  getParameterAttributes,
3050
3499
  getPropertiesValue,
3051
3500
  getPropertyValue,
3501
+ hasReferencedVariables,
3052
3502
  isAddComponentMessage,
3053
3503
  isAllowedReferrer,
3054
3504
  isAssetParamValue,
3055
3505
  isAssetParamValueItem,
3056
3506
  isComponentActionMessage,
3057
3507
  isComponentPlaceholderId,
3508
+ isContextStorageUpdatedMessage,
3058
3509
  isDismissPlaceholderMessage,
3059
3510
  isEntryData,
3511
+ isLinkParamValue,
3060
3512
  isMovingComponentMessage,
3061
3513
  isNestedNodeType,
3062
3514
  isOpenParameterEditorMessage,