@aglyn/shared-util-vendor 1.0.0-beta.217 → 1.0.0-beta.219

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/shared-util-vendor",
3
- "version": "1.0.0-beta.217",
3
+ "version": "1.0.0-beta.219",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -28,12 +28,12 @@
28
28
  "@swc/helpers": "0.5.23",
29
29
  "change-case": "^5.4.4",
30
30
  "deep-equal": "^2.2.3",
31
- "deepmerge-ts": "^8.0.1",
31
+ "deepmerge-ts": "^8.0.2",
32
32
  "flat": "^6.0.1",
33
33
  "fuse.js": "^7.5.0",
34
34
  "hoist-non-react-statics": "^3.3.2",
35
35
  "mitt": "^3.0.1",
36
- "mobx-utils": "^6.1.1",
36
+ "mobx": "^7.0.5",
37
37
  "mout": "^1.2.4",
38
38
  "nanoid": "^6.0.1",
39
39
  "nanoid-dictionary": "^5.0.0",
@@ -15,27 +15,64 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  /**
18
- * `computedFn`, and only `computedFn` (AGL-2706).
19
- *
20
- * `mobx-utils`'s package entry is `mobx-utils.module.js`, a single 68 KB
21
- * rollup bundle of the library's forty-odd helpers. The package declares
22
- * `sideEffects: false`, but a declaration is a permission to drop code, not
23
- * an ability to: measured from the tenant route's production source maps,
24
- * **14.0 KB raw** of that bundle was emitted onto every published customer
25
- * page for the one memoizer four modules import — `canvas-manager`,
18
+ * `computedFn`, and only `computedFn` (AGL-2706), vendored (AGL-3410).
19
+ *
20
+ * ## Why this is a copy and not an import
21
+ *
22
+ * It used to re-export `mobx-utils/lib/computedFn.js`. `mobx-utils` 6.1.1 is
23
+ * that package's latest release and peers on `mobx ^6`; it has not shipped
24
+ * since June 2025 and has no line for MobX 7. This library is published, so
25
+ * declaring `mobx-utils` beside the `mobx ^7` the rest of the workspace needs
26
+ * hands every consumer an unsatisfiable peer range — an `ERESOLVE` on any
27
+ * install that enforces peers, which ours (`legacy-peer-deps`) would never
28
+ * show. The helper is ~100 lines over five MobX exports that all survive in
29
+ * 7, so it lives here instead.
30
+ *
31
+ * The body below is `src/computedFn.ts` and `src/deepMap.ts` from mobx-utils
32
+ * v6.1.1, unchanged except for formatting and `DeepMap` becoming module
33
+ * private. Copyright (c) 2016 MobX, MIT License:
34
+ *
35
+ * Permission is hereby granted, free of charge, to any person obtaining a
36
+ * copy of this software and associated documentation files (the
37
+ * "Software"), to deal in the Software without restriction, including
38
+ * without limitation the rights to use, copy, modify, merge, publish,
39
+ * distribute, sublicense, and/or sell copies of the Software, and to permit
40
+ * persons to whom the Software is furnished to do so, subject to the
41
+ * following conditions:
42
+ *
43
+ * The above copyright notice and this permission notice shall be included
44
+ * in all copies or substantial portions of the Software.
45
+ *
46
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
47
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
48
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
49
+ * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
50
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
51
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
52
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
53
+ *
54
+ * ## Why only this one
55
+ *
56
+ * The package entry was a single 68 KB rollup bundle of forty-odd helpers, and
57
+ * 14.0 KB raw of it reached every published customer page for this one
58
+ * memoizer (AGL-2706). Four modules import it: `canvas-manager`,
26
59
  * `components-manager`, the besigner's `focus-manager`, and the loading
27
60
  * context.
28
61
  *
29
- * `lib/computedFn` is the same code from the same package, published
30
- * alongside the bundle, reaching only `lib/deepMap` and `mobx` itself.
62
+ * NOT re-exported from this library's index, per the note there.
63
+ */
64
+ import { type IComputedValueOptions } from 'mobx';
65
+ export type IComputedFnOptions<F extends (...args: any[]) => any> = {
66
+ onCleanup?: (result: ReturnType<F> | undefined, ...args: Parameters<F>) => void;
67
+ } & IComputedValueOptions<ReturnType<F>>;
68
+ /**
69
+ * Memoizes `fn` per argument list for as long as each result is observed.
31
70
  *
32
- * The deep path lives HERE rather than at the four call sites for the reason
33
- * `object-deep-fill-in` and `deep-equal` do: a package's internal layout is a
34
- * thing to depend on in one place, so a version that moves the file is one
35
- * edit rather than a hunt. Jest resolves the same specifier, which is why
36
- * `mobx-utils` is on the preset's transform allowlist — `lib/` is ESM inside
37
- * a package that does not declare `"type": "module"`.
71
+ * Returns a function with the same signature. The argument count must be
72
+ * constant and default arguments are not supported. Outside a reactive
73
+ * context a call is not memoized and is cleaned up immediately, unless
74
+ * `keepAlive` is set — which caches forever and can leak.
38
75
  *
39
- * NOT re-exported from this library's index, per the note there.
76
+ * `fn` must be pure, must not be an action, and should read only observables.
40
77
  */
