brumate 0.3.0 → 0.4.0

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 (122) hide show
  1. package/README.md +2 -2
  2. package/check.d.ts +49 -0
  3. package/dist/{boot-C25Sa6vq.d.ts → boot-DLlRmD9z.d.ts} +8 -10
  4. package/dist/cli.js +275 -15
  5. package/dist/cli.js.map +1 -1
  6. package/dist/client-BvDsC6Qr.js +3463 -0
  7. package/dist/client-BvDsC6Qr.js.map +1 -0
  8. package/dist/{client-D0CqSxoO.d.ts → client-DBwL2wKQ.d.ts} +390 -181
  9. package/dist/{client-routes-JTbGtukf.js → client-routes-BtGpYCef.js} +60 -30
  10. package/dist/client-routes-BtGpYCef.js.map +1 -0
  11. package/dist/{cookies-BzllthiF.js → cookies-Cnbf4w-S.js} +14 -7
  12. package/dist/cookies-Cnbf4w-S.js.map +1 -0
  13. package/dist/{defer-BbD7JQhj.js → defer-CKWZLv2K.js} +4 -4
  14. package/dist/defer-CKWZLv2K.js.map +1 -0
  15. package/dist/{devtools-CQgD7NPB.js → devtools-4uTPwR_v.js} +56 -82
  16. package/dist/devtools-4uTPwR_v.js.map +1 -0
  17. package/dist/{devtools-panel-BVB-W5q4.js → devtools-panel-Be9pxYgv.js} +397 -333
  18. package/dist/devtools-panel-Be9pxYgv.js.map +1 -0
  19. package/dist/{events-CSs7OwIC.js → events-LgLdp1R7.js} +34 -5
  20. package/dist/events-LgLdp1R7.js.map +1 -0
  21. package/dist/features-CHY5Ekku.js +30 -0
  22. package/dist/features-CHY5Ekku.js.map +1 -0
  23. package/dist/files-WW4RlajL.js +506 -0
  24. package/dist/files-WW4RlajL.js.map +1 -0
  25. package/dist/{forms-Cl21hkHt.d.ts → forms-j1xPAR14.d.ts} +3 -3
  26. package/dist/{forms-Bg-CwGqX.js → forms-nXK7-Lv_.js} +78 -44
  27. package/dist/forms-nXK7-Lv_.js.map +1 -0
  28. package/dist/highlight.js +31 -22
  29. package/dist/highlight.js.map +1 -1
  30. package/dist/{html-mNTKzaDD.js → html-BtKRyi7g.js} +86 -22
  31. package/dist/html-BtKRyi7g.js.map +1 -0
  32. package/dist/{html-Bq1rFxX_.d.ts → html-Bw9Qwu6F.d.ts} +20 -5
  33. package/dist/index.d.ts +96 -10
  34. package/dist/index.js +639 -104
  35. package/dist/index.js.map +1 -1
  36. package/dist/{inspect-BHpOw1LF.js → inspect-Y6y4uNZp.js} +3751 -676
  37. package/dist/inspect-Y6y4uNZp.js.map +1 -0
  38. package/dist/{loader-Dos_3NP0.js → loader-BjKGJzLN.js} +20 -14
  39. package/dist/loader-BjKGJzLN.js.map +1 -0
  40. package/dist/logo-DQ_OYhBi.js +10 -0
  41. package/dist/logo-DQ_OYhBi.js.map +1 -0
  42. package/dist/{navigate-O78d_zGN.js → navigate-CfOr-TRF.js} +94 -31
  43. package/dist/navigate-CfOr-TRF.js.map +1 -0
  44. package/dist/nesting-DA5vJw9X.js +265 -0
  45. package/dist/nesting-DA5vJw9X.js.map +1 -0
  46. package/dist/{produce-Doc91GkX.js → produce-B7X9ori9.js} +137 -9
  47. package/dist/produce-B7X9ori9.js.map +1 -0
  48. package/dist/{produce-D0V0ICkz.d.ts → produce-DIgHBVwL.d.ts} +39 -5
  49. package/dist/{rpc-ygMRPmN4.js → rpc-Q-XkLwFh.js} +11 -6
  50. package/dist/rpc-Q-XkLwFh.js.map +1 -0
  51. package/dist/runtime/batch.js +9 -7
  52. package/dist/runtime/batch.js.map +1 -1
  53. package/dist/runtime/client.d.ts +4 -4
  54. package/dist/runtime/client.js +4 -4
  55. package/dist/runtime/devtools.d.ts +11 -29
  56. package/dist/runtime/devtools.js +3 -1
  57. package/dist/runtime/env.js +14 -2
  58. package/dist/runtime/env.js.map +1 -1
  59. package/dist/runtime/events.d.ts +23 -1
  60. package/dist/runtime/events.js +1 -1
  61. package/dist/runtime/forms.d.ts +2 -2
  62. package/dist/runtime/forms.js +1 -1
  63. package/dist/runtime/hot.d.ts +1 -1
  64. package/dist/runtime/hot.js +5 -2
  65. package/dist/runtime/hot.js.map +1 -1
  66. package/dist/runtime/html.d.ts +2 -2
  67. package/dist/runtime/html.js +1 -1
  68. package/dist/runtime/loader.d.ts +2 -2
  69. package/dist/runtime/loader.js +2 -2
  70. package/dist/runtime/routes.js +4 -1
  71. package/dist/runtime/routes.js.map +1 -1
  72. package/dist/runtime/server.d.ts +5 -5
  73. package/dist/runtime/server.js +5 -5
  74. package/dist/runtime/signals.d.ts +38 -1
  75. package/dist/runtime/signals.js +33 -1
  76. package/dist/runtime/signals.js.map +1 -1
  77. package/dist/runtime/static-loader.d.ts +2 -2
  78. package/dist/runtime/static-loader.js +1 -1
  79. package/dist/runtime/testing.d.ts +18 -3
  80. package/dist/runtime/testing.js +150 -33
  81. package/dist/runtime/testing.js.map +1 -1
  82. package/dist/{server-DuFYRXrd.d.ts → server-BvPIg9pT.d.ts} +84 -22
  83. package/dist/{server-CxVDYE_V.js → server-DjyOVJtJ.js} +598 -164
  84. package/dist/server-DjyOVJtJ.js.map +1 -0
  85. package/dist/{static-loader-Drpr0AzI.d.ts → static-loader-BGgdp_Y5.d.ts} +2 -2
  86. package/dist/{static-loader-nZssh66R.js → static-loader-BZR17hSw.js} +78 -99
  87. package/dist/static-loader-BZR17hSw.js.map +1 -0
  88. package/dist/{stream-DCYZO4IF.js → stream-BP5AVmg5.js} +102 -16
  89. package/dist/stream-BP5AVmg5.js.map +1 -0
  90. package/dist/vite.d.ts +13 -20
  91. package/dist/vite.js +1890 -548
  92. package/dist/vite.js.map +1 -1
  93. package/elements.d.ts +951 -0
  94. package/forms/forms.brm.ts +3 -3
  95. package/package.json +12 -3
  96. package/skills/brumate/SKILL.md +58 -0
  97. package/skills/brumate/references/errors.md +2078 -0
  98. package/skills/brumate/references/events.md +117 -0
  99. package/skills/brumate/references/signals.md +61 -0
  100. package/skills/brumate/references/state.md +235 -0
  101. package/skills/brumate/references/syntax.md +250 -0
  102. package/types.d.ts +4 -4
  103. package/dist/client-BD6XT-s5.js +0 -1968
  104. package/dist/client-BD6XT-s5.js.map +0 -1
  105. package/dist/client-routes-JTbGtukf.js.map +0 -1
  106. package/dist/cookies-BzllthiF.js.map +0 -1
  107. package/dist/defer-BbD7JQhj.js.map +0 -1
  108. package/dist/devtools-CQgD7NPB.js.map +0 -1
  109. package/dist/devtools-panel-BVB-W5q4.js.map +0 -1
  110. package/dist/events-CSs7OwIC.js.map +0 -1
  111. package/dist/files-BXSSrQgc.js +0 -205
  112. package/dist/files-BXSSrQgc.js.map +0 -1
  113. package/dist/forms-Bg-CwGqX.js.map +0 -1
  114. package/dist/html-mNTKzaDD.js.map +0 -1
  115. package/dist/inspect-BHpOw1LF.js.map +0 -1
  116. package/dist/loader-Dos_3NP0.js.map +0 -1
  117. package/dist/navigate-O78d_zGN.js.map +0 -1
  118. package/dist/produce-Doc91GkX.js.map +0 -1
  119. package/dist/rpc-ygMRPmN4.js.map +0 -1
  120. package/dist/server-CxVDYE_V.js.map +0 -1
  121. package/dist/static-loader-nZssh66R.js.map +0 -1
  122. package/dist/stream-DCYZO4IF.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { i as callPlugins, n as fromChunkStream, o as serialOptions } from "./stream-DCYZO4IF.js";
2
- import { dt as skew, p as build } from "./client-BD6XT-s5.js";
1
+ import { i as callPlugins, n as fromChunkStream, o as serialOptions } from "./stream-BP5AVmg5.js";
2
+ import { Jt as build, Qt as skew } from "./client-BvDsC6Qr.js";
3
3
  import { toJSONAsync } from "seroval";
4
4
  //#region src/runtime/rpc.ts
5
5
  /**
@@ -19,7 +19,9 @@ async function call(prefix, id, args, signal) {
19
19
  if (files.length > 0) {
20
20
  const form = new FormData();
21
21
  form.set("args", json);
22
- const blobs = await Promise.all(files.map((file) => file instanceof Blob ? file : file.arrayBuffer().then((data) => new Blob([data], { type: file.type }))));
22
+ const copies = [];
23
+ for (const file of files) copies.push(file instanceof Blob ? file : file.arrayBuffer().then((data) => new Blob([data], { type: file.type })));
24
+ const blobs = await Promise.all(copies);
23
25
  for (const [index, blob] of blobs.entries()) form.set(`file${index}`, blob, files[index].name ?? "blob");
24
26
  init = {
25
27
  headers: { "x-brumate-args": "form" },
@@ -98,7 +100,8 @@ function refreshMemos(ids) {
98
100
  for (const root of scopes.values()) {
99
101
  if (!root.m) continue;
100
102
  loadModule(root.m).then(async (module) => {
101
- const entries = ids.flatMap((id) => module.refresh?.[id] ?? []);
103
+ const entries = [];
104
+ for (const id of ids) entries.push(...module.refresh?.[id] ?? []);
102
105
  if (entries.length === 0) return;
103
106
  const updates = await loadPart(module, "update");
104
107
  for (const [kind, name] of entries) for (const target of kind === root.k ? [root] : descendants(root, kind)) if (scopes.has(target.id)) updates[name](target);
@@ -117,7 +120,9 @@ function renewKey(form, url) {
117
120
  * `submitAction` in the core.
118
121
  */
