@amplifyup/sdk 0.1.52 → 0.1.54
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 +22 -10
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +22 -10
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -2
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.d.mts +10 -12
- package/dist/middleware.d.ts +10 -12
- package/dist/middleware.js +15 -157
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +15 -157
- package/dist/middleware.mjs.map +1 -1
- package/dist/react.js +24 -11
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +24 -11
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1227,7 +1227,9 @@ var AmplifyUpSDK = class {
|
|
|
1227
1227
|
this.page(url);
|
|
1228
1228
|
this.lastTrackedPath = url;
|
|
1229
1229
|
this.setupPageEngagement();
|
|
1230
|
-
this.
|
|
1230
|
+
if (!this.isNextJsApp()) {
|
|
1231
|
+
this.installHistoryHooks();
|
|
1232
|
+
}
|
|
1231
1233
|
}
|
|
1232
1234
|
}
|
|
1233
1235
|
if (this.config?.debug && this.initialized) {
|
|
@@ -1480,9 +1482,21 @@ var AmplifyUpSDK = class {
|
|
|
1480
1482
|
console.log("[AmplifyUp SDK] Route change page view", path);
|
|
1481
1483
|
}
|
|
1482
1484
|
}
|
|
1485
|
+
/** True on Next.js (App or Pages). Do not patch history on these apps. */
|
|
1486
|
+
isNextJsApp() {
|
|
1487
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1488
|
+
return false;
|
|
1489
|
+
}
|
|
1490
|
+
const win = window;
|
|
1491
|
+
if (win.next) return true;
|
|
1492
|
+
if (document.getElementById("__next")) return true;
|
|
1493
|
+
if (document.querySelector('script[src*="/_next/"]')) return true;
|
|
1494
|
+
return false;
|
|
1495
|
+
}
|
|
1483
1496
|
/**
|
|
1484
1497
|
* Patch history.pushState / replaceState + popstate for non-React SPAs.
|
|
1485
|
-
*
|
|
1498
|
+
* Next.js apps use AmplifyUpProvider.routeChange via usePathname instead —
|
|
1499
|
+
* wrapping history breaks App Router <Link> (no RSC request).
|
|
1486
1500
|
*/
|
|
1487
1501
|
installHistoryHooks() {
|
|
1488
1502
|
if (typeof window === "undefined" || this.historyHooksInstalled) return;
|
|
@@ -3426,11 +3440,9 @@ function EmptySlotHint({
|
|
|
3426
3440
|
}
|
|
3427
3441
|
var ComponentContext = React.createContext(null);
|
|
3428
3442
|
function useLiveComposerProps(layoutNodeId, props) {
|
|
3429
|
-
const [
|
|
3430
|
-
React.useEffect(() => {
|
|
3431
|
-
setLive(props);
|
|
3432
|
-
}, [props]);
|
|
3443
|
+
const [patch, setPatch] = React.useState(null);
|
|
3433
3444
|
React.useEffect(() => {
|
|
3445
|
+
setPatch(null);
|
|
3434
3446
|
const matchesNode = (nodeId) => {
|
|
3435
3447
|
if (nodeId && layoutNodeId && String(nodeId) !== String(layoutNodeId)) {
|
|
3436
3448
|
return false;
|
|
@@ -3440,15 +3452,15 @@ function useLiveComposerProps(layoutNodeId, props) {
|
|
|
3440
3452
|
const applyField = (fieldName, value, nodeId) => {
|
|
3441
3453
|
if (!fieldName || typeof fieldName !== "string") return;
|
|
3442
3454
|
if (!matchesNode(nodeId)) return;
|
|
3443
|
-
|
|
3455
|
+
setPatch((prev) => ({ ...prev || {}, [fieldName]: value }));
|
|
3444
3456
|
};
|
|
3445
3457
|
const applyProps = (nextProps, nodeId) => {
|
|
3446
3458
|
if (!nextProps || typeof nextProps !== "object" || Array.isArray(nextProps)) {
|
|
3447
3459
|
return;
|
|
3448
3460
|
}
|
|
3449
3461
|
if (!matchesNode(nodeId)) return;
|
|
3450
|
-
|
|
3451
|
-
...prev,
|
|
3462
|
+
setPatch((prev) => ({
|
|
3463
|
+
...prev || {},
|
|
3452
3464
|
...nextProps
|
|
3453
3465
|
}));
|
|
3454
3466
|
};
|
|
@@ -3477,7 +3489,7 @@ function useLiveComposerProps(layoutNodeId, props) {
|
|
|
3477
3489
|
window.removeEventListener("message", onMessage);
|
|
3478
3490
|
};
|
|
3479
3491
|
}, [layoutNodeId]);
|
|
3480
|
-
return
|
|
3492
|
+
return patch ? { ...props, ...patch } : props;
|
|
3481
3493
|
}
|
|
3482
3494
|
function useComponentProps() {
|
|
3483
3495
|
const context = React.useContext(ComponentContext);
|
|
@@ -3776,9 +3788,10 @@ function ComposerInlineField({
|
|
|
3776
3788
|
event.stopPropagation();
|
|
3777
3789
|
},
|
|
3778
3790
|
onClick: (event) => {
|
|
3791
|
+
if (!isComposerEditMode()) return;
|
|
3779
3792
|
const link = event.target?.closest?.("a");
|
|
3780
3793
|
if (link) event.preventDefault();
|
|
3781
|
-
if (render
|
|
3794
|
+
if (render) {
|
|
3782
3795
|
setEditing(true);
|
|
3783
3796
|
}
|
|
3784
3797
|
},
|