41
- export { computedFn, type IComputedFnOptions, } from 'mobx-utils/lib/computedFn.js';
78
+ export declare function computedFn<T extends (...args: any[]) => any>(fn: T, keepAliveOrOptions?: IComputedFnOptions<T> | boolean): T;
@@ -1,3 +1,4 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
1
2
  /**
2
3
  * @license
3
4
  * Copyright 2026 Aglyn LLC
@@ -14,28 +15,185 @@
14
15
  * See the License for the specific language governing permissions and
15
16
  * limitations under the License.
16
17
  */ /**
17
- * `computedFn`, and only `computedFn` (AGL-2706).
18
- *
19
- * `mobx-utils`'s package entry is `mobx-utils.module.js`, a single 68 KB
20
- * rollup bundle of the library's forty-odd helpers. The package declares
21
- * `sideEffects: false`, but a declaration is a permission to drop code, not
22
- * an ability to: measured from the tenant route's production source maps,
23
- * **14.0 KB raw** of that bundle was emitted onto every published customer
24
- * page for the one memoizer four modules import — `canvas-manager`,
18
+ * `computedFn`, and only `computedFn` (AGL-2706), vendored (AGL-3410).
19
+ *
20
+ * ## Why this is a copy and not an import
21
+ *
22
+ * It used to re-export `mobx-utils/lib/computedFn.js`. `mobx-utils` 6.1.1 is
23
+ * that package's latest release and peers on `mobx ^6`; it has not shipped
24
+ * since June 2025 and has no line for MobX 7. This library is published, so
25
+ * declaring `mobx-utils` beside the `mobx ^7` the rest of the workspace needs
26
+ * hands every consumer an unsatisfiable peer range — an `ERESOLVE` on any
27
+ * install that enforces peers, which ours (`legacy-peer-deps`) would never
28
+ * show. The helper is ~100 lines over five MobX exports that all survive in
29
+ * 7, so it lives here instead.
30
+ *
31
+ * The body below is `src/computedFn.ts` and `src/deepMap.ts` from mobx-utils
32
+ * v6.1.1, unchanged except for formatting and `DeepMap` becoming module
33
+ * private. Copyright (c) 2016 MobX, MIT License:
34
+ *
35
+ * Permission is hereby granted, free of charge, to any person obtaining a
36
+ * copy of this software and associated documentation files (the
37
+ * "Software"), to deal in the Software without restriction, including
38
+ * without limitation the rights to use, copy, modify, merge, publish,
39
+ * distribute, sublicense, and/or sell copies of the Software, and to permit
40
+ * persons to whom the Software is furnished to do so, subject to the
41
+ * following conditions:
42
+ *
43
+ * The above copyright notice and this permission notice shall be included
44
+ * in all copies or substantial portions of the Software.
45
+ *
46
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
47
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
48
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
49
+ * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
50
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
51
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
52
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
53
+ *
54
+ * ## Why only this one
55
+ *
56
+ * The package entry was a single 68 KB rollup bundle of forty-odd helpers, and
57
+ * 14.0 KB raw of it reached every published customer page for this one
58
+ * memoizer (AGL-2706). Four modules import it: `canvas-manager`,
25
59
  * `components-manager`, the besigner's `focus-manager`, and the loading
26
60
  * context.
27
61
  *
28
- * `lib/computedFn` is the same code from the same package, published
29
- * alongside the bundle, reaching only `lib/deepMap` and `mobx` itself.
62
+ * NOT re-exported from this library's index, per the note there.
63
+ */ import { _getGlobalState, _isComputingDerivation, computed, isAction, onBecomeUnobserved } from "mobx";
64
+ /**
65
+ * Memoizes `fn` per argument list for as long as each result is observed.
30
66
  *
31
- * The deep path lives HERE rather than at the four call sites for the reason
32
- * `object-deep-fill-in` and `deep-equal` do: a package's internal layout is a
33
- * thing to depend on in one place, so a version that moves the file is one
34
- * edit rather than a hunt. Jest resolves the same specifier, which is why
35
- * `mobx-utils` is on the preset's transform allowlist — `lib/` is ESM inside
36
- * a package that does not declare `"type": "module"`.
67
+ * Returns a function with the same signature. The argument count must be
68
+ * constant and default arguments are not supported. Outside a reactive
69
+ * context a call is not memoized and is cleaned up immediately, unless
70
+ * `keepAlive` is set — which caches forever and can leak.
37
71
  *
38
- * NOT re-exported from this library's index, per the note there.
39
- */ export { computedFn } from "mobx-utils/lib/computedFn.js";
72
+ * `fn` must be pure, must not be an action, and should read only observables.
73
+ */ export function computedFn(fn, keepAliveOrOptions = false) {
74
+ if (isAction(fn)) throw new Error("computedFn shouldn't be used on actions");
75
+ let memoWarned = false;
76
+ let i = 0;
77
+ const opts = typeof keepAliveOrOptions === 'boolean' ? {
78
+ keepAlive: keepAliveOrOptions
79
+ } : keepAliveOrOptions;
80
+ const d = new DeepMap();
81
+ return function(...args) {
82
+ const entry = d.entry(args);
83
+ // cache hit, return
84
+ if (entry.exists()) return entry.get().get();
85
+ // a cache miss outside a reactive context has nothing to keep it alive
86
+ if (!opts.keepAlive && !_isComputingDerivation()) {
87
+ var _opts_requiresReaction;
88
+ if (!memoWarned && ((_opts_requiresReaction = opts.requiresReaction) != null ? _opts_requiresReaction : _getGlobalState().computedRequiresReaction)) {
89
+ console.warn("Invoking a computedFn from outside a reactive context won't be memoized " + 'and is cleaned up immediately, unless keepAlive is set.');
90
+ memoWarned = true;
91
+ }
92
+ const value = fn.apply(this, args);
93
+ if (opts.onCleanup) opts.onCleanup(value, ...args);
94
+ return value;
95
+ }
96
+ // create new entry
97
+ let latestValue;
98
+ const c = computed(()=>{
99
+ return latestValue = fn.apply(this, args);
100
+ }, _extends({}, opts, {
101
+ name: `computedFn(${opts.name || fn.name}#${++i})`
102
+ }));
103
+ entry.set(c);
104
+ // clean up if no longer observed
105
+ if (!opts.keepAlive) onBecomeUnobserved(c, ()=>{
106
+ d.entry(args).delete();
107
+ if (opts.onCleanup) opts.onCleanup(latestValue, ...args);
108
+ latestValue = undefined;
109
+ });
110
+ // return current val
111
+ return c.get();
112
+ };
113
+ }
114
+ let DeepMapEntry = class DeepMapEntry {
115
+ exists() {
116
+ this.assertCurrentVersion();
117
+ const l = this.args.length;
118
+ return this.closestIdx >= l - 1 && this.closest.has(this.args[l - 1]);
119
+ }
120
+ get() {
121
+ this.assertCurrentVersion();
122
+ if (!this.exists()) throw new Error("Entry doesn't exist");
123
+ return this.closest.get(this.args[this.args.length - 1]);
124
+ }
125
+ set(value) {
126
+ this.assertCurrentVersion();
127
+ const l = this.args.length;
128
+ let current = this.closest;
129
+ // create remaining maps
130
+ for(let i = this.closestIdx; i < l - 1; i++){
131
+ const m = new Map();
132
+ current.set(this.args[i], m);
133
+ current = m;
134
+ }
135
+ this.closestIdx = l - 1;
136
+ this.closest = current;
137
+ current.set(this.args[l - 1], value);
138
+ }
139
+ delete() {
140
+ this.assertCurrentVersion();
141
+ if (!this.exists()) throw new Error("Entry doesn't exist");
142
+ const l = this.args.length;
143
+ this.closest.delete(this.args[l - 1]);
144
+ // clean up remaining maps if needed (reconstruct stack first)
145
+ let c = this.root;
146
+ const maps = [
147
+ c
148
+ ];
149
+ for(let i = 0; i < l - 1; i++){
150
+ c = c.get(this.args[i]);
151
+ maps.push(c);
152
+ }
153
+ for(let i = maps.length - 1; i > 0; i--){
154
+ if (maps[i].size === 0) maps[i - 1].delete(this.args[i - 1]);
155
+ }
156
+ }
157
+ assertCurrentVersion() {
158
+ if (!this.versionChecker(this.version)) {
159
+ throw new Error('Concurrent modification exception');
160
+ }
161
+ }
162
+ constructor(base, args, version, versionChecker){
163
+ this.base = base;
164
+ this.args = args;
165
+ this.version = version;
166
+ this.versionChecker = versionChecker;
167
+ this.closestIdx = 0;
168
+ let current = this.closest = this.root = base;
169
+ let i = 0;
170
+ for(; i < this.args.length - 1; i++){
171
+ current = current.get(args[i]);
172
+ if (current) this.closest = current;
173
+ else break;
174
+ }
175
+ this.closestIdx = i;
176
+ }
177
+ };
178
+ let DeepMap = class DeepMap {
179
+ entry(args) {
180
+ if (this.argsLength === -1) this.argsLength = args.length;
181
+ else if (this.argsLength !== args.length) throw new Error(`DeepMap should be used with functions with a consistent length, expected: ${this.argsLength}, got: ${args.length}`);
182
+ if (this.currentVersion >= Number.MAX_SAFE_INTEGER) {
183
+ // Reset version counter when it reaches max safe integer
184
+ this.currentVersion = 0;
185
+ }
186
+ this.currentVersion++;
187
+ return new DeepMapEntry(this.store, args, this.currentVersion, this.checkVersion);
188
+ }
189
+ constructor(){
190
+ this.store = new Map();
191
+ this.argsLength = -1;
192
+ this.currentVersion = 0;
193
+ this.checkVersion = (version)=>{
194
+ return this.currentVersion === version;
195
+ };
196
+ }
197
+ };
40
198
 
