@farm.js/core 0.1.37 → 0.1.38

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.
Files changed (242) hide show
  1. package/dist/{agent-mcp-BC0bAGVF.d.mts → agent-mcp-BwKlpnc7.d.mts} +1 -1
  2. package/dist/{agent-mcp-jyDHbQKe.d.ts → agent-mcp-De1imoMS.d.ts} +1 -1
  3. package/dist/{agent-mcp-handler-SJAHFSPI.cjs → agent-mcp-handler-MRGP3WJ3.cjs} +5 -5
  4. package/dist/{agent-mcp-handler-LPJ2CADR.mjs → agent-mcp-handler-OLRMZONF.mjs} +4 -4
  5. package/dist/agent-runtime.cjs +2 -2
  6. package/dist/agent-runtime.d.mts +1 -1
  7. package/dist/agent-runtime.d.ts +1 -1
  8. package/dist/agent-runtime.mjs +1 -1
  9. package/dist/api/client.cjs +3 -3
  10. package/dist/api/client.mjs +2 -2
  11. package/dist/api/route-manager.cjs +5 -5
  12. package/dist/api/route-manager.d.mts +3 -3
  13. package/dist/api/route-manager.d.ts +3 -3
  14. package/dist/api/route-manager.mjs +4 -4
  15. package/dist/api/runtime.cjs +4 -4
  16. package/dist/api/runtime.d.mts +2 -2
  17. package/dist/api/runtime.d.ts +2 -2
  18. package/dist/api/runtime.mjs +3 -3
  19. package/dist/api.cjs +7 -7
  20. package/dist/api.d.mts +3 -3
  21. package/dist/api.d.ts +3 -3
  22. package/dist/api.mjs +6 -6
  23. package/dist/{app-Cbkj9ufe.d.mts → app-CFZt-srr.d.mts} +21 -3
  24. package/dist/{app-CKO3iN1c.d.ts → app-kT_QXTdx.d.ts} +21 -3
  25. package/dist/app-markdown.cjs +4 -4
  26. package/dist/app-markdown.d.mts +2 -2
  27. package/dist/app-markdown.d.ts +2 -2
  28. package/dist/app-markdown.mjs +3 -3
  29. package/dist/{chunk-LOFKRKO7.cjs → chunk-2DD4JMQC.cjs} +113 -22
  30. package/dist/chunk-2ZYGC6SS.cjs +576 -0
  31. package/dist/{chunk-75X755YZ.cjs → chunk-34UCJRQO.cjs} +2 -2
  32. package/dist/{chunk-CVH2BXPY.cjs → chunk-3LOLJTFV.cjs} +6 -6
  33. package/dist/{chunk-4GPOC4LN.cjs → chunk-472NCAZ7.cjs} +3 -3
  34. package/dist/{chunk-WT4TGLXT.cjs → chunk-4E5QXOCL.cjs} +6 -6
  35. package/dist/{chunk-7DWNJI73.cjs → chunk-4IE345DM.cjs} +37 -19
  36. package/dist/{chunk-O6WAEAX3.mjs → chunk-5BWWFHR2.mjs} +70 -15
  37. package/dist/{chunk-6LGFV2CQ.cjs → chunk-5OKBARDN.cjs} +2 -2
  38. package/dist/{chunk-3IP27TCG.cjs → chunk-5PWXMJOH.cjs} +19 -19
  39. package/dist/chunk-6BK3K2GB.mjs +318 -0
  40. package/dist/{chunk-HEVMCTSR.mjs → chunk-6HB6V3R7.mjs} +1 -1
  41. package/dist/{chunk-NICDYKBS.cjs → chunk-6XWDE2P2.cjs} +22 -4
  42. package/dist/{chunk-Z7LA7MHQ.mjs → chunk-7FPTZLKH.mjs} +1 -1
  43. package/dist/{chunk-JPNFPAZ4.mjs → chunk-7PEP3BUT.mjs} +1 -1
  44. package/dist/{chunk-XOPOIFTJ.mjs → chunk-A3EAIURZ.mjs} +25 -7
  45. package/dist/{chunk-LBDP3YT3.mjs → chunk-ARC7I3O2.mjs} +1 -1
  46. package/dist/{chunk-LBGILORX.mjs → chunk-B6G5CKMC.mjs} +101 -10
  47. package/dist/{chunk-MCIZVNOQ.mjs → chunk-BZHXGVMA.mjs} +1 -1
  48. package/dist/{chunk-KDTBF3UU.mjs → chunk-CNNOLE4O.mjs} +1 -1
  49. package/dist/{chunk-TDNWPAVR.mjs → chunk-CUM5NYL5.mjs} +1 -1
  50. package/dist/{chunk-HITLGIAO.cjs → chunk-CY2ZQ5C6.cjs} +7 -6
  51. package/dist/{chunk-KPFKMDM7.mjs → chunk-DRLKAXDM.mjs} +1 -1
  52. package/dist/{chunk-VR4GD5I3.cjs → chunk-EIPC3FDA.cjs} +12 -4
  53. package/dist/{chunk-K3SAEIM3.mjs → chunk-EKF7KDFD.mjs} +1 -1
  54. package/dist/{chunk-B5PFZLKV.cjs → chunk-EKN7NSZO.cjs} +25 -8
  55. package/dist/{chunk-ATWHHSY2.cjs → chunk-EMO6K4YY.cjs} +4 -4
  56. package/dist/{chunk-6SJ2KJTA.mjs → chunk-EPYU2EBL.mjs} +1 -1
  57. package/dist/{chunk-PTZ2TVNE.cjs → chunk-H5CLOUZS.cjs} +5 -5
  58. package/dist/{chunk-DTSROJ5J.mjs → chunk-HD5CF3OE.mjs} +1 -1
  59. package/dist/{chunk-IAIYV4RZ.mjs → chunk-HXRYZWTA.mjs} +1 -1
  60. package/dist/{chunk-Z5BEWYVO.mjs → chunk-IBUQWVYA.mjs} +16 -0
  61. package/dist/{chunk-HMRSWN47.mjs → chunk-INL3THCU.mjs} +1 -1
  62. package/dist/{chunk-FBOJ55OM.mjs → chunk-IVLZZZEI.mjs} +1 -1
  63. package/dist/{chunk-ENLZ4R3Y.mjs → chunk-J7K2NZD6.mjs} +7 -6
  64. package/dist/{chunk-NFMDCAOS.mjs → chunk-JCKYH4LG.mjs} +2 -2
  65. package/dist/{chunk-PMQHMWZU.cjs → chunk-JCYYXBAJ.cjs} +3 -3
  66. package/dist/{chunk-LPFV45AY.cjs → chunk-KCQBAKIY.cjs} +9 -9
  67. package/dist/{chunk-FGRYBX5X.mjs → chunk-KHKLMNI5.mjs} +1 -1
  68. package/dist/{chunk-NQ6QFZWD.cjs → chunk-KKSTAEMY.cjs} +1 -1
  69. package/dist/{chunk-7O5M4UKW.cjs → chunk-L4DD7ODZ.cjs} +2 -2
  70. package/dist/{chunk-YCKO6FRS.mjs → chunk-LI2F57NI.mjs} +1 -1
  71. package/dist/{chunk-TW4GYDBJ.mjs → chunk-MLY2RP5R.mjs} +10 -2
  72. package/dist/{chunk-5BXGGEC7.cjs → chunk-N32CC42M.cjs} +5 -5
  73. package/dist/{chunk-BHY547NB.cjs → chunk-NBBEQLOK.cjs} +9 -9
  74. package/dist/{chunk-WQ7T2263.mjs → chunk-OAHTRMIC.mjs} +3 -3
  75. package/dist/{chunk-K4I4O5TS.mjs → chunk-OCIEZME4.mjs} +790 -671
  76. package/dist/{chunk-UH6QN5NL.mjs → chunk-P664ZVTV.mjs} +2 -2
  77. package/dist/{chunk-TE2G5ION.cjs → chunk-PGZDEPTM.cjs} +88 -33
  78. package/dist/{chunk-3KGDJLJK.mjs → chunk-POSPE3IO.mjs} +19 -1
  79. package/dist/{chunk-3A4KGQYI.cjs → chunk-Q3NXS4MU.cjs} +16 -14
  80. package/dist/{chunk-TPLJVC7E.mjs → chunk-QFW2IH5E.mjs} +23 -6
  81. package/dist/{chunk-S3VWVTVA.mjs → chunk-QRKIMN7T.mjs} +13 -1
  82. package/dist/chunk-QTXBII4Z.cjs +632 -0
  83. package/dist/{chunk-CI6E3UOH.cjs → chunk-RG4A6LB2.cjs} +7 -7
  84. package/dist/{chunk-7SQ5SGYZ.cjs → chunk-RW63BOV7.cjs} +2 -2
  85. package/dist/{chunk-U6MPZ35Q.cjs → chunk-RWFLWR5J.cjs} +8 -8
  86. package/dist/{chunk-EUV4YR3V.cjs → chunk-SGBJ247Q.cjs} +18 -2
  87. package/dist/{chunk-J3ANCZKA.mjs → chunk-SKVTP5PR.mjs} +1 -1
  88. package/dist/{chunk-6TJITR2B.cjs → chunk-TGFQVLLF.cjs} +870 -751
  89. package/dist/{chunk-4P6ULFMD.mjs → chunk-TUBTR2OP.mjs} +221 -102
  90. package/dist/{chunk-EMMQ64QW.cjs → chunk-TYJALEHQ.cjs} +2 -2
  91. package/dist/{chunk-WRPHYQVY.mjs → chunk-TYMMBFN2.mjs} +1 -1
  92. package/dist/chunk-U6QLDL3G.mjs +576 -0
  93. package/dist/{chunk-OW67PDDS.cjs → chunk-ULASELLA.cjs} +13 -1
  94. package/dist/{chunk-WWIKMBRN.mjs → chunk-VNGH5MLF.mjs} +17 -1
  95. package/dist/{chunk-NNSAQX3U.mjs → chunk-VT4WFRHA.mjs} +1 -1
  96. package/dist/{chunk-UJZLSXUB.cjs → chunk-VU6AAZVY.cjs} +17 -1
  97. package/dist/{chunk-ADOAUDQ6.cjs → chunk-VXEEATVD.cjs} +2 -2
  98. package/dist/{chunk-RRMVL6CJ.mjs → chunk-W36M2BQ4.mjs} +1 -1
  99. package/dist/{chunk-4WQ6PGSJ.cjs → chunk-WEW2JVA4.cjs} +4 -4
  100. package/dist/{chunk-4E5WBPEG.mjs → chunk-WFRT7JPX.mjs} +8 -533
  101. package/dist/{chunk-VXAWRDK7.mjs → chunk-WLL43JMO.mjs} +1 -1
  102. package/dist/chunk-WW46B6HA.cjs +318 -0
  103. package/dist/{chunk-D3C5LBQY.cjs → chunk-WXJLNP33.cjs} +2 -2
  104. package/dist/{chunk-NDILNQ4L.cjs → chunk-XKG2BLFN.cjs} +2 -2
  105. package/dist/{chunk-W2YDNK66.cjs → chunk-XKVVMZP5.cjs} +2 -2
  106. package/dist/{chunk-Q5FYSK45.cjs → chunk-YR2VBEMO.cjs} +619 -500
  107. package/dist/{chunk-EXG5LD6B.mjs → chunk-ZJD2PN6Z.mjs} +10 -8
  108. package/dist/{chunk-G2TEB74S.cjs → chunk-ZXH4TS3F.cjs} +2 -2
  109. package/dist/{client-plugins-C8DjftDF.d.ts → client-plugins-BvlNhGEB.d.ts} +40 -7
  110. package/dist/{client-plugins-CV4eJ9De.d.mts → client-plugins-DUrIYX9B.d.mts} +40 -7
  111. package/dist/client-plugins.d.mts +1 -1
  112. package/dist/client-plugins.d.ts +1 -1
  113. package/dist/client.cjs +5 -5
  114. package/dist/client.d.mts +5 -5
  115. package/dist/client.d.ts +5 -5
  116. package/dist/client.mjs +4 -4
  117. package/dist/config.d.mts +1 -1
  118. package/dist/config.d.ts +1 -1
  119. package/dist/{devtools-KVOY2TCZ.mjs → devtools-JYJNOLPQ.mjs} +7 -5
  120. package/dist/{devtools-JXFQNWSH.cjs → devtools-VQWJANJV.cjs} +8 -6
  121. package/dist/docs.cjs +11 -9
  122. package/dist/docs.d.mts +20 -2
  123. package/dist/docs.d.ts +20 -2
  124. package/dist/docs.mjs +10 -8
  125. package/dist/headers.cjs +6 -4
  126. package/dist/headers.d.mts +11 -1
  127. package/dist/headers.d.ts +11 -1
  128. package/dist/headers.mjs +5 -3
  129. package/dist/index.cjs +52 -39
  130. package/dist/index.d.mts +15 -15
  131. package/dist/index.d.ts +15 -15
  132. package/dist/index.mjs +52 -39
  133. package/dist/integrations.cjs +4 -2
  134. package/dist/integrations.d.mts +1 -1
  135. package/dist/integrations.d.ts +1 -1
  136. package/dist/integrations.mjs +3 -1
  137. package/dist/internal/app-markdown-runtime.cjs +3 -3
  138. package/dist/internal/app-markdown-runtime.d.mts +2 -2
  139. package/dist/internal/app-markdown-runtime.d.ts +2 -2
  140. package/dist/internal/app-markdown-runtime.mjs +2 -2
  141. package/dist/internal/build-runtime.cjs +28 -27
  142. package/dist/internal/build-runtime.d.mts +3 -3
  143. package/dist/internal/build-runtime.d.ts +3 -3
  144. package/dist/internal/build-runtime.mjs +27 -26
  145. package/dist/internal/cli-runtime.cjs +10 -8
  146. package/dist/internal/cli-runtime.mjs +9 -7
  147. package/dist/internal/client-error-overlay.cjs +4 -4
  148. package/dist/internal/client-error-overlay.mjs +1 -1
  149. package/dist/internal/compression-runtime.d.mts +1 -1
  150. package/dist/internal/compression-runtime.d.ts +1 -1
  151. package/dist/internal/config-runtime.cjs +8 -6
  152. package/dist/internal/config-runtime.d.mts +2 -2
  153. package/dist/internal/config-runtime.d.ts +2 -2
  154. package/dist/internal/config-runtime.mjs +7 -5
  155. package/dist/internal/docs-precompiled-runtime.cjs +19 -13
  156. package/dist/internal/docs-precompiled-runtime.d.mts +5 -0
  157. package/dist/internal/docs-precompiled-runtime.d.ts +5 -0
  158. package/dist/internal/docs-precompiled-runtime.mjs +14 -8
  159. package/dist/internal/infra-analytics-runtime.cjs +5 -5
  160. package/dist/internal/infra-analytics-runtime.mjs +3 -3
  161. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  162. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  163. package/dist/internal/production-node-env.cjs +6 -2
  164. package/dist/internal/production-node-env.d.mts +10 -1
  165. package/dist/internal/production-node-env.d.ts +10 -1
  166. package/dist/internal/production-node-env.mjs +5 -1
  167. package/dist/internal/production-runtime.cjs +34 -14
  168. package/dist/internal/production-runtime.d.mts +51 -11
  169. package/dist/internal/production-runtime.d.ts +51 -11
  170. package/dist/internal/production-runtime.mjs +36 -16
  171. package/dist/markdown.cjs +8 -2
  172. package/dist/markdown.d.mts +1 -1
  173. package/dist/markdown.d.ts +1 -1
  174. package/dist/markdown.mjs +7 -1
  175. package/dist/middleware.cjs +9 -7
  176. package/dist/middleware.d.mts +24 -4
  177. package/dist/middleware.d.ts +24 -4
  178. package/dist/middleware.mjs +9 -7
  179. package/dist/navigation.cjs +4 -4
  180. package/dist/navigation.d.mts +4 -4
  181. package/dist/navigation.d.ts +4 -4
  182. package/dist/navigation.mjs +3 -3
  183. package/dist/plugin.cjs +21 -20
  184. package/dist/plugin.d.mts +1 -1
  185. package/dist/plugin.d.ts +1 -1
  186. package/dist/plugin.mjs +20 -19
  187. package/dist/{production-runtime-Du_FHb2-.d.mts → production-runtime-BQ4_WLwQ.d.mts} +1 -1
  188. package/dist/{production-runtime-C2kkrPVZ.d.ts → production-runtime-D2aMyzjr.d.ts} +1 -1
  189. package/dist/query/client.cjs +2 -2
  190. package/dist/query/client.mjs +1 -1
  191. package/dist/{render-plan-BnnPTpus.d.ts → render-plan-25p4hrj4.d.ts} +1 -1
  192. package/dist/{render-plan-Cgx7v8tJ.d.mts → render-plan-DtkXMN8D.d.mts} +1 -1
  193. package/dist/renderer-client.d.mts +3 -3
  194. package/dist/renderer-client.d.ts +3 -3
  195. package/dist/renderer.d.mts +13 -4
  196. package/dist/renderer.d.ts +13 -4
  197. package/dist/{request-sKayKcop.d.mts → request-DgCkIdcn.d.mts} +4 -2
  198. package/dist/{request-BNWr7r5e.d.ts → request-jF4jwx8f.d.ts} +4 -2
  199. package/dist/request.cjs +3 -3
  200. package/dist/request.d.mts +2 -2
  201. package/dist/request.d.ts +2 -2
  202. package/dist/request.mjs +2 -2
  203. package/dist/{route-rendering-Bx4Auw6Q.d.ts → route-rendering-Bji6S6a_.d.ts} +1 -1
  204. package/dist/{route-rendering-DWFp3Yq4.d.mts → route-rendering-CSBF78Ya.d.mts} +1 -1
  205. package/dist/{router-BK6K42Ij.d.mts → router-B09Ui3Qm.d.mts} +1 -1
  206. package/dist/{router-DnW_2tQi.d.ts → router-CPB9cXtG.d.ts} +1 -1
  207. package/dist/routes.d.mts +1 -1
  208. package/dist/routes.d.ts +1 -1
  209. package/dist/{runtime-DJDaCMd_.d.mts → runtime-CM6E6yuI.d.mts} +1 -1
  210. package/dist/{runtime-CA3Ei5k_.d.ts → runtime-EDMwLdjv.d.ts} +1 -1
  211. package/dist/server-fn.cjs +3 -3
  212. package/dist/server-fn.mjs +2 -2
  213. package/dist/server-plugins.cjs +5 -5
  214. package/dist/server-plugins.d.mts +2 -2
  215. package/dist/server-plugins.d.ts +2 -2
  216. package/dist/server-plugins.mjs +4 -4
  217. package/dist/server-query.cjs +4 -4
  218. package/dist/server-query.mjs +3 -3
  219. package/dist/server.cjs +47 -46
  220. package/dist/server.d.mts +7 -7
  221. package/dist/server.d.ts +7 -7
  222. package/dist/server.mjs +25 -24
  223. package/dist/{spa-router-Mwbd7g2L.d.ts → spa-router-B_N8XgVu.d.ts} +2 -2
  224. package/dist/{spa-router-D6fUA4Rn.d.mts → spa-router-Cgimzfbi.d.mts} +2 -2
  225. package/dist/testing.cjs +5 -5
  226. package/dist/testing.d.mts +1 -1
  227. package/dist/testing.d.ts +1 -1
  228. package/dist/testing.mjs +4 -4
  229. package/dist/theme/server.cjs +4 -4
  230. package/dist/theme/server.mjs +3 -3
  231. package/dist/{utils-BwVcAfUR.d.ts → utils-BNxAKAuT.d.ts} +1 -1
  232. package/dist/{utils-p9Hs-jCc.d.mts → utils-DZciYXYl.d.mts} +1 -1
  233. package/dist/version.cjs +2 -2
  234. package/dist/version.mjs +1 -1
  235. package/dist/vite.cjs +21 -20
  236. package/dist/vite.d.mts +1 -1
  237. package/dist/vite.d.ts +1 -1
  238. package/dist/vite.mjs +20 -19
  239. package/package.json +1 -1
  240. package/dist/chunk-655RLQQL.mjs +0 -43
  241. package/dist/chunk-MRMI32SN.cjs +0 -1157
  242. package/dist/chunk-MT763TDW.cjs +0 -43
