@storybook/react-native 10.2.2-canary.1 → 10.2.2-next.7

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.
Files changed (40) hide show
  1. package/dist/index.d.ts +1 -5
  2. package/dist/index.js +709 -544
  3. package/dist/metro/withStorybook.js +7 -11
  4. package/dist/node.js +3 -2
  5. package/dist/repack/withStorybook.js +6 -10
  6. package/package.json +12 -15
  7. package/scripts/common.js +4 -2
  8. package/scripts/generate.js +3 -9
  9. package/scripts/generate.test.js +0 -218
  10. package/scripts/generate.test.js.snapshot +0 -39
  11. package/scripts/mocks/all-config-files/FakeComponent.tsx +0 -1
  12. package/scripts/mocks/all-config-files/FakeStory.stories.tsx +0 -10
  13. package/scripts/mocks/all-config-files/main.js +0 -9
  14. package/scripts/mocks/all-config-files/preview.js +0 -24
  15. package/scripts/mocks/blank-config/main.js +0 -4
  16. package/scripts/mocks/configuration-objects/components/FakeComponent.tsx +0 -1
  17. package/scripts/mocks/configuration-objects/components/FakeStory.stories.tsx +0 -9
  18. package/scripts/mocks/configuration-objects/main.js +0 -15
  19. package/scripts/mocks/configuration-objects/preview.js +0 -24
  20. package/scripts/mocks/exclude-config-files/exclude-components/FakeComponent.tsx +0 -1
  21. package/scripts/mocks/exclude-config-files/exclude-components/FakeStory.stories.tsx +0 -10
  22. package/scripts/mocks/exclude-config-files/include-components/FakeComponent.tsx +0 -1
  23. package/scripts/mocks/exclude-config-files/include-components/FakeStory.stories.tsx +0 -10
  24. package/scripts/mocks/exclude-config-files/main.js +0 -12
  25. package/scripts/mocks/exclude-config-files/preview.js +0 -24
  26. package/scripts/mocks/file-extensions/FakeComponent.tsx +0 -1
  27. package/scripts/mocks/file-extensions/FakeStory.stories.tsx +0 -10
  28. package/scripts/mocks/file-extensions/main.ts +0 -11
  29. package/scripts/mocks/file-extensions/preview.tsx +0 -23
  30. package/scripts/mocks/no-preview/FakeComponent.tsx +0 -1
  31. package/scripts/mocks/no-preview/FakeStory.stories.tsx +0 -10
  32. package/scripts/mocks/no-preview/main.js +0 -9
  33. package/scripts/mocks/preview-files/js/preview.js +0 -24
  34. package/scripts/mocks/preview-files/jsx/preview.jsx +0 -24
  35. package/scripts/mocks/preview-files/ts/preview.ts +0 -9
  36. package/scripts/mocks/preview-files/tsx/preview.tsx +0 -9
  37. package/scripts/mocks/wrong-extension-preview/FakeComponent.tsx +0 -1
  38. package/scripts/mocks/wrong-extension-preview/FakeStory.stories.tsx +0 -10
  39. package/scripts/mocks/wrong-extension-preview/main.js +0 -9
  40. package/scripts/mocks/wrong-extension-preview/preview.txt +0 -24
