@storybook/react-native 7.6.11 → 7.6.13

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/V6.js CHANGED
@@ -1256,12 +1256,26 @@ var ErrorBoundary = class extends import_react4.default.Component {
1256
1256
  static getDerivedStateFromError(_error) {
1257
1257
  return { hasError: true };
1258
1258
  }
1259
- componentDidCatch(error, errorInfo) {
1260
- console.warn(error, errorInfo);
1259
+ componentDidCatch(error, info) {
1260
+ this.props.onError(error, info.componentStack);
1261
1261
  }
1262
1262
  render() {
1263
1263
  if (this.state.hasError) {
1264
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Text, { children: "Something went wrong rendering your story" });
1264
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1265
+ import_react_native3.View,
1266
+ {
1267
+ style: {
1268
+ margin: 16,
1269
+ padding: 16,
1270
+ borderColor: "red",
1271
+ borderWidth: 2,
1272
+ alignItems: "center",
1273
+ justifyContent: "center",
1274
+ borderRadius: 4
1275
+ },
1276
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Text, { style: { fontWeight: "bold" }, children: "Something went wrong rendering your story" })
1277
+ }
1278
+ );
1265
1279
  }
1266
1280
  return this.props.children;
1267
1281
  }
@@ -1285,7 +1299,15 @@ var StoryView = () => {
1285
1299
  style: { flex: 1, backgroundColor },
1286
1300
  testID: id,
1287
1301
  onStartShouldSetResponder: dismissOnStartResponder,
1288
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorBoundary, { children: StoryComponent && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StoryComponent, { ...context }) })
1302
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1303
+ ErrorBoundary,
1304
+ {
1305
+ onError: () => {
1306
+ console.log(`Error rendering story for ${context.title} ${context.name}`);
1307
+ },
1308
+ children: StoryComponent && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StoryComponent, { ...context })
1309
+ }
1310
+ )
1289
1311
  },
1290
1312
  id
1291
1313
  );
@@ -2003,7 +2025,7 @@ function getHost(hostname) {
2003
2025
  // src/View.tsx
2004
2026
  var import_jsx_runtime16 = require("react/jsx-runtime");
2005
2027
  var STORAGE_KEY = "lastOpenedStory";
2006
- var View10 = class {
2028
+ var View11 = class {
2007
2029
  _storyIndex;
2008
2030
  _setStory = () => {
2009
2031
  };
@@ -2069,7 +2091,6 @@ var View10 = class {
2069
2091
  this._idToPrepared[storyId] = await this._preview.storyStore.loadStory({ storyId });
2070
2092
  })
2071
2093
  );
2072
- console.log("Storybook: Finished building story index");
2073
2094
  };
2074
2095
  getStorybookUI = (params = {}) => {
2075
2096
  const {
@@ -2300,7 +2321,7 @@ function start() {
2300
2321
  preview.onStoriesChanged({ storyIndex });
2301
2322
  view2._storyIndex = storyIndex;
2302
2323
  }
2303
- const view2 = new View10(preview, channel);
2324
+ const view2 = new View11(preview, channel);
2304
2325
  return {
2305
2326
  view: view2,
2306
2327
  forceReRender: () => channel.emit(import_core_events3.default.FORCE_RE_RENDER),
package/dist/index.js CHANGED
@@ -1249,12 +1249,26 @@ var ErrorBoundary = class extends import_react4.default.Component {
1249
1249
  static getDerivedStateFromError(_error) {
1250
1250
  return { hasError: true };
1251
1251
  }
1252
- componentDidCatch(error, errorInfo) {
1253
- console.warn(error, errorInfo);
1252
+ componentDidCatch(error, info) {
1253
+ this.props.onError(error, info.componentStack);
1254
1254
  }
1255
1255
  render() {
1256
1256
  if (this.state.hasError) {
1257
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Text, { children: "Something went wrong rendering your story" });
1257
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1258
+ import_react_native3.View,
1259
+ {
1260
+ style: {
1261
+ margin: 16,
1262
+ padding: 16,
1263
+ borderColor: "red",
1264
+ borderWidth: 2,
1265
+ alignItems: "center",
1266
+ justifyContent: "center",
1267
+ borderRadius: 4
1268
+ },
1269
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Text, { style: { fontWeight: "bold" }, children: "Something went wrong rendering your story" })
1270
+ }
1271
+ );
1258
1272
  }
1259
1273
  return this.props.children;
1260
1274
  }
@@ -1278,7 +1292,15 @@ var StoryView = () => {
1278
1292
  style: { flex: 1, backgroundColor },
1279
1293
  testID: id,
1280
1294
  onStartShouldSetResponder: dismissOnStartResponder,
1281
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorBoundary, { children: StoryComponent && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StoryComponent, { ...context }) })
1295
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1296
+ ErrorBoundary,
1297
+ {
1298
+ onError: () => {
1299
+ console.log(`Error rendering story for ${context.title} ${context.name}`);
1300
+ },
1301
+ children: StoryComponent && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StoryComponent, { ...context })
1302
+ }
1303
+ )
1282
1304
  },
