mirror of
https://github.com/swc-project/swc.git
synced 2024-10-05 12:49:21 +03:00
fix(es/module): Fix jsc.paths
for projects using pnpm (#7918)
**Related issue:** - x-ref: https://vercel.slack.com/archives/C04DUD7EB1B/p1693911653100299?thread_ts=1693819683.070959&cid=C04DUD7EB1B
This commit is contained in:
parent
5c005256d6
commit
a86e9f3bb5
3
.gitignore
vendored
3
.gitignore
vendored
@ -24,7 +24,7 @@ target/
|
||||
|
||||
.DS_Store
|
||||
|
||||
node_modules/
|
||||
/node_modules/
|
||||
|
||||
# Flamegraph
|
||||
*.html
|
||||
@ -42,7 +42,6 @@ package-lock.json
|
||||
.COVERAGE_DIR
|
||||
|
||||
**/*~
|
||||
**/node_modules
|
||||
**/.DS_Store
|
||||
|
||||
pkg/
|
||||
|
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -6,7 +6,6 @@
|
||||
"**/CVS": true,
|
||||
"**/.DS_Store": true,
|
||||
"**/*.bk": true,
|
||||
"**/node_modules": true,
|
||||
"**/target": true
|
||||
},
|
||||
"[rust]": {
|
||||
|
93
bindings/Cargo.lock
generated
93
bindings/Cargo.lock
generated
@ -242,9 +242,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "binding_macros"
|
||||
version = "0.56.10"
|
||||
version = "0.57.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7379c1a81786adc4a7a0bfe197be24402b1314bf7f0e0f45d10de767377aeac"
|
||||
checksum = "31475ae346fe044712464cd23b4062920baca17154a3cb571ac22a59952f57cc"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"console_error_panic_hook",
|
||||
@ -2800,9 +2800,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc"
|
||||
version = "0.265.10"
|
||||
version = "0.266.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ca1e03e7be80a2eae021b23317936d1782998cba8447b56e8f9e13402366837"
|
||||
checksum = "ee8d051cbb46162e3c7a7c2ffb43b0b2d9f1994a68dd84ef422afd752acd398c"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.13.1",
|
||||
@ -2867,9 +2867,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_bundler"
|
||||
version = "0.219.8"
|
||||
version = "0.220.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3a67bb31be024e911195c51dd8ea2a6b3f032d75862e1f81038bba80f67088f"
|
||||
checksum = "0999cc2f5e03dc2817c709f03200a6d27ff2535cb21a325628b2cbbb72c87981"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"crc",
|
||||
@ -2992,9 +2992,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_core"
|
||||
version = "0.82.10"
|
||||
version = "0.83.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "567897c2eaeebc497baa7d1c0047b9d1c807bb88b0b21039485252677d3a05c6"
|
||||
checksum = "22079c12192337bec144dace0e35a934e407db36e9dc21c5d9b876b0b7c9fba2"
|
||||
dependencies = [
|
||||
"binding_macros",
|
||||
"swc",
|
||||
@ -3002,6 +3002,7 @@ dependencies = [
|
||||
"swc_bundler",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen",
|
||||
"swc_ecma_loader",
|
||||
"swc_ecma_transforms_base",
|
||||
"swc_ecma_visit",
|
||||
@ -3035,9 +3036,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_codegen"
|
||||
version = "0.144.2"
|
||||
version = "0.145.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c18a128504833fe3b7201d830271a12d71d76bb6472ede6f11677e98fca9eda"
|
||||
checksum = "3387d6ec9e636999b76af7d604e430f62ac16aee7cff1ff9aa466d7387b59143"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"num-bigint",
|
||||
@ -3067,9 +3068,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_ext_transforms"
|
||||
version = "0.108.1"
|
||||
version = "0.109.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2544221560ee7f035946e93c6407b78f814b0220ae5e1d2a831cfb8418e4699a"
|
||||
checksum = "d995f94740b4cde4919e6e03d982230f755f49dac9dac52f0218254a1fd69f2b"
|
||||
dependencies = [
|
||||
"phf",
|
||||
"swc_atoms",
|
||||
@ -3081,9 +3082,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_lints"
|
||||
version = "0.87.4"
|
||||
version = "0.88.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d69869bb58bf428c8392084d6ead64b164ddec2b979a03b9c6eb70fa617904a1"
|
||||
checksum = "c79cd55fe7b36ba9399fa66609c97cc9220f09a8e7d12e86d721360df1f9c107"
|
||||
dependencies = [
|
||||
"auto_impl",
|
||||
"dashmap",
|
||||
@ -3122,9 +3123,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_minifier"
|
||||
version = "0.186.8"
|
||||
version = "0.187.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f07913f04dfe7baa6a608dea418e69f318518c661814ea2b4c6d355bc5a68fdb"
|
||||
checksum = "5d71b5b6d1f76782e3f91f0ded61364dce32ed70a2b1cf48edb02f7f753b2608"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"indexmap",
|
||||
@ -3157,9 +3158,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_parser"
|
||||
version = "0.139.1"
|
||||
version = "0.140.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e2abc67575c5fcc77cfb9b3eaaeb73bac2cac265504a1fc06a04d0ebbc4c53b"
|
||||
checksum = "3c968599841fcecfdc2e490188ad93251897a1bb912882547e6889e14a368399"
|
||||
dependencies = [
|
||||
"either",
|
||||
"num-bigint",
|
||||
@ -3177,9 +3178,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_preset_env"
|
||||
version = "0.200.7"
|
||||
version = "0.201.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7890a174b923add0d1579b89145b7a6920e83886b688d59c7537e1c89f6c865"
|
||||
checksum = "17148615f8e209fa42f22a4cb893e91b7097c3b65bb5b6202657ba3583b65170"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dashmap",
|
||||
@ -3202,9 +3203,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms"
|
||||
version = "0.223.6"
|
||||
version = "0.224.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d78c832cd4814a2d0a72f404181767cd3086af0dc711da8d250c2cbe09680ae"
|
||||
checksum = "7bbb521b9cddc76c62d9f0243708dbb4797e957922a4953d9722aeef7a53d174"
|
||||
dependencies = [
|
||||
"swc_atoms",
|
||||
"swc_common",
|
||||
@ -3222,9 +3223,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_base"
|
||||
version = "0.132.4"
|
||||
version = "0.133.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82b9cbdb2be485815eb755a0014b3c2a9008ba0c20634b9ccbdef78a79d76c1e"
|
||||
checksum = "d7787d3607d628ad0cc2e7173770f6a43229ce46e55136e81e5fdeb0951dd6c9"
|
||||
dependencies = [
|
||||
"better_scoped_tls",
|
||||
"bitflags 2.3.3",
|
||||
@ -3246,9 +3247,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_classes"
|
||||
version = "0.121.4"
|
||||
version = "0.122.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca2024092cf6ce2bccf714d1ee06f23dc719d7e1f8bf8c04da11abeff9288d1b"
|
||||
checksum = "ad3878381c7a115528f90bd1df4a97ac82711b7013f60b1cbf43982ad31ec645"
|
||||
dependencies = [
|
||||
"swc_atoms",
|
||||
"swc_common",
|
||||
@ -3260,9 +3261,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_compat"
|
||||
version = "0.158.5"
|
||||
version = "0.159.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce98b4da27cec62683329e2c1c5fe7e1a43a44f7a0fe7c436a9cce42eb684917"
|
||||
checksum = "64d4fbea0d55e51492c6bedb37f42b57968df0b1469ef58a9d2532f978131aeb"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"indexmap",
|
||||
@ -3299,9 +3300,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_module"
|
||||
version = "0.175.6"
|
||||
version = "0.176.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d8dad438bcb6ae3051e6a6da8e01c9606c997e9f6c57d8fedace63ee64e80b4"
|
||||
checksum = "b040349682a36a0fb036351fdac4e99a6f1190186c1aed81db29ddb2ba1d0355"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"anyhow",
|
||||
@ -3326,9 +3327,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_optimization"
|
||||
version = "0.192.6"
|
||||
version = "0.193.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb010e3b1664539d63dc46866e4ec74c96c3044d5395260abc6a4163022d9a93"
|
||||
checksum = "0128684058b111f809aa97af9c327523ad232cd4fea14c8f57ce1a3235a1ccf9"
|
||||
dependencies = [
|
||||
"dashmap",
|
||||
"indexmap",
|
||||
@ -3351,9 +3352,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_proposal"
|
||||
version = "0.166.5"
|
||||
version = "0.167.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1244684381c23422ce7f1b9d9dc2541aa008cf5da5b9a3a9d74e5cf0c0b04867"
|
||||
checksum = "00df76004234c6ee80a70a1d869cefe9b223d878b18b7bfd799b574112cd29bc"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rustc-hash",
|
||||
@ -3371,9 +3372,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_react"
|
||||
version = "0.178.6"
|
||||
version = "0.179.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7634824044c431f80f6a5cdc7eb0568b08d8915c5da20427b36ffcf5759e26b"
|
||||
checksum = "59b9c4a068b55238df8bd70730651d45b39d5c924fc4bf4ccbb912e48b406eac"
|
||||
dependencies = [
|
||||
"base64 0.13.1",
|
||||
"dashmap",
|
||||
@ -3396,9 +3397,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_typescript"
|
||||
version = "0.182.6"
|
||||
version = "0.183.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "465158f5266c85c24bf602d8e314935651233328def7f49a5be2d0d57507b50c"
|
||||
checksum = "8d7d39b89a675bc0a8e7b96135899faa2e5f1d29d3c628c16099bf3875ecf077"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"swc_atoms",
|
||||
@ -3412,9 +3413,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_usage_analyzer"
|
||||
version = "0.18.2"
|
||||
version = "0.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89263934ddec01e3738cea970fdf6029b780ad4053d506eb84db9f56b2b95777"
|
||||
checksum = "d71dc9b35f1f137c72badbadb705a2325d161ff603224ab0e07e6834774ea281"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"rustc-hash",
|
||||
@ -3429,9 +3430,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_utils"
|
||||
version = "0.122.1"
|
||||
version = "0.123.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47f412679df4b7f28354b81acdf0fbf53816366019f21e5affc1482b868bda1d"
|
||||
checksum = "5b6d6b59ebd31b25fe2692ff705c806961e7856de8b7e91fd0942328886cd315"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"num_cpus",
|
||||
@ -3535,9 +3536,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_node_bundler"
|
||||
version = "0.54.10"
|
||||
version = "0.55.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ad20a1de24f938346630828c951b38488db4dd4461de7f42b522c1df37ea3ce"
|
||||
checksum = "7c5755844a65c9d2fb7cee1d306859a97409cb35980fcae9f9f0ced09ca6a954"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dashmap",
|
||||
@ -3603,9 +3604,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_plugin_runner"
|
||||
version = "0.101.1"
|
||||
version = "0.102.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de5d17c23f3cde487d510d488fdc420a9150474536e0a525b933375ad8eb711d"
|
||||
checksum = "64706a6675712e565a60e4b4bb369124a22296d4d76ff713a4d3029f94138466"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"enumset",
|
||||
|
@ -51,7 +51,7 @@ tracing-chrome = "0.5.0"
|
||||
tracing-futures = "0.2.5"
|
||||
tracing-subscriber = { version = "0.3.9", features = ["env-filter"] }
|
||||
|
||||
swc_core = { version = "0.82.10", features = [
|
||||
swc_core = { version = "0.83.0", features = [
|
||||
"allocator_node",
|
||||
"ecma_ast",
|
||||
"ecma_codegen",
|
||||
|
@ -35,7 +35,7 @@ anyhow = "1.0.66"
|
||||
getrandom = { version = "0.2.10", features = ["js"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde-wasm-bindgen = "0.4.5"
|
||||
swc_core = { version = "0.82.10", features = [
|
||||
swc_core = { version = "0.83.0", features = [
|
||||
"ecma_ast_serde",
|
||||
"ecma_codegen",
|
||||
"binding_macro_wasm",
|
||||
|
@ -30,7 +30,7 @@ relative-path = "1.6.1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = { version = "1", features = ["unbounded_depth"] }
|
||||
sourcemap = "6.2.2"
|
||||
swc_core = { version = "0.82.10", features = [
|
||||
swc_core = { version = "0.83.0", features = [
|
||||
"trace_macro",
|
||||
"common_concurrent",
|
||||
"base_concurrent",
|
||||
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
},
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"*": [
|
||||
"./*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
import { nanoid } from 'nanoid';
|
||||
import { fnv1a } from '../fnv1a';
|
||||
|
||||
export const VERCEL_AUTHENTICATED_PREFIX = 'v_';
|
||||
|
||||
/**
|
||||
* 1.0 -- random IDs from nanoid() with default length. Authenticated IDs are v_vercelUserID.
|
||||
*/
|
||||
export const IDENTITY_VERSION = '1.0';
|
||||
|
||||
export function generateRandomID(): string {
|
||||
return nanoid();
|
||||
}
|
||||
|
||||
export function formatAuthenticatedID(vercelUserUid: string): string {
|
||||
return `${VERCEL_AUTHENTICATED_PREFIX}${vercelUserUid}`;
|
||||
}
|
||||
|
||||
export function computeIdentityVersion(): string {
|
||||
return String(fnv1a(IDENTITY_VERSION));
|
||||
}
|
17
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.bin/nanoid
generated
vendored
Executable file
17
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.bin/nanoid
generated
vendored
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -z "$NODE_PATH" ]; then
|
||||
export NODE_PATH="/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/bin/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/node_modules"
|
||||
else
|
||||
export NODE_PATH="/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/bin/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/node_modules:$NODE_PATH"
|
||||
fi
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../nanoid/bin/nanoid.js" "$@"
|
||||
else
|
||||
exec node "$basedir/../nanoid/bin/nanoid.js" "$@"
|
||||
fi
|
21
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.modules.yaml
generated
vendored
Normal file
21
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.modules.yaml
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
hoistPattern:
|
||||
- '*'
|
||||
hoistedDependencies: {}
|
||||
included:
|
||||
dependencies: true
|
||||
devDependencies: true
|
||||
optionalDependencies: true
|
||||
injectedDeps: {}
|
||||
layoutVersion: 5
|
||||
nodeLinker: isolated
|
||||
packageManager: pnpm@8.7.4
|
||||
pendingBuilds: []
|
||||
prunedAt: Wed, 06 Sep 2023 09:58:59 GMT
|
||||
publicHoistPattern:
|
||||
- '*eslint*'
|
||||
- '*prettier*'
|
||||
registries:
|
||||
default: https://registry.npmjs.org/
|
||||
skipped: []
|
||||
storeDir: /Users/kdy1/Library/pnpm/store/v3
|
||||
virtualStoreDir: .pnpm
|
18
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/lock.yaml
generated
vendored
Normal file
18
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/lock.yaml
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
nanoid:
|
||||
specifier: ^4.0.2
|
||||
version: 4.0.2
|
||||
|
||||
packages:
|
||||
|
||||
/nanoid@4.0.2:
|
||||
resolution: {integrity: sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw==}
|
||||
engines: {node: ^14 || ^16 || >=18}
|
||||
hasBin: true
|
||||
dev: false
|
20
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/LICENSE
generated
vendored
Normal file
20
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/LICENSE
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
38
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/README.md
generated
vendored
Normal file
38
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/README.md
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
# Nano ID
|
||||
|
||||
<img src="https://ai.github.io/nanoid/logo.svg" align="right"
|
||||
alt="Nano ID logo by Anton Lovchikov" width="180" height="94">
|
||||
|
||||
**English** | [Русский](./README.ru.md) | [简体中文](./README.zh-CN.md) | [Bahasa Indonesia](./README.id-ID.md)
|
||||
|
||||
A tiny, secure, URL-friendly, unique string ID generator for JavaScript.
|
||||
|
||||
> “An amazing level of senseless perfectionism,
|
||||
> which is simply impossible not to respect.”
|
||||
|
||||
* **Small.** 130 bytes (minified and gzipped). No dependencies.
|
||||
[Size Limit] controls the size.
|
||||
* **Safe.** It uses hardware random generator. Can be used in clusters.
|
||||
* **Short IDs.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
|
||||
So ID size was reduced from 36 to 21 symbols.
|
||||
* **Portable.** Nano ID was ported
|
||||
to [20 programming languages](./README.md#other-programming-languages).
|
||||
|
||||
```js
|
||||
import { nanoid } from 'nanoid'
|
||||
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
|
||||
```
|
||||
|
||||
Supports modern browsers, IE [with Babel], Node.js and React Native.
|
||||
|
||||
[online tool]: https://gitpod.io/#https://github.com/ai/nanoid/
|
||||
[with Babel]: https://developer.epages.com/blog/coding/how-to-transpile-node-modules-with-babel-and-webpack-in-a-monorepo/
|
||||
[Size Limit]: https://github.com/ai/size-limit
|
||||
|
||||
<a href="https://evilmartians.com/?utm_source=nanoid">
|
||||
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
|
||||
alt="Sponsored by Evil Martians" width="236" height="54">
|
||||
</a>
|
||||
|
||||
## Docs
|
||||
Read full docs **[here](https://github.com/ai/nanoid#readme)**.
|
33
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.browser.js
generated
vendored
Normal file
33
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.browser.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
export let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
||||
export let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
|
||||
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
|
||||
return async (size = defaultSize) => {
|
||||
let id = ''
|
||||
while (true) {
|
||||
let bytes = crypto.getRandomValues(new Uint8Array(step))
|
||||
let i = step
|
||||
while (i--) {
|
||||
id += alphabet[bytes[i] & mask] || ''
|
||||
if (id.length === size) return id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
export let nanoid = async (size = 21) => {
|
||||
let id = ''
|
||||
let bytes = crypto.getRandomValues(new Uint8Array(size))
|
||||
while (size--) {
|
||||
let byte = bytes[size] & 63
|
||||
if (byte < 36) {
|
||||
id += byte.toString(36)
|
||||
} else if (byte < 62) {
|
||||
id += (byte - 26).toString(36).toUpperCase()
|
||||
} else if (byte < 63) {
|
||||
id += '_'
|
||||
} else {
|
||||
id += '-'
|
||||
}
|
||||
}
|
||||
return id
|
||||
}
|
56
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts
generated
vendored
Normal file
56
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Generate secure URL-friendly unique ID. The non-blocking version.
|
||||
*
|
||||
* By default, the ID will have 21 symbols to have a collision probability
|
||||
* similar to UUID v4.
|
||||
*
|
||||
* ```js
|
||||
* import { nanoid } from 'nanoid/async'
|
||||
* nanoid().then(id => {
|
||||
* model.id = id
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A promise with a random string.
|
||||
*/
|
||||
export function nanoid(size?: number): Promise<string>
|
||||
|
||||
/**
|
||||
* A low-level function.
|
||||
* Generate secure unique ID with custom alphabet. The non-blocking version.
|
||||
*
|
||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
||||
* will not be secure.
|
||||
*
|
||||
* @param alphabet Alphabet used to generate the ID.
|
||||
* @param defaultSize Size of the ID. The default size is 21.
|
||||
* @returns A function that returns a promise with a random string.
|
||||
*
|
||||
* ```js
|
||||
* import { customAlphabet } from 'nanoid/async'
|
||||
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
||||
* nanoid().then(id => {
|
||||
* model.id = id //=> "8ё56а"
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export function customAlphabet(
|
||||
alphabet: string,
|
||||
defaultSize?: number
|
||||
): (size?: number) => Promise<string>
|
||||
|
||||
/**
|
||||
* Generate an array of random bytes collected from hardware noise.
|
||||
*
|
||||
* ```js
|
||||
* import { random } from 'nanoid/async'
|
||||
* random(5).then(bytes => {
|
||||
* bytes //=> [10, 67, 212, 67, 89]
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @param bytes Size of the array.
|
||||
* @returns A promise with a random bytes array.
|
||||
*/
|
||||
export function random(bytes: number): Promise<Uint8Array>
|
34
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.js
generated
vendored
Normal file
34
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
import { randomFill } from 'crypto'
|
||||
import { urlAlphabet } from '../url-alphabet/index.js'
|
||||
export let random = bytes =>
|
||||
new Promise((resolve, reject) => {
|
||||
randomFill(Buffer.allocUnsafe(bytes), (err, buf) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(buf)
|
||||
}
|
||||
})
|
||||
})
|
||||
export let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
||||
let tick = (id, size = defaultSize) =>
|
||||
random(step).then(bytes => {
|
||||
let i = step
|
||||
while (i--) {
|
||||
id += alphabet[bytes[i] & mask] || ''
|
||||
if (id.length === size) return id
|
||||
}
|
||||
return tick(id, size)
|
||||
})
|
||||
return size => tick('', size)
|
||||
}
|
||||
export let nanoid = (size = 21) =>
|
||||
random(size).then(bytes => {
|
||||
let id = ''
|
||||
while (size--) {
|
||||
id += urlAlphabet[bytes[size] & 63]
|
||||
}
|
||||
return id
|
||||
})
|
25
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.native.js
generated
vendored
Normal file
25
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.native.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
import { getRandomBytesAsync } from 'expo-random'
|
||||
import { urlAlphabet } from '../url-alphabet/index.js'
|
||||
export let random = getRandomBytesAsync
|
||||
export let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
||||
let tick = (id, size = defaultSize) =>
|
||||
random(step).then(bytes => {
|
||||
let i = step
|
||||
while (i--) {
|
||||
id += alphabet[bytes[i] & mask] || ''
|
||||
if (id.length === size) return id
|
||||
}
|
||||
return tick(id, size)
|
||||
})
|
||||
return size => tick('', size)
|
||||
}
|
||||
export let nanoid = (size = 21) =>
|
||||
random(size).then(bytes => {
|
||||
let id = ''
|
||||
while (size--) {
|
||||
id += urlAlphabet[bytes[size] & 63]
|
||||
}
|
||||
return id
|
||||
})
|
46
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/bin/nanoid.js
generated
vendored
Executable file
46
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/bin/nanoid.js
generated
vendored
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env node
|
||||
import { nanoid, customAlphabet } from '../index.js'
|
||||
function print(msg) {
|
||||
process.stdout.write(msg + '\n')
|
||||
}
|
||||
function error(msg) {
|
||||
process.stderr.write(msg + '\n')
|
||||
process.exit(1)
|
||||
}
|
||||
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
||||
print(`
|
||||
Usage
|
||||
$ nanoid [options]
|
||||
Options
|
||||
-s, --size Generated ID size
|
||||
-a, --alphabet Alphabet to use
|
||||
-h, --help Show this help
|
||||
Examples
|
||||
$ nanoid --s 15
|
||||
S9sBF77U6sDB8Yg
|
||||
$ nanoid --size 10 --alphabet abc
|
||||
bcabababca`)
|
||||
process.exit()
|
||||
}
|
||||
let alphabet, size
|
||||
for (let i = 2; i < process.argv.length; i++) {
|
||||
let arg = process.argv[i]
|
||||
if (arg === '--size' || arg === '-s') {
|
||||
size = Number(process.argv[i + 1])
|
||||
i += 1
|
||||
if (Number.isNaN(size) || size <= 0) {
|
||||
error('Size must be positive integer')
|
||||
}
|
||||
} else if (arg === '--alphabet' || arg === '-a') {
|
||||
alphabet = process.argv[i + 1]
|
||||
i += 1
|
||||
} else {
|
||||
error('Unknown argument ' + arg)
|
||||
}
|
||||
}
|
||||
if (alphabet) {
|
||||
let customNanoid = customAlphabet(alphabet, size)
|
||||
print(customNanoid())
|
||||
} else {
|
||||
print(nanoid(size))
|
||||
}
|
33
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.browser.js
generated
vendored
Normal file
33
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.browser.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
export { urlAlphabet } from './url-alphabet/index.js'
|
||||
export let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
||||
export let customRandom = (alphabet, defaultSize, getRandom) => {
|
||||
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
|
||||
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
|
||||
return (size = defaultSize) => {
|
||||
let id = ''
|
||||
while (true) {
|
||||
let bytes = getRandom(step)
|
||||
let j = step
|
||||
while (j--) {
|
||||
id += alphabet[bytes[j] & mask] || ''
|
||||
if (id.length === size) return id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
export let customAlphabet = (alphabet, size = 21) =>
|
||||
customRandom(alphabet, size, random)
|
||||
export let nanoid = (size = 21) =>
|
||||
crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
||||
byte &= 63
|
||||
if (byte < 36) {
|
||||
id += byte.toString(36)
|
||||
} else if (byte < 62) {
|
||||
id += (byte - 26).toString(36).toUpperCase()
|
||||
} else if (byte > 62) {
|
||||
id += '-'
|
||||
} else {
|
||||
id += '_'
|
||||
}
|
||||
return id
|
||||
}, '')
|
91
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.d.ts
generated
vendored
Normal file
91
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* Generate secure URL-friendly unique ID.
|
||||
*
|
||||
* By default, the ID will have 21 symbols to have a collision probability
|
||||
* similar to UUID v4.
|
||||
*
|
||||
* ```js
|
||||
* import { nanoid } from 'nanoid'
|
||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A random string.
|
||||
*/
|
||||
export function nanoid(size?: number): string
|
||||
|
||||
/**
|
||||
* Generate secure unique ID with custom alphabet.
|
||||
*
|
||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
||||
* will not be secure.
|
||||
*
|
||||
* @param alphabet Alphabet used to generate the ID.
|
||||
* @param defaultSize Size of the ID. The default size is 21.
|
||||
* @returns A random string generator.
|
||||
*
|
||||
* ```js
|
||||
* const { customAlphabet } = require('nanoid')
|
||||
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
||||
* nanoid() //=> "8ё56а"
|
||||
* ```
|
||||
*/
|
||||
export function customAlphabet(
|
||||
alphabet: string,
|
||||
defaultSize?: number
|
||||
): (size?: number) => string
|
||||
|
||||
/**
|
||||
* Generate unique ID with custom random generator and alphabet.
|
||||
*
|
||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
||||
* will not be secure.
|
||||
*
|
||||
* ```js
|
||||
* import { customRandom } from 'nanoid/format'
|
||||
*
|
||||
* const nanoid = customRandom('abcdef', 5, size => {
|
||||
* const random = []
|
||||
* for (let i = 0; i < size; i++) {
|
||||
* random.push(randomByte())
|
||||
* }
|
||||
* return random
|
||||
* })
|
||||
*
|
||||
* nanoid() //=> "fbaef"
|
||||
* ```
|
||||
*
|
||||
* @param alphabet Alphabet used to generate a random string.
|
||||
* @param size Size of the random string.
|
||||
* @param random A random bytes generator.
|
||||
* @returns A random string generator.
|
||||
*/
|
||||
export function customRandom(
|
||||
alphabet: string,
|
||||
size: number,
|
||||
random: (bytes: number) => Uint8Array
|
||||
): () => string
|
||||
|
||||
/**
|
||||
* URL safe symbols.
|
||||
*
|
||||
* ```js
|
||||
* import { urlAlphabet } from 'nanoid'
|
||||
* const nanoid = customAlphabet(urlAlphabet, 10)
|
||||
* nanoid() //=> "Uakgb_J5m9"
|
||||
* ```
|
||||
*/
|
||||
export const urlAlphabet: string
|
||||
|
||||
/**
|
||||
* Generate an array of random bytes collected from hardware noise.
|
||||
*
|
||||
* ```js
|
||||
* import { customRandom, random } from 'nanoid'
|
||||
* const nanoid = customRandom("abcdef", 5, random)
|
||||
* ```
|
||||
*
|
||||
* @param bytes Size of the array.
|
||||
* @returns An array of random bytes.
|
||||
*/
|
||||
export function random(bytes: number): Uint8Array
|
45
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.js
generated
vendored
Normal file
45
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.js
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
import { randomFillSync } from 'crypto'
|
||||
import { urlAlphabet } from './url-alphabet/index.js'
|
||||
export { urlAlphabet }
|
||||
const POOL_SIZE_MULTIPLIER = 128
|
||||
let pool, poolOffset
|
||||
let fillPool = bytes => {
|
||||
if (!pool || pool.length < bytes) {
|
||||
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)
|
||||
randomFillSync(pool)
|
||||
poolOffset = 0
|
||||
} else if (poolOffset + bytes > pool.length) {
|
||||
randomFillSync(pool)
|
||||
poolOffset = 0
|
||||
}
|
||||
poolOffset += bytes
|
||||
}
|
||||
export let random = bytes => {
|
||||
fillPool((bytes -= 0))
|
||||
return pool.subarray(poolOffset - bytes, poolOffset)
|
||||
}
|
||||
export let customRandom = (alphabet, defaultSize, getRandom) => {
|
||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
||||
return (size = defaultSize) => {
|
||||
let id = ''
|
||||
while (true) {
|
||||
let bytes = getRandom(step)
|
||||
let i = step
|
||||
while (i--) {
|
||||
id += alphabet[bytes[i] & mask] || ''
|
||||
if (id.length === size) return id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
export let customAlphabet = (alphabet, size = 21) =>
|
||||
customRandom(alphabet, size, random)
|
||||
export let nanoid = (size = 21) => {
|
||||
fillPool((size -= 0))
|
||||
let id = ''
|
||||
for (let i = poolOffset - size; i < poolOffset; i++) {
|
||||
id += urlAlphabet[pool[i] & 63]
|
||||
}
|
||||
return id
|
||||
}
|
1
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/nanoid.js
generated
vendored
Normal file
1
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/nanoid.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export let nanoid=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,e)=>t+=(e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e>62?"-":"_"),"");
|
17
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/node_modules/.bin/nanoid
generated
vendored
Executable file
17
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/node_modules/.bin/nanoid
generated
vendored
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -z "$NODE_PATH" ]; then
|
||||
export NODE_PATH="/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/bin/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/node_modules"
|
||||
else
|
||||
export NODE_PATH="/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/bin/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules:/Users/kdy1/projects/s/issues/crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/node_modules:$NODE_PATH"
|
||||
fi
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../../bin/nanoid.js" "$@"
|
||||
else
|
||||
exec node "$basedir/../../bin/nanoid.js" "$@"
|
||||
fi
|
33
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts
generated
vendored
Normal file
33
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Generate URL-friendly unique ID. This method uses the non-secure
|
||||
* predictable random generator with bigger collision probability.
|
||||
*
|
||||
* ```js
|
||||
* import { nanoid } from 'nanoid/non-secure'
|
||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A random string.
|
||||
*/
|
||||
export function nanoid(size?: number): string
|
||||
|
||||
/**
|
||||
* Generate a unique ID based on a custom alphabet.
|
||||
* This method uses the non-secure predictable random generator
|
||||
* with bigger collision probability.
|
||||
*
|
||||
* @param alphabet Alphabet used to generate the ID.
|
||||
* @param defaultSize Size of the ID. The default size is 21.
|
||||
* @returns A random string generator.
|
||||
*
|
||||
* ```js
|
||||
* import { customAlphabet } from 'nanoid/non-secure'
|
||||
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
||||
* model.id = //=> "8ё56а"
|
||||
* ```
|
||||
*/
|
||||
export function customAlphabet(
|
||||
alphabet: string,
|
||||
defaultSize?: number
|
||||
): (size?: number) => string
|
20
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.js
generated
vendored
Normal file
20
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
let urlAlphabet =
|
||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
||||
export let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
return (size = defaultSize) => {
|
||||
let id = ''
|
||||
let i = size
|
||||
while (i--) {
|
||||
id += alphabet[(Math.random() * alphabet.length) | 0]
|
||||
}
|
||||
return id
|
||||
}
|
||||
}
|
||||
export let nanoid = (size = 21) => {
|
||||
let id = ''
|
||||
let i = size
|
||||
while (i--) {
|
||||
id += urlAlphabet[(Math.random() * 64) | 0]
|
||||
}
|
||||
return id
|
||||
}
|
46
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/package.json
generated
vendored
Normal file
46
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/package.json
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "nanoid",
|
||||
"version": "4.0.2",
|
||||
"description": "A tiny (116 bytes), secure URL-friendly unique string ID generator",
|
||||
"keywords": [
|
||||
"uuid",
|
||||
"random",
|
||||
"id",
|
||||
"url"
|
||||
],
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": "^14 || ^16 || >=18"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"author": "Andrey Sitnik <andrey@sitnik.ru>",
|
||||
"license": "MIT",
|
||||
"repository": "ai/nanoid",
|
||||
"exports": {
|
||||
".": {
|
||||
"browser": "./index.browser.js",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./async": {
|
||||
"browser": "./async/index.browser.js",
|
||||
"default": "./async/index.js"
|
||||
},
|
||||
"./non-secure": "./non-secure/index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"browser": {
|
||||
"./index.js": "./index.browser.js",
|
||||
"./async/index.js": "./async/index.browser.js"
|
||||
},
|
||||
"react-native": {
|
||||
"./async/index.js": "./async/index.native.js"
|
||||
},
|
||||
"bin": "./bin/nanoid.js",
|
||||
"sideEffects": false,
|
||||
"types": "./index.d.ts"
|
||||
}
|
2
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/url-alphabet/index.js
generated
vendored
Normal file
2
crates/swc/tests/fixture/jsc-paths/vercel-site/1/input/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/url-alphabet/index.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export const urlAlphabet =
|
||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"packageManager": "pnpm@8.7.4",
|
||||
"dependencies": {
|
||||
"nanoid": "^4.0.2"
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
nanoid:
|
||||
specifier: ^4.0.2
|
||||
version: 4.0.2
|
||||
|
||||
packages:
|
||||
|
||||
/nanoid@4.0.2:
|
||||
resolution: {integrity: sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw==}
|
||||
engines: {node: ^14 || ^16 || >=18}
|
||||
hasBin: true
|
||||
dev: false
|
@ -0,0 +1,15 @@
|
||||
import { nanoid } from "./nanoid";
|
||||
import { fnv1a } from "../fnv1a";
|
||||
export var VERCEL_AUTHENTICATED_PREFIX = "v_";
|
||||
/**
|
||||
* 1.0 -- random IDs from nanoid() with default length. Authenticated IDs are v_vercelUserID.
|
||||
*/ export var IDENTITY_VERSION = "1.0";
|
||||
export function generateRandomID() {
|
||||
return nanoid();
|
||||
}
|
||||
export function formatAuthenticatedID(vercelUserUid) {
|
||||
return "".concat(VERCEL_AUTHENTICATED_PREFIX).concat(vercelUserUid);
|
||||
}
|
||||
export function computeIdentityVersion() {
|
||||
return String(fnv1a(IDENTITY_VERSION));
|
||||
}
|
72
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.browser.js
generated
vendored
Normal file
72
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.browser.js
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
||||
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
||||
export var random = function() {
|
||||
var _ref = _async_to_generator(function(bytes) {
|
||||
return _ts_generator(this, function(_state) {
|
||||
return [
|
||||
2,
|
||||
crypto.getRandomValues(new Uint8Array(bytes))
|
||||
];
|
||||
});
|
||||
});
|
||||
return function random(bytes) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
export var customAlphabet = function(alphabet) {
|
||||
var defaultSize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 21;
|
||||
var mask = (2 << Math.log(alphabet.length - 1) / Math.LN2) - 1;
|
||||
var step = -~(1.6 * mask * defaultSize / alphabet.length);
|
||||
return /*#__PURE__*/ _async_to_generator(function() {
|
||||
var size, id, bytes, i;
|
||||
var _arguments = arguments;
|
||||
return _ts_generator(this, function(_state) {
|
||||
size = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : defaultSize;
|
||||
id = "";
|
||||
while(true){
|
||||
bytes = crypto.getRandomValues(new Uint8Array(step));
|
||||
i = step;
|
||||
while(i--){
|
||||
id += alphabet[bytes[i] & mask] || "";
|
||||
if (id.length === size) return [
|
||||
2,
|
||||
id
|
||||
];
|
||||
}
|
||||
}
|
||||
return [
|
||||
2
|
||||
];
|
||||
});
|
||||
});
|
||||
};
|
||||
export var nanoid = function() {
|
||||
var _ref = _async_to_generator(function() {
|
||||
var size, id, bytes, byte;
|
||||
var _arguments = arguments;
|
||||
return _ts_generator(this, function(_state) {
|
||||
size = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : 21;
|
||||
id = "";
|
||||
bytes = crypto.getRandomValues(new Uint8Array(size));
|
||||
while(size--){
|
||||
byte = bytes[size] & 63;
|
||||
if (byte < 36) {
|
||||
id += byte.toString(36);
|
||||
} else if (byte < 62) {
|
||||
id += (byte - 26).toString(36).toUpperCase();
|
||||
} else if (byte < 63) {
|
||||
id += "_";
|
||||
} else {
|
||||
id += "-";
|
||||
}
|
||||
}
|
||||
return [
|
||||
2,
|
||||
id
|
||||
];
|
||||
});
|
||||
});
|
||||
return function nanoid() {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}();
|
16
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts
generated
vendored
Normal file
16
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Generate secure URL-friendly unique ID. The non-blocking version.
|
||||
*
|
||||
* By default, the ID will have 21 symbols to have a collision probability
|
||||
* similar to UUID v4.
|
||||
*
|
||||
* ```js
|
||||
* import { nanoid } from 'nanoid/async'
|
||||
* nanoid().then(id => {
|
||||
* model.id = id
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A promise with a random string.
|
||||
*/ export { };
|
42
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.js
generated
vendored
Normal file
42
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
import { randomFill } from "crypto";
|
||||
import { urlAlphabet } from "../url-alphabet/index.js";
|
||||
export var random = function(bytes) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
randomFill(Buffer.allocUnsafe(bytes), function(err, buf) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(buf);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
export var customAlphabet = function(alphabet) {
|
||||
var defaultSize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 21;
|
||||
var mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
|
||||
var step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
|
||||
var tick = function(id) {
|
||||
var size = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultSize;
|
||||
return random(step).then(function(bytes) {
|
||||
var i = step;
|
||||
while(i--){
|
||||
id += alphabet[bytes[i] & mask] || "";
|
||||
if (id.length === size) return id;
|
||||
}
|
||||
return tick(id, size);
|
||||
});
|
||||
};
|
||||
return function(size) {
|
||||
return tick("", size);
|
||||
};
|
||||
};
|
||||
export var nanoid = function() {
|
||||
var size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21;
|
||||
return random(size).then(function(bytes) {
|
||||
var id = "";
|
||||
while(size--){
|
||||
id += urlAlphabet[bytes[size] & 63];
|
||||
}
|
||||
return id;
|
||||
});
|
||||
};
|
32
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.native.js
generated
vendored
Normal file
32
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.native.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
import { getRandomBytesAsync } from "expo-random";
|
||||
import { urlAlphabet } from "../url-alphabet/index.js";
|
||||
export var random = getRandomBytesAsync;
|
||||
export var customAlphabet = function(alphabet) {
|
||||
var defaultSize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 21;
|
||||
var mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
|
||||
var step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
|
||||
var tick = function(id) {
|
||||
var size = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultSize;
|
||||
return random(step).then(function(bytes) {
|
||||
var i = step;
|
||||
while(i--){
|
||||
id += alphabet[bytes[i] & mask] || "";
|
||||
if (id.length === size) return id;
|
||||
}
|
||||
return tick(id, size);
|
||||
});
|
||||
};
|
||||
return function(size) {
|
||||
return tick("", size);
|
||||
};
|
||||
};
|
||||
export var nanoid = function() {
|
||||
var size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21;
|
||||
return random(size).then(function(bytes) {
|
||||
var id = "";
|
||||
while(size--){
|
||||
id += urlAlphabet[bytes[size] & 63];
|
||||
}
|
||||
return id;
|
||||
});
|
||||
};
|
35
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/bin/nanoid.js
generated
vendored
Normal file
35
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/bin/nanoid.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env node
|
||||
import { nanoid, customAlphabet } from "../index.js";
|
||||
function print(msg) {
|
||||
process.stdout.write(msg + "\n");
|
||||
}
|
||||
function error(msg) {
|
||||
process.stderr.write(msg + "\n");
|
||||
process.exit(1);
|
||||
}
|
||||
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
||||
print("\n Usage\n $ nanoid [options]\n Options\n -s, --size Generated ID size\n -a, --alphabet Alphabet to use\n -h, --help Show this help\n Examples\n $ nanoid --s 15\n S9sBF77U6sDB8Yg\n $ nanoid --size 10 --alphabet abc\n bcabababca");
|
||||
process.exit();
|
||||
}
|
||||
var alphabet, size;
|
||||
for(var i = 2; i < process.argv.length; i++){
|
||||
var arg = process.argv[i];
|
||||
if (arg === "--size" || arg === "-s") {
|
||||
size = Number(process.argv[i + 1]);
|
||||
i += 1;
|
||||
if (Number.isNaN(size) || size <= 0) {
|
||||
error("Size must be positive integer");
|
||||
}
|
||||
} else if (arg === "--alphabet" || arg === "-a") {
|
||||
alphabet = process.argv[i + 1];
|
||||
i += 1;
|
||||
} else {
|
||||
error("Unknown argument " + arg);
|
||||
}
|
||||
}
|
||||
if (alphabet) {
|
||||
var customNanoid = customAlphabet(alphabet, size);
|
||||
print(customNanoid());
|
||||
} else {
|
||||
print(nanoid(size));
|
||||
}
|
40
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.browser.js
generated
vendored
Normal file
40
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.browser.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
export { urlAlphabet } from "./url-alphabet/index.js";
|
||||
export var random = function(bytes) {
|
||||
return crypto.getRandomValues(new Uint8Array(bytes));
|
||||
};
|
||||
export var customRandom = function(alphabet, defaultSize, getRandom) {
|
||||
var mask = (2 << Math.log(alphabet.length - 1) / Math.LN2) - 1;
|
||||
var step = -~(1.6 * mask * defaultSize / alphabet.length);
|
||||
return function() {
|
||||
var size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultSize;
|
||||
var id = "";
|
||||
while(true){
|
||||
var bytes = getRandom(step);
|
||||
var j = step;
|
||||
while(j--){
|
||||
id += alphabet[bytes[j] & mask] || "";
|
||||
if (id.length === size) return id;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
export var customAlphabet = function(alphabet) {
|
||||
var size = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 21;
|
||||
return customRandom(alphabet, size, random);
|
||||
};
|
||||
export var nanoid = function() {
|
||||
var size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21;
|
||||
return crypto.getRandomValues(new Uint8Array(size)).reduce(function(id, byte) {
|
||||
byte &= 63;
|
||||
if (byte < 36) {
|
||||
id += byte.toString(36);
|
||||
} else if (byte < 62) {
|
||||
id += (byte - 26).toString(36).toUpperCase();
|
||||
} else if (byte > 62) {
|
||||
id += "-";
|
||||
} else {
|
||||
id += "_";
|
||||
}
|
||||
return id;
|
||||
}, "");
|
||||
};
|
22
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.d.ts
generated
vendored
Normal file
22
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Generate secure URL-friendly unique ID.
|
||||
*
|
||||
* By default, the ID will have 21 symbols to have a collision probability
|
||||
* similar to UUID v4.
|
||||
*
|
||||
* ```js
|
||||
* import { nanoid } from 'nanoid'
|
||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A random string.
|
||||
*/ /**
|
||||
* URL safe symbols.
|
||||
*
|
||||
* ```js
|
||||
* import { urlAlphabet } from 'nanoid'
|
||||
* const nanoid = customAlphabet(urlAlphabet, 10)
|
||||
* nanoid() //=> "Uakgb_J5m9"
|
||||
* ```
|
||||
*/ export var urlAlphabet;
|
49
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.js
generated
vendored
Normal file
49
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
import { randomFillSync } from "crypto";
|
||||
import { urlAlphabet } from "./url-alphabet/index.js";
|
||||
export { urlAlphabet };
|
||||
var POOL_SIZE_MULTIPLIER = 128;
|
||||
var pool, poolOffset;
|
||||
var fillPool = function(bytes) {
|
||||
if (!pool || pool.length < bytes) {
|
||||
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
|
||||
randomFillSync(pool);
|
||||
poolOffset = 0;
|
||||
} else if (poolOffset + bytes > pool.length) {
|
||||
randomFillSync(pool);
|
||||
poolOffset = 0;
|
||||
}
|
||||
poolOffset += bytes;
|
||||
};
|
||||
export var random = function(bytes) {
|
||||
fillPool(bytes -= 0);
|
||||
return pool.subarray(poolOffset - bytes, poolOffset);
|
||||
};
|
||||
export var customRandom = function(alphabet, defaultSize, getRandom) {
|
||||
var mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
|
||||
var step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
|
||||
return function() {
|
||||
var size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultSize;
|
||||
var id = "";
|
||||
while(true){
|
||||
var bytes = getRandom(step);
|
||||
var i = step;
|
||||
while(i--){
|
||||
id += alphabet[bytes[i] & mask] || "";
|
||||
if (id.length === size) return id;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
export var customAlphabet = function(alphabet) {
|
||||
var size = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 21;
|
||||
return customRandom(alphabet, size, random);
|
||||
};
|
||||
export var nanoid = function() {
|
||||
var size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21;
|
||||
fillPool(size -= 0);
|
||||
var id = "";
|
||||
for(var i = poolOffset - size; i < poolOffset; i++){
|
||||
id += urlAlphabet[pool[i] & 63];
|
||||
}
|
||||
return id;
|
||||
};
|
6
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/nanoid.js
generated
vendored
Normal file
6
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/nanoid.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
export var nanoid = function() {
|
||||
var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21;
|
||||
return crypto.getRandomValues(new Uint8Array(t)).reduce(function(t, e) {
|
||||
return t += (e &= 63) < 36 ? e.toString(36) : e < 62 ? (e - 26).toString(36).toUpperCase() : e > 62 ? "-" : "_";
|
||||
}, "");
|
||||
};
|
12
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts
generated
vendored
Normal file
12
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Generate URL-friendly unique ID. This method uses the non-secure
|
||||
* predictable random generator with bigger collision probability.
|
||||
*
|
||||
* ```js
|
||||
* import { nanoid } from 'nanoid/non-secure'
|
||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A random string.
|
||||
*/ export { };
|
22
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.js
generated
vendored
Normal file
22
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
||||
export var customAlphabet = function(alphabet) {
|
||||
var defaultSize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 21;
|
||||
return function() {
|
||||
var size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultSize;
|
||||
var id = "";
|
||||
var i = size;
|
||||
while(i--){
|
||||
id += alphabet[Math.random() * alphabet.length | 0];
|
||||
}
|
||||
return id;
|
||||
};
|
||||
};
|
||||
export var nanoid = function() {
|
||||
var size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21;
|
||||
var id = "";
|
||||
var i = size;
|
||||
while(i--){
|
||||
id += urlAlphabet[Math.random() * 64 | 0];
|
||||
}
|
||||
return id;
|
||||
};
|
1
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/url-alphabet/index.js
generated
vendored
Normal file
1
crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/url-alphabet/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
@ -20,6 +20,7 @@ serde = { version = "1", features = ["derive"] }
|
||||
serde-wasm-bindgen = "0.4.5"
|
||||
swc_core = { path = "../../../../swc_core", features = [
|
||||
"ecma_ast_serde",
|
||||
"ecma_codegen",
|
||||
"binding_macro_wasm",
|
||||
"ecma_transforms",
|
||||
"ecma_visit",
|
||||
|
@ -120,18 +120,27 @@ where
|
||||
module_specifier, resolved, base
|
||||
);
|
||||
|
||||
if let FileName::Real(target) = &resolved {
|
||||
// If node_modules is in path, we should return module specifier.
|
||||
if target.components().any(|c| {
|
||||
if let Component::Normal(v) = c {
|
||||
v == "node_modules"
|
||||
let is_base_in_node_modules = if let FileName::Real(v) = base {
|
||||
v.components().any(|c| match c {
|
||||
Component::Normal(v) => v == "node_modules",
|
||||
_ => false,
|
||||
})
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}) {
|
||||
};
|
||||
let is_target_in_node_modules = if let FileName::Real(v) = &resolved {
|
||||
v.components().any(|c| match c {
|
||||
Component::Normal(v) => v == "node_modules",
|
||||
_ => false,
|
||||
})
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
// If node_modules is in path, we should return module specifier.
|
||||
if !is_base_in_node_modules && is_target_in_node_modules {
|
||||
return Ok(FileName::Real(module_specifier.into()));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(resolved)
|
||||
}
|
||||
|
1
packages/.gitignore
vendored
Normal file
1
packages/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules/
|
Loading…
Reference in New Issue
Block a user