@@ -2033,6 +2033,21 @@ function resolveIntegrationMiddlewareParams(entry, pathname, config) {
2033
2033
  return null;
2034
2034
  }
2035
2035
  _chunkS3JO3N4Hcjs.__name.call(void 0, resolveIntegrationMiddlewareParams, "resolveIntegrationMiddlewareParams");
2036
+ function integrationMiddlewareMayHandlePath(integrations, pathname, catchAllProbe) {
2037
+ if (!integrations) return false;
2038
+ const covers = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (entry) => resolveIntegrationMiddlewareParams(entry, pathname, void 0) !== null, "covers");
2039
+ return Object.values(integrations).some(
2040
+ (integration) => isFarmIntegration(integration) && (integration.middleware || []).some((entry) => {
2041
+ if (catchAllProbe === void 0) return covers(entry);
2042
+ if (!entry.matcher) return false;
2043
+ const specific = (Array.isArray(entry.matcher) ? entry.matcher : [entry.matcher]).filter(
2044
+ (matcher) => resolveIntegrationMiddlewareParams({ matcher }, catchAllProbe, void 0) === null
2045
+ );
2046
+ return specific.length > 0 && covers({ matcher: specific });
2047
+ })
2048
+ );
2049
+ }
2050
+ _chunkS3JO3N4Hcjs.__name.call(void 0, integrationMiddlewareMayHandlePath, "integrationMiddlewareMayHandlePath");
2036
2051
  var FARM_INTEGRATION_API_BASE_PATH_KEY = "__farmAPIServerBasePath";