1283
1305
  id
1284
1306
  );
@@ -1996,7 +2018,7 @@ function getHost(hostname) {
1996
2018
  // src/View.tsx
1997
2019
  var import_jsx_runtime16 = require("react/jsx-runtime");
1998
2020
  var STORAGE_KEY = "lastOpenedStory";
1999
- var View10 = class {
2021
+ var View11 = class {
2000
2022
  _storyIndex;
2001
2023
  _setStory = () => {
2002
2024
  };
@@ -2062,7 +2084,6 @@ var View10 = class {
2062
2084
  this._idToPrepared[storyId] = await this._preview.storyStore.loadStory({ storyId });
2063
2085
  })
2064
2086
  );
2065
- console.log("Storybook: Finished building story index");
2066
2087
  };
2067
2088
  getStorybookUI = (params = {}) => {
2068
2089
  const {
@@ -2279,7 +2300,7 @@ function start({
2279
2300
  }
2280
2301
  };
2281
2302
  const preview = new import_preview_web.PreviewWithSelection(urlStore, previewView);
2282
- const view = new View10(preview, channel);
2303
+ const view = new View11(preview, channel);
2283
2304
  if (global) {
2284
2305
  global.__STORYBOOK_ADDONS_CHANNEL__ = channel;
2285
2306
  global.__STORYBOOK_PREVIEW__ = preview;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "7.6.11",
3
+ "version": "7.6.13",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -63,7 +63,7 @@
63
63
  "@storybook/preview-api": "^7.6.10",
64
64
  "@storybook/preview-web": "^7.6.10",
65
65
  "@storybook/react": "^7.6.10",
66
- "@storybook/react-native-theming": "^7.6.11",
66
+ "@storybook/react-native-theming": "^7.6.13",
67
67
  "chokidar": "^3.5.1",
68
68
  "commander": "^8.2.0",
69
69
  "dedent": "^1.5.1",
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "5aed8e2d2ddc4fe76dd5f883aeb35e3fb48cae87"
100
+ "gitHead": "65a036af0a3bdb8a3c48e8acc2b7a935165ddbb8"
101
101
  }
package/readme.md CHANGED
@@ -79,7 +79,7 @@ Then set `transformer.unstable_allowRequireContext` to true and add the generate
79
79
 
80
80
  ```js
81
81
  // metro.config.js
82
-
82
+ const path = require('path');
83
83
  const { getDefaultConfig } = require('expo/metro-config');
84
84
 
85
85
  const { generate } = require('@storybook/react-native/scripts/generate');
@@ -88,16 +88,18 @@ generate({
88
88
  configPath: path.resolve(__dirname, './.storybook'),
89
89
  });
90
90
 
91
- const defaultConfig = getDefaultConfig(__dirname);
91
+ /** @type {import('expo/metro-config').MetroConfig} */
92
+ const config = getDefaultConfig(__dirname);
92
93
 
93
- defaultConfig.transformer.unstable_allowRequireContext = true;
94
+ config.transformer.unstable_allowRequireContext = true;
94
95
 
95
- module.exports = defaultConfig;
96
+ module.exports = config;
96
97
  ```
97
98
 
98
99
  **React native**
99
100
 
100
101
  ```js
102
+ const path = require('path');
101
103
  const { generate } = require('@storybook/react-native/scripts/generate');
102
104
 
103
105
  generate({
@@ -29,14 +29,13 @@ function generate({ configPath, absolute = false, useJs = false }) {
29
29
  workingDir: cwd,
30
30
  });
31
31
 
32
- // TODO refactor contexts and normalized stories to be one thing
33
32
  const normalizedStories = storiesSpecifiers.map((specifier) => {
34
33
  // TODO why????
35
34
  const reg = globToRegexp(`./${specifier.files}`);
36
35
 
37
36
  const { path: p, recursive: r, match: m } = toRequireContext(specifier);
38
37
 
39
- const pathToStory = ensureRelativePathHasDot(path.relative(configPath, p));
38
+ const pathToStory = ensureRelativePathHasDot(path.posix.relative(configPath, p));
40
39
  return `{
41
40
  titlePrefix: "${specifier.titlePrefix}",
42
41
  directory: "${specifier.directory}",