@tamagui/use-store 1.88.1 → 1.88.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 +1 -6
- package/dist/cjs/comparators.js.map +1 -1
- package/dist/cjs/configureUseStore.js +0 -5
- package/dist/cjs/constants.js +0 -5
- package/dist/cjs/decorators.js +0 -4
- package/dist/cjs/helpers.js +0 -10
- package/dist/cjs/index.js +0 -11
- package/dist/cjs/observe.js +5 -13
- package/dist/cjs/observe.js.map +1 -1
- package/dist/cjs/useStore.js +11 -33
- package/dist/cjs/useStore.js.map +1 -1
- package/dist/cjs/useStore.native.js +1 -1
- package/dist/cjs/useStore.native.js.map +1 -1
- package/dist/cjs/useStoreDebug.js +2 -11
- package/dist/cjs/useStoreDebug.js.map +1 -1
- package/dist/esm/comparators.native.js +25 -3
- package/dist/esm/comparators.native.js.map +1 -1
- package/dist/esm/configureUseStore.native.js +24 -2
- package/dist/esm/configureUseStore.native.js.map +1 -1
- package/dist/esm/constants.native.js +24 -2
- package/dist/esm/constants.native.js.map +1 -1
- package/dist/esm/decorators.native.js +23 -2
- package/dist/esm/decorators.native.js.map +1 -1
- package/dist/esm/helpers.native.js +31 -4
- package/dist/esm/helpers.native.js.map +1 -1
- package/dist/esm/index.native.js +38 -10
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/interfaces.native.js +14 -0
- package/dist/esm/interfaces.native.js.map +2 -2
- package/dist/esm/observe.native.js +38 -16
- package/dist/esm/observe.native.js.map +1 -1
- package/dist/esm/useStore.native.js +68 -40
- package/dist/esm/useStore.native.js.map +1 -1
- package/dist/esm/useStoreDebug.native.js +41 -7
- package/dist/esm/useStoreDebug.native.js.map +2 -2
- package/package.json +3 -3
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
|
|
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: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var helpers_exports = {};
|
|
17
|
+
__export(helpers_exports, {
|
|
18
|
+
UNWRAP_STORE_INFO: () => UNWRAP_STORE_INFO,
|
|
19
|
+
cache: () => cache,
|
|
20
|
+
get: () => get,
|
|
21
|
+
getStoreDebugInfo: () => getStoreDebugInfo,
|
|
22
|
+
getStoreDescriptors: () => getStoreDescriptors,
|
|
23
|
+
getStoreUid: () => getStoreUid,
|
|
24
|
+
simpleStr: () => simpleStr
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(helpers_exports);
|
|
27
|
+
var import_simple_hash = require("@tamagui/simple-hash");
|
|
2
28
|
function getStoreUid(Constructor, props) {
|
|
3
|
-
return simpleHash(
|
|
29
|
+
return (0, import_simple_hash.simpleHash)(
|
|
4
30
|
`${Constructor}${props ? typeof props == "string" ? props : JSON.stringify(props) : ""}`,
|
|
5
31
|
"strict"
|
|
6
32
|
);
|
|
@@ -22,7 +48,8 @@ function simpleStr(arg) {
|
|
|
22
48
|
function getStoreDebugInfo(store) {
|
|
23
49
|
return store[UNWRAP_STORE_INFO] ?? cache.get(getStoreUid(store.constructor, store.props));
|
|
24
50
|
}
|
|
25
|
-
export
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
26
53
|
UNWRAP_STORE_INFO,
|
|
27
54
|
cache,
|
|
28
55
|
get,
|
|
@@ -30,5 +57,5 @@ export {
|
|
|
30
57
|
getStoreDescriptors,
|
|
31
58
|
getStoreUid,
|
|
32
59
|
simpleStr
|
|
33
|
-
};
|
|
60
|
+
});
|
|
34
61
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers.tsx"],
|
|
4
|
-
"mappings": "AAAA,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;AAIpB,SAAS,YAAY,aAAkB,OAA+B;AAC3E,aAAO;AAAA,IACL,GAAG,WAAW,GACX,QAAa,OAAO,SAAU,WAAW,QAAQ,KAAK,UAAU,KAAK,IAA7D,EACX;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,oBAAoB,OAAO,mBAAmB,GAC9C,QAAQ,oBAAI,IAAuB;AAEzC,SAAS,oBAAoB,eAAoB;AACtD,QAAM,QAAQ,OAAO,eAAe,aAAa,GAC3C,sBAAsB,OAAO,0BAA0B,aAAa,GAEpE,cAAc;AAAA,IAClB,GAFuB,OAAO,0BAA0B,KAAK;AAAA,IAG7D,GAAG;AAAA,EACL;AAEA,gBAAO,YAAY,aACZ;AACT;AAEO,SAAS,IAAO,GAAM,GAAyD;AACpF,SAAO;AACT;AAEO,SAAS,UAAU,KAAU;AAClC,SAAI,QAAQ,IAAI,aAAa,gBACpB,OAAO,OAAQ,aAClB,OACA,OAAO,OAAQ,WACb,IAAI,GAAG,MACN,QAEC,OAAO,OAAQ,WACb,MACA,MAAM,QAAQ,GAAG,IACf,UACA,WAEP;AACT;AAGO,SAAS,kBAAkB,OAAY;AAC5C,SACE,MAAM,iBAAiB,KAAK,MAAM,IAAI,YAAY,MAAM,aAAa,MAAM,KAAK,CAAC;AAErF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,18 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
__export(src_exports, {
|
|
18
|
+
Store: () => Store,
|
|
19
|
+
UNWRAP_PROXY: () => import_constants.UNWRAP_PROXY,
|
|
20
|
+
configureUseStore: () => import_configureUseStore.configureUseStore
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(src_exports);
|
|
23
|
+
__reExport(src_exports, require("./useStore"), module.exports);
|
|
24
|
+
var import_configureUseStore = require("./configureUseStore");
|
|
25
|
+
__reExport(src_exports, require("./interfaces"), module.exports);
|
|
26
|
+
__reExport(src_exports, require("./observe"), module.exports);
|
|
27
|
+
var import_constants = require("./constants");
|
|
28
|
+
__reExport(src_exports, require("./comparators"), module.exports);
|
|
29
|
+
__reExport(src_exports, require("./decorators"), module.exports);
|
|
8
30
|
class Store {
|
|
9
31
|
constructor(props) {
|
|
10
32
|
this.props = props;
|
|
11
33
|
}
|
|
12
34
|
}
|
|
13
|
-
export
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
14
37
|
Store,
|
|
15
38
|
UNWRAP_PROXY,
|
|
16
|
-
configureUseStore
|
|
17
|
-
|
|
39
|
+
configureUseStore,
|
|
40
|
+
...require("./useStore"),
|
|
41
|
+
...require("./interfaces"),
|
|
42
|
+
...require("./observe"),
|
|
43
|
+
...require("./comparators"),
|
|
44
|
+
...require("./decorators")
|
|
45
|
+
});
|
|
18
46
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,uBAAd;AACA,+BAAkC;AAClC,wBAAc,yBAFd;AAGA,wBAAc,sBAHd;AAIA,uBAA6B;AAC7B,wBAAc,0BALd;AAMA,wBAAc,yBANd;AASO,MAAM,MAAyC;AAAA,EACpD,YAAmB,OAAc;AAAd;AAAA,EAAe;AACpC;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1 +1,15 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
return to;
|
|
11
|
+
};
|
|
12
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
13
|
+
var interfaces_exports = {};
|
|
14
|
+
module.exports = __toCommonJS(interfaces_exports);
|
|
1
15
|
//# sourceMappingURL=interfaces.js.map
|
|
@@ -1,9 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var observe_exports = {};
|
|
17
|
+
__export(observe_exports, {
|
|
18
|
+
observe: () => observe,
|
|
19
|
+
useObserve: () => useObserve
|
|
20
|
+
});
|
|
21
|
+
module.exports = __toCommonJS(observe_exports);
|
|
22
|
+
var import_react = require("react"), import_comparators = require("./comparators"), import_constants = require("./constants"), import_useStore = require("./useStore");
|
|
5
23
|
const logUpdate = process.env.NODE_ENV === "development" ? (fn, stores, last, next) => {
|
|
6
|
-
const getStoreLogName = (store) =>
|
|
24
|
+
const getStoreLogName = (store) => {
|
|
25
|
+
var _a;
|
|
26
|
+
return `${(store[import_constants.UNWRAP_PROXY] ?? store).constructor.name}${(_a = store.props) != null && _a.id ? `:${store.props.id}` : ""}`;
|
|
27
|
+
}, storeNames = stores.map(getStoreLogName).join(", "), name = `\u{1F311} \u25B6\uFE0F %c${fn.name} ${storeNames} () ${last} => ${next}`;
|
|
7
28
|
console.groupCollapsed(name, "color: tomato;"), console.groupCollapsed("trace >"), console.trace(), console.groupEnd(), console.info(" next", next), console.groupEnd();
|
|
8
29
|
} : null;
|
|
9
30
|
function observe(fn) {
|
|
@@ -11,43 +32,43 @@ function observe(fn) {
|
|
|
11
32
|
const subscribe = () => {
|
|
12
33
|
const stores = [...prev.storeInfos];
|
|
13
34
|
return subscribeToStores(stores, () => {
|
|
14
|
-
disposeValue
|
|
35
|
+
disposeValue == null || disposeValue();
|
|
15
36
|
const next = getObserverValueAndStoresAccessed(fn);
|
|
16
37
|
if (typeof next.value == "function") {
|
|
17
38
|
disposeValue = next.value, process.env.NODE_ENV === "development" && logUpdate(fn, [...next.storeInfos], "(fn)", "(fn)");
|
|
18
39
|
return;
|
|
19
40
|
}
|
|
20
|
-
isEqualSubsetShallow(prev.storeInfos, next.storeInfos) && isEqualSubsetShallow(prev.value, next.value) || (process.env.NODE_ENV === "development" && logUpdate(fn, [...next.storeInfos], prev.value, next.value), prev = next, dispose(), dispose = subscribe());
|
|
41
|
+
(0, import_comparators.isEqualSubsetShallow)(prev.storeInfos, next.storeInfos) && (0, import_comparators.isEqualSubsetShallow)(prev.value, next.value) || (process.env.NODE_ENV === "development" && logUpdate(fn, [...next.storeInfos], prev.value, next.value), prev = next, dispose(), dispose = subscribe());
|
|
21
42
|
});
|
|
22
43
|
};
|
|
23
44
|
let dispose = subscribe();
|
|
24
45
|
return {
|
|
25
46
|
dispose: () => {
|
|
26
|
-
dispose(), disposeValue
|
|
47
|
+
dispose(), disposeValue == null || disposeValue();
|
|
27
48
|
},
|
|
28
49
|
getValue: () => prev.value
|
|
29
50
|
};
|
|
30
51
|
}
|
|
31
52
|
function useObserve(fn) {
|
|
32
|
-
const [state, setState] = useState(() => getObserverValueAndStoresAccessed(fn));
|
|
33
|
-
return useEffect(() => {
|
|
53
|
+
const [state, setState] = (0, import_react.useState)(() => getObserverValueAndStoresAccessed(fn));
|
|
54
|
+
return (0, import_react.useEffect)(() => {
|
|
34
55
|
let dispose;
|
|
35
56
|
const unsub = subscribeToStores([...state.storeInfos], () => {
|
|
36
|
-
dispose
|
|
57
|
+
dispose == null || dispose();
|
|
37
58
|
const next = getObserverValueAndStoresAccessed(fn), nextStoreInfos = [...next.storeInfos], prevStoreInfos = [...state.storeInfos];
|
|
38
59
|
if (typeof next.value == "function") {
|
|
39
60
|
process.env.NODE_ENV === "development" && logUpdate(fn, nextStoreInfos, "(fn)", "(fn)"), dispose = next.value;
|
|
40
61
|
return;
|
|
41
62
|
}
|
|
42
|
-
setState((prev) => isEqualSubsetShallow(prevStoreInfos, nextStoreInfos) && isEqualSubsetShallow(prev.value, next.value) ? prev : (process.env.NODE_ENV === "development" && logUpdate(fn, nextStoreInfos, prev.value, next.value), next));
|
|
63
|
+
setState((prev) => (0, import_comparators.isEqualSubsetShallow)(prevStoreInfos, nextStoreInfos) && (0, import_comparators.isEqualSubsetShallow)(prev.value, next.value) ? prev : (process.env.NODE_ENV === "development" && logUpdate(fn, nextStoreInfos, prev.value, next.value), next));
|
|
43
64
|
});
|
|
44
65
|
return () => {
|
|
45
|
-
unsub(), dispose
|
|
66
|
+
unsub(), dispose == null || dispose();
|
|
46
67
|
};
|
|
47
68
|
}, [[...state.storeInfos].map((i) => i.uid).join(",")]), state.value;
|
|
48
69
|
}
|
|
49
70
|
function getObserverValueAndStoresAccessed(selector) {
|
|
50
|
-
const storeInfos = /* @__PURE__ */ new Set(), dispose = trackStoresAccess((storeInfo) => {
|
|
71
|
+
const storeInfos = /* @__PURE__ */ new Set(), dispose = (0, import_useStore.trackStoresAccess)((storeInfo) => {
|
|
51
72
|
storeInfos.add(storeInfo);
|
|
52
73
|
}), value = selector();
|
|
53
74
|
return dispose(), {
|
|
@@ -77,8 +98,9 @@ function subscribeToStores(storeInfos, onUpdate) {
|
|
|
77
98
|
disposes.forEach((x) => x());
|
|
78
99
|
};
|
|
79
100
|
}
|
|
80
|
-
export
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
81
103
|
observe,
|
|
82
104
|
useObserve
|
|
83
|
-
};
|
|
105
|
+
});
|
|
84
106
|
//# sourceMappingURL=observe.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/observe.tsx"],
|
|
4
|
-
"mappings": "AAAA,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC,kBAEpC,qBAAqC,0BACrC,mBAA6B,wBAE7B,kBAAkC;AAElC,MAAM,YACJ,QAAQ,IAAI,aAAa,gBACrB,CAAC,IAAS,QAAe,MAAW,SAAc;AAChD,QAAM,kBAAkB,CAAC,UAAe;AAVhD;AAYU,WAAO,IADK,MAAM,6BAAY,KAAK,OACrB,YAAY,IAAI,IAAG,WAAM,UAAN,WAAa,KAAK,IAAI,MAAM,MAAM,EAAE,KAAK,EAAE;AAAA,EAC9E,GACM,aAAa,OAAO,IAAI,eAAe,EAAE,KAAK,IAAI,GAClD,OAAO,6BAAY,GAAG,IAAI,IAAI,UAAU,OAAO,IAAI,OAAO,IAAI;AACpE,UAAQ,eAAe,MAAM,gBAAgB,GAC7C,QAAQ,eAAe,SAAS,GAChC,QAAQ,MAAM,GACd,QAAQ,S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|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var useStore_exports = {};
|
|
17
|
+
__export(useStore_exports, {
|
|
18
|
+
allStores: () => allStores,
|
|
19
|
+
createStore: () => createStore,
|
|
20
|
+
createUseStore: () => createUseStore,
|
|
21
|
+
createUseStoreSelector: () => createUseStoreSelector,
|
|
22
|
+
getOrCreateStore: () => getOrCreateStore,
|
|
23
|
+
getStore: () => getStore,
|
|
24
|
+
getStoreInfo: () => getStoreInfo,
|
|
25
|
+
onCreateStore: () => onCreateStore,
|
|
26
|
+
setIsInReaction: () => setIsInReaction,
|
|
27
|
+
trackStoresAccess: () => trackStoresAccess,
|
|
28
|
+
useGlobalStore: () => useGlobalStore,
|
|
29
|
+
useGlobalStoreSelector: () => useGlobalStoreSelector,
|
|
30
|
+
useStore: () => useStore,
|
|
31
|
+
useStoreDebug: () => useStoreDebug,
|
|
32
|
+
useStoreSelector: () => useStoreSelector
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(useStore_exports);
|
|
35
|
+
var import_react = require("react"), import_comparators = require("./comparators"), import_configureUseStore = require("./configureUseStore"), import_constants = require("./constants"), import_helpers = require("./helpers"), import_useStoreDebug = require("./useStoreDebug");
|
|
13
36
|
const idFn = (_) => _;
|
|
14
|
-
function useStore(StoreKlass, props, options = defaultOptions) {
|
|
37
|
+
function useStore(StoreKlass, props, options = import_constants.defaultOptions) {
|
|
15
38
|
const info = getOrCreateStoreInfo(StoreKlass, props, options);
|
|
16
39
|
return useStoreFromInfo(info, options.selector, options);
|
|
17
40
|
}
|
|
@@ -19,16 +42,17 @@ function useStoreDebug(StoreKlass, props) {
|
|
|
19
42
|
return useStore(StoreKlass, props, { debug: !0 });
|
|
20
43
|
}
|
|
21
44
|
function createStore(StoreKlass, props, options) {
|
|
22
|
-
|
|
45
|
+
var _a;
|
|
46
|
+
return (_a = getOrCreateStoreInfo(StoreKlass, props, options)) == null ? void 0 : _a.store;
|
|
23
47
|
}
|
|
24
48
|
function useGlobalStore(instance, debug) {
|
|
25
|
-
const store = instance[UNWRAP_PROXY], uid = getStoreUid(store.constructor, store.props), info = cache.get(uid);
|
|
49
|
+
const store = instance[import_constants.UNWRAP_PROXY], uid = (0, import_helpers.getStoreUid)(store.constructor, store.props), info = import_helpers.cache.get(uid);
|
|
26
50
|
if (!info)
|
|
27
51
|
throw new Error("This store not created using createStore()");
|
|
28
52
|
return useStoreFromInfo(info, void 0, { debug });
|
|
29
53
|
}
|
|
30
54
|
function useGlobalStoreSelector(instance, selector, debug) {
|
|
31
|
-
const store = instance[UNWRAP_PROXY], uid = getStoreUid(store.constructor, store.props), info = cache.get(uid);
|
|
55
|
+
const store = instance[import_constants.UNWRAP_PROXY], uid = (0, import_helpers.getStoreUid)(store.constructor, store.props), info = import_helpers.cache.get(uid);
|
|
32
56
|
if (!info)
|
|
33
57
|
throw new Error("This store not created using createStore()");
|
|
34
58
|
return useStoreFromInfo(info, selector, { debug });
|
|
@@ -49,12 +73,14 @@ function trackStoresAccess(cb) {
|
|
|
49
73
|
};
|
|
50
74
|
}
|
|
51
75
|
function getStore(StoreKlass, props) {
|
|
52
|
-
|
|
76
|
+
var _a;
|
|
77
|
+
return (_a = getStoreInfo(StoreKlass, props)) == null ? void 0 : _a.store;
|
|
53
78
|
}
|
|
54
79
|
function getOrCreateStore(StoreKlass, props) {
|
|
55
|
-
|
|
80
|
+
var _a;
|
|
81
|
+
return (_a = getOrCreateStoreInfo(StoreKlass, props, {
|
|
56
82
|
refuseCreation: !1
|
|
57
|
-
})
|
|
83
|
+
})) == null ? void 0 : _a.store;
|
|
58
84
|
}
|
|
59
85
|
function getStoreInfo(StoreKlass, props) {
|
|
60
86
|
return getOrCreateStoreInfo(StoreKlass, props, {
|
|
@@ -68,16 +94,17 @@ function onCreateStore(cb) {
|
|
|
68
94
|
};
|
|
69
95
|
}
|
|
70
96
|
function getOrCreateStoreInfo(StoreKlass, props, options, propsKeyCalculated) {
|
|
97
|
+
var _a;
|
|
71
98
|
if (!StoreKlass)
|
|
72
99
|
return null;
|
|
73
|
-
const uid = getStoreUid(StoreKlass, propsKeyCalculated ?? props);
|
|
74
|
-
if (!options
|
|
75
|
-
return cache.get(uid);
|
|
76
|
-
if (options
|
|
100
|
+
const uid = (0, import_helpers.getStoreUid)(StoreKlass, propsKeyCalculated ?? props);
|
|
101
|
+
if (!(options != null && options.avoidCache) && import_helpers.cache.has(uid))
|
|
102
|
+
return import_helpers.cache.get(uid);
|
|
103
|
+
if (options != null && options.refuseCreation)
|
|
77
104
|
throw new Error(`No store exists (${StoreKlass.name}) with props: ${props}`);
|
|
78
105
|
const storeInstance = new StoreKlass(props);
|
|
79
106
|
storeInstance.props = props;
|
|
80
|
-
const getters = {}, actions = {}, stateKeys = /* @__PURE__ */ new Set(), descriptors = getStoreDescriptors(storeInstance);
|
|
107
|
+
const getters = {}, actions = {}, stateKeys = /* @__PURE__ */ new Set(), descriptors = (0, import_helpers.getStoreDescriptors)(storeInstance);
|
|
81
108
|
for (const key in descriptors) {
|
|
82
109
|
const descriptor = descriptors[key];
|
|
83
110
|
typeof descriptor.value == "function" ? actions[key] = descriptor.value : typeof descriptor.get == "function" ? getters[key] = descriptor.get : key !== "props" && key[0] !== "_" && stateKeys.add(key);
|
|
@@ -90,7 +117,7 @@ function getOrCreateStoreInfo(StoreKlass, props, options, propsKeyCalculated) {
|
|
|
90
117
|
stateKeys,
|
|
91
118
|
props,
|
|
92
119
|
actions,
|
|
93
|
-
debug: options
|
|
120
|
+
debug: options == null ? void 0 : options.debug,
|
|
94
121
|
disableTracking: !1,
|
|
95
122
|
gettersState: {
|
|
96
123
|
getCache: /* @__PURE__ */ new Map(),
|
|
@@ -113,12 +140,12 @@ function getOrCreateStoreInfo(StoreKlass, props, options, propsKeyCalculated) {
|
|
|
113
140
|
// we assign store right after and proxiedStore never accesses it until later on
|
|
114
141
|
storeInfo
|
|
115
142
|
);
|
|
116
|
-
process.env.NODE_ENV === "development" && (allStores[StoreKlass.name + uid] = store), store.mount
|
|
143
|
+
process.env.NODE_ENV === "development" && (allStores[StoreKlass.name + uid] = store), (_a = store.mount) == null || _a.call(store), storeInfo.store = store;
|
|
117
144
|
const result = storeInfo;
|
|
118
|
-
return cache.set(uid, result), onCreateListeners.forEach((cb) => cb(result)), result;
|
|
145
|
+
return import_helpers.cache.set(uid, result), onCreateListeners.forEach((cb) => cb(result)), result;
|
|
119
146
|
}
|
|
120
147
|
const allStores = {};
|
|
121
|
-
process.env.NODE_ENV === "development" && (globalThis.Store
|
|
148
|
+
process.env.NODE_ENV === "development" && (globalThis.Store || (globalThis.Store = allStores));
|
|
122
149
|
const emptyObj = {}, selectKeys = (obj, keys) => {
|
|
123
150
|
if (!keys.length)
|
|
124
151
|
return emptyObj;
|
|
@@ -132,14 +159,14 @@ const setIsInReaction = (val) => {
|
|
|
132
159
|
isInReaction = val;
|
|
133
160
|
};
|
|
134
161
|
function useStoreFromInfo(info, userSelector, options) {
|
|
135
|
-
const store = info
|
|
162
|
+
const store = info == null ? void 0 : info.store, internal = (0, import_react.useRef)(), component = (0, import_useStoreDebug.useCurrentComponent)();
|
|
136
163
|
internal.current || (internal.current = {
|
|
137
164
|
component,
|
|
138
165
|
tracked: /* @__PURE__ */ new Set(),
|
|
139
166
|
last: null,
|
|
140
167
|
lastKeys: null
|
|
141
168
|
});
|
|
142
|
-
const curInternal = internal.current, shouldPrintDebug = options
|
|
169
|
+
const curInternal = internal.current, shouldPrintDebug = options == null ? void 0 : options.debug, getSnapshot = (0, import_react.useCallback)(() => {
|
|
143
170
|
if (!info || !store)
|
|
144
171
|
return;
|
|
145
172
|
const curInternal2 = internal.current, isTracking = curInternal2.tracked.size, keys = [...isTracking ? curInternal2.tracked : info.stateKeys], nextKeys = `${info.version}${keys.join("")}${userSelector || ""}`, lastKeys = curInternal2.lastKeys;
|
|
@@ -150,7 +177,7 @@ function useStoreFromInfo(info, userSelector, options) {
|
|
|
150
177
|
info.disableTracking = !0;
|
|
151
178
|
const last = curInternal2.last;
|
|
152
179
|
userSelector ? snap = userSelector(store) : snap = selectKeys(store, keys), info.disableTracking = !1;
|
|
153
|
-
const isUnchanged = !userSelector && !isTracking && last || typeof last < "u" && isEqualSubsetShallow(last, snap, {
|
|
180
|
+
const isUnchanged = !userSelector && !isTracking && last || typeof last < "u" && (0, import_comparators.isEqualSubsetShallow)(last, snap, {
|
|
154
181
|
keyComparators: info.keyComparators
|
|
155
182
|
});
|
|
156
183
|
return shouldPrintDebug && console.info("\u{1F311} getSnapshot", {
|
|
@@ -166,7 +193,7 @@ function useStoreFromInfo(info, userSelector, options) {
|
|
|
166
193
|
nextKeys,
|
|
167
194
|
lastKeys
|
|
168
195
|
}), isUnchanged ? last : (curInternal2.last = snap, snap);
|
|
169
|
-
}, [store]), state = useSyncExternalStore(info
|
|
196
|
+
}, [store]), state = (0, import_react.useSyncExternalStore)((info == null ? void 0 : info.subscribe) || idFn, getSnapshot, getSnapshot);
|
|
170
197
|
return !info || !store || !state || userSelector ? state : new Proxy(store, {
|
|
171
198
|
get(target, key) {
|
|
172
199
|
const curVal = Reflect.get(target, key);
|
|
@@ -180,7 +207,7 @@ function useStoreFromInfo(info, userSelector, options) {
|
|
|
180
207
|
let setters = /* @__PURE__ */ new Set();
|
|
181
208
|
const logStack = /* @__PURE__ */ new Set();
|
|
182
209
|
function createProxiedStore(storeInfo) {
|
|
183
|
-
const { actions, storeInstance, getters, gettersState } = storeInfo, { getCache, curGetKeys, depsToGetter } = gettersState, constr = storeInstance.constructor, shouldDebug2 = storeInfo.debug ?? DebugStores.has(constr);
|
|
210
|
+
const { actions, storeInstance, getters, gettersState } = storeInfo, { getCache, curGetKeys, depsToGetter } = gettersState, constr = storeInstance.constructor, shouldDebug2 = storeInfo.debug ?? import_useStoreDebug.DebugStores.has(constr);
|
|
184
211
|
let didSet = !1;
|
|
185
212
|
const wrappedActions = {};
|
|
186
213
|
for (const key in actions) {
|
|
@@ -205,7 +232,7 @@ function createProxiedStore(storeInfo) {
|
|
|
205
232
|
wrappedActions[key] = new Proxy(ogAction, {
|
|
206
233
|
apply(target, thisArg, args) {
|
|
207
234
|
const isDebugging = shouldDebug2 || storeInfo.debug;
|
|
208
|
-
if (!(process.env.LOG_LEVEL !== "0" && (isDebugging || configureOpts.logLevel !== "error")))
|
|
235
|
+
if (!(process.env.LOG_LEVEL !== "0" && (isDebugging || import_configureUseStore.configureOpts.logLevel !== "error")))
|
|
209
236
|
return Reflect.apply(target, thisArg, args);
|
|
210
237
|
setters = /* @__PURE__ */ new Set();
|
|
211
238
|
const curSetters = setters, isTopLevelLogger = logStack.size == 0, logs = /* @__PURE__ */ new Set();
|
|
@@ -218,7 +245,7 @@ function createProxiedStore(storeInfo) {
|
|
|
218
245
|
throw console.error("Error", err), err;
|
|
219
246
|
} finally {
|
|
220
247
|
logStack.add("end");
|
|
221
|
-
const name = constr.name, color = strColor2(name), simpleArgs = args.map(simpleStr);
|
|
248
|
+
const name = constr.name, color = strColor2(name), simpleArgs = args.map(import_helpers.simpleStr);
|
|
222
249
|
if (logs.add([
|
|
223
250
|
`%c \u{1F311} ${id} ${name.padStart(
|
|
224
251
|
isTopLevelLogger ? 8 : 4
|
|
@@ -266,9 +293,9 @@ function createProxiedStore(storeInfo) {
|
|
|
266
293
|
return wrappedActions[key];
|
|
267
294
|
if (key in passThroughKeys)
|
|
268
295
|
return Reflect.get(storeInstance, key);
|
|
269
|
-
if (key === UNWRAP_PROXY)
|
|
296
|
+
if (key === import_constants.UNWRAP_PROXY)
|
|
270
297
|
return storeInstance;
|
|
271
|
-
if (key === UNWRAP_STORE_INFO)
|
|
298
|
+
if (key === import_helpers.UNWRAP_STORE_INFO)
|
|
272
299
|
return storeInfo;
|
|
273
300
|
if (storeAccessTrackers.size && storeAccessTrackers.forEach((cb) => cb(storeInfo)), typeof key != "string")
|
|
274
301
|
return Reflect.get(storeInstance, key);
|
|
@@ -315,10 +342,11 @@ const passThroughKeys = {
|
|
|
315
342
|
function getShouldDebug(storeInfo) {
|
|
316
343
|
const info = { storeInstance: storeInfo.store };
|
|
317
344
|
return [...storeInfo.trackers].some(
|
|
318
|
-
(tracker) => tracker.component && shouldDebug(tracker.component, info)
|
|
345
|
+
(tracker) => tracker.component && (0, import_useStoreDebug.shouldDebug)(tracker.component, info)
|
|
319
346
|
);
|
|
320
347
|
}
|
|
321
|
-
export
|
|
348
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
349
|
+
0 && (module.exports = {
|
|
322
350
|
allStores,
|
|
323
351
|
createStore,
|
|
324
352
|
createUseStore,
|
|
@@ -334,5 +362,5 @@ export {
|
|
|
334
362
|
useStore,
|
|
335
363
|
useStoreDebug,
|
|
336
364
|
useStoreSelector
|
|
337
|
-
};
|
|
365
|
+
});
|
|
338
366
|
//# sourceMappingURL=useStore.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useStore.tsx"],
|
|
4
|
-
"mappings": "AAAA
|
|
4
|
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
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
+
mod
|
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
+
var useStoreDebug_exports = {};
|
|
25
|
+
__export(useStoreDebug_exports, {
|
|
26
|
+
DebugComponents: () => DebugComponents,
|
|
27
|
+
DebugStores: () => DebugStores,
|
|
28
|
+
shouldDebug: () => shouldDebug,
|
|
29
|
+
useCurrentComponent: () => useCurrentComponent,
|
|
30
|
+
useDebugStoreComponent: () => useDebugStoreComponent
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(useStoreDebug_exports);
|
|
33
|
+
var import_react = __toESM(require("react"));
|
|
34
|
+
const { ReactCurrentOwner } = import_react.default.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, useCurrentComponent = () => ReactCurrentOwner && ReactCurrentOwner.current && ReactCurrentOwner.current.elementType ? ReactCurrentOwner.current.elementType : {};
|
|
3
35
|
function useDebugStoreComponent(StoreCons) {
|
|
4
36
|
const cmp = useCurrentComponent();
|
|
5
37
|
DebugStores.add(StoreCons), DebugComponents.has(cmp) || DebugComponents.set(cmp, /* @__PURE__ */ new Set());
|
|
6
38
|
const stores = DebugComponents.get(cmp);
|
|
7
|
-
stores.add(StoreCons), useLayoutEffect(() => () => {
|
|
39
|
+
stores.add(StoreCons), (0, import_react.useLayoutEffect)(() => () => {
|
|
8
40
|
DebugStores.delete(StoreCons), stores.delete(StoreCons);
|
|
9
41
|
}, []);
|
|
10
42
|
}
|
|
11
43
|
const shouldDebug = (component, info) => {
|
|
12
|
-
|
|
13
|
-
|
|
44
|
+
var _a, _b;
|
|
45
|
+
const StoreCons = (_a = info.storeInstance) == null ? void 0 : _a.constructor;
|
|
46
|
+
return (_b = DebugComponents.get(component)) == null ? void 0 : _b.has(StoreCons);
|
|
14
47
|
}, DebugComponents = /* @__PURE__ */ new Map(), DebugStores = /* @__PURE__ */ new Set();
|
|
15
|
-
export
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
16
50
|
DebugComponents,
|
|
17
51
|
DebugStores,
|
|
18
52
|
shouldDebug,
|
|
19
53
|
useCurrentComponent,
|
|
20
54
|
useDebugStoreComponent
|
|
21
|
-
};
|
|
55
|
+
});
|
|
22
56
|
//# sourceMappingURL=useStoreDebug.js.map
|