@farm.js/core 0.1.17 → 0.1.19
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/app-markdown.mjs +3 -3
- package/dist/cache.cjs +38 -1560
- package/dist/chunk-22GUSVNJ.cjs +351 -0
- package/dist/{chunk-EN7WTEAY.mjs → chunk-2ANEVVF7.mjs} +1 -1
- package/dist/chunk-2CQ74SP6.cjs +13 -0
- package/dist/{chunk-YD4J4XCI.mjs → chunk-2GNATDDE.mjs} +1 -1
- package/dist/chunk-2SJ4RQ6P.cjs +57 -0
- package/dist/chunk-3376ZTRC.cjs +1 -0
- 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-ZCNJKLA2.mjs → chunk-7BC6GAL7.mjs} +1 -1
- package/dist/chunk-7W3CPVXS.cjs +24 -0
- package/dist/chunk-A6WIQH5Z.cjs +31 -0
- package/dist/chunk-A777V5WU.cjs +725 -0
- package/dist/chunk-AFOD3LYZ.cjs +377 -0
- package/dist/chunk-AH7HOAQ3.cjs +151 -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-AYJR42WX.cjs +711 -0
- package/dist/chunk-BBVSJVBZ.cjs +600 -0
- package/dist/chunk-BIDYX3SL.cjs +91 -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-E2ROOWQC.cjs +2225 -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-MVIWBEJF.mjs → chunk-FVZGEVTO.mjs} +7 -7
- 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-GPVTX3HT.cjs +1415 -0
- package/dist/chunk-H6G5INWM.cjs +1094 -0
- package/dist/{chunk-DHDVMXYK.mjs → chunk-HALDNTIV.mjs} +30 -4
- package/dist/chunk-HBTUGXHS.cjs +180 -0
- package/dist/chunk-HREOKQWT.cjs +45 -0
- package/dist/{chunk-5QOEPUYE.mjs → chunk-HSDL2AUR.mjs} +1 -1
- package/dist/chunk-I4J452B7.cjs +435 -0
- package/dist/chunk-I57LW5VZ.cjs +94 -0
- package/dist/chunk-I5YBCWQ6.cjs +40 -0
- package/dist/chunk-I7PUUDGY.cjs +389 -0
- package/dist/chunk-IAMRBF3Z.cjs +86 -0
- package/dist/chunk-IQXFRNY2.cjs +169 -0
- package/dist/chunk-ISTFC3MZ.cjs +1357 -0
- package/dist/chunk-IXTFU4PL.cjs +2355 -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-KR6CKSXT.cjs +15 -0
- package/dist/chunk-KROWKCUH.cjs +185 -0
- package/dist/chunk-KVFPGF2M.cjs +46 -0
- package/dist/{chunk-TNBAYAWO.mjs → chunk-L4DVIHOC.mjs} +1 -1
- 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-XWAYMDLB.mjs → chunk-MVUREHPN.mjs} +1 -1
- package/dist/chunk-MWSK6C4J.cjs +18 -0
- package/dist/chunk-MWWVKDW3.cjs +169 -0
- package/dist/{chunk-6VQIKZZO.mjs → chunk-N255VYFP.mjs} +1 -1
- package/dist/chunk-NBAHDVOJ.cjs +2040 -0
- package/dist/chunk-NO3WWW3N.cjs +192 -0
- package/dist/chunk-NSFC3LHB.cjs +10244 -0
- package/dist/chunk-NZKJGRB3.cjs +230 -0
- package/dist/chunk-OAVTUMJP.cjs +1496 -0
- package/dist/{chunk-SXHV42UQ.mjs → chunk-OFEY6KHO.mjs} +88 -13
- package/dist/chunk-OHY2ZWUG.cjs +25 -0
- package/dist/chunk-OI6CMLWX.cjs +47 -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-OYDRPBBV.cjs +453 -0
- package/dist/chunk-OYEUREB6.cjs +35 -0
- package/dist/chunk-PCOTGFSM.cjs +139 -0
- package/dist/{chunk-76DG3LF3.mjs → chunk-PGQBL5DN.mjs} +1 -1
- package/dist/chunk-PZYCPSCC.cjs +35 -0
- package/dist/chunk-QBK2AA4U.cjs +445 -0
- package/dist/{chunk-UTBVHYS3.mjs → chunk-QBPKKQTD.mjs} +2 -2
- 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-RFYO7QUD.cjs +9 -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-S27FMYAM.cjs +644 -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-U4KT7QP3.cjs +23 -0
- package/dist/chunk-U5BMPGS3.cjs +862 -0
- package/dist/chunk-UJ2C4ICS.cjs +277 -0
- package/dist/chunk-UQZ4AYTH.cjs +168 -0
- package/dist/chunk-US2QVW3E.cjs +36 -0
- package/dist/{chunk-QGVJVSNX.mjs → chunk-V4AICMQA.mjs} +2 -2
- 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-56DAX2BE.mjs → chunk-WZXN4R5Y.mjs} +24 -13
- package/dist/chunk-XDGMADQM.cjs +14225 -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-5KGPDVKL.cjs +388 -0
- package/dist/{devtools-UFVTMQX5.mjs → devtools-FY5R7TQ4.mjs} +3 -3
- package/dist/devtools-client-4WAPJY5L.cjs +254 -0
- package/dist/devtools-ui-5GBDIGMK.cjs +1296 -0
- package/dist/docs.cjs +46 -5657
- package/dist/docs.mjs +5 -5
- 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 +14 -14
- 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/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +120 -52259
- package/dist/internal/build-runtime.mjs +13 -13
- package/dist/internal/cli-runtime.cjs +67 -13811
- package/dist/internal/cli-runtime.mjs +7 -7
- 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/config-runtime.mjs +3 -3
- 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/production-runtime.mjs +3 -3
- 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/markdown.mjs +1 -1
- 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 +9 -9
- 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-2IE2F2XI.mjs → schema-dev-notice-O67CPXJ6.mjs} +1 -1
- package/dist/schema-dev-notice-Y7MQEFGN.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 +11 -11
- 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 +9 -9
- package/dist/workflows.cjs +19 -1040
- package/package.json +1 -1
|
@@ -0,0 +1,1102 @@
|
|
|
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; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunk5OVTOKGHcjs = require('./chunk-5OVTOKGH.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkR5A5KNVXcjs = require('./chunk-R5A5KNVX.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunkSWN467MPcjs = require('./chunk-SWN467MP.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkJ7FSKED3cjs = require('./chunk-J7FSKED3.cjs');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunkOXSIH4D6cjs = require('./chunk-OXSIH4D6.cjs');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var _chunkC5GUTBZKcjs = require('./chunk-C5GUTBZK.cjs');
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _chunkQBK2AA4Ucjs = require('./chunk-QBK2AA4U.cjs');
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
31
|
+
|
|
32
|
+
// src/client/metadata-reconciler.ts
|
|
33
|
+
var MANAGED_ATTRIBUTE = _chunkOXSIH4D6cjs.FARM_METADATA_ATTRIBUTE;
|
|
34
|
+
var OWNED_SELECTORS = [
|
|
35
|
+
'meta[name="description"]',
|
|
36
|
+
'meta[name="keywords"]',
|
|
37
|
+
'meta[name="author"]',
|
|
38
|
+
'meta[name="google-site-verification"]',
|
|
39
|
+
'meta[name="msvalidate.01"]',
|
|
40
|
+
'meta[name="yandex-verification"]',
|
|
41
|
+
'meta[name="creator"]',
|
|
42
|
+
'meta[name="publisher"]',
|
|
43
|
+
'meta[name="robots"]',
|
|
44
|
+
'meta[name="googlebot"]',
|
|
45
|
+
'link[rel="author"]',
|
|
46
|
+
'link[rel="canonical"]',
|
|
47
|
+
'link[rel="alternate"]',
|
|
48
|
+
'meta[property^="og:"]',
|
|
49
|
+
'meta[property^="article:"]',
|
|
50
|
+
'meta[name^="twitter:"]',
|
|
51
|
+
// Meta tags named by the app carry the marker, since no fixed name matches them.
|
|
52
|
+
`meta[${MANAGED_ATTRIBUTE}]`
|
|
53
|
+
].join(", ");
|
|
54
|
+
var ICON_SELECTORS = [
|
|
55
|
+
'link[rel="icon"]',
|
|
56
|
+
'link[rel="shortcut icon"]',
|
|
57
|
+
'link[rel="apple-touch-icon"]'
|
|
58
|
+
].join(", ");
|
|
59
|
+
var MANIFEST_SELECTOR = 'link[rel="manifest"]';
|
|
60
|
+
var PAGE_JSON_LD_SELECTOR = `script[type="application/ld+json"][${MANAGED_ATTRIBUTE}]`;
|
|
61
|
+
function removeAll(selector) {
|
|
62
|
+
for (const element of Array.from(document.head.querySelectorAll(selector))) {
|
|
63
|
+
element.remove();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, removeAll, "removeAll");
|
|
67
|
+
function applyFarmMetadataToDocument(metadata, pathname) {
|
|
68
|
+
document.title = _chunkOXSIH4D6cjs.resolveMetadataTitle.call(void 0, _optionalChain([metadata, 'optionalAccess', _ => _.title])) || "Farm.js App";
|
|
69
|
+
const rendered = _chunkOXSIH4D6cjs.renderMetadataHead.call(void 0, metadata, { pathname });
|
|
70
|
+
const template = document.createElement("template");
|
|
71
|
+
template.innerHTML = rendered.tags;
|
|
72
|
+
removeAll(OWNED_SELECTORS);
|
|
73
|
+
removeAll(PAGE_JSON_LD_SELECTOR);
|
|
74
|
+
if (_optionalChain([metadata, 'optionalAccess', _2 => _2.icons])) removeAll(ICON_SELECTORS);
|
|
75
|
+
if (_optionalChain([metadata, 'optionalAccess', _3 => _3.manifest])) removeAll(MANIFEST_SELECTOR);
|
|
76
|
+
for (const element of Array.from(template.content.children)) {
|
|
77
|
+
element.setAttribute(MANAGED_ATTRIBUTE, "");
|
|
78
|
+
document.head.appendChild(element);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, applyFarmMetadataToDocument, "applyFarmMetadataToDocument");
|
|
82
|
+
|
|
83
|
+
// src/client/spa-router.ts
|
|
84
|
+
var MAX_CONCURRENT_VIEWPORT_PREFETCHES = 4;
|
|
85
|
+
var FARM_PAGE_STATE_KEY = "__farmPageState";
|
|
86
|
+
var FARM_INTERCEPT_FROM_KEY = "__farmInterceptFrom";
|
|
87
|
+
var FARM_HISTORY_INDEX_KEY = "__farmHistoryIndex";
|
|
88
|
+
function readHistoryIndex(state) {
|
|
89
|
+
if (!state || typeof state !== "object") return null;
|
|
90
|
+
const value = state[FARM_HISTORY_INDEX_KEY];
|
|
91
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
92
|
+
}
|
|
93
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readHistoryIndex, "readHistoryIndex");
|
|
94
|
+
var IDLE_NAVIGATION_STATE = {
|
|
95
|
+
state: "idle",
|
|
96
|
+
pending: false,
|
|
97
|
+
from: null,
|
|
98
|
+
to: null,
|
|
99
|
+
action: null,
|
|
100
|
+
startedAt: null
|
|
101
|
+
};
|
|
102
|
+
function getActiveLayoutChainHeader() {
|
|
103
|
+
if (typeof document === "undefined") return void 0;
|
|
104
|
+
const patterns = Array.from(
|
|
105
|
+
document.querySelectorAll('[data-farm-layout-boundary="true"]')
|
|
106
|
+
).map((element) => element.dataset.farmLayoutPattern).filter((pattern) => Boolean(pattern));
|
|
107
|
+
return patterns.length > 0 ? JSON.stringify(patterns) : void 0;
|
|
108
|
+
}
|
|
109
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getActiveLayoutChainHeader, "getActiveLayoutChainHeader");
|
|
110
|
+
var routerInstance = null;
|
|
111
|
+
var _SPARouter = class _SPARouter {
|
|
112
|
+
constructor(options = {}) {
|
|
113
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
114
|
+
this.prefetchingUrls = /* @__PURE__ */ new Set();
|
|
115
|
+
this.pendingPrefetches = /* @__PURE__ */ new Map();
|
|
116
|
+
this.cacheGeneration = 0;
|
|
117
|
+
this.observedPrefetchLinks = /* @__PURE__ */ new Map();
|
|
118
|
+
this.prefetchTimers = /* @__PURE__ */ new Map();
|
|
119
|
+
this.viewportPrefetchQueue = [];
|
|
120
|
+
this.viewportPrefetchTasksByHref = /* @__PURE__ */ new Map();
|
|
121
|
+
this.viewportPrefetchTasksByElement = /* @__PURE__ */ new Map();
|
|
122
|
+
this.activeViewportPrefetches = 0;
|
|
123
|
+
this.destroyed = false;
|
|
124
|
+
this.blockers = /* @__PURE__ */ new Set();
|
|
125
|
+
this.unloadBlockers = /* @__PURE__ */ new Map();
|
|
126
|
+
this.navigationListeners = /* @__PURE__ */ new Set();
|
|
127
|
+
this.navigationState = IDLE_NAVIGATION_STATE;
|
|
128
|
+
this.currentHistoryPath = null;
|
|
129
|
+
this.currentHistoryHash = "";
|
|
130
|
+
this.currentHistoryIndex = null;
|
|
131
|
+
this.suppressNextPopState = false;
|
|
132
|
+
this.navigationSequence = 0;
|
|
133
|
+
this.scrollElements = /* @__PURE__ */ new Map();
|
|
134
|
+
this.onPopState = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (event) => {
|
|
135
|
+
void this.handlePopState(event);
|
|
136
|
+
}, "onPopState");
|
|
137
|
+
this.onBeforeUnload = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (event) => {
|
|
138
|
+
if (this.shouldBlockUnload()) {
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
event.returnValue = "";
|
|
141
|
+
}
|
|
142
|
+
this.saveScrollPosition(window.location.pathname + window.location.search);
|
|
143
|
+
}, "onBeforeUnload");
|
|
144
|
+
this.options = {
|
|
145
|
+
prefetchTimeout: _nullishCoalesce(options.prefetchTimeout, () => ( 100)),
|
|
146
|
+
cacheMaxAge: _nullishCoalesce(options.cacheMaxAge, () => ( 3e4)),
|
|
147
|
+
// 30 seconds
|
|
148
|
+
scrollRestoration: _nullishCoalesce(options.scrollRestoration, () => ( true)),
|
|
149
|
+
shouldUseDocumentNavigation: _nullishCoalesce(options.shouldUseDocumentNavigation, () => ( (() => false))),
|
|
150
|
+
deploymentId: _nullishCoalesce(options.deploymentId, () => ( readBrowserDeploymentId()))
|
|
151
|
+
};
|
|
152
|
+
if (typeof window !== "undefined") {
|
|
153
|
+
window.addEventListener("popstate", this.onPopState);
|
|
154
|
+
window.addEventListener("beforeunload", this.onBeforeUnload);
|
|
155
|
+
this.currentHistoryPath = window.location.pathname + window.location.search;
|
|
156
|
+
this.currentHistoryHash = window.location.hash;
|
|
157
|
+
this.currentInterceptFrom = _optionalChain([window, 'access', _4 => _4.history, 'access', _5 => _5.state, 'optionalAccess', _6 => _6[FARM_INTERCEPT_FROM_KEY]]);
|
|
158
|
+
const existingIndex = readHistoryIndex(window.history.state);
|
|
159
|
+
if (existingIndex == null) {
|
|
160
|
+
try {
|
|
161
|
+
window.history.replaceState(
|
|
162
|
+
{
|
|
163
|
+
..._nullishCoalesce(window.history.state, () => ( {})),
|
|
164
|
+
[FARM_HISTORY_INDEX_KEY]: 0
|
|
165
|
+
},
|
|
166
|
+
"",
|
|
167
|
+
window.location.href
|
|
168
|
+
);
|
|
169
|
+
this.currentHistoryIndex = 0;
|
|
170
|
+
} catch (e) {
|
|
171
|
+
this.currentHistoryIndex = null;
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
this.currentHistoryIndex = existingIndex;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/** Remove global listeners. Intended for tests and teardown. */
|
|
179
|
+
destroy() {
|
|
180
|
+
if (typeof window === "undefined") return;
|
|
181
|
+
this.destroyed = true;
|
|
182
|
+
this.cancelActiveNavigation();
|
|
183
|
+
this.clearCache();
|
|
184
|
+
_optionalChain([this, 'access', _7 => _7.prefetchObserver, 'optionalAccess', _8 => _8.disconnect, 'call', _9 => _9()]);
|
|
185
|
+
this.prefetchObserver = void 0;
|
|
186
|
+
for (const timer of this.prefetchTimers.values()) clearTimeout(timer);
|
|
187
|
+
this.observedPrefetchLinks.clear();
|
|
188
|
+
this.prefetchTimers.clear();
|
|
189
|
+
for (const task of this.viewportPrefetchQueue) task.cancelled = true;
|
|
190
|
+
this.viewportPrefetchQueue.length = 0;
|
|
191
|
+
this.viewportPrefetchTasksByHref.clear();
|
|
192
|
+
this.viewportPrefetchTasksByElement.clear();
|
|
193
|
+
window.removeEventListener("popstate", this.onPopState);
|
|
194
|
+
window.removeEventListener("beforeunload", this.onBeforeUnload);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Set the navigation handler that updates React
|
|
198
|
+
*/
|
|
199
|
+
setNavigationHandler(handler) {
|
|
200
|
+
this.onNavigate = handler;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Connect Farm's browser plugin lifecycle to SPA navigation.
|
|
204
|
+
*/
|
|
205
|
+
setClientPluginManager(manager) {
|
|
206
|
+
this.clientPlugins = manager;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Navigate to a new URL
|
|
210
|
+
*/
|
|
211
|
+
async navigate(href, options = {}) {
|
|
212
|
+
const {
|
|
213
|
+
replace = false,
|
|
214
|
+
scroll = true,
|
|
215
|
+
state,
|
|
216
|
+
viewTransition = false,
|
|
217
|
+
refresh = false
|
|
218
|
+
} = options;
|
|
219
|
+
const url = _chunkSWN467MPcjs.resolveFarmNavigationURL.call(void 0, href, window.location.href);
|
|
220
|
+
const pathname = url.pathname;
|
|
221
|
+
const search = url.search;
|
|
222
|
+
const fullPath = pathname + search;
|
|
223
|
+
if (_chunkSWN467MPcjs.isFarmExternalNavigationURL.call(void 0, url, window.location.origin) || _chunk5OVTOKGHcjs.isFarmLocaleChangeHref.call(void 0, url.toString()) || this.options.shouldUseDocumentNavigation(pathname)) {
|
|
224
|
+
this.cancelActiveNavigation();
|
|
225
|
+
if (replace) window.location.replace(url.toString());
|
|
226
|
+
else window.location.assign(url.toString());
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (!refresh && pathname === window.location.pathname && search === window.location.search) {
|
|
230
|
+
this.cancelActiveNavigation();
|
|
231
|
+
if (url.hash === window.location.hash) return;
|
|
232
|
+
this.writePageState(
|
|
233
|
+
replace ? "replace" : "push",
|
|
234
|
+
state === void 0 ? readPageState() : state,
|
|
235
|
+
url.toString()
|
|
236
|
+
);
|
|
237
|
+
if (scroll) {
|
|
238
|
+
if (url.hash) {
|
|
239
|
+
_optionalChain([_chunkR5A5KNVXcjs.getHashTargetElement.call(void 0, url.hash), 'optionalAccess', _10 => _10.scrollIntoView, 'call', _11 => _11()]);
|
|
240
|
+
} else {
|
|
241
|
+
window.scrollTo(0, 0);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const from = window.location.pathname + window.location.search;
|
|
247
|
+
if (await this.shouldBlockNavigation({
|
|
248
|
+
from,
|
|
249
|
+
to: fullPath,
|
|
250
|
+
action: replace ? "replace" : "push"
|
|
251
|
+
})) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (this.options.scrollRestoration) {
|
|
255
|
+
this.saveScrollPosition(window.location.pathname + window.location.search);
|
|
256
|
+
}
|
|
257
|
+
const navigation = this.startNavigation({
|
|
258
|
+
from,
|
|
259
|
+
to: createNavigationLocation(url),
|
|
260
|
+
action: replace ? "replace" : "push"
|
|
261
|
+
});
|
|
262
|
+
let clientNavigation;
|
|
263
|
+
try {
|
|
264
|
+
clientNavigation = await _optionalChain([this, 'access', _12 => _12.clientPlugins, 'optionalAccess', _13 => _13.beginNavigation, 'call', _14 => _14({
|
|
265
|
+
from,
|
|
266
|
+
to: url,
|
|
267
|
+
action: replace ? "replace" : "push"
|
|
268
|
+
})]);
|
|
269
|
+
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
270
|
+
const pageData = await this.fetchPageData(
|
|
271
|
+
fullPath,
|
|
272
|
+
true,
|
|
273
|
+
from,
|
|
274
|
+
refresh,
|
|
275
|
+
navigation.controller.signal
|
|
276
|
+
);
|
|
277
|
+
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
278
|
+
if (clientNavigation) {
|
|
279
|
+
await _optionalChain([this, 'access', _15 => _15.clientPlugins, 'optionalAccess', _16 => _16.markNavigationLoaded, 'call', _17 => _17(clientNavigation, pageData)]);
|
|
280
|
+
}
|
|
281
|
+
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
282
|
+
await this.runViewTransition(
|
|
283
|
+
viewTransition,
|
|
284
|
+
() => this.isCurrentNavigation(navigation, clientNavigation) ? this.commitNavigation({
|
|
285
|
+
fullPath,
|
|
286
|
+
pageData,
|
|
287
|
+
pathname,
|
|
288
|
+
replace,
|
|
289
|
+
scroll,
|
|
290
|
+
state,
|
|
291
|
+
url
|
|
292
|
+
}) : Promise.resolve()
|
|
293
|
+
);
|
|
294
|
+
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
295
|
+
if (clientNavigation) {
|
|
296
|
+
await _optionalChain([this, 'access', _18 => _18.clientPlugins, 'optionalAccess', _19 => _19.resolveNavigation, 'call', _20 => _20(clientNavigation)]);
|
|
297
|
+
void _optionalChain([this, 'access', _21 => _21.clientPlugins, 'optionalAccess', _22 => _22.scheduleNavigationRendered, 'call', _23 => _23(clientNavigation)]);
|
|
298
|
+
}
|
|
299
|
+
this.finishNavigation(navigation);
|
|
300
|
+
} catch (error) {
|
|
301
|
+
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
302
|
+
if (clientNavigation) {
|
|
303
|
+
await _optionalChain([this, 'access', _24 => _24.clientPlugins, 'optionalAccess', _25 => _25.failNavigation, 'call', _26 => _26(clientNavigation, error)]);
|
|
304
|
+
}
|
|
305
|
+
this.finishNavigation(navigation);
|
|
306
|
+
console.error("[Farm.js] Navigation error:", error);
|
|
307
|
+
window.location.href = href;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Re-render the active route from the server while preserving the document,
|
|
312
|
+
* shared layouts, client runtime, and browser history entry.
|
|
313
|
+
*/
|
|
314
|
+
refresh(options = {}) {
|
|
315
|
+
return this.navigate(window.location.href, {
|
|
316
|
+
...options,
|
|
317
|
+
replace: true,
|
|
318
|
+
refresh: true,
|
|
319
|
+
scroll: _nullishCoalesce(options.scroll, () => ( false))
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Prefetch a URL
|
|
324
|
+
*/
|
|
325
|
+
async prefetch(href) {
|
|
326
|
+
if (this.destroyed) return;
|
|
327
|
+
if (_chunk5OVTOKGHcjs.isFarmLocaleChangeHref.call(void 0, href)) return;
|
|
328
|
+
const url = _chunkSWN467MPcjs.resolveFarmNavigationURL.call(void 0, href, window.location.href);
|
|
329
|
+
if (_chunkSWN467MPcjs.isFarmExternalNavigationURL.call(void 0, url, window.location.origin)) return;
|
|
330
|
+
if (this.options.shouldUseDocumentNavigation(url.pathname)) return;
|
|
331
|
+
const fullPath = url.pathname + url.search;
|
|
332
|
+
const interceptFrom = window.location.pathname + window.location.search;
|
|
333
|
+
if (this.prefetchingUrls.has(fullPath)) return;
|
|
334
|
+
if (this.isCached(fullPath, interceptFrom)) return;
|
|
335
|
+
this.prefetchingUrls.add(fullPath);
|
|
336
|
+
try {
|
|
337
|
+
await this.fetchPageData(fullPath, false, interceptFrom);
|
|
338
|
+
} catch (error) {
|
|
339
|
+
console.warn("[Farm.js] Prefetch failed:", href, error);
|
|
340
|
+
} finally {
|
|
341
|
+
this.prefetchingUrls.delete(fullPath);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Observe an element for viewport intersection (prefetch when visible)
|
|
346
|
+
*/
|
|
347
|
+
observeForPrefetch(element) {
|
|
348
|
+
if (this.destroyed || typeof IntersectionObserver === "undefined") return;
|
|
349
|
+
const href = element.getAttribute("href");
|
|
350
|
+
if (!href || this.isExternalUrl(href)) return;
|
|
351
|
+
this.unobserveForPrefetch(element);
|
|
352
|
+
const observer = this.getPrefetchObserver();
|
|
353
|
+
this.observedPrefetchLinks.set(element, href);
|
|
354
|
+
observer.observe(element);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Stop observing an element
|
|
358
|
+
*/
|
|
359
|
+
unobserveForPrefetch(element) {
|
|
360
|
+
if (this.observedPrefetchLinks.delete(element)) {
|
|
361
|
+
_optionalChain([this, 'access', _27 => _27.prefetchObserver, 'optionalAccess', _28 => _28.unobserve, 'call', _29 => _29(element)]);
|
|
362
|
+
}
|
|
363
|
+
const timer = this.prefetchTimers.get(element);
|
|
364
|
+
if (timer !== void 0) {
|
|
365
|
+
clearTimeout(timer);
|
|
366
|
+
this.prefetchTimers.delete(element);
|
|
367
|
+
}
|
|
368
|
+
this.cancelQueuedViewportPrefetch(element);
|
|
369
|
+
}
|
|
370
|
+
getPrefetchObserver() {
|
|
371
|
+
_nullishCoalesce(this.prefetchObserver, () => ( (this.prefetchObserver = new IntersectionObserver(
|
|
372
|
+
(entries) => {
|
|
373
|
+
for (const entry of entries) {
|
|
374
|
+
if (!entry.isIntersecting) continue;
|
|
375
|
+
const element = entry.target;
|
|
376
|
+
const href = this.observedPrefetchLinks.get(element);
|
|
377
|
+
if (!href) continue;
|
|
378
|
+
_optionalChain([this, 'access', _30 => _30.prefetchObserver, 'optionalAccess', _31 => _31.unobserve, 'call', _32 => _32(element)]);
|
|
379
|
+
this.observedPrefetchLinks.delete(element);
|
|
380
|
+
const timer = setTimeout(() => {
|
|
381
|
+
if (this.prefetchTimers.get(element) !== timer) return;
|
|
382
|
+
this.prefetchTimers.delete(element);
|
|
383
|
+
this.enqueueViewportPrefetch(element, href);
|
|
384
|
+
}, this.options.prefetchTimeout);
|
|
385
|
+
this.prefetchTimers.set(element, timer);
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
{ rootMargin: "200px" }
|
|
389
|
+
))));
|
|
390
|
+
return this.prefetchObserver;
|
|
391
|
+
}
|
|
392
|
+
enqueueViewportPrefetch(element, href) {
|
|
393
|
+
if (this.destroyed) return;
|
|
394
|
+
let task = this.viewportPrefetchTasksByHref.get(href);
|
|
395
|
+
if (!task) {
|
|
396
|
+
task = { href, elements: /* @__PURE__ */ new Set(), cancelled: false, started: false };
|
|
397
|
+
this.viewportPrefetchTasksByHref.set(href, task);
|
|
398
|
+
this.viewportPrefetchQueue.push(task);
|
|
399
|
+
}
|
|
400
|
+
task.elements.add(element);
|
|
401
|
+
this.viewportPrefetchTasksByElement.set(element, task);
|
|
402
|
+
this.drainViewportPrefetchQueue();
|
|
403
|
+
}
|
|
404
|
+
cancelQueuedViewportPrefetch(element) {
|
|
405
|
+
const task = this.viewportPrefetchTasksByElement.get(element);
|
|
406
|
+
if (!task) return;
|
|
407
|
+
this.viewportPrefetchTasksByElement.delete(element);
|
|
408
|
+
task.elements.delete(element);
|
|
409
|
+
if (task.elements.size > 0) return;
|
|
410
|
+
if (task.started) return;
|
|
411
|
+
task.cancelled = true;
|
|
412
|
+
if (this.viewportPrefetchTasksByHref.get(task.href) === task) {
|
|
413
|
+
this.viewportPrefetchTasksByHref.delete(task.href);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
drainViewportPrefetchQueue() {
|
|
417
|
+
while (!this.destroyed && this.activeViewportPrefetches < MAX_CONCURRENT_VIEWPORT_PREFETCHES && this.viewportPrefetchQueue.length > 0) {
|
|
418
|
+
const task = this.viewportPrefetchQueue.shift();
|
|
419
|
+
if (task.cancelled || task.elements.size === 0) {
|
|
420
|
+
if (this.viewportPrefetchTasksByHref.get(task.href) === task) {
|
|
421
|
+
this.viewportPrefetchTasksByHref.delete(task.href);
|
|
422
|
+
}
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
task.started = true;
|
|
426
|
+
this.activeViewportPrefetches += 1;
|
|
427
|
+
let prefetchResult;
|
|
428
|
+
try {
|
|
429
|
+
prefetchResult = this.prefetch(task.href);
|
|
430
|
+
} catch (e2) {
|
|
431
|
+
prefetchResult = void 0;
|
|
432
|
+
}
|
|
433
|
+
void Promise.resolve(prefetchResult).catch(() => void 0).finally(() => {
|
|
434
|
+
if (this.viewportPrefetchTasksByHref.get(task.href) === task) {
|
|
435
|
+
this.viewportPrefetchTasksByHref.delete(task.href);
|
|
436
|
+
}
|
|
437
|
+
for (const element of task.elements) {
|
|
438
|
+
if (this.viewportPrefetchTasksByElement.get(element) === task) {
|
|
439
|
+
this.viewportPrefetchTasksByElement.delete(element);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
this.activeViewportPrefetches -= 1;
|
|
443
|
+
this.drainViewportPrefetchQueue();
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
addBlocker(blocker, shouldBlockUnload) {
|
|
448
|
+
this.blockers.add(blocker);
|
|
449
|
+
this.unloadBlockers.set(
|
|
450
|
+
blocker,
|
|
451
|
+
_nullishCoalesce(shouldBlockUnload, () => ( (() => this.evaluateBlockerForUnload(blocker))))
|
|
452
|
+
);
|
|
453
|
+
return () => {
|
|
454
|
+
this.blockers.delete(blocker);
|
|
455
|
+
this.unloadBlockers.delete(blocker);
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
getNavigationState() {
|
|
459
|
+
return this.navigationState;
|
|
460
|
+
}
|
|
461
|
+
subscribeNavigation(listener) {
|
|
462
|
+
this.navigationListeners.add(listener);
|
|
463
|
+
listener(this.navigationState);
|
|
464
|
+
return () => {
|
|
465
|
+
this.navigationListeners.delete(listener);
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
registerScrollElement(key, element) {
|
|
469
|
+
this.scrollElements.set(key, element);
|
|
470
|
+
this.restoreScrollElement(window.location.pathname + window.location.search, key, element);
|
|
471
|
+
return () => {
|
|
472
|
+
if (this.scrollElements.get(key) === element) {
|
|
473
|
+
this.scrollElements.delete(key);
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
pushState(state, href) {
|
|
478
|
+
this.writePageState("push", state, href);
|
|
479
|
+
}
|
|
480
|
+
replaceState(state, href) {
|
|
481
|
+
this.writePageState("replace", state, href);
|
|
482
|
+
}
|
|
483
|
+
/** @internal Keep shallow URL-search writes inside the router's history bookkeeping. */
|
|
484
|
+
writeURLSearch(action, href) {
|
|
485
|
+
this.writePageState(action, readPageState(), href, false);
|
|
486
|
+
}
|
|
487
|
+
async commitNavigation(options) {
|
|
488
|
+
const historyUrl = _chunkSWN467MPcjs.resolveFarmNavigationURL.call(void 0,
|
|
489
|
+
options.pageData.canonicalPath || options.fullPath,
|
|
490
|
+
window.location.href
|
|
491
|
+
);
|
|
492
|
+
historyUrl.hash = options.url.hash;
|
|
493
|
+
const historyPath = historyUrl.pathname + historyUrl.search + historyUrl.hash;
|
|
494
|
+
const historyState = createHistoryState(
|
|
495
|
+
historyPath,
|
|
496
|
+
options.state,
|
|
497
|
+
options.replace ? window.history.state : void 0,
|
|
498
|
+
_nullishCoalesce(_optionalChain([options, 'access', _33 => _33.pageData, 'access', _34 => _34.interception, 'optionalAccess', _35 => _35.from]), () => ( null))
|
|
499
|
+
);
|
|
500
|
+
const nextHistoryIndex = this.currentHistoryIndex == null ? null : options.replace ? this.currentHistoryIndex : this.currentHistoryIndex + 1;
|
|
501
|
+
if (nextHistoryIndex != null) {
|
|
502
|
+
historyState[FARM_HISTORY_INDEX_KEY] = nextHistoryIndex;
|
|
503
|
+
}
|
|
504
|
+
if (options.replace) {
|
|
505
|
+
window.history.replaceState(historyState, "", historyPath);
|
|
506
|
+
} else {
|
|
507
|
+
window.history.pushState(historyState, "", historyPath);
|
|
508
|
+
}
|
|
509
|
+
this.currentHistoryIndex = nextHistoryIndex;
|
|
510
|
+
const resolvedHistoryUrl = _chunkSWN467MPcjs.resolveFarmNavigationURL.call(void 0, historyPath, window.location.href);
|
|
511
|
+
this.currentHistoryPath = resolvedHistoryUrl.pathname + resolvedHistoryUrl.search;
|
|
512
|
+
this.currentHistoryHash = resolvedHistoryUrl.hash;
|
|
513
|
+
this.currentInterceptFrom = historyState[FARM_INTERCEPT_FROM_KEY];
|
|
514
|
+
notifyRouterHistoryChange();
|
|
515
|
+
this.updateDocumentMetadata(options.pageData.metadata);
|
|
516
|
+
_chunk5OVTOKGHcjs._hydrateFarmI18n.call(void 0, options.pageData.i18n);
|
|
517
|
+
if (this.onNavigate) {
|
|
518
|
+
await this.onNavigate(options.pageData);
|
|
519
|
+
}
|
|
520
|
+
if (options.scroll) {
|
|
521
|
+
if (options.url.hash) {
|
|
522
|
+
const element = _chunkR5A5KNVXcjs.getHashTargetElement.call(void 0, options.url.hash);
|
|
523
|
+
if (element) {
|
|
524
|
+
element.scrollIntoView();
|
|
525
|
+
}
|
|
526
|
+
} else {
|
|
527
|
+
window.scrollTo(0, 0);
|
|
528
|
+
}
|
|
529
|
+
} else if (this.options.scrollRestoration) {
|
|
530
|
+
const restorePath = _nullishCoalesce(this.currentHistoryPath, () => ( options.fullPath));
|
|
531
|
+
this.restoreWindowScroll(restorePath);
|
|
532
|
+
this.restoreScrollElements(restorePath);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
async runViewTransition(mode, callback) {
|
|
536
|
+
if (!mode || typeof document === "undefined") {
|
|
537
|
+
await callback();
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
const startViewTransition = document.startViewTransition;
|
|
541
|
+
if (typeof startViewTransition !== "function") {
|
|
542
|
+
await callback();
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const transition = startViewTransition.call(document, () => callback());
|
|
546
|
+
const updateDone = _optionalChain([transition, 'optionalAccess', _36 => _36.updateCallbackDone]) || _optionalChain([transition, 'optionalAccess', _37 => _37.ready]);
|
|
547
|
+
if (updateDone && typeof updateDone.then === "function") {
|
|
548
|
+
await updateDone;
|
|
549
|
+
}
|
|
550
|
+
_optionalChain([transition, 'optionalAccess', _38 => _38.finished, 'optionalAccess', _39 => _39.catch, 'optionalCall', _40 => _40(() => void 0)]);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Fetch page data from cache or server
|
|
554
|
+
*/
|
|
555
|
+
async fetchPageData(path, recover = true, interceptFrom, fresh = false, signal) {
|
|
556
|
+
const cacheKey = getPageDataCacheKey(path, interceptFrom);
|
|
557
|
+
const cached = fresh ? void 0 : this.cache.get(cacheKey);
|
|
558
|
+
if (cached && Date.now() - cached.timestamp < this.options.cacheMaxAge) {
|
|
559
|
+
return cached.data;
|
|
560
|
+
}
|
|
561
|
+
const activeLayoutChain = getActiveLayoutChainHeader();
|
|
562
|
+
const prefetchKey = JSON.stringify([path, interceptFrom, activeLayoutChain]);
|
|
563
|
+
let generation = this.cacheGeneration;
|
|
564
|
+
const pending = this.pendingPrefetches.get(prefetchKey);
|
|
565
|
+
if (pending && recover) {
|
|
566
|
+
if (fresh) {
|
|
567
|
+
pending.cacheable = false;
|
|
568
|
+
pending.resolve(void 0);
|
|
569
|
+
this.pendingPrefetches.delete(prefetchKey);
|
|
570
|
+
} else {
|
|
571
|
+
const cancellation = _chunkJ7FSKED3cjs.createClientCancellation.call(void 0, signal);
|
|
572
|
+
try {
|
|
573
|
+
const data = await cancellation.run(() => pending.data);
|
|
574
|
+
cancellation.check();
|
|
575
|
+
if (data && pending.cacheable && generation === this.cacheGeneration) return data;
|
|
576
|
+
} finally {
|
|
577
|
+
cancellation.dispose();
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
generation = this.cacheGeneration;
|
|
582
|
+
let prefetch2;
|
|
583
|
+
if (!recover) {
|
|
584
|
+
let resolve;
|
|
585
|
+
const data = new Promise((done) => {
|
|
586
|
+
resolve = done;
|
|
587
|
+
});
|
|
588
|
+
prefetch2 = { data, resolve, cacheable: true };
|
|
589
|
+
this.pendingPrefetches.set(prefetchKey, prefetch2);
|
|
590
|
+
}
|
|
591
|
+
const cacheData = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (data) => {
|
|
592
|
+
if (!this.destroyed && generation === this.cacheGeneration && _optionalChain([prefetch2, 'optionalAccess', _41 => _41.cacheable]) !== false) {
|
|
593
|
+
this.cachePageData(cacheKey, data);
|
|
594
|
+
}
|
|
595
|
+
}, "cacheData");
|
|
596
|
+
try {
|
|
597
|
+
return await this.requestPageData(
|
|
598
|
+
path,
|
|
599
|
+
recover,
|
|
600
|
+
interceptFrom,
|
|
601
|
+
activeLayoutChain,
|
|
602
|
+
signal,
|
|
603
|
+
cacheData,
|
|
604
|
+
_optionalChain([prefetch2, 'optionalAccess', _42 => _42.resolve])
|
|
605
|
+
);
|
|
606
|
+
} finally {
|
|
607
|
+
_optionalChain([prefetch2, 'optionalAccess', _43 => _43.resolve, 'call', _44 => _44(void 0)]);
|
|
608
|
+
if (prefetch2 && this.pendingPrefetches.get(prefetchKey) === prefetch2) {
|
|
609
|
+
this.pendingPrefetches.delete(prefetchKey);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
async requestPageData(path, recover, interceptFrom, activeLayoutChain, signal, cacheData, resolvePrefetch) {
|
|
614
|
+
const response = await fetch(`/__farm/page-data?path=${encodeURIComponent(path)}`, {
|
|
615
|
+
signal,
|
|
616
|
+
headers: _chunkC5GUTBZKcjs.createFarmDeploymentRequestHeaders.call(void 0, this.options.deploymentId, {
|
|
617
|
+
Accept: "application/x-farm-deferred+json, application/json",
|
|
618
|
+
"X-Farm-SPA": "1",
|
|
619
|
+
...activeLayoutChain ? { "X-Farm-Layout-Chain": activeLayoutChain } : {},
|
|
620
|
+
...interceptFrom ? { "X-Farm-Intercept-From": interceptFrom } : {}
|
|
621
|
+
})
|
|
622
|
+
});
|
|
623
|
+
if (_chunkC5GUTBZKcjs.isFarmDeploymentMismatchResponse.call(void 0, response, this.options.deploymentId)) {
|
|
624
|
+
const error = _chunkC5GUTBZKcjs.createFarmDeploymentMismatchError.call(void 0,
|
|
625
|
+
response,
|
|
626
|
+
this.options.deploymentId || "unknown"
|
|
627
|
+
);
|
|
628
|
+
dispatchDeploymentMismatch(error);
|
|
629
|
+
if (recover) {
|
|
630
|
+
window.location.assign(path);
|
|
631
|
+
}
|
|
632
|
+
throw error;
|
|
633
|
+
}
|
|
634
|
+
if (!response.ok) {
|
|
635
|
+
throw new Error(`Failed to fetch page data: ${response.status}`);
|
|
636
|
+
}
|
|
637
|
+
const isDeferredResponse = (response.headers.get("Content-Type") || "").toLowerCase().startsWith("application/x-farm-deferred+json");
|
|
638
|
+
if (!isDeferredResponse) {
|
|
639
|
+
const data2 = await _chunkQBK2AA4Ucjs.readDeferredDataResponse.call(void 0, response);
|
|
640
|
+
cacheData(data2);
|
|
641
|
+
_optionalChain([resolvePrefetch, 'optionalCall', _45 => _45(data2)]);
|
|
642
|
+
return data2;
|
|
643
|
+
}
|
|
644
|
+
_optionalChain([resolvePrefetch, 'optionalCall', _46 => _46(void 0)]);
|
|
645
|
+
let data;
|
|
646
|
+
let streamCompleted = false;
|
|
647
|
+
const markStreamComplete = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
|
|
648
|
+
streamCompleted = true;
|
|
649
|
+
if (data) cacheData(data);
|
|
650
|
+
}, "markStreamComplete");
|
|
651
|
+
data = await _chunkQBK2AA4Ucjs.readDeferredDataResponse.call(void 0, response, {
|
|
652
|
+
onComplete: markStreamComplete
|
|
653
|
+
});
|
|
654
|
+
if (streamCompleted) cacheData(data);
|
|
655
|
+
return data;
|
|
656
|
+
}
|
|
657
|
+
cachePageData(cacheKey, data) {
|
|
658
|
+
const now = Date.now();
|
|
659
|
+
for (const [key, entry] of this.cache) {
|
|
660
|
+
if (now - entry.timestamp >= this.options.cacheMaxAge) this.cache.delete(key);
|
|
661
|
+
}
|
|
662
|
+
this.cache.set(cacheKey, { data, timestamp: now });
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Put the browser URL back on the rendered page after a blocked pop. When
|
|
666
|
+
* both entries carry a Farm history index the traversal is reversed
|
|
667
|
+
* exactly; otherwise the current path is pushed again, which restores the
|
|
668
|
+
* address bar at the cost of one extra history entry.
|
|
669
|
+
*/
|
|
670
|
+
revertBlockedPopState(event, from) {
|
|
671
|
+
const eventIndex = readHistoryIndex(event.state);
|
|
672
|
+
if (eventIndex != null && this.currentHistoryIndex != null) {
|
|
673
|
+
const delta = eventIndex - this.currentHistoryIndex;
|
|
674
|
+
if (delta !== 0) {
|
|
675
|
+
this.suppressNextPopState = true;
|
|
676
|
+
window.history.go(-delta);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
try {
|
|
681
|
+
const restoredState = {
|
|
682
|
+
path: from
|
|
683
|
+
};
|
|
684
|
+
if (this.currentHistoryIndex != null && eventIndex != null) {
|
|
685
|
+
restoredState[FARM_HISTORY_INDEX_KEY] = eventIndex + 1;
|
|
686
|
+
this.currentHistoryIndex = eventIndex + 1;
|
|
687
|
+
}
|
|
688
|
+
window.history.pushState(restoredState, "", from);
|
|
689
|
+
} catch (e3) {
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Handle browser back/forward navigation
|
|
694
|
+
*/
|
|
695
|
+
async handlePopState(event) {
|
|
696
|
+
if (document.documentElement.dataset.farmDocsRuntime === "true") return;
|
|
697
|
+
if (this.suppressNextPopState) {
|
|
698
|
+
this.suppressNextPopState = false;
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
const path = window.location.pathname + window.location.search;
|
|
702
|
+
const from = _nullishCoalesce(this.currentHistoryPath, () => ( path));
|
|
703
|
+
if (path === from && window.location.hash !== this.currentHistoryHash && _optionalChain([event, 'access', _47 => _47.state, 'optionalAccess', _48 => _48[FARM_INTERCEPT_FROM_KEY]]) === this.currentInterceptFrom) {
|
|
704
|
+
this.cancelActiveNavigation();
|
|
705
|
+
this.currentHistoryHash = window.location.hash;
|
|
706
|
+
this.currentHistoryIndex = readHistoryIndex(event.state);
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
if (await this.shouldBlockNavigation({
|
|
710
|
+
from,
|
|
711
|
+
to: path,
|
|
712
|
+
action: "pop"
|
|
713
|
+
})) {
|
|
714
|
+
this.revertBlockedPopState(event, from);
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
this.currentHistoryPath = path;
|
|
718
|
+
this.currentHistoryHash = window.location.hash;
|
|
719
|
+
this.currentInterceptFrom = _optionalChain([event, 'access', _49 => _49.state, 'optionalAccess', _50 => _50[FARM_INTERCEPT_FROM_KEY]]);
|
|
720
|
+
this.currentHistoryIndex = readHistoryIndex(event.state);
|
|
721
|
+
const navigation = this.startNavigation({
|
|
722
|
+
from,
|
|
723
|
+
to: createNavigationLocation(new URL(window.location.href)),
|
|
724
|
+
action: "pop"
|
|
725
|
+
});
|
|
726
|
+
let clientNavigation;
|
|
727
|
+
try {
|
|
728
|
+
clientNavigation = await _optionalChain([this, 'access', _51 => _51.clientPlugins, 'optionalAccess', _52 => _52.beginNavigation, 'call', _53 => _53({
|
|
729
|
+
from: null,
|
|
730
|
+
to: window.location.href,
|
|
731
|
+
action: "pop"
|
|
732
|
+
})]);
|
|
733
|
+
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
734
|
+
const interceptFrom = typeof _optionalChain([event, 'access', _54 => _54.state, 'optionalAccess', _55 => _55[FARM_INTERCEPT_FROM_KEY]]) === "string" ? event.state[FARM_INTERCEPT_FROM_KEY] : void 0;
|
|
735
|
+
const pageData = await this.fetchPageData(
|
|
736
|
+
path,
|
|
737
|
+
true,
|
|
738
|
+
interceptFrom,
|
|
739
|
+
false,
|
|
740
|
+
navigation.controller.signal
|
|
741
|
+
);
|
|
742
|
+
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
743
|
+
if (clientNavigation) {
|
|
744
|
+
await _optionalChain([this, 'access', _56 => _56.clientPlugins, 'optionalAccess', _57 => _57.markNavigationLoaded, 'call', _58 => _58(clientNavigation, pageData)]);
|
|
745
|
+
}
|
|
746
|
+
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
747
|
+
this.updateDocumentMetadata(pageData.metadata);
|
|
748
|
+
_chunk5OVTOKGHcjs._hydrateFarmI18n.call(void 0, pageData.i18n);
|
|
749
|
+
if (this.onNavigate) {
|
|
750
|
+
await this.onNavigate(pageData);
|
|
751
|
+
}
|
|
752
|
+
const destinationPath = window.location.pathname + window.location.search;
|
|
753
|
+
if (window.location.hash) {
|
|
754
|
+
const target = _chunkR5A5KNVXcjs.getHashTargetElement.call(void 0, window.location.hash);
|
|
755
|
+
if (target) {
|
|
756
|
+
target.scrollIntoView();
|
|
757
|
+
} else if (this.options.scrollRestoration) {
|
|
758
|
+
this.restoreWindowScroll(destinationPath);
|
|
759
|
+
}
|
|
760
|
+
} else if (this.options.scrollRestoration) {
|
|
761
|
+
this.restoreWindowScroll(destinationPath);
|
|
762
|
+
}
|
|
763
|
+
if (this.options.scrollRestoration) {
|
|
764
|
+
this.restoreScrollElements(destinationPath);
|
|
765
|
+
}
|
|
766
|
+
if (clientNavigation) {
|
|
767
|
+
await _optionalChain([this, 'access', _59 => _59.clientPlugins, 'optionalAccess', _60 => _60.resolveNavigation, 'call', _61 => _61(clientNavigation)]);
|
|
768
|
+
void _optionalChain([this, 'access', _62 => _62.clientPlugins, 'optionalAccess', _63 => _63.scheduleNavigationRendered, 'call', _64 => _64(clientNavigation)]);
|
|
769
|
+
}
|
|
770
|
+
this.finishNavigation(navigation);
|
|
771
|
+
} catch (error) {
|
|
772
|
+
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
773
|
+
if (clientNavigation) {
|
|
774
|
+
await _optionalChain([this, 'access', _65 => _65.clientPlugins, 'optionalAccess', _66 => _66.failNavigation, 'call', _67 => _67(clientNavigation, error)]);
|
|
775
|
+
}
|
|
776
|
+
this.finishNavigation(navigation);
|
|
777
|
+
console.error("[Farm.js] Popstate navigation error:", error);
|
|
778
|
+
window.location.reload();
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Check if URL is cached
|
|
783
|
+
*/
|
|
784
|
+
isCached(path, interceptFrom) {
|
|
785
|
+
const cached = this.cache.get(getPageDataCacheKey(path, interceptFrom));
|
|
786
|
+
return cached !== void 0 && Date.now() - cached.timestamp < this.options.cacheMaxAge;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Check if URL is external
|
|
790
|
+
*/
|
|
791
|
+
isExternalUrl(href) {
|
|
792
|
+
return href.startsWith("http://") || href.startsWith("https://") || href.startsWith("//");
|
|
793
|
+
}
|
|
794
|
+
async shouldBlockNavigation(context) {
|
|
795
|
+
for (const blocker of this.blockers) {
|
|
796
|
+
if (await blocker(context)) {
|
|
797
|
+
return true;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
return false;
|
|
801
|
+
}
|
|
802
|
+
evaluateBlockerForUnload(blocker) {
|
|
803
|
+
const path = window.location.pathname + window.location.search;
|
|
804
|
+
const result = blocker({ from: path, to: path, action: "replace" });
|
|
805
|
+
if (result && typeof result !== "boolean") {
|
|
806
|
+
void result.catch(() => void 0);
|
|
807
|
+
return true;
|
|
808
|
+
}
|
|
809
|
+
return result === true;
|
|
810
|
+
}
|
|
811
|
+
shouldBlockUnload() {
|
|
812
|
+
for (const blocker of this.blockers) {
|
|
813
|
+
try {
|
|
814
|
+
if (_optionalChain([this, 'access', _68 => _68.unloadBlockers, 'access', _69 => _69.get, 'call', _70 => _70(blocker), 'optionalCall', _71 => _71()])) return true;
|
|
815
|
+
} catch (e4) {
|
|
816
|
+
return true;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return false;
|
|
820
|
+
}
|
|
821
|
+
updateDocumentMetadata(metadata) {
|
|
822
|
+
applyFarmMetadataToDocument(metadata, window.location.pathname);
|
|
823
|
+
}
|
|
824
|
+
startNavigation(options) {
|
|
825
|
+
_optionalChain([this, 'access', _72 => _72.activeNavigation, 'optionalAccess', _73 => _73.controller, 'access', _74 => _74.abort, 'call', _75 => _75("superseded")]);
|
|
826
|
+
const navigation = {
|
|
827
|
+
id: ++this.navigationSequence,
|
|
828
|
+
controller: new AbortController()
|
|
829
|
+
};
|
|
830
|
+
this.activeNavigation = navigation;
|
|
831
|
+
this.setNavigationState({
|
|
832
|
+
state: "loading",
|
|
833
|
+
pending: true,
|
|
834
|
+
from: options.from,
|
|
835
|
+
to: options.to,
|
|
836
|
+
action: options.action,
|
|
837
|
+
startedAt: Date.now()
|
|
838
|
+
});
|
|
839
|
+
return navigation;
|
|
840
|
+
}
|
|
841
|
+
isCurrentNavigation(navigation, clientNavigation) {
|
|
842
|
+
return _optionalChain([this, 'access', _76 => _76.activeNavigation, 'optionalAccess', _77 => _77.id]) === navigation.id && !navigation.controller.signal.aborted && !_optionalChain([clientNavigation, 'optionalAccess', _78 => _78.signal, 'access', _79 => _79.aborted]);
|
|
843
|
+
}
|
|
844
|
+
finishNavigation(navigation) {
|
|
845
|
+
if (_optionalChain([this, 'access', _80 => _80.activeNavigation, 'optionalAccess', _81 => _81.id]) !== navigation.id) return;
|
|
846
|
+
this.activeNavigation = void 0;
|
|
847
|
+
this.setNavigationState(IDLE_NAVIGATION_STATE);
|
|
848
|
+
}
|
|
849
|
+
cancelActiveNavigation() {
|
|
850
|
+
if (!this.activeNavigation) return;
|
|
851
|
+
this.activeNavigation.controller.abort("superseded");
|
|
852
|
+
this.activeNavigation = void 0;
|
|
853
|
+
this.setNavigationState(IDLE_NAVIGATION_STATE);
|
|
854
|
+
}
|
|
855
|
+
setNavigationState(state) {
|
|
856
|
+
this.navigationState = state;
|
|
857
|
+
for (const listener of this.navigationListeners) {
|
|
858
|
+
listener(state);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
writePageState(action, state, href, notify = true) {
|
|
862
|
+
if (typeof window === "undefined") return;
|
|
863
|
+
const url = href ? _chunkSWN467MPcjs.resolveFarmNavigationURL.call(void 0, href, window.location.href).toString() : window.location.href;
|
|
864
|
+
const parsedUrl = new URL(url);
|
|
865
|
+
const nextPath = parsedUrl.pathname + parsedUrl.search;
|
|
866
|
+
const historyPath = nextPath + parsedUrl.hash;
|
|
867
|
+
const nextState = createHistoryState(historyPath, state, window.history.state);
|
|
868
|
+
if (action === "replace") {
|
|
869
|
+
window.history.replaceState(nextState, "", url);
|
|
870
|
+
} else {
|
|
871
|
+
if (this.currentHistoryIndex != null) {
|
|
872
|
+
nextState[FARM_HISTORY_INDEX_KEY] = this.currentHistoryIndex + 1;
|
|
873
|
+
}
|
|
874
|
+
window.history.pushState(nextState, "", url);
|
|
875
|
+
this.currentHistoryIndex = this.currentHistoryIndex == null ? null : this.currentHistoryIndex + 1;
|
|
876
|
+
}
|
|
877
|
+
this.currentHistoryPath = nextPath;
|
|
878
|
+
this.currentHistoryHash = parsedUrl.hash;
|
|
879
|
+
this.currentInterceptFrom = nextState[FARM_INTERCEPT_FROM_KEY];
|
|
880
|
+
if (notify) notifyHistoryChange("page-state");
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Save scroll position for a path
|
|
884
|
+
*/
|
|
885
|
+
saveScrollPosition(path) {
|
|
886
|
+
try {
|
|
887
|
+
sessionStorage.setItem(
|
|
888
|
+
`farm-scroll-${path}`,
|
|
889
|
+
JSON.stringify({ x: window.scrollX, y: window.scrollY })
|
|
890
|
+
);
|
|
891
|
+
for (const [key, element] of this.scrollElements) {
|
|
892
|
+
sessionStorage.setItem(
|
|
893
|
+
getScrollElementStorageKey(path, key),
|
|
894
|
+
JSON.stringify({ x: element.scrollLeft, y: element.scrollTop })
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
} catch (e5) {
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Restore the saved window scroll position for a path.
|
|
902
|
+
*/
|
|
903
|
+
restoreWindowScroll(path) {
|
|
904
|
+
try {
|
|
905
|
+
const saved = sessionStorage.getItem(`farm-scroll-${path}`);
|
|
906
|
+
if (saved) {
|
|
907
|
+
const { x, y } = JSON.parse(saved);
|
|
908
|
+
setTimeout(() => window.scrollTo(x, y), 0);
|
|
909
|
+
}
|
|
910
|
+
} catch (e6) {
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Restore saved scroll positions for every registered scroll element. Keys
|
|
915
|
+
* are hash-stripped (see getScrollElementStorageKey), so this runs regardless
|
|
916
|
+
* of whether the destination URL carries a fragment.
|
|
917
|
+
*/
|
|
918
|
+
restoreScrollElements(path) {
|
|
919
|
+
try {
|
|
920
|
+
for (const [key, element] of this.scrollElements) {
|
|
921
|
+
this.restoreScrollElement(path, key, element);
|
|
922
|
+
}
|
|
923
|
+
} catch (e7) {
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
restoreScrollElement(path, key, element) {
|
|
927
|
+
try {
|
|
928
|
+
const saved = sessionStorage.getItem(getScrollElementStorageKey(path, key));
|
|
929
|
+
if (!saved) return;
|
|
930
|
+
const { x, y } = JSON.parse(saved);
|
|
931
|
+
setTimeout(() => {
|
|
932
|
+
element.scrollLeft = x;
|
|
933
|
+
element.scrollTop = y;
|
|
934
|
+
}, 0);
|
|
935
|
+
} catch (e8) {
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Clear the page cache
|
|
940
|
+
*/
|
|
941
|
+
clearCache() {
|
|
942
|
+
this.cacheGeneration += 1;
|
|
943
|
+
this.cache.clear();
|
|
944
|
+
for (const pending of this.pendingPrefetches.values()) {
|
|
945
|
+
pending.cacheable = false;
|
|
946
|
+
pending.resolve(void 0);
|
|
947
|
+
}
|
|
948
|
+
this.pendingPrefetches.clear();
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _SPARouter, "SPARouter");
|
|
952
|
+
var SPARouter = _SPARouter;
|
|
953
|
+
function readBrowserDeploymentId() {
|
|
954
|
+
if (typeof window === "undefined") return void 0;
|
|
955
|
+
const runtimeId = window.__FARM_DEPLOYMENT_ID__;
|
|
956
|
+
if (typeof runtimeId === "string" && runtimeId) return runtimeId;
|
|
957
|
+
return _optionalChain([document, 'access', _82 => _82.querySelector, 'call', _83 => _83('meta[name="farm-deployment-id"]'), 'optionalAccess', _84 => _84.content]);
|
|
958
|
+
}
|
|
959
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readBrowserDeploymentId, "readBrowserDeploymentId");
|
|
960
|
+
function dispatchDeploymentMismatch(error) {
|
|
961
|
+
if (typeof window === "undefined" || typeof CustomEvent === "undefined") return;
|
|
962
|
+
window.dispatchEvent(new CustomEvent("farm:deployment-mismatch", { detail: error }));
|
|
963
|
+
}
|
|
964
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, dispatchDeploymentMismatch, "dispatchDeploymentMismatch");
|
|
965
|
+
function getInstalledFarmSPARouter() {
|
|
966
|
+
if (typeof window === "undefined") return void 0;
|
|
967
|
+
return window.__FARM_SPA_ROUTER__;
|
|
968
|
+
}
|
|
969
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getInstalledFarmSPARouter, "getInstalledFarmSPARouter");
|
|
970
|
+
function getRouter() {
|
|
971
|
+
if (typeof window === "undefined") {
|
|
972
|
+
return new SPARouter();
|
|
973
|
+
}
|
|
974
|
+
const installedRouter = getInstalledFarmSPARouter();
|
|
975
|
+
if (installedRouter) {
|
|
976
|
+
routerInstance = installedRouter;
|
|
977
|
+
return installedRouter;
|
|
978
|
+
}
|
|
979
|
+
if (!routerInstance) {
|
|
980
|
+
routerInstance = new SPARouter();
|
|
981
|
+
}
|
|
982
|
+
return routerInstance;
|
|
983
|
+
}
|
|
984
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getRouter, "getRouter");
|
|
985
|
+
function navigateTo(href, options) {
|
|
986
|
+
return getRouter().navigate(href, options);
|
|
987
|
+
}
|
|
988
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, navigateTo, "navigateTo");
|
|
989
|
+
function prefetch(href) {
|
|
990
|
+
return getRouter().prefetch(href);
|
|
991
|
+
}
|
|
992
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, prefetch, "prefetch");
|
|
993
|
+
function pushState(state, href) {
|
|
994
|
+
getRouter().pushState(state, href);
|
|
995
|
+
}
|
|
996
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, pushState, "pushState");
|
|
997
|
+
function replaceState(state, href) {
|
|
998
|
+
getRouter().replaceState(state, href);
|
|
999
|
+
}
|
|
1000
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, replaceState, "replaceState");
|
|
1001
|
+
function readPageState() {
|
|
1002
|
+
if (typeof window === "undefined") return null;
|
|
1003
|
+
const state = window.history.state;
|
|
1004
|
+
if (!state || typeof state !== "object") return null;
|
|
1005
|
+
return _nullishCoalesce(state[FARM_PAGE_STATE_KEY], () => ( null));
|
|
1006
|
+
}
|
|
1007
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readPageState, "readPageState");
|
|
1008
|
+
function createHistoryState(path, pageState, currentState, interceptFrom) {
|
|
1009
|
+
const base = currentState && typeof currentState === "object" ? { ...currentState } : {};
|
|
1010
|
+
const nextState = {
|
|
1011
|
+
...base,
|
|
1012
|
+
path,
|
|
1013
|
+
[FARM_PAGE_STATE_KEY]: pageState
|
|
1014
|
+
};
|
|
1015
|
+
if (interceptFrom === null) {
|
|
1016
|
+
delete nextState[FARM_INTERCEPT_FROM_KEY];
|
|
1017
|
+
} else if (interceptFrom) {
|
|
1018
|
+
nextState[FARM_INTERCEPT_FROM_KEY] = interceptFrom;
|
|
1019
|
+
}
|
|
1020
|
+
return nextState;
|
|
1021
|
+
}
|
|
1022
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createHistoryState, "createHistoryState");
|
|
1023
|
+
function getPageDataCacheKey(path, interceptFrom) {
|
|
1024
|
+
return interceptFrom ? `${path}
|
|
1025
|
+
intercept:${interceptFrom}` : path;
|
|
1026
|
+
}
|
|
1027
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getPageDataCacheKey, "getPageDataCacheKey");
|
|
1028
|
+
function createNavigationLocation(url) {
|
|
1029
|
+
return {
|
|
1030
|
+
href: url.href,
|
|
1031
|
+
pathname: url.pathname,
|
|
1032
|
+
search: url.search,
|
|
1033
|
+
hash: url.hash
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createNavigationLocation, "createNavigationLocation");
|
|
1037
|
+
function getScrollElementStorageKey(path, key) {
|
|
1038
|
+
return `farm-scroll-${path}:${key}`;
|
|
1039
|
+
}
|
|
1040
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getScrollElementStorageKey, "getScrollElementStorageKey");
|
|
1041
|
+
|
|
1042
|
+
// src/client/history-sync.ts
|
|
1043
|
+
var FARM_HISTORY_CHANGE_EVENT = "farm:historychange";
|
|
1044
|
+
function writeFarmURLSearchHistory(action, href) {
|
|
1045
|
+
const router = getInstalledFarmSPARouter();
|
|
1046
|
+
if (!router) return false;
|
|
1047
|
+
const writeURLSearch = router.writeURLSearch;
|
|
1048
|
+
if (typeof writeURLSearch !== "function") return false;
|
|
1049
|
+
if (window.history.state !== null && typeof window.history.state !== "object") return false;
|
|
1050
|
+
writeURLSearch.call(router, action, href);
|
|
1051
|
+
return true;
|
|
1052
|
+
}
|
|
1053
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, writeFarmURLSearchHistory, "writeFarmURLSearchHistory");
|
|
1054
|
+
function dispatchHistoryChange(kind) {
|
|
1055
|
+
window.dispatchEvent(
|
|
1056
|
+
new CustomEvent(FARM_HISTORY_CHANGE_EVENT, {
|
|
1057
|
+
detail: { kind }
|
|
1058
|
+
})
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
1061
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, dispatchHistoryChange, "dispatchHistoryChange");
|
|
1062
|
+
function notifyHistoryChange(kind) {
|
|
1063
|
+
if (typeof window === "undefined") return;
|
|
1064
|
+
setTimeout(() => {
|
|
1065
|
+
if (kind === "url-search" && !getInstalledFarmSPARouter()) {
|
|
1066
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
dispatchHistoryChange(kind);
|
|
1070
|
+
}, 0);
|
|
1071
|
+
}
|
|
1072
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, notifyHistoryChange, "notifyHistoryChange");
|
|
1073
|
+
function notifyRouterHistoryChange() {
|
|
1074
|
+
if (typeof window === "undefined") return;
|
|
1075
|
+
setTimeout(() => dispatchHistoryChange("url-search"), 0);
|
|
1076
|
+
}
|
|
1077
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, notifyRouterHistoryChange, "notifyRouterHistoryChange");
|
|
1078
|
+
function subscribeHistoryChange(listener) {
|
|
1079
|
+
if (typeof window === "undefined") return () => {
|
|
1080
|
+
};
|
|
1081
|
+
window.addEventListener("popstate", listener);
|
|
1082
|
+
window.addEventListener(FARM_HISTORY_CHANGE_EVENT, listener);
|
|
1083
|
+
return () => {
|
|
1084
|
+
window.removeEventListener("popstate", listener);
|
|
1085
|
+
window.removeEventListener(FARM_HISTORY_CHANGE_EVENT, listener);
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, subscribeHistoryChange, "subscribeHistoryChange");
|
|
1089
|
+
|
|
1090
|
+
|
|
1091
|
+
|
|
1092
|
+
|
|
1093
|
+
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
|
|
1097
|
+
|
|
1098
|
+
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
exports.writeFarmURLSearchHistory = writeFarmURLSearchHistory; exports.notifyHistoryChange = notifyHistoryChange; exports.subscribeHistoryChange = subscribeHistoryChange; exports.SPARouter = SPARouter; exports.getInstalledFarmSPARouter = getInstalledFarmSPARouter; exports.getRouter = getRouter; exports.navigateTo = navigateTo; exports.prefetch = prefetch; exports.pushState = pushState; exports.replaceState = replaceState; exports.readPageState = readPageState;
|