diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 0000000..3e5e786 --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,24 @@ +{ + "files": [ + "README.md" + ], + "imageSize": 100, + "commit": false, + "contributors": [ + { + "login": "Marcoo09", + "name": "Marco Fiorito", + "avatar_url": "https://avatars.githubusercontent.com/Marcoo09", + "profile": "https://github.com/Marcoo09", + "contributions": [ + "code", + ] + }, + ], + "contributorsPerLine": 7, + "projectName": "react-native-vimeo-player", + "projectOwner": "Marcoo09", + "repoType": "github", + "repoHost": "https://github.com", + "skipCi": true +} \ No newline at end of file diff --git a/LICENSE b/LICENSE index 96e1eeb..6d2d283 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Alex Demchenko +Copyright (c) 2021 Marco Fiorito Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 23514d0..99837e7 100644 --- a/README.md +++ b/README.md @@ -1,138 +1,55 @@ -# React Native Module Template +# React Native Vimeo Player -A starter for the React Native library written in TypeScript, with linked example project and optional native code written in Swift and Kotlin. This project aims to support the latest React Native versions and keep best practices in mind. +React Native Vimeo Player is a library to render Vimeo videos in a React Native app. +This component allows you to embed a Vimeo video in your app and have full access to +the Vimeo player JS API (more information https://developer.vimeo.com/player/js-api). -## Alternatives +## Installation -[create-react-native-module](https://github.com/brodybits/create-react-native-module) +1. Go through the instructions for installing the + `React Native Webview` library: https://github.com/react-native-webview/react-native-webview. -### Why this template? +1. Run `npm install react-native-vimeo-player` or `yarn add react-native-vimeo-player` within your project. -First of all, it has TypeScript set up and ready. Also, if you will use a native code, this template uses Swift and Kotlin, which is much better than Objective-C and Java. - -The example project is linked in a way so that you can work on your library and see the results of your work immediately. If you use native code you can see linked libraries in the example project opened in Xcode or Android Studio and can modify the code directly from there, just remember to rebuild the example to see the changes. When you change TypeScript code you need to compile it first (using `yarn` command, it has `prepare` hook set up) since with npm you are supplying `lib` folder with JavaScript and type definitions, but there is an [option](#how-to-see-my-changes-immediately-in-the-example) to point example to the `src` folder instead, so that when you modify your library you see changes immediately in the example thanks to [Fast Refresh](https://facebook.github.io/react-native/docs/fast-refresh). +1. Compile and build to make sure everything is set up properly. ## Usage -Clone this repo, rename the `react-native-module-template` folder to your library name, navigate to that folder and run - -``` -node rename.js -``` - -or if you want to **remove native code** - -``` -node rename.js js-only -``` - -This will invoke rename script, which removes all references to the template and makes some cleanup. - -⚠️⚠️⚠️ This script is not made to be bulletproof, some assumptions are made: - -- The script will ask for different information (such as library name, author name, author email etc.) and there might be instructions in the parenthesis, please follow them or something will likely **fail**. -- Use `kebab-case` for the library name, _preferably_ with `react-native` prefix (e.g. `react-native-blue-button`, blue-button, button). -- Use `PascalCase` for the library short name (in case you will have native code, with `js-only` argument script will not ask for this), it is used in native projects (RNModuleTemplate.xcodeproj, RNModuleTemplatePackage.kt etc.). If you prefixed your library name with `react-native` use prefix `RN` for the short name (e.g. `RNBlueButton`, BlueButton, Button). -- Library homepage is used only in `package.json`, if you are not sure, you can press enter to skip this step and modify this field later. Library git url is used only in `.podspec` file, same as above (note that this file will be removed if you pass `js-only` argument). -- Please don't use any special characters in author name since it is a part of Android package name, (e.g. `com.alexdemchenko.reactnativemoduletemplate`) and used in Kotlin and other files. Android package name is generated from author name (with removed spaces and lowercased) and library name (with removed dashes). - -Don't forget to remove the rename script, do `yarn` to install dependencies in root and example folders, and, if you kept native code, do `pod install` in `example/ios`. - -If you didn't use `js-only` you are good to go. If you did, you need to unlink native code from the example - -### iOS - -Open Xcode, in the project navigator find `Libraries` folder, reveal contents using the small arrow and hit `DELETE` on `RNModuleTemplate.xcodeproj`. Alternatively, open `example/ios/example.xcodeproj/project.pbxproj`, search for the `Template` (there should be a number of `libRNModuleTemplate.a` and `RNModuleTemplate.xcodeproj` files) and remove all references to them. Please remove whole lines if it among files with other names or whole sections if it is the only item. Groups, like `Library` or `Products`, must stay, just remove the template from appropriate children field. - -### Android - -In `example/android/settings.gradle` remove - -```gradle -include ':react-native-module-template' -project(':react-native-module-template').projectDir = new File(rootProject.projectDir, '../../android') -``` - -In `example/android/app/build.gradle` remove - -```gradle -implementation project(':react-native-module-template') -``` - -In `example/android/app/src/main/java/com/example/MainApplication.kt` remove - -```kotlin -import com.alexdemchenko.reactnativemoduletemplate.RNModuleTemplatePackage - -packages.add(RNModuleTemplatePackage()) -``` - -## How example project is linked - -The native part is manually linked (you can see changes for Android right above), for iOS check [official docs](https://facebook.github.io/react-native/docs/linking-libraries-ios#manual-linking), but **Header Search Paths** are pointing to the `ios` folder, `$(SRCROOT)/../../ios`, not node_modules. - -JavaScript part is using Metro Bundler configuration, see [this article](https://callstack.com/blog/adding-an-example-app-to-your-react-native-library/) for more details and final configuration [here](example/metro.config.js). - -In the example's [tsconfig.json](example/tsconfig.json) custom path is specified, so you can import your code the same way end user will do. - -```json -"paths": { - "react-native-module-template": ["../src"] -}, -``` - -### How to see my changes immediately in the example - -In the library's `package.json` change - -```json -"main": "lib/index.js", -``` - -to - -```json -"main": "src/index.tsx", // or `index.ts` if you don't have JSX there -``` - -restart the bundler if you have it running - ``` -yarn start + console.log('Video is ready')} + onPlay={() => console.log('Video is playing')} + onPlayProgress={(data) => console.log('Video progress data:', data)} + onFinish={() => console.log('Video is finished')} + loop={false} + autoPlay={false} + controls={true} + speed={false} + /> ``` -⚠️⚠️⚠️ Don't forget to change this back before making a release, since with npm you supply `lib` folder, not `src`. Let me know if there is a way to do this automatically. +## How it works -## Release +Internally, a webview loads a HTML page. This HTML page loads your +Vimeo video in an iFrame, then uses the Froogaloop JS library provided by Vimeo to pass event +information to your application. -Create an npm account [here](https://www.npmjs.com/signup) if you don't have one. Then do +## Example -``` -npm login -``` +If you want to see `MetaLabs-inc/react-native-vimeo-player` in action, just move into the [example](/example) folder and run `yarn && cd ios && pod install && cd .. && yarn ios` or `yarn && yarn android`. By seeing its source code, you will have a better understanding of the library usage. -and - -``` -npm publish -``` +## Contributors -ℹ️ If you want to see what files will be included in your package before release run `npm pack` - -ℹ️ If you have native code in your library most of the time you will need `.kt`, `.h`/`.m`, `.swift` files, `project.pbxproj`, `AndroidManifest.xml` and `build.gradle` aside from TypeScript code and default stuff, so keep an eye on what you are publishing, some configuration/build folders or files might sneak in. Most of them (if not all) are ignored in [package.json](package.json). - -## FAQ - -### VSCode ESLint plugin does not lint example project - -By default, ESLint is configured separately for the library's source code and the example. It uses two `.eslintignore` files, the first one for the library, among others it ignores `/example` folder, and the second one for the example project. Since `/example` folder is ignored in one of these files, the plugin does not lint anything in it, see this [issue](https://github.com/microsoft/vscode-eslint/issues/111). To fix that, go to the VSCode settings and set - -```json -"eslint.workingDirectories": [ - "./example" -] -``` + + + + + + + +

