@mintjamsinc/ichigojs 0.1.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/LICENSE +21 -0
- package/README.md +292 -0
- package/dist/ichigo.esm.js +9517 -0
- package/dist/ichigo.esm.js.map +1 -0
- package/dist/ichigo.esm.min.js +2 -0
- package/dist/ichigo.esm.min.js.map +1 -0
- package/dist/ichigo.umd.js +9525 -0
- package/dist/ichigo.umd.js.map +1 -0
- package/dist/ichigo.umd.min.js +2 -0
- package/dist/ichigo.umd.min.js.map +1 -0
- package/dist/types/ichigo/VApplication.d.ts +66 -0
- package/dist/types/ichigo/VApplicationOptions.d.ts +28 -0
- package/dist/types/ichigo/VBindings.d.ts +9 -0
- package/dist/types/ichigo/VBindingsPreparer.d.ts +23 -0
- package/dist/types/ichigo/VCloser.d.ts +9 -0
- package/dist/types/ichigo/VComponent.d.ts +2 -0
- package/dist/types/ichigo/VComponentRegistry.d.ts +2 -0
- package/dist/types/ichigo/VDOM.d.ts +30 -0
- package/dist/types/ichigo/VDOMUpdater.d.ts +17 -0
- package/dist/types/ichigo/VNode.d.ts +102 -0
- package/dist/types/ichigo/VNodeInit.d.ts +29 -0
- package/dist/types/ichigo/VTextEvaluator.d.ts +29 -0
- package/dist/types/ichigo/VUpdateContext.d.ts +21 -0
- package/dist/types/ichigo/components/VComponent.d.ts +2 -0
- package/dist/types/ichigo/components/VComponentRegistry.d.ts +2 -0
- package/dist/types/ichigo/directives/StandardDirectiveName.d.ts +10 -0
- package/dist/types/ichigo/directives/VBindDirective.d.ts +61 -0
- package/dist/types/ichigo/directives/VBindingsPreparer.d.ts +24 -0
- package/dist/types/ichigo/directives/VConditionalDirective.d.ts +47 -0
- package/dist/types/ichigo/directives/VConditionalDirectiveContext.d.ts +19 -0
- package/dist/types/ichigo/directives/VDOMUpdater.d.ts +17 -0
- package/dist/types/ichigo/directives/VDirective.d.ts +48 -0
- package/dist/types/ichigo/directives/VDirectiveManager.d.ts +39 -0
- package/dist/types/ichigo/directives/VDirectiveParseContext.d.ts +19 -0
- package/dist/types/ichigo/directives/VDirectiveParser.d.ts +31 -0
- package/dist/types/ichigo/directives/VDirectiveParserRegistry.d.ts +26 -0
- package/dist/types/ichigo/directives/VElseDirective.d.ts +21 -0
- package/dist/types/ichigo/directives/VElseIfDirective.d.ts +20 -0
- package/dist/types/ichigo/directives/VForDirective.d.ts +51 -0
- package/dist/types/ichigo/directives/VIfDirective.d.ts +20 -0
- package/dist/types/ichigo/directives/VModelDirective.d.ts +47 -0
- package/dist/types/ichigo/directives/VOnDirective.d.ts +49 -0
- package/dist/types/ichigo/directives/VShowDirective.d.ts +57 -0
- package/dist/types/ichigo/directives/VStandardDirectiveParser.d.ts +20 -0
- package/dist/types/ichigo/util/BindingsUtils.d.ts +10 -0
- package/dist/types/ichigo/util/ExpressionUtils.d.ts +15 -0
- package/dist/types/ichigo/util/LogLevel.d.ts +9 -0
- package/dist/types/ichigo/util/ReactiveProxy.d.ts +34 -0
- package/dist/types/ichigo/util/VLogLevel.d.ts +9 -0
- package/dist/types/ichigo/util/VLogManager.d.ts +9 -0
- package/dist/types/ichigo/util/VLogger.d.ts +9 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +64 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
import { VLogManager } from "./util/VLogManager";
|
2
|
+
import { VApplicationOptions } from "./VApplicationOptions";
|
3
|
+
import { VBindings } from "./VBindings";
|
4
|
+
import { VNode } from "./VNode";
|
5
|
+
import type { VDirectiveParserRegistry } from "./directives/VDirectiveParserRegistry";
|
6
|
+
import { VComponentRegistry } from "./components/VComponentRegistry";
|
7
|
+
/**
|
8
|
+
* Represents a virtual application instance.
|
9
|
+
*/
|
10
|
+
export declare class VApplication {
|
11
|
+
#private;
|
12
|
+
/**
|
13
|
+
* Creates an instance of the virtual application.
|
14
|
+
* @param options The application options.
|
15
|
+
* @param directiveParserRegistry The global directive parser registry.
|
16
|
+
* @param componentRegistry The global component registry.
|
17
|
+
*/
|
18
|
+
constructor(options: VApplicationOptions, directiveParserRegistry: VDirectiveParserRegistry, componentRegistry: VComponentRegistry);
|
19
|
+
/**
|
20
|
+
* Gets the global directive parser registry.
|
21
|
+
*/
|
22
|
+
get directiveParserRegistry(): VDirectiveParserRegistry;
|
23
|
+
/**
|
24
|
+
* Gets the global component registry.
|
25
|
+
*/
|
26
|
+
get componentRegistry(): VComponentRegistry;
|
27
|
+
/**
|
28
|
+
* Gets the root virtual node.
|
29
|
+
*/
|
30
|
+
get rootVNode(): VNode | undefined;
|
31
|
+
/**
|
32
|
+
* Gets the bindings for the virtual application.
|
33
|
+
*/
|
34
|
+
get bindings(): VBindings;
|
35
|
+
/**
|
36
|
+
* Gets the log manager.
|
37
|
+
*/
|
38
|
+
get logManager(): VLogManager;
|
39
|
+
/**
|
40
|
+
* Gets the function dependencies for the virtual application.
|
41
|
+
*/
|
42
|
+
get functionDependencies(): Record<string, string[]>;
|
43
|
+
/**
|
44
|
+
* Gets the list of identifiers that can trigger updates.
|
45
|
+
*/
|
46
|
+
get preparableIdentifiers(): string[];
|
47
|
+
/**
|
48
|
+
* Mounts the application.
|
49
|
+
* @param selectors The CSS selectors to identify the root element.
|
50
|
+
*/
|
51
|
+
mount(selectors: string): void;
|
52
|
+
/**
|
53
|
+
* Schedules a DOM update in the next microtask.
|
54
|
+
* Multiple calls within the same event loop will be batched into a single update.
|
55
|
+
*/
|
56
|
+
scheduleUpdate(): void;
|
57
|
+
/**
|
58
|
+
* Executes an immediate DOM update.
|
59
|
+
*/
|
60
|
+
update(): void;
|
61
|
+
/**
|
62
|
+
* Executes a callback after the next DOM update.
|
63
|
+
* @param callback The callback to execute.
|
64
|
+
*/
|
65
|
+
nextTick(callback: () => void): void;
|
66
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { LogLevel } from "./util/LogLevel";
|
2
|
+
export interface VApplicationOptions {
|
3
|
+
/**
|
4
|
+
* A function that returns the initial data for the application.
|
5
|
+
* @returns The initial data for the application.
|
6
|
+
*/
|
7
|
+
data: () => unknown;
|
8
|
+
/**
|
9
|
+
* A dictionary of computed properties for the application.
|
10
|
+
* Each key is the name of the computed property, and the value is a function that computes its value.
|
11
|
+
*/
|
12
|
+
computed?: {
|
13
|
+
[key: string]: () => unknown;
|
14
|
+
};
|
15
|
+
/**
|
16
|
+
* A dictionary of methods for the application.
|
17
|
+
* Each key is the name of the method, and the value is a function that implements the method.
|
18
|
+
*/
|
19
|
+
methods?: {
|
20
|
+
[key: string]: (...args: unknown[]) => unknown;
|
21
|
+
};
|
22
|
+
/**
|
23
|
+
* The log level for the application.
|
24
|
+
* This property determines the verbosity of logging output.
|
25
|
+
* If not specified, the default log level will be used.
|
26
|
+
*/
|
27
|
+
logLevel?: LogLevel;
|
28
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { VBindings } from "./VBindings";
|
2
|
+
/**
|
3
|
+
* Interface representing a preparer for VBindings in the virtual DOM.
|
4
|
+
*/
|
5
|
+
export interface VBindingsPreparer {
|
6
|
+
/**
|
7
|
+
* The list of identifiers that this preparer is concerned with.
|
8
|
+
* These identifiers are used to determine when the bindings need to be prepared.
|
9
|
+
*/
|
10
|
+
get identifiers(): string[];
|
11
|
+
/**
|
12
|
+
* The list of identifiers that can be prepared by this preparer.
|
13
|
+
* This is a subset of the identifiers property.
|
14
|
+
*/
|
15
|
+
get preparableIdentifiers(): string[];
|
16
|
+
/**
|
17
|
+
* Prepares the given VBindings for use in the virtual DOM.
|
18
|
+
* This method is called before the bindings are applied to the DOM.
|
19
|
+
* It allows for any necessary transformations or initializations of the bindings.
|
20
|
+
* @param bindings The original VBindings to be prepared.
|
21
|
+
*/
|
22
|
+
prepareBindings(bindings: VBindings): void;
|
23
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { VComponentRegistry } from './components/VComponentRegistry';
|
2
|
+
import { VDirectiveParserRegistry } from './directives/VDirectiveParserRegistry';
|
3
|
+
import { VApplication } from './VApplication';
|
4
|
+
/**
|
5
|
+
* The main entry point for the virtual DOM library.
|
6
|
+
*/
|
7
|
+
export declare class VDOM {
|
8
|
+
#private;
|
9
|
+
/**
|
10
|
+
* Gets the component registry.
|
11
|
+
* @return {VComponentRegistry} The component registry.
|
12
|
+
*/
|
13
|
+
static get componentRegistry(): VComponentRegistry;
|
14
|
+
/**
|
15
|
+
* Gets the directive parser registry.
|
16
|
+
* @return {VDirectiveParserRegistry} The directive parser registry.
|
17
|
+
*/
|
18
|
+
static get directiveParserRegistry(): VDirectiveParserRegistry;
|
19
|
+
/**
|
20
|
+
* Checks if the current environment supports the required features.
|
21
|
+
* @return {boolean} True if supported, false otherwise.
|
22
|
+
*/
|
23
|
+
static get isSupported(): boolean;
|
24
|
+
/**
|
25
|
+
* Creates a virtual application instance.
|
26
|
+
* @param options The options for the virtual application.
|
27
|
+
* @returns The created virtual application instance.
|
28
|
+
*/
|
29
|
+
static createApp(options: any): VApplication;
|
30
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* Interface representing an updater for the virtual DOM.
|
3
|
+
* An implementation of this interface is responsible for applying changes
|
4
|
+
* from the virtual DOM to the actual DOM.
|
5
|
+
*/
|
6
|
+
export interface VDOMUpdater {
|
7
|
+
/**
|
8
|
+
* A list of variable and function names that this updater is concerned with.
|
9
|
+
* Changes to these identifiers may trigger the updater to apply changes to the DOM.
|
10
|
+
*/
|
11
|
+
get identifiers(): string[];
|
12
|
+
/**
|
13
|
+
* Applies the changes from the virtual DOM to the actual DOM.
|
14
|
+
* This method is called when the identifiers change or when an update is needed.
|
15
|
+
*/
|
16
|
+
applyToDOM(): void;
|
17
|
+
}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import { VApplication } from "./VApplication";
|
2
|
+
import { VBindings } from "./VBindings";
|
3
|
+
import { VCloser } from "./VCloser";
|
4
|
+
import { VDirectiveManager } from "./directives/VDirectiveManager";
|
5
|
+
import { VNodeInit } from "./VNodeInit";
|
6
|
+
import { VUpdateContext } from "./VUpdateContext";
|
7
|
+
export declare class VNode {
|
8
|
+
#private;
|
9
|
+
/**
|
10
|
+
* Creates an instance of the virtual node.
|
11
|
+
* @param args The initialization arguments for the virtual node.
|
12
|
+
*/
|
13
|
+
constructor(args: VNodeInit);
|
14
|
+
/**
|
15
|
+
* The application instance associated with this virtual node.
|
16
|
+
*/
|
17
|
+
get vApplication(): VApplication;
|
18
|
+
/**
|
19
|
+
* The node associated with this virtual node.
|
20
|
+
*/
|
21
|
+
get node(): Node;
|
22
|
+
/**
|
23
|
+
* The type of the node associated with this virtual node.
|
24
|
+
*/
|
25
|
+
get nodeType(): number;
|
26
|
+
/**
|
27
|
+
* The name of the node associated with this virtual node.
|
28
|
+
*/
|
29
|
+
get nodeName(): string;
|
30
|
+
/**
|
31
|
+
* The parent virtual node, if any.
|
32
|
+
* This is optional and may be undefined for the root node.
|
33
|
+
*/
|
34
|
+
get parentVNode(): VNode | undefined;
|
35
|
+
/**
|
36
|
+
* The child virtual nodes, if any.
|
37
|
+
* This is optional and may be undefined if there are no child nodes.
|
38
|
+
*/
|
39
|
+
get childVNodes(): VNode[] | undefined;
|
40
|
+
/**
|
41
|
+
* The previous sibling virtual node, if any.
|
42
|
+
* This is optional and may be undefined if there is no previous sibling.
|
43
|
+
*/
|
44
|
+
get previousSibling(): VNode | undefined;
|
45
|
+
/**
|
46
|
+
* The next sibling virtual node, if any.
|
47
|
+
* This is optional and may be undefined if there is no next sibling.
|
48
|
+
*/
|
49
|
+
get nextSibling(): VNode | undefined;
|
50
|
+
/**
|
51
|
+
* The data bindings associated with this virtual node, if any.
|
52
|
+
*/
|
53
|
+
get bindings(): VBindings | undefined;
|
54
|
+
/**
|
55
|
+
* The directive manager associated with this virtual node.
|
56
|
+
* This manages any directives applied to the node.
|
57
|
+
*/
|
58
|
+
get directiveManager(): VDirectiveManager | undefined;
|
59
|
+
/**
|
60
|
+
* The anchor comment node used to mark the position of the element in the DOM.
|
61
|
+
* This is used for directives that may remove the element from the DOM,
|
62
|
+
* allowing it to be re-inserted at the correct position later.
|
63
|
+
* This is optional and may be undefined if not applicable.
|
64
|
+
*/
|
65
|
+
get anchorNode(): Comment | undefined;
|
66
|
+
/**
|
67
|
+
* Indicates whether the node is currently in the DOM.
|
68
|
+
* This checks if the node has a parent that is not a document fragment.
|
69
|
+
* @return True if the node is in the DOM, otherwise false.
|
70
|
+
*/
|
71
|
+
get isInDOM(): boolean;
|
72
|
+
/**
|
73
|
+
* Indicates whether this virtual node is the root node (i.e., has no parent).
|
74
|
+
* @return True if this is the root node, otherwise false.
|
75
|
+
*/
|
76
|
+
get isRoot(): boolean;
|
77
|
+
/**
|
78
|
+
* The list of identifiers for this virtual node.
|
79
|
+
* This includes variable and function names used in expressions.
|
80
|
+
*/
|
81
|
+
get identifiers(): string[];
|
82
|
+
get preparableIdentifiers(): string[];
|
83
|
+
/**
|
84
|
+
* Updates the virtual node and its children based on the current bindings.
|
85
|
+
* This method evaluates any expressions in text nodes and applies effectors from directives.
|
86
|
+
* It also recursively updates child virtual nodes.
|
87
|
+
* @param context The context for the update operation.
|
88
|
+
*/
|
89
|
+
update(context: VUpdateContext): void;
|
90
|
+
/**
|
91
|
+
* Adds a dependency on the specified virtual node.
|
92
|
+
* This means that if the specified node's bindings change, this node may need to be updated.
|
93
|
+
* @param dependentNode The virtual node to add as a dependency.
|
94
|
+
* @returns A list of closers to unregister the dependency, or undefined if no dependency was added.
|
95
|
+
*/
|
96
|
+
addDependency(dependentNode: VNode): VCloser[] | undefined;
|
97
|
+
/**
|
98
|
+
* Cleans up any resources used by this virtual node.
|
99
|
+
* This method is called when the virtual node is no longer needed.
|
100
|
+
*/
|
101
|
+
destroy(): void;
|
102
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { VApplication } from "./VApplication";
|
2
|
+
import { VBindings } from "./VBindings";
|
3
|
+
import { VBindingsPreparer } from "./VBindingsPreparer";
|
4
|
+
import { VNode } from "./VNode";
|
5
|
+
/**
|
6
|
+
* Initialization arguments for a virtual node.
|
7
|
+
*/
|
8
|
+
export interface VNodeInit {
|
9
|
+
/**
|
10
|
+
* The DOM node associated with this virtual node.
|
11
|
+
*/
|
12
|
+
node: Node;
|
13
|
+
/**
|
14
|
+
* The virtual application instance this node belongs to.
|
15
|
+
*/
|
16
|
+
vApplication: VApplication;
|
17
|
+
/**
|
18
|
+
* The parent virtual node, if any.
|
19
|
+
*/
|
20
|
+
parentVNode?: VNode;
|
21
|
+
/**
|
22
|
+
* The data bindings associated with this virtual node.
|
23
|
+
*/
|
24
|
+
bindings: VBindings;
|
25
|
+
/**
|
26
|
+
* The preparer for VBindings, if any.
|
27
|
+
*/
|
28
|
+
bindingsPreparer?: VBindingsPreparer;
|
29
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { VBindings } from "./VBindings";
|
2
|
+
/**
|
3
|
+
* A class to evaluate text with embedded expressions in the form of {{...}}.
|
4
|
+
* It extracts identifiers from the expressions and evaluates them using provided bindings.
|
5
|
+
*/
|
6
|
+
export declare class VTextEvaluator {
|
7
|
+
#private;
|
8
|
+
/**
|
9
|
+
* Constructs a VTextEvaluator instance.
|
10
|
+
* @param text The text containing embedded expressions in the form of {{...}}.
|
11
|
+
* @param functionDependencies A dictionary mapping function names to their dependencies.
|
12
|
+
*/
|
13
|
+
constructor(text: string, functionDependencies: Record<string, string[]>);
|
14
|
+
/**
|
15
|
+
* Checks if the given text contains any expressions in the form of {{...}}.
|
16
|
+
* @param text The text to check.
|
17
|
+
* @returns True if the text contains expressions, false otherwise.
|
18
|
+
*/
|
19
|
+
static containsExpression(text: string): boolean;
|
20
|
+
/**
|
21
|
+
* Gets the list of identifiers extracted from the text expressions.
|
22
|
+
*/
|
23
|
+
get identifiers(): string[];
|
24
|
+
/**
|
25
|
+
* Evaluates the text with the provided bindings and returns the resulting string.
|
26
|
+
* @param bindings The bindings to use for evaluating the expressions.
|
27
|
+
*/
|
28
|
+
evaluate(bindings: VBindings): string;
|
29
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { VBindings } from "./VBindings";
|
2
|
+
/**
|
3
|
+
* Context provided during the update of the virtual DOM.
|
4
|
+
* This context includes the current bindings and a list of identifiers that have changed.
|
5
|
+
*/
|
6
|
+
export interface VUpdateContext {
|
7
|
+
/**
|
8
|
+
* The current bindings.
|
9
|
+
*/
|
10
|
+
bindings: VBindings;
|
11
|
+
/**
|
12
|
+
* A list of variable and function names whose values have changed.
|
13
|
+
*/
|
14
|
+
changedIdentifiers: string[];
|
15
|
+
/**
|
16
|
+
* Indicates if this is the initial update.
|
17
|
+
* This flag is true when the update is being performed for the first time after the VNode's creation.
|
18
|
+
* It can be used to optimize rendering or initialization logic that should only run once.
|
19
|
+
*/
|
20
|
+
isInitial?: boolean;
|
21
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { VNode } from "../VNode";
|
2
|
+
import { VBindingsPreparer } from "../VBindingsPreparer";
|
3
|
+
import { VDirective } from "./VDirective";
|
4
|
+
import { VDirectiveParseContext } from "./VDirectiveParseContext";
|
5
|
+
import { VDOMUpdater } from "../VDOMUpdater";
|
6
|
+
/**
|
7
|
+
* Directive for binding dynamic attributes to DOM elements.
|
8
|
+
* The `v-bind` directive allows you to bind HTML attributes to expressions in your data model.
|
9
|
+
* The syntax for using the `v-bind` directive is `v-bind:attribute="expression"`, where `attribute` is the name of the HTML attribute you want to bind (e.g., `src`, `href`, `class`, etc.), and `expression` is a JavaScript expression that evaluates to the value you want to assign to that attribute.
|
10
|
+
* Example usage:
|
11
|
+
* <img v-bind:src="imageSrc" />
|
12
|
+
* The value of `imageSrc` should be defined in the component's data object.
|
13
|
+
* When the value of `imageSrc` changes, the `src` attribute of the `<img>` element will automatically update to reflect the new value.
|
14
|
+
* This directive is particularly useful for dynamically updating attributes based on user interactions or other data changes in your application.
|
15
|
+
* It helps keep the DOM in sync with the underlying data model, making it easier to build reactive user interfaces.
|
16
|
+
* The `v-bind` directive can also be used with shorthand syntax using a colon (:).
|
17
|
+
* For example, `:src="imageSrc"` is equivalent to `v-bind:src="imageSrc"`.
|
18
|
+
* This shorthand syntax is often used for brevity and improved readability in templates.
|
19
|
+
* Overall, the `v-bind` directive is a powerful tool for creating dynamic and responsive web applications by allowing seamless integration between the data model and the DOM.
|
20
|
+
*/
|
21
|
+
export declare class VBindDirective implements VDirective {
|
22
|
+
#private;
|
23
|
+
/**
|
24
|
+
* @param context The context for parsing the directive.
|
25
|
+
*/
|
26
|
+
constructor(context: VDirectiveParseContext);
|
27
|
+
/**
|
28
|
+
* @inheritdoc
|
29
|
+
*/
|
30
|
+
get name(): string;
|
31
|
+
/**
|
32
|
+
* @inheritdoc
|
33
|
+
*/
|
34
|
+
get vNode(): VNode;
|
35
|
+
/**
|
36
|
+
* @inheritdoc
|
37
|
+
*/
|
38
|
+
get needsAnchor(): boolean;
|
39
|
+
/**
|
40
|
+
* @inheritdoc
|
41
|
+
*/
|
42
|
+
get bindingsPreparer(): VBindingsPreparer | undefined;
|
43
|
+
/**
|
44
|
+
* @inheritdoc
|
45
|
+
*/
|
46
|
+
get domUpdater(): VDOMUpdater | undefined;
|
47
|
+
/**
|
48
|
+
* Indicates if this directive is binding the "key" attribute.
|
49
|
+
* The "key" attribute is special and is used for optimizing rendering of lists.
|
50
|
+
* If this directive is binding the "key" attribute, it will be handled by the VForDirective.
|
51
|
+
*/
|
52
|
+
get isKey(): boolean;
|
53
|
+
/**
|
54
|
+
* Gets the original expression string from the directive.
|
55
|
+
*/
|
56
|
+
get expression(): string | undefined;
|
57
|
+
/**
|
58
|
+
* @inheritdoc
|
59
|
+
*/
|
60
|
+
destroy(): void;
|
61
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { VBindings } from "../VBindings";
|
2
|
+
/**
|
3
|
+
* Interface representing a preparer for VBindings in the virtual DOM.
|
4
|
+
*/
|
5
|
+
export interface VBindingsPreparer {
|
6
|
+
/**
|
7
|
+
* The list of identifiers that this preparer is concerned with.
|
8
|
+
* These identifiers are used to determine when the bindings need to be prepared.
|
9
|
+
*/
|
10
|
+
get identifiers(): string[];
|
11
|
+
/**
|
12
|
+
* The list of identifiers that can be prepared by this preparer.
|
13
|
+
* This is a subset of the identifiers property.
|
14
|
+
*/
|
15
|
+
get preparableIdentifiers(): string[];
|
16
|
+
/**
|
17
|
+
* Prepares the VBindings for the virtual node.
|
18
|
+
* This method is called before the bindings are applied to the DOM.
|
19
|
+
* It allows for any necessary transformations or initializations of the bindings.
|
20
|
+
* @param bindings The original VBindings to be prepared.
|
21
|
+
* @returns The prepared VBindings.
|
22
|
+
*/
|
23
|
+
prepareBindings(bindings: VBindings): VBindings;
|
24
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { VNode } from "../VNode";
|
2
|
+
import { VBindingsPreparer } from "../VBindingsPreparer";
|
3
|
+
import { VConditionalDirectiveContext } from "./VConditionalDirectiveContext";
|
4
|
+
import { VDirective } from "./VDirective";
|
5
|
+
import { VDirectiveParseContext } from "./VDirectiveParseContext";
|
6
|
+
import { VDOMUpdater } from "../VDOMUpdater";
|
7
|
+
export declare abstract class VConditionalDirective implements VDirective {
|
8
|
+
#private;
|
9
|
+
/**
|
10
|
+
* @param context The context for parsing the directive.
|
11
|
+
*/
|
12
|
+
constructor(context: VDirectiveParseContext);
|
13
|
+
/**
|
14
|
+
* @inheritdoc
|
15
|
+
*/
|
16
|
+
abstract get name(): string;
|
17
|
+
/**
|
18
|
+
* @inheritdoc
|
19
|
+
*/
|
20
|
+
get vNode(): VNode;
|
21
|
+
/**
|
22
|
+
* @inheritdoc
|
23
|
+
*/
|
24
|
+
get needsAnchor(): boolean;
|
25
|
+
/**
|
26
|
+
* @inheritdoc
|
27
|
+
*/
|
28
|
+
get bindingsPreparer(): VBindingsPreparer | undefined;
|
29
|
+
/**
|
30
|
+
* @inheritdoc
|
31
|
+
*/
|
32
|
+
get domUpdater(): VDOMUpdater | undefined;
|
33
|
+
/**
|
34
|
+
* The context for managing related conditional directives (v-if, v-else-if, v-else).
|
35
|
+
*/
|
36
|
+
get conditionalContext(): VConditionalDirectiveContext;
|
37
|
+
/**
|
38
|
+
* Indicates whether the condition for this directive is currently met.
|
39
|
+
* For v-if and v-else-if, this depends on the evaluation of their expressions.
|
40
|
+
* For v-else, this is always true.
|
41
|
+
*/
|
42
|
+
get conditionIsMet(): boolean;
|
43
|
+
/**
|
44
|
+
* @inheritdoc
|
45
|
+
*/
|
46
|
+
destroy(): void;
|
47
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { VConditionalDirective } from "./VConditionalDirective";
|
2
|
+
/**
|
3
|
+
* Context for managing related conditional directives (v-if, v-else-if, v-else).
|
4
|
+
*/
|
5
|
+
export declare class VConditionalDirectiveContext {
|
6
|
+
#private;
|
7
|
+
/**
|
8
|
+
* Adds a directive (v-else-if or v-else) to the conditional context.
|
9
|
+
* @param directive The directive to add.
|
10
|
+
*/
|
11
|
+
addDirective(directive: VConditionalDirective): void;
|
12
|
+
/**
|
13
|
+
* Checks if any preceding directive's condition is met.
|
14
|
+
* This is used to determine if a v-else-if or v-else directive should be rendered.
|
15
|
+
* @param directive The directive to check against.
|
16
|
+
* @returns True if any preceding directive's condition is met, otherwise false.
|
17
|
+
*/
|
18
|
+
isPrecedingConditionMet(directive: VConditionalDirective): boolean;
|
19
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* Interface representing an updater for the virtual DOM.
|
3
|
+
* An implementation of this interface is responsible for applying changes
|
4
|
+
* from the virtual DOM to the actual DOM.
|
5
|
+
*/
|
6
|
+
export interface VDOMUpdater {
|
7
|
+
/**
|
8
|
+
* A list of variable and function names that this updater is concerned with.
|
9
|
+
* Changes to these identifiers may trigger the updater to apply changes to the DOM.
|
10
|
+
*/
|
11
|
+
get identifiers(): string[];
|
12
|
+
/**
|
13
|
+
* Applies the changes from the virtual DOM to the actual DOM.
|
14
|
+
* This method is called when the identifiers change or when an update is needed.
|
15
|
+
*/
|
16
|
+
applyToDOM(): void;
|
17
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import { VNode } from "../VNode";
|
2
|
+
import { VBindingsPreparer } from "../VBindingsPreparer";
|
3
|
+
import { VDOMUpdater } from "../VDOMUpdater";
|
4
|
+
/**
|
5
|
+
* Interface representing a directive in the virtual DOM.
|
6
|
+
*/
|
7
|
+
export interface VDirective {
|
8
|
+
/**
|
9
|
+
* The name of the directive (e.g., "v-if", "v-for").
|
10
|
+
*/
|
11
|
+
get name(): string;
|
12
|
+
/**
|
13
|
+
* The virtual node to which this directive is applied.
|
14
|
+
*/
|
15
|
+
get vNode(): VNode;
|
16
|
+
/**
|
17
|
+
* Indicates whether this directive requires an anchor comment node for insertion/removal.
|
18
|
+
* This is typically true for directives that may remove the element from the DOM,
|
19
|
+
* such as v-if and v-for.
|
20
|
+
* If true, the VNode will create an anchor comment node to mark the position of the element in the DOM.
|
21
|
+
* This allows the element to be re-inserted at the correct position later.
|
22
|
+
* If false, no anchor node is created and the element remains in the DOM at all times.
|
23
|
+
* Directives that do not remove the element from the DOM should return false.
|
24
|
+
* This property is used by the VNode to determine whether to create an anchor node.
|
25
|
+
* It is also used by the VDOM to manage insertion and removal of nodes.
|
26
|
+
* Note: This property should be implemented as a getter to allow dynamic evaluation based on directive state.
|
27
|
+
*/
|
28
|
+
get needsAnchor(): boolean;
|
29
|
+
/**
|
30
|
+
* Gets the preparer for the VBindings associated with this directive.
|
31
|
+
* This preparer is responsible for preparing the bindings before they are applied to the DOM.
|
32
|
+
* For example, a directive may need to transform or filter the bindings based on its logic.
|
33
|
+
* If the directive does not need to prepare bindings, this may return undefined.
|
34
|
+
*/
|
35
|
+
get bindingsPreparer(): VBindingsPreparer | undefined;
|
36
|
+
/**
|
37
|
+
* Gets the updater for applying changes from the virtual DOM to the actual DOM.
|
38
|
+
* This updater is responsible for applying any changes made by the directive to the DOM.
|
39
|
+
* For example, a directive may need to show/hide elements, update attributes, etc.
|
40
|
+
* If the directive does not need to update the DOM, this may return undefined.
|
41
|
+
*/
|
42
|
+
get domUpdater(): VDOMUpdater | undefined;
|
43
|
+
/**
|
44
|
+
* Cleans up any resources used by the directive.
|
45
|
+
* This method is called when the directive is no longer needed.
|
46
|
+
*/
|
47
|
+
destroy(): void;
|
48
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { VDirective } from "./VDirective";
|
2
|
+
import { VNode } from "../VNode";
|
3
|
+
import { VBindingsPreparer } from "../VBindingsPreparer";
|
4
|
+
import { VDOMUpdater } from "../VDOMUpdater";
|
5
|
+
import { VBindDirective } from "./VBindDirective";
|
6
|
+
export declare class VDirectiveManager {
|
7
|
+
#private;
|
8
|
+
constructor(vNode: VNode);
|
9
|
+
/**
|
10
|
+
* The list of directives associated with the virtual node.
|
11
|
+
* This may be undefined if there are no directives.
|
12
|
+
*/
|
13
|
+
get directives(): VDirective[] | undefined;
|
14
|
+
/**
|
15
|
+
* The anchor comment node used for certain directives.
|
16
|
+
* This may be undefined if no directive requires an anchor.
|
17
|
+
*/
|
18
|
+
get anchorNode(): Comment | undefined;
|
19
|
+
/**
|
20
|
+
* The list of bindings preparers from the associated directives.
|
21
|
+
* This may be undefined if no directive provides a bindings preparer.
|
22
|
+
*/
|
23
|
+
get bindingsPreparers(): VBindingsPreparer[] | undefined;
|
24
|
+
/**
|
25
|
+
* The list of DOM updaters from the associated directives.
|
26
|
+
* This may be undefined if no directive provides a DOM updater.
|
27
|
+
*/
|
28
|
+
get domUpdaters(): VDOMUpdater[] | undefined;
|
29
|
+
/**
|
30
|
+
* Gets the directive that binds the ":key" or "v-bind:key" attribute, if any.
|
31
|
+
* This directive is special and is used for optimizing rendering of lists.
|
32
|
+
* If no such directive exists, this returns undefined.
|
33
|
+
*/
|
34
|
+
get keyDirective(): VBindDirective | undefined;
|
35
|
+
/**
|
36
|
+
* Cleans up any resources used by the directive handler.
|
37
|
+
*/
|
38
|
+
destroy(): void;
|
39
|
+
}
|