brumate 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{boot-DN1ZU8Hg.d.ts → boot-C25Sa6vq.d.ts} +27 -2
- package/dist/cli.js +2 -2
- package/dist/client-BD6XT-s5.js +1968 -0
- package/dist/client-BD6XT-s5.js.map +1 -0
- package/dist/{client-DwJInP_a.d.ts → client-D0CqSxoO.d.ts} +211 -30
- package/dist/{client-routes-DakuM32C.js → client-routes-JTbGtukf.js} +28 -15
- package/dist/client-routes-JTbGtukf.js.map +1 -0
- package/dist/context-CTiSzQRc.js +27 -0
- package/dist/context-CTiSzQRc.js.map +1 -0
- package/dist/context-btHuB01Z.d.ts +42 -0
- package/dist/{cookies-Av5WFmcf.js → cookies-BzllthiF.js} +2 -1
- package/dist/cookies-BzllthiF.js.map +1 -0
- package/dist/defer-BbD7JQhj.js +56 -0
- package/dist/defer-BbD7JQhj.js.map +1 -0
- package/dist/devtools-CQgD7NPB.js +623 -0
- package/dist/devtools-CQgD7NPB.js.map +1 -0
- package/dist/devtools-panel-BVB-W5q4.js +1930 -0
- package/dist/devtools-panel-BVB-W5q4.js.map +1 -0
- package/dist/events-CSs7OwIC.js +85 -0
- package/dist/events-CSs7OwIC.js.map +1 -0
- package/dist/{files-DdT84mPy.js → files-BXSSrQgc.js} +34 -6
- package/dist/files-BXSSrQgc.js.map +1 -0
- package/dist/forms-Bg-CwGqX.js +406 -0
- package/dist/forms-Bg-CwGqX.js.map +1 -0
- package/dist/forms-Cl21hkHt.d.ts +281 -0
- package/dist/highlight.d.ts +17 -0
- package/dist/highlight.js +269 -0
- package/dist/highlight.js.map +1 -0
- package/dist/html-Bq1rFxX_.d.ts +92 -0
- package/dist/html-mNTKzaDD.js +241 -0
- package/dist/html-mNTKzaDD.js.map +1 -0
- package/dist/index.d.ts +123 -30
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/{inspect-BPchdWbU.js → inspect-BHpOw1LF.js} +1400 -121
- package/dist/inspect-BHpOw1LF.js.map +1 -0
- package/dist/{loader-Dc9OwY5I.js → loader-Dos_3NP0.js} +47 -11
- package/dist/loader-Dos_3NP0.js.map +1 -0
- package/dist/{navigate-CzLjnoPH.js → navigate-O78d_zGN.js} +115 -13
- package/dist/navigate-O78d_zGN.js.map +1 -0
- package/dist/produce-D0V0ICkz.d.ts +114 -0
- package/dist/produce-Doc91GkX.js +274 -0
- package/dist/produce-Doc91GkX.js.map +1 -0
- package/dist/routes-BZNt7DSZ.d.ts +38 -0
- package/dist/{rpc-9fSqL_YK.js → rpc-ygMRPmN4.js} +39 -23
- package/dist/rpc-ygMRPmN4.js.map +1 -0
- package/dist/runtime/batch.d.ts +23 -0
- package/dist/runtime/batch.js +69 -0
- package/dist/runtime/batch.js.map +1 -0
- package/dist/runtime/client.d.ts +5 -5
- package/dist/runtime/client.js +5 -1345
- package/dist/runtime/context.d.ts +2 -2
- package/dist/runtime/context.js +1 -1
- package/dist/runtime/devtools.d.ts +191 -5
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/env.d.ts +44 -0
- package/dist/runtime/env.js +61 -0
- package/dist/runtime/env.js.map +1 -0
- package/dist/runtime/events.d.ts +42 -0
- package/dist/runtime/events.js +1 -0
- package/dist/runtime/forms.d.ts +2 -0
- package/dist/runtime/forms.js +1 -0
- package/dist/runtime/gather.d.ts +25 -0
- package/dist/runtime/gather.js +33 -0
- package/dist/runtime/gather.js.map +1 -0
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.d.ts +2 -2
- package/dist/runtime/html.js +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/routes.d.ts +2 -21
- package/dist/runtime/routes.js +31 -1
- package/dist/runtime/routes.js.map +1 -1
- package/dist/runtime/server.d.ts +7 -5
- package/dist/runtime/server.js +6 -7
- package/dist/runtime/signals.d.ts +60 -3
- package/dist/runtime/signals.js +40 -2
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/testing.d.ts +46 -5
- package/dist/runtime/testing.js +240 -33
- package/dist/runtime/testing.js.map +1 -1
- package/dist/runtime/values.d.ts +2 -0
- package/dist/runtime/values.js +24 -0
- package/dist/runtime/values.js.map +1 -0
- package/dist/secrets-BxagsJxJ.js +23 -0
- package/dist/secrets-BxagsJxJ.js.map +1 -0
- package/dist/server-CxVDYE_V.js +3417 -0
- package/dist/server-CxVDYE_V.js.map +1 -0
- package/dist/server-DuFYRXrd.d.ts +1460 -0
- package/dist/skew-FRmAy9iy.js +49 -0
- package/dist/skew-FRmAy9iy.js.map +1 -0
- package/dist/standard-schema-BNY82yX3.d.ts +63 -0
- package/dist/{static-loader-BcFh4ebX.d.ts → static-loader-Drpr0AzI.d.ts} +2 -2
- package/dist/static-loader-nZssh66R.js +333 -0
- package/dist/static-loader-nZssh66R.js.map +1 -0
- package/dist/stream-DCYZO4IF.js +424 -0
- package/dist/stream-DCYZO4IF.js.map +1 -0
- package/dist/values-B8C7CLvG.d.ts +63 -0
- package/dist/vite.d.ts +49 -1
- package/dist/vite.js +598 -68
- package/dist/vite.js.map +1 -1
- package/forms/forms.brm.ts +141 -0
- package/package.json +45 -3
- package/types.d.ts +9 -1
- package/dist/client-routes-DakuM32C.js.map +0 -1
- package/dist/context-BG8KCF3v.js +0 -15
- package/dist/context-BG8KCF3v.js.map +0 -1
- package/dist/context-aeo9esY9.d.ts +0 -16
- package/dist/cookies-Av5WFmcf.js.map +0 -1
- package/dist/devtools-BKjnHrnv.js +0 -113
- package/dist/devtools-BKjnHrnv.js.map +0 -1
- package/dist/devtools-panel-AWOn0VK2.js +0 -434
- package/dist/devtools-panel-AWOn0VK2.js.map +0 -1
- package/dist/files-DdT84mPy.js.map +0 -1
- package/dist/html-DEeoepg3.js +0 -152
- package/dist/html-DEeoepg3.js.map +0 -1
- package/dist/html-Du8jY2Cc.d.ts +0 -53
- package/dist/inspect-BPchdWbU.js.map +0 -1
- package/dist/loader-Dc9OwY5I.js.map +0 -1
- package/dist/navigate-CzLjnoPH.js.map +0 -1
- package/dist/produce-BRGHP7e0.js +0 -126
- package/dist/produce-BRGHP7e0.js.map +0 -1
- package/dist/produce-CtZ32UGG.d.ts +0 -60
- package/dist/rpc-9fSqL_YK.js.map +0 -1
- package/dist/runtime/client.js.map +0 -1
- package/dist/server-BxqjLUnV.d.ts +0 -753
- package/dist/server-DZsgnPKS.js +0 -1615
- package/dist/server-DZsgnPKS.js.map +0 -1
- package/dist/shared-CWYOd0H3.js +0 -40
- package/dist/shared-CWYOd0H3.js.map +0 -1
- package/dist/static-loader-ClNkHZGn.js +0 -185
- package/dist/static-loader-ClNkHZGn.js.map +0 -1
- package/dist/stream-bgNCMcaA.js +0 -280
- package/dist/stream-bgNCMcaA.js.map +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/runtime/html.d.ts
|
|
2
|
+
declare const RAW: unique symbol;
|
|
3
|
+
/** HTML that is inserted as it is, such as the output of a template. */
|
|
4
|
+
interface Raw {
|
|
5
|
+
[RAW]: string;
|
|
6
|
+
}
|
|
7
|
+
declare function raw(html: string): Raw;
|
|
8
|
+
declare function isRaw(value: unknown): value is Raw;
|
|
9
|
+
declare function rawHTML(value: Raw): string;
|
|
10
|
+
declare function escape(value: string): string;
|
|
11
|
+
declare function escapeAttribute(value: string): string;
|
|
12
|
+
/** Renders a value inserted in markup. Promises are not awaited. */
|
|
13
|
+
declare function insertValue(value: unknown): string;
|
|
14
|
+
/**
|
|
15
|
+
* Renders a value as the text of an element whose content is text, such as
|
|
16
|
+
* a `<textarea>`, as `insertValue` does but without escaping.
|
|
17
|
+
*/
|
|
18
|
+
declare function textValue(value: unknown): string;
|
|
19
|
+
declare function classValue(value: unknown): string;
|
|
20
|
+
/**
|
|
21
|
+
* Renders a `class` attribute from classes that each have a space before
|
|
22
|
+
* them, which the compiler builds from a literal class value. The classes
|
|
23
|
+
* are escaped already. No class renders nothing.
|
|
24
|
+
*/
|
|
25
|
+
declare function classAttribute(classes: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the text of an attribute, or undefined if the attribute is not
|
|
28
|
+
* rendered.
|
|
29
|
+
*
|
|
30
|
+
* - `null` and `undefined` leave the attribute out.
|
|
31
|
+
* - For an attribute whose value says its state, such as `aria-expanded`,
|
|
32
|
+
* `draggable` or `translate`, `true` and `false` render as its words:
|
|
33
|
+
* `"true"` and `"false"`, or `"yes"` and `"no"`, or `"on"` and `"off"`.
|
|
34
|
+
* - For other attributes, such as `disabled`, `true` renders the attribute
|
|
35
|
+
* without a value, and `false` leaves it out.
|
|
36
|
+
*/
|
|
37
|
+
declare function attributeText(name: string, value: unknown): string | undefined;
|
|
38
|
+
/** Renders one attribute, with a leading space. A name that is not one attribute renders nothing. */
|
|
39
|
+
declare function attribute(name: string, value: unknown): string;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the value of a style variable with text around it, such as `12px`
|
|
42
|
+
* for `${size}px`. A value that sets no variable stays as it is.
|
|
43
|
+
*/
|
|
44
|
+
declare function affix(prefix: string, value: unknown, suffix: string): unknown;
|
|
45
|
+
/** Returns a style with custom properties before an element's own style. */
|
|
46
|
+
declare function vars(variables: Record<string, unknown>, own: unknown): string;
|
|
47
|
+
/** Returns a `<style>` element for a component's stylesheet. */
|
|
48
|
+
declare function styleElement(id: string, css: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Merges the attributes of an element that has spreads, in their order: a
|
|
51
|
+
* later value wins, except `class`, whose values all apply.
|
|
52
|
+
*/
|
|
53
|
+
declare function mergeAttributes(parts: Record<string, unknown>[]): Record<string, unknown>;
|
|
54
|
+
/**
|
|
55
|
+
* The `b-on` entry of a handler that a spread passes on, such as
|
|
56
|
+
* `click:prevent=Parent#h1@3`: its event, the modifiers of its wrappers, its
|
|
57
|
+
* client function and the scope it runs in. A handler that `$handler` made
|
|
58
|
+
* has its arguments after another `@`, encoded so that they hold no space.
|
|
59
|
+
*/
|
|
60
|
+
declare function handlerEntry(name: string, ref: string, scope: number | string, modifiers?: readonly string[], args?: unknown[]): string;
|
|
61
|
+
/**
|
|
62
|
+
* The `b-on` entry of a binding that a spread puts on `value` or `checked`
|
|
63
|
+
* of an element. It names the scope of the slot, or of the setter of
|
|
64
|
+
* `$bind(name, fn)`, after `@`. A box writes on `change`.
|
|
65
|
+
*/
|
|
66
|
+
declare function bindEntry(name: string, ref: {
|
|
67
|
+
scope: number | string;
|
|
68
|
+
slot: number;
|
|
69
|
+
}, setter?: {
|
|
70
|
+
ref: string;
|
|
71
|
+
scope: number | string;
|
|
72
|
+
}): string;
|
|
73
|
+
/**
|
|
74
|
+
* The `b-on` attribute of an element with spreads: the bindings of its
|
|
75
|
+
* spreads, so its handlers read the new value, then its own handlers, then
|
|
76
|
+
* those of its spreads.
|
|
77
|
+
*/
|
|
78
|
+
declare function onAttribute(on: string[], own: string): string;
|
|
79
|
+
/** Renders an object of attributes. */
|
|
80
|
+
declare function spread(attributes: Record<string, unknown>): string;
|
|
81
|
+
declare const VOID_ELEMENTS: Set<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Renders the attributes of a form that posts to a server function, such as
|
|
84
|
+
* ` action="/_brumate/App_1abc%23save" method="post"`. `method` is the name of
|
|
85
|
+
* the method attribute to add, if the element has none. `build` is the ID
|
|
86
|
+
* of the build of the page, which the URL carries as `__build`, so the
|
|
87
|
+
* server can tell a post from before a deploy without scripts.
|
|
88
|
+
*/
|
|
89
|
+
declare function actionAttributes(prefix: string, name: string, id: string, method?: string, result?: string, build?: string, key?: string): string;
|
|
90
|
+
//#endregion
|
|
91
|
+
export { vars as S, raw as _, attribute as a, styleElement as b, classAttribute as c, escapeAttribute as d, handlerEntry as f, onAttribute as g, mergeAttributes as h, affix as i, classValue as l, isRaw as m, VOID_ELEMENTS as n, attributeText as o, insertValue as p, actionAttributes as r, bindEntry as s, Raw as t, escape as u, rawHTML as v, textValue as x, spread as y };
|
|
92
|
+
//# sourceMappingURL=html-Bq1rFxX_.d.ts.map
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
//#region src/runtime/html.ts
|
|
2
|
+
const RAW = Symbol.for("brumate.raw");
|
|
3
|
+
var RawHTML = class {
|
|
4
|
+
[RAW];
|
|
5
|
+
constructor(html) {
|
|
6
|
+
this[RAW] = html;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
function raw(html) {
|
|
10
|
+
return new RawHTML(html);
|
|
11
|
+
}
|
|
12
|
+
function isRaw(value) {
|
|
13
|
+
return typeof value === "object" && value !== null && RAW in value;
|
|
14
|
+
}
|
|
15
|
+
function rawHTML(value) {
|
|
16
|
+
return value[RAW];
|
|
17
|
+
}
|
|
18
|
+
const ESCAPES = {
|
|
19
|
+
"&": "&",
|
|
20
|
+
"<": "<",
|
|
21
|
+
">": ">",
|
|
22
|
+
"\"": """
|
|
23
|
+
};
|
|
24
|
+
const toEscape = (char) => ESCAPES[char];
|
|
25
|
+
function escape(value) {
|
|
26
|
+
return /[&<>]/.test(value) ? value.replace(/[&<>]/g, toEscape) : value;
|
|
27
|
+
}
|
|
28
|
+
function escapeAttribute(value) {
|
|
29
|
+
return /[&<"]/.test(value) ? value.replace(/[&<"]/g, toEscape) : value;
|
|
30
|
+
}
|
|
31
|
+
/** Renders a value inserted in markup. Promises are not awaited. */
|
|
32
|
+
function insertValue(value) {
|
|
33
|
+
if (isRaw(value)) return value[RAW];
|
|
34
|
+
if (value === null || value === void 0 || typeof value === "boolean") return "";
|
|
35
|
+
if (Array.isArray(value)) return value.map(insertValue).join("");
|
|
36
|
+
return escape(String(value));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Renders a value as the text of an element whose content is text, such as
|
|
40
|
+
* a `<textarea>`, as `insertValue` does but without escaping.
|
|
41
|
+
*/
|
|
42
|
+
function textValue(value) {
|
|
43
|
+
if (isRaw(value)) return value[RAW];
|
|
44
|
+
if (value === null || value === void 0 || typeof value === "boolean") return "";
|
|
45
|
+
if (Array.isArray(value)) return value.map(textValue).join("");
|
|
46
|
+
return String(value);
|
|
47
|
+
}
|
|
48
|
+
function toKebabCase(name) {
|
|
49
|
+
return name.startsWith("--") ? name : name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
|
|
50
|
+
}
|
|
51
|
+
function classValue(value) {
|
|
52
|
+
if (typeof value !== "object" || value === null) return value ? String(value) : "";
|
|
53
|
+
let text = "";
|
|
54
|
+
if (Array.isArray(value)) {
|
|
55
|
+
for (const item of value) {
|
|
56
|
+
const part = classValue(item);
|
|
57
|
+
if (part !== "") text = text === "" ? part : `${text} ${part}`;
|
|
58
|
+
}
|
|
59
|
+
return text;
|
|
60
|
+
}
|
|
61
|
+
let first = true;
|
|
62
|
+
for (const name in value) if (Object.hasOwn(value, name) && value[name]) {
|
|
63
|
+
text = first ? name : `${text} ${name}`;
|
|
64
|
+
first = false;
|
|
65
|
+
}
|
|
66
|
+
return text;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Renders a `class` attribute from classes that each have a space before
|
|
70
|
+
* them, which the compiler builds from a literal class value. The classes
|
|
71
|
+
* are escaped already. No class renders nothing.
|
|
72
|
+
*/
|
|
73
|
+
function classAttribute(classes) {
|
|
74
|
+
return classes === "" ? "" : ` class="${classes.slice(1)}"`;
|
|
75
|
+
}
|
|
76
|
+
function styleValue(value) {
|
|
77
|
+
if (typeof value === "object" && value !== null) return Object.entries(value).filter(([, item]) => item !== null && item !== void 0 && item !== false).map(([name, item]) => `${toKebabCase(name)}:${String(item)}`).join(";");
|
|
78
|
+
return String(value);
|
|
79
|
+
}
|
|
80
|
+
/** The brand of a binding of `$bind`, under the key of the registry. See `Binding`. */
|
|
81
|
+
const BOUND = Symbol.for("brumate.binding");
|
|
82
|
+
/** The words of an attribute that says `true` or `false` in its value. */
|
|
83
|
+
const TRUE_FALSE = ["true", "false"];
|
|
84
|
+
/**
|
|
85
|
+
* Attributes whose two states are words in the value, not whether the
|
|
86
|
+
* attribute is there, by their words for `true` and `false`. A missing
|
|
87
|
+
* attribute means a third state, such as the default of the element, so
|
|
88
|
+
* `false` must not remove it. `aria-*` and `data-*` are such attributes too.
|
|
89
|
+
*/
|
|
90
|
+
const SWITCHES = /* @__PURE__ */ new Map([
|
|
91
|
+
["contenteditable", TRUE_FALSE],
|
|
92
|
+
["draggable", TRUE_FALSE],
|
|
93
|
+
["spellcheck", TRUE_FALSE],
|
|
94
|
+
["writingsuggestions", TRUE_FALSE],
|
|
95
|
+
["focusable", TRUE_FALSE],
|
|
96
|
+
["translate", ["yes", "no"]],
|
|
97
|
+
["autocomplete", ["on", "off"]],
|
|
98
|
+
["autocorrect", ["on", "off"]]
|
|
99
|
+
]);
|
|
100
|
+
/** The words of `true` and `false` for an attribute that says them in its value, or undefined. */
|
|
101
|
+
function switchWords(name) {
|
|
102
|
+
const lower = name.toLowerCase();
|
|
103
|
+
if (lower.startsWith("aria-") || lower.startsWith("data-")) return TRUE_FALSE;
|
|
104
|
+
return SWITCHES.get(lower);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Returns the text of an attribute, or undefined if the attribute is not
|
|
108
|
+
* rendered.
|
|
109
|
+
*
|
|
110
|
+
* - `null` and `undefined` leave the attribute out.
|
|
111
|
+
* - For an attribute whose value says its state, such as `aria-expanded`,
|
|
112
|
+
* `draggable` or `translate`, `true` and `false` render as its words:
|
|
113
|
+
* `"true"` and `"false"`, or `"yes"` and `"no"`, or `"on"` and `"off"`.
|
|
114
|
+
* - For other attributes, such as `disabled`, `true` renders the attribute
|
|
115
|
+
* without a value, and `false` leaves it out.
|
|
116
|
+
*/
|
|
117
|
+
function attributeText(name, value) {
|
|
118
|
+
if (typeof value === "object" && value !== null && BOUND in value) value = value.value;
|
|
119
|
+
if (value === null || value === void 0 || typeof value === "function") return;
|
|
120
|
+
if (typeof value === "boolean") {
|
|
121
|
+
const words = switchWords(name);
|
|
122
|
+
if (words) return value ? words[0] : words[1];
|
|
123
|
+
return value ? "" : void 0;
|
|
124
|
+
}
|
|
125
|
+
if (name === "class") {
|
|
126
|
+
const text = classValue(value);
|
|
127
|
+
return text === "" ? void 0 : text;
|
|
128
|
+
}
|
|
129
|
+
return name === "style" ? styleValue(value) : String(value);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A name that HTML reads as one attribute. A spread takes its names from
|
|
133
|
+
* data, so a name with a space, a quote, `>`, `/` or `=` could write other
|
|
134
|
+
* attributes or markup.
|
|
135
|
+
*/
|
|
136
|
+
const ATTRIBUTE_NAME = /^[^\s"'>/=\x00-\x1f\x7f]+$/;
|
|
137
|
+
/** Renders one attribute, with a leading space. A name that is not one attribute renders nothing. */
|
|
138
|
+
function attribute(name, value) {
|
|
139
|
+
const text = attributeText(name, value);
|
|
140
|
+
if (text === void 0 || !ATTRIBUTE_NAME.test(name)) return "";
|
|
141
|
+
return value === true && text === "" ? ` ${name}` : ` ${name}="${escapeAttribute(text)}"`;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Returns the value of a style variable with text around it, such as `12px`
|
|
145
|
+
* for `${size}px`. A value that sets no variable stays as it is.
|
|
146
|
+
*/
|
|
147
|
+
function affix(prefix, value, suffix) {
|
|
148
|
+
return value === null || value === void 0 || value === false ? value : `${prefix}${String(value)}${suffix}`;
|
|
149
|
+
}
|
|
150
|
+
/** Returns a style with custom properties before an element's own style. */
|
|
151
|
+
function vars(variables, own) {
|
|
152
|
+
const parts = [];
|
|
153
|
+
for (const [name, value] of Object.entries(variables)) if (value !== null && value !== void 0 && value !== false) parts.push(`${name}:${String(value)}`);
|
|
154
|
+
const rest = own === null || own === void 0 || own === false ? "" : styleValue(own);
|
|
155
|
+
if (rest) parts.push(rest);
|
|
156
|
+
return parts.join(";");
|
|
157
|
+
}
|
|
158
|
+
/** Returns a `<style>` element for a component's stylesheet. */
|
|
159
|
+
function styleElement(id, css) {
|
|
160
|
+
return `<style b-style="${escapeAttribute(id)}">${css.replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Merges the attributes of an element that has spreads, in their order: a
|
|
164
|
+
* later value wins, except `class`, whose values all apply.
|
|
165
|
+
*/
|
|
166
|
+
function mergeAttributes(parts) {
|
|
167
|
+
const result = {};
|
|
168
|
+
for (const part of parts) for (const [name, value] of Object.entries(part ?? {})) result[name] = name === "class" && result.class !== void 0 && value !== void 0 ? [result.class, value] : value;
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The `b-on` entry of a handler that a spread passes on, such as
|
|
173
|
+
* `click:prevent=Parent#h1@3`: its event, the modifiers of its wrappers, its
|
|
174
|
+
* client function and the scope it runs in. A handler that `$handler` made
|
|
175
|
+
* has its arguments after another `@`, encoded so that they hold no space.
|
|
176
|
+
*/
|
|
177
|
+
function handlerEntry(name, ref, scope, modifiers = [], args) {
|
|
178
|
+
const bound = args === void 0 ? "" : `@${encodeURIComponent(JSON.stringify(args))}`;
|
|
179
|
+
return `${[name.slice(2).toLowerCase(), ...modifiers].join(":")}=${ref}@${scope}${bound}`;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The `b-on` entry of a binding that a spread puts on `value` or `checked`
|
|
183
|
+
* of an element. It names the scope of the slot, or of the setter of
|
|
184
|
+
* `$bind(name, fn)`, after `@`. A box writes on `change`.
|
|
185
|
+
*/
|
|
186
|
+
function bindEntry(name, ref, setter) {
|
|
187
|
+
const event = name === "checked" ? "change" : "input";
|
|
188
|
+
return setter ? `${event}=$set:${setter.ref}@${setter.scope}` : `${event}=$bind#0.${ref.slot}@${ref.scope}`;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The `b-on` attribute of an element with spreads: the bindings of its
|
|
192
|
+
* spreads, so its handlers read the new value, then its own handlers, then
|
|
193
|
+
* those of its spreads.
|
|
194
|
+
*/
|
|
195
|
+
function onAttribute(on, own) {
|
|
196
|
+
const bindings = on.filter((entry) => /=\$(bind#|set:)/.test(entry));
|
|
197
|
+
const value = [
|
|
198
|
+
...bindings,
|
|
199
|
+
own,
|
|
200
|
+
...on.filter((entry) => !bindings.includes(entry))
|
|
201
|
+
].filter(Boolean).join(" ");
|
|
202
|
+
return value ? ` b-on="${escapeAttribute(value)}"` : "";
|
|
203
|
+
}
|
|
204
|
+
/** Renders an object of attributes. */
|
|
205
|
+
function spread(attributes) {
|
|
206
|
+
let result = "";
|
|
207
|
+
for (const [name, value] of Object.entries(attributes)) if (name !== "children" && !/^on[A-Z]/.test(name)) result += attribute(name, value);
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
const VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
211
|
+
"area",
|
|
212
|
+
"base",
|
|
213
|
+
"br",
|
|
214
|
+
"col",
|
|
215
|
+
"embed",
|
|
216
|
+
"hr",
|
|
217
|
+
"img",
|
|
218
|
+
"input",
|
|
219
|
+
"link",
|
|
220
|
+
"meta",
|
|
221
|
+
"source",
|
|
222
|
+
"track",
|
|
223
|
+
"wbr"
|
|
224
|
+
]);
|
|
225
|
+
/**
|
|
226
|
+
* Renders the attributes of a form that posts to a server function, such as
|
|
227
|
+
* ` action="/_brumate/App_1abc%23save" method="post"`. `method` is the name of
|
|
228
|
+
* the method attribute to add, if the element has none. `build` is the ID
|
|
229
|
+
* of the build of the page, which the URL carries as `__build`, so the
|
|
230
|
+
* server can tell a post from before a deploy without scripts.
|
|
231
|
+
*/
|
|
232
|
+
function actionAttributes(prefix, name, id, method, result, build, key) {
|
|
233
|
+
const methodText = method ? ` ${method}="post"` : "";
|
|
234
|
+
const query = [build === void 0 ? "" : `__build=${encodeURIComponent(build)}`, key === void 0 ? "" : `__key=${key}`].filter(Boolean).join("&");
|
|
235
|
+
if (result !== void 0) return ` ${name}="${escapeAttribute(`?__action=${encodeURIComponent(id)}${query ? `&${query}` : ""}`)}"${methodText} b-action="${escapeAttribute(id)}" b-result="${escapeAttribute(result)}"`;
|
|
236
|
+
return ` ${name}="${escapeAttribute(`${prefix}/${encodeURIComponent(id)}${query ? `?${query}` : ""}`)}"${methodText}`;
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
export { rawHTML as _, attributeText as a, textValue as b, classValue as c, handlerEntry as d, insertValue as f, raw as g, onAttribute as h, attribute as i, escape as l, mergeAttributes as m, actionAttributes as n, bindEntry as o, isRaw as p, affix as r, classAttribute as s, VOID_ELEMENTS as t, escapeAttribute as u, spread as v, vars as x, styleElement as y };
|
|
240
|
+
|
|
241
|
+
//# sourceMappingURL=html-mNTKzaDD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-mNTKzaDD.js","names":[],"sources":["../src/runtime/html.ts"],"sourcesContent":["// HTML string helpers that the server and the client both use.\n\nconst RAW: unique symbol = Symbol.for('brumate.raw');\n\n/** HTML that is inserted as it is, such as the output of a template. */\nexport interface Raw {\n [RAW]: string;\n}\n\n// A class, not an object literal, so serializers can skip their test for raw HTML on plain objects.\nclass RawHTML implements Raw {\n readonly [RAW]: string;\n\n constructor(html: string) {\n this[RAW] = html;\n }\n}\n\nexport function raw(html: string): Raw {\n return new RawHTML(html);\n}\n\nexport function isRaw(value: unknown): value is Raw {\n return typeof value === 'object' && value !== null && RAW in value;\n}\n\nexport function rawHTML(value: Raw): string {\n return value[RAW];\n}\n\nconst ESCAPES: Record<string, string> = { '&': '&', '<': '<', '>': '>', '\"': '"' };\n\nconst toEscape = (char: string): string => ESCAPES[char]!;\n\n// Most text has nothing to escape, so a test without the global flag skips the replace.\nexport function escape(value: string): string {\n return /[&<>]/.test(value) ? value.replace(/[&<>]/g, toEscape) : value;\n}\n\nexport function escapeAttribute(value: string): string {\n return /[&<\"]/.test(value) ? value.replace(/[&<\"]/g, toEscape) : value;\n}\n\n/** Renders a value inserted in markup. Promises are not awaited. */\nexport function insertValue(value: unknown): string {\n if (isRaw(value)) {\n return value[RAW];\n }\n if (value === null || value === undefined || typeof value === 'boolean') {\n return '';\n }\n if (Array.isArray(value)) {\n return value.map(insertValue).join('');\n }\n return escape(String(value));\n}\n\n/**\n * Renders a value as the text of an element whose content is text, such as\n * a `<textarea>`, as `insertValue` does but without escaping.\n */\nexport function textValue(value: unknown): string {\n if (isRaw(value)) {\n return value[RAW];\n }\n if (value === null || value === undefined || typeof value === 'boolean') {\n return '';\n }\n if (Array.isArray(value)) {\n return value.map(textValue).join('');\n }\n return String(value);\n}\n\nfunction toKebabCase(name: string): string {\n return name.startsWith('--') ? name : name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n}\n\nexport function classValue(value: unknown): string {\n if (typeof value !== 'object' || value === null) {\n return value ? String(value) : '';\n }\n let text = '';\n if (Array.isArray(value)) {\n for (const item of value) {\n const part = classValue(item);\n if (part !== '') {\n text = text === '' ? part : `${text} ${part}`;\n }\n }\n return text;\n }\n // An empty name still adds a space between its neighbours, as in a join.\n let first = true;\n for (const name in value) {\n if (Object.hasOwn(value, name) && (value as Record<string, unknown>)[name]) {\n text = first ? name : `${text} ${name}`;\n first = false;\n }\n }\n return text;\n}\n\n/**\n * Renders a `class` attribute from classes that each have a space before\n * them, which the compiler builds from a literal class value. The classes\n * are escaped already. No class renders nothing.\n */\nexport function classAttribute(classes: string): string {\n return classes === '' ? '' : ` class=\"${classes.slice(1)}\"`;\n}\n\nfunction styleValue(value: unknown): string {\n if (typeof value === 'object' && value !== null) {\n return Object.entries(value)\n .filter(([, item]) => item !== null && item !== undefined && item !== false)\n .map(([name, item]) => `${toKebabCase(name)}:${String(item)}`)\n .join(';');\n }\n return String(value);\n}\n\n/** The brand of a binding of `$bind`, under the key of the registry. See `Binding`. */\nconst BOUND = Symbol.for('brumate.binding');\n\n/** The words of an attribute that says `true` or `false` in its value. */\nconst TRUE_FALSE = ['true', 'false'] as const;\n\n/**\n * Attributes whose two states are words in the value, not whether the\n * attribute is there, by their words for `true` and `false`. A missing\n * attribute means a third state, such as the default of the element, so\n * `false` must not remove it. `aria-*` and `data-*` are such attributes too.\n */\nconst SWITCHES = new Map<string, readonly [string, string]>([\n ['contenteditable', TRUE_FALSE],\n ['draggable', TRUE_FALSE],\n ['spellcheck', TRUE_FALSE],\n ['writingsuggestions', TRUE_FALSE],\n // SVG.\n ['focusable', TRUE_FALSE],\n ['translate', ['yes', 'no']],\n ['autocomplete', ['on', 'off']],\n ['autocorrect', ['on', 'off']],\n]);\n\n/** The words of `true` and `false` for an attribute that says them in its value, or undefined. */\nfunction switchWords(name: string): readonly [string, string] | undefined {\n const lower = name.toLowerCase();\n if (lower.startsWith('aria-') || lower.startsWith('data-')) {\n return TRUE_FALSE;\n }\n return SWITCHES.get(lower);\n}\n\n/**\n * Returns the text of an attribute, or undefined if the attribute is not\n * rendered.\n *\n * - `null` and `undefined` leave the attribute out.\n * - For an attribute whose value says its state, such as `aria-expanded`,\n * `draggable` or `translate`, `true` and `false` render as its words:\n * `\"true\"` and `\"false\"`, or `\"yes\"` and `\"no\"`, or `\"on\"` and `\"off\"`.\n * - For other attributes, such as `disabled`, `true` renders the attribute\n * without a value, and `false` leaves it out.\n */\nexport function attributeText(name: string, value: unknown): string | undefined {\n // `value=$bind(name)` on an element renders the value of the name.\n if (typeof value === 'object' && value !== null && BOUND in value) {\n value = (value as unknown as { value: unknown }).value;\n }\n if (value === null || value === undefined || typeof value === 'function') {\n return undefined;\n }\n if (typeof value === 'boolean') {\n const words = switchWords(name);\n if (words) {\n return value ? words[0] : words[1];\n }\n return value ? '' : undefined;\n }\n if (name === 'class') {\n const text = classValue(value);\n return text === '' ? undefined : text;\n }\n return name === 'style' ? styleValue(value) : String(value);\n}\n\n/**\n * A name that HTML reads as one attribute. A spread takes its names from\n * data, so a name with a space, a quote, `>`, `/` or `=` could write other\n * attributes or markup.\n */\n// oxlint-disable-next-line no-control-regex -- HTML reads no control character in a name.\nconst ATTRIBUTE_NAME = /^[^\\s\"'>/=\\x00-\\x1f\\x7f]+$/;\n\n/** Renders one attribute, with a leading space. A name that is not one attribute renders nothing. */\nexport function attribute(name: string, value: unknown): string {\n const text = attributeText(name, value);\n if (text === undefined || !ATTRIBUTE_NAME.test(name)) {\n return '';\n }\n return value === true && text === '' ? ` ${name}` : ` ${name}=\"${escapeAttribute(text)}\"`;\n}\n\n/**\n * Returns the value of a style variable with text around it, such as `12px`\n * for `${size}px`. A value that sets no variable stays as it is.\n */\nexport function affix(prefix: string, value: unknown, suffix: string): unknown {\n return value === null || value === undefined || value === false\n ? value\n : `${prefix}${String(value)}${suffix}`;\n}\n\n/** Returns a style with custom properties before an element's own style. */\nexport function vars(variables: Record<string, unknown>, own: unknown): string {\n const parts: string[] = [];\n for (const [name, value] of Object.entries(variables)) {\n if (value !== null && value !== undefined && value !== false) {\n parts.push(`${name}:${String(value)}`);\n }\n }\n const rest = own === null || own === undefined || own === false ? '' : styleValue(own);\n if (rest) {\n parts.push(rest);\n }\n return parts.join(';');\n}\n\n/** Returns a `<style>` element for a component's stylesheet. */\nexport function styleElement(id: string, css: string): string {\n return `<style b-style=\"${escapeAttribute(id)}\">${css.replace(/<\\/style/gi, '<\\\\/style')}</style>`;\n}\n\n/**\n * Merges the attributes of an element that has spreads, in their order: a\n * later value wins, except `class`, whose values all apply.\n */\nexport function mergeAttributes(parts: Record<string, unknown>[]): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const part of parts) {\n for (const [name, value] of Object.entries(part ?? {})) {\n result[name] =\n name === 'class' && result.class !== undefined && value !== undefined\n ? [result.class, value]\n : value;\n }\n }\n return result;\n}\n\n/**\n * The `b-on` entry of a handler that a spread passes on, such as\n * `click:prevent=Parent#h1@3`: its event, the modifiers of its wrappers, its\n * client function and the scope it runs in. A handler that `$handler` made\n * has its arguments after another `@`, encoded so that they hold no space.\n */\nexport function handlerEntry(\n name: string,\n ref: string,\n scope: number | string,\n modifiers: readonly string[] = [],\n args?: unknown[],\n): string {\n const bound = args === undefined ? '' : `@${encodeURIComponent(JSON.stringify(args))}`;\n return `${[name.slice(2).toLowerCase(), ...modifiers].join(':')}=${ref}@${scope}${bound}`;\n}\n\n/**\n * The `b-on` entry of a binding that a spread puts on `value` or `checked`\n * of an element. It names the scope of the slot, or of the setter of\n * `$bind(name, fn)`, after `@`. A box writes on `change`.\n */\nexport function bindEntry(\n name: string,\n ref: { scope: number | string; slot: number },\n setter?: { ref: string; scope: number | string },\n): string {\n const event = name === 'checked' ? 'change' : 'input';\n return setter\n ? `${event}=$set:${setter.ref}@${setter.scope}`\n : `${event}=$bind#0.${ref.slot}@${ref.scope}`;\n}\n\n/**\n * The `b-on` attribute of an element with spreads: the bindings of its\n * spreads, so its handlers read the new value, then its own handlers, then\n * those of its spreads.\n */\nexport function onAttribute(on: string[], own: string): string {\n const bindings = on.filter((entry) => /=\\$(bind#|set:)/.test(entry));\n const value = [...bindings, own, ...on.filter((entry) => !bindings.includes(entry))]\n .filter(Boolean)\n .join(' ');\n return value ? ` b-on=\"${escapeAttribute(value)}\"` : '';\n}\n\n/** Renders an object of attributes. */\nexport function spread(attributes: Record<string, unknown>): string {\n let result = '';\n for (const [name, value] of Object.entries(attributes)) {\n if (name !== 'children' && !/^on[A-Z]/.test(name)) {\n result += attribute(name, value);\n }\n }\n return result;\n}\n\nexport const VOID_ELEMENTS: Set<string> = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/**\n * Renders the attributes of a form that posts to a server function, such as\n * ` action=\"/_brumate/App_1abc%23save\" method=\"post\"`. `method` is the name of\n * the method attribute to add, if the element has none. `build` is the ID\n * of the build of the page, which the URL carries as `__build`, so the\n * server can tell a post from before a deploy without scripts.\n */\nexport function actionAttributes(\n prefix: string,\n name: string,\n id: string,\n method?: string,\n result?: string,\n build?: string,\n key?: string,\n): string {\n const methodText = method ? ` ${method}=\"post\"` : '';\n // The key of a form of a function that `idempotent` made, so a second post gets the first result.\n const query = [\n build === undefined ? '' : `__build=${encodeURIComponent(build)}`,\n key === undefined ? '' : `__key=${key}`,\n ]\n .filter(Boolean)\n .join('&');\n if (result !== undefined) {\n // The form posts to its page, which renders with the result. With the\n // loader, the result is written into the `$action` at `result` instead.\n const url = `?__action=${encodeURIComponent(id)}${query ? `&${query}` : ''}`;\n return ` ${name}=\"${escapeAttribute(url)}\"${methodText} b-action=\"${escapeAttribute(id)}\" b-result=\"${escapeAttribute(result)}\"`;\n }\n const url = `${prefix}/${encodeURIComponent(id)}${query ? `?${query}` : ''}`;\n return ` ${name}=\"${escapeAttribute(url)}\"${methodText}`;\n}\n"],"mappings":";AAEA,MAAM,MAAqB,OAAO,IAAI,aAAa;AAQnD,IAAM,UAAN,MAA6B;CAC3B,CAAU;CAEV,YAAY,MAAc;EACxB,KAAK,OAAO;CACd;AACF;AAEA,SAAgB,IAAI,MAAmB;CACrC,OAAO,IAAI,QAAQ,IAAI;AACzB;AAEA,SAAgB,MAAM,OAA8B;CAClD,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO;AAC/D;AAEA,SAAgB,QAAQ,OAAoB;CAC1C,OAAO,MAAM;AACf;AAEA,MAAM,UAAkC;CAAE,KAAK;CAAS,KAAK;CAAQ,KAAK;CAAQ,MAAK;AAAS;AAEhG,MAAM,YAAY,SAAyB,QAAQ;AAGnD,SAAgB,OAAO,OAAuB;CAC5C,OAAO,QAAQ,KAAK,KAAK,IAAI,MAAM,QAAQ,UAAU,QAAQ,IAAI;AACnE;AAEA,SAAgB,gBAAgB,OAAuB;CACrD,OAAO,QAAQ,KAAK,KAAK,IAAI,MAAM,QAAQ,UAAU,QAAQ,IAAI;AACnE;;AAGA,SAAgB,YAAY,OAAwB;CAClD,IAAI,MAAM,KAAK,GACb,OAAO,MAAM;CAEf,IAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,OAAO,UAAU,WAC5D,OAAO;CAET,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,WAAW,CAAC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AIb,OAAO,IAAI,KAAK,IAAI,gBAAgB,aADX,mBAAmB,EAAE,IAAI,QAAQ,IAAI,UAAU,IACjC,EAAE,GAAG,WAAW,aAAa,gBAAgB,EAAE,EAAE,cAAc,gBAAgB,MAAM,EAAE;CAGhI,OAAO,IAAI,KAAK,IAAI,gBAAgB,GADrB,OAAO,GAAG,mBAAmB,EAAE,IAAI,QAAQ,IAAI,UAAU,IACjC,EAAE,GAAG;AAC9C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1372,6 +1372,18 @@ interface DynamicTagNode extends Range {
|
|
|
1372
1372
|
interface FragmentNode extends Range {
|
|
1373
1373
|
kind: "fragment";
|
|
1374
1374
|
children: Markup[];
|
|
1375
|
+
/**
|
|
1376
|
+
* For `#reveal`: the order in which the server shows the `#loading` bodies
|
|
1377
|
+
* inside, and whether only the next fallback shows. Elsewhere the children
|
|
1378
|
+
* render as they are.
|
|
1379
|
+
*/
|
|
1380
|
+
reveal?: Reveal;
|
|
1381
|
+
}
|
|
1382
|
+
/** The order of `#reveal`, as its header writes it. */
|
|
1383
|
+
type RevealOrder = "sequential" | "backwards" | "together" | "natural";
|
|
1384
|
+
interface Reveal {
|
|
1385
|
+
order: RevealOrder;
|
|
1386
|
+
collapsed: boolean;
|
|
1375
1387
|
}
|
|
1376
1388
|
interface GlobalListenerNode extends Range {
|
|
1377
1389
|
kind: "listener";
|
|
@@ -1497,6 +1509,19 @@ interface ClientBlock extends Range {
|
|
|
1497
1509
|
kind: "client";
|
|
1498
1510
|
trigger: ClientTrigger;
|
|
1499
1511
|
body: Body;
|
|
1512
|
+
/** Markup that the server renders in place of the body, until the body renders. */
|
|
1513
|
+
fallback?: Body;
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* `#defer (trigger) { … } #else { … }`: a body that the server renders in a
|
|
1517
|
+
* later request, when the trigger fires in the browser. The page has the
|
|
1518
|
+
* fallback until then.
|
|
1519
|
+
*/
|
|
1520
|
+
interface DeferBlock extends Range {
|
|
1521
|
+
kind: "defer";
|
|
1522
|
+
trigger: ClientTrigger;
|
|
1523
|
+
body: Body;
|
|
1524
|
+
fallback?: Body;
|
|
1500
1525
|
}
|
|
1501
1526
|
/**
|
|
1502
1527
|
* `#offscreen (visible) { … }`: a body that stays in the page while it is
|
|
@@ -1507,7 +1532,7 @@ interface OffscreenBlock extends Range {
|
|
|
1507
1532
|
visible: Expression;
|
|
1508
1533
|
body: Body;
|
|
1509
1534
|
}
|
|
1510
|
-
type Block = IfBlock | ForBlock | RepeatBlock | SwitchBlock | KeyBlock | TryBlock | LoadingBlock | PortalBlock | HeadBlock | ClientBlock | OffscreenBlock;
|
|
1535
|
+
type Block = IfBlock | ForBlock | RepeatBlock | SwitchBlock | KeyBlock | TryBlock | LoadingBlock | PortalBlock | HeadBlock | ClientBlock | DeferBlock | OffscreenBlock;
|
|
1511
1536
|
interface TemplateDecl extends Range {
|
|
1512
1537
|
kind: "template";
|
|
1513
1538
|
name: string;
|
|
@@ -1564,10 +1589,25 @@ interface Declaration {
|
|
|
1564
1589
|
* a guess, until the source changes or the server calls of the page finish.
|
|
1565
1590
|
*/
|
|
1566
1591
|
optimistic?: Declaration;
|
|
1592
|
+
/**
|
|
1593
|
+
* For `$debounced(value, ms)` and `$throttled(value, ms)`, how the browser
|
|
1594
|
+
* writes the memo: after the value stops changing for `ms`, or at most once every `ms`.
|
|
1595
|
+
*/
|
|
1596
|
+
timing?: {
|
|
1597
|
+
kind: "debounced" | "throttled";
|
|
1598
|
+
ms: number;
|
|
1599
|
+
};
|
|
1567
1600
|
/** For `let name = $signal(value)`, the value. */
|
|
1568
1601
|
init?: Node;
|
|
1569
|
-
/**
|
|
1602
|
+
/**
|
|
1603
|
+
* True for a memo declared with `$optimistic`, before its source is known,
|
|
1604
|
+
* and for a prop that the component destructures with `let`.
|
|
1605
|
+
*/
|
|
1570
1606
|
writable?: boolean;
|
|
1607
|
+
/** True for a signal or a writable prop that `$bind` passes to a child, which needs a slot. */
|
|
1608
|
+
bound?: boolean;
|
|
1609
|
+
/** True for `const name = await $memo(value)`: the render waits for the memo where it is declared. */
|
|
1610
|
+
awaited?: boolean;
|
|
1571
1611
|
/** For `const name = $id()`, the position of the call among the `$id` calls of its scope. */
|
|
1572
1612
|
idIndex?: number;
|
|
1573
1613
|
/** Elements whose `ref` targets this declaration. */
|
|
@@ -1585,6 +1625,12 @@ interface Reference {
|
|
|
1585
1625
|
tracked: boolean;
|
|
1586
1626
|
/** True inside a function that the site contains, such as an inline arrow function. */
|
|
1587
1627
|
inFunction: boolean;
|
|
1628
|
+
/**
|
|
1629
|
+
* For `await name` of a memo, the range of the whole `await` expression.
|
|
1630
|
+
* The render around the read waits for the memo, and the read compiles to
|
|
1631
|
+
* a plain read of its value.
|
|
1632
|
+
*/
|
|
1633
|
+
await?: Range;
|
|
1588
1634
|
}
|
|
1589
1635
|
type SiteKind = "setup" | "function" | "server-function" | "memo" | "effect" | "client" | "insert" | "attribute" | "event" | "prop" | "spread" | "tag" | "block" | "style" | "provide" | "title";
|
|
1590
1636
|
/** A place where code runs: a function, a statement or a markup expression. */
|
|
@@ -1610,6 +1656,11 @@ interface Site {
|
|
|
1610
1656
|
/** The element, component or listener of an attribute or event site. */
|
|
1611
1657
|
owner?: ElementNode | ComponentNode | DynamicTagNode | GlobalListenerNode;
|
|
1612
1658
|
event?: EventAttribute;
|
|
1659
|
+
/**
|
|
1660
|
+
* For a handler wrapped by `brumate/events`, such as `prevent(move, 'Enter')`,
|
|
1661
|
+
* the modifiers that `b-on` holds, such as `prevent(Enter)`.
|
|
1662
|
+
*/
|
|
1663
|
+
modifiers?: string[];
|
|
1613
1664
|
/** The block whose header this site is. */
|
|
1614
1665
|
block?: Block;
|
|
1615
1666
|
/** The trigger of a `$client` site. */
|
|
@@ -1618,6 +1669,13 @@ interface Site {
|
|
|
1618
1669
|
awaits: boolean;
|
|
1619
1670
|
/** More code of the site, such as the context of `$setContext(context, value)`. */
|
|
1620
1671
|
extra?: Node[];
|
|
1672
|
+
/**
|
|
1673
|
+
* For the function of `$handler(fn, ...args)`, the call, which the server
|
|
1674
|
+
* turns into a reference that a spread can pass on, with its arguments.
|
|
1675
|
+
*/
|
|
1676
|
+
handler?: CallExpression;
|
|
1677
|
+
/** For the function of `$bind(name, fn)`, the call, which passes it as the setter of the binding. */
|
|
1678
|
+
setter?: CallExpression;
|
|
1621
1679
|
}
|
|
1622
1680
|
type Severity = "error" | "warning";
|
|
1623
1681
|
interface Diagnostic {
|
|
@@ -1631,6 +1689,13 @@ interface SemanticModel {
|
|
|
1631
1689
|
scopes: Scope[];
|
|
1632
1690
|
declarations: Declaration[];
|
|
1633
1691
|
sites: Site[];
|
|
1692
|
+
/** The `$bind(name)` calls, with the declaration of their name. */
|
|
1693
|
+
/** The `$bind` calls, with the declaration of their name and the site of their setter. */
|
|
1694
|
+
bindings: {
|
|
1695
|
+
call: CallExpression;
|
|
1696
|
+
declaration: Declaration;
|
|
1697
|
+
setter?: Site;
|
|
1698
|
+
}[];
|
|
1634
1699
|
diagnostics: Diagnostic[];
|
|
1635
1700
|
}
|
|
1636
1701
|
/** Returns true if `scope` is `ancestor` or inside it. */
|
|
@@ -1733,33 +1798,6 @@ export declare function printModel(source: string, model: SemanticModel): string
|
|
|
1733
1798
|
/** Prints the graph: nodes, what is live, what runs on the client and which scopes it creates. */
|
|
1734
1799
|
export declare function printGraph(source: string, graph: Graph): string;
|
|
1735
1800
|
//#endregion
|
|
1736
|
-
//#region src/modules.d.ts
|
|
1737
|
-
/** A module of reactive logic, read by its path. */
|
|
1738
|
-
interface ReactiveModule {
|
|
1739
|
-
/** The absolute path of the module. */
|
|
1740
|
-
path: string;
|
|
1741
|
-
source: string;
|
|
1742
|
-
}
|
|
1743
|
-
/** Finds a module that a file imports, or returns undefined if it cannot. */
|
|
1744
|
-
type ResolveModule = (specifier: string, importer: string) => ReactiveModule | undefined;
|
|
1745
|
-
/** What a name of a module function is in the component that calls it. */
|
|
1746
|
-
type CallName = {
|
|
1747
|
-
name: string;
|
|
1748
|
-
} | {
|
|
1749
|
-
literal: string;
|
|
1750
|
-
};
|
|
1751
|
-
//#endregion
|
|
1752
|
-
//#region src/sourcemap.d.ts
|
|
1753
|
-
/** A source map, version 3. */
|
|
1754
|
-
interface SourceMap {
|
|
1755
|
-
version: 3;
|
|
1756
|
-
file: string;
|
|
1757
|
-
sources: string[];
|
|
1758
|
-
sourcesContent: string[];
|
|
1759
|
-
names: string[];
|
|
1760
|
-
mappings: string;
|
|
1761
|
-
}
|
|
1762
|
-
//#endregion
|
|
1763
1801
|
//#region src/css.d.ts
|
|
1764
1802
|
interface StyleOutput {
|
|
1765
1803
|
/** The scoped CSS of every `<style>` block, or an empty string. */
|
|
@@ -1818,6 +1856,8 @@ interface Plan {
|
|
|
1818
1856
|
bodyScopes: Map<Body, Scope>;
|
|
1819
1857
|
/** The anchor index of a node within its scope. */
|
|
1820
1858
|
anchors: Map<AnchorTarget, number>;
|
|
1859
|
+
/** The scope of each anchor, for the devtools, which find an element by its scope and anchor. */
|
|
1860
|
+
anchorScopes: Map<AnchorTarget, Scope>;
|
|
1821
1861
|
/**
|
|
1822
1862
|
* Inserts that are the only content of their element. They share the
|
|
1823
1863
|
* element's anchor and update its children, so they have no markers.
|
|
@@ -1850,6 +1890,40 @@ interface Plan {
|
|
|
1850
1890
|
export declare function getComponentName(filename: string): string;
|
|
1851
1891
|
export declare function createPlan(file: SFCFile, graph: Graph, path?: string, hideNames?: boolean): Plan;
|
|
1852
1892
|
//#endregion
|
|
1893
|
+
//#region src/env-check.d.ts
|
|
1894
|
+
/**
|
|
1895
|
+
* The names of the server variables that an import gives, such as
|
|
1896
|
+
* `import env from './env.ts'`, or undefined for other imports.
|
|
1897
|
+
*/
|
|
1898
|
+
type EnvImport = (specifier: string, name: string) => string[] | undefined;
|
|
1899
|
+
//#endregion
|
|
1900
|
+
//#region src/modules.d.ts
|
|
1901
|
+
/** A module of reactive logic, read by its path. */
|
|
1902
|
+
interface ReactiveModule {
|
|
1903
|
+
/** The absolute path of the module. */
|
|
1904
|
+
path: string;
|
|
1905
|
+
source: string;
|
|
1906
|
+
}
|
|
1907
|
+
/** Finds a module that a file imports, or returns undefined if it cannot. */
|
|
1908
|
+
type ResolveModule = (specifier: string, importer: string) => ReactiveModule | undefined;
|
|
1909
|
+
/** What a name of a module function is in the component that calls it. */
|
|
1910
|
+
type CallName = {
|
|
1911
|
+
name: string;
|
|
1912
|
+
} | {
|
|
1913
|
+
literal: string;
|
|
1914
|
+
};
|
|
1915
|
+
//#endregion
|
|
1916
|
+
//#region src/sourcemap.d.ts
|
|
1917
|
+
/** A source map, version 3. */
|
|
1918
|
+
interface SourceMap {
|
|
1919
|
+
version: 3;
|
|
1920
|
+
file: string;
|
|
1921
|
+
sources: string[];
|
|
1922
|
+
sourcesContent: string[];
|
|
1923
|
+
names: string[];
|
|
1924
|
+
mappings: string;
|
|
1925
|
+
}
|
|
1926
|
+
//#endregion
|
|
1853
1927
|
//#region src/compile.d.ts
|
|
1854
1928
|
interface CompileOptions {
|
|
1855
1929
|
/** Used for error messages, the component name and the component ID. */
|
|
@@ -1875,6 +1949,25 @@ interface CompileOptions {
|
|
|
1875
1949
|
* server function calls `refresh` with it. The Vite plugin passes it.
|
|
1876
1950
|
*/
|
|
1877
1951
|
serverImport?: (specifier: string, name: string) => string | undefined;
|
|
1952
|
+
/**
|
|
1953
|
+
* The names of the server functions that the project passes to
|
|
1954
|
+
* `refresh`, from `refreshedNames`. A memo that calls an imported server
|
|
1955
|
+
* function outside it renders on the server only. Without it, any imported
|
|
1956
|
+
* server function can be refreshed.
|
|
1957
|
+
*/
|
|
1958
|
+
refreshed?: ReadonlySet<string>;
|
|
1959
|
+
/**
|
|
1960
|
+
* The names of the server environment variables that an import gives,
|
|
1961
|
+
* such as `import env from './env.ts'`, or undefined for other imports.
|
|
1962
|
+
* Code that runs in the browser cannot read them. The Vite plugin passes
|
|
1963
|
+
* it for the imports that resolve to the env file.
|
|
1964
|
+
*/
|
|
1965
|
+
envImport?: EnvImport;
|
|
1966
|
+
/**
|
|
1967
|
+
* Classes that the plugins of the serial entry send, such as `Money`, so a
|
|
1968
|
+
* signal can hold an instance. The Vite plugin reads them from the entry.
|
|
1969
|
+
*/
|
|
1970
|
+
sendableClasses?: readonly string[];
|
|
1878
1971
|
/**
|
|
1879
1972
|
* Server function IDs use a hash of each function's name instead of the
|
|
1880
1973
|
* name, so the browser does not see it. The Vite plugin sets it in builds.
|
|
@@ -2086,5 +2179,5 @@ export declare function inspect(source: string, options?: InspectOptions): {
|
|
|
2086
2179
|
text: string;
|
|
2087
2180
|
};
|
|
2088
2181
|
//#endregion
|
|
2089
|
-
export type { AnchorTarget, Attribute, Block, Body, Branch, CheckMapping, CheckOutput, ClientBlock, ClientTrigger, CompileOptions, CompileResult, ComponentNode, ComponentUsage, ComputedAttribute, Declaration, DeclarationKind, Diagnostic, DynamicTagNode, Edge, ElementNode, EventAttribute, Expression, ForBlock, FragmentNode, GlobalListenerNode, Graph, GraphNode, GraphOptions, HeadBlock, IfBlock, InsertNode, InspectEntry, InspectOptions, InspectReport, KeyBlock, LoadingBlock, Location, Markup, Modifier, OffscreenBlock, ParseOptions, Plan, PortalBlock, PrefetchAttribute, PrefetchStrategy, ProjectProps, Range, ReactiveModule, RefAttribute, Reference, RepeatBlock, Resolve, ResolveModule, SFCFile, Scope, ScopeKind, ScopePlan, Script, SemanticModel, Severity, SharedSite, Site, SiteKind, SourceMap, SpreadAttribute, StaticAttribute, Style, SwitchBlock, TemplateDecl, TextNode, TryBlock, ValueAttribute, upstreamMemos };
|
|
2182
|
+
export type { AnchorTarget, Attribute, Block, Body, Branch, CheckMapping, CheckOutput, ClientBlock, ClientTrigger, CompileOptions, CompileResult, ComponentNode, ComponentUsage, ComputedAttribute, Declaration, DeclarationKind, DeferBlock, Diagnostic, DynamicTagNode, Edge, ElementNode, EventAttribute, Expression, ForBlock, FragmentNode, GlobalListenerNode, Graph, GraphNode, GraphOptions, HeadBlock, IfBlock, InsertNode, InspectEntry, InspectOptions, InspectReport, KeyBlock, LoadingBlock, Location, Markup, Modifier, OffscreenBlock, ParseOptions, Plan, PortalBlock, PrefetchAttribute, PrefetchStrategy, ProjectProps, Range, ReactiveModule, RefAttribute, Reference, RepeatBlock, Resolve, ResolveModule, Reveal, RevealOrder, SFCFile, Scope, ScopeKind, ScopePlan, Script, SemanticModel, Severity, SharedSite, Site, SiteKind, SourceMap, SpreadAttribute, StaticAttribute, Style, SwitchBlock, TemplateDecl, TextNode, TryBlock, ValueAttribute, upstreamMemos };
|
|
2090
2183
|
//# sourceMappingURL=index.d.ts.map
|