Skip to content

Commit

Permalink
Merge pull request #224 from napi-rs/upgrade-dependencies
Browse files Browse the repository at this point in the history
chore: upgrade dependencies and CI
  • Loading branch information
Brooooooklyn authored Jul 5, 2022
2 parents 2739d2f + 1d919eb commit 1ed24f6
Show file tree
Hide file tree
Showing 24 changed files with 5,290 additions and 3,449 deletions.
251 changes: 133 additions & 118 deletions .github/workflows/CI.yml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,11 @@ dist
Cargo.lock

*.node

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
786 changes: 786 additions & 0 deletions .yarn/releases/yarn-3.2.1.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarnPath: .yarn/releases/yarn-3.2.1.cjs
nodeLinker: node-modules
15 changes: 10 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ version = "0.1.0"
crate-type = ["cdylib"]

[dependencies]
napi = {version = "2", default-features = false, features = ["napi3"]}
napi-derive = {version = "2", default-features = false, features = ["type-def"]}
napi = { version = "2", default-features = false, features = ["napi3"] }
napi-derive = { version = "2", default-features = false, features = [
"type-def",
] }
v_htmlescape = "0.14"

[target.'cfg(all(target_arch = "x86_64", not(target_env = "musl")))'.dependencies]
mimalloc = {version = "0.1"}
[target.'cfg(not(target_os = "linux"))'.dependencies]
mimalloc-rust = { version = "0.2" }

[target.'cfg(all(target_os = "linux", not(all(target_env = "musl", target_arch = "aarch64"))))'.dependencies]
mimalloc-rust = { version = "0.2", features = ["local-dynamic-tls"] }

[build-dependencies]
napi-build = "1"
napi-build = "2"

[profile.release]
lto = true
Expand Down
Binary file modified __test__/index.spec.ts.snap
Binary file not shown.
6 changes: 0 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@

/* auto-generated by NAPI-RS */

export class ExternalObject<T> {
readonly '': {
readonly '': unique symbol
[K: symbol]: T
}
}
export function escapeHTML(input: string): string
export function escapeHTMLBuf(input: Buffer): string
export function asyncEscapeHTMLBuf(input: Buffer, signal?: AbortSignal | undefined | null): Promise<string>
96 changes: 70 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,59 @@ const { platform, arch } = process

let nativeBinding = null
let localFileExisted = false
let isMusl = false
let loadError = null

switch (platform) {
case 'android':
if (arch !== 'arm64') {
throw new Error(`Unsupported architecture on Android ${arch}`)
}
localFileExisted = existsSync(join(__dirname, 'escape.android-arm64.node'))
function isMusl() {
// For Node 10
if (!process.report || typeof process.report.getReport !== 'function') {
try {
if (localFileExisted) {
nativeBinding = require('./escape.android-arm64.node')
} else {
nativeBinding = require('@napi-rs/escape-android-arm64')
}
return readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
} catch (e) {
loadError = e
return true
}
} else {
const { glibcVersionRuntime } = process.report.getReport().header
return !glibcVersionRuntime
}
}

switch (platform) {
case 'android':
switch (arch) {
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'escape.android-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./escape.android-arm64.node')
} else {
nativeBinding = require('@napi-rs/escape-android-arm64')
}
} catch (e) {
loadError = e
}
break
case 'arm':
localFileExisted = existsSync(join(__dirname, 'escape.android-arm-eabi.node'))
try {
if (localFileExisted) {
nativeBinding = require('./escape.android-arm-eabi.node')
} else {
nativeBinding = require('@napi-rs/escape-android-arm-eabi')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Android ${arch}`)
}
break
case 'win32':
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'escape.win32-x64-msvc.node'))
localFileExisted = existsSync(
join(__dirname, 'escape.win32-x64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./escape.win32-x64-msvc.node')
Expand All @@ -39,7 +69,9 @@ switch (platform) {
}
break
case 'ia32':
localFileExisted = existsSync(join(__dirname, 'escape.win32-ia32-msvc.node'))
localFileExisted = existsSync(
join(__dirname, 'escape.win32-ia32-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./escape.win32-ia32-msvc.node')
Expand All @@ -51,7 +83,9 @@ switch (platform) {
}
break
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'escape.win32-arm64-msvc.node'))
localFileExisted = existsSync(
join(__dirname, 'escape.win32-arm64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./escape.win32-arm64-msvc.node')
Expand Down Expand Up @@ -81,7 +115,9 @@ switch (platform) {
}
break
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'escape.darwin-arm64.node'))
localFileExisted = existsSync(
join(__dirname, 'escape.darwin-arm64.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./escape.darwin-arm64.node')
Expand Down Expand Up @@ -114,9 +150,10 @@ switch (platform) {
case 'linux':
switch (arch) {
case 'x64':
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
if (isMusl) {
localFileExisted = existsSync(join(__dirname, 'escape.linux-x64-musl.node'))
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'escape.linux-x64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./escape.linux-x64-musl.node')
Expand All @@ -127,7 +164,9 @@ switch (platform) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'escape.linux-x64-gnu.node'))
localFileExisted = existsSync(
join(__dirname, 'escape.linux-x64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./escape.linux-x64-gnu.node')
Expand All @@ -140,9 +179,10 @@ switch (platform) {
}
break
case 'arm64':
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
if (isMusl) {
localFileExisted = existsSync(join(__dirname, 'escape.linux-arm64-musl.node'))
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'escape.linux-arm64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./escape.linux-arm64-musl.node')
Expand All @@ -153,7 +193,9 @@ switch (platform) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'escape.linux-arm64-gnu.node'))
localFileExisted = existsSync(
join(__dirname, 'escape.linux-arm64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./escape.linux-arm64-gnu.node')
Expand All @@ -166,7 +208,9 @@ switch (platform) {
}
break
case 'arm':
localFileExisted = existsSync(join(__dirname, 'escape.linux-arm-gnueabihf.node'))
localFileExisted = existsSync(
join(__dirname, 'escape.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./escape.linux-arm-gnueabihf.node')
Expand Down
2 changes: 1 addition & 1 deletion npm/android-arm-eabi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
}
2 changes: 1 addition & 1 deletion npm/android-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
}
2 changes: 1 addition & 1 deletion npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
}
2 changes: 1 addition & 1 deletion npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
}
2 changes: 1 addition & 1 deletion npm/freebsd-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
}
2 changes: 1 addition & 1 deletion npm/linux-arm-gnueabihf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
}
7 changes: 5 additions & 2 deletions npm/linux-arm64-gnu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
"repository": "git@github.com:napi-rs/escape.git",
"libc": [
"glibc"
]
}
7 changes: 5 additions & 2 deletions npm/linux-arm64-musl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
"repository": "git@github.com:napi-rs/escape.git",
"libc": [
"musl"
]
}
7 changes: 5 additions & 2 deletions npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
"repository": "git@github.com:napi-rs/escape.git",
"libc": [
"glibc"
]
}
7 changes: 5 additions & 2 deletions npm/linux-x64-musl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
"repository": "git@github.com:napi-rs/escape.git",
"libc": [
"musl"
]
}
2 changes: 1 addition & 1 deletion npm/win32-arm64-msvc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
}
2 changes: 1 addition & 1 deletion npm/win32-ia32-msvc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
}
2 changes: 1 addition & 1 deletion npm/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"access": "public"
},
"repository": "git@github.com:napi-rs/escape.git"
}
}
Loading

0 comments on commit 1ed24f6

Please sign in to comment.