brumate 0.7.2 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{boot-CMy0f_iC.d.ts → boot-DQuAhAd5.d.ts} +2 -2
- package/dist/cli.js +3 -2
- package/dist/cli.js.map +1 -1
- package/dist/{client-DnFF9_lv.d.ts → client-4eabQtYJ.d.ts} +38 -12
- package/dist/{client-COm1iA6w.js → client-CwVcmymi.js} +145 -28
- package/dist/client-CwVcmymi.js.map +1 -0
- package/dist/{defer-Cesb-k2Q.js → defer-BaXWydb0.js} +2 -2
- package/dist/{defer-Cesb-k2Q.js.map → defer-BaXWydb0.js.map} +1 -1
- package/dist/{devtools-C9IEkgc1.js → devtools-CMuj12yR.js} +257 -118
- package/dist/devtools-CMuj12yR.js.map +1 -0
- package/dist/devtools-calls-DGW6nLZ2.js +249 -0
- package/dist/devtools-calls-DGW6nLZ2.js.map +1 -0
- package/dist/devtools-panel-Cq8LpsyW.js +3978 -0
- package/dist/devtools-panel-Cq8LpsyW.js.map +1 -0
- package/dist/error-catalog-DakxjSgj.js +308 -0
- package/dist/error-catalog-DakxjSgj.js.map +1 -0
- package/dist/error-catalog-VxLbz-6p.js +1 -0
- package/dist/{files-BuQvpBwF.js → files-DXS8RAtZ.js} +2 -2
- package/dist/{files-BuQvpBwF.js.map → files-DXS8RAtZ.js.map} +1 -1
- package/dist/index.d.ts +73 -18
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/{inspect-BSHv1_25.js → inspect-B5AoHh5O.js} +639 -412
- package/dist/inspect-B5AoHh5O.js.map +1 -0
- package/dist/{loader-CLKrJMqw.js → loader-CTeT6ie9.js} +4 -4
- package/dist/{loader-CLKrJMqw.js.map → loader-CTeT6ie9.js.map} +1 -1
- package/dist/{navigate-OHb0Uw1P.js → navigate-Bj73X4ZS.js} +22 -8
- package/dist/navigate-Bj73X4ZS.js.map +1 -0
- package/dist/{rpc-BAKbRWOT.js → rpc-kVB0Ujdx.js} +5 -4
- package/dist/rpc-kVB0Ujdx.js.map +1 -0
- package/dist/runtime/bundles.d.ts +3 -2
- package/dist/runtime/bundles.js +14 -3
- package/dist/runtime/bundles.js.map +1 -1
- package/dist/runtime/client.d.ts +2 -2
- package/dist/runtime/client.js +4 -3
- package/dist/runtime/devtools.d.ts +59 -1
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/hot.js +6 -2
- package/dist/runtime/hot.js.map +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/server.d.ts +1 -1
- package/dist/runtime/server.js +3 -2
- package/dist/runtime/signals.d.ts +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/store.d.ts +2 -2
- package/dist/runtime/store.js +1 -1
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/search-params-Wg-0FsMj.js +148 -0
- package/dist/search-params-Wg-0FsMj.js.map +1 -0
- package/dist/{stream-RXLadXx1.js → serial-ioa17MuY.js} +67 -168
- package/dist/serial-ioa17MuY.js.map +1 -0
- package/dist/serial-ribg9NAj.js +1 -0
- package/dist/{server-BVObWh-w.js → server-BUuf7XPZ.js} +61 -16
- package/dist/server-BUuf7XPZ.js.map +1 -0
- package/dist/{server-0rS5vUW1.d.ts → server-DesBZv5g.d.ts} +8 -3
- package/dist/{search-params-C64liRBj.js → shared-CX_YacDm.js} +3 -148
- package/dist/shared-CX_YacDm.js.map +1 -0
- package/dist/{signals-DBnq9QRW.d.ts → signals-7VVD9C_H.d.ts} +2 -2
- package/dist/{static-loader-CxANokZ4.js → static-loader-BM0-wdIc.js} +2 -2
- package/dist/{static-loader-CxANokZ4.js.map → static-loader-BM0-wdIc.js.map} +1 -1
- package/dist/{static-loader-BYbXVJDY.d.ts → static-loader-BSAyFqG0.d.ts} +2 -2
- package/dist/{store-xlTzAM_r.d.ts → store-9_oa0HG1.d.ts} +15 -2
- package/dist/{store-BIBAYZo-.js → store-Cy4EEyZ7.js} +148 -2
- package/dist/store-Cy4EEyZ7.js.map +1 -0
- package/dist/stream-read-BTsYstJY.js +22 -0
- package/dist/stream-read-BTsYstJY.js.map +1 -0
- package/dist/stream-read-Dek3HnqO.js +1 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +37 -5
- package/dist/vite.js.map +1 -1
- package/package.json +7 -4
- package/skills/brumate/SKILL.md +6 -2
- package/skills/brumate/references/errors.md +21 -2
- package/skills/brumate/references/state.md +31 -0
- package/skills/brumate/references/syntax.md +45 -1
- package/dist/client-COm1iA6w.js.map +0 -1
- package/dist/devtools-C9IEkgc1.js.map +0 -1
- package/dist/devtools-panel-Doit__YG.js +0 -2018
- package/dist/devtools-panel-Doit__YG.js.map +0 -1
- package/dist/inspect-BSHv1_25.js.map +0 -1
- package/dist/navigate-OHb0Uw1P.js.map +0 -1
- package/dist/rpc-BAKbRWOT.js.map +0 -1
- package/dist/search-params-C64liRBj.js.map +0 -1
- package/dist/server-BVObWh-w.js.map +0 -1
- package/dist/store-BIBAYZo-.js.map +0 -1
- package/dist/stream-RXLadXx1.js.map +0 -1
package/dist/runtime/hot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hot.js","names":[],"sources":["../../src/runtime/hot.ts"],"sourcesContent":["// Hot updates on the dev server. When an edit of a component keeps its\n// markup, its slots and its update table, the plugin sends `brumate:update`\n// instead of reloading the page. New styles replace the old ones, and the\n// next event or update of the component loads its new code. State stays.\n//\n// When the markup changes, the page loads again through the client router,\n// and the signals of the component keep their values, by their names.\n\nimport type { ClientModule } from './client.ts';\n\n/** What `brumate:update` holds for each component that changed. */\nexport interface HotUpdate {\n id: string;\n /** The new styles, when they changed. */\n css?: string;\n /** The URL of the new client entry, when its code changed. */\n url?: string;\n /** Set when the markup changed, so the page renders again with the values of its signals. */\n remount?: Remount;\n}\n\n/** The slots of a component before and after an edit, by the ID of each scope in the component. */\nexport interface Remount {\n /** The names of the slots before the edit. */\n before: Record<number, string[]>;\n /** The names of the slots after the edit. */\n after: Record<number, string[]>;\n /** The names of the signals, whose values stay. */\n signals: string[];\n}\n\n/** The part of `import.meta.hot` that this module uses. */\nexport interface HotContext {\n on(\n event: 'brumate:update',\n listener: (data: { updates: HotUpdate[]; timestamp: number }) => void,\n ): void;\n}\n\n/**\n * Listens for updates of components, and returns a `load` for the loader\n * that loads the new code of a component that changed. Pass\n * `import.meta.hot`, which only the module that reads it gets.\n */\nexport function hotLoad(\n hot: HotContext | undefined,\n load: (id: string) => Promise<ClientModule>,\n): (id: string) => Promise<ClientModule> {\n if (!hot) {\n return load;\n }\n const fresh = new Map<string, string>();\n hot.on('brumate:update', ({ updates, timestamp }) => {\n const changed: string[] = [];\n const remounts: HotUpdate[] = [];\n for (const update of updates) {\n if (update.remount) {\n remounts.push(update);\n }\n if (update.css !== undefined) {\n const style = document.querySelector(`style[b-style=\"${CSS.escape(update.id)}\"]`);\n if (style) {\n style.textContent = update.css;\n }\n }\n if (update.url) {\n fresh.set(update.id, `${update.url}${update.url.includes('?') ? '&' : '?'}t=${timestamp}`);\n changed.push(update.id);\n }\n }\n if (changed.length > 0) {\n document.dispatchEvent(new CustomEvent('brumate:hot', { detail: changed }));\n }\n if (changed.length === 0 && remounts.length === 0) {\n return;\n }\n // The core has the hot update code, which only this module calls, so builds leave it out.\n void import('./client.ts').then(({ forget, remount }) => {\n // The core forgets the old code of these components.\n forget(changed);\n if (remounts.length > 0) {\n // The core keeps the values of the signals, and the loader loads the page again.\n const moved: Parameters<typeof remount>[0] = [];\n for (const update of remounts) {\n moved.push(Object.assign({ id: update.id }, update.remount!));\n }\n remount(moved);\n document.dispatchEvent(new CustomEvent('brumate:reload'));\n }\n });\n });\n
|
|
1
|
+
{"version":3,"file":"hot.js","names":[],"sources":["../../src/runtime/hot.ts"],"sourcesContent":["// Hot updates on the dev server. When an edit of a component keeps its\n// markup, its slots and its update table, the plugin sends `brumate:update`\n// instead of reloading the page. New styles replace the old ones, and the\n// next event or update of the component loads its new code. State stays.\n//\n// When the markup changes, the page loads again through the client router,\n// and the signals of the component keep their values, by their names.\n\nimport type { ClientModule } from './client.ts';\n\n/** What `brumate:update` holds for each component that changed. */\nexport interface HotUpdate {\n id: string;\n /** The new styles, when they changed. */\n css?: string;\n /** The URL of the new client entry, when its code changed. */\n url?: string;\n /** Set when the markup changed, so the page renders again with the values of its signals. */\n remount?: Remount;\n}\n\n/** The slots of a component before and after an edit, by the ID of each scope in the component. */\nexport interface Remount {\n /** The names of the slots before the edit. */\n before: Record<number, string[]>;\n /** The names of the slots after the edit. */\n after: Record<number, string[]>;\n /** The names of the signals, whose values stay. */\n signals: string[];\n}\n\n/** The part of `import.meta.hot` that this module uses. */\nexport interface HotContext {\n on(\n event: 'brumate:update',\n listener: (data: { updates: HotUpdate[]; timestamp: number }) => void,\n ): void;\n}\n\n/** The loads that `hotLoad` returned. */\nconst hotLoads = new WeakSet<object>();\n\n/**\n * Listens for updates of components, and returns a `load` for the loader\n * that loads the new code of a component that changed. Pass\n * `import.meta.hot`, which only the module that reads it gets.\n */\nexport function hotLoad(\n hot: HotContext | undefined,\n load: (id: string) => Promise<ClientModule>,\n): (id: string) => Promise<ClientModule> {\n // The plugin wraps the load of every entry, so a load that is wrapped already stays as it is.\n if (!hot || hotLoads.has(load)) {\n return load;\n }\n const fresh = new Map<string, string>();\n hot.on('brumate:update', ({ updates, timestamp }) => {\n const changed: string[] = [];\n const remounts: HotUpdate[] = [];\n for (const update of updates) {\n if (update.remount) {\n remounts.push(update);\n }\n if (update.css !== undefined) {\n const style = document.querySelector(`style[b-style=\"${CSS.escape(update.id)}\"]`);\n if (style) {\n style.textContent = update.css;\n }\n }\n if (update.url) {\n fresh.set(update.id, `${update.url}${update.url.includes('?') ? '&' : '?'}t=${timestamp}`);\n changed.push(update.id);\n }\n }\n if (changed.length > 0) {\n document.dispatchEvent(new CustomEvent('brumate:hot', { detail: changed }));\n }\n if (changed.length === 0 && remounts.length === 0) {\n return;\n }\n // The core has the hot update code, which only this module calls, so builds leave it out.\n void import('./client.ts').then(({ forget, remount }) => {\n // The core forgets the old code of these components.\n forget(changed);\n if (remounts.length > 0) {\n // The core keeps the values of the signals, and the loader loads the page again.\n const moved: Parameters<typeof remount>[0] = [];\n for (const update of remounts) {\n moved.push(Object.assign({ id: update.id }, update.remount!));\n }\n remount(moved);\n document.dispatchEvent(new CustomEvent('brumate:reload'));\n }\n });\n });\n const wrapped = (id: string): Promise<ClientModule> => {\n const url = fresh.get(id);\n return url ? (import(/* @vite-ignore */ url) as Promise<ClientModule>) : load(id);\n };\n hotLoads.add(wrapped);\n return wrapped;\n}\n"],"mappings":";;AAwCA,MAAM,2BAAW,IAAI,QAAgB;;;;;;AAOrC,SAAgB,QACd,KACA,MACuC;CAEvC,IAAI,CAAC,OAAO,SAAS,IAAI,IAAI,GAC3B,OAAO;CAET,MAAM,wBAAQ,IAAI,IAAoB;CACtC,IAAI,GAAG,mBAAmB,EAAE,SAAS,gBAAgB;EACnD,MAAM,UAAoB,CAAC;EAC3B,MAAM,WAAwB,CAAC;EAC/B,KAAK,MAAM,UAAU,SAAS;GAC5B,IAAI,OAAO,SACT,SAAS,KAAK,MAAM;GAEtB,IAAI,OAAO,QAAQ,KAAA,GAAW;IAC5B,MAAM,QAAQ,SAAS,cAAc,kBAAkB,IAAI,OAAO,OAAO,EAAE,EAAE,GAAG;IAChF,IAAI,OACF,MAAM,cAAc,OAAO;GAE/B;GACA,IAAI,OAAO,KAAK;IACd,MAAM,IAAI,OAAO,IAAI,GAAG,OAAO,MAAM,OAAO,IAAI,SAAS,GAAG,IAAI,MAAM,IAAI,IAAI,WAAW;IACzF,QAAQ,KAAK,OAAO,EAAE;GACxB;EACF;EACA,IAAI,QAAQ,SAAS,GACnB,SAAS,cAAc,IAAI,YAAY,eAAe,EAAE,QAAQ,QAAQ,CAAC,CAAC;EAE5E,IAAI,QAAQ,WAAW,KAAK,SAAS,WAAW,GAC9C;EAGF,OAAY,cAAc,CAAC,MAAM,EAAE,QAAQ,cAAc;GAEvD,OAAO,OAAO;GACd,IAAI,SAAS,SAAS,GAAG;IAEvB,MAAM,QAAuC,CAAC;IAC9C,KAAK,MAAM,UAAU,UACnB,MAAM,KAAK,OAAO,OAAO,EAAE,IAAI,OAAO,GAAG,GAAG,OAAO,OAAQ,CAAC;IAE9D,QAAQ,KAAK;IACb,SAAS,cAAc,IAAI,YAAY,gBAAgB,CAAC;GAC1D;EACF,CAAC;CACH,CAAC;CACD,MAAM,WAAW,OAAsC;EACrD,MAAM,MAAM,MAAM,IAAI,EAAE;EACxB,OAAO,MAAO;;GAA0B;IAAiC,KAAK,EAAE;CAClF;CACA,SAAS,IAAI,OAAO;CACpB,OAAO;AACT"}
|
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-DQuAhAd5.js";
|
|
2
|
+
import { t as startWithoutNavigation } from "../static-loader-BSAyFqG0.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-BM0-wdIc.js";
|
|
2
|
+
import { t as start } from "../loader-CTeT6ie9.js";
|
|
3
3
|
export { start, startWithoutNavigation };
|
package/dist/runtime/server.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { A as mergeAttributes, C as escape, D as internal, P as raw, _ as affix,
|
|
|
3
3
|
import { t as produce } from "../produce-CLABZ8k2.js";
|
|
4
4
|
import { t as StandardSchemaV1 } from "../standard-schema-BNY82yX3.js";
|
|
5
5
|
import { f as Intent, v as SubmissionResult } from "../forms-j1xPAR14.js";
|
|
6
|
-
import { $ as idempotent, $t as defineMiddleware, A as handleRoute, At as safeParse, B as renderToStream, Bt as searchParam, C as attribute, Ct as parseSubmission, D as component, Dt as fieldErrors, E as children, Et as ValidationIssue, F as memo, Ft as MiddlewareLoader, G as start, Gt as RequestEvent, H as settled, Ht as Locals, I as packState, It as RouteMatch, J as streamParts, Jt as ServerError, K as stateScript, Kt as RequestEventOptions, L as read, Lt as RouteNode, M as insert, Mt as Handler, N as isCrossSite, Nt as Loader, O as dynamic, Ot as parse, P as lazy, Pt as Middleware, Q as IdempotentOptions, Qt as dedupe, R as ready, Rt as RouteView, S as actionResult, St as SuccessfulSubmission, T as caught, Tt as ValidationError, U as spacerTag, Ut as Redirect, V as setClientBundles, Vt as EntryMiddleware, W as spread, Wt as RequestCall, X as wait, Xt as ServerErrorInfo, Y as streamState, Yt as ServerErrorHandler, Z as waitAll, Zt as ServerErrorKind, _ as ScopeEntry, _t as FailedSubmission, a as DocumentOptions, an as Session, at as setCacheStore, b as StreamOptions, bt as Submission, c as Mark, cn as parseCookies, ct as RateLimitConfig, d as PageCache, dt as RateLimitOptions, en as getEvent, et as CacheStore, f as RenderOptions, ft as RateLimitStore, g as RouteOptions, gt as rateLimit, h as RevealOrder, ht as configureRateLimit, i as DeferTarget, in as CookieOptions, it as revalidate, j as inlineBodies, jt as EndpointLoader, k as handleRequest, kt as parseForm, l as Memo, ln as serializeCookie, lt as RateLimitError, m as RequestOptions, mt as clientAddress, n as Component, nn as redirect, nt as cached, o as ItemSource, on as SessionOptions, ot as storageStore, p as RenderResult, pt as Window, q as stateValue, qt as RequestKind, r as Context, rn as withEvent, rt as memoryStore, s as Lazy, sn as createSession, st as RateLimit, t as ClientBundles, tn as isRedirect, tt as CachedOptions, u as NotReady, un as toNodeHeaders, ut as RateLimitMiddleware, v as StateAttributes, vt as IntentSubmission, w as binding, wt as ParseResult, x as action, xt as SubmissionOptions, y as StateMap, yt as ReplyOptions, z as render, zt as matchRoute } from "../server-
|
|
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-DesBZv5g.js";
|
|
7
7
|
export { type CacheStore, type CachedOptions, ClientBundles, Component, Context, type CookieOptions, DeferTarget, DocumentOptions, ElementReference, type EndpointLoader, type EntryMiddleware, type FailedSubmission, FunctionReference, type Handler, type IdempotentOptions, type Intent, type IntentSubmission, ItemSource, Lazy, type Loader, type Locals, Mark, Memo, type Middleware, type MiddlewareLoader, type NavigationState, NotReady, PageCache, type PageState, type ParseResult, type RateLimit, type RateLimitConfig, RateLimitError, type RateLimitMiddleware, type RateLimitOptions, type RateLimitStore, type Raw, type Redirect, RenderOptions, RenderResult, type ReplyOptions, type RequestCall, RequestEvent, type RequestEventOptions, type RequestKind, RequestOptions, RevealOrder, type Route, type RouteMatch, type RouteNode, RouteOptions, type RouteView, ScopeEntry, type ScopeId, type ScopeState, ServerError, type ServerErrorHandler, type ServerErrorInfo, type ServerErrorKind, type Session, type SessionOptions, type StandardSchemaV1, StateAttributes, StateMap, StreamOptions, type Submission, type SubmissionOptions, type SubmissionResult, type SuccessfulSubmission, ValidationError, type ValidationIssue, type Window, action, actionResult, affix, attribute, binding, cached, caught, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, gateValue, getEvent, handleRequest, handleRoute, idempotent, inlineBodies, insert, internal, isCrossSite, isRedirect, lazy, matchRoute, memo, memoryStore, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, parseSubmission, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, revalidate, routeContext, safeParse, searchParam, serializeCookie, setCacheStore, setClientBundles, settled, spacerTag, spread, start, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };
|
package/dist/runtime/server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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-Cf5uKhLs.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 { C as unbind, a as FunctionReference, f as gateValue, i as ElementReference, w as useSerialEntry } from "../shared-CX_YacDm.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-BUuf7XPZ.js";
|
|
5
|
+
import { i as produce, n as searchParam } from "../search-params-Wg-0FsMj.js";
|
|
5
6
|
import { a as navigationContext, o as routeContext, r as createContext } from "../context-CU4Fpn5a.js";
|
|
6
7
|
export { Context, ElementReference, FunctionReference, NotReady, RateLimitError, RequestEvent, ServerError, ValidationError, action, actionResult, affix, attribute, binding, cached, caught, children, classAttribute, clientAddress, component, configureRateLimit, createContext, createSession, dedupe, defineMiddleware, dynamic, escape, escapeAttribute, fieldErrors, gateValue, getEvent, handleRequest, handleRoute, idempotent, inlineBodies, insert, internal, isCrossSite, isRedirect, lazy, matchRoute, memo, memoryStore, mergeAttributes, navigationContext, onAttribute, packState, parse, parseCookies, parseForm, parseSubmission, produce, rateLimit, raw, read, ready, redirect, render, renderToStream, revalidate, routeContext, safeParse, searchParam, serializeCookie, setCacheStore, setClientBundles, settled, spacerTag, spread, start, stateScript, stateValue, storageStore, streamParts, streamState, toNodeHeaders, unbind, useSerialEntry, vars, wait, waitAll, withEvent };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as BoundSignal, C as $store, D as $untrack, E as $toStore, F as flush, M as SearchParamOptions, N as Unbound, O as Bindable, P as WritableMark, S as $signal, T as $title, _ as $props, a as $effect, b as $searchParam, c as $handler, d as $isPassed, f as $isPending, g as $produce, h as $optimistic, i as $debounced, j as MemoValue, k as BindableMark, l as $id, m as $navigation, n as $bind, o as $gate, p as $memo, r as $client, s as $getContext, t as $action, u as $isBound, v as $resolve, w as $throttled, x as $setContext, y as $route } from "../signals-
|
|
1
|
+
import { A as BoundSignal, C as $store, D as $untrack, E as $toStore, F as flush, M as SearchParamOptions, N as Unbound, O as Bindable, P as WritableMark, S as $signal, T as $title, _ as $props, a as $effect, b as $searchParam, c as $handler, d as $isPassed, f as $isPending, g as $produce, h as $optimistic, i as $debounced, j as MemoValue, k as BindableMark, l as $id, m as $navigation, n as $bind, o as $gate, p as $memo, r as $client, s as $getContext, t as $action, u as $isBound, v as $resolve, w as $throttled, x as $setContext, y as $route } from "../signals-7VVD9C_H.js";
|
|
2
2
|
export { $action, $bind, $client, $debounced, $effect, $gate, $getContext, $handler, $id, $isBound, $isPassed, $isPending, $memo, $navigation, $optimistic, $produce, $props, $resolve, $route, $searchParam, $setContext, $signal, $store, $throttled, $title, $toStore, $untrack, Bindable, BindableMark, BoundSignal, MemoValue, SearchParamOptions, Unbound, WritableMark, flush };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as LoaderOptions } from "../boot-
|
|
2
|
-
import { t as startWithoutNavigation } from "../static-loader-
|
|
1
|
+
import { t as LoaderOptions } from "../boot-DQuAhAd5.js";
|
|
2
|
+
import { t as startWithoutNavigation } from "../static-loader-BSAyFqG0.js";
|
|
3
3
|
export { type LoaderOptions, startWithoutNavigation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as startWithoutNavigation } from "../static-loader-
|
|
1
|
+
export { t as startWithoutNavigation } from "../static-loader-BM0-wdIc.js";
|
package/dist/runtime/store.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
export { Bridge, BridgeOptions, Bridged, BridgedStore, Store, StoreLike, StoreOrigin, bridge, canSet, findStored, isBridged, isContext, isContract, isForeignStore, isStore, nameBridge, sameData, sendStore, sentForeignStore, setBridgeLoader, store };
|
|
1
|
+
import { C as setBridgeLoader, S as sentForeignStore, _ as isForeignStore, a as Store, b as sameData, c as Stores, d as canSet, f as derived, g as isContract, h as isContext, i as BridgedStore, l as StoresValues, m as isBridged, n as BridgeOptions, o as StoreLike, p as findStored, r as Bridged, s as StoreOrigin, t as Bridge, u as bridge, v as isStore, w as store, x as sendStore, y as nameBridge } from "../store-9_oa0HG1.js";
|
|
2
|
+
export { Bridge, BridgeOptions, Bridged, BridgedStore, Store, StoreLike, StoreOrigin, Stores, StoresValues, bridge, canSet, derived, findStored, isBridged, isContext, isContract, isForeignStore, isStore, nameBridge, sameData, sendStore, sentForeignStore, setBridgeLoader, store };
|
package/dist/runtime/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Bridged, n as Store, r as bridge, i as canSet, a as
|
|
1
|
+
export { t as Bridged, n as Store, r as bridge, i as canSet, a as derived, o as findStored, s as isBridged, c as isContext, l as isContract, u as isForeignStore, d as isStore, f as nameBridge, p as sameData, m as sendStore, h as sentForeignStore, g as setBridgeLoader, _ as store } from "../store-Cy4EEyZ7.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Vt as EntryMiddleware, Yt as ServerErrorHandler, f as RenderOptions, n as Component } from "../server-
|
|
1
|
+
import { Yt as ClientModule } from "../client-4eabQtYJ.js";
|
|
2
|
+
import { Vt as EntryMiddleware, Yt as ServerErrorHandler, f as RenderOptions, n as Component } from "../server-DesBZv5g.js";
|
|
3
3
|
//#region src/runtime/testing.d.ts
|
|
4
4
|
/** The middleware of files of server functions, by function ID. */
|
|
5
5
|
type FileMiddleware = Record<string, EntryMiddleware>;
|
package/dist/runtime/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as handleRequest, x as render } from "../server-
|
|
2
|
-
import { t as start } from "../loader-
|
|
1
|
+
import { d as handleRequest, x as render } from "../server-BUuf7XPZ.js";
|
|
2
|
+
import { t as start } from "../loader-CTeT6ie9.js";
|
|
3
3
|
//#region src/runtime/nodes.ts
|
|
4
4
|
const VOID = /* @__PURE__ */ new Set([
|
|
5
5
|
"area",
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { o as routeContext } from "./context-CU4Fpn5a.js";
|
|
2
|
+
//#region src/runtime/produce.ts
|
|
3
|
+
const DRAFT = Symbol("brumate.draft");
|
|
4
|
+
/** Plain objects and arrays can be drafted. Other values, such as `Map`, are used as they are. */
|
|
5
|
+
function isDraftable(value) {
|
|
6
|
+
if (typeof value !== "object" || value === null) return false;
|
|
7
|
+
if (Array.isArray(value)) return true;
|
|
8
|
+
const prototype = Object.getPrototypeOf(value);
|
|
9
|
+
return prototype === Object.prototype || prototype === null;
|
|
10
|
+
}
|
|
11
|
+
function latest(state) {
|
|
12
|
+
return state.copy ?? state.base;
|
|
13
|
+
}
|
|
14
|
+
/** Copies an object and its parents on the first change. */
|
|
15
|
+
function prepare(state) {
|
|
16
|
+
for (let current = state; current && !current.modified; current = current.parent) {
|
|
17
|
+
current.modified = true;
|
|
18
|
+
current.copy = Array.isArray(current.base) ? [...current.base] : { ...current.base };
|
|
19
|
+
}
|
|
20
|
+
return state.copy;
|
|
21
|
+
}
|
|
22
|
+
function getDraftState(value) {
|
|
23
|
+
return typeof value === "object" && value !== null ? value[DRAFT] : void 0;
|
|
24
|
+
}
|
|
25
|
+
function createDraft(base, parent) {
|
|
26
|
+
const state = {
|
|
27
|
+
base,
|
|
28
|
+
copy: void 0,
|
|
29
|
+
parent,
|
|
30
|
+
children: /* @__PURE__ */ new Map(),
|
|
31
|
+
modified: false
|
|
32
|
+
};
|
|
33
|
+
const target = Array.isArray(base) ? [] : Object.create(Object.getPrototypeOf(base));
|
|
34
|
+
state.proxy = new Proxy(target, {
|
|
35
|
+
get(_, key) {
|
|
36
|
+
if (key === DRAFT) return state;
|
|
37
|
+
const source = latest(state);
|
|
38
|
+
const value = source[key];
|
|
39
|
+
if (!Object.hasOwn(source, key) || !isDraftable(value) || value !== state.base[key]) return value;
|
|
40
|
+
let child = state.children.get(key);
|
|
41
|
+
if (!child) {
|
|
42
|
+
child = createDraft(value, state);
|
|
43
|
+
state.children.set(key, child);
|
|
44
|
+
}
|
|
45
|
+
return child.proxy;
|
|
46
|
+
},
|
|
47
|
+
set(_, key, value) {
|
|
48
|
+
const source = latest(state);
|
|
49
|
+
if (Object.is(source[key], value) && Object.hasOwn(source, key)) return true;
|
|
50
|
+
prepare(state)[key] = value;
|
|
51
|
+
state.children.delete(key);
|
|
52
|
+
return true;
|
|
53
|
+
},
|
|
54
|
+
deleteProperty(_, key) {
|
|
55
|
+
if (Object.hasOwn(latest(state), key)) {
|
|
56
|
+
delete prepare(state)[key];
|
|
57
|
+
state.children.delete(key);
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
},
|
|
61
|
+
has(_, key) {
|
|
62
|
+
return key in latest(state);
|
|
63
|
+
},
|
|
64
|
+
ownKeys() {
|
|
65
|
+
return Reflect.ownKeys(latest(state));
|
|
66
|
+
},
|
|
67
|
+
getOwnPropertyDescriptor(_, key) {
|
|
68
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(latest(state), key);
|
|
69
|
+
if (descriptor && key !== "length") {
|
|
70
|
+
descriptor.configurable = true;
|
|
71
|
+
descriptor.writable = true;
|
|
72
|
+
}
|
|
73
|
+
return descriptor;
|
|
74
|
+
},
|
|
75
|
+
defineProperty(_, key, descriptor) {
|
|
76
|
+
prepare(state);
|
|
77
|
+
return Reflect.defineProperty(state.copy, key, descriptor);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return state;
|
|
81
|
+
}
|
|
82
|
+
/** Returns the final value of a draft: the base if nothing changed, or a new object that shares what did not. */
|
|
83
|
+
function finalize(state) {
|
|
84
|
+
if (!state.modified) {
|
|
85
|
+
for (const child of state.children.values()) if (child.modified) {
|
|
86
|
+
prepare(state);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
if (!state.modified) return state.base;
|
|
90
|
+
}
|
|
91
|
+
const copy = state.copy;
|
|
92
|
+
for (const [key, child] of state.children) if (copy[key] === child.base) copy[key] = finalize(child);
|
|
93
|
+
for (const key of Reflect.ownKeys(copy)) {
|
|
94
|
+
const draft = getDraftState(copy[key]);
|
|
95
|
+
if (draft) copy[key] = finalize(draft);
|
|
96
|
+
}
|
|
97
|
+
return copy;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns a changed copy of a value. The recipe changes a draft as if it
|
|
101
|
+
* were the value. Objects that it does not change keep their identity, and
|
|
102
|
+
* if it changes nothing, the value itself is returned. A recipe can also
|
|
103
|
+
* return a new value. Only plain objects and arrays are drafted.
|
|
104
|
+
*/
|
|
105
|
+
function produce(base, recipe) {
|
|
106
|
+
if (!isDraftable(base)) {
|
|
107
|
+
const result = recipe(base);
|
|
108
|
+
return result === void 0 ? base : result;
|
|
109
|
+
}
|
|
110
|
+
const state = createDraft(base, void 0);
|
|
111
|
+
const result = recipe(state.proxy);
|
|
112
|
+
if (result !== void 0 && result !== state.proxy) return resolve(result, /* @__PURE__ */ new Set());
|
|
113
|
+
return finalize(state);
|
|
114
|
+
}
|
|
115
|
+
/** Replaces the drafts in a value that a recipe returns, such as the result of `draft.filter(…)`. */
|
|
116
|
+
function resolve(value, seen) {
|
|
117
|
+
const draft = getDraftState(value);
|
|
118
|
+
if (draft) return finalize(draft);
|
|
119
|
+
if (!isDraftable(value) || seen.has(value)) return value;
|
|
120
|
+
seen.add(value);
|
|
121
|
+
for (const key of Reflect.ownKeys(value)) value[key] = resolve(value[key], seen);
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/runtime/search-params.ts
|
|
126
|
+
/** The value of a parameter in a query string: its text parsed, or the default when it is absent. */
|
|
127
|
+
function readParam(search, name, options) {
|
|
128
|
+
const text = search.get(name);
|
|
129
|
+
if (text === null) return options?.default ?? null;
|
|
130
|
+
return options?.parse ? options.parse(text) : text;
|
|
131
|
+
}
|
|
132
|
+
/** The text of a value in the URL, or null for the default, which leaves the parameter out. */
|
|
133
|
+
function writeParam(value, options) {
|
|
134
|
+
const own = formatParam(value, options);
|
|
135
|
+
return own === formatParam(options?.default, options) ? null : own;
|
|
136
|
+
}
|
|
137
|
+
function formatParam(value, options) {
|
|
138
|
+
if (value === null || value === void 0) return null;
|
|
139
|
+
return options?.serialize ? options.serialize(value) : String(value);
|
|
140
|
+
}
|
|
141
|
+
/** `$searchParam` on the server: the parameter of the request's URL. */
|
|
142
|
+
function searchParam(context, name, options) {
|
|
143
|
+
return readParam(context.consume(routeContext, 0).search, name, options);
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { produce as i, searchParam as n, writeParam as r, readParam as t };
|
|
147
|
+
|
|
148
|
+
//# sourceMappingURL=search-params-Wg-0FsMj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-params-Wg-0FsMj.js","names":[],"sources":["../src/runtime/produce.ts","../src/runtime/search-params.ts"],"sourcesContent":["const DRAFT = Symbol('brumate.draft');\n\ninterface DraftState {\n base: Record<PropertyKey, unknown>;\n /** A shallow copy, made on the first change. */\n copy: Record<PropertyKey, unknown> | undefined;\n parent: DraftState | undefined;\n /** Drafts of the objects inside, by key. */\n children: Map<PropertyKey, DraftState & { proxy: object }>;\n modified: boolean;\n}\n\n/** Plain objects and arrays can be drafted. Other values, such as `Map`, are used as they are. */\nfunction isDraftable(value: unknown): value is Record<PropertyKey, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n if (Array.isArray(value)) {\n return true;\n }\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction latest(state: DraftState): Record<PropertyKey, unknown> {\n return state.copy ?? state.base;\n}\n\n/** Copies an object and its parents on the first change. */\nfunction prepare(state: DraftState): Record<PropertyKey, unknown> {\n for (\n let current: DraftState | undefined = state;\n current && !current.modified;\n current = current.parent\n ) {\n current.modified = true;\n current.copy = (\n Array.isArray(current.base) ? [...current.base] : { ...current.base }\n ) as Record<PropertyKey, unknown>;\n }\n return state.copy!;\n}\n\nfunction getDraftState(value: unknown): DraftState | undefined {\n return typeof value === 'object' && value !== null\n ? ((value as Record<PropertyKey, unknown>)[DRAFT] as DraftState | undefined)\n : undefined;\n}\n\nfunction createDraft(\n base: Record<PropertyKey, unknown>,\n parent: DraftState | undefined,\n): DraftState & { proxy: object } {\n const state = {\n base,\n copy: undefined,\n parent,\n children: new Map(),\n modified: false,\n } as DraftState & {\n proxy: object;\n };\n // An empty target, so the draft can report the keys of the copy.\n const target = Array.isArray(base) ? [] : Object.create(Object.getPrototypeOf(base));\n state.proxy = new Proxy(target, {\n get(_, key) {\n if (key === DRAFT) {\n return state;\n }\n const source = latest(state);\n const value = source[key];\n if (!Object.hasOwn(source, key) || !isDraftable(value) || value !== state.base[key]) {\n return value;\n }\n let child = state.children.get(key);\n if (!child) {\n child = createDraft(value, state);\n state.children.set(key, child);\n }\n return child.proxy;\n },\n set(_, key, value) {\n const source = latest(state);\n if (Object.is(source[key], value) && Object.hasOwn(source, key)) {\n return true;\n }\n prepare(state)[key] = value;\n state.children.delete(key);\n return true;\n },\n deleteProperty(_, key) {\n if (Object.hasOwn(latest(state), key)) {\n delete prepare(state)[key];\n state.children.delete(key);\n }\n return true;\n },\n has(_, key) {\n return key in latest(state);\n },\n ownKeys() {\n return Reflect.ownKeys(latest(state));\n },\n getOwnPropertyDescriptor(_, key) {\n const descriptor = Reflect.getOwnPropertyDescriptor(latest(state), key);\n if (descriptor && key !== 'length') {\n descriptor.configurable = true;\n descriptor.writable = true;\n }\n return descriptor;\n },\n defineProperty(_, key, descriptor) {\n prepare(state);\n return Reflect.defineProperty(state.copy!, key, descriptor);\n },\n });\n return state;\n}\n\n/** Returns the final value of a draft: the base if nothing changed, or a new object that shares what did not. */\nfunction finalize(state: DraftState): unknown {\n if (!state.modified) {\n // A child can change without its parent being copied yet.\n for (const child of state.children.values()) {\n if (child.modified) {\n prepare(state);\n break;\n }\n }\n if (!state.modified) {\n return state.base;\n }\n }\n const copy = state.copy!;\n for (const [key, child] of state.children) {\n if (copy[key] === child.base) {\n copy[key] = finalize(child);\n }\n }\n // Drafts can also be assigned to other keys, such as when an array is reordered.\n for (const key of Reflect.ownKeys(copy)) {\n const draft = getDraftState(copy[key]);\n if (draft) {\n copy[key] = finalize(draft);\n }\n }\n return copy;\n}\n\n/**\n * Returns a changed copy of a value. The recipe changes a draft as if it\n * were the value. Objects that it does not change keep their identity, and\n * if it changes nothing, the value itself is returned. A recipe can also\n * return a new value. Only plain objects and arrays are drafted.\n */\nexport function produce<T>(base: T, recipe: (draft: T) => T | void): T {\n if (!isDraftable(base)) {\n const result = recipe(base);\n return result === undefined ? base : result;\n }\n const state = createDraft(base, undefined);\n const result = recipe(state.proxy as T);\n if (result !== undefined && result !== state.proxy) {\n return resolve(result, new Set()) as T;\n }\n return finalize(state) as T;\n}\n\n/** Replaces the drafts in a value that a recipe returns, such as the result of `draft.filter(…)`. */\nfunction resolve(value: unknown, seen: Set<unknown>): unknown {\n const draft = getDraftState(value);\n if (draft) {\n return finalize(draft);\n }\n if (!isDraftable(value) || seen.has(value)) {\n return value;\n }\n seen.add(value);\n for (const key of Reflect.ownKeys(value)) {\n value[key] = resolve(value[key], seen);\n }\n return value;\n}\n","// `$searchParam`: the value of a parameter of the query string. The server and the browser read\n// it the same way, and the browser writes it back with `client/search.ts`.\nimport type { SearchParamOptions } from './signals.ts';\nimport { routeContext } from './context.ts';\nimport type { Context } from './context.ts';\n\n/** The value of a parameter in a query string: its text parsed, or the default when it is absent. */\nexport function readParam(\n search: URLSearchParams,\n name: string,\n options?: SearchParamOptions<unknown>,\n): unknown {\n const text = search.get(name);\n if (text === null) {\n return options?.default ?? null;\n }\n return options?.parse ? options.parse(text) : text;\n}\n\n/** The text of a value in the URL, or null for the default, which leaves the parameter out. */\nexport function writeParam(value: unknown, options?: SearchParamOptions<unknown>): string | null {\n const own = formatParam(value, options);\n return own === formatParam(options?.default, options) ? null : own;\n}\n\nfunction formatParam(value: unknown, options?: SearchParamOptions<unknown>): string | null {\n if (value === null || value === undefined) {\n return null;\n }\n return options?.serialize ? options.serialize(value) : String(value);\n}\n\n/** `$searchParam` on the server: the parameter of the request's URL. */\nexport function searchParam(\n context: { consume<T>(context: Context<T>, scope: number): T },\n name: string,\n options?: SearchParamOptions<unknown>,\n): unknown {\n return readParam(context.consume(routeContext, 0).search, name, options);\n}\n"],"mappings":"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"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { n as MODIFIERS } from "./events-LgLdp1R7.js";
|
|
2
2
|
import { S as rawHTML, g as isRaw, h as isInternal } from "./html-Cf5uKhLs.js";
|
|
3
3
|
import { i as HAS_BRIDGES } from "./features-DwMYKBIC.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Feature,
|
|
4
|
+
import { d as isStore, s as isBridged } from "./store-Cy4EEyZ7.js";
|
|
5
|
+
import { S as stateValues, b as onValuePlugin, g as isSlotReference, h as isPropWrapper, i as ElementReference, m as isBinding, n as CHILDREN_REF, s as PARTS, y as onSerialOptions } from "./shared-CX_YacDm.js";
|
|
6
|
+
import { Feature, createPlugin } from "seroval/shared";
|
|
7
|
+
import * as v from "seroval/validator";
|
|
7
8
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ImageDataPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLPlugin, URLSearchParamsPlugin } from "seroval-plugins/web";
|
|
8
9
|
//#region src/runtime/calls.ts
|
|
9
10
|
/**
|
|
@@ -49,6 +50,20 @@ function parsers(read) {
|
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
52
|
}
|
|
53
|
+
/** A scope ID, which is a number or a string. */
|
|
54
|
+
const scopeId = v.union(v.string, v.number);
|
|
55
|
+
/** The index of a file in the form: a whole number from 0. */
|
|
56
|
+
function isIndex(value) {
|
|
57
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
58
|
+
}
|
|
59
|
+
/** An array whose items are not checked: the plugin that reads them checks them. */
|
|
60
|
+
function isArray(value) {
|
|
61
|
+
return Array.isArray(value);
|
|
62
|
+
}
|
|
63
|
+
/** The arguments of a handler: an array, or null when only modifiers follow. */
|
|
64
|
+
function isArgs(value) {
|
|
65
|
+
return value === null || Array.isArray(value);
|
|
66
|
+
}
|
|
52
67
|
const ElementPlugin = createPlugin({
|
|
53
68
|
tag: "brumate/element",
|
|
54
69
|
skipPlainObjects: true,
|
|
@@ -58,7 +73,11 @@ const ElementPlugin = createPlugin({
|
|
|
58
73
|
b: value.anchor
|
|
59
74
|
})),
|
|
60
75
|
serialize: (node, ctx) => `$b.e(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,
|
|
61
|
-
deserialize: (node, ctx) => stateValues.e(ctx.deserialize(node.a), ctx.deserialize(node.b))
|
|
76
|
+
deserialize: (node, ctx) => stateValues.e(ctx.deserialize(node.a), ctx.deserialize(node.b)),
|
|
77
|
+
validate: {
|
|
78
|
+
a: scopeId,
|
|
79
|
+
b: v.number
|
|
80
|
+
}
|
|
62
81
|
});
|
|
63
82
|
const SlotPlugin = createPlugin({
|
|
64
83
|
tag: "brumate/slot",
|
|
@@ -69,7 +88,11 @@ const SlotPlugin = createPlugin({
|
|
|
69
88
|
b: value.slot
|
|
70
89
|
})),
|
|
71
90
|
serialize: (node, ctx) => `$b.l(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,
|
|
72
|
-
deserialize: (node, ctx) => stateValues.l(ctx.deserialize(node.a), ctx.deserialize(node.b))
|
|
91
|
+
deserialize: (node, ctx) => stateValues.l(ctx.deserialize(node.a), ctx.deserialize(node.b)),
|
|
92
|
+
validate: {
|
|
93
|
+
a: scopeId,
|
|
94
|
+
b: v.number
|
|
95
|
+
}
|
|
73
96
|
});
|
|
74
97
|
/** A binding that a rest prop holds: its value, and the scope and the slot it writes. */
|
|
75
98
|
const BindingPlugin = createPlugin({
|
|
@@ -91,7 +114,11 @@ const BindingPlugin = createPlugin({
|
|
|
91
114
|
node.c,
|
|
92
115
|
node.d
|
|
93
116
|
], ctx)})`,
|
|
94
|
-
deserialize: (node, ctx) => stateValues.b(ctx.deserialize(node.a), ctx.deserialize(node.b), ctx.deserialize(node.c), node.d === void 0 ? void 0 : ctx.deserialize(node.d))
|
|
117
|
+
deserialize: (node, ctx) => stateValues.b(ctx.deserialize(node.a), ctx.deserialize(node.b), ctx.deserialize(node.c), node.d === void 0 ? void 0 : ctx.deserialize(node.d)),
|
|
118
|
+
validate: {
|
|
119
|
+
b: scopeId,
|
|
120
|
+
c: v.number
|
|
121
|
+
}
|
|
95
122
|
});
|
|
96
123
|
const FunctionPlugin = createPlugin({
|
|
97
124
|
tag: "brumate/function",
|
|
@@ -114,7 +141,13 @@ const FunctionPlugin = createPlugin({
|
|
|
114
141
|
node.c,
|
|
115
142
|
node.d
|
|
116
143
|
], ctx)})`,
|
|
117
|
-
deserialize: (node, ctx) => stateValues.f(ctx.deserialize(node.a), ctx.deserialize(node.b), node.c === void 0 ? void 0 : ctx.deserialize(node.c), node.d === void 0 ? void 0 : ctx.deserialize(node.d))
|
|
144
|
+
deserialize: (node, ctx) => stateValues.f(ctx.deserialize(node.a), ctx.deserialize(node.b), node.c === void 0 ? void 0 : ctx.deserialize(node.c), node.d === void 0 ? void 0 : ctx.deserialize(node.d)),
|
|
145
|
+
validate: {
|
|
146
|
+
a: v.string,
|
|
147
|
+
b: scopeId,
|
|
148
|
+
c: isArgs,
|
|
149
|
+
d: v.array(v.string)
|
|
150
|
+
}
|
|
118
151
|
});
|
|
119
152
|
/** A handler that merges the handlers of one event, as the parts that refer to client functions. */
|
|
120
153
|
const MergedPlugin = createPlugin({
|
|
@@ -127,7 +160,8 @@ const MergedPlugin = createPlugin({
|
|
|
127
160
|
return { a: parts };
|
|
128
161
|
}),
|
|
129
162
|
serialize: (node, ctx) => `$b.m(${ctx.serialize(node.a)})`,
|
|
130
|
-
deserialize: (node, ctx) => stateValues.m(ctx.deserialize(node.a))
|
|
163
|
+
deserialize: (node, ctx) => stateValues.m(ctx.deserialize(node.a)),
|
|
164
|
+
validate: { a: isArray }
|
|
131
165
|
});
|
|
132
166
|
/**
|
|
133
167
|
* A value of an attribute that brumate writes, which a live rest prop can hold. The ones that
|
|
@@ -165,7 +199,13 @@ const ChildrenPlugin = createPlugin({
|
|
|
165
199
|
node.c,
|
|
166
200
|
node.d
|
|
167
201
|
], ctx)})`,
|
|
168
|
-
deserialize: (node, ctx) => stateValues.n(ctx.deserialize(node.a), ctx.deserialize(node.b), node.c === void 0 ? void 0 : ctx.deserialize(node.c), node.d === void 0 ? void 0 : ctx.deserialize(node.d))
|
|
202
|
+
deserialize: (node, ctx) => stateValues.n(ctx.deserialize(node.a), ctx.deserialize(node.b), node.c === void 0 ? void 0 : ctx.deserialize(node.c), node.d === void 0 ? void 0 : ctx.deserialize(node.d)),
|
|
203
|
+
validate: {
|
|
204
|
+
a: v.string,
|
|
205
|
+
b: scopeId,
|
|
206
|
+
c: scopeId,
|
|
207
|
+
d: v.number
|
|
208
|
+
}
|
|
169
209
|
});
|
|
170
210
|
/**
|
|
171
211
|
* A memo that failed on the server. The page state holds its error, so a read in the browser
|
|
@@ -196,7 +236,8 @@ const RawPlugin = createPlugin({
|
|
|
196
236
|
test: isRaw,
|
|
197
237
|
parse: parsers((value) => ({ h: rawHTML(value) })),
|
|
198
238
|
serialize: (node, ctx) => `$b.r(${ctx.serialize(node.h)})`,
|
|
199
|
-
deserialize: (node, ctx) => stateValues.r(ctx.deserialize(node.h))
|
|
239
|
+
deserialize: (node, ctx) => stateValues.r(ctx.deserialize(node.h)),
|
|
240
|
+
validate: { h: v.string }
|
|
200
241
|
});
|
|
201
242
|
/** A component in the page state, such as the value of a dynamic tag. See `stateValues.c`. */
|
|
202
243
|
const ComponentPlugin = createPlugin({
|
|
@@ -205,7 +246,8 @@ const ComponentPlugin = createPlugin({
|
|
|
205
246
|
test: (value) => typeof value === "function" && typeof value.brumateId === "string",
|
|
206
247
|
parse: parsers((value) => ({ c: value.brumateId })),
|
|
207
248
|
serialize: (node, ctx) => `$b.c(${ctx.serialize(node.c)})`,
|
|
208
|
-
deserialize: (node, ctx) => stateValues.c(ctx.deserialize(node.c))
|
|
249
|
+
deserialize: (node, ctx) => stateValues.c(ctx.deserialize(node.c)),
|
|
250
|
+
validate: { c: v.string }
|
|
209
251
|
});
|
|
210
252
|
/**
|
|
211
253
|
* A store of `brumate/store`: only its value crosses, and where `$toStore` made it, so the
|
|
@@ -230,7 +272,12 @@ const StorePlugin = createPlugin({
|
|
|
230
272
|
node.c,
|
|
231
273
|
node.d
|
|
232
274
|
], ctx)})`,
|
|
233
|
-
deserialize: (node, ctx) => stateValues.s(ctx.deserialize(node.a), node.b === void 0 ? void 0 : ctx.deserialize(node.b), node.c === void 0 ? void 0 : ctx.deserialize(node.c), node.d === void 0 ? void 0 : ctx.deserialize(node.d))
|
|
275
|
+
deserialize: (node, ctx) => stateValues.s(ctx.deserialize(node.a), node.b === void 0 ? void 0 : ctx.deserialize(node.b), node.c === void 0 ? void 0 : ctx.deserialize(node.c), node.d === void 0 ? void 0 : ctx.deserialize(node.d)),
|
|
276
|
+
validate: {
|
|
277
|
+
b: scopeId,
|
|
278
|
+
c: v.number,
|
|
279
|
+
d: v.number
|
|
280
|
+
}
|
|
234
281
|
});
|
|
235
282
|
function isFile(value) {
|
|
236
283
|
const file = value;
|
|
@@ -270,15 +317,19 @@ function uploadPlugin(sent, received) {
|
|
|
270
317
|
if (!(file instanceof Blob)) throw new TypeError("A file of the call is missing");
|
|
271
318
|
if (node.t === void 0) return file;
|
|
272
319
|
const type = ctx.deserialize(node.t);
|
|
273
|
-
if (typeof type !== "string") throw new TypeError("A file of the call is malformed");
|
|
274
320
|
if (node.n === void 0) return new Blob([file], { type });
|
|
275
321
|
const name = ctx.deserialize(node.n);
|
|
276
322
|
const lastModified = node.l === void 0 ? void 0 : ctx.deserialize(node.l);
|
|
277
|
-
if (typeof name !== "string" || typeof lastModified !== "number") throw new TypeError("A file of the call is malformed");
|
|
278
323
|
return new File([file], name, {
|
|
279
324
|
type,
|
|
280
325
|
lastModified
|
|
281
326
|
});
|
|
327
|
+
},
|
|
328
|
+
validate: {
|
|
329
|
+
i: isIndex,
|
|
330
|
+
t: v.string,
|
|
331
|
+
n: v.string,
|
|
332
|
+
l: v.number
|
|
282
333
|
}
|
|
283
334
|
});
|
|
284
335
|
}
|
|
@@ -463,158 +514,6 @@ onSerialOptions((options) => {
|
|
|
463
514
|
if (enabled !== 0) console.warn(`The serial entry turns on ${enabled & Feature.RegExp ? "RegExp" : "ErrorPrototypeStack"}, which brumate turns off: ${enabled & Feature.RegExp ? "a pattern from a client can take the server a long time to match" : "a stack shows the files and code of the server to the browser"}.`);
|
|
464
515
|
});
|
|
465
516
|
//#endregion
|
|
466
|
-
|
|
467
|
-
const HEADER_SIZE = 12;
|
|
468
|
-
const encoder = new TextEncoder();
|
|
469
|
-
const decoder = new TextDecoder();
|
|
470
|
-
/** The content type of a stream of chunks. */
|
|
471
|
-
const STREAM_TYPE = "application/x-brumate-stream";
|
|
472
|
-
/** One chunk: its header and its data, in one array. */
|
|
473
|
-
function chunk(text) {
|
|
474
|
-
const data = encoder.encode(text);
|
|
475
|
-
const result = new Uint8Array(HEADER_SIZE + data.length);
|
|
476
|
-
encoder.encodeInto(`;0x${data.length.toString(16).padStart(8, "0")};`, result);
|
|
477
|
-
result.set(data, HEADER_SIZE);
|
|
478
|
-
return result;
|
|
479
|
-
}
|
|
480
|
-
/** Serializes a value as a stream of chunks. */
|
|
481
|
-
function toChunkStream(value, onCancel) {
|
|
482
|
-
let cancelled = false;
|
|
483
|
-
return new ReadableStream({
|
|
484
|
-
start(controller) {
|
|
485
|
-
toCrossJSONStream(value, {
|
|
486
|
-
refs: /* @__PURE__ */ new Map(),
|
|
487
|
-
plugins,
|
|
488
|
-
...serialOptions(),
|
|
489
|
-
onParse(node) {
|
|
490
|
-
if (!cancelled) controller.enqueue(chunk(JSON.stringify(node)));
|
|
491
|
-
},
|
|
492
|
-
onDone() {
|
|
493
|
-
if (!cancelled) controller.close();
|
|
494
|
-
},
|
|
495
|
-
onError(error) {
|
|
496
|
-
if (!cancelled) controller.error(error);
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
},
|
|
500
|
-
cancel(reason) {
|
|
501
|
-
cancelled = true;
|
|
502
|
-
onCancel?.(reason);
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
/** Reads chunks of a stream, buffering only the bytes of the chunk it waits for. */
|
|
507
|
-
var ChunkReader = class {
|
|
508
|
-
reader;
|
|
509
|
-
pieces = [];
|
|
510
|
-
length = 0;
|
|
511
|
-
done = false;
|
|
512
|
-
constructor(stream) {
|
|
513
|
-
this.reader = stream.getReader();
|
|
514
|
-
}
|
|
515
|
-
async fill(size) {
|
|
516
|
-
while (this.length < size && !this.done) {
|
|
517
|
-
const piece = await this.reader.read();
|
|
518
|
-
if (piece.done) this.done = true;
|
|
519
|
-
else {
|
|
520
|
-
this.pieces.push(piece.value);
|
|
521
|
-
this.length += piece.value.length;
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
take(size) {
|
|
526
|
-
const result = new Uint8Array(size);
|
|
527
|
-
let offset = 0;
|
|
528
|
-
while (offset < size) {
|
|
529
|
-
const piece = this.pieces[0];
|
|
530
|
-
const count = Math.min(piece.length, size - offset);
|
|
531
|
-
result.set(piece.subarray(0, count), offset);
|
|
532
|
-
offset += count;
|
|
533
|
-
if (count === piece.length) this.pieces.shift();
|
|
534
|
-
else this.pieces[0] = piece.subarray(count);
|
|
535
|
-
}
|
|
536
|
-
this.length -= size;
|
|
537
|
-
return result;
|
|
538
|
-
}
|
|
539
|
-
/** The data of the next chunk, or undefined at the end of the stream. */
|
|
540
|
-
async next() {
|
|
541
|
-
await this.fill(HEADER_SIZE);
|
|
542
|
-
if (this.length === 0) return;
|
|
543
|
-
const head = this.length < HEADER_SIZE ? "" : decoder.decode(this.take(HEADER_SIZE));
|
|
544
|
-
const match = /^;0x([0-9a-f]{8});$/.exec(head);
|
|
545
|
-
if (!match) throw new Error("The answer of a server function is not a stream of chunks");
|
|
546
|
-
const size = Number.parseInt(match[1], 16);
|
|
547
|
-
await this.fill(size);
|
|
548
|
-
if (this.length < size) throw new Error("The answer of a server function ended in the middle of a chunk");
|
|
549
|
-
return decoder.decode(this.take(size));
|
|
550
|
-
}
|
|
551
|
-
cancel(reason) {
|
|
552
|
-
this.done = true;
|
|
553
|
-
this.reader.cancel(reason).catch(() => {});
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
function ignore() {}
|
|
557
|
-
/**
|
|
558
|
-
* The refs of a stream. A promise in the answer can fail with nothing that
|
|
559
|
-
* reads it, such as a field the caller ignores, so its failure is claimed
|
|
560
|
-
* here. Code that awaits it still sees the failure.
|
|
561
|
-
*/
|
|
562
|
-
var Refs = class extends Map {
|
|
563
|
-
set(id, value) {
|
|
564
|
-
if (value instanceof Promise) value.catch(ignore);
|
|
565
|
-
return super.set(id, value);
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
/**
|
|
569
|
-
* Fails the promises and async iterables that still wait for a chunk, when
|
|
570
|
-
* the stream ends early. Failing a settled one does nothing.
|
|
571
|
-
*/
|
|
572
|
-
function failPending(refs, error) {
|
|
573
|
-
for (const value of refs.values()) try {
|
|
574
|
-
if (value instanceof Stream) value.throw(error);
|
|
575
|
-
else if (value !== null && typeof value === "object") {
|
|
576
|
-
const resolver = value;
|
|
577
|
-
if (resolver.p instanceof Promise && typeof resolver.f === "function") {
|
|
578
|
-
resolver.p.catch(ignore);
|
|
579
|
-
resolver.f(error);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
} catch {}
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* Reads the first chunk of a stream as the value, and the rest in the
|
|
586
|
-
* background, so the promises and async iterables in it settle as their
|
|
587
|
-
* chunks arrive.
|
|
588
|
-
*/
|
|
589
|
-
async function fromChunkStream(stream) {
|
|
590
|
-
const reader = new ChunkReader(stream);
|
|
591
|
-
const refs = new Refs();
|
|
592
|
-
function read(data) {
|
|
593
|
-
return fromCrossJSON(JSON.parse(data), {
|
|
594
|
-
refs,
|
|
595
|
-
plugins,
|
|
596
|
-
...serialOptions()
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
const first = await reader.next();
|
|
600
|
-
if (first === void 0) throw new Error("The answer of a server function is empty");
|
|
601
|
-
const value = read(first);
|
|
602
|
-
(async () => {
|
|
603
|
-
try {
|
|
604
|
-
for (;;) {
|
|
605
|
-
const data = await reader.next();
|
|
606
|
-
if (data === void 0) break;
|
|
607
|
-
read(data);
|
|
608
|
-
}
|
|
609
|
-
failPending(refs, /* @__PURE__ */ new Error("The answer of a server function ended early"));
|
|
610
|
-
} catch (error) {
|
|
611
|
-
reader.cancel(error);
|
|
612
|
-
failPending(refs, error);
|
|
613
|
-
}
|
|
614
|
-
})();
|
|
615
|
-
return value;
|
|
616
|
-
}
|
|
617
|
-
//#endregion
|
|
618
|
-
export { callPlugins as a, syncPlugins as c, BridgeDataError as i, functionReferences as l, fromChunkStream as n, plugins as o, toChunkStream as r, serialOptions as s, STREAM_TYPE as t };
|
|
517
|
+
export { serialOptions as a, functionReferences as c, plugins as i, callPlugins as n, syncPlugins as o, disabledFeatures as r, uploadPlugin as s, BridgeDataError as t };
|
|
619
518
|
|
|
620
|
-
//# sourceMappingURL=
|
|
519
|
+
//# sourceMappingURL=serial-ioa17MuY.js.map
|