@mintjamsinc/ichigojs 0.1.60 → 0.1.61
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 +69 -3
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +69 -3
- 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 +69 -3
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/dist/types/ichigo/VApplicationOptions.d.ts +15 -2
- package/dist/types/ichigo/VBindings.d.ts +8 -0
- package/package.json +1 -1
package/dist/ichigo.esm.js
CHANGED
|
@@ -8237,6 +8237,13 @@ class VBindings {
|
|
|
8237
8237
|
* their own alias (e.g. "file" -> "files[0]") without overwriting each other.
|
|
8238
8238
|
*/
|
|
8239
8239
|
#localAliases = new Map();
|
|
8240
|
+
/**
|
|
8241
|
+
* Setters for writable computed properties. When a key registered here is assigned
|
|
8242
|
+
* through the bindings proxy (e.g. via v-model or `bindings.set`), the setter is invoked
|
|
8243
|
+
* instead of writing directly to the local store. The cached value of the computed property
|
|
8244
|
+
* is updated by the recompute cycle through `setSilent`, which bypasses this routing.
|
|
8245
|
+
*/
|
|
8246
|
+
#writableComputeds = new Map();
|
|
8240
8247
|
/**
|
|
8241
8248
|
* Creates a new instance of VBindings.
|
|
8242
8249
|
* @param parent The parent bindings, if any.
|
|
@@ -8256,6 +8263,14 @@ class VBindings {
|
|
|
8256
8263
|
return this.#parent?.raw[key];
|
|
8257
8264
|
},
|
|
8258
8265
|
set: (obj, key, value) => {
|
|
8266
|
+
// If this key is a writable computed, route the assignment through its setter.
|
|
8267
|
+
// `setSilent` (used to update the cached value during recompute) sets `suppressOnChange`,
|
|
8268
|
+
// which bypasses this routing so the cached value can be written directly.
|
|
8269
|
+
if (!this.#suppressOnChange && this.#writableComputeds.has(key)) {
|
|
8270
|
+
const setter = this.#writableComputeds.get(key);
|
|
8271
|
+
setter(value);
|
|
8272
|
+
return true;
|
|
8273
|
+
}
|
|
8259
8274
|
let target = obj;
|
|
8260
8275
|
if (!Reflect.has(target, key)) {
|
|
8261
8276
|
for (let parent = this.#parent; parent; parent = parent.#parent) {
|
|
@@ -8442,6 +8457,16 @@ class VBindings {
|
|
|
8442
8457
|
this.#suppressOnChange = false;
|
|
8443
8458
|
}
|
|
8444
8459
|
}
|
|
8460
|
+
/**
|
|
8461
|
+
* Registers a setter for a writable computed property. When the given key is assigned
|
|
8462
|
+
* through the bindings proxy, the setter will be invoked instead of writing directly to
|
|
8463
|
+
* the local store.
|
|
8464
|
+
* @param key The computed property name.
|
|
8465
|
+
* @param setter The setter function to invoke on assignment.
|
|
8466
|
+
*/
|
|
8467
|
+
registerWritableComputed(key, setter) {
|
|
8468
|
+
this.#writableComputeds.set(key, setter);
|
|
8469
|
+
}
|
|
8445
8470
|
/**
|
|
8446
8471
|
* Manually adds an identifier to the set of changed identifiers.
|
|
8447
8472
|
* This is useful for computed properties that need to mark themselves as changed
|
|
@@ -13118,8 +13143,15 @@ class VApplication {
|
|
|
13118
13143
|
this.#logger = this.#logManager.getLogger('VApplication');
|
|
13119
13144
|
// Analyze function dependencies
|
|
13120
13145
|
this.#functionDependencies = ExpressionUtils.analyzeFunctionDependencies(options.methods || {});
|
|
13121
|
-
// Analyze computed dependencies
|
|
13122
|
-
|
|
13146
|
+
// Analyze computed dependencies based on getter functions only.
|
|
13147
|
+
// Writable computeds (defined as { get, set }) contribute their getter for dependency analysis.
|
|
13148
|
+
const computedGetters = {};
|
|
13149
|
+
if (options.computed) {
|
|
13150
|
+
for (const [key, def] of Object.entries(options.computed)) {
|
|
13151
|
+
computedGetters[key] = VApplication.#getComputedGetter(def);
|
|
13152
|
+
}
|
|
13153
|
+
}
|
|
13154
|
+
this.#computedDependencies = ExpressionUtils.analyzeFunctionDependencies(computedGetters);
|
|
13123
13155
|
// Initialize watcher manager
|
|
13124
13156
|
this.#watcher = new VWatcher(this.#logger);
|
|
13125
13157
|
// Initialize bindings from data, computed, and methods
|
|
@@ -13262,6 +13294,26 @@ class VApplication {
|
|
|
13262
13294
|
}
|
|
13263
13295
|
}
|
|
13264
13296
|
}
|
|
13297
|
+
/**
|
|
13298
|
+
* Extracts the getter function from a computed property definition.
|
|
13299
|
+
* Supports both bare function form and { get, set } object form.
|
|
13300
|
+
*/
|
|
13301
|
+
static #getComputedGetter(def) {
|
|
13302
|
+
if (typeof def === 'function') {
|
|
13303
|
+
return def;
|
|
13304
|
+
}
|
|
13305
|
+
return def.get;
|
|
13306
|
+
}
|
|
13307
|
+
/**
|
|
13308
|
+
* Extracts the setter function from a computed property definition, if any.
|
|
13309
|
+
* Returns undefined for read-only (function-form) computed properties.
|
|
13310
|
+
*/
|
|
13311
|
+
static #getComputedSetter(def) {
|
|
13312
|
+
if (typeof def === 'function') {
|
|
13313
|
+
return undefined;
|
|
13314
|
+
}
|
|
13315
|
+
return def.set;
|
|
13316
|
+
}
|
|
13265
13317
|
/**
|
|
13266
13318
|
* Computes dependent identifiers for a given computed property and value.
|
|
13267
13319
|
* This is used to track dependencies in directives like v-for.
|
|
@@ -13324,6 +13376,20 @@ class VApplication {
|
|
|
13324
13376
|
}
|
|
13325
13377
|
}
|
|
13326
13378
|
}
|
|
13379
|
+
// Register setters for writable computed properties so that assignments to them
|
|
13380
|
+
// (e.g. via v-model or direct mutation through bindings.raw) route through the user-provided
|
|
13381
|
+
// setter, which typically writes back to underlying reactive properties.
|
|
13382
|
+
if (this.#options.computed) {
|
|
13383
|
+
for (const [key, def] of Object.entries(this.#options.computed)) {
|
|
13384
|
+
const setter = VApplication.#getComputedSetter(def);
|
|
13385
|
+
if (setter) {
|
|
13386
|
+
const bindings = this.#bindings;
|
|
13387
|
+
this.#bindings.registerWritableComputed(key, (value) => {
|
|
13388
|
+
setter.call(bindings.raw, value);
|
|
13389
|
+
});
|
|
13390
|
+
}
|
|
13391
|
+
}
|
|
13392
|
+
}
|
|
13327
13393
|
// Add computed properties (initialization mode)
|
|
13328
13394
|
this.#recomputeProperties(true);
|
|
13329
13395
|
}
|
|
@@ -13482,7 +13548,7 @@ class VApplication {
|
|
|
13482
13548
|
return;
|
|
13483
13549
|
}
|
|
13484
13550
|
// Now compute this property
|
|
13485
|
-
const computedFn = this.#options.computed[key];
|
|
13551
|
+
const computedFn = VApplication.#getComputedGetter(this.#options.computed[key]);
|
|
13486
13552
|
try {
|
|
13487
13553
|
const oldValue = this.#bindings?.get(key);
|
|
13488
13554
|
const newValue = computedFn.call(this.#bindings?.raw);
|