feat(cli): generate js binding to avoid dynamic require logic
This commit is contained in:
parent
b7a98d2c7a
commit
179f20a7c5
9 changed files with 325 additions and 70 deletions
examples
|
@ -2,13 +2,13 @@
|
|||
"name": "test-module",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"build": "node ../../cli/scripts/index.js build --features \"latest\"",
|
||||
"build-napi3": "node ../../cli/scripts/index.js build --features \"napi3\"",
|
||||
"build-aarch64": "node ../../cli/scripts/index.js build --features \"latest\" --target aarch64-unknown-linux-gnu",
|
||||
"build-armv7": "node ../../cli/scripts/index.js build --features \"latest\" --target armv7-unknown-linux-gnueabihf",
|
||||
"build-i686": "node ../../cli/scripts/index.js build --features \"latest\" --target i686-pc-windows-msvc",
|
||||
"build-i686-release": "node ../../cli/scripts/index.js build --release --features \"latest\" --target i686-pc-windows-msvc",
|
||||
"build-release": "node ../../cli/scripts/index.js build --features \"latest\" --release",
|
||||
"build": "node ../../cli/scripts/index.js build --js false --features \"latest\"",
|
||||
"build-napi3": "node ../../cli/scripts/index.js build --js false --features \"napi3\"",
|
||||
"build-aarch64": "node ../../cli/scripts/index.js build --js false --features \"latest\" --target aarch64-unknown-linux-gnu",
|
||||
"build-armv7": "node ../../cli/scripts/index.js build --js false --features \"latest\" --target armv7-unknown-linux-gnueabihf",
|
||||
"build-i686": "node ../../cli/scripts/index.js build --js false --features \"latest\" --target i686-pc-windows-msvc",
|
||||
"build-i686-release": "node ../../cli/scripts/index.js build --js false --release --features \"latest\" --target i686-pc-windows-msvc",
|
||||
"build-release": "node ../../cli/scripts/index.js build --js false --features \"latest\" --release",
|
||||
"test": "node ./index.js"
|
||||
}
|
||||
}
|
||||
|
|
33
examples/napi/index.d.ts
vendored
33
examples/napi/index.d.ts
vendored
|
@ -4,9 +4,7 @@ export function sumNums(nums: Array<number>): number
|
|||
export function readFileAsync(path: string): Promise<Buffer>
|
||||
export function asyncMultiTwo(arg: number): Promise<number>
|
||||
export function getCwd(callback: (arg0: string) => void): void
|
||||
export function readFile(
|
||||
callback: (arg0: Error | undefined, arg1: string | null) => void,
|
||||
): void
|
||||
export function readFile(callback: (arg0: Error | undefined, arg1: string | null) => void): void
|
||||
export function eitherStringOrNumber(input: string | number): number
|
||||
export function returnEither(input: number): string | number
|
||||
export function either3(input: string | number | boolean): number
|
||||
|
@ -14,21 +12,8 @@ interface Obj {
|
|||
v: string | number
|
||||
}
|
||||
export function either4(input: string | number | boolean | Obj): number
|
||||
export enum Kind {
|
||||
Dog = 0,
|
||||
Cat = 1,
|
||||
Duck = 2,
|
||||
}
|
||||
export enum CustomNumEnum {
|
||||
One = 1,
|
||||
Two = 2,
|
||||
Three = 3,
|
||||
Four = 4,
|
||||
Six = 6,
|
||||
Eight = 8,
|
||||
Nine = 9,
|
||||
Ten = 10,
|
||||
}
|
||||
export enum Kind { Dog = 0, Cat = 1, Duck = 2 }
|
||||
export enum CustomNumEnum { One = 1, Two = 2, Three = 3, Four = 4, Six = 6, Eight = 8, Nine = 9, Ten = 10 }
|
||||
export function enumToI32(e: CustomNumEnum): number
|
||||
export function throwError(): void
|
||||
export function mapOption(val: number | null): number | null
|
||||
|
@ -49,11 +34,7 @@ export function concatStr(mutS: string): string
|
|||
export function concatUtf16(s: string): string
|
||||
export function concatLatin1(s: string): string
|
||||
export function withoutAbortController(a: number, b: number): Promise<number>
|
||||
export function withAbortController(
|
||||
a: number,
|
||||
b: number,
|
||||
signal: AbortSignal,
|
||||
): Promise<number>
|
||||
export function withAbortController(a: number, b: number, signal: AbortSignal): Promise<number>
|
||||
export function getBuffer(): Buffer
|
||||
export class Animal {
|
||||
readonly kind: Kind
|
||||
|
@ -65,10 +46,14 @@ export class Animal {
|
|||
static getDogKind(): Kind
|
||||
}
|
||||
export class Blake2BHasher {
|
||||
|
||||
static withKey(key: Blake2bKey): Blake2BHasher
|
||||
}
|
||||
export class Blake2BKey {}
|
||||
export class Blake2BKey {
|
||||
|
||||
}
|
||||
export class Context {
|
||||
|
||||
constructor()
|
||||
static withData(data: string): Context
|
||||
method(): string
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
"main": "./index.node",
|
||||
"types": "./index.d.ts",
|
||||
"scripts": {
|
||||
"build": "node ../../cli/scripts/index.js build",
|
||||
"build-aarch64": "node ../../cli/scripts/index.js build --target aarch64-unknown-linux-gnu",
|
||||
"build-armv7": "node ../../cli/scripts/index.js build --target armv7-unknown-linux-gnueabihf",
|
||||
"build-i686": "node ../../cli/scripts/index.js build --target i686-pc-windows-msvc",
|
||||
"build-i686-release": "node ../../cli/scripts/index.js build --release --target i686-pc-windows-msvc",
|
||||
"build-release": "node ../../cli/scripts/index.js build --release"
|
||||
"build": "node ../../cli/scripts/index.js build --js false",
|
||||
"build-aarch64": "node ../../cli/scripts/index.js build --js false --target aarch64-unknown-linux-gnu",
|
||||
"build-armv7": "node ../../cli/scripts/index.js build --js false --target armv7-unknown-linux-gnueabihf",
|
||||
"build-i686": "node ../../cli/scripts/index.js build --js false --target i686-pc-windows-msvc",
|
||||
"build-i686-release": "node ../../cli/scripts/index.js build --js false --release --target i686-pc-windows-msvc",
|
||||
"build-release": "node ../../cli/scripts/index.js build --js false --release"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
"rootDir": "__test__",
|
||||
"target": "ES2015"
|
||||
},
|
||||
"exclude": ["dist"]
|
||||
"exclude": ["dist", "index.d.ts"]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue