@hanzogui/use-store 2.0.0

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.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +91 -0
  3. package/dist/cjs/comparators.cjs +37 -0
  4. package/dist/cjs/comparators.native.js +46 -0
  5. package/dist/cjs/comparators.native.js.map +1 -0
  6. package/dist/cjs/configureUseStore.cjs +30 -0
  7. package/dist/cjs/configureUseStore.native.js +33 -0
  8. package/dist/cjs/configureUseStore.native.js.map +1 -0
  9. package/dist/cjs/constants.cjs +31 -0
  10. package/dist/cjs/constants.native.js +34 -0
  11. package/dist/cjs/constants.native.js.map +1 -0
  12. package/dist/cjs/decorators.cjs +30 -0
  13. package/dist/cjs/decorators.native.js +33 -0
  14. package/dist/cjs/decorators.native.js.map +1 -0
  15. package/dist/cjs/helpers.cjs +55 -0
  16. package/dist/cjs/helpers.native.js +65 -0
  17. package/dist/cjs/helpers.native.js.map +1 -0
  18. package/dist/cjs/index.cjs +40 -0
  19. package/dist/cjs/index.native.js +54 -0
  20. package/dist/cjs/index.native.js.map +1 -0
  21. package/dist/cjs/interfaces.cjs +16 -0
  22. package/dist/cjs/interfaces.native.js +19 -0
  23. package/dist/cjs/interfaces.native.js.map +1 -0
  24. package/dist/cjs/observe.cjs +120 -0
  25. package/dist/cjs/observe.native.js +186 -0
  26. package/dist/cjs/observe.native.js.map +1 -0
  27. package/dist/cjs/useStore.cjs +390 -0
  28. package/dist/cjs/useStore.native.js +544 -0
  29. package/dist/cjs/useStore.native.js.map +1 -0
  30. package/dist/cjs/useStoreDebug.cjs +56 -0
  31. package/dist/cjs/useStoreDebug.native.js +65 -0
  32. package/dist/cjs/useStoreDebug.native.js.map +1 -0
  33. package/dist/esm/comparators.mjs +14 -0
  34. package/dist/esm/comparators.mjs.map +1 -0
  35. package/dist/esm/comparators.native.js +20 -0
  36. package/dist/esm/comparators.native.js.map +1 -0
  37. package/dist/esm/configureUseStore.mjs +6 -0
  38. package/dist/esm/configureUseStore.mjs.map +1 -0
  39. package/dist/esm/configureUseStore.native.js +6 -0
  40. package/dist/esm/configureUseStore.native.js.map +1 -0
  41. package/dist/esm/constants.mjs +7 -0
  42. package/dist/esm/constants.mjs.map +1 -0
  43. package/dist/esm/constants.native.js +7 -0
  44. package/dist/esm/constants.native.js.map +1 -0
  45. package/dist/esm/decorators.mjs +7 -0
  46. package/dist/esm/decorators.mjs.map +1 -0
  47. package/dist/esm/decorators.native.js +7 -0
  48. package/dist/esm/decorators.native.js.map +1 -0
  49. package/dist/esm/helpers.mjs +26 -0
  50. package/dist/esm/helpers.mjs.map +1 -0
  51. package/dist/esm/helpers.native.js +33 -0
  52. package/dist/esm/helpers.native.js.map +1 -0
  53. package/dist/esm/index.js +14 -0
  54. package/dist/esm/index.js.map +1 -0
  55. package/dist/esm/index.mjs +14 -0
  56. package/dist/esm/index.mjs.map +1 -0
  57. package/dist/esm/index.native.js +25 -0
  58. package/dist/esm/index.native.js.map +1 -0
  59. package/dist/esm/interfaces.mjs +2 -0
  60. package/dist/esm/interfaces.mjs.map +1 -0
  61. package/dist/esm/interfaces.native.js +2 -0
  62. package/dist/esm/interfaces.native.js.map +1 -0
  63. package/dist/esm/observe.mjs +85 -0
  64. package/dist/esm/observe.mjs.map +1 -0
  65. package/dist/esm/observe.native.js +148 -0
  66. package/dist/esm/observe.native.js.map +1 -0
  67. package/dist/esm/useStore.mjs +342 -0
  68. package/dist/esm/useStore.mjs.map +1 -0
  69. package/dist/esm/useStore.native.js +493 -0
  70. package/dist/esm/useStore.native.js.map +1 -0
  71. package/dist/esm/useStoreDebug.mjs +18 -0
  72. package/dist/esm/useStoreDebug.mjs.map +1 -0
  73. package/dist/esm/useStoreDebug.native.js +24 -0
  74. package/dist/esm/useStoreDebug.native.js.map +1 -0
  75. package/package.json +47 -0
  76. package/src/comparators.tsx +18 -0
  77. package/src/configureUseStore.tsx +7 -0
  78. package/src/constants.tsx +6 -0
  79. package/src/decorators.tsx +8 -0
  80. package/src/helpers.tsx +56 -0
  81. package/src/index.ts +12 -0
  82. package/src/interfaces.tsx +46 -0
  83. package/src/observe.tsx +160 -0
  84. package/src/useStore.tsx +705 -0
  85. package/src/useStoreDebug.tsx +41 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nate Wienert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # @hanzogui/use-store
