@mintjamsinc/ichigojs 0.1.88 → 0.1.90

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.
@@ -111,6 +111,11 @@ export declare class VBindings {
111
111
  * @param key The computed property name.
112
112
  */
113
113
  markComputedDirty(key: string): void;
114
+ /**
115
+ * Indicates whether a computed property is marked dirty and not yet recomputed.
116
+ * @param key The computed property name.
117
+ */
118
+ isComputedDirty(key: string): boolean;
114
119
  /**
115
120
  * Reads the currently cached value of a computed property without triggering pull-based
116
121
  * re-evaluation. Used by the recompute routine to obtain the previous value for change
@@ -152,10 +157,14 @@ export declare class VBindings {
152
157
  * path fits the identifier (not evaluated yet, a raw object, a short-circuited read),
153
158
  * the identifier keeps matching every index.
154
159
  *
160
+ * The recorded paths also count as dependencies of their own: they include what a
161
+ * method called by the expression read, such as `this[key]`, which the identifiers
162
+ * found in the source cannot name.
163
+ *
155
164
  * @param changes The change paths of the current update cycle.
156
165
  * @param identifiers The identifiers the expression depends on.
157
166
  * @param trackedPaths The paths read during the expression's last evaluation, if recorded.
158
- * @returns True if some change matches some identifier.
167
+ * @returns True if some change matches some identifier or recorded path.
159
168
  */
160
169
  isAffected(changes: string[], identifiers: string[], trackedPaths?: ReadonlySet<string>): boolean;
161
170
  }
