source: trip-planner-front/node_modules/esbuild-wasm/esm/browser.d.ts@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 10.7 KB
Line 
1export type Platform = 'browser' | 'node' | 'neutral';
2export type Format = 'iife' | 'cjs' | 'esm';
3export type Loader = 'js' | 'jsx' | 'ts' | 'tsx' | 'css' | 'json' | 'text' | 'base64' | 'file' | 'dataurl' | 'binary' | 'default';
4export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent';
5export type Charset = 'ascii' | 'utf8';
6
7interface CommonOptions {
8 sourcemap?: boolean | 'inline' | 'external' | 'both';
9 legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external';
10 sourceRoot?: string;
11 sourcesContent?: boolean;
12
13 format?: Format;
14 globalName?: string;
15 target?: string | string[];
16
17 minify?: boolean;
18 minifyWhitespace?: boolean;
19 minifyIdentifiers?: boolean;
20 minifySyntax?: boolean;
21 charset?: Charset;
22 treeShaking?: boolean;
23 ignoreAnnotations?: boolean;
24
25 jsx?: 'transform' | 'preserve';
26 jsxFactory?: string;
27 jsxFragment?: string;
28
29 define?: { [key: string]: string };
30 pure?: string[];
31 keepNames?: boolean;
32
33 color?: boolean;
34 logLevel?: LogLevel;
35 logLimit?: number;
36}
37
38export interface BuildOptions extends CommonOptions {
39 bundle?: boolean;
40 splitting?: boolean;
41 preserveSymlinks?: boolean;
42 outfile?: string;
43 metafile?: boolean;
44 outdir?: string;
45 outbase?: string;
46 platform?: Platform;
47 external?: string[];
48 loader?: { [ext: string]: Loader };
49 resolveExtensions?: string[];
50 mainFields?: string[];
51 conditions?: string[];
52 write?: boolean;
53 allowOverwrite?: boolean;
54 tsconfig?: string;
55 outExtension?: { [ext: string]: string };
56 publicPath?: string;
57 entryNames?: string;
58 chunkNames?: string;
59 assetNames?: string;
60 inject?: string[];
61 banner?: { [type: string]: string };
62 footer?: { [type: string]: string };
63 incremental?: boolean;
64 entryPoints?: string[] | Record<string, string>;
65 stdin?: StdinOptions;
66 plugins?: Plugin[];
67 absWorkingDir?: string;
68 nodePaths?: string[]; // The "NODE_PATH" variable from Node.js
69 watch?: boolean | WatchMode;
70}
71
72export interface WatchMode {
73 onRebuild?: (error: BuildFailure | null, result: BuildResult | null) => void;
74}
75
76export interface StdinOptions {
77 contents: string;
78 resolveDir?: string;
79 sourcefile?: string;
80 loader?: Loader;
81}
82
83export interface Message {
84 pluginName: string;
85 text: string;
86 location: Location | null;
87 notes: Note[];
88
89 // Optional user-specified data that is passed through unmodified. You can
90 // use this to stash the original error, for example.
91 detail: any;
92}
93
94export interface Note {
95 text: string;
96 location: Location | null;
97}
98
99export interface Location {
100 file: string;
101 namespace: string;
102 line: number; // 1-based
103 column: number; // 0-based, in bytes
104 length: number; // in bytes
105 lineText: string;
106 suggestion: string;
107}
108
109export interface OutputFile {
110 path: string;
111 contents: Uint8Array; // "text" as bytes
112 text: string; // "contents" as text
113}
114
115export interface BuildInvalidate {
116 (): Promise<BuildIncremental>;
117 dispose(): void;
118}
119
120export interface BuildIncremental extends BuildResult {
121 rebuild: BuildInvalidate;
122}
123
124export interface BuildResult {
125 errors: Message[];
126 warnings: Message[];
127 outputFiles?: OutputFile[]; // Only when "write: false"
128 rebuild?: BuildInvalidate; // Only when "incremental: true"
129 stop?: () => void; // Only when "watch: true"
130 metafile?: Metafile; // Only when "metafile: true"
131}
132
133export interface BuildFailure extends Error {
134 errors: Message[];
135 warnings: Message[];
136}
137
138export interface ServeOptions {
139 port?: number;
140 host?: string;
141 servedir?: string;
142 onRequest?: (args: ServeOnRequestArgs) => void;
143}
144
145export interface ServeOnRequestArgs {
146 remoteAddress: string;
147 method: string;
148 path: string;
149 status: number;
150 timeInMS: number; // The time to generate the response, not to send it
151}
152
153export interface ServeResult {
154 port: number;
155 host: string;
156 wait: Promise<void>;
157 stop: () => void;
158}
159
160export interface TransformOptions extends CommonOptions {
161 tsconfigRaw?: string | {
162 compilerOptions?: {
163 jsxFactory?: string,
164 jsxFragmentFactory?: string,
165 useDefineForClassFields?: boolean,
166 importsNotUsedAsValues?: 'remove' | 'preserve' | 'error',
167 },
168 };
169
170 sourcefile?: string;
171 loader?: Loader;
172 banner?: string;
173 footer?: string;
174}
175
176export interface TransformResult {
177 code: string;
178 map: string;
179 warnings: Message[];
180}
181
182export interface TransformFailure extends Error {
183 errors: Message[];
184 warnings: Message[];
185}
186
187export interface Plugin {
188 name: string;
189 setup: (build: PluginBuild) => (void | Promise<void>);
190}
191
192export interface PluginBuild {
193 initialOptions: BuildOptions;
194 onStart(callback: () =>
195 (OnStartResult | null | void | Promise<OnStartResult | null | void>)): void;
196 onEnd(callback: (result: BuildResult) =>
197 (void | Promise<void>)): void;
198 onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
199 (OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void;
200 onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
201 (OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void;
202}
203
204export interface OnStartResult {
205 errors?: PartialMessage[];
206 warnings?: PartialMessage[];
207}
208
209export interface OnResolveOptions {
210 filter: RegExp;
211 namespace?: string;
212}
213
214export interface OnResolveArgs {
215 path: string;
216 importer: string;
217 namespace: string;
218 resolveDir: string;
219 kind: ImportKind;
220 pluginData: any;
221}
222
223export type ImportKind =
224 | 'entry-point'
225
226 // JS
227 | 'import-statement'
228 | 'require-call'
229 | 'dynamic-import'
230 | 'require-resolve'
231
232 // CSS
233 | 'import-rule'
234 | 'url-token'
235
236export interface OnResolveResult {
237 pluginName?: string;
238
239 errors?: PartialMessage[];
240 warnings?: PartialMessage[];
241
242 path?: string;
243 external?: boolean;
244 sideEffects?: boolean;
245 namespace?: string;
246 pluginData?: any;
247
248 watchFiles?: string[];
249 watchDirs?: string[];
250}
251
252export interface OnLoadOptions {
253 filter: RegExp;
254 namespace?: string;
255}
256
257export interface OnLoadArgs {
258 path: string;
259 namespace: string;
260 pluginData: any;
261}
262
263export interface OnLoadResult {
264 pluginName?: string;
265
266 errors?: PartialMessage[];
267 warnings?: PartialMessage[];
268
269 contents?: string | Uint8Array;
270 resolveDir?: string;
271 loader?: Loader;
272 pluginData?: any;
273
274 watchFiles?: string[];
275 watchDirs?: string[];
276}
277
278export interface PartialMessage {
279 pluginName?: string;
280 text?: string;
281 location?: Partial<Location> | null;
282 notes?: PartialNote[];
283 detail?: any;
284}
285
286export interface PartialNote {
287 text?: string;
288 location?: Partial<Location> | null;
289}
290
291export interface Metafile {
292 inputs: {
293 [path: string]: {
294 bytes: number
295 imports: {
296 path: string
297 kind: ImportKind
298 }[]
299 }
300 }
301 outputs: {
302 [path: string]: {
303 bytes: number
304 inputs: {
305 [path: string]: {
306 bytesInOutput: number
307 }
308 }
309 imports: {
310 path: string
311 kind: ImportKind
312 }[]
313 exports: string[]
314 entryPoint?: string
315 }
316 }
317}
318
319export interface FormatMessagesOptions {
320 kind: 'error' | 'warning';
321 color?: boolean;
322 terminalWidth?: number;
323}
324
325export interface AnalyzeMetafileOptions {
326 color?: boolean;
327 verbose?: boolean;
328}
329
330// This function invokes the "esbuild" command-line tool for you. It returns a
331// promise that either resolves with a "BuildResult" object or rejects with a
332// "BuildFailure" object.
333//
334// Works in node: yes
335// Works in browser: yes
336export declare function build(options: BuildOptions & { write: false }): Promise<BuildResult & { outputFiles: OutputFile[] }>;
337export declare function build(options: BuildOptions & { incremental: true }): Promise<BuildIncremental>;
338export declare function build(options: BuildOptions): Promise<BuildResult>;
339
340// This function is similar to "build" but it serves the resulting files over
341// HTTP on a localhost address with the specified port.
342//
343// Works in node: yes
344// Works in browser: no
345export declare function serve(serveOptions: ServeOptions, buildOptions: BuildOptions): Promise<ServeResult>;
346
347// This function transforms a single JavaScript file. It can be used to minify
348// JavaScript, convert TypeScript/JSX to JavaScript, or convert newer JavaScript
349// to older JavaScript. It returns a promise that is either resolved with a
350// "TransformResult" object or rejected with a "TransformFailure" object.
351//
352// Works in node: yes
353// Works in browser: yes
354export declare function transform(input: string, options?: TransformOptions): Promise<TransformResult>;
355
356// Converts log messages to formatted message strings suitable for printing in
357// the terminal. This allows you to reuse the built-in behavior of esbuild's
358// log message formatter. This is a batch-oriented API for efficiency.
359//
360// Works in node: yes
361// Works in browser: yes
362export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>;
363
364// Pretty-prints an analysis of the metafile JSON to a string. This is just for
365// convenience to be able to match esbuild's pretty-printing exactly. If you want
366// to customize it, you can just inspect the data in the metafile yourself.
367//
368// Works in node: yes
369// Works in browser: yes
370export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>;
371
372// A synchronous version of "build".
373//
374// Works in node: yes
375// Works in browser: no
376export declare function buildSync(options: BuildOptions & { write: false }): BuildResult & { outputFiles: OutputFile[] };
377export declare function buildSync(options: BuildOptions): BuildResult;
378
379// A synchronous version of "transform".
380//
381// Works in node: yes
382// Works in browser: no
383export declare function transformSync(input: string, options?: TransformOptions): TransformResult;
384
385// A synchronous version of "formatMessages".
386//
387// Works in node: yes
388// Works in browser: no
389export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[];
390
391// A synchronous version of "analyzeMetafile".
392//
393// Works in node: yes
394// Works in browser: no
395export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string;
396
397// This configures the browser-based version of esbuild. It is necessary to
398// call this first and wait for the returned promise to be resolved before
399// making other API calls when using esbuild in the browser.
400//
401// Works in node: yes
402// Works in browser: yes ("options" is required)
403export declare function initialize(options: InitializeOptions): Promise<void>;
404
405export interface InitializeOptions {
406 // The URL of the "esbuild.wasm" file. This must be provided when running
407 // esbuild in the browser.
408 wasmURL?: string
409
410 // By default esbuild runs the WebAssembly-based browser API in a web worker
411 // to avoid blocking the UI thread. This can be disabled by setting "worker"
412 // to false.
413 worker?: boolean
414}
415
416export let version: string;
Note: See TracBrowser for help on using the repository browser.