brumate 0.1.1 → 0.2.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 (108) hide show
  1. package/dist/{boot-DN1ZU8Hg.d.ts → boot-D-IdPy7B.d.ts} +24 -2
  2. package/dist/cli.js +2 -2
  3. package/dist/client-C0UCNL3J.js +1643 -0
  4. package/dist/client-C0UCNL3J.js.map +1 -0
  5. package/dist/{client-DwJInP_a.d.ts → client-MD0ZmcFR.d.ts} +101 -26
  6. package/dist/{client-routes-DakuM32C.js → client-routes-JTbGtukf.js} +28 -15
  7. package/dist/client-routes-JTbGtukf.js.map +1 -0
  8. package/dist/context-CTiSzQRc.js +27 -0
  9. package/dist/context-CTiSzQRc.js.map +1 -0
  10. package/dist/context-btHuB01Z.d.ts +42 -0
  11. package/dist/defer-D0bo1Gqx.js +52 -0
  12. package/dist/defer-D0bo1Gqx.js.map +1 -0
  13. package/dist/{devtools-BKjnHrnv.js → devtools-C50VH8gZ.js} +2 -2
  14. package/dist/devtools-C50VH8gZ.js.map +1 -0
  15. package/dist/{devtools-panel-AWOn0VK2.js → devtools-panel-AYjfwPhj.js} +4 -3
  16. package/dist/devtools-panel-AYjfwPhj.js.map +1 -0
  17. package/dist/events-BKWRqtMg.js +52 -0
  18. package/dist/events-BKWRqtMg.js.map +1 -0
  19. package/dist/{files-DdT84mPy.js → files-Bnn1JqHx.js} +18 -3
  20. package/dist/files-Bnn1JqHx.js.map +1 -0
  21. package/dist/{html-DEeoepg3.js → html-bHZbkK-h.js} +26 -8
  22. package/dist/html-bHZbkK-h.js.map +1 -0
  23. package/dist/{html-Du8jY2Cc.d.ts → html-y1q7-t7D.d.ts} +12 -5
  24. package/dist/index.d.ts +77 -29
  25. package/dist/index.js +12 -4
  26. package/dist/index.js.map +1 -1
  27. package/dist/{inspect-BPchdWbU.js → inspect-BJtACnQp.js} +784 -82
  28. package/dist/inspect-BJtACnQp.js.map +1 -0
  29. package/dist/{loader-Dc9OwY5I.js → loader-B18i3_-T.js} +46 -11
  30. package/dist/loader-B18i3_-T.js.map +1 -0
  31. package/dist/{navigate-CzLjnoPH.js → navigate-BwuZveDF.js} +71 -12
  32. package/dist/navigate-BwuZveDF.js.map +1 -0
  33. package/dist/{produce-BRGHP7e0.js → produce-CWfJ4byV.js} +43 -2
  34. package/dist/produce-CWfJ4byV.js.map +1 -0
  35. package/dist/{produce-CtZ32UGG.d.ts → produce-D4K7qpaL.d.ts} +23 -11
  36. package/dist/routes-BZNt7DSZ.d.ts +38 -0
  37. package/dist/{rpc-9fSqL_YK.js → rpc-B-Zkn6Ch.js} +24 -18
  38. package/dist/rpc-B-Zkn6Ch.js.map +1 -0
  39. package/dist/runtime/batch.d.ts +23 -0
  40. package/dist/runtime/batch.js +69 -0
  41. package/dist/runtime/batch.js.map +1 -0
  42. package/dist/runtime/client.d.ts +5 -5
  43. package/dist/runtime/client.js +5 -1345
  44. package/dist/runtime/context.d.ts +2 -2
  45. package/dist/runtime/context.js +1 -1
  46. package/dist/runtime/devtools.d.ts +5 -4
  47. package/dist/runtime/devtools.js +1 -1
  48. package/dist/runtime/env.d.ts +44 -0
  49. package/dist/runtime/env.js +61 -0
  50. package/dist/runtime/env.js.map +1 -0
  51. package/dist/runtime/events.d.ts +27 -0
  52. package/dist/runtime/events.js +1 -0
  53. package/dist/runtime/hot.d.ts +1 -1
  54. package/dist/runtime/html.d.ts +2 -2
  55. package/dist/runtime/html.js +1 -1
  56. package/dist/runtime/loader.d.ts +2 -2
  57. package/dist/runtime/loader.js +2 -2
  58. package/dist/runtime/routes.d.ts +2 -21
  59. package/dist/runtime/routes.js +31 -1
  60. package/dist/runtime/routes.js.map +1 -1
  61. package/dist/runtime/server.d.ts +6 -5
  62. package/dist/runtime/server.js +5 -6
  63. package/dist/runtime/signals.d.ts +22 -1
  64. package/dist/runtime/signals.js +29 -1
  65. package/dist/runtime/signals.js.map +1 -1
  66. package/dist/runtime/static-loader.d.ts +2 -2
  67. package/dist/runtime/static-loader.js +1 -1
  68. package/dist/runtime/testing.d.ts +46 -5
  69. package/dist/runtime/testing.js +240 -33
  70. package/dist/runtime/testing.js.map +1 -1
  71. package/dist/secrets-BxagsJxJ.js +23 -0
  72. package/dist/secrets-BxagsJxJ.js.map +1 -0
  73. package/dist/{server-BxqjLUnV.d.ts → server-BA9SJ2Vm.d.ts} +544 -106
  74. package/dist/server-BqfM95r1.js +2762 -0
  75. package/dist/server-BqfM95r1.js.map +1 -0
  76. package/dist/skew-FRmAy9iy.js +49 -0
  77. package/dist/skew-FRmAy9iy.js.map +1 -0
  78. package/dist/standard-schema-BNY82yX3.d.ts +63 -0
  79. package/dist/{static-loader-BcFh4ebX.d.ts → static-loader-BzE9SRaj.d.ts} +2 -2
  80. package/dist/{static-loader-ClNkHZGn.js → static-loader-DOygOFj5.js} +52 -21
  81. package/dist/static-loader-DOygOFj5.js.map +1 -0
  82. package/dist/{stream-bgNCMcaA.js → stream-JaMHMdBD.js} +126 -61
  83. package/dist/stream-JaMHMdBD.js.map +1 -0
  84. package/dist/vite.d.ts +42 -1
  85. package/dist/vite.js +435 -55
  86. package/dist/vite.js.map +1 -1
  87. package/package.json +15 -2
  88. package/types.d.ts +9 -1
  89. package/dist/client-routes-DakuM32C.js.map +0 -1
  90. package/dist/context-BG8KCF3v.js +0 -15
  91. package/dist/context-BG8KCF3v.js.map +0 -1
  92. package/dist/context-aeo9esY9.d.ts +0 -16
  93. package/dist/devtools-BKjnHrnv.js.map +0 -1
  94. package/dist/devtools-panel-AWOn0VK2.js.map +0 -1
  95. package/dist/files-DdT84mPy.js.map +0 -1
  96. package/dist/html-DEeoepg3.js.map +0 -1
  97. package/dist/inspect-BPchdWbU.js.map +0 -1
  98. package/dist/loader-Dc9OwY5I.js.map +0 -1
  99. package/dist/navigate-CzLjnoPH.js.map +0 -1
  100. package/dist/produce-BRGHP7e0.js.map +0 -1
  101. package/dist/rpc-9fSqL_YK.js.map +0 -1
  102. package/dist/runtime/client.js.map +0 -1
  103. package/dist/server-DZsgnPKS.js +0 -1615
  104. package/dist/server-DZsgnPKS.js.map +0 -1
  105. package/dist/shared-CWYOd0H3.js +0 -40
  106. package/dist/shared-CWYOd0H3.js.map +0 -1
  107. package/dist/static-loader-ClNkHZGn.js.map +0 -1
  108. package/dist/stream-bgNCMcaA.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import { n as createContext, t as Context } from "../context-aeo9esY9.js";
