Skip to content

Commit 3e19981

Browse files
committed
Merge remote-tracking branch 'vincentriemer/master' into slider
2 parents 61a5c20 + 4b9d184 commit 3e19981

File tree

14 files changed

+448
-23
lines changed

14 files changed

+448
-23
lines changed

.all-contributorsrc

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"projectName": "react-native-dom",
3+
"projectOwner": "vincentriemer",
4+
"repoType": "github",
5+
"repoHost": "https://github.com",
6+
"files": [
7+
"README.md"
8+
],
9+
"imageSize": 100,
10+
"commit": false,
11+
"contributors": [
12+
{
13+
"login": "vincentriemer",
14+
"name": "Vincent Riemer",
15+
"avatar_url": "https://avatars2.githubusercontent.com/u/1398555?v=4",
16+
"profile": "http://vincentriemer.com",
17+
"contributions": [
18+
"code",
19+
"bug",
20+
"doc",
21+
"example",
22+
"ideas",
23+
"infra",
24+
"platform",
25+
"talk"
26+
]
27+
},
28+
{
29+
"login": "joegoodall1",
30+
"name": "Joe Goodall",
31+
"avatar_url": "https://avatars0.githubusercontent.com/u/8888799?v=4",
32+
"profile": "https://uk.linkedin.com/in/joegoodall",
33+
"contributions": [
34+
"doc"
35+
]
36+
},
37+
{
38+
"login": "frosato-ekino",
39+
"name": "François Rosato",
40+
"avatar_url": "https://avatars3.githubusercontent.com/u/31624379?v=4",
41+
"profile": "https://github.com/frosato-ekino",
42+
"contributions": [
43+
"doc"
44+
]
45+
},
46+
{
47+
"login": "motiz88",
48+
"name": "Moti Zilberman",
49+
"avatar_url": "https://avatars2.githubusercontent.com/u/2246565?v=4",
50+
"profile": "https://github.com/motiz88",
51+
"contributions": [
52+
"code",
53+
"doc"
54+
]
55+
}
56+
]
57+
}

