forked from napi-rs/napi-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.cts
More file actions
1556 lines (1110 loc) · 49.7 KB
/
Copy pathindex.d.cts
File metadata and controls
1556 lines (1110 loc) · 49.7 KB
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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* auto-generated by NAPI-RS */
/* eslint-disable */
import type { ReadableStream } from 'node:stream/web'
type MaybePromise<T> = T | Promise<T>
export declare const NAPI_RS_SYMBOL: symbol
export declare class ExternalObject<T> {
readonly '': {
readonly '': unique symbol
[K: symbol]: T
}
}
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array
/**
* `constructor` option for `struct` requires all fields to be public,
* otherwise tag impl fn as constructor
* #[napi(constructor)]
*/
export declare 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)
get optionalValue(): number | null
/**
* This is to test that setter with optional parameter generates valid TypeScript.
* TypeScript does not allow optional parameters in setters (TS1051).
*/
set optionalValue(value: number | undefined | null)
/**
* 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:
* \[]{}/\:""{
* }
* Accept header "*\/json" should not break the comment block
*/
returnOtherClass(): Dog
returnOtherClassWithCustomConstructor(): Bird
overrideIndividualArgOnMethod(normalTy: string, overriddenTy: {n: string}): Bird
}
export declare class AnimalWithDefaultConstructor {
name: string
kind: number
constructor(name: string, kind: number)
}
export declare class AnotherClassForEither {
constructor()
}
export declare class AnotherCssStyleSheet {
get rules(): CssRuleList
}
export type AnotherCSSStyleSheet = AnotherCssStyleSheet
export declare class Asset {
constructor()
get filePath(): number
}
export type JsAsset = Asset
export declare class Assets {
constructor()
get(id: number): JsAsset | null
}
export type JsAssets = Assets
/**
* This type implements JavaScript's async iterable protocol.
* It can be used with `for await...of` loops.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
*/
export declare class AsyncDataSource {
[Symbol.asyncIterator](): AsyncGenerator<string, void, undefined>
/** Creates an async data source that yields each item with a simulated I/O delay */
static fromData(data: Array<string>, delayMs: number): AsyncDataSource
}
/**
* This type implements JavaScript's async iterable protocol.
* It can be used with `for await...of` loops.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
*/
export declare class AsyncFib {
[Symbol.asyncIterator](): AsyncGenerator<number, void, number | undefined>
constructor()
}
export declare class AsyncThrowClass {
constructor()
asyncThrowError(): Promise<void>
}
export declare class Bird {
name: string
constructor(name: string)
getCount(): number
getNameAsync(): Promise<string>
acceptSliceMethod(slice: Uint8Array): number
}
/** Smoking test for type generation */
export declare class Blake2BHasher {
static withKey(key: Blake2bKey): Blake2BHasher
update(data: Buffer): void
}
export type Blake2bHasher = Blake2BHasher
export declare class Blake2BKey {
}
export type Blake2bKey = Blake2BKey
export declare class CatchOnConstructor {
constructor()
}
export declare class CatchOnConstructor2 {
constructor()
}
export declare class ClassInArray {
constructor(value: number)
}
export declare class ClassReturnInPromise {
}
export declare class ClassWithFactory {
name: string
static withName(name: string): ClassWithFactory
static with4Name(name: string): Promise<ClassWithFactory>
static with4NameResult(name: string): Promise<ClassWithFactory>
setName(name: string): this
}
export declare class ClassWithLifetime {
constructor()
getName(): string
}
export declare class Context {
maybeNeed?: boolean
buffer: Uint8Array
constructor()
static withData(data: string): Context
static withBuffer(buf: Uint8Array): Context
method(): string
}
/**
* This type implements JavaScript's async iterable protocol.
* It can be used with `for await...of` loops.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
*/
export declare class CounterRepro {
constructor(max: number)
[Symbol.asyncIterator](): AsyncGenerator<number, void, undefined>
}
export declare class CreateStringClass {
static new(): CreateStringClass
createString(): string | null
createStringResult(): string
}
export declare class CssRuleList {
getRules(): Array<string>
get parentStyleSheet(): CSSStyleSheet
get name(): string | null
}
export type CSSRuleList = CssRuleList
export declare class CssStyleSheet {
constructor(name: string, rules: Array<string>)
get rules(): CssRuleList
anotherCssStyleSheet(): AnotherCssStyleSheet
}
export type CSSStyleSheet = CssStyleSheet
export declare class CustomFinalize {
constructor(width: number, height: number)
}
export declare class CustomStruct {
static customStatusCodeForFactory(): CustomStruct
constructor()
}
export declare class DefaultUseNullableClass {
requiredNumberField: number
requiredStringField: string
optionalNumberField?: number
optionalStringField?: string
constructor(requiredNumberField: number, requiredStringField: string, optionalNumberField?: number, optionalStringField?: string)
}
/**
* This type implements JavaScript's async iterable protocol.
* It can be used with `for await...of` loops.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
*/
export declare class DelayedCounter {
[Symbol.asyncIterator](): AsyncGenerator<number, string, undefined>
/** Creates a counter that yields values from 0 to max-1 with a delay between each */
constructor(max: number, delayMs: number)
}
export declare class Dog {
name: string
constructor(name: string)
}
/**
* This type extends JavaScript's `Iterator`, and so has the iterator helper
* methods. It may extend the upcoming TypeScript `Iterator` class in the future.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator#iterator_helper_methods
* @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-6.html#iterator-helper-methods
*/
export declare class Fib extends Iterator<number, void, number> {
constructor()
next(value?: number): IteratorResult<number, void>
}
/**
* This type extends JavaScript's `Iterator`, and so has the iterator helper
* methods. It may extend the upcoming TypeScript `Iterator` class in the future.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator#iterator_helper_methods
* @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-6.html#iterator-helper-methods
*/
export declare class Fib2 extends Iterator<number, void, number> {
static create(seed: number): Fib2
next(value?: number): IteratorResult<number, void>
}
/**
* This type extends JavaScript's `Iterator`, and so has the iterator helper
* methods. It may extend the upcoming TypeScript `Iterator` class in the future.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator#iterator_helper_methods
* @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-6.html#iterator-helper-methods
*/
export declare class Fib3 extends Iterator<number, void, number> {
current: number
nextNum: number
constructor(current: number, nextNum: number)
next(value?: number): IteratorResult<number, void>
}
/**
* This type extends JavaScript's `Iterator`, and so has the iterator helper
* methods. It may extend the upcoming TypeScript `Iterator` class in the future.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator#iterator_helper_methods
* @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-6.html#iterator-helper-methods
*/
export declare class Fib4 extends Iterator<unknown, void, number> {
current: number
nextItem: number
constructor(current: number, nextItem: number)
toJSON(): Array<number>
next(value?: number): IteratorResult<unknown, void>
}
export declare class GetterSetterWithClosures {
constructor()
}
export declare class JsClassForEither {
constructor()
}
export declare class JSOnlyMethodsClass {
data: string
processData(): string
getLength(): number
}
export type RustOnlyMethodsClass = JSOnlyMethodsClass
export declare class JsRemote {
constructor(repo: JsRepo)
name(): string
}
export declare class JsRepo {
constructor(dir: string)
remote(): JsRemote
}
export declare class MyJsNamedClass {
constructor(value: string)
getValue(): string
multiplyValue(times: number): string
}
export type OriginalRustNameForJsNamedStruct = MyJsNamedClass
export declare class NinjaTurtle {
name: string
static isInstanceOf(value: unknown): boolean
/** Create your ninja turtle! 🐢 */
static newRaph(): NinjaTurtle
getMaskColor(): string
getName(): string
returnThis(): this
}
export declare class NotUseNullableClass {
requiredNumberField: number
requiredStringField: string
optionalNumberField?: number
optionalStringField?: string
constructor(requiredNumberField: number, requiredStringField: string, optionalNumberField?: number, optionalStringField?: string)
}
export declare class NotWritableClass {
name: string
constructor(name: string)
setName(name: string): void
}
export declare 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 declare class PackageJsonReader {
constructor()
read(): any
}
export declare class Reader {
constructor()
read(): Buffer
}
/**
* Regression fixture for issue #3378. `Vec` conversion reads JavaScript array
* elements, so an indexed getter can synchronously reenter before conversion
* has finished.
*/
export declare class ReentrantBorrowOrderTest {
values: Array<number>
constructor()
replaceValues(values: Array<number>): void
replaceValuesFromThis(this: object): void
}
export declare class Selector {
orderBy: Array<string>
select: Array<string>
struct: string
where?: string
constructor(orderBy: Array<string>, select: Array<string>, struct: string, where?: string)
}
export declare class Thing {
}
export declare class ThingList {
constructor()
get thing(): Thing
}
export declare class UseNullableClass {
requiredNumberField: number
requiredStringField: string
nullableNumberField: number | null
nullableStringField: string | null
constructor(requiredNumberField: number, requiredStringField: string, nullableNumberField: number | null, nullableStringField: string | null)
}
export declare class Width {
value: number
constructor(value: number)
}
export interface A {
foo: number
}
export declare function acceptArraybuffer(fixture: ArrayBuffer): bigint
export declare function acceptSlice(fixture: Uint8Array): bigint
export declare function acceptStream(stream: ReadableStream<Uint8Array>): Promise<Buffer>
export declare function acceptThreadsafeFunction(func: ((err: Error | null, arg: number) => any)): void
export declare function acceptThreadsafeFunctionFatal(func: ((arg: number) => void)): void
export declare function acceptThreadsafeFunctionTupleArgs(func: ((err: Error | null, arg0: number, arg1: boolean, arg2: string) => any)): void
export declare function acceptThreadsafeFunctionTupleNoFnArgs(func: ((err: Error | null, arg: [number, boolean, string]) => any)): void
export declare function acceptUint8ClampedSlice(input: Uint8ClampedArray): bigint
export declare function acceptUint8ClampedSliceAndBufferSlice(a: Buffer, b: Uint8ClampedArray): bigint
export declare function acceptUntypedTypedArray(input: TypedArray): bigint
export declare function add(a: number, b: number): number
export declare const enum ALIAS {
A = 0,
B = 1
}
export interface AliasedStruct {
a: ALIAS
b: number
}
export interface AllOptionalObject {
name?: string
age?: number
}
export declare function appendBuffer(buf: Buffer): Buffer
export declare function appendToOsString(s: string): string
export declare function apply0(ctx: Animal, callback: () => void): void
export declare function apply1(ctx: Animal, callback: (arg: string) => void, name: string): void
export declare function arrayBufferFromData(): ArrayBuffer
export declare function arrayBufferFromExternal(): ArrayBuffer
export declare function arrayBufferLenAsync(buf: Uint8Array): Promise<number>
export declare function arrayBufferPassThrough(buf: Uint8Array): Promise<Uint8Array>
export declare function arrayParams(arr: Array<number>): number
export declare function asyncBufferToArray(buf: ArrayBuffer): Array<number>
export declare function asyncMultiTwo(arg: number): Promise<number>
export declare function asyncPlus100(p: Promise<number>): Promise<number>
export declare function asyncReduceBuffer(buf: Buffer): Promise<number>
export declare function asyncResolveArray(inner: number): Promise<unknown[]>
export declare function asyncTaskArraybuffer(data: Array<number>): Promise<ArrayBuffer>
export declare function asyncTaskFinally(inner: object): Promise<void>
export declare function asyncTaskOptionalReturn(): Promise<number | null>
export declare function asyncTaskReadFile(path: string): Promise<Buffer>
export declare function asyncTaskVoidReturn(): Promise<void>
/**
* Awaits `promise` on the async runtime; a rejection materializes as an
* `Error` carrying a `napi_ref` and is dropped here, off the JS thread.
* Returns `true` when the promise rejected.
*/
export declare function awaitRejectionOffThread(promise: Promise<undefined>): Promise<boolean>
export interface B {
bar: number
}
export declare function bigintAdd(a: bigint, b: bigint): bigint
export declare function bigintFromI128(): bigint
export declare function bigintFromI64(): bigint
export declare function bigintGetU64AsString(bi: bigint): string
export interface BindingVitePluginMeta {
'vite:import-glob': ViteImportGlobMeta
}
export declare function btreeSetToJs(): Set<string>
export declare function btreeSetToRust(set: Set<string>): void
export declare function bufferLenAsync(buf: Buffer): Promise<number>
export declare function bufferPassThrough(buf: Buffer): Promise<Buffer>
export declare function bufferWithAsyncBlock(buf: Buffer): Promise<number>
export declare function buildThreadsafeFunctionFromFunction(callback: (arg0: number, arg1: number) => number): void
export declare function buildThreadsafeFunctionFromFunctionCalleeHandle(callback: () => void): void
export interface C {
baz: number
}
export declare function call0(callback: () => number): number
export declare function call1(callback: (arg: number) => number, arg: number): number
export declare function call2(callback: (arg0: number, arg1: number) => number, arg1: number, arg2: number): number
export declare function callAsyncWithUnknownReturnValue(tsfn: ((err: Error | null, arg: number) => unknown)): Promise<number>
export declare function callbackInSpawn(callback: (arg: object) => unknown): void
export declare function callbackReturnPromise<T>(functionInput: () => T | Promise<T>, callback: (err: Error | null, result: T) => void): T | Promise<T>
export declare function callbackReturnPromiseAndSpawn(jsFunc: (arg0: string) => Promise<string>): Promise<string>
export declare function callCatchOnPromise(input: Promise<number>): Promise<string>
export declare function callFinallyOnPromise(input: Promise<number>, onFinally: () => void): Promise<number>
export declare function callFunction(cb: () => number): number
export declare function callFunctionWithArg(cb: (arg0: number, arg1: number) => number, arg0: number, arg1: number): number
export declare function callFunctionWithArgAndCtx(ctx: Animal, cb: (arg: string) => void, name: string): void
export declare function callLongThreadsafeFunction(tsfn: ((err: Error | null, arg: number) => unknown)): void
export declare function callRuleHandler(rule: Rule, arg: number): number
export declare function callThenOnPromise(input: Promise<number>): Promise<string>
export declare function callThreadsafeFunction(tsfn: ((err: Error | null, arg: number) => unknown)): void
export declare function callWithNestedFunctionArg(callback: (arg: (arg: number) => number) => number): number
export declare function callWithTupleArg(callback: (arg: [number, number]) => number, arg1: number, arg2: number): number
export declare function captureErrorInCallback(cb1: () => void, cb2: (arg0: Error) => void): void
export declare function chronoDateAdd1Minute(input: Date): Date
export declare function chronoDateFixtureReturn1(): Date
export declare function chronoDateFixtureReturn2(): Date
export declare function chronoDateWithTimezoneReturn(): Date | null
export declare function chronoDateWithTimezoneToMillis(input: Date): number
export declare function chronoLocalDateReturn(): Date | null
export declare function chronoLocalDateToMillis(input: Date): number
export declare function chronoNativeDateTime(date: Date): number
export declare function chronoNativeDateTimeReturn(): Date | null
export declare function chronoUtcDateReturn(): Date | null
export declare function chronoUtcDateToMillis(input: Date): number
/**
* Creates and deletes `count` references on the calling JS thread, so
* concurrent off-thread releases have live `GlobalHandles` traffic to race
* with (this is what made the corruption deterministic in napi-rs#3368).
*/
export declare function churnGlobalHandles(value: unknown, count: number): void
export declare function cleanupReentrantBorrowOrderTestTargets(): number
export interface CompilerAssumptions {
ignoreFunctionLength?: boolean
noDocumentAll?: boolean
objectRestNoSymbols?: boolean
pureGetters?: boolean
/**
* When using public class fields, assume that they don't shadow any getter in the current class,
* in its subclasses or in its superclass. Thus, it's safe to assign them rather than using
* `Object.defineProperty`.
*
* For example:
*
* Input:
* ```js
* class Test {
* field = 2;
*
* static staticField = 3;
* }
* ```
*
* When `set_public_class_fields` is `true`, the output will be:
* ```js
* class Test {
* constructor() {
* this.field = 2;
* }
* }
* Test.staticField = 3;
* ```
*
* Otherwise, the output will be:
* ```js
* import _defineProperty from "@oxc-project/runtime/helpers/defineProperty";
* class Test {
* constructor() {
* _defineProperty(this, "field", 2);
* }
* }
* _defineProperty(Test, "staticField", 3);
* ```
*
* NOTE: For TypeScript, if you wanted behavior is equivalent to `useDefineForClassFields: false`, you should
* set both `set_public_class_fields` and [`crate::TypeScriptOptions::remove_class_fields_without_initializer`]
* to `true`.
*/
setPublicClassFields?: boolean
}
export declare function compressSync(_: string | Uint8Array): Buffer
export declare function concatLatin1(s: string): string
export declare function concatStr(s: string): string
export declare function concatUtf16(s: string): string
export declare function contains(source: string, target: string): boolean
export declare function convertU32Array(input: Uint32Array): Array<number>
export declare function createArraybuffer(): ArrayBuffer
export declare function createBigInt(): bigint
export declare function createBigIntI64(): bigint
export declare function createBufferSliceFromCopiedData(): Buffer
/**
* Regression guard for the off-thread `FunctionRef` drop.
*
* A `create_with_stream_bytes` output whose pull future REJECTS (the underlying
* stream yields an `Err` item, or the output is cancelled while a pull is parked)
* drops the pull resolver — which owns the controller's `enqueue`/`close`
* `FunctionRef`s — on a Tokio worker thread rather than the JS thread. A
* `FunctionRef` holds a thread-affine `napi_ref`; deleting it off the JS thread
* mutates V8's `GlobalHandles` concurrently with the JS thread and corrupts the
* heap, surfacing later as a SIGSEGV/SIGBUS inside V8/napi. This emits one `Ok`
* chunk then a terminal `Err`, so JS can loop it and assert the process stays
* alive (see the matching test in `__tests__/values.spec.ts`).
*/
export declare function createErroringReadableStream(): ReadableStream<Buffer>
export declare function createExternal(size: number): ExternalObject<number>
export declare function createExternalBufferSlice(): Buffer
export declare function createExternalLatin1CustomFinalize(): string
export declare function createExternalLatin1Empty(): string
export declare function createExternalLatin1Long(): string
export declare function createExternalLatin1Short(): string
export declare function createExternalLatin1String(): string
export declare function createExternalLatin1WithLatin1Chars(): string
export declare function createExternalRef(size: number): ExternalObject<number>
export declare function createExternalString(content: string): ExternalObject<string>
export declare function createExternalTypedArray(): Uint32Array
export declare function createExternalUtf16String(): string
export declare function createFunction(): (arg: number) => number
export declare function createI32ArrayFromExternal(): Int32Array
export declare function createNotUseNullableStruct(): NotUseNullableStruct
export declare function createObj(): object
export declare function createObjectRef(): object
export declare function createObjectWithClassField(): ObjectFieldClassInstance
export declare function createObjWithProperty(): { value: ArrayBuffer, get getter(): number }
export declare function createOptionalExternal(size?: number | undefined | null): ExternalObject<number> | null
export declare function createReadableStream(): ReadableStream<Buffer>
export declare function createReadableStreamFromClass(readableStreamClass: typeof ReadableStream): ReadableStream<Buffer>
/**
* Creates a ReadableStream that emits StreamItem objects.
* This demonstrates streaming custom Rust structs to JavaScript.
*/
export declare function createReadableStreamWithObject(): ReadableStream<StreamItem>
/**
* Create a class-branded object whose wrap can be removed without touching
* the generated class instance's reference/finalizer bookkeeping.
*/
export declare function createReentrantBorrowOrderTestTarget(constructor: new (...args: any[]) => unknown): object
export declare function createReferenceOnFunction(cb: () => void): Promise<void>
export declare function createRejectedPromise(message: string): Promise<number>
export declare function createResolvedPromise(value: number): Promise<number>
export declare function createStaticLatin1String(): string
export declare function createStaticUtf16String(): string
export declare function createSymbol(): symbol
export declare function createSymbolFor(desc: string): symbol
export declare function createSymbolRef(desc: string): symbol
export declare function createUint8ClampedArrayFromData(): Uint8ClampedArray
export declare function createUint8ClampedArrayFromExternal(): Uint8ClampedArray
export declare function createUseNullableStruct(): UseNullableStruct
export declare function createZeroCopyLatin1String(): string
export declare function createZeroCopyUtf16String(): string
/** You could break the step and for an new continuous value. */
export declare const enum CustomNumEnum {
One = 1,
Two = 2,
Three = 3,
Four = 4,
Six = 6,
Eight = 8,
Nine = 9,
Ten = 10
}
export declare function customStatusCode(): void
export declare const enum CustomStringEnum {
Foo = 'my-custom-value',
Bar = 'Bar',
Baz = 'Baz'
}
export type CustomU32 =
number
export interface Data {
data: string | Buffer
}
export interface DatesWithTimeZone {
start: Date
end?: Date
}
export declare function dateToNumber(input: Date): number
/** This is a const */
export const DEFAULT_COST: number
export interface DefaultUseNullableStruct {
requiredNumberField: number
requiredStringField: string
optionalNumberField?: number
optionalStringField?: string
}
export declare function defineClass(): typeof DynamicRustClass
class DynamicRustClass {
constructor(value: number)
rustMethod(): number
}
export declare function derefUint8Array(a: Uint8Array, b: Uint8ClampedArray): number
/**
* Detach the native value without constructing a second Rust receiver during
* reentry. Cleanup is deliberately deferred until the outer native call has
* returned or thrown, because the old code generation keeps using the cached
* pointer after input conversion.
*/
export declare function detachReentrantBorrowOrderTestTarget(target: unknown): void
/**
* Counts the chunks read from a stream, swallowing (dropping) any read error.
*
* Regression guard: the read error is dropped here inside the async block, which runs
* on the Tokio runtime thread rather than the JS thread. A `Reader` rejection that
* carried a raw JS `napi_ref` would release that reference off the JS thread on drop,
* aborting the process; the owned-error conversion makes this safe.
*/
export declare function drainStreamCount(stream: ReadableStream<Uint8Array>): Promise<number>
/**
* `try_clone` shares one `napi_ref` between siblings via an `Arc<ErrorRef>`;
* dropping a sibling is an atomic refcount decrement, and the underlying
* reference is released only when the LAST sibling drops. Here the original
* drops on the JS thread first (a plain decrement, no release), then the last
* sibling drops off-thread — so the release is routed through the custom-GC
* TSFN, exactly the path a shared reference must survive without corrupting
* V8's GlobalHandles from a foreign thread.
*/
export declare function dropClonedErrorsOnTwoThreads(value: unknown): void
/**
* Converts `value` into an `Error` — creating a `napi_ref` to it, the same
* code path a `Promise` rejection takes — and drops it on a spawned thread.
*/
export declare function dropErrorFromValueOffThread(value: unknown): void
export declare function either3(input: string | number | boolean): number
export declare function either4(input: string | number | boolean | Obj): number
export declare function eitherBoolOrFunction(input: boolean | ((arg?: unknown) => unknown)): void
export declare function eitherBoolOrTuple(input: boolean | [boolean, string]): void
export declare function eitherF64OrU32(input: number): number
export declare function eitherFromObjects(input: A | B | C): string
export declare function eitherFromOption(): JsClassForEither | undefined
export declare function eitherPromiseInEitherA(input: Promise<number> | number | string): Promise<boolean>
export declare function eitherStringOrNumber(input: string | number): number
export declare const enum Empty {
}
export declare function enumToI32(e: CustomNumEnum): number
export declare function errorMessageContainsNullByte(msg: string): void
export declare function esmResolve(next: () => Promise<undefined>): Promise<undefined>
export declare function extendsJavascriptError(errorClass: any): void
export type ExternalLinterLoadPluginCb =
((arg: string) => PluginLoadResult)
export type ExternalLinterLoadPluginCb2 =
((arg: string) => PluginLoadResult)
export declare function f32ArrayToArray(input: Float32Array): Array<number>
export declare function f64ArrayToArray(input: Float64Array): Array<number>
export declare function fetch(url: string, requestInit?: RequestInit | undefined | null): Promise<import('undici-types').Response>
export declare function fibonacci(n: number): number
export declare function fnReceivedAliased(s: AliasedStruct, e: ALIAS): void
export interface FunctionData {
handle: () => number
}
export declare function generateFunctionAndCallIt(): FunctionData
export declare function getBigintJsonValue(value: bigint): void
export declare function getBtreeMapping(): Record<string, number>
export declare function getBuffer(): Buffer
export declare function getBufferSlice(): Buffer
export declare function getClassFromArray(arr: unknown[]): number | null
export declare function getCwd(callback: (arg0: string) => void): void
export declare function getEmptyBuffer(): Buffer
export declare function getEmptyTypedArray(): Uint8Array
export declare function getExternal(external: ExternalObject<number>): number
export declare function getGlobal(): typeof global
export declare function getIndexMapping(): Record<string, number>
export declare function getIndexMappingWithHasher(): Record<string, number>
export declare function getMapping(): Record<string, number>
export declare function getMappingWithHasher(): Record<string, number>
export declare function getModuleFileName(): string
export declare function getMyVec(): MyVec
export declare function getNestedNumArr(): number[][][]
export declare function getNull(): null
export declare function getNullByteProperty(obj: object): string | null
export declare function getNumArr(): number[]
/** Gets some numbers */
export declare function getNums(): Array<number>
export declare function getOptionalExternal(external?: ExternalObject<number> | undefined | null): number | null
export declare function getPackageJsonName(packageJson: PackageJson): string
export declare function getStrFromObject(): void
export declare function getterFromObj(): number
export declare function getTuple(val: [number, string, number]): number
export declare function getUndefined(): void
export declare function getWords(): Array<string>
export declare function i16ArrayToArray(input: Int16Array): Array<number>
export declare function i32ArrayToArray(input: Int32Array): Array<number>
export declare function i64ArrayToArray(input: BigInt64Array): Array<number>
export declare function i8ArrayToArray(input: Int8Array): Array<number>
export declare function indexmapPassthrough(fixture: Record<string, number>): Record<string, number>
export declare function indexSetToJs(): Set<string>
export declare function indexSetToRust(set: Set<string>): void
export declare function intoUtf8(s: string): string
export declare function joinPath(path: string, segment: string): string
export declare function jsErrorCallback(value: unknown): Array<Error>
/** default enum values are continuos i32s start from 0 */
export declare const enum Kind {
/** Barks */
Dog = 0,
/** Kills birds */
Cat = 1,
/** Tasty */
Duck = 2
}
/** default enum values are continuos i32s start from 0 */
export declare const enum KindInValidate {
/** Barks */
Dog = 0,
/** Kills birds */
Cat = 1,
/** Tasty */
Duck = 2
}
export interface Latin1MethodsResult {