@ember-data/store 5.4.0-alpha.144 → 5.4.0-alpha.145
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/-private.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{many-array-Ct9k0tSz.js → many-array-V2cR1muR.js} +144 -28
- package/dist/many-array-V2cR1muR.js.map +1 -0
- package/package.json +13 -12
- package/unstable-preview-types/-private/managers/notification-manager.d.ts +1 -2
- package/unstable-preview-types/-private/managers/notification-manager.d.ts.map +1 -1
- package/unstable-preview-types/-private/store-service.d.ts.map +1 -1
- package/dist/many-array-Ct9k0tSz.js.map +0 -1
package/dist/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as ARRAY_SIGNAL, C as CacheHandler, j as CollectionRecordArray, I as LiveArray, M as MUTATE, R as RecordArrayManager, v as RelatedCollection, k as SOURCE, S as Store, q as StoreMap, _ as _clearCaches, u as _deprecatingNormalize, g as coerceId, f as constructResource, h as ensureStringId, l as fastPush, i as isStableIdentifier, w as log, x as logGroup, n as notifyArray, p as peekCache, r as recordIdentifierFor, m as removeRecordDataFor, t as setCacheFor, o as setRecordIdentifier, s as storeFor } from "./many-array-
|
|
1
|
+
export { A as ARRAY_SIGNAL, C as CacheHandler, j as CollectionRecordArray, I as LiveArray, M as MUTATE, R as RecordArrayManager, v as RelatedCollection, k as SOURCE, S as Store, q as StoreMap, _ as _clearCaches, u as _deprecatingNormalize, g as coerceId, f as constructResource, h as ensureStringId, l as fastPush, i as isStableIdentifier, w as log, x as logGroup, n as notifyArray, p as peekCache, r as recordIdentifierFor, m as removeRecordDataFor, t as setCacheFor, o as setRecordIdentifier, s as storeFor } from "./many-array-V2cR1muR.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CacheHandler, S as default, r as recordIdentifierFor, c as setIdentifierForgetMethod, a as setIdentifierGenerationMethod, d as setIdentifierResetMethod, b as setIdentifierUpdateMethod, e as setKeyInfoForResource, s as storeFor } from "./many-array-
|
|
1
|
+
export { C as CacheHandler, S as default, r as recordIdentifierFor, c as setIdentifierForgetMethod, a as setIdentifierGenerationMethod, d as setIdentifierResetMethod, b as setIdentifierUpdateMethod, e as setKeyInfoForResource, s as storeFor } from "./many-array-V2cR1muR.js";
|
|
2
2
|
import '@ember/debug';
|
|
3
3
|
import '@embroider/macros';
|
|
4
4
|
import '@ember-data/request-utils/string';
|
|
@@ -2306,10 +2306,8 @@ class CacheManager {
|
|
|
2306
2306
|
* @module @ember-data/store
|
|
2307
2307
|
*/
|
|
2308
2308
|
|
|
2309
|
-
let tokenId = 0;
|
|
2310
|
-
const CacheOperations = new Set(['added', 'removed', 'state', 'updated', 'invalidated']);
|
|
2311
2309
|
function isCacheOperationValue(value) {
|
|
2312
|
-
return
|
|
2310
|
+
return value === 'added' || value === 'state' || value === 'updated' || value === 'removed' || value === 'invalidated';
|
|
2313
2311
|
}
|
|
2314
2312
|
function runLoopIsFlushing() {
|
|
2315
2313
|
//@ts-expect-error
|
|
@@ -2320,8 +2318,16 @@ function count(label) {
|
|
|
2320
2318
|
// eslint-disable-next-line
|
|
2321
2319
|
globalThis.__WarpDriveMetricCountData[label] = (globalThis.__WarpDriveMetricCountData[label] || 0) + 1;
|
|
2322
2320
|
}
|
|
2323
|
-
function
|
|
2324
|
-
|
|
2321
|
+
function asInternalToken(token) {
|
|
2322
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2323
|
+
if (!test) {
|
|
2324
|
+
throw new Error(`Expected a token with a 'for' property`);
|
|
2325
|
+
}
|
|
2326
|
+
})(token && typeof token === 'function' && 'for' in token) : {};
|
|
2327
|
+
}
|
|
2328
|
+
function _unsubscribe(token, cache) {
|
|
2329
|
+
asInternalToken(token);
|
|
2330
|
+
const identifier = token.for;
|
|
2325
2331
|
if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_NOTIFICATIONS)) {
|
|
2326
2332
|
if (getGlobalConfig().WarpDrive.debug.LOG_NOTIFICATIONS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_NOTIFICATIONS) {
|
|
2327
2333
|
if (!identifier) {
|
|
@@ -2331,9 +2337,20 @@ function _unsubscribe(tokens, token, cache) {
|
|
|
2331
2337
|
}
|
|
2332
2338
|
}
|
|
2333
2339
|
if (identifier) {
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2340
|
+
const callbacks = cache.get(identifier);
|
|
2341
|
+
if (!callbacks) {
|
|
2342
|
+
return;
|
|
2343
|
+
}
|
|
2344
|
+
const index = callbacks.indexOf(token);
|
|
2345
|
+
if (index === -1) {
|
|
2346
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2347
|
+
if (!test) {
|
|
2348
|
+
throw new Error(`Cannot unsubscribe a token that is not subscribed`);
|
|
2349
|
+
}
|
|
2350
|
+
})(index !== -1) : {};
|
|
2351
|
+
return;
|
|
2352
|
+
}
|
|
2353
|
+
callbacks.splice(index, 1);
|
|
2337
2354
|
}
|
|
2338
2355
|
}
|
|
2339
2356
|
|
|
@@ -2354,7 +2371,6 @@ class NotificationManager {
|
|
|
2354
2371
|
this._buffered = new Map();
|
|
2355
2372
|
this._hasFlush = false;
|
|
2356
2373
|
this._cache = new Map();
|
|
2357
|
-
this._tokens = new Map();
|
|
2358
2374
|
}
|
|
2359
2375
|
|
|
2360
2376
|
/**
|
|
@@ -2391,17 +2407,26 @@ class NotificationManager {
|
|
|
2391
2407
|
throw new Error(`Expected to receive a stable Identifier to subscribe to`);
|
|
2392
2408
|
}
|
|
2393
2409
|
})(identifier === 'resource' || identifier === 'document' || isStableIdentifier(identifier) || isDocumentIdentifier(identifier)) : {};
|
|
2394
|
-
let
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2410
|
+
let callbacks = this._cache.get(identifier);
|
|
2411
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2412
|
+
if (!test) {
|
|
2413
|
+
throw new Error(`expected to receive a valid callback`);
|
|
2414
|
+
}
|
|
2415
|
+
})(typeof callback === 'function') : {};
|
|
2416
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2417
|
+
if (!test) {
|
|
2418
|
+
throw new Error(`cannot subscribe with the same callback twice`);
|
|
2419
|
+
}
|
|
2420
|
+
})(!callbacks || !callbacks.includes(callback)) : {};
|
|
2421
|
+
// we use the callback as the cancellation token
|
|
2422
|
+
//@ts-expect-error
|
|
2423
|
+
callback.for = identifier;
|
|
2424
|
+
if (!callbacks) {
|
|
2425
|
+
callbacks = [];
|
|
2426
|
+
this._cache.set(identifier, callbacks);
|
|
2398
2427
|
}
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
} : {};
|
|
2402
|
-
map.set(unsubToken, callback);
|
|
2403
|
-
this._tokens.set(unsubToken, identifier);
|
|
2404
|
-
return unsubToken;
|
|
2428
|
+
callbacks.push(callback);
|
|
2429
|
+
return callback;
|
|
2405
2430
|
}
|
|
2406
2431
|
|
|
2407
2432
|
/**
|
|
@@ -2413,7 +2438,7 @@ class NotificationManager {
|
|
|
2413
2438
|
*/
|
|
2414
2439
|
unsubscribe(token) {
|
|
2415
2440
|
if (!this.isDestroyed) {
|
|
2416
|
-
_unsubscribe(
|
|
2441
|
+
_unsubscribe(token, this._cache);
|
|
2417
2442
|
}
|
|
2418
2443
|
}
|
|
2419
2444
|
|
|
@@ -2443,7 +2468,7 @@ class NotificationManager {
|
|
|
2443
2468
|
}
|
|
2444
2469
|
return false;
|
|
2445
2470
|
}
|
|
2446
|
-
const hasSubscribers = Boolean(this._cache.get(identifier)?.
|
|
2471
|
+
const hasSubscribers = Boolean(this._cache.get(identifier)?.length);
|
|
2447
2472
|
if (isCacheOperationValue(value) || hasSubscribers) {
|
|
2448
2473
|
let buffer = this._buffered.get(identifier);
|
|
2449
2474
|
if (!buffer) {
|
|
@@ -2518,11 +2543,11 @@ class NotificationManager {
|
|
|
2518
2543
|
});
|
|
2519
2544
|
}
|
|
2520
2545
|
}
|
|
2521
|
-
const
|
|
2522
|
-
if (!
|
|
2546
|
+
const callbacks = this._cache.get(identifier);
|
|
2547
|
+
if (!callbacks || !callbacks.length) {
|
|
2523
2548
|
return false;
|
|
2524
2549
|
}
|
|
2525
|
-
|
|
2550
|
+
callbacks.forEach(cb => {
|
|
2526
2551
|
// @ts-expect-error overload doesn't narrow within body
|
|
2527
2552
|
cb(identifier, value, key);
|
|
2528
2553
|
});
|
|
@@ -2530,7 +2555,6 @@ class NotificationManager {
|
|
|
2530
2555
|
}
|
|
2531
2556
|
destroy() {
|
|
2532
2557
|
this.isDestroyed = true;
|
|
2533
|
-
this._tokens.clear();
|
|
2534
2558
|
this._cache.clear();
|
|
2535
2559
|
}
|
|
2536
2560
|
}
|
|
@@ -3675,16 +3699,108 @@ globalThis.setWarpDriveLogging = setLogging;
|
|
|
3675
3699
|
globalThis.getWarpDriveRuntimeConfig = getRuntimeConfig;
|
|
3676
3700
|
if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_METRIC_COUNTS)) {
|
|
3677
3701
|
if (getGlobalConfig().WarpDrive.debug.LOG_METRIC_COUNTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_METRIC_COUNTS) {
|
|
3678
|
-
// @ts-expect-error
|
|
3702
|
+
// @ts-expect-error adding to globalThis
|
|
3679
3703
|
// eslint-disable-next-line
|
|
3680
3704
|
globalThis.__WarpDriveMetricCountData = globalThis.__WarpDriveMetricCountData || {};
|
|
3681
3705
|
|
|
3682
|
-
// @ts-expect-error
|
|
3706
|
+
// @ts-expect-error adding to globalThis
|
|
3683
3707
|
globalThis.getWarpDriveMetricCounts = () => {
|
|
3684
3708
|
// @ts-expect-error
|
|
3685
3709
|
// eslint-disable-next-line
|
|
3686
|
-
return globalThis.__WarpDriveMetricCountData;
|
|
3710
|
+
return structuredClone(globalThis.__WarpDriveMetricCountData);
|
|
3711
|
+
};
|
|
3712
|
+
|
|
3713
|
+
// @ts-expect-error adding to globalThis
|
|
3714
|
+
globalThis.resetWarpDriveMetricCounts = () => {
|
|
3715
|
+
// @ts-expect-error
|
|
3716
|
+
globalThis.__WarpDriveMetricCountData = {};
|
|
3687
3717
|
};
|
|
3718
|
+
if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.__INTERNAL_LOG_NATIVE_MAP_SET_COUNTS)) {
|
|
3719
|
+
if (getGlobalConfig().WarpDrive.debug.__INTERNAL_LOG_NATIVE_MAP_SET_COUNTS || globalThis.getWarpDriveRuntimeConfig().debug.__INTERNAL_LOG_NATIVE_MAP_SET_COUNTS) {
|
|
3720
|
+
// @ts-expect-error adding to globalThis
|
|
3721
|
+
globalThis.__primitiveInstanceId = 0;
|
|
3722
|
+
function interceptAndLog(klassName, methodName) {
|
|
3723
|
+
const klass = globalThis[klassName];
|
|
3724
|
+
if (methodName === 'constructor') {
|
|
3725
|
+
const instantiationLabel = `new ${klassName}()`;
|
|
3726
|
+
// @ts-expect-error
|
|
3727
|
+
globalThis[klassName] = class extends klass {
|
|
3728
|
+
// @ts-expect-error
|
|
3729
|
+
constructor(...args) {
|
|
3730
|
+
// eslint-disable-next-line
|
|
3731
|
+
super(...args);
|
|
3732
|
+
// @ts-expect-error
|
|
3733
|
+
|
|
3734
|
+
const instanceId = globalThis.__primitiveInstanceId++;
|
|
3735
|
+
// @ts-expect-error
|
|
3736
|
+
// eslint-disable-next-line
|
|
3737
|
+
globalThis.__WarpDriveMetricCountData[instantiationLabel] =
|
|
3738
|
+
// @ts-expect-error
|
|
3739
|
+
// eslint-disable-next-line
|
|
3740
|
+
(globalThis.__WarpDriveMetricCountData[instantiationLabel] || 0) + 1;
|
|
3741
|
+
// @ts-expect-error
|
|
3742
|
+
this.instanceName = `${klassName}:${instanceId} - ${new Error().stack?.split('\n')[2]}`;
|
|
3743
|
+
}
|
|
3744
|
+
};
|
|
3745
|
+
} else {
|
|
3746
|
+
// @ts-expect-error
|
|
3747
|
+
// eslint-disable-next-line
|
|
3748
|
+
const original = klass.prototype[methodName];
|
|
3749
|
+
const logName = `${klassName}.${methodName}`;
|
|
3750
|
+
|
|
3751
|
+
// @ts-expect-error
|
|
3752
|
+
klass.prototype[methodName] = function (...args) {
|
|
3753
|
+
// @ts-expect-error
|
|
3754
|
+
// eslint-disable-next-line
|
|
3755
|
+
globalThis.__WarpDriveMetricCountData[logName] = (globalThis.__WarpDriveMetricCountData[logName] || 0) + 1;
|
|
3756
|
+
// @ts-expect-error
|
|
3757
|
+
const {
|
|
3758
|
+
instanceName
|
|
3759
|
+
} = this;
|
|
3760
|
+
if (!instanceName) {
|
|
3761
|
+
// @ts-expect-error
|
|
3762
|
+
const instanceId = globalThis.__primitiveInstanceId++;
|
|
3763
|
+
// @ts-expect-error
|
|
3764
|
+
this.instanceName = `${klassName}.${methodName}:${instanceId} - ${new Error().stack?.split('\n')[2]}`;
|
|
3765
|
+
}
|
|
3766
|
+
const instanceLogName = `${logName} (${instanceName})`;
|
|
3767
|
+
// @ts-expect-error
|
|
3768
|
+
// eslint-disable-next-line
|
|
3769
|
+
globalThis.__WarpDriveMetricCountData[instanceLogName] =
|
|
3770
|
+
// @ts-expect-error
|
|
3771
|
+
// eslint-disable-next-line
|
|
3772
|
+
(globalThis.__WarpDriveMetricCountData[instanceLogName] || 0) + 1;
|
|
3773
|
+
// eslint-disable-next-line
|
|
3774
|
+
return original.apply(this, args);
|
|
3775
|
+
};
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
interceptAndLog('Set', 'constructor');
|
|
3779
|
+
interceptAndLog('Set', 'add');
|
|
3780
|
+
interceptAndLog('Set', 'delete');
|
|
3781
|
+
interceptAndLog('Set', 'has');
|
|
3782
|
+
interceptAndLog('Set', 'set');
|
|
3783
|
+
interceptAndLog('Set', 'get');
|
|
3784
|
+
interceptAndLog('Map', 'constructor');
|
|
3785
|
+
interceptAndLog('Map', 'set');
|
|
3786
|
+
interceptAndLog('Map', 'delete');
|
|
3787
|
+
interceptAndLog('Map', 'has');
|
|
3788
|
+
interceptAndLog('Map', 'add');
|
|
3789
|
+
interceptAndLog('Map', 'get');
|
|
3790
|
+
interceptAndLog('WeakSet', 'constructor');
|
|
3791
|
+
interceptAndLog('WeakSet', 'add');
|
|
3792
|
+
interceptAndLog('WeakSet', 'delete');
|
|
3793
|
+
interceptAndLog('WeakSet', 'has');
|
|
3794
|
+
interceptAndLog('WeakSet', 'set');
|
|
3795
|
+
interceptAndLog('WeakSet', 'get');
|
|
3796
|
+
interceptAndLog('WeakMap', 'constructor');
|
|
3797
|
+
interceptAndLog('WeakMap', 'set');
|
|
3798
|
+
interceptAndLog('WeakMap', 'delete');
|
|
3799
|
+
interceptAndLog('WeakMap', 'has');
|
|
3800
|
+
interceptAndLog('WeakMap', 'add');
|
|
3801
|
+
interceptAndLog('WeakMap', 'get');
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3688
3804
|
}
|
|
3689
3805
|
}
|
|
3690
3806
|
|