@farm.js/core 0.1.0-beta.0 → 0.1.0-beta.3
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/README.md +1 -1
- package/dist/agent-runtime.d.mts +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/api/route-manager.cjs +97 -5
- package/dist/api/route-manager.cjs.map +1 -1
- package/dist/api/route-manager.d.mts +3 -2
- package/dist/api/route-manager.d.ts +3 -2
- package/dist/api/route-manager.mjs +8 -8
- package/dist/api/runtime.cjs +441 -5
- package/dist/api/runtime.cjs.map +1 -1
- package/dist/api/runtime.d.mts +2 -16
- package/dist/api/runtime.d.ts +2 -16
- package/dist/api/runtime.mjs +7 -1
- package/dist/api.cjs +579 -263
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.mts +4 -147
- package/dist/api.d.ts +4 -147
- package/dist/api.mjs +30 -20
- package/dist/{app-BiX4qb-d.d.mts → app-BB3Iu3xh.d.mts} +2 -2
- package/dist/{app-CFRNJXP1.d.ts → app-DOKxo-LH.d.ts} +2 -2
- package/dist/app-markdown.cjs +1 -1
- package/dist/app-markdown.cjs.map +1 -1
- package/dist/app-markdown.d.mts +1 -1
- package/dist/app-markdown.d.ts +1 -1
- package/dist/app-markdown.mjs +1 -1
- package/dist/cache.cjs +19 -0
- package/dist/cache.cjs.map +1 -1
- package/dist/cache.d.mts +21 -1
- package/dist/cache.d.ts +21 -1
- package/dist/cache.mjs +5 -3
- package/dist/{chunk-QF4PHCMA.mjs → chunk-2ED5Q2GH.mjs} +3 -3
- package/dist/chunk-2ED5Q2GH.mjs.map +1 -0
- package/dist/{chunk-GZP5W4K3.mjs → chunk-32W4QEJP.mjs} +1 -1
- package/dist/chunk-32W4QEJP.mjs.map +1 -0
- package/dist/{chunk-AGS7UJ52.mjs → chunk-45LKHSHJ.mjs} +2 -2
- package/dist/{chunk-TU4YJICB.mjs → chunk-5FW6PQ3J.mjs} +1 -1
- package/dist/{chunk-TU4YJICB.mjs.map → chunk-5FW6PQ3J.mjs.map} +1 -1
- package/dist/{chunk-TRORP7E4.mjs → chunk-5QH4IKY3.mjs} +2 -2
- package/dist/{chunk-RKI6TN3A.mjs → chunk-6VS6CKAV.mjs} +2 -2
- package/dist/chunk-6VS6CKAV.mjs.map +1 -0
- package/dist/{chunk-25D7G34K.mjs → chunk-6WXJ54TC.mjs} +4 -4
- package/dist/{chunk-3QJO55ZF.mjs → chunk-BIOIOWXZ.mjs} +5 -3
- package/dist/{chunk-3QJO55ZF.mjs.map → chunk-BIOIOWXZ.mjs.map} +1 -1
- package/dist/{chunk-QFQRHRZS.mjs → chunk-C33RALN7.mjs} +75 -11
- package/dist/chunk-C33RALN7.mjs.map +1 -0
- package/dist/{chunk-B6N4ZB2H.mjs → chunk-CSU4KJJF.mjs} +3 -3
- package/dist/{chunk-JN3UU635.mjs → chunk-EJ7T4TPB.mjs} +2 -2
- package/dist/chunk-EJ7T4TPB.mjs.map +1 -0
- package/dist/{chunk-ZJQNATYV.mjs → chunk-FRPWCMMG.mjs} +3 -3
- package/dist/chunk-FRPWCMMG.mjs.map +1 -0
- package/dist/{chunk-PRNYWD7K.mjs → chunk-G5I34UA6.mjs} +67 -239
- package/dist/chunk-G5I34UA6.mjs.map +1 -0
- package/dist/{chunk-QM6VV26B.mjs → chunk-GQVGIUSN.mjs} +3 -3
- package/dist/{chunk-QM6VV26B.mjs.map → chunk-GQVGIUSN.mjs.map} +1 -1
- package/dist/{chunk-UREJA4GZ.mjs → chunk-GXASWWJU.mjs} +1 -1
- package/dist/{chunk-UREJA4GZ.mjs.map → chunk-GXASWWJU.mjs.map} +1 -1
- package/dist/{chunk-4PTK6KT4.mjs → chunk-GZWT6VI5.mjs} +22 -4
- package/dist/chunk-GZWT6VI5.mjs.map +1 -0
- package/dist/{chunk-JLWMCADZ.mjs → chunk-HZYXGV4K.mjs} +2 -2
- package/dist/chunk-JNYVN7YP.mjs +10 -0
- package/dist/chunk-JNYVN7YP.mjs.map +1 -0
- package/dist/{chunk-YHU7SS6L.mjs → chunk-LG3YINQN.mjs} +11 -11
- package/dist/chunk-LWMGIEJA.mjs +593 -0
- package/dist/chunk-LWMGIEJA.mjs.map +1 -0
- package/dist/{chunk-HXP3ZSPC.mjs → chunk-MH6FKW2I.mjs} +3 -3
- package/dist/{chunk-O3HADRW6.mjs → chunk-MIUW47JX.mjs} +2 -2
- package/dist/{chunk-O3HADRW6.mjs.map → chunk-MIUW47JX.mjs.map} +1 -1
- package/dist/{chunk-6XDUHOEM.mjs → chunk-NRRFGX45.mjs} +3 -3
- package/dist/{chunk-G3B5BRDY.mjs → chunk-OHC6VCDI.mjs} +24 -25
- package/dist/{chunk-G3B5BRDY.mjs.map → chunk-OHC6VCDI.mjs.map} +1 -1
- package/dist/{chunk-S2XHZS7W.mjs → chunk-QGQX7SFC.mjs} +2 -2
- package/dist/chunk-QGQX7SFC.mjs.map +1 -0
- package/dist/{chunk-TXCFGOHW.mjs → chunk-SHRJG6OG.mjs} +25 -1
- package/dist/chunk-SHRJG6OG.mjs.map +1 -0
- package/dist/{chunk-UHE2TTLK.mjs → chunk-T543TMFY.mjs} +8 -8
- package/dist/chunk-T543TMFY.mjs.map +1 -0
- package/dist/{chunk-SXZTEK3V.mjs → chunk-UXUAWNO5.mjs} +2 -2
- package/dist/{chunk-Y2OJJD7R.mjs → chunk-XIVV5IWN.mjs} +7 -9
- package/dist/chunk-XIVV5IWN.mjs.map +1 -0
- package/dist/{chunk-CHFHNEMO.mjs → chunk-XJSHJN4M.mjs} +41 -42
- package/dist/chunk-XJSHJN4M.mjs.map +1 -0
- package/dist/{chunk-Y7A27276.mjs → chunk-XUBZ7JI4.mjs} +178 -15
- package/dist/chunk-XUBZ7JI4.mjs.map +1 -0
- package/dist/{chunk-OYXO65LI.mjs → chunk-YW7OBE6Q.mjs} +4 -4
- package/dist/chunk-YW7OBE6Q.mjs.map +1 -0
- package/dist/{chunk-SOU3Q3ZA.mjs → chunk-ZZ57EH5Z.mjs} +1 -1
- package/dist/chunk-ZZ57EH5Z.mjs.map +1 -0
- package/dist/{client-D_yUjVhe.d.mts → client-DiViK9yK.d.mts} +33 -7
- package/dist/{client-Dkc03WP8.d.ts → client-DpEBJbts.d.ts} +33 -7
- package/dist/{client-plugins-BZnpeTGA.d.ts → client-plugins-CTnsZz_A.d.ts} +1 -0
- package/dist/{client-plugins-g4bzuCmo.d.mts → client-plugins-Cnr0D3kk.d.mts} +1 -0
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.cjs +302 -54
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.mts +54 -2
- package/dist/client.d.ts +54 -2
- package/dist/client.mjs +20 -16
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.mjs +1 -1
- package/dist/{devtools-AE4RVXCM.mjs → devtools-HE4FTUDN.mjs} +10 -10
- package/dist/{devtools-client-6WPY2AQU.mjs → devtools-client-3XRTBND5.mjs} +2 -11
- package/dist/devtools-client-3XRTBND5.mjs.map +1 -0
- package/dist/docs.cjs +3 -1
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.mjs +10 -10
- package/dist/i18n/server.cjs +2 -2
- package/dist/i18n/server.cjs.map +1 -1
- package/dist/i18n/server.mjs +1 -1
- package/dist/index.cjs +791 -317
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.mjs +125 -110
- package/dist/index.mjs.map +1 -1
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/internal/build-runtime.cjs +162 -60
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +26 -25
- package/dist/internal/client-runtime.cjs.map +1 -1
- package/dist/internal/client-runtime.mjs +1 -1
- package/dist/internal/config-runtime.cjs +1 -1
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +2 -2
- package/dist/internal/config-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.mjs +9 -9
- package/dist/internal/production-runtime.cjs +3 -3
- package/dist/internal/production-runtime.cjs.map +1 -1
- package/dist/internal/production-runtime.d.mts +3 -3
- package/dist/internal/production-runtime.d.ts +3 -3
- package/dist/internal/production-runtime.mjs +8 -8
- package/dist/{metadata-C9NZxMDW.d.mts → metadata-Dp8AdvsB.d.mts} +1 -1
- package/dist/{metadata-DAXRaOHx.d.ts → metadata-eoVmHoyv.d.ts} +1 -1
- package/dist/middleware.cjs +2 -2
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.mts +3 -3
- package/dist/middleware.d.ts +3 -3
- package/dist/middleware.mjs +3 -3
- package/dist/navigation.cjs.map +1 -1
- package/dist/navigation.mjs +3 -3
- package/dist/{nitro-KME62MWG.mjs → nitro-QO5LV6QK.mjs} +11 -13
- package/dist/{nitro-KME62MWG.mjs.map → nitro-QO5LV6QK.mjs.map} +1 -1
- package/dist/plugin.cjs +119 -39
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.mjs +22 -21
- package/dist/{production-runtime-DRkCHUvJ.d.ts → production-runtime-BqTnUTai.d.ts} +1 -1
- package/dist/{production-runtime-flrjp_nC.d.mts → production-runtime-DtDdG9fc.d.mts} +1 -1
- package/dist/routes.cjs.map +1 -1
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/routes.mjs +4 -4
- package/dist/runtime-C1B7pSGT.d.mts +207 -0
- package/dist/runtime-CdPHt0bv.d.ts +207 -0
- package/dist/server-action-security.cjs.map +1 -1
- package/dist/server-action-security.mjs +2 -2
- package/dist/server-fn-client.cjs.map +1 -1
- package/dist/server-fn-client.mjs +1 -1
- package/dist/server-fn.cjs.map +1 -1
- package/dist/server-fn.mjs +3 -3
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server-query-client.cjs.map +1 -1
- package/dist/server-query-client.mjs +4 -4
- package/dist/server-query.cjs.map +1 -1
- package/dist/server-query.mjs +5 -5
- package/dist/server.cjs +148 -43
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +6 -6
- package/dist/server.d.ts +6 -6
- package/dist/server.mjs +36 -31
- package/dist/server.mjs.map +1 -1
- package/dist/testing.cjs +95 -5
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.mts +3 -3
- package/dist/testing.d.ts +3 -3
- package/dist/testing.mjs +18 -18
- package/dist/{utils-DOXXivjL.d.mts → utils-8USa5BiY.d.mts} +1 -1
- package/dist/{utils-DA1yo54_.d.ts → utils-DKJb6K6G.d.ts} +1 -1
- package/dist/version.cjs +36 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.d.mts +3 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.mjs +8 -0
- package/dist/version.mjs.map +1 -0
- package/dist/vite.cjs +126 -40
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.mjs +22 -21
- package/dist/workflows.cjs +6 -8
- package/dist/workflows.cjs.map +1 -1
- package/dist/workflows.mjs +1 -1
- package/package.json +12 -5
- package/types/client.d.ts +136 -13
- package/dist/chunk-4PTK6KT4.mjs.map +0 -1
- package/dist/chunk-CHFHNEMO.mjs.map +0 -1
- package/dist/chunk-EVGBEZDF.mjs +0 -215
- package/dist/chunk-EVGBEZDF.mjs.map +0 -1
- package/dist/chunk-GZP5W4K3.mjs.map +0 -1
- package/dist/chunk-JN3UU635.mjs.map +0 -1
- package/dist/chunk-OYXO65LI.mjs.map +0 -1
- package/dist/chunk-PRNYWD7K.mjs.map +0 -1
- package/dist/chunk-QF4PHCMA.mjs.map +0 -1
- package/dist/chunk-QFQRHRZS.mjs.map +0 -1
- package/dist/chunk-RKI6TN3A.mjs.map +0 -1
- package/dist/chunk-S2XHZS7W.mjs.map +0 -1
- package/dist/chunk-SOU3Q3ZA.mjs.map +0 -1
- package/dist/chunk-TXCFGOHW.mjs.map +0 -1
- package/dist/chunk-UHE2TTLK.mjs.map +0 -1
- package/dist/chunk-Y2OJJD7R.mjs.map +0 -1
- package/dist/chunk-Y7A27276.mjs.map +0 -1
- package/dist/chunk-ZJQNATYV.mjs.map +0 -1
- package/dist/devtools-client-6WPY2AQU.mjs.map +0 -1
- /package/dist/{chunk-AGS7UJ52.mjs.map → chunk-45LKHSHJ.mjs.map} +0 -0
- /package/dist/{chunk-TRORP7E4.mjs.map → chunk-5QH4IKY3.mjs.map} +0 -0
- /package/dist/{chunk-25D7G34K.mjs.map → chunk-6WXJ54TC.mjs.map} +0 -0
- /package/dist/{chunk-B6N4ZB2H.mjs.map → chunk-CSU4KJJF.mjs.map} +0 -0
- /package/dist/{chunk-JLWMCADZ.mjs.map → chunk-HZYXGV4K.mjs.map} +0 -0
- /package/dist/{chunk-YHU7SS6L.mjs.map → chunk-LG3YINQN.mjs.map} +0 -0
- /package/dist/{chunk-HXP3ZSPC.mjs.map → chunk-MH6FKW2I.mjs.map} +0 -0
- /package/dist/{chunk-6XDUHOEM.mjs.map → chunk-NRRFGX45.mjs.map} +0 -0
- /package/dist/{chunk-SXZTEK3V.mjs.map → chunk-UXUAWNO5.mjs.map} +0 -0
- /package/dist/{devtools-AE4RVXCM.mjs.map → devtools-HE4FTUDN.mjs.map} +0 -0
package/dist/client.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/client.ts
|
|
32
32
|
var client_exports = {};
|
|
33
33
|
__export(client_exports, {
|
|
34
|
+
APIClientError: () => APIClientError,
|
|
34
35
|
FarmClientPluginManager: () => FarmClientPluginManager,
|
|
35
36
|
IntegrationClientError: () => IntegrationClientError,
|
|
36
37
|
Link: () => Link,
|
|
@@ -63,6 +64,7 @@ __export(client_exports, {
|
|
|
63
64
|
readPageState: () => readPageState,
|
|
64
65
|
replaceState: () => replaceState,
|
|
65
66
|
useBlocker: () => useBlocker,
|
|
67
|
+
useMutation: () => useMutation,
|
|
66
68
|
useNavigation: () => useNavigation,
|
|
67
69
|
usePageState: () => usePageState,
|
|
68
70
|
useRouter: () => useRouter,
|
|
@@ -180,7 +182,7 @@ function mergeIntegrationClientData(...values) {
|
|
|
180
182
|
continue;
|
|
181
183
|
}
|
|
182
184
|
merged = {
|
|
183
|
-
...merged
|
|
185
|
+
...merged,
|
|
184
186
|
...data
|
|
185
187
|
};
|
|
186
188
|
}
|
|
@@ -981,6 +983,7 @@ function formatError(error) {
|
|
|
981
983
|
__name(formatError, "formatError");
|
|
982
984
|
|
|
983
985
|
// src/cache-invalidation.ts
|
|
986
|
+
var FARM_CACHE_INVALIDATION_HEADER = "x-farm-cache-invalidations";
|
|
984
987
|
var FARM_CACHE_INVALIDATION_STATE = /* @__PURE__ */ Symbol.for("farm.cacheInvalidationState");
|
|
985
988
|
var globalState = globalThis;
|
|
986
989
|
function getFarmCacheInvalidationState() {
|
|
@@ -989,6 +992,34 @@ function getFarmCacheInvalidationState() {
|
|
|
989
992
|
});
|
|
990
993
|
}
|
|
991
994
|
__name(getFarmCacheInvalidationState, "getFarmCacheInvalidationState");
|
|
995
|
+
function notifyFarmCacheInvalidation(key) {
|
|
996
|
+
if (typeof key !== "string" || key.length === 0) return;
|
|
997
|
+
for (const listener of getFarmCacheInvalidationState().listeners) {
|
|
998
|
+
listener(key);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
__name(notifyFarmCacheInvalidation, "notifyFarmCacheInvalidation");
|
|
1002
|
+
function applyFarmCacheInvalidations(keys) {
|
|
1003
|
+
if (!Array.isArray(keys)) return;
|
|
1004
|
+
for (const key of keys) {
|
|
1005
|
+
if (typeof key === "string") {
|
|
1006
|
+
notifyFarmCacheInvalidation(key);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
__name(applyFarmCacheInvalidations, "applyFarmCacheInvalidations");
|
|
1011
|
+
function decodeFarmCacheInvalidations(value) {
|
|
1012
|
+
if (!value) return [];
|
|
1013
|
+
try {
|
|
1014
|
+
const parsed = JSON.parse(decodeURIComponent(value));
|
|
1015
|
+
return Array.isArray(parsed) ? Array.from(
|
|
1016
|
+
new Set(parsed.filter((key) => typeof key === "string" && key.length > 0))
|
|
1017
|
+
) : [];
|
|
1018
|
+
} catch {
|
|
1019
|
+
return [];
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
__name(decodeFarmCacheInvalidations, "decodeFarmCacheInvalidations");
|
|
992
1023
|
function subscribeFarmCacheInvalidation(listener) {
|
|
993
1024
|
const state = getFarmCacheInvalidationState();
|
|
994
1025
|
state.listeners.add(listener);
|
|
@@ -1437,6 +1468,19 @@ function normalizeFarmClientCacheKey(key) {
|
|
|
1437
1468
|
__name(normalizeFarmClientCacheKey, "normalizeFarmClientCacheKey");
|
|
1438
1469
|
|
|
1439
1470
|
// src/api/client.ts
|
|
1471
|
+
var FARM_API_ROUTE_REF_SYMBOL = /* @__PURE__ */ Symbol.for("farm.api.route-ref");
|
|
1472
|
+
var _APIClientError = class _APIClientError extends Error {
|
|
1473
|
+
constructor(code, data, options) {
|
|
1474
|
+
super(options.message);
|
|
1475
|
+
this.name = "APIClientError";
|
|
1476
|
+
this.code = code;
|
|
1477
|
+
this.data = data;
|
|
1478
|
+
this.status = options.status;
|
|
1479
|
+
this.response = options.response;
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
__name(_APIClientError, "APIClientError");
|
|
1483
|
+
var APIClientError = _APIClientError;
|
|
1440
1484
|
function createAPIClient(options = {}) {
|
|
1441
1485
|
options ?? (options = {});
|
|
1442
1486
|
const baseURL = options.baseURL || (typeof window !== "undefined" ? window.location.origin : "http://localhost:3000");
|
|
@@ -1474,6 +1518,9 @@ function createAPIClient(options = {}) {
|
|
|
1474
1518
|
fetchOptions.body = JSON.stringify(requestOptions.body);
|
|
1475
1519
|
}
|
|
1476
1520
|
const response = await fetch(url.toString(), fetchOptions);
|
|
1521
|
+
applyFarmCacheInvalidations(
|
|
1522
|
+
decodeFarmCacheInvalidations(response.headers?.get?.(FARM_CACHE_INVALIDATION_HEADER))
|
|
1523
|
+
);
|
|
1477
1524
|
let data = void 0;
|
|
1478
1525
|
if (response.status !== 204 && response.status !== 205) {
|
|
1479
1526
|
data = await response.json();
|
|
@@ -1713,9 +1760,15 @@ function createNestedProxy(path, client, routeMeta, baseURL, rootAliases) {
|
|
|
1713
1760
|
const proxy = new Proxy(target, {
|
|
1714
1761
|
// When accessing a property (api.hello)
|
|
1715
1762
|
get(_target, prop) {
|
|
1763
|
+
if (prop === FARM_API_ROUTE_REF_SYMBOL) {
|
|
1764
|
+
return path.length > 0;
|
|
1765
|
+
}
|
|
1716
1766
|
if (path.length === 0 && typeof prop === "string" && rootAliases && prop in rootAliases) {
|
|
1717
1767
|
return rootAliases[prop];
|
|
1718
1768
|
}
|
|
1769
|
+
if (typeof prop !== "string") {
|
|
1770
|
+
return Reflect.get(_target, prop);
|
|
1771
|
+
}
|
|
1719
1772
|
return createNestedProxy([...path, prop], client, routeMeta, baseURL, rootAliases);
|
|
1720
1773
|
},
|
|
1721
1774
|
// When calling as a function
|
|
@@ -1738,6 +1791,10 @@ function createNestedProxy(path, client, routeMeta, baseURL, rootAliases) {
|
|
|
1738
1791
|
return proxy;
|
|
1739
1792
|
}
|
|
1740
1793
|
__name(createNestedProxy, "createNestedProxy");
|
|
1794
|
+
function isAPIRouteRef(value) {
|
|
1795
|
+
return typeof value === "function" && value[FARM_API_ROUTE_REF_SYMBOL] === true;
|
|
1796
|
+
}
|
|
1797
|
+
__name(isAPIRouteRef, "isAPIRouteRef");
|
|
1741
1798
|
function createServerAPIClient(endpoints, options = {}) {
|
|
1742
1799
|
if (options.integrations === false || Object.prototype.hasOwnProperty.call(endpoints, "integrations")) {
|
|
1743
1800
|
return endpoints;
|
|
@@ -1804,7 +1861,10 @@ function resolveTargetKey(routeMeta, target, input, baseURL = "http://localhost:
|
|
|
1804
1861
|
}
|
|
1805
1862
|
if (Array.isArray(target)) {
|
|
1806
1863
|
const [route2, routeInput] = target;
|
|
1807
|
-
|
|
1864
|
+
if (typeof route2 === "function") {
|
|
1865
|
+
return resolveTargetKey(routeMeta, route2, routeInput, baseURL);
|
|
1866
|
+
}
|
|
1867
|
+
return normalizeFarmClientCacheKey(target);
|
|
1808
1868
|
}
|
|
1809
1869
|
if ("key" in target) return normalizeFarmClientCacheKey(target.key);
|
|
1810
1870
|
if ("path" in target) {
|
|
@@ -1830,21 +1890,207 @@ function resolveRouteMeta(meta) {
|
|
|
1830
1890
|
}
|
|
1831
1891
|
__name(resolveRouteMeta, "resolveRouteMeta");
|
|
1832
1892
|
function normalizeError(error) {
|
|
1833
|
-
if (error instanceof
|
|
1834
|
-
|
|
1893
|
+
if (error instanceof APIClientError) return error;
|
|
1894
|
+
const normalized = new APIClientError("network_error", void 0, {
|
|
1895
|
+
status: 0,
|
|
1896
|
+
message: error instanceof Error ? error.message : typeof error === "string" ? error : "Network request failed"
|
|
1897
|
+
});
|
|
1898
|
+
normalized.cause = error;
|
|
1899
|
+
return normalized;
|
|
1835
1900
|
}
|
|
1836
1901
|
__name(normalizeError, "normalizeError");
|
|
1837
1902
|
function createResponseError2(response, data) {
|
|
1838
|
-
const
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1903
|
+
const expected = readEndpointErrorEnvelope(data);
|
|
1904
|
+
if (expected) {
|
|
1905
|
+
return new APIClientError(expected.code, expected.data, {
|
|
1906
|
+
status: response.status,
|
|
1907
|
+
message: expected.message,
|
|
1908
|
+
response
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
return new APIClientError("http_error", data, {
|
|
1912
|
+
status: response.status,
|
|
1913
|
+
message: `HTTP ${response.status}: ${response.statusText}`,
|
|
1914
|
+
response
|
|
1915
|
+
});
|
|
1843
1916
|
}
|
|
1844
1917
|
__name(createResponseError2, "createResponseError");
|
|
1918
|
+
function readEndpointErrorEnvelope(data) {
|
|
1919
|
+
if (!data || typeof data !== "object") return null;
|
|
1920
|
+
const error = data.error;
|
|
1921
|
+
if (!error || typeof error !== "object") return null;
|
|
1922
|
+
const code = error.code;
|
|
1923
|
+
const message = error.message;
|
|
1924
|
+
if (typeof code !== "string" || typeof message !== "string") return null;
|
|
1925
|
+
return {
|
|
1926
|
+
code,
|
|
1927
|
+
message,
|
|
1928
|
+
data: error.data
|
|
1929
|
+
};
|
|
1930
|
+
}
|
|
1931
|
+
__name(readEndpointErrorEnvelope, "readEndpointErrorEnvelope");
|
|
1845
1932
|
|
|
1846
|
-
// src/
|
|
1933
|
+
// src/mutation-client.ts
|
|
1847
1934
|
var import_react = require("react");
|
|
1935
|
+
function useMutation(target, options = {}) {
|
|
1936
|
+
const initialData = options.initialData ?? null;
|
|
1937
|
+
const optionsRef = (0, import_react.useRef)(options);
|
|
1938
|
+
const targetRef = (0, import_react.useRef)(target);
|
|
1939
|
+
const requestIdRef = (0, import_react.useRef)(0);
|
|
1940
|
+
const initialState = {
|
|
1941
|
+
pendingCount: 0,
|
|
1942
|
+
status: "idle",
|
|
1943
|
+
data: initialData,
|
|
1944
|
+
error: null,
|
|
1945
|
+
variables: void 0
|
|
1946
|
+
};
|
|
1947
|
+
const stateRef = (0, import_react.useRef)(initialState);
|
|
1948
|
+
const [state, setState] = (0, import_react.useState)(initialState);
|
|
1949
|
+
optionsRef.current = options;
|
|
1950
|
+
targetRef.current = target;
|
|
1951
|
+
const setMutationState = (0, import_react.useCallback)(
|
|
1952
|
+
(value) => {
|
|
1953
|
+
setState((current) => {
|
|
1954
|
+
const next = typeof value === "function" ? value(current) : value;
|
|
1955
|
+
stateRef.current = next;
|
|
1956
|
+
return next;
|
|
1957
|
+
});
|
|
1958
|
+
},
|
|
1959
|
+
[]
|
|
1960
|
+
);
|
|
1961
|
+
const mutateAsync = (0, import_react.useCallback)(
|
|
1962
|
+
async (variables) => {
|
|
1963
|
+
const requestId = ++requestIdRef.current;
|
|
1964
|
+
const currentOptions = optionsRef.current;
|
|
1965
|
+
const previousData = stateRef.current.data;
|
|
1966
|
+
const optimisticData = currentOptions.optimistic?.({
|
|
1967
|
+
variables,
|
|
1968
|
+
current: previousData
|
|
1969
|
+
});
|
|
1970
|
+
const hasOptimisticData = optimisticData !== void 0;
|
|
1971
|
+
setMutationState((current) => ({
|
|
1972
|
+
pendingCount: current.pendingCount + 1,
|
|
1973
|
+
status: "pending",
|
|
1974
|
+
data: hasOptimisticData ? optimisticData : currentOptions.resetOnMutate === false ? current.data : null,
|
|
1975
|
+
error: null,
|
|
1976
|
+
variables
|
|
1977
|
+
}));
|
|
1978
|
+
try {
|
|
1979
|
+
const mutationTarget = targetRef.current;
|
|
1980
|
+
const rawResult = isAPIRouteRef(mutationTarget) ? await mutationTarget(variables, currentOptions.request) : await mutationTarget(variables);
|
|
1981
|
+
const data = unwrapMutationResult(rawResult, isAPIRouteRef(mutationTarget));
|
|
1982
|
+
const isLatestRequest = requestId === requestIdRef.current;
|
|
1983
|
+
setMutationState((current) => {
|
|
1984
|
+
const pendingCount = Math.max(0, current.pendingCount - 1);
|
|
1985
|
+
if (!isLatestRequest) {
|
|
1986
|
+
return {
|
|
1987
|
+
...current,
|
|
1988
|
+
pendingCount,
|
|
1989
|
+
status: pendingCount > 0 ? "pending" : current.status
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
return {
|
|
1993
|
+
pendingCount,
|
|
1994
|
+
status: "success",
|
|
1995
|
+
data,
|
|
1996
|
+
error: null,
|
|
1997
|
+
variables
|
|
1998
|
+
};
|
|
1999
|
+
});
|
|
2000
|
+
if (isLatestRequest) {
|
|
2001
|
+
currentOptions.onSuccess?.(data, variables);
|
|
2002
|
+
currentOptions.onSettled?.(data, null, variables);
|
|
2003
|
+
}
|
|
2004
|
+
return data;
|
|
2005
|
+
} catch (cause) {
|
|
2006
|
+
const error = normalizeMutationError(cause);
|
|
2007
|
+
const isLatestRequest = requestId === requestIdRef.current;
|
|
2008
|
+
setMutationState((current) => {
|
|
2009
|
+
const pendingCount = Math.max(0, current.pendingCount - 1);
|
|
2010
|
+
if (!isLatestRequest) {
|
|
2011
|
+
return {
|
|
2012
|
+
...current,
|
|
2013
|
+
pendingCount,
|
|
2014
|
+
status: pendingCount > 0 ? "pending" : current.status
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
return {
|
|
2018
|
+
pendingCount,
|
|
2019
|
+
status: "error",
|
|
2020
|
+
data: hasOptimisticData && currentOptions.rollbackOnError ? previousData : currentOptions.resetOnMutate === false ? current.data : null,
|
|
2021
|
+
error,
|
|
2022
|
+
variables
|
|
2023
|
+
};
|
|
2024
|
+
});
|
|
2025
|
+
if (isLatestRequest) {
|
|
2026
|
+
currentOptions.onError?.(error, variables);
|
|
2027
|
+
currentOptions.onSettled?.(null, error, variables);
|
|
2028
|
+
}
|
|
2029
|
+
throw error;
|
|
2030
|
+
}
|
|
2031
|
+
},
|
|
2032
|
+
[setMutationState]
|
|
2033
|
+
);
|
|
2034
|
+
const mutate = (0, import_react.useCallback)(
|
|
2035
|
+
(variables) => {
|
|
2036
|
+
void mutateAsync(variables).catch(() => {
|
|
2037
|
+
});
|
|
2038
|
+
},
|
|
2039
|
+
[mutateAsync]
|
|
2040
|
+
);
|
|
2041
|
+
const reset = (0, import_react.useCallback)(() => {
|
|
2042
|
+
requestIdRef.current += 1;
|
|
2043
|
+
setMutationState({
|
|
2044
|
+
pendingCount: 0,
|
|
2045
|
+
status: "idle",
|
|
2046
|
+
data: optionsRef.current.initialData ?? null,
|
|
2047
|
+
error: null,
|
|
2048
|
+
variables: void 0
|
|
2049
|
+
});
|
|
2050
|
+
}, [setMutationState]);
|
|
2051
|
+
return (0, import_react.useMemo)(
|
|
2052
|
+
() => ({
|
|
2053
|
+
pending: state.pendingCount > 0,
|
|
2054
|
+
status: state.status,
|
|
2055
|
+
data: state.data,
|
|
2056
|
+
error: state.error,
|
|
2057
|
+
variables: state.variables,
|
|
2058
|
+
mutate,
|
|
2059
|
+
mutateAsync,
|
|
2060
|
+
reset
|
|
2061
|
+
}),
|
|
2062
|
+
[
|
|
2063
|
+
mutate,
|
|
2064
|
+
mutateAsync,
|
|
2065
|
+
reset,
|
|
2066
|
+
state.data,
|
|
2067
|
+
state.error,
|
|
2068
|
+
state.pendingCount,
|
|
2069
|
+
state.status,
|
|
2070
|
+
state.variables
|
|
2071
|
+
]
|
|
2072
|
+
);
|
|
2073
|
+
}
|
|
2074
|
+
__name(useMutation, "useMutation");
|
|
2075
|
+
function unwrapMutationResult(result, apiRoute) {
|
|
2076
|
+
if (!apiRoute) return result;
|
|
2077
|
+
const apiResult = result;
|
|
2078
|
+
if (apiResult.error) {
|
|
2079
|
+
throw apiResult.error;
|
|
2080
|
+
}
|
|
2081
|
+
return apiResult.data;
|
|
2082
|
+
}
|
|
2083
|
+
__name(unwrapMutationResult, "unwrapMutationResult");
|
|
2084
|
+
function normalizeMutationError(error) {
|
|
2085
|
+
if (error instanceof Error) return error;
|
|
2086
|
+
const normalized = new Error(typeof error === "string" ? error : "Mutation failed");
|
|
2087
|
+
normalized.cause = error;
|
|
2088
|
+
return normalized;
|
|
2089
|
+
}
|
|
2090
|
+
__name(normalizeMutationError, "normalizeMutationError");
|
|
2091
|
+
|
|
2092
|
+
// src/server-query-client.ts
|
|
2093
|
+
var import_react2 = require("react");
|
|
1848
2094
|
var FARM_SERVER_QUERY_CLIENT_STATE = /* @__PURE__ */ Symbol.for("farm.serverQueryClientState");
|
|
1849
2095
|
var serverQueryClientGlobal = globalThis;
|
|
1850
2096
|
var serverQueryClientState = serverQueryClientGlobal[FARM_SERVER_QUERY_CLIENT_STATE] ?? (serverQueryClientGlobal[FARM_SERVER_QUERY_CLIENT_STATE] = {
|
|
@@ -1876,25 +2122,25 @@ __name(prefetchServerQuery, "prefetchServerQuery");
|
|
|
1876
2122
|
function useServerQuery(query, input, options = {}) {
|
|
1877
2123
|
const cache = getFarmClientDataCache();
|
|
1878
2124
|
const key = createServerQueryCallKey(query, input);
|
|
1879
|
-
const inputRef = (0,
|
|
1880
|
-
const optionsRef = (0,
|
|
1881
|
-
const mountedKeyRef = (0,
|
|
2125
|
+
const inputRef = (0, import_react2.useRef)(input);
|
|
2126
|
+
const optionsRef = (0, import_react2.useRef)(options);
|
|
2127
|
+
const mountedKeyRef = (0, import_react2.useRef)();
|
|
1882
2128
|
inputRef.current = input;
|
|
1883
2129
|
optionsRef.current = options;
|
|
1884
|
-
const subscribe = (0,
|
|
2130
|
+
const subscribe = (0, import_react2.useCallback)(
|
|
1885
2131
|
(listener) => cache.subscribe(key, listener),
|
|
1886
2132
|
[cache, key]
|
|
1887
2133
|
);
|
|
1888
|
-
const getSnapshot = (0,
|
|
1889
|
-
const entry = (0,
|
|
1890
|
-
const run = (0,
|
|
2134
|
+
const getSnapshot = (0, import_react2.useCallback)(() => cache.get(key), [cache, key]);
|
|
2135
|
+
const entry = (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot, () => void 0);
|
|
2136
|
+
const run = (0, import_react2.useCallback)(
|
|
1891
2137
|
(force = false) => fetchServerQuery(query, inputRef.current, {
|
|
1892
2138
|
...optionsRef.current,
|
|
1893
2139
|
force
|
|
1894
2140
|
}),
|
|
1895
2141
|
[query]
|
|
1896
2142
|
);
|
|
1897
|
-
(0,
|
|
2143
|
+
(0, import_react2.useEffect)(() => {
|
|
1898
2144
|
if (options.enabled === false) return;
|
|
1899
2145
|
const firstReadForKey = mountedKeyRef.current !== key;
|
|
1900
2146
|
if (firstReadForKey) mountedKeyRef.current = key;
|
|
@@ -1902,7 +2148,7 @@ function useServerQuery(query, input, options = {}) {
|
|
|
1902
2148
|
void run().catch(() => void 0);
|
|
1903
2149
|
}
|
|
1904
2150
|
}, [cache, entry, key, options.enabled, run]);
|
|
1905
|
-
(0,
|
|
2151
|
+
(0, import_react2.useEffect)(() => {
|
|
1906
2152
|
if (options.enabled === false || typeof window === "undefined") return;
|
|
1907
2153
|
const refreshIfStale = /* @__PURE__ */ __name(() => {
|
|
1908
2154
|
if (cache.isStale(key)) void run().catch(() => void 0);
|
|
@@ -2215,7 +2461,7 @@ var api = {
|
|
|
2215
2461
|
var endpoint = api;
|
|
2216
2462
|
|
|
2217
2463
|
// src/store.ts
|
|
2218
|
-
var
|
|
2464
|
+
var import_react3 = require("react");
|
|
2219
2465
|
var RESERVED_STORE_KEYS = /* @__PURE__ */ new Set([
|
|
2220
2466
|
"use",
|
|
2221
2467
|
"get",
|
|
@@ -2347,20 +2593,20 @@ function createStore(initialState, extend) {
|
|
|
2347
2593
|
}
|
|
2348
2594
|
return lastSlice;
|
|
2349
2595
|
}, "getSnapshot");
|
|
2350
|
-
return (0,
|
|
2596
|
+
return (0, import_react3.useSyncExternalStore)(
|
|
2351
2597
|
(notify) => addSubscription(keys, () => notify()),
|
|
2352
2598
|
getSnapshot,
|
|
2353
2599
|
getSnapshot
|
|
2354
2600
|
);
|
|
2355
2601
|
}
|
|
2356
2602
|
if (typeof keyOrKeys === "string") {
|
|
2357
|
-
return (0,
|
|
2603
|
+
return (0, import_react3.useSyncExternalStore)(
|
|
2358
2604
|
(notify) => addSubscription([keyOrKeys], () => notify()),
|
|
2359
2605
|
() => state[keyOrKeys],
|
|
2360
2606
|
() => state[keyOrKeys]
|
|
2361
2607
|
);
|
|
2362
2608
|
}
|
|
2363
|
-
return (0,
|
|
2609
|
+
return (0, import_react3.useSyncExternalStore)(
|
|
2364
2610
|
(notify) => addSubscription(null, () => notify()),
|
|
2365
2611
|
() => state,
|
|
2366
2612
|
() => state
|
|
@@ -2412,7 +2658,7 @@ function createStore(initialState, extend) {
|
|
|
2412
2658
|
__name(createStore, "createStore");
|
|
2413
2659
|
|
|
2414
2660
|
// src/client/link.tsx
|
|
2415
|
-
var
|
|
2661
|
+
var import_react4 = require("react");
|
|
2416
2662
|
|
|
2417
2663
|
// src/router.ts
|
|
2418
2664
|
function createFarmRouter(routes) {
|
|
@@ -2812,9 +3058,9 @@ function LinkInner({
|
|
|
2812
3058
|
onTouchStart,
|
|
2813
3059
|
...props
|
|
2814
3060
|
}, ref) {
|
|
2815
|
-
const elementRef = (0,
|
|
2816
|
-
const intentTimeoutRef = (0,
|
|
2817
|
-
const hasPrefetched = (0,
|
|
3061
|
+
const elementRef = (0, import_react4.useRef)(null);
|
|
3062
|
+
const intentTimeoutRef = (0, import_react4.useRef)(null);
|
|
3063
|
+
const hasPrefetched = (0, import_react4.useRef)(false);
|
|
2818
3064
|
const { intent, viewport, render } = normalizePrefetch(prefetch2);
|
|
2819
3065
|
const baseHref = resolveLinkHref(href, params, {
|
|
2820
3066
|
query,
|
|
@@ -2823,17 +3069,17 @@ function LinkInner({
|
|
|
2823
3069
|
});
|
|
2824
3070
|
const resolvedHref = localizeActiveFarmHref(baseHref, locale);
|
|
2825
3071
|
const isExternal = isExternalUrl(resolvedHref);
|
|
2826
|
-
const doPrefetch = (0,
|
|
3072
|
+
const doPrefetch = (0, import_react4.useCallback)(() => {
|
|
2827
3073
|
if (isExternal || hasPrefetched.current) return;
|
|
2828
3074
|
const router = getRouter();
|
|
2829
3075
|
if (!router) return;
|
|
2830
3076
|
hasPrefetched.current = true;
|
|
2831
3077
|
router.prefetch(resolvedHref);
|
|
2832
3078
|
}, [resolvedHref, isExternal]);
|
|
2833
|
-
(0,
|
|
3079
|
+
(0, import_react4.useEffect)(() => {
|
|
2834
3080
|
hasPrefetched.current = false;
|
|
2835
3081
|
}, [resolvedHref]);
|
|
2836
|
-
(0,
|
|
3082
|
+
(0, import_react4.useEffect)(() => {
|
|
2837
3083
|
const element = elementRef.current;
|
|
2838
3084
|
if (!element || isExternal) return;
|
|
2839
3085
|
const router = getRouter();
|
|
@@ -2843,7 +3089,7 @@ function LinkInner({
|
|
|
2843
3089
|
return () => router.unobserveForPrefetch(element);
|
|
2844
3090
|
}
|
|
2845
3091
|
}, [resolvedHref, viewport, isExternal]);
|
|
2846
|
-
(0,
|
|
3092
|
+
(0, import_react4.useEffect)(() => {
|
|
2847
3093
|
if (!render || isExternal) return;
|
|
2848
3094
|
let cancelled = false;
|
|
2849
3095
|
let timeoutId = null;
|
|
@@ -2865,7 +3111,7 @@ function LinkInner({
|
|
|
2865
3111
|
}
|
|
2866
3112
|
};
|
|
2867
3113
|
}, [render, isExternal, resolvedHref]);
|
|
2868
|
-
(0,
|
|
3114
|
+
(0, import_react4.useEffect)(() => {
|
|
2869
3115
|
return () => {
|
|
2870
3116
|
if (intentTimeoutRef.current) {
|
|
2871
3117
|
clearTimeout(intentTimeoutRef.current);
|
|
@@ -2873,13 +3119,13 @@ function LinkInner({
|
|
|
2873
3119
|
}
|
|
2874
3120
|
};
|
|
2875
3121
|
}, []);
|
|
2876
|
-
const cancelIntent = (0,
|
|
3122
|
+
const cancelIntent = (0, import_react4.useCallback)(() => {
|
|
2877
3123
|
if (intentTimeoutRef.current) {
|
|
2878
3124
|
clearTimeout(intentTimeoutRef.current);
|
|
2879
3125
|
intentTimeoutRef.current = null;
|
|
2880
3126
|
}
|
|
2881
3127
|
}, []);
|
|
2882
|
-
const scheduleIntentPrefetch = (0,
|
|
3128
|
+
const scheduleIntentPrefetch = (0, import_react4.useCallback)(() => {
|
|
2883
3129
|
if (isExternal || !intent || hasPrefetched.current) return;
|
|
2884
3130
|
cancelIntent();
|
|
2885
3131
|
intentTimeoutRef.current = setTimeout(() => {
|
|
@@ -2887,42 +3133,42 @@ function LinkInner({
|
|
|
2887
3133
|
doPrefetch();
|
|
2888
3134
|
}, prefetchDelay);
|
|
2889
3135
|
}, [intent, isExternal, prefetchDelay, doPrefetch, cancelIntent]);
|
|
2890
|
-
const handleMouseEnter = (0,
|
|
3136
|
+
const handleMouseEnter = (0, import_react4.useCallback)(
|
|
2891
3137
|
(event) => {
|
|
2892
3138
|
onMouseEnter?.(event);
|
|
2893
3139
|
scheduleIntentPrefetch();
|
|
2894
3140
|
},
|
|
2895
3141
|
[onMouseEnter, scheduleIntentPrefetch]
|
|
2896
3142
|
);
|
|
2897
|
-
const handleMouseLeave = (0,
|
|
3143
|
+
const handleMouseLeave = (0, import_react4.useCallback)(
|
|
2898
3144
|
(event) => {
|
|
2899
3145
|
onMouseLeave?.(event);
|
|
2900
3146
|
cancelIntent();
|
|
2901
3147
|
},
|
|
2902
3148
|
[onMouseLeave, cancelIntent]
|
|
2903
3149
|
);
|
|
2904
|
-
const handleTouchStart = (0,
|
|
3150
|
+
const handleTouchStart = (0, import_react4.useCallback)(
|
|
2905
3151
|
(event) => {
|
|
2906
3152
|
onTouchStart?.(event);
|
|
2907
3153
|
scheduleIntentPrefetch();
|
|
2908
3154
|
},
|
|
2909
3155
|
[onTouchStart, scheduleIntentPrefetch]
|
|
2910
3156
|
);
|
|
2911
|
-
const handleFocus = (0,
|
|
3157
|
+
const handleFocus = (0, import_react4.useCallback)(
|
|
2912
3158
|
(event) => {
|
|
2913
3159
|
onFocus?.(event);
|
|
2914
3160
|
scheduleIntentPrefetch();
|
|
2915
3161
|
},
|
|
2916
3162
|
[onFocus, scheduleIntentPrefetch]
|
|
2917
3163
|
);
|
|
2918
|
-
const handleBlur = (0,
|
|
3164
|
+
const handleBlur = (0, import_react4.useCallback)(
|
|
2919
3165
|
(event) => {
|
|
2920
3166
|
onBlur?.(event);
|
|
2921
3167
|
cancelIntent();
|
|
2922
3168
|
},
|
|
2923
3169
|
[onBlur, cancelIntent]
|
|
2924
3170
|
);
|
|
2925
|
-
const handleClick = (0,
|
|
3171
|
+
const handleClick = (0, import_react4.useCallback)(
|
|
2926
3172
|
(event) => {
|
|
2927
3173
|
onClick?.(event);
|
|
2928
3174
|
if (event.defaultPrevented) return;
|
|
@@ -2947,7 +3193,7 @@ function LinkInner({
|
|
|
2947
3193
|
},
|
|
2948
3194
|
[resolvedHref, replace, scroll, viewTransition, target, isExternal, onClick]
|
|
2949
3195
|
);
|
|
2950
|
-
const setRefs = (0,
|
|
3196
|
+
const setRefs = (0, import_react4.useCallback)(
|
|
2951
3197
|
(node) => {
|
|
2952
3198
|
elementRef.current = node;
|
|
2953
3199
|
if (typeof ref === "function") ref(node);
|
|
@@ -2976,7 +3222,7 @@ function LinkInner({
|
|
|
2976
3222
|
);
|
|
2977
3223
|
}
|
|
2978
3224
|
__name(LinkInner, "LinkInner");
|
|
2979
|
-
var LinkWithRef = (0,
|
|
3225
|
+
var LinkWithRef = (0, import_react4.forwardRef)(LinkInner);
|
|
2980
3226
|
LinkWithRef.displayName = "Link";
|
|
2981
3227
|
var Link = LinkWithRef;
|
|
2982
3228
|
function resolveLinkHref(href, params, options) {
|
|
@@ -3077,7 +3323,7 @@ function matchManifestRoute(pathname, route2) {
|
|
|
3077
3323
|
__name(matchManifestRoute, "matchManifestRoute");
|
|
3078
3324
|
|
|
3079
3325
|
// src/client/router.ts
|
|
3080
|
-
var
|
|
3326
|
+
var import_react5 = require("react");
|
|
3081
3327
|
|
|
3082
3328
|
// src/deferred.ts
|
|
3083
3329
|
var FARM_DEFERRED_CONTENT_TYPE = "application/x-farm-deferred+json";
|
|
@@ -3833,14 +4079,14 @@ function useRouter(options = {}) {
|
|
|
3833
4079
|
const basePath = options.basePath || "";
|
|
3834
4080
|
const routes = options.routes;
|
|
3835
4081
|
const routeKey = routes?.map((route2) => typeof route2 === "string" ? route2 : route2.path).join("\n") || "";
|
|
3836
|
-
const routeMatcher = (0,
|
|
4082
|
+
const routeMatcher = (0, import_react5.useMemo)(
|
|
3837
4083
|
() => routeKey ? createFarmRouter(routeKey.split("\n")) : null,
|
|
3838
4084
|
[routeKey]
|
|
3839
4085
|
);
|
|
3840
|
-
const [state, setState] = (0,
|
|
4086
|
+
const [state, setState] = (0, import_react5.useState)(() => {
|
|
3841
4087
|
return readRouterState(basePath, routeMatcher);
|
|
3842
4088
|
});
|
|
3843
|
-
(0,
|
|
4089
|
+
(0, import_react5.useEffect)(() => {
|
|
3844
4090
|
if (typeof window === "undefined") return;
|
|
3845
4091
|
const handlePopState = /* @__PURE__ */ __name(() => {
|
|
3846
4092
|
setState(readRouterState(basePath, routeMatcher));
|
|
@@ -3891,8 +4137,8 @@ function useRouter(options = {}) {
|
|
|
3891
4137
|
}
|
|
3892
4138
|
__name(useRouter, "useRouter");
|
|
3893
4139
|
function usePageState() {
|
|
3894
|
-
const [state, setState] = (0,
|
|
3895
|
-
(0,
|
|
4140
|
+
const [state, setState] = (0, import_react5.useState)(() => readPageState());
|
|
4141
|
+
(0, import_react5.useEffect)(() => {
|
|
3896
4142
|
if (typeof window === "undefined") return;
|
|
3897
4143
|
const handlePopState = /* @__PURE__ */ __name(() => {
|
|
3898
4144
|
setState(readPageState());
|
|
@@ -3905,10 +4151,10 @@ function usePageState() {
|
|
|
3905
4151
|
}
|
|
3906
4152
|
__name(usePageState, "usePageState");
|
|
3907
4153
|
function useNavigation() {
|
|
3908
|
-
const [state, setState] = (0,
|
|
4154
|
+
const [state, setState] = (0, import_react5.useState)(
|
|
3909
4155
|
() => getRouter2().getNavigationState()
|
|
3910
4156
|
);
|
|
3911
|
-
(0,
|
|
4157
|
+
(0, import_react5.useEffect)(() => {
|
|
3912
4158
|
if (typeof window === "undefined") return;
|
|
3913
4159
|
return getRouter2().subscribeNavigation(setState);
|
|
3914
4160
|
}, []);
|
|
@@ -3916,10 +4162,10 @@ function useNavigation() {
|
|
|
3916
4162
|
}
|
|
3917
4163
|
__name(useNavigation, "useNavigation");
|
|
3918
4164
|
function useBlocker(options) {
|
|
3919
|
-
const optionsRef = (0,
|
|
4165
|
+
const optionsRef = (0, import_react5.useRef)(options);
|
|
3920
4166
|
optionsRef.current = options;
|
|
3921
4167
|
const active = Boolean(options.when);
|
|
3922
|
-
(0,
|
|
4168
|
+
(0, import_react5.useEffect)(() => {
|
|
3923
4169
|
if (typeof window === "undefined" || !active) {
|
|
3924
4170
|
return;
|
|
3925
4171
|
}
|
|
@@ -3940,8 +4186,8 @@ function useBlocker(options) {
|
|
|
3940
4186
|
}
|
|
3941
4187
|
__name(useBlocker, "useBlocker");
|
|
3942
4188
|
function useScrollRestoration(key) {
|
|
3943
|
-
const ref = (0,
|
|
3944
|
-
(0,
|
|
4189
|
+
const ref = (0, import_react5.useRef)(null);
|
|
4190
|
+
(0, import_react5.useEffect)(() => {
|
|
3945
4191
|
const element = ref.current;
|
|
3946
4192
|
if (!element) return;
|
|
3947
4193
|
return getRouter2().registerScrollElement(key, element);
|
|
@@ -4530,6 +4776,7 @@ function isObject(value) {
|
|
|
4530
4776
|
__name(isObject, "isObject");
|
|
4531
4777
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4532
4778
|
0 && (module.exports = {
|
|
4779
|
+
APIClientError,
|
|
4533
4780
|
FarmClientPluginManager,
|
|
4534
4781
|
IntegrationClientError,
|
|
4535
4782
|
Link,
|
|
@@ -4562,6 +4809,7 @@ __name(isObject, "isObject");
|
|
|
4562
4809
|
readPageState,
|
|
4563
4810
|
replaceState,
|
|
4564
4811
|
useBlocker,
|
|
4812
|
+
useMutation,
|
|
4565
4813
|
useNavigation,
|
|
4566
4814
|
usePageState,
|
|
4567
4815
|
useRouter,
|