@storybook/react-native 7.0.0-alpha.8 → 7.6.7-alpha.1
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/V6.d.ts +4 -4
- package/dist/V6.js +73 -49
- package/dist/{View-8eae84cb.d.ts → View-acca1d49.d.ts} +1 -1
- package/dist/{index.d-680e82dc.d.ts → index.d-82fc9196.d.ts} +11 -11
- package/dist/index.d.ts +4 -4
- package/dist/index.js +73 -49
- package/dist/preview.d.ts +4 -3
- package/dist/preview.js +2 -2
- package/package.json +15 -15
- package/scripts/generate.js +1 -1
package/dist/V6.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { P as Params, R as ReactNativeFramework } from './View-
|
|
3
|
-
export { C as ComponentMeta, c as ComponentStory, a as ComponentStoryFn, b as ComponentStoryObj, M as Meta, f as Story, d as StoryFn, S as StoryFnReactReturnType, e as StoryObj } from './View-
|
|
2
|
+
import { P as Params, R as ReactNativeFramework } from './View-acca1d49.js';
|
|
3
|
+
export { C as ComponentMeta, c as ComponentStory, a as ComponentStoryFn, b as ComponentStoryObj, M as Meta, f as Story, d as StoryFn, S as StoryFnReactReturnType, e as StoryObj } from './View-acca1d49.js';
|
|
4
4
|
import { ClientApi } from '@storybook/preview-api';
|
|
5
|
-
import { b as Addon_StoryApi } from './index.d-
|
|
6
|
-
export { a as ArgTypes, A as Args, P as Parameters, S as StoryContext } from './index.d-
|
|
5
|
+
import { b as Addon_StoryApi } from './index.d-82fc9196.js';
|
|
6
|
+
export { a as ArgTypes, A as Args, P as Parameters, S as StoryContext } from './index.d-82fc9196.js';
|
|
7
7
|
import { ReactNode } from 'react';
|
|
8
8
|
export { Theme, darkTheme, theme } from '@storybook/react-native-theming';
|
|
9
9
|
import '@storybook/csf';
|
package/dist/V6.js
CHANGED
|
@@ -102,11 +102,15 @@ function atom(read, write) {
|
|
|
102
102
|
config.read = read;
|
|
103
103
|
} else {
|
|
104
104
|
config.init = read;
|
|
105
|
-
config.read = (get)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
config.read = function(get) {
|
|
106
|
+
return get(this);
|
|
107
|
+
};
|
|
108
|
+
config.write = function(get, set, arg) {
|
|
109
|
+
return set(
|
|
110
|
+
this,
|
|
111
|
+
typeof arg === "function" ? arg(get(this)) : arg
|
|
112
|
+
);
|
|
113
|
+
};
|
|
110
114
|
}
|
|
111
115
|
if (write) {
|
|
112
116
|
config.write = write;
|
|
@@ -137,9 +141,9 @@ var rejectPromise = (promise, e) => {
|
|
|
137
141
|
promise.reason = e;
|
|
138
142
|
};
|
|
139
143
|
var isPromiseLike = (x) => typeof (x == null ? void 0 : x.then) === "function";
|
|
140
|
-
var isEqualAtomValue = (a, b) => "v" in a && "v" in b && Object.is(a.v, b.v);
|
|
141
|
-
var isEqualAtomError = (a, b) => "e" in a && "e" in b && Object.is(a.e, b.e);
|
|
142
|
-
var hasPromiseAtomValue = (a) => "v" in a && a.v instanceof Promise;
|
|
144
|
+
var isEqualAtomValue = (a, b) => !!a && "v" in a && "v" in b && Object.is(a.v, b.v);
|
|
145
|
+
var isEqualAtomError = (a, b) => !!a && "e" in a && "e" in b && Object.is(a.e, b.e);
|
|
146
|
+
var hasPromiseAtomValue = (a) => !!a && "v" in a && a.v instanceof Promise;
|
|
143
147
|
var isEqualPromiseAtomValue = (a, b) => "v" in a && "v" in b && a.v.orig && a.v.orig === b.v.orig;
|
|
144
148
|
var returnAtomValue = (atomState) => {
|
|
145
149
|
if ("e" in atomState) {
|
|
@@ -167,9 +171,11 @@ var createStore = () => {
|
|
|
167
171
|
if (!pendingMap.has(atom2)) {
|
|
168
172
|
pendingMap.set(atom2, prevAtomState);
|
|
169
173
|
}
|
|
170
|
-
if (
|
|
174
|
+
if (hasPromiseAtomValue(prevAtomState)) {
|
|
171
175
|
const next = "v" in atomState ? atomState.v instanceof Promise ? atomState.v : Promise.resolve(atomState.v) : Promise.reject(atomState.e);
|
|
172
|
-
|
|
176
|
+
if (prevAtomState.v !== next) {
|
|
177
|
+
cancelPromise(prevAtomState.v, next);
|
|
178
|
+
}
|
|
173
179
|
}
|
|
174
180
|
};
|
|
175
181
|
const updateDependencies = (atom2, nextAtomState, nextDependencies) => {
|
|
@@ -201,10 +207,10 @@ var createStore = () => {
|
|
|
201
207
|
if (nextDependencies) {
|
|
202
208
|
updateDependencies(atom2, nextAtomState, nextDependencies);
|
|
203
209
|
}
|
|
204
|
-
if (
|
|
210
|
+
if (isEqualAtomValue(prevAtomState, nextAtomState) && prevAtomState.d === nextAtomState.d) {
|
|
205
211
|
return prevAtomState;
|
|
206
212
|
}
|
|
207
|
-
if (
|
|
213
|
+
if (hasPromiseAtomValue(prevAtomState) && hasPromiseAtomValue(nextAtomState) && isEqualPromiseAtomValue(prevAtomState, nextAtomState)) {
|
|
208
214
|
if (prevAtomState.d === nextAtomState.d) {
|
|
209
215
|
return prevAtomState;
|
|
210
216
|
} else {
|
|
@@ -217,39 +223,37 @@ var createStore = () => {
|
|
|
217
223
|
const setAtomValueOrPromise = (atom2, valueOrPromise, nextDependencies, abortPromise) => {
|
|
218
224
|
if (isPromiseLike(valueOrPromise)) {
|
|
219
225
|
let continuePromise;
|
|
226
|
+
const updatePromiseDependencies = () => {
|
|
227
|
+
const prevAtomState = getAtomState(atom2);
|
|
228
|
+
if (!hasPromiseAtomValue(prevAtomState) || prevAtomState.v !== promise) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const nextAtomState = setAtomValue(
|
|
232
|
+
atom2,
|
|
233
|
+
promise,
|
|
234
|
+
nextDependencies
|
|
235
|
+
);
|
|
236
|
+
if (mountedMap.has(atom2) && prevAtomState.d !== nextAtomState.d) {
|
|
237
|
+
mountDependencies(atom2, nextAtomState, prevAtomState.d);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
220
240
|
const promise = new Promise((resolve, reject) => {
|
|
221
241
|
let settled = false;
|
|
222
242
|
valueOrPromise.then(
|
|
223
243
|
(v) => {
|
|
224
244
|
if (!settled) {
|
|
225
245
|
settled = true;
|
|
226
|
-
const prevAtomState = getAtomState(atom2);
|
|
227
|
-
const nextAtomState = setAtomValue(
|
|
228
|
-
atom2,
|
|
229
|
-
promise,
|
|
230
|
-
nextDependencies
|
|
231
|
-
);
|
|
232
246
|
resolvePromise(promise, v);
|
|
233
247
|
resolve(v);
|
|
234
|
-
|
|
235
|
-
mountDependencies(atom2, nextAtomState, prevAtomState == null ? void 0 : prevAtomState.d);
|
|
236
|
-
}
|
|
248
|
+
updatePromiseDependencies();
|
|
237
249
|
}
|
|
238
250
|
},
|
|
239
251
|
(e) => {
|
|
240
252
|
if (!settled) {
|
|
241
253
|
settled = true;
|
|
242
|
-
const prevAtomState = getAtomState(atom2);
|
|
243
|
-
const nextAtomState = setAtomValue(
|
|
244
|
-
atom2,
|
|
245
|
-
promise,
|
|
246
|
-
nextDependencies
|
|
247
|
-
);
|
|
248
254
|
rejectPromise(promise, e);
|
|
249
255
|
reject(e);
|
|
250
|
-
|
|
251
|
-
mountDependencies(atom2, nextAtomState, prevAtomState == null ? void 0 : prevAtomState.d);
|
|
252
|
-
}
|
|
256
|
+
updatePromiseDependencies();
|
|
253
257
|
}
|
|
254
258
|
}
|
|
255
259
|
);
|
|
@@ -285,7 +289,7 @@ var createStore = () => {
|
|
|
285
289
|
if (nextDependencies) {
|
|
286
290
|
updateDependencies(atom2, nextAtomState, nextDependencies);
|
|
287
291
|
}
|
|
288
|
-
if (
|
|
292
|
+
if (isEqualAtomError(prevAtomState, nextAtomState) && prevAtomState.d === nextAtomState.d) {
|
|
289
293
|
return prevAtomState;
|
|
290
294
|
}
|
|
291
295
|
setAtomState(atom2, nextAtomState);
|
|
@@ -297,9 +301,13 @@ var createStore = () => {
|
|
|
297
301
|
if (mountedMap.has(atom2)) {
|
|
298
302
|
return atomState;
|
|
299
303
|
}
|
|
300
|
-
if (Array.from(atomState.d).every(
|
|
301
|
-
(
|
|
302
|
-
|
|
304
|
+
if (Array.from(atomState.d).every(([a, s]) => {
|
|
305
|
+
if (a === atom2) {
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
const aState = readAtomState(a);
|
|
309
|
+
return aState === s || isEqualAtomValue(aState, s);
|
|
310
|
+
})) {
|
|
303
311
|
return atomState;
|
|
304
312
|
}
|
|
305
313
|
}
|
|
@@ -380,9 +388,19 @@ var createStore = () => {
|
|
|
380
388
|
const recomputeDependents = (atom2) => {
|
|
381
389
|
const dependencyMap = /* @__PURE__ */ new Map();
|
|
382
390
|
const dirtyMap = /* @__PURE__ */ new WeakMap();
|
|
391
|
+
const getDependents = (a) => {
|
|
392
|
+
var _a;
|
|
393
|
+
const dependents = new Set((_a = mountedMap.get(a)) == null ? void 0 : _a.t);
|
|
394
|
+
pendingMap.forEach((_, pendingAtom) => {
|
|
395
|
+
var _a2;
|
|
396
|
+
if ((_a2 = getAtomState(pendingAtom)) == null ? void 0 : _a2.d.has(a)) {
|
|
397
|
+
dependents.add(pendingAtom);
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
return dependents;
|
|
401
|
+
};
|
|
383
402
|
const loop1 = (a) => {
|
|
384
|
-
|
|
385
|
-
mounted == null ? void 0 : mounted.t.forEach((dependent) => {
|
|
403
|
+
getDependents(a).forEach((dependent) => {
|
|
386
404
|
if (dependent !== a) {
|
|
387
405
|
dependencyMap.set(
|
|
388
406
|
dependent,
|
|
@@ -395,8 +413,7 @@ var createStore = () => {
|
|
|
395
413
|
};
|
|
396
414
|
loop1(atom2);
|
|
397
415
|
const loop2 = (a) => {
|
|
398
|
-
|
|
399
|
-
mounted == null ? void 0 : mounted.t.forEach((dependent) => {
|
|
416
|
+
getDependents(a).forEach((dependent) => {
|
|
400
417
|
var _a;
|
|
401
418
|
if (dependent !== a) {
|
|
402
419
|
let dirtyCount = dirtyMap.get(dependent);
|
|
@@ -408,7 +425,7 @@ var createStore = () => {
|
|
|
408
425
|
if (isChanged) {
|
|
409
426
|
const prevAtomState = getAtomState(dependent);
|
|
410
427
|
const nextAtomState = readAtomState(dependent, true);
|
|
411
|
-
isChanged = !
|
|
428
|
+
isChanged = !isEqualAtomValue(prevAtomState, nextAtomState);
|
|
412
429
|
}
|
|
413
430
|
if (!isChanged) {
|
|
414
431
|
dependencyMap.forEach((s) => s.delete(dependent));
|
|
@@ -431,7 +448,7 @@ var createStore = () => {
|
|
|
431
448
|
}
|
|
432
449
|
const prevAtomState = getAtomState(a);
|
|
433
450
|
const nextAtomState = setAtomValueOrPromise(a, args2[0]);
|
|
434
|
-
if (!
|
|
451
|
+
if (!isEqualAtomValue(prevAtomState, nextAtomState)) {
|
|
435
452
|
recomputeDependents(a);
|
|
436
453
|
}
|
|
437
454
|
} else {
|
|
@@ -461,15 +478,16 @@ var createStore = () => {
|
|
|
461
478
|
}
|
|
462
479
|
return result;
|
|
463
480
|
};
|
|
464
|
-
const mountAtom = (atom2, initialDependent) => {
|
|
481
|
+
const mountAtom = (atom2, initialDependent, onMountQueue) => {
|
|
465
482
|
var _a;
|
|
483
|
+
const queue = onMountQueue || [];
|
|
466
484
|
(_a = getAtomState(atom2)) == null ? void 0 : _a.d.forEach((_, a) => {
|
|
467
485
|
const aMounted = mountedMap.get(a);
|
|
468
486
|
if (aMounted) {
|
|
469
487
|
aMounted.t.add(atom2);
|
|
470
488
|
} else {
|
|
471
489
|
if (a !== atom2) {
|
|
472
|
-
mountAtom(a, atom2);
|
|
490
|
+
mountAtom(a, atom2, queue);
|
|
473
491
|
}
|
|
474
492
|
}
|
|
475
493
|
});
|
|
@@ -483,10 +501,16 @@ var createStore = () => {
|
|
|
483
501
|
mountedAtoms.add(atom2);
|
|
484
502
|
}
|
|
485
503
|
if (isActuallyWritableAtom(atom2) && atom2.onMount) {
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
504
|
+
const { onMount } = atom2;
|
|
505
|
+
queue.push(() => {
|
|
506
|
+
const onUnmount = onMount((...args) => writeAtom(atom2, ...args));
|
|
507
|
+
if (onUnmount) {
|
|
508
|
+
mounted.u = onUnmount;
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
if (!onMountQueue) {
|
|
513
|
+
queue.forEach((f) => f());
|
|
490
514
|
}
|
|
491
515
|
return mounted;
|
|
492
516
|
};
|
|
@@ -555,13 +579,13 @@ var createStore = () => {
|
|
|
555
579
|
pending.forEach(([atom2, prevAtomState]) => {
|
|
556
580
|
const atomState = getAtomState(atom2);
|
|
557
581
|
if (atomState) {
|
|
558
|
-
|
|
582
|
+
const mounted = mountedMap.get(atom2);
|
|
583
|
+
if (mounted && atomState.d !== (prevAtomState == null ? void 0 : prevAtomState.d)) {
|
|
559
584
|
mountDependencies(atom2, atomState, prevAtomState == null ? void 0 : prevAtomState.d);
|
|
560
585
|
}
|
|
561
|
-
const mounted = mountedMap.get(atom2);
|
|
562
586
|
if (mounted && !// TODO This seems pretty hacky. Hope to fix it.
|
|
563
587
|
// Maybe we could `mountDependencies` in `setAtomState`?
|
|
564
|
-
(
|
|
588
|
+
(!hasPromiseAtomValue(prevAtomState) && (isEqualAtomValue(prevAtomState, atomState) || isEqualAtomError(prevAtomState, atomState)))) {
|
|
565
589
|
mounted.l.forEach((listener) => listener());
|
|
566
590
|
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
567
591
|
flushed.add(atom2);
|
|
@@ -2,7 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import { Renderer, Args, ComponentAnnotations, AnnotatedStoryFn, StoryAnnotations, StoryContext } from '@storybook/csf';
|
|
3
3
|
import { PreviewWithSelection } from '@storybook/preview-web';
|
|
4
4
|
import { Theme } from '@storybook/react-native-theming';
|
|
5
|
-
import { c as StoryIndex } from './index.d-
|
|
5
|
+
import { c as StoryIndex } from './index.d-82fc9196.js';
|
|
6
6
|
import { ReactElement, ComponentType, JSXElementConstructor, ComponentProps } from 'react';
|
|
7
7
|
import { Channel } from '@storybook/channels';
|
|
8
8
|
|
|
@@ -94,9 +94,9 @@ type ArgTypes<TArgs = Args> = {
|
|
|
94
94
|
type StrictArgTypes<TArgs = Args> = {
|
|
95
95
|
[name in keyof TArgs]: StrictInputType;
|
|
96
96
|
};
|
|
97
|
-
|
|
97
|
+
interface Globals {
|
|
98
98
|
[name: string]: any;
|
|
99
|
-
}
|
|
99
|
+
}
|
|
100
100
|
type Renderer = {
|
|
101
101
|
/** What is the type of the `component` annotation in this renderer? */
|
|
102
102
|
component: unknown;
|
|
@@ -106,7 +106,7 @@ type Renderer = {
|
|
|
106
106
|
canvasElement: unknown;
|
|
107
107
|
T?: unknown;
|
|
108
108
|
};
|
|
109
|
-
|
|
109
|
+
interface StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryIdentifier {
|
|
110
110
|
component?: (TRenderer & {
|
|
111
111
|
T: any;
|
|
112
112
|
})['component'];
|
|
@@ -116,24 +116,24 @@ type StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TArgs = Arg
|
|
|
116
116
|
parameters: Parameters;
|
|
117
117
|
initialArgs: TArgs;
|
|
118
118
|
argTypes: StrictArgTypes<TArgs>;
|
|
119
|
-
}
|
|
120
|
-
|
|
119
|
+
}
|
|
120
|
+
interface StoryContextUpdate<TArgs = Args> {
|
|
121
121
|
args?: TArgs;
|
|
122
122
|
globals?: Globals;
|
|
123
123
|
[key: string]: any;
|
|
124
|
-
}
|
|
124
|
+
}
|
|
125
125
|
type ViewMode$1 = 'story' | 'docs';
|
|
126
|
-
|
|
126
|
+
interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContextForEnhancers<TRenderer, TArgs>, Required<StoryContextUpdate<TArgs>> {
|
|
127
127
|
hooks: unknown;
|
|
128
128
|
viewMode: ViewMode$1;
|
|
129
129
|
originalStoryFn: StoryFn<TRenderer>;
|
|
130
|
-
}
|
|
131
|
-
type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForLoaders<TRenderer, TArgs>) => Promise<Record<string, any
|
|
132
|
-
|
|
130
|
+
}
|
|
131
|
+
type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForLoaders<TRenderer, TArgs>) => Promise<Record<string, any> | void> | Record<string, any> | void;
|
|
132
|
+
interface StoryContext<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContextForLoaders<TRenderer, TArgs> {
|
|
133
133
|
loaded: Record<string, any>;
|
|
134
134
|
abortSignal: AbortSignal;
|
|
135
135
|
canvasElement: TRenderer['canvasElement'];
|
|
136
|
-
}
|
|
136
|
+
}
|
|
137
137
|
type PartialStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TRenderer['storyResult'];
|
|
138
138
|
type LegacyStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
|
139
139
|
type ArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (args: TArgs, context: StoryContext<TRenderer, TArgs>) => (TRenderer & {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { V as View } from './View-
|
|
2
|
-
export { C as ComponentMeta, c as ComponentStory, a as ComponentStoryFn, b as ComponentStoryObj, M as Meta, R as ReactNativeFramework, f as Story, d as StoryFn, S as StoryFnReactReturnType, e as StoryObj } from './View-
|
|
1
|
+
import { V as View } from './View-acca1d49.js';
|
|
2
|
+
export { C as ComponentMeta, c as ComponentStory, a as ComponentStoryFn, b as ComponentStoryObj, M as Meta, R as ReactNativeFramework, f as Story, d as StoryFn, S as StoryFnReactReturnType, e as StoryObj } from './View-acca1d49.js';
|
|
3
3
|
export { Theme, darkTheme, theme } from '@storybook/react-native-theming';
|
|
4
|
-
import { N as NormalizedStoriesSpecifier } from './index.d-
|
|
5
|
-
export { a as ArgTypes, A as Args, P as Parameters, S as StoryContext } from './index.d-
|
|
4
|
+
import { N as NormalizedStoriesSpecifier } from './index.d-82fc9196.js';
|
|
5
|
+
export { a as ArgTypes, A as Args, P as Parameters, S as StoryContext } from './index.d-82fc9196.js';
|
|
6
6
|
import 'react/jsx-runtime';
|
|
7
7
|
import '@storybook/csf';
|
|
8
8
|
import '@storybook/preview-web';
|
package/dist/index.js
CHANGED
|
@@ -95,11 +95,15 @@ function atom(read, write) {
|
|
|
95
95
|
config.read = read;
|
|
96
96
|
} else {
|
|
97
97
|
config.init = read;
|
|
98
|
-
config.read = (get)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
config.read = function(get) {
|
|
99
|
+
return get(this);
|
|
100
|
+
};
|
|
101
|
+
config.write = function(get, set, arg) {
|
|
102
|
+
return set(
|
|
103
|
+
this,
|
|
104
|
+
typeof arg === "function" ? arg(get(this)) : arg
|
|
105
|
+
);
|
|
106
|
+
};
|
|
103
107
|
}
|
|
104
108
|
if (write) {
|
|
105
109
|
config.write = write;
|
|
@@ -130,9 +134,9 @@ var rejectPromise = (promise, e) => {
|
|
|
130
134
|
promise.reason = e;
|
|
131
135
|
};
|
|
132
136
|
var isPromiseLike = (x) => typeof (x == null ? void 0 : x.then) === "function";
|
|
133
|
-
var isEqualAtomValue = (a, b) => "v" in a && "v" in b && Object.is(a.v, b.v);
|
|
134
|
-
var isEqualAtomError = (a, b) => "e" in a && "e" in b && Object.is(a.e, b.e);
|
|
135
|
-
var hasPromiseAtomValue = (a) => "v" in a && a.v instanceof Promise;
|
|
137
|
+
var isEqualAtomValue = (a, b) => !!a && "v" in a && "v" in b && Object.is(a.v, b.v);
|
|
138
|
+
var isEqualAtomError = (a, b) => !!a && "e" in a && "e" in b && Object.is(a.e, b.e);
|
|
139
|
+
var hasPromiseAtomValue = (a) => !!a && "v" in a && a.v instanceof Promise;
|
|
136
140
|
var isEqualPromiseAtomValue = (a, b) => "v" in a && "v" in b && a.v.orig && a.v.orig === b.v.orig;
|
|
137
141
|
var returnAtomValue = (atomState) => {
|
|
138
142
|
if ("e" in atomState) {
|
|
@@ -160,9 +164,11 @@ var createStore = () => {
|
|
|
160
164
|
if (!pendingMap.has(atom2)) {
|
|
161
165
|
pendingMap.set(atom2, prevAtomState);
|
|
162
166
|
}
|
|
163
|
-
if (
|
|
167
|
+
if (hasPromiseAtomValue(prevAtomState)) {
|
|
164
168
|
const next = "v" in atomState ? atomState.v instanceof Promise ? atomState.v : Promise.resolve(atomState.v) : Promise.reject(atomState.e);
|
|
165
|
-
|
|
169
|
+
if (prevAtomState.v !== next) {
|
|
170
|
+
cancelPromise(prevAtomState.v, next);
|
|
171
|
+
}
|
|
166
172
|
}
|
|
167
173
|
};
|
|
168
174
|
const updateDependencies = (atom2, nextAtomState, nextDependencies) => {
|
|
@@ -194,10 +200,10 @@ var createStore = () => {
|
|
|
194
200
|
if (nextDependencies) {
|
|
195
201
|
updateDependencies(atom2, nextAtomState, nextDependencies);
|
|
196
202
|
}
|
|
197
|
-
if (
|
|
203
|
+
if (isEqualAtomValue(prevAtomState, nextAtomState) && prevAtomState.d === nextAtomState.d) {
|
|
198
204
|
return prevAtomState;
|
|
199
205
|
}
|
|
200
|
-
if (
|
|
206
|
+
if (hasPromiseAtomValue(prevAtomState) && hasPromiseAtomValue(nextAtomState) && isEqualPromiseAtomValue(prevAtomState, nextAtomState)) {
|
|
201
207
|
if (prevAtomState.d === nextAtomState.d) {
|
|
202
208
|
return prevAtomState;
|
|
203
209
|
} else {
|
|
@@ -210,39 +216,37 @@ var createStore = () => {
|
|
|
210
216
|
const setAtomValueOrPromise = (atom2, valueOrPromise, nextDependencies, abortPromise) => {
|
|
211
217
|
if (isPromiseLike(valueOrPromise)) {
|
|
212
218
|
let continuePromise;
|
|
219
|
+
const updatePromiseDependencies = () => {
|
|
220
|
+
const prevAtomState = getAtomState(atom2);
|
|
221
|
+
if (!hasPromiseAtomValue(prevAtomState) || prevAtomState.v !== promise) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const nextAtomState = setAtomValue(
|
|
225
|
+
atom2,
|
|
226
|
+
promise,
|
|
227
|
+
nextDependencies
|
|
228
|
+
);
|
|
229
|
+
if (mountedMap.has(atom2) && prevAtomState.d !== nextAtomState.d) {
|
|
230
|
+
mountDependencies(atom2, nextAtomState, prevAtomState.d);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
213
233
|
const promise = new Promise((resolve, reject) => {
|
|
214
234
|
let settled = false;
|
|
215
235
|
valueOrPromise.then(
|
|
216
236
|
(v) => {
|
|
217
237
|
if (!settled) {
|
|
218
238
|
settled = true;
|
|
219
|
-
const prevAtomState = getAtomState(atom2);
|
|
220
|
-
const nextAtomState = setAtomValue(
|
|
221
|
-
atom2,
|
|
222
|
-
promise,
|
|
223
|
-
nextDependencies
|
|
224
|
-
);
|
|
225
239
|
resolvePromise(promise, v);
|
|
226
240
|
resolve(v);
|
|
227
|
-
|
|
228
|
-
mountDependencies(atom2, nextAtomState, prevAtomState == null ? void 0 : prevAtomState.d);
|
|
229
|
-
}
|
|
241
|
+
updatePromiseDependencies();
|
|
230
242
|
}
|
|
231
243
|
},
|
|
232
244
|
(e) => {
|
|
233
245
|
if (!settled) {
|
|
234
246
|
settled = true;
|
|
235
|
-
const prevAtomState = getAtomState(atom2);
|
|
236
|
-
const nextAtomState = setAtomValue(
|
|
237
|
-
atom2,
|
|
238
|
-
promise,
|
|
239
|
-
nextDependencies
|
|
240
|
-
);
|
|
241
247
|
rejectPromise(promise, e);
|
|
242
248
|
reject(e);
|
|
243
|
-
|
|
244
|
-
mountDependencies(atom2, nextAtomState, prevAtomState == null ? void 0 : prevAtomState.d);
|
|
245
|
-
}
|
|
249
|
+
updatePromiseDependencies();
|
|
246
250
|
}
|
|
247
251
|
}
|
|
248
252
|
);
|
|
@@ -278,7 +282,7 @@ var createStore = () => {
|
|
|
278
282
|
if (nextDependencies) {
|
|
279
283
|
updateDependencies(atom2, nextAtomState, nextDependencies);
|
|
280
284
|
}
|
|
281
|
-
if (
|
|
285
|
+
if (isEqualAtomError(prevAtomState, nextAtomState) && prevAtomState.d === nextAtomState.d) {
|
|
282
286
|
return prevAtomState;
|
|
283
287
|
}
|
|
284
288
|
setAtomState(atom2, nextAtomState);
|
|
@@ -290,9 +294,13 @@ var createStore = () => {
|
|
|
290
294
|
if (mountedMap.has(atom2)) {
|
|
291
295
|
return atomState;
|
|
292
296
|
}
|
|
293
|
-
if (Array.from(atomState.d).every(
|
|
294
|
-
(
|
|
295
|
-
|
|
297
|
+
if (Array.from(atomState.d).every(([a, s]) => {
|
|
298
|
+
if (a === atom2) {
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
const aState = readAtomState(a);
|
|
302
|
+
return aState === s || isEqualAtomValue(aState, s);
|
|
303
|
+
})) {
|
|
296
304
|
return atomState;
|
|
297
305
|
}
|
|
298
306
|
}
|
|
@@ -373,9 +381,19 @@ var createStore = () => {
|
|
|
373
381
|
const recomputeDependents = (atom2) => {
|
|
374
382
|
const dependencyMap = /* @__PURE__ */ new Map();
|
|
375
383
|
const dirtyMap = /* @__PURE__ */ new WeakMap();
|
|
384
|
+
const getDependents = (a) => {
|
|
385
|
+
var _a;
|
|
386
|
+
const dependents = new Set((_a = mountedMap.get(a)) == null ? void 0 : _a.t);
|
|
387
|
+
pendingMap.forEach((_, pendingAtom) => {
|
|
388
|
+
var _a2;
|
|
389
|
+
if ((_a2 = getAtomState(pendingAtom)) == null ? void 0 : _a2.d.has(a)) {
|
|
390
|
+
dependents.add(pendingAtom);
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
return dependents;
|
|
394
|
+
};
|
|
376
395
|
const loop1 = (a) => {
|
|
377
|
-
|
|
378
|
-
mounted == null ? void 0 : mounted.t.forEach((dependent) => {
|
|
396
|
+
getDependents(a).forEach((dependent) => {
|
|
379
397
|
if (dependent !== a) {
|
|
380
398
|
dependencyMap.set(
|
|
381
399
|
dependent,
|
|
@@ -388,8 +406,7 @@ var createStore = () => {
|
|
|
388
406
|
};
|
|
389
407
|
loop1(atom2);
|
|
390
408
|
const loop2 = (a) => {
|
|
391
|
-
|
|
392
|
-
mounted == null ? void 0 : mounted.t.forEach((dependent) => {
|
|
409
|
+
getDependents(a).forEach((dependent) => {
|
|
393
410
|
var _a;
|
|
394
411
|
if (dependent !== a) {
|
|
395
412
|
let dirtyCount = dirtyMap.get(dependent);
|
|
@@ -401,7 +418,7 @@ var createStore = () => {
|
|
|
401
418
|
if (isChanged) {
|
|
402
419
|
const prevAtomState = getAtomState(dependent);
|
|
403
420
|
const nextAtomState = readAtomState(dependent, true);
|
|
404
|
-
isChanged = !
|
|
421
|
+
isChanged = !isEqualAtomValue(prevAtomState, nextAtomState);
|
|
405
422
|
}
|
|
406
423
|
if (!isChanged) {
|
|
407
424
|
dependencyMap.forEach((s) => s.delete(dependent));
|
|
@@ -424,7 +441,7 @@ var createStore = () => {
|
|
|
424
441
|
}
|
|
425
442
|
const prevAtomState = getAtomState(a);
|
|
426
443
|
const nextAtomState = setAtomValueOrPromise(a, args2[0]);
|
|
427
|
-
if (!
|
|
444
|
+
if (!isEqualAtomValue(prevAtomState, nextAtomState)) {
|
|
428
445
|
recomputeDependents(a);
|
|
429
446
|
}
|
|
430
447
|
} else {
|
|
@@ -454,15 +471,16 @@ var createStore = () => {
|
|
|
454
471
|
}
|
|
455
472
|
return result;
|
|
456
473
|
};
|
|
457
|
-
const mountAtom = (atom2, initialDependent) => {
|
|
474
|
+
const mountAtom = (atom2, initialDependent, onMountQueue) => {
|
|
458
475
|
var _a;
|
|
476
|
+
const queue = onMountQueue || [];
|
|
459
477
|
(_a = getAtomState(atom2)) == null ? void 0 : _a.d.forEach((_, a) => {
|
|
460
478
|
const aMounted = mountedMap.get(a);
|
|
461
479
|
if (aMounted) {
|
|
462
480
|
aMounted.t.add(atom2);
|
|
463
481
|
} else {
|
|
464
482
|
if (a !== atom2) {
|
|
465
|
-
mountAtom(a, atom2);
|
|
483
|
+
mountAtom(a, atom2, queue);
|
|
466
484
|
}
|
|
467
485
|
}
|
|
468
486
|
});
|
|
@@ -476,10 +494,16 @@ var createStore = () => {
|
|
|
476
494
|
mountedAtoms.add(atom2);
|
|
477
495
|
}
|
|
478
496
|
if (isActuallyWritableAtom(atom2) && atom2.onMount) {
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
497
|
+
const { onMount } = atom2;
|
|
498
|
+
queue.push(() => {
|
|
499
|
+
const onUnmount = onMount((...args) => writeAtom(atom2, ...args));
|
|
500
|
+
if (onUnmount) {
|
|
501
|
+
mounted.u = onUnmount;
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
if (!onMountQueue) {
|
|
506
|
+
queue.forEach((f) => f());
|
|
483
507
|
}
|
|
484
508
|
return mounted;
|
|
485
509
|
};
|
|
@@ -548,13 +572,13 @@ var createStore = () => {
|
|
|
548
572
|
pending.forEach(([atom2, prevAtomState]) => {
|
|
549
573
|
const atomState = getAtomState(atom2);
|
|
550
574
|
if (atomState) {
|
|
551
|
-
|
|
575
|
+
const mounted = mountedMap.get(atom2);
|
|
576
|
+
if (mounted && atomState.d !== (prevAtomState == null ? void 0 : prevAtomState.d)) {
|
|
552
577
|
mountDependencies(atom2, atomState, prevAtomState == null ? void 0 : prevAtomState.d);
|
|
553
578
|
}
|
|
554
|
-
const mounted = mountedMap.get(atom2);
|
|
555
579
|
if (mounted && !// TODO This seems pretty hacky. Hope to fix it.
|
|
556
580
|
// Maybe we could `mountDependencies` in `setAtomState`?
|
|
557
|
-
(
|
|
581
|
+
(!hasPromiseAtomValue(prevAtomState) && (isEqualAtomValue(prevAtomState, atomState) || isEqualAtomError(prevAtomState, atomState)))) {
|
|
558
582
|
mounted.l.forEach((listener) => listener());
|
|
559
583
|
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
560
584
|
flushed.add(atom2);
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _storybook_docs_tools from '@storybook/docs-tools';
|
|
2
|
+
import { R as Renderer, d as StoryContextForEnhancers, A as Args, e as StrictArgTypes } from './index.d-82fc9196.js';
|
|
2
3
|
|
|
3
4
|
declare const _default: {
|
|
4
|
-
argTypesEnhancers: (<TRenderer extends Renderer>(context: StoryContextForEnhancers<TRenderer>) => StrictArgTypes<Args>)[];
|
|
5
|
+
argTypesEnhancers: (<TRenderer extends Renderer>(context: StoryContextForEnhancers<TRenderer, Args>) => StrictArgTypes<Args>)[];
|
|
5
6
|
parameters: {
|
|
6
7
|
docs: {
|
|
7
|
-
extractArgTypes:
|
|
8
|
+
extractArgTypes: _storybook_docs_tools.ArgTypesExtractor;
|
|
8
9
|
};
|
|
9
10
|
};
|
|
10
11
|
};
|
package/dist/preview.js
CHANGED
|
@@ -22,13 +22,13 @@ __export(preview_exports, {
|
|
|
22
22
|
default: () => preview_default
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(preview_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_entry_preview_docs = require("@storybook/react/dist/entry-preview-docs");
|
|
26
26
|
var import_docs_tools = require("@storybook/docs-tools");
|
|
27
27
|
var preview_default = {
|
|
28
28
|
argTypesEnhancers: [import_docs_tools.enhanceArgTypes],
|
|
29
29
|
parameters: {
|
|
30
30
|
docs: {
|
|
31
|
-
extractArgTypes:
|
|
31
|
+
extractArgTypes: import_entry_preview_docs.parameters.docs.extractArgTypes
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.7-alpha.1",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -51,20 +51,20 @@
|
|
|
51
51
|
"preset": "react-native"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@storybook/channel-websocket": "7.6.
|
|
55
|
-
"@storybook/channels": "7.6.
|
|
56
|
-
"@storybook/client-logger": "7.6.
|
|
57
|
-
"@storybook/core-client": "7.6.
|
|
58
|
-
"@storybook/core-common": "7.6.
|
|
59
|
-
"@storybook/core-events": "7.6.
|
|
54
|
+
"@storybook/channel-websocket": "7.6.7",
|
|
55
|
+
"@storybook/channels": "7.6.7",
|
|
56
|
+
"@storybook/client-logger": "7.6.7",
|
|
57
|
+
"@storybook/core-client": "7.6.7",
|
|
58
|
+
"@storybook/core-common": "7.6.7",
|
|
59
|
+
"@storybook/core-events": "7.6.7",
|
|
60
60
|
"@storybook/csf": "^0.1.1",
|
|
61
|
-
"@storybook/docs-tools": "7.6.
|
|
61
|
+
"@storybook/docs-tools": "7.6.7",
|
|
62
62
|
"@storybook/global": "^5.0.0",
|
|
63
|
-
"@storybook/manager-api": "7.6.
|
|
64
|
-
"@storybook/preview-api": "7.6.
|
|
65
|
-
"@storybook/preview-web": "7.6.
|
|
66
|
-
"@storybook/react": "7.6.
|
|
67
|
-
"@storybook/react-native-theming": "^7.
|
|
63
|
+
"@storybook/manager-api": "7.6.7",
|
|
64
|
+
"@storybook/preview-api": "7.6.7",
|
|
65
|
+
"@storybook/preview-web": "7.6.7",
|
|
66
|
+
"@storybook/react": "7.6.7",
|
|
67
|
+
"@storybook/react-native-theming": "^7.6.7-alpha.1",
|
|
68
68
|
"chokidar": "^3.5.1",
|
|
69
69
|
"commander": "^8.2.0",
|
|
70
70
|
"deepmerge": "^4.3.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"util": "^0.12.4"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@storybook/types": "7.6.
|
|
77
|
+
"@storybook/types": "7.6.7",
|
|
78
78
|
"@types/jest": "^29.4.3",
|
|
79
79
|
"@types/react": "~18.2.14",
|
|
80
80
|
"babel-jest": "^29.4.3",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"publishConfig": {
|
|
98
98
|
"access": "public"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "c3d96087dec39160d6998b80b5d6c6d9654a4e68"
|
|
101
101
|
}
|
package/scripts/generate.js
CHANGED
|
@@ -53,7 +53,7 @@ function generate({ configPath, absolute = false, useJs = false }) {
|
|
|
53
53
|
|
|
54
54
|
// TODO: implement presets or something similar
|
|
55
55
|
const enhancer = main.addons?.includes('@storybook/addon-ondevice-actions')
|
|
56
|
-
? "require('@storybook/addon-actions/
|
|
56
|
+
? "require('@storybook/addon-actions/preview')"
|
|
57
57
|
: '';
|
|
58
58
|
|
|
59
59
|
const previewExists = getPreviewExists({ configPath });
|