1 | import {
|
2 | SimpleElement,
|
3 | SimpleNode,
|
4 | SimpleText,
|
5 | SimpleComment,
|
6 | SimpleDocumentFragment,
|
7 | AttrNamespace,
|
8 | } from '@simple-dom/interface';
|
9 | import { Option, Maybe } from '../core';
|
10 | import { Bounds, Cursor } from './bounds';
|
11 | import { ElementOperations, Environment, ModifierInstance } from '../runtime';
|
12 | import { GlimmerTreeConstruction, GlimmerTreeChanges } from './changes';
|
13 | import { Stack } from '../stack';
|
14 | import { InternalModifierManager } from '../managers';
|
15 |
|
16 | export interface LiveBlock extends Bounds {
|
17 | openElement(element: SimpleElement): void;
|
18 | closeElement(): void;
|
19 | didAppendNode(node: SimpleNode): void;
|
20 | didAppendBounds(bounds: Bounds): void;
|
21 | finalize(stack: ElementBuilder): void;
|
22 | }
|
23 |
|
24 | export interface SimpleLiveBlock extends LiveBlock {
|
25 | parentElement(): SimpleElement;
|
26 | firstNode(): SimpleNode;
|
27 | lastNode(): SimpleNode;
|
28 | }
|
29 |
|
30 | export interface RemoteLiveBlock extends SimpleLiveBlock {}
|
31 |
|
32 | export interface UpdatableBlock extends SimpleLiveBlock {
|
33 | reset(env: Environment): Option<SimpleNode>;
|
34 | }
|
35 |
|
36 | export interface DOMStack {
|
37 | pushRemoteElement(
|
38 | element: SimpleElement,
|
39 | guid: string,
|
40 | insertBefore: Maybe<SimpleNode>
|
41 | ): Option<RemoteLiveBlock>;
|
42 | popRemoteElement(): void;
|
43 | popElement(): void;
|
44 | openElement(tag: string, _operations?: ElementOperations): SimpleElement;
|
45 | flushElement(modifiers: Option<ModifierInstance[]>): void;
|
46 | appendText(string: string): SimpleText;
|
47 | appendComment(string: string): SimpleComment;
|
48 |
|
49 | appendDynamicHTML(value: string): void;
|
50 | appendDynamicText(value: string): SimpleText;
|
51 | appendDynamicFragment(value: SimpleDocumentFragment): void;
|
52 | appendDynamicNode(value: SimpleNode): void;
|
53 |
|
54 | setStaticAttribute(name: string, value: string, namespace: Option<string>): void;
|
55 | setDynamicAttribute(
|
56 | name: string,
|
57 | value: unknown,
|
58 | isTrusting: boolean,
|
59 | namespace: Option<string>
|
60 | ): AttributeOperation;
|
61 |
|
62 | closeElement(): Option<ModifierInstance[]>;
|
63 | }
|
64 |
|
65 | export interface TreeOperations {
|
66 | __openElement(tag: string): SimpleElement;
|
67 | __flushElement(parent: SimpleElement, constructing: SimpleElement): void;
|
68 | __openBlock(): void;
|
69 | __closeBlock(): void;
|
70 | __appendText(text: string): SimpleText;
|
71 | __appendComment(string: string): SimpleComment;
|
72 | __appendNode(node: SimpleNode): SimpleNode;
|
73 | __appendHTML(html: string): Bounds;
|
74 | __setAttribute(name: string, value: string, namespace: Option<string>): void;
|
75 | __setProperty(name: string, value: unknown): void;
|
76 | }
|
77 |
|
78 | declare const CURSOR_STACK: unique symbol;
|
79 | export type CursorStackSymbol = typeof CURSOR_STACK;
|
80 |
|
81 | export interface ElementBuilder extends Cursor, DOMStack, TreeOperations {
|
82 | [CURSOR_STACK]: Stack<Cursor>;
|
83 |
|
84 | nextSibling: Option<SimpleNode>;
|
85 | dom: GlimmerTreeConstruction;
|
86 | updateOperations: GlimmerTreeChanges;
|
87 | constructing: Option<SimpleElement>;
|
88 | element: SimpleElement;
|
89 |
|
90 | hasBlocks: boolean;
|
91 | debugBlocks(): LiveBlock[];
|
92 |
|
93 | pushSimpleBlock(): LiveBlock;
|
94 | pushUpdatableBlock(): UpdatableBlock;
|
95 | pushBlockList(list: Bounds[]): LiveBlock;
|
96 | popBlock(): LiveBlock;
|
97 |
|
98 | didAppendBounds(bounds: Bounds): void;
|
99 | }
|
100 |
|
101 | export interface AttributeCursor {
|
102 | element: SimpleElement;
|
103 | name: string;
|
104 | namespace: Option<AttrNamespace>;
|
105 | }
|
106 |
|
107 | export interface AttributeOperation {
|
108 | attribute: AttributeCursor;
|
109 | set(dom: ElementBuilder, value: unknown, env: Environment): void;
|
110 | update(value: unknown, env: Environment): void;
|
111 | }
|