CHANGELOG.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
<a name="0.2.0"></a>
7+
# [0.2.0](https://github.com/vincentriemer/react-native-dom/compare/v0.1.2...v0.2.0) (2018-06-03)
8+
9+
10+
### Bug Fixes
11+
12+
* **flow:** Fix flow errors ([0304c11](https://github.com/vincentriemer/react-native-dom/commit/0304c11))
13+
* **RCTBridge:** Silence bundle progress parse errors ([62ddca5](https://github.com/vincentriemer/react-native-dom/commit/62ddca5))
14+
* **RCTPropsAnimatedNode:** Fix iteration over prop config ([cdabeb5](https://github.com/vincentriemer/react-native-dom/commit/cdabeb5))
15+
16+
17+
### Features
18+
19+
* **AsyncLocalStorage:** Add clear method to native AsyncLocalStorage ([6e72487](https://github.com/vincentriemer/react-native-dom/commit/6e72487))
20+
* **RCTImage:** Add Image resizeMode=repeat ([3d441ca](https://github.com/vincentriemer/react-native-dom/commit/3d441ca))
21+
* **RCTRootView:** Begin work on decoupling the root view from the document's body ([79a02bc](https://github.com/vincentriemer/react-native-dom/commit/79a02bc))
22+
* **RCTVibration:** Add Vibration API ([9277d56](https://github.com/vincentriemer/react-native-dom/commit/9277d56))

README.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 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/)
1+
# 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)
22

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

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

105+
# Make the dist directory, or the build command below will fail.
106+
mkdir -p ./dom/dist
107+
105108
# Build the main thread bundle
106109
react-native bundle \
107110
--config $(pwd)/rn-cli.config.js \
@@ -184,3 +187,20 @@ like to see.
184187

185188
A live deployment of the RNTester project (used primarily for manually testing
186189
changes) can be found at [rntester.now.sh](https://rntester.now.sh)
190+
191+
## Contributors
192+
193+
Thanks goes to these wonderful people
194+
([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
195+
196+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
197+
198+
<!-- prettier-ignore -->
199+
| [<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") |
200+
| :---: | :---: | :---: | :---: |
201+
202+
<!-- ALL-CONTRIBUTORS-LIST:END -->
203+
204+
This project follows the
205+
[all-contributors](https://github.com/kentcdodds/all-contributors)
206+
specification. Contributions of any kind welcome!

lerna.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"lerna": "2.4.0",
3-
"packages": ["packages/*"],
3+
"packages": [
4+
"packages/*"
5+
],
46
"npmClient": "yarn",
5-
"version": "0.1.2",
7+
"version": "0.2.0",
68
"exact": true,
79
"command": {
810
"publish": {

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323
"precommit": "lint-staged",
2424
"compile": "lerna run compile --stream",
2525
"compile:components": "lerna run compile --scope rndom-* --stream",
26+
"contributors:add": "all-contributors add",
27+
"contributors:generate": "all-contributors generate",
2628
"fmt": "prettier --write 'packages/**/*.js'",
2729
"lint": "flow check && eslint packages",
30+
"release": "lerna publish --conventional-commits --yes --cd-version-minor",
2831
"release:canary": "lerna publish --canary --yes --cd-version minor",
2932
"run-examples": "cd packages/react-native-dom && yarn run-examples",
3033
"test": "lerna run test"
@@ -35,6 +38,7 @@
3538
}
3639
},
3740
"devDependencies": {
41+
"all-contributors-cli": "^4.11.1",
3842
"babel-eslint": "^8.2.3",
3943
"cz-conventional-changelog": "^2.1.0",
4044
"eslint": "^4.19.1",
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
<a name="0.2.0"></a>
7+
# [0.2.0](https://github.com/vincentriemer/react-native-dom/compare/v0.1.2...v0.2.0) (2018-06-03)
8+
9+
10+
### Bug Fixes
11+
12+
* **flow:** Fix flow errors ([0304c11](https://github.com/vincentriemer/react-native-dom/commit/0304c11))
13+
* **RCTBridge:** Silence bundle progress parse errors ([62ddca5](https://github.com/vincentriemer/react-native-dom/commit/62ddca5))
14+
* **RCTPropsAnimatedNode:** Fix iteration over prop config ([cdabeb5](https://github.com/vincentriemer/react-native-dom/commit/cdabeb5))
15+
16+
17+
### Features
18+
19+
* **AsyncLocalStorage:** Add clear method to native AsyncLocalStorage ([6e72487](https://github.com/vincentriemer/react-native-dom/commit/6e72487))
20+
* **RCTImage:** Add Image resizeMode=repeat ([3d441ca](https://github.com/vincentriemer/react-native-dom/commit/3d441ca))
21+
* **RCTRootView:** Begin work on decoupling the root view from the document's body ([79a02bc](https://github.com/vincentriemer/react-native-dom/commit/79a02bc))
22+
* **RCTVibration:** Add Vibration API ([9277d56](https://github.com/vincentriemer/react-native-dom/commit/9277d56))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @providesModule Vibration
8+
* @flow
9+
* @jsdoc
10+
*/
11+
"use strict";
12+
13+
var RCTVibration = require("NativeModules").Vibration;
14+
var Platform = require("Platform");
15+
16+
/**
17+
* Vibration API
18+
*
19+
* See https://facebook.github.io/react-native/docs/vibration.html
20+
*/
21+
22+
var _vibrating: boolean = false;
23+
var _id: number = 0; // _id is necessary to prevent race condition.
24+
25+
function vibrateByPattern(pattern: Array<number>, repeat: boolean = false) {
26+
if (_vibrating) {
27+
return;
28+
}
29+
_vibrating = true;
30+
if (pattern[0] === 0) {
31+
RCTVibration.vibrate();
32+
pattern = pattern.slice(1);
33+
}
34+
if (pattern.length === 0) {
35+
_vibrating = false;
36+
return;
37+
}
38+
setTimeout(() => vibrateScheduler(++_id, pattern, repeat, 1), pattern[0]);
39+
}
40+
41+
function vibrateScheduler(
42+
id,
43+
pattern: Array<number>,
44+
repeat: boolean,
45+
nextIndex: number
46+
) {
47+
if (!_vibrating || id !== _id) {
48+
return;
49+
}
50+
RCTVibration.vibrate();
51+
if (nextIndex >= pattern.length) {
52+
if (repeat) {
53+
nextIndex = 0;
54+
} else {
55+
_vibrating = false;
56+
return;
57+
}
58+
}
59+
setTimeout(
60+
() => vibrateScheduler(id, pattern, repeat, nextIndex + 1),
61+
pattern[nextIndex]
62+
);
63+
}
64+
65+
var Vibration = {
66+
/**
67+
* Trigger a vibration with specified `pattern`.
68+
*
69+
* See https://facebook.github.io/react-native/docs/vibration.html#vibrate
70+
*/
71+
vibrate: function(
72+
pattern: number | Array<number> = 400,
73+
repeat: boolean = false
74+
) {
75+
if (Platform.OS === "android" || Platform.OS === "dom") {
76+
if (typeof pattern === "number") {
77+
RCTVibration.vibrate(pattern);
78+
} else if (Array.isArray(pattern)) {
79+
if (Platform.OS === "android") {
80+
RCTVibration.vibrateByPattern(pattern, repeat ? 0 : -1);
81+
} else {
82+
RCTVibration.vibrateByPattern(pattern, repeat);
83+
}
84+
} else {
85+
throw new Error("Vibration pattern should be a number or array");
86+
}
87+
} else {
88+
if (_vibrating) {
89+
return;
90+
}
91+
if (typeof pattern === "number") {
92+
RCTVibration.vibrate();
93+
} else if (Array.isArray(pattern)) {
94+
vibrateByPattern(pattern, repeat);
95+
} else {
96+
throw new Error("Vibration pattern should be a number or array");
97+
}
98+
}
99+
},
100+
/**
101+
* Stop vibration
102+
*
103+
* See https://facebook.github.io/react-native/docs/vibration.html#cancel
104+
*/
105+
cancel: function() {
106+
if (Platform.OS === "ios") {
107+
_vibrating = false;
108+
} else {
109+
RCTVibration.cancel();
110+
}
111+
}
112+
};
113+
114+
module.exports = Vibration;

packages/react-native-dom/ReactDom/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import RCTView from "RCTView";
2222
import RCTViewManager from "RCTViewManager";
2323
import RCTEventEmitter from "RCTNativeEventEmitter";
2424
import CustomElement from "CustomElement";
25-
import RCTEventDispatcher from "RCTEventDispatcher";
25+
import RCTEventDispatcher, { type RCTEvent } from "RCTEventDispatcher";
2626
import _RCTUIManager from "RCTUIManager";
2727

2828
declare var __DEV__: boolean;
@@ -50,7 +50,7 @@ export {
5050
type RCTUIManager = $await<typeof _RCTUIManager>;
5151

5252
// Export type definitions useful for native module development
53-
export type { RCTUIManager, RCTEventDispatcher, RCTBridge };
53+
export type { RCTUIManager, RCTEventDispatcher, RCTBridge, RCTEvent };
5454

5555
// Register Built-in Native Modules
5656
const builtInNativeModules: any[] = [
@@ -84,7 +84,8 @@ const builtInNativeModules: any[] = [
8484
import("RCTRedBox"),
8585
import("RCTWebViewManager"),
8686
import("RCTNetworkingNative"),
87-
import("RCTBlobManager")
87+
import("RCTBlobManager"),
88+
import("RCTVibration")
8889
];
8990

9091
// Development Specific Native Modules

packages/react-native-dom/ReactDom/modules/RCTAsyncLocalStorage.js

+11
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ class RCTAsyncLocalStorage {
9191
callback(err, null);
9292
}
9393
}
94+
95+
@RCT_EXPORT_METHOD(RCTFunctionTypeNormal)
96+
async clear(callbackId: number) {
97+
const callback = this.bridge.callbackFromId(callbackId);
98+
try {
99+
await idbKeyval.clear();
100+
callback(null);
101+
} catch (err) {
102+
callback(err);
103+
}
104+
}
94105
}
95106

96107
export default RCTAsyncLocalStorage;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @providesModule RCTVibration
3+
* @flow
4+
*/
5+
6+
import RCTBridge, {
7+
RCTFunctionTypeNormal,
8+
RCT_EXPORT_METHOD,
9+
RCT_EXPORT_MODULE
10+
} from "RCTBridge";
11+
12+
@RCT_EXPORT_MODULE("RCTVibration")
13+
class RCTVibration {
14+
_intervalHandle: IntervalID;
15+
16+
@RCT_EXPORT_METHOD(RCTFunctionTypeNormal)
17+
vibrateByPattern(pattern: Array<number>, repeat: boolean = false) {
18+
if (!navigator.vibrate) {
19+
return;
20+
}
21+
// Keep flow happy re: possible mutations of navigator
22+
const vibrate = navigator.vibrate.bind(navigator);
23+
vibrate(pattern);
24+
clearInterval(this._intervalHandle);
25+
if (repeat) {
26+
const patternDuration = pattern.reduce((a, b) => a + b, 0);
27+
this._intervalHandle = setInterval(
28+
() => vibrate(pattern),
29+
patternDuration
30+
);
31+
}
32+
}
33+
34+
@RCT_EXPORT_METHOD(RCTFunctionTypeNormal)
35+
vibrate(duration: number) {
36+
if (!navigator.vibrate) {
37+
return;
38+
}
39+
navigator.vibrate(duration);
40+
clearInterval(this._intervalHandle);
41+
}
42+
43+
@RCT_EXPORT_METHOD(RCTFunctionTypeNormal)
44+
cancel() {
45+
this.vibrate(0);
46+
}
47+
}
48+
49+
export default RCTVibration;

0 commit comments

Comments
 (0)