@farm.js/core 0.1.0-beta.55 → 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-YBHLSG7E.mjs → chunk-5T2XATMK.mjs} +22 -18
- package/dist/chunk-5T2XATMK.mjs.map +1 -0
- package/dist/{chunk-MSQDIAQW.mjs → chunk-FOEPWRHM.mjs} +2 -2
- package/dist/{chunk-ZP5IWDTE.mjs → chunk-FPLRESQA.mjs} +25 -14
- package/dist/chunk-FPLRESQA.mjs.map +1 -0
- package/dist/{chunk-OGFWHBDO.mjs → chunk-UH5R4J5M.mjs} +2 -2
- package/dist/{chunk-BLTATPSB.mjs → chunk-XLQVJDK2.mjs} +2 -2
- package/dist/{chunk-BLTATPSB.mjs.map → chunk-XLQVJDK2.mjs.map} +1 -1
- package/dist/{chunk-RAZ7L3UY.mjs → chunk-YPKCFGA7.mjs} +9 -3
- package/dist/chunk-YPKCFGA7.mjs.map +1 -0
- package/dist/{chunk-2ISN27CV.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 +51 -27
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.mts +0 -3
- package/dist/client.d.ts +0 -3
- package/dist/client.mjs +4 -4
- package/dist/index.cjs +60 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +7 -7
- 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 +49 -24
- package/dist/navigation.cjs.map +1 -1
- package/dist/navigation.mjs +3 -3
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.mjs +2 -2
- package/dist/query/client.cjs +28 -13
- package/dist/query/client.cjs.map +1 -1
- package/dist/query/client.mjs +8 -7
- package/dist/query/client.mjs.map +1 -1
- package/dist/renderer-client.cjs +32 -8
- package/dist/renderer-client.cjs.map +1 -1
- package/dist/renderer-client.mjs +5 -7
- 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/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-RAZ7L3UY.mjs.map +0 -1
- package/dist/chunk-YBHLSG7E.mjs.map +0 -1
- package/dist/chunk-ZP5IWDTE.mjs.map +0 -1
- /package/dist/{chunk-MSQDIAQW.mjs.map → chunk-FOEPWRHM.mjs.map} +0 -0
- /package/dist/{chunk-OGFWHBDO.mjs.map → chunk-UH5R4J5M.mjs.map} +0 -0
- /package/dist/{chunk-2ISN27CV.mjs.map → chunk-ZOQLQAUG.mjs.map} +0 -0
package/dist/client.d.mts
CHANGED
|
@@ -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
|
@@ -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
|
@@ -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";
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
pushState,
|
|
54
54
|
readPageState,
|
|
55
55
|
replaceState
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-5T2XATMK.mjs";
|
|
57
57
|
import "./chunk-ITN462YM.mjs";
|
|
58
58
|
import "./chunk-C4XSKA7P.mjs";
|
|
59
59
|
import "./chunk-SCFX4UTD.mjs";
|
|
@@ -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";
|
|
@@ -48355,7 +48392,7 @@ var _SPARouter = class _SPARouter {
|
|
|
48355
48392
|
} else {
|
|
48356
48393
|
window.history.pushState(nextState, "", url);
|
|
48357
48394
|
}
|
|
48358
|
-
|
|
48395
|
+
notifyHistoryChange("page-state");
|
|
48359
48396
|
}
|
|
48360
48397
|
/**
|
|
48361
48398
|
* Save scroll position for a path
|
|
@@ -48501,22 +48538,24 @@ function getScrollElementStorageKey(path38, key) {
|
|
|
48501
48538
|
}
|
|
48502
48539
|
__name(getScrollElementStorageKey, "getScrollElementStorageKey");
|
|
48503
48540
|
|
|
48504
|
-
// src/client/url-search-sync.ts
|
|
48505
|
-
var FARM_URL_SEARCH_CHANGE_EVENT = "farm:urlsearchchange";
|
|
48506
|
-
function subscribeUrlSearchObservers(listener) {
|
|
48507
|
-
if (typeof window === "undefined") return () => {
|
|
48508
|
-
};
|
|
48509
|
-
window.addEventListener("popstate", listener);
|
|
48510
|
-
window.addEventListener(FARM_URL_SEARCH_CHANGE_EVENT, listener);
|
|
48511
|
-
return () => {
|
|
48512
|
-
window.removeEventListener("popstate", listener);
|
|
48513
|
-
window.removeEventListener(FARM_URL_SEARCH_CHANGE_EVENT, listener);
|
|
48514
|
-
};
|
|
48515
|
-
}
|
|
48516
|
-
__name(subscribeUrlSearchObservers, "subscribeUrlSearchObservers");
|
|
48517
|
-
|
|
48518
48541
|
// src/client/router.ts
|
|
48519
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");
|
|
48520
48559
|
function useRouter(options = {}) {
|
|
48521
48560
|
const basePath = options.basePath || "";
|
|
48522
48561
|
const routes = options.routes;
|
|
@@ -48534,20 +48573,14 @@ function useRouter(options = {}) {
|
|
|
48534
48573
|
setState(readRouterState(basePath, routeMatcher));
|
|
48535
48574
|
}, "handlePopState");
|
|
48536
48575
|
handlePopState();
|
|
48537
|
-
const unsubscribe =
|
|
48576
|
+
const unsubscribe = subscribeHistoryChange(handlePopState);
|
|
48538
48577
|
return unsubscribe;
|
|
48539
48578
|
}, [basePath, routeMatcher]);
|
|
48540
48579
|
const push = /* @__PURE__ */ __name((href) => {
|
|
48541
|
-
|
|
48542
|
-
const url = href.startsWith("/") ? basePath + href : href;
|
|
48543
|
-
window.history.pushState(null, "", url);
|
|
48544
|
-
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
48580
|
+
navigateViaRouter(href, basePath, false);
|
|
48545
48581
|
}, "push");
|
|
48546
48582
|
const replace = /* @__PURE__ */ __name((href) => {
|
|
48547
|
-
|
|
48548
|
-
const url = href.startsWith("/") ? basePath + href : href;
|
|
48549
|
-
window.history.replaceState(null, "", url);
|
|
48550
|
-
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
48583
|
+
navigateViaRouter(href, basePath, true);
|
|
48551
48584
|
}, "replace");
|
|
48552
48585
|
const pushState2 = /* @__PURE__ */ __name((pageState, href) => {
|
|
48553
48586
|
if (typeof window === "undefined") return;
|
|
@@ -48586,8 +48619,7 @@ function usePageState() {
|
|
|
48586
48619
|
setState(readPageState());
|
|
48587
48620
|
}, "handlePopState");
|
|
48588
48621
|
handlePopState();
|
|
48589
|
-
|
|
48590
|
-
return () => window.removeEventListener("popstate", handlePopState);
|
|
48622
|
+
return subscribeHistoryChange(handlePopState);
|
|
48591
48623
|
}, []);
|
|
48592
48624
|
return state;
|
|
48593
48625
|
}
|