@caryhu/codemine-forge 0.0.1-alpha.0
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/README.md +108 -0
- package/dist/build-pipeline/browser-bundle.d.ts +31 -0
- package/dist/build-pipeline/browser-bundle.js +584 -0
- package/dist/build-pipeline/diagnostics.d.ts +7 -0
- package/dist/build-pipeline/diagnostics.js +68 -0
- package/dist/build-pipeline/index.d.ts +3 -0
- package/dist/build-pipeline/index.js +16 -0
- package/dist/build-pipeline/pipeline.d.ts +12 -0
- package/dist/build-pipeline/pipeline.js +273 -0
- package/dist/build-pipeline/types.d.ts +77 -0
- package/dist/build-pipeline/types.js +4 -0
- package/dist/dev-server-preview/diagnostics.d.ts +5 -0
- package/dist/dev-server-preview/diagnostics.js +40 -0
- package/dist/dev-server-preview/index.d.ts +4 -0
- package/dist/dev-server-preview/index.js +16 -0
- package/dist/dev-server-preview/preview-document.d.ts +2 -0
- package/dist/dev-server-preview/preview-document.js +153 -0
- package/dist/dev-server-preview/server.d.ts +26 -0
- package/dist/dev-server-preview/server.js +279 -0
- package/dist/dev-server-preview/types.d.ts +105 -0
- package/dist/dev-server-preview/types.js +4 -0
- package/dist/esbuild-wasm-worker/diagnostics.d.ts +12 -0
- package/dist/esbuild-wasm-worker/diagnostics.js +53 -0
- package/dist/esbuild-wasm-worker/index.d.ts +4 -0
- package/dist/esbuild-wasm-worker/index.js +18 -0
- package/dist/esbuild-wasm-worker/service.d.ts +26 -0
- package/dist/esbuild-wasm-worker/service.js +260 -0
- package/dist/esbuild-wasm-worker/types.d.ts +139 -0
- package/dist/esbuild-wasm-worker/types.js +5 -0
- package/dist/esbuild-wasm-worker/worker-adapter.d.ts +38 -0
- package/dist/esbuild-wasm-worker/worker-adapter.js +165 -0
- package/dist/esbuild-wasm-worker/worker.d.ts +1 -0
- package/dist/esbuild-wasm-worker/worker.js +4 -0
- package/dist/forge-controller.d.ts +38 -0
- package/dist/forge-controller.js +79 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +88 -0
- package/dist/package-resolution/cdn-source.d.ts +11 -0
- package/dist/package-resolution/cdn-source.js +164 -0
- package/dist/package-resolution/diagnostics.d.ts +15 -0
- package/dist/package-resolution/diagnostics.js +51 -0
- package/dist/package-resolution/errors.d.ts +5 -0
- package/dist/package-resolution/errors.js +11 -0
- package/dist/package-resolution/index.d.ts +6 -0
- package/dist/package-resolution/index.js +23 -0
- package/dist/package-resolution/manifest.d.ts +5 -0
- package/dist/package-resolution/manifest.js +128 -0
- package/dist/package-resolution/resolver.d.ts +17 -0
- package/dist/package-resolution/resolver.js +172 -0
- package/dist/package-resolution/types.d.ts +98 -0
- package/dist/package-resolution/types.js +4 -0
- package/dist/terminal-commands/diagnostics.d.ts +3 -0
- package/dist/terminal-commands/diagnostics.js +21 -0
- package/dist/terminal-commands/index.d.ts +7 -0
- package/dist/terminal-commands/index.js +22 -0
- package/dist/terminal-commands/npm-build.d.ts +7 -0
- package/dist/terminal-commands/npm-build.js +63 -0
- package/dist/terminal-commands/npm-dev.d.ts +7 -0
- package/dist/terminal-commands/npm-dev.js +68 -0
- package/dist/terminal-commands/npm-install.d.ts +8 -0
- package/dist/terminal-commands/npm-install.js +56 -0
- package/dist/terminal-commands/parser.d.ts +2 -0
- package/dist/terminal-commands/parser.js +52 -0
- package/dist/terminal-commands/terminal.d.ts +12 -0
- package/dist/terminal-commands/terminal.js +73 -0
- package/dist/terminal-commands/types.d.ts +65 -0
- package/dist/terminal-commands/types.js +4 -0
- package/dist/virtual-file-system/diagnostics.d.ts +14 -0
- package/dist/virtual-file-system/diagnostics.js +55 -0
- package/dist/virtual-file-system/errors.d.ts +5 -0
- package/dist/virtual-file-system/errors.js +11 -0
- package/dist/virtual-file-system/index.d.ts +26 -0
- package/dist/virtual-file-system/index.js +47 -0
- package/dist/virtual-file-system/limits.d.ts +4 -0
- package/dist/virtual-file-system/limits.js +33 -0
- package/dist/virtual-file-system/memory.d.ts +33 -0
- package/dist/virtual-file-system/memory.js +551 -0
- package/dist/virtual-file-system/path.d.ts +9 -0
- package/dist/virtual-file-system/path.js +47 -0
- package/dist/virtual-file-system/storage.d.ts +32 -0
- package/dist/virtual-file-system/storage.js +194 -0
- package/dist/virtual-file-system/types.d.ts +165 -0
- package/dist/virtual-file-system/types.js +2 -0
- package/package.json +43 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSupportedViteDevScript = exports.createDevServerPreview = exports.DefaultDevServerPreview = void 0;
|
|
4
|
+
const package_resolution_1 = require("../package-resolution");
|
|
5
|
+
const diagnostics_1 = require("./diagnostics");
|
|
6
|
+
const preview_document_1 = require("./preview-document");
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
class DefaultDevServerPreview {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.capability = types_1.DEV_SERVER_PREVIEW_CAPABILITY;
|
|
12
|
+
this.listeners = new Set();
|
|
13
|
+
this.sessions = new Map();
|
|
14
|
+
this.nextSessionNumber = 1;
|
|
15
|
+
this.createSessionId =
|
|
16
|
+
options.createSessionId ??
|
|
17
|
+
(() => `dev-${this.nextSessionNumber.toString(36)}`);
|
|
18
|
+
this.now = options.now ?? (() => new Date().toISOString());
|
|
19
|
+
}
|
|
20
|
+
async start(options = {}) {
|
|
21
|
+
const startedAt = this.now();
|
|
22
|
+
const sessionId = options.sessionId ?? this.allocateSessionId();
|
|
23
|
+
const previewUrl = createPreviewUrl(sessionId);
|
|
24
|
+
const record = {
|
|
25
|
+
entry: options.entry,
|
|
26
|
+
session: {
|
|
27
|
+
id: sessionId,
|
|
28
|
+
status: "starting",
|
|
29
|
+
previewUrl,
|
|
30
|
+
revision: 0,
|
|
31
|
+
startedAt,
|
|
32
|
+
updatedAt: startedAt,
|
|
33
|
+
diagnostics: [],
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
this.sessions.set(sessionId, record);
|
|
37
|
+
const devScriptDiagnostics = await this.validateDevScript();
|
|
38
|
+
if (devScriptDiagnostics.length > 0) {
|
|
39
|
+
return this.failStart(record, devScriptDiagnostics, "dev-script");
|
|
40
|
+
}
|
|
41
|
+
const buildResult = await this.options.buildPipeline.build({
|
|
42
|
+
entry: options.entry,
|
|
43
|
+
});
|
|
44
|
+
if (!buildResult.success) {
|
|
45
|
+
return this.failStart(record, buildResult.diagnostics, "initial-build", buildResult);
|
|
46
|
+
}
|
|
47
|
+
const previewDocument = await this.createPreviewDocument(sessionId, previewUrl, 1, buildResult);
|
|
48
|
+
const session = {
|
|
49
|
+
...record.session,
|
|
50
|
+
status: "running",
|
|
51
|
+
revision: 1,
|
|
52
|
+
updatedAt: this.now(),
|
|
53
|
+
diagnostics: buildResult.diagnostics,
|
|
54
|
+
buildResult,
|
|
55
|
+
previewDocument,
|
|
56
|
+
};
|
|
57
|
+
record.session = session;
|
|
58
|
+
record.unsubscribe = this.options.fileSystem.watch((event) => {
|
|
59
|
+
this.handleFileEvent(record, event);
|
|
60
|
+
});
|
|
61
|
+
this.emit({ type: "dev:session-started", session });
|
|
62
|
+
return {
|
|
63
|
+
success: true,
|
|
64
|
+
session,
|
|
65
|
+
diagnostics: buildResult.diagnostics,
|
|
66
|
+
buildResult,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async rebuild(sessionId, options = {}) {
|
|
70
|
+
const record = this.sessions.get(sessionId);
|
|
71
|
+
if (record === undefined) {
|
|
72
|
+
const diagnostic = (0, diagnostics_1.createSessionNotFoundDiagnostic)(sessionId);
|
|
73
|
+
return { success: false, diagnostics: [diagnostic] };
|
|
74
|
+
}
|
|
75
|
+
return this.performRebuild(record, options.reason ?? "manual", options.entry);
|
|
76
|
+
}
|
|
77
|
+
async stop(sessionId) {
|
|
78
|
+
const record = this.sessions.get(sessionId);
|
|
79
|
+
if (record === undefined) {
|
|
80
|
+
const diagnostic = (0, diagnostics_1.createSessionNotFoundDiagnostic)(sessionId);
|
|
81
|
+
return { success: false, diagnostics: [diagnostic] };
|
|
82
|
+
}
|
|
83
|
+
record.unsubscribe?.();
|
|
84
|
+
record.unsubscribe = undefined;
|
|
85
|
+
const session = {
|
|
86
|
+
...record.session,
|
|
87
|
+
status: "stopped",
|
|
88
|
+
updatedAt: this.now(),
|
|
89
|
+
diagnostics: [],
|
|
90
|
+
};
|
|
91
|
+
record.session = session;
|
|
92
|
+
this.emit({ type: "dev:session-stopped", session });
|
|
93
|
+
return {
|
|
94
|
+
success: true,
|
|
95
|
+
session,
|
|
96
|
+
diagnostics: [],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
getSession(sessionId) {
|
|
100
|
+
return this.sessions.get(sessionId)?.session;
|
|
101
|
+
}
|
|
102
|
+
watch(listener) {
|
|
103
|
+
this.listeners.add(listener);
|
|
104
|
+
return () => {
|
|
105
|
+
this.listeners.delete(listener);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async validateDevScript() {
|
|
109
|
+
try {
|
|
110
|
+
const manifest = await (0, package_resolution_1.readPackageManifest)(this.options.fileSystem);
|
|
111
|
+
const devScript = manifest.scripts.dev;
|
|
112
|
+
if (devScript === undefined) {
|
|
113
|
+
return [(0, diagnostics_1.createMissingDevScriptDiagnostic)()];
|
|
114
|
+
}
|
|
115
|
+
if (!isSupportedViteDevScript(devScript)) {
|
|
116
|
+
return [(0, diagnostics_1.createUnsupportedDevScriptDiagnostic)(devScript)];
|
|
117
|
+
}
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (error instanceof package_resolution_1.ForgePackageResolutionError) {
|
|
122
|
+
return [error.diagnostic];
|
|
123
|
+
}
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async failStart(record, diagnostics, reason, buildResult) {
|
|
128
|
+
const session = {
|
|
129
|
+
...record.session,
|
|
130
|
+
status: "failed",
|
|
131
|
+
updatedAt: this.now(),
|
|
132
|
+
diagnostics,
|
|
133
|
+
buildResult,
|
|
134
|
+
};
|
|
135
|
+
record.session = session;
|
|
136
|
+
this.emit({
|
|
137
|
+
type: "dev:session-failed",
|
|
138
|
+
session,
|
|
139
|
+
diagnostics,
|
|
140
|
+
buildResult,
|
|
141
|
+
reason,
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
success: false,
|
|
145
|
+
session,
|
|
146
|
+
diagnostics,
|
|
147
|
+
buildResult,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
handleFileEvent(record, event) {
|
|
151
|
+
const change = describeFileChange(event);
|
|
152
|
+
if (change === undefined || record.session.status === "stopped") {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const previous = record.rebuildQueue ?? Promise.resolve(undefined);
|
|
156
|
+
const next = previous.then(() => this.performRebuild(record, change.reason, record.entry));
|
|
157
|
+
record.rebuildQueue = next;
|
|
158
|
+
void next.catch(() => {
|
|
159
|
+
record.rebuildQueue = undefined;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
async performRebuild(record, reason, entry) {
|
|
163
|
+
if (record.session.status === "stopped") {
|
|
164
|
+
const diagnostic = (0, diagnostics_1.createSessionStoppedDiagnostic)(record.session.id);
|
|
165
|
+
return {
|
|
166
|
+
success: false,
|
|
167
|
+
session: record.session,
|
|
168
|
+
diagnostics: [diagnostic],
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
record.session = {
|
|
172
|
+
...record.session,
|
|
173
|
+
status: "rebuilding",
|
|
174
|
+
updatedAt: this.now(),
|
|
175
|
+
};
|
|
176
|
+
const buildResult = await this.options.buildPipeline.build({ entry });
|
|
177
|
+
if (!buildResult.success) {
|
|
178
|
+
const session = {
|
|
179
|
+
...record.session,
|
|
180
|
+
status: "failed",
|
|
181
|
+
updatedAt: this.now(),
|
|
182
|
+
diagnostics: buildResult.diagnostics,
|
|
183
|
+
buildResult,
|
|
184
|
+
};
|
|
185
|
+
record.session = session;
|
|
186
|
+
this.emit({
|
|
187
|
+
type: "dev:session-failed",
|
|
188
|
+
session,
|
|
189
|
+
diagnostics: buildResult.diagnostics,
|
|
190
|
+
buildResult,
|
|
191
|
+
reason,
|
|
192
|
+
});
|
|
193
|
+
return {
|
|
194
|
+
success: false,
|
|
195
|
+
session,
|
|
196
|
+
diagnostics: buildResult.diagnostics,
|
|
197
|
+
buildResult,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const revision = record.session.revision + 1;
|
|
201
|
+
const previewDocument = await this.createPreviewDocument(record.session.id, record.session.previewUrl, revision, buildResult);
|
|
202
|
+
const session = {
|
|
203
|
+
...record.session,
|
|
204
|
+
status: "running",
|
|
205
|
+
revision,
|
|
206
|
+
updatedAt: this.now(),
|
|
207
|
+
diagnostics: buildResult.diagnostics,
|
|
208
|
+
buildResult,
|
|
209
|
+
previewDocument,
|
|
210
|
+
};
|
|
211
|
+
record.session = session;
|
|
212
|
+
this.emit({
|
|
213
|
+
type: "preview:refreshed",
|
|
214
|
+
session,
|
|
215
|
+
buildResult,
|
|
216
|
+
reason,
|
|
217
|
+
});
|
|
218
|
+
return {
|
|
219
|
+
success: true,
|
|
220
|
+
session,
|
|
221
|
+
diagnostics: buildResult.diagnostics,
|
|
222
|
+
buildResult,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
async createPreviewDocument(sessionId, previewUrl, revision, buildResult) {
|
|
226
|
+
const htmlShell = (await this.options.fileSystem.exists("/index.html"))
|
|
227
|
+
? await this.options.fileSystem.readText("/index.html")
|
|
228
|
+
: undefined;
|
|
229
|
+
return (0, preview_document_1.createForgePreviewDocument)({
|
|
230
|
+
buildResult,
|
|
231
|
+
htmlShell,
|
|
232
|
+
previewUrl,
|
|
233
|
+
revision,
|
|
234
|
+
sessionId,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
allocateSessionId() {
|
|
238
|
+
const sessionId = this.createSessionId();
|
|
239
|
+
this.nextSessionNumber += 1;
|
|
240
|
+
return sessionId;
|
|
241
|
+
}
|
|
242
|
+
emit(event) {
|
|
243
|
+
for (const listener of this.listeners) {
|
|
244
|
+
try {
|
|
245
|
+
listener(event);
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
// Dev-session listeners are observers and must not break the session.
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.DefaultDevServerPreview = DefaultDevServerPreview;
|
|
254
|
+
function createDevServerPreview(options) {
|
|
255
|
+
return new DefaultDevServerPreview(options);
|
|
256
|
+
}
|
|
257
|
+
exports.createDevServerPreview = createDevServerPreview;
|
|
258
|
+
function isSupportedViteDevScript(script) {
|
|
259
|
+
const argv = script.trim().split(/\s+/);
|
|
260
|
+
if (argv[0] !== "vite") {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
return (argv.length === 1 ||
|
|
264
|
+
argv[1] === "dev" ||
|
|
265
|
+
argv[1].startsWith("-"));
|
|
266
|
+
}
|
|
267
|
+
exports.isSupportedViteDevScript = isSupportedViteDevScript;
|
|
268
|
+
function createPreviewUrl(sessionId) {
|
|
269
|
+
return `/preview/${encodeURIComponent(sessionId)}/`;
|
|
270
|
+
}
|
|
271
|
+
function describeFileChange(event) {
|
|
272
|
+
const path = event.type === "file:renamed" ? event.to : event.path;
|
|
273
|
+
if (path.startsWith("/.forge/")) {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
reason: `${event.type}:${path}`,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { ForgeBuildDiagnostic, ForgeBuildPipeline, ForgeBuildResult } from "../build-pipeline";
|
|
2
|
+
import type { ForgePackageDiagnostic } from "../package-resolution";
|
|
3
|
+
import type { ForgeFileEvent, ForgeUnsubscribe, ForgeVirtualFileSystem } from "../virtual-file-system";
|
|
4
|
+
export declare const DEV_SERVER_PREVIEW_CAPABILITY: "dev-server-preview";
|
|
5
|
+
export type ForgeDevSessionStatus = "starting" | "running" | "rebuilding" | "stopped" | "failed";
|
|
6
|
+
export type ForgeDevServerPreviewDiagnosticCode = "missing_dev_script" | "session_not_found" | "session_stopped" | "unsupported_dev_script";
|
|
7
|
+
export interface ForgeDevServerPreviewDiagnostic {
|
|
8
|
+
readonly code: ForgeDevServerPreviewDiagnosticCode;
|
|
9
|
+
readonly severity: "error";
|
|
10
|
+
readonly message: string;
|
|
11
|
+
readonly path?: string;
|
|
12
|
+
readonly script?: string;
|
|
13
|
+
readonly sessionId?: string;
|
|
14
|
+
}
|
|
15
|
+
export type ForgeDevSessionDiagnostic = ForgeBuildDiagnostic | ForgeDevServerPreviewDiagnostic | ForgePackageDiagnostic;
|
|
16
|
+
export interface ForgePreviewDocument {
|
|
17
|
+
readonly contentType: "text/html";
|
|
18
|
+
readonly html: string;
|
|
19
|
+
readonly revision: number;
|
|
20
|
+
readonly sessionId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ForgeDevSession {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly status: ForgeDevSessionStatus;
|
|
25
|
+
readonly previewUrl: string;
|
|
26
|
+
readonly revision: number;
|
|
27
|
+
readonly startedAt: string;
|
|
28
|
+
readonly updatedAt: string;
|
|
29
|
+
readonly diagnostics: readonly ForgeDevSessionDiagnostic[];
|
|
30
|
+
readonly buildResult?: ForgeBuildResult;
|
|
31
|
+
readonly previewDocument?: ForgePreviewDocument;
|
|
32
|
+
}
|
|
33
|
+
export interface ForgeStartDevSessionOptions {
|
|
34
|
+
readonly entry?: string;
|
|
35
|
+
readonly sessionId?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ForgeRebuildDevSessionOptions {
|
|
38
|
+
readonly entry?: string;
|
|
39
|
+
readonly reason?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ForgeDevSessionStartResult {
|
|
42
|
+
readonly success: boolean;
|
|
43
|
+
readonly session: ForgeDevSession;
|
|
44
|
+
readonly diagnostics: readonly ForgeDevSessionDiagnostic[];
|
|
45
|
+
readonly buildResult?: ForgeBuildResult;
|
|
46
|
+
}
|
|
47
|
+
export interface ForgeDevSessionRefreshResult {
|
|
48
|
+
readonly success: boolean;
|
|
49
|
+
readonly session?: ForgeDevSession;
|
|
50
|
+
readonly diagnostics: readonly ForgeDevSessionDiagnostic[];
|
|
51
|
+
readonly buildResult?: ForgeBuildResult;
|
|
52
|
+
}
|
|
53
|
+
export interface ForgeDevSessionStopResult {
|
|
54
|
+
readonly success: boolean;
|
|
55
|
+
readonly session?: ForgeDevSession;
|
|
56
|
+
readonly diagnostics: readonly ForgeDevSessionDiagnostic[];
|
|
57
|
+
}
|
|
58
|
+
export type ForgeDevServerPreviewEvent = ForgeDevSessionFailedEvent | ForgeDevSessionStartedEvent | ForgeDevSessionStoppedEvent | ForgePreviewRefreshedEvent;
|
|
59
|
+
export interface ForgeDevSessionStartedEvent {
|
|
60
|
+
readonly type: "dev:session-started";
|
|
61
|
+
readonly session: ForgeDevSession;
|
|
62
|
+
}
|
|
63
|
+
export interface ForgeDevSessionStoppedEvent {
|
|
64
|
+
readonly type: "dev:session-stopped";
|
|
65
|
+
readonly session: ForgeDevSession;
|
|
66
|
+
}
|
|
67
|
+
export interface ForgePreviewRefreshedEvent {
|
|
68
|
+
readonly type: "preview:refreshed";
|
|
69
|
+
readonly session: ForgeDevSession;
|
|
70
|
+
readonly buildResult: ForgeBuildResult;
|
|
71
|
+
readonly reason: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ForgeDevSessionFailedEvent {
|
|
74
|
+
readonly type: "dev:session-failed";
|
|
75
|
+
readonly session: ForgeDevSession;
|
|
76
|
+
readonly diagnostics: readonly ForgeDevSessionDiagnostic[];
|
|
77
|
+
readonly buildResult?: ForgeBuildResult;
|
|
78
|
+
readonly reason: string;
|
|
79
|
+
}
|
|
80
|
+
export type ForgeDevServerPreviewEventListener = (event: ForgeDevServerPreviewEvent) => void;
|
|
81
|
+
export interface ForgeDevServerPreviewOptions {
|
|
82
|
+
readonly fileSystem: ForgeVirtualFileSystem;
|
|
83
|
+
readonly buildPipeline: ForgeBuildPipeline;
|
|
84
|
+
readonly createSessionId?: () => string;
|
|
85
|
+
readonly now?: () => string;
|
|
86
|
+
}
|
|
87
|
+
export interface ForgeCreatePreviewDocumentOptions {
|
|
88
|
+
readonly buildResult: ForgeBuildResult;
|
|
89
|
+
readonly htmlShell?: string;
|
|
90
|
+
readonly previewUrl: string;
|
|
91
|
+
readonly revision: number;
|
|
92
|
+
readonly sessionId: string;
|
|
93
|
+
}
|
|
94
|
+
export interface ForgeDevServerPreview {
|
|
95
|
+
readonly capability: typeof DEV_SERVER_PREVIEW_CAPABILITY;
|
|
96
|
+
start(options?: ForgeStartDevSessionOptions): Promise<ForgeDevSessionStartResult>;
|
|
97
|
+
rebuild(sessionId: string, options?: ForgeRebuildDevSessionOptions): Promise<ForgeDevSessionRefreshResult>;
|
|
98
|
+
stop(sessionId: string): Promise<ForgeDevSessionStopResult>;
|
|
99
|
+
getSession(sessionId: string): ForgeDevSession | undefined;
|
|
100
|
+
watch(listener: ForgeDevServerPreviewEventListener): ForgeUnsubscribe;
|
|
101
|
+
}
|
|
102
|
+
export interface ForgeDevSessionFileChange {
|
|
103
|
+
readonly event: ForgeFileEvent;
|
|
104
|
+
readonly reason: string;
|
|
105
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ForgeEsbuildWasmUnsupportedOperation, ForgeEsbuildWasmWorkerDiagnostic } from "./types";
|
|
2
|
+
interface WorkerStartupFailureInput {
|
|
3
|
+
readonly workerScriptUrl: string;
|
|
4
|
+
readonly cause?: unknown;
|
|
5
|
+
readonly causeCategory?: "message_channel" | "worker_script_load";
|
|
6
|
+
}
|
|
7
|
+
export declare function createWorkerStartupFailureDiagnostic(input: WorkerStartupFailureInput): ForgeEsbuildWasmWorkerDiagnostic;
|
|
8
|
+
export declare function createWasmInitializationFailureDiagnostic(wasmAssetUrl: string, cause?: unknown): ForgeEsbuildWasmWorkerDiagnostic;
|
|
9
|
+
export declare function createWorkerNotInitializedDiagnostic(): ForgeEsbuildWasmWorkerDiagnostic;
|
|
10
|
+
export declare function createUnsupportedOperationDiagnostic(operation: ForgeEsbuildWasmUnsupportedOperation): ForgeEsbuildWasmWorkerDiagnostic;
|
|
11
|
+
export declare function createTransformFailureDiagnostic(path: string, cause?: unknown): ForgeEsbuildWasmWorkerDiagnostic;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTransformFailureDiagnostic = exports.createUnsupportedOperationDiagnostic = exports.createWorkerNotInitializedDiagnostic = exports.createWasmInitializationFailureDiagnostic = exports.createWorkerStartupFailureDiagnostic = void 0;
|
|
4
|
+
function createWorkerStartupFailureDiagnostic(input) {
|
|
5
|
+
return {
|
|
6
|
+
code: "worker_startup_failed",
|
|
7
|
+
severity: "error",
|
|
8
|
+
message: "Esbuild wasm worker failed to start.",
|
|
9
|
+
workerScriptUrl: input.workerScriptUrl,
|
|
10
|
+
causeCategory: input.causeCategory ?? "worker_script_load",
|
|
11
|
+
cause: input.cause,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.createWorkerStartupFailureDiagnostic = createWorkerStartupFailureDiagnostic;
|
|
15
|
+
function createWasmInitializationFailureDiagnostic(wasmAssetUrl, cause) {
|
|
16
|
+
return {
|
|
17
|
+
code: "wasm_initialization_failed",
|
|
18
|
+
severity: "error",
|
|
19
|
+
message: "Esbuild wasm runtime failed to initialize from the wasm asset.",
|
|
20
|
+
wasmAssetUrl,
|
|
21
|
+
causeCategory: "runtime_initialization",
|
|
22
|
+
cause,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.createWasmInitializationFailureDiagnostic = createWasmInitializationFailureDiagnostic;
|
|
26
|
+
function createWorkerNotInitializedDiagnostic() {
|
|
27
|
+
return {
|
|
28
|
+
code: "worker_not_initialized",
|
|
29
|
+
severity: "error",
|
|
30
|
+
message: "Esbuild wasm worker has not been initialized.",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.createWorkerNotInitializedDiagnostic = createWorkerNotInitializedDiagnostic;
|
|
34
|
+
function createUnsupportedOperationDiagnostic(operation) {
|
|
35
|
+
return {
|
|
36
|
+
code: "unsupported_operation",
|
|
37
|
+
severity: "error",
|
|
38
|
+
message: `Esbuild wasm worker does not support ${operation}.`,
|
|
39
|
+
operation,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.createUnsupportedOperationDiagnostic = createUnsupportedOperationDiagnostic;
|
|
43
|
+
function createTransformFailureDiagnostic(path, cause) {
|
|
44
|
+
return {
|
|
45
|
+
code: "transform_failed",
|
|
46
|
+
severity: "error",
|
|
47
|
+
message: "Esbuild wasm transform failed.",
|
|
48
|
+
path,
|
|
49
|
+
causeCategory: "transform",
|
|
50
|
+
cause,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.createTransformFailureDiagnostic = createTransformFailureDiagnostic;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createTransformFailureDiagnostic, createUnsupportedOperationDiagnostic, createWasmInitializationFailureDiagnostic, createWorkerNotInitializedDiagnostic, createWorkerStartupFailureDiagnostic, } from "./diagnostics";
|
|
2
|
+
export { createEsbuildWasmWorkerService, DefaultEsbuildWasmWorkerService, } from "./service";
|
|
3
|
+
export { createEsbuildWasmWorkerMessageHandler, installEsbuildWasmWorker, type ForgeEsbuildWasmRuntime, type ForgeEsbuildWasmWorkerAdapterOptions, type ForgeEsbuildWasmWorkerGlobalScope, } from "./worker-adapter";
|
|
4
|
+
export { ESBUILD_WASM_WORKER_CAPABILITY, ESBUILD_WASM_WORKER_PROTOCOL, type ForgeEsbuildWasmDiagnosticCauseCategory, type ForgeEsbuildWasmInitializeRequest, type ForgeEsbuildWasmInitializeResult, type ForgeEsbuildWasmInitializeSuccessResult, type ForgeEsbuildWasmInitializeFailureResult, type ForgeEsbuildWasmInitializeWorkerFailureResponse, type ForgeEsbuildWasmInitializeWorkerRequest, type ForgeEsbuildWasmInitializeWorkerSuccessResponse, type ForgeEsbuildWasmRuntimeMetadata, type ForgeEsbuildWasmTransformFailureResult, type ForgeEsbuildWasmTransformLoader, type ForgeEsbuildWasmTransformRequest, type ForgeEsbuildWasmTransformResult, type ForgeEsbuildWasmTransformSuccessResult, type ForgeEsbuildWasmTransformWarning, type ForgeEsbuildWasmTransformWorkerFailureResponse, type ForgeEsbuildWasmTransformWorkerRequest, type ForgeEsbuildWasmTransformWorkerSuccessResponse, type ForgeEsbuildWasmUnsupportedOperation, type ForgeEsbuildWasmUnsupportedOperationResult, type ForgeEsbuildWasmUrl, type ForgeEsbuildWasmWorkerDiagnostic, type ForgeEsbuildWasmWorkerDiagnosticCode, type ForgeEsbuildWasmWorkerFactory, type ForgeEsbuildWasmWorkerMessageEvent, type ForgeEsbuildWasmWorkerPort, type ForgeEsbuildWasmWorkerRequestMessage, type ForgeEsbuildWasmWorkerResponseMessage, type ForgeEsbuildWasmWorkerService, type ForgeEsbuildWasmWorkerServiceOptions, } from "./types";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ESBUILD_WASM_WORKER_PROTOCOL = exports.ESBUILD_WASM_WORKER_CAPABILITY = exports.installEsbuildWasmWorker = exports.createEsbuildWasmWorkerMessageHandler = exports.DefaultEsbuildWasmWorkerService = exports.createEsbuildWasmWorkerService = exports.createWorkerStartupFailureDiagnostic = exports.createWorkerNotInitializedDiagnostic = exports.createWasmInitializationFailureDiagnostic = exports.createUnsupportedOperationDiagnostic = exports.createTransformFailureDiagnostic = void 0;
|
|
4
|
+
var diagnostics_1 = require("./diagnostics");
|
|
5
|
+
Object.defineProperty(exports, "createTransformFailureDiagnostic", { enumerable: true, get: function () { return diagnostics_1.createTransformFailureDiagnostic; } });
|
|
6
|
+
Object.defineProperty(exports, "createUnsupportedOperationDiagnostic", { enumerable: true, get: function () { return diagnostics_1.createUnsupportedOperationDiagnostic; } });
|
|
7
|
+
Object.defineProperty(exports, "createWasmInitializationFailureDiagnostic", { enumerable: true, get: function () { return diagnostics_1.createWasmInitializationFailureDiagnostic; } });
|
|
8
|
+
Object.defineProperty(exports, "createWorkerNotInitializedDiagnostic", { enumerable: true, get: function () { return diagnostics_1.createWorkerNotInitializedDiagnostic; } });
|
|
9
|
+
Object.defineProperty(exports, "createWorkerStartupFailureDiagnostic", { enumerable: true, get: function () { return diagnostics_1.createWorkerStartupFailureDiagnostic; } });
|
|
10
|
+
var service_1 = require("./service");
|
|
11
|
+
Object.defineProperty(exports, "createEsbuildWasmWorkerService", { enumerable: true, get: function () { return service_1.createEsbuildWasmWorkerService; } });
|
|
12
|
+
Object.defineProperty(exports, "DefaultEsbuildWasmWorkerService", { enumerable: true, get: function () { return service_1.DefaultEsbuildWasmWorkerService; } });
|
|
13
|
+
var worker_adapter_1 = require("./worker-adapter");
|
|
14
|
+
Object.defineProperty(exports, "createEsbuildWasmWorkerMessageHandler", { enumerable: true, get: function () { return worker_adapter_1.createEsbuildWasmWorkerMessageHandler; } });
|
|
15
|
+
Object.defineProperty(exports, "installEsbuildWasmWorker", { enumerable: true, get: function () { return worker_adapter_1.installEsbuildWasmWorker; } });
|
|
16
|
+
var types_1 = require("./types");
|
|
17
|
+
Object.defineProperty(exports, "ESBUILD_WASM_WORKER_CAPABILITY", { enumerable: true, get: function () { return types_1.ESBUILD_WASM_WORKER_CAPABILITY; } });
|
|
18
|
+
Object.defineProperty(exports, "ESBUILD_WASM_WORKER_PROTOCOL", { enumerable: true, get: function () { return types_1.ESBUILD_WASM_WORKER_PROTOCOL; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ForgeEsbuildWasmInitializeRequest, type ForgeEsbuildWasmInitializeResult, type ForgeEsbuildWasmTransformResult, type ForgeEsbuildWasmUnsupportedOperation, type ForgeEsbuildWasmUnsupportedOperationResult, type ForgeEsbuildWasmWorkerService, type ForgeEsbuildWasmWorkerServiceOptions, type ForgeEsbuildWasmTransformRequest } from "./types";
|
|
2
|
+
export declare class DefaultEsbuildWasmWorkerService implements ForgeEsbuildWasmWorkerService {
|
|
3
|
+
readonly capability: "esbuild-wasm-worker";
|
|
4
|
+
private readonly requestTimeoutMs;
|
|
5
|
+
private readonly workerFactory;
|
|
6
|
+
private readonly workerScriptUrl;
|
|
7
|
+
private readonly wasmAssetUrl;
|
|
8
|
+
private readonly pendingRequests;
|
|
9
|
+
private worker;
|
|
10
|
+
private nextRequestId;
|
|
11
|
+
private initializePromise;
|
|
12
|
+
private initializedResult;
|
|
13
|
+
private readonly handleMessage;
|
|
14
|
+
private readonly handleError;
|
|
15
|
+
constructor(options: ForgeEsbuildWasmWorkerServiceOptions);
|
|
16
|
+
initialize(request?: ForgeEsbuildWasmInitializeRequest): Promise<ForgeEsbuildWasmInitializeResult>;
|
|
17
|
+
transform(request: ForgeEsbuildWasmTransformRequest): Promise<ForgeEsbuildWasmTransformResult>;
|
|
18
|
+
unsupportedOperation(operation: ForgeEsbuildWasmUnsupportedOperation): ForgeEsbuildWasmUnsupportedOperationResult;
|
|
19
|
+
dispose(): void;
|
|
20
|
+
private initializeWorker;
|
|
21
|
+
private requestWorker;
|
|
22
|
+
private ensureWorker;
|
|
23
|
+
private failPendingRequests;
|
|
24
|
+
private createRequestId;
|
|
25
|
+
}
|
|
26
|
+
export declare function createEsbuildWasmWorkerService(options: ForgeEsbuildWasmWorkerServiceOptions): ForgeEsbuildWasmWorkerService;
|