@@ -72,16 +72,17 @@ var require_common = __commonJS({
72
72
  }
73
73
  function resolveAddonFile(addon, file, extensions = ["js", "mjs", "ts"], configPath) {
74
74
  if (!addon || typeof addon !== "string") return null;
75
+ const resolvePaths = { paths: [cwd2] };
75
76
  try {
76
77
  const basePath = `${addon}/${file}`;
77
- require.resolve(basePath);
78
+ require.resolve(basePath, resolvePaths);
78
79
  return basePath;
79
80
  } catch (_error) {
80
81
  }
81
82
  for (const ext of extensions) {
82
83
  try {
83
84
  const filePath = `${addon}/${file}.${ext}`;
84
- require.resolve(filePath);
85
+ require.resolve(filePath, resolvePaths);
85
86
  return filePath;
86
87
  } catch (_error) {
87
88
  }
@@ -199,10 +200,7 @@ var require_generate = __commonJS({
199
200
  host = void 0,
200
201
  port = 7007
201
202
  }) {
202
- const envChannelHost = process.env.STORYBOOK_CHANNEL_HOST;
203
- const envChannelPort = process.env.STORYBOOK_CHANNEL_PORT;
204
- const channelHost = envChannelHost || (host === "auto" ? getLocalIPAddress() : host);
205
- const channelPort = envChannelPort || port;
203
+ const channelHost = host === "auto" ? getLocalIPAddress() : host;
206
204
  const storybookRequiresLocation = path3.resolve(
207
205
  cwd2,
208
206
  configPath,
@@ -278,7 +276,6 @@ declare global {
278
276
  var view: View;
279
277
  var STORIES: typeof normalizedStories;
280
278
  var STORYBOOK_WEBSOCKET: { host: string; port: number } | undefined;
281
- var STORYBOOK_FORCE_ENABLED: boolean | undefined;
282
279
  }
283
280
  `;
284
281
  const fileContent = `/* do not change this file, it is auto generated by storybook. */
@@ -294,10 +291,9 @@ ${useJs ? "" : globalTypes}
294
291
 
295
292
  const annotations = ${annotations};
296
293
 
297
-
298
294
  globalThis.STORIES = normalizedStories;
299
- ${channelHost ? `globalThis.STORYBOOK_WEBSOCKET = { host: '${channelHost}', port: ${channelPort} };` : ""}
300
- ${process.env.STORYBOOK_FORCE_ENABLED ? `globalThis.STORYBOOK_FORCE_ENABLED = true;` : ""}
295
+ ${channelHost ? `globalThis.STORYBOOK_WEBSOCKET = { host: '${channelHost}', port: ${port ?? 7007} };` : ""}
296
+
301
297
  ${useJs ? "" : "// @ts-ignore"}
302
298
  module?.hot?.accept?.();
303
299
 
@@ -534,11 +530,11 @@ function withStorybook(config, options = {
534
530
  configPath = path2.resolve(process.cwd(), "./.rnstorybook"),
535
531
  websockets,
536
532
  useJs = false,
533
+ enabled = true,
537
534
  docTools = true,
538
535
  liteMode = false
539
536
  } = options;
540
537
  const disableTelemetry = (0, import_common3.optionalEnvToBoolean)(process.env.STORYBOOK_DISABLE_TELEMETRY);
541
- const enabled = (0, import_common3.optionalEnvToBoolean)(process.env.STORYBOOK_FORCE_ENABLED) || (options.enabled ?? true);
542
538
  if (!disableTelemetry && enabled) {
543
539
  const event = process.env.NODE_ENV === "production" ? "build" : "dev";
544
540
  (0, import_telemetry.telemetry)(event, {}).catch((e) => {
package/dist/node.js CHANGED
@@ -72,16 +72,17 @@ var require_common = __commonJS({
72
72
  }
73
73
  function resolveAddonFile(addon, file, extensions = ["js", "mjs", "ts"], configPath) {
74
74
  if (!addon || typeof addon !== "string") return null;
75
+ const resolvePaths = { paths: [cwd2] };
75
76
  try {
76
77
  const basePath = `${addon}/${file}`;
77
- require.resolve(basePath);
78
+ require.resolve(basePath, resolvePaths);
78
79
  return basePath;
79
80
  } catch (_error) {
80
81
  }
81
82
  for (const ext of extensions) {
82
83
  try {
83
84
  const filePath = `${addon}/${file}.${ext}`;
84
- require.resolve(filePath);
85
+ require.resolve(filePath, resolvePaths);
85
86
  return filePath;
86
87
  } catch (_error) {
87
88
  }
@@ -72,16 +72,17 @@ var require_common = __commonJS({
72
72
  }
73
73
  function resolveAddonFile(addon, file, extensions = ["js", "mjs", "ts"], configPath) {
74
74
  if (!addon || typeof addon !== "string") return null;
75
+ const resolvePaths = { paths: [cwd2] };
75
76
  try {
76
77
  const basePath = `${addon}/${file}`;
77
- require.resolve(basePath);
78
+ require.resolve(basePath, resolvePaths);
78
79
  return basePath;
79
80
  } catch (_error) {
80
81
  }
81
82
  for (const ext of extensions) {
82
83
  try {
83
84
  const filePath = `${addon}/${file}.${ext}`;
84
- require.resolve(filePath);
85
+ require.resolve(filePath, resolvePaths);
85
86
  return filePath;
86
87
  } catch (_error) {
87
88
  }
@@ -199,10 +200,7 @@ var require_generate = __commonJS({
199
200
  host = void 0,
200
201
  port = 7007
201
202
  }) {
202
- const envChannelHost = process.env.STORYBOOK_CHANNEL_HOST;
203
- const envChannelPort = process.env.STORYBOOK_CHANNEL_PORT;
204
- const channelHost = envChannelHost || (host === "auto" ? getLocalIPAddress() : host);
205
- const channelPort = envChannelPort || port;
203
+ const channelHost = host === "auto" ? getLocalIPAddress() : host;
206
204
  const storybookRequiresLocation = path3.resolve(
207
205
  cwd2,
208
206
  configPath,
@@ -278,7 +276,6 @@ declare global {
278
276
  var view: View;
279
277
  var STORIES: typeof normalizedStories;
280
278
  var STORYBOOK_WEBSOCKET: { host: string; port: number } | undefined;
281
- var STORYBOOK_FORCE_ENABLED: boolean | undefined;
282
279
  }
283
280
  `;
284
281
  const fileContent = `/* do not change this file, it is auto generated by storybook. */
@@ -294,10 +291,9 @@ ${useJs ? "" : globalTypes}
294
291
 
295
292
  const annotations = ${annotations};
296
293
 
297
-
298
294
  globalThis.STORIES = normalizedStories;
299
- ${channelHost ? `globalThis.STORYBOOK_WEBSOCKET = { host: '${channelHost}', port: ${channelPort} };` : ""}
300
- ${process.env.STORYBOOK_FORCE_ENABLED ? `globalThis.STORYBOOK_FORCE_ENABLED = true;` : ""}
295
+ ${channelHost ? `globalThis.STORYBOOK_WEBSOCKET = { host: '${channelHost}', port: ${port ?? 7007} };` : ""}
296
+
301
297
  ${useJs ? "" : "// @ts-ignore"}
302
298
  module?.hot?.accept?.();
303
299
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "10.2.2-canary.1",
3
+ "version": "10.2.2-next.7",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -41,19 +41,11 @@
41
41
  "template/**/*",
42
42
  "metro/**/*"
43
43
  ],
44
- "scripts": {
45
- "dev": "npx --yes tsx buildscripts/gendtsdev.ts && tsup --watch",
46
- "prepare": "rm -rf dist/ && tsup",
47
- "test": "jest && yarn test:generate",
48
- "test:ci": "jest && yarn test:generate",
49
- "test:generate": "node --test scripts/generate.test.js",
50
- "test:generate:update": "node --test --test-update-snapshots scripts/generate.test.js"
51
- },
52
44
  "dependencies": {
53
45
  "@storybook/react": "^10.2.2",
54
- "@storybook/react-native-theming": "^10.2.2-canary.1",
55
- "@storybook/react-native-ui": "^10.2.2-canary.1",
56
- "@storybook/react-native-ui-common": "^10.2.2-canary.1",
46
+ "@storybook/react-native-theming": "^10.2.2-next.7",
47
+ "@storybook/react-native-ui": "^10.2.2-next.7",
48
+ "@storybook/react-native-ui-common": "^10.2.2-next.7",
57
49
  "commander": "^14.0.2",
58
50
  "dedent": "^1.7.0",
59
51
  "deepmerge": "^4.3.1",
@@ -70,7 +62,7 @@
70
62
  "babel-preset-expo": "^54.0.6",
71
63
  "jest": "^29.7.0",
72
64
  "jest-expo": "~54.0.16",
73
- "jotai": "^2.6.2",
65
+ "jotai": "^2.17.1",
74
66
  "react": "19.1.0",
75
67
  "react-native": "0.81.5",
76
68
  "storybook": "^10.2.2",
@@ -107,5 +99,10 @@
107
99
  "publishConfig": {
108
100
  "access": "public"
109
101
  },
110
- "gitHead": "1626205fb105d17ee86111d277a7a939140b5e87"
111
- }
102
+ "gitHead": "4aa2ae40569ea7f61e438ce568a39c580b3097d8",
103
+ "scripts": {
104
+ "dev": "npx --yes tsx buildscripts/gendtsdev.ts && tsup --watch",
105
+ "test": "jest",
106
+ "test:ci": "jest"
107
+ }
108
+ }
package/scripts/common.js CHANGED
@@ -55,10 +55,12 @@ function getPreviewExists({ configPath }) {
55
55
  function resolveAddonFile(addon, file, extensions = ['js', 'mjs', 'ts'], configPath) {
56
56
  if (!addon || typeof addon !== 'string') return null;
57
57
 
58
+ const resolvePaths = { paths: [cwd] };
59
+
58
60
  try {
59
61
  const basePath = `${addon}/${file}`;
60
62
 
61
- require.resolve(basePath);
63
+ require.resolve(basePath, resolvePaths);
62
64
 
63
65
  return basePath;
64
66
  } catch (_error) {}
@@ -67,7 +69,7 @@ function resolveAddonFile(addon, file, extensions = ['js', 'mjs', 'ts'], configP
67
69
  try {
68
70
  const filePath = `${addon}/${file}.${ext}`;
69
71
 
70
- require.resolve(filePath);
72
+ require.resolve(filePath, resolvePaths);
71
73
 
72
74
  return filePath;
73
75
  } catch (_error) {}
@@ -58,11 +58,7 @@ async function generate({
58
58
  port = 7007,
59
59
  }) {
60
60
  // here we want to get the ip address and pass it to rn storybook so that devices can connect over lan easily
61
- const envChannelHost = process.env.STORYBOOK_CHANNEL_HOST;
62
- const envChannelPort = process.env.STORYBOOK_CHANNEL_PORT;
63
-
64
- const channelHost = envChannelHost || (host === 'auto' ? getLocalIPAddress() : host);
65
- const channelPort = envChannelPort || port;
61
+ const channelHost = host === 'auto' ? getLocalIPAddress() : host;
66
62
  const storybookRequiresLocation = path.resolve(
67
63
  cwd,
68
64
  configPath,
@@ -158,7 +154,6 @@ declare global {
158
154
  var view: View;
159
155
  var STORIES: typeof normalizedStories;
160
156
  var STORYBOOK_WEBSOCKET: { host: string; port: number } | undefined;
161
- var STORYBOOK_FORCE_ENABLED: boolean | undefined;
162
157
  }
163
158
  `;
164
159
 
@@ -175,10 +170,9 @@ ${useJs ? '' : globalTypes}
175
170
 
176
171
  const annotations = ${annotations};
177
172
 
178
-
179
173
  globalThis.STORIES = normalizedStories;
180
- ${channelHost ? `globalThis.STORYBOOK_WEBSOCKET = { host: '${channelHost}', port: ${channelPort} };` : ''}
181
- ${process.env.STORYBOOK_FORCE_ENABLED ? `globalThis.STORYBOOK_FORCE_ENABLED = true;` : ''}
174
+ ${channelHost ? `globalThis.STORYBOOK_WEBSOCKET = { host: '${channelHost}', port: ${port ?? 7007} };` : ''}
175
+
182
176
  ${useJs ? '' : '// @ts-ignore'}
183
177
  module?.hot?.accept?.();
184
178
 
@@ -1,218 +0,0 @@
1
- const { describe, it, beforeEach, mock } = require('node:test');
2
- const assert = require('node:assert');
3
- const path = require('node:path');
4
- const { generate } = require('./generate');
5
-
6
- let pathMock;
7
- let fileContentMock;
8
-
9
- global.window = { navigator: {} };
10
-
11
- const mockFs = {
12
- writeFileSync: (filePath, fileContent, opts) => {
13
- pathMock = filePath;
14
- fileContentMock = fileContent;
15
- },
16
- };
17
-
18
- describe('loader', () => {
19
- beforeEach(() => {
20
- pathMock = undefined;
21
- fileContentMock = undefined;
22
- });
23
-
24
- describe('writeRequires', () => {
25
- describe('when there is a story glob', () => {
26
- it('writes the story imports', async (t) => {
27
- mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
28
- await generate({ configPath: 'scripts/mocks/all-config-files' });
29
- mock.reset();
30
-
31
- assert.strictEqual(
32
- pathMock,
33
- path.resolve(__dirname, 'mocks/all-config-files/storybook.requires.ts')
34
- );
35
- t.assert.snapshot(fileContentMock);
36
- });
37
- });
38
-
39
- describe('when using js', () => {
40
- it('writes the story imports without types', async (t) => {
41
- mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
42
- await generate({ configPath: 'scripts/mocks/all-config-files', useJs: true });
43
- mock.reset();
44
-
45
- assert.strictEqual(
46
- pathMock,
47
- path.resolve(__dirname, 'mocks/all-config-files/storybook.requires.js')
48
- );
49
- t.assert.snapshot(fileContentMock);
50
- });
51
- });
52
-
53
- describe('when there are different file extensions', () => {
54
- it('writes the story imports', async (t) => {
55
- mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
56
- await generate({ configPath: 'scripts/mocks/file-extensions' });
57
- mock.reset();
58
-
59
- assert.strictEqual(
60
- pathMock,
61
- path.resolve(__dirname, 'mocks/file-extensions/storybook.requires.ts')
62
- );
63
- t.assert.snapshot(fileContentMock);
64
- });
65
- });
66
-
67
- // TODO can we support exclude globs?
68
- // describe('when there is a story glob and exclude paths globs', () => {
69
- // it('writes the story imports', () => {
70
- // generate({ configPath: 'scripts/mocks/exclude-config-files' });
71
- // assert.strictEqual(
72
- // pathMock,
73
- // path.resolve(__dirname, 'mocks/exclude-config-files/storybook.requires.ts')
74
- // );
75
-
76
- // assert.ok(fileContentMock.includes('include-components/FakeStory.stories.tsx'));
77
- // assert.ok(!fileContentMock.includes('exclude-components/FakeStory.stories.tsx'));
78
-
79
- // t.assert.snapshot(fileContentMock);
80
- // });
81
- // });
82
-
83
- describe('when there is no story glob or addons', () => {
84
- it('throws an error', async () => {
85
- mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
86
- await assert.rejects(
87
- async () => await generate({ configPath: 'scripts/mocks/blank-config' }),
88
- Error
89
- );
90
- mock.reset();
91
- });
92
- });
93
-
94
- describe('when there is no preview', () => {
95
- it('does not add preview related stuff', async (t) => {
96
- mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
97
- await generate({ configPath: 'scripts/mocks/no-preview' });
98
- mock.reset();
99
-
100
- assert.strictEqual(
101
- pathMock,
102
- path.resolve(__dirname, 'mocks/no-preview/storybook.requires.ts')
103
- );
104
- t.assert.snapshot(fileContentMock);
105
- });
106
- });
107
-
108
- // TODO does this still make sense?
109
- // describe('when the absolute option is true', () => {
110
- // it('should write absolute paths to the requires file', () => {
111
- // generate({ configPath: 'scripts/mocks/all-config-files', absolute: true });
112
- // assert.strictEqual(
113
- // pathMock,
114
- // path.resolve(__dirname, 'mocks/all-config-files/storybook.requires.ts')
115
- // );
116
-
117
- // // assert.ok(fileContentMock.includes(`FakeStory.stories.tsx`));
118
- // assert.ok(fileContentMock.includes(path.resolve(__dirname, 'mocks/all-config-files')));
119
- // });
120
- // });
121
-
122
- describe('when there is a configuration object', () => {
123
- it('writes the story imports', async (t) => {
124
- mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
125
- await generate({ configPath: 'scripts/mocks/configuration-objects' });
126
- mock.reset();
127
-
128
- assert.strictEqual(
129
- pathMock,
130
- path.resolve(__dirname, 'mocks/configuration-objects/storybook.requires.ts')
131
- );
132
- t.assert.snapshot(fileContentMock);
133
- });
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
- });
217
- });
218
- });
@@ -1,39 +0,0 @@
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 var STORYBOOK_FORCE_ENABLED: boolean | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\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\\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 var STORYBOOK_FORCE_ENABLED: boolean | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\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 var STORYBOOK_FORCE_ENABLED: boolean | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\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 var STORYBOOK_FORCE_ENABLED: boolean | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\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
-
21
- exports[`loader > writeRequires > when there are different file extensions > writes the story imports 1`] = `
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 var STORYBOOK_FORCE_ENABLED: boolean | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\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"
23
- `;
24
-
25
- exports[`loader > writeRequires > when there is a configuration object > writes the story imports 1`] = `
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 var STORYBOOK_FORCE_ENABLED: boolean | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\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"
27
- `;
28
-
29
- exports[`loader > writeRequires > when there is a story glob > writes the story imports 1`] = `
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 var STORYBOOK_FORCE_ENABLED: boolean | undefined;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\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"
31
- `;
32
-
33
- exports[`loader > writeRequires > when there is no preview > does not add preview related stuff 1`] = `
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 var STORYBOOK_FORCE_ENABLED: boolean | undefined;\\n}\\n\\n\\nconst annotations = [\\n require(\\"@storybook/react-native/preview\\")\\n];\\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"
35
- `;
36
-
37
- exports[`loader > writeRequires > when using js > writes the story imports without types 1`] = `
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\\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"
39
- `;
@@ -1 +0,0 @@
1
- export const FakeComponent = () => null;
@@ -1,10 +0,0 @@
1
- import { FakeComponent } from './FakeComponent';
2
-
3
- export default {
4
- title: 'components/FakeComponent',
5
- component: FakeComponent,
6
- };
7
-
8
- export const Basic = {
9
- args: {},
10
- };
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- stories: ['./FakeStory.stories.tsx'],
3
- addons: [
4
- '@storybook/addon-ondevice-notes',
5
- '@storybook/addon-ondevice-controls',
6
- '@storybook/addon-ondevice-backgrounds',
7
- '@storybook/addon-ondevice-actions',
8
- ],
9
- };
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { View, StyleSheet } from 'react-native';
3
- import { withBackgrounds } from '@storybook/addon-ondevice-backgrounds';
4
-
5
- export const decorators = [
6
- (StoryFn) => (
7
- <View style={styles.container}>
8
- <StoryFn />
9
- </View>
10
- ),
11
- withBackgrounds,
12
- ];
13
- export const parameters = {
14
- my_param: 'anything',
15
- backgrounds: [
16
- { name: 'plain', value: 'white', default: true },
17
- { name: 'warm', value: 'hotpink' },
18
- { name: 'cool', value: 'deepskyblue' },
19
- ],
20
- };
21
-
22
- const styles = StyleSheet.create({
23
- container: { padding: 8, flex: 1 },
24
- });
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- stories: [],
3
- addons: [],
4
- };
@@ -1 +0,0 @@
1
- export const FakeComponent = () => null;
@@ -1,9 +0,0 @@
1
- import { FakeComponent } from './FakeComponent';
2
-
3
- export default {
4
- component: FakeComponent,
5
- };
6
-
7
- export const Basic = {
8
- args: {},
9
- };
@@ -1,15 +0,0 @@
1
- module.exports = {
2
- stories: [
3
- {
4
- files: '**/*.stories.tsx',
5
- directory: './components',
6
- titlePrefix: 'ComponentsPrefix',
7
- },
8
- ],
9
- addons: [
10
- '@storybook/addon-ondevice-notes',
11
- '@storybook/addon-ondevice-controls',
12
- '@storybook/addon-ondevice-backgrounds',
13
- '@storybook/addon-ondevice-actions',
14
- ],
15
- };
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { View, StyleSheet } from 'react-native';
3
- import { withBackgrounds } from '@storybook/addon-ondevice-backgrounds';
4
-
5
- export const decorators = [
6
- (StoryFn) => (
7
- <View style={styles.container}>
8
- <StoryFn />
9
- </View>
10
- ),
11
- withBackgrounds,
12
- ];
13
- export const parameters = {
14
- my_param: 'anything',
15
- backgrounds: [
16
- { name: 'plain', value: 'white', default: true },
17
- { name: 'warm', value: 'hotpink' },
18
- { name: 'cool', value: 'deepskyblue' },
19
- ],
20
- };
21
-
22
- const styles = StyleSheet.create({
23
- container: { padding: 8, flex: 1 },
24
- });
@@ -1 +0,0 @@
1
- export const FakeComponentExcluded = () => null;