@farm.js/core 0.1.0-beta.54 → 0.1.0-beta.56
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-427JQ6OZ.mjs → chunk-5T2XATMK.mjs} +58 -11
- package/dist/chunk-5T2XATMK.mjs.map +1 -0
- package/dist/{chunk-J34JCW6R.mjs → chunk-FOEPWRHM.mjs} +2 -2
- package/dist/{chunk-BDHDDITP.mjs → chunk-FPLRESQA.mjs} +30 -18
- package/dist/chunk-FPLRESQA.mjs.map +1 -0
- package/dist/{chunk-JECGLPIS.mjs → chunk-PYIVNTDI.mjs} +4 -4
- package/dist/{chunk-GPHLXAFT.mjs → chunk-UH5R4J5M.mjs} +2 -2
- package/dist/{chunk-ENPB4CSY.mjs → chunk-XLQVJDK2.mjs} +2 -2
- package/dist/{chunk-ENPB4CSY.mjs.map → chunk-XLQVJDK2.mjs.map} +1 -1
- package/dist/{chunk-GVQ54ERX.mjs → chunk-YPKCFGA7.mjs} +9 -3
- package/dist/chunk-YPKCFGA7.mjs.map +1 -0
- package/dist/{chunk-PGZVE6P7.mjs → chunk-ZOQLQAUG.mjs} +2 -2
- 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 +76 -23
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.mts +2 -5
- package/dist/client.d.ts +2 -5
- package/dist/client.mjs +11 -11
- package/dist/index.cjs +85 -24
- 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 +8 -2
- 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 +74 -20
- 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 +105 -11
- package/dist/query/client.cjs.map +1 -1
- package/dist/query/client.mjs +18 -11
- package/dist/query/client.mjs.map +1 -1
- package/dist/renderer-client.cjs +56 -12
- 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 -11
- 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 +1 -1
- package/dist/chunk-427JQ6OZ.mjs.map +0 -1
- package/dist/chunk-BDHDDITP.mjs.map +0 -1
- package/dist/chunk-GVQ54ERX.mjs.map +0 -1
- /package/dist/{chunk-J34JCW6R.mjs.map → chunk-FOEPWRHM.mjs.map} +0 -0
- /package/dist/{chunk-JECGLPIS.mjs.map → chunk-PYIVNTDI.mjs.map} +0 -0
- /package/dist/{chunk-GPHLXAFT.mjs.map → chunk-UH5R4J5M.mjs.map} +0 -0
- /package/dist/{chunk-PGZVE6P7.mjs.map → chunk-ZOQLQAUG.mjs.map} +0 -0
package/dist/client.d.mts
CHANGED
|
@@ -7,8 +7,8 @@ export { UseServerQueryOptions, UseServerQueryResult, useServerQuery } from './s
|
|
|
7
7
|
export { F as FarmIntegrationAPI, e as FarmIntegrationAPIBodyFormat, f as FarmIntegrationAPIMethod, a as FarmIntegrationAPIOperation, g as FarmIntegrationAPIResponseFormat, b as api, d as defineIntegrationAPI, c as defineIntegrationAPIOperation, i as endpoint } from './config-DtTPh5Ml.mjs';
|
|
8
8
|
export { UseThemeResult, useTheme } from './theme/client.mjs';
|
|
9
9
|
import { FarmRouterPathParams, FarmRouterPathParam, FarmRouterBuildOptions, FarmRouterRouteInput } from './router.mjs';
|
|
10
|
-
import { i as FarmViewTransitionMode, e as FarmNavigationBlockerContext, F as FarmNavigationState } from './spa-router-
|
|
11
|
-
export { a as FarmNavigateOptions, d as FarmNavigationBlocker, f as FarmNavigationListener, h as FarmNavigationLocation, S as SPARouter, g as getRouter, n as navigateTo, p as prefetch, b as pushState, r as readPageState, c as replaceState } from './spa-router-
|
|
10
|
+
import { i as FarmViewTransitionMode, e as FarmNavigationBlockerContext, F as FarmNavigationState } from './spa-router-BV71GGW0.mjs';
|
|
11
|
+
export { a as FarmNavigateOptions, d as FarmNavigationBlocker, f as FarmNavigationListener, h as FarmNavigationLocation, S as SPARouter, g as getRouter, n as navigateTo, p as prefetch, b as pushState, r as readPageState, c as replaceState } from './spa-router-BV71GGW0.mjs';
|
|
12
12
|
import { b as FarmI18nLocale } from './types-mP6R6CzS.mjs';
|
|
13
13
|
export { F as FarmChunkRecoveryOptions, i as installChunkErrorRecovery, a as isChunkLoadError } from './chunk-recovery-lnQFzcQP.mjs';
|
|
14
14
|
export { a as FarmClientHydrationCompleteEvent, b as FarmClientHydrationEvent, d as FarmClientHydrationMode, e as FarmClientHydrationSession, f as FarmClientLocation, g as FarmClientNavigationAction, h as FarmClientNavigationErrorEvent, i as FarmClientNavigationEvent, j as FarmClientNavigationLoadedEvent, k as FarmClientNavigationResolvedEvent, l as FarmClientNavigationSession, m as FarmClientPerformanceEvent, n as FarmClientPlugin, o as FarmClientPluginCloseEvent, p as FarmClientPluginEnforce, q as FarmClientPluginErrorEvent, r as FarmClientPluginErrorPhase, F as FarmClientPluginManager, s as FarmClientPluginManagerOptions, t as FarmClientPluginMetadata, u as FarmClientPluginRegistration, v as FarmClientPluginRouter, w as FarmClientPluginSetupEvent, x as FarmClientPluginStateEvent, c as createClientPluginManager } from './lifecycle-CgO0tX2y.mjs';
|
|
@@ -286,9 +286,6 @@ interface UseBlockerOptions {
|
|
|
286
286
|
interface UseBlockerReturn {
|
|
287
287
|
active: boolean;
|
|
288
288
|
}
|
|
289
|
-
/**
|
|
290
|
-
* Hook for accessing router state and navigation
|
|
291
|
-
*/
|
|
292
289
|
declare function useRouter(options?: UseRouterOptions): {
|
|
293
290
|
push: (href: string) => void;
|
|
294
291
|
replace: (href: string) => void;
|
package/dist/client.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export { UseServerQueryOptions, UseServerQueryResult, useServerQuery } from './s
|
|
|
7
7
|
export { F as FarmIntegrationAPI, e as FarmIntegrationAPIBodyFormat, f as FarmIntegrationAPIMethod, a as FarmIntegrationAPIOperation, g as FarmIntegrationAPIResponseFormat, b as api, d as defineIntegrationAPI, c as defineIntegrationAPIOperation, i as endpoint } from './config-kwlUiWBX.js';
|
|
8
8
|
export { UseThemeResult, useTheme } from './theme/client.js';
|
|
9
9
|
import { FarmRouterPathParams, FarmRouterPathParam, FarmRouterBuildOptions, FarmRouterRouteInput } from './router.js';
|
|
10
|
-
import { i as FarmViewTransitionMode, e as FarmNavigationBlockerContext, F as FarmNavigationState } from './spa-router-
|
|
11
|
-
export { a as FarmNavigateOptions, d as FarmNavigationBlocker, f as FarmNavigationListener, h as FarmNavigationLocation, S as SPARouter, g as getRouter, n as navigateTo, p as prefetch, b as pushState, r as readPageState, c as replaceState } from './spa-router-
|
|
10
|
+
import { i as FarmViewTransitionMode, e as FarmNavigationBlockerContext, F as FarmNavigationState } from './spa-router-BylM6JXm.js';
|
|
11
|
+
export { a as FarmNavigateOptions, d as FarmNavigationBlocker, f as FarmNavigationListener, h as FarmNavigationLocation, S as SPARouter, g as getRouter, n as navigateTo, p as prefetch, b as pushState, r as readPageState, c as replaceState } from './spa-router-BylM6JXm.js';
|
|
12
12
|
import { b as FarmI18nLocale } from './types-mP6R6CzS.js';
|
|
13
13
|
export { F as FarmChunkRecoveryOptions, i as installChunkErrorRecovery, a as isChunkLoadError } from './chunk-recovery-lnQFzcQP.js';
|
|
14
14
|
export { a as FarmClientHydrationCompleteEvent, b as FarmClientHydrationEvent, d as FarmClientHydrationMode, e as FarmClientHydrationSession, f as FarmClientLocation, g as FarmClientNavigationAction, h as FarmClientNavigationErrorEvent, i as FarmClientNavigationEvent, j as FarmClientNavigationLoadedEvent, k as FarmClientNavigationResolvedEvent, l as FarmClientNavigationSession, m as FarmClientPerformanceEvent, n as FarmClientPlugin, o as FarmClientPluginCloseEvent, p as FarmClientPluginEnforce, q as FarmClientPluginErrorEvent, r as FarmClientPluginErrorPhase, F as FarmClientPluginManager, s as FarmClientPluginManagerOptions, t as FarmClientPluginMetadata, u as FarmClientPluginRegistration, v as FarmClientPluginRouter, w as FarmClientPluginSetupEvent, x as FarmClientPluginStateEvent, c as createClientPluginManager } from './lifecycle-CgO0tX2y.js';
|
|
@@ -286,9 +286,6 @@ interface UseBlockerOptions {
|
|
|
286
286
|
interface UseBlockerReturn {
|
|
287
287
|
active: boolean;
|
|
288
288
|
}
|
|
289
|
-
/**
|
|
290
|
-
* Hook for accessing router state and navigation
|
|
291
|
-
*/
|
|
292
289
|
declare function useRouter(options?: UseRouterOptions): {
|
|
293
290
|
push: (href: string) => void;
|
|
294
291
|
replace: (href: string) => void;
|
package/dist/client.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createStore,
|
|
4
4
|
useFetcher,
|
|
5
5
|
useMutation
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PYIVNTDI.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useAction
|
|
9
9
|
} from "./chunk-SALMKQXH.mjs";
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
usePageState,
|
|
17
17
|
useRouter,
|
|
18
18
|
useScrollRestoration
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-FPLRESQA.mjs";
|
|
20
20
|
import {
|
|
21
21
|
useTheme
|
|
22
22
|
} from "./chunk-CHITERV2.mjs";
|
|
@@ -39,6 +39,12 @@ import {
|
|
|
39
39
|
fetchServerQuery,
|
|
40
40
|
prefetchServerQuery
|
|
41
41
|
} from "./chunk-3E2WRUR2.mjs";
|
|
42
|
+
import {
|
|
43
|
+
getTheme,
|
|
44
|
+
setTheme,
|
|
45
|
+
toggleTheme
|
|
46
|
+
} from "./chunk-ZUSJ5CDC.mjs";
|
|
47
|
+
import "./chunk-ZBE6MLHL.mjs";
|
|
42
48
|
import {
|
|
43
49
|
SPARouter,
|
|
44
50
|
getRouter,
|
|
@@ -47,14 +53,8 @@ import {
|
|
|
47
53
|
pushState,
|
|
48
54
|
readPageState,
|
|
49
55
|
replaceState
|
|
50
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-5T2XATMK.mjs";
|
|
51
57
|
import "./chunk-ITN462YM.mjs";
|
|
52
|
-
import {
|
|
53
|
-
getTheme,
|
|
54
|
-
setTheme,
|
|
55
|
-
toggleTheme
|
|
56
|
-
} from "./chunk-ZUSJ5CDC.mjs";
|
|
57
|
-
import "./chunk-ZBE6MLHL.mjs";
|
|
58
58
|
import "./chunk-C4XSKA7P.mjs";
|
|
59
59
|
import "./chunk-SCFX4UTD.mjs";
|
|
60
60
|
import {
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
createClientPluginManager,
|
|
63
63
|
installChunkErrorRecovery,
|
|
64
64
|
isChunkLoadError
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-FOEPWRHM.mjs";
|
|
66
66
|
import "./chunk-GQVQESLY.mjs";
|
|
67
67
|
import {
|
|
68
68
|
api,
|
|
@@ -80,7 +80,7 @@ import "./chunk-RBRLLZL5.mjs";
|
|
|
80
80
|
import "./chunk-WZ5QFROO.mjs";
|
|
81
81
|
import "./chunk-7ZMKVETU.mjs";
|
|
82
82
|
import "./chunk-FXG2PS27.mjs";
|
|
83
|
-
import "./chunk-
|
|
83
|
+
import "./chunk-XLQVJDK2.mjs";
|
|
84
84
|
import "./chunk-CGILA3WO.mjs";
|
|
85
85
|
export {
|
|
86
86
|
APIClientError,
|
package/dist/index.cjs
CHANGED
|
@@ -15255,7 +15255,7 @@ var init_server3 = __esm({
|
|
|
15255
15255
|
var version;
|
|
15256
15256
|
var init_package = __esm({
|
|
15257
15257
|
"package.json"() {
|
|
15258
|
-
version = "0.1.0-beta.
|
|
15258
|
+
version = "0.1.0-beta.56";
|
|
15259
15259
|
}
|
|
15260
15260
|
});
|
|
15261
15261
|
|
|
@@ -40879,7 +40879,13 @@ function generateUniversalRouterStateProperties() {
|
|
|
40879
40879
|
} else {
|
|
40880
40880
|
window.history.pushState(nextState, "", url);
|
|
40881
40881
|
}
|
|
40882
|
-
|
|
40882
|
+
// Announce on the dedicated history channel; a synthetic popstate would
|
|
40883
|
+
// be treated as back/forward by the popstate listener below and trigger
|
|
40884
|
+
// a full navigation for a shallow page-state write. The bundled client
|
|
40885
|
+
// hooks subscribe to this event via subscribeHistoryChange.
|
|
40886
|
+
window.dispatchEvent(
|
|
40887
|
+
new CustomEvent("farm:historychange", { detail: { kind: "page-state" } }),
|
|
40888
|
+
);
|
|
40883
40889
|
},
|
|
40884
40890
|
|
|
40885
40891
|
registerScrollElement: function(key, element) {
|
|
@@ -47904,6 +47910,37 @@ var import_react11 = require("react");
|
|
|
47904
47910
|
|
|
47905
47911
|
// src/client/spa-router.ts
|
|
47906
47912
|
init_deferred();
|
|
47913
|
+
|
|
47914
|
+
// src/client/history-sync.ts
|
|
47915
|
+
var FARM_HISTORY_CHANGE_EVENT = "farm:historychange";
|
|
47916
|
+
function notifyHistoryChange(kind) {
|
|
47917
|
+
if (typeof window === "undefined") return;
|
|
47918
|
+
setTimeout(() => {
|
|
47919
|
+
if (kind === "url-search" && !getInstalledFarmSPARouter()) {
|
|
47920
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
47921
|
+
return;
|
|
47922
|
+
}
|
|
47923
|
+
window.dispatchEvent(
|
|
47924
|
+
new CustomEvent(FARM_HISTORY_CHANGE_EVENT, {
|
|
47925
|
+
detail: { kind }
|
|
47926
|
+
})
|
|
47927
|
+
);
|
|
47928
|
+
}, 0);
|
|
47929
|
+
}
|
|
47930
|
+
__name(notifyHistoryChange, "notifyHistoryChange");
|
|
47931
|
+
function subscribeHistoryChange(listener) {
|
|
47932
|
+
if (typeof window === "undefined") return () => {
|
|
47933
|
+
};
|
|
47934
|
+
window.addEventListener("popstate", listener);
|
|
47935
|
+
window.addEventListener(FARM_HISTORY_CHANGE_EVENT, listener);
|
|
47936
|
+
return () => {
|
|
47937
|
+
window.removeEventListener("popstate", listener);
|
|
47938
|
+
window.removeEventListener(FARM_HISTORY_CHANGE_EVENT, listener);
|
|
47939
|
+
};
|
|
47940
|
+
}
|
|
47941
|
+
__name(subscribeHistoryChange, "subscribeHistoryChange");
|
|
47942
|
+
|
|
47943
|
+
// src/client/spa-router.ts
|
|
47907
47944
|
init_deployment();
|
|
47908
47945
|
var FARM_PAGE_STATE_KEY = "__farmPageState";
|
|
47909
47946
|
var FARM_INTERCEPT_FROM_KEY = "__farmInterceptFrom";
|
|
@@ -47933,6 +47970,16 @@ var _SPARouter = class _SPARouter {
|
|
|
47933
47970
|
this.navigationListeners = /* @__PURE__ */ new Set();
|
|
47934
47971
|
this.navigationState = IDLE_NAVIGATION_STATE;
|
|
47935
47972
|
this.scrollElements = /* @__PURE__ */ new Map();
|
|
47973
|
+
this.onPopState = /* @__PURE__ */ __name((event) => {
|
|
47974
|
+
void this.handlePopState(event);
|
|
47975
|
+
}, "onPopState");
|
|
47976
|
+
this.onBeforeUnload = /* @__PURE__ */ __name((event) => {
|
|
47977
|
+
if (this.blockers.size > 0) {
|
|
47978
|
+
event.preventDefault();
|
|
47979
|
+
event.returnValue = "";
|
|
47980
|
+
}
|
|
47981
|
+
this.saveScrollPosition(window.location.pathname);
|
|
47982
|
+
}, "onBeforeUnload");
|
|
47936
47983
|
this.options = {
|
|
47937
47984
|
prefetchTimeout: options.prefetchTimeout ?? 100,
|
|
47938
47985
|
cacheMaxAge: options.cacheMaxAge ?? 3e4,
|
|
@@ -47942,16 +47989,16 @@ var _SPARouter = class _SPARouter {
|
|
|
47942
47989
|
deploymentId: options.deploymentId ?? readBrowserDeploymentId()
|
|
47943
47990
|
};
|
|
47944
47991
|
if (typeof window !== "undefined") {
|
|
47945
|
-
window.addEventListener("popstate", this.
|
|
47946
|
-
window.addEventListener("beforeunload",
|
|
47947
|
-
if (this.blockers.size > 0) {
|
|
47948
|
-
event.preventDefault();
|
|
47949
|
-
event.returnValue = "";
|
|
47950
|
-
}
|
|
47951
|
-
this.saveScrollPosition(window.location.pathname);
|
|
47952
|
-
});
|
|
47992
|
+
window.addEventListener("popstate", this.onPopState);
|
|
47993
|
+
window.addEventListener("beforeunload", this.onBeforeUnload);
|
|
47953
47994
|
}
|
|
47954
47995
|
}
|
|
47996
|
+
/** Remove global listeners. Intended for tests and teardown. */
|
|
47997
|
+
destroy() {
|
|
47998
|
+
if (typeof window === "undefined") return;
|
|
47999
|
+
window.removeEventListener("popstate", this.onPopState);
|
|
48000
|
+
window.removeEventListener("beforeunload", this.onBeforeUnload);
|
|
48001
|
+
}
|
|
47955
48002
|
/**
|
|
47956
48003
|
* Set the navigation handler that updates React
|
|
47957
48004
|
*/
|
|
@@ -48345,7 +48392,7 @@ var _SPARouter = class _SPARouter {
|
|
|
48345
48392
|
} else {
|
|
48346
48393
|
window.history.pushState(nextState, "", url);
|
|
48347
48394
|
}
|
|
48348
|
-
|
|
48395
|
+
notifyHistoryChange("page-state");
|
|
48349
48396
|
}
|
|
48350
48397
|
/**
|
|
48351
48398
|
* Save scroll position for a path
|
|
@@ -48414,11 +48461,16 @@ function dispatchDeploymentMismatch(error) {
|
|
|
48414
48461
|
window.dispatchEvent(new CustomEvent("farm:deployment-mismatch", { detail: error }));
|
|
48415
48462
|
}
|
|
48416
48463
|
__name(dispatchDeploymentMismatch, "dispatchDeploymentMismatch");
|
|
48464
|
+
function getInstalledFarmSPARouter() {
|
|
48465
|
+
if (typeof window === "undefined") return void 0;
|
|
48466
|
+
return window.__FARM_SPA_ROUTER__;
|
|
48467
|
+
}
|
|
48468
|
+
__name(getInstalledFarmSPARouter, "getInstalledFarmSPARouter");
|
|
48417
48469
|
function getRouter2() {
|
|
48418
48470
|
if (typeof window === "undefined") {
|
|
48419
48471
|
return new SPARouter();
|
|
48420
48472
|
}
|
|
48421
|
-
const installedRouter =
|
|
48473
|
+
const installedRouter = getInstalledFarmSPARouter();
|
|
48422
48474
|
if (installedRouter) {
|
|
48423
48475
|
routerInstance = installedRouter;
|
|
48424
48476
|
return installedRouter;
|
|
@@ -48488,6 +48540,22 @@ __name(getScrollElementStorageKey, "getScrollElementStorageKey");
|
|
|
48488
48540
|
|
|
48489
48541
|
// src/client/router.ts
|
|
48490
48542
|
init_routing();
|
|
48543
|
+
function navigateViaRouter(href, basePath, replace) {
|
|
48544
|
+
if (typeof window === "undefined") return;
|
|
48545
|
+
const url = href.startsWith("/") ? basePath + href : href;
|
|
48546
|
+
const spaRouter = getInstalledFarmSPARouter();
|
|
48547
|
+
if (spaRouter) {
|
|
48548
|
+
void spaRouter.navigate(url, { replace });
|
|
48549
|
+
return;
|
|
48550
|
+
}
|
|
48551
|
+
if (replace) {
|
|
48552
|
+
window.history.replaceState(null, "", url);
|
|
48553
|
+
} else {
|
|
48554
|
+
window.history.pushState(null, "", url);
|
|
48555
|
+
}
|
|
48556
|
+
notifyHistoryChange("url-search");
|
|
48557
|
+
}
|
|
48558
|
+
__name(navigateViaRouter, "navigateViaRouter");
|
|
48491
48559
|
function useRouter(options = {}) {
|
|
48492
48560
|
const basePath = options.basePath || "";
|
|
48493
48561
|
const routes = options.routes;
|
|
@@ -48505,20 +48573,14 @@ function useRouter(options = {}) {
|
|
|
48505
48573
|
setState(readRouterState(basePath, routeMatcher));
|
|
48506
48574
|
}, "handlePopState");
|
|
48507
48575
|
handlePopState();
|
|
48508
|
-
|
|
48509
|
-
return
|
|
48576
|
+
const unsubscribe = subscribeHistoryChange(handlePopState);
|
|
48577
|
+
return unsubscribe;
|
|
48510
48578
|
}, [basePath, routeMatcher]);
|
|
48511
48579
|
const push = /* @__PURE__ */ __name((href) => {
|
|
48512
|
-
|
|
48513
|
-
const url = href.startsWith("/") ? basePath + href : href;
|
|
48514
|
-
window.history.pushState(null, "", url);
|
|
48515
|
-
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
48580
|
+
navigateViaRouter(href, basePath, false);
|
|
48516
48581
|
}, "push");
|
|
48517
48582
|
const replace = /* @__PURE__ */ __name((href) => {
|
|
48518
|
-
|
|
48519
|
-
const url = href.startsWith("/") ? basePath + href : href;
|
|
48520
|
-
window.history.replaceState(null, "", url);
|
|
48521
|
-
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
48583
|
+
navigateViaRouter(href, basePath, true);
|
|
48522
48584
|
}, "replace");
|
|
48523
48585
|
const pushState2 = /* @__PURE__ */ __name((pageState, href) => {
|
|
48524
48586
|
if (typeof window === "undefined") return;
|
|
@@ -48557,8 +48619,7 @@ function usePageState() {
|
|
|
48557
48619
|
setState(readPageState());
|
|
48558
48620
|
}, "handlePopState");
|
|
48559
48621
|
handlePopState();
|
|
48560
|
-
|
|
48561
|
-
return () => window.removeEventListener("popstate", handlePopState);
|
|
48622
|
+
return subscribeHistoryChange(handlePopState);
|
|
48562
48623
|
}, []);
|
|
48563
48624
|
return state;
|
|
48564
48625
|
}
|