2
- export { Context, createContext };
1
+ import { a as Route, c as routeContext, i as ROUTE_KEY, n as NAVIGATION_KEY, o as createContext, r as NavigationState, s as navigationContext, t as Context } from "../context-btHuB01Z.js";
2
+ export { Context, NAVIGATION_KEY, NavigationState, ROUTE_KEY, Route, createContext, navigationContext, routeContext };
@@ -1 +1 @@
1
- export { t as createContext } from "../context-BG8KCF3v.js";
1
+ export { t as NAVIGATION_KEY, n as ROUTE_KEY, r as createContext, i as navigationContext, a as routeContext } from "../context-CTiSzQRc.js";
@@ -1,4 +1,5 @@
1
- import { c as Scope } from "../client-DwJInP_a.js";
1
+ import { o as ScopeId } from "../produce-D4K7qpaL.js";
2
+ import { c as Scope } from "../client-MD0ZmcFR.js";
2
3
  //#region src/runtime/devtools.d.ts
3
4
  /** Something that happened on the page, for the log of the panel. */
4
5
  export interface DevtoolsEntry {
@@ -6,7 +7,7 @@ export interface DevtoolsEntry {
6
7
  kind: "handler" | "part" | "write" | "call";
7
8
  text: string;
8
9
  /** The scope of a write, so the panel can mark it. */
9
- scope?: number;
10
+ scope?: ScopeId;
10
11
  /** For a write: the component, the scope in the compiled component, and the slot. */
11
12
  write?: {
12
13
  component: string;
@@ -15,12 +16,12 @@ export interface DevtoolsEntry {
15
16
  };
16
17
  }
17
18
  export interface DevtoolsState {
18
- scopes?: Map<number, Scope>;
19
+ scopes?: Map<ScopeId, Scope>;
19
20
  /** Writes a slot, as a handler does, so the page updates. */
20
21
  set?: (scope: Scope, slot: number, value: unknown) => void;
21
22
  log: DevtoolsEntry[];
22
23
  /** The scopes written since the panel last drew, by scope ID. */
23
- written: Set<number>;
24
+ written: Set<ScopeId>;
24
25
  /** The URL prefix of the inspect endpoint of the dev server. */
25
26
  endpoint: string;
26
27
  /** Called after each change, while the panel is open. */
@@ -1 +1 @@
1
- export { t as installDevtools, n as preview, r as rootOf } from "../devtools-BKjnHrnv.js";
1
+ export { t as installDevtools, n as preview, r as rootOf } from "../devtools-C50VH8gZ.js";
@@ -0,0 +1,44 @@
1
+ import { t as StandardSchemaV1 } from "../standard-schema-BNY82yX3.js";
2
+ //#region src/runtime/env.d.ts
3
+ /** A schema for each variable, by name. */
4
+ export type EnvSchemas = Record<string, StandardSchemaV1>;
5
+ export interface EnvSchema {
6
+ /** Variables that only the server reads, such as secrets. */
7
+ server?: EnvSchemas;
8
+ /** Variables that the browser reads too. The client build has their values. */
9
+ public?: EnvSchemas;
10
+ }
11
+ /** The output of each schema of a group, by name. */
12
+ type Outputs<S extends EnvSchemas | undefined> = S extends EnvSchemas ? { readonly [K in keyof S]: StandardSchemaV1.InferOutput<S[K]>; } : {};
13
+ /** The values of the variables that a schema declares. */
14
+ export type Env<S extends EnvSchema> = Outputs<S["server"]> & Outputs<S["public"]>;
15
+ export interface EnvOptions {
16
+ /**
17
+ * Where the values come from. Defaults to `process.env`. The client
18
+ * build passes the values of the public variables, read when it ran.
19
+ */
20
+ source?: Record<string, string | undefined>;
21
+ }
22
+ /**
23
+ * Checks the environment variables of the app, and returns their values
24
+ * with their types:
25
+ *
26
+ * ```ts
27
+ * // src/env.ts
28
+ * import { defineEnv } from 'brumate/env';
29
+ * import * as v from 'valibot';
30
+ *
31
+ * export default defineEnv({
32
+ * server: { DATABASE_URL: v.pipe(v.string(), v.url()) },
33
+ * public: { SITE_NAME: v.optional(v.string(), 'Tracker') },
34
+ * });
35
+ * ```
36
+ *
37
+ * Every variable is checked when the file loads, so a server that starts
38
+ * without a secret fails at once, with every missing or wrong variable in
39
+ * the message. A schema must validate without waiting.
40
+ */
41
+ export declare function defineEnv<const S extends EnvSchema>(schema: S, options?: EnvOptions): Env<S>;
42
+ //#endregion
43
+ export {};
44
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { t as addSecret } from "../secrets-BxagsJxJ.js";
2
+ //#region src/runtime/env.ts
3
+ /**
4
+ * Checks the environment variables of the app, and returns their values
5
+ * with their types:
6
+ *
7
+ * ```ts
8
+ * // src/env.ts
9
+ * import { defineEnv } from 'brumate/env';
10
+ * import * as v from 'valibot';
11
+ *
12
+ * export default defineEnv({
13
+ * server: { DATABASE_URL: v.pipe(v.string(), v.url()) },
14
+ * public: { SITE_NAME: v.optional(v.string(), 'Tracker') },
15
+ * });
16
+ * ```
17
+ *
18
+ * Every variable is checked when the file loads, so a server that starts
19
+ * without a secret fails at once, with every missing or wrong variable in
20
+ * the message. A schema must validate without waiting.
21
+ */
22
+ function defineEnv(schema, options = {}) {
23
+ const source = options.source ?? processEnv();
24
+ const values = {};
25
+ const problems = [];
26
+ for (const [group, isServer] of [[schema.server, true], [schema.public, false]]) for (const [name, variable] of Object.entries(group ?? {})) {
27
+ const props = variable["~standard"];
28
+ if (props?.version !== 1 || typeof props.validate !== "function") throw new TypeError(`The schema of ${name} is not a Standard Schema of version 1`);
29
+ const input = source[name];
30
+ const result = props.validate(input);
31
+ if (result instanceof Promise) throw new TypeError(`The schema of ${name} validates asynchronously. Use one that does not wait`);
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("; ")}`}`);
34
+ continue;
35
+ }
36
+ values[name] = result.value;
37
+ if (isServer) {
38
+ addSecret(input);
39
+ addSecret(result.value);
40
+ }
41
+ }
42
+ if (problems.length > 0) throw new Error(`Environment variables: ${problems.join(". ")}`);
43
+ return Object.freeze(values);
44
+ }
45
+ /**
46
+ * Where the issues of a server variable are, such as ` at port`. The
47
+ * messages of some schema libraries hold the value, which is a secret, so
48
+ * the error leaves them out.
49
+ */
50
+ function issuePaths(issues) {
51
+ const paths = issues.map((issue) => (issue.path ?? []).map((segment) => String(typeof segment === "object" ? segment.key : segment)).join(".")).filter((path) => path !== "");
52
+ return paths.length > 0 ? ` at ${paths.join(", ")}` : "";
53
+ }
54
+ /** The variables of the process, where there is one. */
55
+ function processEnv() {
56
+ return globalThis.process?.env ?? {};
57
+ }
58
+ //#endregion
59
+ export { defineEnv };
60
+
61
+ //# sourceMappingURL=env.js.map
@@ -0,0 +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"}
@@ -0,0 +1,27 @@
1
+ //#region src/runtime/events.d.ts
2
+ /** The keys that `prevent` can name, by their `event.key`. `Space` is the space bar. */
3
+ export declare const KEY_NAMES: readonly string[];
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
+ type Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
6
+ type FunctionKey = `F${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12}`;
7
+ /** 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;
9
+ /** The modifiers of a handler, which `spread` writes into `b-on`. A symbol of the registry. */
10
+ export declare const MODIFIERS: unique symbol;
11
+ /** A handler with the modifiers of its wrappers. */
12
+ type Handler = (...args: any[]) => unknown;
13
+ /**
14
+ * Prevents the default action of the event, before the handler's code
15
+ * loads. With keys, on a keyboard event, it prevents only those keys, and
16
+ * the handler still runs for every key.
17
+ */
18
+ export declare function prevent<H extends Handler>(handler: H, ...keys: KeyName[]): H;
19
+ /** Stops the event at this element, so the handlers of the elements around it do not run. */
20
+ export declare function stop<H extends Handler>(handler: H): H;
21
+ /** Runs the handler for the first event only. */
22
+ export declare function once<H extends Handler>(handler: H): H;
23
+ /** Runs the handler before the handlers of the elements inside, as a listener in the capture phase. */
24
+ export declare function capture<H extends Handler>(handler: H): H;
25
+ //#endregion
26
+ export {};
27
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ export { t as KEY_NAMES, n as MODIFIERS, r as capture, i as once, a as prevent, o as stop } from "../events-BKWRqtMg.js";
@@ -1,4 +1,4 @@
1
- import { t as ClientModule } from "../client-DwJInP_a.js";
1
+ import { t as ClientModule } from "../client-MD0ZmcFR.js";
2
2
  //#region src/runtime/hot.d.ts
