@uniformdev/canvas 19.135.1-alpha.10 → 19.135.1-alpha.12
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 +7262 -6209
- package/dist/index.d.ts +7262 -6209
- package/dist/index.esm.js +622 -189
- package/dist/index.js +643 -191
- package/dist/index.mjs +622 -189
- package/package.json +7 -6
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({
|
@@ -466,6 +459,22 @@ function createLimitPolicy({
|
|
466
459
|
}
|
467
460
|
var nullLimitPolicy = async (func) => await func();
|
468
461
|
|
462
|
+
// src/utils/rewriteFilters.ts
|
463
|
+
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
464
|
+
function rewriteFilters(filters) {
|
465
|
+
return Object.entries(filters != null ? filters : {}).reduce(
|
466
|
+
(acc, [key, value]) => {
|
467
|
+
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
468
|
+
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
469
|
+
return {
|
470
|
+
...acc,
|
471
|
+
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
472
|
+
};
|
473
|
+
},
|
474
|
+
{}
|
475
|
+
);
|
476
|
+
}
|
477
|
+
|
469
478
|
// src/CanvasClient.ts
|
470
479
|
var CANVAS_URL = "/api/v1/canvas";
|
471
480
|
var CanvasClient = class extends ApiClient {
|
@@ -482,12 +491,7 @@ var CanvasClient = class extends ApiClient {
|
|
482
491
|
async getCompositionList(params = {}) {
|
483
492
|
const { projectId } = this.options;
|
484
493
|
const { resolveData, filters, ...originParams } = params;
|
485
|
-
const rewrittenFilters =
|
486
|
-
const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
|
487
|
-
let rhs = typeof value === "object" ? Object.values(value)[0] : value;
|
488
|
-
rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
|
489
|
-
return { ...acc, [lhs]: rhs };
|
490
|
-
}, {});
|
494
|
+
const rewrittenFilters = rewriteFilters(filters);
|
491
495
|
if (!resolveData) {
|
492
496
|
const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
|
493
497
|
return this.apiClient(fetchUri);
|
@@ -651,12 +655,7 @@ var _ContentClient = class _ContentClient extends ApiClient3 {
|
|
651
655
|
getEntries(options) {
|
652
656
|
const { projectId } = this.options;
|
653
657
|
const { skipDataResolution, filters, ...params } = options;
|
654
|
-
const rewrittenFilters =
|
655
|
-
const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
|
656
|
-
let rhs = typeof value === "object" ? Object.values(value)[0] : value;
|
657
|
-
rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
|
658
|
-
return { ...acc, [lhs]: rhs };
|
659
|
-
}, {});
|
658
|
+
const rewrittenFilters = rewriteFilters(filters);
|
660
659
|
if (skipDataResolution) {
|
661
660
|
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
|
662
661
|
return this.apiClient(url);
|
@@ -984,6 +983,9 @@ function isAssetParamValueItem(item) {
|
|
984
983
|
item instanceof Object && "_source" in item && "fields" in item && item.fields instanceof Object && "url" in item.fields && item.fields.url instanceof Object
|
985
984
|
);
|
986
985
|
}
|
986
|
+
function isLinkParamValue(value) {
|
987
|
+
return typeof value === "object" && value !== null && "type" in value && "path" in value;
|
988
|
+
}
|
987
989
|
|
988
990
|
// src/utils/properties.ts
|
989
991
|
function getPropertiesValue(entity) {
|
@@ -1035,6 +1037,86 @@ function flattenSingleNodeValues(data, options = {}) {
|
|
1035
1037
|
) : properties;
|
1036
1038
|
}
|
1037
1039
|
|
1040
|
+
// src/utils/variables/parseVariableExpression.ts
|
1041
|
+
var escapeCharacter = "\\";
|
1042
|
+
var variablePrefix = "${";
|
1043
|
+
var variableSuffix = "}";
|
1044
|
+
function parseVariableExpression(serialized, onToken) {
|
1045
|
+
let bufferStartIndex = 0;
|
1046
|
+
let bufferEndIndex = 0;
|
1047
|
+
let tokenCount = 0;
|
1048
|
+
const handleToken = (token, type) => {
|
1049
|
+
tokenCount++;
|
1050
|
+
return onToken == null ? void 0 : onToken(token, type);
|
1051
|
+
};
|
1052
|
+
let state = "text";
|
1053
|
+
for (let index = 0; index < serialized.length; index++) {
|
1054
|
+
const char = serialized[index];
|
1055
|
+
if (bufferStartIndex > bufferEndIndex) {
|
1056
|
+
bufferEndIndex = bufferStartIndex;
|
1057
|
+
}
|
1058
|
+
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
1059
|
+
if (serialized[index - 1] === escapeCharacter) {
|
1060
|
+
bufferEndIndex -= escapeCharacter.length;
|
1061
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
1062
|
+
return tokenCount;
|
1063
|
+
}
|
1064
|
+
bufferStartIndex = index;
|
1065
|
+
bufferEndIndex = index + 1;
|
1066
|
+
continue;
|
1067
|
+
}
|
1068
|
+
state = "variable";
|
1069
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1070
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
1071
|
+
return tokenCount;
|
1072
|
+
}
|
1073
|
+
bufferStartIndex = bufferEndIndex;
|
1074
|
+
}
|
1075
|
+
index += variablePrefix.length - 1;
|
1076
|
+
bufferStartIndex += variablePrefix.length;
|
1077
|
+
continue;
|
1078
|
+
}
|
1079
|
+
if (char === variableSuffix && state === "variable") {
|
1080
|
+
if (serialized[index - 1] === escapeCharacter) {
|
1081
|
+
bufferEndIndex++;
|
1082
|
+
continue;
|
1083
|
+
}
|
1084
|
+
state = "text";
|
1085
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1086
|
+
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
1087
|
+
if (handleToken(unescapedVariableName, "variable") === false) {
|
1088
|
+
return tokenCount;
|
1089
|
+
}
|
1090
|
+
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
1091
|
+
}
|
1092
|
+
continue;
|
1093
|
+
}
|
1094
|
+
bufferEndIndex++;
|
1095
|
+
}
|
1096
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1097
|
+
if (state === "variable") {
|
1098
|
+
state = "text";
|
1099
|
+
bufferStartIndex -= variablePrefix.length;
|
1100
|
+
}
|
1101
|
+
handleToken(serialized.substring(bufferStartIndex), state);
|
1102
|
+
}
|
1103
|
+
return tokenCount;
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
// src/utils/variables/hasReferencedVariables.ts
|
1107
|
+
function hasReferencedVariables(value) {
|
1108
|
+
if (value === void 0) {
|
1109
|
+
return 0;
|
1110
|
+
}
|
1111
|
+
let variableTokenCount = 0;
|
1112
|
+
parseVariableExpression(value, (_, tokenType) => {
|
1113
|
+
if (tokenType === "variable") {
|
1114
|
+
variableTokenCount++;
|
1115
|
+
}
|
1116
|
+
});
|
1117
|
+
return variableTokenCount;
|
1118
|
+
}
|
1119
|
+
|
1038
1120
|
// src/enhancement/walkNodeTree.ts
|
1039
1121
|
function walkNodeTree(node, visitor, options) {
|
1040
1122
|
var _a, _b;
|
@@ -1047,8 +1129,7 @@ function walkNodeTree(node, visitor, options) {
|
|
1047
1129
|
const childContexts = /* @__PURE__ */ new Map();
|
1048
1130
|
do {
|
1049
1131
|
const currentQueueEntry = componentQueue.pop();
|
1050
|
-
if (!currentQueueEntry)
|
1051
|
-
continue;
|
1132
|
+
if (!currentQueueEntry) continue;
|
1052
1133
|
const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
|
1053
1134
|
let visitDescendants = true;
|
1054
1135
|
let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
|
@@ -1259,8 +1340,25 @@ function walkNodeTree(node, visitor, options) {
|
|
1259
1340
|
const propertyEntries = Object.entries(properties);
|
1260
1341
|
for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
|
1261
1342
|
const [propKey, propObject] = propertyEntries[propIndex];
|
1262
|
-
if (!isNestedNodeType(propObject.type))
|
1343
|
+
if (!isNestedNodeType(propObject.type)) {
|
1344
|
+
continue;
|
1345
|
+
}
|
1346
|
+
if (typeof propObject.value === "string" && hasReferencedVariables(propObject.value) > 0) {
|
1263
1347
|
continue;
|
1348
|
+
}
|
1349
|
+
if (!Array.isArray(propObject.value)) {
|
1350
|
+
const error = new BlockFormatError(
|
1351
|
+
`${getComponentPath(currentQueueEntry.ancestorsAndSelf)}`,
|
1352
|
+
propKey,
|
1353
|
+
propObject.value
|
1354
|
+
);
|
1355
|
+
if (options == null ? void 0 : options.throwForInvalidBlockValues) {
|
1356
|
+
throw error;
|
1357
|
+
} else {
|
1358
|
+
console.warn(`Skipped invalid block value: ${error.message}}`);
|
1359
|
+
continue;
|
1360
|
+
}
|
1361
|
+
}
|
1264
1362
|
const blocks = (_b = propObject.value) != null ? _b : [];
|
1265
1363
|
for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
|
1266
1364
|
const enqueueingBlock = blocks[blockIndex];
|
@@ -1296,6 +1394,17 @@ function getBlockValue(component, parameterName) {
|
|
1296
1394
|
}
|
1297
1395
|
return [];
|
1298
1396
|
}
|
1397
|
+
var BlockFormatError = class _BlockFormatError extends Error {
|
1398
|
+
constructor(componentPath, propertyId, blockValue) {
|
1399
|
+
super(
|
1400
|
+
`${componentPath} has an invalid block property value on ${propertyId}. Block values must be arrays of blocks (BlockValue type), but received ${blockValue === null ? "null" : typeof blockValue}`
|
1401
|
+
);
|
1402
|
+
this.componentPath = componentPath;
|
1403
|
+
this.propertyId = propertyId;
|
1404
|
+
this.blockValue = blockValue;
|
1405
|
+
Object.setPrototypeOf(this, _BlockFormatError.prototype);
|
1406
|
+
}
|
1407
|
+
};
|
1299
1408
|
|
1300
1409
|
// src/enhancement/enhance.ts
|
1301
1410
|
async function enhance({
|
@@ -1605,6 +1714,366 @@ function findParameterInNodeTree(data, predicate) {
|
|
1605
1714
|
return results;
|
1606
1715
|
}
|
1607
1716
|
|
1717
|
+
// src/enhancement/visibility/evaluateVisibilityCriteriaGroup.ts
|
1718
|
+
function evaluateVisibilityCriteriaGroup(options) {
|
1719
|
+
const { criteriaGroup, simplifyCriteria } = options;
|
1720
|
+
const earlyExitResult = criteriaGroup.op === "&" || !criteriaGroup.op ? false : true;
|
1721
|
+
let hasIndeterminateClauses = false;
|
1722
|
+
for (let index = criteriaGroup.clauses.length - 1; index >= 0; index--) {
|
1723
|
+
const clause = criteriaGroup.clauses[index];
|
1724
|
+
const criteriaResult = evaluateCriterion(clause, options);
|
1725
|
+
if (criteriaResult === null) {
|
1726
|
+
hasIndeterminateClauses = true;
|
1727
|
+
} else if (criteriaResult === earlyExitResult) {
|
1728
|
+
return earlyExitResult;
|
1729
|
+
} else if (criteriaResult !== null && simplifyCriteria) {
|
1730
|
+
criteriaGroup.clauses.splice(index, 1);
|
1731
|
+
}
|
1732
|
+
}
|
1733
|
+
return hasIndeterminateClauses ? null : !earlyExitResult;
|
1734
|
+
}
|
1735
|
+
function evaluateCriterion(clause, rootOptions) {
|
1736
|
+
var _a;
|
1737
|
+
if ("clauses" in clause) {
|
1738
|
+
return evaluateVisibilityCriteriaGroup({
|
1739
|
+
...rootOptions,
|
1740
|
+
criteriaGroup: clause
|
1741
|
+
});
|
1742
|
+
}
|
1743
|
+
const lhs = (_a = clause.source) != null ? _a : clause.rule;
|
1744
|
+
const rhs = Array.isArray(clause.value) ? clause.value : clause.value !== void 0 ? [clause.value] : void 0;
|
1745
|
+
if (hasReferencedVariables(lhs) > 0 || (rhs == null ? void 0 : rhs.some((rhv) => hasReferencedVariables(rhv) > 0))) {
|
1746
|
+
return null;
|
1747
|
+
}
|
1748
|
+
const rule = rootOptions.rules[clause.rule];
|
1749
|
+
if (rule) {
|
1750
|
+
return rule(clause);
|
1751
|
+
}
|
1752
|
+
return null;
|
1753
|
+
}
|
1754
|
+
|
1755
|
+
// src/enhancement/visibility/evaluateNodeVisibilityParameter.ts
|
1756
|
+
function evaluateNodeVisibilityParameter({
|
1757
|
+
parameter,
|
1758
|
+
...evaluateGroupOptions
|
1759
|
+
}) {
|
1760
|
+
if (parameter == null ? void 0 : parameter.explicitlyHidden) {
|
1761
|
+
return false;
|
1762
|
+
}
|
1763
|
+
if (!(parameter == null ? void 0 : parameter.criteria)) {
|
1764
|
+
return true;
|
1765
|
+
}
|
1766
|
+
const result = evaluateVisibilityCriteriaGroup({
|
1767
|
+
...evaluateGroupOptions,
|
1768
|
+
criteriaGroup: parameter.criteria
|
1769
|
+
});
|
1770
|
+
return result;
|
1771
|
+
}
|
1772
|
+
|
1773
|
+
// src/enhancement/visibility/evaluatePropertyCriteria.ts
|
1774
|
+
function evaluatePropertyCriteria({
|
1775
|
+
baseValue,
|
1776
|
+
conditionalValues,
|
1777
|
+
keepIndeterminate,
|
1778
|
+
...evaluateGroupOptions
|
1779
|
+
}) {
|
1780
|
+
let authoritative = true;
|
1781
|
+
const result = {
|
1782
|
+
currentValue: baseValue,
|
1783
|
+
remainingConditionalValues: evaluateGroupOptions.simplifyCriteria && conditionalValues ? [...conditionalValues] : conditionalValues,
|
1784
|
+
currentConditionIndex: -1
|
1785
|
+
};
|
1786
|
+
if (!conditionalValues) {
|
1787
|
+
return result;
|
1788
|
+
}
|
1789
|
+
const conditionIndexesToRemove = [];
|
1790
|
+
for (let i = 0; i < conditionalValues.length; i++) {
|
1791
|
+
const conditionalVariant = conditionalValues[i];
|
1792
|
+
if (result.matched) {
|
1793
|
+
conditionIndexesToRemove.push(i);
|
1794
|
+
continue;
|
1795
|
+
}
|
1796
|
+
const evaluationResult = evaluateVisibilityCriteriaGroup({
|
1797
|
+
...evaluateGroupOptions,
|
1798
|
+
criteriaGroup: conditionalVariant.when
|
1799
|
+
});
|
1800
|
+
if (evaluationResult === null) {
|
1801
|
+
if (keepIndeterminate) {
|
1802
|
+
authoritative = false;
|
1803
|
+
} else {
|
1804
|
+
conditionIndexesToRemove.push(i);
|
1805
|
+
}
|
1806
|
+
} else if (evaluationResult === true) {
|
1807
|
+
result.matched = conditionalVariant;
|
1808
|
+
result.currentValue = conditionalVariant.value;
|
1809
|
+
result.currentConditionIndex = i;
|
1810
|
+
conditionIndexesToRemove.push(i);
|
1811
|
+
} else {
|
1812
|
+
conditionIndexesToRemove.push(i);
|
1813
|
+
}
|
1814
|
+
}
|
1815
|
+
if (evaluateGroupOptions.simplifyCriteria) {
|
1816
|
+
for (let i = conditionIndexesToRemove.length - 1; i >= 0; i--) {
|
1817
|
+
result.remainingConditionalValues.splice(conditionIndexesToRemove[i], 1);
|
1818
|
+
}
|
1819
|
+
}
|
1820
|
+
if (authoritative) {
|
1821
|
+
result.remainingConditionalValues = void 0;
|
1822
|
+
}
|
1823
|
+
return result;
|
1824
|
+
}
|
1825
|
+
|
1826
|
+
// src/enhancement/visibility/types.ts
|
1827
|
+
var CANVAS_VIZ_CONTROL_PARAM = "$viz";
|
1828
|
+
|
1829
|
+
// src/enhancement/visibility/evaluateNodeVisibility.ts
|
1830
|
+
function evaluateNodeVisibility({
|
1831
|
+
node,
|
1832
|
+
...evaluateGroupOptions
|
1833
|
+
}) {
|
1834
|
+
var _a;
|
1835
|
+
const properties = getPropertiesValue(node);
|
1836
|
+
const vizCriteria = (_a = properties == null ? void 0 : properties[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _a.value;
|
1837
|
+
const result = evaluateNodeVisibilityParameter({
|
1838
|
+
...evaluateGroupOptions,
|
1839
|
+
parameter: vizCriteria
|
1840
|
+
});
|
1841
|
+
if ((vizCriteria == null ? void 0 : vizCriteria.criteria) && vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
|
1842
|
+
properties == null ? true : delete properties[CANVAS_VIZ_CONTROL_PARAM];
|
1843
|
+
}
|
1844
|
+
return result;
|
1845
|
+
}
|
1846
|
+
|
1847
|
+
// src/enhancement/visibility/evaluateWalkTreeNodeVisibility.ts
|
1848
|
+
function evaluateWalkTreeNodeVisibility({
|
1849
|
+
rules,
|
1850
|
+
showIndeterminate,
|
1851
|
+
context
|
1852
|
+
}) {
|
1853
|
+
const { type, node, actions } = context;
|
1854
|
+
if (type !== "component") {
|
1855
|
+
return;
|
1856
|
+
}
|
1857
|
+
const result = evaluateNodeVisibility({ node, rules, simplifyCriteria: true });
|
1858
|
+
if (result === null && !showIndeterminate || result === false) {
|
1859
|
+
actions.remove();
|
1860
|
+
return false;
|
1861
|
+
}
|
1862
|
+
return true;
|
1863
|
+
}
|
1864
|
+
|
1865
|
+
// src/enhancement/visibility/evaluateWalkTreePropertyCriteria.ts
|
1866
|
+
function evaluateWalkTreePropertyCriteria({
|
1867
|
+
rules,
|
1868
|
+
node,
|
1869
|
+
keepIndeterminate
|
1870
|
+
}) {
|
1871
|
+
const properties = getPropertiesValue(node);
|
1872
|
+
if (!properties) {
|
1873
|
+
return;
|
1874
|
+
}
|
1875
|
+
Object.entries(properties).forEach(([propertyName, property]) => {
|
1876
|
+
var _a, _b, _c;
|
1877
|
+
if (property.locales || property.localesConditions) {
|
1878
|
+
const localesDefined = [
|
1879
|
+
...Object.keys((_a = property.locales) != null ? _a : {}),
|
1880
|
+
...Object.keys((_b = property.localesConditions) != null ? _b : {})
|
1881
|
+
];
|
1882
|
+
localesDefined.forEach((locale) => {
|
1883
|
+
var _a2, _b2, _c2, _d, _e, _f;
|
1884
|
+
const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
|
1885
|
+
baseValue: (_a2 = property.locales) == null ? void 0 : _a2[locale],
|
1886
|
+
conditionalValues: (_b2 = property.localesConditions) == null ? void 0 : _b2[locale],
|
1887
|
+
rules,
|
1888
|
+
simplifyCriteria: true,
|
1889
|
+
keepIndeterminate
|
1890
|
+
});
|
1891
|
+
if (currentValue === null || currentValue === void 0) {
|
1892
|
+
(_c2 = property.locales) == null ? true : delete _c2[locale];
|
1893
|
+
} else {
|
1894
|
+
(_d = property.locales) != null ? _d : property.locales = {};
|
1895
|
+
property.locales[locale] = currentValue;
|
1896
|
+
}
|
1897
|
+
if (!(remainingConditionalValues == null ? void 0 : remainingConditionalValues.length)) {
|
1898
|
+
(_e = property.localesConditions) == null ? true : delete _e[locale];
|
1899
|
+
} else {
|
1900
|
+
(_f = property.localesConditions) != null ? _f : property.localesConditions = {};
|
1901
|
+
property.localesConditions[locale] = remainingConditionalValues;
|
1902
|
+
}
|
1903
|
+
});
|
1904
|
+
if (!Object.keys((_c = property.localesConditions) != null ? _c : {}).length) {
|
1905
|
+
delete property.localesConditions;
|
1906
|
+
}
|
1907
|
+
if (!property.locales && !property.localesConditions) {
|
1908
|
+
delete properties[propertyName];
|
1909
|
+
}
|
1910
|
+
} else {
|
1911
|
+
const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
|
1912
|
+
baseValue: property.value,
|
1913
|
+
conditionalValues: property.conditions,
|
1914
|
+
rules,
|
1915
|
+
simplifyCriteria: true,
|
1916
|
+
keepIndeterminate
|
1917
|
+
});
|
1918
|
+
if (currentValue === null) {
|
1919
|
+
delete properties[propertyName];
|
1920
|
+
} else {
|
1921
|
+
if (currentValue !== void 0) {
|
1922
|
+
property.value = currentValue;
|
1923
|
+
} else {
|
1924
|
+
delete property.value;
|
1925
|
+
}
|
1926
|
+
}
|
1927
|
+
if (remainingConditionalValues === void 0) {
|
1928
|
+
delete property.conditions;
|
1929
|
+
} else {
|
1930
|
+
property.conditions = remainingConditionalValues;
|
1931
|
+
}
|
1932
|
+
}
|
1933
|
+
});
|
1934
|
+
}
|
1935
|
+
|
1936
|
+
// src/enhancement/visibility/rules/evaluateStringMatch.ts
|
1937
|
+
var isEvaluator = (criteria, matchValue) => {
|
1938
|
+
if (Array.isArray(criteria)) {
|
1939
|
+
return criteria.includes(matchValue);
|
1940
|
+
}
|
1941
|
+
return criteria === matchValue;
|
1942
|
+
};
|
1943
|
+
var containsEvaluator = (criteria, matchValue) => {
|
1944
|
+
if (Array.isArray(criteria)) {
|
1945
|
+
return criteria.some((criterion) => matchValue.includes(criterion));
|
1946
|
+
}
|
1947
|
+
return matchValue.includes(criteria);
|
1948
|
+
};
|
1949
|
+
var startsWithEvaluator = (criteria, matchValue) => {
|
1950
|
+
if (Array.isArray(criteria)) {
|
1951
|
+
return criteria.some((criterion) => matchValue.startsWith(criterion));
|
1952
|
+
}
|
1953
|
+
return matchValue.startsWith(criteria);
|
1954
|
+
};
|
1955
|
+
var endsWithEvaluator = (criteria, matchValue) => {
|
1956
|
+
if (Array.isArray(criteria)) {
|
1957
|
+
return criteria.some((criterion) => matchValue.endsWith(criterion));
|
1958
|
+
}
|
1959
|
+
return matchValue.endsWith(criteria);
|
1960
|
+
};
|
1961
|
+
var emptyEvaluator = (_, matchValue) => {
|
1962
|
+
return matchValue === "";
|
1963
|
+
};
|
1964
|
+
var stringOperatorEvaluators = {
|
1965
|
+
is: isEvaluator,
|
1966
|
+
has: containsEvaluator,
|
1967
|
+
startswith: startsWithEvaluator,
|
1968
|
+
endswith: endsWithEvaluator,
|
1969
|
+
empty: emptyEvaluator
|
1970
|
+
};
|
1971
|
+
function evaluateStringMatch(criteria, matchValue, allow) {
|
1972
|
+
const { op, value } = criteria;
|
1973
|
+
if (allow && !allow.has(op)) {
|
1974
|
+
return null;
|
1975
|
+
}
|
1976
|
+
let opMatch = op;
|
1977
|
+
const negation = op.startsWith("!");
|
1978
|
+
if (negation) {
|
1979
|
+
opMatch = opMatch.slice(1);
|
1980
|
+
}
|
1981
|
+
const evaluator = stringOperatorEvaluators[opMatch];
|
1982
|
+
if (!evaluator) {
|
1983
|
+
return null;
|
1984
|
+
}
|
1985
|
+
const result = evaluator(value, matchValue);
|
1986
|
+
return negation ? !result : result;
|
1987
|
+
}
|
1988
|
+
|
1989
|
+
// src/enhancement/visibility/rules/createDynamicInputVisibilityRule.ts
|
1990
|
+
var dynamicInputVisibilityOperators = /* @__PURE__ */ new Set([
|
1991
|
+
"is",
|
1992
|
+
"!is",
|
1993
|
+
"has",
|
1994
|
+
"!has",
|
1995
|
+
"startswith",
|
1996
|
+
"!startswith",
|
1997
|
+
"endswith",
|
1998
|
+
"!endswith",
|
1999
|
+
"empty",
|
2000
|
+
"!empty"
|
2001
|
+
]);
|
2002
|
+
var CANVAS_VIZ_DI_RULE = "$di";
|
2003
|
+
function createDynamicInputVisibilityRule(dynamicInputs) {
|
2004
|
+
return {
|
2005
|
+
[CANVAS_VIZ_DI_RULE]: (criterion) => {
|
2006
|
+
const { source } = criterion;
|
2007
|
+
const diValue = source ? dynamicInputs[source] : void 0;
|
2008
|
+
return evaluateStringMatch(criterion, diValue != null ? diValue : "", dynamicInputVisibilityOperators);
|
2009
|
+
}
|
2010
|
+
};
|
2011
|
+
}
|
2012
|
+
|
2013
|
+
// src/enhancement/visibility/rules/createDynamicTokenVisibilityRule.ts
|
2014
|
+
var dynamicTokenVisibilityOperators = /* @__PURE__ */ new Set([
|
2015
|
+
"is",
|
2016
|
+
"!is",
|
2017
|
+
"has",
|
2018
|
+
"!has",
|
2019
|
+
"startswith",
|
2020
|
+
"!startswith",
|
2021
|
+
"endswith",
|
2022
|
+
"!endswith",
|
2023
|
+
"empty",
|
2024
|
+
"!empty"
|
2025
|
+
]);
|
2026
|
+
var CANVAS_VIZ_DYNAMIC_TOKEN_RULE = "$dt";
|
2027
|
+
function createDynamicTokenVisibilityRule() {
|
2028
|
+
return {
|
2029
|
+
[CANVAS_VIZ_DYNAMIC_TOKEN_RULE]: (criterion) => {
|
2030
|
+
var _a;
|
2031
|
+
if (hasReferencedVariables(criterion.source)) {
|
2032
|
+
return null;
|
2033
|
+
}
|
2034
|
+
return evaluateStringMatch(criterion, (_a = criterion.source) != null ? _a : "", dynamicTokenVisibilityOperators);
|
2035
|
+
}
|
2036
|
+
};
|
2037
|
+
}
|
2038
|
+
|
2039
|
+
// src/enhancement/visibility/rules/createLocaleVisibilityRule.ts
|
2040
|
+
var localeVisibilityOperators = /* @__PURE__ */ new Set(["is", "!is"]);
|
2041
|
+
var CANVAS_VIZ_LOCALE_RULE = "$locale";
|
2042
|
+
function createLocaleVisibilityRule(currentLocale) {
|
2043
|
+
return {
|
2044
|
+
[CANVAS_VIZ_LOCALE_RULE]: (criterion) => {
|
2045
|
+
if (!currentLocale) {
|
2046
|
+
return false;
|
2047
|
+
}
|
2048
|
+
return evaluateStringMatch(criterion, currentLocale, localeVisibilityOperators);
|
2049
|
+
}
|
2050
|
+
};
|
2051
|
+
}
|
2052
|
+
|
2053
|
+
// src/enhancement/visibility/rules/createQuirksVisibilityRule.ts
|
2054
|
+
var quirksVisibilityOperators = /* @__PURE__ */ new Set([
|
2055
|
+
"is",
|
2056
|
+
"!is",
|
2057
|
+
"has",
|
2058
|
+
"!has",
|
2059
|
+
"startswith",
|
2060
|
+
"!startswith",
|
2061
|
+
"endswith",
|
2062
|
+
"!endswith",
|
2063
|
+
"empty",
|
2064
|
+
"!empty"
|
2065
|
+
]);
|
2066
|
+
var CANVAS_VIZ_QUIRKS_RULE = "$qk";
|
2067
|
+
function createQuirksVisibilityRule(quirks) {
|
2068
|
+
return {
|
2069
|
+
[CANVAS_VIZ_QUIRKS_RULE]: (criterion) => {
|
2070
|
+
const { source } = criterion;
|
2071
|
+
const quirkValue = source ? quirks[source] : void 0;
|
2072
|
+
return evaluateStringMatch(criterion, quirkValue != null ? quirkValue : "", quirksVisibilityOperators);
|
2073
|
+
}
|
2074
|
+
};
|
2075
|
+
}
|
2076
|
+
|
1608
2077
|
// src/enhancement/localize.ts
|
1609
2078
|
function extractLocales({ component }) {
|
1610
2079
|
var _a;
|
@@ -1623,17 +2092,29 @@ function extractLocales({ component }) {
|
|
1623
2092
|
function localize(options) {
|
1624
2093
|
const nodes = "nodes" in options ? options.nodes : options.composition;
|
1625
2094
|
const locale = options.locale;
|
1626
|
-
|
2095
|
+
const isUsingModernOptions = typeof locale === "string";
|
2096
|
+
const vizControlLocaleRule = isUsingModernOptions ? createLocaleVisibilityRule(locale) : {};
|
2097
|
+
walkNodeTree(nodes, (context) => {
|
2098
|
+
const { type, node, actions } = context;
|
1627
2099
|
if (type !== "component") {
|
1628
|
-
if (
|
1629
|
-
localizeProperties(node
|
2100
|
+
if (isUsingModernOptions) {
|
2101
|
+
localizeProperties(node, locale, vizControlLocaleRule);
|
1630
2102
|
}
|
1631
2103
|
return;
|
1632
2104
|
}
|
1633
|
-
|
2105
|
+
if (isUsingModernOptions) {
|
2106
|
+
const result = evaluateWalkTreeNodeVisibility({
|
2107
|
+
context,
|
2108
|
+
rules: vizControlLocaleRule,
|
2109
|
+
showIndeterminate: true
|
2110
|
+
});
|
2111
|
+
if (!result) {
|
2112
|
+
return;
|
2113
|
+
}
|
2114
|
+
}
|
1634
2115
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
1635
2116
|
const locales = extractLocales({ component: node });
|
1636
|
-
const resolvedLocale =
|
2117
|
+
const resolvedLocale = isUsingModernOptions ? locale : locale == null ? void 0 : locale({ component: node, locales });
|
1637
2118
|
let replaceComponent;
|
1638
2119
|
if (resolvedLocale) {
|
1639
2120
|
replaceComponent = locales[resolvedLocale];
|
@@ -1641,8 +2122,8 @@ function localize(options) {
|
|
1641
2122
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
1642
2123
|
replaceComponent.forEach((component) => {
|
1643
2124
|
removeLocaleProperty(component);
|
1644
|
-
if (
|
1645
|
-
localizeProperties(
|
2125
|
+
if (isUsingModernOptions) {
|
2126
|
+
localizeProperties(component, locale, vizControlLocaleRule);
|
1646
2127
|
}
|
1647
2128
|
});
|
1648
2129
|
const [first, ...rest] = replaceComponent;
|
@@ -1653,8 +2134,8 @@ function localize(options) {
|
|
1653
2134
|
} else {
|
1654
2135
|
actions.remove();
|
1655
2136
|
}
|
1656
|
-
} else if (
|
1657
|
-
localizeProperties(
|
2137
|
+
} else if (isUsingModernOptions) {
|
2138
|
+
localizeProperties(node, locale, vizControlLocaleRule);
|
1658
2139
|
}
|
1659
2140
|
});
|
1660
2141
|
}
|
@@ -1673,36 +2154,51 @@ function removeLocaleProperty(component) {
|
|
1673
2154
|
}
|
1674
2155
|
}
|
1675
2156
|
}
|
1676
|
-
function localizeProperties(
|
2157
|
+
function localizeProperties(node, locale, rules) {
|
2158
|
+
const properties = getPropertiesValue(node);
|
1677
2159
|
if (!properties) {
|
1678
2160
|
return void 0;
|
1679
2161
|
}
|
1680
|
-
Object.entries(properties).forEach(([
|
1681
|
-
var _a;
|
2162
|
+
Object.entries(properties).forEach(([propertyId, propertyValue]) => {
|
2163
|
+
var _a, _b;
|
1682
2164
|
if (!locale) {
|
1683
|
-
delete
|
2165
|
+
delete propertyValue.locales;
|
2166
|
+
delete propertyValue.localesConditions;
|
1684
2167
|
}
|
1685
|
-
const currentLocaleValue = locale ? (_a =
|
2168
|
+
const currentLocaleValue = locale ? (_a = propertyValue.locales) == null ? void 0 : _a[locale] : void 0;
|
1686
2169
|
if (currentLocaleValue !== void 0) {
|
1687
|
-
|
2170
|
+
propertyValue.value = currentLocaleValue;
|
1688
2171
|
}
|
1689
|
-
|
1690
|
-
if (
|
1691
|
-
|
2172
|
+
const currentLocaleConditionalValues = locale ? (_b = propertyValue.localesConditions) == null ? void 0 : _b[locale] : void 0;
|
2173
|
+
if (currentLocaleConditionalValues !== void 0) {
|
2174
|
+
propertyValue.conditions = currentLocaleConditionalValues;
|
1692
2175
|
}
|
2176
|
+
delete propertyValue.locales;
|
2177
|
+
delete propertyValue.localesConditions;
|
2178
|
+
if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
|
2179
|
+
delete properties[propertyId];
|
2180
|
+
}
|
2181
|
+
});
|
2182
|
+
evaluateWalkTreePropertyCriteria({
|
2183
|
+
node,
|
2184
|
+
rules,
|
2185
|
+
keepIndeterminate: true
|
1693
2186
|
});
|
1694
2187
|
}
|
1695
2188
|
|
1696
2189
|
// src/enhancement/UniqueBatchEntries.ts
|
1697
2190
|
var UniqueBatchEntries = class {
|
1698
2191
|
constructor(entries, uniqueKeySelector) {
|
1699
|
-
this.groups = entries.reduce(
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
2192
|
+
this.groups = entries.reduce(
|
2193
|
+
(acc, task) => {
|
2194
|
+
var _a;
|
2195
|
+
const key = uniqueKeySelector(task.args);
|
2196
|
+
acc[key] = (_a = acc[key]) != null ? _a : [];
|
2197
|
+
acc[key].push(task);
|
2198
|
+
return acc;
|
2199
|
+
},
|
2200
|
+
{}
|
2201
|
+
);
|
1706
2202
|
}
|
1707
2203
|
/** Resolves all entries in a group key with the same result value. */
|
1708
2204
|
resolveKey(key, result) {
|
@@ -1732,8 +2228,7 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1732
2228
|
const childContexts = /* @__PURE__ */ new Map();
|
1733
2229
|
do {
|
1734
2230
|
const currentQueueEntry = componentQueue.pop();
|
1735
|
-
if (!currentQueueEntry)
|
1736
|
-
continue;
|
2231
|
+
if (!currentQueueEntry) continue;
|
1737
2232
|
const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
|
1738
2233
|
let visitDescendants = true;
|
1739
2234
|
let descendantContext = (_a = childContexts.get(currentComponent.component)) != null ? _a : currentQueueEntry.context;
|
@@ -1838,10 +2333,25 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1838
2333
|
} while (componentQueue.length > 0);
|
1839
2334
|
}
|
1840
2335
|
|
1841
|
-
// src/
|
2336
|
+
// src/EntityReleasesClient.ts
|
1842
2337
|
import { ApiClient as ApiClient6 } from "@uniformdev/context/api";
|
2338
|
+
var releaseContentsUrl = "/api/v1/entity-releases";
|
2339
|
+
var EntityReleasesClient = class extends ApiClient6 {
|
2340
|
+
constructor(options) {
|
2341
|
+
super(options);
|
2342
|
+
}
|
2343
|
+
/** Fetches entity across all releases (and base) */
|
2344
|
+
async get(options) {
|
2345
|
+
const { projectId } = this.options;
|
2346
|
+
const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
|
2347
|
+
return await this.apiClient(fetchUri);
|
2348
|
+
}
|
2349
|
+
};
|
2350
|
+
|
2351
|
+
// src/LocaleClient.ts
|
2352
|
+
import { ApiClient as ApiClient7 } from "@uniformdev/context/api";
|
1843
2353
|
var localesUrl = "/api/v1/locales";
|
1844
|
-
var LocaleClient = class extends
|
2354
|
+
var LocaleClient = class extends ApiClient7 {
|
1845
2355
|
constructor(options) {
|
1846
2356
|
super(options);
|
1847
2357
|
}
|
@@ -1947,6 +2457,9 @@ var isRequestComponentSuggestionMessage = (message) => {
|
|
1947
2457
|
var isSuggestComponentMessage = (message) => {
|
1948
2458
|
return message.type === "suggest-component";
|
1949
2459
|
};
|
2460
|
+
var isContextStorageUpdatedMessage = (message) => {
|
2461
|
+
return message.type === "context-storage-command-executed";
|
2462
|
+
};
|
1950
2463
|
var createCanvasChannel = ({
|
1951
2464
|
listenTo,
|
1952
2465
|
broadcastTo
|
@@ -2127,6 +2640,13 @@ var createCanvasChannel = ({
|
|
2127
2640
|
};
|
2128
2641
|
postMessage(message);
|
2129
2642
|
};
|
2643
|
+
const contextStorageUpdated = (options) => {
|
2644
|
+
const message = {
|
2645
|
+
...options,
|
2646
|
+
type: "context-storage-command-executed"
|
2647
|
+
};
|
2648
|
+
postMessage(message);
|
2649
|
+
};
|
2130
2650
|
const messageEventListener = (event) => {
|
2131
2651
|
if (typeof event.data !== "string") {
|
2132
2652
|
return;
|
@@ -2176,7 +2696,8 @@ var createCanvasChannel = ({
|
|
2176
2696
|
editorStateUpdated,
|
2177
2697
|
updateComponentReferences,
|
2178
2698
|
requestComponentSuggestion,
|
2179
|
-
suggestComponent
|
2699
|
+
suggestComponent,
|
2700
|
+
contextStorageUpdated
|
2180
2701
|
};
|
2181
2702
|
};
|
2182
2703
|
|
@@ -2259,9 +2780,9 @@ function subscribeToComposition({
|
|
2259
2780
|
}
|
2260
2781
|
|
2261
2782
|
// src/PromptClient.ts
|
2262
|
-
import { ApiClient as
|
2783
|
+
import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
|
2263
2784
|
var PromptsUrl = "/api/v1/prompts";
|
2264
|
-
var PromptClient = class extends
|
2785
|
+
var PromptClient = class extends ApiClient8 {
|
2265
2786
|
constructor(options) {
|
2266
2787
|
super(options);
|
2267
2788
|
}
|
@@ -2292,9 +2813,9 @@ var PromptClient = class extends ApiClient7 {
|
|
2292
2813
|
};
|
2293
2814
|
|
2294
2815
|
// src/RelationshipClient.ts
|
2295
|
-
import { ApiClient as
|
2816
|
+
import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
|
2296
2817
|
var RELATIONSHIPS_URL = "/api/v1/relationships";
|
2297
|
-
var RelationshipClient = class extends
|
2818
|
+
var RelationshipClient = class extends ApiClient9 {
|
2298
2819
|
constructor(options) {
|
2299
2820
|
super(options);
|
2300
2821
|
this.get = async (options) => {
|
@@ -2302,56 +2823,13 @@ var RelationshipClient = class extends ApiClient8 {
|
|
2302
2823
|
const url = this.createUrl(RELATIONSHIPS_URL, { ...options, projectId });
|
2303
2824
|
return this.apiClient(url);
|
2304
2825
|
};
|
2305
|
-
this.clearProjectRelationships = async () => {
|
2306
|
-
const { projectId } = this.options;
|
2307
|
-
const url = this.createUrl(RELATIONSHIPS_URL);
|
2308
|
-
return this.apiClient(url, {
|
2309
|
-
method: "POST",
|
2310
|
-
body: JSON.stringify({
|
2311
|
-
action: "clear",
|
2312
|
-
projectId
|
2313
|
-
})
|
2314
|
-
});
|
2315
|
-
};
|
2316
|
-
this.indexRelationships = async ({ state, id, type }) => {
|
2317
|
-
const { projectId } = this.options;
|
2318
|
-
const url = this.createUrl(RELATIONSHIPS_URL);
|
2319
|
-
return this.apiClient(url, {
|
2320
|
-
method: "POST",
|
2321
|
-
body: JSON.stringify({
|
2322
|
-
action: "index",
|
2323
|
-
type,
|
2324
|
-
projectId,
|
2325
|
-
state,
|
2326
|
-
id
|
2327
|
-
})
|
2328
|
-
});
|
2329
|
-
};
|
2330
|
-
this.getVersion = async () => {
|
2331
|
-
const { projectId } = this.options;
|
2332
|
-
const url = this.createUrl("/api/v1/usage-tracking", {
|
2333
|
-
projectId
|
2334
|
-
});
|
2335
|
-
return this.apiClient(url).then((response) => response.version);
|
2336
|
-
};
|
2337
|
-
this.setVersion = async (version) => {
|
2338
|
-
const { projectId } = this.options;
|
2339
|
-
const url = this.createUrl("/api/v1/usage-tracking");
|
2340
|
-
return this.apiClient(url, {
|
2341
|
-
method: "POST",
|
2342
|
-
body: JSON.stringify({
|
2343
|
-
projectId,
|
2344
|
-
version
|
2345
|
-
})
|
2346
|
-
});
|
2347
|
-
};
|
2348
2826
|
}
|
2349
2827
|
};
|
2350
2828
|
|
2351
2829
|
// src/ReleaseClient.ts
|
2352
|
-
import { ApiClient as
|
2830
|
+
import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
|
2353
2831
|
var releasesUrl = "/api/v1/releases";
|
2354
|
-
var ReleaseClient = class extends
|
2832
|
+
var ReleaseClient = class extends ApiClient10 {
|
2355
2833
|
constructor(options) {
|
2356
2834
|
super(options);
|
2357
2835
|
}
|
@@ -2391,21 +2869,21 @@ var ReleaseClient = class extends ApiClient9 {
|
|
2391
2869
|
};
|
2392
2870
|
|
2393
2871
|
// src/ReleaseContentsClient.ts
|
2394
|
-
import { ApiClient as
|
2395
|
-
var
|
2396
|
-
var ReleaseContentsClient = class extends
|
2872
|
+
import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
|
2873
|
+
var releaseContentsUrl2 = "/api/v1/release-contents";
|
2874
|
+
var ReleaseContentsClient = class extends ApiClient11 {
|
2397
2875
|
constructor(options) {
|
2398
2876
|
super(options);
|
2399
2877
|
}
|
2400
2878
|
/** Fetches all entities added to a release */
|
2401
2879
|
async get(options) {
|
2402
2880
|
const { projectId } = this.options;
|
2403
|
-
const fetchUri = this.createUrl(
|
2881
|
+
const fetchUri = this.createUrl(releaseContentsUrl2, { ...options, projectId });
|
2404
2882
|
return await this.apiClient(fetchUri);
|
2405
2883
|
}
|
2406
2884
|
/** Removes a release content from a release */
|
2407
2885
|
async remove(body) {
|
2408
|
-
const fetchUri = this.createUrl(
|
2886
|
+
const fetchUri = this.createUrl(releaseContentsUrl2);
|
2409
2887
|
await this.apiClient(fetchUri, {
|
2410
2888
|
method: "DELETE",
|
2411
2889
|
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
@@ -2415,9 +2893,9 @@ var ReleaseContentsClient = class extends ApiClient10 {
|
|
2415
2893
|
};
|
2416
2894
|
|
2417
2895
|
// src/RouteClient.ts
|
2418
|
-
import { ApiClient as
|
2896
|
+
import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
|
2419
2897
|
var ROUTE_URL = "/api/v1/route";
|
2420
|
-
var RouteClient = class extends
|
2898
|
+
var RouteClient = class extends ApiClient12 {
|
2421
2899
|
constructor(options) {
|
2422
2900
|
var _a;
|
2423
2901
|
if (!options.limitPolicy) {
|
@@ -2528,8 +3006,7 @@ var isSystemComponentDefinition = (componentType) => {
|
|
2528
3006
|
|
2529
3007
|
// src/utils/mapSlotToPersonalizedVariations.ts
|
2530
3008
|
function mapSlotToPersonalizedVariations(slot) {
|
2531
|
-
if (!slot)
|
2532
|
-
return [];
|
3009
|
+
if (!slot) return [];
|
2533
3010
|
return slot.map((v, i) => {
|
2534
3011
|
var _a, _b;
|
2535
3012
|
const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b.value;
|
@@ -2544,8 +3021,7 @@ function mapSlotToPersonalizedVariations(slot) {
|
|
2544
3021
|
|
2545
3022
|
// src/utils/mapSlotToTestVariations.ts
|
2546
3023
|
function mapSlotToTestVariations(slot) {
|
2547
|
-
if (!slot)
|
2548
|
-
return [];
|
3024
|
+
if (!slot) return [];
|
2549
3025
|
return slot.map((v, i) => {
|
2550
3026
|
var _a, _b, _c;
|
2551
3027
|
const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b.value;
|
@@ -2570,7 +3046,7 @@ var isComponentPlaceholderId = (id) => {
|
|
2570
3046
|
return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
|
2571
3047
|
};
|
2572
3048
|
var generateComponentPlaceholderId = (randomId, sdkVersion, parent) => {
|
2573
|
-
if (
|
3049
|
+
if (sdkVersion === 1) {
|
2574
3050
|
return PLACEHOLDER_ID;
|
2575
3051
|
}
|
2576
3052
|
let idParts = [PLACEHOLDER_ID, randomId];
|
@@ -2596,72 +3072,6 @@ var parseComponentPlaceholderId = (id) => {
|
|
2596
3072
|
return result;
|
2597
3073
|
};
|
2598
3074
|
|
2599
|
-
// src/utils/variables/parseVariableExpression.ts
|
2600
|
-
var escapeCharacter = "\\";
|
2601
|
-
var variablePrefix = "${";
|
2602
|
-
var variableSuffix = "}";
|
2603
|
-
function parseVariableExpression(serialized, onToken) {
|
2604
|
-
let bufferStartIndex = 0;
|
2605
|
-
let bufferEndIndex = 0;
|
2606
|
-
let tokenCount = 0;
|
2607
|
-
const handleToken = (token, type) => {
|
2608
|
-
tokenCount++;
|
2609
|
-
return onToken == null ? void 0 : onToken(token, type);
|
2610
|
-
};
|
2611
|
-
let state = "text";
|
2612
|
-
for (let index = 0; index < serialized.length; index++) {
|
2613
|
-
const char = serialized[index];
|
2614
|
-
if (bufferStartIndex > bufferEndIndex) {
|
2615
|
-
bufferEndIndex = bufferStartIndex;
|
2616
|
-
}
|
2617
|
-
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
2618
|
-
if (serialized[index - 1] === escapeCharacter) {
|
2619
|
-
bufferEndIndex -= escapeCharacter.length;
|
2620
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
2621
|
-
return tokenCount;
|
2622
|
-
}
|
2623
|
-
bufferStartIndex = index;
|
2624
|
-
bufferEndIndex = index + 1;
|
2625
|
-
continue;
|
2626
|
-
}
|
2627
|
-
state = "variable";
|
2628
|
-
if (bufferEndIndex > bufferStartIndex) {
|
2629
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
2630
|
-
return tokenCount;
|
2631
|
-
}
|
2632
|
-
bufferStartIndex = bufferEndIndex;
|
2633
|
-
}
|
2634
|
-
index += variablePrefix.length - 1;
|
2635
|
-
bufferStartIndex += variablePrefix.length;
|
2636
|
-
continue;
|
2637
|
-
}
|
2638
|
-
if (char === variableSuffix && state === "variable") {
|
2639
|
-
if (serialized[index - 1] === escapeCharacter) {
|
2640
|
-
bufferEndIndex++;
|
2641
|
-
continue;
|
2642
|
-
}
|
2643
|
-
state = "text";
|
2644
|
-
if (bufferEndIndex > bufferStartIndex) {
|
2645
|
-
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
2646
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
2647
|
-
return tokenCount;
|
2648
|
-
}
|
2649
|
-
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
2650
|
-
}
|
2651
|
-
continue;
|
2652
|
-
}
|
2653
|
-
bufferEndIndex++;
|
2654
|
-
}
|
2655
|
-
if (bufferEndIndex > bufferStartIndex) {
|
2656
|
-
if (state === "variable") {
|
2657
|
-
state = "text";
|
2658
|
-
bufferStartIndex -= variablePrefix.length;
|
2659
|
-
}
|
2660
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
2661
|
-
}
|
2662
|
-
return tokenCount;
|
2663
|
-
}
|
2664
|
-
|
2665
3075
|
// src/utils/variables/bindVariables.ts
|
2666
3076
|
function bindVariables({
|
2667
3077
|
variables,
|
@@ -2699,7 +3109,7 @@ function bindVariables({
|
|
2699
3109
|
}
|
2700
3110
|
|
2701
3111
|
// src/utils/variables/bindVariablesToObject.ts
|
2702
|
-
import { produce } from "immer";
|
3112
|
+
import { isDraft, produce } from "immer";
|
2703
3113
|
|
2704
3114
|
// src/utils/variables/createVariableReference.ts
|
2705
3115
|
function createVariableReference(variableName) {
|
@@ -2727,7 +3137,11 @@ function bindVariablesToObjectRecursive({
|
|
2727
3137
|
if (richTextNodeResult !== void 0) {
|
2728
3138
|
return richTextNodeResult;
|
2729
3139
|
}
|
2730
|
-
const
|
3140
|
+
const produceToUse = !isDraft(value) ? produce : (produceValue, producer) => {
|
3141
|
+
producer(produceValue);
|
3142
|
+
return produceValue;
|
3143
|
+
};
|
3144
|
+
const result = produceToUse(value, (draft) => {
|
2731
3145
|
Object.entries(draft).forEach(([property, oldValue]) => {
|
2732
3146
|
const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
|
2733
3147
|
if (typeof oldValue === "string") {
|
@@ -2787,9 +3201,9 @@ function handleRichTextNodeBinding(object, options) {
|
|
2787
3201
|
import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
|
2788
3202
|
|
2789
3203
|
// src/WorkflowClient.ts
|
2790
|
-
import { ApiClient as
|
3204
|
+
import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
|
2791
3205
|
var workflowsUrl = "/api/v1/workflows";
|
2792
|
-
var WorkflowClient = class extends
|
3206
|
+
var WorkflowClient = class extends ApiClient13 {
|
2793
3207
|
constructor(options) {
|
2794
3208
|
super(options);
|
2795
3209
|
}
|
@@ -2833,6 +3247,7 @@ export {
|
|
2833
3247
|
ATTRIBUTE_PLACEHOLDER,
|
2834
3248
|
ApiClientError2 as ApiClientError,
|
2835
3249
|
BatchEntry,
|
3250
|
+
BlockFormatError,
|
2836
3251
|
CANVAS_BLOCK_PARAM_TYPE,
|
2837
3252
|
CANVAS_DRAFT_STATE,
|
2838
3253
|
CANVAS_EDITOR_STATE,
|
@@ -2850,6 +3265,11 @@ export {
|
|
2850
3265
|
CANVAS_TEST_SLOT,
|
2851
3266
|
CANVAS_TEST_TYPE,
|
2852
3267
|
CANVAS_TEST_VARIANT_PARAM,
|
3268
|
+
CANVAS_VIZ_CONTROL_PARAM,
|
3269
|
+
CANVAS_VIZ_DI_RULE,
|
3270
|
+
CANVAS_VIZ_DYNAMIC_TOKEN_RULE,
|
3271
|
+
CANVAS_VIZ_LOCALE_RULE,
|
3272
|
+
CANVAS_VIZ_QUIRKS_RULE,
|
2853
3273
|
CanvasClient,
|
2854
3274
|
CanvasClientError,
|
2855
3275
|
CategoryClient,
|
@@ -2863,6 +3283,7 @@ export {
|
|
2863
3283
|
EDGE_MIN_CACHE_TTL,
|
2864
3284
|
EMPTY_COMPOSITION,
|
2865
3285
|
EnhancerBuilder,
|
3286
|
+
EntityReleasesClient,
|
2866
3287
|
IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
|
2867
3288
|
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
2868
3289
|
IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
|
@@ -2891,11 +3312,20 @@ export {
|
|
2891
3312
|
convertEntryToPutEntry,
|
2892
3313
|
createBatchEnhancer,
|
2893
3314
|
createCanvasChannel,
|
3315
|
+
createDynamicInputVisibilityRule,
|
3316
|
+
createDynamicTokenVisibilityRule,
|
2894
3317
|
createEventBus,
|
2895
3318
|
createLimitPolicy,
|
3319
|
+
createLocaleVisibilityRule,
|
3320
|
+
createQuirksVisibilityRule,
|
2896
3321
|
createUniformApiEnhancer,
|
2897
3322
|
createVariableReference,
|
2898
3323
|
enhance,
|
3324
|
+
evaluateNodeVisibilityParameter,
|
3325
|
+
evaluatePropertyCriteria,
|
3326
|
+
evaluateVisibilityCriteriaGroup,
|
3327
|
+
evaluateWalkTreeNodeVisibility,
|
3328
|
+
evaluateWalkTreePropertyCriteria,
|
2899
3329
|
extractLocales,
|
2900
3330
|
findParameterInNodeTree,
|
2901
3331
|
flattenValues,
|
@@ -2911,14 +3341,17 @@ export {
|
|
2911
3341
|
getParameterAttributes,
|
2912
3342
|
getPropertiesValue,
|
2913
3343
|
getPropertyValue,
|
3344
|
+
hasReferencedVariables,
|
2914
3345
|
isAddComponentMessage,
|
2915
3346
|
isAllowedReferrer,
|
2916
3347
|
isAssetParamValue,
|
2917
3348
|
isAssetParamValueItem,
|
2918
3349
|
isComponentActionMessage,
|
2919
3350
|
isComponentPlaceholderId,
|
3351
|
+
isContextStorageUpdatedMessage,
|
2920
3352
|
isDismissPlaceholderMessage,
|
2921
3353
|
isEntryData,
|
3354
|
+
isLinkParamValue,
|
2922
3355
|
isMovingComponentMessage,
|
2923
3356
|
isNestedNodeType,
|
2924
3357
|
isOpenParameterEditorMessage,
|