@absolutejs/absolute 0.19.0-beta.782 → 0.19.0-beta.784
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/angular/browser.js +57 -9801
- package/dist/angular/browser.js.map +4 -246
- package/dist/angular/index.js +61 -14880
- package/dist/angular/index.js.map +4 -282
- package/dist/angular/server.js +46 -5613
- package/dist/angular/server.js.map +3 -52
- package/dist/build.js +45 -17902
- package/dist/build.js.map +3 -100
- package/dist/chunk-102fp7xe.js +63 -0
- package/dist/chunk-102fp7xe.js.map +10 -0
- package/dist/chunk-11zpfqz6.js +19 -0
- package/dist/chunk-11zpfqz6.js.map +10 -0
- package/dist/chunk-1e9vsfyh.js +100 -0
- package/dist/chunk-1e9vsfyh.js.map +10 -0
- package/dist/chunk-25v9t56f.js +29 -0
- package/dist/chunk-25v9t56f.js.map +11 -0
- package/dist/chunk-2f21eenc.js +21 -0
- package/dist/chunk-2f21eenc.js.map +10 -0
- package/dist/chunk-2ga2znex.js +13 -0
- package/dist/chunk-2ga2znex.js.map +9 -0
- package/dist/chunk-30yrw0f6.js +33 -0
- package/dist/chunk-30yrw0f6.js.map +10 -0
- package/dist/chunk-3c7mpj3m.js +784 -0
- package/dist/chunk-3c7mpj3m.js.map +10 -0
- package/dist/chunk-3g91wb4f.js +358 -0
- package/dist/chunk-3g91wb4f.js.map +10 -0
- package/dist/chunk-3yjzpcne.js +34 -0
- package/dist/chunk-3yjzpcne.js.map +10 -0
- package/dist/chunk-4bq79t8v.js +136 -0
- package/dist/chunk-4bq79t8v.js.map +10 -0
- package/dist/chunk-4d39r92n.js +81 -0
- package/dist/chunk-4d39r92n.js.map +10 -0
- package/dist/chunk-4m75s5xf.js +184 -0
- package/dist/chunk-4m75s5xf.js.map +11 -0
- package/dist/chunk-5003emhv.js +17 -0
- package/dist/chunk-5003emhv.js.map +10 -0
- package/dist/chunk-5fhp1jap.js +9169 -0
- package/dist/chunk-5fhp1jap.js.map +236 -0
- package/dist/chunk-6fkgm9s5.js +569 -0
- package/dist/chunk-6fkgm9s5.js.map +10 -0
- package/dist/chunk-6pdj08z3.js +73 -0
- package/dist/chunk-6pdj08z3.js.map +12 -0
- package/dist/chunk-6qjbrt0k.js +13 -0
- package/dist/chunk-6qjbrt0k.js.map +9 -0
- package/dist/chunk-6sccb4jr.js +14 -0
- package/dist/chunk-6sccb4jr.js.map +9 -0
- package/dist/chunk-73brtyw5.js +16 -0
- package/dist/chunk-73brtyw5.js.map +9 -0
- package/dist/chunk-77cqkarb.js +25 -0
- package/dist/chunk-77cqkarb.js.map +9 -0
- package/dist/chunk-798spvzv.js +50 -0
- package/dist/chunk-798spvzv.js.map +10 -0
- package/dist/chunk-7fw6x3js.js +131 -0
- package/dist/chunk-7fw6x3js.js.map +11 -0
- package/dist/chunk-7kjj42xm.js +11 -0
- package/dist/chunk-7kjj42xm.js.map +10 -0
- package/dist/chunk-851whwc7.js +17 -0
- package/dist/chunk-851whwc7.js.map +10 -0
- package/dist/chunk-85n68sy6.js +103 -0
- package/dist/chunk-85n68sy6.js.map +10 -0
- package/dist/chunk-8feq2qek.js +17 -0
- package/dist/chunk-8feq2qek.js.map +9 -0
- package/dist/chunk-8kcfffry.js +35 -0
- package/dist/chunk-8kcfffry.js.map +10 -0
- package/dist/chunk-93sqk7be.js +139 -0
- package/dist/chunk-93sqk7be.js.map +12 -0
- package/dist/chunk-97572s32.js +262 -0
- package/dist/chunk-97572s32.js.map +12 -0
- package/dist/chunk-9a307ca6.js +1742 -0
- package/dist/chunk-9a307ca6.js.map +11 -0
- package/dist/chunk-9c5tj4k3.js +130 -0
- package/dist/chunk-9c5tj4k3.js.map +10 -0
- package/dist/chunk-9xrsjeem.js +12 -0
- package/dist/chunk-9xrsjeem.js.map +9 -0
- package/dist/chunk-a9mvyp04.js +87 -0
- package/dist/chunk-a9mvyp04.js.map +10 -0
- package/dist/chunk-b3gbnrwe.js +21 -0
- package/dist/chunk-b3gbnrwe.js.map +10 -0
- package/dist/chunk-bmgqm774.js +65 -0
- package/dist/chunk-bmgqm774.js.map +9 -0
- package/dist/chunk-bxfghpma.js +69 -0
- package/dist/chunk-bxfghpma.js.map +10 -0
- package/dist/chunk-c1jfjnka.js +74 -0
- package/dist/chunk-c1jfjnka.js.map +10 -0
- package/dist/chunk-cbkrwmvh.js +80 -0
- package/dist/chunk-cbkrwmvh.js.map +10 -0
- package/dist/chunk-cdxd7sy2.js +71 -0
- package/dist/chunk-cdxd7sy2.js.map +10 -0
- package/dist/chunk-cg95827x.js +21 -0
- package/dist/chunk-cg95827x.js.map +10 -0
- package/dist/chunk-d9c0am65.js +12 -0
- package/dist/chunk-d9c0am65.js.map +10 -0
- package/dist/chunk-daqghmg8.js +12 -0
- package/dist/chunk-daqghmg8.js.map +9 -0
- package/dist/chunk-dr9yqsdb.js +203 -0
- package/dist/chunk-dr9yqsdb.js.map +10 -0
- package/dist/chunk-e8eecyrq.js +244 -0
- package/dist/chunk-e8eecyrq.js.map +10 -0
- package/dist/chunk-ex2hxe0v.js +160 -0
- package/dist/chunk-ex2hxe0v.js.map +11 -0
- package/dist/chunk-ey5hs6x6.js +253 -0
- package/dist/chunk-ey5hs6x6.js.map +11 -0
- package/dist/chunk-fak944et.js +91 -0
- package/dist/chunk-fak944et.js.map +10 -0
- package/dist/chunk-fygx2ymm.js +118 -0
- package/dist/chunk-fygx2ymm.js.map +12 -0
- package/dist/chunk-g15qj669.js +271 -0
- package/dist/chunk-g15qj669.js.map +11 -0
- package/dist/chunk-g3j22qf6.js +51 -0
- package/dist/chunk-g3j22qf6.js.map +9 -0
- package/dist/chunk-gd6wmknh.js +121 -0
- package/dist/chunk-gd6wmknh.js.map +11 -0
- package/dist/chunk-gf0ygptk.js +85 -0
- package/dist/chunk-gf0ygptk.js.map +11 -0
- package/dist/chunk-gq0zxpm0.js +90 -0
- package/dist/chunk-gq0zxpm0.js.map +10 -0
- package/dist/chunk-gytkmthr.js +220 -0
- package/dist/chunk-gytkmthr.js.map +10 -0
- package/dist/chunk-h5bbfn3n.js +28 -0
- package/dist/chunk-h5bbfn3n.js.map +11 -0
- package/dist/chunk-h6mye9r3.js +93 -0
- package/dist/chunk-h6mye9r3.js.map +10 -0
- package/dist/chunk-hcsmxw1v.js +85 -0
- package/dist/chunk-hcsmxw1v.js.map +10 -0
- package/dist/chunk-hep68ja7.js +4444 -0
- package/dist/chunk-hep68ja7.js.map +29 -0
- package/dist/chunk-hhqh49fz.js +149 -0
- package/dist/chunk-hhqh49fz.js.map +10 -0
- package/dist/chunk-hyjs4bqs.js +8 -0
- package/dist/chunk-hyjs4bqs.js.map +10 -0
- package/dist/chunk-hza0n8qm.js +20 -0
- package/dist/chunk-hza0n8qm.js.map +9 -0
- package/dist/chunk-jn91vzkh.js +66 -0
- package/dist/chunk-jn91vzkh.js.map +10 -0
- package/dist/chunk-jwxt8gnp.js +13 -0
- package/dist/chunk-jwxt8gnp.js.map +9 -0
- package/dist/chunk-kk8w9rh5.js +195 -0
- package/dist/chunk-kk8w9rh5.js.map +10 -0
- package/dist/chunk-kndkjsya.js +261 -0
- package/dist/chunk-kndkjsya.js.map +10 -0
- package/dist/chunk-kvq01j35.js +36 -0
- package/dist/chunk-kvq01j35.js.map +10 -0
- package/dist/chunk-mbazhahf.js +60 -0
- package/dist/chunk-mbazhahf.js.map +10 -0
- package/dist/chunk-mgfwq18r.js +15 -0
- package/dist/chunk-mgfwq18r.js.map +9 -0
- package/dist/chunk-mtgf69xn.js +88 -0
- package/dist/chunk-mtgf69xn.js.map +10 -0
- package/dist/chunk-nehhtthw.js +225 -0
- package/dist/chunk-nehhtthw.js.map +10 -0
- package/dist/chunk-nhzf4az4.js +149 -0
- package/dist/chunk-nhzf4az4.js.map +10 -0
- package/dist/chunk-p5504p14.js +16 -0
- package/dist/chunk-p5504p14.js.map +10 -0
- package/dist/chunk-pnscgw95.js +90 -0
- package/dist/chunk-pnscgw95.js.map +10 -0
- package/dist/chunk-pvpp4pvs.js +17 -0
- package/dist/chunk-pvpp4pvs.js.map +10 -0
- package/dist/chunk-qh75agse.js +95 -0
- package/dist/chunk-qh75agse.js.map +10 -0
- package/dist/chunk-qk8kd3hr.js +526 -0
- package/dist/chunk-qk8kd3hr.js.map +12 -0
- package/dist/chunk-qxq2zcty.js +52 -0
- package/dist/chunk-qxq2zcty.js.map +10 -0
- package/dist/chunk-r7jmgqnw.js +114 -0
- package/dist/chunk-r7jmgqnw.js.map +10 -0
- package/dist/chunk-s6defjk2.js +116 -0
- package/dist/chunk-s6defjk2.js.map +10 -0
- package/dist/chunk-sd39p726.js +619 -0
- package/dist/chunk-sd39p726.js.map +10 -0
- package/dist/chunk-smgj0epn.js +18 -0
- package/dist/chunk-smgj0epn.js.map +9 -0
- package/dist/chunk-swrnzs4c.js +63 -0
- package/dist/chunk-swrnzs4c.js.map +10 -0
- package/dist/chunk-t81a331y.js +27 -0
- package/dist/chunk-t81a331y.js.map +10 -0
- package/dist/chunk-tfe3sb44.js +33 -0
- package/dist/chunk-tfe3sb44.js.map +10 -0
- package/dist/chunk-tx9edm1x.js +34 -0
- package/dist/chunk-tx9edm1x.js.map +10 -0
- package/dist/chunk-vkrpm7kc.js +247 -0
- package/dist/chunk-vkrpm7kc.js.map +12 -0
- package/dist/chunk-vvz7dcvq.js +434 -0
- package/dist/chunk-vvz7dcvq.js.map +13 -0
- package/dist/chunk-w3m4m5we.js +4925 -0
- package/dist/chunk-w3m4m5we.js.map +12 -0
- package/dist/chunk-wrxtn9ve.js +18 -0
- package/dist/chunk-wrxtn9ve.js.map +10 -0
- package/dist/chunk-xpkjbmd3.js +428 -0
- package/dist/chunk-xpkjbmd3.js.map +14 -0
- package/dist/chunk-xrmjy8kk.js +454 -0
- package/dist/chunk-xrmjy8kk.js.map +10 -0
- package/dist/chunk-xw0tx842.js +13 -0
- package/dist/chunk-xw0tx842.js.map +9 -0
- package/dist/chunk-xx5b6b9m.js +69 -0
- package/dist/chunk-xx5b6b9m.js.map +10 -0
- package/dist/chunk-xz1kdswj.js +21 -0
- package/dist/chunk-xz1kdswj.js.map +9 -0
- package/dist/chunk-xzvy9hr4.js +377 -0
- package/dist/chunk-xzvy9hr4.js.map +10 -0
- package/dist/chunk-yfqhr31t.js +39 -0
- package/dist/chunk-yfqhr31t.js.map +9 -0
- package/dist/chunk-ygzd5s4z.js +184 -0
- package/dist/chunk-ygzd5s4z.js.map +10 -0
- package/dist/chunk-ywjn0rad.js +14 -0
- package/dist/chunk-ywjn0rad.js.map +9 -0
- package/dist/chunk-z9nvhm6r.js +13 -0
- package/dist/chunk-z9nvhm6r.js.map +9 -0
- package/dist/chunk-zhmvdpk6.js +15 -0
- package/dist/chunk-zhmvdpk6.js.map +9 -0
- package/dist/cli/index.js +6 -3
- package/dist/client/index.js +32 -1112
- package/dist/client/index.js.map +4 -22
- package/dist/core/streamingSlotRegistrar.js +11 -108
- package/dist/core/streamingSlotRegistrar.js.map +3 -4
- package/dist/core/streamingSlotRegistry.js +7 -169
- package/dist/core/streamingSlotRegistry.js.map +3 -5
- package/dist/index.js +537 -19714
- package/dist/index.js.map +3 -117
- package/dist/islands/browser.js +9 -228
- package/dist/islands/browser.js.map +4 -9
- package/dist/islands/index.js +18 -1900
- package/dist/islands/index.js.map +3 -28
- package/dist/react/browser.js +12 -328
- package/dist/react/browser.js.map +4 -12
- package/dist/react/components/index.js +16 -167
- package/dist/react/components/index.js.map +3 -6
- package/dist/react/hooks/index.js +8 -183
- package/dist/react/hooks/index.js.map +3 -7
- package/dist/react/index.js +37 -3619
- package/dist/react/index.js.map +4 -46
- package/dist/react/jsxDevRuntimeCompat.js +2 -61
- package/dist/react/jsxDevRuntimeCompat.js.map +2 -2
- package/dist/react/server.js +18 -1789
- package/dist/react/server.js.map +3 -21
- package/dist/src/build/stylePreprocessor.d.ts +3 -0
- package/dist/src/core/index.d.ts +0 -2
- package/dist/svelte/browser.js +12 -247
- package/dist/svelte/browser.js.map +3 -10
- package/dist/svelte/index.js +38 -3724
- package/dist/svelte/index.js.map +4 -48
- package/dist/svelte/server.js +22 -2701
- package/dist/svelte/server.js.map +3 -27
- package/dist/vue/browser.js +12 -348
- package/dist/vue/browser.js.map +4 -12
- package/dist/vue/components/Image.js +7 -240
- package/dist/vue/components/Image.js.map +3 -6
- package/dist/vue/components/index.js +11 -544
- package/dist/vue/components/index.js.map +3 -9
- package/dist/vue/index.js +53 -4204
- package/dist/vue/index.js.map +4 -51
- package/dist/vue/server.js +18 -1849
- package/dist/vue/server.js.map +3 -21
- package/package.json +7 -7
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils/streamingSlots.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { getStreamSwapRuntimeScript } from '../client/streamSwap';\nimport { BASE_36_RADIX, RANDOM_ID_END_INDEX } from '../constants';\nimport { escapeScriptContent } from './escapeScriptContent';\n\nconst SLOT_ID_PREFIX = 'abs-slot-';\nconst CLOSING_BODY_TAG = '</body>';\nconst CLOSING_HEAD_TAG = '</head>';\nconst CLOSING_BODY_TAG_LENGTH = CLOSING_BODY_TAG.length;\nconst CLOSING_HEAD_TAG_LENGTH = CLOSING_HEAD_TAG.length;\nconst CLOSING_PAGE_TAG_REGEX = /<\\/body>\\s*<\\/html>\\s*$/i;\nconst STREAMING_RUNTIME_GLOBAL = '__ABS_SLOT_ENQUEUE__';\nconst STREAMING_PENDING_GLOBAL = '__ABS_SLOT_PENDING__';\nconst STREAM_TAIL_LOOKBEHIND = 128;\nconst STREAMING_SLOT_TIMEOUT_MS = 5_000;\nconst STREAMING_SLOT_MAX_PER_RESPONSE = 128;\nconst STREAMING_SLOT_MAX_HTML_BYTES = 64_000;\n\ntype SlotResolver = () => Promise<unknown> | unknown;\ntype SlotErrorHandler = (error: unknown, slot: StreamingSlot) => void;\ntype StreamReader = ReadableStreamDefaultReader<string | Uint8Array>;\ntype StreamReadPromise = ReturnType<StreamReader['read']>;\nexport type StreamingSlotMetricType =\n\t| 'prepared'\n\t| 'dropped'\n\t| 'resolved'\n\t| 'patched'\n\t| 'timeout'\n\t| 'size_exceeded'\n\t| 'error';\nexport type StreamingSlotMetric = {\n\ttype: StreamingSlotMetricType;\n\tslotId: string;\n\tdurationMs?: number;\n\tbytes?: number;\n\treason?: string;\n\terror?: unknown;\n};\nexport type StreamingSlotMetricHandler = (metric: StreamingSlotMetric) => void;\n\nexport type StreamingSlotPolicy = {\n\ttimeoutMs?: number;\n\tfallbackHtml?: unknown;\n\terrorHtml?: unknown;\n\tmaxSlotsPerResponse?: number;\n\tmaxSlotHtmlSizeBytes?: number;\n\tonError?: SlotErrorHandler;\n\tonSlotMetric?: StreamingSlotMetricHandler;\n};\n\ntype StreamingSlotPolicyValue = {\n\ttimeoutMs: number;\n\tfallbackHtml: string;\n\terrorHtml?: string;\n\tmaxSlotsPerResponse: number;\n\tmaxSlotHtmlSizeBytes: number;\n\tonError?: SlotErrorHandler;\n\tonSlotMetric?: StreamingSlotMetricHandler;\n};\n\nexport type StreamingSlot = {\n\terrorHtml?: unknown;\n\tfallbackHtml?: unknown;\n\tid: string;\n\ttimeoutMs?: number;\n\tresolve: SlotResolver;\n};\n\nexport type StreamingSlotPatchPayload =\n\t| string\n\t| {\n\t\t\t[key: string]: unknown;\n\t\t\thtml: string;\n\t };\n\ntype DeferredStreamingSlot = Omit<StreamingSlot, 'id'> & { id?: string };\n\nexport type AppendStreamingSlotsOptions = {\n\tinjectRuntime?: boolean;\n\tnonce?: string;\n\truntimePreludeScript?: string;\n\tpolicy?: StreamingSlotPolicy;\n\tonSlotMetric?: StreamingSlotMetricHandler;\n\tonError?: (error: unknown, slot: StreamingSlot) => void;\n\truntimePlacement?: 'body' | 'head';\n};\n\nexport type StreamOutOfOrderSlotsOptions = {\n\tfooterHtml?: string;\n\theaderHtml?: string;\n\tnonce?: string;\n\tpolicy?: StreamingSlotPolicy;\n\tonSlotMetric?: StreamingSlotMetricHandler;\n\tonError?: (error: unknown, slot: StreamingSlot) => void;\n\tslots: DeferredStreamingSlot[];\n};\n\nconst createSlotPatchStatement = (\n\tid: string,\n\tpayload: StreamingSlotPatchPayload\n) =>\n\t`(window.${STREAMING_RUNTIME_GLOBAL}||function(i,p){window.${STREAMING_PENDING_GLOBAL}=window.${STREAMING_PENDING_GLOBAL}||{};window.${STREAMING_PENDING_GLOBAL}[i]=p;})(${JSON.stringify(id)},${JSON.stringify(payload)});`;\n\nconst createNonceAttr = (nonce?: string) => (nonce ? ` nonce=\"${nonce}\"` : '');\n\nexport const createStreamingSlotId = () =>\n\t`${SLOT_ID_PREFIX}${Math.random().toString(BASE_36_RADIX).slice(2, RANDOM_ID_END_INDEX)}`;\nexport const getStreamingSlotsRuntimeScript = () =>\n\tgetStreamSwapRuntimeScript();\nexport const injectHtmlIntoBody = (html: string, injection: string) => {\n\tconst closingBodyIndex = html.indexOf(CLOSING_BODY_TAG);\n\tif (closingBodyIndex >= 0) {\n\t\treturn `${html.slice(0, closingBodyIndex)}${injection}${html.slice(closingBodyIndex)}`;\n\t}\n\n\treturn `${html}${injection}`;\n};\nexport const injectHtmlIntoHead = (html: string, injection: string) => {\n\tconst closingHeadIndex = html.indexOf(CLOSING_HEAD_TAG);\n\tif (closingHeadIndex >= 0) {\n\t\treturn `${html.slice(0, closingHeadIndex)}${injection}${html.slice(closingHeadIndex)}`;\n\t}\n\n\treturn `${html}${injection}`;\n};\nexport const renderStreamingSlotPatchTag = (\n\tid: string,\n\tpayload: StreamingSlotPatchPayload,\n\tnonce?: string\n) =>\n\t`<script${createNonceAttr(nonce)}>${escapeScriptContent(\n\t\tcreateSlotPatchStatement(id, payload)\n\t)}</script>`;\nexport const renderStreamingSlotPlaceholder = (id: string, fallbackHtml = '') =>\n\t`<div id=\"${id}\" data-absolute-slot=\"true\" data-absolute-slot-state=\"fallback\">${fallbackHtml}</div>`;\nexport const renderStreamingSlotsRuntimeTag = (\n\tnonce?: string,\n\truntimePreludeScript?: string\n) => {\n\tconst runtimeBody = [\n\t\truntimePreludeScript?.trim() ? runtimePreludeScript.trim() : '',\n\t\tgetStreamingSlotsRuntimeScript()\n\t]\n\t\t.filter(Boolean)\n\t\t.join(';');\n\n\treturn `<script${createNonceAttr(nonce)}>${escapeScriptContent(runtimeBody)}</script>`;\n};\n\nconst toUint8 = (value: string, encoder: TextEncoder) => encoder.encode(value);\n\ntype SafeHtmlLike = {\n\tchangingThisBreaksApplicationSecurity: string;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\tBoolean(value) && typeof value === 'object';\n\nconst isSafeHtmlLike = (value: unknown): value is SafeHtmlLike =>\n\tisRecord(value) &&\n\ttypeof value.changingThisBreaksApplicationSecurity === 'string';\n\nconst normalizeSafeHtml = (value: unknown) => {\n\tif (isSafeHtmlLike(value)) {\n\t\treturn value.changingThisBreaksApplicationSecurity;\n\t}\n\n\treturn value;\n};\n\nlet currentStreamingSlotPolicy: StreamingSlotPolicyValue = {\n\terrorHtml: undefined,\n\tfallbackHtml: '',\n\tmaxSlotHtmlSizeBytes: STREAMING_SLOT_MAX_HTML_BYTES,\n\tmaxSlotsPerResponse: STREAMING_SLOT_MAX_PER_RESPONSE,\n\ttimeoutMs: STREAMING_SLOT_TIMEOUT_MS\n};\n\nconst clonePolicy = (\n\tpolicy: StreamingSlotPolicyValue\n): StreamingSlotPolicyValue => ({\n\t...policy\n});\n\nconst normalizeSlotBytes = (value: unknown, fallback: number) => {\n\tif (typeof value === 'number' && Number.isFinite(value) && value >= 0) {\n\t\treturn Math.floor(value);\n\t}\n\n\treturn fallback;\n};\n\nconst normalizeSlotText = (value: unknown, fallback: string) => {\n\tconst normalizedValue = normalizeSafeHtml(value);\n\n\treturn typeof normalizedValue === 'string' ? normalizedValue : fallback;\n};\nconst normalizeSlotError = (\n\tvalue: unknown,\n\tfallback: string | undefined = undefined\n) => {\n\tconst safeValue = normalizeSafeHtml(value);\n\tif (typeof safeValue === 'string') return safeValue;\n\n\treturn fallback;\n};\nconst hasPolicyValue = (\n\tpolicy: StreamingSlotPolicy,\n\tkey: keyof StreamingSlotPolicy\n) => Object.prototype.hasOwnProperty.call(policy, key);\n\nconst applyStreamingSlotPolicyOverrides = (\n\tbase: StreamingSlotPolicyValue,\n\toverridePolicy: StreamingSlotPolicy = {}\n) => ({\n\terrorHtml: hasPolicyValue(overridePolicy, 'errorHtml')\n\t\t? normalizeSlotError(overridePolicy.errorHtml)\n\t\t: base.errorHtml,\n\tfallbackHtml: hasPolicyValue(overridePolicy, 'fallbackHtml')\n\t\t? normalizeSlotText(overridePolicy.fallbackHtml, '')\n\t\t: base.fallbackHtml,\n\tmaxSlotHtmlSizeBytes: hasPolicyValue(overridePolicy, 'maxSlotHtmlSizeBytes')\n\t\t? normalizeSlotBytes(\n\t\t\t\toverridePolicy.maxSlotHtmlSizeBytes,\n\t\t\t\tbase.maxSlotHtmlSizeBytes\n\t\t\t)\n\t\t: base.maxSlotHtmlSizeBytes,\n\tmaxSlotsPerResponse: hasPolicyValue(overridePolicy, 'maxSlotsPerResponse')\n\t\t? normalizeSlotBytes(\n\t\t\t\toverridePolicy.maxSlotsPerResponse,\n\t\t\t\tbase.maxSlotsPerResponse\n\t\t\t)\n\t\t: base.maxSlotsPerResponse,\n\tonError: hasPolicyValue(overridePolicy, 'onError')\n\t\t? overridePolicy.onError\n\t\t: base.onError,\n\tonSlotMetric: hasPolicyValue(overridePolicy, 'onSlotMetric')\n\t\t? overridePolicy.onSlotMetric\n\t\t: base.onSlotMetric,\n\ttimeoutMs: hasPolicyValue(overridePolicy, 'timeoutMs')\n\t\t? normalizeSlotBytes(overridePolicy.timeoutMs, base.timeoutMs)\n\t\t: base.timeoutMs\n});\n\nconst createCombinedSlotErrorHandler = (\n\tpolicyOnError?: SlotErrorHandler,\n\tenhancerOnError?: SlotErrorHandler\n) => {\n\tif (!policyOnError && !enhancerOnError) return undefined;\n\n\treturn (error: unknown, slot: StreamingSlot) => {\n\t\tpolicyOnError?.(error, slot);\n\t\tenhancerOnError?.(error, slot);\n\t};\n};\n\nconst createCombinedSlotMetricHandler = (\n\tpolicyOnSlotMetric?: StreamingSlotMetricHandler,\n\tcallOnSlotMetric?: StreamingSlotMetricHandler\n) => {\n\tif (!policyOnSlotMetric && !callOnSlotMetric) return undefined;\n\n\treturn (metric: StreamingSlotMetric) => {\n\t\tpolicyOnSlotMetric?.(metric);\n\t\tcallOnSlotMetric?.(metric);\n\t};\n};\n\nconst resolveStreamingSlotPolicy = (\n\toverridePolicy: StreamingSlotPolicy = {}\n) => {\n\tconst base = getStreamingSlotPolicy();\n\n\treturn applyStreamingSlotPolicyOverrides(base, overridePolicy);\n};\n\nexport const getStreamingSlotPolicy = () =>\n\tclonePolicy(currentStreamingSlotPolicy);\n\nexport const setStreamingSlotPolicy = (policy: StreamingSlotPolicy = {}) => {\n\tconst base = getStreamingSlotPolicy();\n\n\tcurrentStreamingSlotPolicy = applyStreamingSlotPolicyOverrides(\n\t\tbase,\n\t\tpolicy\n\t);\n};\n\nexport const withStreamingSlotPolicy = async <T>(\n\tpolicy: StreamingSlotPolicy,\n\tcallback: () => Promise<T> | T\n) => {\n\tconst previous = getStreamingSlotPolicy();\n\n\tsetStreamingSlotPolicy(policy);\n\ttry {\n\t\treturn await callback();\n\t} finally {\n\t\tcurrentStreamingSlotPolicy = previous;\n\t}\n};\n\nconst emitSlotMetric = (\n\tmetric: StreamingSlotMetric,\n\tonSlotMetric?: StreamingSlotMetricHandler\n) => {\n\tonSlotMetric?.(metric);\n};\n\nconst createTimeoutError = (slot: StreamingSlot, timeoutMs: number) => {\n\tconst error = Object.assign(\n\t\tnew Error(`Streaming slot \"${slot.id}\" timed out after ${timeoutMs}ms`),\n\t\t{ __absTimeout: true }\n\t);\n\n\treturn error;\n};\n\nconst isSlotPatchPayloadObject = (\n\tvalue: unknown\n): value is Record<string, unknown> & { html: unknown } =>\n\tisRecord(value) && 'html' in value;\n\nconst isTimeoutError = (\n\terror: unknown\n): error is Error & { __absTimeout: true } =>\n\tisRecord(error) && error.__absTimeout === true;\n\nconst toStreamingSlot = (\n\tslot: DeferredStreamingSlot,\n\tpolicy: StreamingSlotPolicyValue\n): StreamingSlot => ({\n\terrorHtml: slot.errorHtml === undefined ? policy.errorHtml : slot.errorHtml,\n\tfallbackHtml: normalizeSlotText(slot.fallbackHtml, policy.fallbackHtml),\n\tid: slot.id ?? createStreamingSlotId(),\n\tresolve: slot.resolve,\n\ttimeoutMs: normalizeSlotBytes(slot.timeoutMs, policy.timeoutMs)\n});\n\nconst prepareSlots = ({\n\tpolicy,\n\tslots,\n\tonError,\n\tonSlotMetric\n}: {\n\tpolicy: StreamingSlotPolicyValue;\n\tslots: DeferredStreamingSlot[];\n\tonError?: SlotErrorHandler;\n\tonSlotMetric?: StreamingSlotMetricHandler;\n}) => {\n\tconst preparedSlots = slots.map((slot) => toStreamingSlot(slot, policy));\n\tconst emitPreparedSlotMetric = (slot: StreamingSlot) => {\n\t\temitSlotMetric(\n\t\t\t{\n\t\t\t\tslotId: slot.id,\n\t\t\t\ttype: 'prepared'\n\t\t\t},\n\t\t\tonSlotMetric\n\t\t);\n\t};\n\tconst dropPreparedSlot = (slot: StreamingSlot, reason: string) => {\n\t\tonError?.(new Error(reason), slot);\n\t\temitSlotMetric(\n\t\t\t{\n\t\t\t\treason,\n\t\t\t\tslotId: slot.id,\n\t\t\t\ttype: 'dropped'\n\t\t\t},\n\t\t\tonSlotMetric\n\t\t);\n\t};\n\n\tconst { maxSlotsPerResponse } = policy;\n\tif (maxSlotsPerResponse === 0) {\n\t\tpreparedSlots.forEach((slot) =>\n\t\t\tdropPreparedSlot(slot, 'maxSlotsPerResponse is 0')\n\t\t);\n\n\t\treturn [];\n\t}\n\n\tif (preparedSlots.length <= maxSlotsPerResponse) {\n\t\tpreparedSlots.forEach(emitPreparedSlotMetric);\n\n\t\treturn preparedSlots;\n\t}\n\n\tconst keptSlots = preparedSlots.slice(0, maxSlotsPerResponse);\n\tconst droppedSlots = preparedSlots.slice(maxSlotsPerResponse);\n\tdroppedSlots.forEach((slot) => {\n\t\tdropPreparedSlot(\n\t\t\tslot,\n\t\t\t`Streaming slot \"${slot.id}\" dropped because ${maxSlotsPerResponse} slots is the configured maximum`\n\t\t);\n\t});\n\tkeptSlots.forEach(emitPreparedSlotMetric);\n\n\treturn keptSlots;\n};\n\nconst htmlByteLength = (value: string, encoder: TextEncoder) =>\n\tencoder.encode(value).length;\n\ntype ResolvedStreamingSlot = {\n\tpayload: StreamingSlotPatchPayload | null;\n\tid: string;\n\tdurationMs: number;\n\tbytes: number;\n};\n\nconst normalizeSlotPatchPayload = (value: unknown) => {\n\tconst safeValue = normalizeSafeHtml(value);\n\tif (\n\t\tisSlotPatchPayloadObject(safeValue) &&\n\t\ttypeof safeValue.html === 'string'\n\t) {\n\t\treturn {\n\t\t\t...safeValue,\n\t\t\thtml: normalizeSlotText(safeValue.html, '')\n\t\t};\n\t}\n\n\treturn typeof safeValue === 'string' ? safeValue : `${safeValue}`;\n};\n\nconst getPayloadHtml = (payload: StreamingSlotPatchPayload) =>\n\ttypeof payload === 'string' ? payload : payload.html;\n\nconst enqueueEncodedText = (\n\tcontroller: ReadableStreamDefaultController<Uint8Array>,\n\tencoder: TextEncoder,\n\tvalue: string\n) => {\n\tif (value.length === 0) {\n\t\treturn;\n\t}\n\n\tcontroller.enqueue(encoder.encode(value));\n};\n\nconst readStreamingRuntimeChunk = async (\n\treader: ReadableStreamDefaultReader<string | Uint8Array>\n) => {\n\tconst { done, value } = await reader.read();\n\tif (done || !value) {\n\t\treturn { done, value: undefined };\n\t}\n\n\treturn { done, value };\n};\n\nconst applyBaseWinnerState = (\n\tstate: {\n\t\tbaseDone: boolean;\n\t\tbaseRead: StreamReadPromise;\n\t\tfooter: string;\n\t\thandled: boolean;\n\t\ttail: string;\n\t},\n\twinner:\n\t\t| {\n\t\t\t\tdone: boolean;\n\t\t\t\tkind: 'base';\n\t\t\t\tvalue?: string | Uint8Array;\n\t\t }\n\t\t| {\n\t\t\t\tkind: 'slot';\n\t\t\t\toriginal: Promise<{\n\t\t\t\t\tpayload: StreamingSlotPatchPayload | null;\n\t\t\t\t\tid: string;\n\t\t\t\t\tdurationMs: number;\n\t\t\t\t\tbytes: number;\n\t\t\t\t}>;\n\t\t\t\tresult: {\n\t\t\t\t\tpayload: StreamingSlotPatchPayload | null;\n\t\t\t\t\tid: string;\n\t\t\t\t\tdurationMs: number;\n\t\t\t\t\tbytes: number;\n\t\t\t\t};\n\t\t },\n\thandleResolved: (winner: {\n\t\tkind: 'slot';\n\t\toriginal: Promise<{\n\t\t\tpayload: StreamingSlotPatchPayload | null;\n\t\t\tid: string;\n\t\t\tdurationMs: number;\n\t\t\tbytes: number;\n\t\t}>;\n\t\tresult: {\n\t\t\tpayload: StreamingSlotPatchPayload | null;\n\t\t\tid: string;\n\t\t\tdurationMs: number;\n\t\t\tbytes: number;\n\t\t};\n\t}) => void\n) => {\n\tif (!state.handled && winner.kind === 'slot') {\n\t\thandleResolved(winner);\n\t}\n\n\treturn state;\n};\n\nconst resolveOversizedSlotPayload = (input: {\n\tencoder: TextEncoder;\n\thtml: string;\n\tmaxSlotHtmlSizeBytes: number;\n\tonError?: SlotErrorHandler;\n\tonSlotMetric?: StreamingSlotMetricHandler;\n\tslot: StreamingSlot;\n\tstart: number;\n}) => {\n\tconst {\n\t\tencoder,\n\t\thtml,\n\t\tmaxSlotHtmlSizeBytes,\n\t\tonError,\n\t\tonSlotMetric,\n\t\tslot,\n\t\tstart\n\t} = input;\n\tconst bytes = htmlByteLength(html, encoder);\n\tif (bytes <= maxSlotHtmlSizeBytes) {\n\t\treturn null;\n\t}\n\n\tconst error = new Error(\n\t\t`Streaming slot \"${slot.id}\" exceeded max payload size of ${maxSlotHtmlSizeBytes} bytes`\n\t);\n\tconst durationMs = Date.now() - start;\n\tonError?.(error, slot);\n\temitSlotMetric(\n\t\t{\n\t\t\tbytes,\n\t\t\tdurationMs,\n\t\t\terror,\n\t\t\tslotId: slot.id,\n\t\t\ttype: 'size_exceeded'\n\t\t},\n\t\tonSlotMetric\n\t);\n\n\tconst fallbackHtml = normalizeSlotError(slot.errorHtml, undefined);\n\n\treturn {\n\t\tbytes:\n\t\t\tfallbackHtml === undefined\n\t\t\t\t? 0\n\t\t\t\t: htmlByteLength(fallbackHtml, encoder),\n\t\tdurationMs,\n\t\tid: slot.id,\n\t\tpayload: fallbackHtml === undefined ? null : fallbackHtml\n\t};\n};\n\nconst raceWithTimeout = (promise: Promise<unknown>, slot: StreamingSlot) => {\n\tconst { timeoutMs } = slot;\n\tif (typeof timeoutMs !== 'number' || timeoutMs <= 0) {\n\t\treturn promise;\n\t}\n\n\tconst { promise: timeoutPromise, reject } =\n\t\tPromise.withResolvers<StreamingSlotPatchPayload>();\n\n\tsetTimeout(() => {\n\t\treject(createTimeoutError(slot, timeoutMs));\n\t}, timeoutMs);\n\n\treturn Promise.race([promise, timeoutPromise]);\n};\n\nconst resolveSlot = async (\n\tslot: StreamingSlot,\n\tonError?: SlotErrorHandler,\n\tpolicy?: StreamingSlotPolicyValue,\n\tonSlotMetric?: StreamingSlotMetricHandler\n) => {\n\tconst safePolicy = policy ?? getStreamingSlotPolicy();\n\tconst encoder = new TextEncoder();\n\tconst start = Date.now();\n\ttry {\n\t\tconst maybeAsyncValue = Promise.resolve(slot.resolve());\n\t\tconst resolved = await raceWithTimeout(maybeAsyncValue, slot);\n\t\tconst payload = normalizeSlotPatchPayload(resolved);\n\t\tconst html = getPayloadHtml(payload);\n\t\tconst oversizedResult =\n\t\t\tsafePolicy.maxSlotHtmlSizeBytes > 0\n\t\t\t\t? resolveOversizedSlotPayload({\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\thtml,\n\t\t\t\t\t\tmaxSlotHtmlSizeBytes: safePolicy.maxSlotHtmlSizeBytes,\n\t\t\t\t\t\tonError,\n\t\t\t\t\t\tonSlotMetric,\n\t\t\t\t\t\tslot,\n\t\t\t\t\t\tstart\n\t\t\t\t\t})\n\t\t\t\t: null;\n\t\tif (oversizedResult) {\n\t\t\treturn oversizedResult;\n\t\t}\n\t\tconst durationMs = Date.now() - start;\n\t\tconst bytes = htmlByteLength(html, encoder);\n\t\temitSlotMetric(\n\t\t\t{\n\t\t\t\tbytes,\n\t\t\t\tdurationMs,\n\t\t\t\tslotId: slot.id,\n\t\t\t\ttype: 'resolved'\n\t\t\t},\n\t\t\tonSlotMetric\n\t\t);\n\n\t\treturn {\n\t\t\tbytes,\n\t\t\tdurationMs,\n\t\t\tid: slot.id,\n\t\t\tpayload\n\t\t};\n\t} catch (error) {\n\t\tconst durationMs = Date.now() - start;\n\t\tonError?.(error, slot);\n\t\temitSlotMetric(\n\t\t\t{\n\t\t\t\tdurationMs,\n\t\t\t\terror,\n\t\t\t\tslotId: slot.id,\n\t\t\t\ttype: isTimeoutError(error) ? 'timeout' : 'error'\n\t\t\t},\n\t\t\tonSlotMetric\n\t\t);\n\t\tconst html = normalizeSlotError(slot.errorHtml, undefined);\n\t\tif (html) {\n\t\t\treturn {\n\t\t\t\tbytes: htmlByteLength(html, encoder),\n\t\t\t\tdurationMs,\n\t\t\t\tid: slot.id,\n\t\t\t\tpayload: html\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tbytes: 0,\n\t\t\tdurationMs,\n\t\t\tid: slot.id,\n\t\t\tpayload: null\n\t\t};\n\t}\n};\n\nconst nextResolvedSlot = async (\n\tpending: Array<Promise<ResolvedStreamingSlot>>\n) => {\n\tconst wrapped = pending.map((promise) =>\n\t\tpromise.then((result) => ({\n\t\t\toriginal: promise,\n\t\t\tresult\n\t\t}))\n\t);\n\n\treturn Promise.race(wrapped);\n};\n\nconst streamChunkToString = (\n\tvalue: string | Uint8Array,\n\tdecoder: TextDecoder\n) =>\n\ttypeof value === 'string' ? value : decoder.decode(value, { stream: true });\n\nexport const appendStreamingSlotPatchesToStream = (\n\tstream: ReadableStream<string | Uint8Array>,\n\tslots: DeferredStreamingSlot[] = [],\n\t{\n\t\tinjectRuntime = true,\n\t\tnonce,\n\t\tonError,\n\t\tonSlotMetric,\n\t\tpolicy,\n\t\truntimePreludeScript,\n\t\truntimePlacement = 'head'\n\t}: AppendStreamingSlotsOptions = {}\n) => {\n\tconst resolvedPolicy = resolveStreamingSlotPolicy(policy);\n\tconst combinedOnError = createCombinedSlotErrorHandler(\n\t\tresolvedPolicy.onError,\n\t\tonError\n\t);\n\tconst combinedOnSlotMetric = createCombinedSlotMetricHandler(\n\t\tresolvedPolicy.onSlotMetric,\n\t\tonSlotMetric\n\t);\n\tconst effectivePolicy: StreamingSlotPolicyValue = {\n\t\t...resolvedPolicy,\n\t\tonSlotMetric: combinedOnSlotMetric\n\t};\n\tconst preparedSlots = prepareSlots({\n\t\tonError: combinedOnError,\n\t\tonSlotMetric: combinedOnSlotMetric,\n\t\tpolicy: effectivePolicy,\n\t\tslots\n\t});\n\tif (preparedSlots.length === 0) return stream;\n\n\tconst source = injectRuntime\n\t\t? injectStreamingRuntimeIntoStream(\n\t\t\t\tstream,\n\t\t\t\tnonce,\n\t\t\t\truntimePlacement,\n\t\t\t\truntimePreludeScript\n\t\t\t)\n\t\t: stream;\n\tconst encoder = new TextEncoder();\n\tconst decoder = new TextDecoder();\n\tconst reader = source.getReader();\n\tconst pending: Array<Promise<ResolvedStreamingSlot>> = preparedSlots.map(\n\t\t(slot) =>\n\t\t\tresolveSlot(\n\t\t\t\tslot,\n\t\t\t\tcombinedOnError,\n\t\t\t\teffectivePolicy,\n\t\t\t\tcombinedOnSlotMetric\n\t\t\t)\n\t);\n\tconst createRaceCandidates = (\n\t\tbaseDone: boolean,\n\t\tbaseRead: StreamReadPromise\n\t) => {\n\t\tconst racers: Array<\n\t\t\tPromise<\n\t\t\t\t| {\n\t\t\t\t\t\tdone: boolean;\n\t\t\t\t\t\tkind: 'base';\n\t\t\t\t\t\tvalue?: string | Uint8Array;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\tkind: 'slot';\n\t\t\t\t\t\toriginal: Promise<{\n\t\t\t\t\t\t\tpayload: StreamingSlotPatchPayload | null;\n\t\t\t\t\t\t\tid: string;\n\t\t\t\t\t\t\tdurationMs: number;\n\t\t\t\t\t\t\tbytes: number;\n\t\t\t\t\t\t}>;\n\t\t\t\t\t\tresult: {\n\t\t\t\t\t\t\tpayload: StreamingSlotPatchPayload | null;\n\t\t\t\t\t\t\tid: string;\n\t\t\t\t\t\t\tdurationMs: number;\n\t\t\t\t\t\t\tbytes: number;\n\t\t\t\t\t\t};\n\t\t\t\t }\n\t\t\t>\n\t\t> = [];\n\n\t\tif (!baseDone) {\n\t\t\tracers.push(\n\t\t\t\tbaseRead.then(({ done, value }) => ({\n\t\t\t\t\tdone,\n\t\t\t\t\tkind: 'base' as const,\n\t\t\t\t\tvalue\n\t\t\t\t}))\n\t\t\t);\n\t\t}\n\t\tif (pending.length > 0) {\n\t\t\tracers.push(\n\t\t\t\tnextResolvedSlot(pending).then((resolved) => ({\n\t\t\t\t\tkind: 'slot' as const,\n\t\t\t\t\t...resolved\n\t\t\t\t}))\n\t\t\t);\n\t\t}\n\n\t\treturn racers;\n\t};\n\tconst flushTailLookbehind = (\n\t\tcontroller: ReadableStreamDefaultController<Uint8Array>,\n\t\ttail: string\n\t) => {\n\t\tif (tail.length <= STREAM_TAIL_LOOKBEHIND) {\n\t\t\treturn tail;\n\t\t}\n\n\t\tconst content = tail.slice(0, tail.length - STREAM_TAIL_LOOKBEHIND);\n\t\tcontroller.enqueue(encoder.encode(content));\n\n\t\treturn tail.slice(-STREAM_TAIL_LOOKBEHIND);\n\t};\n\tconst finalizeCompletedBaseWinner = (\n\t\tcontroller: ReadableStreamDefaultController<Uint8Array>,\n\t\tdecodedTail: string,\n\t\tbaseRead: StreamReadPromise\n\t) => {\n\t\tconst footerStart = decodedTail.search(CLOSING_PAGE_TAG_REGEX);\n\t\tif (footerStart < 0) {\n\t\t\tenqueueEncodedText(controller, encoder, decodedTail);\n\n\t\t\treturn {\n\t\t\t\tbaseDone: true,\n\t\t\t\tbaseRead,\n\t\t\t\tfooter: '',\n\t\t\t\thandled: true,\n\t\t\t\ttail: ''\n\t\t\t};\n\t\t}\n\n\t\tconst content = decodedTail.slice(0, footerStart);\n\t\tconst nextFooter = decodedTail.slice(footerStart);\n\t\tenqueueEncodedText(controller, encoder, content);\n\n\t\treturn {\n\t\t\tbaseDone: true,\n\t\t\tbaseRead,\n\t\t\tfooter: nextFooter,\n\t\t\thandled: true,\n\t\t\ttail: ''\n\t\t};\n\t};\n\tconst handleBaseWinner = (\n\t\tcontroller: ReadableStreamDefaultController<Uint8Array>,\n\t\twinner:\n\t\t\t| {\n\t\t\t\t\tdone: boolean;\n\t\t\t\t\tkind: 'base';\n\t\t\t\t\tvalue?: string | Uint8Array;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tkind: 'slot';\n\t\t\t\t\toriginal: Promise<{\n\t\t\t\t\t\tpayload: StreamingSlotPatchPayload | null;\n\t\t\t\t\t\tid: string;\n\t\t\t\t\t\tdurationMs: number;\n\t\t\t\t\t\tbytes: number;\n\t\t\t\t\t}>;\n\t\t\t\t\tresult: {\n\t\t\t\t\t\tpayload: StreamingSlotPatchPayload | null;\n\t\t\t\t\t\tid: string;\n\t\t\t\t\t\tdurationMs: number;\n\t\t\t\t\t\tbytes: number;\n\t\t\t\t\t};\n\t\t\t },\n\t\tbaseRead: StreamReadPromise,\n\t\ttail: string,\n\t\tfooter: string\n\t) => {\n\t\tif (winner.kind !== 'base') {\n\t\t\treturn { baseDone: false, baseRead, footer, handled: false, tail };\n\t\t}\n\n\t\tif (winner.done) {\n\t\t\treturn finalizeCompletedBaseWinner(\n\t\t\t\tcontroller,\n\t\t\t\ttail + decoder.decode(),\n\t\t\t\tbaseRead\n\t\t\t);\n\t\t}\n\n\t\tif (!winner.value) {\n\t\t\treturn { baseDone: false, baseRead, footer, handled: true, tail };\n\t\t}\n\n\t\tconst nextTail = flushTailLookbehind(\n\t\t\tcontroller,\n\t\t\ttail + streamChunkToString(winner.value, decoder)\n\t\t);\n\n\t\treturn {\n\t\t\tbaseDone: false,\n\t\t\tbaseRead: reader.read(),\n\t\t\tfooter,\n\t\t\thandled: true,\n\t\t\ttail: nextTail\n\t\t};\n\t};\n\tconst handleResolvedSlot = (\n\t\tcontroller: ReadableStreamDefaultController<Uint8Array>,\n\t\twinner: {\n\t\t\tkind: 'slot';\n\t\t\toriginal: Promise<{\n\t\t\t\tpayload: StreamingSlotPatchPayload | null;\n\t\t\t\tid: string;\n\t\t\t\tdurationMs: number;\n\t\t\t\tbytes: number;\n\t\t\t}>;\n\t\t\tresult: {\n\t\t\t\tpayload: StreamingSlotPatchPayload | null;\n\t\t\t\tid: string;\n\t\t\t\tdurationMs: number;\n\t\t\t\tbytes: number;\n\t\t\t};\n\t\t}\n\t) => {\n\t\tconst index = pending.indexOf(winner.original);\n\t\tif (index >= 0) pending.splice(index, 1);\n\t\tif (winner.result.payload === null) {\n\t\t\treturn;\n\t\t}\n\n\t\temitSlotMetric(\n\t\t\t{\n\t\t\t\tbytes: winner.result.bytes,\n\t\t\t\tdurationMs: winner.result.durationMs,\n\t\t\t\tslotId: winner.result.id,\n\t\t\t\ttype: 'patched'\n\t\t\t},\n\t\t\tcombinedOnSlotMetric\n\t\t);\n\n\t\tcontroller.enqueue(\n\t\t\tencoder.encode(\n\t\t\t\trenderStreamingSlotPatchTag(\n\t\t\t\t\twinner.result.id,\n\t\t\t\t\twinner.result.payload,\n\t\t\t\t\tnonce\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t};\n\n\tconst runPatchedStreamLoop = async (\n\t\tcontroller: ReadableStreamDefaultController<Uint8Array>\n\t) => {\n\t\tlet baseDone = false;\n\t\tlet baseRead = reader.read();\n\t\tlet tail = '';\n\t\tlet footer = '';\n\t\tconst readNextRaceWinner = async () => {\n\t\t\tconst racers = createRaceCandidates(baseDone, baseRead);\n\t\t\tif (racers.length === 0) {\n\t\t\t\treturn footer;\n\t\t\t}\n\n\t\t\tconst winner = await Promise.race(racers);\n\t\t\tconst baseWinnerState = applyBaseWinnerState(\n\t\t\t\thandleBaseWinner(controller, winner, baseRead, tail, footer),\n\t\t\t\twinner,\n\t\t\t\t(slotWinner) => {\n\t\t\t\t\thandleResolvedSlot(controller, slotWinner);\n\t\t\t\t}\n\t\t\t);\n\t\t\t({ baseDone, baseRead, footer, tail } = baseWinnerState);\n\t\t\tif (baseDone && pending.length === 0) {\n\t\t\t\treturn footer;\n\t\t\t}\n\n\t\t\treturn readNextRaceWinner();\n\t\t};\n\n\t\treturn readNextRaceWinner();\n\t};\n\n\treturn new ReadableStream<Uint8Array>({\n\t\tasync start(controller) {\n\t\t\ttry {\n\t\t\t\tconst footer = await runPatchedStreamLoop(controller);\n\t\t\t\tenqueueEncodedText(controller, encoder, footer);\n\t\t\t\tcontroller.close();\n\t\t\t} catch (error) {\n\t\t\t\tcontroller.error(error);\n\t\t\t}\n\t\t}\n\t});\n};\nexport const injectStreamingRuntimeIntoStream = (\n\tstream: ReadableStream<string | Uint8Array>,\n\tnonce?: string,\n\truntimePlacement: 'body' | 'head' = 'head',\n\truntimePreludeScript?: string\n) => {\n\tconst runtimeTag = renderStreamingSlotsRuntimeTag(\n\t\tnonce,\n\t\truntimePreludeScript\n\t);\n\tconst encoder = new TextEncoder();\n\tconst decoder = new TextDecoder();\n\tconst closingTag =\n\t\truntimePlacement === 'body' ? CLOSING_BODY_TAG : CLOSING_HEAD_TAG;\n\tconst lookbehind =\n\t\t(runtimePlacement === 'body'\n\t\t\t? CLOSING_BODY_TAG_LENGTH\n\t\t\t: CLOSING_HEAD_TAG_LENGTH) - 1;\n\tconst flushRuntimeLookbehind = (\n\t\tcontroller: ReadableStreamDefaultController<Uint8Array>,\n\t\tpending: string\n\t) => {\n\t\tif (pending.length <= lookbehind) {\n\t\t\treturn pending;\n\t\t}\n\n\t\tconst safeText = pending.slice(0, pending.length - lookbehind);\n\t\tcontroller.enqueue(encoder.encode(safeText));\n\n\t\treturn pending.slice(-lookbehind);\n\t};\n\tconst injectRuntimeIntoPending = (pending: string) =>\n\t\truntimePlacement === 'body'\n\t\t\t? injectHtmlIntoBody(pending, runtimeTag)\n\t\t\t: injectHtmlIntoHead(pending, runtimeTag);\n\tconst processRuntimePending = (\n\t\tcontroller: ReadableStreamDefaultController<Uint8Array>,\n\t\tpending: string,\n\t\tinjected: boolean\n\t) => {\n\t\tif (injected) {\n\t\t\tcontroller.enqueue(encoder.encode(pending));\n\n\t\t\treturn { injected, pending: '' };\n\t\t}\n\n\t\tconst closingTagIndex = pending.indexOf(closingTag);\n\t\tif (closingTagIndex >= 0) {\n\t\t\tconst withRuntime = `${pending.slice(0, closingTagIndex)}${runtimeTag}${pending.slice(closingTagIndex)}`;\n\t\t\tcontroller.enqueue(encoder.encode(withRuntime));\n\n\t\t\treturn { injected: true, pending: '' };\n\t\t}\n\n\t\treturn {\n\t\t\tinjected,\n\t\t\tpending: flushRuntimeLookbehind(controller, pending)\n\t\t};\n\t};\n\n\treturn new ReadableStream<Uint8Array>({\n\t\tasync start(controller) {\n\t\t\tconst reader = stream.getReader();\n\t\t\tlet injected = false;\n\t\t\tlet pending = '';\n\t\t\tconst enqueuePending = () =>\n\t\t\t\tenqueueEncodedText(controller, encoder, pending);\n\t\t\tconst consumeRuntimeChunk = async () => {\n\t\t\t\tconst { done, value } = await readStreamingRuntimeChunk(reader);\n\t\t\t\tif (done || !value) {\n\t\t\t\t\treturn done;\n\t\t\t\t}\n\n\t\t\t\tpending += streamChunkToString(value, decoder);\n\t\t\t\t({ injected, pending } = processRuntimePending(\n\t\t\t\t\tcontroller,\n\t\t\t\t\tpending,\n\t\t\t\t\tinjected\n\t\t\t\t));\n\n\t\t\t\treturn false;\n\t\t\t};\n\n\t\t\tconst runRuntimeInjectionLoop = async () => {\n\t\t\t\tconst done = await consumeRuntimeChunk();\n\t\t\t\tif (done) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tawait runRuntimeInjectionLoop();\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\tawait runRuntimeInjectionLoop();\n\n\t\t\t\tpending += decoder.decode();\n\t\t\t\tpending = injected\n\t\t\t\t\t? pending\n\t\t\t\t\t: injectRuntimeIntoPending(pending);\n\t\t\t\tenqueuePending();\n\t\t\t\tcontroller.close();\n\t\t\t} catch (error) {\n\t\t\t\tcontroller.error(error);\n\t\t\t}\n\t\t}\n\t});\n};\nexport const streamOutOfOrderSlots = ({\n\tfooterHtml = '',\n\theaderHtml = '',\n\tnonce,\n\tpolicy,\n\tonSlotMetric,\n\tonError,\n\tslots\n}: StreamOutOfOrderSlotsOptions) => {\n\tconst resolvedPolicy = resolveStreamingSlotPolicy(policy);\n\tconst combinedOnError = createCombinedSlotErrorHandler(\n\t\tresolvedPolicy.onError,\n\t\tonError\n\t);\n\tconst combinedOnSlotMetric = createCombinedSlotMetricHandler(\n\t\tresolvedPolicy.onSlotMetric,\n\t\tonSlotMetric\n\t);\n\tconst effectivePolicy: StreamingSlotPolicyValue = {\n\t\t...resolvedPolicy,\n\t\tonSlotMetric: combinedOnSlotMetric\n\t};\n\tconst preparedSlots = prepareSlots({\n\t\tonError: combinedOnError,\n\t\tonSlotMetric: combinedOnSlotMetric,\n\t\tpolicy: effectivePolicy,\n\t\tslots\n\t});\n\tconst encoder = new TextEncoder();\n\tconst createPendingSlots = (\n\t\tcontroller: ReadableStreamDefaultController<Uint8Array>\n\t) =>\n\t\tpreparedSlots.map((slot) => {\n\t\t\tconst fallback = renderStreamingSlotPlaceholder(\n\t\t\t\tslot.id,\n\t\t\t\tnormalizeSlotText(slot.fallbackHtml, '')\n\t\t\t);\n\t\t\tcontroller.enqueue(toUint8(fallback, encoder));\n\n\t\t\treturn resolveSlot(\n\t\t\t\tslot,\n\t\t\t\tcombinedOnError,\n\t\t\t\teffectivePolicy,\n\t\t\t\tcombinedOnSlotMetric\n\t\t\t);\n\t\t});\n\tconst handleResolvedPreparedSlot = async (\n\t\tcontroller: ReadableStreamDefaultController<Uint8Array>,\n\t\tpending: Array<\n\t\t\tPromise<{\n\t\t\t\tpayload: StreamingSlotPatchPayload | null;\n\t\t\t\tid: string;\n\t\t\t\tdurationMs: number;\n\t\t\t\tbytes: number;\n\t\t\t}>\n\t\t>\n\t) => {\n\t\tconst { original, result } = await nextResolvedSlot(pending);\n\t\tconst index = pending.indexOf(original);\n\t\tif (index >= 0) pending.splice(index, 1);\n\t\tif (result.payload === null) {\n\t\t\treturn;\n\t\t}\n\n\t\temitSlotMetric(\n\t\t\t{\n\t\t\t\tbytes: result.bytes,\n\t\t\t\tdurationMs: result.durationMs,\n\t\t\t\tslotId: result.id,\n\t\t\t\ttype: 'patched'\n\t\t\t},\n\t\t\tcombinedOnSlotMetric\n\t\t);\n\t\tcontroller.enqueue(\n\t\t\ttoUint8(\n\t\t\t\trenderStreamingSlotPatchTag(result.id, result.payload, nonce),\n\t\t\t\tencoder\n\t\t\t)\n\t\t);\n\t};\n\n\tconst streamPreparedSlots = async (\n\t\tcontroller: ReadableStreamDefaultController<Uint8Array>\n\t) => {\n\t\tconst pending = createPendingSlots(controller);\n\t\tconst streamNextPreparedSlot = async () => {\n\t\t\tif (pending.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait handleResolvedPreparedSlot(controller, pending);\n\n\t\t\tawait streamNextPreparedSlot();\n\t\t};\n\n\t\tawait streamNextPreparedSlot();\n\t};\n\tconst resolveHeaderHtml = () => {\n\t\tconst needsRuntimeTag =\n\t\t\tpreparedSlots.length > 0 &&\n\t\t\t!headerHtml.includes(STREAMING_RUNTIME_GLOBAL);\n\t\tif (!needsRuntimeTag) {\n\t\t\treturn headerHtml;\n\t\t}\n\n\t\treturn injectHtmlIntoHead(\n\t\t\theaderHtml,\n\t\t\trenderStreamingSlotsRuntimeTag(nonce)\n\t\t);\n\t};\n\n\treturn new ReadableStream<Uint8Array>({\n\t\tasync start(controller) {\n\t\t\ttry {\n\t\t\t\tconst header = resolveHeaderHtml();\n\t\t\t\tcontroller.enqueue(toUint8(header, encoder));\n\t\t\t\tawait streamPreparedSlots(controller);\n\n\t\t\t\tenqueueEncodedText(controller, encoder, footer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AC/B,MAAK,CAAC,YAAY;AAAA,MACvB,IAAI;AAAA,QACH,MAAM,SAAS,kBAAkB;AAAA,QACjC,WAAW,QAAQ,QAAQ,QAAQ,OAAO,CAAC;AAAA,QAC3C,MAAM,oBAAoB,UAAU;AAAA,QAEpC,mBAAmB,YAAY,SAAS,UAAU;AAAA,QAClD,WAAW,MAAM;AAAA,QAChB,OAAO,OAAO;AAAA,QACf,WAAW,MAAM,KAAK;AAAA;AAAA;AAAA,EAGzB,CAAC;AAAA;",
|
|
8
|
+
"debugId": "469B6C14F150BF0864756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
disposeTailwindCompiler,
|
|
4
|
+
extractCandidates,
|
|
5
|
+
incrementalTailwindBuild,
|
|
6
|
+
warmTailwindCompiler
|
|
7
|
+
} from "./chunk-kndkjsya.js";
|
|
8
|
+
import"./chunk-6fkgm9s5.js";
|
|
9
|
+
import"./chunk-bmgqm774.js";
|
|
10
|
+
export {
|
|
11
|
+
warmTailwindCompiler,
|
|
12
|
+
incrementalTailwindBuild,
|
|
13
|
+
extractCandidates,
|
|
14
|
+
disposeTailwindCompiler
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//# debugId=9682DA217E0C7A1564756E2164756E21
|
|
18
|
+
//# sourceMappingURL=chunk-smgj0epn.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/dev/transformCache.ts
|
|
3
|
+
var cache = globalThis.__transformCache ?? new Map;
|
|
4
|
+
globalThis.__transformCache = cache;
|
|
5
|
+
var importers = globalThis.__transformImporters ?? new Map;
|
|
6
|
+
globalThis.__transformImporters = importers;
|
|
7
|
+
var getTransformed = (filePath) => cache.get(filePath)?.content;
|
|
8
|
+
var setTransformed = (filePath, content, mtime, imports) => {
|
|
9
|
+
const resolvedImports = imports ?? [];
|
|
10
|
+
cache.set(filePath, { content, imports: resolvedImports, mtime });
|
|
11
|
+
for (const imp of resolvedImports) {
|
|
12
|
+
const set = importers.get(imp) ?? new Set;
|
|
13
|
+
importers.set(imp, set);
|
|
14
|
+
set.add(filePath);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var invalidationVersions = globalThis.__transformInvalidationVersions ?? new Map;
|
|
18
|
+
globalThis.__transformInvalidationVersions = invalidationVersions;
|
|
19
|
+
var isComponentFile = (filePath) => filePath.endsWith(".tsx") || filePath.endsWith(".jsx");
|
|
20
|
+
var processParents = (parents, queue) => {
|
|
21
|
+
const component = [...parents].find(isComponentFile);
|
|
22
|
+
if (component !== undefined)
|
|
23
|
+
return component;
|
|
24
|
+
for (const parent of parents)
|
|
25
|
+
queue.push(parent);
|
|
26
|
+
return;
|
|
27
|
+
};
|
|
28
|
+
var findNearestComponent = (filePath) => {
|
|
29
|
+
const visited = new Set;
|
|
30
|
+
const queue = [filePath];
|
|
31
|
+
while (queue.length > 0) {
|
|
32
|
+
const current = queue.shift();
|
|
33
|
+
if (!current)
|
|
34
|
+
break;
|
|
35
|
+
if (visited.has(current))
|
|
36
|
+
continue;
|
|
37
|
+
visited.add(current);
|
|
38
|
+
const parents = importers.get(current);
|
|
39
|
+
if (!parents)
|
|
40
|
+
continue;
|
|
41
|
+
const found = processParents(parents, queue);
|
|
42
|
+
if (found !== undefined)
|
|
43
|
+
return found;
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
};
|
|
47
|
+
var getInvalidationVersion = (filePath) => invalidationVersions.get(filePath) ?? 0;
|
|
48
|
+
var invalidate = (filePath) => {
|
|
49
|
+
cache.delete(filePath);
|
|
50
|
+
invalidationVersions.set(filePath, (invalidationVersions.get(filePath) ?? 0) + 1);
|
|
51
|
+
for (const parent of importers.get(filePath) ?? []) {
|
|
52
|
+
cache.delete(parent);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var invalidateAll = () => {
|
|
56
|
+
cache.clear();
|
|
57
|
+
importers.clear();
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { getTransformed, setTransformed, findNearestComponent, getInvalidationVersion, invalidate, invalidateAll };
|
|
61
|
+
|
|
62
|
+
//# debugId=D2BA3CC1E79C978F64756E2164756E21
|
|
63
|
+
//# sourceMappingURL=chunk-swrnzs4c.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/dev/transformCache.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"type CacheEntry = {\n\tcontent: string;\n\timports: string[];\n\tmtime: number;\n};\n\n// Persist across bun --hot reloads so HMR doesn't refetch everything\nconst cache = globalThis.__transformCache ?? new Map<string, CacheEntry>();\nglobalThis.__transformCache = cache;\n\n// Reverse map: importedFile → Set<files that import it>\n// Used to cascade invalidation up the import chain.\nconst importers =\n\tglobalThis.__transformImporters ?? new Map<string, Set<string>>();\nglobalThis.__transformImporters = importers;\n\n// Cache entries are invalidated by invalidateModule() when files\n// change — no need to re-stat on every read. If it's in the cache,\n// it's valid.\nexport const getTransformed = (filePath: string) =>\n\tcache.get(filePath)?.content;\n\nexport const setTransformed = (\n\tfilePath: string,\n\tcontent: string,\n\tmtime: number,\n\timports?: string[]\n) => {\n\tconst resolvedImports = imports ?? [];\n\tcache.set(filePath, { content, imports: resolvedImports, mtime });\n\n\t// Update reverse dependency map\n\tfor (const imp of resolvedImports) {\n\t\tconst set = importers.get(imp) ?? new Set<string>();\n\t\timporters.set(imp, set);\n\t\tset.add(filePath);\n\t}\n};\n\n// Per-file invalidation version. Incremented when a file's transform\n// cache is cleared due to a downstream import changing. Used by\n// srcUrl() to force browser re-fetch even if the file's mtime is same.\nconst invalidationVersions =\n\tglobalThis.__transformInvalidationVersions ?? new Map<string, number>();\nglobalThis.__transformInvalidationVersions = invalidationVersions;\n\nconst isComponentFile = (filePath: string) =>\n\tfilePath.endsWith('.tsx') || filePath.endsWith('.jsx');\n\nconst processParents = (parents: Set<string>, queue: string[]) => {\n\tconst component = [...parents].find(isComponentFile);\n\tif (component !== undefined) return component;\n\n\tfor (const parent of parents) queue.push(parent);\n\n\treturn undefined;\n};\n\nexport const findNearestComponent = (filePath: string) => {\n\tconst visited = new Set<string>();\n\tconst queue = [filePath];\n\n\twhile (queue.length > 0) {\n\t\tconst current = queue.shift();\n\t\tif (!current) break;\n\t\tif (visited.has(current)) continue;\n\t\tvisited.add(current);\n\n\t\tconst parents = importers.get(current);\n\t\tif (!parents) continue;\n\n\t\tconst found = processParents(parents, queue);\n\t\tif (found !== undefined) return found;\n\t}\n\n\treturn undefined;\n};\nexport const getInvalidationVersion = (filePath: string) =>\n\tinvalidationVersions.get(filePath) ?? 0;\nexport const invalidate = (filePath: string) => {\n\tcache.delete(filePath);\n\n\t// Bump the CHANGED file's version so when importers are\n\t// re-transpiled, srcUrl() generates a new ?v= for it.\n\tinvalidationVersions.set(\n\t\tfilePath,\n\t\t(invalidationVersions.get(filePath) ?? 0) + 1\n\t);\n\n\t// Clear transform cache for direct importers so they get\n\t// re-transpiled with the changed file's new ?v= param.\n\tfor (const parent of importers.get(filePath) ?? []) {\n\t\tcache.delete(parent);\n\t}\n};\nexport const invalidateAll = () => {\n\tcache.clear();\n\timporters.clear();\n};\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AAOA,IAAM,QAAQ,WAAW,oBAAoB,IAAI;AACjD,WAAW,mBAAmB;AAI9B,IAAM,YACL,WAAW,wBAAwB,IAAI;AACxC,WAAW,uBAAuB;AAK3B,IAAM,iBAAiB,CAAC,aAC9B,MAAM,IAAI,QAAQ,GAAG;AAEf,IAAM,iBAAiB,CAC7B,UACA,SACA,OACA,YACI;AAAA,EACJ,MAAM,kBAAkB,WAAW,CAAC;AAAA,EACpC,MAAM,IAAI,UAAU,EAAE,SAAS,SAAS,iBAAiB,MAAM,CAAC;AAAA,EAGhE,WAAW,OAAO,iBAAiB;AAAA,IAClC,MAAM,MAAM,UAAU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AAO,MAAM;AAAA,EACpB;AAAA;AAEM,IAAM,gBAAgB,MAAM;AAAA,EAClC,MAAM,MAAM;AAAA,EACZ,UAAU,MAAM;AAAA;",
|
|
8
|
+
"debugId": "D2BA3CC1E79C978F64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/core/devVendorPaths.ts
|
|
3
|
+
var devVendorPaths = null;
|
|
4
|
+
var getDevVendorPaths = () => devVendorPaths;
|
|
5
|
+
var setDevVendorPaths = (paths) => {
|
|
6
|
+
devVendorPaths = paths;
|
|
7
|
+
};
|
|
8
|
+
var angularVendorPaths = null;
|
|
9
|
+
var getAngularVendorPaths = () => angularVendorPaths;
|
|
10
|
+
var setAngularVendorPaths = (paths) => {
|
|
11
|
+
angularVendorPaths = paths;
|
|
12
|
+
};
|
|
13
|
+
var svelteVendorPaths = null;
|
|
14
|
+
var getSvelteVendorPaths = () => svelteVendorPaths;
|
|
15
|
+
var setSvelteVendorPaths = (paths) => {
|
|
16
|
+
svelteVendorPaths = paths;
|
|
17
|
+
};
|
|
18
|
+
var vueVendorPaths = null;
|
|
19
|
+
var getVueVendorPaths = () => vueVendorPaths;
|
|
20
|
+
var setVueVendorPaths = (paths) => {
|
|
21
|
+
vueVendorPaths = paths;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { getDevVendorPaths, setDevVendorPaths, getAngularVendorPaths, setAngularVendorPaths, getSvelteVendorPaths, setSvelteVendorPaths, getVueVendorPaths, setVueVendorPaths };
|
|
25
|
+
|
|
26
|
+
//# debugId=B8D7CD29E8493CCD64756E2164756E21
|
|
27
|
+
//# sourceMappingURL=chunk-t81a331y.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/core/devVendorPaths.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/** Module-level dev vendor paths state.\n * Set by devBuild() before the initial build so that build() can\n * externalize React and rewrite imports to stable vendor files.\n * Production builds never call setDevVendorPaths, so the getter\n * returns null and build() bundles React normally. */\n\nlet devVendorPaths: Record<string, string> | null = null;\n\nexport const getDevVendorPaths = () => devVendorPaths;\nexport const setDevVendorPaths = (paths: Record<string, string>) => {\n\tdevVendorPaths = paths;\n};\n\n/** Angular vendor paths — same pattern as React. */\nlet angularVendorPaths: Record<string, string> | null = null;\n\nexport const getAngularVendorPaths = () => angularVendorPaths;\nexport const setAngularVendorPaths = (paths: Record<string, string>) => {\n\tangularVendorPaths = paths;\n};\n\n/** Svelte vendor paths — same pattern as React. */\nlet svelteVendorPaths: Record<string, string> | null = null;\n\nexport const getSvelteVendorPaths = () => svelteVendorPaths;\nexport const setSvelteVendorPaths = (paths: Record<string, string>) => {\n\tsvelteVendorPaths = paths;\n};\n\n/** Vue vendor paths — same pattern as React. */\nlet vueVendorPaths: Record<string, string> | null = null;\n\nexport const getVueVendorPaths = () => vueVendorPaths;\nexport const setVueVendorPaths = (paths: Record<string, string>) => {\n\tvueVendorPaths = paths;\n};\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AAMA,IAAI,iBAAgD;AAE7C,IAAM,oBAAoB,MAAM;AAChC,IAAM,oBAAoB,CAAC,UAAkC;AAAA,EACnE,iBAAiB;AAAA;AAIlB,IAAI,qBAAoD;AAEjD,IAAM,wBAAwB,MAAM;AACpC,IAAM,wBAAwB,CAAC,UAAkC;AAAA,EACvE,qBAAqB;AAAA;AAItB,IAAI,oBAAmD;AAEhD,IAAM,uBAAuB,MAAM;AACnC,IAAM,uBAAuB,CAAC,UAAkC;AAAA,EACtE,oBAAoB;AAAA;AAIrB,IAAI,iBAAgD;AAE7C,IAAM,oBAAoB,MAAM;AAChC,IAAM,oBAAoB,CAAC,UAAkC;AAAA,EACnE,iBAAiB;AAAA;",
|
|
8
|
+
"debugId": "B8D7CD29E8493CCD64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import"./chunk-bmgqm774.js";
|
|
3
|
+
|
|
4
|
+
// src/dev/simpleHTMXHMR.ts
|
|
5
|
+
import { resolve } from "path";
|
|
6
|
+
var handleHTMXUpdate = async (htmxFilePath) => {
|
|
7
|
+
let htmlContent;
|
|
8
|
+
try {
|
|
9
|
+
const resolvedPath = resolve(htmxFilePath);
|
|
10
|
+
const file = Bun.file(resolvedPath);
|
|
11
|
+
if (!await file.exists()) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
htmlContent = await file.text();
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const headMatch = htmlContent.match(/<head[^>]*>([\s\S]*?)<\/head>/i);
|
|
19
|
+
const bodyMatch = htmlContent.match(/<body[^>]*>([\s\S]*)<\/body>/i);
|
|
20
|
+
if (bodyMatch && bodyMatch[1]) {
|
|
21
|
+
return {
|
|
22
|
+
body: bodyMatch[1].trim(),
|
|
23
|
+
head: headMatch && headMatch[1] ? headMatch[1].trim() : null
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return htmlContent;
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
handleHTMXUpdate
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//# debugId=F112B1D267B653D964756E2164756E21
|
|
33
|
+
//# sourceMappingURL=chunk-tfe3sb44.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/dev/simpleHTMXHMR.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/* Simple HTMX HMR Implementation\n Lightweight approach: read HTMX HTML file → send HTML patch */\n\nimport { resolve } from 'node:path';\n\n/* Simple HTMX HMR handler for server-side\n When an HTMX file changes:\n 1. Read the HTML file\n 2. Extract body content (or return full HTML)\n 3. Return the HTML for patching */\nexport const handleHTMXUpdate = async (htmxFilePath: string) => {\n\tlet htmlContent: string;\n\ttry {\n\t\tconst resolvedPath = resolve(htmxFilePath);\n\t\tconst file = Bun.file(resolvedPath);\n\t\tif (!(await file.exists())) {\n\t\t\treturn null;\n\t\t}\n\t\thtmlContent = await file.text();\n\t} catch {\n\t\treturn null;\n\t}\n\n\tconst headMatch = htmlContent.match(/<head[^>]*>([\\s\\S]*?)<\\/head>/i);\n\tconst bodyMatch = htmlContent.match(/<body[^>]*>([\\s\\S]*)<\\/body>/i);\n\n\tif (bodyMatch && bodyMatch[1]) {\n\t\treturn {\n\t\t\tbody: bodyMatch[1].trim(),\n\t\t\thead: headMatch && headMatch[1] ? headMatch[1].trim() : null\n\t\t};\n\t}\n\n\treturn htmlContent;\n};\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;AAGA;AAOO,IAAM,mBAAmB,OAAO,iBAAyB;AAAA,EAC/D,IAAI;AAAA,EACJ,IAAI;AAAA,IACH,MAAM,eAAe,QAAQ,YAAY;AAAA,IACzC,MAAM,OAAO,IAAI,KAAK,YAAY;AAAA,IAClC,IAAI,CAAE,MAAM,KAAK,OAAO,GAAI;AAAA,MAC3B,OAAO;AAAA,IACR;AAAA,IACA,cAAc,MAAM,KAAK,KAAK;AAAA,IAC7B,MAAM;AAAA,IACP,OAAO;AAAA;AAAA,EAGR,MAAM,YAAY,YAAY,MAAM,gCAAgC;AAAA,EACpE,MAAM,YAAY,YAAY,MAAM,+BAA+B;AAAA,EAEnE,IAAI,aAAa,UAAU,IAAI;AAAA,IAC9B,OAAO;AAAA,MACN,MAAM,UAAU,GAAG,KAAK;AAAA,MACxB,MAAM,aAAa,UAAU,KAAK,UAAU,GAAG,KAAK,IAAI;AAAA,IACzD;AAAA,EACD;AAAA,EAEA,OAAO;AAAA;",
|
|
8
|
+
"debugId": "F112B1D267B653D964756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
readIslandStore,
|
|
4
|
+
subscribeIslandStore
|
|
5
|
+
} from "./chunk-fygx2ymm.js";
|
|
6
|
+
|
|
7
|
+
// src/vue/useIslandStore.ts
|
|
8
|
+
import { customRef, onBeforeUnmount } from "vue";
|
|
9
|
+
var useIslandStore = (store, selector) => {
|
|
10
|
+
let current = readIslandStore(store, selector);
|
|
11
|
+
let unsubscribe;
|
|
12
|
+
const state = customRef((track, trigger) => {
|
|
13
|
+
unsubscribe = subscribeIslandStore(store, selector, (value) => {
|
|
14
|
+
current = value;
|
|
15
|
+
trigger();
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
get() {
|
|
19
|
+
track();
|
|
20
|
+
return current;
|
|
21
|
+
},
|
|
22
|
+
set() {}
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
onBeforeUnmount(() => {
|
|
26
|
+
unsubscribe?.();
|
|
27
|
+
});
|
|
28
|
+
return state;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { useIslandStore };
|
|
32
|
+
|
|
33
|
+
//# debugId=91B10F01C4975EE764756E2164756E21
|
|
34
|
+
//# sourceMappingURL=chunk-tx9edm1x.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/vue/useIslandStore.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { customRef, onBeforeUnmount } from 'vue';\nimport type { StoreApi } from 'zustand/vanilla';\nimport {\n\treadIslandStore,\n\tsubscribeIslandStore,\n\ttype IslandStoreState\n} from '../client/islandStore';\n\nexport const useIslandStore = <TState extends IslandStoreState, TSelected>(\n\tstore: StoreApi<TState>,\n\tselector: (state: TState) => TSelected\n) => {\n\tlet current = readIslandStore(store, selector);\n\tlet unsubscribe: (() => void) | undefined;\n\n\tconst state = customRef<TSelected>((track, trigger) => {\n\t\tunsubscribe = subscribeIslandStore(store, selector, (value) => {\n\t\t\tcurrent = value;\n\t\t\ttrigger();\n\t\t});\n\n\t\treturn {\n\t\t\tget() {\n\t\t\t\ttrack();\n\n\t\t\t\treturn current;\n\t\t\t},\n\t\t\tset() {}\n\t\t};\n\t});\n\n\tonBeforeUnmount(() => {\n\t\tunsubscribe?.();\n\t});\n\n\treturn state;\n};\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;AAAA;AAQO,IAAM,iBAAiB,CAC7B,OACA,aACI;AAAA,EACJ,IAAI,UAAU,gBAAgB,OAAO,QAAQ;AAAA,EAC7C,IAAI;AAAA,EAEJ,MAAM,QAAQ,UAAqB,CAAC,OAAO,YAAY;AAAA,IACtD,cAAc,qBAAqB,OAAO,UAAU,CAAC,UAAU;AAAA,MAC9D,UAAU;AAAA,MACV,QAAQ;AAAA,KACR;AAAA,IAED,OAAO;AAAA,MACN,GAAG,GAAG;AAAA,QACL,MAAM;AAAA,QAEN,OAAO;AAAA;AAAA,MAER,GAAG,GAAG;AAAA,IACP;AAAA,GACA;AAAA,EAED,gBAAgB,MAAM;AAAA,IACrB,cAAc;AAAA,GACd;AAAA,EAED,OAAO;AAAA;",
|
|
8
|
+
"debugId": "91B10F01C4975EE764756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
WS_READY_STATE_OPEN,
|
|
4
|
+
isValidHMRClientMessage
|
|
5
|
+
} from "./chunk-h5bbfn3n.js";
|
|
6
|
+
import {
|
|
7
|
+
logHmrUpdate
|
|
8
|
+
} from "./chunk-cbkrwmvh.js";
|
|
9
|
+
|
|
10
|
+
// src/dev/assetStore.ts
|
|
11
|
+
import { resolve } from "path";
|
|
12
|
+
import { readdir, unlink } from "fs/promises";
|
|
13
|
+
var mimeTypes = {
|
|
14
|
+
".css": "text/css",
|
|
15
|
+
".html": "text/html",
|
|
16
|
+
".js": "application/javascript",
|
|
17
|
+
".json": "application/json",
|
|
18
|
+
".mjs": "application/javascript",
|
|
19
|
+
".svg": "image/svg+xml",
|
|
20
|
+
".woff": "font/woff",
|
|
21
|
+
".woff2": "font/woff2"
|
|
22
|
+
};
|
|
23
|
+
var getMimeType = (filePath) => {
|
|
24
|
+
const ext = filePath.slice(filePath.lastIndexOf("."));
|
|
25
|
+
return mimeTypes[ext] ?? "application/octet-stream";
|
|
26
|
+
};
|
|
27
|
+
var HASHED_FILE_RE = /\.[a-z0-9]{8}\.(js|css|mjs)$/;
|
|
28
|
+
var stripHash = (webPath) => webPath.replace(/\.[a-z0-9]{8}(\.(js|css|mjs))$/, "$1");
|
|
29
|
+
var processWalkEntry = (entry, dir, liveByIdentity, walkAndClean) => {
|
|
30
|
+
const fullPath = resolve(dir, entry.name);
|
|
31
|
+
if (entry.isDirectory()) {
|
|
32
|
+
return walkAndClean(fullPath);
|
|
33
|
+
}
|
|
34
|
+
if (!HASHED_FILE_RE.test(entry.name)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const identity = stripHash(fullPath);
|
|
38
|
+
const livePath = liveByIdentity.get(identity);
|
|
39
|
+
if (livePath !== fullPath) {
|
|
40
|
+
return unlink(fullPath).catch(() => {});
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
};
|
|
44
|
+
var cleanStaleAssets = async (store, manifest, buildDir) => {
|
|
45
|
+
const liveByIdentity = new Map;
|
|
46
|
+
for (const webPath of store.keys()) {
|
|
47
|
+
const diskPath = resolve(buildDir, webPath.slice(1));
|
|
48
|
+
liveByIdentity.set(stripHash(diskPath), diskPath);
|
|
49
|
+
}
|
|
50
|
+
const absBuildDir = resolve(buildDir);
|
|
51
|
+
Object.values(manifest).forEach((val) => {
|
|
52
|
+
if (!HASHED_FILE_RE.test(val))
|
|
53
|
+
return;
|
|
54
|
+
if (val.startsWith(absBuildDir)) {
|
|
55
|
+
liveByIdentity.set(stripHash(val), val);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
try {
|
|
59
|
+
const walkAndClean = async (dir) => {
|
|
60
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
61
|
+
const tasks = entries.map((entry) => processWalkEntry(entry, dir, liveByIdentity, walkAndClean)).filter((task) => task !== null);
|
|
62
|
+
await Promise.all(tasks);
|
|
63
|
+
};
|
|
64
|
+
await walkAndClean(buildDir);
|
|
65
|
+
} catch {}
|
|
66
|
+
};
|
|
67
|
+
var lookupAsset = (store, path) => store.get(path);
|
|
68
|
+
var processScanEntry = (entry, dir, prefix, store, scanDir) => {
|
|
69
|
+
if (entry.isDirectory()) {
|
|
70
|
+
return scanDir(resolve(dir, entry.name), `${prefix}${entry.name}/`);
|
|
71
|
+
}
|
|
72
|
+
if (!entry.name.startsWith("chunk-")) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const webPath = `/${prefix}${entry.name}`;
|
|
76
|
+
if (store.has(webPath)) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return Bun.file(resolve(dir, entry.name)).bytes().then((bytes) => {
|
|
80
|
+
store.set(webPath, bytes);
|
|
81
|
+
return;
|
|
82
|
+
}).catch(() => {});
|
|
83
|
+
};
|
|
84
|
+
var populateAssetStore = async (store, manifest, buildDir) => {
|
|
85
|
+
const loadPromises = [];
|
|
86
|
+
const newIdentities = new Map;
|
|
87
|
+
for (const webPath of Object.values(manifest)) {
|
|
88
|
+
if (!webPath.startsWith("/"))
|
|
89
|
+
continue;
|
|
90
|
+
newIdentities.set(stripHash(webPath), webPath);
|
|
91
|
+
}
|
|
92
|
+
const staleKeys = [...store.keys()].filter((existingPath) => {
|
|
93
|
+
if (existingPath.includes("/chunk-"))
|
|
94
|
+
return false;
|
|
95
|
+
const replacement = newIdentities.get(stripHash(existingPath));
|
|
96
|
+
return replacement !== undefined && replacement !== existingPath;
|
|
97
|
+
});
|
|
98
|
+
staleKeys.forEach((key) => store.delete(key));
|
|
99
|
+
for (const webPath of newIdentities.values()) {
|
|
100
|
+
if (store.has(webPath))
|
|
101
|
+
continue;
|
|
102
|
+
loadPromises.push(Bun.file(resolve(buildDir, webPath.slice(1))).bytes().then((bytes) => {
|
|
103
|
+
store.set(webPath, bytes);
|
|
104
|
+
return;
|
|
105
|
+
}).catch(() => {}));
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const scanDir = async (dir, prefix) => {
|
|
109
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
110
|
+
const subTasks = entries.map((entry) => processScanEntry(entry, dir, prefix, store, scanDir)).filter((task) => task !== null);
|
|
111
|
+
await Promise.all(subTasks);
|
|
112
|
+
};
|
|
113
|
+
await scanDir(buildDir, "");
|
|
114
|
+
} catch {}
|
|
115
|
+
await Promise.all(loadPromises);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/dev/moduleVersionTracker.ts
|
|
119
|
+
var globalVersionCounter = 0;
|
|
120
|
+
var createModuleVersionTracker = () => new Map;
|
|
121
|
+
var getNextVersion = () => ++globalVersionCounter;
|
|
122
|
+
var incrementModuleVersion = (versions, modulePath) => {
|
|
123
|
+
const newVersion = getNextVersion();
|
|
124
|
+
versions.set(modulePath, newVersion);
|
|
125
|
+
return newVersion;
|
|
126
|
+
};
|
|
127
|
+
var incrementModuleVersions = (versions, modulePaths) => {
|
|
128
|
+
const updated = new Map;
|
|
129
|
+
for (const path of modulePaths) {
|
|
130
|
+
const version = incrementModuleVersion(versions, path);
|
|
131
|
+
updated.set(path, version);
|
|
132
|
+
}
|
|
133
|
+
return updated;
|
|
134
|
+
};
|
|
135
|
+
var serializeModuleVersions = (versions) => {
|
|
136
|
+
const serialized = {};
|
|
137
|
+
for (const [path, version] of versions.entries()) {
|
|
138
|
+
serialized[path] = version;
|
|
139
|
+
}
|
|
140
|
+
return serialized;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// src/dev/webSocket.ts
|
|
144
|
+
var trySendMessage = (client, messageStr) => {
|
|
145
|
+
try {
|
|
146
|
+
client.send(messageStr);
|
|
147
|
+
return true;
|
|
148
|
+
} catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
var broadcastToClients = (state, message) => {
|
|
153
|
+
const messageStr = JSON.stringify({
|
|
154
|
+
...message,
|
|
155
|
+
timestamp: Date.now()
|
|
156
|
+
});
|
|
157
|
+
const shouldRemove = (client) => {
|
|
158
|
+
if (client.readyState !== WS_READY_STATE_OPEN)
|
|
159
|
+
return true;
|
|
160
|
+
return !trySendMessage(client, messageStr);
|
|
161
|
+
};
|
|
162
|
+
const clientsToRemove = [];
|
|
163
|
+
state.connectedClients.forEach((client) => {
|
|
164
|
+
if (shouldRemove(client))
|
|
165
|
+
clientsToRemove.push(client);
|
|
166
|
+
});
|
|
167
|
+
clientsToRemove.forEach((client) => {
|
|
168
|
+
state.connectedClients.delete(client);
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
var handleClientConnect = (state, client, manifest) => {
|
|
172
|
+
state.connectedClients.add(client);
|
|
173
|
+
const serverVersions = serializeModuleVersions(state.moduleVersions);
|
|
174
|
+
client.send(JSON.stringify({
|
|
175
|
+
data: {
|
|
176
|
+
manifest,
|
|
177
|
+
serverVersions
|
|
178
|
+
},
|
|
179
|
+
timestamp: Date.now(),
|
|
180
|
+
type: "manifest"
|
|
181
|
+
}));
|
|
182
|
+
client.send(JSON.stringify({
|
|
183
|
+
message: "HMR client connected successfully",
|
|
184
|
+
timestamp: Date.now(),
|
|
185
|
+
type: "connected"
|
|
186
|
+
}));
|
|
187
|
+
};
|
|
188
|
+
var handleClientDisconnect = (state, client) => {
|
|
189
|
+
state.connectedClients.delete(client);
|
|
190
|
+
};
|
|
191
|
+
var parseJsonSafe = (raw) => JSON.parse(raw);
|
|
192
|
+
var parseMessage = (message) => {
|
|
193
|
+
if (typeof message === "string") {
|
|
194
|
+
return parseJsonSafe(message);
|
|
195
|
+
}
|
|
196
|
+
if (message instanceof Buffer) {
|
|
197
|
+
return parseJsonSafe(message.toString());
|
|
198
|
+
}
|
|
199
|
+
if (message instanceof ArrayBuffer) {
|
|
200
|
+
return parseJsonSafe(new TextDecoder().decode(new Uint8Array(message)));
|
|
201
|
+
}
|
|
202
|
+
if (ArrayBuffer.isView(message)) {
|
|
203
|
+
const view = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
|
|
204
|
+
return parseJsonSafe(new TextDecoder().decode(view));
|
|
205
|
+
}
|
|
206
|
+
if (typeof message === "object" && message !== null) {
|
|
207
|
+
return message;
|
|
208
|
+
}
|
|
209
|
+
return null;
|
|
210
|
+
};
|
|
211
|
+
var handleParsedMessage = (state, client, data) => {
|
|
212
|
+
switch (data.type) {
|
|
213
|
+
case "ping":
|
|
214
|
+
client.send(JSON.stringify({
|
|
215
|
+
timestamp: Date.now(),
|
|
216
|
+
type: "pong"
|
|
217
|
+
}));
|
|
218
|
+
break;
|
|
219
|
+
case "request-rebuild":
|
|
220
|
+
break;
|
|
221
|
+
case "ready":
|
|
222
|
+
if (data.framework) {
|
|
223
|
+
state.activeFrameworks.add(data.framework);
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
case "hmr-timing":
|
|
227
|
+
logHmrUpdate(state.lastHmrPath ?? "", state.lastHmrFramework, data.duration);
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
var handleHMRMessage = (state, client, message) => {
|
|
232
|
+
try {
|
|
233
|
+
const parsedData = parseMessage(message);
|
|
234
|
+
if (parsedData === null) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (!isValidHMRClientMessage(parsedData)) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
handleParsedMessage(state, client, parsedData);
|
|
241
|
+
} catch {}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export { createModuleVersionTracker, incrementModuleVersions, serializeModuleVersions, getMimeType, cleanStaleAssets, lookupAsset, populateAssetStore, broadcastToClients, handleClientConnect, handleClientDisconnect, handleHMRMessage };
|
|
245
|
+
|
|
246
|
+
//# debugId=B4BC5290E57E33C064756E2164756E21
|
|
247
|
+
//# sourceMappingURL=chunk-vkrpm7kc.js.map
|