@@ -113,6 +113,15 @@ export declare class VNode {
113
113
  * This includes variable and function names used in expressions.
114
114
  */
115
115
  get dependentIdentifiers(): string[];
116
+ /**
117
+ * Whether a change of the current update cycle concerns this node, so that a node it
118
+ * depends on should update it: a change matches one of its identifiers, or touches a
119
+ * path one of its bindings read the last time it ran. The recorded reads cover what a
120
+ * called method read, such as `this[key]`, which the identifiers cannot name. Each
121
+ * binding decides again for itself when the node updates.
122
+ * @param changes The change paths of the current update cycle.
123
+ */
124
+ isAffectedBy(changes: string[]): boolean;
116
125
  get preparableIdentifiers(): string[];
117
126
  /**
118
127
  * Gets the user data storage for this virtual node.
@@ -22,9 +22,9 @@ export declare class VTextEvaluator {
22
22
  */
23
23
  get identifiers(): string[];
24
24
  /**
25
- * The source paths read through reactive proxies during the last evaluation.
26
- * Recorded only when an expression has a run-time index ("items[i].name");
27
- * undefined before the first evaluation and for texts without such an index.
25
+ * The source paths read during the last evaluation. Recorded only when an
26
+ * expression has a run-time index ("items[i].name") or calls a method;
27
+ * undefined before the first evaluation and for other texts.
28
28
  */
29
29
  get trackedPaths(): ReadonlySet<string> | undefined;
30
30
  /**
@@ -54,13 +54,14 @@ export declare class ExpressionEvaluator {
54
54
  */
55
55
  private readonly additionalContext?;
56
56
  /**
57
- * Whether any identifier has an index known only at run time ("items[*].name").
58
- * Only then are the paths read during evaluation worth recording.
57
+ * Whether the paths read during evaluation are recorded: when an identifier has an
58
+ * index known only at run time ("items[*].name"), or when the expression calls a
59
+ * method, whose reads (`this[key]` among them) the source analysis may not see.
59
60
  */
60
- private readonly hasDynamicIndex;
61
+ private readonly tracksReads;
61
62
  /**
62
- * The source paths read through reactive proxies during the last evaluation,
63
- * or undefined before the first evaluation and when nothing is recorded.
63
+ * The source paths read during the last evaluation, or undefined before the
64
+ * first evaluation and when nothing is recorded.
64
65
  */
65
66
  private trackedPathSet?;
66
67
  /**
@@ -93,11 +94,11 @@ export declare class ExpressionEvaluator {
93
94
  */
94
95
  evaluate(): any;
95
96
  /**
96
- * The source paths read through reactive proxies during the last evaluation,
97
- * recorded only for an expression with a run-time index ("items[i].name").
97
+ * The source paths read during the last evaluation, recorded only for an
98
+ * expression with a run-time index ("items[i].name") or a method call.
98
99
  * Each evaluation replaces the previous set, so a path read for a former
99
100
  * index value is dropped as soon as the expression runs with the new one.
100
- * Undefined before the first evaluation and for expressions without such an index.
101
+ * Undefined before the first evaluation and for other expressions.
101
102
  */
102
103
  get trackedPaths(): ReadonlySet<string> | undefined;
103
104
  /**
@@ -15,6 +15,16 @@ export declare class ExpressionUtils {
15
15
  static extractIdentifiers(expression: string, functionDependencies: Record<string, string[]>, options?: {
16
16
  asScript?: boolean;
17
17
  }): string[];
18
+ /**
19
+ * Whether an expression refers to one of the application's methods, judged by the
20
+ * identifiers extractIdentifiers returned for it. A called method may read bindings
21
+ * the source analysis cannot name (e.g. `this[key]`), so such an expression records
22
+ * its reads when it runs.
23
+ * @param identifiers The identifiers extracted from the expression.
24
+ * @param functionDependencies The application's methods and their dependencies.
25
+ * @returns True if an identifier names a method.
26
+ */
27
+ static callsFunction(identifiers: string[], functionDependencies: Record<string, string[]>): boolean;
18
28
  /**
19
29
  * Returns the binding name an identifier chain starts with
20
30
  * (e.g. "items" for "items[0].name" or "user.name").
@@ -84,11 +84,53 @@ export declare class ReactiveProxy {
84
84
  * through a reactive proxy. Nested calls record into the innermost set only;
85
85
  * the previous set is restored when fn returns or throws.
86
86
  *
87
+ * The set is kept closed under ancestors: whenever a path is recorded, every
88
+ * path above it ("items" and "items[2]" for "items[2].name") is in the set as
89
+ * well. A read reached through a proxy records them on its way down; a read
90
+ * that starts partway (a proxy a computed returned, a v-for item) has them
91
+ * added when it is recorded. changeAffectsRead relies on this to answer with
92
+ * one lookup.
93
+ *
87
94
  * @param paths The set that receives the paths read.
88
95
  * @param fn The function to run.
89
96
  * @returns The value fn returns.
90
97
  */
91
98
  static track<T>(paths: Set<string>, fn: () => T): T;
99
+ /**
100
+ * Records a read made outside any proxy while track() runs: a binding read by
101
+ * name (`this.flag`, `this[key]`), which the bindings report here. Reads below
102
+ * a binding are recorded by the proxy itself.
103
+ *
104
+ * @param path The binding name read.
105
+ */
106
+ static recordRead(path: string): void;
107
+ /**
108
+ * Records a read made through a proxy while track() runs: the member `key` of
109
+ * the object at `containerPath`. The container's own path and its ancestors are
110
+ * added first when they are missing, which happens when the proxy was not
111
+ * reached from a root binding during this run (see track()). A container that
112
+ * is already recorded has its ancestors recorded too, so the common case is one
113
+ * lookup.
114
+ *
115
+ * @param containerPath The source path of the object read from ("" for a root).
116
+ * @param key The property key read.
117
+ */
118
+ private static recordProxyRead;
119
+ /**
120
+ * Checks whether a change touches something read during a tracked run (see
121
+ * track()): the path read was written, or an object or array holding it was
122
+ * replaced. A change below a path read does not count, since a read of the
123
+ * changed member itself would have been recorded too; this keeps a read of a
124
+ * whole collection ("items") from matching a write to one element.
125
+ *
126
+ * The set holds the ancestors of every path read, so a replaced container is
127
+ * found by the same lookup as the path itself.
128
+ *
129
+ * @param changePath The path that was changed (e.g., "items[2].name")
130
+ * @param readPaths The paths read during the tracked run
131
+ * @returns True if the change touches a path read
132
+ */
133
+ static changeAffectsRead(changePath: string, readPaths: ReadonlySet<string>): boolean;
92
134
  /**
93
135
  * The `Object.prototype.toString` tags of the *only* value types we deeply
94
136
  * proxy. Everything else is returned untouched (raw).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintjamsinc/ichigojs",
3
- "version": "0.1.88",
3
+ "version": "0.1.90",
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",