@frontman-ai/vite 0.1.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/dist/index.d.ts +465 -0
- package/dist/index.js +5652 -0
- package/package.json +64 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import * as Stdlib_Option from '@rescript/runtime/lib/es6/Stdlib_Option.js';
|
|
2
|
+
import * as Stdlib_JsError from '@rescript/runtime/lib/es6/Stdlib_JsError.js';
|
|
3
|
+
import * as Stdlib_JsExn from '@rescript/runtime/lib/es6/Stdlib_JsExn.js';
|
|
4
|
+
import * as Stdlib_Promise from '@rescript/runtime/lib/es6/Stdlib_Promise.js';
|
|
5
|
+
import * as Primitive_option from '@rescript/runtime/lib/es6/Primitive_option.js';
|
|
6
|
+
import * as Stdlib_Dict from '@rescript/runtime/lib/es6/Stdlib_Dict.js';
|
|
7
|
+
import * as Stdlib_String from '@rescript/runtime/lib/es6/Stdlib_String.js';
|
|
8
|
+
import * as S from 'sury/src/S.res.mjs';
|
|
9
|
+
import * as Web from 'stream/web';
|
|
10
|
+
import * as Stdlib_JSON from '@rescript/runtime/lib/es6/Stdlib_JSON.js';
|
|
11
|
+
import * as Primitive_exceptions from '@rescript/runtime/lib/es6/Primitive_exceptions.js';
|
|
12
|
+
import * as FrontmanCore__SSE$FrontmanFrontmanCore from '@frontman/frontman-core/src/FrontmanCore__SSE.res.mjs';
|
|
13
|
+
import * as Server$1 from 'dom-element-to-component-source/server';
|
|
14
|
+
import * as FrontmanCore__Server$FrontmanFrontmanCore from '@frontman/frontman-core/src/FrontmanCore__Server.res.mjs';
|
|
15
|
+
import * as FrontmanCore__PathContext$FrontmanFrontmanCore from '@frontman/frontman-core/src/FrontmanCore__PathContext.res.mjs';
|
|
16
|
+
import * as FrontmanProtocol__MCP$FrontmanFrontmanProtocol from '@frontman/frontman-protocol/src/FrontmanProtocol__MCP.res.mjs';
|
|
17
|
+
import * as FrontmanProtocol__Relay$FrontmanFrontmanProtocol from '@frontman/frontman-protocol/src/FrontmanProtocol__Relay.res.mjs';
|
|
18
|
+
import * as FrontmanCore__ToolRegistry$FrontmanFrontmanCore from '@frontman/frontman-core/src/FrontmanCore__ToolRegistry.res.mjs';
|
|
19
|
+
|
|
20
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
let host = process.env["FRONTMAN_HOST"];
|
|
24
|
+
|
|
25
|
+
let defaultHost = host !== undefined ? host : "frontman.local:4000";
|
|
26
|
+
|
|
27
|
+
function makeFromObject(config) {
|
|
28
|
+
let isDev = Stdlib_Option.getOr(config.isDev, Stdlib_Option.mapOr(process.env["NODE_ENV"], true, env => env === "development"));
|
|
29
|
+
let projectRoot = Stdlib_Option.getOr(Stdlib_Option.orElse(config.projectRoot, Stdlib_Option.orElse(process.env["PROJECT_ROOT"], process.env["PWD"])), ".");
|
|
30
|
+
let sourceRoot = Stdlib_Option.getOr(config.sourceRoot, projectRoot);
|
|
31
|
+
let basePath = Stdlib_Option.getOr(config.basePath, "frontman");
|
|
32
|
+
let serverName = Stdlib_Option.getOr(config.serverName, "frontman-vite");
|
|
33
|
+
let serverVersion = Stdlib_Option.getOr(config.serverVersion, "1.0.0");
|
|
34
|
+
let host = Stdlib_Option.getOr(config.host, defaultHost);
|
|
35
|
+
let isLightTheme = Stdlib_Option.getOr(config.isLightTheme, false);
|
|
36
|
+
let baseUrl = Stdlib_Option.getOr(process.env["FRONTMAN_CLIENT_URL"], isDev ? "http://localhost:5173/src/Main.res.mjs" : "https://frontman.dev/frontman.es.js");
|
|
37
|
+
let url = new URL(baseUrl);
|
|
38
|
+
let clientUrl = Stdlib_Option.getOr(config.clientUrl, (url.searchParams.set("clientName", "vite"), url.searchParams.set("host", host), url.href));
|
|
39
|
+
let parsedUrl = new URL(clientUrl);
|
|
40
|
+
if (!parsedUrl.searchParams.has("host")) {
|
|
41
|
+
Stdlib_JsError.throwWithMessage(`[frontman-vite] clientUrl must include a "host" query parameter. Got: ` + clientUrl);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
isDev: isDev,
|
|
45
|
+
projectRoot: projectRoot,
|
|
46
|
+
sourceRoot: sourceRoot,
|
|
47
|
+
basePath: basePath,
|
|
48
|
+
serverName: serverName,
|
|
49
|
+
serverVersion: serverVersion,
|
|
50
|
+
host: host,
|
|
51
|
+
clientUrl: clientUrl,
|
|
52
|
+
clientCssUrl: config.clientCssUrl,
|
|
53
|
+
entrypointUrl: config.entrypointUrl,
|
|
54
|
+
isLightTheme: isLightTheme
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/* host Not a pure module */
|
|
58
|
+
|
|
59
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
function handleGetTools(registry, config) {
|
|
63
|
+
let response = FrontmanCore__Server$FrontmanFrontmanCore.getToolsResponse(registry, config.serverName, config.serverVersion);
|
|
64
|
+
let json = S.reverseConvertToJsonOrThrow(response, FrontmanProtocol__Relay$FrontmanFrontmanProtocol.toolsResponseSchema);
|
|
65
|
+
let headers = Object.fromEntries([[
|
|
66
|
+
"Content-Type",
|
|
67
|
+
"application/json"
|
|
68
|
+
]]);
|
|
69
|
+
return Response.json(json, {
|
|
70
|
+
headers: Primitive_option.some(headers)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function handleToolCall(registry, config, req) {
|
|
75
|
+
let body = await req.json();
|
|
76
|
+
let request;
|
|
77
|
+
try {
|
|
78
|
+
request = {
|
|
79
|
+
TAG: "Ok",
|
|
80
|
+
_0: S.parseOrThrow(body, FrontmanProtocol__Relay$FrontmanFrontmanProtocol.toolCallRequestSchema)
|
|
81
|
+
};
|
|
82
|
+
} catch (raw_e) {
|
|
83
|
+
let e = Primitive_exceptions.internalToException(raw_e);
|
|
84
|
+
if (e.RE_EXN_ID === S.$$Error) {
|
|
85
|
+
request = {
|
|
86
|
+
TAG: "Error",
|
|
87
|
+
_0: e._1.message
|
|
88
|
+
};
|
|
89
|
+
} else {
|
|
90
|
+
throw e;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (request.TAG === "Ok") {
|
|
94
|
+
let request$1 = request._0;
|
|
95
|
+
let ctx_projectRoot = config.projectRoot;
|
|
96
|
+
let ctx_sourceRoot = config.sourceRoot;
|
|
97
|
+
let ctx = {
|
|
98
|
+
projectRoot: ctx_projectRoot,
|
|
99
|
+
sourceRoot: ctx_sourceRoot,
|
|
100
|
+
onProgress: undefined
|
|
101
|
+
};
|
|
102
|
+
let resultPromise = FrontmanCore__Server$FrontmanFrontmanCore.executeTool(registry, ctx, request$1.name, request$1.arguments);
|
|
103
|
+
let encoder = new TextEncoder();
|
|
104
|
+
let stream = new Web.ReadableStream({
|
|
105
|
+
start: controller => {
|
|
106
|
+
resultPromise.then(result => {
|
|
107
|
+
let mcpResult = FrontmanCore__Server$FrontmanFrontmanCore.resultToMCP(result);
|
|
108
|
+
let match = mcpResult.isError;
|
|
109
|
+
let eventData = match !== undefined && match ? FrontmanCore__SSE$FrontmanFrontmanCore.errorEvent(mcpResult) : FrontmanCore__SSE$FrontmanFrontmanCore.resultEvent(mcpResult);
|
|
110
|
+
controller.enqueue(encoder.encode(eventData));
|
|
111
|
+
controller.close();
|
|
112
|
+
return Promise.resolve();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return new Response(stream, {
|
|
117
|
+
headers: Primitive_option.some(FrontmanCore__SSE$FrontmanFrontmanCore.headers())
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
let errorResult_content = [{
|
|
121
|
+
type: "text",
|
|
122
|
+
text: `Invalid request: ` + request._0
|
|
123
|
+
}];
|
|
124
|
+
let errorResult_isError = true;
|
|
125
|
+
let errorResult = {
|
|
126
|
+
content: errorResult_content,
|
|
127
|
+
isError: errorResult_isError
|
|
128
|
+
};
|
|
129
|
+
let json = S.reverseConvertToJsonOrThrow(errorResult, FrontmanProtocol__MCP$FrontmanFrontmanProtocol.callToolResultSchema);
|
|
130
|
+
return Response.json(json, {
|
|
131
|
+
status: 400
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function handleResolveSourceLocation(config, req) {
|
|
136
|
+
let body = await req.json();
|
|
137
|
+
let requestObj = Stdlib_JSON.Decode.object(body);
|
|
138
|
+
if (requestObj === undefined) {
|
|
139
|
+
return Response.json(Object.fromEntries([[
|
|
140
|
+
"error",
|
|
141
|
+
"Invalid request body"
|
|
142
|
+
]]), {
|
|
143
|
+
status: 400
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
let componentName = Stdlib_Option.flatMap(requestObj["componentName"], Stdlib_JSON.Decode.string);
|
|
147
|
+
let file = Stdlib_Option.flatMap(requestObj["file"], Stdlib_JSON.Decode.string);
|
|
148
|
+
let line = Stdlib_Option.flatMap(requestObj["line"], Stdlib_JSON.Decode.float);
|
|
149
|
+
let column = Stdlib_Option.flatMap(requestObj["column"], Stdlib_JSON.Decode.float);
|
|
150
|
+
if (componentName !== undefined && file !== undefined && line !== undefined && column !== undefined) {
|
|
151
|
+
try {
|
|
152
|
+
let sourceLocation_line = line | 0;
|
|
153
|
+
let sourceLocation_column = column | 0;
|
|
154
|
+
let sourceLocation = {
|
|
155
|
+
componentName: componentName,
|
|
156
|
+
file: file,
|
|
157
|
+
line: sourceLocation_line,
|
|
158
|
+
column: sourceLocation_column,
|
|
159
|
+
componentProps: undefined,
|
|
160
|
+
parent: undefined
|
|
161
|
+
};
|
|
162
|
+
let resolved = await Server$1.resolveSourceLocationInServer(sourceLocation);
|
|
163
|
+
let relativeFile = FrontmanCore__PathContext$FrontmanFrontmanCore.toRelativePath(config.sourceRoot, resolved.file);
|
|
164
|
+
let responseJson = Object.fromEntries([
|
|
165
|
+
[
|
|
166
|
+
"componentName",
|
|
167
|
+
resolved.componentName
|
|
168
|
+
],
|
|
169
|
+
[
|
|
170
|
+
"file",
|
|
171
|
+
relativeFile
|
|
172
|
+
],
|
|
173
|
+
[
|
|
174
|
+
"line",
|
|
175
|
+
resolved.line
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
"column",
|
|
179
|
+
resolved.column
|
|
180
|
+
]
|
|
181
|
+
]);
|
|
182
|
+
let headers = Object.fromEntries([[
|
|
183
|
+
"Content-Type",
|
|
184
|
+
"application/json"
|
|
185
|
+
]]);
|
|
186
|
+
return Response.json(responseJson, {
|
|
187
|
+
headers: Primitive_option.some(headers)
|
|
188
|
+
});
|
|
189
|
+
} catch (raw_exn) {
|
|
190
|
+
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
191
|
+
let msg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "Unknown error");
|
|
192
|
+
return Response.json(Object.fromEntries([
|
|
193
|
+
[
|
|
194
|
+
"error",
|
|
195
|
+
"Failed to resolve source location"
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
"details",
|
|
199
|
+
msg
|
|
200
|
+
]
|
|
201
|
+
]), {
|
|
202
|
+
status: 500
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return Response.json(Object.fromEntries([[
|
|
207
|
+
"error",
|
|
208
|
+
"Missing required fields: componentName, file, line, column"
|
|
209
|
+
]]), {
|
|
210
|
+
status: 400
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/* S Not a pure module */
|
|
214
|
+
|
|
215
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
function make() {
|
|
219
|
+
return FrontmanCore__ToolRegistry$FrontmanFrontmanCore.coreTools();
|
|
220
|
+
}
|
|
221
|
+
/* FrontmanCore__ToolRegistry-FrontmanFrontmanCore Not a pure module */
|
|
222
|
+
|
|
223
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
let corsHeaders = Object.fromEntries([
|
|
227
|
+
[
|
|
228
|
+
"Access-Control-Allow-Origin",
|
|
229
|
+
"*"
|
|
230
|
+
],
|
|
231
|
+
[
|
|
232
|
+
"Access-Control-Allow-Methods",
|
|
233
|
+
"GET, POST, OPTIONS"
|
|
234
|
+
],
|
|
235
|
+
[
|
|
236
|
+
"Access-Control-Allow-Headers",
|
|
237
|
+
"Content-Type"
|
|
238
|
+
]
|
|
239
|
+
]);
|
|
240
|
+
|
|
241
|
+
function withCors(response) {
|
|
242
|
+
let headers = response.headers;
|
|
243
|
+
Stdlib_Dict.forEachWithKey(corsHeaders, (value, key) => {
|
|
244
|
+
headers.set(key, value);
|
|
245
|
+
});
|
|
246
|
+
return response;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function handlePreflight() {
|
|
250
|
+
return new Response(null, {
|
|
251
|
+
status: 204,
|
|
252
|
+
headers: Primitive_option.some(corsHeaders)
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function handleUI(config) {
|
|
257
|
+
let clientCssTag = Stdlib_Option.mapOr(config.clientCssUrl, "", url => `<link rel="stylesheet" href="` + url + `">`);
|
|
258
|
+
let entrypointTemplate = Stdlib_Option.mapOr(config.entrypointUrl, "", url => `<script type="template" id="frontman-entrypoint-url">` + url + `</script>`);
|
|
259
|
+
let themeClass = config.isLightTheme ? "" : "dark";
|
|
260
|
+
let openrouterKey = Stdlib_Option.flatMap(process.env["OPENROUTER_API_KEY"], key => {
|
|
261
|
+
if (key !== "") {
|
|
262
|
+
return key;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
let configObj = Object.fromEntries([[
|
|
266
|
+
"framework",
|
|
267
|
+
"Vite"
|
|
268
|
+
]]);
|
|
269
|
+
Stdlib_Option.forEach(openrouterKey, key => {
|
|
270
|
+
configObj["openrouterKeyValue"] = key;
|
|
271
|
+
});
|
|
272
|
+
let payload = JSON.stringify(configObj);
|
|
273
|
+
let runtimeConfigScript = `<script>window.__frontmanRuntime=` + payload + `</script>`;
|
|
274
|
+
let html = `<!DOCTYPE html>
|
|
275
|
+
<html lang="en" class="` + themeClass + `">
|
|
276
|
+
<head>
|
|
277
|
+
<meta charset="UTF-8">
|
|
278
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
279
|
+
<title>Frontman</title>
|
|
280
|
+
` + entrypointTemplate + `
|
|
281
|
+
` + clientCssTag + `
|
|
282
|
+
</head>
|
|
283
|
+
<body>
|
|
284
|
+
<div id="root"></div>
|
|
285
|
+
` + runtimeConfigScript + `
|
|
286
|
+
<script type="module" src="` + config.clientUrl + `"></script>
|
|
287
|
+
</body>
|
|
288
|
+
</html>`;
|
|
289
|
+
let headers = Object.fromEntries([[
|
|
290
|
+
"Content-Type",
|
|
291
|
+
"text/html"
|
|
292
|
+
]]);
|
|
293
|
+
return new Response(html, {
|
|
294
|
+
headers: Primitive_option.some(headers)
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function createMiddleware$1(config) {
|
|
299
|
+
let registry = make();
|
|
300
|
+
return async req => {
|
|
301
|
+
let method = req.method.toLowerCase();
|
|
302
|
+
let pathname = URL.parse(req.url).pathname;
|
|
303
|
+
let path = pathname.split("/").filter(p => !Stdlib_String.isEmpty(p)).join("/").toLowerCase();
|
|
304
|
+
let toolsPath = config.basePath.toLowerCase() + "/tools";
|
|
305
|
+
let toolsCallPath = config.basePath.toLowerCase() + "/tools/call";
|
|
306
|
+
let resolveSourceLocationPath = config.basePath.toLowerCase() + "/resolve-source-location";
|
|
307
|
+
let uiPath = config.basePath.toLowerCase();
|
|
308
|
+
let isFrontmanRoute = path === toolsPath || path === toolsCallPath || path === resolveSourceLocationPath || path === uiPath;
|
|
309
|
+
switch (method) {
|
|
310
|
+
case "get" :
|
|
311
|
+
if (path === uiPath) {
|
|
312
|
+
return withCors(handleUI(config));
|
|
313
|
+
} else if (path === toolsPath) {
|
|
314
|
+
return withCors(handleGetTools(registry, config));
|
|
315
|
+
} else {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
case "options" :
|
|
319
|
+
if (isFrontmanRoute) {
|
|
320
|
+
return handlePreflight();
|
|
321
|
+
} else {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
case "post" :
|
|
325
|
+
if (path === toolsCallPath) {
|
|
326
|
+
return withCors(await handleToolCall(registry, config, req));
|
|
327
|
+
} else if (path === resolveSourceLocationPath) {
|
|
328
|
+
return withCors(await handleResolveSourceLocation(config, req));
|
|
329
|
+
} else {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
default:
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
/* corsHeaders Not a pure module */
|
|
338
|
+
|
|
339
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
let headersToDict = (function headersToDict(headers) {
|
|
343
|
+
const dict = {};
|
|
344
|
+
headers.forEach(function(value, key) {
|
|
345
|
+
dict[key] = value;
|
|
346
|
+
});
|
|
347
|
+
return dict;
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
let collectBody = (async function collectBody(req) {
|
|
351
|
+
const chunks = [];
|
|
352
|
+
for await (const chunk of req) {
|
|
353
|
+
chunks.push(chunk);
|
|
354
|
+
}
|
|
355
|
+
return Buffer.concat(chunks);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
let pipeStreamToResponse = (async function pipeStreamToResponse(stream, res) {
|
|
359
|
+
const reader = stream.getReader();
|
|
360
|
+
try {
|
|
361
|
+
while (true) {
|
|
362
|
+
const { done, value } = await reader.read();
|
|
363
|
+
if (done) break;
|
|
364
|
+
res.write(value);
|
|
365
|
+
}
|
|
366
|
+
} finally {
|
|
367
|
+
reader.releaseLock();
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
function adaptMiddlewareToVite(middleware) {
|
|
372
|
+
return async (req, res, next) => {
|
|
373
|
+
let bodyBuffer = await collectBody(req);
|
|
374
|
+
let host = Stdlib_Option.getOr(req.headers["host"], "localhost");
|
|
375
|
+
let reqUrl = Stdlib_Option.getOr(Primitive_option.fromNull(req.url), "/");
|
|
376
|
+
let url = `http://` + host + reqUrl;
|
|
377
|
+
let method = Stdlib_Option.getOr(Primitive_option.fromNull(req.method), "GET");
|
|
378
|
+
let headers = req.headers;
|
|
379
|
+
let hasBody = bodyBuffer.length > 0;
|
|
380
|
+
let body = hasBody ? Primitive_option.some(bodyBuffer) : undefined;
|
|
381
|
+
let webRequest = new Request(url, {
|
|
382
|
+
method: method,
|
|
383
|
+
headers: Primitive_option.some(headers),
|
|
384
|
+
body: body
|
|
385
|
+
});
|
|
386
|
+
let responseOption = await middleware(webRequest);
|
|
387
|
+
if (responseOption === undefined) {
|
|
388
|
+
return next();
|
|
389
|
+
}
|
|
390
|
+
res.statusCode = responseOption.status;
|
|
391
|
+
let headerDict = headersToDict(responseOption.headers);
|
|
392
|
+
res.writeHead(responseOption.status, headerDict);
|
|
393
|
+
let stream = responseOption.body;
|
|
394
|
+
if (stream !== null) {
|
|
395
|
+
await pipeStreamToResponse(stream, res);
|
|
396
|
+
}
|
|
397
|
+
res.end();
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function frontmanPlugin$1(options) {
|
|
402
|
+
let opts = Stdlib_Option.getOr(options, {});
|
|
403
|
+
return {
|
|
404
|
+
name: "frontman",
|
|
405
|
+
configureServer: server => {
|
|
406
|
+
let isDev = opts.isDev;
|
|
407
|
+
let basePath = opts.basePath;
|
|
408
|
+
let clientUrl = opts.clientUrl;
|
|
409
|
+
let clientCssUrl = opts.clientCssUrl;
|
|
410
|
+
let entrypointUrl = opts.entrypointUrl;
|
|
411
|
+
let isLightTheme = opts.isLightTheme;
|
|
412
|
+
let projectRoot = opts.projectRoot;
|
|
413
|
+
let sourceRoot = opts.sourceRoot;
|
|
414
|
+
let host = opts.host;
|
|
415
|
+
let configInput = {
|
|
416
|
+
isDev: isDev,
|
|
417
|
+
projectRoot: projectRoot,
|
|
418
|
+
sourceRoot: sourceRoot,
|
|
419
|
+
basePath: basePath,
|
|
420
|
+
host: host,
|
|
421
|
+
clientUrl: clientUrl,
|
|
422
|
+
clientCssUrl: clientCssUrl,
|
|
423
|
+
entrypointUrl: entrypointUrl,
|
|
424
|
+
isLightTheme: isLightTheme
|
|
425
|
+
};
|
|
426
|
+
let config = makeFromObject(configInput);
|
|
427
|
+
let middleware = createMiddleware$1(config);
|
|
428
|
+
let adaptedMiddleware = adaptMiddlewareToVite(middleware);
|
|
429
|
+
server.middlewares.use((req, res, next) => {
|
|
430
|
+
Stdlib_Promise.$$catch(adaptedMiddleware(req, res, next), error => {
|
|
431
|
+
let msg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(error), Stdlib_JsExn.message), "Unknown error");
|
|
432
|
+
console.error("Frontman middleware error:", msg);
|
|
433
|
+
res.statusCode = 500;
|
|
434
|
+
res.end("Internal Server Error");
|
|
435
|
+
return Promise.resolve();
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
/* collectBody Not a pure module */
|
|
442
|
+
|
|
443
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
let Config;
|
|
447
|
+
|
|
448
|
+
let Middleware;
|
|
449
|
+
|
|
450
|
+
let Server;
|
|
451
|
+
|
|
452
|
+
let ToolRegistry;
|
|
453
|
+
|
|
454
|
+
let Plugin;
|
|
455
|
+
|
|
456
|
+
let SSE;
|
|
457
|
+
|
|
458
|
+
let createMiddleware = createMiddleware$1;
|
|
459
|
+
|
|
460
|
+
let makeConfig = makeFromObject;
|
|
461
|
+
|
|
462
|
+
let frontmanPlugin = frontmanPlugin$1;
|
|
463
|
+
/* FrontmanVite__Config-FrontmanAiVite Not a pure module */
|
|
464
|
+
|
|
465
|
+
export { Config, Middleware, Plugin, SSE, Server, ToolRegistry, createMiddleware, frontmanPlugin, makeConfig };
|