@uniformdev/canvas 19.162.2-alpha.11 → 19.164.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1608,198 +1608,6 @@ function findParameterInNodeTree(data, predicate) {
1608
1608
  return results;
1609
1609
  }
1610
1610
 
1611
- // src/enhancement/visibility/evaluateVisibilityCriteriaGroup.ts
1612
- function evaluateVisibilityCriteriaGroup(options) {
1613
- const { criteriaGroup, simplifyCriteria } = options;
1614
- const earlyExitResult = criteriaGroup.op === "&" || !criteriaGroup.op ? false : true;
1615
- let hasIndeterminateClauses = false;
1616
- for (let index = criteriaGroup.clauses.length - 1; index >= 0; index--) {
1617
- const clause = criteriaGroup.clauses[index];
1618
- const criteriaResult = evaluateCriterion(clause, options);
1619
- if (criteriaResult === null) {
1620
- hasIndeterminateClauses = true;
1621
- } else if (criteriaResult === earlyExitResult) {
1622
- return earlyExitResult;
1623
- } else if (criteriaResult !== null && simplifyCriteria) {
1624
- criteriaGroup.clauses.splice(index, 1);
1625
- }
1626
- }
1627
- return hasIndeterminateClauses ? null : !earlyExitResult;
1628
- }
1629
- function evaluateCriterion(clause, rootOptions) {
1630
- if ("clauses" in clause) {
1631
- return evaluateVisibilityCriteriaGroup({
1632
- ...rootOptions,
1633
- criteriaGroup: clause
1634
- });
1635
- }
1636
- const rule = rootOptions.rules[clause.rule];
1637
- if (rule) {
1638
- return rule(clause);
1639
- }
1640
- return null;
1641
- }
1642
-
1643
- // src/enhancement/visibility/types.ts
1644
- var CANVAS_VIZ_CONTROL_PARAM = "$viz";
1645
-
1646
- // src/enhancement/visibility/evaluateNodeVisibility.ts
1647
- function evaluateNodeVisibility({
1648
- node,
1649
- ...evaluateGroupOptions
1650
- }) {
1651
- var _a;
1652
- const properties = getPropertiesValue(node);
1653
- const vizCriteria = (_a = properties == null ? void 0 : properties[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _a.value;
1654
- if (vizCriteria == null ? void 0 : vizCriteria.explicitlyHidden) {
1655
- return false;
1656
- }
1657
- if (!(vizCriteria == null ? void 0 : vizCriteria.criteria)) {
1658
- return true;
1659
- }
1660
- const result = evaluateVisibilityCriteriaGroup({
1661
- ...evaluateGroupOptions,
1662
- criteriaGroup: vizCriteria.criteria
1663
- });
1664
- if (vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
1665
- properties == null ? true : delete properties[CANVAS_VIZ_CONTROL_PARAM];
1666
- }
1667
- return result;
1668
- }
1669
-
1670
- // src/enhancement/visibility/evaluateWalkTreeVisibility.ts
1671
- function evaluateWalkTreeVisibility({
1672
- rules,
1673
- showIndeterminate,
1674
- context
1675
- }) {
1676
- const { type, node, actions } = context;
1677
- if (type !== "component") {
1678
- return;
1679
- }
1680
- const result = evaluateNodeVisibility({ node, rules, simplifyCriteria: true });
1681
- if (result === null && !showIndeterminate || result === false) {
1682
- actions.remove();
1683
- return false;
1684
- }
1685
- return true;
1686
- }
1687
-
1688
- // src/enhancement/visibility/rules/evaluateStringMatch.ts
1689
- var isEvaluator = (criteria, matchValue) => {
1690
- if (Array.isArray(criteria)) {
1691
- return criteria.includes(matchValue);
1692
- }
1693
- return criteria === matchValue;
1694
- };
1695
- var containsEvaluator = (criteria, matchValue) => {
1696
- if (Array.isArray(criteria)) {
1697
- return criteria.some((criterion) => matchValue.includes(criterion));
1698
- }
1699
- return matchValue.includes(criteria);
1700
- };
1701
- var startsWithEvaluator = (criteria, matchValue) => {
1702
- if (Array.isArray(criteria)) {
1703
- return criteria.some((criterion) => matchValue.startsWith(criterion));
1704
- }
1705
- return matchValue.startsWith(criteria);
1706
- };
1707
- var endsWithEvaluator = (criteria, matchValue) => {
1708
- if (Array.isArray(criteria)) {
1709
- return criteria.some((criterion) => matchValue.endsWith(criterion));
1710
- }
1711
- return matchValue.endsWith(criteria);
1712
- };
1713
- var emptyEvaluator = (_, matchValue) => {
1714
- return matchValue === "";
1715
- };
1716
- var stringOperatorEvaluators = {
1717
- is: isEvaluator,
1718
- has: containsEvaluator,
1719
- startswith: startsWithEvaluator,
1720
- endswith: endsWithEvaluator,
1721
- empty: emptyEvaluator
1722
- };
1723
- function evaluateStringMatch(criteria, matchValue, allow) {
1724
- const { op, value } = criteria;
1725
- if (allow && !allow.has(op)) {
1726
- return null;
1727
- }
1728
- let opMatch = op;
1729
- const negation = op.startsWith("!");
1730
- if (negation) {
1731
- opMatch = opMatch.slice(1);
1732
- }
1733
- const evaluator = stringOperatorEvaluators[opMatch];
1734
- if (!evaluator) {
1735
- return null;
1736
- }
1737
- const result = evaluator(value, matchValue);
1738
- return negation ? !result : result;
1739
- }
1740
-
1741
- // src/enhancement/visibility/rules/dynamicInputVisibilityRule.ts
1742
- var dynamicInputVisibilityOperators = /* @__PURE__ */ new Set([
1743
- "is",
1744
- "!is",
1745
- "has",
1746
- "!has",
1747
- "startswith",
1748
- "!startswith",
1749
- "endswith",
1750
- "!endswith",
1751
- "empty",
1752
- "!empty"
1753
- ]);
1754
- var CANVAS_VIZ_DI_RULE = "$di";
1755
- function createDynamicInputVisibilityRule(dynamicInputs) {
1756
- return {
1757
- [CANVAS_VIZ_DI_RULE]: (criterion) => {
1758
- const { source } = criterion;
1759
- const diValue = source ? dynamicInputs[source] : void 0;
1760
- return evaluateStringMatch(criterion, diValue != null ? diValue : "", dynamicInputVisibilityOperators);
1761
- }
1762
- };
1763
- }
1764
-
1765
- // src/enhancement/visibility/rules/localeVisibilityRule.ts
1766
- var localeVisibilityOperators = /* @__PURE__ */ new Set(["is", "!is"]);
1767
- var CANVAS_VIZ_LOCALE_RULE = "$locale";
1768
- function createLocaleVisibilityRule(currentLocale) {
1769
- return {
1770
- [CANVAS_VIZ_LOCALE_RULE]: (criterion) => {
1771
- if (!currentLocale) {
1772
- return false;
1773
- }
1774
- return evaluateStringMatch(criterion, currentLocale, localeVisibilityOperators);
1775
- }
1776
- };
1777
- }
1778
-
1779
- // src/enhancement/visibility/rules/quirksRule.ts
1780
- var quirksVisibilityOperators = /* @__PURE__ */ new Set([
1781
- "is",
1782
- "!is",
1783
- "has",
1784
- "!has",
1785
- "startswith",
1786
- "!startswith",
1787
- "endswith",
1788
- "!endswith",
1789
- "empty",
1790
- "!empty"
1791
- ]);
1792
- var CANVAS_VIZ_QUIRKS_RULE = "$qk";
1793
- function createQuirksVisibilityRule(quirks) {
1794
- return {
1795
- [CANVAS_VIZ_QUIRKS_RULE]: (criterion) => {
1796
- const { source } = criterion;
1797
- const quirkValue = source ? quirks[source] : void 0;
1798
- return evaluateStringMatch(criterion, quirkValue != null ? quirkValue : "", quirksVisibilityOperators);
1799
- }
1800
- };
1801
- }
1802
-
1803
1611
  // src/enhancement/localize.ts
1804
1612
  function extractLocales({ component }) {
1805
1613
  var _a;
@@ -1818,29 +1626,17 @@ function extractLocales({ component }) {
1818
1626
  function localize(options) {
1819
1627
  const nodes = "nodes" in options ? options.nodes : options.composition;
1820
1628
  const locale = options.locale;
1821
- const isUsingModernOptions = typeof locale === "string";
1822
- const vizControlLocaleRule = isUsingModernOptions ? createLocaleVisibilityRule(locale) : {};
1823
- walkNodeTree(nodes, (context) => {
1824
- const { type, node, actions } = context;
1629
+ walkNodeTree(nodes, ({ type, node, actions }) => {
1825
1630
  if (type !== "component") {
1826
- if (isUsingModernOptions) {
1631
+ if (typeof locale === "string") {
1827
1632
  localizeProperties(node.fields, locale);
1828
1633
  }
1829
1634
  return;
1830
1635
  }
1831
- if (isUsingModernOptions) {
1832
- const result = evaluateWalkTreeVisibility({
1833
- context,
1834
- rules: vizControlLocaleRule,
1835
- showIndeterminate: true
1836
- });
1837
- if (!result) {
1838
- return;
1839
- }
1840
- }
1636
+ const shouldRunPropertyLocalization = typeof locale === "string";
1841
1637
  if (node.type === CANVAS_LOCALIZATION_TYPE) {
1842
1638
  const locales = extractLocales({ component: node });
1843
- const resolvedLocale = isUsingModernOptions ? locale : locale == null ? void 0 : locale({ component: node, locales });
1639
+ const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
1844
1640
  let replaceComponent;
1845
1641
  if (resolvedLocale) {
1846
1642
  replaceComponent = locales[resolvedLocale];
@@ -1848,7 +1644,7 @@ function localize(options) {
1848
1644
  if (replaceComponent == null ? void 0 : replaceComponent.length) {
1849
1645
  replaceComponent.forEach((component) => {
1850
1646
  removeLocaleProperty(component);
1851
- if (isUsingModernOptions) {
1647
+ if (shouldRunPropertyLocalization) {
1852
1648
  localizeProperties(getPropertiesValue(component), locale);
1853
1649
  }
1854
1650
  });
@@ -1860,7 +1656,7 @@ function localize(options) {
1860
1656
  } else {
1861
1657
  actions.remove();
1862
1658
  }
1863
- } else if (isUsingModernOptions) {
1659
+ } else if (shouldRunPropertyLocalization) {
1864
1660
  localizeProperties(getPropertiesValue(node), locale);
1865
1661
  }
1866
1662
  });
@@ -2045,10 +1841,25 @@ function walkComponentTree(component, visitor, initialContext) {
2045
1841
  } while (componentQueue.length > 0);
2046
1842
  }
2047
1843
 
2048
- // src/LocaleClient.ts
1844
+ // src/EntityReleasesClient.ts
2049
1845
  import { ApiClient as ApiClient6 } from "@uniformdev/context/api";
1846
+ var releaseContentsUrl = "/api/v1/entity-releases";
1847
+ var EntityReleasesClient = class extends ApiClient6 {
1848
+ constructor(options) {
1849
+ super(options);
1850
+ }
1851
+ /** Fetches entity across all releases (and base) */
1852
+ async get(options) {
1853
+ const { projectId } = this.options;
1854
+ const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
1855
+ return await this.apiClient(fetchUri);
1856
+ }
1857
+ };
1858
+
1859
+ // src/LocaleClient.ts
1860
+ import { ApiClient as ApiClient7 } from "@uniformdev/context/api";
2050
1861
  var localesUrl = "/api/v1/locales";
2051
- var LocaleClient = class extends ApiClient6 {
1862
+ var LocaleClient = class extends ApiClient7 {
2052
1863
  constructor(options) {
2053
1864
  super(options);
2054
1865
  }
@@ -2154,9 +1965,6 @@ var isRequestComponentSuggestionMessage = (message) => {
2154
1965
  var isSuggestComponentMessage = (message) => {
2155
1966
  return message.type === "suggest-component";
2156
1967
  };
2157
- var isContextStorageUpdatedMessage = (message) => {
2158
- return message.type === "context-storage-command-executed";
2159
- };
2160
1968
  var createCanvasChannel = ({
2161
1969
  listenTo,
2162
1970
  broadcastTo
@@ -2337,13 +2145,6 @@ var createCanvasChannel = ({
2337
2145
  };
2338
2146
  postMessage(message);
2339
2147
  };
2340
- const contextStorageUpdated = (options) => {
2341
- const message = {
2342
- ...options,
2343
- type: "context-storage-command-executed"
2344
- };
2345
- postMessage(message);
2346
- };
2347
2148
  const messageEventListener = (event) => {
2348
2149
  if (typeof event.data !== "string") {
2349
2150
  return;
@@ -2393,8 +2194,7 @@ var createCanvasChannel = ({
2393
2194
  editorStateUpdated,
2394
2195
  updateComponentReferences,
2395
2196
  requestComponentSuggestion,
2396
- suggestComponent,
2397
- contextStorageUpdated
2197
+ suggestComponent
2398
2198
  };
2399
2199
  };
2400
2200
 
@@ -2477,9 +2277,9 @@ function subscribeToComposition({
2477
2277
  }
2478
2278
 
2479
2279
  // src/PromptClient.ts
2480
- import { ApiClient as ApiClient7 } from "@uniformdev/context/api";
2280
+ import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
2481
2281
  var PromptsUrl = "/api/v1/prompts";
2482
- var PromptClient = class extends ApiClient7 {
2282
+ var PromptClient = class extends ApiClient8 {
2483
2283
  constructor(options) {
2484
2284
  super(options);
2485
2285
  }
@@ -2510,9 +2310,9 @@ var PromptClient = class extends ApiClient7 {
2510
2310
  };
2511
2311
 
2512
2312
  // src/RelationshipClient.ts
2513
- import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
2313
+ import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
2514
2314
  var RELATIONSHIPS_URL = "/api/v1/relationships";
2515
- var RelationshipClient = class extends ApiClient8 {
2315
+ var RelationshipClient = class extends ApiClient9 {
2516
2316
  constructor(options) {
2517
2317
  super(options);
2518
2318
  this.get = async (options) => {
@@ -2524,9 +2324,9 @@ var RelationshipClient = class extends ApiClient8 {
2524
2324
  };
2525
2325
 
2526
2326
  // src/ReleaseClient.ts
2527
- import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
2327
+ import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
2528
2328
  var releasesUrl = "/api/v1/releases";
2529
- var ReleaseClient = class extends ApiClient9 {
2329
+ var ReleaseClient = class extends ApiClient10 {
2530
2330
  constructor(options) {
2531
2331
  super(options);
2532
2332
  }
@@ -2566,21 +2366,21 @@ var ReleaseClient = class extends ApiClient9 {
2566
2366
  };
2567
2367
 
2568
2368
  // src/ReleaseContentsClient.ts
2569
- import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
2570
- var releaseContentsUrl = "/api/v1/release-contents";
2571
- var ReleaseContentsClient = class extends ApiClient10 {
2369
+ import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
2370
+ var releaseContentsUrl2 = "/api/v1/release-contents";
2371
+ var ReleaseContentsClient = class extends ApiClient11 {
2572
2372
  constructor(options) {
2573
2373
  super(options);
2574
2374
  }
2575
2375
  /** Fetches all entities added to a release */
2576
2376
  async get(options) {
2577
2377
  const { projectId } = this.options;
2578
- const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
2378
+ const fetchUri = this.createUrl(releaseContentsUrl2, { ...options, projectId });
2579
2379
  return await this.apiClient(fetchUri);
2580
2380
  }
2581
2381
  /** Removes a release content from a release */
2582
2382
  async remove(body) {
2583
- const fetchUri = this.createUrl(releaseContentsUrl);
2383
+ const fetchUri = this.createUrl(releaseContentsUrl2);
2584
2384
  await this.apiClient(fetchUri, {
2585
2385
  method: "DELETE",
2586
2386
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -2590,9 +2390,9 @@ var ReleaseContentsClient = class extends ApiClient10 {
2590
2390
  };
2591
2391
 
2592
2392
  // src/RouteClient.ts
2593
- import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
2393
+ import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
2594
2394
  var ROUTE_URL = "/api/v1/route";
2595
- var RouteClient = class extends ApiClient11 {
2395
+ var RouteClient = class extends ApiClient12 {
2596
2396
  constructor(options) {
2597
2397
  var _a;
2598
2398
  if (!options.limitPolicy) {
@@ -2962,9 +2762,9 @@ function handleRichTextNodeBinding(object, options) {
2962
2762
  import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
2963
2763
 
2964
2764
  // src/WorkflowClient.ts
2965
- import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
2765
+ import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
2966
2766
  var workflowsUrl = "/api/v1/workflows";
2967
- var WorkflowClient = class extends ApiClient12 {
2767
+ var WorkflowClient = class extends ApiClient13 {
2968
2768
  constructor(options) {
2969
2769
  super(options);
2970
2770
  }
@@ -3025,10 +2825,6 @@ export {
3025
2825
  CANVAS_TEST_SLOT,
3026
2826
  CANVAS_TEST_TYPE,
3027
2827
  CANVAS_TEST_VARIANT_PARAM,
3028
- CANVAS_VIZ_CONTROL_PARAM,
3029
- CANVAS_VIZ_DI_RULE,
3030
- CANVAS_VIZ_LOCALE_RULE,
3031
- CANVAS_VIZ_QUIRKS_RULE,
3032
2828
  CanvasClient,
3033
2829
  CanvasClientError,
3034
2830
  CategoryClient,
@@ -3042,6 +2838,7 @@ export {
3042
2838
  EDGE_MIN_CACHE_TTL,
3043
2839
  EMPTY_COMPOSITION,
3044
2840
  EnhancerBuilder,
2841
+ EntityReleasesClient,
3045
2842
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
3046
2843
  IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
3047
2844
  IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
@@ -3070,16 +2867,11 @@ export {
3070
2867
  convertEntryToPutEntry,
3071
2868
  createBatchEnhancer,
3072
2869
  createCanvasChannel,
3073
- createDynamicInputVisibilityRule,
3074
2870
  createEventBus,
3075
2871
  createLimitPolicy,
3076
- createLocaleVisibilityRule,
3077
- createQuirksVisibilityRule,
3078
2872
  createUniformApiEnhancer,
3079
2873
  createVariableReference,
3080
2874
  enhance,
3081
- evaluateVisibilityCriteriaGroup,
3082
- evaluateWalkTreeVisibility,
3083
2875
  extractLocales,
3084
2876
  findParameterInNodeTree,
3085
2877
  flattenValues,
@@ -3101,7 +2893,6 @@ export {
3101
2893
  isAssetParamValueItem,
3102
2894
  isComponentActionMessage,
3103
2895
  isComponentPlaceholderId,
3104
- isContextStorageUpdatedMessage,
3105
2896
  isDismissPlaceholderMessage,
3106
2897
  isEntryData,
3107
2898
  isMovingComponentMessage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas",
3
- "version": "19.162.2-alpha.11+5544f3f2ca",
3
+ "version": "19.164.0",
4
4
  "description": "Common functionality and types for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -38,8 +38,8 @@
38
38
  "pusher-js": "8.2.0"
39
39
  },
40
40
  "dependencies": {
41
- "@uniformdev/assets": "19.162.2-alpha.11+5544f3f2ca",
42
- "@uniformdev/context": "19.162.2-alpha.11+5544f3f2ca",
41
+ "@uniformdev/assets": "19.164.0",
42
+ "@uniformdev/context": "19.164.0",
43
43
  "immer": "10.0.4"
44
44
  },
45
45
  "files": [
@@ -48,5 +48,5 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "gitHead": "5544f3f2ca31829767dbe8511c21b1192a811443"
51
+ "gitHead": "016e3b85373592ca9beb19593aa120247b638c06"
52
52
  }