@uniformdev/canvas 20.1.1-alpha.2 → 20.3.1-alpha.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.d.mts +133 -2
- package/dist/index.d.ts +133 -2
- package/dist/index.esm.js +148 -8
- package/dist/index.js +155 -9
- package/dist/index.mjs +148 -8
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
@@ -805,6 +805,9 @@ var _ContentClient = class _ContentClient extends ApiClient3 {
|
|
805
805
|
}
|
806
806
|
async upsertContentType(body, opts = {}) {
|
807
807
|
const fetchUri = this.createUrl(__privateGet(_ContentClient, _contentTypesUrl));
|
808
|
+
if (typeof body.contentType.slugSettings === "object" && body.contentType.slugSettings !== null && Object.keys(body.contentType.slugSettings).length === 0) {
|
809
|
+
delete body.contentType.slugSettings;
|
810
|
+
}
|
808
811
|
await this.apiClient(fetchUri, {
|
809
812
|
method: "PUT",
|
810
813
|
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
@@ -1855,6 +1858,101 @@ function findParameterInNodeTree(data, predicate) {
|
|
1855
1858
|
return results;
|
1856
1859
|
}
|
1857
1860
|
|
1861
|
+
// src/utils/variables/convertToBindExpression.ts
|
1862
|
+
var bindExpressionPrefix = "#";
|
1863
|
+
var bindExpressionEscapeChars = /* @__PURE__ */ new Set(["#", "\\", "[", "]", ":"]);
|
1864
|
+
function convertToBindExpression(binding) {
|
1865
|
+
if (binding.syntax === "jptr") {
|
1866
|
+
const expressionComponents = [
|
1867
|
+
`${bindExpressionPrefix}${binding.syntax}:${escapeNestedVariableExpressions(
|
1868
|
+
escapeBindExpressionReservedChars(binding.pointer)
|
1869
|
+
)}`
|
1870
|
+
];
|
1871
|
+
if (binding.failureAction && binding.failureAction !== "t") {
|
1872
|
+
expressionComponents.push(`fa=${binding.failureAction}`);
|
1873
|
+
}
|
1874
|
+
if (binding.failureLogLevel && binding.failureLogLevel !== "w") {
|
1875
|
+
expressionComponents.push(`fl=${binding.failureLogLevel}`);
|
1876
|
+
}
|
1877
|
+
if (binding.failureDefault) {
|
1878
|
+
expressionComponents.push(`fd=${escapeBindExpressionDefaultValue(binding.failureDefault)}`);
|
1879
|
+
}
|
1880
|
+
return expressionComponents.join(":");
|
1881
|
+
}
|
1882
|
+
throw new Error(`Unsupported dynamic token binding syntax '${binding.syntax}'`);
|
1883
|
+
}
|
1884
|
+
function escapeNestedVariableExpressions(pointer) {
|
1885
|
+
return pointer.replace(/\$\{([^}]+)\}/g, "$[$1]");
|
1886
|
+
}
|
1887
|
+
function escapeBindExpressionReservedChars(pointer) {
|
1888
|
+
return pointer.split("").map((c) => bindExpressionEscapeChars.has(c) ? `\\${c === ":" ? ";" : c}` : c).join("");
|
1889
|
+
}
|
1890
|
+
function escapeBindExpressionDefaultValue(defaultValue) {
|
1891
|
+
return escapeBindExpressionReservedChars(defaultValue).replace("=", "\\+");
|
1892
|
+
}
|
1893
|
+
|
1894
|
+
// src/utils/variables/createVariableReference.ts
|
1895
|
+
function createVariableReference(variableName) {
|
1896
|
+
return `\${${variableName.replace(/([${}])/g, "\\$1")}}`;
|
1897
|
+
}
|
1898
|
+
|
1899
|
+
// src/enhancement/getEffectivePropertyValue.ts
|
1900
|
+
function getEffectivePropertyValue({
|
1901
|
+
property,
|
1902
|
+
conditionIndex,
|
1903
|
+
locale,
|
1904
|
+
strict,
|
1905
|
+
greedyLocaleMatching
|
1906
|
+
}) {
|
1907
|
+
var _a, _b, _c, _d;
|
1908
|
+
if (!property) {
|
1909
|
+
return void 0;
|
1910
|
+
}
|
1911
|
+
let effectiveValue = property.value;
|
1912
|
+
if (conditionIndex >= 0) {
|
1913
|
+
const conditionalValue = (_b = (_a = property.conditions) == null ? void 0 : _a[conditionIndex]) == null ? void 0 : _b.value;
|
1914
|
+
if (conditionalValue === null) {
|
1915
|
+
return void 0;
|
1916
|
+
}
|
1917
|
+
if (conditionalValue !== void 0 || strict) {
|
1918
|
+
effectiveValue = conditionalValue;
|
1919
|
+
}
|
1920
|
+
}
|
1921
|
+
if (locale) {
|
1922
|
+
const localeValue = getLocaleMatch(property.locales, locale, greedyLocaleMatching);
|
1923
|
+
if (localeValue !== void 0 || strict) {
|
1924
|
+
effectiveValue = localeValue;
|
1925
|
+
}
|
1926
|
+
if (conditionIndex >= 0) {
|
1927
|
+
const localeConditionalValue = (_d = (_c = getLocaleMatch(
|
1928
|
+
property.localesConditions,
|
1929
|
+
locale,
|
1930
|
+
greedyLocaleMatching
|
1931
|
+
)) == null ? void 0 : _c[conditionIndex]) == null ? void 0 : _d.value;
|
1932
|
+
if (localeConditionalValue === null) {
|
1933
|
+
return void 0;
|
1934
|
+
}
|
1935
|
+
if (localeConditionalValue !== void 0 || strict) {
|
1936
|
+
effectiveValue = localeConditionalValue;
|
1937
|
+
}
|
1938
|
+
}
|
1939
|
+
}
|
1940
|
+
if (property.connectedData) {
|
1941
|
+
effectiveValue = createVariableReference(convertToBindExpression(property.connectedData));
|
1942
|
+
}
|
1943
|
+
return effectiveValue;
|
1944
|
+
}
|
1945
|
+
function getLocaleMatch(index, locale, greedy) {
|
1946
|
+
if (!index) {
|
1947
|
+
return void 0;
|
1948
|
+
}
|
1949
|
+
const match = index[locale];
|
1950
|
+
if (match === void 0 && greedy) {
|
1951
|
+
return Object.values(index)[0];
|
1952
|
+
}
|
1953
|
+
return match;
|
1954
|
+
}
|
1955
|
+
|
1858
1956
|
// src/enhancement/visibility/evaluateVisibilityCriteriaGroup.ts
|
1859
1957
|
function evaluateVisibilityCriteriaGroup(options) {
|
1860
1958
|
const { criteriaGroup, simplifyCriteria } = options;
|
@@ -2356,6 +2454,33 @@ var UniqueBatchEntries = class {
|
|
2356
2454
|
}
|
2357
2455
|
};
|
2358
2456
|
|
2457
|
+
// src/enhancement/walkPropertyValues.ts
|
2458
|
+
function walkPropertyValues(property, visitor) {
|
2459
|
+
var _a, _b;
|
2460
|
+
const definedLocales = /* @__PURE__ */ new Set([
|
2461
|
+
...Object.keys((_a = property.locales) != null ? _a : {}),
|
2462
|
+
...Object.keys((_b = property.localesConditions) != null ? _b : {})
|
2463
|
+
]);
|
2464
|
+
const propertyLocales = [void 0, ...definedLocales];
|
2465
|
+
propertyLocales.forEach((locale) => {
|
2466
|
+
var _a2, _b2;
|
2467
|
+
const conditionalValues = (_b2 = locale === void 0 ? property.conditions : (_a2 = property.localesConditions) == null ? void 0 : _a2[locale]) != null ? _b2 : [];
|
2468
|
+
for (let conditionIndex = conditionalValues.length - 1; conditionIndex >= -1; conditionIndex--) {
|
2469
|
+
const value = getEffectivePropertyValue({
|
2470
|
+
property,
|
2471
|
+
locale,
|
2472
|
+
conditionIndex,
|
2473
|
+
strict: true
|
2474
|
+
});
|
2475
|
+
visitor({
|
2476
|
+
locale,
|
2477
|
+
conditionIndex,
|
2478
|
+
value
|
2479
|
+
});
|
2480
|
+
}
|
2481
|
+
});
|
2482
|
+
}
|
2483
|
+
|
2359
2484
|
// src/EntityReleasesClient.ts
|
2360
2485
|
import { ApiClient as ApiClient6 } from "@uniformdev/context/api";
|
2361
2486
|
var releaseContentsUrl = "/api/v1/entity-releases";
|
@@ -2601,6 +2726,20 @@ var createCanvasChannel = ({
|
|
2601
2726
|
};
|
2602
2727
|
postMessage(message);
|
2603
2728
|
};
|
2729
|
+
const requestPageHtml = (options) => {
|
2730
|
+
const message = {
|
2731
|
+
...options,
|
2732
|
+
type: "request-page-html"
|
2733
|
+
};
|
2734
|
+
postMessage(message);
|
2735
|
+
};
|
2736
|
+
const sendPageHtml = (options) => {
|
2737
|
+
const message = {
|
2738
|
+
...options,
|
2739
|
+
type: "send-page-html"
|
2740
|
+
};
|
2741
|
+
postMessage(message);
|
2742
|
+
};
|
2604
2743
|
const updateContextualEditingStateInternal = (options) => {
|
2605
2744
|
const message = {
|
2606
2745
|
...options,
|
@@ -2720,6 +2859,8 @@ var createCanvasChannel = ({
|
|
2720
2859
|
updateComponentReferences,
|
2721
2860
|
requestComponentSuggestion,
|
2722
2861
|
suggestComponent,
|
2862
|
+
requestPageHtml,
|
2863
|
+
sendPageHtml,
|
2723
2864
|
contextStorageUpdated
|
2724
2865
|
};
|
2725
2866
|
};
|
@@ -3139,13 +3280,6 @@ function bindVariables({
|
|
3139
3280
|
|
3140
3281
|
// src/utils/variables/bindVariablesToObject.ts
|
3141
3282
|
import { isDraft, produce } from "immer";
|
3142
|
-
|
3143
|
-
// src/utils/variables/createVariableReference.ts
|
3144
|
-
function createVariableReference(variableName) {
|
3145
|
-
return `\${${variableName.replace(/([${}])/g, "\\$1")}}`;
|
3146
|
-
}
|
3147
|
-
|
3148
|
-
// src/utils/variables/bindVariablesToObject.ts
|
3149
3283
|
function bindVariablesToObject(options) {
|
3150
3284
|
return bindVariablesToObjectRecursive(options);
|
3151
3285
|
}
|
@@ -3337,10 +3471,13 @@ export {
|
|
3337
3471
|
UncachedContentClient,
|
3338
3472
|
UniqueBatchEntries,
|
3339
3473
|
WorkflowClient,
|
3474
|
+
bindExpressionEscapeChars,
|
3475
|
+
bindExpressionPrefix,
|
3340
3476
|
bindVariables,
|
3341
3477
|
bindVariablesToObject,
|
3342
3478
|
compose,
|
3343
3479
|
convertEntryToPutEntry,
|
3480
|
+
convertToBindExpression,
|
3344
3481
|
createBatchEnhancer,
|
3345
3482
|
createCanvasChannel,
|
3346
3483
|
createDynamicInputVisibilityRule,
|
@@ -3351,6 +3488,7 @@ export {
|
|
3351
3488
|
createUniformApiEnhancer,
|
3352
3489
|
createVariableReference,
|
3353
3490
|
enhance,
|
3491
|
+
escapeBindExpressionDefaultValue,
|
3354
3492
|
evaluateNodeVisibilityParameter,
|
3355
3493
|
evaluatePropertyCriteria,
|
3356
3494
|
evaluateVisibilityCriteriaGroup,
|
@@ -3365,6 +3503,7 @@ export {
|
|
3365
3503
|
getComponentJsonPointer,
|
3366
3504
|
getComponentPath,
|
3367
3505
|
getDataSourceVariantFromRouteGetParams,
|
3506
|
+
getEffectivePropertyValue,
|
3368
3507
|
getLocalizedPropertyValues,
|
3369
3508
|
getNounForLocation,
|
3370
3509
|
getNounForNode,
|
@@ -3406,5 +3545,6 @@ export {
|
|
3406
3545
|
nullLimitPolicy,
|
3407
3546
|
parseComponentPlaceholderId,
|
3408
3547
|
parseVariableExpression,
|
3409
|
-
walkNodeTree
|
3548
|
+
walkNodeTree,
|
3549
|
+
walkPropertyValues
|
3410
3550
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/canvas",
|
3
|
-
"version": "20.
|
3
|
+
"version": "20.3.1-alpha.0+86ebe90984",
|
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,9 +38,9 @@
|
|
38
38
|
"p-throttle": "5.0.0"
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@uniformdev/assets": "20.
|
42
|
-
"@uniformdev/context": "20.
|
43
|
-
"@uniformdev/richtext": "20.
|
41
|
+
"@uniformdev/assets": "20.3.1-alpha.0+86ebe90984",
|
42
|
+
"@uniformdev/context": "20.3.1-alpha.0+86ebe90984",
|
43
|
+
"@uniformdev/richtext": "20.3.1-alpha.0+86ebe90984",
|
44
44
|
"immer": "10.1.1"
|
45
45
|
},
|
46
46
|
"files": [
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"publishConfig": {
|
50
50
|
"access": "public"
|
51
51
|
},
|
52
|
-
"gitHead": "
|
52
|
+
"gitHead": "86ebe909840ce1e8a9ecabc93298b5243a7b6179"
|
53
53
|
}
|