@storybook/react-native 7.6.11 → 8.0.0-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/index.d.ts CHANGED
@@ -1,14 +1,70 @@
1
- import { N as NormalizedStoriesSpecifier, S as StorybookConfig$1 } from './index.d-da6c1de4.js';
1
+ import { S as StoryIndex, P as PreparedStory, N as NormalizedStoriesSpecifier, a as StorybookConfig$1 } from './index.d-b039fbf0.js';
2
+ import { Theme } from '@storybook/react-native-theming';
2
3
  export { Theme, darkTheme, theme } from '@storybook/react-native-theming';
3
- import { V as View } from './View-bd441663.js';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { StoryContext } from '@storybook/csf';
6
+ import { PreviewWithSelection } from '@storybook/preview-api';
7
+ import { ReactRenderer } from '@storybook/react';
8
+ import { Channel } from '@storybook/channels';
4
9
  import 'file-system-cache';
5
- import '@babel/core';
6
10
  import 'http';
7
- import 'react/jsx-runtime';
8
- import '@storybook/csf';
9
- import '@storybook/preview-web';
10
- import '@storybook/react';
11
- import '@storybook/channels';
11
+
12
+ interface Storage {
13
+ getItem: (key: string) => Promise<string | null>;
14
+ setItem: (key: string, value: string) => Promise<void>;
15
+ }
16
+ type StoryKind = string;
17
+ type StoryName = string;
18
+ type InitialSelection = `${StoryKind}--${StoryName}` | {
19
+ /**
20
+ * Kind is the default export name or the storiesOf("name") name
21
+ */
22
+ kind: StoryKind;
23
+ /**
24
+ * Name is the named export or the .add("name") name
25
+ */
26
+ name: StoryName;
27
+ };
28
+ type DeepPartial<T> = T extends object ? {
29
+ [P in keyof T]?: DeepPartial<T[P]>;
30
+ } : T;
31
+ type Params = {
32
+ onDeviceUI?: boolean;
33
+ enableWebsockets?: boolean;
34
+ query?: string;
35
+ host?: string;
36
+ port?: number;
37
+ secured?: boolean;
38
+ initialSelection?: InitialSelection;
39
+ shouldPersistSelection?: boolean;
40
+ tabOpen?: number;
41
+ isUIHidden?: boolean;
42
+ isSplitPanelVisible?: boolean;
43
+ shouldDisableKeyboardAvoidingView?: boolean;
44
+ keyboardAvoidingViewVerticalOffset?: number;
45
+ theme: DeepPartial<Theme>;
46
+ storage?: Storage;
47
+ };
48
+ declare class View {
49
+ _storyIndex: StoryIndex;
50
+ _setStory: (story: StoryContext<ReactRenderer>) => void;
51
+ _forceRerender: () => void;
52
+ _ready: boolean;
53
+ _preview: PreviewWithSelection<ReactRenderer>;
54
+ _asyncStorageStoryId: string;
55
+ _webUrl: string;
56
+ _storage: Storage;
57
+ _channel: Channel;
58
+ _idToPrepared: Record<string, PreparedStory<ReactRenderer>>;
59
+ constructor(preview: PreviewWithSelection<ReactRenderer>, channel: Channel);
60
+ _getInitialStory: ({ initialSelection, shouldPersistSelection, }?: Partial<Params>) => Promise<{
61
+ storySpecifier: string;
62
+ viewMode: string;
63
+ }>;
64
+ _getServerChannel: (params?: Partial<Params>) => Channel;
65
+ createPreparedStoryMapping: () => Promise<void>;
66
+ getStorybookUI: (params?: Partial<Params>) => () => react_jsx_runtime.JSX.Element;
67
+ }
12
68
 
