Skip to content

Commit

Permalink
Merge remote-tracking branch 'vincentriemer/master' into slider
Browse files Browse the repository at this point in the history
  • Loading branch information
motiz88 committed Jun 3, 2018
2 parents cd18206 + 4b9d184 commit 8d32d89
Show file tree
Hide file tree
Showing 13 changed files with 440 additions and 23 deletions.
57 changes: 57 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"projectName": "react-native-dom",
"projectOwner": "vincentriemer",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"imageSize": 100,
"commit": false,
"contributors": [
{
"login": "vincentriemer",
"name": "Vincent Riemer",
"avatar_url": "https://avatars2.githubusercontent.com/u/1398555?v=4",
"profile": "http://vincentriemer.com",
"contributions": [
"code",
"bug",
"doc",
"example",
"ideas",
"infra",
"platform",
"talk"
]
},
{
"login": "joegoodall1",
"name": "Joe Goodall",
"avatar_url": "https://avatars0.githubusercontent.com/u/8888799?v=4",
"profile": "https://uk.linkedin.com/in/joegoodall",
"contributions": [
"doc"
]
},
{
"login": "frosato-ekino",
"name": "François Rosato",
"avatar_url": "https://avatars3.githubusercontent.com/u/31624379?v=4",
"profile": "https://github.com/frosato-ekino",
"contributions": [
"doc"
]
},
{
"login": "motiz88",
"name": "Moti Zilberman",
"avatar_url": "https://avatars2.githubusercontent.com/u/2246565?v=4",
"profile": "https://github.com/motiz88",
"contributions": [
"code",
"doc"
]
}
]
}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="0.2.0"></a>
# [0.2.0](https://github.com/vincentriemer/react-native-dom/compare/v0.1.2...v0.2.0) (2018-06-03)


### Bug Fixes

