@amplifyup/sdk 0.1.31 → 0.1.33
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/AmplifyRenderer.js +62 -4
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +62 -4
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +63 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{preview-BMrIgUvp.d.mts → preview-_vHmzRen.d.mts} +6 -1
- package/dist/{preview-BMrIgUvp.d.ts → preview-_vHmzRen.d.ts} +6 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +65 -4
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +65 -5
- package/dist/react.mjs.map +1 -1
- package/dist/server.js +13 -4
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +13 -4
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -325,12 +325,17 @@ function resolveAmplifyUpUrls(target) {
|
|
|
325
325
|
|
|
326
326
|
// src/preview.ts
|
|
327
327
|
function isPreviewRequest(searchParams) {
|
|
328
|
+
return paramIsTrue(searchParams, "preview") || paramIsTrue(searchParams, "visualEditor");
|
|
329
|
+
}
|
|
330
|
+
function isWorkingContentRequest(searchParams) {
|
|
331
|
+
return paramIsTrue(searchParams, "working");
|
|
332
|
+
}
|
|
333
|
+
function paramIsTrue(searchParams, key) {
|
|
328
334
|
if (searchParams instanceof URLSearchParams) {
|
|
329
|
-
return searchParams.get(
|
|
335
|
+
return searchParams.get(key) === "true";
|
|
330
336
|
}
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
return preview === "true" || visualEditor === "true";
|
|
337
|
+
const value = searchParams[key];
|
|
338
|
+
return value === "true" || Array.isArray(value) && value[0] === "true";
|
|
334
339
|
}
|
|
335
340
|
function isComposerPreview() {
|
|
336
341
|
if (typeof window === "undefined") return false;
|
|
@@ -393,6 +398,8 @@ var AmplifyUpSDK = class {
|
|
|
393
398
|
this.showZonesEnabled = false;
|
|
394
399
|
this.componentRegistry = [];
|
|
395
400
|
this.messageListener = null;
|
|
401
|
+
this.composerBoundsRaf = 0;
|
|
402
|
+
this.composerBoundsScrollListener = null;
|
|
396
403
|
this.mutationObserver = null;
|
|
397
404
|
this.composerDragHandlers = null;
|
|
398
405
|
/** Last slot highlighted during Composer drag — avoid clear/re-add flicker. */
|
|
@@ -1292,6 +1299,9 @@ Available Console Commands:
|
|
|
1292
1299
|
});
|
|
1293
1300
|
if (preview) {
|
|
1294
1301
|
params.set("preview", "true");
|
|
1302
|
+
if (typeof window !== "undefined" && isWorkingContentRequest(new URLSearchParams(window.location.search))) {
|
|
1303
|
+
params.set("working", "true");
|
|
1304
|
+
}
|
|
1295
1305
|
}
|
|
1296
1306
|
if (isOnOrchestratorOrigin) {
|
|
1297
1307
|
return `/api/layout/provider?${params.toString()}`;
|
|
@@ -2051,6 +2061,7 @@ Available Console Commands:
|
|
|
2051
2061
|
this.applyComponentHighlights(highlightComponents, showZones);
|
|
2052
2062
|
this.setupMutationObserver();
|
|
2053
2063
|
this.setupComposerDragDrop();
|
|
2064
|
+
this.setupComposerBoundsTracking();
|
|
2054
2065
|
}
|
|
2055
2066
|
previouslySelected.forEach((el) => {
|
|
2056
2067
|
if (document.contains(el)) {
|
|
@@ -2205,6 +2216,52 @@ Available Console Commands:
|
|
|
2205
2216
|
this.clearComposerSelection();
|
|
2206
2217
|
element.classList.add("amplifyup-selected");
|
|
2207
2218
|
}
|
|
2219
|
+
postComposerSelectionBounds() {
|
|
2220
|
+
if (typeof document === "undefined") return;
|
|
2221
|
+
if (!window.parent || window.parent === window) return;
|
|
2222
|
+
const el = document.querySelector(".amplifyup-selected");
|
|
2223
|
+
if (!el) return;
|
|
2224
|
+
const rect = el.getBoundingClientRect();
|
|
2225
|
+
window.parent.postMessage(
|
|
2226
|
+
{
|
|
2227
|
+
type: "SELECTION_BOUNDS",
|
|
2228
|
+
bounds: {
|
|
2229
|
+
top: rect.top,
|
|
2230
|
+
left: rect.left,
|
|
2231
|
+
width: rect.width,
|
|
2232
|
+
height: rect.height
|
|
2233
|
+
}
|
|
2234
|
+
},
|
|
2235
|
+
"*"
|
|
2236
|
+
);
|
|
2237
|
+
}
|
|
2238
|
+
setupComposerBoundsTracking() {
|
|
2239
|
+
if (typeof document === "undefined") return;
|
|
2240
|
+
this.teardownComposerBoundsTracking();
|
|
2241
|
+
const onScroll = () => {
|
|
2242
|
+
if (this.composerBoundsRaf) return;
|
|
2243
|
+
this.composerBoundsRaf = requestAnimationFrame(() => {
|
|
2244
|
+
this.composerBoundsRaf = 0;
|
|
2245
|
+
this.postComposerSelectionBounds();
|
|
2246
|
+
});
|
|
2247
|
+
};
|
|
2248
|
+
this.composerBoundsScrollListener = onScroll;
|
|
2249
|
+
document.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
2250
|
+
window.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
2251
|
+
window.addEventListener("resize", onScroll);
|
|
2252
|
+
}
|
|
2253
|
+
teardownComposerBoundsTracking() {
|
|
2254
|
+
const onScroll = this.composerBoundsScrollListener;
|
|
2255
|
+
this.composerBoundsScrollListener = null;
|
|
2256
|
+
if (this.composerBoundsRaf) {
|
|
2257
|
+
cancelAnimationFrame(this.composerBoundsRaf);
|
|
2258
|
+
this.composerBoundsRaf = 0;
|
|
2259
|
+
}
|
|
2260
|
+
if (!onScroll || typeof document === "undefined") return;
|
|
2261
|
+
document.removeEventListener("scroll", onScroll, true);
|
|
2262
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
2263
|
+
window.removeEventListener("resize", onScroll);
|
|
2264
|
+
}
|
|
2208
2265
|
/** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
|
|
2209
2266
|
injectComposerHighlightStyles(highlightComponents, showZones) {
|
|
2210
2267
|
if (typeof document === "undefined") return;
|
|
@@ -2372,6 +2429,7 @@ Available Console Commands:
|
|
|
2372
2429
|
if (typeof document === "undefined") return;
|
|
2373
2430
|
const clearSelection = opts?.clearSelection !== false;
|
|
2374
2431
|
this.highlightingEnabled = false;
|
|
2432
|
+
this.teardownComposerBoundsTracking();
|
|
2375
2433
|
this.teardownComposerDragDrop();
|
|
2376
2434
|
if (opts?.clearSelection !== false && typeof window !== "undefined") {
|
|
2377
2435
|
window.__AMPLIFYUP_COMPOSER_EDIT__ = false;
|