41
199
  //# sourceMappingURL=mobx-computed-fn.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/shared/util/vendor/src/lib/mobx-computed-fn.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * `computedFn`, and only `computedFn` (AGL-2706).\n *\n * `mobx-utils`'s package entry is `mobx-utils.module.js`, a single 68 KB\n * rollup bundle of the library's forty-odd helpers. The package declares\n * `sideEffects: false`, but a declaration is a permission to drop code, not\n * an ability to: measured from the tenant route's production source maps,\n * **14.0 KB raw** of that bundle was emitted onto every published customer\n * page for the one memoizer four modules import — `canvas-manager`,\n * `components-manager`, the besigner's `focus-manager`, and the loading\n * context.\n *\n * `lib/computedFn` is the same code from the same package, published\n * alongside the bundle, reaching only `lib/deepMap` and `mobx` itself.\n *\n * The deep path lives HERE rather than at the four call sites for the reason\n * `object-deep-fill-in` and `deep-equal` do: a package's internal layout is a\n * thing to depend on in one place, so a version that moves the file is one\n * edit rather than a hunt. Jest resolves the same specifier, which is why\n * `mobx-utils` is on the preset's transform allowlist — `lib/` is ESM inside\n * a package that does not declare `\"type\": \"module\"`.\n *\n * NOT re-exported from this library's index, per the note there.\n */\nexport {\n computedFn,\n type IComputedFnOptions,\n} from 'mobx-utils/lib/computedFn.js'\n"],"names":["computedFn"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,SACEA,UAAU,QAEL,+BAA8B"}
