diff --git a/.flowconfig b/.flowconfig index f9805d50c..19252f320 100644 --- a/.flowconfig +++ b/.flowconfig @@ -28,6 +28,20 @@ packages/react-native-dom/flow-typed [options] module.system.node.resolve_dirname=node_modules module.system.node.resolve_dirname=packages/react-native-dom/node_modules -esproposal.decorators=ignore module.system=haste +module.system.haste.use_name_reducers=true + +# keep the following in sync with server/haste/hasteImpl.js +# get basename +module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1' +# strip .js or .js.flow suffix +module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1' +# strip .dom suffix +module.system.haste.name_reducers='^\(.*\)\.dom$' -> '\1' +module.system.haste.paths.whitelist=/packages/react-native-dom/Libraries/.* +module.system.haste.paths.whitelist=/packages/react-native-dom/RNTester/.* +module.system.haste.paths.whitelist=/packages/react-native-dom/ReactDom/.* + +[version] +^0.75.0 \ No newline at end of file diff --git a/.gitignore b/.gitignore index bcde016b1..2bf9ff300 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,14 @@ +.DS_Store + node_modules lerna-debug.log -TestApp \ No newline at end of file +TestApp + +lib/core/metadata.js +lib/core/MetadataBlog.js + +website/translated_docs +website/build/ +website/yarn.lock +website/node_modules +website/i18n/* \ No newline at end of file diff --git a/Examples/index.html b/Examples/index.html new file mode 100644 index 000000000..b544ff4a8 --- /dev/null +++ b/Examples/index.html @@ -0,0 +1,30 @@ + + + + React Native DOM Examples + + + + +

React Native DOM Examples

