@uniformdev/canvas-vue 17.7.0 → 17.7.1-alpha.167
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.ts +6 -6
- package/dist/index.esm.js +425 -1
- package/dist/index.js +435 -1
- package/dist/index.mjs +425 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1 +1,435 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
CANVAS_COMPOSITION_TYPE: () => CANVAS_COMPOSITION_TYPE,
|
|
24
|
+
CANVAS_SLOT_CONTENT_TYPE: () => CANVAS_SLOT_CONTENT_TYPE,
|
|
25
|
+
Composition: () => Composition,
|
|
26
|
+
DefaultNotImplementedComponent: () => DefaultNotImplementedComponent,
|
|
27
|
+
SlotContent: () => SlotContent,
|
|
28
|
+
compositionInjectionKey: () => compositionInjectionKey,
|
|
29
|
+
convertComponentToProps: () => convertComponentToProps,
|
|
30
|
+
createApiEnhancer: () => createApiEnhancer,
|
|
31
|
+
resolveRendererInjectionKey: () => resolveRendererInjectionKey,
|
|
32
|
+
useCompositionEventEffect: () => useCompositionEventEffect,
|
|
33
|
+
useContextualEditing: () => useContextualEditing
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
|
|
37
|
+
// src/components/Composition.ts
|
|
38
|
+
var import_canvas = require("@uniformdev/canvas");
|
|
39
|
+
var import_context_vue = require("@uniformdev/context-vue");
|
|
40
|
+
var import_vue_demi = require("vue-demi");
|
|
41
|
+
|
|
42
|
+
// src/utils/constants.ts
|
|
43
|
+
var CANVAS_COMPOSITION_TYPE = "Composition";
|
|
44
|
+
var CANVAS_SLOT_CONTENT_TYPE = "SlotContent";
|
|
45
|
+
var compositionInjectionKey = "uniformComposition";
|
|
46
|
+
var resolveRendererInjectionKey = "uniformResolveRenderer";
|
|
47
|
+
|
|
48
|
+
// src/components/Composition.ts
|
|
49
|
+
var Composition = (0, import_vue_demi.defineComponent)({
|
|
50
|
+
name: CANVAS_COMPOSITION_TYPE,
|
|
51
|
+
inheritAttrs: false,
|
|
52
|
+
props: {
|
|
53
|
+
data: {
|
|
54
|
+
type: Object,
|
|
55
|
+
required: true
|
|
56
|
+
},
|
|
57
|
+
resolveRenderer: {
|
|
58
|
+
type: Function,
|
|
59
|
+
default: () => ({ type }) => (0, import_vue_demi.resolveComponent)(type)
|
|
60
|
+
},
|
|
61
|
+
behaviorTracking: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: "onView"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
setup(props, context) {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
const data = (0, import_vue_demi.computed)(() => {
|
|
69
|
+
var _a2, _b2;
|
|
70
|
+
return (_b2 = props.data) != null ? _b2 : (_a2 = (0, import_vue_demi.inject)(compositionInjectionKey)) == null ? void 0 : _a2.value;
|
|
71
|
+
});
|
|
72
|
+
const resolveRenderer = (_a = props.resolveRenderer) != null ? _a : (0, import_vue_demi.inject)(resolveRendererInjectionKey);
|
|
73
|
+
(0, import_vue_demi.provide)(compositionInjectionKey, data);
|
|
74
|
+
(0, import_vue_demi.provide)(resolveRendererInjectionKey, resolveRenderer);
|
|
75
|
+
const slots = (0, import_vue_demi.computed)(() => {
|
|
76
|
+
var _a2, _b2;
|
|
77
|
+
return (_b2 = (_a2 = data.value) == null ? void 0 : _a2.slots) != null ? _b2 : {};
|
|
78
|
+
});
|
|
79
|
+
const parameters = (0, import_vue_demi.computed)(() => {
|
|
80
|
+
var _a2, _b2;
|
|
81
|
+
return (_b2 = (_a2 = data.value) == null ? void 0 : _a2.parameters) != null ? _b2 : {};
|
|
82
|
+
});
|
|
83
|
+
const componentKey = (0, import_vue_demi.computed)(() => {
|
|
84
|
+
return JSON.stringify(data.value);
|
|
85
|
+
});
|
|
86
|
+
const enrichmentTags = (_c = (_b = data.value.parameters) == null ? void 0 : _b[import_canvas.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _c.value;
|
|
87
|
+
const renderChildren = () => {
|
|
88
|
+
var _a2, _b2;
|
|
89
|
+
return (_b2 = (_a2 = context.slots).default) == null ? void 0 : _b2.call(_a2, {
|
|
90
|
+
slots: slots.value,
|
|
91
|
+
parameters: parameters.value
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
if ((0, import_context_vue.isUsingUniformContext)()) {
|
|
95
|
+
const TrackComponent = props.behaviorTracking === "onLoad" ? import_context_vue.TrackSlot : import_context_vue.Track;
|
|
96
|
+
return () => (0, import_vue_demi.h)(
|
|
97
|
+
TrackComponent,
|
|
98
|
+
{ behavior: enrichmentTags, key: componentKey.value },
|
|
99
|
+
renderChildren
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return renderChildren;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// src/components/DefaultNotImplementedComponent.ts
|
|
107
|
+
var import_vue_demi2 = require("vue-demi");
|
|
108
|
+
var inlineStyles = {
|
|
109
|
+
borderLeft: "10px solid #e42535",
|
|
110
|
+
background: "rgba(122, 215, 218, 0.3)",
|
|
111
|
+
color: "#1d3557",
|
|
112
|
+
padding: "1rem",
|
|
113
|
+
textAlign: "left",
|
|
114
|
+
margin: "1rem 5vw"
|
|
115
|
+
};
|
|
116
|
+
var headingStyle = {
|
|
117
|
+
margin: "0 0 1rem"
|
|
118
|
+
};
|
|
119
|
+
var DefaultNotImplementedComponent = (0, import_vue_demi2.defineComponent)({
|
|
120
|
+
name: "DefaultNotImplementedComponent",
|
|
121
|
+
props: {
|
|
122
|
+
component: {
|
|
123
|
+
type: Object,
|
|
124
|
+
required: true
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
setup(props, { attrs }) {
|
|
128
|
+
var _a;
|
|
129
|
+
const componentType = (_a = props.component) == null ? void 0 : _a.type;
|
|
130
|
+
return () => (0, import_vue_demi2.h)("div", { key: "content", style: { ...inlineStyles } }, [
|
|
131
|
+
(0, import_vue_demi2.h)("h2", { style: { ...headingStyle } }, `Component: ${componentType}`),
|
|
132
|
+
(0, import_vue_demi2.h)("p", [
|
|
133
|
+
(0, import_vue_demi2.h)("strong", `${componentType} has no Vue implementation. It may need to be added to your `),
|
|
134
|
+
(0, import_vue_demi2.h)("code", {}, "resolveRenderer()"),
|
|
135
|
+
(0, import_vue_demi2.h)("strong", {}, " function.")
|
|
136
|
+
]),
|
|
137
|
+
(0, import_vue_demi2.h)("details", {}, [
|
|
138
|
+
(0, import_vue_demi2.h)("summary", {}, "props/attributes"),
|
|
139
|
+
(0, import_vue_demi2.h)(
|
|
140
|
+
"pre",
|
|
141
|
+
{
|
|
142
|
+
style: {
|
|
143
|
+
overflowX: "auto"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
`${JSON.stringify(attrs)}`
|
|
147
|
+
)
|
|
148
|
+
])
|
|
149
|
+
]);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// src/components/SlotContent.ts
|
|
154
|
+
var import_canvas2 = require("@uniformdev/canvas");
|
|
155
|
+
var import_context_vue2 = require("@uniformdev/context-vue");
|
|
156
|
+
var import_vue_demi3 = require("vue-demi");
|
|
157
|
+
|
|
158
|
+
// src/utils/convertComponentToProps.ts
|
|
159
|
+
function convertComponentToProps(component) {
|
|
160
|
+
var _a;
|
|
161
|
+
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
162
|
+
const flatParams = Object.entries(parameters).reduce(
|
|
163
|
+
(props, [key, { value }]) => ({
|
|
164
|
+
...props,
|
|
165
|
+
[normalizePropName(key)]: value
|
|
166
|
+
}),
|
|
167
|
+
{}
|
|
168
|
+
);
|
|
169
|
+
const renderComponentProps = {
|
|
170
|
+
...flatParams,
|
|
171
|
+
...component.data,
|
|
172
|
+
component
|
|
173
|
+
};
|
|
174
|
+
return renderComponentProps;
|
|
175
|
+
}
|
|
176
|
+
function normalizePropName(name) {
|
|
177
|
+
return name.replace("$", "");
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/components/SlotContent.ts
|
|
181
|
+
var SlotContent = (0, import_vue_demi3.defineComponent)({
|
|
182
|
+
name: CANVAS_SLOT_CONTENT_TYPE,
|
|
183
|
+
inheritAttrs: false,
|
|
184
|
+
props: {
|
|
185
|
+
name: {
|
|
186
|
+
type: String
|
|
187
|
+
},
|
|
188
|
+
resolveRenderer: {
|
|
189
|
+
type: Function
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
setup(props, context) {
|
|
193
|
+
var _a;
|
|
194
|
+
const componentData = (0, import_vue_demi3.inject)(compositionInjectionKey);
|
|
195
|
+
const resolveRenderer = (_a = props.resolveRenderer) != null ? _a : (0, import_vue_demi3.inject)(resolveRendererInjectionKey);
|
|
196
|
+
const emptyPlaceholder = context.slots.emptyPlaceholder;
|
|
197
|
+
if (!componentData || !resolveRenderer) {
|
|
198
|
+
throw new Error("<SlotContent /> can only be used inside a <Composition />");
|
|
199
|
+
}
|
|
200
|
+
const slotItems = (0, import_vue_demi3.computed)(() => {
|
|
201
|
+
var _a2, _b, _c;
|
|
202
|
+
if (props.name) {
|
|
203
|
+
return (_b = (_a2 = componentData == null ? void 0 : componentData.value.slots) == null ? void 0 : _a2[props.name]) != null ? _b : [];
|
|
204
|
+
}
|
|
205
|
+
return Object.values((_c = componentData == null ? void 0 : componentData.value.slots) != null ? _c : {}).flat();
|
|
206
|
+
});
|
|
207
|
+
const childrenToRender = slotItems.value.map((component, index) => {
|
|
208
|
+
const child = renderComponent({
|
|
209
|
+
component,
|
|
210
|
+
resolveRenderer,
|
|
211
|
+
indexInSlot: index,
|
|
212
|
+
slotName: props.name,
|
|
213
|
+
parentComponent: componentData.value,
|
|
214
|
+
slotChildrenCount: slotItems.value.length,
|
|
215
|
+
emptyPlaceholder
|
|
216
|
+
});
|
|
217
|
+
return context.slots.default ? context.slots.default({ child, component }) : child;
|
|
218
|
+
});
|
|
219
|
+
return () => childrenToRender;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
function renderPersonalizeComponent(component, resolveRenderer) {
|
|
223
|
+
var _a, _b, _c, _d, _e, _f;
|
|
224
|
+
const parameters = component == null ? void 0 : component.parameters;
|
|
225
|
+
const processedVariants = (0, import_canvas2.mapSlotToPersonalizedVariations)((_a = component.slots) == null ? void 0 : _a.pz);
|
|
226
|
+
const name = (_d = (_c = (_b = component.parameters) == null ? void 0 : _b.trackingEventName) == null ? void 0 : _c.value) != null ? _d : "Untitled Personalization";
|
|
227
|
+
return (0, import_vue_demi3.h)(import_context_vue2.Personalize, {
|
|
228
|
+
name,
|
|
229
|
+
component: (variant) => resolveRenderer(variant),
|
|
230
|
+
variations: processedVariants,
|
|
231
|
+
count: Number((_f = (_e = parameters == null ? void 0 : parameters.count) == null ? void 0 : _e.value) != null ? _f : 1)
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
function renderTestComponent(component, resolveRenderer) {
|
|
235
|
+
var _a, _b, _c, _d, _e;
|
|
236
|
+
const variants = (_b = (_a = component == null ? void 0 : component.slots) == null ? void 0 : _a.test) != null ? _b : [];
|
|
237
|
+
const testName = (_e = (_d = (_c = component == null ? void 0 : component.parameters) == null ? void 0 : _c.test) == null ? void 0 : _d.value) != null ? _e : "Untitled Test";
|
|
238
|
+
const finalVariants = (0, import_canvas2.mapSlotToTestVariations)(variants);
|
|
239
|
+
return (0, import_vue_demi3.h)(import_context_vue2.Test, {
|
|
240
|
+
variations: finalVariants,
|
|
241
|
+
name: testName,
|
|
242
|
+
component: (variant) => resolveRenderer(variant)
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function renderComponent({
|
|
246
|
+
component,
|
|
247
|
+
resolveRenderer,
|
|
248
|
+
indexInSlot,
|
|
249
|
+
slotName,
|
|
250
|
+
parentComponent,
|
|
251
|
+
slotChildrenCount,
|
|
252
|
+
emptyPlaceholder
|
|
253
|
+
}) {
|
|
254
|
+
var _a, _b;
|
|
255
|
+
if (component.type === import_canvas2.CANVAS_TEST_TYPE) {
|
|
256
|
+
return renderTestComponent(
|
|
257
|
+
component,
|
|
258
|
+
(component2) => renderComponent({ component: component2, resolveRenderer })
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
if (component.type === import_canvas2.CANVAS_PERSONALIZE_TYPE) {
|
|
262
|
+
return renderPersonalizeComponent(
|
|
263
|
+
component,
|
|
264
|
+
(component2) => renderComponent({ component: component2, resolveRenderer })
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
const resolvedComponent = resolveRenderer == null ? void 0 : resolveRenderer(component);
|
|
268
|
+
if (resolvedComponent) {
|
|
269
|
+
const props = convertComponentToProps(component);
|
|
270
|
+
const shouldRenderContextualEditingTags = Boolean(component._id);
|
|
271
|
+
const isPlaceholder = component._id === import_canvas2.PLACEHOLDER_ID;
|
|
272
|
+
const elementsToRender = shouldRenderContextualEditingTags ? [
|
|
273
|
+
(0, import_vue_demi3.h)("script", {
|
|
274
|
+
"data-role": import_canvas2.IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
|
275
|
+
"data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
|
|
276
|
+
"data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
|
|
277
|
+
"data-component-id": component._id,
|
|
278
|
+
"data-slot-name": slotName,
|
|
279
|
+
"data-component-index": indexInSlot,
|
|
280
|
+
"data-total-components": slotChildrenCount,
|
|
281
|
+
"data-component-name": component.type,
|
|
282
|
+
"data-is-placeholder": isPlaceholder ? "true" : void 0,
|
|
283
|
+
"data-component-title": (_b = (_a = component.parameters) == null ? void 0 : _a.title) == null ? void 0 : _b.value
|
|
284
|
+
}),
|
|
285
|
+
isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder() : (0, import_vue_demi3.h)(resolvedComponent, props),
|
|
286
|
+
(0, import_vue_demi3.h)("script", { "data-role": "component-end" })
|
|
287
|
+
] : [(0, import_vue_demi3.h)(resolvedComponent, props)];
|
|
288
|
+
return (0, import_vue_demi3.h)(Composition, { data: component, resolveRenderer }, () => elementsToRender);
|
|
289
|
+
}
|
|
290
|
+
console.warn(
|
|
291
|
+
`[canvas] found component of type '${component.type}' which the 'resolveRenderer' prop returned no component for. Nothing will be rendered. The resolveRenderer function may need to be extended to handle the new type.`,
|
|
292
|
+
component
|
|
293
|
+
);
|
|
294
|
+
return (0, import_vue_demi3.h)("");
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// src/composables/useCompositionEventEffect.ts
|
|
298
|
+
var import_canvas3 = require("@uniformdev/canvas");
|
|
299
|
+
var import_vue_demi4 = require("vue-demi");
|
|
300
|
+
async function useCompositionEventEffect({
|
|
301
|
+
enabled,
|
|
302
|
+
projectId,
|
|
303
|
+
compositionIdRef,
|
|
304
|
+
effect
|
|
305
|
+
}) {
|
|
306
|
+
let unsubscribe;
|
|
307
|
+
(0, import_vue_demi4.watch)(
|
|
308
|
+
[() => enabled, () => compositionIdRef.value, () => projectId],
|
|
309
|
+
async () => {
|
|
310
|
+
unsubscribe == null ? void 0 : unsubscribe();
|
|
311
|
+
if (!enabled || !compositionIdRef.value || !projectId) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const eventBus = await (0, import_canvas3.createEventBus)();
|
|
315
|
+
if (eventBus) {
|
|
316
|
+
unsubscribe = (0, import_canvas3.subscribeToComposition)({
|
|
317
|
+
eventBus,
|
|
318
|
+
compositionId: compositionIdRef.value,
|
|
319
|
+
compositionState: import_canvas3.CANVAS_DRAFT_STATE,
|
|
320
|
+
projectId,
|
|
321
|
+
callback: effect,
|
|
322
|
+
event: "updated"
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
{ immediate: true }
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// src/composables/useContextualEditing.ts
|
|
331
|
+
var import_canvas4 = require("@uniformdev/canvas");
|
|
332
|
+
var import_vue_demi5 = require("vue-demi");
|
|
333
|
+
var previewScriptId = "uniform-canvas-preview-script";
|
|
334
|
+
var createApiEnhancer = ({ apiUrl }) => {
|
|
335
|
+
return async (message) => {
|
|
336
|
+
const response = await fetch(apiUrl, {
|
|
337
|
+
method: "post",
|
|
338
|
+
body: JSON.stringify({
|
|
339
|
+
composition: message.composition,
|
|
340
|
+
hash: message.hash
|
|
341
|
+
}),
|
|
342
|
+
headers: {
|
|
343
|
+
"Content-Type": "application/json"
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
const json = await response.json();
|
|
347
|
+
if (!response.ok) {
|
|
348
|
+
throw new Error("Error reading enhanced composition");
|
|
349
|
+
}
|
|
350
|
+
const body = json;
|
|
351
|
+
return body.composition;
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
var useContextualEditing = ({
|
|
355
|
+
initialCompositionValue,
|
|
356
|
+
enhance = (message) => message.composition
|
|
357
|
+
}) => {
|
|
358
|
+
const contextualComposition = (0, import_vue_demi5.ref)();
|
|
359
|
+
const channel = (0, import_vue_demi5.computed)(() => {
|
|
360
|
+
var _a;
|
|
361
|
+
if (!isInContextEditingMode()) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const channel2 = (0, import_canvas4.createCanvasChannel)({
|
|
365
|
+
broadcastTo: [(_a = window.opener) != null ? _a : window.top],
|
|
366
|
+
listenTo: [window]
|
|
367
|
+
});
|
|
368
|
+
return channel2;
|
|
369
|
+
});
|
|
370
|
+
(0, import_vue_demi5.watch)(
|
|
371
|
+
[channel, () => enhance],
|
|
372
|
+
() => {
|
|
373
|
+
if (!channel.value) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
const unsubscribe = channel.value.on("update-composition", async (message) => {
|
|
377
|
+
if ((0, import_canvas4.isUpdateCompositionMessage)(message)) {
|
|
378
|
+
const composition = await enhance(message);
|
|
379
|
+
contextualComposition.value = composition;
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
return () => {
|
|
383
|
+
unsubscribe();
|
|
384
|
+
};
|
|
385
|
+
},
|
|
386
|
+
{ immediate: true }
|
|
387
|
+
);
|
|
388
|
+
(0, import_vue_demi5.onMounted)(() => {
|
|
389
|
+
if (!isInContextEditingMode()) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const existingScript = document.getElementById(previewScriptId);
|
|
393
|
+
if (existingScript) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const script = document.createElement("script");
|
|
397
|
+
script.id = previewScriptId;
|
|
398
|
+
script.src = getCanvasInContextEmbedScriptUrl();
|
|
399
|
+
script.async = true;
|
|
400
|
+
document.head.appendChild(script);
|
|
401
|
+
});
|
|
402
|
+
return {
|
|
403
|
+
composition: contextualComposition != null ? contextualComposition : initialCompositionValue
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
function getCanvasInContextEmbedScriptUrl() {
|
|
407
|
+
const scriptUrl = `${window.document.referrer}files/canvas-in-context-embed/index.js`;
|
|
408
|
+
return scriptUrl;
|
|
409
|
+
}
|
|
410
|
+
function isInContextEditingMode() {
|
|
411
|
+
if (typeof window === "undefined") {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
const isOpenedByInContextEditor = new URLSearchParams(window.location.search).has(
|
|
415
|
+
import_canvas4.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
|
|
416
|
+
);
|
|
417
|
+
const isAllowlistedReferrer = Boolean(
|
|
418
|
+
window.document.referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//)
|
|
419
|
+
);
|
|
420
|
+
return isOpenedByInContextEditor && isAllowlistedReferrer;
|
|
421
|
+
}
|
|
422
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
423
|
+
0 && (module.exports = {
|
|
424
|
+
CANVAS_COMPOSITION_TYPE,
|
|
425
|
+
CANVAS_SLOT_CONTENT_TYPE,
|
|
426
|
+
Composition,
|
|
427
|
+
DefaultNotImplementedComponent,
|
|
428
|
+
SlotContent,
|
|
429
|
+
compositionInjectionKey,
|
|
430
|
+
convertComponentToProps,
|
|
431
|
+
createApiEnhancer,
|
|
432
|
+
resolveRendererInjectionKey,
|
|
433
|
+
useCompositionEventEffect,
|
|
434
|
+
useContextualEditing
|
|
435
|
+
});
|