3
3
  /** What `brumate:update` holds for each component that changed. */
4
4
  export interface HotUpdate {
@@ -1,2 +1,2 @@
1
- import { _ as textValue, a as attribute, c as classValue, d as insertValue, f as isRaw, g as styleElement, h as spread, i as affix, l as escape, m as rawHTML, n as VOID_ELEMENTS, o as attributeText, p as raw, r as actionAttributes, s as classAttribute, t as Raw, u as escapeAttribute, v as vars } from "../html-Du8jY2Cc.js";
2
- export { Raw, VOID_ELEMENTS, actionAttributes, affix, attribute, attributeText, classAttribute, classValue, escape, escapeAttribute, insertValue, isRaw, raw, rawHTML, spread, styleElement, textValue, vars };
1
+ import { _ as styleElement, a as attribute, c as classValue, d as insertValue, f as isRaw, g as spread, h as rawHTML, i as affix, l as escape, m as raw, n as VOID_ELEMENTS, o as attributeText, p as mergeAttributes, r as actionAttributes, s as classAttribute, t as Raw, u as escapeAttribute, v as textValue, y as vars } from "../html-y1q7-t7D.js";
2
+ export { Raw, VOID_ELEMENTS, actionAttributes, affix, attribute, attributeText, classAttribute, classValue, escape, escapeAttribute, insertValue, isRaw, mergeAttributes, 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 classAttribute, s as classValue, c as escape, l as escapeAttribute, u as insertValue, d as isRaw, f as raw, p as rawHTML, m as spread, h as styleElement, g as textValue, _ as vars } from "../html-DEeoepg3.js";
1
+ export { t as VOID_ELEMENTS, n as actionAttributes, r as affix, i as attribute, a as attributeText, o as classAttribute, s as classValue, c as escape, l as escapeAttribute, u as insertValue, d as isRaw, f as mergeAttributes, p as raw, m as rawHTML, h as spread, g as styleElement, _ as textValue, v as vars } from "../html-bHZbkK-h.js";
@@ -1,5 +1,5 @@
1
- import { n as NavigateOptions, t as LoaderOptions } from "../boot-DN1ZU8Hg.js";
2
- import { t as startWithoutNavigation } from "../static-loader-BcFh4ebX.js";
1
+ import { n as NavigateOptions, t as LoaderOptions } from "../boot-D-IdPy7B.js";
2
+ import { t as startWithoutNavigation } from "../static-loader-BzE9SRaj.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-ClNkHZGn.js";
2
- import { t as start } from "../loader-Dc9OwY5I.js";
1
+ import { t as startWithoutNavigation } from "../static-loader-DOygOFj5.js";
2
+ import { t as start } from "../loader-B18i3_-T.js";
3
3
  export { start, startWithoutNavigation };
@@ -1,21 +1,2 @@
1
- //#region src/runtime/routes.d.ts
2
- /**
3
- * The paths of the routes, with their params, such as
4
- * `'/todos/[id]': { id: string }`. The Vite plugin adds them.
5
- */
6
- export interface Routes {}
7
- /** A route path, such as `/todos/[id]`. Any string while no routes are declared. */
8
- export type RoutePath = [keyof Routes] extends [never] ? string : keyof Routes & string;
9
- /** The params of a route path, such as `{ id: string }` for `/todos/[id]`. */
10
- export type RouteParams<P extends RoutePath> = P extends keyof Routes ? Routes[P] : Record<string, string>;
11
- /** The arguments after the path: none for a path without params. */
12
- type ParamsArgument<P extends RoutePath> = [keyof RouteParams<P>] extends [never] ? [params?: RouteParams<P>] : [params: RouteParams<P>];
13
- /**
14
- * The URL of a route, with its params in place:
15
- * `href('/todos/[id]', { id: '3' })` is `/todos/3`. A rest param, such as
16
- * `[...path]`, keeps its slashes.
17
- */
18
- export declare function href<P extends RoutePath>(path: P, ...[params]: ParamsArgument<P>): string;
19
- //#endregion
20
- export {};
21
- //# sourceMappingURL=routes.d.ts.map
1
+ import { a as href, i as Routes, n as RouteParams, o as navigate, r as RoutePath, t as NavigateOptions } from "../routes-BZNt7DSZ.js";
2
+ export { NavigateOptions, RouteParams, RoutePath, Routes, href, navigate };
@@ -12,7 +12,37 @@ function href(path, ...[params]) {
12
12
  return rest ? String(value).split("/").map(encodeURIComponent).join("/") : encodeURIComponent(String(value));
13
13
  });
