diff --git a/.gitignore b/.gitignore index 35881a0e0..fb78e4ccb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ **/android/build/ **/app/build/ +**/target/.rustc_info.json +**/target/CACHEDIR.TAG +**/target/debug/ +**/target/release/ *.log *.tgz *.xcworkspace/ @@ -13,12 +17,10 @@ .yarn/* !.yarn/plugins/ !.yarn/releases/ -/incubator/*/bin/ /incubator/*/dist/ /incubator/*/lib/ /packages/*/*.LICENSE.txt /packages/*/*/rnx-build/ -/packages/*/bin/ /packages/*/dist/ /packages/*/ios/build /packages/*/lib/ diff --git a/incubator/@react-native-webapis/scan/Cargo.lock b/incubator/@react-native-webapis/scan/Cargo.lock new file mode 100644 index 000000000..2f47da7b3 --- /dev/null +++ b/incubator/@react-native-webapis/scan/Cargo.lock @@ -0,0 +1,993 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "aho-corasick" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" +dependencies = [ + "memchr", +] + +[[package]] +name = "ast_node" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c09c69dffe06d222d072c878c3afe86eee2179806f20503faec97250268b4c24" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "better_scoped_tls" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "794edcc9b3fb07bb4aecaa11f093fd45663b4feadb782d68303a2268bc2701de" +dependencies = [ + "scoped-tls", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "crossbeam-channel" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "from_variant" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ec5dc38ee19078d84a692b1c41181ff9f94331c76cee66ff0208c770b5e54f" +dependencies = [ + "pmutil", + "proc-macro2", + "swc_macros_common", + "syn", +] + +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "is-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4467ed1321b310c2625c5aa6c1b1ffc5de4d9e42668cf697a08fb033ee8265e" +dependencies = [ + "Inflector", + "pmutil", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "lock_api" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", + "serde", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "phf_generator" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" + +[[package]] +name = "pmutil" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "proc-macro2" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "regex" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scan" +version = "0.1.0" +dependencies = [ + "rayon", + "swc_common", + "swc_ecma_parser", + "swc_ecma_visit", + "swc_ecmascript", + "walkdir", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.185" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.185" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + +[[package]] +name = "smallvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" + +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "stacker" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "winapi", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "string_cache" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot", + "phf_shared", + "precomputed-hash", + "serde", +] + +[[package]] +name = "string_cache_codegen" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", +] + +[[package]] +name = "string_enum" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fa4d4f81d7c05b9161f8de839975d3326328b8ba2831164b465524cc2f55252" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn", +] + +[[package]] +name = "swc_atoms" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8066e17abb484602da673e2d35138ab32ce53f26368d9c92113510e1659220b" +dependencies = [ + "once_cell", + "rustc-hash", + "serde", + "string_cache", + "string_cache_codegen", + "triomphe", +] + +[[package]] +name = "swc_common" +version = "0.31.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de5823ef063f116ad281cde9700f5be6dfb182e543ce3f62c42cee1c03ffbc6b" +dependencies = [ + "ast_node", + "better_scoped_tls", + "cfg-if", + "either", + "from_variant", + "new_debug_unreachable", + "num-bigint", + "once_cell", + "rustc-hash", + "serde", + "siphasher", + "string_cache", + "swc_atoms", + "swc_eq_ignore_macros", + "swc_visit", + "tracing", + "unicode-width", + "url", +] + +[[package]] +name = "swc_ecma_ast" +version = "0.107.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7191c8c57af059b75a2aadc927a2608c3962d19e4d09ce8f9c3f03739ddf833" +dependencies = [ + "bitflags 2.4.0", + "is-macro", + "num-bigint", + "scoped-tls", + "string_enum", + "swc_atoms", + "swc_common", + "unicode-id", +] + +[[package]] +name = "swc_ecma_parser" +version = "0.137.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c0d554865a63bfa58cf1c433fa91d7d4adf40030fa8e4530e8065d0578166a" +dependencies = [ + "either", + "num-bigint", + "num-traits", + "serde", + "smallvec", + "smartstring", + "stacker", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "tracing", + "typed-arena", +] + +[[package]] +name = "swc_ecma_visit" +version = "0.93.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb23a48abd9f5731b6275dbf4ea89f6e03dc60b7c8e3e1e383bb4a6c39fd7e25" +dependencies = [ + "num-bigint", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_visit", + "tracing", +] + +[[package]] +name = "swc_ecmascript" +version = "0.231.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a70f499b1c90d9d787936163aa69619767d297b895697a02f436c2311d102f3a" +dependencies = [ + "swc_ecma_ast", + "swc_ecma_parser", +] + +[[package]] +name = "swc_eq_ignore_macros" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05a95d367e228d52484c53336991fdcf47b6b553ef835d9159db4ba40efb0ee8" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "swc_macros_common" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a273205ccb09b51fabe88c49f3b34c5a4631c4c00a16ae20e03111d6a42e832" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "swc_visit" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c337fbb2d191bf371173dea6a957f01899adb8f189c6c31b122a6cfc98fc3" +dependencies = [ + "either", + "swc_visit_macros", +] + +[[package]] +name = "swc_visit_macros" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f322730fb82f3930a450ac24de8c98523af7d34ab8cb2f46bcb405839891a99" +dependencies = [ + "Inflector", + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn", +] + +[[package]] +name = "syn" +version = "2.0.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "triomphe" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee8098afad3fb0c54a9007aab6804558410503ad676d4633f9c2559a00ac0f" +dependencies = [ + "serde", + "stable_deref_trait", +] + +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-id" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d70b6494226b36008c8366c288d77190b3fad2eb4c10533139c1c1f461127f1a" + +[[package]] +name = "unicode-ident" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "url" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/incubator/@react-native-webapis/scan/Cargo.toml b/incubator/@react-native-webapis/scan/Cargo.toml new file mode 100644 index 000000000..4957bb692 --- /dev/null +++ b/incubator/@react-native-webapis/scan/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "scan" +version = "0.1.0" +authors = ["Tommy Nguyen <4123478+tido64@users.noreply.github.com>"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rayon = "1.7.0" +swc_common = "0.31.21" +swc_ecma_parser = "0.137.15" +swc_ecma_visit = "0.93.7" +swc_ecmascript = "0.231.40" +walkdir = "2.3.3" + +[profile.release] +# Tell `rustc` to optimize for small code size. +opt-level = "s" diff --git a/incubator/@react-native-webapis/scan/README.md b/incubator/@react-native-webapis/scan/README.md new file mode 100644 index 000000000..2f6001dd1 --- /dev/null +++ b/incubator/@react-native-webapis/scan/README.md @@ -0,0 +1,31 @@ +# @react-native-webapis/scan + +[![Build](https://github.com/microsoft/rnx-kit/actions/workflows/build.yml/badge.svg)](https://github.com/microsoft/rnx-kit/actions/workflows/build.yml) +[![npm version](https://img.shields.io/npm/v/@react-native-webapis/scan)](https://www.npmjs.com/package/@react-native-webapis/scan) + +`@react-native-webapis/scan` is a tool for scanning your code bases for +potential uses of [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API). + +## Build + +1. [Install Rust](https://www.rust-lang.org/learn/get-started) +2. Build: `cargo build --release` + +A binary will be output at `target/release/scan`. Make note of this location or +copy the binary somewhere that you can easily access later. + +## Usage + +```sh +./scan +``` + +This is currently a very simple tool. It takes no arguments and simply scans all +`.js` and `.ts` files it finds in the current working directory. For each file +it finds, it tries to parse using [SWC](https://swc.rs/). Once parsed, it will +try to count all references to `navigator.*` and any identifiers listed in +`src/web_apis.rs`. Files or directories that are listed in `src/ignored_dirs.rs` +are skipped. + +You can see examples of output in `merge.mjs`. This is a script we use to +aggregate the output from multiple repositories. diff --git a/incubator/@react-native-webapis/scan/merge.mjs b/incubator/@react-native-webapis/scan/merge.mjs new file mode 100644 index 000000000..ca06c74c9 --- /dev/null +++ b/incubator/@react-native-webapis/scan/merge.mjs @@ -0,0 +1,669 @@ +// Last updated 2023-08-30 +const data = [ + { + Range: 791, + "navigator.userAgent": 513, + Event: 465, + Node: 229, + DOMException: 219, + MutationObserver: 124, + Selection: 116, + DOMParser: 113, + CSSStyleDeclaration: 104, + "navigator.product": 101, + MessageChannel: 91, + "navigator.sendBeacon": 82, + Element: 80, + CustomEvent: 79, + TreeWalker: 65, + MouseEvent: 59, + "navigator.language": 53, + Comment: 52, + "navigator.onLine": 49, + DOMRect: 48, + ResizeObserver: 46, + "navigator.userLanguage": 44, + Table: 44, + Document: 41, + Notification: 40, + Worker: 39, + Report: 38, + NodeList: 34, + Text: 33, + TextDecoder: 32, + MessageEvent: 27, + CompileError: 27, + IntersectionObserver: 24, + Cache: 24, + "navigator.maxTouchPoints": 23, + "navigator.scheduling": 22, + "navigator.userAgentData": 21, + CSSStyleSheet: 18, + StyleSheet: 17, + TextEncoder: 17, + NamedNodeMap: 17, + "navigator.clipboard": 14, + "navigator.appName": 13, + Clipboard: 13, + "navigator.platform": 12, + ProcessingInstruction: 12, + Attr: 12, + XMLSerializer: 12, + "navigator.hardwareConcurrency": 12, + DOMRectReadOnly: 11, + "navigator.connection": 9, + "navigator.languages": 9, + DocumentFragment: 8, + ImageData: 8, + XPathExpression: 8, + ErrorEvent: 8, + Module: 7, + KeyboardEvent: 7, + Storage: 6, + DocumentType: 6, + ResizeObserverEntry: 6, + CDATASection: 6, + WheelEvent: 5, + IDBFactory: 5, + "navigator.appVersion": 5, + FileList: 5, + Credential: 5, + Window: 5, + WritableStream: 4, + "navigator.doNotTrack": 4, + "navigator.deviceMemory": 4, + DataTransfer: 4, + XPathResult: 4, + "navigator.virtualKeyboard": 4, + PerformanceObserver: 4, + ReadableStream: 4, + "navigator.msMaxTouchPoints": 4, + IDBKeyRange: 4, + DOMQuad: 3, + "navigator.vendor": 3, + Lock: 3, + CloseEvent: 3, + TouchEvent: 3, + "navigator.keyboard": 3, + "navigator.storage": 2, + ResizeObserverSize: 2, + Permissions: 2, + MediaSource: 2, + AudioContext: 2, + Path2D: 2, + "navigator.serviceWorker": 2, + EventSource: 2, + IDBCursorWithValue: 2, + IDBTransaction: 2, + TransformStream: 2, + IDBIndex: 2, + IDBDatabase: 2, + XPathEvaluator: 2, + IDBObjectStore: 2, + IDBOpenDBRequest: 2, + FocusEvent: 1, + PermissionStatus: 1, + PointerEvent: 1, + "navigator.mozGetUserMedia": 1, + "navigator.cookieEnabled": 1, + DragEvent: 1, + "navigator.go": 1, + ClipboardItem: 1, + "navigator.msSaveBlob": 1, + IDBVersionChangeEvent: 1, + BroadcastChannel: 1, + Location: 1, + ShadowRoot: 1, + "navigator.replace": 1, + "navigator.push": 1, + "navigator.createHref": 1, + "navigator.msSaveOrOpenBlob": 1, + IDBRequest: 1, + "navigator.getUserMedia": 1, + Plugin: 1, + }, + { + "navigator.userAgent": 6064, + Range: 943, + Event: 644, + Node: 593, + Worker: 441, + CustomEvent: 404, + Selection: 388, + PerformanceObserver: 309, + MutationObserver: 309, + MouseEvent: 297, + DOMException: 250, + "navigator.platform": 239, + ResizeObserver: 197, + IntersectionObserver: 196, + Element: 190, + MessageChannel: 162, + "navigator.product": 142, + TextDecoder: 136, + "navigator.language": 128, + TreeWalker: 128, + MessageEvent: 116, + DOMParser: 108, + CSSStyleDeclaration: 105, + "navigator.onLine": 99, + "navigator.maxTouchPoints": 99, + "navigator.hardwareConcurrency": 93, + Notification: 89, + RuntimeError: 85, + "navigator.mediaDevices": 82, + DOMRect: 82, + KeyboardEvent: 80, + Report: 76, + Document: 74, + Cache: 66, + "navigator.sendBeacon": 64, + ImageData: 63, + AudioContext: 58, + StyleSheet: 56, + "navigator.vendor": 52, + XMLSerializer: 51, + Module: 51, + HTMLElement: 49, + TextEncoder: 47, + Text: 45, + RTCPeerConnection: 45, + NodeList: 42, + Animation: 39, + TransformStream: 37, + Comment: 37, + "navigator.requestMediaKeySystemAccess": 35, + OffscreenCanvas: 31, + "navigator.getUserMedia": 30, + "navigator.appName": 30, + Location: 29, + "navigator.connection": 28, + CompileError: 27, + Path2D: 27, + NamedNodeMap: 25, + History: 24, + "navigator.clipboard": 24, + "navigator.userLanguage": 22, + ReadableStream: 19, + "navigator.createHref": 18, + "navigator.go": 18, + "navigator.push": 18, + "navigator.vibrate": 18, + Table: 18, + "navigator.replace": 18, + DragEvent: 17, + "navigator.deviceMemory": 17, + "navigator.scheduling": 16, + LinkError: 16, + Storage: 16, + ProcessingInstruction: 16, + Attr: 16, + MediaStream: 15, + "navigator.languages": 15, + "navigator.userAgentData": 14, + "navigator.msLaunchUri": 14, + "navigator.webkitGetUserMedia": 13, + BroadcastChannel: 13, + HTMLCollection: 12, + RTCSessionDescription: 12, + DocumentFragment: 12, + InputEvent: 12, + Clipboard: 12, + Lock: 11, + Plugin: 11, + XPathExpression: 10, + DOMMatrix: 10, + EventSource: 10, + "navigator.msSaveBlob": 10, + WritableStreamDefaultWriter: 10, + ReadableStreamDefaultReader: 10, + ReadableStreamBYOBReader: 10, + ErrorEvent: 9, + VideoEncoder: 9, + MediaRecorder: 9, + "navigator.getGamepads": 9, + AudioWorkletNode: 9, + VideoFrame: 9, + "navigator.appVersion": 9, + "navigator.msSaveOrOpenBlob": 9, + PerformanceEntry: 8, + CDATASection: 8, + DocumentType: 8, + MediaSource: 8, + Window: 8, + PointerEvent: 7, + FileList: 7, + DataTransfer: 7, + "navigator.mimeTypes": 7, + "navigator.mozGetUserMedia": 7, + CloseEvent: 7, + WritableStream: 6, + XSLTProcessor: 6, + ClipboardEvent: 6, + SpeechSynthesisUtterance: 6, + "navigator.mediaSession": 6, + HTMLHeadingElement: 6, + HTMLDocument: 6, + "navigator.callback": 6, + VTTCue: 5, + ResizeObserverEntry: 5, + "navigator.serviceWorker": 5, + "navigator.xr": 5, + XPathResult: 5, + DOMPoint: 4, + OfflineAudioContext: 4, + MessagePort: 4, + IntersectionObserverEntry: 4, + "navigator.mediaCapabilities": 4, + HTMLTableSectionElement: 3, + "navigator.virtualKeyboard": 3, + "navigator.webkitGetGamepads": 3, + "navigator.pointerEnabled": 3, + StorageEvent: 3, + MediaMetadata: 3, + DOMQuad: 3, + IDBFactory: 3, + HTMLImageElement: 2, + HTMLModElement: 2, + HTMLQuoteElement: 2, + "navigator.doNotTrack": 2, + MediaQueryList: 2, + HTMLFrameElement: 2, + FileSystem: 2, + CharacterData: 2, + SVGTextElement: 2, + HTMLTableCellElement: 2, + ClipboardItem: 2, + "navigator.keyboard": 2, + UIEvent: 2, + Permissions: 2, + TextDecoderStream: 2, + HTMLLegendElement: 2, + HTMLOptionElement: 2, + HTMLTableColElement: 2, + CanvasGradient: 2, + FocusEvent: 2, + MediaStreamTrack: 2, + SubtleCrypto: 2, + CSSStyleSheet: 2, + "navigator.gpu": 2, + CanvasRenderingContext2D: 2, + AnimationEvent: 2, + Screen: 1, + HTMLAnchorElement: 1, + "navigator.navigate": 1, + HTMLHeadElement: 1, + HTMLHRElement: 1, + HTMLTableElement: 1, + HTMLParamElement: 1, + HTMLFormElement: 1, + CSSRule: 1, + HTMLSelectElement: 1, + EncodedVideoChunk: 1, + "navigator.storage": 1, + HTMLObjectElement: 1, + VideoDecoder: 1, + IDBRequest: 1, + HTMLCanvasElement: 1, + HTMLParagraphElement: 1, + StyleSheetList: 1, + HTMLMetaElement: 1, + DOMImplementation: 1, + WheelEvent: 1, + HTMLLabelElement: 1, + HTMLBRElement: 1, + HTMLButtonElement: 1, + HTMLTitleElement: 1, + HTMLBodyElement: 1, + HTMLInputElement: 1, + CSSRuleList: 1, + HTMLIFrameElement: 1, + "navigator.webkitGamepads": 1, + HTMLSpanElement: 1, + HTMLStyleElement: 1, + HTMLTextAreaElement: 1, + HTMLBaseElement: 1, + HTMLPreElement: 1, + HTMLDivElement: 1, + HTMLLinkElement: 1, + PageTransitionEvent: 1, + "navigator.msGetGamepads": 1, + HTMLUnknownElement: 1, + HTMLLIElement: 1, + "navigator.msGetUserMedia": 1, + HTMLFieldSetElement: 1, + HTMLOListElement: 1, + HTMLHtmlElement: 1, + Navigator: 1, + HTMLUListElement: 1, + HTMLDListElement: 1, + TouchEvent: 1, + "navigator.cpuClass": 1, + HTMLAreaElement: 1, + HTMLMapElement: 1, + HTMLTableRowElement: 1, + HTMLOptGroupElement: 1, + HTMLScriptElement: 1, + }, + { + Event: 400, + Selection: 80, + MouseEvent: 78, + Range: 69, + MessageEvent: 69, + CustomEvent: 65, + "navigator.userAgent": 65, + DOMParser: 47, + KeyboardEvent: 33, + ResizeObserver: 31, + "navigator.platform": 20, + IntersectionObserver: 19, + MutationObserver: 18, + Screen: 15, + "navigator.msSaveBlob": 14, + "navigator.maxTouchPoints": 13, + "navigator.mediaDevices": 12, + PerformanceObserver: 12, + "navigator.left": 12, + "navigator.language": 11, + "navigator.top": 11, + "navigator.onLine": 11, + "navigator.zoomedMax": 10, + ReadableStream: 9, + "navigator.appVersion": 9, + Worker: 9, + "navigator.hasDragged": 9, + "navigator.chart": 8, + DataTransfer: 8, + "navigator.size": 8, + "navigator.zoomedMin": 8, + MessageChannel: 8, + "navigator.appCodeName": 7, + "navigator.clipboard": 7, + "navigator.otherHandlePos": 7, + "navigator.msLaunchUri": 6, + "navigator.series": 6, + "navigator.render": 6, + XMLSerializer: 6, + "navigator.height": 6, + "navigator.scrollbar": 6, + "navigator.xAxis": 6, + Notification: 5, + Comment: 5, + PopStateEvent: 5, + TextDecoder: 5, + "navigator.fixedExtreme": 5, + DOMException: 5, + Node: 5, + "navigator.hasNavigatorData": 5, + Document: 5, + "navigator.fixedWidth": 5, + Module: 4, + ClipboardEvent: 4, + MessagePort: 4, + TextEncoder: 4, + "navigator.baseSeries": 4, + "navigator.msSaveOrOpenBlob": 4, + EventSource: 4, + "navigator.grabbedCenter": 3, + "navigator.onMouseUp": 3, + "navigator.opposite": 3, + "navigator.stickToMax": 3, + ClipboardItem: 3, + ImageData: 3, + VideoEncoder: 3, + VTTCue: 3, + "navigator.grabbedRight": 3, + "navigator.range": 3, + "navigator.scrollbarHeight": 3, + Path2D: 3, + "navigator.stickToMin": 3, + "navigator.grabbedLeft": 3, + "navigator.dragOffset": 3, + "navigator.rendered": 2, + PerformanceEntry: 2, + ReadableStreamBYOBReader: 2, + "navigator.drawHandle": 2, + "navigator.getPartsEvents": 2, + FontFace: 2, + "navigator.outlineHeight": 2, + WritableStreamDefaultWriter: 2, + Navigator: 2, + "navigator.yAxis": 2, + "navigator.serviceWorker": 2, + ReadableStreamDefaultReader: 2, + "navigator.navigatorEnabled": 2, + "navigator.mimeTypes": 2, + "navigator.navigatorGroup": 1, + "navigator.userLanguage": 1, + "navigator.enabled": 1, + "navigator.addChartEvents": 1, + "navigator.eventsToUnbind": 1, + "navigator.renderElements": 1, + "navigator.pointerEnabled": 1, + Table: 1, + "navigator.outline": 1, + "navigator.languages": 1, + "navigator.storage": 1, + DocumentFragment: 1, + Storage: 1, + XSLTProcessor: 1, + MediaRecorder: 1, + Animation: 1, + "navigator.drawOutline": 1, + "navigator.onMouseMove": 1, + "navigator.addMouseEvents": 1, + "navigator.xr": 1, + DragEvent: 1, + "navigator.drawMasks": 1, + PointerEvent: 1, + "navigator.updatedDataHandler": 1, + "navigator.navigatorSize": 1, + "navigator.addBaseSeriesEvents": 1, + "navigator.setBaseSeries": 1, + BroadcastChannel: 1, + AudioContext: 1, + Location: 1, + "navigator.shades": 1, + IntersectionObserverEntry: 1, + FocusEvent: 1, + "navigator.permissions": 1, + MediaSource: 1, + "navigator.updateNavigatorSeries": 1, + "navigator.mouseUpHandler": 1, + "navigator.mouseMoveHandler": 1, + "navigator.navigatorOptions": 1, + }, + { + Range: 2419, + "navigator.userAgent": 974, + Selection: 591, + Event: 498, + EventSource: 460, + MouseEvent: 322, + Node: 238, + Element: 186, + CustomEvent: 174, + MessageChannel: 141, + MutationObserver: 132, + MessageEvent: 120, + TextDecoder: 103, + Worker: 103, + DOMParser: 93, + "navigator.platform": 91, + ResizeObserver: 90, + RuntimeError: 90, + ImageData: 89, + "navigator.sendBeacon": 88, + DOMException: 88, + CompileError: 81, + "navigator.product": 76, + DOMRect: 71, + Comment: 70, + "navigator.onLine": 68, + KeyboardEvent: 68, + TreeWalker: 65, + Document: 63, + ReadableStream: 62, + "navigator.maxTouchPoints": 60, + CSSStyleDeclaration: 57, + Text: 42, + "navigator.vendor": 41, + "navigator.language": 41, + StyleSheet: 40, + Notification: 40, + Table: 39, + OffscreenCanvas: 38, + Cache: 37, + TextEncoder: 36, + "navigator.hardwareConcurrency": 36, + XMLSerializer: 30, + "navigator.clipboard": 28, + SVGTextElement: 28, + IntersectionObserver: 27, + Report: 25, + PerformanceObserver: 25, + "navigator.msSaveBlob": 24, + Path2D: 23, + "navigator.appName": 22, + Module: 20, + "navigator.doNotTrack": 20, + NodeList: 20, + FontFace: 20, + Animation: 20, + "navigator.push": 18, + "navigator.replace": 18, + "navigator.createHref": 18, + "navigator.go": 18, + ProcessingInstruction: 16, + "navigator.connection": 16, + XPathEvaluator: 15, + DOMMatrix: 15, + Attr: 14, + Plugin: 14, + ErrorEvent: 14, + "navigator.appVersion": 14, + "navigator.userLanguage": 14, + ReadableStreamDefaultReader: 14, + ReadableStreamBYOBReader: 14, + Window: 14, + WritableStreamDefaultWriter: 14, + "navigator.deviceMemory": 13, + Clipboard: 13, + NamedNodeMap: 12, + "navigator.mediaDevices": 12, + "navigator.msLaunchUri": 12, + DOMRectReadOnly: 11, + AudioContext: 11, + "navigator.userAgentData": 11, + CloseEvent: 11, + XPathExpression: 10, + Credential: 10, + ClipboardItem: 10, + "navigator.encodeLocation": 9, + Permissions: 9, + History: 9, + WritableStream: 9, + Location: 9, + "navigator.getGamepads": 9, + ResizeObserverEntry: 8, + "navigator.virtualKeyboard": 8, + Storage: 8, + DragEvent: 7, + VTTCue: 7, + "navigator.storage": 7, + PointerEvent: 7, + "navigator.findNearbyNodes": 7, + MediaSource: 6, + "navigator.getUserMedia": 6, + ReadableStreamDefaultController: 6, + WritableStreamDefaultController: 6, + TransformStreamDefaultController: 6, + ReadableStreamBYOBRequest: 6, + DocumentFragment: 6, + "navigator.scheduling": 6, + "navigator.getClosestTextRange": 6, + Instance: 6, + DOMQuad: 6, + ReadableByteStreamController: 6, + MediaRecorder: 5, + BroadcastChannel: 5, + "navigator.recyclebinNode": 5, + "navigator.xr": 5, + FileList: 5, + TransformStream: 5, + XPathResult: 5, + "navigator.vendorSub": 4, + ResizeObserverSize: 4, + "navigator.permissions": 4, + DocumentType: 4, + CDATASection: 4, + LinkError: 4, + "navigator.mozGetUserMedia": 3, + TextMetrics: 3, + WheelEvent: 3, + LockManager: 3, + "navigator.keyboard": 3, + "navigator.returnToContainingPage": 3, + "navigator.updateRecyclebinState": 3, + "navigator.webkitGetGamepads": 3, + "navigator.getPageContent": 3, + MediaQueryListEvent: 2, + "navigator.updateActiveState": 2, + TouchEvent: 2, + MessagePort: 2, + IdleDeadline: 2, + "navigator.serviceWorker": 2, + SVGElement: 2, + "navigator.ink": 2, + ShadowRoot: 2, + DOMPoint: 2, + XSLTProcessor: 2, + AnimationEvent: 2, + "navigator.plugins": 2, + "navigator.mozConnection": 2, + DataTransfer: 2, + PopStateEvent: 2, + SubtleCrypto: 2, + "navigator.webkitConnection": 2, + "navigator.gpu": 2, + FocusEvent: 1, + "navigator.pointerEnabled": 1, + "navigator.msGetGamepads": 1, + HTMLElement: 1, + CSSStyleSheet: 1, + Lock: 1, + PromiseRejectionEvent: 1, + MutationRecord: 1, + Memory: 1, + Crypto: 1, + "navigator.navigateTo": 1, + CacheStorage: 1, + "navigator.webkitGetUserMedia": 1, + "navigator.registerProtocolHandler": 1, + MediaStream: 1, + "navigator.msPointerEnabled": 1, + PerformanceMark: 1, + "navigator.msGetUserMedia": 1, + "navigator.cookieEnabled": 1, + "navigator.webkitGamepads": 1, + "navigator.msSaveOrOpenBlob": 1, + "navigator.cpuClass": 1, + }, +]; + +const accumulated = data.reduce((acc, usage) => { + if (!acc) { + return usage; + } + + for (const [name, count] of Object.entries(usage)) { + acc[name] = (acc[name] ?? 0) + count; + } + + return acc; +}, null); + +const sorted = Object.entries(accumulated).sort((lhs, rhs) => rhs[1] - lhs[1]); + +console.log(Object.fromEntries(sorted)); diff --git a/incubator/@react-native-webapis/scan/src/ignored_dirs.rs b/incubator/@react-native-webapis/scan/src/ignored_dirs.rs new file mode 100644 index 000000000..dba617f91 --- /dev/null +++ b/incubator/@react-native-webapis/scan/src/ignored_dirs.rs @@ -0,0 +1,116 @@ +/** + * THIS ARRAY MUST BE SORTED! We perform binary searches on it. + * + * List of directories to ignore. + */ +pub static IGNORED_DIRECTORIES: &'static [&str] = &[ + "@babel", + "@changesets", + "@eslint-community", + "@haul-bundler", + "@jest", + "@pnpm", + "@react-native", + "@react-native-community", + "@react-native-mac", + "@react-native-webapis", + "@react-native-windows", + "@rnx-kit", + "@types", + "@typescript-eslint", + "@yarnpkg", + "__mocks__", + "__snapshots__", + "babel-core", + "babel-jest", + "babel-plugin-codegen", + "babel-plugin-const-enum", + "babel-plugin-istanbul", + "babel-plugin-jest-hoist", + "babel-plugin-macros", + "babel-plugin-polyfill-corejs2", + "babel-plugin-polyfill-corejs3", + "babel-plugin-polyfill-regenerator", + "babel-plugin-syntax-trailing-function-commas", + "babel-preset-current-node-syntax", + "babel-preset-fbjs", + "babel-preset-jest", + "caniuse-lite", + "cross-spawn", + "depcheck", + "esbuild", + "eslint", + "eslint-plugin-es", + "eslint-plugin-node", + "eslint-plugin-react", + "eslint-plugin-react-hooks", + "eslint-plugin-security", + "hermes-parser", + "istanbul-reports", + "jest", + "jest-changed-files", + "jest-circus", + "jest-cli", + "jest-config", + "jest-diff", + "jest-docblock", + "jest-each", + "jest-environment-node", + "jest-get-type", + "jest-haste-map", + "jest-leak-detector", + "jest-matcher-utils", + "jest-message-util", + "jest-mock", + "jest-pnp-resolver", + "jest-regex-util", + "jest-resolve", + "jest-resolve-dependencies", + "jest-runner", + "jest-runtime", + "jest-serializer", + "jest-snapshot", + "jest-util", + "jest-validate", + "jest-watcher", + "jest-worker", + "metro", + "metro-babel-transformer", + "metro-cache", + "metro-cache-key", + "metro-config", + "metro-core", + "metro-file-map", + "metro-hermes-compiler", + "metro-inspector-proxy", + "metro-minify-terser", + "metro-minify-uglify", + "metro-react-native-babel-preset", + "metro-react-native-babel-transformer", + "metro-resolver", + "metro-runtime", + "metro-source-map", + "metro-symbolicate", + "metro-transform-plugins", + "metro-transform-worker", + "nx", + "package-json", + "postcss", + "prettier", + "react-devtools-core", + "react-dom", + "react-native", + "react-native-macos", + "react-native-web", + "react-native-win32", + "react-native-windows", + "rollup", + "sass", + "source-map-support", + "terser", + "type-fest", + "typedoc", + "typescript", + "uglify-es", + "vite", +]; diff --git a/incubator/@react-native-webapis/scan/src/main.rs b/incubator/@react-native-webapis/scan/src/main.rs new file mode 100644 index 000000000..d543b4101 --- /dev/null +++ b/incubator/@react-native-webapis/scan/src/main.rs @@ -0,0 +1,64 @@ +use crate::ignored_dirs::IGNORED_DIRECTORIES; +use rayon::prelude::*; +use std::collections::HashMap; +use visitor::visit; +use walkdir::{DirEntry, WalkDir}; + +mod ignored_dirs; +mod visitor; +mod web_api_visitor; +mod web_apis; + +fn print_sorted(map: &HashMap) { + let mut entries = map.iter().collect::>(); + entries.sort_unstable_by(|lhs, rhs| (*lhs.1).cmp(rhs.1).reverse()); + + println!("{{"); + for (k, v) in entries.iter() { + println!("\t\"{}\": {},", k, v); + } + println!("}}"); +} + +fn is_source_file(entry: &DirEntry, extensions: &[&str], ignored_extensions: &[&str]) -> bool { + match entry.file_type().is_file() { + true => { + let filename = entry.file_name().to_string_lossy(); + let is_ignored = ignored_extensions + .iter() + .any(|&ext| filename.ends_with(ext)); + !is_ignored && extensions.iter().any(|&ext| filename.ends_with(ext)) + } + false => { + let filename = entry.file_name().to_string_lossy(); + if let Ok(..) = IGNORED_DIRECTORIES.binary_search(&filename.as_ref()) { + false + } else { + true + } + } + } +} + +fn main() { + let extensions = &[".js", ".jsx", ".ts", ".tsx"]; + let ignored_extensions = &[".d.ts"]; + + let result = WalkDir::new(".") + .into_iter() + .filter_entry(|entry| is_source_file(entry, extensions, ignored_extensions)) + .filter_map(Result::ok) + .collect::>() + .par_iter() + .filter(|entry| entry.file_type().is_file()) + .map(|entry| visit(entry.path())) + .reduce_with(|mut result, segment| { + for (k, v) in segment { + result.entry(k).and_modify(|count| *count += v).or_insert(v); + } + result + }) + .unwrap(); + + print_sorted(&result); +} diff --git a/incubator/@react-native-webapis/scan/src/visitor.rs b/incubator/@react-native-webapis/scan/src/visitor.rs new file mode 100644 index 000000000..cf7e9f536 --- /dev/null +++ b/incubator/@react-native-webapis/scan/src/visitor.rs @@ -0,0 +1,60 @@ +use crate::web_api_visitor::WebApiVisitor; +use std::collections::HashMap; +use std::path::Path; +use swc_common::{self, sync::Lrc, SourceFile, SourceMap}; +use swc_ecma_parser::{error::Error, parse_file_as_module, EsConfig, Syntax, TsConfig}; +use swc_ecma_visit::VisitWith; +use swc_ecmascript::ast::{EsVersion, Module}; + +trait ParseableModule { + fn parse_file_as_module(&self, source_path: &Path) -> Result; +} + +impl ParseableModule for SourceFile { + fn parse_file_as_module(&self, source_path: &Path) -> Result { + let extension = source_path.extension().expect("Expected a file extension"); + parse_file_as_module( + self, + if extension == "ts" || extension == "tsx" { + Syntax::Typescript(TsConfig { + tsx: extension == "tsx", + decorators: true, + ..Default::default() + }) + } else { + Syntax::Es(EsConfig { + jsx: true, + decorators: true, + ..Default::default() + }) + }, + EsVersion::latest(), + None, + &mut vec![], + ) + } +} + +pub fn visit(source_path: &Path) -> HashMap { + let mut usage_map = HashMap::new(); + + let cm: Lrc = Default::default(); + let fm = match cm.load_file(source_path) { + Ok(fm) => fm, + Err(..) => { + eprintln!("Failed to load source file: {}", source_path.display()); + return usage_map; + } + }; + + match fm.parse_file_as_module(&source_path) { + Ok(module) => module.visit_with(&mut WebApiVisitor { + usage_map: &mut usage_map, + }), + Err(..) => { + eprintln!("Failed to parse source file: {}", source_path.display()); + } + } + + usage_map +} diff --git a/incubator/@react-native-webapis/scan/src/web_api_visitor.rs b/incubator/@react-native-webapis/scan/src/web_api_visitor.rs new file mode 100644 index 000000000..cad3ae4cf --- /dev/null +++ b/incubator/@react-native-webapis/scan/src/web_api_visitor.rs @@ -0,0 +1,51 @@ +use crate::web_apis::WEB_APIS; +use std::collections::HashMap; +use swc_ecma_visit::{Visit, VisitWith}; +use swc_ecmascript::ast::{ComputedPropName, Expr, Lit, MemberExpr, MemberProp, NewExpr, Str}; + +pub struct WebApiVisitor<'a> { + pub usage_map: &'a mut HashMap, +} + +impl<'a> WebApiVisitor<'a> { + pub fn insert(&mut self, sym: String) { + self.usage_map + .entry(sym) + .and_modify(|count| *count += 1) + .or_insert(1); + } + + pub fn insert_navigator_member(&mut self, sym: &str) { + self.insert(format!("navigator.{}", sym)); + } +} + +impl<'a> Visit for WebApiVisitor<'a> { + /// Count all references to `navigator.*` + fn visit_member_expr(&mut self, member: &MemberExpr) { + if let Expr::Ident(ident) = member.obj.as_ref() { + if ident.as_ref() == "navigator" { + match &member.prop { + MemberProp::Ident(prop) => self.insert_navigator_member(prop.as_ref()), + MemberProp::Computed(ComputedPropName { expr, .. }) => { + if let Expr::Lit(Lit::Str(Str { value, .. })) = expr.as_ref() { + self.insert_navigator_member(&value); + } else { + expr.visit_with(self); + } + } + _ => {} + } + } + } + } + + /// Count all uses of identifiers that found in `WEB_APIS` + fn visit_new_expr(&mut self, expr: &NewExpr) { + if let Expr::Ident(ident) = expr.callee.as_ref() { + if let Ok(..) = WEB_APIS.binary_search(&ident.as_ref()) { + self.insert(ident.as_ref().to_string()); + } + } + } +} diff --git a/incubator/@react-native-webapis/scan/src/web_apis.rs b/incubator/@react-native-webapis/scan/src/web_apis.rs new file mode 100644 index 000000000..6c979e7d5 --- /dev/null +++ b/incubator/@react-native-webapis/scan/src/web_apis.rs @@ -0,0 +1,615 @@ +/** + * THIS ARRAY MUST BE SORTED! We perform binary searches on it. + * + * Names extracted from `lib.dom.d.ts` in TypeScript 5.1.6, subtracting names + * in `react-native/types/modules/globals.d.ts`. + */ +pub static WEB_APIS: &'static [&str] = &[ + //"AbortController", // Polyfilled by React Native + //"AbortSignal", // Polyfilled by React Native + "AbstractRange", + "AnalyserNode", + "Animation", + "AnimationEffect", + "AnimationEvent", + "AnimationPlaybackEvent", + "AnimationTimeline", + "Attr", + "AudioBuffer", + "AudioBufferSourceNode", + "AudioContext", + "AudioDestinationNode", + "AudioListener", + "AudioNode", + "AudioParam", + "AudioParamMap", + "AudioProcessingEvent", + "AudioScheduledSourceNode", + "AudioWorklet", + "AudioWorkletNode", + "AuthenticatorAssertionResponse", + "AuthenticatorAttestationResponse", + "AuthenticatorResponse", + "BarProp", + "BaseAudioContext", + "BeforeUnloadEvent", + "BiquadFilterNode", + //"Blob", // Polyfilled by React Native + "BlobEvent", + "BroadcastChannel", + "ByteLengthQueuingStrategy", + "CDATASection", + "CSSAnimation", + "CSSConditionRule", + "CSSContainerRule", + "CSSCounterStyleRule", + "CSSFontFaceRule", + "CSSFontFeatureValuesRule", + "CSSFontPaletteValuesRule", + "CSSGroupingRule", + "CSSImageValue", + "CSSImportRule", + "CSSKeyframeRule", + "CSSKeyframesRule", + "CSSKeywordValue", + "CSSLayerBlockRule", + "CSSLayerStatementRule", + "CSSMathClamp", + "CSSMathInvert", + "CSSMathMax", + "CSSMathMin", + "CSSMathNegate", + "CSSMathProduct", + "CSSMathSum", + "CSSMathValue", + "CSSMatrixComponent", + "CSSMediaRule", + "CSSNamespaceRule", + "CSSNumericArray", + "CSSNumericValue", + "CSSPageRule", + "CSSPerspective", + "CSSPropertyRule", + "CSSRotate", + "CSSRule", + "CSSRuleList", + "CSSScale", + "CSSSkew", + "CSSSkewX", + "CSSSkewY", + "CSSStyleDeclaration", + "CSSStyleRule", + "CSSStyleSheet", + "CSSStyleValue", + "CSSSupportsRule", + "CSSTransformComponent", + "CSSTransformValue", + "CSSTransition", + "CSSTranslate", + "CSSUnitValue", + "CSSUnparsedValue", + "CSSVariableReferenceValue", + "Cache", + "CacheStorage", + "CanvasCaptureMediaStreamTrack", + "CanvasGradient", + "CanvasPattern", + "CanvasRenderingContext2D", + "ChannelMergerNode", + "ChannelSplitterNode", + "CharacterData", + "Clipboard", + "ClipboardEvent", + "ClipboardItem", + "CloseEvent", + "Comment", + "CompileError", + "CompositionEvent", + "CompressionStream", + "ConstantSourceNode", + "ConvolverNode", + "CountQueuingStrategy", + "Credential", + "CredentialsContainer", + "Crypto", + "CryptoKey", + "CustomElementRegistry", + "CustomEvent", + "DOMException", + "DOMImplementation", + "DOMMatrix", + "DOMMatrixReadOnly", + "DOMParser", + "DOMPoint", + "DOMPointReadOnly", + "DOMQuad", + "DOMRect", + "DOMRectList", + "DOMRectReadOnly", + "DOMStringList", + "DOMStringMap", + "DOMTokenList", + "DataTransfer", + "DataTransferItem", + "DataTransferItemList", + "DecompressionStream", + "DelayNode", + "DeviceMotionEvent", + "DeviceOrientationEvent", + "Document", + "DocumentFragment", + "DocumentTimeline", + "DocumentType", + "DragEvent", + "DynamicsCompressorNode", + "Element", + "ElementInternals", + "EncodedVideoChunk", + "ErrorEvent", + "Event", + "EventCounts", + "EventSource", + //"EventTarget", // Polyfilled by React Native + "External", + //"File", // Polyfilled by React Native + "FileList", + //"FileReader", // Polyfilled by React Native + "FileSystem", + "FileSystemDirectoryEntry", + "FileSystemDirectoryHandle", + "FileSystemDirectoryReader", + "FileSystemEntry", + "FileSystemFileEntry", + "FileSystemFileHandle", + "FileSystemHandle", + "FileSystemWritableFileStream", + "FocusEvent", + "FontFace", + "FontFaceSet", + "FontFaceSetLoadEvent", + //"FormData", // Polyfilled by React Native + "FormDataEvent", + "GainNode", + "Gamepad", + "GamepadButton", + "GamepadEvent", + "GamepadHapticActuator", + "Geolocation", + "GeolocationCoordinates", + "GeolocationPosition", + "GeolocationPositionError", + "Global", + "HTMLAllCollection", + "HTMLAnchorElement", + "HTMLAreaElement", + "HTMLAudioElement", + "HTMLBRElement", + "HTMLBaseElement", + "HTMLBodyElement", + "HTMLButtonElement", + "HTMLCanvasElement", + "HTMLCollection", + "HTMLDListElement", + "HTMLDataElement", + "HTMLDataListElement", + "HTMLDetailsElement", + "HTMLDialogElement", + "HTMLDirectoryElement", + "HTMLDivElement", + "HTMLDocument", + "HTMLElement", + "HTMLEmbedElement", + "HTMLFieldSetElement", + "HTMLFontElement", + "HTMLFormControlsCollection", + "HTMLFormElement", + "HTMLFrameElement", + "HTMLFrameSetElement", + "HTMLHRElement", + "HTMLHeadElement", + "HTMLHeadingElement", + "HTMLHtmlElement", + "HTMLIFrameElement", + "HTMLImageElement", + "HTMLInputElement", + "HTMLLIElement", + "HTMLLabelElement", + "HTMLLegendElement", + "HTMLLinkElement", + "HTMLMapElement", + "HTMLMarqueeElement", + "HTMLMediaElement", + "HTMLMenuElement", + "HTMLMetaElement", + "HTMLMeterElement", + "HTMLModElement", + "HTMLOListElement", + "HTMLObjectElement", + "HTMLOptGroupElement", + "HTMLOptionElement", + "HTMLOptionsCollection", + "HTMLOutputElement", + "HTMLParagraphElement", + "HTMLParamElement", + "HTMLPictureElement", + "HTMLPreElement", + "HTMLProgressElement", + "HTMLQuoteElement", + "HTMLScriptElement", + "HTMLSelectElement", + "HTMLSlotElement", + "HTMLSourceElement", + "HTMLSpanElement", + "HTMLStyleElement", + "HTMLTableCaptionElement", + "HTMLTableCellElement", + "HTMLTableColElement", + "HTMLTableElement", + "HTMLTableRowElement", + "HTMLTableSectionElement", + "HTMLTemplateElement", + "HTMLTextAreaElement", + "HTMLTimeElement", + "HTMLTitleElement", + "HTMLTrackElement", + "HTMLUListElement", + "HTMLUnknownElement", + "HTMLVideoElement", + "HashChangeEvent", + //"Headers", // Polyfilled by React Native + "History", + "IDBCursor", + "IDBCursorWithValue", + "IDBDatabase", + "IDBFactory", + "IDBIndex", + "IDBKeyRange", + "IDBObjectStore", + "IDBOpenDBRequest", + "IDBRequest", + "IDBTransaction", + "IDBVersionChangeEvent", + "IIRFilterNode", + "IdleDeadline", + "ImageBitmap", + "ImageBitmapRenderingContext", + "ImageData", + "InputDeviceInfo", + "InputEvent", + "Instance", + "IntersectionObserver", + "IntersectionObserverEntry", + "KeyboardEvent", + "KeyframeEffect", + "LinkError", + "Location", + "Lock", + "LockManager", + "MIDIAccess", + "MIDIConnectionEvent", + "MIDIInput", + "MIDIInputMap", + "MIDIMessageEvent", + "MIDIOutput", + "MIDIOutputMap", + "MIDIPort", + "MathMLElement", + "MediaCapabilities", + "MediaDeviceInfo", + "MediaDevices", + "MediaElementAudioSourceNode", + "MediaEncryptedEvent", + "MediaError", + "MediaKeyMessageEvent", + "MediaKeySession", + "MediaKeyStatusMap", + "MediaKeySystemAccess", + "MediaKeys", + "MediaList", + "MediaMetadata", + "MediaQueryList", + "MediaQueryListEvent", + "MediaRecorder", + "MediaSession", + "MediaSource", + "MediaStream", + "MediaStreamAudioDestinationNode", + "MediaStreamAudioSourceNode", + "MediaStreamTrack", + "MediaStreamTrackEvent", + "Memory", + "MessageChannel", + "MessageEvent", + "MessagePort", + "MimeType", + "MimeTypeArray", + "Module", + "MouseEvent", + "MutationEvent", + "MutationObserver", + "MutationRecord", + "NamedNodeMap", + "NavigationPreloadManager", + "Navigator", + "Node", + "NodeIterator", + "NodeList", + "Notification", + "OfflineAudioCompletionEvent", + "OfflineAudioContext", + "OffscreenCanvas", + "OffscreenCanvasRenderingContext2D", + "OscillatorNode", + "OverconstrainedError", + "PageTransitionEvent", + "PannerNode", + "Path2D", + "PaymentMethodChangeEvent", + "PaymentRequest", + "PaymentRequestUpdateEvent", + "PaymentResponse", + "Performance", + "PerformanceEntry", + "PerformanceEventTiming", + "PerformanceMark", + "PerformanceMeasure", + "PerformanceNavigation", + "PerformanceNavigationTiming", + "PerformanceObserver", + "PerformanceObserverEntryList", + "PerformancePaintTiming", + "PerformanceResourceTiming", + "PerformanceServerTiming", + "PerformanceTiming", + "PeriodicWave", + "PermissionStatus", + "Permissions", + "PictureInPictureEvent", + "PictureInPictureWindow", + "Plugin", + "PluginArray", + "PointerEvent", + "PopStateEvent", + "ProcessingInstruction", + //"ProgressEvent", // Polyfilled by React Native + "PromiseRejectionEvent", + "PublicKeyCredential", + "PushManager", + "PushSubscription", + "PushSubscriptionOptions", + "RTCCertificate", + "RTCDTMFSender", + "RTCDTMFToneChangeEvent", + "RTCDataChannel", + "RTCDataChannelEvent", + "RTCDtlsTransport", + "RTCEncodedAudioFrame", + "RTCEncodedVideoFrame", + "RTCError", + "RTCErrorEvent", + "RTCIceCandidate", + "RTCIceTransport", + "RTCPeerConnection", + "RTCPeerConnectionIceErrorEvent", + "RTCPeerConnectionIceEvent", + "RTCRtpReceiver", + "RTCRtpSender", + "RTCRtpTransceiver", + "RTCSctpTransport", + "RTCSessionDescription", + "RTCStatsReport", + "RTCTrackEvent", + "RadioNodeList", + "Range", + "ReadableByteStreamController", + "ReadableStream", + "ReadableStreamBYOBReader", + "ReadableStreamBYOBRequest", + "ReadableStreamDefaultController", + "ReadableStreamDefaultReader", + "RemotePlayback", + "Report", + "ReportBody", + "ReportingObserver", + //"Request", // Polyfilled by React Native + "ResizeObserver", + "ResizeObserverEntry", + "ResizeObserverSize", + //"Response", // Polyfilled by React Native + "RuntimeError", + "SVGAElement", + "SVGAngle", + "SVGAnimateElement", + "SVGAnimateMotionElement", + "SVGAnimateTransformElement", + "SVGAnimatedAngle", + "SVGAnimatedBoolean", + "SVGAnimatedEnumeration", + "SVGAnimatedInteger", + "SVGAnimatedLength", + "SVGAnimatedLengthList", + "SVGAnimatedNumber", + "SVGAnimatedNumberList", + "SVGAnimatedPreserveAspectRatio", + "SVGAnimatedRect", + "SVGAnimatedString", + "SVGAnimatedTransformList", + "SVGAnimationElement", + "SVGCircleElement", + "SVGClipPathElement", + "SVGComponentTransferFunctionElement", + "SVGDefsElement", + "SVGDescElement", + "SVGElement", + "SVGEllipseElement", + "SVGFEBlendElement", + "SVGFEColorMatrixElement", + "SVGFEComponentTransferElement", + "SVGFECompositeElement", + "SVGFEConvolveMatrixElement", + "SVGFEDiffuseLightingElement", + "SVGFEDisplacementMapElement", + "SVGFEDistantLightElement", + "SVGFEDropShadowElement", + "SVGFEFloodElement", + "SVGFEFuncAElement", + "SVGFEFuncBElement", + "SVGFEFuncGElement", + "SVGFEFuncRElement", + "SVGFEGaussianBlurElement", + "SVGFEImageElement", + "SVGFEMergeElement", + "SVGFEMergeNodeElement", + "SVGFEMorphologyElement", + "SVGFEOffsetElement", + "SVGFEPointLightElement", + "SVGFESpecularLightingElement", + "SVGFESpotLightElement", + "SVGFETileElement", + "SVGFETurbulenceElement", + "SVGFilterElement", + "SVGForeignObjectElement", + "SVGGElement", + "SVGGeometryElement", + "SVGGradientElement", + "SVGGraphicsElement", + "SVGImageElement", + "SVGLength", + "SVGLengthList", + "SVGLineElement", + "SVGLinearGradientElement", + "SVGMPathElement", + "SVGMarkerElement", + "SVGMaskElement", + "SVGMetadataElement", + "SVGNumber", + "SVGNumberList", + "SVGPathElement", + "SVGPatternElement", + "SVGPointList", + "SVGPolygonElement", + "SVGPolylineElement", + "SVGPreserveAspectRatio", + "SVGRadialGradientElement", + "SVGRectElement", + "SVGSVGElement", + "SVGScriptElement", + "SVGSetElement", + "SVGStopElement", + "SVGStringList", + "SVGStyleElement", + "SVGSwitchElement", + "SVGSymbolElement", + "SVGTSpanElement", + "SVGTextContentElement", + "SVGTextElement", + "SVGTextPathElement", + "SVGTextPositioningElement", + "SVGTitleElement", + "SVGTransform", + "SVGTransformList", + "SVGUnitTypes", + "SVGUseElement", + "SVGViewElement", + "Screen", + "ScreenOrientation", + "ScriptProcessorNode", + "SecurityPolicyViolationEvent", + "Selection", + "ServiceWorker", + "ServiceWorkerContainer", + "ServiceWorkerRegistration", + "ShadowRoot", + "SharedWorker", + "SourceBuffer", + "SourceBufferList", + "SpeechRecognitionAlternative", + "SpeechRecognitionResult", + "SpeechRecognitionResultList", + "SpeechSynthesis", + "SpeechSynthesisErrorEvent", + "SpeechSynthesisEvent", + "SpeechSynthesisUtterance", + "SpeechSynthesisVoice", + "StaticRange", + "StereoPannerNode", + "Storage", + "StorageEvent", + "StorageManager", + "StylePropertyMap", + "StylePropertyMapReadOnly", + "StyleSheet", + "StyleSheetList", + "SubmitEvent", + "SubtleCrypto", + "Table", + "Text", + "TextDecoder", + "TextDecoderStream", + "TextEncoder", + "TextEncoderStream", + "TextMetrics", + "TextTrack", + "TextTrackCue", + "TextTrackCueList", + "TextTrackList", + "TimeRanges", + "Touch", + "TouchEvent", + "TouchList", + "TrackEvent", + "TransformStream", + "TransformStreamDefaultController", + "TransitionEvent", + "TreeWalker", + "UIEvent", + //"URL", // Polyfilled by React Native + //"URLSearchParams", // Polyfilled by React Native + "UserActivation", + "VTTCue", + "VTTRegion", + "ValidityState", + "VideoColorSpace", + "VideoDecoder", + "VideoEncoder", + "VideoFrame", + "VideoPlaybackQuality", + "VisualViewport", + "WakeLock", + "WakeLockSentinel", + "WaveShaperNode", + "WebGL2RenderingContext", + "WebGLActiveInfo", + "WebGLBuffer", + "WebGLContextEvent", + "WebGLFramebuffer", + "WebGLProgram", + "WebGLQuery", + "WebGLRenderbuffer", + "WebGLRenderingContext", + "WebGLSampler", + "WebGLShader", + "WebGLShaderPrecisionFormat", + "WebGLSync", + "WebGLTexture", + "WebGLTransformFeedback", + "WebGLUniformLocation", + "WebGLVertexArrayObject", + //"WebSocket", // Polyfilled by React Native + "WheelEvent", + "Window", + "Worker", + "Worklet", + "WritableStream", + "WritableStreamDefaultController", + "WritableStreamDefaultWriter", + "XMLDocument", + //"XMLHttpRequest", // Polyfilled by React Native + //"XMLHttpRequestEventTarget", // Polyfilled by React Native + //"XMLHttpRequestUpload", // Polyfilled by React Native + "XMLSerializer", + "XPathEvaluator", + "XPathExpression", + "XPathResult", + "XSLTProcessor", +]; diff --git a/incubator/@react-native-webapis/types/README.md b/incubator/@react-native-webapis/types/README.md deleted file mode 100644 index 95ec49aa8..000000000 --- a/incubator/@react-native-webapis/types/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# @react-native-webapis/types - -[![Build](https://github.com/microsoft/rnx-kit/actions/workflows/build.yml/badge.svg)](https://github.com/microsoft/rnx-kit/actions/workflows/build.yml) -[![npm version](https://img.shields.io/npm/v/@react-native-webapis/types)](https://www.npmjs.com/package/@react-native-webapis/types) - -🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧 - -### THIS TOOL IS EXPERIMENTAL — USE WITH CAUTION - -🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧 - -`@react-native-webapis/types` provides types for the React Native equivalent to -[Web APIs](https://developer.mozilla.org/en-US/docs/Web/API). - -## Motivation - -TODO - -## Installation - -```sh -yarn add @react-native-webapis/types --dev -``` - -or if you're using npm - -```sh -npm add --save-dev @react-native-webapis/types -``` - -## Usage - -TODO diff --git a/incubator/@react-native-webapis/types/generate.mjs b/incubator/@react-native-webapis/types/generate.mjs deleted file mode 100644 index 76403005c..000000000 --- a/incubator/@react-native-webapis/types/generate.mjs +++ /dev/null @@ -1,271 +0,0 @@ -// @ts-check -import got from "got"; -import * as fs from "node:fs"; -import * as module from "node:module"; -import ts from "typescript"; - -const compatData = "https://unpkg.com/@mdn/browser-compat-data/data.json"; - -// https://developer.mozilla.org/en-US/docs/Web/API -const ignoredSpecs = [ - "https://dom.spec.whatwg.org/", // DOM - "https://drafts.css-houdini.org/", // CSS Houdini - "https://drafts.fxtf.org/", // W3C CSS-SVG effects - "https://html.spec.whatwg.org/multipage/browsing-the-web.html", // HTML - "https://html.spec.whatwg.org/multipage/canvas.html", // Canvas - "https://html.spec.whatwg.org/multipage/common-dom-interfaces.html", // DOM - "https://html.spec.whatwg.org/multipage/custom-elements.html", // DOM - "https://html.spec.whatwg.org/multipage/dom.html", // DOM - "https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html", // DOM - "https://html.spec.whatwg.org/multipage/edits.html", // DOM - "https://html.spec.whatwg.org/multipage/embedded-content.html", // DOM - "https://html.spec.whatwg.org/multipage/form-control-infrastructure.html", // DOM - "https://html.spec.whatwg.org/multipage/form-elements.html", // DOM - "https://html.spec.whatwg.org/multipage/forms.html", // DOM - "https://html.spec.whatwg.org/multipage/grouping-content.html", // DOM - "https://html.spec.whatwg.org/multipage/history.html", // DOM - "https://html.spec.whatwg.org/multipage/iframe-embed-object.html", // DOM - "https://html.spec.whatwg.org/multipage/image-maps.html", // DOM - "https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html", // DOM - "https://html.spec.whatwg.org/multipage/input.html", // DOM - "https://html.spec.whatwg.org/multipage/interaction.html", // DOM - "https://html.spec.whatwg.org/multipage/interactive-elements.html", // DOM - "https://html.spec.whatwg.org/multipage/media.html", // DOM - "https://html.spec.whatwg.org/multipage/obsolete.html", // DOM - "https://html.spec.whatwg.org/multipage/parsing.html", // DOM - "https://html.spec.whatwg.org/multipage/scripting.html", // DOM - "https://html.spec.whatwg.org/multipage/sections.html", // DOM - "https://html.spec.whatwg.org/multipage/semantics.html", // DOM - "https://html.spec.whatwg.org/multipage/tables.html", // DOM - "https://html.spec.whatwg.org/multipage/text-level-semantics.html", // DOM - "https://html.spec.whatwg.org/multipage/web-messaging.html", // Broadcast - "https://html.spec.whatwg.org/multipage/window-object.html#htmldocument", // HTMLDocument - "https://html.spec.whatwg.org/multipage/workers.html", // Workers - "https://immersive-web.github.io/", // WebXR - "https://registry.khronos.org/", // WebGL - "https://svgwg.org/", // SVG - "https://w3c.github.io/DOM-Parsing/", // XMLSerializer - "https://w3c.github.io/IntersectionObserver/", // IntersectionObserver - "https://w3c.github.io/ServiceWorker/", // ServiceWorker - "https://w3c.github.io/csswg-drafts/", // CSS - "https://w3c.github.io/mathml-core/", // MathML - "https://w3c.github.io/mediacapture-fromelement", // Canvas - "https://w3c.github.io/uievents/", // DOM events - "https://webidl.spec.whatwg.org/", // DOMException - "https://xhr.spec.whatwg.org/#dom-formdata", // XMLHttpRequest -]; - -/** - * @typedef {{ - * error: typeof console.error; - * info: typeof console.info; - * warn: typeof console.warn; - * }} Logger; - * - * @typedef {{ - * version_added: string | boolean; - * version_removed?: string; - * alternative_name?: string; - * }} Support; - * - * @typedef {{ - * spec_url?: string | string[]; - * status: { - * deprecated: boolean; - * experimental: boolean; - * standard_track: boolean; - * }; - * support: Record - * }} Spec; - */ - -/** - * @param {ts.ParameterDeclaration | ts.PropertySignature | ts.MethodSignature} node - * @returns {string | null} - */ -function getTypeName(node) { - if ( - !node.type || - !ts.isTypeReferenceNode(node.type) || - !ts.isIdentifier(node.type.typeName) - ) { - return null; - } - - return node.type.typeName.text; -} - -/** - * Returns whether the spec if deprecated, experimental, or otherwise unstable, - * and whether it comes from a domain that we currently don't care about. - * - * @see {@link ignoredSpecs} - * - * @param {Spec} spec - * @returns {boolean} - */ -function isIgnored({ spec_url, status }) { - if (status.deprecated || status.experimental || !status.standard_track) { - return true; - } - - if (Array.isArray(spec_url)) { - return spec_url.some((spec) => - ignoredSpecs.some((url) => spec.startsWith(url)) - ); - } else if (typeof spec_url === "string") { - return ignoredSpecs.some((url) => spec_url.startsWith(url)); - } - - return !spec_url; -} - -/** - * Load the baseline generated by the TypeScript team. - * @see {@link https://github.com/microsoft/TypeScript-DOM-lib-generator} - * @returns {ts.SourceFile | null} - */ -function loadBaseline() { - const require = module.createRequire(import.meta.url); - const lib = require.resolve("typescript/lib/lib.dom.d.ts"); - const def = fs.readFileSync(lib, { encoding: "utf-8" }); - return ts.createSourceFile("lib.native.d.ts", def, ts.ScriptTarget.ESNext); -} - -/** - * @param {ts.SourceFile} node - * @returns {string} - */ -function serialize(node) { - return ts - .createPrinter({ newLine: ts.NewLineKind.LineFeed }) - .printNode(ts.EmitHint.SourceFile, node, node); -} - -/** - * Generates interfaces from browser compatiblity data. - * @param {string} address - * @param {Logger} logger - */ -async function derive(address, logger) { - logger.info("Loading baseline"); - const baseline = loadBaseline(); - if (!baseline) { - logger.error("Failed to load baseline"); - process.exitCode = 1; - return; - } - - logger.info("Loading browser compatibility data"); - const { api } = await got(address).json(); - const included = new Set(); - for (const [name, spec] of Object.entries(api)) { - const compat = spec.__compat; - if (!isIgnored(compat)) { - included.add(name); - } - } - - logger.info("Generating interfaces"); - - /* - Step 1: Filter out variables that we don't care about. Also put all - interfaces somewhere easily accessible. - */ - - /** @type {Record} */ - const interfaces = {}; - /** @type {ts.VariableStatement[]} */ - const globals = []; - - for (const node of baseline.statements) { - if (ts.isVariableStatement(node)) { - // declare var AudioBuffer: {...}; - for (const decl of node.declarationList.declarations) { - if (ts.isIdentifier(decl.name) && included.has(decl.name.text)) { - globals.push(node); - break; - } - } - } else if (ts.isInterfaceDeclaration(node)) { - // interface AudioBuffer {...} - if (included.has(node.name.text)) { - interfaces[node.name.text] = node; - } - } - } - - /* - Step 2: Iterate over variables and keep only used interfaces. - */ - - /** @type {Record} */ - const statements = {}; - - /** @type {(node: ts.ParameterDeclaration | ts.TypeElement) => void} */ - const visitNode = (node) => { - if (ts.isMethodSignature(node)) { - for (const param of node.parameters) { - visitNode(param); - } - } else if (!ts.isParameter(node) && !ts.isPropertySignature(node)) { - return; - } - - const typeName = getTypeName(node); - if (typeName && interfaces[typeName]) { - const node = interfaces[typeName]; - delete interfaces[typeName]; - - for (const member of node.members) { - visitNode(member); - } - - statements[typeName] = node; - } - }; - - for (const node of globals) { - for (const decl of node.declarationList.declarations) { - const name = ts.isIdentifier(decl.name) ? decl.name.text : ""; - if ( - !name || - statements[name] || - !decl.type || - !ts.isTypeLiteralNode(decl.type) - ) { - continue; - } - - for (const member of decl.type.members) { - visitNode(member); - } - } - } - - /* - Step 3: Modify the baseline and write to disk. - */ - - // @ts-expect-error Cannot assign to 'statements' because it is a read-only property. - baseline.statements = [...Object.values(statements), ...globals]; - - const manifest = fs.readFileSync("package.json", { encoding: "utf-8" }); - const { types } = JSON.parse(manifest); - logger.info(`Writing '${types}'`); - fs.writeFileSync(types, serialize(baseline)); -} - -/** - * @param {string} address - * @param {boolean} verbose - */ -function main(address, verbose) { - const { error, info, warn } = console; - const logger = verbose - ? { error, info, warn } - : { error, info: () => 0, warn }; - return derive(address, logger); -} - -main(compatData, process.argv.includes("--verbose")); diff --git a/incubator/@react-native-webapis/types/package.json b/incubator/@react-native-webapis/types/package.json deleted file mode 100644 index 5d70b864e..000000000 --- a/incubator/@react-native-webapis/types/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "private": true, - "name": "@react-native-webapis/types", - "version": "0.0.1", - "description": "EXPERIMENTAL - USE WITH CAUTION - New package called @react-native-webapis/types", - "homepage": "https://github.com/microsoft/rnx-kit/tree/main/incubator/@react-native-webapis/types#readme", - "license": "MIT", - "author": { - "name": "Microsoft Open Source", - "email": "microsoftopensource@users.noreply.github.com" - }, - "files": [ - "lib.d.ts" - ], - "main": "lib.js", - "types": "lib.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/microsoft/rnx-kit", - "directory": "incubator/@react-native-webapis/types" - }, - "engines": { - "node": ">=14.15" - }, - "scripts": { - "format": "rnx-kit-scripts format", - "generate": "node generate.mjs" - }, - "devDependencies": { - "@rnx-kit/scripts": "*", - "eslint": "^8.0.0", - "got": "^13.0.0", - "prettier": "^3.0.0", - "typescript": "^5.0.0" - }, - "eslintConfig": { - "extends": "@rnx-kit/eslint-config" - }, - "experimental": true -} diff --git a/yarn.lock b/yarn.lock index f47083a2b..22115b35f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3167,18 +3167,6 @@ __metadata: languageName: node linkType: hard -"@react-native-webapis/types@workspace:incubator/@react-native-webapis/types": - version: 0.0.0-use.local - resolution: "@react-native-webapis/types@workspace:incubator/@react-native-webapis/types" - dependencies: - "@rnx-kit/scripts": "*" - eslint: ^8.0.0 - got: ^13.0.0 - prettier: ^3.0.0 - typescript: ^5.0.0 - languageName: unknown - linkType: soft - "@react-native-windows/cli@npm:0.72.3": version: 0.72.3 resolution: "@react-native-windows/cli@npm:0.72.3" @@ -7988,25 +7976,6 @@ __metadata: languageName: node linkType: hard -"got@npm:^13.0.0": - version: 13.0.0 - resolution: "got@npm:13.0.0" - dependencies: - "@sindresorhus/is": ^5.2.0 - "@szmarczak/http-timer": ^5.0.1 - cacheable-lookup: ^7.0.0 - cacheable-request: ^10.2.8 - decompress-response: ^6.0.0 - form-data-encoder: ^2.1.2 - get-stream: ^6.0.1 - http2-wrapper: ^2.1.10 - lowercase-keys: ^3.0.0 - p-cancelable: ^3.0.0 - responselike: ^3.0.0 - checksum: bcae6601efd710bc6c5b454c5e44bcb16fcfe57a1065e2d61ff918c1d69c3cf124984ebf509ca64ed10f0da2d2b5531b77da05aa786e75849d084fb8fbea711b - languageName: node - linkType: hard - "graceful-fs@npm:4.2.10, graceful-fs@npm:^4.1.11, graceful-fs@npm:^4.1.2, graceful-fs@npm:^4.1.3, graceful-fs@npm:^4.1.5, graceful-fs@npm:^4.1.6, graceful-fs@npm:^4.2.0, graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6, graceful-fs@npm:^4.2.8, graceful-fs@npm:^4.2.9": version: 4.2.10 resolution: "graceful-fs@npm:4.2.10"