@storybook/react-native 8.0.0-alpha.1 → 8.0.0-alpha.3
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-ab512c60.d.ts → index.d-3fb25d8d.d.ts} +166 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.js +3069 -1233
- package/dist/preview.d.ts +1 -1
- package/package.json +16 -14
- package/scripts/__snapshots__/generate.test.js.snap +104 -36
- package/scripts/generate.js +28 -22
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.3",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"template/**/*"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"dev": "
|
|
35
|
+
"dev": "npx tsx buildscripts/gendtsdev.ts && tsup --watch",
|
|
36
36
|
"prepare": "rm -rf dist/ && tsup",
|
|
37
37
|
"test": "jest",
|
|
38
38
|
"test:ci": "jest"
|
|
@@ -52,17 +52,18 @@
|
|
|
52
52
|
"preset": "react-native"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@storybook/channels": "8
|
|
56
|
-
"@storybook/client-logger": "8
|
|
57
|
-
"@storybook/core-common": "8
|
|
58
|
-
"@storybook/core-events": "8
|
|
55
|
+
"@storybook/channels": "^8",
|
|
56
|
+
"@storybook/client-logger": "^8",
|
|
57
|
+
"@storybook/core-common": "^8",
|
|
58
|
+
"@storybook/core-events": "^8",
|
|
59
59
|
"@storybook/csf": "^0.1.1",
|
|
60
|
-
"@storybook/docs-tools": "8
|
|
60
|
+
"@storybook/docs-tools": "^8",
|
|
61
61
|
"@storybook/global": "^5.0.0",
|
|
62
|
-
"@storybook/manager-api": "8
|
|
63
|
-
"@storybook/preview-api": "8
|
|
64
|
-
"@storybook/react": "8
|
|
65
|
-
"@storybook/react-native-theming": "^8.0.0-alpha.
|
|
62
|
+
"@storybook/manager-api": "^8",
|
|
63
|
+
"@storybook/preview-api": "^8",
|
|
64
|
+
"@storybook/react": "^8",
|
|
65
|
+
"@storybook/react-native-theming": "^8.0.0-alpha.3",
|
|
66
|
+
"@storybook/react-native-ui": "^8.0.0-alpha.3",
|
|
66
67
|
"chokidar": "^3.5.1",
|
|
67
68
|
"commander": "^8.2.0",
|
|
68
69
|
"dedent": "^1.5.1",
|
|
@@ -74,20 +75,21 @@
|
|
|
74
75
|
"util": "^0.12.4"
|
|
75
76
|
},
|
|
76
77
|
"devDependencies": {
|
|
77
|
-
"@storybook/types": "8
|
|
78
|
+
"@storybook/types": "^8",
|
|
78
79
|
"@types/jest": "^29.4.3",
|
|
79
80
|
"@types/react": "~18.2.14",
|
|
80
81
|
"babel-jest": "^29.4.3",
|
|
81
82
|
"jest": "^29.7.0",
|
|
82
83
|
"jotai": "^2.6.2",
|
|
83
84
|
"react-test-renderer": "18.2.0",
|
|
84
|
-
"ts-node": "^10.9.1",
|
|
85
85
|
"tsup": "^7.2.0",
|
|
86
86
|
"typescript": "^5.3.3"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
|
+
"@gorhom/bottom-sheet": ">=4",
|
|
89
90
|
"react": "*",
|
|
90
91
|
"react-native": ">=0.57.0",
|
|
92
|
+
"react-native-gesture-handler": ">=2",
|
|
91
93
|
"react-native-safe-area-context": "*"
|
|
92
94
|
},
|
|
93
95
|
"engines": {
|
|
@@ -96,5 +98,5 @@
|
|
|
96
98
|
"publishConfig": {
|
|
97
99
|
"access": "public"
|
|
98
100
|
},
|
|
99
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "b7c2a24d21c0a38bd5e31349b3ba370af7c3d863"
|
|
100
102
|
}
|
|
@@ -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, updateView } 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,40 @@ 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
|
+
updateView(global.view, annotations, normalizedStories);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const view = global.view;
|
|
30
47
|
"
|
|
31
48
|
`;
|
|
32
49
|
|
|
33
50
|
exports[`loader writeRequires when there is a configuration object writes the story imports 1`] = `
|
|
34
51
|
"
|
|
35
52
|
/* do not change this file, it is auto generated by storybook. */
|
|
36
|
-
|
|
37
|
-
import { start } from '@storybook/react-native';
|
|
53
|
+
|
|
54
|
+
import { start, prepareStories, getProjectAnnotations, updateView } from '@storybook/react-native';
|
|
38
55
|
|
|
39
56
|
import "@storybook/addon-ondevice-notes/register";
|
|
40
57
|
import "@storybook/addon-ondevice-controls/register";
|
|
@@ -48,23 +65,40 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
48
65
|
importPathMatcher: /^\\.(?:(?:^|\\/|(?:(?:(?!(?:^|\\/)\\.).)*?)\\/)(?!\\.)(?=.)[^/]*?\\.stories\\.tsx)$/,
|
|
49
66
|
// @ts-ignore
|
|
50
67
|
req: require.context('./components', true, /^\\.(?:(?:^|\\/|(?:(?:(?!(?:^|\\/)\\.).)*?)\\/)(?!\\.)(?=.)[^/]*?\\.stories\\.tsx)$/)
|
|
51
|
-
}]
|
|
68
|
+
}];
|
|
52
69
|
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
|
|
71
|
+
declare global {
|
|
72
|
+
var view: ReturnType<typeof start>;
|
|
73
|
+
var STORIES: typeof normalizedStories;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
const annotations = [require('./preview'),require("@storybook/react-native/dist/preview"), require('@storybook/addon-actions/preview')];
|
|
55
78
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
79
|
+
global.STORIES = normalizedStories;
|
|
80
|
+
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
module?.hot?.accept?.();
|
|
83
|
+
|
|
84
|
+
if (!global.view) {
|
|
85
|
+
global.view = start({
|
|
86
|
+
annotations,
|
|
87
|
+
storyEntries: normalizedStories
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
updateView(global.view, annotations, normalizedStories);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const view = global.view;
|
|
60
94
|
"
|
|
61
95
|
`;
|
|
62
96
|
|
|
63
97
|
exports[`loader writeRequires when there is a story glob writes the story imports 1`] = `
|
|
64
98
|
"
|
|
65
99
|
/* do not change this file, it is auto generated by storybook. */
|
|
66
|
-
|
|
67
|
-
import { start } from '@storybook/react-native';
|
|
100
|
+
|
|
101
|
+
import { start, prepareStories, getProjectAnnotations, updateView } from '@storybook/react-native';
|
|
68
102
|
|
|
69
103
|
import "@storybook/addon-ondevice-notes/register";
|
|
70
104
|
import "@storybook/addon-ondevice-controls/register";
|
|
@@ -78,23 +112,40 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
78
112
|
importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
|
|
79
113
|
// @ts-ignore
|
|
80
114
|
req: require.context('./', false, /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/)
|
|
81
|
-
}]
|
|
115
|
+
}];
|
|
82
116
|
|
|
83
|
-
|
|
84
|
-
|
|
117
|
+
|
|
118
|
+
declare global {
|
|
119
|
+
var view: ReturnType<typeof start>;
|
|
120
|
+
var STORIES: typeof normalizedStories;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
const annotations = [require('./preview'),require("@storybook/react-native/dist/preview"), require('@storybook/addon-actions/preview')];
|
|
85
125
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
126
|
+
global.STORIES = normalizedStories;
|
|
127
|
+
|
|
128
|
+
// @ts-ignore
|
|
129
|
+
module?.hot?.accept?.();
|
|
130
|
+
|
|
131
|
+
if (!global.view) {
|
|
132
|
+
global.view = start({
|
|
133
|
+
annotations,
|
|
134
|
+
storyEntries: normalizedStories
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
updateView(global.view, annotations, normalizedStories);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export const view = global.view;
|
|
90
141
|
"
|
|
91
142
|
`;
|
|
92
143
|
|
|
93
144
|
exports[`loader writeRequires when there is no preview does not add preview related stuff 1`] = `
|
|
94
145
|
"
|
|
95
146
|
/* do not change this file, it is auto generated by storybook. */
|
|
96
|
-
|
|
97
|
-
import { start } from '@storybook/react-native';
|
|
147
|
+
|
|
148
|
+
import { start, prepareStories, getProjectAnnotations, updateView } from '@storybook/react-native';
|
|
98
149
|
|
|
99
150
|
import "@storybook/addon-ondevice-notes/register";
|
|
100
151
|
import "@storybook/addon-ondevice-controls/register";
|
|
@@ -108,14 +159,31 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
108
159
|
importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
|
|
109
160
|
// @ts-ignore
|
|
110
161
|
req: require.context('./', false, /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/)
|
|
111
|
-
}]
|
|
162
|
+
}];
|
|
112
163
|
|
|
113
|
-
|
|
114
|
-
|
|
164
|
+
|
|
165
|
+
declare global {
|
|
166
|
+
var view: ReturnType<typeof start>;
|
|
167
|
+
var STORIES: typeof normalizedStories;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
const annotations = [require("@storybook/react-native/dist/preview"), require('@storybook/addon-actions/preview')];
|
|
115
172
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
173
|
+
global.STORIES = normalizedStories;
|
|
174
|
+
|
|
175
|
+
// @ts-ignore
|
|
176
|
+
module?.hot?.accept?.();
|
|
177
|
+
|
|
178
|
+
if (!global.view) {
|
|
179
|
+
global.view = start({
|
|
180
|
+
annotations,
|
|
181
|
+
storyEntries: normalizedStories
|
|
182
|
+
});
|
|
183
|
+
} else {
|
|
184
|
+
updateView(global.view, annotations, normalizedStories);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export const view = global.view;
|
|
120
188
|
"
|
|
121
189
|
`;
|
package/scripts/generate.js
CHANGED
|
@@ -59,25 +59,44 @@ 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
71
|
|
|
65
|
-
import { start } from '@storybook/react-native';
|
|
66
|
-
|
|
72
|
+
import { start, updateView } from '@storybook/react-native';
|
|
73
|
+
|
|
67
74
|
${registerAddons}
|
|
68
75
|
|
|
69
|
-
const normalizedStories = [${normalizedStories.join(',')}]
|
|
76
|
+
const normalizedStories = [${normalizedStories.join(',')}];
|
|
77
|
+
|
|
78
|
+
${useJs ? '' : globalTypes}
|
|
79
|
+
|
|
80
|
+
const annotations = ${annotations};
|
|
70
81
|
|
|
71
|
-
// @ts-ignore
|
|
72
82
|
global.STORIES = normalizedStories;
|
|
73
83
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
+
updateView(global.view, annotations, normalizedStories);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const view = global.view;
|
|
78
97
|
`;
|
|
79
98
|
|
|
80
|
-
const formattedFileContent = prettier.format(fileContent, { parser: 'babel' });
|
|
99
|
+
const formattedFileContent = prettier.format(fileContent, { parser: 'babel-ts' });
|
|
81
100
|
|
|
82
101
|
fs.writeFileSync(storybookRequiresLocation, formattedFileContent, {
|
|
83
102
|
encoding: 'utf8',
|
|
@@ -88,16 +107,3 @@ function generate({ configPath, absolute = false, useJs = false }) {
|
|
|
88
107
|
module.exports = {
|
|
89
108
|
generate,
|
|
90
109
|
};
|
|
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
|
-
// }
|