@depup/jotai 2.18.0-depup.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 (215) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/babel/plugin-debug-label.d.ts +5 -0
  4. package/babel/plugin-debug-label.js +54 -0
  5. package/babel/plugin-react-refresh.d.ts +5 -0
  6. package/babel/plugin-react-refresh.js +72 -0
  7. package/babel/preset.d.ts +6 -0
  8. package/babel/preset.js +110 -0
  9. package/babel/utils.d.ts +5 -0
  10. package/benchmarks/simple-read.d.ts +2 -0
  11. package/benchmarks/simple-write.d.ts +2 -0
  12. package/benchmarks/subscribe-write.d.ts +2 -0
  13. package/changes.json +5 -0
  14. package/esm/babel/plugin-debug-label.d.mts +5 -0
  15. package/esm/babel/plugin-debug-label.mjs +103 -0
  16. package/esm/babel/plugin-react-refresh.d.mts +5 -0
  17. package/esm/babel/plugin-react-refresh.mjs +121 -0
  18. package/esm/babel/preset.d.mts +6 -0
  19. package/esm/babel/preset.mjs +179 -0
  20. package/esm/babel/utils.d.mts +5 -0
  21. package/esm/index.d.mts +2 -0
  22. package/esm/index.mjs +2 -0
  23. package/esm/react/Provider.d.mts +16 -0
  24. package/esm/react/useAtom.d.mts +13 -0
  25. package/esm/react/useAtomValue.d.mts +9 -0
  26. package/esm/react/useSetAtom.d.mts +7 -0
  27. package/esm/react/utils/useAtomCallback.d.mts +5 -0
  28. package/esm/react/utils/useHydrateAtoms.d.mts +14 -0
  29. package/esm/react/utils/useReducerAtom.d.mts +14 -0
  30. package/esm/react/utils/useResetAtom.d.mts +6 -0
  31. package/esm/react/utils.d.mts +4 -0
  32. package/esm/react/utils.mjs +57 -0
  33. package/esm/react.d.mts +4 -0
  34. package/esm/react.mjs +182 -0
  35. package/esm/utils.d.mts +2 -0
  36. package/esm/utils.mjs +2 -0
  37. package/esm/vanilla/atom.d.mts +47 -0
  38. package/esm/vanilla/internals.d.mts +164 -0
  39. package/esm/vanilla/internals.mjs +715 -0
  40. package/esm/vanilla/store.d.mts +5 -0
  41. package/esm/vanilla/typeUtils.d.mts +7 -0
  42. package/esm/vanilla/utils/atomFamily.d.mts +55 -0
  43. package/esm/vanilla/utils/atomWithDefault.d.mts +6 -0
  44. package/esm/vanilla/utils/atomWithLazy.d.mts +2 -0
  45. package/esm/vanilla/utils/atomWithObservable.d.mts +32 -0
  46. package/esm/vanilla/utils/atomWithReducer.d.mts +3 -0
  47. package/esm/vanilla/utils/atomWithRefresh.d.mts +6 -0
  48. package/esm/vanilla/utils/atomWithReset.d.mts +8 -0
  49. package/esm/vanilla/utils/atomWithStorage.d.mts +50 -0
  50. package/esm/vanilla/utils/constants.d.mts +1 -0
  51. package/esm/vanilla/utils/freezeAtom.d.mts +6 -0
  52. package/esm/vanilla/utils/loadable.d.mts +33 -0
  53. package/esm/vanilla/utils/selectAtom.d.mts +2 -0
  54. package/esm/vanilla/utils/splitAtom.d.mts +16 -0
  55. package/esm/vanilla/utils/unwrap.d.mts +5 -0
  56. package/esm/vanilla/utils.d.mts +14 -0
  57. package/esm/vanilla/utils.mjs +736 -0
  58. package/esm/vanilla.d.mts +4 -0
  59. package/esm/vanilla.mjs +59 -0
  60. package/index.d.ts +2 -0
  61. package/index.js +19 -0
  62. package/package.json +125 -0
  63. package/react/Provider.d.ts +16 -0
  64. package/react/useAtom.d.ts +13 -0
  65. package/react/useAtomValue.d.ts +9 -0
  66. package/react/useSetAtom.d.ts +7 -0
  67. package/react/utils/useAtomCallback.d.ts +5 -0
  68. package/react/utils/useHydrateAtoms.d.ts +14 -0
  69. package/react/utils/useReducerAtom.d.ts +14 -0
  70. package/react/utils/useResetAtom.d.ts +6 -0
  71. package/react/utils.d.ts +4 -0
  72. package/react/utils.js +100 -0
  73. package/react.d.ts +4 -0
  74. package/react.js +182 -0
  75. package/system/babel/plugin-debug-label.development.js +113 -0
  76. package/system/babel/plugin-debug-label.production.js +4 -0
  77. package/system/babel/plugin-react-refresh.development.js +131 -0
  78. package/system/babel/plugin-react-refresh.production.js +11 -0
  79. package/system/babel/preset.development.js +189 -0
  80. package/system/babel/preset.production.js +14 -0
  81. package/system/index.development.js +27 -0
  82. package/system/index.production.js +1 -0
  83. package/system/react/utils.development.js +79 -0
  84. package/system/react/utils.production.js +2 -0
  85. package/system/react.development.js +210 -0
  86. package/system/react.production.js +2 -0
  87. package/system/utils.development.js +27 -0
  88. package/system/utils.production.js +1 -0
  89. package/system/vanilla/internals.development.js +735 -0
  90. package/system/vanilla/internals.production.js +1 -0
  91. package/system/vanilla/utils.development.js +764 -0
  92. package/system/vanilla/utils.production.js +1 -0
  93. package/system/vanilla.development.js +75 -0
  94. package/system/vanilla.production.js +1 -0
  95. package/ts3.8/babel/plugin-debug-label.d.ts +6 -0
  96. package/ts3.8/babel/plugin-react-refresh.d.ts +6 -0
  97. package/ts3.8/babel/preset.d.ts +7 -0
  98. package/ts3.8/babel/utils.d.ts +6 -0
  99. package/ts3.8/benchmarks/simple-read.d.ts +3 -0
  100. package/ts3.8/benchmarks/simple-write.d.ts +3 -0
  101. package/ts3.8/benchmarks/subscribe-write.d.ts +3 -0
  102. package/ts3.8/esm/babel/plugin-debug-label.d.ts +6 -0
  103. package/ts3.8/esm/babel/plugin-react-refresh.d.ts +6 -0
  104. package/ts3.8/esm/babel/preset.d.ts +7 -0
  105. package/ts3.8/esm/babel/utils.d.ts +6 -0
  106. package/ts3.8/esm/index.d.ts +3 -0
  107. package/ts3.8/esm/react/Provider.d.ts +17 -0
  108. package/ts3.8/esm/react/useAtom.d.ts +28 -0
  109. package/ts3.8/esm/react/useAtomValue.d.ts +10 -0
  110. package/ts3.8/esm/react/useSetAtom.d.ts +8 -0
  111. package/ts3.8/esm/react/utils/useAtomCallback.d.ts +6 -0
  112. package/ts3.8/esm/react/utils/useHydrateAtoms.d.ts +27 -0
  113. package/ts3.8/esm/react/utils/useReducerAtom.d.ts +21 -0
  114. package/ts3.8/esm/react/utils/useResetAtom.d.ts +9 -0
  115. package/ts3.8/esm/react/utils.d.ts +5 -0
  116. package/ts3.8/esm/react.d.ts +5 -0
  117. package/ts3.8/esm/utils.d.ts +3 -0
  118. package/ts3.8/esm/vanilla/atom.d.ts +48 -0
  119. package/ts3.8/esm/vanilla/internals.d.ts +165 -0
  120. package/ts3.8/esm/vanilla/store.d.ts +6 -0
  121. package/ts3.8/esm/vanilla/typeUtils.d.ts +8 -0
  122. package/ts3.8/esm/vanilla/utils/atomFamily.d.ts +56 -0
  123. package/ts3.8/esm/vanilla/utils/atomWithDefault.d.ts +11 -0
  124. package/ts3.8/esm/vanilla/utils/atomWithLazy.d.ts +3 -0
  125. package/ts3.8/esm/vanilla/utils/atomWithObservable.d.ts +37 -0
  126. package/ts3.8/esm/vanilla/utils/atomWithReducer.d.ts +8 -0
  127. package/ts3.8/esm/vanilla/utils/atomWithRefresh.d.ts +10 -0
  128. package/ts3.8/esm/vanilla/utils/atomWithReset.d.ts +11 -0
  129. package/ts3.8/esm/vanilla/utils/atomWithStorage.d.ts +53 -0
  130. package/ts3.8/esm/vanilla/utils/constants.d.ts +2 -0
  131. package/ts3.8/esm/vanilla/utils/freezeAtom.d.ts +7 -0
  132. package/ts3.8/esm/vanilla/utils/loadable.d.ts +34 -0
  133. package/ts3.8/esm/vanilla/utils/selectAtom.d.ts +3 -0
  134. package/ts3.8/esm/vanilla/utils/splitAtom.d.ts +21 -0
  135. package/ts3.8/esm/vanilla/utils/unwrap.d.ts +6 -0
  136. package/ts3.8/esm/vanilla/utils.d.ts +15 -0
  137. package/ts3.8/esm/vanilla.d.ts +5 -0
  138. package/ts3.8/index.d.ts +3 -0
  139. package/ts3.8/react/Provider.d.ts +17 -0
  140. package/ts3.8/react/useAtom.d.ts +28 -0
  141. package/ts3.8/react/useAtomValue.d.ts +10 -0
  142. package/ts3.8/react/useSetAtom.d.ts +8 -0
  143. package/ts3.8/react/utils/useAtomCallback.d.ts +6 -0
  144. package/ts3.8/react/utils/useHydrateAtoms.d.ts +27 -0
  145. package/ts3.8/react/utils/useReducerAtom.d.ts +21 -0
  146. package/ts3.8/react/utils/useResetAtom.d.ts +9 -0
  147. package/ts3.8/react/utils.d.ts +5 -0
  148. package/ts3.8/react.d.ts +5 -0
  149. package/ts3.8/utils.d.ts +3 -0
  150. package/ts3.8/vanilla/atom.d.ts +48 -0
  151. package/ts3.8/vanilla/internals.d.ts +165 -0
  152. package/ts3.8/vanilla/store.d.ts +6 -0
  153. package/ts3.8/vanilla/typeUtils.d.ts +8 -0
  154. package/ts3.8/vanilla/utils/atomFamily.d.ts +56 -0
  155. package/ts3.8/vanilla/utils/atomWithDefault.d.ts +11 -0
  156. package/ts3.8/vanilla/utils/atomWithLazy.d.ts +3 -0
  157. package/ts3.8/vanilla/utils/atomWithObservable.d.ts +37 -0
  158. package/ts3.8/vanilla/utils/atomWithReducer.d.ts +8 -0
  159. package/ts3.8/vanilla/utils/atomWithRefresh.d.ts +10 -0
  160. package/ts3.8/vanilla/utils/atomWithReset.d.ts +11 -0
  161. package/ts3.8/vanilla/utils/atomWithStorage.d.ts +53 -0
  162. package/ts3.8/vanilla/utils/constants.d.ts +2 -0
  163. package/ts3.8/vanilla/utils/freezeAtom.d.ts +7 -0
  164. package/ts3.8/vanilla/utils/loadable.d.ts +34 -0
  165. package/ts3.8/vanilla/utils/selectAtom.d.ts +3 -0
  166. package/ts3.8/vanilla/utils/splitAtom.d.ts +21 -0
  167. package/ts3.8/vanilla/utils/unwrap.d.ts +6 -0
  168. package/ts3.8/vanilla/utils.d.ts +15 -0
  169. package/ts3.8/vanilla.d.ts +5 -0
  170. package/ts_version_3.8_and_above_is_required.d.ts +0 -0
  171. package/umd/babel/plugin-debug-label.development.js +58 -0
  172. package/umd/babel/plugin-debug-label.production.js +1 -0
  173. package/umd/babel/plugin-react-refresh.development.js +76 -0
  174. package/umd/babel/plugin-react-refresh.production.js +1 -0
  175. package/umd/babel/preset.development.js +114 -0
  176. package/umd/babel/preset.production.js +1 -0
  177. package/umd/index.development.js +20 -0
  178. package/umd/index.production.js +1 -0
  179. package/umd/react/utils.development.js +101 -0
  180. package/umd/react/utils.production.js +1 -0
  181. package/umd/react.development.js +184 -0
  182. package/umd/react.production.js +1 -0
  183. package/umd/utils.development.js +20 -0
  184. package/umd/utils.production.js +1 -0
  185. package/umd/vanilla/internals.development.js +785 -0
  186. package/umd/vanilla/internals.production.js +1 -0
  187. package/umd/vanilla/utils.development.js +858 -0
  188. package/umd/vanilla/utils.production.js +1 -0
  189. package/umd/vanilla.development.js +64 -0
  190. package/umd/vanilla.production.js +1 -0
  191. package/utils.d.ts +2 -0
  192. package/utils.js +19 -0
  193. package/vanilla/atom.d.ts +47 -0
  194. package/vanilla/internals.d.ts +164 -0
  195. package/vanilla/internals.js +779 -0
  196. package/vanilla/store.d.ts +5 -0
  197. package/vanilla/typeUtils.d.ts +7 -0
  198. package/vanilla/utils/atomFamily.d.ts +55 -0
  199. package/vanilla/utils/atomWithDefault.d.ts +6 -0
  200. package/vanilla/utils/atomWithLazy.d.ts +2 -0
  201. package/vanilla/utils/atomWithObservable.d.ts +32 -0
  202. package/vanilla/utils/atomWithReducer.d.ts +3 -0
  203. package/vanilla/utils/atomWithRefresh.d.ts +6 -0
  204. package/vanilla/utils/atomWithReset.d.ts +8 -0
  205. package/vanilla/utils/atomWithStorage.d.ts +50 -0
  206. package/vanilla/utils/constants.d.ts +1 -0
  207. package/vanilla/utils/freezeAtom.d.ts +6 -0
  208. package/vanilla/utils/loadable.d.ts +33 -0
  209. package/vanilla/utils/selectAtom.d.ts +2 -0
  210. package/vanilla/utils/splitAtom.d.ts +16 -0
  211. package/vanilla/utils/unwrap.d.ts +5 -0
  212. package/vanilla/utils.d.ts +14 -0
  213. package/vanilla/utils.js +854 -0
  214. package/vanilla.d.ts +4 -0
  215. package/vanilla.js +60 -0
