@hanzogui/use-store 8.3.1 → 8.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/comparators.js +21 -0
- package/dist/cjs/comparators.js.map +1 -0
- package/dist/cjs/configureUseStore.js +9 -0
- package/dist/cjs/configureUseStore.js.map +1 -0
- package/dist/cjs/constants.js +9 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/decorators.js +10 -0
- package/dist/cjs/decorators.js.map +1 -0
- package/dist/cjs/helpers.js +50 -0
- package/dist/cjs/helpers.js.map +1 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces.js +3 -0
- package/dist/cjs/interfaces.js.map +1 -0
- package/dist/cjs/observe.js +141 -0
- package/dist/cjs/observe.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/useStore.js +574 -0
- package/dist/cjs/useStore.js.map +1 -0
- package/dist/cjs/useStoreDebug.js +41 -0
- package/dist/cjs/useStoreDebug.js.map +1 -0
- package/dist/esm/comparators.js +17 -0
- package/dist/esm/comparators.js.map +1 -0
- package/dist/esm/configureUseStore.js +5 -0
- package/dist/esm/configureUseStore.js.map +1 -0
- package/dist/esm/constants.js +6 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/decorators.js +7 -0
- package/dist/esm/decorators.js.map +1 -0
- package/dist/esm/helpers.js +42 -0
- package/dist/esm/helpers.js.map +1 -0
- package/dist/esm/index.js +13 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces.js +2 -0
- package/dist/esm/interfaces.js.map +1 -0
- package/dist/esm/observe.js +136 -0
- package/dist/esm/observe.js.map +1 -0
- package/dist/esm/useStore.js +556 -0
- package/dist/esm/useStore.js.map +1 -0
- package/dist/esm/useStoreDebug.js +34 -0
- package/dist/esm/useStoreDebug.js.map +1 -0
- package/package.json +23 -18
- package/src/configureUseStore.tsx +1 -1
- package/src/helpers.tsx +1 -1
- package/src/index.ts +7 -7
- package/src/interfaces.tsx +1 -1
- package/src/observe.tsx +4 -4
- package/src/useStore.tsx +6 -6
- package/src/useStoreDebug.tsx +1 -1
- package/types/comparators.d.ts +6 -0
- package/types/comparators.d.ts.map +1 -0
- package/types/configureUseStore.d.ts +4 -0
- package/types/configureUseStore.d.ts.map +1 -0
- package/types/constants.d.ts +6 -0
- package/types/constants.d.ts.map +1 -0
- package/types/decorators.d.ts +3 -0
- package/types/decorators.d.ts.map +1 -0
- package/types/helpers.d.ts +11 -0
- package/types/helpers.d.ts.map +1 -0
- package/types/index.d.ts +12 -0
- package/types/index.d.ts.map +1 -0
- package/types/interfaces.d.ts +43 -0
- package/types/interfaces.d.ts.map +1 -0
- package/types/observe.d.ts +6 -0
- package/types/observe.d.ts.map +1 -0
- package/types/useStore.d.ts +26 -0
- package/types/useStore.d.ts.map +1 -0
- package/types/useStoreDebug.d.ts +7 -0
- package/types/useStoreDebug.d.ts.map +1 -0
- package/dist/cjs/comparators.cjs +0 -41
- package/dist/cjs/comparators.native.js +0 -50
- package/dist/cjs/comparators.native.js.map +0 -1
- package/dist/cjs/configureUseStore.cjs +0 -32
- package/dist/cjs/configureUseStore.native.js +0 -35
- package/dist/cjs/configureUseStore.native.js.map +0 -1
- package/dist/cjs/constants.cjs +0 -33
- package/dist/cjs/constants.native.js +0 -36
- package/dist/cjs/constants.native.js.map +0 -1
- package/dist/cjs/decorators.cjs +0 -33
- package/dist/cjs/decorators.native.js +0 -36
- package/dist/cjs/decorators.native.js.map +0 -1
- package/dist/cjs/helpers.cjs +0 -62
- package/dist/cjs/helpers.native.js +0 -71
- package/dist/cjs/helpers.native.js.map +0 -1
- package/dist/cjs/index.cjs +0 -43
- package/dist/cjs/index.native.js +0 -65
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/cjs/interfaces.cjs +0 -18
- package/dist/cjs/interfaces.native.js +0 -21
- package/dist/cjs/interfaces.native.js.map +0 -1
- package/dist/cjs/observe.cjs +0 -166
- package/dist/cjs/observe.native.js +0 -234
- package/dist/cjs/observe.native.js.map +0 -1
- package/dist/cjs/useStore.cjs +0 -467
- package/dist/cjs/useStore.native.js +0 -608
- package/dist/cjs/useStore.native.js.map +0 -1
- package/dist/cjs/useStoreDebug.cjs +0 -67
- package/dist/cjs/useStoreDebug.native.js +0 -71
- package/dist/cjs/useStoreDebug.native.js.map +0 -1
- package/dist/esm/comparators.mjs +0 -16
- package/dist/esm/comparators.mjs.map +0 -1
- package/dist/esm/comparators.native.js +0 -22
- package/dist/esm/comparators.native.js.map +0 -1
- package/dist/esm/configureUseStore.mjs +0 -6
- package/dist/esm/configureUseStore.mjs.map +0 -1
- package/dist/esm/configureUseStore.native.js +0 -6
- package/dist/esm/configureUseStore.native.js.map +0 -1
- package/dist/esm/constants.mjs +0 -7
- package/dist/esm/constants.mjs.map +0 -1
- package/dist/esm/constants.native.js +0 -7
- package/dist/esm/constants.native.js.map +0 -1
- package/dist/esm/decorators.mjs +0 -8
- package/dist/esm/decorators.mjs.map +0 -1
- package/dist/esm/decorators.native.js +0 -8
- package/dist/esm/decorators.native.js.map +0 -1
- package/dist/esm/helpers.mjs +0 -31
- package/dist/esm/helpers.mjs.map +0 -1
- package/dist/esm/helpers.native.js +0 -37
- package/dist/esm/helpers.native.js.map +0 -1
- package/dist/esm/index.mjs +0 -15
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js +0 -34
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/interfaces.mjs +0 -2
- package/dist/esm/interfaces.mjs.map +0 -1
- package/dist/esm/interfaces.native.js +0 -2
- package/dist/esm/interfaces.native.js.map +0 -1
- package/dist/esm/observe.mjs +0 -129
- package/dist/esm/observe.mjs.map +0 -1
- package/dist/esm/observe.native.js +0 -194
- package/dist/esm/observe.native.js.map +0 -1
- package/dist/esm/useStore.mjs +0 -415
- package/dist/esm/useStore.mjs.map +0 -1
- package/dist/esm/useStore.native.js +0 -553
- package/dist/esm/useStore.native.js.map +0 -1
- package/dist/esm/useStoreDebug.mjs +0 -27
- package/dist/esm/useStoreDebug.mjs.map +0 -1
- package/dist/esm/useStoreDebug.native.js +0 -28
- package/dist/esm/useStoreDebug.native.js.map +0 -1
|
@@ -1,36 +0,0 @@
|
|
|
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: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
25
|
-
var decorators_exports = {};
|
|
26
|
-
__export(decorators_exports, {
|
|
27
|
-
compare: () => compare
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(decorators_exports);
|
|
30
|
-
function compare(comparator) {
|
|
31
|
-
return function (target, propertyKey) {
|
|
32
|
-
target["_comparators"] = target["_comparators"] || {};
|
|
33
|
-
target["_comparators"][propertyKey] = comparator;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=decorators.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","decorators_exports","__export","compare","module","exports","comparator","target","propertyKey"],"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,EAAcC,WAAW;IAChCD,MAAA,CAAO,cAAc,IAAEA,MAAA,eAAe;IACxCA,MAAA,iBAAAC,WAAA,IAAAF,UAAA;EACF","ignoreList":[]}
|
package/dist/cjs/helpers.cjs
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
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: true
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
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 getStoreUid(Constructor, props) {
|
|
36
|
-
return (0, import_simple_hash.simpleHash)(`${Constructor}${!props ? "" : typeof props === "string" ? props : JSON.stringify(props)}`, "strict");
|
|
37
|
-
}
|
|
38
|
-
const UNWRAP_STORE_INFO = /* @__PURE__ */Symbol("UNWRAP_STORE_INFO");
|
|
39
|
-
const cache = /* @__PURE__ */new Map();
|
|
40
|
-
function getStoreDescriptors(storeInstance) {
|
|
41
|
-
const proto = Object.getPrototypeOf(storeInstance);
|
|
42
|
-
const instanceDescriptors = Object.getOwnPropertyDescriptors(storeInstance);
|
|
43
|
-
const protoDescriptors = Object.getOwnPropertyDescriptors(proto);
|
|
44
|
-
const descriptors = {
|
|
45
|
-
...protoDescriptors,
|
|
46
|
-
...instanceDescriptors
|
|
47
|
-
};
|
|
48
|
-
delete descriptors.constructor;
|
|
49
|
-
return descriptors;
|
|
50
|
-
}
|
|
51
|
-
function get(_, b) {
|
|
52
|
-
return _;
|
|
53
|
-
}
|
|
54
|
-
function simpleStr(arg) {
|
|
55
|
-
if (process.env.NODE_ENV === "development") {
|
|
56
|
-
return typeof arg === "function" ? "fn" : typeof arg === "string" ? `"${arg}"` : !arg ? arg : typeof arg !== "object" ? arg : Array.isArray(arg) ? "[...]" : `{...}`;
|
|
57
|
-
}
|
|
58
|
-
return arg;
|
|
59
|
-
}
|
|
60
|
-
function getStoreDebugInfo(store) {
|
|
61
|
-
return store[UNWRAP_STORE_INFO] ?? cache.get(getStoreUid(store.constructor, store.props));
|
|
62
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
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: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
25
|
-
var helpers_exports = {};
|
|
26
|
-
__export(helpers_exports, {
|
|
27
|
-
UNWRAP_STORE_INFO: () => UNWRAP_STORE_INFO,
|
|
28
|
-
cache: () => cache,
|
|
29
|
-
get: () => get,
|
|
30
|
-
getStoreDebugInfo: () => getStoreDebugInfo,
|
|
31
|
-
getStoreDescriptors: () => getStoreDescriptors,
|
|
32
|
-
getStoreUid: () => getStoreUid,
|
|
33
|
-
simpleStr: () => simpleStr
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(helpers_exports);
|
|
36
|
-
var import_simple_hash = require("@hanzogui/simple-hash");
|
|
37
|
-
function _type_of(obj) {
|
|
38
|
-
"@swc/helpers - typeof";
|
|
39
|
-
|
|
40
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
41
|
-
}
|
|
42
|
-
function getStoreUid(Constructor, props) {
|
|
43
|
-
return (0, import_simple_hash.simpleHash)(`${Constructor}${!props ? "" : typeof props === "string" ? props : JSON.stringify(props)}`, "strict");
|
|
44
|
-
}
|
|
45
|
-
var UNWRAP_STORE_INFO = /* @__PURE__ */Symbol("UNWRAP_STORE_INFO");
|
|
46
|
-
var cache = /* @__PURE__ */new Map();
|
|
47
|
-
function getStoreDescriptors(storeInstance) {
|
|
48
|
-
var proto = Object.getPrototypeOf(storeInstance);
|
|
49
|
-
var instanceDescriptors = Object.getOwnPropertyDescriptors(storeInstance);
|
|
50
|
-
var protoDescriptors = Object.getOwnPropertyDescriptors(proto);
|
|
51
|
-
var descriptors = {
|
|
52
|
-
...protoDescriptors,
|
|
53
|
-
...instanceDescriptors
|
|
54
|
-
};
|
|
55
|
-
delete descriptors.constructor;
|
|
56
|
-
return descriptors;
|
|
57
|
-
}
|
|
58
|
-
function get(_, b) {
|
|
59
|
-
return _;
|
|
60
|
-
}
|
|
61
|
-
function simpleStr(arg) {
|
|
62
|
-
if (process.env.NODE_ENV === "development") {
|
|
63
|
-
return typeof arg === "function" ? "fn" : typeof arg === "string" ? `"${arg}"` : !arg ? arg : (typeof arg === "undefined" ? "undefined" : _type_of(arg)) !== "object" ? arg : Array.isArray(arg) ? "[...]" : `{...}`;
|
|
64
|
-
}
|
|
65
|
-
return arg;
|
|
66
|
-
}
|
|
67
|
-
function getStoreDebugInfo(store) {
|
|
68
|
-
var _store_UNWRAP_STORE_INFO;
|
|
69
|
-
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));
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=helpers.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,oBAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AAAA;AAEJ,SAAAP,YAAAU,WAAA,EAAAC,KAAA;EAEO,OAAM,IAAAP,kBAAoB,CAAAQ,UAAA,KAAAF,WAAO,IAAAC,KAAA,GAAmB,YAAAA,KAAA,gBAAAA,KAAA,GAAAE,IAAA,CAAAC,SAAA,CAAAH,KAAA;AACpD;AAEA,IAAAhB,iBAAS,kBAAoBa,MAAoB;AACtD,IAAAZ,KAAM,kBAAe,IAAAmB,GAAA;AACrB,SAAMhB,oBAAAiB,aAA6B;EACnC,IAAAC,KAAM,GAAAC,MAAA,CAAAC,cAA0B,CAAAH,aAAA;EAChC,IAAAI,mBAAoB,GAAAF,MAAA,CAAAG,yBAAA,CAAAL,aAAA;EAAA,IAClBM,gBAAG,GAAAJ,MAAA,CAAAG,yBAAA,CAAAJ,KAAA;EAAA,IACHM,WAAG;IACL,GAAAD,gBAAA;IAEA,GAAAF;EACA;EACF,OAAAG,WAAA,CAAAd,WAAA;EAEO,OAASc,WAAsE;AACpF;AACF,SAAA1B,IAAA2B,CAAA,EAAAC,CAAA;EAEO,OAASD,CAAA;AACd;AACE,SAAAvB,SAAcA,CAAAyB,GAAA;EAWhB,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA;IACA,OAAO,OAAAH,GAAA,gCAAAA,GAAA,oBAAAA,GAAA,OAAAA,GAAA,GAAAA,GAAA,WAAAA,GAAA,iCAAApB,QAAA,CAAAoB,GAAA,kBAAAA,GAAA,GAAAI,KAAA,CAAAC,OAAA,CAAAL,GAAA;EACT;EAGO,OAASA,GAAA;AACd;AAGF,SAAA5B,kBAAAkC,KAAA","ignoreList":[]}
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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: true
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
22
|
-
value: true
|
|
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.cjs"), module.exports);
|
|
32
|
-
var import_configureUseStore = require("./configureUseStore.cjs");
|
|
33
|
-
__reExport(index_exports, require("./interfaces.cjs"), module.exports);
|
|
34
|
-
__reExport(index_exports, require("./observe.cjs"), module.exports);
|
|
35
|
-
var import_constants = require("./constants.cjs");
|
|
36
|
-
__reExport(index_exports, require("./comparators.cjs"), module.exports);
|
|
37
|
-
__reExport(index_exports, require("./decorators.cjs"), module.exports);
|
|
38
|
-
class Store {
|
|
39
|
-
constructor(props) {
|
|
40
|
-
this.props = props;
|
|
41
|
-
}
|
|
42
|
-
props;
|
|
43
|
-
}
|
package/dist/cjs/index.native.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
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: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
23
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
24
|
-
value: true
|
|
25
|
-
}), mod);
|
|
26
|
-
var index_exports = {};
|
|
27
|
-
__export(index_exports, {
|
|
28
|
-
Store: () => Store,
|
|
29
|
-
UNWRAP_PROXY: () => import_constants.UNWRAP_PROXY,
|
|
30
|
-
configureUseStore: () => import_configureUseStore.configureUseStore
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(index_exports);
|
|
33
|
-
__reExport(index_exports, require("./useStore.native.js"), module.exports);
|
|
34
|
-
var import_configureUseStore = require("./configureUseStore.native.js");
|
|
35
|
-
__reExport(index_exports, require("./interfaces.native.js"), module.exports);
|
|
36
|
-
__reExport(index_exports, require("./observe.native.js"), module.exports);
|
|
37
|
-
var import_constants = require("./constants.native.js");
|
|
38
|
-
__reExport(index_exports, require("./comparators.native.js"), module.exports);
|
|
39
|
-
__reExport(index_exports, require("./decorators.native.js"), module.exports);
|
|
40
|
-
function _class_call_check(instance, Constructor) {
|
|
41
|
-
if (!(instance instanceof Constructor)) {
|
|
42
|
-
throw new TypeError("Cannot call a class as a function");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function _define_property(obj, key, value) {
|
|
46
|
-
if (key in obj) {
|
|
47
|
-
Object.defineProperty(obj, key, {
|
|
48
|
-
value,
|
|
49
|
-
enumerable: true,
|
|
50
|
-
configurable: true,
|
|
51
|
-
writable: true
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
obj[key] = value;
|
|
55
|
-
}
|
|
56
|
-
return obj;
|
|
57
|
-
}
|
|
58
|
-
var Store = function Store2(props) {
|
|
59
|
-
"use strict";
|
|
60
|
-
|
|
61
|
-
_class_call_check(this, Store2);
|
|
62
|
-
_define_property(this, "props", void 0);
|
|
63
|
-
this.props = props;
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;IAAe,UAAAC,SAAA;EAAf;AACrB","ignoreList":[]}
|
package/dist/cjs/interfaces.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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") {
|
|
7
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
8
|
-
get: () => from[key],
|
|
9
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
}), mod);
|
|
17
|
-
var interfaces_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(interfaces_exports);
|
|
@@ -1,21 +0,0 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
-
get: () => from[key],
|
|
11
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
}), mod);
|
|
19
|
-
var interfaces_exports = {};
|
|
20
|
-
module.exports = __toCommonJS(interfaces_exports);
|
|
21
|
-
//# sourceMappingURL=interfaces.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","interfaces_exports"],"sources":["../../src/interfaces.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,kBAAA","ignoreList":[]}
|
package/dist/cjs/observe.cjs
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
34
|
-
var observe_exports = {};
|
|
35
|
-
__export(observe_exports, {
|
|
36
|
-
observe: () => observe,
|
|
37
|
-
useObserve: () => useObserve
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(observe_exports);
|
|
40
|
-
var import_react = __toESM(require("react"), 1);
|
|
41
|
-
var import_comparators = require("./comparators.cjs");
|
|
42
|
-
var import_constants = require("./constants.cjs");
|
|
43
|
-
var import_useStore = require("./useStore.cjs");
|
|
44
|
-
const logUpdate = process.env.NODE_ENV === "development" ? (fn, stores, last, next) => {
|
|
45
|
-
const getStoreLogName = store => {
|
|
46
|
-
const str = store[import_constants.UNWRAP_PROXY] ?? store;
|
|
47
|
-
return `${str.constructor.name}${store.props?.id ? `:${store.props.id}` : ""}`;
|
|
48
|
-
};
|
|
49
|
-
const storeNames = stores.map(getStoreLogName).join(", ");
|
|
50
|
-
const name = `\u{1F311} \u25B6\uFE0F %c${fn.name} ${storeNames} () ${last} => ${next}`;
|
|
51
|
-
console.groupCollapsed(name, "color: tomato;");
|
|
52
|
-
console.groupCollapsed("trace >");
|
|
53
|
-
console.trace();
|
|
54
|
-
console.groupEnd();
|
|
55
|
-
console.info(" next", next);
|
|
56
|
-
console.groupEnd();
|
|
57
|
-
} : null;
|
|
58
|
-
function observe(fn) {
|
|
59
|
-
let prev = getObserverValueAndStoresAccessed(fn);
|
|
60
|
-
let disposeValue = null;
|
|
61
|
-
const subscribe = () => {
|
|
62
|
-
const stores = [...prev.storeInfos];
|
|
63
|
-
return subscribeToStores(stores, () => {
|
|
64
|
-
disposeValue?.();
|
|
65
|
-
const next = getObserverValueAndStoresAccessed(fn);
|
|
66
|
-
if (typeof next.value === "function") {
|
|
67
|
-
disposeValue = next.value;
|
|
68
|
-
if (process.env.NODE_ENV === "development") {
|
|
69
|
-
logUpdate(fn, [...next.storeInfos], "(fn)", "(fn)");
|
|
70
|
-
}
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if ((0, import_comparators.isEqualSubsetShallow)(prev.storeInfos, next.storeInfos) && (0, import_comparators.isEqualSubsetShallow)(prev.value, next.value)) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (process.env.NODE_ENV === "development") {
|
|
77
|
-
logUpdate(fn, [...next.storeInfos], prev.value, next.value);
|
|
78
|
-
}
|
|
79
|
-
prev = next;
|
|
80
|
-
dispose();
|
|
81
|
-
dispose = subscribe();
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
let dispose = subscribe();
|
|
85
|
-
return {
|
|
86
|
-
dispose: () => {
|
|
87
|
-
dispose();
|
|
88
|
-
disposeValue?.();
|
|
89
|
-
},
|
|
90
|
-
getValue: () => prev.value
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function useObserve(fn) {
|
|
94
|
-
const [state, setState] = import_react.default.useState(() => {
|
|
95
|
-
return getObserverValueAndStoresAccessed(fn);
|
|
96
|
-
});
|
|
97
|
-
import_react.default.useEffect(() => {
|
|
98
|
-
let dispose;
|
|
99
|
-
const unsub = subscribeToStores([...state.storeInfos], () => {
|
|
100
|
-
dispose?.();
|
|
101
|
-
const next = getObserverValueAndStoresAccessed(fn);
|
|
102
|
-
const nextStoreInfos = [...next.storeInfos];
|
|
103
|
-
const prevStoreInfos = [...state.storeInfos];
|
|
104
|
-
if (typeof next.value === "function") {
|
|
105
|
-
if (process.env.NODE_ENV === "development") {
|
|
106
|
-
logUpdate(fn, nextStoreInfos, "(fn)", "(fn)");
|
|
107
|
-
}
|
|
108
|
-
dispose = next.value;
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
setState(prev => {
|
|
112
|
-
if ((0, import_comparators.isEqualSubsetShallow)(prevStoreInfos, nextStoreInfos) && (0, import_comparators.isEqualSubsetShallow)(prev.value, next.value)) {
|
|
113
|
-
return prev;
|
|
114
|
-
}
|
|
115
|
-
if (process.env.NODE_ENV === "development") {
|
|
116
|
-
logUpdate(fn, nextStoreInfos, prev.value, next.value);
|
|
117
|
-
}
|
|
118
|
-
return next;
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
return () => {
|
|
122
|
-
unsub();
|
|
123
|
-
dispose?.();
|
|
124
|
-
};
|
|
125
|
-
}, [[...state.storeInfos].map(i => i.uid).join(",")]);
|
|
126
|
-
return state.value;
|
|
127
|
-
}
|
|
128
|
-
function getObserverValueAndStoresAccessed(selector) {
|
|
129
|
-
const storeInfos = /* @__PURE__ */new Set();
|
|
130
|
-
const dispose = (0, import_useStore.trackStoresAccess)(storeInfo => {
|
|
131
|
-
storeInfos.add(storeInfo);
|
|
132
|
-
});
|
|
133
|
-
const value = selector();
|
|
134
|
-
dispose();
|
|
135
|
-
return {
|
|
136
|
-
value,
|
|
137
|
-
storeInfos
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function subscribeToStores(storeInfos, onUpdate) {
|
|
141
|
-
const disposes = [];
|
|
142
|
-
let isUpdating = false;
|
|
143
|
-
const onUpdateDebouncedWithoutTracking = () => {
|
|
144
|
-
if (isUpdating) return;
|
|
145
|
-
isUpdating = true;
|
|
146
|
-
queueMicrotask(() => {
|
|
147
|
-
try {
|
|
148
|
-
for (const storeInfo of storeInfos) {
|
|
149
|
-
storeInfo.disableTracking = true;
|
|
150
|
-
}
|
|
151
|
-
onUpdate();
|
|
152
|
-
} finally {
|
|
153
|
-
isUpdating = false;
|
|
154
|
-
for (const storeInfo of storeInfos) {
|
|
155
|
-
storeInfo.disableTracking = false;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
for (const storeInfo of storeInfos) {
|
|
161
|
-
disposes.push(storeInfo.subscribe(onUpdateDebouncedWithoutTracking));
|
|
162
|
-
}
|
|
163
|
-
return () => {
|
|
164
|
-
disposes.forEach(x => x());
|
|
165
|
-
};
|
|
166
|
-
}
|