@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/AmplifyRenderer.mjs
CHANGED
|
@@ -827,7 +827,9 @@ var AmplifyUpSDK = class {
|
|
|
827
827
|
this.page(url);
|
|
828
828
|
this.lastTrackedPath = url;
|
|
829
829
|
this.setupPageEngagement();
|
|
830
|
-
this.
|
|
830
|
+
if (!this.isNextJsApp()) {
|
|
831
|
+
this.installHistoryHooks();
|
|
832
|
+
}
|
|
831
833
|
}
|
|
832
834
|
}
|
|
833
835
|
if (this.config?.debug && this.initialized) {
|
|
@@ -1080,9 +1082,21 @@ var AmplifyUpSDK = class {
|
|
|
1080
1082
|
console.log("[AmplifyUp SDK] Route change page view", path);
|
|
1081
1083
|
}
|
|
1082
1084
|
}
|
|
1085
|
+
/** True on Next.js (App or Pages). Do not patch history on these apps. */
|
|
1086
|
+
isNextJsApp() {
|
|
1087
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1088
|
+
return false;
|
|
1089
|
+
}
|
|
1090
|
+
const win = window;
|
|
1091
|
+
if (win.next) return true;
|
|
1092
|
+
if (document.getElementById("__next")) return true;
|
|
1093
|
+
if (document.querySelector('script[src*="/_next/"]')) return true;
|
|
1094
|
+
return false;
|
|
1095
|
+
}
|
|
1083
1096
|
/**
|
|
1084
1097
|
* Patch history.pushState / replaceState + popstate for non-React SPAs.
|
|
1085
|
-
*
|
|
1098
|
+
* Next.js apps use AmplifyUpProvider.routeChange via usePathname instead —
|
|
1099
|
+
* wrapping history breaks App Router <Link> (no RSC request).
|
|
1086
1100
|
*/
|
|
1087
1101
|
installHistoryHooks() {
|
|
1088
1102
|
if (typeof window === "undefined" || this.historyHooksInstalled) return;
|
|
@@ -2931,11 +2945,9 @@ var refreshEventTracking = () => getSDK().refreshEventTracking();
|
|
|
2931
2945
|
getSDK();
|
|
2932
2946
|
createContext(null);
|
|
2933
2947
|
function useLiveComposerProps(layoutNodeId, props) {
|
|
2934
|
-
const [
|
|
2935
|
-
useEffect(() => {
|
|
2936
|
-
setLive(props);
|
|
2937
|
-
}, [props]);
|
|
2948
|
+
const [patch, setPatch] = useState(null);
|
|
2938
2949
|
useEffect(() => {
|
|
2950
|
+
setPatch(null);
|
|
2939
2951
|
const matchesNode = (nodeId) => {
|
|
2940
2952
|
if (nodeId && layoutNodeId && String(nodeId) !== String(layoutNodeId)) {
|
|
2941
2953
|
return false;
|
|
@@ -2945,15 +2957,15 @@ function useLiveComposerProps(layoutNodeId, props) {
|
|
|
2945
2957
|
const applyField = (fieldName, value, nodeId) => {
|
|
2946
2958
|
if (!fieldName || typeof fieldName !== "string") return;
|
|
2947
2959
|
if (!matchesNode(nodeId)) return;
|
|
2948
|
-
|
|
2960
|
+
setPatch((prev) => ({ ...prev || {}, [fieldName]: value }));
|
|
2949
2961
|
};
|
|
2950
2962
|
const applyProps = (nextProps, nodeId) => {
|
|
2951
2963
|
if (!nextProps || typeof nextProps !== "object" || Array.isArray(nextProps)) {
|
|
2952
2964
|
return;
|
|
2953
2965
|
}
|
|
2954
2966
|
if (!matchesNode(nodeId)) return;
|
|
2955
|
-
|
|
2956
|
-
...prev,
|
|
2967
|
+
setPatch((prev) => ({
|
|
2968
|
+
...prev || {},
|
|
2957
2969
|
...nextProps
|
|
2958
2970
|
}));
|
|
2959
2971
|
};
|
|
@@ -2982,7 +2994,7 @@ function useLiveComposerProps(layoutNodeId, props) {
|
|
|
2982
2994
|
window.removeEventListener("message", onMessage);
|
|
2983
2995
|
};
|
|
2984
2996
|
}, [layoutNodeId]);
|
|
2985
|
-
return
|
|
2997
|
+
return patch ? { ...props, ...patch } : props;
|
|
2986
2998
|
}
|
|
2987
2999
|
var usePathname = null;
|
|
2988
3000
|
if (typeof window !== "undefined") {
|