@mintjamsinc/ichigojs 0.1.82 → 0.1.84

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.
@@ -0,0 +1,118 @@
1
+ import { VBindings } from "./VBindings";
2
+ /**
3
+ * Options for expression evaluation.
4
+ */
5
+ export interface ExpressionEvaluatorOptions {
6
+ /**
7
+ * Additional context variables to be available in the expression (e.g., 'event', '$ctx').
8
+ */
9
+ additionalContext?: Record<string, any>;
10
+ /**
11
+ * If true, allows assignment expressions (e.g., "count++", "value = 10").
12
+ * This is used by VOnDirective to support inline assignments.
13
+ * Default: false
14
+ */
15
+ allowAssignment?: boolean;
16
+ /**
17
+ * A custom function to rewrite the expression before evaluation.
18
+ * This is used by VOnDirective to transform identifiers into 'this.identifier' form.
19
+ */
20
+ rewriteExpression?: (expression: string, identifiers: string[]) => string;
21
+ }
22
+ /**
23
+ * A centralized expression evaluator that normalizes expression evaluation across all directives.
24
+ *
25
+ * This class provides:
26
+ * - Consistent identifier extraction and binding resolution
27
+ * - Unified global object whitelisting (Math, Date, JSON, etc.)
28
+ * - Expression caching for performance
29
+ * - Centralized error handling
30
+ * - Support for custom expression rewriting (for VOnDirective)
31
+ *
32
+ * Example usage:
33
+ * ```typescript
34
+ * const evaluator = ExpressionEvaluator.create(
35
+ * "count + 1",
36
+ * bindings,
37
+ * functionDependencies
38
+ * );
39
+ * const result = evaluator.evaluate();
40
+ * ```
41
+ */
42
+ export declare class ExpressionEvaluator {
43
+ /**
44
+ * Cache for compiled expression functions.
45
+ * Key: expression string
46
+ * Value: compiled function
47
+ */
48
+ private static readonly cache;
49
+ /**
50
+ * Global objects that are whitelisted for use in expressions.
51
+ * These objects are available to all expressions for convenience and compatibility.
52
+ */
53
+ private static readonly GLOBAL_WHITELIST;
54
+ /**
55
+ * The original expression string.
56
+ */
57
+ private readonly expression;
58
+ /**
59
+ * The identifiers extracted from the expression.
60
+ */
61
+ private readonly identifiers;
62
+ /**
63
+ * The bindings to use for evaluating the expression.
64
+ */
65
+ private readonly bindings;
66
+ /**
67
+ * The compiled function for evaluating the expression.
68
+ */
69
+ private readonly evaluatorFunc;
70
+ /**
71
+ * Additional context variables (e.g., 'event', '$ctx').
72
+ */
73
+ private readonly additionalContext?;
74
+ /**
75
+ * Private constructor. Use ExpressionEvaluator.create() to create instances.
76
+ */
77
+ private constructor();
78
+ /**
79
+ * Creates an ExpressionEvaluator instance.
80
+ *
81
+ * @param expression The expression string to evaluate.
82
+ * @param bindings The bindings to use for evaluating the expression.
83
+ * @param functionDependencies A dictionary mapping function names to their dependencies.
84
+ * @param options Optional configuration for the evaluator.
85
+ * @returns An ExpressionEvaluator instance.
86
+ */
87
+ static create(expression: string, bindings: VBindings, functionDependencies: Record<string, string[]>, options?: ExpressionEvaluatorOptions): ExpressionEvaluator;
88
+ /**
89
+ * Compiles an expression into a function.
90
+ *
91
+ * @param expression The expression string to compile.
92
+ * @param identifiers The identifiers extracted from the expression.
93
+ * @param options Optional configuration.
94
+ * @returns A compiled function.
95
+ */
96
+ private static compileExpression;
97
+ /**
98
+ * Evaluates the expression with the current bindings.
99
+ *
100
+ * @returns The result of the expression evaluation.
101
+ */
102
+ evaluate(): any;
103
+ /**
104
+ * Evaluates the expression and returns the result as a boolean.
105
+ *
106
+ * @returns The boolean result of the expression evaluation.
107
+ */
108
+ evaluateAsBoolean(): boolean;
109
+ /**
110
+ * Gets the list of identifiers extracted from the expression.
111
+ */
112
+ get dependentIdentifiers(): string[];
113
+ /**
114
+ * Clears the expression cache.
115
+ * This should be called sparingly, as it will force recompilation of all expressions.
116
+ */
117
+ static clearCache(): void;
118
+ }
@@ -0,0 +1,2 @@
1
+ export declare class VComponent {
2
+ }
@@ -0,0 +1,2 @@
1
+ export declare class VComponentRegistry {
2
+ }
@@ -175,6 +175,7 @@ export declare class VNode {
175
175
  * 4. Unregister dependencies
176
176
  * 5. Clean up directive manager
177
177
  * 6. Call onUnmounted lifecycle hooks
178
+ * 7. Leave the parent's child list
178
179
  */
179
180
  destroy(): void;
180
181
  }
@@ -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,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,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,10 @@
1
+ import { VBindings } from "../VBindings";
2
+ export declare class BindingsUtils {
3
+ /**
4
+ * Gets the identifiers that have changed between two sets of bindings.
5
+ * @param oldBindings The old set of bindings.
6
+ * @param newBindings The new set of bindings.
7
+ * @returns An array of identifiers that have changed.
8
+ */
9
+ static getChangedIdentifiers(oldBindings: VBindings, newBindings: VBindings): string[];
10
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Log level enumeration.
3
+ */
4
+ export declare enum VLogLevel {
5
+ DEBUG = "debug",
6
+ INFO = "info",
7
+ WARN = "warn",
8
+ ERROR = "error"
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintjamsinc/ichigojs",
3
- "version": "0.1.82",
3
+ "version": "0.1.84",
4
4
  "description": "ichigo.js - Simple and intuitive reactive framework. Lightweight, fast, and user-friendly virtual DOM library",
5
5
  "main": "./dist/ichigo.cjs",
6
6
  "module": "./dist/ichigo.esm.js",