* **flow:** Fix flow errors ([0304c11](https://github.com/vincentriemer/react-native-dom/commit/0304c11))
* **RCTBridge:** Silence bundle progress parse errors ([62ddca5](https://github.com/vincentriemer/react-native-dom/commit/62ddca5))
* **RCTPropsAnimatedNode:** Fix iteration over prop config ([cdabeb5](https://github.com/vincentriemer/react-native-dom/commit/cdabeb5))


### Features

* **AsyncLocalStorage:** Add clear method to native AsyncLocalStorage ([6e72487](https://github.com/vincentriemer/react-native-dom/commit/6e72487))
* **RCTImage:** Add Image resizeMode=repeat ([3d441ca](https://github.com/vincentriemer/react-native-dom/commit/3d441ca))
* **RCTRootView:** Begin work on decoupling the root view from the document's body ([79a02bc](https://github.com/vincentriemer/react-native-dom/commit/79a02bc))
* **RCTVibration:** Add Vibration API ([9277d56](https://github.com/vincentriemer/react-native-dom/commit/9277d56))
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# React Native DOM &middot; [![CircleCI](https://circleci.com/gh/vincentriemer/react-native-dom.svg?style=shield&circle-token=96448c580730a065cb93c0a10af0f85f6c954166)](https://circleci.com/gh/vincentriemer/react-native-dom) [![npm version](https://badge.fury.io/js/react-native-dom.svg)](https://badge.fury.io/js/react-native-dom) [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/)
# React Native DOM &middot; [![CircleCI](https://circleci.com/gh/vincentriemer/react-native-dom.svg?style=shield&circle-token=96448c580730a065cb93c0a10af0f85f6c954166)](https://circleci.com/gh/vincentriemer/react-native-dom) [![npm version](https://badge.fury.io/js/react-native-dom.svg)](https://badge.fury.io/js/react-native-dom) [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/) [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg)](#contributors)

An experimental, comprehensive port of React Native to the web.

Expand Down Expand Up @@ -102,6 +102,9 @@ that gets generated from the rnpm plugin).
# Ensure development-speecific code is stripped from the bundle
export NODE_ENV=production

# Make the dist directory, or the build command below will fail.
mkdir -p ./dom/dist

# Build the main thread bundle
react-native bundle \
--config $(pwd)/rn-cli.config.js \
Expand Down Expand Up @@ -184,3 +187,20 @@ like to see.

A live deployment of the RNTester project (used primarily for manually testing
changes) can be found at [rntester.now.sh](https://rntester.now.sh)

## Contributors

Thanks goes to these wonderful people
([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->

<!-- prettier-ignore -->
| [<img src="https://avatars2.githubusercontent.com/u/1398555?v=4" width="100px;"/><br /><sub><b>Vincent Riemer</b></sub>](http://vincentriemer.com)<br />[💻](https://github.com/vincentriemer/react-native-dom/commits?author=vincentriemer "Code") [🐛](https://github.com/vincentriemer/react-native-dom/issues?q=author%3Avincentriemer "Bug reports") [📖](https://github.com/vincentriemer/react-native-dom/commits?author=vincentriemer "Documentation") [💡](#example-vincentriemer "Examples") [🤔](#ideas-vincentriemer "Ideas, Planning, & Feedback") [🚇](#infra-vincentriemer "Infrastructure (Hosting, Build-Tools, etc)") [📦](#platform-vincentriemer "Packaging/porting to new platform") [📢](#talk-vincentriemer "Talks") | [<img src="https://avatars0.githubusercontent.com/u/8888799?v=4" width="100px;"/><br /><sub><b>Joe Goodall</b></sub>](https://uk.linkedin.com/in/joegoodall)<br />[📖](https://github.com/vincentriemer/react-native-dom/commits?author=joegoodall1 "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/31624379?v=4" width="100px;"/><br /><sub><b>François Rosato</b></sub>](https://github.com/frosato-ekino)<br />[📖](https://github.com/vincentriemer/react-native-dom/commits?author=frosato-ekino "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/2246565?v=4" width="100px;"/><br /><sub><b>Moti Zilberman</b></sub>](https://github.com/motiz88)<br />[💻](https://github.com/vincentriemer/react-native-dom/commits?author=motiz88 "Code") [📖](https://github.com/vincentriemer/react-native-dom/commits?author=motiz88 "Documentation") |
| :---: | :---: | :---: | :---: |

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the
[all-contributors](https://github.com/kentcdodds/all-contributors)
specification. Contributions of any kind welcome!
6 changes: 4 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"lerna": "2.4.0",
"packages": ["packages/*"],
"packages": [
"packages/*"
],
"npmClient": "yarn",
"version": "0.1.2",
"version": "0.2.0",
"exact": true,
"command": {
"publish": {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
"precommit": "lint-staged",
"compile": "lerna run compile --stream",
"compile:components": "lerna run compile --scope rndom-* --stream",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate",
"fmt": "prettier --write 'packages/**/*.js'",
"lint": "flow check && eslint packages",
"release": "lerna publish --conventional-commits --yes",
"release": "lerna publish --conventional-commits --yes --cd-version-minor",
"release:canary": "lerna publish --canary --yes --cd-version minor",
"run-examples": "cd packages/react-native-dom && yarn run-examples",
"test": "lerna run test"
Expand All @@ -36,6 +38,7 @@
}
},
"devDependencies": {
"all-contributors-cli": "^4.11.1",
"babel-eslint": "^8.2.3",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^4.19.1",
Expand Down
22 changes: 22 additions & 0 deletions packages/react-native-dom/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="0.2.0"></a>
# [0.2.0](https://github.com/vincentriemer/react-native-dom/compare/v0.1.2...v0.2.0) (2018-06-03)


### Bug Fixes

* **flow:** Fix flow errors ([0304c11](https://github.com/vincentriemer/react-native-dom/commit/0304c11))
* **RCTBridge:** Silence bundle progress parse errors ([62ddca5](https://github.com/vincentriemer/react-native-dom/commit/62ddca5))
* **RCTPropsAnimatedNode:** Fix iteration over prop config ([cdabeb5](https://github.com/vincentriemer/react-native-dom/commit/cdabeb5))


### Features

* **AsyncLocalStorage:** Add clear method to native AsyncLocalStorage ([6e72487](https://github.com/vincentriemer/react-native-dom/commit/6e72487))
* **RCTImage:** Add Image resizeMode=repeat ([3d441ca](https://github.com/vincentriemer/react-native-dom/commit/3d441ca))
* **RCTRootView:** Begin work on decoupling the root view from the document's body ([79a02bc](https://github.com/vincentriemer/react-native-dom/commit/79a02bc))
* **RCTVibration:** Add Vibration API ([9277d56](https://github.com/vincentriemer/react-native-dom/commit/9277d56))
114 changes: 114 additions & 0 deletions packages/react-native-dom/Libraries/Vibration/Vibration.dom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule Vibration
* @flow
* @jsdoc
*/
"use strict";

var RCTVibration = require("NativeModules").Vibration;
var Platform = require("Platform");

/**
* Vibration API
*
* See https://facebook.github.io/react-native/docs/vibration.html
*/

var _vibrating: boolean = false;
var _id: number = 0; // _id is necessary to prevent race condition.

function vibrateByPattern(pattern: Array<number>, repeat: boolean = false) {
if (_vibrating) {
return;
}
_vibrating = true;
if (pattern[0] === 0) {
RCTVibration.vibrate();
pattern = pattern.slice(1);
}
if (pattern.length === 0) {
_vibrating = false;
return;
}
setTimeout(() => vibrateScheduler(++_id, pattern, repeat, 1), pattern[0]);
}

function vibrateScheduler(
id,
pattern: Array<number>,
repeat: boolean,
nextIndex: number
) {
if (!_vibrating || id !== _id) {
return;
}
RCTVibration.vibrate();
if (nextIndex >= pattern.length) {
if (repeat) {
nextIndex = 0;
} else {
_vibrating = false;
return;
}
}
setTimeout(
() => vibrateScheduler(id, pattern, repeat, nextIndex + 1),
pattern[nextIndex]
);
}

var Vibration = {
/**
* Trigger a vibration with specified `pattern`.
*
* See https://facebook.github.io/react-native/docs/vibration.html#vibrate
*/
vibrate: function(
pattern: number | Array<number> = 400,
repeat: boolean = false
) {
if (Platform.OS === "android" || Platform.OS === "dom") {
if (typeof pattern === "number") {
RCTVibration.vibrate(pattern);
} else if (Array.isArray(pattern)) {
if (Platform.OS === "android") {
RCTVibration.vibrateByPattern(pattern, repeat ? 0 : -1);
} else {
RCTVibration.vibrateByPattern(pattern, repeat);
}
} else {
throw new Error("Vibration pattern should be a number or array");
}
} else {
if (_vibrating) {
return;
}
if (typeof pattern === "number") {
RCTVibration.vibrate();
} else if (Array.isArray(pattern)) {
vibrateByPattern(pattern, repeat);
} else {
throw new Error("Vibration pattern should be a number or array");
}
}
},
/**
* Stop vibration
*
* See https://facebook.github.io/react-native/docs/vibration.html#cancel
*/
cancel: function() {
if (Platform.OS === "ios") {
_vibrating = false;
} else {
RCTVibration.cancel();
}
}
};

module.exports = Vibration;
2 changes: 1 addition & 1 deletion packages/react-native-dom/RNTester
7 changes: 4 additions & 3 deletions packages/react-native-dom/ReactDom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import RCTView from "RCTView";
import RCTViewManager from "RCTViewManager";
import RCTEventEmitter from "RCTNativeEventEmitter";
import CustomElement from "CustomElement";
import RCTEventDispatcher from "RCTEventDispatcher";
import RCTEventDispatcher, { type RCTEvent } from "RCTEventDispatcher";
import _RCTUIManager from "RCTUIManager";

declare var __DEV__: boolean;
Expand Down Expand Up @@ -50,7 +50,7 @@ export {
type RCTUIManager = $await<typeof _RCTUIManager>;

// Export type definitions useful for native module development
export type { RCTUIManager, RCTEventDispatcher, RCTBridge };
export type { RCTUIManager, RCTEventDispatcher, RCTBridge, RCTEvent };

// Register Built-in Native Modules
const builtInNativeModules: any[] = [
Expand Down Expand Up @@ -84,7 +84,8 @@ const builtInNativeModules: any[] = [
import("RCTRedBox"),
import("RCTWebViewManager"),
import("RCTNetworkingNative"),
import("RCTBlobManager")
import("RCTBlobManager"),
import("RCTVibration")
];

// Development Specific Native Modules
Expand Down
49 changes: 49 additions & 0 deletions packages/react-native-dom/ReactDom/modules/RCTVibration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* @providesModule RCTVibration
* @flow
*/

import RCTBridge, {
RCTFunctionTypeNormal,
RCT_EXPORT_METHOD,
RCT_EXPORT_MODULE
} from "RCTBridge";

@RCT_EXPORT_MODULE("RCTVibration")
class RCTVibration {
_intervalHandle: IntervalID;

@RCT_EXPORT_METHOD(RCTFunctionTypeNormal)
vibrateByPattern(pattern: Array<number>, repeat: boolean = false) {
if (!navigator.vibrate) {
return;
}
// Keep flow happy re: possible mutations of navigator
const vibrate = navigator.vibrate.bind(navigator);
vibrate(pattern);
clearInterval(this._intervalHandle);
if (repeat) {
const patternDuration = pattern.reduce((a, b) => a + b, 0);
this._intervalHandle = setInterval(
() => vibrate(pattern),
patternDuration
);
}
}

@RCT_EXPORT_METHOD(RCTFunctionTypeNormal)
vibrate(duration: number) {
if (!navigator.vibrate) {
return;
}
navigator.vibrate(duration);
clearInterval(this._intervalHandle);
}

@RCT_EXPORT_METHOD(RCTFunctionTypeNormal)
cancel() {
this.vibrate(0);
}
}

export default RCTVibration;

0 comments on commit 8d32d89

Please sign in to comment.