-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
97 lines (90 loc) · 3.26 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
/** Import Map fllow the spec: https://wicg.github.io/import-maps/ */
export interface ImportMap {
$src?: string;
imports?: Record<string, string>;
scopes?: Record<string, Record<string, string>>;
}
/** Delopment options. */
export interface DevOptions {
/**
* Enable hot module replacement, default is disabled.
* ```js
* // the injected code
* import __CREATE_HOT_CONTEXT__ from "hmr_runtime"
* import.meta.hot = __CREATE_HOT_CONTEXT__(import.meta.url)
*/
hmr?: { runtime: string };
/**
* Enable react refresh, default is disabled.
* to enable it, you need to enable hmr first.
* The runtime module must export `__REFRESH_RUNTIME__` and `__REFRESH__`.
*/
refresh?: { runtime: string };
/**
* Enable preact refresh, default is disabled.
* to enable it, you need to enable hmr first.
* The runtime module must export `__REFRESH_RUNTIME__` and `__REFRESH__`.
*/
prefresh?: { runtime: string };
/** Add `__source` props to JSX elements, default is disabled. */
jsxSource?: { fileName: string };
}
/** Transform options. */
export interface TransformOptions {
/** The file name, used for source map and error message. */
filename: string;
/** The code to transform. */
code: string | Uint8Array;
/** The code language, default is using the file extension. */
lang?: "ts" | "tsx" | "js" | "jsx";
/** The transform target, default is "esnext". */
target?: "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "es2023" | "es2024" | "esnext";
/** The import map, pass it if the browser does not support import maps. */
importMap?: ImportMap;
/**
* Specifies the JSX import source. By default, it will use `react` or `preact` from the import map.
*
* ```json
* {
* "importMap": {
* "imports": { "react": "https://esm.sh/react" }
* }
* }
* ```
*
* Alternatively, you can specify it by adding an "@jsxRuntime" entry in the import map.
*
* ```json
* {
* "importMap": {
* "imports": { "@jsxRuntime": "https://esm.sh/react" }
* }
* }
* ```
*/
jsxImportSource?: string;
/** minify outputed code, default is disabled. */
minify?: boolean;
/** strip unused code, default is disabled. */
treeShaking?: boolean;
/** create source map, default is disabled. */
sourceMap?: "inline" | "external";
/** development mode, default is disabled. */
dev?: DevOptions;
}
/** Transform result. */
export interface TransformResult {
/** The transformed JavaScript code. */
readonly code: Uint8Array;
/** The generated source map, if the `sourceMap` option is enabled as `external`. */
readonly map?: Uint8Array;
}
/** Transforms the given code. */
export function transform(options: TransformOptions): TransformResult;
/** Instantiates the given `module`, which can either be bytes or a precompiled `WebAssembly.Module`. */
export function initSync(module: BufferSource | WebAssembly.Module): { memory: WebAssembly.Memory };
/** If `module_or_path` is {RequestInfo} or {URL}, makes a request and for everything else, calls `WebAssembly.instantiate` directly. */
export function init(
module_or_path?: RequestInfo | URL | Response | BufferSource | WebAssembly.Module,
): Promise<{ memory: WebAssembly.Memory }>;
export { init as default };