@frontman-ai/astro 0.5.1 → 0.6.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.
@@ -1,11 +1,12 @@
1
1
  import * as Fs7 from 'fs';
2
2
  import { existsSync, readFileSync } from 'fs';
3
+ import * as Nodemodule from 'module';
4
+ import { createRequire } from 'module';
3
5
  import * as Nodepath5 from 'path';
4
6
  import { dirname, join } from 'path';
5
7
  import * as Nodebuffer from 'buffer';
6
8
  import * as Nodechild_process from 'child_process';
7
9
  import * as Web from 'stream/web';
8
- import { createRequire } from 'module';
9
10
 
10
11
  var __getOwnPropNames = Object.getOwnPropertyNames;
11
12
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
@@ -25,8 +26,39 @@ var require_lib = __commonJS({
25
26
  module.exports.rgPath = path.join(__dirname, `../bin/rg${process.platform === "win32" ? ".exe" : ""}`);
26
27
  }
27
28
  });
28
- function panic(msg) {
29
- throw new Error(`Panic! ` + msg);
29
+
30
+ // ../../node_modules/@rescript/runtime/lib/es6/Primitive_int.js
31
+ function min(x, y) {
32
+ if (x < y) {
33
+ return x;
34
+ } else {
35
+ return y;
36
+ }
37
+ }
38
+ function max(x, y) {
39
+ if (x > y) {
40
+ return x;
41
+ } else {
42
+ return y;
43
+ }
44
+ }
45
+ function div(x, y) {
46
+ if (y === 0) {
47
+ throw {
48
+ RE_EXN_ID: "Division_by_zero",
49
+ Error: new Error()
50
+ };
51
+ }
52
+ return x / y | 0;
53
+ }
54
+ function mod_(x, y) {
55
+ if (y === 0) {
56
+ throw {
57
+ RE_EXN_ID: "Division_by_zero",
58
+ Error: new Error()
59
+ };
60
+ }
61
+ return x % y;
30
62
  }
31
63
 
32
64
  // ../../node_modules/@rescript/runtime/lib/es6/Primitive_option.js
@@ -64,586 +96,222 @@ function valFromOption(x) {
64
96
  }
65
97
  }
66
98
 