2037
2052
  var integrationAPIPathnames = /* @__PURE__ */ new WeakMap();
2038
2053
  function getIntegrationAPIPathnames(config) {
@@ -2184,4 +2199,5 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeMatcher, "normalizeMatcher");
2184
2199
 
2185
2200
 
2186
2201
 
2187
- exports.getFarmPluginIntegrationContext = getFarmPluginIntegrationContext; exports.FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY; exports.FARM_INTEGRATION_SET_COOKIES_KEY = FARM_INTEGRATION_SET_COOKIES_KEY; exports.forwardIntegrationSetCookies = forwardIntegrationSetCookies; exports.defineIntegrationSchema = defineIntegrationSchema; exports.getFarmIntegrationPluginServerRuntime = getFarmIntegrationPluginServerRuntime; exports.getFarmIntegrationPluginOwner = getFarmIntegrationPluginOwner; exports.createIntegrationRoute = createIntegrationRoute; exports.integrationRoute = integrationRoute; exports.defineIntegration = defineIntegration; exports.isFarmIntegration = isFarmIntegration; exports.resolveIntegrationPlugins = resolveIntegrationPlugins; exports.getIntegrationProviders = getIntegrationProviders; exports.isFarmIntegrationProviderComponentReference = isFarmIntegrationProviderComponentReference; exports.getIntegrationDocumentNavigationMatchers = getIntegrationDocumentNavigationMatchers; exports.getIntegrationSchemas = getIntegrationSchemas; exports.getRegisteredIntegrationRuntime = getRegisteredIntegrationRuntime; exports.getRegisteredIntegrations = getRegisteredIntegrations; exports.getRegisteredIntegrationSchemas = getRegisteredIntegrationSchemas; exports.matchIntegrationRoute = matchIntegrationRoute; exports.matchRegisteredIntegrationRoute = matchRegisteredIntegrationRoute; exports.getRegisteredIntegrationAPIManifest = getRegisteredIntegrationAPIManifest; exports.dispatchIntegrationRequest = dispatchIntegrationRequest; exports.dispatchIntegrationRequests = dispatchIntegrationRequests; exports.FARM_INTEGRATION_API_BASE_PATH_KEY = FARM_INTEGRATION_API_BASE_PATH_KEY;
2202
+
2203
+ exports.getFarmPluginIntegrationContext = getFarmPluginIntegrationContext; exports.FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY; exports.FARM_INTEGRATION_SET_COOKIES_KEY = FARM_INTEGRATION_SET_COOKIES_KEY; exports.forwardIntegrationSetCookies = forwardIntegrationSetCookies; exports.defineIntegrationSchema = defineIntegrationSchema; exports.getFarmIntegrationPluginServerRuntime = getFarmIntegrationPluginServerRuntime; exports.getFarmIntegrationPluginOwner = getFarmIntegrationPluginOwner; exports.createIntegrationRoute = createIntegrationRoute; exports.integrationRoute = integrationRoute; exports.defineIntegration = defineIntegration; exports.isFarmIntegration = isFarmIntegration; exports.resolveIntegrationPlugins = resolveIntegrationPlugins; exports.getIntegrationProviders = getIntegrationProviders; exports.isFarmIntegrationProviderComponentReference = isFarmIntegrationProviderComponentReference; exports.getIntegrationDocumentNavigationMatchers = getIntegrationDocumentNavigationMatchers; exports.getIntegrationSchemas = getIntegrationSchemas; exports.getRegisteredIntegrationRuntime = getRegisteredIntegrationRuntime; exports.getRegisteredIntegrations = getRegisteredIntegrations; exports.getRegisteredIntegrationSchemas = getRegisteredIntegrationSchemas; exports.matchIntegrationRoute = matchIntegrationRoute; exports.matchRegisteredIntegrationRoute = matchRegisteredIntegrationRoute; exports.getRegisteredIntegrationAPIManifest = getRegisteredIntegrationAPIManifest; exports.dispatchIntegrationRequest = dispatchIntegrationRequest; exports.dispatchIntegrationRequests = dispatchIntegrationRequests; exports.integrationMiddlewareMayHandlePath = integrationMiddlewareMayHandlePath; exports.FARM_INTEGRATION_API_BASE_PATH_KEY = FARM_INTEGRATION_API_BASE_PATH_KEY;
@@ -6,7 +6,7 @@
6
6
  var _chunkDVM4FKZLcjs = require('./chunk-DVM4FKZL.cjs');
