@cyclone-ui/state 0.0.31 → 0.0.33

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 (160) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/base/atoms/atom-with-broadcast.cjs +1 -44
  3. package/dist/base/atoms/atom-with-broadcast.mjs +1 -44
  4. package/dist/base/atoms/atom-with-broadcast.mjs.map +1 -1
  5. package/dist/base/atoms/atom-with-compare.cjs +1 -11
  6. package/dist/base/atoms/atom-with-compare.mjs +1 -11
  7. package/dist/base/atoms/atom-with-compare.mjs.map +1 -1
  8. package/dist/base/atoms/atom-with-debounce.cjs +1 -51
  9. package/dist/base/atoms/atom-with-debounce.mjs +1 -51
  10. package/dist/base/atoms/atom-with-debounce.mjs.map +1 -1
  11. package/dist/base/atoms/atom-with-effect.cjs +1 -122
  12. package/dist/base/atoms/atom-with-effect.mjs +1 -119
  13. package/dist/base/atoms/atom-with-effect.mjs.map +1 -1
  14. package/dist/base/atoms/atom-with-listeners.cjs +1 -35
  15. package/dist/base/atoms/atom-with-listeners.mjs +1 -35
  16. package/dist/base/atoms/atom-with-listeners.mjs.map +1 -1
  17. package/dist/base/atoms/atom-with-pending.cjs +1 -13
  18. package/dist/base/atoms/atom-with-pending.mjs +1 -13
  19. package/dist/base/atoms/atom-with-pending.mjs.map +1 -1
  20. package/dist/base/atoms/atom-with-refresh-and-default.cjs +1 -18
  21. package/dist/base/atoms/atom-with-refresh-and-default.mjs +1 -18
  22. package/dist/base/atoms/atom-with-refresh-and-default.mjs.map +1 -1
  23. package/dist/base/atoms/atom-with-refresh.cjs +1 -12
  24. package/dist/base/atoms/atom-with-refresh.mjs +1 -12
  25. package/dist/base/atoms/atom-with-refresh.mjs.map +1 -1
  26. package/dist/base/atoms/atom-with-toggle.cjs +1 -12
  27. package/dist/base/atoms/atom-with-toggle.mjs +1 -12
  28. package/dist/base/atoms/atom-with-toggle.mjs.map +1 -1
  29. package/dist/base/atoms/atom-with-web-storage.cjs +1 -47
  30. package/dist/base/atoms/atom-with-web-storage.mjs +1 -46
  31. package/dist/base/atoms/atom-with-web-storage.mjs.map +1 -1
  32. package/dist/base/atoms/atom-with-wrapper.cjs +1 -24
  33. package/dist/base/atoms/atom-with-wrapper.mjs +1 -24
  34. package/dist/base/atoms/atom-with-wrapper.mjs.map +1 -1
  35. package/dist/base/atoms/base-atom.cjs +1 -24
  36. package/dist/base/atoms/base-atom.mjs +1 -24
  37. package/dist/base/atoms/base-atom.mjs.map +1 -1
  38. package/dist/base/atoms/index.cjs +1 -24
  39. package/dist/base/atoms/index.mjs +1 -13
  40. package/dist/base/hooks/index.cjs +1 -9
  41. package/dist/base/hooks/index.mjs +1 -6
  42. package/dist/base/hooks/use-atom-effect.cjs +1 -16
  43. package/dist/base/hooks/use-atom-effect.mjs +1 -16
  44. package/dist/base/hooks/use-atom-effect.mjs.map +1 -1
  45. package/dist/base/hooks/use-hydrate-molecule.cjs +1 -16
  46. package/dist/base/hooks/use-hydrate-molecule.mjs +1 -16
  47. package/dist/base/hooks/use-hydrate-molecule.mjs.map +1 -1
  48. package/dist/base/hooks/use-prepare-atoms.cjs +1 -19
  49. package/dist/base/hooks/use-prepare-atoms.mjs +1 -19
  50. package/dist/base/hooks/use-prepare-atoms.mjs.map +1 -1
  51. package/dist/base/hooks/use-sync-molecule.cjs +1 -36
  52. package/dist/base/hooks/use-sync-molecule.mjs +1 -36
  53. package/dist/base/hooks/use-sync-molecule.mjs.map +1 -1
  54. package/dist/base/index.cjs +1 -47
  55. package/dist/base/index.mjs +1 -24
  56. package/dist/base/utilities/create-molecule.cjs +1 -104
  57. package/dist/base/utilities/create-molecule.mjs +1 -101
  58. package/dist/base/utilities/create-molecule.mjs.map +1 -1
  59. package/dist/base/utilities/create-web-storage.cjs +1 -54
  60. package/dist/base/utilities/create-web-storage.mjs +1 -54
  61. package/dist/base/utilities/create-web-storage.mjs.map +1 -1
  62. package/dist/base/utilities/debounce.cjs +1 -51
  63. package/dist/base/utilities/debounce.mjs +1 -51
  64. package/dist/base/utilities/debounce.mjs.map +1 -1
  65. package/dist/base/utilities/index.cjs +1 -13
  66. package/dist/base/utilities/index.mjs +1 -6
  67. package/dist/base/utilities/is-atom.cjs +1 -47
  68. package/dist/base/utilities/is-atom.mjs +1 -45
  69. package/dist/base/utilities/is-atom.mjs.map +1 -1
  70. package/dist/base/utilities/set-atom-debug.cjs +1 -23
  71. package/dist/base/utilities/set-atom-debug.mjs +1 -22
  72. package/dist/base/utilities/set-atom-debug.mjs.map +1 -1
  73. package/dist/form/atoms/atom-with-field.cjs +1 -22
  74. package/dist/form/atoms/atom-with-field.mjs +1 -22
  75. package/dist/form/atoms/atom-with-field.mjs.map +1 -1
  76. package/dist/form/atoms/atom-with-messages.cjs +1 -84
  77. package/dist/form/atoms/atom-with-messages.mjs +1 -77
  78. package/dist/form/atoms/atom-with-messages.mjs.map +1 -1
  79. package/dist/form/hooks/index.cjs +1 -7
  80. package/dist/form/hooks/index.mjs +1 -5
  81. package/dist/form/hooks/use-field-actions.cjs +1 -91
  82. package/dist/form/hooks/use-field-actions.mjs +1 -91
  83. package/dist/form/hooks/use-field-actions.mjs.map +1 -1
  84. package/dist/form/hooks/use-field-ref.cjs +1 -15
  85. package/dist/form/hooks/use-field-ref.mjs +1 -15
  86. package/dist/form/hooks/use-field-ref.mjs.map +1 -1
  87. package/dist/form/hooks/use-form-actions.cjs +1 -68
  88. package/dist/form/hooks/use-form-actions.mjs +1 -68
  89. package/dist/form/hooks/use-form-actions.mjs.map +1 -1
  90. package/dist/form/index.cjs +1 -30
  91. package/dist/form/index.mjs +1 -17
  92. package/dist/form/molecules/field-molecule.cjs +1 -156
  93. package/dist/form/molecules/field-molecule.mjs +1 -155
  94. package/dist/form/molecules/field-molecule.mjs.map +1 -1
  95. package/dist/form/molecules/form-molecule.cjs +1 -179
  96. package/dist/form/molecules/form-molecule.mjs +1 -178
  97. package/dist/form/molecules/form-molecule.mjs.map +1 -1
  98. package/dist/form/molecules/index.cjs +1 -7
  99. package/dist/form/molecules/index.mjs +1 -4
  100. package/dist/form/providers/FieldProvider.cjs +1 -102
  101. package/dist/form/providers/FieldProvider.mjs +1 -102
  102. package/dist/form/providers/FieldProvider.mjs.map +1 -1
  103. package/dist/form/providers/FormProvider.cjs +1 -65
  104. package/dist/form/providers/FormProvider.mjs +1 -65
  105. package/dist/form/providers/FormProvider.mjs.map +1 -1
  106. package/dist/form/providers/index.cjs +1 -5
  107. package/dist/form/providers/index.mjs +1 -4
  108. package/dist/form/types.cjs +1 -12
  109. package/dist/form/types.mjs +1 -12
  110. package/dist/form/types.mjs.map +1 -1
  111. package/dist/form/utilities/abort-error.cjs +1 -14
  112. package/dist/form/utilities/abort-error.mjs +1 -14
  113. package/dist/form/utilities/abort-error.mjs.map +1 -1
  114. package/dist/form/utilities/index.cjs +1 -7
  115. package/dist/form/utilities/index.mjs +1 -5
  116. package/dist/form/utilities/is-validation-results.cjs +1 -8
  117. package/dist/form/utilities/is-validation-results.mjs +1 -8
  118. package/dist/form/utilities/is-validation-results.mjs.map +1 -1
  119. package/dist/form/utilities/validators.cjs +1 -7
  120. package/dist/form/utilities/validators.mjs +1 -7
  121. package/dist/form/utilities/validators.mjs.map +1 -1
  122. package/dist/index.cjs +1 -46
  123. package/dist/index.mjs +1 -22
  124. package/dist/message/components/MessageViewport.cjs +1 -20
  125. package/dist/message/components/MessageViewport.mjs +1 -20
  126. package/dist/message/components/MessageViewport.mjs.map +1 -1
  127. package/dist/message/components/index.cjs +1 -3
  128. package/dist/message/components/index.mjs +1 -3
  129. package/dist/message/hooks/index.cjs +1 -3
  130. package/dist/message/hooks/index.mjs +1 -3
  131. package/dist/message/hooks/use-message-actions.cjs +1 -63
  132. package/dist/message/hooks/use-message-actions.mjs +1 -63
  133. package/dist/message/hooks/use-message-actions.mjs.map +1 -1
  134. package/dist/message/index.cjs +1 -23
  135. package/dist/message/index.mjs +1 -8
  136. package/dist/message/providers/MessageProvider.cjs +1 -15
  137. package/dist/message/providers/MessageProvider.mjs +1 -15
  138. package/dist/message/providers/MessageProvider.mjs.map +1 -1
  139. package/dist/theme/hooks/index.cjs +1 -7
  140. package/dist/theme/hooks/index.mjs +1 -4
  141. package/dist/theme/hooks/use-theme-actions.cjs +1 -20
  142. package/dist/theme/hooks/use-theme-actions.mjs +1 -20
  143. package/dist/theme/hooks/use-theme-actions.mjs.map +1 -1
  144. package/dist/theme/hooks/use-theme-store.cjs +1 -60
  145. package/dist/theme/hooks/use-theme-store.mjs +1 -58
  146. package/dist/theme/hooks/use-theme-store.mjs.map +1 -1
  147. package/dist/theme/index.cjs +1 -17
  148. package/dist/theme/index.mjs +1 -9
  149. package/dist/theme/molecules/index.cjs +1 -3
  150. package/dist/theme/molecules/index.mjs +1 -3
  151. package/dist/theme/molecules/theme-molecule.cjs +1 -13
  152. package/dist/theme/molecules/theme-molecule.mjs +1 -13
  153. package/dist/theme/molecules/theme-molecule.mjs.map +1 -1
  154. package/dist/theme/providers/ThemeProvider.cjs +1 -29
  155. package/dist/theme/providers/ThemeProvider.mjs +1 -29
  156. package/dist/theme/providers/ThemeProvider.mjs.map +1 -1
  157. package/dist/theme/utilities/theme-helpers.cjs +1 -70
  158. package/dist/theme/utilities/theme-helpers.mjs +1 -69
  159. package/dist/theme/utilities/theme-helpers.mjs.map +1 -1
  160. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  # Changelog for Cyclone UI - State
