@hyperfixi/engine 3.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/CHANGELOG.md +921 -0
- package/LICENSE +20 -0
- package/README.md +272 -0
- package/dist/additions.d.ts +30 -0
- package/dist/ast.d.ts +277 -0
- package/dist/commands/animation.d.ts +34 -0
- package/dist/commands/control.d.ts +36 -0
- package/dist/commands/dom-more.d.ts +68 -0
- package/dist/commands/dom.d.ts +50 -0
- package/dist/commands/events.d.ts +25 -0
- package/dist/commands/js.d.ts +22 -0
- package/dist/commands/loops.d.ts +34 -0
- package/dist/commands/misc.d.ts +36 -0
- package/dist/commands/morph.d.ts +18 -0
- package/dist/commands/pick.d.ts +22 -0
- package/dist/commands/platform.d.ts +44 -0
- package/dist/commands/setters.d.ts +38 -0
- package/dist/common.js +3020 -0
- package/dist/common.min.js +17 -0
- package/dist/conversions.d.ts +6 -0
- package/dist/cookies.d.ts +10 -0
- package/dist/core.js +2190 -0
- package/dist/core.min.js +17 -0
- package/dist/engine.d.ts +79 -0
- package/dist/everything.d.ts +2 -0
- package/dist/expressions-extra.d.ts +2 -0
- package/dist/expressions.d.ts +51 -0
- package/dist/features.d.ts +47 -0
- package/dist/full.js +5673 -0
- package/dist/full.min.js +19 -0
- package/dist/hyperfixi-hs.dev.js +5676 -0
- package/dist/hyperfixi-hs.js +19 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +5737 -0
- package/dist/live-templates.d.ts +3 -0
- package/dist/minimal.js +2580 -0
- package/dist/minimal.min.js +17 -0
- package/dist/on.d.ts +39 -0
- package/dist/parser.d.ts +97 -0
- package/dist/reactivity.d.ts +30 -0
- package/dist/runtime.d.ts +160 -0
- package/dist/statements.d.ts +24 -0
- package/dist/templates.d.ts +61 -0
- package/dist/tokenizer.d.ts +25 -0
- package/dist/util.d.ts +34 -0
- package/package.json +60 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rest of the DOM commands: `hide` / `show`, `take`, `measure`, `make`,
|
|
3
|
+
* `append`, `swap`, and the family that applies one action to a target
|
|
4
|
+
* (`focus`, `blur`, `select`, `empty` / `clear`, `reset`, `open`, `close`).
|
|
5
|
+
* Follows upstream `parsetree/commands/dom.js`, `basic.js` and `setters.js`.
|
|
6
|
+
*/
|
|
7
|
+
import type { AttributeRefNode, ClassRefNode, Cmd, Expr } from '../ast';
|
|
8
|
+
import type { Grammar } from '../parser';
|
|
9
|
+
export interface VisibilityNode extends Cmd {
|
|
10
|
+
type: 'hideCommand' | 'showCommand';
|
|
11
|
+
target: Expr;
|
|
12
|
+
/** `with <strategy>`: display (default), visibility, opacity, hidden, or a configured one. */
|
|
13
|
+
strategy?: string;
|
|
14
|
+
/** `show … with display:inline-block`: the value to show with. */
|
|
15
|
+
arg?: string;
|
|
16
|
+
when?: Expr;
|
|
17
|
+
}
|
|
18
|
+
export declare function hideShow(g: Grammar): void;
|
|
19
|
+
export interface TakeNode extends Cmd {
|
|
20
|
+
type: 'takeCommand';
|
|
21
|
+
classRefs: ClassRefNode[];
|
|
22
|
+
attributeRef?: AttributeRefNode;
|
|
23
|
+
from?: Expr;
|
|
24
|
+
for: Expr;
|
|
25
|
+
/** `with` / `giving`: what the elements that lose the class or attribute get instead. */
|
|
26
|
+
replacementClass?: ClassRefNode;
|
|
27
|
+
replacementValue?: Expr;
|
|
28
|
+
}
|
|
29
|
+
/** `take .class [with .other] [from <others> [giving .other]] [for <target>]`, or the same with `@attr`. */
|
|
30
|
+
export declare function take(g: Grammar): void;
|
|
31
|
+
export interface MeasureNode extends Cmd {
|
|
32
|
+
type: 'measureCommand';
|
|
33
|
+
target: Expr;
|
|
34
|
+
properties: string[];
|
|
35
|
+
}
|
|
36
|
+
/** `measure [<target>'s] [x, y, width, …]`: the result holds every measurement; named ones also become locals. */
|
|
37
|
+
export declare function measure(g: Grammar): void;
|
|
38
|
+
export interface TargetNode extends Cmd {
|
|
39
|
+
type: string;
|
|
40
|
+
/** Absent means `me`. */
|
|
41
|
+
target?: Expr;
|
|
42
|
+
}
|
|
43
|
+
export declare function targetCommands(g: Grammar): void;
|
|
44
|
+
export declare function openClose(g: Grammar): void;
|
|
45
|
+
export interface MakeNode extends Cmd {
|
|
46
|
+
type: 'makeCommand';
|
|
47
|
+
/** `<tag#id.class/>`, or a constructor. */
|
|
48
|
+
value: Expr;
|
|
49
|
+
args: Expr[];
|
|
50
|
+
/** `called <name>`. */
|
|
51
|
+
called?: Expr;
|
|
52
|
+
}
|
|
53
|
+
export declare function make(g: Grammar): void;
|
|
54
|
+
export interface AppendNode extends Cmd {
|
|
55
|
+
type: 'appendCommand';
|
|
56
|
+
value: Expr;
|
|
57
|
+
/** Absent means the result (`it`). */
|
|
58
|
+
target?: Expr;
|
|
59
|
+
}
|
|
60
|
+
/** `append <value> [to <target>]`: push to a list, add to a set, add content to an element, or concatenate. */
|
|
61
|
+
export declare function append(g: Grammar): void;
|
|
62
|
+
export interface SwapNode extends Cmd {
|
|
63
|
+
type: 'swapCommand';
|
|
64
|
+
first: Expr;
|
|
65
|
+
second: Expr;
|
|
66
|
+
}
|
|
67
|
+
/** `swap <a> with <b>`: exchange two values, or two elements' places in the document. */
|
|
68
|
+
export declare function swap(g: Grammar): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `add`, `remove`, `toggle`. Follows upstream `parsetree/commands/dom.js`.
|
|
3
|
+
*/
|
|
4
|
+
import type { AttributeRefNode, ClassRefNode, Cmd, Expr, StyleLiteralNode } from '../ast';
|
|
5
|
+
import type { Grammar, Parser } from '../parser';
|
|
6
|
+
export interface AddNode extends Cmd {
|
|
7
|
+
type: 'addCommand';
|
|
8
|
+
classRefs?: ClassRefNode[];
|
|
9
|
+
attributeRef?: AttributeRefNode;
|
|
10
|
+
css?: StyleLiteralNode;
|
|
11
|
+
/** `add <value> to <array or set>`. */
|
|
12
|
+
value?: Expr;
|
|
13
|
+
to: Expr;
|
|
14
|
+
when?: Expr;
|
|
15
|
+
}
|
|
16
|
+
export declare function add(g: Grammar): void;
|
|
17
|
+
export interface RemoveNode extends Cmd {
|
|
18
|
+
type: 'removeCommand';
|
|
19
|
+
classRefs?: ClassRefNode[];
|
|
20
|
+
attributeRef?: AttributeRefNode;
|
|
21
|
+
css?: StyleLiteralNode;
|
|
22
|
+
/** `remove <element>` or `remove <item> from <collection>`. */
|
|
23
|
+
element?: Expr;
|
|
24
|
+
from?: Expr;
|
|
25
|
+
when?: Expr;
|
|
26
|
+
}
|
|
27
|
+
export declare function remove(g: Grammar): void;
|
|
28
|
+
export type Visibility = (op: 'hide' | 'show' | 'toggle', elt: HTMLElement, arg?: string) => void;
|
|
29
|
+
export declare const strategies: Record<string, Visibility>;
|
|
30
|
+
/** The strategy named in `with <name>`, the configured default, or `display`. */
|
|
31
|
+
export declare function strategy(p: Parser, name?: string): Visibility;
|
|
32
|
+
export interface ToggleNode extends Cmd {
|
|
33
|
+
type: 'toggleCommand';
|
|
34
|
+
classRefs?: ClassRefNode[];
|
|
35
|
+
/** `toggle between .a and .b` / `toggle between @a and @b`. */
|
|
36
|
+
between?: [ClassRefNode, ClassRefNode] | [AttributeRefNode, AttributeRefNode];
|
|
37
|
+
attributeRef?: AttributeRefNode;
|
|
38
|
+
/** `toggle *display`. */
|
|
39
|
+
styleProp?: string;
|
|
40
|
+
/** `toggle <assignable> between <values>`. */
|
|
41
|
+
target?: Expr;
|
|
42
|
+
betweenValues?: Expr[];
|
|
43
|
+
on?: Expr;
|
|
44
|
+
/** `for <duration>`. */
|
|
45
|
+
time?: Expr;
|
|
46
|
+
/** `until <event> [from <source>]`. */
|
|
47
|
+
until?: string;
|
|
48
|
+
from?: Expr;
|
|
49
|
+
}
|
|
50
|
+
export declare function toggle(g: Grammar): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `send` / `trigger` and `wait`. Follows upstream `parsetree/commands/events.js`.
|
|
3
|
+
*/
|
|
4
|
+
import type { Cmd, Expr, NamedArgsNode } from '../ast';
|
|
5
|
+
import type { Grammar } from '../parser';
|
|
6
|
+
export interface SendNode extends Cmd {
|
|
7
|
+
type: 'sendCommand';
|
|
8
|
+
event: string;
|
|
9
|
+
details?: NamedArgsNode;
|
|
10
|
+
to: Expr;
|
|
11
|
+
}
|
|
12
|
+
/** `send <event>[(details)] [to <target>]`; `trigger` is the same with `on`. */
|
|
13
|
+
export declare function send(g: Grammar): void;
|
|
14
|
+
export interface WaitNode extends Cmd {
|
|
15
|
+
type: 'waitCommand';
|
|
16
|
+
/** `wait <duration>`. */
|
|
17
|
+
time?: Expr;
|
|
18
|
+
/** `wait for <event>[(args)] or <duration> … [from <source>]`. */
|
|
19
|
+
events?: ({
|
|
20
|
+
event: string;
|
|
21
|
+
args: string[];
|
|
22
|
+
} | Expr)[];
|
|
23
|
+
from?: Expr;
|
|
24
|
+
}
|
|
25
|
+
export declare function wait(g: Grammar): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `js … end`: inline JavaScript, as a command and as a top-level feature.
|
|
3
|
+
* Follows upstream `parsetree/commands/execution.js` and `features/js.js`.
|
|
4
|
+
*
|
|
5
|
+
* This is the one module that compiles source with `Function`. A bundle for a
|
|
6
|
+
* page with a strict Content-Security-Policy leaves it out.
|
|
7
|
+
*/
|
|
8
|
+
import type { Cmd, Feature } from '../ast';
|
|
9
|
+
import type { Grammar } from '../parser';
|
|
10
|
+
export interface JsNode extends Cmd {
|
|
11
|
+
type: 'jsCommand';
|
|
12
|
+
source: string;
|
|
13
|
+
/** Hyperscript variables passed in as parameters: `js(x, y) … end`. */
|
|
14
|
+
inputs: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface JsFeature extends Feature {
|
|
17
|
+
type: 'jsFeature';
|
|
18
|
+
source: string;
|
|
19
|
+
/** Function declarations the block exposes as globals. */
|
|
20
|
+
functions: string[];
|
|
21
|
+
}
|
|
22
|
+
export declare function js(g: Grammar): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `repeat` / `for`, `break`, `continue`, `tell`. Follows upstream
|
|
3
|
+
* `parsetree/commands/controlflow.js`.
|
|
4
|
+
*/
|
|
5
|
+
import type { Cmd, Expr } from '../ast';
|
|
6
|
+
import type { Grammar } from '../parser';
|
|
7
|
+
export interface RepeatNode extends Cmd {
|
|
8
|
+
type: 'repeatCommand';
|
|
9
|
+
/** `for x in <expression>`; `repeat in <expression>` binds `it`. */
|
|
10
|
+
identifier?: string;
|
|
11
|
+
indexIdentifier?: string;
|
|
12
|
+
expression?: Expr;
|
|
13
|
+
times?: Expr;
|
|
14
|
+
/** `while <cond>` or `until <cond>`; `bottomTested` when it follows the body. */
|
|
15
|
+
condition?: Expr;
|
|
16
|
+
until: boolean;
|
|
17
|
+
bottomTested: boolean;
|
|
18
|
+
forever: boolean;
|
|
19
|
+
/** `until event <name> [from <source>]`. */
|
|
20
|
+
event?: string;
|
|
21
|
+
from?: Expr;
|
|
22
|
+
body: Cmd[];
|
|
23
|
+
elseBranch?: Cmd[];
|
|
24
|
+
}
|
|
25
|
+
export declare function repeat(g: Grammar): void;
|
|
26
|
+
/** `break` and `continue`: signals the enclosing loop acts on. */
|
|
27
|
+
export declare function loopControl(g: Grammar): void;
|
|
28
|
+
export interface TellNode extends Cmd {
|
|
29
|
+
type: 'tellCommand';
|
|
30
|
+
value: Expr;
|
|
31
|
+
body: Cmd[];
|
|
32
|
+
}
|
|
33
|
+
/** `tell <targets> <commands> [end]`: run the body once per target, with `you` bound to it. */
|
|
34
|
+
export declare function tell(g: Grammar): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `log`, `call` / `get`, and the pseudo-command (`foo()` or `me.focus()` used as
|
|
3
|
+
* a statement). Follows upstream `basic.js`, `execution.js`, `pseudoCommand.js`.
|
|
4
|
+
*/
|
|
5
|
+
import type { Cmd, Expr } from '../ast';
|
|
6
|
+
import type { Grammar } from '../parser';
|
|
7
|
+
export interface LogNode extends Cmd {
|
|
8
|
+
type: 'logCommand';
|
|
9
|
+
values: Expr[];
|
|
10
|
+
/** `log x with console.warn`. */
|
|
11
|
+
logger?: Expr;
|
|
12
|
+
}
|
|
13
|
+
export declare function log(g: Grammar): void;
|
|
14
|
+
export interface GetNode extends Cmd {
|
|
15
|
+
type: 'getCommand';
|
|
16
|
+
value: Expr;
|
|
17
|
+
}
|
|
18
|
+
/** `get <expr>` / `call <function call>`: evaluate and keep the value as `it`. */
|
|
19
|
+
export declare function get_(g: Grammar): void;
|
|
20
|
+
export interface PseudoNode extends Cmd {
|
|
21
|
+
type: 'pseudoCommand';
|
|
22
|
+
value: Expr;
|
|
23
|
+
/** `reload() the location`: the call's receiver, written after it. */
|
|
24
|
+
target?: Expr;
|
|
25
|
+
}
|
|
26
|
+
export declare function pseudoCommand(g: Grammar): void;
|
|
27
|
+
export interface AskNode extends Cmd {
|
|
28
|
+
type: 'askCommand' | 'answerCommand';
|
|
29
|
+
message: Expr;
|
|
30
|
+
/** `answer … with <a> or <b>`: the two choices of a confirmation. */
|
|
31
|
+
choices?: [Expr, Expr];
|
|
32
|
+
}
|
|
33
|
+
/** `ask <message>` prompts; `answer <message> [with <a> or <b>]` alerts or confirms. */
|
|
34
|
+
export declare function askAnswer(g: Grammar): void;
|
|
35
|
+
/** `breakpoint`: stop in the debugger. */
|
|
36
|
+
export declare function breakpoint(g: Grammar): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `morph <target> to <content>`: change an element's tree into another, keeping the
|
|
3
|
+
* nodes that can be kept, so identity, focus and listeners survive.
|
|
4
|
+
*
|
|
5
|
+
* The algorithm follows upstream `core/runtime/morph.js` (itself the htmx 4 morph by
|
|
6
|
+
* Michael West). Nodes are matched by id first, then by shape; a node with an id that
|
|
7
|
+
* appears on both sides is moved rather than rebuilt.
|
|
8
|
+
*/
|
|
9
|
+
import type { Cmd, Expr } from '../ast';
|
|
10
|
+
import type { Grammar } from '../parser';
|
|
11
|
+
/** Morph `old` to match `content`: an HTML string, an element or a fragment. */
|
|
12
|
+
export declare function morphTo(old: Element, content: unknown): void;
|
|
13
|
+
export interface MorphNode extends Cmd {
|
|
14
|
+
type: 'morphCommand';
|
|
15
|
+
target: Expr;
|
|
16
|
+
content: Expr;
|
|
17
|
+
}
|
|
18
|
+
export declare function morph(g: Grammar): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pick`: take part of a list or string, or match a regular expression.
|
|
3
|
+
* Follows upstream `parsetree/commands/basic.js`.
|
|
4
|
+
*/
|
|
5
|
+
import type { Cmd, Expr } from '../ast';
|
|
6
|
+
import type { Grammar } from '../parser';
|
|
7
|
+
export interface PickNode extends Cmd {
|
|
8
|
+
type: 'pickCommand';
|
|
9
|
+
variant: 'first' | 'last' | 'random' | 'range' | 'match' | 'matches';
|
|
10
|
+
root: Expr;
|
|
11
|
+
/** How many, for first / last / random. */
|
|
12
|
+
count?: Expr;
|
|
13
|
+
/** Range bounds; `start` and `end` are the list's own ends. */
|
|
14
|
+
from?: Expr;
|
|
15
|
+
to?: Expr;
|
|
16
|
+
toEnd?: boolean;
|
|
17
|
+
/** `inclusive` includes the end index; `exclusive` skips the start index. */
|
|
18
|
+
bounds?: 'inclusive' | 'exclusive';
|
|
19
|
+
re?: Expr;
|
|
20
|
+
flags?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function pick(g: Grammar): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fetch`, `go`, `scroll`. Follows upstream `parsetree/commands/basic.js`.
|
|
3
|
+
*/
|
|
4
|
+
import type { Cmd, Expr } from '../ast';
|
|
5
|
+
import type { Grammar } from '../parser';
|
|
6
|
+
export interface FetchNode extends Cmd {
|
|
7
|
+
type: 'fetchCommand';
|
|
8
|
+
url: Expr;
|
|
9
|
+
options?: Expr;
|
|
10
|
+
/** How the response becomes the result: text (default), json, html, the response itself, or a named conversion. */
|
|
11
|
+
as: string;
|
|
12
|
+
dontThrow: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** `fetch <url> [as <type>] [with <options>] [as <type>] [do not throw]`. */
|
|
15
|
+
export declare function fetchCommand(g: Grammar): void;
|
|
16
|
+
interface ScrollSpec {
|
|
17
|
+
target: Expr;
|
|
18
|
+
offset?: Expr;
|
|
19
|
+
/** +1 or -1 when an offset follows the target. */
|
|
20
|
+
sign: number;
|
|
21
|
+
options: ScrollIntoViewOptions;
|
|
22
|
+
container?: Expr;
|
|
23
|
+
}
|
|
24
|
+
export interface ScrollNode extends Cmd {
|
|
25
|
+
type: 'scrollCommand';
|
|
26
|
+
/** `scroll to …`. */
|
|
27
|
+
to?: ScrollSpec;
|
|
28
|
+
/** `scroll [<target>] [up|down|left|right] by <n> [px]`. */
|
|
29
|
+
target?: Expr;
|
|
30
|
+
direction?: string;
|
|
31
|
+
by?: Expr;
|
|
32
|
+
behavior?: ScrollBehavior;
|
|
33
|
+
}
|
|
34
|
+
export declare function scroll(g: Grammar): void;
|
|
35
|
+
export interface GoNode extends Cmd {
|
|
36
|
+
type: 'goCommand';
|
|
37
|
+
back: boolean;
|
|
38
|
+
target?: Expr;
|
|
39
|
+
scroll?: ScrollSpec;
|
|
40
|
+
newWindow: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** `go back`, `go to url <url> [in new window]`, `go to <url or element>`, `go to the top of <element>`. */
|
|
43
|
+
export declare function go(g: Grammar): void;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `set`, `increment`, `decrement`, `put`. Follows upstream `parsetree/commands/setters.js`.
|
|
3
|
+
*
|
|
4
|
+
* Every write goes through the target expression's own `lhs` / `put` pair, so a
|
|
5
|
+
* command never inspects what kind of expression it was given.
|
|
6
|
+
*/
|
|
7
|
+
import type { Cmd, Expr, ObjectNode } from '../ast';
|
|
8
|
+
import type { Grammar, Parser } from '../parser';
|
|
9
|
+
export interface SetNode extends Cmd {
|
|
10
|
+
type: 'setCommand';
|
|
11
|
+
target: Expr;
|
|
12
|
+
value?: Expr;
|
|
13
|
+
/** `set { … } on <target>`: copy the object's properties onto the target. */
|
|
14
|
+
object?: ObjectNode;
|
|
15
|
+
}
|
|
16
|
+
export declare function set(g: Grammar): void;
|
|
17
|
+
export declare function parseSet(p: Parser, start: number): SetNode;
|
|
18
|
+
export interface DefaultNode extends Cmd {
|
|
19
|
+
type: 'defaultCommand';
|
|
20
|
+
target: Expr;
|
|
21
|
+
value: Expr;
|
|
22
|
+
}
|
|
23
|
+
/** `default <target> to <value>`: assign only when the target is null, undefined or empty. */
|
|
24
|
+
export declare function defaultCommand(g: Grammar): void;
|
|
25
|
+
export interface StepNode extends Cmd {
|
|
26
|
+
type: 'incrementCommand' | 'decrementCommand';
|
|
27
|
+
target: Expr;
|
|
28
|
+
amount?: Expr;
|
|
29
|
+
}
|
|
30
|
+
/** `increment` and `decrement`: the same rule with the sign flipped. */
|
|
31
|
+
export declare function increment(g: Grammar): void;
|
|
32
|
+
export interface PutNode extends Cmd {
|
|
33
|
+
type: 'putCommand';
|
|
34
|
+
value: Expr;
|
|
35
|
+
operation: 'into' | 'before' | 'after' | 'start' | 'end';
|
|
36
|
+
target: Expr;
|
|
37
|
+
}
|
|
38
|
+
export declare function put(g: Grammar): void;
|