@tamagui/use-store 1.15.40
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/README.md +91 -0
- package/dist/cjs/Store.js +99 -0
- package/dist/cjs/Store.js.map +6 -0
- package/dist/cjs/comparators.js +45 -0
- package/dist/cjs/comparators.js.map +6 -0
- package/dist/cjs/configureUseStore.js +34 -0
- package/dist/cjs/configureUseStore.js.map +6 -0
- package/dist/cjs/constants.js +35 -0
- package/dist/cjs/constants.js.map +6 -0
- package/dist/cjs/decorators.js +34 -0
- package/dist/cjs/decorators.js.map +6 -0
- package/dist/cjs/fastCompare.js +168 -0
- package/dist/cjs/fastCompare.js.map +6 -0
- package/dist/cjs/helpers.js +101 -0
- package/dist/cjs/helpers.js.map +6 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/interfaces.js +17 -0
- package/dist/cjs/interfaces.js.map +6 -0
- package/dist/cjs/reaction.js +78 -0
- package/dist/cjs/reaction.js.map +6 -0
- package/dist/cjs/selector.js +139 -0
- package/dist/cjs/selector.js.map +6 -0
- package/dist/cjs/useStore.js +534 -0
- package/dist/cjs/useStore.js.map +6 -0
- package/dist/cjs/useStoreDebug.js +73 -0
- package/dist/cjs/useStoreDebug.js.map +6 -0
- package/dist/esm/Store.js +69 -0
- package/dist/esm/Store.js.map +6 -0
- package/dist/esm/Store.mjs +69 -0
- package/dist/esm/Store.mjs.map +6 -0
- package/dist/esm/comparators.js +21 -0
- package/dist/esm/comparators.js.map +6 -0
- package/dist/esm/comparators.mjs +21 -0
- package/dist/esm/comparators.mjs.map +6 -0
- package/dist/esm/configureUseStore.js +9 -0
- package/dist/esm/configureUseStore.js.map +6 -0
- package/dist/esm/configureUseStore.mjs +9 -0
- package/dist/esm/configureUseStore.mjs.map +6 -0
- package/dist/esm/constants.js +10 -0
- package/dist/esm/constants.js.map +6 -0
- package/dist/esm/constants.mjs +10 -0
- package/dist/esm/constants.mjs.map +6 -0
- package/dist/esm/decorators.js +10 -0
- package/dist/esm/decorators.js.map +6 -0
- package/dist/esm/decorators.mjs +10 -0
- package/dist/esm/decorators.mjs.map +6 -0
- package/dist/esm/fastCompare.js +143 -0
- package/dist/esm/fastCompare.js.map +6 -0
- package/dist/esm/fastCompare.mjs +143 -0
- package/dist/esm/fastCompare.mjs.map +6 -0
- package/dist/esm/helpers.js +70 -0
- package/dist/esm/helpers.js.map +6 -0
- package/dist/esm/helpers.mjs +70 -0
- package/dist/esm/helpers.mjs.map +6 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +6 -0
- package/dist/esm/index.mjs +14 -0
- package/dist/esm/index.mjs.map +6 -0
- package/dist/esm/interfaces.js +1 -0
- package/dist/esm/interfaces.js.map +6 -0
- package/dist/esm/interfaces.mjs +1 -0
- package/dist/esm/interfaces.mjs.map +6 -0
- package/dist/esm/reaction.js +53 -0
- package/dist/esm/reaction.js.map +6 -0
- package/dist/esm/reaction.mjs +53 -0
- package/dist/esm/reaction.mjs.map +6 -0
- package/dist/esm/selector.js +114 -0
- package/dist/esm/selector.js.map +6 -0
- package/dist/esm/selector.mjs +114 -0
- package/dist/esm/selector.mjs.map +6 -0
- package/dist/esm/useStore.js +516 -0
- package/dist/esm/useStore.js.map +6 -0
- package/dist/esm/useStore.mjs +516 -0
- package/dist/esm/useStore.mjs.map +6 -0
- package/dist/esm/useStoreDebug.js +35 -0
- package/dist/esm/useStoreDebug.js.map +6 -0
- package/dist/esm/useStoreDebug.mjs +35 -0
- package/dist/esm/useStoreDebug.mjs.map +6 -0
- package/package.json +44 -0
- package/src/Store.tsx +77 -0
- package/src/comparators.tsx +18 -0
- package/src/configureUseStore.tsx +7 -0
- package/src/constants.tsx +6 -0
- package/src/decorators.tsx +8 -0
- package/src/helpers.tsx +87 -0
- package/src/index.ts +9 -0
- package/src/interfaces.tsx +32 -0
- package/src/reaction.tsx +109 -0
- package/src/selector.tsx +129 -0
- package/src/useStore.tsx +705 -0
- package/src/useStoreDebug.tsx +40 -0
- package/types/Store.d.ts +28 -0
- package/types/Store.d.ts.map +1 -0
- 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/fastCompare.d.ts +13 -0
- package/types/fastCompare.d.ts.map +1 -0
- package/types/helpers.d.ts +13 -0
- package/types/helpers.d.ts.map +1 -0
- package/types/index.d.ts +10 -0
- package/types/index.d.ts.map +1 -0
- package/types/interfaces.d.ts +30 -0
- package/types/interfaces.d.ts.map +1 -0
- package/types/reaction.d.ts +4 -0
- package/types/reaction.d.ts.map +1 -0
- package/types/selector.d.ts +3 -0
- package/types/selector.d.ts.map +1 -0
- package/types/useStore.d.ts +18 -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/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @tamagui/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 { Store } from '@tamagui/use-store'
|
|
7
|
+
|
|
8
|
+
class X extends Store {
|
|
9
|
+
y = 0
|
|
10
|
+
|
|
11
|
+
add() {
|
|
12
|
+
this.y += 1
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Can use it a few ways, all these will access *the same* store:
|
|
17
|
+
const useX = createUseStore(X)
|
|
18
|
+
const x = createStoreInstance(X)
|
|
19
|
+
|
|
20
|
+
// all of these will be reactive, so only props you use cause re-renders
|
|
21
|
+
export function ReactComponent() {
|
|
22
|
+
const x0 = useStore(X)
|
|
23
|
+
const x1 = useX()
|
|
24
|
+
const x2 = useGlobalStore(x)
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<div>{x0.y}</div>
|
|
29
|
+
<button action={x0.add}>add</button>
|
|
30
|
+
</>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// if you want a different instance or namespace, pass props, these will also all access the same store:
|
|
35
|
+
export function ReactComponentAlt() {
|
|
36
|
+
const x0 = useStore(X, { id: 100 })
|
|
37
|
+
const x1 = useX({ id: 100 })
|
|
38
|
+
const x2 = useGlobalStore(x, { id: 100 })
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div>{x0.y}</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// finally, you can make selectors with
|
|
46
|
+
export function ReactComponentAlt() {
|
|
47
|
+
const xplusten0 = useStoreSelector(X, { id: 100 }, x => x.y + 10)
|
|
48
|
+
const xplusten1 = useGlobalStoreSelector(X, { id: 100 }, x => x.y + 10)
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div>{xplusten}</div>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
TODO
|
|
59
|
+
|
|
60
|
+
- usePortal
|
|
61
|
+
|
|
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,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Store_exports = {};
|
|
20
|
+
__export(Store_exports, {
|
|
21
|
+
ADD_TRACKER: () => ADD_TRACKER,
|
|
22
|
+
SHOULD_DEBUG: () => SHOULD_DEBUG,
|
|
23
|
+
Store: () => Store,
|
|
24
|
+
TRACK: () => TRACK,
|
|
25
|
+
TRIGGER_UPDATE: () => TRIGGER_UPDATE,
|
|
26
|
+
disableTracking: () => disableTracking,
|
|
27
|
+
setDisableStoreTracking: () => setDisableStoreTracking
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(Store_exports);
|
|
30
|
+
var import_constants = require("./constants");
|
|
31
|
+
var import_useStoreDebug = require("./useStoreDebug");
|
|
32
|
+
const TRIGGER_UPDATE = Symbol();
|
|
33
|
+
const ADD_TRACKER = Symbol();
|
|
34
|
+
const TRACK = Symbol();
|
|
35
|
+
const SHOULD_DEBUG = Symbol();
|
|
36
|
+
const disableTracking = /* @__PURE__ */ new WeakMap();
|
|
37
|
+
const setDisableStoreTracking = (storeInstance, val) => {
|
|
38
|
+
const store = storeInstance[import_constants.UNWRAP_PROXY] ?? storeInstance;
|
|
39
|
+
disableTracking.set(store, val);
|
|
40
|
+
};
|
|
41
|
+
class Store {
|
|
42
|
+
constructor(props) {
|
|
43
|
+
this.props = props;
|
|
44
|
+
this._listeners = /* @__PURE__ */ new Set();
|
|
45
|
+
this._trackers = /* @__PURE__ */ new Set();
|
|
46
|
+
this._version = 0;
|
|
47
|
+
this.subscribe = (onChanged) => {
|
|
48
|
+
this._listeners.add(onChanged);
|
|
49
|
+
return () => {
|
|
50
|
+
this._listeners.delete(onChanged);
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
[TRIGGER_UPDATE]() {
|
|
55
|
+
this._version = (this._version + 1) % Number.MAX_SAFE_INTEGER;
|
|
56
|
+
for (const cb of this._listeners) {
|
|
57
|
+
cb();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
[ADD_TRACKER](tracker) {
|
|
61
|
+
this._trackers.add(tracker);
|
|
62
|
+
return () => {
|
|
63
|
+
this._trackers.delete(tracker);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
[TRACK](key, debug) {
|
|
67
|
+
if (key[0] === "_" || key[0] === "$" || key === "props" || key === "toJSON") {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (debug) {
|
|
71
|
+
console.log("(debug) CHECK TRACKERS FOR", key);
|
|
72
|
+
}
|
|
73
|
+
for (const tracker of this._trackers) {
|
|
74
|
+
if (tracker.isTracking) {
|
|
75
|
+
tracker.tracked.add(key);
|
|
76
|
+
if (debug) {
|
|
77
|
+
console.log("(debug) TRACK", key, tracker);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
[SHOULD_DEBUG]() {
|
|
83
|
+
const info = { storeInstance: this };
|
|
84
|
+
return [...this._trackers].some(
|
|
85
|
+
(tracker) => tracker.component && (0, import_useStoreDebug.shouldDebug)(tracker.component, info)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
ADD_TRACKER,
|
|
92
|
+
SHOULD_DEBUG,
|
|
93
|
+
Store,
|
|
94
|
+
TRACK,
|
|
95
|
+
TRIGGER_UPDATE,
|
|
96
|
+
disableTracking,
|
|
97
|
+
setDisableStoreTracking
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=Store.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Store.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA6B;AAC7B,2BAA4B;AAErB,MAAM,iBAAiB,OAAO;AAC9B,MAAM,cAAc,OAAO;AAC3B,MAAM,QAAQ,OAAO;AACrB,MAAM,eAAe,OAAO;AAY5B,MAAM,kBAAkB,oBAAI,QAAQ;AAEpC,MAAM,0BAA0B,CAAC,eAAoB,QAAiB;AAC3E,QAAM,QAAQ,cAAc,6BAAY,KAAK;AAC7C,kBAAgB,IAAI,OAAO,GAAG;AAChC;AAEO,MAAM,MAAiC;AAAA,EAK5C,YAAmB,OAAc;AAAd;AAJnB,SAAQ,aAAa,oBAAI,IAAc;AACvC,SAAQ,YAAY,oBAAI,IAAkB;AAC1C,oBAAW;AAIX,qBAAY,CAAC,cAAwB;AACnC,WAAK,WAAW,IAAI,SAAS;AAC7B,aAAO,MAAM;AACX,aAAK,WAAW,OAAO,SAAS;AAAA,MAClC;AAAA,IACF;AAAA,EAPkC;AAAA,EASlC,CAAC,cAAc,IAAI;AACjB,SAAK,YAAY,KAAK,WAAW,KAAK,OAAO;AAC7C,eAAW,MAAM,KAAK,YAAY;AAChC,SAAG;AAAA,IACL;AAAA,EACF;AAAA,EAEA,CAAC,WAAW,EAAE,SAAuB;AACnC,SAAK,UAAU,IAAI,OAAO;AAC1B,WAAO,MAAM;AACX,WAAK,UAAU,OAAO,OAAO;AAAA,IAC/B;AAAA,EACF;AAAA,EAEA,CAAC,KAAK,EAAE,KAAa,OAAiB;AACpC,QAAI,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,MAAM,OAAO,QAAQ,WAAW,QAAQ,UAAU;AAC3E;AAAA,IACF;AACA,QAAI,OAAO;AACT,cAAQ,IAAI,8BAA8B,GAAG;AAAA,IAC/C;AACA,eAAW,WAAW,KAAK,WAAW;AACpC,UAAI,QAAQ,YAAY;AACtB,gBAAQ,QAAQ,IAAI,GAAG;AACvB,YAAI,OAAO;AACT,kBAAQ,IAAI,iBAAiB,KAAK,OAAO;AAAA,QAC3C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,CAAC,YAAY,IAAI;AACf,UAAM,OAAO,EAAE,eAAe,KAAK;AACnC,WAAO,CAAC,GAAG,KAAK,SAAS,EAAE;AAAA,MACzB,CAAC,YAAY,QAAQ,iBAAa,kCAAY,QAAQ,WAAW,IAAI;AAAA,IACvE;AAAA,EACF;AACF;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var comparators_exports = {};
|
|
20
|
+
__export(comparators_exports, {
|
|
21
|
+
isEqualSubsetShallow: () => isEqualSubsetShallow
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(comparators_exports);
|
|
24
|
+
const isEqualSubsetShallow = (a, b, opts) => {
|
|
25
|
+
var _a;
|
|
26
|
+
if (b == null || a == null)
|
|
27
|
+
return a === b;
|
|
28
|
+
if (typeof a !== typeof b)
|
|
29
|
+
return false;
|
|
30
|
+
if (typeof b === "object") {
|
|
31
|
+
for (const key in b) {
|
|
32
|
+
const compare = (_a = opts == null ? void 0 : opts.keyComparators) == null ? void 0 : _a[key];
|
|
33
|
+
if (compare ? !compare(a[key], b[key]) : b[key] !== a[key]) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return a === b;
|
|
40
|
+
};
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
isEqualSubsetShallow
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=comparators.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/comparators.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,uBAAuB,CAClC,GACA,GACA,SACG;AAJL;AAKE,MAAI,KAAK,QAAQ,KAAK;AAAM,WAAO,MAAM;AACzC,MAAI,OAAO,MAAM,OAAO;AAAG,WAAO;AAClC,MAAI,OAAO,MAAM,UAAU;AACzB,eAAW,OAAO,GAAG;AACnB,YAAM,WAAU,kCAAM,mBAAN,mBAAuB;AACvC,UAAI,UAAU,CAAC,QAAQ,EAAE,GAAG,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,GAAG;AAC1D,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACA,SAAO,MAAM;AACf;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var configureUseStore_exports = {};
|
|
20
|
+
__export(configureUseStore_exports, {
|
|
21
|
+
configureOpts: () => configureOpts,
|
|
22
|
+
configureUseStore: () => configureUseStore
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(configureUseStore_exports);
|
|
25
|
+
let configureOpts = {};
|
|
26
|
+
function configureUseStore(opts) {
|
|
27
|
+
configureOpts = opts;
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
configureOpts,
|
|
32
|
+
configureUseStore
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=configureUseStore.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
UNWRAP_PROXY: () => UNWRAP_PROXY,
|
|
22
|
+
defaultOptions: () => defaultOptions
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(constants_exports);
|
|
25
|
+
const UNWRAP_PROXY = Symbol();
|
|
26
|
+
const defaultOptions = {
|
|
27
|
+
once: false,
|
|
28
|
+
selector: void 0
|
|
29
|
+
};
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
UNWRAP_PROXY,
|
|
33
|
+
defaultOptions
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var decorators_exports = {};
|
|
20
|
+
__export(decorators_exports, {
|
|
21
|
+
compare: () => compare
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(decorators_exports);
|
|
24
|
+
function compare(comparator) {
|
|
25
|
+
return (target, propertyKey) => {
|
|
26
|
+
target["_comparators"] = target["_comparators"] || {};
|
|
27
|
+
target["_comparators"][propertyKey] = comparator;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
compare
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/decorators.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,QAAQ,YAA0B;AAChD,SAAO,CAAC,QAAa,gBAA6B;AAChD,WAAO,cAAc,IAAI,OAAO,cAAc,KAAK,CAAC;AACpD,WAAO,cAAc,EAAE,WAAW,IAAI;AAAA,EACxC;AACF;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var fastCompare_exports = {};
|
|
20
|
+
__export(fastCompare_exports, {
|
|
21
|
+
EQUALITY_KEY: () => EQUALITY_KEY,
|
|
22
|
+
isEqual: () => isEqual
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(fastCompare_exports);
|
|
25
|
+
const isArray = Array.isArray;
|
|
26
|
+
const keyList = Object.keys;
|
|
27
|
+
const hasProp = Object.prototype.hasOwnProperty;
|
|
28
|
+
const hasElementType = typeof Element !== "undefined";
|
|
29
|
+
const EQUALITY_KEY = Symbol();
|
|
30
|
+
function isEqual(a, b, options) {
|
|
31
|
+
if (process.env.NODE_ENV !== "development") {
|
|
32
|
+
return isEqualInner(a, b, options);
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
return isEqualInner(a, b, options);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
if (err.message && err.message.match(/stack|recursion/i) || err.number === -2146828260) {
|
|
38
|
+
if (process.env.NODE_ENV === "development") {
|
|
39
|
+
console.warn(
|
|
40
|
+
"Warning: @dish/fast-compare does not handle circular references.",
|
|
41
|
+
err.name,
|
|
42
|
+
err.message
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function isEqualInner(a, b, options) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
if (a === b)
|
|
53
|
+
return true;
|
|
54
|
+
const maxDepth = options == null ? void 0 : options.maxDepth;
|
|
55
|
+
if (options && options.maxDepth) {
|
|
56
|
+
options.maxDepth -= 1;
|
|
57
|
+
}
|
|
58
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
59
|
+
if (a[EQUALITY_KEY] && a[EQUALITY_KEY] === b[EQUALITY_KEY])
|
|
60
|
+
return true;
|
|
61
|
+
let arrA = isArray(a), arrB = isArray(b), i, length, key;
|
|
62
|
+
if (arrA && arrB) {
|
|
63
|
+
length = a.length;
|
|
64
|
+
if (length != b.length)
|
|
65
|
+
return false;
|
|
66
|
+
if (length > 200 || b.length > 200) {
|
|
67
|
+
console.warn("comparing large props! ignoring this, may want to fix");
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (maxDepth === 0) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
for (i = length; i-- !== 0; ) {
|
|
74
|
+
if (!isEqualInner(a[i], b[i], options))
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
if (arrA != arrB)
|
|
80
|
+
return false;
|
|
81
|
+
var dateA = a instanceof Date, dateB = b instanceof Date;
|
|
82
|
+
if (dateA != dateB)
|
|
83
|
+
return false;
|
|
84
|
+
if (dateA && dateB)
|
|
85
|
+
return a.getTime() == b.getTime();
|
|
86
|
+
var regexpA = a instanceof RegExp, regexpB = b instanceof RegExp;
|
|
87
|
+
if (regexpA != regexpB)
|
|
88
|
+
return false;
|
|
89
|
+
if (regexpA && regexpB)
|
|
90
|
+
return a.toString() == b.toString();
|
|
91
|
+
let setA = a instanceof Set;
|
|
92
|
+
let setB = b instanceof Set;
|
|
93
|
+
if (setA != setB)
|
|
94
|
+
return false;
|
|
95
|
+
if (setA && setB) {
|
|
96
|
+
if (a.size !== b.size)
|
|
97
|
+
return false;
|
|
98
|
+
if (maxDepth === 0) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
for (let item of a) {
|
|
102
|
+
if (!b.has(item))
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
var keys = keyList(a);
|
|
108
|
+
length = keys.length;
|
|
109
|
+
const log = options && options.log || false;
|
|
110
|
+
const keysB = keyList(b);
|
|
111
|
+
if (length !== keysB.length) {
|
|
112
|
+
if (log)
|
|
113
|
+
console.log("diff keylist", keysB);
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
for (i = length; i-- !== 0; ) {
|
|
117
|
+
if (!hasProp.call(b, keys[i])) {
|
|
118
|
+
if (log)
|
|
119
|
+
console.log("diff no key in", keys[i]);
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (hasElementType && a instanceof Element && b instanceof Element) {
|
|
124
|
+
if (log)
|
|
125
|
+
console.log("diff dom not equal");
|
|
126
|
+
return a === b;
|
|
127
|
+
}
|
|
128
|
+
if (maxDepth === 0) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
for (i = length; i-- !== 0; ) {
|
|
132
|
+
key = keys[i];
|
|
133
|
+
if (options) {
|
|
134
|
+
if ((_a = options.ignoreKeys) == null ? void 0 : _a[key]) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
const compare = (_b = options.keyComparators) == null ? void 0 : _b[key];
|
|
138
|
+
if (compare) {
|
|
139
|
+
if (compare(a[key], b[key])) {
|
|
140
|
+
continue;
|
|
141
|
+
} else {
|
|
142
|
+
if (log)
|
|
143
|
+
console.log("diff simplecomapre", key);
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (key === "_owner" && a.$$typeof) {
|
|
149
|
+
continue;
|
|
150
|
+
} else {
|
|
151
|
+
if (!isEqualInner(a[key], b[key], options)) {
|
|
152
|
+
if (log) {
|
|
153
|
+
console.log("diff", key, a[key], b[key]);
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
return a !== a && b !== b;
|
|
162
|
+
}
|
|
163
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
164
|
+
0 && (module.exports = {
|
|
165
|
+
EQUALITY_KEY,
|
|
166
|
+
isEqual
|
|
167
|
+
});
|
|
168
|
+
//# sourceMappingURL=fastCompare.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/fastCompare.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,UAAU,MAA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Aa,GAAG;AAClB,aAAO;AAAA,IACT;AAEA,SAAK,IAAI,QAAQ,QAAQ,KAAK;AAC5B,YAAM,KAAK,CAAC;AACZ,UAAI,SAAS;AACX,aAAI,aAAQ,eAAR,mBAAqB,MAAM;AAC7B;AAAA,QACF;AACA,cAAM,WAAU,aAAQ,mBAAR,mBAAyB;AACzC,YAAI,SAAS;AACX,cAAI,QAAQ,EAAE,GAAG,GAAG,EAAE,GAAG,CAAC,GAAG;AAC3B;AAAA,UACF,OAAO;AACL,gBAAI;AAAK,sBAAQ,IAAI,sBAAsB,GAAG;AAC9C,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAEA,UAAI,QAAQ,YAAY,EAAE,UAAU;AAKlC;AAAA,MACF,OAAO;AAEL,YAAI,CAAC,aAAa,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,OAAO,GAAG;AAC1C,cAAI,KAAK;AACP,oBAAQ,IAAI,QAAQ,KAAK,EAAE,GAAG,GAAG,EAAE,GAAG,CAAC;AAAA,UACzC;AACA,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,KAAK,MAAM;AAC1B;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var helpers_exports = {};
|
|
20
|
+
__export(helpers_exports, {
|
|
21
|
+
UNWRAP_STORE_INFO: () => UNWRAP_STORE_INFO,
|
|
22
|
+
cache: () => cache,
|
|
23
|
+
default: () => useConstant,
|
|
24
|
+
get: () => get,
|
|
25
|
+
getKey: () => getKey,
|
|
26
|
+
getStoreDebugInfo: () => getStoreDebugInfo,
|
|
27
|
+
getStoreDescriptors: () => getStoreDescriptors,
|
|
28
|
+
getStoreUid: () => getStoreUid,
|
|
29
|
+
simpleStr: () => simpleStr
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(helpers_exports);
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
const wkm = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
const weakKey = (obj, prefix = "") => {
|
|
35
|
+
if (wkm.has(obj))
|
|
36
|
+
return wkm.get(obj);
|
|
37
|
+
const key = `${prefix}-${Math.random()}`;
|
|
38
|
+
wkm.set(obj, key);
|
|
39
|
+
return key;
|
|
40
|
+
};
|
|
41
|
+
function getStoreUid(Constructor, props) {
|
|
42
|
+
const storeName = process.env.NODE_ENV === "development" ? Constructor.name : weakKey(Constructor);
|
|
43
|
+
return `${storeName}${!props ? "" : typeof props === "string" ? props : getKey(props)}`;
|
|
44
|
+
}
|
|
45
|
+
const UNWRAP_STORE_INFO = Symbol("UNWRAP_STORE_INFO");
|
|
46
|
+
const cache = /* @__PURE__ */ new Map();
|
|
47
|
+
function getStoreDescriptors(storeInstance) {
|
|
48
|
+
const proto = Object.getPrototypeOf(storeInstance);
|
|
49
|
+
const instanceDescriptors = Object.getOwnPropertyDescriptors(storeInstance);
|
|
50
|
+
const protoDescriptors = Object.getOwnPropertyDescriptors(proto);
|
|
51
|
+
const descriptors = {
|
|
52
|
+
...protoDescriptors,
|
|
53
|
+
...instanceDescriptors
|
|
54
|
+
};
|
|
55
|
+
delete descriptors.constructor;
|
|
56
|
+
return descriptors;
|
|
57
|
+
}
|
|
58
|
+
function get(_, b) {
|
|
59
|
+
return _;
|
|
60
|
+
}
|
|
61
|
+
function getKey(props) {
|
|
62
|
+
let s = "";
|
|
63
|
+
const sorted = Object.keys(props).sort();
|
|
64
|
+
for (const key of sorted) {
|
|
65
|
+
const v = props[key];
|
|
66
|
+
if (v && typeof v === "object") {
|
|
67
|
+
s += getKey(v);
|
|
68
|
+
} else {
|
|
69
|
+
s += `.${key}:${v}`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return s;
|
|
73
|
+
}
|
|
74
|
+
function useConstant(fn) {
|
|
75
|
+
const ref = (0, import_react.useRef)();
|
|
76
|
+
if (!ref.current) {
|
|
77
|
+
ref.current = { v: fn() };
|
|
78
|
+
}
|
|
79
|
+
return ref.current.v;
|
|
80
|
+
}
|
|
81
|
+
function simpleStr(arg) {
|
|
82
|
+
if (process.env.NODE_ENV === "development") {
|
|
83
|
+
return typeof arg === "function" ? "fn" : typeof arg === "string" ? `"${arg}"` : !arg ? arg : typeof arg !== "object" ? arg : Array.isArray(arg) ? "[...]" : `{...}`;
|
|
84
|
+
}
|
|
85
|
+
return arg;
|
|
86
|
+
}
|
|
87
|
+
function getStoreDebugInfo(store) {
|
|
88
|
+
return store[UNWRAP_STORE_INFO] ?? cache.get(getStoreUid(store.constructor, store.props));
|
|
89
|
+
}
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
UNWRAP_STORE_INFO,
|
|
93
|
+
cache,
|
|
94
|
+
get,
|
|
95
|
+
getKey,
|
|
96
|
+
getStoreDebugInfo,
|
|
97
|
+
getStoreDescriptors,
|
|
98
|
+
getStoreUid,
|
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