New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jotai

Package Overview
Dependencies
Maintainers
2
Versions
186
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jotai - npm Package Compare versions

Comparing version 2.11.3 to 2.12.0

esm/vanilla/internals.d.mts

6

babel/plugin-debug-label.js

@@ -6,3 +6,3 @@ 'use strict';

function isAtom(t, callee, customAtomNames) {
if (customAtomNames === undefined) {
if (customAtomNames === void 0) {
customAtomNames = [];

@@ -31,3 +31,3 @@ }

var node = nodePath.node;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = (state.filename || 'unknown').replace(/\.\w+$/, '');

@@ -47,3 +47,3 @@ var displayName = filename.split('/').pop();

VariableDeclarator: function VariableDeclarator(path) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path.parentPath.insertAfter(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.identifier(path.node.id.name), t.identifier('debugLabel')), t.stringLiteral(path.node.id.name))));

@@ -50,0 +50,0 @@ }

@@ -6,3 +6,3 @@ 'use strict';

function isAtom(t, callee, customAtomNames) {
if (customAtomNames === undefined) {
if (customAtomNames === void 0) {
customAtomNames = [];

@@ -43,3 +43,3 @@ }

var node = nodePath.node;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = state.filename || 'unknown';

@@ -57,3 +57,3 @@ var atomKey = filename + "/defaultExport";

var _nodePath$parentPath$, _nodePath$parentPath$2;
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? undefined : options.customAtomNames) && ((_nodePath$parentPath$ = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$.isProgram() || (_nodePath$parentPath$2 = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$2.isExportNamedDeclaration())) {
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? void 0 : options.customAtomNames) && ((_nodePath$parentPath$ = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$.isProgram() || (_nodePath$parentPath$2 = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$2.isExportNamedDeclaration())) {
var filename = state.filename || 'unknown';

@@ -60,0 +60,0 @@ var atomKey = filename + "/" + nodePath.node.id.name;

@@ -6,3 +6,3 @@ 'use strict';

function isAtom(t, callee, customAtomNames) {
if (customAtomNames === undefined) {
if (customAtomNames === void 0) {
customAtomNames = [];

@@ -31,3 +31,3 @@ }

var node = nodePath.node;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = (state.filename || 'unknown').replace(/\.\w+$/, '');

@@ -47,3 +47,3 @@ var displayName = filename.split('/').pop();

VariableDeclarator: function VariableDeclarator(path) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path.parentPath.insertAfter(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.identifier(path.node.id.name), t.identifier('debugLabel')), t.stringLiteral(path.node.id.name))));

@@ -75,3 +75,3 @@ }

var node = nodePath.node;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = state.filename || 'unknown';

@@ -89,3 +89,3 @@ var atomKey = filename + "/defaultExport";

var _nodePath$parentPath$, _nodePath$parentPath$2;
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? undefined : options.customAtomNames) && ((_nodePath$parentPath$ = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$.isProgram() || (_nodePath$parentPath$2 = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$2.isExportNamedDeclaration())) {
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? void 0 : options.customAtomNames) && ((_nodePath$parentPath$ = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$.isProgram() || (_nodePath$parentPath$2 = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$2.isExportNamedDeclaration())) {
var filename = state.filename || 'unknown';

@@ -92,0 +92,0 @@ var atomKey = filename + "/" + nodePath.node.id.name;

@@ -6,3 +6,3 @@ {

"type": "commonjs",
"version": "2.11.3",
"version": "2.12.0",
"main": "./index.js",

@@ -9,0 +9,0 @@ "types": "./index.d.ts",

@@ -10,3 +10,3 @@ 'use client';

var store = ReactExports.useContext(StoreContext);
return (options == null ? undefined : options.store) || store || vanilla.getDefaultStore();
return (options == null ? void 0 : options.store) || store || vanilla.getDefaultStore();
};

@@ -26,3 +26,3 @@ var Provider = function Provider(_ref) {

var isPromiseLike = function isPromiseLike(x) {
return typeof (x == null ? undefined : x.then) === 'function';
return typeof (x == null ? void 0 : x.then) === 'function';
};

@@ -116,3 +116,3 @@ var attachPromiseMeta = function attachPromiseMeta(promise) {

}
var delay = options == null ? undefined : options.delay;
var delay = options == null ? void 0 : options.delay;
ReactExports.useEffect(function () {

@@ -119,0 +119,0 @@ var unsub = store.sub(atom, function () {

@@ -38,3 +38,3 @@ 'use client';

}
return callback.apply(undefined, [get, set].concat(args));
return callback.apply(void 0, [get, set].concat(args));
});

@@ -71,3 +71,3 @@ }, [callback]);

var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}

@@ -74,0 +74,0 @@ }

@@ -71,3 +71,3 @@ System.register(['@babel/core', '@babel/template'], (function (exports) {

const { node } = nodePath;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
const filename = (state.filename || "unknown").replace(/\.\w+$/, "");

@@ -90,3 +90,3 @@ let displayName = filename.split("/").pop();

VariableDeclarator(path) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path.parentPath.insertAfter(

@@ -93,0 +93,0 @@ t.expressionStatement(

@@ -1,4 +0,4 @@

System.register(["@babel/core","@babel/template"],function(m){"use strict";var r;return{setters:[null,function(o){r=o.default}],execute:function(){m("default",d);function o(t,i,e=[]){const n=[...u,...e];if(t.isIdentifier(i)&&n.includes(i.name))return!0;if(t.isMemberExpression(i)){const{property:a}=i;if(t.isIdentifier(a)&&n.includes(a.name))return!0}return!1}const u=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],c=r.default||r;function d({types:t},i){return{visitor:{ExportDefaultDeclaration(e,n){const{node:a}=e;if(t.isCallExpression(a.declaration)&&o(t,a.declaration.callee,i==null?void 0:i.customAtomNames)){const l=(n.filename||"unknown").replace(/\.\w+$/,"");let s=l.split("/").pop();s==="index"&&(s=l.slice(0,-6).split("/").pop()||"unknown");const f=c(`
System.register(["@babel/core","@babel/template"],function(m){"use strict";var r;return{setters:[null,function(o){r=o.default}],execute:function(){m("default",d);function o(t,i,e=[]){const n=[...c,...e];if(t.isIdentifier(i)&&n.includes(i.name))return!0;if(t.isMemberExpression(i)){const{property:a}=i;if(t.isIdentifier(a)&&n.includes(a.name))return!0}return!1}const c=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],u=r.default||r;function d({types:t},i){return{visitor:{ExportDefaultDeclaration(e,n){const{node:a}=e;if(t.isCallExpression(a.declaration)&&o(t,a.declaration.callee,i==null?void 0:i.customAtomNames)){const l=(n.filename||"unknown").replace(/\.\w+$/,"");let s=l.split("/").pop();s==="index"&&(s=l.slice(0,-6).split("/").pop()||"unknown");const f=u(`
const %%atomIdentifier%% = %%atom%%;
export default %%atomIdentifier%%
`)({atomIdentifier:t.identifier(s),atom:a.declaration});e.replaceWithMultiple(f)}},VariableDeclarator(e){t.isIdentifier(e.node.id)&&t.isCallExpression(e.node.init)&&o(t,e.node.init.callee,i==null?void 0:i.customAtomNames)&&e.parentPath.insertAfter(t.expressionStatement(t.assignmentExpression("=",t.memberExpression(t.identifier(e.node.id.name),t.identifier("debugLabel")),t.stringLiteral(e.node.id.name))))}}}}}}});

@@ -92,3 +92,3 @@ System.register(['@babel/core', '@babel/template'], (function (exports) {

const { node } = nodePath;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
const filename = state.filename || "unknown";

@@ -108,4 +108,4 @@ const atomKey = `${filename}/defaultExport`;

var _a, _b;
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? undefined : options.customAtomNames) && // Make sure atom declaration is in module scope
(((_a = nodePath.parentPath.parentPath) == null ? undefined : _a.isProgram()) || ((_b = nodePath.parentPath.parentPath) == null ? undefined : _b.isExportNamedDeclaration()))) {
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? void 0 : options.customAtomNames) && // Make sure atom declaration is in module scope
(((_a = nodePath.parentPath.parentPath) == null ? void 0 : _a.isProgram()) || ((_b = nodePath.parentPath.parentPath) == null ? void 0 : _b.isExportNamedDeclaration()))) {
const filename = state.filename || "unknown";

@@ -112,0 +112,0 @@ const atomKey = `${filename}/${nodePath.node.id.name}`;

@@ -1,2 +0,2 @@

System.register(["@babel/core","@babel/template"],function(c){"use strict";var m;return{setters:[null,function(n){m=n.default}],execute:function(){c("default",h);function n(e,a,t=[]){const o=[...u,...t];if(e.isIdentifier(a)&&o.includes(a.name))return!0;if(e.isMemberExpression(a)){const{property:i}=a;if(e.isIdentifier(i)&&o.includes(i.name))return!0}return!1}const u=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],l=m.default||m;function h({types:e},a){return{pre({opts:t}){if(!t.filename)throw new Error("Filename must be available")},visitor:{Program:{exit(t){const o=l(`
System.register(["@babel/core","@babel/template"],function(c){"use strict";var m;return{setters:[null,function(n){m=n.default}],execute:function(){c("default",u);function n(e,a,t=[]){const o=[...h,...t];if(e.isIdentifier(a)&&o.includes(a.name))return!0;if(e.isMemberExpression(a)){const{property:i}=a;if(e.isIdentifier(i)&&o.includes(i.name))return!0}return!1}const h=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],l=m.default||m;function u({types:e},a){return{pre({opts:t}){if(!t.filename)throw new Error("Filename must be available")},visitor:{Program:{exit(t){const o=l(`
globalThis.jotaiAtomCache = globalThis.jotaiAtomCache || {

@@ -3,0 +3,0 @@ cache: new Map(),

@@ -71,3 +71,3 @@ System.register(['@babel/core', '@babel/template'], (function (exports) {

const { node } = nodePath;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
const filename = (state.filename || "unknown").replace(/\.\w+$/, "");

@@ -90,3 +90,3 @@ let displayName = filename.split("/").pop();

VariableDeclarator(path) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path.parentPath.insertAfter(

@@ -137,3 +137,3 @@ t.expressionStatement(

const { node } = nodePath;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
const filename = state.filename || "unknown";

@@ -153,4 +153,4 @@ const atomKey = `${filename}/defaultExport`;

var _a, _b;
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? undefined : options.customAtomNames) && // Make sure atom declaration is in module scope
(((_a = nodePath.parentPath.parentPath) == null ? undefined : _a.isProgram()) || ((_b = nodePath.parentPath.parentPath) == null ? undefined : _b.isExportNamedDeclaration()))) {
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? void 0 : options.customAtomNames) && // Make sure atom declaration is in module scope
(((_a = nodePath.parentPath.parentPath) == null ? void 0 : _a.isProgram()) || ((_b = nodePath.parentPath.parentPath) == null ? void 0 : _b.isExportNamedDeclaration()))) {
const filename = state.filename || "unknown";

@@ -157,0 +157,0 @@ const atomKey = `${filename}/${nodePath.node.id.name}`;

@@ -1,5 +0,5 @@

System.register(["@babel/core","@babel/template"],function(d){"use strict";var s;return{setters:[null,function(l){s=l.default}],execute:function(){d("default",b);function l(e,i,t=[]){const n=[...u,...t];if(e.isIdentifier(i)&&n.includes(i.name))return!0;if(e.isMemberExpression(i)){const{property:a}=i;if(e.isIdentifier(a)&&n.includes(a.name))return!0}return!1}const u=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],f=s.default||s;function h({types:e},i){return{visitor:{ExportDefaultDeclaration(t,n){const{node:a}=t;if(e.isCallExpression(a.declaration)&&l(e,a.declaration.callee,i==null?void 0:i.customAtomNames)){const o=(n.filename||"unknown").replace(/\.\w+$/,"");let r=o.split("/").pop();r==="index"&&(r=o.slice(0,-6).split("/").pop()||"unknown");const c=f(`
System.register(["@babel/core","@babel/template"],function(d){"use strict";var s;return{setters:[null,function(l){s=l.default}],execute:function(){d("default",b);function l(e,i,t=[]){const o=[...u,...t];if(e.isIdentifier(i)&&o.includes(i.name))return!0;if(e.isMemberExpression(i)){const{property:a}=i;if(e.isIdentifier(a)&&o.includes(a.name))return!0}return!1}const u=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],f=s.default||s;function h({types:e},i){return{visitor:{ExportDefaultDeclaration(t,o){const{node:a}=t;if(e.isCallExpression(a.declaration)&&l(e,a.declaration.callee,i==null?void 0:i.customAtomNames)){const n=(o.filename||"unknown").replace(/\.\w+$/,"");let r=n.split("/").pop();r==="index"&&(r=n.slice(0,-6).split("/").pop()||"unknown");const c=f(`
const %%atomIdentifier%% = %%atom%%;
export default %%atomIdentifier%%
`)({atomIdentifier:e.identifier(r),atom:a.declaration});t.replaceWithMultiple(c)}},VariableDeclarator(t){e.isIdentifier(t.node.id)&&e.isCallExpression(t.node.init)&&l(e,t.node.init.callee,i==null?void 0:i.customAtomNames)&&t.parentPath.insertAfter(e.expressionStatement(e.assignmentExpression("=",e.memberExpression(e.identifier(t.node.id.name),e.identifier("debugLabel")),e.stringLiteral(t.node.id.name))))}}}}const m=s.default||s;function p({types:e},i){return{pre({opts:t}){if(!t.filename)throw new Error("Filename must be available")},visitor:{Program:{exit(t){const n=m(`
`)({atomIdentifier:e.identifier(r),atom:a.declaration});t.replaceWithMultiple(c)}},VariableDeclarator(t){e.isIdentifier(t.node.id)&&e.isCallExpression(t.node.init)&&l(e,t.node.init.callee,i==null?void 0:i.customAtomNames)&&t.parentPath.insertAfter(e.expressionStatement(e.assignmentExpression("=",e.memberExpression(e.identifier(t.node.id.name),e.identifier("debugLabel")),e.stringLiteral(t.node.id.name))))}}}}const m=s.default||s;function p({types:e},i){return{pre({opts:t}){if(!t.filename)throw new Error("Filename must be available")},visitor:{Program:{exit(t){const o=m(`
globalThis.jotaiAtomCache = globalThis.jotaiAtomCache || {

@@ -14,2 +14,2 @@ cache: new Map(),

},
}`)();t.unshiftContainer("body",n)}},ExportDefaultDeclaration(t,n){const{node:a}=t;if(e.isCallExpression(a.declaration)&&l(e,a.declaration.callee,i==null?void 0:i.customAtomNames)){const o=`${n.filename||"unknown"}/defaultExport`,r=m("export default globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomKey:e.stringLiteral(o),atom:a.declaration});t.replaceWith(r)}},VariableDeclarator(t,n){var a,o;if(e.isIdentifier(t.node.id)&&e.isCallExpression(t.node.init)&&l(e,t.node.init.callee,i==null?void 0:i.customAtomNames)&&((a=t.parentPath.parentPath)!=null&&a.isProgram()||(o=t.parentPath.parentPath)!=null&&o.isExportNamedDeclaration())){const r=`${n.filename||"unknown"}/${t.node.id.name}`,c=m("const %%atomIdentifier%% = globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomIdentifier:e.identifier(t.node.id.name),atomKey:e.stringLiteral(r),atom:t.node.init});t.parentPath.replaceWith(c)}}}}}function b(e,i){return{plugins:[[h,i],[p,i]]}}}}});
}`)();t.unshiftContainer("body",o)}},ExportDefaultDeclaration(t,o){const{node:a}=t;if(e.isCallExpression(a.declaration)&&l(e,a.declaration.callee,i==null?void 0:i.customAtomNames)){const n=`${o.filename||"unknown"}/defaultExport`,r=m("export default globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomKey:e.stringLiteral(n),atom:a.declaration});t.replaceWith(r)}},VariableDeclarator(t,o){var a,n;if(e.isIdentifier(t.node.id)&&e.isCallExpression(t.node.init)&&l(e,t.node.init.callee,i==null?void 0:i.customAtomNames)&&((a=t.parentPath.parentPath)!=null&&a.isProgram()||(n=t.parentPath.parentPath)!=null&&n.isExportNamedDeclaration())){const r=`${o.filename||"unknown"}/${t.node.id.name}`,c=m("const %%atomIdentifier%% = globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomIdentifier:e.identifier(t.node.id.name),atomKey:e.stringLiteral(r),atom:t.node.init});t.parentPath.replaceWith(c)}}}}}function b(e,i){return{plugins:[[h,i],[p,i]]}}}}});

@@ -29,7 +29,7 @@ 'use client';

const StoreContext = createContext(
undefined
void 0
);
const useStore = exports("useStore", (options) => {
const store = useContext(StoreContext);
return (options == null ? undefined : options.store) || store || getDefaultStore();
return (options == null ? void 0 : options.store) || store || getDefaultStore();
});

@@ -40,3 +40,3 @@ const Provider = exports("Provider", ({

}) => {
const storeRef = useRef(undefined);
const storeRef = useRef(void 0);
if (!store && !storeRef.current) {

@@ -54,3 +54,3 @@ storeRef.current = createStore();

const isPromiseLike = (x) => typeof (x == null ? undefined : x.then) === "function";
const isPromiseLike = (x) => typeof (x == null ? void 0 : x.then) === "function";
const attachPromiseMeta = (promise) => {

@@ -131,3 +131,3 @@ promise.status = "pending";

},
undefined,
void 0,
() => [store.get(atom), store, atom]

@@ -140,3 +140,3 @@ );

}
const delay = options == null ? undefined : options.delay;
const delay = options == null ? void 0 : options.delay;
useEffect(() => {

@@ -143,0 +143,0 @@ const unsub = store.sub(atom, () => {

'use client';
System.register(["react","jotai/vanilla"],function(C){"use strict";var S,b,h,A,p,y,P,j,k,m,w;return{setters:[function(u){S=u.createContext,b=u.useContext,h=u.useRef,A=u.createElement,p=u.default,y=u.useReducer,P=u.useEffect,j=u.useDebugValue,k=u.useCallback},function(u){m=u.getDefaultStore,w=u.createStore}],execute:function(){C({useAtom:T,useAtomValue:E,useSetAtom:R});const u=S(void 0),d=e=>{const t=b(u);return(e==null?void 0:e.store)||t||m()};C({useStore:d,Provider:({children:e,store:t})=>{const r=h(void 0);return!t&&!r.current&&(r.current=w()),A(u.Provider,{value:t||r.current},e)}});const g=e=>typeof(e==null?void 0:e.then)=="function",x=e=>{e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t})},V=p.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(x(e),e)}),v=new WeakMap,D=e=>{let t=v.get(e);return t||(t=new Promise((r,a)=>{let i=e;const l=s=>n=>{i===s&&r(n)},o=s=>n=>{i===s&&a(n)},c=s=>{"onCancel"in s&&typeof s.onCancel=="function"&&s.onCancel(n=>{g(n)?(v.set(n,t),i=n,n.then(l(n),o(n)),c(n)):r(n)})};e.then(l(e),o(e)),c(e)}),v.set(e,t)),t};function E(e,t){const r=d(t),[[a,i,l],o]=y(n=>{const f=r.get(e);return Object.is(n[0],f)&&n[1]===r&&n[2]===e?n:[f,r,e]},void 0,()=>[r.get(e),r,e]);let c=a;(i!==r||l!==e)&&(o(),c=r.get(e));const s=t==null?void 0:t.delay;if(P(()=>{const n=r.sub(e,()=>{if(typeof s=="number"){const f=r.get(e);g(f)&&x(D(f)),setTimeout(o,s);return}o()});return o(),n},[r,e,s]),j(c),g(c)){const n=D(c);return V(n)}return c}function R(e,t){const r=d(t);return k((...a)=>r.set(e,...a),[r,e])}function T(e,t){return[E(e,t),R(e,t)]}}}});
System.register(["react","jotai/vanilla"],function(C){"use strict";var S,b,h,A,p,y,P,j,k,m,w;return{setters:[function(u){S=u.createContext,b=u.useContext,h=u.useRef,A=u.createElement,p=u.default,y=u.useReducer,P=u.useEffect,j=u.useDebugValue,k=u.useCallback},function(u){m=u.getDefaultStore,w=u.createStore}],execute:function(){C({useAtom:T,useAtomValue:E,useSetAtom:R});const u=S(void 0),v=t=>{const e=b(u);return(t==null?void 0:t.store)||e||m()};C({useStore:v,Provider:({children:t,store:e})=>{const r=h(void 0);return!e&&!r.current&&(r.current=w()),A(u.Provider,{value:e||r.current},t)}});const d=t=>typeof(t==null?void 0:t.then)=="function",x=t=>{t.status="pending",t.then(e=>{t.status="fulfilled",t.value=e},e=>{t.status="rejected",t.reason=e})},V=p.use||(t=>{if(t.status==="pending")throw t;if(t.status==="fulfilled")return t.value;throw t.status==="rejected"?t.reason:(x(t),t)}),g=new WeakMap,D=t=>{let e=g.get(t);return e||(e=new Promise((r,a)=>{let i=t;const f=s=>n=>{i===s&&r(n)},c=s=>n=>{i===s&&a(n)},o=s=>{"onCancel"in s&&typeof s.onCancel=="function"&&s.onCancel(n=>{d(n)?(g.set(n,e),i=n,n.then(f(n),c(n)),o(n)):r(n)})};t.then(f(t),c(t)),o(t)}),g.set(t,e)),e};function E(t,e){const r=v(e),[[a,i,f],c]=y(n=>{const l=r.get(t);return Object.is(n[0],l)&&n[1]===r&&n[2]===t?n:[l,r,t]},void 0,()=>[r.get(t),r,t]);let o=a;(i!==r||f!==t)&&(c(),o=r.get(t));const s=e==null?void 0:e.delay;if(P(()=>{const n=r.sub(t,()=>{if(typeof s=="number"){const l=r.get(t);d(l)&&x(D(l)),setTimeout(c,s);return}c()});return c(),n},[r,t,s]),j(o),d(o)){const n=D(o);return V(n)}return o}function R(t,e){const r=v(e);return k((...a)=>r.set(t,...a),[r,t])}function T(t,e){return[E(t,e),R(t,e)]}}}});

@@ -62,3 +62,3 @@ 'use client';

for (const [atom, value] of values) {
if (!hydratedSet.has(atom) || (options == null ? undefined : options.dangerouslyForceHydrate)) {
if (!hydratedSet.has(atom) || (options == null ? void 0 : options.dangerouslyForceHydrate)) {
hydratedSet.add(atom);

@@ -65,0 +65,0 @@ store.set(atom, value);

@@ -1,4 +0,9 @@

System.register([], (function (exports) {
System.register(['jotai/vanilla/internals'], (function (exports) {
'use strict';
var INTERNAL_initializeStoreHooks, INTERNAL_buildStoreRev1;
return {
setters: [function (module) {
INTERNAL_initializeStoreHooks = module.INTERNAL_initializeStoreHooks;
INTERNAL_buildStoreRev1 = module.INTERNAL_buildStoreRev1;
}],
execute: (function () {

@@ -38,521 +43,37 @@

const isSelfAtom = (atom, a) => atom.unstable_is ? atom.unstable_is(a) : a === atom;
const hasInitialValue = (atom) => "init" in atom;
const isActuallyWritableAtom = (atom) => !!atom.write;
const cancelablePromiseMap = /* @__PURE__ */ new WeakMap();
const isPendingPromise = (value) => {
var _a;
return isPromiseLike(value) && !((_a = cancelablePromiseMap.get(value)) == null ? undefined : _a[1]);
};
const cancelPromise = (promise, nextValue) => {
const promiseState = cancelablePromiseMap.get(promise);
if (promiseState) {
promiseState[1] = true;
promiseState[0].forEach((fn) => fn(nextValue));
} else {
throw new Error("[Bug] cancelable promise not found");
}
};
const patchPromiseForCancelability = (promise) => {
if (cancelablePromiseMap.has(promise)) {
return;
}
const promiseState = [/* @__PURE__ */ new Set(), false];
cancelablePromiseMap.set(promise, promiseState);
const settle = () => {
promiseState[1] = true;
};
promise.then(settle, settle);
promise.onCancel = (fn) => {
promiseState[0].add(fn);
};
};
const isPromiseLike = (p) => typeof (p == null ? undefined : p.then) === "function";
const isAtomStateInitialized = (atomState) => "v" in atomState || "e" in atomState;
const returnAtomValue = (atomState) => {
if ("e" in atomState) {
throw atomState.e;
}
if (!("v" in atomState)) {
throw new Error("[Bug] atom state is not initialized");
}
return atomState.v;
};
const addPendingPromiseToDependency = (atom, promise, dependencyAtomState) => {
if (!dependencyAtomState.p.has(atom)) {
dependencyAtomState.p.add(atom);
promise.then(
() => {
dependencyAtomState.p.delete(atom);
},
() => {
dependencyAtomState.p.delete(atom);
const createDevStoreRev4 = () => {
let inRestoreAtom = 0;
const storeHooks = INTERNAL_initializeStoreHooks({});
const atomStateMap = /* @__PURE__ */ new WeakMap();
const mountedAtoms = /* @__PURE__ */ new WeakMap();
const store = INTERNAL_buildStoreRev1(
atomStateMap,
mountedAtoms,
void 0,
void 0,
void 0,
void 0,
storeHooks,
void 0,
(atom, get, set, ...args) => {
if (inRestoreAtom) {
return set(atom, ...args);
}
);
}
};
const addDependency = (atom, atomState, a, aState) => {
var _a;
if (a === atom) {
throw new Error("[Bug] atom cannot depend on itself");
}
atomState.d.set(a, aState.n);
if (isPendingPromise(atomState.v)) {
addPendingPromiseToDependency(atom, atomState.v, aState);
}
(_a = aState.m) == null ? undefined : _a.t.add(atom);
};
const INTERNAL_flushStoreHook = Symbol.for("JOTAI.EXPERIMENTAL.FLUSHSTOREHOOK");
const buildStore = (...storeArgs) => {
const [
getAtomState,
setAtomState,
atomRead,
atomWrite,
atomOnInit,
atomOnMount
] = storeArgs;
const ensureAtomState = (atom) => {
if (!atom) {
throw new Error("Atom is undefined or null");
return atom.write(get, set, ...args);
}
let atomState = getAtomState(atom);
if (!atomState) {
atomState = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 };
setAtomState(atom, atomState);
atomOnInit == null ? undefined : atomOnInit(atom, store);
}
return atomState;
};
const invalidatedAtoms = /* @__PURE__ */ new WeakMap();
const changedAtoms = /* @__PURE__ */ new Map();
const unmountCallbacks = /* @__PURE__ */ new Set();
const mountCallbacks = /* @__PURE__ */ new Set();
const flushCallbacks = () => {
var _a;
const errors = [];
const call = (fn) => {
try {
fn();
} catch (e) {
errors.push(e);
}
};
do {
(_a = store[INTERNAL_flushStoreHook]) == null ? undefined : _a.call(store);
const callbacks = /* @__PURE__ */ new Set();
const add = callbacks.add.bind(callbacks);
changedAtoms.forEach((atomState) => {
var _a2;
return (_a2 = atomState.m) == null ? undefined : _a2.l.forEach(add);
});
changedAtoms.clear();
unmountCallbacks.forEach(add);
unmountCallbacks.clear();
mountCallbacks.forEach(add);
mountCallbacks.clear();
callbacks.forEach(call);
if (changedAtoms.size) {
recomputeInvalidatedAtoms();
}
} while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
if (errors.length) {
throw errors[0];
}
};
const setAtomStateValueOrPromise = (atom, atomState, valueOrPromise) => {
const hasPrevValue = "v" in atomState;
const prevValue = atomState.v;
const pendingPromise = isPendingPromise(atomState.v) ? atomState.v : null;
if (isPromiseLike(valueOrPromise)) {
patchPromiseForCancelability(valueOrPromise);
for (const a of atomState.d.keys()) {
addPendingPromiseToDependency(atom, valueOrPromise, ensureAtomState(a));
}
atomState.v = valueOrPromise;
} else {
atomState.v = valueOrPromise;
}
delete atomState.e;
if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {
++atomState.n;
if (pendingPromise) {
cancelPromise(pendingPromise, valueOrPromise);
}
}
};
const readAtomState = (atom) => {
var _a, _b;
const atomState = ensureAtomState(atom);
if (isAtomStateInitialized(atomState)) {
if (atomState.m && invalidatedAtoms.get(atom) !== atomState.n) {
return atomState;
}
if (Array.from(atomState.d).every(
([a, n]) => (
// Recursively, read the atom state of the dependency, and
// check if the atom epoch number is unchanged
readAtomState(a).n === n
)
)) {
return atomState;
}
}
atomState.d.clear();
let isSync = true;
const mountDependenciesIfAsync = () => {
if (atomState.m) {
mountDependencies(atom, atomState);
recomputeInvalidatedAtoms();
flushCallbacks();
}
};
const getter = (a) => {
if (isSelfAtom(atom, a)) {
const aState2 = ensureAtomState(a);
if (!isAtomStateInitialized(aState2)) {
if (hasInitialValue(a)) {
setAtomStateValueOrPromise(a, aState2, a.init);
} else {
throw new Error("no atom init");
}
}
return returnAtomValue(aState2);
}
const aState = readAtomState(a);
try {
return returnAtomValue(aState);
} finally {
addDependency(atom, atomState, a, aState);
if (!isSync) {
mountDependenciesIfAsync();
}
}
};
let controller;
let setSelf;
const options = {
get signal() {
if (!controller) {
controller = new AbortController();
}
return controller.signal;
},
get setSelf() {
if (!isActuallyWritableAtom(atom)) {
console.warn("setSelf function cannot be used with read-only atom");
}
if (!setSelf && isActuallyWritableAtom(atom)) {
setSelf = (...args) => {
if (isSync) {
console.warn("setSelf function cannot be called in sync");
}
if (!isSync) {
return writeAtom(atom, ...args);
}
};
}
return setSelf;
}
};
const prevEpochNumber = atomState.n;
try {
const valueOrPromise = atomRead(atom, getter, options);
setAtomStateValueOrPromise(atom, atomState, valueOrPromise);
if (isPromiseLike(valueOrPromise)) {
(_a = valueOrPromise.onCancel) == null ? void 0 : _a.call(valueOrPromise, () => controller == null ? void 0 : controller.abort());
valueOrPromise.then(mountDependenciesIfAsync, mountDependenciesIfAsync);
}
return atomState;
} catch (error) {
delete atomState.v;
atomState.e = error;
++atomState.n;
return atomState;
} finally {
isSync = false;
if (prevEpochNumber !== atomState.n && invalidatedAtoms.get(atom) === prevEpochNumber) {
invalidatedAtoms.set(atom, atomState.n);
changedAtoms.set(atom, atomState);
(_b = atomState.u) == null ? undefined : _b.call(atomState);
}
}
};
const readAtom = (atom) => returnAtomValue(readAtomState(atom));
const getMountedOrPendingDependents = (atomState) => {
var _a;
const dependents = /* @__PURE__ */ new Map();
for (const a of ((_a = atomState.m) == null ? undefined : _a.t) || []) {
const aState = ensureAtomState(a);
if (aState.m) {
dependents.set(a, aState);
}
}
for (const atomWithPendingPromise of atomState.p) {
dependents.set(
atomWithPendingPromise,
ensureAtomState(atomWithPendingPromise)
);
}
return dependents;
};
const invalidateDependents = (atomState) => {
const stack = [atomState];
while (stack.length) {
const aState = stack.pop();
for (const [d, s] of getMountedOrPendingDependents(aState)) {
invalidatedAtoms.set(d, s.n);
stack.push(s);
}
}
};
const recomputeInvalidatedAtoms = () => {
var _a;
const topSortedReversed = [];
const visiting = /* @__PURE__ */ new WeakSet();
const visited = /* @__PURE__ */ new WeakSet();
const stack = Array.from(changedAtoms);
while (stack.length) {
const [a, aState] = stack[stack.length - 1];
if (visited.has(a)) {
stack.pop();
continue;
}
if (visiting.has(a)) {
if (invalidatedAtoms.get(a) === aState.n) {
topSortedReversed.push([a, aState, aState.n]);
} else {
invalidatedAtoms.delete(a);
changedAtoms.set(a, aState);
}
visited.add(a);
stack.pop();
continue;
}
visiting.add(a);
for (const [d, s] of getMountedOrPendingDependents(aState)) {
if (!visiting.has(d)) {
stack.push([d, s]);
}
}
}
for (let i = topSortedReversed.length - 1; i >= 0; --i) {
const [a, aState, prevEpochNumber] = topSortedReversed[i];
let hasChangedDeps = false;
for (const dep of aState.d.keys()) {
if (dep !== a && changedAtoms.has(dep)) {
hasChangedDeps = true;
break;
}
}
if (hasChangedDeps) {
readAtomState(a);
mountDependencies(a, aState);
if (prevEpochNumber !== aState.n) {
changedAtoms.set(a, aState);
(_a = aState.u) == null ? undefined : _a.call(aState);
}
}
invalidatedAtoms.delete(a);
}
};
const writeAtomState = (atom, ...args) => {
let isSync = true;
const getter = (a) => returnAtomValue(readAtomState(a));
const setter = (a, ...args2) => {
var _a;
const aState = ensureAtomState(a);
try {
if (isSelfAtom(atom, a)) {
if (!hasInitialValue(a)) {
throw new Error("atom not writable");
}
const prevEpochNumber = aState.n;
const v = args2[0];
setAtomStateValueOrPromise(a, aState, v);
mountDependencies(a, aState);
if (prevEpochNumber !== aState.n) {
changedAtoms.set(a, aState);
(_a = aState.u) == null ? void 0 : _a.call(aState);
invalidateDependents(aState);
}
return void 0;
} else {
return writeAtomState(a, ...args2);
}
} finally {
if (!isSync) {
recomputeInvalidatedAtoms();
flushCallbacks();
}
}
};
try {
return atomWrite(atom, getter, setter, ...args);
} finally {
isSync = false;
}
};
const writeAtom = (atom, ...args) => {
try {
return writeAtomState(atom, ...args);
} finally {
recomputeInvalidatedAtoms();
flushCallbacks();
}
};
const mountDependencies = (atom, atomState) => {
var _a;
if (atomState.m && !isPendingPromise(atomState.v)) {
for (const [a, n] of atomState.d) {
if (!atomState.m.d.has(a)) {
const aState = ensureAtomState(a);
const aMounted = mountAtom(a, aState);
aMounted.t.add(atom);
atomState.m.d.add(a);
if (n !== aState.n) {
changedAtoms.set(a, aState);
(_a = aState.u) == null ? undefined : _a.call(aState);
invalidateDependents(aState);
}
}
}
for (const a of atomState.m.d || []) {
if (!atomState.d.has(a)) {
atomState.m.d.delete(a);
const aMounted = unmountAtom(a, ensureAtomState(a));
aMounted == null ? undefined : aMounted.t.delete(atom);
}
}
}
};
const mountAtom = (atom, atomState) => {
var _a;
if (!atomState.m) {
readAtomState(atom);
for (const a of atomState.d.keys()) {
const aMounted = mountAtom(a, ensureAtomState(a));
aMounted.t.add(atom);
}
atomState.m = {
l: /* @__PURE__ */ new Set(),
d: new Set(atomState.d.keys()),
t: /* @__PURE__ */ new Set()
};
(_a = atomState.h) == null ? undefined : _a.call(atomState);
if (isActuallyWritableAtom(atom)) {
const mounted = atomState.m;
const processOnMount = () => {
let isSync = true;
const setAtom = (...args) => {
try {
return writeAtomState(atom, ...args);
} finally {
if (!isSync) {
recomputeInvalidatedAtoms();
flushCallbacks();
}
}
};
try {
const onUnmount = atomOnMount(atom, setAtom);
if (onUnmount) {
mounted.u = () => {
isSync = true;
try {
onUnmount();
} finally {
isSync = false;
}
};
}
} finally {
isSync = false;
}
};
mountCallbacks.add(processOnMount);
}
}
return atomState.m;
};
const unmountAtom = (atom, atomState) => {
var _a;
if (atomState.m && !atomState.m.l.size && !Array.from(atomState.m.t).some((a) => {
var _a2;
return (_a2 = ensureAtomState(a).m) == null ? undefined : _a2.d.has(atom);
})) {
const onUnmount = atomState.m.u;
if (onUnmount) {
unmountCallbacks.add(onUnmount);
}
delete atomState.m;
(_a = atomState.h) == null ? undefined : _a.call(atomState);
for (const a of atomState.d.keys()) {
const aMounted = unmountAtom(a, ensureAtomState(a));
aMounted == null ? undefined : aMounted.t.delete(atom);
}
return undefined;
}
return atomState.m;
};
const subscribeAtom = (atom, listener) => {
const atomState = ensureAtomState(atom);
const mounted = mountAtom(atom, atomState);
const listeners = mounted.l;
listeners.add(listener);
flushCallbacks();
return () => {
listeners.delete(listener);
unmountAtom(atom, atomState);
flushCallbacks();
};
};
const unstable_derive = (fn) => buildStore(...fn(...storeArgs));
const store = {
get: readAtom,
set: writeAtom,
sub: subscribeAtom,
unstable_derive
};
return store;
};
const deriveDevStoreRev4 = (store) => {
);
const debugMountedAtoms = /* @__PURE__ */ new Set();
let savedGetAtomState;
let inRestoreAtom = 0;
const derivedStore = store.unstable_derive((...storeArgs) => {
const [getAtomState, setAtomState, , atomWrite] = storeArgs;
savedGetAtomState = getAtomState;
storeArgs[1] = function devSetAtomState(atom, atomState) {
setAtomState(atom, atomState);
const originalMounted = atomState.h;
atomState.h = () => {
originalMounted == null ? undefined : originalMounted();
if (atomState.m) {
debugMountedAtoms.add(atom);
} else {
debugMountedAtoms.delete(atom);
}
};
};
storeArgs[3] = function devAtomWrite(atom, getter, setter, ...args) {
if (inRestoreAtom) {
return setter(atom, ...args);
}
return atomWrite(atom, getter, setter, ...args);
};
return storeArgs;
storeHooks.m.add(void 0, (atom) => {
debugMountedAtoms.add(atom);
const atomState = atomStateMap.get(atom);
atomState.m = mountedAtoms.get(atom);
});
const savedStoreSet = derivedStore.set;
storeHooks.u.add(void 0, (atom) => {
debugMountedAtoms.delete(atom);
const atomState = atomStateMap.get(atom);
delete atomState.m;
});
const devStore = {
// store dev methods (these are tentative and subject to change without notice)
dev4_get_internal_weak_map: () => ({
get: (atom) => {
const atomState = savedGetAtomState(atom);
if (!atomState || atomState.n === 0) {
return undefined;
}
return atomState;
}
}),
dev4_get_internal_weak_map: () => atomStateMap,
dev4_get_mounted_atoms: () => debugMountedAtoms,

@@ -566,3 +87,3 @@ dev4_restore_atoms: (values) => {

for (const [atom, value] of values) {
if (hasInitialValue(atom)) {
if ("init" in atom) {
set(atom, value);

@@ -576,25 +97,10 @@ }

};
savedStoreSet(restoreAtom);
store.set(restoreAtom);
}
};
return Object.assign(derivedStore, devStore);
return Object.assign(store, devStore);
};
const createStore = exports("createStore", () => {
const atomStateMap = /* @__PURE__ */ new WeakMap();
const store = buildStore(
(atom) => atomStateMap.get(atom),
(atom, atomState) => atomStateMap.set(atom, atomState).get(atom),
(atom, ...params) => atom.read(...params),
(atom, ...params) => atom.write(...params),
(atom, ...params) => {
var _a;
return (_a = atom.unstable_onInit) == null ? undefined : _a.call(atom, ...params);
},
(atom, ...params) => {
var _a;
return (_a = atom.onMount) == null ? undefined : _a.call(atom, ...params);
}
);
{
return deriveDevStoreRev4(store);
return createDevStoreRev4();
}

@@ -601,0 +107,0 @@ });

@@ -1,1 +0,1 @@

System.register([],function(_){"use strict";return{execute:function(){_("atom",V);let Q=0;function V(r,l){const u=`atom${++Q}`,c={toString(){return u}};return typeof r=="function"?c.read=r:(c.init=r,c.read=Y,c.write=Z),l&&(c.write=l),c}function Y(r){return r(this)}function Z(r,l,u){return l(this,typeof u=="function"?u(r(this)):u)}const J=(r,l)=>r.unstable_is?r.unstable_is(l):l===r,K=r=>"init"in r,N=r=>!!r.write,b=new WeakMap,C=r=>{var l;return I(r)&&!((l=b.get(r))!=null&&l[1])},x=(r,l)=>{const u=b.get(r);u&&(u[1]=!0,u[0].forEach(c=>c(l)))},nn=r=>{if(b.has(r))return;const l=[new Set,!1];b.set(r,l);const u=()=>{l[1]=!0};r.then(u,u),r.onCancel=c=>{l[0].add(c)}},I=r=>typeof(r==null?void 0:r.then)=="function",P=r=>"v"in r||"e"in r,E=r=>{if("e"in r)throw r.e;return r.v},U=(r,l,u)=>{u.p.has(r)||(u.p.add(r),l.then(()=>{u.p.delete(r)},()=>{u.p.delete(r)}))},en=(r,l,u,c)=>{var M;l.d.set(u,c.n),C(l.v)&&U(r,l.v,c),(M=c.m)==null||M.t.add(r)},tn=Symbol.for("JOTAI.EXPERIMENTAL.FLUSHSTOREHOOK"),X=(...r)=>{const[l,u,c,M,$,on]=r,v=t=>{let n=l(t);return n||(n={d:new Map,p:new Set,n:0},u(t,n),$==null||$(t,O)),n},y=new WeakMap,w=new Map,A=new Set,z=new Set,g=()=>{var t;const n=[],a=e=>{try{e()}catch(s){n.push(s)}};do{(t=O[tn])==null||t.call(O);const e=new Set,s=e.add.bind(e);w.forEach(o=>{var i;return(i=o.m)==null?void 0:i.l.forEach(s)}),w.clear(),A.forEach(s),A.clear(),z.forEach(s),z.clear(),e.forEach(a),w.size&&k()}while(w.size||A.size||z.size);if(n.length)throw n[0]},D=(t,n,a)=>{const e="v"in n,s=n.v,o=C(n.v)?n.v:null;if(I(a)){nn(a);for(const i of n.d.keys())U(t,a,v(i));n.v=a}else n.v=a;delete n.e,(!e||!Object.is(s,n.v))&&(++n.n,o&&x(o,a))},p=t=>{var n,a;const e=v(t);if(P(e)&&(e.m&&y.get(t)!==e.n||Array.from(e.d).every(([d,W])=>p(d).n===W)))return e;e.d.clear();let s=!0;const o=()=>{e.m&&(L(t,e),k(),g())},i=d=>{if(J(t,d)){const F=v(d);if(!P(F))if(K(d))D(d,F,d.init);else throw new Error("no atom init");return E(F)}const W=p(d);try{return E(W)}finally{en(t,e,d,W),s||o()}};let f,h;const S={get signal(){return f||(f=new AbortController),f.signal},get setSelf(){return!h&&N(t)&&(h=(...d)=>{if(!s)return G(t,...d)}),h}},m=e.n;try{const d=c(t,i,S);return D(t,e,d),I(d)&&((n=d.onCancel)==null||n.call(d,()=>f==null?void 0:f.abort()),d.then(o,o)),e}catch(d){return delete e.v,e.e=d,++e.n,e}finally{s=!1,m!==e.n&&y.get(t)===m&&(y.set(t,e.n),w.set(t,e),(a=e.u)==null||a.call(e))}},ln=t=>E(p(t)),q=t=>{var n;const a=new Map;for(const e of((n=t.m)==null?void 0:n.t)||[]){const s=v(e);s.m&&a.set(e,s)}for(const e of t.p)a.set(e,v(e));return a},B=t=>{const n=[t];for(;n.length;){const a=n.pop();for(const[e,s]of q(a))y.set(e,s.n),n.push(s)}},k=()=>{var t;const n=[],a=new WeakSet,e=new WeakSet,s=Array.from(w);for(;s.length;){const[o,i]=s[s.length-1];if(e.has(o)){s.pop();continue}if(a.has(o)){y.get(o)===i.n?n.push([o,i,i.n]):(y.delete(o),w.set(o,i)),e.add(o),s.pop();continue}a.add(o);for(const[f,h]of q(i))a.has(f)||s.push([f,h])}for(let o=n.length-1;o>=0;--o){const[i,f,h]=n[o];let S=!1;for(const m of f.d.keys())if(m!==i&&w.has(m)){S=!0;break}S&&(p(i),L(i,f),h!==f.n&&(w.set(i,f),(t=f.u)==null||t.call(f))),y.delete(i)}},H=(t,...n)=>{let a=!0;const e=o=>E(p(o)),s=(o,...i)=>{var f;const h=v(o);try{if(J(t,o)){if(!K(o))throw new Error("atom not writable");const S=h.n,m=i[0];D(o,h,m),L(o,h),S!==h.n&&(w.set(o,h),(f=h.u)==null||f.call(h),B(h));return}else return H(o,...i)}finally{a||(k(),g())}};try{return M(t,e,s,...n)}finally{a=!1}},G=(t,...n)=>{try{return H(t,...n)}finally{k(),g()}},L=(t,n)=>{var a;if(n.m&&!C(n.v)){for(const[e,s]of n.d)if(!n.m.d.has(e)){const o=v(e);R(e,o).t.add(t),n.m.d.add(e),s!==o.n&&(w.set(e,o),(a=o.u)==null||a.call(o),B(o))}for(const e of n.m.d||[])if(!n.d.has(e)){n.m.d.delete(e);const s=j(e,v(e));s==null||s.t.delete(t)}}},R=(t,n)=>{var a;if(!n.m){p(t);for(const e of n.d.keys())R(e,v(e)).t.add(t);if(n.m={l:new Set,d:new Set(n.d.keys()),t:new Set},(a=n.h)==null||a.call(n),N(t)){const e=n.m,s=()=>{let o=!0;const i=(...f)=>{try{return H(t,...f)}finally{o||(k(),g())}};try{const f=on(t,i);f&&(e.u=()=>{o=!0;try{f()}finally{o=!1}})}finally{o=!1}};z.add(s)}}return n.m},j=(t,n)=>{var a;if(n.m&&!n.m.l.size&&!Array.from(n.m.t).some(e=>{var s;return(s=v(e).m)==null?void 0:s.d.has(t)})){const e=n.m.u;e&&A.add(e),delete n.m,(a=n.h)==null||a.call(n);for(const s of n.d.keys()){const o=j(s,v(s));o==null||o.t.delete(t)}return}return n.m},O={get:ln,set:G,sub:(t,n)=>{const a=v(t),e=R(t,a).l;return e.add(n),g(),()=>{e.delete(n),j(t,a),g()}},unstable_derive:t=>X(...t(...r))};return O},rn=_("createStore",()=>{const r=new WeakMap;return X(l=>r.get(l),(l,u)=>r.set(l,u).get(l),(l,...u)=>l.read(...u),(l,...u)=>l.write(...u),(l,...u)=>{var c;return(c=l.unstable_onInit)==null?void 0:c.call(l,...u)},(l,...u)=>{var c;return(c=l.onMount)==null?void 0:c.call(l,...u)})});let T;const sn=_("getDefaultStore",()=>(T||(T=rn()),T))}}});
System.register(["jotai/vanilla/internals"],function(i){"use strict";var a;return{setters:[function(o){a=o.INTERNAL_buildStoreRev1}],execute:function(){i("atom",c);let o=0;function c(t,r){const n=`atom${++o}`,e={toString(){return n}};return typeof t=="function"?e.read=t:(e.init=t,e.read=f,e.write=s),r&&(e.write=r),e}function f(t){return t(this)}function s(t,r,n){return r(this,typeof n=="function"?n(t(this)):n)}const l=i("createStore",()=>a());let u;const S=i("getDefaultStore",()=>(u||(u=l()),u))}}});

@@ -56,3 +56,3 @@ System.register(['jotai/vanilla'], (function (exports) {

let item;
if (areEqual === undefined) {
if (areEqual === void 0) {
item = atoms.get(param);

@@ -67,4 +67,4 @@ } else {

}
if (item !== undefined) {
if (shouldRemove == null ? undefined : shouldRemove(item[1], param)) {
if (item !== void 0) {
if (shouldRemove == null ? void 0 : shouldRemove(item[1], param)) {
createAtom.remove(param);

@@ -93,3 +93,3 @@ } else {

createAtom.remove = (param) => {
if (areEqual === undefined) {
if (areEqual === void 0) {
if (!atoms.has(param)) return;

@@ -233,3 +233,3 @@ const [atom] = atoms.get(param);

const currArr = get(arrAtom);
const mapping2 = getMapping(currArr, prev2 == null ? undefined : prev2.arr);
const mapping2 = getMapping(currArr, prev2 == null ? void 0 : prev2.arr);
const index2 = mapping2.keyList.indexOf(key);

@@ -248,3 +248,3 @@ if (index2 < 0 || index2 >= currArr.length) {

const arr2 = get(arrAtom);
const mapping2 = getMapping(arr2, prev2 == null ? undefined : prev2.arr);
const mapping2 = getMapping(arr2, prev2 == null ? void 0 : prev2.arr);
const index2 = mapping2.keyList.indexOf(key);

@@ -276,3 +276,3 @@ if (index2 < 0 || index2 >= arr2.length) {

const arr = get(arrAtom);
const mapping = getMapping(arr, prev == null ? undefined : prev.arr);
const mapping = getMapping(arr, prev == null ? void 0 : prev.arr);
return mapping;

@@ -283,3 +283,3 @@ });

}
mappingAtom.init = undefined;
mappingAtom.init = void 0;
const splittedAtom = isWritable(arrAtom) ? atom(

@@ -373,3 +373,3 @@ (get) => get(mappingAtom).atomList,

const isPromiseLike = (x) => typeof (x == null ? undefined : x.then) === "function";
const isPromiseLike = (x) => typeof (x == null ? void 0 : x.then) === "function";
function withStorageValidator(validator) {

@@ -405,3 +405,3 @@ return (unknownStorage) => {

}
return undefined;
return void 0;
}

@@ -427,3 +427,3 @@ }, options) {

};
const str = (_b = (_a2 = getStringStorage()) == null ? undefined : _a2.getItem(key)) != null ? _b : null;
const str = (_b = (_a2 = getStringStorage()) == null ? void 0 : _a2.getItem(key)) != null ? _b : null;
if (isPromiseLike(str)) {

@@ -436,5 +436,5 @@ return str.then(parse);

var _a2;
return (_a2 = getStringStorage()) == null ? undefined : _a2.setItem(
return (_a2 = getStringStorage()) == null ? void 0 : _a2.setItem(
key,
JSON.stringify(newValue, options == null ? undefined : options.replacer)
JSON.stringify(newValue, options == null ? void 0 : options.replacer)
);

@@ -444,3 +444,3 @@ },

var _a2;
return (_a2 = getStringStorage()) == null ? undefined : _a2.removeItem(key);
return (_a2 = getStringStorage()) == null ? void 0 : _a2.removeItem(key);
}

@@ -486,3 +486,3 @@ };

function atomWithStorage(key, initialValue, storage = defaultStorage, options) {
const getOnInit = options == null ? undefined : options.getOnInit;
const getOnInit = options == null ? void 0 : options.getOnInit;
const baseAtom = atom(

@@ -533,3 +533,3 @@ getOnInit ? storage.getItem(key, initialValue) : initialValue

let observable = getObservable(get);
const itself = (_a = observable[Symbol.observable]) == null ? undefined : _a.call(observable);
const itself = (_a = observable[Symbol.observable]) == null ? void 0 : _a.call(observable);
if (itself) {

@@ -549,4 +549,4 @@ observable = itself;

lastResult = result;
resolve == null ? undefined : resolve(result);
setResult == null ? undefined : setResult(result);
resolve == null ? void 0 : resolve(result);
setResult == null ? void 0 : setResult(result);
};

@@ -567,7 +567,7 @@ let subscription;

});
if (isNotMounted() && (options == null ? undefined : options.unstable_timeout)) {
if (isNotMounted() && (options == null ? void 0 : options.unstable_timeout)) {
timer = setTimeout(() => {
if (subscription) {
subscription.unsubscribe();
subscription = undefined;
subscription = void 0;
}

@@ -593,6 +593,6 @@ }, options.unstable_timeout);

return () => {
setResult = undefined;
setResult = void 0;
if (subscription) {
subscription.unsubscribe();
subscription = undefined;
subscription = void 0;
}

@@ -694,3 +694,3 @@ };

const isPromise = (x) => x instanceof Promise;
const defaultFallback = () => undefined;
const defaultFallback = () => void 0;
function unwrap(anAtom, fallback = defaultFallback) {

@@ -713,3 +713,3 @@ return memo2(

}
if (promise !== (prev == null ? undefined : prev.p)) {
if (promise !== (prev == null ? void 0 : prev.p)) {
promise.then(

@@ -744,3 +744,3 @@ (v) => {

);
promiseAndValueAtom.init = undefined;
promiseAndValueAtom.init = void 0;
{

@@ -786,3 +786,3 @@ promiseAndValueAtom.debugPrivate = true;

function atomWithLazy(makeInitial) {
const a = atom(undefined);
const a = atom(void 0);
delete a.init;

@@ -789,0 +789,0 @@ Object.defineProperty(a, "init", {

@@ -1,1 +0,1 @@

System.register(["jotai/vanilla"],function(x){"use strict";var d;return{setters:[function(W){d=W.atom}],execute:function(){x({atomFamily:_,atomWithDefault:X,atomWithLazy:ft,atomWithObservable:et,atomWithReducer:$,atomWithRefresh:lt,atomWithReset:J,atomWithStorage:tt,createJSONStorage:z,freezeAtom:A,freezeAtomCreator:q,loadable:ot,selectAtom:K,splitAtom:U,unstable_withStorageValidator:Y,unwrap:ct});const W=x("RESET",Symbol(""));function J(t){const e=d(t,(i,a,c)=>{const u=typeof c=="function"?c(i(e)):c;a(e,u===W?t:u)});return e}function $(t,e){return d(t,function(i,a,c){a(this,e(i(this),c))})}function _(t,e){let i=null;const a=new Map,c=new Set,u=r=>{let o;if(e===void 0)o=a.get(r);else for(const[l,f]of a)if(e(l,r)){o=f;break}if(o!==void 0)if(i!=null&&i(o[1],r))u.remove(r);else return o[0];const s=t(r);return a.set(r,[s,Date.now()]),n("CREATE",r,s),s};function n(r,o,s){for(const l of c)l({type:r,param:o,atom:s})}return u.unstable_listen=r=>(c.add(r),()=>{c.delete(r)}),u.getParams=()=>a.keys(),u.remove=r=>{if(e===void 0){if(!a.has(r))return;const[o]=a.get(r);a.delete(r),n("REMOVE",r,o)}else for(const[o,[s]]of a)if(e(o,r)){a.delete(o),n("REMOVE",o,s);break}},u.setShouldRemove=r=>{if(i=r,!!i)for(const[o,[s,l]]of a)i(l,o)&&(a.delete(o),n("REMOVE",o,s))},u}const M=(t,e,i)=>(e.has(i)?e:e.set(i,t())).get(i),C=new WeakMap,F=(t,e,i,a)=>{const c=M(()=>new WeakMap,C,e),u=M(()=>new WeakMap,c,i);return M(t,u,a)};function K(t,e,i=Object.is){return F(()=>{const a=Symbol(),c=([n,r])=>{if(r===a)return e(n);const o=e(n,r);return i(r,o)?r:o},u=d(n=>{const r=n(u),o=n(t);return c([o,r])});return u.init=a,u},t,e,i)}const R=new WeakSet,L=t=>{if(typeof t!="object"||t===null)return;Object.freeze(t);const e=Object.getOwnPropertyNames(t);for(const i of e){const a=t[i];L(a)}return t};function A(t){if(R.has(t))return t;R.add(t);const e=t.read;if(t.read=function(i,a){return L(e.call(this,i,a))},"write"in t){const i=t.write;t.write=function(a,c,...u){return i.call(this,a,(...n)=>(n[0]===t&&(n[1]=L(n[1])),c(...n)),...u)}}return t}function q(t){return(...e)=>A(t(...e))}const P=(t,e,i)=>(e.has(i)?e:e.set(i,t())).get(i),B=new WeakMap,G=(t,e,i)=>{const a=P(()=>new WeakMap,B,e);return P(t,a,i)},H={},V=t=>!!t.write,Q=t=>typeof t=="function";function U(t,e){return G(()=>{const i=new WeakMap,a=(n,r)=>{let o=i.get(n);if(o)return o;const s=r&&i.get(r),l=[],f=[];return n.forEach((w,h)=>{const m=e?e(w):h;f[h]=m;const v=s&&s.atomList[s.keyList.indexOf(m)];if(v){l[h]=v;return}const O=p=>{const b=p(c),y=p(t),S=a(y,b==null?void 0:b.arr).keyList.indexOf(m);if(S<0||S>=y.length){const g=n[a(n).keyList.indexOf(m)];if(g)return g;throw new Error("splitAtom: index out of bounds for read")}return y[S]},E=(p,b,y)=>{const S=p(c),g=p(t),k=a(g,S==null?void 0:S.arr).keyList.indexOf(m);if(k<0||k>=g.length)throw new Error("splitAtom: index out of bounds for write");const N=Q(y)?y(g[k]):y;Object.is(g[k],N)||b(t,[...g.slice(0,k),N,...g.slice(k+1)])};l[h]=V(t)?d(O,E):d(O)}),s&&s.keyList.length===f.length&&s.keyList.every((w,h)=>w===f[h])?o=s:o={arr:n,atomList:l,keyList:f},i.set(n,o),o},c=d(n=>{const r=n(c),o=n(t);return a(o,r==null?void 0:r.arr)});c.init=void 0;const u=V(t)?d(n=>n(c).atomList,(n,r,o)=>{switch(o.type){case"remove":{const s=n(u).indexOf(o.atom);if(s>=0){const l=n(t);r(t,[...l.slice(0,s),...l.slice(s+1)])}break}case"insert":{const s=o.before?n(u).indexOf(o.before):n(u).length;if(s>=0){const l=n(t);r(t,[...l.slice(0,s),o.value,...l.slice(s)])}break}case"move":{const s=n(u).indexOf(o.atom),l=o.before?n(u).indexOf(o.before):n(u).length;if(s>=0&&l>=0){const f=n(t);s<l?r(t,[...f.slice(0,s),...f.slice(s+1,l),f[s],...f.slice(l)]):r(t,[...f.slice(0,l),f[s],...f.slice(l,s),...f.slice(s+1)])}break}}}):d(n=>n(c).atomList);return u},t,e||H)}function X(t){const e=Symbol(),i=d(e),a=d((c,u)=>{const n=c(i);return n!==e?n:t(c,u)},(c,u,n)=>{if(n===W)u(i,e);else if(typeof n=="function"){const r=c(a);u(i,n(r))}else u(i,n)});return a}const j=t=>typeof(t==null?void 0:t.then)=="function";function Y(t){return e=>({...e,getItem:(i,a)=>{const c=n=>t(n)?n:a,u=e.getItem(i,a);return j(u)?u.then(c):c(u)}})}function z(t=()=>{try{return window.localStorage}catch(i){return}},e){var i;let a,c;const u={getItem:(o,s)=>{var l,f;const w=m=>{if(m=m||"",a!==m){try{c=JSON.parse(m,e==null?void 0:e.reviver)}catch(v){return s}a=m}return c},h=(f=(l=t())==null?void 0:l.getItem(o))!=null?f:null;return j(h)?h.then(w):w(h)},setItem:(o,s)=>{var l;return(l=t())==null?void 0:l.setItem(o,JSON.stringify(s,e==null?void 0:e.replacer))},removeItem:o=>{var s;return(s=t())==null?void 0:s.removeItem(o)}},n=o=>(s,l,f)=>o(s,w=>{let h;try{h=JSON.parse(w||"")}catch(m){h=f}l(h)});let r;try{r=(i=t())==null?void 0:i.subscribe}catch(o){}return!r&&typeof window!="undefined"&&typeof window.addEventListener=="function"&&window.Storage&&(r=(o,s)=>{if(!(t()instanceof window.Storage))return()=>{};const l=f=>{f.storageArea===t()&&f.key===o&&s(f.newValue)};return window.addEventListener("storage",l),()=>{window.removeEventListener("storage",l)}}),r&&(u.subscribe=n(r)),u}const Z=z();function tt(t,e,i=Z,a){const c=a==null?void 0:a.getOnInit,u=d(c?i.getItem(t,e):e);return u.onMount=n=>{n(i.getItem(t,e));let r;return i.subscribe&&(r=i.subscribe(t,n,e)),r},d(n=>n(u),(n,r,o)=>{const s=typeof o=="function"?o(n(u)):o;return s===W?(r(u,e),i.removeItem(t)):s instanceof Promise?s.then(l=>(r(u,l),i.setItem(t,l))):(r(u,s),i.setItem(t,s))})}function et(t,e){const i=c=>{if("e"in c)throw c.e;return c.d},a=d(c=>{var u;let n=t(c);const r=(u=n[Symbol.observable])==null?void 0:u.call(n);r&&(n=r);let o;const s=()=>new Promise(b=>{o=b}),l=e&&"initialValue"in e?{d:typeof e.initialValue=="function"?e.initialValue():e.initialValue}:s();let f,w;const h=b=>{w=b,o==null||o(b),f==null||f(b)};let m,v;const O=()=>!f,E=()=>{m&&(clearTimeout(v),m.unsubscribe()),m=n.subscribe({next:b=>h({d:b}),error:b=>h({e:b}),complete:()=>{}}),O()&&e!=null&&e.unstable_timeout&&(v=setTimeout(()=>{m&&(m.unsubscribe(),m=void 0)},e.unstable_timeout))};E();const p=d(w||l);return p.onMount=b=>(f=b,w&&b(w),m?clearTimeout(v):E(),()=>{f=void 0,m&&(m.unsubscribe(),m=void 0)}),[p,n,s,E,O]});return d(c=>{const[u]=c(a),n=c(u);return n instanceof Promise?n.then(i):i(n)},(c,u,n)=>{const[r,o,s,l,f]=c(a);if("next"in o)f()&&(u(r,s()),l()),o.next(n);else throw new Error("observable is not subject")})}const I=new WeakMap,nt=(t,e)=>(I.has(e)?I:I.set(e,t())).get(e),rt=t=>t instanceof Promise,T={state:"loading"};function ot(t){return nt(()=>{const e=new WeakMap,i=d(0),a=d((c,{setSelf:u})=>{c(i);let n;try{n=c(t)}catch(l){return{state:"hasError",error:l}}if(!rt(n))return{state:"hasData",data:n};const r=n,o=e.get(r);return o||(r.then(l=>{e.set(r,{state:"hasData",data:l}),u()},l=>{e.set(r,{state:"hasError",error:l}),u()}),e.get(r)||(e.set(r,T),T))},(c,u)=>{u(i,n=>n+1)});return d(c=>c(a))},t)}const D=(t,e,i)=>(e.has(i)?e:e.set(i,t())).get(i),it=new WeakMap,st=(t,e,i)=>{const a=D(()=>new WeakMap,it,e);return D(t,a,i)},ut=t=>t instanceof Promise,at=()=>{};function ct(t,e=at){return st(()=>{const i=new WeakMap,a=new WeakMap,c=d(0),u=d((n,{setSelf:r})=>{n(c);const o=n(u),s=n(t);if(!ut(s))return{v:s};if(s!==(o==null?void 0:o.p)&&s.then(l=>{a.set(s,l),r()},l=>{i.set(s,l),r()}),i.has(s))throw i.get(s);return a.has(s)?{p:s,v:a.get(s)}:o&&"v"in o?{p:s,f:e(o.v),v:o.v}:{p:s,f:e()}},(n,r)=>{r(c,o=>o+1)});return u.init=void 0,d(n=>{const r=n(u);return"f"in r?r.f:r.v},(n,r,...o)=>r(t,...o))},t,e)}function lt(t,e){const i=d(0);return d((a,c)=>(a(i),t(a,c)),(a,c,...u)=>{if(u.length===0)c(i,n=>n+1);else if(e)return e(a,c,...u)})}function ft(t){const e=d(void 0);return delete e.init,Object.defineProperty(e,"init",{get(){return t()}}),e}}}});
System.register(["jotai/vanilla"],function(x){"use strict";var m;return{setters:[function(W){m=W.atom}],execute:function(){x({atomFamily:_,atomWithDefault:X,atomWithLazy:ft,atomWithObservable:et,atomWithReducer:$,atomWithRefresh:lt,atomWithReset:J,atomWithStorage:tt,createJSONStorage:z,freezeAtom:A,freezeAtomCreator:q,loadable:ot,selectAtom:K,splitAtom:U,unstable_withStorageValidator:Y,unwrap:ut});const W=x("RESET",Symbol(""));function J(t){const e=m(t,(i,c,u)=>{const a=typeof u=="function"?u(i(e)):u;c(e,a===W?t:a)});return e}function $(t,e){return m(t,function(i,c,u){c(this,e(i(this),u))})}function _(t,e){let i=null;const c=new Map,u=new Set,a=r=>{let o;if(e===void 0)o=c.get(r);else for(const[l,f]of c)if(e(l,r)){o=f;break}if(o!==void 0)if(i!=null&&i(o[1],r))a.remove(r);else return o[0];const s=t(r);return c.set(r,[s,Date.now()]),n("CREATE",r,s),s};function n(r,o,s){for(const l of u)l({type:r,param:o,atom:s})}return a.unstable_listen=r=>(u.add(r),()=>{u.delete(r)}),a.getParams=()=>c.keys(),a.remove=r=>{if(e===void 0){if(!c.has(r))return;const[o]=c.get(r);c.delete(r),n("REMOVE",r,o)}else for(const[o,[s]]of c)if(e(o,r)){c.delete(o),n("REMOVE",o,s);break}},a.setShouldRemove=r=>{if(i=r,!!i)for(const[o,[s,l]]of c)i(l,o)&&(c.delete(o),n("REMOVE",o,s))},a}const M=(t,e,i)=>(e.has(i)?e:e.set(i,t())).get(i),C=new WeakMap,F=(t,e,i,c)=>{const u=M(()=>new WeakMap,C,e),a=M(()=>new WeakMap,u,i);return M(t,a,c)};function K(t,e,i=Object.is){return F(()=>{const c=Symbol(),u=([n,r])=>{if(r===c)return e(n);const o=e(n,r);return i(r,o)?r:o},a=m(n=>{const r=n(a),o=n(t);return u([o,r])});return a.init=c,a},t,e,i)}const R=new WeakSet,L=t=>{if(typeof t!="object"||t===null)return;Object.freeze(t);const e=Object.getOwnPropertyNames(t);for(const i of e){const c=t[i];L(c)}return t};function A(t){if(R.has(t))return t;R.add(t);const e=t.read;if(t.read=function(i,c){return L(e.call(this,i,c))},"write"in t){const i=t.write;t.write=function(c,u,...a){return i.call(this,c,(...n)=>(n[0]===t&&(n[1]=L(n[1])),u(...n)),...a)}}return t}function q(t){return(...e)=>A(t(...e))}const P=(t,e,i)=>(e.has(i)?e:e.set(i,t())).get(i),B=new WeakMap,G=(t,e,i)=>{const c=P(()=>new WeakMap,B,e);return P(t,c,i)},H={},V=t=>!!t.write,Q=t=>typeof t=="function";function U(t,e){return G(()=>{const i=new WeakMap,c=(n,r)=>{let o=i.get(n);if(o)return o;const s=r&&i.get(r),l=[],f=[];return n.forEach((b,h)=>{const d=e?e(b):h;f[h]=d;const p=s&&s.atomList[s.keyList.indexOf(d)];if(p){l[h]=p;return}const O=g=>{const v=g(u),y=g(t),S=c(y,v==null?void 0:v.arr).keyList.indexOf(d);if(S<0||S>=y.length){const w=n[c(n).keyList.indexOf(d)];if(w)return w;throw new Error("splitAtom: index out of bounds for read")}return y[S]},E=(g,v,y)=>{const S=g(u),w=g(t),k=c(w,S==null?void 0:S.arr).keyList.indexOf(d);if(k<0||k>=w.length)throw new Error("splitAtom: index out of bounds for write");const N=Q(y)?y(w[k]):y;Object.is(w[k],N)||v(t,[...w.slice(0,k),N,...w.slice(k+1)])};l[h]=V(t)?m(O,E):m(O)}),s&&s.keyList.length===f.length&&s.keyList.every((b,h)=>b===f[h])?o=s:o={arr:n,atomList:l,keyList:f},i.set(n,o),o},u=m(n=>{const r=n(u),o=n(t);return c(o,r==null?void 0:r.arr)});u.init=void 0;const a=V(t)?m(n=>n(u).atomList,(n,r,o)=>{switch(o.type){case"remove":{const s=n(a).indexOf(o.atom);if(s>=0){const l=n(t);r(t,[...l.slice(0,s),...l.slice(s+1)])}break}case"insert":{const s=o.before?n(a).indexOf(o.before):n(a).length;if(s>=0){const l=n(t);r(t,[...l.slice(0,s),o.value,...l.slice(s)])}break}case"move":{const s=n(a).indexOf(o.atom),l=o.before?n(a).indexOf(o.before):n(a).length;if(s>=0&&l>=0){const f=n(t);s<l?r(t,[...f.slice(0,s),...f.slice(s+1,l),f[s],...f.slice(l)]):r(t,[...f.slice(0,l),f[s],...f.slice(l,s),...f.slice(s+1)])}break}}}):m(n=>n(u).atomList);return a},t,e||H)}function X(t){const e=Symbol(),i=m(e),c=m((u,a)=>{const n=u(i);return n!==e?n:t(u,a)},(u,a,n)=>{if(n===W)a(i,e);else if(typeof n=="function"){const r=u(c);a(i,n(r))}else a(i,n)});return c}const j=t=>typeof(t==null?void 0:t.then)=="function";function Y(t){return e=>({...e,getItem:(i,c)=>{const u=n=>t(n)?n:c,a=e.getItem(i,c);return j(a)?a.then(u):u(a)}})}function z(t=()=>{try{return window.localStorage}catch(i){return}},e){var i;let c,u;const a={getItem:(o,s)=>{var l,f;const b=d=>{if(d=d||"",c!==d){try{u=JSON.parse(d,e==null?void 0:e.reviver)}catch(p){return s}c=d}return u},h=(f=(l=t())==null?void 0:l.getItem(o))!=null?f:null;return j(h)?h.then(b):b(h)},setItem:(o,s)=>{var l;return(l=t())==null?void 0:l.setItem(o,JSON.stringify(s,e==null?void 0:e.replacer))},removeItem:o=>{var s;return(s=t())==null?void 0:s.removeItem(o)}},n=o=>(s,l,f)=>o(s,b=>{let h;try{h=JSON.parse(b||"")}catch(d){h=f}l(h)});let r;try{r=(i=t())==null?void 0:i.subscribe}catch(o){}return!r&&typeof window!="undefined"&&typeof window.addEventListener=="function"&&window.Storage&&(r=(o,s)=>{if(!(t()instanceof window.Storage))return()=>{};const l=f=>{f.storageArea===t()&&f.key===o&&s(f.newValue)};return window.addEventListener("storage",l),()=>{window.removeEventListener("storage",l)}}),r&&(a.subscribe=n(r)),a}const Z=z();function tt(t,e,i=Z,c){const u=c==null?void 0:c.getOnInit,a=m(u?i.getItem(t,e):e);return a.onMount=n=>{n(i.getItem(t,e));let r;return i.subscribe&&(r=i.subscribe(t,n,e)),r},m(n=>n(a),(n,r,o)=>{const s=typeof o=="function"?o(n(a)):o;return s===W?(r(a,e),i.removeItem(t)):s instanceof Promise?s.then(l=>(r(a,l),i.setItem(t,l))):(r(a,s),i.setItem(t,s))})}function et(t,e){const i=u=>{if("e"in u)throw u.e;return u.d},c=m(u=>{var a;let n=t(u);const r=(a=n[Symbol.observable])==null?void 0:a.call(n);r&&(n=r);let o;const s=()=>new Promise(v=>{o=v}),l=e&&"initialValue"in e?{d:typeof e.initialValue=="function"?e.initialValue():e.initialValue}:s();let f,b;const h=v=>{b=v,o==null||o(v),f==null||f(v)};let d,p;const O=()=>!f,E=()=>{d&&(clearTimeout(p),d.unsubscribe()),d=n.subscribe({next:v=>h({d:v}),error:v=>h({e:v}),complete:()=>{}}),O()&&e!=null&&e.unstable_timeout&&(p=setTimeout(()=>{d&&(d.unsubscribe(),d=void 0)},e.unstable_timeout))};E();const g=m(b||l);return g.onMount=v=>(f=v,b&&v(b),d?clearTimeout(p):E(),()=>{f=void 0,d&&(d.unsubscribe(),d=void 0)}),[g,n,s,E,O]});return m(u=>{const[a]=u(c),n=u(a);return n instanceof Promise?n.then(i):i(n)},(u,a,n)=>{const[r,o,s,l,f]=u(c);if("next"in o)f()&&(a(r,s()),l()),o.next(n);else throw new Error("observable is not subject")})}const I=new WeakMap,nt=(t,e)=>(I.has(e)?I:I.set(e,t())).get(e),rt=t=>t instanceof Promise,T={state:"loading"};function ot(t){return nt(()=>{const e=new WeakMap,i=m(0),c=m((u,{setSelf:a})=>{u(i);let n;try{n=u(t)}catch(l){return{state:"hasError",error:l}}if(!rt(n))return{state:"hasData",data:n};const r=n,o=e.get(r);return o||(r.then(l=>{e.set(r,{state:"hasData",data:l}),a()},l=>{e.set(r,{state:"hasError",error:l}),a()}),e.get(r)||(e.set(r,T),T))},(u,a)=>{a(i,n=>n+1)});return m(u=>u(c))},t)}const D=(t,e,i)=>(e.has(i)?e:e.set(i,t())).get(i),it=new WeakMap,st=(t,e,i)=>{const c=D(()=>new WeakMap,it,e);return D(t,c,i)},at=t=>t instanceof Promise,ct=()=>{};function ut(t,e=ct){return st(()=>{const i=new WeakMap,c=new WeakMap,u=m(0),a=m((n,{setSelf:r})=>{n(u);const o=n(a),s=n(t);if(!at(s))return{v:s};if(s!==(o==null?void 0:o.p)&&s.then(l=>{c.set(s,l),r()},l=>{i.set(s,l),r()}),i.has(s))throw i.get(s);return c.has(s)?{p:s,v:c.get(s)}:o&&"v"in o?{p:s,f:e(o.v),v:o.v}:{p:s,f:e()}},(n,r)=>{r(u,o=>o+1)});return a.init=void 0,m(n=>{const r=n(a);return"f"in r?r.f:r.v},(n,r,...o)=>r(t,...o))},t,e)}function lt(t,e){const i=m(0);return m((c,u)=>(c(i),t(c,u)),(c,u,...a)=>{if(a.length===0)u(i,n=>n+1);else if(e)return e(c,u,...a)})}function ft(t){const e=m(void 0);return delete e.init,Object.defineProperty(e,"init",{get(){return t()}}),e}}}});

@@ -1,95 +0,15 @@

import type { Atom, WritableAtom } from './atom';
type AnyValue = unknown;
type AnyError = unknown;
type AnyAtom = Atom<AnyValue>;
type OnUnmount = () => void;
type EpochNumber = number;
/**
* State tracked for mounted atoms. An atom is considered "mounted" if it has a
* subscriber, or is a transitive dependency of another atom that has a
* subscriber.
*
* The mounted state of an atom is freed once it is no longer mounted.
*/
type Mounted = {
/** Set of listeners to notify when the atom value changes. */
readonly l: Set<() => void>;
/** Set of mounted atoms that the atom depends on. */
readonly d: Set<AnyAtom>;
/** Set of mounted atoms that depends on the atom. */
readonly t: Set<AnyAtom>;
/** Function to run when the atom is unmounted. */
u?: () => void;
};
/**
* Mutable atom state,
* tracked for both mounted and unmounted atoms in a store.
*
* This should be garbage collectable.
* We can mutate it during atom read. (except for fields with TODO)
*/
type AtomState<Value = AnyValue> = {
/**
* Map of atoms that the atom depends on.
* The map value is the epoch number of the dependency.
*/
readonly d: Map<AnyAtom, EpochNumber>;
/**
* Set of atoms with pending promise that depend on the atom.
*
* This may cause memory leaks, but it's for the capability to continue promises
* TODO(daishi): revisit how to handle this
*/
readonly p: Set<AnyAtom>;
/** The epoch number of the atom. */
n: EpochNumber;
/**
* Object to store mounted state of the atom.
* TODO(daishi): move this out of AtomState
*/
m?: Mounted;
/**
* Listener to notify when the atom value is updated.
* This is an experimental API and will be changed in the next minor.
* TODO(daishi): move this store hooks
*/
u?: () => void;
/**
* Listener to notify when the atom is mounted or unmounted.
* This is an experimental API and will be changed in the next minor.
* TODO(daishi): move this store hooks
*/
h?: () => void;
/** Atom value */
v?: Value;
/** Atom error */
e?: AnyError;
};
type StoreArgs = readonly [
/*getAtomState*/ <Value>(atom: Atom<Value>) => AtomState<Value> | undefined,
/*setAtomState*/ <Value>(atom: Atom<Value>, atomState: AtomState<Value>) => void,
/*atomRead*/ <Value>(atom: Atom<Value>, ...params: Parameters<Atom<Value>['read']>) => Value,
/*atomWrite*/ <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...params: Parameters<WritableAtom<Value, Args, Result>['write']>) => Result,
/*atomOnInit*/ <Value>(atom: Atom<Value>, store: Store) => void,
/*atomOnMount*/ <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, setAtom: (...args: Args) => Result) => OnUnmount | void
];
type DevStoreRev4 = {
import type { Atom } from './atom';
import type { INTERNAL_AtomState, INTERNAL_Store } from 'jotai/vanilla/internals';
export type INTERNAL_PrdStore = INTERNAL_Store;
export type INTERNAL_DevStoreRev4 = {
dev4_get_internal_weak_map: () => {
get: (atom: AnyAtom) => AtomState | undefined;
get: (atom: Atom<unknown>) => INTERNAL_AtomState | undefined;
};
dev4_get_mounted_atoms: () => Set<AnyAtom>;
dev4_get_mounted_atoms: () => Set<Atom<unknown>>;
dev4_restore_atoms: (values: Iterable<readonly [
AnyAtom,
AnyValue
Atom<unknown>,
unknown
]>) => void;
};
type Store = {
get: <Value>(atom: Atom<Value>) => Value;
set: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
sub: (atom: AnyAtom, listener: () => void) => () => void;
unstable_derive: (fn: (...args: StoreArgs) => StoreArgs) => Store;
};
export type INTERNAL_DevStoreRev4 = DevStoreRev4;
export type INTERNAL_PrdStore = Store;
type PrdOrDevStore = Store | (Store & DevStoreRev4);
type PrdOrDevStore = INTERNAL_PrdStore | (INTERNAL_PrdStore & INTERNAL_DevStoreRev4);
export declare const createStore: () => PrdOrDevStore;

@@ -96,0 +16,0 @@ export declare const getDefaultStore: () => PrdOrDevStore;

@@ -1,95 +0,15 @@

import type { Atom, WritableAtom } from './atom';
type AnyValue = unknown;
type AnyError = unknown;
type AnyAtom = Atom<AnyValue>;
type OnUnmount = () => void;
type EpochNumber = number;
/**
* State tracked for mounted atoms. An atom is considered "mounted" if it has a
* subscriber, or is a transitive dependency of another atom that has a
* subscriber.
*
* The mounted state of an atom is freed once it is no longer mounted.
*/
type Mounted = {
/** Set of listeners to notify when the atom value changes. */
readonly l: Set<() => void>;
/** Set of mounted atoms that the atom depends on. */
readonly d: Set<AnyAtom>;
/** Set of mounted atoms that depends on the atom. */
readonly t: Set<AnyAtom>;
/** Function to run when the atom is unmounted. */
u?: () => void;
};
/**
* Mutable atom state,
* tracked for both mounted and unmounted atoms in a store.
*
* This should be garbage collectable.
* We can mutate it during atom read. (except for fields with TODO)
*/
type AtomState<Value = AnyValue> = {
/**
* Map of atoms that the atom depends on.
* The map value is the epoch number of the dependency.
*/
readonly d: Map<AnyAtom, EpochNumber>;
/**
* Set of atoms with pending promise that depend on the atom.
*
* This may cause memory leaks, but it's for the capability to continue promises
* TODO(daishi): revisit how to handle this
*/
readonly p: Set<AnyAtom>;
/** The epoch number of the atom. */
n: EpochNumber;
/**
* Object to store mounted state of the atom.
* TODO(daishi): move this out of AtomState
*/
m?: Mounted;
/**
* Listener to notify when the atom value is updated.
* This is an experimental API and will be changed in the next minor.
* TODO(daishi): move this store hooks
*/
u?: () => void;
/**
* Listener to notify when the atom is mounted or unmounted.
* This is an experimental API and will be changed in the next minor.
* TODO(daishi): move this store hooks
*/
h?: () => void;
/** Atom value */
v?: Value;
/** Atom error */
e?: AnyError;
};
type StoreArgs = readonly [
/*getAtomState*/ <Value>(atom: Atom<Value>) => AtomState<Value> | undefined,
/*setAtomState*/ <Value>(atom: Atom<Value>, atomState: AtomState<Value>) => void,
/*atomRead*/ <Value>(atom: Atom<Value>, ...params: Parameters<Atom<Value>['read']>) => Value,
/*atomWrite*/ <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...params: Parameters<WritableAtom<Value, Args, Result>['write']>) => Result,
/*atomOnInit*/ <Value>(atom: Atom<Value>, store: Store) => void,
/*atomOnMount*/ <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, setAtom: (...args: Args) => Result) => OnUnmount | void
];
type DevStoreRev4 = {
import type { Atom } from './atom';
import type { INTERNAL_AtomState, INTERNAL_Store } from 'jotai/vanilla/internals';
export type INTERNAL_PrdStore = INTERNAL_Store;
export type INTERNAL_DevStoreRev4 = {
dev4_get_internal_weak_map: () => {
get: (atom: AnyAtom) => AtomState | undefined;
get: (atom: Atom<unknown>) => INTERNAL_AtomState | undefined;
};
dev4_get_mounted_atoms: () => Set<AnyAtom>;
dev4_get_mounted_atoms: () => Set<Atom<unknown>>;
dev4_restore_atoms: (values: Iterable<readonly [
AnyAtom,
AnyValue
Atom<unknown>,
unknown
]>) => void;
};
type Store = {
get: <Value>(atom: Atom<Value>) => Value;
set: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
sub: (atom: AnyAtom, listener: () => void) => () => void;
unstable_derive: (fn: (...args: StoreArgs) => StoreArgs) => Store;
};
export type INTERNAL_DevStoreRev4 = DevStoreRev4;
export type INTERNAL_PrdStore = Store;
type PrdOrDevStore = Store | (Store & DevStoreRev4);
type PrdOrDevStore = INTERNAL_PrdStore | (INTERNAL_PrdStore & INTERNAL_DevStoreRev4);
export declare const createStore: () => PrdOrDevStore;

@@ -96,0 +16,0 @@ export declare const getDefaultStore: () => PrdOrDevStore;

@@ -8,3 +8,3 @@ (function (global, factory) {

function isAtom(t, callee, customAtomNames) {
if (customAtomNames === undefined) {
if (customAtomNames === void 0) {
customAtomNames = [];

@@ -33,3 +33,3 @@ }

var node = nodePath.node;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = (state.filename || 'unknown').replace(/\.\w+$/, '');

@@ -49,3 +49,3 @@ var displayName = filename.split('/').pop();

VariableDeclarator: function VariableDeclarator(path) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path.parentPath.insertAfter(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.identifier(path.node.id.name), t.identifier('debugLabel')), t.stringLiteral(path.node.id.name))));

@@ -52,0 +52,0 @@ }

@@ -8,3 +8,3 @@ (function (global, factory) {

function isAtom(t, callee, customAtomNames) {
if (customAtomNames === undefined) {
if (customAtomNames === void 0) {
customAtomNames = [];

@@ -45,3 +45,3 @@ }

var node = nodePath.node;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = state.filename || 'unknown';

@@ -59,3 +59,3 @@ var atomKey = filename + "/defaultExport";

var _nodePath$parentPath$, _nodePath$parentPath$2;
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? undefined : options.customAtomNames) && ((_nodePath$parentPath$ = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$.isProgram() || (_nodePath$parentPath$2 = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$2.isExportNamedDeclaration())) {
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? void 0 : options.customAtomNames) && ((_nodePath$parentPath$ = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$.isProgram() || (_nodePath$parentPath$2 = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$2.isExportNamedDeclaration())) {
var filename = state.filename || 'unknown';

@@ -62,0 +62,0 @@ var atomKey = filename + "/" + nodePath.node.id.name;

@@ -8,3 +8,3 @@ (function (global, factory) {

function isAtom(t, callee, customAtomNames) {
if (customAtomNames === undefined) {
if (customAtomNames === void 0) {
customAtomNames = [];

@@ -33,3 +33,3 @@ }

var node = nodePath.node;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = (state.filename || 'unknown').replace(/\.\w+$/, '');

@@ -49,3 +49,3 @@ var displayName = filename.split('/').pop();

VariableDeclarator: function VariableDeclarator(path) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path.parentPath.insertAfter(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.identifier(path.node.id.name), t.identifier('debugLabel')), t.stringLiteral(path.node.id.name))));

@@ -77,3 +77,3 @@ }

var node = nodePath.node;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? undefined : options.customAtomNames)) {
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = state.filename || 'unknown';

@@ -91,3 +91,3 @@ var atomKey = filename + "/defaultExport";

var _nodePath$parentPath$, _nodePath$parentPath$2;
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? undefined : options.customAtomNames) && ((_nodePath$parentPath$ = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$.isProgram() || (_nodePath$parentPath$2 = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$2.isExportNamedDeclaration())) {
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? void 0 : options.customAtomNames) && ((_nodePath$parentPath$ = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$.isProgram() || (_nodePath$parentPath$2 = nodePath.parentPath.parentPath) != null && _nodePath$parentPath$2.isExportNamedDeclaration())) {
var filename = state.filename || 'unknown';

@@ -94,0 +94,0 @@ var atomKey = filename + "/" + nodePath.node.id.name;

@@ -11,3 +11,3 @@ 'use client';

var store = ReactExports.useContext(StoreContext);
return (options == null ? undefined : options.store) || store || vanilla.getDefaultStore();
return (options == null ? void 0 : options.store) || store || vanilla.getDefaultStore();
};

@@ -27,3 +27,3 @@ var Provider = function Provider(_ref) {

var isPromiseLike = function isPromiseLike(x) {
return typeof (x == null ? undefined : x.then) === 'function';
return typeof (x == null ? void 0 : x.then) === 'function';
};

@@ -117,3 +117,3 @@ var attachPromiseMeta = function attachPromiseMeta(promise) {

}
var delay = options == null ? undefined : options.delay;
var delay = options == null ? void 0 : options.delay;
ReactExports.useEffect(function () {

@@ -120,0 +120,0 @@ var unsub = store.sub(atom, function () {

@@ -37,3 +37,3 @@ 'use client';

}
return callback.apply(undefined, [get, set].concat(args));
return callback.apply(void 0, [get, set].concat(args));
});

@@ -70,3 +70,3 @@ }, [callback]);

var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}

@@ -73,0 +73,0 @@ }

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jotaiVanilla = {}));
})(this, (function (exports) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jotai/vanilla/internals')) :
typeof define === 'function' && define.amd ? define(['exports', 'jotai/vanilla/internals'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jotaiVanilla = {}, global.jotaiVanillaInternals));
})(this, (function (exports, internals) { 'use strict';

@@ -60,585 +60,34 @@ var keyCount = 0;

var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
var isSelfAtom = function isSelfAtom(atom, a) {
return atom.unstable_is ? atom.unstable_is(a) : a === atom;
};
var hasInitialValue = function hasInitialValue(atom) {
return 'init' in atom;
};
var isActuallyWritableAtom = function isActuallyWritableAtom(atom) {
return !!atom.write;
};
var cancelablePromiseMap = new WeakMap();
var isPendingPromise = function isPendingPromise(value) {
var _cancelablePromiseMap;
return isPromiseLike(value) && !((_cancelablePromiseMap = cancelablePromiseMap.get(value)) != null && _cancelablePromiseMap[1]);
};
var cancelPromise = function cancelPromise(promise, nextValue) {
var promiseState = cancelablePromiseMap.get(promise);
if (promiseState) {
promiseState[1] = true;
promiseState[0].forEach(function (fn) {
return fn(nextValue);
});
} else {
throw new Error('[Bug] cancelable promise not found');
}
};
var patchPromiseForCancelability = function patchPromiseForCancelability(promise) {
if (cancelablePromiseMap.has(promise)) {
return;
}
var promiseState = [new Set(), false];
cancelablePromiseMap.set(promise, promiseState);
var settle = function settle() {
promiseState[1] = true;
};
promise.then(settle, settle);
promise.onCancel = function (fn) {
promiseState[0].add(fn);
};
};
var isPromiseLike = function isPromiseLike(p) {
return typeof (p == null ? undefined : p.then) === 'function';
};
var isAtomStateInitialized = function isAtomStateInitialized(atomState) {
return 'v' in atomState || 'e' in atomState;
};
var returnAtomValue = function returnAtomValue(atomState) {
if ('e' in atomState) {
throw atomState.e;
}
if (!('v' in atomState)) {
throw new Error('[Bug] atom state is not initialized');
}
return atomState.v;
};
var addPendingPromiseToDependency = function addPendingPromiseToDependency(atom, promise, dependencyAtomState) {
if (!dependencyAtomState.p.has(atom)) {
dependencyAtomState.p.add(atom);
promise.then(function () {
dependencyAtomState.p.delete(atom);
}, function () {
dependencyAtomState.p.delete(atom);
});
}
};
var addDependency = function addDependency(atom, atomState, a, aState) {
var _aState$m;
if (a === atom) {
throw new Error('[Bug] atom cannot depend on itself');
}
atomState.d.set(a, aState.n);
if (isPendingPromise(atomState.v)) {
addPendingPromiseToDependency(atom, atomState.v, aState);
}
(_aState$m = aState.m) == null || _aState$m.t.add(atom);
};
var INTERNAL_flushStoreHook = Symbol.for('JOTAI.EXPERIMENTAL.FLUSHSTOREHOOK');
var _buildStore = function buildStore() {
for (var _len = arguments.length, storeArgs = new Array(_len), _key = 0; _key < _len; _key++) {
storeArgs[_key] = arguments[_key];
}
var getAtomState = storeArgs[0],
setAtomState = storeArgs[1],
atomRead = storeArgs[2],
atomWrite = storeArgs[3],
atomOnInit = storeArgs[4],
atomOnMount = storeArgs[5];
var ensureAtomState = function ensureAtomState(atom) {
if (!atom) {
throw new Error('Atom is undefined or null');
var createDevStoreRev4 = function createDevStoreRev4() {
var inRestoreAtom = 0;
var storeHooks = internals.INTERNAL_initializeStoreHooks({});
var atomStateMap = new WeakMap();
var mountedAtoms = new WeakMap();
var store = internals.INTERNAL_buildStoreRev1(atomStateMap, mountedAtoms, undefined, undefined, undefined, undefined, storeHooks, undefined, function (atom, get, set) {
for (var _len = arguments.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
args[_key - 3] = arguments[_key];
}
var atomState = getAtomState(atom);
if (!atomState) {
atomState = {
d: new Map(),
p: new Set(),
n: 0
};
setAtomState(atom, atomState);
atomOnInit == null || atomOnInit(atom, store);
if (inRestoreAtom) {
return set.apply(void 0, [atom].concat(args));
}
return atomState;
};
var invalidatedAtoms = new WeakMap();
var changedAtoms = new Map();
var unmountCallbacks = new Set();
var mountCallbacks = new Set();
var flushCallbacks = function flushCallbacks() {
var errors = [];
var call = function call(fn) {
try {
fn();
} catch (e) {
errors.push(e);
}
};
var _loop = function _loop() {
var _INTERNAL_flushStoreH, _ref;
(_INTERNAL_flushStoreH = (_ref = store)[INTERNAL_flushStoreHook]) == null || _INTERNAL_flushStoreH.call(_ref);
var callbacks = new Set();
var add = callbacks.add.bind(callbacks);
changedAtoms.forEach(function (atomState) {
var _atomState$m;
return (_atomState$m = atomState.m) == null ? undefined : _atomState$m.l.forEach(add);
});
changedAtoms.clear();
unmountCallbacks.forEach(add);
unmountCallbacks.clear();
mountCallbacks.forEach(add);
mountCallbacks.clear();
callbacks.forEach(call);
if (changedAtoms.size) {
recomputeInvalidatedAtoms();
}
};
do {
_loop();
} while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
if (errors.length) {
throw errors[0];
}
};
var setAtomStateValueOrPromise = function setAtomStateValueOrPromise(atom, atomState, valueOrPromise) {
var hasPrevValue = 'v' in atomState;
var prevValue = atomState.v;
var pendingPromise = isPendingPromise(atomState.v) ? atomState.v : null;
if (isPromiseLike(valueOrPromise)) {
patchPromiseForCancelability(valueOrPromise);
for (var _iterator = _createForOfIteratorHelperLoose(atomState.d.keys()), _step; !(_step = _iterator()).done;) {
var a = _step.value;
addPendingPromiseToDependency(atom, valueOrPromise, ensureAtomState(a));
}
atomState.v = valueOrPromise;
} else {
atomState.v = valueOrPromise;
}
delete atomState.e;
if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {
++atomState.n;
if (pendingPromise) {
cancelPromise(pendingPromise, valueOrPromise);
}
}
};
var _readAtomState = function readAtomState(atom) {
var atomState = ensureAtomState(atom);
if (isAtomStateInitialized(atomState)) {
if (atomState.m && invalidatedAtoms.get(atom) !== atomState.n) {
return atomState;
}
if (Array.from(atomState.d).every(function (_ref2) {
var a = _ref2[0],
n = _ref2[1];
return (_readAtomState(a).n === n
);
})) {
return atomState;
}
}
atomState.d.clear();
var isSync = true;
var mountDependenciesIfAsync = function mountDependenciesIfAsync() {
if (atomState.m) {
mountDependencies(atom, atomState);
recomputeInvalidatedAtoms();
flushCallbacks();
}
};
var getter = function getter(a) {
if (isSelfAtom(atom, a)) {
var _aState = ensureAtomState(a);
if (!isAtomStateInitialized(_aState)) {
if (hasInitialValue(a)) {
setAtomStateValueOrPromise(a, _aState, a.init);
} else {
throw new Error('no atom init');
}
}
return returnAtomValue(_aState);
}
var aState = _readAtomState(a);
try {
return returnAtomValue(aState);
} finally {
addDependency(atom, atomState, a, aState);
if (!isSync) {
mountDependenciesIfAsync();
}
}
};
var controller;
var setSelf;
var options = {
get signal() {
if (!controller) {
controller = new AbortController();
}
return controller.signal;
},
get setSelf() {
if (!isActuallyWritableAtom(atom)) {
console.warn('setSelf function cannot be used with read-only atom');
}
if (!setSelf && isActuallyWritableAtom(atom)) {
setSelf = function setSelf() {
if (isSync) {
console.warn('setSelf function cannot be called in sync');
}
if (!isSync) {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return writeAtom.apply(undefined, [atom].concat(args));
}
};
}
return setSelf;
}
};
var prevEpochNumber = atomState.n;
try {
var valueOrPromise = atomRead(atom, getter, options);
setAtomStateValueOrPromise(atom, atomState, valueOrPromise);
if (isPromiseLike(valueOrPromise)) {
valueOrPromise.onCancel == null || valueOrPromise.onCancel(function () {
var _controller;
return (_controller = controller) == null ? void 0 : _controller.abort();
});
valueOrPromise.then(mountDependenciesIfAsync, mountDependenciesIfAsync);
}
return atomState;
} catch (error) {
delete atomState.v;
atomState.e = error;
++atomState.n;
return atomState;
} finally {
isSync = false;
if (prevEpochNumber !== atomState.n && invalidatedAtoms.get(atom) === prevEpochNumber) {
invalidatedAtoms.set(atom, atomState.n);
changedAtoms.set(atom, atomState);
atomState.u == null || atomState.u();
}
}
};
var readAtom = function readAtom(atom) {
return returnAtomValue(_readAtomState(atom));
};
var getMountedOrPendingDependents = function getMountedOrPendingDependents(atomState) {
var dependents = new Map();
for (var _iterator2 = _createForOfIteratorHelperLoose(((_atomState$m2 = atomState.m) == null ? undefined : _atomState$m2.t) || []), _step2; !(_step2 = _iterator2()).done;) {
var _atomState$m2;
var a = _step2.value;
var aState = ensureAtomState(a);
if (aState.m) {
dependents.set(a, aState);
}
}
for (var _iterator3 = _createForOfIteratorHelperLoose(atomState.p), _step3; !(_step3 = _iterator3()).done;) {
var atomWithPendingPromise = _step3.value;
dependents.set(atomWithPendingPromise, ensureAtomState(atomWithPendingPromise));
}
return dependents;
};
var invalidateDependents = function invalidateDependents(atomState) {
var stack = [atomState];
while (stack.length) {
var aState = stack.pop();
for (var _iterator4 = _createForOfIteratorHelperLoose(getMountedOrPendingDependents(aState)), _step4; !(_step4 = _iterator4()).done;) {
var _step4$value = _step4.value,
d = _step4$value[0],
s = _step4$value[1];
invalidatedAtoms.set(d, s.n);
stack.push(s);
}
}
};
var recomputeInvalidatedAtoms = function recomputeInvalidatedAtoms() {
var topSortedReversed = [];
var visiting = new WeakSet();
var visited = new WeakSet();
var stack = Array.from(changedAtoms);
while (stack.length) {
var _ref3 = stack[stack.length - 1],
a = _ref3[0],
aState = _ref3[1];
if (visited.has(a)) {
stack.pop();
continue;
}
if (visiting.has(a)) {
if (invalidatedAtoms.get(a) === aState.n) {
topSortedReversed.push([a, aState, aState.n]);
} else {
invalidatedAtoms.delete(a);
changedAtoms.set(a, aState);
}
visited.add(a);
stack.pop();
continue;
}
visiting.add(a);
for (var _iterator5 = _createForOfIteratorHelperLoose(getMountedOrPendingDependents(aState)), _step5; !(_step5 = _iterator5()).done;) {
var _step5$value = _step5.value,
d = _step5$value[0],
s = _step5$value[1];
if (!visiting.has(d)) {
stack.push([d, s]);
}
}
}
for (var i = topSortedReversed.length - 1; i >= 0; --i) {
var _ref4 = topSortedReversed[i],
_a = _ref4[0],
_aState2 = _ref4[1],
prevEpochNumber = _ref4[2];
var hasChangedDeps = false;
for (var _iterator6 = _createForOfIteratorHelperLoose(_aState2.d.keys()), _step6; !(_step6 = _iterator6()).done;) {
var dep = _step6.value;
if (dep !== _a && changedAtoms.has(dep)) {
hasChangedDeps = true;
break;
}
}
if (hasChangedDeps) {
_readAtomState(_a);
mountDependencies(_a, _aState2);
if (prevEpochNumber !== _aState2.n) {
changedAtoms.set(_a, _aState2);
_aState2.u == null || _aState2.u();
}
}
invalidatedAtoms.delete(_a);
}
};
var _writeAtomState = function writeAtomState(atom) {
var isSync = true;
var getter = function getter(a) {
return returnAtomValue(_readAtomState(a));
};
var setter = function setter(a) {
var aState = ensureAtomState(a);
try {
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
args[_key4 - 1] = arguments[_key4];
}
if (isSelfAtom(atom, a)) {
if (!hasInitialValue(a)) {
throw new Error('atom not writable');
}
var prevEpochNumber = aState.n;
var v = args[0];
setAtomStateValueOrPromise(a, aState, v);
mountDependencies(a, aState);
if (prevEpochNumber !== aState.n) {
changedAtoms.set(a, aState);
aState.u == null || aState.u();
invalidateDependents(aState);
}
return undefined;
} else {
return _writeAtomState.apply(void 0, [a].concat(args));
}
} finally {
if (!isSync) {
recomputeInvalidatedAtoms();
flushCallbacks();
}
}
};
try {
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];
}
return atomWrite.apply(void 0, [atom, getter, setter].concat(args));
} finally {
isSync = false;
}
};
var writeAtom = function writeAtom(atom) {
try {
for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
args[_key5 - 1] = arguments[_key5];
}
return _writeAtomState.apply(void 0, [atom].concat(args));
} finally {
recomputeInvalidatedAtoms();
flushCallbacks();
}
};
var mountDependencies = function mountDependencies(atom, atomState) {
if (atomState.m && !isPendingPromise(atomState.v)) {
for (var _iterator7 = _createForOfIteratorHelperLoose(atomState.d), _step7; !(_step7 = _iterator7()).done;) {
var _step7$value = _step7.value,
a = _step7$value[0],
n = _step7$value[1];
if (!atomState.m.d.has(a)) {
var aState = ensureAtomState(a);
var aMounted = _mountAtom(a, aState);
aMounted.t.add(atom);
atomState.m.d.add(a);
if (n !== aState.n) {
changedAtoms.set(a, aState);
aState.u == null || aState.u();
invalidateDependents(aState);
}
}
}
for (var _iterator8 = _createForOfIteratorHelperLoose(atomState.m.d || []), _step8; !(_step8 = _iterator8()).done;) {
var _a2 = _step8.value;
if (!atomState.d.has(_a2)) {
atomState.m.d.delete(_a2);
var _aMounted = _unmountAtom(_a2, ensureAtomState(_a2));
_aMounted == null || _aMounted.t.delete(atom);
}
}
}
};
var _mountAtom = function mountAtom(atom, atomState) {
if (!atomState.m) {
_readAtomState(atom);
for (var _iterator9 = _createForOfIteratorHelperLoose(atomState.d.keys()), _step9; !(_step9 = _iterator9()).done;) {
var a = _step9.value;
var aMounted = _mountAtom(a, ensureAtomState(a));
aMounted.t.add(atom);
}
atomState.m = {
l: new Set(),
d: new Set(atomState.d.keys()),
t: new Set()
};
atomState.h == null || atomState.h();
if (isActuallyWritableAtom(atom)) {
var mounted = atomState.m;
var processOnMount = function processOnMount() {
var isSync = true;
var setAtom = function setAtom() {
try {
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
return _writeAtomState.apply(void 0, [atom].concat(args));
} finally {
if (!isSync) {
recomputeInvalidatedAtoms();
flushCallbacks();
}
}
};
try {
var onUnmount = atomOnMount(atom, setAtom);
if (onUnmount) {
mounted.u = function () {
isSync = true;
try {
onUnmount();
} finally {
isSync = false;
}
};
}
} finally {
isSync = false;
}
};
mountCallbacks.add(processOnMount);
}
}
return atomState.m;
};
var _unmountAtom = function unmountAtom(atom, atomState) {
if (atomState.m && !atomState.m.l.size && !Array.from(atomState.m.t).some(function (a) {
var _ensureAtomState$m;
return (_ensureAtomState$m = ensureAtomState(a).m) == null ? undefined : _ensureAtomState$m.d.has(atom);
})) {
var onUnmount = atomState.m.u;
if (onUnmount) {
unmountCallbacks.add(onUnmount);
}
delete atomState.m;
atomState.h == null || atomState.h();
for (var _iterator10 = _createForOfIteratorHelperLoose(atomState.d.keys()), _step10; !(_step10 = _iterator10()).done;) {
var a = _step10.value;
var aMounted = _unmountAtom(a, ensureAtomState(a));
aMounted == null || aMounted.t.delete(atom);
}
return undefined;
}
return atomState.m;
};
var subscribeAtom = function subscribeAtom(atom, listener) {
var atomState = ensureAtomState(atom);
var mounted = _mountAtom(atom, atomState);
var listeners = mounted.l;
listeners.add(listener);
flushCallbacks();
return function () {
listeners.delete(listener);
_unmountAtom(atom, atomState);
flushCallbacks();
};
};
var unstable_derive = function unstable_derive(fn) {
return _buildStore.apply(undefined, fn.apply(undefined, storeArgs));
};
var store = {
get: readAtom,
set: writeAtom,
sub: subscribeAtom,
unstable_derive: unstable_derive
};
return store;
};
var deriveDevStoreRev4 = function deriveDevStoreRev4(store) {
return atom.write.apply(atom, [get, set].concat(args));
});
var debugMountedAtoms = new Set();
var savedGetAtomState;
var inRestoreAtom = 0;
var derivedStore = store.unstable_derive(function () {
for (var _len7 = arguments.length, storeArgs = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
storeArgs[_key7] = arguments[_key7];
}
var getAtomState = storeArgs[0],
setAtomState = storeArgs[1],
atomWrite = storeArgs[3];
savedGetAtomState = getAtomState;
storeArgs[1] = function devSetAtomState(atom, atomState) {
setAtomState(atom, atomState);
var originalMounted = atomState.h;
atomState.h = function () {
originalMounted == null || originalMounted();
if (atomState.m) {
debugMountedAtoms.add(atom);
} else {
debugMountedAtoms.delete(atom);
}
};
};
storeArgs[3] = function devAtomWrite(atom, getter, setter) {
for (var _len8 = arguments.length, args = new Array(_len8 > 3 ? _len8 - 3 : 0), _key8 = 3; _key8 < _len8; _key8++) {
args[_key8 - 3] = arguments[_key8];
}
if (inRestoreAtom) {
return setter.apply(undefined, [atom].concat(args));
}
return atomWrite.apply(undefined, [atom, getter, setter].concat(args));
};
return storeArgs;
storeHooks.m.add(undefined, function (atom) {
debugMountedAtoms.add(atom);
var atomState = atomStateMap.get(atom);
atomState.m = mountedAtoms.get(atom);
});
var savedStoreSet = derivedStore.set;
storeHooks.u.add(undefined, function (atom) {
debugMountedAtoms.delete(atom);
var atomState = atomStateMap.get(atom);
delete atomState.m;
});
var devStore = {
dev4_get_internal_weak_map: function dev4_get_internal_weak_map() {
return {
get: function get(atom) {
var atomState = savedGetAtomState(atom);
if (!atomState || atomState.n === 0) {
return undefined;
}
return atomState;
}
};
return atomStateMap;
},

@@ -656,8 +105,8 @@ dev4_get_mounted_atoms: function dev4_get_mounted_atoms() {

try {
for (var _iterator11 = _createForOfIteratorHelperLoose(values), _step11; !(_step11 = _iterator11()).done;) {
var _step11$value = _step11.value,
_atom = _step11$value[0],
value = _step11$value[1];
if (hasInitialValue(_atom)) {
set(_atom, value);
for (var _iterator = _createForOfIteratorHelperLoose(values), _step; !(_step = _iterator()).done;) {
var _step$value = _step.value,
atom = _step$value[0],
value = _step$value[1];
if ('init' in atom) {
set(atom, value);
}

@@ -670,36 +119,10 @@ }

};
savedStoreSet(restoreAtom);
store.set(restoreAtom);
}
};
return Object.assign(derivedStore, devStore);
return Object.assign(store, devStore);
};
var createStore = function createStore() {
var atomStateMap = new WeakMap();
var store = _buildStore(function (atom) {
return atomStateMap.get(atom);
}, function (atom, atomState) {
return atomStateMap.set(atom, atomState).get(atom);
}, function (atom) {
for (var _len9 = arguments.length, params = new Array(_len9 > 1 ? _len9 - 1 : 0), _key9 = 1; _key9 < _len9; _key9++) {
params[_key9 - 1] = arguments[_key9];
}
return atom.read.apply(atom, params);
}, function (atom) {
for (var _len10 = arguments.length, params = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) {
params[_key10 - 1] = arguments[_key10];
}
return atom.write.apply(atom, params);
}, function (atom) {
for (var _len11 = arguments.length, params = new Array(_len11 > 1 ? _len11 - 1 : 0), _key11 = 1; _key11 < _len11; _key11++) {
params[_key11 - 1] = arguments[_key11];
}
return atom.unstable_onInit == null ? undefined : atom.unstable_onInit.apply(atom, params);
}, function (atom) {
for (var _len12 = arguments.length, params = new Array(_len12 > 1 ? _len12 - 1 : 0), _key12 = 1; _key12 < _len12; _key12++) {
params[_key12 - 1] = arguments[_key12];
}
return atom.onMount == null ? undefined : atom.onMount.apply(atom, params);
});
{
return deriveDevStoreRev4(store);
return createDevStoreRev4();
}

@@ -712,4 +135,4 @@ };

{
var _ref5;
(_ref5 = globalThis).__JOTAI_DEFAULT_STORE__ || (_ref5.__JOTAI_DEFAULT_STORE__ = defaultStore);
var _ref;
(_ref = globalThis).__JOTAI_DEFAULT_STORE__ || (_ref.__JOTAI_DEFAULT_STORE__ = defaultStore);
if (globalThis.__JOTAI_DEFAULT_STORE__ !== defaultStore) {

@@ -716,0 +139,0 @@ console.warn('Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044');

@@ -1,1 +0,1 @@

!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((n="undefined"!=typeof globalThis?globalThis:n||self).jotaiVanilla={})}(this,(function(n){"use strict";var r=0;function e(n){return n(this)}function t(n,r,e){return r(this,"function"==typeof e?e(n(this)):e)}function a(n,r){(null==r||r>n.length)&&(r=n.length);for(var e=0,t=Array(r);e<r;e++)t[e]=n[e];return t}function o(n,r){var e="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(e)return(e=e.call(n)).next.bind(e);if(Array.isArray(n)||(e=function(n,r){if(n){if("string"==typeof n)return a(n,r);var e={}.toString.call(n).slice(8,-1);return"Object"===e&&n.constructor&&(e=n.constructor.name),"Map"===e||"Set"===e?Array.from(n):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?a(n,r):void 0}}(n))||r){e&&(n=e);var t=0;return function(){return t>=n.length?{done:!0}:{done:!1,value:n[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,i=function(n,r){return n.unstable_is?n.unstable_is(r):r===n},l=function(n){return"init"in n},f=function(n){return!!n.write},v=new WeakMap,c=function(n){var r;return d(n)&&!(null!=(r=v.get(n))&&r[1])},d=function(n){return"function"==typeof(null==n?void 0:n.then)},s=function(n){return"v"in n||"e"in n},y=function(n){if("e"in n)throw n.e;return n.v},h=function(n,r,e){e.p.has(n)||(e.p.add(n),r.then((function(){e.p.delete(n)}),(function(){e.p.delete(n)})))},p=Symbol.for("JOTAI.EXPERIMENTAL.FLUSHSTOREHOOK"),m=function(){for(var n=arguments.length,r=new Array(n),e=0;e<n;e++)r[e]=arguments[e];var t=r[0],a=r[1],u=r[2],w=r[3],g=r[4],b=r[5],A=function(n){var r=t(n);return r||(r={d:new Map,p:new Set,n:0},a(n,r),null==g||g(n,R)),r},S=new WeakMap,E=new Map,k=new Set,M=new Set,I=function(){var n=[],r=function(r){try{r()}catch(r){n.push(r)}},e=function(){var n,e;null==(n=(e=R)[p])||n.call(e);var t=new Set,a=t.add.bind(t);E.forEach((function(n){var r;return null==(r=n.m)?void 0:r.l.forEach(a)})),E.clear(),k.forEach(a),k.clear(),M.forEach(a),M.clear(),t.forEach(r),E.size&&C()};do{e()}while(E.size||k.size||M.size);if(n.length)throw n[0]},O=function(n,r,e){var t,a,u,i="v"in r,l=r.v,f=c(r.v)?r.v:null;if(d(e)){!function(n){if(!v.has(n)){var r=[new Set,!1];v.set(n,r);var e=function(){r[1]=!0};n.then(e,e),n.onCancel=function(n){r[0].add(n)}}}(e);for(var s,y=o(r.d.keys());!(s=y()).done;){var p=s.value;h(n,e,A(p))}r.v=e}else r.v=e;delete r.e,i&&Object.is(l,r.v)||(++r.n,f&&(t=f,a=e,(u=v.get(t))&&(u[1]=!0,u[0].forEach((function(n){return n(a)})))))},T=function(n){var r=A(n);if(s(r)){if(r.m&&S.get(n)!==r.n)return r;if(Array.from(r.d).every((function(n){var r=n[0],e=n[1];return T(r).n===e})))return r}r.d.clear();var e,t,a=!0,o=function(){r.m&&(x(n,r),C(),I())},v={get signal(){return e||(e=new AbortController),e.signal},get setSelf(){return!t&&f(n)&&(t=function(){if(!a){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return _.apply(void 0,[n].concat(e))}}),t}},p=r.n;try{var m=u(n,(function(e){if(i(n,e)){var t=A(e);if(!s(t)){if(!l(e))throw new Error("no atom init");O(e,t,e.init)}return y(t)}var u=T(e);try{return y(u)}finally{!function(n,r,e,t){var a;r.d.set(e,t.n),c(r.v)&&h(n,r.v,t),null==(a=t.m)||a.t.add(n)}(n,r,e,u),a||o()}}),v);return O(n,r,m),d(m)&&(null==m.onCancel||m.onCancel((function(){var n;return null==(n=e)?void 0:n.abort()})),m.then(o,o)),r}catch(n){return delete r.v,r.e=n,++r.n,r}finally{a=!1,p!==r.n&&S.get(n)===p&&(S.set(n,r.n),E.set(n,r),null==r.u||r.u())}},j=function(n){for(var r,e=new Map,t=o((null==(a=n.m)?void 0:a.t)||[]);!(r=t()).done;){var a,u=r.value,i=A(u);i.m&&e.set(u,i)}for(var l,f=o(n.p);!(l=f()).done;){var v=l.value;e.set(v,A(v))}return e},z=function(n){for(var r=[n];r.length;)for(var e,t=r.pop(),a=o(j(t));!(e=a()).done;){var u=e.value,i=u[0],l=u[1];S.set(i,l.n),r.push(l)}},C=function(){for(var n=[],r=new WeakSet,e=new WeakSet,t=Array.from(E);t.length;){var a=t[t.length-1],u=a[0],i=a[1];if(e.has(u))t.pop();else if(r.has(u))S.get(u)===i.n?n.push([u,i,i.n]):(S.delete(u),E.set(u,i)),e.add(u),t.pop();else{r.add(u);for(var l,f=o(j(i));!(l=f()).done;){var v=l.value,c=v[0],d=v[1];r.has(c)||t.push([c,d])}}}for(var s=n.length-1;s>=0;--s){for(var y,h=n[s],p=h[0],m=h[1],w=h[2],g=!1,b=o(m.d.keys());!(y=b()).done;){var A=y.value;if(A!==p&&E.has(A)){g=!0;break}}g&&(T(p),x(p,m),w!==m.n&&(E.set(p,m),null==m.u||m.u())),S.delete(p)}},W=function(n){var r=!0;try{for(var e=arguments.length,t=new Array(e>1?e-1:0),a=1;a<e;a++)t[a-1]=arguments[a];return w.apply(void 0,[n,function(n){return y(T(n))},function(e){var t=A(e);try{for(var a=arguments.length,o=new Array(a>1?a-1:0),u=1;u<a;u++)o[u-1]=arguments[u];if(i(n,e)){if(!l(e))throw new Error("atom not writable");var f=t.n,v=o[0];return O(e,t,v),x(e,t),void(f!==t.n&&(E.set(e,t),null==t.u||t.u(),z(t)))}return W.apply(void 0,[e].concat(o))}finally{r||(C(),I())}}].concat(t))}finally{r=!1}},_=function(n){try{for(var r=arguments.length,e=new Array(r>1?r-1:0),t=1;t<r;t++)e[t-1]=arguments[t];return W.apply(void 0,[n].concat(e))}finally{C(),I()}},x=function(n,r){if(r.m&&!c(r.v)){for(var e,t=o(r.d);!(e=t()).done;){var a=e.value,u=a[0],i=a[1];if(!r.m.d.has(u)){var l=A(u);H(u,l).t.add(n),r.m.d.add(u),i!==l.n&&(E.set(u,l),null==l.u||l.u(),z(l))}}for(var f,v=o(r.m.d||[]);!(f=v()).done;){var d=f.value;if(!r.d.has(d)){r.m.d.delete(d);var s=L(d,A(d));null==s||s.t.delete(n)}}}},H=function(n,r){if(!r.m){T(n);for(var e,t=o(r.d.keys());!(e=t()).done;){var a=e.value;H(a,A(a)).t.add(n)}if(r.m={l:new Set,d:new Set(r.d.keys()),t:new Set},null==r.h||r.h(),f(n)){var u=r.m;M.add((function(){var r=!0;try{var e=b(n,(function(){try{for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return W.apply(void 0,[n].concat(t))}finally{r||(C(),I())}}));e&&(u.u=function(){r=!0;try{e()}finally{r=!1}})}finally{r=!1}}))}}return r.m},L=function(n,r){if(!r.m||r.m.l.size||Array.from(r.m.t).some((function(r){var e;return null==(e=A(r).m)?void 0:e.d.has(n)})))return r.m;var e=r.m.u;e&&k.add(e),delete r.m,null==r.h||r.h();for(var t,a=o(r.d.keys());!(t=a()).done;){var u=t.value,i=L(u,A(u));null==i||i.t.delete(n)}},R={get:function(n){return y(T(n))},set:_,sub:function(n,r){var e=A(n),t=H(n,e).l;return t.add(r),I(),function(){t.delete(r),L(n,e),I()}},unstable_derive:function(n){return m.apply(void 0,n.apply(void 0,r))}};return R},w=function(){var n=new WeakMap,r=m((function(r){return n.get(r)}),(function(r,e){return n.set(r,e).get(r)}),(function(n){for(var r=arguments.length,e=new Array(r>1?r-1:0),t=1;t<r;t++)e[t-1]=arguments[t];return n.read.apply(n,e)}),(function(n){for(var r=arguments.length,e=new Array(r>1?r-1:0),t=1;t<r;t++)e[t-1]=arguments[t];return n.write.apply(n,e)}),(function(n){for(var r=arguments.length,e=new Array(r>1?r-1:0),t=1;t<r;t++)e[t-1]=arguments[t];return null==n.unstable_onInit?void 0:n.unstable_onInit.apply(n,e)}),(function(n){for(var r=arguments.length,e=new Array(r>1?r-1:0),t=1;t<r;t++)e[t-1]=arguments[t];return null==n.onMount?void 0:n.onMount.apply(n,e)}));return r};n.atom=function(n,a){var o="atom"+ ++r,u={toString:function(){return o}};return"function"==typeof n?u.read=n:(u.init=n,u.read=e,u.write=t),a&&(u.write=a),u},n.createStore=w,n.getDefaultStore=function(){return u||(u=w()),u}}));
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("jotai/vanilla/internals")):"function"==typeof define&&define.amd?define(["exports","jotai/vanilla/internals"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).jotaiVanilla={},t.jotaiVanillaInternals)}(this,(function(t,n){"use strict";var e=0;function i(t){return t(this)}function o(t,n,e){return n(this,"function"==typeof e?e(t(this)):e)}var r,a=function(){return n.INTERNAL_buildStoreRev1()};t.atom=function(t,n){var r="atom"+ ++e,a={toString:function(){return r}};return"function"==typeof t?a.read=t:(a.init=t,a.read=i,a.write=o),n&&(a.write=n),a},t.createStore=a,t.getDefaultStore=function(){return r||(r=a()),r}}));

@@ -58,3 +58,3 @@ (function (global, factory) {

var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}

@@ -166,3 +166,3 @@ }

function selectAtom(anAtom, selector, equalityFn) {
if (equalityFn === undefined) {
if (equalityFn === void 0) {
equalityFn = Object.is;

@@ -225,3 +225,3 @@ }

}
return set.apply(undefined, setArgs);
return set.apply(void 0, setArgs);
}].concat(args));

@@ -237,3 +237,3 @@ };

return function () {
return freezeAtom(createAtom.apply(undefined, arguments));
return freezeAtom(createAtom.apply(void 0, arguments));
};

@@ -281,3 +281,3 @@ }

var currArr = get(arrAtom);
var mapping = _getMapping(currArr, prev == null ? undefined : prev.arr);
var mapping = _getMapping(currArr, prev == null ? void 0 : prev.arr);
var index = mapping.keyList.indexOf(key);

@@ -296,3 +296,3 @@ if (index < 0 || index >= currArr.length) {

var arr = get(arrAtom);
var mapping = _getMapping(arr, prev == null ? undefined : prev.arr);
var mapping = _getMapping(arr, prev == null ? void 0 : prev.arr);
var index = mapping.keyList.indexOf(key);

@@ -326,3 +326,3 @@ if (index < 0 || index >= arr.length) {

var arr = get(arrAtom);
var mapping = _getMapping(arr, prev == null ? undefined : prev.arr);
var mapping = _getMapping(arr, prev == null ? void 0 : prev.arr);
return mapping;

@@ -404,3 +404,3 @@ });

var isPromiseLike = function isPromiseLike(x) {
return typeof (x == null ? undefined : x.then) === 'function';
return typeof (x == null ? void 0 : x.then) === 'function';
};

@@ -428,3 +428,3 @@ function withStorageValidator(validator) {

function createJSONStorage(getStringStorage, options) {
if (getStringStorage === undefined) {
if (getStringStorage === void 0) {
getStringStorage = function getStringStorage() {

@@ -460,3 +460,3 @@ try {

};
var str = (_getStringStorage$get = (_getStringStorage = getStringStorage()) == null ? undefined : _getStringStorage.getItem(key)) != null ? _getStringStorage$get : null;
var str = (_getStringStorage$get = (_getStringStorage = getStringStorage()) == null ? void 0 : _getStringStorage.getItem(key)) != null ? _getStringStorage$get : null;
if (isPromiseLike(str)) {

@@ -469,7 +469,7 @@ return str.then(parse);

var _getStringStorage2;
return (_getStringStorage2 = getStringStorage()) == null ? undefined : _getStringStorage2.setItem(key, JSON.stringify(newValue, options == null ? undefined : options.replacer));
return (_getStringStorage2 = getStringStorage()) == null ? void 0 : _getStringStorage2.setItem(key, JSON.stringify(newValue, options == null ? void 0 : options.replacer));
},
removeItem: function removeItem(key) {
var _getStringStorage3;
return (_getStringStorage3 = getStringStorage()) == null ? undefined : _getStringStorage3.removeItem(key);
return (_getStringStorage3 = getStringStorage()) == null ? void 0 : _getStringStorage3.removeItem(key);
}

@@ -518,6 +518,6 @@ };

function atomWithStorage(key, initialValue, storage, options) {
if (storage === undefined) {
if (storage === void 0) {
storage = defaultStorage;
}
var getOnInit = options == null ? undefined : options.getOnInit;
var getOnInit = options == null ? void 0 : options.getOnInit;
var baseAtom = vanilla.atom(getOnInit ? storage.getItem(key, initialValue) : initialValue);

@@ -565,3 +565,3 @@ {

var observable = getObservable(get);
var itself = (_observable$Symbol$ob = (_observable = observable)[Symbol.observable]) == null ? undefined : _observable$Symbol$ob.call(_observable);
var itself = (_observable$Symbol$ob = (_observable = observable)[Symbol.observable]) == null ? void 0 : _observable$Symbol$ob.call(_observable);
if (itself) {

@@ -764,3 +764,3 @@ observable = itself;

function unwrap(anAtom, fallback) {
if (fallback === undefined) {
if (fallback === void 0) {
fallback = defaultFallback;

@@ -785,3 +785,3 @@ }

}
if (promise !== (prev == null ? undefined : prev.p)) {
if (promise !== (prev == null ? void 0 : prev.p)) {
promise.then(function (v) {

@@ -834,3 +834,3 @@ promiseResultCache.set(promise, v);

}
return set.apply(undefined, [anAtom].concat(args));
return set.apply(void 0, [anAtom].concat(args));
});

@@ -857,3 +857,3 @@ }, anAtom, fallback);

} else if (write) {
return write.apply(undefined, [get, set].concat(args));
return write.apply(void 0, [get, set].concat(args));
}

@@ -860,0 +860,0 @@ });

'use strict';
var internals = require('jotai/vanilla/internals');
var keyCount = 0;

@@ -56,585 +58,34 @@ function atom(read, write) {

var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
var isSelfAtom = function isSelfAtom(atom, a) {
return atom.unstable_is ? atom.unstable_is(a) : a === atom;
};
var hasInitialValue = function hasInitialValue(atom) {
return 'init' in atom;
};
var isActuallyWritableAtom = function isActuallyWritableAtom(atom) {
return !!atom.write;
};
var cancelablePromiseMap = new WeakMap();
var isPendingPromise = function isPendingPromise(value) {
var _cancelablePromiseMap;
return isPromiseLike(value) && !((_cancelablePromiseMap = cancelablePromiseMap.get(value)) != null && _cancelablePromiseMap[1]);
};
var cancelPromise = function cancelPromise(promise, nextValue) {
var promiseState = cancelablePromiseMap.get(promise);
if (promiseState) {
promiseState[1] = true;
promiseState[0].forEach(function (fn) {
return fn(nextValue);
});
} else if (process.env.NODE_ENV !== 'production') {
throw new Error('[Bug] cancelable promise not found');
}
};
var patchPromiseForCancelability = function patchPromiseForCancelability(promise) {
if (cancelablePromiseMap.has(promise)) {
return;
}
var promiseState = [new Set(), false];
cancelablePromiseMap.set(promise, promiseState);
var settle = function settle() {
promiseState[1] = true;
};
promise.then(settle, settle);
promise.onCancel = function (fn) {
promiseState[0].add(fn);
};
};
var isPromiseLike = function isPromiseLike(p) {
return typeof (p == null ? undefined : p.then) === 'function';
};
var isAtomStateInitialized = function isAtomStateInitialized(atomState) {
return 'v' in atomState || 'e' in atomState;
};
var returnAtomValue = function returnAtomValue(atomState) {
if ('e' in atomState) {
throw atomState.e;
}
if (process.env.NODE_ENV !== 'production' && !('v' in atomState)) {
throw new Error('[Bug] atom state is not initialized');
}
return atomState.v;
};
var addPendingPromiseToDependency = function addPendingPromiseToDependency(atom, promise, dependencyAtomState) {
if (!dependencyAtomState.p.has(atom)) {
dependencyAtomState.p.add(atom);
promise.then(function () {
dependencyAtomState.p.delete(atom);
}, function () {
dependencyAtomState.p.delete(atom);
});
}
};
var addDependency = function addDependency(atom, atomState, a, aState) {
var _aState$m;
if (process.env.NODE_ENV !== 'production' && a === atom) {
throw new Error('[Bug] atom cannot depend on itself');
}
atomState.d.set(a, aState.n);
if (isPendingPromise(atomState.v)) {
addPendingPromiseToDependency(atom, atomState.v, aState);
}
(_aState$m = aState.m) == null || _aState$m.t.add(atom);
};
var INTERNAL_flushStoreHook = Symbol.for('JOTAI.EXPERIMENTAL.FLUSHSTOREHOOK');
var _buildStore = function buildStore() {
for (var _len = arguments.length, storeArgs = new Array(_len), _key = 0; _key < _len; _key++) {
storeArgs[_key] = arguments[_key];
}
var getAtomState = storeArgs[0],
setAtomState = storeArgs[1],
atomRead = storeArgs[2],
atomWrite = storeArgs[3],
atomOnInit = storeArgs[4],
atomOnMount = storeArgs[5];
var ensureAtomState = function ensureAtomState(atom) {
if (process.env.NODE_ENV !== 'production' && !atom) {
throw new Error('Atom is undefined or null');
var createDevStoreRev4 = function createDevStoreRev4() {
var inRestoreAtom = 0;
var storeHooks = internals.INTERNAL_initializeStoreHooks({});
var atomStateMap = new WeakMap();
var mountedAtoms = new WeakMap();
var store = internals.INTERNAL_buildStoreRev1(atomStateMap, mountedAtoms, undefined, undefined, undefined, undefined, storeHooks, undefined, function (atom, get, set) {
for (var _len = arguments.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
args[_key - 3] = arguments[_key];
}
var atomState = getAtomState(atom);
if (!atomState) {
atomState = {
d: new Map(),
p: new Set(),
n: 0
};
setAtomState(atom, atomState);
atomOnInit == null || atomOnInit(atom, store);
if (inRestoreAtom) {
return set.apply(void 0, [atom].concat(args));
}
return atomState;
};
var invalidatedAtoms = new WeakMap();
var changedAtoms = new Map();
var unmountCallbacks = new Set();
var mountCallbacks = new Set();
var flushCallbacks = function flushCallbacks() {
var errors = [];
var call = function call(fn) {
try {
fn();
} catch (e) {
errors.push(e);
}
};
var _loop = function _loop() {
var _INTERNAL_flushStoreH, _ref;
(_INTERNAL_flushStoreH = (_ref = store)[INTERNAL_flushStoreHook]) == null || _INTERNAL_flushStoreH.call(_ref);
var callbacks = new Set();
var add = callbacks.add.bind(callbacks);
changedAtoms.forEach(function (atomState) {
var _atomState$m;
return (_atomState$m = atomState.m) == null ? undefined : _atomState$m.l.forEach(add);
});
changedAtoms.clear();
unmountCallbacks.forEach(add);
unmountCallbacks.clear();
mountCallbacks.forEach(add);
mountCallbacks.clear();
callbacks.forEach(call);
if (changedAtoms.size) {
recomputeInvalidatedAtoms();
}
};
do {
_loop();
} while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
if (errors.length) {
throw errors[0];
}
};
var setAtomStateValueOrPromise = function setAtomStateValueOrPromise(atom, atomState, valueOrPromise) {
var hasPrevValue = 'v' in atomState;
var prevValue = atomState.v;
var pendingPromise = isPendingPromise(atomState.v) ? atomState.v : null;
if (isPromiseLike(valueOrPromise)) {
patchPromiseForCancelability(valueOrPromise);
for (var _iterator = _createForOfIteratorHelperLoose(atomState.d.keys()), _step; !(_step = _iterator()).done;) {
var a = _step.value;
addPendingPromiseToDependency(atom, valueOrPromise, ensureAtomState(a));
}
atomState.v = valueOrPromise;
} else {
atomState.v = valueOrPromise;
}
delete atomState.e;
if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {
++atomState.n;
if (pendingPromise) {
cancelPromise(pendingPromise, valueOrPromise);
}
}
};
var _readAtomState = function readAtomState(atom) {
var atomState = ensureAtomState(atom);
if (isAtomStateInitialized(atomState)) {
if (atomState.m && invalidatedAtoms.get(atom) !== atomState.n) {
return atomState;
}
if (Array.from(atomState.d).every(function (_ref2) {
var a = _ref2[0],
n = _ref2[1];
return (_readAtomState(a).n === n
);
})) {
return atomState;
}
}
atomState.d.clear();
var isSync = true;
var mountDependenciesIfAsync = function mountDependenciesIfAsync() {
if (atomState.m) {
mountDependencies(atom, atomState);
recomputeInvalidatedAtoms();
flushCallbacks();
}
};
var getter = function getter(a) {
if (isSelfAtom(atom, a)) {
var _aState = ensureAtomState(a);
if (!isAtomStateInitialized(_aState)) {
if (hasInitialValue(a)) {
setAtomStateValueOrPromise(a, _aState, a.init);
} else {
throw new Error('no atom init');
}
}
return returnAtomValue(_aState);
}
var aState = _readAtomState(a);
try {
return returnAtomValue(aState);
} finally {
addDependency(atom, atomState, a, aState);
if (!isSync) {
mountDependenciesIfAsync();
}
}
};
var controller;
var setSelf;
var options = {
get signal() {
if (!controller) {
controller = new AbortController();
}
return controller.signal;
},
get setSelf() {
if (process.env.NODE_ENV !== 'production' && !isActuallyWritableAtom(atom)) {
console.warn('setSelf function cannot be used with read-only atom');
}
if (!setSelf && isActuallyWritableAtom(atom)) {
setSelf = function setSelf() {
if (process.env.NODE_ENV !== 'production' && isSync) {
console.warn('setSelf function cannot be called in sync');
}
if (!isSync) {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return writeAtom.apply(undefined, [atom].concat(args));
}
};
}
return setSelf;
}
};
var prevEpochNumber = atomState.n;
try {
var valueOrPromise = atomRead(atom, getter, options);
setAtomStateValueOrPromise(atom, atomState, valueOrPromise);
if (isPromiseLike(valueOrPromise)) {
valueOrPromise.onCancel == null || valueOrPromise.onCancel(function () {
var _controller;
return (_controller = controller) == null ? void 0 : _controller.abort();
});
valueOrPromise.then(mountDependenciesIfAsync, mountDependenciesIfAsync);
}
return atomState;
} catch (error) {
delete atomState.v;
atomState.e = error;
++atomState.n;
return atomState;
} finally {
isSync = false;
if (prevEpochNumber !== atomState.n && invalidatedAtoms.get(atom) === prevEpochNumber) {
invalidatedAtoms.set(atom, atomState.n);
changedAtoms.set(atom, atomState);
atomState.u == null || atomState.u();
}
}
};
var readAtom = function readAtom(atom) {
return returnAtomValue(_readAtomState(atom));
};
var getMountedOrPendingDependents = function getMountedOrPendingDependents(atomState) {
var dependents = new Map();
for (var _iterator2 = _createForOfIteratorHelperLoose(((_atomState$m2 = atomState.m) == null ? undefined : _atomState$m2.t) || []), _step2; !(_step2 = _iterator2()).done;) {
var _atomState$m2;
var a = _step2.value;
var aState = ensureAtomState(a);
if (aState.m) {
dependents.set(a, aState);
}
}
for (var _iterator3 = _createForOfIteratorHelperLoose(atomState.p), _step3; !(_step3 = _iterator3()).done;) {
var atomWithPendingPromise = _step3.value;
dependents.set(atomWithPendingPromise, ensureAtomState(atomWithPendingPromise));
}
return dependents;
};
var invalidateDependents = function invalidateDependents(atomState) {
var stack = [atomState];
while (stack.length) {
var aState = stack.pop();
for (var _iterator4 = _createForOfIteratorHelperLoose(getMountedOrPendingDependents(aState)), _step4; !(_step4 = _iterator4()).done;) {
var _step4$value = _step4.value,
d = _step4$value[0],
s = _step4$value[1];
invalidatedAtoms.set(d, s.n);
stack.push(s);
}
}
};
var recomputeInvalidatedAtoms = function recomputeInvalidatedAtoms() {
var topSortedReversed = [];
var visiting = new WeakSet();
var visited = new WeakSet();
var stack = Array.from(changedAtoms);
while (stack.length) {
var _ref3 = stack[stack.length - 1],
a = _ref3[0],
aState = _ref3[1];
if (visited.has(a)) {
stack.pop();
continue;
}
if (visiting.has(a)) {
if (invalidatedAtoms.get(a) === aState.n) {
topSortedReversed.push([a, aState, aState.n]);
} else {
invalidatedAtoms.delete(a);
changedAtoms.set(a, aState);
}
visited.add(a);
stack.pop();
continue;
}
visiting.add(a);
for (var _iterator5 = _createForOfIteratorHelperLoose(getMountedOrPendingDependents(aState)), _step5; !(_step5 = _iterator5()).done;) {
var _step5$value = _step5.value,
d = _step5$value[0],
s = _step5$value[1];
if (!visiting.has(d)) {
stack.push([d, s]);
}
}
}
for (var i = topSortedReversed.length - 1; i >= 0; --i) {
var _ref4 = topSortedReversed[i],
_a = _ref4[0],
_aState2 = _ref4[1],
prevEpochNumber = _ref4[2];
var hasChangedDeps = false;
for (var _iterator6 = _createForOfIteratorHelperLoose(_aState2.d.keys()), _step6; !(_step6 = _iterator6()).done;) {
var dep = _step6.value;
if (dep !== _a && changedAtoms.has(dep)) {
hasChangedDeps = true;
break;
}
}
if (hasChangedDeps) {
_readAtomState(_a);
mountDependencies(_a, _aState2);
if (prevEpochNumber !== _aState2.n) {
changedAtoms.set(_a, _aState2);
_aState2.u == null || _aState2.u();
}
}
invalidatedAtoms.delete(_a);
}
};
var _writeAtomState = function writeAtomState(atom) {
var isSync = true;
var getter = function getter(a) {
return returnAtomValue(_readAtomState(a));
};
var setter = function setter(a) {
var aState = ensureAtomState(a);
try {
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
args[_key4 - 1] = arguments[_key4];
}
if (isSelfAtom(atom, a)) {
if (!hasInitialValue(a)) {
throw new Error('atom not writable');
}
var prevEpochNumber = aState.n;
var v = args[0];
setAtomStateValueOrPromise(a, aState, v);
mountDependencies(a, aState);
if (prevEpochNumber !== aState.n) {
changedAtoms.set(a, aState);
aState.u == null || aState.u();
invalidateDependents(aState);
}
return undefined;
} else {
return _writeAtomState.apply(void 0, [a].concat(args));
}
} finally {
if (!isSync) {
recomputeInvalidatedAtoms();
flushCallbacks();
}
}
};
try {
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];
}
return atomWrite.apply(void 0, [atom, getter, setter].concat(args));
} finally {
isSync = false;
}
};
var writeAtom = function writeAtom(atom) {
try {
for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
args[_key5 - 1] = arguments[_key5];
}
return _writeAtomState.apply(void 0, [atom].concat(args));
} finally {
recomputeInvalidatedAtoms();
flushCallbacks();
}
};
var mountDependencies = function mountDependencies(atom, atomState) {
if (atomState.m && !isPendingPromise(atomState.v)) {
for (var _iterator7 = _createForOfIteratorHelperLoose(atomState.d), _step7; !(_step7 = _iterator7()).done;) {
var _step7$value = _step7.value,
a = _step7$value[0],
n = _step7$value[1];
if (!atomState.m.d.has(a)) {
var aState = ensureAtomState(a);
var aMounted = _mountAtom(a, aState);
aMounted.t.add(atom);
atomState.m.d.add(a);
if (n !== aState.n) {
changedAtoms.set(a, aState);
aState.u == null || aState.u();
invalidateDependents(aState);
}
}
}
for (var _iterator8 = _createForOfIteratorHelperLoose(atomState.m.d || []), _step8; !(_step8 = _iterator8()).done;) {
var _a2 = _step8.value;
if (!atomState.d.has(_a2)) {
atomState.m.d.delete(_a2);
var _aMounted = _unmountAtom(_a2, ensureAtomState(_a2));
_aMounted == null || _aMounted.t.delete(atom);
}
}
}
};
var _mountAtom = function mountAtom(atom, atomState) {
if (!atomState.m) {
_readAtomState(atom);
for (var _iterator9 = _createForOfIteratorHelperLoose(atomState.d.keys()), _step9; !(_step9 = _iterator9()).done;) {
var a = _step9.value;
var aMounted = _mountAtom(a, ensureAtomState(a));
aMounted.t.add(atom);
}
atomState.m = {
l: new Set(),
d: new Set(atomState.d.keys()),
t: new Set()
};
atomState.h == null || atomState.h();
if (isActuallyWritableAtom(atom)) {
var mounted = atomState.m;
var processOnMount = function processOnMount() {
var isSync = true;
var setAtom = function setAtom() {
try {
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
return _writeAtomState.apply(void 0, [atom].concat(args));
} finally {
if (!isSync) {
recomputeInvalidatedAtoms();
flushCallbacks();
}
}
};
try {
var onUnmount = atomOnMount(atom, setAtom);
if (onUnmount) {
mounted.u = function () {
isSync = true;
try {
onUnmount();
} finally {
isSync = false;
}
};
}
} finally {
isSync = false;
}
};
mountCallbacks.add(processOnMount);
}
}
return atomState.m;
};
var _unmountAtom = function unmountAtom(atom, atomState) {
if (atomState.m && !atomState.m.l.size && !Array.from(atomState.m.t).some(function (a) {
var _ensureAtomState$m;
return (_ensureAtomState$m = ensureAtomState(a).m) == null ? undefined : _ensureAtomState$m.d.has(atom);
})) {
var onUnmount = atomState.m.u;
if (onUnmount) {
unmountCallbacks.add(onUnmount);
}
delete atomState.m;
atomState.h == null || atomState.h();
for (var _iterator10 = _createForOfIteratorHelperLoose(atomState.d.keys()), _step10; !(_step10 = _iterator10()).done;) {
var a = _step10.value;
var aMounted = _unmountAtom(a, ensureAtomState(a));
aMounted == null || aMounted.t.delete(atom);
}
return undefined;
}
return atomState.m;
};
var subscribeAtom = function subscribeAtom(atom, listener) {
var atomState = ensureAtomState(atom);
var mounted = _mountAtom(atom, atomState);
var listeners = mounted.l;
listeners.add(listener);
flushCallbacks();
return function () {
listeners.delete(listener);
_unmountAtom(atom, atomState);
flushCallbacks();
};
};
var unstable_derive = function unstable_derive(fn) {
return _buildStore.apply(undefined, fn.apply(undefined, storeArgs));
};
var store = {
get: readAtom,
set: writeAtom,
sub: subscribeAtom,
unstable_derive: unstable_derive
};
return store;
};
var deriveDevStoreRev4 = function deriveDevStoreRev4(store) {
return atom.write.apply(atom, [get, set].concat(args));
});
var debugMountedAtoms = new Set();
var savedGetAtomState;
var inRestoreAtom = 0;
var derivedStore = store.unstable_derive(function () {
for (var _len7 = arguments.length, storeArgs = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
storeArgs[_key7] = arguments[_key7];
}
var getAtomState = storeArgs[0],
setAtomState = storeArgs[1],
atomWrite = storeArgs[3];
savedGetAtomState = getAtomState;
storeArgs[1] = function devSetAtomState(atom, atomState) {
setAtomState(atom, atomState);
var originalMounted = atomState.h;
atomState.h = function () {
originalMounted == null || originalMounted();
if (atomState.m) {
debugMountedAtoms.add(atom);
} else {
debugMountedAtoms.delete(atom);
}
};
};
storeArgs[3] = function devAtomWrite(atom, getter, setter) {
for (var _len8 = arguments.length, args = new Array(_len8 > 3 ? _len8 - 3 : 0), _key8 = 3; _key8 < _len8; _key8++) {
args[_key8 - 3] = arguments[_key8];
}
if (inRestoreAtom) {
return setter.apply(undefined, [atom].concat(args));
}
return atomWrite.apply(undefined, [atom, getter, setter].concat(args));
};
return storeArgs;
storeHooks.m.add(undefined, function (atom) {
debugMountedAtoms.add(atom);
var atomState = atomStateMap.get(atom);
atomState.m = mountedAtoms.get(atom);
});
var savedStoreSet = derivedStore.set;
storeHooks.u.add(undefined, function (atom) {
debugMountedAtoms.delete(atom);
var atomState = atomStateMap.get(atom);
delete atomState.m;
});
var devStore = {
dev4_get_internal_weak_map: function dev4_get_internal_weak_map() {
return {
get: function get(atom) {
var atomState = savedGetAtomState(atom);
if (!atomState || atomState.n === 0) {
return undefined;
}
return atomState;
}
};
return atomStateMap;
},

@@ -652,8 +103,8 @@ dev4_get_mounted_atoms: function dev4_get_mounted_atoms() {

try {
for (var _iterator11 = _createForOfIteratorHelperLoose(values), _step11; !(_step11 = _iterator11()).done;) {
var _step11$value = _step11.value,
_atom = _step11$value[0],
value = _step11$value[1];
if (hasInitialValue(_atom)) {
set(_atom, value);
for (var _iterator = _createForOfIteratorHelperLoose(values), _step; !(_step = _iterator()).done;) {
var _step$value = _step.value,
atom = _step$value[0],
value = _step$value[1];
if ('init' in atom) {
set(atom, value);
}

@@ -666,37 +117,12 @@ }

};
savedStoreSet(restoreAtom);
store.set(restoreAtom);
}
};
return Object.assign(derivedStore, devStore);
return Object.assign(store, devStore);
};
var createStore = function createStore() {
var atomStateMap = new WeakMap();
var store = _buildStore(function (atom) {
return atomStateMap.get(atom);
}, function (atom, atomState) {
return atomStateMap.set(atom, atomState).get(atom);
}, function (atom) {
for (var _len9 = arguments.length, params = new Array(_len9 > 1 ? _len9 - 1 : 0), _key9 = 1; _key9 < _len9; _key9++) {
params[_key9 - 1] = arguments[_key9];
}
return atom.read.apply(atom, params);
}, function (atom) {
for (var _len10 = arguments.length, params = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) {
params[_key10 - 1] = arguments[_key10];
}
return atom.write.apply(atom, params);
}, function (atom) {
for (var _len11 = arguments.length, params = new Array(_len11 > 1 ? _len11 - 1 : 0), _key11 = 1; _key11 < _len11; _key11++) {
params[_key11 - 1] = arguments[_key11];
}
return atom.unstable_onInit == null ? undefined : atom.unstable_onInit.apply(atom, params);
}, function (atom) {
for (var _len12 = arguments.length, params = new Array(_len12 > 1 ? _len12 - 1 : 0), _key12 = 1; _key12 < _len12; _key12++) {
params[_key12 - 1] = arguments[_key12];
}
return atom.onMount == null ? undefined : atom.onMount.apply(atom, params);
});
if (process.env.NODE_ENV !== 'production') {
return deriveDevStoreRev4(store);
return createDevStoreRev4();
}
var store = internals.INTERNAL_buildStoreRev1();
return store;

@@ -709,4 +135,4 @@ };

if (process.env.NODE_ENV !== 'production') {
var _ref5;
(_ref5 = globalThis).__JOTAI_DEFAULT_STORE__ || (_ref5.__JOTAI_DEFAULT_STORE__ = defaultStore);
var _ref;
(_ref = globalThis).__JOTAI_DEFAULT_STORE__ || (_ref.__JOTAI_DEFAULT_STORE__ = defaultStore);
if (globalThis.__JOTAI_DEFAULT_STORE__ !== defaultStore) {

@@ -713,0 +139,0 @@ console.warn('Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044');

@@ -1,94 +0,14 @@

import type { Atom, WritableAtom } from './atom';
type AnyValue = unknown;
type AnyError = unknown;
type AnyAtom = Atom<AnyValue>;
type OnUnmount = () => void;
type EpochNumber = number;
/**
* State tracked for mounted atoms. An atom is considered "mounted" if it has a
* subscriber, or is a transitive dependency of another atom that has a
* subscriber.
*
* The mounted state of an atom is freed once it is no longer mounted.
*/
type Mounted = {
/** Set of listeners to notify when the atom value changes. */
readonly l: Set<() => void>;
/** Set of mounted atoms that the atom depends on. */
readonly d: Set<AnyAtom>;
/** Set of mounted atoms that depends on the atom. */
readonly t: Set<AnyAtom>;
/** Function to run when the atom is unmounted. */
u?: () => void;
};
/**
* Mutable atom state,
* tracked for both mounted and unmounted atoms in a store.
*
* This should be garbage collectable.
* We can mutate it during atom read. (except for fields with TODO)
*/
type AtomState<Value = AnyValue> = {
/**
* Map of atoms that the atom depends on.
* The map value is the epoch number of the dependency.
*/
readonly d: Map<AnyAtom, EpochNumber>;
/**
* Set of atoms with pending promise that depend on the atom.
*
* This may cause memory leaks, but it's for the capability to continue promises
* TODO(daishi): revisit how to handle this
*/
readonly p: Set<AnyAtom>;
/** The epoch number of the atom. */
n: EpochNumber;
/**
* Object to store mounted state of the atom.
* TODO(daishi): move this out of AtomState
*/
m?: Mounted;
/**
* Listener to notify when the atom value is updated.
* This is an experimental API and will be changed in the next minor.
* TODO(daishi): move this store hooks
*/
u?: () => void;
/**
* Listener to notify when the atom is mounted or unmounted.
* This is an experimental API and will be changed in the next minor.
* TODO(daishi): move this store hooks
*/
h?: () => void;
/** Atom value */
v?: Value;
/** Atom error */
e?: AnyError;
};
type StoreArgs = readonly [
getAtomState: <Value>(atom: Atom<Value>) => AtomState<Value> | undefined,
setAtomState: <Value>(atom: Atom<Value>, atomState: AtomState<Value>) => void,
atomRead: <Value>(atom: Atom<Value>, ...params: Parameters<Atom<Value>['read']>) => Value,
atomWrite: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...params: Parameters<WritableAtom<Value, Args, Result>['write']>) => Result,
atomOnInit: <Value>(atom: Atom<Value>, store: Store) => void,
atomOnMount: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, setAtom: (...args: Args) => Result) => OnUnmount | void
];
type DevStoreRev4 = {
import type { Atom } from './atom';
import type { INTERNAL_AtomState, INTERNAL_Store } from 'jotai/vanilla/internals';
export type INTERNAL_PrdStore = INTERNAL_Store;
export type INTERNAL_DevStoreRev4 = {
dev4_get_internal_weak_map: () => {
get: (atom: AnyAtom) => AtomState | undefined;
get: (atom: Atom<unknown>) => INTERNAL_AtomState | undefined;
};
dev4_get_mounted_atoms: () => Set<AnyAtom>;
dev4_restore_atoms: (values: Iterable<readonly [AnyAtom, AnyValue]>) => void;
dev4_get_mounted_atoms: () => Set<Atom<unknown>>;
dev4_restore_atoms: (values: Iterable<readonly [Atom<unknown>, unknown]>) => void;
};
type Store = {
get: <Value>(atom: Atom<Value>) => Value;
set: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
sub: (atom: AnyAtom, listener: () => void) => () => void;
unstable_derive: (fn: (...args: StoreArgs) => StoreArgs) => Store;
};
export type INTERNAL_DevStoreRev4 = DevStoreRev4;
export type INTERNAL_PrdStore = Store;
type PrdOrDevStore = Store | (Store & DevStoreRev4);
type PrdOrDevStore = INTERNAL_PrdStore | (INTERNAL_PrdStore & INTERNAL_DevStoreRev4);
export declare const createStore: () => PrdOrDevStore;
export declare const getDefaultStore: () => PrdOrDevStore;
export {};

@@ -56,3 +56,3 @@ 'use strict';

var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}

@@ -164,3 +164,3 @@ }

function selectAtom(anAtom, selector, equalityFn) {
if (equalityFn === undefined) {
if (equalityFn === void 0) {
equalityFn = Object.is;

@@ -223,3 +223,3 @@ }

}
return set.apply(undefined, setArgs);
return set.apply(void 0, setArgs);
}].concat(args));

@@ -235,3 +235,3 @@ };

return function () {
return freezeAtom(createAtom.apply(undefined, arguments));
return freezeAtom(createAtom.apply(void 0, arguments));
};

@@ -279,3 +279,3 @@ }

var currArr = get(arrAtom);
var mapping = _getMapping(currArr, prev == null ? undefined : prev.arr);
var mapping = _getMapping(currArr, prev == null ? void 0 : prev.arr);
var index = mapping.keyList.indexOf(key);

@@ -294,3 +294,3 @@ if (index < 0 || index >= currArr.length) {

var arr = get(arrAtom);
var mapping = _getMapping(arr, prev == null ? undefined : prev.arr);
var mapping = _getMapping(arr, prev == null ? void 0 : prev.arr);
var index = mapping.keyList.indexOf(key);

@@ -324,3 +324,3 @@ if (index < 0 || index >= arr.length) {

var arr = get(arrAtom);
var mapping = _getMapping(arr, prev == null ? undefined : prev.arr);
var mapping = _getMapping(arr, prev == null ? void 0 : prev.arr);
return mapping;

@@ -402,3 +402,3 @@ });

var isPromiseLike = function isPromiseLike(x) {
return typeof (x == null ? undefined : x.then) === 'function';
return typeof (x == null ? void 0 : x.then) === 'function';
};

@@ -426,3 +426,3 @@ function withStorageValidator(validator) {

function createJSONStorage(getStringStorage, options) {
if (getStringStorage === undefined) {
if (getStringStorage === void 0) {
getStringStorage = function getStringStorage() {

@@ -458,3 +458,3 @@ try {

};
var str = (_getStringStorage$get = (_getStringStorage = getStringStorage()) == null ? undefined : _getStringStorage.getItem(key)) != null ? _getStringStorage$get : null;
var str = (_getStringStorage$get = (_getStringStorage = getStringStorage()) == null ? void 0 : _getStringStorage.getItem(key)) != null ? _getStringStorage$get : null;
if (isPromiseLike(str)) {

@@ -467,7 +467,7 @@ return str.then(parse);

var _getStringStorage2;
return (_getStringStorage2 = getStringStorage()) == null ? undefined : _getStringStorage2.setItem(key, JSON.stringify(newValue, options == null ? undefined : options.replacer));
return (_getStringStorage2 = getStringStorage()) == null ? void 0 : _getStringStorage2.setItem(key, JSON.stringify(newValue, options == null ? void 0 : options.replacer));
},
removeItem: function removeItem(key) {
var _getStringStorage3;
return (_getStringStorage3 = getStringStorage()) == null ? undefined : _getStringStorage3.removeItem(key);
return (_getStringStorage3 = getStringStorage()) == null ? void 0 : _getStringStorage3.removeItem(key);
}

@@ -516,6 +516,6 @@ };

function atomWithStorage(key, initialValue, storage, options) {
if (storage === undefined) {
if (storage === void 0) {
storage = defaultStorage;
}
var getOnInit = options == null ? undefined : options.getOnInit;
var getOnInit = options == null ? void 0 : options.getOnInit;
var baseAtom = vanilla.atom(getOnInit ? storage.getItem(key, initialValue) : initialValue);

@@ -563,3 +563,3 @@ if (process.env.NODE_ENV !== 'production') {

var observable = getObservable(get);
var itself = (_observable$Symbol$ob = (_observable = observable)[Symbol.observable]) == null ? undefined : _observable$Symbol$ob.call(_observable);
var itself = (_observable$Symbol$ob = (_observable = observable)[Symbol.observable]) == null ? void 0 : _observable$Symbol$ob.call(_observable);
if (itself) {

@@ -762,3 +762,3 @@ observable = itself;

function unwrap(anAtom, fallback) {
if (fallback === undefined) {
if (fallback === void 0) {
fallback = defaultFallback;

@@ -783,3 +783,3 @@ }

}
if (promise !== (prev == null ? undefined : prev.p)) {
if (promise !== (prev == null ? void 0 : prev.p)) {
promise.then(function (v) {

@@ -832,3 +832,3 @@ promiseResultCache.set(promise, v);

}
return set.apply(undefined, [anAtom].concat(args));
return set.apply(void 0, [anAtom].concat(args));
});

@@ -855,3 +855,3 @@ }, anAtom, fallback);

} else if (write) {
return write.apply(undefined, [get, set].concat(args));
return write.apply(void 0, [get, set].concat(args));
}

@@ -858,0 +858,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc