@storybook/react-native 10.1.1 → 10.1.2-alpha.0
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/metro/withStorybook.js +51 -1
- package/package.json +9 -8
- package/scripts/generate.js +21 -3
- package/scripts/require-interop.js +32 -0
|
@@ -105,6 +105,38 @@ var require_common = __commonJS({
|
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
+
// scripts/require-interop.js
|
|
109
|
+
var require_require_interop = __commonJS({
|
|
110
|
+
"scripts/require-interop.js"(exports2, module2) {
|
|
111
|
+
var registered = false;
|
|
112
|
+
function interopRequireDefault(filePath) {
|
|
113
|
+
const hasEsbuildBeenRegistered = !!require("module")._extensions[".ts"];
|
|
114
|
+
if (registered === false && !hasEsbuildBeenRegistered) {
|
|
115
|
+
const { register } = require("esbuild-register/dist/node");
|
|
116
|
+
registered = true;
|
|
117
|
+
register({
|
|
118
|
+
target: `node${process.version.slice(1)}`,
|
|
119
|
+
format: "cjs",
|
|
120
|
+
hookIgnoreNodeModules: true,
|
|
121
|
+
// Some frameworks, like Stylus, rely on the 'name' property of classes or functions
|
|
122
|
+
// https://github.com/storybookjs/storybook/issues/19049
|
|
123
|
+
keepNames: true,
|
|
124
|
+
tsconfigRaw: `{
|
|
125
|
+
"compilerOptions": {
|
|
126
|
+
"strict": false,
|
|
127
|
+
"skipLibCheck": true,
|
|
128
|
+
},
|
|
129
|
+
}`
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
const result = require(filePath);
|
|
133
|
+
const isES6DefaultExported = typeof result === "object" && result !== null && typeof result.default !== "undefined";
|
|
134
|
+
return isES6DefaultExported ? result.default : result;
|
|
135
|
+
}
|
|
136
|
+
module2.exports = { interopRequireDefault };
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
108
140
|
// scripts/generate.js
|
|
109
141
|
var require_generate = __commonJS({
|
|
110
142
|
"scripts/generate.js"(exports2, module2) {
|
|
@@ -116,9 +148,27 @@ var require_generate = __commonJS({
|
|
|
116
148
|
getAddonName
|
|
117
149
|
} = require_common();
|
|
118
150
|
var { normalizeStories, globToRegexp, loadMainConfig } = require("storybook/internal/common");
|
|
151
|
+
var { interopRequireDefault } = require_require_interop();
|
|
119
152
|
var fs = require("fs");
|
|
120
153
|
var path2 = require("path");
|
|
121
154
|
var cwd = process.cwd();
|
|
155
|
+
var loadMain = async ({ configPath, cwd: cwd2 }) => {
|
|
156
|
+
try {
|
|
157
|
+
const main = await loadMainConfig({ configDir: configPath, cwd: cwd2 });
|
|
158
|
+
return main;
|
|
159
|
+
} catch {
|
|
160
|
+
console.error("Error loading main config, trying fallback");
|
|
161
|
+
}
|
|
162
|
+
const mainPathTs = path2.resolve(cwd2, configPath, `main.ts`);
|
|
163
|
+
const mainPathJs = path2.resolve(cwd2, configPath, `main.js`);
|
|
164
|
+
if (fs.existsSync(mainPathTs)) {
|
|
165
|
+
return interopRequireDefault(mainPathTs);
|
|
166
|
+
} else if (fs.existsSync(mainPathJs)) {
|
|
167
|
+
return interopRequireDefault(mainPathJs);
|
|
168
|
+
} else {
|
|
169
|
+
throw new Error(`Main config file not found at ${mainPathTs} or ${mainPathJs}`);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
122
172
|
async function generate2({
|
|
123
173
|
configPath,
|
|
124
174
|
/* absolute = false, */
|
|
@@ -130,7 +180,7 @@ var require_generate = __commonJS({
|
|
|
130
180
|
configPath,
|
|
131
181
|
`storybook.requires.${useJs ? "js" : "ts"}`
|
|
132
182
|
);
|
|
133
|
-
const main = await
|
|
183
|
+
const main = await loadMain({ configPath, cwd });
|
|
134
184
|
const storiesSpecifiers = normalizeStories(main.stories, {
|
|
135
185
|
configDir: configPath,
|
|
136
186
|
workingDir: cwd
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.2-alpha.0",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -48,13 +48,14 @@
|
|
|
48
48
|
"test:generate:update": "node --test --test-update-snapshots scripts/generate.test.js"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@storybook/react": "^10.1.
|
|
52
|
-
"@storybook/react-native-theming": "^10.1.
|
|
53
|
-
"@storybook/react-native-ui": "^10.1.
|
|
54
|
-
"@storybook/react-native-ui-common": "^10.1.
|
|
51
|
+
"@storybook/react": "^10.1.2",
|
|
52
|
+
"@storybook/react-native-theming": "^10.1.2-alpha.0",
|
|
53
|
+
"@storybook/react-native-ui": "^10.1.2-alpha.0",
|
|
54
|
+
"@storybook/react-native-ui-common": "^10.1.2-alpha.0",
|
|
55
55
|
"commander": "^14.0.2",
|
|
56
56
|
"dedent": "^1.7.0",
|
|
57
57
|
"deepmerge": "^4.3.1",
|
|
58
|
+
"esbuild-register": "^3.6.0",
|
|
58
59
|
"react-native-url-polyfill": "^3.0.0",
|
|
59
60
|
"setimmediate": "^1.0.5",
|
|
60
61
|
"ws": "^8.18.3"
|
|
@@ -65,11 +66,11 @@
|
|
|
65
66
|
"babel-jest": "^29.7.0",
|
|
66
67
|
"babel-preset-expo": "^54.0.6",
|
|
67
68
|
"jest": "^29.7.0",
|
|
68
|
-
"jest-expo": "~54.0.
|
|
69
|
+
"jest-expo": "~54.0.16",
|
|
69
70
|
"jotai": "^2.6.2",
|
|
70
71
|
"react": "19.1.0",
|
|
71
72
|
"react-native": "0.81.5",
|
|
72
|
-
"storybook": "^10.1.
|
|
73
|
+
"storybook": "^10.1.2",
|
|
73
74
|
"tsup": "^8.5.0",
|
|
74
75
|
"typescript": "~5.9.3",
|
|
75
76
|
"universal-test-renderer": "^0.6.0"
|
|
@@ -103,5 +104,5 @@
|
|
|
103
104
|
"publishConfig": {
|
|
104
105
|
"access": "public"
|
|
105
106
|
},
|
|
106
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "3c47e12910793c447acdd33e6ce8f9628c63019b"
|
|
107
108
|
}
|
package/scripts/generate.js
CHANGED
|
@@ -6,12 +6,32 @@ const {
|
|
|
6
6
|
getAddonName,
|
|
7
7
|
} = require('./common');
|
|
8
8
|
const { normalizeStories, globToRegexp, loadMainConfig } = require('storybook/internal/common');
|
|
9
|
+
const { interopRequireDefault } = require('./require-interop');
|
|
9
10
|
const fs = require('fs');
|
|
10
11
|
|
|
11
12
|
const path = require('path');
|
|
12
13
|
|
|
13
14
|
const cwd = process.cwd();
|
|
14
15
|
|
|
16
|
+
const loadMain = async ({ configPath, cwd }) => {
|
|
17
|
+
try {
|
|
18
|
+
const main = await loadMainConfig({ configDir: configPath, cwd });
|
|
19
|
+
return main;
|
|
20
|
+
} catch {
|
|
21
|
+
console.error('Error loading main config, trying fallback');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const mainPathTs = path.resolve(cwd, configPath, `main.ts`);
|
|
25
|
+
const mainPathJs = path.resolve(cwd, configPath, `main.js`);
|
|
26
|
+
if (fs.existsSync(mainPathTs)) {
|
|
27
|
+
return interopRequireDefault(mainPathTs);
|
|
28
|
+
} else if (fs.existsSync(mainPathJs)) {
|
|
29
|
+
return interopRequireDefault(mainPathJs);
|
|
30
|
+
} else {
|
|
31
|
+
throw new Error(`Main config file not found at ${mainPathTs} or ${mainPathJs}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
15
35
|
async function generate({ configPath, /* absolute = false, */ useJs = false, docTools = true }) {
|
|
16
36
|
const storybookRequiresLocation = path.resolve(
|
|
17
37
|
cwd,
|
|
@@ -19,9 +39,7 @@ async function generate({ configPath, /* absolute = false, */ useJs = false, doc
|
|
|
19
39
|
`storybook.requires.${useJs ? 'js' : 'ts'}`
|
|
20
40
|
);
|
|
21
41
|
|
|
22
|
-
const main = await
|
|
23
|
-
|
|
24
|
-
// const reactNativeOptions = main.reactNativeOptions;
|
|
42
|
+
const main = await loadMain({ configPath, cwd });
|
|
25
43
|
|
|
26
44
|
const storiesSpecifiers = normalizeStories(main.stories, {
|
|
27
45
|
configDir: configPath,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
let registered = false;
|
|
2
|
+
function interopRequireDefault(filePath) {
|
|
3
|
+
const hasEsbuildBeenRegistered = !!require('module')._extensions['.ts'];
|
|
4
|
+
|
|
5
|
+
if (registered === false && !hasEsbuildBeenRegistered) {
|
|
6
|
+
const { register } = require('esbuild-register/dist/node');
|
|
7
|
+
registered = true;
|
|
8
|
+
register({
|
|
9
|
+
target: `node${process.version.slice(1)}`,
|
|
10
|
+
format: 'cjs',
|
|
11
|
+
hookIgnoreNodeModules: true,
|
|
12
|
+
// Some frameworks, like Stylus, rely on the 'name' property of classes or functions
|
|
13
|
+
// https://github.com/storybookjs/storybook/issues/19049
|
|
14
|
+
keepNames: true,
|
|
15
|
+
tsconfigRaw: `{
|
|
16
|
+
"compilerOptions": {
|
|
17
|
+
"strict": false,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
},
|
|
20
|
+
}`,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const result = require(filePath);
|
|
25
|
+
|
|
26
|
+
const isES6DefaultExported =
|
|
27
|
+
typeof result === 'object' && result !== null && typeof result.default !== 'undefined';
|
|
28
|
+
|
|
29
|
+
return isES6DefaultExported ? result.default : result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = { interopRequireDefault };
|