@storybook/react-native 8.0.0-alpha.0 → 8.0.0-alpha.2
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.d-b039fbf0.d.ts → index.d-3fb25d8d.d.ts} +167 -5
- package/dist/index.d.ts +14 -2
- package/dist/index.js +52 -9
- package/dist/preview.d.ts +1 -1
- package/package.json +15 -14
- package/scripts/__snapshots__/generate.test.js.snap +136 -36
- package/scripts/generate.js +37 -23
- package/scripts/handle-args.js +1 -6
- package/scripts/watcher.js +20 -1
|
@@ -21,6 +21,90 @@ declare global {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
@see Simplify
|
|
26
|
+
*/
|
|
27
|
+
interface SimplifyOptions {
|
|
28
|
+
/**
|
|
29
|
+
Do the simplification recursively.
|
|
30
|
+
|
|
31
|
+
@default false
|
|
32
|
+
*/
|
|
33
|
+
deep?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Flatten a type without worrying about the result.
|
|
37
|
+
type Flatten<
|
|
38
|
+
AnyType,
|
|
39
|
+
Options extends SimplifyOptions = {},
|
|
40
|
+
> = Options['deep'] extends true
|
|
41
|
+
? {[KeyType in keyof AnyType]: Simplify<AnyType[KeyType], Options>}
|
|
42
|
+
: {[KeyType in keyof AnyType]: AnyType[KeyType]};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
46
|
+
|
|
47
|
+
@example
|
|
48
|
+
```
|
|
49
|
+
import type {Simplify} from 'type-fest';
|
|
50
|
+
|
|
51
|
+
type PositionProps = {
|
|
52
|
+
top: number;
|
|
53
|
+
left: number;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
type SizeProps = {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
62
|
+
type Props = Simplify<PositionProps & SizeProps>;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
66
|
+
|
|
67
|
+
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
68
|
+
|
|
69
|
+
@example
|
|
70
|
+
```
|
|
71
|
+
import type {Simplify} from 'type-fest';
|
|
72
|
+
|
|
73
|
+
interface SomeInterface {
|
|
74
|
+
foo: number;
|
|
75
|
+
bar?: string;
|
|
76
|
+
baz: number | undefined;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type SomeType = {
|
|
80
|
+
foo: number;
|
|
81
|
+
bar?: string;
|
|
82
|
+
baz: number | undefined;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
86
|
+
const someType: SomeType = literal;
|
|
87
|
+
const someInterface: SomeInterface = literal;
|
|
88
|
+
|
|
89
|
+
function fn(object: Record<string, unknown>): void {}
|
|
90
|
+
|
|
91
|
+
fn(literal); // Good: literal object type is sealed
|
|
92
|
+
fn(someType); // Good: type is sealed
|
|
93
|
+
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
94
|
+
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
98
|
+
|
|
99
|
+
@category Object
|
|
100
|
+
*/
|
|
101
|
+
type Simplify<
|
|
102
|
+
AnyType,
|
|
103
|
+
Options extends SimplifyOptions = {},
|
|
104
|
+
> = Flatten<AnyType> extends AnyType
|
|
105
|
+
? Flatten<AnyType, Options>
|
|
106
|
+
: AnyType;
|
|
107
|
+
|
|
24
108
|
/**
|
|
25
109
|
Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
|
|
26
110
|
|
|
@@ -799,12 +883,18 @@ interface StrictInputType extends InputType {
|
|
|
799
883
|
interface Args {
|
|
800
884
|
[name: string]: any;
|
|
801
885
|
}
|
|
886
|
+
type ArgTypes<TArgs = Args> = {
|
|
887
|
+
[name in keyof TArgs]: InputType;
|
|
888
|
+
};
|
|
802
889
|
type StrictArgTypes<TArgs = Args> = {
|
|
803
890
|
[name in keyof TArgs]: StrictInputType;
|
|
804
891
|
};
|
|
805
892
|
interface Globals {
|
|
806
893
|
[name: string]: any;
|
|
807
894
|
}
|
|
895
|
+
interface GlobalTypes {
|
|
896
|
+
[name: string]: InputType;
|
|
897
|
+
}
|
|
808
898
|
type Renderer = {
|
|
809
899
|
/** What is the type of the `component` annotation in this renderer? */
|
|
810
900
|
component: unknown;
|
|
@@ -825,6 +915,10 @@ interface StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TArgs
|
|
|
825
915
|
initialArgs: TArgs;
|
|
826
916
|
argTypes: StrictArgTypes<TArgs>;
|
|
827
917
|
}
|
|
918
|
+
type ArgsEnhancer<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForEnhancers<TRenderer, TArgs>) => TArgs;
|
|
919
|
+
type ArgTypesEnhancer<TRenderer extends Renderer = Renderer, TArgs = Args> = ((context: StoryContextForEnhancers<TRenderer, TArgs>) => StrictArgTypes<TArgs>) & {
|
|
920
|
+
secondPass?: boolean;
|
|
921
|
+
};
|
|
828
922
|
interface StoryContextUpdate<TArgs = Args> {
|
|
829
923
|
args?: TArgs;
|
|
830
924
|
globals?: Globals;
|
|
@@ -836,16 +930,68 @@ interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs =
|
|
|
836
930
|
viewMode: ViewMode$1;
|
|
837
931
|
originalStoryFn: StoryFn<TRenderer>;
|
|
838
932
|
}
|
|
933
|
+
type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForLoaders<TRenderer, TArgs>) => Promise<Record<string, any> | void> | Record<string, any> | void;
|
|
839
934
|
interface StoryContext<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContextForLoaders<TRenderer, TArgs> {
|
|
840
935
|
loaded: Record<string, any>;
|
|
841
936
|
abortSignal: AbortSignal;
|
|
842
937
|
canvasElement: TRenderer['canvasElement'];
|
|
843
938
|
}
|
|
939
|
+
type StepLabel = string;
|
|
940
|
+
type StepFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>) => Promise<void> | void;
|
|
941
|
+
type PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContext<TRenderer, TArgs> & {
|
|
942
|
+
step: StepFunction<TRenderer, TArgs>;
|
|
943
|
+
};
|
|
944
|
+
type PlayFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: PlayFunctionContext<TRenderer, TArgs>) => Promise<void> | void;
|
|
945
|
+
type PartialStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TRenderer['storyResult'];
|
|
844
946
|
type LegacyStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
|
845
947
|
type ArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (args: TArgs, context: StoryContext<TRenderer, TArgs>) => (TRenderer & {
|
|
846
948
|
T: TArgs;
|
|
847
949
|
})['storyResult'];
|
|
848
950
|
type StoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = LegacyStoryFn<TRenderer, TArgs> | ArgsStoryFn<TRenderer, TArgs>;
|
|
951
|
+
type DecoratorFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (fn: PartialStoryFn<TRenderer, TArgs>, c: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
|
952
|
+
type DecoratorApplicator<TRenderer extends Renderer = Renderer, TArgs = Args> = (storyFn: LegacyStoryFn<TRenderer, TArgs>, decorators: DecoratorFunction<TRenderer, TArgs>[]) => LegacyStoryFn<TRenderer, TArgs>;
|
|
953
|
+
type StepRunner<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>, context: PlayFunctionContext<TRenderer, TArgs>) => Promise<void>;
|
|
954
|
+
type BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> = {
|
|
955
|
+
/**
|
|
956
|
+
* Wrapper components or Storybook decorators that wrap a story.
|
|
957
|
+
*
|
|
958
|
+
* Decorators defined in Meta will be applied to every story variation.
|
|
959
|
+
* @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators)
|
|
960
|
+
*/
|
|
961
|
+
decorators?: DecoratorFunction<TRenderer, Simplify<TArgs>>[] | DecoratorFunction<TRenderer, Simplify<TArgs>>;
|
|
962
|
+
/**
|
|
963
|
+
* Custom metadata for a story.
|
|
964
|
+
* @see [Parameters](https://storybook.js.org/docs/basics/writing-stories/#parameters)
|
|
965
|
+
*/
|
|
966
|
+
parameters?: Parameters;
|
|
967
|
+
/**
|
|
968
|
+
* Dynamic data that are provided (and possibly updated by) Storybook and its addons.
|
|
969
|
+
* @see [Arg story inputs](https://storybook.js.org/docs/react/api/csf#args-story-inputs)
|
|
970
|
+
*/
|
|
971
|
+
args?: Partial<TArgs>;
|
|
972
|
+
/**
|
|
973
|
+
* ArgTypes encode basic metadata for args, such as `name`, `description`, `defaultValue` for an arg. These get automatically filled in by Storybook Docs.
|
|
974
|
+
* @see [Control annotations](https://github.com/storybookjs/storybook/blob/91e9dee33faa8eff0b342a366845de7100415367/addons/controls/README.md#control-annotations)
|
|
975
|
+
*/
|
|
976
|
+
argTypes?: Partial<ArgTypes<TArgs>>;
|
|
977
|
+
/**
|
|
978
|
+
* Asynchronous functions which provide data for a story.
|
|
979
|
+
* @see [Loaders](https://storybook.js.org/docs/react/writing-stories/loaders)
|
|
980
|
+
*/
|
|
981
|
+
loaders?: LoaderFunction<TRenderer, TArgs>[] | LoaderFunction<TRenderer, TArgs>;
|
|
982
|
+
/**
|
|
983
|
+
* Define a custom render function for the story(ies). If not passed, a default render function by the renderer will be used.
|
|
984
|
+
*/
|
|
985
|
+
render?: ArgsStoryFn<TRenderer, TArgs>;
|
|
986
|
+
};
|
|
987
|
+
type ProjectAnnotations$1<TRenderer extends Renderer = Renderer, TArgs = Args> = BaseAnnotations<TRenderer, TArgs> & {
|
|
988
|
+
argsEnhancers?: ArgsEnhancer<TRenderer, Args>[];
|
|
989
|
+
argTypesEnhancers?: ArgTypesEnhancer<TRenderer, Args>[];
|
|
990
|
+
globals?: Globals;
|
|
991
|
+
globalTypes?: GlobalTypes;
|
|
992
|
+
applyDecorators?: DecoratorApplicator<TRenderer, Args>;
|
|
993
|
+
runStep?: StepRunner<TRenderer, TArgs>;
|
|
994
|
+
};
|
|
849
995
|
|
|
850
996
|
interface Options$1 {
|
|
851
997
|
allowRegExp: boolean;
|
|
@@ -1079,6 +1225,7 @@ interface CLIOptions {
|
|
|
1079
1225
|
test?: boolean;
|
|
1080
1226
|
debugWebpack?: boolean;
|
|
1081
1227
|
webpackStatsJson?: string | boolean;
|
|
1228
|
+
statsJson?: string | boolean;
|
|
1082
1229
|
outputDir?: string;
|
|
1083
1230
|
}
|
|
1084
1231
|
interface BuilderOptions {
|
|
@@ -1210,10 +1357,6 @@ interface StorybookConfigRaw {
|
|
|
1210
1357
|
* Filter args with a "target" on the type from the render function (EXPERIMENTAL)
|
|
1211
1358
|
*/
|
|
1212
1359
|
argTypeTargetsV7?: boolean;
|
|
1213
|
-
/**
|
|
1214
|
-
* Use legacy MDX1, to help smooth migration to 7.0
|
|
1215
|
-
*/
|
|
1216
|
-
legacyMdx1?: boolean;
|
|
1217
1360
|
/**
|
|
1218
1361
|
* Apply decorators from preview.js before decorators from addons or frameworks
|
|
1219
1362
|
*/
|
|
@@ -1344,6 +1487,13 @@ interface StorybookConfig {
|
|
|
1344
1487
|
type PresetValue<T> = T | ((config: T, options: Options) => T | Promise<T>);
|
|
1345
1488
|
type Path = string;
|
|
1346
1489
|
type ModuleExport = any;
|
|
1490
|
+
type MaybePromise<T> = Promise<T> | T;
|
|
1491
|
+
type TeardownRenderToCanvas = () => MaybePromise<void>;
|
|
1492
|
+
type RenderToCanvas<TRenderer extends Renderer> = (context: RenderContext<TRenderer>, element: TRenderer['canvasElement']) => MaybePromise<void | TeardownRenderToCanvas>;
|
|
1493
|
+
type ProjectAnnotations<TRenderer extends Renderer> = ProjectAnnotations$1<TRenderer> & {
|
|
1494
|
+
renderToCanvas?: RenderToCanvas<TRenderer>;
|
|
1495
|
+
renderToDOM?: RenderToCanvas<TRenderer>;
|
|
1496
|
+
};
|
|
1347
1497
|
type PreparedStory<TRenderer extends Renderer = Renderer> = StoryContextForEnhancers<TRenderer> & {
|
|
1348
1498
|
moduleExport: ModuleExport;
|
|
1349
1499
|
originalStoryFn: StoryFn<TRenderer>;
|
|
@@ -1354,5 +1504,17 @@ type PreparedStory<TRenderer extends Renderer = Renderer> = StoryContextForEnhan
|
|
|
1354
1504
|
}>;
|
|
1355
1505
|
playFunction?: (context: StoryContext<TRenderer>) => Promise<void> | void;
|
|
1356
1506
|
};
|
|
1507
|
+
declare type RenderContext<TRenderer extends Renderer = Renderer> = StoryIdentifier & {
|
|
1508
|
+
showMain: () => void;
|
|
1509
|
+
showError: (error: {
|
|
1510
|
+
title: string;
|
|
1511
|
+
description: string;
|
|
1512
|
+
}) => void;
|
|
1513
|
+
showException: (err: Error) => void;
|
|
1514
|
+
forceRemount: boolean;
|
|
1515
|
+
storyContext: StoryContext<TRenderer>;
|
|
1516
|
+
storyFn: PartialStoryFn<TRenderer>;
|
|
1517
|
+
unboundStoryFn: LegacyStoryFn<TRenderer>;
|
|
1518
|
+
};
|
|
1357
1519
|
|
|
1358
|
-
export { Args as A, NormalizedStoriesSpecifier as N, PreparedStory as P, Renderer as R, StoryIndex as S,
|
|
1520
|
+
export { Args as A, NormalizedStoriesSpecifier as N, PreparedStory as P, Renderer as R, StoryIndex as S, ProjectAnnotations as a, StorybookConfig as b, StoryContextForEnhancers as c, StrictArgTypes as d };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as StoryIndex, P as PreparedStory, N as NormalizedStoriesSpecifier, a as StorybookConfig$1 } from './index.d-
|
|
1
|
+
import { S as StoryIndex, P as PreparedStory, N as NormalizedStoriesSpecifier, a as ProjectAnnotations, b as StorybookConfig$1 } from './index.d-3fb25d8d.js';
|
|
2
2
|
import { Theme } from '@storybook/react-native-theming';
|
|
3
3
|
export { Theme, darkTheme, theme } from '@storybook/react-native-theming';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -66,6 +66,18 @@ declare class View {
|
|
|
66
66
|
getStorybookUI: (params?: Partial<Params>) => () => react_jsx_runtime.JSX.Element;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
declare function prepareStories({ storyEntries, }: {
|
|
70
|
+
storyEntries: Array<NormalizedStoriesSpecifier & {
|
|
71
|
+
req: any;
|
|
72
|
+
}>;
|
|
73
|
+
}): {
|
|
74
|
+
index: {
|
|
75
|
+
v: number;
|
|
76
|
+
entries: {};
|
|
77
|
+
};
|
|
78
|
+
importMap: {};
|
|
79
|
+
};
|
|
80
|
+
declare const getProjectAnnotations: (view: View, annotations: any[]) => () => Promise<ProjectAnnotations<ReactRenderer>>;
|
|
69
81
|
declare function start({ annotations, storyEntries, }: {
|
|
70
82
|
storyEntries: Array<NormalizedStoriesSpecifier & {
|
|
71
83
|
req: any;
|
|
@@ -78,4 +90,4 @@ interface StorybookConfig {
|
|
|
78
90
|
addons: string[];
|
|
79
91
|
}
|
|
80
92
|
|
|
81
|
-
export { StorybookConfig, start };
|
|
93
|
+
export { StorybookConfig, getProjectAnnotations, prepareStories, start };
|
package/dist/index.js
CHANGED
|
@@ -59,6 +59,8 @@ var require_dist = __commonJS({
|
|
|
59
59
|
var src_exports = {};
|
|
60
60
|
__export(src_exports, {
|
|
61
61
|
darkTheme: () => import_react_native_theming13.darkTheme,
|
|
62
|
+
getProjectAnnotations: () => getProjectAnnotations,
|
|
63
|
+
prepareStories: () => prepareStories,
|
|
62
64
|
start: () => start,
|
|
63
65
|
theme: () => import_react_native_theming13.theme
|
|
64
66
|
});
|
|
@@ -1248,12 +1250,26 @@ var ErrorBoundary = class extends import_react4.default.Component {
|
|
|
1248
1250
|
static getDerivedStateFromError(_error) {
|
|
1249
1251
|
return { hasError: true };
|
|
1250
1252
|
}
|
|
1251
|
-
componentDidCatch(error,
|
|
1252
|
-
|
|
1253
|
+
componentDidCatch(error, info) {
|
|
1254
|
+
this.props.onError(error, info.componentStack);
|
|
1253
1255
|
}
|
|
1254
1256
|
render() {
|
|
1255
1257
|
if (this.state.hasError) {
|
|
1256
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1258
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1259
|
+
import_react_native3.View,
|
|
1260
|
+
{
|
|
1261
|
+
style: {
|
|
1262
|
+
margin: 16,
|
|
1263
|
+
padding: 16,
|
|
1264
|
+
borderColor: "red",
|
|
1265
|
+
borderWidth: 2,
|
|
1266
|
+
alignItems: "center",
|
|
1267
|
+
justifyContent: "center",
|
|
1268
|
+
borderRadius: 4
|
|
1269
|
+
},
|
|
1270
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Text, { style: { fontWeight: "bold" }, children: "Something went wrong rendering your story" })
|
|
1271
|
+
}
|
|
1272
|
+
);
|
|
1257
1273
|
}
|
|
1258
1274
|
return this.props.children;
|
|
1259
1275
|
}
|
|
@@ -1277,7 +1293,15 @@ var StoryView = () => {
|
|
|
1277
1293
|
style: { flex: 1, backgroundColor },
|
|
1278
1294
|
testID: id,
|
|
1279
1295
|
onStartShouldSetResponder: dismissOnStartResponder,
|
|
1280
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1296
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1297
|
+
ErrorBoundary,
|
|
1298
|
+
{
|
|
1299
|
+
onError: () => {
|
|
1300
|
+
console.log(`Error rendering story for ${context.title} ${context.name}`);
|
|
1301
|
+
},
|
|
1302
|
+
children: StoryComponent && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StoryComponent, { ...context })
|
|
1303
|
+
}
|
|
1304
|
+
)
|
|
1281
1305
|
},
|
|
1282
1306
|
id
|
|
1283
1307
|
);
|
|
@@ -1995,7 +2019,7 @@ function getHost(hostname) {
|
|
|
1995
2019
|
// src/View.tsx
|
|
1996
2020
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1997
2021
|
var STORAGE_KEY = "lastOpenedStory";
|
|
1998
|
-
var
|
|
2022
|
+
var View11 = class {
|
|
1999
2023
|
_storyIndex;
|
|
2000
2024
|
_setStory = () => {
|
|
2001
2025
|
};
|
|
@@ -2065,7 +2089,6 @@ var View10 = class {
|
|
|
2065
2089
|
this._idToPrepared[storyId] = await this._preview.loadStory({ storyId });
|
|
2066
2090
|
})
|
|
2067
2091
|
);
|
|
2068
|
-
console.log("Storybook: Finished building story index");
|
|
2069
2092
|
};
|
|
2070
2093
|
getStorybookUI = (params = {}) => {
|
|
2071
2094
|
const {
|
|
@@ -2241,6 +2264,23 @@ function prepareStories({
|
|
|
2241
2264
|
});
|
|
2242
2265
|
return { index, importMap };
|
|
2243
2266
|
}
|
|
2267
|
+
var getProjectAnnotations = (view, annotations) => async () => (0, import_preview_api3.composeConfigs)([
|
|
2268
|
+
{
|
|
2269
|
+
renderToCanvas: (context) => {
|
|
2270
|
+
view._setStory(context.storyContext);
|
|
2271
|
+
},
|
|
2272
|
+
render: (args, context) => {
|
|
2273
|
+
const { id, component: Component } = context;
|
|
2274
|
+
if (!Component) {
|
|
2275
|
+
throw new Error(
|
|
2276
|
+
`Unable to render story ${id} as the component annotation is missing from the default export`
|
|
2277
|
+
);
|
|
2278
|
+
}
|
|
2279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Component, { ...args });
|
|
2280
|
+
}
|
|
2281
|
+
},
|
|
2282
|
+
...annotations
|
|
2283
|
+
]);
|
|
2244
2284
|
function start({
|
|
2245
2285
|
annotations,
|
|
2246
2286
|
storyEntries
|
|
@@ -2272,6 +2312,7 @@ function start({
|
|
|
2272
2312
|
},
|
|
2273
2313
|
showStoryDuringRender: () => {
|
|
2274
2314
|
}
|
|
2315
|
+
// TODO what happened to this type?
|
|
2275
2316
|
};
|
|
2276
2317
|
const selectionStore = {
|
|
2277
2318
|
selection: null,
|
|
@@ -2282,7 +2323,7 @@ function start({
|
|
|
2282
2323
|
preview.selectionStore.selection = selection;
|
|
2283
2324
|
}
|
|
2284
2325
|
};
|
|
2285
|
-
const
|
|
2326
|
+
const getProjectAnnotationsInitial = async () => (0, import_preview_api3.composeConfigs)([
|
|
2286
2327
|
{
|
|
2287
2328
|
renderToCanvas: (context) => {
|
|
2288
2329
|
view._setStory(context.storyContext);
|
|
@@ -2301,11 +2342,11 @@ function start({
|
|
|
2301
2342
|
]);
|
|
2302
2343
|
const preview = new import_preview_api3.PreviewWithSelection(
|
|
2303
2344
|
async (importPath) => importMap[importPath],
|
|
2304
|
-
|
|
2345
|
+
getProjectAnnotationsInitial,
|
|
2305
2346
|
selectionStore,
|
|
2306
2347
|
previewView
|
|
2307
2348
|
);
|
|
2308
|
-
const view = new
|
|
2349
|
+
const view = new View11(preview, channel);
|
|
2309
2350
|
if (global) {
|
|
2310
2351
|
global.__STORYBOOK_ADDONS_CHANNEL__ = channel;
|
|
2311
2352
|
global.__STORYBOOK_PREVIEW__ = preview;
|
|
@@ -2317,6 +2358,8 @@ function start({
|
|
|
2317
2358
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2318
2359
|
0 && (module.exports = {
|
|
2319
2360
|
darkTheme,
|
|
2361
|
+
getProjectAnnotations,
|
|
2362
|
+
prepareStories,
|
|
2320
2363
|
start,
|
|
2321
2364
|
theme
|
|
2322
2365
|
});
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _storybook_docs_tools from '@storybook/docs-tools';
|
|
2
|
-
import { R as Renderer,
|
|
2
|
+
import { R as Renderer, c as StoryContextForEnhancers, A as Args, d as StrictArgTypes } from './index.d-3fb25d8d.js';
|
|
3
3
|
import 'file-system-cache';
|
|
4
4
|
import 'http';
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.2",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"dev": "ts-node ./buildscripts/gentsdev.ts && tsup --watch",
|
|
36
36
|
"prepare": "rm -rf dist/ && tsup",
|
|
37
|
-
"test": "jest"
|
|
37
|
+
"test": "jest",
|
|
38
|
+
"test:ci": "jest"
|
|
38
39
|
},
|
|
39
40
|
"jest": {
|
|
40
41
|
"modulePathIgnorePatterns": [
|
|
@@ -51,17 +52,17 @@
|
|
|
51
52
|
"preset": "react-native"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"@storybook/channels": "8.0.0-
|
|
55
|
-
"@storybook/client-logger": "8.0.0-
|
|
56
|
-
"@storybook/core-common": "8.0.0-
|
|
57
|
-
"@storybook/core-events": "8.0.0-
|
|
55
|
+
"@storybook/channels": "8.0.0-rc.1",
|
|
56
|
+
"@storybook/client-logger": "8.0.0-rc.1",
|
|
57
|
+
"@storybook/core-common": "8.0.0-rc.1",
|
|
58
|
+
"@storybook/core-events": "8.0.0-rc.1",
|
|
58
59
|
"@storybook/csf": "^0.1.1",
|
|
59
|
-
"@storybook/docs-tools": "8.0.0-
|
|
60
|
+
"@storybook/docs-tools": "8.0.0-rc.1",
|
|
60
61
|
"@storybook/global": "^5.0.0",
|
|
61
|
-
"@storybook/manager-api": "8.0.0-
|
|
62
|
-
"@storybook/preview-api": "8.0.0-
|
|
63
|
-
"@storybook/react": "8.0.0-
|
|
64
|
-
"@storybook/react-native-theming": "^8.0.0-alpha.
|
|
62
|
+
"@storybook/manager-api": "8.0.0-rc.1",
|
|
63
|
+
"@storybook/preview-api": "8.0.0-rc.1",
|
|
64
|
+
"@storybook/react": "8.0.0-rc.1",
|
|
65
|
+
"@storybook/react-native-theming": "^8.0.0-alpha.2",
|
|
65
66
|
"chokidar": "^3.5.1",
|
|
66
67
|
"commander": "^8.2.0",
|
|
67
68
|
"dedent": "^1.5.1",
|
|
@@ -73,11 +74,11 @@
|
|
|
73
74
|
"util": "^0.12.4"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
|
-
"@storybook/types": "8.0.0-
|
|
77
|
+
"@storybook/types": "8.0.0-rc.1",
|
|
77
78
|
"@types/jest": "^29.4.3",
|
|
78
79
|
"@types/react": "~18.2.14",
|
|
79
80
|
"babel-jest": "^29.4.3",
|
|
80
|
-
"jest": "^29.
|
|
81
|
+
"jest": "^29.7.0",
|
|
81
82
|
"jotai": "^2.6.2",
|
|
82
83
|
"react-test-renderer": "18.2.0",
|
|
83
84
|
"ts-node": "^10.9.1",
|
|
@@ -95,5 +96,5 @@
|
|
|
95
96
|
"publishConfig": {
|
|
96
97
|
"access": "public"
|
|
97
98
|
},
|
|
98
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "6f189532af5cbfbdd4bc968faab66721407c84ca"
|
|
99
100
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
exports[`loader writeRequires when there are different file extensions writes the story imports 1`] = `
|
|
4
4
|
"
|
|
5
5
|
/* do not change this file, it is auto generated by storybook. */
|
|
6
|
-
|
|
7
|
-
import { start } from '@storybook/react-native';
|
|
6
|
+
|
|
7
|
+
import { start, prepareStories, getProjectAnnotations } from '@storybook/react-native';
|
|
8
8
|
|
|
9
9
|
import "@storybook/addon-ondevice-notes/register";
|
|
10
10
|
import "@storybook/addon-ondevice-controls/register";
|
|
@@ -18,23 +18,48 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
18
18
|
importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
|
|
19
19
|
// @ts-ignore
|
|
20
20
|
req: require.context('./', false, /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/)
|
|
21
|
-
}]
|
|
21
|
+
}];
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
|
|
24
|
+
declare global {
|
|
25
|
+
var view: ReturnType<typeof start>;
|
|
26
|
+
var STORIES: typeof normalizedStories;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
const annotations = [require('./preview'),require("@storybook/react-native/dist/preview"), require('@storybook/addon-actions/preview')];
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
global.STORIES = normalizedStories;
|
|
33
|
+
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
module?.hot?.accept?.();
|
|
36
|
+
|
|
37
|
+
if (!global.view) {
|
|
38
|
+
global.view = start({
|
|
39
|
+
annotations,
|
|
40
|
+
storyEntries: normalizedStories
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
const { importMap } = prepareStories({ storyEntries: normalizedStories });
|
|
44
|
+
|
|
45
|
+
global.view._preview.onStoriesChanged({
|
|
46
|
+
importFn: async (importPath: string) => importMap[importPath],
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
global.view._preview.onGetProjectAnnotationsChanged({
|
|
50
|
+
getProjectAnnotations: getProjectAnnotations(global.view, annotations),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const view = global.view;
|
|
30
55
|
"
|
|
31
56
|
`;
|
|
32
57
|
|
|
33
58
|
exports[`loader writeRequires when there is a configuration object writes the story imports 1`] = `
|
|
34
59
|
"
|
|
35
60
|
/* do not change this file, it is auto generated by storybook. */
|
|
36
|
-
|
|
37
|
-
import { start } from '@storybook/react-native';
|
|
61
|
+
|
|
62
|
+
import { start, prepareStories, getProjectAnnotations } from '@storybook/react-native';
|
|
38
63
|
|
|
39
64
|
import "@storybook/addon-ondevice-notes/register";
|
|
40
65
|
import "@storybook/addon-ondevice-controls/register";
|
|
@@ -48,23 +73,48 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
48
73
|
importPathMatcher: /^\\.(?:(?:^|\\/|(?:(?:(?!(?:^|\\/)\\.).)*?)\\/)(?!\\.)(?=.)[^/]*?\\.stories\\.tsx)$/,
|
|
49
74
|
// @ts-ignore
|
|
50
75
|
req: require.context('./components', true, /^\\.(?:(?:^|\\/|(?:(?:(?!(?:^|\\/)\\.).)*?)\\/)(?!\\.)(?=.)[^/]*?\\.stories\\.tsx)$/)
|
|
51
|
-
}]
|
|
76
|
+
}];
|
|
52
77
|
|
|
53
|
-
|
|
54
|
-
|
|
78
|
+
|
|
79
|
+
declare global {
|
|
80
|
+
var view: ReturnType<typeof start>;
|
|
81
|
+
var STORIES: typeof normalizedStories;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const annotations = [require('./preview'),require("@storybook/react-native/dist/preview"), require('@storybook/addon-actions/preview')];
|
|
55
86
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
87
|
+
global.STORIES = normalizedStories;
|
|
88
|
+
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
module?.hot?.accept?.();
|
|
91
|
+
|
|
92
|
+
if (!global.view) {
|
|
93
|
+
global.view = start({
|
|
94
|
+
annotations,
|
|
95
|
+
storyEntries: normalizedStories
|
|
96
|
+
});
|
|
97
|
+
} else {
|
|
98
|
+
const { importMap } = prepareStories({ storyEntries: normalizedStories });
|
|
99
|
+
|
|
100
|
+
global.view._preview.onStoriesChanged({
|
|
101
|
+
importFn: async (importPath: string) => importMap[importPath],
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
global.view._preview.onGetProjectAnnotationsChanged({
|
|
105
|
+
getProjectAnnotations: getProjectAnnotations(global.view, annotations),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const view = global.view;
|
|
60
110
|
"
|
|
61
111
|
`;
|
|
62
112
|
|
|
63
113
|
exports[`loader writeRequires when there is a story glob writes the story imports 1`] = `
|
|
64
114
|
"
|
|
65
115
|
/* do not change this file, it is auto generated by storybook. */
|
|
66
|
-
|
|
67
|
-
import { start } from '@storybook/react-native';
|
|
116
|
+
|
|
117
|
+
import { start, prepareStories, getProjectAnnotations } from '@storybook/react-native';
|
|
68
118
|
|
|
69
119
|
import "@storybook/addon-ondevice-notes/register";
|
|
70
120
|
import "@storybook/addon-ondevice-controls/register";
|
|
@@ -78,23 +128,48 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
78
128
|
importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
|
|
79
129
|
// @ts-ignore
|
|
80
130
|
req: require.context('./', false, /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/)
|
|
81
|
-
}]
|
|
131
|
+
}];
|
|
82
132
|
|
|
83
|
-
|
|
84
|
-
|
|
133
|
+
|
|
134
|
+
declare global {
|
|
135
|
+
var view: ReturnType<typeof start>;
|
|
136
|
+
var STORIES: typeof normalizedStories;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
const annotations = [require('./preview'),require("@storybook/react-native/dist/preview"), require('@storybook/addon-actions/preview')];
|
|
85
141
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
142
|
+
global.STORIES = normalizedStories;
|
|
143
|
+
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
module?.hot?.accept?.();
|
|
146
|
+
|
|
147
|
+
if (!global.view) {
|
|
148
|
+
global.view = start({
|
|
149
|
+
annotations,
|
|
150
|
+
storyEntries: normalizedStories
|
|
151
|
+
});
|
|
152
|
+
} else {
|
|
153
|
+
const { importMap } = prepareStories({ storyEntries: normalizedStories });
|
|
154
|
+
|
|
155
|
+
global.view._preview.onStoriesChanged({
|
|
156
|
+
importFn: async (importPath: string) => importMap[importPath],
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
global.view._preview.onGetProjectAnnotationsChanged({
|
|
160
|
+
getProjectAnnotations: getProjectAnnotations(global.view, annotations),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export const view = global.view;
|
|
90
165
|
"
|
|
91
166
|
`;
|
|
92
167
|
|
|
93
168
|
exports[`loader writeRequires when there is no preview does not add preview related stuff 1`] = `
|
|
94
169
|
"
|
|
95
170
|
/* do not change this file, it is auto generated by storybook. */
|
|
96
|
-
|
|
97
|
-
import { start } from '@storybook/react-native';
|
|
171
|
+
|
|
172
|
+
import { start, prepareStories, getProjectAnnotations } from '@storybook/react-native';
|
|
98
173
|
|
|
99
174
|
import "@storybook/addon-ondevice-notes/register";
|
|
100
175
|
import "@storybook/addon-ondevice-controls/register";
|
|
@@ -108,14 +183,39 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
108
183
|
importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
|
|
109
184
|
// @ts-ignore
|
|
110
185
|
req: require.context('./', false, /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/)
|
|
111
|
-
}]
|
|
186
|
+
}];
|
|
112
187
|
|
|
113
|
-
|
|
114
|
-
|
|
188
|
+
|
|
189
|
+
declare global {
|
|
190
|
+
var view: ReturnType<typeof start>;
|
|
191
|
+
var STORIES: typeof normalizedStories;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
const annotations = [require("@storybook/react-native/dist/preview"), require('@storybook/addon-actions/preview')];
|
|
115
196
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
197
|
+
global.STORIES = normalizedStories;
|
|
198
|
+
|
|
199
|
+
// @ts-ignore
|
|
200
|
+
module?.hot?.accept?.();
|
|
201
|
+
|
|
202
|
+
if (!global.view) {
|
|
203
|
+
global.view = start({
|
|
204
|
+
annotations,
|
|
205
|
+
storyEntries: normalizedStories
|
|
206
|
+
});
|
|
207
|
+
} else {
|
|
208
|
+
const { importMap } = prepareStories({ storyEntries: normalizedStories });
|
|
209
|
+
|
|
210
|
+
global.view._preview.onStoriesChanged({
|
|
211
|
+
importFn: async (importPath: string) => importMap[importPath],
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
global.view._preview.onGetProjectAnnotationsChanged({
|
|
215
|
+
getProjectAnnotations: getProjectAnnotations(global.view, annotations),
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export const view = global.view;
|
|
120
220
|
"
|
|
121
221
|
`;
|
package/scripts/generate.js
CHANGED
|
@@ -59,25 +59,52 @@ function generate({ configPath, absolute = false, useJs = false }) {
|
|
|
59
59
|
|
|
60
60
|
const annotations = `[${previewExists ? "require('./preview')," : ''}${doctools}, ${enhancer}]`;
|
|
61
61
|
|
|
62
|
+
const globalTypes = `
|
|
63
|
+
declare global {
|
|
64
|
+
var view: ReturnType<typeof start>;
|
|
65
|
+
var STORIES: typeof normalizedStories;
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
|
|
62
69
|
const fileContent = `
|
|
63
70
|
/* do not change this file, it is auto generated by storybook. */
|
|
64
|
-
|
|
65
|
-
import { start } from '@storybook/react-native';
|
|
71
|
+
|
|
72
|
+
import { start, prepareStories, getProjectAnnotations } from '@storybook/react-native';
|
|
66
73
|
|
|
67
74
|
${registerAddons}
|
|
68
75
|
|
|
69
|
-
const normalizedStories = [${normalizedStories.join(',')}]
|
|
76
|
+
const normalizedStories = [${normalizedStories.join(',')}];
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
global.STORIES = normalizedStories;
|
|
78
|
+
${useJs ? '' : globalTypes}
|
|
73
79
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
const annotations = ${annotations};
|
|
81
|
+
|
|
82
|
+
global.STORIES = normalizedStories;
|
|
83
|
+
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
module?.hot?.accept?.();
|
|
86
|
+
|
|
87
|
+
if (!global.view) {
|
|
88
|
+
global.view = start({
|
|
89
|
+
annotations,
|
|
90
|
+
storyEntries: normalizedStories
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
const { importMap } = prepareStories({ storyEntries: normalizedStories });
|
|
94
|
+
|
|
95
|
+
global.view._preview.onStoriesChanged({
|
|
96
|
+
importFn: async (importPath: string) => importMap[importPath],
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
global.view._preview.onGetProjectAnnotationsChanged({
|
|
100
|
+
getProjectAnnotations: getProjectAnnotations(global.view, annotations),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const view = global.view;
|
|
78
105
|
`;
|
|
79
106
|
|
|
80
|
-
const formattedFileContent = prettier.format(fileContent, { parser: 'babel' });
|
|
107
|
+
const formattedFileContent = prettier.format(fileContent, { parser: 'babel-ts' });
|
|
81
108
|
|
|
82
109
|
fs.writeFileSync(storybookRequiresLocation, formattedFileContent, {
|
|
83
110
|
encoding: 'utf8',
|
|
@@ -88,16 +115,3 @@ function generate({ configPath, absolute = false, useJs = false }) {
|
|
|
88
115
|
module.exports = {
|
|
89
116
|
generate,
|
|
90
117
|
};
|
|
91
|
-
|
|
92
|
-
// TODO evaluate if this is needed
|
|
93
|
-
// if (import.meta.webpackHot) {
|
|
94
|
-
// import.meta.webpackHot.accept('./{{storiesFilename}}', () => {
|
|
95
|
-
// // importFn has changed so we need to patch the new one in
|
|
96
|
-
// preview.onStoriesChanged({ importFn });
|
|
97
|
-
// });
|
|
98
|
-
|
|
99
|
-
// import.meta.webpackHot.accept([{{#each previewAnnotations}}'{{this}}',{{/each}}], () => {
|
|
100
|
-
// // getProjectAnnotations has changed so we need to patch the new one in
|
|
101
|
-
// preview.onGetProjectAnnotationsChanged({ getProjectAnnotations });
|
|
102
|
-
// });
|
|
103
|
-
// }
|
package/scripts/handle-args.js
CHANGED
|
@@ -9,12 +9,7 @@ function getArguments() {
|
|
|
9
9
|
'./.storybook'
|
|
10
10
|
)
|
|
11
11
|
.option('-js, --use-js', 'Use a js file for storybook.requires')
|
|
12
|
-
.option('-a, --absolute', 'Use absolute paths for story imports')
|
|
13
|
-
.option('-v6, --v6-store', 'Use v6 store, for storiesof compatibility')
|
|
14
|
-
.option(
|
|
15
|
-
'-rc, --v6-require-context',
|
|
16
|
-
'When using v6 store should use require.context to load stories'
|
|
17
|
-
);
|
|
12
|
+
.option('-a, --absolute', 'Use absolute paths for story imports');
|
|
18
13
|
|
|
19
14
|
program.parse();
|
|
20
15
|
|
package/scripts/watcher.js
CHANGED
|
@@ -6,6 +6,15 @@ const { writeRequires, getMain, getFilePathExtension } = require('./loader');
|
|
|
6
6
|
const { getArguments } = require('./handle-args');
|
|
7
7
|
|
|
8
8
|
const args = getArguments();
|
|
9
|
+
|
|
10
|
+
if (!args.v6Store) {
|
|
11
|
+
console.log(
|
|
12
|
+
"in v7 you don't need the watcher anymore, if you are using v6 compat mode then pass the -v6 flag"
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
|
|
9
18
|
const log = console.log.bind(console);
|
|
10
19
|
|
|
11
20
|
const mainExt = getFilePathExtension(args, 'main');
|
|
@@ -17,6 +26,8 @@ if (previewExt) {
|
|
|
17
26
|
watchPaths.push(`./preview.${previewExt}`);
|
|
18
27
|
}
|
|
19
28
|
|
|
29
|
+
console.log(watchPaths);
|
|
30
|
+
|
|
20
31
|
const updateRequires = (event, watchPath) => {
|
|
21
32
|
if (typeof watchPath === 'string') {
|
|
22
33
|
log(`event ${event} for file ${path.basename(watchPath)}`);
|
|
@@ -25,6 +36,14 @@ const updateRequires = (event, watchPath) => {
|
|
|
25
36
|
};
|
|
26
37
|
|
|
27
38
|
const globs = getMain(args).stories;
|
|
39
|
+
// directory
|
|
40
|
+
// files
|
|
41
|
+
const globsStrings = globs.map((g) => {
|
|
42
|
+
if (typeof g === 'string') return g;
|
|
43
|
+
if (g.directory && g.files) {
|
|
44
|
+
return `${g.directory}/${g.files}`;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
28
47
|
|
|
29
48
|
chokidar
|
|
30
49
|
.watch(watchPaths, { cwd: args.configPath })
|
|
@@ -33,7 +52,7 @@ chokidar
|
|
|
33
52
|
let isReady = false;
|
|
34
53
|
|
|
35
54
|
chokidar
|
|
36
|
-
.watch(
|
|
55
|
+
.watch(globsStrings, { cwd: args.configPath })
|
|
37
56
|
.on('ready', () => {
|
|
38
57
|
log('Watcher is ready, performing initial write');
|
|
39
58
|
writeRequires(args);
|