-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate
@emnapi/core
to typescript (#100)
- Loading branch information
1 parent
0660480
commit 9037460
Showing
13 changed files
with
468 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/lib | ||
node_modules | ||
/dist | ||
/src/module.js | ||
/src/emnapi/**/*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
|
||
// "extends": "./shared/api-extractor-base.json" | ||
// "extends": "my-package/include/api-extractor-base.json" | ||
|
||
"projectFolder": ".", | ||
|
||
"mainEntryPointFilePath": "<projectFolder>/lib/typings/index.d.ts", | ||
|
||
"bundledPackages": [], | ||
|
||
"compiler": { | ||
"tsconfigFilePath": "<projectFolder>/tsconfig.json" | ||
|
||
// "overrideTsconfig": { | ||
// . . . | ||
// } | ||
|
||
// "skipLibCheck": true, | ||
}, | ||
|
||
"apiReport": { | ||
"enabled": false | ||
|
||
// "reportFileName": "<unscopedPackageName>.api.md", | ||
|
||
// "reportFolder": "<projectFolder>/etc/", | ||
|
||
// "reportTempFolder": "<projectFolder>/api/temp/" | ||
}, | ||
|
||
"docModel": { | ||
"enabled": false | ||
|
||
// "apiJsonFilePath": "<projectFolder>/temp/<unscopedPackageName>.api.json" | ||
}, | ||
|
||
"dtsRollup": { | ||
"enabled": true, | ||
|
||
"untrimmedFilePath": "", | ||
|
||
// "betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts", | ||
|
||
"publicTrimmedFilePath": "<projectFolder>/dist/emnapi-core.d.ts" | ||
|
||
// "omitTrimmingComments": true | ||
}, | ||
|
||
"tsdocMetadata": { | ||
"enabled": false, | ||
|
||
"tsdocMetadataFilePath": "<projectFolder>/dist/tsdoc-metadata.json" | ||
}, | ||
|
||
// "newlineKind": "crlf", | ||
|
||
"messages": { | ||
/** | ||
* Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing | ||
* the input .d.ts files. | ||
* | ||
* TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551" | ||
* | ||
* DEFAULT VALUE: A single "default" entry with logLevel=warning. | ||
*/ | ||
"compilerMessageReporting": { | ||
"default": { | ||
"logLevel": "warning" | ||
|
||
// "addToApiReportFile": false | ||
} | ||
|
||
// "TS2551": { | ||
// "logLevel": "warning", | ||
// "addToApiReportFile": true | ||
// }, | ||
// | ||
// . . . | ||
}, | ||
|
||
"extractorMessageReporting": { | ||
"default": { | ||
"logLevel": "warning" | ||
// "addToApiReportFile": false | ||
}, | ||
"ae-missing-release-tag": { | ||
"logLevel": "none", | ||
"addToApiReportFile": false | ||
} | ||
|
||
// "ae-extra-release-tag": { | ||
// "logLevel": "warning", | ||
// "addToApiReportFile": true | ||
// }, | ||
// | ||
// . . . | ||
}, | ||
|
||
"tsdocMessageReporting": { | ||
"default": { | ||
"logLevel": "warning" | ||
// "addToApiReportFile": false | ||
} | ||
|
||
// "tsdoc-link-tag-unescaped-text": { | ||
// "logLevel": "warning", | ||
// "addToApiReportFile": true | ||
// }, | ||
// | ||
// . . . | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import type { Context } from '@emnapi/runtime' | ||
|
||
/** @public */ | ||
export declare interface PointerInfo { | ||
address: number | ||
ownership: 0 | 1 | ||
runtimeAllocated: 0 | 1 | ||
} | ||
|
||
/** @public */ | ||
export declare interface InitOptions { | ||
instance: WebAssembly.Instance | ||
module: WebAssembly.Module | ||
memory?: WebAssembly.Memory | ||
table?: WebAssembly.Table | ||
} | ||
|
||
/** @public */ | ||
export declare interface NapiModule { | ||
imports: { | ||
env: any | ||
napi: any | ||
emnapi: any | ||
} | ||
exports: any | ||
loaded: boolean | ||
filename: string | ||
childThread: boolean | ||
emnapi: { | ||
syncMemory<T extends ArrayBuffer | ArrayBufferView> ( | ||
js_to_wasm: boolean, | ||
arrayBufferOrView: T, | ||
offset?: number, | ||
len?: number | ||
): T | ||
getMemoryAddress (arrayBufferOrView: ArrayBuffer | ArrayBufferView): PointerInfo | ||
} | ||
|
||
init (options: InitOptions): any | ||
spawnThread (startArg: number, errorOrTid?: number): number | ||
startThread (tid: number, startArg: number): void | ||
initWorker (arg: number): void | ||
executeAsyncWork (work: number): void | ||
postMessage?: (msg: any) => any | ||
} | ||
|
||
/** @public */ | ||
export declare interface NodeBinding { | ||
node: { | ||
emitAsyncInit: Function | ||
emitAsyncDestroy: Function | ||
makeCallback: Function | ||
} | ||
napi: { | ||
asyncInit: Function | ||
asyncDestroy: Function | ||
makeCallback: Function | ||
} | ||
} | ||
|
||
/** @public */ | ||
export declare interface CreateWorkerInfo { | ||
type: 'thread' | 'async-work' | ||
} | ||
|
||
/** @public */ | ||
export declare type BaseCreateOptions = { | ||
filename?: string | ||
nodeBinding?: NodeBinding | ||
reuseWorker?: boolean | ||
asyncWorkPoolSize?: number | ||
onCreateWorker?: (info: CreateWorkerInfo) => any | ||
print?: (str: string) => void | ||
printErr?: (str: string) => void | ||
postMessage?: (msg: any) => any | ||
} | ||
|
||
/** @public */ | ||
export declare type CreateOptions = BaseCreateOptions & ({ | ||
context: Context | ||
childThread?: boolean | ||
} | { | ||
context?: Context | ||
childThread: true | ||
}) | ||
|
||
/** @public */ | ||
export declare function createNapiModule ( | ||
options: CreateOptions | ||
): NapiModule |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export { createNapiModule } from './emnapi/index' | ||
export { | ||
loadNapiModule, | ||
loadNapiModuleSync, | ||
instantiateNapiModule, | ||
instantiateNapiModuleSync | ||
} from './load' | ||
|
||
export { MessageHandler } from './worker' | ||
|
||
declare const __VERSION__: string | ||
export const version = __VERSION__ | ||
|
||
export type { | ||
PointerInfo, | ||
InitOptions, | ||
NapiModule, | ||
NodeBinding, | ||
CreateWorkerInfo, | ||
BaseCreateOptions, | ||
CreateOptions | ||
} from './emnapi/index' | ||
|
||
export type { | ||
LoadOptions, | ||
InstantiateOptions, | ||
InstantiatedSource, | ||
ReactorWASI | ||
} from './load' | ||
|
||
export type { | ||
OnLoadData, | ||
HandleOptions | ||
} from './worker' | ||
|
||
export type { | ||
InputType | ||
} from './util' |
Oops, something went wrong.