ferrovue 0.2.0 → 0.4.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/README.md +103 -15
- package/dist/attrs.d.ts +8 -42
- package/dist/attrs.js +148 -297
- package/dist/calls.d.ts +4 -0
- package/dist/calls.js +219 -0
- package/dist/children.d.ts +9 -0
- package/dist/children.js +273 -0
- package/dist/classes.d.ts +13 -0
- package/dist/classes.js +176 -0
- package/dist/cli.js +121 -27
- package/dist/client.d.ts +11 -2
- package/dist/client.js +45 -9
- package/dist/compiler.d.ts +4 -0
- package/dist/compiler.js +37 -90
- package/dist/component.js +19 -82
- package/dist/context.d.ts +6 -68
- package/dist/context.js +25 -38
- package/dist/diff.d.ts +1 -0
- package/dist/diff.js +68 -0
- package/dist/emitter.d.ts +0 -8
- package/dist/emitter.js +0 -12
- package/dist/expr.d.ts +0 -70
- package/dist/expr.js +30 -855
- package/dist/fallthrough.d.ts +9 -0
- package/dist/fallthrough.js +78 -0
- package/dist/fixture.d.ts +2 -1
- package/dist/fixture.js +37 -22
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/islands.d.ts +6 -0
- package/dist/islands.js +5 -0
- package/dist/lists.d.ts +0 -11
- package/dist/lists.js +4 -39
- package/dist/loops.d.ts +3 -0
- package/dist/loops.js +164 -0
- package/dist/model.d.ts +22 -130
- package/dist/model.js +37 -9
- package/dist/narrowing.d.ts +19 -0
- package/dist/narrowing.js +126 -0
- package/dist/numbers.d.ts +8 -0
- package/dist/numbers.js +73 -0
- package/dist/parens.d.ts +0 -27
- package/dist/parens.js +0 -44
- package/dist/plugin.d.ts +84 -0
- package/dist/plugin.js +26 -0
- package/dist/plugins/i18n.d.ts +23 -0
- package/dist/{i18n.js → plugins/i18n.js} +76 -19
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +8 -0
- package/dist/plugins/router-link.d.ts +8 -0
- package/dist/{router.js → plugins/router-link.js} +65 -57
- package/dist/plugins/router.d.ts +42 -0
- package/dist/plugins/router.js +256 -0
- package/dist/plugins/scoped.d.ts +12 -0
- package/dist/{scoped.js → plugins/scoped.js} +55 -20
- package/dist/plugins/shared-types.d.ts +2 -0
- package/dist/plugins/shared-types.js +7 -0
- package/dist/plugins/stores.d.ts +37 -0
- package/dist/plugins/stores.js +377 -0
- package/dist/plugins/teleport.d.ts +5 -0
- package/dist/plugins/teleport.js +55 -0
- package/dist/rust.d.ts +2 -5
- package/dist/rust.js +66 -161
- package/dist/script.d.ts +0 -6
- package/dist/script.js +22 -121
- package/dist/slots.d.ts +13 -0
- package/dist/slots.js +160 -0
- package/dist/strings.d.ts +13 -0
- package/dist/strings.js +208 -0
- package/dist/styles.d.ts +14 -0
- package/dist/styles.js +181 -0
- package/dist/template.d.ts +2 -40
- package/dist/template.js +40 -691
- package/dist/testing.d.ts +1 -0
- package/dist/testing.js +1 -8
- package/dist/types.d.ts +2 -0
- package/dist/typescript.d.ts +0 -13
- package/dist/typescript.js +8 -41
- package/dist/vite.d.ts +1 -0
- package/dist/vite.js +35 -14
- package/package.json +11 -2
- package/dist/i18n.d.ts +0 -27
- package/dist/router.d.ts +0 -17
- package/dist/scoped.d.ts +0 -10
- package/dist/stores.d.ts +0 -6
- package/dist/stores.js +0 -227
package/dist/emitter.d.ts
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
/** Statements, with adjacent literal pushes merged into one `push_str`. */
|
|
2
1
|
export declare class Emitter {
|
|
3
2
|
lines: string[];
|
|
4
|
-
/** Bytes of markup written once per render, part of what `render` reserves up front: the literal
|
|
5
|
-
* markup, and what the numbers written at run time are expected to take. */
|
|
6
3
|
literalBytes: number;
|
|
7
|
-
/** Rust expressions for the rest of the reservation: a loop's markup once per item. */
|
|
8
4
|
perItem: string[];
|
|
9
5
|
private pending;
|
|
10
6
|
private depth;
|
|
11
7
|
lit(s: string): void;
|
|
12
|
-
/** `bytes` more expected of a value written at run time. */
|
|
13
8
|
expect(bytes: number): void;
|
|
14
9
|
stmt(code: string): void;
|
|
15
10
|
open(code: string): void;
|
|
16
11
|
close(tail?: string): void;
|
|
17
|
-
/** Whether the lines from \`from\` on read \`name\`. Literals are skipped, so markup that happens to
|
|
18
|
-
* spell the name does not count, and so are fields of that name. */
|
|
19
12
|
reads(name: string, from: number): boolean;
|
|
20
|
-
/** Replace \`from\` with \`to\` in line \`index\`: an unused binding renamed to \`_\`. */
|
|
21
13
|
replace(index: number, from: string, to: string): void;
|
|
22
14
|
flush(): void;
|
|
23
15
|
}
|
package/dist/emitter.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
/* The Rust statements a render is written as. */
|
|
2
1
|
import { rustChar, rustStr } from "./model.js";
|
|
3
2
|
import { occurrences } from "./parens.js";
|
|
4
|
-
/** Statements, with adjacent literal pushes merged into one `push_str`. */
|
|
5
3
|
export class Emitter {
|
|
6
4
|
lines = [];
|
|
7
|
-
/** Bytes of markup written once per render, part of what `render` reserves up front: the literal
|
|
8
|
-
* markup, and what the numbers written at run time are expected to take. */
|
|
9
5
|
literalBytes = 0;
|
|
10
|
-
/** Rust expressions for the rest of the reservation: a loop's markup once per item. */
|
|
11
6
|
perItem = [];
|
|
12
7
|
pending = "";
|
|
13
8
|
depth = 1;
|
|
@@ -15,7 +10,6 @@ export class Emitter {
|
|
|
15
10
|
this.pending += s;
|
|
16
11
|
this.literalBytes += Buffer.byteLength(s);
|
|
17
12
|
}
|
|
18
|
-
/** `bytes` more expected of a value written at run time. */
|
|
19
13
|
expect(bytes) {
|
|
20
14
|
this.literalBytes += bytes;
|
|
21
15
|
}
|
|
@@ -31,19 +25,14 @@ export class Emitter {
|
|
|
31
25
|
this.flush();
|
|
32
26
|
this.depth--;
|
|
33
27
|
this.lines.push(" ".repeat(this.depth) + "}" + tail);
|
|
34
|
-
// `} else {` closes one block and opens the next.
|
|
35
28
|
if (tail.endsWith("{"))
|
|
36
29
|
this.depth++;
|
|
37
30
|
}
|
|
38
|
-
/** Whether the lines from \`from\` on read \`name\`. Literals are skipped, so markup that happens to
|
|
39
|
-
* spell the name does not count, and so are fields of that name. */
|
|
40
31
|
reads(name, from) {
|
|
41
32
|
this.flush();
|
|
42
33
|
return occurrences(this.lines.slice(from).join("\n"), name) > 0;
|
|
43
34
|
}
|
|
44
|
-
/** Replace \`from\` with \`to\` in line \`index\`: an unused binding renamed to \`_\`. */
|
|
45
35
|
replace(index, from, to) {
|
|
46
|
-
// A function, so a `$&` or `$'` in the generated text is not read as a replacement pattern.
|
|
47
36
|
this.lines[index] = this.lines[index].replace(from, () => to);
|
|
48
37
|
}
|
|
49
38
|
flush() {
|
|
@@ -51,7 +40,6 @@ export class Emitter {
|
|
|
51
40
|
return;
|
|
52
41
|
const text = this.pending;
|
|
53
42
|
this.pending = "";
|
|
54
|
-
// One character is pushed as a `char`.
|
|
55
43
|
const push = /^.$/su.test(text) ? `out.push(${rustChar(text)});` : `out.push_str(${rustStr(text)});`;
|
|
56
44
|
this.lines.push(" ".repeat(this.depth) + push);
|
|
57
45
|
}
|
package/dist/expr.d.ts
CHANGED
|
@@ -1,76 +1,6 @@
|
|
|
1
1
|
import { type Component, type N, type Scope, type Ty, type Val } from "./model.ts";
|
|
2
|
-
/** The refusal for a string that may hold half of a surrogate pair, used where that half matters. */
|
|
3
|
-
export declare function lonely(what: string): string;
|
|
4
|
-
/** Two strings meeting, where a half of a surrogate pair — which ferrovue holds as U+FFFD — would
|
|
5
|
-
* change the result:
|
|
6
|
-
* - `equal`: two halves may differ, and a half never equals a literal U+FFFD;
|
|
7
|
-
* - `order`: a half orders as a surrogate, below U+E000, where U+FFFD orders above — the same only
|
|
8
|
-
* against a literal of characters below U+D800, which both order after;
|
|
9
|
-
* - `search`: a half searched for (`b`) matches half of a whole pair in `a`;
|
|
10
|
-
* - `join`: two halves side by side join into one character.
|
|
11
|
-
* A string holding U+FFFD in the data still equals, or is found in, a half: README, "Strings". */
|
|
12
|
-
export declare function meet(comp: Component, a: Val, b: Val, what: string, n: N, how: "equal" | "order" | "search" | "join"): void;
|
|
13
|
-
/** Whether a string expression borrows from a temporary it builds — \`&*format!(…)\`, a call that
|
|
14
|
-
* returns a \`String\` — rather than from the props or the state. Such a borrow ends with the block
|
|
15
|
-
* it is in, so a branch of \`?:\` or \`||\` must hand back the string itself. */
|
|
16
|
-
export declare function isTemporary(v: Val): boolean;
|
|
17
|
-
/** A string as a \`Cow\`: borrowed when it lives on, owned when it is a temporary. The \`Cow\` is
|
|
18
|
-
* itself a temporary of the whole statement, so the \`&str\` taken from it lives to its end. A
|
|
19
|
-
* \`String\` built for the purpose is moved into it, and one that is already a \`Cow\` — a branch
|
|
20
|
-
* of \`?:\` or \`||\` — is taken as it is. */
|
|
21
|
-
export declare function asCow(v: Val): string;
|
|
22
|
-
/** Whether built code is a `Cow<str>` already: a runtime routine that borrows when it can
|
|
23
|
-
* (`js_slice`, `js_replace`, `js_pad_start`, …), or a fallback taken from one (`.unwrap_or(Cow…)`). */
|
|
24
|
-
export declare function yieldsCow(code: string): boolean;
|
|
25
|
-
/** Whether a value is a JavaScript number: an integer or a fraction. */
|
|
26
|
-
export declare function isNumber(ty: Ty): boolean;
|
|
27
|
-
/** A number as an `f64`, as JavaScript holds every number. */
|
|
28
|
-
export declare function asF64(v: Val): string;
|
|
29
|
-
/** A type as an error names it. */
|
|
30
2
|
export declare function describeTy(ty: Ty): string;
|
|
31
3
|
export declare function fieldVal(comp: Component, base: string, ty: Ty, js: string, node: N): Val;
|
|
32
|
-
/** A value's truthiness when it is known at generation time: a boolean constant, a string literal,
|
|
33
|
-
* a number JavaScript computed. */
|
|
34
|
-
export declare function known(v: Val): boolean | undefined;
|
|
35
|
-
export declare function truthy(v: Val): string;
|
|
36
|
-
/** A value passed where `want` is expected: a present value into an optional slot is wrapped. */
|
|
37
4
|
export declare function coerce(comp: Component, v: Val, want: Ty, node: N): string;
|
|
38
|
-
/** The JavaScript path an expression names — `$props.user`, `item.author.name` — or `null` when it
|
|
39
|
-
* is not a plain chain of names. */
|
|
40
|
-
export declare function pathOf(n: N): string | null;
|
|
41
|
-
/** A test that an optional value is present, as TypeScript narrows on it: `x`, `x !== undefined`,
|
|
42
|
-
* and, `negated`, `!x` and `x === undefined`, after which the value is present in the other branch. */
|
|
43
|
-
export interface Presence {
|
|
44
|
-
path: string;
|
|
45
|
-
/** The value bound where it is present, and its type there. */
|
|
46
|
-
pattern: (name: string) => string;
|
|
47
|
-
/** The `Option` the pattern matches: the value, or for a truthiness test only its truthy values. */
|
|
48
|
-
option: string;
|
|
49
|
-
/** The test alone, for a branch that never reads the value. */
|
|
50
|
-
present: string;
|
|
51
|
-
of: Ty;
|
|
52
|
-
negated: boolean;
|
|
53
|
-
/** Tested by truthiness, so the test itself is a boolean only when it is negated. */
|
|
54
|
-
truthy: boolean;
|
|
55
|
-
}
|
|
56
|
-
export declare function presence(s: Scope, n: N): Presence | null;
|
|
57
|
-
/** The scope with `p`'s value present, bound as `name`. */
|
|
58
|
-
export declare function narrowTo(s: Scope, p: Presence, name: string): Scope;
|
|
59
|
-
export declare function cond(s: Scope, n: N): string;
|
|
60
5
|
export declare function childOf(name: string): Component;
|
|
61
|
-
/** The reader's route, which the component then takes. */
|
|
62
|
-
export declare function theRoute(s: Scope, n: N): Val;
|
|
63
|
-
/** A field of the route: what `useRoute()` gives that the server knows as vue-router does. */
|
|
64
|
-
export declare function routeField(s: Scope, base: Val, prop: string, n: N): Val;
|
|
65
|
-
/** A Pinia getter read from a store's state, `prefs.doubled`: its expression, translated with the
|
|
66
|
-
* state it takes bound to that state. `null` when `name` is not a getter of that store. */
|
|
67
|
-
export declare function storeGetter(s: Scope, base: Val, name: string, node: N): Val | null;
|
|
68
|
-
/** A Rust string literal's text. */
|
|
69
|
-
export declare function unquote(literal: string): string;
|
|
70
6
|
export declare function expr(s: Scope, n: N): Val;
|
|
71
|
-
/** A boolean computed at run time, or known now when it folded to a constant. */
|
|
72
|
-
export declare function boolOf(code: string): Val;
|
|
73
|
-
export declare function call(s: Scope, n: N): Val;
|
|
74
|
-
/** Whether `n` is `Object.<method>(…)`. */
|
|
75
|
-
export declare function isObjectCall(n: N, method: string): boolean;
|
|
76
|
-
export declare function helperCall(s: Scope, name: string, args: N[], n: N): Val;
|