@storybook/react-native 7.6.10-alpha.1 → 7.6.10-alpha.4

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.d.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { P as Params } from './View-3a0f8584.js';
2
+ import { P as Params } from './View-bd441663.js';
3
3
  import { ClientApi } from '@storybook/preview-api';
4
- import { L as LoaderFunction, A as Addon_StoryApi } from './index.d-cff8c6fa.js';
4
+ import { L as LoaderFunction, A as Addon_StoryApi } from './index.d-da6c1de4.js';
5
5
  import { ReactNode } from 'react';
6
6
  import { ReactRenderer } from '@storybook/react';
7
7
  export { Theme, darkTheme, theme } from '@storybook/react-native-theming';
8
8
  import '@storybook/csf';
9
9
  import '@storybook/preview-web';
10
10
  import '@storybook/channels';
11
+ import 'file-system-cache';
12
+ import '@babel/core';
13
+ import 'http';
11
14
 
12
15
  interface RequireContext {
13
16
  keys: () => string[];
package/dist/V6.js CHANGED
@@ -2014,6 +2014,7 @@ var View10 = class {
2014
2014
  _webUrl;
2015
2015
  _storage;
2016
2016
  _channel;
2017
+ _idToPrepared = {};
2017
2018
  constructor(preview, channel) {
2018
2019
  this._preview = preview;
2019
2020
  this._channel = channel;
@@ -2062,6 +2063,14 @@ var View10 = class {
2062
2063
  }
2063
2064
  });
2064
2065
  };
2066
+ createPreparedStoryMapping = async () => {
2067
+ await Promise.all(
2068
+ Object.keys(this._storyIndex.entries).map(async (storyId) => {
2069
+ this._idToPrepared[storyId] = await this._preview.storyStore.loadStory({ storyId });
2070
+ })
2071
+ );
2072
+ console.log("Storybook: Finished building story index");
2073
+ };
2065
2074
  getStorybookUI = (params = {}) => {
2066
2075
  const {
2067
2076
  shouldPersistSelection = true,
@@ -2072,7 +2081,6 @@ var View10 = class {
2072
2081
  this._storage = storage;
2073
2082
  const initialStory = this._getInitialStory(params);
2074
2083
  if (enableWebsockets) {
2075
- console.log("websockets enabled");
2076
2084
  const channel = this._getServerChannel(params);
2077
2085
  import_manager_api2.addons.setChannel(channel);
2078
2086
  import_preview_api2.addons.setChannel(channel);
@@ -2084,13 +2092,15 @@ var View10 = class {
2084
2092
  }
2085
2093
  import_manager_api2.addons.loadAddons({
2086
2094
  store: () => ({
2087
- fromId: (id) => this._preview.storyStore.getStoryContext(this._preview.storyStore.fromId(id)),
2095
+ fromId: (id) => {
2096
+ if (!this._ready) {
2097
+ throw new Error("Storybook is not ready yet");
2098
+ }
2099
+ return this._preview.storyStore.getStoryContext(this._idToPrepared[id]);
2100
+ },
2088
2101
  getSelection: () => {
2089
2102
  return this._preview.currentSelection;
2090
2103
  },
2091
- // @ts-ignore :) FIXME
2092
- // _channel: this._preview.channel,
2093
- // global.__STORYBOOK_ADDONS_CHANNEL__,
2094
2104
  _channel: this._channel
2095
2105
  })
2096
2106
  });
@@ -2103,11 +2113,16 @@ var View10 = class {
2103
2113
  const setContext = useSetStoryContext();
2104
2114
  const colorScheme = (0, import_react_native16.useColorScheme)();
2105
2115
  const [, forceUpdate] = (0, import_react16.useReducer)((x) => x + 1, 0);
2116
+ const [ready, setReady] = (0, import_react16.useState)(false);
2106
2117
  const appliedTheme = (0, import_react16.useMemo)(
2107
2118
  () => (0, import_deepmerge.default)(colorScheme === "dark" ? import_react_native_theming12.darkTheme : import_react_native_theming12.theme, params.theme ?? {}),
2108
2119
  [colorScheme]
2109
2120
  );
2110
2121
  (0, import_react16.useEffect)(() => {
2122
+ this.createPreparedStoryMapping().then(() => {
2123
+ this._ready = true;
2124
+ setReady(true);
2125
+ }).catch((e) => console.error(e));
2111
2126
  self._setStory = (newStory) => {
2112
2127
  setContext(newStory);
2113
2128
  if (shouldPersistSelection && !storage) {
@@ -2132,6 +2147,19 @@ var View10 = class {
2132
2147
  self._preview.selectSpecifiedStory();
2133
2148
  });
2134
2149
  }, []);
2150
+ if (!ready) {
2151
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2152
+ import_react_native16.View,
2153
+ {
2154
+ style: {
2155
+ ...import_react_native16.StyleSheet.absoluteFillObject,
2156
+ alignItems: "center",
2157
+ justifyContent: "center"
2158
+ },
2159
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native16.ActivityIndicator, { animating: true, size: "large" })
2160
+ }
2161
+ );
2162
+ }
2135
2163
  if (onDeviceUI) {
2136
2164
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native_safe_area_context3.SafeAreaProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native_theming12.ThemeProvider, { theme: appliedTheme, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2137
2165
  OnDeviceUI_default,
@@ -3,7 +3,7 @@ import { StoryContext } from '@storybook/csf';
3
3
  import { PreviewWithSelection } from '@storybook/preview-web';
4
4
  import { ReactRenderer } from '@storybook/react';
5
5
  import { Theme } from '@storybook/react-native-theming';
6
- import { S as StoryIndex } from './index.d-cff8c6fa.js';
6
+ import { a as StoryIndex, P as PreparedStory } from './index.d-da6c1de4.js';
7
7
  import { Channel } from '@storybook/channels';
8
8
 
9
9
  interface Storage {
@@ -52,12 +52,14 @@ declare class View {
52
52
  _webUrl: string;
53
53
  _storage: Storage;
54
54
  _channel: Channel;
55
+ _idToPrepared: Record<string, PreparedStory<ReactRenderer>>;
55
56
  constructor(preview: PreviewWithSelection<ReactRenderer>, channel: Channel);
56
57
  _getInitialStory: ({ initialSelection, shouldPersistSelection, }?: Partial<Params>) => Promise<{
57
58
  storySpecifier: string;
58
59
  viewMode: string;
59
60
  }>;
60
61
  _getServerChannel: (params?: Partial<Params>) => Channel;
62
+ createPreparedStoryMapping: () => Promise<void>;
61
63
  getStorybookUI: (params?: Partial<Params>) => () => react_jsx_runtime.JSX.Element;
62
64
  }
63
65