@farm.js/core 0.1.0-beta.95 → 0.1.0-beta.97
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/after.cjs +1 -1
- package/dist/after.mjs +1 -1
- package/dist/agent-runtime.d.mts +3 -2
- package/dist/agent-runtime.d.ts +3 -2
- package/dist/api/route-manager.cjs +43 -4
- package/dist/api/route-manager.d.mts +4 -3
- package/dist/api/route-manager.d.ts +4 -3
- package/dist/api/route-manager.mjs +7 -7
- package/dist/api/runtime.cjs +43 -4
- package/dist/api/runtime.d.mts +1 -1
- package/dist/api/runtime.d.ts +1 -1
- package/dist/api/runtime.mjs +5 -5
- package/dist/api.cjs +352 -109
- package/dist/api.d.mts +7 -6
- package/dist/api.d.ts +7 -6
- package/dist/api.mjs +19 -12
- package/dist/{app-CIIEvA4r.d.ts → app-CIOx3LvY.d.ts} +4 -4
- package/dist/{app-O4AEC1OH.d.mts → app-DBd6437H.d.mts} +4 -4
- package/dist/app-markdown.d.mts +4 -3
- package/dist/app-markdown.d.ts +4 -3
- package/dist/cache.cjs +42 -4
- package/dist/cache.d.mts +68 -1
- package/dist/cache.d.ts +68 -1
- package/dist/cache.mjs +3 -3
- package/dist/{chunk-AXVJCMVF.mjs → chunk-2HDOV47R.mjs} +3 -3
- package/dist/chunk-2HDOV47R.mjs.map +1 -0
- package/dist/{chunk-RBRLLZL5.mjs → chunk-34IAPZBG.mjs} +16 -3
- package/dist/chunk-34IAPZBG.mjs.map +1 -0
- package/dist/{chunk-VV24CC42.mjs → chunk-35NPLKQJ.mjs} +2 -2
- package/dist/{chunk-D7QH7MDU.mjs → chunk-3TWQERDE.mjs} +5 -4
- package/dist/chunk-3TWQERDE.mjs.map +1 -0
- package/dist/{chunk-RWYRFCLG.mjs → chunk-4X57GXQA.mjs} +2 -2
- package/dist/{chunk-KOTSX5JH.mjs → chunk-52BR7LTX.mjs} +30 -21
- package/dist/chunk-52BR7LTX.mjs.map +1 -0
- package/dist/{chunk-SALMKQXH.mjs → chunk-6EJHNHH4.mjs} +80 -27
- package/dist/chunk-6EJHNHH4.mjs.map +1 -0
- package/dist/{chunk-ZFNK77WN.mjs → chunk-6JNGOC37.mjs} +2 -2
- package/dist/{after.cjs.map → chunk-6JNGOC37.mjs.map} +1 -1
- package/dist/{chunk-MOW47IF5.mjs → chunk-6UYVU46O.mjs} +2 -2
- package/dist/{chunk-7MABZJIM.mjs → chunk-7PYVLJ4J.mjs} +1 -1
- package/dist/chunk-7PYVLJ4J.mjs.map +1 -0
- package/dist/{chunk-FLHLPB57.mjs → chunk-D7F7YZ7L.mjs} +93 -67
- package/dist/chunk-D7F7YZ7L.mjs.map +1 -0
- package/dist/chunk-DU3PKDVQ.mjs +35 -0
- package/dist/chunk-DU3PKDVQ.mjs.map +1 -0
- package/dist/{chunk-SCFX4UTD.mjs → chunk-EHTUKVSW.mjs} +1 -1
- package/dist/chunk-EHTUKVSW.mjs.map +1 -0
- package/dist/{chunk-KWCNQUH5.mjs → chunk-EPDIF432.mjs} +526 -50
- package/dist/chunk-EPDIF432.mjs.map +1 -0
- package/dist/{chunk-A3636IHN.mjs → chunk-FP5Q67FO.mjs} +167 -96
- package/dist/chunk-FP5Q67FO.mjs.map +1 -0
- package/dist/{chunk-HHZAOTQD.mjs → chunk-GJ7W6LNK.mjs} +7 -6
- package/dist/chunk-GJ7W6LNK.mjs.map +1 -0
- package/dist/{chunk-RLGUZ3HS.mjs → chunk-I3OOUWO5.mjs} +3 -3
- package/dist/{chunk-75CGAL6E.mjs → chunk-IZBX2TEU.mjs} +217 -105
- package/dist/chunk-IZBX2TEU.mjs.map +1 -0
- package/dist/{chunk-22VG4DFJ.mjs → chunk-J3MPQ4MQ.mjs} +2 -2
- package/dist/{chunk-22VG4DFJ.mjs.map → chunk-J3MPQ4MQ.mjs.map} +1 -1
- package/dist/{chunk-2LS3KKE7.mjs → chunk-JV7JUD7Q.mjs} +4 -4
- package/dist/{chunk-Q3OX763A.mjs → chunk-LXDASSTE.mjs} +2 -2
- package/dist/{chunk-ZRBCBOEX.mjs → chunk-N2FY2QZ7.mjs} +28 -3
- package/dist/chunk-N2FY2QZ7.mjs.map +1 -0
- package/dist/{chunk-MRVJCLYQ.mjs → chunk-PSQ7N4XP.mjs} +4 -2
- package/dist/chunk-PSQ7N4XP.mjs.map +1 -0
- package/dist/{chunk-HVG3HLQZ.mjs → chunk-Q7WGOOAI.mjs} +3 -3
- package/dist/{chunk-WTYAPO5I.mjs → chunk-RCNWMEBT.mjs} +3 -2
- package/dist/{chunk-WTYAPO5I.mjs.map → chunk-RCNWMEBT.mjs.map} +1 -1
- package/dist/{chunk-3INDBMUU.mjs → chunk-TGDIACZT.mjs} +2 -2
- package/dist/{chunk-WB75GIX2.mjs → chunk-TQTB33JS.mjs} +14 -3
- package/dist/chunk-TQTB33JS.mjs.map +1 -0
- package/dist/{chunk-MH27UH72.mjs → chunk-TT3E2JOF.mjs} +3 -3
- package/dist/{chunk-UWRGX3J3.mjs → chunk-UMUWR5XA.mjs} +2 -2
- package/dist/{chunk-XTLLHCWU.mjs → chunk-V4VRLVLW.mjs} +52 -31
- package/dist/chunk-V4VRLVLW.mjs.map +1 -0
- package/dist/{chunk-EXCGBERG.mjs → chunk-WD2EBM3I.mjs} +79 -17
- package/dist/chunk-WD2EBM3I.mjs.map +1 -0
- package/dist/{chunk-DLBUAJTK.mjs → chunk-WMJGA32P.mjs} +74 -5
- package/dist/chunk-WMJGA32P.mjs.map +1 -0
- package/dist/{chunk-TKQCJMY7.mjs → chunk-X4SFHKFH.mjs} +7 -4
- package/dist/{chunk-TKQCJMY7.mjs.map → chunk-X4SFHKFH.mjs.map} +1 -1
- package/dist/{chunk-Q7GPJZCO.mjs → chunk-YIBV77KZ.mjs} +26 -7
- package/dist/chunk-YIBV77KZ.mjs.map +1 -0
- package/dist/client/lifecycle.mjs +2 -2
- package/dist/{client-mcMC334J.d.mts → client-DWoLZ3QU.d.mts} +52 -5
- package/dist/{client-d5ONQ-Pd.d.ts → client-DuQuQC1h.d.ts} +52 -5
- package/dist/client-cache-BMxuFqwH.d.ts +18 -0
- package/dist/client-cache-CCK-fCe0.d.mts +18 -0
- package/dist/{client-plugins-BvClItiL.d.mts → client-plugins-B6-07YmP.d.mts} +52 -99
- package/dist/{client-plugins-B9Sq-iMg.d.ts → client-plugins-By6MVUX-.d.ts} +52 -99
- package/dist/client-plugins.cjs +1 -1
- package/dist/client-plugins.d.mts +3 -2
- package/dist/client-plugins.d.ts +3 -2
- package/dist/client-plugins.mjs +2 -2
- package/dist/client.cjs +1046 -211
- package/dist/client.d.mts +136 -18
- package/dist/client.d.ts +136 -18
- package/dist/client.mjs +32 -15
- package/dist/config.d.mts +3 -2
- package/dist/config.d.ts +3 -2
- package/dist/{devtools-S52RRRMN.mjs → devtools-XWZX6CCL.mjs} +5 -5
- package/dist/{devtools-client-3XRTBND5.mjs → devtools-client-Z7QQA3Q2.mjs} +56 -17
- package/dist/devtools-client-Z7QQA3Q2.mjs.map +1 -0
- package/dist/{devtools-ui-NJKFORTG.mjs → devtools-ui-2HG5M4EL.mjs} +3 -1
- package/dist/devtools-ui-2HG5M4EL.mjs.map +1 -0
- package/dist/docs.cjs +24 -5
- package/dist/docs.mjs +5 -5
- package/dist/i18n/server.cjs +13 -2
- package/dist/i18n/server.d.mts +2 -2
- package/dist/i18n/server.d.ts +2 -2
- package/dist/i18n/server.mjs +1 -1
- package/dist/index.cjs +1928 -894
- package/dist/index.d.mts +139 -21
- package/dist/index.d.ts +139 -21
- package/dist/index.mjs +57 -34
- package/dist/index.mjs.map +1 -1
- package/dist/integration-api-BT024nuJ.d.mts +97 -0
- package/dist/integration-api-BT024nuJ.d.ts +97 -0
- package/dist/integrations.d.mts +3 -2
- package/dist/integrations.d.ts +3 -2
- package/dist/internal/build-runtime.cjs +764 -547
- package/dist/internal/build-runtime.d.mts +5 -4
- package/dist/internal/build-runtime.d.ts +5 -4
- package/dist/internal/build-runtime.mjs +16 -16
- package/dist/internal/client-runtime.cjs +1 -1
- package/dist/internal/client-runtime.mjs +2 -2
- package/dist/internal/config-runtime.cjs +4 -1
- package/dist/internal/config-runtime.d.mts +4 -3
- package/dist/internal/config-runtime.d.ts +4 -3
- package/dist/internal/config-runtime.mjs +4 -4
- package/dist/internal/product-telemetry-runtime.cjs +1 -1
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +29 -3
- package/dist/internal/production-runtime.d.mts +8 -7
- package/dist/internal/production-runtime.d.ts +8 -7
- package/dist/internal/production-runtime.mjs +5 -5
- package/dist/{metadata-route-yV4U6X8h.d.ts → metadata-route-8_V3UonT.d.ts} +1 -1
- package/dist/{metadata-route-p4K1l92V.d.mts → metadata-route-CWP_HjGU.d.mts} +1 -1
- package/dist/middleware.cjs +28 -2
- package/dist/middleware.d.mts +5 -4
- package/dist/middleware.d.ts +5 -4
- package/dist/middleware.mjs +4 -4
- package/dist/navigation.cjs +3 -1
- package/dist/navigation.mjs +3 -3
- package/dist/observability.cjs +27 -2
- package/dist/observability.mjs +1 -1
- package/dist/plugin.cjs +528 -349
- package/dist/plugin.d.mts +3 -2
- package/dist/plugin.d.ts +3 -2
- package/dist/plugin.mjs +13 -13
- package/dist/{production-runtime-IkB0Qj4i.d.mts → production-runtime-BGRH1dKG.d.mts} +1 -1
- package/dist/{production-runtime-0JTch4_d.d.ts → production-runtime-CdmzsDax.d.ts} +1 -1
- package/dist/query/client.cjs +68 -29
- package/dist/query/client.mjs +69 -30
- package/dist/query/client.mjs.map +1 -1
- package/dist/{render-plan-Dc8CjNI7.d.ts → render-plan-0GeHiGVZ.d.ts} +1 -1
- package/dist/{render-plan-CU31j-Jk.d.mts → render-plan-DLxJYAA5.d.mts} +1 -1
- package/dist/renderer-client.cjs +169 -26
- package/dist/renderer-client.d.mts +7 -6
- package/dist/renderer-client.d.ts +7 -6
- package/dist/renderer-client.mjs +16 -19
- package/dist/renderer-client.mjs.map +1 -1
- package/dist/{request-BXa1KY8i.d.mts → request-BCNXSXLh.d.mts} +1 -1
- package/dist/{request-CUUBujZt.d.ts → request-BstWbZ6O.d.ts} +1 -1
- package/dist/request.d.mts +4 -3
- package/dist/request.d.ts +4 -3
- package/dist/{route-Y8lfz1wF.d.ts → route-4pd-EVtw.d.ts} +45 -50
- package/dist/{route-Cq3aObmj.d.mts → route-CvEr4Uc9.d.mts} +45 -50
- package/dist/routes.cjs +27 -2
- package/dist/routes.d.mts +3 -2
- package/dist/routes.d.ts +3 -2
- package/dist/routes.mjs +4 -4
- package/dist/{runtime-j1S3sDTh.d.ts → runtime-BgDQzBiu.d.ts} +1 -0
- package/dist/{runtime-DDwvDtS4.d.mts → runtime-CV2UCV-5.d.mts} +1 -0
- package/dist/server-action-security.mjs +2 -2
- package/dist/server-fn-client.cjs +102 -26
- package/dist/server-fn-client.d.mts +6 -0
- package/dist/server-fn-client.d.ts +6 -0
- package/dist/server-fn-client.mjs +2 -1
- package/dist/server-fn.cjs +42 -4
- package/dist/server-fn.mjs +5 -5
- package/dist/server-plugins.d.mts +4 -3
- package/dist/server-plugins.d.ts +4 -3
- package/dist/server-query-client.cjs +195 -34
- package/dist/server-query-client.d.mts +3 -3
- package/dist/server-query-client.d.ts +3 -3
- package/dist/server-query-client.mjs +7 -7
- package/dist/{server-query-runtime-3zAj77yv.d.ts → server-query-runtime-DXRNhX_3.d.ts} +2 -0
- package/dist/{server-query-runtime-B50KAcj5.d.mts → server-query-runtime-aP52iuL5.d.mts} +2 -0
- package/dist/server-query.cjs +44 -5
- package/dist/server-query.d.mts +4 -0
- package/dist/server-query.d.ts +4 -0
- package/dist/server-query.mjs +7 -7
- package/dist/server.cjs +553 -370
- package/dist/server.d.mts +11 -10
- package/dist/server.d.ts +11 -10
- package/dist/server.mjs +17 -17
- package/dist/{spa-router-CyLkwst6.d.mts → spa-router-BeyAVSc6.d.mts} +1 -1
- package/dist/{spa-router-BkqGXaV_.d.ts → spa-router-COgu4txb.d.ts} +1 -1
- package/dist/testing.cjs +27 -2
- package/dist/testing.d.mts +3 -2
- package/dist/testing.d.ts +3 -2
- package/dist/testing.mjs +9 -9
- package/dist/{utils-NKR6SoNv.d.mts → utils-DL2VwDQl.d.mts} +1 -1
- package/dist/{utils-B2OHrb9F.d.ts → utils-DkU2c_1B.d.ts} +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +536 -353
- package/dist/vite.d.mts +3 -2
- package/dist/vite.d.ts +3 -2
- package/dist/vite.mjs +17 -13
- package/package.json +17 -17
- package/types/client.d.ts +115 -10
- package/dist/agent-runtime.cjs.map +0 -1
- package/dist/api/route-manager.cjs.map +0 -1
- package/dist/api/runtime.cjs.map +0 -1
- package/dist/api.cjs.map +0 -1
- package/dist/app-markdown.cjs.map +0 -1
- package/dist/cache.cjs.map +0 -1
- package/dist/chunk-75CGAL6E.mjs.map +0 -1
- package/dist/chunk-7MABZJIM.mjs.map +0 -1
- package/dist/chunk-A3636IHN.mjs.map +0 -1
- package/dist/chunk-AXVJCMVF.mjs.map +0 -1
- package/dist/chunk-D7QH7MDU.mjs.map +0 -1
- package/dist/chunk-DLBUAJTK.mjs.map +0 -1
- package/dist/chunk-EXCGBERG.mjs.map +0 -1
- package/dist/chunk-FLHLPB57.mjs.map +0 -1
- package/dist/chunk-HHZAOTQD.mjs.map +0 -1
- package/dist/chunk-KOTSX5JH.mjs.map +0 -1
- package/dist/chunk-KWCNQUH5.mjs.map +0 -1
- package/dist/chunk-MRVJCLYQ.mjs.map +0 -1
- package/dist/chunk-Q7GPJZCO.mjs.map +0 -1
- package/dist/chunk-RBRLLZL5.mjs.map +0 -1
- package/dist/chunk-SALMKQXH.mjs.map +0 -1
- package/dist/chunk-SCFX4UTD.mjs.map +0 -1
- package/dist/chunk-WB75GIX2.mjs.map +0 -1
- package/dist/chunk-XTLLHCWU.mjs.map +0 -1
- package/dist/chunk-ZFNK77WN.mjs.map +0 -1
- package/dist/chunk-ZRBCBOEX.mjs.map +0 -1
- package/dist/client/lifecycle.cjs.map +0 -1
- package/dist/client-cache-CopR_MaI.d.mts +0 -6
- package/dist/client-cache-Djy_TlE8.d.ts +0 -6
- package/dist/client-plugins.cjs.map +0 -1
- package/dist/client.cjs.map +0 -1
- package/dist/config.cjs.map +0 -1
- package/dist/cron.cjs.map +0 -1
- package/dist/deferred.cjs.map +0 -1
- package/dist/deployment.cjs.map +0 -1
- package/dist/devtools-client-3XRTBND5.mjs.map +0 -1
- package/dist/devtools-ui-NJKFORTG.mjs.map +0 -1
- package/dist/docs.cjs.map +0 -1
- package/dist/env-types.cjs.map +0 -1
- package/dist/env.cjs.map +0 -1
- package/dist/environment/vite.cjs.map +0 -1
- package/dist/environment.cjs.map +0 -1
- package/dist/font.cjs.map +0 -1
- package/dist/headers.cjs.map +0 -1
- package/dist/i18n/client.cjs.map +0 -1
- package/dist/i18n/index.cjs.map +0 -1
- package/dist/i18n/server.cjs.map +0 -1
- package/dist/image/server.cjs.map +0 -1
- package/dist/image/sharp.cjs.map +0 -1
- package/dist/image.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/instrumentation.cjs.map +0 -1
- package/dist/integrations.cjs.map +0 -1
- package/dist/internal/build-runtime.cjs.map +0 -1
- package/dist/internal/client-runtime.cjs.map +0 -1
- package/dist/internal/config-runtime.cjs.map +0 -1
- package/dist/internal/isolated-boundary.cjs.map +0 -1
- package/dist/internal/metadata-image-runtime.cjs.map +0 -1
- package/dist/internal/product-telemetry-runtime.cjs.map +0 -1
- package/dist/internal/production-node-env.cjs.map +0 -1
- package/dist/internal/production-runtime.cjs.map +0 -1
- package/dist/markdown.cjs.map +0 -1
- package/dist/middleware.cjs.map +0 -1
- package/dist/navigation.cjs.map +0 -1
- package/dist/observability.cjs.map +0 -1
- package/dist/plugin.cjs.map +0 -1
- package/dist/query/client.cjs.map +0 -1
- package/dist/query/index.cjs.map +0 -1
- package/dist/query/parsers.cjs.map +0 -1
- package/dist/query/server.cjs.map +0 -1
- package/dist/renderer/react/client.cjs.map +0 -1
- package/dist/renderer/react/server.cjs.map +0 -1
- package/dist/renderer/react/vite.cjs.map +0 -1
- package/dist/renderer-client.cjs.map +0 -1
- package/dist/renderer.cjs.map +0 -1
- package/dist/request.cjs.map +0 -1
- package/dist/router.cjs.map +0 -1
- package/dist/routes.cjs.map +0 -1
- package/dist/server-action-security.cjs.map +0 -1
- package/dist/server-fn-client.cjs.map +0 -1
- package/dist/server-fn.cjs.map +0 -1
- package/dist/server-plugins.cjs.map +0 -1
- package/dist/server-query-client.cjs.map +0 -1
- package/dist/server-query.cjs.map +0 -1
- package/dist/server.cjs.map +0 -1
- package/dist/storage.cjs.map +0 -1
- package/dist/testing.cjs.map +0 -1
- package/dist/theme/client.cjs.map +0 -1
- package/dist/theme/index.cjs.map +0 -1
- package/dist/theme/runtime.cjs.map +0 -1
- package/dist/theme/server.cjs.map +0 -1
- package/dist/version.cjs.map +0 -1
- package/dist/vite.cjs.map +0 -1
- package/dist/workflows.cjs.map +0 -1
- /package/dist/{chunk-VV24CC42.mjs.map → chunk-35NPLKQJ.mjs.map} +0 -0
- /package/dist/{chunk-RWYRFCLG.mjs.map → chunk-4X57GXQA.mjs.map} +0 -0
- /package/dist/{chunk-MOW47IF5.mjs.map → chunk-6UYVU46O.mjs.map} +0 -0
- /package/dist/{chunk-RLGUZ3HS.mjs.map → chunk-I3OOUWO5.mjs.map} +0 -0
- /package/dist/{chunk-2LS3KKE7.mjs.map → chunk-JV7JUD7Q.mjs.map} +0 -0
- /package/dist/{chunk-Q3OX763A.mjs.map → chunk-LXDASSTE.mjs.map} +0 -0
- /package/dist/{chunk-HVG3HLQZ.mjs.map → chunk-Q7WGOOAI.mjs.map} +0 -0
- /package/dist/{chunk-3INDBMUU.mjs.map → chunk-TGDIACZT.mjs.map} +0 -0
- /package/dist/{chunk-MH27UH72.mjs.map → chunk-TT3E2JOF.mjs.map} +0 -0
- /package/dist/{chunk-UWRGX3J3.mjs.map → chunk-UMUWR5XA.mjs.map} +0 -0
- /package/dist/{devtools-S52RRRMN.mjs.map → devtools-XWZX6CCL.mjs.map} +0 -0
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
runWithServerActionRequest,
|
|
11
11
|
sanitizeServerActionError,
|
|
12
12
|
validateServerActionRequest
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-35NPLKQJ.mjs";
|
|
14
14
|
import "./chunk-ZHQMHJAV.mjs";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-34IAPZBG.mjs";
|
|
16
16
|
import "./chunk-DZU3EKQP.mjs";
|
|
17
17
|
import "./chunk-CGILA3WO.mjs";
|
|
18
18
|
export {
|
|
@@ -27,10 +27,60 @@ __export(server_fn_client_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(server_fn_client_exports);
|
|
29
29
|
var import_react = require("react");
|
|
30
|
+
|
|
31
|
+
// src/client-observers.ts
|
|
32
|
+
function notifyClientObserver(observer, args, label = "Client lifecycle") {
|
|
33
|
+
if (!observer) return;
|
|
34
|
+
const report = /* @__PURE__ */ __name((error) => {
|
|
35
|
+
const reportError = globalThis.reportError;
|
|
36
|
+
if (typeof reportError === "function") {
|
|
37
|
+
try {
|
|
38
|
+
reportError.call(globalThis, error);
|
|
39
|
+
return;
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
console.error(`[Farm.js] ${label} callback failed:`, error);
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
}, "report");
|
|
48
|
+
try {
|
|
49
|
+
const result = observer(...args);
|
|
50
|
+
if (result && typeof result.then === "function")
|
|
51
|
+
void Promise.resolve(result).catch(report);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
report(error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
__name(notifyClientObserver, "notifyClientObserver");
|
|
57
|
+
|
|
58
|
+
// src/mutation-retry.ts
|
|
59
|
+
async function invokeMutationWithRetry(invoke, retry, shouldContinue) {
|
|
60
|
+
const maxRetries = Math.max(0, retry?.count ?? 0);
|
|
61
|
+
let attempt = 0;
|
|
62
|
+
while (true) {
|
|
63
|
+
try {
|
|
64
|
+
return await invoke();
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (attempt >= maxRetries || !shouldContinue()) throw error;
|
|
67
|
+
attempt += 1;
|
|
68
|
+
const delay = typeof retry?.delay === "function" ? retry.delay(attempt) : retry?.delay ?? 0;
|
|
69
|
+
if (delay > 0) {
|
|
70
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
71
|
+
if (!shouldContinue()) throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
__name(invokeMutationWithRetry, "invokeMutationWithRetry");
|
|
77
|
+
|
|
78
|
+
// src/server-fn-client.ts
|
|
30
79
|
function useServerFn(serverFn, options = {}) {
|
|
31
80
|
const { initialResult = null, resetOnSubmit = true } = options;
|
|
32
81
|
const callbacksRef = (0, import_react.useRef)({});
|
|
33
82
|
const requestIdRef = (0, import_react.useRef)(0);
|
|
83
|
+
const lastResetIdRef = (0, import_react.useRef)(0);
|
|
34
84
|
const initialState = {
|
|
35
85
|
pendingCount: 0,
|
|
36
86
|
status: "idle",
|
|
@@ -41,11 +91,9 @@ function useServerFn(serverFn, options = {}) {
|
|
|
41
91
|
const [state, setState] = (0, import_react.useState)(initialState);
|
|
42
92
|
const setActionState = (0, import_react.useCallback)(
|
|
43
93
|
(value) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return next;
|
|
48
|
-
});
|
|
94
|
+
const next = typeof value === "function" ? value(stateRef.current) : value;
|
|
95
|
+
stateRef.current = next;
|
|
96
|
+
setState(next);
|
|
49
97
|
},
|
|
50
98
|
[]
|
|
51
99
|
);
|
|
@@ -66,63 +114,88 @@ function useServerFn(serverFn, options = {}) {
|
|
|
66
114
|
current: previousResult
|
|
67
115
|
});
|
|
68
116
|
const hasOptimisticResult = optimisticResult !== void 0;
|
|
69
|
-
setActionState((current) =>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
117
|
+
setActionState((current) => {
|
|
118
|
+
if (requestId < lastResetIdRef.current) return current;
|
|
119
|
+
const pendingCount = current.pendingCount + 1;
|
|
120
|
+
if (requestId !== requestIdRef.current) return { ...current, pendingCount };
|
|
121
|
+
return {
|
|
122
|
+
pendingCount,
|
|
123
|
+
status: "pending",
|
|
124
|
+
result: hasOptimisticResult ? optimisticResult : resetOnSubmit ? null : current.result,
|
|
125
|
+
error: null
|
|
126
|
+
};
|
|
127
|
+
});
|
|
75
128
|
try {
|
|
76
|
-
const result = await
|
|
129
|
+
const result = await invokeMutationWithRetry(
|
|
130
|
+
() => serverFn(input),
|
|
131
|
+
options.retry,
|
|
132
|
+
// A reset disowns this submission; stop scheduling retries then.
|
|
133
|
+
() => requestId >= lastResetIdRef.current
|
|
134
|
+
);
|
|
77
135
|
const isLatestRequest = requestId === requestIdRef.current;
|
|
78
136
|
setActionState((current) => {
|
|
137
|
+
if (requestId < lastResetIdRef.current) return current;
|
|
79
138
|
const pendingCount = Math.max(0, current.pendingCount - 1);
|
|
80
139
|
if (!isLatestRequest) {
|
|
81
140
|
return {
|
|
82
141
|
...current,
|
|
83
|
-
pendingCount
|
|
84
|
-
status: pendingCount > 0 ? "pending" : current.status
|
|
142
|
+
pendingCount
|
|
85
143
|
};
|
|
86
144
|
}
|
|
87
145
|
return {
|
|
88
146
|
pendingCount,
|
|
89
|
-
status:
|
|
147
|
+
status: "success",
|
|
90
148
|
result,
|
|
91
149
|
error: null
|
|
92
150
|
};
|
|
93
151
|
});
|
|
94
152
|
if (isLatestRequest) {
|
|
95
|
-
callbacksRef.current.onSuccess
|
|
96
|
-
|
|
153
|
+
notifyClientObserver(callbacksRef.current.onSuccess, [result], "Action onSuccess");
|
|
154
|
+
if (requestId === requestIdRef.current) {
|
|
155
|
+
notifyClientObserver(
|
|
156
|
+
callbacksRef.current.onSettled,
|
|
157
|
+
[result, null],
|
|
158
|
+
"Action onSettled"
|
|
159
|
+
);
|
|
160
|
+
}
|
|
97
161
|
}
|
|
98
162
|
return result;
|
|
99
163
|
} catch (cause) {
|
|
100
164
|
const error = normalizeServerFnError(cause);
|
|
101
165
|
const isLatestRequest = requestId === requestIdRef.current;
|
|
102
166
|
setActionState((current) => {
|
|
167
|
+
if (requestId < lastResetIdRef.current) return current;
|
|
103
168
|
const pendingCount = Math.max(0, current.pendingCount - 1);
|
|
104
169
|
if (!isLatestRequest) {
|
|
105
170
|
return {
|
|
106
171
|
...current,
|
|
107
|
-
pendingCount
|
|
108
|
-
status: pendingCount > 0 ? "pending" : current.status
|
|
172
|
+
pendingCount
|
|
109
173
|
};
|
|
110
174
|
}
|
|
111
175
|
return {
|
|
112
176
|
pendingCount,
|
|
113
|
-
status:
|
|
177
|
+
status: "error",
|
|
114
178
|
result: hasOptimisticResult && options.rollbackOnError ? previousResult : resetOnSubmit ? null : current.result,
|
|
115
179
|
error
|
|
116
180
|
};
|
|
117
181
|
});
|
|
118
182
|
if (isLatestRequest) {
|
|
119
|
-
callbacksRef.current.onError
|
|
120
|
-
|
|
183
|
+
notifyClientObserver(callbacksRef.current.onError, [error], "Action onError");
|
|
184
|
+
if (requestId === requestIdRef.current) {
|
|
185
|
+
notifyClientObserver(callbacksRef.current.onSettled, [null, error], "Action onSettled");
|
|
186
|
+
}
|
|
121
187
|
}
|
|
122
188
|
throw error;
|
|
123
189
|
}
|
|
124
190
|
},
|
|
125
|
-
[
|
|
191
|
+
[
|
|
192
|
+
options.optimistic,
|
|
193
|
+
options.retry,
|
|
194
|
+
options.rollbackOnError,
|
|
195
|
+
resetOnSubmit,
|
|
196
|
+
serverFn,
|
|
197
|
+
setActionState
|
|
198
|
+
]
|
|
126
199
|
);
|
|
127
200
|
const formAction = (0, import_react.useCallback)(
|
|
128
201
|
async (formData) => {
|
|
@@ -137,7 +210,7 @@ function useServerFn(serverFn, options = {}) {
|
|
|
137
210
|
[submit]
|
|
138
211
|
);
|
|
139
212
|
const reset = (0, import_react.useCallback)(() => {
|
|
140
|
-
|
|
213
|
+
lastResetIdRef.current = ++requestIdRef.current;
|
|
141
214
|
setActionState({
|
|
142
215
|
pendingCount: 0,
|
|
143
216
|
status: "idle",
|
|
@@ -162,14 +235,17 @@ __name(useServerFn, "useServerFn");
|
|
|
162
235
|
function useAction(target, options = {}) {
|
|
163
236
|
const serverFn = resolveServerFnTarget(target);
|
|
164
237
|
const action = useServerFn(serverFn, options);
|
|
238
|
+
const formActionRef = (0, import_react.useRef)(action.formAction);
|
|
239
|
+
formActionRef.current = action.formAction;
|
|
165
240
|
const Form = (0, import_react.useMemo)(() => {
|
|
241
|
+
const submitForm = /* @__PURE__ */ __name((formData) => formActionRef.current(formData), "submitForm");
|
|
166
242
|
const ActionForm = /* @__PURE__ */ __name((props) => (0, import_react.createElement)("form", {
|
|
167
243
|
...props,
|
|
168
|
-
action:
|
|
244
|
+
action: submitForm
|
|
169
245
|
}), "ActionForm");
|
|
170
246
|
ActionForm.displayName = "FarmActionForm";
|
|
171
247
|
return ActionForm;
|
|
172
|
-
}, [
|
|
248
|
+
}, []);
|
|
173
249
|
return (0, import_react.useMemo)(() => {
|
|
174
250
|
const call = /* @__PURE__ */ __name(((input) => action.submit(input)), "call");
|
|
175
251
|
return Object.assign(call, {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { FormHTMLAttributes, ComponentType } from 'react';
|
|
2
2
|
import { ServerFn } from './server-fn.mjs';
|
|
3
|
+
import { R as RetryOptions } from './client-DWoLZ3QU.mjs';
|
|
3
4
|
import './cache.mjs';
|
|
4
5
|
import './server-fn-error-DDh14a0V.mjs';
|
|
6
|
+
import './integration-api-BT024nuJ.mjs';
|
|
7
|
+
import './client-cache-CCK-fCe0.mjs';
|
|
8
|
+
import './route-CvEr4Uc9.mjs';
|
|
5
9
|
|
|
6
10
|
type ServerFnActionStatus = "idle" | "pending" | "success" | "error";
|
|
7
11
|
type ServerFnSubmit<TInput, TResult> = [unknown] extends [TInput] ? (input?: TInput | FormData) => Promise<TResult> : (input: TInput | FormData) => Promise<TResult>;
|
|
@@ -16,6 +20,8 @@ type UseServerFnOptions<TResult, TError extends Error = Error, TInput = unknown>
|
|
|
16
20
|
throwOnFormError?: boolean;
|
|
17
21
|
optimistic?: (context: ServerFnOptimisticContext<TInput, TResult>) => TResult | null | undefined;
|
|
18
22
|
rollbackOnError?: boolean;
|
|
23
|
+
/** Retry failed submissions with the API client's retry shape. Defaults to no retries. */
|
|
24
|
+
retry?: RetryOptions;
|
|
19
25
|
onSuccess?: (result: TResult) => void;
|
|
20
26
|
onError?: (error: TError) => void;
|
|
21
27
|
onSettled?: (result: TResult | null, error: TError | null) => void;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { FormHTMLAttributes, ComponentType } from 'react';
|
|
2
2
|
import { ServerFn } from './server-fn.js';
|
|
3
|
+
import { R as RetryOptions } from './client-DuQuQC1h.js';
|
|
3
4
|
import './cache.js';
|
|
4
5
|
import './server-fn-error-DDh14a0V.js';
|
|
6
|
+
import './integration-api-BT024nuJ.js';
|
|
7
|
+
import './client-cache-BMxuFqwH.js';
|
|
8
|
+
import './route-4pd-EVtw.js';
|
|
5
9
|
|
|
6
10
|
type ServerFnActionStatus = "idle" | "pending" | "success" | "error";
|
|
7
11
|
type ServerFnSubmit<TInput, TResult> = [unknown] extends [TInput] ? (input?: TInput | FormData) => Promise<TResult> : (input: TInput | FormData) => Promise<TResult>;
|
|
@@ -16,6 +20,8 @@ type UseServerFnOptions<TResult, TError extends Error = Error, TInput = unknown>
|
|
|
16
20
|
throwOnFormError?: boolean;
|
|
17
21
|
optimistic?: (context: ServerFnOptimisticContext<TInput, TResult>) => TResult | null | undefined;
|
|
18
22
|
rollbackOnError?: boolean;
|
|
23
|
+
/** Retry failed submissions with the API client's retry shape. Defaults to no retries. */
|
|
24
|
+
retry?: RetryOptions;
|
|
19
25
|
onSuccess?: (result: TResult) => void;
|
|
20
26
|
onError?: (error: TError) => void;
|
|
21
27
|
onSettled?: (result: TResult | null, error: TError | null) => void;
|
package/dist/server-fn.cjs
CHANGED
|
@@ -46,16 +46,29 @@ function getFarmCacheInvalidationState() {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
__name(getFarmCacheInvalidationState, "getFarmCacheInvalidationState");
|
|
49
|
+
function warnFarmCacheListenerError(scope, error) {
|
|
50
|
+
const detail = error instanceof Error ? error.stack ?? error.message : String(error);
|
|
51
|
+
console.warn(`[farm:cache] ${scope} listener failed: ${detail}`);
|
|
52
|
+
}
|
|
53
|
+
__name(warnFarmCacheListenerError, "warnFarmCacheListenerError");
|
|
49
54
|
function notifyFarmCacheInvalidation(key) {
|
|
50
55
|
if (typeof key !== "string" || key.length === 0) return;
|
|
51
56
|
for (const listener of getFarmCacheInvalidationState().listeners) {
|
|
52
|
-
|
|
57
|
+
try {
|
|
58
|
+
listener(key);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
warnFarmCacheListenerError("invalidation", error);
|
|
61
|
+
}
|
|
53
62
|
}
|
|
54
63
|
}
|
|
55
64
|
__name(notifyFarmCacheInvalidation, "notifyFarmCacheInvalidation");
|
|
56
65
|
function notifyFarmCacheTask(task) {
|
|
57
66
|
for (const listener of getFarmCacheInvalidationState().taskListeners) {
|
|
58
|
-
|
|
67
|
+
try {
|
|
68
|
+
listener(task);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
warnFarmCacheListenerError("task", error);
|
|
71
|
+
}
|
|
59
72
|
}
|
|
60
73
|
}
|
|
61
74
|
__name(notifyFarmCacheTask, "notifyFarmCacheTask");
|
|
@@ -235,7 +248,13 @@ function recordFarmEventTrace(event) {
|
|
|
235
248
|
activeSpan.addEvent(event.type, toEventAttributes(event), event.timestamp);
|
|
236
249
|
}
|
|
237
250
|
const error = event.type === "request.error" ? void 0 : getEventError(event);
|
|
238
|
-
if (error !== void 0)
|
|
251
|
+
if (error !== void 0) {
|
|
252
|
+
if (event.type === "render.error") {
|
|
253
|
+
recordSpanException(activeSpan, error);
|
|
254
|
+
} else {
|
|
255
|
+
recordSpanError(activeSpan, error);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
239
258
|
}
|
|
240
259
|
const completedTraceContext = recordCompletedEventSpan(event, activeContext);
|
|
241
260
|
return traceContext ?? completedTraceContext;
|
|
@@ -332,12 +351,26 @@ function getCompletedSpanDescriptor(event) {
|
|
|
332
351
|
}
|
|
333
352
|
}
|
|
334
353
|
__name(getCompletedSpanDescriptor, "getCompletedSpanDescriptor");
|
|
354
|
+
function hashFarmCacheKey(value) {
|
|
355
|
+
let hash = 2166136261;
|
|
356
|
+
for (let index = 0; index < value.length; index++) {
|
|
357
|
+
hash ^= value.charCodeAt(index);
|
|
358
|
+
hash = Math.imul(hash, 16777619);
|
|
359
|
+
}
|
|
360
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
361
|
+
}
|
|
362
|
+
__name(hashFarmCacheKey, "hashFarmCacheKey");
|
|
335
363
|
function toEventAttributes(event) {
|
|
336
364
|
const attributes = {};
|
|
365
|
+
const redactKey = typeof event.type === "string" && event.type.startsWith("cache.");
|
|
337
366
|
for (const [key, value] of Object.entries(event)) {
|
|
338
367
|
if (key === "timestamp" || key === "level" || key === "error" || key === "traceId" || key === "spanId" || key === "traceSampled" || value === void 0) {
|
|
339
368
|
continue;
|
|
340
369
|
}
|
|
370
|
+
if (redactKey && key === "key" && typeof value === "string") {
|
|
371
|
+
attributes["farm.key_hash"] = hashFarmCacheKey(value);
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
341
374
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
342
375
|
attributes[`farm.${key}`] = value;
|
|
343
376
|
} else if (Array.isArray(value)) {
|
|
@@ -357,9 +390,14 @@ function getEventError(event) {
|
|
|
357
390
|
return "error" in event ? event.error : void 0;
|
|
358
391
|
}
|
|
359
392
|
__name(getEventError, "getEventError");
|
|
360
|
-
function
|
|
393
|
+
function recordSpanException(span, error) {
|
|
361
394
|
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
362
395
|
span.recordException(normalized);
|
|
396
|
+
return normalized;
|
|
397
|
+
}
|
|
398
|
+
__name(recordSpanException, "recordSpanException");
|
|
399
|
+
function recordSpanError(span, error) {
|
|
400
|
+
const normalized = recordSpanException(span, error);
|
|
363
401
|
span.setStatus({ code: import_api.SpanStatusCode.ERROR, message: normalized.message });
|
|
364
402
|
}
|
|
365
403
|
__name(recordSpanError, "recordSpanError");
|
package/dist/server-fn.mjs
CHANGED
|
@@ -3,19 +3,19 @@ import {
|
|
|
3
3
|
_parseServerFnSchema,
|
|
4
4
|
createServerFn,
|
|
5
5
|
createServerMiddleware
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-I3OOUWO5.mjs";
|
|
7
7
|
import {
|
|
8
8
|
FARM_SERVER_FN_FAILURE_SYMBOL,
|
|
9
9
|
ServerActionError,
|
|
10
10
|
ServerFnFailure,
|
|
11
11
|
createServerFnTransportError,
|
|
12
12
|
isServerFnFailure
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-35NPLKQJ.mjs";
|
|
14
14
|
import "./chunk-ZHQMHJAV.mjs";
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-2HDOV47R.mjs";
|
|
16
|
+
import "./chunk-34IAPZBG.mjs";
|
|
17
17
|
import "./chunk-WZ5QFROO.mjs";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-N2FY2QZ7.mjs";
|
|
19
19
|
import "./chunk-LM2YNO4U.mjs";
|
|
20
20
|
import "./chunk-DZU3EKQP.mjs";
|
|
21
21
|
import "./chunk-CGILA3WO.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { bx as RedirectConfig, Y as FarmRequest, Z as FarmResponse, aV as FarmPluginContext, a as FarmPlugin, by as HeaderConfig, bz as RewriteConfig } from './client-plugins-B6-07YmP.mjs';
|
|
2
|
+
export { aX as FarmPluginLifecycle, aY as FarmRequestPluginContext, aZ as FarmRequestStore } from './client-plugins-B6-07YmP.mjs';
|
|
3
3
|
import { R as ResolvedFarmI18nConfig } from './types-CnH8DOqo.mjs';
|
|
4
4
|
import './lifecycle-De0vQG45.mjs';
|
|
5
|
-
import './route-
|
|
5
|
+
import './route-CvEr4Uc9.mjs';
|
|
6
6
|
import './cache.mjs';
|
|
7
7
|
import './renderer.mjs';
|
|
8
8
|
import 'http';
|
|
@@ -10,6 +10,7 @@ import './types-Cc8l9IqS.mjs';
|
|
|
10
10
|
import 'db0';
|
|
11
11
|
import 'unstorage';
|
|
12
12
|
import 'react';
|
|
13
|
+
import './integration-api-BT024nuJ.mjs';
|
|
13
14
|
import '@farming-labs/orm';
|
|
14
15
|
import './types-CKwggz9n.mjs';
|
|
15
16
|
import '@farming-labs/docs';
|
package/dist/server-plugins.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { bx as RedirectConfig, Y as FarmRequest, Z as FarmResponse, aV as FarmPluginContext, a as FarmPlugin, by as HeaderConfig, bz as RewriteConfig } from './client-plugins-By6MVUX-.js';
|
|
2
|
+
export { aX as FarmPluginLifecycle, aY as FarmRequestPluginContext, aZ as FarmRequestStore } from './client-plugins-By6MVUX-.js';
|
|
3
3
|
import { R as ResolvedFarmI18nConfig } from './types-CnH8DOqo.js';
|
|
4
4
|
import './lifecycle-De0vQG45.js';
|
|
5
|
-
import './route-
|
|
5
|
+
import './route-4pd-EVtw.js';
|
|
6
6
|
import './cache.js';
|
|
7
7
|
import './renderer.js';
|
|
8
8
|
import 'http';
|
|
@@ -10,6 +10,7 @@ import './types-Cc8l9IqS.js';
|
|
|
10
10
|
import 'db0';
|
|
11
11
|
import 'unstorage';
|
|
12
12
|
import 'react';
|
|
13
|
+
import './integration-api-BT024nuJ.js';
|
|
13
14
|
import '@farming-labs/orm';
|
|
14
15
|
import './types-CKwggz9n.js';
|
|
15
16
|
import '@farming-labs/docs';
|