1
+ {"version":3,"sources":["../../../../../../../libs/shared/util/vendor/src/lib/mobx-computed-fn.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * `computedFn`, and only `computedFn` (AGL-2706), vendored (AGL-3410).\n *\n * ## Why this is a copy and not an import\n *\n * It used to re-export `mobx-utils/lib/computedFn.js`. `mobx-utils` 6.1.1 is\n * that package's latest release and peers on `mobx ^6`; it has not shipped\n * since June 2025 and has no line for MobX 7. This library is published, so\n * declaring `mobx-utils` beside the `mobx ^7` the rest of the workspace needs\n * hands every consumer an unsatisfiable peer range — an `ERESOLVE` on any\n * install that enforces peers, which ours (`legacy-peer-deps`) would never\n * show. The helper is ~100 lines over five MobX exports that all survive in\n * 7, so it lives here instead.\n *\n * The body below is `src/computedFn.ts` and `src/deepMap.ts` from mobx-utils\n * v6.1.1, unchanged except for formatting and `DeepMap` becoming module\n * private. Copyright (c) 2016 MobX, MIT License:\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to permit\n * persons to whom the Software is furnished to do so, subject to the\n * following conditions:\n *\n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n * USE OR OTHER DEALINGS IN THE SOFTWARE.\n *\n * ## Why only this one\n *\n * The package entry was a single 68 KB rollup bundle of forty-odd helpers, and\n * 14.0 KB raw of it reached every published customer page for this one\n * memoizer (AGL-2706). Four modules import it: `canvas-manager`,\n * `components-manager`, the besigner's `focus-manager`, and the loading\n * context.\n *\n * NOT re-exported from this library's index, per the note there.\n */\n\nimport {\n type IComputedValue,\n type IComputedValueOptions,\n _getGlobalState,\n _isComputingDerivation,\n computed,\n isAction,\n onBecomeUnobserved,\n} from 'mobx'\n\nexport type IComputedFnOptions<F extends (...args: any[]) => any> = {\n onCleanup?: (\n result: ReturnType<F> | undefined,\n ...args: Parameters<F>\n ) => void\n} & IComputedValueOptions<ReturnType<F>>\n\n/**\n * Memoizes `fn` per argument list for as long as each result is observed.\n *\n * Returns a function with the same signature. The argument count must be\n * constant and default arguments are not supported. Outside a reactive\n * context a call is not memoized and is cleaned up immediately, unless\n * `keepAlive` is set — which caches forever and can leak.\n *\n * `fn` must be pure, must not be an action, and should read only observables.\n */\nexport function computedFn<T extends (...args: any[]) => any>(\n fn: T,\n keepAliveOrOptions: IComputedFnOptions<T> | boolean = false,\n): T {\n if (isAction(fn)) throw new Error(\"computedFn shouldn't be used on actions\")\n\n let memoWarned = false\n let i = 0\n const opts =\n typeof keepAliveOrOptions === 'boolean'\n ? { keepAlive: keepAliveOrOptions }\n : keepAliveOrOptions\n const d = new DeepMap<IComputedValue<any>>()\n\n return function (this: any, ...args: Parameters<T>): ReturnType<T> {\n const entry = d.entry(args)\n // cache hit, return\n if (entry.exists()) return entry.get().get()\n // a cache miss outside a reactive context has nothing to keep it alive\n if (!opts.keepAlive && !_isComputingDerivation()) {\n if (\n !memoWarned &&\n (opts.requiresReaction ?? _getGlobalState().computedRequiresReaction)\n ) {\n console.warn(\n \"Invoking a computedFn from outside a reactive context won't be memoized \" +\n 'and is cleaned up immediately, unless keepAlive is set.',\n )\n memoWarned = true\n }\n const value = fn.apply(this, args)\n if (opts.onCleanup) opts.onCleanup(value, ...args)\n return value\n }\n // create new entry\n let latestValue: ReturnType<T> | undefined\n const c = computed(\n () => {\n return (latestValue = fn.apply(this, args))\n },\n {\n ...opts,\n name: `computedFn(${opts.name || fn.name}#${++i})`,\n },\n )\n entry.set(c)\n // clean up if no longer observed\n if (!opts.keepAlive)\n onBecomeUnobserved(c, () => {\n d.entry(args).delete()\n if (opts.onCleanup) opts.onCleanup(latestValue, ...args)\n latestValue = undefined\n })\n // return current val\n return c.get()\n } as any\n}\n\nclass DeepMapEntry<T> {\n private root: Map<any, any>\n private closest: Map<any, any>\n private closestIdx = 0\n\n constructor(\n private base: Map<any, any>,\n private args: any[],\n private version: number,\n private versionChecker: (version: number) => boolean,\n ) {\n let current: undefined | Map<any, any> = (this.closest = this.root = base)\n let i = 0\n for (; i < this.args.length - 1; i++) {\n current = current!.get(args[i])\n if (current) this.closest = current\n else break\n }\n this.closestIdx = i\n }\n\n exists(): boolean {\n this.assertCurrentVersion()\n const l = this.args.length\n return this.closestIdx >= l - 1 && this.closest.has(this.args[l - 1])\n }\n\n get(): T {\n this.assertCurrentVersion()\n if (!this.exists()) throw new Error(\"Entry doesn't exist\")\n return this.closest.get(this.args[this.args.length - 1])\n }\n\n set(value: T) {\n this.assertCurrentVersion()\n const l = this.args.length\n let current: Map<any, any> = this.closest\n // create remaining maps\n for (let i = this.closestIdx; i < l - 1; i++) {\n const m = new Map()\n current.set(this.args[i], m)\n current = m\n }\n this.closestIdx = l - 1\n this.closest = current\n current.set(this.args[l - 1], value)\n }\n\n delete() {\n this.assertCurrentVersion()\n if (!this.exists()) throw new Error(\"Entry doesn't exist\")\n const l = this.args.length\n this.closest.delete(this.args[l - 1])\n // clean up remaining maps if needed (reconstruct stack first)\n let c = this.root\n const maps: Map<any, any>[] = [c]\n for (let i = 0; i < l - 1; i++) {\n c = c.get(this.args[i])!\n maps.push(c)\n }\n for (let i = maps.length - 1; i > 0; i--) {\n if (maps[i].size === 0) maps[i - 1].delete(this.args[i - 1])\n }\n }\n\n private assertCurrentVersion() {\n if (!this.versionChecker(this.version)) {\n throw new Error('Concurrent modification exception')\n }\n }\n}\n\nclass DeepMap<T> {\n private store = new Map<any, any>()\n private argsLength = -1\n private currentVersion = 0\n\n private checkVersion = (version: number) => {\n return this.currentVersion === version\n }\n\n entry(args: any[]): DeepMapEntry<T> {\n if (this.argsLength === -1) this.argsLength = args.length\n else if (this.argsLength !== args.length)\n throw new Error(\n `DeepMap should be used with functions with a consistent length, expected: ${this.argsLength}, got: ${args.length}`,\n )\n\n if (this.currentVersion >= Number.MAX_SAFE_INTEGER) {\n // Reset version counter when it reaches max safe integer\n this.currentVersion = 0\n }\n\n this.currentVersion++\n return new DeepMapEntry(\n this.store,\n args,\n this.currentVersion,\n this.checkVersion,\n )\n }\n}\n"],"names":["_getGlobalState","_isComputingDerivation","computed","isAction","onBecomeUnobserved","computedFn","fn","keepAliveOrOptions","Error","memoWarned","i","opts","keepAlive","d","DeepMap","args","entry","exists","get","requiresReaction","computedRequiresReaction","console","warn","value","apply","onCleanup","latestValue","c","name","set","delete","undefined","DeepMapEntry","assertCurrentVersion","l","length","closestIdx","closest","has","current","m","Map","root","maps","push","size","versionChecker","version","base","argsLength","currentVersion","Number","MAX_SAFE_INTEGER","store","checkVersion"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CC,GAED,SAGEA,eAAe,EACfC,sBAAsB,EACtBC,QAAQ,EACRC,QAAQ,EACRC,kBAAkB,QACb,OAAM;AASb;;;;;;;;;CASC,GACD,OAAO,SAASC,WACdC,EAAK,EACLC,qBAAsD,KAAK;IAE3D,IAAIJ,SAASG,KAAK,MAAM,IAAIE,MAAM;IAElC,IAAIC,aAAa;IACjB,IAAIC,IAAI;IACR,MAAMC,OACJ,OAAOJ,uBAAuB,YAC1B;QAAEK,WAAWL;IAAmB,IAChCA;IACN,MAAMM,IAAI,IAAIC;IAEd,OAAO,SAAqB,GAAGC,IAAmB;QAChD,MAAMC,QAAQH,EAAEG,KAAK,CAACD;QACtB,oBAAoB;QACpB,IAA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