brumate 0.5.1 → 0.6.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-Difa0qdg.d.ts → boot-CMvhoWRu.d.ts} +2 -2
- package/dist/cli.js +2 -2
- package/dist/{client-DvsU9qxG.d.ts → client-C4kNKGwH.d.ts} +18 -5
- package/dist/{client-BYHGusTe.js → client-eVI8Wc95.js} +199 -33
- package/dist/client-eVI8Wc95.js.map +1 -0
- package/dist/{defer-B63oF5Oa.js → defer-pKO0S6UT.js} +2 -2
- package/dist/{defer-B63oF5Oa.js.map → defer-pKO0S6UT.js.map} +1 -1
- package/dist/{devtools-D_SQpXTg.js → devtools-DqqqdI4b.js} +4 -4
- package/dist/{devtools-D_SQpXTg.js.map → devtools-DqqqdI4b.js.map} +1 -1
- package/dist/{devtools-panel-B9yokst5.js → devtools-panel--GYjFZ35.js} +2 -2
- package/dist/{devtools-panel-B9yokst5.js.map → devtools-panel--GYjFZ35.js.map} +1 -1
- package/dist/{features-D5kLyihb.js → features-CbgII-o7.js} +4 -2
- package/dist/features-CbgII-o7.js.map +1 -0
- package/dist/{files-s4wmjcZV.js → files-CR-V05xd.js} +2 -2
- package/dist/{files-s4wmjcZV.js.map → files-CR-V05xd.js.map} +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +2 -7
- package/dist/index.js.map +1 -1
- package/dist/{inspect-BLPt-dZZ.js → inspect-ddfGeww0.js} +236 -57
- package/dist/inspect-ddfGeww0.js.map +1 -0
- package/dist/{loader-DKxhLjJw.js → loader-CQkAXO0g.js} +11 -3
- package/dist/loader-CQkAXO0g.js.map +1 -0
- package/dist/routes-D21FQyGF.js +51 -0
- package/dist/routes-D21FQyGF.js.map +1 -0
- package/dist/{rpc-CIVU4Ktx.js → rpc-BgYnfg_a.js} +3 -3
- package/dist/{rpc-CIVU4Ktx.js.map → rpc-BgYnfg_a.js.map} +1 -1
- package/dist/runtime/bundles.d.ts +1 -1
- package/dist/runtime/client.d.ts +2 -2
- package/dist/runtime/client.js +3 -3
- package/dist/runtime/devtools.d.ts +1 -1
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/routes.js +1 -51
- package/dist/runtime/server.d.ts +2 -2
- package/dist/runtime/server.js +3 -3
- package/dist/runtime/signals.d.ts +2 -140
- package/dist/runtime/signals.js +4 -1
- 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 +24 -4
- package/dist/runtime/testing.js +66 -2
- package/dist/runtime/testing.js.map +1 -1
- package/dist/{produce-Cq6KKi7b.js → search-params-CM1RWR2P.js} +25 -3
- package/dist/search-params-CM1RWR2P.js.map +1 -0
- package/dist/{server-Doy5HR7r.js → server-BcT9icQ4.js} +107 -40
- package/dist/server-BcT9icQ4.js.map +1 -0
- package/dist/{server-CAwIqrXl.d.ts → server-dP_ucRiJ.d.ts} +42 -3
- package/dist/signals-BwD4u22K.d.ts +165 -0
- package/dist/{static-loader-9Nc1GvF0.d.ts → static-loader-CGthkX0s.d.ts} +2 -2
- package/dist/{static-loader-Bdet7g76.js → static-loader-DCxASuzA.js} +3 -3
- package/dist/{static-loader-Bdet7g76.js.map → static-loader-DCxASuzA.js.map} +1 -1
- package/dist/{stream-BdhzvPQO.js → stream-DRjx0keF.js} +2 -2
- package/dist/{stream-BdhzvPQO.js.map → stream-DRjx0keF.js.map} +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +17 -12
- package/dist/vite.js.map +1 -1
- package/elements.d.ts +231 -35
- package/package.json +6 -1
- package/skills/brumate/references/errors.md +32 -12
- package/skills/brumate/references/signals.md +27 -25
- package/skills/brumate/references/syntax.md +1 -1
- package/dist/client-BYHGusTe.js.map +0 -1
- package/dist/features-D5kLyihb.js.map +0 -1
- package/dist/inspect-BLPt-dZZ.js.map +0 -1
- package/dist/loader-DKxhLjJw.js.map +0 -1
- package/dist/produce-Cq6KKi7b.js.map +0 -1
- package/dist/runtime/routes.js.map +0 -1
- package/dist/server-Doy5HR7r.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { p as HAS_SEARCH_PARAMS } from "./features-CbgII-o7.js";
|
|
1
2
|
import { n as ROUTE_KEY, t as NAVIGATION_KEY } from "./context-CTiSzQRc.js";
|
|
2
|
-
import { n as boot, r as importCore } from "./static-loader-
|
|
3
|
+
import { n as boot, r as importCore } from "./static-loader-DCxASuzA.js";
|
|
3
4
|
//#region src/runtime/loader.ts
|
|
4
5
|
/**
|
|
5
6
|
* Starts resuming the page. Listens to the events in `b-on` attributes
|
|
@@ -132,12 +133,19 @@ function navigation({ options, listen, core, start: startCore, scan }) {
|
|
|
132
133
|
}
|
|
133
134
|
});
|
|
134
135
|
listen(document, "brumate:reload", () => void go(location.href, { method: "GET" }, false));
|
|
136
|
+
if (HAS_SEARCH_PARAMS) listen(document, "brumate:search", () => {
|
|
137
|
+
page = location.href.split("#")[0];
|
|
138
|
+
});
|
|
135
139
|
listen(window, "popstate", () => {
|
|
136
|
-
|
|
140
|
+
const target = location.href.split("#")[0];
|
|
141
|
+
if (target !== page) {
|
|
142
|
+
if ((HAS_SEARCH_PARAMS ? globalThis[Symbol.for("brumate.search")] : void 0)?.(page)) page = target;
|
|
143
|
+
else go(location.href, void 0, false);
|
|
144
|
+
}
|
|
137
145
|
});
|
|
138
146
|
return () => Promise.all([importCore(), document.querySelector("[b-offset],[b-roots]") && routes()]).then(([client]) => client);
|
|
139
147
|
}
|
|
140
148
|
//#endregion
|
|
141
149
|
export { start as t };
|
|
142
150
|
|
|
143
|
-
//# sourceMappingURL=loader-
|
|
151
|
+
//# sourceMappingURL=loader-CQkAXO0g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader-CQkAXO0g.js","names":[],"sources":["../src/runtime/loader.ts"],"sourcesContent":["import type * as Routes from './client-routes.ts';\nimport { boot, importCore } from './boot.ts';\nimport { NAVIGATION_KEY, ROUTE_KEY } from './context.ts';\nimport { HAS_SEARCH_PARAMS } from './features.ts';\nimport type { Core, LoaderOptions, Navigation } from './boot.ts';\n\nexport type { LoaderOptions, NavigateOptions } from './boot.ts';\nexport { startWithoutNavigation } from './static-loader.ts';\n\n/**\n * Starts resuming the page. Listens to the events in `b-on` attributes\n * and loads `brumate/client` and the component's module on the first one.\n * Returns a function that removes the listeners and stops the core.\n */\nexport function start(options: LoaderOptions): () => void {\n return boot(options, options.navigate === false ? undefined : navigation);\n}\n\n/** Starts loading the page of a link, unless the link asks not to. */\nfunction prefetch(link: HTMLAnchorElement | undefined): void {\n if (link && link.getAttribute('data-prefetch') !== 'none') {\n void import('./navigate.ts').then((module) => module.prefetch(link.href));\n }\n}\n\n/**\n * Imports the code with which the core reads the pages that navigation adds.\n * A core that runs loads it when the loader navigates. A core that starts\n * later loads it with the core, when the page has records that navigation\n * marked.\n */\nfunction routes(): (typeof Routes)['ready'] {\n return import('./client-routes.ts').then((module) => module.ready);\n}\n\n/**\n * Loads pages without a full page load: links to the same origin, the back\n * and forward buttons, forms that post to a server function, and redirects\n * from server functions to the same origin. Returns how the loader imports\n * the core.\n */\nfunction navigation({\n options,\n listen,\n core,\n start: startCore,\n scan,\n}: Navigation): () => Promise<Core> {\n const rpc = `${options.rpc ?? '/_brumate'}/`;\n const settings = typeof options.navigate === 'object' ? options.navigate : {};\n // The page without its hash, to tell a change of the hash from a change of the page.\n let page = String(location.href).split('#')[0];\n // True once the site changed since the page loaded: the next page loads in full, with new code.\n let skewed = false;\n listen(document, 'brumate:skew', () => {\n skewed = true;\n });\n // The core when the page reads a context of navigation, which it starts for them, or when it runs.\n function reader(key: string): Promise<Core> | undefined {\n const running = core();\n if (running) {\n return running;\n }\n for (const script of document.querySelectorAll('script[b-state]')) {\n if (script.textContent?.includes(key)) {\n return startCore();\n }\n }\n return undefined;\n }\n function state(value: { pending: boolean; from?: string; to?: string }): void {\n void reader(NAVIGATION_KEY)?.then((client) => client.setGlobal(NAVIGATION_KEY, value));\n }\n function go(\n url: string,\n init?: RequestInit,\n push = true,\n reload = false,\n scroll = true,\n ): Promise<void> {\n const from = location.href;\n if (skewed) {\n // A form post cannot be a full page load: the page loads again, and the form is lost with\n // the rest of the state of the page.\n if (init) {\n location.reload();\n } else {\n location.assign(url);\n }\n return Promise.resolve();\n }\n page = url.split('#')[0]!;\n if (core()) {\n void routes();\n }\n // CSS can show a progress bar while a page loads, with no client code in the page.\n document.documentElement.setAttribute('data-navigating', '');\n state({ pending: true, from, to: new URL(url, from).href });\n function done(): void {\n document.documentElement.removeAttribute('data-navigating');\n state({ pending: false });\n }\n return import('./navigate.ts')\n .then((module) =>\n module.navigate({\n url,\n init,\n push,\n reload,\n scroll,\n build: options.build,\n focus: settings.focus !== false,\n transition: settings.transition === true,\n // The core forgets the old page, or only stops reading, when layouts stay.\n leave: async (partial) => {\n if (core()) {\n (await routes())(partial);\n }\n },\n enter: () => {\n // The core took the serial entry when it started.\n void core()?.then((client) =>\n client.init({ ...options, serial: undefined, listen: scan }),\n );\n // Code that reads the route, such as in a layout that stays, gets the new one.\n void reader(ROUTE_KEY)?.then((client) => client.updateRoute());\n page = location.href.split('#')[0]!;\n },\n }),\n )\n .finally(done);\n }\n // `navigate(href, options)` from `brumate/routes`.\n listen(document, 'brumate:navigate', (event) => {\n const detail = (\n event as CustomEvent<{ url: string; replace: boolean; scroll: boolean; done: () => void }>\n ).detail;\n event.preventDefault();\n void go(detail.url, undefined, !detail.replace, false, detail.scroll).then(detail.done);\n });\n // A link to another page of this site, which the loader loads itself.\n function pageLink(target: EventTarget | null): HTMLAnchorElement | undefined {\n const link = (target as Element | null)?.closest?.('a[href]') as HTMLAnchorElement | null;\n return link &&\n !link.target &&\n !link.matches('[download],[data-reload]') &&\n link.origin === location.origin &&\n // A link to a place in the same page scrolls there.\n !(link.hash && link.href.split('#')[0] === page)\n ? link\n : undefined;\n }\n listen(document, 'click', (event) => {\n const mouse = event as MouseEvent;\n const link = pageLink(event.target);\n if (\n !link ||\n event.defaultPrevented ||\n mouse.button ||\n mouse.metaKey ||\n mouse.ctrlKey ||\n mouse.shiftKey ||\n mouse.altKey\n ) {\n return;\n }\n event.preventDefault();\n void go(link.href);\n });\n // A page loads when the pointer rests on its link, or the link gets focus, so a click finds it loading.\n let resting: ReturnType<typeof setTimeout> | undefined;\n listen(\n document,\n 'pointerover',\n (event) => {\n const link = pageLink(event.target);\n if (link) {\n clearTimeout(resting);\n resting = setTimeout(() => prefetch(link), 80);\n }\n },\n { passive: true },\n );\n listen(document, 'pointerout', () => clearTimeout(resting), { passive: true });\n listen(document, 'focusin', (event) => prefetch(pageLink(event.target)));\n listen(document, 'submit', (event) => {\n const form = event.target as HTMLFormElement;\n const submitter = (event as SubmitEvent).submitter;\n const action = submitter?.getAttribute('formaction') ?? form.getAttribute('action') ?? '';\n const method = submitter?.getAttribute('formmethod') ?? form.getAttribute('method');\n if (\n event.defaultPrevented ||\n method?.toLowerCase() !== 'post' ||\n !action.startsWith(rpc) ||\n // After a deploy, the browser posts the form itself, and the page that answers is new.\n skewed\n ) {\n return;\n }\n event.preventDefault();\n void go(action, { method: 'POST', body: new FormData(form, submitter) });\n });\n // A server function that redirects, from `rpc.ts`. Another site loads in full.\n listen(document, 'brumate:redirect', (event) => {\n const url = new URL((event as CustomEvent<string>).detail, location.href);\n if (url.origin === location.origin) {\n event.preventDefault();\n void go(url.href, undefined, true, true);\n }\n });\n // A hot update whose markup changed loads the page again, in place. With `init`, the whole\n // page is replaced, as for a form, so layouts render again too, and it keeps the scroll.\n listen(document, 'brumate:reload', () => void go(location.href, { method: 'GET' }, false));\n // The query string moved by `$searchParam` stays on the page, so the next change is told from it.\n if (HAS_SEARCH_PARAMS) {\n listen(document, 'brumate:search', () => {\n page = location.href.split('#')[0]!;\n });\n }\n listen(window, 'popstate', () => {\n // A change of the hash only stays on the page.\n const target = location.href.split('#')[0]!;\n if (target !== page) {\n // `$searchParam` follows the history itself when only its parameters changed.\n const follow = HAS_SEARCH_PARAMS\n ? (globalThis as Record<symbol, ((from: string) => boolean) | undefined>)[\n Symbol.for('brumate.search')\n ]\n : undefined;\n if (follow?.(page)) {\n page = target;\n } else {\n void go(location.href, undefined, false);\n }\n }\n });\n return () =>\n Promise.all([importCore(), document.querySelector('[b-offset],[b-roots]') && routes()]).then(\n ([client]) => client,\n );\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgB,MAAM,SAAoC;CACxD,OAAO,KAAK,SAAS,QAAQ,aAAa,QAAQ,KAAA,IAAY,UAAU;AAC1E;;AAGA,SAAS,SAAS,MAA2C;CAC3D,IAAI,QAAQ,KAAK,aAAa,eAAe,MAAM,QACjD,OAAY,yBAAgB,CAAC,MAAM,WAAW,OAAO,SAAS,KAAK,IAAI,CAAC;AAE5E;;;;;;;AAQA,SAAS,SAAmC;CAC1C,OAAO,OAAO,8BAAqB,CAAC,MAAM,WAAW,OAAO,KAAK;AACnE;;;;;;;AAQA,SAAS,WAAW,EAClB,SACA,QACA,MACA,OAAO,WACP,QACkC;CAClC,MAAM,MAAM,GAAG,QAAQ,OAAO,YAAY;CAC1C,MAAM,WAAW,OAAO,QAAQ,aAAa,WAAW,QAAQ,WAAW,CAAC;CAE5E,IAAI,OAAO,OAAO,SAAS,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;CAE5C,IAAI,SAAS;CACb,OAAO,UAAU,sBAAsB;EACrC,SAAS;CACX,CAAC;CAED,SAAS,OAAO,KAAwC;EACtD,MAAM,UAAU,KAAK;EACrB,IAAI,SACF,OAAO;EAET,KAAK,MAAM,UAAU,SAAS,iBAAiB,iBAAiB,GAC9D,IAAI,OAAO,aAAa,SAAS,GAAG,GAClC,OAAO,UAAU;CAIvB;CACA,SAAS,MAAM,OAA+D;EAC5E,OAAY,cAAc,CAAC,EAAE,MAAM,WAAW,OAAO,UAAU,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C9C,MAAM,MAAM,IAAI,IAAK,MAA8B,QAAQ,SAAS,IAAI;EACxE,IAAI,IAAI,WAAW,SAAS,QAAQ;GAClC,MAAM,eAAe;GACrB,GAAQ,IAAI,MAAM,KAAA,GAAW,MAAM,IAAI;EACzC;CACF,CAAC;CAGD,OAAO,UAAU,wBAAwB,KAAK,GAAG,SAAS,MAAM,EAAE,QAAQ,MAAM,GAAG,KAAK,CAAC;CAEzF,IAAI,mBACF,OAAO,UAAU,wBAAwB;EACvC,OAAO,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC;CAClC,CAAC;CAEH,OAAO,QAAQ,kBAAkB;EAE/B,MAAM,SAAS,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC;EACxC,IAAI,WAAW,MAAM;GAOnB,KALe,oBACV,WACC,OAAO,IAAI,gBAAgB,KAE7B,KAAA,EAAA,GACS,IAAI,GACf,OAAO;QAEP,GAAQ,SAAS,MAAM,KAAA,GAAW,KAAK;EAE3C;CACF,CAAC;CACD,aACE,QAAQ,IAAI,CAAC,WAAW,GAAG,SAAS,cAAc,sBAAsB,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,MACrF,CAAC,YAAY,MAChB;AACJ"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/runtime/routes.ts
|
|
2
|
+
/**
|
|
3
|
+
* The URL of a route, with its params in place:
|
|
4
|
+
* `href('/todos/[id]', { id: '3' })` is `/todos/3`. A rest param, such as
|
|
5
|
+
* `[...path]`, keeps its slashes.
|
|
6
|
+
*/
|
|
7
|
+
function href(path, ...[params]) {
|
|
8
|
+
const values = params ?? {};
|
|
9
|
+
return path.replace(/\[(\.\.\.)?([^\]]+)\]/g, (_, rest, name) => {
|
|
10
|
+
const value = values[name];
|
|
11
|
+
if (value === void 0 || value === "") throw new Error(`The param ${name} of ${path} is missing`);
|
|
12
|
+
if (!rest) return encodeURIComponent(String(value));
|
|
13
|
+
const parts = [];
|
|
14
|
+
for (const part of String(value).split("/")) parts.push(encodeURIComponent(part));
|
|
15
|
+
return parts.join("/");
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Loads a page as a link does: the layouts that stay keep their state. It
|
|
20
|
+
* returns when the page shows. A URL of another origin, or a page without
|
|
21
|
+
* the loader, loads in full.
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* await navigate(href('/issues/[id]', { id: issue.id }));
|
|
25
|
+
* navigate(`?q=${query}`, { replace: true });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function navigate(to, options = {}) {
|
|
29
|
+
const url = new URL(to, location.href);
|
|
30
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return Promise.reject(/* @__PURE__ */ new TypeError(`navigate loads http and https URLs, not ${url.protocol}`));
|
|
31
|
+
if (url.origin !== location.origin) {
|
|
32
|
+
location.assign(url.href);
|
|
33
|
+
return new Promise(() => {});
|
|
34
|
+
}
|
|
35
|
+
return new Promise((resolve) => {
|
|
36
|
+
const event = new CustomEvent("brumate:navigate", {
|
|
37
|
+
cancelable: true,
|
|
38
|
+
detail: {
|
|
39
|
+
url: url.href,
|
|
40
|
+
replace: options.replace === true,
|
|
41
|
+
scroll: options.scroll !== false,
|
|
42
|
+
done: resolve
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
if (document.dispatchEvent(event)) location.assign(url.href);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { navigate as n, href as t };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=routes-D21FQyGF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-D21FQyGF.js","names":[],"sources":["../src/runtime/routes.ts"],"sourcesContent":["// Links to routes, checked against the route files. The Vite plugin writes\n// the paths into `Routes` in a declaration file, such as\n// `src/brumate-routes.d.ts`.\n\n/**\n * The paths of the routes, with their params, such as\n * `'/todos/[id]': { id: string }`. The Vite plugin adds them.\n */\n// oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type -- Declaration files add the routes.\nexport interface Routes {}\n\n/** A route path, such as `/todos/[id]`. Any string while no routes are declared. */\nexport type RoutePath = [keyof Routes] extends [never] ? string : keyof Routes & string;\n\n/** The params of a route path, such as `{ id: string }` for `/todos/[id]`. */\nexport type RouteParams<P extends RoutePath> = P extends keyof Routes\n ? Routes[P]\n : Record<string, string>;\n\n/** The arguments after the path: none for a path without params. */\ntype ParamsArgument<P extends RoutePath> = [keyof RouteParams<P>] extends [never]\n ? [params?: RouteParams<P>]\n : [params: RouteParams<P>];\n\n/**\n * The URL of a route, with its params in place:\n * `href('/todos/[id]', { id: '3' })` is `/todos/3`. A rest param, such as\n * `[...path]`, keeps its slashes.\n */\nexport function href<P extends RoutePath>(path: P, ...[params]: ParamsArgument<P>): string {\n const values = (params ?? {}) as Record<string, string>;\n return path.replace(/\\[(\\.\\.\\.)?([^\\]]+)\\]/g, (_, rest: string | undefined, name: string) => {\n const value = values[name];\n if (value === undefined || value === '') {\n throw new Error(`The param ${name} of ${path} is missing`);\n }\n if (!rest) {\n return encodeURIComponent(String(value));\n }\n const parts: string[] = [];\n for (const part of String(value).split('/')) {\n parts.push(encodeURIComponent(part));\n }\n return parts.join('/');\n });\n}\n\nexport interface NavigateOptions {\n /** Replaces the current entry of the history instead of adding one. */\n replace?: boolean;\n /** Scrolls to the top of the new page, or to its hash. Defaults to true. False keeps the place. */\n scroll?: boolean;\n}\n\n/**\n * Loads a page as a link does: the layouts that stay keep their state. It\n * returns when the page shows. A URL of another origin, or a page without\n * the loader, loads in full.\n *\n * ```ts\n * await navigate(href('/issues/[id]', { id: issue.id }));\n * navigate(`?q=${query}`, { replace: true });\n * ```\n */\nexport function navigate(to: string, options: NavigateOptions = {}): Promise<void> {\n const url = new URL(to, location.href);\n // A `javascript:` URL would run its script, so only web pages load.\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n return Promise.reject(new TypeError(`navigate loads http and https URLs, not ${url.protocol}`));\n }\n if (url.origin !== location.origin) {\n location.assign(url.href);\n return new Promise(() => {});\n }\n return new Promise((resolve) => {\n const event = new CustomEvent('brumate:navigate', {\n cancelable: true,\n detail: {\n url: url.href,\n replace: options.replace === true,\n scroll: options.scroll !== false,\n done: resolve,\n },\n });\n // The loader answers the event. Without it, the page loads in full.\n if (document.dispatchEvent(event)) {\n location.assign(url.href);\n }\n });\n}\n"],"mappings":";;;;;;AA6BA,SAAgB,KAA0B,MAAS,GAAG,CAAC,SAAoC;CACzF,MAAM,SAAU,UAAU,CAAC;CAC3B,OAAO,KAAK,QAAQ,2BAA2B,GAAG,MAA0B,SAAiB;EAC3F,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAA,KAAa,UAAU,IACnC,MAAM,IAAI,MAAM,aAAa,KAAK,MAAM,KAAK,YAAY;EAE3D,IAAI,CAAC,MACH,OAAO,mBAAmB,OAAO,KAAK,CAAC;EAEzC,MAAM,QAAkB,CAAC;EACzB,KAAK,MAAM,QAAQ,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,GACxC,MAAM,KAAK,mBAAmB,IAAI,CAAC;EAErC,OAAO,MAAM,KAAK,GAAG;CACvB,CAAC;AACH;;;;;;;;;;;AAmBA,SAAgB,SAAS,IAAY,UAA2B,CAAC,GAAkB;CACjF,MAAM,MAAM,IAAI,IAAI,IAAI,SAAS,IAAI;CAErC,IAAI,IAAI,aAAa,WAAW,IAAI,aAAa,UAC/C,OAAO,QAAQ,uBAAO,IAAI,UAAU,2CAA2C,IAAI,UAAU,CAAC;CAEhG,IAAI,IAAI,WAAW,SAAS,QAAQ;EAClC,SAAS,OAAO,IAAI,IAAI;EACxB,OAAO,IAAI,cAAc,CAAC,CAAC;CAC7B;CACA,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,QAAQ,IAAI,YAAY,oBAAoB;GAChD,YAAY;GACZ,QAAQ;IACN,KAAK,IAAI;IACT,SAAS,QAAQ,YAAY;IAC7B,QAAQ,QAAQ,WAAW;IAC3B,MAAM;GACR;EACF,CAAC;EAED,IAAI,SAAS,cAAc,KAAK,GAC9B,SAAS,OAAO,IAAI,IAAI;CAE5B,CAAC;AACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as callPlugins, n as fromChunkStream, o as serialOptions } from "./stream-
|
|
2
|
-
import {
|
|
1
|
+
import { i as callPlugins, n as fromChunkStream, o as serialOptions } from "./stream-DRjx0keF.js";
|
|
2
|
+
import { ln as build, pn as skew } from "./client-eVI8Wc95.js";
|
|
3
3
|
import { toJSONAsync } from "seroval";
|
|
4
4
|
//#region src/runtime/rpc.ts
|
|
5
5
|
/**
|
|
@@ -146,4 +146,4 @@ function sendAction(form, submitter) {
|
|
|
146
146
|
//#endregion
|
|
147
147
|
export { call, sendAction };
|
|
148
148
|
|
|
149
|
-
//# sourceMappingURL=rpc-
|
|
149
|
+
//# sourceMappingURL=rpc-BgYnfg_a.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-CIVU4Ktx.js","names":[],"sources":["../src/runtime/rpc.ts"],"sourcesContent":["import { toJSONAsync } from 'seroval';\nimport { build, skew } from './client.ts';\nimport type { Scope } from './client.ts';\nimport { callPlugins, serialOptions } from './serial.ts';\nimport { fromChunkStream } from './stream.ts';\n\n/**\n * Calls a server function. It is a separate module, so pages that never call\n * one never load seroval's serializer.\n *\n * Files and blobs in the arguments, anywhere in them, go as parts of\n * multipart form data. `signal` aborts the call.\n */\nexport async function call(\n prefix: string,\n id: string,\n args: unknown[],\n signal?: AbortSignal,\n): Promise<unknown> {\n // The plugin of uploads takes each file and blob in the arguments, wherever it is.\n const files: Blob[] = [];\n const json = JSON.stringify(\n await toJSONAsync(args, { plugins: callPlugins(files), ...serialOptions() }),\n );\n let init: RequestInit;\n if (files.length > 0) {\n const form = new FormData();\n form.set('args', json);\n // A blob of another DOM is copied, because form data takes only its own.\n const copies: (Blob | Promise<Blob>)[] = [];\n for (const file of files) {\n // Typed as a Blob, so the check narrows a blob of another DOM to never.\n copies.push(\n file instanceof Blob\n ? file\n : (file as Blob)\n .arrayBuffer()\n .then((data) => new Blob([data], { type: (file as Blob).type })),\n );\n }\n const blobs = await Promise.all(copies);\n for (const [index, blob] of blobs.entries()) {\n form.set(`file${index}`, blob, (files[index] as Partial<File>).name ?? 'blob');\n }\n init = { headers: { 'x-brumate-args': 'form' }, body: form };\n } else {\n init = { headers: { 'content-type': 'application/json' }, body: json };\n }\n return post(prefix, id, { ...init, signal });\n}\n\n/**\n * Sends a form to a server function, and returns its result. The form data\n * goes as it is, files included, as when the browser posts the form.\n */\nexport async function submit(\n prefix: string,\n id: string,\n form: FormData,\n key?: string | null,\n): Promise<unknown> {\n return post(prefix, id, { headers: { 'x-brumate-result': '1' }, body: form }, key);\n}\n\n/** Posts to a server function, and reads its answer. */\nasync function post(\n prefix: string,\n id: string,\n init: RequestInit,\n key?: string | null,\n): Promise<unknown> {\n const headers = new Headers(init.headers);\n // The build of the page, so the server can tell a call from before a deploy.\n if (build !== undefined) {\n headers.set('x-brumate-build', build);\n }\n // The key of a form of a function that `idempotent` made.\n const query = key ? `?__key=${encodeURIComponent(key)}` : '';\n return answer(\n id,\n await fetch(`${prefix}/${encodeURIComponent(id)}${query}`, {\n ...init,\n headers,\n method: 'POST',\n }),\n );\n}\n\n/** Reads the answer of a server function: its result, a redirect or an error. */\nasync function answer(id: string, response: Response): Promise<unknown> {\n // The server functions whose memos load again, from `refresh` on the server.\n const refreshed = response.headers.get('x-brumate-refresh');\n if (refreshed) {\n const ids = refreshed.split(',');\n void refreshMemos(ids);\n document.dispatchEvent(new CustomEvent('brumate:refresh', { detail: ids }));\n }\n const location = response.headers.get('x-brumate-redirect');\n if (location !== null) {\n // The loader navigates on the client when it can. Without client navigation, the page loads in full.\n const redirect = new CustomEvent('brumate:redirect', { detail: location, cancelable: true });\n if (document.dispatchEvent(redirect)) {\n window.location.assign(location);\n }\n // The page is leaving, so the call never settles.\n return new Promise(() => {});\n }\n if (!response.ok) {\n // The site changed, and this page is from before. The next page loads in full.\n if (response.status === 409 && response.headers.get('x-brumate-build')) {\n skew('call');\n }\n let message = `Server function \"${id}\" failed with status ${response.status}`;\n try {\n message = ((await response.json()) as { error: string }).error;\n } catch {\n // The body is not the error of a server function.\n }\n const retryAfter = Number(response.headers.get('retry-after'));\n throw Object.assign(new Error(message), {\n name: 'ServerError',\n status: response.status,\n // The seconds to wait, for a call that a rate limit refused.\n ...(retryAfter > 0 ? { retryAfter } : {}),\n });\n }\n // Promises and async iterables in the result settle as the rest of the answer arrives.\n return fromChunkStream(response.body!);\n}\n\n// The code below reads the core with `import()`, not a static import: a module that imports\n// the core statically would make the package build move the core into a chunk of its own, behind\n// a module that only re-exports it, which a page loads one after the other. The core is loaded\n// already when it runs, so the import costs no request. It names the exports it uses, so a build\n// keeps only them.\n\n/**\n * Loads again the memos that call these server functions, after a server\n * function named them with `refresh`. Each component on the page knows its\n * own memos, from its client module. It is here, and not in the core, because\n * only the answer of a server call starts it.\n */\nexport function refreshMemos(ids: string[]): Promise<void> {\n return import('./client.ts').then(({ descendants, loadModule, scopes }) => {\n for (const root of scopes.values()) {\n if (!root.m) {\n continue;\n }\n void loadModule(root.m).then(async (module) => {\n const entries: NonNullable<typeof module.refresh>[string] = [];\n for (const id of ids) {\n entries.push(...(module.refresh?.[id] ?? []));\n }\n if (entries.length === 0) {\n return;\n }\n const updates = module as unknown as Record<string, unknown>;\n for (const [kind, name] of entries) {\n for (const target of kind === root.k ? [root] : descendants(root, kind)) {\n if (scopes.has(target.id)) {\n (updates[name] as (scope: Scope) => void)(target);\n }\n }\n }\n });\n }\n });\n}\n\n/** Gives a form a new key in its URL, for its next post. */\nfunction renewKey(form: HTMLFormElement, url: URL): void {\n url.searchParams.set('__key', crypto.randomUUID());\n form.setAttribute('action', `${url.pathname}${url.search}`);\n}\n\n/**\n * Sends a form to the server function of its `$action`, and writes the\n * result into the `$action` when it arrives. It is pending until then. See\n * `submitAction` in the core.\n */\nexport function sendAction(form: HTMLFormElement, submitter: HTMLElement | null): Promise<void> {\n const [scopeText, slotText] = form.getAttribute('b-result')!.split(':') as [string, string];\n const scopeId = Number(scopeText);\n const slot = Number(slotText);\n const data = new FormData(form, submitter);\n const action = form.getAttribute('b-action')!;\n return import('./client.ts').then(({ asyncMemo, rpcPrefix, scopes, track }) => {\n const scope = scopes.get(scopeId);\n if (scope) {\n // A form of a function that `idempotent` made sends its key, and gets a new one once the\n // server answered, so a post that the user means again runs again.\n const url = new URL(form.getAttribute('action') ?? '', location.href);\n const key = url.searchParams.get('__key');\n const result = submit(rpcPrefix, action, data, key);\n if (key) {\n void result.then(\n () => renewKey(form, url),\n () => {},\n );\n }\n const answered = result.catch((error: unknown) => {\n // The site changed since the page loaded. The form posts again without scripts, and the\n // page that answers is of the new build.\n if ((error as { status?: number }).status === 409 && build !== undefined) {\n form.submit();\n return new Promise(() => {});\n }\n throw error;\n });\n asyncMemo(scope, slot, track(answered));\n }\n });\n}\n"],"mappings":";;;;;;;;;;;AAaA,eAAsB,KACpB,QACA,IACA,MACA,QACkB;CAElB,MAAM,QAAgB,CAAC;CACvB,MAAM,OAAO,KAAK,UAChB,MAAM,YAAY,MAAM;EAAE,SAAS,YAAY,KAAK;EAAG,GAAG,cAAc;CAAE,CAAC,CAC7E;CACA,IAAI;CACJ,IAAI,MAAM,SAAS,GAAG;EACpB,MAAM,OAAO,IAAI,SAAS;EAC1B,KAAK,IAAI,QAAQ,IAAI;EAErB,MAAM,SAAmC,CAAC;EAC1C,KAAK,MAAM,QAAQ,OAEjB,OAAO,KACL,gBAAgB,OACZ,OACC,KACE,YAAY,CAAC,CACb,MAAM,SAAS,IAAI,KAAK,CAAC,IAAI,GAAG,EAAE,MAAO,KAAc,KAAK,CAAC,CAAC,CACvE;EAEF,MAAM,QAAQ,MAAM,QAAQ,IAAI,MAAM;EACtC,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GACxC,KAAK,IAAI,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AC,WAAW,YAAY,KAAK,aAAa,UAAU,CAAC,CAAE,MAAM,GAAG;CACtE,MAAM,UAAU,OAAO,SAAS;CAChC,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,OAAO,IAAI,SAAS,MAAM,SAAS;CACzC,MAAM,SAAS,KAAK,aAAa,UAAU;CAC3C,OAAO,OAAO,sBAAc,CAAC,MAAM,EAAE,WAAW,WAAW,QAAQ,YAAY;EAC7E,MAAM,QAAQ,OAAO,IAAI,OAAO;EAChC,IAAI,OAAO;GAGT,MAAM,MAAM,IAAI,IAAI,KAAK,aAAa,QAAQ,KAAK,IAAI,SAAS,IAAI;GACpE,MAAM,MAAM,IAAI,aAAa,IAAI,OAAO;GACxC,MAAM,SAAS,OAAO,WAAW,QAAQ,MAAM,GAAG;GAClD,IAAI,KACF,OAAY,WACJ,SAAS,MAAM,GAAG,SAClB,CAAC,CACT;GAEF,MAAM,WAAW,OAAO,OAAO,UAAmB;IAGhD,IAAK,MAA8B,WAAW,OAAO,UAAU,KAAA,GAAW;KACxE,KAAK,OAAO;KACZ,OAAO,IAAI,cAAc,CAAC,CAAC;IAC7B;IACA,MAAM;GACR,CAAC;GACD,UAAU,OAAO,MAAM,MAAM,QAAQ,CAAC;EACxC;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"rpc-BgYnfg_a.js","names":[],"sources":["../src/runtime/rpc.ts"],"sourcesContent":["import { toJSONAsync } from 'seroval';\nimport { build, skew } from './client.ts';\nimport type { Scope } from './client.ts';\nimport { callPlugins, serialOptions } from './serial.ts';\nimport { fromChunkStream } from './stream.ts';\n\n/**\n * Calls a server function. It is a separate module, so pages that never call\n * one never load seroval's serializer.\n *\n * Files and blobs in the arguments, anywhere in them, go as parts of\n * multipart form data. `signal` aborts the call.\n */\nexport async function call(\n prefix: string,\n id: string,\n args: unknown[],\n signal?: AbortSignal,\n): Promise<unknown> {\n // The plugin of uploads takes each file and blob in the arguments, wherever it is.\n const files: Blob[] = [];\n const json = JSON.stringify(\n await toJSONAsync(args, { plugins: callPlugins(files), ...serialOptions() }),\n );\n let init: RequestInit;\n if (files.length > 0) {\n const form = new FormData();\n form.set('args', json);\n // A blob of another DOM is copied, because form data takes only its own.\n const copies: (Blob | Promise<Blob>)[] = [];\n for (const file of files) {\n // Typed as a Blob, so the check narrows a blob of another DOM to never.\n copies.push(\n file instanceof Blob\n ? file\n : (file as Blob)\n .arrayBuffer()\n .then((data) => new Blob([data], { type: (file as Blob).type })),\n );\n }\n const blobs = await Promise.all(copies);\n for (const [index, blob] of blobs.entries()) {\n form.set(`file${index}`, blob, (files[index] as Partial<File>).name ?? 'blob');\n }\n init = { headers: { 'x-brumate-args': 'form' }, body: form };\n } else {\n init = { headers: { 'content-type': 'application/json' }, body: json };\n }\n return post(prefix, id, { ...init, signal });\n}\n\n/**\n * Sends a form to a server function, and returns its result. The form data\n * goes as it is, files included, as when the browser posts the form.\n */\nexport async function submit(\n prefix: string,\n id: string,\n form: FormData,\n key?: string | null,\n): Promise<unknown> {\n return post(prefix, id, { headers: { 'x-brumate-result': '1' }, body: form }, key);\n}\n\n/** Posts to a server function, and reads its answer. */\nasync function post(\n prefix: string,\n id: string,\n init: RequestInit,\n key?: string | null,\n): Promise<unknown> {\n const headers = new Headers(init.headers);\n // The build of the page, so the server can tell a call from before a deploy.\n if (build !== undefined) {\n headers.set('x-brumate-build', build);\n }\n // The key of a form of a function that `idempotent` made.\n const query = key ? `?__key=${encodeURIComponent(key)}` : '';\n return answer(\n id,\n await fetch(`${prefix}/${encodeURIComponent(id)}${query}`, {\n ...init,\n headers,\n method: 'POST',\n }),\n );\n}\n\n/** Reads the answer of a server function: its result, a redirect or an error. */\nasync function answer(id: string, response: Response): Promise<unknown> {\n // The server functions whose memos load again, from `refresh` on the server.\n const refreshed = response.headers.get('x-brumate-refresh');\n if (refreshed) {\n const ids = refreshed.split(',');\n void refreshMemos(ids);\n document.dispatchEvent(new CustomEvent('brumate:refresh', { detail: ids }));\n }\n const location = response.headers.get('x-brumate-redirect');\n if (location !== null) {\n // The loader navigates on the client when it can. Without client navigation, the page loads in full.\n const redirect = new CustomEvent('brumate:redirect', { detail: location, cancelable: true });\n if (document.dispatchEvent(redirect)) {\n window.location.assign(location);\n }\n // The page is leaving, so the call never settles.\n return new Promise(() => {});\n }\n if (!response.ok) {\n // The site changed, and this page is from before. The next page loads in full.\n if (response.status === 409 && response.headers.get('x-brumate-build')) {\n skew('call');\n }\n let message = `Server function \"${id}\" failed with status ${response.status}`;\n try {\n message = ((await response.json()) as { error: string }).error;\n } catch {\n // The body is not the error of a server function.\n }\n const retryAfter = Number(response.headers.get('retry-after'));\n throw Object.assign(new Error(message), {\n name: 'ServerError',\n status: response.status,\n // The seconds to wait, for a call that a rate limit refused.\n ...(retryAfter > 0 ? { retryAfter } : {}),\n });\n }\n // Promises and async iterables in the result settle as the rest of the answer arrives.\n return fromChunkStream(response.body!);\n}\n\n// The code below reads the core with `import()`, not a static import: a module that imports\n// the core statically would make the package build move the core into a chunk of its own, behind\n// a module that only re-exports it, which a page loads one after the other. The core is loaded\n// already when it runs, so the import costs no request. It names the exports it uses, so a build\n// keeps only them.\n\n/**\n * Loads again the memos that call these server functions, after a server\n * function named them with `refresh`. Each component on the page knows its\n * own memos, from its client module. It is here, and not in the core, because\n * only the answer of a server call starts it.\n */\nexport function refreshMemos(ids: string[]): Promise<void> {\n return import('./client.ts').then(({ descendants, loadModule, scopes }) => {\n for (const root of scopes.values()) {\n if (!root.m) {\n continue;\n }\n void loadModule(root.m).then(async (module) => {\n const entries: NonNullable<typeof module.refresh>[string] = [];\n for (const id of ids) {\n entries.push(...(module.refresh?.[id] ?? []));\n }\n if (entries.length === 0) {\n return;\n }\n const updates = module as unknown as Record<string, unknown>;\n for (const [kind, name] of entries) {\n for (const target of kind === root.k ? [root] : descendants(root, kind)) {\n if (scopes.has(target.id)) {\n (updates[name] as (scope: Scope) => void)(target);\n }\n }\n }\n });\n }\n });\n}\n\n/** Gives a form a new key in its URL, for its next post. */\nfunction renewKey(form: HTMLFormElement, url: URL): void {\n url.searchParams.set('__key', crypto.randomUUID());\n form.setAttribute('action', `${url.pathname}${url.search}`);\n}\n\n/**\n * Sends a form to the server function of its `$action`, and writes the\n * result into the `$action` when it arrives. It is pending until then. See\n * `submitAction` in the core.\n */\nexport function sendAction(form: HTMLFormElement, submitter: HTMLElement | null): Promise<void> {\n const [scopeText, slotText] = form.getAttribute('b-result')!.split(':') as [string, string];\n const scopeId = Number(scopeText);\n const slot = Number(slotText);\n const data = new FormData(form, submitter);\n const action = form.getAttribute('b-action')!;\n return import('./client.ts').then(({ asyncMemo, rpcPrefix, scopes, track }) => {\n const scope = scopes.get(scopeId);\n if (scope) {\n // A form of a function that `idempotent` made sends its key, and gets a new one once the\n // server answered, so a post that the user means again runs again.\n const url = new URL(form.getAttribute('action') ?? '', location.href);\n const key = url.searchParams.get('__key');\n const result = submit(rpcPrefix, action, data, key);\n if (key) {\n void result.then(\n () => renewKey(form, url),\n () => {},\n );\n }\n const answered = result.catch((error: unknown) => {\n // The site changed since the page loaded. The form posts again without scripts, and the\n // page that answers is of the new build.\n if ((error as { status?: number }).status === 409 && build !== undefined) {\n form.submit();\n return new Promise(() => {});\n }\n throw error;\n });\n asyncMemo(scope, slot, track(answered));\n }\n });\n}\n"],"mappings":";;;;;;;;;;;AAaA,eAAsB,KACpB,QACA,IACA,MACA,QACkB;CAElB,MAAM,QAAgB,CAAC;CACvB,MAAM,OAAO,KAAK,UAChB,MAAM,YAAY,MAAM;EAAE,SAAS,YAAY,KAAK;EAAG,GAAG,cAAc;CAAE,CAAC,CAC7E;CACA,IAAI;CACJ,IAAI,MAAM,SAAS,GAAG;EACpB,MAAM,OAAO,IAAI,SAAS;EAC1B,KAAK,IAAI,QAAQ,IAAI;EAErB,MAAM,SAAmC,CAAC;EAC1C,KAAK,MAAM,QAAQ,OAEjB,OAAO,KACL,gBAAgB,OACZ,OACC,KACE,YAAY,CAAC,CACb,MAAM,SAAS,IAAI,KAAK,CAA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B;CACvD,IAAI,aAAa,IAAI,SAAS,OAAO,WAAW,CAAC;CACjD,KAAK,aAAa,UAAU,GAAG,IAAI,WAAW,IAAI,QAAQ;AAC5D;;;;;;AAOA,SAAgB,WAAW,MAAuB,WAA8C;CAC9F,MAAM,CAAC,WAAW,YAAY,KAAK,aAAa,UAAU,CAAC,CAAE,MAAM,GAAG;CACtE,MAAM,UAAU,OAAO,SAAS;CAChC,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,OAAO,IAAI,SAAS,MAAM,SAAS;CACzC,MAAM,SAAS,KAAK,aAAa,UAAU;CAC3C,OAAO,OAAO,sBAAc,CAAC,MAAM,EAAE,WAAW,WAAW,QAAQ,YAAY;EAC7E,MAAM,QAAQ,OAAO,IAAI,OAAO;EAChC,IAAI,OAAO;GAGT,MAAM,MAAM,IAAI,IAAI,KAAK,aAAa,QAAQ,KAAK,IAAI,SAAS,IAAI;GACpE,MAAM,MAAM,IAAI,aAAa,IAAI,OAAO;GACxC,MAAM,SAAS,OAAO,WAAW,QAAQ,MAAM,GAAG;GAClD,IAAI,KACF,OAAY,WACJ,SAAS,MAAM,GAAG,SAClB,CAAC,CACT;GAEF,MAAM,WAAW,OAAO,OAAO,UAAmB;IAGhD,IAAK,MAA8B,WAAW,OAAO,UAAU,KAAA,GAAW;KACxE,KAAK,OAAO;KACZ,OAAO,IAAI,cAAc,CAAC,CAAC;IAC7B;IACA,MAAM;GACR,CAAC;GACD,UAAU,OAAO,MAAM,MAAM,QAAQ,CAAC;EACxC;CACF,CAAC;AACH"}
|
package/dist/runtime/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as routeContext, o as createContext, s as navigationContext } from "../context-btHuB01Z.js";
|
|
2
2
|
import { A as onAttribute, E as internal, N as raw, R as vars, S as escape, _ as attribute, b as classAttribute, g as affix, k as mergeAttributes, p as Raw, s as SCOPE_IDS, u as unbind } from "../shared-CzbnWkVA.js";
|
|
3
|
-
import { $ as
|
|
3
|
+
import { $ as toList, $t as skew, A as putText, At as leaveRoutes, B as getScope, Bt as provideValue, C as fillBranch, Ct as fail, D as listNodes, Dt as forget, E as keepText, Et as dispose, F as setSpread, Ft as handlerProp, G as prop, Gt as CoreOptions, H as removeScope, Ht as updateContext, I as template, It as rpc, J as addPortal, Jt as Scope, K as spreadProps, Kt as DEVTOOLS, L as afterInsert, Lt as spread, M as setAttrText, Mt as removeRoot, N as setContent, Nt as action, O as markBlock, Ot as init, P as setOn, Pt as handle, Q as list, Qt as scopes, R as createScope, Rt as submitAction, S as clone, St as wait, T as keep, Tt as nameComment, U as setOwner, Ut as updateRoute, V as makeId, Vt as setGlobal, W as sink, Wt as ClientModule, X as deferInBrowser, Xt as hooks, Y as addStyle, Yt as build, Z as setVar, Zt as rpcPrefix, _ as title, _n as rekey, _t as fillValue, a as cells, an as elementAt, at as portalTo, b as appendText, bt as reveal, c as isBound, cn as setItem, ct as writeText, d as resolve, dn as insert, dt as after, en as Component, et as windowList, f as set, fn as HiddenBody, ft as attempt, g as updated, gn as offscreen, gt as fillSpread, h as update, hn as held, ht as fillSettled, i as bindings, in as dynamicNodes, it as content, j as setAttr, jt as remount, k as nodes, kt as leavePage, l as memo, ln as setSlots, lt as guess, m as unreadMemo, mn as fill, mt as fillAttrs, n as asyncMemo, nn as componentNodes, nt as attr, o as effect, on as foreignNodes, ot as restRef, p as timed, pn as branch, pt as countLoads, q as addHead, qt as DevtoolsHooks, r as binding, rn as dynamic, rt as attrs, s as get, sn as place, st as text, t as loader, tn as component, tt as windowStart, u as pending, un as children, ut as track, v as paramEffect, vn as reset, vt as keepValue, w as fillList, wt as loadModule, x as branchNodes, xt as started, y as searchParam, yn as retag, yt as loading, z as descendants, zt as consumeContext } from "../client-C4kNKGwH.js";
|
|
4
4
|
import { t as produce } from "../produce-CLABZ8k2.js";
|
|
5
|
-
export { type ClientModule, type Component, type CoreOptions, DEVTOOLS, type DevtoolsHooks, type HiddenBody, type Raw, type Scope, action, addHead, addPortal, addStyle, affix, after, afterInsert, appendText, asyncMemo, attempt, attr, attribute, attrs, binding, bindings, branch, branchNodes, build, cells, children, classAttribute, clone, component, componentNodes, consumeContext, content, countLoads, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, dynamicNodes, effect, elementAt, escape, fail, fill, fillAttrs, fillBranch, fillList, fillSettled, fillSpread, fillValue, foreignNodes, forget, get, getScope, guess, handle, handlerProp, held, hooks, init, insert, internal, isBound, keep, keepText, keepValue, leavePage, leaveRoutes, list, listNodes, loadModule, loader, loading, makeId, markBlock, memo, mergeAttributes, nameComment, navigationContext, nodes, offscreen, onAttribute, pending, place, portalTo, produce, prop, provideValue, putText, raw, rekey, remount, removeRoot, removeScope, reset, resolve, restRef, retag, reveal, routeContext, rpc, rpcPrefix, SCOPE_IDS as scopeIds, scopes, set, setAttr, setAttrText, setContent, setGlobal, setItem, setOn, setOwner, setSlots, setSpread, setVar, sink, skew, spread, spreadProps, started, submitAction, template, text, timed, title, toList, track, unbind, unreadMemo, update, updateContext, updateRoute, updated, vars, wait, windowList, windowStart, writeText };
|
|
5
|
+
export { type ClientModule, type Component, type CoreOptions, DEVTOOLS, type DevtoolsHooks, type HiddenBody, type Raw, type Scope, action, addHead, addPortal, addStyle, affix, after, afterInsert, appendText, asyncMemo, attempt, attr, attribute, attrs, binding, bindings, branch, branchNodes, build, cells, children, classAttribute, clone, component, componentNodes, consumeContext, content, countLoads, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, dynamicNodes, effect, elementAt, escape, fail, fill, fillAttrs, fillBranch, fillList, fillSettled, fillSpread, fillValue, foreignNodes, forget, get, getScope, guess, handle, handlerProp, held, hooks, init, insert, internal, isBound, keep, keepText, keepValue, leavePage, leaveRoutes, list, listNodes, loadModule, loader, loading, makeId, markBlock, memo, mergeAttributes, nameComment, navigationContext, nodes, offscreen, onAttribute, paramEffect, pending, place, portalTo, produce, prop, provideValue, putText, raw, rekey, remount, removeRoot, removeScope, reset, resolve, restRef, retag, reveal, routeContext, rpc, rpcPrefix, SCOPE_IDS as scopeIds, scopes, searchParam, set, setAttr, setAttrText, setContent, setGlobal, setItem, setOn, setOwner, setSlots, setSpread, setVar, sink, skew, spread, spreadProps, started, submitAction, template, text, timed, title, toList, track, unbind, unreadMemo, update, updateContext, updateRoute, updated, vars, wait, windowList, windowStart, writeText };
|
package/dist/runtime/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { E as vars, _ as mergeAttributes, a as attribute, c as classAttribute, i as affix, m as internal, u as escape, v as onAttribute, x as raw } from "../html-t1JpkODI.js";
|
|
2
|
-
import {
|
|
2
|
+
import { T as unbind, i as produce, p as SCOPE_IDS } from "../search-params-CM1RWR2P.js";
|
|
3
3
|
import { a as routeContext, i as navigationContext, r as createContext } from "../context-CTiSzQRc.js";
|
|
4
|
-
import { $ as
|
|
5
|
-
export { DEVTOOLS, action, addHead, addPortal, addStyle, affix, after, afterInsert, appendText, asyncMemo, attempt, attr, attribute, attrs, binding, bindings, branch, branchNodes, build, cells, children, classAttribute, clone, component, componentNodes, consumeContext, content, countLoads, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, dynamicNodes, effect, elementAt, escape, fail, fill, fillAttrs, fillBranch, fillList, fillSettled, fillSpread, fillValue, foreignNodes, forget, get, getScope, guess, handle, handlerProp, held, hooks, init, insert, internal, isBound, keep, keepText, keepValue, leavePage, leaveRoutes, list, listNodes, loadModule, loader, loading, makeId, markBlock, memo, mergeAttributes, nameComment, navigationContext, nodes, offscreen, onAttribute, pending, place, portalTo, produce, prop, provideValue, putText, raw, rekey, remount, removeRoot, removeScope, reset, resolve, restRef, retag, reveal, routeContext, rpc, rpcPrefix, SCOPE_IDS as scopeIds, scopes, set, setAttr, setAttrText, setContent, setGlobal, setItem, setOn, setOwner, setSlots, setSpread, setVar, sink, skew, spread, spreadProps, started, submitAction, template, text, timed, title, toList, track, unbind, unreadMemo, update, updateContext, updateRoute, updated, vars, wait, windowList, windowStart, writeText };
|
|
4
|
+
import { $ as fillBranch, $t as createScope, A as started, At as setGlobal, B as spreadProps, Bt as memo, C as fillAttrs, Ct as rpc, D as keepValue, Dt as track, E as fillValue, Et as guess, F as portalTo, Ft as bindings, G as elementAt, Gt as unreadMemo, H as componentNodes, Ht as resolve, I as restRef, It as cells, J as setItem, Jt as fail, K as foreignNodes, Kt as update, L as text, Lt as effect, M as attr, Mt as updateRoute, N as attrs, Nt as asyncMemo, O as loading, Ot as consumeContext, P as content, Pt as binding, Q as clone, Qt as afterInsert, R as writeText, Rt as get, S as countLoads, St as handlerProp, T as fillSpread, Tt as submitAction, U as dynamic, Ut as set, V as component, Vt as pending, W as dynamicNodes, Wt as timed, X as appendText, Xt as insert, Y as setSlots, Yt as children, Z as branchNodes, Zt as title, _ as rekey, _t as leaveRoutes, a as addPortal, an as sink, at as nodes, b as after, bt as action, c as setVar, cn as DEVTOOLS, ct as setAttrText, d as windowList, dn as rpcPrefix, dt as setSpread, en as descendants, et as fillList, f as windowStart, fn as scopes, ft as template, g as offscreen, gt as leavePage, h as held, ht as init, i as addHead, in as setOwner, it as markBlock, j as wait, jt as updateContext, k as reveal, kt as provideValue, l as list, ln as build, lt as setContent, m as fill, mt as forget, n as paramEffect, nn as makeId, nt as keepText, o as addStyle, on as loadModule, ot as putText, p as branch, pn as skew, pt as dispose, q as place, qt as updated, r as searchParam, rn as removeScope, rt as listNodes, s as deferInBrowser, sn as nameComment, st as setAttr, t as loader, tn as getScope, tt as keep, u as toList, un as hooks, ut as setOn, v as reset, vt as remount, w as fillSettled, wt as spread, x as attempt, xt as handle, y as retag, yt as removeRoot, z as prop, zt as isBound } from "../client-eVI8Wc95.js";
|
|
5
|
+
export { DEVTOOLS, action, addHead, addPortal, addStyle, affix, after, afterInsert, appendText, asyncMemo, attempt, attr, attribute, attrs, binding, bindings, branch, branchNodes, build, cells, children, classAttribute, clone, component, componentNodes, consumeContext, content, countLoads, createContext, createScope, deferInBrowser, descendants, dispose, dynamic, dynamicNodes, effect, elementAt, escape, fail, fill, fillAttrs, fillBranch, fillList, fillSettled, fillSpread, fillValue, foreignNodes, forget, get, getScope, guess, handle, handlerProp, held, hooks, init, insert, internal, isBound, keep, keepText, keepValue, leavePage, leaveRoutes, list, listNodes, loadModule, loader, loading, makeId, markBlock, memo, mergeAttributes, nameComment, navigationContext, nodes, offscreen, onAttribute, paramEffect, pending, place, portalTo, produce, prop, provideValue, putText, raw, rekey, remount, removeRoot, removeScope, reset, resolve, restRef, retag, reveal, routeContext, rpc, rpcPrefix, SCOPE_IDS as scopeIds, scopes, searchParam, set, setAttr, setAttrText, setContent, setGlobal, setItem, setOn, setOwner, setSlots, setSpread, setVar, sink, skew, spread, spreadProps, started, submitAction, template, text, timed, title, toList, track, unbind, unreadMemo, update, updateContext, updateRoute, updated, vars, wait, windowList, windowStart, writeText };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as ScopeId } from "../shared-CzbnWkVA.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Jt as Scope, bn as NavigationReport } from "../client-C4kNKGwH.js";
|
|
3
3
|
//#region src/runtime/logo.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The logo of brumate: the pole and the bowl of a b, in outline, where the
|
package/dist/runtime/devtools.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as LOGO } from "../logo-DQ_OYhBi.js";
|
|
2
|
-
import { a as scanBlocks, i as reportError, n as installDevtools, r as preview, t as findRootScope } from "../devtools-
|
|
2
|
+
import { a as scanBlocks, i as reportError, n as installDevtools, r as preview, t as findRootScope } from "../devtools-DqqqdI4b.js";
|
|
3
3
|
export { LOGO, findRootScope, installDevtools, preview, reportError, scanBlocks };
|
package/dist/runtime/hot.d.ts
CHANGED
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-CMvhoWRu.js";
|
|
2
|
+
import { t as startWithoutNavigation } from "../static-loader-CGthkX0s.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-DCxASuzA.js";
|
|
2
|
+
import { t as start } from "../loader-CQkAXO0g.js";
|
|
3
3
|
export { start, startWithoutNavigation };
|
package/dist/runtime/routes.js
CHANGED
|
@@ -1,51 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* The URL of a route, with its params in place:
|
|
4
|
-
* `href('/todos/[id]', { id: '3' })` is `/todos/3`. A rest param, such as
|
|
5
|
-
* `[...path]`, keeps its slashes.
|
|
6
|
-
*/
|
|
7
|
-
function href(path, ...[params]) {
|
|
8
|
-
const values = params ?? {};
|
|
9
|
-
return path.replace(/\[(\.\.\.)?([^\]]+)\]/g, (_, rest, name) => {
|
|
10
|
-
const value = values[name];
|
|
11
|
-
if (value === void 0 || value === "") throw new Error(`The param ${name} of ${path} is missing`);
|
|
12
|
-
if (!rest) return encodeURIComponent(String(value));
|
|
13
|
-
const parts = [];
|
|
14
|
-
for (const part of String(value).split("/")) parts.push(encodeURIComponent(part));
|
|
15
|
-
return parts.join("/");
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Loads a page as a link does: the layouts that stay keep their state. It
|
|
20
|
-
* returns when the page shows. A URL of another origin, or a page without
|
|
21
|
-
* the loader, loads in full.
|
|
22
|
-
*
|
|
23
|
-
* ```ts
|
|
24
|
-
* await navigate(href('/issues/[id]', { id: issue.id }));
|
|
25
|
-
* navigate(`?q=${query}`, { replace: true });
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
function navigate(to, options = {}) {
|
|
29
|
-
const url = new URL(to, location.href);
|
|
30
|
-
if (url.protocol !== "http:" && url.protocol !== "https:") return Promise.reject(/* @__PURE__ */ new TypeError(`navigate loads http and https URLs, not ${url.protocol}`));
|
|
31
|
-
if (url.origin !== location.origin) {
|
|
32
|
-
location.assign(url.href);
|
|
33
|
-
return new Promise(() => {});
|
|
34
|
-
}
|
|
35
|
-
return new Promise((resolve) => {
|
|
36
|
-
const event = new CustomEvent("brumate:navigate", {
|
|
37
|
-
cancelable: true,
|
|
38
|
-
detail: {
|
|
39
|
-
url: url.href,
|
|
40
|
-
replace: options.replace === true,
|
|
41
|
-
scroll: options.scroll !== false,
|
|
42
|
-
done: resolve
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
if (document.dispatchEvent(event)) location.assign(url.href);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
export { href, navigate };
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=routes.js.map
|
|
1
|
+
export { t as href, n as navigate } from "../routes-D21FQyGF.js";
|
package/dist/runtime/server.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { A as onAttribute, C as escapeAttribute, E as internal, N as raw, R as v
|
|
|
3
3
|
import { t as produce } from "../produce-CLABZ8k2.js";
|
|
4
4
|
import { t as StandardSchemaV1 } from "../standard-schema-BNY82yX3.js";
|
|
5
5
|
import { f as Intent, v as SubmissionResult } from "../forms-j1xPAR14.js";
|
|
6
|
-
import { $ as idempotent, $t as
|
|
7
|
-
export { type CacheStore, type CachedOptions, ClientBundles, Component, Context, type CookieOptions, DeferTarget, DocumentOptions, ElementReference, type EndpointLoader, type EntryMiddleware, type FailedSubmission, FunctionReference, type Handler, type IdempotentOptions, type Intent, type IntentSubmission, ItemSource, Lazy, type Loader, type Locals, Mark, Memo, type Middleware, type MiddlewareLoader, type NavigationState, NotReady, PageCache, type PageState, type ParseResult, type RateLimit, type RateLimitConfig, RateLimitError, type RateLimitMiddleware, type RateLimitOptions, type RateLimitStore, type Raw, type Redirect, RenderOptions, RenderResult, type ReplyOptions, type RequestCall, RequestEvent, type RequestEventOptions, type RequestKind, RequestOptions, RevealOrder, type Route, type RouteMatch, type RouteNode, RouteOptions, type RouteView, ScopeEntry, type ScopeId, type ScopeState, ServerError, type Session, type SessionOptions, type StandardSchemaV1, StateAttributes, StateMap, StreamOptions, type Submission, type SubmissionOptions, type SubmissionResult, type SuccessfulSubmission, ValidationError, type ValidationIssue, type Window, action, actionResult, affix, attribute, binding, cached, caught, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, getEvent, handleRequest, handleRoute, idempotent, inlineBodies, insert, internal, isCrossSite, isRedirect, lazy, matchRoute, memo, memoryStore, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, parseSubmission, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, revalidate, routeContext, safeParse, serializeCookie, setCacheStore, setClientBundles, settled, spacerTag, spread, start, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };
|
|
6
|
+
import { $ as idempotent, $t as defineMiddleware, A as handleRoute, At as safeParse, B as renderToStream, Bt as searchParam, C as attribute, Ct as parseSubmission, D as component, Dt as fieldErrors, E as children, Et as ValidationIssue, F as memo, Ft as MiddlewareLoader, G as start, Gt as RequestEvent, H as settled, Ht as Locals, I as packState, It as RouteMatch, J as streamParts, Jt as ServerError, K as stateScript, Kt as RequestEventOptions, L as read, Lt as RouteNode, M as insert, Mt as Handler, N as isCrossSite, Nt as Loader, O as dynamic, Ot as parse, P as lazy, Pt as Middleware, Q as IdempotentOptions, Qt as dedupe, R as ready, Rt as RouteView, S as actionResult, St as SuccessfulSubmission, T as caught, Tt as ValidationError, U as spacerTag, Ut as Redirect, V as setClientBundles, Vt as EntryMiddleware, W as spread, Wt as RequestCall, X as wait, Xt as ServerErrorInfo, Y as streamState, Yt as ServerErrorHandler, Z as waitAll, Zt as ServerErrorKind, _ as ScopeEntry, _t as FailedSubmission, a as DocumentOptions, an as Session, at as setCacheStore, b as StreamOptions, bt as Submission, c as Mark, cn as parseCookies, ct as RateLimitConfig, d as PageCache, dt as RateLimitOptions, en as getEvent, et as CacheStore, f as RenderOptions, ft as RateLimitStore, g as RouteOptions, gt as rateLimit, h as RevealOrder, ht as configureRateLimit, i as DeferTarget, in as CookieOptions, it as revalidate, j as inlineBodies, jt as EndpointLoader, k as handleRequest, kt as parseForm, l as Memo, ln as serializeCookie, lt as RateLimitError, m as RequestOptions, mt as clientAddress, n as Component, nn as redirect, nt as cached, o as ItemSource, on as SessionOptions, ot as storageStore, p as RenderResult, pt as Window, q as stateValue, qt as RequestKind, r as Context, rn as withEvent, rt as memoryStore, s as Lazy, sn as createSession, st as RateLimit, t as ClientBundles, tn as isRedirect, tt as CachedOptions, u as NotReady, un as toNodeHeaders, ut as RateLimitMiddleware, v as StateAttributes, vt as IntentSubmission, w as binding, wt as ParseResult, x as action, xt as SubmissionOptions, y as StateMap, yt as ReplyOptions, z as render, zt as matchRoute } from "../server-dP_ucRiJ.js";
|
|
7
|
+
export { type CacheStore, type CachedOptions, ClientBundles, Component, Context, type CookieOptions, DeferTarget, DocumentOptions, ElementReference, type EndpointLoader, type EntryMiddleware, type FailedSubmission, FunctionReference, type Handler, type IdempotentOptions, type Intent, type IntentSubmission, ItemSource, Lazy, type Loader, type Locals, Mark, Memo, type Middleware, type MiddlewareLoader, type NavigationState, NotReady, PageCache, type PageState, type ParseResult, type RateLimit, type RateLimitConfig, RateLimitError, type RateLimitMiddleware, type RateLimitOptions, type RateLimitStore, type Raw, type Redirect, RenderOptions, RenderResult, type ReplyOptions, type RequestCall, RequestEvent, type RequestEventOptions, type RequestKind, RequestOptions, RevealOrder, type Route, type RouteMatch, type RouteNode, RouteOptions, type RouteView, ScopeEntry, type ScopeId, type ScopeState, ServerError, type ServerErrorHandler, type ServerErrorInfo, type ServerErrorKind, type Session, type SessionOptions, type StandardSchemaV1, StateAttributes, StateMap, StreamOptions, type Submission, type SubmissionOptions, type SubmissionResult, type SuccessfulSubmission, ValidationError, type ValidationIssue, type Window, action, actionResult, affix, attribute, binding, cached, caught, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, getEvent, handleRequest, handleRoute, idempotent, inlineBodies, insert, internal, isCrossSite, isRedirect, lazy, matchRoute, memo, memoryStore, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, parseSubmission, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, revalidate, routeContext, safeParse, searchParam, serializeCookie, setCacheStore, setClientBundles, settled, spacerTag, spread, start, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };
|
package/dist/runtime/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { E as vars, _ as mergeAttributes, c as classAttribute, d as escapeAttribute, i as affix, m as internal, u as escape, v as onAttribute, x as raw } from "../html-t1JpkODI.js";
|
|
2
2
|
import { a as serializeCookie, i as parseCookies, s as toNodeHeaders, t as createSession } from "../cookies-Cnbf4w-S.js";
|
|
3
|
-
import {
|
|
4
|
-
import { $ as dedupe, A as streamParts, B as ValidationError, C as setClientBundles, D as start, E as spread, F as RateLimitError, G as matchRoute, H as parse, I as clientAddress, J as revalidate, K as cached, L as configureRateLimit, M as wait, N as waitAll, O as stateScript, P as idempotent, Q as ServerError, R as rateLimit, S as renderToStream, T as spacerTag, U as parseForm, V as fieldErrors, W as safeParse, X as storageStore, Y as setCacheStore, Z as RequestEvent, _ as memo, a as attribute, b as ready, c as children, d as handleRequest, et as defineMiddleware, f as handleRoute, g as lazy, h as isCrossSite, i as actionResult, it as withEvent, j as streamState, k as stateValue, l as component, m as insert, n as NotReady, nt as isRedirect, o as binding, p as inlineBodies, q as memoryStore, r as action, rt as redirect, s as caught, t as Context, tt as getEvent, u as dynamic, v as packState, w as settled, x as render, y as read, z as parseSubmission } from "../server-
|
|
3
|
+
import { E as useSerialEntry, T as unbind, c as ElementReference, i as produce, l as FunctionReference, n as searchParam } from "../search-params-CM1RWR2P.js";
|
|
4
|
+
import { $ as dedupe, A as streamParts, B as ValidationError, C as setClientBundles, D as start, E as spread, F as RateLimitError, G as matchRoute, H as parse, I as clientAddress, J as revalidate, K as cached, L as configureRateLimit, M as wait, N as waitAll, O as stateScript, P as idempotent, Q as ServerError, R as rateLimit, S as renderToStream, T as spacerTag, U as parseForm, V as fieldErrors, W as safeParse, X as storageStore, Y as setCacheStore, Z as RequestEvent, _ as memo, a as attribute, b as ready, c as children, d as handleRequest, et as defineMiddleware, f as handleRoute, g as lazy, h as isCrossSite, i as actionResult, it as withEvent, j as streamState, k as stateValue, l as component, m as insert, n as NotReady, nt as isRedirect, o as binding, p as inlineBodies, q as memoryStore, r as action, rt as redirect, s as caught, t as Context, tt as getEvent, u as dynamic, v as packState, w as settled, x as render, y as read, z as parseSubmission } from "../server-BcT9icQ4.js";
|
|
5
5
|
import { a as routeContext, i as navigationContext, r as createContext } from "../context-CTiSzQRc.js";
|
|
6
|
-
export { Context, ElementReference, FunctionReference, NotReady, RateLimitError, RequestEvent, ServerError, ValidationError, action, actionResult, affix, attribute, binding, cached, caught, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, getEvent, handleRequest, handleRoute, idempotent, inlineBodies, insert, internal, isCrossSite, isRedirect, lazy, matchRoute, memo, memoryStore, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, parseSubmission, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, revalidate, routeContext, safeParse, serializeCookie, setCacheStore, setClientBundles, settled, spacerTag, spread, start, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };
|
|
6
|
+
export { Context, ElementReference, FunctionReference, NotReady, RateLimitError, RequestEvent, ServerError, ValidationError, action, actionResult, affix, attribute, binding, cached, caught, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, getEvent, handleRequest, handleRoute, idempotent, inlineBodies, insert, internal, isCrossSite, isRedirect, lazy, matchRoute, memo, memoryStore, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, parseSubmission, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, revalidate, routeContext, safeParse, searchParam, serializeCookie, setCacheStore, setClientBundles, settled, spacerTag, spread, start, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };
|
|
@@ -1,140 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
|
|
3
|
-
//#region src/runtime/signals.d.ts
|
|
4
|
-
declare const BINDABLE: unique symbol;
|
|
5
|
-
declare const WRITES: unique symbol;
|
|
6
|
-
/** The mark of a prop that a parent can bind. It has no value at runtime. */
|
|
7
|
-
export interface BindableMark<T> {
|
|
8
|
-
readonly [BINDABLE]: T;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* What a binding writes. A binding of a signal of `T` takes a prop that writes `W` when `W` is
|
|
12
|
-
* assignable to `T`, as a signal of `HTMLElement | undefined` takes the ref of a `div`.
|
|
13
|
-
*/
|
|
14
|
-
export interface WritableMark<W> {
|
|
15
|
-
readonly [WRITES]: (value: W) => void;
|
|
16
|
-
}
|
|
17
|
-
/** What `$bind` returns: the mark of a prop, and the write side that checks the type of a ref. */
|
|
18
|
-
export interface BoundSignal<T> extends BindableMark<T>, WritableMark<T> {}
|
|
19
|
-
/**
|
|
20
|
-
* Marks a prop that a parent can bind with `$bind`, such as
|
|
21
|
-
* `open?: Bindable<boolean>`. The parent passes `T` or `$bind(name)`.
|
|
22
|
-
* Inside the component, `$props<T>()` gives `T`.
|
|
23
|
-
*/
|
|
24
|
-
export type Bindable<T> = T | BindableMark<T>;
|
|
25
|
-
/** The props as the component reads them, with `Bindable<T>` as `T`. */
|
|
26
|
-
export type Unbound<T> = { [K in keyof T]: Exclude<T[K], BindableMark<unknown>>; };
|
|
27
|
-
/**
|
|
28
|
-
* Returns the props of the component. Destructure the call to keep each prop
|
|
29
|
-
* reactive. Destructure it with `let` to write props, such as
|
|
30
|
-
* `let { open = false } = $props()`.
|
|
31
|
-
*/
|
|
32
|
-
export declare function $props<T = Record<string, any>>(): Unbound<T>;
|
|
33
|
-
/** Declares writable state. The variable reads and writes the signal. */
|
|
34
|
-
export declare function $signal<T>(value: T): T;
|
|
35
|
-
export declare function $signal<T>(): T | undefined;
|
|
36
|
-
/** The value of a memo: what a promise settles to, or the latest value of an async iterable. */
|
|
37
|
-
export type MemoValue<T> = Awaited<T> extends AsyncIterable<infer U> ? U : Awaited<T>;
|
|
38
|
-
/**
|
|
39
|
-
* Declares a value computed from other values. A promise is awaited where it
|
|
40
|
-
* is read. An async iterable gives each of its values in turn.
|
|
41
|
-
*/
|
|
42
|
-
export declare function $memo<T>(_value: T): MemoValue<T>;
|
|
43
|
-
/**
|
|
44
|
-
* Declares a memo that takes the value once it stops changing for `ms`
|
|
45
|
-
* milliseconds, such as a search query while the user types. On the server,
|
|
46
|
-
* and until the value first changes, it is the value.
|
|
47
|
-
*/
|
|
48
|
-
export declare function $debounced<T>(_value: T, _ms: number): MemoValue<T>;
|
|
49
|
-
/**
|
|
50
|
-
* Declares a memo that takes the value at most once every `ms`
|
|
51
|
-
* milliseconds, and the last value after the wait, such as a position while
|
|
52
|
-
* the pointer moves. On the server, and until the value first changes, it is the value.
|
|
53
|
-
*/
|
|
54
|
-
export declare function $throttled<T>(_value: T, _ms: number): MemoValue<T>;
|
|
55
|
-
/**
|
|
56
|
-
* Declares a value that follows a memo, and that handlers can write. A write
|
|
57
|
-
* shows a guess, such as a new item while the form that adds it posts. The
|
|
58
|
-
* value goes back to the memo when the memo changes, or when the server
|
|
59
|
-
* calls of the page finish, such as after a failed post.
|
|
60
|
-
*/
|
|
61
|
-
export declare function $optimistic<T>(_source: T): T;
|
|
62
|
-
/** Runs a callback when the values it reads change, after the page resumes. Never on load. */
|
|
63
|
-
export declare function $effect(_callback: () => void | (() => void)): void;
|
|
64
|
-
/** Runs a callback in the browser when a trigger fires. */
|
|
65
|
-
export declare function $client(_callback: () => void | (() => void), _trigger?: "visible" | "idle" | "load"): void;
|
|
66
|
-
/** Reads a value without depending on it. */
|
|
67
|
-
export declare function $untrack<T>(_value: T): T;
|
|
68
|
-
/** True while a new value of a memo, or of a memo it reads, loads on the client. Always false on the server. */
|
|
69
|
-
export declare function $isPending(_memo: unknown): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Waits for a memo to have its value, and gives it. It resolves at once when the memo is settled,
|
|
72
|
-
* and after the load when the memo loads its first value or loads again. When the inputs of the
|
|
73
|
-
* memo change while it waits, it waits for the load of the current inputs. It rejects with the
|
|
74
|
-
* error of the memo, when `timeout` milliseconds pass, or when `signal` aborts. Use it in a handler,
|
|
75
|
-
* an effect or a `$client` callback, never where a memo computes or markup renders.
|
|
76
|
-
*/
|
|
77
|
-
export declare function $resolve<T>(_memo: T, _options?: {
|
|
78
|
-
timeout?: number;
|
|
79
|
-
signal?: AbortSignal;
|
|
80
|
-
}): Promise<Awaited<T>>;
|
|
81
|
-
/**
|
|
82
|
-
* True when the parent passed a prop with `$bind`, so a write of it reaches the parent. The prop is
|
|
83
|
-
* one that the component destructures with `let`. Always false on the server, where nothing writes.
|
|
84
|
-
*/
|
|
85
|
-
export declare function $isBound(_prop: unknown): boolean;
|
|
86
|
-
/**
|
|
87
|
-
* True when the caller passed the prop, even as `undefined`. A part uses it to tell a controlled
|
|
88
|
-
* value, such as `value=(null)`, from no value. Declare it with `const` in the component script.
|
|
89
|
-
*/
|
|
90
|
-
export declare function $isPassed(_prop: unknown): boolean;
|
|
91
|
-
/** Returns an ID that is unique in the page and the same on the server and the client. */
|
|
92
|
-
export declare function $id(): string;
|
|
93
|
-
/** Provides a value of a context to the components inside this one. */
|
|
94
|
-
export declare function $setContext<T>(_context: Context<T>, _value: T): void;
|
|
95
|
-
/** Reads a context from the nearest component above that provides it, or its default value. */
|
|
96
|
-
export declare function $getContext<T>(_context: Context<T>): T;
|
|
97
|
-
/**
|
|
98
|
-
* The route of the page: its URL, its query string and its params, typed
|
|
99
|
-
* from the route files as `href` is. The server reads the request, and the
|
|
100
|
-
* browser reads `location`. It changes when navigation changes the URL.
|
|
101
|
-
*/
|
|
102
|
-
export declare function $route<P extends RoutePath = RoutePath>(_path?: P): Route<RouteParams<P>>;
|
|
103
|
-
/** The navigation that loads, with `pending` false when none does. Always `{ pending: false }` on the server. */
|
|
104
|
-
export declare function $navigation(): NavigationState;
|
|
105
|
-
/** Changes an object or an array in a signal through a draft, and writes the signal with the result. */
|
|
106
|
-
export declare function $produce<T>(_signal: T, _recipe: (draft: T) => T | void): void;
|
|
107
|
-
/** Sets the title of the page. The last component that sets it wins. */
|
|
108
|
-
export declare function $title(_value: unknown): void;
|
|
109
|
-
/**
|
|
110
|
-
* The latest result of a server function that a form of this component posts
|
|
111
|
-
* to, or undefined before the first post. Pending while the form sends.
|
|
112
|
-
*/
|
|
113
|
-
export declare function $action<F extends (...args: never[]) => unknown>(_fn: F): Awaited<ReturnType<F>> | undefined;
|
|
114
|
-
/**
|
|
115
|
-
* Passes a child a signal, or a prop that the component writes, so a write
|
|
116
|
-
* of the prop in the child writes it. The child destructures the prop with
|
|
117
|
-
* `let`. Pass it as the value of a prop: `<Dialog open=$bind(open) />`.
|
|
118
|
-
*
|
|
119
|
-
* - Only a prop of type `Bindable<T>` takes it.
|
|
120
|
-
* - With `set`, a write calls `set(next)` in place of writing the signal.
|
|
121
|
-
*/
|
|
122
|
-
export declare function $bind<T>(signal: T, set?: (next: T) => unknown): BoundSignal<T>;
|
|
123
|
-
/**
|
|
124
|
-
* Marks a function that a script makes as an event handler, so a spread can
|
|
125
|
-
* pass it on, as it passes on a handler that a caller writes in markup.
|
|
126
|
-
* `args` are JSON values that go with the handler, and it runs as
|
|
127
|
-
* `fn(...args, event)`.
|
|
128
|
-
*/
|
|
129
|
-
export declare function $handler<A extends unknown[], E = Event>(fn: (...args: [...A, E]) => unknown, ...args: A): (event: E) => unknown;
|
|
130
|
-
/** A function that does not read the event. */
|
|
131
|
-
export declare function $handler<A extends unknown[]>(fn: (...args: A) => unknown, ...args: A): (event: Event) => unknown;
|
|
132
|
-
/**
|
|
133
|
-
* Writes what the writes of the handler so far changed to the page, so the code after it can read
|
|
134
|
-
* the DOM, such as to focus or measure what a write rendered. A handler is one pass, and the page
|
|
135
|
-
* changes when it returns. Does nothing outside a handler, and on the server.
|
|
136
|
-
*/
|
|
137
|
-
export declare function flush(): void;
|
|
138
|
-
//#endregion
|
|
139
|
-
export {};
|
|
140
|
-
//# sourceMappingURL=signals.d.ts.map
|
|
1
|
+
import { A as Unbound, C as $title, D as BoundSignal, E as BindableMark, M as flush, O as MemoValue, S as $throttled, T as Bindable, _ as $resolve, a as $effect, b as $setContext, c as $id, d as $isPending, f as $memo, g as $props, h as $produce, i as $debounced, j as WritableMark, k as SearchParamOptions, l as $isBound, m as $optimistic, n as $bind, o as $getContext, p as $navigation, r as $client, s as $handler, t as $action, u as $isPassed, v as $route, w as $untrack, x as $signal, y as $searchParam } from "../signals-BwD4u22K.js";
|
|
2
|
+
export { $action, $bind, $client, $debounced, $effect, $getContext, $handler, $id, $isBound, $isPassed, $isPending, $memo, $navigation, $optimistic, $produce, $props, $resolve, $route, $searchParam, $setContext, $signal, $throttled, $title, $untrack, Bindable, BindableMark, BoundSignal, MemoValue, SearchParamOptions, Unbound, WritableMark, flush };
|
package/dist/runtime/signals.js
CHANGED
|
@@ -105,6 +105,9 @@ function $getContext(_context) {
|
|
|
105
105
|
function $route(_path) {
|
|
106
106
|
return compileTimeOnly("$route");
|
|
107
107
|
}
|
|
108
|
+
function $searchParam() {
|
|
109
|
+
return compileTimeOnly("$searchParam");
|
|
110
|
+
}
|
|
108
111
|
/** The navigation that loads, with `pending` false when none does. Always `{ pending: false }` on the server. */
|
|
109
112
|
function $navigation() {
|
|
110
113
|
return compileTimeOnly("$navigation");
|
|
@@ -139,6 +142,6 @@ function flush() {
|
|
|
139
142
|
globalThis[Symbol.for("brumate.flush")]?.();
|
|
140
143
|
}
|
|
141
144
|
//#endregion
|
|
142
|
-
export { $action, $bind, $client, $debounced, $effect, $getContext, $handler, $id, $isBound, $isPassed, $isPending, $memo, $navigation, $optimistic, $produce, $props, $resolve, $route, $setContext, $signal, $throttled, $title, $untrack, flush };
|
|
145
|
+
export { $action, $bind, $client, $debounced, $effect, $getContext, $handler, $id, $isBound, $isPassed, $isPending, $memo, $navigation, $optimistic, $produce, $props, $resolve, $route, $searchParam, $setContext, $signal, $throttled, $title, $untrack, flush };
|
|
143
146
|
|
|
144
147
|
//# sourceMappingURL=signals.js.map
|