@storybook/react-native 10.1.11 → 10.2.0-beta.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.
@@ -132,5 +132,87 @@ describe('loader', () => {
132
132
  t.assert.snapshot(fileContentMock);
133
133
  });
134
134
  });
135
+
136
+ describe('when host and port are provided', () => {
137
+ it('includes STORYBOOK_WEBSOCKET with host and port', async (t) => {
138
+ mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
139
+ await generate({
140
+ configPath: 'scripts/mocks/all-config-files',
141
+ host: '192.168.1.100',
142
+ port: 8080,
143
+ });
144
+ mock.reset();
145
+
146
+ assert.ok(
147
+ fileContentMock.includes(
148
+ "globalThis.STORYBOOK_WEBSOCKET = { host: '192.168.1.100', port: 8080 };"
149
+ )
150
+ );
151
+ t.assert.snapshot(fileContentMock);
152
+ });
153
+ });
154
+
155
+ describe('when only host is provided', () => {
156
+ it('includes STORYBOOK_WEBSOCKET with host and default port', async (t) => {
157
+ mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
158
+ await generate({
159
+ configPath: 'scripts/mocks/all-config-files',
160
+ host: 'localhost',
161
+ });
162
+ mock.reset();
163
+
164
+ assert.ok(
165
+ fileContentMock.includes(
166
+ "globalThis.STORYBOOK_WEBSOCKET = { host: 'localhost', port: 7007 };"
167
+ )
168
+ );
169
+ t.assert.snapshot(fileContentMock);
170
+ });
171
+ });
172
+
173
+ describe('when host is not provided', () => {
174
+ it('does not include STORYBOOK_WEBSOCKET assignment', async (t) => {
175
+ mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
176
+ await generate({ configPath: 'scripts/mocks/all-config-files' });
177
+ mock.reset();
178
+
179
+ assert.ok(!fileContentMock.includes('globalThis.STORYBOOK_WEBSOCKET ='));
180
+ t.assert.snapshot(fileContentMock);
181
+ });
182
+ });
183
+
184
+ describe('when only port is provided without host', () => {
185
+ it('does not include STORYBOOK_WEBSOCKET assignment', async (t) => {
186
+ mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
187
+ await generate({
188
+ configPath: 'scripts/mocks/all-config-files',
189
+ port: 8080,
190
+ });
191
+ mock.reset();
192
+
193
+ assert.ok(!fileContentMock.includes('globalThis.STORYBOOK_WEBSOCKET ='));
194
+ t.assert.snapshot(fileContentMock);
195
+ });
196
+ });
197
+
198
+ describe('when host and port are provided with useJs', () => {
199
+ it('includes STORYBOOK_WEBSOCKET in JS file', async (t) => {
200
+ mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
201
+ await generate({
202
+ configPath: 'scripts/mocks/all-config-files',
203
+ useJs: true,
204
+ host: '192.168.1.100',
205
+ port: 8080,
206
+ });
207
+ mock.reset();
208
+
209
+ assert.ok(
210
+ fileContentMock.includes(
211
+ "globalThis.STORYBOOK_WEBSOCKET = { host: '192.168.1.100', port: 8080 };"
212
+ )
213
+ );
214
+ t.assert.snapshot(fileContentMock);
215
+ });
216
+ });
135
217
  });
136
218
  });
@@ -1,19 +1,39 @@
1
+ exports[`loader > writeRequires > when host and port are provided > includes STORYBOOK_WEBSOCKET with host and port 1`] = `
2
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/all-config-files\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n var STORYBOOK_WEBSOCKET: { host: string; port: number } | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobalThis.STORIES = normalizedStories;\\nglobalThis.STORYBOOK_WEBSOCKET = { host: '192.168.1.100', port: 8080 };\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!globalThis.view) {\\n globalThis.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(globalThis.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = globalThis.view;\\n"
3
+ `;
4
+
5
+ exports[`loader > writeRequires > when host and port are provided with useJs > includes STORYBOOK_WEBSOCKET in JS file 1`] = `
6
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/all-config-files\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n \\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobalThis.STORIES = normalizedStories;\\nglobalThis.STORYBOOK_WEBSOCKET = { host: '192.168.1.100', port: 8080 };\\n\\n\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!globalThis.view) {\\n globalThis.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(globalThis.view, annotations, normalizedStories);\\n}\\n\\nexport const view = globalThis.view;\\n"
7
+ `;
8
+
9
+ exports[`loader > writeRequires > when host is not provided > does not include STORYBOOK_WEBSOCKET assignment 1`] = `
10
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/all-config-files\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n var STORYBOOK_WEBSOCKET: { host: string; port: number } | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobalThis.STORIES = normalizedStories;\\n\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!globalThis.view) {\\n globalThis.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(globalThis.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = globalThis.view;\\n"
11
+ `;
12
+
13
+ exports[`loader > writeRequires > when only host is provided > includes STORYBOOK_WEBSOCKET with host and default port 1`] = `
14
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/all-config-files\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n var STORYBOOK_WEBSOCKET: { host: string; port: number } | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobalThis.STORIES = normalizedStories;\\nglobalThis.STORYBOOK_WEBSOCKET = { host: 'localhost', port: 7007 };\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!globalThis.view) {\\n globalThis.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(globalThis.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = globalThis.view;\\n"
15
+ `;
16
+
17
+ exports[`loader > writeRequires > when only port is provided without host > does not include STORYBOOK_WEBSOCKET assignment 1`] = `
18
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/all-config-files\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n var STORYBOOK_WEBSOCKET: { host: string; port: number } | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobalThis.STORIES = normalizedStories;\\n\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!globalThis.view) {\\n globalThis.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(globalThis.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = globalThis.view;\\n"
19
+ `;
20
+
1
21
  exports[`loader > writeRequires > when there are different file extensions > writes the story imports 1`] = `
2
- "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/file-extensions\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobal.STORIES = normalizedStories;\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!global.view) {\\n global.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(global.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = global.view;\\n"
22
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/file-extensions\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n var STORYBOOK_WEBSOCKET: { host: string; port: number } | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobalThis.STORIES = normalizedStories;\\n\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!globalThis.view) {\\n globalThis.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(globalThis.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = globalThis.view;\\n"
3
23
  `;
