@okamjs/okam
Advanced tools
Comparing version 0.0.1 to 0.0.3
@@ -6,23 +6,26 @@ /* tslint:disable */ | ||
export function build(root: string, config: | ||
{ | ||
entry?: Record<string, string>; | ||
output?: {path: string}; | ||
resolve?: { | ||
alias?: Record<string, string>; | ||
extensions?: string[]; | ||
}; | ||
mode?: "development" | "production"; | ||
define?: Record<string, string>; | ||
devtool?: "source-map" | "inline-source-map"; | ||
externals?: Record<string, string>; | ||
copy?: string[]; | ||
providers?: Record<string, string[]>; | ||
public_path?: string; | ||
inline_limit?: number; | ||
targets?: Record<string, number>; | ||
platform?: "node" | "browser"; | ||
hmr?: boolean; | ||
hmr_port?: string; | ||
hmr_host?: string; | ||
}, watch: boolean): Promise<void> | ||
export function build( | ||
root: string, | ||
config: { | ||
entry?: Record<string, string>; | ||
output?: { path: string }; | ||
resolve?: { | ||
alias?: Record<string, string>; | ||
extensions?: string[]; | ||
}; | ||
mode?: 'development' | 'production'; | ||
define?: Record<string, string>; | ||
devtool?: 'source-map' | 'inline-source-map'; | ||
externals?: Record<string, string>; | ||
copy?: string[]; | ||
providers?: Record<string, string[]>; | ||
public_path?: string; | ||
inline_limit?: number; | ||
targets?: Record<string, number>; | ||
platform?: 'node' | 'browser'; | ||
hmr?: boolean; | ||
hmr_port?: string; | ||
hmr_host?: string; | ||
}, | ||
watch: boolean, | ||
): Promise<void>; |
211
index.js
@@ -1,9 +0,9 @@ | ||
const { existsSync, readFileSync } = require('fs') | ||
const { join } = require('path') | ||
const { existsSync, readFileSync } = require('fs'); | ||
const { join } = require('path'); | ||
const { platform, arch } = process | ||
const { platform, arch } = process; | ||
let nativeBinding = null | ||
let localFileExisted = false | ||
let loadError = null | ||
let nativeBinding = null; | ||
let localFileExisted = false; | ||
let loadError = null; | ||
@@ -14,10 +14,13 @@ function isMusl() { | ||
try { | ||
const lddPath = require('child_process').execSync('which ldd').toString().trim(); | ||
return readFileSync(lddPath, 'utf8').includes('musl') | ||
const lddPath = require('child_process') | ||
.execSync('which ldd') | ||
.toString() | ||
.trim(); | ||
return readFileSync(lddPath, 'utf8').includes('musl'); | ||
} catch (e) { | ||
return true | ||
return true; | ||
} | ||
} else { | ||
const { glibcVersionRuntime } = process.report.getReport().header | ||
return !glibcVersionRuntime | ||
const { glibcVersionRuntime } = process.report.getReport().header; | ||
return !glibcVersionRuntime; | ||
} | ||
@@ -30,29 +33,33 @@ } | ||
case 'arm64': | ||
localFileExisted = existsSync(join(__dirname, 'okam.android-arm64.node')) | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.android-arm64.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.android-arm64.node') | ||
nativeBinding = require('./okam.android-arm64.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-android-arm64') | ||
nativeBinding = require('@okamjs/okam-android-arm64'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
break | ||
break; | ||
case 'arm': | ||
localFileExisted = existsSync(join(__dirname, 'okam.android-arm-eabi.node')) | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.android-arm-eabi.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.android-arm-eabi.node') | ||
nativeBinding = require('./okam.android-arm-eabi.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-android-arm-eabi') | ||
nativeBinding = require('@okamjs/okam-android-arm-eabi'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
break | ||
break; | ||
default: | ||
throw new Error(`Unsupported architecture on Android ${arch}`) | ||
throw new Error(`Unsupported architecture on Android ${arch}`); | ||
} | ||
break | ||
break; | ||
case 'win32': | ||
@@ -62,102 +69,104 @@ switch (arch) { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.win32-x64-msvc.node') | ||
) | ||
join(__dirname, 'okam.win32-x64-msvc.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.win32-x64-msvc.node') | ||
nativeBinding = require('./okam.win32-x64-msvc.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-win32-x64-msvc') | ||
nativeBinding = require('@okamjs/okam-win32-x64-msvc'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
break | ||
break; | ||
case 'ia32': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.win32-ia32-msvc.node') | ||
) | ||
join(__dirname, 'okam.win32-ia32-msvc.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.win32-ia32-msvc.node') | ||
nativeBinding = require('./okam.win32-ia32-msvc.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-win32-ia32-msvc') | ||
nativeBinding = require('@okamjs/okam-win32-ia32-msvc'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
break | ||
break; | ||
case 'arm64': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.win32-arm64-msvc.node') | ||
) | ||
join(__dirname, 'okam.win32-arm64-msvc.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.win32-arm64-msvc.node') | ||
nativeBinding = require('./okam.win32-arm64-msvc.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-win32-arm64-msvc') | ||
nativeBinding = require('@okamjs/okam-win32-arm64-msvc'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
break | ||
break; | ||
default: | ||
throw new Error(`Unsupported architecture on Windows: ${arch}`) | ||
throw new Error(`Unsupported architecture on Windows: ${arch}`); | ||
} | ||
break | ||
break; | ||
case 'darwin': | ||
localFileExisted = existsSync(join(__dirname, 'okam.darwin-universal.node')) | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.darwin-universal.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.darwin-universal.node') | ||
nativeBinding = require('./okam.darwin-universal.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-darwin-universal') | ||
nativeBinding = require('@okamjs/okam-darwin-universal'); | ||
} | ||
break | ||
break; | ||
} catch {} | ||
switch (arch) { | ||
case 'x64': | ||
localFileExisted = existsSync(join(__dirname, 'okam.darwin-x64.node')) | ||
localFileExisted = existsSync(join(__dirname, 'okam.darwin-x64.node')); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.darwin-x64.node') | ||
nativeBinding = require('./okam.darwin-x64.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-darwin-x64') | ||
nativeBinding = require('@okamjs/okam-darwin-x64'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
break | ||
break; | ||
case 'arm64': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.darwin-arm64.node') | ||
) | ||
join(__dirname, 'okam.darwin-arm64.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.darwin-arm64.node') | ||
nativeBinding = require('./okam.darwin-arm64.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-darwin-arm64') | ||
nativeBinding = require('@okamjs/okam-darwin-arm64'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
break | ||
break; | ||
default: | ||
throw new Error(`Unsupported architecture on macOS: ${arch}`) | ||
throw new Error(`Unsupported architecture on macOS: ${arch}`); | ||
} | ||
break | ||
break; | ||
case 'freebsd': | ||
if (arch !== 'x64') { | ||
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`) | ||
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`); | ||
} | ||
localFileExisted = existsSync(join(__dirname, 'okam.freebsd-x64.node')) | ||
localFileExisted = existsSync(join(__dirname, 'okam.freebsd-x64.node')); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.freebsd-x64.node') | ||
nativeBinding = require('./okam.freebsd-x64.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-freebsd-x64') | ||
nativeBinding = require('@okamjs/okam-freebsd-x64'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
break | ||
break; | ||
case 'linux': | ||
@@ -168,77 +177,77 @@ switch (arch) { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.linux-x64-musl.node') | ||
) | ||
join(__dirname, 'okam.linux-x64-musl.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.linux-x64-musl.node') | ||
nativeBinding = require('./okam.linux-x64-musl.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-linux-x64-musl') | ||
nativeBinding = require('@okamjs/okam-linux-x64-musl'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
} else { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.linux-x64-gnu.node') | ||
) | ||
join(__dirname, 'okam.linux-x64-gnu.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.linux-x64-gnu.node') | ||
nativeBinding = require('./okam.linux-x64-gnu.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-linux-x64-gnu') | ||
nativeBinding = require('@okamjs/okam-linux-x64-gnu'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
} | ||
break | ||
break; | ||
case 'arm64': | ||
if (isMusl()) { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.linux-arm64-musl.node') | ||
) | ||
join(__dirname, 'okam.linux-arm64-musl.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.linux-arm64-musl.node') | ||
nativeBinding = require('./okam.linux-arm64-musl.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-linux-arm64-musl') | ||
nativeBinding = require('@okamjs/okam-linux-arm64-musl'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
} else { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.linux-arm64-gnu.node') | ||
) | ||
join(__dirname, 'okam.linux-arm64-gnu.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.linux-arm64-gnu.node') | ||
nativeBinding = require('./okam.linux-arm64-gnu.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-linux-arm64-gnu') | ||
nativeBinding = require('@okamjs/okam-linux-arm64-gnu'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
} | ||
break | ||
break; | ||
case 'arm': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'okam.linux-arm-gnueabihf.node') | ||
) | ||
join(__dirname, 'okam.linux-arm-gnueabihf.node'), | ||
); | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./okam.linux-arm-gnueabihf.node') | ||
nativeBinding = require('./okam.linux-arm-gnueabihf.node'); | ||
} else { | ||
nativeBinding = require('@okamjs/okam-linux-arm-gnueabihf') | ||
nativeBinding = require('@okamjs/okam-linux-arm-gnueabihf'); | ||
} | ||
} catch (e) { | ||
loadError = e | ||
loadError = e; | ||
} | ||
break | ||
break; | ||
default: | ||
throw new Error(`Unsupported architecture on Linux: ${arch}`) | ||
throw new Error(`Unsupported architecture on Linux: ${arch}`); | ||
} | ||
break | ||
break; | ||
default: | ||
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`) | ||
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`); | ||
} | ||
@@ -248,9 +257,9 @@ | ||
if (loadError) { | ||
throw loadError | ||
throw loadError; | ||
} | ||
throw new Error(`Failed to load native binding`) | ||
throw new Error(`Failed to load native binding`); | ||
} | ||
const { build } = nativeBinding | ||
const { build } = nativeBinding; | ||
module.exports.build = build | ||
module.exports.build = build; |
{ | ||
"name": "@okamjs/okam", | ||
"version": "0.0.1", | ||
"version": "0.0.3", | ||
"main": "index.js", | ||
@@ -9,10 +9,7 @@ "types": "index.d.ts", | ||
"triples": { | ||
"defaults": false, | ||
"additional": [ | ||
"aarch64-apple-darwin", | ||
"aarch64-unknown-linux-gnu", | ||
"aarch64-unknown-linux-musl", | ||
"aarch64-pc-windows-msvc", | ||
"armv7-unknown-linux-gnueabihf", | ||
"x86_64-unknown-linux-musl", | ||
"i686-pc-windows-msvc" | ||
"x86_64-apple-darwin", | ||
"x86_64-unknown-linux-gnu" | ||
] | ||
@@ -33,12 +30,5 @@ } | ||
"optionalDependencies": { | ||
"@okamjs/okam-win32-x64-msvc": "0.0.1", | ||
"@okamjs/okam-darwin-x64": "0.0.1", | ||
"@okamjs/okam-linux-x64-gnu": "0.0.1", | ||
"@okamjs/okam-darwin-arm64": "0.0.1", | ||
"@okamjs/okam-linux-arm64-gnu": "0.0.1", | ||
"@okamjs/okam-linux-arm64-musl": "0.0.1", | ||
"@okamjs/okam-win32-arm64-msvc": "0.0.1", | ||
"@okamjs/okam-linux-arm-gnueabihf": "0.0.1", | ||
"@okamjs/okam-linux-x64-musl": "0.0.1", | ||
"@okamjs/okam-win32-ia32-msvc": "0.0.1" | ||
"@okamjs/okam-darwin-arm64": "0.0.3", | ||
"@okamjs/okam-darwin-x64": "0.0.3", | ||
"@okamjs/okam-linux-x64-gnu": "0.0.3" | ||
}, | ||
@@ -45,0 +35,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
281
10508