@frontman-ai/astro 0.2.1 → 0.2.3

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
@@ -382,25 +382,6 @@ function div(x, y) {
382
382
  return x / y | 0;
383
383
  }
384
384
 
385
- // ../../node_modules/@rescript/runtime/lib/es6/Belt_Array.js
386
- function concatMany(arrs) {
387
- let lenArrs = arrs.length;
388
- let totalLen = 0;
389
- for (let i = 0; i < lenArrs; ++i) {
390
- totalLen = totalLen + arrs[i].length | 0;
391
- }
392
- let result = new Array(totalLen);
393
- totalLen = 0;
394
- for (let j2 = 0; j2 < lenArrs; ++j2) {
395
- let cur = arrs[j2];
396
- for (let k2 = 0, k_finish = cur.length; k2 < k_finish; ++k2) {
397
- result[totalLen] = cur[k2];
398
- totalLen = totalLen + 1 | 0;
399
- }
400
- }
401
- return result;
402
- }
403
-
404
385
  // ../../node_modules/@rescript/runtime/lib/es6/Primitive_exceptions.js
405
386
  function isExtension(e) {
406
387
  if (e == null) {
@@ -4575,7 +4556,8 @@ var ToolNames = {
4575
4556
  searchFiles: "search_files",
4576
4557
  grep: "grep",
4577
4558
  fileExists: "file_exists",
4578
- loadAgentInstructions: "load_agent_instructions"};
4559
+ loadAgentInstructions: "load_agent_instructions",
4560
+ lighthouse: "lighthouse"};
4579
4561
 
4580
4562
  // ../frontman-core/src/tools/FrontmanCore__Tool__Grep.res.mjs
4581
4563
  var name2 = ToolNames.grep;
@@ -5211,40 +5193,19 @@ var launch = ((options) => import('module').then(({ createRequire }) => {
5211
5193
  throw e;
5212
5194
  }
5213
5195
  }));
