@tamagui/use-store 2.0.0-rc.3 → 2.0.0-rc.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/cjs/index.js +24 -18
  2. package/dist/esm/index.js +8 -12
  3. package/dist/esm/index.js.map +1 -6
  4. package/package.json +6 -9
  5. package/dist/cjs/comparators.js +0 -33
  6. package/dist/cjs/comparators.js.map +0 -6
  7. package/dist/cjs/configureUseStore.js +0 -25
  8. package/dist/cjs/configureUseStore.js.map +0 -6
  9. package/dist/cjs/constants.js +0 -25
  10. package/dist/cjs/constants.js.map +0 -6
  11. package/dist/cjs/decorators.js +0 -25
  12. package/dist/cjs/decorators.js.map +0 -6
  13. package/dist/cjs/helpers.js +0 -50
  14. package/dist/cjs/helpers.js.map +0 -6
  15. package/dist/cjs/interfaces.js +0 -14
  16. package/dist/cjs/interfaces.js.map +0 -6
  17. package/dist/cjs/observe.js +0 -105
  18. package/dist/cjs/observe.js.map +0 -6
  19. package/dist/cjs/useStore.js +0 -353
  20. package/dist/cjs/useStore.js.map +0 -6
  21. package/dist/cjs/useStoreDebug.js +0 -46
  22. package/dist/cjs/useStoreDebug.js.map +0 -6
  23. package/dist/esm/comparators.js +0 -17
  24. package/dist/esm/comparators.js.map +0 -6
  25. package/dist/esm/configureUseStore.js +0 -9
  26. package/dist/esm/configureUseStore.js.map +0 -6
  27. package/dist/esm/constants.js +0 -9
  28. package/dist/esm/constants.js.map +0 -6
  29. package/dist/esm/decorators.js +0 -9
  30. package/dist/esm/decorators.js.map +0 -6
  31. package/dist/esm/helpers.js +0 -34
  32. package/dist/esm/helpers.js.map +0 -6
  33. package/dist/esm/interfaces.js +0 -1
  34. package/dist/esm/interfaces.js.map +0 -6
  35. package/dist/esm/observe.js +0 -84
  36. package/dist/esm/observe.js.map +0 -6
  37. package/dist/esm/useStore.js +0 -340
  38. package/dist/esm/useStore.js.map +0 -6
  39. package/dist/esm/useStoreDebug.js +0 -22
  40. package/dist/esm/useStoreDebug.js.map +0 -6
package/dist/cjs/index.js CHANGED
@@ -3,15 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ },
18
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
20
+ value: !0
21
+ }), mod);
15
22
  var index_exports = {};
