@uniformdev/canvas 19.55.1-alpha.8 → 19.55.2-alpha.14
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 +2260 -624
- package/dist/index.d.ts +2260 -624
- package/dist/index.esm.js +572 -167
- package/dist/index.js +587 -174
- package/dist/index.mjs +572 -167
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -283,8 +283,9 @@ __export(src_exports, {
|
|
283
283
|
ATTRIBUTE_PARAMETER_TYPE: () => ATTRIBUTE_PARAMETER_TYPE,
|
284
284
|
ATTRIBUTE_PARAMETER_VALUE: () => ATTRIBUTE_PARAMETER_VALUE,
|
285
285
|
ATTRIBUTE_PLACEHOLDER: () => ATTRIBUTE_PLACEHOLDER,
|
286
|
-
ApiClientError: () =>
|
286
|
+
ApiClientError: () => import_api10.ApiClientError,
|
287
287
|
BatchEntry: () => BatchEntry,
|
288
|
+
CANVAS_BLOCK_PARAM_TYPE: () => CANVAS_BLOCK_PARAM_TYPE,
|
288
289
|
CANVAS_DRAFT_STATE: () => CANVAS_DRAFT_STATE,
|
289
290
|
CANVAS_EDITOR_STATE: () => CANVAS_EDITOR_STATE,
|
290
291
|
CANVAS_ENRICHMENT_TAG_PARAM: () => CANVAS_ENRICHMENT_TAG_PARAM,
|
@@ -308,11 +309,8 @@ __export(src_exports, {
|
|
308
309
|
DataTypeClient: () => DataTypeClient,
|
309
310
|
EDGE_CACHE_DISABLED: () => EDGE_CACHE_DISABLED,
|
310
311
|
EDGE_DEFAULT_CACHE_TTL: () => EDGE_DEFAULT_CACHE_TTL,
|
311
|
-
EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS: () => EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS,
|
312
312
|
EDGE_MAX_CACHE_TTL: () => EDGE_MAX_CACHE_TTL,
|
313
|
-
EDGE_MAX_L2_CACHE_TTL_IN_HOURS: () => EDGE_MAX_L2_CACHE_TTL_IN_HOURS,
|
314
313
|
EDGE_MIN_CACHE_TTL: () => EDGE_MIN_CACHE_TTL,
|
315
|
-
EDGE_MIN_L2_CACHE_TTL_IN_HOURS: () => EDGE_MIN_L2_CACHE_TTL_IN_HOURS,
|
316
314
|
EMPTY_COMPOSITION: () => EMPTY_COMPOSITION,
|
317
315
|
EnhancerBuilder: () => EnhancerBuilder,
|
318
316
|
IN_CONTEXT_EDITOR_COMPONENT_END_ROLE: () => IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
|
@@ -323,7 +321,9 @@ __export(src_exports, {
|
|
323
321
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM: () => IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
324
322
|
IS_RENDERED_BY_UNIFORM_ATTRIBUTE: () => IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
325
323
|
PLACEHOLDER_ID: () => PLACEHOLDER_ID,
|
324
|
+
PromptClient: () => PromptClient,
|
326
325
|
RouteClient: () => RouteClient,
|
326
|
+
SECRET_QUERY_STRING_PARAM: () => SECRET_QUERY_STRING_PARAM,
|
327
327
|
UncachedCanvasClient: () => UncachedCanvasClient,
|
328
328
|
UncachedCategoryClient: () => UncachedCategoryClient,
|
329
329
|
UncachedContentClient: () => UncachedContentClient,
|
@@ -342,14 +342,19 @@ __export(src_exports, {
|
|
342
342
|
extractLocales: () => extractLocales,
|
343
343
|
generateComponentPlaceholderId: () => generateComponentPlaceholderId,
|
344
344
|
generateHash: () => generateHash,
|
345
|
+
getBlockValue: () => getBlockValue,
|
345
346
|
getChannelName: () => getChannelName,
|
346
347
|
getComponentJsonPointer: () => getComponentJsonPointer,
|
347
348
|
getComponentPath: () => getComponentPath,
|
348
349
|
getParameterAttributes: () => getParameterAttributes,
|
350
|
+
getPropertiesValue: () => getPropertiesValue,
|
349
351
|
isAddComponentMessage: () => isAddComponentMessage,
|
352
|
+
isAllowedReferrer: () => isAllowedReferrer,
|
353
|
+
isComponentActionMessage: () => isComponentActionMessage,
|
350
354
|
isComponentPlaceholderId: () => isComponentPlaceholderId,
|
351
355
|
isDismissPlaceholderMessage: () => isDismissPlaceholderMessage,
|
352
356
|
isMovingComponentMessage: () => isMovingComponentMessage,
|
357
|
+
isOpenParameterEditorMessage: () => isOpenParameterEditorMessage,
|
353
358
|
isReadyMessage: () => isReadyMessage,
|
354
359
|
isReportRenderedCompositionsMessage: () => isReportRenderedCompositionsMessage,
|
355
360
|
isSelectComponentMessage: () => isSelectComponentMessage,
|
@@ -357,9 +362,11 @@ __export(src_exports, {
|
|
357
362
|
isSystemComponentDefinition: () => isSystemComponentDefinition,
|
358
363
|
isTriggerCompositionActionMessage: () => isTriggerCompositionActionMessage,
|
359
364
|
isUpdateComponentParameterMessage: () => isUpdateComponentParameterMessage,
|
365
|
+
isUpdateComponentReferencesMessage: () => isUpdateComponentReferencesMessage,
|
360
366
|
isUpdateCompositionInternalMessage: () => isUpdateCompositionInternalMessage,
|
361
367
|
isUpdateCompositionMessage: () => isUpdateCompositionMessage,
|
362
368
|
isUpdateContextualEditingStateInternalMessage: () => isUpdateContextualEditingStateInternalMessage,
|
369
|
+
isUpdateFeatureFlagsMessage: () => isUpdateFeatureFlagsMessage,
|
363
370
|
isUpdatePreviewSettingsMessage: () => isUpdatePreviewSettingsMessage,
|
364
371
|
localize: () => localize,
|
365
372
|
mapSlotToPersonalizedVariations: () => mapSlotToPersonalizedVariations,
|
@@ -368,7 +375,8 @@ __export(src_exports, {
|
|
368
375
|
parseVariableExpression: () => parseVariableExpression,
|
369
376
|
subscribeToComposition: () => subscribeToComposition,
|
370
377
|
unstable_CompositionRelationshipClient: () => unstable_CompositionRelationshipClient,
|
371
|
-
walkComponentTree: () => walkComponentTree
|
378
|
+
walkComponentTree: () => walkComponentTree,
|
379
|
+
walkNodeTree: () => walkNodeTree
|
372
380
|
});
|
373
381
|
module.exports = __toCommonJS(src_exports);
|
374
382
|
|
@@ -1026,13 +1034,92 @@ function isPromise(obj) {
|
|
1026
1034
|
return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
|
1027
1035
|
}
|
1028
1036
|
|
1029
|
-
// src/enhancement/
|
1030
|
-
function
|
1031
|
-
|
1037
|
+
// src/enhancement/getComponentPath.ts
|
1038
|
+
function getComponentPath(ancestorsAndSelf) {
|
1039
|
+
const path = [];
|
1040
|
+
for (let i = ancestorsAndSelf.length - 1; i >= 0; i--) {
|
1041
|
+
const currentLocation = ancestorsAndSelf[i];
|
1042
|
+
const parentLocation = ancestorsAndSelf[i + 1];
|
1043
|
+
if ("type" in currentLocation && currentLocation.type !== "slot") {
|
1044
|
+
if (currentLocation.type === "block") {
|
1045
|
+
const { fieldName, blockIndex } = currentLocation;
|
1046
|
+
if (fieldName && blockIndex !== void 0) {
|
1047
|
+
const noun = parentLocation && "type" in parentLocation && parentLocation.type === "block" ? "fields" : "parameters";
|
1048
|
+
path.push(`${noun}.${fieldName}.value[${blockIndex}]`);
|
1049
|
+
}
|
1050
|
+
} else {
|
1051
|
+
}
|
1052
|
+
continue;
|
1053
|
+
}
|
1054
|
+
const { parentSlot, parentSlotIndex } = currentLocation;
|
1055
|
+
if (parentSlot && parentSlotIndex !== void 0) {
|
1056
|
+
path.push(`${parentSlot}[${parentSlotIndex}]`);
|
1057
|
+
}
|
1058
|
+
}
|
1059
|
+
return `.${path.join(".")}`;
|
1060
|
+
}
|
1061
|
+
|
1062
|
+
// src/utils/constants.ts
|
1063
|
+
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
1064
|
+
var CANVAS_TEST_TYPE = "$test";
|
1065
|
+
var CANVAS_LOCALIZATION_TYPE = "$localization";
|
1066
|
+
var CANVAS_INTENT_TAG_PARAM = "intentTag";
|
1067
|
+
var CANVAS_LOCALE_TAG_PARAM = "locale";
|
1068
|
+
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
1069
|
+
var CANVAS_PERSONALIZE_SLOT = "pz";
|
1070
|
+
var CANVAS_TEST_SLOT = "test";
|
1071
|
+
var CANVAS_LOCALIZATION_SLOT = "localized";
|
1072
|
+
var CANVAS_DRAFT_STATE = 0;
|
1073
|
+
var CANVAS_PUBLISHED_STATE = 64;
|
1074
|
+
var CANVAS_EDITOR_STATE = 63;
|
1075
|
+
var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
|
1076
|
+
var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
|
1077
|
+
var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
|
1078
|
+
var SECRET_QUERY_STRING_PARAM = "secret";
|
1079
|
+
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
1080
|
+
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
1081
|
+
var IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM = "is_config_check";
|
1082
|
+
var IN_CONTEXT_EDITOR_COMPONENT_START_ROLE = "uniform-component-start";
|
1083
|
+
var IN_CONTEXT_EDITOR_COMPONENT_END_ROLE = "uniform-component-end";
|
1084
|
+
var IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID = "uniform-canvas-preview-script";
|
1085
|
+
var IS_RENDERED_BY_UNIFORM_ATTRIBUTE = "data-is-rendered-by-uniform";
|
1086
|
+
var PLACEHOLDER_ID = "placeholder";
|
1087
|
+
var EMPTY_COMPOSITION = {
|
1088
|
+
_id: "_empty_composition_id",
|
1089
|
+
_name: "An empty composition used for contextual editing",
|
1090
|
+
type: "_empty_composition_type"
|
1091
|
+
};
|
1092
|
+
var EDGE_MIN_CACHE_TTL = 10;
|
1093
|
+
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
1094
|
+
var EDGE_DEFAULT_CACHE_TTL = 30;
|
1095
|
+
var EDGE_CACHE_DISABLED = -1;
|
1096
|
+
|
1097
|
+
// src/utils/entryConverter.ts
|
1098
|
+
function convertEntryToPutEntry(entry) {
|
1099
|
+
return {
|
1100
|
+
entry: {
|
1101
|
+
type: entry.entry.type,
|
1102
|
+
_dataResources: entry.entry._dataResources,
|
1103
|
+
_id: entry.entry._id,
|
1104
|
+
_name: entry.entry._name,
|
1105
|
+
_slug: entry.entry._slug,
|
1106
|
+
fields: entry.entry.fields
|
1107
|
+
},
|
1108
|
+
state: entry.state,
|
1109
|
+
projectId: entry.projectId
|
1110
|
+
};
|
1111
|
+
}
|
1112
|
+
function getPropertiesValue(entity) {
|
1113
|
+
return "parameters" in entity && entity.parameters ? entity.parameters : "fields" in entity && entity.fields ? entity.fields : void 0;
|
1114
|
+
}
|
1115
|
+
|
1116
|
+
// src/enhancement/walkNodeTree.ts
|
1117
|
+
function walkNodeTree(node, visitor, options) {
|
1118
|
+
var _a, _b;
|
1032
1119
|
const componentQueue = [
|
1033
1120
|
{
|
1034
|
-
ancestorsAndSelf:
|
1035
|
-
context: initialContext
|
1121
|
+
ancestorsAndSelf: Array.isArray(node) ? node : [{ node, type: "root" }],
|
1122
|
+
context: options == null ? void 0 : options.initialContext
|
1036
1123
|
}
|
1037
1124
|
];
|
1038
1125
|
const childContexts = /* @__PURE__ */ new Map();
|
@@ -1042,81 +1129,182 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1042
1129
|
continue;
|
1043
1130
|
const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
|
1044
1131
|
let visitDescendants = true;
|
1045
|
-
let descendantContext = (_a = childContexts.get(currentComponent.
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1132
|
+
let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
|
1133
|
+
let visitorInfo;
|
1134
|
+
if (currentComponent.type === "root" || currentComponent.type === "slot") {
|
1135
|
+
visitorInfo = {
|
1136
|
+
type: "component",
|
1137
|
+
node: currentComponent.node,
|
1138
|
+
ancestorsAndSelf: currentQueueEntry.ancestorsAndSelf,
|
1139
|
+
actions: {
|
1140
|
+
replace: (replacementComponent) => {
|
1141
|
+
Object.assign(currentComponent.node, replacementComponent);
|
1142
|
+
const propertiesToCheck = [
|
1143
|
+
"parameters",
|
1144
|
+
"variant",
|
1145
|
+
"slots",
|
1146
|
+
"data",
|
1147
|
+
"_pattern",
|
1148
|
+
"_patternError",
|
1149
|
+
"_dataResources",
|
1150
|
+
"_overridability",
|
1151
|
+
"_overrides",
|
1152
|
+
"_patternDataResources"
|
1153
|
+
];
|
1154
|
+
propertiesToCheck.forEach((property) => {
|
1155
|
+
if (!replacementComponent[property]) {
|
1156
|
+
delete currentComponent.node[property];
|
1157
|
+
}
|
1158
|
+
});
|
1159
|
+
},
|
1160
|
+
remove: () => {
|
1161
|
+
const currentComponentLocation = currentQueueEntry.ancestorsAndSelf[0];
|
1162
|
+
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1163
|
+
if (currentComponentLocation.type === "root") {
|
1164
|
+
throw new Error("Unable to delete root node.");
|
1063
1165
|
}
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1166
|
+
if (currentComponentLocation.type === "slot") {
|
1167
|
+
const { parentSlot, parentSlotIndex } = currentComponentLocation;
|
1168
|
+
parentComponent.node.slots[parentSlot].splice(parentSlotIndex, 1);
|
1169
|
+
} else {
|
1170
|
+
throw new Error("Unknown node type");
|
1171
|
+
}
|
1172
|
+
},
|
1173
|
+
insertAfter: (nodes) => {
|
1174
|
+
const nodesToInsert = Array.isArray(nodes) ? nodes : [nodes];
|
1175
|
+
const currentNodeInfo = currentQueueEntry.ancestorsAndSelf[0];
|
1176
|
+
if (currentNodeInfo.type === "root") {
|
1177
|
+
throw new Error("Unable to insert after root node.");
|
1178
|
+
}
|
1179
|
+
if (currentNodeInfo.type === "slot") {
|
1180
|
+
const { parentSlot, parentSlotIndex } = currentNodeInfo;
|
1181
|
+
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1182
|
+
if (parentSlot && typeof parentSlotIndex !== "undefined") {
|
1183
|
+
parentComponent.node.slots[parentSlot].splice(
|
1184
|
+
parentSlotIndex + 1,
|
1185
|
+
0,
|
1186
|
+
...nodesToInsert
|
1187
|
+
);
|
1188
|
+
componentQueue.unshift(
|
1189
|
+
...nodesToInsert.map((enqueueingComponent) => ({
|
1190
|
+
type: "slot",
|
1191
|
+
ancestorsAndSelf: [
|
1192
|
+
{
|
1193
|
+
type: "slot",
|
1194
|
+
node: enqueueingComponent,
|
1195
|
+
parentSlot,
|
1196
|
+
get parentSlotIndex() {
|
1197
|
+
return parentComponent.node.slots[parentSlot].findIndex(
|
1198
|
+
(x) => x === enqueueingComponent
|
1199
|
+
);
|
1200
|
+
}
|
1201
|
+
},
|
1202
|
+
// slice removes 'self' since we are inserting a peer of self
|
1203
|
+
...currentQueueEntry.ancestorsAndSelf.slice(1)
|
1204
|
+
],
|
1205
|
+
context: descendantContext
|
1206
|
+
}))
|
1207
|
+
);
|
1208
|
+
}
|
1209
|
+
} else {
|
1210
|
+
throw new Error("Unknown type");
|
1211
|
+
}
|
1212
|
+
},
|
1213
|
+
stopProcessingDescendants() {
|
1214
|
+
visitDescendants = false;
|
1215
|
+
},
|
1216
|
+
setDescendantsContext(context) {
|
1217
|
+
descendantContext = context;
|
1218
|
+
},
|
1219
|
+
setChildContext(child, context) {
|
1220
|
+
childContexts.set(child, context);
|
1073
1221
|
}
|
1074
1222
|
},
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
);
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1223
|
+
context: descendantContext
|
1224
|
+
};
|
1225
|
+
} else {
|
1226
|
+
visitorInfo = {
|
1227
|
+
type: "entry",
|
1228
|
+
node: currentComponent.node,
|
1229
|
+
ancestorsAndSelf: currentQueueEntry.ancestorsAndSelf,
|
1230
|
+
actions: {
|
1231
|
+
replace: (replacementNode) => {
|
1232
|
+
Object.assign(currentComponent.node, replacementNode);
|
1233
|
+
const propertiesToCheck = ["fields", "_dataResources", "_author"];
|
1234
|
+
propertiesToCheck.forEach((property) => {
|
1235
|
+
if (!replacementNode[property]) {
|
1236
|
+
delete currentComponent.node[property];
|
1237
|
+
}
|
1238
|
+
});
|
1239
|
+
},
|
1240
|
+
remove: () => {
|
1241
|
+
const currentComponentLocation = currentQueueEntry.ancestorsAndSelf[0];
|
1242
|
+
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1243
|
+
if (currentComponentLocation.type === "block") {
|
1244
|
+
const { fieldName, blockIndex } = currentComponentLocation;
|
1245
|
+
const blockValue = getBlockValue(parentComponent.node, fieldName);
|
1246
|
+
blockValue.splice(blockIndex, 1);
|
1247
|
+
if (blockValue.length === 0) {
|
1248
|
+
const properties2 = getPropertiesValue(parentComponent.node);
|
1249
|
+
delete properties2[fieldName];
|
1250
|
+
}
|
1251
|
+
} else {
|
1252
|
+
throw new Error("Unknown node type");
|
1253
|
+
}
|
1254
|
+
},
|
1255
|
+
insertAfter: (nodes) => {
|
1256
|
+
const currentNodeInfo = currentQueueEntry.ancestorsAndSelf[0];
|
1257
|
+
if (currentNodeInfo.type !== "block") {
|
1258
|
+
throw new Error("Unknown type");
|
1259
|
+
}
|
1260
|
+
const { fieldName, blockIndex } = currentNodeInfo;
|
1261
|
+
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1262
|
+
const nodesToInsert = Array.isArray(nodes) ? nodes : [nodes];
|
1263
|
+
if (fieldName && typeof blockIndex !== "undefined") {
|
1264
|
+
getPropertiesValue(parentComponent.node)[fieldName].value.splice(
|
1265
|
+
blockIndex + 1,
|
1266
|
+
0,
|
1267
|
+
...nodesToInsert
|
1268
|
+
);
|
1269
|
+
componentQueue.unshift(
|
1270
|
+
...nodesToInsert.map((enqueueingComponent) => ({
|
1271
|
+
ancestorsAndSelf: [
|
1272
|
+
{
|
1273
|
+
type: "block",
|
1274
|
+
node: enqueueingComponent,
|
1275
|
+
fieldName,
|
1276
|
+
get blockIndex() {
|
1277
|
+
const parentArray = getPropertiesValue(parentComponent.node)[fieldName].value;
|
1278
|
+
return parentArray.findIndex((x) => x === enqueueingComponent);
|
1279
|
+
}
|
1280
|
+
},
|
1281
|
+
// slice removes 'self' since we are inserting a peer of self
|
1282
|
+
...currentQueueEntry.ancestorsAndSelf.slice(1)
|
1283
|
+
],
|
1284
|
+
context: descendantContext
|
1285
|
+
}))
|
1286
|
+
);
|
1287
|
+
}
|
1288
|
+
},
|
1289
|
+
stopProcessingDescendants() {
|
1290
|
+
visitDescendants = false;
|
1291
|
+
},
|
1292
|
+
setDescendantsContext(context) {
|
1293
|
+
descendantContext = context;
|
1294
|
+
},
|
1295
|
+
setChildContext(child, context) {
|
1296
|
+
childContexts.set(child, context);
|
1104
1297
|
}
|
1105
1298
|
},
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
},
|
1116
|
-
descendantContext
|
1117
|
-
);
|
1118
|
-
const slots = currentComponent.component.slots;
|
1119
|
-
if (visitDescendants && slots) {
|
1299
|
+
context: descendantContext
|
1300
|
+
};
|
1301
|
+
}
|
1302
|
+
visitor(visitorInfo);
|
1303
|
+
if (!visitDescendants) {
|
1304
|
+
continue;
|
1305
|
+
}
|
1306
|
+
const slots = "slots" in currentComponent.node && currentComponent.node.slots;
|
1307
|
+
if (slots) {
|
1120
1308
|
const slotKeys = Object.keys(slots);
|
1121
1309
|
for (let slotIndex = slotKeys.length - 1; slotIndex >= 0; slotIndex--) {
|
1122
1310
|
const slotKey = slotKeys[slotIndex];
|
@@ -1126,10 +1314,11 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1126
1314
|
componentQueue.push({
|
1127
1315
|
ancestorsAndSelf: [
|
1128
1316
|
{
|
1129
|
-
|
1317
|
+
type: "slot",
|
1318
|
+
node: enqueueingComponent,
|
1130
1319
|
parentSlot: slotKey,
|
1131
1320
|
get parentSlotIndex() {
|
1132
|
-
return currentComponent.
|
1321
|
+
return currentComponent.node.slots[slotKey].findIndex(
|
1133
1322
|
(x) => x === enqueueingComponent
|
1134
1323
|
);
|
1135
1324
|
}
|
@@ -1141,27 +1330,44 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1141
1330
|
}
|
1142
1331
|
}
|
1143
1332
|
}
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1333
|
+
const properties = getPropertiesValue(currentComponent.node);
|
1334
|
+
if (properties) {
|
1335
|
+
const propertyEntries = Object.entries(properties);
|
1336
|
+
for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
|
1337
|
+
const [propKey, propObject] = propertyEntries[propIndex];
|
1338
|
+
if (propObject.type !== CANVAS_BLOCK_PARAM_TYPE)
|
1339
|
+
continue;
|
1340
|
+
const blocks = (_b = propObject.value) != null ? _b : [];
|
1341
|
+
for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
|
1342
|
+
const enqueueingBlock = blocks[blockIndex];
|
1343
|
+
componentQueue.push({
|
1344
|
+
ancestorsAndSelf: [
|
1345
|
+
{
|
1346
|
+
type: "block",
|
1347
|
+
node: enqueueingBlock,
|
1348
|
+
fieldName: propKey,
|
1349
|
+
get blockIndex() {
|
1350
|
+
return getBlockValue(currentComponent.node, propKey).findIndex(
|
1351
|
+
(x) => x === enqueueingBlock
|
1352
|
+
);
|
1353
|
+
}
|
1354
|
+
},
|
1355
|
+
...currentQueueEntry.ancestorsAndSelf
|
1356
|
+
],
|
1357
|
+
context: descendantContext
|
1358
|
+
});
|
1359
|
+
}
|
1360
|
+
}
|
1152
1361
|
}
|
1153
|
-
}
|
1154
|
-
return `.${path.join(".")}`;
|
1362
|
+
} while (componentQueue.length > 0);
|
1155
1363
|
}
|
1156
|
-
function
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
path.push(`${parentSlot}/${parentSlotIndex}`);
|
1162
|
-
}
|
1364
|
+
function getBlockValue(component, parameterName) {
|
1365
|
+
var _a;
|
1366
|
+
const parameter = (_a = getPropertiesValue(component)) == null ? void 0 : _a[parameterName];
|
1367
|
+
if ((parameter == null ? void 0 : parameter.value) && parameter.type === CANVAS_BLOCK_PARAM_TYPE && Array.isArray(parameter.value)) {
|
1368
|
+
return parameter.value;
|
1163
1369
|
}
|
1164
|
-
return
|
1370
|
+
return [];
|
1165
1371
|
}
|
1166
1372
|
|
1167
1373
|
// src/enhancement/enhance.ts
|
@@ -1181,19 +1387,21 @@ async function enhance({
|
|
1181
1387
|
const promises = [];
|
1182
1388
|
const usedComponentEnhancers = /* @__PURE__ */ new Set();
|
1183
1389
|
const usedParameterEnhancers = /* @__PURE__ */ new Set();
|
1184
|
-
|
1390
|
+
walkNodeTree(composition, ({ type, node, ancestorsAndSelf, actions }) => {
|
1185
1391
|
var _a;
|
1186
|
-
|
1187
|
-
|
1392
|
+
if (type !== "component") {
|
1393
|
+
actions.stopProcessingDescendants();
|
1394
|
+
return;
|
1395
|
+
}
|
1396
|
+
Object.entries((_a = node.parameters) != null ? _a : {}).forEach(([paramName, paramValue]) => {
|
1397
|
+
const enhancer = enhancers.resolveParameterEnhancer(node, paramName, paramValue);
|
1188
1398
|
if (enhancer) {
|
1189
1399
|
usedParameterEnhancers.add(enhancer);
|
1190
|
-
promises.push(
|
1191
|
-
enhanceParameter(currentComponent, componentContext, paramName, paramValue, enhancer, context)
|
1192
|
-
);
|
1400
|
+
promises.push(enhanceParameter(node, ancestorsAndSelf, paramName, paramValue, enhancer, context));
|
1193
1401
|
}
|
1194
1402
|
});
|
1195
|
-
const componentEnhancers = enhancers.resolveComponentEnhancers(
|
1196
|
-
promises.push(enhanceComponent(
|
1403
|
+
const componentEnhancers = enhancers.resolveComponentEnhancers(node);
|
1404
|
+
promises.push(enhanceComponent(node, ancestorsAndSelf, componentEnhancers, context));
|
1197
1405
|
usedComponentEnhancers.add(componentEnhancers);
|
1198
1406
|
});
|
1199
1407
|
promises.push(
|
@@ -1411,41 +1619,30 @@ var EnhancerBuilder = class {
|
|
1411
1619
|
}
|
1412
1620
|
};
|
1413
1621
|
|
1414
|
-
// src/
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
_id: "_empty_composition_id",
|
1439
|
-
_name: "An empty composition used for contextual editing",
|
1440
|
-
type: "_empty_composition_type"
|
1441
|
-
};
|
1442
|
-
var EDGE_MIN_CACHE_TTL = 15;
|
1443
|
-
var EDGE_MAX_CACHE_TTL = 600;
|
1444
|
-
var EDGE_DEFAULT_CACHE_TTL = 30;
|
1445
|
-
var EDGE_CACHE_DISABLED = -1;
|
1446
|
-
var EDGE_MIN_L2_CACHE_TTL_IN_HOURS = 1;
|
1447
|
-
var EDGE_MAX_L2_CACHE_TTL_IN_HOURS = 4 * 7 * 24;
|
1448
|
-
var EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS = 24;
|
1622
|
+
// src/enhancement/getComponentJsonPointer.ts
|
1623
|
+
function getComponentJsonPointer(ancestorsAndSelf) {
|
1624
|
+
const path = [];
|
1625
|
+
for (let i = ancestorsAndSelf.length - 1; i >= 0; i--) {
|
1626
|
+
const currentLocation = ancestorsAndSelf[i];
|
1627
|
+
const parentLocation = ancestorsAndSelf[i + 1];
|
1628
|
+
if ("type" in currentLocation && currentLocation.type !== "slot") {
|
1629
|
+
if (currentLocation.type === "block") {
|
1630
|
+
const { fieldName: parameterName, blockIndex } = currentLocation;
|
1631
|
+
if (parameterName && blockIndex !== void 0) {
|
1632
|
+
const noun = parentLocation && "type" in parentLocation && parentLocation.type === "block" ? "fields" : "parameters";
|
1633
|
+
path.push(`${noun}/${parameterName}/value/${blockIndex}`);
|
1634
|
+
}
|
1635
|
+
} else {
|
1636
|
+
}
|
1637
|
+
continue;
|
1638
|
+
}
|
1639
|
+
const { parentSlot, parentSlotIndex } = currentLocation;
|
1640
|
+
if (parentSlot && parentSlotIndex !== void 0) {
|
1641
|
+
path.push(`slots/${parentSlot}/${parentSlotIndex}`);
|
1642
|
+
}
|
1643
|
+
}
|
1644
|
+
return `/${path.join("/")}`;
|
1645
|
+
}
|
1449
1646
|
|
1450
1647
|
// src/enhancement/localize.ts
|
1451
1648
|
function extractLocales({ component }) {
|
@@ -1466,22 +1663,26 @@ function localize({
|
|
1466
1663
|
composition,
|
1467
1664
|
locale
|
1468
1665
|
}) {
|
1469
|
-
|
1470
|
-
if (
|
1471
|
-
|
1472
|
-
|
1666
|
+
walkNodeTree(composition, ({ type, node, actions }) => {
|
1667
|
+
if (type !== "component") {
|
1668
|
+
actions.stopProcessingDescendants();
|
1669
|
+
return;
|
1670
|
+
}
|
1671
|
+
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
1672
|
+
const locales = extractLocales({ component: node });
|
1673
|
+
const resolvedLocale = typeof locale === "string" ? locale : locale({ component: node, locales });
|
1473
1674
|
let replaceComponent;
|
1474
1675
|
if (resolvedLocale) {
|
1475
1676
|
replaceComponent = locales[resolvedLocale];
|
1476
1677
|
}
|
1477
1678
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
1478
1679
|
const [first, ...rest] = replaceComponent;
|
1479
|
-
actions.
|
1680
|
+
actions.replace(first);
|
1480
1681
|
if (rest.length) {
|
1481
1682
|
actions.insertAfter(rest);
|
1482
1683
|
}
|
1483
1684
|
} else {
|
1484
|
-
actions.
|
1685
|
+
actions.remove();
|
1485
1686
|
}
|
1486
1687
|
}
|
1487
1688
|
});
|
@@ -1514,6 +1715,124 @@ var UniqueBatchEntries = class {
|
|
1514
1715
|
}
|
1515
1716
|
};
|
1516
1717
|
|
1718
|
+
// src/enhancement/walkComponentTree.ts
|
1719
|
+
function walkComponentTree(component, visitor, initialContext) {
|
1720
|
+
var _a;
|
1721
|
+
const componentQueue = [
|
1722
|
+
{
|
1723
|
+
ancestorsAndSelf: [{ component, parentSlot: void 0, parentSlotIndex: void 0 }],
|
1724
|
+
context: initialContext
|
1725
|
+
}
|
1726
|
+
];
|
1727
|
+
const childContexts = /* @__PURE__ */ new Map();
|
1728
|
+
do {
|
1729
|
+
const currentQueueEntry = componentQueue.pop();
|
1730
|
+
if (!currentQueueEntry)
|
1731
|
+
continue;
|
1732
|
+
const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
|
1733
|
+
let visitDescendants = true;
|
1734
|
+
let descendantContext = (_a = childContexts.get(currentComponent.component)) != null ? _a : currentQueueEntry.context;
|
1735
|
+
visitor(
|
1736
|
+
currentComponent.component,
|
1737
|
+
currentQueueEntry.ancestorsAndSelf,
|
1738
|
+
{
|
1739
|
+
replaceComponent: (replacementComponent) => {
|
1740
|
+
Object.assign(currentComponent.component, replacementComponent);
|
1741
|
+
const propertiesToCheck = [
|
1742
|
+
"parameters",
|
1743
|
+
"variant",
|
1744
|
+
"slots",
|
1745
|
+
"data",
|
1746
|
+
"_pattern",
|
1747
|
+
"_patternError"
|
1748
|
+
];
|
1749
|
+
propertiesToCheck.forEach((property) => {
|
1750
|
+
if (!replacementComponent[property]) {
|
1751
|
+
delete currentComponent.component[property];
|
1752
|
+
}
|
1753
|
+
});
|
1754
|
+
},
|
1755
|
+
removeComponent: () => {
|
1756
|
+
const { parentSlot, parentSlotIndex } = currentQueueEntry.ancestorsAndSelf[0];
|
1757
|
+
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1758
|
+
if (parentSlot && typeof parentSlotIndex !== "undefined") {
|
1759
|
+
parentComponent.component.slots[parentSlot].splice(parentSlotIndex, 1);
|
1760
|
+
} else {
|
1761
|
+
throw new Error("Unable to delete composition.");
|
1762
|
+
}
|
1763
|
+
},
|
1764
|
+
insertAfter: (components) => {
|
1765
|
+
const componentsToInsert = Array.isArray(components) ? components : [components];
|
1766
|
+
const { parentSlot, parentSlotIndex } = currentQueueEntry.ancestorsAndSelf[0];
|
1767
|
+
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1768
|
+
if (parentSlot && typeof parentSlotIndex !== "undefined") {
|
1769
|
+
parentComponent.component.slots[parentSlot].splice(
|
1770
|
+
parentSlotIndex + 1,
|
1771
|
+
0,
|
1772
|
+
...componentsToInsert
|
1773
|
+
);
|
1774
|
+
componentQueue.unshift(
|
1775
|
+
...componentsToInsert.map((enqueueingComponent) => ({
|
1776
|
+
ancestorsAndSelf: [
|
1777
|
+
{
|
1778
|
+
component: enqueueingComponent,
|
1779
|
+
parentSlot,
|
1780
|
+
get parentSlotIndex() {
|
1781
|
+
return parentComponent.component.slots[parentSlot].findIndex(
|
1782
|
+
(x) => x === enqueueingComponent
|
1783
|
+
);
|
1784
|
+
}
|
1785
|
+
},
|
1786
|
+
...currentQueueEntry.ancestorsAndSelf
|
1787
|
+
],
|
1788
|
+
context: descendantContext
|
1789
|
+
}))
|
1790
|
+
);
|
1791
|
+
} else {
|
1792
|
+
throw new Error("Unable to insert after a component not in a slot.");
|
1793
|
+
}
|
1794
|
+
},
|
1795
|
+
stopProcessingDescendants() {
|
1796
|
+
visitDescendants = false;
|
1797
|
+
},
|
1798
|
+
setDescendantsContext(context) {
|
1799
|
+
descendantContext = context;
|
1800
|
+
},
|
1801
|
+
setChildContext(child, context) {
|
1802
|
+
childContexts.set(child, context);
|
1803
|
+
}
|
1804
|
+
},
|
1805
|
+
descendantContext
|
1806
|
+
);
|
1807
|
+
const slots = currentComponent.component.slots;
|
1808
|
+
if (visitDescendants && slots) {
|
1809
|
+
const slotKeys = Object.keys(slots);
|
1810
|
+
for (let slotIndex = slotKeys.length - 1; slotIndex >= 0; slotIndex--) {
|
1811
|
+
const slotKey = slotKeys[slotIndex];
|
1812
|
+
const components = slots[slotKey];
|
1813
|
+
for (let componentIndex = components.length - 1; componentIndex >= 0; componentIndex--) {
|
1814
|
+
const enqueueingComponent = components[componentIndex];
|
1815
|
+
componentQueue.push({
|
1816
|
+
ancestorsAndSelf: [
|
1817
|
+
{
|
1818
|
+
component: enqueueingComponent,
|
1819
|
+
parentSlot: slotKey,
|
1820
|
+
get parentSlotIndex() {
|
1821
|
+
return currentComponent.component.slots[slotKey].findIndex(
|
1822
|
+
(x) => x === enqueueingComponent
|
1823
|
+
);
|
1824
|
+
}
|
1825
|
+
},
|
1826
|
+
...currentQueueEntry.ancestorsAndSelf
|
1827
|
+
],
|
1828
|
+
context: descendantContext
|
1829
|
+
});
|
1830
|
+
}
|
1831
|
+
}
|
1832
|
+
}
|
1833
|
+
} while (componentQueue.length > 0);
|
1834
|
+
}
|
1835
|
+
|
1517
1836
|
// src/utils/hash.ts
|
1518
1837
|
var generateHash = ({
|
1519
1838
|
composition,
|
@@ -1539,6 +1858,9 @@ var isSelectComponentMessage = (message) => {
|
|
1539
1858
|
var isReadyMessage = (message) => {
|
1540
1859
|
return message.type === "ready";
|
1541
1860
|
};
|
1861
|
+
var isComponentActionMessage = (message) => {
|
1862
|
+
return message.type === "trigger-component-action";
|
1863
|
+
};
|
1542
1864
|
var isUpdateCompositionMessage = (message) => {
|
1543
1865
|
return message.type === "update-composition";
|
1544
1866
|
};
|
@@ -1563,6 +1885,9 @@ var isTriggerCompositionActionMessage = (message) => {
|
|
1563
1885
|
var isUpdatePreviewSettingsMessage = (message) => {
|
1564
1886
|
return message.type === "update-preview-settings";
|
1565
1887
|
};
|
1888
|
+
var isUpdateFeatureFlagsMessage = (message) => {
|
1889
|
+
return message.type === "update-feature-flags";
|
1890
|
+
};
|
1566
1891
|
var isUpdateContextualEditingStateInternalMessage = (message) => {
|
1567
1892
|
return message.type === "update-contextual-editing-state-internal";
|
1568
1893
|
};
|
@@ -1572,6 +1897,12 @@ var isReportRenderedCompositionsMessage = (message) => {
|
|
1572
1897
|
var isSelectParameterMessage = (message) => {
|
1573
1898
|
return message.type === "select-parameter";
|
1574
1899
|
};
|
1900
|
+
var isOpenParameterEditorMessage = (message) => {
|
1901
|
+
return message.type === "open-parameter-editor";
|
1902
|
+
};
|
1903
|
+
var isUpdateComponentReferencesMessage = (message) => {
|
1904
|
+
return message.type === "update-component-references";
|
1905
|
+
};
|
1575
1906
|
var createCanvasChannel = ({
|
1576
1907
|
listenTo,
|
1577
1908
|
broadcastTo
|
@@ -1632,6 +1963,13 @@ var createCanvasChannel = ({
|
|
1632
1963
|
};
|
1633
1964
|
postMessage(message);
|
1634
1965
|
};
|
1966
|
+
const triggerComponentAction = (options) => {
|
1967
|
+
const message = {
|
1968
|
+
...options,
|
1969
|
+
type: "trigger-component-action"
|
1970
|
+
};
|
1971
|
+
postMessage(message);
|
1972
|
+
};
|
1635
1973
|
const addComponent = (options) => {
|
1636
1974
|
const message = {
|
1637
1975
|
...options,
|
@@ -1695,12 +2033,33 @@ var createCanvasChannel = ({
|
|
1695
2033
|
};
|
1696
2034
|
postMessage(message);
|
1697
2035
|
};
|
2036
|
+
const openParameterEditor = (options) => {
|
2037
|
+
const message = {
|
2038
|
+
...options,
|
2039
|
+
type: "open-parameter-editor"
|
2040
|
+
};
|
2041
|
+
postMessage(message);
|
2042
|
+
};
|
1698
2043
|
const editorStateUpdated = () => {
|
1699
2044
|
const message = {
|
1700
2045
|
type: "editor-state-updated"
|
1701
2046
|
};
|
1702
2047
|
postMessage(message);
|
1703
2048
|
};
|
2049
|
+
const updateComponentReferences = (options) => {
|
2050
|
+
const message = {
|
2051
|
+
...options,
|
2052
|
+
type: "update-component-references"
|
2053
|
+
};
|
2054
|
+
postMessage(message);
|
2055
|
+
};
|
2056
|
+
const updateFeatureFlags = (options) => {
|
2057
|
+
const message = {
|
2058
|
+
...options,
|
2059
|
+
type: "update-feature-flags"
|
2060
|
+
};
|
2061
|
+
postMessage(message);
|
2062
|
+
};
|
1704
2063
|
const messageEventListener = (event) => {
|
1705
2064
|
if (typeof event.data !== "string") {
|
1706
2065
|
return;
|
@@ -1730,6 +2089,7 @@ var createCanvasChannel = ({
|
|
1730
2089
|
return {
|
1731
2090
|
ready,
|
1732
2091
|
destroy,
|
2092
|
+
triggerComponentAction,
|
1733
2093
|
selectComponent,
|
1734
2094
|
updateComposition,
|
1735
2095
|
updateCompositionInternal,
|
@@ -1740,10 +2100,13 @@ var createCanvasChannel = ({
|
|
1740
2100
|
dismissPlaceholder,
|
1741
2101
|
triggerCompositionAction,
|
1742
2102
|
updatePreviewSettings,
|
2103
|
+
updateFeatureFlags,
|
1743
2104
|
updateContextualEditingStateInternal,
|
1744
2105
|
selectParameter,
|
2106
|
+
openParameterEditor,
|
1745
2107
|
reportRenderedCompositions,
|
1746
|
-
editorStateUpdated
|
2108
|
+
editorStateUpdated,
|
2109
|
+
updateComponentReferences
|
1747
2110
|
};
|
1748
2111
|
};
|
1749
2112
|
|
@@ -1825,10 +2188,50 @@ function subscribeToComposition({
|
|
1825
2188
|
};
|
1826
2189
|
}
|
1827
2190
|
|
1828
|
-
// src/
|
2191
|
+
// src/PromptClient.ts
|
1829
2192
|
var import_api8 = require("@uniformdev/context/api");
|
2193
|
+
var PromptUrl = "/api/v1/prompt";
|
2194
|
+
var PromptsUrl = "/api/v1/prompts";
|
2195
|
+
var PromptClient = class extends import_api8.ApiClient {
|
2196
|
+
constructor(options) {
|
2197
|
+
super(options);
|
2198
|
+
}
|
2199
|
+
/** Fetches all Prompts for a project */
|
2200
|
+
async get(options) {
|
2201
|
+
const { projectId } = this.options;
|
2202
|
+
const fetchUri = this.createUrl(PromptUrl, { ...options, projectId });
|
2203
|
+
return await this.apiClient(fetchUri);
|
2204
|
+
}
|
2205
|
+
/** Fetches all Prompts for a project */
|
2206
|
+
async getList(options) {
|
2207
|
+
const { projectId } = this.options;
|
2208
|
+
const fetchUri = this.createUrl(PromptsUrl, { ...options, projectId });
|
2209
|
+
return await this.apiClient(fetchUri);
|
2210
|
+
}
|
2211
|
+
/** Updates or creates (based on id) a Prompt */
|
2212
|
+
async upsert(body) {
|
2213
|
+
const fetchUri = this.createUrl(PromptUrl);
|
2214
|
+
await this.apiClient(fetchUri, {
|
2215
|
+
method: "PUT",
|
2216
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2217
|
+
expectNoContent: true
|
2218
|
+
});
|
2219
|
+
}
|
2220
|
+
/** Deletes a Prompt */
|
2221
|
+
async remove(body) {
|
2222
|
+
const fetchUri = this.createUrl(PromptUrl);
|
2223
|
+
await this.apiClient(fetchUri, {
|
2224
|
+
method: "DELETE",
|
2225
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2226
|
+
expectNoContent: true
|
2227
|
+
});
|
2228
|
+
}
|
2229
|
+
};
|
2230
|
+
|
2231
|
+
// src/RouteClient.ts
|
2232
|
+
var import_api9 = require("@uniformdev/context/api");
|
1830
2233
|
var ROUTE_URL = "/api/v1/route";
|
1831
|
-
var RouteClient = class extends
|
2234
|
+
var RouteClient = class extends import_api9.ApiClient {
|
1832
2235
|
constructor(options) {
|
1833
2236
|
var _a;
|
1834
2237
|
if (!options.limitPolicy) {
|
@@ -1867,20 +2270,6 @@ var createUniformApiEnhancer = ({ apiUrl }) => {
|
|
1867
2270
|
};
|
1868
2271
|
};
|
1869
2272
|
|
1870
|
-
// src/utils/entryConverter.ts
|
1871
|
-
function convertEntryToPutEntry(entry) {
|
1872
|
-
return {
|
1873
|
-
entry: {
|
1874
|
-
type: entry.entry.type,
|
1875
|
-
_dataResources: entry.entry._dataResources,
|
1876
|
-
_id: entry.entry._id,
|
1877
|
-
fields: entry.entry.fields
|
1878
|
-
},
|
1879
|
-
state: entry.state,
|
1880
|
-
projectId: entry.projectId
|
1881
|
-
};
|
1882
|
-
}
|
1883
|
-
|
1884
2273
|
// src/utils/getParameterAttributes.ts
|
1885
2274
|
var ATTRIBUTE_COMPONENT_ID = "data-uniform-component-id";
|
1886
2275
|
var ATTRIBUTE_PARAMETER_ID = "data-uniform-parameter-id";
|
@@ -1911,6 +2300,11 @@ var getParameterAttributes = ({
|
|
1911
2300
|
};
|
1912
2301
|
};
|
1913
2302
|
|
2303
|
+
// src/utils/isAllowedReferrer.ts
|
2304
|
+
var isAllowedReferrer = (referrer) => {
|
2305
|
+
return Boolean(referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//));
|
2306
|
+
};
|
2307
|
+
|
1914
2308
|
// src/utils/isSystemComponentDefinition.ts
|
1915
2309
|
var isSystemComponentDefinition = (componentType) => {
|
1916
2310
|
return componentType.startsWith("$");
|
@@ -1955,7 +2349,10 @@ var isComponentPlaceholderId = (id) => {
|
|
1955
2349
|
}
|
1956
2350
|
return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
|
1957
2351
|
};
|
1958
|
-
var generateComponentPlaceholderId = (randomId) => {
|
2352
|
+
var generateComponentPlaceholderId = (randomId, sdkVersion) => {
|
2353
|
+
if (typeof sdkVersion === "undefined" || sdkVersion === 1) {
|
2354
|
+
return PLACEHOLDER_ID;
|
2355
|
+
}
|
1959
2356
|
return `${PLACEHOLDER_ID}_${randomId}`;
|
1960
2357
|
};
|
1961
2358
|
|
@@ -2094,7 +2491,15 @@ function bindVariablesToObjectRecursive({
|
|
2094
2491
|
boundCount += bindResult.boundCount;
|
2095
2492
|
draft[property] = bindResult.result;
|
2096
2493
|
if (bindResult.errors) {
|
2097
|
-
errors.push(
|
2494
|
+
errors.push(
|
2495
|
+
...bindResult.errors.map((e) => {
|
2496
|
+
if (typeof e === "string") {
|
2497
|
+
return `${currentObjectPath}: ${e}`;
|
2498
|
+
}
|
2499
|
+
e.message = `${currentObjectPath}: ${e.message}`;
|
2500
|
+
return e;
|
2501
|
+
})
|
2502
|
+
);
|
2098
2503
|
}
|
2099
2504
|
}
|
2100
2505
|
return;
|
@@ -2134,8 +2539,8 @@ function handleRichTextNodeBinding(object, options) {
|
|
2134
2539
|
}
|
2135
2540
|
|
2136
2541
|
// src/index.ts
|
2137
|
-
var
|
2138
|
-
var CanvasClientError =
|
2542
|
+
var import_api10 = require("@uniformdev/context/api");
|
2543
|
+
var CanvasClientError = import_api10.ApiClientError;
|
2139
2544
|
// Annotate the CommonJS export names for ESM import in node:
|
2140
2545
|
0 && (module.exports = {
|
2141
2546
|
ATTRIBUTE_COMPONENT_ID,
|
@@ -2146,6 +2551,7 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2146
2551
|
ATTRIBUTE_PLACEHOLDER,
|
2147
2552
|
ApiClientError,
|
2148
2553
|
BatchEntry,
|
2554
|
+
CANVAS_BLOCK_PARAM_TYPE,
|
2149
2555
|
CANVAS_DRAFT_STATE,
|
2150
2556
|
CANVAS_EDITOR_STATE,
|
2151
2557
|
CANVAS_ENRICHMENT_TAG_PARAM,
|
@@ -2169,11 +2575,8 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2169
2575
|
DataTypeClient,
|
2170
2576
|
EDGE_CACHE_DISABLED,
|
2171
2577
|
EDGE_DEFAULT_CACHE_TTL,
|
2172
|
-
EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS,
|
2173
2578
|
EDGE_MAX_CACHE_TTL,
|
2174
|
-
EDGE_MAX_L2_CACHE_TTL_IN_HOURS,
|
2175
2579
|
EDGE_MIN_CACHE_TTL,
|
2176
|
-
EDGE_MIN_L2_CACHE_TTL_IN_HOURS,
|
2177
2580
|
EMPTY_COMPOSITION,
|
2178
2581
|
EnhancerBuilder,
|
2179
2582
|
IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
|
@@ -2184,7 +2587,9 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2184
2587
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
2185
2588
|
IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
2186
2589
|
PLACEHOLDER_ID,
|
2590
|
+
PromptClient,
|
2187
2591
|
RouteClient,
|
2592
|
+
SECRET_QUERY_STRING_PARAM,
|
2188
2593
|
UncachedCanvasClient,
|
2189
2594
|
UncachedCategoryClient,
|
2190
2595
|
UncachedContentClient,
|
@@ -2203,14 +2608,19 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2203
2608
|
extractLocales,
|
2204
2609
|
generateComponentPlaceholderId,
|
2205
2610
|
generateHash,
|
2611
|
+
getBlockValue,
|
2206
2612
|
getChannelName,
|
2207
2613
|
getComponentJsonPointer,
|
2208
2614
|
getComponentPath,
|
2209
2615
|
getParameterAttributes,
|
2616
|
+
getPropertiesValue,
|
2210
2617
|
isAddComponentMessage,
|
2618
|
+
isAllowedReferrer,
|
2619
|
+
isComponentActionMessage,
|
2211
2620
|
isComponentPlaceholderId,
|
2212
2621
|
isDismissPlaceholderMessage,
|
2213
2622
|
isMovingComponentMessage,
|
2623
|
+
isOpenParameterEditorMessage,
|
2214
2624
|
isReadyMessage,
|
2215
2625
|
isReportRenderedCompositionsMessage,
|
2216
2626
|
isSelectComponentMessage,
|
@@ -2218,9 +2628,11 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2218
2628
|
isSystemComponentDefinition,
|
2219
2629
|
isTriggerCompositionActionMessage,
|
2220
2630
|
isUpdateComponentParameterMessage,
|
2631
|
+
isUpdateComponentReferencesMessage,
|
2221
2632
|
isUpdateCompositionInternalMessage,
|
2222
2633
|
isUpdateCompositionMessage,
|
2223
2634
|
isUpdateContextualEditingStateInternalMessage,
|
2635
|
+
isUpdateFeatureFlagsMessage,
|
2224
2636
|
isUpdatePreviewSettingsMessage,
|
2225
2637
|
localize,
|
2226
2638
|
mapSlotToPersonalizedVariations,
|
@@ -2229,5 +2641,6 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2229
2641
|
parseVariableExpression,
|
2230
2642
|
subscribeToComposition,
|
2231
2643
|
unstable_CompositionRelationshipClient,
|
2232
|
-
walkComponentTree
|
2644
|
+
walkComponentTree,
|
2645
|
+
walkNodeTree
|
2233
2646
|
});
|