@farm.js/core 0.1.0-beta.53 → 0.1.0-beta.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/{chunk-FCY7TXMA.mjs → chunk-2ISN27CV.mjs} +2 -2
- package/dist/{chunk-RPEYD7TD.mjs → chunk-BLTATPSB.mjs} +2 -2
- package/dist/{chunk-RPEYD7TD.mjs.map → chunk-BLTATPSB.mjs.map} +1 -1
- package/dist/{chunk-LN2BAU5H.mjs → chunk-MSQDIAQW.mjs} +2 -2
- package/dist/{chunk-GPHLXAFT.mjs → chunk-OGFWHBDO.mjs} +2 -2
- package/dist/{chunk-JECGLPIS.mjs → chunk-PYIVNTDI.mjs} +4 -4
- package/dist/{chunk-HAMMDSJM.mjs → chunk-RAZ7L3UY.mjs} +2 -2
- package/dist/{chunk-427JQ6OZ.mjs → chunk-YBHLSG7E.mjs} +54 -11
- package/dist/chunk-YBHLSG7E.mjs.map +1 -0
- package/dist/{chunk-BDHDDITP.mjs → chunk-ZP5IWDTE.mjs} +9 -8
- package/dist/chunk-ZP5IWDTE.mjs.map +1 -0
- package/dist/client/lifecycle.mjs +2 -2
- package/dist/client-plugins.cjs +1 -1
- package/dist/client-plugins.cjs.map +1 -1
- package/dist/client-plugins.mjs +2 -2
- package/dist/client.cjs +41 -12
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.mts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.mjs +11 -11
- package/dist/index.cjs +41 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +17 -17
- package/dist/internal/build-runtime.cjs +1 -1
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.mjs +3 -3
- package/dist/internal/client-runtime.cjs +1 -1
- package/dist/internal/client-runtime.cjs.map +1 -1
- package/dist/internal/client-runtime.mjs +2 -2
- package/dist/navigation.cjs +40 -11
- package/dist/navigation.cjs.map +1 -1
- package/dist/navigation.mjs +4 -4
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.mjs +2 -2
- package/dist/query/client.cjs +86 -7
- package/dist/query/client.cjs.map +1 -1
- package/dist/query/client.mjs +13 -7
- package/dist/query/client.mjs.map +1 -1
- package/dist/renderer-client.cjs +29 -9
- package/dist/renderer-client.cjs.map +1 -1
- package/dist/renderer-client.d.mts +1 -1
- package/dist/renderer-client.d.ts +1 -1
- package/dist/renderer-client.mjs +12 -9
- package/dist/renderer-client.mjs.map +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.mjs +2 -2
- package/dist/{spa-router-BD7iUG-C.d.mts → spa-router-BV71GGW0.d.mts} +4 -3
- package/dist/{spa-router-swFKTqwR.d.ts → spa-router-BylM6JXm.d.ts} +4 -3
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +2 -2
- package/package.json +3 -3
- package/dist/chunk-427JQ6OZ.mjs.map +0 -1
- package/dist/chunk-BDHDDITP.mjs.map +0 -1
- /package/dist/{chunk-FCY7TXMA.mjs.map → chunk-2ISN27CV.mjs.map} +0 -0
- /package/dist/{chunk-LN2BAU5H.mjs.map → chunk-MSQDIAQW.mjs.map} +0 -0
- /package/dist/{chunk-GPHLXAFT.mjs.map → chunk-OGFWHBDO.mjs.map} +0 -0
- /package/dist/{chunk-JECGLPIS.mjs.map → chunk-PYIVNTDI.mjs.map} +0 -0
- /package/dist/{chunk-HAMMDSJM.mjs.map → chunk-RAZ7L3UY.mjs.map} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createClientPluginManager,
|
|
3
3
|
installChunkErrorRecovery
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-MSQDIAQW.mjs";
|
|
5
5
|
import {
|
|
6
6
|
searchParamsToObject
|
|
7
7
|
} from "../chunk-4DCGM2BW.mjs";
|
|
8
8
|
import "../chunk-FXG2PS27.mjs";
|
|
9
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-BLTATPSB.mjs";
|
|
10
10
|
import {
|
|
11
11
|
__name
|
|
12
12
|
} from "../chunk-CGILA3WO.mjs";
|
package/dist/navigation.cjs
CHANGED
|
@@ -616,6 +616,16 @@ var _SPARouter = class _SPARouter {
|
|
|
616
616
|
this.navigationListeners = /* @__PURE__ */ new Set();
|
|
617
617
|
this.navigationState = IDLE_NAVIGATION_STATE;
|
|
618
618
|
this.scrollElements = /* @__PURE__ */ new Map();
|
|
619
|
+
this.onPopState = /* @__PURE__ */ __name((event) => {
|
|
620
|
+
void this.handlePopState(event);
|
|
621
|
+
}, "onPopState");
|
|
622
|
+
this.onBeforeUnload = /* @__PURE__ */ __name((event) => {
|
|
623
|
+
if (this.blockers.size > 0) {
|
|
624
|
+
event.preventDefault();
|
|
625
|
+
event.returnValue = "";
|
|
626
|
+
}
|
|
627
|
+
this.saveScrollPosition(window.location.pathname);
|
|
628
|
+
}, "onBeforeUnload");
|
|
619
629
|
this.options = {
|
|
620
630
|
prefetchTimeout: options.prefetchTimeout ?? 100,
|
|
621
631
|
cacheMaxAge: options.cacheMaxAge ?? 3e4,
|
|
@@ -625,16 +635,16 @@ var _SPARouter = class _SPARouter {
|
|
|
625
635
|
deploymentId: options.deploymentId ?? readBrowserDeploymentId()
|
|
626
636
|
};
|
|
627
637
|
if (typeof window !== "undefined") {
|
|
628
|
-
window.addEventListener("popstate", this.
|
|
629
|
-
window.addEventListener("beforeunload",
|
|
630
|
-
if (this.blockers.size > 0) {
|
|
631
|
-
event.preventDefault();
|
|
632
|
-
event.returnValue = "";
|
|
633
|
-
}
|
|
634
|
-
this.saveScrollPosition(window.location.pathname);
|
|
635
|
-
});
|
|
638
|
+
window.addEventListener("popstate", this.onPopState);
|
|
639
|
+
window.addEventListener("beforeunload", this.onBeforeUnload);
|
|
636
640
|
}
|
|
637
641
|
}
|
|
642
|
+
/** Remove global listeners. Intended for tests and teardown. */
|
|
643
|
+
destroy() {
|
|
644
|
+
if (typeof window === "undefined") return;
|
|
645
|
+
window.removeEventListener("popstate", this.onPopState);
|
|
646
|
+
window.removeEventListener("beforeunload", this.onBeforeUnload);
|
|
647
|
+
}
|
|
638
648
|
/**
|
|
639
649
|
* Set the navigation handler that updates React
|
|
640
650
|
*/
|
|
@@ -1097,11 +1107,16 @@ function dispatchDeploymentMismatch(error) {
|
|
|
1097
1107
|
window.dispatchEvent(new CustomEvent("farm:deployment-mismatch", { detail: error }));
|
|
1098
1108
|
}
|
|
1099
1109
|
__name(dispatchDeploymentMismatch, "dispatchDeploymentMismatch");
|
|
1110
|
+
function getInstalledFarmSPARouter() {
|
|
1111
|
+
if (typeof window === "undefined") return void 0;
|
|
1112
|
+
return window.__FARM_SPA_ROUTER__;
|
|
1113
|
+
}
|
|
1114
|
+
__name(getInstalledFarmSPARouter, "getInstalledFarmSPARouter");
|
|
1100
1115
|
function getRouter() {
|
|
1101
1116
|
if (typeof window === "undefined") {
|
|
1102
1117
|
return new SPARouter();
|
|
1103
1118
|
}
|
|
1104
|
-
const installedRouter =
|
|
1119
|
+
const installedRouter = getInstalledFarmSPARouter();
|
|
1105
1120
|
if (installedRouter) {
|
|
1106
1121
|
routerInstance = installedRouter;
|
|
1107
1122
|
return installedRouter;
|
|
@@ -1153,6 +1168,20 @@ function getScrollElementStorageKey(path, key) {
|
|
|
1153
1168
|
}
|
|
1154
1169
|
__name(getScrollElementStorageKey, "getScrollElementStorageKey");
|
|
1155
1170
|
|
|
1171
|
+
// src/client/url-search-sync.ts
|
|
1172
|
+
var FARM_URL_SEARCH_CHANGE_EVENT = "farm:urlsearchchange";
|
|
1173
|
+
function subscribeUrlSearchObservers(listener) {
|
|
1174
|
+
if (typeof window === "undefined") return () => {
|
|
1175
|
+
};
|
|
1176
|
+
window.addEventListener("popstate", listener);
|
|
1177
|
+
window.addEventListener(FARM_URL_SEARCH_CHANGE_EVENT, listener);
|
|
1178
|
+
return () => {
|
|
1179
|
+
window.removeEventListener("popstate", listener);
|
|
1180
|
+
window.removeEventListener(FARM_URL_SEARCH_CHANGE_EVENT, listener);
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
__name(subscribeUrlSearchObservers, "subscribeUrlSearchObservers");
|
|
1184
|
+
|
|
1156
1185
|
// src/client/router.ts
|
|
1157
1186
|
function useRouter(options = {}) {
|
|
1158
1187
|
const basePath = options.basePath || "";
|
|
@@ -1171,8 +1200,8 @@ function useRouter(options = {}) {
|
|
|
1171
1200
|
setState(readRouterState(basePath, routeMatcher));
|
|
1172
1201
|
}, "handlePopState");
|
|
1173
1202
|
handlePopState();
|
|
1174
|
-
|
|
1175
|
-
return
|
|
1203
|
+
const unsubscribe = subscribeUrlSearchObservers(handlePopState);
|
|
1204
|
+
return unsubscribe;
|
|
1176
1205
|
}, [basePath, routeMatcher]);
|
|
1177
1206
|
const push = /* @__PURE__ */ __name((href) => {
|
|
1178
1207
|
if (typeof window === "undefined") return;
|