14
14
  }
15
+ /**
16
+ * Loads a page as a link does: the layouts that stay keep their state. It
17
+ * returns when the page shows. A URL of another origin, or a page without
18
+ * the loader, loads in full.
19
+ *
20
+ * ```ts
21
+ * await navigate(href('/issues/[id]', { id: issue.id }));
22
+ * navigate(`?q=${query}`, { replace: true });
23
+ * ```
24
+ */
25
+ function navigate(to, options = {}) {
26
+ const url = new URL(to, location.href);
27
+ if (url.protocol !== "http:" && url.protocol !== "https:") return Promise.reject(/* @__PURE__ */ new TypeError(`navigate loads http and https URLs, not ${url.protocol}`));
28
+ if (url.origin !== location.origin) {
29
+ location.assign(url.href);
30
+ return new Promise(() => {});
31
+ }
32
+ return new Promise((resolve) => {
33
+ const event = new CustomEvent("brumate:navigate", {
34
+ cancelable: true,
35
+ detail: {
36
+ url: url.href,
37
+ replace: options.replace === true,
38
+ scroll: options.scroll !== false,
39
+ done: resolve
40
+ }
41
+ });
42
+ if (document.dispatchEvent(event)) location.assign(url.href);
43
+ });
44
+ }
15
45
  //#endregion
16
- export { href };
46
+ export { href, navigate };
17
47
 
18
48
  //# sourceMappingURL=routes.js.map
@@ -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"],"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"}
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,5 +1,6 @@
1
- import { a as attribute, h as spread, i as affix, l as escape, p as raw, s as classAttribute, t as Raw, u as escapeAttribute, v as vars } from "../html-Du8jY2Cc.js";
2
- import { a as PageState, n as ElementReference, o as ScopeState, r as FunctionReference, t as produce } from "../produce-CtZ32UGG.js";
3
- import { n as createContext } from "../context-aeo9esY9.js";
4
- import { $ as ServerError, A as stateScript, B as safeParse, C as lazy, D as ready, E as read, F as ValidationError, G as Middleware, H as EndpointLoader, I as ValidationIssue, J as RouteNode, K as MiddlewareLoader, L as fieldErrors, M as streamState, N as wait, O as render, P as ParseResult, Q as RequestEvent, R as parse, S as isCrossSite, T as packState, U as Handler, V as StandardSchemaV1, W as Loader, X as matchRoute, Y as RouteView, Z as Redirect, _ as component, a as Lazy, at as CookieOptions, b as handleRoute, c as NotReady, ct as createSession, d as RequestOptions, dt as toNodeHeaders, et as dedupe, f as RouteOptions, g as actionResult, h as action, i as ItemSource, it as withEvent, j as streamParts, k as renderToStream, l as RenderOptions, lt as parseCookies, m as StreamOptions, n as Context, nt as isRedirect, o as Mark, ot as Session, p as StateAttributes, q as RouteMatch, r as DocumentOptions, rt as redirect, s as Memo, st as SessionOptions, t as Component, tt as getEvent, u as RenderResult, ut as serializeCookie, v as dynamic, w as memo, x as insert, y as handleRequest, z as parseForm } from "../server-BxqjLUnV.js";
5
- export { Component, Context, type CookieOptions, DocumentOptions, ElementReference, type EndpointLoader, FunctionReference, type Handler, ItemSource, Lazy, type Loader, Mark, Memo, type Middleware, type MiddlewareLoader, NotReady, type PageState, type ParseResult, type Raw, type Redirect, RenderOptions, RenderResult, RequestEvent, RequestOptions, type RouteMatch, type RouteNode, RouteOptions, type RouteView, type ScopeState, ServerError, type Session, type SessionOptions, type StandardSchemaV1, StateAttributes, StreamOptions, ValidationError, type ValidationIssue, action, actionResult, affix, attribute, classAttribute, component, createContext, createSession, dedupe, dynamic, escape, escapeAttribute, fieldErrors, getEvent, handleRequest, handleRoute, insert, isCrossSite, isRedirect, lazy, matchRoute, memo, packState, parse, parseCookies, parseForm, produce, raw, read, ready, redirect, render, renderToStream, safeParse, serializeCookie, spread, stateScript, streamParts, streamState, toNodeHeaders, vars, wait, withEvent };
1
+ import { a as attribute, i as affix, l as escape, m as raw, p as mergeAttributes, s as classAttribute, t as Raw, u as escapeAttribute, y as vars } from "../html-y1q7-t7D.js";
2
+ import { a as PageState, n as ElementReference, o as ScopeId, r as FunctionReference, s as ScopeState, t as produce } from "../produce-D4K7qpaL.js";
3
+ import { a as Route, c as routeContext, o as createContext, r as NavigationState, s as navigationContext } from "../context-btHuB01Z.js";
4
+ import { t as StandardSchemaV1 } from "../standard-schema-BNY82yX3.js";
5
+ import { $ as rateLimit, A as onAttribute, At as CookieOptions, B as streamParts, C as handleRequest, Ct as ServerError, D as isCrossSite, Dt as isRedirect, E as insert, Et as getEvent, F as renderToStream, Ft as serializeCookie, G as RateLimitConfig, H as wait, I as settled, It as toNodeHeaders, J as RateLimitOptions, K as RateLimitError, L as spread, M as read, Mt as SessionOptions, N as ready, Nt as createSession, O as lazy, Ot as redirect, P as render, Pt as parseCookies, Q as configureRateLimit, R as stateScript, S as dynamic, St as RequestKind, T as inlineBodies, Tt as defineMiddleware, U as waitAll, V as streamState, W as RateLimit, X as Window, Y as RateLimitStore, Z as clientAddress, _ as StreamOptions, _t as Locals, a as ItemSource, at as parseForm, b as children, bt as RequestEvent, c as Memo, ct as Handler, d as RenderResult, dt as MiddlewareLoader, et as ParseResult, f as RequestOptions, ft as RouteMatch, g as StateMap, gt as EntryMiddleware, h as StateAttributes, ht as matchRoute, i as DocumentOptions, it as parse, j as packState, jt as Session, k as memo, kt as withEvent, l as NotReady, lt as Loader, m as ScopeEntry, mt as RouteView, n as Context, nt as ValidationIssue, o as Lazy, ot as safeParse, p as RouteOptions, pt as RouteNode, q as RateLimitMiddleware, r as DeferTarget, rt as fieldErrors, s as Mark, st as EndpointLoader, t as Component, tt as ValidationError, u as RenderOptions, ut as Middleware, v as action, vt as Redirect, w as handleRoute, wt as dedupe, x as component, xt as RequestEventOptions, y as actionResult, yt as RequestCall, z as stateValue } from "../server-BA9SJ2Vm.js";
6
+ export { Component, Context, type CookieOptions, DeferTarget, DocumentOptions, ElementReference, type EndpointLoader, type EntryMiddleware, FunctionReference, type Handler, ItemSource, Lazy, type Loader, type Locals, Mark, Memo, type Middleware, type MiddlewareLoader, type NavigationState, NotReady, type PageState, type ParseResult, type RateLimit, type RateLimitConfig, RateLimitError, type RateLimitMiddleware, type RateLimitOptions, type RateLimitStore, type Raw, type Redirect, RenderOptions, RenderResult, type RequestCall, RequestEvent, type RequestEventOptions, type RequestKind, RequestOptions, type Route, type RouteMatch, type RouteNode, RouteOptions, type RouteView, ScopeEntry, type ScopeId, type ScopeState, ServerError, type Session, type SessionOptions, type StandardSchemaV1, StateAttributes, StateMap, StreamOptions, ValidationError, type ValidationIssue, type Window, action, actionResult, affix, attribute, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, getEvent, handleRequest, handleRoute, inlineBodies, insert, isCrossSite, isRedirect, lazy, matchRoute, memo, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, routeContext, safeParse, serializeCookie, settled, spread, stateScript, stateValue, streamParts, streamState, toNodeHeaders, vars, wait, waitAll, withEvent };
@@ -1,7 +1,6 @@
1
- import { _ as vars, c as escape, f as raw, i as attribute, l as escapeAttribute, m as spread, o as classAttribute, r as affix } from "../html-DEeoepg3.js";
2
- import { n as FunctionReference, t as ElementReference } from "../shared-CWYOd0H3.js";
1
+ import { c as escape, f as mergeAttributes, i as attribute, l as escapeAttribute, o as classAttribute, p as raw, r as affix, v as vars } from "../html-bHZbkK-h.js";
2
+ import { n as ElementReference, r as FunctionReference, t as produce } from "../produce-CWfJ4byV.js";
3
3
  import { a as serializeCookie, i as parseCookies, s as toNodeHeaders, t as createSession } from "../cookies-Av5WFmcf.js";