2
+
3
+ Simplish reactive classes in react. It doesn't do granular deep object reaction, just the top level set.
4
+
5
+ ```tsx
6
+ import {
7
+ createUseStore,
8
+ createStoreInstance,
9
+ useStore,
10
+ useGlobalStore,
11
+ } from '@hanzogui/use-store'
12
+
13
+ class X {
14
+ y = 0
15
+
16
+ add() {
17
+ this.y += 1
18
+ }
19
+ }
20
+
21
+ // Can use it a few ways, all these will access *the same* store:
22
+ const useX = createUseStore(X)
23
+ const x = createStoreInstance(X)
24
+
25
+ // all of these will be reactive, so only props you use cause re-renders
26
+ export function ReactComponent() {
27
+ const x0 = useStore(X)
28
+ const x1 = useX()
29
+ const x2 = useGlobalStore(x)
30
+
31
+ return (
32
+ <>
33
+ <div>{x0.y}</div>
34
+ <button action={x0.add}>add</button>
35
+ </>
36
+ )
37
+ }
38
+
39
+ // if you want a different instance or namespace, pass props, these will also all access the same store:
40
+ export function ReactComponentAlt() {
41
+ const x0 = useStore(X, { id: 100 })
42
+ const x1 = useX({ id: 100 })
43
+ const x2 = useGlobalStore(x, { id: 100 })
44
+
45
+ return <div>{x0.y}</div>
46
+ }
47
+
48
+ // finally, you can make selectors with
49
+ export function ReactComponentAlt() {
50
+ const xplusten0 = useStoreSelector(X, { id: 100 }, (x) => x.y + 10)
51
+ const xplusten1 = useGlobalStoreSelector(X, { id: 100 }, (x) => x.y + 10)
52
+
53
+ return <div>{xplusten}</div>
54
+ }
55
+ ```
56
+
57
+ ---
58
+
59
+ TODO
60
+
61
+ - usePortal
62
+
63
+ Better selectors/reactions:
64
+
65
+ - useSelector
66
+ - reaction
67
+
68
+ Basically make them not tied to one store:
69
+
70
+ ```tsx
71
+ const isValid = useStoreSelector(() => {
72
+ return mapStore.isActive && homeStore.isActive
73
+ })
74
+ ```
75
+
76
+ Same with reaction:
77
+
78
+ ```tsx
79
+ useEffect(() => {
80
+ return reaction(
81
+ () => {
82
+ return homeStore.isActive && mapStore.isActive
83
+ },
84
+ (isValid) => {
85
+ // ...
86
+ }
87
+ )
88
+ }, [])
89
+ ```
90
+
91
+ Note it does shallow compare.
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var comparators_exports = {};
22
+ __export(comparators_exports, {
23
+ isEqualSubsetShallow: () => isEqualSubsetShallow
24
+ });
25
+ module.exports = __toCommonJS(comparators_exports);
26
+ const isEqualSubsetShallow = (a, b, opts) => {
27
+ if (b == null || a == null) return a === b;
28
+ if (typeof a != typeof b) return !1;
29
+ if (typeof b == "object") {
30
+ for (const key in b) {
31
+ const compare = opts?.keyComparators?.[key];
32
+ if (compare ? !compare(a[key], b[key]) : b[key] !== a[key]) return !1;
33
+ }
34
+ return !0;
35
+ }
36
+ return a === b;
37
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var comparators_exports = {};
24
+ __export(comparators_exports, {
25
+ isEqualSubsetShallow: () => isEqualSubsetShallow
26
+ });
27
+ module.exports = __toCommonJS(comparators_exports);
28
+ function _type_of(obj) {
29
+ "@swc/helpers - typeof";
30
+
31
+ return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
32
+ }
33
+ var isEqualSubsetShallow = function (a, b, opts) {
34
+ if (b == null || a == null) return a === b;
35
+ if ((typeof a > "u" ? "undefined" : _type_of(a)) !== (typeof b > "u" ? "undefined" : _type_of(b))) return !1;
36
+ if ((typeof b > "u" ? "undefined" : _type_of(b)) === "object") {
37
+ for (var key in b) {
38
+ var _opts_keyComparators,
39
+ compare = opts == null || (_opts_keyComparators = opts.keyComparators) === null || _opts_keyComparators === void 0 ? void 0 : _opts_keyComparators[key];
40
+ if (compare ? !compare(a[key], b[key]) : b[key] !== a[key]) return !1;
41
+ }
42
+ return !0;
43
+ }
44
+ return a === b;
45
+ };
46
+ //# sourceMappingURL=comparators.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","comparators_exports","__export","isEqualSubsetShallow","module","exports","_type_of","obj","Symbol","constructor","a","b","opts","key","_opts_keyComparators","compare","keyComparators"],"sources":["../../src/comparators.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,mBAAA;AAAAC,QAAA,CAAAD,mBAAA;EAAAE,oBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAOC,MAAM,CAAAC,OAAA,GAAAT,YAAuB,CAClCK,mBAGG;AACH,SAAIK,QAAKA,CAAAC,GAAQ;EACjB,uBAAwB;;EACxB,OAAIA,GAAA,IAAO,OAAMC,MAAU,UAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AACzB;AACE,IAAAJ,oBAAgB,YAAAA,CAAMO,CAAA,EAAAC,CAAA,EAAAC,IAAiB,EAAG;EAC1C,IAAAD,CAAA,IAAI,QAAAD,CAAU,IAAC,MAAQ,OAAQA,CAAA,KAAMC,CAAA;EACnC,YAAAD,CAAO,uBAAAJ,QAAA,CAAAI,CAAA,eAAAC,CAAA,uBAAAL,QAAA,CAAAK,CAAA;EAAA,IAEX,QAAAA,CAAA,uBAAAL,QAAA,CAAAK,CAAA;IACA,SAAOE,GAAA,IAAAF,CAAA;MACT,IAAAG,oBAAA;QAAAC,OAAA,GAAAH,IAAA,aAAAE,oBAAA,GAAAF,IAAA,CAAAI,cAAA,cAAAF,oBAAA,uBAAAA,oBAAA,CAAAD,GAAA;MACA,IAAOE,OAAM,IAAAA,OAAA,CAAAL,CAAA,CAAAG,GAAA,GAAAF,CAAA,CAAAE,GAAA,KAAAF,CAAA,CAAAE,GAAA,MAAAH,CAAA,CAAAG,GAAA,GACf","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var configureUseStore_exports = {};
22
+ __export(configureUseStore_exports, {
23
+ configureOpts: () => configureOpts,
24
+ configureUseStore: () => configureUseStore
25
+ });
26
+ module.exports = __toCommonJS(configureUseStore_exports);
27
+ let configureOpts = {};
28
+ function configureUseStore(opts) {
29
+ configureOpts = opts;
30
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var configureUseStore_exports = {};
24
+ __export(configureUseStore_exports, {
25
+ configureOpts: () => configureOpts,
26
+ configureUseStore: () => configureUseStore
27
+ });
28
+ module.exports = __toCommonJS(configureUseStore_exports);
29
+ var configureOpts = {};
30
+ function configureUseStore(opts) {
31
+ configureOpts = opts;
32
+ }
33
+ //# sourceMappingURL=configureUseStore.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","configureUseStore_exports","__export","configureOpts","configureUseStore","module","exports","opts"],"sources":["../../src/configureUseStore.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,yBAAA;AAAAC,QAAA,CAAAD,yBAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,iBAAA,EAAAA,CAAA,KAAAA;AAAA;AAEOC,MAAI,CAAAC,OAAA,GAAAV,YAAiC,CAAAK,yBAAA;AAErC,IAAAE,aAAS;AACd,SAAAC,iBAAgBA,CAAAG,IAAA;EAClBJ,aAAA,GAAAI,IAAA","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var constants_exports = {};
22
+ __export(constants_exports, {
23
+ UNWRAP_PROXY: () => UNWRAP_PROXY,
24
+ defaultOptions: () => defaultOptions
25
+ });
26
+ module.exports = __toCommonJS(constants_exports);
27
+ const UNWRAP_PROXY = /* @__PURE__ */Symbol(),
28
+ defaultOptions = {
29
+ once: !1,
30
+ selector: void 0
31
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var constants_exports = {};
24
+ __export(constants_exports, {
25
+ UNWRAP_PROXY: () => UNWRAP_PROXY,
26
+ defaultOptions: () => defaultOptions
27
+ });
28
+ module.exports = __toCommonJS(constants_exports);
29
+ var UNWRAP_PROXY = /* @__PURE__ */Symbol(),
30
+ defaultOptions = {
31
+ once: !1,
32
+ selector: void 0
33
+ };
34
+ //# sourceMappingURL=constants.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","constants_exports","__export","UNWRAP_PROXY","defaultOptions","module","exports","Symbol","once","selector"],"sources":["../../src/constants.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,iBAAA;AAAAC,QAAA,CAAAD,iBAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA,YAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA;AAAA;AAAOC,MAAM,CAAAC,OAAA,GAAAV,YAAe,CAAAK,iBAEf;AAAiB,IAC5BE,YAAM,kBAAAI,MAAA;EAAAH,cAAA;IACNI,IAAA;IACFC,QAAA","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var decorators_exports = {};
22
+ __export(decorators_exports, {
23
+ compare: () => compare
24
+ });
25
+ module.exports = __toCommonJS(decorators_exports);
26
+ function compare(comparator) {
27
+ return (target, propertyKey) => {
28
+ target._comparators = target._comparators || {}, target._comparators[propertyKey] = comparator;
29
+ };
30
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var decorators_exports = {};
24
+ __export(decorators_exports, {
25
+ compare: () => compare
26
+ });
27
+ module.exports = __toCommonJS(decorators_exports);
28
+ function compare(comparator) {
29
+ return function (target, propertyKey) {
30
+ target._comparators = target._comparators || {}, target._comparators[propertyKey] = comparator;
31
+ };
32
+ }
33
+ //# sourceMappingURL=decorators.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","decorators_exports","__export","compare","module","exports","comparator","target","propertyKey","_comparators"],"sources":["../../src/decorators.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,kBAAA;AAAAC,QAAA,CAAAD,kBAAA;EAAAE,OAAA,EAAAA,CAAA,KAAAA;AAAA;AAEOC,MAAA,CAAAC,OAAS,GAAQT,YAA0B,CAAAK,kBAAA;AAChD,SAAOE,OAACA,CAAAG,UAAa;EACnB,iBAAOC,MAAA,EAAkBC,WAAO;IAElCD,MAAA,CAAAE,YAAA,GAAAF,MAAA,CAAAE,YAAA,QAAAF,MAAA,CAAAE,YAAA,CAAAD,WAAA,IAAAF,UAAA;EACF","ignoreList":[]}
@@ -0,0 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var helpers_exports = {};
22
+ __export(helpers_exports, {
23
+ UNWRAP_STORE_INFO: () => UNWRAP_STORE_INFO,
24
+ cache: () => cache,
25
+ get: () => get,
26
+ getStoreDebugInfo: () => getStoreDebugInfo,
27
+ getStoreDescriptors: () => getStoreDescriptors,
28
+ getStoreUid: () => getStoreUid,
29
+ simpleStr: () => simpleStr
30
+ });
31
+ module.exports = __toCommonJS(helpers_exports);
32
+ var import_simple_hash = require("@hanzogui/simple-hash");
33
+ function getStoreUid(Constructor, props) {
34
+ return (0, import_simple_hash.simpleHash)(`${Constructor}${props ? typeof props == "string" ? props : JSON.stringify(props) : ""}`, "strict");
35
+ }
36
+ const UNWRAP_STORE_INFO = /* @__PURE__ */Symbol("UNWRAP_STORE_INFO"),
37
+ cache = /* @__PURE__ */new Map();
38
+ function getStoreDescriptors(storeInstance) {
39
+ const proto = Object.getPrototypeOf(storeInstance),
40
+ instanceDescriptors = Object.getOwnPropertyDescriptors(storeInstance),
41
+ descriptors = {
42
+ ...Object.getOwnPropertyDescriptors(proto),
43
+ ...instanceDescriptors
44
+ };
45
+ return delete descriptors.constructor, descriptors;
46
+ }
47
+ function get(_, b) {
48
+ return _;
49
+ }
50
+ function simpleStr(arg) {
51
+ return process.env.NODE_ENV === "development" ? typeof arg == "function" ? "fn" : typeof arg == "string" ? `"${arg}"` : arg && (typeof arg != "object" ? arg : Array.isArray(arg) ? "[...]" : "{...}") : arg;
52
+ }
53
+ function getStoreDebugInfo(store) {
54
+ return store[UNWRAP_STORE_INFO] ?? cache.get(getStoreUid(store.constructor, store.props));
55
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var helpers_exports = {};
24
+ __export(helpers_exports, {
25
+ UNWRAP_STORE_INFO: () => UNWRAP_STORE_INFO,
26
+ cache: () => cache,
27
+ get: () => get,
28
+ getStoreDebugInfo: () => getStoreDebugInfo,
29
+ getStoreDescriptors: () => getStoreDescriptors,
30
+ getStoreUid: () => getStoreUid,
31
+ simpleStr: () => simpleStr
32
+ });
33
+ module.exports = __toCommonJS(helpers_exports);
34
+ var import_simple_hash = require("@hanzogui/simple-hash");
35
+ function _type_of(obj) {
36
+ "@swc/helpers - typeof";
37
+
38
+ return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
39
+ }
40
+ function getStoreUid(Constructor, props) {
41
+ return (0, import_simple_hash.simpleHash)(`${Constructor}${props ? typeof props == "string" ? props : JSON.stringify(props) : ""}`, "strict");
42
+ }
43
+ var UNWRAP_STORE_INFO = /* @__PURE__ */Symbol("UNWRAP_STORE_INFO"),
44
+ cache = /* @__PURE__ */new Map();
45
+ function getStoreDescriptors(storeInstance) {
46
+ var proto = Object.getPrototypeOf(storeInstance),
47
+ instanceDescriptors = Object.getOwnPropertyDescriptors(storeInstance),
48
+ protoDescriptors = Object.getOwnPropertyDescriptors(proto),
49
+ descriptors = {
50
+ ...protoDescriptors,
51
+ ...instanceDescriptors
52
+ };
53
+ return delete descriptors.constructor, descriptors;
54
+ }
55
+ function get(_, b) {
56
+ return _;
57
+ }
58
+ function simpleStr(arg) {
59
+ return process.env.NODE_ENV === "development" ? typeof arg == "function" ? "fn" : typeof arg == "string" ? `"${arg}"` : arg && ((typeof arg > "u" ? "undefined" : _type_of(arg)) !== "object" ? arg : Array.isArray(arg) ? "[...]" : "{...}") : arg;
60
+ }
61
+ function getStoreDebugInfo(store) {
62
+ var _store_UNWRAP_STORE_INFO;
63
+ 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));
64
+ }
65
+ //# sourceMappingURL=helpers.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","helpers_exports","__export","UNWRAP_STORE_INFO","cache","get","getStoreDebugInfo","getStoreDescriptors","getStoreUid","simpleStr","module","exports","import_simple_hash","require","_type_of","obj","Symbol","constructor","Constructor","props","simpleHash","JSON","stringify","Map","storeInstance","proto","Object","getPrototypeOf","instanceDescriptors","getOwnPropertyDescriptors","protoDescriptors","descriptors","_","b","arg","process","env","NODE_ENV","Array","isArray","store"],"sources":["../../src/helpers.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,eAAA;AAAAC,QAAA,CAAAD,eAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,KAAA,EAAAA,CAAA,KAAAA,KAAA;EAAAC,GAAA,EAAAA,CAAA,KAAAA,GAAA;EAAAC,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,mBAAA,EAAAA,CAAA,KAAAA,mBAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAf,YAA2B,CAAAK,eAAA;AAIpB,IAAAW,kBAAqB,GAAAC,OAAA,wBAAiD;AAC3E,SAAAC,QAAOA,CAAAC,GAAA;EAAA,uBAEF;;EACH,OACAA,GAAA,WAAAC,MAAA,UAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AAAA;AAEJ,SAAAP,YAAAU,WAAA,EAAAC,KAAA;EAEO,OAAM,IAAAP,kBAAoB,CAAAQ,UAAA,KAAAF,WAAO,GAAAC,KAAA,GAAmB,OAC9CA,KAAQ,eAAAA,KAAI,GAAuBE,IAAA,CAAAC,SAAA,CAAAH,KAAA;AAEzC;AACL,IAAAhB,iBAAc,GAAO,eAAea,MAAA,oBAC9B;EAAAZ,KAAA,GAAsB,eAAO,IAAAmB,GAAA;AAEf,SADKhB,mBAAOA,CAAAiB,aAA0B;EAAK,IAG7DC,KAAG,GAAAC,MAAA,CAAAC,cAAA,CAAAH,aAAA;IAAAI,mBAAA,GAAAF,MAAA,CAAAG,yBAAA,CAAAL,aAAA;IAAAM,gBAAA,GAAAJ,MAAA,CAAAG,yBAAA,CAAAJ,KAAA;IAAAM,WAAA;MACL,GAAAD,gBAAA;MAEA,GAAAF;IAEF;EAEO,OAAS,OAAaG,WAAyD,CAAAd,WAAA,EAAAc,WAAA;AACpF;AACF,SAAA1B,IAAA2B,CAAA,EAAAC,CAAA;EAEO,OAASD,CAAA;AACd;AAcF,SAAAvB,UAAAyB,GAAA;EAGO,OAASC,OAAA,CAAAC,GAAA,CAAAC,QAAkB,KAAY,uBAAAH,GAAA,+BAAAA,GAAA,mBAAAA,GAAA,MAAAA,GAAA,aAAAA,GAAA,uBAAApB,QAAA,CAAAoB,GAAA,kBAAAA,GAAA,GAAAI,KAAA,CAAAC,OAAA,CAAAL,GAAA,yBAAAA,GAAA;AAC5C;AAGF,SAAA5B,kBAAAkC,KAAA","ignoreList":[]}
@@ -0,0 +1,40 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ },
18
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
20
+ value: !0
21
+ }), mod);
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ Store: () => Store,
25
+ UNWRAP_PROXY: () => import_constants.UNWRAP_PROXY,
26
+ configureUseStore: () => import_configureUseStore.configureUseStore
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+ __reExport(index_exports, require("./useStore.cjs"), module.exports);
30
+ var import_configureUseStore = require("./configureUseStore.cjs");
31
+ __reExport(index_exports, require("./interfaces.cjs"), module.exports);
32
+ __reExport(index_exports, require("./observe.cjs"), module.exports);
33
+ var import_constants = require("./constants.cjs");
34
+ __reExport(index_exports, require("./comparators.cjs"), module.exports);
35
+ __reExport(index_exports, require("./decorators.cjs"), module.exports);
36
+ class Store {
37
+ constructor(props) {
38
+ this.props = props;
39
+ }
40
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ },
20
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
22
+ value: !0
23
+ }), mod);
24
+ var index_exports = {};
25
+ __export(index_exports, {
26
+ Store: () => Store,
27
+ UNWRAP_PROXY: () => import_constants.UNWRAP_PROXY,
28
+ configureUseStore: () => import_configureUseStore.configureUseStore
29
+ });
30
+ module.exports = __toCommonJS(index_exports);
31
+ __reExport(index_exports, require("./useStore.native.js"), module.exports);
32
+ var import_configureUseStore = require("./configureUseStore.native.js");
33
+ __reExport(index_exports, require("./interfaces.native.js"), module.exports);
34
+ __reExport(index_exports, require("./observe.native.js"), module.exports);
35
+ var import_constants = require("./constants.native.js");
36
+ __reExport(index_exports, require("./comparators.native.js"), module.exports);
37
+ __reExport(index_exports, require("./decorators.native.js"), module.exports);
38
+ function _class_call_check(instance, Constructor) {
39
+ if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
40
+ }
41
+ function _define_property(obj, key, value) {
42
+ return key in obj ? Object.defineProperty(obj, key, {
43
+ value,
44
+ enumerable: !0,
45
+ configurable: !0,
46
+ writable: !0
47
+ }) : obj[key] = value, obj;
48
+ }
49
+ var Store = function Store2(props) {
50
+ "use strict";
51
+
52
+ _class_call_check(this, Store2), _define_property(this, "props", void 0), this.props = props;
53
+ };
54
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","Store","UNWRAP_PROXY","import_constants","configureUseStore","import_configureUseStore","module","exports","__reExport","require","_class_call_check","instance","Constructor","TypeError"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,KAAA,EAAAA,CAAA,KAAAA,KAAA;EAAAC,YAAA,EAAAA,CAAA,KAAAC,gBAAA,CAAAD,YAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAC,wBAAA,CAAAD;AAAA;AAAAE,MAAA,CAAAC,OAAA,GAAAb,YAAc,CAAAK,aAAA;AACdS,UAAA,CAAAT,aAAA,EAAAU,OAAkC,0BAAAH,MAAA,CAAAC,OAAA;AAClC,IAAAF,wBAAc,GAAAI,OAAA,gCAFd;AAGAD,UAAA,CAAAT,aAAA,EAAcU,OAAA,yBAHd,GAAAH,MAAA,CAAAC,OAAA;AAIAC,UAAA,CAAAT,aAA6B,EAAAU,OAAA,yBAAAH,MAAA,CAAAC,OAAA;AAC7B,IAAAJ,gBAAA,GAAAM,OAAc;AACdD,UAAA,CAAAT,aAAA,EAAcU,OAAA,6BANdH,MAAA,CAAAC,OAAA;AASOC,UAAM,CAAAT,aAAyC,EAAAU,OAAA,4BAAAH,MAAA,CAAAC,OAAA;AAAA,SACpDG,iBAAiCA,CAAAC,QAAA,EAAAC,WAAA;EAAd,MAAAD,QAAA,YAAAC,WAAA,GAAe,UAAAC,SAAA;AACpC","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ };
12
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
13
+ value: !0
14
+ }), mod);
15
+ var interfaces_exports = {};
16
+ module.exports = __toCommonJS(interfaces_exports);