brumate 0.7.2 → 0.8.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-CMy0f_iC.d.ts → boot-BkUdiYOF.d.ts} +2 -2
- package/dist/cli.js +3 -2
- package/dist/cli.js.map +1 -1
- package/dist/{client-COm1iA6w.js → client-B0FXW5Kw.js} +48 -14
- package/dist/client-B0FXW5Kw.js.map +1 -0
- package/dist/{client-DnFF9_lv.d.ts → client-Cq6aTiDs.d.ts} +15 -7
- package/dist/{defer-Cesb-k2Q.js → defer-BMIMP4Hq.js} +2 -2
- package/dist/{defer-Cesb-k2Q.js.map → defer-BMIMP4Hq.js.map} +1 -1
- package/dist/{devtools-C9IEkgc1.js → devtools-B4prrxht.js} +257 -118
- package/dist/devtools-B4prrxht.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-B1nF1KB7.js +3978 -0
- package/dist/devtools-panel-B1nF1KB7.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-D5GtxwEQ.js} +2 -2
- package/dist/{files-BuQvpBwF.js.map → files-D5GtxwEQ.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-CGl5Y8q6.js} +581 -399
- package/dist/inspect-CGl5Y8q6.js.map +1 -0
- package/dist/{loader-CLKrJMqw.js → loader-BsaSuIoG.js} +4 -4
- package/dist/{loader-CLKrJMqw.js.map → loader-BsaSuIoG.js.map} +1 -1
- package/dist/{navigate-OHb0Uw1P.js → navigate-BlowKvhB.js} +13 -6
- package/dist/navigate-BlowKvhB.js.map +1 -0
- package/dist/{rpc-BAKbRWOT.js → rpc-C1jYVNAe.js} +5 -4
- package/dist/rpc-C1jYVNAe.js.map +1 -0
- package/dist/runtime/bundles.d.ts +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-C_en-4v8.js} +2 -2
- package/dist/{static-loader-CxANokZ4.js.map → static-loader-C_en-4v8.js.map} +1 -1
- package/dist/{static-loader-BYbXVJDY.d.ts → static-loader-UKnK11Em.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
|
@@ -2,13 +2,18 @@ import { n as closesParagraph, r as firstTag } from "./nesting-DA5vJw9X.js";
|
|
|
2
2
|
import { n as MODIFIERS } from "./events-LgLdp1R7.js";
|
|
3
3
|
import { C as spread$1, S as rawHTML, a as attribute$1, b as ownValue, d as escapeAttribute, f as handlerEntry, g as isRaw, n as VOID_ELEMENTS, p as insertValue, r as actionAttributes, s as bindEntry, u as escape, v as onAttribute, w as styleElement } from "./html-Cf5uKhLs.js";
|
|
4
4
|
import { n as deleteCookie, o as setCookie, r as getCookies } from "./cookies-Cnbf4w-S.js";
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { a as serialOptions, c as functionReferences, i as plugins, n as callPlugins, o as syncPlugins, t as BridgeDataError } from "./serial-ioa17MuY.js";
|
|
6
|
+
import { d as isStore, h as sentForeignStore, n as Store, o as findStored, u as isForeignStore } from "./store-Cy4EEyZ7.js";
|
|
7
|
+
import { a as FunctionReference, c as PropPromise, d as addEntryHandlers, g as isSlotReference, i as ElementReference, m as isBinding, n as CHILDREN_REF, o as MemoError, p as isAsyncIterable, r as ChildrenReference, s as PARTS, t as Binding, u as SlotReference, x as parseId } from "./shared-CX_YacDm.js";
|
|
8
8
|
import { n as serverSecrets } from "./secrets-BxagsJxJ.js";
|
|
9
|
+
import { t as ANSWER } from "./stream-read-BTsYstJY.js";
|
|
10
|
+
import "./search-params-Wg-0FsMj.js";
|
|
9
11
|
import { i as missingContext } from "./context-CU4Fpn5a.js";
|
|
10
12
|
import { a as applyIntent, d as formatPath, f as getAt, m as groupIssues, r as INTENT, u as formValues, v as parseIntent, y as parsePath } from "./forms-nXK7-Lv_.js";
|
|
11
|
-
import {
|
|
13
|
+
import { SerovalDeserializationError, SerovalMissingPluginError, SerovalPluginValidationError, fromJSON } from "seroval/read";
|
|
14
|
+
import { crossSerialize, crossSerializeStream, toJSON } from "seroval/write";
|
|
15
|
+
import { toWebStream } from "@seroval/transport/web";
|
|
16
|
+
import { createJSONWriter } from "@seroval/transport/write";
|
|
12
17
|
//#region src/runtime/request.ts
|
|
13
18
|
/** Where the server takes the error of a `waitUntil` promise that no host keeps, in place of the log. */
|
|
14
19
|
const failures = {};
|
|
@@ -75,6 +80,11 @@ var RequestEvent = class {
|
|
|
75
80
|
/** True while the build prerenders the page. */
|
|
76
81
|
prerender;
|
|
77
82
|
/**
|
|
83
|
+
* The Content Security Policy nonce of the render, from its `nonce` option. Undefined without
|
|
84
|
+
* one. A component that writes an inline script with `raw()` gives it this nonce.
|
|
85
|
+
*/
|
|
86
|
+
nonce;
|
|
87
|
+
/**
|
|
78
88
|
* The pattern of the route files that matched the path, such as
|
|
79
89
|
* `/todos/[id]`. `handleRoute` sets it. Undefined for a path that no route
|
|
80
90
|
* matches.
|
|
@@ -285,6 +295,7 @@ const IDEMPOTENT = Symbol.for("brumate.idempotent");
|
|
|
285
295
|
const idempotentIds = /* @__PURE__ */ new Set();
|
|
286
296
|
/** The ID of each function that `idempotent` made, once the server registered it. */
|
|
287
297
|
const idempotentId = /* @__PURE__ */ new WeakMap();
|
|
298
|
+
const CALL_HOOK = Symbol.for("brumate.callHook");
|
|
288
299
|
function dedupe(fn, id) {
|
|
289
300
|
if (IDEMPOTENT in fn) {
|
|
290
301
|
idempotentIds.add(id);
|
|
@@ -292,7 +303,10 @@ function dedupe(fn, id) {
|
|
|
292
303
|
}
|
|
293
304
|
const wrapper = ((...args) => {
|
|
294
305
|
const cache = currentCalls;
|
|
295
|
-
if (!cache)
|
|
306
|
+
if (!cache) {
|
|
307
|
+
const hook = globalThis[CALL_HOOK];
|
|
308
|
+
return hook ? hook(id, () => fn(...args)) : fn(...args);
|
|
309
|
+
}
|
|
296
310
|
let key;
|
|
297
311
|
try {
|
|
298
312
|
key = `${id} ${JSON.stringify(toJSON(args, {
|
|
@@ -503,6 +517,30 @@ async function revalidate(...tags) {
|
|
|
503
517
|
await Promise.all(writes);
|
|
504
518
|
}
|
|
505
519
|
//#endregion
|
|
520
|
+
//#region src/runtime/stream.ts
|
|
521
|
+
/** The content type of a stream of messages. */
|
|
522
|
+
const STREAM_TYPE = "application/x-brumate-stream";
|
|
523
|
+
/**
|
|
524
|
+
* Serializes a value as a byte stream. `onError` gets the error of a value that cannot be
|
|
525
|
+
* serialized, which the reader only sees as a failed answer.
|
|
526
|
+
*/
|
|
527
|
+
function toChunkStream(value, onCancel, onError) {
|
|
528
|
+
return toWebStream((sink) => {
|
|
529
|
+
const writer = createJSONWriter({
|
|
530
|
+
...sink,
|
|
531
|
+
onError,
|
|
532
|
+
plugins,
|
|
533
|
+
...serialOptions()
|
|
534
|
+
});
|
|
535
|
+
writer.write(ANSWER, value);
|
|
536
|
+
writer.flush();
|
|
537
|
+
return { close(reason) {
|
|
538
|
+
onCancel?.(reason);
|
|
539
|
+
writer.close(reason);
|
|
540
|
+
} };
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
//#endregion
|
|
506
544
|
//#region src/runtime/router.ts
|
|
507
545
|
function key(path, file, params) {
|
|
508
546
|
return `${path}/${file} ${JSON.stringify(params)}`;
|
|
@@ -2945,6 +2983,7 @@ async function render(Root, props, options = {}) {
|
|
|
2945
2983
|
prerender: options.prerender,
|
|
2946
2984
|
onError: options.onError
|
|
2947
2985
|
}) : void 0);
|
|
2986
|
+
if (event && options.nonce !== void 0) event.nonce = options.nonce;
|
|
2948
2987
|
ctx.event = event;
|
|
2949
2988
|
ctx.errors = event ? event.errors : errorSink(options.onError);
|
|
2950
2989
|
const rendered = await ctx.run(() => Root(props, ctx));
|
|
@@ -3510,15 +3549,20 @@ async function handleForm(invoke, event) {
|
|
|
3510
3549
|
* `file<index>`, whose index stands in the JSON.
|
|
3511
3550
|
*/
|
|
3512
3551
|
async function readArgs(request) {
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3552
|
+
try {
|
|
3553
|
+
if (!request.headers.has("x-brumate-args")) return fromJSON(await request.json(), {
|
|
3554
|
+
plugins,
|
|
3555
|
+
...serialOptions()
|
|
3556
|
+
});
|
|
3557
|
+
const form = await request.formData();
|
|
3558
|
+
return fromJSON(JSON.parse(String(form.get("args"))), {
|
|
3559
|
+
plugins: callPlugins(void 0, form),
|
|
3560
|
+
...serialOptions()
|
|
3561
|
+
});
|
|
3562
|
+
} catch (error) {
|
|
3563
|
+
if (error instanceof SerovalDeserializationError && (error.cause instanceof SerovalPluginValidationError || error.cause instanceof SerovalMissingPluginError)) throw new ServerError(`The arguments of the call are malformed: ${error.cause.message}`, { status: 400 });
|
|
3564
|
+
throw error;
|
|
3565
|
+
}
|
|
3522
3566
|
}
|
|
3523
3567
|
/**
|
|
3524
3568
|
* True when a request comes from a page of another site. Server function
|
|
@@ -3613,7 +3657,7 @@ async function answerCall(functions, event, run) {
|
|
|
3613
3657
|
if (ids.length > 0) headers.set("x-brumate-refresh", ids.join(","));
|
|
3614
3658
|
}
|
|
3615
3659
|
headers.set("content-type", STREAM_TYPE);
|
|
3616
|
-
return respond(toChunkStream(result, (reason) => event.abort(reason)), { headers });
|
|
3660
|
+
return respond(toChunkStream(result, (reason) => event.abort(reason), (error) => logError(error, "call", event.errors, event)), { headers });
|
|
3617
3661
|
} catch (error) {
|
|
3618
3662
|
return callFailure(error, headers, event);
|
|
3619
3663
|
}
|
|
@@ -3958,6 +4002,7 @@ async function handleRoute(tree, request, options = {}) {
|
|
|
3958
4002
|
prerender: options.prerender,
|
|
3959
4003
|
onError: options.onError
|
|
3960
4004
|
});
|
|
4005
|
+
if (options.nonce !== void 0) event.nonce = options.nonce;
|
|
3961
4006
|
event.route = match?.route;
|
|
3962
4007
|
const answer = await routeAnswer(tree, match, url, {
|
|
3963
4008
|
...options,
|
|
@@ -4158,4 +4203,4 @@ function spread(attributes, on, names) {
|
|
|
4158
4203
|
//#endregion
|
|
4159
4204
|
export { dedupe as $, streamParts as A, ValidationError as B, setClientBundles as C, start as D, spread as E, RateLimitError as F, matchRoute as G, parse as H, clientAddress as I, revalidate as J, cached as K, configureRateLimit as L, wait as M, waitAll as N, stateScript as O, idempotent as P, ServerError as Q, rateLimit as R, renderToStream as S, spacerTag as T, parseForm as U, fieldErrors as V, safeParse as W, storageStore as X, setCacheStore as Y, RequestEvent as Z, memo as _, attribute as a, ready as b, children as c, handleRequest as d, defineMiddleware as et, handleRoute as f, lazy as g, isCrossSite as h, actionResult as i, withEvent as it, streamState as j, stateValue as k, component as l, insert as m, NotReady as n, isRedirect as nt, binding as o, inlineBodies as p, memoryStore as q, action as r, redirect as rt, caught as s, Context as t, getEvent as tt, dynamic as u, packState as v, settled as w, render as x, read as y, parseSubmission as z };
|
|
4160
4205
|
|
|
4161
|
-
//# sourceMappingURL=server-
|
|
4206
|
+
//# sourceMappingURL=server-BUuf7XPZ.js.map
|