4
24
 
5
25
  exports[`loader > writeRequires > when there is a configuration object > writes the story imports 1`] = `
6
- "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"ComponentsPrefix\\",\\n directory: \\"./scripts/mocks/configuration-objects/components\\",\\n files: \\"**/*.stories.tsx\\",\\n importPathMatcher: /^\\\\.(?:(?:^|\\\\/|(?:(?:(?!(?:^|\\\\/)\\\\.).)*?)\\\\/)(?!\\\\.)(?=.)[^/]*?\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './components',\\n true,\\n /^\\\\.(?:(?:^|\\\\/|(?:(?:(?!(?:^|\\\\/)\\\\.).)*?)\\\\/)(?!\\\\.)(?=.)[^/]*?\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobal.STORIES = normalizedStories;\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!global.view) {\\n global.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(global.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = global.view;\\n"
26
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"ComponentsPrefix\\",\\n directory: \\"./scripts/mocks/configuration-objects/components\\",\\n files: \\"**/*.stories.tsx\\",\\n importPathMatcher: /^\\\\.(?:(?:^|\\\\/|(?:(?:(?!(?:^|\\\\/)\\\\.).)*?)\\\\/)(?!\\\\.)(?=.)[^/]*?\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './components',\\n true,\\n /^\\\\.(?:(?:^|\\\\/|(?:(?:(?!(?:^|\\\\/)\\\\.).)*?)\\\\/)(?!\\\\.)(?=.)[^/]*?\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n var STORYBOOK_WEBSOCKET: { host: string; port: number } | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobalThis.STORIES = normalizedStories;\\n\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!globalThis.view) {\\n globalThis.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(globalThis.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = globalThis.view;\\n"
7
27
  `;
8
28
 
9
29
  exports[`loader > writeRequires > when there is a story glob > writes the story imports 1`] = `
10
- "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/all-config-files\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobal.STORIES = normalizedStories;\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!global.view) {\\n global.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(global.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = global.view;\\n"
30
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/all-config-files\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n var STORYBOOK_WEBSOCKET: { host: string; port: number } | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobalThis.STORIES = normalizedStories;\\n\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!globalThis.view) {\\n globalThis.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(globalThis.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = globalThis.view;\\n"
11
31
  `;
12
32
 
13
33
  exports[`loader > writeRequires > when there is no preview > does not add preview related stuff 1`] = `
14
- "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/no-preview\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n}\\n\\n\\nconst annotations = [\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobal.STORIES = normalizedStories;\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!global.view) {\\n global.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(global.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = global.view;\\n"
34
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/no-preview\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n var STORYBOOK_WEBSOCKET: { host: string; port: number } | undefined;\\n}\\n\\n\\nconst annotations = [\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobalThis.STORIES = normalizedStories;\\n\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!globalThis.view) {\\n globalThis.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(globalThis.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = globalThis.view;\\n"
15
35
  `;
16
36
 
17
37
  exports[`loader > writeRequires > when using js > writes the story imports without types 1`] = `
18
- "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/all-config-files\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n \\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobal.STORIES = normalizedStories;\\n\\n\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!global.view) {\\n global.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(global.view, annotations, normalizedStories);\\n}\\n\\nexport const view = global.view;\\n"
38
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/all-config-files\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n \\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobalThis.STORIES = normalizedStories;\\n\\n\\n\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!globalThis.view) {\\n globalThis.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(globalThis.view, annotations, normalizedStories);\\n}\\n\\nexport const view = globalThis.view;\\n"
19
39
  `;
@@ -10,7 +10,17 @@ function getArguments() {
10
10
  )
11
11
  .option('-j, --use-js', 'Use a js file for storybook.requires')
12
12
  .option('-D, --no-doc-tools', 'Do not include doc tools in the storybook.requires file')
13
- .option('-a, --absolute', 'Use absolute paths for story imports');
13
+ .option(
14
+ '-w, --host <host>',
15
+ "Host for websockets, the value 'auto' will tell storybook to use your local ip address"
16
+ )
17
+ .option('-p, --port <port>', 'Port for websockets', (value) => {
18
+ const port = parseInt(value, 10);
19
+ if (isNaN(port)) {
20
+ throw new Error(`Invalid port number: "${value}"`);
21
+ }
22
+ return port;
23
+ });
14
24
 
15
25
  program.parse();
16
26