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,5 @@
|
|
|
1
1
|
import { r as SerialEntry } from "./values-B8C7CLvG.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Wt as ClientModule } from "./client-C4kNKGwH.js";
|
|
3
3
|
//#region src/runtime/boot.d.ts
|
|
4
4
|
interface LoaderOptions {
|
|
5
5
|
/**
|
|
@@ -51,4 +51,4 @@ interface NavigateOptions {
|
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
|
53
53
|
export { NavigateOptions as n, LoaderOptions as t };
|
|
54
|
-
//# sourceMappingURL=boot-
|
|
54
|
+
//# sourceMappingURL=boot-CMvhoWRu.d.ts.map
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { B as getLocation, H as findError, j as analyzeProjectProps, o as CompileError, r as inspect, s as compile, w as resolveFromDisk, z as BrumateError } from "./inspect-
|
|
3
|
-
import { h as findPackages, o as findPackageServerFile, s as findServerImport, t as collectSources, v as resolveComponentPackage } from "./files-
|
|
2
|
+
import { B as getLocation, H as findError, j as analyzeProjectProps, o as CompileError, r as inspect, s as compile, w as resolveFromDisk, z as BrumateError } from "./inspect-ddfGeww0.js";
|
|
3
|
+
import { h as findPackages, o as findPackageServerFile, s as findServerImport, t as collectSources, v as resolveComponentPackage } from "./files-CR-V05xd.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
6
|
import { cp } from "node:fs/promises";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { t as Context } from "./context-btHuB01Z.js";
|
|
2
2
|
import { a as PageState, c as ScopeId, n as ElementReference, p as Raw, t as Binding } from "./shared-CzbnWkVA.js";
|
|
3
3
|
import { r as SerialEntry } from "./values-B8C7CLvG.js";
|
|
4
|
+
import { k as SearchParamOptions } from "./signals-BwD4u22K.js";
|
|
4
5
|
//#region src/runtime/navigate.d.ts
|
|
5
6
|
/** What the devtools learn of a navigation. See `DevtoolsHooks.navigated`. */
|
|
6
7
|
interface NavigationReport {
|
|
@@ -606,12 +607,14 @@ interface Template {
|
|
|
606
607
|
count: number;
|
|
607
608
|
/** `svg` or `math`, for markup whose elements are of SVG or MathML, which parses inside one. */
|
|
608
609
|
foreign?: string;
|
|
610
|
+
/** Its clones hold markers or `<template>` elements, which their insert indexes and starts. */
|
|
611
|
+
m?: 1;
|
|
609
612
|
t?: HTMLTemplateElement;
|
|
610
613
|
/** The moves that reach the marked nodes of a clone. See `encodeWalk`. */
|
|
611
614
|
walk?: number[];
|
|
612
615
|
}
|
|
613
616
|
/** A template of the markup of a render, which `clone` parses once. */
|
|
614
|
-
declare function template(html: string, count: number, foreign?: string): Template;
|
|
617
|
+
declare function template(html: string, count: number, foreign?: string, indexed?: 1): Template;
|
|
615
618
|
/**
|
|
616
619
|
* A node of a clone: an element, the comment of an insert, or the fragment. The type lets the
|
|
617
620
|
* render pass each to the write that takes it.
|
|
@@ -670,6 +673,15 @@ declare function setOn(element: Element, on: string[], own: string): void;
|
|
|
670
673
|
/** Writes the content of an element of cloned markup, as `insert` writes it in HTML. */
|
|
671
674
|
declare function setContent(element: Element, value: unknown, at?: ScopeId | Scope): void;
|
|
672
675
|
//#endregion
|
|
676
|
+
//#region src/runtime/client/search.d.ts
|
|
677
|
+
/** `$searchParam` in the browser: the parameter of the URL of the page. */
|
|
678
|
+
declare function searchParam(name: string, options?: SearchParamOptions<unknown>): unknown;
|
|
679
|
+
/**
|
|
680
|
+
* The effect of `$searchParam`: it writes the URL when the signal changes, and follows the
|
|
681
|
+
* history while the scope lives.
|
|
682
|
+
*/
|
|
683
|
+
declare function paramEffect(scope: Scope, slot: number, name: string, options?: SearchParamOptions<unknown>): () => () => void;
|
|
684
|
+
//#endregion
|
|
673
685
|
//#region src/runtime/client/titles.d.ts
|
|
674
686
|
/** Sets the title of the page. */
|
|
675
687
|
declare function title(value: unknown): void;
|
|
@@ -705,8 +717,9 @@ declare function cells(scope: Scope, links: unknown[], names: string[]): Record<
|
|
|
705
717
|
*/
|
|
706
718
|
declare function timed(scope: Scope, slot: number, ms: number, throttle: boolean, compute: () => unknown): void;
|
|
707
719
|
/**
|
|
708
|
-
* Reports the rejection of a memo that the browser renders and
|
|
709
|
-
* The error reaches the nearest `#try` around
|
|
720
|
+
* Reports the rejection of a memo that the browser renders and that only an `await` reads, so it
|
|
721
|
+
* has no slot. The server throws the error at the `await`. It reaches the nearest `#try` around
|
|
722
|
+
* the scope, or `onError`. A memo that nothing reads is not declared at all.
|
|
710
723
|
*/
|
|
711
724
|
declare function unreadMemo(scope: Scope | ScopeId, value: unknown): void;
|
|
712
725
|
/**
|
|
@@ -762,5 +775,5 @@ declare const loader: {
|
|
|
762
775
|
updateRoute: typeof updateRoute;
|
|
763
776
|
};
|
|
764
777
|
//#endregion
|
|
765
|
-
export {
|
|
766
|
-
//# sourceMappingURL=client-
|
|
778
|
+
export { toList as $, skew as $t, putText as A, leaveRoutes as At, getScope as B, provideValue as Bt, fillBranch as C, fail as Ct, listNodes as D, forget as Dt, keepText as E, dispose as Et, setSpread as F, handlerProp as Ft, prop as G, CoreOptions as Gt, removeScope as H, updateContext as Ht, template as I, rpc as It, addPortal as J, Scope as Jt, spreadProps as K, DEVTOOLS as Kt, afterInsert as L, spread as Lt, setAttrText as M, removeRoot as Mt, setContent as N, action as Nt, markBlock as O, init as Ot, setOn as P, handle as Pt, list as Q, scopes as Qt, createScope as R, submitAction as Rt, clone as S, wait as St, keep as T, nameComment as Tt, setOwner as U, updateRoute as Ut, makeId as V, setGlobal as Vt, sink as W, ClientModule as Wt, deferInBrowser as X, hooks as Xt, addStyle as Y, build as Yt, setVar as Z, rpcPrefix as Zt, title as _, rekey as _n, fillValue as _t, cells as a, elementAt as an, portalTo as at, appendText as b, NavigationReport as bn, reveal as bt, isBound as c, setItem as cn, writeText as ct, resolve as d, insert as dn, after as dt, Component as en, windowList as et, set as f, HiddenBody as fn, attempt as ft, updated as g, offscreen as gn, fillSpread as gt, update as h, held as hn, fillSettled as ht, bindings as i, dynamicNodes as in, content as it, setAttr as j, remount as jt, nodes as k, leavePage as kt, memo as l, setSlots as ln, guess as lt, unreadMemo as m, fill as mn, fillAttrs as mt, asyncMemo as n, componentNodes as nn, attr as nt, effect as o, foreignNodes as on, restRef as ot, timed as p, branch as pn, countLoads as pt, addHead as q, DevtoolsHooks as qt, binding as r, dynamic as rn, attrs as rt, get as s, place as sn, text as st, loader as t, component as tn, windowStart as tt, pending as u, children as un, track as ut, paramEffect as v, reset as vn, keepValue as vt, fillList as w, loadModule as wt, branchNodes as x, started as xt, searchParam as y, retag as yn, loading as yt, descendants as z, consumeContext as zt };
|
|
779
|
+
//# sourceMappingURL=client-C4kNKGwH.d.ts.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { C as spread$1, T as textValue, b as ownValue, f as handlerEntry, g as isRaw, n as VOID_ELEMENTS, o as attributeText, p as insertValue, r as actionAttributes, s as bindEntry, v as onAttribute, y as onValue } from "./html-t1JpkODI.js";
|
|
2
|
-
import { a as HAS_CLIENT_HTML, c as HAS_LATE_MARKUP, d as HAS_ROOT_WAIT, f as HAS_ROUTES, g as
|
|
3
|
-
import { C as useSerialEntry, _ as
|
|
2
|
+
import { _ as HAS_WINDOWS, a as HAS_CLIENT_HTML, c as HAS_LATE_MARKUP, d as HAS_ROOT_WAIT, f as HAS_ROUTES, g as HAS_TRIES, h as HAS_TITLES, i as HAS_CHILDREN, m as HAS_TEMPLATES, n as HAS_BINDINGS, o as HAS_DYNAMIC, s as HAS_FIELDS, u as HAS_LOADING } from "./features-CbgII-o7.js";
|
|
3
|
+
import { C as parseId, E as useSerialEntry, _ as isBinding, a as Binding, b as mergeHandlers, c as ElementReference, d as PARTS, g as isAsyncIterable, h as addEntryHandlers, l as FunctionReference, m as SlotReference, r as writeParam, s as ChildrenReference, t as readParam, u as MemoError, v as isPropWrapper, w as stateValues, y as isSlotReference } from "./search-params-CM1RWR2P.js";
|
|
4
4
|
import { n as ROUTE_KEY } from "./context-CTiSzQRc.js";
|
|
5
5
|
import { n as trustedHTML, t as loadOnce } from "./skew-FRmAy9iy.js";
|
|
6
|
+
import { n as navigate } from "./routes-D21FQyGF.js";
|
|
6
7
|
//#region src/runtime/client/state.ts
|
|
7
8
|
let options;
|
|
8
9
|
/** The URL prefix of server function calls, from the options. */
|
|
@@ -286,14 +287,38 @@ function isTemplate(ref) {
|
|
|
286
287
|
* functions of other components wait for it, so the code that they call has loaded.
|
|
287
288
|
*/
|
|
288
289
|
const loadingCode = /* @__PURE__ */ new Set();
|
|
290
|
+
/** The same loads as `loadingCode`, by the ID of the component. */
|
|
291
|
+
const loadingComponents = /* @__PURE__ */ new Map();
|
|
289
292
|
/** The components whose code loads, or has loaded, with the page. */
|
|
290
293
|
const pageComponents = /* @__PURE__ */ new Set();
|
|
291
294
|
/** Loads the code of a component and all of its parts, as the page reads its scopes. */
|
|
292
295
|
function loadComponent(id) {
|
|
293
296
|
if (options === void 0 || pageComponents.has(id)) return;
|
|
294
297
|
pageComponents.add(id);
|
|
295
|
-
const code = loadModule(id).catch(() => {}).finally(() =>
|
|
298
|
+
const code = loadModule(id).catch(() => {}).finally(() => {
|
|
299
|
+
loadingCode.delete(code);
|
|
300
|
+
loadingComponents.delete(id);
|
|
301
|
+
});
|
|
296
302
|
loadingCode.add(code);
|
|
303
|
+
loadingComponents.set(id, code);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The code that still loads for the components at a scope and above it. An update of the scope
|
|
307
|
+
* renders the templates and calls the function props of those components, never the code of a
|
|
308
|
+
* component below it, so a layout that stays updates while the code of a new page loads.
|
|
309
|
+
*
|
|
310
|
+
* The walk is the one of contexts. Children that a component C inserted go to C through `t`,
|
|
311
|
+
* and C goes to the parent P that wrote the children through `o`, so the code of P, which
|
|
312
|
+
* the templates and function props of the children come from, is on the walk too.
|
|
313
|
+
*/
|
|
314
|
+
function codeAbove(scope) {
|
|
315
|
+
const waits = [];
|
|
316
|
+
if (loadingComponents.size === 0) return waits;
|
|
317
|
+
for (let current = scope; current; current = current.t ?? current.p ?? current.o) {
|
|
318
|
+
const code = current.m === void 0 ? void 0 : loadingComponents.get(current.m);
|
|
319
|
+
if (code) waits.push(code);
|
|
320
|
+
}
|
|
321
|
+
return waits;
|
|
297
322
|
}
|
|
298
323
|
/** Resolves when the code of the components on the page has loaded. */
|
|
299
324
|
function codeReady() {
|
|
@@ -650,7 +675,13 @@ function insertHTML(before, html) {
|
|
|
650
675
|
for (const scope of client) if (scopes.has(scope.id)) live.push(scope);
|
|
651
676
|
if (live.length > 0) refresh(live, true);
|
|
652
677
|
}
|
|
653
|
-
/**
|
|
678
|
+
/**
|
|
679
|
+
* True when a clone holds markup that it rendered as HTML, or markers and `<template>` elements
|
|
680
|
+
* of its own (`clone` of an indexed template), whose markers its insert indexes. The flag is
|
|
681
|
+
* global and the next insert takes it, so an insert that runs between such a clone and its own
|
|
682
|
+
* insert would take it instead and the clone would not be indexed. No render does that today:
|
|
683
|
+
* a render makes its clones and returns them, and the insert comes after all of them.
|
|
684
|
+
*/
|
|
654
685
|
let clonedMarkup = false;
|
|
655
686
|
/** Notes that a clone holds markup that it rendered as HTML. */
|
|
656
687
|
function markCloned() {
|
|
@@ -744,14 +775,14 @@ let inPass = (run) => run();
|
|
|
744
775
|
function setPass(pass) {
|
|
745
776
|
inPass = pass;
|
|
746
777
|
}
|
|
747
|
-
let waiting$
|
|
778
|
+
let waiting$2 = 0;
|
|
748
779
|
/**
|
|
749
780
|
* Calls a function of another component at once, as a pass, when its code has loaded and no call
|
|
750
781
|
* waits before it, so the caller reads what the function wrote. Returns false when it did not
|
|
751
782
|
* call, and `call` is the way then.
|
|
752
783
|
*/
|
|
753
784
|
function callNow(ref, scope, args) {
|
|
754
|
-
const fn = waiting$
|
|
785
|
+
const fn = waiting$2 === 0 && !codeReady() ? loadedFunction(ref) : void 0;
|
|
755
786
|
if (!fn) return false;
|
|
756
787
|
inPass(() => fn(scope, ...args));
|
|
757
788
|
return true;
|
|
@@ -766,9 +797,9 @@ let lastCall = Promise.resolve();
|
|
|
766
797
|
function call(ref, scope, args) {
|
|
767
798
|
const code = codeReady();
|
|
768
799
|
const loaded = code ? Promise.all([resolve$1(ref), code]).then(([fn]) => fn) : resolve$1(ref);
|
|
769
|
-
waiting$
|
|
800
|
+
waiting$2++;
|
|
770
801
|
const started = lastCall.then(() => loaded).finally(() => {
|
|
771
|
-
waiting$
|
|
802
|
+
waiting$2--;
|
|
772
803
|
}).then((fn) => ({ value: inPass(() => fn(scope, ...args)) }));
|
|
773
804
|
lastCall = started.catch(() => {});
|
|
774
805
|
return started.then((result) => result.value);
|
|
@@ -1200,8 +1231,9 @@ function isThenable(value) {
|
|
|
1200
1231
|
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
1201
1232
|
}
|
|
1202
1233
|
/**
|
|
1203
|
-
* Reports the rejection of a memo that the browser renders and
|
|
1204
|
-
* The error reaches the nearest `#try` around
|
|
1234
|
+
* Reports the rejection of a memo that the browser renders and that only an `await` reads, so it
|
|
1235
|
+
* has no slot. The server throws the error at the `await`. It reaches the nearest `#try` around
|
|
1236
|
+
* the scope, or `onError`. A memo that nothing reads is not declared at all.
|
|
1205
1237
|
*/
|
|
1206
1238
|
function unreadMemo(scope, value) {
|
|
1207
1239
|
if (isThenable(value)) {
|
|
@@ -1392,12 +1424,12 @@ function trigger(scope, slot) {
|
|
|
1392
1424
|
for (const check of waiters.keys()) check();
|
|
1393
1425
|
const id = findRoot(scope).m;
|
|
1394
1426
|
const children = childrenReady(scope);
|
|
1395
|
-
if (modules.has(id) &&
|
|
1427
|
+
if (modules.has(id) && codeAbove(scope).length === 0 && !children) {
|
|
1396
1428
|
pass(() => queueWrite(scope, slot));
|
|
1397
1429
|
return;
|
|
1398
1430
|
}
|
|
1399
|
-
if (waiting) {
|
|
1400
|
-
waiting.push([
|
|
1431
|
+
if (waiting$1) {
|
|
1432
|
+
waiting$1.push([
|
|
1401
1433
|
scope,
|
|
1402
1434
|
slot,
|
|
1403
1435
|
loadModule(id).then(() => childrenReady(scope)).catch((error) => fail(scope, error))
|
|
@@ -1407,10 +1439,10 @@ function trigger(scope, slot) {
|
|
|
1407
1439
|
const from = origin;
|
|
1408
1440
|
const via = viaContext;
|
|
1409
1441
|
const list = [[scope, slot]];
|
|
1410
|
-
if (running > 0) waiting = list;
|
|
1442
|
+
if (running > 0) waiting$1 = list;
|
|
1411
1443
|
const loading = loadModule(id).then(async () => {
|
|
1412
|
-
const waits = [
|
|
1413
|
-
for (const [, , load] of list) waits.push(load);
|
|
1444
|
+
const waits = [children];
|
|
1445
|
+
for (const [target, , load] of list) waits.push(...codeAbove(target), load);
|
|
1414
1446
|
await Promise.allSettled(waits);
|
|
1415
1447
|
const before = origin;
|
|
1416
1448
|
const viaBefore = viaContext;
|
|
@@ -1435,7 +1467,7 @@ function trigger(scope, slot) {
|
|
|
1435
1467
|
});
|
|
1436
1468
|
}
|
|
1437
1469
|
/** The writes of the pass that runs that wait for code, to run as one pass of their own. */
|
|
1438
|
-
let waiting;
|
|
1470
|
+
let waiting$1;
|
|
1439
1471
|
/** The updates that wait for their code. */
|
|
1440
1472
|
const loadingUpdates = /* @__PURE__ */ new Set();
|
|
1441
1473
|
/**
|
|
@@ -1476,8 +1508,8 @@ function pass(write) {
|
|
|
1476
1508
|
if (--running === 0) {
|
|
1477
1509
|
for (const level of levels.reverse()) for (const [key, runEffect] of level?.e ?? []) pendingEffects.set(key, runEffect);
|
|
1478
1510
|
levels = [];
|
|
1479
|
-
held = waiting !== void 0;
|
|
1480
|
-
waiting = void 0;
|
|
1511
|
+
held = waiting$1 !== void 0;
|
|
1512
|
+
waiting$1 = void 0;
|
|
1481
1513
|
depths.clear();
|
|
1482
1514
|
failed = false;
|
|
1483
1515
|
stuck = false;
|
|
@@ -1966,12 +1998,12 @@ function action(name, id, method, result) {
|
|
|
1966
1998
|
* call loads, so the core holds only this.
|
|
1967
1999
|
*/
|
|
1968
2000
|
function submitAction(form, submitter) {
|
|
1969
|
-
import("./rpc-
|
|
2001
|
+
import("./rpc-BgYnfg_a.js").then((module) => module.sendAction(form, submitter));
|
|
1970
2002
|
}
|
|
1971
2003
|
/** Calls a server function. */
|
|
1972
2004
|
async function rpc(id, args) {
|
|
1973
2005
|
const signal = memoSignal();
|
|
1974
|
-
return track(import("./rpc-
|
|
2006
|
+
return track(import("./rpc-BgYnfg_a.js").then((module) => module.call(rpcPrefix, id, args, signal)));
|
|
1975
2007
|
}
|
|
1976
2008
|
/** A function prop rendered on the client calls the parent's exported handler. */
|
|
1977
2009
|
function handlerProp(value, ref, scope, bound = [], modifiers) {
|
|
@@ -2312,11 +2344,12 @@ function init(value) {
|
|
|
2312
2344
|
//#endregion
|
|
2313
2345
|
//#region src/runtime/client/templates.ts
|
|
2314
2346
|
/** A template of the markup of a render, which `clone` parses once. */
|
|
2315
|
-
function template(html, count, foreign) {
|
|
2347
|
+
function template(html, count, foreign, indexed) {
|
|
2316
2348
|
return {
|
|
2317
2349
|
html,
|
|
2318
2350
|
count,
|
|
2319
|
-
foreign
|
|
2351
|
+
foreign,
|
|
2352
|
+
m: indexed
|
|
2320
2353
|
};
|
|
2321
2354
|
}
|
|
2322
2355
|
/**
|
|
@@ -2347,7 +2380,7 @@ function parseTemplate(source) {
|
|
|
2347
2380
|
const mark = /^x(\d+)$/.exec(node.data);
|
|
2348
2381
|
if (mark) paths[Number(mark[1])] = findPath(node);
|
|
2349
2382
|
}
|
|
2350
|
-
options?.listen(root);
|
|
2383
|
+
if (!source.m) options?.listen(root);
|
|
2351
2384
|
source.t = element;
|
|
2352
2385
|
return paths;
|
|
2353
2386
|
}
|
|
@@ -2399,6 +2432,7 @@ function encodeWalk(paths) {
|
|
|
2399
2432
|
*/
|
|
2400
2433
|
function clone(source) {
|
|
2401
2434
|
const walk = source.walk ??= encodeWalk(parseTemplate(source));
|
|
2435
|
+
if (source.m) markCloned();
|
|
2402
2436
|
const fragment = source.t.content.cloneNode(true);
|
|
2403
2437
|
const cloned = new Array(source.count + 1);
|
|
2404
2438
|
cloned[source.count] = fragment;
|
|
@@ -2748,8 +2782,16 @@ function portalTo(scope, target, render, kinds = [], holderKind, holderAnchor) {
|
|
|
2748
2782
|
const element = typeof target === "string" ? document.querySelector(target) : target;
|
|
2749
2783
|
if (!(element instanceof Element)) return;
|
|
2750
2784
|
const id = nextId;
|
|
2751
|
-
const
|
|
2752
|
-
|
|
2785
|
+
const out = inPlace(scope, render, holderKind, holderAnchor)(scope);
|
|
2786
|
+
if (typeof out === "string") {
|
|
2787
|
+
insertHTML({ parent: element }, `<!--P${id}-->${out}<!--/P-->`);
|
|
2788
|
+
return;
|
|
2789
|
+
}
|
|
2790
|
+
const start = document.createComment("");
|
|
2791
|
+
nameComment(start, `P${id}`);
|
|
2792
|
+
out.prepend(start);
|
|
2793
|
+
out.append(document.createComment("/P"));
|
|
2794
|
+
insertHTML({ parent: element }, out);
|
|
2753
2795
|
}
|
|
2754
2796
|
/** Writes an inserted value between `<!--t…-->` and `<!--/t-->`. */
|
|
2755
2797
|
function text(scope, anchor, value) {
|
|
@@ -2971,7 +3013,7 @@ function within$1(own, render) {
|
|
|
2971
3013
|
* so the insert of anything else does not take them. `give` puts them back before the body goes
|
|
2972
3014
|
* in, and the caller sets `done`, and `f` if it handles failures, before any wait settles.
|
|
2973
3015
|
*/
|
|
2974
|
-
function bound(body) {
|
|
3016
|
+
function bound$1(body) {
|
|
2975
3017
|
const own = {
|
|
2976
3018
|
n: 0,
|
|
2977
3019
|
c: writes,
|
|
@@ -3010,7 +3052,7 @@ function give(own) {
|
|
|
3010
3052
|
*/
|
|
3011
3053
|
function attempt(body) {
|
|
3012
3054
|
if (!boundary) return toNodes(body());
|
|
3013
|
-
const [out, own] = bound(body);
|
|
3055
|
+
const [out, own] = bound$1(body);
|
|
3014
3056
|
if (own) {
|
|
3015
3057
|
const outer = join();
|
|
3016
3058
|
own.done = () => {
|
|
@@ -3324,7 +3366,7 @@ function hold(at, key, render, show) {
|
|
|
3324
3366
|
return;
|
|
3325
3367
|
}
|
|
3326
3368
|
drop(at);
|
|
3327
|
-
const [out, own] = bound(render);
|
|
3369
|
+
const [out, own] = bound$1(render);
|
|
3328
3370
|
if (!own) {
|
|
3329
3371
|
show(out);
|
|
3330
3372
|
return;
|
|
@@ -3371,7 +3413,7 @@ function release(at) {
|
|
|
3371
3413
|
* not render it again.
|
|
3372
3414
|
*/
|
|
3373
3415
|
function holdRow(list, render) {
|
|
3374
|
-
const [out, own] = bound(render);
|
|
3416
|
+
const [out, own] = bound$1(render);
|
|
3375
3417
|
if (!own) return out;
|
|
3376
3418
|
let row;
|
|
3377
3419
|
for (const scope of own.w[0]) if (scope.p === list) row ??= scope;
|
|
@@ -3477,7 +3519,7 @@ function renderLoading(group, body, fallback) {
|
|
|
3477
3519
|
const made = rendered.length;
|
|
3478
3520
|
const queued = afterInsert.length;
|
|
3479
3521
|
const turn = group && !(group.o === "natural" || group.o === "sequential" && group.m.length === 0);
|
|
3480
|
-
const result = bound(body);
|
|
3522
|
+
const result = bound$1(body);
|
|
3481
3523
|
const nodes = toNodes(result[0]);
|
|
3482
3524
|
let own = result[1];
|
|
3483
3525
|
if (!own) {
|
|
@@ -4171,6 +4213,130 @@ function addStyle(id, css) {
|
|
|
4171
4213
|
return "";
|
|
4172
4214
|
}
|
|
4173
4215
|
//#endregion
|
|
4216
|
+
//#region src/runtime/client/search.ts
|
|
4217
|
+
/** The signals of the page that follow a parameter, by scope and slot. */
|
|
4218
|
+
const bound = /* @__PURE__ */ new Map();
|
|
4219
|
+
/** The changes of the URL that wait for the end of the writes of one pass. */
|
|
4220
|
+
const waiting = /* @__PURE__ */ new Map();
|
|
4221
|
+
/** `$searchParam` in the browser: the parameter of the URL of the page. */
|
|
4222
|
+
function searchParam(name, options) {
|
|
4223
|
+
return readParam(new URLSearchParams(location.search), name, options);
|
|
4224
|
+
}
|
|
4225
|
+
/**
|
|
4226
|
+
* The effect of `$searchParam`: it writes the URL when the signal changes, and follows the
|
|
4227
|
+
* history while the scope lives.
|
|
4228
|
+
*/
|
|
4229
|
+
function paramEffect(scope, slot, name, options) {
|
|
4230
|
+
return () => {
|
|
4231
|
+
const key = `${scope.id}:${slot}`;
|
|
4232
|
+
if (!options?.server) {
|
|
4233
|
+
bound.set(key, {
|
|
4234
|
+
scope,
|
|
4235
|
+
slot,
|
|
4236
|
+
name,
|
|
4237
|
+
options
|
|
4238
|
+
});
|
|
4239
|
+
globalThis[HOOK] = follow;
|
|
4240
|
+
}
|
|
4241
|
+
const text = writeParam(get(scope, slot), options);
|
|
4242
|
+
const current = readParam(new URLSearchParams(location.search), name, options);
|
|
4243
|
+
if (writeParam(current, options) !== text) {
|
|
4244
|
+
if (waiting.size === 0) queueMicrotask(commit);
|
|
4245
|
+
waiting.set(name, {
|
|
4246
|
+
text,
|
|
4247
|
+
options
|
|
4248
|
+
});
|
|
4249
|
+
}
|
|
4250
|
+
return () => void bound.delete(key);
|
|
4251
|
+
};
|
|
4252
|
+
}
|
|
4253
|
+
/** The key of the hook with which the loader asks whether a change of the URL is ours. */
|
|
4254
|
+
const HOOK = Symbol.for("brumate.search");
|
|
4255
|
+
/** Writes the changes of one pass to the URL, as one entry of the history. */
|
|
4256
|
+
function commit() {
|
|
4257
|
+
const url = new URL(location.href);
|
|
4258
|
+
let push = false;
|
|
4259
|
+
let server = false;
|
|
4260
|
+
const changes = /* @__PURE__ */ new Map();
|
|
4261
|
+
for (const [name, { text, options }] of waiting) {
|
|
4262
|
+
changes.set(name, text);
|
|
4263
|
+
push ||= options?.history === "push";
|
|
4264
|
+
server ||= options?.server === true;
|
|
4265
|
+
}
|
|
4266
|
+
const names = new Set(waiting.keys());
|
|
4267
|
+
waiting.clear();
|
|
4268
|
+
url.search = editQuery(url.search, changes);
|
|
4269
|
+
if (server) {
|
|
4270
|
+
navigate(url.href, {
|
|
4271
|
+
replace: !push,
|
|
4272
|
+
scroll: false
|
|
4273
|
+
});
|
|
4274
|
+
return;
|
|
4275
|
+
}
|
|
4276
|
+
if (push) history.pushState({}, "", url);
|
|
4277
|
+
else history.replaceState(history.state, "", url);
|
|
4278
|
+
pass(() => {
|
|
4279
|
+
for (const { scope, slot, name, options } of bound.values()) if (names.has(name)) set(scope, slot, readParam(url.searchParams, name, options));
|
|
4280
|
+
});
|
|
4281
|
+
document.dispatchEvent(new Event("brumate:search"));
|
|
4282
|
+
updateRoute();
|
|
4283
|
+
}
|
|
4284
|
+
/** The names of the parameters in a query string, as the URL reads them. */
|
|
4285
|
+
function queryName(piece) {
|
|
4286
|
+
return new URLSearchParams(piece).keys().next().value ?? "";
|
|
4287
|
+
}
|
|
4288
|
+
/**
|
|
4289
|
+
* The query string with the changes made, and every other parameter as it was written. The
|
|
4290
|
+
* first piece of a changed name takes the new text, and its other pieces go.
|
|
4291
|
+
*/
|
|
4292
|
+
function editQuery(search, changes) {
|
|
4293
|
+
const pieces = [];
|
|
4294
|
+
const done = /* @__PURE__ */ new Set();
|
|
4295
|
+
for (const piece of search.slice(1).split("&")) {
|
|
4296
|
+
const name = piece === "" ? "" : queryName(piece);
|
|
4297
|
+
if (!changes.has(name)) {
|
|
4298
|
+
if (piece !== "") pieces.push(piece);
|
|
4299
|
+
continue;
|
|
4300
|
+
}
|
|
4301
|
+
const text = changes.get(name);
|
|
4302
|
+
if (text !== null && !done.has(name)) pieces.push(new URLSearchParams({ [name]: text }).toString());
|
|
4303
|
+
done.add(name);
|
|
4304
|
+
}
|
|
4305
|
+
for (const [name, text] of changes) if (text !== null && !done.has(name)) pieces.push(new URLSearchParams({ [name]: text }).toString());
|
|
4306
|
+
return pieces.length > 0 ? `?${pieces.join("&")}` : "";
|
|
4307
|
+
}
|
|
4308
|
+
/**
|
|
4309
|
+
* Writes the signals whose parameter changed, from `from` to the URL now. False when another
|
|
4310
|
+
* parameter changed, or the path did: the page loads then.
|
|
4311
|
+
*/
|
|
4312
|
+
function follow(from) {
|
|
4313
|
+
const before = new URL(from);
|
|
4314
|
+
const now = new URL(location.href);
|
|
4315
|
+
if (before.pathname !== now.pathname) return false;
|
|
4316
|
+
const names = /* @__PURE__ */ new Set([...before.searchParams.keys(), ...now.searchParams.keys()]);
|
|
4317
|
+
const changed = [];
|
|
4318
|
+
for (const name of names) {
|
|
4319
|
+
if (same(before.searchParams.getAll(name), now.searchParams.getAll(name))) continue;
|
|
4320
|
+
let owned = false;
|
|
4321
|
+
for (const item of bound.values()) if (item.name === name) {
|
|
4322
|
+
changed.push(item);
|
|
4323
|
+
owned = true;
|
|
4324
|
+
}
|
|
4325
|
+
if (!owned) return false;
|
|
4326
|
+
}
|
|
4327
|
+
pass(() => {
|
|
4328
|
+
for (const { scope, slot, name, options } of changed) set(scope, slot, readParam(now.searchParams, name, options));
|
|
4329
|
+
});
|
|
4330
|
+
updateRoute();
|
|
4331
|
+
return true;
|
|
4332
|
+
}
|
|
4333
|
+
/** True for two lists of texts that are equal item by item. */
|
|
4334
|
+
function same(a, b) {
|
|
4335
|
+
if (a.length !== b.length) return false;
|
|
4336
|
+
for (let index = 0; index < a.length; index++) if (a[index] !== b[index]) return false;
|
|
4337
|
+
return true;
|
|
4338
|
+
}
|
|
4339
|
+
//#endregion
|
|
4174
4340
|
//#region src/runtime/client.ts
|
|
4175
4341
|
/**
|
|
4176
4342
|
* What the loader calls. It is one export, so the loader's import of the core
|
|
@@ -4186,6 +4352,6 @@ const loader = {
|
|
|
4186
4352
|
};
|
|
4187
4353
|
function noop() {}
|
|
4188
4354
|
//#endregion
|
|
4189
|
-
export {
|
|
4355
|
+
export { fillBranch as $, createScope as $t, started as A, setGlobal as At, spreadProps as B, memo as Bt, fillAttrs as C, rpc as Ct, keepValue as D, track as Dt, fillValue as E, guess as Et, portalTo as F, bindings as Ft, elementAt as G, unreadMemo as Gt, componentNodes as H, resolve as Ht, restRef as I, cells as It, setItem as J, fail as Jt, foreignNodes as K, update as Kt, text as L, effect as Lt, attr as M, updateRoute as Mt, attrs as N, asyncMemo as Nt, loading as O, consumeContext as Ot, content as P, binding as Pt, clone as Q, afterInsert as Qt, writeText as R, get as Rt, countLoads as S, handlerProp as St, fillSpread as T, submitAction as Tt, dynamic as U, set as Ut, component as V, pending as Vt, dynamicNodes as W, timed as Wt, appendText as X, insert as Xt, setSlots as Y, children as Yt, branchNodes as Z, title as Zt, rekey as _, leaveRoutes as _t, addPortal as a, sink as an, nodes as at, after as b, action as bt, setVar as c, DEVTOOLS as cn, setAttrText as ct, windowList as d, rpcPrefix as dn, setSpread as dt, descendants as en, fillList as et, windowStart as f, scopes as fn, template as ft, offscreen as g, leavePage as gt, held as h, init as ht, addHead as i, setOwner as in, markBlock as it, wait as j, updateContext as jt, reveal as k, provideValue as kt, list as l, build as ln, setContent as lt, fill as m, forget as mt, paramEffect as n, makeId as nn, keepText as nt, addStyle as o, loadModule as on, putText as ot, branch as p, skew as pn, dispose as pt, place as q, updated as qt, searchParam as r, removeScope as rn, listNodes as rt, deferInBrowser as s, nameComment as sn, setAttr as st, loader as t, getScope as tn, keep as tt, toList as u, hooks as un, setOn as ut, reset as v, remount as vt, fillSettled as w, spread as wt, attempt as x, handle as xt, retag as y, removeRoot as yt, prop as z, isBound as zt };
|
|
4190
4356
|
|
|
4191
|
-
//# sourceMappingURL=client-
|
|
4357
|
+
//# sourceMappingURL=client-eVI8Wc95.js.map
|