67
- // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Option.js
68
- function forEach(opt, f) {
69
- if (opt !== void 0) {
70
- return f(valFromOption(opt));
71
- }
72
- }
73
- function getOrThrow(x, message4) {
74
- if (x !== void 0) {
75
- return valFromOption(x);
99
+ // ../../node_modules/@rescript/runtime/lib/es6/Primitive_exceptions.js
100
+ function isExtension(e) {
101
+ if (e == null) {
102
+ return false;
76
103
  } else {
77
- return panic("Option.getOrThrow called for None value");
104
+ return typeof e.RE_EXN_ID === "string";
78
105
  }
79
106
  }
80
- function mapOr(opt, $$default, f) {
81
- if (opt !== void 0) {
82
- return f(valFromOption(opt));
107
+ function internalToException(e) {
108
+ if (isExtension(e)) {
109
+ return e;
83
110
  } else {
84
- return $$default;
111
+ return {
112
+ RE_EXN_ID: "JsExn",
113
+ _1: e
114
+ };
85
115
  }
86
116
  }
87
- function map(opt, f) {
88
- if (opt !== void 0) {
89
- return some(f(valFromOption(opt)));
117
+ var idMap = {};
118
+ function create(str) {
119
+ let v = idMap[str];
120
+ if (v !== void 0) {
121
+ let id = v + 1 | 0;
122
+ idMap[str] = id;
123
+ return str + ("/" + id);
90
124
  }
125
+ idMap[str] = 1;
126
+ return str;
91
127
  }
92
- function flatMap(opt, f) {
93
- if (opt !== void 0) {
94
- return f(valFromOption(opt));
95
- }
128
+
129
+ // ../../node_modules/sury/src/Sury.res.mjs
130
+ var immutableEmpty = {};
131
+ var immutableEmpty$1 = [];
132
+ function capitalize(string4) {
133
+ return string4.slice(0, 1).toUpperCase() + string4.slice(1);
96
134
  }
97
- function getOr(opt, $$default) {
98
- if (opt !== void 0) {
99
- return valFromOption(opt);
100
- } else {
101
- return $$default;
135
+ var copy = ((d2) => ({ ...d2 }));
136
+ function fromString(string4) {
137
+ let _idx = 0;
138
+ while (true) {
139
+ let idx = _idx;
140
+ let match = string4[idx];
141
+ if (match === void 0) {
142
+ return `"` + string4 + `"`;
143
+ }
144
+ switch (match) {
145
+ case '"':
146
+ case "\n":
147
+ return JSON.stringify(string4);
148
+ default:
149
+ _idx = idx + 1 | 0;
150
+ continue;
151
+ }
102
152
  }
103
153
  }
104
- function orElse(opt, other) {
105
- if (opt !== void 0) {
106
- return opt;
154
+ function toArray2(path) {
155
+ if (path === "") {
156
+ return [];
107
157
  } else {
108
- return other;
158
+ return JSON.parse(path.split(`"]["`).join(`","`));
109
159
  }
110
160
  }
111
- function isSome(x) {
112
- return x !== void 0;
161
+ var vendor = "sury";
162
+ var s = Symbol(vendor);
163
+ var $$Error = /* @__PURE__ */ create("Sury.Error");
164
+ var constField = "const";
165
+ function isOptional(schema3) {
166
+ let match = schema3.type;
167
+ switch (match) {
168
+ case "undefined":
169
+ return true;
170
+ case "union":
171
+ return "undefined" in schema3.has;
172
+ default:
173
+ return false;
174
+ }
113
175
  }
114
- function isNone(x) {
115
- return x === void 0;
176
+ function has(acc, flag) {
177
+ return (acc & flag) !== 0;
116
178
  }
117
-
118
- // src/annotation-capture.mjs
119
- var annotationCaptureScript = `(function() {
120
- var PROPS_PREFIX = '__frontman_props__:';
121
-
122
- function parsePropsPayload(text) {
123
- text = text.trim();
124
- if (text.indexOf(PROPS_PREFIX) !== 0) return null;
125
- try {
126
- var encoded = text.slice(PROPS_PREFIX.length).trim();
127
- return JSON.parse(atob(encoded));
128
- } catch(e) {
129
- return null;
179
+ var flags = {
180
+ unknown: 1,
181
+ string: 2,
182
+ number: 4,
183
+ boolean: 8,
184
+ undefined: 16,
185
+ null: 32,
186
+ object: 64,
187
+ array: 128,
188
+ union: 256,
189
+ ref: 512,
190
+ bigint: 1024,
191
+ nan: 2048,
192
+ "function": 4096,
193
+ instance: 8192,
194
+ never: 16384,
195
+ symbol: 32768
196
+ };
197
+ function stringify(unknown2) {
198
+ let tagFlag = flags[typeof unknown2];
199
+ if (tagFlag & 16) {
200
+ return "undefined";
201
+ }
202
+ if (!(tagFlag & 64)) {
203
+ if (tagFlag & 2) {
204
+ return `"` + unknown2 + `"`;
205
+ } else if (tagFlag & 1024) {
206
+ return unknown2 + `n`;
207
+ } else {
208
+ return unknown2.toString();
130
209
  }
131
210
  }
132
-
133
- function captureAnnotations() {
134
- var annotations = new Map();
135
- var propsMap = new Map();
136
- var pendingProps = [];
137
-
138
- var walker = document.createTreeWalker(
139
- document.documentElement,
140
- NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_ELEMENT,
141
- null
142
- );
143
-
144
- var node;
145
- while (node = walker.nextNode()) {
146
- if (node.nodeType === 8) {
147
- var parsed = parsePropsPayload(node.textContent);
148
- if (parsed) {
149
- pendingProps.push(parsed);
150
- }
151
- } else if (node.nodeType === 1) {
152
- if (pendingProps.length > 0 && node.hasAttribute('data-astro-source-file')) {
153
- propsMap.set(node, pendingProps.slice());
154
- pendingProps = [];
155
- }
211
+ if (unknown2 === null) {
212
+ return "null";
213
+ }
214
+ if (Array.isArray(unknown2)) {
215
+ let string4 = "[";
216
+ for (let i = 0, i_finish = unknown2.length; i < i_finish; ++i) {
217
+ if (i !== 0) {
218
+ string4 = string4 + ", ";
156
219
  }
220
+ string4 = string4 + stringify(unknown2[i]);
157
221
  }
158
-
159
- document.querySelectorAll('[data-astro-source-file]').forEach(function(el) {
160
- var sourceFile = el.getAttribute('data-astro-source-file');
161
- var annotation = {
162
- file: sourceFile,
163
- loc: el.getAttribute('data-astro-source-loc')
164
- };
165
-
166
- var propsChain = propsMap.get(el);
167
-
168
- if (!propsChain) {
169
- var parent = el.parentElement;
170
- var maxSteps = 30;
171
- while (parent && maxSteps-- > 0) {
172
- propsChain = propsMap.get(parent);
173
- if (propsChain) break;
174
- parent = parent.parentElement;
175
- }
176
- }
177
-
178
- if (propsChain && propsChain.length > 0) {
179
- var match = null;
180
- for (var i = 0; i < propsChain.length; i++) {
181
- var entry = propsChain[i];
182
- if (entry.moduleId) {
183
- var entryFile = entry.moduleId.split('/').pop() || '';
184
- var srcFile = sourceFile.split('/').pop() || '';
185
- if (entryFile === srcFile && entryFile !== '') {
186
- match = entry;
187
- break;
188
- }
189
- }
190
- }
191
- if (!match) match = propsChain[0];
192
-
193
- if (match) {
194
- annotation.componentProps = match.props || null;
195
- if (match.displayName) {
196
- annotation.displayName = match.displayName;
197
- }
198
- }
199
- }
200
-
201
- annotations.set(el, annotation);
202
- });
203
-
204
- window.__frontman_annotations__ = {
205
- _map: annotations,
206
- get: function(el) { return annotations.get(el); },
207
- has: function(el) { return annotations.has(el); },
208
- size: function() { return annotations.size; }
209
- };
222
+ return string4 + "]";
210
223
  }
211
-
212
- document.addEventListener('DOMContentLoaded', captureAnnotations);
213
-
214
- var initialLoad = true;
215
- document.addEventListener('astro:page-load', function() {
216
- if (initialLoad) { initialLoad = false; return; }
217
- captureAnnotations();
218
- });
219
- })();`;
220
-
221
- // src/vite-plugin-props-injection.mjs
222
- function frontmanPropsInjectionPlugin() {
223
- return {
224
- name: "frontman:props-injection",
225
- enforce: "pre",
226
- apply: "serve",
227
- // Only apply in SSR (server-side rendering) mode
228
- transform(code, id, options) {
229
- if (!options?.ssr) return null;
230
- if (!id.includes("astro/dist/runtime/server/render/component") && !id.includes("astro/runtime/server/render/component")) {
231
- return null;
224
+ if (unknown2.constructor !== Object) {
225
+ return Object.prototype.toString.call(unknown2);
226
+ }
227
+ let keys = Object.keys(unknown2);
228
+ let string$1 = "{ ";
229
+ for (let i$1 = 0, i_finish$1 = keys.length; i$1 < i_finish$1; ++i$1) {
230
+ let key = keys[i$1];
231
+ let value = unknown2[key];
232
+ string$1 = string$1 + key + `: ` + stringify(value) + `; `;
233
+ }
234
+ return string$1 + "}";
235
+ }
236
+ function toExpression(schema3) {
237
+ let tag = schema3.type;
238
+ let $$const = schema3.const;
239
+ let name16 = schema3.name;
240
+ if (name16 !== void 0) {
241
+ return name16;
242
+ }
243
+ if ($$const !== void 0) {
244
+ return stringify($$const);
245
+ }
246
+ let format = schema3.format;
247
+ let anyOf = schema3.anyOf;
248
+ if (anyOf !== void 0) {
249
+ return anyOf.map(toExpression).join(" | ");
250
+ }
251
+ if (format !== void 0) {
252
+ return format;
253
+ }
254
+ switch (tag) {
255
+ case "nan":
256
+ return "NaN";
257
+ case "object":
258
+ let additionalItems = schema3.additionalItems;
259
+ let properties = schema3.properties;
260
+ let locations = Object.keys(properties);
261
+ if (locations.length === 0) {
262
+ if (typeof additionalItems === "object") {
263
+ return `{ [key: string]: ` + toExpression(additionalItems) + `; }`;
264
+ } else {
265
+ return `{}`;
266
+ }
267
+ } else {
268
+ return `{ ` + locations.map((location) => location + `: ` + toExpression(properties[location]) + `;`).join(" ") + ` }`;
232
269
  }
233
- if (!code.includes("function renderComponent(")) {
234
- console.warn(
235
- "[Frontman] Could not find renderComponent in Astro internals \u2014 component props injection will be disabled. This may happen after an Astro upgrade. File: " + id
236
- );
237
- return null;
270
+ default:
271
+ if (schema3.b) {
272
+ return tag;
238
273
  }
239
- let transformed = code.replace(
240
- "function renderComponent(",
241
- "function __original_renderComponent("
242
- );
243
- const wrapperCode = `
244
-
245
- // --- Frontman props injection wrapper ---
246
-
247
- function __frontman_safeSerialize(displayName, Component, props) {
248
- try {
249
- const clean = {};
250
- for (const [key, value] of Object.entries(props || {})) {
251
- // Skip internal Astro props (scoped CSS hashes)
252
- if (key.startsWith('data-astro-cid-')) continue;
253
- // Skip class (styling detail, not semantic)
254
- if (key === 'class' || key === 'class:list') continue;
255
-
256
- const t = typeof value;
257
- if (t === 'string' || t === 'number' || t === 'boolean') {
258
- clean[key] = value;
259
- } else if (value === null || value === undefined) {
260
- clean[key] = value;
261
- } else if (Array.isArray(value)) {
262
- try {
263
- const serialized = JSON.stringify(value);
264
- clean[key] = serialized.length < 1000 ? value : '[Array(' + value.length + ')]';
265
- } catch {
266
- clean[key] = '[Array]';
267
- }
268
- } else if (t === 'object') {
269
- try {
270
- const serialized = JSON.stringify(value);
271
- clean[key] = serialized.length < 500 ? value : '{...}';
272
- } catch {
273
- clean[key] = '{...}';
274
- }
274
+ switch (tag) {
275
+ case "instance":
276
+ return schema3.class.name;
277
+ case "array":
278
+ let additionalItems$1 = schema3.additionalItems;
279
+ let items = schema3.items;
280
+ if (typeof additionalItems$1 !== "object") {
281
+ return `[` + items.map((item) => toExpression(item.schema)).join(", ") + `]`;
282
+ }
283
+ let itemName = toExpression(additionalItems$1);
284
+ return (additionalItems$1.type === "union" ? `(` + itemName + `)` : itemName) + "[]";
285
+ default:
286
+ return tag;
275
287
  }
276
- // Skip functions, symbols, etc.
277
- }
278
-
279
- const entry = { displayName, props: clean };
280
- // Include the component's moduleId (file path) if available
281
- if (Component && Component.moduleId) {
282
- entry.moduleId = Component.moduleId;
283
- }
284
- return JSON.stringify(entry);
285
- } catch {
286
- return null;
287
288
  }
288
289
  }
289
-
290
- function __frontman_toBase64(str) {
291
- if (typeof Buffer !== 'undefined') return Buffer.from(str, 'utf-8').toString('base64');
292
- if (typeof btoa === 'function') return btoa(unescape(encodeURIComponent(str)));
293
- return null;
294
- }
295
-
296
- function __frontman_wrapInstance(renderInstance, displayName, Component, props) {
297
- // If no render method (e.g. fragment), pass through
298
- if (!renderInstance || typeof renderInstance.render !== 'function') {
299
- return renderInstance;
290
+ var SuryError = class extends Error {
291
+ constructor(code, flag, path) {
292
+ super();
293
+ this.flag = flag;
294
+ this.code = code;
295
+ this.path = path;
300
296
  }
301
-
302
- const serialized = __frontman_safeSerialize(displayName, Component, props);
303
- if (!serialized) return renderInstance;
304
-
305
- const encoded = __frontman_toBase64(serialized);
306
- if (!encoded) return renderInstance;
307
-
308
- const originalRender = renderInstance.render;
309
-
310
- renderInstance.render = function(destination) {
311
- // Write the props comment BEFORE the component renders.
312
- // This creates a Comment node in the DOM immediately preceding
313
- // the component's first rendered element.
314
- // Guard: markHTMLString is assumed to be in scope from Astro's module.
315
- // If it's missing (e.g., after an Astro upgrade), skip injection gracefully.
316
- if (typeof markHTMLString === 'function') {
317
- destination.write(markHTMLString('<!-- __frontman_props__:' + encoded + ' -->'));
318
- }
319
- return originalRender.call(renderInstance, destination);
320
- };
321
-
322
- return renderInstance;
323
- }
324
-
325
- function renderComponent(result, displayName, Component, props, slots) {
326
- const renderInstance = __original_renderComponent(result, displayName, Component, props, slots);
327
-
328
- // Handle promise (async component resolution)
329
- if (renderInstance && typeof renderInstance.then === 'function') {
330
- return renderInstance.then(function(resolved) {
331
- return __frontman_wrapInstance(resolved, displayName, Component, props);
332
- });
297
+ };
298
+ var d = Object.defineProperty;
299
+ var p = SuryError.prototype;
300
+ d(p, "message", {
301
+ get() {
302
+ return message(this);
333
303
  }
334
-
335
- return __frontman_wrapInstance(renderInstance, displayName, Component, props);
336
- }
337
-
338
- // --- End Frontman props injection wrapper ---
339
- `;
340
- transformed += wrapperCode;
341
- return {
342
- code: transformed,
343
- map: null
344
- };
345
- }
346
- };
347
- }
348
-
349
- // ../frontman-core/src/FrontmanCore__Hosts.res.mjs
350
- var apiHost = "api.frontman.sh";
351
- var clientJs = "https://app.frontman.sh/frontman.es.js";
352
- var clientCss = "https://app.frontman.sh/frontman.css";
353
- var devClientJs = "http://localhost:5173/src/Main.res.mjs";
354
-
355
- // src/FrontmanAstro__Config.res.mjs
356
- var packageVersion = "0.5.1" ;
357
- var host = process.env["FRONTMAN_HOST"];
358
- var defaultHost = host !== void 0 ? host : apiHost;
359
- var ensureConfig = (function(c2) {
360
- return c2 || {};
361
304
  });
362
- function makeFromObject(rawConfig) {
363
- let config = ensureConfig(rawConfig);
364
- let host2 = getOr(config.host, defaultHost);
365
- let isDev = host2 !== apiHost;
366
- let projectRoot = getOr(orElse(config.projectRoot, orElse(process.env["PROJECT_ROOT"], process.env["PWD"])), ".");
367
- let sourceRoot = getOr(config.sourceRoot, projectRoot);
368
- let raw = getOr(config.basePath, "frontman").replace(/^\/+|\/+$/g, "");
369
- let basePath = raw === "" ? "frontman" : raw;
370
- let serverName = getOr(config.serverName, "frontman-astro");
371
- let serverVersion = getOr(config.serverVersion, packageVersion);
372
- let isLightTheme = getOr(config.isLightTheme, false);
373
- let baseUrl = getOr(config.clientUrl, getOr(process.env["FRONTMAN_CLIENT_URL"], isDev ? devClientJs : clientJs));
374
- let url2 = new URL(baseUrl);
375
- if (url2.searchParams.has("clientName")) ; else {
376
- url2.searchParams.set("clientName", "astro");
305
+ d(p, "reason", {
306
+ get() {
307
+ return reason(this);
377
308
  }
378
- if (url2.searchParams.has("host")) ; else {
379
- url2.searchParams.set("host", host2);
380
- }
381
- let clientUrl = url2.href;
382
- return {
383
- isDev,
384
- projectRoot,
385
- sourceRoot,
386
- basePath,
387
- serverName,
388
- serverVersion,
389
- host: host2,
390
- clientUrl,
391
- clientCssUrl: orElse(config.clientCssUrl, isDev ? void 0 : clientCss),
392
- entrypointUrl: config.entrypointUrl,
393
- isLightTheme
394
- };
395
- }
396
-
397
- // ../../node_modules/@rescript/runtime/lib/es6/Primitive_int.js
398
- function min(x, y) {
399
- if (x < y) {
400
- return x;
401
- } else {
402
- return y;
403
- }
404
- }
405
- function max(x, y) {
406
- if (x > y) {
407
- return x;
408
- } else {
409
- return y;
410
- }
411
- }
412
- function div(x, y) {
413
- if (y === 0) {
414
- throw {
415
- RE_EXN_ID: "Division_by_zero",
416
- Error: new Error()
417
- };
418
- }
419
- return x / y | 0;
420
- }
421
- function mod_(x, y) {
422
- if (y === 0) {
423
- throw {
424
- RE_EXN_ID: "Division_by_zero",
425
- Error: new Error()
426
- };
427
- }
428
- return x % y;
429
- }
430
-
431
- // ../../node_modules/@rescript/runtime/lib/es6/Primitive_exceptions.js
432
- function isExtension(e) {
433
- if (e == null) {
434
- return false;
435
- } else {
436
- return typeof e.RE_EXN_ID === "string";
437
- }
438
- }
439
- function internalToException(e) {
440
- if (isExtension(e)) {
441
- return e;
442
- } else {
443
- return {
444
- RE_EXN_ID: "JsExn",
445
- _1: e
446
- };
447
- }
448
- }
449
- var idMap = {};
450
- function create(str) {
451
- let v = idMap[str];
452
- if (v !== void 0) {
453
- let id = v + 1 | 0;
454
- idMap[str] = id;
455
- return str + ("/" + id);
456
- }
457
- idMap[str] = 1;
458
- return str;
459
- }
460
-
461
- // ../../node_modules/sury/src/Sury.res.mjs
462
- var immutableEmpty = {};
463
- var immutableEmpty$1 = [];
464
- function capitalize(string4) {
465
- return string4.slice(0, 1).toUpperCase() + string4.slice(1);
466
- }
467
- var copy = ((d2) => ({ ...d2 }));
468
- function fromString(string4) {
469
- let _idx = 0;
470
- while (true) {
471
- let idx = _idx;
472
- let match = string4[idx];
473
- if (match === void 0) {
474
- return `"` + string4 + `"`;
475
- }
476
- switch (match) {
477
- case '"':
478
- case "\n":
479
- return JSON.stringify(string4);
480
- default:
481
- _idx = idx + 1 | 0;
482
- continue;
483
- }
484
- }
485
- }
486
- function toArray2(path) {
487
- if (path === "") {
488
- return [];
489
- } else {
490
- return JSON.parse(path.split(`"]["`).join(`","`));
491
- }
492
- }
493
- var vendor = "sury";
494
- var s = Symbol(vendor);
495
- var $$Error = /* @__PURE__ */ create("Sury.Error");
496
- var constField = "const";
497
- function isOptional(schema3) {
498
- let match = schema3.type;
499
- switch (match) {
500
- case "undefined":
501
- return true;
502
- case "union":
503
- return "undefined" in schema3.has;
504
- default:
505
- return false;
506
- }
507
- }
508
- function has(acc, flag) {
509
- return (acc & flag) !== 0;
510
- }
511
- var flags = {
512
- unknown: 1,
513
- string: 2,
514
- number: 4,
515
- boolean: 8,
516
- undefined: 16,
517
- null: 32,
518
- object: 64,
519
- array: 128,
520
- union: 256,
521
- ref: 512,
522
- bigint: 1024,
523
- nan: 2048,
524
- "function": 4096,
525
- instance: 8192,
526
- never: 16384,
527
- symbol: 32768
528
- };
529
- function stringify(unknown2) {
530
- let tagFlag = flags[typeof unknown2];
531
- if (tagFlag & 16) {
532
- return "undefined";
533
- }
534
- if (!(tagFlag & 64)) {
535
- if (tagFlag & 2) {
536
- return `"` + unknown2 + `"`;
537
- } else if (tagFlag & 1024) {
538
- return unknown2 + `n`;
539
- } else {
540
- return unknown2.toString();
541
- }
542
- }
543
- if (unknown2 === null) {
544
- return "null";
545
- }
546
- if (Array.isArray(unknown2)) {
547
- let string4 = "[";
548
- for (let i = 0, i_finish = unknown2.length; i < i_finish; ++i) {
549
- if (i !== 0) {
550
- string4 = string4 + ", ";
551
- }
552
- string4 = string4 + stringify(unknown2[i]);
553
- }
554
- return string4 + "]";
555
- }
556
- if (unknown2.constructor !== Object) {
557
- return Object.prototype.toString.call(unknown2);
558
- }
559
- let keys = Object.keys(unknown2);
560
- let string$1 = "{ ";
561
- for (let i$1 = 0, i_finish$1 = keys.length; i$1 < i_finish$1; ++i$1) {
562
- let key = keys[i$1];
563
- let value = unknown2[key];
564
- string$1 = string$1 + key + `: ` + stringify(value) + `; `;
565
- }
566
- return string$1 + "}";
567
- }
568
- function toExpression(schema3) {
569
- let tag = schema3.type;
570
- let $$const = schema3.const;
571
- let name15 = schema3.name;
572
- if (name15 !== void 0) {
573
- return name15;
574
- }
575
- if ($$const !== void 0) {
576
- return stringify($$const);
577
- }
578
- let format = schema3.format;
579
- let anyOf = schema3.anyOf;
580
- if (anyOf !== void 0) {
581
- return anyOf.map(toExpression).join(" | ");
582
- }
583
- if (format !== void 0) {
584
- return format;
585
- }
586
- switch (tag) {
587
- case "nan":
588
- return "NaN";
589
- case "object":
590
- let additionalItems = schema3.additionalItems;
591
- let properties = schema3.properties;
592
- let locations = Object.keys(properties);
593
- if (locations.length === 0) {
594
- if (typeof additionalItems === "object") {
595
- return `{ [key: string]: ` + toExpression(additionalItems) + `; }`;
596
- } else {
597
- return `{}`;
598
- }
599
- } else {
600
- return `{ ` + locations.map((location) => location + `: ` + toExpression(properties[location]) + `;`).join(" ") + ` }`;
601
- }
602
- default:
603
- if (schema3.b) {
604
- return tag;
605
- }
606
- switch (tag) {
607
- case "instance":
608
- return schema3.class.name;
609
- case "array":
610
- let additionalItems$1 = schema3.additionalItems;
611
- let items = schema3.items;
612
- if (typeof additionalItems$1 !== "object") {
613
- return `[` + items.map((item) => toExpression(item.schema)).join(", ") + `]`;
614
- }
615
- let itemName = toExpression(additionalItems$1);
616
- return (additionalItems$1.type === "union" ? `(` + itemName + `)` : itemName) + "[]";
617
- default:
618
- return tag;
619
- }
620
- }
621
- }
622
- var SuryError = class extends Error {
623
- constructor(code, flag, path) {
624
- super();
625
- this.flag = flag;
626
- this.code = code;
627
- this.path = path;
628
- }
629
- };
630
- var d = Object.defineProperty;
631
- var p = SuryError.prototype;
632
- d(p, "message", {
633
- get() {
634
- return message(this);
635
- }
636
- });
637
- d(p, "reason", {
638
- get() {
639
- return reason(this);
640
- }
641
- });
642
- d(p, "name", { value: "SuryError" });
643
- d(p, "s", { value: s });
644
- d(p, "_1", {
645
- get() {
646
- return this;
309
+ });
310
+ d(p, "name", { value: "SuryError" });
311
+ d(p, "s", { value: s });
312
+ d(p, "_1", {
313
+ get() {
314
+ return this;
647
315
  }
648
316
  });
649
317
  d(p, "RE_EXN_ID", {
@@ -982,7 +650,7 @@ function get(b, targetVal, location) {
982
650
  function setInlined(b, input, inlined) {
983
651
  return input.v(b) + `=` + inlined;
984
652
  }
985
- function map2(inlinedFn, input) {
653
+ function map(inlinedFn, input) {
986
654
  return {
987
655
  b: input.b,
988
656
  v: _notVar,
@@ -1295,7 +963,7 @@ function parse(prevB, schema3, inputArg, path) {
1295
963
  recOperation = embed(b, fn$2);
1296
964
  }
1297
965
  input = withPathPrepend(b, input, path, void 0, void 0, (param, input2, param$1) => {
1298
- let output = map2(recOperation, input2);
966
+ let output = map(recOperation, input2);
1299
967
  if (def.isAsync === void 0) {
1300
968
  let defsMut = copy(defs);
1301
969
  defsMut[identifier] = unknown;
@@ -1609,6 +1277,18 @@ d(sp, "~standard", {
1609
1277
  function parseOrThrow(any, schema3) {
1610
1278
  return operationFn(schema3, 1)(any);
1611
1279
  }
1280
+ function parseJsonStringOrThrow(jsonString2, schema3) {
1281
+ let tmp;
1282
+ try {
1283
+ tmp = JSON.parse(jsonString2);
1284
+ } catch (exn) {
1285
+ throw new SuryError({
1286
+ TAG: "OperationFailed",
1287
+ _0: exn.message
1288
+ }, 1, "");
1289
+ }
1290
+ return parseOrThrow(tmp, schema3);
1291
+ }
1612
1292
  function reverseConvertToJsonOrThrow(value, schema3) {
1613
1293
  return operationFn(schema3, 40)(value);
1614
1294
  }
@@ -1690,10 +1370,10 @@ function isPriority(tagFlag, byKey) {
1690
1370
  }
1691
1371
  }
1692
1372
  function isWiderUnionSchema(schemaAnyOf, inputAnyOf) {
1693
- return inputAnyOf.every((inputSchema14, idx) => {
1373
+ return inputAnyOf.every((inputSchema15, idx) => {
1694
1374
  let schema3 = schemaAnyOf[idx];
1695
- if (schema3 !== void 0 && !(flags[inputSchema14.type] & 9152) && inputSchema14.type === schema3.type) {
1696
- return inputSchema14.const === schema3.const;
1375
+ if (schema3 !== void 0 && !(flags[inputSchema15.type] & 9152) && inputSchema15.type === schema3.type) {
1376
+ return inputSchema15.const === schema3.const;
1697
1377
  } else {
1698
1378
  return false;
1699
1379
  }
@@ -2516,49 +2196,463 @@ function internalToJSONSchema(schema3, defs) {
2516
2196
  if (schemaDefs !== void 0) {
2517
2197
  Object.assign(defs, schemaDefs);
2518
2198
  }
2519
- let metadataRawSchema = schema3[jsonSchemaMetadataId];
2520
- if (metadataRawSchema !== void 0) {
2521
- Object.assign(jsonSchema, metadataRawSchema);
2199
+ let metadataRawSchema = schema3[jsonSchemaMetadataId];
2200
+ if (metadataRawSchema !== void 0) {
2201
+ Object.assign(jsonSchema, metadataRawSchema);
2202
+ }
2203
+ return jsonSchema;
2204
+ }
2205
+ function toJSONSchema(schema3) {
2206
+ jsonableValidation(schema3, schema3, "", 8);
2207
+ let defs = {};
2208
+ let jsonSchema = internalToJSONSchema(schema3, defs);
2209
+ delete defs.JSON;
2210
+ let defsKeys = Object.keys(defs);
2211
+ if (defsKeys.length) {
2212
+ defsKeys.forEach((key) => {
2213
+ defs[key] = internalToJSONSchema(defs[key], 0);
2214
+ });
2215
+ jsonSchema.$defs = defs;
2216
+ }
2217
+ return jsonSchema;
2218
+ }
2219
+ var literal = js_schema;
2220
+ var array = factory$2;
2221
+ var dict = factory$3;
2222
+ var union = factory;
2223
+ var schema = factory$4;
2224
+
2225
+ // ../../node_modules/sury/src/S.res.mjs
2226
+ var $$Error2 = $$Error;
2227
+ var string2 = string;
2228
+ var bool2 = bool;
2229
+ var int2 = int;
2230
+ var float2 = float;
2231
+ var json2 = json;
2232
+ var enableJson2 = enableJson;
2233
+ var literal2 = literal;
2234
+ var array2 = array;
2235
+ var dict2 = dict;
2236
+ var option2 = option;
2237
+ var union2 = union;
2238
+ var parseOrThrow2 = parseOrThrow;
2239
+ var parseJsonStringOrThrow2 = parseJsonStringOrThrow;
2240
+ var reverseConvertToJsonOrThrow2 = reverseConvertToJsonOrThrow;
2241
+ var schema2 = schema;
2242
+ var toJSONSchema2 = toJSONSchema;
2243
+
2244
+ // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Array.js
2245
+ function make2(length3, x) {
2246
+ if (length3 <= 0) {
2247
+ return [];
2248
+ }
2249
+ let arr = new Array(length3);
2250
+ arr.fill(x);
2251
+ return arr;
2252
+ }
2253
+ function fromInitializer(length3, f) {
2254
+ if (length3 <= 0) {
2255
+ return [];
2256
+ }
2257
+ let arr = new Array(length3);
2258
+ for (let i = 0; i < length3; ++i) {
2259
+ arr[i] = f(i);
2260
+ }
2261
+ return arr;
2262
+ }
2263
+ function reduce(arr, init, f) {
2264
+ return arr.reduce(f, init);
2265
+ }
2266
+ function reduceWithIndex(arr, init, f) {
2267
+ return arr.reduce(f, init);
2268
+ }
2269
+ function filterMap(a, f) {
2270
+ let l = a.length;
2271
+ let r = new Array(l);
2272
+ let j2 = 0;
2273
+ for (let i = 0; i < l; ++i) {
2274
+ let v = a[i];
2275
+ let v$1 = f(v);
2276
+ if (v$1 !== void 0) {
2277
+ r[j2] = valFromOption(v$1);
2278
+ j2 = j2 + 1 | 0;
2279
+ }
2280
+ }
2281
+ r.length = j2;
2282
+ return r;
2283
+ }
2284
+
2285
+ // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Int.js
2286
+ function fromString2(x, radix) {
2287
+ let maybeInt = parseInt(x);
2288
+ if (Number.isNaN(maybeInt) || maybeInt > 2147483647 || maybeInt < -2147483648) {
2289
+ return;
2290
+ } else {
2291
+ return maybeInt | 0;
2292
+ }
2293
+ }
2294
+ function panic(msg) {
2295
+ throw new Error(`Panic! ` + msg);
2296
+ }
2297
+
2298
+ // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Option.js
2299
+ function forEach(opt, f) {
2300
+ if (opt !== void 0) {
2301
+ return f(valFromOption(opt));
2302
+ }
2303
+ }
2304
+ function getOrThrow(x, message4) {
2305
+ if (x !== void 0) {
2306
+ return valFromOption(x);
2307
+ } else {
2308
+ return panic(message4 !== void 0 ? message4 : "Option.getOrThrow called for None value");
2309
+ }
2310
+ }
2311
+ function mapOr(opt, $$default, f) {
2312
+ if (opt !== void 0) {
2313
+ return f(valFromOption(opt));
2314
+ } else {
2315
+ return $$default;
2316
+ }
2317
+ }
2318
+ function map2(opt, f) {
2319
+ if (opt !== void 0) {
2320
+ return some(f(valFromOption(opt)));
2321
+ }
2322
+ }
2323
+ function flatMap(opt, f) {
2324
+ if (opt !== void 0) {
2325
+ return f(valFromOption(opt));
2326
+ }
2327
+ }
2328
+ function getOr(opt, $$default) {
2329
+ if (opt !== void 0) {
2330
+ return valFromOption(opt);
2331
+ } else {
2332
+ return $$default;
2333
+ }
2334
+ }
2335
+ function orElse(opt, other) {
2336
+ if (opt !== void 0) {
2337
+ return opt;
2338
+ } else {
2339
+ return other;
2340
+ }
2341
+ }
2342
+ function isSome(x) {
2343
+ return x !== void 0;
2344
+ }
2345
+ function isNone(x) {
2346
+ return x === void 0;
2347
+ }
2348
+
2349
+ // src/annotation-capture.mjs
2350
+ var annotationCaptureScript = `(function() {
2351
+ var PROPS_PREFIX = '__frontman_props__:';
2352
+
2353
+ function parsePropsPayload(text) {
2354
+ text = text.trim();
2355
+ if (text.indexOf(PROPS_PREFIX) !== 0) return null;
2356
+ try {
2357
+ var encoded = text.slice(PROPS_PREFIX.length).trim();
2358
+ return JSON.parse(atob(encoded));
2359
+ } catch(e) {
2360
+ return null;
2361
+ }
2362
+ }
2363
+
2364
+ function captureAnnotations() {
2365
+ var annotations = new Map();
2366
+ var propsMap = new Map();
2367
+ var pendingProps = [];
2368
+ var contentFile = null;
2369
+
2370
+ var walker = document.createTreeWalker(
2371
+ document.documentElement,
2372
+ NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_ELEMENT,
2373
+ null
2374
+ );
2375
+
2376
+ var node;
2377
+ while (node = walker.nextNode()) {
2378
+ if (node.nodeType === 8) {
2379
+ var text = node.textContent;
2380
+ var parsed = parsePropsPayload(text);
2381
+ if (parsed) {
2382
+ pendingProps.push(parsed);
2383
+ } else if (text && text.trim().indexOf('__frontman_content_file__:') === 0) {
2384
+ contentFile = text.trim().slice('__frontman_content_file__:'.length).trim();
2385
+ }
2386
+ } else if (node.nodeType === 1) {
2387
+ if (pendingProps.length > 0 && node.hasAttribute('data-astro-source-file')) {
2388
+ propsMap.set(node, pendingProps.slice());
2389
+ pendingProps = [];
2390
+ }
2391
+ }
2392
+ }
2393
+
2394
+ document.querySelectorAll('[data-astro-source-file]').forEach(function(el) {
2395
+ var sourceFile = el.getAttribute('data-astro-source-file');
2396
+ var annotation = {
2397
+ file: sourceFile,
2398
+ loc: el.getAttribute('data-astro-source-loc')
2399
+ };
2400
+
2401
+ var propsChain = propsMap.get(el);
2402
+
2403
+ if (!propsChain) {
2404
+ var parent = el.parentElement;
2405
+ var maxSteps = 30;
2406
+ while (parent && maxSteps-- > 0) {
2407
+ propsChain = propsMap.get(parent);
2408
+ if (propsChain) break;
2409
+ parent = parent.parentElement;
2410
+ }
2411
+ }
2412
+
2413
+ if (propsChain && propsChain.length > 0) {
2414
+ var match = null;
2415
+ for (var i = 0; i < propsChain.length; i++) {
2416
+ var entry = propsChain[i];
2417
+ if (entry.moduleId) {
2418
+ var entryFile = entry.moduleId.split('/').pop() || '';
2419
+ var srcFile = sourceFile.split('/').pop() || '';
2420
+ if (entryFile === srcFile && entryFile !== '') {
2421
+ match = entry;
2422
+ break;
2423
+ }
2424
+ }
2425
+ }
2426
+ if (!match) match = propsChain[0];
2427
+
2428
+ if (match) {
2429
+ annotation.componentProps = match.props || null;
2430
+ if (match.displayName) {
2431
+ annotation.displayName = match.displayName;
2432
+ }
2433
+ }
2434
+ }
2435
+
2436
+ annotations.set(el, annotation);
2437
+ });
2438
+
2439
+ window.__frontman_annotations__ = {
2440
+ _map: annotations,
2441
+ get: function(el) { return annotations.get(el); },
2442
+ has: function(el) { return annotations.has(el); },
2443
+ size: function() { return annotations.size; },
2444
+ contentFile: contentFile
2445
+ };
2446
+ }
2447
+
2448
+ document.addEventListener('DOMContentLoaded', captureAnnotations);
2449
+
2450
+ var initialLoad = true;
2451
+ document.addEventListener('astro:page-load', function() {
2452
+ if (initialLoad) { initialLoad = false; return; }
2453
+ captureAnnotations();
2454
+ });
2455
+ })();`;
2456
+
2457
+ // src/rehype-content-file.mjs
2458
+ function rehypeContentFile(options) {
2459
+ var raw = options && options.projectRoot || "";
2460
+ var projectRoot = typeof raw === "string" ? raw : raw.pathname || "";
2461
+ if (projectRoot.endsWith("/")) {
2462
+ projectRoot = projectRoot.slice(0, -1);
2463
+ }
2464
+ return function transformer(tree, file) {
2465
+ if (!file || !file.path) {
2466
+ return;
2467
+ }
2468
+ var absolute = file.path;
2469
+ var relative = absolute;
2470
+ if (projectRoot && absolute.startsWith(projectRoot + "/")) {
2471
+ relative = absolute.slice(projectRoot.length + 1);
2472
+ }
2473
+ var comment = {
2474
+ type: "comment",
2475
+ value: " __frontman_content_file__:" + relative + " "
2476
+ };
2477
+ tree.children.unshift(comment);
2478
+ };
2479
+ }
2480
+
2481
+ // src/vite-plugin-props-injection.mjs
2482
+ function frontmanPropsInjectionPlugin() {
2483
+ return {
2484
+ name: "frontman:props-injection",
2485
+ enforce: "pre",
2486
+ apply: "serve",
2487
+ // Only apply in SSR (server-side rendering) mode
2488
+ transform(code, id, options) {
2489
+ if (!options?.ssr) return null;
2490
+ if (!id.includes("astro/dist/runtime/server/render/component") && !id.includes("astro/runtime/server/render/component")) {
2491
+ return null;
2492
+ }
2493
+ if (!code.includes("function renderComponent(")) {
2494
+ console.warn(
2495
+ "[Frontman] Could not find renderComponent in Astro internals \u2014 component props injection will be disabled. This may happen after an Astro upgrade. File: " + id
2496
+ );
2497
+ return null;
2498
+ }
2499
+ let transformed = code.replace(
2500
+ "function renderComponent(",
2501
+ "function __original_renderComponent("
2502
+ );
2503
+ const wrapperCode = `
2504
+
2505
+ // --- Frontman props injection wrapper ---
2506
+
2507
+ function __frontman_safeSerialize(displayName, Component, props) {
2508
+ try {
2509
+ const clean = {};
2510
+ for (const [key, value] of Object.entries(props || {})) {
2511
+ // Skip internal Astro props (scoped CSS hashes)
2512
+ if (key.startsWith('data-astro-cid-')) continue;
2513
+ // Skip class (styling detail, not semantic)
2514
+ if (key === 'class' || key === 'class:list') continue;
2515
+
2516
+ const t = typeof value;
2517
+ if (t === 'string' || t === 'number' || t === 'boolean') {
2518
+ clean[key] = value;
2519
+ } else if (value === null || value === undefined) {
2520
+ clean[key] = value;
2521
+ } else if (Array.isArray(value)) {
2522
+ try {
2523
+ const serialized = JSON.stringify(value);
2524
+ clean[key] = serialized.length < 1000 ? value : '[Array(' + value.length + ')]';
2525
+ } catch {
2526
+ clean[key] = '[Array]';
2527
+ }
2528
+ } else if (t === 'object') {
2529
+ try {
2530
+ const serialized = JSON.stringify(value);
2531
+ clean[key] = serialized.length < 500 ? value : '{...}';
2532
+ } catch {
2533
+ clean[key] = '{...}';
2534
+ }
2535
+ }
2536
+ // Skip functions, symbols, etc.
2537
+ }
2538
+
2539
+ const entry = { displayName, props: clean };
2540
+ // Include the component's moduleId (file path) if available
2541
+ if (Component && Component.moduleId) {
2542
+ entry.moduleId = Component.moduleId;
2543
+ }
2544
+ return JSON.stringify(entry);
2545
+ } catch {
2546
+ return null;
2547
+ }
2548
+ }
2549
+
2550
+ function __frontman_toBase64(str) {
2551
+ if (typeof Buffer !== 'undefined') return Buffer.from(str, 'utf-8').toString('base64');
2552
+ if (typeof btoa === 'function') return btoa(unescape(encodeURIComponent(str)));
2553
+ return null;
2554
+ }
2555
+
2556
+ function __frontman_wrapInstance(renderInstance, displayName, Component, props) {
2557
+ // If no render method (e.g. fragment), pass through
2558
+ if (!renderInstance || typeof renderInstance.render !== 'function') {
2559
+ return renderInstance;
2522
2560
  }
2523
- return jsonSchema;
2561
+
2562
+ const serialized = __frontman_safeSerialize(displayName, Component, props);
2563
+ if (!serialized) return renderInstance;
2564
+
2565
+ const encoded = __frontman_toBase64(serialized);
2566
+ if (!encoded) return renderInstance;
2567
+
2568
+ const originalRender = renderInstance.render;
2569
+
2570
+ renderInstance.render = function(destination) {
2571
+ // Write the props comment BEFORE the component renders.
2572
+ // This creates a Comment node in the DOM immediately preceding
2573
+ // the component's first rendered element.
2574
+ // Guard: markHTMLString is assumed to be in scope from Astro's module.
2575
+ // If it's missing (e.g., after an Astro upgrade), skip injection gracefully.
2576
+ if (typeof markHTMLString === 'function') {
2577
+ destination.write(markHTMLString('<!-- __frontman_props__:' + encoded + ' -->'));
2578
+ }
2579
+ return originalRender.call(renderInstance, destination);
2580
+ };
2581
+
2582
+ return renderInstance;
2524
2583
  }
2525
- function toJSONSchema(schema3) {
2526
- jsonableValidation(schema3, schema3, "", 8);
2527
- let defs = {};
2528
- let jsonSchema = internalToJSONSchema(schema3, defs);
2529
- delete defs.JSON;
2530
- let defsKeys = Object.keys(defs);
2531
- if (defsKeys.length) {
2532
- defsKeys.forEach((key) => {
2533
- defs[key] = internalToJSONSchema(defs[key], 0);
2584
+
2585
+ function renderComponent(result, displayName, Component, props, slots) {
2586
+ const renderInstance = __original_renderComponent(result, displayName, Component, props, slots);
2587
+
2588
+ // Handle promise (async component resolution)
2589
+ if (renderInstance && typeof renderInstance.then === 'function') {
2590
+ return renderInstance.then(function(resolved) {
2591
+ return __frontman_wrapInstance(resolved, displayName, Component, props);
2534
2592
  });
2535
- jsonSchema.$defs = defs;
2536
2593
  }
2537
- return jsonSchema;
2594
+
2595
+ return __frontman_wrapInstance(renderInstance, displayName, Component, props);
2538
2596
  }
2539
- var literal = js_schema;
2540
- var array = factory$2;
2541
- var dict = factory$3;
2542
- var union = factory;
2543
- var schema = factory$4;
2544
2597
 
2545
- // ../../node_modules/sury/src/S.res.mjs
2546
- var $$Error2 = $$Error;
2547
- var string2 = string;
2548
- var bool2 = bool;
2549
- var int2 = int;
2550
- var float2 = float;
2551
- var json2 = json;
2552
- var enableJson2 = enableJson;
2553
- var literal2 = literal;
2554
- var array2 = array;
2555
- var dict2 = dict;
2556
- var option2 = option;
2557
- var union2 = union;
2558
- var parseOrThrow2 = parseOrThrow;
2559
- var reverseConvertToJsonOrThrow2 = reverseConvertToJsonOrThrow;
2560
- var schema2 = schema;
2561
- var toJSONSchema2 = toJSONSchema;
2598
+ // --- End Frontman props injection wrapper ---
2599
+ `;
2600
+ transformed += wrapperCode;
2601
+ return {
2602
+ code: transformed,
2603
+ map: null
2604
+ };
2605
+ }
2606
+ };
2607
+ }
2608
+
2609
+ // ../frontman-core/src/FrontmanCore__Hosts.res.mjs
2610
+ var apiHost = "api.frontman.sh";
2611
+ var clientJs = "https://app.frontman.sh/frontman.es.js";
2612
+ var clientCss = "https://app.frontman.sh/frontman.css";
2613
+ var devClientJs = "http://localhost:5173/src/Main.res.mjs";
2614
+
2615
+ // src/FrontmanAstro__Config.res.mjs
2616
+ var packageVersion = "0.6.0" ;
2617
+ var host = process.env["FRONTMAN_HOST"];
2618
+ var defaultHost = host !== void 0 ? host : apiHost;
2619
+ var ensureConfig = (function(c2) {
2620
+ return c2 || {};
2621
+ });
2622
+ function makeFromObject(rawConfig) {
2623
+ let config = ensureConfig(rawConfig);
2624
+ let host2 = getOr(config.host, defaultHost);
2625
+ let isDev = host2 !== apiHost;
2626
+ let projectRoot = getOr(orElse(config.projectRoot, orElse(process.env["PROJECT_ROOT"], process.env["PWD"])), ".");
2627
+ let sourceRoot = getOr(config.sourceRoot, projectRoot);
2628
+ let raw = getOr(config.basePath, "frontman").replace(/^\/+|\/+$/g, "");
2629
+ let basePath = raw === "" ? "frontman" : raw;
2630
+ let serverName = getOr(config.serverName, "frontman-astro");
2631
+ let serverVersion = getOr(config.serverVersion, packageVersion);
2632
+ let isLightTheme = getOr(config.isLightTheme, false);
2633
+ let baseUrl = getOr(config.clientUrl, getOr(process.env["FRONTMAN_CLIENT_URL"], isDev ? devClientJs : clientJs));
2634
+ let url2 = new URL(baseUrl);
2635
+ if (url2.searchParams.has("clientName")) ; else {
2636
+ url2.searchParams.set("clientName", "astro");
2637
+ }
2638
+ if (url2.searchParams.has("host")) ; else {
2639
+ url2.searchParams.set("host", host2);
2640
+ }
2641
+ let clientUrl = url2.href;
2642
+ return {
2643
+ isDev,
2644
+ projectRoot,
2645
+ sourceRoot,
2646
+ basePath,
2647
+ serverName,
2648
+ serverVersion,
2649
+ host: host2,
2650
+ clientUrl,
2651
+ clientCssUrl: orElse(config.clientCssUrl, isDev ? void 0 : clientCss),
2652
+ entrypointUrl: config.entrypointUrl,
2653
+ isLightTheme
2654
+ };
2655
+ }
2562
2656
 
2563
2657
  // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_JsExn.js
2564
2658
  function fromException(exn) {
@@ -2569,47 +2663,6 @@ function fromException(exn) {
2569
2663
  var getOrUndefined = ((fieldName) => (t) => t && typeof t[fieldName] === "string" ? t[fieldName] : void 0);
2570
2664
  var message2 = getOrUndefined("message");
2571
2665
 
2572
- // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Array.js
2573
- function make2(length3, x) {
2574
- if (length3 <= 0) {
2575
- return [];
2576
- }
2577
- let arr = new Array(length3);
2578
- arr.fill(x);
2579
- return arr;
2580
- }
2581
- function fromInitializer(length3, f) {
2582
- if (length3 <= 0) {
2583
- return [];
2584
- }
2585
- let arr = new Array(length3);
2586
- for (let i = 0; i < length3; ++i) {
2587
- arr[i] = f(i);
2588
- }
2589
- return arr;
2590
- }
2591
- function reduce(arr, init, f) {
2592
- return arr.reduce(f, init);
2593
- }
2594
- function reduceWithIndex(arr, init, f) {
2595
- return arr.reduce(f, init);
2596
- }
2597
- function filterMap(a, f) {
2598
- let l = a.length;
2599
- let r = new Array(l);
2600
- let j2 = 0;
2601
- for (let i = 0; i < l; ++i) {
2602
- let v = a[i];
2603
- let v$1 = f(v);
2604
- if (v$1 !== void 0) {
2605
- r[j2] = valFromOption(v$1);
2606
- j2 = j2 + 1 | 0;
2607
- }
2608
- }
2609
- r.length = j2;
2610
- return r;
2611
- }
2612
-
2613
2666
  // ../frontman-core/src/FrontmanCore__CircularBuffer.res.mjs
2614
2667
  function make3(capacity) {
2615
2668
  return {
@@ -2684,6 +2737,7 @@ var defaultConfig_stdoutPatterns = [
2684
2737
  "hmr",
2685
2738
  "error",
2686
2739
  "Error",
2740
+ "ERROR",
2687
2741
  "astro",
2688
2742
  "build"
2689
2743
  ];
@@ -2831,12 +2885,16 @@ function handleStdoutWrite(state, message4) {
2831
2885
  }
2832
2886
  function interceptStdout(_state) {
2833
2887
  (function(_state2) {
2834
- const originalWrite = process.stdout.write.bind(process.stdout);
2835
- process.stdout.write = (chunk, ...args) => {
2836
- const message4 = typeof chunk === "string" ? chunk : chunk.toString();
2837
- handleStdoutWrite(_state2, message4);
2838
- return originalWrite(chunk, ...args);
2888
+ const interceptStream = (stream) => {
2889
+ const originalWrite = stream.write.bind(stream);
2890
+ stream.write = (chunk, ...args) => {
2891
+ const message4 = typeof chunk === "string" ? chunk : chunk.toString();
2892
+ handleStdoutWrite(_state2, message4);
2893
+ return originalWrite(chunk, ...args);
2894
+ };
2839
2895
  };
2896
+ interceptStream(process.stdout);
2897
+ interceptStream(process.stderr);
2840
2898
  })(_state);
2841
2899
  }
2842
2900
  function interceptUncaughtErrors(state) {
@@ -2846,7 +2904,7 @@ function interceptUncaughtErrors(state) {
2846
2904
  let attributes = Object.fromEntries([
2847
2905
  [
2848
2906
  "stack",
2849
- getOr(map(error.stack, (prim) => prim), null)
2907
+ getOr(map2(error.stack, (prim) => prim), null)
2850
2908
  ],
2851
2909
  [
2852
2910
  "name",
@@ -2863,7 +2921,7 @@ function interceptUncaughtErrors(state) {
2863
2921
  let reasonMessage = getOr(reason2.message, String.toString(reason2));
2864
2922
  let attributes = Object.fromEntries([[
2865
2923
  "stack",
2866
- getOr(map(reason2.stack, (prim) => prim), null)
2924
+ getOr(map2(reason2.stack, (prim) => prim), null)
2867
2925
  ]]);
2868
2926
  return addLog(state, "error", reasonMessage, attributes, void 0);
2869
2927
  } catch (exn) {
@@ -2944,7 +3002,7 @@ var outputSchema = schema2((s2) => ({
2944
3002
  }));
2945
3003
  async function execute(_ctx, input) {
2946
3004
  try {
2947
- let sinceTimestamp = map(input.since, (isoString) => new Date(isoString).getTime());
3005
+ let sinceTimestamp = map2(input.since, (isoString) => new Date(isoString).getTime());
2948
3006
  let allMatchedLogs = getLogs(input.pattern, input.level, sinceTimestamp, void 0);
2949
3007
  let totalMatched = allMatchedLogs.length;
2950
3008
  let n = input.tail;
@@ -3323,24 +3381,24 @@ function levenshtein(a, b) {
3323
3381
  for (let i = 1; i <= match; ++i) {
3324
3382
  for (let j2 = 1; j2 <= match$1; ++j2) {
3325
3383
  let cost = a.charAt(i - 1 | 0) === b.charAt(j2 - 1 | 0) ? 0 : 1;
3326
- let del = getOrThrow(matrix[i - 1 | 0])[j2] + 1 | 0;
3327
- let ins = getOrThrow(matrix[i])[j2 - 1 | 0] + 1 | 0;
3328
- let sub = getOrThrow(matrix[i - 1 | 0])[j2 - 1 | 0] + cost | 0;
3329
- getOrThrow(matrix[i])[j2] = min(del, min(ins, sub));
3384
+ let del = getOrThrow(matrix[i - 1 | 0], void 0)[j2] + 1 | 0;
3385
+ let ins = getOrThrow(matrix[i], void 0)[j2 - 1 | 0] + 1 | 0;
3386
+ let sub = getOrThrow(matrix[i - 1 | 0], void 0)[j2 - 1 | 0] + cost | 0;
3387
+ getOrThrow(matrix[i], void 0)[j2] = min(del, min(ins, sub));
3330
3388
  }
3331
3389
  }
3332
- return getOrThrow(matrix[match])[match$1];
3390
+ return getOrThrow(matrix[match], void 0)[match$1];
3333
3391
  }
3334
3392
  function lineOffset(lines, lineIndex) {
3335
3393
  let offset = 0;
3336
3394
  for (let k2 = 0; k2 < lineIndex; ++k2) {
3337
- offset = (offset + getOrThrow(lines[k2]).length | 0) + 1 | 0;
3395
+ offset = (offset + getOrThrow(lines[k2], void 0).length | 0) + 1 | 0;
3338
3396
  }
3339
3397
  return offset;
3340
3398
  }
3341
3399
  function extractBlock(content, lines, startLine, endLine) {
3342
3400
  let startIdx = lineOffset(lines, startLine);
3343
- let endIdx = lineOffset(lines, endLine) + getOrThrow(lines[endLine]).length | 0;
3401
+ let endIdx = lineOffset(lines, endLine) + getOrThrow(lines[endLine], void 0).length | 0;
3344
3402
  return content.slice(startIdx, endIdx);
3345
3403
  }
3346
3404
  function escapeRegex(str) {
@@ -3364,8 +3422,8 @@ function lineTrimMatch(content, find) {
3364
3422
  let matches2 = true;
3365
3423
  let j2 = 0;
3366
3424
  while (j2 < searchLen && matches2) {
3367
- let origTrimmed = getOrThrow(contentLines[i + j2 | 0]).trim();
3368
- let searchTrimmed = getOrThrow(searchLines$1[j2]).trim();
3425
+ let origTrimmed = getOrThrow(contentLines[i + j2 | 0], void 0).trim();
3426
+ let searchTrimmed = getOrThrow(searchLines$1[j2], void 0).trim();
3369
3427
  if (origTrimmed === searchTrimmed) {
3370
3428
  j2 = j2 + 1 | 0;
3371
3429
  } else {
@@ -3386,15 +3444,15 @@ function anchoredBlockMatch(content, find) {
3386
3444
  if (searchLines$1.length < 3) {
3387
3445
  return [];
3388
3446
  }
3389
- let firstLineSearch = getOrThrow(searchLines$1[0]).trim();
3390
- let lastLineSearch = getOrThrow(searchLines$1[searchLines$1.length - 1 | 0]).trim();
3447
+ let firstLineSearch = getOrThrow(searchLines$1[0], void 0).trim();
3448
+ let lastLineSearch = getOrThrow(searchLines$1[searchLines$1.length - 1 | 0], void 0).trim();
3391
3449
  let searchBlockSize = searchLines$1.length;
3392
3450
  let candidates = [];
3393
3451
  for (let i = 0, i_finish = contentLines.length; i < i_finish; ++i) {
3394
- if (getOrThrow(contentLines[i]).trim() === firstLineSearch) {
3452
+ if (getOrThrow(contentLines[i], void 0).trim() === firstLineSearch) {
3395
3453
  let j2 = i + 2 | 0;
3396
3454
  while (j2 < contentLines.length) {
3397
- if (getOrThrow(contentLines[j2]).trim() === lastLineSearch) {
3455
+ if (getOrThrow(contentLines[j2], void 0).trim() === lastLineSearch) {
3398
3456
  candidates.push({
3399
3457
  startLine: i,
3400
3458
  endLine: j2
@@ -3425,8 +3483,8 @@ function anchoredBlockMatch(content, find) {
3425
3483
  if (linesToCheck2 > 0) {
3426
3484
  let sim = 0;
3427
3485
  for (let j2 = 1, j_finish = min(searchBlockSize - 2 | 0, actualBlockSize2 - 2 | 0); j2 <= j_finish; ++j2) {
3428
- let origLine = getOrThrow(contentLines[startLine2 + j2 | 0]).trim();
3429
- let searchLine = getOrThrow(searchLines$1[j2]).trim();
3486
+ let origLine = getOrThrow(contentLines[startLine2 + j2 | 0], void 0).trim();
3487
+ let searchLine = getOrThrow(searchLines$1[j2], void 0).trim();
3430
3488
  let maxLen = max(origLine.length, searchLine.length);
3431
3489
  if (maxLen > 0) {
3432
3490
  let distance = levenshtein(origLine, searchLine);
@@ -3455,7 +3513,7 @@ function anchoredBlockMatch(content, find) {
3455
3513
  return [];
3456
3514
  }
3457
3515
  }
3458
- let match$3 = getOrThrow(candidates[0]);
3516
+ let match$3 = getOrThrow(candidates[0], void 0);
3459
3517
  let endLine = match$3.endLine;
3460
3518
  let startLine = match$3.startLine;
3461
3519
  let actualBlockSize = (endLine - startLine | 0) + 1 | 0;
@@ -3465,8 +3523,8 @@ function anchoredBlockMatch(content, find) {
3465
3523
  let sim = 0;
3466
3524
  let j$1 = 1;
3467
3525
  while (j$1 < (searchBlockSize - 1 | 0) && j$1 < (actualBlockSize - 1 | 0)) {
3468
- let origLine = getOrThrow(contentLines[startLine + j$1 | 0]).trim();
3469
- let searchLine = getOrThrow(searchLines$1[j$1]).trim();
3526
+ let origLine = getOrThrow(contentLines[startLine + j$1 | 0], void 0).trim();
3527
+ let searchLine = getOrThrow(searchLines$1[j$1], void 0).trim();
3470
3528
  let maxLen = max(origLine.length, searchLine.length);
3471
3529
  if (maxLen > 0) {
3472
3530
  let distance = levenshtein(origLine, searchLine);
@@ -3617,21 +3675,21 @@ function contextAnchorMatch(content, find) {
3617
3675
  return [];
3618
3676
  }
3619
3677
  let contentLines = content.split("\n");
3620
- let firstLine = getOrThrow(findLines$1[0]).trim();
3621
- let lastLine = getOrThrow(findLines$1[findLines$1.length - 1 | 0]).trim();
3678
+ let firstLine = getOrThrow(findLines$1[0], void 0).trim();
3679
+ let lastLine = getOrThrow(findLines$1[findLines$1.length - 1 | 0], void 0).trim();
3622
3680
  let results = [];
3623
3681
  for (let i = 0, i_finish = contentLines.length; i < i_finish; ++i) {
3624
- if (getOrThrow(contentLines[i]).trim() === firstLine) {
3682
+ if (getOrThrow(contentLines[i], void 0).trim() === firstLine) {
3625
3683
  let j2 = i + 2 | 0;
3626
3684
  while (j2 < contentLines.length) {
3627
- if (getOrThrow(contentLines[j2]).trim() === lastLine) {
3685
+ if (getOrThrow(contentLines[j2], void 0).trim() === lastLine) {
3628
3686
  let blockLines = contentLines.slice(i, j2 + 1 | 0);
3629
3687
  if (blockLines.length === findLines$1.length) {
3630
3688
  let matchingLines = 0;
3631
3689
  let totalNonEmpty = 0;
3632
3690
  for (let k2 = 1, k_finish = blockLines.length - 2 | 0; k2 <= k_finish; ++k2) {
3633
- let blockLine = getOrThrow(blockLines[k2]).trim();
3634
- let findLine = getOrThrow(findLines$1[k2]).trim();
3691
+ let blockLine = getOrThrow(blockLines[k2], void 0).trim();
3692
+ let findLine = getOrThrow(findLines$1[k2], void 0).trim();
3635
3693
  let match = blockLine.length > 0;
3636
3694
  let match$1 = findLine.length > 0;
3637
3695
  let exit = 0;
@@ -3668,7 +3726,7 @@ function multiOccurrenceMatch(content, find) {
3668
3726
  let continue_ = true;
3669
3727
  while (continue_) {
3670
3728
  let searchContent = content.slice(startIndex.contents, content.length);
3671
- let idx = map(indexOfOpt(searchContent, find), (i) => i + startIndex.contents | 0);
3729
+ let idx = map2(indexOfOpt(searchContent, find), (i) => i + startIndex.contents | 0);
3672
3730
  if (idx !== void 0) {
3673
3731
  results.push(find);
3674
3732
  startIndex.contents = idx + find.length | 0;
@@ -3699,7 +3757,7 @@ function applyEdit(content, oldText, newText, replaceAllOpt) {
3699
3757
  };
3700
3758
  let strategyIdx = 0;
3701
3759
  while (isNone(result.contents) && strategyIdx < strategies.length) {
3702
- let strategy = getOrThrow(strategies[strategyIdx]);
3760
+ let strategy = getOrThrow(strategies[strategyIdx], void 0);
3703
3761
  let candidates = strategy(content, oldText);
3704
3762
  let match = !replaceAll && candidates.length > 1;
3705
3763
  if (match) {
@@ -3874,6 +3932,8 @@ Parameters:
3874
3932
  The tool uses multiple matching strategies (exact, line-trimmed, whitespace-normalized,
3875
3933
  indentation-flexible, etc.) to handle common formatting differences.
3876
3934
 
3935
+ When replacing most of a file, prefer write_file instead \u2014 it avoids reproducing the original content. Use edit_file for surgical changes: a few lines, a function body, a config block. For multiple changes in one file, make several small edit_file calls targeting specific sections rather than one large replacement.
3936
+
3877
3937
  IMPORTANT: You must read_file before editing. The tool will reject edits on unread files.`;
3878
3938
 
3879
3939
  // src/tools/FrontmanAstro__Tool__EditFile.res.mjs
@@ -4052,16 +4112,6 @@ Parameters: None
4052
4112
 
4053
4113
  Returns array of page paths based on file-system routing conventions.
4054
4114
  Excludes API routes (src/pages/api/) - focuses on renderable pages only.`;
4055
-
4056
- // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Int.js
4057
- function fromString2(x, radix) {
4058
- let maybeInt = parseInt(x);
4059
- if (Number.isNaN(maybeInt) || maybeInt > 2147483647 || maybeInt < -2147483648) {
4060
- return;
4061
- } else {
4062
- return maybeInt | 0;
4063
- }
4064
- }
4065
4115
  function execPromise(command, options) {
4066
4116
  let maxBuffer = getOr(options.maxBuffer, 52428800);
4067
4117
  return new Promise((resolve3, _reject) => {
@@ -4447,7 +4497,7 @@ async function executeGitGrep(pattern2, searchPath, caseInsensitive, literal3, m
4447
4497
  };
4448
4498
  }
4449
4499
  let stderr = match$1.stderr;
4450
- let codeStr = getOr(map(code, (c2) => c2.toString()), "unknown");
4500
+ let codeStr = getOr(map2(code, (c2) => c2.toString()), "unknown");
4451
4501
  let detail = stderr === "" ? match$1.message : stderr;
4452
4502
  return {
4453
4503
  TAG: "Error",
@@ -4502,7 +4552,7 @@ async function executePlainGrep(pattern2, searchPath, caseInsensitive, literal3,
4502
4552
  };
4503
4553
  }
4504
4554
  let stderr = match.stderr;
4505
- let codeStr = getOr(map(code, (c2) => c2.toString()), "unknown");
4555
+ let codeStr = getOr(map2(code, (c2) => c2.toString()), "unknown");
4506
4556
  let detail = stderr === "" ? match.message : stderr;
4507
4557
  return {
4508
4558
  TAG: "Error",
@@ -4657,9 +4707,9 @@ var noiseDirs = [
4657
4707
  "__pycache__",
4658
4708
  "target"
4659
4709
  ];
4660
- function makeTrieNode(name15) {
4710
+ function makeTrieNode(name16) {
4661
4711
  return {
4662
- name: name15,
4712
+ name: name16,
4663
4713
  children: {
4664
4714
  contents: {}
4665
4715
  },
@@ -4878,9 +4928,9 @@ async function detectMonorepo(rootPath) {
4878
4928
  workspaces = await Promise.all(resolvedPaths.map(async (wsPath) => {
4879
4929
  let fullPath = Nodepath5.join(rootPath, wsPath);
4880
4930
  let n = await readPackageName(fullPath);
4881
- let name15 = n !== void 0 ? n : wsPath;
4931
+ let name16 = n !== void 0 ? n : wsPath;
4882
4932
  return {
4883
- name: name15,
4933
+ name: name16,
4884
4934
  path: wsPath
4885
4935
  };
4886
4936
  }));
@@ -5153,19 +5203,19 @@ async function execute8(ctx2, input) {
5153
5203
  let relativePath = match[1];
5154
5204
  let fullPath = match[0];
5155
5205
  let entries = await Fs7.promises.readdir(fullPath);
5156
- let filteredEntriesResult = map3(await getIgnoredEntries(fullPath, entries), (ignored) => entries.filter((name15) => !ignored.includes(name15)));
5206
+ let filteredEntriesResult = map3(await getIgnoredEntries(fullPath, entries), (ignored) => entries.filter((name16) => !ignored.includes(name16)));
5157
5207
  if (filteredEntriesResult.TAG !== "Ok") {
5158
5208
  return {
5159
5209
  TAG: "Error",
5160
5210
  _0: filteredEntriesResult._0
5161
5211
  };
5162
5212
  }
5163
- let entriesWithStats = await Promise.all(filteredEntriesResult._0.map(async (name15) => {
5164
- let entryPath = Nodepath5.join(fullPath, name15);
5213
+ let entriesWithStats = await Promise.all(filteredEntriesResult._0.map(async (name16) => {
5214
+ let entryPath = Nodepath5.join(fullPath, name16);
5165
5215
  let stats = await Fs7.promises.stat(entryPath);
5166
5216
  return {
5167
- name: name15,
5168
- path: Nodepath5.join(relativePath, name15),
5217
+ name: name16,
5218
+ path: Nodepath5.join(relativePath, name16),
5169
5219
  isFile: stats.isFile(),
5170
5220
  isDirectory: stats.isDirectory()
5171
5221
  };
@@ -5296,6 +5346,8 @@ Parameters:
5296
5346
  Provide either content OR image_ref, not both.
5297
5347
  Creates parent directories if they don't exist. Overwrites existing files.
5298
5348
 
5349
+ Prefer write_file over edit_file when rewriting most of a file \u2014 it is more efficient since you only provide the final content once.
5350
+
5299
5351
  IMPORTANT: If the file already exists, you MUST read it with read_file first. The tool will reject writes to existing files that haven't been read.`;
5300
5352
 
5301
5353
  // ../frontman-core/src/tools/FrontmanCore__Tool__FileExists.res.mjs
@@ -5326,8 +5378,8 @@ Returns true if the path exists, false otherwise.`;
5326
5378
  var outputSchema10 = bool2;
5327
5379
 
5328
5380
  // ../frontman-core/src/FrontmanCore__Lighthouse.res.mjs
5329
- var run = ((url2, flags2) => import('module').then(({ createRequire }) => {
5330
- const req = createRequire(import.meta.url);
5381
+ var run = ((url2, flags2) => import('module').then(({ createRequire: createRequire2 }) => {
5382
+ const req = createRequire2(import.meta.url);
5331
5383
  try {
5332
5384
  const mod = req("lighthouse");
5333
5385
  const lighthouse = mod.default ?? mod;
@@ -5344,8 +5396,8 @@ var run = ((url2, flags2) => import('module').then(({ createRequire }) => {
5344
5396
  function getPort(prim) {
5345
5397
  return prim.port;
5346
5398
  }
5347
- var launch = ((options) => import('module').then(({ createRequire }) => {
5348
- const req = createRequire(import.meta.url);
5399
+ var launch = ((options) => import('module').then(({ createRequire: createRequire2 }) => {
5400
+ const req = createRequire2(import.meta.url);
5349
5401
  try {
5350
5402
  const mod = req("chrome-launcher");
5351
5403
  return mod.launch(options);
@@ -5459,8 +5511,8 @@ function extractSourceLocation(itemDict) {
5459
5511
  if (url2 === void 0) {
5460
5512
  return;
5461
5513
  }
5462
- let line = map(flatMap(sourceDict["line"], Decode.float), (prim) => prim | 0);
5463
- let col = map(flatMap(sourceDict["column"], Decode.float), (prim) => prim | 0);
5514
+ let line = map2(flatMap(sourceDict["line"], Decode.float), (prim) => prim | 0);
5515
+ let col = map2(flatMap(sourceDict["column"], Decode.float), (prim) => prim | 0);
5464
5516
  if (line !== void 0) {
5465
5517
  if (col !== void 0) {
5466
5518
  return url2 + `:` + line.toString() + `:` + col.toString();
@@ -5524,21 +5576,21 @@ function getTopIssues(category, audits, maxIssues) {
5524
5576
  return match$1 < 1;
5525
5577
  }
5526
5578
  }).toSorted((a, b) => {
5527
- let scoreA = getOrThrow(fromNullable(a.score));
5528
- let scoreB = getOrThrow(fromNullable(b.score));
5579
+ let scoreA = getOrThrow(fromNullable(a.score), void 0);
5580
+ let scoreB = getOrThrow(fromNullable(b.score), void 0);
5529
5581
  return scoreA - scoreB;
5530
5582
  }).slice(0, maxIssues).map((audit) => ({
5531
5583
  id: audit.id,
5532
5584
  title: audit.title,
5533
5585
  description: audit.description,
5534
- score: getOrThrow(fromNullable(audit.score)),
5586
+ score: getOrThrow(fromNullable(audit.score), void 0),
5535
5587
  displayValue: audit.displayValue,
5536
5588
  elements: extractElements(audit.details)
5537
5589
  }));
5538
5590
  }
5539
5591
  function processLhr(lhr) {
5540
5592
  let categories = filterMap(categoryIds, (id) => lhr.categories[id]).map((category) => {
5541
- let score = Math.round(getOrThrow(fromNullable(category.score)) * 100) | 0;
5593
+ let score = Math.round(getOrThrow(fromNullable(category.score), void 0) * 100) | 0;
5542
5594
  let topIssues = getTopIssues(category, lhr.audits, 3);
5543
5595
  return {
5544
5596
  id: category.id,
@@ -6024,8 +6076,8 @@ function replaceByName(registry, replacement) {
6024
6076
  })
6025
6077
  };
6026
6078
  }
6027
- function getToolByName(registry, name15) {
6028
- return registry.tools.find((m) => m.name === name15);
6079
+ function getToolByName(registry, name16) {
6080
+ return registry.tools.find((m) => m.name === name16);
6029
6081
  }
6030
6082
  function serializeTool(m) {
6031
6083
  return {
@@ -6039,6 +6091,55 @@ function getToolDefinitions(registry) {
6039
6091
  return registry.tools.map(serializeTool);
6040
6092
  }
6041
6093
 
6094
+ // src/tools/FrontmanAstro__Tool__GetResolvedRoutes.res.mjs
6095
+ var name15 = "get_client_pages";
6096
+ var description14 = `Lists all routes resolved by Astro's router.
6097
+
6098
+ Parameters: None
6099
+
6100
+ Returns routes from Astro's astro:routes:resolved hook, including pages,
6101
+ API endpoints, redirects, content collection routes, and integration-injected
6102
+ routes. Each route includes its pattern, entrypoint, type, origin, params,
6103
+ and prerender status.`;
6104
+ var inputSchema14 = schema2((s2) => ({
6105
+ placeholder: s2.m(option2(bool2))
6106
+ }));
6107
+ var routeEntrySchema = schema2((s2) => ({
6108
+ path: s2.m(string2),
6109
+ file: s2.m(string2),
6110
+ isDynamic: s2.m(bool2),
6111
+ params: s2.m(array2(string2)),
6112
+ type: s2.m(string2),
6113
+ origin: s2.m(string2),
6114
+ isPrerendered: s2.m(bool2)
6115
+ }));
6116
+ var outputSchema14 = array2(routeEntrySchema);
6117
+ function toRouteEntry(route) {
6118
+ return {
6119
+ path: route.pattern,
6120
+ file: route.entrypoint,
6121
+ isDynamic: route.params.length !== 0,
6122
+ params: route.params,
6123
+ type: route.type,
6124
+ origin: route.origin,
6125
+ isPrerendered: route.isPrerendered
6126
+ };
6127
+ }
6128
+ function make4(getRoutes) {
6129
+ let execute14 = async (_ctx, _input) => ({
6130
+ TAG: "Ok",
6131
+ _0: getRoutes().map(toRouteEntry)
6132
+ });
6133
+ return {
6134
+ name: name15,
6135
+ description: description14,
6136
+ inputSchema: inputSchema14,
6137
+ outputSchema: outputSchema14,
6138
+ execute: execute14,
6139
+ visibleToAgent: true
6140
+ };
6141
+ }
6142
+
6042
6143
  // src/FrontmanAstro__ToolRegistry.res.mjs
6043
6144
  var astroTools = [
6044
6145
  {
@@ -6058,7 +6159,7 @@ var astroTools = [
6058
6159
  visibleToAgent: true
6059
6160
  }
6060
6161
  ];
6061
- function make4() {
6162
+ function make5() {
6062
6163
  return replaceByName(addTools(coreTools(), astroTools), {
6063
6164
  name: name4,
6064
6165
  description: description3,
@@ -6068,6 +6169,27 @@ function make4() {
6068
6169
  visibleToAgent: true
6069
6170
  });
6070
6171
  }
6172
+ function makeWithResolvedRoutes(getRoutes) {
6173
+ let resolvedRoutesTool = make4(getRoutes);
6174
+ return replaceByName(addTools(coreTools(), [
6175
+ resolvedRoutesTool,
6176
+ {
6177
+ name: name2,
6178
+ description,
6179
+ inputSchema,
6180
+ outputSchema,
6181
+ execute,
6182
+ visibleToAgent: true
6183
+ }
6184
+ ]), {
6185
+ name: name4,
6186
+ description: description3,
6187
+ inputSchema: inputSchema3,
6188
+ outputSchema: outputSchema3,
6189
+ execute: execute3,
6190
+ visibleToAgent: true
6191
+ });
6192
+ }
6071
6193
 
6072
6194
  // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Dict.js
6073
6195
  var forEachWithKey = ((dict3, f) => {
@@ -7934,12 +8056,12 @@ var toolCallRequestSchema = schema2((s2) => ({
7934
8056
  var protocolVersion = "1.0";
7935
8057
 
7936
8058
  // ../frontman-core/src/FrontmanCore__Server.res.mjs
7937
- async function executeTool(registry, ctx2, name15, $$arguments) {
7938
- let toolModule = getToolByName(registry, name15);
8059
+ async function executeTool(registry, ctx2, name16, $$arguments) {
8060
+ let toolModule = getToolByName(registry, name16);
7939
8061
  if (toolModule === void 0) {
7940
8062
  return {
7941
8063
  TAG: "ToolNotFound",
7942
- _0: name15
8064
+ _0: name16
7943
8065
  };
7944
8066
  }
7945
8067
  let toolCtx_projectRoot = ctx2.projectRoot;
@@ -8288,7 +8410,7 @@ function createMiddleware(config, registry) {
8288
8410
  let resolveSourceLocationPath = basePath + "/resolve-source-location";
8289
8411
  let isApiRoute = path === toolsPath || path === toolsCallPath || path === resolveSourceLocationPath;
8290
8412
  let suffixPrefix = isApiRoute ? void 0 : getSuffixRoutePrefix(path, basePath);
8291
- let originalSuffixPrefix = map(suffixPrefix, (loweredPrefix) => {
8413
+ let originalSuffixPrefix = map2(suffixPrefix, (loweredPrefix) => {
8292
8414
  if (loweredPrefix === "") {
8293
8415
  return "";
8294
8416
  } else {
@@ -8304,7 +8426,7 @@ function createMiddleware(config, registry) {
8304
8426
  if (!isSome(suffixPrefix)) {
8305
8427
  return;
8306
8428
  }
8307
- let prefixPath = getOrThrow(suffixPrefix);
8429
+ let prefixPath = getOrThrow(suffixPrefix, void 0);
8308
8430
  let canonicalPath = getCanonicalRedirect(prefixPath, basePath);
8309
8431
  if (canonicalPath !== void 0) {
8310
8432
  return new Response("", {
@@ -8315,7 +8437,7 @@ function createMiddleware(config, registry) {
8315
8437
  ]]))
8316
8438
  });
8317
8439
  }
8318
- let originalPrefix = getOrThrow(originalSuffixPrefix);
8440
+ let originalPrefix = getOrThrow(originalSuffixPrefix, void 0);
8319
8441
  let entrypointUrl = buildEntrypointUrl(config, req.url, originalPrefix);
8320
8442
  return withCors(serveWithEntrypoint(config, entrypointUrl));
8321
8443
  case "options":
@@ -8353,8 +8475,9 @@ function toMiddlewareConfig(config) {
8353
8475
  frameworkId: "Astro"
8354
8476
  };
8355
8477
  }
8356
- function createMiddleware2(config) {
8357
- let registry = make4();
8478
+ function createMiddleware2(config, routeDiscovery) {
8479
+ let registry;
8480
+ registry = typeof routeDiscovery !== "object" ? make5() : makeWithResolvedRoutes(routeDiscovery.getRoutes);
8358
8481
  let middlewareConfig = toMiddlewareConfig(config);
8359
8482
  return createMiddleware(middlewareConfig, registry);
8360
8483
  }
@@ -8392,7 +8515,7 @@ async function toWebRequest(req) {
8392
8515
  let init = {
8393
8516
  method,
8394
8517
  headers: some(headersDict),
8395
- body: map(body, (b) => b)
8518
+ body: map2(body, (b) => b)
8396
8519
  };
8397
8520
  if (body !== void 0) {
8398
8521
  init["duplex"] = "half";
@@ -8456,16 +8579,41 @@ function adaptToConnect(middleware, basePath) {
8456
8579
  }
8457
8580
 
8458
8581
  // src/FrontmanAstro__Integration.res.mjs
8582
+ var packageJsonSchema = schema2((s2) => ({
8583
+ version: s2.m(string2)
8584
+ }));
8585
+ function getAstroVersion() {
8586
+ let $$require = Nodemodule.createRequire(import.meta.url);
8587
+ let pkgPath = $$require.resolve("astro/package.json");
8588
+ let raw = Fs7.readFileSync(pkgPath, "utf8");
8589
+ return parseJsonStringOrThrow2(raw, packageJsonSchema).version;
8590
+ }
8591
+ function parseMajorVersion(version) {
8592
+ return getOrThrow(flatMap(version.split(".")[0], (s2) => fromString2(s2)), `[Frontman] Failed to parse Astro major version from "` + version + `"`);
8593
+ }
8594
+ function getAstroMajorVersion() {
8595
+ return parseMajorVersion(getAstroVersion());
8596
+ }
8459
8597
  function frontmanPropsInjectionPlugin2(prim) {
8460
8598
  return frontmanPropsInjectionPlugin();
8461
8599
  }
8462
8600
  var annotationCaptureScript2 = annotationCaptureScript;
8601
+ function rehypeContentFile2(prim) {
8602
+ return rehypeContentFile(prim);
8603
+ }
8463
8604
  var icon = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="90 70 230 270" fill="none"><path d="M145.925 316.925C136.175 316.925 129.242 315.517 125.125 312.7C121.008 309.667 118.517 305.875 117.65 301.325C116.783 296.558 116.35 291.792 116.35 287.025V119C116.35 107.733 118.517 100.042 122.85 95.925C127.4 91.5917 135.417 89.425 146.9 89.425H265.85C270.833 89.425 275.492 89.8583 279.825 90.725C284.375 91.5917 288.058 94.0833 290.875 98.2C293.692 102.317 295.1 109.358 295.1 119.325C295.1 129.075 293.583 136.008 290.55 140.125C287.733 144.242 284.05 146.733 279.5 147.6C274.95 148.467 270.183 148.9 265.2 148.9H175.825V177.825H235.625C240.608 177.825 245.05 178.258 248.95 179.125C253.067 179.775 256.208 181.942 258.375 185.625C260.758 189.092 261.95 195.158 261.95 203.825C261.95 212.058 260.758 217.908 258.375 221.375C255.992 224.842 252.742 226.9 248.625 227.55C244.725 228.2 240.283 228.525 235.3 228.525H175.825V287.35C175.825 292.117 175.392 296.775 174.525 301.325C173.658 305.875 171.167 309.667 167.05 312.7C162.933 315.517 155.892 316.925 145.925 316.925Z" fill="currentColor"/></svg>`;
8464
8605
  function getToolbarAppPath() {
8465
8606
  return new URL("./toolbar.js", import.meta.url).pathname;
8466
8607
  }
8467
- function make5(configInput) {
8608
+ function make6(configInput) {
8468
8609
  let config = makeFromObject(configInput);
8610
+ let useResolvedRoutes = parseMajorVersion(getAstroVersion()) >= 5;
8611
+ let resolvedRoutes = {
8612
+ contents: []
8613
+ };
8614
+ let routeDiscovery = useResolvedRoutes ? {
8615
+ getRoutes: () => resolvedRoutes.contents
8616
+ } : "Filesystem";
8469
8617
  return {
8470
8618
  name: "frontman",
8471
8619
  hooks: {
@@ -8476,7 +8624,7 @@ function make5(configInput) {
8476
8624
  if (!ctx2.config.devToolbar.enabled) {
8477
8625
  console.warn("[Frontman] Astro devToolbar is disabled \u2014 element source detection will be limited. Set `devToolbar: { enabled: true }` in your astro.config to enable full component source resolution.");
8478
8626
  }
8479
- let webMiddleware = createMiddleware2(config);
8627
+ let webMiddleware = createMiddleware2(config, routeDiscovery);
8480
8628
  let connectMiddleware = adaptToConnect(webMiddleware, config.basePath);
8481
8629
  let middlewarePlugin_configureServer = (server) => {
8482
8630
  server.middlewares.use(connectMiddleware);
@@ -8493,6 +8641,16 @@ function make5(configInput) {
8493
8641
  ]
8494
8642
  }
8495
8643
  });
8644
+ ctx2.updateConfig({
8645
+ markdown: {
8646
+ rehypePlugins: [[
8647
+ rehypeContentFile2,
8648
+ {
8649
+ projectRoot: config.sourceRoot
8650
+ }
8651
+ ]]
8652
+ }
8653
+ });
8496
8654
  ctx2.addDevToolbarApp({
8497
8655
  id: "frontman:toolbar",
8498
8656
  name: "Frontman",
@@ -8536,7 +8694,10 @@ function make5(configInput) {
8536
8694
  param.toolbar.onAppInitialized("frontman:toolbar", () => {
8537
8695
  console.log("[Frontman] Dev toolbar app initialized");
8538
8696
  });
8539
- }
8697
+ },
8698
+ "astro:routes:resolved": useResolvedRoutes ? (param) => {
8699
+ resolvedRoutes.contents = param.routes;
8700
+ } : void 0
8540
8701
  }
8541
8702
  };
8542
8703
  }
@@ -8545,4 +8706,4 @@ var Config;
8545
8706
  var Middleware;
8546
8707
  var ViteAdapter;
8547
8708
 
8548
- export { Bindings, Config, Middleware, ViteAdapter, annotationCaptureScript2 as annotationCaptureScript, frontmanPropsInjectionPlugin2 as frontmanPropsInjectionPlugin, getToolbarAppPath, icon, make5 as make };
8709
+ export { Bindings, Config, Middleware, ViteAdapter, annotationCaptureScript2 as annotationCaptureScript, frontmanPropsInjectionPlugin2 as frontmanPropsInjectionPlugin, getAstroMajorVersion, getAstroVersion, getToolbarAppPath, icon, make6 as make, packageJsonSchema, parseMajorVersion, rehypeContentFile2 as rehypeContentFile };