16
23
  __export(index_exports, {
17
24
  Store: () => Store,
@@ -19,16 +26,15 @@ __export(index_exports, {
19
26
  configureUseStore: () => import_configureUseStore.configureUseStore
20
27
  });
21
28
  module.exports = __toCommonJS(index_exports);
22
- __reExport(index_exports, require("./useStore"), module.exports);
23
- var import_configureUseStore = require("./configureUseStore");
24
- __reExport(index_exports, require("./interfaces"), module.exports);
25
- __reExport(index_exports, require("./observe"), module.exports);
26
- var import_constants = require("./constants");
27
- __reExport(index_exports, require("./comparators"), module.exports);
28
- __reExport(index_exports, require("./decorators"), module.exports);
29
+ __reExport(index_exports, require("./useStore.cjs"), module.exports);
30
+ var import_configureUseStore = require("./configureUseStore.cjs");
31
+ __reExport(index_exports, require("./interfaces.cjs"), module.exports);
32
+ __reExport(index_exports, require("./observe.cjs"), module.exports);
33
+ var import_constants = require("./constants.cjs");
34
+ __reExport(index_exports, require("./comparators.cjs"), module.exports);
35
+ __reExport(index_exports, require("./decorators.cjs"), module.exports);
29
36
  class Store {
30
37
  constructor(props) {
31
38
  this.props = props;
32
39
  }
33
- }
34
- //# sourceMappingURL=index.js.map
40
+ }
package/dist/esm/index.js CHANGED
@@ -1,18 +1,14 @@
1
- export * from "./useStore";
2
- import { configureUseStore } from "./configureUseStore";
3
- export * from "./interfaces";
4
- export * from "./observe";
5
- import { UNWRAP_PROXY } from "./constants";
6
- export * from "./comparators";
7
- export * from "./decorators";
1
+ export * from "./useStore.mjs";
2
+ import { configureUseStore } from "./configureUseStore.mjs";
3
+ export * from "./interfaces.mjs";
4
+ export * from "./observe.mjs";
5
+ import { UNWRAP_PROXY } from "./constants.mjs";
6
+ export * from "./comparators.mjs";
7
+ export * from "./decorators.mjs";
8
8
  class Store {
9
9
  constructor(props) {
10
10
  this.props = props;
11
11
  }
12
12
  }
13
- export {
14
- Store,
15
- UNWRAP_PROXY,
16
- configureUseStore
17
- };
13
+ export { Store, UNWRAP_PROXY, configureUseStore };
18
14
  //# sourceMappingURL=index.js.map
@@ -1,6 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": "AAAA,cAAc;AACd,SAAS,yBAAyB;AAClC,cAAc;AACd,cAAc;AACd,SAAS,oBAAoB;AAC7B,cAAc;AACd,cAAc;AAGP,MAAM,MAAyC;AAAA,EACpD,YAAmB,OAAc;AAAd;AAAA,EAAe;AACpC;",
5
- "names": []
6
- }
1
+ {"version":3,"names":["configureUseStore","UNWRAP_PROXY","Store","constructor","props"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,SAASA,iBAAA,QAAyB;AAClC,cAAc;AACd,cAAc;AACd,SAASC,YAAA,QAAoB;AAC7B,cAAc;AACd,cAAc;AAGP,MAAMC,KAAA,CAAyC;EACpDC,YAAmBC,KAAA,EAAc;IAAd,KAAAA,KAAA,GAAAA,KAAA;EAAe;AACpC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/use-store",
3
- "version": "2.0.0-rc.3",
3
+ "version": "2.0.0-rc.30",
4
4
  "files": [
5
5
  "src",
6
6
  "types",
@@ -15,15 +15,12 @@
15
15
  "./package.json": "./package.json",
16
16
  ".": {
17
17
  "types": "./src/index.ts",
18
- "react-native": {
19
- "module": "./dist/esm/index.native.js",
20
- "import": "./dist/esm/index.native.js",
21
- "require": "./dist/cjs/index.native.js"
22
- },
18
+ "react-native": "./dist/esm/index.native.js",
19
+ "browser": "./dist/esm/index.mjs",
23
20
  "module": "./dist/esm/index.mjs",
24
21
  "import": "./dist/esm/index.mjs",
25
22
  "require": "./dist/cjs/index.cjs",
26
- "default": "./dist/cjs/index.native.js"
23
+ "default": "./dist/esm/index.mjs"
27
24
  }
28
25
  },
29
26
  "publishConfig": {
@@ -36,10 +33,10 @@
36
33
  "clean:build": "tamagui-build clean:build"
37
34
  },
38
35
  "dependencies": {
39
- "@tamagui/simple-hash": "2.0.0-rc.3"
36
+ "@tamagui/simple-hash": "2.0.0-rc.30"
40
37
  },
41
38
  "devDependencies": {
42
- "@tamagui/build": "2.0.0-rc.3",
39
+ "@tamagui/build": "2.0.0-rc.30",
43
40
  "@testing-library/react": "^16.1.0",
44
41
  "react": ">=19",
45
42
  "vitest": "4.0.4"
@@ -1,33 +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)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var comparators_exports = {};
16
- __export(comparators_exports, {
17
- isEqualSubsetShallow: () => isEqualSubsetShallow
18
- });
19
- module.exports = __toCommonJS(comparators_exports);
20
- const isEqualSubsetShallow = (a, b, opts) => {
21
- if (b == null || a == null) return a === b;
22
- if (typeof a != typeof b) return !1;
23
- if (typeof b == "object") {
24
- for (const key in b) {
25
- const compare = opts?.keyComparators?.[key];
26
- if (compare ? !compare(a[key], b[key]) : b[key] !== a[key])
27
- return !1;
28
- }
29
- return !0;
30
- }
31
- return a === b;
32
- };
33
- //# sourceMappingURL=comparators.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/comparators.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,uBAAuB,CAClC,GACA,GACA,SACG;AACH,MAAI,KAAK,QAAQ,KAAK,KAAM,QAAO,MAAM;AACzC,MAAI,OAAO,KAAM,OAAO,EAAG,QAAO;AAClC,MAAI,OAAO,KAAM,UAAU;AACzB,eAAW,OAAO,GAAG;AACnB,YAAM,UAAU,MAAM,iBAAiB,GAAG;AAC1C,UAAI,UAAU,CAAC,QAAQ,EAAE,GAAG,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG;AACvD,eAAO;AAAA,IAEX;AACA,WAAO;AAAA,EACT;AACA,SAAO,MAAM;AACf;",
5
- "names": []
6
- }
@@ -1,25 +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)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var configureUseStore_exports = {};
16
- __export(configureUseStore_exports, {
17
- configureOpts: () => configureOpts,
18
- configureUseStore: () => configureUseStore
19
- });
20
- module.exports = __toCommonJS(configureUseStore_exports);
21
- let configureOpts = {};
22
- function configureUseStore(opts) {
23
- configureOpts = opts;
24
- }
25
- //# sourceMappingURL=configureUseStore.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/configureUseStore.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAI,gBAAgC,CAAC;AAErC,SAAS,kBAAkB,MAAsB;AACtD,kBAAgB;AAClB;",
5
- "names": []
6
- }
@@ -1,25 +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)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var constants_exports = {};
16
- __export(constants_exports, {
17
- UNWRAP_PROXY: () => UNWRAP_PROXY,
18
- defaultOptions: () => defaultOptions
19
- });
20
- module.exports = __toCommonJS(constants_exports);
21
- const UNWRAP_PROXY = /* @__PURE__ */ Symbol(), defaultOptions = {
22
- once: !1,
23
- selector: void 0
24
- };
25
- //# sourceMappingURL=constants.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/constants.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,eAAe,uBAAO,GAEtB,iBAAiB;AAAA,EAC5B,MAAM;AAAA,EACN,UAAU;AACZ;",
5
- "names": []
6
- }
@@ -1,25 +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)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var decorators_exports = {};
16
- __export(decorators_exports, {
17
- compare: () => compare
18
- });
19
- module.exports = __toCommonJS(decorators_exports);
20
- function compare(comparator) {
21
- return (target, propertyKey) => {
22
- target._comparators = target._comparators || {}, target._comparators[propertyKey] = comparator;
23
- };
24
- }
25
- //# sourceMappingURL=decorators.js.map
@@ -1,6 +0,0 @@
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,eAAkB,OAAO,gBAAmB,CAAC,GACpD,OAAO,aAAgB,WAAW,IAAI;AAAA,EACxC;AACF;",
5
- "names": []
6
- }
@@ -1,50 +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)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var helpers_exports = {};
16
- __export(helpers_exports, {
17
- UNWRAP_STORE_INFO: () => UNWRAP_STORE_INFO,
18
- cache: () => cache,
19
- get: () => get,
20
- getStoreDebugInfo: () => getStoreDebugInfo,
21
- getStoreDescriptors: () => getStoreDescriptors,
22
- getStoreUid: () => getStoreUid,
23
- simpleStr: () => simpleStr
24
- });
25
- module.exports = __toCommonJS(helpers_exports);
26
- var import_simple_hash = require("@tamagui/simple-hash");
27
- function getStoreUid(Constructor, props) {
28
- return (0, import_simple_hash.simpleHash)(
29
- `${Constructor}${props ? typeof props == "string" ? props : JSON.stringify(props) : ""}`,
30
- "strict"
31
- );
32
- }
33
- const UNWRAP_STORE_INFO = /* @__PURE__ */ Symbol("UNWRAP_STORE_INFO"), cache = /* @__PURE__ */ new Map();
34
- function getStoreDescriptors(storeInstance) {
35
- const proto = Object.getPrototypeOf(storeInstance), instanceDescriptors = Object.getOwnPropertyDescriptors(storeInstance), descriptors = {
36
- ...Object.getOwnPropertyDescriptors(proto),
37
- ...instanceDescriptors
38
- };
39
- return delete descriptors.constructor, descriptors;
40
- }
41
- function get(_, b) {
42
- return _;
43
- }
44
- function simpleStr(arg) {
45
- return process.env.NODE_ENV === "development" ? typeof arg == "function" ? "fn" : typeof arg == "string" ? `"${arg}"` : arg && (typeof arg != "object" ? arg : Array.isArray(arg) ? "[...]" : "{...}") : arg;
46
- }
47
- function getStoreDebugInfo(store) {
48
- return store[UNWRAP_STORE_INFO] ?? cache.get(getStoreUid(store.constructor, store.props));
49
- }
50
- //# sourceMappingURL=helpers.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers.tsx"],
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,uBAAO,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
- "names": []
6
- }
@@ -1,14 +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))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- };
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var interfaces_exports = {};
13
- module.exports = __toCommonJS(interfaces_exports);
14
- //# sourceMappingURL=interfaces.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/interfaces.tsx"],
4
- "mappings": ";;;;;;;;;;;AAAA;AAAA;",
5
- "names": []
6
- }
@@ -1,105 +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, __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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var observe_exports = {};
24
- __export(observe_exports, {
25
- observe: () => observe,
26
- useObserve: () => useObserve
27
- });
28
- module.exports = __toCommonJS(observe_exports);
29
- var import_react = __toESM(require("react"), 1), import_comparators = require("./comparators"), import_constants = require("./constants"), import_useStore = require("./useStore");
30
- const logUpdate = process.env.NODE_ENV === "development" ? (fn, stores, last, next) => {
31
- const getStoreLogName = (store) => `${(store[import_constants.UNWRAP_PROXY] ?? store).constructor.name}${store.props?.id ? `:${store.props.id}` : ""}`, storeNames = stores.map(getStoreLogName).join(", "), name = `\u{1F311} \u25B6\uFE0F %c${fn.name} ${storeNames} () ${last} => ${next}`;
32
- console.groupCollapsed(name, "color: tomato;"), console.groupCollapsed("trace >"), console.trace(), console.groupEnd(), console.info(" next", next), console.groupEnd();
33
- } : null;
34
- function observe(fn) {
35
- let prev = getObserverValueAndStoresAccessed(fn), disposeValue = null;
36
- const subscribe = () => {
37
- const stores = [...prev.storeInfos];
38
- return subscribeToStores(stores, () => {
39
- disposeValue?.();
40
- const next = getObserverValueAndStoresAccessed(fn);
41
- if (typeof next.value == "function") {
42
- disposeValue = next.value, process.env.NODE_ENV === "development" && logUpdate(fn, [...next.storeInfos], "(fn)", "(fn)");
43
- return;
44
- }
45
- (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());
46
- });
47
- };
48
- let dispose = subscribe();
49
- return {
50
- dispose: () => {
51
- dispose(), disposeValue?.();
52
- },
53
- getValue: () => prev.value
54
- };
55
- }
56
- function useObserve(fn) {
57
- const [state, setState] = import_react.default.useState(() => getObserverValueAndStoresAccessed(fn));
58
- return import_react.default.useEffect(() => {
59
- let dispose;
60
- const unsub = subscribeToStores([...state.storeInfos], () => {
61
- dispose?.();
62
- const next = getObserverValueAndStoresAccessed(fn), nextStoreInfos = [...next.storeInfos], prevStoreInfos = [...state.storeInfos];
63
- if (typeof next.value == "function") {
64
- process.env.NODE_ENV === "development" && logUpdate(fn, nextStoreInfos, "(fn)", "(fn)"), dispose = next.value;
65
- return;
66
- }
67
- 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));
68
- });
69
- return () => {
70
- unsub(), dispose?.();
71
- };
72
- }, [[...state.storeInfos].map((i) => i.uid).join(",")]), state.value;
73
- }
74
- function getObserverValueAndStoresAccessed(selector) {
75
- const storeInfos = /* @__PURE__ */ new Set(), dispose = (0, import_useStore.trackStoresAccess)((storeInfo) => {
76
- storeInfos.add(storeInfo);
77
- }), value = selector();
78
- return dispose(), {
79
- value,
80
- storeInfos
81
- };
82
- }
83
- function subscribeToStores(storeInfos, onUpdate) {
84
- const disposes = [];
85
- let isUpdating = !1;
86
- const onUpdateDebouncedWithoutTracking = () => {
87
- isUpdating || (isUpdating = !0, queueMicrotask(() => {
88
- try {
89
- for (const storeInfo of storeInfos)
90
- storeInfo.disableTracking = !0;
91
- onUpdate();
92
- } finally {
93
- isUpdating = !1;
94
- for (const storeInfo of storeInfos)
95
- storeInfo.disableTracking = !1;
96
- }
97
- }));
98
- };
99
- for (const storeInfo of storeInfos)
100
- disposes.push(storeInfo.subscribe(onUpdateDebouncedWithoutTracking));
101
- return () => {
102
- disposes.forEach((x) => x());
103
- };
104
- }
105
- //# sourceMappingURL=observe.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/observe.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB,8BAElB,qBAAqC,0BACrC,mBAA6B,wBAE7B,kBAAkC;AAElC,MAAM,YACJ,QAAQ,IAAI,aAAa,gBACrB,CAAC,IAAS,QAAe,MAAW,SAAc;AAChD,QAAM,kBAAkB,CAAC,UAEhB,IADK,MAAM,6BAAY,KAAK,OACrB,YAAY,IAAI,GAAG,MAAM,OAAO,KAAK,IAAI,MAAM,MAAM,EAAE,KAAK,EAAE,IAExE,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,SAAS,GACjB,QAAQ,KAAK,UAAU,IAAI,GAC3B,QAAQ,SAAS;AACnB,IACA;AAEC,SAAS,QAAQ,IAAe;AACrC,MAAI,OAAO,kCAAkC,EAAE,GAC3C,eAAgC;AAEpC,QAAM,YAAY,MAAM;AACtB,UAAM,SAAS,CAAC,GAAG,KAAK,UAAU;AAClC,WAAO,kBAAkB,QAAQ,MAAM;AACrC,qBAAe;AACf,YAAM,OAAO,kCAAkC,EAAE;AAEjD,UAAI,OAAO,KAAK,SAAU,YAAY;AACpC,uBAAe,KAAK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