@amplifyup/sdk 0.1.54 → 0.1.56
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.d.mts +5 -3
- package/dist/AmplifyRenderer.d.ts +5 -3
- package/dist/AmplifyRenderer.js +58 -27
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +59 -28
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{query-L7zSmLFX.d.ts → query-BqApXxQi.d.ts} +1 -1
- package/dist/{query-CWFb7rSm.d.mts → query-DaJlqU-Z.d.mts} +1 -1
- package/dist/react.d.mts +10 -10
- package/dist/react.d.ts +10 -10
- package/dist/react.js +168 -117
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +170 -119
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/{types-DpTzUg1C.d.mts → types-Db_eLrfU.d.mts} +5 -0
- package/dist/{types-DpTzUg1C.d.ts → types-Db_eLrfU.d.ts} +5 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { P as PageConfig } from './types-Db_eLrfU.mjs';
|
|
4
5
|
|
|
5
6
|
interface AmplifyRendererProps {
|
|
6
7
|
/**
|
|
@@ -33,6 +34,7 @@ interface AmplifyRendererProps {
|
|
|
33
34
|
*/
|
|
34
35
|
composerPreview?: boolean;
|
|
35
36
|
}
|
|
36
|
-
declare function
|
|
37
|
+
declare function AmplifyRendererInner({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, composerPreview, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
38
|
+
declare const AmplifyRenderer: React.MemoExoticComponent<typeof AmplifyRendererInner>;
|
|
37
39
|
|
|
38
40
|
export { AmplifyRenderer };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { P as PageConfig } from './types-Db_eLrfU.js';
|
|
4
5
|
|
|
5
6
|
interface AmplifyRendererProps {
|
|
6
7
|
/**
|
|
@@ -33,6 +34,7 @@ interface AmplifyRendererProps {
|
|
|
33
34
|
*/
|
|
34
35
|
composerPreview?: boolean;
|
|
35
36
|
}
|
|
36
|
-
declare function
|
|
37
|
+
declare function AmplifyRendererInner({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, composerPreview, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
38
|
+
declare const AmplifyRenderer: React.MemoExoticComponent<typeof AmplifyRendererInner>;
|
|
37
39
|
|
|
38
40
|
export { AmplifyRenderer };
|
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -558,6 +558,49 @@ function mergeEventContext(properties, attached) {
|
|
|
558
558
|
function setPageResourceFields(fields) {
|
|
559
559
|
}
|
|
560
560
|
|
|
561
|
+
// src/debug.ts
|
|
562
|
+
function envFlag(value) {
|
|
563
|
+
if (!value) return false;
|
|
564
|
+
const v = value.trim().toLowerCase();
|
|
565
|
+
return v === "1" || v === "true" || v === "yes";
|
|
566
|
+
}
|
|
567
|
+
function readAmplifyUpDebugEnv() {
|
|
568
|
+
try {
|
|
569
|
+
if (typeof process === "undefined") return false;
|
|
570
|
+
return envFlag(process.env.NEXT_PUBLIC_AMPLIFYUP_DEBUG) || envFlag(process.env.AMPLIFYUP_DEBUG);
|
|
571
|
+
} catch {
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
var configDebug;
|
|
576
|
+
function setAmplifyUpDebug(enabled) {
|
|
577
|
+
configDebug = enabled;
|
|
578
|
+
}
|
|
579
|
+
function isAmplifyUpDebug() {
|
|
580
|
+
if (configDebug === true) return true;
|
|
581
|
+
if (configDebug === false) return false;
|
|
582
|
+
return readAmplifyUpDebugEnv();
|
|
583
|
+
}
|
|
584
|
+
var onceKeys = /* @__PURE__ */ new Set();
|
|
585
|
+
var onceRoute = "";
|
|
586
|
+
function resetOnceIfRouteChanged() {
|
|
587
|
+
const route = typeof window !== "undefined" ? window.location.pathname : "";
|
|
588
|
+
if (route === onceRoute) return;
|
|
589
|
+
onceKeys.clear();
|
|
590
|
+
onceRoute = route;
|
|
591
|
+
}
|
|
592
|
+
function sdkDebug(...args) {
|
|
593
|
+
if (!isAmplifyUpDebug()) return;
|
|
594
|
+
console.log(...args);
|
|
595
|
+
}
|
|
596
|
+
function sdkDebugOnce(key, ...args) {
|
|
597
|
+
if (!isAmplifyUpDebug()) return;
|
|
598
|
+
resetOnceIfRouteChanged();
|
|
599
|
+
if (onceKeys.has(key)) return;
|
|
600
|
+
onceKeys.add(key);
|
|
601
|
+
console.log(...args);
|
|
602
|
+
}
|
|
603
|
+
|
|
561
604
|
// src/index.ts
|
|
562
605
|
var DWELL_ACTIVITY_IDLE_MS = 2 * 60 * 1e3;
|
|
563
606
|
var DWELL_POLL_MS = 5e3;
|
|
@@ -789,13 +832,13 @@ var AmplifyUpSDK = class {
|
|
|
789
832
|
}
|
|
790
833
|
this.config = {
|
|
791
834
|
trackingId: previewOverrides.trackingId || config.trackingId,
|
|
792
|
-
debug: config.debug ??
|
|
793
|
-
// Enable debug by default
|
|
835
|
+
debug: config.debug ?? readAmplifyUpDebugEnv(),
|
|
794
836
|
target: this.target,
|
|
795
837
|
dev: config.dev,
|
|
796
838
|
...config.siteId ? { siteId: config.siteId } : {},
|
|
797
839
|
...config.pageContext ? { pageContext: config.pageContext } : {}
|
|
798
840
|
};
|
|
841
|
+
setAmplifyUpDebug(!!this.config.debug);
|
|
799
842
|
if (config.pageContext) {
|
|
800
843
|
this.pendingPageContext = config.pageContext;
|
|
801
844
|
this.recomputeAttachedContext();
|
|
@@ -3081,7 +3124,7 @@ function LiveNodeRender({
|
|
|
3081
3124
|
layoutNodeId: nodeId
|
|
3082
3125
|
}) });
|
|
3083
3126
|
}
|
|
3084
|
-
function
|
|
3127
|
+
function AmplifyRendererInner({
|
|
3085
3128
|
renderComponent,
|
|
3086
3129
|
pageConfig: serverPageConfig,
|
|
3087
3130
|
loadingComponent,
|
|
@@ -3223,14 +3266,22 @@ function AmplifyRenderer({
|
|
|
3223
3266
|
return `${indent}- ${n.id} (${n.componentId || "?"})${slotsDesc ? "\n" + slotsDesc : ""}`;
|
|
3224
3267
|
}).join("\n");
|
|
3225
3268
|
};
|
|
3226
|
-
|
|
3269
|
+
sdkDebugOnce(
|
|
3270
|
+
`layoutTree:${pageConfig?.id || ""}:${pageConfig?.route || ""}`,
|
|
3271
|
+
"[AmplifyRenderer] layoutTree received:\n%s",
|
|
3272
|
+
describeLayoutTree(layoutTree2)
|
|
3273
|
+
);
|
|
3227
3274
|
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
3228
3275
|
const message = {
|
|
3229
3276
|
type: "COMPONENT_TREE",
|
|
3230
3277
|
tree: componentTree
|
|
3231
3278
|
};
|
|
3232
3279
|
window.parent.postMessage(message, "*");
|
|
3233
|
-
|
|
3280
|
+
sdkDebug(
|
|
3281
|
+
"[AmplifyRenderer] Sent component tree from layoutTree:",
|
|
3282
|
+
componentTree.length,
|
|
3283
|
+
"root components"
|
|
3284
|
+
);
|
|
3234
3285
|
}
|
|
3235
3286
|
}, [pageConfig]);
|
|
3236
3287
|
react.useEffect(() => {
|
|
@@ -3381,7 +3432,7 @@ function AmplifyRenderer({
|
|
|
3381
3432
|
);
|
|
3382
3433
|
}
|
|
3383
3434
|
let slotChildren = {};
|
|
3384
|
-
|
|
3435
|
+
sdkDebugOnce(`node:${node.id}`, `[AmplifyRenderer] Rendering node ${node.id} (${node.componentId})`, {
|
|
3385
3436
|
hasSlots: !!(node.slots && node.slots.length > 0),
|
|
3386
3437
|
slotCount: node.slots?.length || 0,
|
|
3387
3438
|
slots: node.slots?.map((s) => ({ slotId: s.slotId, zoneId: s.zoneId, childrenCount: s.children?.length || 0 }))
|
|
@@ -3390,30 +3441,13 @@ function AmplifyRenderer({
|
|
|
3390
3441
|
for (const slot of node.slots) {
|
|
3391
3442
|
const slotKey = `${node.id}-${slot.slotId}`;
|
|
3392
3443
|
let childrenToRender = [];
|
|
3393
|
-
console.log(`[AmplifyRenderer] Processing slot ${slot.slotId} for node ${node.id}`, {
|
|
3394
|
-
slotKey,
|
|
3395
|
-
hasZoneId: !!slot.zoneId,
|
|
3396
|
-
hasVariants: !!slot.variants,
|
|
3397
|
-
hasVariantCache: !!variantCache[slotKey],
|
|
3398
|
-
directChildrenCount: slot.children?.length || 0
|
|
3399
|
-
});
|
|
3400
3444
|
if (slot.zoneId && slot.variants && variantCache[slotKey]) {
|
|
3401
3445
|
childrenToRender = variantCache[slotKey].children;
|
|
3402
|
-
console.log(`[AmplifyRenderer] Using cached variant for slot ${slot.slotId}`, {
|
|
3403
|
-
variantId: variantCache[slotKey].variantId,
|
|
3404
|
-
childrenCount: childrenToRender.length
|
|
3405
|
-
});
|
|
3406
3446
|
} else if (slot.zoneId && slot.variants) {
|
|
3407
3447
|
const defaultVariant = slot.variants.find((v) => v.isDefault);
|
|
3408
3448
|
childrenToRender = defaultVariant?.children || [];
|
|
3409
|
-
console.log(`[AmplifyRenderer] Using default variant for slot ${slot.slotId}`, {
|
|
3410
|
-
childrenCount: childrenToRender.length
|
|
3411
|
-
});
|
|
3412
3449
|
} else {
|
|
3413
3450
|
childrenToRender = Array.isArray(slot.children) ? slot.children : [];
|
|
3414
|
-
console.log(`[AmplifyRenderer] Using direct children for slot ${slot.slotId}`, {
|
|
3415
|
-
childrenCount: childrenToRender.length
|
|
3416
|
-
});
|
|
3417
3451
|
}
|
|
3418
3452
|
const safeChildren = Array.isArray(childrenToRender) ? childrenToRender : [];
|
|
3419
3453
|
slotChildren[slot.slotId] = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3428,10 +3462,6 @@ function AmplifyRenderer({
|
|
|
3428
3462
|
},
|
|
3429
3463
|
slot.slotId
|
|
3430
3464
|
);
|
|
3431
|
-
console.log(`[AmplifyRenderer] Created slot content for ${slot.slotId}`, {
|
|
3432
|
-
slotId: slot.slotId,
|
|
3433
|
-
renderedChildrenCount: childrenToRender.length
|
|
3434
|
-
});
|
|
3435
3465
|
}
|
|
3436
3466
|
}
|
|
3437
3467
|
const slotsToPass = Object.keys(slotChildren).length > 0 ? slotChildren : void 0;
|
|
@@ -3469,6 +3499,7 @@ function AmplifyRenderer({
|
|
|
3469
3499
|
}
|
|
3470
3500
|
) : layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderNode(node) }, node.id)) });
|
|
3471
3501
|
}
|
|
3502
|
+
var AmplifyRenderer = react.memo(AmplifyRendererInner);
|
|
3472
3503
|
|
|
3473
3504
|
exports.AmplifyRenderer = AmplifyRenderer;
|
|
3474
3505
|
//# sourceMappingURL=AmplifyRenderer.js.map
|