brumate 0.6.2 → 0.7.1

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 (96) hide show
  1. package/check.d.ts +3 -3
  2. package/dist/{boot-DkbcqdUz.d.ts → boot-CMy0f_iC.d.ts} +2 -2
  3. package/dist/cli.js +77 -6
  4. package/dist/cli.js.map +1 -1
  5. package/dist/{client-C3vRNuLi.js → client-Bm0XbjHr.js} +274 -113
  6. package/dist/client-Bm0XbjHr.js.map +1 -0
  7. package/dist/{client-CqGDbWd_.d.ts → client-DnFF9_lv.d.ts} +40 -14
  8. package/dist/{client-routes-BtGpYCef.js → client-routes-BmPvNr4s.js} +10 -1
  9. package/dist/client-routes-BmPvNr4s.js.map +1 -0
  10. package/dist/{context-btHuB01Z.d.ts → context-BNgBXVUQ.d.ts} +7 -5
  11. package/dist/{context-CTiSzQRc.js → context-CU4Fpn5a.js} +10 -13
  12. package/dist/context-CU4Fpn5a.js.map +1 -0
  13. package/dist/{defer-M18UKyfG.js → defer-BWwxv7Qf.js} +2 -2
  14. package/dist/{defer-M18UKyfG.js.map → defer-BWwxv7Qf.js.map} +1 -1
  15. package/dist/{devtools-D9Q7a41M.js → devtools-Cl6AhENB.js} +4 -4
  16. package/dist/{devtools-D9Q7a41M.js.map → devtools-Cl6AhENB.js.map} +1 -1
  17. package/dist/{devtools-panel-DTQtljeA.js → devtools-panel-DLIeWcAj.js} +32 -9
  18. package/dist/devtools-panel-DLIeWcAj.js.map +1 -0
  19. package/dist/events-LgLdp1R7.js.map +1 -1
  20. package/dist/{features-CbgII-o7.js → features-DwMYKBIC.js} +6 -2
  21. package/dist/features-DwMYKBIC.js.map +1 -0
  22. package/dist/{files-DtDH5AR4.js → files-BuQvpBwF.js} +94 -3
  23. package/dist/files-BuQvpBwF.js.map +1 -0
  24. package/dist/{html-t1JpkODI.js → html-Cf5uKhLs.js} +3 -3
  25. package/dist/html-Cf5uKhLs.js.map +1 -0
  26. package/dist/index.d.ts +44 -0
  27. package/dist/index.js +3 -3
  28. package/dist/index.js.map +1 -1
  29. package/dist/{inspect-Bonq6EJO.js → inspect-BSHv1_25.js} +2739 -2080
  30. package/dist/inspect-BSHv1_25.js.map +1 -0
  31. package/dist/{loader-C-S3yzep.js → loader-BPNSRA2A.js} +5 -5
  32. package/dist/{loader-C-S3yzep.js.map → loader-BPNSRA2A.js.map} +1 -1
  33. package/dist/{rpc-C_znDZ_w.js → rpc-DqfCaYgF.js} +3 -3
  34. package/dist/{rpc-C_znDZ_w.js.map → rpc-DqfCaYgF.js.map} +1 -1
  35. package/dist/runtime/bundles.d.ts +1 -1
  36. package/dist/runtime/bundles.js +2 -0
  37. package/dist/runtime/bundles.js.map +1 -1
  38. package/dist/runtime/client.d.ts +4 -4
  39. package/dist/runtime/client.js +5 -5
  40. package/dist/runtime/context.d.ts +2 -2
  41. package/dist/runtime/context.js +1 -1
  42. package/dist/runtime/devtools.d.ts +2 -2
  43. package/dist/runtime/devtools.js +1 -1
  44. package/dist/runtime/events.d.ts +1 -1
  45. package/dist/runtime/hot.d.ts +1 -1
  46. package/dist/runtime/html.d.ts +1 -1
  47. package/dist/runtime/html.js +1 -1
  48. package/dist/runtime/loader.d.ts +2 -2
  49. package/dist/runtime/loader.js +2 -2
  50. package/dist/runtime/server.d.ts +4 -4
  51. package/dist/runtime/server.js +5 -5
  52. package/dist/runtime/signals.d.ts +2 -2
  53. package/dist/runtime/signals.js +43 -5
  54. package/dist/runtime/signals.js.map +1 -1
  55. package/dist/runtime/static-loader.d.ts +2 -2
  56. package/dist/runtime/static-loader.js +1 -1
  57. package/dist/runtime/store.d.ts +2 -0
  58. package/dist/runtime/store.js +1 -0
  59. package/dist/runtime/testing.d.ts +2 -2
  60. package/dist/runtime/testing.js +2 -2
  61. package/dist/{search-params-CM1RWR2P.js → search-params-C64liRBj.js} +34 -9
  62. package/dist/search-params-C64liRBj.js.map +1 -0
  63. package/dist/{server-dP_ucRiJ.d.ts → server-0rS5vUW1.d.ts} +37 -10
  64. package/dist/{server-BcT9icQ4.js → server-BVObWh-w.js} +132 -16
  65. package/dist/server-BVObWh-w.js.map +1 -0
  66. package/dist/{shared-CzbnWkVA.d.ts → shared-CuJdWifz.d.ts} +16 -3
  67. package/dist/{signals-BwD4u22K.d.ts → signals-DBnq9QRW.d.ts} +46 -6
  68. package/dist/{static-loader-DysAET-w.d.ts → static-loader-BYbXVJDY.d.ts} +2 -2
  69. package/dist/{static-loader-Bt2WDkY1.js → static-loader-V4V1Oy6G.js} +13 -5
  70. package/dist/static-loader-V4V1Oy6G.js.map +1 -0
  71. package/dist/store-BIBAYZo-.js +293 -0
  72. package/dist/store-BIBAYZo-.js.map +1 -0
  73. package/dist/store-xlTzAM_r.d.ts +171 -0
  74. package/dist/{stream-DRjx0keF.js → stream-RXLadXx1.js} +90 -4
  75. package/dist/stream-RXLadXx1.js.map +1 -0
  76. package/dist/vite.d.ts +1 -1
  77. package/dist/vite.js +128 -13
  78. package/dist/vite.js.map +1 -1
  79. package/elements.d.ts +349 -79
  80. package/package.json +5 -1
  81. package/skills/brumate/SKILL.md +1 -1
  82. package/skills/brumate/references/errors.md +127 -9
  83. package/skills/brumate/references/signals.md +37 -30
  84. package/skills/brumate/references/state.md +3 -2
  85. package/dist/client-C3vRNuLi.js.map +0 -1
  86. package/dist/client-routes-BtGpYCef.js.map +0 -1
  87. package/dist/context-CTiSzQRc.js.map +0 -1
  88. package/dist/devtools-panel-DTQtljeA.js.map +0 -1
  89. package/dist/features-CbgII-o7.js.map +0 -1
  90. package/dist/files-DtDH5AR4.js.map +0 -1
  91. package/dist/html-t1JpkODI.js.map +0 -1
  92. package/dist/inspect-Bonq6EJO.js.map +0 -1
  93. package/dist/search-params-CM1RWR2P.js.map +0 -1
  94. package/dist/server-BcT9icQ4.js.map +0 -1
  95. package/dist/static-loader-Bt2WDkY1.js.map +0 -1
  96. package/dist/stream-DRjx0keF.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { p as HAS_SEARCH_PARAMS } from "./features-CbgII-o7.js";
2
- import { n as ROUTE_KEY, t as NAVIGATION_KEY } from "./context-CTiSzQRc.js";
3
- import { n as boot, r as importCore } from "./static-loader-Bt2WDkY1.js";
1
+ import { m as HAS_SEARCH_PARAMS } from "./features-DwMYKBIC.js";
2
+ import { n as ROUTE_KEY, t as NAVIGATION_KEY } from "./context-CU4Fpn5a.js";
3
+ import { n as boot, r as importCore } from "./static-loader-V4V1Oy6G.js";
4
4
  //#region src/runtime/loader.ts
5
5
  /**
6
6
  * Starts resuming the page. Listens to the events in `b-on` attributes
@@ -21,7 +21,7 @@ function prefetch(link) {
21
21
  * marked.
22
22
  */
23
23
  function routes() {
24
- return import("./client-routes-BtGpYCef.js").then((module) => module.ready);
24
+ return import("./client-routes-BmPvNr4s.js").then((module) => module.ready);
25
25
  }