4
- import { A as dedupe, C as fieldErrors, D as matchRoute, E as safeParse, M as isRedirect, N as redirect, O as RequestEvent, P as withEvent, S as ValidationError, T as parseForm, _ as renderToStream, a as component, b as streamState, c as handleRoute, d as lazy, f as memo, g as render, h as ready, i as actionResult, j as getEvent, k as ServerError, l as insert, m as read, n as NotReady, o as dynamic, p as packState, r as action, s as handleRequest, t as Context, u as isCrossSite, v as stateScript, w as parse, x as wait, y as streamParts } from "../server-DZsgnPKS.js";
5
- import { t as produce } from "../produce-BRGHP7e0.js";
6
- import { t as createContext } from "../context-BG8KCF3v.js";
7
- export { Context, ElementReference, FunctionReference, NotReady, RequestEvent, ServerError, ValidationError, action, actionResult, affix, attribute, classAttribute, component, createContext, createSession, dedupe, dynamic, escape, escapeAttribute, fieldErrors, getEvent, handleRequest, handleRoute, insert, isCrossSite, isRedirect, lazy, matchRoute, memo, packState, parse, parseCookies, parseForm, produce, raw, read, ready, redirect, render, renderToStream, safeParse, serializeCookie, spread, stateScript, streamParts, streamState, toNodeHeaders, vars, wait, withEvent };
4
+ import { A as clientAddress, B as ServerError, C as stateScript, D as wait, E as streamState, F as parse, G as redirect, H as defineMiddleware, I as parseForm, K as withEvent, L as safeParse, M as rateLimit, N as ValidationError, O as waitAll, P as fieldErrors, R as matchRoute, S as spread, T as streamParts, U as getEvent, V as dedupe, W as isRedirect, _ as read, a as children, b as renderToStream, c as handleRequest, d as insert, f as isCrossSite, g as packState, h as onAttribute, i as actionResult, j as configureRateLimit, k as RateLimitError, l as handleRoute, m as memo, n as NotReady, o as component, p as lazy, r as action, s as dynamic, t as Context, u as inlineBodies, v as ready, w as stateValue, x as settled, y as render, z as RequestEvent } from "../server-BqfM95r1.js";
5
+ import { a as routeContext, i as navigationContext, r as createContext } from "../context-CTiSzQRc.js";
6
+ export { Context, ElementReference, FunctionReference, NotReady, RateLimitError, RequestEvent, ServerError, ValidationError, action, actionResult, affix, attribute, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, getEvent, handleRequest, handleRoute, inlineBodies, insert, isCrossSite, isRedirect, lazy, matchRoute, memo, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, routeContext, safeParse, serializeCookie, settled, spread, stateScript, stateValue, streamParts, streamState, toNodeHeaders, vars, wait, waitAll, withEvent };
@@ -1,4 +1,5 @@
1
- import { t as Context } from "../context-aeo9esY9.js";
1
+ import { a as Route, r as NavigationState, t as Context } from "../context-btHuB01Z.js";
2
+ import { n as RouteParams, r as RoutePath } from "../routes-BZNt7DSZ.js";
2
3
  //#region src/runtime/signals.d.ts
3
4
  /** Returns the props of the component. Destructure the call to keep each prop reactive. */
4
5
  export declare function $props<T = Record<string, any>>(): T;
@@ -12,6 +13,18 @@ export type MemoValue<T> = Awaited<T> extends AsyncIterable<infer U> ? U : Await
12
13
  * is read. An async iterable gives each of its values in turn.
13
14
  */
14
15
  export declare function $memo<T>(_value: T): MemoValue<T>;
16
+ /**
17
+ * Declares a memo that takes the value once it stops changing for `ms`
18
+ * milliseconds, such as a search query while the user types. On the server,
19
+ * and until the value first changes, it is the value.
20
+ */
21
+ export declare function $debounced<T>(_value: T, _ms: number): MemoValue<T>;
22
+ /**
23
+ * Declares a memo that takes the value at most once every `ms`
24
+ * milliseconds, and the last value after the wait, such as a position while
25
+ * the pointer moves. On the server, and until the value first changes, it is the value.
26
+ */
27
+ export declare function $throttled<T>(_value: T, _ms: number): MemoValue<T>;
15
28
  /**
16
29
  * Declares a value that follows a memo, and that handlers can write. A write
17
30
  * shows a guess, such as a new item while the form that adds it posts. The
@@ -33,6 +46,14 @@ export declare function $id(): string;
33
46
  export declare function $setContext<T>(_context: Context<T>, _value: T): void;
34
47
  /** Reads a context from the nearest component above that provides it, or its default value. */
35
48
  export declare function $getContext<T>(_context: Context<T>): T;
