@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.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_api13.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,
@@ -339,17 +339,27 @@ __export(src_exports, {
339
339
  UncachedCategoryClient: () => UncachedCategoryClient,
340
340
  UncachedContentClient: () => UncachedContentClient,
341
341
  UniqueBatchEntries: () => UniqueBatchEntries,
342
+ WorkflowClient: () => WorkflowClient,
342
343
  bindVariables: () => bindVariables,
343
344
  bindVariablesToObject: () => bindVariablesToObject,
344
345
  compose: () => compose,
345
346
  convertEntryToPutEntry: () => convertEntryToPutEntry,
346
347
  createBatchEnhancer: () => createBatchEnhancer,
347
348
  createCanvasChannel: () => createCanvasChannel,
349
+ createDynamicInputVisibilityRule: () => createDynamicInputVisibilityRule,
350
+ createDynamicTokenVisibilityRule: () => createDynamicTokenVisibilityRule,
348
351
  createEventBus: () => createEventBus,
349
352
  createLimitPolicy: () => createLimitPolicy,
353
+ createLocaleVisibilityRule: () => createLocaleVisibilityRule,
354
+ createQuirksVisibilityRule: () => createQuirksVisibilityRule,
350
355
  createUniformApiEnhancer: () => createUniformApiEnhancer,
351
356
  createVariableReference: () => createVariableReference,
352
357
  enhance: () => enhance,
358
+ evaluateNodeVisibilityParameter: () => evaluateNodeVisibilityParameter,
359
+ evaluatePropertyCriteria: () => evaluatePropertyCriteria,
360
+ evaluateVisibilityCriteriaGroup: () => evaluateVisibilityCriteriaGroup,
361
+ evaluateWalkTreeNodeVisibility: () => evaluateWalkTreeNodeVisibility,
362
+ evaluateWalkTreePropertyCriteria: () => evaluateWalkTreePropertyCriteria,
353
363
  extractLocales: () => extractLocales,
354
364
  findParameterInNodeTree: () => findParameterInNodeTree,
355
365
  flattenValues: () => flattenValues,
@@ -359,19 +369,23 @@ __export(src_exports, {
359
369
  getChannelName: () => getChannelName,
360
370
  getComponentJsonPointer: () => getComponentJsonPointer,
361
371
  getComponentPath: () => getComponentPath,
372
+ getLocalizedPropertyValues: () => getLocalizedPropertyValues,
362
373
  getNounForLocation: () => getNounForLocation,
363
374
  getNounForNode: () => getNounForNode,
364
375
  getParameterAttributes: () => getParameterAttributes,
365
376
  getPropertiesValue: () => getPropertiesValue,
366
377
  getPropertyValue: () => getPropertyValue,
378
+ hasReferencedVariables: () => hasReferencedVariables,
367
379
  isAddComponentMessage: () => isAddComponentMessage,
368
380
  isAllowedReferrer: () => isAllowedReferrer,
369
381
  isAssetParamValue: () => isAssetParamValue,
370
382
  isAssetParamValueItem: () => isAssetParamValueItem,
371
383
  isComponentActionMessage: () => isComponentActionMessage,
372
384
  isComponentPlaceholderId: () => isComponentPlaceholderId,
385
+ isContextStorageUpdatedMessage: () => isContextStorageUpdatedMessage,
373
386
  isDismissPlaceholderMessage: () => isDismissPlaceholderMessage,
374
387
  isEntryData: () => isEntryData,
388
+ isLinkParamValue: () => isLinkParamValue,
375
389
  isMovingComponentMessage: () => isMovingComponentMessage,
376
390
  isNestedNodeType: () => isNestedNodeType,
377
391
  isOpenParameterEditorMessage: () => isOpenParameterEditorMessage,
@@ -601,6 +615,22 @@ function createLimitPolicy({
601
615
  }
602
616
  var nullLimitPolicy = async (func) => await func();
603
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
+
604
634
  // src/CanvasClient.ts
605
635
  var CANVAS_URL = "/api/v1/canvas";
606
636
  var CanvasClient = class extends import_api2.ApiClient {
@@ -617,12 +647,7 @@ var CanvasClient = class extends import_api2.ApiClient {
617
647
  async getCompositionList(params = {}) {
618
648
  const { projectId } = this.options;
619
649
  const { resolveData, filters, ...originParams } = params;
620
- const rewrittenFilters = Object.entries(filters != null ? filters : {}).reduce((acc, [key, value]) => {
621
- const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
622
- let rhs = typeof value === "object" ? Object.values(value)[0] : value;
623
- rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
624
- return { ...acc, [lhs]: rhs };
625
- }, {});
650
+ const rewrittenFilters = rewriteFilters(filters);
626
651
  if (!resolveData) {
627
652
  const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
628
653
  return this.apiClient(fetchUri);
@@ -786,12 +811,7 @@ var _ContentClient = class _ContentClient extends import_api4.ApiClient {
786
811
  getEntries(options) {
787
812
  const { projectId } = this.options;
788
813
  const { skipDataResolution, filters, ...params } = options;
789
- const rewrittenFilters = Object.entries(filters != null ? filters : {}).reduce((acc, [key, value]) => {
790
- const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
791
- let rhs = typeof value === "object" ? Object.values(value)[0] : value;
792
- rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
793
- return { ...acc, [lhs]: rhs };
794
- }, {});
814
+ const rewrittenFilters = rewriteFilters(filters);
795
815
  if (skipDataResolution) {
796
816
  const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
797
817
  return this.apiClient(url);
@@ -1119,6 +1139,9 @@ function isAssetParamValueItem(item) {
1119
1139
  item instanceof Object && "_source" in item && "fields" in item && item.fields instanceof Object && "url" in item.fields && item.fields.url instanceof Object
1120
1140
  );
1121
1141
  }
1142
+ function isLinkParamValue(value) {
1143
+ return typeof value === "object" && value !== null && "type" in value && "path" in value;
1144
+ }
1122
1145
 
1123
1146
  // src/utils/properties.ts
1124
1147
  function getPropertiesValue(entity) {
@@ -1127,6 +1150,21 @@ function getPropertiesValue(entity) {
1127
1150
  function getPropertyValue(parameter) {
1128
1151
  return parameter ? parameter.value : parameter;
1129
1152
  }
1153
+ function getLocalizedPropertyValues(parameter) {
1154
+ if (!parameter) {
1155
+ return parameter;
1156
+ }
1157
+ const localizedValues = /* @__PURE__ */ new Map();
1158
+ if (typeof parameter.value !== "undefined") {
1159
+ localizedValues.set(void 0, parameter.value);
1160
+ }
1161
+ if (parameter.locales !== void 0) {
1162
+ for (const [locale, localeValue] of Object.entries(parameter.locales)) {
1163
+ localizedValues.set(locale, localeValue);
1164
+ }
1165
+ }
1166
+ return localizedValues;
1167
+ }
1130
1168
  function flattenValues(data, options = {}) {
1131
1169
  if (!data) {
1132
1170
  return data;
@@ -1155,6 +1193,86 @@ function flattenSingleNodeValues(data, options = {}) {
1155
1193
  ) : properties;
1156
1194
  }
1157
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
+
1158
1276
  // src/enhancement/walkNodeTree.ts
1159
1277
  function walkNodeTree(node, visitor, options) {
1160
1278
  var _a, _b;
@@ -1167,8 +1285,7 @@ function walkNodeTree(node, visitor, options) {
1167
1285
  const childContexts = /* @__PURE__ */ new Map();
1168
1286
  do {
1169
1287
  const currentQueueEntry = componentQueue.pop();
1170
- if (!currentQueueEntry)
1171
- continue;
1288
+ if (!currentQueueEntry) continue;
1172
1289
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1173
1290
  let visitDescendants = true;
1174
1291
  let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
@@ -1202,6 +1319,7 @@ function walkNodeTree(node, visitor, options) {
1202
1319
  } else {
1203
1320
  throw new Error("Unknown node type");
1204
1321
  }
1322
+ visitDescendants = false;
1205
1323
  },
1206
1324
  insertAfter: (nodes) => {
1207
1325
  const currentNodeInfo = currentQueueEntry.ancestorsAndSelf[0];
@@ -1287,6 +1405,7 @@ function walkNodeTree(node, visitor, options) {
1287
1405
  } else {
1288
1406
  throw new Error("Unknown node type");
1289
1407
  }
1408
+ visitDescendants = false;
1290
1409
  },
1291
1410
  insertAfter: (nodes) => {
1292
1411
  const nodesToInsert = Array.isArray(nodes) ? nodes : [nodes];
@@ -1377,8 +1496,25 @@ function walkNodeTree(node, visitor, options) {
1377
1496
  const propertyEntries = Object.entries(properties);
1378
1497
  for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
1379
1498
  const [propKey, propObject] = propertyEntries[propIndex];
1380
- if (!isNestedNodeType(propObject.type))
1499
+ if (!isNestedNodeType(propObject.type)) {
1381
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
+ }
1382
1518
  const blocks = (_b = propObject.value) != null ? _b : [];
1383
1519
  for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
1384
1520
  const enqueueingBlock = blocks[blockIndex];
@@ -1414,6 +1550,17 @@ function getBlockValue(component, parameterName) {
1414
1550
  }
1415
1551
  return [];
1416
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
+ };
1417
1564
 
1418
1565
  // src/enhancement/enhance.ts
1419
1566
  async function enhance({
@@ -1723,6 +1870,366 @@ function findParameterInNodeTree(data, predicate) {
1723
1870
  return results;
1724
1871
  }
1725
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
+
1726
2233
  // src/enhancement/localize.ts
1727
2234
  function extractLocales({ component }) {
1728
2235
  var _a;
@@ -1741,17 +2248,29 @@ function extractLocales({ component }) {
1741
2248
  function localize(options) {
1742
2249
  const nodes = "nodes" in options ? options.nodes : options.composition;
1743
2250
  const locale = options.locale;
1744
- 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;
1745
2255
  if (type !== "component") {
1746
- if (typeof locale === "string") {
1747
- localizeProperties(node.fields, locale);
2256
+ if (isUsingModernOptions) {
2257
+ localizeProperties(node, locale, vizControlLocaleRule);
1748
2258
  }
1749
2259
  return;
1750
2260
  }
1751
- 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
+ }
1752
2271
  if (node.type === CANVAS_LOCALIZATION_TYPE) {
1753
2272
  const locales = extractLocales({ component: node });
1754
- 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 });
1755
2274
  let replaceComponent;
1756
2275
  if (resolvedLocale) {
1757
2276
  replaceComponent = locales[resolvedLocale];
@@ -1759,8 +2278,8 @@ function localize(options) {
1759
2278
  if (replaceComponent == null ? void 0 : replaceComponent.length) {
1760
2279
  replaceComponent.forEach((component) => {
1761
2280
  removeLocaleProperty(component);
1762
- if (shouldRunPropertyLocalization) {
1763
- localizeProperties(getPropertiesValue(component), locale);
2281
+ if (isUsingModernOptions) {
2282
+ localizeProperties(component, locale, vizControlLocaleRule);
1764
2283
  }
1765
2284
  });
1766
2285
  const [first, ...rest] = replaceComponent;
@@ -1771,8 +2290,8 @@ function localize(options) {
1771
2290
  } else {
1772
2291
  actions.remove();
1773
2292
  }
1774
- } else if (shouldRunPropertyLocalization) {
1775
- localizeProperties(getPropertiesValue(node), locale);
2293
+ } else if (isUsingModernOptions) {
2294
+ localizeProperties(node, locale, vizControlLocaleRule);
1776
2295
  }
1777
2296
  });
1778
2297
  }
@@ -1791,36 +2310,51 @@ function removeLocaleProperty(component) {
1791
2310
  }
1792
2311
  }
1793
2312
  }
1794
- function localizeProperties(properties, locale) {
2313
+ function localizeProperties(node, locale, rules) {
2314
+ const properties = getPropertiesValue(node);
1795
2315
  if (!properties) {
1796
2316
  return void 0;
1797
2317
  }
1798
- Object.entries(properties).forEach(([key, property]) => {
1799
- var _a;
2318
+ Object.entries(properties).forEach(([propertyId, propertyValue]) => {
2319
+ var _a, _b;
1800
2320
  if (!locale) {
1801
- delete property.locales;
2321
+ delete propertyValue.locales;
2322
+ delete propertyValue.localesConditions;
1802
2323
  }
1803
- 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;
1804
2325
  if (currentLocaleValue !== void 0) {
1805
- property.value = currentLocaleValue;
2326
+ propertyValue.value = currentLocaleValue;
1806
2327
  }
1807
- delete property.locales;
1808
- if (property.value === void 0) {
1809
- delete properties[key];
2328
+ const currentLocaleConditionalValues = locale ? (_b = propertyValue.localesConditions) == null ? void 0 : _b[locale] : void 0;
2329
+ if (currentLocaleConditionalValues !== void 0) {
2330
+ propertyValue.conditions = currentLocaleConditionalValues;
1810
2331
  }
2332
+ delete propertyValue.locales;
2333
+ delete propertyValue.localesConditions;
2334
+ if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
2335
+ delete properties[propertyId];
2336
+ }
2337
+ });
2338
+ evaluateWalkTreePropertyCriteria({
2339
+ node,
2340
+ rules,
2341
+ keepIndeterminate: true
1811
2342
  });
1812
2343
  }
1813
2344
 
1814
2345
  // src/enhancement/UniqueBatchEntries.ts
1815
2346
  var UniqueBatchEntries = class {
1816
2347
  constructor(entries, uniqueKeySelector) {
1817
- this.groups = entries.reduce((acc, task) => {
1818
- var _a;
1819
- const key = uniqueKeySelector(task.args);
1820
- acc[key] = (_a = acc[key]) != null ? _a : [];
1821
- acc[key].push(task);
1822
- return acc;
1823
- }, {});
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
+ );
1824
2358
  }
1825
2359
  /** Resolves all entries in a group key with the same result value. */
1826
2360
  resolveKey(key, result) {
@@ -1850,8 +2384,7 @@ function walkComponentTree(component, visitor, initialContext) {
1850
2384
  const childContexts = /* @__PURE__ */ new Map();
1851
2385
  do {
1852
2386
  const currentQueueEntry = componentQueue.pop();
1853
- if (!currentQueueEntry)
1854
- continue;
2387
+ if (!currentQueueEntry) continue;
1855
2388
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1856
2389
  let visitDescendants = true;
1857
2390
  let descendantContext = (_a = childContexts.get(currentComponent.component)) != null ? _a : currentQueueEntry.context;
@@ -1956,10 +2489,25 @@ function walkComponentTree(component, visitor, initialContext) {
1956
2489
  } while (componentQueue.length > 0);
1957
2490
  }
1958
2491
 
1959
- // src/LocaleClient.ts
2492
+ // src/EntityReleasesClient.ts
1960
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");
1961
2509
  var localesUrl = "/api/v1/locales";
1962
- var LocaleClient = class extends import_api7.ApiClient {
2510
+ var LocaleClient = class extends import_api8.ApiClient {
1963
2511
  constructor(options) {
1964
2512
  super(options);
1965
2513
  }
@@ -2065,6 +2613,9 @@ var isRequestComponentSuggestionMessage = (message) => {
2065
2613
  var isSuggestComponentMessage = (message) => {
2066
2614
  return message.type === "suggest-component";
2067
2615
  };
2616
+ var isContextStorageUpdatedMessage = (message) => {
2617
+ return message.type === "context-storage-command-executed";
2618
+ };
2068
2619
  var createCanvasChannel = ({
2069
2620
  listenTo,
2070
2621
  broadcastTo
@@ -2074,6 +2625,12 @@ var createCanvasChannel = ({
2074
2625
  const broadcastToItems = [...broadcastTo];
2075
2626
  const postMessage = (message) => {
2076
2627
  broadcastToItems.forEach((item) => item == null ? void 0 : item.postMessage(JSON.stringify(message), "*"));
2628
+ for (const handlerId in handlers) {
2629
+ const handler = handlers[handlerId];
2630
+ if (handler.types.includes(message.type)) {
2631
+ handler.handler(message, new MessageEvent(message.type));
2632
+ }
2633
+ }
2077
2634
  };
2078
2635
  const selectComponent = (id) => {
2079
2636
  const message = {
@@ -2114,15 +2671,17 @@ var createCanvasChannel = ({
2114
2671
  hash: generateHash({
2115
2672
  composition,
2116
2673
  secret
2117
- })
2674
+ }),
2675
+ eventTimestamp: Date.now()
2118
2676
  };
2119
2677
  postMessage(message);
2120
2678
  };
2121
- const updateCompositionInternal = (composition, hash) => {
2679
+ const updateCompositionInternal = (composition, hash, eventTimestamp) => {
2122
2680
  const message = {
2123
2681
  type: "update-composition-internal",
2124
2682
  composition,
2125
- hash
2683
+ hash,
2684
+ eventTimestamp: eventTimestamp != null ? eventTimestamp : Date.now()
2126
2685
  };
2127
2686
  postMessage(message);
2128
2687
  };
@@ -2237,6 +2796,13 @@ var createCanvasChannel = ({
2237
2796
  };
2238
2797
  postMessage(message);
2239
2798
  };
2799
+ const contextStorageUpdated = (options) => {
2800
+ const message = {
2801
+ ...options,
2802
+ type: "context-storage-command-executed"
2803
+ };
2804
+ postMessage(message);
2805
+ };
2240
2806
  const messageEventListener = (event) => {
2241
2807
  if (typeof event.data !== "string") {
2242
2808
  return;
@@ -2264,6 +2830,7 @@ var createCanvasChannel = ({
2264
2830
  listenTo.forEach((item) => item.removeEventListener("message", messageEventListener));
2265
2831
  };
2266
2832
  return {
2833
+ broadcastTo,
2267
2834
  ready,
2268
2835
  destroy,
2269
2836
  triggerComponentAction,
@@ -2285,7 +2852,8 @@ var createCanvasChannel = ({
2285
2852
  editorStateUpdated,
2286
2853
  updateComponentReferences,
2287
2854
  requestComponentSuggestion,
2288
- suggestComponent
2855
+ suggestComponent,
2856
+ contextStorageUpdated
2289
2857
  };
2290
2858
  };
2291
2859
 
@@ -2368,9 +2936,9 @@ function subscribeToComposition({
2368
2936
  }
2369
2937
 
2370
2938
  // src/PromptClient.ts
2371
- var import_api8 = require("@uniformdev/context/api");
2939
+ var import_api9 = require("@uniformdev/context/api");
2372
2940
  var PromptsUrl = "/api/v1/prompts";
2373
- var PromptClient = class extends import_api8.ApiClient {
2941
+ var PromptClient = class extends import_api9.ApiClient {
2374
2942
  constructor(options) {
2375
2943
  super(options);
2376
2944
  }
@@ -2401,9 +2969,9 @@ var PromptClient = class extends import_api8.ApiClient {
2401
2969
  };
2402
2970
 
2403
2971
  // src/RelationshipClient.ts
2404
- var import_api9 = require("@uniformdev/context/api");
2972
+ var import_api10 = require("@uniformdev/context/api");
2405
2973
  var RELATIONSHIPS_URL = "/api/v1/relationships";
2406
- var RelationshipClient = class extends import_api9.ApiClient {
2974
+ var RelationshipClient = class extends import_api10.ApiClient {
2407
2975
  constructor(options) {
2408
2976
  super(options);
2409
2977
  this.get = async (options) => {
@@ -2411,56 +2979,13 @@ var RelationshipClient = class extends import_api9.ApiClient {
2411
2979
  const url = this.createUrl(RELATIONSHIPS_URL, { ...options, projectId });
2412
2980
  return this.apiClient(url);
2413
2981
  };
2414
- this.clearProjectRelationships = async () => {
2415
- const { projectId } = this.options;
2416
- const url = this.createUrl(RELATIONSHIPS_URL);
2417
- return this.apiClient(url, {
2418
- method: "POST",
2419
- body: JSON.stringify({
2420
- action: "clear",
2421
- projectId
2422
- })
2423
- });
2424
- };
2425
- this.indexRelationships = async ({ state, id, type }) => {
2426
- const { projectId } = this.options;
2427
- const url = this.createUrl(RELATIONSHIPS_URL);
2428
- return this.apiClient(url, {
2429
- method: "POST",
2430
- body: JSON.stringify({
2431
- action: "index",
2432
- type,
2433
- projectId,
2434
- state,
2435
- id
2436
- })
2437
- });
2438
- };
2439
- this.getVersion = async () => {
2440
- const { projectId } = this.options;
2441
- const url = this.createUrl("/api/v1/usage-tracking", {
2442
- projectId
2443
- });
2444
- return this.apiClient(url).then((response) => response.version);
2445
- };
2446
- this.setVersion = async (version) => {
2447
- const { projectId } = this.options;
2448
- const url = this.createUrl("/api/v1/usage-tracking");
2449
- return this.apiClient(url, {
2450
- method: "POST",
2451
- body: JSON.stringify({
2452
- projectId,
2453
- version
2454
- })
2455
- });
2456
- };
2457
2982
  }
2458
2983
  };
2459
2984
 
2460
2985
  // src/ReleaseClient.ts
2461
- var import_api10 = require("@uniformdev/context/api");
2986
+ var import_api11 = require("@uniformdev/context/api");
2462
2987
  var releasesUrl = "/api/v1/releases";
2463
- var ReleaseClient = class extends import_api10.ApiClient {
2988
+ var ReleaseClient = class extends import_api11.ApiClient {
2464
2989
  constructor(options) {
2465
2990
  super(options);
2466
2991
  }
@@ -2500,21 +3025,21 @@ var ReleaseClient = class extends import_api10.ApiClient {
2500
3025
  };
2501
3026
 
2502
3027
  // src/ReleaseContentsClient.ts
2503
- var import_api11 = require("@uniformdev/context/api");
2504
- var releaseContentsUrl = "/api/v1/release-contents";
2505
- 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 {
2506
3031
  constructor(options) {
2507
3032
  super(options);
2508
3033
  }
2509
3034
  /** Fetches all entities added to a release */
2510
3035
  async get(options) {
2511
3036
  const { projectId } = this.options;
2512
- const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
3037
+ const fetchUri = this.createUrl(releaseContentsUrl2, { ...options, projectId });
2513
3038
  return await this.apiClient(fetchUri);
2514
3039
  }
2515
3040
  /** Removes a release content from a release */
2516
3041
  async remove(body) {
2517
- const fetchUri = this.createUrl(releaseContentsUrl);
3042
+ const fetchUri = this.createUrl(releaseContentsUrl2);
2518
3043
  await this.apiClient(fetchUri, {
2519
3044
  method: "DELETE",
2520
3045
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -2524,9 +3049,9 @@ var ReleaseContentsClient = class extends import_api11.ApiClient {
2524
3049
  };
2525
3050
 
2526
3051
  // src/RouteClient.ts
2527
- var import_api12 = require("@uniformdev/context/api");
3052
+ var import_api13 = require("@uniformdev/context/api");
2528
3053
  var ROUTE_URL = "/api/v1/route";
2529
- var RouteClient = class extends import_api12.ApiClient {
3054
+ var RouteClient = class extends import_api13.ApiClient {
2530
3055
  constructor(options) {
2531
3056
  var _a;
2532
3057
  if (!options.limitPolicy) {
@@ -2589,7 +3114,9 @@ function convertEntryToPutEntry(entry) {
2589
3114
  pattern: entry.pattern,
2590
3115
  state: entry.state,
2591
3116
  projectId: entry.projectId,
2592
- releaseId: entry.releaseId
3117
+ releaseId: entry.releaseId,
3118
+ workflowId: entry.workflowId,
3119
+ workflowStageId: entry.workflowStageId
2593
3120
  };
2594
3121
  }
2595
3122
 
@@ -2635,8 +3162,7 @@ var isSystemComponentDefinition = (componentType) => {
2635
3162
 
2636
3163
  // src/utils/mapSlotToPersonalizedVariations.ts
2637
3164
  function mapSlotToPersonalizedVariations(slot) {
2638
- if (!slot)
2639
- return [];
3165
+ if (!slot) return [];
2640
3166
  return slot.map((v, i) => {
2641
3167
  var _a, _b;
2642
3168
  const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b.value;
@@ -2651,8 +3177,7 @@ function mapSlotToPersonalizedVariations(slot) {
2651
3177
 
2652
3178
  // src/utils/mapSlotToTestVariations.ts
2653
3179
  function mapSlotToTestVariations(slot) {
2654
- if (!slot)
2655
- return [];
3180
+ if (!slot) return [];
2656
3181
  return slot.map((v, i) => {
2657
3182
  var _a, _b, _c;
2658
3183
  const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b.value;
@@ -2677,7 +3202,7 @@ var isComponentPlaceholderId = (id) => {
2677
3202
  return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
2678
3203
  };
2679
3204
  var generateComponentPlaceholderId = (randomId, sdkVersion, parent) => {
2680
- if (typeof sdkVersion === "undefined" || sdkVersion === 1) {
3205
+ if (sdkVersion === 1) {
2681
3206
  return PLACEHOLDER_ID;
2682
3207
  }
2683
3208
  let idParts = [PLACEHOLDER_ID, randomId];
@@ -2703,72 +3228,6 @@ var parseComponentPlaceholderId = (id) => {
2703
3228
  return result;
2704
3229
  };
2705
3230
 
2706
- // src/utils/variables/parseVariableExpression.ts
2707
- var escapeCharacter = "\\";
2708
- var variablePrefix = "${";
2709
- var variableSuffix = "}";
2710
- function parseVariableExpression(serialized, onToken) {
2711
- let bufferStartIndex = 0;
2712
- let bufferEndIndex = 0;
2713
- let tokenCount = 0;
2714
- const handleToken = (token, type) => {
2715
- tokenCount++;
2716
- return onToken == null ? void 0 : onToken(token, type);
2717
- };
2718
- let state = "text";
2719
- for (let index = 0; index < serialized.length; index++) {
2720
- const char = serialized[index];
2721
- if (bufferStartIndex > bufferEndIndex) {
2722
- bufferEndIndex = bufferStartIndex;
2723
- }
2724
- if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
2725
- if (serialized[index - 1] === escapeCharacter) {
2726
- bufferEndIndex -= escapeCharacter.length;
2727
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
2728
- return tokenCount;
2729
- }
2730
- bufferStartIndex = index;
2731
- bufferEndIndex = index + 1;
2732
- continue;
2733
- }
2734
- state = "variable";
2735
- if (bufferEndIndex > bufferStartIndex) {
2736
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
2737
- return tokenCount;
2738
- }
2739
- bufferStartIndex = bufferEndIndex;
2740
- }
2741
- index += variablePrefix.length - 1;
2742
- bufferStartIndex += variablePrefix.length;
2743
- continue;
2744
- }
2745
- if (char === variableSuffix && state === "variable") {
2746
- if (serialized[index - 1] === escapeCharacter) {
2747
- bufferEndIndex++;
2748
- continue;
2749
- }
2750
- state = "text";
2751
- if (bufferEndIndex > bufferStartIndex) {
2752
- const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
2753
- if (handleToken(unescapedVariableName, "variable") === false) {
2754
- return tokenCount;
2755
- }
2756
- bufferStartIndex = bufferEndIndex + variableSuffix.length;
2757
- }
2758
- continue;
2759
- }
2760
- bufferEndIndex++;
2761
- }
2762
- if (bufferEndIndex > bufferStartIndex) {
2763
- if (state === "variable") {
2764
- state = "text";
2765
- bufferStartIndex -= variablePrefix.length;
2766
- }
2767
- handleToken(serialized.substring(bufferStartIndex), state);
2768
- }
2769
- return tokenCount;
2770
- }
2771
-
2772
3231
  // src/utils/variables/bindVariables.ts
2773
3232
  function bindVariables({
2774
3233
  variables,
@@ -2834,7 +3293,11 @@ function bindVariablesToObjectRecursive({
2834
3293
  if (richTextNodeResult !== void 0) {
2835
3294
  return richTextNodeResult;
2836
3295
  }
2837
- 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) => {
2838
3301
  Object.entries(draft).forEach(([property, oldValue]) => {
2839
3302
  const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
2840
3303
  if (typeof oldValue === "string") {
@@ -2891,8 +3354,43 @@ function handleRichTextNodeBinding(object, options) {
2891
3354
  }
2892
3355
 
2893
3356
  // src/index.ts
2894
- var import_api13 = require("@uniformdev/context/api");
2895
- var CanvasClientError = import_api13.ApiClientError;
3357
+ var import_api15 = require("@uniformdev/context/api");
3358
+
3359
+ // src/WorkflowClient.ts
3360
+ var import_api14 = require("@uniformdev/context/api");
3361
+ var workflowsUrl = "/api/v1/workflows";
3362
+ var WorkflowClient = class extends import_api14.ApiClient {
3363
+ constructor(options) {
3364
+ super(options);
3365
+ }
3366
+ /** Fetches workflows for a project */
3367
+ async get(options) {
3368
+ const { projectId } = this.options;
3369
+ const fetchUri = this.createUrl(workflowsUrl, { ...options, projectId });
3370
+ return await this.apiClient(fetchUri);
3371
+ }
3372
+ /** Updates or creates a workflow definition */
3373
+ async upsert(body) {
3374
+ const fetchUri = this.createUrl(workflowsUrl);
3375
+ await this.apiClient(fetchUri, {
3376
+ method: "PUT",
3377
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
3378
+ expectNoContent: true
3379
+ });
3380
+ }
3381
+ /** Deletes a workflow definition */
3382
+ async remove(body) {
3383
+ const fetchUri = this.createUrl(workflowsUrl);
3384
+ await this.apiClient(fetchUri, {
3385
+ method: "DELETE",
3386
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
3387
+ expectNoContent: true
3388
+ });
3389
+ }
3390
+ };
3391
+
3392
+ // src/index.ts
3393
+ var CanvasClientError = import_api15.ApiClientError;
2896
3394
  // Annotate the CommonJS export names for ESM import in node:
2897
3395
  0 && (module.exports = {
2898
3396
  ASSETS_SOURCE_CUSTOM_URL,
@@ -2906,6 +3404,7 @@ var CanvasClientError = import_api13.ApiClientError;
2906
3404
  ATTRIBUTE_PLACEHOLDER,
2907
3405
  ApiClientError,
2908
3406
  BatchEntry,
3407
+ BlockFormatError,
2909
3408
  CANVAS_BLOCK_PARAM_TYPE,
2910
3409
  CANVAS_DRAFT_STATE,
2911
3410
  CANVAS_EDITOR_STATE,
@@ -2923,6 +3422,11 @@ var CanvasClientError = import_api13.ApiClientError;
2923
3422
  CANVAS_TEST_SLOT,
2924
3423
  CANVAS_TEST_TYPE,
2925
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,
2926
3430
  CanvasClient,
2927
3431
  CanvasClientError,
2928
3432
  CategoryClient,
@@ -2936,6 +3440,7 @@ var CanvasClientError = import_api13.ApiClientError;
2936
3440
  EDGE_MIN_CACHE_TTL,
2937
3441
  EMPTY_COMPOSITION,
2938
3442
  EnhancerBuilder,
3443
+ EntityReleasesClient,
2939
3444
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
2940
3445
  IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
2941
3446
  IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
@@ -2957,17 +3462,27 @@ var CanvasClientError = import_api13.ApiClientError;
2957
3462
  UncachedCategoryClient,
2958
3463
  UncachedContentClient,
2959
3464
  UniqueBatchEntries,
3465
+ WorkflowClient,
2960
3466
  bindVariables,
2961
3467
  bindVariablesToObject,
2962
3468
  compose,
2963
3469
  convertEntryToPutEntry,
2964
3470
  createBatchEnhancer,
2965
3471
  createCanvasChannel,
3472
+ createDynamicInputVisibilityRule,
3473
+ createDynamicTokenVisibilityRule,
2966
3474
  createEventBus,
2967
3475
  createLimitPolicy,
3476
+ createLocaleVisibilityRule,
3477
+ createQuirksVisibilityRule,
2968
3478
  createUniformApiEnhancer,
2969
3479
  createVariableReference,
2970
3480
  enhance,
3481
+ evaluateNodeVisibilityParameter,
3482
+ evaluatePropertyCriteria,
3483
+ evaluateVisibilityCriteriaGroup,
3484
+ evaluateWalkTreeNodeVisibility,
3485
+ evaluateWalkTreePropertyCriteria,
2971
3486
  extractLocales,
2972
3487
  findParameterInNodeTree,
2973
3488
  flattenValues,
@@ -2977,19 +3492,23 @@ var CanvasClientError = import_api13.ApiClientError;
2977
3492
  getChannelName,
2978
3493
  getComponentJsonPointer,
2979
3494
  getComponentPath,
3495
+ getLocalizedPropertyValues,
2980
3496
  getNounForLocation,
2981
3497
  getNounForNode,
2982
3498
  getParameterAttributes,
2983
3499
  getPropertiesValue,
2984
3500
  getPropertyValue,
3501
+ hasReferencedVariables,
2985
3502
  isAddComponentMessage,
2986
3503
  isAllowedReferrer,
2987
3504
  isAssetParamValue,
2988
3505
  isAssetParamValueItem,
2989
3506
  isComponentActionMessage,
2990
3507
  isComponentPlaceholderId,
3508
+ isContextStorageUpdatedMessage,
2991
3509
  isDismissPlaceholderMessage,
2992
3510
  isEntryData,
3511
+ isLinkParamValue,
2993
3512
  isMovingComponentMessage,
2994
3513
  isNestedNodeType,
2995
3514
  isOpenParameterEditorMessage,