@amplifyup/sdk 0.1.54 → 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 +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 +6 -6
- package/dist/react.d.ts +6 -6
- package/dist/react.js +124 -91
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +126 -93
- 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
package/dist/AmplifyRenderer.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { createContext, useState, useEffect, Fragment as Fragment$1,
|
|
2
|
+
import { createContext, memo, useState, useEffect, useContext, Fragment as Fragment$1, Component } from 'react';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import 'marked';
|
|
5
5
|
|
|
@@ -556,6 +556,49 @@ function mergeEventContext(properties, attached) {
|
|
|
556
556
|
function setPageResourceFields(fields) {
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
+
// src/debug.ts
|
|
560
|
+
function envFlag(value) {
|
|
561
|
+
if (!value) return false;
|
|
562
|
+
const v = value.trim().toLowerCase();
|
|
563
|
+
return v === "1" || v === "true" || v === "yes";
|
|
564
|
+
}
|
|
565
|
+
function readAmplifyUpDebugEnv() {
|
|
566
|
+
try {
|
|
567
|
+
if (typeof process === "undefined") return false;
|
|
568
|
+
return envFlag(process.env.NEXT_PUBLIC_AMPLIFYUP_DEBUG) || envFlag(process.env.AMPLIFYUP_DEBUG);
|
|
569
|
+
} catch {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
var configDebug;
|
|
574
|
+
function setAmplifyUpDebug(enabled) {
|
|
575
|
+
configDebug = enabled;
|
|
576
|
+
}
|
|
577
|
+
function isAmplifyUpDebug() {
|
|
578
|
+
if (configDebug === true) return true;
|
|
579
|
+
if (configDebug === false) return false;
|
|
580
|
+
return readAmplifyUpDebugEnv();
|
|
581
|
+
}
|
|
582
|
+
var onceKeys = /* @__PURE__ */ new Set();
|
|
583
|
+
var onceRoute = "";
|
|
584
|
+
function resetOnceIfRouteChanged() {
|
|
585
|
+
const route = typeof window !== "undefined" ? window.location.pathname : "";
|
|
586
|
+
if (route === onceRoute) return;
|
|
587
|
+
onceKeys.clear();
|
|
588
|
+
onceRoute = route;
|
|
589
|
+
}
|
|
590
|
+
function sdkDebug(...args) {
|
|
591
|
+
if (!isAmplifyUpDebug()) return;
|
|
592
|
+
console.log(...args);
|
|
593
|
+
}
|
|
594
|
+
function sdkDebugOnce(key, ...args) {
|
|
595
|
+
if (!isAmplifyUpDebug()) return;
|
|
596
|
+
resetOnceIfRouteChanged();
|
|
597
|
+
if (onceKeys.has(key)) return;
|
|
598
|
+
onceKeys.add(key);
|
|
599
|
+
console.log(...args);
|
|
600
|
+
}
|
|
601
|
+
|
|
559
602
|
// src/index.ts
|
|
560
603
|
var DWELL_ACTIVITY_IDLE_MS = 2 * 60 * 1e3;
|
|
561
604
|
var DWELL_POLL_MS = 5e3;
|
|
@@ -787,13 +830,13 @@ var AmplifyUpSDK = class {
|
|
|
787
830
|
}
|
|
788
831
|
this.config = {
|
|
789
832
|
trackingId: previewOverrides.trackingId || config.trackingId,
|
|
790
|
-
debug: config.debug ??
|
|
791
|
-
// Enable debug by default
|
|
833
|
+
debug: config.debug ?? readAmplifyUpDebugEnv(),
|
|
792
834
|
target: this.target,
|
|
793
835
|
dev: config.dev,
|
|
794
836
|
...config.siteId ? { siteId: config.siteId } : {},
|
|
795
837
|
...config.pageContext ? { pageContext: config.pageContext } : {}
|
|
796
838
|
};
|
|
839
|
+
setAmplifyUpDebug(!!this.config.debug);
|
|
797
840
|
if (config.pageContext) {
|
|
798
841
|
this.pendingPageContext = config.pageContext;
|
|
799
842
|
this.recomputeAttachedContext();
|
|
@@ -3079,7 +3122,7 @@ function LiveNodeRender({
|
|
|
3079
3122
|
layoutNodeId: nodeId
|
|
3080
3123
|
}) });
|
|
3081
3124
|
}
|
|
3082
|
-
function
|
|
3125
|
+
function AmplifyRendererInner({
|
|
3083
3126
|
renderComponent,
|
|
3084
3127
|
pageConfig: serverPageConfig,
|
|
3085
3128
|
loadingComponent,
|
|
@@ -3221,14 +3264,22 @@ function AmplifyRenderer({
|
|
|
3221
3264
|
return `${indent}- ${n.id} (${n.componentId || "?"})${slotsDesc ? "\n" + slotsDesc : ""}`;
|
|
3222
3265
|
}).join("\n");
|
|
3223
3266
|
};
|
|
3224
|
-
|
|
3267
|
+
sdkDebugOnce(
|
|
3268
|
+
`layoutTree:${pageConfig?.id || ""}:${pageConfig?.route || ""}`,
|
|
3269
|
+
"[AmplifyRenderer] layoutTree received:\n%s",
|
|
3270
|
+
describeLayoutTree(layoutTree2)
|
|
3271
|
+
);
|
|
3225
3272
|
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
3226
3273
|
const message = {
|
|
3227
3274
|
type: "COMPONENT_TREE",
|
|
3228
3275
|
tree: componentTree
|
|
3229
3276
|
};
|
|
3230
3277
|
window.parent.postMessage(message, "*");
|
|
3231
|
-
|
|
3278
|
+
sdkDebug(
|
|
3279
|
+
"[AmplifyRenderer] Sent component tree from layoutTree:",
|
|
3280
|
+
componentTree.length,
|
|
3281
|
+
"root components"
|
|
3282
|
+
);
|
|
3232
3283
|
}
|
|
3233
3284
|
}, [pageConfig]);
|
|
3234
3285
|
useEffect(() => {
|
|
@@ -3379,7 +3430,7 @@ function AmplifyRenderer({
|
|
|
3379
3430
|
);
|
|
3380
3431
|
}
|
|
3381
3432
|
let slotChildren = {};
|
|
3382
|
-
|
|
3433
|
+
sdkDebugOnce(`node:${node.id}`, `[AmplifyRenderer] Rendering node ${node.id} (${node.componentId})`, {
|
|
3383
3434
|
hasSlots: !!(node.slots && node.slots.length > 0),
|
|
3384
3435
|
slotCount: node.slots?.length || 0,
|
|
3385
3436
|
slots: node.slots?.map((s) => ({ slotId: s.slotId, zoneId: s.zoneId, childrenCount: s.children?.length || 0 }))
|
|
@@ -3388,30 +3439,13 @@ function AmplifyRenderer({
|
|
|
3388
3439
|
for (const slot of node.slots) {
|
|
3389
3440
|
const slotKey = `${node.id}-${slot.slotId}`;
|
|
3390
3441
|
let childrenToRender = [];
|
|
3391
|
-
console.log(`[AmplifyRenderer] Processing slot ${slot.slotId} for node ${node.id}`, {
|
|
3392
|
-
slotKey,
|
|
3393
|
-
hasZoneId: !!slot.zoneId,
|
|
3394
|
-
hasVariants: !!slot.variants,
|
|
3395
|
-
hasVariantCache: !!variantCache[slotKey],
|
|
3396
|
-
directChildrenCount: slot.children?.length || 0
|
|
3397
|
-
});
|
|
3398
3442
|
if (slot.zoneId && slot.variants && variantCache[slotKey]) {
|
|
3399
3443
|
childrenToRender = variantCache[slotKey].children;
|
|
3400
|
-
console.log(`[AmplifyRenderer] Using cached variant for slot ${slot.slotId}`, {
|
|
3401
|
-
variantId: variantCache[slotKey].variantId,
|
|
3402
|
-
childrenCount: childrenToRender.length
|
|
3403
|
-
});
|
|
3404
3444
|
} else if (slot.zoneId && slot.variants) {
|
|
3405
3445
|
const defaultVariant = slot.variants.find((v) => v.isDefault);
|
|
3406
3446
|
childrenToRender = defaultVariant?.children || [];
|
|
3407
|
-
console.log(`[AmplifyRenderer] Using default variant for slot ${slot.slotId}`, {
|
|
3408
|
-
childrenCount: childrenToRender.length
|
|
3409
|
-
});
|
|
3410
3447
|
} else {
|
|
3411
3448
|
childrenToRender = Array.isArray(slot.children) ? slot.children : [];
|
|
3412
|
-
console.log(`[AmplifyRenderer] Using direct children for slot ${slot.slotId}`, {
|
|
3413
|
-
childrenCount: childrenToRender.length
|
|
3414
|
-
});
|
|
3415
3449
|
}
|
|
3416
3450
|
const safeChildren = Array.isArray(childrenToRender) ? childrenToRender : [];
|
|
3417
3451
|
slotChildren[slot.slotId] = /* @__PURE__ */ jsx(
|
|
@@ -3426,10 +3460,6 @@ function AmplifyRenderer({
|
|
|
3426
3460
|
},
|
|
3427
3461
|
slot.slotId
|
|
3428
3462
|
);
|
|
3429
|
-
console.log(`[AmplifyRenderer] Created slot content for ${slot.slotId}`, {
|
|
3430
|
-
slotId: slot.slotId,
|
|
3431
|
-
renderedChildrenCount: childrenToRender.length
|
|
3432
|
-
});
|
|
3433
3463
|
}
|
|
3434
3464
|
}
|
|
3435
3465
|
const slotsToPass = Object.keys(slotChildren).length > 0 ? slotChildren : void 0;
|
|
@@ -3467,6 +3497,7 @@ function AmplifyRenderer({
|
|
|
3467
3497
|
}
|
|
3468
3498
|
) : layoutTree.map((node) => /* @__PURE__ */ jsx("div", { children: renderNode(node) }, node.id)) });
|
|
3469
3499
|
}
|
|
3500
|
+
var AmplifyRenderer = memo(AmplifyRendererInner);
|
|
3470
3501
|
|
|
3471
3502
|
export { AmplifyRenderer };
|
|
3472
3503
|
//# sourceMappingURL=AmplifyRenderer.mjs.map
|