@tamagui/use-store 1.61.2 → 1.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cjs/comparators.js +12 -18
  2. package/dist/cjs/comparators.js.map +1 -1
  3. package/dist/cjs/comparators.native.js +40 -0
  4. package/dist/cjs/comparators.native.js.map +6 -0
  5. package/dist/cjs/configureUseStore.js +5 -9
  6. package/dist/cjs/configureUseStore.js.map +1 -1
  7. package/dist/cjs/configureUseStore.native.js +31 -0
  8. package/dist/cjs/configureUseStore.native.js.map +6 -0
  9. package/dist/cjs/constants.js +7 -12
  10. package/dist/cjs/constants.js.map +1 -1
  11. package/dist/cjs/constants.native.js +31 -0
  12. package/dist/cjs/constants.native.js.map +6 -0
  13. package/dist/cjs/decorators.js +6 -11
  14. package/dist/cjs/decorators.js.map +1 -1
  15. package/dist/cjs/decorators.native.js +30 -0
  16. package/dist/cjs/decorators.native.js.map +6 -0
  17. package/dist/cjs/helpers.js +13 -29
  18. package/dist/cjs/helpers.js.map +1 -1
  19. package/dist/cjs/helpers.native.js +66 -0
  20. package/dist/cjs/helpers.native.js.map +6 -0
  21. package/dist/cjs/index.js +6 -11
  22. package/dist/cjs/index.js.map +1 -1
  23. package/dist/cjs/index.native.js +46 -0
  24. package/dist/cjs/index.native.js.map +6 -0
  25. package/dist/cjs/interfaces.js +3 -6
  26. package/dist/cjs/interfaces.js.map +1 -1
  27. package/dist/cjs/interfaces.native.js +15 -0
  28. package/dist/cjs/interfaces.native.js.map +6 -0
  29. package/dist/cjs/observe.js +35 -92
  30. package/dist/cjs/observe.js.map +1 -1
  31. package/dist/cjs/observe.native.js +103 -0
  32. package/dist/cjs/observe.native.js.map +6 -0
  33. package/dist/cjs/useStore.js +114 -318
  34. package/dist/cjs/useStore.js.map +2 -2
  35. package/dist/cjs/useStore.native.js +350 -0
  36. package/dist/cjs/useStore.native.js.map +6 -0
  37. package/dist/cjs/useStoreDebug.js +14 -33
  38. package/dist/cjs/useStoreDebug.js.map +1 -1
  39. package/dist/cjs/useStoreDebug.native.js +55 -0
  40. package/dist/cjs/useStoreDebug.native.js.map +6 -0
  41. package/dist/esm/comparators.js +7 -9
  42. package/dist/esm/comparators.js.map +1 -1
  43. package/dist/esm/constants.js +2 -3
  44. package/dist/esm/constants.js.map +1 -1
  45. package/dist/esm/decorators.js +1 -2
  46. package/dist/esm/decorators.js.map +1 -1
  47. package/dist/esm/helpers.js +7 -18
  48. package/dist/esm/helpers.js.map +1 -1
  49. package/dist/esm/observe.js +29 -79
  50. package/dist/esm/observe.js.map +1 -1
  51. package/dist/esm/useStore.js +108 -303
  52. package/dist/esm/useStore.js.map +2 -2
  53. package/dist/esm/useStoreDebug.js +7 -20
  54. package/dist/esm/useStoreDebug.js.map +1 -1
  55. package/package.json +4 -4
@@ -1,30 +1,17 @@
1
1
  import React, { useLayoutEffect } from "react";