49
+ /**
50
+ * The route of the page: its URL, its query string and its params, typed
51
+ * from the route files as `href` is. The server reads the request, and the
52
+ * browser reads `location`. It changes when navigation changes the URL.
53
+ */
54
+ export declare function $route<P extends RoutePath = RoutePath>(_path?: P): Route<RouteParams<P>>;
55
+ /** The navigation that loads, with `pending` false when none does. Always `{ pending: false }` on the server. */
56
+ export declare function $navigation(): NavigationState;
36
57
  /** Changes an object or an array in a signal through a draft, and writes the signal with the result. */
37
58
  export declare function $produce<T>(_signal: T, _recipe: (draft: T) => T | void): void;
38
59
  /** Sets the title of the page. The last component that sets it wins. */
@@ -17,6 +17,22 @@ function $memo(_value) {
17
17
  return compileTimeOnly("$memo");
18
18
  }
19
19
  /**
20
+ * Declares a memo that takes the value once it stops changing for `ms`
21
+ * milliseconds, such as a search query while the user types. On the server,
22
+ * and until the value first changes, it is the value.
23
+ */
24
+ function $debounced(_value, _ms) {
25
+ return compileTimeOnly("$debounced");
26
+ }
27
+ /**
28
+ * Declares a memo that takes the value at most once every `ms`
29
+ * milliseconds, and the last value after the wait, such as a position while
30
+ * the pointer moves. On the server, and until the value first changes, it is the value.
31
+ */
32
+ function $throttled(_value, _ms) {
33
+ return compileTimeOnly("$throttled");
34
+ }
35
+ /**
20
36
  * Declares a value that follows a memo, and that handlers can write. A write
21
37
  * shows a guess, such as a new item while the form that adds it posts. The
22
38
  * value goes back to the memo when the memo changes, or when the server
@@ -53,6 +69,18 @@ function $setContext(_context, _value) {
53
69
  function $getContext(_context) {
54
70
  return compileTimeOnly("$getContext");
55
71
  }
72
+ /**
73
+ * The route of the page: its URL, its query string and its params, typed
74
+ * from the route files as `href` is. The server reads the request, and the
75
+ * browser reads `location`. It changes when navigation changes the URL.
76
+ */
77
+ function $route(_path) {
78
+ return compileTimeOnly("$route");
79
+ }
80
+ /** The navigation that loads, with `pending` false when none does. Always `{ pending: false }` on the server. */
81
+ function $navigation() {
82
+ return compileTimeOnly("$navigation");
83
+ }
56
84
  /** Changes an object or an array in a signal through a draft, and writes the signal with the result. */