7
7
 
8
8
 
9
- var _chunkNICDYKBScjs = require('./chunk-NICDYKBS.cjs');
9
+ var _chunk6XWDE2P2cjs = require('./chunk-6XWDE2P2.cjs');
10
10
 
11
11
 
12
12
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
@@ -29,7 +29,7 @@ function createRewritesPlugin(rewrites, {
29
29
  if (overrideBeforeRequest) {
30
30
  await overrideBeforeRequest(req, res, context);
31
31
  }
32
- const url = _chunkNICDYKBScjs.resolveFarmRequestURL.call(void 0, req);
32
+ const url = _chunk6XWDE2P2cjs.resolveFarmRequestURL.call(void 0, req);
33
33
  const routePath = _chunkDVM4FKZLcjs.resolveConfigRoutePathname.call(void 0, url.pathname, i18n);
34
34
  const pathname = routePath.pathname;
35
35
  for (const { rewrite, pattern } of compiledRewrites) {
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-CBBLJMR5.mjs";
14
14
  import {
15
15
  _resolveCurrentRequestForApp
16
- } from "./chunk-S3VWVTVA.mjs";
16
+ } from "./chunk-QRKIMN7T.mjs";
17
17
  import {
18
18
  __name
19
19
  } from "./chunk-LPEX4YW6.mjs";
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkEUV4YR3Vcjs = require('./chunk-EUV4YR3V.cjs');
5
+ var _chunkSGBJ247Qcjs = require('./chunk-SGBJ247Q.cjs');
6
6
 
7
7
 
8
8
  var _chunkJ63ZH5OQcjs = require('./chunk-J63ZH5OQ.cjs');
@@ -66,12 +66,12 @@ function collectFarmLlmsTxtPages(sources, options) {
66
66
  for (const source of sources) {
67
67
  const path = source.pattern;
68
68
  if (path.includes("[") || pages.has(path)) continue;
69
- if (include.length && !include.some((pattern) => _chunkEUV4YR3Vcjs.matchesFarmMarkdownRoutePattern.call(void 0, pattern, path))) {
69
+ if (include.length && !include.some((pattern) => _chunkSGBJ247Qcjs.matchesFarmMarkdownRoutePattern.call(void 0, pattern, path))) {
70
70
  continue;
71
71
  }
72
- if (exclude.some((pattern) => _chunkEUV4YR3Vcjs.matchesFarmMarkdownRoutePattern.call(void 0, pattern, path))) continue;
72
+ if (exclude.some((pattern) => _chunkSGBJ247Qcjs.matchesFarmMarkdownRoutePattern.call(void 0, pattern, path))) continue;
73
73
  if (isFarmMetadataNoIndex(source.metadata)) continue;
74
- const target = _chunkEUV4YR3Vcjs.isFarmMarkdownMirrorExposed.call(void 0, options.markdown, path) ? _chunkEUV4YR3Vcjs.getFarmMarkdownMirrorPath.call(void 0, path) : path;
74
+ const target = _chunkSGBJ247Qcjs.isFarmMarkdownMirrorExposed.call(void 0, options.markdown, path) ? _chunkSGBJ247Qcjs.getFarmMarkdownMirrorPath.call(void 0, path) : path;
75
75
  const description = readMetadataString(source.metadata, "description");
76
76
  pages.set(path, {
77
77
  path,
@@ -1,13 +1,9 @@
1
1
  import {
2
2
  isFarmMetadataNoIndex
3
- } from "./chunk-DTSROJ5J.mjs";
3
+ } from "./chunk-HD5CF3OE.mjs";
4
4
  import {
5
5
  matchesFarmMarkdownRoutePattern
6
- } from "./chunk-WWIKMBRN.mjs";
7
- import {
8
- _markFarmOwnedResponse,
9
- _withFarmResponseHeaders
10
- } from "./chunk-Z3HATSKO.mjs";
6
+ } from "./chunk-VNGH5MLF.mjs";
11
7
  import {
12
8
  applyFarmBasePath
13
9
  } from "./chunk-4RB44K6Z.mjs";
@@ -212,519 +208,6 @@ function isRecord(value) {
212
208
  }
213
209
  __name(isRecord, "isRecord");
214
210
 
215
- // src/security.ts
216
- function resolveFarmSecurityConfig(input) {
217
- if (input === void 0) return { csp: false };
218
- if (!isPlainRecord(input)) {
219
- throw new TypeError("security must be an object containing the csp option.");
220
- }
221
- if (Object.prototype.hasOwnProperty.call(input, "contentSecurityPolicy")) {
222
- throw new TypeError(
223
- "security.contentSecurityPolicy is not supported. Use security.csp instead."
224
- );
225
- }
226
- const csp = input.csp;
227
- if (csp === void 0 || csp === false) return { csp: false };
228
- if (typeof csp === "string") {
229
- return {
230
- csp: {
231
- value: validateSerializedCsp(csp),
232
- reportOnly: false,
233
- nonce: false
234
- }
235
- };
236
- }
237
- if (!isPlainRecord(csp)) {
238
- throw new TypeError("security.csp must be a policy string, false, or an options object.");
239
- }
240
- const reportOnly = validateReportOnly(csp.reportOnly);
241
- const nonce = validateNonce(csp.nonce);
242
- if (Object.prototype.hasOwnProperty.call(csp, "value")) {
243
- if (Object.prototype.hasOwnProperty.call(csp, "policy") || Object.prototype.hasOwnProperty.call(csp, "directives")) {
244
- throw new TypeError(
245
- "Resolved security.csp values cannot include policy or directives options."
246
- );
247
- }
248
- return {
249
- csp: {
250
- value: validateSerializedCsp(csp.value),
251
- reportOnly,
252
- nonce
253
- }
254
- };
255
- }
256
- const { policy, directives } = csp;
257
- if (policy !== void 0 && directives !== void 0) {
258
- throw new TypeError("security.csp accepts either policy or directives, not both.");
259
- }
260
- if (policy === void 0 && directives === void 0) {
261
- throw new TypeError("security.csp requires a policy string or directives object.");
262
- }
263
- return {
264
- csp: {
265
- value: policy !== void 0 ? validateSerializedCsp(policy) : serializeFarmCspDirectives(directives),
266
- reportOnly,
267
- nonce
268
- }
269
- };
270
- }
271
- __name(resolveFarmSecurityConfig, "resolveFarmSecurityConfig");
272
- function serializeFarmCspDirectives(directives) {
273
- if (!isPlainRecord(directives)) {
274
- throw new TypeError("security.csp.directives must be an object.");
275
- }
276
- const serialized = [];
277
- const normalizedNames = /* @__PURE__ */ new Set();
278
- for (const [configuredName, configuredValue] of Object.entries(directives)) {
279
- if (configuredValue === false || configuredValue === null || configuredValue === void 0) {
280
- continue;
281
- }
282
- const name = normalizeDirectiveName(configuredName);
283
- if (normalizedNames.has(name)) {
284
- throw new TypeError(`security.csp contains the duplicate directive ${JSON.stringify(name)}.`);
285
- }
286
- normalizedNames.add(name);
287
- const values = configuredValue === true ? [] : (Array.isArray(configuredValue) ? configuredValue : [configuredValue]).map(
288
- validateDirectiveValue
289
- );
290
- serialized.push(values.length > 0 ? `${name} ${values.join(" ")}` : name);
291
- }
292
- if (serialized.length === 0) {
293
- throw new TypeError("security.csp.directives must contain at least one enabled directive.");
294
- }
295
- return serialized.join("; ");
296
- }
297
- __name(serializeFarmCspDirectives, "serializeFarmCspDirectives");
298
- function getFarmSecurityHeader(security, nonce) {
299
- if (!security.csp) return void 0;
300
- if (security.csp.nonce && !nonce) return void 0;
301
- return {
302
- key: security.csp.reportOnly ? "Content-Security-Policy-Report-Only" : "Content-Security-Policy",
303
- value: nonce ? applyFarmCspNonceToPolicy(security.csp.value, nonce) : security.csp.value
304
- };
305
- }
306
- __name(getFarmSecurityHeader, "getFarmSecurityHeader");
307
- function createFarmCspNonce(security) {
308
- if (!security.csp || !security.csp.nonce) return void 0;
309
- const bytes = new Uint8Array(16);
310
- globalThis.crypto.getRandomValues(bytes);
311
- return Array.from(bytes, (value) => value.toString(16).padStart(2, "0")).join("");
312
- }
313
- __name(createFarmCspNonce, "createFarmCspNonce");
314
- function applyFarmCspNonceToPolicy(policy, nonce) {
315
- validateCspNonce(nonce);
316
- return applyFarmCspScriptSourcesToPolicy(policy, [`'nonce-${nonce}'`]);
317
- }
318
- __name(applyFarmCspNonceToPolicy, "applyFarmCspNonceToPolicy");
319
- function applyFarmCspHashesToPolicy(policy, hashes) {
320
- const sources = hashes.map((hash) => {
321
- if (!/^sha(?:256|384|512)-[A-Za-z0-9+/]+={0,2}$/.test(hash)) {
322
- throw new TypeError(`Invalid CSP script hash: ${JSON.stringify(hash)}.`);
323
- }
324
- return `'${hash}'`;
325
- });
326
- return applyFarmCspScriptSourcesToPolicy(policy, sources);
327
- }
328
- __name(applyFarmCspHashesToPolicy, "applyFarmCspHashesToPolicy");
329
- function applyFarmCspScriptSourcesToPolicy(policy, sources) {
330
- const uniqueSources = [...new Set(sources)];
331
- if (uniqueSources.length === 0) return policy;
332
- const segments = policy.split(";").map((segment) => segment.trim()).filter(Boolean);
333
- const names = segments.map((segment) => segment.split(/\s+/, 1)[0].toLowerCase());
334
- const governingName = names.includes("script-src-elem") ? "script-src-elem" : names.includes("script-src") ? "script-src" : names.includes("default-src") ? "default-src" : void 0;
335
- if (!governingName) return `${policy}; script-src ${uniqueSources.join(" ")}`;
336
- return segments.map((segment, index) => {
337
- if (names[index] !== governingName) return segment;
338
- const existing = new Set(segment.split(/\s+/));
339
- const missing = uniqueSources.filter((source) => !existing.has(source));
340
- return missing.length > 0 ? `${segment} ${missing.join(" ")}` : segment;
341
- }).join("; ");
342
- }
343
- __name(applyFarmCspScriptSourcesToPolicy, "applyFarmCspScriptSourcesToPolicy");
344
- function addFarmCspNonceToScriptTags(html, nonce) {
345
- validateCspNonce(nonce);
346
- return createFarmCspNonceRewriter(nonce).write(html, true);
347
- }
348
- __name(addFarmCspNonceToScriptTags, "addFarmCspNonceToScriptTags");
349
- function removeFarmCspNoncesFromScriptTags(html) {
350
- return createFarmScriptTagRewriter(stripScriptNonceAttribute).write(html, true);
351
- }
352
- __name(removeFarmCspNoncesFromScriptTags, "removeFarmCspNoncesFromScriptTags");
353
- async function createFarmCspScriptHashes(html) {
354
- const hashes = [];
355
- const seen = /* @__PURE__ */ new Set();
356
- for (const content of collectFarmInlineScriptContents(html)) {
357
- const digest = await globalThis.crypto.subtle.digest(
358
- "SHA-256",
359
- new TextEncoder().encode(content)
360
- );
361
- let binary = "";
362
- for (const byte of new Uint8Array(digest)) binary += String.fromCharCode(byte);
363
- const hash = `sha256-${globalThis.btoa(binary)}`;
364
- if (!seen.has(hash)) {
365
- seen.add(hash);
366
- hashes.push(hash);
367
- }
368
- }
369
- return hashes;
370
- }
371
- __name(createFarmCspScriptHashes, "createFarmCspScriptHashes");
372
- async function applyFarmCspHashesToHtml(html, security) {
373
- if (!security.csp || !security.csp.nonce) return void 0;
374
- const staticHtml = removeFarmCspNoncesFromScriptTags(html);
375
- const hashes = await createFarmCspScriptHashes(staticHtml);
376
- return {
377
- html: staticHtml,
378
- header: {
379
- key: security.csp.reportOnly ? "Content-Security-Policy-Report-Only" : "Content-Security-Policy",
380
- value: applyFarmCspHashesToPolicy(security.csp.value, hashes)
381
- }
382
- };
383
- }
384
- __name(applyFarmCspHashesToHtml, "applyFarmCspHashesToHtml");
385
- function applyFarmCspNonceToResponse(response, security) {
386
- if (!security.csp || !security.csp.nonce) return response;
387
- if (!response.headers.get("content-type")?.toLowerCase().includes("text/html")) return response;
388
- const nonce = createFarmCspNonce(security);
389
- const securityHeader = getFarmSecurityHeader(security, nonce);
390
- if (!response.body) {
391
- return _withFarmResponseHeaders(response, (headers2) => {
392
- headers2.set(securityHeader.key, securityHeader.value);
393
- headers2.delete("content-length");
394
- });
395
- }
396
- const headers = new Headers(response.headers);
397
- headers.set(securityHeader.key, securityHeader.value);
398
- headers.delete("content-length");
399
- const decoder = new TextDecoder();
400
- const encoder = new TextEncoder();
401
- const rewriter = createFarmCspNonceRewriter(nonce);
402
- const body = response.body.pipeThrough(
403
- new TransformStream({
404
- transform(chunk, controller) {
405
- const output = rewriter.write(decoder.decode(chunk, { stream: true }));
406
- if (output) controller.enqueue(encoder.encode(output));
407
- },
408
- flush(controller) {
409
- const output = rewriter.write(decoder.decode(), true);
410
- if (output) controller.enqueue(encoder.encode(output));
411
- }
412
- })
413
- );
414
- return _markFarmOwnedResponse(
415
- new Response(body, {
416
- status: response.status,
417
- statusText: response.statusText,
418
- headers
419
- })
420
- );
421
- }
422
- __name(applyFarmCspNonceToResponse, "applyFarmCspNonceToResponse");
423
- function farmCspBlocksFrameworkInlineScripts(security) {
424
- if (!security.csp) return false;
425
- if (security.csp.nonce) return false;
426
- const directives = parseCspDirectives(security.csp.value);
427
- const governing = directives.get("script-src-elem") ?? directives.get("script-src") ?? directives.get("default-src");
428
- if (!governing) return false;
429
- const sources = governing.map((source) => source.toLowerCase());
430
- const disablesUnsafeInline = sources.some(
431
- (value) => value === "'strict-dynamic'" || value.startsWith("'nonce-") || value.startsWith("'sha256-") || value.startsWith("'sha384-") || value.startsWith("'sha512-")
432
- );
433
- return !sources.includes("'unsafe-inline'") || disablesUnsafeInline;
434
- }
435
- __name(farmCspBlocksFrameworkInlineScripts, "farmCspBlocksFrameworkInlineScripts");
436
- function parseCspDirectives(value) {
437
- const directives = /* @__PURE__ */ new Map();
438
- for (const segment of value.split(";")) {
439
- const parts = segment.trim().split(/\s+/).filter(Boolean);
440
- if (parts.length === 0) continue;
441
- const name = parts[0].toLowerCase();
442
- if (!directives.has(name)) directives.set(name, parts.slice(1));
443
- }
444
- return directives;
445
- }
446
- __name(parseCspDirectives, "parseCspDirectives");
447
- function normalizeDirectiveName(value) {
448
- const name = value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
449
- if (!/^[a-z][a-z0-9-]*$/.test(name)) {
450
- throw new TypeError(`Invalid security.csp directive name: ${JSON.stringify(value)}.`);
451
- }
452
- return name;
453
- }
454
- __name(normalizeDirectiveName, "normalizeDirectiveName");
455
- function validateDirectiveValue(value) {
456
- if (typeof value !== "string") {
457
- throw new TypeError("security.csp directive values must be strings or booleans.");
458
- }
459
- const normalized = value.trim();
460
- if (!normalized || /[;\r\n]/.test(normalized) || normalized.includes("\0")) {
461
- throw new TypeError(`Invalid security.csp directive value: ${JSON.stringify(value)}.`);
462
- }
463
- return normalized;
464
- }
465
- __name(validateDirectiveValue, "validateDirectiveValue");
466
- function validateSerializedCsp(value) {
467
- if (typeof value !== "string") {
468
- throw new TypeError("security.csp policy must be a non-empty single-line string.");
469
- }
470
- const normalized = value.trim().replace(/;+$/g, "").trim();
471
- if (!normalized || /[\r\n]/.test(normalized) || normalized.includes("\0")) {
472
- throw new TypeError("security.csp policy must be a non-empty single-line string.");
473
- }
474
- return normalized;
475
- }
476
- __name(validateSerializedCsp, "validateSerializedCsp");
477
- function validateReportOnly(value) {
478
- if (value === void 0) return false;
479
- if (typeof value !== "boolean") {
480
- throw new TypeError("security.csp.reportOnly must be a boolean.");
481
- }
482
- return value;
483
- }
484
- __name(validateReportOnly, "validateReportOnly");
485
- function validateNonce(value) {
486
- if (value === void 0) return false;
487
- if (typeof value !== "boolean") {
488
- throw new TypeError("security.csp.nonce must be a boolean.");
489
- }
490
- return value;
491
- }
492
- __name(validateNonce, "validateNonce");
493
- function validateCspNonce(value) {
494
- if (!/^[A-Za-z0-9+/_-]+={0,2}$/.test(value)) {
495
- throw new TypeError("A CSP nonce must be a base64 or base64url value.");
496
- }
497
- }
498
- __name(validateCspNonce, "validateCspNonce");
499
- function createFarmCspNonceRewriter(nonce) {
500
- validateCspNonce(nonce);
501
- return createFarmScriptTagRewriter((tag) => stampScriptTag(tag, nonce));
502
- }
503
- __name(createFarmCspNonceRewriter, "createFarmCspNonceRewriter");
504
- function createFarmScriptTagRewriter(transformScriptTag) {
505
- let pending = "";
506
- let rawTextElement;
507
- return {
508
- write(chunk, final = false) {
509
- pending += chunk;
510
- let output = "";
511
- while (pending) {
512
- if (rawTextElement) {
513
- if (rawTextElement === "plaintext") {
514
- output += pending;
515
- pending = "";
516
- break;
517
- }
518
- const closing = `</${rawTextElement}`;
519
- const start2 = findRawTextEnd(pending, rawTextElement);
520
- if (start2 === -1) {
521
- if (final) {
522
- output += pending;
523
- pending = "";
524
- } else {
525
- const keep = matchingSuffixLength(pending, closing);
526
- output += pending.slice(0, pending.length - keep);
527
- pending = pending.slice(pending.length - keep);
528
- }
529
- break;
530
- }
531
- output += pending.slice(0, start2);
532
- pending = pending.slice(start2);
533
- const end2 = findHtmlTagEnd(pending);
534
- if (end2 === -1) {
535
- if (final) {
536
- output += pending;
537
- pending = "";
538
- }
539
- break;
540
- }
541
- output += pending.slice(0, end2 + 1);
542
- pending = pending.slice(end2 + 1);
543
- rawTextElement = void 0;
544
- continue;
545
- }
546
- const start = pending.indexOf("<");
547
- if (start === -1) {
548
- output += pending;
549
- pending = "";
550
- break;
551
- }
552
- output += pending.slice(0, start);
553
- pending = pending.slice(start);
554
- if (pending.startsWith("<!--")) {
555
- const end2 = pending.indexOf("-->", 4);
556
- if (end2 === -1) {
557
- if (final) {
558
- output += pending;
559
- pending = "";
560
- }
561
- break;
562
- }
563
- output += pending.slice(0, end2 + 3);
564
- pending = pending.slice(end2 + 3);
565
- continue;
566
- }
567
- if (!final && "<!--".startsWith(pending)) break;
568
- const tagNameMatch = pending.match(/^<\/?([a-z][a-z0-9:-]*)\b/i);
569
- if (!tagNameMatch) {
570
- if (!final && /^<\/?[a-z][a-z0-9:-]*$/i.test(pending)) break;
571
- output += pending[0];
572
- pending = pending.slice(1);
573
- continue;
574
- }
575
- const end = findHtmlTagEnd(pending);
576
- if (end === -1) {
577
- if (!final) break;
578
- output += pending;
579
- pending = "";
580
- break;
581
- }
582
- const tag = pending.slice(0, end + 1);
583
- const tagName = tagNameMatch[1].toLowerCase();
584
- const isClosing = pending.startsWith("</");
585
- const isSelfClosing = /\/\s*>$/.test(tag);
586
- output += !isClosing && tagName === "script" ? transformScriptTag(tag) : tag;
587
- pending = pending.slice(end + 1);
588
- if (!isClosing && !isSelfClosing && rawTextElements.has(tagName)) {
589
- rawTextElement = tagName;
590
- }
591
- }
592
- return output;
593
- }
594
- };
595
- }
596
- __name(createFarmScriptTagRewriter, "createFarmScriptTagRewriter");
597
- var rawTextElements = /* @__PURE__ */ new Map([
598
- ["iframe", /<\/iframe(?=[\s/>]|$)/gi],
599
- ["noembed", /<\/noembed(?=[\s/>]|$)/gi],
600
- ["noframes", /<\/noframes(?=[\s/>]|$)/gi],
601
- ["plaintext", null],
602
- ["script", /<\/script(?=[\s/>]|$)/gi],
603
- ["style", /<\/style(?=[\s/>]|$)/gi],
604
- ["textarea", /<\/textarea(?=[\s/>]|$)/gi],
605
- ["title", /<\/title(?=[\s/>]|$)/gi],
606
- ["xmp", /<\/xmp(?=[\s/>]|$)/gi]
607
- ]);
608
- function stampScriptTag(tag, nonce) {
609
- const opening = tag.match(/^<script\b/i)?.[0];
610
- if (!opening) return tag;
611
- const attributes = stripScriptNonceAttribute(tag).slice(opening.length, -1);
612
- return `<script nonce="${nonce}"${attributes}>`;
613
- }
614
- __name(stampScriptTag, "stampScriptTag");
615
- function stripScriptNonceAttribute(tag) {
616
- let normalized = tag;
617
- let range = findScriptTagAttributeRange(normalized, "nonce");
618
- while (range) {
619
- normalized = normalized.slice(0, range.start) + normalized.slice(range.end);
620
- range = findScriptTagAttributeRange(normalized, "nonce");
621
- }
622
- return normalized;
623
- }
624
- __name(stripScriptNonceAttribute, "stripScriptNonceAttribute");
625
- function collectFarmInlineScriptContents(html) {
626
- const contents = [];
627
- let offset = 0;
628
- while (offset < html.length) {
629
- const start = html.indexOf("<", offset);
630
- if (start === -1) break;
631
- if (html.startsWith("<!--", start)) {
632
- const commentEnd = html.indexOf("-->", start + 4);
633
- offset = commentEnd === -1 ? html.length : commentEnd + 3;
634
- continue;
635
- }
636
- const remaining = html.slice(start);
637
- const tagNameMatch = remaining.match(/^<\/?([a-z][a-z0-9:-]*)\b/i);
638
- if (!tagNameMatch) {
639
- offset = start + 1;
640
- continue;
641
- }
642
- const tagEnd = findHtmlTagEnd(remaining);
643
- if (tagEnd === -1) break;
644
- const tag = remaining.slice(0, tagEnd + 1);
645
- const tagName = tagNameMatch[1].toLowerCase();
646
- const isClosing = remaining.startsWith("</");
647
- const isSelfClosing = /\/\s*>$/.test(tag);
648
- offset = start + tagEnd + 1;
649
- if (isClosing || isSelfClosing || !rawTextElements.has(tagName)) continue;
650
- if (tagName === "plaintext") break;
651
- const closingStart = findRawTextEnd(html, tagName, offset);
652
- const contentEnd = closingStart === -1 ? html.length : closingStart;
653
- if (tagName === "script" && !findScriptTagAttributeRange(tag, "src")) {
654
- contents.push(html.slice(offset, contentEnd));
655
- }
656
- if (closingStart === -1) break;
657
- const closingEnd = findHtmlTagEnd(html.slice(contentEnd));
658
- if (closingEnd === -1) break;
659
- offset = contentEnd + closingEnd + 1;
660
- }
661
- return contents;
662
- }
663
- __name(collectFarmInlineScriptContents, "collectFarmInlineScriptContents");
664
- function findScriptTagAttributeRange(tag, expectedName) {
665
- const opening = tag.match(/^<script\b/i)?.[0];
666
- if (!opening) return void 0;
667
- let offset = opening.length;
668
- while (offset < tag.length - 1) {
669
- const whitespaceStart = offset;
670
- while (/\s/.test(tag[offset] || "")) offset++;
671
- if (tag[offset] === "/" || tag[offset] === ">" || offset >= tag.length - 1) break;
672
- const nameStart = offset;
673
- while (offset < tag.length && !/[\s=/>]/.test(tag[offset])) offset++;
674
- const name = tag.slice(nameStart, offset).toLowerCase();
675
- while (/\s/.test(tag[offset] || "")) offset++;
676
- if (tag[offset] === "=") {
677
- offset++;
678
- while (/\s/.test(tag[offset] || "")) offset++;
679
- const quote = tag[offset] === '"' || tag[offset] === "'" ? tag[offset++] : void 0;
680
- if (quote) {
681
- while (offset < tag.length && tag[offset] !== quote) offset++;
682
- if (tag[offset] === quote) offset++;
683
- } else {
684
- while (offset < tag.length && !/[\s>]/.test(tag[offset])) offset++;
685
- }
686
- }
687
- if (name === expectedName) return { start: whitespaceStart, end: offset };
688
- }
689
- return void 0;
690
- }
691
- __name(findScriptTagAttributeRange, "findScriptTagAttributeRange");
692
- function findRawTextEnd(input, tagName, offset = 0) {
693
- const closing = rawTextElements.get(tagName);
694
- closing.lastIndex = offset;
695
- return closing.exec(input)?.index ?? -1;
696
- }
697
- __name(findRawTextEnd, "findRawTextEnd");
698
- function matchingSuffixLength(input, token) {
699
- const limit = Math.min(token.length - 1, input.length);
700
- for (let length = limit; length > 0; length--) {
701
- if (token.startsWith(input.slice(-length).toLowerCase())) return length;
702
- }
703
- return 0;
704
- }
705
- __name(matchingSuffixLength, "matchingSuffixLength");
706
- function findHtmlTagEnd(tag) {
707
- let quote;
708
- for (let index = 1; index < tag.length; index++) {
709
- const character = tag[index];
710
- if (quote) {
711
- if (character === quote) quote = void 0;
712
- } else if (character === '"' || character === "'") {
713
- quote = character;
714
- } else if (character === ">") {
715
- return index;
716
- }
717
- }
718
- return -1;
719
- }
720
- __name(findHtmlTagEnd, "findHtmlTagEnd");
721
- function isPlainRecord(value) {
722
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
723
- const prototype = Object.getPrototypeOf(value);
724
- return prototype === Object.prototype || prototype === null;
725
- }
726
- __name(isPlainRecord, "isPlainRecord");
727
-
728
211
  // src/preload.ts
729
212
  var DEFAULT_PRELOAD_CONFIG = {
730
213
  mode: "enforce",
@@ -977,7 +460,7 @@ function findHtmlLinkElements(html) {
977
460
  rawTextTag.lastIndex = start;
978
461
  const rawText = rawTextTag.exec(lowerHtml);
979
462
  if (rawText?.[1]) {
980
- const openingEnd = findHtmlTagEnd2(html, start);
463
+ const openingEnd = findHtmlTagEnd(html, start);
981
464
  if (openingEnd === -1) break;
982
465
  if (rawText[1] === "svg" && html[openingEnd - 2] === "/") {
983
466
  cursor = openingEnd;
@@ -992,13 +475,13 @@ function findHtmlLinkElements(html) {
992
475
  cursor = html.length;
993
476
  continue;
994
477
  }
995
- const closingEnd = findHtmlTagEnd2(html, closingStart);
478
+ const closingEnd = findHtmlTagEnd(html, closingStart);
996
479
  cursor = closingEnd === -1 ? html.length : closingEnd;
997
480
  continue;
998
481
  }
999
482
  linkTag.lastIndex = start;
1000
483
  if (linkTag.test(html)) {
1001
- const end = findHtmlTagEnd2(html, start);
484
+ const end = findHtmlTagEnd(html, start);
1002
485
  if (end === -1) break;
1003
486
  elements.push({ start, end, value: html.slice(start, end) });
1004
487
  cursor = end;
@@ -1006,7 +489,7 @@ function findHtmlLinkElements(html) {
1006
489
  }
1007
490
  ordinaryTag.lastIndex = start;
1008
491
  if (ordinaryTag.test(html)) {
1009
- const end = findHtmlTagEnd2(html, start);
492
+ const end = findHtmlTagEnd(html, start);
1010
493
  cursor = end === -1 ? html.length : end;
1011
494
  continue;
1012
495
  }
@@ -1042,7 +525,7 @@ function findHtmlClosingTag(html, tagName, start) {
1042
525
  return -1;
1043
526
  }
1044
527
  __name(findHtmlClosingTag, "findHtmlClosingTag");
1045
- function findHtmlTagEnd2(html, start) {
528
+ function findHtmlTagEnd(html, start) {
1046
529
  let quote;
1047
530
  for (let index = start + 1; index < html.length; index += 1) {
1048
531
  const character = html[index];
@@ -1056,7 +539,7 @@ function findHtmlTagEnd2(html, start) {
1056
539
  }
1057
540
  return -1;
1058
541
  }
1059
- __name(findHtmlTagEnd2, "findHtmlTagEnd");
542
+ __name(findHtmlTagEnd, "findHtmlTagEnd");
1060
543
  function removeHtmlLinkElements(html, elements, removed) {
1061
544
  let cursor = 0;
1062
545
  let output = "";
@@ -1138,14 +621,6 @@ export {
1138
621
  createFarmAgentRobots,
1139
622
  resolveFarmAgentSitemap,
1140
623
  createFarmDefaultSitemap,
1141
- resolveFarmSecurityConfig,
1142
- getFarmSecurityHeader,
1143
- createFarmCspNonce,
1144
- addFarmCspNonceToScriptTags,
1145
- applyFarmCspHashesToHtml,
1146
- applyFarmCspNonceToResponse,
1147
- farmCspBlocksFrameworkInlineScripts,
1148
- createFarmCspNonceRewriter,
1149
624
  resolveFarmPerformanceConfig,
1150
625
  manageFarmHtmlPreloads,
1151
626
  manageFarmLinkHeaderPreloads,