@mintjamsinc/ichigojs 0.1.21 → 0.1.22
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.esm.js +65 -4
- package/dist/ichigo.esm.js.map +1 -1
- package/dist/ichigo.esm.min.js +1 -1
- package/dist/ichigo.esm.min.js.map +1 -1
- package/dist/ichigo.umd.js +65 -3
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/dist/ichigo.umd.min.js.map +1 -1
- package/dist/types/ichigo/util/ReactiveProxy.d.ts +29 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/ichigo.esm.js
CHANGED
|
@@ -7417,6 +7417,16 @@ class ReactiveProxy {
|
|
|
7417
7417
|
* This prevents creating multiple proxies for the same object accessed from different paths.
|
|
7418
7418
|
*/
|
|
7419
7419
|
static proxyCache = new WeakMap();
|
|
7420
|
+
/**
|
|
7421
|
+
* A WeakMap to track which objects are proxies, mapping proxy -> original target.
|
|
7422
|
+
* This prevents double-wrapping of already proxied objects.
|
|
7423
|
+
*/
|
|
7424
|
+
static proxyToTarget = new WeakMap();
|
|
7425
|
+
/**
|
|
7426
|
+
* A WeakSet to track objects marked as "raw" (non-reactive).
|
|
7427
|
+
* These objects will not be wrapped with Proxy.
|
|
7428
|
+
*/
|
|
7429
|
+
static rawObjects = new WeakSet();
|
|
7420
7430
|
/**
|
|
7421
7431
|
* Creates a reactive proxy for the given object.
|
|
7422
7432
|
* The proxy will call the onChange callback whenever a property is modified.
|
|
@@ -7431,9 +7441,19 @@ class ReactiveProxy {
|
|
|
7431
7441
|
if (typeof target !== 'object' || target === null) {
|
|
7432
7442
|
return target;
|
|
7433
7443
|
}
|
|
7444
|
+
// Don't wrap objects marked as raw (non-reactive)
|
|
7445
|
+
if (this.rawObjects.has(target)) {
|
|
7446
|
+
return target;
|
|
7447
|
+
}
|
|
7434
7448
|
// Don't wrap built-in objects that have internal slots
|
|
7435
7449
|
// These objects require their methods to be called with the correct 'this' context
|
|
7436
|
-
|
|
7450
|
+
// Use Object.prototype.toString for more reliable type checking
|
|
7451
|
+
const typeTag = Object.prototype.toString.call(target);
|
|
7452
|
+
if (typeTag === '[object Date]' || typeTag === '[object RegExp]' || typeTag === '[object Error]') {
|
|
7453
|
+
return target;
|
|
7454
|
+
}
|
|
7455
|
+
// Check if the target is already a proxy - if so, return it as-is to prevent double-wrapping
|
|
7456
|
+
if (this.proxyToTarget.has(target)) {
|
|
7437
7457
|
return target;
|
|
7438
7458
|
}
|
|
7439
7459
|
// Check if we already have a proxy for this target with this path
|
|
@@ -7454,8 +7474,14 @@ class ReactiveProxy {
|
|
|
7454
7474
|
const value = Reflect.get(obj, key);
|
|
7455
7475
|
// If the value is an object or array, make it reactive too
|
|
7456
7476
|
if (typeof value === 'object' && value !== null) {
|
|
7477
|
+
// Don't wrap objects marked as raw (non-reactive)
|
|
7478
|
+
if (ReactiveProxy.rawObjects.has(value)) {
|
|
7479
|
+
return value;
|
|
7480
|
+
}
|
|
7457
7481
|
// Don't wrap built-in objects that have internal slots
|
|
7458
|
-
|
|
7482
|
+
// Use Object.prototype.toString for more reliable type checking
|
|
7483
|
+
const valueTypeTag = Object.prototype.toString.call(value);
|
|
7484
|
+
if (valueTypeTag === '[object Date]' || valueTypeTag === '[object RegExp]' || valueTypeTag === '[object Error]') {
|
|
7459
7485
|
return value;
|
|
7460
7486
|
}
|
|
7461
7487
|
// Build the nested path
|
|
@@ -7497,6 +7523,8 @@ class ReactiveProxy {
|
|
|
7497
7523
|
});
|
|
7498
7524
|
// Cache the proxy for this path
|
|
7499
7525
|
pathMap.set(path, proxy);
|
|
7526
|
+
// Track that this proxy wraps the target to prevent double-wrapping
|
|
7527
|
+
this.proxyToTarget.set(proxy, target);
|
|
7500
7528
|
return proxy;
|
|
7501
7529
|
}
|
|
7502
7530
|
/**
|
|
@@ -7520,6 +7548,32 @@ class ReactiveProxy {
|
|
|
7520
7548
|
// In a full implementation, we'd need to store a reverse mapping
|
|
7521
7549
|
return obj;
|
|
7522
7550
|
}
|
|
7551
|
+
/**
|
|
7552
|
+
* Marks an object as "raw" (non-reactive).
|
|
7553
|
+
* Objects marked as raw will not be wrapped with Proxy when accessed from reactive objects.
|
|
7554
|
+
* This is useful for objects that should not be reactive, such as:
|
|
7555
|
+
* - Objects with private fields (class instances with # fields)
|
|
7556
|
+
* - Third-party library instances
|
|
7557
|
+
* - Objects used only for method calls
|
|
7558
|
+
*
|
|
7559
|
+
* @param obj The object to mark as raw.
|
|
7560
|
+
* @returns The same object (for chaining).
|
|
7561
|
+
*/
|
|
7562
|
+
static markRaw(obj) {
|
|
7563
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
7564
|
+
this.rawObjects.add(obj);
|
|
7565
|
+
}
|
|
7566
|
+
return obj;
|
|
7567
|
+
}
|
|
7568
|
+
/**
|
|
7569
|
+
* Checks if an object is marked as raw (non-reactive).
|
|
7570
|
+
*
|
|
7571
|
+
* @param obj The object to check.
|
|
7572
|
+
* @returns True if the object is marked as raw, false otherwise.
|
|
7573
|
+
*/
|
|
7574
|
+
static isRaw(obj) {
|
|
7575
|
+
return typeof obj === 'object' && obj !== null && this.rawObjects.has(obj);
|
|
7576
|
+
}
|
|
7523
7577
|
}
|
|
7524
7578
|
|
|
7525
7579
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
|
@@ -11253,6 +11307,7 @@ class VApplication {
|
|
|
11253
11307
|
});
|
|
11254
11308
|
// Inject utility methods into bindings
|
|
11255
11309
|
this.#bindings.set('$nextTick', (callback) => this.#nextTick(callback));
|
|
11310
|
+
this.#bindings.set('$markRaw', (obj) => ReactiveProxy.markRaw(obj));
|
|
11256
11311
|
// Add methods
|
|
11257
11312
|
if (this.#options.methods) {
|
|
11258
11313
|
for (const [key, method] of Object.entries(this.#options.methods)) {
|
|
@@ -11267,7 +11322,13 @@ class VApplication {
|
|
|
11267
11322
|
}
|
|
11268
11323
|
// Add data properties
|
|
11269
11324
|
if (this.#options.data) {
|
|
11270
|
-
|
|
11325
|
+
// Create a $ctx context object with utility functions for data()
|
|
11326
|
+
// This provides the same $markRaw access as in lifecycle hooks (@mount, etc.)
|
|
11327
|
+
const $ctx = {
|
|
11328
|
+
$markRaw: (obj) => ReactiveProxy.markRaw(obj)
|
|
11329
|
+
};
|
|
11330
|
+
// Call data() with $ctx as 'this'
|
|
11331
|
+
const data = this.#options.data.call($ctx);
|
|
11271
11332
|
if (data && typeof data === 'object') {
|
|
11272
11333
|
for (const [key, value] of Object.entries(data)) {
|
|
11273
11334
|
this.#bindings.set(key, value);
|
|
@@ -11445,5 +11506,5 @@ class VDOM {
|
|
|
11445
11506
|
}
|
|
11446
11507
|
}
|
|
11447
11508
|
|
|
11448
|
-
export { VComponent, VComponentRegistry, VDOM };
|
|
11509
|
+
export { ReactiveProxy, VComponent, VComponentRegistry, VDOM };
|
|
11449
11510
|
//# sourceMappingURL=ichigo.esm.js.map
|