package/vanilla.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { atom } from './vanilla/atom';
2
+ export type { Atom, WritableAtom, PrimitiveAtom } from './vanilla/atom';
3
+ export { createStore, getDefaultStore, INTERNAL_overrideCreateStore, } from './vanilla/store';
4
+ export type { Getter, Setter, ExtractAtomValue, ExtractAtomArgs, ExtractAtomResult, SetStateAction, } from './vanilla/typeUtils';
package/vanilla.js ADDED
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ var internals = require('jotai/vanilla/internals');
4
+
5
+ var keyCount = 0;
6
+ function atom(read, write) {
7
+ var key = "atom" + ++keyCount;
8
+ var config = {
9
+ toString: function toString() {
10
+ return process.env.NODE_ENV !== 'production' && this.debugLabel ? key + ':' + this.debugLabel : key;
11
+ }
12
+ };
13
+ if (typeof read === 'function') {
14
+ config.read = read;
15
+ } else {
16
+ config.init = read;
17
+ config.read = defaultRead;
18
+ config.write = defaultWrite;
19
+ }
20
+ if (write) {
21
+ config.write = write;
22
+ }
23
+ return config;
24
+ }
25
+ function defaultRead(get) {
26
+ return get(this);
27
+ }
28
+ function defaultWrite(get, set, arg) {
29
+ return set(this, typeof arg === 'function' ? arg(get(this)) : arg);
30
+ }
31
+
32
+ var overriddenCreateStore;
33
+ function INTERNAL_overrideCreateStore(fn) {
34
+ overriddenCreateStore = fn(overriddenCreateStore);
35
+ }
36
+ function createStore() {
37
+ if (overriddenCreateStore) {
38
+ return overriddenCreateStore();
39
+ }
40
+ return internals.INTERNAL_buildStoreRev2();
41
+ }
42
+ var defaultStore;
43
+ function getDefaultStore() {
44
+ if (!defaultStore) {
45
+ defaultStore = createStore();
46
+ if (process.env.NODE_ENV !== 'production') {
47
+ var _ref;
48
+ (_ref = globalThis).__JOTAI_DEFAULT_STORE__ || (_ref.__JOTAI_DEFAULT_STORE__ = defaultStore);
49
+ if (globalThis.__JOTAI_DEFAULT_STORE__ !== defaultStore) {
50
+ console.warn('Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044');
51
+ }
52
+ }
53
+ }
54
+ return defaultStore;
55
+ }
56
+
57
+ exports.INTERNAL_overrideCreateStore = INTERNAL_overrideCreateStore;
58
+ exports.atom = atom;
59
+ exports.createStore = createStore;
60
+ exports.getDefaultStore = getDefaultStore;