forked from napi-rs/napi-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
359 lines (356 loc) · 12.5 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export class ExternalObject<T> {
readonly '': {
readonly '': unique symbol
[K: symbol]: T
}
}
/** This is a const */
export const DEFAULT_COST: number
export function getWords(): Array<string>
/** Gets some numbers */
export function getNums(): Array<number>
export function sumNums(nums: Array<number>): number
export function toJsObj(): object
export function getNumArr(): number[]
export function getNestedNumArr(): number[][][]
export function readFileAsync(path: string): Promise<Buffer>
export function asyncMultiTwo(arg: number): Promise<number>
export function bigintAdd(a: bigint, b: bigint): bigint
export function createBigInt(): bigint
export function createBigIntI64(): bigint
export function bigintGetU64AsString(bi: bigint): string
export function getCwd(callback: (arg0: string) => void): void
export function optionEnd(callback: (arg0: string, arg1?: string | undefined | null) => void): void
export function optionStart(callback: (arg0: string | undefined | null, arg1: string) => void): void
export function optionStartEnd(callback: (arg0: string | undefined | null, arg1: string, arg2?: string | undefined | null) => void): void
export function optionOnly(callback: (arg0?: string | undefined | null) => void): void
/** napi = { version = 2, features = ["serde-json"] } */
export function readFile(callback: (arg0: Error | undefined, arg1?: string | undefined | null) => void): void
export function returnJsFunction(): (...args: any[]) => any
export function callbackReturnPromise<T>(functionInput: () => T | Promise<T>, callback: (err: Error | null, result: T) => void): T | Promise<T>
export interface ObjectFieldClassInstance {
bird: Bird
}
export function createObjectWithClassField(): ObjectFieldClassInstance
export function receiveObjectWithClassField(object: ObjectFieldClassInstance): Bird
export function plusOne(this: Width): number
export function dateToNumber(input: Date): number
export function chronoDateToMillis(input: Date): number
export function chronoDateAdd1Minute(input: Date): Date
export interface Dates {
start: Date
end?: Date
}
export function eitherStringOrNumber(input: string | number): number
export function returnEither(input: number): string | number
export function either3(input: string | number | boolean): number
export interface Obj {
v: string | number
}
export function either4(input: string | number | boolean | Obj): number
export function receiveClassOrNumber(either: number | JsClassForEither): number
export function receiveMutClassOrNumber(either: number | JsClassForEither): number
export function receiveDifferentClass(either: JsClassForEither | AnotherClassForEither): number
export function returnEitherClass(input: number): number | JsClassForEither
export function eitherFromOption(): JsClassForEither | undefined
export interface A {
foo: number
}
export interface B {
bar: number
}
export interface C {
baz: number
}
export function eitherFromObjects(input: A | B | C): string
/** default enum values are continuos i32s start from 0 */
export const enum Kind {
/** Barks */
Dog = 0,
/** Kills birds */
Cat = 1,
/** Tasty */
Duck = 2
}
export const enum Empty {
}
/** You could break the step and for an new continuous value. */
export const 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 panic(): void
export function createExternal(size: number): ExternalObject<number>
export function createExternalString(content: string): ExternalObject<string>
export function getExternal(external: ExternalObject<number>): number
export function mutateExternal(external: ExternalObject<number>, newVal: number): void
export function validateArray(arr: Array<number>): number
export function validateBuffer(b: Buffer): number
export function validateTypedArray(input: Uint8Array): number
export function validateBigint(input: bigint): bigint
export function validateBoolean(i: boolean): boolean
export function validateDate(d: Date): number
export function validateDateTime(d: Date): number
export function validateExternal(e: ExternalObject<number>): number
export function validateFunction(cb: () => number): number
export function validateHashMap(input: Record<string, number>): number
export function validateNull(i: null): boolean
export function validateUndefined(i: undefined): boolean
export function validateNumber(i: number): number
export function validatePromise(p: Promise<number>): Promise<number>
export function validateString(s: string): string
export function validateSymbol(s: symbol): boolean
export function validateOptional(input1?: string | undefined | null, input2?: boolean | undefined | null): boolean
export function returnUndefinedIfInvalid(input: boolean): boolean
export function returnUndefinedIfInvalidPromise(input: Promise<boolean>): Promise<boolean>
export function tsRename(a: { foo: number }): string[]
export function overrideIndividualArgOnFunction(notOverridden: string, f: () => string, notOverridden2: number): string
export function overrideIndividualArgOnFunctionWithCbArg(callback: (town: string, name?: string | undefined | null) => string, notOverridden: number): object
export function xxh64Alias(input: Buffer): bigint
export function getMapping(): Record<string, number>
export function sumMapping(nums: Record<string, number>): number
export function mapOption(val?: number | undefined | null): number | null
export function returnNull(): null
export function returnUndefined(): void
export function add(a: number, b: number): number
export function fibonacci(n: number): number
export function listObjKeys(obj: object): Array<string>
export function createObj(): object
export function getGlobal(): typeof global
export function getUndefined(): void
export function getNull(): null
export interface AllOptionalObject {
name?: string
age?: number
}
export function receiveAllOptionalObject(obj?: AllOptionalObject | undefined | null): void
export const enum ALIAS {
A = 0,
B = 1
}
export interface AliasedStruct {
a: ALIAS
b: number
}
export function fnReceivedAliased(s: AliasedStruct, e: ALIAS): void
export interface StrictObject {
name: string
}
export function receiveStrictObject(strictObject: StrictObject): void
export function getStrFromObject(): void
export interface TsTypeChanged {
typeOverride: object
typeOverrideOptional?: object
}
export function createObjWithProperty(): { value: ArrayBuffer, get getter(): number }
export function getterFromObj(): number
export function asyncPlus100(p: Promise<number>): Promise<number>
/** This is an interface for package.json */
export interface PackageJson {
name: string
/** The version of the package */
version: string
dependencies?: Record<string, any>
devDependencies?: Record<string, any>
}
export function readPackageJson(): PackageJson
export function getPackageJsonName(packageJson: PackageJson): string
export function testSerdeRoundtrip(data: any): any
export function contains(source: string, target: string): boolean
export function concatStr(s: string): string
export function concatUtf16(s: string): string
export function concatLatin1(s: string): string
export function roundtripStr(s: string): string
export function setSymbolInObj(symbol: symbol): object
export function createSymbol(): symbol
export function withoutAbortController(a: number, b: number): Promise<number>
export function withAbortController(a: number, b: number, signal: AbortSignal): Promise<number>
export function callThreadsafeFunction(callback: (...args: any[]) => any): void
export function threadsafeFunctionThrowError(cb: (...args: any[]) => any): void
export function threadsafeFunctionFatalMode(cb: (...args: any[]) => any): void
export function threadsafeFunctionFatalModeError(cb: (...args: any[]) => any): void
export function useTokioWithoutAsync(): void
export function getBuffer(): Buffer
export function appendBuffer(buf: Buffer): Buffer
export function getEmptyBuffer(): Buffer
export function convertU32Array(input: Uint32Array): Array<number>
export function createExternalTypedArray(): Uint32Array
export function mutateTypedArray(input: Float32Array): void
export function derefUint8Array(a: Uint8Array, b: Uint8ClampedArray): number
export function bufferPassThrough(buf: Buffer): Promise<Buffer>
export function arrayBufferPassThrough(buf: Uint8Array): Promise<Uint8Array>
export function asyncReduceBuffer(buf: Buffer): Promise<number>
/**
* `constructor` option for `struct` requires all fields to be public,
* otherwise tag impl fn as constructor
* #[napi(constructor)]
*/
export class Animal {
/** Kind of animal */
readonly kind: Kind
/** This is the constructor */
constructor(kind: Kind, name: string)
/** This is a factory method */
static withKind(kind: Kind): Animal
get name(): string
set name(name: string)
get type(): Kind
set type(kind: Kind)
/**
* This is a
* multi-line comment
* with an emoji 🚀
*/
whoami(): string
/** This is static... */
static getDogKind(): Kind
/**
* Here are some characters and character sequences
* that should be escaped correctly:
* \[]{}/\:""
*/
returnOtherClass(): Dog
returnOtherClassWithCustomConstructor(): Bird
overrideIndividualArgOnMethod(normalTy: string, overriddenTy: {n: string}): Bird
}
export class Dog {
name: string
constructor(name: string)
}
export class Bird {
name: string
constructor(name: string)
getCount(): number
}
export type Blake2bHasher = Blake2BHasher
/** Smoking test for type generation */
export class Blake2BHasher {
update(data: Buffer): void
}
export type Blake2bKey = Blake2BKey
export class Blake2BKey { }
export class Context {
maybeNeed?: boolean
buffer: Uint8Array
constructor()
static withData(data: string): Context
static withBuffer(buf: Uint8Array): Context
method(): string
}
export class AnimalWithDefaultConstructor {
name: string
kind: number
constructor(name: string, kind: number)
}
export class NinjaTurtle {
name: string
static isInstanceOf(value: unknown): boolean
/** Create your ninja turtle! 🐢 */
static newRaph(): NinjaTurtle
getMaskColor(): string
getName(): string
returnThis(this: this): this
}
export type JsAssets = Assets
export class Assets {
constructor()
get(id: number): JsAsset | null
}
export type JsAsset = Asset
export class Asset {
constructor()
get filePath(): number
}
export class Optional {
static optionEnd(required: string, optional?: string | undefined | null): string
static optionStart(optional: string | undefined | null, required: string): string
static optionStartEnd(optional1: string | undefined | null, required: string, optional2?: string | undefined | null): string
static optionOnly(optional?: string | undefined | null): string
}
export class NotWritableClass {
name: string
constructor(name: string)
setName(name: string): void
}
export class CustomFinalize {
constructor(width: number, height: number)
}
export class Width {
value: number
constructor(value: number)
}
export class ClassWithFactory {
name: string
static withName(name: string): ClassWithFactory
setName(name: string): this
}
export class JsClassForEither {
constructor()
}
export class AnotherClassForEither {
constructor()
}
export class Fib {
constructor()
}
export class Fib2 {
[Symbol.iterator](): Iterator<number, void, number>
static create(seed: number): Fib2
}
export class Fib3 {
current: number
next: number
constructor(current: number, next: number)
[Symbol.iterator](): Iterator<number, void, number>
}
export class JsRepo {
constructor(dir: string)
remote(): JsRemote
}
export class JsRemote {
name(): string
}
export type CSSRuleList = CssRuleList
export class CssRuleList {
getRules(): Array<string>
get parentStyleSheet(): CSSStyleSheet
get name(): string | null
}
export type CSSStyleSheet = CssStyleSheet
export class CssStyleSheet {
constructor(name: string, rules: Array<string>)
get rules(): CssRuleList
anotherCssStyleSheet(): AnotherCssStyleSheet
}
export type AnotherCSSStyleSheet = AnotherCssStyleSheet
export class AnotherCssStyleSheet {
get rules(): CssRuleList
}
export namespace xxh3 {
export const ALIGNMENT: number
export function xxh3_64(input: Buffer): bigint
/** xxh128 function */
export function xxh128(input: Buffer): bigint
/** Xxh3 class */
export class Xxh3 {
constructor()
/** update */
update(input: Buffer): void
digest(): bigint
}
}
export namespace xxh2 {
export function xxh2Plus(a: number, b: number): number
export function xxh3Xxh64Alias(input: Buffer): bigint
}