From c431ff6dbc7fb3e5bd411e26c5fd0c47412f5e16 Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Sat, 22 May 2021 12:55:55 +0100 Subject: [PATCH] feat: some improvements to using facing api --- app/react-native/loader.js | 2 +- app/react-native/src/preview/Preview.tsx | 12 ++++-------- examples/native/Storybook.tsx | 5 ++++- examples/native/ios/Podfile.lock | 3 +++ examples/native/package.json | 1 + yarn.lock | 14 ++++++++++++++ 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app/react-native/loader.js b/app/react-native/loader.js index 6029826fd5..c83929d8da 100644 --- a/app/react-native/loader.js +++ b/app/react-native/loader.js @@ -48,7 +48,7 @@ const paths = ${path_array_str} const getCSFStories=() => { return paths.filter((exports) => !!exports.default?.title); } -configure("react-native", getCSFStories, module, true) +configure(getCSFStories, module, false) `; diff --git a/app/react-native/src/preview/Preview.tsx b/app/react-native/src/preview/Preview.tsx index df97d257d6..6e64a218cc 100644 --- a/app/react-native/src/preview/Preview.tsx +++ b/app/react-native/src/preview/Preview.tsx @@ -2,8 +2,8 @@ import { addons } from '@storybook/addons'; import Channel from '@storybook/channels'; import { ClientApi, ConfigApi, StoryStore } from '@storybook/client-api'; -import { loadCsf } from '@storybook/core-client/dist/modern/preview/loadCsf'; import { Loadable } from '@storybook/core-client'; +import { loadCsf } from '@storybook/core-client/dist/modern/preview/loadCsf'; import Events from '@storybook/core-events'; import { ThemeProvider } from 'emotion-theming'; import React from 'react'; @@ -51,12 +51,7 @@ export default class Preview { _configApi: ConfigApi; - configure: ( - framework: string, - loadable: Loadable, - m: NodeModule, - showDeprecationWarning: boolean - ) => void; + configure: (loadable: Loadable, m: NodeModule, showDeprecationWarning: boolean) => void; constructor() { const channel = new Channel({ async: true }); @@ -65,11 +60,12 @@ export default class Preview { this._clientApi = new ClientApi({ storyStore: this._storyStore }); this._configApi = new ConfigApi({ storyStore: this._storyStore }); this._channel = channel; - this.configure = loadCsf({ + const configure = loadCsf({ clientApi: this._clientApi, storyStore: this._storyStore, configApi: this._configApi, }); + this.configure = (...args) => configure('react-native', ...args); addons.setChannel(channel); } diff --git a/examples/native/Storybook.tsx b/examples/native/Storybook.tsx index 92e6fe8c0f..e364b61f75 100644 --- a/examples/native/Storybook.tsx +++ b/examples/native/Storybook.tsx @@ -1,8 +1,11 @@ // @ts-ignore +import AsyncStorage from '@react-native-async-storage/async-storage'; import { getStorybookUI } from '@storybook/react-native'; + import './storybook.requires'; + const StorybookUIRoot = getStorybookUI({ - asyncStorage: null, + asyncStorage: AsyncStorage, }); export default StorybookUIRoot; diff --git a/examples/native/ios/Podfile.lock b/examples/native/ios/Podfile.lock index d8124eaed8..22d9e22fd9 100644 --- a/examples/native/ios/Podfile.lock +++ b/examples/native/ios/Podfile.lock @@ -371,6 +371,7 @@ DEPENDENCIES: - React-RCTVibration (from `../../../node_modules/react-native/Libraries/Vibration`) - React-runtimeexecutor (from `../../../node_modules/react-native/ReactCommon/runtimeexecutor`) - ReactCommon/turbomodule/core (from `../../../node_modules/react-native/ReactCommon`) + - "RNCAsyncStorage (from `../../../node_modules/@react-native-async-storage/async-storage`)" - Yoga (from `../../../node_modules/react-native/ReactCommon/yoga`) SPEC REPOS: @@ -443,6 +444,8 @@ EXTERNAL SOURCES: :path: "../../../node_modules/react-native/ReactCommon/runtimeexecutor" ReactCommon: :path: "../../../node_modules/react-native/ReactCommon" + RNCAsyncStorage: + :path: "../../../node_modules/@react-native-async-storage/async-storage" Yoga: :path: "../../../node_modules/react-native/ReactCommon/yoga" diff --git a/examples/native/package.json b/examples/native/package.json index e475a495a9..dbd543db3c 100644 --- a/examples/native/package.json +++ b/examples/native/package.json @@ -27,6 +27,7 @@ "preset": "react-native" }, "dependencies": { + "@react-native-async-storage/async-storage": "^1.15.4", "@storybook/addon-actions": "6.3.0-alpha.33", "@storybook/addon-links": "6.3.0-alpha.33", "@storybook/addons": "6.3.0-alpha.33", diff --git a/yarn.lock b/yarn.lock index 40d250ed24..fff05388e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3928,6 +3928,13 @@ prop-types "^15.6.1" react-lifecycles-compat "^3.0.4" +"@react-native-async-storage/async-storage@^1.15.4": + version "1.15.4" + resolved "https://registry.yarnpkg.com/@react-native-async-storage/async-storage/-/async-storage-1.15.4.tgz#cdba464ca3bb9f10ec538342cbf2520c06f453ab" + integrity sha512-pC0MS6UBuv/YiVAxtzi7CgUed8oCQNYMtGt0yb/I9fI/BWTiJK5cj4YtW2XtL95K5IuvPX/6uGWaouZ8KqXwdg== + dependencies: + deep-assign "^3.0.0" + "@react-native-community/cli-debugger-ui@^5.0.1-alpha.1": version "5.0.1-alpha.1" resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-5.0.1-alpha.1.tgz#09a856ccd2954cf16eea59b14dd26ae66720e4e6" @@ -8765,6 +8772,13 @@ dedent@^0.7.0: resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" integrity sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw= +deep-assign@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/deep-assign/-/deep-assign-3.0.0.tgz#c8e4c4d401cba25550a2f0f486a2e75bc5f219a2" + integrity sha512-YX2i9XjJ7h5q/aQ/IM9PEwEnDqETAIYbggmdDB3HLTlSgo1CxPsj6pvhPG68rq6SVE0+p+6Ywsm5fTYNrYtBWw== + dependencies: + is-obj "^1.0.0" + deep-equal-ident@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/deep-equal-ident/-/deep-equal-ident-1.1.1.tgz#06f4b89e53710cd6cea4a7781c7a956642de8dc9"