Skip to content

Commit b2ee3ef

Browse files
authored
web-platform support (#85)
* web-platform support * fix linting * platform-specific wrapper around WebView * react-native-web-webview peerDep * WebView is NOT default export
1 parent cb660a7 commit b2ee3ef

File tree

8 files changed

+1642
-18
lines changed

8 files changed

+1642
-18
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
2-
.vscode
2+
.vscode
3+
.idea
4+
dist

babel.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = function (api) {
2+
api.cache(true);
3+
return {
4+
presets: ['module:metro-react-native-babel-preset'],
5+
};
6+
};

package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
"name": "react-native-youtube-iframe",
33
"version": "1.4.0",
44
"description": "A simple wrapper around the youtube iframe js API for react native",
5-
"main": "index.js",
5+
"main": "dist/index.js",
6+
"types": "index.d.ts",
67
"scripts": {
7-
"lint": "eslint index.js src",
8-
"test": "echo \"Error: no test specified\" && exit 1"
8+
"lint": "eslint src",
9+
"test": "echo \"Error: no test specified\" && exit 1",
10+
"build": "rm -rf dist && babel src --out-dir dist",
11+
"prepare": "yarn build"
912
},
1013
"repository": {
1114
"type": "git",
@@ -34,11 +37,15 @@
3437
"peerDependencies": {
3538
"react": ">=16.8.6",
3639
"react-native": ">=0.60",
37-
"react-native-webview": ">=7.0.0"
40+
"react-native-webview": ">=7.0.0",
41+
"react-native-web-webview": ">=1.0.2"
3842
},
3943
"devDependencies": {
44+
"@babel/cli": "^7.2.3",
45+
"@babel/core": "^7.2.2",
4046
"@react-native-community/eslint-config": "^2.0.0",
41-
"eslint": "^7.7.0"
47+
"eslint": "^7.7.0",
48+
"metro-react-native-babel-preset": "^0.64.0"
4249
},
4350
"dependencies": {
4451
"events": "^3.2.0"

src/WebView.native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {WebView} from 'react-native-webview';

src/WebView.web.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {WebView} from 'react-native-web-webview';

src/YoutubeIframe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import React, {
77
useImperativeHandle,
88
} from 'react';
99
import {View, StyleSheet, Platform} from 'react-native';
10-
import WebView from 'react-native-webview';
10+
import {WebView} from './WebView';
1111
import {PLAYER_STATES, PLAYER_ERROR, CUSTOM_USER_AGENT} from './constants';
1212
import {EventEmitter} from 'events';
1313
import {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import YoutubeIframe from './src/YoutubeIframe';
2-
import {getYoutubeMeta} from './src/oEmbed';
1+
import YoutubeIframe from './YoutubeIframe';
2+
import {getYoutubeMeta} from './oEmbed';
33
import {
44
PLAYER_STATES_NAMES as PLAYER_STATES,
55
PLAYER_ERROR_NAMES as PLAYER_ERRORS,
6-
} from './src/constants';
6+
} from './constants';
77

88
export default YoutubeIframe;
99
export {getYoutubeMeta, PLAYER_STATES, PLAYER_ERRORS};

yarn.lock

Lines changed: 1615 additions & 8 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)