Skip to content

Commit

Permalink
Adds react-events package for internal testing (#15150)
Browse files Browse the repository at this point in the history
* Adds react-events package for internal testing
  • Loading branch information
trueadm authored Mar 19, 2019
1 parent 7ad7386 commit 55cc921
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/react-events/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `react-events`

This is package is intended for use with the experimental React events API.
16 changes: 16 additions & 0 deletions packages/react-events/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

'use strict';

const ReactEvents = require('./src/ReactEvents');

// TODO: decide on the top-level export form.
// This is hacky but makes it work with both Rollup and Jest.
module.exports = ReactEvents.default || ReactEvents;
7 changes: 7 additions & 0 deletions packages/react-events/npm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-events.production.min.js');
} else {
module.exports = require('./cjs/react-events.development.js');
}
35 changes: 35 additions & 0 deletions packages/react-events/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "react-events",
"description": "React is a JavaScript library for building user interfaces.",
"keywords": [
"react"
],
"version": "0.1.0",
"homepage": "https://reactjs.org/",
"bugs": "https://github.com/facebook/react/issues",
"license": "MIT",
"files": [
"LICENSE",
"README.md",
"build-info.json",
"cjs/",
"umd/"
],
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",
"directory": "packages/react"
},
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
"loose-envify": "^1.1.0"
},
"browserify": {
"transform": [
"loose-envify"
]
}
}
25 changes: 25 additions & 0 deletions packages/react-events/src/ReactEvents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import {
REACT_EVENT_TARGET_TYPE,
REACT_EVENT_TARGET_TOUCH_HIT,
} from 'shared/ReactSymbols';
import type {ReactEventTarget} from 'shared/ReactTypes';

const TouchHitTarget: ReactEventTarget = {
$$typeof: REACT_EVENT_TARGET_TYPE,
type: REACT_EVENT_TARGET_TOUCH_HIT,
};

const ReactEvents = {
TouchHitTarget,
};

export default ReactEvents;
5 changes: 5 additions & 0 deletions packages/shared/ReactSymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export const REACT_EVENT_TARGET_TYPE = hasSymbol
? Symbol.for('react.event_target')
: 0xead6;

// React event targets
export const REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol
? Symbol.for('react.event_target.touch_hit')
: 0xead7;

const MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
const FAUX_ITERATOR_SYMBOL = '@@iterator';

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/ReactTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ export type ReactEvent = {|

export type ReactEventTarget = {|
$$typeof: Symbol | number,
type: string,
type: Symbol | number,
|};
9 changes: 9 additions & 0 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,15 @@ const bundles = [
global: 'SchedulerTracing',
externals: [],
},

/******* React Events (experimental) *******/
{
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
moduleType: ISOMORPHIC,
entry: 'react-events',
global: 'ReactEvents',
externals: [],
},
];

// Based on deep-freeze by substack (public domain)
Expand Down
28 changes: 28 additions & 0 deletions scripts/rollup/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,34 @@
"packageName": "scheduler",
"size": 12088,
"gzip": 2473
},
{
"filename": "react-events.development.js",
"bundleType": "NODE_DEV",
"packageName": "react-events",
"size": 1135,
"gzip": 623
},
{
"filename": "react-events.production.min.js",
"bundleType": "NODE_PROD",
"packageName": "react-events",
"size": 448,
"gzip": 328
},
{
"filename": "ReactEvents-dev.js",
"bundleType": "FB_WWW_DEV",
"packageName": "react-events",
"size": 1106,
"gzip": 613
},
{
"filename": "ReactEvents-prod.js",
"bundleType": "FB_WWW_PROD",
"packageName": "react-events",
"size": 643,
"gzip": 377
}
]
}

0 comments on commit 55cc921

Please sign in to comment.