@storybook/react-native 10.4.3 → 10.4.5-canary-20260529144515

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.
package/dist/index.js CHANGED
@@ -88,7 +88,7 @@ function hasInitialValue(atom) {
88
88
  return "init" in atom;
89
89
  }
90
90
  function isActuallyWritableAtom(atom) {
91
- return !!atom.write;
91
+ return typeof atom.write === "function";
92
92
  }
93
93
  function hasOnMount(atom) {
94
94
  return !!atom.onMount;
@@ -121,25 +121,23 @@ function getMountedOrPendingDependents(atom, atomState, mountedMap) {
121
121
  for (const a of pendingDependents) dependents.add(a);
122
122
  return dependents;
123
123
  }
124
- const BUILDING_BLOCK_atomRead = (_store, atom, ...params) => atom.read(...params);
125
- const BUILDING_BLOCK_atomWrite = (_store, atom, ...params) => atom.write(...params);
126
- const BUILDING_BLOCK_atomOnInit = (store, atom) => {
127
- var _a;
128
- return (_a = atom.INTERNAL_onInit) == null ? void 0 : _a.call(atom, store);
129
- };
130
- const BUILDING_BLOCK_atomOnMount = (_store, atom, setAtom) => {
124
+ function hasOnInit(atom) {
125
+ return !!atom.INTERNAL_onInit;
126
+ }
127
+ const BUILDING_BLOCK_atomRead = (_buildingBlocks, _store, atom, ...params) => atom.read(...params);
128
+ const BUILDING_BLOCK_atomWrite = (_buildingBlocks, _store, atom, ...params) => atom.write(...params);
129
+ const BUILDING_BLOCK_atomOnInit = (_buildingBlocks, store, atom) => atom.INTERNAL_onInit(store);
130
+ const BUILDING_BLOCK_atomOnMount = (_buildingBlocks, _store, atom, setAtom) => {
131
131
  var _a;
132
132
  return (_a = atom.onMount) == null ? void 0 : _a.call(atom, setAtom);
133
133
  };
134
- const BUILDING_BLOCK_ensureAtomState = (store, atom) => {
134
+ const BUILDING_BLOCK_ensureAtomState = (buildingBlocks, store, atom) => {
135
135
  var _a;
136
- const buildingBlocks = getInternalBuildingBlocks(store);
137
136
  const atomStateMap = buildingBlocks[0];
138
- const storeHooks = buildingBlocks[6];
139
- const atomOnInit = buildingBlocks[9];
140
- if (({}.env ? {}.env.MODE : void 0) !== "production" && !atom) throw new Error("Atom is undefined or null");
141
137
  let atomState = atomStateMap.get(atom);
142
138
  if (!atomState) {
139
+ const storeHooks = buildingBlocks[6];
140
+ const atomOnInit = buildingBlocks[9];
143
141
  atomState = {
144
142
  d: /* @__PURE__ */ new Map(),
145
143
  p: /* @__PURE__ */ new Set(),
@@ -147,13 +145,12 @@ const BUILDING_BLOCK_ensureAtomState = (store, atom) => {
147
145
  };
148
146
  atomStateMap.set(atom, atomState);
149
147
  (_a = storeHooks.i) == null || _a.call(storeHooks, atom);
150
- atomOnInit?.(store, atom);
148
+ if (hasOnInit(atom)) atomOnInit(buildingBlocks, store, atom);
151
149
  }
152
150
  return atomState;
153
151
  };
154
- const BUILDING_BLOCK_flushCallbacks = (store) => {
152
+ const BUILDING_BLOCK_flushCallbacks = (buildingBlocks, store) => {
155
153
  var _a;
156
- const buildingBlocks = getInternalBuildingBlocks(store);
157
154
  const mountedMap = buildingBlocks[1];
158
155
  const changedAtoms = buildingBlocks[3];
159
156
  const mountCallbacks = buildingBlocks[4];
@@ -182,12 +179,11 @@ const BUILDING_BLOCK_flushCallbacks = (store) => {
182
179
  for (const fn of mountCallbacks) callbacks.add(fn);
183
180
  mountCallbacks.clear();
184
181
  for (const fn of callbacks) call(fn);
185
- if (changedAtoms.size) recomputeInvalidatedAtoms(store);
182
+ if (changedAtoms.size) recomputeInvalidatedAtoms(buildingBlocks, store);
186
183
  } while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
187
184
  if (errors.length) throw new AggregateError(errors);
188
185
  };
189
- const BUILDING_BLOCK_recomputeInvalidatedAtoms = (store) => {
190
- const buildingBlocks = getInternalBuildingBlocks(store);
186
+ const BUILDING_BLOCK_recomputeInvalidatedAtoms = (buildingBlocks, store) => {
191
187
  const mountedMap = buildingBlocks[1];
192
188
  const invalidatedAtoms = buildingBlocks[2];
193
189
  const changedAtoms = buildingBlocks[3];
@@ -203,7 +199,7 @@ const BUILDING_BLOCK_recomputeInvalidatedAtoms = (store) => {
203
199
  const stackStates = [];
204
200
  for (const atom of changedAtoms) {
205
201
  stackAtoms.push(atom);
206
- stackStates.push(ensureAtomState(store, atom));
202
+ stackStates.push(ensureAtomState(buildingBlocks, store, atom));
207
203
  }
208
204
  while (stackAtoms.length) {
209
205
  const top = stackAtoms.length - 1;
@@ -227,7 +223,7 @@ const BUILDING_BLOCK_recomputeInvalidatedAtoms = (store) => {
227
223
  visiting.add(a);
228
224
  for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) if (!visiting.has(d)) {
229
225
  stackAtoms.push(d);
230
- stackStates.push(ensureAtomState(store, d));
226
+ stackStates.push(ensureAtomState(buildingBlocks, store, d));
231
227
  }
232
228
  }
233
229
  for (let i = sortedReversedAtoms.length - 1; i >= 0; --i) {
@@ -240,16 +236,15 @@ const BUILDING_BLOCK_recomputeInvalidatedAtoms = (store) => {
240
236
  }
241
237
  if (hasChangedDeps) {
242
238
  invalidatedAtoms.set(a, aState.n);
243
- readAtomState(store, a);
244
- mountDependencies(store, a);
239
+ readAtomState(buildingBlocks, store, a);
240
+ mountDependencies(buildingBlocks, store, a);
245
241
  }
246
242
  invalidatedAtoms.delete(a);
247
243
  }
248
244
  };
249
245
  const storeMutationSet = /* @__PURE__ */ new WeakSet();
250
- const BUILDING_BLOCK_readAtomState = (store, atom) => {
246
+ const BUILDING_BLOCK_readAtomState = (buildingBlocks, store, atom) => {
251
247
  var _a, _b;
252
- const buildingBlocks = getInternalBuildingBlocks(store);
253
248
  const mountedMap = buildingBlocks[1];
254
249
  const invalidatedAtoms = buildingBlocks[2];
255
250
  const changedAtoms = buildingBlocks[3];
@@ -264,7 +259,7 @@ const BUILDING_BLOCK_readAtomState = (store, atom) => {
264
259
  const setAtomStateValueOrPromise = buildingBlocks[20];
265
260
  const registerAbortHandler = buildingBlocks[26];
266
261
  const storeEpochHolder = buildingBlocks[28];
267
- const atomState = ensureAtomState(store, atom);
262
+ const atomState = ensureAtomState(buildingBlocks, store, atom);
268
263
  const storeEpochNumber = storeEpochHolder[0];
269
264
  if (isAtomStateInitialized(atomState)) {
270
265
  if (mountedMap.has(atom) && invalidatedAtoms.get(atom) !== atomState.n || atomState.m === storeEpochNumber) {
@@ -272,7 +267,7 @@ const BUILDING_BLOCK_readAtomState = (store, atom) => {
272
267
  return atomState;
273
268
  }
274
269
  let hasChangedDeps = false;
275
- for (const [a, n] of atomState.d) if (readAtomState(store, a).n !== n) {
270
+ for (const [a, n] of atomState.d) if (readAtomState(buildingBlocks, store, a).n !== n) {
276
271
  hasChangedDeps = true;
277
272
  break;
278
273
  }
@@ -289,22 +284,22 @@ const BUILDING_BLOCK_readAtomState = (store, atom) => {
289
284
  const mountDependenciesIfAsync = () => {
290
285
  if (mountedMap.has(atom)) {
291
286
  const shouldRecompute = !changedAtoms.size;
292
- mountDependencies(store, atom);
287
+ mountDependencies(buildingBlocks, store, atom);
293
288
  if (shouldRecompute) {
294
- recomputeInvalidatedAtoms(store);
295
- flushCallbacks(store);
289
+ recomputeInvalidatedAtoms(buildingBlocks, store);
290
+ flushCallbacks(buildingBlocks, store);
296
291
  }
297
292
  }
298
293
  };
299
294
  const getter = (a) => {
300
295
  var _a2;
301
296
  if (a === atom) {
302
- const aState2 = ensureAtomState(store, a);
303
- if (!isAtomStateInitialized(aState2)) if (hasInitialValue(a)) setAtomStateValueOrPromise(store, a, a.init);
297
+ const aState2 = ensureAtomState(buildingBlocks, store, a);
298
+ if (!isAtomStateInitialized(aState2)) if (hasInitialValue(a)) setAtomStateValueOrPromise(buildingBlocks, store, a, a.init);
304
299
  else throw new Error("no atom init");
305
300
  return returnAtomValue(aState2);
306
301
  }
307
- const aState = readAtomState(store, a);
302
+ const aState = readAtomState(buildingBlocks, store, a);
308
303
  try {
309
304
  return returnAtomValue(aState);
310
305
  } finally {
@@ -328,10 +323,10 @@ const BUILDING_BLOCK_readAtomState = (store, atom) => {
328
323
  if (!setSelf && isActuallyWritableAtom(atom)) setSelf = (...args) => {
329
324
  if (({}.env ? {}.env.MODE : void 0) !== "production" && isSync) console.warn("setSelf function cannot be called in sync");
330
325
  if (!isSync) try {
331
- return writeAtomState(store, atom, ...args);
326
+ return writeAtomState(buildingBlocks, store, atom, args);
332
327
  } finally {
333
- recomputeInvalidatedAtoms(store);
334
- flushCallbacks(store);
328
+ recomputeInvalidatedAtoms(buildingBlocks, store);
329
+ flushCallbacks(buildingBlocks, store);
335
330
  }
336
331
  };
337
332
  return setSelf;
@@ -341,11 +336,11 @@ const BUILDING_BLOCK_readAtomState = (store, atom) => {
341
336
  const prevInvalidated = invalidatedAtoms.get(atom) === prevEpochNumber;
342
337
  try {
343
338
  if (({}.env ? {}.env.MODE : void 0) !== "production") storeMutationSet.delete(store);
344
- const valueOrPromise = atomRead(store, atom, getter, options);
339
+ const valueOrPromise = atomRead(buildingBlocks, store, atom, getter, options);
345
340
  if (({}.env ? {}.env.MODE : void 0) !== "production" && storeMutationSet.has(store)) console.warn("Detected store mutation during atom read. This is not supported.");
346
- setAtomStateValueOrPromise(store, atom, valueOrPromise);
341
+ setAtomStateValueOrPromise(buildingBlocks, store, atom, valueOrPromise);
347
342
  if (isPromiseLike$1(valueOrPromise)) {
348
- registerAbortHandler(store, valueOrPromise, () => controller == null ? void 0 : controller.abort());
343
+ registerAbortHandler(buildingBlocks, store, valueOrPromise, () => controller == null ? void 0 : controller.abort());
349
344
  const settle = () => {
350
345
  pruneDependencies();
351
346
  mountDependenciesIfAsync();
@@ -370,17 +365,16 @@ const BUILDING_BLOCK_readAtomState = (store, atom) => {
370
365
  }
371
366
  }
372
367
  };
373
- const BUILDING_BLOCK_invalidateDependents = (store, atom) => {
374
- const buildingBlocks = getInternalBuildingBlocks(store);
368
+ const BUILDING_BLOCK_invalidateDependents = (buildingBlocks, store, atom) => {
375
369
  const mountedMap = buildingBlocks[1];
376
370
  const invalidatedAtoms = buildingBlocks[2];
377
371
  const ensureAtomState = buildingBlocks[11];
378
372
  const stack = [atom];
379
373
  while (stack.length) {
380
374
  const a = stack.pop();
381
- const aState = ensureAtomState(store, a);
375
+ const aState = ensureAtomState(buildingBlocks, store, a);
382
376
  for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) {
383
- const dState = ensureAtomState(store, d);
377
+ const dState = ensureAtomState(buildingBlocks, store, d);
384
378
  if (invalidatedAtoms.get(d) !== dState.n) {
385
379
  invalidatedAtoms.set(d, dState.n);
386
380
  stack.push(d);
@@ -388,8 +382,7 @@ const BUILDING_BLOCK_invalidateDependents = (store, atom) => {
388
382
  }
389
383
  }
390
384
  };
391
- const BUILDING_BLOCK_writeAtomState = (store, atom, ...args) => {
392
- const buildingBlocks = getInternalBuildingBlocks(store);
385
+ const BUILDING_BLOCK_writeAtomState = (buildingBlocks, store, atom, args) => {
393
386
  const changedAtoms = buildingBlocks[3];
394
387
  const storeHooks = buildingBlocks[6];
395
388
  const atomWrite = buildingBlocks[8];
@@ -403,42 +396,41 @@ const BUILDING_BLOCK_writeAtomState = (store, atom, ...args) => {
403
396
  const setAtomStateValueOrPromise = buildingBlocks[20];
404
397
  const storeEpochHolder = buildingBlocks[28];
405
398
  let isSync = true;
406
- const getter = (a) => returnAtomValue(readAtomState(store, a));
399
+ const getter = (a) => returnAtomValue(readAtomState(buildingBlocks, store, a));
407
400
  const setter = (a, ...args2) => {
408
401
  var _a;
409
- const aState = ensureAtomState(store, a);
402
+ const aState = ensureAtomState(buildingBlocks, store, a);
410
403
  try {
411
404
  if (a === atom) {
412
405
  if (!hasInitialValue(a)) throw new Error("atom not writable");
413
406
  if (({}.env ? {}.env.MODE : void 0) !== "production") storeMutationSet.add(store);
414
407
  const prevEpochNumber = aState.n;
415
408
  const v = args2[0];
416
- setAtomStateValueOrPromise(store, a, v);
417
- mountDependencies(store, a);
409
+ setAtomStateValueOrPromise(buildingBlocks, store, a, v);
410
+ mountDependencies(buildingBlocks, store, a);
418
411
  if (prevEpochNumber !== aState.n) {
419
412
  ++storeEpochHolder[0];
420
413
  changedAtoms.add(a);
421
- invalidateDependents(store, a);
414
+ invalidateDependents(buildingBlocks, store, a);
422
415
  (_a = storeHooks.c) == null || _a.call(storeHooks, a);
423
416
  }
424
417
  return;
425
- } else return writeAtomState(store, a, ...args2);
418
+ } else return writeAtomState(buildingBlocks, store, a, args2);
426
419
  } finally {
427
420
  if (!isSync) {
428
- recomputeInvalidatedAtoms(store);
429
- flushCallbacks(store);
421
+ recomputeInvalidatedAtoms(buildingBlocks, store);
422
+ flushCallbacks(buildingBlocks, store);
430
423
  }
431
424
  }
432
425
  };
433
426
  try {
434
- return atomWrite(store, atom, getter, setter, ...args);
427
+ return atomWrite(buildingBlocks, store, atom, getter, setter, ...args);
435
428
  } finally {
436
429
  isSync = false;
437
430
  }
438
431
  };
439
- const BUILDING_BLOCK_mountDependencies = (store, atom) => {
432
+ const BUILDING_BLOCK_mountDependencies = (buildingBlocks, store, atom) => {
440
433
  var _a;
441
- const buildingBlocks = getInternalBuildingBlocks(store);
442
434
  const mountedMap = buildingBlocks[1];
443
435
  const changedAtoms = buildingBlocks[3];
444
436
  const storeHooks = buildingBlocks[6];
@@ -446,28 +438,27 @@ const BUILDING_BLOCK_mountDependencies = (store, atom) => {
446
438
  const invalidateDependents = buildingBlocks[15];
447
439
  const mountAtom = buildingBlocks[18];
448
440
  const unmountAtom = buildingBlocks[19];
449
- const atomState = ensureAtomState(store, atom);
441
+ const atomState = ensureAtomState(buildingBlocks, store, atom);
450
442
  const mounted = mountedMap.get(atom);
451
443
  if (mounted && atomState.d.size > 0) {
452
444
  for (const [a, n] of atomState.d) if (!mounted.d.has(a)) {
453
- const aState = ensureAtomState(store, a);
454
- mountAtom(store, a).t.add(atom);
445
+ const aState = ensureAtomState(buildingBlocks, store, a);
446
+ mountAtom(buildingBlocks, store, a).t.add(atom);
455
447
  mounted.d.add(a);
456
448
  if (n !== aState.n) {
457
449
  changedAtoms.add(a);
458
- invalidateDependents(store, a);
450
+ invalidateDependents(buildingBlocks, store, a);
459
451
  (_a = storeHooks.c) == null || _a.call(storeHooks, a);
460
452
  }
461
453
  }
462
454
  for (const a of mounted.d) if (!atomState.d.has(a)) {
463
455
  mounted.d.delete(a);
464
- unmountAtom(store, a)?.t.delete(atom);
456
+ unmountAtom(buildingBlocks, store, a)?.t.delete(atom);
465
457
  }
466
458
  }
467
459
  };
468
- const BUILDING_BLOCK_mountAtom = (store, atom) => {
460
+ const BUILDING_BLOCK_mountAtom = (buildingBlocks, store, atom) => {
469
461
  var _a;
470
- const buildingBlocks = getInternalBuildingBlocks(store);
471
462
  const mountedMap = buildingBlocks[1];
472
463
  const mountCallbacks = buildingBlocks[4];
473
464
  const storeHooks = buildingBlocks[6];
@@ -478,11 +469,11 @@ const BUILDING_BLOCK_mountAtom = (store, atom) => {
478
469
  const readAtomState = buildingBlocks[14];
479
470
  const writeAtomState = buildingBlocks[16];
480
471
  const mountAtom = buildingBlocks[18];
481
- const atomState = ensureAtomState(store, atom);
472
+ const atomState = ensureAtomState(buildingBlocks, store, atom);
482
473
  let mounted = mountedMap.get(atom);
483
474
  if (!mounted) {
484
- readAtomState(store, atom);
485
- for (const a of atomState.d.keys()) mountAtom(store, a).t.add(atom);
475
+ readAtomState(buildingBlocks, store, atom);
476
+ for (const a of atomState.d.keys()) mountAtom(buildingBlocks, store, a).t.add(atom);
486
477
  mounted = {
487
478
  l: /* @__PURE__ */ new Set(),
488
479
  d: new Set(atomState.d.keys()),
@@ -494,16 +485,16 @@ const BUILDING_BLOCK_mountAtom = (store, atom) => {
494
485
  let isSync = true;
495
486
  const setAtom = (...args) => {
496
487
  try {
497
- return writeAtomState(store, atom, ...args);
488
+ return writeAtomState(buildingBlocks, store, atom, args);
498
489
  } finally {
499
490
  if (!isSync) {
500
- recomputeInvalidatedAtoms(store);
501
- flushCallbacks(store);
491
+ recomputeInvalidatedAtoms(buildingBlocks, store);
492
+ flushCallbacks(buildingBlocks, store);
502
493
  }
503
494
  }
504
495
  };
505
496
  try {
506
- const onUnmount = atomOnMount(store, atom, setAtom);
497
+ const onUnmount = atomOnMount(buildingBlocks, store, atom, setAtom);
507
498
  if (onUnmount) mounted.u = () => {
508
499
  isSync = true;
509
500
  try {
@@ -522,15 +513,14 @@ const BUILDING_BLOCK_mountAtom = (store, atom) => {
522
513
  }
523
514
  return mounted;
524
515
  };
525
- const BUILDING_BLOCK_unmountAtom = (store, atom) => {
516
+ const BUILDING_BLOCK_unmountAtom = (buildingBlocks, store, atom) => {
526
517
  var _a, _b;
527
- const buildingBlocks = getInternalBuildingBlocks(store);
528
518
  const mountedMap = buildingBlocks[1];
529
519
  const unmountCallbacks = buildingBlocks[5];
530
520
  const storeHooks = buildingBlocks[6];
531
521
  const ensureAtomState = buildingBlocks[11];
532
522
  const unmountAtom = buildingBlocks[19];
533
- const atomState = ensureAtomState(store, atom);
523
+ const atomState = ensureAtomState(buildingBlocks, store, atom);
534
524
  let mounted = mountedMap.get(atom);
535
525
  if (!mounted || mounted.l.size) return mounted;
536
526
  let isDependent = false;
@@ -542,63 +532,60 @@ const BUILDING_BLOCK_unmountAtom = (store, atom) => {
542
532
  if (mounted.u) unmountCallbacks.add(mounted.u);
543
533
  mounted = void 0;
544
534
  mountedMap.delete(atom);
545
- for (const a of atomState.d.keys()) unmountAtom(store, a)?.t.delete(atom);
535
+ for (const a of atomState.d.keys()) unmountAtom(buildingBlocks, store, a)?.t.delete(atom);
546
536
  (_b = storeHooks.u) == null || _b.call(storeHooks, atom);
547
537
  return;
548
538
  }
549
539
  return mounted;
550
540
  };
551
- const BUILDING_BLOCK_setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
552
- const buildingBlocks = getInternalBuildingBlocks(store);
541
+ const BUILDING_BLOCK_setAtomStateValueOrPromise = (buildingBlocks, store, atom, valueOrPromise) => {
553
542
  const ensureAtomState = buildingBlocks[11];
554
543
  const abortPromise = buildingBlocks[27];
555
- const atomState = ensureAtomState(store, atom);
544
+ const atomState = ensureAtomState(buildingBlocks, store, atom);
556
545
  const hasPrevValue = "v" in atomState;
557
546
  const prevValue = atomState.v;
558
- if (isPromiseLike$1(valueOrPromise)) for (const a of atomState.d.keys()) addPendingPromiseToDependency(atom, valueOrPromise, ensureAtomState(store, a));
547
+ if (isPromiseLike$1(valueOrPromise)) for (const a of atomState.d.keys()) addPendingPromiseToDependency(atom, valueOrPromise, ensureAtomState(buildingBlocks, store, a));
559
548
  atomState.v = valueOrPromise;
560
549
  delete atomState.e;
561
550
  if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {
562
551
  ++atomState.n;
563
- if (isPromiseLike$1(prevValue)) abortPromise(store, prevValue);
552
+ if (isPromiseLike$1(prevValue)) abortPromise(buildingBlocks, store, prevValue);
564
553
  }
565
554
  };
566
- const BUILDING_BLOCK_storeGet = (store, atom) => {
567
- const readAtomState = getInternalBuildingBlocks(store)[14];
568
- return returnAtomValue(readAtomState(store, atom));
555
+ const BUILDING_BLOCK_storeGet = (buildingBlocks, store, atom) => {
556
+ const readAtomState = buildingBlocks[14];
557
+ return returnAtomValue(readAtomState(buildingBlocks, store, atom));
569
558
  };
570
- const BUILDING_BLOCK_storeSet = (store, atom, ...args) => {
571
- const buildingBlocks = getInternalBuildingBlocks(store);
559
+ const BUILDING_BLOCK_storeSet = (buildingBlocks, store, atom, ...args) => {
572
560
  const changedAtoms = buildingBlocks[3];
573
561
  const flushCallbacks = buildingBlocks[12];
574
562
  const recomputeInvalidatedAtoms = buildingBlocks[13];
575
563
  const writeAtomState = buildingBlocks[16];
576
564
  const prevChangedAtomsSize = changedAtoms.size;
577
565
  try {
578
- return writeAtomState(store, atom, ...args);
566
+ return writeAtomState(buildingBlocks, store, atom, args);
579
567
  } finally {
580
568
  if (changedAtoms.size !== prevChangedAtomsSize) {
581
- recomputeInvalidatedAtoms(store);
582
- flushCallbacks(store);
569
+ recomputeInvalidatedAtoms(buildingBlocks, store);
570
+ flushCallbacks(buildingBlocks, store);
583
571
  }
584
572
  }
585
573
  };
586
- const BUILDING_BLOCK_storeSub = (store, atom, listener) => {
587
- const buildingBlocks = getInternalBuildingBlocks(store);
574
+ const BUILDING_BLOCK_storeSub = (buildingBlocks, store, atom, listener) => {
588
575
  const flushCallbacks = buildingBlocks[12];
589
576
  const mountAtom = buildingBlocks[18];
590
577
  const unmountAtom = buildingBlocks[19];
591
- const listeners = mountAtom(store, atom).l;
578
+ const listeners = mountAtom(buildingBlocks, store, atom).l;
592
579
  listeners.add(listener);
593
- flushCallbacks(store);
580
+ flushCallbacks(buildingBlocks, store);
594
581
  return () => {
595
582
  listeners.delete(listener);
596
- unmountAtom(store, atom);
597
- flushCallbacks(store);
583
+ unmountAtom(buildingBlocks, store, atom);
584
+ flushCallbacks(buildingBlocks, store);
598
585
  };
599
586
  };
600
- const BUILDING_BLOCK_registerAbortHandler = (store, promise, abortHandler) => {
601
- const abortHandlersMap = getInternalBuildingBlocks(store)[25];
587
+ const BUILDING_BLOCK_registerAbortHandler = (buildingBlocks, _store, promise, abortHandler) => {
588
+ const abortHandlersMap = buildingBlocks[25];
602
589
  let abortHandlers = abortHandlersMap.get(promise);
603
590
  if (!abortHandlers) {
604
591
  abortHandlers = /* @__PURE__ */ new Set();
@@ -608,34 +595,27 @@ const BUILDING_BLOCK_registerAbortHandler = (store, promise, abortHandler) => {
608
595
  }
609
596
  abortHandlers.add(abortHandler);
610
597
  };
611
- const BUILDING_BLOCK_abortPromise = (store, promise) => {
612
- getInternalBuildingBlocks(store)[25].get(promise)?.forEach((fn) => fn());
598
+ const BUILDING_BLOCK_abortPromise = (buildingBlocks, _store, promise) => {
599
+ buildingBlocks[25].get(promise)?.forEach((fn) => fn());
613
600
  };
614
601
  const buildingBlockMap = /* @__PURE__ */ new WeakMap();
615
- const getInternalBuildingBlocks = (store) => {
602
+ function getBuildingBlocks(store) {
616
603
  const buildingBlocks = buildingBlockMap.get(store);
617
604
  if (({}.env ? {}.env.MODE : void 0) !== "production" && !buildingBlocks) throw new Error("Store must be created by buildStore to read its building blocks");
618
- return buildingBlocks;
619
- };
620
- function getBuildingBlocks(store) {
621
- const buildingBlocks = getInternalBuildingBlocks(store);
622
605
  const enhanceBuildingBlocks = buildingBlocks[24];
623
- if (enhanceBuildingBlocks) return enhanceBuildingBlocks(buildingBlocks);
606
+ if (enhanceBuildingBlocks) return enhanceBuildingBlocks(buildingBlocks, store);
624
607
  return buildingBlocks;
625
608
  }
626
- function buildStore(...buildArgs) {
609
+ function buildStore(...partialBuildingBlocks) {
627
610
  const store = {
628
611
  get(atom) {
629
- const storeGet = getInternalBuildingBlocks(store)[21];
630
- return storeGet(store, atom);
612
+ return storeGet(buildingBlocks, store, atom);
631
613
  },
632
614
  set(atom, ...args) {
633
- const storeSet = getInternalBuildingBlocks(store)[22];
634
- return storeSet(store, atom, ...args);
615
+ return storeSet(buildingBlocks, store, atom, ...args);
635
616
  },
636
617
  sub(atom, listener) {
637
- const storeSub = getInternalBuildingBlocks(store)[23];
638
- return storeSub(store, atom, listener);
618
+ return storeSub(buildingBlocks, store, atom, listener);
639
619
  }
640
620
  };
641
621
  const buildingBlocks = [
@@ -668,8 +648,11 @@ function buildStore(...buildArgs) {
668
648
  BUILDING_BLOCK_registerAbortHandler,
669
649
  BUILDING_BLOCK_abortPromise,
670
650
  [0]
671
- ].map((fn, i) => buildArgs[i] || fn);
651
+ ].map((fn, i) => partialBuildingBlocks[i] || fn);
672
652
  buildingBlockMap.set(store, Object.freeze(buildingBlocks));
653
+ const storeGet = buildingBlocks[21];
654
+ const storeSet = buildingBlocks[22];
655
+ const storeSub = buildingBlocks[23];
673
656
  return store;
674
657
  }
675
658
  //#endregion
@@ -740,7 +723,8 @@ const use = react$1.default.use || ((promise) => {
740
723
  });
741
724
  const continuablePromiseMap = /* @__PURE__ */ new WeakMap();
742
725
  const createContinuablePromise = (store, promise, getValue) => {
743
- const registerAbortHandler = getBuildingBlocks(store)[26];
726
+ const buildingBlocks = getBuildingBlocks(store);
727
+ const registerAbortHandler = buildingBlocks[26];
744
728
  let continuablePromise = continuablePromiseMap.get(promise);
745
729
  if (!continuablePromise) {
746
730
  continuablePromise = new Promise((resolve, reject) => {
@@ -758,14 +742,14 @@ const createContinuablePromise = (store, promise, getValue) => {
758
742
  continuablePromiseMap.set(nextValue, continuablePromise);
759
743
  curr = nextValue;
760
744
  nextValue.then(onFulfilled(nextValue), onRejected(nextValue));
761
- registerAbortHandler(store, nextValue, onAbort);
745
+ registerAbortHandler(buildingBlocks, store, nextValue, onAbort);
762
746
  } else resolve(nextValue);
763
747
  } catch (e) {
764
748
  reject(e);
765
749
  }
766
750
  };
767
751
  promise.then(onFulfilled(promise), onRejected(promise));
768
- registerAbortHandler(store, promise, onAbort);
752
+ registerAbortHandler(buildingBlocks, store, promise, onAbort);
769
753
  });
770
754
  continuablePromiseMap.set(promise, continuablePromise);
771
755
  }
@@ -86,7 +86,9 @@ function withStorybook(config, options = {
86
86
  configPath: path.resolve(process.cwd(), "./.rnstorybook")
87
87
  }) {
88
88
  const { configPath = path.resolve(process.cwd(), "./.rnstorybook"), websockets, useJs = false, enabled = true, docTools = true, liteMode = false, experimental_mcp = false } = options;
89
- if (!(0, storybook_internal_common.optionalEnvToBoolean)(process.env.STORYBOOK_DISABLE_TELEMETRY) && enabled) (0, storybook_internal_telemetry.telemetry)(process.env.NODE_ENV === "production" ? "build" : "dev", {}).catch((e) => {});
89
+ const disableTelemetry = (0, storybook_internal_common.optionalEnvToBoolean)(process.env.STORYBOOK_DISABLE_TELEMETRY);
90
+ const server = require_env_tools.envVariableToBoolean(process.env.STORYBOOK_SERVER, true);
91
+ if (!disableTelemetry && enabled) (0, storybook_internal_telemetry.telemetry)(process.env.NODE_ENV === "production" ? "build" : "dev", {}).catch((e) => {});
90
92
  if (!enabled) return {
91
93
  ...config,
92
94
  resolver: {
@@ -112,12 +114,13 @@ function withStorybook(config, options = {
112
114
  const generateHost = resolvedWs.host ?? (websockets === "auto" && !process.env.STORYBOOK_WS_HOST ? "auto" : void 0);
113
115
  const port = resolvedWs.port ?? 7007;
114
116
  const secured = resolvedWs.secured;
115
- require_channelServer.createChannelServer({
117
+ const channelWebsocketsEnabled = Boolean(websockets) || Boolean(process.env.STORYBOOK_WS_HOST) || Boolean(resolvedWs.host);
118
+ if (server) require_channelServer.createChannelServer({
116
119
  port,
117
120
  host: bindHost,
118
121
  configPath,
119
122
  experimental_mcp,
120
- websockets: Boolean(websockets) || Boolean(process.env.STORYBOOK_WS_HOST) || Boolean(resolvedWs.host),
123
+ websockets: channelWebsocketsEnabled,
121
124
  secured,
122
125
  ssl: websockets && websockets !== "auto" ? {
123
126
  key: websockets.key,
@@ -71,12 +71,13 @@ var StorybookPlugin = class {
71
71
  */
72
72
  applyEnabled(compiler, { configPath, websockets, useJs, docTools, liteMode, experimental_mcp }) {
73
73
  const resolvedWs = require_env_tools.loadWebsocketEnvOverrides(websockets);
74
+ const server = require_env_tools.envVariableToBoolean(process.env.STORYBOOK_SERVER, true);
74
75
  const bindHost = websockets === "auto" && !process.env.STORYBOOK_WS_HOST ? void 0 : resolvedWs.host;
75
76
  const generateHost = resolvedWs.host ?? (websockets === "auto" && !process.env.STORYBOOK_WS_HOST ? "auto" : void 0);
76
77
  const port = resolvedWs.port ?? 7007;
77
78
  const secured = resolvedWs.secured;
78
79
  const channelWebsocketsEnabled = Boolean(websockets) || Boolean(process.env.STORYBOOK_WS_HOST) || Boolean(resolvedWs.host);
79
- if ((experimental_mcp || websockets != null || process.env.STORYBOOK_WS_HOST) && !this.serverStarted) {
80
+ if ((experimental_mcp || websockets != null || process.env.STORYBOOK_WS_HOST) && !this.serverStarted && server) {
80
81
  this.serverStarted = true;
81
82
  require_channelServer.createChannelServer({
82
83
  port,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "10.4.3",
3
+ "version": "10.4.5-canary-20260529144515",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -44,11 +44,11 @@
44
44
  "metro/**/*"
45
45
  ],
46
46
  "dependencies": {
47
- "@storybook/mcp": "^0.6.1",
48
- "@storybook/react": "^10.3.2",
49
- "@storybook/react-native-theming": "^10.4.3",
50
- "@storybook/react-native-ui": "^10.4.3",
51
- "@storybook/react-native-ui-common": "^10.4.3",
47
+ "@storybook/mcp": "^0.7.0",
48
+ "@storybook/react": "^10.4.0",
49
+ "@storybook/react-native-theming": "10.4.5-canary-20260529144515",
50
+ "@storybook/react-native-ui": "10.4.5-canary-20260529144515",
51
+ "@storybook/react-native-ui-common": "10.4.5-canary-20260529144515",
52
52
  "@tmcp/adapter-valibot": "^0.1.4",
53
53
  "@tmcp/transport-http": "^0.8.5",
54
54
  "commander": "^14.0.2",
@@ -69,11 +69,11 @@
69
69
  "babel-jest": "^29.7.0",
70
70
  "babel-preset-expo": "^55.0.13",
71
71
  "jest": "^29.7.0",
72
- "jest-expo": "~56.0.0",
72
+ "jest-expo": "~56.0.1",
73
73
  "jotai": "^2.19.0",
74
74
  "react": "19.2.3",
75
75
  "react-native": "0.85.3",
76
- "storybook": "^10.3.2",
76
+ "storybook": "^10.4.0",
77
77
  "sucrase": "^3.35.1",
78
78
  "test-renderer": "^0.15.0",
79
79
  "tsdown": "^0.22.0",