├── .cargo └── config.toml ├── .github ├── dependabot.yml └── workflows │ └── tag-release.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── bench.js ├── build.rs ├── false ├── index.d.ts ├── index.js ├── options.d.ts ├── package.json ├── src └── lib.rs ├── test.js └── yarn.lock /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.arm-unknown-linux-gnueabihf] 2 | linker = "arm-linux-gnueabihf-gcc" 3 | 4 | [target.armv7-unknown-linux-gnueabihf] 5 | linker = "arm-linux-gnueabihf-gcc" 6 | 7 | [target.aarch64-unknown-linux-gnu] 8 | linker = "aarch64-linux-gnu-gcc" 9 | 10 | [target.aarch64-unknown-linux-musl] 11 | linker = "aarch64-linux-musl-gcc" 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "cargo" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | - package-ecosystem: "npm" 8 | directory: "/" 9 | schedule: 10 | interval: "daily" 11 | -------------------------------------------------------------------------------- /.github/workflows/tag-release.yml: -------------------------------------------------------------------------------- 1 | name: tag-release 2 | on: 3 | release: 4 | types: [published] 5 | workflow_dispatch: 6 | jobs: 7 | build: 8 | strategy: 9 | fail-fast: false 10 | matrix: 11 | os: [macos-latest, windows-latest] 12 | name: ${{ matrix.os }} 13 | runs-on: ${{ matrix.os }} 14 | steps: 15 | - uses: actions/checkout@v1 16 | - name: Install Rust 17 | uses: actions-rs/toolchain@v1 18 | with: 19 | toolchain: stable 20 | profile: minimal 21 | override: true 22 | - uses: bahmutov/npm-install@v1.1.0 23 | - name: Build native packages 24 | run: yarn build-release 25 | - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 26 | if: ${{ matrix.os == 'macos-latest' }} 27 | run: strip -x ./*.node # Must use -x on macOS. This produces larger results on linux. 28 | - name: Upload artifacts 29 | uses: actions/upload-artifact@v2 30 | with: 31 | name: bindings-${{ matrix.os }} 32 | path: ./*.node 33 | - name: Smoke test 34 | run: node -e "require('./')" 35 | 36 | build-linux: 37 | strategy: 38 | fail-fast: false 39 | matrix: 40 | include: 41 | - target: x86_64-unknown-linux-gnu 42 | strip: strip 43 | image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian 44 | setup: npm install --global yarn@1 45 | - target: aarch64-unknown-linux-gnu 46 | strip: llvm-strip 47 | image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 48 | - target: aarch64-unknown-linux-musl 49 | image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine 50 | strip: aarch64-linux-musl-strip 51 | - target: x86_64-unknown-linux-musl 52 | image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine 53 | strip: strip 54 | name: build-${{ matrix.target }} 55 | runs-on: ubuntu-latest 56 | container: 57 | image: ${{ matrix.image }} 58 | steps: 59 | - uses: actions/checkout@v1 60 | - name: Install Rust 61 | uses: actions-rs/toolchain@v1 62 | with: 63 | toolchain: stable 64 | profile: minimal 65 | override: true 66 | target: ${{ matrix.target }} 67 | - name: Setup cross compile toolchain 68 | if: ${{ matrix.setup }} 69 | run: ${{ matrix.setup }} 70 | - name: Setup rust target 71 | run: rustup target add ${{ matrix.target }} 72 | - uses: bahmutov/npm-install@v1.8.32 73 | - name: Build native packages 74 | run: yarn build-release --target ${{ matrix.target }} 75 | - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 76 | if: ${{ matrix.strip }} 77 | run: ${{ matrix.strip }} *.node 78 | - name: Upload artifacts 79 | uses: actions/upload-artifact@v2 80 | with: 81 | name: bindings-${{ matrix.target }} 82 | path: ./*.node 83 | 84 | build-apple-silicon: 85 | name: aarch64-apple-darwin 86 | runs-on: macos-latest 87 | steps: 88 | - uses: actions/checkout@v1 89 | - name: Install Rust 90 | uses: actions-rs/toolchain@v1 91 | with: 92 | toolchain: stable 93 | profile: minimal 94 | override: true 95 | target: aarch64-apple-darwin 96 | - uses: bahmutov/npm-install@v1.1.0 97 | - name: Build native packages 98 | run: | 99 | sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; 100 | export CC=$(xcrun -f clang); 101 | export CXX=$(xcrun -f clang++); 102 | SYSROOT=$(xcrun --sdk macosx --show-sdk-path); 103 | export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; 104 | export JEMALLOC_SYS_WITH_LG_PAGE=14; 105 | yarn build-release --target aarch64-apple-darwin 106 | - name: Strip debug symbols 107 | run: strip -x ./*.node 108 | - name: Upload artifacts 109 | uses: actions/upload-artifact@v2 110 | with: 111 | name: bindings-apple-aarch64 112 | path: ./*.node 113 | - name: debug 114 | run: ls -l ./*.node 115 | 116 | build-and-release: 117 | runs-on: ubuntu-latest 118 | name: Build and release the tagged version 119 | needs: 120 | - build 121 | - build-linux 122 | - build-apple-silicon 123 | steps: 124 | - uses: actions/checkout@v1 125 | - uses: bahmutov/npm-install@v1.1.0 126 | - name: Build native packages 127 | run: yarn build-release 128 | - name: Download artifacts 129 | uses: actions/download-artifact@v2 130 | with: 131 | path: artifacts 132 | - name: Move artifacts 133 | run: mv artifacts/*/*.node . 134 | - name: Debug 135 | run: ls -l ./*.node 136 | - run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc 137 | env: 138 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 139 | - run: npm publish 140 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | target 3 | *.node 4 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "Inflector" 7 | version = "0.11.4" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" 10 | dependencies = [ 11 | "lazy_static", 12 | "regex", 13 | ] 14 | 15 | [[package]] 16 | name = "aho-corasick" 17 | version = "1.0.5" 18 | source = "registry+https://github.com/rust-lang/crates.io-index" 19 | checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" 20 | dependencies = [ 21 | "memchr", 22 | ] 23 | 24 | [[package]] 25 | name = "anyhow" 26 | version = "1.0.75" 27 | source = "registry+https://github.com/rust-lang/crates.io-index" 28 | checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" 29 | 30 | [[package]] 31 | name = "ast_node" 32 | version = "0.9.5" 33 | source = "registry+https://github.com/rust-lang/crates.io-index" 34 | checksum = "c09c69dffe06d222d072c878c3afe86eee2179806f20503faec97250268b4c24" 35 | dependencies = [ 36 | "pmutil", 37 | "proc-macro2", 38 | "quote", 39 | "swc_macros_common", 40 | "syn 2.0.32", 41 | ] 42 | 43 | [[package]] 44 | name = "autocfg" 45 | version = "1.1.0" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 48 | 49 | [[package]] 50 | name = "better_scoped_tls" 51 | version = "0.1.1" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | checksum = "794edcc9b3fb07bb4aecaa11f093fd45663b4feadb782d68303a2268bc2701de" 54 | dependencies = [ 55 | "scoped-tls", 56 | ] 57 | 58 | [[package]] 59 | name = "bitflags" 60 | version = "1.3.2" 61 | source = "registry+https://github.com/rust-lang/crates.io-index" 62 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 63 | 64 | [[package]] 65 | name = "bitflags" 66 | version = "2.4.0" 67 | source = "registry+https://github.com/rust-lang/crates.io-index" 68 | checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" 69 | 70 | [[package]] 71 | name = "bumpalo" 72 | version = "3.13.0" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" 75 | 76 | [[package]] 77 | name = "cc" 78 | version = "1.0.83" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" 81 | dependencies = [ 82 | "libc", 83 | ] 84 | 85 | [[package]] 86 | name = "cfg-if" 87 | version = "1.0.0" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 90 | 91 | [[package]] 92 | name = "convert_case" 93 | version = "0.6.0" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" 96 | dependencies = [ 97 | "unicode-segmentation", 98 | ] 99 | 100 | [[package]] 101 | name = "ctor" 102 | version = "0.2.4" 103 | source = "registry+https://github.com/rust-lang/crates.io-index" 104 | checksum = "1f34ba9a9bcb8645379e9de8cb3ecfcf4d1c85ba66d90deb3259206fa5aa193b" 105 | dependencies = [ 106 | "quote", 107 | "syn 2.0.32", 108 | ] 109 | 110 | [[package]] 111 | name = "deno_ast" 112 | version = "0.29.1" 113 | source = "registry+https://github.com/rust-lang/crates.io-index" 114 | checksum = "e8bb902bcaa072210ca7b2f28c391f77bb16f6ef64664331c5d928d99943303c" 115 | dependencies = [ 116 | "deno_media_type", 117 | "dprint-swc-ext", 118 | "serde", 119 | "swc_atoms", 120 | "swc_common", 121 | "swc_ecma_ast", 122 | "swc_ecma_parser", 123 | "swc_eq_ignore_macros", 124 | "text_lines", 125 | ] 126 | 127 | [[package]] 128 | name = "deno_media_type" 129 | version = "0.1.2" 130 | source = "registry+https://github.com/rust-lang/crates.io-index" 131 | checksum = "a798670c20308e5770cc0775de821424ff9e85665b602928509c8c70430b3ee0" 132 | dependencies = [ 133 | "serde", 134 | ] 135 | 136 | [[package]] 137 | name = "dprint-core" 138 | version = "0.62.1" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | checksum = "e6563addfa2b6c6fa96acdda0341090beba2c5c4ff6ef91f3a232a6d4dd34156" 141 | dependencies = [ 142 | "anyhow", 143 | "bumpalo", 144 | "indexmap", 145 | "rustc-hash", 146 | "serde", 147 | "unicode-width", 148 | ] 149 | 150 | [[package]] 151 | name = "dprint-node" 152 | version = "0.1.0" 153 | dependencies = [ 154 | "dprint-core", 155 | "dprint-plugin-typescript", 156 | "jemallocator", 157 | "napi", 158 | "napi-build", 159 | "napi-derive", 160 | ] 161 | 162 | [[package]] 163 | name = "dprint-plugin-typescript" 164 | version = "0.87.1" 165 | source = "registry+https://github.com/rust-lang/crates.io-index" 166 | checksum = "c6be002070326615a3faf423ad398dac631fc5e3289ff7a6ea5bfe2919c21ad6" 167 | dependencies = [ 168 | "anyhow", 169 | "deno_ast", 170 | "dprint-core", 171 | "rustc-hash", 172 | "serde", 173 | ] 174 | 175 | [[package]] 176 | name = "dprint-swc-ext" 177 | version = "0.12.0" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | checksum = "6a0a2492465344a58a37ae119de59e81fe5a2885f2711c7b5048ef0dfa14ce42" 180 | dependencies = [ 181 | "bumpalo", 182 | "num-bigint", 183 | "rustc-hash", 184 | "swc_atoms", 185 | "swc_common", 186 | "swc_ecma_ast", 187 | "swc_ecma_parser", 188 | "text_lines", 189 | ] 190 | 191 | [[package]] 192 | name = "either" 193 | version = "1.9.0" 194 | source = "registry+https://github.com/rust-lang/crates.io-index" 195 | checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" 196 | 197 | [[package]] 198 | name = "form_urlencoded" 199 | version = "1.2.0" 200 | source = "registry+https://github.com/rust-lang/crates.io-index" 201 | checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" 202 | dependencies = [ 203 | "percent-encoding", 204 | ] 205 | 206 | [[package]] 207 | name = "from_variant" 208 | version = "0.1.6" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | checksum = "03ec5dc38ee19078d84a692b1c41181ff9f94331c76cee66ff0208c770b5e54f" 211 | dependencies = [ 212 | "pmutil", 213 | "proc-macro2", 214 | "swc_macros_common", 215 | "syn 2.0.32", 216 | ] 217 | 218 | [[package]] 219 | name = "fs_extra" 220 | version = "1.3.0" 221 | source = "registry+https://github.com/rust-lang/crates.io-index" 222 | checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" 223 | 224 | [[package]] 225 | name = "getrandom" 226 | version = "0.2.10" 227 | source = "registry+https://github.com/rust-lang/crates.io-index" 228 | checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" 229 | dependencies = [ 230 | "cfg-if", 231 | "libc", 232 | "wasi", 233 | ] 234 | 235 | [[package]] 236 | name = "hashbrown" 237 | version = "0.12.3" 238 | source = "registry+https://github.com/rust-lang/crates.io-index" 239 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 240 | 241 | [[package]] 242 | name = "idna" 243 | version = "0.4.0" 244 | source = "registry+https://github.com/rust-lang/crates.io-index" 245 | checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" 246 | dependencies = [ 247 | "unicode-bidi", 248 | "unicode-normalization", 249 | ] 250 | 251 | [[package]] 252 | name = "indexmap" 253 | version = "1.9.3" 254 | source = "registry+https://github.com/rust-lang/crates.io-index" 255 | checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" 256 | dependencies = [ 257 | "autocfg", 258 | "hashbrown", 259 | "serde", 260 | ] 261 | 262 | [[package]] 263 | name = "is-macro" 264 | version = "0.3.0" 265 | source = "registry+https://github.com/rust-lang/crates.io-index" 266 | checksum = "f4467ed1321b310c2625c5aa6c1b1ffc5de4d9e42668cf697a08fb033ee8265e" 267 | dependencies = [ 268 | "Inflector", 269 | "pmutil", 270 | "proc-macro2", 271 | "quote", 272 | "syn 2.0.32", 273 | ] 274 | 275 | [[package]] 276 | name = "itoa" 277 | version = "1.0.9" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" 280 | 281 | [[package]] 282 | name = "jemalloc-sys" 283 | version = "0.3.2" 284 | source = "registry+https://github.com/rust-lang/crates.io-index" 285 | checksum = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45" 286 | dependencies = [ 287 | "cc", 288 | "fs_extra", 289 | "libc", 290 | ] 291 | 292 | [[package]] 293 | name = "jemallocator" 294 | version = "0.3.2" 295 | source = "registry+https://github.com/rust-lang/crates.io-index" 296 | checksum = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69" 297 | dependencies = [ 298 | "jemalloc-sys", 299 | "libc", 300 | ] 301 | 302 | [[package]] 303 | name = "lazy_static" 304 | version = "1.4.0" 305 | source = "registry+https://github.com/rust-lang/crates.io-index" 306 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 307 | 308 | [[package]] 309 | name = "libc" 310 | version = "0.2.148" 311 | source = "registry+https://github.com/rust-lang/crates.io-index" 312 | checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" 313 | 314 | [[package]] 315 | name = "libloading" 316 | version = "0.7.4" 317 | source = "registry+https://github.com/rust-lang/crates.io-index" 318 | checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" 319 | dependencies = [ 320 | "cfg-if", 321 | "winapi", 322 | ] 323 | 324 | [[package]] 325 | name = "lock_api" 326 | version = "0.4.10" 327 | source = "registry+https://github.com/rust-lang/crates.io-index" 328 | checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" 329 | dependencies = [ 330 | "autocfg", 331 | "scopeguard", 332 | ] 333 | 334 | [[package]] 335 | name = "memchr" 336 | version = "2.6.3" 337 | source = "registry+https://github.com/rust-lang/crates.io-index" 338 | checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" 339 | 340 | [[package]] 341 | name = "napi" 342 | version = "2.13.3" 343 | source = "registry+https://github.com/rust-lang/crates.io-index" 344 | checksum = "fd063c93b900149304e3ba96ce5bf210cd4f81ef5eb80ded0d100df3e85a3ac0" 345 | dependencies = [ 346 | "bitflags 2.4.0", 347 | "ctor", 348 | "napi-derive", 349 | "napi-sys", 350 | "once_cell", 351 | "serde", 352 | "serde_json", 353 | ] 354 | 355 | [[package]] 356 | name = "napi-build" 357 | version = "1.2.1" 358 | source = "registry+https://github.com/rust-lang/crates.io-index" 359 | checksum = "ebd4419172727423cf30351406c54f6cc1b354a2cfb4f1dba3e6cd07f6d5522b" 360 | 361 | [[package]] 362 | name = "napi-derive" 363 | version = "2.13.0" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | checksum = "da1c6a8fa84d549aa8708fcd062372bf8ec6e849de39016ab921067d21bde367" 366 | dependencies = [ 367 | "cfg-if", 368 | "convert_case", 369 | "napi-derive-backend", 370 | "proc-macro2", 371 | "quote", 372 | "syn 1.0.109", 373 | ] 374 | 375 | [[package]] 376 | name = "napi-derive-backend" 377 | version = "1.0.52" 378 | source = "registry+https://github.com/rust-lang/crates.io-index" 379 | checksum = "20bbc7c69168d06a848f925ec5f0e0997f98e8c8d4f2cc30157f0da51c009e17" 380 | dependencies = [ 381 | "convert_case", 382 | "once_cell", 383 | "proc-macro2", 384 | "quote", 385 | "regex", 386 | "semver", 387 | "syn 1.0.109", 388 | ] 389 | 390 | [[package]] 391 | name = "napi-sys" 392 | version = "2.2.3" 393 | source = "registry+https://github.com/rust-lang/crates.io-index" 394 | checksum = "166b5ef52a3ab5575047a9fe8d4a030cdd0f63c96f071cd6907674453b07bae3" 395 | dependencies = [ 396 | "libloading", 397 | ] 398 | 399 | [[package]] 400 | name = "new_debug_unreachable" 401 | version = "1.0.4" 402 | source = "registry+https://github.com/rust-lang/crates.io-index" 403 | checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" 404 | 405 | [[package]] 406 | name = "num-bigint" 407 | version = "0.4.4" 408 | source = "registry+https://github.com/rust-lang/crates.io-index" 409 | checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" 410 | dependencies = [ 411 | "autocfg", 412 | "num-integer", 413 | "num-traits", 414 | "serde", 415 | ] 416 | 417 | [[package]] 418 | name = "num-integer" 419 | version = "0.1.45" 420 | source = "registry+https://github.com/rust-lang/crates.io-index" 421 | checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" 422 | dependencies = [ 423 | "autocfg", 424 | "num-traits", 425 | ] 426 | 427 | [[package]] 428 | name = "num-traits" 429 | version = "0.2.16" 430 | source = "registry+https://github.com/rust-lang/crates.io-index" 431 | checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" 432 | dependencies = [ 433 | "autocfg", 434 | ] 435 | 436 | [[package]] 437 | name = "once_cell" 438 | version = "1.18.0" 439 | source = "registry+https://github.com/rust-lang/crates.io-index" 440 | checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" 441 | 442 | [[package]] 443 | name = "parking_lot" 444 | version = "0.12.1" 445 | source = "registry+https://github.com/rust-lang/crates.io-index" 446 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 447 | dependencies = [ 448 | "lock_api", 449 | "parking_lot_core", 450 | ] 451 | 452 | [[package]] 453 | name = "parking_lot_core" 454 | version = "0.9.8" 455 | source = "registry+https://github.com/rust-lang/crates.io-index" 456 | checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" 457 | dependencies = [ 458 | "cfg-if", 459 | "libc", 460 | "redox_syscall", 461 | "smallvec", 462 | "windows-targets", 463 | ] 464 | 465 | [[package]] 466 | name = "percent-encoding" 467 | version = "2.3.0" 468 | source = "registry+https://github.com/rust-lang/crates.io-index" 469 | checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" 470 | 471 | [[package]] 472 | name = "phf_generator" 473 | version = "0.10.0" 474 | source = "registry+https://github.com/rust-lang/crates.io-index" 475 | checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" 476 | dependencies = [ 477 | "phf_shared", 478 | "rand", 479 | ] 480 | 481 | [[package]] 482 | name = "phf_shared" 483 | version = "0.10.0" 484 | source = "registry+https://github.com/rust-lang/crates.io-index" 485 | checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" 486 | dependencies = [ 487 | "siphasher", 488 | ] 489 | 490 | [[package]] 491 | name = "pin-project-lite" 492 | version = "0.2.13" 493 | source = "registry+https://github.com/rust-lang/crates.io-index" 494 | checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" 495 | 496 | [[package]] 497 | name = "pmutil" 498 | version = "0.6.1" 499 | source = "registry+https://github.com/rust-lang/crates.io-index" 500 | checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" 501 | dependencies = [ 502 | "proc-macro2", 503 | "quote", 504 | "syn 2.0.32", 505 | ] 506 | 507 | [[package]] 508 | name = "ppv-lite86" 509 | version = "0.2.17" 510 | source = "registry+https://github.com/rust-lang/crates.io-index" 511 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" 512 | 513 | [[package]] 514 | name = "precomputed-hash" 515 | version = "0.1.1" 516 | source = "registry+https://github.com/rust-lang/crates.io-index" 517 | checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" 518 | 519 | [[package]] 520 | name = "proc-macro2" 521 | version = "1.0.66" 522 | source = "registry+https://github.com/rust-lang/crates.io-index" 523 | checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" 524 | dependencies = [ 525 | "unicode-ident", 526 | ] 527 | 528 | [[package]] 529 | name = "psm" 530 | version = "0.1.21" 531 | source = "registry+https://github.com/rust-lang/crates.io-index" 532 | checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" 533 | dependencies = [ 534 | "cc", 535 | ] 536 | 537 | [[package]] 538 | name = "quote" 539 | version = "1.0.33" 540 | source = "registry+https://github.com/rust-lang/crates.io-index" 541 | checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" 542 | dependencies = [ 543 | "proc-macro2", 544 | ] 545 | 546 | [[package]] 547 | name = "rand" 548 | version = "0.8.5" 549 | source = "registry+https://github.com/rust-lang/crates.io-index" 550 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 551 | dependencies = [ 552 | "libc", 553 | "rand_chacha", 554 | "rand_core", 555 | ] 556 | 557 | [[package]] 558 | name = "rand_chacha" 559 | version = "0.3.1" 560 | source = "registry+https://github.com/rust-lang/crates.io-index" 561 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 562 | dependencies = [ 563 | "ppv-lite86", 564 | "rand_core", 565 | ] 566 | 567 | [[package]] 568 | name = "rand_core" 569 | version = "0.6.4" 570 | source = "registry+https://github.com/rust-lang/crates.io-index" 571 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 572 | dependencies = [ 573 | "getrandom", 574 | ] 575 | 576 | [[package]] 577 | name = "redox_syscall" 578 | version = "0.3.5" 579 | source = "registry+https://github.com/rust-lang/crates.io-index" 580 | checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" 581 | dependencies = [ 582 | "bitflags 1.3.2", 583 | ] 584 | 585 | [[package]] 586 | name = "regex" 587 | version = "1.9.5" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" 590 | dependencies = [ 591 | "aho-corasick", 592 | "memchr", 593 | "regex-automata", 594 | "regex-syntax", 595 | ] 596 | 597 | [[package]] 598 | name = "regex-automata" 599 | version = "0.3.8" 600 | source = "registry+https://github.com/rust-lang/crates.io-index" 601 | checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" 602 | dependencies = [ 603 | "aho-corasick", 604 | "memchr", 605 | "regex-syntax", 606 | ] 607 | 608 | [[package]] 609 | name = "regex-syntax" 610 | version = "0.7.5" 611 | source = "registry+https://github.com/rust-lang/crates.io-index" 612 | checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" 613 | 614 | [[package]] 615 | name = "rustc-hash" 616 | version = "1.1.0" 617 | source = "registry+https://github.com/rust-lang/crates.io-index" 618 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 619 | 620 | [[package]] 621 | name = "ryu" 622 | version = "1.0.15" 623 | source = "registry+https://github.com/rust-lang/crates.io-index" 624 | checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" 625 | 626 | [[package]] 627 | name = "scoped-tls" 628 | version = "1.0.1" 629 | source = "registry+https://github.com/rust-lang/crates.io-index" 630 | checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" 631 | 632 | [[package]] 633 | name = "scopeguard" 634 | version = "1.2.0" 635 | source = "registry+https://github.com/rust-lang/crates.io-index" 636 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 637 | 638 | [[package]] 639 | name = "semver" 640 | version = "1.0.18" 641 | source = "registry+https://github.com/rust-lang/crates.io-index" 642 | checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" 643 | 644 | [[package]] 645 | name = "serde" 646 | version = "1.0.188" 647 | source = "registry+https://github.com/rust-lang/crates.io-index" 648 | checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" 649 | dependencies = [ 650 | "serde_derive", 651 | ] 652 | 653 | [[package]] 654 | name = "serde_derive" 655 | version = "1.0.188" 656 | source = "registry+https://github.com/rust-lang/crates.io-index" 657 | checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" 658 | dependencies = [ 659 | "proc-macro2", 660 | "quote", 661 | "syn 2.0.32", 662 | ] 663 | 664 | [[package]] 665 | name = "serde_json" 666 | version = "1.0.106" 667 | source = "registry+https://github.com/rust-lang/crates.io-index" 668 | checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" 669 | dependencies = [ 670 | "itoa", 671 | "ryu", 672 | "serde", 673 | ] 674 | 675 | [[package]] 676 | name = "siphasher" 677 | version = "0.3.11" 678 | source = "registry+https://github.com/rust-lang/crates.io-index" 679 | checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" 680 | 681 | [[package]] 682 | name = "smallvec" 683 | version = "1.11.0" 684 | source = "registry+https://github.com/rust-lang/crates.io-index" 685 | checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" 686 | 687 | [[package]] 688 | name = "smartstring" 689 | version = "1.0.1" 690 | source = "registry+https://github.com/rust-lang/crates.io-index" 691 | checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" 692 | dependencies = [ 693 | "autocfg", 694 | "static_assertions", 695 | "version_check", 696 | ] 697 | 698 | [[package]] 699 | name = "stable_deref_trait" 700 | version = "1.2.0" 701 | source = "registry+https://github.com/rust-lang/crates.io-index" 702 | checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" 703 | 704 | [[package]] 705 | name = "stacker" 706 | version = "0.1.15" 707 | source = "registry+https://github.com/rust-lang/crates.io-index" 708 | checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" 709 | dependencies = [ 710 | "cc", 711 | "cfg-if", 712 | "libc", 713 | "psm", 714 | "winapi", 715 | ] 716 | 717 | [[package]] 718 | name = "static_assertions" 719 | version = "1.1.0" 720 | source = "registry+https://github.com/rust-lang/crates.io-index" 721 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 722 | 723 | [[package]] 724 | name = "string_cache" 725 | version = "0.8.7" 726 | source = "registry+https://github.com/rust-lang/crates.io-index" 727 | checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" 728 | dependencies = [ 729 | "new_debug_unreachable", 730 | "once_cell", 731 | "parking_lot", 732 | "phf_shared", 733 | "precomputed-hash", 734 | "serde", 735 | ] 736 | 737 | [[package]] 738 | name = "string_cache_codegen" 739 | version = "0.5.2" 740 | source = "registry+https://github.com/rust-lang/crates.io-index" 741 | checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" 742 | dependencies = [ 743 | "phf_generator", 744 | "phf_shared", 745 | "proc-macro2", 746 | "quote", 747 | ] 748 | 749 | [[package]] 750 | name = "string_enum" 751 | version = "0.4.1" 752 | source = "registry+https://github.com/rust-lang/crates.io-index" 753 | checksum = "8fa4d4f81d7c05b9161f8de839975d3326328b8ba2831164b465524cc2f55252" 754 | dependencies = [ 755 | "pmutil", 756 | "proc-macro2", 757 | "quote", 758 | "swc_macros_common", 759 | "syn 2.0.32", 760 | ] 761 | 762 | [[package]] 763 | name = "swc_atoms" 764 | version = "0.5.9" 765 | source = "registry+https://github.com/rust-lang/crates.io-index" 766 | checksum = "9f54563d7dcba626d4acfe14ed12def7ecc28e004debe3ecd2c3ee07cc47e449" 767 | dependencies = [ 768 | "once_cell", 769 | "rustc-hash", 770 | "serde", 771 | "string_cache", 772 | "string_cache_codegen", 773 | "triomphe", 774 | ] 775 | 776 | [[package]] 777 | name = "swc_common" 778 | version = "0.32.0" 779 | source = "registry+https://github.com/rust-lang/crates.io-index" 780 | checksum = "39cb7fcd56655c8ae7dcf2344f0be6cbff4d9c7cb401fe3ec8e56e1de8dfe582" 781 | dependencies = [ 782 | "ast_node", 783 | "better_scoped_tls", 784 | "cfg-if", 785 | "either", 786 | "from_variant", 787 | "new_debug_unreachable", 788 | "num-bigint", 789 | "once_cell", 790 | "rustc-hash", 791 | "serde", 792 | "siphasher", 793 | "string_cache", 794 | "swc_atoms", 795 | "swc_eq_ignore_macros", 796 | "swc_visit", 797 | "tracing", 798 | "unicode-width", 799 | "url", 800 | ] 801 | 802 | [[package]] 803 | name = "swc_ecma_ast" 804 | version = "0.109.0" 805 | source = "registry+https://github.com/rust-lang/crates.io-index" 806 | checksum = "7bc2286cedd688a68f214faa1c19bb5cceab7c9c54d0cbe3273e4c1704e38f69" 807 | dependencies = [ 808 | "bitflags 2.4.0", 809 | "is-macro", 810 | "num-bigint", 811 | "scoped-tls", 812 | "serde", 813 | "string_enum", 814 | "swc_atoms", 815 | "swc_common", 816 | "unicode-id", 817 | ] 818 | 819 | [[package]] 820 | name = "swc_ecma_parser" 821 | version = "0.139.0" 822 | source = "registry+https://github.com/rust-lang/crates.io-index" 823 | checksum = "3eab46cb863bc5cd61535464e07e5b74d5f792fa26a27b9f6fd4c8daca9903b7" 824 | dependencies = [ 825 | "either", 826 | "num-bigint", 827 | "num-traits", 828 | "serde", 829 | "smallvec", 830 | "smartstring", 831 | "stacker", 832 | "swc_atoms", 833 | "swc_common", 834 | "swc_ecma_ast", 835 | "tracing", 836 | "typed-arena", 837 | ] 838 | 839 | [[package]] 840 | name = "swc_eq_ignore_macros" 841 | version = "0.1.2" 842 | source = "registry+https://github.com/rust-lang/crates.io-index" 843 | checksum = "05a95d367e228d52484c53336991fdcf47b6b553ef835d9159db4ba40efb0ee8" 844 | dependencies = [ 845 | "pmutil", 846 | "proc-macro2", 847 | "quote", 848 | "syn 2.0.32", 849 | ] 850 | 851 | [[package]] 852 | name = "swc_macros_common" 853 | version = "0.3.8" 854 | source = "registry+https://github.com/rust-lang/crates.io-index" 855 | checksum = "7a273205ccb09b51fabe88c49f3b34c5a4631c4c00a16ae20e03111d6a42e832" 856 | dependencies = [ 857 | "pmutil", 858 | "proc-macro2", 859 | "quote", 860 | "syn 2.0.32", 861 | ] 862 | 863 | [[package]] 864 | name = "swc_visit" 865 | version = "0.5.7" 866 | source = "registry+https://github.com/rust-lang/crates.io-index" 867 | checksum = "e87c337fbb2d191bf371173dea6a957f01899adb8f189c6c31b122a6cfc98fc3" 868 | dependencies = [ 869 | "either", 870 | "swc_visit_macros", 871 | ] 872 | 873 | [[package]] 874 | name = "swc_visit_macros" 875 | version = "0.5.8" 876 | source = "registry+https://github.com/rust-lang/crates.io-index" 877 | checksum = "0f322730fb82f3930a450ac24de8c98523af7d34ab8cb2f46bcb405839891a99" 878 | dependencies = [ 879 | "Inflector", 880 | "pmutil", 881 | "proc-macro2", 882 | "quote", 883 | "swc_macros_common", 884 | "syn 2.0.32", 885 | ] 886 | 887 | [[package]] 888 | name = "syn" 889 | version = "1.0.109" 890 | source = "registry+https://github.com/rust-lang/crates.io-index" 891 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 892 | dependencies = [ 893 | "proc-macro2", 894 | "quote", 895 | "unicode-ident", 896 | ] 897 | 898 | [[package]] 899 | name = "syn" 900 | version = "2.0.32" 901 | source = "registry+https://github.com/rust-lang/crates.io-index" 902 | checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" 903 | dependencies = [ 904 | "proc-macro2", 905 | "quote", 906 | "unicode-ident", 907 | ] 908 | 909 | [[package]] 910 | name = "text_lines" 911 | version = "0.6.0" 912 | source = "registry+https://github.com/rust-lang/crates.io-index" 913 | checksum = "7fd5828de7deaa782e1dd713006ae96b3bee32d3279b79eb67ecf8072c059bcf" 914 | dependencies = [ 915 | "serde", 916 | ] 917 | 918 | [[package]] 919 | name = "tinyvec" 920 | version = "1.6.0" 921 | source = "registry+https://github.com/rust-lang/crates.io-index" 922 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 923 | dependencies = [ 924 | "tinyvec_macros", 925 | ] 926 | 927 | [[package]] 928 | name = "tinyvec_macros" 929 | version = "0.1.1" 930 | source = "registry+https://github.com/rust-lang/crates.io-index" 931 | checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" 932 | 933 | [[package]] 934 | name = "tracing" 935 | version = "0.1.37" 936 | source = "registry+https://github.com/rust-lang/crates.io-index" 937 | checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" 938 | dependencies = [ 939 | "cfg-if", 940 | "pin-project-lite", 941 | "tracing-attributes", 942 | "tracing-core", 943 | ] 944 | 945 | [[package]] 946 | name = "tracing-attributes" 947 | version = "0.1.26" 948 | source = "registry+https://github.com/rust-lang/crates.io-index" 949 | checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" 950 | dependencies = [ 951 | "proc-macro2", 952 | "quote", 953 | "syn 2.0.32", 954 | ] 955 | 956 | [[package]] 957 | name = "tracing-core" 958 | version = "0.1.31" 959 | source = "registry+https://github.com/rust-lang/crates.io-index" 960 | checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" 961 | dependencies = [ 962 | "once_cell", 963 | ] 964 | 965 | [[package]] 966 | name = "triomphe" 967 | version = "0.1.9" 968 | source = "registry+https://github.com/rust-lang/crates.io-index" 969 | checksum = "0eee8098afad3fb0c54a9007aab6804558410503ad676d4633f9c2559a00ac0f" 970 | dependencies = [ 971 | "serde", 972 | "stable_deref_trait", 973 | ] 974 | 975 | [[package]] 976 | name = "typed-arena" 977 | version = "2.0.2" 978 | source = "registry+https://github.com/rust-lang/crates.io-index" 979 | checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" 980 | 981 | [[package]] 982 | name = "unicode-bidi" 983 | version = "0.3.13" 984 | source = "registry+https://github.com/rust-lang/crates.io-index" 985 | checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" 986 | 987 | [[package]] 988 | name = "unicode-id" 989 | version = "0.3.4" 990 | source = "registry+https://github.com/rust-lang/crates.io-index" 991 | checksum = "b1b6def86329695390197b82c1e244a54a131ceb66c996f2088a3876e2ae083f" 992 | 993 | [[package]] 994 | name = "unicode-ident" 995 | version = "1.0.12" 996 | source = "registry+https://github.com/rust-lang/crates.io-index" 997 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 998 | 999 | [[package]] 1000 | name = "unicode-normalization" 1001 | version = "0.1.22" 1002 | source = "registry+https://github.com/rust-lang/crates.io-index" 1003 | checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" 1004 | dependencies = [ 1005 | "tinyvec", 1006 | ] 1007 | 1008 | [[package]] 1009 | name = "unicode-segmentation" 1010 | version = "1.10.1" 1011 | source = "registry+https://github.com/rust-lang/crates.io-index" 1012 | checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" 1013 | 1014 | [[package]] 1015 | name = "unicode-width" 1016 | version = "0.1.10" 1017 | source = "registry+https://github.com/rust-lang/crates.io-index" 1018 | checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" 1019 | 1020 | [[package]] 1021 | name = "url" 1022 | version = "2.4.1" 1023 | source = "registry+https://github.com/rust-lang/crates.io-index" 1024 | checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" 1025 | dependencies = [ 1026 | "form_urlencoded", 1027 | "idna", 1028 | "percent-encoding", 1029 | ] 1030 | 1031 | [[package]] 1032 | name = "version_check" 1033 | version = "0.9.4" 1034 | source = "registry+https://github.com/rust-lang/crates.io-index" 1035 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1036 | 1037 | [[package]] 1038 | name = "wasi" 1039 | version = "0.11.0+wasi-snapshot-preview1" 1040 | source = "registry+https://github.com/rust-lang/crates.io-index" 1041 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1042 | 1043 | [[package]] 1044 | name = "winapi" 1045 | version = "0.3.9" 1046 | source = "registry+https://github.com/rust-lang/crates.io-index" 1047 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1048 | dependencies = [ 1049 | "winapi-i686-pc-windows-gnu", 1050 | "winapi-x86_64-pc-windows-gnu", 1051 | ] 1052 | 1053 | [[package]] 1054 | name = "winapi-i686-pc-windows-gnu" 1055 | version = "0.4.0" 1056 | source = "registry+https://github.com/rust-lang/crates.io-index" 1057 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1058 | 1059 | [[package]] 1060 | name = "winapi-x86_64-pc-windows-gnu" 1061 | version = "0.4.0" 1062 | source = "registry+https://github.com/rust-lang/crates.io-index" 1063 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1064 | 1065 | [[package]] 1066 | name = "windows-targets" 1067 | version = "0.48.5" 1068 | source = "registry+https://github.com/rust-lang/crates.io-index" 1069 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 1070 | dependencies = [ 1071 | "windows_aarch64_gnullvm", 1072 | "windows_aarch64_msvc", 1073 | "windows_i686_gnu", 1074 | "windows_i686_msvc", 1075 | "windows_x86_64_gnu", 1076 | "windows_x86_64_gnullvm", 1077 | "windows_x86_64_msvc", 1078 | ] 1079 | 1080 | [[package]] 1081 | name = "windows_aarch64_gnullvm" 1082 | version = "0.48.5" 1083 | source = "registry+https://github.com/rust-lang/crates.io-index" 1084 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 1085 | 1086 | [[package]] 1087 | name = "windows_aarch64_msvc" 1088 | version = "0.48.5" 1089 | source = "registry+https://github.com/rust-lang/crates.io-index" 1090 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 1091 | 1092 | [[package]] 1093 | name = "windows_i686_gnu" 1094 | version = "0.48.5" 1095 | source = "registry+https://github.com/rust-lang/crates.io-index" 1096 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 1097 | 1098 | [[package]] 1099 | name = "windows_i686_msvc" 1100 | version = "0.48.5" 1101 | source = "registry+https://github.com/rust-lang/crates.io-index" 1102 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 1103 | 1104 | [[package]] 1105 | name = "windows_x86_64_gnu" 1106 | version = "0.48.5" 1107 | source = "registry+https://github.com/rust-lang/crates.io-index" 1108 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 1109 | 1110 | [[package]] 1111 | name = "windows_x86_64_gnullvm" 1112 | version = "0.48.5" 1113 | source = "registry+https://github.com/rust-lang/crates.io-index" 1114 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 1115 | 1116 | [[package]] 1117 | name = "windows_x86_64_msvc" 1118 | version = "0.48.5" 1119 | source = "registry+https://github.com/rust-lang/crates.io-index" 1120 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 1121 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Devon Govett "] 3 | name = "dprint-node" 4 | version = "0.1.0" 5 | edition = "2021" 6 | 7 | [lib] 8 | crate-type = ["cdylib"] 9 | 10 | [profile.release] 11 | opt-level = 3 12 | lto = true 13 | 14 | [dependencies] 15 | napi = { version = "2", features = ["serde-json"] } 16 | napi-derive = "2" 17 | dprint-plugin-typescript = "0.87.1" 18 | dprint-core = "0.62.1" 19 | 20 | [target.'cfg(target_os = "macos")'.dependencies] 21 | jemallocator = { version = "0.3.2", features = ["disable_initial_exec_tls"] } 22 | 23 | [build-dependencies] 24 | napi-build = { version = "1" } 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Devon Govett 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dprint-node 2 | 3 | A node API for the [dprint](https://dprint.dev) TypeScript and JavaScript code formatter. It's written in Rust for blazing fast speed. 4 | 5 | ## Usage 6 | 7 | Pass a file path and the code to format to `dprint.format`. 8 | 9 | ```js 10 | const dprint = require('dprint-node'); 11 | 12 | dprint.format(filePath, code); 13 | ``` 14 | 15 | You can also optionally pass some configuration options as an object to the third parameter. All of the [options listed here](https://dprint.dev/plugins/typescript/config/) are supported. 16 | 17 | ```js 18 | dprint.format(filePath, code, { 19 | lineWidth: 100 20 | }); 21 | ``` 22 | 23 | ## Benchmark 24 | 25 | ``` 26 | $ node bench.js 27 | #1 dprint: 12,173 opts/sec, ±17% (mean: 0.082ms, stddev: 0.051ms, 50 samples) 28 | #2 prettier: 450 opts/sec, ±53% (mean: 2.222ms, stddev: 4.229ms, 50 samples) 29 | ``` 30 | -------------------------------------------------------------------------------- /bench.js: -------------------------------------------------------------------------------- 1 | const {Benchmark} = require("tiny-benchy"); 2 | const prettier = require('prettier'); 3 | const dprint = require('./'); 4 | 5 | let input = ` 6 | function Example() { 7 | let alertDismiss = (close) => { 8 | close(); 9 | alert('Dialog dismissed.'); 10 | }; 11 | return ( 12 | 13 | Info 14 | {(close) => ( 15 | alertDismiss(close)}> 16 | Version Info 17 | 18 | 19 | Version 1.0.0, Copyright 2020 20 | 21 | 22 | )} 23 | 24 | ); 25 | } 26 | `; 27 | 28 | let suite = new Benchmark({iterations: 50}); 29 | 30 | suite.add('prettier', () => { 31 | prettier.format(input, {parser: 'babel'}); 32 | }); 33 | 34 | suite.add('dprint', () => { 35 | dprint.format('input.js', input); 36 | }); 37 | 38 | suite.run(); 39 | -------------------------------------------------------------------------------- /build.rs: -------------------------------------------------------------------------------- 1 | extern crate napi_build; 2 | 3 | fn main() { 4 | napi_build::setup(); 5 | } 6 | -------------------------------------------------------------------------------- /false: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | 4 | /* auto-generated by NAPI-RS */ 5 | 6 | export function format(fileName: string, code: string, config?: object | undefined | null): string 7 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | import { Options } from './options'; 2 | 3 | export function format(filePath: string, code: string, options?: Options): string; 4 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | let parts = [process.platform, process.arch]; 2 | if (process.platform === 'linux') { 3 | const {MUSL, family} = require('detect-libc'); 4 | if (family === MUSL) { 5 | parts.push('musl'); 6 | } else if (process.arch === 'arm') { 7 | parts.push('gnueabihf'); 8 | } else { 9 | parts.push('gnu'); 10 | } 11 | } else if (process.platform === 'win32') { 12 | parts.push('msvc'); 13 | } 14 | 15 | module.exports = require(`./dprint-node.${parts.join('-')}.node`); 16 | -------------------------------------------------------------------------------- /options.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated by json-schema-to-typescript. 4 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, 5 | * and run json-schema-to-typescript to regenerate this file. 6 | */ 7 | 8 | export type UseTabs = boolean; 9 | export type UseTabs1 = true | false; 10 | export type SemiColons = "always" | "prefer" | "asi"; 11 | export type SemiColons1 = string; 12 | export type QuoteStyle = "alwaysDouble" | "alwaysSingle" | "preferDouble" | "preferSingle"; 13 | export type QuoteStyle1 = string; 14 | export type QuoteProps = "preserve" | "asNeeded"; 15 | export type QuoteProps1 = string; 16 | export type NewLineKind = "auto" | "crlf" | "lf" | "system"; 17 | export type NewLineKind1 = string; 18 | export type UseBraces = "maintain" | "whenNotSingleLine" | "always" | "preferNone"; 19 | export type UseBraces1 = string; 20 | export type BracePosition = "maintain" | "sameLine" | "nextLine" | "sameLineUnlessHanging"; 21 | export type BracePosition1 = string; 22 | export type SingleBodyPosition = "maintain" | "sameLine" | "nextLine"; 23 | export type SingleBodyPosition1 = string; 24 | export type NextControlFlowPosition = "maintain" | "sameLine" | "nextLine"; 25 | export type NextControlFlowPosition1 = string; 26 | export type TrailingCommas = "never" | "always" | "onlyMultiLine"; 27 | export type TrailingCommas1 = string; 28 | export type OperatorPosition = "maintain" | "sameLine" | "nextLine"; 29 | export type OperatorPosition1 = string; 30 | export type PreferHanging = boolean; 31 | export type PreferHanging1 = true | false; 32 | export type PreferSingleLine = boolean; 33 | export type PreferSingleLine1 = true | false; 34 | export type Deno = boolean; 35 | export type Deno1 = true | false; 36 | export type ArrowFunctionUseParentheses = "force" | "maintain" | "preferNone"; 37 | export type ArrowFunctionUseParentheses1 = string; 38 | export type BinaryExpressionLinePerExpression = boolean; 39 | export type BinaryExpressionLinePerExpression1 = true | false; 40 | export type JsxQuoteStyle = "preferDouble" | "preferSingle"; 41 | export type JsxQuoteStyle1 = string; 42 | export type JsxMultiLineParens = "never" | "prefer" | "always"; 43 | export type JsxMultiLineParens1 = string; 44 | export type MemberExpressionLinePerExpression = boolean; 45 | export type MemberExpressionLinePerExpression1 = true | false; 46 | export type TypeLiteralSeparatorKind = "semiColon" | "comma"; 47 | export type TypeLiteralSeparatorKind1 = string; 48 | export type EnumDeclarationMemberSpacing = "newLine" | "blankLine" | "maintain"; 49 | export type EnumDeclarationMemberSpacing1 = string; 50 | export type SpaceAround = boolean; 51 | export type SpaceAround1 = true | false; 52 | export type SpaceSurroundingProperties = boolean; 53 | export type SpaceSurroundingProperties1 = true | false; 54 | export type ObjectExpressionSpaceSurroundingProperties = boolean; 55 | export type ObjectExpressionSpaceSurroundingProperties1 = true | false; 56 | export type ObjectPatternSpaceSurroundingProperties = boolean; 57 | export type ObjectPatternSpaceSurroundingProperties1 = true | false; 58 | export type TypeLiteralSpaceSurroundingProperties = boolean; 59 | export type TypeLiteralSpaceSurroundingProperties1 = true | false; 60 | export type BinaryExpressionSpaceSurroundingBitwiseAndArithmeticOperator = boolean; 61 | export type BinaryExpressionSpaceSurroundingBitwiseAndArithmeticOperator1 = true | false; 62 | export type CommentLineForceSpaceAfterSlashes = boolean; 63 | export type CommentLineForceSpaceAfterSlashes1 = true | false; 64 | export type ConstructorSpaceBeforeParentheses = boolean; 65 | export type ConstructorSpaceBeforeParentheses1 = true | false; 66 | export type ConstructorTypeSpaceAfterNewKeyword = boolean; 67 | export type ConstructorTypeSpaceAfterNewKeyword1 = true | false; 68 | export type ConstructSignatureSpaceAfterNewKeyword = boolean; 69 | export type ConstructSignatureSpaceAfterNewKeyword1 = true | false; 70 | export type DoWhileStatementSpaceAfterWhileKeyword = boolean; 71 | export type DoWhileStatementSpaceAfterWhileKeyword1 = true | false; 72 | export type ExportDeclarationSpaceSurroundingNamedExports = boolean; 73 | export type ExportDeclarationSpaceSurroundingNamedExports1 = true | false; 74 | export type ForInStatementSpaceAfterForKeyword = boolean; 75 | export type ForInStatementSpaceAfterForKeyword1 = true | false; 76 | export type ForOfStatementSpaceAfterForKeyword = boolean; 77 | export type ForOfStatementSpaceAfterForKeyword1 = true | false; 78 | export type ForStatementSpaceAfterForKeyword = boolean; 79 | export type ForStatementSpaceAfterForKeyword1 = true | false; 80 | export type ForStatementSpaceAfterSemiColons = boolean; 81 | export type ForStatementSpaceAfterSemiColons1 = true | false; 82 | export type FunctionDeclarationSpaceBeforeParentheses = boolean; 83 | export type FunctionDeclarationSpaceBeforeParentheses1 = true | false; 84 | export type FunctionExpressionSpaceBeforeParentheses = boolean; 85 | export type FunctionExpressionSpaceBeforeParentheses1 = true | false; 86 | export type FunctionExpressionSpaceAfterFunctionKeyword = boolean; 87 | export type FunctionExpressionSpaceAfterFunctionKeyword1 = true | false; 88 | export type GetAccessorSpaceBeforeParentheses = boolean; 89 | export type GetAccessorSpaceBeforeParentheses1 = true | false; 90 | export type IfStatementSpaceAfterIfKeyword = boolean; 91 | export type IfStatementSpaceAfterIfKeyword1 = true | false; 92 | export type ImportDeclarationSpaceSurroundingNamedImports = boolean; 93 | export type ImportDeclarationSpaceSurroundingNamedImports1 = true | false; 94 | export type JsxElementSpaceBeforeSelfClosingTagSlash = boolean; 95 | export type JsxElementSpaceBeforeSelfClosingTagSlash1 = true | false; 96 | export type JsxExpressionContainerSpaceSurroundingExpression = boolean; 97 | export type JsxExpressionContainerSpaceSurroundingExpression1 = true | false; 98 | export type MethodSpaceBeforeParentheses = boolean; 99 | export type MethodSpaceBeforeParentheses1 = true | false; 100 | export type SetAccessorSpaceBeforeParentheses = boolean; 101 | export type SetAccessorSpaceBeforeParentheses1 = true | false; 102 | export type TaggedTemplateSpaceBeforeLiteral = boolean; 103 | export type TaggedTemplateSpaceBeforeLiteral1 = true | false; 104 | export type TypeAnnotationSpaceBeforeColon = boolean; 105 | export type TypeAnnotationSpaceBeforeColon1 = true | false; 106 | export type TypeAssertionSpaceBeforeExpression = boolean; 107 | export type TypeAssertionSpaceBeforeExpression1 = true | false; 108 | export type WhileStatementSpaceAfterWhileKeyword = boolean; 109 | export type WhileStatementSpaceAfterWhileKeyword1 = true | false; 110 | export type SortOrder = "maintain" | "caseSensitive" | "caseInsensitive"; 111 | export type SortOrder1 = string; 112 | export type ForceSingleLine = boolean; 113 | export type ForceSingleLine1 = true | false; 114 | 115 | export interface Options { 116 | /** 117 | * Whether the configuration is not allowed to be overridden or extended. 118 | */ 119 | locked?: boolean; 120 | /** 121 | * The width of a line the printer will try to stay under. Note that the printer may exceed this width in certain cases. 122 | */ 123 | lineWidth?: number; 124 | /** 125 | * The number of columns for an indent. 126 | */ 127 | indentWidth?: number; 128 | /** 129 | * Whether to use tabs (true) or spaces (false). 130 | */ 131 | useTabs?: UseTabs & UseTabs1; 132 | /** 133 | * How semi-colons should be used. 134 | */ 135 | semiColons?: SemiColons & SemiColons1; 136 | /** 137 | * How to use single or double quotes. 138 | */ 139 | quoteStyle?: QuoteStyle & QuoteStyle1; 140 | /** 141 | * Change when properties in objects are quoted. 142 | */ 143 | quoteProps?: QuoteProps & QuoteProps1; 144 | /** 145 | * The kind of newline to use. 146 | */ 147 | newLineKind?: NewLineKind & NewLineKind1; 148 | /** 149 | * If braces should be used or not. 150 | */ 151 | useBraces?: UseBraces & UseBraces1; 152 | /** 153 | * Where to place the opening brace. 154 | */ 155 | bracePosition?: BracePosition & BracePosition1; 156 | /** 157 | * Where to place the expression of a statement that could possibly be on one line (ex. `if (true) console.log(5);`). 158 | */ 159 | singleBodyPosition?: SingleBodyPosition & SingleBodyPosition1; 160 | /** 161 | * Where to place the next control flow within a control flow statement. 162 | */ 163 | nextControlFlowPosition?: NextControlFlowPosition & NextControlFlowPosition1; 164 | /** 165 | * If trailing commas should be used. 166 | */ 167 | trailingCommas?: TrailingCommas & TrailingCommas1; 168 | /** 169 | * Where to place the operator for expressions that span multiple lines. 170 | */ 171 | operatorPosition?: OperatorPosition & OperatorPosition1; 172 | /** 173 | * Set to prefer hanging indentation when exceeding the line width instead of making code split up on multiple lines. 174 | */ 175 | preferHanging?: PreferHanging & PreferHanging1; 176 | /** 177 | * If code should revert back from being on multiple lines to being on a single line when able. 178 | */ 179 | preferSingleLine?: PreferSingleLine & PreferSingleLine1; 180 | /** 181 | * Top level configuration that sets the configuration to what is used in Deno. 182 | */ 183 | deno?: Deno & Deno1; 184 | /** 185 | * Whether to use parentheses around a single parameter in an arrow function. 186 | */ 187 | "arrowFunction.useParentheses"?: ArrowFunctionUseParentheses & ArrowFunctionUseParentheses1; 188 | /** 189 | * Whether to force a line per expression when spanning multiple lines. 190 | */ 191 | "binaryExpression.linePerExpression"?: BinaryExpressionLinePerExpression & BinaryExpressionLinePerExpression1; 192 | /** 193 | * How to use single or double quotes in JSX attributes. 194 | */ 195 | "jsx.quoteStyle"?: JsxQuoteStyle & JsxQuoteStyle1; 196 | /** 197 | * Surrounds the top-most JSX element or fragment in parentheses when it spans multiple lines. 198 | */ 199 | "jsx.multiLineParens"?: JsxMultiLineParens & JsxMultiLineParens1; 200 | /** 201 | * Whether to force a line per expression when spanning multiple lines. 202 | */ 203 | "memberExpression.linePerExpression"?: MemberExpressionLinePerExpression & MemberExpressionLinePerExpression1; 204 | /** 205 | * The kind of separator to use in type literals. 206 | */ 207 | "typeLiteral.separatorKind"?: TypeLiteralSeparatorKind & TypeLiteralSeparatorKind1; 208 | "typeLiteral.separatorKind.singleLine"?: TypeLiteralSeparatorKind & TypeLiteralSeparatorKind1; 209 | "typeLiteral.separatorKind.multiLine"?: TypeLiteralSeparatorKind & TypeLiteralSeparatorKind1; 210 | /** 211 | * How to space the members of an enum. 212 | */ 213 | "enumDeclaration.memberSpacing"?: EnumDeclarationMemberSpacing & EnumDeclarationMemberSpacing1; 214 | /** 215 | * Whether to place spaces around enclosed expressions. 216 | */ 217 | spaceAround?: SpaceAround & SpaceAround1; 218 | "arguments.spaceAround"?: SpaceAround & SpaceAround1; 219 | "arrayExpression.spaceAround"?: SpaceAround & SpaceAround1; 220 | "arrayPattern.spaceAround"?: SpaceAround & SpaceAround1; 221 | "doWhileStatement.spaceAround"?: SpaceAround & SpaceAround1; 222 | "forInStatement.spaceAround"?: SpaceAround & SpaceAround1; 223 | "forOfStatement.spaceAround"?: SpaceAround & SpaceAround1; 224 | "forStatement.spaceAround"?: SpaceAround & SpaceAround1; 225 | "ifStatement.spaceAround"?: SpaceAround & SpaceAround1; 226 | "parameters.spaceAround"?: SpaceAround & SpaceAround1; 227 | "switchStatement.spaceAround"?: SpaceAround & SpaceAround1; 228 | "tupleType.spaceAround"?: SpaceAround & SpaceAround1; 229 | "whileStatement.spaceAround"?: SpaceAround & SpaceAround1; 230 | /** 231 | * Whether to add a space surrounding the properties of single line object-like nodes. 232 | */ 233 | spaceSurroundingProperties?: SpaceSurroundingProperties & SpaceSurroundingProperties1; 234 | /** 235 | * Whether to add a space surrounding the properties of a single line object expression. 236 | */ 237 | "objectExpression.spaceSurroundingProperties"?: ObjectExpressionSpaceSurroundingProperties & 238 | ObjectExpressionSpaceSurroundingProperties1; 239 | /** 240 | * Whether to add a space surrounding the properties of a single line object pattern. 241 | */ 242 | "objectPattern.spaceSurroundingProperties"?: ObjectPatternSpaceSurroundingProperties & 243 | ObjectPatternSpaceSurroundingProperties1; 244 | /** 245 | * Whether to add a space surrounding the properties of a single line type literal. 246 | */ 247 | "typeLiteral.spaceSurroundingProperties"?: TypeLiteralSpaceSurroundingProperties & 248 | TypeLiteralSpaceSurroundingProperties1; 249 | /** 250 | * Whether to surround the operator in a binary expression with spaces. 251 | */ 252 | "binaryExpression.spaceSurroundingBitwiseAndArithmeticOperator"?: BinaryExpressionSpaceSurroundingBitwiseAndArithmeticOperator & 253 | BinaryExpressionSpaceSurroundingBitwiseAndArithmeticOperator1; 254 | /** 255 | * Forces a space after the double slash in a comment line. 256 | */ 257 | "commentLine.forceSpaceAfterSlashes"?: CommentLineForceSpaceAfterSlashes & CommentLineForceSpaceAfterSlashes1; 258 | /** 259 | * Whether to add a space before the parentheses of a constructor. 260 | */ 261 | "constructor.spaceBeforeParentheses"?: ConstructorSpaceBeforeParentheses & ConstructorSpaceBeforeParentheses1; 262 | /** 263 | * Whether to add a space after the `new` keyword in a constructor type. 264 | */ 265 | "constructorType.spaceAfterNewKeyword"?: ConstructorTypeSpaceAfterNewKeyword & ConstructorTypeSpaceAfterNewKeyword1; 266 | /** 267 | * Whether to add a space after the `new` keyword in a construct signature. 268 | */ 269 | "constructSignature.spaceAfterNewKeyword"?: ConstructSignatureSpaceAfterNewKeyword & 270 | ConstructSignatureSpaceAfterNewKeyword1; 271 | /** 272 | * Whether to add a space after the `while` keyword in a do while statement. 273 | */ 274 | "doWhileStatement.spaceAfterWhileKeyword"?: DoWhileStatementSpaceAfterWhileKeyword & 275 | DoWhileStatementSpaceAfterWhileKeyword1; 276 | /** 277 | * Whether to add spaces around named exports in an export declaration. 278 | */ 279 | "exportDeclaration.spaceSurroundingNamedExports"?: ExportDeclarationSpaceSurroundingNamedExports & 280 | ExportDeclarationSpaceSurroundingNamedExports1; 281 | /** 282 | * Whether to add a space after the `for` keyword in a "for in" statement. 283 | */ 284 | "forInStatement.spaceAfterForKeyword"?: ForInStatementSpaceAfterForKeyword & ForInStatementSpaceAfterForKeyword1; 285 | /** 286 | * Whether to add a space after the `for` keyword in a "for of" statement. 287 | */ 288 | "forOfStatement.spaceAfterForKeyword"?: ForOfStatementSpaceAfterForKeyword & ForOfStatementSpaceAfterForKeyword1; 289 | /** 290 | * Whether to add a space after the `for` keyword in a "for" statement. 291 | */ 292 | "forStatement.spaceAfterForKeyword"?: ForStatementSpaceAfterForKeyword & ForStatementSpaceAfterForKeyword1; 293 | /** 294 | * Whether to add a space after the semi-colons in a "for" statement. 295 | */ 296 | "forStatement.spaceAfterSemiColons"?: ForStatementSpaceAfterSemiColons & ForStatementSpaceAfterSemiColons1; 297 | /** 298 | * Whether to add a space before the parentheses of a function declaration. 299 | */ 300 | "functionDeclaration.spaceBeforeParentheses"?: FunctionDeclarationSpaceBeforeParentheses & 301 | FunctionDeclarationSpaceBeforeParentheses1; 302 | /** 303 | * Whether to add a space before the parentheses of a function expression. 304 | */ 305 | "functionExpression.spaceBeforeParentheses"?: FunctionExpressionSpaceBeforeParentheses & 306 | FunctionExpressionSpaceBeforeParentheses1; 307 | /** 308 | * Whether to add a space after the function keyword of a function expression. 309 | */ 310 | "functionExpression.spaceAfterFunctionKeyword"?: FunctionExpressionSpaceAfterFunctionKeyword & 311 | FunctionExpressionSpaceAfterFunctionKeyword1; 312 | /** 313 | * Whether to add a space before the parentheses of a get accessor. 314 | */ 315 | "getAccessor.spaceBeforeParentheses"?: GetAccessorSpaceBeforeParentheses & GetAccessorSpaceBeforeParentheses1; 316 | /** 317 | * Whether to add a space after the `if` keyword in an "if" statement. 318 | */ 319 | "ifStatement.spaceAfterIfKeyword"?: IfStatementSpaceAfterIfKeyword & IfStatementSpaceAfterIfKeyword1; 320 | /** 321 | * Whether to add spaces around named imports in an import declaration. 322 | */ 323 | "importDeclaration.spaceSurroundingNamedImports"?: ImportDeclarationSpaceSurroundingNamedImports & 324 | ImportDeclarationSpaceSurroundingNamedImports1; 325 | /** 326 | * Whether to add a space before a JSX element's slash when self closing. 327 | */ 328 | "jsxElement.spaceBeforeSelfClosingTagSlash"?: JsxElementSpaceBeforeSelfClosingTagSlash & 329 | JsxElementSpaceBeforeSelfClosingTagSlash1; 330 | /** 331 | * Whether to add a space surrounding the expression of a JSX container. 332 | */ 333 | "jsxExpressionContainer.spaceSurroundingExpression"?: JsxExpressionContainerSpaceSurroundingExpression & 334 | JsxExpressionContainerSpaceSurroundingExpression1; 335 | /** 336 | * Whether to add a space before the parentheses of a method. 337 | */ 338 | "method.spaceBeforeParentheses"?: MethodSpaceBeforeParentheses & MethodSpaceBeforeParentheses1; 339 | /** 340 | * Whether to add a space before the parentheses of a set accessor. 341 | */ 342 | "setAccessor.spaceBeforeParentheses"?: SetAccessorSpaceBeforeParentheses & SetAccessorSpaceBeforeParentheses1; 343 | /** 344 | * Whether to add a space before the literal in a tagged template. 345 | */ 346 | "taggedTemplate.spaceBeforeLiteral"?: TaggedTemplateSpaceBeforeLiteral & TaggedTemplateSpaceBeforeLiteral1; 347 | /** 348 | * Whether to add a space before the colon of a type annotation. 349 | */ 350 | "typeAnnotation.spaceBeforeColon"?: TypeAnnotationSpaceBeforeColon & TypeAnnotationSpaceBeforeColon1; 351 | /** 352 | * Whether to add a space before the expression in a type assertion. 353 | */ 354 | "typeAssertion.spaceBeforeExpression"?: TypeAssertionSpaceBeforeExpression & TypeAssertionSpaceBeforeExpression1; 355 | /** 356 | * Whether to add a space after the `while` keyword in a while statement. 357 | */ 358 | "whileStatement.spaceAfterWhileKeyword"?: WhileStatementSpaceAfterWhileKeyword & 359 | WhileStatementSpaceAfterWhileKeyword1; 360 | /** 361 | * The kind of sort ordering to use. 362 | */ 363 | "module.sortImportDeclarations"?: SortOrder & SortOrder1; 364 | "module.sortExportDeclarations"?: SortOrder & SortOrder1; 365 | "exportDeclaration.sortNamedExports"?: SortOrder & SortOrder1; 366 | "importDeclaration.sortNamedImports"?: SortOrder & SortOrder1; 367 | /** 368 | * The text to use for an ignore comment (ex. `// dprint-ignore`). 369 | */ 370 | ignoreNodeCommentText?: string; 371 | /** 372 | * The text to use for a file ignore comment (ex. `// dprint-ignore-file`). 373 | */ 374 | ignoreFileCommentText?: string; 375 | "forInStatement.useBraces"?: UseBraces & UseBraces1; 376 | "forOfStatement.useBraces"?: UseBraces & UseBraces1; 377 | "forStatement.useBraces"?: UseBraces & UseBraces1; 378 | "ifStatement.useBraces"?: UseBraces & UseBraces1; 379 | "whileStatement.useBraces"?: UseBraces & UseBraces1; 380 | "arrowFunction.bracePosition"?: BracePosition & BracePosition1; 381 | "classDeclaration.bracePosition"?: BracePosition & BracePosition1; 382 | "classExpression.bracePosition"?: BracePosition & BracePosition1; 383 | "constructor.bracePosition"?: BracePosition & BracePosition1; 384 | "doWhileStatement.bracePosition"?: BracePosition & BracePosition1; 385 | "enumDeclaration.bracePosition"?: BracePosition & BracePosition1; 386 | "forInStatement.bracePosition"?: BracePosition & BracePosition1; 387 | "forOfStatement.bracePosition"?: BracePosition & BracePosition1; 388 | "forStatement.bracePosition"?: BracePosition & BracePosition1; 389 | "functionDeclaration.bracePosition"?: BracePosition & BracePosition1; 390 | "functionExpression.bracePosition"?: BracePosition & BracePosition1; 391 | "getAccessor.bracePosition"?: BracePosition & BracePosition1; 392 | "ifStatement.bracePosition"?: BracePosition & BracePosition1; 393 | "interfaceDeclaration.bracePosition"?: BracePosition & BracePosition1; 394 | "moduleDeclaration.bracePosition"?: BracePosition & BracePosition1; 395 | "method.bracePosition"?: BracePosition & BracePosition1; 396 | "setAccessor.bracePosition"?: BracePosition & BracePosition1; 397 | "staticBlock.bracePosition"?: BracePosition & BracePosition1; 398 | "switchStatement.bracePosition"?: BracePosition & BracePosition1; 399 | "switchCase.bracePosition"?: BracePosition & BracePosition1; 400 | "tryStatement.bracePosition"?: BracePosition & BracePosition1; 401 | "whileStatement.bracePosition"?: BracePosition & BracePosition1; 402 | "forInStatement.singleBodyPosition"?: SingleBodyPosition & SingleBodyPosition1; 403 | "forOfStatement.singleBodyPosition"?: SingleBodyPosition & SingleBodyPosition1; 404 | "forStatement.singleBodyPosition"?: SingleBodyPosition & SingleBodyPosition1; 405 | "ifStatement.singleBodyPosition"?: SingleBodyPosition & SingleBodyPosition1; 406 | "whileStatement.singleBodyPosition"?: SingleBodyPosition & SingleBodyPosition1; 407 | "ifStatement.nextControlFlowPosition"?: NextControlFlowPosition & NextControlFlowPosition1; 408 | "tryStatement.nextControlFlowPosition"?: NextControlFlowPosition & NextControlFlowPosition1; 409 | "arguments.trailingCommas"?: TrailingCommas & TrailingCommas1; 410 | "parameters.trailingCommas"?: TrailingCommas & TrailingCommas1; 411 | "arrayExpression.trailingCommas"?: TrailingCommas & TrailingCommas1; 412 | "arrayPattern.trailingCommas"?: TrailingCommas & TrailingCommas1; 413 | "enumDeclaration.trailingCommas"?: TrailingCommas & TrailingCommas1; 414 | "exportDeclaration.trailingCommas"?: TrailingCommas & TrailingCommas1; 415 | "importDeclaration.trailingCommas"?: TrailingCommas & TrailingCommas1; 416 | "objectExpression.trailingCommas"?: TrailingCommas & TrailingCommas1; 417 | "objectPattern.trailingCommas"?: TrailingCommas & TrailingCommas1; 418 | "tupleType.trailingCommas"?: TrailingCommas & TrailingCommas1; 419 | "typeLiteral.trailingCommas"?: TrailingCommas & TrailingCommas1; 420 | "typeParameters.trailingCommas"?: TrailingCommas & TrailingCommas1; 421 | "binaryExpression.operatorPosition"?: OperatorPosition & OperatorPosition1; 422 | "conditionalExpression.operatorPosition"?: OperatorPosition & OperatorPosition1; 423 | "arguments.preferHanging"?: PreferHanging & PreferHanging1; 424 | "arrayExpression.preferHanging"?: PreferHanging & PreferHanging1; 425 | "arrayPattern.preferHanging"?: PreferHanging & PreferHanging1; 426 | "doWhileStatement.preferHanging"?: PreferHanging & PreferHanging1; 427 | "exportDeclaration.preferHanging"?: PreferHanging & PreferHanging1; 428 | "extendsClause.preferHanging"?: PreferHanging & PreferHanging1; 429 | "forInStatement.preferHanging"?: PreferHanging & PreferHanging1; 430 | "forOfStatement.preferHanging"?: PreferHanging & PreferHanging1; 431 | "forStatement.preferHanging"?: PreferHanging & PreferHanging1; 432 | "ifStatement.preferHanging"?: PreferHanging & PreferHanging1; 433 | "implementsClause.preferHanging"?: PreferHanging & PreferHanging1; 434 | "importDeclaration.preferHanging"?: PreferHanging & PreferHanging1; 435 | "jsxAttributes.preferHanging"?: PreferHanging & PreferHanging1; 436 | "objectExpression.preferHanging"?: PreferHanging & PreferHanging1; 437 | "objectPattern.preferHanging"?: PreferHanging & PreferHanging1; 438 | "parameters.preferHanging"?: PreferHanging & PreferHanging1; 439 | "sequenceExpression.preferHanging"?: PreferHanging & PreferHanging1; 440 | "switchStatement.preferHanging"?: PreferHanging & PreferHanging1; 441 | "tupleType.preferHanging"?: PreferHanging & PreferHanging1; 442 | "typeLiteral.preferHanging"?: PreferHanging & PreferHanging1; 443 | "typeParameters.preferHanging"?: PreferHanging & PreferHanging1; 444 | "unionAndIntersectionType.preferHanging"?: PreferHanging & PreferHanging1; 445 | "variableStatement.preferHanging"?: PreferHanging & PreferHanging1; 446 | "whileStatement.preferHanging"?: PreferHanging & PreferHanging1; 447 | "arrayExpression.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 448 | "arrayPattern.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 449 | "arguments.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 450 | "binaryExpression.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 451 | "computed.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 452 | "conditionalExpression.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 453 | "conditionalType.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 454 | "decorators.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 455 | "exportDeclaration.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 456 | "forStatement.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 457 | "importDeclaration.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 458 | "jsxAttributes.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 459 | "jsxElement.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 460 | "mappedType.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 461 | "memberExpression.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 462 | "objectExpression.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 463 | "objectPattern.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 464 | "parameters.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 465 | "parentheses.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 466 | "tupleType.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 467 | "typeLiteral.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 468 | "typeParameters.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 469 | "unionAndIntersectionType.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 470 | "variableStatement.preferSingleLine"?: PreferSingleLine & PreferSingleLine1; 471 | /** 472 | * If code should be forced to be on a single line if able. 473 | */ 474 | "exportDeclaration.forceSingleLine"?: ForceSingleLine & ForceSingleLine1; 475 | "importDeclaration.forceSingleLine"?: ForceSingleLine & ForceSingleLine1; 476 | [k: string]: unknown; 477 | } 478 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dprint-node", 3 | "version": "1.0.8", 4 | "description": "A node API for the dprint TypeScript and JavaScript code formatter", 5 | "repository": "https://github.com/devongovett/dprint-node", 6 | "author": "Devon Govett ", 7 | "license": "MIT", 8 | "napi": { 9 | "name": "dprint-node" 10 | }, 11 | "files": [ 12 | "*.node", 13 | "index.js", 14 | "index.d.ts", 15 | "options.d.ts" 16 | ], 17 | "scripts": { 18 | "build": "napi build --platform --dts false --js false", 19 | "build-release": "napi build --platform --release --dts false --js false" 20 | }, 21 | "dependencies": { 22 | "detect-libc": "^1.0.3" 23 | }, 24 | "devDependencies": { 25 | "@napi-rs/cli": "^2.11.4", 26 | "prettier": "^2.7.1", 27 | "tiny-benchy": "^2.1.0" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(target_os = "macos")] 2 | #[global_allocator] 3 | static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; 4 | 5 | use dprint_core::configuration::{ 6 | resolve_global_config, ConfigKeyMap, ConfigKeyValue, ResolveGlobalConfigOptions, 7 | }; 8 | use dprint_plugin_typescript::{ 9 | configuration::{resolve_config, ConfigurationBuilder}, 10 | format_text, 11 | }; 12 | use napi::{JsBoolean, JsNumber, JsObject, JsString, JsUnknown, Result, ValueType}; 13 | use napi_derive::napi; 14 | use std::path::Path; 15 | 16 | #[napi] 17 | fn format(file_name: String, code: String, config: Option) -> Result { 18 | let path = Path::new(&file_name); 19 | 20 | let config = match config { 21 | Some(obj) => { 22 | let mut c = ConfigKeyMap::new(); 23 | c.insert("deno".into(), ConfigKeyValue::Bool(true)); 24 | 25 | let properties = obj.get_property_names()?; 26 | let len = properties 27 | .get_named_property::("length")? 28 | .get_uint32()?; 29 | for i in 0..len { 30 | let property = properties.get_element::(i)?; 31 | let property_str = property.into_utf8()?; 32 | let k = property_str.into_owned()?; 33 | let value: JsUnknown = obj.get_property(property)?; 34 | let v = match value.get_type()? { 35 | ValueType::String => { 36 | let s = unsafe { value.cast::() }.into_utf8()?; 37 | ConfigKeyValue::String(s.into_owned()?) 38 | } 39 | ValueType::Number => { 40 | ConfigKeyValue::Number(unsafe { value.cast::() }.get_int32()?) 41 | } 42 | ValueType::Boolean => { 43 | ConfigKeyValue::Bool(unsafe { value.cast::() }.get_value()?) 44 | } 45 | _ => { 46 | return Err(napi::Error::new( 47 | napi::Status::InvalidArg, 48 | format!("Unsupported type for configuration property {}", k), 49 | )) 50 | } 51 | }; 52 | 53 | c.insert(k, v); 54 | } 55 | let res = resolve_config( 56 | c, 57 | &resolve_global_config(ConfigKeyMap::new(), &ResolveGlobalConfigOptions::default()) 58 | .config, 59 | ); 60 | if !res.diagnostics.is_empty() { 61 | let message = res 62 | .diagnostics 63 | .iter() 64 | .map(|d| d.message.clone()) 65 | .collect::>() 66 | .join("\n "); 67 | return Err(napi::Error::new( 68 | napi::Status::InvalidArg, 69 | format!("Invalid configuration.\n {}", message), 70 | )); 71 | } 72 | res.config 73 | } 74 | _ => ConfigurationBuilder::new().deno().build(), 75 | }; 76 | 77 | match format_text(&path, &code, &config) { 78 | Ok(res) => Ok(res.unwrap_or(code)), 79 | Err(e) => Err(napi::Error::new( 80 | napi::Status::GenericFailure, 81 | e.to_string(), 82 | )), 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | const dprint = require('./'); 2 | 3 | let input = ` 4 | function Example() { 5 | let alertDismiss = (close) => { 6 | close(); 7 | alert('Dialog dismissed.'); 8 | }; 9 | return ( 10 | 11 | Info 12 | {(close) => ( 13 | alertDismiss(close)}> 14 | Version Info 15 | 16 | 17 | Version 1.0.0, Copyright 2020 18 | 19 | 20 | )} 21 | 22 | ); 23 | } 24 | `; 25 | 26 | console.log(dprint.format('test.js', input, {lineWidth: 80})); 27 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@napi-rs/cli@^2.11.4": 6 | version "2.11.4" 7 | resolved "https://registry.yarnpkg.com/@napi-rs/cli/-/cli-2.11.4.tgz#28bea72dd6758ce7fc94d515493c5bd1ef00b6ec" 8 | integrity sha512-rjU651owB4GJetO3pnu3B8TyVM3Fis3AYb+U16bKxYyykp81S+dJlIgWc8Lc0t55PYbHlBM3hxdgy4pultxMAw== 9 | 10 | detect-libc@^1.0.3: 11 | version "1.0.3" 12 | resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" 13 | integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= 14 | 15 | prettier@^2.7.1: 16 | version "2.7.1" 17 | resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" 18 | integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== 19 | 20 | tiny-benchy@^2.1.0: 21 | version "2.1.0" 22 | resolved "https://registry.yarnpkg.com/tiny-benchy/-/tiny-benchy-2.1.0.tgz#f14c2597c54dd4c35ab582824ca4613a60d010d3" 23 | integrity sha512-84QOWzFrcrswVVfpGp0Bg1uLLKC59EdgT58l57A8J8orCR2wGemCsqsxhpJ7JmbTx8py2915+B9kpcsPDmuTcQ== 24 | --------------------------------------------------------------------------------