2
- const { ReactCurrentOwner } = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
3
- const useCurrentComponent = () => {
4
- return ReactCurrentOwner && ReactCurrentOwner.current && ReactCurrentOwner.current.elementType ? ReactCurrentOwner.current.elementType : {};
5
- };
2
+ const { ReactCurrentOwner } = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, useCurrentComponent = () => ReactCurrentOwner && ReactCurrentOwner.current && ReactCurrentOwner.current.elementType ? ReactCurrentOwner.current.elementType : {};
6
3
  function useDebugStoreComponent(StoreCons) {
7
4
  const cmp = useCurrentComponent();
8
- DebugStores.add(StoreCons);
9
- if (!DebugComponents.has(cmp)) {
10
- DebugComponents.set(cmp, /* @__PURE__ */ new Set());
11
- }
5
+ DebugStores.add(StoreCons), DebugComponents.has(cmp) || DebugComponents.set(cmp, /* @__PURE__ */ new Set());
12
6
  const stores = DebugComponents.get(cmp);
13
- stores.add(StoreCons);
14
- useLayoutEffect(() => {
15
- return () => {
16
- DebugStores.delete(StoreCons);
17
- stores.delete(StoreCons);
18
- };
7
+ stores.add(StoreCons), useLayoutEffect(() => () => {
8
+ DebugStores.delete(StoreCons), stores.delete(StoreCons);
19
9
  }, []);
20
10
  }
21
11
  const shouldDebug = (component, info) => {
22
- var _a, _b;
23
- const StoreCons = (_a = info.storeInstance) == null ? void 0 : _a.constructor;
24
- return (_b = DebugComponents.get(component)) == null ? void 0 : _b.has(StoreCons);
25
- };
26
- const DebugComponents = /* @__PURE__ */ new Map();
27
- const DebugStores = /* @__PURE__ */ new Set();
12
+ const StoreCons = info.storeInstance?.constructor;
13
+ return DebugComponents.get(component)?.has(StoreCons);
14
+ }, DebugComponents = /* @__PURE__ */ new Map(), DebugStores = /* @__PURE__ */ new Set();
28
15
  export {
29
16
  DebugComponents,
30
17
  DebugStores,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/useStoreDebug.tsx"],
4
- "mappings": "AAAA,OAAO,SAAS,uBAAuB;AAIvC,MAAM,EAAE,kBAAkB,IAAK,MAC5B;AACI,MAAM,sBAAsB,MAAM;AACvC,SAAO,qBACL,kBAAkB,WAClB,kBAAkB,QAAQ,cACxB,kBAAkB,QAAQ,cAC1B,CAAC;AACP;AAEO,SAAS,uBAAuB,WAAgB;AACrD,QAAM,MAAM,oBAAoB;AAGhC,cAAY,IAAI,SAAS;AACzB,MAAI,CAAC,gBAAgB,IAAI,GAAG,GAAG;AAC7B,oBAAgB,IAAI,KAAK,oBAAI,IAAI,CAAC;AAAA,EACpC;AACA,QAAM,SAAS,gBAAgB,IAAI,GAAG;AACtC,SAAO,IAAI,SAAS;AAEpB,kBAAgB,MAAM;AACpB,WAAO,MAAM;AACX,kBAAY,OAAO,SAAS;AAC5B,aAAO,OAAO,SAAS;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,CAAC;AACP;AAEO,MAAM,cAAc,CAAC,WAAgB,SAA2C;AAjCvF;AAkCE,QAAM,aAAY,UAAK,kBAAL,mBAAoB;AACtC,UAAO,qBAAgB,IAAI,SAAS,MAA7B,mBAAgC,IAAI;AAC7C;AAEO,MAAM,kBAAkB,oBAAI,IAAmB;AAC/C,MAAM,cAAc,oBAAI,IAAS;",
4
+ "mappings": "AAAA,OAAO,SAAS,uBAAuB;AAIvC,MAAM,EAAE,kBAAkB,IAAK,MAC5B,oDACU,sBAAsB,MAC1B,qBACL,kBAAkB,WAClB,kBAAkB,QAAQ,cACxB,kBAAkB,QAAQ,cAC1B,CAAC;AAGA,SAAS,uBAAuB,WAAgB;AACrD,QAAM,MAAM,oBAAoB;AAGhC,cAAY,IAAI,SAAS,GACpB,gBAAgB,IAAI,GAAG,KAC1B,gBAAgB,IAAI,KAAK,oBAAI,IAAI,CAAC;AAEpC,QAAM,SAAS,gBAAgB,IAAI,GAAG;AACtC,SAAO,IAAI,SAAS,GAEpB,gBAAgB,MACP,MAAM;AACX,gBAAY,OAAO,SAAS,GAC5B,OAAO,OAAO,SAAS;AAAA,EACzB,GACC,CAAC,CAAC;AACP;AAEO,MAAM,cAAc,CAAC,WAAgB,SAA2C;AACrF,QAAM,YAAY,KAAK,eAAe;AACtC,SAAO,gBAAgB,IAAI,SAAS,GAAG,IAAI,SAAS;AACtD,GAEa,kBAAkB,oBAAI,IAAmB,GACzC,cAAc,oBAAI,IAAS;",
5
5
  "names": []
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/use-store",
3
- "version": "1.61.2",
3
+ "version": "1.62.0",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -12,7 +12,7 @@
12
12
  "scripts": {
13
13
  "build": "tamagui-build",
14
14
  "watch": "tamagui-build --watch",
15
- "test": "TAMAGUI_TARGET=web vitest --config ../vite-plugin-internal/src/vite.config.ts --run",
15
+ "test": "vitest --config ../vite-plugin-internal/src/vite.config.ts --run",
16
16
  "lint": "../../node_modules/.bin/biome check src",
17
17
  "lint:fix": "../../node_modules/.bin/biome check --apply src",
18
18
  "clean": "tamagui-build clean",
@@ -27,10 +27,10 @@
27
27
  }
28
28
  },
29
29
  "dependencies": {
30
- "@tamagui/simple-hash": "1.61.2"
30
+ "@tamagui/simple-hash": "1.62.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@tamagui/build": "1.61.2",
33
+ "@tamagui/build": "1.62.0",
34
34
  "@testing-library/react": "^14.0.0",
35
35
  "react": "^18.2.0",
36
36
  "vitest": "^0.34.3"