4
4
 
5
+ ## [0.0.32](https://github.com/storm-software/cyclone-ui/releases/tag/state%400.0.32) (10/24/2026)
6
+
7
+ ### Features
8
+
9
+ - **nextjs:** Added NextJS and Vite build packages, setup skills, and documentation updates ([2759b41c](https://github.com/storm-software/cyclone-ui/commit/2759b41c))
10
+
11
+ ### Updated Dependencies
12
+
13
+ - Updated **helpers** to **v0.3.31**
14
+
15
+ ## [0.0.31](https://github.com/storm-software/cyclone-ui/releases/tag/state%400.0.31) (10/24/2026)
16
+
17
+ ### Updated Dependencies
18
+
19
+ - Updated **helpers** to **v0.3.30**
20
+
5
21
  ## [0.0.30](https://github.com/storm-software/cyclone-ui/releases/tag/state%400.0.30) (10/23/2026)
6
22
 
7
23
  ### Updated Dependencies
@@ -1,44 +1 @@
1
- const require_is_atom = require("../utilities/is-atom.cjs");
2
- const require_base_atom = require("./base-atom.cjs");
3
- let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
4
-
5
- // src/base/atoms/atom-with-broadcast.ts
6
- /**
7
- * Creates an atom that broadcasts its value to other tabs/windows using the BroadcastChannel API.
8
- *
9
- * @param key - The key to use for the BroadcastChannel
10
- * @param initialValueOrAtom - The initial value of the atom
11
- * @returns An atom that broadcasts its value to other tabs/windows using the BroadcastChannel API.
12
- */
13
- function atomWithBroadcast(key, initialValueOrAtom) {
14
- const valueAtom = require_is_atom.isAtom(initialValueOrAtom) ? initialValueOrAtom : require_base_atom.baseAtom(initialValueOrAtom);
15
- const listeners = /* @__PURE__ */ new Set();
16
- const channel = typeof BroadcastChannel === "undefined" ? void 0 : new BroadcastChannel(key);
17
- if (channel) channel.onmessage = (message) => {
18
- for (const listener of listeners) listener(message);
19
- };
20
- const broadcastAtom = require_base_atom.baseAtom((get) => get(valueAtom), (get, set, update) => {
21
- set(valueAtom, (0, _stryke_type_checks_is_function.isFunction)(update.value) ? update.value(get(valueAtom)) : update.value);
22
- if (!update.isEvent && channel) channel.postMessage(JSON.stringify(get(valueAtom)));
23
- });
24
- broadcastAtom.onMount = (setAtom) => {
25
- const listener = (event) => {
26
- setAtom({
27
- isEvent: true,
28
- value: JSON.parse(event.data)
29
- });
30
- };
31
- listeners.add(listener);
32
- return () => {
33
- listeners.delete(listener);
34
- };
35
- };
36
- return require_base_atom.baseAtom((get) => get(broadcastAtom), (_, set, update) => {
37
- set(broadcastAtom, {
38
- isEvent: false,
39
- value: update
40
- });
41
- });
42
- }
43
-
44
- exports.atomWithBroadcast = atomWithBroadcast;
1
+ const e=require("../utilities/is-atom.cjs"),t=require("./base-atom.cjs");let n=require("@stryke/type-checks/is-function");function r(r,i){let a=e.isAtom(i)?i:t.baseAtom(i),o=/* @__PURE__ */ new Set,s=typeof BroadcastChannel>`u`?void 0:new BroadcastChannel(r);s&&(s.onmessage=e=>{for(let t of o)t(e)});let c=t.baseAtom(e=>e(a),(e,t,r)=>{t(a,(0,n.isFunction)(r.value)?r.value(e(a)):r.value),!r.isEvent&&s&&s.postMessage(JSON.stringify(e(a)))});return c.onMount=e=>{let t=t=>{e({isEvent:!0,value:JSON.parse(t.data)})};return o.add(t),()=>{o.delete(t)}},t.baseAtom(e=>e(c),(e,t,n)=>{t(c,{isEvent:!1,value:n})})}exports.atomWithBroadcast=r;
@@ -1,45 +1,2 @@
1
- import { isAtom } from "../utilities/is-atom.mjs";
2
- import { baseAtom } from "./base-atom.mjs";
3
- import { isFunction } from "@stryke/type-checks/is-function";
4
-
5
- // src/base/atoms/atom-with-broadcast.ts
6
- /**
7
- * Creates an atom that broadcasts its value to other tabs/windows using the BroadcastChannel API.
8
- *
9
- * @param key - The key to use for the BroadcastChannel
10
- * @param initialValueOrAtom - The initial value of the atom
11
- * @returns An atom that broadcasts its value to other tabs/windows using the BroadcastChannel API.
12
- */
13
- function atomWithBroadcast(key, initialValueOrAtom) {
14
- const valueAtom = isAtom(initialValueOrAtom) ? initialValueOrAtom : baseAtom(initialValueOrAtom);
15
- const listeners = /* @__PURE__ */ new Set();
16
- const channel = typeof BroadcastChannel === "undefined" ? void 0 : new BroadcastChannel(key);
17
- if (channel) channel.onmessage = (message) => {
18
- for (const listener of listeners) listener(message);
19
- };
20
- const broadcastAtom = baseAtom((get) => get(valueAtom), (get, set, update) => {
21
- set(valueAtom, isFunction(update.value) ? update.value(get(valueAtom)) : update.value);
22
- if (!update.isEvent && channel) channel.postMessage(JSON.stringify(get(valueAtom)));
23
- });
24
- broadcastAtom.onMount = (setAtom) => {
25
- const listener = (event) => {
26
- setAtom({
27
- isEvent: true,
28
- value: JSON.parse(event.data)
29
- });
30
- };
31
- listeners.add(listener);
32
- return () => {
33
- listeners.delete(listener);
34
- };
35
- };
36
- return baseAtom((get) => get(broadcastAtom), (_, set, update) => {
37
- set(broadcastAtom, {
38
- isEvent: false,
39
- value: update
40
- });
41
- });
42
- }
43
-
44
- export { atomWithBroadcast };
1
+ import{isAtom as e}from"../utilities/is-atom.mjs";import{baseAtom as t}from"./base-atom.mjs";import{isFunction as n}from"@stryke/type-checks/is-function";function r(r,i){let a=e(i)?i:t(i),o=/* @__PURE__ */ new Set,s=typeof BroadcastChannel>`u`?void 0:new BroadcastChannel(r);s&&(s.onmessage=e=>{for(let t of o)t(e)});let c=t(e=>e(a),(e,t,r)=>{t(a,n(r.value)?r.value(e(a)):r.value),!r.isEvent&&s&&s.postMessage(JSON.stringify(e(a)))});return c.onMount=e=>{let t=t=>{e({isEvent:!0,value:JSON.parse(t.data)})};return o.add(t),()=>{o.delete(t)}},t(e=>e(c),(e,t,n)=>{t(c,{isEvent:!1,value:n})})}export{r as atomWithBroadcast};
45
2
  //# sourceMappingURL=atom-with-broadcast.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"atom-with-broadcast.mjs","names":[],"sources":[],"mappings":""}
1
+ {"version":3,"file":"atom-with-broadcast.mjs","names":["atomWithBroadcast","valueAtom","isAtom","initialValueOrAtom","baseAtom","listeners","channel","key","listener","message","broadcastAtom","get","set","isFunction","update","setAtom","event"],"sources":[],"mappings":""}
@@ -1,11 +1 @@
1
- let jotai_utils = require("jotai/utils");
2
-
3
- // src/base/atoms/atom-with-compare.ts
4
- function atomWithCompare(initialValue, areEqual) {
5
- return (0, jotai_utils.atomWithReducer)(initialValue, (prev, next) => {
6
- if (areEqual(prev, next)) return prev;
7
- return next;
8
- });
9
- }
10
-
11
- exports.atomWithCompare = atomWithCompare;
1
+ let e=require("jotai/utils");function t(t,n){return(0,e.atomWithReducer)(t,(e,t)=>n(e,t)?e:t)}exports.atomWithCompare=t;
@@ -1,12 +1,2 @@
1
- import { atomWithReducer } from "jotai/utils";
2
-
3
- // src/base/atoms/atom-with-compare.ts
4
- function atomWithCompare(initialValue, areEqual) {
5
- return atomWithReducer(initialValue, (prev, next) => {
6
- if (areEqual(prev, next)) return prev;
7
- return next;
8
- });
9
- }
10
-
11
- export { atomWithCompare };
1
+ import{atomWithReducer as e}from"jotai/utils";function t(t,n){return e(t,(e,t)=>n(e,t)?e:t)}export{t as atomWithCompare};
12
2
  //# sourceMappingURL=atom-with-compare.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"atom-with-compare.mjs","names":[],"sources":[],"mappings":""}
1
+ {"version":3,"file":"atom-with-compare.mjs","names":["atomWithCompare","atomWithReducer","initialValue","areEqual","prev","next"],"sources":[],"mappings":""}
@@ -1,51 +1 @@
1
- const require_is_atom = require("../utilities/is-atom.cjs");
2
- const require_base_atom = require("./base-atom.cjs");
3
- const require_atom_with_wrapper = require("./atom-with-wrapper.cjs");
4
- let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
5
- let jotai_utils = require("jotai/utils");
6
-
7
- // src/base/atoms/atom-with-debounce.ts
8
- function atomWithDebounce(initialValueOrAtom, debounceMs = 500, shouldDebounceOnReset = false) {
9
- const prevTimeoutAtom = require_base_atom.baseAtom(void 0);
10
- const initialValueAtom = require_is_atom.isAtom(initialValueOrAtom) ? initialValueOrAtom : require_atom_with_wrapper.atomWithWrapper(initialValueOrAtom);
11
- const innerValueAtom = require_base_atom.baseAtom(null);
12
- const _currentValueAtom = require_base_atom.baseAtom((get) => {
13
- const innerValue = get(innerValueAtom);
14
- if (innerValue === null) return get(initialValueAtom);
15
- return innerValue;
16
- }, (get, set, update) => set(innerValueAtom, update));
17
- const isDebouncingAtom = require_base_atom.baseAtom(false);
18
- const debouncedValueAtom = require_base_atom.baseAtom((get) => get(innerValueAtom), (get, set, update) => {
19
- clearTimeout(get(prevTimeoutAtom));
20
- const prevValue = get(_currentValueAtom);
21
- const nextValue = update === jotai_utils.RESET ? get(innerValueAtom) : (0, _stryke_type_checks_is_function.isFunction)(update) ? update(prevValue) : update;
22
- const onDebounceStart = () => {
23
- set(_currentValueAtom, nextValue);
24
- set(isDebouncingAtom, true);
25
- };
26
- const onDebounceEnd = () => {
27
- set(debouncedValueAtom, nextValue);
28
- set(isDebouncingAtom, false);
29
- };
30
- onDebounceStart();
31
- if (!shouldDebounceOnReset && nextValue === get(initialValueAtom)) {
32
- onDebounceEnd();
33
- return;
34
- }
35
- const nextTimeoutId = setTimeout(() => {
36
- onDebounceEnd();
37
- }, debounceMs);
38
- set(prevTimeoutAtom, nextTimeoutId);
39
- });
40
- return {
41
- clearTimeoutAtom: require_base_atom.baseAtom(null, (get, set) => {
42
- clearTimeout(get(prevTimeoutAtom));
43
- set(isDebouncingAtom, false);
44
- }),
45
- currentValueAtom: require_base_atom.baseAtom((get) => get(_currentValueAtom)),
46
- debouncedValueAtom,
47
- isDebouncingAtom
48
- };
49
- }
50
-
51
- exports.atomWithDebounce = atomWithDebounce;
1
+ const e=require("../utilities/is-atom.cjs"),t=require("./base-atom.cjs"),n=require("./atom-with-wrapper.cjs");let r=require("@stryke/type-checks/is-function"),i=require("jotai/utils");function a(a,o=500,s=!1){let c=t.baseAtom(void 0),l=e.isAtom(a)?a:n.atomWithWrapper(a),u=t.baseAtom(null),d=t.baseAtom(e=>{let t=e(u);return t===null?e(l):t},(e,t,n)=>t(u,n)),f=t.baseAtom(!1),p=t.baseAtom(e=>e(u),(e,t,n)=>{clearTimeout(e(c));let a=e(d),m=n===i.RESET?e(u):(0,r.isFunction)(n)?n(a):n,h=()=>{t(d,m),t(f,!0)},g=()=>{t(p,m),t(f,!1)};if(h(),!s&&m===e(l)){g();return}let _=setTimeout(()=>{g()},o);t(c,_)});return{clearTimeoutAtom:t.baseAtom(null,(e,t)=>{clearTimeout(e(c)),t(f,!1)}),currentValueAtom:t.baseAtom(e=>e(d)),debouncedValueAtom:p,isDebouncingAtom:f}}exports.atomWithDebounce=a;
@@ -1,52 +1,2 @@
1
- import { isAtom } from "../utilities/is-atom.mjs";
2
- import { baseAtom } from "./base-atom.mjs";
3
- import { atomWithWrapper } from "./atom-with-wrapper.mjs";
4
- import { isFunction } from "@stryke/type-checks/is-function";
5
- import { RESET } from "jotai/utils";
6
-
7
- // src/base/atoms/atom-with-debounce.ts
8
- function atomWithDebounce(initialValueOrAtom, debounceMs = 500, shouldDebounceOnReset = false) {
9
- const prevTimeoutAtom = baseAtom(void 0);
10
- const initialValueAtom = isAtom(initialValueOrAtom) ? initialValueOrAtom : atomWithWrapper(initialValueOrAtom);
11
- const innerValueAtom = baseAtom(null);
12
- const _currentValueAtom = baseAtom((get) => {
13
- const innerValue = get(innerValueAtom);
14
- if (innerValue === null) return get(initialValueAtom);
15
- return innerValue;
16
- }, (get, set, update) => set(innerValueAtom, update));
17
- const isDebouncingAtom = baseAtom(false);
18
- const debouncedValueAtom = baseAtom((get) => get(innerValueAtom), (get, set, update) => {
19
- clearTimeout(get(prevTimeoutAtom));
20
- const prevValue = get(_currentValueAtom);
21
- const nextValue = update === RESET ? get(innerValueAtom) : isFunction(update) ? update(prevValue) : update;
22
- const onDebounceStart = () => {
23
- set(_currentValueAtom, nextValue);
24
- set(isDebouncingAtom, true);
25
- };
26
- const onDebounceEnd = () => {
27
- set(debouncedValueAtom, nextValue);
28
- set(isDebouncingAtom, false);
29
- };
30
- onDebounceStart();
31
- if (!shouldDebounceOnReset && nextValue === get(initialValueAtom)) {
32
- onDebounceEnd();
33
- return;
34
- }
35
- const nextTimeoutId = setTimeout(() => {
36
- onDebounceEnd();
37
- }, debounceMs);
38
- set(prevTimeoutAtom, nextTimeoutId);
39
- });
40
- return {
41
- clearTimeoutAtom: baseAtom(null, (get, set) => {
42
- clearTimeout(get(prevTimeoutAtom));
43
- set(isDebouncingAtom, false);
44
- }),
45
- currentValueAtom: baseAtom((get) => get(_currentValueAtom)),
46
- debouncedValueAtom,
47
- isDebouncingAtom
48
- };
49
- }
50
-
51
- export { atomWithDebounce };
1
+ import{isAtom as e}from"../utilities/is-atom.mjs";import{baseAtom as t}from"./base-atom.mjs";import{atomWithWrapper as n}from"./atom-with-wrapper.mjs";import{isFunction as r}from"@stryke/type-checks/is-function";import{RESET as i}from"jotai/utils";function a(a,o=500,s=!1){let c=t(void 0),l=e(a)?a:n(a),u=t(null),d=t(e=>{let t=e(u);return t===null?e(l):t},(e,t,n)=>t(u,n)),f=t(!1),p=t(e=>e(u),(e,t,n)=>{clearTimeout(e(c));let a=e(d),m=n===i?e(u):r(n)?n(a):n,h=()=>{t(d,m),t(f,!0)},g=()=>{t(p,m),t(f,!1)};if(h(),!s&&m===e(l)){g();return}let _=setTimeout(()=>{g()},o);t(c,_)});return{clearTimeoutAtom:t(null,(e,t)=>{clearTimeout(e(c)),t(f,!1)}),currentValueAtom:t(e=>e(d)),debouncedValueAtom:p,isDebouncingAtom:f}}export{a as atomWithDebounce};
52
2
  //# sourceMappingURL=atom-with-debounce.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"atom-with-debounce.mjs","names":[],"sources":[],"mappings":""}
1
+ {"version":3,"file":"atom-with-debounce.mjs","names":["atomWithDebounce","prevTimeoutAtom","baseAtom","initialValueAtom","isAtom","initialValueOrAtom","atomWithWrapper","innerValueAtom","_currentValueAtom","innerValue","get","set","update","isDebouncingAtom","debouncedValueAtom","prevValue","nextValue","RESET","isFunction","onDebounceStart","onDebounceEnd","shouldDebounceOnReset","nextTimeoutId","debounceMs"],"sources":[],"mappings":""}
@@ -1,122 +1 @@
1
- let jotai_vanilla = require("jotai/vanilla");
2
- let _stryke_helpers_is_equal = require("@stryke/helpers/is-equal");
3
-
4
- // src/base/atoms/atom-with-effect.ts
5
- function atomWithEffect(effect) {
6
- const refreshAtom = (0, jotai_vanilla.atom)(0);
7
- const refAtom = (0, jotai_vanilla.atom)(() => ({
8
- inProgress: 0,
9
- mounted: false,
10
- promise: void 0,
11
- pendingError: void 0,
12
- cleanup: void 0,
13
- fromCleanup: false,
14
- isRecursing: false,
15
- isRefreshing: false,
16
- get: (() => {}),
17
- set: (() => {})
18
- }), (get, set) => {
19
- const ref = get(refAtom);
20
- Object.assign(ref, {
21
- mounted: true,
22
- get,
23
- set
24
- });
25
- set(refreshAtom, (c) => c + 1);
26
- return () => {
27
- ref.mounted = false;
28
- cleanup(ref);
29
- throwPendingError(ref);
30
- };
31
- });
32
- refAtom.onMount = (mount) => mount();
33
- const baseAtom = (0, jotai_vanilla.atom)(async (get) => {
34
- get(refreshAtom);
35
- const ref = get(refAtom);
36
- if (!ref.mounted || ref.isRecursing || ref.inProgress && !ref.isRefreshing) return ref.promise;
37
- throwPendingError(ref);
38
- const currDeps = /* @__PURE__ */ new Map();
39
- const getter = (a) => {
40
- const value = get(a);
41
- currDeps.set(a, value);
42
- return value;
43
- };
44
- getter.peek = (anAtom) => ref.get(anAtom);
45
- const setter = (...args) => {
46
- try {
47
- ++ref.inProgress;
48
- return ref.set(...args);
49
- } finally {
50
- Array.from(currDeps.keys(), get);
51
- --ref.inProgress;
52
- }
53
- };
54
- setter.recurse = (anAtom, ...args) => {
55
- if (ref.fromCleanup) {
56
- if (process.env.NODE_ENV !== "production") throw new Error("set.recurse is not allowed in cleanup");
57
- return;
58
- }
59
- try {
60
- ref.isRecursing = true;
61
- return ref.set(anAtom, ...args);
62
- } finally {
63
- ref.isRecursing = false;
64
- if (Array.from(currDeps).some(([atom, value]) => !(0, _stryke_helpers_is_equal.isEqual)(get(atom), value))) refresh(ref);
65
- }
66
- };
67
- ++ref.inProgress;
68
- function runEffect() {
69
- try {
70
- ref.isRefreshing = false;
71
- if (!ref.mounted) return;
72
- cleanup(ref);
73
- ref.cleanup = effect(getter, setter);
74
- } catch (error) {
75
- ref.pendingError = error;
76
- refresh(ref);
77
- } finally {
78
- ref.promise = void 0;
79
- --ref.inProgress;
80
- }
81
- }
82
- return ref.isRefreshing ? runEffect() : ref.promise = Promise.resolve().then(runEffect);
83
- });
84
- if (process.env.NODE_ENV !== "production") {
85
- function setLabel(atom, label) {
86
- Object.defineProperty(atom, "debugLabel", { get: () => `${effectAtom.debugLabel ?? "effect"}:${label}` });
87
- atom.debugPrivate = true;
88
- }
89
- setLabel(refreshAtom, "refresh");
90
- setLabel(refAtom, "ref");
91
- setLabel(baseAtom, "base");
92
- }
93
- const effectAtom = (0, jotai_vanilla.atom)((get) => void get(baseAtom));
94
- return effectAtom;
95
- function refresh(ref) {
96
- try {
97
- ref.isRefreshing = true;
98
- ref.set(refreshAtom, (c) => c + 1);
99
- } finally {
100
- ref.isRefreshing = false;
101
- }
102
- }
103
- function cleanup(ref) {
104
- if (!ref.cleanup) return;
105
- try {
106
- ref.fromCleanup = true;
107
- ref.cleanup();
108
- } finally {
109
- ref.fromCleanup = false;
110
- ref.cleanup = void 0;
111
- }
112
- }
113
- function throwPendingError(ref) {
114
- if ("e" in ref) {
115
- const error = ref.pendingError;
116
- delete ref.pendingError;
117
- throw error;
118
- }
119
- }
120
- }
121
-
122
- exports.atomWithEffect = atomWithEffect;
1
+ let e=require("jotai/vanilla"),t=require("@stryke/helpers/is-equal");function n(n){let r=(0,e.atom)(0),i=(0,e.atom)(()=>({inProgress:0,mounted:!1,promise:void 0,pendingError:void 0,cleanup:void 0,fromCleanup:!1,isRecursing:!1,isRefreshing:!1,get:(()=>{}),set:(()=>{})}),(e,t)=>{let n=e(i);return Object.assign(n,{mounted:!0,get:e,set:t}),t(r,e=>e+1),()=>{n.mounted=!1,l(n),u(n)}});i.onMount=e=>e();let a=(0,e.atom)(async e=>{e(r);let a=e(i);if(!a.mounted||a.isRecursing||a.inProgress&&!a.isRefreshing)return a.promise;u(a);let o=/* @__PURE__ */ new Map,s=t=>{let n=e(t);return o.set(t,n),n};s.peek=e=>a.get(e);let d=(...t)=>{try{return++a.inProgress,a.set(...t)}finally{Array.from(o.keys(),e),--a.inProgress}};d.recurse=(n,...r)=>{if(a.fromCleanup){if(process.env.NODE_ENV!==`production`)throw Error(`set.recurse is not allowed in cleanup`)}else try{return a.isRecursing=!0,a.set(n,...r)}finally{a.isRecursing=!1,Array.from(o).some(([n,r])=>!(0,t.isEqual)(e(n),r))&&c(a)}},++a.inProgress;function f(){try{if(a.isRefreshing=!1,!a.mounted)return;l(a),a.cleanup=n(s,d)}catch(e){a.pendingError=e,c(a)}finally{a.promise=void 0,--a.inProgress}}return a.isRefreshing?f():a.promise=Promise.resolve().then(f)});if(process.env.NODE_ENV!==`production`){function o(e,t){Object.defineProperty(e,"debugLabel",{get:()=>`${s.debugLabel??`effect`}:${t}`}),e.debugPrivate=!0}o(r,`refresh`),o(i,`ref`),o(a,`base`)}let s=(0,e.atom)(e=>void e(a));return s;function c(e){try{e.isRefreshing=!0,e.set(r,e=>e+1)}finally{e.isRefreshing=!1}}function l(e){if(e.cleanup)try{e.fromCleanup=!0,e.cleanup()}finally{e.fromCleanup=!1,e.cleanup=void 0}}function u(e){if(`e`in e){let t=e.pendingError;throw delete e.pendingError,t}}}exports.atomWithEffect=n;
@@ -1,120 +1,2 @@
1
- import { atom } from "jotai/vanilla";
2
- import { isEqual } from "@stryke/helpers/is-equal";
3
-
4
- // src/base/atoms/atom-with-effect.ts
5
- function atomWithEffect(effect) {
6
- const refreshAtom = atom(0);
7
- const refAtom = atom(() => ({
8
- inProgress: 0,
9
- mounted: false,
10
- promise: void 0,
11
- pendingError: void 0,
12
- cleanup: void 0,
13
- fromCleanup: false,
14
- isRecursing: false,
15
- isRefreshing: false,
16
- get: (() => {}),
17
- set: (() => {})
18
- }), (get, set) => {
19
- const ref = get(refAtom);
20
- Object.assign(ref, {
21
- mounted: true,
22
- get,
23
- set
24
- });
25
- set(refreshAtom, (c) => c + 1);
26
- return () => {
27
- ref.mounted = false;
28
- cleanup(ref);
29
- throwPendingError(ref);
30
- };
31
- });
32
- refAtom.onMount = (mount) => mount();
33
- const baseAtom = atom(async (get) => {
34
- get(refreshAtom);
35
- const ref = get(refAtom);
36
- if (!ref.mounted || ref.isRecursing || ref.inProgress && !ref.isRefreshing) return ref.promise;
37
- throwPendingError(ref);
38
- const currDeps = /* @__PURE__ */ new Map();
39
- const getter = (a) => {
40
- const value = get(a);
41
- currDeps.set(a, value);
42
- return value;
43
- };
44
- getter.peek = (anAtom) => ref.get(anAtom);
45
- const setter = (...args) => {
46
- try {
47
- ++ref.inProgress;
48
- return ref.set(...args);
49
- } finally {
50
- Array.from(currDeps.keys(), get);
51
- --ref.inProgress;
52
- }
53
- };
54
- setter.recurse = (anAtom, ...args) => {
55
- if (ref.fromCleanup) throw new Error("set.recurse is not allowed in cleanup");
56
- try {
57
- ref.isRecursing = true;
58
- return ref.set(anAtom, ...args);
59
- } finally {
60
- ref.isRecursing = false;
61
- if (Array.from(currDeps).some(([atom, value]) => !isEqual(get(atom), value))) refresh(ref);
62
- }
63
- };
64
- ++ref.inProgress;
65
- function runEffect() {
66
- try {
67
- ref.isRefreshing = false;
68
- if (!ref.mounted) return;
69
- cleanup(ref);
70
- ref.cleanup = effect(getter, setter);
71
- } catch (error) {
72
- ref.pendingError = error;
73
- refresh(ref);
74
- } finally {
75
- ref.promise = void 0;
76
- --ref.inProgress;
77
- }
78
- }
79
- return ref.isRefreshing ? runEffect() : ref.promise = Promise.resolve().then(runEffect);
80
- });
81
- {
82
- function setLabel(atom, label) {
83
- Object.defineProperty(atom, "debugLabel", { get: () => `${effectAtom.debugLabel ?? "effect"}:${label}` });
84
- atom.debugPrivate = true;
85
- }
86
- setLabel(refreshAtom, "refresh");
87
- setLabel(refAtom, "ref");
88
- setLabel(baseAtom, "base");
89
- }
90
- const effectAtom = atom((get) => void get(baseAtom));
91
- return effectAtom;
92
- function refresh(ref) {
93
- try {
94
- ref.isRefreshing = true;
95
- ref.set(refreshAtom, (c) => c + 1);
96
- } finally {
97
- ref.isRefreshing = false;
98
- }
99
- }
100
- function cleanup(ref) {
101
- if (!ref.cleanup) return;
102
- try {
103
- ref.fromCleanup = true;
104
- ref.cleanup();
105
- } finally {
106
- ref.fromCleanup = false;
107
- ref.cleanup = void 0;
108
- }
109
- }
110
- function throwPendingError(ref) {
111
- if ("e" in ref) {
112
- const error = ref.pendingError;
113
- delete ref.pendingError;
114
- throw error;
115
- }
116
- }
117
- }
118
-
119
- export { atomWithEffect };
1
+ import{atom as e}from"jotai/vanilla";import{isEqual as t}from"@stryke/helpers/is-equal";function n(n){let r=e(0),i=e(()=>({inProgress:0,mounted:!1,promise:void 0,pendingError:void 0,cleanup:void 0,fromCleanup:!1,isRecursing:!1,isRefreshing:!1,get:(()=>{}),set:(()=>{})}),(e,t)=>{let n=e(i);return Object.assign(n,{mounted:!0,get:e,set:t}),t(r,e=>e+1),()=>{n.mounted=!1,s(n),c(n)}});i.onMount=e=>e();let a=e(async e=>{e(r);let a=e(i);if(!a.mounted||a.isRecursing||a.inProgress&&!a.isRefreshing)return a.promise;c(a);let l=/* @__PURE__ */ new Map,u=t=>{let n=e(t);return l.set(t,n),n};u.peek=e=>a.get(e);let d=(...t)=>{try{return++a.inProgress,a.set(...t)}finally{Array.from(l.keys(),e),--a.inProgress}};d.recurse=(n,...r)=>{if(!a.fromCleanup)try{return a.isRecursing=!0,a.set(n,...r)}finally{a.isRecursing=!1,Array.from(l).some(([n,r])=>!t(e(n),r))&&o(a)}},++a.inProgress;function f(){try{if(a.isRefreshing=!1,!a.mounted)return;s(a),a.cleanup=n(u,d)}catch(e){a.pendingError=e,o(a)}finally{a.promise=void 0,--a.inProgress}}return a.isRefreshing?f():a.promise=Promise.resolve().then(f)});return e(e=>void e(a));function o(e){try{e.isRefreshing=!0,e.set(r,e=>e+1)}finally{e.isRefreshing=!1}}function s(e){if(e.cleanup)try{e.fromCleanup=!0,e.cleanup()}finally{e.fromCleanup=!1,e.cleanup=void 0}}function c(e){if(`e`in e){let t=e.pendingError;throw delete e.pendingError,t}}}export{n as atomWithEffect};
120
2
  //# sourceMappingURL=atom-with-effect.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"atom-with-effect.mjs","names":[],"sources":[],"mappings":""}
1
+ {"version":3,"file":"atom-with-effect.mjs","names":["atomWithEffect","refreshAtom","atom","refAtom","ref","get","set","c","cleanup","throwPendingError","mount","baseAtom","currDeps","getter","value","a","anAtom","setter","args","isEqual","refresh","runEffect","effect","error"],"sources":[],"mappings":""}
@@ -1,35 +1 @@
1
- const require_is_atom = require("../utilities/is-atom.cjs");
2
- const require_base_atom = require("./base-atom.cjs");
3
- let jotai = require("jotai");
4
- let react = require("react");
5
-
6
- // src/base/atoms/atom-with-listeners.ts
7
- /**
8
- * Creates an atom that broadcasts its value to other tabs/windows using the BroadcastChannel API.
9
- *
10
- * @param initialValue - The initial value of the atom
11
- * @returns An atom that broadcasts its value to other tabs/windows using the BroadcastChannel API.
12
- */
13
- function atomWithListeners(initialValue) {
14
- const rootAtom = require_is_atom.isAtom(initialValue) ? initialValue : require_base_atom.baseAtom(initialValue);
15
- const listenersAtom = require_base_atom.baseAtom([]);
16
- const anAtom = require_base_atom.baseAtom((get) => get(rootAtom), (get, set, arg) => {
17
- const prevVal = get(rootAtom);
18
- set(rootAtom, arg);
19
- const newVal = get(rootAtom);
20
- for (const callback of get(listenersAtom)) callback(get, set, newVal, prevVal);
21
- });
22
- const useListener = (callback) => {
23
- const setListeners = (0, jotai.useSetAtom)(listenersAtom);
24
- (0, react.useEffect)(() => {
25
- setListeners((prev) => [...prev, callback]);
26
- return () => setListeners((prev) => {
27
- const index = prev.indexOf(callback);
28
- return [...prev.slice(0, index), ...prev.slice(index + 1)];
29
- });
30
- }, [setListeners, callback]);
31
- };
32
- return [anAtom, useListener];
33
- }
34
-
35
- exports.atomWithListeners = atomWithListeners;
1
+ const e=require("../utilities/is-atom.cjs"),t=require("./base-atom.cjs");let n=require("jotai"),r=require("react");function i(i){let a=e.isAtom(i)?i:t.baseAtom(i),o=t.baseAtom([]);return[t.baseAtom(e=>e(a),(e,t,n)=>{let r=e(a);t(a,n);let i=e(a);for(let n of e(o))n(e,t,i,r)}),e=>{let t=(0,n.useSetAtom)(o);(0,r.useEffect)(()=>(t(t=>[...t,e]),()=>t(t=>{let n=t.indexOf(e);return[...t.slice(0,n),...t.slice(n+1)]})),[t,e])}]}exports.atomWithListeners=i;
@@ -1,36 +1,2 @@
1
- import { isAtom } from "../utilities/is-atom.mjs";
2
- import { baseAtom } from "./base-atom.mjs";
3
- import { useSetAtom } from "jotai";
4
- import { useEffect } from "react";
5
-
6
- // src/base/atoms/atom-with-listeners.ts
7
- /**
8
- * Creates an atom that broadcasts its value to other tabs/windows using the BroadcastChannel API.
9
- *
10
- * @param initialValue - The initial value of the atom
11
- * @returns An atom that broadcasts its value to other tabs/windows using the BroadcastChannel API.
12
- */
13
- function atomWithListeners(initialValue) {
14
- const rootAtom = isAtom(initialValue) ? initialValue : baseAtom(initialValue);
15
- const listenersAtom = baseAtom([]);
16
- const anAtom = baseAtom((get) => get(rootAtom), (get, set, arg) => {
17
- const prevVal = get(rootAtom);
18
- set(rootAtom, arg);
19
- const newVal = get(rootAtom);
20
- for (const callback of get(listenersAtom)) callback(get, set, newVal, prevVal);
21
- });
22
- const useListener = (callback) => {
23
- const setListeners = useSetAtom(listenersAtom);
24
- useEffect(() => {
25
- setListeners((prev) => [...prev, callback]);
26
- return () => setListeners((prev) => {
27
- const index = prev.indexOf(callback);
28
- return [...prev.slice(0, index), ...prev.slice(index + 1)];
29
- });
30
- }, [setListeners, callback]);
31
- };
32
- return [anAtom, useListener];
33
- }
34
-
35
- export { atomWithListeners };
1
+ import{isAtom as e}from"../utilities/is-atom.mjs";import{baseAtom as t}from"./base-atom.mjs";import{useSetAtom as n}from"jotai";import{useEffect as r}from"react";function i(i){let a=e(i)?i:t(i),o=t([]);return[t(e=>e(a),(e,t,n)=>{let r=e(a);t(a,n);let i=e(a);for(let n of e(o))n(e,t,i,r)}),e=>{let t=n(o);r(()=>(t(t=>[...t,e]),()=>t(t=>{let n=t.indexOf(e);return[...t.slice(0,n),...t.slice(n+1)]})),[t,e])}]}export{i as atomWithListeners};
36
2
  //# sourceMappingURL=atom-with-listeners.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"atom-with-listeners.mjs","names":[],"sources":[],"mappings":""}
1
+ {"version":3,"file":"atom-with-listeners.mjs","names":["atomWithListeners","rootAtom","isAtom","initialValue","baseAtom","listenersAtom","get","prevVal","set","arg","newVal","callback","setListeners","useSetAtom","useEffect","prev","index"],"sources":[],"mappings":""}
@@ -1,13 +1 @@
1
- const require_base_atom = require("./base-atom.cjs");
2
- let _stryke_helpers_noop = require("@stryke/helpers/noop");
3
-
4
- // src/base/atoms/atom-with-pending.ts
5
- const pendingPromise = new Promise(_stryke_helpers_noop.noop);
6
- /**
7
- * Creates an atom that always returns a pending promise.
8
- *
9
- * @returns An atom that always returns a pending promise.
10
- */
11
- const atomWithPending = () => require_base_atom.baseAtom(pendingPromise);
12
-
13
- exports.atomWithPending = atomWithPending;
1
+ const e=require("./base-atom.cjs");let t=require("@stryke/helpers/noop");const n=new Promise(t.noop),r=()=>e.baseAtom(n);exports.atomWithPending=r;
@@ -1,14 +1,2 @@
1
- import { baseAtom } from "./base-atom.mjs";
2
- import { noop } from "@stryke/helpers/noop";
3
-
4
- // src/base/atoms/atom-with-pending.ts
5
- const pendingPromise = new Promise(noop);
6
- /**
7
- * Creates an atom that always returns a pending promise.
8
- *
9
- * @returns An atom that always returns a pending promise.
10
- */
11
- const atomWithPending = () => baseAtom(pendingPromise);
12
-
13
- export { atomWithPending };
1
+ import{baseAtom as e}from"./base-atom.mjs";import{noop as t}from"@stryke/helpers/noop";const n=new Promise(t),r=()=>e(n);export{r as atomWithPending};
14
2
  //# sourceMappingURL=atom-with-pending.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"atom-with-pending.mjs","names":[],"sources":[],"mappings":""}
1
+ {"version":3,"file":"atom-with-pending.mjs","names":["pendingPromise","noop","atomWithPending","baseAtom"],"sources":[],"mappings":""}
@@ -1,18 +1 @@
1
- const require_base_atom = require("./base-atom.cjs");
2
-
3
- // src/base/atoms/atom-with-refresh-and-default.ts
4
- const atomWithRefreshAndDefault = (refreshAtom, getDefault) => {
5
- const overwrittenAtom = require_base_atom.baseAtom(null);
6
- return require_base_atom.baseAtom((get) => {
7
- const lastState = get(overwrittenAtom);
8
- if (lastState && lastState.refresh === get(refreshAtom)) return lastState.value;
9
- return getDefault(get);
10
- }, (get, set, update) => {
11
- set(overwrittenAtom, {
12
- refresh: get(refreshAtom),
13
- value: update
14
- });
15
- });
16
- };
17
-
18
- exports.atomWithRefreshAndDefault = atomWithRefreshAndDefault;
1
+ const e=require("./base-atom.cjs"),t=(t,n)=>{let r=e.baseAtom(null);return e.baseAtom(e=>{let i=e(r);return i&&i.refresh===e(t)?i.value:n(e)},(e,n,i)=>{n(r,{refresh:e(t),value:i})})};exports.atomWithRefreshAndDefault=t;