react-cosmos-native 6.0.0-alpha.0 → 6.0.0-alpha.12
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.
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { FixtureId,
|
|
1
|
+
import { FixtureId, RendererConfig, UserModuleWrappers } from 'react-cosmos-core';
|
|
2
2
|
type Props = {
|
|
3
3
|
rendererConfig: RendererConfig;
|
|
4
|
-
|
|
5
|
-
decorators: ReactDecorators;
|
|
4
|
+
moduleWrappers: UserModuleWrappers;
|
|
6
5
|
initialFixtureId?: FixtureId;
|
|
7
6
|
};
|
|
8
|
-
export declare function NativeFixtureLoader({ rendererConfig: { playgroundUrl },
|
|
7
|
+
export declare function NativeFixtureLoader({ rendererConfig: { playgroundUrl }, moduleWrappers, initialFixtureId, }: Props): JSX.Element;
|
|
9
8
|
export {};
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { createWebSocketsConnect,
|
|
2
|
+
import { createWebSocketsConnect, FixtureConnect, } from 'react-cosmos-core';
|
|
3
3
|
import * as ReactNative from 'react-native';
|
|
4
|
-
|
|
4
|
+
import { getSocketUrl } from './getSocketUrl.js';
|
|
5
|
+
const { View, Text, StyleSheet } = ReactNative;
|
|
5
6
|
// TODO: Generate unique ID per device
|
|
6
7
|
const rendererId = 'native-renderer';
|
|
7
|
-
export function NativeFixtureLoader({ rendererConfig: { playgroundUrl },
|
|
8
|
+
export function NativeFixtureLoader({ rendererConfig: { playgroundUrl }, moduleWrappers, initialFixtureId, }) {
|
|
8
9
|
const socketUrl = getSocketUrl(playgroundUrl);
|
|
9
|
-
return (React.createElement(
|
|
10
|
+
return (React.createElement(FixtureConnect, { rendererId: rendererId, rendererConnect: createWebSocketsConnect(socketUrl), moduleWrappers: moduleWrappers, systemDecorators: [], initialFixtureId: initialFixtureId, renderMessage: renderMessage }));
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
const { hostname } = new URL(NativeModules.SourceCode.scriptURL);
|
|
13
|
-
const { port } = new URL(playgroundUrl);
|
|
14
|
-
return `ws://${hostname}:${port}`;
|
|
15
|
-
}
|
|
16
|
-
function renderMessage({ msg }) {
|
|
12
|
+
function renderMessage(msg) {
|
|
17
13
|
return (React.createElement(View, { style: styles.container },
|
|
18
14
|
React.createElement(Text, null, msg)));
|
|
19
15
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getSocketUrl(playgroundUrl: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as ReactNative from 'react-native';
|
|
2
|
+
const { NativeModules } = ReactNative;
|
|
3
|
+
export function getSocketUrl(playgroundUrl) {
|
|
4
|
+
// The URL module isn't implemented fully in React Native and I don't want to
|
|
5
|
+
// bring in another dependency just for this.
|
|
6
|
+
const scriptURL = NativeModules.SourceCode.scriptURL;
|
|
7
|
+
const [, hostname] = scriptURL.match(/:\/\/(.+?)(:|\/)/);
|
|
8
|
+
const portMatch = playgroundUrl.match(/:(\d+)(\/|$)/);
|
|
9
|
+
const port = portMatch ? portMatch[1] : '80';
|
|
10
|
+
return `ws://${hostname}:${port}`;
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cosmos-native",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.12",
|
|
4
4
|
"description": "React Cosmos Native",
|
|
5
5
|
"repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos-native",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/index.js",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"react-cosmos-core": "^6.0.0-alpha.
|
|
10
|
+
"react-cosmos-core": "^6.0.0-alpha.12"
|
|
11
11
|
},
|
|
12
|
-
"gitHead": "
|
|
12
|
+
"gitHead": "5987f899563ec2ddae727d4d57431a0400c49161"
|
|
13
13
|
}
|