@amplifyup/sdk 0.3.1 → 0.3.2-uat.107.gfe9868a
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 +15 -1
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +15 -1
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +52 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +52 -1
- package/dist/react.mjs.map +1 -1
- package/dist/server.js +36 -22
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +36 -22
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -409,6 +409,12 @@ function resolveAmplifyUpUrls(target) {
|
|
|
409
409
|
function isPreviewRequest(searchParams) {
|
|
410
410
|
return paramIsTrue(searchParams, "preview") || paramIsTrue(searchParams, "visualEditor");
|
|
411
411
|
}
|
|
412
|
+
var PREVIEW_ACCESS_REQUIRED = "preview_access_required";
|
|
413
|
+
function readPreviewToken(searchParams) {
|
|
414
|
+
if (searchParams instanceof URLSearchParams) return searchParams.get("previewToken");
|
|
415
|
+
const value = searchParams.previewToken;
|
|
416
|
+
return (Array.isArray(value) ? value[0] : value) || null;
|
|
417
|
+
}
|
|
412
418
|
function isWorkingContentRequest(searchParams) {
|
|
413
419
|
return paramIsTrue(searchParams, "working");
|
|
414
420
|
}
|
|
@@ -2506,6 +2512,8 @@ Available Console Commands:
|
|
|
2506
2512
|
if (compositionId) params.set("compositionId", compositionId);
|
|
2507
2513
|
const layoutId = pageSearch.get("layoutId");
|
|
2508
2514
|
if (layoutId) params.set("layoutId", layoutId);
|
|
2515
|
+
const previewToken = readPreviewToken(pageSearch);
|
|
2516
|
+
if (previewToken) params.set("previewToken", previewToken);
|
|
2509
2517
|
}
|
|
2510
2518
|
}
|
|
2511
2519
|
if (isOnOrchestratorOrigin) {
|
|
@@ -2550,6 +2558,10 @@ Available Console Commands:
|
|
|
2550
2558
|
if (response.status === 404) {
|
|
2551
2559
|
return null;
|
|
2552
2560
|
}
|
|
2561
|
+
if (response.status === 401) {
|
|
2562
|
+
const body = await response.json().catch(() => null);
|
|
2563
|
+
if (body?.error === PREVIEW_ACCESS_REQUIRED) throw new Error(PREVIEW_ACCESS_REQUIRED);
|
|
2564
|
+
}
|
|
2553
2565
|
throw new Error(`Failed to fetch page: ${response.statusText}`);
|
|
2554
2566
|
}
|
|
2555
2567
|
const contentType = response.headers.get("content-type") || "";
|
|
@@ -5243,7 +5255,9 @@ function AmplifyRendererInner(rendererProps) {
|
|
|
5243
5255
|
}
|
|
5244
5256
|
personalizationUrl = url.toString();
|
|
5245
5257
|
} else if (orchestratorUrl) {
|
|
5246
|
-
|
|
5258
|
+
const trackingId = sdk.getTrackingId();
|
|
5259
|
+
if (!trackingId) return;
|
|
5260
|
+
personalizationUrl = `${orchestratorUrl}/api/personalization/variant?trackingId=${encodeURIComponent(trackingId)}&instanceId=${encodeURIComponent(instanceId)}&layoutId=${encodeURIComponent(pageConfig.layoutId)}&slotId=${encodeURIComponent(slot.slotId)}&nodeId=${encodeURIComponent(node.id)}`;
|
|
5247
5261
|
} else {
|
|
5248
5262
|
return;
|
|
5249
5263
|
}
|
|
@@ -5424,6 +5438,40 @@ function AmplifyRendererInner(rendererProps) {
|
|
|
5424
5438
|
) });
|
|
5425
5439
|
}
|
|
5426
5440
|
var AmplifyRenderer = React3.memo(AmplifyRendererInner);
|
|
5441
|
+
var containerStyle = {
|
|
5442
|
+
display: "flex",
|
|
5443
|
+
minHeight: "50vh",
|
|
5444
|
+
alignItems: "center",
|
|
5445
|
+
justifyContent: "center",
|
|
5446
|
+
padding: "24px",
|
|
5447
|
+
fontFamily: "system-ui, sans-serif"
|
|
5448
|
+
};
|
|
5449
|
+
var cardStyle = {
|
|
5450
|
+
maxWidth: "24rem",
|
|
5451
|
+
padding: "24px",
|
|
5452
|
+
textAlign: "center",
|
|
5453
|
+
border: "1px solid #e2e8f0",
|
|
5454
|
+
borderRadius: "12px",
|
|
5455
|
+
background: "#ffffff",
|
|
5456
|
+
color: "#0f172a"
|
|
5457
|
+
};
|
|
5458
|
+
var headingStyle = { margin: "0 0 8px", fontSize: "18px", fontWeight: 600 };
|
|
5459
|
+
var bodyStyle = { margin: "0 0 16px", fontSize: "14px", lineHeight: 1.5, color: "#475569" };
|
|
5460
|
+
var buttonStyle = {
|
|
5461
|
+
padding: "8px 16px",
|
|
5462
|
+
border: "none",
|
|
5463
|
+
borderRadius: "8px",
|
|
5464
|
+
background: "#0f172a",
|
|
5465
|
+
color: "#ffffff",
|
|
5466
|
+
fontSize: "14px",
|
|
5467
|
+
fontWeight: 500,
|
|
5468
|
+
cursor: "pointer"
|
|
5469
|
+
};
|
|
5470
|
+
var PreviewRefreshNotice = () => /* @__PURE__ */ jsxRuntime.jsx("div", { style: containerStyle, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: cardStyle, children: [
|
|
5471
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle, children: "This preview needs a refresh" }),
|
|
5472
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: bodyStyle, children: "Reload it to keep seeing your latest changes." }),
|
|
5473
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: buttonStyle, onClick: () => window.location.reload(), children: "Reload preview" })
|
|
5474
|
+
] }) });
|
|
5427
5475
|
function previewPageSlot(state) {
|
|
5428
5476
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5429
5477
|
"div",
|
|
@@ -5492,6 +5540,9 @@ function AmplifyPageContent(contentProps) {
|
|
|
5492
5540
|
const previewEmpty = previewEmptyComponent ?? previewPageSlot("empty");
|
|
5493
5541
|
const previewLoading = previewLoadingComponent ?? previewPageSlot("loading");
|
|
5494
5542
|
if (preview) {
|
|
5543
|
+
if (client.error === PREVIEW_ACCESS_REQUIRED && !pageConfig) {
|
|
5544
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PreviewRefreshNotice, {});
|
|
5545
|
+
}
|
|
5495
5546
|
const ready = previewLayoutReady({
|
|
5496
5547
|
clientLoading: client.loading,
|
|
5497
5548
|
hasClientLayout: !!clientLayout,
|