@farm.js/core 0.1.17 → 0.1.18
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 +12 -225
- package/dist/agent-runtime.cjs +83 -2800
- package/dist/api/client.cjs +17 -4060
- package/dist/api/route-manager.cjs +34 -4354
- package/dist/api/runtime.cjs +29 -2696
- package/dist/api.cjs +88 -8434
- package/dist/app-markdown.cjs +39 -280
- package/dist/cache.cjs +38 -1560
- package/dist/chunk-22GUSVNJ.cjs +351 -0
- package/dist/chunk-2CQ74SP6.cjs +13 -0
- package/dist/chunk-2SJ4RQ6P.cjs +57 -0
- package/dist/chunk-3376ZTRC.cjs +1 -0
- package/dist/{chunk-YD4J4XCI.mjs → chunk-3XG26Z3J.mjs} +1 -1
- package/dist/chunk-4PNUXIVU.cjs +472 -0
- package/dist/chunk-4PPEPOZZ.cjs +21 -0
- package/dist/chunk-4ZFL5GFN.cjs +520 -0
- package/dist/chunk-5OVTOKGH.cjs +65 -0
- package/dist/chunk-5QIKR7RR.cjs +224 -0
- package/dist/chunk-5ZSWG4UX.cjs +127 -0
- package/dist/chunk-62YJ2IEB.cjs +238 -0
- package/dist/chunk-6EODJYCX.cjs +183 -0
- package/dist/chunk-6EXBPJ24.cjs +434 -0
- package/dist/chunk-6QQDAAAZ.cjs +38 -0
- package/dist/chunk-6V4TDWEC.cjs +455 -0
- package/dist/chunk-72ADZ6GQ.cjs +19 -0
- package/dist/chunk-75BRBIFP.cjs +172 -0
- package/dist/chunk-7W3CPVXS.cjs +24 -0
- package/dist/chunk-A6WIQH5Z.cjs +31 -0
- package/dist/chunk-AFOD3LYZ.cjs +377 -0
- package/dist/chunk-AMDMVWMI.cjs +39 -0
- package/dist/chunk-AORPIPNB.cjs +552 -0
- package/dist/chunk-ARJWXNQL.cjs +256 -0
- package/dist/chunk-AWRISO2H.cjs +2199 -0
- package/dist/chunk-AYJR42WX.cjs +711 -0
- package/dist/chunk-B4CH33IG.cjs +644 -0
- package/dist/chunk-BIDYX3SL.cjs +91 -0
- package/dist/chunk-BSTRERPP.cjs +40 -0
- package/dist/chunk-BYODCJD6.cjs +663 -0
- package/dist/chunk-C3VRMB6H.cjs +85 -0
- package/dist/chunk-C5GUTBZK.cjs +173 -0
- package/dist/chunk-CIAGU2X4.cjs +337 -0
- package/dist/chunk-CMGMGHUZ.cjs +27 -0
- package/dist/chunk-CXP5U3RW.cjs +54 -0
- package/dist/chunk-D2ULAULS.cjs +166 -0
- package/dist/chunk-D7JTOLFK.cjs +285 -0
- package/dist/chunk-DVM4FKZL.cjs +169 -0
- package/dist/chunk-DYEJQTDN.cjs +49 -0
- package/dist/chunk-E2BMSZ2W.cjs +151 -0
- package/dist/chunk-E3UK5IIB.cjs +593 -0
- package/dist/chunk-EM6SBQKM.cjs +470 -0
- package/dist/chunk-FJSWYIR7.cjs +482 -0
- package/dist/chunk-FK6GO24V.cjs +54 -0
- package/dist/chunk-FXUUWYAX.cjs +654 -0
- package/dist/chunk-G3HRIVEY.cjs +395 -0
- package/dist/chunk-G643DQCH.cjs +13 -0
- package/dist/chunk-G7HXGLEC.cjs +175 -0
- package/dist/chunk-GDSHDTJ4.cjs +152 -0
- package/dist/chunk-GNEO2XOF.cjs +2040 -0
- package/dist/{chunk-56DAX2BE.mjs → chunk-GYKJCFTS.mjs} +1 -1
- package/dist/chunk-H6G5INWM.cjs +1094 -0
- package/dist/chunk-HBTUGXHS.cjs +180 -0
- package/dist/chunk-HREOKQWT.cjs +45 -0
- package/dist/chunk-I4J452B7.cjs +435 -0
- package/dist/chunk-I57LW5VZ.cjs +94 -0
- package/dist/chunk-I7PUUDGY.cjs +389 -0
- package/dist/chunk-IAMRBF3Z.cjs +86 -0
- package/dist/chunk-IKNRN4VS.cjs +14214 -0
- package/dist/chunk-IQXFRNY2.cjs +169 -0
- package/dist/chunk-IXTFU4PL.cjs +2355 -0
- package/dist/chunk-J2OP5GG3.cjs +725 -0
- package/dist/chunk-J3LOGE4T.cjs +42 -0
- package/dist/chunk-J7FSKED3.cjs +93 -0
- package/dist/chunk-JDNHKPTD.cjs +22 -0
- package/dist/chunk-JSROZYYO.cjs +164 -0
- package/dist/chunk-K6FNHVDR.cjs +696 -0
- package/dist/chunk-KGZIORNL.cjs +43 -0
- package/dist/{chunk-MVIWBEJF.mjs → chunk-KPNVGRBL.mjs} +1 -1
- package/dist/chunk-KR6CKSXT.cjs +15 -0
- package/dist/chunk-KROWKCUH.cjs +185 -0
- package/dist/chunk-KVFPGF2M.cjs +46 -0
- package/dist/chunk-LCCBO7PJ.cjs +46 -0
- package/dist/chunk-LIUGYUX3.cjs +22 -0
- package/dist/chunk-LTNGXMQ6.cjs +55 -0
- package/dist/chunk-M2L4MYDQ.cjs +14 -0
- package/dist/chunk-MCJLA63J.cjs +1 -0
- package/dist/chunk-MKB2EGIR.cjs +148 -0
- package/dist/chunk-MQ3H6LT5.cjs +202 -0
- package/dist/chunk-MT763TDW.cjs +43 -0
- package/dist/chunk-MWSK6C4J.cjs +18 -0
- package/dist/chunk-MWWVKDW3.cjs +169 -0
- package/dist/chunk-NO3WWW3N.cjs +192 -0
- package/dist/chunk-NV3A5DXM.cjs +862 -0
- package/dist/chunk-NWOD6NIT.cjs +9 -0
- package/dist/chunk-NZKJGRB3.cjs +230 -0
- package/dist/chunk-OAVTUMJP.cjs +1496 -0
- package/dist/chunk-OHY2ZWUG.cjs +25 -0
- package/dist/chunk-OI6CMLWX.cjs +47 -0
- package/dist/chunk-OIEOCXKG.cjs +453 -0
- package/dist/chunk-OWOUTKIJ.cjs +558 -0
- package/dist/chunk-OX6O6WVA.cjs +74 -0
- package/dist/chunk-OXSIH4D6.cjs +476 -0
- package/dist/chunk-OYEUREB6.cjs +35 -0
- package/dist/chunk-PCOTGFSM.cjs +139 -0
- package/dist/chunk-PZYCPSCC.cjs +35 -0
- package/dist/chunk-QBK2AA4U.cjs +445 -0
- package/dist/chunk-QBPXNZGV.cjs +487 -0
- package/dist/chunk-QNPEUFHQ.cjs +27 -0
- package/dist/chunk-QZRVZSPN.cjs +236 -0
- package/dist/chunk-R5A5KNVX.cjs +20 -0
- package/dist/chunk-R5JIFR6B.cjs +42 -0
- package/dist/chunk-R6AIILII.cjs +193 -0
- package/dist/chunk-RG3ZOTG5.cjs +34 -0
- package/dist/chunk-ROUTX2E5.cjs +390 -0
- package/dist/chunk-RTHIVJ2G.cjs +54 -0
- package/dist/chunk-S3A45T7F.cjs +166 -0
- package/dist/chunk-S3JO3N4H.cjs +17 -0
- package/dist/chunk-SK35NQKK.cjs +27 -0
- package/dist/chunk-SU7MH53P.cjs +180 -0
- package/dist/chunk-SVRTJOUF.cjs +113 -0
- package/dist/chunk-SWN467MP.cjs +18 -0
- package/dist/chunk-SYQ3MOWW.cjs +73 -0
- package/dist/chunk-T5CERMEH.cjs +417 -0
- package/dist/chunk-TFAXUHWX.cjs +206 -0
- package/dist/chunk-TIWHTW3Q.cjs +24 -0
- package/dist/chunk-TKJZFIML.cjs +20 -0
- package/dist/chunk-TKNSDBBN.cjs +193 -0
- package/dist/chunk-TWGMSEHX.cjs +525 -0
- package/dist/chunk-TYQUSXUG.cjs +1357 -0
- package/dist/chunk-U4KT7QP3.cjs +23 -0
- package/dist/chunk-UJ2C4ICS.cjs +277 -0
- package/dist/chunk-UN5GHC5V.cjs +10244 -0
- package/dist/chunk-UQZ4AYTH.cjs +168 -0
- package/dist/chunk-US2QVW3E.cjs +36 -0
- package/dist/chunk-VB6UCX3V.cjs +421 -0
- package/dist/chunk-VEKFLAQM.cjs +300 -0
- package/dist/chunk-VQDBNVOO.cjs +14 -0
- package/dist/chunk-W4E7WMXE.cjs +71 -0
- package/dist/chunk-WJ3HK3LJ.cjs +1102 -0
- package/dist/chunk-WMAPPDMM.cjs +28 -0
- package/dist/chunk-WMOGFOUJ.cjs +223 -0
- package/dist/chunk-WPYFSQKK.cjs +37 -0
- package/dist/chunk-WZMNW2IW.cjs +1415 -0
- package/dist/chunk-XGC343EY.cjs +443 -0
- package/dist/chunk-XSKZORAS.cjs +727 -0
- package/dist/chunk-XWAWFQFS.cjs +82 -0
- package/dist/chunk-Y4YMF2NQ.cjs +460 -0
- package/dist/chunk-Y4YWHNKU.cjs +250 -0
- package/dist/chunk-Y53ZSFN6.cjs +504 -0
- package/dist/chunk-YA6LLTIJ.cjs +411 -0
- package/dist/chunk-YFPGHF5F.cjs +202 -0
- package/dist/chunk-YJRZR7VU.cjs +28 -0
- package/dist/chunk-YTAABQEV.cjs +1 -0
- package/dist/chunk-YX3DBN4M.cjs +18 -0
- package/dist/chunk-YZTASLPQ.cjs +64 -0
- package/dist/chunk-Z5HIWVDP.cjs +2173 -0
- package/dist/chunk-ZEG3OPIB.cjs +93 -0
- package/dist/chunk-ZMN3H73H.cjs +155 -0
- package/dist/client/lifecycle.cjs +6 -35
- package/dist/client-plugins.cjs +7 -448
- package/dist/client.cjs +171 -9808
- package/dist/config.cjs +8 -36
- package/dist/cron.cjs +24 -491
- package/dist/deferred.cjs +26 -475
- package/dist/deployment.cjs +39 -210
- package/dist/devtools-OUIPHVV6.cjs +388 -0
- package/dist/devtools-client-4WAPJY5L.cjs +254 -0
- package/dist/devtools-ui-5GBDIGMK.cjs +1296 -0
- package/dist/docs.cjs +46 -5657
- package/dist/env-types.cjs +5 -226
- package/dist/env.cjs +21 -338
- package/dist/environment/vite.cjs +8 -372
- package/dist/environment.cjs +12 -94
- package/dist/font.cjs +13 -63
- package/dist/headers.cjs +7 -123
- package/dist/i18n/client.cjs +55 -294
- package/dist/i18n/index.cjs +22 -209
- package/dist/i18n/server.cjs +22 -745
- package/dist/image/server.cjs +13 -729
- package/dist/image/sharp.cjs +33 -171
- package/dist/image.cjs +41 -85
- package/dist/index.cjs +1151 -68080
- package/dist/index.mjs +3 -3
- package/dist/instrumentation.cjs +12 -138
- package/dist/integration-orm-55F7CII5.cjs +13 -0
- package/dist/integrations.cjs +55 -4090
- package/dist/internal/app-markdown-runtime.cjs +27 -224
- package/dist/internal/build-runtime.cjs +120 -52259
- package/dist/internal/build-runtime.mjs +3 -3
- package/dist/internal/cli-runtime.cjs +67 -13811
- package/dist/internal/client-error-overlay.cjs +80 -733
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +81 -913
- package/dist/internal/compression-runtime.cjs +8 -214
- package/dist/internal/config-runtime.cjs +42 -6547
- package/dist/internal/docs-precompiled-runtime.cjs +26 -46
- package/dist/internal/infra-analytics-runtime.cjs +10 -536
- package/dist/internal/isolated-boundary.cjs +14 -414
- package/dist/internal/metadata-image-runtime.cjs +7 -285
- package/dist/internal/product-telemetry-runtime.cjs +42 -97
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-node-env.cjs +6 -63
- package/dist/internal/production-runtime.cjs +418 -7133
- package/dist/internal/request-cookies.cjs +6 -54
- package/dist/json-ld.cjs +24 -50
- package/dist/layers-E4WPJNY5.cjs +17 -0
- package/dist/manager-G4B2IPYE.cjs +14 -0
- package/dist/markdown.cjs +21 -547
- package/dist/middleware.cjs +36 -2995
- package/dist/navigation.cjs +22 -2588
- package/dist/nitro-4I2MYLY2.cjs +652 -0
- package/dist/observability.cjs +22 -614
- package/dist/og.cjs +5 -28
- package/dist/plugin.cjs +106 -37442
- package/dist/plugin.mjs +2 -2
- package/dist/query/client.cjs +113 -449
- package/dist/query/index.cjs +26 -288
- package/dist/query/parsers.cjs +23 -247
- package/dist/query/server.cjs +36 -298
- package/dist/renderer/react/client.cjs +9 -43
- package/dist/renderer/react/server.cjs +40 -103
- package/dist/renderer/react/vite.cjs +7 -29
- package/dist/renderer-client.cjs +126 -4295
- package/dist/renderer.cjs +31 -249
- package/dist/request.cjs +5 -68
- package/dist/router.cjs +11 -474
- package/dist/routes.cjs +42 -2461
- package/dist/schema-dev-notice-MXSZMVDG.cjs +56 -0
- package/dist/schema.cjs +6 -33
- package/dist/search-client-G3RICOFU.cjs +13 -0
- package/dist/server-action-security.cjs +25 -541
- package/dist/server-fn-client.cjs +6 -337
- package/dist/server-fn.cjs +32 -1841
- package/dist/server-plugins.cjs +15 -884
- package/dist/server-query-client.cjs +15 -1883
- package/dist/server-query.cjs +16 -1838
- package/dist/server.cjs +296 -44681
- package/dist/server.mjs +2 -2
- package/dist/storage.cjs +57 -576
- package/dist/testing.cjs +89 -3186
- package/dist/theme/client.cjs +13 -108
- package/dist/theme/index.cjs +6 -68
- package/dist/theme/runtime.cjs +13 -78
- package/dist/theme/server.cjs +10 -179
- package/dist/version.cjs +4 -32
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +119 -37773
- package/dist/vite.mjs +2 -2
- package/dist/workflows.cjs +19 -1040
- package/package.json +1 -1
|
@@ -1,231 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
30
2
|
|
|
31
|
-
|
|
32
|
-
var production_runtime_exports = {};
|
|
33
|
-
__export(production_runtime_exports, {
|
|
34
|
-
createClientCancellation: () => createClientCancellation,
|
|
35
|
-
createClientPluginManager: () => createClientPluginManager,
|
|
36
|
-
getHashTargetElement: () => getHashTargetElement,
|
|
37
|
-
installChunkErrorRecovery: () => installChunkErrorRecovery,
|
|
38
|
-
isFarmExternalNavigationURL: () => isFarmExternalNavigationURL,
|
|
39
|
-
reconcileFarmDocumentHead: () => reconcileFarmDocumentHead,
|
|
40
|
-
replayFarmQueuedInteraction: () => replayFarmQueuedInteraction,
|
|
41
|
-
scheduleFarmIslandHydration: () => scheduleFarmIslandHydration,
|
|
42
|
-
searchParamsToObject: () => searchParamsToObject,
|
|
43
|
-
setFarmBasePath: () => setFarmBasePath,
|
|
44
|
-
setFarmTrailingSlashPreference: () => setFarmTrailingSlashPreference,
|
|
45
|
-
stripFarmBasePath: () => stripFarmBasePath
|
|
46
|
-
});
|
|
47
|
-
module.exports = __toCommonJS(production_runtime_exports);
|
|
3
|
+
var _chunkKGZIORNLcjs = require('../chunk-KGZIORNL.cjs');
|
|
48
4
|
|
|
49
|
-
// src/client/chunk-recovery.ts
|
|
50
|
-
var DEFAULT_MAX_AGE_MS = 3e4;
|
|
51
|
-
var STORAGE_KEY_PREFIX = "farm:chunk-recovery:";
|
|
52
|
-
var CHUNK_ERROR_PATTERNS = [
|
|
53
|
-
/ChunkLoadError/i,
|
|
54
|
-
/Loading chunk [\w-]+ failed/i,
|
|
55
|
-
/Loading CSS chunk [\w-]+ failed/i,
|
|
56
|
-
/CSS_CHUNK_LOAD_FAILED/i,
|
|
57
|
-
/failed to fetch dynamically imported module/i,
|
|
58
|
-
/error loading dynamically imported module/i,
|
|
59
|
-
/importing a module script failed/i,
|
|
60
|
-
/unable to preload CSS/i,
|
|
61
|
-
/module script failed/i
|
|
62
|
-
];
|
|
63
|
-
function isChunkLoadError(errorLike) {
|
|
64
|
-
const values = collectErrorText(errorLike);
|
|
65
|
-
if (values.some((value) => CHUNK_ERROR_PATTERNS.some((pattern) => pattern.test(value)))) {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
const targetUrl = getEventTargetAssetUrl(errorLike);
|
|
69
|
-
return Boolean(
|
|
70
|
-
targetUrl && /\.(?:m?js|css)(?:[?#].*)?$/i.test(targetUrl) && isSameOriginAssetUrl(targetUrl)
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
__name(isChunkLoadError, "isChunkLoadError");
|
|
74
|
-
function isSameOriginAssetUrl(url) {
|
|
75
|
-
if (typeof window === "undefined" || !window.location) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
return new URL(url, window.location.href).origin === window.location.origin;
|
|
80
|
-
} catch {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
__name(isSameOriginAssetUrl, "isSameOriginAssetUrl");
|
|
85
|
-
function installChunkErrorRecovery(options = {}) {
|
|
86
|
-
if (typeof window === "undefined") {
|
|
87
|
-
return () => {
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
const recover = /* @__PURE__ */ __name((errorLike) => {
|
|
91
|
-
if (!isChunkLoadError(errorLike)) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (!markRecovered(options)) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
options.onRecover?.(errorLike);
|
|
98
|
-
getReload(options)();
|
|
99
|
-
}, "recover");
|
|
100
|
-
const onError = /* @__PURE__ */ __name((event) => {
|
|
101
|
-
recover(getErrorEventPayload(event));
|
|
102
|
-
}, "onError");
|
|
103
|
-
const onUnhandledRejection = /* @__PURE__ */ __name((event) => {
|
|
104
|
-
recover(event.reason);
|
|
105
|
-
}, "onUnhandledRejection");
|
|
106
|
-
window.addEventListener("error", onError, true);
|
|
107
|
-
window.addEventListener("unhandledrejection", onUnhandledRejection);
|
|
108
|
-
return () => {
|
|
109
|
-
window.removeEventListener("error", onError, true);
|
|
110
|
-
window.removeEventListener("unhandledrejection", onUnhandledRejection);
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
__name(installChunkErrorRecovery, "installChunkErrorRecovery");
|
|
114
|
-
function markRecovered(options) {
|
|
115
|
-
const now2 = getNow(options);
|
|
116
|
-
const maxAgeMs = options.maxAgeMs ?? DEFAULT_MAX_AGE_MS;
|
|
117
|
-
const storage = getStorage(options);
|
|
118
|
-
const key = getStorageKey(options);
|
|
119
|
-
if (!storage) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
123
|
-
const previous = Number(storage.getItem(key));
|
|
124
|
-
if (Number.isFinite(previous) && previous > 0 && now2 - previous < maxAgeMs) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
storage.setItem(key, String(now2));
|
|
128
|
-
return true;
|
|
129
|
-
} catch {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
__name(markRecovered, "markRecovered");
|
|
134
|
-
function getErrorEventPayload(event) {
|
|
135
|
-
if ("error" in event && event.error) {
|
|
136
|
-
return event.error;
|
|
137
|
-
}
|
|
138
|
-
if ("message" in event && event.message) {
|
|
139
|
-
return event.message;
|
|
140
|
-
}
|
|
141
|
-
return event;
|
|
142
|
-
}
|
|
143
|
-
__name(getErrorEventPayload, "getErrorEventPayload");
|
|
144
|
-
function collectErrorText(value, seen = /* @__PURE__ */ new Set()) {
|
|
145
|
-
if (value == null || seen.has(value)) {
|
|
146
|
-
return [];
|
|
147
|
-
}
|
|
148
|
-
seen.add(value);
|
|
149
|
-
if (typeof value === "string") {
|
|
150
|
-
return [value];
|
|
151
|
-
}
|
|
152
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
153
|
-
return [String(value)];
|
|
154
|
-
}
|
|
155
|
-
if (typeof value !== "object") {
|
|
156
|
-
return [];
|
|
157
|
-
}
|
|
158
|
-
const record = value;
|
|
159
|
-
const output = [];
|
|
160
|
-
for (const key of ["name", "message", "code", "type", "request", "src", "href"]) {
|
|
161
|
-
const candidate = record[key];
|
|
162
|
-
if (typeof candidate === "string") {
|
|
163
|
-
output.push(candidate);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if ("reason" in record) {
|
|
167
|
-
output.push(...collectErrorText(record.reason, seen));
|
|
168
|
-
}
|
|
169
|
-
if ("error" in record) {
|
|
170
|
-
output.push(...collectErrorText(record.error, seen));
|
|
171
|
-
}
|
|
172
|
-
return output;
|
|
173
|
-
}
|
|
174
|
-
__name(collectErrorText, "collectErrorText");
|
|
175
|
-
function getEventTargetAssetUrl(value) {
|
|
176
|
-
if (!value || typeof value !== "object") {
|
|
177
|
-
return void 0;
|
|
178
|
-
}
|
|
179
|
-
const target = value.target;
|
|
180
|
-
if (!target || typeof target !== "object") {
|
|
181
|
-
return void 0;
|
|
182
|
-
}
|
|
183
|
-
const tagName = typeof target.tagName === "string" ? target.tagName.toLowerCase() : "";
|
|
184
|
-
if (tagName !== "script" && tagName !== "link") {
|
|
185
|
-
return void 0;
|
|
186
|
-
}
|
|
187
|
-
return typeof target.src === "string" && target.src ? target.src : typeof target.href === "string" && target.href ? target.href : void 0;
|
|
188
|
-
}
|
|
189
|
-
__name(getEventTargetAssetUrl, "getEventTargetAssetUrl");
|
|
190
|
-
function getStorage(options) {
|
|
191
|
-
if ("storage" in options) {
|
|
192
|
-
return options.storage;
|
|
193
|
-
}
|
|
194
|
-
try {
|
|
195
|
-
return window.sessionStorage;
|
|
196
|
-
} catch {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
__name(getStorage, "getStorage");
|
|
201
|
-
function getStorageKey(options) {
|
|
202
|
-
if (options.storageKey) {
|
|
203
|
-
return options.storageKey;
|
|
204
|
-
}
|
|
205
|
-
const location = getLocation(options);
|
|
206
|
-
return `${STORAGE_KEY_PREFIX}${location.pathname}${location.search}`;
|
|
207
|
-
}
|
|
208
|
-
__name(getStorageKey, "getStorageKey");
|
|
209
|
-
function getLocation(options) {
|
|
210
|
-
return options.location ?? window.location;
|
|
211
|
-
}
|
|
212
|
-
__name(getLocation, "getLocation");
|
|
213
|
-
function getReload(options) {
|
|
214
|
-
if (options.reload) {
|
|
215
|
-
return options.reload;
|
|
216
|
-
}
|
|
217
|
-
const location = getLocation(options);
|
|
218
|
-
return () => location.reload();
|
|
219
|
-
}
|
|
220
|
-
__name(getReload, "getReload");
|
|
221
|
-
function getNow(options) {
|
|
222
|
-
return options.now ? options.now() : Date.now();
|
|
223
|
-
}
|
|
224
|
-
__name(getNow, "getNow");
|
|
225
5
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
6
|
+
var _chunkKROWKCUHcjs = require('../chunk-KROWKCUH.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkR5A5KNVXcjs = require('../chunk-R5A5KNVX.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkSWN467MPcjs = require('../chunk-SWN467MP.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunkJ7FSKED3cjs = require('../chunk-J7FSKED3.cjs');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var _chunkVB6UCX3Vcjs = require('../chunk-VB6UCX3V.cjs');
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
var _chunkMWSK6C4Jcjs = require('../chunk-MWSK6C4J.cjs');
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var _chunkQNPEUFHQcjs = require('../chunk-QNPEUFHQ.cjs');
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
var _chunkOYEUREB6cjs = require('../chunk-OYEUREB6.cjs');
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
var _chunkI57LW5VZcjs = require('../chunk-I57LW5VZ.cjs');
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
var _chunkS3JO3N4Hcjs = require('../chunk-S3JO3N4H.cjs');
|
|
229
36
|
|
|
230
37
|
// src/client/island-triggers.ts
|
|
231
38
|
var visibilityRegistries = /* @__PURE__ */ new WeakMap();
|
|
@@ -238,7 +45,7 @@ function observeIslandVisibility(document2, targets, start) {
|
|
|
238
45
|
const pending = /* @__PURE__ */ new Set();
|
|
239
46
|
for (const entry of entries) {
|
|
240
47
|
if (entry.isIntersecting) {
|
|
241
|
-
for (const callback of subscriptions.get(entry.target)
|
|
48
|
+
for (const callback of _nullishCoalesce(subscriptions.get(entry.target), () => ( []))) pending.add(callback);
|
|
242
49
|
}
|
|
243
50
|
}
|
|
244
51
|
for (const callback of pending) callback();
|
|
@@ -263,8 +70,8 @@ function observeIslandVisibility(document2, targets, start) {
|
|
|
263
70
|
active = false;
|
|
264
71
|
for (const target of targets) {
|
|
265
72
|
const callbacks = registry.targets.get(target);
|
|
266
|
-
callbacks
|
|
267
|
-
if (callbacks
|
|
73
|
+
_optionalChain([callbacks, 'optionalAccess', _ => _.delete, 'call', _2 => _2(start)]);
|
|
74
|
+
if (_optionalChain([callbacks, 'optionalAccess', _3 => _3.size]) === 0) {
|
|
268
75
|
registry.targets.delete(target);
|
|
269
76
|
registry.observer.unobserve(target);
|
|
270
77
|
}
|
|
@@ -275,53 +82,53 @@ function observeIslandVisibility(document2, targets, start) {
|
|
|
275
82
|
}
|
|
276
83
|
};
|
|
277
84
|
}
|
|
278
|
-
__name(observeIslandVisibility, "observeIslandVisibility");
|
|
85
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, observeIslandVisibility, "observeIslandVisibility");
|
|
279
86
|
|
|
280
87
|
// src/client/island-runtime.ts
|
|
281
88
|
function toReplayKind(value) {
|
|
282
89
|
return value === "submit" ? "submit" : "click";
|
|
283
90
|
}
|
|
284
|
-
__name(toReplayKind, "toReplayKind");
|
|
91
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, toReplayKind, "toReplayKind");
|
|
285
92
|
function getPreHydrationClickQueue() {
|
|
286
93
|
const windowWithQueue = window;
|
|
287
94
|
return Array.isArray(windowWithQueue.__FARM_PREHYDRATION_CLICK_QUEUE__) ? windowWithQueue.__FARM_PREHYDRATION_CLICK_QUEUE__ : null;
|
|
288
95
|
}
|
|
289
|
-
__name(getPreHydrationClickQueue, "getPreHydrationClickQueue");
|
|
96
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getPreHydrationClickQueue, "getPreHydrationClickQueue");
|
|
290
97
|
function findQueuedTarget(container) {
|
|
291
98
|
const queue = getPreHydrationClickQueue();
|
|
292
99
|
if (!queue) return null;
|
|
293
100
|
for (const item of queue) {
|
|
294
|
-
if (item
|
|
101
|
+
if (_optionalChain([item, 'optionalAccess', _4 => _4.target]) instanceof Element && container.contains(item.target)) {
|
|
295
102
|
return { target: item.target, kind: toReplayKind(item.kind) };
|
|
296
103
|
}
|
|
297
104
|
}
|
|
298
105
|
return null;
|
|
299
106
|
}
|
|
300
|
-
__name(findQueuedTarget, "findQueuedTarget");
|
|
107
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, findQueuedTarget, "findQueuedTarget");
|
|
301
108
|
function takeQueuedTargets(container) {
|
|
302
109
|
const queue = getPreHydrationClickQueue();
|
|
303
110
|
if (!queue) return [];
|
|
304
111
|
const interactions = [];
|
|
305
112
|
for (let index = queue.length - 1; index >= 0; index--) {
|
|
306
113
|
const item = queue[index];
|
|
307
|
-
const target = item
|
|
114
|
+
const target = _optionalChain([item, 'optionalAccess', _5 => _5.target]);
|
|
308
115
|
if (!(target instanceof Element) || !container.contains(target)) continue;
|
|
309
116
|
queue.splice(index, 1);
|
|
310
|
-
interactions.unshift({ target, kind: toReplayKind(item
|
|
117
|
+
interactions.unshift({ target, kind: toReplayKind(_optionalChain([item, 'optionalAccess', _6 => _6.kind])) });
|
|
311
118
|
}
|
|
312
119
|
return interactions;
|
|
313
120
|
}
|
|
314
|
-
__name(takeQueuedTargets, "takeQueuedTargets");
|
|
121
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, takeQueuedTargets, "takeQueuedTargets");
|
|
315
122
|
function runWhenIdle(callback) {
|
|
316
123
|
const windowWithIdleCallback = window;
|
|
317
124
|
if (typeof windowWithIdleCallback.requestIdleCallback === "function") {
|
|
318
125
|
const handle2 = windowWithIdleCallback.requestIdleCallback(callback, { timeout: 2e3 });
|
|
319
|
-
return () => windowWithIdleCallback.cancelIdleCallback
|
|
126
|
+
return () => _optionalChain([windowWithIdleCallback, 'access', _7 => _7.cancelIdleCallback, 'optionalCall', _8 => _8(handle2)]);
|
|
320
127
|
}
|
|
321
128
|
const handle = window.setTimeout(callback, 1);
|
|
322
129
|
return () => window.clearTimeout(handle);
|
|
323
130
|
}
|
|
324
|
-
__name(runWhenIdle, "runWhenIdle");
|
|
131
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, runWhenIdle, "runWhenIdle");
|
|
325
132
|
function replayClick(target) {
|
|
326
133
|
const clickable = target;
|
|
327
134
|
if (typeof clickable.click === "function") {
|
|
@@ -330,7 +137,7 @@ function replayClick(target) {
|
|
|
330
137
|
}
|
|
331
138
|
target.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
|
|
332
139
|
}
|
|
333
|
-
__name(replayClick, "replayClick");
|
|
140
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, replayClick, "replayClick");
|
|
334
141
|
function replaySubmit(target) {
|
|
335
142
|
const form = target;
|
|
336
143
|
if (typeof form.requestSubmit === "function") {
|
|
@@ -339,7 +146,7 @@ function replaySubmit(target) {
|
|
|
339
146
|
}
|
|
340
147
|
target.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
|
|
341
148
|
}
|
|
342
|
-
__name(replaySubmit, "replaySubmit");
|
|
149
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, replaySubmit, "replaySubmit");
|
|
343
150
|
function replayInteraction(interaction) {
|
|
344
151
|
if (interaction.kind === "submit") {
|
|
345
152
|
replaySubmit(interaction.target);
|
|
@@ -347,14 +154,14 @@ function replayInteraction(interaction) {
|
|
|
347
154
|
}
|
|
348
155
|
replayClick(interaction.target);
|
|
349
156
|
}
|
|
350
|
-
__name(replayInteraction, "replayInteraction");
|
|
157
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, replayInteraction, "replayInteraction");
|
|
351
158
|
function replayFarmQueuedInteraction(target, kind) {
|
|
352
159
|
replayInteraction({ target, kind: toReplayKind(kind) });
|
|
353
160
|
}
|
|
354
|
-
__name(replayFarmQueuedInteraction, "replayFarmQueuedInteraction");
|
|
161
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, replayFarmQueuedInteraction, "replayFarmQueuedInteraction");
|
|
355
162
|
function finishIslandHydration(container, activating) {
|
|
356
163
|
const interactions = /* @__PURE__ */ new Map();
|
|
357
|
-
if (activating
|
|
164
|
+
if (_optionalChain([activating, 'optionalAccess', _9 => _9.target, 'access', _10 => _10.isConnected])) interactions.set(activating.target, activating);
|
|
358
165
|
for (const interaction of takeQueuedTargets(container)) {
|
|
359
166
|
if (interaction.target.isConnected) interactions.set(interaction.target, interaction);
|
|
360
167
|
}
|
|
@@ -368,18 +175,18 @@ function finishIslandHydration(container, activating) {
|
|
|
368
175
|
}, 0);
|
|
369
176
|
}
|
|
370
177
|
}
|
|
371
|
-
__name(finishIslandHydration, "finishIslandHydration");
|
|
178
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, finishIslandHydration, "finishIslandHydration");
|
|
372
179
|
function scheduleFarmIslandHydration({
|
|
373
180
|
container,
|
|
374
181
|
strategy,
|
|
375
182
|
signal,
|
|
376
183
|
hydrate
|
|
377
184
|
}) {
|
|
378
|
-
const resolvedStrategy = strategy
|
|
379
|
-
if (signal
|
|
185
|
+
const resolvedStrategy = _nullishCoalesce(strategy, () => ( "load"));
|
|
186
|
+
if (_optionalChain([signal, 'optionalAccess', _11 => _11.aborted])) return Promise.resolve(void 0);
|
|
380
187
|
if (resolvedStrategy === "load") {
|
|
381
|
-
return Promise.resolve().then(() => signal
|
|
382
|
-
if (signal
|
|
188
|
+
return Promise.resolve().then(() => _optionalChain([signal, 'optionalAccess', _12 => _12.aborted]) ? void 0 : hydrate()).then((value) => {
|
|
189
|
+
if (_optionalChain([signal, 'optionalAccess', _13 => _13.aborted])) return void 0;
|
|
383
190
|
finishIslandHydration(container);
|
|
384
191
|
return value;
|
|
385
192
|
});
|
|
@@ -391,28 +198,28 @@ function scheduleFarmIslandHydration({
|
|
|
391
198
|
const triggerCleanups = /* @__PURE__ */ new Set();
|
|
392
199
|
const captureCleanups = /* @__PURE__ */ new Set();
|
|
393
200
|
let removeAbortListener = null;
|
|
394
|
-
const cleanupTriggers = /* @__PURE__ */ __name(() => {
|
|
201
|
+
const cleanupTriggers = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
|
|
395
202
|
for (const dispose of triggerCleanups) dispose();
|
|
396
203
|
triggerCleanups.clear();
|
|
397
204
|
}, "cleanupTriggers");
|
|
398
|
-
const cleanupCaptures = /* @__PURE__ */ __name(() => {
|
|
205
|
+
const cleanupCaptures = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
|
|
399
206
|
for (const dispose of captureCleanups) dispose();
|
|
400
207
|
captureCleanups.clear();
|
|
401
208
|
}, "cleanupCaptures");
|
|
402
|
-
const cleanup = /* @__PURE__ */ __name(() => {
|
|
209
|
+
const cleanup = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
|
|
403
210
|
cleanupTriggers();
|
|
404
211
|
cleanupCaptures();
|
|
405
|
-
removeAbortListener
|
|
212
|
+
_optionalChain([removeAbortListener, 'optionalCall', _14 => _14()]);
|
|
406
213
|
removeAbortListener = null;
|
|
407
214
|
}, "cleanup");
|
|
408
|
-
const start = /* @__PURE__ */ __name(() => {
|
|
215
|
+
const start = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
|
|
409
216
|
if (started || cancelled) return;
|
|
410
217
|
started = true;
|
|
411
218
|
cleanupTriggers();
|
|
412
219
|
Promise.resolve().then(hydrate).then(
|
|
413
220
|
(value) => {
|
|
414
221
|
cleanup();
|
|
415
|
-
if (cancelled || signal
|
|
222
|
+
if (cancelled || _optionalChain([signal, 'optionalAccess', _15 => _15.aborted])) return;
|
|
416
223
|
const activating = queuedInteraction;
|
|
417
224
|
queuedInteraction = null;
|
|
418
225
|
finishIslandHydration(container, activating);
|
|
@@ -425,14 +232,14 @@ function scheduleFarmIslandHydration({
|
|
|
425
232
|
);
|
|
426
233
|
}, "start");
|
|
427
234
|
if (signal) {
|
|
428
|
-
const abort = /* @__PURE__ */ __name(() => {
|
|
235
|
+
const abort = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
|
|
429
236
|
cancelled = true;
|
|
430
237
|
cleanup();
|
|
431
238
|
takeQueuedTargets(container);
|
|
432
239
|
resolve(void 0);
|
|
433
240
|
}, "abort");
|
|
434
241
|
signal.addEventListener("abort", abort, { once: true });
|
|
435
|
-
removeAbortListener = /* @__PURE__ */ __name(() => signal.removeEventListener("abort", abort), "removeAbortListener");
|
|
242
|
+
removeAbortListener = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => signal.removeEventListener("abort", abort), "removeAbortListener");
|
|
436
243
|
}
|
|
437
244
|
if (resolvedStrategy === "idle") {
|
|
438
245
|
triggerCleanups.add(runWhenIdle(start));
|
|
@@ -451,38 +258,38 @@ function scheduleFarmIslandHydration({
|
|
|
451
258
|
triggerCleanups.add(observeIslandVisibility(container.ownerDocument, targets, start));
|
|
452
259
|
return;
|
|
453
260
|
}
|
|
454
|
-
const hold = /* @__PURE__ */ __name((event, target, kind) => {
|
|
455
|
-
queuedInteraction
|
|
261
|
+
const hold = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (event, target, kind) => {
|
|
262
|
+
_nullishCoalesce(queuedInteraction, () => ( (queuedInteraction = { target, kind })));
|
|
456
263
|
event.preventDefault();
|
|
457
264
|
event.stopImmediatePropagation();
|
|
458
265
|
start();
|
|
459
266
|
}, "hold");
|
|
460
|
-
const queueActivatingClick = /* @__PURE__ */ __name((event) => {
|
|
461
|
-
const target = event.target instanceof Element ? event.target.closest(FARM_ISLAND_REPLAYABLE_SELECTOR) : null;
|
|
267
|
+
const queueActivatingClick = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (event) => {
|
|
268
|
+
const target = event.target instanceof Element ? event.target.closest(_chunkMWSK6C4Jcjs.FARM_ISLAND_REPLAYABLE_SELECTOR) : null;
|
|
462
269
|
if (!target || !container.contains(target) || target.closest("a[href]") || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) {
|
|
463
270
|
return;
|
|
464
271
|
}
|
|
465
272
|
hold(event, target, "click");
|
|
466
273
|
}, "queueActivatingClick");
|
|
467
|
-
const queueActivatingSubmit = /* @__PURE__ */ __name((event) => {
|
|
274
|
+
const queueActivatingSubmit = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (event) => {
|
|
468
275
|
const form = event.target;
|
|
469
276
|
if (!(form instanceof Element) || form.nodeName !== "FORM") return;
|
|
470
277
|
if (!container.contains(form) || event.defaultPrevented) return;
|
|
471
278
|
hold(event, form, "submit");
|
|
472
279
|
}, "queueActivatingSubmit");
|
|
473
|
-
const observeActivation = /* @__PURE__ */ __name((event) => {
|
|
280
|
+
const observeActivation = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (event) => {
|
|
474
281
|
const target = event.target;
|
|
475
282
|
if (!(target instanceof Element) || !container.contains(target)) return;
|
|
476
283
|
start();
|
|
477
284
|
}, "observeActivation");
|
|
478
|
-
const activateFromInteraction = /* @__PURE__ */ __name((event) => {
|
|
285
|
+
const activateFromInteraction = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (event) => {
|
|
479
286
|
const detail = event.detail;
|
|
480
|
-
const target = detail
|
|
287
|
+
const target = _optionalChain([detail, 'optionalAccess', _16 => _16.target]);
|
|
481
288
|
if (!(target instanceof Element) || !container.contains(target)) return;
|
|
482
|
-
if (detail
|
|
289
|
+
if (_optionalChain([detail, 'optionalAccess', _17 => _17.kind])) _nullishCoalesce(queuedInteraction, () => ( (queuedInteraction = { target, kind: toReplayKind(detail.kind) })));
|
|
483
290
|
start();
|
|
484
291
|
}, "activateFromInteraction");
|
|
485
|
-
const listen = /* @__PURE__ */ __name((type, handler, capture) => {
|
|
292
|
+
const listen = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (type, handler, capture) => {
|
|
486
293
|
document.addEventListener(type, handler, capture);
|
|
487
294
|
captureCleanups.add(() => document.removeEventListener(type, handler, capture));
|
|
488
295
|
}, "listen");
|
|
@@ -492,7 +299,7 @@ function scheduleFarmIslandHydration({
|
|
|
492
299
|
pointerdown: observeActivation,
|
|
493
300
|
focusin: observeActivation
|
|
494
301
|
};
|
|
495
|
-
for (const type of FARM_ISLAND_ACTIVATION_EVENTS) {
|
|
302
|
+
for (const type of _chunkMWSK6C4Jcjs.FARM_ISLAND_ACTIVATION_EVENTS) {
|
|
496
303
|
listen(type, activationHandlers[type], true);
|
|
497
304
|
}
|
|
498
305
|
listen("farm:island-interaction", activateFromInteraction, false);
|
|
@@ -503,657 +310,18 @@ function scheduleFarmIslandHydration({
|
|
|
503
310
|
}
|
|
504
311
|
});
|
|
505
312
|
}
|
|
506
|
-
__name(scheduleFarmIslandHydration, "scheduleFarmIslandHydration");
|
|
313
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, scheduleFarmIslandHydration, "scheduleFarmIslandHydration");
|
|
507
314
|
|
|
508
|
-
// src/client/plugin.ts
|
|
509
|
-
var PERFORMANCE_ENTRY_TYPES = [
|
|
510
|
-
"navigation",
|
|
511
|
-
"paint",
|
|
512
|
-
"largest-contentful-paint",
|
|
513
|
-
"layout-shift",
|
|
514
|
-
"event"
|
|
515
|
-
];
|
|
516
|
-
var _FarmClientPluginManager = class _FarmClientPluginManager {
|
|
517
|
-
constructor(registrations, options) {
|
|
518
|
-
this.instances = [];
|
|
519
|
-
this.performanceObservers = [];
|
|
520
|
-
this.navigationSequence = 0;
|
|
521
|
-
this.starting = false;
|
|
522
|
-
this.started = false;
|
|
523
|
-
this.closed = false;
|
|
524
|
-
this.reportedErrors = /* @__PURE__ */ new WeakSet();
|
|
525
|
-
this.handleWindowError = /* @__PURE__ */ __name((event) => {
|
|
526
|
-
const error = event.error ?? new Error(event.message || "Unknown browser error");
|
|
527
|
-
void this.reportError(error, "window", void 0, this.getLocation(), event);
|
|
528
|
-
}, "handleWindowError");
|
|
529
|
-
this.handleUnhandledRejection = /* @__PURE__ */ __name((event) => {
|
|
530
|
-
void this.reportError(
|
|
531
|
-
event.reason,
|
|
532
|
-
"unhandled-rejection",
|
|
533
|
-
void 0,
|
|
534
|
-
this.getLocation(),
|
|
535
|
-
event
|
|
536
|
-
);
|
|
537
|
-
}, "handleUnhandledRejection");
|
|
538
|
-
this.handlePageHide = /* @__PURE__ */ __name((event) => {
|
|
539
|
-
if (event.persisted) return;
|
|
540
|
-
void this.close("pagehide");
|
|
541
|
-
}, "handlePageHide");
|
|
542
|
-
this.registrations = sortRegistrations(registrations);
|
|
543
|
-
this.options = {
|
|
544
|
-
...options,
|
|
545
|
-
isDev: options.isDev ?? false,
|
|
546
|
-
isProd: options.isProd ?? !options.isDev,
|
|
547
|
-
window: options.window ?? (typeof window !== "undefined" ? window : void 0)
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
start() {
|
|
551
|
-
if (this.startPromise) return this.startPromise;
|
|
552
|
-
this.startPromise = Promise.resolve().then(() => this.startInternal());
|
|
553
|
-
return this.startPromise;
|
|
554
|
-
}
|
|
555
|
-
async beginHydration(input) {
|
|
556
|
-
await this.start();
|
|
557
|
-
const session = {
|
|
558
|
-
...input,
|
|
559
|
-
location: this.getLocation(),
|
|
560
|
-
startedAt: now()
|
|
561
|
-
};
|
|
562
|
-
await this.runHook(
|
|
563
|
-
"hydration.before",
|
|
564
|
-
(instance) => instance.plugin.hydration?.before?.({
|
|
565
|
-
...this.createStateEvent(instance),
|
|
566
|
-
...session
|
|
567
|
-
})
|
|
568
|
-
);
|
|
569
|
-
return session;
|
|
570
|
-
}
|
|
571
|
-
async completeHydration(session, options = {}) {
|
|
572
|
-
await this.runHook(
|
|
573
|
-
"hydration.after",
|
|
574
|
-
(instance) => instance.plugin.hydration?.after?.({
|
|
575
|
-
...this.createStateEvent(instance),
|
|
576
|
-
...session,
|
|
577
|
-
durationMs: now() - session.startedAt,
|
|
578
|
-
recovered: options.recovered ?? false
|
|
579
|
-
})
|
|
580
|
-
);
|
|
581
|
-
}
|
|
582
|
-
async failHydration(session, error) {
|
|
583
|
-
await this.reportError(error, "hydration", void 0, session.location);
|
|
584
|
-
}
|
|
585
|
-
async beginNavigation(input) {
|
|
586
|
-
await this.start();
|
|
587
|
-
this.currentNavigation?.controller.abort("superseded");
|
|
588
|
-
const controller = new AbortController();
|
|
589
|
-
const session = {
|
|
590
|
-
id: `navigation:${++this.navigationSequence}`,
|
|
591
|
-
from: input.from === null ? null : toClientLocation(input.from ?? this.getLocation().href, this.getBaseUrl()),
|
|
592
|
-
to: toClientLocation(input.to, this.getBaseUrl()),
|
|
593
|
-
action: input.action,
|
|
594
|
-
signal: controller.signal,
|
|
595
|
-
startedAt: now(),
|
|
596
|
-
route: input.route
|
|
597
|
-
};
|
|
598
|
-
this.currentNavigation = { controller, session };
|
|
599
|
-
await this.runHook(
|
|
600
|
-
"navigation.before",
|
|
601
|
-
(instance) => instance.plugin.navigation?.before?.({
|
|
602
|
-
...this.createStateEvent(instance),
|
|
603
|
-
...session
|
|
604
|
-
})
|
|
605
|
-
);
|
|
606
|
-
return session;
|
|
607
|
-
}
|
|
608
|
-
async markNavigationLoaded(session, data) {
|
|
609
|
-
if (session.signal.aborted) return;
|
|
610
|
-
await this.runHook(
|
|
611
|
-
"navigation.loaded",
|
|
612
|
-
(instance) => instance.plugin.navigation?.loaded?.({
|
|
613
|
-
...this.createStateEvent(instance),
|
|
614
|
-
...session,
|
|
615
|
-
data,
|
|
616
|
-
durationMs: now() - session.startedAt
|
|
617
|
-
})
|
|
618
|
-
);
|
|
619
|
-
}
|
|
620
|
-
cancelNavigation(session, reason = "canceled") {
|
|
621
|
-
const current = this.currentNavigation;
|
|
622
|
-
if (!current || session && current.session !== session) return;
|
|
623
|
-
current.controller.abort(reason);
|
|
624
|
-
this.currentNavigation = void 0;
|
|
625
|
-
}
|
|
626
|
-
async resolveNavigation(session) {
|
|
627
|
-
if (session.signal.aborted) return;
|
|
628
|
-
await this.runHook(
|
|
629
|
-
"navigation.resolved",
|
|
630
|
-
(instance) => instance.plugin.navigation?.resolved?.({
|
|
631
|
-
...this.createStateEvent(instance),
|
|
632
|
-
...session,
|
|
633
|
-
durationMs: now() - session.startedAt
|
|
634
|
-
})
|
|
635
|
-
);
|
|
636
|
-
}
|
|
637
|
-
scheduleNavigationRendered(session) {
|
|
638
|
-
if (session.signal.aborted) return Promise.resolve();
|
|
639
|
-
const clientWindow = this.options.window;
|
|
640
|
-
const schedule = clientWindow?.requestAnimationFrame ? (callback) => clientWindow.requestAnimationFrame(() => clientWindow.requestAnimationFrame(callback)) : (callback) => setTimeout(callback, 0);
|
|
641
|
-
return new Promise((resolve) => {
|
|
642
|
-
schedule(() => {
|
|
643
|
-
if (session.signal.aborted || this.closed) {
|
|
644
|
-
resolve();
|
|
645
|
-
return;
|
|
646
|
-
}
|
|
647
|
-
void this.runHook(
|
|
648
|
-
"navigation.rendered",
|
|
649
|
-
(instance) => instance.plugin.navigation?.rendered?.({
|
|
650
|
-
...this.createStateEvent(instance),
|
|
651
|
-
...session,
|
|
652
|
-
durationMs: now() - session.startedAt
|
|
653
|
-
})
|
|
654
|
-
).finally(() => {
|
|
655
|
-
if (this.currentNavigation?.session === session) {
|
|
656
|
-
this.currentNavigation = void 0;
|
|
657
|
-
}
|
|
658
|
-
resolve();
|
|
659
|
-
});
|
|
660
|
-
});
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
async failNavigation(session, error) {
|
|
664
|
-
if (!session.signal.aborted) {
|
|
665
|
-
await this.runHook(
|
|
666
|
-
"navigation.error",
|
|
667
|
-
(instance) => instance.plugin.navigation?.error?.({
|
|
668
|
-
...this.createStateEvent(instance),
|
|
669
|
-
...session,
|
|
670
|
-
durationMs: now() - session.startedAt,
|
|
671
|
-
error
|
|
672
|
-
})
|
|
673
|
-
);
|
|
674
|
-
await this.reportError(error, "navigation", session, session.to);
|
|
675
|
-
}
|
|
676
|
-
if (this.currentNavigation?.session === session) {
|
|
677
|
-
this.currentNavigation = void 0;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
async reportError(error, phase, navigation, location = this.getLocation(), sourceEvent) {
|
|
681
|
-
if (this.closed) return;
|
|
682
|
-
if (isObject(error)) {
|
|
683
|
-
if (this.reportedErrors.has(error)) return;
|
|
684
|
-
this.reportedErrors.add(error);
|
|
685
|
-
}
|
|
686
|
-
if (!this.started && !this.starting) await this.start();
|
|
687
|
-
if (this.closed) return;
|
|
688
|
-
await this.runErrorHooks({ error, phase, navigation, location }, void 0, sourceEvent);
|
|
689
|
-
}
|
|
690
|
-
close(reason = "manual") {
|
|
691
|
-
if (this.closePromise) return this.closePromise;
|
|
692
|
-
this.closePromise = this.closeInternal(reason);
|
|
693
|
-
return this.closePromise;
|
|
694
|
-
}
|
|
695
|
-
getPlugins() {
|
|
696
|
-
return this.instances.map(({ registration }) => ({
|
|
697
|
-
name: registration.name,
|
|
698
|
-
version: registration.version
|
|
699
|
-
}));
|
|
700
|
-
}
|
|
701
|
-
async startInternal() {
|
|
702
|
-
if (this.started || this.closed) return;
|
|
703
|
-
if (process.env.NODE_ENV !== "production" && this.options.isDev && this.options.window) {
|
|
704
|
-
try {
|
|
705
|
-
const { createFarmRuntimeErrorOverlay } = await import("@farm.js/core/internal/client-error-overlay");
|
|
706
|
-
this.runtimeErrorOverlay = createFarmRuntimeErrorOverlay({ window: this.options.window });
|
|
707
|
-
} catch (error) {
|
|
708
|
-
this.logHookError("farm:runtime-error-overlay", "load", error);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
this.starting = true;
|
|
712
|
-
try {
|
|
713
|
-
for (const registration of this.registrations) {
|
|
714
|
-
try {
|
|
715
|
-
const definition = registration.definition;
|
|
716
|
-
if (!definition || typeof definition !== "object") {
|
|
717
|
-
throw new TypeError(
|
|
718
|
-
`Client plugin "${registration.name}" does not define a lifecycle object`
|
|
719
|
-
);
|
|
720
|
-
}
|
|
721
|
-
const instance = {
|
|
722
|
-
registration,
|
|
723
|
-
plugin: definition,
|
|
724
|
-
state: void 0
|
|
725
|
-
};
|
|
726
|
-
instance.state = await definition.setup?.(this.createSetupEvent(instance));
|
|
727
|
-
this.instances.push(instance);
|
|
728
|
-
} catch (error) {
|
|
729
|
-
this.logHookError(registration.name, "setup", error);
|
|
730
|
-
await this.runErrorHooks({
|
|
731
|
-
error,
|
|
732
|
-
phase: "setup",
|
|
733
|
-
location: this.getLocation()
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
this.started = true;
|
|
738
|
-
this.installBrowserListeners();
|
|
739
|
-
this.installPerformanceObservers();
|
|
740
|
-
} finally {
|
|
741
|
-
this.starting = false;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
installBrowserListeners() {
|
|
745
|
-
const clientWindow = this.options.window;
|
|
746
|
-
if (!clientWindow) return;
|
|
747
|
-
if (this.runtimeErrorOverlay || this.instances.some(({ plugin }) => plugin.error)) {
|
|
748
|
-
clientWindow.addEventListener("error", this.handleWindowError);
|
|
749
|
-
clientWindow.addEventListener("unhandledrejection", this.handleUnhandledRejection);
|
|
750
|
-
}
|
|
751
|
-
clientWindow.addEventListener("pagehide", this.handlePageHide);
|
|
752
|
-
}
|
|
753
|
-
installPerformanceObservers() {
|
|
754
|
-
if (!this.instances.some(({ plugin }) => plugin.performance)) return;
|
|
755
|
-
const Observer = typeof PerformanceObserver !== "undefined" ? PerformanceObserver : void 0;
|
|
756
|
-
if (!Observer) return;
|
|
757
|
-
const supported = new Set(Observer.supportedEntryTypes || []);
|
|
758
|
-
for (const type of PERFORMANCE_ENTRY_TYPES) {
|
|
759
|
-
if (!supported.has(type)) continue;
|
|
760
|
-
try {
|
|
761
|
-
const observer = new Observer((list) => {
|
|
762
|
-
for (const entry of list.getEntries()) {
|
|
763
|
-
void this.runHook(
|
|
764
|
-
"performance",
|
|
765
|
-
(instance) => instance.plugin.performance?.({
|
|
766
|
-
...this.createStateEvent(instance),
|
|
767
|
-
entry,
|
|
768
|
-
location: this.getLocation()
|
|
769
|
-
})
|
|
770
|
-
);
|
|
771
|
-
}
|
|
772
|
-
});
|
|
773
|
-
observer.observe({ type, buffered: true });
|
|
774
|
-
this.performanceObservers.push(observer);
|
|
775
|
-
} catch (error) {
|
|
776
|
-
void this.reportError(error, "performance");
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
async closeInternal(reason) {
|
|
781
|
-
if (this.closed) return;
|
|
782
|
-
if (this.startPromise) await this.startPromise;
|
|
783
|
-
this.closed = true;
|
|
784
|
-
this.currentNavigation?.controller.abort(reason);
|
|
785
|
-
this.currentNavigation = void 0;
|
|
786
|
-
const clientWindow = this.options.window;
|
|
787
|
-
clientWindow?.removeEventListener("error", this.handleWindowError);
|
|
788
|
-
clientWindow?.removeEventListener("unhandledrejection", this.handleUnhandledRejection);
|
|
789
|
-
clientWindow?.removeEventListener("pagehide", this.handlePageHide);
|
|
790
|
-
for (const observer of this.performanceObservers) observer.disconnect();
|
|
791
|
-
this.performanceObservers.length = 0;
|
|
792
|
-
this.runtimeErrorOverlay?.destroy();
|
|
793
|
-
for (const instance of [...this.instances].reverse()) {
|
|
794
|
-
try {
|
|
795
|
-
await instance.plugin.close?.({
|
|
796
|
-
...this.createStateEvent(instance),
|
|
797
|
-
reason
|
|
798
|
-
});
|
|
799
|
-
} catch (error) {
|
|
800
|
-
this.logHookError(instance.registration.name, "close", error);
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
async runHook(hook, invoke) {
|
|
805
|
-
for (const instance of this.instances) {
|
|
806
|
-
try {
|
|
807
|
-
await invoke(instance);
|
|
808
|
-
} catch (error) {
|
|
809
|
-
this.logHookError(instance.registration.name, hook, error);
|
|
810
|
-
await this.runErrorHooks(
|
|
811
|
-
{
|
|
812
|
-
error,
|
|
813
|
-
phase: `plugin:${hook}`,
|
|
814
|
-
location: this.getLocation()
|
|
815
|
-
},
|
|
816
|
-
instance
|
|
817
|
-
);
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
async runErrorHooks(event, excluded, sourceEvent) {
|
|
822
|
-
this.runtimeErrorOverlay?.show(event.error, {
|
|
823
|
-
phase: event.phase,
|
|
824
|
-
location: event.location,
|
|
825
|
-
sourceEvent
|
|
826
|
-
});
|
|
827
|
-
for (const instance of this.instances) {
|
|
828
|
-
if (instance === excluded || !instance.plugin.error) continue;
|
|
829
|
-
try {
|
|
830
|
-
await instance.plugin.error({
|
|
831
|
-
...this.createStateEvent(instance),
|
|
832
|
-
...event
|
|
833
|
-
});
|
|
834
|
-
} catch (error) {
|
|
835
|
-
this.logHookError(instance.registration.name, "error", error);
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
createSetupEvent(instance) {
|
|
840
|
-
return {
|
|
841
|
-
plugin: {
|
|
842
|
-
name: instance.registration.name,
|
|
843
|
-
version: instance.registration.version
|
|
844
|
-
},
|
|
845
|
-
public: readonlyPublicData(instance.registration.public),
|
|
846
|
-
router: this.options.router,
|
|
847
|
-
isDev: Boolean(this.options.isDev),
|
|
848
|
-
isProd: Boolean(this.options.isProd),
|
|
849
|
-
deploymentId: this.options.deploymentId
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
createStateEvent(instance) {
|
|
853
|
-
return {
|
|
854
|
-
...this.createSetupEvent(instance),
|
|
855
|
-
state: instance.state
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
getLocation() {
|
|
859
|
-
const href = this.options.window?.location.href ?? "http://localhost/";
|
|
860
|
-
return toClientLocation(href, href);
|
|
861
|
-
}
|
|
862
|
-
getBaseUrl() {
|
|
863
|
-
return this.options.window?.location.href ?? "http://localhost/";
|
|
864
|
-
}
|
|
865
|
-
logHookError(name, hook, error) {
|
|
866
|
-
console.error(`[Farm.js] Client plugin "${name}" failed in ${hook}:`, error);
|
|
867
|
-
}
|
|
868
|
-
};
|
|
869
|
-
__name(_FarmClientPluginManager, "FarmClientPluginManager");
|
|
870
|
-
var FarmClientPluginManager = _FarmClientPluginManager;
|
|
871
|
-
function createClientPluginManager(registrations, options) {
|
|
872
|
-
return new FarmClientPluginManager(registrations, options);
|
|
873
|
-
}
|
|
874
|
-
__name(createClientPluginManager, "createClientPluginManager");
|
|
875
|
-
function sortRegistrations(registrations) {
|
|
876
|
-
const rank = /* @__PURE__ */ __name((enforce) => enforce === "pre" ? 0 : enforce === "post" ? 2 : 1, "rank");
|
|
877
|
-
return registrations.map((registration, index) => ({ registration, index })).sort(
|
|
878
|
-
(left, right) => rank(left.registration.enforce) - rank(right.registration.enforce) || left.index - right.index
|
|
879
|
-
).map(({ registration }) => registration);
|
|
880
|
-
}
|
|
881
|
-
__name(sortRegistrations, "sortRegistrations");
|
|
882
|
-
function toClientLocation(input, base) {
|
|
883
|
-
if (typeof input === "object" && "href" in input && "pathname" in input) {
|
|
884
|
-
return {
|
|
885
|
-
href: input.href,
|
|
886
|
-
pathname: input.pathname,
|
|
887
|
-
search: input.search,
|
|
888
|
-
hash: input.hash
|
|
889
|
-
};
|
|
890
|
-
}
|
|
891
|
-
const url = new URL(input, base);
|
|
892
|
-
return {
|
|
893
|
-
href: url.href,
|
|
894
|
-
pathname: url.pathname,
|
|
895
|
-
search: url.search,
|
|
896
|
-
hash: url.hash
|
|
897
|
-
};
|
|
898
|
-
}
|
|
899
|
-
__name(toClientLocation, "toClientLocation");
|
|
900
|
-
function readonlyPublicData(value) {
|
|
901
|
-
if (value && typeof value === "object") {
|
|
902
|
-
return Object.freeze(value);
|
|
903
|
-
}
|
|
904
|
-
return value;
|
|
905
|
-
}
|
|
906
|
-
__name(readonlyPublicData, "readonlyPublicData");
|
|
907
|
-
function now() {
|
|
908
|
-
return typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
909
|
-
}
|
|
910
|
-
__name(now, "now");
|
|
911
|
-
function isObject(value) {
|
|
912
|
-
return typeof value === "object" && value !== null || typeof value === "function";
|
|
913
|
-
}
|
|
914
|
-
__name(isObject, "isObject");
|
|
915
315
|
|
|
916
|
-
// src/search-params.ts
|
|
917
|
-
function searchParamsToObject(searchParams) {
|
|
918
|
-
const output = {};
|
|
919
|
-
searchParams.forEach((value, key) => {
|
|
920
|
-
if (key === "__proto__" || key === "constructor" || key === "prototype") return;
|
|
921
|
-
const existing = Object.prototype.hasOwnProperty.call(output, key) ? output[key] : void 0;
|
|
922
|
-
if (existing !== void 0) {
|
|
923
|
-
if (Array.isArray(existing)) {
|
|
924
|
-
existing.push(value);
|
|
925
|
-
} else {
|
|
926
|
-
output[key] = [existing, value];
|
|
927
|
-
}
|
|
928
|
-
} else {
|
|
929
|
-
output[key] = value;
|
|
930
|
-
}
|
|
931
|
-
});
|
|
932
|
-
return output;
|
|
933
|
-
}
|
|
934
|
-
__name(searchParamsToObject, "searchParamsToObject");
|
|
935
316
|
|
|
936
|
-
// src/trailing-slash.ts
|
|
937
|
-
var FARM_TRAILING_SLASH_PREFERENCE = /* @__PURE__ */ Symbol.for("farm.trailingSlashPreference");
|
|
938
|
-
function getFarmGlobalState() {
|
|
939
|
-
return globalThis;
|
|
940
|
-
}
|
|
941
|
-
__name(getFarmGlobalState, "getFarmGlobalState");
|
|
942
|
-
function setFarmTrailingSlashPreference(enabled) {
|
|
943
|
-
getFarmGlobalState()[FARM_TRAILING_SLASH_PREFERENCE] = enabled === true;
|
|
944
|
-
}
|
|
945
|
-
__name(setFarmTrailingSlashPreference, "setFarmTrailingSlashPreference");
|
|
946
317
|
|
|
947
|
-
// src/base-path.ts
|
|
948
|
-
var FARM_BASE_PATH = /* @__PURE__ */ Symbol.for("farm.basePath");
|
|
949
|
-
function getFarmGlobalState2() {
|
|
950
|
-
return globalThis;
|
|
951
|
-
}
|
|
952
|
-
__name(getFarmGlobalState2, "getFarmGlobalState");
|
|
953
|
-
function setFarmBasePath(basePath) {
|
|
954
|
-
getFarmGlobalState2()[FARM_BASE_PATH] = normalizeFarmBasePath(basePath);
|
|
955
|
-
}
|
|
956
|
-
__name(setFarmBasePath, "setFarmBasePath");
|
|
957
|
-
function getFarmBasePath() {
|
|
958
|
-
return getFarmGlobalState2()[FARM_BASE_PATH] ?? "";
|
|
959
|
-
}
|
|
960
|
-
__name(getFarmBasePath, "getFarmBasePath");
|
|
961
|
-
function stripFarmBasePath(pathname, basePath = getFarmBasePath()) {
|
|
962
|
-
const normalizedBasePath = normalizeFarmBasePath(basePath);
|
|
963
|
-
if (!normalizedBasePath) return pathname || "/";
|
|
964
|
-
if (pathname === normalizedBasePath) return "/";
|
|
965
|
-
if (!pathname.startsWith(`${normalizedBasePath}/`)) return pathname || "/";
|
|
966
|
-
return pathname.slice(normalizedBasePath.length) || "/";
|
|
967
|
-
}
|
|
968
|
-
__name(stripFarmBasePath, "stripFarmBasePath");
|
|
969
|
-
function normalizeFarmBasePath(basePath) {
|
|
970
|
-
if (!basePath || basePath === "/") return "";
|
|
971
|
-
const hasUnstableCharacters = /* @__PURE__ */ __name((candidate) => candidate.includes("\\") || Array.from(candidate).some((character) => {
|
|
972
|
-
const code = character.charCodeAt(0);
|
|
973
|
-
return code <= 31 || code >= 127 && code <= 159;
|
|
974
|
-
}), "hasUnstableCharacters");
|
|
975
|
-
if (hasUnstableCharacters(basePath)) {
|
|
976
|
-
throw new Error("Farm basePath cannot contain backslashes or control characters.");
|
|
977
|
-
}
|
|
978
|
-
const pathname = basePath.trim();
|
|
979
|
-
if (!pathname || pathname === "/") return "";
|
|
980
|
-
if (pathname.includes("?") || pathname.includes("#")) {
|
|
981
|
-
throw new Error("Farm basePath cannot contain a query string or hash.");
|
|
982
|
-
}
|
|
983
|
-
if (pathname.startsWith("//") || /^[a-z][a-z\d+.-]*:\/\//i.test(pathname)) {
|
|
984
|
-
throw new Error('Farm basePath must be a pathname such as "/docs", not a URL.');
|
|
985
|
-
}
|
|
986
|
-
for (const segment of pathname.split("/")) {
|
|
987
|
-
let decoded = segment;
|
|
988
|
-
try {
|
|
989
|
-
decoded = decodeURIComponent(segment);
|
|
990
|
-
} catch {
|
|
991
|
-
}
|
|
992
|
-
if (hasUnstableCharacters(decoded)) {
|
|
993
|
-
throw new Error("Farm basePath cannot contain backslashes or control characters.");
|
|
994
|
-
}
|
|
995
|
-
if (decoded.includes("/")) {
|
|
996
|
-
throw new Error("Farm basePath cannot contain percent-encoded path separators.");
|
|
997
|
-
}
|
|
998
|
-
if (decoded === "." || decoded === "..") {
|
|
999
|
-
throw new Error('Farm basePath cannot contain "." or ".." path segments.');
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
return `/${pathname}`.replace(/\/{2,}/g, "/").replace(/\/+$/, "");
|
|
1003
|
-
}
|
|
1004
|
-
__name(normalizeFarmBasePath, "normalizeFarmBasePath");
|
|
1005
318
|
|
|
1006
|
-
// src/client/hash-target.ts
|
|
1007
|
-
function getHashTargetElement(hash) {
|
|
1008
|
-
const fragment = hash.startsWith("#") ? hash.slice(1) : hash;
|
|
1009
|
-
if (!fragment) return null;
|
|
1010
|
-
let decoded = fragment;
|
|
1011
|
-
try {
|
|
1012
|
-
decoded = decodeURIComponent(fragment);
|
|
1013
|
-
} catch {
|
|
1014
|
-
}
|
|
1015
|
-
return document.getElementById(decoded) || document.getElementById(fragment) || document.getElementsByName(decoded)[0] || null;
|
|
1016
|
-
}
|
|
1017
|
-
__name(getHashTargetElement, "getHashTargetElement");
|
|
1018
319
|
|
|
1019
|
-
// src/client/document-head.ts
|
|
1020
|
-
var FARM_NAVIGATION_HEAD_SELECTOR = [
|
|
1021
|
-
"meta[name]",
|
|
1022
|
-
"meta[property]",
|
|
1023
|
-
"meta[http-equiv]",
|
|
1024
|
-
"meta[charset]",
|
|
1025
|
-
"meta[itemprop]",
|
|
1026
|
-
'link[rel~="author"]',
|
|
1027
|
-
'link[rel~="canonical"]',
|
|
1028
|
-
'link[rel~="alternate"]',
|
|
1029
|
-
'link[rel~="icon"]',
|
|
1030
|
-
'link[rel~="apple-touch-icon"]',
|
|
1031
|
-
'link[rel~="manifest"]',
|
|
1032
|
-
'link[rel~="search"]',
|
|
1033
|
-
'link[rel~="next"]',
|
|
1034
|
-
'link[rel~="prev"]',
|
|
1035
|
-
'link[rel~="publisher"]',
|
|
1036
|
-
'link[rel~="license"]',
|
|
1037
|
-
'link[rel~="help"]',
|
|
1038
|
-
'link[rel~="me"]',
|
|
1039
|
-
'link[rel~="pingback"]',
|
|
1040
|
-
'link[rel~="privacy-policy"]',
|
|
1041
|
-
'link[rel~="terms-of-service"]',
|
|
1042
|
-
// Page and layout `metadata.jsonLd` (FARM_METADATA_ATTRIBUTE). The site-level
|
|
1043
|
-
// agent JSON-LD and app-authored scripts carry no marker and stay in place.
|
|
1044
|
-
'script[type="application/ld+json"][data-farm-metadata]'
|
|
1045
|
-
].join(",");
|
|
1046
|
-
function reconcileFarmDocumentHead(nextDocument) {
|
|
1047
|
-
const nextTitle = nextDocument.querySelector("title");
|
|
1048
|
-
document.title = nextTitle?.textContent || "";
|
|
1049
|
-
document.head.querySelectorAll(FARM_NAVIGATION_HEAD_SELECTOR).forEach((node) => node.remove());
|
|
1050
|
-
nextDocument.head.querySelectorAll(FARM_NAVIGATION_HEAD_SELECTOR).forEach((node) => document.head.appendChild(document.importNode(node, true)));
|
|
1051
|
-
}
|
|
1052
|
-
__name(reconcileFarmDocumentHead, "reconcileFarmDocumentHead");
|
|
1053
320
|
|
|
1054
|
-
// src/client/navigation-url.ts
|
|
1055
|
-
function isFarmExternalNavigationURL(url, currentOrigin) {
|
|
1056
|
-
return url.protocol !== "http:" && url.protocol !== "https:" || url.origin !== currentOrigin;
|
|
1057
|
-
}
|
|
1058
|
-
__name(isFarmExternalNavigationURL, "isFarmExternalNavigationURL");
|
|
1059
321
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
if (!Number.isInteger(timeoutMs) || timeoutMs < 0 || timeoutMs > 2147483647) {
|
|
1067
|
-
invalid = new RangeError(
|
|
1068
|
-
"timeoutMs must be an integer between 0 and 2147483647 (0 disables the deadline)."
|
|
1069
|
-
);
|
|
1070
|
-
} else if (timeoutMs > 0) {
|
|
1071
|
-
const controller = new AbortController();
|
|
1072
|
-
signals.push(controller.signal);
|
|
1073
|
-
timer = setTimeout(() => {
|
|
1074
|
-
timeoutReason = new DOMException("Client request timed out", "TimeoutError");
|
|
1075
|
-
controller.abort(timeoutReason);
|
|
1076
|
-
}, timeoutMs);
|
|
1077
|
-
}
|
|
1078
|
-
const combined = signals.length > 1 ? AbortSignal.any(signals) : signals[0];
|
|
1079
|
-
let active = 0;
|
|
1080
|
-
let closed = false;
|
|
1081
|
-
const cleanup = /* @__PURE__ */ __name(() => {
|
|
1082
|
-
if (closed && active === 0 && timer !== void 0) {
|
|
1083
|
-
clearTimeout(timer);
|
|
1084
|
-
timer = void 0;
|
|
1085
|
-
}
|
|
1086
|
-
}, "cleanup");
|
|
1087
|
-
const check = /* @__PURE__ */ __name(() => {
|
|
1088
|
-
if (invalid) throw invalid;
|
|
1089
|
-
combined?.throwIfAborted();
|
|
1090
|
-
}, "check");
|
|
1091
|
-
return {
|
|
1092
|
-
signal: combined,
|
|
1093
|
-
get timedOut() {
|
|
1094
|
-
return timeoutReason !== void 0 && combined?.reason === timeoutReason;
|
|
1095
|
-
},
|
|
1096
|
-
check,
|
|
1097
|
-
hold() {
|
|
1098
|
-
active++;
|
|
1099
|
-
return () => {
|
|
1100
|
-
active--;
|
|
1101
|
-
cleanup();
|
|
1102
|
-
};
|
|
1103
|
-
},
|
|
1104
|
-
// A race also bounds cooperative local dispatch and custom HTTP implementations.
|
|
1105
|
-
// Late completion is consumed, but cannot turn a cancelled result into success.
|
|
1106
|
-
async run(work) {
|
|
1107
|
-
check();
|
|
1108
|
-
active++;
|
|
1109
|
-
let abort;
|
|
1110
|
-
try {
|
|
1111
|
-
if (!combined) return await work();
|
|
1112
|
-
return await new Promise((resolve, reject) => {
|
|
1113
|
-
abort = /* @__PURE__ */ __name(() => reject(combined.reason), "abort");
|
|
1114
|
-
combined.addEventListener("abort", abort, { once: true });
|
|
1115
|
-
Promise.resolve().then(() => {
|
|
1116
|
-
check();
|
|
1117
|
-
return work();
|
|
1118
|
-
}).then(resolve, reject);
|
|
1119
|
-
});
|
|
1120
|
-
} finally {
|
|
1121
|
-
if (abort) combined?.removeEventListener("abort", abort);
|
|
1122
|
-
active--;
|
|
1123
|
-
cleanup();
|
|
1124
|
-
}
|
|
1125
|
-
},
|
|
1126
|
-
async delay(ms) {
|
|
1127
|
-
let retryTimer;
|
|
1128
|
-
try {
|
|
1129
|
-
await this.run(
|
|
1130
|
-
() => new Promise((resolve) => {
|
|
1131
|
-
retryTimer = setTimeout(resolve, ms);
|
|
1132
|
-
})
|
|
1133
|
-
);
|
|
1134
|
-
} finally {
|
|
1135
|
-
if (retryTimer !== void 0) clearTimeout(retryTimer);
|
|
1136
|
-
}
|
|
1137
|
-
},
|
|
1138
|
-
dispose() {
|
|
1139
|
-
closed = true;
|
|
1140
|
-
cleanup();
|
|
1141
|
-
}
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
__name(createClientCancellation, "createClientCancellation");
|
|
1145
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1146
|
-
0 && (module.exports = {
|
|
1147
|
-
createClientCancellation,
|
|
1148
|
-
createClientPluginManager,
|
|
1149
|
-
getHashTargetElement,
|
|
1150
|
-
installChunkErrorRecovery,
|
|
1151
|
-
isFarmExternalNavigationURL,
|
|
1152
|
-
reconcileFarmDocumentHead,
|
|
1153
|
-
replayFarmQueuedInteraction,
|
|
1154
|
-
scheduleFarmIslandHydration,
|
|
1155
|
-
searchParamsToObject,
|
|
1156
|
-
setFarmBasePath,
|
|
1157
|
-
setFarmTrailingSlashPreference,
|
|
1158
|
-
stripFarmBasePath
|
|
1159
|
-
});
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
exports.createClientCancellation = _chunkJ7FSKED3cjs.createClientCancellation; exports.createClientPluginManager = _chunkVB6UCX3Vcjs.createClientPluginManager; exports.getHashTargetElement = _chunkR5A5KNVXcjs.getHashTargetElement; exports.installChunkErrorRecovery = _chunkKROWKCUHcjs.installChunkErrorRecovery; exports.isFarmExternalNavigationURL = _chunkSWN467MPcjs.isFarmExternalNavigationURL; exports.reconcileFarmDocumentHead = _chunkKGZIORNLcjs.reconcileFarmDocumentHead; exports.replayFarmQueuedInteraction = replayFarmQueuedInteraction; exports.scheduleFarmIslandHydration = scheduleFarmIslandHydration; exports.searchParamsToObject = _chunkQNPEUFHQcjs.searchParamsToObject; exports.setFarmBasePath = _chunkI57LW5VZcjs.setFarmBasePath; exports.setFarmTrailingSlashPreference = _chunkOYEUREB6cjs.setFarmTrailingSlashPreference; exports.stripFarmBasePath = _chunkI57LW5VZcjs.stripFarmBasePath;
|