13
69
  declare function start({ annotations, storyEntries, }: {
14
70
  storyEntries: Array<NormalizedStoriesSpecifier & {
package/dist/index.js CHANGED
@@ -51,7 +51,7 @@ var require_dist = __commonJS({
51
51
  var src_exports2 = {};
52
52
  __export2(src_exports2, { Addon_TypesEnum: () => Addon_TypesEnum2 });
53
53
  module2.exports = __toCommonJS2(src_exports2);
54
- var Addon_TypesEnum2 = ((Addon_TypesEnum22) => (Addon_TypesEnum22.TAB = "tab", Addon_TypesEnum22.PANEL = "panel", Addon_TypesEnum22.TOOL = "tool", Addon_TypesEnum22.TOOLEXTRA = "toolextra", Addon_TypesEnum22.PREVIEW = "preview", Addon_TypesEnum22.experimental_PAGE = "page", Addon_TypesEnum22.experimental_SIDEBAR_BOTTOM = "sidebar-bottom", Addon_TypesEnum22.experimental_SIDEBAR_TOP = "sidebar-top", Addon_TypesEnum22.NOTES_ELEMENT = "notes-element", Addon_TypesEnum22))(Addon_TypesEnum2 || {});
54
+ var Addon_TypesEnum2 = ((Addon_TypesEnum22) => (Addon_TypesEnum22.TAB = "tab", Addon_TypesEnum22.PANEL = "panel", Addon_TypesEnum22.TOOL = "tool", Addon_TypesEnum22.TOOLEXTRA = "toolextra", Addon_TypesEnum22.PREVIEW = "preview", Addon_TypesEnum22.experimental_PAGE = "page", Addon_TypesEnum22.experimental_SIDEBAR_BOTTOM = "sidebar-bottom", Addon_TypesEnum22.experimental_SIDEBAR_TOP = "sidebar-top", Addon_TypesEnum22))(Addon_TypesEnum2 || {});
55
55
  }
56
56
  });
57
57
 
@@ -69,7 +69,6 @@ var import_react_native_theming13 = require("@storybook/react-native-theming");
69
69
  var import_csf2 = require("@storybook/csf");
70
70
  var import_preview_api3 = require("@storybook/preview-api");
71
71
  var import_manager_api3 = require("@storybook/manager-api");
72
- var import_preview_web = require("@storybook/preview-api/dist/preview-web");
73
72
  var import_channels2 = require("@storybook/channels");
74
73
 
75
74
  // src/View.tsx
@@ -1446,7 +1445,7 @@ var Wrapper = ({ panels, addonSelected }) => {
1446
1445
  const addonKeys = Object.keys(panels);
1447
1446
  const content = addonKeys.map((id) => {
1448
1447
  const selected = addonSelected === id;
1449
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Container2, { selected, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native8.ScrollView, { contentContainerStyle: { padding: theme3.panel.paddingHorizontal }, children: panels[id].render({ active: selected, key: id }) }) }, id);
1448
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Container2, { selected, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native8.ScrollView, { contentContainerStyle: { padding: theme3.panel.paddingHorizontal }, children: panels[id].render({ active: selected }) }) }, id);
1450
1449
  });
1451
1450
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: content });
1452
1451
  };