+ + \ No newline at end of file diff --git a/docs/doc1.md b/docs/doc1.md new file mode 100644 index 000000000..c0db478e6 --- /dev/null +++ b/docs/doc1.md @@ -0,0 +1,93 @@ +--- +id: doc1 +title: Latin-ish +sidebar_label: Example Page +--- + +Check the [documentation](https://docusaurus.io) for how to use Docusaurus. + +## Lorem + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum +dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem +ipsum dolor sit amet, consectetur adipiscing elit. Vivamus elementum massa eget +nulla aliquet sagittis. Proin odio tortor, vulputate ut odio in, ultrices +ultricies augue. Cras ornare ultrices lorem malesuada iaculis. Etiam sit amet +libero tempor, pulvinar mauris sed, sollicitudin sapien. + +## Mauris In Code + +```js +// Expression bodies +var odds = evens.map((v) => v + 1); +var nums = evens.map((v, i) => v + i); + +// Statement bodies +nums.forEach((v) => { + if (v % 5 === 0) fives.push(v); +}); + +// Lexical this +var bob = { + _name: "Bob", + _friends: [], + printFriends() { + this._friends.forEach((f) => console.log(this._name + " knows " + f)); + } +}; + +// Lexical arguments +function square() { + let example = () => { + let numbers = []; + for (let number of arguments) { + numbers.push(number * number); + } + + return numbers; + }; + + return example(); +} + +square(2, 4, 7.5, 8, 11.5, 21); // returns: [4, 16, 56.25, 64, 132.25, 441] +``` + +## Nulla + +Nulla facilisi. Maecenas sodales nec purus eget posuere. Sed sapien quam, +pretium a risus in, porttitor dapibus erat. Sed sit amet fringilla ipsum, eget +iaculis augue. Integer sollicitudin tortor quis ultricies aliquam. Suspendisse +fringilla nunc in tellus cursus, at placerat tellus scelerisque. Sed tempus elit +a sollicitudin rhoncus. Nulla facilisi. Morbi nec dolor dolor. Orci varius +natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras +et aliquet lectus. Pellentesque sit amet eros nisi. Quisque ac sapien in sapien +congue accumsan. Nullam in posuere ante. Vestibulum ante ipsum primis in +faucibus orci luctus et ultrices posuere cubilia Curae; Proin lacinia leo a nibh +fringilla pharetra. + +## Orci + +Orci varius natoque penatibus et magnis dis parturient montes, nascetur +ridiculus mus. Proin venenatis lectus dui, vel ultrices ante bibendum hendrerit. +Aenean egestas feugiat dui id hendrerit. Orci varius natoque penatibus et magnis +dis parturient montes, nascetur ridiculus mus. Curabitur in tellus laoreet, +eleifend nunc id, viverra leo. Proin vulputate non dolor vel vulputate. +Curabitur pretium lobortis felis, sit amet finibus lorem suscipit ut. Sed non +mollis risus. Duis sagittis, mi in euismod tincidunt, nunc mauris vestibulum +urna, at euismod est elit quis erat. Phasellus accumsan vitae neque eu placerat. +In elementum arcu nec tellus imperdiet, eget maximus nulla sodales. Curabitur eu +sapien eget nisl sodales fermentum. + +## Phasellus + +Phasellus pulvinar ex id commodo imperdiet. Praesent odio nibh, sollicitudin sit +amet faucibus id, placerat at metus. Donec vitae eros vitae tortor hendrerit +finibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque +vitae purus dolor. Duis suscipit ac nulla et finibus. Phasellus ac sem sed dui +dictum gravida. Phasellus eleifend vestibulum facilisis. Integer pharetra nec +enim vitae mattis. Duis auctor, lectus quis condimentum bibendum, nunc dolor +aliquam massa, id bibendum orci velit quis magna. Ut volutpat nulla nunc, sed +interdum magna condimentum non. Sed urna metus, scelerisque vitae consectetur a, +feugiat quis magna. Donec dignissim ornare nisl, eget tempor risus malesuada +quis. diff --git a/docs/doc2.md b/docs/doc2.md new file mode 100644 index 000000000..20c0c95a6 --- /dev/null +++ b/docs/doc2.md @@ -0,0 +1,7 @@ +--- +id: doc2 +title: document number 2 +--- + +This is a link to [another document.](doc3.md) +This is a link to an [external page.](http://www.example.com) diff --git a/docs/doc3.md b/docs/doc3.md new file mode 100644 index 000000000..8d36aa618 --- /dev/null +++ b/docs/doc3.md @@ -0,0 +1,37 @@ +--- +id: doc3 +title: This is document number 3 +--- + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ac euismod odio, eu +consequat dui. Nullam molestie consectetur risus id imperdiet. Proin sodales +ornare turpis, non mollis massa ultricies id. Nam at nibh scelerisque, feugiat +ante non, dapibus tortor. Vivamus volutpat diam quis tellus elementum bibendum. +Praesent semper gravida velit quis aliquam. Etiam in cursus neque. Nam lectus +ligula, malesuada et mauris a, bibendum faucibus mi. Phasellus ut interdum +felis. Phasellus in odio pulvinar, porttitor urna eget, fringilla lectus. +Aliquam sollicitudin est eros. Mauris consectetur quam vitae mauris interdum +hendrerit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. + +Duis et egestas libero, imperdiet faucibus ipsum. Sed posuere eget urna vel +feugiat. Vivamus a arcu sagittis, fermentum urna dapibus, congue lectus. Fusce +vulputate porttitor nisl, ac cursus elit volutpat vitae. Nullam vitae ipsum +egestas, convallis quam non, porta nibh. Morbi gravida erat nec neque bibendum, +eu pellentesque velit posuere. Fusce aliquam erat eu massa eleifend tristique. + +Sed consequat sollicitudin ipsum eget tempus. Integer a aliquet velit. In justo +nibh, pellentesque non suscipit eget, gravida vel lacus. Donec odio ante, +malesuada in massa quis, pharetra tristique ligula. Donec eros est, tristique +eget finibus quis, semper non nisl. Vivamus et elit nec enim ornare placerat. +Sed posuere odio a elit cursus sagittis. + +Phasellus feugiat purus eu tortor ultrices finibus. Ut libero nibh, lobortis et +libero nec, dapibus posuere eros. Sed sagittis euismod justo at consectetur. +Nulla finibus libero placerat, cursus sapien at, eleifend ligula. Vivamus elit +nisl, hendrerit ac nibh eu, ultrices tempus dui. Nam tellus neque, commodo non +rhoncus eu, gravida in risus. Nullam id iaculis tortor. + +Nullam at odio in sem varius tempor sit amet vel lorem. Etiam eu hendrerit nisl. +Fusce nibh mauris, vulputate sit amet ex vitae, congue rhoncus nisl. Sed eget +tellus purus. Nullam tempus commodo erat ut tristique. Cras accumsan massa sit +amet justo consequat eleifend. Integer scelerisque vitae tellus id consectetur. diff --git a/docs/exampledoc4.md b/docs/exampledoc4.md new file mode 100644 index 000000000..6f94ffe91 --- /dev/null +++ b/docs/exampledoc4.md @@ -0,0 +1,6 @@ +--- +id: doc4 +title: Other Document +--- + +this is another document diff --git a/docs/exampledoc5.md b/docs/exampledoc5.md new file mode 100644 index 000000000..92e2d0d5b --- /dev/null +++ b/docs/exampledoc5.md @@ -0,0 +1,6 @@ +--- +id: doc5 +title: Fifth Document +--- + +Another one diff --git a/package.json b/package.json index e9d23a1f5..a2a1914f7 100644 --- a/package.json +++ b/package.json @@ -8,15 +8,33 @@ "bugs": { "url": "https://github.com/vincentriemer/react-native-dom/issues" }, + "repository": { + "type": "git", + "url": "https://github.com/vincentriemer/react-native-dom.git" + }, "license": "MIT", "author": { "name": "Vincent Riemer", "email": "vincentriemer+rndom@gmail.com", "url": "https://vincentriemer.com" }, - "repository": { - "type": "git", - "url": "https://github.com/vincentriemer/react-native-dom.git" + "workspaces": { + "packages": [ + "packages/*" + ], + "nohoist": [ + "**/react-native", + "**/react-native/**", + "**/@babel/runtime", + "**/@abel/runtime/**", + "**/pepjs", + "**/pepjs/**", + "**/webcomponentsjs", + "**/webcomponentsjs/**", + "**/web-animations-js", + "**/web-animations-js/**", + "**/react-native-dom/**" + ] }, "scripts": { "clean": "shx rm -rf packages/*/lib", @@ -42,13 +60,14 @@ "all-contributors-cli": "^4.11.1", "babel-eslint": "^8.2.3", "cz-conventional-changelog": "^2.1.0", - "eslint": "^4.19.1", + "eslint": "^5.0.1", "eslint-import-resolver-lerna": "^1.0.0", "eslint-plugin-import": "^2.11.0", "eslint-plugin-prettier": "^2.6.0", - "flow-bin": "^0.73.0", + "flow-bin": "^0.75.0", "husky": "^0.14.3", "lerna": "^2.4.0", + "lint-staged": "^7.2.2", "prettier": "^1.12.1", "shelljs": "^0.8.2", "shx": "^0.2.2", @@ -56,15 +75,17 @@ "wait-port": "^0.2.2" }, "lint-staged": { - "package.json": ["sort-package-json", "git add"], - "*.js": ["eslint --fix", "git add"], - "*.{js,json,css,md}": ["prettier --write", "git add"] - }, - "resolutions": { - "react": "^16.3.1" - }, - "workspaces": { - "packages": ["packages/*"], - "nohoist": ["**/react-native", "**/react-native/**"] + "package.json": [ + "sort-package-json", + "git add" + ], + "*.js": [ + "eslint --fix", + "git add" + ], + "*.{js,json,css,md}": [ + "prettier --write", + "git add" + ] } } diff --git a/packages/react-native-dom/.babelrc b/packages/react-native-dom/.babelrc index 76d54e09b..6dfb28ac4 100644 --- a/packages/react-native-dom/.babelrc +++ b/packages/react-native-dom/.babelrc @@ -1,32 +1,23 @@ { - "sourceMaps": "inline", - "presets": ["flow", "react-native"], + "presets": ["@babel/flow", "module:metro-react-native-babel-preset"], "plugins": [ - "syntax-trailing-function-commas", - "transform-object-rest-spread", - "transform-decorators-legacy", - "transform-class-properties", + "@babel/plugin-syntax-dynamic-import", + "@babel/plugin-proposal-object-rest-spread", + ["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": true }], [ - "transform-runtime", + "@babel/plugin-transform-runtime", { "helpers": true, - "polyfill": false, "regenerator": true } ], "transform-inline-environment-variables", "preval", - [ - "babel-plugin-transform-builtin-classes", - { - "globals": ["HTMLElement"] - } - ], "./scripts/babel-plugin-haste-require" ], "env": { "lib": { - "presets": ["flow"] + "presets": ["@babel/flow"] } } } diff --git a/packages/react-native-dom/Examples/index.html b/packages/react-native-dom/Examples/index.html deleted file mode 100644 index c276fab27..000000000 --- a/packages/react-native-dom/Examples/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - React Native DOM Examples - - - - -

React Native DOM Examples

- - \ No newline at end of file diff --git a/packages/react-native-dom/Libraries/Components/Clipboard/Clipboard.dom.js b/packages/react-native-dom/Libraries/Components/Clipboard/Clipboard.dom.js new file mode 100644 index 000000000..78ced09d2 --- /dev/null +++ b/packages/react-native-dom/Libraries/Components/Clipboard/Clipboard.dom.js @@ -0,0 +1,9 @@ +// @flow + +// TODO: Replace with real implementation +module.exports = { + getString() { + return Promise.resolve(""); + }, + setString(content: string) {} +}; diff --git a/packages/react-native-dom/Libraries/Components/TextInput/TextInputState.dom.js b/packages/react-native-dom/Libraries/Components/TextInput/TextInputState.dom.js index 999cd8bc0..8b273a2ce 100644 --- a/packages/react-native-dom/Libraries/Components/TextInput/TextInputState.dom.js +++ b/packages/react-native-dom/Libraries/Components/TextInput/TextInputState.dom.js @@ -1,76 +1,91 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * - * @providesModule TextInputState - * @flow * * This class is responsible for coordinating the "focused" * state for TextInputs. All calls relating to the keyboard * should be funneled through here + * + * @format + * @flow */ + "use strict"; -var Platform = require("Platform"); -var UIManager = require("UIManager"); +const Platform = require("Platform"); +const UIManager = require("UIManager"); -var TextInputState = { - /** - * Internal state - */ - _currentlyFocusedID: (null: ?number), +let currentlyFocusedID: ?number = null; +const inputs = new Set(); - /** - * Returns the ID of the currently focused text field, if one exists - * If no text field is focused it returns null - */ - currentlyFocusedField: function(): ?number { - return this._currentlyFocusedID; - }, +/** + * Returns the ID of the currently focused text field, if one exists + * If no text field is focused it returns null + */ +function currentlyFocusedField(): ?number { + return currentlyFocusedID; +} - /** - * @param {number} TextInputID id of the text field to focus - * Focuses the specified text field - * noop if the text field was already focused - */ - focusTextInput: function(textFieldID: ?number) { - if (this._currentlyFocusedID !== textFieldID && textFieldID !== null) { - this._currentlyFocusedID = textFieldID; - if (Platform.OS === "ios" || Platform.OS === "web") { - UIManager.focus(textFieldID); - } else if (Platform.OS === "android") { - UIManager.dispatchViewManagerCommand( - textFieldID, - UIManager.AndroidTextInput.Commands.focusTextInput, - null - ); - } +/** + * @param {number} TextInputID id of the text field to focus + * Focuses the specified text field + * noop if the text field was already focused + */ +function focusTextInput(textFieldID: ?number) { + if (currentlyFocusedID !== textFieldID && textFieldID !== null) { + currentlyFocusedID = textFieldID; + if (Platform.OS === "ios" || Platform.OS === "dom") { + UIManager.focus(textFieldID); + } else if (Platform.OS === "android") { + UIManager.dispatchViewManagerCommand( + textFieldID, + UIManager.AndroidTextInput.Commands.focusTextInput, + null + ); } - }, + } +} - /** - * @param {number} textFieldID id of the text field to unfocus - * Unfocuses the specified text field - * noop if it wasn't focused - */ - blurTextInput: function(textFieldID: ?number) { - if (this._currentlyFocusedID === textFieldID && textFieldID !== null) { - this._currentlyFocusedID = null; - if (Platform.OS === "ios" || Platform.OS === "web") { - UIManager.blur(textFieldID); - } else if (Platform.OS === "android") { - UIManager.dispatchViewManagerCommand( - textFieldID, - UIManager.AndroidTextInput.Commands.blurTextInput, - null - ); - } +/** + * @param {number} textFieldID id of the text field to unfocus + * Unfocuses the specified text field + * noop if it wasn't focused + */ +function blurTextInput(textFieldID: ?number) { + if (currentlyFocusedID === textFieldID && textFieldID !== null) { + currentlyFocusedID = null; + if (Platform.OS === "ios" || Platform.OS === "dom") { + UIManager.blur(textFieldID); + } else if (Platform.OS === "android") { + UIManager.dispatchViewManagerCommand( + textFieldID, + UIManager.AndroidTextInput.Commands.blurTextInput, + null + ); } } -}; +} -module.exports = TextInputState; +function registerInput(textFieldID: number) { + inputs.add(textFieldID); +} + +function unregisterInput(textFieldID: number) { + inputs.delete(textFieldID); +} + +function isTextInput(textFieldID: number) { + return inputs.has(textFieldID); +} + +module.exports = { + currentlyFocusedField, + focusTextInput, + blurTextInput, + registerInput, + unregisterInput, + isTextInput +}; diff --git a/packages/react-native-dom/Libraries/Components/WebView/WebView.dom.js b/packages/react-native-dom/Libraries/Components/WebView/WebView.dom.js index ef3cb0385..5a20ccfc2 100644 --- a/packages/react-native-dom/Libraries/Components/WebView/WebView.dom.js +++ b/packages/react-native-dom/Libraries/Components/WebView/WebView.dom.js @@ -212,7 +212,10 @@ class WebView extends React.Component { * - fast: 0.99 (the default for iOS web view) * @platform ios */ - decelerationRate: ScrollView.propTypes.decelerationRate, + decelerationRate: PropTypes.oneOfType([ + PropTypes.oneOf(["fast", "normal"]), + PropTypes.number + ]), /** * Boolean value that determines whether scrolling is enabled in the * `WebView`. The default value is `true`. diff --git a/packages/react-native-dom/Libraries/Components/button.dom.js b/packages/react-native-dom/Libraries/Components/button.dom.js index 4201d4e7a..e17d9c881 100644 --- a/packages/react-native-dom/Libraries/Components/button.dom.js +++ b/packages/react-native-dom/Libraries/Components/button.dom.js @@ -1,14 +1,13 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * - * @providesModule Button + * @format * @flow */ + "use strict"; const ColorPropType = require("ColorPropType"); @@ -38,6 +37,9 @@ const invariant = require("fbjs/lib/invariant"); * Example usage: * * ``` + * import { Button } from 'react-native'; + * ... + * *