@gaddario98/react-core 2.0.5 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,5 @@
1
1
  import * as _gaddario98_react_state from '@gaddario98/react-state';
2
2
 
3
- declare const authAtom: _gaddario98_react_state.PrimitiveAtom<AuthState | null>;
4
- declare const useAuthValue: () => AuthState | null;
5
- declare const useAuthState: () => [AuthState | null, (value: AuthState | null) => void];
6
-
7
3
  type AuthState = {
8
4
  id: string;
9
5
  accountVerified?: boolean;
@@ -13,5 +9,9 @@ type AuthState = {
13
9
  email?: string;
14
10
  };
15
11
 
12
+ declare const authAtom: _gaddario98_react_state.PrimitiveAtom<AuthState | null>;
13
+ declare const useAuthValue: () => AuthState | null;
14
+ declare const useAuthState: () => [AuthState | null, (value: AuthState | null) => void];
15
+
16
16
  export { authAtom, useAuthState, useAuthValue };
17
17
  export type { AuthState };
@@ -4,6 +4,6 @@
4
4
  useState: useAuthState
5
5
  } = reactState.atomStateGenerator({
6
6
  defaultValue: null,
7
- key: 'reactAuthStore',
7
+ key: "reactAuthStore",
8
8
  persist: true
9
9
  });exports.authAtom=authAtom;exports.useAuthState=useAuthState;exports.useAuthValue=useAuthValue;//# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../auth/state.ts"],"sourcesContent":["import { atomStateGenerator } from '@gaddario98/react-state'\nimport type { AuthState } from '.'\n\nconst {\n atom: authAtom,\n useValue: useAuthValue,\n useState: useAuthState,\n} = atomStateGenerator<AuthState | null>({\n defaultValue: null,\n key: 'reactAuthStore',\n persist: true,\n})\nexport { authAtom, useAuthValue, useAuthState }\n"],"names":["atom","authAtom","useValue","useAuthValue","useState","useAuthState","atomStateGenerator","defaultValue","key","persist"],"mappings":"+DAGA,MAAM;AACJA,EAAAA,IAAI,EAAEC,QAAQ;AACdC,EAAAA,QAAQ,EAAEC,YAAY;AACtBC,EAAAA,QAAQ,EAAEC;AAAY,CACvB,GAAGC,6BAAkB,CAAmB;AACvCC,EAAAA,YAAY,EAAE,IAAI;AAClBC,EAAAA,GAAG,EAAE,gBAAgB;AACrBC,EAAAA,OAAO,EAAE;AACV,CAAA"}
1
+ {"version":3,"file":"index.js","sources":["../../auth/state.ts"],"sourcesContent":["import { atomStateGenerator } from \"@gaddario98/react-state\";\nimport type { AuthState } from \"./types\";\n\nconst {\n atom: authAtom,\n useValue: useAuthValue,\n useState: useAuthState,\n} = atomStateGenerator<AuthState | null>({\n defaultValue: null,\n key: \"reactAuthStore\",\n persist: true,\n});\nexport { authAtom, useAuthValue, useAuthState };\n"],"names":["atom","authAtom","useValue","useAuthValue","useState","useAuthState","atomStateGenerator","defaultValue","key","persist"],"mappings":"+DAGA,MAAM;AACJA,EAAAA,IAAI,EAAEC,QAAQ;AACdC,EAAAA,QAAQ,EAAEC,YAAY;AACtBC,EAAAA,QAAQ,EAAEC;AAAY,CACvB,GAAGC,6BAAkB,CAAmB;AACvCC,EAAAA,YAAY,EAAE,IAAI;AAClBC,EAAAA,GAAG,EAAE,gBAAgB;AACrBC,EAAAA,OAAO,EAAE;AACV,CAAA"}
@@ -4,6 +4,6 @@ import {atomStateGenerator}from'@gaddario98/react-state';const {
4
4
  useState: useAuthState
5
5
  } = atomStateGenerator({
6
6
  defaultValue: null,
7
- key: 'reactAuthStore',
7
+ key: "reactAuthStore",
8
8
  persist: true
9
9
  });export{authAtom,useAuthState,useAuthValue};//# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../auth/state.ts"],"sourcesContent":["import { atomStateGenerator } from '@gaddario98/react-state'\nimport type { AuthState } from '.'\n\nconst {\n atom: authAtom,\n useValue: useAuthValue,\n useState: useAuthState,\n} = atomStateGenerator<AuthState | null>({\n defaultValue: null,\n key: 'reactAuthStore',\n persist: true,\n})\nexport { authAtom, useAuthValue, useAuthState }\n"],"names":["atom","authAtom","useValue","useAuthValue","useState","useAuthState","atomStateGenerator","defaultValue","key","persist"],"mappings":"yDAGA,MAAM;AACJA,EAAAA,IAAI,EAAEC,QAAQ;AACdC,EAAAA,QAAQ,EAAEC,YAAY;AACtBC,EAAAA,QAAQ,EAAEC;AAAY,CACvB,GAAGC,kBAAkB,CAAmB;AACvCC,EAAAA,YAAY,EAAE,IAAI;AAClBC,EAAAA,GAAG,EAAE,gBAAgB;AACrBC,EAAAA,OAAO,EAAE;AACV,CAAA"}
