@amplifyup/sdk 0.1.53 → 0.1.55
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 +64 -35
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +65 -36
- 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 +6 -6
- package/dist/react.d.ts +6 -6
- package/dist/react.js +132 -100
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +134 -102
- 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();
|
|
@@ -2947,11 +2990,9 @@ var refreshEventTracking = () => getSDK().refreshEventTracking();
|
|
|
2947
2990
|
getSDK();
|
|
2948
2991
|
react.createContext(null);
|
|
2949
2992
|
function useLiveComposerProps(layoutNodeId, props) {
|
|
2950
|
-
const [
|
|
2951
|
-
react.useEffect(() => {
|
|
2952
|
-
setLive(props);
|
|
2953
|
-
}, [props]);
|
|
2993
|
+
const [patch, setPatch] = react.useState(null);
|
|
2954
2994
|
react.useEffect(() => {
|
|
2995
|
+
setPatch(null);
|
|
2955
2996
|
const matchesNode = (nodeId) => {
|
|
2956
2997
|
if (nodeId && layoutNodeId && String(nodeId) !== String(layoutNodeId)) {
|
|
2957
2998
|
return false;
|
|
@@ -2961,15 +3002,15 @@ function useLiveComposerProps(layoutNodeId, props) {
|
|
|
2961
3002
|
const applyField = (fieldName, value, nodeId) => {
|
|
2962
3003
|
if (!fieldName || typeof fieldName !== "string") return;
|
|
2963
3004
|
if (!matchesNode(nodeId)) return;
|
|
2964
|
-
|
|
3005
|
+
setPatch((prev) => ({ ...prev || {}, [fieldName]: value }));
|
|
2965
3006
|
};
|
|
2966
3007
|
const applyProps = (nextProps, nodeId) => {
|
|
2967
3008
|
if (!nextProps || typeof nextProps !== "object" || Array.isArray(nextProps)) {
|
|
2968
3009
|
return;
|
|
2969
3010
|
}
|
|
2970
3011
|
if (!matchesNode(nodeId)) return;
|
|
2971
|
-
|
|
2972
|
-
...prev,
|
|
3012
|
+
setPatch((prev) => ({
|
|
3013
|
+
...prev || {},
|
|
2973
3014
|
...nextProps
|
|
2974
3015
|
}));
|
|
2975
3016
|
};
|
|
@@ -2998,7 +3039,7 @@ function useLiveComposerProps(layoutNodeId, props) {
|
|
|
2998
3039
|
window.removeEventListener("message", onMessage);
|
|
2999
3040
|
};
|
|
3000
3041
|
}, [layoutNodeId]);
|
|
3001
|
-
return
|
|
3042
|
+
return patch ? { ...props, ...patch } : props;
|
|
3002
3043
|
}
|
|
3003
3044
|
var usePathname = null;
|
|
3004
3045
|
if (typeof window !== "undefined") {
|
|
@@ -3083,7 +3124,7 @@ function LiveNodeRender({
|
|
|
3083
3124
|
layoutNodeId: nodeId
|
|
3084
3125
|
}) });
|
|
3085
3126
|
}
|
|
3086
|
-
function
|
|
3127
|
+
function AmplifyRendererInner({
|
|
3087
3128
|
renderComponent,
|
|
3088
3129
|
pageConfig: serverPageConfig,
|
|
3089
3130
|
loadingComponent,
|
|
@@ -3225,14 +3266,22 @@ function AmplifyRenderer({
|
|
|
3225
3266
|
return `${indent}- ${n.id} (${n.componentId || "?"})${slotsDesc ? "\n" + slotsDesc : ""}`;
|
|
3226
3267
|
}).join("\n");
|
|
3227
3268
|
};
|
|
3228
|
-
|
|
3269
|
+
sdkDebugOnce(
|
|
3270
|
+
`layoutTree:${pageConfig?.id || ""}:${pageConfig?.route || ""}`,
|
|
3271
|
+
"[AmplifyRenderer] layoutTree received:\n%s",
|
|
3272
|
+
describeLayoutTree(layoutTree2)
|
|
3273
|
+
);
|
|
3229
3274
|
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
3230
3275
|
const message = {
|
|
3231
3276
|
type: "COMPONENT_TREE",
|
|
3232
3277
|
tree: componentTree
|
|
3233
3278
|
};
|
|
3234
3279
|
window.parent.postMessage(message, "*");
|
|
3235
|
-
|
|
3280
|
+
sdkDebug(
|
|
3281
|
+
"[AmplifyRenderer] Sent component tree from layoutTree:",
|
|
3282
|
+
componentTree.length,
|
|
3283
|
+
"root components"
|
|
3284
|
+
);
|
|
3236
3285
|
}
|
|
3237
3286
|
}, [pageConfig]);
|
|
3238
3287
|
react.useEffect(() => {
|
|
@@ -3383,7 +3432,7 @@ function AmplifyRenderer({
|
|
|
3383
3432
|
);
|
|
3384
3433
|
}
|
|
3385
3434
|
let slotChildren = {};
|
|
3386
|
-
|
|
3435
|
+
sdkDebugOnce(`node:${node.id}`, `[AmplifyRenderer] Rendering node ${node.id} (${node.componentId})`, {
|
|
3387
3436
|
hasSlots: !!(node.slots && node.slots.length > 0),
|
|
3388
3437
|
slotCount: node.slots?.length || 0,
|
|
3389
3438
|
slots: node.slots?.map((s) => ({ slotId: s.slotId, zoneId: s.zoneId, childrenCount: s.children?.length || 0 }))
|
|
@@ -3392,30 +3441,13 @@ function AmplifyRenderer({
|
|
|
3392
3441
|
for (const slot of node.slots) {
|
|
3393
3442
|
const slotKey = `${node.id}-${slot.slotId}`;
|
|
3394
3443
|
let childrenToRender = [];
|
|
3395
|
-
console.log(`[AmplifyRenderer] Processing slot ${slot.slotId} for node ${node.id}`, {
|
|
3396
|
-
slotKey,
|
|
3397
|
-
hasZoneId: !!slot.zoneId,
|
|
3398
|
-
hasVariants: !!slot.variants,
|
|
3399
|
-
hasVariantCache: !!variantCache[slotKey],
|
|
3400
|
-
directChildrenCount: slot.children?.length || 0
|
|
3401
|
-
});
|
|
3402
3444
|
if (slot.zoneId && slot.variants && variantCache[slotKey]) {
|
|
3403
3445
|
childrenToRender = variantCache[slotKey].children;
|
|
3404
|
-
console.log(`[AmplifyRenderer] Using cached variant for slot ${slot.slotId}`, {
|
|
3405
|
-
variantId: variantCache[slotKey].variantId,
|
|
3406
|
-
childrenCount: childrenToRender.length
|
|
3407
|
-
});
|
|
3408
3446
|
} else if (slot.zoneId && slot.variants) {
|
|
3409
3447
|
const defaultVariant = slot.variants.find((v) => v.isDefault);
|
|
3410
3448
|
childrenToRender = defaultVariant?.children || [];
|
|
3411
|
-
console.log(`[AmplifyRenderer] Using default variant for slot ${slot.slotId}`, {
|
|
3412
|
-
childrenCount: childrenToRender.length
|
|
3413
|
-
});
|
|
3414
3449
|
} else {
|
|
3415
3450
|
childrenToRender = Array.isArray(slot.children) ? slot.children : [];
|
|
3416
|
-
console.log(`[AmplifyRenderer] Using direct children for slot ${slot.slotId}`, {
|
|
3417
|
-
childrenCount: childrenToRender.length
|
|
3418
|
-
});
|
|
3419
3451
|
}
|
|
3420
3452
|
const safeChildren = Array.isArray(childrenToRender) ? childrenToRender : [];
|
|
3421
3453
|
slotChildren[slot.slotId] = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3430,10 +3462,6 @@ function AmplifyRenderer({
|
|
|
3430
3462
|
},
|
|
3431
3463
|
slot.slotId
|
|
3432
3464
|
);
|
|
3433
|
-
console.log(`[AmplifyRenderer] Created slot content for ${slot.slotId}`, {
|
|
3434
|
-
slotId: slot.slotId,
|
|
3435
|
-
renderedChildrenCount: childrenToRender.length
|
|
3436
|
-
});
|
|
3437
3465
|
}
|
|
3438
3466
|
}
|
|
3439
3467
|
const slotsToPass = Object.keys(slotChildren).length > 0 ? slotChildren : void 0;
|
|
@@ -3471,6 +3499,7 @@ function AmplifyRenderer({
|
|
|
3471
3499
|
}
|
|
3472
3500
|
) : layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderNode(node) }, node.id)) });
|
|
3473
3501
|
}
|
|
3502
|
+
var AmplifyRenderer = react.memo(AmplifyRendererInner);
|
|
3474
3503
|
|
|
3475
3504
|
exports.AmplifyRenderer = AmplifyRenderer;
|
|
3476
3505
|
//# sourceMappingURL=AmplifyRenderer.js.map
|