@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-plugins.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FarmClientPluginManager,
|
|
3
3
|
createClientPluginManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FOEPWRHM.mjs";
|
|
5
5
|
import "./chunk-FXG2PS27.mjs";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-XLQVJDK2.mjs";
|
|
7
7
|
import "./chunk-CGILA3WO.mjs";
|
|
8
8
|
export {
|
|
9
9
|
FarmClientPluginManager,
|
package/dist/client.cjs
CHANGED
|
@@ -4664,6 +4664,35 @@ function rejectPendingDeferred(controllers, message) {
|
|
|
4664
4664
|
}
|
|
4665
4665
|
__name(rejectPendingDeferred, "rejectPendingDeferred");
|
|
4666
4666
|
|
|
4667
|
+
// src/client/history-sync.ts
|
|
4668
|
+
var FARM_HISTORY_CHANGE_EVENT = "farm:historychange";
|
|
4669
|
+
function notifyHistoryChange(kind) {
|
|
4670
|
+
if (typeof window === "undefined") return;
|
|
4671
|
+
setTimeout(() => {
|
|
4672
|
+
if (kind === "url-search" && !getInstalledFarmSPARouter()) {
|
|
4673
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
4674
|
+
return;
|
|
4675
|
+
}
|
|
4676
|
+
window.dispatchEvent(
|
|
4677
|
+
new CustomEvent(FARM_HISTORY_CHANGE_EVENT, {
|
|
4678
|
+
detail: { kind }
|
|
4679
|
+
})
|
|
4680
|
+
);
|
|
4681
|
+
}, 0);
|
|
4682
|
+
}
|
|
4683
|
+
__name(notifyHistoryChange, "notifyHistoryChange");
|
|
4684
|
+
function subscribeHistoryChange(listener) {
|
|
4685
|
+
if (typeof window === "undefined") return () => {
|
|
4686
|
+
};
|
|
4687
|
+
window.addEventListener("popstate", listener);
|
|
4688
|
+
window.addEventListener(FARM_HISTORY_CHANGE_EVENT, listener);
|
|
4689
|
+
return () => {
|
|
4690
|
+
window.removeEventListener("popstate", listener);
|
|
4691
|
+
window.removeEventListener(FARM_HISTORY_CHANGE_EVENT, listener);
|
|
4692
|
+
};
|
|
4693
|
+
}
|
|
4694
|
+
__name(subscribeHistoryChange, "subscribeHistoryChange");
|
|
4695
|
+
|
|
4667
4696
|
// src/deployment.ts
|
|
4668
4697
|
var FARM_DEPLOYMENT_ID_HEADER = "x-farm-deployment-id";
|
|
4669
4698
|
var FARM_DEPLOYMENT_MISMATCH_HEADER = "x-farm-deployment-mismatch";
|
|
@@ -4738,6 +4767,16 @@ var _SPARouter = class _SPARouter {
|
|
|
4738
4767
|
this.navigationListeners = /* @__PURE__ */ new Set();
|
|
4739
4768
|
this.navigationState = IDLE_NAVIGATION_STATE;
|
|
4740
4769
|
this.scrollElements = /* @__PURE__ */ new Map();
|
|
4770
|
+
this.onPopState = /* @__PURE__ */ __name((event) => {
|
|
4771
|
+
void this.handlePopState(event);
|
|
4772
|
+
}, "onPopState");
|
|
4773
|
+
this.onBeforeUnload = /* @__PURE__ */ __name((event) => {
|
|
4774
|
+
if (this.blockers.size > 0) {
|
|
4775
|
+
event.preventDefault();
|
|
4776
|
+
event.returnValue = "";
|
|
4777
|
+
}
|
|
4778
|
+
this.saveScrollPosition(window.location.pathname);
|
|
4779
|
+
}, "onBeforeUnload");
|
|
4741
4780
|
this.options = {
|
|
4742
4781
|
prefetchTimeout: options.prefetchTimeout ?? 100,
|
|
4743
4782
|
cacheMaxAge: options.cacheMaxAge ?? 3e4,
|
|
@@ -4747,16 +4786,16 @@ var _SPARouter = class _SPARouter {
|
|
|
4747
4786
|
deploymentId: options.deploymentId ?? readBrowserDeploymentId()
|
|
4748
4787
|
};
|
|
4749
4788
|
if (typeof window !== "undefined") {
|
|
4750
|
-
window.addEventListener("popstate", this.
|
|
4751
|
-
window.addEventListener("beforeunload",
|
|
4752
|
-
if (this.blockers.size > 0) {
|
|
4753
|
-
event.preventDefault();
|
|
4754
|
-
event.returnValue = "";
|
|
4755
|
-
}
|
|
4756
|
-
this.saveScrollPosition(window.location.pathname);
|
|
4757
|
-
});
|
|
4789
|
+
window.addEventListener("popstate", this.onPopState);
|
|
4790
|
+
window.addEventListener("beforeunload", this.onBeforeUnload);
|
|
4758
4791
|
}
|
|
4759
4792
|
}
|
|
4793
|
+
/** Remove global listeners. Intended for tests and teardown. */
|
|
4794
|
+
destroy() {
|
|
4795
|
+
if (typeof window === "undefined") return;
|
|
4796
|
+
window.removeEventListener("popstate", this.onPopState);
|
|
4797
|
+
window.removeEventListener("beforeunload", this.onBeforeUnload);
|
|
4798
|
+
}
|
|
4760
4799
|
/**
|
|
4761
4800
|
* Set the navigation handler that updates React
|
|
4762
4801
|
*/
|
|
@@ -5150,7 +5189,7 @@ var _SPARouter = class _SPARouter {
|
|
|
5150
5189
|
} else {
|
|
5151
5190
|
window.history.pushState(nextState, "", url);
|
|
5152
5191
|
}
|
|
5153
|
-
|
|
5192
|
+
notifyHistoryChange("page-state");
|
|
5154
5193
|
}
|
|
5155
5194
|
/**
|
|
5156
5195
|
* Save scroll position for a path
|
|
@@ -5219,11 +5258,16 @@ function dispatchDeploymentMismatch(error) {
|
|
|
5219
5258
|
window.dispatchEvent(new CustomEvent("farm:deployment-mismatch", { detail: error }));
|
|
5220
5259
|
}
|
|
5221
5260
|
__name(dispatchDeploymentMismatch, "dispatchDeploymentMismatch");
|
|
5261
|
+
function getInstalledFarmSPARouter() {
|
|
5262
|
+
if (typeof window === "undefined") return void 0;
|
|
5263
|
+
return window.__FARM_SPA_ROUTER__;
|
|
5264
|
+
}
|
|
5265
|
+
__name(getInstalledFarmSPARouter, "getInstalledFarmSPARouter");
|
|
5222
5266
|
function getRouter2() {
|
|
5223
5267
|
if (typeof window === "undefined") {
|
|
5224
5268
|
return new SPARouter();
|
|
5225
5269
|
}
|
|
5226
|
-
const installedRouter =
|
|
5270
|
+
const installedRouter = getInstalledFarmSPARouter();
|
|
5227
5271
|
if (installedRouter) {
|
|
5228
5272
|
routerInstance = installedRouter;
|
|
5229
5273
|
return installedRouter;
|
|
@@ -5292,6 +5336,22 @@ function getScrollElementStorageKey(path, key) {
|
|
|
5292
5336
|
__name(getScrollElementStorageKey, "getScrollElementStorageKey");
|
|
5293
5337
|
|
|
5294
5338
|
// src/client/router.ts
|
|
5339
|
+
function navigateViaRouter(href, basePath, replace) {
|
|
5340
|
+
if (typeof window === "undefined") return;
|
|
5341
|
+
const url = href.startsWith("/") ? basePath + href : href;
|
|
5342
|
+
const spaRouter = getInstalledFarmSPARouter();
|
|
5343
|
+
if (spaRouter) {
|
|
5344
|
+
void spaRouter.navigate(url, { replace });
|
|
5345
|
+
return;
|
|
5346
|
+
}
|
|
5347
|
+
if (replace) {
|
|
5348
|
+
window.history.replaceState(null, "", url);
|
|
5349
|
+
} else {
|
|
5350
|
+
window.history.pushState(null, "", url);
|
|
5351
|
+
}
|
|
5352
|
+
notifyHistoryChange("url-search");
|
|
5353
|
+
}
|
|
5354
|
+
__name(navigateViaRouter, "navigateViaRouter");
|
|
5295
5355
|
function useRouter(options = {}) {
|
|
5296
5356
|
const basePath = options.basePath || "";
|
|
5297
5357
|
const routes = options.routes;
|
|
@@ -5309,20 +5369,14 @@ function useRouter(options = {}) {
|
|
|
5309
5369
|
setState(readRouterState(basePath, routeMatcher));
|
|
5310
5370
|
}, "handlePopState");
|
|
5311
5371
|
handlePopState();
|
|
5312
|
-
|
|
5313
|
-
return
|
|
5372
|
+
const unsubscribe = subscribeHistoryChange(handlePopState);
|
|
5373
|
+
return unsubscribe;
|
|
5314
5374
|
}, [basePath, routeMatcher]);
|
|
5315
5375
|
const push = /* @__PURE__ */ __name((href) => {
|
|
5316
|
-
|
|
5317
|
-
const url = href.startsWith("/") ? basePath + href : href;
|
|
5318
|
-
window.history.pushState(null, "", url);
|
|
5319
|
-
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
5376
|
+
navigateViaRouter(href, basePath, false);
|
|
5320
5377
|
}, "push");
|
|
5321
5378
|
const replace = /* @__PURE__ */ __name((href) => {
|
|
5322
|
-
|
|
5323
|
-
const url = href.startsWith("/") ? basePath + href : href;
|
|
5324
|
-
window.history.replaceState(null, "", url);
|
|
5325
|
-
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
5379
|
+
navigateViaRouter(href, basePath, true);
|
|
5326
5380
|
}, "replace");
|
|
5327
5381
|
const pushState2 = /* @__PURE__ */ __name((pageState, href) => {
|
|
5328
5382
|
if (typeof window === "undefined") return;
|
|
@@ -5361,8 +5415,7 @@ function usePageState() {
|
|
|
5361
5415
|
setState(readPageState());
|
|
5362
5416
|
}, "handlePopState");
|
|
5363
5417
|
handlePopState();
|
|
5364
|
-
|
|
5365
|
-
return () => window.removeEventListener("popstate", handlePopState);
|
|
5418
|
+
return subscribeHistoryChange(handlePopState);
|
|
5366
5419
|
}, []);
|
|
5367
5420
|
return state;
|
|
5368
5421
|
}
|
|
@@ -6049,7 +6102,7 @@ body {
|
|
|
6049
6102
|
`;
|
|
6050
6103
|
|
|
6051
6104
|
// package.json
|
|
6052
|
-
var version = "0.1.0-beta.
|
|
6105
|
+
var version = "0.1.0-beta.56";
|
|
6053
6106
|
|
|
6054
6107
|
// src/version.ts
|
|
6055
6108
|
var FARM_VERSION = version;
|