@utoo/pack 0.0.1-alpha.18 → 0.0.1-alpha.2

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.
@@ -1,7 +1,8 @@
1
+ import { ModernSourceMapPayload } from "./sourceMap";
2
+ import { Project, ProjectOptions, Update as TurbopackUpdate } from "./types";
3
+ import type webpack from "webpack";
1
4
  import { IncomingMessage } from "http";
2
5
  import { Duplex } from "stream";
3
- import type webpack from "webpack";
4
- import { BundleOptions, Project, Update as TurbopackUpdate } from "./types";
5
6
  export declare const enum HMR_ACTIONS_SENT_TO_BROWSER {
6
7
  RELOAD = "reload",
7
8
  CLIENT_CHANGES = "clientChanges",
@@ -16,6 +17,10 @@ export interface TurbopackMessageAction {
16
17
  action: HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_MESSAGE;
17
18
  data: TurbopackUpdate | TurbopackUpdate[];
18
19
  }
20
+ export interface TurbopackMessageAction {
21
+ action: HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_MESSAGE;
22
+ data: TurbopackUpdate | TurbopackUpdate[];
23
+ }
19
24
  export interface TurbopackConnectedAction {
20
25
  action: HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_CONNECTED;
21
26
  data: {
@@ -60,12 +65,14 @@ export interface HotReloaderInterface {
60
65
  clearHmrServerError(): void;
61
66
  start(): Promise<void>;
62
67
  send(action: HMR_ACTION_TYPES): void;
63
- onHMR(req: IncomingMessage, socket: Duplex, head: Buffer, onUpgrade?: (client: {
68
+ onHMR(req: IncomingMessage, _socket: Duplex, head: Buffer, onUpgrade: (client: {
64
69
  send(data: string): void;
65
70
  }) => void): void;
66
71
  buildFallbackError(): Promise<void>;
67
72
  close(): void;
68
73
  }
74
+ type FindSourceMapPayload = (sourceURL: string) => ModernSourceMapPayload | undefined;
75
+ export declare function setBundlerFindSourceMapImplementation(findSourceMapImplementation: FindSourceMapPayload): void;
69
76
  export type ChangeSubscriptions = Map<string, Promise<AsyncIterableIterator<TurbopackResult>>>;
70
77
  export type ReadyIds = Set<string>;
71
78
  export type StartBuilding = (id: string, forceRebuild: boolean) => () => void;
@@ -76,5 +83,5 @@ export type ClientState = {
76
83
  };
77
84
  export type SendHmr = (id: string, payload: HMR_ACTION_TYPES) => void;
78
85
  export declare const FAST_REFRESH_RUNTIME_RELOAD = "Fast Refresh had to perform a full reload due to a runtime error.";
79
- export declare function createHotReloader(bundleOptions: BundleOptions, projectPath?: string, rootPath?: string): Promise<HotReloaderInterface>;
86
+ export declare function createHotReloader(projectOptions: ProjectOptions, projectPath?: string, rootPath?: string): Promise<HotReloaderInterface>;
80
87
  export {};
@@ -1,30 +1,71 @@
1
- import { nanoid } from "nanoid";
2
1
  import ws from "ws";
2
+ import { join } from "path";
3
+ import { pathToFileURL } from "url";
3
4
  import { projectFactory } from "./project";
4
5
  import { createDefineEnv, debounce, processIssues } from "./util";
6
+ import { nanoid } from "nanoid";
5
7
  const wsServer = new ws.Server({ noServer: true });
6
8
  const sessionId = Math.floor(Number.MAX_SAFE_INTEGER * Math.random());
9
+ /**
10
+ * Replaces turbopack:///[project] with the specified project in the `source` field.
11
+ */
12
+ function rewriteTurbopackSources(projectRoot, sourceMap) {
13
+ if ("sections" in sourceMap) {
14
+ for (const section of sourceMap.sections) {
15
+ rewriteTurbopackSources(projectRoot, section.map);
16
+ }
17
+ }
18
+ else {
19
+ for (let i = 0; i < sourceMap.sources.length; i++) {
20
+ sourceMap.sources[i] = pathToFileURL(join(projectRoot, sourceMap.sources[i].replace(/turbopack:\/\/\/\[project\]/, ""))).toString();
21
+ }
22
+ }
23
+ }
24
+ function getSourceMapFromTurbopack(project, projectRoot, sourceURL) {
25
+ let sourceMapJson = null;
26
+ try {
27
+ sourceMapJson = project.getSourceMapSync(sourceURL);
28
+ }
29
+ catch (err) { }
30
+ if (sourceMapJson === null) {
31
+ return undefined;
32
+ }
33
+ else {
34
+ const payload = JSON.parse(sourceMapJson);
35
+ // The sourcemap from Turbopack is not yet written to disk so its `sources`
36
+ // are not absolute paths yet. We need to rewrite them to be absolute paths.
37
+ rewriteTurbopackSources(projectRoot, payload);
38
+ return payload;
39
+ }
40
+ }
41
+ // Find a source map using the bundler's API.
42
+ // This is only a fallback for when Node.js fails to due to bugs e.g. https://github.com/nodejs/node/issues/52102
43
+ // TODO: Remove once all supported Node.js versions are fixed.
44
+ // TODO(veil): Set from Webpack as well
45
+ let bundlerFindSourceMapPayload = () => undefined;
46
+ export function setBundlerFindSourceMapImplementation(findSourceMapImplementation) {
47
+ bundlerFindSourceMapPayload = findSourceMapImplementation;
48
+ }
7
49
  export const FAST_REFRESH_RUNTIME_RELOAD = "Fast Refresh had to perform a full reload due to a runtime error.";
8
- export async function createHotReloader(bundleOptions, projectPath, rootPath) {
9
- var _a;
50
+ export async function createHotReloader(projectOptions, projectPath, rootPath) {
51
+ var _a, _b;
10
52
  const createProject = projectFactory();
11
53
  const project = await createProject({
12
- processEnv: (_a = bundleOptions.processEnv) !== null && _a !== void 0 ? _a : {},
13
- defineEnv: createDefineEnv({
14
- config: bundleOptions.config,
54
+ processEnv: (_a = projectOptions.processEnv) !== null && _a !== void 0 ? _a : {},
55
+ processDefineEnv: createDefineEnv({
56
+ config: projectOptions.config,
15
57
  dev: true,
16
- optionDefineEnv: bundleOptions.defineEnv,
58
+ optionDefineEnv: projectOptions.processDefineEnv,
17
59
  }),
18
- watch: {
19
- enable: true,
60
+ watch: (_b = projectOptions.watch) !== null && _b !== void 0 ? _b : {
61
+ enable: false,
20
62
  },
21
63
  dev: true,
22
- buildId: bundleOptions.buildId || nanoid(),
64
+ buildId: nanoid(),
23
65
  config: {
24
- ...bundleOptions.config,
25
- mode: "development",
66
+ ...projectOptions.config,
26
67
  optimization: {
27
- ...bundleOptions.config.optimization,
68
+ ...projectOptions.config.optimization,
28
69
  minify: false,
29
70
  moduleIds: "named",
30
71
  },
@@ -34,6 +75,7 @@ export async function createHotReloader(bundleOptions, projectPath, rootPath) {
34
75
  }, {
35
76
  persistentCaching: true,
36
77
  });
78
+ setBundlerFindSourceMapImplementation(getSourceMapFromTurbopack.bind(null, project, projectOptions.projectPath));
37
79
  const entrypointsSubscription = project.entrypointsSubscribe();
38
80
  let currentEntriesHandlingResolve;
39
81
  let currentEntriesHandling = new Promise((resolve) => (currentEntriesHandlingResolve = resolve));
@@ -66,6 +108,9 @@ export async function createHotReloader(bundleOptions, projectPath, rootPath) {
66
108
  const sendEnqueuedMessagesDebounce = debounce(sendEnqueuedMessages, 2);
67
109
  function sendTurbopackMessage(payload) {
68
110
  var _a;
111
+ // TODO(PACK-2049): For some reason we end up emitting hundreds of issues messages on bigger apps,
112
+ // a lot of which are duplicates.
113
+ // They are currently not handled on the client at all, so might as well not send them for now.
69
114
  payload.diagnostics = [];
70
115
  payload.issues = [];
71
116
  for (const client of clients) {
@@ -129,9 +174,10 @@ export async function createHotReloader(bundleOptions, projectPath, rootPath) {
129
174
  const hotReloader = {
130
175
  turbopackProject: project,
131
176
  serverStats: null,
177
+ // TODO: Figure out if socket type can match the HotReloaderInterface
132
178
  onHMR(req, socket, head, onUpgrade) {
133
179
  wsServer.handleUpgrade(req, socket, head, (client) => {
134
- onUpgrade === null || onUpgrade === void 0 ? void 0 : onUpgrade(client);
180
+ onUpgrade(client);
135
181
  const subscriptions = new Map();
136
182
  clients.add(client);
137
183
  clientStates.set(client, {
package/esm/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- import { build } from "./build";
2
- import { serve } from "./dev";
3
- import * as webpackCompat from "./webpackCompat";
4
- export { build };
5
- export { serve };
6
- declare const utoopack: {
7
- build: typeof build;
8
- serve: typeof serve;
9
- };
10
- export default utoopack;
11
- export type WebpackConfig = webpackCompat.WebpackConfig;
12
- declare namespace utoopack {
13
- type WebpackConfig = webpackCompat.WebpackConfig;
1
+ import { NapiDiagnostic, NapiIssue } from "./binding";
2
+ export { build } from "./build";
3
+ export { watch } from "./watch";
4
+ declare global {
5
+ export type TurbopackResult<T = {}> = T & {
6
+ issues: NapiIssue[];
7
+ diagnostics: NapiDiagnostic[];
8
+ };
9
+ export type RefCell = {
10
+ readonly __tag: unique symbol;
11
+ };
12
+ export type ExternalEndpoint = {
13
+ readonly __tag: unique symbol;
14
+ };
14
15
  }
package/esm/index.js CHANGED
@@ -1,6 +1,2 @@
1
- import { build } from "./build";
2
- import { serve } from "./dev";
3
- export { build };
4
- export { serve };
5
- const utoopack = { build, serve };
6
- export default utoopack;
1
+ export { build } from "./build";
2
+ export { watch } from "./watch";
package/esm/project.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import type { HmrIdentifiers, NapiUpdateMessage, NapiWrittenEndpoint, StackFrame } from "./binding";
2
1
  import * as binding from "./binding";
2
+ import type { NapiWrittenEndpoint, StackFrame } from "./binding";
3
3
  import { ProjectOptions, RawEntrypoints, Update } from "./types";
4
4
  export declare class TurbopackInternalError extends Error {
5
5
  name: string;
6
6
  constructor(cause: Error);
7
7
  }
8
- export declare function projectFactory(): (options: Required<ProjectOptions>, turboEngineOptions: binding.NapiTurboEngineOptions) => Promise<{
8
+ export declare function projectFactory(): (options: ProjectOptions, turboEngineOptions: binding.NapiTurboEngineOptions) => Promise<{
9
9
  readonly _nativeProject: {
10
10
  __napiType: "Project";
11
11
  };
@@ -32,12 +32,12 @@ export declare function projectFactory(): (options: Required<ProjectOptions>, tu
32
32
  diagnostics: binding.NapiDiagnostic[];
33
33
  }, void, unknown>;
34
34
  hmrEvents(identifier: string): AsyncIterableIterator<TurbopackResult<Update>>;
35
- hmrIdentifiersSubscribe(): AsyncIterableIterator<TurbopackResult<HmrIdentifiers>>;
35
+ hmrIdentifiersSubscribe(): AsyncIterableIterator<TurbopackResult<binding.HmrIdentifiers>>;
36
36
  traceSource(stackFrame: StackFrame, currentDirectoryFileUrl: string): Promise<StackFrame | null>;
37
37
  getSourceForAsset(filePath: string): Promise<string | null>;
38
38
  getSourceMap(filePath: string): Promise<string | null>;
39
39
  getSourceMapSync(filePath: string): string | null;
40
- updateInfoSubscribe(aggregationMs: number): AsyncIterableIterator<TurbopackResult<NapiUpdateMessage>>;
40
+ updateInfoSubscribe(aggregationMs: number): AsyncIterableIterator<TurbopackResult<binding.NapiUpdateMessage>>;
41
41
  shutdown(): Promise<void>;
42
42
  onExit(): Promise<void>;
43
43
  }>;
package/esm/project.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { isDeepStrictEqual } from "util";
2
2
  import * as binding from "./binding";
3
+ import { nanoid } from "nanoid";
3
4
  import { rustifyEnv } from "./util";
4
5
  export class TurbopackInternalError extends Error {
5
6
  constructor(cause) {
@@ -52,6 +53,7 @@ function ensureLoadersHaveSerializableOptions(turbopackRules) {
52
53
  async function serializeConfig(config) {
53
54
  var _a, _b;
54
55
  let configSerializable = { ...config };
56
+ configSerializable.generateBuildId = () => nanoid();
55
57
  if ((_a = configSerializable.module) === null || _a === void 0 ? void 0 : _a.rules) {
56
58
  ensureLoadersHaveSerializableOptions(configSerializable.module.rules);
57
59
  }
@@ -0,0 +1,21 @@
1
+ import { type SourceMapPayload } from "module";
2
+ /**
3
+ * https://tc39.es/source-map/#index-map
4
+ */
5
+ interface IndexSourceMapSection {
6
+ offset: {
7
+ line: number;
8
+ column: number;
9
+ };
10
+ map: ModernRawSourceMap;
11
+ }
12
+ interface IndexSourceMap {
13
+ version: number;
14
+ file: string;
15
+ sections: IndexSourceMapSection[];
16
+ }
17
+ interface ModernRawSourceMap extends SourceMapPayload {
18
+ ignoreList?: number[];
19
+ }
20
+ export type ModernSourceMapPayload = ModernRawSourceMap | IndexSourceMap;
21
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/esm/types.d.ts CHANGED
@@ -1,17 +1,4 @@
1
- import { HmrIdentifiers, NapiDiagnostic, NapiIssue, NapiUpdateMessage, NapiWrittenEndpoint, StackFrame } from "./binding";
2
- declare global {
3
- export type TurbopackResult<T = {}> = T & {
4
- issues: NapiIssue[];
5
- diagnostics: NapiDiagnostic[];
6
- };
7
- export type RefCell = {
8
- readonly __tag: unique symbol;
9
- };
10
- export type ExternalEndpoint = {
11
- readonly __tag: unique symbol;
12
- };
13
- export type RcStr = string;
14
- }
1
+ import { HmrIdentifiers, NapiIssue, NapiUpdateMessage, NapiWrittenEndpoint, StackFrame } from "./binding";
15
2
  export interface BaseUpdate {
16
3
  resource: {
17
4
  headers: unknown;
@@ -66,6 +53,7 @@ export interface DefineEnv {
66
53
  }
67
54
  export interface ExperimentalConfig {
68
55
  }
56
+ export type TurbopackRuleConfigItemOrShortcut = TurbopackRuleConfigItem;
69
57
  export type TurbopackRuleConfigItem = TurbopackRuleConfigItemOptions | {
70
58
  [condition: string]: TurbopackRuleConfigItem;
71
59
  } | false;
@@ -81,7 +69,7 @@ export type TurbopackRuleConfigItemOptions = {
81
69
  as?: string;
82
70
  };
83
71
  export interface ModuleOptions {
84
- rules?: Record<string, TurbopackRuleConfigItem>;
72
+ rules?: Record<string, TurbopackRuleConfigItemOrShortcut>;
85
73
  }
86
74
  export interface ResolveOptions {
87
75
  alias?: Record<string, string | string[] | Record<string, string | string[]>>;
@@ -152,7 +140,6 @@ export interface ConfigComplete {
152
140
  images?: {
153
141
  inlineLimit?: number;
154
142
  };
155
- stats?: boolean;
156
143
  experimental?: ExperimentalConfig;
157
144
  persistentCaching?: boolean;
158
145
  cacheHandler?: string;
@@ -206,25 +193,25 @@ export interface ProjectOptions {
206
193
  /**
207
194
  * A map of environment variables to use when compiling code.
208
195
  */
209
- processEnv?: Record<string, string>;
210
- defineEnv?: DefineEnv;
196
+ processEnv: Record<string, string>;
197
+ processDefineEnv: DefineEnv;
211
198
  /**
212
199
  * Whether to watch the filesystem for file changes.
213
200
  */
214
- watch?: {
201
+ watch: {
215
202
  enable: boolean;
216
203
  pollIntervalMs?: number;
217
204
  };
218
205
  /**
219
206
  * The mode of utoo-pack.
220
207
  */
221
- dev?: boolean;
208
+ dev: boolean;
222
209
  /**
223
210
  * The build id.
224
211
  */
225
- buildId?: string;
212
+ buildId: string;
226
213
  }
227
- export type BundleOptions = Omit<ProjectOptions, "rootPath" | "projectPath">;
214
+ export type BuildOptions = Omit<ProjectOptions, "rootPath" | "projectPath">;
228
215
  export interface Project {
229
216
  update(options: Partial<ProjectOptions>): Promise<void>;
230
217
  entrypointsSubscribe(): AsyncIterableIterator<TurbopackResult<RawEntrypoints>>;
package/esm/util.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NapiIssue } from "./binding";
2
- import { ConfigComplete, DefineEnv, RustifiedEnv, StyledString } from "./types";
2
+ import { DefineEnv, StyledString, RustifiedEnv, ConfigComplete } from "./types";
3
3
  export declare class ModuleBuildError extends Error {
4
4
  name: string;
5
5
  }
package/esm/util.js CHANGED
@@ -1,5 +1,5 @@
1
- import { codeFrameColumns } from "@babel/code-frame";
2
1
  import { bold, green, magenta, red } from "picocolors";
2
+ import { codeFrameColumns } from "@babel/code-frame";
3
3
  import { decodeMagicIdentifier, MAGIC_IDENTIFIER_REGEX, } from "./magicIdentifier";
4
4
  export class ModuleBuildError extends Error {
5
5
  constructor() {
package/esm/watch.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { ProjectOptions } from "./types";
2
+ export declare function watch(options: ProjectOptions, projectPath: string, rootPath?: string): Promise<void>;
package/esm/watch.js ADDED
@@ -0,0 +1,11 @@
1
+ import { createHotReloader } from "./hotReloader";
2
+ import { blockStdout } from "./util";
3
+ import { xcodeProfilingReady } from "./xcodeProfile";
4
+ export async function watch(options, projectPath, rootPath) {
5
+ blockStdout();
6
+ if (process.env.XCODE_PROFILE) {
7
+ await xcodeProfilingReady();
8
+ }
9
+ const hotReloader = await createHotReloader(options, projectPath, rootPath);
10
+ await hotReloader.start();
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utoo/pack",
3
- "version": "0.0.1-alpha.18",
3
+ "version": "0.0.1-alpha.2",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "exports": {
@@ -49,8 +49,7 @@
49
49
  "resolve-url-loader": "^5.0.0",
50
50
  "sass": "1.54.0",
51
51
  "sass-loader": "^13.2.0",
52
- "ws": "^8.18.1",
53
- "send": "0.17.1"
52
+ "ws": "^8.18.1"
54
53
  },
55
54
  "devDependencies": {
56
55
  "@napi-rs/cli": "^2.18.0",
@@ -60,10 +59,6 @@
60
59
  "styled-jsx": "^5.1.6",
61
60
  "typescript": "^5.8.3",
62
61
  "@types/ws": "^8.18.1",
63
- "@types/send": "0.14.4",
64
- "@types/mime-types": "3.0.1"
65
- },
66
- "peerDependencies": {
67
62
  "@types/webpack": "^5.28.5"
68
63
  },
69
64
  "engines": {
@@ -76,17 +71,17 @@
76
71
  "artifacts": "napi artifacts --dir ./src --dist npm",
77
72
  "build:binding": "napi build src --platform --release -p pack-napi --cargo-cwd ../../ --cargo-name pack_napi --features plugin --js binding.js --dts binding.d.ts",
78
73
  "build:binding:local": "napi build src --platform --profile release-local -p pack-napi --cargo-cwd ../../ --cargo-name pack_napi --features plugin --js binding.js --dts binding.d.ts",
79
- "prepublishOnly": "npm run build:esm && npm run build:cjs && napi prepublish -t npm --skip-gh-release",
74
+ "prepublishOnly": "npm run build:esm && npm run build:cjs && napi prepublish -t npm",
80
75
  "version": "napi version"
81
76
  },
82
77
  "repository": "git@github.com:umijs/mako.git",
83
78
  "optionalDependencies": {
84
- "@utoo/pack-darwin-arm64": "0.0.1-alpha.18",
85
- "@utoo/pack-darwin-x64": "0.0.1-alpha.18",
86
- "@utoo/pack-linux-arm64-gnu": "0.0.1-alpha.18",
87
- "@utoo/pack-linux-arm64-musl": "0.0.1-alpha.18",
88
- "@utoo/pack-linux-x64-gnu": "0.0.1-alpha.18",
89
- "@utoo/pack-linux-x64-musl": "0.0.1-alpha.18",
90
- "@utoo/pack-win32-x64-msvc": "0.0.1-alpha.18"
79
+ "@utoo/pack-darwin-arm64": "0.0.1-alpha.2",
80
+ "@utoo/pack-darwin-x64": "0.0.1-alpha.2",
81
+ "@utoo/pack-linux-arm64-gnu": "0.0.1-alpha.2",
82
+ "@utoo/pack-linux-arm64-musl": "0.0.1-alpha.2",
83
+ "@utoo/pack-linux-x64-gnu": "0.0.1-alpha.2",
84
+ "@utoo/pack-linux-x64-musl": "0.0.1-alpha.2",
85
+ "@utoo/pack-win32-x64-msvc": "0.0.1-alpha.2"
91
86
  }
92
87
  }
package/cjs/dev.d.ts DELETED
@@ -1,44 +0,0 @@
1
- import { IncomingMessage, ServerResponse } from "http";
2
- import send from "send";
3
- import { Duplex, Writable } from "stream";
4
- import { BundleOptions } from "./types";
5
- import { WebpackConfig } from "./webpackCompat";
6
- export declare function serve(bundleOptions: BundleOptions, projectPath?: string, rootPath?: string, serverOptions?: StartServerOptions): Promise<void>;
7
- export declare function serve(webpackConfig: WebpackConfig, projectPath?: string, rootPath?: string, serverOptions?: StartServerOptions): Promise<void>;
8
- export interface SelfSignedCertificate {
9
- key: string;
10
- cert: string;
11
- rootCA?: string;
12
- }
13
- export interface StartServerOptions {
14
- port: number;
15
- https?: boolean;
16
- hostname?: string;
17
- selfSignedCertificate?: SelfSignedCertificate;
18
- }
19
- export type RequestHandler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
20
- export type UpgradeHandler = (req: IncomingMessage, socket: Duplex, head: Buffer) => Promise<void>;
21
- export type ServerInitResult = {
22
- requestHandler: RequestHandler;
23
- upgradeHandler: UpgradeHandler;
24
- closeUpgraded: () => void;
25
- };
26
- export declare function startServer(serverOptions: StartServerOptions, bundleOptions: BundleOptions, projectPath: string, rootPath?: string): Promise<void>;
27
- export declare function initialize(bundleOptions: BundleOptions, projectPath: string, rootPath?: string): Promise<ServerInitResult>;
28
- export declare function pipeToNodeResponse(readable: ReadableStream<Uint8Array>, res: ServerResponse, waitUntilForEnd?: Promise<unknown>): Promise<void>;
29
- export declare function createAbortController(response: Writable): AbortController;
30
- export declare function isAbortError(e: any): e is Error & {
31
- name: "AbortError";
32
- };
33
- export declare const ResponseAbortedName = "ResponseAborted";
34
- export declare class ResponseAborted extends Error {
35
- readonly name = "ResponseAborted";
36
- }
37
- export declare class DetachedPromise<T = any> {
38
- readonly resolve: (value: T | PromiseLike<T>) => void;
39
- readonly reject: (reason: any) => void;
40
- readonly promise: Promise<T>;
41
- constructor();
42
- }
43
- export declare function serveStatic(req: IncomingMessage, res: ServerResponse, path: string, opts?: Parameters<typeof send>[2]): Promise<void>;
44
- export declare function formatHostname(hostname: string): string;