26
26
  /**
27
27
  * Loads pages without a full page load: links to the same origin, the back
@@ -148,4 +148,4 @@ function navigation({ options, listen, core, start: startCore, scan }) {
148
148
  //#endregion
149
149
  export { start as t };
150
150
 
151
- //# sourceMappingURL=loader-C-S3yzep.js.map
151
+ //# sourceMappingURL=loader-BPNSRA2A.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader-C-S3yzep.js","names":[],"sources":["../src/runtime/loader.ts"],"sourcesContent":["import type * as Routes from './client-routes.ts';\nimport { boot, importCore } from './boot.ts';\nimport { NAVIGATION_KEY, ROUTE_KEY } from './context.ts';\nimport { HAS_SEARCH_PARAMS } from './features.ts';\nimport type { Core, LoaderOptions, Navigation } from './boot.ts';\n\nexport type { LoaderOptions, NavigateOptions } from './boot.ts';\nexport { startWithoutNavigation } from './static-loader.ts';\n\n/**\n * Starts resuming the page. Listens to the events in `b-on` attributes\n * and loads `brumate/client` and the component's module on the first one.\n * Returns a function that removes the listeners and stops the core.\n */\nexport function start(options: LoaderOptions): () => void {\n return boot(options, options.navigate === false ? undefined : navigation);\n}\n\n/** Starts loading the page of a link, unless the link asks not to. */\nfunction prefetch(link: HTMLAnchorElement | undefined): void {\n if (link && link.getAttribute('data-prefetch') !== 'none') {\n void import('./navigate.ts').then((module) => module.prefetch(link.href));\n }\n}\n\n/**\n * Imports the code with which the core reads the pages that navigation adds.\n * A core that runs loads it when the loader navigates. A core that starts\n * later loads it with the core, when the page has records that navigation\n * marked.\n */\nfunction routes(): (typeof Routes)['ready'] {\n return import('./client-routes.ts').then((module) => module.ready);\n}\n\n/**\n * Loads pages without a full page load: links to the same origin, the back\n * and forward buttons, forms that post to a server function, and redirects\n * from server functions to the same origin. Returns how the loader imports\n * the core.\n */\nfunction navigation({\n options,\n listen,\n core,\n start: startCore,\n scan,\n}: Navigation): () => Promise<Core> {\n const rpc = `${options.rpc ?? '/_brumate'}/`;\n const settings = typeof options.navigate === 'object' ? options.navigate : {};\n // The page without its hash, to tell a change of the hash from a change of the page.\n let page = String(location.href).split('#')[0];\n // True once the site changed since the page loaded: the next page loads in full, with new code.\n let skewed = false;\n listen(document, 'brumate:skew', () => {\n skewed = true;\n });\n // The core when the page reads a context of navigation, which it starts for them, or when it runs.\n function reader(key: string): Promise<Core> | undefined {\n const running = core();\n if (running) {\n return running;\n }\n for (const script of document.querySelectorAll('script[b-state]')) {\n if (script.textContent?.includes(key)) {\n return startCore();\n }\n }\n return undefined;\n }\n function state(value: { pending: boolean; from?: string; to?: string }): void {\n void reader(NAVIGATION_KEY)?.then((client) => client.setGlobal(NAVIGATION_KEY, value));\n }\n function go(\n url: string,\n init?: RequestInit,\n push = true,\n reload = false,\n scroll = true,\n ): Promise<void> {\n const from = location.href;\n if (skewed) {\n // A form post cannot be a full page load: the page loads again, and the form is lost with\n // the rest of the state of the page.\n if (init) {\n location.reload();\n } else {\n location.assign(url);\n }\n return Promise.resolve();\n }\n page = url.split('#')[0]!;\n if (core()) {\n void routes();\n }\n // CSS can show a progress bar while a page loads, with no client code in the page.\n document.documentElement.setAttribute('data-navigating', '');\n state({ pending: true, from, to: new URL(url, from).href });\n function done(): void {\n document.documentElement.removeAttribute('data-navigating');\n state({ pending: false });\n }\n return import('./navigate.ts')\n .then((module) =>\n module.navigate({\n url,\n init,\n push,\n reload,\n scroll,\n build: options.build,\n focus: settings.focus !== false,\n transition: settings.transition === true,\n // The core forgets the old page, or only stops reading, when layouts stay.\n leave: async (partial) => {\n if (core()) {\n (await routes())(partial);\n }\n },\n enter: () => {\n // The core took the serial entry when it started.\n void core()?.then((client) =>\n client.init({ ...options, serial: undefined, listen: scan }),\n );\n // Code that reads the route, such as in a layout that stays, gets the new one.\n void reader(ROUTE_KEY)?.then((client) => client.updateRoute());\n page = location.href.split('#')[0]!;\n },\n }),\n )\n .finally(done);\n }\n // `navigate(href, options)` from `brumate/routes`.\n listen(document, 'brumate:navigate', (event) => {\n const detail = (\n event as CustomEvent<{ url: string; replace: boolean; scroll: boolean; done: () => void }>\n ).detail;\n event.preventDefault();\n void go(detail.url, undefined, !detail.replace, false, detail.scroll).then(detail.done);\n });\n // A link to another page of this site, which the loader loads itself.\n function pageLink(target: EventTarget | null): HTMLAnchorElement | undefined {\n const link = (target as Element | null)?.closest?.('a[href]') as HTMLAnchorElement | null;\n return link &&\n !link.target &&\n !link.matches('[download],[data-reload]') &&\n link.origin === location.origin &&\n // A link to a place in the same page scrolls there.\n !(link.hash && link.href.split('#')[0] === page)\n ? link\n : undefined;\n }\n listen(document, 'click', (event) => {\n const mouse = event as MouseEvent;\n const link = pageLink(event.target);\n if (\n !link ||\n event.defaultPrevented ||\n mouse.button ||\n mouse.metaKey ||\n mouse.ctrlKey ||\n mouse.shiftKey ||\n mouse.altKey\n ) {\n return;\n }\n event.preventDefault();\n void go(link.href);\n });\n // A page loads when the pointer rests on its link, or the link gets focus, so a click finds it loading.\n let resting: ReturnType<typeof setTimeout> | undefined;\n listen(\n document,\n 'pointerover',\n (event) => {\n const link = pageLink(event.target);\n if (link) {\n clearTimeout(resting);\n resting = setTimeout(() => prefetch(link), 80);\n }\n },\n { passive: true },\n );\n listen(document, 'pointerout', () => clearTimeout(resting), { passive: true });\n listen(document, 'focusin', (event) => prefetch(pageLink(event.target)));\n listen(document, 'submit', (event) => {\n const form = event.target as HTMLFormElement;\n const submitter = (event as SubmitEvent).submitter;\n const action = submitter?.getAttribute('formaction') ?? form.getAttribute('action') ?? '';\n const method = submitter?.getAttribute('formmethod') ?? form.getAttribute('method');\n if (\n event.defaultPrevented ||\n method?.toLowerCase() !== 'post' ||\n !action.startsWith(rpc) ||\n // After a deploy, the browser posts the form itself, and the page that answers is new.\n skewed\n ) {\n return;\n }\n event.preventDefault();\n void go(action, { method: 'POST', body: new FormData(form, submitter) });\n });\n // A server function that redirects, from `rpc.ts`. Another site loads in full.\n listen(document, 'brumate:redirect', (event) => {\n const url = new URL((event as CustomEvent<string>).detail, location.href);\n if (url.origin === location.origin) {\n event.preventDefault();\n void go(url.href, undefined, true, true);\n }\n });\n // A hot update whose markup changed loads the page again, in place. With `init`, the whole\n // page is replaced, as for a form, so layouts render again too, and it keeps the scroll.\n listen(document, 'brumate:reload', () => void go(location.href, { method: 'GET' }, false));\n // The query string moved by `$searchParam` stays on the page, so the next change is told from it.\n if (HAS_SEARCH_PARAMS) {\n listen(document, 'brumate:search', () => {\n page = location.href.split('#')[0]!;\n });\n }\n listen(window, 'popstate', () => {\n // A change of the hash only stays on the page.\n const target = location.href.split('#')[0]!;\n if (target !== page) {\n // `$searchParam` follows the history itself when only its parameters changed.\n const follow = HAS_SEARCH_PARAMS\n ? (globalThis as Record<symbol, ((from: string) => boolean) | undefined>)[\n Symbol.for('brumate.search')\n ]\n : undefined;\n if (follow?.(page)) {\n page = target;\n } else {\n void go(location.href, undefined, false);\n }\n }\n });\n return () =>\n Promise.all([importCore(), document.querySelector('[b-offset],[b-roots]') && routes()]).then(\n ([client]) => client,\n );\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgB,MAAM,SAAoC;CACxD,OAAO,KAAK,SAAS,QAAQ,aAAa,QAAQ,KAAA,IAAY,UAAU;AAC1E;;AAGA,SAAS,SAAS,MAA2C;CAC3D,IAAI,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MAAM;GAOnB,KALe,oBACV,WACC,OAAO,IAAI,gBAAgB,KAE7B,KAAA,EAAA,GACS,IAAI,GACf,OAAO;QAEP,GAAQ,SAAS,MAAM,KAAA,GAAW,KAAK;EAE3C;CACF,CAAC;CACD,aACE,QAAQ,IAAI,CAAC,WAAW,GAAG,SAAS,cAAc,sBAAsB,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,MACrF,CAAC,YAAY,MAChB;AACJ"}
1
+ {"version":3,"file":"loader-BPNSRA2A.js","names":[],"sources":["../src/runtime/loader.ts"],"sourcesContent":["import type * as Routes from './client-routes.ts';\nimport { boot, importCore } from './boot.ts';\nimport { NAVIGATION_KEY, ROUTE_KEY } from './context.ts';\nimport { HAS_SEARCH_PARAMS } from './features.ts';\nimport type { Core, LoaderOptions, Navigation } from './boot.ts';\n\nexport type { LoaderOptions, NavigateOptions } from './boot.ts';\nexport { startWithoutNavigation } from './static-loader.ts';\n\n/**\n * Starts resuming the page. Listens to the events in `b-on` attributes\n * and loads `brumate/client` and the component's module on the first one.\n * Returns a function that removes the listeners and stops the core.\n */\nexport function start(options: LoaderOptions): () => void {\n return boot(options, options.navigate === false ? undefined : navigation);\n}\n\n/** Starts loading the page of a link, unless the link asks not to. */\nfunction prefetch(link: HTMLAnchorElement | undefined): void {\n if (link && link.getAttribute('data-prefetch') !== 'none') {\n void import('./navigate.ts').then((module) => module.prefetch(link.href));\n }\n}\n\n/**\n * Imports the code with which the core reads the pages that navigation adds.\n * A core that runs loads it when the loader navigates. A core that starts\n * later loads it with the core, when the page has records that navigation\n * marked.\n */\nfunction routes(): (typeof Routes)['ready'] {\n return import('./client-routes.ts').then((module) => module.ready);\n}\n\n/**\n * Loads pages without a full page load: links to the same origin, the back\n * and forward buttons, forms that post to a server function, and redirects\n * from server functions to the same origin. Returns how the loader imports\n * the core.\n */\nfunction navigation({\n options,\n listen,\n core,\n start: startCore,\n scan,\n}: Navigation): () => Promise<Core> {\n const rpc = `${options.rpc ?? '/_brumate'}/`;\n const settings = typeof options.navigate === 'object' ? options.navigate : {};\n // The page without its hash, to tell a change of the hash from a change of the page.\n let page = String(location.href).split('#')[0];\n // True once the site changed since the page loaded: the next page loads in full, with new code.\n let skewed = false;\n listen(document, 'brumate:skew', () => {\n skewed = true;\n });\n // The core when the page reads a context of navigation, which it starts for them, or when it runs.\n function reader(key: string): Promise<Core> | undefined {\n const running = core();\n if (running) {\n return running;\n }\n for (const script of document.querySelectorAll('script[b-state]')) {\n if (script.textContent?.includes(key)) {\n return startCore();\n }\n }\n return undefined;\n }\n function state(value: { pending: boolean; from?: string; to?: string }): void {\n void reader(NAVIGATION_KEY)?.then((client) => client.setGlobal(NAVIGATION_KEY, value));\n }\n function go(\n url: string,\n init?: RequestInit,\n push = true,\n reload = false,\n scroll = true,\n ): Promise<void> {\n const from = location.href;\n if (skewed) {\n // A form post cannot be a full page load: the page loads again, and the form is lost with\n // the rest of the state of the page.\n if (init) {\n location.reload();\n } else {\n location.assign(url);\n }\n return Promise.resolve();\n }\n page = url.split('#')[0]!;\n if (core()) {\n void routes();\n }\n // CSS can show a progress bar while a page loads, with no client code in the page.\n document.documentElement.setAttribute('data-navigating', '');\n state({ pending: true, from, to: new URL(url, from).href });\n function done(): void {\n document.documentElement.removeAttribute('data-navigating');\n state({ pending: false });\n }\n return import('./navigate.ts')\n .then((module) =>\n module.navigate({\n url,\n init,\n push,\n reload,\n scroll,\n build: options.build,\n focus: settings.focus !== false,\n transition: settings.transition === true,\n // The core forgets the old page, or only stops reading, when layouts stay.\n leave: async (partial) => {\n if (core()) {\n (await routes())(partial);\n }\n },\n enter: () => {\n // The core took the serial entry when it started.\n void core()?.then((client) =>\n client.init({ ...options, serial: undefined, listen: scan }),\n );\n // Code that reads the route, such as in a layout that stays, gets the new one.\n void reader(ROUTE_KEY)?.then((client) => client.updateRoute());\n page = location.href.split('#')[0]!;\n },\n }),\n )\n .finally(done);\n }\n // `navigate(href, options)` from `brumate/routes`.\n listen(document, 'brumate:navigate', (event) => {\n const detail = (\n event as CustomEvent<{ url: string; replace: boolean; scroll: boolean; done: () => void }>\n ).detail;\n event.preventDefault();\n void go(detail.url, undefined, !detail.replace, false, detail.scroll).then(detail.done);\n });\n // A link to another page of this site, which the loader loads itself.\n function pageLink(target: EventTarget | null): HTMLAnchorElement | undefined {\n const link = (target as Element | null)?.closest?.('a[href]') as HTMLAnchorElement | null;\n return link &&\n !link.target &&\n !link.matches('[download],[data-reload]') &&\n link.origin === location.origin &&\n // A link to a place in the same page scrolls there.\n !(link.hash && link.href.split('#')[0] === page)\n ? link\n : undefined;\n }\n listen(document, 'click', (event) => {\n const mouse = event as MouseEvent;\n const link = pageLink(event.target);\n if (\n !link ||\n event.defaultPrevented ||\n mouse.button ||\n mouse.metaKey ||\n mouse.ctrlKey ||\n mouse.shiftKey ||\n mouse.altKey\n ) {\n return;\n }\n event.preventDefault();\n void go(link.href);\n });\n // A page loads when the pointer rests on its link, or the link gets focus, so a click finds it loading.\n let resting: ReturnType<typeof setTimeout> | undefined;\n listen(\n document,\n 'pointerover',\n (event) => {\n const link = pageLink(event.target);\n if (link) {\n clearTimeout(resting);\n resting = setTimeout(() => prefetch(link), 80);\n }\n },\n { passive: true },\n );\n listen(document, 'pointerout', () => clearTimeout(resting), { passive: true });\n listen(document, 'focusin', (event) => prefetch(pageLink(event.target)));\n listen(document, 'submit', (event) => {\n const form = event.target as HTMLFormElement;\n const submitter = (event as SubmitEvent).submitter;\n const action = submitter?.getAttribute('formaction') ?? form.getAttribute('action') ?? '';\n const method = submitter?.getAttribute('formmethod') ?? form.getAttribute('method');\n if (\n event.defaultPrevented ||\n method?.toLowerCase() !== 'post' ||\n !action.startsWith(rpc) ||\n // After a deploy, the browser posts the form itself, and the page that answers is new.\n skewed\n ) {\n return;\n }\n event.preventDefault();\n void go(action, { method: 'POST', body: new FormData(form, submitter) });\n });\n // A server function that redirects, from `rpc.ts`. Another site loads in full.\n listen(document, 'brumate:redirect', (event) => {\n const url = new URL((event as CustomEvent<string>).detail, location.href);\n if (url.origin === location.origin) {\n event.preventDefault();\n void go(url.href, undefined, true, true);\n }\n });\n // A hot update whose markup changed loads the page again, in place. With `init`, the whole\n // page is replaced, as for a form, so layouts render again too, and it keeps the scroll.\n listen(document, 'brumate:reload', () => void go(location.href, { method: 'GET' }, false));\n // The query string moved by `$searchParam` stays on the page, so the next change is told from it.\n if (HAS_SEARCH_PARAMS) {\n listen(document, 'brumate:search', () => {\n page = location.href.split('#')[0]!;\n });\n }\n listen(window, 'popstate', () => {\n // A change of the hash only stays on the page.\n const target = location.href.split('#')[0]!;\n if (target !== page) {\n // `$searchParam` follows the history itself when only its parameters changed.\n const follow = HAS_SEARCH_PARAMS\n ? (globalThis as Record<symbol, ((from: string) => boolean) | undefined>)[\n Symbol.for('brumate.search')\n ]\n : undefined;\n if (follow?.(page)) {\n page = target;\n } else {\n void go(location.href, undefined, false);\n }\n }\n });\n return () =>\n Promise.all([importCore(), document.querySelector('[b-offset],[b-roots]') && routes()]).then(\n ([client]) => client,\n );\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgB,MAAM,SAAoC;CACxD,OAAO,KAAK,SAAS,QAAQ,aAAa,QAAQ,KAAA,IAAY,UAAU;AAC1E;;AAGA,SAAS,SAAS,MAA2C;CAC3D,IAAI,QAAQ,KAAK,aAAa,eAAe,MAAM,QACjD,OAAY,yBAAgB,CAAC,MAAM,WAAW,OAAO,SAAS,KAAK,IAAI,CAAC;AAE5E;;;;;;;AAQA,SAAS,SAAmC;CAC1C,OAAO,OAAO,8BAAqB,CAAC,MAAM,WAAW,OAAO,KAAK;AACnE;;;;;;;AAQA,SAAS,WAAW,EAClB,SACA,QACA,MACA,OAAO,WACP,QACkC;CAClC,MAAM,MAAM,GAAG,QAAQ,OAAO,YAAY;CAC1C,MAAM,WAAW,OAAO,QAAQ,aAAa,WAAW,QAAQ,WAAW,CAAC;CAE5E,IAAI,OAAO,OAAO,SAAS,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;CAE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K,KAAK,aAAa,QAAQ,KAAK;EACvF,MAAM,SAAS,WAAW,aAAa,YAAY,KAAK,KAAK,aAAa,QAAQ;EAClF,IACE,MAAM,oBACN,QAAQ,YAAY,MAAM,UAC1B,CAAC,OAAO,WAAW,GAAG,KAEtB,QAEA;EAEF,MAAM,eAAe;EACrB,GAAQ,QAAQ;GAAE,QAAQ;GAAQ,MAAM,IAAI,SAAS,MAAM,SAAS;EAAE,CAAC;CACzE,CAAC;CAED,OAAO,UAAU,qBAAqB,UAAU;EAC9C,MAAM,MAAM,IAAI,IAAK,MAA8B,QAAQ,SAAS,IAAI;EACxE,IAAI,IAAI,WAAW,SAAS,QAAQ;GAClC,MAAM,eAAe;GACrB,GAAQ,IAAI,MAAM,KAAA,GAAW,MAAM,IAAI;EACzC;CACF,CAAC;CAGD,OAAO,UAAU,wBAAwB,KAAK,GAAG,SAAS,MAAM,EAAE,QAAQ,MAAM,GAAG,KAAK,CAAC;CAEzF,IAAI,mBACF,OAAO,UAAU,wBAAwB;EACvC,OAAO,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC;CAClC,CAAC;CAEH,OAAO,QAAQ,kBAAkB;EAE/B,MAAM,SAAS,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC;EACxC,IAAI,WAAW,MAAM;GAOnB,KALe,oBACV,WACC,OAAO,IAAI,gBAAgB,KAE7B,KAAA,EAAA,GACS,IAAI,GACf,OAAO;QAEP,GAAQ,SAAS,MAAM,KAAA,GAAW,KAAK;EAE3C;CACF,CAAC;CACD,aACE,QAAQ,IAAI,CAAC,WAAW,GAAG,SAAS,cAAc,sBAAsB,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,MACrF,CAAC,YAAY,MAChB;AACJ"}
@@ -1,5 +1,5 @@
1
- import { i as callPlugins, n as fromChunkStream, o as serialOptions } from "./stream-DRjx0keF.js";
2
- import { fn as build, gn as skew } from "./client-C3vRNuLi.js";
1
+ import { a as callPlugins, n as fromChunkStream, s as serialOptions } from "./stream-RXLadXx1.js";
2
+ import { hn as build, yn as skew } from "./client-Bm0XbjHr.js";
3
3
  import { toJSONAsync } from "seroval";
4
4
  //#region src/runtime/rpc.ts
5
5
  /**
@@ -146,4 +146,4 @@ function sendAction(form, submitter) {
146
146
  //#endregion
147
147
  export { call, sendAction };
148
148
 
149
- //# sourceMappingURL=rpc-C_znDZ_w.js.map
149
+ //# sourceMappingURL=rpc-DqfCaYgF.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-C_znDZ_w.js","names":[],"sources":["../src/runtime/rpc.ts"],"sourcesContent":["import { toJSONAsync } from 'seroval';\nimport { build, skew } from './client.ts';\nimport type { Scope } from './client.ts';\nimport { callPlugins, serialOptions } from './serial.ts';\nimport { fromChunkStream } from './stream.ts';\n\n/**\n * Calls a server function. It is a separate module, so pages that never call\n * one never load seroval's serializer.\n *\n * Files and blobs in the arguments, anywhere in them, go as parts of\n * multipart form data. `signal` aborts the call.\n */\nexport async function call(\n prefix: string,\n id: string,\n args: unknown[],\n signal?: AbortSignal,\n): Promise<unknown> {\n // The plugin of uploads takes each file and blob in the arguments, wherever it is.\n const files: Blob[] = [];\n const json = JSON.stringify(\n await toJSONAsync(args, { plugins: callPlugins(files), ...serialOptions() }),\n );\n let init: RequestInit;\n if (files.length > 0) {\n const form = new FormData();\n form.set('args', json);\n // A blob of another DOM is copied, because form data takes only its own.\n const copies: (Blob | Promise<Blob>)[] = [];\n for (const file of files) {\n // Typed as a Blob, so the check narrows a blob of another DOM to never.\n copies.push(\n file instanceof Blob\n ? file\n : (file as Blob)\n .arrayBuffer()\n .then((data) => new Blob([data], { type: (file as Blob).type })),\n );\n }\n const blobs = await Promise.all(copies);\n for (const [index, blob] of blobs.entries()) {\n form.set(`file${index}`, blob, (files[index] as Partial<File>).name ?? 'blob');\n }\n init = { headers: { 'x-brumate-args': 'form' }, body: form };\n } else {\n init = { headers: { 'content-type': 'application/json' }, body: json };\n }\n return post(prefix, id, { ...init, signal });\n}\n\n/**\n * Sends a form to a server function, and returns its result. The form data\n * goes as it is, files included, as when the browser posts the form.\n */\nexport async function submit(\n prefix: string,\n id: string,\n form: FormData,\n key?: string | null,\n): Promise<unknown> {\n return post(prefix, id, { headers: { 'x-brumate-result': '1' }, body: form }, key);\n}\n\n/** Posts to a server function, and reads its answer. */\nasync function post(\n prefix: string,\n id: string,\n init: RequestInit,\n key?: string | null,\n): Promise<unknown> {\n const headers = new Headers(init.headers);\n // The build of the page, so the server can tell a call from before a deploy.\n if (build !== undefined) {\n headers.set('x-brumate-build', build);\n }\n // The key of a form of a function that `idempotent` made.\n const query = key ? `?__key=${encodeURIComponent(key)}` : '';\n return answer(\n id,\n await fetch(`${prefix}/${encodeURIComponent(id)}${query}`, {\n ...init,\n headers,\n method: 'POST',\n }),\n );\n}\n\n/** Reads the answer of a server function: its result, a redirect or an error. */\nasync function answer(id: string, response: Response): Promise<unknown> {\n // The server functions whose memos load again, from `refresh` on the server.\n const refreshed = response.headers.get('x-brumate-refresh');\n if (refreshed) {\n const ids = refreshed.split(',');\n void refreshMemos(ids);\n document.dispatchEvent(new CustomEvent('brumate:refresh', { detail: ids }));\n }\n const location = response.headers.get('x-brumate-redirect');\n if (location !== null) {\n // The loader navigates on the client when it can. Without client navigation, the page loads in full.\n const redirect = new CustomEvent('brumate:redirect', { detail: location, cancelable: true });\n if (document.dispatchEvent(redirect)) {\n window.location.assign(location);\n }\n // The page is leaving, so the call never settles.\n return new Promise(() => {});\n }\n if (!response.ok) {\n // The site changed, and this page is from before. The next page loads in full.\n if (response.status === 409 && response.headers.get('x-brumate-build')) {\n skew('call');\n }\n let message = `Server function \"${id}\" failed with status ${response.status}`;\n try {\n message = ((await response.json()) as { error: string }).error;\n } catch {\n // The body is not the error of a server function.\n }\n const retryAfter = Number(response.headers.get('retry-after'));\n throw Object.assign(new Error(message), {\n name: 'ServerError',\n status: response.status,\n // The seconds to wait, for a call that a rate limit refused.\n ...(retryAfter > 0 ? { retryAfter } : {}),\n });\n }\n // Promises and async iterables in the result settle as the rest of the answer arrives.\n return fromChunkStream(response.body!);\n}\n\n// The code below reads the core with `import()`, not a static import: a module that imports\n// the core statically would make the package build move the core into a chunk of its own, behind\n// a module that only re-exports it, which a page loads one after the other. The core is loaded\n// already when it runs, so the import costs no request. It names the exports it uses, so a build\n// keeps only them.\n\n/**\n * Loads again the memos that call these server functions, after a server\n * function named them with `refresh`. Each component on the page knows its\n * own memos, from its client module. It is here, and not in the core, because\n * only the answer of a server call starts it.\n */\nexport function refreshMemos(ids: string[]): Promise<void> {\n return import('./client.ts').then(({ descendants, loadModule, scopes }) => {\n for (const root of scopes.values()) {\n if (!root.m) {\n continue;\n }\n void loadModule(root.m).then(async (module) => {\n const entries: NonNullable<typeof module.refresh>[string] = [];\n for (const id of ids) {\n entries.push(...(module.refresh?.[id] ?? []));\n }\n if (entries.length === 0) {\n return;\n }\n const updates = module as unknown as Record<string, unknown>;\n for (const [kind, name] of entries) {\n for (const target of kind === root.k ? [root] : descendants(root, kind)) {\n if (scopes.has(target.id)) {\n (updates[name] as (scope: Scope) => void)(target);\n }\n }\n }\n });\n }\n });\n}\n\n/** Gives a form a new key in its URL, for its next post. */\nfunction renewKey(form: HTMLFormElement, url: URL): void {\n url.searchParams.set('__key', crypto.randomUUID());\n form.setAttribute('action', `${url.pathname}${url.search}`);\n}\n\n/**\n * Sends a form to the server function of its `$action`, and writes the\n * result into the `$action` when it arrives. It is pending until then. See\n * `submitAction` in the core.\n */\nexport function sendAction(form: HTMLFormElement, submitter: HTMLElement | null): Promise<void> {\n const [scopeText, slotText] = form.getAttribute('b-result')!.split(':') as [string, string];\n const scopeId = Number(scopeText);\n const slot = Number(slotText);\n const data = new FormData(form, submitter);\n const action = form.getAttribute('b-action')!;\n return import('./client.ts').then(({ asyncMemo, rpcPrefix, scopes, track }) => {\n const scope = scopes.get(scopeId);\n if (scope) {\n // A form of a function that `idempotent` made sends its key, and gets a new one once the\n // server answered, so a post that the user means again runs again.\n const url = new URL(form.getAttribute('action') ?? '', location.href);\n const key = url.searchParams.get('__key');\n const result = submit(rpcPrefix, action, data, key);\n if (key) {\n void result.then(\n () => renewKey(form, url),\n () => {},\n );\n }\n const answered = result.catch((error: unknown) => {\n // The site changed since the page loaded. The form posts again without scripts, and the\n // page that answers is of the new build.\n if ((error as { status?: number }).status === 409 && build !== undefined) {\n form.submit();\n return new Promise(() => {});\n }\n throw error;\n });\n asyncMemo(scope, slot, track(answered));\n }\n });\n}\n"],"mappings":";;;;;;;;;;;AAaA,eAAsB,KACpB,QACA,IACA,MACA,QACkB;CAElB,MAAM,QAAgB,CAAC;CACvB,MAAM,OAAO,KAAK,UAChB,MAAM,YAAY,MAAM;EAAE,SAAS,YAAY,KAAK;EAAG,GAAG,cAAc;CAAE,CAAC,CAC7E;CACA,IAAI;CACJ,IAAI,MAAM,SAAS,GAAG;EACpB,MAAM,OAAO,IAAI,SAAS;EAC1B,KAAK,IAAI,QAAQ,IAAI;EAErB,MAAM,SAAmC,CAAC;EAC1C,KAAK,MAAM,QAAQ,OAEjB,OAAO,KACL,gBAAgB,OACZ,OACC,KACE,YAAY,CAAC,CACb,MAAM,SAAS,IAAI,KAAK,CAAC,IAAI,GAAG,EAAE,MAAO,KAAc,KAAK,CAAC,CAAC,CACvE;EAEF,MAAM,QAAQ,MAAM,QAAQ,IAAI,MAAM;EACtC,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GACxC,KAAK,IAAI,OAAO,SAAS,MAAO,MAAM,MAAM,CAAmB,QAAQ,MAAM;EAE/E,OAAO;GAAE,SAAS,EAAE,kBAAkB,OAAO;GAAG,MAAM;EAAK;CAC7D,OACE,OAAO;EAAE,SAAS,EAAE,gBAAgB,mBAAmB;EAAG,MAAM;CAAK;CAEvE,OAAO,KAAK,QAAQ,IAAI;EAAE,GAAG;EAAM;CAAO,CAAC;AAC7C;;;;;AAMA,eAAsB,OACpB,QACA,IACA,MACA,KACkB;CAClB,OAAO,KAAK,QAAQ,IAAI;EAAE,SAAS,EAAE,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IAAI,KAAK,aAAa,QAAQ,KAAK,IAAI,SAAS,IAAI;GACpE,MAAM,MAAM,IAAI,aAAa,IAAI,OAAO;GACxC,MAAM,SAAS,OAAO,WAAW,QAAQ,MAAM,GAAG;GAClD,IAAI,KACF,OAAY,WACJ,SAAS,MAAM,GAAG,SAClB,CAAC,CACT;GAEF,MAAM,WAAW,OAAO,OAAO,UAAmB;IAGhD,IAAK,MAA8B,WAAW,OAAO,UAAU,KAAA,GAAW;KACxE,KAAK,OAAO;KACZ,OAAO,IAAI,cAAc,CAAC,CAAC;IAC7B;IACA,MAAM;GACR,CAAC;GACD,UAAU,OAAO,MAAM,MAAM,QAAQ,CAAC;EACxC;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"rpc-DqfCaYgF.js","names":[],"sources":["../src/runtime/rpc.ts"],"sourcesContent":["import { toJSONAsync } from 'seroval';\nimport { build, skew } from './client.ts';\nimport type { Scope } from './client.ts';\nimport { callPlugins, serialOptions } from './serial.ts';\nimport { fromChunkStream } from './stream.ts';\n\n/**\n * Calls a server function. It is a separate module, so pages that never call\n * one never load seroval's serializer.\n *\n * Files and blobs in the arguments, anywhere in them, go as parts of\n * multipart form data. `signal` aborts the call.\n */\nexport async function call(\n prefix: string,\n id: string,\n args: unknown[],\n signal?: AbortSignal,\n): Promise<unknown> {\n // The plugin of uploads takes each file and blob in the arguments, wherever it is.\n const files: Blob[] = [];\n const json = JSON.stringify(\n await toJSONAsync(args, { plugins: callPlugins(files), ...serialOptions() }),\n );\n let init: RequestInit;\n if (files.length > 0) {\n const form = new FormData();\n form.set('args', json);\n // A blob of another DOM is copied, because form data takes only its own.\n const copies: (Blob | Promise<Blob>)[] = [];\n for (const file of files) {\n // Typed as a Blob, so the check narrows a blob of another DOM to never.\n copies.push(\n file instanceof Blob\n ? file\n : (file as Blob)\n .arrayBuffer()\n .then((data) => new Blob([data], { type: (file as Blob).type })),\n );\n }\n const blobs = await Promise.all(copies);\n for (const [index, blob] of blobs.entries()) {\n form.set(`file${index}`, blob, (files[index] as Partial<File>).name ?? 'blob');\n }\n init = { headers: { 'x-brumate-args': 'form' }, body: form };\n } else {\n init = { headers: { 'content-type': 'application/json' }, body: json };\n }\n return post(prefix, id, { ...init, signal });\n}\n\n/**\n * Sends a form to a server function, and returns its result. The form data\n * goes as it is, files included, as when the browser posts the form.\n */\nexport async function submit(\n prefix: string,\n id: string,\n form: FormData,\n key?: string | null,\n): Promise<unknown> {\n return post(prefix, id, { headers: { 'x-brumate-result': '1' }, body: form }, key);\n}\n\n/** Posts to a server function, and reads its answer. */\nasync function post(\n prefix: string,\n id: string,\n init: RequestInit,\n key?: string | null,\n): Promise<unknown> {\n const headers = new Headers(init.headers);\n // The build of the page, so the server can tell a call from before a deploy.\n if (build !== undefined) {\n headers.set('x-brumate-build', build);\n }\n // The key of a form of a function that `idempotent` made.\n const query = key ? `?__key=${encodeURIComponent(key)}` : '';\n return answer(\n id,\n await fetch(`${prefix}/${encodeURIComponent(id)}${query}`, {\n ...init,\n headers,\n method: 'POST',\n }),\n );\n}\n\n/** Reads the answer of a server function: its result, a redirect or an error. */\nasync function answer(id: string, response: Response): Promise<unknown> {\n // The server functions whose memos load again, from `refresh` on the server.\n const refreshed = response.headers.get('x-brumate-refresh');\n if (refreshed) {\n const ids = refreshed.split(',');\n void refreshMemos(ids);\n document.dispatchEvent(new CustomEvent('brumate:refresh', { detail: ids }));\n }\n const location = response.headers.get('x-brumate-redirect');\n if (location !== null) {\n // The loader navigates on the client when it can. Without client navigation, the page loads in full.\n const redirect = new CustomEvent('brumate:redirect', { detail: location, cancelable: true });\n if (document.dispatchEvent(redirect)) {\n window.location.assign(location);\n }\n // The page is leaving, so the call never settles.\n return new Promise(() => {});\n }\n if (!response.ok) {\n // The site changed, and this page is from before. The next page loads in full.\n if (response.status === 409 && response.headers.get('x-brumate-build')) {\n skew('call');\n }\n let message = `Server function \"${id}\" failed with status ${response.status}`;\n try {\n message = ((await response.json()) as { error: string }).error;\n } catch {\n // The body is not the error of a server function.\n }\n const retryAfter = Number(response.headers.get('retry-after'));\n throw Object.assign(new Error(message), {\n name: 'ServerError',\n status: response.status,\n // The seconds to wait, for a call that a rate limit refused.\n ...(retryAfter > 0 ? { retryAfter } : {}),\n });\n }\n // Promises and async iterables in the result settle as the rest of the answer arrives.\n return fromChunkStream(response.body!);\n}\n\n// The code below reads the core with `import()`, not a static import: a module that imports\n// the core statically would make the package build move the core into a chunk of its own, behind\n// a module that only re-exports it, which a page loads one after the other. The core is loaded\n// already when it runs, so the import costs no request. It names the exports it uses, so a build\n// keeps only them.\n\n/**\n * Loads again the memos that call these server functions, after a server\n * function named them with `refresh`. Each component on the page knows its\n * own memos, from its client module. It is here, and not in the core, because\n * only the answer of a server call starts it.\n */\nexport function refreshMemos(ids: string[]): Promise<void> {\n return import('./client.ts').then(({ descendants, loadModule, scopes }) => {\n for (const root of scopes.values()) {\n if (!root.m) {\n continue;\n }\n void loadModule(root.m).then(async (module) => {\n const entries: NonNullable<typeof module.refresh>[string] = [];\n for (const id of ids) {\n entries.push(...(module.refresh?.[id] ?? []));\n }\n if (entries.length === 0) {\n return;\n }\n const updates = module as unknown as Record<string, unknown>;\n for (const [kind, name] of entries) {\n for (const target of kind === root.k ? [root] : descendants(root, kind)) {\n if (scopes.has(target.id)) {\n (updates[name] as (scope: Scope) => void)(target);\n }\n }\n }\n });\n }\n });\n}\n\n/** Gives a form a new key in its URL, for its next post. */\nfunction renewKey(form: HTMLFormElement, url: URL): void {\n url.searchParams.set('__key', crypto.randomUUID());\n form.setAttribute('action', `${url.pathname}${url.search}`);\n}\n\n/**\n * Sends a form to the server function of its `$action`, and writes the\n * result into the `$action` when it arrives. It is pending until then. See\n * `submitAction` in the core.\n */\nexport function sendAction(form: HTMLFormElement, submitter: HTMLElement | null): Promise<void> {\n const [scopeText, slotText] = form.getAttribute('b-result')!.split(':') as [string, string];\n const scopeId = Number(scopeText);\n const slot = Number(slotText);\n const data = new FormData(form, submitter);\n const action = form.getAttribute('b-action')!;\n return import('./client.ts').then(({ asyncMemo, rpcPrefix, scopes, track }) => {\n const scope = scopes.get(scopeId);\n if (scope) {\n // A form of a function that `idempotent` made sends its key, and gets a new one once the\n // server answered, so a post that the user means again runs again.\n const url = new URL(form.getAttribute('action') ?? '', location.href);\n const key = url.searchParams.get('__key');\n const result = submit(rpcPrefix, action, data, key);\n if (key) {\n void result.then(\n () => renewKey(form, url),\n () => {},\n );\n }\n const answered = result.catch((error: unknown) => {\n // The site changed since the page loaded. The form posts again without scripts, and the\n // page that answers is of the new build.\n if ((error as { status?: number }).status === 409 && build !== undefined) {\n form.submit();\n return new Promise(() => {});\n }\n throw error;\n });\n asyncMemo(scope, slot, track(answered));\n }\n });\n}\n"],"mappings":";;;;;;;;;;;AAaA,eAAsB,KACpB,QACA,IACA,MACA,QACkB;CAElB,MAAM,QAAgB,CAAC;CACvB,MAAM,OAAO,KAAK,UAChB,MAAM,YAAY,MAAM;EAAE,SAAS,YAAY,KAAK;EAAG,GAAG,cAAc;CAAE,CAAC,CAC7E;CACA,IAAI;CACJ,IAAI,MAAM,SAAS,GAAG;EACpB,MAAM,OAAO,IAAI,SAAS;EAC1B,KAAK,IAAI,QAAQ,IAAI;EAErB,MAAM,SAAmC,CAAC;EAC1C,KAAK,MAAM,QAAQ,OAEjB,OAAO,KACL,gBAAgB,OACZ,OACC,KACE,YAAY,CAAC,CACb,MAAM,SAAS,IAAI,KAAK,CAAC,IAAI,GAAG,EAAE,MAAO,KAAc,KAAK,CAAC,CAAC,CACvE;EAEF,MAAM,QAAQ,MAAM,QAAQ,IAAI,MAAM;EACtC,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GACxC,KAAK,IAAI,OAAO,SAAS,MAAO,MAAM,MAAM,CAAmB,QAAQ,MAAM;EAE/E,OAAO;GAAE,SAAS,EAAE,kBAAkB,OAAO;GAAG,MAAM;EAAK;CAC7D,OACE,OAAO;EAAE,SAAS,EAAE,gBAAgB,mBAAmB;EAAG,MAAM;CAAK;CA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AAa,UAAU;CAC3C,OAAO,OAAO,sBAAc,CAAC,MAAM,EAAE,WAAW,WAAW,QAAQ,YAAY;EAC7E,MAAM,QAAQ,OAAO,IAAI,OAAO;EAChC,IAAI,OAAO;GAGT,MAAM,MAAM,IAAI,IAAI,KAAK,aAAa,QAAQ,KAAK,IAAI,SAAS,IAAI;GACpE,MAAM,MAAM,IAAI,aAAa,IAAI,OAAO;GACxC,MAAM,SAAS,OAAO,WAAW,QAAQ,MAAM,GAAG;GAClD,IAAI,KACF,OAAY,WACJ,SAAS,MAAM,GAAG,SAClB,CAAC,CACT;GAEF,MAAM,WAAW,OAAO,OAAO,UAAmB;IAGhD,IAAK,MAA8B,WAAW,OAAO,UAAU,KAAA,GAAW;KACxE,KAAK,OAAO;KACZ,OAAO,IAAI,cAAc,CAAC,CAAC;IAC7B;IACA,MAAM;GACR,CAAC;GACD,UAAU,OAAO,MAAM,MAAM,QAAQ,CAAC;EACxC;CACF,CAAC;AACH"}
@@ -1,4 +1,4 @@
1
- import { Wt as ClientModule } from "../client-CqGDbWd_.js";
1
+ import { qt as ClientModule } from "../client-DnFF9_lv.js";
2
2
  //#region src/runtime/bundles.d.ts
3
3
  /**
4
4
  * The client module of a component, from the bundles that the state records of the page name.
@@ -1,3 +1,4 @@
1
+ import { i as HAS_BRIDGES } from "../features-DwMYKBIC.js";
1
2
  //#region src/runtime/bundles.ts
2
3
  /** The client modules of the bundles that loaded, by component ID. */
3
4
  const loaded = /* @__PURE__ */ new Map();
@@ -49,6 +50,7 @@ if (document.readyState === "loading") document.addEventListener("DOMContentLoad
49
50
  * Undefined for a component with no client code.
50
51
  */
51
52
  function load(id) {
53
+ if (HAS_BRIDGES && id.startsWith("bridge:")) id = id.slice(7);
52
54
  if (loaded.has(id)) return Promise.resolve(loaded.get(id));
53
55
  readRecords();
54
56
  const waiting = [...pending.values()];
@@ -1 +1 @@
1
- {"version":3,"file":"bundles.js","names":[],"sources":["../../src/runtime/bundles.ts"],"sourcesContent":["// The `load` of a build, which `virtual:brumate/manifest` exports. The server names the bundles\n// that a page needs in the `b-load` attribute of its state records, so the client entry holds\n// no table of the bundles of the app.\n\nimport type { ClientModule } from './client.ts';\n\n/** The client modules of the bundles that loaded, by component ID. */\nconst loaded = new Map<string, ClientModule>();\n/** The bundles that load or loaded, by URL. */\nconst pending = new Map<string, Promise<void>>();\n/** The state records whose `b-load` was read. */\nconst read = new WeakSet<Element>();\n\n/**\n * Loads a URL that a state record names: a bundle, with the client modules of the components\n * that it holds, or a stylesheet that a module of a bundle imports. A URL is relative to this\n * chunk, as the server writes it for a base of \"./\".\n */\nfunction loadBundle(url: string, nonce: string | null): Promise<void> | undefined {\n const href = new URL(url, import.meta.url).href;\n // A stylesheet goes in the head unless the page has it, such as from the head of the page.\n if (url.endsWith('.css')) {\n for (const link of document.querySelectorAll<HTMLLinkElement>('link[rel=stylesheet]')) {\n if (link.href === href) {\n return undefined;\n }\n }\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = href;\n // The nonce of the record, for a policy on styles. A navigation keeps the link (`b-bundle`),\n // as it keeps the code of the bundle.\n if (nonce) {\n link.setAttribute('nonce', nonce);\n }\n link.setAttribute('b-bundle', '');\n document.head.append(link);\n return undefined;\n }\n let promise = pending.get(url);\n if (!promise) {\n promise = import(/* @vite-ignore */ href).then(\n (bundle: { modules: Record<string, ClientModule> }) => {\n for (const [id, module] of Object.entries(bundle.modules)) {\n loaded.set(id, module);\n }\n },\n );\n pending.set(url, promise);\n // A load that fails can start again, such as after the network comes back.\n promise.catch(() => pending.delete(url));\n }\n return promise;\n}\n\n/** Loads what the state records of the page that were not read yet name. */\nfunction readRecords(): void {\n for (const script of document.querySelectorAll('script[b-load]')) {\n if (!read.has(script)) {\n read.add(script);\n for (const url of script.getAttribute('b-load')!.split(' ')) {\n // Browsers hide the attribute once the page loads, and keep the property.\n const nonce = (script as HTMLScriptElement).nonce || script.getAttribute('nonce');\n void loadBundle(url, nonce)?.catch(() => {});\n }\n }\n }\n}\n\n// The bundles of the page start with the entry, so the code of the page comes in the same round\n// trip as the core. The rest of a page that the browser reads after an `async` entry comes later.\nreadRecords();\nif (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', readRecords);\n}\n\n/**\n * The client module of a component, from the bundles that the state records of the page name.\n * Undefined for a component with no client code.\n */\nexport function load(id: string): Promise<ClientModule> | undefined {\n if (loaded.has(id)) {\n return Promise.resolve(loaded.get(id)!);\n }\n // The records that the page added since, such as those of a navigation or a `#defer` body.\n readRecords();\n const waiting = [...pending.values()];\n return waiting.length > 0 ? Promise.allSettled(waiting).then(() => loaded.get(id)!) : undefined;\n}\n"],"mappings":";;AAOA,MAAM,yBAAS,IAAI,IAA0B;;AAE7C,MAAM,0BAAU,IAAI,IAA2B;;AAE/C,MAAM,uBAAO,IAAI,QAAiB;;;;;;AAOlC,SAAS,WAAW,KAAa,OAAiD;CAChF,MAAM,OAAO,IAAI,IAAI,KAAK,YAAY,GAAG,CAAC,CAAC;CAE3C,IAAI,IAAI,SAAS,MAAM,GAAG;EACxB,KAAK,MAAM,QAAQ,SAAS,iBAAkC,sBAAsB,GAClF,IAAI,KAAK,SAAS,MAChB;EAGJ,MAAM,OAAO,SAAS,cAAc,MAAM;EAC1C,KAAK,MAAM;EACX,KAAK,OAAO;EAGZ,IAAI,OACF,KAAK,aAAa,SAAS,KAAK;EAElC,KAAK,aAAa,YAAY,EAAE;EAChC,SAAS,KAAK,OAAO,IAAI;EACzB;CACF;CACA,IAAI,UAAU,QAAQ,IAAI,GAAG;CAC7B,IAAI,CAAC,SAAS;EACZ,UAAU;;GAA0B;CAAK,CAAC,MACvC,WAAsD;GACrD,KAAK,MAAM,CAAC,IAAI,WAAW,OAAO,QAAQ,OAAO,OAAO,GACtD,OAAO,IAAI,IAAI,MAAM;EAEzB,CACF;EACA,QAAQ,IAAI,KAAK,OAAO;EAExB,QAAQ,YAAY,QAAQ,OAAO,GAAG,CAAC;CACzC;CACA,OAAO;AACT;;AAGA,SAAS,cAAoB;CAC3B,KAAK,MAAM,UAAU,SAAS,iBAAiB,gBAAgB,GAC7D,IAAI,CAAC,KAAK,IAAI,MAAM,GAAG;EACrB,KAAK,IAAI,MAAM;EACf,KAAK,MAAM,OAAO,OAAO,aAAa,QAAQ,CAAC,CAAE,MAAM,GAAG,GAGxD,WAAgB,KADD,OAA6B,SAAS,OAAO,aAAa,OAAO,CACtD,CAAC,EAAE,YAAY,CAAC,CAAC;CAE/C;AAEJ;AAIA,YAAY;AACZ,IAAI,SAAS,eAAe,WAC1B,SAAS,iBAAiB,oBAAoB,WAAW;;;;;AAO3D,SAAgB,KAAK,IAA+C;CAClE,IAAI,OAAO,IAAI,EAAE,GACf,OAAO,QAAQ,QAAQ,OAAO,IAAI,EAAE,CAAE;CAGxC,YAAY;CACZ,MAAM,UAAU,CAAC,GAAG,QAAQ,OAAO,CAAC;CACpC,OAAO,QAAQ,SAAS,IAAI,QAAQ,WAAW,OAAO,CAAC,CAAC,WAAW,OAAO,IAAI,EAAE,CAAE,IAAI,KAAA;AACxF"}
1
+ {"version":3,"file":"bundles.js","names":[],"sources":["../../src/runtime/bundles.ts"],"sourcesContent":["// The `load` of a build, which `virtual:brumate/manifest` exports. The server names the bundles\n// that a page needs in the `b-load` attribute of its state records, so the client entry holds\n// no table of the bundles of the app.\n\nimport type { ClientModule } from './client.ts';\nimport { HAS_BRIDGES } from './features.ts';\n\n/** The client modules of the bundles that loaded, by component ID. */\nconst loaded = new Map<string, ClientModule>();\n/** The bundles that load or loaded, by URL. */\nconst pending = new Map<string, Promise<void>>();\n/** The state records whose `b-load` was read. */\nconst read = new WeakSet<Element>();\n\n/**\n * Loads a URL that a state record names: a bundle, with the client modules of the components\n * that it holds, or a stylesheet that a module of a bundle imports. A URL is relative to this\n * chunk, as the server writes it for a base of \"./\".\n */\nfunction loadBundle(url: string, nonce: string | null): Promise<void> | undefined {\n const href = new URL(url, import.meta.url).href;\n // A stylesheet goes in the head unless the page has it, such as from the head of the page.\n if (url.endsWith('.css')) {\n for (const link of document.querySelectorAll<HTMLLinkElement>('link[rel=stylesheet]')) {\n if (link.href === href) {\n return undefined;\n }\n }\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = href;\n // The nonce of the record, for a policy on styles. A navigation keeps the link (`b-bundle`),\n // as it keeps the code of the bundle.\n if (nonce) {\n link.setAttribute('nonce', nonce);\n }\n link.setAttribute('b-bundle', '');\n document.head.append(link);\n return undefined;\n }\n let promise = pending.get(url);\n if (!promise) {\n promise = import(/* @vite-ignore */ href).then(\n (bundle: { modules: Record<string, ClientModule> }) => {\n for (const [id, module] of Object.entries(bundle.modules)) {\n loaded.set(id, module);\n }\n },\n );\n pending.set(url, promise);\n // A load that fails can start again, such as after the network comes back.\n promise.catch(() => pending.delete(url));\n }\n return promise;\n}\n\n/** Loads what the state records of the page that were not read yet name. */\nfunction readRecords(): void {\n for (const script of document.querySelectorAll('script[b-load]')) {\n if (!read.has(script)) {\n read.add(script);\n for (const url of script.getAttribute('b-load')!.split(' ')) {\n // Browsers hide the attribute once the page loads, and keep the property.\n const nonce = (script as HTMLScriptElement).nonce || script.getAttribute('nonce');\n void loadBundle(url, nonce)?.catch(() => {});\n }\n }\n }\n}\n\n// The bundles of the page start with the entry, so the code of the page comes in the same round\n// trip as the core. The rest of a page that the browser reads after an `async` entry comes later.\nreadRecords();\nif (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', readRecords);\n}\n\n/**\n * The client module of a component, from the bundles that the state records of the page name.\n * Undefined for a component with no client code.\n */\nexport function load(id: string): Promise<ClientModule> | undefined {\n // A bridge of `<script module>` is named by its component, which holds its code.\n if (HAS_BRIDGES && id.startsWith('bridge:')) {\n id = id.slice(7);\n }\n if (loaded.has(id)) {\n return Promise.resolve(loaded.get(id)!);\n }\n // The records that the page added since, such as those of a navigation or a `#defer` body.\n readRecords();\n const waiting = [...pending.values()];\n return waiting.length > 0 ? Promise.allSettled(waiting).then(() => loaded.get(id)!) : undefined;\n}\n"],"mappings":";;;AAQA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AAG,WAAW,SAAS,GACxC,KAAK,GAAG,MAAM,CAAC;CAEjB,IAAI,OAAO,IAAI,EAAE,GACf,OAAO,QAAQ,QAAQ,OAAO,IAAI,EAAE,CAAE;CAGxC,YAAY;CACZ,MAAM,UAAU,CAAC,GAAG,QAAQ,OAAO,CAAC;CACpC,OAAO,QAAQ,SAAS,IAAI,QAAQ,WAAW,OAAO,CAAC,CAAC,WAAW,OAAO,IAAI,EAAE,CAAE,IAAI,KAAA;AACxF"}
@@ -1,5 +1,5 @@
1
- import { c as routeContext, o as createContext, s as navigationContext } from "../context-btHuB01Z.js";
2
- import { A as onAttribute, E as internal, N as raw, R as vars, S as escape, _ as attribute, b as classAttribute, g as affix, k as mergeAttributes, p as Raw, s as SCOPE_IDS, u as unbind } from "../shared-CzbnWkVA.js";
3
- import { $ as toList, $t as skew, A as putText, At as leaveRoutes, B as getScope, Bt as provideValue, C as fillBranch, Ct as fail, D as listNodes, Dt as forget, E as keepText, Et as dispose, F as setSpread, Ft as handlerProp, G as prop, Gt as CoreOptions, H as removeScope, Ht as updateContext, I as template, It as rpc, J as addPortal, Jt as Scope, K as spreadProps, Kt as DEVTOOLS, L as afterInsert, Lt as spread, M as setAttrText, Mt as removeRoot, N as setContent, Nt as action, O as markBlock, Ot as init, P as setOn, Pt as handle, Q as list, Qt as scopes, R as createScope, Rt as submitAction, S as clone, Sn as retag, St as wait, T as keep, Tt as nameComment, U as setOwner, Ut as updateRoute, V as makeId, Vt as setGlobal, W as sink, Wt as ClientModule, X as deferInBrowser, Xt as hooks, Y as addStyle, Yt as build, Z as setVar, Zt as rpcPrefix, _ as title, _n as fill, _t as fillValue, a as cells, an as elementAt, at as portalTo, b as appendText, bn as rekey, bt as reveal, c as isBound, cn as readMemo, ct as writeText, d as resolve, dn as setSlots, dt as after, en as Component, et as windowList, f as set, fn as children, ft as attempt, g as updated, gn as branch, gt as fillSpread, h as update, hn as HiddenBody, ht as fillSettled, i as bindings, in as dynamicNodes, it as content, j as setAttr, jt as remount, k as nodes, kt as leavePage, l as memo, ln as renderMemo, lt as guess, m as unreadMemo, mn as templateCall, mt as fillAttrs, n as asyncMemo, nn as componentNodes, nt as attr, o as effect, on as foreignNodes, ot as restRef, p as timed, pn as insert, pt as countLoads, q as addHead, qt as DevtoolsHooks, r as binding, rn as dynamic, rt as attrs, s as get, sn as place, st as text, t as loader, tn as component, tt as windowStart, u as pending, un as setItem, ut as track, v as paramEffect, vn as held, vt as keepValue, w as fillList, wt as loadModule, x as branchNodes, xn as reset, xt as started, y as searchParam, yn as offscreen, yt as loading, z as descendants, zt as consumeContext } from "../client-CqGDbWd_.js";
1
+ import { c as navigationContext, l as routeContext, o as createContext } from "../context-BNgBXVUQ.js";
2
+ import { A as mergeAttributes, C as escape, D as internal, P as raw, _ as affix, d as unbind, j as onAttribute, m as Raw, s as SCOPE_IDS, u as gateValue, v as attribute, x as classAttribute, z as vars } from "../shared-CuJdWifz.js";
3
+ import { $ as list, $t as hooks, A as nodes, At as leavePage, B as descendants, Bt as consumeContext, C as clone, Cn as rekey, Ct as wait, D as keepText, Dt as dispose, E as keep, Et as nameComment, F as setOn, Ft as handle, G as sink, Gt as toStore, H as makeId, Ht as provideValue, I as setSpread, It as handlerProp, J as addHead, Jt as CoreOptions, K as prop, Kt as updateRoute, L as template, Lt as rpc, M as setAttr, Mt as remount, N as setAttrText, Nt as removeRoot, O as listNodes, Ot as forget, P as setContent, Pt as action, Q as setVar, Qt as build, R as afterInsert, Rt as spread, S as branchNodes, Sn as offscreen, St as started, T as fillList, Tn as retag, Tt as loadModule, U as removeScope, Ut as setGlobal, V as getScope, Vt as consumeStore, W as setOwner, Wt as storeUpdate, X as addStyle, Xt as DevtoolsHooks, Y as addPortal, Yt as DEVTOOLS, Z as deferInBrowser, Zt as Scope, _ as updated, _n as templateCall, _t as fillSpread, a as cells, an as componentNodes, at as content, b as searchParam, bn as fill, bt as loading, c as get, cn as elementAt, ct as text, d as pending, dn as readMemo, dt as track, en as rpcPrefix, et as toList, f as resolve, fn as renderMemo, ft as after, g as update, gn as insert, gt as fillSettled, h as unreadMemo, hn as children, ht as fillAttrs, i as bindings, in as component, it as attrs, j as putText, jt as leaveRoutes, k as markBlock, kt as init, l as isBound, ln as foreignNodes, lt as writeText, m as timed, mn as setSlots, mt as countLoads, n as asyncMemo, nn as skew, nt as windowStart, o as effect, on as dynamic, ot as portalTo, p as set, pn as setItem, pt as attempt, q as spreadProps, qt as ClientModule, r as binding, rn as Component, rt as attr, s as gate, sn as dynamicNodes, st as restRef, t as loader, tn as scopes, tt as windowList, u as memo, un as place, ut as guess, v as title, vn as HiddenBody, vt as fillValue, w as fillBranch, wn as reset, wt as fail, x as appendText, xn as held, xt as reveal, y as paramEffect, yn as branch, yt as keepValue, z as createScope, zt as submitAction } from "../client-DnFF9_lv.js";
4
4
  import { t as produce } from "../produce-CLABZ8k2.js";
5
- export { type ClientModule, type Component, type CoreOptions, DEVTOOLS, type DevtoolsHooks, type HiddenBody, type Raw, type Scope, action, addHead, addPortal, addStyle, affix, after, afterInsert, appendText, asyncMemo, attempt, attr, attribute, attrs, binding, bindings, branch, branchNodes, build, cells, children, classAttribute, clone, component, componentNodes, consumeContext, content, countLoads, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, dynamicNodes, effect, elementAt, escape, fail, fill, fillAttrs, fillBranch, fillList, fillSettled, fillSpread, fillValue, foreignNodes, forget, get, getScope, guess, handle, handlerProp, held, hooks, init, insert, internal, isBound, keep, keepText, keepValue, leavePage, leaveRoutes, list, listNodes, loadModule, loader, loading, makeId, markBlock, memo, mergeAttributes, nameComment, navigationContext, nodes, offscreen, onAttribute, paramEffect, pending, place, portalTo, produce, prop, provideValue, putText, raw, readMemo, rekey, remount, removeRoot, removeScope, renderMemo, reset, resolve, restRef, retag, reveal, routeContext, rpc, rpcPrefix, SCOPE_IDS as scopeIds, scopes, searchParam, set, setAttr, setAttrText, setContent, setGlobal, setItem, setOn, setOwner, setSlots, setSpread, setVar, sink, skew, spread, spreadProps, started, submitAction, template, templateCall, text, timed, title, toList, track, unbind, unreadMemo, update, updateContext, updateRoute, updated, vars, wait, windowList, windowStart, writeText };
5
+ export { type ClientModule, type Component, type CoreOptions, DEVTOOLS, type DevtoolsHooks, type HiddenBody, type Raw, type Scope, action, addHead, addPortal, addStyle, affix, after, afterInsert, appendText, asyncMemo, attempt, attr, attribute, attrs, binding, bindings, branch, branchNodes, build, cells, children, classAttribute, clone, component, componentNodes, consumeContext, consumeStore, content, countLoads, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, dynamicNodes, effect, elementAt, escape, fail, fill, fillAttrs, fillBranch, fillList, fillSettled, fillSpread, fillValue, foreignNodes, forget, gate, gateValue, get, getScope, guess, handle, handlerProp, held, hooks, init, insert, internal, isBound, keep, keepText, keepValue, leavePage, leaveRoutes, list, listNodes, loadModule, loader, loading, makeId, markBlock, memo, mergeAttributes, nameComment, navigationContext, nodes, offscreen, onAttribute, paramEffect, pending, place, portalTo, produce, prop, provideValue, putText, raw, readMemo, rekey, remount, removeRoot, removeScope, renderMemo, reset, resolve, restRef, retag, reveal, routeContext, rpc, rpcPrefix, SCOPE_IDS as scopeIds, scopes, searchParam, set, setAttr, setAttrText, setContent, setGlobal, setItem, setOn, setOwner, setSlots, setSpread, setVar, sink, skew, spread, spreadProps, started, storeUpdate, submitAction, template, templateCall, text, timed, title, toList, toStore, track, unbind, unreadMemo, update, updateRoute, updated, vars, wait, windowList, windowStart, writeText };
@@ -1,5 +1,5 @@
1
- import { E as vars, _ as mergeAttributes, a as attribute, c as classAttribute, i as affix, m as internal, u as escape, v as onAttribute, x as raw } from "../html-t1JpkODI.js";
2
- import { T as unbind, i as produce, p as SCOPE_IDS } from "../search-params-CM1RWR2P.js";
3
- import { a as routeContext, i as navigationContext, r as createContext } from "../context-CTiSzQRc.js";
4
- import { $ as branchNodes, $t as templateCall, A as started, At as consumeContext, B as spreadProps, Bt as get, C as fillAttrs, Ct as handle, D as keepValue, Dt as submitAction, E as fillValue, Et as spread, F as portalTo, Ft as asyncMemo, G as elementAt, Gt as set, H as componentNodes, Ht as memo, I as restRef, It as binding, J as readMemo, Jt as update, K as foreignNodes, Kt as timed, L as text, Lt as bindings, M as attr, Mt as setGlobal, N as attrs, Nt as updateContext, O as loading, Ot as guess, P as content, Pt as updateRoute, Q as appendText, Qt as insert, R as writeText, Rt as cells, S as countLoads, St as action, T as fillSpread, Tt as rpc, U as dynamic, Ut as pending, V as component, Vt as isBound, W as dynamicNodes, Wt as resolve, X as setItem, Xt as fail, Y as renderMemo, Yt as updated, Z as setSlots, Zt as children, _ as rekey, _t as init, a as addPortal, an as makeId, at as listNodes, b as after, bt as remount, c as setVar, cn as sink, ct as putText, d as windowList, dn as DEVTOOLS, dt as setContent, en as title, et as clone, f as windowStart, fn as build, ft as setOn, g as offscreen, gn as skew, gt as forget, h as held, hn as scopes, ht as dispose, i as addHead, in as getScope, it as keepText, j as wait, jt as provideValue, k as reveal, kt as track, l as list, ln as loadModule, lt as setAttr, m as fill, mn as rpcPrefix, mt as template, n as paramEffect, nn as createScope, nt as fillList, o as addStyle, on as removeScope, ot as markBlock, p as branch, pn as hooks, pt as setSpread, q as place, qt as unreadMemo, r as searchParam, rn as descendants, rt as keep, s as deferInBrowser, sn as setOwner, st as nodes, t as loader, tn as afterInsert, tt as fillBranch, u as toList, un as nameComment, ut as setAttrText, v as reset, vt as leavePage, w as fillSettled, wt as handlerProp, x as attempt, xt as removeRoot, y as retag, yt as leaveRoutes, z as prop, zt as effect } from "../client-C3vRNuLi.js";
5
- export { DEVTOOLS, action, addHead, addPortal, addStyle, affix, after, afterInsert, appendText, asyncMemo, attempt, attr, attribute, attrs, binding, bindings, branch, branchNodes, build, cells, children, classAttribute, clone, component, componentNodes, consumeContext, content, countLoads, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, dynamicNodes, effect, elementAt, escape, fail, fill, fillAttrs, fillBranch, fillList, fillSettled, fillSpread, fillValue, foreignNodes, forget, get, getScope, guess, handle, handlerProp, held, hooks, init, insert, internal, isBound, keep, keepText, keepValue, leavePage, leaveRoutes, list, listNodes, loadModule, loader, loading, makeId, markBlock, memo, mergeAttributes, nameComment, navigationContext, nodes, offscreen, onAttribute, paramEffect, pending, place, portalTo, produce, prop, provideValue, putText, raw, readMemo, rekey, remount, removeRoot, removeScope, renderMemo, reset, resolve, restRef, retag, reveal, routeContext, rpc, rpcPrefix, SCOPE_IDS as scopeIds, scopes, searchParam, set, setAttr, setAttrText, setContent, setGlobal, setItem, setOn, setOwner, setSlots, setSpread, setVar, sink, skew, spread, spreadProps, started, submitAction, template, templateCall, text, timed, title, toList, track, unbind, unreadMemo, update, updateContext, updateRoute, updated, vars, wait, windowList, windowStart, writeText };
1
+ import { E as vars, _ as mergeAttributes, a as attribute, c as classAttribute, i as affix, m as internal, u as escape, v as onAttribute, x as raw } from "../html-Cf5uKhLs.js";
2
+ import { D as unbind, g as gateValue, i as produce, p as SCOPE_IDS } from "../search-params-C64liRBj.js";
3
+ import { a as navigationContext, o as routeContext, r as createContext } from "../context-CU4Fpn5a.js";
4
+ import { $ as branchNodes, $t as fail, A as started, At as consumeContext, B as spreadProps, Bt as cells, C as fillAttrs, Ct as handle, D as keepValue, Dt as submitAction, E as fillValue, Et as spread, F as portalTo, Ft as toStore, G as elementAt, Gt as memo, H as componentNodes, Ht as gate, I as restRef, It as updateRoute, J as readMemo, Jt as set, K as foreignNodes, Kt as pending, L as text, Lt as asyncMemo, M as attr, Mt as provideValue, N as attrs, Nt as setGlobal, O as loading, Ot as guess, P as content, Pt as storeUpdate, Q as appendText, Qt as updated, R as writeText, Rt as binding, S as countLoads, St as action, T as fillSpread, Tt as rpc, U as dynamic, Ut as get, V as component, Vt as effect, W as dynamicNodes, Wt as isBound, X as setItem, Xt as unreadMemo, Y as renderMemo, Yt as timed, Z as setSlots, Zt as update, _ as rekey, _n as rpcPrefix, _t as init, a as addPortal, an as createScope, at as listNodes, b as after, bt as remount, c as setVar, cn as makeId, ct as putText, d as windowList, dn as sink, dt as setContent, en as children, et as clone, f as windowStart, fn as nameComment, ft as setOn, g as offscreen, gn as hooks, gt as forget, h as held, hn as build, ht as dispose, i as addHead, in as afterInsert, it as keepText, j as wait, jt as consumeStore, k as reveal, kt as track, l as list, ln as removeScope, lt as setAttr, m as fill, mn as DEVTOOLS, mt as template, n as paramEffect, nn as templateCall, nt as fillList, o as addStyle, on as descendants, ot as markBlock, p as branch, pn as loadModule, pt as setSpread, q as place, qt as resolve, r as searchParam, rn as title, rt as keep, s as deferInBrowser, sn as getScope, st as nodes, t as loader, tn as insert, tt as fillBranch, u as toList, un as setOwner, ut as setAttrText, v as reset, vn as scopes, vt as leavePage, w as fillSettled, wt as handlerProp, x as attempt, xt as removeRoot, y as retag, yn as skew, yt as leaveRoutes, z as prop, zt as bindings } from "../client-Bm0XbjHr.js";
5
+ export { DEVTOOLS, action, addHead, addPortal, addStyle, affix, after, afterInsert, appendText, asyncMemo, attempt, attr, attribute, attrs, binding, bindings, branch, branchNodes, build, cells, children, classAttribute, clone, component, componentNodes, consumeContext, consumeStore, content, countLoads, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, dynamicNodes, effect, elementAt, escape, fail, fill, fillAttrs, fillBranch, fillList, fillSettled, fillSpread, fillValue, foreignNodes, forget, gate, gateValue, get, getScope, guess, handle, handlerProp, held, hooks, init, insert, internal, isBound, keep, keepText, keepValue, leavePage, leaveRoutes, list, listNodes, loadModule, loader, loading, makeId, markBlock, memo, mergeAttributes, nameComment, navigationContext, nodes, offscreen, onAttribute, paramEffect, pending, place, portalTo, produce, prop, provideValue, putText, raw, readMemo, rekey, remount, removeRoot, removeScope, renderMemo, reset, resolve, restRef, retag, reveal, routeContext, rpc, rpcPrefix, SCOPE_IDS as scopeIds, scopes, searchParam, set, setAttr, setAttrText, setContent, setGlobal, setItem, setOn, setOwner, setSlots, setSpread, setVar, sink, skew, spread, spreadProps, started, storeUpdate, submitAction, template, templateCall, text, timed, title, toList, toStore, track, unbind, unreadMemo, update, updateRoute, updated, vars, wait, windowList, windowStart, writeText };
@@ -1,2 +1,2 @@
1
- import { a as Route, c as routeContext, i as ROUTE_KEY, n as NAVIGATION_KEY, o as createContext, r as NavigationState, s as navigationContext, t as Context } from "../context-btHuB01Z.js";
2
- export { Context, NAVIGATION_KEY, NavigationState, ROUTE_KEY, Route, createContext, navigationContext, routeContext };
1
+ import { a as Route, c as navigationContext, i as ROUTE_KEY, l as routeContext, n as NAVIGATION_KEY, o as createContext, r as NavigationState, s as missingContext, t as Context } from "../context-BNgBXVUQ.js";
2
+ export { Context, NAVIGATION_KEY, NavigationState, ROUTE_KEY, Route, createContext, missingContext, navigationContext, routeContext };
@@ -1 +1 @@
1
- export { t as NAVIGATION_KEY, n as ROUTE_KEY, r as createContext, i as navigationContext, a as routeContext } from "../context-CTiSzQRc.js";
1
+ export { t as NAVIGATION_KEY, n as ROUTE_KEY, r as createContext, i as missingContext, a as navigationContext, o as routeContext } from "../context-CU4Fpn5a.js";
@@ -1,5 +1,5 @@
1
- import { c as ScopeId } from "../shared-CzbnWkVA.js";
2
- import { Cn as NavigationReport, Jt as Scope } from "../client-CqGDbWd_.js";
1
+ import { c as ScopeId } from "../shared-CuJdWifz.js";
2
+ import { En as NavigationReport, Zt as Scope } from "../client-DnFF9_lv.js";
3
3
  //#region src/runtime/logo.d.ts
4
4
  /**
5
5
  * The logo of brumate: the pole and the bowl of a b, in outline, where the
@@ -1,3 +1,3 @@
1
1
  import { t as LOGO } from "../logo-DQ_OYhBi.js";
2
- import { a as preview, i as nextBlockState, n as installDevtools, o as reportError, r as moveBlock, s as scanBlocks, t as findRootScope } from "../devtools-D9Q7a41M.js";
2
+ import { a as preview, i as nextBlockState, n as installDevtools, o as reportError, r as moveBlock, s as scanBlocks, t as findRootScope } from "../devtools-Cl6AhENB.js";
3
3
  export { LOGO, findRootScope, installDevtools, moveBlock, nextBlockState, preview, reportError, scanBlocks };
@@ -8,7 +8,7 @@ type FunctionKey = `F${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12}`;
8
8
  * A key of `prevent`: a key by its `event.key`, or that key with a modifier that must be held,
9
9
  * such as `Mod+ArrowDown`. A key alone matches only while Ctrl, Meta and Alt are up, so the
10
10
  * shortcuts of the browser, such as Cmd+Left or Alt+Left, keep their default. `Mod` is Ctrl or
11
- * Meta.
11
+ * Meta. A letter after a modifier matches in either case.
12
12
  */
13
13
  export type KeyName = Key | `${"Mod" | "Ctrl" | "Meta" | "Alt"}+${Key}`;
14
14
  /** A key by its `event.key`: a named key, a letter or a digit. */
@@ -1,4 +1,4 @@
1
- import { Wt as ClientModule } from "../client-CqGDbWd_.js";
1
+ import { qt as ClientModule } from "../client-DnFF9_lv.js";
2
2
  //#region src/runtime/hot.d.ts
3
3
  /** What `brumate:update` holds for each component that changed. */
4
4
  export interface HotUpdate {
@@ -1,2 +1,2 @@
1
- import { A as onAttribute, C as escapeAttribute, D as isInternal, E as internal, F as spread, I as styleElement, L as textValue, M as ownValue, N as raw, O as isRaw, P as rawHTML, R as vars, S as escape, T as insertValue, _ as attribute, b as classAttribute, f as Internal, g as affix, h as actionAttributes, j as onValue, k as mergeAttributes, m as VOID_ELEMENTS, p as Raw, v as attributeText, w as handlerEntry, x as classValue, y as bindEntry } from "../shared-CzbnWkVA.js";
1
+ import { A as mergeAttributes, C as escape, D as internal, E as insertValue, F as rawHTML, I as spread, L as styleElement, M as onValue, N as ownValue, O as isInternal, P as raw, R as textValue, S as classValue, T as handlerEntry, _ as affix, b as bindEntry, g as actionAttributes, h as VOID_ELEMENTS, j as onAttribute, k as isRaw, m as Raw, p as Internal, v as attribute, w as escapeAttribute, x as classAttribute, y as attributeText, z as vars } from "../shared-CuJdWifz.js";
2
2
  export { Internal, Raw, VOID_ELEMENTS, actionAttributes, affix, attribute, attributeText, bindEntry, classAttribute, classValue, escape, escapeAttribute, handlerEntry, insertValue, internal, isInternal, isRaw, mergeAttributes, onAttribute, onValue, ownValue, raw, rawHTML, spread, styleElement, textValue, vars };
@@ -1 +1 @@
1
- export { t as Internal, n as VOID_ELEMENTS, r as actionAttributes, i as affix, a as attribute, o as attributeText, s as bindEntry, c as classAttribute, l as classValue, u as escape, d as escapeAttribute, f as handlerEntry, p as insertValue, m as internal, h as isInternal, g as isRaw, _ as mergeAttributes, v as onAttribute, y as onValue, b as ownValue, x as raw, S as rawHTML, C as spread, w as styleElement, T as textValue, E as vars } from "../html-t1JpkODI.js";
1
+ export { t as Internal, n as VOID_ELEMENTS, r as actionAttributes, i as affix, a as attribute, o as attributeText, s as bindEntry, c as classAttribute, l as classValue, u as escape, d as escapeAttribute, f as handlerEntry, p as insertValue, m as internal, h as isInternal, g as isRaw, _ as mergeAttributes, v as onAttribute, y as onValue, b as ownValue, x as raw, S as rawHTML, C as spread, w as styleElement, T as textValue, E as vars } from "../html-Cf5uKhLs.js";
@@ -1,5 +1,5 @@
1
- import { n as NavigateOptions, t as LoaderOptions } from "../boot-DkbcqdUz.js";
2
- import { t as startWithoutNavigation } from "../static-loader-DysAET-w.js";
1
+ import { n as NavigateOptions, t as LoaderOptions } from "../boot-CMy0f_iC.js";
2
+ import { t as startWithoutNavigation } from "../static-loader-BYbXVJDY.js";
3
3
  //#region src/runtime/loader.d.ts
4
4
  /**
5
5
  * Starts resuming the page. Listens to the events in `b-on` attributes
@@ -1,3 +1,3 @@
1
- import { t as startWithoutNavigation } from "../static-loader-Bt2WDkY1.js";
2
- import { t as start } from "../loader-C-S3yzep.js";
1
+ import { t as startWithoutNavigation } from "../static-loader-V4V1Oy6G.js";
2
+ import { t as start } from "../loader-BPNSRA2A.js";
3
3
  export { start, startWithoutNavigation };
@@ -1,7 +1,7 @@
1
- import { a as Route, c as routeContext, o as createContext, r as NavigationState, s as navigationContext } from "../context-btHuB01Z.js";
2
- import { A as onAttribute, C as escapeAttribute, E as internal, N as raw, R as vars, S as escape, a as PageState, b as classAttribute, c as ScopeId, d as useSerialEntry, g as affix, k as mergeAttributes, l as ScopeState, n as ElementReference, p as Raw, r as FunctionReference, u as unbind } from "../shared-CzbnWkVA.js";
1
+ import { a as Route, c as navigationContext, l as routeContext, o as createContext, r as NavigationState } from "../context-BNgBXVUQ.js";
2
+ import { A as mergeAttributes, C as escape, D as internal, P as raw, _ as affix, a as PageState, c as ScopeId, d as unbind, f as useSerialEntry, j as onAttribute, l as ScopeState, m as Raw, n as ElementReference, r as FunctionReference, u as gateValue, w as escapeAttribute, x as classAttribute, z as vars } from "../shared-CuJdWifz.js";
3
3
  import { t as produce } from "../produce-CLABZ8k2.js";
4
4
  import { t as StandardSchemaV1 } from "../standard-schema-BNY82yX3.js";
5
5
  import { f as Intent, v as SubmissionResult } from "../forms-j1xPAR14.js";
6
- import { $ as idempotent, $t as defineMiddleware, A as handleRoute, At as safeParse, B as renderToStream, Bt as searchParam, C as attribute, Ct as parseSubmission, D as component, Dt as fieldErrors, E as children, Et as ValidationIssue, F as memo, Ft as MiddlewareLoader, G as start, Gt as RequestEvent, H as settled, Ht as Locals, I as packState, It as RouteMatch, J as streamParts, Jt as ServerError, K as stateScript, Kt as RequestEventOptions, L as read, Lt as RouteNode, M as insert, Mt as Handler, N as isCrossSite, Nt as Loader, O as dynamic, Ot as parse, P as lazy, Pt as Middleware, Q as IdempotentOptions, Qt as dedupe, R as ready, Rt as RouteView, S as actionResult, St as SuccessfulSubmission, T as caught, Tt as ValidationError, U as spacerTag, Ut as Redirect, V as setClientBundles, Vt as EntryMiddleware, W as spread, Wt as RequestCall, X as wait, Xt as ServerErrorInfo, Y as streamState, Yt as ServerErrorHandler, Z as waitAll, Zt as ServerErrorKind, _ as ScopeEntry, _t as FailedSubmission, a as DocumentOptions, an as Session, at as setCacheStore, b as StreamOptions, bt as Submission, c as Mark, cn as parseCookies, ct as RateLimitConfig, d as PageCache, dt as RateLimitOptions, en as getEvent, et as CacheStore, f as RenderOptions, ft as RateLimitStore, g as RouteOptions, gt as rateLimit, h as RevealOrder, ht as configureRateLimit, i as DeferTarget, in as CookieOptions, it as revalidate, j as inlineBodies, jt as EndpointLoader, k as handleRequest, kt as parseForm, l as Memo, ln as serializeCookie, lt as RateLimitError, m as RequestOptions, mt as clientAddress, n as Component, nn as redirect, nt as cached, o as ItemSource, on as SessionOptions, ot as storageStore, p as RenderResult, pt as Window, q as stateValue, qt as RequestKind, r as Context, rn as withEvent, rt as memoryStore, s as Lazy, sn as createSession, st as RateLimit, t as ClientBundles, tn as isRedirect, tt as CachedOptions, u as NotReady, un as toNodeHeaders, ut as RateLimitMiddleware, v as StateAttributes, vt as IntentSubmission, w as binding, wt as ParseResult, x as action, xt as SubmissionOptions, y as StateMap, yt as ReplyOptions, z as render, zt as matchRoute } from "../server-dP_ucRiJ.js";
7
- export { type CacheStore, type CachedOptions, ClientBundles, Component, Context, type CookieOptions, DeferTarget, DocumentOptions, ElementReference, type EndpointLoader, type EntryMiddleware, type FailedSubmission, FunctionReference, type Handler, type IdempotentOptions, type Intent, type IntentSubmission, ItemSource, Lazy, type Loader, type Locals, Mark, Memo, type Middleware, type MiddlewareLoader, type NavigationState, NotReady, PageCache, type PageState, type ParseResult, type RateLimit, type RateLimitConfig, RateLimitError, type RateLimitMiddleware, type RateLimitOptions, type RateLimitStore, type Raw, type Redirect, RenderOptions, RenderResult, type ReplyOptions, type RequestCall, RequestEvent, type RequestEventOptions, type RequestKind, RequestOptions, RevealOrder, type Route, type RouteMatch, type RouteNode, RouteOptions, type RouteView, ScopeEntry, type ScopeId, type ScopeState, ServerError, type ServerErrorHandler, type ServerErrorInfo, type ServerErrorKind, type Session, type SessionOptions, type StandardSchemaV1, StateAttributes, StateMap, StreamOptions, type Submission, type SubmissionOptions, type SubmissionResult, type SuccessfulSubmission, ValidationError, type ValidationIssue, type Window, action, actionResult, affix, attribute, binding, cached, caught, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, getEvent, handleRequest, handleRoute, idempotent, inlineBodies, insert, internal, isCrossSite, isRedirect, lazy, matchRoute, memo, memoryStore, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, parseSubmission, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, revalidate, routeContext, safeParse, searchParam, serializeCookie, setCacheStore, setClientBundles, settled, spacerTag, spread, start, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };
6
+ import { $ as idempotent, $t as defineMiddleware, A as handleRoute, At as safeParse, B as renderToStream, Bt as searchParam, C as attribute, Ct as parseSubmission, D as component, Dt as fieldErrors, E as children, Et as ValidationIssue, F as memo, Ft as MiddlewareLoader, G as start, Gt as RequestEvent, H as settled, Ht as Locals, I as packState, It as RouteMatch, J as streamParts, Jt as ServerError, K as stateScript, Kt as RequestEventOptions, L as read, Lt as RouteNode, M as insert, Mt as Handler, N as isCrossSite, Nt as Loader, O as dynamic, Ot as parse, P as lazy, Pt as Middleware, Q as IdempotentOptions, Qt as dedupe, R as ready, Rt as RouteView, S as actionResult, St as SuccessfulSubmission, T as caught, Tt as ValidationError, U as spacerTag, Ut as Redirect, V as setClientBundles, Vt as EntryMiddleware, W as spread, Wt as RequestCall, X as wait, Xt as ServerErrorInfo, Y as streamState, Yt as ServerErrorHandler, Z as waitAll, Zt as ServerErrorKind, _ as ScopeEntry, _t as FailedSubmission, a as DocumentOptions, an as Session, at as setCacheStore, b as StreamOptions, bt as Submission, c as Mark, cn as parseCookies, ct as RateLimitConfig, d as PageCache, dt as RateLimitOptions, en as getEvent, et as CacheStore, f as RenderOptions, ft as RateLimitStore, g as RouteOptions, gt as rateLimit, h as RevealOrder, ht as configureRateLimit, i as DeferTarget, in as CookieOptions, it as revalidate, j as inlineBodies, jt as EndpointLoader, k as handleRequest, kt as parseForm, l as Memo, ln as serializeCookie, lt as RateLimitError, m as RequestOptions, mt as clientAddress, n as Component, nn as redirect, nt as cached, o as ItemSource, on as SessionOptions, ot as storageStore, p as RenderResult, pt as Window, q as stateValue, qt as RequestKind, r as Context, rn as withEvent, rt as memoryStore, s as Lazy, sn as createSession, st as RateLimit, t as ClientBundles, tn as isRedirect, tt as CachedOptions, u as NotReady, un as toNodeHeaders, ut as RateLimitMiddleware, v as StateAttributes, vt as IntentSubmission, w as binding, wt as ParseResult, x as action, xt as SubmissionOptions, y as StateMap, yt as ReplyOptions, z as render, zt as matchRoute } from "../server-0rS5vUW1.js";
7
+ export { type CacheStore, type CachedOptions, ClientBundles, Component, Context, type CookieOptions, DeferTarget, DocumentOptions, ElementReference, type EndpointLoader, type EntryMiddleware, type FailedSubmission, FunctionReference, type Handler, type IdempotentOptions, type Intent, type IntentSubmission, ItemSource, Lazy, type Loader, type Locals, Mark, Memo, type Middleware, type MiddlewareLoader, type NavigationState, NotReady, PageCache, type PageState, type ParseResult, type RateLimit, type RateLimitConfig, RateLimitError, type RateLimitMiddleware, type RateLimitOptions, type RateLimitStore, type Raw, type Redirect, RenderOptions, RenderResult, type ReplyOptions, type RequestCall, RequestEvent, type RequestEventOptions, type RequestKind, RequestOptions, RevealOrder, type Route, type RouteMatch, type RouteNode, RouteOptions, type RouteView, ScopeEntry, type ScopeId, type ScopeState, ServerError, type ServerErrorHandler, type ServerErrorInfo, type ServerErrorKind, type Session, type SessionOptions, type StandardSchemaV1, StateAttributes, StateMap, StreamOptions, type Submission, type SubmissionOptions, type SubmissionResult, type SuccessfulSubmission, ValidationError, type ValidationIssue, type Window, action, actionResult, affix, attribute, binding, cached, caught, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, gateValue, getEvent, handleRequest, handleRoute, idempotent, inlineBodies, insert, internal, isCrossSite, isRedirect, lazy, matchRoute, memo, memoryStore, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, parseSubmission, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, revalidate, routeContext, safeParse, searchParam, serializeCookie, setCacheStore, setClientBundles, settled, spacerTag, spread, start, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };
@@ -1,6 +1,6 @@
1
- import { E as vars, _ as mergeAttributes, c as classAttribute, d as escapeAttribute, i as affix, m as internal, u as escape, v as onAttribute, x as raw } from "../html-t1JpkODI.js";
1
+ import { E as vars, _ as mergeAttributes, c as classAttribute, d as escapeAttribute, i as affix, m as internal, u as escape, v as onAttribute, x as raw } from "../html-Cf5uKhLs.js";
2
2
  import { a as serializeCookie, i as parseCookies, s as toNodeHeaders, t as createSession } from "../cookies-Cnbf4w-S.js";
3
- import { E as useSerialEntry, T as unbind, c as ElementReference, i as produce, l as FunctionReference, n as searchParam } from "../search-params-CM1RWR2P.js";
4
- import { $ as dedupe, A as streamParts, B as ValidationError, C as setClientBundles, D as start, E as spread, F as RateLimitError, G as matchRoute, H as parse, I as clientAddress, J as revalidate, K as cached, L as configureRateLimit, M as wait, N as waitAll, O as stateScript, P as idempotent, Q as ServerError, R as rateLimit, S as renderToStream, T as spacerTag, U as parseForm, V as fieldErrors, W as safeParse, X as storageStore, Y as setCacheStore, Z as RequestEvent, _ as memo, a as attribute, b as ready, c as children, d as handleRequest, et as defineMiddleware, f as handleRoute, g as lazy, h as isCrossSite, i as actionResult, it as withEvent, j as streamState, k as stateValue, l as component, m as insert, n as NotReady, nt as isRedirect, o as binding, p as inlineBodies, q as memoryStore, r as action, rt as redirect, s as caught, t as Context, tt as getEvent, u as dynamic, v as packState, w as settled, x as render, y as read, z as parseSubmission } from "../server-BcT9icQ4.js";
5
- import { a as routeContext, i as navigationContext, r as createContext } from "../context-CTiSzQRc.js";
6
- export { Context, ElementReference, FunctionReference, NotReady, RateLimitError, RequestEvent, ServerError, ValidationError, action, actionResult, affix, attribute, binding, cached, caught, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, getEvent, handleRequest, handleRoute, idempotent, inlineBodies, insert, internal, isCrossSite, isRedirect, lazy, matchRoute, memo, memoryStore, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, parseSubmission, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, revalidate, routeContext, safeParse, searchParam, serializeCookie, setCacheStore, setClientBundles, settled, spacerTag, spread, start, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };
3
+ import { D as unbind, O as useSerialEntry, c as ElementReference, g as gateValue, i as produce, l as FunctionReference, n as searchParam } from "../search-params-C64liRBj.js";
4
+ import { $ as dedupe, A as streamParts, B as ValidationError, C as setClientBundles, D as start, E as spread, F as RateLimitError, G as matchRoute, H as parse, I as clientAddress, J as revalidate, K as cached, L as configureRateLimit, M as wait, N as waitAll, O as stateScript, P as idempotent, Q as ServerError, R as rateLimit, S as renderToStream, T as spacerTag, U as parseForm, V as fieldErrors, W as safeParse, X as storageStore, Y as setCacheStore, Z as RequestEvent, _ as memo, a as attribute, b as ready, c as children, d as handleRequest, et as defineMiddleware, f as handleRoute, g as lazy, h as isCrossSite, i as actionResult, it as withEvent, j as streamState, k as stateValue, l as component, m as insert, n as NotReady, nt as isRedirect, o as binding, p as inlineBodies, q as memoryStore, r as action, rt as redirect, s as caught, t as Context, tt as getEvent, u as dynamic, v as packState, w as settled, x as render, y as read, z as parseSubmission } from "../server-BVObWh-w.js";
5
+ import { a as navigationContext, o as routeContext, r as createContext } from "../context-CU4Fpn5a.js";
6
+ export { Context, ElementReference, FunctionReference, NotReady, RateLimitError, RequestEvent, ServerError, ValidationError, action, actionResult, affix, attribute, binding, cached, caught, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, gateValue, getEvent, handleRequest, handleRoute, idempotent, inlineBodies, insert, internal, isCrossSite, isRedirect, lazy, matchRoute, memo, memoryStore, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, parseSubmission, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, revalidate, routeContext, safeParse, searchParam, serializeCookie, setCacheStore, setClientBundles, settled, spacerTag, spread, start, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };
@@ -1,2 +1,2 @@
1
- import { A as Unbound, C as $title, D as BoundSignal, E as BindableMark, M as flush, O as MemoValue, S as $throttled, T as Bindable, _ as $resolve, a as $effect, b as $setContext, c as $id, d as $isPending, f as $memo, g as $props, h as $produce, i as $debounced, j as WritableMark, k as SearchParamOptions, l as $isBound, m as $optimistic, n as $bind, o as $getContext, p as $navigation, r as $client, s as $handler, t as $action, u as $isPassed, v as $route, w as $untrack, x as $signal, y as $searchParam } from "../signals-BwD4u22K.js";
2
- export { $action, $bind, $client, $debounced, $effect, $getContext, $handler, $id, $isBound, $isPassed, $isPending, $memo, $navigation, $optimistic, $produce, $props, $resolve, $route, $searchParam, $setContext, $signal, $throttled, $title, $untrack, Bindable, BindableMark, BoundSignal, MemoValue, SearchParamOptions, Unbound, WritableMark, flush };
1
+ import { A as BoundSignal, C as $store, D as $untrack, E as $toStore, F as flush, M as SearchParamOptions, N as Unbound, O as Bindable, P as WritableMark, S as $signal, T as $title, _ as $props, a as $effect, b as $searchParam, c as $handler, d as $isPassed, f as $isPending, g as $produce, h as $optimistic, i as $debounced, j as MemoValue, k as BindableMark, l as $id, m as $navigation, n as $bind, o as $gate, p as $memo, r as $client, s as $getContext, t as $action, u as $isBound, v as $resolve, w as $throttled, x as $setContext, y as $route } from "../signals-DBnq9QRW.js";
2
+ export { $action, $bind, $client, $debounced, $effect, $gate, $getContext, $handler, $id, $isBound, $isPassed, $isPending, $memo, $navigation, $optimistic, $produce, $props, $resolve, $route, $searchParam, $setContext, $signal, $store, $throttled, $title, $toStore, $untrack, Bindable, BindableMark, BoundSignal, MemoValue, SearchParamOptions, Unbound, WritableMark, flush };
@@ -21,6 +21,17 @@ function $memo(_value) {
21
21
  return compileTimeOnly("$memo");
22
22
  }
23
23
  /**
24
+ * Declares a memo that takes a new value only when the guard returns true.
25
+ * Otherwise it keeps its value and its readers do not run. The first value
26
+ * passes without the guard, and the server has no history, so it renders the
27
+ * value. The guard runs in the browser, on changes only, with the value the
28
+ * memo holds and the new one. A throw in the guard is held like a throw in
29
+ * a memo. The value cannot be a promise.
30
+ */
31
+ function $gate(_value, _guard) {
32
+ return compileTimeOnly("$gate");
33
+ }
34
+ /**
24
35
  * Declares a memo that takes the value once it stops changing for `ms`
25
36
  * milliseconds, such as a search query while the user types. On the server,
26
37
  * and until the value first changes, it is the value.
@@ -57,8 +68,8 @@ function $client(_callback, _trigger) {
57
68
  function $untrack(_value) {
58
69
  return compileTimeOnly("$untrack");
59
70
  }
60
- /** True while a new value of a memo, or of a memo it reads, loads on the client. Always false on the server. */
61
- function $isPending(_memo) {
71
+ /** True while a new value of one of the memos, or of a memo one reads, loads on the client. Always false on the server. */
72
+ function $isPending(..._memos) {
62
73
  return compileTimeOnly("$isPending");
63
74
  }
64
75
  /**
@@ -93,11 +104,38 @@ function $id() {
93
104
  function $setContext(_context, _value) {
94
105
  compileTimeOnly("$setContext");
95
106
  }
96
- /** Reads a context from the nearest component above that provides it, or its default value. */
97
- function $getContext(_context) {
107
+ function $getContext(_context, _fallback) {
98
108
  return compileTimeOnly("$getContext");
99
109
  }
100
110
  /**
111
+ * Binds a store to a variable. The store is any value with the functions `get`, `subscribe`
112
+ * (which returns a function that stops it) and, optionally, `set`. The source gives a store:
113
+ * `$store(field.state)` for `const field = $getContext(FieldContext)`,
114
+ * `$store($getContext(FieldContext))` for a context that holds a store, an import, a prop, a local
115
+ * `store(0)` or a call. A source that gives no store throws a `TypeError`. For a context that may
116
+ * have no provider, guard on its value, `const s = field ? $store(field.state) : undefined` with
117
+ * `const field = $getContext(FieldContext, undefined)`, or give a store as the fallback,
118
+ * `$store($getContext(LocaleContext, store('en-US')))`. It runs once and is not tracked, and the
119
+ * subscription ends with the scope. On resume the browser keeps the value that the server
120
+ * rendered, runs the source again when it is not a context, and writes the variable once if the
121
+ * store's value differs.
122
+ *
123
+ * `const x = $store(source)` is one-way: the store writes the variable. `let x = $store(source)`
124
+ * is two-way: a write to the variable, such as `x = next` or `x++`, calls `set` of the store, and
125
+ * a store without `set` throws a `TypeError` when the variable registers.
126
+ */
127
+ function $store(_source) {
128
+ return compileTimeOnly("$store");
129
+ }
130
+ /**
131
+ * The store of a memo, a signal or a prop, for a value of `$setContext`. It adds no reactive
132
+ * value: the provider's update writes it. A store of a signal has a `set` that writes the
133
+ * signal; a store of a memo or a prop is read-only.
134
+ */
135
+ function $toStore(_value) {
136
+ return compileTimeOnly("$toStore");
137
+ }
138
+ /**
101
139
  * The route of the page: its URL, its query string and its params, typed
102
140
  * from the route files as `href` is. The server reads the request, and the
103
141
  * browser reads `location`. It changes when navigation changes the URL.
@@ -142,6 +180,6 @@ function flush() {
142
180
  globalThis[Symbol.for("brumate.flush")]?.();
143
181
  }
144
182
  //#endregion
145
- export { $action, $bind, $client, $debounced, $effect, $getContext, $handler, $id, $isBound, $isPassed, $isPending, $memo, $navigation, $optimistic, $produce, $props, $resolve, $route, $searchParam, $setContext, $signal, $throttled, $title, $untrack, flush };
183
+ export { $action, $bind, $client, $debounced, $effect, $gate, $getContext, $handler, $id, $isBound, $isPassed, $isPending, $memo, $navigation, $optimistic, $produce, $props, $resolve, $route, $searchParam, $setContext, $signal, $store, $throttled, $title, $toStore, $untrack, flush };
146
184
 
147
185
  //# sourceMappingURL=signals.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signals.js","names":[],"sources":["../../src/runtime/signals.ts"],"sourcesContent":["// The compile-time functions of `.brm` files. The compiler replaces every\n// call and removes the import, so this module only gives them their types.\n// A call outside a `.brm` file throws.\n\nimport type { Context, NavigationState, Route } from './context.ts';\nimport type { RoutePath, RouteParams } from './routes.ts';\n\nfunction compileTimeOnly(name: string): never {\n throw new Error(`${name} works only in .brm files, which the brumate compiler compiles`);\n}\n\ndeclare const BINDABLE: unique symbol;\ndeclare const WRITES: unique symbol;\n\n/** The mark of a prop that a parent can bind. It has no value at runtime. */\nexport interface BindableMark<T> {\n readonly [BINDABLE]: T;\n}\n\n/**\n * What a binding writes. A binding of a signal of `T` takes a prop that writes `W` when `W` is\n * assignable to `T`, as a signal of `HTMLElement | undefined` takes the ref of a `div`.\n */\nexport interface WritableMark<W> {\n readonly [WRITES]: (value: W) => void;\n}\n\n/** What `$bind` returns: the mark of a prop, and the write side that checks the type of a ref. */\n// oxlint-disable-next-line typescript/no-empty-object-type, typescript/no-empty-interface -- An interface keeps its name in messages.\nexport interface BoundSignal<T> extends BindableMark<T>, WritableMark<T> {}\n\n/**\n * Marks a prop that a parent can bind with `$bind`, such as\n * `open?: Bindable<boolean>`. The parent passes `T` or `$bind(name)`.\n * Inside the component, `$props<T>()` gives `T`.\n */\nexport type Bindable<T> = T | BindableMark<T>;\n\n/** The props as the component reads them, with `Bindable<T>` as `T`. */\nexport type Unbound<T> = { [K in keyof T]: Exclude<T[K], BindableMark<unknown>> };\n\n/**\n * Returns the props of the component. Destructure the call to keep each prop\n * reactive. Destructure it with `let` to write props, such as\n * `let { open = false } = $props()`.\n */\n// oxlint-disable-next-line typescript/no-explicit-any -- Props are any object unless typed.\nexport function $props<T = Record<string, any>>(): Unbound<T> {\n return compileTimeOnly('$props');\n}\n\n/** Declares writable state. The variable reads and writes the signal. */\nexport function $signal<T>(value: T): T;\nexport function $signal<T>(): T | undefined;\nexport function $signal(): never {\n return compileTimeOnly('$signal');\n}\n\n/** The value of a memo: what a promise settles to, or the latest value of an async iterable. */\nexport type MemoValue<T> = Awaited<T> extends AsyncIterable<infer U> ? U : Awaited<T>;\n\n/**\n * Declares a value computed from other values. A promise is awaited where it\n * is read. An async iterable gives each of its values in turn.\n */\nexport function $memo<T>(_value: T): MemoValue<T> {\n return compileTimeOnly('$memo');\n}\n\n/**\n * Declares a memo that takes the value once it stops changing for `ms`\n * milliseconds, such as a search query while the user types. On the server,\n * and until the value first changes, it is the value.\n */\nexport function $debounced<T>(_value: T, _ms: number): MemoValue<T> {\n return compileTimeOnly('$debounced');\n}\n\n/**\n * Declares a memo that takes the value at most once every `ms`\n * milliseconds, and the last value after the wait, such as a position while\n * the pointer moves. On the server, and until the value first changes, it is the value.\n */\nexport function $throttled<T>(_value: T, _ms: number): MemoValue<T> {\n return compileTimeOnly('$throttled');\n}\n\n/**\n * Declares a value that follows a memo, and that handlers can write. A write\n * shows a guess, such as a new item while the form that adds it posts. The\n * value goes back to the memo when the memo changes, or when the server\n * calls of the page finish, such as after a failed post.\n */\nexport function $optimistic<T>(_source: T): T {\n return compileTimeOnly('$optimistic');\n}\n\n/** Runs a callback when the values it reads change, after the page resumes. Never on load. */\nexport function $effect(_callback: () => void | (() => void)): void {\n compileTimeOnly('$effect');\n}\n\n/** Runs a callback in the browser when a trigger fires. */\nexport function $client(\n _callback: () => void | (() => void),\n _trigger?: 'visible' | 'idle' | 'load',\n): void {\n compileTimeOnly('$client');\n}\n\n/** Reads a value without depending on it. */\nexport function $untrack<T>(_value: T): T {\n return compileTimeOnly('$untrack');\n}\n\n/** True while a new value of a memo, or of a memo it reads, loads on the client. Always false on the server. */\nexport function $isPending(_memo: unknown): boolean {\n return compileTimeOnly('$isPending');\n}\n\n/**\n * Waits for a memo to have its value, and gives it. It resolves at once when the memo is settled,\n * and after the load when the memo loads its first value or loads again. When the inputs of the\n * memo change while it waits, it waits for the load of the current inputs. It rejects with the\n * error of the memo, when `timeout` milliseconds pass, or when `signal` aborts. Use it in a handler,\n * an effect or a `$client` callback, never where a memo computes or markup renders.\n */\nexport function $resolve<T>(\n _memo: T,\n _options?: { timeout?: number; signal?: AbortSignal },\n): Promise<Awaited<T>> {\n return compileTimeOnly('$resolve');\n}\n\n/**\n * True when the parent passed a prop with `$bind`, so a write of it reaches the parent. The prop is\n * one that the component destructures with `let`. Always false on the server, where nothing writes.\n */\nexport function $isBound(_prop: unknown): boolean {\n return compileTimeOnly('$isBound');\n}\n\n/**\n * True when the caller passed the prop, even as `undefined`. A part uses it to tell a controlled\n * value, such as `value=(null)`, from no value. Declare it with `const` in the component script.\n */\nexport function $isPassed(_prop: unknown): boolean {\n return compileTimeOnly('$isPassed');\n}\n\n/** Returns an ID that is unique in the page and the same on the server and the client. */\nexport function $id(): string {\n return compileTimeOnly('$id');\n}\n\n/** Provides a value of a context to the components inside this one. */\nexport function $setContext<T>(_context: Context<T>, _value: T): void {\n compileTimeOnly('$setContext');\n}\n\n/** Reads a context from the nearest component above that provides it, or its default value. */\nexport function $getContext<T>(_context: Context<T>): T {\n return compileTimeOnly('$getContext');\n}\n\n/**\n * The route of the page: its URL, its query string and its params, typed\n * from the route files as `href` is. The server reads the request, and the\n * browser reads `location`. It changes when navigation changes the URL.\n */\nexport function $route<P extends RoutePath = RoutePath>(_path?: P): Route<RouteParams<P>> {\n return compileTimeOnly('$route');\n}\n\n/** The options of `$searchParam`. */\nexport interface SearchParamOptions<T> {\n /** The value while the parameter is not in the URL. A write of this value leaves the parameter out. */\n default?: T;\n /** Converts the text of the parameter to a value. Defaults to the text. */\n parse?: (text: string) => T;\n /** Converts a value to the text of the parameter. Defaults to `String`. */\n serialize?: (value: T) => string;\n /** `'push'` adds an entry to the history for each change, and `'replace'` (the default) changes the entry. */\n history?: 'push' | 'replace';\n /** True asks the server for the page again when the parameter changes, as a link to the new URL does. */\n server?: boolean;\n}\n\n/**\n * A signal bound to one parameter of the query string. The server reads the URL of the request.\n * A write in the browser changes the URL with `history.replaceState`, or `pushState` with\n * `{ history: 'push' }`, and asks the server nothing. Back and forward write the signal.\n */\nexport function $searchParam(name: string, options?: SearchParamOptions<string>): string | null;\nexport function $searchParam<T>(name: string, options: SearchParamOptions<T> & { default: T }): T;\nexport function $searchParam<T>(\n name: string,\n options: SearchParamOptions<T> & { parse: (text: string) => T },\n): T | null;\nexport function $searchParam(): never {\n return compileTimeOnly('$searchParam');\n}\n\n/** The navigation that loads, with `pending` false when none does. Always `{ pending: false }` on the server. */\nexport function $navigation(): NavigationState {\n return compileTimeOnly('$navigation');\n}\n\n/** Changes an object or an array in a signal through a draft, and writes the signal with the result. */\nexport function $produce<T>(_signal: T, _recipe: (draft: T) => T | void): void {\n compileTimeOnly('$produce');\n}\n\n/** Sets the title of the page. The last component that sets it wins. */\nexport function $title(_value: unknown): void {\n compileTimeOnly('$title');\n}\n\n/**\n * The latest result of a server function that a form of this component posts\n * to, or undefined before the first post. Pending while the form sends.\n */\nexport function $action<F extends (...args: never[]) => unknown>(\n _fn: F,\n): Awaited<ReturnType<F>> | undefined {\n return compileTimeOnly('$action');\n}\n\n/**\n * Passes a child a signal, or a prop that the component writes, so a write\n * of the prop in the child writes it. The child destructures the prop with\n * `let`. Pass it as the value of a prop: `<Dialog open=$bind(open) />`.\n *\n * - Only a prop of type `Bindable<T>` takes it.\n * - With `set`, a write calls `set(next)` in place of writing the signal.\n */\nexport function $bind<T>(signal: T, set?: (next: T) => unknown): BoundSignal<T>;\nexport function $bind(): never {\n return compileTimeOnly('$bind');\n}\n\n/**\n * Marks a function that a script makes as an event handler, so a spread can\n * pass it on, as it passes on a handler that a caller writes in markup.\n * `args` are JSON values that go with the handler, and it runs as\n * `fn(...args, event)`.\n */\nexport function $handler<A extends unknown[], E = Event>(\n fn: (...args: [...A, E]) => unknown,\n ...args: A\n): (event: E) => unknown;\n/** A function that does not read the event. */\nexport function $handler<A extends unknown[]>(\n fn: (...args: A) => unknown,\n ...args: A\n): (event: Event) => unknown;\nexport function $handler(): never {\n return compileTimeOnly('$handler');\n}\n\n/**\n * Writes what the writes of the handler so far changed to the page, so the code after it can read\n * the DOM, such as to focus or measure what a write rendered. A handler is one pass, and the page\n * changes when it returns. Does nothing outside a handler, and on the server.\n */\nexport function flush(): void {\n (globalThis as { [key: symbol]: (() => void) | undefined })[Symbol.for('brumate.flush')]?.();\n}\n"],"mappings":";AAOA,SAAS,gBAAgB,MAAqB;CAC5C,MAAM,IAAI,MAAM,GAAG,KAAK,+DAA+D;AACzF;;;;;;AAsCA,SAAgB,SAA8C;CAC5D,OAAO,gBAA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AQ;AAC1B;;;;;AAMA,SAAgB,QACd,KACoC;CACpC,OAAO,gBAAgB,SAAS;AAClC;AAWA,SAAgB,QAAe;CAC7B,OAAO,gBAAgB,OAAO;AAChC;AAiBA,SAAgB,WAAkB;CAChC,OAAO,gBAAgB,UAAU;AACnC;;;;;;AAOA,SAAgB,QAAc;CAC5B,WAA4D,OAAO,IAAI,eAAe,EAAE,GAAG;AAC7F"}
1
+ {"version":3,"file":"signals.js","names":[],"sources":["../../src/runtime/signals.ts"],"sourcesContent":["// The compile-time functions of `.brm` files. The compiler replaces every\n// call and removes the import, so this module only gives them their types.\n// A call outside a `.brm` file throws.\n\nimport type { Context, NavigationState, Route } from './context.ts';\nimport type { RoutePath, RouteParams } from './routes.ts';\nimport type { Store, StoreLike } from './store.ts';\n\nfunction compileTimeOnly(name: string): never {\n throw new Error(`${name} works only in .brm files, which the brumate compiler compiles`);\n}\n\ndeclare const BINDABLE: unique symbol;\ndeclare const WRITES: unique symbol;\n\n/** The mark of a prop that a parent can bind. It has no value at runtime. */\nexport interface BindableMark<T> {\n readonly [BINDABLE]: T;\n}\n\n/**\n * What a binding writes. A binding of a signal of `T` takes a prop that writes `W` when `W` is\n * assignable to `T`, as a signal of `HTMLElement | undefined` takes the ref of a `div`.\n */\nexport interface WritableMark<W> {\n readonly [WRITES]: (value: W) => void;\n}\n\n/** What `$bind` returns: the mark of a prop, and the write side that checks the type of a ref. */\n// oxlint-disable-next-line typescript/no-empty-object-type, typescript/no-empty-interface -- An interface keeps its name in messages.\nexport interface BoundSignal<T> extends BindableMark<T>, WritableMark<T> {}\n\n/**\n * Marks a prop that a parent can bind with `$bind`, such as\n * `open?: Bindable<boolean>`. The parent passes `T` or `$bind(name)`.\n * Inside the component, `$props<T>()` gives `T`.\n */\nexport type Bindable<T> = T | BindableMark<T>;\n\n/** The props as the component reads them, with `Bindable<T>` as `T`. */\nexport type Unbound<T> = { [K in keyof T]: Exclude<T[K], BindableMark<unknown>> };\n\n/**\n * Returns the props of the component. Destructure the call to keep each prop\n * reactive. Destructure it with `let` to write props, such as\n * `let { open = false } = $props()`.\n */\n// oxlint-disable-next-line typescript/no-explicit-any -- Props are any object unless typed.\nexport function $props<T = Record<string, any>>(): Unbound<T> {\n return compileTimeOnly('$props');\n}\n\n/** Declares writable state. The variable reads and writes the signal. */\nexport function $signal<T>(value: T): T;\nexport function $signal<T>(): T | undefined;\nexport function $signal(): never {\n return compileTimeOnly('$signal');\n}\n\n/** The value of a memo: what a promise settles to, or the latest value of an async iterable. */\nexport type MemoValue<T> = Awaited<T> extends AsyncIterable<infer U> ? U : Awaited<T>;\n\n/**\n * Declares a value computed from other values. A promise is awaited where it\n * is read. An async iterable gives each of its values in turn.\n */\nexport function $memo<T>(_value: T): MemoValue<T> {\n return compileTimeOnly('$memo');\n}\n\n/**\n * Declares a memo that takes a new value only when the guard returns true.\n * Otherwise it keeps its value and its readers do not run. The first value\n * passes without the guard, and the server has no history, so it renders the\n * value. The guard runs in the browser, on changes only, with the value the\n * memo holds and the new one. A throw in the guard is held like a throw in\n * a memo. The value cannot be a promise.\n */\nexport function $gate<T>(_value: T, _guard: (prev: T, next: T) => boolean): T {\n return compileTimeOnly('$gate');\n}\n\n/**\n * Declares a memo that takes the value once it stops changing for `ms`\n * milliseconds, such as a search query while the user types. On the server,\n * and until the value first changes, it is the value.\n */\nexport function $debounced<T>(_value: T, _ms: number): MemoValue<T> {\n return compileTimeOnly('$debounced');\n}\n\n/**\n * Declares a memo that takes the value at most once every `ms`\n * milliseconds, and the last value after the wait, such as a position while\n * the pointer moves. On the server, and until the value first changes, it is the value.\n */\nexport function $throttled<T>(_value: T, _ms: number): MemoValue<T> {\n return compileTimeOnly('$throttled');\n}\n\n/**\n * Declares a value that follows a memo, and that handlers can write. A write\n * shows a guess, such as a new item while the form that adds it posts. The\n * value goes back to the memo when the memo changes, or when the server\n * calls of the page finish, such as after a failed post.\n */\nexport function $optimistic<T>(_source: T): T {\n return compileTimeOnly('$optimistic');\n}\n\n/** Runs a callback when the values it reads change, after the page resumes. Never on load. */\nexport function $effect(_callback: () => void | (() => void)): void {\n compileTimeOnly('$effect');\n}\n\n/** Runs a callback in the browser when a trigger fires. */\nexport function $client(\n _callback: () => void | (() => void),\n _trigger?: 'visible' | 'idle' | 'load',\n): void {\n compileTimeOnly('$client');\n}\n\n/** Reads a value without depending on it. */\nexport function $untrack<T>(_value: T): T {\n return compileTimeOnly('$untrack');\n}\n\n/** True while a new value of one of the memos, or of a memo one reads, loads on the client. Always false on the server. */\nexport function $isPending(..._memos: unknown[]): boolean {\n return compileTimeOnly('$isPending');\n}\n\n/**\n * Waits for a memo to have its value, and gives it. It resolves at once when the memo is settled,\n * and after the load when the memo loads its first value or loads again. When the inputs of the\n * memo change while it waits, it waits for the load of the current inputs. It rejects with the\n * error of the memo, when `timeout` milliseconds pass, or when `signal` aborts. Use it in a handler,\n * an effect or a `$client` callback, never where a memo computes or markup renders.\n */\nexport function $resolve<T>(\n _memo: T,\n _options?: { timeout?: number; signal?: AbortSignal },\n): Promise<Awaited<T>> {\n return compileTimeOnly('$resolve');\n}\n\n/**\n * True when the parent passed a prop with `$bind`, so a write of it reaches the parent. The prop is\n * one that the component destructures with `let`. Always false on the server, where nothing writes.\n */\nexport function $isBound(_prop: unknown): boolean {\n return compileTimeOnly('$isBound');\n}\n\n/**\n * True when the caller passed the prop, even as `undefined`. A part uses it to tell a controlled\n * value, such as `value=(null)`, from no value. Declare it with `const` in the component script.\n */\nexport function $isPassed(_prop: unknown): boolean {\n return compileTimeOnly('$isPassed');\n}\n\n/** Returns an ID that is unique in the page and the same on the server and the client. */\nexport function $id(): string {\n return compileTimeOnly('$id');\n}\n\n/** Provides a value of a context to the components inside this one. */\nexport function $setContext<T>(_context: Context<T>, _value: T): void {\n compileTimeOnly('$setContext');\n}\n\n/**\n * Reads a context from the nearest component above that provides it. Without a provider it throws,\n * or, with a second argument, gives `fallback`: `$getContext(Field, undefined)` is a read that may\n * have no provider. A fallback that is not a literal runs only when no provider is above, once per\n * read.\n */\nexport function $getContext<T>(_context: Context<T>): T;\nexport function $getContext<T, F>(_context: Context<T>, _fallback: F): T | F;\nexport function $getContext<T, F>(_context: Context<T>, _fallback?: F): T | F {\n return compileTimeOnly('$getContext');\n}\n\n/**\n * Binds a store to a variable. The store is any value with the functions `get`, `subscribe`\n * (which returns a function that stops it) and, optionally, `set`. The source gives a store:\n * `$store(field.state)` for `const field = $getContext(FieldContext)`,\n * `$store($getContext(FieldContext))` for a context that holds a store, an import, a prop, a local\n * `store(0)` or a call. A source that gives no store throws a `TypeError`. For a context that may\n * have no provider, guard on its value, `const s = field ? $store(field.state) : undefined` with\n * `const field = $getContext(FieldContext, undefined)`, or give a store as the fallback,\n * `$store($getContext(LocaleContext, store('en-US')))`. It runs once and is not tracked, and the\n * subscription ends with the scope. On resume the browser keeps the value that the server\n * rendered, runs the source again when it is not a context, and writes the variable once if the\n * store's value differs.\n *\n * `const x = $store(source)` is one-way: the store writes the variable. `let x = $store(source)`\n * is two-way: a write to the variable, such as `x = next` or `x++`, calls `set` of the store, and\n * a store without `set` throws a `TypeError` when the variable registers.\n */\nexport function $store<T>(_source: StoreLike<T>): T {\n return compileTimeOnly('$store');\n}\n\n/**\n * The store of a memo, a signal or a prop, for a value of `$setContext`. It adds no reactive\n * value: the provider's update writes it. A store of a signal has a `set` that writes the\n * signal; a store of a memo or a prop is read-only.\n */\nexport function $toStore<T>(_value: T): Store<T> {\n return compileTimeOnly('$toStore');\n}\n\n/**\n * The route of the page: its URL, its query string and its params, typed\n * from the route files as `href` is. The server reads the request, and the\n * browser reads `location`. It changes when navigation changes the URL.\n */\nexport function $route<P extends RoutePath = RoutePath>(_path?: P): Route<RouteParams<P>> {\n return compileTimeOnly('$route');\n}\n\n/** The options of `$searchParam`. */\nexport interface SearchParamOptions<T> {\n /** The value while the parameter is not in the URL. A write of this value leaves the parameter out. */\n default?: T;\n /** Converts the text of the parameter to a value. Defaults to the text. */\n parse?: (text: string) => T;\n /** Converts a value to the text of the parameter. Defaults to `String`. */\n serialize?: (value: T) => string;\n /** `'push'` adds an entry to the history for each change, and `'replace'` (the default) changes the entry. */\n history?: 'push' | 'replace';\n /** True asks the server for the page again when the parameter changes, as a link to the new URL does. */\n server?: boolean;\n}\n\n/**\n * A signal bound to one parameter of the query string. The server reads the URL of the request.\n * A write in the browser changes the URL with `history.replaceState`, or `pushState` with\n * `{ history: 'push' }`, and asks the server nothing. Back and forward write the signal.\n */\nexport function $searchParam(name: string, options?: SearchParamOptions<string>): string | null;\nexport function $searchParam<T>(name: string, options: SearchParamOptions<T> & { default: T }): T;\nexport function $searchParam<T>(\n name: string,\n options: SearchParamOptions<T> & { parse: (text: string) => T },\n): T | null;\nexport function $searchParam(): never {\n return compileTimeOnly('$searchParam');\n}\n\n/** The navigation that loads, with `pending` false when none does. Always `{ pending: false }` on the server. */\nexport function $navigation(): NavigationState {\n return compileTimeOnly('$navigation');\n}\n\n/** Changes an object or an array in a signal through a draft, and writes the signal with the result. */\nexport function $produce<T>(_signal: T, _recipe: (draft: T) => T | void): void {\n compileTimeOnly('$produce');\n}\n\n/** Sets the title of the page. The last component that sets it wins. */\nexport function $title(_value: unknown): void {\n compileTimeOnly('$title');\n}\n\n/**\n * The latest result of a server function that a form of this component posts\n * to, or undefined before the first post. Pending while the form sends.\n */\nexport function $action<F extends (...args: never[]) => unknown>(\n _fn: F,\n): Awaited<ReturnType<F>> | undefined {\n return compileTimeOnly('$action');\n}\n\n/**\n * Passes a child a signal, or a prop that the component writes, so a write\n * of the prop in the child writes it. The child destructures the prop with\n * `let`. Pass it as the value of a prop: `<Dialog open=$bind(open) />`.\n *\n * - Only a prop of type `Bindable<T>` takes it.\n * - With `set`, a write calls `set(next)` in place of writing the signal.\n */\nexport function $bind<T>(signal: T, set?: (next: T) => unknown): BoundSignal<T>;\nexport function $bind(): never {\n return compileTimeOnly('$bind');\n}\n\n/**\n * Marks a function that a script makes as an event handler, so a spread can\n * pass it on, as it passes on a handler that a caller writes in markup.\n * `args` are JSON values that go with the handler, and it runs as\n * `fn(...args, event)`.\n */\nexport function $handler<A extends unknown[], E = Event>(\n fn: (...args: [...A, E]) => unknown,\n ...args: A\n): (event: E) => unknown;\n/** A function that does not read the event. */\nexport function $handler<A extends unknown[]>(\n fn: (...args: A) => unknown,\n ...args: A\n): (event: Event) => unknown;\nexport function $handler(): never {\n return compileTimeOnly('$handler');\n}\n\n/**\n * Writes what the writes of the handler so far changed to the page, so the code after it can read\n * the DOM, such as to focus or measure what a write rendered. A handler is one pass, and the page\n * changes when it returns. Does nothing outside a handler, and on the server.\n */\nexport function flush(): void {\n (globalThis as { [key: symbol]: (() => void) | undefined })[Symbol.for('brumate.flush')]?.();\n}\n"],"mappings":";AAQA,SAAS,gBAAgB,MAAqB;CAC5C,MAAM,IAAI,MAAM,GAAG,KAAK,+DAA+D;AACzF;;;;;;AAsCA,SAAgB,SAA8C;CAC5D,OAAO,gBAAgB,QAAQ;AACjC;AAKA,SAAgB,UAAiB;CAC/B,OAAO,gBAAgB,SAAS;AAClC;;;;;AASA,SAAgB,MAAS,QAAyB;CAChD,OAAO,gBAAgB,OAAO;AAChC;;;;;;;;;AAUA,SAAgB,MAAS,QAAW,QAA0C;CAC5E,OAAO,gBAAgB,OAAO;AAChC;;;;;;AAOA,SAAgB,WAAc,QAAW,KAA2B;CAClE,OAAO,gBAAgB,YAAY;AACrC;;;;;;AAOA,SAAgB,WAAc,QAAW,KAA2B;CAClE,OAAO,gBAAgB,YAAY;AACrC;;;;;;;AAQA,SAAgB,YAAe,SAAe;CAC5C,OAAO,gBAAgB,aAAa;AACtC;;AAGA,SAAgB,QAAQ,WAA4C;CAClE,gBAAgB,SAAS;AAC3B;;AAGA,SAAgB,QACd,WACA,UACM;CACN,gBAAgB,SAAS;AAC3B;;AAGA,SAAgB,SAAY,QAAc;CACxC,OAAO,gBAAgB,UAAU;AACnC;;AAGA,SAAgB,WAAW,GAAG,QAA4B;CACxD,OAAO,gBAAgB,YAAY;AACrC;;;;;;;;AASA,SAAgB,SACd,OACA,UACqB;CACrB,OAAO,gBAAgB,UAAU;AACnC;;;;;AAMA,SAAgB,SAAS,OAAyB;CAChD,OAAO,gBAAgB,UAAU;AACnC;;;;;AAMA,SAAgB,UAAU,OAAyB;CACjD,OAAO,gBAAgB,WAAW;AACpC;;AAGA,SAAgB,MAAc;CAC5B,OAAO,gBAAgB,KAAK;AAC9B;;AAGA,SAAgB,YAAe,UAAsB,QAAiB;CACpE,gBAAgB,aAAa;AAC/B;AAUA,SAAgB,YAAkB,UAAsB,WAAsB;CAC5E,OAAO,gBAAgB,aAAa;AACtC;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,OAAU,SAA0B;CAClD,OAAO,gBAAgB,QAAQ;AACjC;;;;;;AAOA,SAAgB,SAAY,QAAqB;CAC/C,OAAO,gBAAgB,UAAU;AACnC;;;;;;AAOA,SAAgB,OAAwC,OAAkC;CACxF,OAAO,gBAAgB,QAAQ;AACjC;AA2BA,SAAgB,eAAsB;CACpC,OAAO,gBAAgB,cAAc;AACvC;;AAGA,SAAgB,cAA+B;CAC7C,OAAO,gBAAgB,aAAa;AACtC;;AAGA,SAAgB,SAAY,SAAY,SAAuC;CAC7E,gBAAgB,UAAU;AAC5B;;AAGA,SAAgB,OAAO,QAAuB;CAC5C,gBAAgB,QAAQ;AAC1B;;;;;AAMA,SAAgB,QACd,KACoC;CACpC,OAAO,gBAAgB,SAAS;AAClC;AAWA,SAAgB,QAAe;CAC7B,OAAO,gBAAgB,OAAO;AAChC;AAiBA,SAAgB,WAAkB;CAChC,OAAO,gBAAgB,UAAU;AACnC;;;;;;AAOA,SAAgB,QAAc;CAC5B,WAA4D,OAAO,IAAI,eAAe,EAAE,GAAG;AAC7F"}
@@ -1,3 +1,3 @@
1
- import { t as LoaderOptions } from "../boot-DkbcqdUz.js";
2
- import { t as startWithoutNavigation } from "../static-loader-DysAET-w.js";
1
+ import { t as LoaderOptions } from "../boot-CMy0f_iC.js";
2
+ import { t as startWithoutNavigation } from "../static-loader-BYbXVJDY.js";
3
3
  export { type LoaderOptions, startWithoutNavigation };
@@ -1 +1 @@
1
- export { t as startWithoutNavigation } from "../static-loader-Bt2WDkY1.js";
1
+ export { t as startWithoutNavigation } from "../static-loader-V4V1Oy6G.js";
@@ -0,0 +1,2 @@
1
+ import { _ as sameData, a as Store, b as setBridgeLoader, c as bridge, d as isBridged, f as isContext, g as nameBridge, h as isStore, i as BridgedStore, l as canSet, m as isForeignStore, n as BridgeOptions, o as StoreLike, p as isContract, r as Bridged, s as StoreOrigin, t as Bridge, u as findStored, v as sendStore, x as store, y as sentForeignStore } from "../store-xlTzAM_r.js";
2
+ export { Bridge, BridgeOptions, Bridged, BridgedStore, Store, StoreLike, StoreOrigin, bridge, canSet, findStored, isBridged, isContext, isContract, isForeignStore, isStore, nameBridge, sameData, sendStore, sentForeignStore, setBridgeLoader, store };