@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.
package/dist/index.js CHANGED
@@ -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, {
@@ -74,7 +75,7 @@ function getOrThrow(x, message4) {
74
75
  if (x !== void 0) {
75
76
  return valFromOption(x);
76
77
  } else {
77
- return panic("Option.getOrThrow called for None value");
78
+ return panic(message4 !== void 0 ? message4 : "Option.getOrThrow called for None value");
78
79
  }
79
80
  }
80
81
  function mapOr(opt, $$default, f) {
@@ -122,7 +123,7 @@ var clientCss = "https://app.frontman.sh/frontman.css";
122
123
  var devClientJs = "http://localhost:5173/src/Main.res.mjs";
123
124
 
124
125
  // src/FrontmanAstro__Config.res.mjs
125
- var packageVersion = "0.5.1" ;
126
+ var packageVersion = "0.6.0" ;
126
127
  var host = process.env["FRONTMAN_HOST"];
127
128
  var defaultHost = host !== void 0 ? host : apiHost;
128
129
  var ensureConfig = (function(c2) {
@@ -163,237 +164,6 @@ function makeFromObject(rawConfig) {
163
164
  };
164
165
  }
165
166
 
166
- // src/annotation-capture.mjs
167
- var annotationCaptureScript = `(function() {
168
- var PROPS_PREFIX = '__frontman_props__:';
169
-
170
- function parsePropsPayload(text) {
171
- text = text.trim();
172
- if (text.indexOf(PROPS_PREFIX) !== 0) return null;
173
- try {
174
- var encoded = text.slice(PROPS_PREFIX.length).trim();
175
- return JSON.parse(atob(encoded));
176
- } catch(e) {
177
- return null;
178
- }
179
- }
180
-
181
- function captureAnnotations() {
182
- var annotations = new Map();
183
- var propsMap = new Map();
184
- var pendingProps = [];
185
-
186
- var walker = document.createTreeWalker(
187
- document.documentElement,
188
- NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_ELEMENT,
189
- null
190
- );
191
-
192
- var node;
193
- while (node = walker.nextNode()) {
194
- if (node.nodeType === 8) {
195
- var parsed = parsePropsPayload(node.textContent);
196
- if (parsed) {
197
- pendingProps.push(parsed);
198
- }
199
- } else if (node.nodeType === 1) {
200
- if (pendingProps.length > 0 && node.hasAttribute('data-astro-source-file')) {
201
- propsMap.set(node, pendingProps.slice());
202
- pendingProps = [];
203
- }
204
- }
205
- }
206
-
207
- document.querySelectorAll('[data-astro-source-file]').forEach(function(el) {
208
- var sourceFile = el.getAttribute('data-astro-source-file');
209
- var annotation = {
210
- file: sourceFile,
211
- loc: el.getAttribute('data-astro-source-loc')
212
- };
213
-
214
- var propsChain = propsMap.get(el);
215
-
216
- if (!propsChain) {
217
- var parent = el.parentElement;
218
- var maxSteps = 30;
219
- while (parent && maxSteps-- > 0) {
220
- propsChain = propsMap.get(parent);
221
- if (propsChain) break;
222
- parent = parent.parentElement;
223
- }
224
- }
225
-
226
- if (propsChain && propsChain.length > 0) {
227
- var match = null;
228
- for (var i = 0; i < propsChain.length; i++) {
229
- var entry = propsChain[i];
230
- if (entry.moduleId) {
231
- var entryFile = entry.moduleId.split('/').pop() || '';
232
- var srcFile = sourceFile.split('/').pop() || '';
233
- if (entryFile === srcFile && entryFile !== '') {
234
- match = entry;
235
- break;
236
- }
237
- }
238
- }
239
- if (!match) match = propsChain[0];
240
-
241
- if (match) {
242
- annotation.componentProps = match.props || null;
243
- if (match.displayName) {
244
- annotation.displayName = match.displayName;
245
- }
246
- }
247
- }
248
-
249
- annotations.set(el, annotation);
250
- });
251
-
252
- window.__frontman_annotations__ = {
253
- _map: annotations,
254
- get: function(el) { return annotations.get(el); },
255
- has: function(el) { return annotations.has(el); },
256
- size: function() { return annotations.size; }
257
- };
258
- }
259
-
260
- document.addEventListener('DOMContentLoaded', captureAnnotations);
261
-
262
- var initialLoad = true;
263
- document.addEventListener('astro:page-load', function() {
264
- if (initialLoad) { initialLoad = false; return; }
265
- captureAnnotations();
266
- });
267
- })();`;
268
-
269
- // src/vite-plugin-props-injection.mjs
270
- function frontmanPropsInjectionPlugin() {
271
- return {
272
- name: "frontman:props-injection",
273
- enforce: "pre",
274
- apply: "serve",
275
- // Only apply in SSR (server-side rendering) mode
276
- transform(code, id, options) {
277
- if (!options?.ssr) return null;
278
- if (!id.includes("astro/dist/runtime/server/render/component") && !id.includes("astro/runtime/server/render/component")) {
279
- return null;
280
- }
281
- if (!code.includes("function renderComponent(")) {
282
- console.warn(
283
- "[Frontman] Could not find renderComponent in Astro internals \u2014 component props injection will be disabled. This may happen after an Astro upgrade. File: " + id
284
- );
285
- return null;
286
- }
287
- let transformed = code.replace(
288
- "function renderComponent(",
289
- "function __original_renderComponent("
290
- );
291
- const wrapperCode = `
292
-
293
- // --- Frontman props injection wrapper ---
294
-
295
- function __frontman_safeSerialize(displayName, Component, props) {
296
- try {
297
- const clean = {};
298
- for (const [key, value] of Object.entries(props || {})) {
299
- // Skip internal Astro props (scoped CSS hashes)
300
- if (key.startsWith('data-astro-cid-')) continue;
301
- // Skip class (styling detail, not semantic)
302
- if (key === 'class' || key === 'class:list') continue;
303
-
304
- const t = typeof value;
305
- if (t === 'string' || t === 'number' || t === 'boolean') {
306
- clean[key] = value;
307
- } else if (value === null || value === undefined) {
308
- clean[key] = value;
309
- } else if (Array.isArray(value)) {
310
- try {
311
- const serialized = JSON.stringify(value);
312
- clean[key] = serialized.length < 1000 ? value : '[Array(' + value.length + ')]';
313
- } catch {
314
- clean[key] = '[Array]';
315
- }
316
- } else if (t === 'object') {
317
- try {
318
- const serialized = JSON.stringify(value);
319
- clean[key] = serialized.length < 500 ? value : '{...}';
320
- } catch {
321
- clean[key] = '{...}';
322
- }
323
- }
324
- // Skip functions, symbols, etc.
325
- }
326
-
327
- const entry = { displayName, props: clean };
328
- // Include the component's moduleId (file path) if available
329
- if (Component && Component.moduleId) {
330
- entry.moduleId = Component.moduleId;
331
- }
332
- return JSON.stringify(entry);
333
- } catch {
334
- return null;
335
- }
336
- }
337
-
338
- function __frontman_toBase64(str) {
339
- if (typeof Buffer !== 'undefined') return Buffer.from(str, 'utf-8').toString('base64');
340
- if (typeof btoa === 'function') return btoa(unescape(encodeURIComponent(str)));
341
- return null;
342
- }
343
-
344
- function __frontman_wrapInstance(renderInstance, displayName, Component, props) {
345
- // If no render method (e.g. fragment), pass through
346
- if (!renderInstance || typeof renderInstance.render !== 'function') {
347
- return renderInstance;
348
- }
349
-
350
- const serialized = __frontman_safeSerialize(displayName, Component, props);
351
- if (!serialized) return renderInstance;
352
-
353
- const encoded = __frontman_toBase64(serialized);
354
- if (!encoded) return renderInstance;
355
-
356
- const originalRender = renderInstance.render;
357
-
358
- renderInstance.render = function(destination) {
359
- // Write the props comment BEFORE the component renders.
360
- // This creates a Comment node in the DOM immediately preceding
361
- // the component's first rendered element.
362
- // Guard: markHTMLString is assumed to be in scope from Astro's module.
363
- // If it's missing (e.g., after an Astro upgrade), skip injection gracefully.
364
- if (typeof markHTMLString === 'function') {
365
- destination.write(markHTMLString('<!-- __frontman_props__:' + encoded + ' -->'));
366
- }
367
- return originalRender.call(renderInstance, destination);
368
- };
369
-
370
- return renderInstance;
371
- }
372
-
373
- function renderComponent(result, displayName, Component, props, slots) {
374
- const renderInstance = __original_renderComponent(result, displayName, Component, props, slots);
375
-
376
- // Handle promise (async component resolution)
377
- if (renderInstance && typeof renderInstance.then === 'function') {
378
- return renderInstance.then(function(resolved) {
379
- return __frontman_wrapInstance(resolved, displayName, Component, props);
380
- });
381
- }
382
-
383
- return __frontman_wrapInstance(renderInstance, displayName, Component, props);
384
- }
385
-
386
- // --- End Frontman props injection wrapper ---
387
- `;
388
- transformed += wrapperCode;
389
- return {
390
- code: transformed,
391
- map: null
392
- };
393
- }
394
- };
395
- }
396
-
397
167
  // ../../node_modules/@rescript/runtime/lib/es6/Primitive_int.js
398
168
  function min(x, y) {
399
169
  if (x < y) {
@@ -568,9 +338,9 @@ function stringify(unknown2) {
568
338
  function toExpression(schema3) {
569
339
  let tag = schema3.type;
570
340
  let $$const = schema3.const;
571
- let name15 = schema3.name;
572
- if (name15 !== void 0) {
573
- return name15;
341
+ let name16 = schema3.name;
342
+ if (name16 !== void 0) {
343
+ return name16;
574
344
  }
575
345
  if ($$const !== void 0) {
576
346
  return stringify($$const);
@@ -1609,6 +1379,18 @@ d(sp, "~standard", {
1609
1379
  function parseOrThrow(any, schema3) {
1610
1380
  return operationFn(schema3, 1)(any);
1611
1381
  }
1382
+ function parseJsonStringOrThrow(jsonString2, schema3) {
1383
+ let tmp;
1384
+ try {
1385
+ tmp = JSON.parse(jsonString2);
1386
+ } catch (exn) {
1387
+ throw new SuryError({
1388
+ TAG: "OperationFailed",
1389
+ _0: exn.message
1390
+ }, 1, "");
1391
+ }
1392
+ return parseOrThrow(tmp, schema3);
1393
+ }
1612
1394
  function reverseConvertToJsonOrThrow(value, schema3) {
1613
1395
  return operationFn(schema3, 40)(value);
1614
1396
  }
@@ -1690,10 +1472,10 @@ function isPriority(tagFlag, byKey) {
1690
1472
  }
1691
1473
  }
1692
1474
  function isWiderUnionSchema(schemaAnyOf, inputAnyOf) {
1693
- return inputAnyOf.every((inputSchema14, idx) => {
1475
+ return inputAnyOf.every((inputSchema15, idx) => {
1694
1476
  let schema3 = schemaAnyOf[idx];
1695
- if (schema3 !== void 0 && !(flags[inputSchema14.type] & 9152) && inputSchema14.type === schema3.type) {
1696
- return inputSchema14.const === schema3.const;
1477
+ if (schema3 !== void 0 && !(flags[inputSchema15.type] & 9152) && inputSchema15.type === schema3.type) {
1478
+ return inputSchema15.const === schema3.const;
1697
1479
  } else {
1698
1480
  return false;
1699
1481
  }
@@ -2468,97 +2250,409 @@ function internalToJSONSchema(schema3, defs) {
2468
2250
  if (childSchema.type === "undefined") {
2469
2251
  return;
2470
2252
  }
2471
- items$1.push(internalToJSONSchema(childSchema, defs));
2472
- if (constField in childSchema) {
2473
- literals.push(childSchema.const);
2474
- return;
2253
+ items$1.push(internalToJSONSchema(childSchema, defs));
2254
+ if (constField in childSchema) {
2255
+ literals.push(childSchema.const);
2256
+ return;
2257
+ }
2258
+ });
2259
+ let itemsNumber$1 = items$1.length;
2260
+ let $$default = schema3.default;
2261
+ if ($$default !== void 0) {
2262
+ jsonSchema.default = valFromOption($$default);
2263
+ }
2264
+ if (itemsNumber$1 === 1) {
2265
+ Object.assign(jsonSchema, items$1[0]);
2266
+ } else if (literals.length === itemsNumber$1) {
2267
+ jsonSchema.enum = literals;
2268
+ } else {
2269
+ jsonSchema.anyOf = items$1;
2270
+ }
2271
+ break;
2272
+ case "ref":
2273
+ let ref = schema3.$ref;
2274
+ if (ref === defsPath + jsonName) ; else {
2275
+ jsonSchema.$ref = ref;
2276
+ }
2277
+ break;
2278
+ default:
2279
+ throw new Error(`[Sury] Unexpected schema type`);
2280
+ }
2281
+ let m = schema3.description;
2282
+ if (m !== void 0) {
2283
+ jsonSchema.description = m;
2284
+ }
2285
+ let m$1 = schema3.title;
2286
+ if (m$1 !== void 0) {
2287
+ jsonSchema.title = m$1;
2288
+ }
2289
+ let deprecated = schema3.deprecated;
2290
+ if (deprecated !== void 0) {
2291
+ jsonSchema.deprecated = deprecated;
2292
+ }
2293
+ let examples = schema3.examples;
2294
+ if (examples !== void 0) {
2295
+ jsonSchema.examples = examples;
2296
+ }
2297
+ let schemaDefs = schema3.$defs;
2298
+ if (schemaDefs !== void 0) {
2299
+ Object.assign(defs, schemaDefs);
2300
+ }
2301
+ let metadataRawSchema = schema3[jsonSchemaMetadataId];
2302
+ if (metadataRawSchema !== void 0) {
2303
+ Object.assign(jsonSchema, metadataRawSchema);
2304
+ }
2305
+ return jsonSchema;
2306
+ }
2307
+ function toJSONSchema(schema3) {
2308
+ jsonableValidation(schema3, schema3, "", 8);
2309
+ let defs = {};
2310
+ let jsonSchema = internalToJSONSchema(schema3, defs);
2311
+ delete defs.JSON;
2312
+ let defsKeys = Object.keys(defs);
2313
+ if (defsKeys.length) {
2314
+ defsKeys.forEach((key) => {
2315
+ defs[key] = internalToJSONSchema(defs[key], 0);
2316
+ });
2317
+ jsonSchema.$defs = defs;
2318
+ }
2319
+ return jsonSchema;
2320
+ }
2321
+ var literal = js_schema;
2322
+ var array = factory$2;
2323
+ var dict = factory$3;
2324
+ var union = factory;
2325
+ var schema = factory$4;
2326
+
2327
+ // ../../node_modules/sury/src/S.res.mjs
2328
+ var $$Error2 = $$Error;
2329
+ var string2 = string;
2330
+ var bool2 = bool;
2331
+ var int2 = int;
2332
+ var float2 = float;
2333
+ var json2 = json;
2334
+ var enableJson2 = enableJson;
2335
+ var literal2 = literal;
2336
+ var array2 = array;
2337
+ var dict2 = dict;
2338
+ var option2 = option;
2339
+ var union2 = union;
2340
+ var parseOrThrow2 = parseOrThrow;
2341
+ var parseJsonStringOrThrow2 = parseJsonStringOrThrow;
2342
+ var reverseConvertToJsonOrThrow2 = reverseConvertToJsonOrThrow;
2343
+ var schema2 = schema;
2344
+ var toJSONSchema2 = toJSONSchema;
2345
+
2346
+ // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Array.js
2347
+ function make2(length3, x) {
2348
+ if (length3 <= 0) {
2349
+ return [];
2350
+ }
2351
+ let arr = new Array(length3);
2352
+ arr.fill(x);
2353
+ return arr;
2354
+ }
2355
+ function fromInitializer(length3, f) {
2356
+ if (length3 <= 0) {
2357
+ return [];
2358
+ }
2359
+ let arr = new Array(length3);
2360
+ for (let i = 0; i < length3; ++i) {
2361
+ arr[i] = f(i);
2362
+ }
2363
+ return arr;
2364
+ }
2365
+ function reduce(arr, init, f) {
2366
+ return arr.reduce(f, init);
2367
+ }
2368
+ function reduceWithIndex(arr, init, f) {
2369
+ return arr.reduce(f, init);
2370
+ }
2371
+ function filterMap(a, f) {
2372
+ let l = a.length;
2373
+ let r = new Array(l);
2374
+ let j2 = 0;
2375
+ for (let i = 0; i < l; ++i) {
2376
+ let v = a[i];
2377
+ let v$1 = f(v);
2378
+ if (v$1 !== void 0) {
2379
+ r[j2] = valFromOption(v$1);
2380
+ j2 = j2 + 1 | 0;
2381
+ }
2382
+ }
2383
+ r.length = j2;
2384
+ return r;
2385
+ }
2386
+
2387
+ // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Int.js
2388
+ function fromString2(x, radix) {
2389
+ let maybeInt = parseInt(x);
2390
+ if (Number.isNaN(maybeInt) || maybeInt > 2147483647 || maybeInt < -2147483648) {
2391
+ return;
2392
+ } else {
2393
+ return maybeInt | 0;
2394
+ }
2395
+ }
2396
+
2397
+ // src/annotation-capture.mjs
2398
+ var annotationCaptureScript = `(function() {
2399
+ var PROPS_PREFIX = '__frontman_props__:';
2400
+
2401
+ function parsePropsPayload(text) {
2402
+ text = text.trim();
2403
+ if (text.indexOf(PROPS_PREFIX) !== 0) return null;
2404
+ try {
2405
+ var encoded = text.slice(PROPS_PREFIX.length).trim();
2406
+ return JSON.parse(atob(encoded));
2407
+ } catch(e) {
2408
+ return null;
2409
+ }
2410
+ }
2411
+
2412
+ function captureAnnotations() {
2413
+ var annotations = new Map();
2414
+ var propsMap = new Map();
2415
+ var pendingProps = [];
2416
+ var contentFile = null;
2417
+
2418
+ var walker = document.createTreeWalker(
2419
+ document.documentElement,
2420
+ NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_ELEMENT,
2421
+ null
2422
+ );
2423
+
2424
+ var node;
2425
+ while (node = walker.nextNode()) {
2426
+ if (node.nodeType === 8) {
2427
+ var text = node.textContent;
2428
+ var parsed = parsePropsPayload(text);
2429
+ if (parsed) {
2430
+ pendingProps.push(parsed);
2431
+ } else if (text && text.trim().indexOf('__frontman_content_file__:') === 0) {
2432
+ contentFile = text.trim().slice('__frontman_content_file__:'.length).trim();
2433
+ }
2434
+ } else if (node.nodeType === 1) {
2435
+ if (pendingProps.length > 0 && node.hasAttribute('data-astro-source-file')) {
2436
+ propsMap.set(node, pendingProps.slice());
2437
+ pendingProps = [];
2438
+ }
2439
+ }
2440
+ }
2441
+
2442
+ document.querySelectorAll('[data-astro-source-file]').forEach(function(el) {
2443
+ var sourceFile = el.getAttribute('data-astro-source-file');
2444
+ var annotation = {
2445
+ file: sourceFile,
2446
+ loc: el.getAttribute('data-astro-source-loc')
2447
+ };
2448
+
2449
+ var propsChain = propsMap.get(el);
2450
+
2451
+ if (!propsChain) {
2452
+ var parent = el.parentElement;
2453
+ var maxSteps = 30;
2454
+ while (parent && maxSteps-- > 0) {
2455
+ propsChain = propsMap.get(parent);
2456
+ if (propsChain) break;
2457
+ parent = parent.parentElement;
2458
+ }
2459
+ }
2460
+
2461
+ if (propsChain && propsChain.length > 0) {
2462
+ var match = null;
2463
+ for (var i = 0; i < propsChain.length; i++) {
2464
+ var entry = propsChain[i];
2465
+ if (entry.moduleId) {
2466
+ var entryFile = entry.moduleId.split('/').pop() || '';
2467
+ var srcFile = sourceFile.split('/').pop() || '';
2468
+ if (entryFile === srcFile && entryFile !== '') {
2469
+ match = entry;
2470
+ break;
2471
+ }
2472
+ }
2473
+ }
2474
+ if (!match) match = propsChain[0];
2475
+
2476
+ if (match) {
2477
+ annotation.componentProps = match.props || null;
2478
+ if (match.displayName) {
2479
+ annotation.displayName = match.displayName;
2480
+ }
2481
+ }
2482
+ }
2483
+
2484
+ annotations.set(el, annotation);
2485
+ });
2486
+
2487
+ window.__frontman_annotations__ = {
2488
+ _map: annotations,
2489
+ get: function(el) { return annotations.get(el); },
2490
+ has: function(el) { return annotations.has(el); },
2491
+ size: function() { return annotations.size; },
2492
+ contentFile: contentFile
2493
+ };
2494
+ }
2495
+
2496
+ document.addEventListener('DOMContentLoaded', captureAnnotations);
2497
+
2498
+ var initialLoad = true;
2499
+ document.addEventListener('astro:page-load', function() {
2500
+ if (initialLoad) { initialLoad = false; return; }
2501
+ captureAnnotations();
2502
+ });
2503
+ })();`;
2504
+
2505
+ // src/rehype-content-file.mjs
2506
+ function rehypeContentFile(options) {
2507
+ var raw = options && options.projectRoot || "";
2508
+ var projectRoot = typeof raw === "string" ? raw : raw.pathname || "";
2509
+ if (projectRoot.endsWith("/")) {
2510
+ projectRoot = projectRoot.slice(0, -1);
2511
+ }
2512
+ return function transformer(tree, file) {
2513
+ if (!file || !file.path) {
2514
+ return;
2515
+ }
2516
+ var absolute = file.path;
2517
+ var relative = absolute;
2518
+ if (projectRoot && absolute.startsWith(projectRoot + "/")) {
2519
+ relative = absolute.slice(projectRoot.length + 1);
2520
+ }
2521
+ var comment = {
2522
+ type: "comment",
2523
+ value: " __frontman_content_file__:" + relative + " "
2524
+ };
2525
+ tree.children.unshift(comment);
2526
+ };
2527
+ }
2528
+
2529
+ // src/vite-plugin-props-injection.mjs
2530
+ function frontmanPropsInjectionPlugin() {
2531
+ return {
2532
+ name: "frontman:props-injection",
2533
+ enforce: "pre",
2534
+ apply: "serve",
2535
+ // Only apply in SSR (server-side rendering) mode
2536
+ transform(code, id, options) {
2537
+ if (!options?.ssr) return null;
2538
+ if (!id.includes("astro/dist/runtime/server/render/component") && !id.includes("astro/runtime/server/render/component")) {
2539
+ return null;
2540
+ }
2541
+ if (!code.includes("function renderComponent(")) {
2542
+ console.warn(
2543
+ "[Frontman] Could not find renderComponent in Astro internals \u2014 component props injection will be disabled. This may happen after an Astro upgrade. File: " + id
2544
+ );
2545
+ return null;
2546
+ }
2547
+ let transformed = code.replace(
2548
+ "function renderComponent(",
2549
+ "function __original_renderComponent("
2550
+ );
2551
+ const wrapperCode = `
2552
+
2553
+ // --- Frontman props injection wrapper ---
2554
+
2555
+ function __frontman_safeSerialize(displayName, Component, props) {
2556
+ try {
2557
+ const clean = {};
2558
+ for (const [key, value] of Object.entries(props || {})) {
2559
+ // Skip internal Astro props (scoped CSS hashes)
2560
+ if (key.startsWith('data-astro-cid-')) continue;
2561
+ // Skip class (styling detail, not semantic)
2562
+ if (key === 'class' || key === 'class:list') continue;
2563
+
2564
+ const t = typeof value;
2565
+ if (t === 'string' || t === 'number' || t === 'boolean') {
2566
+ clean[key] = value;
2567
+ } else if (value === null || value === undefined) {
2568
+ clean[key] = value;
2569
+ } else if (Array.isArray(value)) {
2570
+ try {
2571
+ const serialized = JSON.stringify(value);
2572
+ clean[key] = serialized.length < 1000 ? value : '[Array(' + value.length + ')]';
2573
+ } catch {
2574
+ clean[key] = '[Array]';
2575
+ }
2576
+ } else if (t === 'object') {
2577
+ try {
2578
+ const serialized = JSON.stringify(value);
2579
+ clean[key] = serialized.length < 500 ? value : '{...}';
2580
+ } catch {
2581
+ clean[key] = '{...}';
2475
2582
  }
2476
- });
2477
- let itemsNumber$1 = items$1.length;
2478
- let $$default = schema3.default;
2479
- if ($$default !== void 0) {
2480
- jsonSchema.default = valFromOption($$default);
2481
- }
2482
- if (itemsNumber$1 === 1) {
2483
- Object.assign(jsonSchema, items$1[0]);
2484
- } else if (literals.length === itemsNumber$1) {
2485
- jsonSchema.enum = literals;
2486
- } else {
2487
- jsonSchema.anyOf = items$1;
2488
- }
2489
- break;
2490
- case "ref":
2491
- let ref = schema3.$ref;
2492
- if (ref === defsPath + jsonName) ; else {
2493
- jsonSchema.$ref = ref;
2494
2583
  }
2495
- break;
2496
- default:
2497
- throw new Error(`[Sury] Unexpected schema type`);
2498
- }
2499
- let m = schema3.description;
2500
- if (m !== void 0) {
2501
- jsonSchema.description = m;
2502
- }
2503
- let m$1 = schema3.title;
2504
- if (m$1 !== void 0) {
2505
- jsonSchema.title = m$1;
2506
- }
2507
- let deprecated = schema3.deprecated;
2508
- if (deprecated !== void 0) {
2509
- jsonSchema.deprecated = deprecated;
2510
- }
2511
- let examples = schema3.examples;
2512
- if (examples !== void 0) {
2513
- jsonSchema.examples = examples;
2514
- }
2515
- let schemaDefs = schema3.$defs;
2516
- if (schemaDefs !== void 0) {
2517
- Object.assign(defs, schemaDefs);
2584
+ // Skip functions, symbols, etc.
2585
+ }
2586
+
2587
+ const entry = { displayName, props: clean };
2588
+ // Include the component's moduleId (file path) if available
2589
+ if (Component && Component.moduleId) {
2590
+ entry.moduleId = Component.moduleId;
2591
+ }
2592
+ return JSON.stringify(entry);
2593
+ } catch {
2594
+ return null;
2518
2595
  }
2519
- let metadataRawSchema = schema3[jsonSchemaMetadataId];
2520
- if (metadataRawSchema !== void 0) {
2521
- Object.assign(jsonSchema, metadataRawSchema);
2596
+ }
2597
+
2598
+ function __frontman_toBase64(str) {
2599
+ if (typeof Buffer !== 'undefined') return Buffer.from(str, 'utf-8').toString('base64');
2600
+ if (typeof btoa === 'function') return btoa(unescape(encodeURIComponent(str)));
2601
+ return null;
2602
+ }
2603
+
2604
+ function __frontman_wrapInstance(renderInstance, displayName, Component, props) {
2605
+ // If no render method (e.g. fragment), pass through
2606
+ if (!renderInstance || typeof renderInstance.render !== 'function') {
2607
+ return renderInstance;
2522
2608
  }
2523
- return jsonSchema;
2609
+
2610
+ const serialized = __frontman_safeSerialize(displayName, Component, props);
2611
+ if (!serialized) return renderInstance;
2612
+
2613
+ const encoded = __frontman_toBase64(serialized);
2614
+ if (!encoded) return renderInstance;
2615
+
2616
+ const originalRender = renderInstance.render;
2617
+
2618
+ renderInstance.render = function(destination) {
2619
+ // Write the props comment BEFORE the component renders.
2620
+ // This creates a Comment node in the DOM immediately preceding
2621
+ // the component's first rendered element.
2622
+ // Guard: markHTMLString is assumed to be in scope from Astro's module.
2623
+ // If it's missing (e.g., after an Astro upgrade), skip injection gracefully.
2624
+ if (typeof markHTMLString === 'function') {
2625
+ destination.write(markHTMLString('<!-- __frontman_props__:' + encoded + ' -->'));
2626
+ }
2627
+ return originalRender.call(renderInstance, destination);
2628
+ };
2629
+
2630
+ return renderInstance;
2524
2631
  }
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);
2632
+
2633
+ function renderComponent(result, displayName, Component, props, slots) {
2634
+ const renderInstance = __original_renderComponent(result, displayName, Component, props, slots);
2635
+
2636
+ // Handle promise (async component resolution)
2637
+ if (renderInstance && typeof renderInstance.then === 'function') {
2638
+ return renderInstance.then(function(resolved) {
2639
+ return __frontman_wrapInstance(resolved, displayName, Component, props);
2534
2640
  });
2535
- jsonSchema.$defs = defs;
2536
2641
  }
2537
- return jsonSchema;
2642
+
2643
+ return __frontman_wrapInstance(renderInstance, displayName, Component, props);
2538
2644
  }
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
2645
 
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;
2646
+ // --- End Frontman props injection wrapper ---
2647
+ `;
2648
+ transformed += wrapperCode;
2649
+ return {
2650
+ code: transformed,
2651
+ map: null
2652
+ };
2653
+ }
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) {
@@ -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;
@@ -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) => {
@@ -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);
@@ -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;
@@ -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
  }
@@ -8456,13 +8579,35 @@ 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
+ }
8459
8594
  var annotationCaptureScript2 = annotationCaptureScript;
8595
+ function rehypeContentFile2(prim) {
8596
+ return rehypeContentFile(prim);
8597
+ }
8460
8598
  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>`;
8461
8599
  function getToolbarAppPath() {
8462
8600
  return new URL("./toolbar.js", import.meta.url).pathname;
8463
8601
  }
8464
- function make5(configInput) {
8602
+ function make6(configInput) {
8465
8603
  let config = makeFromObject(configInput);
8604
+ let useResolvedRoutes = parseMajorVersion(getAstroVersion()) >= 5;
8605
+ let resolvedRoutes = {
8606
+ contents: []
8607
+ };
8608
+ let routeDiscovery = useResolvedRoutes ? {
8609
+ getRoutes: () => resolvedRoutes.contents
8610
+ } : "Filesystem";
8466
8611
  return {
8467
8612
  name: "frontman",
8468
8613
  hooks: {
@@ -8473,7 +8618,7 @@ function make5(configInput) {
8473
8618
  if (!ctx2.config.devToolbar.enabled) {
8474
8619
  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.");
8475
8620
  }
8476
- let webMiddleware = createMiddleware2(config);
8621
+ let webMiddleware = createMiddleware2(config, routeDiscovery);
8477
8622
  let connectMiddleware = adaptToConnect(webMiddleware, config.basePath);
8478
8623
  let middlewarePlugin_configureServer = (server) => {
8479
8624
  server.middlewares.use(connectMiddleware);
@@ -8490,6 +8635,16 @@ function make5(configInput) {
8490
8635
  ]
8491
8636
  }
8492
8637
  });
8638
+ ctx2.updateConfig({
8639
+ markdown: {
8640
+ rehypePlugins: [[
8641
+ rehypeContentFile2,
8642
+ {
8643
+ projectRoot: config.sourceRoot
8644
+ }
8645
+ ]]
8646
+ }
8647
+ });
8493
8648
  ctx2.addDevToolbarApp({
8494
8649
  id: "frontman:toolbar",
8495
8650
  name: "Frontman",
@@ -8533,13 +8688,16 @@ function make5(configInput) {
8533
8688
  param.toolbar.onAppInitialized("frontman:toolbar", () => {
8534
8689
  console.log("[Frontman] Dev toolbar app initialized");
8535
8690
  });
8536
- }
8691
+ },
8692
+ "astro:routes:resolved": useResolvedRoutes ? (param) => {
8693
+ resolvedRoutes.contents = param.routes;
8694
+ } : void 0
8537
8695
  }
8538
8696
  };
8539
8697
  }
8540
8698
 
8541
8699
  // src/FrontmanAstro.res.mjs
8542
- var frontmanIntegration = make5;
8700
+ var frontmanIntegration = make6;
8543
8701
 
8544
8702
  // index.mjs
8545
8703
  var index_default = frontmanIntegration;