57
85
  function $produce(_signal, _recipe) {
58
86
  compileTimeOnly("$produce");
@@ -69,6 +97,6 @@ function $action(_fn) {
69
97
  return compileTimeOnly("$action");
70
98
  }
71
99
  //#endregion
72
- export { $action, $client, $effect, $getContext, $id, $isPending, $memo, $optimistic, $produce, $props, $setContext, $signal, $title, $untrack };
100
+ export { $action, $client, $debounced, $effect, $getContext, $id, $isPending, $memo, $navigation, $optimistic, $produce, $props, $route, $setContext, $signal, $throttled, $title, $untrack };
73
101
 
74
102
  //# sourceMappingURL=signals.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signals.js","names":[],"sources":["../../src/runtime/signals.ts"],"sourcesContent":["// The compile-time functions of `.brm` files. The compiler replaces every\n// call and removes the import, so this module only gives them their types.\n// A call outside a `.brm` file throws.\n\nimport type { Context } from './context.ts';\n\nfunction compileTimeOnly(name: string): never {\n throw new Error(`${name} works only in .brm files, which the brumate compiler compiles`);\n}\n\n/** Returns the props of the component. Destructure the call to keep each prop reactive. */\n// oxlint-disable-next-line typescript/no-explicit-any -- Props are any object unless typed.\nexport function $props<T = Record<string, any>>(): T {\n return compileTimeOnly('$props');\n}\n\n/** Declares writable state. The variable reads and writes the signal. */\nexport function $signal<T>(value: T): T;\nexport function $signal<T>(): T | undefined;\nexport function $signal(): never {\n return compileTimeOnly('$signal');\n}\n\n/** The value of a memo: what a promise settles to, or the latest value of an async iterable. */\nexport type MemoValue<T> = Awaited<T> extends AsyncIterable<infer U> ? U : Awaited<T>;\n\n/**\n * Declares a value computed from other values. A promise is awaited where it\n * is read. An async iterable gives each of its values in turn.\n */\nexport function $memo<T>(_value: T): MemoValue<T> {\n return compileTimeOnly('$memo');\n}\n\n/**\n * Declares a value that follows a memo, and that handlers can write. A write\n * shows a guess, such as a new item while the form that adds it posts. The\n * value goes back to the memo when the memo changes, or when the server\n * calls of the page finish, such as after a failed post.\n */\nexport function $optimistic<T>(_source: T): T {\n return compileTimeOnly('$optimistic');\n}\n\n/** Runs a callback when the values it reads change, after the page resumes. Never on load. */\nexport function $effect(_callback: () => void | (() => void)): void {\n compileTimeOnly('$effect');\n}\n\n/** Runs a callback in the browser when a trigger fires. */\nexport function $client(\n _callback: () => void | (() => void),\n _trigger?: 'visible' | 'idle' | 'load',\n): void {\n compileTimeOnly('$client');\n}\n\n/** Reads a value without depending on it. */\nexport function $untrack<T>(_value: T): T {\n return compileTimeOnly('$untrack');\n}\n\n/** True while a new value of a memo, or of a memo it reads, loads on the client. Always false on the server. */\nexport function $isPending(_memo: unknown): boolean {\n return compileTimeOnly('$isPending');\n}\n\n/** Returns an ID that is unique in the page and the same on the server and the client. */\nexport function $id(): string {\n return compileTimeOnly('$id');\n}\n\n/** Provides a value of a context to the components inside this one. */\nexport function $setContext<T>(_context: Context<T>, _value: T): void {\n compileTimeOnly('$setContext');\n}\n\n/** Reads a context from the nearest component above that provides it, or its default value. */\nexport function $getContext<T>(_context: Context<T>): T {\n return compileTimeOnly('$getContext');\n}\n\n/** Changes an object or an array in a signal through a draft, and writes the signal with the result. */\nexport function $produce<T>(_signal: T, _recipe: (draft: T) => T | void): void {\n compileTimeOnly('$produce');\n}\n\n/** Sets the title of the page. The last component that sets it wins. */\nexport function $title(_value: unknown): void {\n compileTimeOnly('$title');\n}\n\n/**\n * The latest result of a server function that a form of this component posts\n * to, or undefined before the first post. Pending while the form sends.\n */\nexport function $action<F extends (...args: never[]) => unknown>(\n _fn: F,\n): Awaited<ReturnType<F>> | undefined {\n return compileTimeOnly('$action');\n}\n"],"mappings":";AAMA,SAAS,gBAAgB,MAAqB;CAC5C,MAAM,IAAI,MAAM,GAAG,KAAK,+DAA+D;AACzF;;AAIA,SAAgB,SAAqC;CACnD,OAAO,gBAAgB,QAAQ;AACjC;AAKA,SAAgB,UAAiB;CAC/B,OAAO,gBAAgB,SAAS;AAClC;;;;;AASA,SAAgB,MAAS,QAAyB;CAChD,OAAO,gBAAgB,OAAO;AAChC;;;;;;;AAQA,SAAgB,YAAe,SAAe;CAC5C,OAAO,gBAAgB,aAAa;AACtC;;AAGA,SAAgB,QAAQ,WAA4C;CAClE,gBAAgB,SAAS;AAC3B;;AAGA,SAAgB,QACd,WACA,UACM;CACN,gBAAgB,SAAS;AAC3B;;AAGA,SAAgB,SAAY,QAAc;CACxC,OAAO,gBAAgB,UAAU;AACnC;;AAGA,SAAgB,WAAW,OAAyB;CAClD,OAAO,gBAAgB,YAAY;AACrC;;AAGA,SAAgB,MAAc;CAC5B,OAAO,gBAAgB,KAAK;AAC9B;;AAGA,SAAgB,YAAe,UAAsB,QAAiB;CACpE,gBAAgB,aAAa;AAC/B;;AAGA,SAAgB,YAAe,UAAyB;CACtD,OAAO,gBAAgB,aAAa;AACtC;;AAGA,SAAgB,SAAY,SAAY,SAAuC;CAC7E,gBAAgB,UAAU;AAC5B;;AAGA,SAAgB,OAAO,QAAuB;CAC5C,gBAAgB,QAAQ;AAC1B;;;;;AAMA,SAAgB,QACd,KACoC;CACpC,OAAO,gBAAgB,SAAS;AAClC"}
1
+ {"version":3,"file":"signals.js","names":[],"sources":["../../src/runtime/signals.ts"],"sourcesContent":["// The compile-time functions of `.brm` files. The compiler replaces every\n// call and removes the import, so this module only gives them their types.\n// A call outside a `.brm` file throws.\n\nimport type { Context, NavigationState, Route } from './context.ts';\nimport type { RoutePath, RouteParams } from './routes.ts';\n\nfunction compileTimeOnly(name: string): never {\n throw new Error(`${name} works only in .brm files, which the brumate compiler compiles`);\n}\n\n/** Returns the props of the component. Destructure the call to keep each prop reactive. */\n// oxlint-disable-next-line typescript/no-explicit-any -- Props are any object unless typed.\nexport function $props<T = Record<string, any>>(): T {\n return compileTimeOnly('$props');\n}\n\n/** Declares writable state. The variable reads and writes the signal. */\nexport function $signal<T>(value: T): T;\nexport function $signal<T>(): T | undefined;\nexport function $signal(): never {\n return compileTimeOnly('$signal');\n}\n\n/** The value of a memo: what a promise settles to, or the latest value of an async iterable. */\nexport type MemoValue<T> = Awaited<T> extends AsyncIterable<infer U> ? U : Awaited<T>;\n\n/**\n * Declares a value computed from other values. A promise is awaited where it\n * is read. An async iterable gives each of its values in turn.\n */\nexport function $memo<T>(_value: T): MemoValue<T> {\n return compileTimeOnly('$memo');\n}\n\n/**\n * Declares a memo that takes the value once it stops changing for `ms`\n * milliseconds, such as a search query while the user types. On the server,\n * and until the value first changes, it is the value.\n */\nexport function $debounced<T>(_value: T, _ms: number): MemoValue<T> {\n return compileTimeOnly('$debounced');\n}\n\n/**\n * Declares a memo that takes the value at most once every `ms`\n * milliseconds, and the last value after the wait, such as a position while\n * the pointer moves. On the server, and until the value first changes, it is the value.\n */\nexport function $throttled<T>(_value: T, _ms: number): MemoValue<T> {\n return compileTimeOnly('$throttled');\n}\n\n/**\n * Declares a value that follows a memo, and that handlers can write. A write\n * shows a guess, such as a new item while the form that adds it posts. The\n * value goes back to the memo when the memo changes, or when the server\n * calls of the page finish, such as after a failed post.\n */\nexport function $optimistic<T>(_source: T): T {\n return compileTimeOnly('$optimistic');\n}\n\n/** Runs a callback when the values it reads change, after the page resumes. Never on load. */\nexport function $effect(_callback: () => void | (() => void)): void {\n compileTimeOnly('$effect');\n}\n\n/** Runs a callback in the browser when a trigger fires. */\nexport function $client(\n _callback: () => void | (() => void),\n _trigger?: 'visible' | 'idle' | 'load',\n): void {\n compileTimeOnly('$client');\n}\n\n/** Reads a value without depending on it. */\nexport function $untrack<T>(_value: T): T {\n return compileTimeOnly('$untrack');\n}\n\n/** True while a new value of a memo, or of a memo it reads, loads on the client. Always false on the server. */\nexport function $isPending(_memo: unknown): boolean {\n return compileTimeOnly('$isPending');\n}\n\n/** Returns an ID that is unique in the page and the same on the server and the client. */\nexport function $id(): string {\n return compileTimeOnly('$id');\n}\n\n/** Provides a value of a context to the components inside this one. */\nexport function $setContext<T>(_context: Context<T>, _value: T): void {\n compileTimeOnly('$setContext');\n}\n\n/** Reads a context from the nearest component above that provides it, or its default value. */\nexport function $getContext<T>(_context: Context<T>): T {\n return compileTimeOnly('$getContext');\n}\n\n/**\n * The route of the page: its URL, its query string and its params, typed\n * from the route files as `href` is. The server reads the request, and the\n * browser reads `location`. It changes when navigation changes the URL.\n */\nexport function $route<P extends RoutePath = RoutePath>(_path?: P): Route<RouteParams<P>> {\n return compileTimeOnly('$route');\n}\n\n/** The navigation that loads, with `pending` false when none does. Always `{ pending: false }` on the server. */\nexport function $navigation(): NavigationState {\n return compileTimeOnly('$navigation');\n}\n\n/** Changes an object or an array in a signal through a draft, and writes the signal with the result. */\nexport function $produce<T>(_signal: T, _recipe: (draft: T) => T | void): void {\n compileTimeOnly('$produce');\n}\n\n/** Sets the title of the page. The last component that sets it wins. */\nexport function $title(_value: unknown): void {\n compileTimeOnly('$title');\n}\n\n/**\n * The latest result of a server function that a form of this component posts\n * to, or undefined before the first post. Pending while the form sends.\n */\nexport function $action<F extends (...args: never[]) => unknown>(\n _fn: F,\n): Awaited<ReturnType<F>> | undefined {\n return compileTimeOnly('$action');\n}\n"],"mappings":";AAOA,SAAS,gBAAgB,MAAqB;CAC5C,MAAM,IAAI,MAAM,GAAG,KAAK,+DAA+D;AACzF;;AAIA,SAAgB,SAAqC;CACnD,OAAO,gBAAgB,QAAQ;AACjC;AAKA,SAAgB,UAAiB;CAC/B,OAAO,gBAAgB,SAAS;AAClC;;;;;AASA,SAAgB,MAAS,QAAyB;CAChD,OAAO,gBAAgB,OAAO;AAChC;;;;;;AAOA,SAAgB,WAAc,QAAW,KAA2B;CAClE,OAAO,gBAAgB,YAAY;AACrC;;;;;;AAOA,SAAgB,WAAc,QAAW,KAA2B;CAClE,OAAO,gBAAgB,YAAY;AACrC;;;;;;;AAQA,SAAgB,YAAe,SAAe;CAC5C,OAAO,gBAAgB,aAAa;AACtC;;AAGA,SAAgB,QAAQ,WAA4C;CAClE,gBAAgB,SAAS;AAC3B;;AAGA,SAAgB,QACd,WACA,UACM;CACN,gBAAgB,SAAS;AAC3B;;AAGA,SAAgB,SAAY,QAAc;CACxC,OAAO,gBAAgB,UAAU;AACnC;;AAGA,SAAgB,WAAW,OAAyB;CAClD,OAAO,gBAAgB,YAAY;AACrC;;AAGA,SAAgB,MAAc;CAC5B,OAAO,gBAAgB,KAAK;AAC9B;;AAGA,SAAgB,YAAe,UAAsB,QAAiB;CACpE,gBAAgB,aAAa;AAC/B;;AAGA,SAAgB,YAAe,UAAyB;CACtD,OAAO,gBAAgB,aAAa;AACtC;;;;;;AAOA,SAAgB,OAAwC,OAAkC;CACxF,OAAO,gBAAgB,QAAQ;AACjC;;AAGA,SAAgB,cAA+B;CAC7C,OAAO,gBAAgB,aAAa;AACtC;;AAGA,SAAgB,SAAY,SAAY,SAAuC;CAC7E,gBAAgB,UAAU;AAC5B;;AAGA,SAAgB,OAAO,QAAuB;CAC5C,gBAAgB,QAAQ;AAC1B;;;;;AAMA,SAAgB,QACd,KACoC;CACpC,OAAO,gBAAgB,SAAS;AAClC"}
@@ -1,3 +1,3 @@
1
- import { t as LoaderOptions } from "../boot-DN1ZU8Hg.js";
2
- import { t as startWithoutNavigation } from "../static-loader-BcFh4ebX.js";
1
+ import { t as LoaderOptions } from "../boot-D-IdPy7B.js";
2
+ import { t as startWithoutNavigation } from "../static-loader-BzE9SRaj.js";
3
3
  export { type LoaderOptions, startWithoutNavigation };
@@ -1 +1 @@
1
- export { t as startWithoutNavigation } from "../static-loader-ClNkHZGn.js";
1
+ export { t as startWithoutNavigation } from "../static-loader-DOygOFj5.js";
@@ -1,15 +1,16 @@
1
- import { t as ClientModule } from "../client-DwJInP_a.js";
2
- import { l as RenderOptions, t as Component } from "../server-BxqjLUnV.js";
1
+ import { t as ClientModule } from "../client-MD0ZmcFR.js";
2
+ import { gt as EntryMiddleware, t as Component, u as RenderOptions } from "../server-BA9SJ2Vm.js";
3
3
  //#region src/runtime/testing.d.ts
4
+ /** The middleware of files of server functions, by function ID. */
5
+ type FileMiddleware = Record<string, EntryMiddleware>;
4
6
  export interface TestingOptions {
5
7
  /** Imports the client module of a component, by component ID. */
6
8
  load: (id: string) => Promise<ClientModule>;
7
9
  /** The URL prefix of server function calls. */
8
10
  rpc?: string;
9
11
  }
10
- export interface Mounted {
11
- /** The element that holds the component. */
12
- container: HTMLElement;
12
+ /** What a test does with the page, as a user does. */
13
+ export interface Actions {
13
14
  /** The first element that matches a selector. Throws if none does. */
14
15
  get: (selector: string) => HTMLElement;
15
16
  /** The text of the first element that matches a selector. */
@@ -25,6 +26,10 @@ export interface Mounted {
25
26
  * client code, so its effects arrive a moment later.
26
27
  */
27
28
  waitFor: (assertion: () => void, timeout?: number) => Promise<void>;
29
+ }
30
+ export interface Mounted extends Actions {
31
+ /** The element that holds the component. */
32
+ container: HTMLElement;
28
33
  /** Stops the loader and removes the component. */
29
34
  unmount: () => void;
30
35
  }
@@ -39,6 +44,13 @@ export interface AnswerOptions {
39
44
  rpc?: string;
40
45
  /** Called with the ID of each call, such as `issues_1a2b#toggleStar`, before it runs. */
41
46
  onCall?: (id: string) => void;
47
+ /** The middleware of the entry, which runs before each call. `virtual:brumate/testing` passes the app's. */
48
+ middleware?: EntryMiddleware;
49
+ /**
50
+ * The middleware of each `'use server'` file, by function ID, or a
51
+ * function that imports them. `virtual:brumate/testing` passes them.
52
+ */
53
+ fileMiddleware?: FileMiddleware | (() => Promise<FileMiddleware>);
42
54
  }
43
55
  /**
44
56
  * Answers the server function calls of the page in the test, with
@@ -51,5 +63,34 @@ export interface AnswerOptions {
51
63
  * `fetch`, as a browser stub does, throws: it would call itself without end.
52
64
  */
53
65
  export declare function answerCalls(functions: ServerFunctions | (() => Promise<ServerFunctions>), options?: AnswerOptions): () => void;
66
+ /** Answers a request as the server of the app does, or undefined when nothing does. */
67
+ export type RequestHandler = (request: Request) => Promise<Response | undefined>;
68
+ export interface VisitorOptions extends TestingOptions {
69
+ /** Answers the requests for pages, forms without scripts, `#defer` bodies and endpoints. */
70
+ routes: () => Promise<RequestHandler>;
71
+ /** Answers server function calls. */
72
+ calls: () => Promise<RequestHandler>;
73
+ }
74
+ export interface VisitOptions {
75
+ /** Cookies that the browser has before the first request, by name. */
76
+ cookies?: Record<string, string>;
77
+ /** Headers of every request, such as `accept-language`. */
78
+ headers?: HeadersInit;
79
+ }
80
+ export interface Visited extends Actions {
81
+ /** The path and the query of the page, such as `/issues?q=bug`. It changes with client navigation. */
82
+ readonly url: string;
83
+ /** The status of the first page. */
84
+ status: number;
85
+ /** The cookies that the browser has now, by name. */
86
+ readonly cookies: Record<string, string>;
87
+ /** Stops the loader, puts `fetch` back and empties the document. */
88
+ close: () => void;
89
+ }
90
+ /** Visits a path of the app, as a browser that runs scripts does. */
91
+ export type Visit = (path: string, options?: VisitOptions) => Promise<Visited>;
92
+ /** Returns `visit`, which answers the requests of the page with the routes of the app. */
93
+ export declare function createVisit(options: VisitorOptions): Visit;
54
94
  //#endregion
95
+ export {};
55
96
  //# sourceMappingURL=testing.d.ts.map