Marco Fiorito

💻
-## License +## Acknowledgements -[MIT](LICENSE) +- [@Myagi](https://github.com/Myagi) for `react-native-vimeo`, I based on that library to make that library with the latest versions of react-native. diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index 8e9e80e..0000000 --- a/android/build.gradle +++ /dev/null @@ -1,44 +0,0 @@ -buildscript { - ext.safeExtGet = { prop, fallback -> - return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:4.1.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.4.21')}" - } -} - -def safeExtGet(prop, fallback) { - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback -} - -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' - -android { - compileSdkVersion safeExtGet('compileSdkVersion', 29) - buildToolsVersion safeExtGet('buildToolsVersion', '29.0.3') - - defaultConfig { - minSdkVersion safeExtGet('minSdkVersion', 16) - targetSdkVersion safeExtGet('targetSdkVersion', 29) - } -} - -repositories { - google() - jcenter() - mavenCentral() -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:${safeExtGet('kotlinVersion', '1.4.21')}" - //noinspection GradleDynamicVersion - implementation 'com.facebook.react:react-native:+' -} diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml deleted file mode 100644 index 33f4d35..0000000 --- a/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - diff --git a/android/src/main/java/com/alexdemchenko/reactnativemoduletemplate/RNModuleTemplateModule.kt b/android/src/main/java/com/alexdemchenko/reactnativemoduletemplate/RNModuleTemplateModule.kt deleted file mode 100644 index 36ec7f2..0000000 --- a/android/src/main/java/com/alexdemchenko/reactnativemoduletemplate/RNModuleTemplateModule.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.alexdemchenko.reactnativemoduletemplate - -import com.facebook.react.bridge.ReactApplicationContext -import com.facebook.react.bridge.ReactContextBaseJavaModule - -class RNModuleTemplateModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) { - - override fun getName() = "RNModuleTemplate" - - override fun getConstants(): MutableMap { - return hashMapOf("count" to 1) - } -} diff --git a/android/src/main/java/com/alexdemchenko/reactnativemoduletemplate/RNModuleTemplatePackage.kt b/android/src/main/java/com/alexdemchenko/reactnativemoduletemplate/RNModuleTemplatePackage.kt deleted file mode 100644 index 7efd2ba..0000000 --- a/android/src/main/java/com/alexdemchenko/reactnativemoduletemplate/RNModuleTemplatePackage.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.alexdemchenko.reactnativemoduletemplate - -import com.facebook.react.ReactPackage -import com.facebook.react.bridge.NativeModule -import com.facebook.react.bridge.ReactApplicationContext -import com.facebook.react.uimanager.ViewManager - -class RNModuleTemplatePackage : ReactPackage { - - override fun createViewManagers(reactContext: ReactApplicationContext): - MutableList> { - return mutableListOf() - } - - override fun createNativeModules(reactContext: ReactApplicationContext): - MutableList { - return mutableListOf(RNModuleTemplateModule(reactContext)) - } -} diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6180ef6..8ef5e1f 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -182,7 +182,6 @@ android { } dependencies { - implementation project(':react-native-module-template') implementation fileTree(dir: 'libs', include: ['*.jar']) //noinspection GradleDynamicVersion implementation 'com.facebook.react:react-native:+' // From node_modules diff --git a/example/android/app/src/main/java/com/example/MainApplication.kt b/example/android/app/src/main/java/com/example/MainApplication.kt index d2bfb08..fbe7dbc 100644 --- a/example/android/app/src/main/java/com/example/MainApplication.kt +++ b/example/android/app/src/main/java/com/example/MainApplication.kt @@ -2,7 +2,6 @@ package com.example import android.app.Application import android.content.Context -import com.alexdemchenko.reactnativemoduletemplate.RNModuleTemplatePackage import com.facebook.react.* import com.facebook.soloader.SoLoader import java.lang.reflect.InvocationTargetException @@ -16,7 +15,6 @@ class MainApplication : Application(), ReactApplication { override fun getPackages(): List { val packages = PackageList(this).packages - packages.add(RNModuleTemplatePackage()) return packages } diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 9063ded..325873c 100755 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,6 +1,3 @@ -rootProject.name = 'example' -apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) - include ':react-native-module-template' project(':react-native-module-template').projectDir = new File(rootProject.projectDir, '../../android') diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index b10bd65..c4d4d59 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -236,6 +236,8 @@ PODS: - React-cxxreact (= 0.63.4) - React-jsi (= 0.63.4) - React-jsinspector (0.63.4) + - react-native-webview (11.2.3): + - React-Core - React-RCTActionSheet (0.63.4): - React-Core/RCTActionSheetHeaders (= 0.63.4) - React-RCTAnimation (0.63.4): @@ -337,6 +339,7 @@ DEPENDENCIES: - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) + - react-native-webview (from `../node_modules/react-native-webview`) - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) @@ -395,6 +398,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/jsiexecutor" React-jsinspector: :path: "../node_modules/react-native/ReactCommon/jsinspector" + react-native-webview: + :path: "../node_modules/react-native-webview" React-RCTActionSheet: :path: "../node_modules/react-native/Libraries/ActionSheetIOS" React-RCTAnimation: @@ -445,6 +450,7 @@ SPEC CHECKSUMS: React-jsi: a0418934cf48f25b485631deb27c64dc40fb4c31 React-jsiexecutor: 93bd528844ad21dc07aab1c67cb10abae6df6949 React-jsinspector: 58aef7155bc9a9683f5b60b35eccea8722a4f53a + react-native-webview: 6520e3e7b4933de76b95ef542c8d7115cf45b68e React-RCTActionSheet: 89a0ca9f4a06c1f93c26067af074ccdce0f40336 React-RCTAnimation: 1bde3ecc0c104c55df246eda516e0deb03c4e49b React-RCTBlob: a97d378b527740cc667e03ebfa183a75231ab0f0 @@ -460,4 +466,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 67546a31292453d5d7519f46729a35755310976e -COCOAPODS: 1.10.1 +COCOAPODS: 1.9.3 diff --git a/example/ios/example.xcodeproj/project.pbxproj b/example/ios/example.xcodeproj/project.pbxproj index 2631f7e..b27b2a2 100644 --- a/example/ios/example.xcodeproj/project.pbxproj +++ b/example/ios/example.xcodeproj/project.pbxproj @@ -9,21 +9,10 @@ /* Begin PBXBuildFile section */ 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; AD7F6F5E51A4583A329C159C /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F9830928ACC38C373A5553B3 /* libPods-example.a */; }; - FA0EFF72236CCB6600069FA8 /* libRNModuleTemplate.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA0EFF71236CCB5C00069FA8 /* libRNModuleTemplate.a */; }; FA4A9D282369C1DB0065E0DD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4A9D272369C1DB0065E0DD /* AppDelegate.swift */; }; FA4A9D2B2369C4B80065E0DD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FA4A9D2A2369C4B80065E0DD /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - FA0EFF70236CCB5C00069FA8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FA0EFF6C236CCB5C00069FA8 /* RNModuleTemplate.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = FA0EFF60236CC8FB00069FA8; - remoteInfo = RNModuleTemplate; - }; -/* End PBXContainerItemProxy section */ - /* Begin PBXFileReference section */ 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = ""; }; 13B07F961A680F5B00A75B9A /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -33,7 +22,6 @@ CD8C4D2F1DF5380C94EABC8C /* Pods-example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.release.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.release.xcconfig"; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; F9830928ACC38C373A5553B3 /* libPods-example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - FA0EFF6C236CCB5C00069FA8 /* RNModuleTemplate.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNModuleTemplate.xcodeproj; path = ../../ios/RNModuleTemplate.xcodeproj; sourceTree = ""; }; FA4A9D272369C1DB0065E0DD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = example/AppDelegate.swift; sourceTree = ""; }; FA4A9D292369C20E0065E0DD /* example-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "example-Bridging-Header.h"; path = "example/example-Bridging-Header.h"; sourceTree = ""; }; FA4A9D2A2369C4B80065E0DD /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = example/LaunchScreen.storyboard; sourceTree = ""; }; @@ -45,7 +33,6 @@ buildActionMask = 2147483647; files = ( AD7F6F5E51A4583A329C159C /* libPods-example.a in Frameworks */, - FA0EFF72236CCB6600069FA8 /* libRNModuleTemplate.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -77,7 +64,6 @@ 832341AE1AAA6A7D00B99B32 /* Libraries */ = { isa = PBXGroup; children = ( - FA0EFF6C236CCB5C00069FA8 /* RNModuleTemplate.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -113,14 +99,6 @@ path = Pods; sourceTree = ""; }; - FA0EFF6D236CCB5C00069FA8 /* Products */ = { - isa = PBXGroup; - children = ( - FA0EFF71236CCB5C00069FA8 /* libRNModuleTemplate.a */, - ); - name = Products; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -170,12 +148,6 @@ mainGroup = 83CBB9F61A601CBA00E9B192; productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; projectDirPath = ""; - projectReferences = ( - { - ProductGroup = FA0EFF6D236CCB5C00069FA8 /* Products */; - ProjectRef = FA0EFF6C236CCB5C00069FA8 /* RNModuleTemplate.xcodeproj */; - }, - ); projectRoot = ""; targets = ( 13B07F861A680F5B00A75B9A /* example */, @@ -183,16 +155,6 @@ }; /* End PBXProject section */ -/* Begin PBXReferenceProxy section */ - FA0EFF71236CCB5C00069FA8 /* libRNModuleTemplate.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRNModuleTemplate.a; - remoteRef = FA0EFF70236CCB5C00069FA8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - /* Begin PBXResourcesBuildPhase section */ 13B07F8E1A680F5B00A75B9A /* Resources */ = { isa = PBXResourcesBuildPhase; diff --git a/example/package.json b/example/package.json index 2820ab0..44b8c7a 100644 --- a/example/package.json +++ b/example/package.json @@ -12,7 +12,8 @@ }, "dependencies": { "react": "^17.0.1", - "react-native": "^0.63.4" + "react-native": "^0.63.4", + "react-native-webview": "11.2.3" }, "devDependencies": { "@babel/core": "^7.12.10", diff --git a/example/src/App.tsx b/example/src/App.tsx index 283b5ff..6ab253e 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,12 +1,50 @@ -import React, { useEffect } from 'react' -import RNModuleTemplate, { Counter } from 'react-native-module-template' +import React from 'react' +import { SafeAreaView, View } from 'react-native' +import { Vimeo } from 'react-native-vimeo-player' const App = () => { - useEffect(() => { - console.log(RNModuleTemplate) - }) - - return + return ( + + + console.log('Video is ready')} + onPlay={() => console.log('Video is playing')} + onPlayProgress={(data) => console.log('Video progress data:', data)} + onFinish={() => console.log('Video is finished')} + loop={false} + autoPlay={false} + controls={true} + speed={false} + /> + console.log('Video is ready')} + onPlay={() => console.log('Video is playing')} + onPlayProgress={(data) => console.log('Video progress data:', data)} + onFinish={() => console.log('Video is finished')} + loop={true} + autoPlay={false} + controls={false} + speed={false} + /> + + + ) } +import { StyleSheet } from 'react-native' + +export const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: 'white', + }, + mainContainer: { + flex: 1, + justifyContent: 'space-between', + paddingHorizontal: 30, + }, +}) + export default App diff --git a/example/tsconfig.json b/example/tsconfig.json index 9682c09..2555552 100644 --- a/example/tsconfig.json +++ b/example/tsconfig.json @@ -8,7 +8,7 @@ "module": "CommonJS", "noEmit": true, "paths": { - "react-native-module-template": ["../src"] + "react-native-vimeo-player": ["../src"] }, "skipLibCheck": true, "strict": true, diff --git a/example/yarn.lock b/example/yarn.lock index 63830f5..0083092 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -2549,16 +2549,16 @@ escape-html@~1.0.3: resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= +escape-string-regexp@2.0.0, escape-string-regexp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" + integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== + escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= -escape-string-regexp@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" - integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== - escodegen@^1.14.1: version "1.14.3" resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.3.tgz#4e7b81fba61581dc97582ed78cab7f0e8d63f503" @@ -3445,7 +3445,7 @@ internal-slot@^1.0.2: has "^1.0.3" side-channel "^1.0.4" -invariant@^2.2.4: +invariant@2.2.4, invariant@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== @@ -5653,6 +5653,14 @@ react-is@^16.12.0, react-is@^16.8.1, react-is@^16.8.4: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.1.tgz#5b3531bd76a645a4c9fb6e693ed36419e3301339" integrity sha512-NAnt2iGDXohE5LI7uBnLnqvLQMtzhkiAOLXTmv+qnF9Ky7xAPcX8Up/xWIhxvLVGJvuLiNc4xQLtuqDRzb4fSA== +react-native-webview@11.2.3: + version "11.2.3" + resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-11.2.3.tgz#1b82685ab60645d4161f2e25e98286493cdffa5d" + integrity sha512-r/K+Lf/O5aij72gRndMX2qsyQ/WLtDPiO75SS57y6JjqSKxedGASVL9Jwl1TM7fCXqUq8dgiwik/LuBHbJXAEg== + dependencies: + escape-string-regexp "2.0.0" + invariant "2.2.4" + react-native@^0.63.4: version "0.63.4" resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.63.4.tgz#2210fdd404c94a5fa6b423c6de86f8e48810ec36" diff --git a/ios/RNModuleTemplate-Bridging-Header.h b/ios/RNModuleTemplate-Bridging-Header.h deleted file mode 100644 index 84805a3..0000000 --- a/ios/RNModuleTemplate-Bridging-Header.h +++ /dev/null @@ -1,5 +0,0 @@ -// -// Use this file to import your target's public headers that you would like to expose to Swift. -// - -#import diff --git a/ios/RNModuleTemplate.m b/ios/RNModuleTemplate.m deleted file mode 100644 index 0dc5d79..0000000 --- a/ios/RNModuleTemplate.m +++ /dev/null @@ -1,11 +0,0 @@ -// -// RNModuleTemplate.m -// RNModuleTemplate -// -// Copyright © 2021 Alex Demchenko. All rights reserved. -// - -#import - -@interface RCT_EXTERN_MODULE(RNModuleTemplate, NSObject) -@end diff --git a/ios/RNModuleTemplate.swift b/ios/RNModuleTemplate.swift deleted file mode 100644 index 69d3adc..0000000 --- a/ios/RNModuleTemplate.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// RNModuleTemplate.swift -// RNModuleTemplate -// -// Copyright © 2021 Alex Demchenko. All rights reserved. -// - -import Foundation - -@objc(RNModuleTemplate) -class RNModuleTemplate: NSObject { - @objc - func constantsToExport() -> [AnyHashable : Any]! { - return ["count": 1] - } - - @objc - static func requiresMainQueueSetup() -> Bool { - return true - } -} diff --git a/ios/RNModuleTemplate.xcodeproj/project.pbxproj b/ios/RNModuleTemplate.xcodeproj/project.pbxproj deleted file mode 100644 index 02ba426..0000000 --- a/ios/RNModuleTemplate.xcodeproj/project.pbxproj +++ /dev/null @@ -1,314 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 50; - objects = { - -/* Begin PBXBuildFile section */ - FA4F9FE82512AA42002DB4D5 /* RNModuleTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4F9FE72512AA42002DB4D5 /* RNModuleTemplate.swift */; }; - FA4F9FEB2512ACC2002DB4D5 /* RNModuleTemplate.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4F9FEA2512ACC2002DB4D5 /* RNModuleTemplate.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - FA0EFF5E236CC8FB00069FA8 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - FA0EFF60236CC8FB00069FA8 /* libRNModuleTemplate.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNModuleTemplate.a; sourceTree = BUILT_PRODUCTS_DIR; }; - FA4F9FE62512AA41002DB4D5 /* RNModuleTemplate-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNModuleTemplate-Bridging-Header.h"; sourceTree = ""; }; - FA4F9FE72512AA42002DB4D5 /* RNModuleTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNModuleTemplate.swift; sourceTree = ""; }; - FA4F9FEA2512ACC2002DB4D5 /* RNModuleTemplate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNModuleTemplate.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - FA0EFF5D236CC8FB00069FA8 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - FA0EFF57236CC8FB00069FA8 = { - isa = PBXGroup; - children = ( - FA4F9FE62512AA41002DB4D5 /* RNModuleTemplate-Bridging-Header.h */, - FA4F9FEA2512ACC2002DB4D5 /* RNModuleTemplate.m */, - FA4F9FE72512AA42002DB4D5 /* RNModuleTemplate.swift */, - FA0EFF61236CC8FB00069FA8 /* Products */, - ); - sourceTree = ""; - }; - FA0EFF61236CC8FB00069FA8 /* Products */ = { - isa = PBXGroup; - children = ( - FA0EFF60236CC8FB00069FA8 /* libRNModuleTemplate.a */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - FA0EFF5F236CC8FB00069FA8 /* RNModuleTemplate */ = { - isa = PBXNativeTarget; - buildConfigurationList = FA0EFF69236CC8FB00069FA8 /* Build configuration list for PBXNativeTarget "RNModuleTemplate" */; - buildPhases = ( - FA0EFF5C236CC8FB00069FA8 /* Sources */, - FA0EFF5D236CC8FB00069FA8 /* Frameworks */, - FA0EFF5E236CC8FB00069FA8 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RNModuleTemplate; - productName = RNModuleTemplate; - productReference = FA0EFF60236CC8FB00069FA8 /* libRNModuleTemplate.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - FA0EFF58236CC8FB00069FA8 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 1230; - ORGANIZATIONNAME = "Alex Demchenko"; - TargetAttributes = { - FA0EFF5F236CC8FB00069FA8 = { - CreatedOnToolsVersion = 11.1; - LastSwiftMigration = 1170; - }; - }; - }; - buildConfigurationList = FA0EFF5B236CC8FB00069FA8 /* Build configuration list for PBXProject "RNModuleTemplate" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = FA0EFF57236CC8FB00069FA8; - productRefGroup = FA0EFF61236CC8FB00069FA8 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - FA0EFF5F236CC8FB00069FA8 /* RNModuleTemplate */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - FA0EFF5C236CC8FB00069FA8 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - FA4F9FE82512AA42002DB4D5 /* RNModuleTemplate.swift in Sources */, - FA4F9FEB2512ACC2002DB4D5 /* RNModuleTemplate.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - FA0EFF67236CC8FB00069FA8 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - FA0EFF68236CC8FB00069FA8 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - FA0EFF6A236CC8FB00069FA8 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Automatic; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../example/ios/Pods/Headers/Public/React-Core", - "$(SRCROOT)/../../../ios/Pods/Headers/Public/React-Core", - ); - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - SWIFT_OBJC_BRIDGING_HEADER = "RNModuleTemplate-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - FA0EFF6B236CC8FB00069FA8 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Automatic; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../example/ios/Pods/Headers/Public/React-Core", - "$(SRCROOT)/../../../ios/Pods/Headers/Public/React-Core", - ); - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - SWIFT_OBJC_BRIDGING_HEADER = "RNModuleTemplate-Bridging-Header.h"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - FA0EFF5B236CC8FB00069FA8 /* Build configuration list for PBXProject "RNModuleTemplate" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - FA0EFF67236CC8FB00069FA8 /* Debug */, - FA0EFF68236CC8FB00069FA8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - FA0EFF69236CC8FB00069FA8 /* Build configuration list for PBXNativeTarget "RNModuleTemplate" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - FA0EFF6A236CC8FB00069FA8 /* Debug */, - FA0EFF6B236CC8FB00069FA8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = FA0EFF58236CC8FB00069FA8 /* Project object */; -} diff --git a/ios/RNModuleTemplate.xcodeproj/xcshareddata/xcschemes/RNModuleTemplate.xcscheme b/ios/RNModuleTemplate.xcodeproj/xcshareddata/xcschemes/RNModuleTemplate.xcscheme deleted file mode 100644 index 113e0e4..0000000 --- a/ios/RNModuleTemplate.xcodeproj/xcshareddata/xcschemes/RNModuleTemplate.xcscheme +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/package.json b/package.json index 2c78243..9acc167 100644 --- a/package.json +++ b/package.json @@ -1,29 +1,14 @@ { - "name": "react-native-module-template", - "version": "2.1.0", - "description": "A starter for the React Native library written in TypeScript, with linked example project and optional native code in Swift and Kotlin.", - "homepage": "https://github.com/demchenkoalex/react-native-module-template#readme", - "main": "lib/index.js", + "name": "react-native-vimeo-player", + "version": "1.0.0", + "description": "", + "homepage": "https://github.com/MetaLabs-inc/react-native-vimeo-player#readme", + "main": "src/index.tsx", "types": "lib/index.d.ts", - "author": "Alex Demchenko ", + "author": "Marco Fiorito ", "license": "MIT", "files": [ - "android", - "ios", - "lib", - "react-native-module-template.podspec", - "!.DS_Store", - "!.gradle", - "!.idea", - "!build", - "!gradle", - "!*.iml", - "!gradlew", - "!gradlew.bat", - "!local.properties", - "!project.xcworkspace", - "!xcshareddata", - "!xcuserdata" + "lib" ], "scripts": { "compile": "rm -rf lib && tsc -p .", @@ -31,6 +16,11 @@ "prepare": "yarn compile", "test": "jest" }, + "dependencies": { + "react": "^17.0.1", + "react-native": "^0.63.4", + "react-native-webview": "11.2.3" + }, "devDependencies": { "@babel/core": "^7.12.10", "@babel/runtime": "^7.12.5", diff --git a/react-native-module-template.podspec b/react-native-module-template.podspec deleted file mode 100644 index baf8b1a..0000000 --- a/react-native-module-template.podspec +++ /dev/null @@ -1,20 +0,0 @@ -require 'json' - -package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) - -Pod::Spec.new do |s| - s.name = package['name'] - s.version = package['version'] - s.summary = package['description'] - s.license = package['license'] - - s.authors = package['author'] - s.homepage = package['homepage'] - s.platform = :ios, "10.0" - - s.source = { :git => "https://github.com/demchenkoalex/react-native-module-template.git", :tag => "v#{s.version}" } - s.source_files = "ios/**/*.{h,m,swift}" - - s.dependency 'React' -end - diff --git a/rename.js b/rename.js deleted file mode 100644 index c3fda32..0000000 --- a/rename.js +++ /dev/null @@ -1,362 +0,0 @@ -const fs = require('fs') -const readline = require('readline') - -// Params used in the template project -const DEFAULT_NAME = 'react-native-module-template' -const DEFAULT_SHORT_NAME = 'RNModuleTemplate' -const DEFAULT_URL = - 'https://github.com/demchenkoalex/react-native-module-template#readme' -const DEFAULT_GIT_URL = - 'https://github.com/demchenkoalex/react-native-module-template.git' -const DEFAULT_AUTHOR_NAME = 'Alex Demchenko' -const DEFAULT_AUTHOR_EMAIL = 'alexdemchenko@yahoo.com' - -// Questions list -const QUESTION_NAME = `Enter library name (use kebab-case) (default ${DEFAULT_NAME}): ` -const QUESTION_SHORT_NAME = `Enter library short name (used to name Swift and Kotlin classes, use PascalCase) (default ${DEFAULT_SHORT_NAME}): ` -const QUESTION_URL = `Enter library homepage (default ${DEFAULT_URL}): ` -const QUESTION_GIT_URL = `Enter library git url (default ${DEFAULT_GIT_URL}): ` -const QUESTION_AUTHOR_NAME = `Enter author name (default ${DEFAULT_AUTHOR_NAME}): ` -const QUESTION_AUTHOR_EMAIL = `Enter author email (default ${DEFAULT_AUTHOR_EMAIL}): ` - -// Pass `js-only` parameter to remove native code -const jsOnly = process.argv.slice(2).includes('js-only') - -const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, -}) - -if (jsOnly) { - // JS only mode - // Remove `QUESTION_SHORT_NAME` since it is used only in the native code - // Remove `QUESTION_GIT_URL` since in it used only in the .podspec file - rl.question(QUESTION_NAME, (name) => { - rl.question(QUESTION_URL, (url) => { - rl.question(QUESTION_AUTHOR_NAME, (authorName) => { - rl.question(QUESTION_AUTHOR_EMAIL, (authorEmail) => { - renameFiles( - name || undefined, - undefined, - url || undefined, - undefined, - authorName || undefined, - authorEmail || undefined - ) - rl.close() - }) - }) - }) - }) -} else { - // Normal mode - // All questions - rl.question(QUESTION_NAME, (name) => { - rl.question(QUESTION_SHORT_NAME, (shortName) => { - rl.question(QUESTION_URL, (url) => { - rl.question(QUESTION_GIT_URL, (gitUrl) => { - rl.question(QUESTION_AUTHOR_NAME, (authorName) => { - rl.question(QUESTION_AUTHOR_EMAIL, (authorEmail) => { - renameFiles( - name || undefined, - shortName || undefined, - url || undefined, - gitUrl || undefined, - authorName || undefined, - authorEmail || undefined - ) - rl.close() - }) - }) - }) - }) - }) - }) -} - -const replaceDefaultShortName = (data, shortName) => { - return data.replace(new RegExp(DEFAULT_SHORT_NAME, 'g'), shortName) -} - -const renameFiles = ( - name = DEFAULT_NAME, - shortName = DEFAULT_SHORT_NAME, - url = DEFAULT_URL, - gitUrl = DEFAULT_GIT_URL, - authorName = DEFAULT_AUTHOR_NAME, - authorEmail = DEFAULT_AUTHOR_EMAIL -) => { - try { - // Clear `README.md` - fs.writeFileSync('README.md', '') - - if (jsOnly) { - // JS only mode - // Remove .podspec - fs.unlinkSync(`${DEFAULT_NAME}.podspec`) - } else { - // Normal mode - // Rename .podspec and replace git url - fs.renameSync(`${DEFAULT_NAME}.podspec`, `${name}.podspec`) - const podspecData = fs.readFileSync(`${name}.podspec`).toString() - const newPodspecData = podspecData.replace(DEFAULT_GIT_URL, gitUrl) - fs.writeFileSync(`${name}.podspec`, newPodspecData) - } - - // Modify `package.json` - const packageData = fs.readFileSync('package.json').toString() - let newPackageData = packageData - .replace(DEFAULT_URL, url) - .replace(new RegExp(DEFAULT_NAME, 'g'), name) - .replace(DEFAULT_AUTHOR_NAME, authorName) - .replace(DEFAULT_AUTHOR_EMAIL, authorEmail) - .replace(/"description": ".+"/g, '"description": ""') - .replace(/"version": ".+"/g, '"version": "1.0.0"') - if (jsOnly) { - // JS only mode - // Supply only `lib` folder in `package.json` - newPackageData = newPackageData.replace( - /"files": \[.+\],/s, - '"files": [\n "lib"\n ],' - ) - } - fs.writeFileSync('package.json', newPackageData) - - // Modify author in `LICENSE` - const licenseData = fs.readFileSync('LICENSE').toString() - const newLicenseData = licenseData.replace(DEFAULT_AUTHOR_NAME, authorName) - fs.writeFileSync('LICENSE', newLicenseData) - - // Modify example's `tsconfig.json` - const tsConfigData = fs.readFileSync('example/tsconfig.json').toString() - const newTsConfigData = tsConfigData.replace(DEFAULT_NAME, name) - fs.writeFileSync('example/tsconfig.json', newTsConfigData) - - if (jsOnly) { - // JS only mode - // Remove native modules from `index.tsx` - const indexData = fs.readFileSync('src/index.tsx').toString() - const newIndexData = indexData - .replace( - new RegExp( - `\nexport default NativeModules.${DEFAULT_SHORT_NAME}\n`, - 'g' - ), - '' - ) - .replace('NativeModules, ', '') - fs.writeFileSync('src/index.tsx', newIndexData) - - // Remove native modules from `App.tsx` - const appData = fs.readFileSync('example/src/App.tsx').toString() - const newAppData = appData - .replace(`${DEFAULT_SHORT_NAME}, `, '') - .replace(DEFAULT_SHORT_NAME, "''") - .replace(DEFAULT_NAME, name) - fs.writeFileSync('example/src/App.tsx', newAppData) - - // Remove native folders - fs.rmdirSync('ios', { recursive: true }) - fs.rmdirSync('android', { recursive: true }) - } else { - // Normal mode - // Rename native modules in `index.tsx` - const indexData = fs.readFileSync('src/index.tsx').toString() - const newIndexData = replaceDefaultShortName(indexData, shortName) - fs.writeFileSync('src/index.tsx', newIndexData) - - // Rename native modules in `App.tsx` - const appData = fs.readFileSync('example/src/App.tsx').toString() - const newAppData = replaceDefaultShortName(appData, shortName).replace( - DEFAULT_NAME, - name - ) - fs.writeFileSync('example/src/App.tsx', newAppData) - - // Rename and modify .xcscheme file - fs.renameSync( - `ios/${DEFAULT_SHORT_NAME}.xcodeproj/xcshareddata/xcschemes/${DEFAULT_SHORT_NAME}.xcscheme`, - `ios/${DEFAULT_SHORT_NAME}.xcodeproj/xcshareddata/xcschemes/${shortName}.xcscheme` - ) - const schemeData = fs - .readFileSync( - `ios/${DEFAULT_SHORT_NAME}.xcodeproj/xcshareddata/xcschemes/${shortName}.xcscheme` - ) - .toString() - const newSchemeData = replaceDefaultShortName(schemeData, shortName) - fs.writeFileSync( - `ios/${DEFAULT_SHORT_NAME}.xcodeproj/xcshareddata/xcschemes/${shortName}.xcscheme`, - newSchemeData - ) - - // Rename .xcodeproj folder - fs.renameSync( - `ios/${DEFAULT_SHORT_NAME}.xcodeproj`, - `ios/${shortName}.xcodeproj` - ) - - // Modify `project.pbxproj` - const projectData = fs - .readFileSync(`ios/${shortName}.xcodeproj/project.pbxproj`) - .toString() - const newProjectData = replaceDefaultShortName( - projectData, - shortName - ).replace(DEFAULT_AUTHOR_NAME, authorName) - fs.writeFileSync( - `ios/${shortName}.xcodeproj/project.pbxproj`, - newProjectData - ) - - // Rename and modify bridging header .h file - fs.renameSync( - `ios/${DEFAULT_SHORT_NAME}-Bridging-Header.h`, - `ios/${shortName}-Bridging-Header.h` - ) - - // Rename and modify .m file - fs.renameSync(`ios/${DEFAULT_SHORT_NAME}.m`, `ios/${shortName}.m`) - const implementationData = fs - .readFileSync(`ios/${shortName}.m`) - .toString() - const newImplementationData = replaceDefaultShortName( - implementationData, - shortName - ).replace(DEFAULT_AUTHOR_NAME, authorName) - fs.writeFileSync(`ios/${shortName}.m`, newImplementationData) - - // Rename and modify .swift file - fs.renameSync(`ios/${DEFAULT_SHORT_NAME}.swift`, `ios/${shortName}.swift`) - const swiftData = fs.readFileSync(`ios/${shortName}.swift`).toString() - const newSwiftData = replaceDefaultShortName( - swiftData, - shortName - ).replace(DEFAULT_AUTHOR_NAME, authorName) - fs.writeFileSync(`ios/${shortName}.swift`, newSwiftData) - - // Generate Android package name from auther and module names - const androidPackageAuthorName = authorName - .replace(/\s/g, '') - .toLowerCase() - const androidPackageModuleName = name.replace(/-/g, '').toLowerCase() - const androidPackageName = `com.${androidPackageAuthorName}.${androidPackageModuleName}` - - // Generate current Android package name from default author and module names - const defaultAndroidPackageAuthorName = DEFAULT_AUTHOR_NAME.replace( - /\s/g, - '' - ).toLowerCase() - const defaultAndroidPackageModuleName = DEFAULT_NAME.replace( - /-/g, - '' - ).toLowerCase() - const defaultAndroidPackageName = `com.${defaultAndroidPackageAuthorName}.${defaultAndroidPackageModuleName}` - - // Rename package in `AndroidManifest.xml` - const manifestData = fs - .readFileSync('android/src/main/AndroidManifest.xml') - .toString() - const newManifestData = manifestData.replace( - defaultAndroidPackageName, - androidPackageName - ) - fs.writeFileSync('android/src/main/AndroidManifest.xml', newManifestData) - - // Rename package folders - fs.renameSync( - `android/src/main/java/com/${defaultAndroidPackageAuthorName}`, - `android/src/main/java/com/${androidPackageAuthorName}` - ) - fs.renameSync( - `android/src/main/java/com/${androidPackageAuthorName}/${defaultAndroidPackageModuleName}`, - `android/src/main/java/com/${androidPackageAuthorName}/${androidPackageModuleName}` - ) - - // Rename and modify Kotlin files - fs.renameSync( - `android/src/main/java/com/${androidPackageAuthorName}/${androidPackageModuleName}/${DEFAULT_SHORT_NAME}Module.kt`, - `android/src/main/java/com/${androidPackageAuthorName}/${androidPackageModuleName}/${shortName}Module.kt` - ) - const kotlinModuleData = fs - .readFileSync( - `android/src/main/java/com/${androidPackageAuthorName}/${androidPackageModuleName}/${shortName}Module.kt` - ) - .toString() - const newKotlinModuleData = replaceDefaultShortName( - kotlinModuleData, - shortName - ).replace(defaultAndroidPackageName, androidPackageName) - fs.writeFileSync( - `android/src/main/java/com/${androidPackageAuthorName}/${androidPackageModuleName}/${shortName}Module.kt`, - newKotlinModuleData - ) - fs.renameSync( - `android/src/main/java/com/${androidPackageAuthorName}/${androidPackageModuleName}/${DEFAULT_SHORT_NAME}Package.kt`, - `android/src/main/java/com/${androidPackageAuthorName}/${androidPackageModuleName}/${shortName}Package.kt` - ) - const kotlinPackageData = fs - .readFileSync( - `android/src/main/java/com/${androidPackageAuthorName}/${androidPackageModuleName}/${shortName}Package.kt` - ) - .toString() - const newKotlinPackageData = replaceDefaultShortName( - kotlinPackageData, - shortName - ).replace(defaultAndroidPackageName, androidPackageName) - fs.writeFileSync( - `android/src/main/java/com/${androidPackageAuthorName}/${androidPackageModuleName}/${shortName}Package.kt`, - newKotlinPackageData - ) - - // Modify example's `project.pbxproj` - const exampleProjectData = fs - .readFileSync('example/ios/example.xcodeproj/project.pbxproj') - .toString() - const newExampleProjectData = replaceDefaultShortName( - exampleProjectData, - shortName - ) - fs.writeFileSync( - 'example/ios/example.xcodeproj/project.pbxproj', - newExampleProjectData - ) - - // Modify `settings.gradle` - const settingsData = fs - .readFileSync('example/android/settings.gradle') - .toString() - const newSettingsData = settingsData.replace( - new RegExp(DEFAULT_NAME, 'g'), - name - ) - fs.writeFileSync('example/android/settings.gradle', newSettingsData) - - // Modify `build.gradle` - const buildData = fs - .readFileSync('example/android/app/build.gradle') - .toString() - const newBuildData = buildData.replace( - new RegExp(DEFAULT_NAME, 'g'), - name - ) - fs.writeFileSync('example/android/app/build.gradle', newBuildData) - - // Modify `MainApplication.kt` - const mainApplicationData = fs - .readFileSync( - 'example/android/app/src/main/java/com/example/MainApplication.kt' - ) - .toString() - const newMainApplicationData = replaceDefaultShortName( - mainApplicationData, - shortName - ).replace(defaultAndroidPackageName, androidPackageName) - fs.writeFileSync( - 'example/android/app/src/main/java/com/example/MainApplication.kt', - newMainApplicationData - ) - } - } catch (err) { - console.log(err) - } -} diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts deleted file mode 100644 index d15a87f..0000000 --- a/src/__tests__/index.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { addOne } from '../index' - -test('addOne', () => { - expect(addOne(0)).toEqual(1) -}) diff --git a/src/index.tsx b/src/index.tsx index f63ee8e..4958163 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,26 +1,86 @@ -import * as React from 'react' -import { Button, NativeModules, StyleSheet, Text, View } from 'react-native' +import React, {useCallback, useEffect, useState} from 'react'; +import {TouchableWithoutFeedback} from 'react-native'; +import {WebView} from 'react-native-webview'; +import webplayer from './template'; +import {LayoutProps} from './types'; -export const addOne = (input: number) => input + 1 +export const Vimeo: React.FC = ({ + videoId, + onReady, + onPlay, + onPlayProgress, + onPause, + onFinish, + scalesPageToFit, + loop, + controls, + autoPlay, + speed = false, + style, +}) => { + const [isReady, setReady] = useState(); -export const Counter = () => { - const [count, setCount] = React.useState(0) + const [autoPlayValue, setAutoPlay] = useState(autoPlay); + const toggleAutoPlay = useCallback(() => setAutoPlay(!autoPlayValue), [ + autoPlayValue, + ]); + + const handlers: any = {}; + const registerHandlers = () => { + registerBridgeEventHandler('ready', onReady ?? onReadyDefault); + registerBridgeEventHandler('play', onPlay); + registerBridgeEventHandler('playProgress', onPlayProgress); + registerBridgeEventHandler('pause', onPause); + registerBridgeEventHandler('finish', onFinish); + }; + + const registerBridgeEventHandler = (eventName: string, handler: any) => { + handlers[eventName] = handler; + }; + + useEffect(() => { + registerHandlers(); + }, [videoId, scalesPageToFit]); + + const onBridgeMessage = (event: any) => { + const message = event.nativeEvent.data; + let payload; + try { + payload = JSON.parse(message); + if (payload?.name === 'finish') { + toggleAutoPlay(); + } + } catch (err) { + return; + } + let handler = handlers[payload.name]; + if (handler) handler(payload.data); + }; + + const onReadyDefault = () => { + setReady(true); + if (onReady) setTimeout(onReady); + }; return ( - - You pressed {count} times -