@utoo/pack 0.0.1-alpha.1 → 0.0.1-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/binding.d.ts +153 -100
- package/cjs/build.d.ts +2 -0
- package/cjs/build.js +53 -0
- package/cjs/dev.d.ts +42 -0
- package/cjs/dev.js +355 -0
- package/cjs/hmr.d.ts +80 -0
- package/cjs/hmr.js +285 -0
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +5 -73
- package/cjs/mkcert.d.ts +7 -0
- package/cjs/mkcert.js +183 -0
- package/cjs/project.d.ts +3 -3
- package/cjs/project.js +4 -11
- package/cjs/types.d.ts +16 -2
- package/cjs/util.d.ts +12 -1
- package/cjs/util.js +102 -1
- package/config_schema.json +710 -0
- package/esm/binding.d.ts +153 -100
- package/esm/build.d.ts +2 -0
- package/esm/build.js +50 -0
- package/esm/dev.d.ts +42 -0
- package/esm/dev.js +339 -0
- package/esm/hmr.d.ts +80 -0
- package/esm/hmr.js +278 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -69
- package/esm/mkcert.d.ts +7 -0
- package/esm/mkcert.js +176 -0
- package/esm/project.d.ts +3 -3
- package/esm/project.js +2 -9
- package/esm/types.d.ts +16 -2
- package/esm/util.d.ts +12 -1
- package/esm/util.js +98 -1
- package/package.json +38 -23
- package/bin/cli.js +0 -9
- package/global.d.ts +0 -10
package/cjs/binding.d.ts
CHANGED
|
@@ -4,70 +4,78 @@
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
6
|
export declare class ExternalObject<T> {
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
9
|
-
[K: symbol]: T
|
|
10
|
-
}
|
|
7
|
+
readonly "": {
|
|
8
|
+
readonly "": unique symbol;
|
|
9
|
+
[K: symbol]: T;
|
|
10
|
+
};
|
|
11
11
|
}
|
|
12
12
|
export interface TransformOutput {
|
|
13
|
-
code: string
|
|
14
|
-
map?: string
|
|
15
|
-
output?: string
|
|
16
|
-
diagnostics: Array<string
|
|
17
|
-
}
|
|
18
|
-
export interface NapiEndpointConfig {
|
|
19
|
-
|
|
13
|
+
code: string;
|
|
14
|
+
map?: string;
|
|
15
|
+
output?: string;
|
|
16
|
+
diagnostics: Array<string>;
|
|
20
17
|
}
|
|
18
|
+
|
|
19
|
+
export interface NapiEndpointConfig {}
|
|
21
20
|
export interface NapiServerPath {
|
|
22
|
-
path: string
|
|
23
|
-
contentHash: string
|
|
21
|
+
path: string;
|
|
22
|
+
contentHash: string;
|
|
24
23
|
}
|
|
25
24
|
export interface NapiWrittenEndpoint {
|
|
26
|
-
type: string
|
|
27
|
-
entryPath?: string
|
|
28
|
-
clientPaths: Array<string
|
|
29
|
-
serverPaths: Array<NapiServerPath
|
|
30
|
-
config: NapiEndpointConfig
|
|
31
|
-
}
|
|
32
|
-
export declare function endpointWriteToDisk(endpoint: {
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
type: string;
|
|
26
|
+
entryPath?: string;
|
|
27
|
+
clientPaths: Array<string>;
|
|
28
|
+
serverPaths: Array<NapiServerPath>;
|
|
29
|
+
config: NapiEndpointConfig;
|
|
30
|
+
}
|
|
31
|
+
export declare function endpointWriteToDisk(endpoint: {
|
|
32
|
+
__napiType: "Endpoint";
|
|
33
|
+
}): Promise<TurbopackResult>;
|
|
34
|
+
export declare function endpointServerChangedSubscribe(
|
|
35
|
+
endpoint: { __napiType: "Endpoint" },
|
|
36
|
+
issues: boolean,
|
|
37
|
+
func: (...args: any[]) => any,
|
|
38
|
+
): { __napiType: "RootTask" };
|
|
39
|
+
export declare function endpointClientChangedSubscribe(
|
|
40
|
+
endpoint: { __napiType: "Endpoint" },
|
|
41
|
+
func: (...args: any[]) => any,
|
|
42
|
+
): { __napiType: "RootTask" };
|
|
35
43
|
export interface NapiEnvVar {
|
|
36
|
-
name: string
|
|
37
|
-
value: string
|
|
44
|
+
name: string;
|
|
45
|
+
value: string;
|
|
38
46
|
}
|
|
39
47
|
export interface NapiWatchOptions {
|
|
40
48
|
/** Whether to watch the filesystem for file changes. */
|
|
41
|
-
enable: boolean
|
|
49
|
+
enable: boolean;
|
|
42
50
|
/**
|
|
43
51
|
* Enable polling at a certain interval if the native file watching doesn't work (e.g.
|
|
44
52
|
* docker).
|
|
45
53
|
*/
|
|
46
|
-
pollIntervalMs?: number
|
|
54
|
+
pollIntervalMs?: number;
|
|
47
55
|
}
|
|
48
56
|
export interface NapiProjectOptions {
|
|
49
57
|
/**
|
|
50
58
|
* A root path from which all files must be nested under. Trying to access
|
|
51
59
|
* a file outside this root will fail. Think of this as a chroot.
|
|
52
60
|
*/
|
|
53
|
-
rootPath: string
|
|
61
|
+
rootPath: string;
|
|
54
62
|
/** A path inside the root_path which contains the app/pages directories. */
|
|
55
|
-
projectPath: string
|
|
63
|
+
projectPath: string;
|
|
56
64
|
/** Filesystem watcher options. */
|
|
57
|
-
watch: NapiWatchOptions
|
|
65
|
+
watch: NapiWatchOptions;
|
|
58
66
|
/** The contents of config.js, serialized to JSON. */
|
|
59
|
-
config: string
|
|
67
|
+
config: string;
|
|
60
68
|
/** A map of environment variables to use when compiling code. */
|
|
61
|
-
processEnv: Array<NapiEnvVar
|
|
69
|
+
processEnv: Array<NapiEnvVar>;
|
|
62
70
|
/**
|
|
63
71
|
* A map of environment variables which should get injected at compile
|
|
64
72
|
* time.
|
|
65
73
|
*/
|
|
66
|
-
processDefineEnv: NapiDefineEnv
|
|
74
|
+
processDefineEnv: NapiDefineEnv;
|
|
67
75
|
/** The mode in which Next.js is running. */
|
|
68
|
-
dev: boolean
|
|
76
|
+
dev: boolean;
|
|
69
77
|
/** The build id. */
|
|
70
|
-
buildId: string
|
|
78
|
+
buildId: string;
|
|
71
79
|
}
|
|
72
80
|
/** [NapiProjectOptions] with all fields optional. */
|
|
73
81
|
export interface NapiPartialProjectOptions {
|
|
@@ -75,53 +83,61 @@ export interface NapiPartialProjectOptions {
|
|
|
75
83
|
* A root path from which all files must be nested under. Trying to access
|
|
76
84
|
* a file outside this root will fail. Think of this as a chroot.
|
|
77
85
|
*/
|
|
78
|
-
rootPath?: string
|
|
86
|
+
rootPath?: string;
|
|
79
87
|
/** A path inside the root_path which contains the app/pages directories. */
|
|
80
|
-
projectPath?: string
|
|
88
|
+
projectPath?: string;
|
|
81
89
|
/** Filesystem watcher options. */
|
|
82
|
-
watch?: NapiWatchOptions
|
|
90
|
+
watch?: NapiWatchOptions;
|
|
83
91
|
/** The contents of config.js, serialized to JSON. */
|
|
84
|
-
config?: string
|
|
92
|
+
config?: string;
|
|
85
93
|
/** A map of environment variables to use when compiling code. */
|
|
86
|
-
processEnv?: Array<NapiEnvVar
|
|
94
|
+
processEnv?: Array<NapiEnvVar>;
|
|
87
95
|
/**
|
|
88
96
|
* A map of environment variables which should get injected at compile
|
|
89
97
|
* time.
|
|
90
98
|
*/
|
|
91
|
-
processDefineEnv?: NapiDefineEnv
|
|
99
|
+
processDefineEnv?: NapiDefineEnv;
|
|
92
100
|
/** The mode in which Next.js is running. */
|
|
93
|
-
dev?: boolean
|
|
101
|
+
dev?: boolean;
|
|
94
102
|
/** The build id. */
|
|
95
|
-
buildId?: string
|
|
103
|
+
buildId?: string;
|
|
96
104
|
/**
|
|
97
105
|
* When the code is minified, this opts out of the default mangling of
|
|
98
106
|
* local names for variables, functions etc., which can be useful for
|
|
99
107
|
* debugging/profiling purposes.
|
|
100
108
|
*/
|
|
101
|
-
noMangling?: boolean
|
|
109
|
+
noMangling?: boolean;
|
|
102
110
|
}
|
|
103
111
|
export interface NapiDefineEnv {
|
|
104
|
-
client: Array<NapiEnvVar
|
|
105
|
-
edge: Array<NapiEnvVar
|
|
106
|
-
nodejs: Array<NapiEnvVar
|
|
112
|
+
client: Array<NapiEnvVar>;
|
|
113
|
+
edge: Array<NapiEnvVar>;
|
|
114
|
+
nodejs: Array<NapiEnvVar>;
|
|
107
115
|
}
|
|
108
116
|
export interface NapiTurboEngineOptions {
|
|
109
117
|
/** Use the new backend with persistent caching enabled. */
|
|
110
|
-
persistentCaching?: boolean
|
|
118
|
+
persistentCaching?: boolean;
|
|
111
119
|
/** An upper bound of memory that turbopack will attempt to stay under. */
|
|
112
|
-
memoryLimit?: number
|
|
120
|
+
memoryLimit?: number;
|
|
113
121
|
/** Track dependencies between tasks. If false, any change during build will error. */
|
|
114
|
-
dependencyTracking?: boolean
|
|
122
|
+
dependencyTracking?: boolean;
|
|
115
123
|
}
|
|
116
|
-
export declare function projectNew(
|
|
117
|
-
|
|
124
|
+
export declare function projectNew(
|
|
125
|
+
options: NapiProjectOptions,
|
|
126
|
+
turboEngineOptions: NapiTurboEngineOptions,
|
|
127
|
+
): Promise<{ __napiType: "Project" }>;
|
|
128
|
+
export declare function projectUpdate(
|
|
129
|
+
project: { __napiType: "Project" },
|
|
130
|
+
options: NapiPartialProjectOptions,
|
|
131
|
+
): Promise<void>;
|
|
118
132
|
/**
|
|
119
133
|
* Runs exit handlers for the project registered using the [`ExitHandler`] API.
|
|
120
134
|
*
|
|
121
135
|
* This is called by `project_shutdown`, so if you're calling that API, you shouldn't call this
|
|
122
136
|
* one.
|
|
123
137
|
*/
|
|
124
|
-
export declare function projectOnExit(project: {
|
|
138
|
+
export declare function projectOnExit(project: {
|
|
139
|
+
__napiType: "Project";
|
|
140
|
+
}): Promise<void>;
|
|
125
141
|
/**
|
|
126
142
|
* Runs `project_on_exit`, and then waits for turbo_tasks to gracefully shut down.
|
|
127
143
|
*
|
|
@@ -129,25 +145,39 @@ export declare function projectOnExit(project: { __napiType: "Project" }): Promi
|
|
|
129
145
|
* it's skipped in the development server (`project_on_exit` is used instead with a short timeout),
|
|
130
146
|
* where we prioritize fast exit and user responsiveness over all else.
|
|
131
147
|
*/
|
|
132
|
-
export declare function projectShutdown(project: {
|
|
148
|
+
export declare function projectShutdown(project: {
|
|
149
|
+
__napiType: "Project";
|
|
150
|
+
}): Promise<void>;
|
|
133
151
|
export interface NapiEntrypoints {
|
|
134
|
-
apps?: Array<ExternalObject<ExternalEndpoint
|
|
135
|
-
libraries?: Array<ExternalObject<ExternalEndpoint
|
|
152
|
+
apps?: Array<ExternalObject<ExternalEndpoint>>;
|
|
153
|
+
libraries?: Array<ExternalObject<ExternalEndpoint>>;
|
|
136
154
|
}
|
|
137
|
-
export declare function projectWriteAllEntrypointsToDisk(project: {
|
|
138
|
-
|
|
139
|
-
|
|
155
|
+
export declare function projectWriteAllEntrypointsToDisk(project: {
|
|
156
|
+
__napiType: "Project";
|
|
157
|
+
}): Promise<TurbopackResult>;
|
|
158
|
+
export declare function projectEntrypointsSubscribe(
|
|
159
|
+
project: { __napiType: "Project" },
|
|
160
|
+
func: (...args: any[]) => any,
|
|
161
|
+
): { __napiType: "RootTask" };
|
|
162
|
+
export declare function projectHmrEvents(
|
|
163
|
+
project: { __napiType: "Project" },
|
|
164
|
+
identifier: string,
|
|
165
|
+
func: (...args: any[]) => any,
|
|
166
|
+
): { __napiType: "RootTask" };
|
|
140
167
|
export interface HmrIdentifiers {
|
|
141
|
-
identifiers: Array<string
|
|
168
|
+
identifiers: Array<string>;
|
|
142
169
|
}
|
|
143
|
-
export declare function projectHmrIdentifiersSubscribe(
|
|
170
|
+
export declare function projectHmrIdentifiersSubscribe(
|
|
171
|
+
project: { __napiType: "Project" },
|
|
172
|
+
func: (...args: any[]) => any,
|
|
173
|
+
): { __napiType: "RootTask" };
|
|
144
174
|
export interface NapiUpdateMessage {
|
|
145
|
-
updateType: string
|
|
146
|
-
value?: NapiUpdateInfo
|
|
175
|
+
updateType: string;
|
|
176
|
+
value?: NapiUpdateInfo;
|
|
147
177
|
}
|
|
148
178
|
export interface NapiUpdateInfo {
|
|
149
|
-
duration: number
|
|
150
|
-
tasks: number
|
|
179
|
+
duration: number;
|
|
180
|
+
tasks: number;
|
|
151
181
|
}
|
|
152
182
|
/**
|
|
153
183
|
* Subscribes to lifecycle events of the compilation.
|
|
@@ -162,61 +192,84 @@ export interface NapiUpdateInfo {
|
|
|
162
192
|
*
|
|
163
193
|
* The signature of the `func` is `(update_message: UpdateMessage) => void`.
|
|
164
194
|
*/
|
|
165
|
-
export declare function projectUpdateInfoSubscribe(
|
|
195
|
+
export declare function projectUpdateInfoSubscribe(
|
|
196
|
+
project: { __napiType: "Project" },
|
|
197
|
+
aggregationMs: number,
|
|
198
|
+
func: (...args: any[]) => any,
|
|
199
|
+
): void;
|
|
166
200
|
export interface StackFrame {
|
|
167
|
-
isServer: boolean
|
|
168
|
-
isInternal?: boolean
|
|
169
|
-
originalFile?: string
|
|
170
|
-
file: string
|
|
171
|
-
line?: number
|
|
172
|
-
column?: number
|
|
173
|
-
methodName?: string
|
|
174
|
-
}
|
|
175
|
-
export declare function projectTraceSource(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
201
|
+
isServer: boolean;
|
|
202
|
+
isInternal?: boolean;
|
|
203
|
+
originalFile?: string;
|
|
204
|
+
file: string;
|
|
205
|
+
line?: number;
|
|
206
|
+
column?: number;
|
|
207
|
+
methodName?: string;
|
|
208
|
+
}
|
|
209
|
+
export declare function projectTraceSource(
|
|
210
|
+
project: { __napiType: "Project" },
|
|
211
|
+
frame: StackFrame,
|
|
212
|
+
currentDirectoryFileUrl: string,
|
|
213
|
+
): Promise<StackFrame | null>;
|
|
214
|
+
export declare function projectGetSourceForAsset(
|
|
215
|
+
project: { __napiType: "Project" },
|
|
216
|
+
filePath: string,
|
|
217
|
+
): Promise<string | null>;
|
|
218
|
+
export declare function projectGetSourceMap(
|
|
219
|
+
project: { __napiType: "Project" },
|
|
220
|
+
filePath: string,
|
|
221
|
+
): Promise<string | null>;
|
|
222
|
+
export declare function projectGetSourceMapSync(
|
|
223
|
+
project: { __napiType: "Project" },
|
|
224
|
+
filePath: string,
|
|
225
|
+
): string | null;
|
|
226
|
+
export declare function rootTaskDispose(rootTask: {
|
|
227
|
+
__napiType: "RootTask";
|
|
228
|
+
}): void;
|
|
180
229
|
export interface NapiIssue {
|
|
181
|
-
severity: string
|
|
182
|
-
stage: string
|
|
183
|
-
filePath: string
|
|
184
|
-
title: any
|
|
185
|
-
description?: any
|
|
186
|
-
detail?: any
|
|
187
|
-
source?: NapiIssueSource
|
|
188
|
-
documentationLink: string
|
|
189
|
-
subIssues: Array<NapiIssue
|
|
230
|
+
severity: string;
|
|
231
|
+
stage: string;
|
|
232
|
+
filePath: string;
|
|
233
|
+
title: any;
|
|
234
|
+
description?: any;
|
|
235
|
+
detail?: any;
|
|
236
|
+
source?: NapiIssueSource;
|
|
237
|
+
documentationLink: string;
|
|
238
|
+
subIssues: Array<NapiIssue>;
|
|
190
239
|
}
|
|
191
240
|
export interface NapiIssueSource {
|
|
192
|
-
source: NapiSource
|
|
193
|
-
range?: NapiIssueSourceRange
|
|
241
|
+
source: NapiSource;
|
|
242
|
+
range?: NapiIssueSourceRange;
|
|
194
243
|
}
|
|
195
244
|
export interface NapiIssueSourceRange {
|
|
196
|
-
start: NapiSourcePos
|
|
197
|
-
end: NapiSourcePos
|
|
245
|
+
start: NapiSourcePos;
|
|
246
|
+
end: NapiSourcePos;
|
|
198
247
|
}
|
|
199
248
|
export interface NapiSource {
|
|
200
|
-
ident: string
|
|
201
|
-
content?: string
|
|
249
|
+
ident: string;
|
|
250
|
+
content?: string;
|
|
202
251
|
}
|
|
203
252
|
export interface NapiSourcePos {
|
|
204
|
-
line: number
|
|
205
|
-
column: number
|
|
253
|
+
line: number;
|
|
254
|
+
column: number;
|
|
206
255
|
}
|
|
207
256
|
export interface NapiDiagnostic {
|
|
208
|
-
category: string
|
|
209
|
-
name: string
|
|
210
|
-
payload: Record<string, string
|
|
257
|
+
category: string;
|
|
258
|
+
name: string;
|
|
259
|
+
payload: Record<string, string>;
|
|
211
260
|
}
|
|
212
261
|
/**
|
|
213
262
|
* Initialize tracing subscriber to emit traces. This configures subscribers
|
|
214
263
|
* for Trace Event Format <https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview>.
|
|
215
264
|
*/
|
|
216
|
-
export declare function initCustomTraceSubscriber(
|
|
265
|
+
export declare function initCustomTraceSubscriber(
|
|
266
|
+
traceOutFilePath?: string | undefined | null,
|
|
267
|
+
): ExternalObject<RefCell>;
|
|
217
268
|
/**
|
|
218
269
|
* Teardown currently running tracing subscriber to flush out remaining traces.
|
|
219
270
|
* This should be called when parent node.js process exits, otherwise generated
|
|
220
271
|
* trace may drop traces in the buffer.
|
|
221
272
|
*/
|
|
222
|
-
export declare function teardownTraceSubscriber(
|
|
273
|
+
export declare function teardownTraceSubscriber(
|
|
274
|
+
guardExternal: ExternalObject<RefCell>,
|
|
275
|
+
): void;
|
package/cjs/build.d.ts
ADDED
package/cjs/build.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build = build;
|
|
4
|
+
const nanoid_1 = require("nanoid");
|
|
5
|
+
const project_1 = require("./project");
|
|
6
|
+
const util_1 = require("./util");
|
|
7
|
+
const xcodeProfile_1 = require("./xcodeProfile");
|
|
8
|
+
async function build(projectOptions, projectPath, rootPath) {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
|
+
(0, util_1.blockStdout)();
|
|
11
|
+
if (process.env.XCODE_PROFILE) {
|
|
12
|
+
await (0, xcodeProfile_1.xcodeProfilingReady)();
|
|
13
|
+
}
|
|
14
|
+
const createProject = (0, project_1.projectFactory)();
|
|
15
|
+
const project = await createProject({
|
|
16
|
+
processEnv: (_a = projectOptions.processEnv) !== null && _a !== void 0 ? _a : {},
|
|
17
|
+
processDefineEnv: (0, util_1.createDefineEnv)({
|
|
18
|
+
config: projectOptions.config,
|
|
19
|
+
dev: (_b = projectOptions.dev) !== null && _b !== void 0 ? _b : false,
|
|
20
|
+
optionDefineEnv: projectOptions.processDefineEnv,
|
|
21
|
+
}),
|
|
22
|
+
watch: (_c = projectOptions.watch) !== null && _c !== void 0 ? _c : {
|
|
23
|
+
enable: false,
|
|
24
|
+
},
|
|
25
|
+
dev: (_d = projectOptions.dev) !== null && _d !== void 0 ? _d : false,
|
|
26
|
+
buildId: (0, nanoid_1.nanoid)(),
|
|
27
|
+
config: projectOptions.config,
|
|
28
|
+
projectPath: projectPath || process.cwd(),
|
|
29
|
+
rootPath: rootPath || projectPath || process.cwd(),
|
|
30
|
+
}, {
|
|
31
|
+
persistentCaching: false,
|
|
32
|
+
});
|
|
33
|
+
const entrypoints = await project.writeAllEntrypointsToDisk();
|
|
34
|
+
const topLevelErrors = [];
|
|
35
|
+
const topLevelWarnings = [];
|
|
36
|
+
for (const issue of entrypoints.issues) {
|
|
37
|
+
if (issue.severity === "error" || issue.severity === "fatal") {
|
|
38
|
+
topLevelErrors.push((0, util_1.formatIssue)(issue));
|
|
39
|
+
}
|
|
40
|
+
else if ((0, util_1.isRelevantWarning)(issue)) {
|
|
41
|
+
topLevelWarnings.push((0, util_1.formatIssue)(issue));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (topLevelWarnings.length > 0) {
|
|
45
|
+
console.warn(`Turbopack build encountered ${topLevelWarnings.length} warnings:\n${topLevelWarnings.join("\n")}`);
|
|
46
|
+
}
|
|
47
|
+
if (topLevelErrors.length > 0) {
|
|
48
|
+
throw new Error(`Turbopack build failed with ${topLevelErrors.length} errors:\n${topLevelErrors.join("\n")}`);
|
|
49
|
+
}
|
|
50
|
+
await project.shutdown();
|
|
51
|
+
// TODO: Maybe run tasks in worker is a better way, see
|
|
52
|
+
// https://github.com/vercel/next.js/blob/512d8283054407ab92b2583ecce3b253c3be7b85/packages/next/src/lib/worker.ts
|
|
53
|
+
}
|
package/cjs/dev.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from "http";
|
|
2
|
+
import send from "send";
|
|
3
|
+
import { Duplex, Writable } from "stream";
|
|
4
|
+
import { BundleOptions } from "./types";
|
|
5
|
+
export declare function serve(options: BundleOptions, projectPath: string, rootPath?: string, serverOptions?: StartServerOptions): Promise<void>;
|
|
6
|
+
export interface SelfSignedCertificate {
|
|
7
|
+
key: string;
|
|
8
|
+
cert: string;
|
|
9
|
+
rootCA?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface StartServerOptions {
|
|
12
|
+
port: number;
|
|
13
|
+
https?: boolean;
|
|
14
|
+
hostname?: string;
|
|
15
|
+
selfSignedCertificate?: SelfSignedCertificate;
|
|
16
|
+
}
|
|
17
|
+
export type RequestHandler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
18
|
+
export type UpgradeHandler = (req: IncomingMessage, socket: Duplex, head: Buffer) => Promise<void>;
|
|
19
|
+
export type ServerInitResult = {
|
|
20
|
+
requestHandler: RequestHandler;
|
|
21
|
+
upgradeHandler: UpgradeHandler;
|
|
22
|
+
closeUpgraded: () => void;
|
|
23
|
+
};
|
|
24
|
+
export declare function startServer(serverOptions: StartServerOptions, bundleOptions: BundleOptions, projectPath: string, rootPath?: string): Promise<void>;
|
|
25
|
+
export declare function initialize(bundleOptions: BundleOptions, projectPath: string, rootPath?: string): Promise<ServerInitResult>;
|
|
26
|
+
export declare function pipeToNodeResponse(readable: ReadableStream<Uint8Array>, res: ServerResponse, waitUntilForEnd?: Promise<unknown>): Promise<void>;
|
|
27
|
+
export declare function createAbortController(response: Writable): AbortController;
|
|
28
|
+
export declare function isAbortError(e: any): e is Error & {
|
|
29
|
+
name: "AbortError";
|
|
30
|
+
};
|
|
31
|
+
export declare const ResponseAbortedName = "ResponseAborted";
|
|
32
|
+
export declare class ResponseAborted extends Error {
|
|
33
|
+
readonly name = "ResponseAborted";
|
|
34
|
+
}
|
|
35
|
+
export declare class DetachedPromise<T = any> {
|
|
36
|
+
readonly resolve: (value: T | PromiseLike<T>) => void;
|
|
37
|
+
readonly reject: (reason: any) => void;
|
|
38
|
+
readonly promise: Promise<T>;
|
|
39
|
+
constructor();
|
|
40
|
+
}
|
|
41
|
+
export declare function serveStatic(req: IncomingMessage, res: ServerResponse, path: string, opts?: Parameters<typeof send>[2]): Promise<void>;
|
|
42
|
+
export declare function formatHostname(hostname: string): string;
|