5214
-
5215
- // ../frontman-core/src/tools/FrontmanCore__Tool__Lighthouse.res.mjs
5216
- var rewriteUrlForRuntime = ((url2) => {
5217
- const override = process.env.FRONTMAN_LIGHTHOUSE_DEVPOD_LOCALHOST;
5218
- const worktreeId = process.env.WORKTREE_ID;
5219
- const overrideLower = typeof override === "string" ? override.toLowerCase() : "";
5220
- const devpodMode = overrideLower === "1" || overrideLower === "true" || overrideLower === "yes" || overrideLower === "on" || typeof worktreeId === "string";
5221
- if (!devpodMode) {
5222
- return url2;
5223
- }
5224
- let parsed;
5196
+ async function killSafely(chrome) {
5225
5197
  try {
5226
- parsed = new URL(url2);
5227
- } catch {
5228
- return url2;
5229
- }
5230
- const host2 = parsed.hostname;
5231
- const mapToLocalhost = (port2, protocol) => {
5232
- parsed.protocol = protocol;
5233
- parsed.hostname = "127.0.0.1";
5234
- parsed.port = String(port2);
5235
- return parsed.toString();
5236
- };
5237
- if (host2.endsWith(".nextjs.frontman.local")) {
5238
- return mapToLocalhost(3e3, "http:");
5239
- }
5240
- if (host2.endsWith(".vite.frontman.local")) {
5241
- return mapToLocalhost(5173, "http:");
5242
- }
5243
- if (host2.endsWith(".api.frontman.local")) {
5244
- return mapToLocalhost(4e3, "https:");
5198
+ return await chrome.kill();
5199
+ } catch (raw_exn) {
5200
+ let exn = internalToException(raw_exn);
5201
+ let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
5202
+ console.error(`[chrome-launcher] Failed to kill Chrome (pid ` + chrome.pid.toString() + `): ` + msg);
5203
+ return;
5245
5204
  }
5246
- return url2;
5247
- });
5205
+ }
5206
+
5207
+ // ../frontman-core/src/tools/FrontmanCore__Tool__Lighthouse.res.mjs
5208
+ var name7 = ToolNames.lighthouse;
5248
5209
  var inputSchema6 = schema2((s2) => ({
5249
5210
  url: s2.m(string2),
5250
5211
  preset: s2.m(option2(string2))
@@ -5275,21 +5236,6 @@ var categoryIds = [
5275
5236
  "best-practices",
5276
5237
  "seo"
5277
5238
  ];
5278
- function getErrorMessage(exn) {
5279
- let jsError = fromException(exn);
5280
- if (jsError === void 0) {
5281
- return String(exn);
5282
- }
5283
- let jsError$1 = valFromOption(jsError);
5284
- let message3 = getOr(message2(jsError$1), "Unknown error");
5285
- let stack2 = jsError$1.stack;
5286
- if (stack2 !== void 0) {
5287
- return message3 + `
5288
- ` + stack2;
5289
- } else {
5290
- return message3;
5291
- }
5292
- }
5293
5239
  function getTopIssues(category, audits, maxIssues) {
5294
5240
  return filterMap(category.auditRefs, (ref) => audits[ref.id]).filter((audit) => {
5295
5241
  let score = audit.score;
@@ -5333,13 +5279,6 @@ function processLhr(lhr) {
5333
5279
  warnings: lhr.runWarnings
5334
5280
  };
5335
5281
  }
5336
- async function killChrome(chrome) {
5337
- try {
5338
- return await chrome.kill();
5339
- } catch (exn) {
5340
- return;
5341
- }
5342
- }
5343
5282
  async function runLighthouse(chrome, url2, preset) {
5344
5283
  let port2 = chrome.port;
5345
5284
  let flags_port = port2;
@@ -5362,7 +5301,7 @@ async function runLighthouse(chrome, url2, preset) {
5362
5301
  };
5363
5302
  try {
5364
5303
  let runnerResult = await run(url2, flags2);
5365
- await killChrome(chrome);
5304
+ await killSafely(chrome);
5366
5305
  if (runnerResult == null) {
5367
5306
  return {
5368
5307
  TAG: "Error",
@@ -5376,8 +5315,8 @@ async function runLighthouse(chrome, url2, preset) {
5376
5315
  }
5377
5316
  } catch (raw_exn) {
5378
5317
  let exn = internalToException(raw_exn);
5379
- await killChrome(chrome);
5380
- let msg = getErrorMessage(exn);
5318
+ await killSafely(chrome);
5319
+ let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
5381
5320
  return {
5382
5321
  TAG: "Error",
5383
5322
  _0: `Lighthouse audit failed: ` + msg
@@ -5386,7 +5325,6 @@ async function runLighthouse(chrome, url2, preset) {
5386
5325
  }
5387
5326
  async function execute6(_ctx, input) {
5388
5327
  let preset = getOr(input.preset, "desktop");
5389
- let auditUrl = rewriteUrlForRuntime(input.url);
5390
5328
  switch (preset) {
5391
5329
  case "desktop":
5392
5330
  case "mobile":
@@ -5406,41 +5344,16 @@ async function execute6(_ctx, input) {
5406
5344
  "--disable-dev-shm-usage"
5407
5345
  ]
5408
5346
  });
5409
- let result = await runLighthouse(chrome, auditUrl, preset);
5410
- if (result.TAG !== "Ok") {
5411
- return result;
5412
- }
5413
- let out = result._0;
5414
- if (auditUrl === input.url) {
5415
- return {
5416
- TAG: "Ok",
5417
- _0: out
5418
- };
5419
- }
5420
- let warning = `DevPod mode: audited local URL ` + auditUrl + ` instead of ` + input.url + `.`;
5421
- return {
5422
- TAG: "Ok",
5423
- _0: {
5424
- url: input.url,
5425
- fetchTime: out.fetchTime,
5426
- categories: out.categories,
5427
- overallScore: out.overallScore,
5428
- warnings: concatMany([
5429
- [warning],
5430
- out.warnings
5431
- ])
5432
- }
5433
- };
5347
+ return await runLighthouse(chrome, input.url, preset);
5434
5348
  } catch (raw_exn) {
5435
5349
  let exn = internalToException(raw_exn);
5436
- let msg = getErrorMessage(exn);
5350
+ let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
5437
5351
  return {
5438
5352
  TAG: "Error",
5439
5353
  _0: `Failed to launch Chrome: ` + msg + `. Make sure Chrome is installed on the system.`
5440
5354
  };
5441
5355
  }
5442
5356
  }
5443
- var name7 = "lighthouse";
5444
5357
  var description6 = `Runs a Lighthouse audit on a URL to analyze performance, accessibility, best practices, and SEO.
5445
5358
 
5446
5359
  WHEN TO USE THIS TOOL:
@@ -6462,8 +6375,9 @@ function make3(configInput) {
6462
6375
  name: "frontman",
6463
6376
  hooks: {
6464
6377
  "astro:config:setup": (ctx2) => {
6465
- if (ctx2.command === "dev") {
6466
- if (!ctx2.config.devToolbar.enabled) {
6378
+ let match = ctx2.command;
6379
+ if (match === "dev") {
6380
+ if (ctx2.config.devToolbar.enabled) ; else {
6467
6381
  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.");
6468
6382
  }
6469
6383
  ctx2.updateConfig({
@@ -382,25 +382,6 @@ function div(x, y) {
382
382
  return x / y | 0;
383
383
  }
384
384
 
385
- // ../../node_modules/@rescript/runtime/lib/es6/Belt_Array.js
386
- function concatMany(arrs) {
387
- let lenArrs = arrs.length;
388
- let totalLen = 0;
389
- for (let i = 0; i < lenArrs; ++i) {
390
- totalLen = totalLen + arrs[i].length | 0;
391
- }
392
- let result = new Array(totalLen);
393
- totalLen = 0;
394
- for (let j2 = 0; j2 < lenArrs; ++j2) {
395
- let cur = arrs[j2];
396
- for (let k2 = 0, k_finish = cur.length; k2 < k_finish; ++k2) {
397
- result[totalLen] = cur[k2];
398
- totalLen = totalLen + 1 | 0;
399
- }
400
- }
401
- return result;
402
- }
403
-
404
385
  // ../../node_modules/@rescript/runtime/lib/es6/Primitive_exceptions.js
405
386
  function isExtension(e) {
406
387
  if (e == null) {
@@ -4575,7 +4556,8 @@ var ToolNames = {
4575
4556
  searchFiles: "search_files",
4576
4557
  grep: "grep",
4577
4558
  fileExists: "file_exists",
4578
- loadAgentInstructions: "load_agent_instructions"};
4559
+ loadAgentInstructions: "load_agent_instructions",
4560
+ lighthouse: "lighthouse"};
4579
4561
 
4580
4562
  // ../frontman-core/src/tools/FrontmanCore__Tool__Grep.res.mjs
4581
4563
  var name2 = ToolNames.grep;
@@ -5211,40 +5193,19 @@ var launch = ((options) => import('module').then(({ createRequire }) => {
5211
5193
  throw e;
5212
5194
  }
5213
5195
  }));
5214
-
5215
- // ../frontman-core/src/tools/FrontmanCore__Tool__Lighthouse.res.mjs
5216
- var rewriteUrlForRuntime = ((url2) => {
5217
- const override = process.env.FRONTMAN_LIGHTHOUSE_DEVPOD_LOCALHOST;
5218
- const worktreeId = process.env.WORKTREE_ID;
5219
- const overrideLower = typeof override === "string" ? override.toLowerCase() : "";
5220
- const devpodMode = overrideLower === "1" || overrideLower === "true" || overrideLower === "yes" || overrideLower === "on" || typeof worktreeId === "string";
5221
- if (!devpodMode) {
5222
- return url2;
5223
- }
5224
- let parsed;
5196
+ async function killSafely(chrome) {
5225
5197
  try {
5226
- parsed = new URL(url2);
5227
- } catch {
5228
- return url2;
5229
- }
5230
- const host2 = parsed.hostname;
5231
- const mapToLocalhost = (port2, protocol) => {
5232
- parsed.protocol = protocol;
5233
- parsed.hostname = "127.0.0.1";
5234
- parsed.port = String(port2);
5235
- return parsed.toString();
5236
- };
5237
- if (host2.endsWith(".nextjs.frontman.local")) {
5238
- return mapToLocalhost(3e3, "http:");
5239
- }
5240
- if (host2.endsWith(".vite.frontman.local")) {
5241
- return mapToLocalhost(5173, "http:");
5242
- }
5243
- if (host2.endsWith(".api.frontman.local")) {
5244
- return mapToLocalhost(4e3, "https:");
5198
+ return await chrome.kill();
5199
+ } catch (raw_exn) {
5200
+ let exn = internalToException(raw_exn);
5201
+ let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
5202
+ console.error(`[chrome-launcher] Failed to kill Chrome (pid ` + chrome.pid.toString() + `): ` + msg);
5203
+ return;
5245
5204
  }
5246
- return url2;
5247
- });
5205
+ }
5206
+
5207
+ // ../frontman-core/src/tools/FrontmanCore__Tool__Lighthouse.res.mjs
5208
+ var name7 = ToolNames.lighthouse;
5248
5209
  var inputSchema6 = schema2((s2) => ({
5249
5210
  url: s2.m(string2),
5250
5211
  preset: s2.m(option2(string2))
@@ -5275,21 +5236,6 @@ var categoryIds = [
5275
5236
  "best-practices",
5276
5237
  "seo"
5277
5238
  ];
5278
- function getErrorMessage(exn) {
5279
- let jsError = fromException(exn);
5280
- if (jsError === void 0) {
5281
- return String(exn);
5282
- }
5283
- let jsError$1 = valFromOption(jsError);
5284
- let message3 = getOr(message2(jsError$1), "Unknown error");
5285
- let stack2 = jsError$1.stack;
5286
- if (stack2 !== void 0) {
5287
- return message3 + `
5288
- ` + stack2;
5289
- } else {
5290
- return message3;
5291
- }
5292
- }
5293
5239
  function getTopIssues(category, audits, maxIssues) {
5294
5240
  return filterMap(category.auditRefs, (ref) => audits[ref.id]).filter((audit) => {
5295
5241
  let score = audit.score;
@@ -5333,13 +5279,6 @@ function processLhr(lhr) {
5333
5279
  warnings: lhr.runWarnings
5334
5280
  };
5335
5281
  }
5336
- async function killChrome(chrome) {
5337
- try {
5338
- return await chrome.kill();
5339
- } catch (exn) {
5340
- return;
5341
- }
5342
- }
5343
5282
  async function runLighthouse(chrome, url2, preset) {
5344
5283
  let port2 = chrome.port;
5345
5284
  let flags_port = port2;
@@ -5362,7 +5301,7 @@ async function runLighthouse(chrome, url2, preset) {
5362
5301
  };
5363
5302
  try {
5364
5303
  let runnerResult = await run(url2, flags2);
5365
- await killChrome(chrome);
5304
+ await killSafely(chrome);
5366
5305
  if (runnerResult == null) {
5367
5306
  return {
5368
5307
  TAG: "Error",
@@ -5376,8 +5315,8 @@ async function runLighthouse(chrome, url2, preset) {
5376
5315
  }
5377
5316
  } catch (raw_exn) {
5378
5317
  let exn = internalToException(raw_exn);
5379
- await killChrome(chrome);
5380
- let msg = getErrorMessage(exn);
5318
+ await killSafely(chrome);
5319
+ let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
5381
5320
  return {
5382
5321
  TAG: "Error",
5383
5322
  _0: `Lighthouse audit failed: ` + msg
@@ -5386,7 +5325,6 @@ async function runLighthouse(chrome, url2, preset) {
5386
5325
  }
5387
5326
  async function execute6(_ctx, input) {
5388
5327
  let preset = getOr(input.preset, "desktop");
5389
- let auditUrl = rewriteUrlForRuntime(input.url);
5390
5328
  switch (preset) {
5391
5329
  case "desktop":
5392
5330
  case "mobile":
@@ -5406,41 +5344,16 @@ async function execute6(_ctx, input) {
5406
5344
  "--disable-dev-shm-usage"
5407
5345
  ]
5408
5346
  });
5409
- let result = await runLighthouse(chrome, auditUrl, preset);
5410
- if (result.TAG !== "Ok") {
5411
- return result;
5412
- }
5413
- let out = result._0;
5414
- if (auditUrl === input.url) {
5415
- return {
5416
- TAG: "Ok",
5417
- _0: out
5418
- };
5419
- }
5420
- let warning = `DevPod mode: audited local URL ` + auditUrl + ` instead of ` + input.url + `.`;
5421
- return {
5422
- TAG: "Ok",
5423
- _0: {
5424
- url: input.url,
5425
- fetchTime: out.fetchTime,
5426
- categories: out.categories,
5427
- overallScore: out.overallScore,
5428
- warnings: concatMany([
5429
- [warning],
5430
- out.warnings
5431
- ])
5432
- }
5433
- };
5347
+ return await runLighthouse(chrome, input.url, preset);
5434
5348
  } catch (raw_exn) {
5435
5349
  let exn = internalToException(raw_exn);
5436
- let msg = getErrorMessage(exn);
5350
+ let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
5437
5351
  return {
5438
5352
  TAG: "Error",
5439
5353
  _0: `Failed to launch Chrome: ` + msg + `. Make sure Chrome is installed on the system.`
5440
5354
  };
5441
5355
  }
5442
5356
  }
5443
- var name7 = "lighthouse";
5444
5357
  var description6 = `Runs a Lighthouse audit on a URL to analyze performance, accessibility, best practices, and SEO.
5445
5358
 
5446
5359
  WHEN TO USE THIS TOOL:
@@ -6465,8 +6378,9 @@ function make3(configInput) {
6465
6378
  name: "frontman",
6466
6379
  hooks: {
6467
6380
  "astro:config:setup": (ctx2) => {
6468
- if (ctx2.command === "dev") {
6469
- if (!ctx2.config.devToolbar.enabled) {
6381
+ let match = ctx2.command;
6382
+ if (match === "dev") {
6383
+ if (ctx2.config.devToolbar.enabled) ; else {
6470
6384
  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.");
6471
6385
  }
6472
6386
  ctx2.updateConfig({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontman-ai/astro",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Astro integration for Frontman",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Frontman AI",
@@ -48,6 +48,10 @@
48
48
  "engines": {
49
49
  "node": ">=18.0.0"
50
50
  },
51
+ "dependencies": {
52
+ "chrome-launcher": "^1.1.2",
53
+ "lighthouse": "^12.5.1"
54
+ },
51
55
  "peerDependencies": {
52
56
  "astro": "^5.0.0"
53
57
  },