@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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createClientPluginManager,
|
|
3
3
|
installChunkErrorRecovery
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-FOEPWRHM.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-XLQVJDK2.mjs";
|
|
10
10
|
import {
|
|
11
11
|
__name
|
|
12
12
|
} from "../chunk-CGILA3WO.mjs";
|
package/dist/navigation.cjs
CHANGED
|
@@ -435,6 +435,35 @@ function rejectPendingDeferred(controllers, message) {
|
|
|
435
435
|
}
|
|
436
436
|
__name(rejectPendingDeferred, "rejectPendingDeferred");
|
|
437
437
|
|
|
438
|
+
// src/client/history-sync.ts
|
|
439
|
+
var FARM_HISTORY_CHANGE_EVENT = "farm:historychange";
|
|
440
|
+
function notifyHistoryChange(kind) {
|
|
441
|
+
if (typeof window === "undefined") return;
|
|
442
|
+
setTimeout(() => {
|
|
443
|
+
if (kind === "url-search" && !getInstalledFarmSPARouter()) {
|
|
444
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
window.dispatchEvent(
|
|
448
|
+
new CustomEvent(FARM_HISTORY_CHANGE_EVENT, {
|
|
449
|
+
detail: { kind }
|
|
450
|
+
})
|
|
451
|
+
);
|
|
452
|
+
}, 0);
|
|
453
|
+
}
|
|
454
|
+
__name(notifyHistoryChange, "notifyHistoryChange");
|
|
455
|
+
function subscribeHistoryChange(listener) {
|
|
456
|
+
if (typeof window === "undefined") return () => {
|
|
457
|
+
};
|
|
458
|
+
window.addEventListener("popstate", listener);
|
|
459
|
+
window.addEventListener(FARM_HISTORY_CHANGE_EVENT, listener);
|
|
460
|
+
return () => {
|
|
461
|
+
window.removeEventListener("popstate", listener);
|
|
462
|
+
window.removeEventListener(FARM_HISTORY_CHANGE_EVENT, listener);
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
__name(subscribeHistoryChange, "subscribeHistoryChange");
|
|
466
|
+
|
|
438
467
|
// src/deployment.ts
|
|
439
468
|
var FARM_DEPLOYMENT_ID_HEADER = "x-farm-deployment-id";
|
|
440
469
|
var FARM_DEPLOYMENT_MISMATCH_HEADER = "x-farm-deployment-mismatch";
|
|
@@ -1038,7 +1067,7 @@ var _SPARouter = class _SPARouter {
|
|
|
1038
1067
|
} else {
|
|
1039
1068
|
window.history.pushState(nextState, "", url);
|
|
1040
1069
|
}
|
|
1041
|
-
|
|
1070
|
+
notifyHistoryChange("page-state");
|
|
1042
1071
|
}
|
|
1043
1072
|
/**
|
|
1044
1073
|
* Save scroll position for a path
|
|
@@ -1168,21 +1197,23 @@ function getScrollElementStorageKey(path, key) {
|
|
|
1168
1197
|
}
|
|
1169
1198
|
__name(getScrollElementStorageKey, "getScrollElementStorageKey");
|
|
1170
1199
|
|
|
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
|
-
|
|
1185
1200
|
// src/client/router.ts
|
|
1201
|
+
function navigateViaRouter(href, basePath, replace) {
|
|
1202
|
+
if (typeof window === "undefined") return;
|
|
1203
|
+
const url = href.startsWith("/") ? basePath + href : href;
|
|
1204
|
+
const spaRouter = getInstalledFarmSPARouter();
|
|
1205
|
+
if (spaRouter) {
|
|
1206
|
+
void spaRouter.navigate(url, { replace });
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
if (replace) {
|
|
1210
|
+
window.history.replaceState(null, "", url);
|
|
1211
|
+
} else {
|
|
1212
|
+
window.history.pushState(null, "", url);
|
|
1213
|
+
}
|
|
1214
|
+
notifyHistoryChange("url-search");
|
|
1215
|
+
}
|
|
1216
|
+
__name(navigateViaRouter, "navigateViaRouter");
|
|
1186
1217
|
function useRouter(options = {}) {
|
|
1187
1218
|
const basePath = options.basePath || "";
|
|
1188
1219
|
const routes = options.routes;
|
|
@@ -1200,20 +1231,14 @@ function useRouter(options = {}) {
|
|
|
1200
1231
|
setState(readRouterState(basePath, routeMatcher));
|
|
1201
1232
|
}, "handlePopState");
|
|
1202
1233
|
handlePopState();
|
|
1203
|
-
const unsubscribe =
|
|
1234
|
+
const unsubscribe = subscribeHistoryChange(handlePopState);
|
|
1204
1235
|
return unsubscribe;
|
|
1205
1236
|
}, [basePath, routeMatcher]);
|
|
1206
1237
|
const push = /* @__PURE__ */ __name((href) => {
|
|
1207
|
-
|
|
1208
|
-
const url = href.startsWith("/") ? basePath + href : href;
|
|
1209
|
-
window.history.pushState(null, "", url);
|
|
1210
|
-
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
1238
|
+
navigateViaRouter(href, basePath, false);
|
|
1211
1239
|
}, "push");
|
|
1212
1240
|
const replace = /* @__PURE__ */ __name((href) => {
|
|
1213
|
-
|
|
1214
|
-
const url = href.startsWith("/") ? basePath + href : href;
|
|
1215
|
-
window.history.replaceState(null, "", url);
|
|
1216
|
-
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
1241
|
+
navigateViaRouter(href, basePath, true);
|
|
1217
1242
|
}, "replace");
|
|
1218
1243
|
const pushState = /* @__PURE__ */ __name((pageState, href) => {
|
|
1219
1244
|
if (typeof window === "undefined") return;
|