119
122
  function sendAction(form, submitter) {
120
- const [scopeId, slot] = form.getAttribute("b-result").split(":").map(Number);
123
+ const [scopeText, slotText] = form.getAttribute("b-result").split(":");
124
+ const scopeId = Number(scopeText);
125
+ const slot = Number(slotText);
121
126
  const data = new FormData(form, submitter);
122
127
  const action = form.getAttribute("b-action");
123
128
  return import("./runtime/client.js").then(({ asyncMemo, rpcPrefix, scopes, track }) => {
@@ -141,4 +146,4 @@ function sendAction(form, submitter) {
141
146
  //#endregion
142
147
  export { call, sendAction };
143
148
 
144
- //# sourceMappingURL=rpc-ygMRPmN4.js.map
149
+ //# sourceMappingURL=rpc-Q-XkLwFh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-Q-XkLwFh.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, loadPart, 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 = await loadPart(module, 'update');\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,oBAAoB,IAAI;EAAG,MAAM;CAAK,GAAG,GAAG;AACnF;;AAGA,eAAe,KACb,QACA,IACA,MACA,KACkB;CAClB,MAAM,UAAU,IAAI,QAAQ,KAAK,OAAO;CAExC,IAAI,UAAU,KAAA,GACZ,QAAQ,IAAI,mBAAmB,KAAK;CAGtC,MAAM,QAAQ,MAAM,UAAU,mBAAmB,GAAG,MAAM;CAC1D,OAAO,OACL,IACA,MAAM,MAAM,GAAG,OAAO,GAAG,mBAAmB,EAAE,IAAI,SAAS;EACzD,GAAG;EACH;EACA,QAAQ;CACV,CAAC,CACH;AACF;;AAGA,eAAe,OAAO,IAAY,UAAsC;CAEtE,MAAM,YAAY,SAAS,QAAQ,IAAI,mBAAmB;CAC1D,IAAI,WAAW;EACb,MAAM,MAAM,UAAU,MAAM,GAAG;EAC/B,aAAkB,GAAG;EACrB,SAAS,cAAc,IAAI,YAAY,mBAAmB,EAAE,QAAQ,IAAI,CAAC,CAAC;CAC5E;CACA,MAAM,WAAW,SAAS,QAAQ,IAAI,oBAAoB;CAC1D,IAAI,aAAa,MAAM;EAErB,MAAM,WAAW,IAAI,YAAY,oBAAoB;GAAE,QAAQ;GAAU,YAAY;EAAK,CAAC;EAC3F,IAAI,SAAS,cAAc,QAAQ,GACjC,OAAO,SAAS,OAAO,QAAQ;EAGjC,OAAO,IAAI,cAAc,CAAC,CAAC;CAC7B;CACA,IAAI,CAAC,SAAS,IAAI;EAEhB,IAAI,SAAS,WAAW,OAAO,SAAS,QAAQ,IAAI,iBAAiB,GACnE,KAAK,MAAM;EAEb,IAAI,UAAU,oBAAoB,GAAG,uBAAuB,SAAS;EACrE,IAAI;GACF,WAAY,MAAM,SAAS,KAAK,EAAA,CAAyB;EAC3D,QAAQ,CAER;EACA,MAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,aAAa,CAAC;EAC7D,MAAM,OAAO,OAAO,IAAI,MAAM,OAAO,GAAG;GACtC,MAAM;GACN,QAAQ,SAAS;GAEjB,GAAI,aAAa,IAAI,EAAE,WAAW,IAAI,CAAC;EACzC,CAAC;CACH;CAEA,OAAO,gBAAgB,SAAS,IAAK;AACvC;;;;;;;AAcA,SAAgB,aAAa,KAA8B;CACzD,OAAO,OAAO,sBAAc,CAAC,MAAM,EAAE,aAAa,YAAY,UAAU,aAAa;EACnF,KAAK,MAAM,QAAQ,OAAO,OAAO,GAAG;GAClC,IAAI,CAAC,KAAK,GACR;GAEF,WAAgB,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,WAAW;IAC7C,MAAM,UAAsD,CAAC;IAC7D,KAAK,MAAM,MAAM,KACf,QAAQ,KAAK,GAAI,OAAO,UAAU,OAAO,CAAC,CAAE;IAE9C,IAAI,QAAQ,WAAW,GACrB;IAEF,MAAM,UAAU,MAAM,SAAS,QAAQ,QAAQ;IAC/C,KAAK,MAAM,CAAC,MAAM,SAAS,SACzB,KAAK,MAAM,UAAU,SAAS,KAAK,IAAI,CAAC,IAAI,IAAI,YAAY,MAAM,IAAI,GACpE,IAAI,OAAO,IAAI,OAAO,EAAE,GACtB,QAAS,KAAK,CAA4B,MAAM;GAIxD,CAAC;EACH;CACF,CAAC;AACH;;AAGA,SAAS,SAAS,MAAuB,KAAgB;CACvD,IAAI,aAAa,IAAI,SAAS,OAAO,WAAW,CAAC;CACjD,KAAK,aAAa,UAAU,GAAG,IAAI,WAAW,IAAI,QAAQ;AAC5D;;;;;;AAOA,SAAgB,WAAW,MAAuB,WAA8C;CAC9F,MAAM,CAAC,WAAW,YAAY,KAAK,aAAa,UAAU,CAAC,CAAE,MAAM,GAAG;CACtE,MAAM,UAAU,OAAO,SAAS;CAChC,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,OAAO,IAAI,SAAS,MAAM,SAAS;CACzC,MAAM,SAAS,KAAK,aAAa,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"}
@@ -18,14 +18,16 @@ function identity(key) {
18
18
  * throws rejects only the calls of its key.
19
19
  */
20
20
  function batched(readMany, lookup, options = {}) {
21
- const keyOf = options.key ?? identity;
21
+ const getKey = options.key ?? identity;
22
22
  const limit = Math.max(1, options.limit ?? Infinity);
23
23
  let pending = /* @__PURE__ */ new Map();
24
24
  let timer;
25
- const read = async (entries) => {
25
+ async function read(entries) {
26
+ const keys = [];
27
+ for (const entry of entries) keys.push(entry.key);
26
28
  let found;
27
29
  try {
28
- found = await readMany(entries.map((entry) => entry.key));
30
+ found = await readMany(keys);
29
31
  } catch (error) {
30
32
  for (const entry of entries) for (const waiter of entry.waiters) waiter.reject(error);
31
33
  return;
@@ -36,17 +38,17 @@ function batched(readMany, lookup, options = {}) {
36
38
  } catch (error) {
37
39
  for (const waiter of entry.waiters) waiter.reject(error);
38
40
  }
39
- };
40
- const flush = () => {
41
+ }
42
+ function flush() {
41
43
  timer = void 0;
42
44
  const entries = [...pending.values()];
43
45
  pending = /* @__PURE__ */ new Map();
44
46
  for (let start = 0; start < entries.length; start += limit) read(entries.slice(start, start + limit));
45
- };
47
+ }
46
48
  return (key) => {
47
49
  if (onServer()) return (async () => lookup(await readMany([key]), key))();
48
50
  return new Promise((resolve, reject) => {
49
- const id = keyOf(key);
51
+ const id = getKey(key);
50
52
  let entry = pending.get(id);
51
53
  if (!entry) {
52
54
  entry = {
@@ -1 +1 @@
1
- {"version":3,"file":"batch.js","names":[],"sources":["../../src/runtime/batch.ts"],"sourcesContent":["// Reads of many keys at once. In the browser, the calls of one moment, such\n// as the rows of a list that renders, become one call of a server function\n// with every key. The server renders the rows of a list one after another,\n// so there each call reads its own key at once.\n\nexport interface BatchOptions<K> {\n /**\n * What makes two calls the same key. Defaults to the key itself, and to\n * its JSON for an object.\n */\n key?: (key: K) => unknown;\n /** The most keys in one call. A larger batch becomes several calls. */\n limit?: number;\n /** How long a batch gathers calls, in milliseconds. Defaults to 0, until the next task. */\n wait?: number;\n}\n\ninterface Waiter<V> {\n resolve: (value: V) => void;\n reject: (error: unknown) => void;\n}\n\n/** True while the server answers a request, from `request.ts`. A symbol of the registry, so the browser has none. */\nconst IN_REQUEST = Symbol.for('brumate.inRequest');\n\n/** True on the server, or in a test while server code runs. */\nfunction onServer(): boolean {\n const inRequest = (globalThis as Record<symbol, (() => boolean) | undefined>)[IN_REQUEST];\n return typeof document === 'undefined' || inRequest?.() === true;\n}\n\nfunction identity(key: unknown): unknown {\n return key !== null && typeof key === 'object' ? JSON.stringify(key) : key;\n}\n\n/**\n * Gives a function of one key, whose calls in the same moment become one\n * call of `readMany` with every distinct key. Each call gets its value from\n * `lookup`, with what `readMany` returned and its key.\n *\n * A failed read rejects only the calls that it read for, and a `lookup` that\n * throws rejects only the calls of its key.\n */\nexport function batched<K, R, V>(\n readMany: (keys: K[]) => R | Promise<R>,\n lookup: (found: R, key: K) => V,\n options: BatchOptions<K> = {},\n): (key: K) => Promise<Awaited<V>> {\n const keyOf = options.key ?? identity;\n const limit = Math.max(1, options.limit ?? Infinity);\n let pending = new Map<unknown, { key: K; waiters: Waiter<Awaited<V>>[] }>();\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const read = async (entries: { key: K; waiters: Waiter<Awaited<V>>[] }[]): Promise<void> => {\n let found: R;\n try {\n found = await readMany(entries.map((entry) => entry.key));\n } catch (error) {\n for (const entry of entries) {\n for (const waiter of entry.waiters) {\n waiter.reject(error);\n }\n }\n return;\n }\n for (const entry of entries) {\n try {\n // A promise that `lookup` returns settles each call by itself.\n const value = lookup(found, entry.key) as Awaited<V>;\n for (const waiter of entry.waiters) {\n waiter.resolve(value);\n }\n } catch (error) {\n for (const waiter of entry.waiters) {\n waiter.reject(error);\n }\n }\n }\n };\n\n const flush = (): void => {\n timer = undefined;\n const entries = [...pending.values()];\n pending = new Map();\n for (let start = 0; start < entries.length; start += limit) {\n void read(entries.slice(start, start + limit));\n }\n };\n\n return (key) => {\n if (onServer()) {\n // One read for the key, at once, so it reads the event of the request and shares the\n // result of equal calls in the render.\n return (async () => lookup(await readMany([key]), key))() as Promise<Awaited<V>>;\n }\n return new Promise<Awaited<V>>((resolve, reject) => {\n const id = keyOf(key);\n let entry = pending.get(id);\n if (!entry) {\n entry = { key, waiters: [] };\n pending.set(id, entry);\n }\n entry.waiters.push({ resolve, reject });\n timer ??= setTimeout(flush, options.wait ?? 0);\n });\n };\n}\n"],"mappings":";;AAuBA,MAAM,aAAa,OAAO,IAAI,mBAAmB;;AAGjD,SAAS,WAAoB;CAC3B,MAAM,YAAa,WAA2D;CAC9E,OAAO,OAAO,aAAa,eAAe,YAAY,MAAM;AAC9D;AAEA,SAAS,SAAS,KAAuB;CACvC,OAAO,QAAQ,QAAQ,OAAO,QAAQ,WAAW,KAAK,UAAU,GAAG,IAAI;AACzE;;;;;;;;;AAUA,SAAgB,QACd,UACA,QACA,UAA2B,CAAC,GACK;CACjC,MAAM,QAAQ,QAAQ,OAAO;CAC7B,MAAM,QAAQ,KAAK,IAAI,GAAG,QAAQ,SAAS,QAAQ;CACnD,IAAI,0BAAU,IAAI,IAAwD;CAC1E,IAAI;CAEJ,MAAM,OAAO,OAAO,YAAwE;EAC1F,IAAI;EACJ,IAAI;GACF,QAAQ,MAAM,SAAS,QAAQ,KAAK,UAAU,MAAM,GAAG,CAAC;EAC1D,SAAS,OAAO;GACd,KAAK,MAAM,SAAS,SAClB,KAAK,MAAM,UAAU,MAAM,SACzB,OAAO,OAAO,KAAK;GAGvB;EACF;EACA,KAAK,MAAM,SAAS,SAClB,IAAI;GAEF,MAAM,QAAQ,OAAO,OAAO,MAAM,GAAG;GACrC,KAAK,MAAM,UAAU,MAAM,SACzB,OAAO,QAAQ,KAAK;EAExB,SAAS,OAAO;GACd,KAAK,MAAM,UAAU,MAAM,SACzB,OAAO,OAAO,KAAK;EAEvB;CAEJ;CAEA,MAAM,cAAoB;EACxB,QAAQ,KAAA;EACR,MAAM,UAAU,CAAC,GAAG,QAAQ,OAAO,CAAC;EACpC,0BAAU,IAAI,IAAI;EAClB,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS,OACnD,KAAU,QAAQ,MAAM,OAAO,QAAQ,KAAK,CAAC;CAEjD;CAEA,QAAQ,QAAQ;EACd,IAAI,SAAS,GAGX,QAAQ,YAAY,OAAO,MAAM,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,EAAA,CAAG;EAE1D,OAAO,IAAI,SAAqB,SAAS,WAAW;GAClD,MAAM,KAAK,MAAM,GAAG;GACpB,IAAI,QAAQ,QAAQ,IAAI,EAAE;GAC1B,IAAI,CAAC,OAAO;IACV,QAAQ;KAAE;KAAK,SAAS,CAAC;IAAE;IAC3B,QAAQ,IAAI,IAAI,KAAK;GACvB;GACA,MAAM,QAAQ,KAAK;IAAE;IAAS;GAAO,CAAC;GACtC,UAAU,WAAW,OAAO,QAAQ,QAAQ,CAAC;EAC/C,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"batch.js","names":[],"sources":["../../src/runtime/batch.ts"],"sourcesContent":["// Reads of many keys at once. In the browser, the calls of one moment, such\n// as the rows of a list that renders, become one call of a server function\n// with every key. The server renders the rows of a list one after another,\n// so there each call reads its own key at once.\n\nexport interface BatchOptions<K> {\n /**\n * What makes two calls the same key. Defaults to the key itself, and to\n * its JSON for an object.\n */\n key?: (key: K) => unknown;\n /** The most keys in one call. A larger batch becomes several calls. */\n limit?: number;\n /** How long a batch gathers calls, in milliseconds. Defaults to 0, until the next task. */\n wait?: number;\n}\n\ninterface Waiter<V> {\n resolve: (value: V) => void;\n reject: (error: unknown) => void;\n}\n\n/** True while the server answers a request, from `request.ts`. A symbol of the registry, so the browser has none. */\nconst IN_REQUEST = Symbol.for('brumate.inRequest');\n\n/** True on the server, or in a test while server code runs. */\nfunction onServer(): boolean {\n const inRequest = (globalThis as Record<symbol, (() => boolean) | undefined>)[IN_REQUEST];\n return typeof document === 'undefined' || inRequest?.() === true;\n}\n\nfunction identity(key: unknown): unknown {\n return key !== null && typeof key === 'object' ? JSON.stringify(key) : key;\n}\n\n/**\n * Gives a function of one key, whose calls in the same moment become one\n * call of `readMany` with every distinct key. Each call gets its value from\n * `lookup`, with what `readMany` returned and its key.\n *\n * A failed read rejects only the calls that it read for, and a `lookup` that\n * throws rejects only the calls of its key.\n */\nexport function batched<K, R, V>(\n readMany: (keys: K[]) => R | Promise<R>,\n lookup: (found: R, key: K) => V,\n options: BatchOptions<K> = {},\n): (key: K) => Promise<Awaited<V>> {\n const getKey = options.key ?? identity;\n const limit = Math.max(1, options.limit ?? Infinity);\n let pending = new Map<unknown, { key: K; waiters: Waiter<Awaited<V>>[] }>();\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n async function read(entries: { key: K; waiters: Waiter<Awaited<V>>[] }[]): Promise<void> {\n const keys: K[] = [];\n for (const entry of entries) {\n keys.push(entry.key);\n }\n let found: R;\n try {\n found = await readMany(keys);\n } catch (error) {\n for (const entry of entries) {\n for (const waiter of entry.waiters) {\n waiter.reject(error);\n }\n }\n return;\n }\n for (const entry of entries) {\n try {\n // A promise that `lookup` returns settles each call by itself.\n const value = lookup(found, entry.key) as Awaited<V>;\n for (const waiter of entry.waiters) {\n waiter.resolve(value);\n }\n } catch (error) {\n for (const waiter of entry.waiters) {\n waiter.reject(error);\n }\n }\n }\n }\n\n function flush(): void {\n timer = undefined;\n const entries = [...pending.values()];\n pending = new Map();\n for (let start = 0; start < entries.length; start += limit) {\n void read(entries.slice(start, start + limit));\n }\n }\n\n return (key) => {\n if (onServer()) {\n // One read for the key, at once, so it reads the event of the request and shares the\n // result of equal calls in the render.\n return (async () => lookup(await readMany([key]), key))() as Promise<Awaited<V>>;\n }\n return new Promise<Awaited<V>>((resolve, reject) => {\n const id = getKey(key);\n let entry = pending.get(id);\n if (!entry) {\n entry = { key, waiters: [] };\n pending.set(id, entry);\n }\n entry.waiters.push({ resolve, reject });\n timer ??= setTimeout(flush, options.wait ?? 0);\n });\n };\n}\n"],"mappings":";;AAuBA,MAAM,aAAa,OAAO,IAAI,mBAAmB;;AAGjD,SAAS,WAAoB;CAC3B,MAAM,YAAa,WAA2D;CAC9E,OAAO,OAAO,aAAa,eAAe,YAAY,MAAM;AAC9D;AAEA,SAAS,SAAS,KAAuB;CACvC,OAAO,QAAQ,QAAQ,OAAO,QAAQ,WAAW,KAAK,UAAU,GAAG,IAAI;AACzE;;;;;;;;;AAUA,SAAgB,QACd,UACA,QACA,UAA2B,CAAC,GACK;CACjC,MAAM,SAAS,QAAQ,OAAO;CAC9B,MAAM,QAAQ,KAAK,IAAI,GAAG,QAAQ,SAAS,QAAQ;CACnD,IAAI,0BAAU,IAAI,IAAwD;CAC1E,IAAI;CAEJ,eAAe,KAAK,SAAqE;EACvF,MAAM,OAAY,CAAC;EACnB,KAAK,MAAM,SAAS,SAClB,KAAK,KAAK,MAAM,GAAG;EAErB,IAAI;EACJ,IAAI;GACF,QAAQ,MAAM,SAAS,IAAI;EAC7B,SAAS,OAAO;GACd,KAAK,MAAM,SAAS,SAClB,KAAK,MAAM,UAAU,MAAM,SACzB,OAAO,OAAO,KAAK;GAGvB;EACF;EACA,KAAK,MAAM,SAAS,SAClB,IAAI;GAEF,MAAM,QAAQ,OAAO,OAAO,MAAM,GAAG;GACrC,KAAK,MAAM,UAAU,MAAM,SACzB,OAAO,QAAQ,KAAK;EAExB,SAAS,OAAO;GACd,KAAK,MAAM,UAAU,MAAM,SACzB,OAAO,OAAO,KAAK;EAEvB;CAEJ;CAEA,SAAS,QAAc;EACrB,QAAQ,KAAA;EACR,MAAM,UAAU,CAAC,GAAG,QAAQ,OAAO,CAAC;EACpC,0BAAU,IAAI,IAAI;EAClB,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS,OACnD,KAAU,QAAQ,MAAM,OAAO,QAAQ,KAAK,CAAC;CAEjD;CAEA,QAAQ,QAAQ;EACd,IAAI,SAAS,GAGX,QAAQ,YAAY,OAAO,MAAM,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,EAAA,CAAG;EAE1D,OAAO,IAAI,SAAqB,SAAS,WAAW;GAClD,MAAM,KAAK,OAAO,GAAG;GACrB,IAAI,QAAQ,QAAQ,IAAI,EAAE;GAC1B,IAAI,CAAC,OAAO;IACV,QAAQ;KAAE;KAAK,SAAS,CAAC;IAAE;IAC3B,QAAQ,IAAI,IAAI,KAAK;GACvB;GACA,MAAM,QAAQ,KAAK;IAAE;IAAS;GAAO,CAAC;GACtC,UAAU,WAAW,OAAO,QAAQ,QAAQ,CAAC;EAC/C,CAAC;CACH;AACF"}
@@ -1,5 +1,5 @@
1
- import { $ as offscreen, A as dispose, At as updated, B as handlerProp, C as children, Ct as text, D as createScope, Dt as update, E as content, Et as track, F as fill, G as leaveRoutes, H as init, I as forget, J as loadModule, K as list, L as get, M as effect, N as elementAt, O as deferInBrowser, Ot as updateContext, P as fail, Q as memo, R as guess, S as cells, St as submitAction, T as consumeContext, Tt as title, U as insert, V as hooks, W as leavePage, X as loader, Y as loadPart, Z as makeId, _ as attrs, _t as setSlots, a as DevtoolsHooks, at as remount, b as branch, bt as spread, c as Part, ct as reset, d as addHead, dt as scopeOf, et as pending, f as addPortal, ft as scopes, g as attr, gt as setOwner, h as asyncMemo, ht as setItem, i as DEVTOOLS, it as rekey, j as dynamic, jt as writeText, k as descendants, kt as updateRoute, l as Scope, lt as rpc, m as afterInsert, mt as setGlobal, n as Component, nt as prop, o as HiddenBody, ot as removeRoot, p as addStyle, pt as set, q as listOf, r as CoreOptions, rt as provideValue, s as LoadReason, st as removeScope, t as ClientModule, tt as portalTo, u as action, ut as rpcPrefix, v as binding, vt as setVar, w as component, wt as timed, x as build, xt as spreadProps, y as bindings, yt as skew, z as handle } from "../client-D0CqSxoO.js";
2
- import { S as vars, _ as raw, a as attribute, c as classAttribute, g as onAttribute, h as mergeAttributes, i as affix, t as Raw, u as escape } from "../html-Bq1rFxX_.js";
3
- import { i as FunctionReference, l as unbind, r as ElementReference, t as produce } from "../produce-D0V0ICkz.js";
4
1
  import { c as routeContext, o as createContext, s as navigationContext } from "../context-btHuB01Z.js";
5
- export { ClientModule, Component, CoreOptions, DEVTOOLS, DevtoolsHooks, ElementReference, FunctionReference, HiddenBody, LoadReason, Part, type Raw, Scope, action, addHead, addPortal, addStyle, affix, afterInsert, asyncMemo, attr, attribute, attrs, binding, bindings, branch, build, cells, children, classAttribute, component, consumeContext, content, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, effect, elementAt, escape, fail, fill, forget, get, guess, handle, handlerProp, hooks, init, insert, leavePage, leaveRoutes, list, listOf, loadModule, loadPart, loader, makeId, memo, mergeAttributes, navigationContext, offscreen, onAttribute, pending, portalTo, produce, prop, provideValue, raw, rekey, remount, removeRoot, removeScope, reset, routeContext, rpc, rpcPrefix, scopeOf, scopes, set, setGlobal, setItem, setOwner, setSlots, setVar, skew, spread, spreadProps, submitAction, text, timed, title, track, unbind, update, updateContext, updateRoute, updated, vars, writeText };
2
+ import { E as vars, _ as mergeAttributes, a as affix, d as escape, h as internal, l as classAttribute, n as Raw, o as attribute, v as onAttribute, x as raw } from "../html-Bw9Qwu6F.js";
3
+ import { c as SCOPE_IDS, d as unbind, t as produce } from "../produce-DIgHBVwL.js";
4
+ import { $ as attr, $t as HiddenBody, A as setContent, At as ClientModule, B as setOwner, Bt as skew, C as keepText, Ct as spread, D as putText, Dt as setGlobal, E as nodes, Et as provideValue, F as createScope, Ft as Scope, G as addPortal, Gt as dynamicNodes, H as prop, Ht as component, I as descendants, It as build, J as setVar, Jt as place, K as addStyle, Kt as elementAt, L as getScope, Lt as hooks, M as setSpread, Mt as DEVTOOLS, N as template, Nt as DevtoolsHooks, O as setAttr, Ot as updateContext, P as afterInsert, Pt as Part, Q as windowStart, Qt as insert, R as makeId, Rt as rpcPrefix, S as keep, St as rpc, T as markBlock, Tt as consumeContext, U as spreadProps, Ut as componentNodes, V as sink, Vt as Component, W as addHead, Wt as dynamic, X as toList, Xt as setSlots, Y as list, Yt as setItem, Z as windowList, Zt as children, _ as appendText, _t as remount, a as cells, an as retag, at as writeText, b as fillBranch, bt as handle, c as isBound, ct as fail, d as resolve, dt as nameComment, en as branch, et as attrs, f as set, ft as dispose, g as title, gt as leaveRoutes, h as updated, ht as leavePage, i as bindings, in as reset, it as text, j as setOn, jt as CoreOptions, k as setAttrText, kt as updateRoute, l as memo, lt as loadModule, m as update, mt as init, n as asyncMemo, nn as offscreen, nt as portalTo, o as effect, ot as guess, p as timed, pt as forget, q as deferInBrowser, qt as foreignNodes, r as binding, rn as rekey, rt as restRef, s as get, st as track, t as loader, tn as fill, tt as content, u as pending, ut as loadPart, v as branchNodes, vt as removeRoot, w as listNodes, wt as submitAction, x as fillList, xt as handlerProp, y as clone, yt as action, z as removeScope, zt as scopes } from "../client-DBwL2wKQ.js";
5
+ export { type ClientModule, type Component, type CoreOptions, DEVTOOLS, type DevtoolsHooks, type HiddenBody, type Part, type Raw, type Scope, action, addHead, addPortal, addStyle, affix, afterInsert, appendText, asyncMemo, attr, attribute, attrs, binding, bindings, branch, branchNodes, build, cells, children, classAttribute, clone, component, componentNodes, consumeContext, content, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, dynamicNodes, effect, elementAt, escape, fail, fill, fillBranch, fillList, foreignNodes, forget, get, getScope, guess, handle, handlerProp, hooks, init, insert, internal, isBound, keep, keepText, leavePage, leaveRoutes, list, listNodes, loadModule, loadPart, loader, makeId, markBlock, memo, mergeAttributes, nameComment, navigationContext, nodes, offscreen, onAttribute, pending, place, portalTo, produce, prop, provideValue, putText, raw, rekey, remount, removeRoot, removeScope, reset, resolve, restRef, retag, routeContext, rpc, rpcPrefix, SCOPE_IDS as scopeIds, scopes, set, setAttr, setAttrText, setContent, setGlobal, setItem, setOn, setOwner, setSlots, setSpread, setVar, sink, skew, spread, spreadProps, submitAction, template, text, timed, title, toList, track, unbind, update, updateContext, updateRoute, updated, vars, windowList, windowStart, writeText };
@@ -1,5 +1,5 @@
1
- import { g as raw, h as onAttribute, i as attribute, l as escape, m as mergeAttributes, r as affix, s as classAttribute, x as vars } from "../html-mNTKzaDD.js";
2
- import { i as FunctionReference, p as unbind, r as ElementReference, t as produce } from "../produce-Doc91GkX.js";
1
+ import { T as vars, _ as onAttribute, a as attribute, b as raw, c as classAttribute, g as mergeAttributes, i as affix, m as internal, u as escape } from "../html-BtKRyi7g.js";
2
+ import { S as unbind, t as produce, u as SCOPE_IDS } from "../produce-B7X9ori9.js";
3
3
  import { a as routeContext, i as navigationContext, r as createContext } from "../context-CTiSzQRc.js";
4
- import { $ as removeScope, A as guess, B as loadModule, C as dynamic, Ct as writeText, D as fill, E as fail, F as insert, G as offscreen, H as loader, I as leavePage, J as prop, K as pending, L as leaveRoutes, M as handlerProp, N as hooks, O as forget, P as init, Q as removeRoot, R as list, S as dispose, St as updated, T as elementAt, U as makeId, V as loadPart, W as memo, X as rekey, Y as provideValue, Z as remount, _ as consumeContext, _t as title, a as addStyle, at as set, b as deferInBrowser, bt as updateContext, c as attr, ct as setOwner, d as bindings, dt as skew, et as reset, f as branch, ft as spread, g as component, gt as timed, h as children, ht as text, i as addPortal, it as scopes, j as handle, k as get, l as attrs, lt as setSlots, m as cells, mt as submitAction, n as action, nt as rpcPrefix, o as afterInsert, ot as setGlobal, p as build, pt as spreadProps, q as portalTo, r as addHead, rt as scopeOf, s as asyncMemo, st as setItem, t as DEVTOOLS, tt as rpc, u as binding, ut as setVar, v as content, vt as track, w as effect, x as descendants, xt as updateRoute, y as createScope, yt as update, z as listOf } from "../client-BD6XT-s5.js";
5
- export { DEVTOOLS, ElementReference, FunctionReference, action, addHead, addPortal, addStyle, affix, afterInsert, asyncMemo, attr, attribute, attrs, binding, bindings, branch, build, cells, children, classAttribute, component, consumeContext, content, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, effect, elementAt, escape, fail, fill, forget, get, guess, handle, handlerProp, hooks, init, insert, leavePage, leaveRoutes, list, listOf, loadModule, loadPart, loader, makeId, memo, mergeAttributes, navigationContext, offscreen, onAttribute, pending, portalTo, produce, prop, provideValue, raw, rekey, remount, removeRoot, removeScope, reset, routeContext, rpc, rpcPrefix, scopeOf, scopes, set, setGlobal, setItem, setOwner, setSlots, setVar, skew, spread, spreadProps, submitAction, text, timed, title, track, unbind, update, updateContext, updateRoute, updated, vars, writeText };
4
+ import { $ as forget, A as branchNodes, At as update, B as setAttr, Bt as makeId, C as dynamicNodes, Ct as get, D as setItem, Dt as resolve, E as place, Et as pending, F as keepText, Ft as title, G as template, Gt as loadPart, H as setContent, Ht as setOwner, I as listNodes, It as afterInsert, J as offscreen, Jt as build, K as branch, Kt as nameComment, L as markBlock, Lt as createScope, M as fillBranch, Mt as fail, N as fillList, Nt as children, O as setSlots, Ot as set, P as keep, Pt as insert, Q as dispose, Qt as skew, R as nodes, Rt as descendants, S as dynamic, St as effect, T as foreignNodes, Tt as memo, U as setOn, Ut as sink, V as setAttrText, Vt as removeScope, W as setSpread, Wt as loadModule, X as reset, Xt as rpcPrefix, Y as rekey, Yt as hooks, Z as retag, Zt as scopes, _ as writeText, _t as updateRoute, a as deferInBrowser, at as action, b as component, bt as bindings, c as toList, ct as rpc, d as attr, dt as guess, et as init, f as attrs, ft as track, g as text, gt as updateContext, h as restRef, ht as setGlobal, i as addStyle, it as removeRoot, j as clone, jt as updated, k as appendText, kt as timed, l as windowList, lt as spread, m as portalTo, mt as provideValue, n as addHead, nt as leaveRoutes, o as setVar, ot as handle, p as content, pt as consumeContext, q as fill, qt as DEVTOOLS, r as addPortal, rt as remount, s as list, st as handlerProp, t as loader, tt as leavePage, u as windowStart, ut as submitAction, v as prop, vt as asyncMemo, w as elementAt, wt as isBound, x as componentNodes, xt as cells, y as spreadProps, yt as binding, z as putText, zt as getScope } from "../client-BvDsC6Qr.js";
5
+ export { DEVTOOLS, action, addHead, addPortal, addStyle, affix, afterInsert, appendText, asyncMemo, attr, attribute, attrs, binding, bindings, branch, branchNodes, build, cells, children, classAttribute, clone, component, componentNodes, consumeContext, content, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, dynamicNodes, effect, elementAt, escape, fail, fill, fillBranch, fillList, foreignNodes, forget, get, getScope, guess, handle, handlerProp, hooks, init, insert, internal, isBound, keep, keepText, leavePage, leaveRoutes, list, listNodes, loadModule, loadPart, loader, makeId, markBlock, memo, mergeAttributes, nameComment, navigationContext, nodes, offscreen, onAttribute, pending, place, portalTo, produce, prop, provideValue, putText, raw, rekey, remount, removeRoot, removeScope, reset, resolve, restRef, retag, routeContext, rpc, rpcPrefix, SCOPE_IDS as scopeIds, scopes, set, setAttr, setAttrText, setContent, setGlobal, setItem, setOn, setOwner, setSlots, setSpread, setVar, sink, skew, spread, spreadProps, submitAction, template, text, timed, title, toList, track, unbind, update, updateContext, updateRoute, updated, vars, windowList, windowStart, writeText };
@@ -1,10 +1,17 @@
1
- import { Mt as NavigationReport, l as Scope } from "../client-D0CqSxoO.js";
2
- import { s as ScopeId } from "../produce-D0V0ICkz.js";
1
+ import { l as ScopeId } from "../produce-DIgHBVwL.js";
2
+ import { Ft as Scope, on as NavigationReport } from "../client-DBwL2wKQ.js";
3
+ //#region src/runtime/logo.d.ts
4
+ /**
5
+ * The logo of brumate: the pole and the bowl of a b, in outline, where the
6
+ * pole runs through the left of the bowl. The part they share is orange.
7
+ */
8
+ export declare const LOGO = "<svg viewBox=\"0 0 32 32\" width=\"100%\" height=\"100%\" aria-hidden=\"true\"><defs><linearGradient id=\"brumate-logo-fill\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0\" stop-color=\"#ffc38a\"/><stop offset=\".5\" stop-color=\"#ee7a3e\"/><stop offset=\"1\" stop-color=\"#e0445a\"/></linearGradient><clipPath id=\"brumate-logo-pole\"><rect x=\"7.5\" y=\"2.5\" width=\"8\" height=\"27\" rx=\"4\"/></clipPath></defs><circle cx=\"18\" cy=\"19.5\" r=\"10\" fill=\"url(#brumate-logo-fill)\" clip-path=\"url(#brumate-logo-pole)\"/><g fill=\"none\" stroke=\"#ece8e4\" stroke-width=\"2.2\"><rect x=\"7.5\" y=\"2.5\" width=\"8\" height=\"27\" rx=\"4\"/><circle cx=\"18\" cy=\"19.5\" r=\"10\"/></g></svg>";
9
+ //#endregion
3
10
  //#region src/runtime/devtools.d.ts
4
11
  /** Something that happened on the page, for the log of the panel. */
5
12
  export interface DevtoolsEntry {
6
13
  time: number;
7
- kind: "handler" | "part" | "write" | "call";
14
+ kind: "handler" | "write" | "call";
8
15
  text: string;
9
16
  /** The scope of a write, so the panel can mark it. */
10
17
  scope?: ScopeId;
@@ -54,22 +61,6 @@ export interface ErrorPayload {
54
61
  interface HotContext {
55
62
  on(event: string, listener: (payload: never) => void): void;
56
63
  }
57
- /** Code of a component that loaded, or is loading, for the Loading tab. */
58
- export interface LoadEntry {
59
- component: string;
60
- /** The part, such as `h3` or `update`, `entry` for the module, or `all` for a merged module. */
61
- part: string;
62
- /**
63
- * Why it loaded: `event`, `block`, `call`, `template`, `state`, `write`, `error`, `reset` or
64
- * `prop`, or a preload: `hover`, `visible`, `idle` or `eager`.
65
- */
66
- reason: string;
67
- start: number;
68
- end?: number;
69
- failed?: boolean;
70
- /** For a preload: true once something ran the code, such as a handler. */
71
- used: boolean;
72
- }
73
64
  /** A server function call, for the Timeline tab. */
74
65
  export interface CallTiming {
75
66
  name: string;
@@ -123,8 +114,6 @@ export interface BlockEntry {
123
114
  /** True while the devtools show its fallback in place of its body. */
124
115
  fallback?: boolean;
125
116
  }
126
- /** The loads that are preloads, which the Loading tab marks when nothing used them. */
127
- export declare const PRELOADS: ReadonlySet<string>;
128
117
  /** An effect or a `$client` callback of a scope, with how it ran. */
129
118
  export interface EffectEntry {
130
119
  scope: ScopeId;
@@ -150,8 +139,6 @@ export interface DevtoolsState {
150
139
  /** Runs a reference for an element, as the loader does for a trigger. */
151
140
  handle?: (element: Element, ref: string, event?: Event) => Promise<unknown>;
152
141
  log: DevtoolsEntry[];
153
- /** The code that loaded, by `component:part`, in the order it started. */
154
- loads: Map<string, LoadEntry>;
155
142
  /** The blocks of the page, by kind and ID. */
156
143
  blocks: Map<string, BlockEntry>;
157
144
  /** Asks the server for the body of a `#defer` block now. */
@@ -189,13 +176,8 @@ export interface DevtoolsState {
189
176
  /** Called after each change, while the panel is open. */
190
177
  changed?: () => void;
191
178
  }
192
- /**
193
- * The logo of brumate: the pole and the bowl of a b, in outline, where the
194
- * pole runs through the left of the bowl. The part they share is orange.
195
- */
196
- export declare const LOGO = "<svg viewBox=\"0 0 32 32\" width=\"100%\" height=\"100%\" aria-hidden=\"true\"><defs><linearGradient id=\"brumate-logo-fill\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0\" stop-color=\"#ffc38a\"/><stop offset=\".5\" stop-color=\"#ee7a3e\"/><stop offset=\"1\" stop-color=\"#e0445a\"/></linearGradient><clipPath id=\"brumate-logo-pole\"><rect x=\"7.5\" y=\"2.5\" width=\"8\" height=\"27\" rx=\"4\"/></clipPath></defs><circle cx=\"18\" cy=\"19.5\" r=\"10\" fill=\"url(#brumate-logo-fill)\" clip-path=\"url(#brumate-logo-pole)\"/><g fill=\"none\" stroke=\"#ece8e4\" stroke-width=\"2.2\"><rect x=\"7.5\" y=\"2.5\" width=\"8\" height=\"27\" rx=\"4\"/><circle cx=\"18\" cy=\"19.5\" r=\"10\"/></g></svg>";
197
179
  /** The root scope of a scope, whose `m` names its component. */
198
- export declare function rootOf(scope: Scope): Scope;
180
+ export declare function findRootScope(scope: Scope): Scope;
199
181
  /** A short text for a value in the log. */
200
182
  export declare function preview(value: unknown): string;
201
183
  /**
@@ -1 +1,3 @@
1
- export { t as LOGO, n as PRELOADS, r as installDevtools, i as preview, a as reportError, o as rootOf, s as scanBlocks } from "../devtools-CQgD7NPB.js";
1
+ import { t as LOGO } from "../logo-DQ_OYhBi.js";
2
+ import { a as scanBlocks, i as reportError, n as installDevtools, r as preview, t as findRootScope } from "../devtools-4uTPwR_v.js";
3
+ export { LOGO, findRootScope, installDevtools, preview, reportError, scanBlocks };
@@ -30,7 +30,7 @@ function defineEnv(schema, options = {}) {
30
30
  const result = props.validate(input);
31
31
  if (result instanceof Promise) throw new TypeError(`The schema of ${name} validates asynchronously. Use one that does not wait`);
32
32
  if (result.issues) {
33
- problems.push(input === void 0 ? `${name} is missing` : `${name} is invalid${isServer ? issuePaths(result.issues) : `: ${result.issues.map((issue) => issue.message).join("; ")}`}`);
33
+ problems.push(input === void 0 ? `${name} is missing` : `${name} is invalid${isServer ? issuePaths(result.issues) : `: ${issueMessages(result.issues)}`}`);
34
34
  continue;
35
35
  }
36
36
  values[name] = result.value;
@@ -42,13 +42,25 @@ function defineEnv(schema, options = {}) {
42
42
  if (problems.length > 0) throw new Error(`Environment variables: ${problems.join(". ")}`);
43
43
  return Object.freeze(values);
44
44
  }
45
+ /** The messages of the issues of a variable, joined. */
46
+ function issueMessages(issues) {
47
+ const messages = [];
48
+ for (const issue of issues) messages.push(issue.message);
49
+ return messages.join("; ");
50
+ }
45
51
  /**
46
52
  * Where the issues of a server variable are, such as ` at port`. The
47
53
  * messages of some schema libraries hold the value, which is a secret, so
48
54
  * the error leaves them out.
49
55
  */
50
56
  function issuePaths(issues) {
51
- const paths = issues.map((issue) => (issue.path ?? []).map((segment) => String(typeof segment === "object" ? segment.key : segment)).join(".")).filter((path) => path !== "");
57
+ const paths = [];
58
+ for (const issue of issues) {
59
+ const keys = [];
60
+ for (const segment of issue.path ?? []) keys.push(String(typeof segment === "object" ? segment.key : segment));
61
+ const path = keys.join(".");
62
+ if (path !== "") paths.push(path);
63
+ }
52
64
  return paths.length > 0 ? ` at ${paths.join(", ")}` : "";
53
65
  }
54
66
  /** The variables of the process, where there is one. */
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","names":[],"sources":["../../src/runtime/env.ts"],"sourcesContent":["// Environment variables, checked with a schema when the server starts. The\n// app declares them in one file, `src/env.ts`, split into server and public\n// values. Server values never reach the browser: the Vite plugin gives the\n// browser a copy of the file without them.\n\nimport { addSecret } from './secrets.ts';\nimport type { StandardSchemaV1 } from './standard-schema.ts';\n\n/** A schema for each variable, by name. */\nexport type EnvSchemas = Record<string, StandardSchemaV1>;\n\nexport interface EnvSchema {\n /** Variables that only the server reads, such as secrets. */\n server?: EnvSchemas;\n /** Variables that the browser reads too. The client build has their values. */\n public?: EnvSchemas;\n}\n\n/** The output of each schema of a group, by name. */\ntype Outputs<S extends EnvSchemas | undefined> = S extends EnvSchemas\n ? { readonly [K in keyof S]: StandardSchemaV1.InferOutput<S[K]> }\n : // oxlint-disable-next-line typescript/no-empty-object-type -- No variables add no fields.\n {};\n\n/** The values of the variables that a schema declares. */\nexport type Env<S extends EnvSchema> = Outputs<S['server']> & Outputs<S['public']>;\n\nexport interface EnvOptions {\n /**\n * Where the values come from. Defaults to `process.env`. The client\n * build passes the values of the public variables, read when it ran.\n */\n source?: Record<string, string | undefined>;\n}\n\n/**\n * Checks the environment variables of the app, and returns their values\n * with their types:\n *\n * ```ts\n * // src/env.ts\n * import { defineEnv } from 'brumate/env';\n * import * as v from 'valibot';\n *\n * export default defineEnv({\n * server: { DATABASE_URL: v.pipe(v.string(), v.url()) },\n * public: { SITE_NAME: v.optional(v.string(), 'Tracker') },\n * });\n * ```\n *\n * Every variable is checked when the file loads, so a server that starts\n * without a secret fails at once, with every missing or wrong variable in\n * the message. A schema must validate without waiting.\n */\nexport function defineEnv<const S extends EnvSchema>(schema: S, options: EnvOptions = {}): Env<S> {\n const source = options.source ?? processEnv();\n const values: Record<string, unknown> = {};\n const problems: string[] = [];\n for (const [group, isServer] of [\n [schema.server, true],\n [schema.public, false],\n ] as const) {\n for (const [name, variable] of Object.entries(group ?? {})) {\n const props = variable['~standard'];\n if (props?.version !== 1 || typeof props.validate !== 'function') {\n throw new TypeError(`The schema of ${name} is not a Standard Schema of version 1`);\n }\n const input = source[name];\n const result = props.validate(input);\n if (result instanceof Promise) {\n throw new TypeError(\n `The schema of ${name} validates asynchronously. Use one that does not wait`,\n );\n }\n if (result.issues) {\n problems.push(\n input === undefined\n ? `${name} is missing`\n : `${name} is invalid${isServer ? issuePaths(result.issues) : `: ${result.issues.map((issue) => issue.message).join('; ')}`}`,\n );\n continue;\n }\n values[name] = result.value;\n if (isServer) {\n addSecret(input);\n addSecret(result.value);\n }\n }\n }\n if (problems.length > 0) {\n throw new Error(`Environment variables: ${problems.join('. ')}`);\n }\n return Object.freeze(values) as Env<S>;\n}\n\n/**\n * Where the issues of a server variable are, such as ` at port`. The\n * messages of some schema libraries hold the value, which is a secret, so\n * the error leaves them out.\n */\nfunction issuePaths(issues: readonly StandardSchemaV1.Issue[]): string {\n const paths = issues\n .map((issue) =>\n (issue.path ?? [])\n .map((segment) => String(typeof segment === 'object' ? segment.key : segment))\n .join('.'),\n )\n .filter((path) => path !== '');\n return paths.length > 0 ? ` at ${paths.join(', ')}` : '';\n}\n\n/** The variables of the process, where there is one. */\nfunction processEnv(): Record<string, string | undefined> {\n const process = (globalThis as { process?: { env?: Record<string, string | undefined> } })\n .process;\n return process?.env ?? {};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,UAAqC,QAAW,UAAsB,CAAC,GAAW;CAChG,MAAM,SAAS,QAAQ,UAAU,WAAW;CAC5C,MAAM,SAAkC,CAAC;CACzC,MAAM,WAAqB,CAAC;CAC5B,KAAK,MAAM,CAAC,OAAO,aAAa,CAC9B,CAAC,OAAO,QAAQ,IAAI,GACpB,CAAC,OAAO,QAAQ,KAAK,CACvB,GACE,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,SAAS,CAAC,CAAC,GAAG;EAC1D,MAAM,QAAQ,SAAS;EACvB,IAAI,OAAO,YAAY,KAAK,OAAO,MAAM,aAAa,YACpD,MAAM,IAAI,UAAU,iBAAiB,KAAK,uCAAuC;EAEnF,MAAM,QAAQ,OAAO;EACrB,MAAM,SAAS,MAAM,SAAS,KAAK;EACnC,IAAI,kBAAkB,SACpB,MAAM,IAAI,UACR,iBAAiB,KAAK,sDACxB;EAEF,IAAI,OAAO,QAAQ;GACjB,SAAS,KACP,UAAU,KAAA,IACN,GAAG,KAAK,eACR,GAAG,KAAK,aAAa,WAAW,WAAW,OAAO,MAAM,IAAI,KAAK,OAAO,OAAO,KAAK,UAAU,MAAM,OAAO,CAAC,CAAC,KAAK,IAAI,KAC5H;GACA;EACF;EACA,OAAO,QAAQ,OAAO;EACtB,IAAI,UAAU;GACZ,UAAU,KAAK;GACf,UAAU,OAAO,KAAK;EACxB;CACF;CAEF,IAAI,SAAS,SAAS,GACpB,MAAM,IAAI,MAAM,0BAA0B,SAAS,KAAK,IAAI,GAAG;CAEjE,OAAO,OAAO,OAAO,MAAM;AAC7B;;;;;;AAOA,SAAS,WAAW,QAAmD;CACrE,MAAM,QAAQ,OACX,KAAK,WACH,MAAM,QAAQ,CAAC,EAAA,CACb,KAAK,YAAY,OAAO,OAAO,YAAY,WAAW,QAAQ,MAAM,OAAO,CAAC,CAAC,CAC7E,KAAK,GAAG,CACb,CAAC,CACA,QAAQ,SAAS,SAAS,EAAE;CAC/B,OAAO,MAAM,SAAS,IAAI,OAAO,MAAM,KAAK,IAAI,MAAM;AACxD;;AAGA,SAAS,aAAiD;CAGxD,OAFiB,WACd,SACa,OAAO,CAAC;AAC1B"}
1
+ {"version":3,"file":"env.js","names":[],"sources":["../../src/runtime/env.ts"],"sourcesContent":["// Environment variables, checked with a schema when the server starts. The\n// app declares them in one file, `src/env.ts`, split into server and public\n// values. Server values never reach the browser: the Vite plugin gives the\n// browser a copy of the file without them.\n\nimport { addSecret } from './secrets.ts';\nimport type { StandardSchemaV1 } from './standard-schema.ts';\n\n/** A schema for each variable, by name. */\nexport type EnvSchemas = Record<string, StandardSchemaV1>;\n\nexport interface EnvSchema {\n /** Variables that only the server reads, such as secrets. */\n server?: EnvSchemas;\n /** Variables that the browser reads too. The client build has their values. */\n public?: EnvSchemas;\n}\n\n/** The output of each schema of a group, by name. */\ntype Outputs<S extends EnvSchemas | undefined> = S extends EnvSchemas\n ? { readonly [K in keyof S]: StandardSchemaV1.InferOutput<S[K]> }\n : // oxlint-disable-next-line typescript/no-empty-object-type -- No variables add no fields.\n {};\n\n/** The values of the variables that a schema declares. */\nexport type Env<S extends EnvSchema> = Outputs<S['server']> & Outputs<S['public']>;\n\nexport interface EnvOptions {\n /**\n * Where the values come from. Defaults to `process.env`. The client\n * build passes the values of the public variables, read when it ran.\n */\n source?: Record<string, string | undefined>;\n}\n\n/**\n * Checks the environment variables of the app, and returns their values\n * with their types:\n *\n * ```ts\n * // src/env.ts\n * import { defineEnv } from 'brumate/env';\n * import * as v from 'valibot';\n *\n * export default defineEnv({\n * server: { DATABASE_URL: v.pipe(v.string(), v.url()) },\n * public: { SITE_NAME: v.optional(v.string(), 'Tracker') },\n * });\n * ```\n *\n * Every variable is checked when the file loads, so a server that starts\n * without a secret fails at once, with every missing or wrong variable in\n * the message. A schema must validate without waiting.\n */\nexport function defineEnv<const S extends EnvSchema>(schema: S, options: EnvOptions = {}): Env<S> {\n const source = options.source ?? processEnv();\n const values: Record<string, unknown> = {};\n const problems: string[] = [];\n for (const [group, isServer] of [\n [schema.server, true],\n [schema.public, false],\n ] as const) {\n for (const [name, variable] of Object.entries(group ?? {})) {\n const props = variable['~standard'];\n if (props?.version !== 1 || typeof props.validate !== 'function') {\n throw new TypeError(`The schema of ${name} is not a Standard Schema of version 1`);\n }\n const input = source[name];\n const result = props.validate(input);\n if (result instanceof Promise) {\n throw new TypeError(\n `The schema of ${name} validates asynchronously. Use one that does not wait`,\n );\n }\n if (result.issues) {\n problems.push(\n input === undefined\n ? `${name} is missing`\n : `${name} is invalid${isServer ? issuePaths(result.issues) : `: ${issueMessages(result.issues)}`}`,\n );\n continue;\n }\n values[name] = result.value;\n if (isServer) {\n addSecret(input);\n addSecret(result.value);\n }\n }\n }\n if (problems.length > 0) {\n throw new Error(`Environment variables: ${problems.join('. ')}`);\n }\n return Object.freeze(values) as Env<S>;\n}\n\n/** The messages of the issues of a variable, joined. */\nfunction issueMessages(issues: readonly StandardSchemaV1.Issue[]): string {\n const messages: string[] = [];\n for (const issue of issues) {\n messages.push(issue.message);\n }\n return messages.join('; ');\n}\n\n/**\n * Where the issues of a server variable are, such as ` at port`. The\n * messages of some schema libraries hold the value, which is a secret, so\n * the error leaves them out.\n */\nfunction issuePaths(issues: readonly StandardSchemaV1.Issue[]): string {\n const paths: string[] = [];\n for (const issue of issues) {\n const keys: string[] = [];\n for (const segment of issue.path ?? []) {\n keys.push(String(typeof segment === 'object' ? segment.key : segment));\n }\n const path = keys.join('.');\n if (path !== '') {\n paths.push(path);\n }\n }\n return paths.length > 0 ? ` at ${paths.join(', ')}` : '';\n}\n\n/** The variables of the process, where there is one. */\nfunction processEnv(): Record<string, string | undefined> {\n const process = (globalThis as { process?: { env?: Record<string, string | undefined> } })\n .process;\n return process?.env ?? {};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,UAAqC,QAAW,UAAsB,CAAC,GAAW;CAChG,MAAM,SAAS,QAAQ,UAAU,WAAW;CAC5C,MAAM,SAAkC,CAAC;CACzC,MAAM,WAAqB,CAAC;CAC5B,KAAK,MAAM,CAAC,OAAO,aAAa,CAC9B,CAAC,OAAO,QAAQ,IAAI,GACpB,CAAC,OAAO,QAAQ,KAAK,CACvB,GACE,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,SAAS,CAAC,CAAC,GAAG;EAC1D,MAAM,QAAQ,SAAS;EACvB,IAAI,OAAO,YAAY,KAAK,OAAO,MAAM,aAAa,YACpD,MAAM,IAAI,UAAU,iBAAiB,KAAK,uCAAuC;EAEnF,MAAM,QAAQ,OAAO;EACrB,MAAM,SAAS,MAAM,SAAS,KAAK;EACnC,IAAI,kBAAkB,SACpB,MAAM,IAAI,UACR,iBAAiB,KAAK,sDACxB;EAEF,IAAI,OAAO,QAAQ;GACjB,SAAS,KACP,UAAU,KAAA,IACN,GAAG,KAAK,eACR,GAAG,KAAK,aAAa,WAAW,WAAW,OAAO,MAAM,IAAI,KAAK,cAAc,OAAO,MAAM,KAClG;GACA;EACF;EACA,OAAO,QAAQ,OAAO;EACtB,IAAI,UAAU;GACZ,UAAU,KAAK;GACf,UAAU,OAAO,KAAK;EACxB;CACF;CAEF,IAAI,SAAS,SAAS,GACpB,MAAM,IAAI,MAAM,0BAA0B,SAAS,KAAK,IAAI,GAAG;CAEjE,OAAO,OAAO,OAAO,MAAM;AAC7B;;AAGA,SAAS,cAAc,QAAmD;CACxE,MAAM,WAAqB,CAAC;CAC5B,KAAK,MAAM,SAAS,QAClB,SAAS,KAAK,MAAM,OAAO;CAE7B,OAAO,SAAS,KAAK,IAAI;AAC3B;;;;;;AAOA,SAAS,WAAW,QAAmD;CACrE,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,OAAiB,CAAC;EACxB,KAAK,MAAM,WAAW,MAAM,QAAQ,CAAC,GACnC,KAAK,KAAK,OAAO,OAAO,YAAY,WAAW,QAAQ,MAAM,OAAO,CAAC;EAEvE,MAAM,OAAO,KAAK,KAAK,GAAG;EAC1B,IAAI,SAAS,IACX,MAAM,KAAK,IAAI;CAEnB;CACA,OAAO,MAAM,SAAS,IAAI,OAAO,MAAM,KAAK,IAAI,MAAM;AACxD;;AAGA,SAAS,aAAiD;CAGxD,OAFiB,WACd,SACa,OAAO,CAAC;AAC1B"}
@@ -4,8 +4,15 @@ export declare const KEY_NAMES: readonly string[];
4
4
  type Letter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
5
5
  type Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
6
6
  type FunctionKey = `F${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12}`;
7
+ /**
8
+ * A key of `prevent`: a key by its `event.key`, or that key with a modifier that must be held,
9
+ * such as `Mod+ArrowDown`. A key alone matches only while Ctrl, Meta and Alt are up, so the
10
+ * shortcuts of the browser, such as Cmd+Left or Alt+Left, keep their default. `Mod` is Ctrl or
11
+ * Meta.
12
+ */
13
+ export type KeyName = Key | `${"Mod" | "Ctrl" | "Meta" | "Alt"}+${Key}`;
7
14
  /** A key by its `event.key`: a named key, a letter or a digit. */
8
- export type KeyName = "Enter" | "Escape" | "Tab" | "Space" | "Backspace" | "Delete" | "Insert" | "ArrowUp" | "ArrowDown" | "ArrowLeft" | "ArrowRight" | "Home" | "End" | "PageUp" | "PageDown" | "ContextMenu" | FunctionKey | Letter | Uppercase<Letter> | Digit;
15
+ type Key = "Enter" | "Escape" | "Tab" | "Space" | "Backspace" | "Delete" | "Insert" | "ArrowUp" | "ArrowDown" | "ArrowLeft" | "ArrowRight" | "Home" | "End" | "PageUp" | "PageDown" | "ContextMenu" | FunctionKey | Letter | Uppercase<Letter> | Digit;
9
16
  /** The modifiers of a handler, which `spread` writes into `b-on`. A symbol of the registry. */
10
17
  export declare const MODIFIERS: unique symbol;
11
18
  /** A handler with the modifiers of its wrappers. */
@@ -37,6 +44,21 @@ export declare function once<H extends Handler>(handler: H): H;
37
44
  export declare function transition<H extends Handler>(handler: H, ...types: string[]): H;
38
45
  /** Runs the handler before the handlers of the elements inside, as a listener in the capture phase. */
39
46
  export declare function capture<H extends Handler>(handler: H): H;
47
+ /** The events that `cancelWhen` can cancel. Scroll-type events cannot be, for their listeners are passive. */
48
+ export type CancelableEvent = "click" | "submit";
49
+ /**
50
+ * Cancels an event of the element, or of an element inside it, before any handler of brumate
51
+ * runs, while `check` returns true. The document listener of brumate calls `preventDefault()` and
52
+ * runs no brumate handler for the event. It does not stop the event, so listeners that were added
53
+ * with `addEventListener` still run, and they can read `event.defaultPrevented`.
54
+ *
55
+ * Returns a function that removes the check.
56
+ *
57
+ * ```ts
58
+ * const stop = cancelWhen(form, 'submit', () => form.hasAttribute('data-pending'));
59
+ * ```
60
+ */
61
+ export declare function cancelWhen<T extends CancelableEvent>(element: Element, type: T, check: (event: HTMLElementEventMap[T]) => boolean): () => void;
40
62
  //#endregion
41
63
  export {};
42
64
  //# sourceMappingURL=events.d.ts.map
@@ -1 +1 @@
1
- export { t as KEY_NAMES, n as MODIFIERS, r as capture, i as once, a as prevent, o as stop, s as transition } from "../events-CSs7OwIC.js";
1
+ export { t as KEY_NAMES, n as MODIFIERS, r as cancelWhen, i as capture, a as once, o as prevent, s as stop, c as transition } from "../events-LgLdp1R7.js";
@@ -1,2 +1,2 @@
1
- import { A as intentValue, C as formErrorsOf, D as getAt, E as formatPath, F as validateForm, I as validateValues, M as parseIntent, N as parsePath, O as groupIssues, P as setAt, S as checkedSince, T as formValues, _ as PathSegment, a as FieldAttributes, b as applyLocalIntent, c as FormErrors, d as INTENT, f as Intent, g as MAX_INDEX, h as LocalChanges, i as Field, j as localSince, k as intentButton, l as FormIssue, m as ListItem, n as DEFAULT_SUBMIT, o as FieldState, p as IntentAttributes, r as FORBIDDEN, s as Fields, t as CheckedErrors, u as FormState, v as SubmissionResult, w as formFields, x as checkField, y as applyIntent } from "../forms-Cl21hkHt.js";
2
- export { CheckedErrors, DEFAULT_SUBMIT, FORBIDDEN, Field, FieldAttributes, FieldState, Fields, FormErrors, FormIssue, FormState, INTENT, Intent, IntentAttributes, ListItem, LocalChanges, MAX_INDEX, PathSegment, SubmissionResult, applyIntent, applyLocalIntent, checkField, checkedSince, formErrorsOf, formFields, formValues, formatPath, getAt, groupIssues, intentButton, intentValue, localSince, parseIntent, parsePath, setAt, validateForm, validateValues };
1
+ import { A as intentValue, C as formFields, D as getFormErrors, E as getAt, F as validateForm, I as validateValues, M as parseIntent, N as parsePath, O as groupIssues, P as setAt, S as checkedSince, T as formatPath, _ as PathSegment, a as FieldAttributes, b as applyLocalIntent, c as FormErrors, d as INTENT, f as Intent, g as MAX_INDEX, h as LocalChanges, i as Field, j as localSince, k as intentButton, l as FormIssue, m as ListItem, n as DEFAULT_SUBMIT, o as FieldState, p as IntentAttributes, r as FORBIDDEN, s as Fields, t as CheckedErrors, u as FormState, v as SubmissionResult, w as formValues, x as checkField, y as applyIntent } from "../forms-j1xPAR14.js";
2
+ export { CheckedErrors, DEFAULT_SUBMIT, FORBIDDEN, Field, FieldAttributes, FieldState, Fields, FormErrors, FormIssue, FormState, INTENT, Intent, IntentAttributes, ListItem, LocalChanges, MAX_INDEX, PathSegment, SubmissionResult, applyIntent, applyLocalIntent, checkField, checkedSince, formFields, formValues, formatPath, getAt, getFormErrors, groupIssues, intentButton, intentValue, localSince, parseIntent, parsePath, setAt, validateForm, validateValues };
@@ -1 +1 @@
1
- export { t as DEFAULT_SUBMIT, n as FORBIDDEN, r as INTENT, i as MAX_INDEX, a as applyIntent, o as applyLocalIntent, s as checkField, c as checkedSince, l as formErrorsOf, u as formFields, d as formValues, f as formatPath, p as getAt, m as groupIssues, h as intentButton, g as intentValue, _ as localSince, v as parseIntent, y as parsePath, b as setAt, x as validateForm, S as validateValues } from "../forms-Bg-CwGqX.js";
1
+ export { t as DEFAULT_SUBMIT, n as FORBIDDEN, r as INTENT, i as MAX_INDEX, a as applyIntent, o as applyLocalIntent, s as checkField, c as checkedSince, l as formFields, u as formValues, d as formatPath, f as getAt, p as getFormErrors, m as groupIssues, h as intentButton, g as intentValue, _ as localSince, v as parseIntent, y as parsePath, b as setAt, x as validateForm, S as validateValues } from "../forms-nXK7-Lv_.js";
@@ -1,4 +1,4 @@
1
- import { t as ClientModule } from "../client-D0CqSxoO.js";
1
+ import { At as ClientModule } from "../client-DBwL2wKQ.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 {
@@ -9,7 +9,9 @@ function hotLoad(hot, load) {
9
9
  const fresh = /* @__PURE__ */ new Map();
10
10
  hot.on("brumate:update", ({ updates, timestamp }) => {
11
11
  const changed = [];
12
+ const remounts = [];
12
13
  for (const update of updates) {
14
+ if (update.remount) remounts.push(update);
13
15
  if (update.css !== void 0) {
14
16
  const style = document.querySelector(`style[b-style="${CSS.escape(update.id)}"]`);
15
17
  if (style) style.textContent = update.css;
@@ -20,12 +22,13 @@ function hotLoad(hot, load) {
20
22
  }
21
23
  }
22
24
  if (changed.length > 0) document.dispatchEvent(new CustomEvent("brumate:hot", { detail: changed }));
23
- const remounts = updates.filter((update) => update.remount);
24
25
  if (changed.length === 0 && remounts.length === 0) return;
25
26
  import("./client.js").then(({ forget, remount }) => {
26
27
  forget(changed);
27
28
  if (remounts.length > 0) {
28
- remount(remounts.map((update) => Object.assign({ id: update.id }, update.remount)));
29
+ const moved = [];
30
+ for (const update of remounts) moved.push(Object.assign({ id: update.id }, update.remount));
31
+ remount(moved);
29
32
  document.dispatchEvent(new CustomEvent("brumate:reload"));
30
33
  }
31
34
  });
@@ -1 +1 @@
1
- {"version":3,"file":"hot.js","names":[],"sources":["../../src/runtime/hot.ts"],"sourcesContent":["// Hot updates on the dev server. When an edit of a component keeps its\n// markup, its slots and its update table, the plugin sends `brumate:update`\n// instead of reloading the page. New styles replace the old ones, and the\n// next event or update of the component loads its new code. State stays.\n//\n// When the markup changes, the page loads again through the client router,\n// and the signals of the component keep their values, by their names.\n\nimport type { ClientModule } from './client.ts';\n\n/** What `brumate:update` holds for each component that changed. */\nexport interface HotUpdate {\n id: string;\n /** The new styles, when they changed. */\n css?: string;\n /** The URL of the new client entry, when its code changed. */\n url?: string;\n /** Set when the markup changed, so the page renders again with the values of its signals. */\n remount?: Remount;\n}\n\n/** The slots of a component before and after an edit, by the ID of each scope in the component. */\nexport interface Remount {\n /** The names of the slots before the edit. */\n before: Record<number, string[]>;\n /** The names of the slots after the edit. */\n after: Record<number, string[]>;\n /** The names of the signals, whose values stay. */\n signals: string[];\n}\n\n/** The part of `import.meta.hot` that this module uses. */\nexport interface HotContext {\n on(\n event: 'brumate:update',\n listener: (data: { updates: HotUpdate[]; timestamp: number }) => void,\n ): void;\n}\n\n/**\n * Listens for updates of components, and returns a `load` for the loader\n * that loads the new code of a component that changed. Pass\n * `import.meta.hot`, which only the module that reads it gets.\n */\nexport function hotLoad(\n hot: HotContext | undefined,\n load: (id: string) => Promise<ClientModule>,\n): (id: string) => Promise<ClientModule> {\n if (!hot) {\n return load;\n }\n const fresh = new Map<string, string>();\n hot.on('brumate:update', ({ updates, timestamp }) => {\n const changed: string[] = [];\n for (const update of updates) {\n if (update.css !== undefined) {\n const style = document.querySelector(`style[b-style=\"${CSS.escape(update.id)}\"]`);\n if (style) {\n style.textContent = update.css;\n }\n }\n if (update.url) {\n fresh.set(update.id, `${update.url}${update.url.includes('?') ? '&' : '?'}t=${timestamp}`);\n changed.push(update.id);\n }\n }\n if (changed.length > 0) {\n document.dispatchEvent(new CustomEvent('brumate:hot', { detail: changed }));\n }\n const remounts = updates.filter((update) => update.remount);\n if (changed.length === 0 && remounts.length === 0) {\n return;\n }\n // The core has the hot update code, which only this module calls, so builds leave it out.\n void import('./client.ts').then(({ forget, remount }) => {\n // The core forgets the old code of these components.\n forget(changed);\n if (remounts.length > 0) {\n // The core keeps the values of the signals, and the loader loads the page again.\n remount(remounts.map((update) => Object.assign({ id: update.id }, update.remount!)));\n document.dispatchEvent(new CustomEvent('brumate:reload'));\n }\n });\n });\n return (id) => {\n const url = fresh.get(id);\n return url ? (import(/* @vite-ignore */ url) as Promise<ClientModule>) : load(id);\n };\n}\n"],"mappings":";;;;;;AA4CA,SAAgB,QACd,KACA,MACuC;CACvC,IAAI,CAAC,KACH,OAAO;CAET,MAAM,wBAAQ,IAAI,IAAoB;CACtC,IAAI,GAAG,mBAAmB,EAAE,SAAS,gBAAgB;EACnD,MAAM,UAAoB,CAAC;EAC3B,KAAK,MAAM,UAAU,SAAS;GAC5B,IAAI,OAAO,QAAQ,KAAA,GAAW;IAC5B,MAAM,QAAQ,SAAS,cAAc,kBAAkB,IAAI,OAAO,OAAO,EAAE,EAAE,GAAG;IAChF,IAAI,OACF,MAAM,cAAc,OAAO;GAE/B;GACA,IAAI,OAAO,KAAK;IACd,MAAM,IAAI,OAAO,IAAI,GAAG,OAAO,MAAM,OAAO,IAAI,SAAS,GAAG,IAAI,MAAM,IAAI,IAAI,WAAW;IACzF,QAAQ,KAAK,OAAO,EAAE;GACxB;EACF;EACA,IAAI,QAAQ,SAAS,GACnB,SAAS,cAAc,IAAI,YAAY,eAAe,EAAE,QAAQ,QAAQ,CAAC,CAAC;EAE5E,MAAM,WAAW,QAAQ,QAAQ,WAAW,OAAO,OAAO;EAC1D,IAAI,QAAQ,WAAW,KAAK,SAAS,WAAW,GAC9C;EAGF,OAAY,cAAc,CAAC,MAAM,EAAE,QAAQ,cAAc;GAEvD,OAAO,OAAO;GACd,IAAI,SAAS,SAAS,GAAG;IAEvB,QAAQ,SAAS,KAAK,WAAW,OAAO,OAAO,EAAE,IAAI,OAAO,GAAG,GAAG,OAAO,OAAQ,CAAC,CAAC;IACnF,SAAS,cAAc,IAAI,YAAY,gBAAgB,CAAC;GAC1D;EACF,CAAC;CACH,CAAC;CACD,QAAQ,OAAO;EACb,MAAM,MAAM,MAAM,IAAI,EAAE;EACxB,OAAO,MAAO;;GAA0B;IAAiC,KAAK,EAAE;CAClF;AACF"}
1
+ {"version":3,"file":"hot.js","names":[],"sources":["../../src/runtime/hot.ts"],"sourcesContent":["// Hot updates on the dev server. When an edit of a component keeps its\n// markup, its slots and its update table, the plugin sends `brumate:update`\n// instead of reloading the page. New styles replace the old ones, and the\n// next event or update of the component loads its new code. State stays.\n//\n// When the markup changes, the page loads again through the client router,\n// and the signals of the component keep their values, by their names.\n\nimport type { ClientModule } from './client.ts';\n\n/** What `brumate:update` holds for each component that changed. */\nexport interface HotUpdate {\n id: string;\n /** The new styles, when they changed. */\n css?: string;\n /** The URL of the new client entry, when its code changed. */\n url?: string;\n /** Set when the markup changed, so the page renders again with the values of its signals. */\n remount?: Remount;\n}\n\n/** The slots of a component before and after an edit, by the ID of each scope in the component. */\nexport interface Remount {\n /** The names of the slots before the edit. */\n before: Record<number, string[]>;\n /** The names of the slots after the edit. */\n after: Record<number, string[]>;\n /** The names of the signals, whose values stay. */\n signals: string[];\n}\n\n/** The part of `import.meta.hot` that this module uses. */\nexport interface HotContext {\n on(\n event: 'brumate:update',\n listener: (data: { updates: HotUpdate[]; timestamp: number }) => void,\n ): void;\n}\n\n/**\n * Listens for updates of components, and returns a `load` for the loader\n * that loads the new code of a component that changed. Pass\n * `import.meta.hot`, which only the module that reads it gets.\n */\nexport function hotLoad(\n hot: HotContext | undefined,\n load: (id: string) => Promise<ClientModule>,\n): (id: string) => Promise<ClientModule> {\n if (!hot) {\n return load;\n }\n const fresh = new Map<string, string>();\n hot.on('brumate:update', ({ updates, timestamp }) => {\n const changed: string[] = [];\n const remounts: HotUpdate[] = [];\n for (const update of updates) {\n if (update.remount) {\n remounts.push(update);\n }\n if (update.css !== undefined) {\n const style = document.querySelector(`style[b-style=\"${CSS.escape(update.id)}\"]`);\n if (style) {\n style.textContent = update.css;\n }\n }\n if (update.url) {\n fresh.set(update.id, `${update.url}${update.url.includes('?') ? '&' : '?'}t=${timestamp}`);\n changed.push(update.id);\n }\n }\n if (changed.length > 0) {\n document.dispatchEvent(new CustomEvent('brumate:hot', { detail: changed }));\n }\n if (changed.length === 0 && remounts.length === 0) {\n return;\n }\n // The core has the hot update code, which only this module calls, so builds leave it out.\n void import('./client.ts').then(({ forget, remount }) => {\n // The core forgets the old code of these components.\n forget(changed);\n if (remounts.length > 0) {\n // The core keeps the values of the signals, and the loader loads the page again.\n const moved: Parameters<typeof remount>[0] = [];\n for (const update of remounts) {\n moved.push(Object.assign({ id: update.id }, update.remount!));\n }\n remount(moved);\n document.dispatchEvent(new CustomEvent('brumate:reload'));\n }\n });\n });\n return (id) => {\n const url = fresh.get(id);\n return url ? (import(/* @vite-ignore */ url) as Promise<ClientModule>) : load(id);\n };\n}\n"],"mappings":";;;;;;AA4CA,SAAgB,QACd,KACA,MACuC;CACvC,IAAI,CAAC,KACH,OAAO;CAET,MAAM,wBAAQ,IAAI,IAAoB;CACtC,IAAI,GAAG,mBAAmB,EAAE,SAAS,gBAAgB;EACnD,MAAM,UAAoB,CAAC;EAC3B,MAAM,WAAwB,CAAC;EAC/B,KAAK,MAAM,UAAU,SAAS;GAC5B,IAAI,OAAO,SACT,SAAS,KAAK,MAAM;GAEtB,IAAI,OAAO,QAAQ,KAAA,GAAW;IAC5B,MAAM,QAAQ,SAAS,cAAc,kBAAkB,IAAI,OAAO,OAAO,EAAE,EAAE,GAAG;IAChF,IAAI,OACF,MAAM,cAAc,OAAO;GAE/B;GACA,IAAI,OAAO,KAAK;IACd,MAAM,IAAI,OAAO,IAAI,GAAG,OAAO,MAAM,OAAO,IAAI,SAAS,GAAG,IAAI,MAAM,IAAI,IAAI,WAAW;IACzF,QAAQ,KAAK,OAAO,EAAE;GACxB;EACF;EACA,IAAI,QAAQ,SAAS,GACnB,SAAS,cAAc,IAAI,YAAY,eAAe,EAAE,QAAQ,QAAQ,CAAC,CAAC;EAE5E,IAAI,QAAQ,WAAW,KAAK,SAAS,WAAW,GAC9C;EAGF,OAAY,cAAc,CAAC,MAAM,EAAE,QAAQ,cAAc;GAEvD,OAAO,OAAO;GACd,IAAI,SAAS,SAAS,GAAG;IAEvB,MAAM,QAAuC,CAAC;IAC9C,KAAK,MAAM,UAAU,UACnB,MAAM,KAAK,OAAO,OAAO,EAAE,IAAI,OAAO,GAAG,GAAG,OAAO,OAAQ,CAAC;IAE9D,QAAQ,KAAK;IACb,SAAS,cAAc,IAAI,YAAY,gBAAgB,CAAC;GAC1D;EACF,CAAC;CACH,CAAC;CACD,QAAQ,OAAO;EACb,MAAM,MAAM,MAAM,IAAI,EAAE;EACxB,OAAO,MAAO;;GAA0B;IAAiC,KAAK,EAAE;CAClF;AACF"}
@@ -1,2 +1,2 @@
1
- import { S as vars, _ as raw, a as attribute, b as styleElement, c as classAttribute, d as escapeAttribute, f as handlerEntry, g as onAttribute, h as mergeAttributes, i as affix, l as classValue, m as isRaw, n as VOID_ELEMENTS, o as attributeText, p as insertValue, r as actionAttributes, s as bindEntry, t as Raw, u as escape, v as rawHTML, x as textValue, y as spread } from "../html-Bq1rFxX_.js";
2
- export { Raw, VOID_ELEMENTS, actionAttributes, affix, attribute, attributeText, bindEntry, classAttribute, classValue, escape, escapeAttribute, handlerEntry, insertValue, isRaw, mergeAttributes, onAttribute, raw, rawHTML, spread, styleElement, textValue, vars };
1
+ import { C as spread, E as vars, S as rawHTML, T as textValue, _ as mergeAttributes, a as affix, b as ownValue, c as bindEntry, d as escape, f as escapeAttribute, g as isRaw, h as internal, i as actionAttributes, l as classAttribute, m as insertValue, n as Raw, o as attribute, p as handlerEntry, r as VOID_ELEMENTS, s as attributeText, t as Internal, u as classValue, v as onAttribute, w as styleElement, x as raw, y as onValue } from "../html-Bw9Qwu6F.js";
2
+ export { Internal, Raw, VOID_ELEMENTS, actionAttributes, affix, attribute, attributeText, bindEntry, classAttribute, classValue, escape, escapeAttribute, handlerEntry, insertValue, internal, isRaw, mergeAttributes, onAttribute, onValue, ownValue, raw, rawHTML, spread, styleElement, textValue, vars };
@@ -1 +1 @@
1
- export { t as VOID_ELEMENTS, n as actionAttributes, r as affix, i as attribute, a as attributeText, o as bindEntry, s as classAttribute, c as classValue, l as escape, u as escapeAttribute, d as handlerEntry, f as insertValue, p as isRaw, m as mergeAttributes, h as onAttribute, g as raw, _ as rawHTML, v as spread, y as styleElement, b as textValue, x as vars } from "../html-mNTKzaDD.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 isRaw, g as mergeAttributes, _ as onAttribute, v as onValue, y as ownValue, b as raw, x as rawHTML, S as spread, C as styleElement, w as textValue, T as vars } from "../html-BtKRyi7g.js";
@@ -1,5 +1,5 @@
1
- import { n as NavigateOptions, t as LoaderOptions } from "../boot-C25Sa6vq.js";
2
- import { t as startWithoutNavigation } from "../static-loader-Drpr0AzI.js";
1
+ import { n as NavigateOptions, t as LoaderOptions } from "../boot-DLlRmD9z.js";
2
+ import { t as startWithoutNavigation } from "../static-loader-BGgdp_Y5.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-nZssh66R.js";
2
- import { t as start } from "../loader-Dos_3NP0.js";
1
+ import { t as startWithoutNavigation } from "../static-loader-BZR17hSw.js";
2
+ import { t as start } from "../loader-BjKGJzLN.js";
3
3
  export { start, startWithoutNavigation };
@@ -9,7 +9,10 @@ function href(path, ...[params]) {
9
9
  return path.replace(/\[(\.\.\.)?([^\]]+)\]/g, (_, rest, name) => {
10
10
  const value = values[name];
11
11
  if (value === void 0 || value === "") throw new Error(`The param ${name} of ${path} is missing`);
12
- return rest ? String(value).split("/").map(encodeURIComponent).join("/") : encodeURIComponent(String(value));
12
+ if (!rest) return encodeURIComponent(String(value));
13
+ const parts = [];
14
+ for (const part of String(value).split("/")) parts.push(encodeURIComponent(part));
15
+ return parts.join("/");
13
16
  });
14
17
  }
15
18
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"routes.js","names":[],"sources":["../../src/runtime/routes.ts"],"sourcesContent":["// Links to routes, checked against the route files. The Vite plugin writes\n// the paths into `Routes` in a declaration file, such as\n// `src/brumate-routes.d.ts`.\n\n/**\n * The paths of the routes, with their params, such as\n * `'/todos/[id]': { id: string }`. The Vite plugin adds them.\n */\n// oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type -- Declaration files add the routes.\nexport interface Routes {}\n\n/** A route path, such as `/todos/[id]`. Any string while no routes are declared. */\nexport type RoutePath = [keyof Routes] extends [never] ? string : keyof Routes & string;\n\n/** The params of a route path, such as `{ id: string }` for `/todos/[id]`. */\nexport type RouteParams<P extends RoutePath> = P extends keyof Routes\n ? Routes[P]\n : Record<string, string>;\n\n/** The arguments after the path: none for a path without params. */\ntype ParamsArgument<P extends RoutePath> = [keyof RouteParams<P>] extends [never]\n ? [params?: RouteParams<P>]\n : [params: RouteParams<P>];\n\n/**\n * The URL of a route, with its params in place:\n * `href('/todos/[id]', { id: '3' })` is `/todos/3`. A rest param, such as\n * `[...path]`, keeps its slashes.\n */\nexport function href<P extends RoutePath>(path: P, ...[params]: ParamsArgument<P>): string {\n const values = (params ?? {}) as Record<string, string>;\n return path.replace(/\\[(\\.\\.\\.)?([^\\]]+)\\]/g, (_, rest: string | undefined, name: string) => {\n const value = values[name];\n if (value === undefined || value === '') {\n throw new Error(`The param ${name} of ${path} is missing`);\n }\n return rest\n ? String(value).split('/').map(encodeURIComponent).join('/')\n : encodeURIComponent(String(value));\n });\n}\n\nexport interface NavigateOptions {\n /** Replaces the current entry of the history instead of adding one. */\n replace?: boolean;\n /** Scrolls to the top of the new page, or to its hash. Defaults to true. False keeps the place. */\n scroll?: boolean;\n}\n\n/**\n * Loads a page as a link does: the layouts that stay keep their state. It\n * returns when the page shows. A URL of another origin, or a page without\n * the loader, loads in full.\n *\n * ```ts\n * await navigate(href('/issues/[id]', { id: issue.id }));\n * navigate(`?q=${query}`, { replace: true });\n * ```\n */\nexport function navigate(to: string, options: NavigateOptions = {}): Promise<void> {\n const url = new URL(to, location.href);\n // A `javascript:` URL would run its script, so only web pages load.\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n return Promise.reject(new TypeError(`navigate loads http and https URLs, not ${url.protocol}`));\n }\n if (url.origin !== location.origin) {\n location.assign(url.href);\n return new Promise(() => {});\n }\n return new Promise((resolve) => {\n const event = new CustomEvent('brumate:navigate', {\n cancelable: true,\n detail: {\n url: url.href,\n replace: options.replace === true,\n scroll: options.scroll !== false,\n done: resolve,\n },\n });\n // The loader answers the event. Without it, the page loads in full.\n if (document.dispatchEvent(event)) {\n location.assign(url.href);\n }\n });\n}\n"],"mappings":";;;;;;AA6BA,SAAgB,KAA0B,MAAS,GAAG,CAAC,SAAoC;CACzF,MAAM,SAAU,UAAU,CAAC;CAC3B,OAAO,KAAK,QAAQ,2BAA2B,GAAG,MAA0B,SAAiB;EAC3F,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAA,KAAa,UAAU,IACnC,MAAM,IAAI,MAAM,aAAa,KAAK,MAAM,KAAK,YAAY;EAE3D,OAAO,OACH,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,KAAK,GAAG,IACzD,mBAAmB,OAAO,KAAK,CAAC;CACtC,CAAC;AACH;;;;;;;;;;;AAmBA,SAAgB,SAAS,IAAY,UAA2B,CAAC,GAAkB;CACjF,MAAM,MAAM,IAAI,IAAI,IAAI,SAAS,IAAI;CAErC,IAAI,IAAI,aAAa,WAAW,IAAI,aAAa,UAC/C,OAAO,QAAQ,uBAAO,IAAI,UAAU,2CAA2C,IAAI,UAAU,CAAC;CAEhG,IAAI,IAAI,WAAW,SAAS,QAAQ;EAClC,SAAS,OAAO,IAAI,IAAI;EACxB,OAAO,IAAI,cAAc,CAAC,CAAC;CAC7B;CACA,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,QAAQ,IAAI,YAAY,oBAAoB;GAChD,YAAY;GACZ,QAAQ;IACN,KAAK,IAAI;IACT,SAAS,QAAQ,YAAY;IAC7B,QAAQ,QAAQ,WAAW;IAC3B,MAAM;GACR;EACF,CAAC;EAED,IAAI,SAAS,cAAc,KAAK,GAC9B,SAAS,OAAO,IAAI,IAAI;CAE5B,CAAC;AACH"}
1
+ {"version":3,"file":"routes.js","names":[],"sources":["../../src/runtime/routes.ts"],"sourcesContent":["// Links to routes, checked against the route files. The Vite plugin writes\n// the paths into `Routes` in a declaration file, such as\n// `src/brumate-routes.d.ts`.\n\n/**\n * The paths of the routes, with their params, such as\n * `'/todos/[id]': { id: string }`. The Vite plugin adds them.\n */\n// oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type -- Declaration files add the routes.\nexport interface Routes {}\n\n/** A route path, such as `/todos/[id]`. Any string while no routes are declared. */\nexport type RoutePath = [keyof Routes] extends [never] ? string : keyof Routes & string;\n\n/** The params of a route path, such as `{ id: string }` for `/todos/[id]`. */\nexport type RouteParams<P extends RoutePath> = P extends keyof Routes\n ? Routes[P]\n : Record<string, string>;\n\n/** The arguments after the path: none for a path without params. */\ntype ParamsArgument<P extends RoutePath> = [keyof RouteParams<P>] extends [never]\n ? [params?: RouteParams<P>]\n : [params: RouteParams<P>];\n\n/**\n * The URL of a route, with its params in place:\n * `href('/todos/[id]', { id: '3' })` is `/todos/3`. A rest param, such as\n * `[...path]`, keeps its slashes.\n */\nexport function href<P extends RoutePath>(path: P, ...[params]: ParamsArgument<P>): string {\n const values = (params ?? {}) as Record<string, string>;\n return path.replace(/\\[(\\.\\.\\.)?([^\\]]+)\\]/g, (_, rest: string | undefined, name: string) => {\n const value = values[name];\n if (value === undefined || value === '') {\n throw new Error(`The param ${name} of ${path} is missing`);\n }\n if (!rest) {\n return encodeURIComponent(String(value));\n }\n const parts: string[] = [];\n for (const part of String(value).split('/')) {\n parts.push(encodeURIComponent(part));\n }\n return parts.join('/');\n });\n}\n\nexport interface NavigateOptions {\n /** Replaces the current entry of the history instead of adding one. */\n replace?: boolean;\n /** Scrolls to the top of the new page, or to its hash. Defaults to true. False keeps the place. */\n scroll?: boolean;\n}\n\n/**\n * Loads a page as a link does: the layouts that stay keep their state. It\n * returns when the page shows. A URL of another origin, or a page without\n * the loader, loads in full.\n *\n * ```ts\n * await navigate(href('/issues/[id]', { id: issue.id }));\n * navigate(`?q=${query}`, { replace: true });\n * ```\n */\nexport function navigate(to: string, options: NavigateOptions = {}): Promise<void> {\n const url = new URL(to, location.href);\n // A `javascript:` URL would run its script, so only web pages load.\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n return Promise.reject(new TypeError(`navigate loads http and https URLs, not ${url.protocol}`));\n }\n if (url.origin !== location.origin) {\n location.assign(url.href);\n return new Promise(() => {});\n }\n return new Promise((resolve) => {\n const event = new CustomEvent('brumate:navigate', {\n cancelable: true,\n detail: {\n url: url.href,\n replace: options.replace === true,\n scroll: options.scroll !== false,\n done: resolve,\n },\n });\n // The loader answers the event. Without it, the page loads in full.\n if (document.dispatchEvent(event)) {\n location.assign(url.href);\n }\n });\n}\n"],"mappings":";;;;;;AA6BA,SAAgB,KAA0B,MAAS,GAAG,CAAC,SAAoC;CACzF,MAAM,SAAU,UAAU,CAAC;CAC3B,OAAO,KAAK,QAAQ,2BAA2B,GAAG,MAA0B,SAAiB;EAC3F,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAA,KAAa,UAAU,IACnC,MAAM,IAAI,MAAM,aAAa,KAAK,MAAM,KAAK,YAAY;EAE3D,IAAI,CAAC,MACH,OAAO,mBAAmB,OAAO,KAAK,CAAC;EAEzC,MAAM,QAAkB,CAAC;EACzB,KAAK,MAAM,QAAQ,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,GACxC,MAAM,KAAK,mBAAmB,IAAI,CAAC;EAErC,OAAO,MAAM,KAAK,GAAG;CACvB,CAAC;AACH;;;;;;;;;;;AAmBA,SAAgB,SAAS,IAAY,UAA2B,CAAC,GAAkB;CACjF,MAAM,MAAM,IAAI,IAAI,IAAI,SAAS,IAAI;CAErC,IAAI,IAAI,aAAa,WAAW,IAAI,aAAa,UAC/C,OAAO,QAAQ,uBAAO,IAAI,UAAU,2CAA2C,IAAI,UAAU,CAAC;CAEhG,IAAI,IAAI,WAAW,SAAS,QAAQ;EAClC,SAAS,OAAO,IAAI,IAAI;EACxB,OAAO,IAAI,cAAc,CAAC,CAAC;CAC7B;CACA,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,QAAQ,IAAI,YAAY,oBAAoB;GAChD,YAAY;GACZ,QAAQ;IACN,KAAK,IAAI;IACT,SAAS,QAAQ,YAAY;IAC7B,QAAQ,QAAQ,WAAW;IAC3B,MAAM;GACR;EACF,CAAC;EAED,IAAI,SAAS,cAAc,KAAK,GAC9B,SAAS,OAAO,IAAI,IAAI;CAE5B,CAAC;AACH"}
@@ -1,7 +1,7 @@
1
- import { S as vars, _ as raw, a as attribute, c as classAttribute, d as escapeAttribute, g as onAttribute, h as mergeAttributes, i as affix, t as Raw, u as escape } from "../html-Bq1rFxX_.js";
2
- import { c as ScopeState, i as FunctionReference, l as unbind, o as PageState, r as ElementReference, s as ScopeId, t as produce, u as useSerialEntry } from "../produce-D0V0ICkz.js";
3
1
  import { a as Route, c as routeContext, o as createContext, r as NavigationState, s as navigationContext } from "../context-btHuB01Z.js";
2
+ import { E as vars, _ as mergeAttributes, a as affix, d as escape, f as escapeAttribute, h as internal, l as classAttribute, n as Raw, o as attribute, v as onAttribute, x as raw } from "../html-Bw9Qwu6F.js";
3
+ import { d as unbind, f as useSerialEntry, i as FunctionReference, l as ScopeId, o as PageState, r as ElementReference, t as produce, u as ScopeState } from "../produce-DIgHBVwL.js";
4
4
  import { t as StandardSchemaV1 } from "../standard-schema-BNY82yX3.js";
5
- import { f as Intent, v as SubmissionResult } from "../forms-Cl21hkHt.js";
6
- import { $ as setCacheStore, $t as serializeCookie, A as isCrossSite, At as RouteMatch, B as stateScript, Bt as RequestKind, C as children, Ct as parseForm, D as handleRoute, Dt as Loader, E as handleRequest, Et as Handler, F as ready, Ft as Locals, G as waitAll, Gt as isRedirect, H as streamParts, Ht as dedupe, I as render, It as Redirect, J as CacheStore, Jt as CookieOptions, K as IdempotentOptions, Kt as redirect, L as renderToStream, Lt as RequestCall, M as memo, Mt as RouteView, N as packState, Nt as matchRoute, O as inlineBodies, Ot as Middleware, P as read, Pt as EntryMiddleware, Q as revalidate, Qt as parseCookies, R as settled, Rt as RequestEvent, S as binding, St as parse, T as dynamic, Tt as EndpointLoader, U as streamState, Ut as defineMiddleware, V as stateValue, Vt as ServerError, W as wait, Wt as getEvent, X as cached, Xt as SessionOptions, Y as CachedOptions, Yt as Session, Z as memoryStore, Zt as createSession, _ as StateAttributes, _t as parseSubmission, a as ItemSource, at as RateLimitOptions, b as action, bt as ValidationIssue, c as Memo, ct as clientAddress, d as RenderOptions, dt as FailedSubmission, en as toNodeHeaders, et as storageStore, f as RenderResult, ft as IntentSubmission, g as ScopeEntry, gt as SuccessfulSubmission, h as RouteOptions, ht as SubmissionOptions, i as DocumentOptions, it as RateLimitMiddleware, j as lazy, jt as RouteNode, k as insert, kt as MiddlewareLoader, l as NotReady, lt as configureRateLimit, m as RevealOrder, mt as Submission, n as Context, nt as RateLimitConfig, o as Lazy, ot as RateLimitStore, p as RequestOptions, pt as ReplyOptions, q as idempotent, qt as withEvent, r as DeferTarget, rt as RateLimitError, s as Mark, st as Window, t as Component, tt as RateLimit, u as PageCache, ut as rateLimit, v as StateMap, vt as ParseResult, w as component, wt as safeParse, x as actionResult, xt as fieldErrors, y as StreamOptions, yt as ValidationError, z as spread, zt as RequestEventOptions } from "../server-DuFYRXrd.js";
7
- export { type CacheStore, type CachedOptions, 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 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, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, getEvent, handleRequest, handleRoute, idempotent, inlineBodies, insert, 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, serializeCookie, setCacheStore, settled, spread, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };
5
+ import { f as Intent, v as SubmissionResult } from "../forms-j1xPAR14.js";
6
+ import { $ as memoryStore, $t as createSession, A as insert, At as Middleware, B as spacerTag, Bt as RequestEvent, C as caught, Ct as fieldErrors, D as handleRequest, Dt as EndpointLoader, E as dynamic, Et as safeParse, F as read, Ft as matchRoute, G as streamState, Gt as defineMiddleware, H as stateScript, Ht as RequestKind, I as ready, It as EntryMiddleware, J as IdempotentOptions, Jt as redirect, K as wait, Kt as getEvent, L as render, Lt as Locals, M as lazy, Mt as RouteMatch, N as memo, Nt as RouteNode, O as handleRoute, Ot as Handler, P as packState, Pt as RouteView, Q as cached, Qt as SessionOptions, R as renderToStream, Rt as Redirect, S as binding, St as ValidationIssue, T as component, Tt as parseForm, U as stateValue, Ut as ServerError, V as spread, Vt as RequestEventOptions, W as streamParts, Wt as dedupe, X as CacheStore, Xt as CookieOptions, Y as idempotent, Yt as withEvent, Z as CachedOptions, Zt as Session, _ as StateAttributes, _t as SubmissionOptions, a as ItemSource, at as RateLimitError, b as action, bt as ParseResult, c as Memo, ct as RateLimitStore, d as RenderOptions, dt as configureRateLimit, en as parseCookies, et as revalidate, f as RenderResult, ft as rateLimit, g as ScopeEntry, gt as Submission, h as RouteOptions, ht as ReplyOptions, i as DocumentOptions, it as RateLimitConfig, j as isCrossSite, jt as MiddlewareLoader, k as inlineBodies, kt as Loader, l as NotReady, lt as Window, m as RevealOrder, mt as IntentSubmission, n as Context, nn as toNodeHeaders, nt as storageStore, o as Lazy, ot as RateLimitMiddleware, p as RequestOptions, pt as FailedSubmission, q as waitAll, qt as isRedirect, r as DeferTarget, rt as RateLimit, s as Mark, st as RateLimitOptions, t as Component, tn as serializeCookie, tt as setCacheStore, u as PageCache, ut as clientAddress, v as StateMap, vt as SuccessfulSubmission, w as children, wt as parse, x as actionResult, xt as ValidationError, y as StreamOptions, yt as parseSubmission, z as settled, zt as RequestCall } from "../server-BvPIg9pT.js";
7
+ export { type CacheStore, type CachedOptions, 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 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, serializeCookie, setCacheStore, settled, spacerTag, spread, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };