Adds react-events package for internal testing (#15150)
* Adds react-events package for internal testing
Dominic Gannaway committed
Mar 19, 2019 at 15:12 UTC
55cc921c5d3485eb60fe94628b227d4069c97b6c
9 files changed
+129
-1
packages/react-events/README.md
new
+3
@@ -0,0 +1,3 @@
1
+# `react-events`
2
+
3
+This is package is intended for use with the experimental React events API.
\ No newline at end of file
packages/react-events/index.js
new
+16
@@ -0,0 +1,16 @@
1
+/**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
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
+ * @flow
8
+ */
9
+
10
+'use strict';
11
+
12
+const ReactEvents = require('./src/ReactEvents');
13
+
14
+// TODO: decide on the top-level export form.
15
+// This is hacky but makes it work with both Rollup and Jest.
16
+module.exports = ReactEvents.default || ReactEvents;
packages/react-events/npm/index.js
new
+7
@@ -0,0 +1,7 @@
1
+'use strict';
2
+
3
+if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./cjs/react-events.production.min.js');
5
+} else {
6
+ module.exports = require('./cjs/react-events.development.js');
7
+}
packages/react-events/package.json
new
+35
@@ -0,0 +1,35 @@
1
+{
2
+ "name": "react-events",
3
+ "description": "React is a JavaScript library for building user interfaces.",
4
+ "keywords": [
5
+ "react"
6
+ ],
7
+ "version": "0.1.0",
8
+ "homepage": "https://reactjs.org/",
9
+ "bugs": "https://github.com/facebook/react/issues",
10
+ "license": "MIT",
11
+ "files": [
12
+ "LICENSE",
13
+ "README.md",
14
+ "build-info.json",
15
+ "cjs/",
16
+ "umd/"
17
+ ],
18
+ "main": "index.js",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/facebook/react.git",
22
+ "directory": "packages/react"
23
+ },
24
+ "engines": {
25
+ "node": ">=0.10.0"
26
+ },
27
+ "dependencies": {
28
+ "loose-envify": "^1.1.0"
29
+ },
30
+ "browserify": {
31
+ "transform": [
32
+ "loose-envify"
33
+ ]
34
+ }
35
+}
\ No newline at end of file
packages/react-events/src/ReactEvents.js
new
+25
@@ -0,0 +1,25 @@
1
+/**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
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
+ * @flow
8
+ */
9
+
10
+import {
11
+ REACT_EVENT_TARGET_TYPE,
12
+ REACT_EVENT_TARGET_TOUCH_HIT,
13
+} from 'shared/ReactSymbols';
14
+import type {ReactEventTarget} from 'shared/ReactTypes';
15
+
16
+const TouchHitTarget: ReactEventTarget = {
17
+ $$typeof: REACT_EVENT_TARGET_TYPE,
18
+ type: REACT_EVENT_TARGET_TOUCH_HIT,
19
+};
20
+
21
+const ReactEvents = {
22
+ TouchHitTarget,
23
+};
24
+
25
+export default ReactEvents;
packages/shared/ReactSymbols.js
+5
@@ -53,6 +53,11 @@ export const REACT_EVENT_TARGET_TYPE = hasSymbol
53
? Symbol.for('react.event_target')
54
: 0xead6;
55
56
+// React event targets
57
+export const REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol
58
+ ? Symbol.for('react.event_target.touch_hit')
59
+ : 0xead7;
60
+
61
const MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
62
const FAUX_ITERATOR_SYMBOL = '@@iterator';
63
packages/shared/ReactTypes.js
+1
-1
@@ -95,5 +95,5 @@ export type ReactEvent = {|
95
96
export type ReactEventTarget = {|
97
$$typeof: Symbol | number,
98
- type: string,
98
+ type: Symbol | number,
99
|};
scripts/rollup/bundles.js
+9
@@ -461,6 +461,15 @@ const bundles = [
461
global: 'SchedulerTracing',
462
externals: [],
463
},
464
+
465
+ /******* React Events (experimental) *******/
466
+ {
467
+ bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
468
+ moduleType: ISOMORPHIC,
469
+ entry: 'react-events',
470
+ global: 'ReactEvents',
471
+ externals: [],
472
+ },
473
];
474
475
// Based on deep-freeze by substack (public domain)
scripts/rollup/results.json
+28
@@ -1147,6 +1147,34 @@
1147
"packageName": "scheduler",
1148
"size": 12088,
1149
"gzip": 2473
1150
+ },
1151
+ {
1152
+ "filename": "react-events.development.js",
1153
+ "bundleType": "NODE_DEV",
1154
+ "packageName": "react-events",
1155
+ "size": 1135,
1156
+ "gzip": 623
1157
+ },
1158
+ {
1159
+ "filename": "react-events.production.min.js",
1160
+ "bundleType": "NODE_PROD",
1161
+ "packageName": "react-events",
1162
+ "size": 448,
1163
+ "gzip": 328
1164
+ },
1165
+ {
1166
+ "filename": "ReactEvents-dev.js",
1167
+ "bundleType": "FB_WWW_DEV",
1168
+ "packageName": "react-events",
1169
+ "size": 1106,
1170
+ "gzip": 613
1171
+ },
1172
+ {
1173
+ "filename": "ReactEvents-prod.js",
1174
+ "bundleType": "FB_WWW_PROD",
1175
+ "packageName": "react-events",
1176
+ "size": 643,
1177
+ "gzip": 377
1178
}
1179
]
1180
}
\ No newline at end of file