@uniformdev/canvas 19.159.1-alpha.16 → 19.159.1-alpha.27
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.d.mts +108 -1
- package/dist/index.d.ts +108 -1
- package/dist/index.esm.js +204 -29
- package/dist/index.js +211 -29
- package/dist/index.mjs +204 -29
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
@@ -4,6 +4,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __typeError = (msg) => {
|
8
|
+
throw TypeError(msg);
|
9
|
+
};
|
7
10
|
var __commonJS = (cb, mod) => function __require() {
|
8
11
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
9
12
|
};
|
@@ -23,19 +26,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
23
26
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
24
27
|
mod
|
25
28
|
));
|
26
|
-
var __accessCheck = (obj, member, msg) =>
|
27
|
-
|
28
|
-
|
29
|
-
};
|
30
|
-
var __privateGet = (obj, member, getter) => {
|
31
|
-
__accessCheck(obj, member, "read from private field");
|
32
|
-
return getter ? getter.call(obj) : member.get(obj);
|
33
|
-
};
|
34
|
-
var __privateAdd = (obj, member, value) => {
|
35
|
-
if (member.has(obj))
|
36
|
-
throw TypeError("Cannot add the same private member more than once");
|
37
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
38
|
-
};
|
29
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
30
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
31
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
39
32
|
|
40
33
|
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
|
41
34
|
var require_retry_operation = __commonJS({
|
@@ -1050,8 +1043,7 @@ function walkNodeTree(node, visitor, options) {
|
|
1050
1043
|
const childContexts = /* @__PURE__ */ new Map();
|
1051
1044
|
do {
|
1052
1045
|
const currentQueueEntry = componentQueue.pop();
|
1053
|
-
if (!currentQueueEntry)
|
1054
|
-
continue;
|
1046
|
+
if (!currentQueueEntry) continue;
|
1055
1047
|
const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
|
1056
1048
|
let visitDescendants = true;
|
1057
1049
|
let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
|
@@ -1262,8 +1254,7 @@ function walkNodeTree(node, visitor, options) {
|
|
1262
1254
|
const propertyEntries = Object.entries(properties);
|
1263
1255
|
for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
|
1264
1256
|
const [propKey, propObject] = propertyEntries[propIndex];
|
1265
|
-
if (!isNestedNodeType(propObject.type))
|
1266
|
-
continue;
|
1257
|
+
if (!isNestedNodeType(propObject.type)) continue;
|
1267
1258
|
const blocks = (_b = propObject.value) != null ? _b : [];
|
1268
1259
|
for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
|
1269
1260
|
const enqueueingBlock = blocks[blockIndex];
|
@@ -1608,6 +1599,174 @@ function findParameterInNodeTree(data, predicate) {
|
|
1608
1599
|
return results;
|
1609
1600
|
}
|
1610
1601
|
|
1602
|
+
// src/enhancement/visibility/evaluateVisibilityCriteriaGroup.ts
|
1603
|
+
function evaluateVisibilityCriteriaGroup(options) {
|
1604
|
+
const { criteriaGroup, simplifyCriteria } = options;
|
1605
|
+
const earlyExitResult = criteriaGroup.op === "&" || !criteriaGroup.op ? false : true;
|
1606
|
+
let hasIndeterminateClauses = false;
|
1607
|
+
for (let index = criteriaGroup.clauses.length - 1; index >= 0; index--) {
|
1608
|
+
const clause = criteriaGroup.clauses[index];
|
1609
|
+
const criteriaResult = evaluateCriterion(clause, options);
|
1610
|
+
if (criteriaResult === null) {
|
1611
|
+
hasIndeterminateClauses = true;
|
1612
|
+
} else if (criteriaResult === earlyExitResult) {
|
1613
|
+
return earlyExitResult;
|
1614
|
+
} else if (criteriaResult !== null && simplifyCriteria) {
|
1615
|
+
criteriaGroup.clauses.splice(index, 1);
|
1616
|
+
}
|
1617
|
+
}
|
1618
|
+
return hasIndeterminateClauses ? null : !earlyExitResult;
|
1619
|
+
}
|
1620
|
+
function evaluateCriterion(clause, rootOptions) {
|
1621
|
+
if ("clauses" in clause) {
|
1622
|
+
return evaluateVisibilityCriteriaGroup({
|
1623
|
+
...rootOptions,
|
1624
|
+
criteriaGroup: clause
|
1625
|
+
});
|
1626
|
+
}
|
1627
|
+
const rule = rootOptions.rules[clause.rule];
|
1628
|
+
if (rule) {
|
1629
|
+
return rule(clause);
|
1630
|
+
}
|
1631
|
+
return null;
|
1632
|
+
}
|
1633
|
+
|
1634
|
+
// src/enhancement/visibility/types.ts
|
1635
|
+
var CANVAS_VIZ_CONTROL_PARAM = "$viz";
|
1636
|
+
|
1637
|
+
// src/enhancement/visibility/evaluateNodeVisibility.ts
|
1638
|
+
function evaluateNodeVisibility({
|
1639
|
+
node,
|
1640
|
+
...evaluateGroupOptions
|
1641
|
+
}) {
|
1642
|
+
var _a;
|
1643
|
+
const properties = getPropertiesValue(node);
|
1644
|
+
const vizCriteria = (_a = properties == null ? void 0 : properties[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _a.value;
|
1645
|
+
if (vizCriteria == null ? void 0 : vizCriteria.explicitlyHidden) {
|
1646
|
+
return false;
|
1647
|
+
}
|
1648
|
+
if (!(vizCriteria == null ? void 0 : vizCriteria.criteria)) {
|
1649
|
+
return true;
|
1650
|
+
}
|
1651
|
+
const result = evaluateVisibilityCriteriaGroup({
|
1652
|
+
...evaluateGroupOptions,
|
1653
|
+
criteriaGroup: vizCriteria.criteria
|
1654
|
+
});
|
1655
|
+
if (vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
|
1656
|
+
properties == null ? true : delete properties[CANVAS_VIZ_CONTROL_PARAM];
|
1657
|
+
}
|
1658
|
+
return result;
|
1659
|
+
}
|
1660
|
+
|
1661
|
+
// src/enhancement/visibility/evaluateWalkTreeVisibility.ts
|
1662
|
+
function evaluateWalkTreeVisibility({
|
1663
|
+
rules,
|
1664
|
+
showIndeterminate,
|
1665
|
+
context
|
1666
|
+
}) {
|
1667
|
+
const { type, node, actions } = context;
|
1668
|
+
if (type !== "component") {
|
1669
|
+
return;
|
1670
|
+
}
|
1671
|
+
const result = evaluateNodeVisibility({ node, rules, simplifyCriteria: true });
|
1672
|
+
if (result === null && !showIndeterminate || result === false) {
|
1673
|
+
actions.remove();
|
1674
|
+
return false;
|
1675
|
+
}
|
1676
|
+
return true;
|
1677
|
+
}
|
1678
|
+
|
1679
|
+
// src/enhancement/visibility/rules/evaluateStringMatch.ts
|
1680
|
+
var isEvaluator = (criteria, matchValue) => {
|
1681
|
+
if (Array.isArray(criteria)) {
|
1682
|
+
return criteria.includes(matchValue);
|
1683
|
+
}
|
1684
|
+
return criteria === matchValue;
|
1685
|
+
};
|
1686
|
+
var containsEvaluator = (criteria, matchValue) => {
|
1687
|
+
if (Array.isArray(criteria)) {
|
1688
|
+
return criteria.some((criterion) => matchValue.includes(criterion));
|
1689
|
+
}
|
1690
|
+
return matchValue.includes(criteria);
|
1691
|
+
};
|
1692
|
+
var startsWithEvaluator = (criteria, matchValue) => {
|
1693
|
+
if (Array.isArray(criteria)) {
|
1694
|
+
return criteria.some((criterion) => matchValue.startsWith(criterion));
|
1695
|
+
}
|
1696
|
+
return matchValue.startsWith(criteria);
|
1697
|
+
};
|
1698
|
+
var endsWithEvaluator = (criteria, matchValue) => {
|
1699
|
+
if (Array.isArray(criteria)) {
|
1700
|
+
return criteria.some((criterion) => matchValue.endsWith(criterion));
|
1701
|
+
}
|
1702
|
+
return matchValue.endsWith(criteria);
|
1703
|
+
};
|
1704
|
+
var emptyEvaluator = (_, matchValue) => {
|
1705
|
+
return matchValue === "";
|
1706
|
+
};
|
1707
|
+
var stringOperatorEvaluators = {
|
1708
|
+
is: isEvaluator,
|
1709
|
+
has: containsEvaluator,
|
1710
|
+
startswith: startsWithEvaluator,
|
1711
|
+
endswith: endsWithEvaluator,
|
1712
|
+
empty: emptyEvaluator
|
1713
|
+
};
|
1714
|
+
function evaluateStringMatch(criteria, matchValue, allow) {
|
1715
|
+
const { op, value } = criteria;
|
1716
|
+
if (allow && !allow.has(op)) {
|
1717
|
+
return null;
|
1718
|
+
}
|
1719
|
+
let opMatch = op;
|
1720
|
+
const negation = op.startsWith("!");
|
1721
|
+
if (negation) {
|
1722
|
+
opMatch = opMatch.slice(1);
|
1723
|
+
}
|
1724
|
+
const evaluator = stringOperatorEvaluators[opMatch];
|
1725
|
+
if (!evaluator) {
|
1726
|
+
return null;
|
1727
|
+
}
|
1728
|
+
const result = evaluator(value, matchValue);
|
1729
|
+
return negation ? !result : result;
|
1730
|
+
}
|
1731
|
+
|
1732
|
+
// src/enhancement/visibility/rules/dynamicInputVisibilityRule.ts
|
1733
|
+
var dynamicInputVisibilityOperators = /* @__PURE__ */ new Set([
|
1734
|
+
"is",
|
1735
|
+
"!is",
|
1736
|
+
"has",
|
1737
|
+
"!has",
|
1738
|
+
"startswith",
|
1739
|
+
"!startswith",
|
1740
|
+
"endswith",
|
1741
|
+
"!endswith",
|
1742
|
+
"empty",
|
1743
|
+
"!empty"
|
1744
|
+
]);
|
1745
|
+
var CANVAS_VIZ_DI_RULE = "$di";
|
1746
|
+
function createDynamicInputVisibilityRule(dynamicInputs) {
|
1747
|
+
return {
|
1748
|
+
[CANVAS_VIZ_DI_RULE]: (criterion) => {
|
1749
|
+
const { source } = criterion;
|
1750
|
+
const diValue = source ? dynamicInputs[source] : void 0;
|
1751
|
+
return evaluateStringMatch(criterion, diValue != null ? diValue : "", dynamicInputVisibilityOperators);
|
1752
|
+
}
|
1753
|
+
};
|
1754
|
+
}
|
1755
|
+
|
1756
|
+
// src/enhancement/visibility/rules/localeVisibilityRule.ts
|
1757
|
+
var localeVisibilityOperators = /* @__PURE__ */ new Set(["is", "!is"]);
|
1758
|
+
var CANVAS_VIZ_LOCALE_RULE = "$locale";
|
1759
|
+
function createLocaleVisibilityRule(currentLocale) {
|
1760
|
+
return {
|
1761
|
+
[CANVAS_VIZ_LOCALE_RULE]: (criterion) => {
|
1762
|
+
if (!currentLocale) {
|
1763
|
+
return false;
|
1764
|
+
}
|
1765
|
+
return evaluateStringMatch(criterion, currentLocale, localeVisibilityOperators);
|
1766
|
+
}
|
1767
|
+
};
|
1768
|
+
}
|
1769
|
+
|
1611
1770
|
// src/enhancement/localize.ts
|
1612
1771
|
function extractLocales({ component }) {
|
1613
1772
|
var _a;
|
@@ -1626,17 +1785,29 @@ function extractLocales({ component }) {
|
|
1626
1785
|
function localize(options) {
|
1627
1786
|
const nodes = "nodes" in options ? options.nodes : options.composition;
|
1628
1787
|
const locale = options.locale;
|
1629
|
-
|
1788
|
+
const isUsingModernOptions = typeof locale === "string";
|
1789
|
+
const vizControlLocaleRule = isUsingModernOptions ? createLocaleVisibilityRule(locale) : {};
|
1790
|
+
walkNodeTree(nodes, (context) => {
|
1791
|
+
const { type, node, actions } = context;
|
1630
1792
|
if (type !== "component") {
|
1631
|
-
if (
|
1793
|
+
if (isUsingModernOptions) {
|
1632
1794
|
localizeProperties(node.fields, locale);
|
1633
1795
|
}
|
1634
1796
|
return;
|
1635
1797
|
}
|
1636
|
-
|
1798
|
+
if (isUsingModernOptions) {
|
1799
|
+
const result = evaluateWalkTreeVisibility({
|
1800
|
+
context,
|
1801
|
+
rules: vizControlLocaleRule,
|
1802
|
+
showIndeterminate: true
|
1803
|
+
});
|
1804
|
+
if (!result) {
|
1805
|
+
return;
|
1806
|
+
}
|
1807
|
+
}
|
1637
1808
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
1638
1809
|
const locales = extractLocales({ component: node });
|
1639
|
-
const resolvedLocale =
|
1810
|
+
const resolvedLocale = isUsingModernOptions ? locale : locale == null ? void 0 : locale({ component: node, locales });
|
1640
1811
|
let replaceComponent;
|
1641
1812
|
if (resolvedLocale) {
|
1642
1813
|
replaceComponent = locales[resolvedLocale];
|
@@ -1644,7 +1815,7 @@ function localize(options) {
|
|
1644
1815
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
1645
1816
|
replaceComponent.forEach((component) => {
|
1646
1817
|
removeLocaleProperty(component);
|
1647
|
-
if (
|
1818
|
+
if (isUsingModernOptions) {
|
1648
1819
|
localizeProperties(getPropertiesValue(component), locale);
|
1649
1820
|
}
|
1650
1821
|
});
|
@@ -1656,7 +1827,7 @@ function localize(options) {
|
|
1656
1827
|
} else {
|
1657
1828
|
actions.remove();
|
1658
1829
|
}
|
1659
|
-
} else if (
|
1830
|
+
} else if (isUsingModernOptions) {
|
1660
1831
|
localizeProperties(getPropertiesValue(node), locale);
|
1661
1832
|
}
|
1662
1833
|
});
|
@@ -1735,8 +1906,7 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1735
1906
|
const childContexts = /* @__PURE__ */ new Map();
|
1736
1907
|
do {
|
1737
1908
|
const currentQueueEntry = componentQueue.pop();
|
1738
|
-
if (!currentQueueEntry)
|
1739
|
-
continue;
|
1909
|
+
if (!currentQueueEntry) continue;
|
1740
1910
|
const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
|
1741
1911
|
let visitDescendants = true;
|
1742
1912
|
let descendantContext = (_a = childContexts.get(currentComponent.component)) != null ? _a : currentQueueEntry.context;
|
@@ -2503,8 +2673,7 @@ var isSystemComponentDefinition = (componentType) => {
|
|
2503
2673
|
|
2504
2674
|
// src/utils/mapSlotToPersonalizedVariations.ts
|
2505
2675
|
function mapSlotToPersonalizedVariations(slot) {
|
2506
|
-
if (!slot)
|
2507
|
-
return [];
|
2676
|
+
if (!slot) return [];
|
2508
2677
|
return slot.map((v, i) => {
|
2509
2678
|
var _a, _b;
|
2510
2679
|
const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b.value;
|
@@ -2519,8 +2688,7 @@ function mapSlotToPersonalizedVariations(slot) {
|
|
2519
2688
|
|
2520
2689
|
// src/utils/mapSlotToTestVariations.ts
|
2521
2690
|
function mapSlotToTestVariations(slot) {
|
2522
|
-
if (!slot)
|
2523
|
-
return [];
|
2691
|
+
if (!slot) return [];
|
2524
2692
|
return slot.map((v, i) => {
|
2525
2693
|
var _a, _b, _c;
|
2526
2694
|
const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b.value;
|
@@ -2825,6 +2993,9 @@ export {
|
|
2825
2993
|
CANVAS_TEST_SLOT,
|
2826
2994
|
CANVAS_TEST_TYPE,
|
2827
2995
|
CANVAS_TEST_VARIANT_PARAM,
|
2996
|
+
CANVAS_VIZ_CONTROL_PARAM,
|
2997
|
+
CANVAS_VIZ_DI_RULE,
|
2998
|
+
CANVAS_VIZ_LOCALE_RULE,
|
2828
2999
|
CanvasClient,
|
2829
3000
|
CanvasClientError,
|
2830
3001
|
CategoryClient,
|
@@ -2867,11 +3038,15 @@ export {
|
|
2867
3038
|
convertEntryToPutEntry,
|
2868
3039
|
createBatchEnhancer,
|
2869
3040
|
createCanvasChannel,
|
3041
|
+
createDynamicInputVisibilityRule,
|
2870
3042
|
createEventBus,
|
2871
3043
|
createLimitPolicy,
|
3044
|
+
createLocaleVisibilityRule,
|
2872
3045
|
createUniformApiEnhancer,
|
2873
3046
|
createVariableReference,
|
2874
3047
|
enhance,
|
3048
|
+
evaluateVisibilityCriteriaGroup,
|
3049
|
+
evaluateWalkTreeVisibility,
|
2875
3050
|
extractLocales,
|
2876
3051
|
findParameterInNodeTree,
|
2877
3052
|
flattenValues,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/canvas",
|
3
|
-
"version": "19.159.1-alpha.
|
3
|
+
"version": "19.159.1-alpha.27+344f3d36db",
|
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.159.1-alpha.
|
42
|
-
"@uniformdev/context": "19.159.1-alpha.
|
41
|
+
"@uniformdev/assets": "19.159.1-alpha.27+344f3d36db",
|
42
|
+
"@uniformdev/context": "19.159.1-alpha.27+344f3d36db",
|
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": "
|
51
|
+
"gitHead": "344f3d36dba87d4e2340a1687c20b163be1d2c83"
|
52
52
|
}
|