@@ -2049,17 +2048,21 @@ var View10 = class {
2049
2048
  const query = params.query || "";
2050
2049
  const websocketType = params.secured ? "wss" : "ws";
2051
2050
  const url = `${websocketType}://${host}${port}/${query}`;
2052
- return (0, import_channels.createWebSocketChannel)({
2053
- url,
2054
- async: true,
2055
- onError: async () => {
2056
- }
2051
+ const channel = new import_channels.Channel({
2052
+ transport: new import_channels.WebsocketTransport({
2053
+ url,
2054
+ onError: (e) => {
2055
+ console.log(`WebsocketTransport error ${JSON.stringify(e)}`);
2056
+ }
2057
+ }),
2058
+ async: true
2057
2059
  });
2060
+ return channel;
2058
2061
  };
2059
2062
  createPreparedStoryMapping = async () => {
2060
2063
  await Promise.all(
2061
2064
  Object.keys(this._storyIndex.entries).map(async (storyId) => {
2062
- this._idToPrepared[storyId] = await this._preview.storyStore.loadStory({ storyId });
2065
+ this._idToPrepared[storyId] = await this._preview.loadStory({ storyId });
2063
2066
  })
2064
2067
  );
2065
2068
  console.log("Storybook: Finished building story index");
@@ -2074,6 +2077,7 @@ var View10 = class {
2074
2077
  this._storage = storage;
2075
2078
  const initialStory = this._getInitialStory(params);
2076
2079
  if (enableWebsockets) {
2080
+ console.log("websockets enabled");
2077
2081
  const channel = this._getServerChannel(params);
2078
2082
  import_manager_api2.addons.setChannel(channel);
2079
2083
  import_preview_api2.addons.setChannel(channel);
@@ -2089,7 +2093,7 @@ var View10 = class {
2089
2093
  if (!this._ready) {
2090
2094
  throw new Error("Storybook is not ready yet");
2091
2095
  }
2092
- return this._preview.storyStore.getStoryContext(this._idToPrepared[id]);
2096
+ return this._preview.getStoryContext(this._idToPrepared[id]);
2093
2097
  },
2094
2098
  getSelection: () => {
2095
2099
  return this._preview.currentSelection;
@@ -2269,7 +2273,7 @@ function start({
2269
2273
  showStoryDuringRender: () => {
2270
2274
  }
2271
2275
  };
2272
- const urlStore = {
2276
+ const selectionStore = {
2273
2277
  selection: null,
2274
2278
  selectionSpecifier: null,
2275
2279
  setQueryParams: () => {
@@ -2278,13 +2282,6 @@ function start({
2278
2282
  preview.selectionStore.selection = selection;
2279
2283
  }
2280
2284
  };
2281
- const preview = new import_preview_web.PreviewWithSelection(urlStore, previewView);
2282
- const view = new View10(preview, channel);
2283
- if (global) {
2284
- global.__STORYBOOK_ADDONS_CHANNEL__ = channel;
2285
- global.__STORYBOOK_PREVIEW__ = preview;
2286
- global.__STORYBOOK_STORY_STORE__ = preview.storyStore;
2287
- }
2288
2285
  const getProjectAnnotations = async () => (0, import_preview_api3.composeConfigs)([
2289
2286
  {
2290
2287
  renderToCanvas: (context) => {
@@ -2302,11 +2299,18 @@ function start({
2302
2299
  },
2303
2300
  ...annotations
2304
2301
  ]);
2305
- preview.initialize({
2306
- importFn: async (importPath) => importMap[importPath],
2302
+ const preview = new import_preview_api3.PreviewWithSelection(
2303
+ async (importPath) => importMap[importPath],
2307
2304
  getProjectAnnotations,
2308
- getStoryIndex: () => index
2309
- });
2305
+ selectionStore,
2306
+ previewView
2307
+ );
2308
+ const view = new View10(preview, channel);
2309
+ if (global) {
2310
+ global.__STORYBOOK_ADDONS_CHANNEL__ = channel;
2311
+ global.__STORYBOOK_PREVIEW__ = preview;
2312
+ }
2313
+ preview.getStoryIndexFromServer = async () => index;
2310
2314
  view._storyIndex = index;
2311
2315
  return view;
2312
2316
  }
package/dist/preview.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as _storybook_docs_tools from '@storybook/docs-tools';
2
- import { R as Renderer, b as StoryContextForEnhancers, c as Args, d as StrictArgTypes } from './index.d-da6c1de4.js';
2
+ import { R as Renderer, b as StoryContextForEnhancers, A as Args, c as StrictArgTypes } from './index.d-b039fbf0.js';
3
3
  import 'file-system-cache';
4
- import '@babel/core';
5
4
  import 'http';
6
5
 
7
6
  declare const _default: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "7.6.11",
3
+ "version": "8.0.0-alpha.0",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -51,19 +51,17 @@
51
51
  "preset": "react-native"
52
52
  },
53
53
  "dependencies": {
54
- "@storybook/channels": "^7.6.10",
55
- "@storybook/client-logger": "^7.6.10",
56
- "@storybook/core-client": "^7.6.10",
57
- "@storybook/core-common": "^7.6.10",
58
- "@storybook/core-events": "^7.6.10",
54
+ "@storybook/channels": "8.0.0-alpha.15",
55
+ "@storybook/client-logger": "8.0.0-alpha.15",
56
+ "@storybook/core-common": "8.0.0-alpha.15",
57
+ "@storybook/core-events": "8.0.0-alpha.15",
59
58
  "@storybook/csf": "^0.1.1",
60
- "@storybook/docs-tools": "^7.6.10",
59
+ "@storybook/docs-tools": "8.0.0-alpha.15",
61
60
  "@storybook/global": "^5.0.0",
62
- "@storybook/manager-api": "^7.6.10",
63
- "@storybook/preview-api": "^7.6.10",
64
- "@storybook/preview-web": "^7.6.10",
65
- "@storybook/react": "^7.6.10",
66
- "@storybook/react-native-theming": "^7.6.11",
61
+ "@storybook/manager-api": "8.0.0-alpha.15",
62
+ "@storybook/preview-api": "8.0.0-alpha.15",
63
+ "@storybook/react": "8.0.0-alpha.15",
64
+ "@storybook/react-native-theming": "^8.0.0-alpha.0",
67
65
  "chokidar": "^3.5.1",
68
66
  "commander": "^8.2.0",
69
67
  "dedent": "^1.5.1",
@@ -75,7 +73,7 @@
75
73
  "util": "^0.12.4"
76
74
  },
77
75
  "devDependencies": {
78
- "@storybook/types": "^7.6.10",
76
+ "@storybook/types": "8.0.0-alpha.15",
79
77
  "@types/jest": "^29.4.3",
80
78
  "@types/react": "~18.2.14",
81
79
  "babel-jest": "^29.4.3",
@@ -97,5 +95,5 @@
97
95
  "publishConfig": {
98
96
  "access": "public"
99
97
  },
100
- "gitHead": "5aed8e2d2ddc4fe76dd5f883aeb35e3fb48cae87"
98
+ "gitHead": "14ffe40751c45e03046117bec794fb4e34c56418"
101
99
  }
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({
@@ -277,6 +279,11 @@ You can pass these parameters to getStorybookUI call in your storybook entry poi
277
279
  -- Disable KeyboardAvoidingView wrapping Storybook's view
278
280
  keyboardAvoidingViewVerticalOffset: Number (0)
279
281
  -- With shouldDisableKeyboardAvoidingView=true, this will set the keyboardverticaloffset (https://facebook.github.io/react-native/docs/keyboardavoidingview#keyboardverticaloffset) value for KeyboardAvoidingView wrapping Storybook's view
282
+ storage: Object (undefined)
283
+ -- {getItem: (key: string) => Promise<string | null>;setItem: (key: string, value: string) => Promise<void>;}
284
+ -- Custom storage to be used instead of AsyncStorage
285
+ shouldPersistSelection: Boolean (true)
286
+ -- Stores last selected story in your devices storage.
280
287
  }
281
288
  ```
282
289
 
@@ -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}",
package/V6.js DELETED
@@ -1 +0,0 @@
1
- export * from './dist/V6';
package/dist/V6.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { P as Params } from './View-bd441663.js';
3
- import { ClientApi } from '@storybook/preview-api';
4
- import { L as LoaderFunction, A as Addon_StoryApi } from './index.d-da6c1de4.js';
5
- import { ReactNode } from 'react';
6
- import { ReactRenderer } from '@storybook/react';
7
- export { Theme, darkTheme, theme } from '@storybook/react-native-theming';
8
- import '@storybook/csf';
9
- import '@storybook/preview-web';
10
- import '@storybook/channels';
11
- import 'file-system-cache';
12
- import '@babel/core';
13
- import 'http';
14
-
15
- interface RequireContext {
16
- keys: () => string[];
17
- (id: string): any;
18
- resolve(id: string): string;
19
- }
20
- type Loadable = RequireContext | RequireContext[] | LoaderFunction;
21
-
22
- declare const configure: (loadable: any, m: {
23
- hot?: {
24
- accept?: () => void;
25
- };
26
- }) => void;
27
-
28
- type C = ClientApi<ReactRenderer>;
29
- declare const addDecorator: C['addDecorator'];
30
- declare const addParameters: C['addParameters'];
31
- declare const addArgsEnhancer: C['addArgsEnhancer'];
32
- declare const addArgTypesEnhancer: C['addArgTypesEnhancer'];
33
- declare const raw: C['raw'];
34
- declare const storiesOf: (kind: string, m: any) => Addon_StoryApi<ReactNode>;
35
- declare const getStorybookUI: (params?: Partial<Params>) => () => react_jsx_runtime.JSX.Element;
36
-
37
- export { Loadable, RequireContext, addArgTypesEnhancer, addArgsEnhancer, addDecorator, addParameters, configure, getStorybookUI, raw, storiesOf };