@uniformdev/canvas 19.54.3-alpha.5 → 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 +2266 -627
- package/dist/index.d.ts +2266 -627
- package/dist/index.esm.js +584 -166
- package/dist/index.js +601 -173
- package/dist/index.mjs +584 -166
- package/package.json +14 -5
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,
|
@@ -340,14 +340,21 @@ __export(src_exports, {
|
|
340
340
|
createVariableReference: () => createVariableReference,
|
341
341
|
enhance: () => enhance,
|
342
342
|
extractLocales: () => extractLocales,
|
343
|
+
generateComponentPlaceholderId: () => generateComponentPlaceholderId,
|
343
344
|
generateHash: () => generateHash,
|
345
|
+
getBlockValue: () => getBlockValue,
|
344
346
|
getChannelName: () => getChannelName,
|
345
347
|
getComponentJsonPointer: () => getComponentJsonPointer,
|
346
348
|
getComponentPath: () => getComponentPath,
|
347
349
|
getParameterAttributes: () => getParameterAttributes,
|
350
|
+
getPropertiesValue: () => getPropertiesValue,
|
348
351
|
isAddComponentMessage: () => isAddComponentMessage,
|
352
|
+
isAllowedReferrer: () => isAllowedReferrer,
|
353
|
+
isComponentActionMessage: () => isComponentActionMessage,
|
354
|
+
isComponentPlaceholderId: () => isComponentPlaceholderId,
|
349
355
|
isDismissPlaceholderMessage: () => isDismissPlaceholderMessage,
|
350
356
|
isMovingComponentMessage: () => isMovingComponentMessage,
|
357
|
+
isOpenParameterEditorMessage: () => isOpenParameterEditorMessage,
|
351
358
|
isReadyMessage: () => isReadyMessage,
|
352
359
|
isReportRenderedCompositionsMessage: () => isReportRenderedCompositionsMessage,
|
353
360
|
isSelectComponentMessage: () => isSelectComponentMessage,
|
@@ -355,9 +362,11 @@ __export(src_exports, {
|
|
355
362
|
isSystemComponentDefinition: () => isSystemComponentDefinition,
|
356
363
|
isTriggerCompositionActionMessage: () => isTriggerCompositionActionMessage,
|
357
364
|
isUpdateComponentParameterMessage: () => isUpdateComponentParameterMessage,
|
365
|
+
isUpdateComponentReferencesMessage: () => isUpdateComponentReferencesMessage,
|
358
366
|
isUpdateCompositionInternalMessage: () => isUpdateCompositionInternalMessage,
|
359
367
|
isUpdateCompositionMessage: () => isUpdateCompositionMessage,
|
360
368
|
isUpdateContextualEditingStateInternalMessage: () => isUpdateContextualEditingStateInternalMessage,
|
369
|
+
isUpdateFeatureFlagsMessage: () => isUpdateFeatureFlagsMessage,
|
361
370
|
isUpdatePreviewSettingsMessage: () => isUpdatePreviewSettingsMessage,
|
362
371
|
localize: () => localize,
|
363
372
|
mapSlotToPersonalizedVariations: () => mapSlotToPersonalizedVariations,
|
@@ -366,7 +375,8 @@ __export(src_exports, {
|
|
366
375
|
parseVariableExpression: () => parseVariableExpression,
|
367
376
|
subscribeToComposition: () => subscribeToComposition,
|
368
377
|
unstable_CompositionRelationshipClient: () => unstable_CompositionRelationshipClient,
|
369
|
-
walkComponentTree: () => walkComponentTree
|
378
|
+
walkComponentTree: () => walkComponentTree,
|
379
|
+
walkNodeTree: () => walkNodeTree
|
370
380
|
});
|
371
381
|
module.exports = __toCommonJS(src_exports);
|
372
382
|
|
@@ -1024,13 +1034,92 @@ function isPromise(obj) {
|
|
1024
1034
|
return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
|
1025
1035
|
}
|
1026
1036
|
|
1027
|
-
// src/enhancement/
|
1028
|
-
function
|
1029
|
-
|
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;
|
1030
1119
|
const componentQueue = [
|
1031
1120
|
{
|
1032
|
-
ancestorsAndSelf:
|
1033
|
-
context: initialContext
|
1121
|
+
ancestorsAndSelf: Array.isArray(node) ? node : [{ node, type: "root" }],
|
1122
|
+
context: options == null ? void 0 : options.initialContext
|
1034
1123
|
}
|
1035
1124
|
];
|
1036
1125
|
const childContexts = /* @__PURE__ */ new Map();
|
@@ -1040,81 +1129,182 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1040
1129
|
continue;
|
1041
1130
|
const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
|
1042
1131
|
let visitDescendants = true;
|
1043
|
-
let descendantContext = (_a = childContexts.get(currentComponent.
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
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.");
|
1061
1165
|
}
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
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);
|
1071
1221
|
}
|
1072
1222
|
},
|
1073
|
-
|
1074
|
-
|
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
|
-
|
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);
|
1102
1297
|
}
|
1103
1298
|
},
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
},
|
1114
|
-
descendantContext
|
1115
|
-
);
|
1116
|
-
const slots = currentComponent.component.slots;
|
1117
|
-
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) {
|
1118
1308
|
const slotKeys = Object.keys(slots);
|
1119
1309
|
for (let slotIndex = slotKeys.length - 1; slotIndex >= 0; slotIndex--) {
|
1120
1310
|
const slotKey = slotKeys[slotIndex];
|
@@ -1124,10 +1314,11 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1124
1314
|
componentQueue.push({
|
1125
1315
|
ancestorsAndSelf: [
|
1126
1316
|
{
|
1127
|
-
|
1317
|
+
type: "slot",
|
1318
|
+
node: enqueueingComponent,
|
1128
1319
|
parentSlot: slotKey,
|
1129
1320
|
get parentSlotIndex() {
|
1130
|
-
return currentComponent.
|
1321
|
+
return currentComponent.node.slots[slotKey].findIndex(
|
1131
1322
|
(x) => x === enqueueingComponent
|
1132
1323
|
);
|
1133
1324
|
}
|
@@ -1139,27 +1330,44 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1139
1330
|
}
|
1140
1331
|
}
|
1141
1332
|
}
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
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
|
+
}
|
1150
1361
|
}
|
1151
|
-
}
|
1152
|
-
return `.${path.join(".")}`;
|
1362
|
+
} while (componentQueue.length > 0);
|
1153
1363
|
}
|
1154
|
-
function
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
path.push(`${parentSlot}/${parentSlotIndex}`);
|
1160
|
-
}
|
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;
|
1161
1369
|
}
|
1162
|
-
return
|
1370
|
+
return [];
|
1163
1371
|
}
|
1164
1372
|
|
1165
1373
|
// src/enhancement/enhance.ts
|
@@ -1179,19 +1387,21 @@ async function enhance({
|
|
1179
1387
|
const promises = [];
|
1180
1388
|
const usedComponentEnhancers = /* @__PURE__ */ new Set();
|
1181
1389
|
const usedParameterEnhancers = /* @__PURE__ */ new Set();
|
1182
|
-
|
1390
|
+
walkNodeTree(composition, ({ type, node, ancestorsAndSelf, actions }) => {
|
1183
1391
|
var _a;
|
1184
|
-
|
1185
|
-
|
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);
|
1186
1398
|
if (enhancer) {
|
1187
1399
|
usedParameterEnhancers.add(enhancer);
|
1188
|
-
promises.push(
|
1189
|
-
enhanceParameter(currentComponent, componentContext, paramName, paramValue, enhancer, context)
|
1190
|
-
);
|
1400
|
+
promises.push(enhanceParameter(node, ancestorsAndSelf, paramName, paramValue, enhancer, context));
|
1191
1401
|
}
|
1192
1402
|
});
|
1193
|
-
const componentEnhancers = enhancers.resolveComponentEnhancers(
|
1194
|
-
promises.push(enhanceComponent(
|
1403
|
+
const componentEnhancers = enhancers.resolveComponentEnhancers(node);
|
1404
|
+
promises.push(enhanceComponent(node, ancestorsAndSelf, componentEnhancers, context));
|
1195
1405
|
usedComponentEnhancers.add(componentEnhancers);
|
1196
1406
|
});
|
1197
1407
|
promises.push(
|
@@ -1409,41 +1619,30 @@ var EnhancerBuilder = class {
|
|
1409
1619
|
}
|
1410
1620
|
};
|
1411
1621
|
|
1412
|
-
// src/
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
_id: "_empty_composition_id",
|
1437
|
-
_name: "An empty composition used for contextual editing",
|
1438
|
-
type: "_empty_composition_type"
|
1439
|
-
};
|
1440
|
-
var EDGE_MIN_CACHE_TTL = 15;
|
1441
|
-
var EDGE_MAX_CACHE_TTL = 600;
|
1442
|
-
var EDGE_DEFAULT_CACHE_TTL = 30;
|
1443
|
-
var EDGE_CACHE_DISABLED = -1;
|
1444
|
-
var EDGE_MIN_L2_CACHE_TTL_IN_HOURS = 1;
|
1445
|
-
var EDGE_MAX_L2_CACHE_TTL_IN_HOURS = 4 * 7 * 24;
|
1446
|
-
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
|
+
}
|
1447
1646
|
|
1448
1647
|
// src/enhancement/localize.ts
|
1449
1648
|
function extractLocales({ component }) {
|
@@ -1464,22 +1663,26 @@ function localize({
|
|
1464
1663
|
composition,
|
1465
1664
|
locale
|
1466
1665
|
}) {
|
1467
|
-
|
1468
|
-
if (
|
1469
|
-
|
1470
|
-
|
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 });
|
1471
1674
|
let replaceComponent;
|
1472
1675
|
if (resolvedLocale) {
|
1473
1676
|
replaceComponent = locales[resolvedLocale];
|
1474
1677
|
}
|
1475
1678
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
1476
1679
|
const [first, ...rest] = replaceComponent;
|
1477
|
-
actions.
|
1680
|
+
actions.replace(first);
|
1478
1681
|
if (rest.length) {
|
1479
1682
|
actions.insertAfter(rest);
|
1480
1683
|
}
|
1481
1684
|
} else {
|
1482
|
-
actions.
|
1685
|
+
actions.remove();
|
1483
1686
|
}
|
1484
1687
|
}
|
1485
1688
|
});
|
@@ -1512,6 +1715,124 @@ var UniqueBatchEntries = class {
|
|
1512
1715
|
}
|
1513
1716
|
};
|
1514
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
|
+
|
1515
1836
|
// src/utils/hash.ts
|
1516
1837
|
var generateHash = ({
|
1517
1838
|
composition,
|
@@ -1537,6 +1858,9 @@ var isSelectComponentMessage = (message) => {
|
|
1537
1858
|
var isReadyMessage = (message) => {
|
1538
1859
|
return message.type === "ready";
|
1539
1860
|
};
|
1861
|
+
var isComponentActionMessage = (message) => {
|
1862
|
+
return message.type === "trigger-component-action";
|
1863
|
+
};
|
1540
1864
|
var isUpdateCompositionMessage = (message) => {
|
1541
1865
|
return message.type === "update-composition";
|
1542
1866
|
};
|
@@ -1561,6 +1885,9 @@ var isTriggerCompositionActionMessage = (message) => {
|
|
1561
1885
|
var isUpdatePreviewSettingsMessage = (message) => {
|
1562
1886
|
return message.type === "update-preview-settings";
|
1563
1887
|
};
|
1888
|
+
var isUpdateFeatureFlagsMessage = (message) => {
|
1889
|
+
return message.type === "update-feature-flags";
|
1890
|
+
};
|
1564
1891
|
var isUpdateContextualEditingStateInternalMessage = (message) => {
|
1565
1892
|
return message.type === "update-contextual-editing-state-internal";
|
1566
1893
|
};
|
@@ -1570,6 +1897,12 @@ var isReportRenderedCompositionsMessage = (message) => {
|
|
1570
1897
|
var isSelectParameterMessage = (message) => {
|
1571
1898
|
return message.type === "select-parameter";
|
1572
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
|
+
};
|
1573
1906
|
var createCanvasChannel = ({
|
1574
1907
|
listenTo,
|
1575
1908
|
broadcastTo
|
@@ -1630,6 +1963,13 @@ var createCanvasChannel = ({
|
|
1630
1963
|
};
|
1631
1964
|
postMessage(message);
|
1632
1965
|
};
|
1966
|
+
const triggerComponentAction = (options) => {
|
1967
|
+
const message = {
|
1968
|
+
...options,
|
1969
|
+
type: "trigger-component-action"
|
1970
|
+
};
|
1971
|
+
postMessage(message);
|
1972
|
+
};
|
1633
1973
|
const addComponent = (options) => {
|
1634
1974
|
const message = {
|
1635
1975
|
...options,
|
@@ -1693,12 +2033,33 @@ var createCanvasChannel = ({
|
|
1693
2033
|
};
|
1694
2034
|
postMessage(message);
|
1695
2035
|
};
|
2036
|
+
const openParameterEditor = (options) => {
|
2037
|
+
const message = {
|
2038
|
+
...options,
|
2039
|
+
type: "open-parameter-editor"
|
2040
|
+
};
|
2041
|
+
postMessage(message);
|
2042
|
+
};
|
1696
2043
|
const editorStateUpdated = () => {
|
1697
2044
|
const message = {
|
1698
2045
|
type: "editor-state-updated"
|
1699
2046
|
};
|
1700
2047
|
postMessage(message);
|
1701
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
|
+
};
|
1702
2063
|
const messageEventListener = (event) => {
|
1703
2064
|
if (typeof event.data !== "string") {
|
1704
2065
|
return;
|
@@ -1728,6 +2089,7 @@ var createCanvasChannel = ({
|
|
1728
2089
|
return {
|
1729
2090
|
ready,
|
1730
2091
|
destroy,
|
2092
|
+
triggerComponentAction,
|
1731
2093
|
selectComponent,
|
1732
2094
|
updateComposition,
|
1733
2095
|
updateCompositionInternal,
|
@@ -1738,10 +2100,13 @@ var createCanvasChannel = ({
|
|
1738
2100
|
dismissPlaceholder,
|
1739
2101
|
triggerCompositionAction,
|
1740
2102
|
updatePreviewSettings,
|
2103
|
+
updateFeatureFlags,
|
1741
2104
|
updateContextualEditingStateInternal,
|
1742
2105
|
selectParameter,
|
2106
|
+
openParameterEditor,
|
1743
2107
|
reportRenderedCompositions,
|
1744
|
-
editorStateUpdated
|
2108
|
+
editorStateUpdated,
|
2109
|
+
updateComponentReferences
|
1745
2110
|
};
|
1746
2111
|
};
|
1747
2112
|
|
@@ -1823,10 +2188,50 @@ function subscribeToComposition({
|
|
1823
2188
|
};
|
1824
2189
|
}
|
1825
2190
|
|
1826
|
-
// src/
|
2191
|
+
// src/PromptClient.ts
|
1827
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");
|
1828
2233
|
var ROUTE_URL = "/api/v1/route";
|
1829
|
-
var RouteClient = class extends
|
2234
|
+
var RouteClient = class extends import_api9.ApiClient {
|
1830
2235
|
constructor(options) {
|
1831
2236
|
var _a;
|
1832
2237
|
if (!options.limitPolicy) {
|
@@ -1865,20 +2270,6 @@ var createUniformApiEnhancer = ({ apiUrl }) => {
|
|
1865
2270
|
};
|
1866
2271
|
};
|
1867
2272
|
|
1868
|
-
// src/utils/entryConverter.ts
|
1869
|
-
function convertEntryToPutEntry(entry) {
|
1870
|
-
return {
|
1871
|
-
entry: {
|
1872
|
-
type: entry.entry.type,
|
1873
|
-
_dataResources: entry.entry._dataResources,
|
1874
|
-
_id: entry.entry._id,
|
1875
|
-
fields: entry.entry.fields
|
1876
|
-
},
|
1877
|
-
state: entry.state,
|
1878
|
-
projectId: entry.projectId
|
1879
|
-
};
|
1880
|
-
}
|
1881
|
-
|
1882
2273
|
// src/utils/getParameterAttributes.ts
|
1883
2274
|
var ATTRIBUTE_COMPONENT_ID = "data-uniform-component-id";
|
1884
2275
|
var ATTRIBUTE_PARAMETER_ID = "data-uniform-parameter-id";
|
@@ -1909,6 +2300,11 @@ var getParameterAttributes = ({
|
|
1909
2300
|
};
|
1910
2301
|
};
|
1911
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
|
+
|
1912
2308
|
// src/utils/isSystemComponentDefinition.ts
|
1913
2309
|
var isSystemComponentDefinition = (componentType) => {
|
1914
2310
|
return componentType.startsWith("$");
|
@@ -1946,6 +2342,20 @@ function mapSlotToTestVariations(slot) {
|
|
1946
2342
|
});
|
1947
2343
|
}
|
1948
2344
|
|
2345
|
+
// src/utils/placeholder.ts
|
2346
|
+
var isComponentPlaceholderId = (id) => {
|
2347
|
+
if (id === PLACEHOLDER_ID) {
|
2348
|
+
return true;
|
2349
|
+
}
|
2350
|
+
return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
|
2351
|
+
};
|
2352
|
+
var generateComponentPlaceholderId = (randomId, sdkVersion) => {
|
2353
|
+
if (typeof sdkVersion === "undefined" || sdkVersion === 1) {
|
2354
|
+
return PLACEHOLDER_ID;
|
2355
|
+
}
|
2356
|
+
return `${PLACEHOLDER_ID}_${randomId}`;
|
2357
|
+
};
|
2358
|
+
|
1949
2359
|
// src/utils/variables/parseVariableExpression.ts
|
1950
2360
|
var escapeCharacter = "\\";
|
1951
2361
|
var variablePrefix = "${";
|
@@ -2081,7 +2491,15 @@ function bindVariablesToObjectRecursive({
|
|
2081
2491
|
boundCount += bindResult.boundCount;
|
2082
2492
|
draft[property] = bindResult.result;
|
2083
2493
|
if (bindResult.errors) {
|
2084
|
-
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
|
+
);
|
2085
2503
|
}
|
2086
2504
|
}
|
2087
2505
|
return;
|
@@ -2121,8 +2539,8 @@ function handleRichTextNodeBinding(object, options) {
|
|
2121
2539
|
}
|
2122
2540
|
|
2123
2541
|
// src/index.ts
|
2124
|
-
var
|
2125
|
-
var CanvasClientError =
|
2542
|
+
var import_api10 = require("@uniformdev/context/api");
|
2543
|
+
var CanvasClientError = import_api10.ApiClientError;
|
2126
2544
|
// Annotate the CommonJS export names for ESM import in node:
|
2127
2545
|
0 && (module.exports = {
|
2128
2546
|
ATTRIBUTE_COMPONENT_ID,
|
@@ -2133,6 +2551,7 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2133
2551
|
ATTRIBUTE_PLACEHOLDER,
|
2134
2552
|
ApiClientError,
|
2135
2553
|
BatchEntry,
|
2554
|
+
CANVAS_BLOCK_PARAM_TYPE,
|
2136
2555
|
CANVAS_DRAFT_STATE,
|
2137
2556
|
CANVAS_EDITOR_STATE,
|
2138
2557
|
CANVAS_ENRICHMENT_TAG_PARAM,
|
@@ -2156,11 +2575,8 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2156
2575
|
DataTypeClient,
|
2157
2576
|
EDGE_CACHE_DISABLED,
|
2158
2577
|
EDGE_DEFAULT_CACHE_TTL,
|
2159
|
-
EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS,
|
2160
2578
|
EDGE_MAX_CACHE_TTL,
|
2161
|
-
EDGE_MAX_L2_CACHE_TTL_IN_HOURS,
|
2162
2579
|
EDGE_MIN_CACHE_TTL,
|
2163
|
-
EDGE_MIN_L2_CACHE_TTL_IN_HOURS,
|
2164
2580
|
EMPTY_COMPOSITION,
|
2165
2581
|
EnhancerBuilder,
|
2166
2582
|
IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
|
@@ -2171,7 +2587,9 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2171
2587
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
2172
2588
|
IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
2173
2589
|
PLACEHOLDER_ID,
|
2590
|
+
PromptClient,
|
2174
2591
|
RouteClient,
|
2592
|
+
SECRET_QUERY_STRING_PARAM,
|
2175
2593
|
UncachedCanvasClient,
|
2176
2594
|
UncachedCategoryClient,
|
2177
2595
|
UncachedContentClient,
|
@@ -2188,14 +2606,21 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2188
2606
|
createVariableReference,
|
2189
2607
|
enhance,
|
2190
2608
|
extractLocales,
|
2609
|
+
generateComponentPlaceholderId,
|
2191
2610
|
generateHash,
|
2611
|
+
getBlockValue,
|
2192
2612
|
getChannelName,
|
2193
2613
|
getComponentJsonPointer,
|
2194
2614
|
getComponentPath,
|
2195
2615
|
getParameterAttributes,
|
2616
|
+
getPropertiesValue,
|
2196
2617
|
isAddComponentMessage,
|
2618
|
+
isAllowedReferrer,
|
2619
|
+
isComponentActionMessage,
|
2620
|
+
isComponentPlaceholderId,
|
2197
2621
|
isDismissPlaceholderMessage,
|
2198
2622
|
isMovingComponentMessage,
|
2623
|
+
isOpenParameterEditorMessage,
|
2199
2624
|
isReadyMessage,
|
2200
2625
|
isReportRenderedCompositionsMessage,
|
2201
2626
|
isSelectComponentMessage,
|
@@ -2203,9 +2628,11 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2203
2628
|
isSystemComponentDefinition,
|
2204
2629
|
isTriggerCompositionActionMessage,
|
2205
2630
|
isUpdateComponentParameterMessage,
|
2631
|
+
isUpdateComponentReferencesMessage,
|
2206
2632
|
isUpdateCompositionInternalMessage,
|
2207
2633
|
isUpdateCompositionMessage,
|
2208
2634
|
isUpdateContextualEditingStateInternalMessage,
|
2635
|
+
isUpdateFeatureFlagsMessage,
|
2209
2636
|
isUpdatePreviewSettingsMessage,
|
2210
2637
|
localize,
|
2211
2638
|
mapSlotToPersonalizedVariations,
|
@@ -2214,5 +2641,6 @@ var CanvasClientError = import_api9.ApiClientError;
|
|
2214
2641
|
parseVariableExpression,
|
2215
2642
|
subscribeToComposition,
|
2216
2643
|
unstable_CompositionRelationshipClient,
|
2217
|
-
walkComponentTree
|
2644
|
+
walkComponentTree,
|
2645
|
+
walkNodeTree
|
2218
2646
|
});
|