brumate 0.1.1 → 0.3.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.
- package/dist/{boot-DN1ZU8Hg.d.ts → boot-C25Sa6vq.d.ts} +27 -2
- package/dist/cli.js +2 -2
- package/dist/client-BD6XT-s5.js +1968 -0
- package/dist/client-BD6XT-s5.js.map +1 -0
- package/dist/{client-DwJInP_a.d.ts → client-D0CqSxoO.d.ts} +211 -30
- package/dist/{client-routes-DakuM32C.js → client-routes-JTbGtukf.js} +28 -15
- package/dist/client-routes-JTbGtukf.js.map +1 -0
- package/dist/context-CTiSzQRc.js +27 -0
- package/dist/context-CTiSzQRc.js.map +1 -0
- package/dist/context-btHuB01Z.d.ts +42 -0
- package/dist/{cookies-Av5WFmcf.js → cookies-BzllthiF.js} +2 -1
- package/dist/cookies-BzllthiF.js.map +1 -0
- package/dist/defer-BbD7JQhj.js +56 -0
- package/dist/defer-BbD7JQhj.js.map +1 -0
- package/dist/devtools-CQgD7NPB.js +623 -0
- package/dist/devtools-CQgD7NPB.js.map +1 -0
- package/dist/devtools-panel-BVB-W5q4.js +1930 -0
- package/dist/devtools-panel-BVB-W5q4.js.map +1 -0
- package/dist/events-CSs7OwIC.js +85 -0
- package/dist/events-CSs7OwIC.js.map +1 -0
- package/dist/{files-DdT84mPy.js → files-BXSSrQgc.js} +34 -6
- package/dist/files-BXSSrQgc.js.map +1 -0
- package/dist/forms-Bg-CwGqX.js +406 -0
- package/dist/forms-Bg-CwGqX.js.map +1 -0
- package/dist/forms-Cl21hkHt.d.ts +281 -0
- package/dist/highlight.d.ts +17 -0
- package/dist/highlight.js +269 -0
- package/dist/highlight.js.map +1 -0
- package/dist/html-Bq1rFxX_.d.ts +92 -0
- package/dist/html-mNTKzaDD.js +241 -0
- package/dist/html-mNTKzaDD.js.map +1 -0
- package/dist/index.d.ts +123 -30
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/{inspect-BPchdWbU.js → inspect-BHpOw1LF.js} +1400 -121
- package/dist/inspect-BHpOw1LF.js.map +1 -0
- package/dist/{loader-Dc9OwY5I.js → loader-Dos_3NP0.js} +47 -11
- package/dist/loader-Dos_3NP0.js.map +1 -0
- package/dist/{navigate-CzLjnoPH.js → navigate-O78d_zGN.js} +115 -13
- package/dist/navigate-O78d_zGN.js.map +1 -0
- package/dist/produce-D0V0ICkz.d.ts +114 -0
- package/dist/produce-Doc91GkX.js +274 -0
- package/dist/produce-Doc91GkX.js.map +1 -0
- package/dist/routes-BZNt7DSZ.d.ts +38 -0
- package/dist/{rpc-9fSqL_YK.js → rpc-ygMRPmN4.js} +39 -23
- package/dist/rpc-ygMRPmN4.js.map +1 -0
- package/dist/runtime/batch.d.ts +23 -0
- package/dist/runtime/batch.js +69 -0
- package/dist/runtime/batch.js.map +1 -0
- package/dist/runtime/client.d.ts +5 -5
- package/dist/runtime/client.js +5 -1345
- package/dist/runtime/context.d.ts +2 -2
- package/dist/runtime/context.js +1 -1
- package/dist/runtime/devtools.d.ts +191 -5
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/env.d.ts +44 -0
- package/dist/runtime/env.js +61 -0
- package/dist/runtime/env.js.map +1 -0
- package/dist/runtime/events.d.ts +42 -0
- package/dist/runtime/events.js +1 -0
- package/dist/runtime/forms.d.ts +2 -0
- package/dist/runtime/forms.js +1 -0
- package/dist/runtime/gather.d.ts +25 -0
- package/dist/runtime/gather.js +33 -0
- package/dist/runtime/gather.js.map +1 -0
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.d.ts +2 -2
- package/dist/runtime/html.js +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/routes.d.ts +2 -21
- package/dist/runtime/routes.js +31 -1
- package/dist/runtime/routes.js.map +1 -1
- package/dist/runtime/server.d.ts +7 -5
- package/dist/runtime/server.js +6 -7
- package/dist/runtime/signals.d.ts +60 -3
- package/dist/runtime/signals.js +40 -2
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/testing.d.ts +46 -5
- package/dist/runtime/testing.js +240 -33
- package/dist/runtime/testing.js.map +1 -1
- package/dist/runtime/values.d.ts +2 -0
- package/dist/runtime/values.js +24 -0
- package/dist/runtime/values.js.map +1 -0
- package/dist/secrets-BxagsJxJ.js +23 -0
- package/dist/secrets-BxagsJxJ.js.map +1 -0
- package/dist/server-CxVDYE_V.js +3417 -0
- package/dist/server-CxVDYE_V.js.map +1 -0
- package/dist/server-DuFYRXrd.d.ts +1460 -0
- package/dist/skew-FRmAy9iy.js +49 -0
- package/dist/skew-FRmAy9iy.js.map +1 -0
- package/dist/standard-schema-BNY82yX3.d.ts +63 -0
- package/dist/{static-loader-BcFh4ebX.d.ts → static-loader-Drpr0AzI.d.ts} +2 -2
- package/dist/static-loader-nZssh66R.js +333 -0
- package/dist/static-loader-nZssh66R.js.map +1 -0
- package/dist/stream-DCYZO4IF.js +424 -0
- package/dist/stream-DCYZO4IF.js.map +1 -0
- package/dist/values-B8C7CLvG.d.ts +63 -0
- package/dist/vite.d.ts +49 -1
- package/dist/vite.js +598 -68
- package/dist/vite.js.map +1 -1
- package/forms/forms.brm.ts +141 -0
- package/package.json +45 -3
- package/types.d.ts +9 -1
- package/dist/client-routes-DakuM32C.js.map +0 -1
- package/dist/context-BG8KCF3v.js +0 -15
- package/dist/context-BG8KCF3v.js.map +0 -1
- package/dist/context-aeo9esY9.d.ts +0 -16
- package/dist/cookies-Av5WFmcf.js.map +0 -1
- package/dist/devtools-BKjnHrnv.js +0 -113
- package/dist/devtools-BKjnHrnv.js.map +0 -1
- package/dist/devtools-panel-AWOn0VK2.js +0 -434
- package/dist/devtools-panel-AWOn0VK2.js.map +0 -1
- package/dist/files-DdT84mPy.js.map +0 -1
- package/dist/html-DEeoepg3.js +0 -152
- package/dist/html-DEeoepg3.js.map +0 -1
- package/dist/html-Du8jY2Cc.d.ts +0 -53
- package/dist/inspect-BPchdWbU.js.map +0 -1
- package/dist/loader-Dc9OwY5I.js.map +0 -1
- package/dist/navigate-CzLjnoPH.js.map +0 -1
- package/dist/produce-BRGHP7e0.js +0 -126
- package/dist/produce-BRGHP7e0.js.map +0 -1
- package/dist/produce-CtZ32UGG.d.ts +0 -60
- package/dist/rpc-9fSqL_YK.js.map +0 -1
- package/dist/runtime/client.js.map +0 -1
- package/dist/server-BxqjLUnV.d.ts +0 -753
- package/dist/server-DZsgnPKS.js +0 -1615
- package/dist/server-DZsgnPKS.js.map +0 -1
- package/dist/shared-CWYOd0H3.js +0 -40
- package/dist/shared-CWYOd0H3.js.map +0 -1
- package/dist/static-loader-ClNkHZGn.js +0 -185
- package/dist/static-loader-ClNkHZGn.js.map +0 -1
- package/dist/stream-bgNCMcaA.js +0 -280
- package/dist/stream-bgNCMcaA.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createContext, t as Context } from "../context-
|
|
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 };
|
package/dist/runtime/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as createContext } from "../context-
|
|
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 {
|
|
1
|
+
import { Mt as NavigationReport, l as Scope } from "../client-D0CqSxoO.js";
|
|
2
|
+
import { s as ScopeId } from "../produce-D0V0ICkz.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?:
|
|
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;
|
|
@@ -14,23 +15,208 @@ export interface DevtoolsEntry {
|
|
|
14
15
|
slot: number;
|
|
15
16
|
};
|
|
16
17
|
}
|
|
18
|
+
/** What the plugin tells the devtools about the dev server. */
|
|
19
|
+
export interface DevtoolsMeta {
|
|
20
|
+
version?: string;
|
|
21
|
+
vite?: string;
|
|
22
|
+
}
|
|
23
|
+
/** An error for the Errors tab: of a render on the server, of Vite, or of code in the browser. */
|
|
24
|
+
export interface ErrorEntry {
|
|
25
|
+
time: number;
|
|
26
|
+
source: "server" | "compile" | "browser";
|
|
27
|
+
message: string;
|
|
28
|
+
stack?: string;
|
|
29
|
+
/** The lines around the error, as Vite's overlay shows them. */
|
|
30
|
+
frame?: string;
|
|
31
|
+
/** The place of the error, such as a compile error in a `.brm` file. */
|
|
32
|
+
loc?: {
|
|
33
|
+
file: string;
|
|
34
|
+
line: number;
|
|
35
|
+
column: number;
|
|
36
|
+
};
|
|
37
|
+
/** The plugin that threw it, such as `brumate`. */
|
|
38
|
+
plugin?: string;
|
|
39
|
+
}
|
|
40
|
+
/** What Vite's overlay gets, and what `errorPage` sends. */
|
|
41
|
+
export interface ErrorPayload {
|
|
42
|
+
message: string;
|
|
43
|
+
stack?: string;
|
|
44
|
+
frame?: string;
|
|
45
|
+
plugin?: string;
|
|
46
|
+
id?: string;
|
|
47
|
+
loc?: {
|
|
48
|
+
file?: string;
|
|
49
|
+
line: number;
|
|
50
|
+
column: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** The part of `import.meta.hot` that the devtools listen to. */
|
|
54
|
+
interface HotContext {
|
|
55
|
+
on(event: string, listener: (payload: never) => void): void;
|
|
56
|
+
}
|
|
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
|
+
/** A server function call, for the Timeline tab. */
|
|
74
|
+
export interface CallTiming {
|
|
75
|
+
name: string;
|
|
76
|
+
start: number;
|
|
77
|
+
end?: number;
|
|
78
|
+
/** The status of the answer, `redirect` for a redirect, or `failed`. */
|
|
79
|
+
status?: number | "redirect" | "failed";
|
|
80
|
+
/** How long the function took on the server, from the `Server-Timing` of the dev server. */
|
|
81
|
+
server?: number;
|
|
82
|
+
}
|
|
83
|
+
/** A batch of updates that a write ran, with its effects. */
|
|
84
|
+
export interface UpdateTiming {
|
|
85
|
+
count: number;
|
|
86
|
+
start: number;
|
|
87
|
+
end: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A handler that ran, for the Timeline tab: when its event came, when its
|
|
91
|
+
* code was ready and the handlers before it had started, when its call
|
|
92
|
+
* returned, and when the promise of an async handler settled. The server
|
|
93
|
+
* calls and the updates that ran meanwhile are its own.
|
|
94
|
+
*/
|
|
95
|
+
export interface Interaction {
|
|
96
|
+
ref: string;
|
|
97
|
+
/** What happened, such as `click on <button>`. */
|
|
98
|
+
label: string;
|
|
99
|
+
begun: number;
|
|
100
|
+
ready: number;
|
|
101
|
+
end: number;
|
|
102
|
+
settled?: number;
|
|
103
|
+
failed?: boolean;
|
|
104
|
+
calls: CallTiming[];
|
|
105
|
+
updates: UpdateTiming[];
|
|
106
|
+
}
|
|
107
|
+
/** A block of the page that renders later, for the Blocks tab. */
|
|
108
|
+
export interface BlockEntry {
|
|
109
|
+
kind: "loading" | "defer" | "client" | "$client";
|
|
110
|
+
/** The boundary of `#loading` and `#defer`, or the `b-b` of the template of the others. */
|
|
111
|
+
id: string;
|
|
112
|
+
/** The trigger of `#defer`, `#client` and `$client`. */
|
|
113
|
+
trigger?: string;
|
|
114
|
+
/** The reference that `#client` and `$client` run. */
|
|
115
|
+
ref?: string;
|
|
116
|
+
/** The template that the loader reads for `#defer`, `#client` and `$client`. */
|
|
117
|
+
template?: Element;
|
|
118
|
+
state: "waiting" | "loading" | "streaming" | "rendered" | "failed";
|
|
119
|
+
/** When the panel first saw the block, when its trigger fired, and when it rendered. */
|
|
120
|
+
seen: number;
|
|
121
|
+
fired?: number;
|
|
122
|
+
rendered?: number;
|
|
123
|
+
/** True while the devtools show its fallback in place of its body. */
|
|
124
|
+
fallback?: boolean;
|
|
125
|
+
}
|
|
126
|
+
/** The loads that are preloads, which the Loading tab marks when nothing used them. */
|
|
127
|
+
export declare const PRELOADS: ReadonlySet<string>;
|
|
128
|
+
/** An effect or a `$client` callback of a scope, with how it ran. */
|
|
129
|
+
export interface EffectEntry {
|
|
130
|
+
scope: ScopeId;
|
|
131
|
+
/** The ID of the component of the scope, and the scope's number in it. */
|
|
132
|
+
component: string;
|
|
133
|
+
k: number;
|
|
134
|
+
/** Its name in the update code: `e<n>` for an effect, `c<n>` for a `$client` callback. */
|
|
135
|
+
name: string;
|
|
136
|
+
runs: number;
|
|
137
|
+
/** When its last runs were, the newest last, at most 50. */
|
|
138
|
+
recent: number[];
|
|
139
|
+
/** The time of all its runs, in milliseconds. */
|
|
140
|
+
time: number;
|
|
141
|
+
cleanups: number;
|
|
142
|
+
lastCleanup?: number;
|
|
143
|
+
/** False once its cleanup ran and it has not run again, such as in a removed scope. */
|
|
144
|
+
active: boolean;
|
|
145
|
+
}
|
|
17
146
|
export interface DevtoolsState {
|
|
18
|
-
scopes?: Map<
|
|
147
|
+
scopes?: Map<ScopeId, Scope>;
|
|
19
148
|
/** Writes a slot, as a handler does, so the page updates. */
|
|
20
149
|
set?: (scope: Scope, slot: number, value: unknown) => void;
|
|
150
|
+
/** Runs a reference for an element, as the loader does for a trigger. */
|
|
151
|
+
handle?: (element: Element, ref: string, event?: Event) => Promise<unknown>;
|
|
21
152
|
log: DevtoolsEntry[];
|
|
153
|
+
/** The code that loaded, by `component:part`, in the order it started. */
|
|
154
|
+
loads: Map<string, LoadEntry>;
|
|
155
|
+
/** The blocks of the page, by kind and ID. */
|
|
156
|
+
blocks: Map<string, BlockEntry>;
|
|
157
|
+
/** Asks the server for the body of a `#defer` block now. */
|
|
158
|
+
fire?: (block: BlockEntry) => void;
|
|
159
|
+
/**
|
|
160
|
+
* Shows the fallback of a `#loading` or `#defer` block in place of its
|
|
161
|
+
* body, or its body again. False when the page did not keep its fallback.
|
|
162
|
+
*/
|
|
163
|
+
showFallback?: (block: BlockEntry, on: boolean) => boolean;
|
|
22
164
|
/** The scopes written since the panel last drew, by scope ID. */
|
|
23
|
-
written: Set<
|
|
165
|
+
written: Set<ScopeId>;
|
|
24
166
|
/** The URL prefix of the inspect endpoint of the dev server. */
|
|
25
167
|
endpoint: string;
|
|
168
|
+
/** The versions of brumate and Vite, from the plugin. */
|
|
169
|
+
meta: DevtoolsMeta;
|
|
170
|
+
/** The errors of the page, oldest first. */
|
|
171
|
+
errors: ErrorEntry[];
|
|
172
|
+
/** The handlers that ran, oldest first, with their calls and updates. */
|
|
173
|
+
timeline: Interaction[];
|
|
174
|
+
/** The effects and `$client` callbacks that ran, by scope and name. */
|
|
175
|
+
effects: Map<string, EffectEntry>;
|
|
176
|
+
/** The client navigations of the page, newest last, at most 20. */
|
|
177
|
+
navigations: NavigationReport[];
|
|
178
|
+
/** Opens the panel on a tab, such as `errors`. */
|
|
179
|
+
open?: (tab: string) => void;
|
|
180
|
+
/** Shows the number of errors on the tab. */
|
|
181
|
+
errorCount?: () => void;
|
|
182
|
+
/** True while the elements that change are outlined on the page. */
|
|
183
|
+
flash: boolean;
|
|
184
|
+
/** Turns the outlines of changed elements on or off, and keeps the choice. */
|
|
185
|
+
setFlash?: (on: boolean) => void;
|
|
186
|
+
/** While the panel is open: sets its top edge to a place of the pointer, and keeps it. */
|
|
187
|
+
resize?: (clientY: number) => void;
|
|
188
|
+
resized?: () => void;
|
|
26
189
|
/** Called after each change, while the panel is open. */
|
|
27
190
|
changed?: () => void;
|
|
28
191
|
}
|
|
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>";
|
|
29
197
|
/** The root scope of a scope, whose `m` names its component. */
|
|
30
198
|
export declare function rootOf(scope: Scope): Scope;
|
|
31
199
|
/** A short text for a value in the log. */
|
|
32
200
|
export declare function preview(value: unknown): string;
|
|
201
|
+
/**
|
|
202
|
+
* Reads the blocks of the page from their markers, and updates their state.
|
|
203
|
+
* Returns true when something changed.
|
|
204
|
+
*
|
|
205
|
+
* - `#defer`: a `<template b-defer>`, and `<!--l…-->` around its fallback until its body arrives.
|
|
206
|
+
* - `#loading`: `<!--l…-->` around its fallback until the server streams its body.
|
|
207
|
+
* - `#client`: a `<template b-client>` with a `#k` reference, and a marker that gets `:1` once
|
|
208
|
+
* its body rendered.
|
|
209
|
+
* - `$client`: a `<template b-client>` with a `#c` reference.
|
|
210
|
+
*/
|
|
211
|
+
export declare function scanBlocks(state: DevtoolsState): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Adds an error to the Errors tab. An error of the server or of Vite opens
|
|
214
|
+
* the panel on it, as Vite's overlay would. An error of the browser only
|
|
215
|
+
* counts on the button.
|
|
216
|
+
*/
|
|
217
|
+
export declare function reportError(state: DevtoolsState, payload: ErrorPayload, source: ErrorEntry["source"]): void;
|
|
33
218
|
/** Listens to the core, and adds the button that opens the panel. */
|
|
34
|
-
export declare function installDevtools(endpoint?: string, rpc?: string): DevtoolsState;
|
|
219
|
+
export declare function installDevtools(endpoint?: string, rpc?: string, meta?: DevtoolsMeta, hot?: HotContext): DevtoolsState;
|
|
35
220
|
//#endregion
|
|
221
|
+
export {};
|
|
36
222
|
//# sourceMappingURL=devtools.d.ts.map
|
package/dist/runtime/devtools.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as
|
|
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";
|
|
@@ -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,42 @@
|
|
|
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
|
+
/**
|
|
24
|
+
* Runs the handler inside a view transition, so the browser animates the
|
|
25
|
+
* change of the page, such as an element that `#if` removes or a list that
|
|
26
|
+
* changes order. CSS styles the animation, with `view-transition-name` and
|
|
27
|
+
* `::view-transition-*`.
|
|
28
|
+
*
|
|
29
|
+
* - The transition holds the writes that the handler makes before its first
|
|
30
|
+
* `await`. Writes after it, such as after a server call, change the page
|
|
31
|
+
* without an animation.
|
|
32
|
+
* - `types` are the types of the transition, which `:active-view-transition-type()`
|
|
33
|
+
* matches in CSS.
|
|
34
|
+
* - Without view transitions, or with `prefers-reduced-motion`, the handler
|
|
35
|
+
* runs as it is.
|
|
36
|
+
*/
|
|
37
|
+
export declare function transition<H extends Handler>(handler: H, ...types: string[]): H;
|
|
38
|
+
/** Runs the handler before the handlers of the elements inside, as a listener in the capture phase. */
|
|
39
|
+
export declare function capture<H extends Handler>(handler: H): H;
|
|
40
|
+
//#endregion
|
|
41
|
+
export {};
|
|
42
|
+
//# 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, s as transition } from "../events-CSs7OwIC.js";
|
|
@@ -0,0 +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 };
|
|
@@ -0,0 +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";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/runtime/gather.d.ts
|
|
2
|
+
export interface GatherOptions<T> {
|
|
3
|
+
/**
|
|
4
|
+
* The key of an item. A value with a key that the stream sent before
|
|
5
|
+
* takes the place of that item, so a stream can update an item in place.
|
|
6
|
+
*/
|
|
7
|
+
key?: (item: T) => unknown;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Gathers the values of a stream into a list, and gives the list so far
|
|
11
|
+
* after each one, starting with an empty list:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const tokens = $memo(gather(reply(prompt)));
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* - The memo starts again with an empty list when the stream changes, such
|
|
18
|
+
* as for a new prompt, and stops reading the older stream.
|
|
19
|
+
* - The empty list comes before the stream is read, so the server, which
|
|
20
|
+
* renders the first value of a memo, renders it without starting the
|
|
21
|
+
* stream. The list fills in the browser, when the memo runs there.
|
|
22
|
+
*/
|
|
23
|
+
export declare function gather<T>(stream: AsyncIterable<T> | PromiseLike<AsyncIterable<T>>, options?: GatherOptions<T>): AsyncGenerator<T[], void, undefined>;
|
|
24
|
+
//#endregion
|
|
25
|
+
//# sourceMappingURL=gather.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/runtime/gather.ts
|
|
2
|
+
/**
|
|
3
|
+
* Gathers the values of a stream into a list, and gives the list so far
|
|
4
|
+
* after each one, starting with an empty list:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const tokens = $memo(gather(reply(prompt)));
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* - The memo starts again with an empty list when the stream changes, such
|
|
11
|
+
* as for a new prompt, and stops reading the older stream.
|
|
12
|
+
* - The empty list comes before the stream is read, so the server, which
|
|
13
|
+
* renders the first value of a memo, renders it without starting the
|
|
14
|
+
* stream. The list fills in the browser, when the memo runs there.
|
|
15
|
+
*/
|
|
16
|
+
async function* gather(stream, options = {}) {
|
|
17
|
+
yield [];
|
|
18
|
+
const items = [];
|
|
19
|
+
const places = /* @__PURE__ */ new Map();
|
|
20
|
+
for await (const item of await stream) {
|
|
21
|
+
const key = options.key?.(item);
|
|
22
|
+
const place = options.key ? places.get(key) : void 0;
|
|
23
|
+
if (place === void 0) {
|
|
24
|
+
if (options.key) places.set(key, items.length);
|
|
25
|
+
items.push(item);
|
|
26
|
+
} else items[place] = item;
|
|
27
|
+
yield [...items];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { gather };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=gather.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gather.js","names":[],"sources":["../../src/runtime/gather.ts"],"sourcesContent":["// `brumate/stream`: a list that grows as a stream sends its values, such as\n// the reply of a language model, search results or log lines. A memo of it\n// gives the list so far, so `#for` renders each item as it arrives.\n\nexport interface GatherOptions<T> {\n /**\n * The key of an item. A value with a key that the stream sent before\n * takes the place of that item, so a stream can update an item in place.\n */\n key?: (item: T) => unknown;\n}\n\n/**\n * Gathers the values of a stream into a list, and gives the list so far\n * after each one, starting with an empty list:\n *\n * ```ts\n * const tokens = $memo(gather(reply(prompt)));\n * ```\n *\n * - The memo starts again with an empty list when the stream changes, such\n * as for a new prompt, and stops reading the older stream.\n * - The empty list comes before the stream is read, so the server, which\n * renders the first value of a memo, renders it without starting the\n * stream. The list fills in the browser, when the memo runs there.\n */\nexport async function* gather<T>(\n stream: AsyncIterable<T> | PromiseLike<AsyncIterable<T>>,\n options: GatherOptions<T> = {},\n): AsyncGenerator<T[], void, undefined> {\n yield [];\n const items: T[] = [];\n const places = new Map<unknown, number>();\n for await (const item of await stream) {\n const key = options.key?.(item);\n const place = options.key ? places.get(key) : undefined;\n if (place === undefined) {\n if (options.key) {\n places.set(key, items.length);\n }\n items.push(item);\n } else {\n items[place] = item;\n }\n // A new array, so the memo sees a new value.\n yield [...items];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,gBAAuB,OACrB,QACA,UAA4B,CAAC,GACS;CACtC,MAAM,CAAC;CACP,MAAM,QAAa,CAAC;CACpB,MAAM,yBAAS,IAAI,IAAqB;CACxC,WAAW,MAAM,QAAQ,MAAM,QAAQ;EACrC,MAAM,MAAM,QAAQ,MAAM,IAAI;EAC9B,MAAM,QAAQ,QAAQ,MAAM,OAAO,IAAI,GAAG,IAAI,KAAA;EAC9C,IAAI,UAAU,KAAA,GAAW;GACvB,IAAI,QAAQ,KACV,OAAO,IAAI,KAAK,MAAM,MAAM;GAE9B,MAAM,KAAK,IAAI;EACjB,OACE,MAAM,SAAS;EAGjB,MAAM,CAAC,GAAG,KAAK;CACjB;AACF"}
|
package/dist/runtime/hot.d.ts
CHANGED
package/dist/runtime/html.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
export { Raw, VOID_ELEMENTS, actionAttributes, affix, attribute, attributeText, classAttribute, classValue, escape, escapeAttribute, insertValue, isRaw, raw, rawHTML, spread, styleElement, textValue, vars };
|
|
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 };
|
package/dist/runtime/html.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as VOID_ELEMENTS, n as actionAttributes, r as affix, i as attribute, a as attributeText, o as
|
|
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";
|
package/dist/runtime/loader.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as NavigateOptions, t as LoaderOptions } from "../boot-
|
|
2
|
-
import { t as startWithoutNavigation } from "../static-loader-
|
|
1
|
+
import { n as NavigateOptions, t as LoaderOptions } from "../boot-C25Sa6vq.js";
|
|
2
|
+
import { t as startWithoutNavigation } from "../static-loader-Drpr0AzI.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
|
package/dist/runtime/loader.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as startWithoutNavigation } from "../static-loader-
|
|
2
|
-
import { t as start } from "../loader-
|
|
1
|
+
import { t as startWithoutNavigation } from "../static-loader-nZssh66R.js";
|
|
2
|
+
import { t as start } from "../loader-Dos_3NP0.js";
|
|
3
3
|
export { start, startWithoutNavigation };
|
package/dist/runtime/routes.d.ts
CHANGED
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
|
|
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 };
|
package/dist/runtime/routes.js
CHANGED
|
@@ -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"}
|
package/dist/runtime/server.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { a as attribute,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
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
|
+
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 { 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 };
|