cross-state 0.6.7 → 0.6.9
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/cjs/hash.cjs +712 -0
- package/dist/cjs/hash.cjs.map +1 -0
- package/dist/cjs/immer.cjs +7 -2
- package/dist/cjs/immer.cjs.map +1 -1
- package/dist/cjs/index.cjs +341 -19
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/react.cjs +289 -11
- package/dist/cjs/react.cjs.map +1 -1
- package/dist/es/hash.mjs +713 -0
- package/dist/es/hash.mjs.map +1 -0
- package/dist/es/{immer/immerActions.js → immer.mjs} +1 -1
- package/dist/es/immer.mjs.map +1 -0
- package/dist/es/{core/cache.js → index.mjs} +126 -8
- package/dist/es/index.mjs.map +1 -0
- package/dist/es/react.mjs +292 -0
- package/dist/es/react.mjs.map +1 -0
- package/package.json +8 -8
- package/dist/cjs/_virtual/use-sync-external-store-with-selector.development.cjs +0 -103
- package/dist/cjs/_virtual/use-sync-external-store-with-selector.development.cjs.map +0 -1
- package/dist/cjs/_virtual/use-sync-external-store-with-selector.development2.cjs +0 -5
- package/dist/cjs/_virtual/use-sync-external-store-with-selector.development2.cjs.map +0 -1
- package/dist/cjs/_virtual/use-sync-external-store-with-selector.production.min.cjs +0 -71
- package/dist/cjs/_virtual/use-sync-external-store-with-selector.production.min.cjs.map +0 -1
- package/dist/cjs/_virtual/use-sync-external-store-with-selector.production.min2.cjs +0 -5
- package/dist/cjs/_virtual/use-sync-external-store-with-selector.production.min2.cjs.map +0 -1
- package/dist/cjs/_virtual/with-selector.cjs +0 -12
- package/dist/cjs/_virtual/with-selector.cjs.map +0 -1
- package/dist/cjs/_virtual/with-selector2.cjs +0 -13
- package/dist/cjs/_virtual/with-selector2.cjs.map +0 -1
- package/dist/cjs/core/cache.cjs +0 -227
- package/dist/cjs/core/cache.cjs.map +0 -1
- package/dist/cjs/core/resourceGroup.cjs +0 -53
- package/dist/cjs/core/resourceGroup.cjs.map +0 -1
- package/dist/cjs/core/store.cjs +0 -259
- package/dist/cjs/core/store.cjs.map +0 -1
- package/dist/cjs/immer/immerActions.cjs +0 -10
- package/dist/cjs/immer/immerActions.cjs.map +0 -1
- package/dist/cjs/lib/calcDuration.cjs +0 -9
- package/dist/cjs/lib/calcDuration.cjs.map +0 -1
- package/dist/cjs/lib/calculationHelper.cjs +0 -140
- package/dist/cjs/lib/calculationHelper.cjs.map +0 -1
- package/dist/cjs/lib/callable.cjs +0 -11
- package/dist/cjs/lib/callable.cjs.map +0 -1
- package/dist/cjs/lib/clone.cjs +0 -19
- package/dist/cjs/lib/clone.cjs.map +0 -1
- package/dist/cjs/lib/debounce.cjs +0 -28
- package/dist/cjs/lib/debounce.cjs.map +0 -1
- package/dist/cjs/lib/equals.cjs +0 -5
- package/dist/cjs/lib/equals.cjs.map +0 -1
- package/dist/cjs/lib/forwardError.cjs +0 -9
- package/dist/cjs/lib/forwardError.cjs.map +0 -1
- package/dist/cjs/lib/hash.cjs +0 -19
- package/dist/cjs/lib/hash.cjs.map +0 -1
- package/dist/cjs/lib/instanceCache.cjs +0 -68
- package/dist/cjs/lib/instanceCache.cjs.map +0 -1
- package/dist/cjs/lib/makeSelector.cjs +0 -14
- package/dist/cjs/lib/makeSelector.cjs.map +0 -1
- package/dist/cjs/lib/propAccess.cjs +0 -66
- package/dist/cjs/lib/propAccess.cjs.map +0 -1
- package/dist/cjs/lib/queue.cjs +0 -61
- package/dist/cjs/lib/queue.cjs.map +0 -1
- package/dist/cjs/lib/standardMethods.cjs +0 -78
- package/dist/cjs/lib/standardMethods.cjs.map +0 -1
- package/dist/cjs/lib/throttle.cjs +0 -25
- package/dist/cjs/lib/throttle.cjs.map +0 -1
- package/dist/cjs/lib/trackingProxy.cjs +0 -39
- package/dist/cjs/lib/trackingProxy.cjs.map +0 -1
- package/dist/cjs/react/read.cjs +0 -15
- package/dist/cjs/react/read.cjs.map +0 -1
- package/dist/cjs/react/storeScope.cjs +0 -31
- package/dist/cjs/react/storeScope.cjs.map +0 -1
- package/dist/cjs/react/useCache.cjs +0 -31
- package/dist/cjs/react/useCache.cjs.map +0 -1
- package/dist/cjs/react/useProp.cjs +0 -9
- package/dist/cjs/react/useProp.cjs.map +0 -1
- package/dist/cjs/react/useStore.cjs +0 -51
- package/dist/cjs/react/useStore.cjs.map +0 -1
- package/dist/es/_virtual/use-sync-external-store-with-selector.development.js +0 -103
- package/dist/es/_virtual/use-sync-external-store-with-selector.development.js.map +0 -1
- package/dist/es/_virtual/use-sync-external-store-with-selector.development2.js +0 -5
- package/dist/es/_virtual/use-sync-external-store-with-selector.development2.js.map +0 -1
- package/dist/es/_virtual/use-sync-external-store-with-selector.production.min.js +0 -71
- package/dist/es/_virtual/use-sync-external-store-with-selector.production.min.js.map +0 -1
- package/dist/es/_virtual/use-sync-external-store-with-selector.production.min2.js +0 -5
- package/dist/es/_virtual/use-sync-external-store-with-selector.production.min2.js.map +0 -1
- package/dist/es/_virtual/with-selector.js +0 -11
- package/dist/es/_virtual/with-selector.js.map +0 -1
- package/dist/es/_virtual/with-selector2.js +0 -14
- package/dist/es/_virtual/with-selector2.js.map +0 -1
- package/dist/es/core/cache.js.map +0 -1
- package/dist/es/core/resourceGroup.js +0 -53
- package/dist/es/core/resourceGroup.js.map +0 -1
- package/dist/es/core/store.js +0 -259
- package/dist/es/core/store.js.map +0 -1
- package/dist/es/immer/immerActions.js.map +0 -1
- package/dist/es/immer.js +0 -5
- package/dist/es/immer.js.map +0 -1
- package/dist/es/index.js +0 -22
- package/dist/es/index.js.map +0 -1
- package/dist/es/lib/calcDuration.js +0 -9
- package/dist/es/lib/calcDuration.js.map +0 -1
- package/dist/es/lib/calculationHelper.js +0 -140
- package/dist/es/lib/calculationHelper.js.map +0 -1
- package/dist/es/lib/callable.js +0 -11
- package/dist/es/lib/callable.js.map +0 -1
- package/dist/es/lib/clone.js +0 -19
- package/dist/es/lib/clone.js.map +0 -1
- package/dist/es/lib/debounce.js +0 -28
- package/dist/es/lib/debounce.js.map +0 -1
- package/dist/es/lib/equals.js +0 -5
- package/dist/es/lib/equals.js.map +0 -1
- package/dist/es/lib/forwardError.js +0 -9
- package/dist/es/lib/forwardError.js.map +0 -1
- package/dist/es/lib/hash.js +0 -19
- package/dist/es/lib/hash.js.map +0 -1
- package/dist/es/lib/instanceCache.js +0 -68
- package/dist/es/lib/instanceCache.js.map +0 -1
- package/dist/es/lib/makeSelector.js +0 -14
- package/dist/es/lib/makeSelector.js.map +0 -1
- package/dist/es/lib/propAccess.js +0 -66
- package/dist/es/lib/propAccess.js.map +0 -1
- package/dist/es/lib/queue.js +0 -61
- package/dist/es/lib/queue.js.map +0 -1
- package/dist/es/lib/standardMethods.js +0 -78
- package/dist/es/lib/standardMethods.js.map +0 -1
- package/dist/es/lib/throttle.js +0 -25
- package/dist/es/lib/throttle.js.map +0 -1
- package/dist/es/lib/trackingProxy.js +0 -39
- package/dist/es/lib/trackingProxy.js.map +0 -1
- package/dist/es/react/read.js +0 -15
- package/dist/es/react/read.js.map +0 -1
- package/dist/es/react/storeScope.js +0 -31
- package/dist/es/react/storeScope.js.map +0 -1
- package/dist/es/react/useCache.js +0 -31
- package/dist/es/react/useCache.js.map +0 -1
- package/dist/es/react/useProp.js +0 -9
- package/dist/es/react/useProp.js.map +0 -1
- package/dist/es/react/useStore.js +0 -51
- package/dist/es/react/useStore.js.map +0 -1
- package/dist/es/react.js +0 -14
- package/dist/es/react.js.map +0 -1
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const hash = require("./hash.cjs");
|
|
4
|
-
class InstanceCache {
|
|
5
|
-
constructor(factory, cacheTime) {
|
|
6
|
-
this.factory = factory;
|
|
7
|
-
this.cacheTime = cacheTime;
|
|
8
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
9
|
-
this.interval = this.cacheTime ? setInterval(() => this.cleanup(), Math.max(this.cacheTime / 10, 1)) : void 0;
|
|
10
|
-
}
|
|
11
|
-
cleanup() {
|
|
12
|
-
var _a;
|
|
13
|
-
const cutoff = this.now() - (this.cacheTime ?? 0);
|
|
14
|
-
for (const [key, entry] of this.cache.entries()) {
|
|
15
|
-
if (entry.ref && entry.t <= cutoff) {
|
|
16
|
-
delete entry.ref;
|
|
17
|
-
}
|
|
18
|
-
if (!entry.ref && !((_a = entry.weakRef) == null ? void 0 : _a.deref())) {
|
|
19
|
-
this.cache.delete(key);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
get(...args) {
|
|
24
|
-
var _a;
|
|
25
|
-
const key = hash.hash(args);
|
|
26
|
-
let entry = this.cache.get(key);
|
|
27
|
-
let value = (entry == null ? void 0 : entry.ref) ?? ((_a = entry == null ? void 0 : entry.weakRef) == null ? void 0 : _a.deref());
|
|
28
|
-
if (!entry || !value) {
|
|
29
|
-
value = this.factory(...args);
|
|
30
|
-
entry = {
|
|
31
|
-
t: this.now(),
|
|
32
|
-
ref: value,
|
|
33
|
-
weakRef: new WeakRef(value)
|
|
34
|
-
};
|
|
35
|
-
this.cache.set(key, entry);
|
|
36
|
-
} else {
|
|
37
|
-
entry.t = this.now();
|
|
38
|
-
entry.ref ?? (entry.ref = value);
|
|
39
|
-
}
|
|
40
|
-
return value;
|
|
41
|
-
}
|
|
42
|
-
values() {
|
|
43
|
-
return [...this.cache.values()].map((entry) => {
|
|
44
|
-
var _a;
|
|
45
|
-
return entry.ref ?? ((_a = entry.weakRef) == null ? void 0 : _a.deref());
|
|
46
|
-
}).filter((value) => !!value);
|
|
47
|
-
}
|
|
48
|
-
stop() {
|
|
49
|
-
if (this.interval) {
|
|
50
|
-
clearInterval(this.interval);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
stats() {
|
|
54
|
-
return {
|
|
55
|
-
count: this.cache.size,
|
|
56
|
-
withRef: [...this.cache.values()].filter((x) => !!x.ref).length,
|
|
57
|
-
withWeakRef: [...this.cache.values()].filter((x) => {
|
|
58
|
-
var _a;
|
|
59
|
-
return !!((_a = x.weakRef) == null ? void 0 : _a.deref());
|
|
60
|
-
}).length
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
now() {
|
|
64
|
-
return performance.now();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.InstanceCache = InstanceCache;
|
|
68
|
-
//# sourceMappingURL=instanceCache.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instanceCache.cjs","sources":["../../../src/lib/instanceCache.ts"],"sourcesContent":["import { hash } from './hash';\n\nexport class InstanceCache<Args extends any[], T extends object> {\n private cache = new Map<string, { t: number; ref?: T; weakRef: WeakRef<T> }>();\n\n private interval = this.cacheTime\n ? setInterval(() => this.cleanup(), Math.max(this.cacheTime / 10, 1))\n : undefined;\n\n constructor(public readonly factory: (...args: Args) => T, public readonly cacheTime?: number) {}\n\n cleanup() {\n const cutoff = this.now() - (this.cacheTime ?? 0);\n\n for (const [key, entry] of this.cache.entries()) {\n if (entry.ref && entry.t <= cutoff) {\n delete entry.ref;\n }\n\n if (!entry.ref && !entry.weakRef?.deref()) {\n this.cache.delete(key);\n }\n }\n }\n\n get(...args: Args) {\n const key = hash(args);\n let entry = this.cache.get(key);\n let value = entry?.ref ?? entry?.weakRef?.deref();\n\n if (!entry || !value) {\n value = this.factory(...args);\n entry = {\n t: this.now(),\n ref: value,\n weakRef: new WeakRef(value),\n };\n\n this.cache.set(key, entry);\n } else {\n entry.t = this.now();\n entry.ref ??= value;\n }\n\n return value;\n }\n\n values() {\n return [...this.cache.values()]\n .map((entry) => entry.ref ?? entry.weakRef?.deref())\n .filter((value): value is T => !!value);\n }\n\n stop() {\n if (this.interval) {\n clearInterval(this.interval);\n }\n }\n\n stats() {\n return {\n count: this.cache.size,\n withRef: [...this.cache.values()].filter((x) => !!x.ref).length,\n withWeakRef: [...this.cache.values()].filter((x) => !!x.weakRef?.deref()).length,\n };\n }\n\n private now() {\n return performance.now();\n }\n}\n"],"names":["hash"],"mappings":";;;AAEO,MAAM,cAAoD;AAAA,EAO/D,YAA4B,SAA+C,WAAoB;AAAnE,SAAA,UAAA;AAA+C,SAAA,YAAA;AANnE,SAAA,4BAAY;AAEpB,SAAQ,WAAW,KAAK,YACpB,YAAY,MAAM,KAAK,QAAW,GAAA,KAAK,IAAI,KAAK,YAAY,IAAI,CAAC,CAAC,IAClE;AAAA,EAE4F;AAAA,EAEhG,UAAU;;AACR,UAAM,SAAS,KAAK,IAAI,KAAK,KAAK,aAAa;AAE/C,eAAW,CAAC,KAAK,KAAK,KAAK,KAAK,MAAM,WAAW;AAC/C,UAAI,MAAM,OAAO,MAAM,KAAK,QAAQ;AAClC,eAAO,MAAM;AAAA,MACf;AAEA,UAAI,CAAC,MAAM,OAAO,GAAC,WAAM,YAAN,mBAAe,UAAS;AACpC,aAAA,MAAM,OAAO,GAAG;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAO,MAAY;;AACX,UAAA,MAAMA,UAAK,IAAI;AACrB,QAAI,QAAQ,KAAK,MAAM,IAAI,GAAG;AAC9B,QAAI,SAAQ,+BAAO,UAAO,oCAAO,YAAP,mBAAgB;AAEtC,QAAA,CAAC,SAAS,CAAC,OAAO;AACZ,cAAA,KAAK,QAAQ,GAAG,IAAI;AACpB,cAAA;AAAA,QACN,GAAG,KAAK,IAAI;AAAA,QACZ,KAAK;AAAA,QACL,SAAS,IAAI,QAAQ,KAAK;AAAA,MAAA;AAGvB,WAAA,MAAM,IAAI,KAAK,KAAK;AAAA,IAAA,OACpB;AACC,YAAA,IAAI,KAAK;AACf,YAAM,QAAN,MAAM,MAAQ;AAAA,IAChB;AAEO,WAAA;AAAA,EACT;AAAA,EAEA,SAAS;AACA,WAAA,CAAC,GAAG,KAAK,MAAM,OAAQ,CAAA,EAC3B,IAAI,CAAC;;AAAU,mBAAM,SAAO,WAAM,YAAN,mBAAe;AAAA,KAAO,EAClD,OAAO,CAAC,UAAsB,CAAC,CAAC,KAAK;AAAA,EAC1C;AAAA,EAEA,OAAO;AACL,QAAI,KAAK,UAAU;AACjB,oBAAc,KAAK,QAAQ;AAAA,IAC7B;AAAA,EACF;AAAA,EAEA,QAAQ;AACC,WAAA;AAAA,MACL,OAAO,KAAK,MAAM;AAAA,MAClB,SAAS,CAAC,GAAG,KAAK,MAAM,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE;AAAA,MACzD,aAAa,CAAC,GAAG,KAAK,MAAM,OAAQ,CAAA,EAAE,OAAO,CAAC;;AAAM,gBAAC,GAAC,OAAE,YAAF,mBAAW;AAAA,OAAO,EAAE;AAAA,IAAA;AAAA,EAE9E;AAAA,EAEQ,MAAM;AACZ,WAAO,YAAY;EACrB;AACF;;"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const propAccess = require("./propAccess.cjs");
|
|
4
|
-
function makeSelector(selector) {
|
|
5
|
-
if (!selector) {
|
|
6
|
-
return (x) => x;
|
|
7
|
-
}
|
|
8
|
-
if (selector instanceof Function) {
|
|
9
|
-
return selector;
|
|
10
|
-
}
|
|
11
|
-
return (x) => propAccess.get(x, selector);
|
|
12
|
-
}
|
|
13
|
-
exports.makeSelector = makeSelector;
|
|
14
|
-
//# sourceMappingURL=makeSelector.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"makeSelector.cjs","sources":["../../../src/lib/makeSelector.ts"],"sourcesContent":["import type { Path } from './path';\nimport { get } from './propAccess';\n\nexport function makeSelector<T, S>(selector?: ((value: T) => S) | Path<any>): (value: T) => S {\n if (!selector) {\n return (x) => x as any;\n }\n\n if (selector instanceof Function) {\n return selector;\n }\n\n return (x) => get(x, selector as any) as any;\n}\n"],"names":["get"],"mappings":";;;AAGO,SAAS,aAAmB,UAA2D;AAC5F,MAAI,CAAC,UAAU;AACb,WAAO,CAAC,MAAM;AAAA,EAChB;AAEA,MAAI,oBAAoB,UAAU;AACzB,WAAA;AAAA,EACT;AAEA,SAAO,CAAC,MAAMA,WAAAA,IAAI,GAAG,QAAe;AACtC;;"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const clone = require("./clone.cjs");
|
|
4
|
-
function castArrayPath(path) {
|
|
5
|
-
if (Array.isArray(path)) {
|
|
6
|
-
return path;
|
|
7
|
-
}
|
|
8
|
-
if (path === "") {
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
return path.split(".");
|
|
12
|
-
}
|
|
13
|
-
function get(object, path) {
|
|
14
|
-
const _path = castArrayPath(path);
|
|
15
|
-
const [first, ...rest] = _path;
|
|
16
|
-
if (first === void 0 || !object) {
|
|
17
|
-
return object;
|
|
18
|
-
}
|
|
19
|
-
if (object instanceof Map) {
|
|
20
|
-
return get(object.get(first), rest);
|
|
21
|
-
}
|
|
22
|
-
if (object instanceof Set) {
|
|
23
|
-
return get(Array.from(object)[Number(first)], rest);
|
|
24
|
-
}
|
|
25
|
-
if (object instanceof Object) {
|
|
26
|
-
return get(object[first], rest);
|
|
27
|
-
}
|
|
28
|
-
throw new Error(`Could not get ${path} of ${object}`);
|
|
29
|
-
}
|
|
30
|
-
function set(object, path, value, rootPath = path) {
|
|
31
|
-
const _path = castArrayPath(path);
|
|
32
|
-
const [first, ...rest] = _path;
|
|
33
|
-
if (first === void 0) {
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
const updateChild = (child) => {
|
|
37
|
-
if (!child && rest.length > 0) {
|
|
38
|
-
const _rootPath = castArrayPath(rootPath);
|
|
39
|
-
const prefix = _rootPath.slice(0, -rest.length);
|
|
40
|
-
throw new Error(`Cannot set ${rootPath} because ${prefix.join(".")} is ${child}`);
|
|
41
|
-
}
|
|
42
|
-
return set(child, rest, value, rootPath);
|
|
43
|
-
};
|
|
44
|
-
if (object instanceof Map) {
|
|
45
|
-
const copy = clone.flatClone(object);
|
|
46
|
-
const child = copy.get(first);
|
|
47
|
-
copy.set(first, updateChild(child));
|
|
48
|
-
return copy;
|
|
49
|
-
}
|
|
50
|
-
if (object instanceof Set) {
|
|
51
|
-
const copy = [...object];
|
|
52
|
-
const child = copy[Number(first)];
|
|
53
|
-
copy[Number(first)] = updateChild(child);
|
|
54
|
-
return new Set(copy);
|
|
55
|
-
}
|
|
56
|
-
if (object instanceof Object) {
|
|
57
|
-
const copy = clone.flatClone(object);
|
|
58
|
-
copy[first] = updateChild(copy[first]);
|
|
59
|
-
return copy;
|
|
60
|
-
}
|
|
61
|
-
throw new Error(`Could not set ${path} of ${object}`);
|
|
62
|
-
}
|
|
63
|
-
exports.castArrayPath = castArrayPath;
|
|
64
|
-
exports.get = get;
|
|
65
|
-
exports.set = set;
|
|
66
|
-
//# sourceMappingURL=propAccess.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"propAccess.cjs","sources":["../../../src/lib/propAccess.ts"],"sourcesContent":["import type { Update } from '../core/commonTypes';\nimport { flatClone } from './clone';\nimport type { Path, Value } from './path';\n\nexport function castArrayPath(path: string | KeyType[]): KeyType[] {\n if (Array.isArray(path)) {\n return path as any;\n }\n\n if (path === '') {\n return [] as any;\n }\n\n return (path as string).split('.') as any;\n}\n\nexport function get<T, P extends Path<T>>(object: T, path: P): Value<T, P> {\n const _path = castArrayPath(path as any);\n const [first, ...rest] = _path;\n\n if (first === undefined || !object) {\n return object as Value<T, P>;\n }\n\n if (object instanceof Map) {\n return get(object.get(first), rest as any);\n }\n\n if (object instanceof Set) {\n return get(Array.from(object)[Number(first)], rest as any);\n }\n\n if (object instanceof Object) {\n return get(object[first as keyof T], rest as any) as Value<T, P>;\n }\n\n throw new Error(`Could not get ${path} of ${object}`);\n}\n\nexport function set<T, P extends Path<T>>(\n object: T,\n path: P,\n value: Update<Value<T, P>>,\n rootPath = path,\n): T {\n const _path = castArrayPath(path as any);\n const [first, ...rest] = _path;\n\n if (first === undefined) {\n return value as any;\n }\n\n const updateChild = (child: any) => {\n if (!child && rest.length > 0) {\n const _rootPath = castArrayPath(rootPath as any);\n\n const prefix = _rootPath.slice(0, -rest.length) as KeyType[];\n throw new Error(`Cannot set ${rootPath} because ${prefix.join('.')} is ${child}`);\n }\n\n return set(child, rest as any, value, rootPath);\n };\n\n if (object instanceof Map) {\n const copy = flatClone(object);\n const child = copy.get(first);\n copy.set(first, updateChild(child));\n return copy;\n }\n\n if (object instanceof Set) {\n const copy = [...object];\n const child = copy[Number(first)];\n copy[Number(first)] = updateChild(child);\n return new Set(copy) as any;\n }\n\n if (object instanceof Object) {\n const copy = flatClone(object);\n copy[first as keyof T] = updateChild(copy[first as keyof T]);\n return copy;\n }\n\n throw new Error(`Could not set ${path} of ${object}`);\n}\n\nexport function remove<T, P extends Path<T, true>>(object: T, path: P): T {\n const _path = castArrayPath(path as any);\n\n if (_path.length === 0) {\n return undefined as any;\n }\n\n const parentPath = _path.slice(0, -1);\n const key = _path[_path.length - 1];\n\n const parent = flatClone(get(object, parentPath as any));\n\n if (parent instanceof Map) {\n parent.delete(key);\n } else if (parent instanceof Set) {\n const value = Array.from(parent)[Number(key)];\n parent.delete(value);\n } else {\n delete parent[key as keyof typeof parent];\n }\n\n return set(object, parentPath as any, parent);\n}\n"],"names":["flatClone"],"mappings":";;;AAIO,SAAS,cAAc,MAAqC;AAC7D,MAAA,MAAM,QAAQ,IAAI,GAAG;AAChB,WAAA;AAAA,EACT;AAEA,MAAI,SAAS,IAAI;AACf,WAAO;EACT;AAEQ,SAAA,KAAgB,MAAM,GAAG;AACnC;AAEgB,SAAA,IAA0B,QAAW,MAAsB;AACnE,QAAA,QAAQ,cAAc,IAAW;AACvC,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AAErB,MAAA,UAAU,UAAa,CAAC,QAAQ;AAC3B,WAAA;AAAA,EACT;AAEA,MAAI,kBAAkB,KAAK;AACzB,WAAO,IAAI,OAAO,IAAI,KAAK,GAAG,IAAW;AAAA,EAC3C;AAEA,MAAI,kBAAkB,KAAK;AAClB,WAAA,IAAI,MAAM,KAAK,MAAM,EAAE,OAAO,KAAK,CAAC,GAAG,IAAW;AAAA,EAC3D;AAEA,MAAI,kBAAkB,QAAQ;AAC5B,WAAO,IAAI,OAAO,KAAgB,GAAG,IAAW;AAAA,EAClD;AAEA,QAAM,IAAI,MAAM,iBAAiB,WAAW,QAAQ;AACtD;AAEO,SAAS,IACd,QACA,MACA,OACA,WAAW,MACR;AACG,QAAA,QAAQ,cAAc,IAAW;AACvC,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AAEzB,MAAI,UAAU,QAAW;AAChB,WAAA;AAAA,EACT;AAEM,QAAA,cAAc,CAAC,UAAe;AAClC,QAAI,CAAC,SAAS,KAAK,SAAS,GAAG;AACvB,YAAA,YAAY,cAAc,QAAe;AAE/C,YAAM,SAAS,UAAU,MAAM,GAAG,CAAC,KAAK,MAAM;AACxC,YAAA,IAAI,MAAM,cAAc,oBAAoB,OAAO,KAAK,GAAG,QAAQ,OAAO;AAAA,IAClF;AAEA,WAAO,IAAI,OAAO,MAAa,OAAO,QAAQ;AAAA,EAAA;AAGhD,MAAI,kBAAkB,KAAK;AACnB,UAAA,OAAOA,gBAAU,MAAM;AACvB,UAAA,QAAQ,KAAK,IAAI,KAAK;AAC5B,SAAK,IAAI,OAAO,YAAY,KAAK,CAAC;AAC3B,WAAA;AAAA,EACT;AAEA,MAAI,kBAAkB,KAAK;AACnB,UAAA,OAAO,CAAC,GAAG,MAAM;AACvB,UAAM,QAAQ,KAAK,OAAO,KAAK,CAAC;AAChC,SAAK,OAAO,KAAK,CAAC,IAAI,YAAY,KAAK;AAChC,WAAA,IAAI,IAAI,IAAI;AAAA,EACrB;AAEA,MAAI,kBAAkB,QAAQ;AACtB,UAAA,OAAOA,gBAAU,MAAM;AAC7B,SAAK,KAAgB,IAAI,YAAY,KAAK,KAAgB,CAAC;AACpD,WAAA;AAAA,EACT;AAEA,QAAM,IAAI,MAAM,iBAAiB,WAAW,QAAQ;AACtD;;;;"}
|
package/dist/cjs/lib/queue.cjs
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function queue() {
|
|
4
|
-
const q = [];
|
|
5
|
-
const completionListeners = /* @__PURE__ */ new Set();
|
|
6
|
-
let active = false;
|
|
7
|
-
const notify = () => {
|
|
8
|
-
for (const listener of completionListeners) {
|
|
9
|
-
listener();
|
|
10
|
-
}
|
|
11
|
-
completionListeners.clear();
|
|
12
|
-
};
|
|
13
|
-
const run = async () => {
|
|
14
|
-
if (!active) {
|
|
15
|
-
active = true;
|
|
16
|
-
let next;
|
|
17
|
-
while (next = q.shift()) {
|
|
18
|
-
try {
|
|
19
|
-
let result = next.action();
|
|
20
|
-
if (result instanceof Promise) {
|
|
21
|
-
result = await result;
|
|
22
|
-
}
|
|
23
|
-
next.resolve(result);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
next.reject(error);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
active = false;
|
|
29
|
-
notify();
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
return Object.assign(
|
|
33
|
-
(action, ref) => {
|
|
34
|
-
return new Promise((resolve, reject) => {
|
|
35
|
-
q.push({ action, resolve, reject, ref });
|
|
36
|
-
run();
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
clear() {
|
|
41
|
-
q.length = 0;
|
|
42
|
-
},
|
|
43
|
-
whenDone() {
|
|
44
|
-
if (!active) {
|
|
45
|
-
return Promise.resolve();
|
|
46
|
-
}
|
|
47
|
-
return new Promise((resolve) => {
|
|
48
|
-
completionListeners.add(resolve);
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
get size() {
|
|
52
|
-
return q.length;
|
|
53
|
-
},
|
|
54
|
-
getRefs() {
|
|
55
|
-
return q.map((item) => item.ref).filter((x) => x !== void 0);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
exports.queue = queue;
|
|
61
|
-
//# sourceMappingURL=queue.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queue.cjs","sources":["../../../src/lib/queue.ts"],"sourcesContent":["import type { MaybePromise } from './maybePromise';\nimport type { Listener } from '@core';\n\ntype Action<T> = () => MaybePromise<T>;\n\nexport interface Queue {\n <T>(action: Action<T>, ref?: any): Promise<T>;\n clear: () => void;\n whenDone: () => Promise<void>;\n size: number;\n getRefs: () => any[];\n}\n\nexport function queue(): Queue {\n const q: {\n action: Action<any>;\n resolve: (value: any) => void;\n reject: (error: unknown) => void;\n ref?: any;\n }[] = [];\n const completionListeners = new Set<Listener<void>>();\n let active = false;\n\n const notify = () => {\n for (const listener of completionListeners) {\n listener();\n }\n\n completionListeners.clear();\n };\n\n const run = async () => {\n if (!active) {\n active = true;\n\n let next;\n while ((next = q.shift())) {\n try {\n let result = next.action();\n if (result instanceof Promise) {\n result = await result;\n }\n\n next.resolve(result);\n } catch (error) {\n next.reject(error);\n }\n }\n\n active = false;\n notify();\n }\n };\n\n return Object.assign(\n <T>(action: Action<T>, ref?: any) => {\n return new Promise<T>((resolve, reject) => {\n q.push({ action, resolve, reject, ref });\n run();\n });\n },\n {\n clear() {\n q.length = 0;\n },\n\n whenDone() {\n if (!active) {\n return Promise.resolve();\n }\n\n return new Promise<void>((resolve) => {\n completionListeners.add(resolve);\n });\n },\n\n get size() {\n return q.length;\n },\n\n getRefs() {\n return q.map((item) => item.ref).filter((x) => x !== undefined);\n },\n },\n );\n}\n"],"names":[],"mappings":";;AAaO,SAAS,QAAe;AAC7B,QAAM,IAKA,CAAA;AACA,QAAA,0CAA0B;AAChC,MAAI,SAAS;AAEb,QAAM,SAAS,MAAM;AACnB,eAAW,YAAY,qBAAqB;AACjC;IACX;AAEA,wBAAoB,MAAM;AAAA,EAAA;AAG5B,QAAM,MAAM,YAAY;AACtB,QAAI,CAAC,QAAQ;AACF,eAAA;AAEL,UAAA;AACI,aAAA,OAAO,EAAE,SAAU;AACrB,YAAA;AACE,cAAA,SAAS,KAAK;AAClB,cAAI,kBAAkB,SAAS;AAC7B,qBAAS,MAAM;AAAA,UACjB;AAEA,eAAK,QAAQ,MAAM;AAAA,iBACZ;AACP,eAAK,OAAO,KAAK;AAAA,QACnB;AAAA,MACF;AAES,eAAA;AACF;IACT;AAAA,EAAA;AAGF,SAAO,OAAO;AAAA,IACZ,CAAI,QAAmB,QAAc;AACnC,aAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,UAAE,KAAK,EAAE,QAAQ,SAAS,QAAQ,KAAK;AACnC;MAAA,CACL;AAAA,IACH;AAAA,IACA;AAAA,MACE,QAAQ;AACN,UAAE,SAAS;AAAA,MACb;AAAA,MAEA,WAAW;AACT,YAAI,CAAC,QAAQ;AACX,iBAAO,QAAQ;QACjB;AAEO,eAAA,IAAI,QAAc,CAAC,YAAY;AACpC,8BAAoB,IAAI,OAAO;AAAA,QAAA,CAChC;AAAA,MACH;AAAA,MAEA,IAAI,OAAO;AACT,eAAO,EAAE;AAAA,MACX;AAAA,MAEA,UAAU;AACD,eAAA,EAAE,IAAI,CAAC,SAAS,KAAK,GAAG,EAAE,OAAO,CAAC,MAAM,MAAM,MAAS;AAAA,MAChE;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const createArrayAction = (prop) => function arrayAction(...args) {
|
|
4
|
-
const newArray = this.get().slice();
|
|
5
|
-
const result = newArray[prop](...args);
|
|
6
|
-
this.set(newArray);
|
|
7
|
-
return result;
|
|
8
|
-
};
|
|
9
|
-
const arrayMethods = {
|
|
10
|
-
splice: createArrayAction("splice"),
|
|
11
|
-
push: createArrayAction("push"),
|
|
12
|
-
pop: createArrayAction("pop"),
|
|
13
|
-
shift: createArrayAction("shift"),
|
|
14
|
-
unshift: createArrayAction("unshift"),
|
|
15
|
-
reverse: createArrayAction("reverse"),
|
|
16
|
-
sort: createArrayAction("sort")
|
|
17
|
-
};
|
|
18
|
-
const recordMethods = {
|
|
19
|
-
// set<T extends Record<any, any>, P extends Path<T>>(
|
|
20
|
-
// this: Store<T>,
|
|
21
|
-
// path: P,
|
|
22
|
-
// value: Update<Value<T, P>>,
|
|
23
|
-
// ) {
|
|
24
|
-
// if (value instanceof Function) {
|
|
25
|
-
// value = value(get(this.get(), path));
|
|
26
|
-
// }
|
|
27
|
-
// this.set(set(this.get(), path, value));
|
|
28
|
-
// return this;
|
|
29
|
-
// },
|
|
30
|
-
delete(key) {
|
|
31
|
-
const copy = { ...this.get() };
|
|
32
|
-
delete copy[key];
|
|
33
|
-
this.set(copy);
|
|
34
|
-
},
|
|
35
|
-
clear() {
|
|
36
|
-
this.set({});
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const mapMethods = {
|
|
40
|
-
// set<K, V>(this: Store<Map<K, V>>, key: K, value: UpdateFrom<V, [V | undefined]>) {
|
|
41
|
-
// if (value instanceof Function) {
|
|
42
|
-
// value = value(this.get().get(key));
|
|
43
|
-
// }
|
|
44
|
-
// const newMap = new Map(this.get());
|
|
45
|
-
// newMap.set(key, value);
|
|
46
|
-
// this.set(newMap);
|
|
47
|
-
// return this;
|
|
48
|
-
// },
|
|
49
|
-
delete(key) {
|
|
50
|
-
const newMap = new Map(this.get());
|
|
51
|
-
const result = newMap.delete(key);
|
|
52
|
-
this.set(newMap);
|
|
53
|
-
return result;
|
|
54
|
-
},
|
|
55
|
-
clear() {
|
|
56
|
-
this.set(/* @__PURE__ */ new Map());
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const setMethods = {
|
|
60
|
-
add(value) {
|
|
61
|
-
const newSet = new Set(this.get());
|
|
62
|
-
newSet.add(value);
|
|
63
|
-
this.set(newSet);
|
|
64
|
-
},
|
|
65
|
-
delete(value) {
|
|
66
|
-
const newSet = new Set(this.get());
|
|
67
|
-
newSet.delete(value);
|
|
68
|
-
this.set(newSet);
|
|
69
|
-
},
|
|
70
|
-
clear() {
|
|
71
|
-
this.set(/* @__PURE__ */ new Set());
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
exports.arrayMethods = arrayMethods;
|
|
75
|
-
exports.mapMethods = mapMethods;
|
|
76
|
-
exports.recordMethods = recordMethods;
|
|
77
|
-
exports.setMethods = setMethods;
|
|
78
|
-
//# sourceMappingURL=standardMethods.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standardMethods.cjs","sources":["../../../src/lib/standardMethods.ts"],"sourcesContent":["import type { Store } from '../core/store';\nimport type { OptionalPropertyOf } from './typeHelpers';\n\ntype Function_ = (...args: any) => any;\n\nconst createArrayAction = <P extends keyof Array<any>>(prop: P) =>\n function arrayAction<T extends Array<any>>(\n this: Store<T>,\n ...args: T[P] extends Function_ ? Parameters<T[P]> : never\n ): T[P] extends Function_ ? ReturnType<T[P]> : never {\n const newArray = this.get().slice() as T;\n const result = (newArray[prop] as Function_)(...(args as any));\n this.set(newArray);\n return result;\n };\n\nexport const arrayMethods = {\n splice: createArrayAction('splice'),\n push: createArrayAction('push'),\n pop: createArrayAction('pop'),\n shift: createArrayAction('shift'),\n unshift: createArrayAction('unshift'),\n reverse: createArrayAction('reverse'),\n sort: createArrayAction('sort'),\n};\n\nexport const recordMethods = {\n // set<T extends Record<any, any>, P extends Path<T>>(\n // this: Store<T>,\n // path: P,\n // value: Update<Value<T, P>>,\n // ) {\n // if (value instanceof Function) {\n // value = value(get(this.get(), path));\n // }\n\n // this.set(set(this.get(), path, value));\n // return this;\n // },\n\n delete<T extends Record<any, any>, K extends OptionalPropertyOf<T>>(this: Store<T>, key: K) {\n const copy = { ...this.get() };\n delete copy[key];\n this.set(copy);\n },\n\n clear<T extends Record<any, any>>(this: Store<Partial<T>>) {\n this.set({} as T);\n },\n};\n\nexport const mapMethods = {\n // set<K, V>(this: Store<Map<K, V>>, key: K, value: UpdateFrom<V, [V | undefined]>) {\n // if (value instanceof Function) {\n // value = value(this.get().get(key));\n // }\n\n // const newMap = new Map(this.get());\n // newMap.set(key, value);\n // this.set(newMap);\n // return this;\n // },\n\n delete<K, V>(this: Store<Map<K, V>>, key: K) {\n const newMap = new Map(this.get());\n const result = newMap.delete(key);\n this.set(newMap);\n return result;\n },\n\n clear<K, V>(this: Store<Map<K, V>>) {\n this.set(new Map());\n },\n};\n\nexport const setMethods = {\n add<T>(this: Store<Set<T>>, value: T) {\n const newSet = new Set(this.get());\n newSet.add(value);\n this.set(newSet);\n },\n\n delete<T>(this: Store<Set<T>>, value: T) {\n const newSet = new Set(this.get());\n newSet.delete(value);\n this.set(newSet);\n },\n\n clear<T>(this: Store<Set<T>>) {\n this.set(new Set());\n },\n};\n"],"names":[],"mappings":";;AAKA,MAAM,oBAAoB,CAA6B,SACrD,SAAS,eAEJ,MACgD;AACnD,QAAM,WAAW,KAAK,IAAI,EAAE,MAAM;AAClC,QAAM,SAAU,SAAS,IAAI,EAAgB,GAAI,IAAY;AAC7D,OAAK,IAAI,QAAQ;AACV,SAAA;AACT;AAEK,MAAM,eAAe;AAAA,EAC1B,QAAQ,kBAAkB,QAAQ;AAAA,EAClC,MAAM,kBAAkB,MAAM;AAAA,EAC9B,KAAK,kBAAkB,KAAK;AAAA,EAC5B,OAAO,kBAAkB,OAAO;AAAA,EAChC,SAAS,kBAAkB,SAAS;AAAA,EACpC,SAAS,kBAAkB,SAAS;AAAA,EACpC,MAAM,kBAAkB,MAAM;AAChC;AAEO,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc3B,OAAoF,KAAQ;AAC1F,UAAM,OAAO,EAAE,GAAG,KAAK,IAAM,EAAA;AAC7B,WAAO,KAAK,GAAG;AACf,SAAK,IAAI,IAAI;AAAA,EACf;AAAA,EAEA,QAA2D;AACpD,SAAA,IAAI,CAAA,CAAO;AAAA,EAClB;AACF;AAEO,MAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYxB,OAAqC,KAAQ;AAC3C,UAAM,SAAS,IAAI,IAAI,KAAK,IAAK,CAAA;AAC3B,UAAA,SAAS,OAAO,OAAO,GAAG;AAChC,SAAK,IAAI,MAAM;AACR,WAAA;AAAA,EACT;AAAA,EAEA,QAAoC;AAC7B,SAAA,IAAQ,oBAAA,IAAA,CAAK;AAAA,EACpB;AACF;AAEO,MAAM,aAAa;AAAA,EACxB,IAA4B,OAAU;AACpC,UAAM,SAAS,IAAI,IAAI,KAAK,IAAK,CAAA;AACjC,WAAO,IAAI,KAAK;AAChB,SAAK,IAAI,MAAM;AAAA,EACjB;AAAA,EAEA,OAA+B,OAAU;AACvC,UAAM,SAAS,IAAI,IAAI,KAAK,IAAK,CAAA;AACjC,WAAO,OAAO,KAAK;AACnB,SAAK,IAAI,MAAM;AAAA,EACjB;AAAA,EAEA,QAA8B;AACvB,SAAA,IAAQ,oBAAA,IAAA,CAAK;AAAA,EACpB;AACF;;;;;"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const calcDuration = require("./calcDuration.cjs");
|
|
4
|
-
function throttle(action, duration) {
|
|
5
|
-
const ms = calcDuration.calcDuration(duration);
|
|
6
|
-
let t = 0;
|
|
7
|
-
let timeout;
|
|
8
|
-
return (...args) => {
|
|
9
|
-
if (timeout !== void 0) {
|
|
10
|
-
clearTimeout(timeout);
|
|
11
|
-
}
|
|
12
|
-
const dt = t + ms - Date.now();
|
|
13
|
-
if (dt <= 0) {
|
|
14
|
-
action(...args);
|
|
15
|
-
t = Date.now();
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
timeout = setTimeout(() => {
|
|
19
|
-
action(...args);
|
|
20
|
-
t = Date.now();
|
|
21
|
-
}, dt);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.throttle = throttle;
|
|
25
|
-
//# sourceMappingURL=throttle.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.cjs","sources":["../../../src/lib/throttle.ts"],"sourcesContent":["import { calcDuration } from './calcDuration';\nimport type { Duration } from '@core';\n\nexport function throttle<Args extends any[]>(\n action: (...args: Args) => void,\n duration: Duration,\n): (...args: Args) => void {\n const ms = calcDuration(duration);\n\n let t = 0;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n\n return (...args: Args) => {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n const dt = t + ms - Date.now();\n if (dt <= 0) {\n action(...args);\n t = Date.now();\n return;\n }\n\n timeout = setTimeout(() => {\n action(...args);\n t = Date.now();\n }, dt);\n };\n}\n"],"names":["calcDuration"],"mappings":";;;AAGgB,SAAA,SACd,QACA,UACyB;AACnB,QAAA,KAAKA,0BAAa,QAAQ;AAEhC,MAAI,IAAI;AACJ,MAAA;AAEJ,SAAO,IAAI,SAAe;AACxB,QAAI,YAAY,QAAW;AACzB,mBAAa,OAAO;AAAA,IACtB;AAEA,UAAM,KAAK,IAAI,KAAK,KAAK,IAAI;AAC7B,QAAI,MAAM,GAAG;AACX,aAAO,GAAG,IAAI;AACd,UAAI,KAAK;AACT;AAAA,IACF;AAEA,cAAU,WAAW,MAAM;AACzB,aAAO,GAAG,IAAI;AACd,UAAI,KAAK;OACR,EAAE;AAAA,EAAA;AAET;;"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const ProxyKeys = [
|
|
4
|
-
"get",
|
|
5
|
-
"getOwnPropertyDescriptor",
|
|
6
|
-
"getPrototypeOf",
|
|
7
|
-
"has",
|
|
8
|
-
"isExtensible",
|
|
9
|
-
"ownKeys"
|
|
10
|
-
];
|
|
11
|
-
const isPlainObject = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value) === Object.prototype;
|
|
12
|
-
function trackingProxy(value) {
|
|
13
|
-
if (!isPlainObject(value) && !Array.isArray(value)) {
|
|
14
|
-
return [value, (other) => other === value];
|
|
15
|
-
}
|
|
16
|
-
const deps = new Array();
|
|
17
|
-
const proxy = new Proxy(
|
|
18
|
-
value,
|
|
19
|
-
Object.fromEntries(
|
|
20
|
-
ProxyKeys.map((key) => [
|
|
21
|
-
key,
|
|
22
|
-
(currentValue, ...args) => {
|
|
23
|
-
const function_ = Reflect[key];
|
|
24
|
-
const [proxiedValue, equals] = trackingProxy(function_(currentValue, ...args));
|
|
25
|
-
deps.push((otherValue) => {
|
|
26
|
-
if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
return equals(function_(otherValue, ...args));
|
|
30
|
-
});
|
|
31
|
-
return proxiedValue;
|
|
32
|
-
}
|
|
33
|
-
])
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
|
-
return [proxy, (other) => !!other && deps.every((equals) => equals(other))];
|
|
37
|
-
}
|
|
38
|
-
exports.trackingProxy = trackingProxy;
|
|
39
|
-
//# sourceMappingURL=trackingProxy.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trackingProxy.cjs","sources":["../../../src/lib/trackingProxy.ts"],"sourcesContent":["export type TrackingProxy<T> = [value: T, equals: (newValue: T) => boolean];\ntype Object_ = Record<string | symbol, unknown>;\n\nconst ProxyKeys = [\n 'get',\n 'getOwnPropertyDescriptor',\n 'getPrototypeOf',\n 'has',\n 'isExtensible',\n 'ownKeys',\n] as const;\n\nconst isPlainObject = (value: unknown) =>\n typeof value === 'object' && value !== null && Object.getPrototypeOf(value) === Object.prototype;\n\nexport function trackingProxy<T>(value: T): TrackingProxy<T> {\n if (!isPlainObject(value) && !Array.isArray(value)) {\n return [value, (other) => other === value];\n }\n\n const deps = new Array<TrackingProxy<any>[1]>();\n\n const proxy = new Proxy(\n value as T & Object_,\n Object.fromEntries(\n ProxyKeys.map((key) => [\n key,\n (currentValue: T & Object_, ...args: any[]) => {\n const function_ = Reflect[key] as any;\n const [proxiedValue, equals] = trackingProxy(function_(currentValue, ...args));\n\n deps.push((otherValue) => {\n if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {\n return false;\n }\n\n return equals(function_(otherValue, ...args));\n });\n\n return proxiedValue;\n },\n ]),\n ),\n );\n\n return [proxy, (other) => !!other && deps.every((equals) => equals(other))];\n}\n"],"names":[],"mappings":";;AAGA,MAAM,YAAY;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,gBAAgB,CAAC,UACrB,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,eAAe,KAAK,MAAM,OAAO;AAElF,SAAS,cAAiB,OAA4B;AACvD,MAAA,CAAC,cAAc,KAAK,KAAK,CAAC,MAAM,QAAQ,KAAK,GAAG;AAClD,WAAO,CAAC,OAAO,CAAC,UAAU,UAAU,KAAK;AAAA,EAC3C;AAEM,QAAA,OAAO,IAAI;AAEjB,QAAM,QAAQ,IAAI;AAAA,IAChB;AAAA,IACA,OAAO;AAAA,MACL,UAAU,IAAI,CAAC,QAAQ;AAAA,QACrB;AAAA,QACA,CAAC,iBAA8B,SAAgB;AACvC,gBAAA,YAAY,QAAQ,GAAG;AACvB,gBAAA,CAAC,cAAc,MAAM,IAAI,cAAc,UAAU,cAAc,GAAG,IAAI,CAAC;AAExE,eAAA,KAAK,CAAC,eAAe;AACpB,gBAAA,CAAC,cAAc,UAAU,KAAK,CAAC,MAAM,QAAQ,UAAU,GAAG;AACrD,qBAAA;AAAA,YACT;AAEA,mBAAO,OAAO,UAAU,YAAY,GAAG,IAAI,CAAC;AAAA,UAAA,CAC7C;AAEM,iBAAA;AAAA,QACT;AAAA,MAAA,CACD;AAAA,IACH;AAAA,EAAA;AAGF,SAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,SAAS,KAAK,MAAM,CAAC,WAAW,OAAO,KAAK,CAAC,CAAC;AAC5E;;"}
|
package/dist/cjs/react/read.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const useCache = require("./useCache.cjs");
|
|
4
|
-
function read(cache, options) {
|
|
5
|
-
const { status, value, error } = useCache.useCache(cache, options);
|
|
6
|
-
if (status === "value") {
|
|
7
|
-
return value;
|
|
8
|
-
}
|
|
9
|
-
if (status === "error") {
|
|
10
|
-
throw error;
|
|
11
|
-
}
|
|
12
|
-
throw cache.state.once((state) => state.status !== "pending");
|
|
13
|
-
}
|
|
14
|
-
exports.read = read;
|
|
15
|
-
//# sourceMappingURL=read.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read.cjs","sources":["../../../src/react/read.ts"],"sourcesContent":["import { useCache } from './useCache';\nimport type { UseStoreOptions } from './useStore';\nimport type { Cache } from '@core';\n\nexport function read<T>(cache: Cache<T>, options?: UseStoreOptions): T {\n const { status, value, error } = useCache(cache, options);\n\n if (status === 'value') {\n return value;\n }\n\n if (status === 'error') {\n throw error;\n }\n\n throw cache.state.once((state) => state.status !== 'pending');\n}\n"],"names":["useCache"],"mappings":";;;AAIgB,SAAA,KAAQ,OAAiB,SAA8B;AACrE,QAAM,EAAE,QAAQ,OAAO,MAAU,IAAAA,kBAAS,OAAO,OAAO;AAExD,MAAI,WAAW,SAAS;AACf,WAAA;AAAA,EACT;AAEA,MAAI,WAAW,SAAS;AAChB,UAAA;AAAA,EACR;AAEA,QAAM,MAAM,MAAM,KAAK,CAAC,UAAU,MAAM,WAAW,SAAS;AAC9D;;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const require$$0 = require("react");
|
|
5
|
-
const store = require("../core/store.cjs");
|
|
6
|
-
const contextMap = /* @__PURE__ */ new WeakMap();
|
|
7
|
-
function getStoreScopeContext(scope) {
|
|
8
|
-
let context = contextMap.get(scope);
|
|
9
|
-
if (!context) {
|
|
10
|
-
context = require$$0.createContext(store.createStore(scope.defaultValue));
|
|
11
|
-
contextMap.set(scope, context);
|
|
12
|
-
}
|
|
13
|
-
return context;
|
|
14
|
-
}
|
|
15
|
-
function StoreScopeProvider({ scope, store: inputStore, children }) {
|
|
16
|
-
const context = getStoreScopeContext(scope);
|
|
17
|
-
const currentStore = require$$0.useMemo(
|
|
18
|
-
() => inputStore ?? store.createStore(scope.defaultValue),
|
|
19
|
-
[scope, inputStore]
|
|
20
|
-
);
|
|
21
|
-
return /* @__PURE__ */ jsxRuntime.jsx(context.Provider, { value: currentStore, children });
|
|
22
|
-
}
|
|
23
|
-
function useStoreScope(scope) {
|
|
24
|
-
const context = getStoreScopeContext(scope);
|
|
25
|
-
return require$$0.useContext(context);
|
|
26
|
-
}
|
|
27
|
-
exports.StoreScopeProvider = StoreScopeProvider;
|
|
28
|
-
exports.contextMap = contextMap;
|
|
29
|
-
exports.getStoreScopeContext = getStoreScopeContext;
|
|
30
|
-
exports.useStoreScope = useStoreScope;
|
|
31
|
-
//# sourceMappingURL=storeScope.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storeScope.cjs","sources":["../../../src/react/storeScope.tsx"],"sourcesContent":["import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport type { Store } from '@core/store';\nimport { createStore } from '@core/store';\nimport type { StoreScope } from '@core/storeScope';\n\nexport type StoreScopeProps<T> = { scope: StoreScope<T>; store?: Store<T>; children?: ReactNode };\n\nexport const contextMap = new WeakMap<StoreScope<any>, Context<Store<any>>>();\n\nexport function getStoreScopeContext<T>(scope: StoreScope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function StoreScopeProvider<T>({ scope, store: inputStore, children }: StoreScopeProps<T>) {\n const context = getStoreScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useStoreScope<T>(scope: StoreScope<T>): Store<T> {\n const context = getStoreScopeContext(scope);\n return useContext(context);\n}\n"],"names":["createContext","createStore","useMemo","useContext"],"mappings":";;;;;AAQa,MAAA,iCAAiB,QAA8C;AAErE,SAAS,qBAAwB,OAAyC;AAC3E,MAAA,UAAU,WAAW,IAAI,KAAK;AAElC,MAAI,CAAC,SAAS;AACZ,cAAUA,WAAAA,cAAwBC,MAAAA,YAAY,MAAM,YAAY,CAAC;AACtD,eAAA,IAAI,OAAO,OAAO;AAAA,EAC/B;AAEO,SAAA;AACT;AAEO,SAAS,mBAAsB,EAAE,OAAO,OAAO,YAAY,YAAgC;AAC1F,QAAA,UAAU,qBAAqB,KAAK;AAC1C,QAAM,eAAeC,WAAA;AAAA,IACnB,MAAM,cAAcD,MAAAA,YAAY,MAAM,YAAY;AAAA,IAClD,CAAC,OAAO,UAAU;AAAA,EAAA;AAGpB,wCAAQ,QAAQ,UAAR,EAAiB,OAAO,cAAe,SAAS,CAAA;AAC1D;AAEO,SAAS,cAAiB,OAAgC;AACzD,QAAA,UAAU,qBAAqB,KAAK;AAC1C,SAAOE,WAAAA,WAAW,OAAO;AAC3B;;;;;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const require$$0 = require("react");
|
|
4
|
-
const useStore = require("./useStore.cjs");
|
|
5
|
-
const makeSelector = require("../lib/makeSelector.cjs");
|
|
6
|
-
function useCache(cache, { passive, ...options } = {}) {
|
|
7
|
-
const mappedState = require$$0.useMemo(() => {
|
|
8
|
-
var _a;
|
|
9
|
-
const rootCache = ((_a = cache.derivedFromCache) == null ? void 0 : _a.cache) ?? cache;
|
|
10
|
-
let selector = (x) => x;
|
|
11
|
-
if (cache.derivedFromCache) {
|
|
12
|
-
selector = (value) => {
|
|
13
|
-
for (const s of cache.derivedFromCache.selectors) {
|
|
14
|
-
value = makeSelector.makeSelector(s)(value);
|
|
15
|
-
}
|
|
16
|
-
return value;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
return rootCache.state.map((state) => {
|
|
20
|
-
const value = state.status === "value" ? selector(state.value) : void 0;
|
|
21
|
-
return Object.assign(
|
|
22
|
-
[value, state.error, state.isUpdating, state.isStale],
|
|
23
|
-
{ ...state, value }
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
}, [cache]);
|
|
27
|
-
require$$0.useEffect(() => !passive ? cache.sub(() => void 0) : void 0, [cache, passive]);
|
|
28
|
-
return useStore.useStore(mappedState, options);
|
|
29
|
-
}
|
|
30
|
-
exports.useCache = useCache;
|
|
31
|
-
//# sourceMappingURL=useCache.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCache.cjs","sources":["../../../src/react/useCache.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedState = useMemo(() => {\n const rootCache: Cache<any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return rootCache.state.map((state) => {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, state.isStale],\n { ...state, value },\n );\n });\n }, [cache]);\n\n useEffect(() => (!passive ? cache.sub(() => undefined) : undefined), [cache, passive]);\n\n return useStore(mappedState, options);\n}\n"],"names":["useMemo","makeSelector","useEffect","useStore"],"mappings":";;;;;AAoBgB,SAAA,SACd,OACA,EAAE,SAAS,GAAG,QAAQ,IAAqB,CAAA,GACzB;AACZ,QAAA,cAAcA,WAAAA,QAAQ,MAAM;;AAC1B,UAAA,cAAwB,WAAM,qBAAN,mBAAwB,UAAS;AAC3D,QAAA,WAAW,CAAC,MAAW;AAE3B,QAAI,MAAM,kBAAkB;AAC1B,iBAAW,CAAC,UAAe;AACd,mBAAA,KAAK,MAAM,iBAAkB,WAAW;AACzC,kBAAAC,aAAA,aAAa,CAAC,EAAE,KAAK;AAAA,QAC/B;AACO,eAAA;AAAA,MAAA;AAAA,IAEX;AAEA,WAAO,UAAU,MAAM,IAAI,CAAC,UAAU;AACpC,YAAM,QAAQ,MAAM,WAAW,UAAU,SAAS,MAAM,KAAK,IAAI;AAEjE,aAAO,OAAO;AAAA,QACZ,CAAC,OAAO,MAAM,OAAO,MAAM,YAAY,MAAM,OAAO;AAAA,QACpD,EAAE,GAAG,OAAO,MAAM;AAAA,MAAA;AAAA,IACpB,CACD;AAAA,EAAA,GACA,CAAC,KAAK,CAAC;AAEVC,aAAAA,UAAU,MAAO,CAAC,UAAU,MAAM,IAAI,MAAM,MAAS,IAAI,QAAY,CAAC,OAAO,OAAO,CAAC;AAE9E,SAAAC,SAAA,SAAS,aAAa,OAAO;AACtC;;"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const useStore = require("./useStore.cjs");
|
|
4
|
-
function useProp(store, options) {
|
|
5
|
-
const value = useStore.useStore(store, options);
|
|
6
|
-
return [value, store.set];
|
|
7
|
-
}
|
|
8
|
-
exports.useProp = useProp;
|
|
9
|
-
//# sourceMappingURL=useProp.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useProp.cjs","sources":["../../../src/react/useProp.ts"],"sourcesContent":["import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\nimport type { UpdateFunction } from '@core/commonTypes';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: UpdateFunction<T>] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n"],"names":["useStore"],"mappings":";;;AAKgB,SAAA,QACd,OACA,SACyC;AACnC,QAAA,QAAQA,SAAAA,SAAS,OAAO,OAAO;AAE9B,SAAA,CAAC,OAAO,MAAM,GAAG;AAC1B;;"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const require$$0 = require("react");
|
|
4
|
-
require("../_virtual/with-selector.cjs");
|
|
5
|
-
const hash = require("../lib/hash.cjs");
|
|
6
|
-
const makeSelector = require("../lib/makeSelector.cjs");
|
|
7
|
-
const trackingProxy = require("../lib/trackingProxy.cjs");
|
|
8
|
-
const withSelector = require("../_virtual/with-selector2.cjs");
|
|
9
|
-
function useStore(store, options) {
|
|
10
|
-
const lastEqualsRef = require$$0.useRef();
|
|
11
|
-
const { rootStore, selector } = require$$0.useMemo(() => {
|
|
12
|
-
var _a;
|
|
13
|
-
const rootStore2 = ((_a = store.derivedFrom) == null ? void 0 : _a.store) ?? store;
|
|
14
|
-
let selector2 = (x) => x;
|
|
15
|
-
if (store.derivedFrom) {
|
|
16
|
-
selector2 = (value2) => {
|
|
17
|
-
for (const s of store.derivedFrom.selectors) {
|
|
18
|
-
value2 = makeSelector.makeSelector(s)(value2);
|
|
19
|
-
}
|
|
20
|
-
return value2;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return { rootStore: rootStore2, selector: selector2 };
|
|
24
|
-
}, [store]);
|
|
25
|
-
const subOptions = { ...options, runNow: false, equals: void 0, passive: false };
|
|
26
|
-
const subscribe = require$$0.useCallback(
|
|
27
|
-
(listener) => {
|
|
28
|
-
return rootStore.sub(listener, subOptions);
|
|
29
|
-
},
|
|
30
|
-
[rootStore, hash.hash(subOptions)]
|
|
31
|
-
);
|
|
32
|
-
const value = withSelector.exports.useSyncExternalStoreWithSelector(
|
|
33
|
-
//
|
|
34
|
-
subscribe,
|
|
35
|
-
rootStore.get,
|
|
36
|
-
void 0,
|
|
37
|
-
selector,
|
|
38
|
-
(options == null ? void 0 : options.equals) ?? ((_v, newValue) => {
|
|
39
|
-
var _a;
|
|
40
|
-
return ((_a = lastEqualsRef.current) == null ? void 0 : _a.call(lastEqualsRef, newValue)) ?? false;
|
|
41
|
-
})
|
|
42
|
-
);
|
|
43
|
-
const [proxiedValue, equals] = trackingProxy.trackingProxy(value);
|
|
44
|
-
require$$0.useLayoutEffect(() => {
|
|
45
|
-
lastEqualsRef.current = equals;
|
|
46
|
-
});
|
|
47
|
-
require$$0.useDebugValue(value);
|
|
48
|
-
return proxiedValue;
|
|
49
|
-
}
|
|
50
|
-
exports.useStore = useStore;
|
|
51
|
-
//# sourceMappingURL=useStore.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useStore.cjs","sources":["../../../src/react/useStore.ts"],"sourcesContent":["import { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const { rootStore, selector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let selector = (x: any) => x;\n\n if (store.derivedFrom) {\n selector = (value: any) => {\n for (const s of store.derivedFrom!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootStore, selector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.sub(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<unknown, T>(\n //\n subscribe,\n rootStore.get,\n undefined,\n selector,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n"],"names":["useRef","useMemo","rootStore","selector","value","makeSelector","useCallback","hash","useSyncExternalStoreWithSelector","trackingProxy","useLayoutEffect","useDebugValue"],"mappings":";;;;;;;;AAUgB,SAAA,SAAY,OAAiB,SAA8B;AACzE,QAAM,gBAAgBA,WAAAA;AAEtB,QAAM,EAAE,WAAW,SAAS,IAAIC,mBAAQ,MAAM;;AACtCC,UAAAA,eAAY,WAAM,gBAAN,mBAAmB,UAAS;AAC1CC,QAAAA,YAAW,CAAC,MAAW;AAE3B,QAAI,MAAM,aAAa;AACrBA,kBAAW,CAACC,WAAe;AACd,mBAAA,KAAK,MAAM,YAAa,WAAW;AAC5CA,mBAAQC,aAAA,aAAa,CAAC,EAAED,MAAK;AAAA,QAC/B;AACOA,eAAAA;AAAAA,MAAA;AAAA,IAEX;AAEA,WAAO,EAAE,WAAAF,YAAW,UAAAC,UAAS;AAAA,EAAA,GAC5B,CAAC,KAAK,CAAC;AAEJ,QAAA,aAAa,EAAE,GAAG,SAAS,QAAQ,OAAO,QAAQ,QAAW,SAAS;AAC5E,QAAM,YAAYG,WAAA;AAAA,IAChB,CAAC,aAAyB;AACjB,aAAA,UAAU,IAAI,UAAU,UAAU;AAAA,IAC3C;AAAA,IACA,CAAC,WAAWC,UAAK,UAAU,CAAC;AAAA,EAAA;AAG9B,QAAM,QAAQC,aAAA,QAAA;AAAA;AAAA,IAEZ;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,KACA,mCAAS,YAAW,CAAC,IAAI,aAAa;;AAAA,kCAAc,YAAd,uCAAwB,cAAa;AAAA;AAAA,EAAA;AAE7E,QAAM,CAAC,cAAc,MAAM,IAAIC,4BAAc,KAAK;AAElDC,aAAAA,gBAAgB,MAAM;AACpB,kBAAc,UAAU;AAAA,EAAA,CACzB;AAEDC,aAAA,cAAc,KAAK;AACZ,SAAA;AACT;;"}
|