@storybook/react-native 8.2.0-alpha.1 → 8.3.0-alpha.1

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
@@ -81,7 +81,7 @@ declare function prepareStories({ storyEntries, options, }: {
81
81
  index: StoryIndex;
82
82
  importMap: Record<string, any>;
83
83
  };
84
- declare const getProjectAnnotations: (view: View, annotations: any[]) => () => Promise<_storybook_core_types.ProjectAnnotations<ReactRenderer>>;
84
+ declare const getProjectAnnotations: (view: View, annotations: any[]) => () => Promise<_storybook_core_types.NormalizedProjectAnnotations<ReactRenderer>>;
85
85
  declare function start({ annotations, storyEntries, options, }: {
86
86
  storyEntries: Array<NormalizedStoriesSpecifier & {
87
87
  req: any;
package/dist/index.js CHANGED
@@ -782,16 +782,19 @@ function dismissOnStartResponder() {
782
782
  import_react_native2.Keyboard.dismiss();
783
783
  return false;
784
784
  }
785
+ var Text2 = import_react_native_theming.styled.Text(({ theme: theme3 }) => ({
786
+ color: theme3?.color?.defaultText
787
+ }));
785
788
  var StoryView = () => {
786
789
  const context = useStoryContext();
787
790
  const id = context?.id;
788
- const { backgroundColor } = (0, import_react_native_theming.useTheme)();
791
+ const theme3 = (0, import_react_native_theming.useTheme)();
789
792
  if (context && context.unboundStoryFn) {
790
793
  const { unboundStoryFn: StoryComponent } = context;
791
794
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
792
795
  import_react_native2.View,
793
796
  {
794
- style: { flex: 1, backgroundColor },
797
+ style: { flex: 1, backgroundColor: theme3.background?.content },
795
798
  testID: id,
796
799
  onStartShouldSetResponder: dismissOnStartResponder,
797
800
  children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -807,7 +810,7 @@ var StoryView = () => {
807
810
  id
808
811
  );
809
812
  }
810
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, { style: { flex: 1, padding: 16, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { children: "Please open the sidebar and select a story to preview." }) });
813
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, { style: { flex: 1, padding: 16, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text2, { children: "Please open the sidebar and select a story to preview." }) });
811
814
  };
812
815
  var StoryView_default = import_react3.default.memo(StoryView);
813
816
 
@@ -924,10 +927,12 @@ var View3 = class {
924
927
  return channel;
925
928
  };
926
929
  createPreparedStoryMapping = async () => {
927
- await Promise.all(
928
- Object.keys(this._storyIndex.entries).map(async (storyId) => {
929
- this._idToPrepared[storyId] = await this._preview.loadStory({ storyId });
930
- })
930
+ await this._preview.ready().then(
931
+ () => Promise.all(
932
+ Object.keys(this._storyIndex.entries).map(async (storyId) => {
933
+ this._idToPrepared[storyId] = await this._preview.loadStory({ storyId });
934
+ })
935
+ )
931
936
  );
932
937
  };
933
938
  getStorybookUI = (params = {}) => {
@@ -948,7 +953,7 @@ var View3 = class {
948
953
  this._preview.channel = channel;
949
954
  this._preview.setupListeners();
950
955
  channel.emit(import_core_events.default.CHANNEL_CREATED);
951
- this._preview.initializeWithStoryIndex(this._storyIndex);
956
+ this._preview.ready().then(() => this._preview.onStoryIndexChanged());
952
957
  }
953
958
  import_manager_api.addons.loadAddons({
954
959
  store: () => ({
@@ -1042,6 +1047,10 @@ var View3 = class {
1042
1047
 
1043
1048
  // src/Start.tsx
1044
1049
  var import_jsx_runtime4 = require("react/jsx-runtime");
1050
+ if (!URLSearchParams.get) {
1051
+ const { setupURLPolyfill } = require("react-native-url-polyfill");
1052
+ setupURLPolyfill();
1053
+ }
1045
1054
  function prepareStories({
1046
1055
  storyEntries,
1047
1056
  options
@@ -1,14 +1,39 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
3
  const { generate } = require('../scripts/generate');
4
+ const { WebSocketServer } = require('ws');
4
5
 
5
6
  let alreadyReplaced = false;
6
7
 
7
- module.exports = (config, { configPath, enabled }) => {
8
+ module.exports = (config, { configPath, enabled, websockets }) => {
8
9
  if (!enabled) {
9
10
  return config;
10
11
  }
11
12
 
13
+ if (websockets) {
14
+ const port = websockets.port ?? 7007;
15
+
16
+ const host = websockets.host ?? 'localhost';
17
+
18
+ const wss = new WebSocketServer({ port, host });
19
+
20
+ wss.on('connection', function connection(ws) {
21
+ console.log('websocket connection established');
22
+
23
+ ws.on('error', console.error);
24
+
25
+ ws.on('message', function message(data) {
26
+ try {
27
+ const json = JSON.parse(data.toString());
28
+
29
+ wss.clients.forEach((wsClient) => wsClient.send(JSON.stringify(json)));
30
+ } catch (error) {
31
+ console.error(error);
32
+ }
33
+ });
34
+ });
35
+ }
36
+
12
37
  generate({
13
38
  configPath: configPath ?? path.resolve(process.cwd(), './.storybook'),
14
39
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "8.2.0-alpha.1",
3
+ "version": "8.3.0-alpha.1",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -39,12 +39,12 @@
39
39
  "test:ci": "jest"
40
40
  },
41
41
  "dependencies": {
42
- "@storybook/core": "^8.2.2",
42
+ "@storybook/core": "^8.3.0",
43
43
  "@storybook/csf": "^0.1.1",
44
44
  "@storybook/global": "^5.0.0",
45
- "@storybook/react": "^8.2.2",
46
- "@storybook/react-native-theming": "^8.2.0-alpha.1",
47
- "@storybook/react-native-ui": "^8.2.0-alpha.1",
45
+ "@storybook/react": "^8.3.0",
46
+ "@storybook/react-native-theming": "^8.3.0-alpha.1",
47
+ "@storybook/react-native-ui": "^8.3.0-alpha.1",
48
48
  "chokidar": "^3.5.1",
49
49
  "commander": "^8.2.0",
50
50
  "dedent": "^1.5.1",
@@ -52,8 +52,10 @@
52
52
  "glob": "^7.1.7",
53
53
  "prettier": "^2.4.1",
54
54
  "react-native-swipe-gestures": "^1.0.5",
55
+ "react-native-url-polyfill": "^2.0.0",
55
56
  "type-fest": "~2.19",
56
- "util": "^0.12.4"
57
+ "util": "^0.12.4",
58
+ "ws": "^8.18.0"
57
59
  },
58
60
  "devDependencies": {
59
61
  "@types/jest": "^29.4.3",
@@ -78,5 +80,5 @@
78
80
  "publishConfig": {
79
81
  "access": "public"
80
82
  },
81
- "gitHead": "361474c61185642c3e041d6a1d35b935a8725b7b"
83
+ "gitHead": "44d795b125a02dc9f669187d37d6b5f348bb2ea8"
82
84
  }