1
+ {"version":3,"file":"index.mjs","sources":["../../auth/state.ts"],"sourcesContent":["import { atomStateGenerator } from \"@gaddario98/react-state\";\nimport type { AuthState } from \"./types\";\n\nconst {\n atom: authAtom,\n useValue: useAuthValue,\n useState: useAuthState,\n} = atomStateGenerator<AuthState | null>({\n defaultValue: null,\n key: \"reactAuthStore\",\n persist: true,\n});\nexport { authAtom, useAuthValue, useAuthState };\n"],"names":["atom","authAtom","useValue","useAuthValue","useState","useAuthState","atomStateGenerator","defaultValue","key","persist"],"mappings":"yDAGA,MAAM;AACJA,EAAAA,IAAI,EAAEC,QAAQ;AACdC,EAAAA,QAAQ,EAAEC,YAAY;AACtBC,EAAAA,QAAQ,EAAEC;AAAY,CACvB,GAAGC,kBAAkB,CAAmB;AACvCC,EAAAA,YAAY,EAAE,IAAI;AAClBC,EAAAA,GAAG,EAAE,gBAAgB;AACrBC,EAAAA,OAAO,EAAE;AACV,CAAA"}
@@ -1,11 +1,11 @@
1
- 'use strict';var reactState=require('@gaddario98/react-state'),compilerRuntime=require('react/compiler-runtime'),jsxRuntime=require('react/jsx-runtime'),React=require('react'),equal=require('fast-deep-equal'),withSelector_js=require('use-sync-external-store/shim/with-selector.js');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var React__namespace=/*#__PURE__*/_interopNamespaceDefault(React);const DefaultContainer = ({
1
+ 'use strict';var reactState=require('@gaddario98/react-state'),compilerRuntime=require('react/compiler-runtime'),jsxRuntime=require('react/jsx-runtime'),React=require('react'),equal=require('fast-deep-equal'),withSelector_js=require('use-sync-external-store/shim/with-selector.js');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var React__namespace=/*#__PURE__*/_interopNamespaceDefault(React);const DefaultContainer$1 = ({
2
2
  children
3
3
  }) => {
4
4
  return children;
5
5
  };
6
6
  // Lazy initialization to avoid side effects at module load time
7
7
  const _formConfig = {
8
- formFieldContainer: DefaultContainer
8
+ formFieldContainer: DefaultContainer$1
9
9
  };
10
10
  const {
11
11
  atom: formConfigAtom,
@@ -1343,7 +1343,17 @@ class FormApi {
1343
1343
  };
1344
1344
  this.validateField = (field, cause) => {
1345
1345
  const fieldInstance = this.fieldInfo[field]?.instance;
1346
- if (!fieldInstance) return [];
1346
+ if (!fieldInstance) {
1347
+ const {
1348
+ hasErrored
1349
+ } = this.validateSync(cause);
1350
+ if (hasErrored && !this.options.asyncAlways) {
1351
+ return this.getFieldMeta(field)?.errors ?? [];
1352
+ }
1353
+ return this.validateAsync(cause).then(() => {
1354
+ return this.getFieldMeta(field)?.errors ?? [];
1355
+ });
1356
+ }
1347
1357
  if (!fieldInstance.state.meta.isTouched) {
1348
1358
  fieldInstance.setMeta(prev => ({
1349
1359
  ...prev,
@@ -2030,7 +2040,7 @@ class FormApi {
2030
2040
  if (!prevBaseMeta || currBaseMeta.errorMap !== prevBaseMeta.errorMap) {
2031
2041
  fieldErrors = Object.values(currBaseMeta.errorMap ?? {}).filter(val => val !== void 0);
2032
2042
  const fieldInstance = this.getFieldInfo(fieldName)?.instance;
2033
- if (fieldInstance && !fieldInstance.options.disableErrorFlat) {
2043
+ if (!fieldInstance || !fieldInstance.options.disableErrorFlat) {
2034
2044
  fieldErrors = fieldErrors.flat(1);
2035
2045
  }
2036
2046
  }
@@ -3109,29 +3119,22 @@ function getMountedOrPendingDependents(atom, atomState, mountedMap) {
3109
3119
  }
3110
3120
  return dependents;
3111
3121
  }
3112
- const atomRead = (_store, atom, ...params) => atom.read(...params);
3113
- const atomWrite = (_store, atom, ...params) => atom.write(...params);
3114
- const atomOnInit = (store, atom) => {
3115
- if (atom.INTERNAL_onInit) {
3116
- return atom.INTERNAL_onInit(store);
3117
- }
3118
- if (atom.unstable_onInit) {
3119
- console.warn(
3120
- "[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."
3121
- );
3122
- return atom.unstable_onInit(store);
3123
- }
3122
+ const BUILDING_BLOCK_atomRead = (_store, atom, ...params) => atom.read(...params);
3123
+ const BUILDING_BLOCK_atomWrite = (_store, atom, ...params) => atom.write(...params);
3124
+ const BUILDING_BLOCK_atomOnInit = (store, atom) => {
3125
+ var _a;
3126
+ return (_a = atom.INTERNAL_onInit) == null ? void 0 : _a.call(atom, store);
3124
3127
  };
3125
- const atomOnMount = (_store, atom, setAtom) => {
3128
+ const BUILDING_BLOCK_atomOnMount = (_store, atom, setAtom) => {
3126
3129
  var _a;
3127
3130
  return (_a = atom.onMount) == null ? void 0 : _a.call(atom, setAtom);
3128
3131
  };
3129
- const ensureAtomState = (store, atom) => {
3132
+ const BUILDING_BLOCK_ensureAtomState = (store, atom) => {
3130
3133
  var _a;
3131
3134
  const buildingBlocks = getInternalBuildingBlocks(store);
3132
3135
  const atomStateMap = buildingBlocks[0];
3133
3136
  const storeHooks = buildingBlocks[6];
3134
- const atomOnInit2 = buildingBlocks[9];
3137
+ const atomOnInit = buildingBlocks[9];
3135
3138
  if ((undefined ? undefined.MODE : void 0) !== "production" && !atom) {
3136
3139
  throw new Error("Atom is undefined or null");
3137
3140
  }
@@ -3140,18 +3143,18 @@ const ensureAtomState = (store, atom) => {
3140
3143
  atomState = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 };
3141
3144
  atomStateMap.set(atom, atomState);
3142
3145
  (_a = storeHooks.i) == null ? void 0 : _a.call(storeHooks, atom);
3143
- atomOnInit2 == null ? void 0 : atomOnInit2(store, atom);
3146
+ atomOnInit == null ? void 0 : atomOnInit(store, atom);
3144
3147
  }
3145
3148
  return atomState;
3146
3149
  };
3147
- const flushCallbacks = (store) => {
3150
+ const BUILDING_BLOCK_flushCallbacks = (store) => {
3148
3151
  const buildingBlocks = getInternalBuildingBlocks(store);
3149
3152
  const mountedMap = buildingBlocks[1];
3150
3153
  const changedAtoms = buildingBlocks[3];
3151
3154
  const mountCallbacks = buildingBlocks[4];
3152
3155
  const unmountCallbacks = buildingBlocks[5];
3153
3156
  const storeHooks = buildingBlocks[6];
3154
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
3157
+ const recomputeInvalidatedAtoms = buildingBlocks[13];
3155
3158
  const errors = [];
3156
3159
  const call = (fn) => {
3157
3160
  try {
@@ -3177,28 +3180,28 @@ const flushCallbacks = (store) => {
3177
3180
  mountCallbacks.clear();
3178
3181
  callbacks.forEach(call);
3179
3182
  if (changedAtoms.size) {
3180
- recomputeInvalidatedAtoms2(store);
3183
+ recomputeInvalidatedAtoms(store);
3181
3184
  }
3182
3185
  } while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
3183
3186
  if (errors.length) {
3184
3187
  throw new AggregateError(errors);
3185
3188
  }
3186
3189
  };
3187
- const recomputeInvalidatedAtoms = (store) => {
3190
+ const BUILDING_BLOCK_recomputeInvalidatedAtoms = (store) => {
3188
3191
  const buildingBlocks = getInternalBuildingBlocks(store);
3189
3192
  const mountedMap = buildingBlocks[1];
3190
3193
  const invalidatedAtoms = buildingBlocks[2];
3191
3194
  const changedAtoms = buildingBlocks[3];
3192
- const ensureAtomState2 = buildingBlocks[11];
3193
- const readAtomState2 = buildingBlocks[14];
3194
- const mountDependencies2 = buildingBlocks[17];
3195
+ const ensureAtomState = buildingBlocks[11];
3196
+ const readAtomState = buildingBlocks[14];
3197
+ const mountDependencies = buildingBlocks[17];
3195
3198
  const topSortedReversed = [];
3196
3199
  const visiting = /* @__PURE__ */ new WeakSet();
3197
3200
  const visited = /* @__PURE__ */ new WeakSet();
3198
3201
  const stack = Array.from(changedAtoms);
3199
3202
  while (stack.length) {
3200
3203
  const a = stack[stack.length - 1];
3201
- const aState = ensureAtomState2(store, a);
3204
+ const aState = ensureAtomState(store, a);
3202
3205
  if (visited.has(a)) {
3203
3206
  stack.pop();
3204
3207
  continue;
@@ -3230,35 +3233,36 @@ const recomputeInvalidatedAtoms = (store) => {
3230
3233
  }
3231
3234
  }
3232
3235
  if (hasChangedDeps) {
3233
- readAtomState2(store, a);
3234
- mountDependencies2(store, a);
3236
+ readAtomState(store, a);
3237
+ mountDependencies(store, a);
3235
3238
  }
3236
3239
  invalidatedAtoms.delete(a);
3237
3240
  }
3238
3241
  };
3239
3242
  const storeMutationSet = /* @__PURE__ */ new WeakSet();
3240
- const readAtomState = (store, atom) => {
3243
+ const BUILDING_BLOCK_readAtomState = (store, atom) => {
3241
3244
  var _a, _b;
3242
3245
  const buildingBlocks = getInternalBuildingBlocks(store);
3243
3246
  const mountedMap = buildingBlocks[1];
3244
3247
  const invalidatedAtoms = buildingBlocks[2];
3245
3248
  const changedAtoms = buildingBlocks[3];
3246
3249
  const storeHooks = buildingBlocks[6];
3247
- const atomRead2 = buildingBlocks[7];
3248
- const ensureAtomState2 = buildingBlocks[11];
3249
- const flushCallbacks2 = buildingBlocks[12];
3250
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
3251
- const readAtomState2 = buildingBlocks[14];
3252
- const writeAtomState2 = buildingBlocks[16];
3253
- const mountDependencies2 = buildingBlocks[17];
3254
- const atomState = ensureAtomState2(store, atom);
3250
+ const atomRead = buildingBlocks[7];
3251
+ const ensureAtomState = buildingBlocks[11];
3252
+ const flushCallbacks = buildingBlocks[12];
3253
+ const recomputeInvalidatedAtoms = buildingBlocks[13];
3254
+ const readAtomState = buildingBlocks[14];
3255
+ const writeAtomState = buildingBlocks[16];
3256
+ const mountDependencies = buildingBlocks[17];
3257
+ const setAtomStateValueOrPromise = buildingBlocks[20];
3258
+ const atomState = ensureAtomState(store, atom);
3255
3259
  if (isAtomStateInitialized(atomState)) {
3256
3260
  if (mountedMap.has(atom) && invalidatedAtoms.get(atom) !== atomState.n) {
3257
3261
  return atomState;
3258
3262
  }
3259
3263
  let hasChangedDeps = false;
3260
3264
  for (const [a, n] of atomState.d) {
3261
- if (readAtomState2(store, a).n !== n) {
3265
+ if (readAtomState(store, a).n !== n) {
3262
3266
  hasChangedDeps = true;
3263
3267
  break;
3264
3268
  }
@@ -3271,15 +3275,15 @@ const readAtomState = (store, atom) => {
3271
3275
  let isSync = true;
3272
3276
  function mountDependenciesIfAsync() {
3273
3277
  if (mountedMap.has(atom)) {
3274
- mountDependencies2(store, atom);
3275
- recomputeInvalidatedAtoms2(store);
3276
- flushCallbacks2(store);
3278
+ mountDependencies(store, atom);
3279
+ recomputeInvalidatedAtoms(store);
3280
+ flushCallbacks(store);
3277
3281
  }
3278
3282
  }
3279
3283
  function getter(a) {
3280
3284
  var _a2;
3281
3285
  if (a === atom) {
3282
- const aState2 = ensureAtomState2(store, a);
3286
+ const aState2 = ensureAtomState(store, a);
3283
3287
  if (!isAtomStateInitialized(aState2)) {
3284
3288
  if (hasInitialValue(a)) {
3285
3289
  setAtomStateValueOrPromise(store, a, a.init);
@@ -3289,7 +3293,7 @@ const readAtomState = (store, atom) => {
3289
3293
  }
3290
3294
  return returnAtomValue(aState2);
3291
3295
  }
3292
- const aState = readAtomState2(store, a);
3296
+ const aState = readAtomState(store, a);
3293
3297
  try {
3294
3298
  return returnAtomValue(aState);
3295
3299
  } finally {
@@ -3315,6 +3319,11 @@ const readAtomState = (store, atom) => {
3315
3319
  return controller.signal;
3316
3320
  },
3317
3321
  get setSelf() {
3322
+ if ((undefined ? undefined.MODE : void 0) !== "production") {
3323
+ console.warn(
3324
+ "[DEPRECATED] setSelf is deprecated and will be removed in v3."
3325
+ );
3326
+ }
3318
3327
  if ((undefined ? undefined.MODE : void 0) !== "production" && !isActuallyWritableAtom(atom)) {
3319
3328
  console.warn("setSelf function cannot be used with read-only atom");
3320
3329
  }
@@ -3325,10 +3334,10 @@ const readAtomState = (store, atom) => {
3325
3334
  }
3326
3335
  if (!isSync) {
3327
3336
  try {
3328
- return writeAtomState2(store, atom, ...args);
3337
+ return writeAtomState(store, atom, ...args);
3329
3338
  } finally {
3330
- recomputeInvalidatedAtoms2(store);
3331
- flushCallbacks2(store);
3339
+ recomputeInvalidatedAtoms(store);
3340
+ flushCallbacks(store);
3332
3341
  }
3333
3342
  }
3334
3343
  };
@@ -3341,7 +3350,7 @@ const readAtomState = (store, atom) => {
3341
3350
  if ((undefined ? undefined.MODE : void 0) !== "production") {
3342
3351
  storeMutationSet.delete(store);
3343
3352
  }
3344
- const valueOrPromise = atomRead2(store, atom, getter, options);
3353
+ const valueOrPromise = atomRead(store, atom, getter, options);
3345
3354
  if ((undefined ? undefined.MODE : void 0) !== "production" && storeMutationSet.has(store)) {
3346
3355
  console.warn(
3347
3356
  "Detected store mutation during atom read. This is not supported."
@@ -3368,38 +3377,40 @@ const readAtomState = (store, atom) => {
3368
3377
  }
3369
3378
  }
3370
3379
  };
3371
- const invalidateDependents = (store, atom) => {
3380
+ const BUILDING_BLOCK_invalidateDependents = (store, atom) => {
3372
3381
  const buildingBlocks = getInternalBuildingBlocks(store);
3373
3382
  const mountedMap = buildingBlocks[1];
3374
3383
  const invalidatedAtoms = buildingBlocks[2];
3375
- const ensureAtomState2 = buildingBlocks[11];
3384
+ const ensureAtomState = buildingBlocks[11];
3376
3385
  const stack = [atom];
3377
3386
  while (stack.length) {
3378
3387
  const a = stack.pop();
3379
- const aState = ensureAtomState2(store, a);
3388
+ const aState = ensureAtomState(store, a);
3380
3389
  for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) {
3381
- const dState = ensureAtomState2(store, d);
3390
+ const dState = ensureAtomState(store, d);
3382
3391
  invalidatedAtoms.set(d, dState.n);
3383
3392
  stack.push(d);
3384
3393
  }
3385
3394
  }
3386
3395
  };
3387
- const writeAtomState = (store, atom, ...args) => {
3396
+ const BUILDING_BLOCK_writeAtomState = (store, atom, ...args) => {
3388
3397
  const buildingBlocks = getInternalBuildingBlocks(store);
3389
3398
  const changedAtoms = buildingBlocks[3];
3390
3399
  const storeHooks = buildingBlocks[6];
3391
- const atomWrite2 = buildingBlocks[8];
3392
- const ensureAtomState2 = buildingBlocks[11];
3393
- const flushCallbacks2 = buildingBlocks[12];
3394
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
3395
- const readAtomState2 = buildingBlocks[14];
3396
- const invalidateDependents2 = buildingBlocks[15];
3397
- const mountDependencies2 = buildingBlocks[17];
3400
+ const atomWrite = buildingBlocks[8];
3401
+ const ensureAtomState = buildingBlocks[11];
3402
+ const flushCallbacks = buildingBlocks[12];
3403
+ const recomputeInvalidatedAtoms = buildingBlocks[13];
3404
+ const readAtomState = buildingBlocks[14];
3405
+ const invalidateDependents = buildingBlocks[15];
3406
+ const writeAtomState = buildingBlocks[16];
3407
+ const mountDependencies = buildingBlocks[17];
3408
+ const setAtomStateValueOrPromise = buildingBlocks[20];
3398
3409
  let isSync = true;
3399
- const getter = (a) => returnAtomValue(readAtomState2(store, a));
3410
+ const getter = (a) => returnAtomValue(readAtomState(store, a));
3400
3411
  const setter = (a, ...args2) => {
3401
3412
  var _a;
3402
- const aState = ensureAtomState2(store, a);
3413
+ const aState = ensureAtomState(store, a);
3403
3414
  try {
3404
3415
  if (a === atom) {
3405
3416
  if (!hasInitialValue(a)) {
@@ -3411,10 +3422,10 @@ const writeAtomState = (store, atom, ...args) => {
3411
3422
  const prevEpochNumber = aState.n;
3412
3423
  const v = args2[0];
3413
3424
  setAtomStateValueOrPromise(store, a, v);
3414
- mountDependencies2(store, a);
3425
+ mountDependencies(store, a);
3415
3426
  if (prevEpochNumber !== aState.n) {
3416
3427
  changedAtoms.add(a);
3417
- invalidateDependents2(store, a);
3428
+ invalidateDependents(store, a);
3418
3429
  (_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
3419
3430
  }
3420
3431
  return void 0;
@@ -3423,39 +3434,39 @@ const writeAtomState = (store, atom, ...args) => {
3423
3434
  }
3424
3435
  } finally {
3425
3436
  if (!isSync) {
3426
- recomputeInvalidatedAtoms2(store);
3427
- flushCallbacks2(store);
3437
+ recomputeInvalidatedAtoms(store);
3438
+ flushCallbacks(store);
3428
3439
  }
3429
3440
  }
3430
3441
  };
3431
3442
  try {
3432
- return atomWrite2(store, atom, getter, setter, ...args);
3443
+ return atomWrite(store, atom, getter, setter, ...args);
3433
3444
  } finally {
3434
3445
  isSync = false;
3435
3446
  }
3436
3447
  };
3437
- const mountDependencies = (store, atom) => {
3448
+ const BUILDING_BLOCK_mountDependencies = (store, atom) => {
3438
3449
  var _a;
3439
3450
  const buildingBlocks = getInternalBuildingBlocks(store);
3440
3451
  const mountedMap = buildingBlocks[1];
3441
3452
  const changedAtoms = buildingBlocks[3];
3442
3453
  const storeHooks = buildingBlocks[6];
3443
- const ensureAtomState2 = buildingBlocks[11];
3444
- const invalidateDependents2 = buildingBlocks[15];
3445
- const mountAtom2 = buildingBlocks[18];
3446
- const unmountAtom2 = buildingBlocks[19];
3447
- const atomState = ensureAtomState2(store, atom);
3454
+ const ensureAtomState = buildingBlocks[11];
3455
+ const invalidateDependents = buildingBlocks[15];
3456
+ const mountAtom = buildingBlocks[18];
3457
+ const unmountAtom = buildingBlocks[19];
3458
+ const atomState = ensureAtomState(store, atom);
3448
3459
  const mounted = mountedMap.get(atom);
3449
3460
  if (mounted && !isPendingPromise(atomState.v)) {
3450
3461
  for (const [a, n] of atomState.d) {
3451
3462
  if (!mounted.d.has(a)) {
3452
- const aState = ensureAtomState2(store, a);
3453
- const aMounted = mountAtom2(store, a);
3463
+ const aState = ensureAtomState(store, a);
3464
+ const aMounted = mountAtom(store, a);
3454
3465
  aMounted.t.add(atom);
3455
3466
  mounted.d.add(a);
3456
3467
  if (n !== aState.n) {
3457
3468
  changedAtoms.add(a);
3458
- invalidateDependents2(store, a);
3469
+ invalidateDependents(store, a);
3459
3470
  (_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
3460
3471
  }
3461
3472
  }
@@ -3463,28 +3474,29 @@ const mountDependencies = (store, atom) => {
3463
3474
  for (const a of mounted.d) {
3464
3475
  if (!atomState.d.has(a)) {
3465
3476
  mounted.d.delete(a);
3466
- const aMounted = unmountAtom2(store, a);
3477
+ const aMounted = unmountAtom(store, a);
3467
3478
  aMounted == null ? void 0 : aMounted.t.delete(atom);
3468
3479
  }
3469
3480
  }
3470
3481
  }
3471
3482
  };
3472
- const mountAtom = (store, atom) => {
3483
+ const BUILDING_BLOCK_mountAtom = (store, atom) => {
3473
3484
  var _a;
3474
3485
  const buildingBlocks = getInternalBuildingBlocks(store);
3475
3486
  const mountedMap = buildingBlocks[1];
3476
3487
  const mountCallbacks = buildingBlocks[4];
3477
3488
  const storeHooks = buildingBlocks[6];
3478
- const atomOnMount2 = buildingBlocks[10];
3479
- const ensureAtomState2 = buildingBlocks[11];
3480
- const flushCallbacks2 = buildingBlocks[12];
3481
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
3482
- const readAtomState2 = buildingBlocks[14];
3483
- const writeAtomState2 = buildingBlocks[16];
3484
- const atomState = ensureAtomState2(store, atom);
3489
+ const atomOnMount = buildingBlocks[10];
3490
+ const ensureAtomState = buildingBlocks[11];
3491
+ const flushCallbacks = buildingBlocks[12];
3492
+ const recomputeInvalidatedAtoms = buildingBlocks[13];
3493
+ const readAtomState = buildingBlocks[14];
3494
+ const writeAtomState = buildingBlocks[16];
3495
+ const mountAtom = buildingBlocks[18];
3496
+ const atomState = ensureAtomState(store, atom);
3485
3497
  let mounted = mountedMap.get(atom);
3486
3498
  if (!mounted) {
3487
- readAtomState2(store, atom);
3499
+ readAtomState(store, atom);
3488
3500
  for (const a of atomState.d.keys()) {
3489
3501
  const aMounted = mountAtom(store, a);
3490
3502
  aMounted.t.add(atom);
@@ -3500,16 +3512,16 @@ const mountAtom = (store, atom) => {
3500
3512
  let isSync = true;
3501
3513
  const setAtom = (...args) => {
3502
3514
  try {
3503
- return writeAtomState2(store, atom, ...args);
3515
+ return writeAtomState(store, atom, ...args);
3504
3516
  } finally {
3505
3517
  if (!isSync) {
3506
- recomputeInvalidatedAtoms2(store);
3507
- flushCallbacks2(store);
3518
+ recomputeInvalidatedAtoms(store);
3519
+ flushCallbacks(store);
3508
3520
  }
3509
3521
  }
3510
3522
  };
3511
3523
  try {
3512
- const onUnmount = atomOnMount2(store, atom, setAtom);
3524
+ const onUnmount = atomOnMount(store, atom, setAtom);
3513
3525
  if (onUnmount) {
3514
3526
  mounted.u = () => {
3515
3527
  isSync = true;
@@ -3530,15 +3542,15 @@ const mountAtom = (store, atom) => {
3530
3542
  }
3531
3543
  return mounted;
3532
3544
  };
3533
- const unmountAtom = (store, atom) => {
3545
+ const BUILDING_BLOCK_unmountAtom = (store, atom) => {
3534
3546
  var _a, _b;
3535
3547
  const buildingBlocks = getInternalBuildingBlocks(store);
3536
3548
  const mountedMap = buildingBlocks[1];
3537
3549
  const unmountCallbacks = buildingBlocks[5];
3538
3550
  const storeHooks = buildingBlocks[6];
3539
- const ensureAtomState2 = buildingBlocks[11];
3540
- const unmountAtom2 = buildingBlocks[19];
3541
- const atomState = ensureAtomState2(store, atom);
3551
+ const ensureAtomState = buildingBlocks[11];
3552
+ const unmountAtom = buildingBlocks[19];
3553
+ const atomState = ensureAtomState(store, atom);
3542
3554
  let mounted = mountedMap.get(atom);
3543
3555
  if (!mounted || mounted.l.size) {
3544
3556
  return mounted;
@@ -3557,7 +3569,7 @@ const unmountAtom = (store, atom) => {
3557
3569
  mounted = void 0;
3558
3570
  mountedMap.delete(atom);
3559
3571
  for (const a of atomState.d.keys()) {
3560
- const aMounted = unmountAtom2(store, a);
3572
+ const aMounted = unmountAtom(store, a);
3561
3573
  aMounted == null ? void 0 : aMounted.t.delete(atom);
3562
3574
  }
3563
3575
  (_b = storeHooks.u) == null ? void 0 : _b.call(storeHooks, atom);
@@ -3565,9 +3577,9 @@ const unmountAtom = (store, atom) => {
3565
3577
  }
3566
3578
  return mounted;
3567
3579
  };
3568
- const setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
3569
- const ensureAtomState2 = getInternalBuildingBlocks(store)[11];
3570
- const atomState = ensureAtomState2(store, atom);
3580
+ const BUILDING_BLOCK_setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
3581
+ const ensureAtomState = getInternalBuildingBlocks(store)[11];
3582
+ const atomState = ensureAtomState(store, atom);
3571
3583
  const hasPrevValue = "v" in atomState;
3572
3584
  const prevValue = atomState.v;
3573
3585
  if (isPromiseLike$1(valueOrPromise)) {
@@ -3575,7 +3587,7 @@ const setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
3575
3587
  addPendingPromiseToDependency(
3576
3588
  atom,
3577
3589
  valueOrPromise,
3578
- ensureAtomState2(store, a)
3590
+ ensureAtomState(store, a)
3579
3591
  );
3580
3592
  }
3581
3593
  }
@@ -3588,35 +3600,35 @@ const setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
3588
3600
  }
3589
3601
  }
3590
3602
  };
3591
- const storeGet = (store, atom) => {
3592
- const readAtomState2 = getInternalBuildingBlocks(store)[14];
3593
- return returnAtomValue(readAtomState2(store, atom));
3603
+ const BUILDING_BLOCK_storeGet = (store, atom) => {
3604
+ const readAtomState = getInternalBuildingBlocks(store)[14];
3605
+ return returnAtomValue(readAtomState(store, atom));
3594
3606
  };
3595
- const storeSet = (store, atom, ...args) => {
3607
+ const BUILDING_BLOCK_storeSet = (store, atom, ...args) => {
3596
3608
  const buildingBlocks = getInternalBuildingBlocks(store);
3597
- const flushCallbacks2 = buildingBlocks[12];
3598
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
3599
- const writeAtomState2 = buildingBlocks[16];
3609
+ const flushCallbacks = buildingBlocks[12];
3610
+ const recomputeInvalidatedAtoms = buildingBlocks[13];
3611
+ const writeAtomState = buildingBlocks[16];
3600
3612
  try {
3601
- return writeAtomState2(store, atom, ...args);
3613
+ return writeAtomState(store, atom, ...args);
3602
3614
  } finally {
3603
- recomputeInvalidatedAtoms2(store);
3604
- flushCallbacks2(store);
3615
+ recomputeInvalidatedAtoms(store);
3616
+ flushCallbacks(store);
3605
3617
  }
3606
3618
  };
3607
- const storeSub = (store, atom, listener) => {
3619
+ const BUILDING_BLOCK_storeSub = (store, atom, listener) => {
3608
3620
  const buildingBlocks = getInternalBuildingBlocks(store);
3609
- const flushCallbacks2 = buildingBlocks[12];
3610
- const mountAtom2 = buildingBlocks[18];
3611
- const unmountAtom2 = buildingBlocks[19];
3612
- const mounted = mountAtom2(store, atom);
3621
+ const flushCallbacks = buildingBlocks[12];
3622
+ const mountAtom = buildingBlocks[18];
3623
+ const unmountAtom = buildingBlocks[19];
3624
+ const mounted = mountAtom(store, atom);
3613
3625
  const listeners = mounted.l;
3614
3626
  listeners.add(listener);
3615
- flushCallbacks2(store);
3627
+ flushCallbacks(store);
3616
3628
  return () => {
3617
3629
  listeners.delete(listener);
3618
- unmountAtom2(store, atom);
3619
- flushCallbacks2(store);
3630
+ unmountAtom(store, atom);
3631
+ flushCallbacks(store);
3620
3632
  };
3621
3633
  };
3622
3634
  const buildingBlockMap = /* @__PURE__ */ new WeakMap();
@@ -3632,16 +3644,16 @@ const getInternalBuildingBlocks = (store) => {
3632
3644
  function buildStore(...buildArgs) {
3633
3645
  const store = {
3634
3646
  get(atom) {
3635
- const storeGet2 = getInternalBuildingBlocks(store)[21];
3636
- return storeGet2(store, atom);
3647
+ const storeGet = getInternalBuildingBlocks(store)[21];
3648
+ return storeGet(store, atom);
3637
3649
  },
3638
3650
  set(atom, ...args) {
3639
- const storeSet2 = getInternalBuildingBlocks(store)[22];
3640
- return storeSet2(store, atom, ...args);
3651
+ const storeSet = getInternalBuildingBlocks(store)[22];
3652
+ return storeSet(store, atom, ...args);
3641
3653
  },
3642
3654
  sub(atom, listener) {
3643
- const storeSub2 = getInternalBuildingBlocks(store)[23];
3644
- return storeSub2(store, atom, listener);
3655
+ const storeSub = getInternalBuildingBlocks(store)[23];
3656
+ return storeSub(store, atom, listener);
3645
3657
  }
3646
3658
  };
3647
3659
  const buildingBlocks = [
@@ -3661,24 +3673,24 @@ function buildStore(...buildArgs) {
3661
3673
  {},
3662
3674
  // storeHooks
3663
3675
  // atom interceptors
3664
- atomRead,
3665
- atomWrite,
3666
- atomOnInit,
3667
- atomOnMount,
3676
+ BUILDING_BLOCK_atomRead,
3677
+ BUILDING_BLOCK_atomWrite,
3678
+ BUILDING_BLOCK_atomOnInit,
3679
+ BUILDING_BLOCK_atomOnMount,
3668
3680
  // building-block functions
3669
- ensureAtomState,
3670
- flushCallbacks,
3671
- recomputeInvalidatedAtoms,
3672
- readAtomState,
3673
- invalidateDependents,
3674
- writeAtomState,
3675
- mountDependencies,
3676
- mountAtom,
3677
- unmountAtom,
3678
- setAtomStateValueOrPromise,
3679
- storeGet,
3680
- storeSet,
3681
- storeSub,
3681
+ BUILDING_BLOCK_ensureAtomState,
3682
+ BUILDING_BLOCK_flushCallbacks,
3683
+ BUILDING_BLOCK_recomputeInvalidatedAtoms,
3684
+ BUILDING_BLOCK_readAtomState,
3685
+ BUILDING_BLOCK_invalidateDependents,
3686
+ BUILDING_BLOCK_writeAtomState,
3687
+ BUILDING_BLOCK_mountDependencies,
3688
+ BUILDING_BLOCK_mountAtom,
3689
+ BUILDING_BLOCK_unmountAtom,
3690
+ BUILDING_BLOCK_setAtomStateValueOrPromise,
3691
+ BUILDING_BLOCK_storeGet,
3692
+ BUILDING_BLOCK_storeSet,
3693
+ BUILDING_BLOCK_storeSub,
3682
3694
  void 0
3683
3695
  ].map((fn, i) => buildArgs[i] || fn);
3684
3696
  buildingBlockMap.set(store, Object.freeze(buildingBlocks));
@@ -3908,7 +3920,7 @@ function selectAtom(anAtom, selector, equalityFn = Object.is) {
3908
3920
  );
3909
3921
  }
3910
3922
 
3911
- const isPromiseLike$3 = (x) => typeof (x == null ? void 0 : x.then) === "function";
3923
+ const isPromiseLike$2 = (x) => typeof (x == null ? void 0 : x.then) === "function";
3912
3924
  function createJSONStorage(getStringStorage = () => {
3913
3925
  try {
3914
3926
  return window.localStorage;
@@ -3940,7 +3952,7 @@ function createJSONStorage(getStringStorage = () => {
3940
3952
  return lastValue;
3941
3953
  };
3942
3954
  const str = (_b = (_a2 = getStringStorage()) == null ? void 0 : _a2.getItem(key)) != null ? _b : null;
3943
- if (isPromiseLike$3(str)) {
3955
+ if (isPromiseLike$2(str)) {
3944
3956
  return str.then(parse);
3945
3957
  }
3946
3958
  return parse(str);