UNPKG

2.85 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Buffer } from 'buffer';
3import { ReadStream } from 'fs';
4import { Logger } from './logger';
5import { NexeOptions } from './options';
6import { NexeTarget } from './target';
7import { Bundle } from './fs/bundle';
8import { File } from 'resolve-dependencies';
9declare type StringReplacer = (match: string) => string;
10export interface NexeFile {
11 filename: string;
12 absPath: string;
13 contents: string | Buffer;
14}
15export { NexeOptions };
16export declare class NexeError extends Error {
17 constructor(m: string);
18}
19export declare class NexeCompiler {
20 options: NexeOptions;
21 /**
22 * Epoch of when compilation started
23 */
24 private start;
25 private compileStep;
26 log: Logger;
27 /**
28 * Copy of process.env
29 */
30 env: {
31 [x: string]: string | undefined;
32 TZ?: string | undefined;
33 };
34 /**
35 * Virtual FileSystem
36 */
37 bundle: Bundle;
38 /**
39 * Root directory for the source of the current build
40 */
41 src: string;
42 /**
43 * In memory files that are being manipulated by the compiler
44 */
45 files: NexeFile[];
46 /**
47 * Standalone pieces of code run before the application entrypoint
48 */
49 shims: string[];
50 /**
51 * The last shim (defaults to "require('module').runMain()")
52 */
53 startup: string;
54 /**
55 * The main entrypoint filename for your application - eg. node mainFile.js
56 */
57 entrypoint: string | undefined;
58 /**
59 * Not used
60 */
61 targets: NexeTarget[];
62 /**
63 * Current target of the compiler
64 */
65 target: NexeTarget;
66 /**
67 * Output filename (-o myapp.exe)
68 */
69 output: string;
70 /**
71 * Flag to indicate whether or notstdin was used for input
72 */
73 stdinUsed: boolean;
74 /**
75 * Path to the configure script
76 */
77 configureScript: string;
78 /**
79 * The file path of node binary
80 */
81 nodeSrcBinPath: string;
82 /**
83 * Remote asset path if available
84 */
85 remoteAsset: string;
86 constructor(options: NexeOptions);
87 addResource(absoluteFileName: string, content?: Buffer | string | File): Promise<number>;
88 readFileAsync(file: string): Promise<NexeFile>;
89 writeFileAsync(file: string, contents: string | Buffer): Promise<void>;
90 replaceInFileAsync(file: string, replace: string | RegExp, value: string | StringReplacer): Promise<void>;
91 setFileContentsAsync(file: string, contents: string | Buffer): Promise<void>;
92 quit(error?: any): Promise<unknown>;
93 assertBuild(): void;
94 getNodeExecutableLocation(target?: NexeTarget): string;
95 private _runBuildCommandAsync;
96 private _configureAsync;
97 build(): Promise<ReadStream>;
98 private _shouldCompileBinaryAsync;
99 compileAsync(target: NexeTarget): Promise<any>;
100 code(): string;
101 private _assembleDeliverable;
102}