@mintjamsinc/ichigojs 0.1.50 → 0.1.52
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/dist/ichigo.cjs +70 -8
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +70 -8
- package/dist/ichigo.esm.js.map +1 -1
- package/dist/ichigo.esm.min.js +1 -1
- package/dist/ichigo.min.cjs +1 -1
- package/dist/ichigo.umd.js +70 -8
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/dist/types/ichigo/VBindings.d.ts +11 -0
- package/package.json +1 -1
package/dist/ichigo.cjs
CHANGED
|
@@ -6941,6 +6941,8 @@
|
|
|
6941
6941
|
const allDependencies = new Set();
|
|
6942
6942
|
const directDependencies = functionDependencies[funcName] || [];
|
|
6943
6943
|
for (const dep of directDependencies) {
|
|
6944
|
+
if (dep === funcName)
|
|
6945
|
+
continue; // Skip self-references
|
|
6944
6946
|
if (functions[dep]) {
|
|
6945
6947
|
// It's a function, recursively resolve its dependencies
|
|
6946
6948
|
const subDependencies = resolveDependencies(dep);
|
|
@@ -8127,6 +8129,12 @@
|
|
|
8127
8129
|
* Flag to suppress onChange callbacks temporarily.
|
|
8128
8130
|
*/
|
|
8129
8131
|
#suppressOnChange = false;
|
|
8132
|
+
/**
|
|
8133
|
+
* Per-instance path aliases. Maps local variable names to their reactive source paths.
|
|
8134
|
+
* Scoped here instead of the global ReactiveProxy map so that v-for items each maintain
|
|
8135
|
+
* their own alias (e.g. "file" -> "files[0]") without overwriting each other.
|
|
8136
|
+
*/
|
|
8137
|
+
#localAliases = new Map();
|
|
8130
8138
|
/**
|
|
8131
8139
|
* Creates a new instance of VBindings.
|
|
8132
8140
|
* @param parent The parent bindings, if any.
|
|
@@ -8161,7 +8169,7 @@
|
|
|
8161
8169
|
const existingPath = ReactiveProxy.getPath(value);
|
|
8162
8170
|
if (existingPath) {
|
|
8163
8171
|
// Register a path alias so changes to the source path will match this identifier
|
|
8164
|
-
|
|
8172
|
+
this.#localAliases.set(key, existingPath);
|
|
8165
8173
|
this.#logger?.debug(`Path alias registered: ${key} -> ${existingPath}`);
|
|
8166
8174
|
// Keep the existing proxy as-is to preserve reactivity chain
|
|
8167
8175
|
newValue = value;
|
|
@@ -8176,7 +8184,7 @@
|
|
|
8176
8184
|
const propPath = ReactiveProxy.getPath(propValue);
|
|
8177
8185
|
if (propPath) {
|
|
8178
8186
|
// Register alias: key.propKey -> propPath
|
|
8179
|
-
|
|
8187
|
+
this.#localAliases.set(`${key}.${propKey}`, propPath);
|
|
8180
8188
|
this.#logger?.debug(`Property path alias registered: ${key}.${propKey} -> ${propPath}`);
|
|
8181
8189
|
}
|
|
8182
8190
|
}
|
|
@@ -8197,8 +8205,14 @@
|
|
|
8197
8205
|
}
|
|
8198
8206
|
}
|
|
8199
8207
|
else if (value === null || value === undefined) {
|
|
8200
|
-
// When setting to null/undefined,
|
|
8201
|
-
|
|
8208
|
+
// When setting to null/undefined, remove local aliases for this key and nested paths
|
|
8209
|
+
for (const aliasKey of [...this.#localAliases.keys()]) {
|
|
8210
|
+
if (aliasKey === key ||
|
|
8211
|
+
aliasKey.startsWith(key + ".") ||
|
|
8212
|
+
aliasKey.startsWith(key + "[")) {
|
|
8213
|
+
this.#localAliases.delete(aliasKey);
|
|
8214
|
+
}
|
|
8215
|
+
}
|
|
8202
8216
|
}
|
|
8203
8217
|
const oldValue = Reflect.get(target, key);
|
|
8204
8218
|
const result = Reflect.set(target, key, newValue);
|
|
@@ -8335,6 +8349,54 @@
|
|
|
8335
8349
|
markChanged(key) {
|
|
8336
8350
|
this.#changes.add(key);
|
|
8337
8351
|
}
|
|
8352
|
+
/**
|
|
8353
|
+
* Resolves a local path alias for the given identifier by walking up the bindings chain.
|
|
8354
|
+
* Returns the resolved source path, or undefined if no alias is found.
|
|
8355
|
+
*/
|
|
8356
|
+
resolveAlias(identifier) {
|
|
8357
|
+
// Direct match in local aliases
|
|
8358
|
+
if (this.#localAliases.has(identifier)) {
|
|
8359
|
+
return this.#localAliases.get(identifier);
|
|
8360
|
+
}
|
|
8361
|
+
// Check if this is a nested path of a locally aliased variable (e.g. "file.isModified")
|
|
8362
|
+
for (const [alias, source] of this.#localAliases.entries()) {
|
|
8363
|
+
if (identifier.startsWith(alias + '.') || identifier.startsWith(alias + '[')) {
|
|
8364
|
+
return source + identifier.substring(alias.length);
|
|
8365
|
+
}
|
|
8366
|
+
}
|
|
8367
|
+
// Walk up the parent chain
|
|
8368
|
+
return this.#parent?.resolveAlias(identifier);
|
|
8369
|
+
}
|
|
8370
|
+
/**
|
|
8371
|
+
* Checks whether a reactive change path matches a given identifier, taking local path
|
|
8372
|
+
* aliases into account. Falls back to ReactiveProxy.doesChangeMatchIdentifier for
|
|
8373
|
+
* global aliases (computed properties etc.).
|
|
8374
|
+
*/
|
|
8375
|
+
doesChangeMatchIdentifier(changePath, identifier) {
|
|
8376
|
+
// Direct match
|
|
8377
|
+
if (changePath === identifier) {
|
|
8378
|
+
return true;
|
|
8379
|
+
}
|
|
8380
|
+
// Resolve via local (scoped) alias chain
|
|
8381
|
+
const resolved = this.resolveAlias(identifier);
|
|
8382
|
+
if (resolved) {
|
|
8383
|
+
if (changePath === resolved) {
|
|
8384
|
+
return true;
|
|
8385
|
+
}
|
|
8386
|
+
// changePath is a descendant of resolved (e.g. "files[0].isModified" for resolved "files[0]")
|
|
8387
|
+
if (changePath.startsWith(resolved + '.') || changePath.startsWith(resolved + '[')) {
|
|
8388
|
+
return true;
|
|
8389
|
+
}
|
|
8390
|
+
// changePath is an ancestor of resolved (e.g. "files" for resolved "files[0].isModified")
|
|
8391
|
+
// This handles raw objects: when the parent collection is replaced/spliced, all item
|
|
8392
|
+
// properties are considered changed.
|
|
8393
|
+
if (resolved.startsWith(changePath + '.') || resolved.startsWith(changePath + '[')) {
|
|
8394
|
+
return true;
|
|
8395
|
+
}
|
|
8396
|
+
}
|
|
8397
|
+
// Fall back to global alias resolution (computed properties, etc.)
|
|
8398
|
+
return ReactiveProxy.doesChangeMatchIdentifier(changePath, identifier);
|
|
8399
|
+
}
|
|
8338
8400
|
}
|
|
8339
8401
|
|
|
8340
8402
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
|
@@ -9051,7 +9113,7 @@
|
|
|
9051
9113
|
if (this.#nodeType === Node.TEXT_NODE && this.#textEvaluator) {
|
|
9052
9114
|
// If this is a text node with a text evaluator, update its content if needed
|
|
9053
9115
|
// Check if any of the identifiers are in the changed identifiers (considering path aliases)
|
|
9054
|
-
const changed = this.#textEvaluator.identifiers.some(id => changes.some(change =>
|
|
9116
|
+
const changed = this.#textEvaluator.identifiers.some(id => changes.some(change => this.bindings.doesChangeMatchIdentifier(change, id)));
|
|
9055
9117
|
// If the text node has changed, update its content
|
|
9056
9118
|
if (changed) {
|
|
9057
9119
|
const text = this.#node;
|
|
@@ -9074,7 +9136,7 @@
|
|
|
9074
9136
|
}
|
|
9075
9137
|
// Prepare bindings for each preparer if relevant identifiers have changed
|
|
9076
9138
|
for (const preparer of this.#directiveManager.bindingsPreparers) {
|
|
9077
|
-
const changed = preparer.dependentIdentifiers.some(id => changes.some(change =>
|
|
9139
|
+
const changed = preparer.dependentIdentifiers.some(id => changes.some(change => this.bindings.doesChangeMatchIdentifier(change, id)));
|
|
9078
9140
|
if (changed) {
|
|
9079
9141
|
preparer.prepareBindings();
|
|
9080
9142
|
}
|
|
@@ -9083,7 +9145,7 @@
|
|
|
9083
9145
|
// Apply DOM updaters from directives, if any
|
|
9084
9146
|
if (this.#directiveManager?.domUpdaters) {
|
|
9085
9147
|
for (const updater of this.#directiveManager.domUpdaters) {
|
|
9086
|
-
const changed = updater.dependentIdentifiers.some(id => changes.some(change =>
|
|
9148
|
+
const changed = updater.dependentIdentifiers.some(id => changes.some(change => this.bindings.doesChangeMatchIdentifier(change, id)));
|
|
9087
9149
|
if (changed) {
|
|
9088
9150
|
updater.applyToDOM();
|
|
9089
9151
|
}
|
|
@@ -9091,7 +9153,7 @@
|
|
|
9091
9153
|
}
|
|
9092
9154
|
// Recursively update dependent virtual nodes
|
|
9093
9155
|
this.#dependents?.forEach(dependentNode => {
|
|
9094
|
-
const changed = dependentNode.dependentIdentifiers.some(id => changes.some(change =>
|
|
9156
|
+
const changed = dependentNode.dependentIdentifiers.some(id => changes.some(change => dependentNode.bindings.doesChangeMatchIdentifier(change, id)));
|
|
9095
9157
|
if (changed) {
|
|
9096
9158
|
dependentNode.update();
|
|
9097
9159
|
}
|