@hanzogui/use-store 8.3.1 → 8.3.2
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/comparators.js +21 -0
- package/dist/cjs/comparators.js.map +1 -0
- package/dist/cjs/configureUseStore.js +9 -0
- package/dist/cjs/configureUseStore.js.map +1 -0
- package/dist/cjs/constants.js +9 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/decorators.js +10 -0
- package/dist/cjs/decorators.js.map +1 -0
- package/dist/cjs/helpers.js +50 -0
- package/dist/cjs/helpers.js.map +1 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces.js +3 -0
- package/dist/cjs/interfaces.js.map +1 -0
- package/dist/cjs/observe.js +141 -0
- package/dist/cjs/observe.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/useStore.js +574 -0
- package/dist/cjs/useStore.js.map +1 -0
- package/dist/cjs/useStoreDebug.js +41 -0
- package/dist/cjs/useStoreDebug.js.map +1 -0
- package/dist/esm/comparators.js +17 -0
- package/dist/esm/comparators.js.map +1 -0
- package/dist/esm/configureUseStore.js +5 -0
- package/dist/esm/configureUseStore.js.map +1 -0
- package/dist/esm/constants.js +6 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/decorators.js +7 -0
- package/dist/esm/decorators.js.map +1 -0
- package/dist/esm/helpers.js +42 -0
- package/dist/esm/helpers.js.map +1 -0
- package/dist/esm/index.js +13 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces.js +2 -0
- package/dist/esm/interfaces.js.map +1 -0
- package/dist/esm/observe.js +136 -0
- package/dist/esm/observe.js.map +1 -0
- package/dist/esm/useStore.js +556 -0
- package/dist/esm/useStore.js.map +1 -0
- package/dist/esm/useStoreDebug.js +34 -0
- package/dist/esm/useStoreDebug.js.map +1 -0
- package/package.json +23 -18
- package/src/configureUseStore.tsx +1 -1
- package/src/helpers.tsx +1 -1
- package/src/index.ts +7 -7
- package/src/interfaces.tsx +1 -1
- package/src/observe.tsx +4 -4
- package/src/useStore.tsx +6 -6
- package/src/useStoreDebug.tsx +1 -1
- package/types/comparators.d.ts +6 -0
- package/types/comparators.d.ts.map +1 -0
- package/types/configureUseStore.d.ts +4 -0
- package/types/configureUseStore.d.ts.map +1 -0
- package/types/constants.d.ts +6 -0
- package/types/constants.d.ts.map +1 -0
- package/types/decorators.d.ts +3 -0
- package/types/decorators.d.ts.map +1 -0
- package/types/helpers.d.ts +11 -0
- package/types/helpers.d.ts.map +1 -0
- package/types/index.d.ts +12 -0
- package/types/index.d.ts.map +1 -0
- package/types/interfaces.d.ts +43 -0
- package/types/interfaces.d.ts.map +1 -0
- package/types/observe.d.ts +6 -0
- package/types/observe.d.ts.map +1 -0
- package/types/useStore.d.ts +26 -0
- package/types/useStore.d.ts.map +1 -0
- package/types/useStoreDebug.d.ts +7 -0
- package/types/useStoreDebug.d.ts.map +1 -0
- package/dist/cjs/comparators.cjs +0 -41
- package/dist/cjs/comparators.native.js +0 -50
- package/dist/cjs/comparators.native.js.map +0 -1
- package/dist/cjs/configureUseStore.cjs +0 -32
- package/dist/cjs/configureUseStore.native.js +0 -35
- package/dist/cjs/configureUseStore.native.js.map +0 -1
- package/dist/cjs/constants.cjs +0 -33
- package/dist/cjs/constants.native.js +0 -36
- package/dist/cjs/constants.native.js.map +0 -1
- package/dist/cjs/decorators.cjs +0 -33
- package/dist/cjs/decorators.native.js +0 -36
- package/dist/cjs/decorators.native.js.map +0 -1
- package/dist/cjs/helpers.cjs +0 -62
- package/dist/cjs/helpers.native.js +0 -71
- package/dist/cjs/helpers.native.js.map +0 -1
- package/dist/cjs/index.cjs +0 -43
- package/dist/cjs/index.native.js +0 -65
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/cjs/interfaces.cjs +0 -18
- package/dist/cjs/interfaces.native.js +0 -21
- package/dist/cjs/interfaces.native.js.map +0 -1
- package/dist/cjs/observe.cjs +0 -166
- package/dist/cjs/observe.native.js +0 -234
- package/dist/cjs/observe.native.js.map +0 -1
- package/dist/cjs/useStore.cjs +0 -467
- package/dist/cjs/useStore.native.js +0 -608
- package/dist/cjs/useStore.native.js.map +0 -1
- package/dist/cjs/useStoreDebug.cjs +0 -67
- package/dist/cjs/useStoreDebug.native.js +0 -71
- package/dist/cjs/useStoreDebug.native.js.map +0 -1
- package/dist/esm/comparators.mjs +0 -16
- package/dist/esm/comparators.mjs.map +0 -1
- package/dist/esm/comparators.native.js +0 -22
- package/dist/esm/comparators.native.js.map +0 -1
- package/dist/esm/configureUseStore.mjs +0 -6
- package/dist/esm/configureUseStore.mjs.map +0 -1
- package/dist/esm/configureUseStore.native.js +0 -6
- package/dist/esm/configureUseStore.native.js.map +0 -1
- package/dist/esm/constants.mjs +0 -7
- package/dist/esm/constants.mjs.map +0 -1
- package/dist/esm/constants.native.js +0 -7
- package/dist/esm/constants.native.js.map +0 -1
- package/dist/esm/decorators.mjs +0 -8
- package/dist/esm/decorators.mjs.map +0 -1
- package/dist/esm/decorators.native.js +0 -8
- package/dist/esm/decorators.native.js.map +0 -1
- package/dist/esm/helpers.mjs +0 -31
- package/dist/esm/helpers.mjs.map +0 -1
- package/dist/esm/helpers.native.js +0 -37
- package/dist/esm/helpers.native.js.map +0 -1
- package/dist/esm/index.mjs +0 -15
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js +0 -34
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/interfaces.mjs +0 -2
- package/dist/esm/interfaces.mjs.map +0 -1
- package/dist/esm/interfaces.native.js +0 -2
- package/dist/esm/interfaces.native.js.map +0 -1
- package/dist/esm/observe.mjs +0 -129
- package/dist/esm/observe.mjs.map +0 -1
- package/dist/esm/observe.native.js +0 -194
- package/dist/esm/observe.native.js.map +0 -1
- package/dist/esm/useStore.mjs +0 -415
- package/dist/esm/useStore.mjs.map +0 -1
- package/dist/esm/useStore.native.js +0 -553
- package/dist/esm/useStore.native.js.map +0 -1
- package/dist/esm/useStoreDebug.mjs +0 -27
- package/dist/esm/useStoreDebug.mjs.map +0 -1
- package/dist/esm/useStoreDebug.native.js +0 -28
- package/dist/esm/useStoreDebug.native.js.map +0 -1
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
34
|
-
var useStoreDebug_exports = {};
|
|
35
|
-
__export(useStoreDebug_exports, {
|
|
36
|
-
DebugComponents: () => DebugComponents,
|
|
37
|
-
DebugStores: () => DebugStores,
|
|
38
|
-
shouldDebug: () => shouldDebug,
|
|
39
|
-
useCurrentComponent: () => useCurrentComponent,
|
|
40
|
-
useDebugStoreComponent: () => useDebugStoreComponent
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(useStoreDebug_exports);
|
|
43
|
-
var import_react = __toESM(require("react"), 1);
|
|
44
|
-
const useCurrentComponent = () => {
|
|
45
|
-
return {};
|
|
46
|
-
};
|
|
47
|
-
function useDebugStoreComponent(StoreCons) {
|
|
48
|
-
const cmp = useCurrentComponent();
|
|
49
|
-
DebugStores.add(StoreCons);
|
|
50
|
-
if (!DebugComponents.has(cmp)) {
|
|
51
|
-
DebugComponents.set(cmp, /* @__PURE__ */new Set());
|
|
52
|
-
}
|
|
53
|
-
const stores = DebugComponents.get(cmp);
|
|
54
|
-
stores.add(StoreCons);
|
|
55
|
-
import_react.default.useLayoutEffect(() => {
|
|
56
|
-
return () => {
|
|
57
|
-
DebugStores.delete(StoreCons);
|
|
58
|
-
stores.delete(StoreCons);
|
|
59
|
-
};
|
|
60
|
-
}, []);
|
|
61
|
-
}
|
|
62
|
-
const shouldDebug = (component, info) => {
|
|
63
|
-
const StoreCons = info.storeInstance?.constructor;
|
|
64
|
-
return DebugComponents.get(component)?.has(StoreCons);
|
|
65
|
-
};
|
|
66
|
-
const DebugComponents = /* @__PURE__ */new Map();
|
|
67
|
-
const DebugStores = /* @__PURE__ */new Set();
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all) __defProp(target, name, {
|
|
11
|
-
get: all[name],
|
|
12
|
-
enumerable: true
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
-
get: () => from[key],
|
|
19
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
-
value: mod,
|
|
31
|
-
enumerable: true
|
|
32
|
-
}) : target, mod));
|
|
33
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
-
value: true
|
|
35
|
-
}), mod);
|
|
36
|
-
var useStoreDebug_exports = {};
|
|
37
|
-
__export(useStoreDebug_exports, {
|
|
38
|
-
DebugComponents: () => DebugComponents,
|
|
39
|
-
DebugStores: () => DebugStores,
|
|
40
|
-
shouldDebug: () => shouldDebug,
|
|
41
|
-
useCurrentComponent: () => useCurrentComponent,
|
|
42
|
-
useDebugStoreComponent: () => useDebugStoreComponent
|
|
43
|
-
});
|
|
44
|
-
module.exports = __toCommonJS(useStoreDebug_exports);
|
|
45
|
-
var import_react = __toESM(require("react"), 1);
|
|
46
|
-
var useCurrentComponent = function () {
|
|
47
|
-
return {};
|
|
48
|
-
};
|
|
49
|
-
function useDebugStoreComponent(StoreCons) {
|
|
50
|
-
var cmp = useCurrentComponent();
|
|
51
|
-
DebugStores.add(StoreCons);
|
|
52
|
-
if (!DebugComponents.has(cmp)) {
|
|
53
|
-
DebugComponents.set(cmp, /* @__PURE__ */new Set());
|
|
54
|
-
}
|
|
55
|
-
var stores = DebugComponents.get(cmp);
|
|
56
|
-
stores.add(StoreCons);
|
|
57
|
-
import_react.default.useLayoutEffect(function () {
|
|
58
|
-
return function () {
|
|
59
|
-
DebugStores.delete(StoreCons);
|
|
60
|
-
stores.delete(StoreCons);
|
|
61
|
-
};
|
|
62
|
-
}, []);
|
|
63
|
-
}
|
|
64
|
-
var shouldDebug = function (component, info) {
|
|
65
|
-
var _info_storeInstance, _DebugComponents_get;
|
|
66
|
-
var StoreCons = (_info_storeInstance = info.storeInstance) === null || _info_storeInstance === void 0 ? void 0 : _info_storeInstance.constructor;
|
|
67
|
-
return (_DebugComponents_get = DebugComponents.get(component)) === null || _DebugComponents_get === void 0 ? void 0 : _DebugComponents_get.has(StoreCons);
|
|
68
|
-
};
|
|
69
|
-
var DebugComponents = /* @__PURE__ */new Map();
|
|
70
|
-
var DebugStores = /* @__PURE__ */new Set();
|
|
71
|
-
//# sourceMappingURL=useStoreDebug.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useStoreDebug_exports","__export","DebugComponents","DebugStores","shouldDebug","useCurrentComponent","useDebugStoreComponent","module","exports","import_react","__toESM","require","StoreCons","cmp","add","has","set","Set","stores","get","default","useLayoutEffect","delete","component","info","_info_storeInstance","_DebugComponents_get","storeInstance","constructor"],"sources":["../../src/useStoreDebug.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA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,eAAAG,oBAAA,uBAAAA,oBAAA,CAAAX,GAAA,CAAAH,SAAA;AAC/C","ignoreList":[]}
|
package/dist/esm/comparators.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const isEqualSubsetShallow = (a, b, opts) => {
|
|
2
|
-
if (b == null || a == null) return a === b;
|
|
3
|
-
if (typeof a !== typeof b) return false;
|
|
4
|
-
if (typeof b === "object") {
|
|
5
|
-
for (const key in b) {
|
|
6
|
-
const compare = opts?.keyComparators?.[key];
|
|
7
|
-
if (compare ? !compare(a[key], b[key]) : b[key] !== a[key]) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
return a === b;
|
|
14
|
-
};
|
|
15
|
-
export { isEqualSubsetShallow };
|
|
16
|
-
//# sourceMappingURL=comparators.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["isEqualSubsetShallow","a","b","opts","key","compare","keyComparators"],"sources":["../../src/comparators.tsx"],"sourcesContent":[null],"mappings":"AAAO,MAAMA,oBAAA,GAAuBA,CAClCC,CAAA,EACAC,CAAA,EACAC,IAAA,KACG;EACH,IAAID,CAAA,IAAK,QAAQD,CAAA,IAAK,MAAM,OAAOA,CAAA,KAAMC,CAAA;EACzC,IAAI,OAAOD,CAAA,KAAM,OAAOC,CAAA,EAAG,OAAO;EAClC,IAAI,OAAOA,CAAA,KAAM,UAAU;IACzB,WAAWE,GAAA,IAAOF,CAAA,EAAG;MACnB,MAAMG,OAAA,GAAUF,IAAA,EAAMG,cAAA,GAAiBF,GAAG;MAC1C,IAAIC,OAAA,GAAU,CAACA,OAAA,CAAQJ,CAAA,CAAEG,GAAG,GAAGF,CAAA,CAAEE,GAAG,CAAC,IAAIF,CAAA,CAAEE,GAAG,MAAMH,CAAA,CAAEG,GAAG,GAAG;QAC1D,OAAO;MACT;IACF;IACA,OAAO;EACT;EACA,OAAOH,CAAA,KAAMC,CAAA;AACf","ignoreList":[]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
function _type_of(obj) {
|
|
2
|
-
"@swc/helpers - typeof";
|
|
3
|
-
|
|
4
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
5
|
-
}
|
|
6
|
-
var isEqualSubsetShallow = function (a, b, opts) {
|
|
7
|
-
if (b == null || a == null) return a === b;
|
|
8
|
-
if ((typeof a === "undefined" ? "undefined" : _type_of(a)) !== (typeof b === "undefined" ? "undefined" : _type_of(b))) return false;
|
|
9
|
-
if ((typeof b === "undefined" ? "undefined" : _type_of(b)) === "object") {
|
|
10
|
-
for (var key in b) {
|
|
11
|
-
var _opts_keyComparators;
|
|
12
|
-
var compare = opts === null || opts === void 0 ? void 0 : (_opts_keyComparators = opts.keyComparators) === null || _opts_keyComparators === void 0 ? void 0 : _opts_keyComparators[key];
|
|
13
|
-
if (compare ? !compare(a[key], b[key]) : b[key] !== a[key]) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
return a === b;
|
|
20
|
-
};
|
|
21
|
-
export { isEqualSubsetShallow };
|
|
22
|
-
//# sourceMappingURL=comparators.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_type_of","obj","Symbol","constructor","isEqualSubsetShallow","a","b","opts","key","_opts_keyComparators","compare","keyComparators"],"sources":["../../src/comparators.tsx"],"sourcesContent":[null],"mappings":"AAAO,SAAMA,SAAAC,GAAA;EAKX,uBAAsB;;EACtB,OAAIA,GAAA,IAAO,OAAMC,MAAU,gBAAO,IAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AAClC;AACE,IAAAG,oBAAkB,GAAG,SAAAA,CAAAC,CAAA,EAAAC,CAAA,EAAAC,IAAA;EACnB,IAAAD,CAAA,QAAM,IAAAD,CAAA,IAAU,IAAM,SAAAA,CAAA,KAAAC,CAAA;EACtB,YAAID,CAAA,KAAU,WAAW,GAAG,WAAS,GAAIL,QAAK,CAAAK,CAAM,QAAQ,OAAAC,CAAA,iCAAAN,QAAA,CAAAM,CAAA;EAC1D,YAAAA,CAAO,iCAAAN,QAAA,CAAAM,CAAA;IAAA,KACT,IAAAE,GAAA,IAAAF,CAAA;MACF,IAAAG,oBAAA;MACA,IAAAC,OAAO,GAAAH,IAAA,aAAAA,IAAA,wBAAAE,oBAAA,GAAAF,IAAA,CAAAI,cAAA,cAAAF,oBAAA,uBAAAA,oBAAA,CAAAD,GAAA;MACT,IAAAE,OAAA,IAAAA,OAAA,CAAAL,CAAA,CAAAG,GAAA,GAAAF,CAAA,CAAAE,GAAA,KAAAF,CAAA,CAAAE,GAAA,MAAAH,CAAA,CAAAG,GAAA;QACA,OAAa;MACf","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["configureOpts","configureUseStore","opts"],"sources":["../../src/configureUseStore.tsx"],"sourcesContent":[null],"mappings":"AAEO,IAAIA,aAAA,GAAgC,CAAC;AAErC,SAASC,kBAAkBC,IAAA,EAAsB;EACtDF,aAAA,GAAgBE,IAAA;AAClB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["configureOpts","configureUseStore","opts"],"sources":["../../src/configureUseStore.tsx"],"sourcesContent":[null],"mappings":"AAEO,IAAIA,aAAA,GAAgC,CAAC;AAErC,SAASC,kBAAkBC,IAAA,EAAsB;EACtDF,aAAA,GAAgBE,IAAA;AAClB","ignoreList":[]}
|
package/dist/esm/constants.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["UNWRAP_PROXY","Symbol","defaultOptions","once","selector"],"sources":["../../src/constants.tsx"],"sourcesContent":[null],"mappings":"AAAO,MAAMA,YAAA,GAAe,eAAAC,MAAA,CAAO;AAE5B,MAAMC,cAAA,GAAiB;EAC5BC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["UNWRAP_PROXY","Symbol","defaultOptions","once","selector"],"sources":["../../src/constants.tsx"],"sourcesContent":[null],"mappings":"AAAO,IAAAA,YAAM,kBAAeC,MAAA;AAErB,IAAAC,cAAM;EACXC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ","ignoreList":[]}
|
package/dist/esm/decorators.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["compare","comparator","target","propertyKey"],"sources":["../../src/decorators.tsx"],"sourcesContent":[null],"mappings":"AAEO,SAASA,QAAQC,UAAA,EAA0B;EAChD,OAAO,CAACC,MAAA,EAAaC,WAAA,KAA6B;IAChDD,MAAA,CAAO,cAAc,IAAIA,MAAA,CAAO,cAAc,KAAK,CAAC;IACpDA,MAAA,CAAO,cAAc,EAAEC,WAAW,IAAIF,UAAA;EACxC;AACF","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["compare","comparator","target","propertyKey"],"sources":["../../src/decorators.tsx"],"sourcesContent":[null],"mappings":"AAEO,SAASA,QAAQC,UAAA,EAA0B;EAChD,OAAO,UAAcC,MAAA,EAAAC,WAA6B;IAChDD,MAAA,CAAO,cAAc,IAAIA,MAAA,CAAO,cAAc,KAAK,CAAC;IACpDA,MAAA,CAAO,cAAc,EAAEC,WAAW,IAAIF,UAAA;EACxC;AACF","ignoreList":[]}
|
package/dist/esm/helpers.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { simpleHash } from "@hanzogui/simple-hash";
|
|
2
|
-
function getStoreUid(Constructor, props) {
|
|
3
|
-
return simpleHash(`${Constructor}${!props ? "" : typeof props === "string" ? props : JSON.stringify(props)}`, "strict");
|
|
4
|
-
}
|
|
5
|
-
const UNWRAP_STORE_INFO = /* @__PURE__ */Symbol("UNWRAP_STORE_INFO");
|
|
6
|
-
const cache = /* @__PURE__ */new Map();
|
|
7
|
-
function getStoreDescriptors(storeInstance) {
|
|
8
|
-
const proto = Object.getPrototypeOf(storeInstance);
|
|
9
|
-
const instanceDescriptors = Object.getOwnPropertyDescriptors(storeInstance);
|
|
10
|
-
const protoDescriptors = Object.getOwnPropertyDescriptors(proto);
|
|
11
|
-
const descriptors = {
|
|
12
|
-
...protoDescriptors,
|
|
13
|
-
...instanceDescriptors
|
|
14
|
-
};
|
|
15
|
-
delete descriptors.constructor;
|
|
16
|
-
return descriptors;
|
|
17
|
-
}
|
|
18
|
-
function get(_, b) {
|
|
19
|
-
return _;
|
|
20
|
-
}
|
|
21
|
-
function simpleStr(arg) {
|
|
22
|
-
if (process.env.NODE_ENV === "development") {
|
|
23
|
-
return typeof arg === "function" ? "fn" : typeof arg === "string" ? `"${arg}"` : !arg ? arg : typeof arg !== "object" ? arg : Array.isArray(arg) ? "[...]" : `{...}`;
|
|
24
|
-
}
|
|
25
|
-
return arg;
|
|
26
|
-
}
|
|
27
|
-
function getStoreDebugInfo(store) {
|
|
28
|
-
return store[UNWRAP_STORE_INFO] ?? cache.get(getStoreUid(store.constructor, store.props));
|
|
29
|
-
}
|
|
30
|
-
export { UNWRAP_STORE_INFO, cache, get, getStoreDebugInfo, getStoreDescriptors, getStoreUid, simpleStr };
|
|
31
|
-
//# sourceMappingURL=helpers.mjs.map
|
package/dist/esm/helpers.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["simpleHash","getStoreUid","Constructor","props","JSON","stringify","UNWRAP_STORE_INFO","Symbol","cache","Map","getStoreDescriptors","storeInstance","proto","Object","getPrototypeOf","instanceDescriptors","getOwnPropertyDescriptors","protoDescriptors","descriptors","constructor","get","_","b","simpleStr","arg","process","env","NODE_ENV","Array","isArray","getStoreDebugInfo","store"],"sources":["../../src/helpers.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAA,QAAkB;AAIpB,SAASC,YAAYC,WAAA,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|
|
|
1
|
-
import { simpleHash } from "@hanzogui/simple-hash";
|
|
2
|
-
function _type_of(obj) {
|
|
3
|
-
"@swc/helpers - typeof";
|
|
4
|
-
|
|
5
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
6
|
-
}
|
|
7
|
-
function getStoreUid(Constructor, props) {
|
|
8
|
-
return simpleHash(`${Constructor}${!props ? "" : typeof props === "string" ? props : JSON.stringify(props)}`, "strict");
|
|
9
|
-
}
|
|
10
|
-
var UNWRAP_STORE_INFO = /* @__PURE__ */Symbol("UNWRAP_STORE_INFO");
|
|
11
|
-
var cache = /* @__PURE__ */new Map();
|
|
12
|
-
function getStoreDescriptors(storeInstance) {
|
|
13
|
-
var proto = Object.getPrototypeOf(storeInstance);
|
|
14
|
-
var instanceDescriptors = Object.getOwnPropertyDescriptors(storeInstance);
|
|
15
|
-
var protoDescriptors = Object.getOwnPropertyDescriptors(proto);
|
|
16
|
-
var descriptors = {
|
|
17
|
-
...protoDescriptors,
|
|
18
|
-
...instanceDescriptors
|
|
19
|
-
};
|
|
20
|
-
delete descriptors.constructor;
|
|
21
|
-
return descriptors;
|
|
22
|
-
}
|
|
23
|
-
function get(_, b) {
|
|
24
|
-
return _;
|
|
25
|
-
}
|
|
26
|
-
function simpleStr(arg) {
|
|
27
|
-
if (process.env.NODE_ENV === "development") {
|
|
28
|
-
return typeof arg === "function" ? "fn" : typeof arg === "string" ? `"${arg}"` : !arg ? arg : (typeof arg === "undefined" ? "undefined" : _type_of(arg)) !== "object" ? arg : Array.isArray(arg) ? "[...]" : `{...}`;
|
|
29
|
-
}
|
|
30
|
-
return arg;
|
|
31
|
-
}
|
|
32
|
-
function getStoreDebugInfo(store) {
|
|
33
|
-
var _store_UNWRAP_STORE_INFO;
|
|
34
|
-
return (_store_UNWRAP_STORE_INFO = store[UNWRAP_STORE_INFO]) !== null && _store_UNWRAP_STORE_INFO !== void 0 ? _store_UNWRAP_STORE_INFO : cache.get(getStoreUid(store.constructor, store.props));
|
|
35
|
-
}
|
|
36
|
-
export { UNWRAP_STORE_INFO, cache, get, getStoreDebugInfo, getStoreDescriptors, getStoreUid, simpleStr };
|
|
37
|
-
//# sourceMappingURL=helpers.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["simpleHash","_type_of","obj","Symbol","constructor","getStoreUid","Constructor","props","JSON","stringify","UNWRAP_STORE_INFO","cache","Map","getStoreDescriptors","storeInstance","proto","Object","getPrototypeOf","instanceDescriptors","getOwnPropertyDescriptors","protoDescriptors","descriptors","get","_","b","simpleStr","arg","process","env","NODE_ENV","Array","isArray","getStoreDebugInfo","store","_store_UNWRAP_STORE_INFO"],"sources":["../../src/helpers.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAA,QAAkB;AAIpB,SAASC,SAAAC,GAAY;EAC1B,uBAAO;;EAAA,OACFA,GAAA,WACAC,MAAA,KAAQ,WAAY,IAAAD,GAAU,CAAAE,WAAW,KAAAD,MAAQ,GAAK,QAAU,UACnED,GAAA;AAAA;AACA,SACFG,YAAAC,WAAA,EAAAC,KAAA;EACF,OAAAP,UAAA,IAAAM,WAAA,IAAAC,KAAA,eAAAA,KAAA,gBAAAA,KAAA,GAAAC,IAAA,CAAAC,SAAA,CAAAF,KAAA;AAEO;AACA,IAAAG,iBAAc,kBAA2BP,MAAA;AAEzC,IAAAQ,KAAS,sBAAoBC,GAAA;AAClC,SAAMC,mBAAeA,CAAAC,aAAe;EACpC,IAAAC,KAAM,GAAAC,MAAA,CAAAC,cAAsB,CAAAH,aAAO;EACnC,IAAAI,mBAAM,GAAmBF,MAAO,CAAAG,yBAA0B,CAAAL,aAAK;EAC/D,IAAAM,gBAAoB,GAAAJ,MAAA,CAAAG,yBAAA,CAAAJ,KAAA;EAAA,IAClBM,WAAG;IACH,GAAGD,gBAAA;IACL,GAAAF;EAEA;EACA,OAAOG,WAAA,CAAAjB,WAAA;EACT,OAAAiB,WAAA;AAEO;AACL,SAAOC,IAAAC,CAAA,EAAAC,CAAA;EACT,OAAAD,CAAA;AAEO;AACL,SAAIE,SAAYA,CAAAC,GAAA;EACd,IAAAC,OAAO,CAAAC,GAAA,CAAOC,QAAQ,kBAClB,EACA;IASN,cAAAH,GAAA,gCAAAA,GAAA,oBAAAA,GAAA,OAAAA,GAAA,GAAAA,GAAA,WAAAA,GAAA,iCAAAzB,QAAA,CAAAyB,GAAA,kBAAAA,GAAA,GAAAI,KAAA,CAAAC,OAAA,CAAAL,GAAA;EACA;EACF,OAAAA,GAAA;AAGO;AACL,SACEM,iBAAMA,CAAAC,KAAiB;EAE3B,IAAAC,wBAAA","ignoreList":[]}
|
package/dist/esm/index.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from "./useStore.mjs";
|
|
2
|
-
import { configureUseStore } from "./configureUseStore.mjs";
|
|
3
|
-
export * from "./interfaces.mjs";
|
|
4
|
-
export * from "./observe.mjs";
|
|
5
|
-
import { UNWRAP_PROXY } from "./constants.mjs";
|
|
6
|
-
export * from "./comparators.mjs";
|
|
7
|
-
export * from "./decorators.mjs";
|
|
8
|
-
class Store {
|
|
9
|
-
constructor(props) {
|
|
10
|
-
this.props = props;
|
|
11
|
-
}
|
|
12
|
-
props;
|
|
13
|
-
}
|
|
14
|
-
export { Store, UNWRAP_PROXY, configureUseStore };
|
|
15
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["configureUseStore","UNWRAP_PROXY","Store","constructor","props"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,SAASA,iBAAA,QAAyB;AAClC,cAAc;AACd,cAAc;AACd,SAASC,YAAA,QAAoB;AAC7B,cAAc;AACd,cAAc;AAGP,MAAMC,KAAA,CAAyC;EACpDC,YAAmBC,KAAA,EAAc;IAAd,KAAAA,KAAA,GAAAA,KAAA;EAAe;EAAfA,KAAA;AACrB","ignoreList":[]}
|
package/dist/esm/index.native.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export * from "./useStore.native.js";
|
|
2
|
-
import { configureUseStore } from "./configureUseStore.native.js";
|
|
3
|
-
export * from "./interfaces.native.js";
|
|
4
|
-
export * from "./observe.native.js";
|
|
5
|
-
import { UNWRAP_PROXY } from "./constants.native.js";
|
|
6
|
-
export * from "./comparators.native.js";
|
|
7
|
-
export * from "./decorators.native.js";
|
|
8
|
-
function _class_call_check(instance, Constructor) {
|
|
9
|
-
if (!(instance instanceof Constructor)) {
|
|
10
|
-
throw new TypeError("Cannot call a class as a function");
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
function _define_property(obj, key, value) {
|
|
14
|
-
if (key in obj) {
|
|
15
|
-
Object.defineProperty(obj, key, {
|
|
16
|
-
value,
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true
|
|
20
|
-
});
|
|
21
|
-
} else {
|
|
22
|
-
obj[key] = value;
|
|
23
|
-
}
|
|
24
|
-
return obj;
|
|
25
|
-
}
|
|
26
|
-
var Store = function Store2(props) {
|
|
27
|
-
"use strict";
|
|
28
|
-
|
|
29
|
-
_class_call_check(this, Store2);
|
|
30
|
-
_define_property(this, "props", void 0);
|
|
31
|
-
this.props = props;
|
|
32
|
-
};
|
|
33
|
-
export { Store, UNWRAP_PROXY, configureUseStore };
|
|
34
|
-
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["configureUseStore","UNWRAP_PROXY","_class_call_check","instance","Constructor","TypeError","_define_property","obj","key","value"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,SAASA,iBAAA,QAAyB;AAClC,cAAc;AACd,cAAc;AACd,SAASC,YAAA,QAAoB;AAC7B,cAAc;AACd,cAAc;AAGP,SAAMC,iBAAyCA,CAAAC,QAAA,EAAAC,WAAA;EACpD,MAAAD,QAAmB,YAAcC,WAAA;IAAd,UAAAC,SAAA;EAAe;AAAA;AACpC,SAAAC,iBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA","ignoreList":[]}
|
package/dist/esm/interfaces.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
|
package/dist/esm/observe.mjs
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { isEqualSubsetShallow } from "./comparators.mjs";
|
|
3
|
-
import { UNWRAP_PROXY } from "./constants.mjs";
|
|
4
|
-
import { trackStoresAccess } from "./useStore.mjs";
|
|
5
|
-
const logUpdate = process.env.NODE_ENV === "development" ? (fn, stores, last, next) => {
|
|
6
|
-
const getStoreLogName = store => {
|
|
7
|
-
const str = store[UNWRAP_PROXY] ?? store;
|
|
8
|
-
return `${str.constructor.name}${store.props?.id ? `:${store.props.id}` : ""}`;
|
|
9
|
-
};
|
|
10
|
-
const storeNames = stores.map(getStoreLogName).join(", ");
|
|
11
|
-
const name = `\u{1F311} \u25B6\uFE0F %c${fn.name} ${storeNames} () ${last} => ${next}`;
|
|
12
|
-
console.groupCollapsed(name, "color: tomato;");
|
|
13
|
-
console.groupCollapsed("trace >");
|
|
14
|
-
console.trace();
|
|
15
|
-
console.groupEnd();
|
|
16
|
-
console.info(" next", next);
|
|
17
|
-
console.groupEnd();
|
|
18
|
-
} : null;
|
|
19
|
-
function observe(fn) {
|
|
20
|
-
let prev = getObserverValueAndStoresAccessed(fn);
|
|
21
|
-
let disposeValue = null;
|
|
22
|
-
const subscribe = () => {
|
|
23
|
-
const stores = [...prev.storeInfos];
|
|
24
|
-
return subscribeToStores(stores, () => {
|
|
25
|
-
disposeValue?.();
|
|
26
|
-
const next = getObserverValueAndStoresAccessed(fn);
|
|
27
|
-
if (typeof next.value === "function") {
|
|
28
|
-
disposeValue = next.value;
|
|
29
|
-
if (process.env.NODE_ENV === "development") {
|
|
30
|
-
logUpdate(fn, [...next.storeInfos], "(fn)", "(fn)");
|
|
31
|
-
}
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (isEqualSubsetShallow(prev.storeInfos, next.storeInfos) && isEqualSubsetShallow(prev.value, next.value)) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (process.env.NODE_ENV === "development") {
|
|
38
|
-
logUpdate(fn, [...next.storeInfos], prev.value, next.value);
|
|
39
|
-
}
|
|
40
|
-
prev = next;
|
|
41
|
-
dispose();
|
|
42
|
-
dispose = subscribe();
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
let dispose = subscribe();
|
|
46
|
-
return {
|
|
47
|
-
dispose: () => {
|
|
48
|
-
dispose();
|
|
49
|
-
disposeValue?.();
|
|
50
|
-
},
|
|
51
|
-
getValue: () => prev.value
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function useObserve(fn) {
|
|
55
|
-
const [state, setState] = React.useState(() => {
|
|
56
|
-
return getObserverValueAndStoresAccessed(fn);
|
|
57
|
-
});
|
|
58
|
-
React.useEffect(() => {
|
|
59
|
-
let dispose;
|
|
60
|
-
const unsub = subscribeToStores([...state.storeInfos], () => {
|
|
61
|
-
dispose?.();
|
|
62
|
-
const next = getObserverValueAndStoresAccessed(fn);
|
|
63
|
-
const nextStoreInfos = [...next.storeInfos];
|
|
64
|
-
const prevStoreInfos = [...state.storeInfos];
|
|
65
|
-
if (typeof next.value === "function") {
|
|
66
|
-
if (process.env.NODE_ENV === "development") {
|
|
67
|
-
logUpdate(fn, nextStoreInfos, "(fn)", "(fn)");
|
|
68
|
-
}
|
|
69
|
-
dispose = next.value;
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
setState(prev => {
|
|
73
|
-
if (isEqualSubsetShallow(prevStoreInfos, nextStoreInfos) && isEqualSubsetShallow(prev.value, next.value)) {
|
|
74
|
-
return prev;
|
|
75
|
-
}
|
|
76
|
-
if (process.env.NODE_ENV === "development") {
|
|
77
|
-
logUpdate(fn, nextStoreInfos, prev.value, next.value);
|
|
78
|
-
}
|
|
79
|
-
return next;
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
return () => {
|
|
83
|
-
unsub();
|
|
84
|
-
dispose?.();
|
|
85
|
-
};
|
|
86
|
-
}, [[...state.storeInfos].map(i => i.uid).join(",")]);
|
|
87
|
-
return state.value;
|
|
88
|
-
}
|
|
89
|
-
function getObserverValueAndStoresAccessed(selector) {
|
|
90
|
-
const storeInfos = /* @__PURE__ */new Set();
|
|
91
|
-
const dispose = trackStoresAccess(storeInfo => {
|
|
92
|
-
storeInfos.add(storeInfo);
|
|
93
|
-
});
|
|
94
|
-
const value = selector();
|
|
95
|
-
dispose();
|
|
96
|
-
return {
|
|
97
|
-
value,
|
|
98
|
-
storeInfos
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function subscribeToStores(storeInfos, onUpdate) {
|
|
102
|
-
const disposes = [];
|
|
103
|
-
let isUpdating = false;
|
|
104
|
-
const onUpdateDebouncedWithoutTracking = () => {
|
|
105
|
-
if (isUpdating) return;
|
|
106
|
-
isUpdating = true;
|
|
107
|
-
queueMicrotask(() => {
|
|
108
|
-
try {
|
|
109
|
-
for (const storeInfo of storeInfos) {
|
|
110
|
-
storeInfo.disableTracking = true;
|
|
111
|
-
}
|
|
112
|
-
onUpdate();
|
|
113
|
-
} finally {
|
|
114
|
-
isUpdating = false;
|
|
115
|
-
for (const storeInfo of storeInfos) {
|
|
116
|
-
storeInfo.disableTracking = false;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
for (const storeInfo of storeInfos) {
|
|
122
|
-
disposes.push(storeInfo.subscribe(onUpdateDebouncedWithoutTracking));
|
|
123
|
-
}
|
|
124
|
-
return () => {
|
|
125
|
-
disposes.forEach(x => x());
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
export { observe, useObserve };
|
|
129
|
-
//# sourceMappingURL=observe.mjs.map
|
package/dist/esm/observe.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","isEqualSubsetShallow","UNWRAP_PROXY","trackStoresAccess","logUpdate","process","env","NODE_ENV","fn","stores","last","next","getStoreLogName","store","str","constructor","name","props","id","storeNames","map","join","console","groupCollapsed","trace","groupEnd","info","observe","prev","getObserverValueAndStoresAccessed","disposeValue","subscribe","storeInfos","subscribeToStores","value","dispose","getValue","useObserve","state","setState","useState","useEffect","unsub","nextStoreInfos","prevStoreInfos","i","uid","selector","Set","storeInfo","add","onUpdate","disposes","isUpdating","onUpdateDebouncedWithoutTracking","queueMicrotask","disableTracking","push","forEach","x"],"sources":["../../src/observe.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAElB,SAASC,oBAAA,QAA4B;AACrC,SAASC,YAAA,QAAoB;AAE7B,SAASC,iBAAA,QAAyB;AAElC,MAAMC,SAAA,GACJC,OAAA,CAAQC,GAAA,CAAIC,QAAA,KAAa,gBACrB,CAACC,EAAA,EAASC,MAAA,EAAeC,IAAA,EAAWC,IAAA,KAAc;EAChD,MAAMC,eAAA,GAAmBC,KAAA,IAAe;IACtC,MAAMC,GAAA,GAAMD,KAAA,CAAMX,YAAY,KAAKW,KAAA;IACnC,OAAO,GAAGC,GAAA,CAAIC,WAAA,CAAYC,IAAI,GAAGH,KAAA,CAAMI,KAAA,EAAOC,EAAA,GAAK,IAAIL,KAAA,CAAMI,KAAA,CAAMC,EAAE,KAAK,EAAE;EAC9E;EACA,MAAMC,UAAA,GAAaV,MAAA,CAAOW,GAAA,CAAIR,eAAe,EAAES,IAAA,CAAK,IAAI;EACxD,MAAML,IAAA,GAAO,6BAAYR,EAAA,CAAGQ,IAAI,IAAIG,UAA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