mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 13:18:23 +08:00
140 lines
65 KiB
Diff
140 lines
65 KiB
Diff
|
diff --git a/dist/-private/array.d.ts.map b/dist/-private/array.d.ts.map
|
||
|
index aa3d9ff546e443781610002ad61b381be7ed148a..c34ce1b8d50371e14fcde9b3b0bda316c8d92909 100644
|
||
|
--- a/dist/-private/array.d.ts.map
|
||
|
+++ b/dist/-private/array.d.ts.map
|
||
|
@@ -1 +1 @@
|
||
|
-{"version":3,"file":"-private/array.d.ts","sourceRoot":"","sources":["../src/-private/array.ts"],"names":[],"mappings":"AAkDA,cAAM,YAAY,CAAC,CAAC,GAAG,OAAO;;IAC5B;;;OAGG;;;;;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;IAErE;;;;;OAKG;;;;;;;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EACd,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EACpC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,EAC7B,OAAO,CAAC,EAAE,OAAO,GAChB,YAAY,CAAC,CAAC,CAAC;IAYlB,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC;gBAI9B,GAAG,GAAE,CAAC,EAAO;CAgF1B;AAYD,UAAU,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;CAAG"}
|
||
|
\ No newline at end of file
|
||
|
+{"version":3,"file":"-private/array.d.ts","sourceRoot":"","sources":["../src/-private/array.ts"],"names":[],"mappings":"AAkDA,cAAM,YAAY,CAAC,CAAC,GAAG,OAAO;;IAC5B;;;OAGG;;;;;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;IAErE;;;;;OAKG;;;;;;;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EACd,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EACpC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,EAC7B,OAAO,CAAC,EAAE,OAAO,GAChB,YAAY,CAAC,CAAC,CAAC;IAYlB,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC;gBAI9B,GAAG,GAAE,CAAC,EAAO;CAkF1B;AAYD,UAAU,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;CAAG"}
|
||
|
\ No newline at end of file
|
||
|
diff --git a/dist/-private/array.js b/dist/-private/array.js
|
||
|
index 37194ae8e30a1f1554c6d441e766d890a86d06b0..728d9d52f56aecf64b87bbdfe7bf7ffd1d3a3ad2 100644
|
||
|
--- a/dist/-private/array.js
|
||
|
+++ b/dist/-private/array.js
|
||
|
@@ -34,6 +34,7 @@ var _collection = /*#__PURE__*/new WeakMap();
|
||
|
var _storages = /*#__PURE__*/new WeakMap();
|
||
|
var _readStorageFor = /*#__PURE__*/new WeakSet();
|
||
|
var _dirtyStorageFor = /*#__PURE__*/new WeakSet();
|
||
|
+var _dirtyCollection = /*#__PURE__*/new WeakSet();
|
||
|
class TrackedArray {
|
||
|
/**
|
||
|
* Creates an array from an iterable object.
|
||
|
@@ -54,6 +55,7 @@ class TrackedArray {
|
||
|
return new TrackedArray(arr);
|
||
|
}
|
||
|
constructor(arr = []) {
|
||
|
+ _classPrivateMethodInitSpec(this, _dirtyCollection);
|
||
|
_classPrivateMethodInitSpec(this, _dirtyStorageFor);
|
||
|
_classPrivateMethodInitSpec(this, _readStorageFor);
|
||
|
_classPrivateFieldInitSpec(this, _collection, {
|
||
|
@@ -93,11 +95,8 @@ class TrackedArray {
|
||
|
set(target, prop, value /*, _receiver */) {
|
||
|
target[prop] = value;
|
||
|
let index = convertToInt(prop);
|
||
|
- if (index !== null) {
|
||
|
- _classPrivateMethodGet(self, _dirtyStorageFor, _dirtyStorageFor2).call(self, index);
|
||
|
- setValue(_classPrivateFieldGet(self, _collection), null);
|
||
|
- } else if (prop === 'length') {
|
||
|
- setValue(_classPrivateFieldGet(self, _collection), null);
|
||
|
+ if (index !== null || prop === 'length') {
|
||
|
+ _classPrivateMethodGet(self, _dirtyCollection, _dirtyCollection2).call(self);
|
||
|
}
|
||
|
return true;
|
||
|
},
|
||
|
@@ -127,11 +126,9 @@ function _readStorageFor2(index) {
|
||
|
}
|
||
|
getValue(storage);
|
||
|
}
|
||
|
-function _dirtyStorageFor2(index) {
|
||
|
- const storage = _classPrivateFieldGet(this, _storages).get(index);
|
||
|
- if (storage) {
|
||
|
- setValue(storage, null);
|
||
|
- }
|
||
|
+function _dirtyCollection2() {
|
||
|
+ setValue(_classPrivateFieldGet(this, _collection), null);
|
||
|
+ _classPrivateFieldGet(this, _storages).clear();
|
||
|
}
|
||
|
|
||
|
// Ensure instanceof works correctly
|
||
|
diff --git a/dist/-private/array.js.map b/dist/-private/array.js.map
|
||
|
index c363292ff9aeb7c17969715b667566eb89176d94..92943c02d0e7ab174d206a2905432dd784f186cc 100644
|
||
|
--- a/dist/-private/array.js.map
|
||
|
+++ b/dist/-private/array.js.map
|
||
|
@@ -1 +1 @@
|
||
|
-{"version":3,"file":"array.js","sources":["../../../node_modules/.pnpm/@babel+runtime@7.20.1/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorGet.js","../../../node_modules/.pnpm/@babel+runtime@7.20.1/node_modules/@babel/runtime/helpers/esm/classExtractFieldDescriptor.js","../../../node_modules/.pnpm/@babel+runtime@7.20.1/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js","../../src/-private/array.ts"],"sourcesContent":["export default function _classApplyDescriptorGet(receiver, descriptor) {\n if (descriptor.get) {\n return descriptor.get.call(receiver);\n }\n return descriptor.value;\n}","export default function _classExtractFieldDescriptor(receiver, privateMap, action) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to \" + action + \" private field on non-instance\");\n }\n return privateMap.get(receiver);\n}","import classApplyDescriptorGet from \"./classApplyDescriptorGet.js\";\nimport classExtractFieldDescriptor from \"./classExtractFieldDescriptor.js\";\nexport default function _classPrivateFieldGet(receiver, privateMap) {\n var descriptor = classExtractFieldDescriptor(receiver, privateMap, \"get\");\n return classApplyDescriptorGet(receiver, descriptor);\n}","/* eslint-disable @typescript-eslint/no-explicit-any */\n// Unfortunately, TypeScript's ability to do inference *or* type-checking in a\n// `Proxy`'s body is very limited, so we have to use a number of casts `as any`\n// to make the internal accesses work. The type safety of these is guaranteed at\n// the *call site* instead of within the body: you cannot do `Array.blah` in TS,\n// and it will blow up in JS in exactly the same way, so it is safe to assume\n// that properties within the getter have the correct type in TS.\n\nimport {\n TrackedStorage,\n createStorage,\n getValue,\n setValue,\n} from 'ember-tracked-storage-polyfill';\n\nconst ARRAY_GETTER_METHODS = new Set<string | symbol | number>([\n Symbol.iterator,\n 'concat',\n 'entries',\n 'every',\n 'fill',\n 'filter',\n 'find',\n 'findIndex',\n 'flat',\n 'flatMap',\n 'forEach',\n 'includes',\n 'indexOf',\n 'join',\n 'keys',\n 'lastIndexOf',\n 'map',\n 'reduce',\n 'reduceRight',\n 'slice',\n 'some',\n 'values',\n]);\n\nfunction convertToInt(prop: number | string | symbol): number | null {\n if (typeof prop === 'symbol') return null;\n\n const num = Number(prop);\n\n if (isNaN(num)) return null;\n\n return num % 1 === 0 ? num : null;\n}\n\nclass TrackedArray<T = unknown> {\n /**\n * Creates an array from an iterable object.\n * @param iterable An iterable object to convert to an array.\n */\n static from<T>(iterable: Iterable<T> | ArrayLike<T>): TrackedArray<T>;\n\n /**\n * Creates an array from an iterable object.\n * @param iterable An iterable object to convert to an array.\n * @param mapfn A mapping function to call on every element of the array.\n * @param thisArg Value of 'this' used to invoke the mapfn.\n */\n static from<T, U>(\n iterable: Iterable<T> | ArrayLike<T>,\n mapfn: (v: T, k: number) => U,\n thisArg?: unknown\n ): TrackedArray<U>;\n\n static from<T, U>(\n iterable: Iterable<T> | ArrayLike<T>,\n mapfn?: (v: T, k: number) => U,\n thisArg?: unknown\n ): TrackedArray<T> | TrackedArray<U> {\n return mapfn\n ? new TrackedArray(Array.from(iterable, mapfn, thisArg))\n : new TrackedArray(Array.from(iterable));\n }\n\n static of<T>(...arr: T[]): TrackedArray<T> {\n return new TrackedArray(arr);\n }\n\n constructor(arr: T[] = []) {\n let clone = arr.slice();\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let self = this;\n\n let boundFns = new Map();\n\n return new Proxy(clone, {\n get(target, prop /*, _receiver */) {\n let index = convertToInt(prop);\n\n if (index !== null) {\n self.#readStorageFor(index);\n getValue(self.#collection);\n\n return target[index];\n } else if (prop === 'length') {\n getValue(self.#collection);\n } else if (ARRAY_
|
||
|
\ No newline at end of file
|
||
|
+{"version":3,"file":"array.js","sources":["../../../node_modules/.pnpm/@babel+runtime@7.20.1/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorGet.js","../../../node_modules/.pnpm/@babel+runtime@7.20.1/node_modules/@babel/runtime/helpers/esm/classExtractFieldDescriptor.js","../../../node_modules/.pnpm/@babel+runtime@7.20.1/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js","../../src/-private/array.ts"],"sourcesContent":["export default function _classApplyDescriptorGet(receiver, descriptor) {\n if (descriptor.get) {\n return descriptor.get.call(receiver);\n }\n return descriptor.value;\n}","export default function _classExtractFieldDescriptor(receiver, privateMap, action) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to \" + action + \" private field on non-instance\");\n }\n return privateMap.get(receiver);\n}","import classApplyDescriptorGet from \"./classApplyDescriptorGet.js\";\nimport classExtractFieldDescriptor from \"./classExtractFieldDescriptor.js\";\nexport default function _classPrivateFieldGet(receiver, privateMap) {\n var descriptor = classExtractFieldDescriptor(receiver, privateMap, \"get\");\n return classApplyDescriptorGet(receiver, descriptor);\n}","/* eslint-disable @typescript-eslint/no-explicit-any */\n// Unfortunately, TypeScript's ability to do inference *or* type-checking in a\n// `Proxy`'s body is very limited, so we have to use a number of casts `as any`\n// to make the internal accesses work. The type safety of these is guaranteed at\n// the *call site* instead of within the body: you cannot do `Array.blah` in TS,\n// and it will blow up in JS in exactly the same way, so it is safe to assume\n// that properties within the getter have the correct type in TS.\n\nimport {\n TrackedStorage,\n createStorage,\n getValue,\n setValue,\n} from 'ember-tracked-storage-polyfill';\n\nconst ARRAY_GETTER_METHODS = new Set<string | symbol | number>([\n Symbol.iterator,\n 'concat',\n 'entries',\n 'every',\n 'fill',\n 'filter',\n 'find',\n 'findIndex',\n 'flat',\n 'flatMap',\n 'forEach',\n 'includes',\n 'indexOf',\n 'join',\n 'keys',\n 'lastIndexOf',\n 'map',\n 'reduce',\n 'reduceRight',\n 'slice',\n 'some',\n 'values',\n]);\n\nfunction convertToInt(prop: number | string | symbol): number | null {\n if (typeof prop === 'symbol') return null;\n\n const num = Number(prop);\n\n if (isNaN(num)) return null;\n\n return num % 1 === 0 ? num : null;\n}\n\nclass TrackedArray<T = unknown> {\n /**\n * Creates an array from an iterable object.\n * @param iterable An iterable object to convert to an array.\n */\n static from<T>(iterable: Iterable<T> | ArrayLike<T>): TrackedArray<T>;\n\n /**\n * Creates an array from an iterable object.\n * @param iterable An iterable object to convert to an array.\n * @param mapfn A mapping function to call on every element of the array.\n * @param thisArg Value of 'this' used to invoke the mapfn.\n */\n static from<T, U>(\n iterable: Iterable<T> | ArrayLike<T>,\n mapfn: (v: T, k: number) => U,\n thisArg?: unknown\n ): TrackedArray<U>;\n\n static from<T, U>(\n iterable: Iterable<T> | ArrayLike<T>,\n mapfn?: (v: T, k: number) => U,\n thisArg?: unknown\n ): TrackedArray<T> | TrackedArray<U> {\n return mapfn\n ? new TrackedArray(Array.from(iterable, mapfn, thisArg))\n : new TrackedArray(Array.from(iterable));\n }\n\n static of<T>(...arr: T[]): TrackedArray<T> {\n return new TrackedArray(arr);\n }\n\n constructor(arr: T[] = []) {\n let clone = arr.slice();\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let self = this;\n\n let boundFns = new Map();\n\n return new Proxy(clone, {\n get(target, prop /*, _receiver */) {\n let index = convertToInt(prop);\n\n if (index !== null) {\n self.#readStorageFor(index);\n getValue(self.#collection);\n\n return target[index];\n } else if (prop === 'length') {\n getValue(self.#collection);\n } else if (ARRAY_
|
||
|
\ No newline at end of file
|
||
|
diff --git a/dist/-private/map.js b/dist/-private/map.js
|
||
|
index ede4d374e29051732e4efcb3ce19851b64b0a839..f220d187fed5537aa817c080c3ca9e7339fcf4bc 100644
|
||
|
--- a/dist/-private/map.js
|
||
|
+++ b/dist/-private/map.js
|
||
|
@@ -76,12 +76,14 @@ class TrackedMap {
|
||
|
delete(key) {
|
||
|
this.dirtyStorageFor(key);
|
||
|
setValue(this.collection, null);
|
||
|
+ this.storages.delete(key);
|
||
|
return this.vals.delete(key);
|
||
|
}
|
||
|
|
||
|
// **** ALL SETTERS ****
|
||
|
clear() {
|
||
|
this.storages.forEach(s => setValue(s, null));
|
||
|
+ this.storages.clear();
|
||
|
setValue(this.collection, null);
|
||
|
this.vals.clear();
|
||
|
}
|
||
|
@@ -128,6 +130,7 @@ class TrackedWeakMap {
|
||
|
}
|
||
|
delete(key) {
|
||
|
this.dirtyStorageFor(key);
|
||
|
+ this.storages.delete(key);
|
||
|
return this.vals.delete(key);
|
||
|
}
|
||
|
get [Symbol.toStringTag]() {
|
||
|
diff --git a/dist/-private/map.js.map b/dist/-private/map.js.map
|
||
|
index d75767f21d5129a0513c5c95213b7fc48231518b..5ff28279011f33ed122e7b596d1eea8e908ba904 100644
|
||
|
--- a/dist/-private/map.js.map
|
||
|
+++ b/dist/-private/map.js.map
|
||
|
@@ -1 +1 @@
|
||
|
-{"version":3,"file":"map.js","sources":["../../src/-private/map.ts"],"sourcesContent":["import {\n TrackedStorage,\n createStorage,\n getValue,\n setValue,\n} from 'ember-tracked-storage-polyfill';\n\nexport class TrackedMap<K = unknown, V = unknown> implements Map<K, V> {\n private collection = createStorage(null, () => false);\n\n private storages: Map<K, TrackedStorage<null>> = new Map();\n\n private vals: Map<K, V>;\n\n private readStorageFor(key: K): void {\n const { storages } = this;\n let storage = storages.get(key);\n\n if (storage === undefined) {\n storage = createStorage(null, () => false);\n storages.set(key, storage);\n }\n\n getValue(storage);\n }\n\n private dirtyStorageFor(key: K): void {\n const storage = this.storages.get(key);\n\n if (storage) {\n setValue(storage, null);\n }\n }\n\n constructor();\n constructor(entries: readonly (readonly [K, V])[] | null);\n constructor(iterable: Iterable<readonly [K, V]>);\n constructor(\n existing?:\n | readonly (readonly [K, V])[]\n | Iterable<readonly [K, V]>\n | null\n | undefined\n ) {\n // TypeScript doesn't correctly resolve the overloads for calling the `Map`\n // constructor for the no-value constructor. This resolves that.\n this.vals = existing ? new Map(existing) : new Map();\n }\n\n // **** KEY GETTERS ****\n get(key: K): V | undefined {\n // entangle the storage for the key\n this.readStorageFor(key);\n\n return this.vals.get(key);\n }\n\n has(key: K): boolean {\n this.readStorageFor(key);\n\n return this.vals.has(key);\n }\n\n // **** ALL GETTERS ****\n entries(): IterableIterator<[K, V]> {\n getValue(this.collection);\n\n return this.vals.entries();\n }\n\n keys(): IterableIterator<K> {\n getValue(this.collection);\n\n return this.vals.keys();\n }\n\n values(): IterableIterator<V> {\n getValue(this.collection);\n\n return this.vals.values();\n }\n\n forEach(fn: (value: V, key: K, map: Map<K, V>) => void): void {\n getValue(this.collection);\n\n this.vals.forEach(fn);\n }\n\n get size(): number {\n getValue(this.collection);\n\n return this.vals.size;\n }\n\n [Symbol.iterator](): IterableIterator<[K, V]> {\n getValue(this.collection);\n\n return this.vals[Symbol.iterator]();\n }\n\n get [Symbol.toStringTag](): string {\n return this.vals[Symbol.toStringTag];\n }\n\n // **** KEY SETTERS ****\n set(key: K, value: V): this {\n this.dirtyStorageFor(key);\n setValue(this.collection, null);\n\n this.vals.set(key, value);\n\n return this;\n }\n\n delete(key: K): boolean {\n this.dirtyStorageFor(key);\n setValue(this.collection, null);\n\n return this.vals.delete(key);\n }\n\n // **** ALL SETTERS ****\n clear(): void {\n this.storages.forEach((s) => setValue(s, null));\n setValue(this.collection, null);\n\n this.vals.clear();\n }\n}\n\n// So instanceof works\nObject.setPrototypeOf(TrackedMap.prototype, Map.prototype);\n\nexport class TrackedWeakMap<K extends object = object, V = unknown>\n implements WeakMap<K, V>\n{\n private storages: WeakMap<K, TrackedStorage<null>> = new WeakMap();\n\n private vals: WeakMap<K, V>;\n\n private readStorageFor(key: K): void {\n const { storages } = this;\n let storage = storages.get(key);\n\n if (storage === undefined) {\n storage = createStorage(null, () => false);\n storages.set(key, storage);\n }\n\n getValue(storage);\n }\n\n private dirtyStorageFor(key: K): void {\n const storage = this.storages.get(key);\n\n if (storage) {\n setValue(storage, null);\n }\n }\n\n constructor();\n constructor(iterable: Iterable<readonly [K, V]>);\n constructor(entries: readonly [K, V][] | null);\n constructor(\n existing?: readonly [K, V][] | Iterable<readonly [K, V]> | null | undefined\n ) {\n // TypeScript doesn't correctly resolve the overloads for calling the `Map`\n // constructor for the no-value constructor. This resolves that.\n this.vals = existing ? new WeakMap(existi
|
||
|
\ No newline at end of file
|
||
|
+{"version":3,"file":"map.js","sources":["../../src/-private/map.ts"],"sourcesContent":["import {\n TrackedStorage,\n createStorage,\n getValue,\n setValue,\n} from 'ember-tracked-storage-polyfill';\n\nexport class TrackedMap<K = unknown, V = unknown> implements Map<K, V> {\n private collection = createStorage(null, () => false);\n\n private storages: Map<K, TrackedStorage<null>> = new Map();\n\n private vals: Map<K, V>;\n\n private readStorageFor(key: K): void {\n const { storages } = this;\n let storage = storages.get(key);\n\n if (storage === undefined) {\n storage = createStorage(null, () => false);\n storages.set(key, storage);\n }\n\n getValue(storage);\n }\n\n private dirtyStorageFor(key: K): void {\n const storage = this.storages.get(key);\n\n if (storage) {\n setValue(storage, null);\n }\n }\n\n constructor();\n constructor(entries: readonly (readonly [K, V])[] | null);\n constructor(iterable: Iterable<readonly [K, V]>);\n constructor(\n existing?:\n | readonly (readonly [K, V])[]\n | Iterable<readonly [K, V]>\n | null\n | undefined\n ) {\n // TypeScript doesn't correctly resolve the overloads for calling the `Map`\n // constructor for the no-value constructor. This resolves that.\n this.vals = existing ? new Map(existing) : new Map();\n }\n\n // **** KEY GETTERS ****\n get(key: K): V | undefined {\n // entangle the storage for the key\n this.readStorageFor(key);\n\n return this.vals.get(key);\n }\n\n has(key: K): boolean {\n this.readStorageFor(key);\n\n return this.vals.has(key);\n }\n\n // **** ALL GETTERS ****\n entries(): IterableIterator<[K, V]> {\n getValue(this.collection);\n\n return this.vals.entries();\n }\n\n keys(): IterableIterator<K> {\n getValue(this.collection);\n\n return this.vals.keys();\n }\n\n values(): IterableIterator<V> {\n getValue(this.collection);\n\n return this.vals.values();\n }\n\n forEach(fn: (value: V, key: K, map: Map<K, V>) => void): void {\n getValue(this.collection);\n\n this.vals.forEach(fn);\n }\n\n get size(): number {\n getValue(this.collection);\n\n return this.vals.size;\n }\n\n [Symbol.iterator](): IterableIterator<[K, V]> {\n getValue(this.collection);\n\n return this.vals[Symbol.iterator]();\n }\n\n get [Symbol.toStringTag](): string {\n return this.vals[Symbol.toStringTag];\n }\n\n // **** KEY SETTERS ****\n set(key: K, value: V): this {\n this.dirtyStorageFor(key);\n setValue(this.collection, null);\n\n this.vals.set(key, value);\n\n return this;\n }\n\n delete(key: K): boolean {\n this.dirtyStorageFor(key);\n setValue(this.collection, null);\n\n this.storages.delete(key);\n return this.vals.delete(key);\n }\n\n // **** ALL SETTERS ****\n clear(): void {\n this.storages.forEach((s) => setValue(s, null));\n this.storages.clear();\n\n setValue(this.collection, null);\n this.vals.clear();\n }\n}\n\n// So instanceof works\nObject.setPrototypeOf(TrackedMap.prototype, Map.prototype);\n\nexport class TrackedWeakMap<K extends object = object, V = unknown>\n implements WeakMap<K, V>\n{\n private storages: WeakMap<K, TrackedStorage<null>> = new WeakMap();\n\n private vals: WeakMap<K, V>;\n\n private readStorageFor(key: K): void {\n const { storages } = this;\n let storage = storages.get(key);\n\n if (storage === undefined) {\n storage = createStorage(null, () => false);\n storages.set(key, storage);\n }\n\n getValue(storage);\n }\n\n private dirtyStorageFor(key: K): void {\n const storage = this.storages.get(key);\n\n if (storage) {\n setValue(storage, null);\n }\n }\n\n constructor();\n constructor(iterable: Iterable<readonly [K, V]>);\n constructor(entries: readonly [K, V][] | null);\n constructor(\n existing?: readonly [K, V][] | Iterable<readonly [K, V]> | null | undefined\n ) {\n // TypeScript doesn't correctly resolve the overloads for calling the `Map`\n // constructor for the no-value constructor. This r
|
||
|
\ No newline at end of file
|
||
|
diff --git a/dist/-private/set.js b/dist/-private/set.js
|
||
|
index 93f6728a13891e6e4cecd09c258fccb8aae803b6..44df87ab187511b4da0ea47158fad1cc2643890e 100644
|
||
|
--- a/dist/-private/set.js
|
||
|
+++ b/dist/-private/set.js
|
||
|
@@ -67,6 +67,7 @@ class TrackedSet {
|
||
|
delete(value) {
|
||
|
this.dirtyStorageFor(value);
|
||
|
setValue(this.collection, null);
|
||
|
+ this.storages.delete(value);
|
||
|
return this.vals.delete(value);
|
||
|
}
|
||
|
|
||
|
@@ -74,6 +75,7 @@ class TrackedSet {
|
||
|
clear() {
|
||
|
this.storages.forEach(s => setValue(s, null));
|
||
|
setValue(this.collection, null);
|
||
|
+ this.storages.clear();
|
||
|
this.vals.clear();
|
||
|
}
|
||
|
}
|
||
|
@@ -112,6 +114,7 @@ class TrackedWeakSet {
|
||
|
}
|
||
|
delete(value) {
|
||
|
this.dirtyStorageFor(value);
|
||
|
+ this.storages.delete(value);
|
||
|
return this.vals.delete(value);
|
||
|
}
|
||
|
get [Symbol.toStringTag]() {
|
||
|
diff --git a/dist/-private/set.js.map b/dist/-private/set.js.map
|
||
|
index f2b3867aaaff38e4608de854d0b6bd31017d9153..0f761b60cca57ad4692b0aaaaf52d49e6b8f48a7 100644
|
||
|
--- a/dist/-private/set.js.map
|
||
|
+++ b/dist/-private/set.js.map
|
||
|
@@ -1 +1 @@
|
||
|
-{"version":3,"file":"set.js","sources":["../../src/-private/set.ts"],"sourcesContent":["import {\n TrackedStorage,\n createStorage,\n getValue,\n setValue,\n} from 'ember-tracked-storage-polyfill';\n\nexport class TrackedSet<T = unknown> implements Set<T> {\n private collection = createStorage(null, () => false);\n\n private storages: Map<T, TrackedStorage<null>> = new Map();\n\n private vals: Set<T>;\n\n private storageFor(key: T): TrackedStorage<null> {\n const storages = this.storages;\n let storage = storages.get(key);\n\n if (storage === undefined) {\n storage = createStorage(null, () => false);\n storages.set(key, storage);\n }\n\n return storage;\n }\n\n private dirtyStorageFor(key: T): void {\n const storage = this.storages.get(key);\n\n if (storage) {\n setValue(storage, null);\n }\n }\n\n constructor();\n constructor(values: readonly T[] | null);\n constructor(iterable: Iterable<T>);\n constructor(existing?: readonly T[] | Iterable<T> | null | undefined) {\n this.vals = new Set(existing);\n }\n\n // **** KEY GETTERS ****\n has(value: T): boolean {\n getValue(this.storageFor(value));\n\n return this.vals.has(value);\n }\n\n // **** ALL GETTERS ****\n entries(): IterableIterator<[T, T]> {\n getValue(this.collection);\n\n return this.vals.entries();\n }\n\n keys(): IterableIterator<T> {\n getValue(this.collection);\n\n return this.vals.keys();\n }\n\n values(): IterableIterator<T> {\n getValue(this.collection);\n\n return this.vals.values();\n }\n\n forEach(fn: (value1: T, value2: T, set: Set<T>) => void): void {\n getValue(this.collection);\n\n this.vals.forEach(fn);\n }\n\n get size(): number {\n getValue(this.collection);\n\n return this.vals.size;\n }\n\n [Symbol.iterator](): IterableIterator<T> {\n getValue(this.collection);\n\n return this.vals[Symbol.iterator]();\n }\n\n get [Symbol.toStringTag](): string {\n return this.vals[Symbol.toStringTag];\n }\n\n // **** KEY SETTERS ****\n add(value: T): this {\n this.dirtyStorageFor(value);\n setValue(this.collection, null);\n\n this.vals.add(value);\n\n return this;\n }\n\n delete(value: T): boolean {\n this.dirtyStorageFor(value);\n setValue(this.collection, null);\n\n return this.vals.delete(value);\n }\n\n // **** ALL SETTERS ****\n clear(): void {\n this.storages.forEach((s) => setValue(s, null));\n setValue(this.collection, null);\n\n this.vals.clear();\n }\n}\n\n// So instanceof works\nObject.setPrototypeOf(TrackedSet.prototype, Set.prototype);\n\nexport class TrackedWeakSet<T extends object = object> implements WeakSet<T> {\n private storages: WeakMap<T, TrackedStorage<null>> = new WeakMap();\n\n private vals: WeakSet<T>;\n\n private storageFor(key: T): TrackedStorage<null> {\n const storages = this.storages;\n let storage = storages.get(key);\n\n if (storage === undefined) {\n storage = createStorage(null, () => false);\n storages.set(key, storage);\n }\n\n return storage;\n }\n\n private dirtyStorageFor(key: T): void {\n const storage = this.storages.get(key);\n\n if (storage) {\n setValue(storage, null);\n }\n }\n\n constructor(values?: readonly T[] | null) {\n this.vals = new WeakSet(values);\n }\n\n has(value: T): boolean {\n getValue(this.storageFor(value));\n\n return this.vals.has(value);\n }\n\n add(value: T): this {\n // Add to vals first to get better error message\n this.vals.add(value);\n\n this.dirtyStorageFor(value);\n\n return this;\n }\n\n delete(value: T): boolean {\n this.dirtyStorageFor(value);\n\n return this.vals.delete(value);\n }\n\n get [Symbol.toStringTag](): string {\n return this.vals[Symbol.toStringTag];\n }\n}\n\n// So instanceof works\nObject.setPrototypeOf(TrackedWeakSet.prototype, WeakSet.prototype);\n"],"names":["TrackedSet","collection","createStorage","storages","Map","storageFor","key","storage","get","undefined","set","dirtyStorageFor","setValue","constructor","existing","vals",
|
||
|
\ No newline at end of file
|
||
|
+{"version":3,"file":"set.js","sources":["../../src/-private/set.ts"],"sourcesContent":["import {\n TrackedStorage,\n createStorage,\n getValue,\n setValue,\n} from 'ember-tracked-storage-polyfill';\n\nexport class TrackedSet<T = unknown> implements Set<T> {\n private collection = createStorage(null, () => false);\n\n private storages: Map<T, TrackedStorage<null>> = new Map();\n\n private vals: Set<T>;\n\n private storageFor(key: T): TrackedStorage<null> {\n const storages = this.storages;\n let storage = storages.get(key);\n\n if (storage === undefined) {\n storage = createStorage(null, () => false);\n storages.set(key, storage);\n }\n\n return storage;\n }\n\n private dirtyStorageFor(key: T): void {\n const storage = this.storages.get(key);\n\n if (storage) {\n setValue(storage, null);\n }\n }\n\n constructor();\n constructor(values: readonly T[] | null);\n constructor(iterable: Iterable<T>);\n constructor(existing?: readonly T[] | Iterable<T> | null | undefined) {\n this.vals = new Set(existing);\n }\n\n // **** KEY GETTERS ****\n has(value: T): boolean {\n getValue(this.storageFor(value));\n\n return this.vals.has(value);\n }\n\n // **** ALL GETTERS ****\n entries(): IterableIterator<[T, T]> {\n getValue(this.collection);\n\n return this.vals.entries();\n }\n\n keys(): IterableIterator<T> {\n getValue(this.collection);\n\n return this.vals.keys();\n }\n\n values(): IterableIterator<T> {\n getValue(this.collection);\n\n return this.vals.values();\n }\n\n forEach(fn: (value1: T, value2: T, set: Set<T>) => void): void {\n getValue(this.collection);\n\n this.vals.forEach(fn);\n }\n\n get size(): number {\n getValue(this.collection);\n\n return this.vals.size;\n }\n\n [Symbol.iterator](): IterableIterator<T> {\n getValue(this.collection);\n\n return this.vals[Symbol.iterator]();\n }\n\n get [Symbol.toStringTag](): string {\n return this.vals[Symbol.toStringTag];\n }\n\n // **** KEY SETTERS ****\n add(value: T): this {\n this.dirtyStorageFor(value);\n setValue(this.collection, null);\n\n this.vals.add(value);\n\n return this;\n }\n\n delete(value: T): boolean {\n this.dirtyStorageFor(value);\n setValue(this.collection, null);\n\n this.storages.delete(value);\n return this.vals.delete(value);\n }\n\n // **** ALL SETTERS ****\n clear(): void {\n this.storages.forEach((s) => setValue(s, null));\n setValue(this.collection, null);\n\n this.storages.clear();\n this.vals.clear();\n }\n}\n\n// So instanceof works\nObject.setPrototypeOf(TrackedSet.prototype, Set.prototype);\n\nexport class TrackedWeakSet<T extends object = object> implements WeakSet<T> {\n private storages: WeakMap<T, TrackedStorage<null>> = new WeakMap();\n\n private vals: WeakSet<T>;\n\n private storageFor(key: T): TrackedStorage<null> {\n const storages = this.storages;\n let storage = storages.get(key);\n\n if (storage === undefined) {\n storage = createStorage(null, () => false);\n storages.set(key, storage);\n }\n\n return storage;\n }\n\n private dirtyStorageFor(key: T): void {\n const storage = this.storages.get(key);\n\n if (storage) {\n setValue(storage, null);\n }\n }\n\n constructor(values?: readonly T[] | null) {\n this.vals = new WeakSet(values);\n }\n\n has(value: T): boolean {\n getValue(this.storageFor(value));\n\n return this.vals.has(value);\n }\n\n add(value: T): this {\n // Add to vals first to get better error message\n this.vals.add(value);\n\n this.dirtyStorageFor(value);\n\n return this;\n }\n\n delete(value: T): boolean {\n this.dirtyStorageFor(value);\n\n this.storages.delete(value);\n return this.vals.delete(value);\n }\n\n get [Symbol.toStringTag](): string {\n return this.vals[Symbol.toStringTag];\n }\n}\n\n// So instanceof works\nObject.setPrototypeOf(TrackedWeakSet.prototype, WeakSet.prototype);\n"],"names":["TrackedSet","collection","createStorage","storages","Map","storageFor","key"
|