@ggui-ai/ui-gen 0.7.0 → 0.9.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.
Files changed (52) hide show
  1. package/dist/adapters/generation-dispatch.d.ts +10 -0
  2. package/dist/adapters/generation-dispatch.js +172 -1392
  3. package/dist/adapters/generation-dispatch.js.map +1 -1
  4. package/dist/advanced/index.d.ts +1 -1
  5. package/dist/advanced/index.js +191 -1403
  6. package/dist/advanced/index.js.map +1 -1
  7. package/dist/boilerplate.js +3 -2
  8. package/dist/boilerplate.js.map +1 -1
  9. package/dist/compose.js +5 -5
  10. package/dist/compose.js.map +1 -1
  11. package/dist/{create-ui-generator-GX7tvbyH.d.ts → create-ui-generator-B9kV4U9h.d.ts} +13 -0
  12. package/dist/evaluation/axis-checks/index.js +32 -1
  13. package/dist/evaluation/axis-checks/index.js.map +1 -1
  14. package/dist/evaluation/axis-checks/registry.js +32 -1
  15. package/dist/evaluation/axis-checks/registry.js.map +1 -1
  16. package/dist/evaluation/index.js +57 -12
  17. package/dist/evaluation/index.js.map +1 -1
  18. package/dist/fragments/index.js +5 -5
  19. package/dist/fragments/index.js.map +1 -1
  20. package/dist/harness/index.d.ts +4 -125
  21. package/dist/harness/index.js +34 -19
  22. package/dist/harness/index.js.map +1 -1
  23. package/dist/harness/runtime.d.ts +9 -0
  24. package/dist/harness/runtime.js +3 -2
  25. package/dist/harness/runtime.js.map +1 -1
  26. package/dist/harness/types-public.js +8 -7
  27. package/dist/harness/types-public.js.map +1 -1
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +191 -1403
  30. package/dist/index.js.map +1 -1
  31. package/dist/llm-router-1TyI0_TV.d.ts +156 -0
  32. package/dist/providers/index.d.ts +35 -93
  33. package/dist/providers/index.js +13 -8
  34. package/dist/providers/index.js.map +1 -1
  35. package/dist/validation/index.js +2 -2
  36. package/dist/validation/index.js.map +1 -1
  37. package/package.json +18 -18
  38. package/src/adapters/generation-dispatch.ts +19 -2
  39. package/src/boilerplate/system-prompt.ts +3 -2
  40. package/src/create-ui-generator.ts +44 -11
  41. package/src/evaluation/axis-checks/checks/state-merge.ts +1 -1
  42. package/src/evaluation/axis-checks/checks/universal.ts +39 -0
  43. package/src/evaluation/llm-evaluator.ts +13 -3
  44. package/src/evaluation/visual-evaluator.ts +5 -1
  45. package/src/fragments/realtime.ts +3 -3
  46. package/src/fragments/state.ts +2 -2
  47. package/src/harness/coding/init-session.ts +4 -1
  48. package/src/harness/coding/run-eval-round.ts +6 -0
  49. package/src/harness/llm-router.ts +59 -14
  50. package/src/harness/runtime.ts +8 -0
  51. package/src/providers/bedrock.ts +84 -22
  52. package/src/validation/ui-compiler.ts +2 -2
@@ -10,7 +10,10 @@ import path, { dirname, resolve, join, basename } from 'path';
10
10
  import { createRequire } from 'module';
11
11
  import { Linter } from 'eslint';
12
12
  import { createHash } from 'crypto';
13
+ import 'fs/promises';
13
14
  import { tmpdir } from 'os';
15
+ import { Readable } from 'stream';
16
+ import { pipeline } from 'stream/promises';
14
17
  import { createBrotliDecompress, createUnzip } from 'zlib';
15
18
  import { fileURLToPath, pathToFileURL } from 'url';
16
19
  import { PlaywrightNotAvailableError, validateContractBehavior } from '@ggui-ai/ui-visual-tester';
@@ -1888,8 +1891,8 @@ var init_ui_compiler = __esm({
1888
1891
  "@ggui-ai/design/*",
1889
1892
  "@ggui-ai/wire",
1890
1893
  "@ggui-ai/wire/*",
1891
- "@ggui-ai/react",
1892
- "@ggui-ai/react/*"
1894
+ "@ggui-ai/mcp-apps-react",
1895
+ "@ggui-ai/mcp-apps-react/*"
1893
1896
  ];
1894
1897
  MAX_BUNDLE_SIZE = 2 * 1024 * 1024;
1895
1898
  UiValidationError = class extends Error {
@@ -4130,16 +4133,18 @@ function functionCallSteps(interaction) {
4130
4133
  function toUserInputStep(text) {
4131
4134
  return { type: "user_input", content: [{ type: "text", text }] };
4132
4135
  }
4133
- function createAgent(provider) {
4136
+ function createAgent(providerOrConfig) {
4137
+ const provider = typeof providerOrConfig === "string" ? providerOrConfig : providerOrConfig.provider;
4138
+ const routeOverride = typeof providerOrConfig === "string" ? void 0 : providerOrConfig.routeOverride;
4134
4139
  switch (provider) {
4135
4140
  case "anthropic":
4136
- return new AnthropicAgent();
4141
+ return new AnthropicAgent(routeOverride);
4137
4142
  case "openai":
4138
- return new OpenAIAgent();
4143
+ return new OpenAIAgent(routeOverride);
4139
4144
  case "google":
4140
- return new GoogleAgent();
4145
+ return new GoogleAgent(routeOverride);
4141
4146
  case "openrouter":
4142
- return new OpenRouterAgent();
4147
+ return new OpenRouterAgent(routeOverride);
4143
4148
  }
4144
4149
  }
4145
4150
  var LLMAgent, AnthropicAgent, OpenAIAgent, GoogleAgent, OpenRouterAgent;
@@ -4156,6 +4161,16 @@ var init_llm_router = __esm({
4156
4161
  // Enables turn 2+ to skip re-sending system prompt + history.
4157
4162
  // Call resetSession() between independent generation runs.
4158
4163
  lastSessionId;
4164
+ /**
4165
+ * Explicit per-call routing override — see `AgentConfig.routeOverride`.
4166
+ * Absent when constructed via the bare `new XAgent()` form (every
4167
+ * existing call site), so `createClient()`/`resolveModel()` fall
4168
+ * back to `process.env` exactly as before.
4169
+ */
4170
+ routeOverride;
4171
+ constructor(routeOverride) {
4172
+ this.routeOverride = routeOverride;
4173
+ }
4159
4174
  async getClient() {
4160
4175
  if (!this.client) {
4161
4176
  this.client = await this.createClient();
@@ -4206,19 +4221,21 @@ var init_llm_router = __esm({
4206
4221
  AnthropicAgent = class extends LLMAgent {
4207
4222
  provider = "anthropic";
4208
4223
  resolveModel(model) {
4209
- if (process.env.CLAUDE_CODE_USE_BEDROCK === "1") {
4224
+ const useBedrock = this.routeOverride?.useBedrock ?? process.env.CLAUDE_CODE_USE_BEDROCK === "1";
4225
+ if (useBedrock) {
4210
4226
  return getBedrockModelId(model);
4211
4227
  }
4212
4228
  return model.startsWith("anthropic/") ? model.slice("anthropic/".length) : model;
4213
4229
  }
4214
4230
  async createClient() {
4215
- if (process.env.CLAUDE_CODE_USE_BEDROCK === "1") {
4231
+ const useBedrock = this.routeOverride?.useBedrock ?? process.env.CLAUDE_CODE_USE_BEDROCK === "1";
4232
+ if (useBedrock) {
4216
4233
  const { AnthropicBedrock } = await import('@anthropic-ai/bedrock-sdk');
4217
4234
  return new AnthropicBedrock({
4218
4235
  awsRegion: process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION ?? "us-east-1"
4219
4236
  });
4220
4237
  }
4221
- return createAnthropicClient(process.env.ANTHROPIC_API_KEY);
4238
+ return createAnthropicClient(this.routeOverride?.apiKey ?? process.env.ANTHROPIC_API_KEY);
4222
4239
  }
4223
4240
  async callText(model, systemPrompt, userPrompt, maxTokens, temperature) {
4224
4241
  const client = await this.getClient();
@@ -4489,7 +4506,7 @@ var init_llm_router = __esm({
4489
4506
  }
4490
4507
  async createClient() {
4491
4508
  const { default: OpenAISDK } = await import('openai');
4492
- return new OpenAISDK({ apiKey: process.env.OPENAI_API_KEY });
4509
+ return new OpenAISDK({ apiKey: this.routeOverride?.apiKey ?? process.env.OPENAI_API_KEY });
4493
4510
  }
4494
4511
  async callText(model, systemPrompt, userPrompt, maxTokens, temperature) {
4495
4512
  const client = await this.getClient();
@@ -4639,7 +4656,7 @@ var init_llm_router = __esm({
4639
4656
  async createClient() {
4640
4657
  const { GoogleGenAI: GoogleGenAISDK } = await import('@google/genai');
4641
4658
  return new GoogleGenAISDK({
4642
- apiKey: process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY,
4659
+ apiKey: this.routeOverride?.apiKey ?? (process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY),
4643
4660
  httpOptions: { timeout: 3e5 }
4644
4661
  // 5 min — Pro models can be slow
4645
4662
  });
@@ -4866,7 +4883,7 @@ var init_llm_router = __esm({
4866
4883
  async createClient() {
4867
4884
  const { OpenRouterClient: OpenRouterClient2 } = await Promise.resolve().then(() => (init_client2(), client_exports));
4868
4885
  return new OpenRouterClient2({
4869
- apiKey: process.env.OPENROUTER_API_KEY
4886
+ apiKey: this.routeOverride?.apiKey ?? process.env.OPENROUTER_API_KEY
4870
4887
  });
4871
4888
  }
4872
4889
  async callText(model, systemPrompt, userPrompt, maxTokens, temperature) {
@@ -6008,7 +6025,7 @@ async function runLLMEvaluation(context, config, preWarmedContext) {
6008
6025
  designSystemSummary: context.designContext
6009
6026
  });
6010
6027
  const numberedSource = context.sourceCode.split("\n").map((line, i) => `${String(i + 1).padStart(4)} | ${line}`).join("\n");
6011
- const agent = createAgent(routerProvider);
6028
+ const agent = createAgent({ provider: routerProvider, routeOverride: config.routeOverride });
6012
6029
  const evalStart = Date.now();
6013
6030
  const totalCriteriaCount = TIER_1_CRITERIA.length + TIER_2_CRITERIA.length;
6014
6031
  const results = await Promise.all([
@@ -6122,1298 +6139,6 @@ var init_cost_tracker = __esm({
6122
6139
  }
6123
6140
  });
6124
6141
 
6125
- // ../../node_modules/ms/index.js
6126
- var require_ms = __commonJS({
6127
- "../../node_modules/ms/index.js"(exports, module) {
6128
- var s = 1e3;
6129
- var m = s * 60;
6130
- var h = m * 60;
6131
- var d = h * 24;
6132
- var w = d * 7;
6133
- var y = d * 365.25;
6134
- module.exports = function(val, options) {
6135
- options = options || {};
6136
- var type = typeof val;
6137
- if (type === "string" && val.length > 0) {
6138
- return parse(val);
6139
- } else if (type === "number" && isFinite(val)) {
6140
- return options.long ? fmtLong(val) : fmtShort(val);
6141
- }
6142
- throw new Error(
6143
- "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
6144
- );
6145
- };
6146
- function parse(str) {
6147
- str = String(str);
6148
- if (str.length > 100) {
6149
- return;
6150
- }
6151
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
6152
- str
6153
- );
6154
- if (!match) {
6155
- return;
6156
- }
6157
- var n = parseFloat(match[1]);
6158
- var type = (match[2] || "ms").toLowerCase();
6159
- switch (type) {
6160
- case "years":
6161
- case "year":
6162
- case "yrs":
6163
- case "yr":
6164
- case "y":
6165
- return n * y;
6166
- case "weeks":
6167
- case "week":
6168
- case "w":
6169
- return n * w;
6170
- case "days":
6171
- case "day":
6172
- case "d":
6173
- return n * d;
6174
- case "hours":
6175
- case "hour":
6176
- case "hrs":
6177
- case "hr":
6178
- case "h":
6179
- return n * h;
6180
- case "minutes":
6181
- case "minute":
6182
- case "mins":
6183
- case "min":
6184
- case "m":
6185
- return n * m;
6186
- case "seconds":
6187
- case "second":
6188
- case "secs":
6189
- case "sec":
6190
- case "s":
6191
- return n * s;
6192
- case "milliseconds":
6193
- case "millisecond":
6194
- case "msecs":
6195
- case "msec":
6196
- case "ms":
6197
- return n;
6198
- default:
6199
- return void 0;
6200
- }
6201
- }
6202
- function fmtShort(ms) {
6203
- var msAbs = Math.abs(ms);
6204
- if (msAbs >= d) {
6205
- return Math.round(ms / d) + "d";
6206
- }
6207
- if (msAbs >= h) {
6208
- return Math.round(ms / h) + "h";
6209
- }
6210
- if (msAbs >= m) {
6211
- return Math.round(ms / m) + "m";
6212
- }
6213
- if (msAbs >= s) {
6214
- return Math.round(ms / s) + "s";
6215
- }
6216
- return ms + "ms";
6217
- }
6218
- function fmtLong(ms) {
6219
- var msAbs = Math.abs(ms);
6220
- if (msAbs >= d) {
6221
- return plural(ms, msAbs, d, "day");
6222
- }
6223
- if (msAbs >= h) {
6224
- return plural(ms, msAbs, h, "hour");
6225
- }
6226
- if (msAbs >= m) {
6227
- return plural(ms, msAbs, m, "minute");
6228
- }
6229
- if (msAbs >= s) {
6230
- return plural(ms, msAbs, s, "second");
6231
- }
6232
- return ms + " ms";
6233
- }
6234
- function plural(ms, msAbs, n, name) {
6235
- var isPlural = msAbs >= n * 1.5;
6236
- return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
6237
- }
6238
- }
6239
- });
6240
-
6241
- // ../../node_modules/debug/src/common.js
6242
- var require_common = __commonJS({
6243
- "../../node_modules/debug/src/common.js"(exports, module) {
6244
- function setup(env) {
6245
- createDebug.debug = createDebug;
6246
- createDebug.default = createDebug;
6247
- createDebug.coerce = coerce;
6248
- createDebug.disable = disable;
6249
- createDebug.enable = enable;
6250
- createDebug.enabled = enabled;
6251
- createDebug.humanize = require_ms();
6252
- createDebug.destroy = destroy;
6253
- Object.keys(env).forEach((key) => {
6254
- createDebug[key] = env[key];
6255
- });
6256
- createDebug.names = [];
6257
- createDebug.skips = [];
6258
- createDebug.formatters = {};
6259
- function selectColor(namespace) {
6260
- let hash = 0;
6261
- for (let i = 0; i < namespace.length; i++) {
6262
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
6263
- hash |= 0;
6264
- }
6265
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
6266
- }
6267
- createDebug.selectColor = selectColor;
6268
- function createDebug(namespace) {
6269
- let prevTime;
6270
- let enableOverride = null;
6271
- let namespacesCache;
6272
- let enabledCache;
6273
- function debug(...args) {
6274
- if (!debug.enabled) {
6275
- return;
6276
- }
6277
- const self = debug;
6278
- const curr = Number(/* @__PURE__ */ new Date());
6279
- const ms = curr - (prevTime || curr);
6280
- self.diff = ms;
6281
- self.prev = prevTime;
6282
- self.curr = curr;
6283
- prevTime = curr;
6284
- args[0] = createDebug.coerce(args[0]);
6285
- if (typeof args[0] !== "string") {
6286
- args.unshift("%O");
6287
- }
6288
- let index = 0;
6289
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
6290
- if (match === "%%") {
6291
- return "%";
6292
- }
6293
- index++;
6294
- const formatter = createDebug.formatters[format];
6295
- if (typeof formatter === "function") {
6296
- const val = args[index];
6297
- match = formatter.call(self, val);
6298
- args.splice(index, 1);
6299
- index--;
6300
- }
6301
- return match;
6302
- });
6303
- createDebug.formatArgs.call(self, args);
6304
- const logFn = self.log || createDebug.log;
6305
- logFn.apply(self, args);
6306
- }
6307
- debug.namespace = namespace;
6308
- debug.useColors = createDebug.useColors();
6309
- debug.color = createDebug.selectColor(namespace);
6310
- debug.extend = extend;
6311
- debug.destroy = createDebug.destroy;
6312
- Object.defineProperty(debug, "enabled", {
6313
- enumerable: true,
6314
- configurable: false,
6315
- get: () => {
6316
- if (enableOverride !== null) {
6317
- return enableOverride;
6318
- }
6319
- if (namespacesCache !== createDebug.namespaces) {
6320
- namespacesCache = createDebug.namespaces;
6321
- enabledCache = createDebug.enabled(namespace);
6322
- }
6323
- return enabledCache;
6324
- },
6325
- set: (v) => {
6326
- enableOverride = v;
6327
- }
6328
- });
6329
- if (typeof createDebug.init === "function") {
6330
- createDebug.init(debug);
6331
- }
6332
- return debug;
6333
- }
6334
- function extend(namespace, delimiter) {
6335
- const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
6336
- newDebug.log = this.log;
6337
- return newDebug;
6338
- }
6339
- function enable(namespaces) {
6340
- createDebug.save(namespaces);
6341
- createDebug.namespaces = namespaces;
6342
- createDebug.names = [];
6343
- createDebug.skips = [];
6344
- const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
6345
- for (const ns of split) {
6346
- if (ns[0] === "-") {
6347
- createDebug.skips.push(ns.slice(1));
6348
- } else {
6349
- createDebug.names.push(ns);
6350
- }
6351
- }
6352
- }
6353
- function matchesTemplate(search, template) {
6354
- let searchIndex = 0;
6355
- let templateIndex = 0;
6356
- let starIndex = -1;
6357
- let matchIndex = 0;
6358
- while (searchIndex < search.length) {
6359
- if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
6360
- if (template[templateIndex] === "*") {
6361
- starIndex = templateIndex;
6362
- matchIndex = searchIndex;
6363
- templateIndex++;
6364
- } else {
6365
- searchIndex++;
6366
- templateIndex++;
6367
- }
6368
- } else if (starIndex !== -1) {
6369
- templateIndex = starIndex + 1;
6370
- matchIndex++;
6371
- searchIndex = matchIndex;
6372
- } else {
6373
- return false;
6374
- }
6375
- }
6376
- while (templateIndex < template.length && template[templateIndex] === "*") {
6377
- templateIndex++;
6378
- }
6379
- return templateIndex === template.length;
6380
- }
6381
- function disable() {
6382
- const namespaces = [
6383
- ...createDebug.names,
6384
- ...createDebug.skips.map((namespace) => "-" + namespace)
6385
- ].join(",");
6386
- createDebug.enable("");
6387
- return namespaces;
6388
- }
6389
- function enabled(name) {
6390
- for (const skip of createDebug.skips) {
6391
- if (matchesTemplate(name, skip)) {
6392
- return false;
6393
- }
6394
- }
6395
- for (const ns of createDebug.names) {
6396
- if (matchesTemplate(name, ns)) {
6397
- return true;
6398
- }
6399
- }
6400
- return false;
6401
- }
6402
- function coerce(val) {
6403
- if (val instanceof Error) {
6404
- return val.stack || val.message;
6405
- }
6406
- return val;
6407
- }
6408
- function destroy() {
6409
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
6410
- }
6411
- createDebug.enable(createDebug.load());
6412
- return createDebug;
6413
- }
6414
- module.exports = setup;
6415
- }
6416
- });
6417
-
6418
- // ../../node_modules/debug/src/browser.js
6419
- var require_browser = __commonJS({
6420
- "../../node_modules/debug/src/browser.js"(exports, module) {
6421
- exports.formatArgs = formatArgs;
6422
- exports.save = save;
6423
- exports.load = load;
6424
- exports.useColors = useColors;
6425
- exports.storage = localstorage();
6426
- exports.destroy = /* @__PURE__ */ (() => {
6427
- let warned = false;
6428
- return () => {
6429
- if (!warned) {
6430
- warned = true;
6431
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
6432
- }
6433
- };
6434
- })();
6435
- exports.colors = [
6436
- "#0000CC",
6437
- "#0000FF",
6438
- "#0033CC",
6439
- "#0033FF",
6440
- "#0066CC",
6441
- "#0066FF",
6442
- "#0099CC",
6443
- "#0099FF",
6444
- "#00CC00",
6445
- "#00CC33",
6446
- "#00CC66",
6447
- "#00CC99",
6448
- "#00CCCC",
6449
- "#00CCFF",
6450
- "#3300CC",
6451
- "#3300FF",
6452
- "#3333CC",
6453
- "#3333FF",
6454
- "#3366CC",
6455
- "#3366FF",
6456
- "#3399CC",
6457
- "#3399FF",
6458
- "#33CC00",
6459
- "#33CC33",
6460
- "#33CC66",
6461
- "#33CC99",
6462
- "#33CCCC",
6463
- "#33CCFF",
6464
- "#6600CC",
6465
- "#6600FF",
6466
- "#6633CC",
6467
- "#6633FF",
6468
- "#66CC00",
6469
- "#66CC33",
6470
- "#9900CC",
6471
- "#9900FF",
6472
- "#9933CC",
6473
- "#9933FF",
6474
- "#99CC00",
6475
- "#99CC33",
6476
- "#CC0000",
6477
- "#CC0033",
6478
- "#CC0066",
6479
- "#CC0099",
6480
- "#CC00CC",
6481
- "#CC00FF",
6482
- "#CC3300",
6483
- "#CC3333",
6484
- "#CC3366",
6485
- "#CC3399",
6486
- "#CC33CC",
6487
- "#CC33FF",
6488
- "#CC6600",
6489
- "#CC6633",
6490
- "#CC9900",
6491
- "#CC9933",
6492
- "#CCCC00",
6493
- "#CCCC33",
6494
- "#FF0000",
6495
- "#FF0033",
6496
- "#FF0066",
6497
- "#FF0099",
6498
- "#FF00CC",
6499
- "#FF00FF",
6500
- "#FF3300",
6501
- "#FF3333",
6502
- "#FF3366",
6503
- "#FF3399",
6504
- "#FF33CC",
6505
- "#FF33FF",
6506
- "#FF6600",
6507
- "#FF6633",
6508
- "#FF9900",
6509
- "#FF9933",
6510
- "#FFCC00",
6511
- "#FFCC33"
6512
- ];
6513
- function useColors() {
6514
- if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
6515
- return true;
6516
- }
6517
- if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
6518
- return false;
6519
- }
6520
- let m;
6521
- return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
6522
- typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
6523
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
6524
- typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
6525
- typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
6526
- }
6527
- function formatArgs(args) {
6528
- args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
6529
- if (!this.useColors) {
6530
- return;
6531
- }
6532
- const c = "color: " + this.color;
6533
- args.splice(1, 0, c, "color: inherit");
6534
- let index = 0;
6535
- let lastC = 0;
6536
- args[0].replace(/%[a-zA-Z%]/g, (match) => {
6537
- if (match === "%%") {
6538
- return;
6539
- }
6540
- index++;
6541
- if (match === "%c") {
6542
- lastC = index;
6543
- }
6544
- });
6545
- args.splice(lastC, 0, c);
6546
- }
6547
- exports.log = console.debug || console.log || (() => {
6548
- });
6549
- function save(namespaces) {
6550
- try {
6551
- if (namespaces) {
6552
- exports.storage.setItem("debug", namespaces);
6553
- } else {
6554
- exports.storage.removeItem("debug");
6555
- }
6556
- } catch (error) {
6557
- }
6558
- }
6559
- function load() {
6560
- let r;
6561
- try {
6562
- r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
6563
- } catch (error) {
6564
- }
6565
- if (!r && typeof process !== "undefined" && "env" in process) {
6566
- r = process.env.DEBUG;
6567
- }
6568
- return r;
6569
- }
6570
- function localstorage() {
6571
- try {
6572
- return localStorage;
6573
- } catch (error) {
6574
- }
6575
- }
6576
- module.exports = require_common()(exports);
6577
- var { formatters } = module.exports;
6578
- formatters.j = function(v) {
6579
- try {
6580
- return JSON.stringify(v);
6581
- } catch (error) {
6582
- return "[UnexpectedJSONParseError]: " + error.message;
6583
- }
6584
- };
6585
- }
6586
- });
6587
-
6588
- // ../../node_modules/has-flag/index.js
6589
- var require_has_flag = __commonJS({
6590
- "../../node_modules/has-flag/index.js"(exports, module) {
6591
- module.exports = (flag, argv = process.argv) => {
6592
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
6593
- const position = argv.indexOf(prefix + flag);
6594
- const terminatorPosition = argv.indexOf("--");
6595
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
6596
- };
6597
- }
6598
- });
6599
-
6600
- // ../../node_modules/supports-color/index.js
6601
- var require_supports_color = __commonJS({
6602
- "../../node_modules/supports-color/index.js"(exports, module) {
6603
- var os = __require("os");
6604
- var tty = __require("tty");
6605
- var hasFlag = require_has_flag();
6606
- var { env } = process;
6607
- var forceColor;
6608
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
6609
- forceColor = 0;
6610
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
6611
- forceColor = 1;
6612
- }
6613
- if ("FORCE_COLOR" in env) {
6614
- if (env.FORCE_COLOR === "true") {
6615
- forceColor = 1;
6616
- } else if (env.FORCE_COLOR === "false") {
6617
- forceColor = 0;
6618
- } else {
6619
- forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
6620
- }
6621
- }
6622
- function translateLevel(level) {
6623
- if (level === 0) {
6624
- return false;
6625
- }
6626
- return {
6627
- level,
6628
- hasBasic: true,
6629
- has256: level >= 2,
6630
- has16m: level >= 3
6631
- };
6632
- }
6633
- function supportsColor(haveStream, streamIsTTY) {
6634
- if (forceColor === 0) {
6635
- return 0;
6636
- }
6637
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
6638
- return 3;
6639
- }
6640
- if (hasFlag("color=256")) {
6641
- return 2;
6642
- }
6643
- if (haveStream && !streamIsTTY && forceColor === void 0) {
6644
- return 0;
6645
- }
6646
- const min = forceColor || 0;
6647
- if (env.TERM === "dumb") {
6648
- return min;
6649
- }
6650
- if (process.platform === "win32") {
6651
- const osRelease = os.release().split(".");
6652
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
6653
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
6654
- }
6655
- return 1;
6656
- }
6657
- if ("CI" in env) {
6658
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
6659
- return 1;
6660
- }
6661
- return min;
6662
- }
6663
- if ("TEAMCITY_VERSION" in env) {
6664
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
6665
- }
6666
- if (env.COLORTERM === "truecolor") {
6667
- return 3;
6668
- }
6669
- if ("TERM_PROGRAM" in env) {
6670
- const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
6671
- switch (env.TERM_PROGRAM) {
6672
- case "iTerm.app":
6673
- return version >= 3 ? 3 : 2;
6674
- case "Apple_Terminal":
6675
- return 2;
6676
- }
6677
- }
6678
- if (/-256(color)?$/i.test(env.TERM)) {
6679
- return 2;
6680
- }
6681
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
6682
- return 1;
6683
- }
6684
- if ("COLORTERM" in env) {
6685
- return 1;
6686
- }
6687
- return min;
6688
- }
6689
- function getSupportLevel(stream) {
6690
- const level = supportsColor(stream, stream && stream.isTTY);
6691
- return translateLevel(level);
6692
- }
6693
- module.exports = {
6694
- supportsColor: getSupportLevel,
6695
- stdout: translateLevel(supportsColor(true, tty.isatty(1))),
6696
- stderr: translateLevel(supportsColor(true, tty.isatty(2)))
6697
- };
6698
- }
6699
- });
6700
-
6701
- // ../../node_modules/debug/src/node.js
6702
- var require_node = __commonJS({
6703
- "../../node_modules/debug/src/node.js"(exports, module) {
6704
- var tty = __require("tty");
6705
- var util = __require("util");
6706
- exports.init = init;
6707
- exports.log = log;
6708
- exports.formatArgs = formatArgs;
6709
- exports.save = save;
6710
- exports.load = load;
6711
- exports.useColors = useColors;
6712
- exports.destroy = util.deprecate(
6713
- () => {
6714
- },
6715
- "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
6716
- );
6717
- exports.colors = [6, 2, 3, 4, 5, 1];
6718
- try {
6719
- const supportsColor = require_supports_color();
6720
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
6721
- exports.colors = [
6722
- 20,
6723
- 21,
6724
- 26,
6725
- 27,
6726
- 32,
6727
- 33,
6728
- 38,
6729
- 39,
6730
- 40,
6731
- 41,
6732
- 42,
6733
- 43,
6734
- 44,
6735
- 45,
6736
- 56,
6737
- 57,
6738
- 62,
6739
- 63,
6740
- 68,
6741
- 69,
6742
- 74,
6743
- 75,
6744
- 76,
6745
- 77,
6746
- 78,
6747
- 79,
6748
- 80,
6749
- 81,
6750
- 92,
6751
- 93,
6752
- 98,
6753
- 99,
6754
- 112,
6755
- 113,
6756
- 128,
6757
- 129,
6758
- 134,
6759
- 135,
6760
- 148,
6761
- 149,
6762
- 160,
6763
- 161,
6764
- 162,
6765
- 163,
6766
- 164,
6767
- 165,
6768
- 166,
6769
- 167,
6770
- 168,
6771
- 169,
6772
- 170,
6773
- 171,
6774
- 172,
6775
- 173,
6776
- 178,
6777
- 179,
6778
- 184,
6779
- 185,
6780
- 196,
6781
- 197,
6782
- 198,
6783
- 199,
6784
- 200,
6785
- 201,
6786
- 202,
6787
- 203,
6788
- 204,
6789
- 205,
6790
- 206,
6791
- 207,
6792
- 208,
6793
- 209,
6794
- 214,
6795
- 215,
6796
- 220,
6797
- 221
6798
- ];
6799
- }
6800
- } catch (error) {
6801
- }
6802
- exports.inspectOpts = Object.keys(process.env).filter((key) => {
6803
- return /^debug_/i.test(key);
6804
- }).reduce((obj, key) => {
6805
- const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
6806
- return k.toUpperCase();
6807
- });
6808
- let val = process.env[key];
6809
- if (/^(yes|on|true|enabled)$/i.test(val)) {
6810
- val = true;
6811
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
6812
- val = false;
6813
- } else if (val === "null") {
6814
- val = null;
6815
- } else {
6816
- val = Number(val);
6817
- }
6818
- obj[prop] = val;
6819
- return obj;
6820
- }, {});
6821
- function useColors() {
6822
- return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
6823
- }
6824
- function formatArgs(args) {
6825
- const { namespace: name, useColors: useColors2 } = this;
6826
- if (useColors2) {
6827
- const c = this.color;
6828
- const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
6829
- const prefix = ` ${colorCode};1m${name} \x1B[0m`;
6830
- args[0] = prefix + args[0].split("\n").join("\n" + prefix);
6831
- args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
6832
- } else {
6833
- args[0] = getDate() + name + " " + args[0];
6834
- }
6835
- }
6836
- function getDate() {
6837
- if (exports.inspectOpts.hideDate) {
6838
- return "";
6839
- }
6840
- return (/* @__PURE__ */ new Date()).toISOString() + " ";
6841
- }
6842
- function log(...args) {
6843
- return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + "\n");
6844
- }
6845
- function save(namespaces) {
6846
- if (namespaces) {
6847
- process.env.DEBUG = namespaces;
6848
- } else {
6849
- delete process.env.DEBUG;
6850
- }
6851
- }
6852
- function load() {
6853
- return process.env.DEBUG;
6854
- }
6855
- function init(debug) {
6856
- debug.inspectOpts = {};
6857
- const keys = Object.keys(exports.inspectOpts);
6858
- for (let i = 0; i < keys.length; i++) {
6859
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
6860
- }
6861
- }
6862
- module.exports = require_common()(exports);
6863
- var { formatters } = module.exports;
6864
- formatters.o = function(v) {
6865
- this.inspectOpts.colors = this.useColors;
6866
- return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
6867
- };
6868
- formatters.O = function(v) {
6869
- this.inspectOpts.colors = this.useColors;
6870
- return util.inspect(v, this.inspectOpts);
6871
- };
6872
- }
6873
- });
6874
-
6875
- // ../../node_modules/debug/src/index.js
6876
- var require_src = __commonJS({
6877
- "../../node_modules/debug/src/index.js"(exports, module) {
6878
- if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
6879
- module.exports = require_browser();
6880
- } else {
6881
- module.exports = require_node();
6882
- }
6883
- }
6884
- });
6885
-
6886
- // ../../node_modules/follow-redirects/debug.js
6887
- var require_debug = __commonJS({
6888
- "../../node_modules/follow-redirects/debug.js"(exports, module) {
6889
- var debug;
6890
- module.exports = function() {
6891
- if (!debug) {
6892
- try {
6893
- debug = require_src()("follow-redirects");
6894
- } catch (error) {
6895
- }
6896
- if (typeof debug !== "function") {
6897
- debug = function() {
6898
- };
6899
- }
6900
- }
6901
- debug.apply(null, arguments);
6902
- };
6903
- }
6904
- });
6905
-
6906
- // ../../node_modules/follow-redirects/index.js
6907
- var require_follow_redirects = __commonJS({
6908
- "../../node_modules/follow-redirects/index.js"(exports, module) {
6909
- var url = __require("url");
6910
- var URL2 = url.URL;
6911
- var http = __require("http");
6912
- var https = __require("https");
6913
- var Writable = __require("stream").Writable;
6914
- var assert = __require("assert");
6915
- var debug = require_debug();
6916
- (function detectUnsupportedEnvironment() {
6917
- var looksLikeNode = typeof process !== "undefined";
6918
- var looksLikeBrowser = typeof window !== "undefined" && typeof document !== "undefined";
6919
- var looksLikeV8 = isFunction(Error.captureStackTrace);
6920
- if (!looksLikeNode && (looksLikeBrowser || !looksLikeV8)) {
6921
- console.warn("The follow-redirects package should be excluded from browser builds.");
6922
- }
6923
- })();
6924
- var useNativeURL = false;
6925
- try {
6926
- assert(new URL2(""));
6927
- } catch (error) {
6928
- useNativeURL = error.code === "ERR_INVALID_URL";
6929
- }
6930
- var sensitiveHeaders = [
6931
- "Authorization",
6932
- "Proxy-Authorization",
6933
- "Cookie"
6934
- ];
6935
- var preservedUrlFields = [
6936
- "auth",
6937
- "host",
6938
- "hostname",
6939
- "href",
6940
- "path",
6941
- "pathname",
6942
- "port",
6943
- "protocol",
6944
- "query",
6945
- "search",
6946
- "hash"
6947
- ];
6948
- var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
6949
- var eventHandlers = /* @__PURE__ */ Object.create(null);
6950
- events.forEach(function(event) {
6951
- eventHandlers[event] = function(arg1, arg2, arg3) {
6952
- this._redirectable.emit(event, arg1, arg2, arg3);
6953
- };
6954
- });
6955
- var InvalidUrlError = createErrorType(
6956
- "ERR_INVALID_URL",
6957
- "Invalid URL",
6958
- TypeError
6959
- );
6960
- var RedirectionError = createErrorType(
6961
- "ERR_FR_REDIRECTION_FAILURE",
6962
- "Redirected request failed"
6963
- );
6964
- var TooManyRedirectsError = createErrorType(
6965
- "ERR_FR_TOO_MANY_REDIRECTS",
6966
- "Maximum number of redirects exceeded",
6967
- RedirectionError
6968
- );
6969
- var MaxBodyLengthExceededError = createErrorType(
6970
- "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
6971
- "Request body larger than maxBodyLength limit"
6972
- );
6973
- var WriteAfterEndError = createErrorType(
6974
- "ERR_STREAM_WRITE_AFTER_END",
6975
- "write after end"
6976
- );
6977
- var destroy = Writable.prototype.destroy || noop;
6978
- function RedirectableRequest(options, responseCallback) {
6979
- Writable.call(this);
6980
- this._sanitizeOptions(options);
6981
- this._options = options;
6982
- this._ended = false;
6983
- this._ending = false;
6984
- this._redirectCount = 0;
6985
- this._redirects = [];
6986
- this._requestBodyLength = 0;
6987
- this._requestBodyBuffers = [];
6988
- if (responseCallback) {
6989
- this.on("response", responseCallback);
6990
- }
6991
- var self = this;
6992
- this._onNativeResponse = function(response) {
6993
- try {
6994
- self._processResponse(response);
6995
- } catch (cause) {
6996
- self.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause }));
6997
- }
6998
- };
6999
- this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i");
7000
- this._performRequest();
7001
- }
7002
- RedirectableRequest.prototype = Object.create(Writable.prototype);
7003
- RedirectableRequest.prototype.abort = function() {
7004
- destroyRequest(this._currentRequest);
7005
- this._currentRequest.abort();
7006
- this.emit("abort");
7007
- };
7008
- RedirectableRequest.prototype.destroy = function(error) {
7009
- destroyRequest(this._currentRequest, error);
7010
- destroy.call(this, error);
7011
- return this;
7012
- };
7013
- RedirectableRequest.prototype.write = function(data, encoding, callback) {
7014
- if (this._ending) {
7015
- throw new WriteAfterEndError();
7016
- }
7017
- if (!isString(data) && !isBuffer(data)) {
7018
- throw new TypeError("data should be a string, Buffer or Uint8Array");
7019
- }
7020
- if (isFunction(encoding)) {
7021
- callback = encoding;
7022
- encoding = null;
7023
- }
7024
- if (data.length === 0) {
7025
- if (callback) {
7026
- callback();
7027
- }
7028
- return;
7029
- }
7030
- if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
7031
- this._requestBodyLength += data.length;
7032
- this._requestBodyBuffers.push({ data, encoding });
7033
- this._currentRequest.write(data, encoding, callback);
7034
- } else {
7035
- this.emit("error", new MaxBodyLengthExceededError());
7036
- this.abort();
7037
- }
7038
- };
7039
- RedirectableRequest.prototype.end = function(data, encoding, callback) {
7040
- if (isFunction(data)) {
7041
- callback = data;
7042
- data = encoding = null;
7043
- } else if (isFunction(encoding)) {
7044
- callback = encoding;
7045
- encoding = null;
7046
- }
7047
- if (!data) {
7048
- this._ended = this._ending = true;
7049
- this._currentRequest.end(null, null, callback);
7050
- } else {
7051
- var self = this;
7052
- var currentRequest = this._currentRequest;
7053
- this.write(data, encoding, function() {
7054
- self._ended = true;
7055
- currentRequest.end(null, null, callback);
7056
- });
7057
- this._ending = true;
7058
- }
7059
- };
7060
- RedirectableRequest.prototype.setHeader = function(name, value) {
7061
- this._options.headers[name] = value;
7062
- this._currentRequest.setHeader(name, value);
7063
- };
7064
- RedirectableRequest.prototype.removeHeader = function(name) {
7065
- delete this._options.headers[name];
7066
- this._currentRequest.removeHeader(name);
7067
- };
7068
- RedirectableRequest.prototype.setTimeout = function(msecs, callback) {
7069
- var self = this;
7070
- function destroyOnTimeout(socket) {
7071
- socket.setTimeout(msecs);
7072
- socket.removeListener("timeout", socket.destroy);
7073
- socket.addListener("timeout", socket.destroy);
7074
- }
7075
- function startTimer(socket) {
7076
- if (self._timeout) {
7077
- clearTimeout(self._timeout);
7078
- }
7079
- self._timeout = setTimeout(function() {
7080
- self.emit("timeout");
7081
- clearTimer();
7082
- }, msecs);
7083
- destroyOnTimeout(socket);
7084
- }
7085
- function clearTimer() {
7086
- if (self._timeout) {
7087
- clearTimeout(self._timeout);
7088
- self._timeout = null;
7089
- }
7090
- self.removeListener("abort", clearTimer);
7091
- self.removeListener("error", clearTimer);
7092
- self.removeListener("response", clearTimer);
7093
- self.removeListener("close", clearTimer);
7094
- if (callback) {
7095
- self.removeListener("timeout", callback);
7096
- }
7097
- if (!self.socket) {
7098
- self._currentRequest.removeListener("socket", startTimer);
7099
- }
7100
- }
7101
- if (callback) {
7102
- this.on("timeout", callback);
7103
- }
7104
- if (this.socket) {
7105
- startTimer(this.socket);
7106
- } else {
7107
- this._currentRequest.once("socket", startTimer);
7108
- }
7109
- this.on("socket", destroyOnTimeout);
7110
- this.on("abort", clearTimer);
7111
- this.on("error", clearTimer);
7112
- this.on("response", clearTimer);
7113
- this.on("close", clearTimer);
7114
- return this;
7115
- };
7116
- [
7117
- "flushHeaders",
7118
- "getHeader",
7119
- "setNoDelay",
7120
- "setSocketKeepAlive"
7121
- ].forEach(function(method) {
7122
- RedirectableRequest.prototype[method] = function(a, b) {
7123
- return this._currentRequest[method](a, b);
7124
- };
7125
- });
7126
- ["aborted", "connection", "socket"].forEach(function(property) {
7127
- Object.defineProperty(RedirectableRequest.prototype, property, {
7128
- get: function() {
7129
- return this._currentRequest[property];
7130
- }
7131
- });
7132
- });
7133
- RedirectableRequest.prototype._sanitizeOptions = function(options) {
7134
- if (!options.headers) {
7135
- options.headers = {};
7136
- }
7137
- if (!isArray(options.sensitiveHeaders)) {
7138
- options.sensitiveHeaders = [];
7139
- }
7140
- if (options.host) {
7141
- if (!options.hostname) {
7142
- options.hostname = options.host;
7143
- }
7144
- delete options.host;
7145
- }
7146
- if (!options.pathname && options.path) {
7147
- var searchPos = options.path.indexOf("?");
7148
- if (searchPos < 0) {
7149
- options.pathname = options.path;
7150
- } else {
7151
- options.pathname = options.path.substring(0, searchPos);
7152
- options.search = options.path.substring(searchPos);
7153
- }
7154
- }
7155
- };
7156
- RedirectableRequest.prototype._performRequest = function() {
7157
- var protocol = this._options.protocol;
7158
- var nativeProtocol = this._options.nativeProtocols[protocol];
7159
- if (!nativeProtocol) {
7160
- throw new TypeError("Unsupported protocol " + protocol);
7161
- }
7162
- if (this._options.agents) {
7163
- var scheme = protocol.slice(0, -1);
7164
- this._options.agent = this._options.agents[scheme];
7165
- }
7166
- var request = this._currentRequest = nativeProtocol.request(this._options, this._onNativeResponse);
7167
- request._redirectable = this;
7168
- for (var event of events) {
7169
- request.on(event, eventHandlers[event]);
7170
- }
7171
- this._currentUrl = /^\//.test(this._options.path) ? url.format(this._options) : (
7172
- // When making a request to a proxy, […]
7173
- // a client MUST send the target URI in absolute-form […].
7174
- this._options.path
7175
- );
7176
- if (this._isRedirect) {
7177
- var i = 0;
7178
- var self = this;
7179
- var buffers = this._requestBodyBuffers;
7180
- (function writeNext(error) {
7181
- if (request === self._currentRequest) {
7182
- if (error) {
7183
- self.emit("error", error);
7184
- } else if (i < buffers.length) {
7185
- var buffer = buffers[i++];
7186
- if (!request.finished) {
7187
- request.write(buffer.data, buffer.encoding, writeNext);
7188
- }
7189
- } else if (self._ended) {
7190
- request.end();
7191
- }
7192
- }
7193
- })();
7194
- }
7195
- };
7196
- RedirectableRequest.prototype._processResponse = function(response) {
7197
- var statusCode = response.statusCode;
7198
- if (this._options.trackRedirects) {
7199
- this._redirects.push({
7200
- url: this._currentUrl,
7201
- headers: response.headers,
7202
- statusCode
7203
- });
7204
- }
7205
- var location = response.headers.location;
7206
- if (!location || this._options.followRedirects === false || statusCode < 300 || statusCode >= 400) {
7207
- response.responseUrl = this._currentUrl;
7208
- response.redirects = this._redirects;
7209
- this.emit("response", response);
7210
- this._requestBodyBuffers = [];
7211
- return;
7212
- }
7213
- destroyRequest(this._currentRequest);
7214
- response.destroy();
7215
- if (++this._redirectCount > this._options.maxRedirects) {
7216
- throw new TooManyRedirectsError();
7217
- }
7218
- var requestHeaders;
7219
- var beforeRedirect = this._options.beforeRedirect;
7220
- if (beforeRedirect) {
7221
- requestHeaders = Object.assign({
7222
- // The Host header was set by nativeProtocol.request
7223
- Host: response.req.getHeader("host")
7224
- }, this._options.headers);
7225
- }
7226
- var method = this._options.method;
7227
- if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" || // RFC7231§6.4.4: The 303 (See Other) status code indicates that
7228
- // the server is redirecting the user agent to a different resource […]
7229
- // A user agent can perform a retrieval request targeting that URI
7230
- // (a GET or HEAD request if using HTTP) […]
7231
- statusCode === 303 && !/^(?:GET|HEAD)$/.test(this._options.method)) {
7232
- this._options.method = "GET";
7233
- this._requestBodyBuffers = [];
7234
- removeMatchingHeaders(/^content-/i, this._options.headers);
7235
- }
7236
- var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
7237
- var currentUrlParts = parseUrl(this._currentUrl);
7238
- var currentHost = currentHostHeader || currentUrlParts.host;
7239
- var currentUrl = /^\w+:/.test(location) ? this._currentUrl : url.format(Object.assign(currentUrlParts, { host: currentHost }));
7240
- var redirectUrl = resolveUrl(location, currentUrl);
7241
- debug("redirecting to", redirectUrl.href);
7242
- this._isRedirect = true;
7243
- spreadUrlObject(redirectUrl, this._options);
7244
- if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) {
7245
- removeMatchingHeaders(this._headerFilter, this._options.headers);
7246
- }
7247
- if (isFunction(beforeRedirect)) {
7248
- var responseDetails = {
7249
- headers: response.headers,
7250
- statusCode
7251
- };
7252
- var requestDetails = {
7253
- url: currentUrl,
7254
- method,
7255
- headers: requestHeaders
7256
- };
7257
- beforeRedirect(this._options, responseDetails, requestDetails);
7258
- this._sanitizeOptions(this._options);
7259
- }
7260
- this._performRequest();
7261
- };
7262
- function wrap(protocols) {
7263
- var exports2 = {
7264
- maxRedirects: 21,
7265
- maxBodyLength: 10 * 1024 * 1024
7266
- };
7267
- var nativeProtocols = {};
7268
- Object.keys(protocols).forEach(function(scheme) {
7269
- var protocol = scheme + ":";
7270
- var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
7271
- var wrappedProtocol = exports2[scheme] = Object.create(nativeProtocol);
7272
- function request(input, options, callback) {
7273
- if (isURL(input)) {
7274
- input = spreadUrlObject(input);
7275
- } else if (isString(input)) {
7276
- input = spreadUrlObject(parseUrl(input));
7277
- } else {
7278
- callback = options;
7279
- options = validateUrl(input);
7280
- input = { protocol };
7281
- }
7282
- if (isFunction(options)) {
7283
- callback = options;
7284
- options = null;
7285
- }
7286
- options = Object.assign({
7287
- maxRedirects: exports2.maxRedirects,
7288
- maxBodyLength: exports2.maxBodyLength
7289
- }, input, options);
7290
- options.nativeProtocols = nativeProtocols;
7291
- if (!isString(options.host) && !isString(options.hostname)) {
7292
- options.hostname = "::1";
7293
- }
7294
- assert.equal(options.protocol, protocol, "protocol mismatch");
7295
- debug("options", options);
7296
- return new RedirectableRequest(options, callback);
7297
- }
7298
- function get(input, options, callback) {
7299
- var wrappedRequest = wrappedProtocol.request(input, options, callback);
7300
- wrappedRequest.end();
7301
- return wrappedRequest;
7302
- }
7303
- Object.defineProperties(wrappedProtocol, {
7304
- request: { value: request, configurable: true, enumerable: true, writable: true },
7305
- get: { value: get, configurable: true, enumerable: true, writable: true }
7306
- });
7307
- });
7308
- return exports2;
7309
- }
7310
- function noop() {
7311
- }
7312
- function parseUrl(input) {
7313
- var parsed;
7314
- if (useNativeURL) {
7315
- parsed = new URL2(input);
7316
- } else {
7317
- parsed = validateUrl(url.parse(input));
7318
- if (!isString(parsed.protocol)) {
7319
- throw new InvalidUrlError({ input });
7320
- }
7321
- }
7322
- return parsed;
7323
- }
7324
- function resolveUrl(relative, base) {
7325
- return useNativeURL ? new URL2(relative, base) : parseUrl(url.resolve(base, relative));
7326
- }
7327
- function validateUrl(input) {
7328
- if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
7329
- throw new InvalidUrlError({ input: input.href || input });
7330
- }
7331
- if (/^\[/.test(input.host) && !/^\[[:0-9a-f]+\](:\d+)?$/i.test(input.host)) {
7332
- throw new InvalidUrlError({ input: input.href || input });
7333
- }
7334
- return input;
7335
- }
7336
- function spreadUrlObject(urlObject, target) {
7337
- var spread = target || {};
7338
- for (var key of preservedUrlFields) {
7339
- spread[key] = urlObject[key];
7340
- }
7341
- if (spread.hostname.startsWith("[")) {
7342
- spread.hostname = spread.hostname.slice(1, -1);
7343
- }
7344
- if (spread.port !== "") {
7345
- spread.port = Number(spread.port);
7346
- }
7347
- spread.path = spread.search ? spread.pathname + spread.search : spread.pathname;
7348
- return spread;
7349
- }
7350
- function removeMatchingHeaders(regex, headers) {
7351
- var lastValue;
7352
- for (var header in headers) {
7353
- if (regex.test(header)) {
7354
- lastValue = headers[header];
7355
- delete headers[header];
7356
- }
7357
- }
7358
- return lastValue === null || typeof lastValue === "undefined" ? void 0 : String(lastValue).trim();
7359
- }
7360
- function createErrorType(code, message, baseClass) {
7361
- function CustomError(properties) {
7362
- if (isFunction(Error.captureStackTrace)) {
7363
- Error.captureStackTrace(this, this.constructor);
7364
- }
7365
- Object.assign(this, properties || {});
7366
- this.code = code;
7367
- this.message = this.cause ? message + ": " + this.cause.message : message;
7368
- }
7369
- CustomError.prototype = new (baseClass || Error)();
7370
- Object.defineProperties(CustomError.prototype, {
7371
- constructor: {
7372
- value: CustomError,
7373
- enumerable: false
7374
- },
7375
- name: {
7376
- value: "Error [" + code + "]",
7377
- enumerable: false
7378
- }
7379
- });
7380
- return CustomError;
7381
- }
7382
- function destroyRequest(request, error) {
7383
- for (var event of events) {
7384
- request.removeListener(event, eventHandlers[event]);
7385
- }
7386
- request.on("error", noop);
7387
- request.destroy(error);
7388
- }
7389
- function isSubdomain(subdomain, domain) {
7390
- assert(isString(subdomain) && isString(domain));
7391
- var dot = subdomain.length - domain.length - 1;
7392
- return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
7393
- }
7394
- function isArray(value) {
7395
- return value instanceof Array;
7396
- }
7397
- function isString(value) {
7398
- return typeof value === "string" || value instanceof String;
7399
- }
7400
- function isFunction(value) {
7401
- return typeof value === "function";
7402
- }
7403
- function isBuffer(value) {
7404
- return typeof value === "object" && "length" in value;
7405
- }
7406
- function isURL(value) {
7407
- return URL2 && value instanceof URL2;
7408
- }
7409
- function escapeRegex(regex) {
7410
- return regex.replace(/[\]\\/()*+?.$]/g, "\\$&");
7411
- }
7412
- module.exports = wrap({ http, https });
7413
- module.exports.wrap = wrap;
7414
- }
7415
- });
7416
-
7417
6142
  // ../../node_modules/events-universal/default.js
7418
6143
  var require_default = __commonJS({
7419
6144
  "../../node_modules/events-universal/default.js"(exports, module) {
@@ -8539,7 +7264,7 @@ var require_streamx = __commonJS({
8539
7264
  }
8540
7265
  }
8541
7266
  };
8542
- var Readable = class _Readable extends Stream {
7267
+ var Readable2 = class _Readable extends Stream {
8543
7268
  constructor(opts) {
8544
7269
  super(opts);
8545
7270
  this._duplexState |= OPENING | WRITE_DONE | READ_READ_AHEAD;
@@ -8556,7 +7281,7 @@ var require_streamx = __commonJS({
8556
7281
  fn().then((src) => {
8557
7282
  if (src === null) return out.end();
8558
7283
  if (out.destroying) return;
8559
- pipeline(src, out, noop);
7284
+ pipeline2(src, out, noop);
8560
7285
  }).catch((err) => out.destroy(err));
8561
7286
  return out;
8562
7287
  }
@@ -8750,7 +7475,7 @@ var require_streamx = __commonJS({
8750
7475
  return this;
8751
7476
  }
8752
7477
  };
8753
- var Duplex = class extends Readable {
7478
+ var Duplex = class extends Readable2 {
8754
7479
  // and Writable
8755
7480
  constructor(opts) {
8756
7481
  super(opts);
@@ -8843,13 +7568,13 @@ var require_streamx = __commonJS({
8843
7568
  }
8844
7569
  function pipelinePromise(...streams) {
8845
7570
  return new Promise((resolve3, reject) => {
8846
- return pipeline(...streams, (err) => {
7571
+ return pipeline2(...streams, (err) => {
8847
7572
  if (err) return reject(err);
8848
7573
  resolve3();
8849
7574
  });
8850
7575
  });
8851
7576
  }
8852
- function pipeline(stream, ...streams) {
7577
+ function pipeline2(stream, ...streams) {
8853
7578
  const all = Array.isArray(stream) ? [...stream, ...streams] : [stream, ...streams];
8854
7579
  const done = all.length && typeof all[all.length - 1] === "function" ? all.pop() : null;
8855
7580
  if (all.length < 2) throw StreamError.BAD_ARGUMENT("Pipeline requires at least 2 streams");
@@ -8947,7 +7672,7 @@ var require_streamx = __commonJS({
8947
7672
  return s._writev !== Writable.prototype._writev && s._writev !== Duplex.prototype._writev;
8948
7673
  }
8949
7674
  module.exports = {
8950
- pipeline,
7675
+ pipeline: pipeline2,
8951
7676
  pipelinePromise,
8952
7677
  isStream,
8953
7678
  isStreamx,
@@ -8959,7 +7684,7 @@ var require_streamx = __commonJS({
8959
7684
  getStreamError,
8960
7685
  Stream,
8961
7686
  Writable,
8962
- Readable,
7687
+ Readable: Readable2,
8963
7688
  Duplex,
8964
7689
  Transform,
8965
7690
  // Export PassThrough for compatibility with Node.js core's stream module
@@ -8968,9 +7693,9 @@ var require_streamx = __commonJS({
8968
7693
  }
8969
7694
  });
8970
7695
 
8971
- // ../../node_modules/tar-fs/node_modules/tar-stream/headers.js
7696
+ // ../../node_modules/@sparticuz/chromium/node_modules/tar-stream/headers.js
8972
7697
  var require_headers = __commonJS({
8973
- "../../node_modules/tar-fs/node_modules/tar-stream/headers.js"(exports) {
7698
+ "../../node_modules/@sparticuz/chromium/node_modules/tar-stream/headers.js"(exports) {
8974
7699
  var b4a = require_b4a();
8975
7700
  var ZEROS = "0000000000000000000";
8976
7701
  var SEVENS = "7777777777777777777";
@@ -9228,10 +7953,10 @@ var require_headers = __commonJS({
9228
7953
  }
9229
7954
  });
9230
7955
 
9231
- // ../../node_modules/tar-fs/node_modules/tar-stream/extract.js
7956
+ // ../../node_modules/@sparticuz/chromium/node_modules/tar-stream/extract.js
9232
7957
  var require_extract = __commonJS({
9233
- "../../node_modules/tar-fs/node_modules/tar-stream/extract.js"(exports, module) {
9234
- var { Writable, Readable, getStreamError } = require_streamx();
7958
+ "../../node_modules/@sparticuz/chromium/node_modules/tar-stream/extract.js"(exports, module) {
7959
+ var { Writable, Readable: Readable2, getStreamError } = require_streamx();
9235
7960
  var FIFO = require_fast_fifo();
9236
7961
  var b4a = require_b4a();
9237
7962
  var headers = require_headers();
@@ -9278,7 +8003,7 @@ var require_extract = __commonJS({
9278
8003
  return buf.subarray(this._offset, this._offset += size);
9279
8004
  }
9280
8005
  };
9281
- var Source = class extends Readable {
8006
+ var Source = class extends Readable2 {
9282
8007
  constructor(self, header, offset) {
9283
8008
  super();
9284
8009
  this.header = header;
@@ -9562,9 +8287,9 @@ var require_extract = __commonJS({
9562
8287
  }
9563
8288
  });
9564
8289
 
9565
- // ../../node_modules/tar-fs/node_modules/tar-stream/constants.js
8290
+ // ../../node_modules/@sparticuz/chromium/node_modules/tar-stream/constants.js
9566
8291
  var require_constants = __commonJS({
9567
- "../../node_modules/tar-fs/node_modules/tar-stream/constants.js"(exports, module) {
8292
+ "../../node_modules/@sparticuz/chromium/node_modules/tar-stream/constants.js"(exports, module) {
9568
8293
  var constants = {
9569
8294
  // just for envs without fs
9570
8295
  S_IFMT: 61440,
@@ -9582,10 +8307,10 @@ var require_constants = __commonJS({
9582
8307
  }
9583
8308
  });
9584
8309
 
9585
- // ../../node_modules/tar-fs/node_modules/tar-stream/pack.js
8310
+ // ../../node_modules/@sparticuz/chromium/node_modules/tar-stream/pack.js
9586
8311
  var require_pack = __commonJS({
9587
- "../../node_modules/tar-fs/node_modules/tar-stream/pack.js"(exports, module) {
9588
- var { Readable, Writable, getStreamError } = require_streamx();
8312
+ "../../node_modules/@sparticuz/chromium/node_modules/tar-stream/pack.js"(exports, module) {
8313
+ var { Readable: Readable2, Writable, getStreamError } = require_streamx();
9589
8314
  var b4a = require_b4a();
9590
8315
  var constants = require_constants();
9591
8316
  var headers = require_headers();
@@ -9678,7 +8403,7 @@ var require_pack = __commonJS({
9678
8403
  cb();
9679
8404
  }
9680
8405
  };
9681
- var Pack = class extends Readable {
8406
+ var Pack = class extends Readable2 {
9682
8407
  constructor(opts) {
9683
8408
  super(opts);
9684
8409
  this._drain = noop;
@@ -9816,9 +8541,9 @@ var require_pack = __commonJS({
9816
8541
  }
9817
8542
  });
9818
8543
 
9819
- // ../../node_modules/tar-fs/node_modules/tar-stream/index.js
8544
+ // ../../node_modules/@sparticuz/chromium/node_modules/tar-stream/index.js
9820
8545
  var require_tar_stream = __commonJS({
9821
- "../../node_modules/tar-fs/node_modules/tar-stream/index.js"(exports) {
8546
+ "../../node_modules/@sparticuz/chromium/node_modules/tar-stream/index.js"(exports) {
9822
8547
  exports.extract = require_extract();
9823
8548
  exports.pack = require_pack();
9824
8549
  }
@@ -10056,9 +8781,9 @@ var require_pump = __commonJS({
10056
8781
  }
10057
8782
  });
10058
8783
 
10059
- // ../../node_modules/tar-fs/index.js
8784
+ // ../../node_modules/@sparticuz/chromium/node_modules/tar-fs/index.js
10060
8785
  var require_tar_fs = __commonJS({
10061
- "../../node_modules/tar-fs/index.js"(exports) {
8786
+ "../../node_modules/@sparticuz/chromium/node_modules/tar-fs/index.js"(exports) {
10062
8787
  var tar = require_tar_stream();
10063
8788
  var pump = require_pump();
10064
8789
  var fs2 = __require("fs");
@@ -10384,10 +9109,9 @@ var require_tar_fs = __commonJS({
10384
9109
  }
10385
9110
  }
10386
9111
  });
10387
- var import_follow_redirects, import_tar_fs, setupLambdaEnvironment, isValidUrl, isRunningInAmazonLinux2023, downloadAndExtract;
9112
+ var import_tar_fs, setupLambdaEnvironment, isValidUrl, isRunningInAmazonLinux2023, downloadAndExtract;
10388
9113
  var init_helper = __esm({
10389
- "../../node_modules/@sparticuz/chromium/build/esm/helper.js"() {
10390
- import_follow_redirects = __toESM(require_follow_redirects());
9114
+ "../../node_modules/@sparticuz/chromium/build/helper.js"() {
10391
9115
  import_tar_fs = __toESM(require_tar_fs());
10392
9116
  setupLambdaEnvironment = (baseLibPath) => {
10393
9117
  process.env["FONTCONFIG_PATH"] ??= join(tmpdir(), "fonts");
@@ -10403,7 +9127,13 @@ var init_helper = __esm({
10403
9127
  };
10404
9128
  isValidUrl = (input) => {
10405
9129
  try {
10406
- return Boolean(new URL(input));
9130
+ const url = new URL(input);
9131
+ if (url.protocol === "https:")
9132
+ return true;
9133
+ if (url.protocol === "http:" && (url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "[::1]")) {
9134
+ return true;
9135
+ }
9136
+ return false;
10407
9137
  } catch {
10408
9138
  return false;
10409
9139
  }
@@ -10421,43 +9151,41 @@ var init_helper = __esm({
10421
9151
  return false;
10422
9152
  };
10423
9153
  downloadAndExtract = async (url) => {
10424
- const getOptions = new URL(url);
10425
- getOptions.maxBodyLength = 60 * 1024 * 1024;
10426
9154
  const destDir = join(tmpdir(), "chromium-pack");
10427
- return new Promise((resolve3, reject) => {
10428
- const extractObj = (0, import_tar_fs.extract)(destDir);
10429
- const cleanupOnError = (err) => {
9155
+ const response = await fetch(url, {
9156
+ redirect: "follow",
9157
+ signal: AbortSignal.timeout(3e5)
9158
+ });
9159
+ if (!response.ok) {
9160
+ throw new Error(`Unexpected status code: ${String(response.status)}.`);
9161
+ }
9162
+ if (!response.body) {
9163
+ throw new Error("Response body is empty.");
9164
+ }
9165
+ try {
9166
+ await pipeline(Readable.fromWeb(response.body), (0, import_tar_fs.extract)(destDir));
9167
+ } catch (error) {
9168
+ await new Promise((resolve3) => {
10430
9169
  rm(destDir, { force: true, recursive: true }, () => {
10431
- reject(err);
9170
+ resolve3();
10432
9171
  });
10433
- };
10434
- extractObj.once("error", cleanupOnError);
10435
- extractObj.once("finish", () => {
10436
- resolve3(destDir);
10437
- });
10438
- const req = import_follow_redirects.default.https.get(url, (response) => {
10439
- if (response.statusCode !== 200) {
10440
- reject(new Error(`Unexpected status code: ${response.statusCode?.toFixed(0) ?? "UNK"}.`));
10441
- return;
10442
- }
10443
- response.pipe(extractObj);
10444
- response.once("error", cleanupOnError);
10445
- });
10446
- req.once("error", cleanupOnError);
10447
- req.setTimeout(60 * 1e3, () => {
10448
- req.destroy();
10449
- cleanupOnError(new Error("Request timeout"));
10450
9172
  });
10451
- });
9173
+ throw error;
9174
+ }
9175
+ return destDir;
10452
9176
  };
10453
9177
  }
10454
9178
  });
10455
- var import_tar_fs2, inflate;
9179
+ var import_tar_fs2, ARCHIVE_EXTENSION_REGEX, TAR_EXTENSION_REGEX, BROTLI_EXTENSION_REGEX, GZIP_EXTENSION_REGEX, inflate;
10456
9180
  var init_lambdafs = __esm({
10457
- "../../node_modules/@sparticuz/chromium/build/esm/lambdafs.js"() {
9181
+ "../../node_modules/@sparticuz/chromium/build/lambdafs.js"() {
10458
9182
  import_tar_fs2 = __toESM(require_tar_fs());
9183
+ ARCHIVE_EXTENSION_REGEX = /\.(?:t(?:ar(?:\.(?:br|gz))?|br|gz)|br|gz)$/i;
9184
+ TAR_EXTENSION_REGEX = /\.t(?:ar(?:\.(?:br|gz))?|br|gz)$/i;
9185
+ BROTLI_EXTENSION_REGEX = /br$/i;
9186
+ GZIP_EXTENSION_REGEX = /gz$/i;
10459
9187
  inflate = (filePath) => {
10460
- const output = filePath.includes("swiftshader") ? tmpdir() : join(tmpdir(), basename(filePath).replace(/\.(?:t(?:ar(?:\.(?:br|gz))?|br|gz)|br|gz)$/i, ""));
9188
+ const output = filePath.includes("swiftshader") ? tmpdir() : join(tmpdir(), basename(filePath).replace(ARCHIVE_EXTENSION_REGEX, ""));
10461
9189
  return new Promise((resolve3, reject) => {
10462
9190
  if (filePath.includes("swiftshader")) {
10463
9191
  if (existsSync(`${output}/libGLESv2.so`)) {
@@ -10468,9 +9196,9 @@ var init_lambdafs = __esm({
10468
9196
  resolve3(output);
10469
9197
  return;
10470
9198
  }
10471
- const isBrotli = /br$/i.test(filePath);
10472
- const isGzip = /gz$/i.test(filePath);
10473
- const isTar = /\.t(?:ar(?:\.(?:br|gz))?|br|gz)$/i.test(filePath);
9199
+ const isBrotli = BROTLI_EXTENSION_REGEX.test(filePath);
9200
+ const isGzip = GZIP_EXTENSION_REGEX.test(filePath);
9201
+ const isTar = TAR_EXTENSION_REGEX.test(filePath);
10474
9202
  const highWaterMark = 2 ** 22;
10475
9203
  const source = createReadStream(filePath, { highWaterMark });
10476
9204
  let target;
@@ -10502,24 +9230,28 @@ var init_lambdafs = __esm({
10502
9230
  }
10503
9231
  });
10504
9232
  function getBinPath() {
10505
- return join(dirname(fileURLToPath(import.meta.url)), "..", "..", "bin");
9233
+ return join(dirname(fileURLToPath(import.meta.url)), "..", "bin");
10506
9234
  }
10507
- var init_paths_esm = __esm({
10508
- "../../node_modules/@sparticuz/chromium/build/esm/paths.esm.js"() {
9235
+ var init_paths = __esm({
9236
+ "../../node_modules/@sparticuz/chromium/build/paths.js"() {
10509
9237
  }
10510
9238
  });
10511
9239
 
10512
- // ../../node_modules/@sparticuz/chromium/build/esm/index.js
10513
- var esm_exports = {};
10514
- __export(esm_exports, {
10515
- default: () => esm_default
9240
+ // ../../node_modules/@sparticuz/chromium/build/index.js
9241
+ var build_exports = {};
9242
+ __export(build_exports, {
9243
+ default: () => build_default,
9244
+ inflate: () => inflate,
9245
+ setupLambdaEnvironment: () => setupLambdaEnvironment
10516
9246
  });
10517
- var nodeMajorVersion, Chromium, esm_default;
10518
- var init_esm = __esm({
10519
- "../../node_modules/@sparticuz/chromium/build/esm/index.js"() {
9247
+ var nodeMajorVersion, Chromium, build_default;
9248
+ var init_build = __esm({
9249
+ "../../node_modules/@sparticuz/chromium/build/index.js"() {
9250
+ init_helper();
9251
+ init_lambdafs();
9252
+ init_paths();
10520
9253
  init_helper();
10521
9254
  init_lambdafs();
10522
- init_paths_esm();
10523
9255
  nodeMajorVersion = Number.parseInt(process.versions.node.split(".")[0] ?? "");
10524
9256
  if (isRunningInAmazonLinux2023(nodeMajorVersion)) {
10525
9257
  setupLambdaEnvironment(join(tmpdir(), "al2023", "lib"));
@@ -10638,7 +9370,7 @@ var init_esm = __esm({
10638
9370
  }
10639
9371
  input ??= getBinPath();
10640
9372
  if (!existsSync(input)) {
10641
- throw new Error(`The input directory "${input}" does not exist. Please provide the location of the brotli files.`);
9373
+ throw new Error(`The input directory "${input}" does not exist. If you are using a bundler (esbuild, webpack, etc.), you must externalize @sparticuz/chromium so it is not relocated. See: https://github.com/Sparticuz/chromium#bundler-configuration`);
10642
9374
  }
10643
9375
  const promises = [
10644
9376
  inflate(join(input, "chromium.br")),
@@ -10652,7 +9384,7 @@ var init_esm = __esm({
10652
9384
  return result.shift();
10653
9385
  }
10654
9386
  };
10655
- esm_default = Chromium;
9387
+ build_default = Chromium;
10656
9388
  }
10657
9389
  });
10658
9390
 
@@ -10759,7 +9491,7 @@ ${bundledCode}
10759
9491
  async function captureScreenshot(html, viewport = { width: 1280, height: 800 }) {
10760
9492
  try {
10761
9493
  const puppeteer = await import('puppeteer-core');
10762
- const chromium = await Promise.resolve().then(() => (init_esm(), esm_exports));
9494
+ const chromium = await Promise.resolve().then(() => (init_build(), build_exports));
10763
9495
  const launchOptions = {
10764
9496
  args: chromium.default.args,
10765
9497
  defaultViewport: viewport,
@@ -10769,7 +9501,9 @@ async function captureScreenshot(html, viewport = { width: 1280, height: 800 })
10769
9501
  const browser = await puppeteer.default.launch(launchOptions);
10770
9502
  try {
10771
9503
  const page = await browser.newPage();
10772
- await page.setContent(html, { waitUntil: "networkidle0", timeout: 15e3 });
9504
+ await page.setContent(html, { waitUntil: "load", timeout: 15e3 });
9505
+ await page.waitForNetworkIdle({ idleTime: 500, timeout: 15e3 }).catch(() => {
9506
+ });
10773
9507
  await page.waitForSelector("#root > *", { timeout: 1e4 }).catch(() => {
10774
9508
  });
10775
9509
  await new Promise((r) => setTimeout(r, 1e3));
@@ -13171,11 +11905,11 @@ var stateFragments = {
13171
11905
  axis: "state",
13172
11906
  value: "merge",
13173
11907
  cacheTier: "axisDelta",
13174
- promptText: "## State: merge (live entity reconciliation)\n1. Seed `const [items, setItems] = useState(props.items ?? [])`.\n2. On stream updates: `setItems(prev => prev.map(it => it.id === event.id ? { ...it, ...event } : it))` \u2014 merge by id, do NOT append.\n3. Memoize derived views (grouping/sorting/filtering) with useMemo.\n4. Per-item actions pass `{ id, ... }` in the payload.\n5. Never push the stream payload into an append-only list unless realtime=append.",
11908
+ promptText: "## State: merge (live entity reconciliation)\n1. Seed `const [items, setItems] = useState(props.items ?? [])` AND re-seed on prop change: `useEffect(() => setItems(props.items ?? []), [props.items])` \u2014 a `ggui_amend` repaint must move the list.\n2. On stream updates: `setItems(prev => prev.map(it => it.id === event.id ? { ...it, ...event } : it))` \u2014 merge by id, do NOT append.\n3. Memoize derived views (grouping/sorting/filtering) with useMemo.\n4. Per-item actions pass `{ id, ... }` in the payload.\n5. Never push the stream payload into an append-only list unless realtime=append.",
13175
11909
  boilerplateMarker: [
13176
11910
  "",
13177
11911
  " // \u2500\u2500 Live entity state (merge-by-id) \u2500\u2500",
13178
- " // useState(props.items ?? []); merge stream events by item.id; never append.",
11912
+ " // useState(props.items ?? []); re-seed via useEffect on [props.items]; merge stream events by item.id; never append.",
13179
11913
  ""
13180
11914
  ].join("\n")
13181
11915
  },
@@ -13293,13 +12027,13 @@ var realtimeFragments = {
13293
12027
  axis: "realtime",
13294
12028
  value: "merge",
13295
12029
  cacheTier: "axisDelta",
13296
- promptText: "## Realtime: merge\nStream events carry an id; merge into LOCAL STATE. Subscribing alone is not enough \u2014 the local list must update on each event for the DOM to re-render.\n\n```tsx\nconst stream = useStream<UpdateT>('streamName');\nconst [items, setItems] = useState(props.items);\nuseEffect(() => {\n if (!stream.latest) return;\n setItems((prev) => prev.map((it) => it.id === stream.latest!.id ? { ...it, ...stream.latest } : it));\n}, [stream.latest]);\n// Render `items.map(...)` \u2014 NOT props.items, NOT stream.all.\n```\n\nNever append \u2014 stream=merge means the entity already exists locally."
12030
+ promptText: "## Realtime: merge\nStream events carry an id; merge into LOCAL STATE. Subscribing alone is not enough \u2014 the local list must update on each event for the DOM to re-render.\n\n```tsx\nconst stream = useStream<UpdateT>('streamName');\nconst [items, setItems] = useState(props.items);\nuseEffect(() => setItems(props.items), [props.items]); // re-seed on ggui_amend repaint \u2014 props stay the source of truth\nuseEffect(() => {\n if (!stream.latest) return;\n setItems((prev) => prev.map((it) => it.id === stream.latest!.id ? { ...it, ...stream.latest } : it));\n}, [stream.latest]);\n// Render `items.map(...)` \u2014 NOT props.items, NOT stream.all.\n```\n\nNever append \u2014 stream=merge means the entity already exists locally."
13297
12031
  },
13298
12032
  append: {
13299
12033
  axis: "realtime",
13300
12034
  value: "append",
13301
12035
  cacheTier: "axisDelta",
13302
- promptText: "## Realtime: append\nStream events are new entities; APPEND to local state. Subscribing alone is not enough \u2014 the local list must update for the DOM to re-render.\n\n```tsx\nconst stream = useStream<EventT>('streamName');\nconst [items, setItems] = useState(props.items);\nuseEffect(() => {\n if (!stream.latest) return;\n setItems((prev) => [...prev, stream.latest!]);\n}, [stream.latest]);\n// Render `items.map(...)` \u2014 NOT props.items, NOT stream.all (which accumulates only post-mount).\n```\n\nUse head for newest-first, tail for chat-style. Cap list length if needed. Do not dedupe unless the contract guarantees at-most-once."
12036
+ promptText: "## Realtime: append\nStream events are new entities; APPEND to local state. Subscribing alone is not enough \u2014 the local list must update for the DOM to re-render.\n\n```tsx\nconst stream = useStream<EventT>('streamName');\nconst [items, setItems] = useState(props.items);\nuseEffect(() => setItems(props.items), [props.items]); // re-seed on ggui_amend repaint \u2014 props stay the source of truth\nuseEffect(() => {\n if (!stream.latest) return;\n setItems((prev) => [...prev, stream.latest!]);\n}, [stream.latest]);\n// Render `items.map(...)` \u2014 NOT props.items, NOT stream.all (which accumulates only post-mount).\n```\n\nUse head for newest-first, tail for chat-style. Cap list length if needed. Do not dedupe unless the contract guarantees at-most-once."
13303
12037
  },
13304
12038
  status: {
13305
12039
  axis: "realtime",
@@ -13317,7 +12051,7 @@ var realtimeFragments = {
13317
12051
  axis: "realtime",
13318
12052
  value: "mixed",
13319
12053
  cacheTier: "axisDelta",
13320
- promptText: "## Realtime: mixed\nMultiple stream channels with DIFFERENT semantics. Each `streamKinds` entry in the contract maps to one of: merge, append, status, presence. Subscribe + sync to local state PER CHANNEL \u2014 subscribing alone never re-renders the DOM.\n\nExample (chat-interface \u2014 message=append, typing=presence):\n\n```tsx\nconst messages = useStream<MessageT>('message');\nconst typing = useStream<TypingT>('typing');\nconst [messageList, setMessageList] = useState(props.messages);\nconst [typingUsers, setTypingUsers] = useState<Set<string>>(new Set());\n\nuseEffect(() => {\n if (!messages.latest) return;\n setMessageList((prev) => [...prev, messages.latest!]);\n}, [messages.latest]);\n\nuseEffect(() => {\n if (!typing.latest) return;\n setTypingUsers((prev) => {\n const next = new Set(prev);\n if (typing.latest!.active) next.add(typing.latest!.sender);\n else next.delete(typing.latest!.sender);\n return next;\n });\n}, [typing.latest]);\n```\n\nDo NOT treat all events the same. Do NOT skip the local-state sync \u2014 `useStream` alone won't trigger DOM updates of your derived view.",
12054
+ promptText: "## Realtime: mixed\nMultiple stream channels with DIFFERENT semantics. Each `streamKinds` entry in the contract maps to one of: merge, append, status, presence. Subscribe + sync to local state PER CHANNEL \u2014 subscribing alone never re-renders the DOM.\n\nExample (chat-interface \u2014 message=append, typing=presence):\n\n```tsx\nconst messages = useStream<MessageT>('message');\nconst typing = useStream<TypingT>('typing');\nconst [messageList, setMessageList] = useState(props.messages);\nconst [typingUsers, setTypingUsers] = useState<Set<string>>(new Set());\n\nuseEffect(() => setMessageList(props.messages), [props.messages]); // re-seed on ggui_amend repaint\n\nuseEffect(() => {\n if (!messages.latest) return;\n setMessageList((prev) => [...prev, messages.latest!]);\n}, [messages.latest]);\n\nuseEffect(() => {\n if (!typing.latest) return;\n setTypingUsers((prev) => {\n const next = new Set(prev);\n if (typing.latest!.active) next.add(typing.latest!.sender);\n else next.delete(typing.latest!.sender);\n return next;\n });\n}, [typing.latest]);\n```\n\nDo NOT treat all events the same. Do NOT skip the local-state sync \u2014 `useStream` alone won't trigger DOM updates of your derived view.",
13321
12055
  boilerplateMarker: [
13322
12056
  "",
13323
12057
  " // \u2500\u2500 Mixed stream handlers \u2500\u2500",
@@ -14191,13 +12925,14 @@ A \`DataContract\` declares everything a GguiSession exchanges with the outside
14191
12925
 
14192
12926
  ## Defensive coding for absent / late-arriving data
14193
12927
 
14194
- Props arrive via \`ggui_update\` and may be partial on first render. Stream channels start empty and fill over time. Context slots start at their declared default (often \`null\`). **Never assume a field exists before you read it.**
12928
+ Props arrive at mount and may be partial on first render; later prop changes reach the SAME mounted component via \`ggui_amend\` (in-place repaint) on the live channel. Stream channels start empty and fill over time. Context slots start at their declared default (often \`null\`). **Never assume a field exists before you read it.**
14195
12929
 
14196
12930
  - **Array iteration**: always default to \`[]\` before \`.map\`/\`.filter\`/\`.length\`. Use \`(props.items ?? []).map(...)\` not \`props.items.map(...)\`. Same for stream.all, stream.latest, etc.
14197
12931
  - **Object access**: optional-chain through nested fields. \`props.user?.name ?? 'Anonymous'\` not \`props.user.name\`.
14198
12932
  - **Number ops**: default before arithmetic. \`(props.count ?? 0) + 1\` not \`props.count + 1\`.
14199
12933
  - **Stream latest**: \`useStream\` returns \`{latest: T | null, all: T[], isComplete: boolean}\`. The default \`all\` is \`[]\` so it's safe to map; \`latest\` is null until the first frame arrives \u2014 guard before reading \`.foo\`.
14200
12934
  - **Stream reconciliation**: when a stream event carries an \`action\` discriminant (e.g. \`create | move | edit | delete\`), the channel is a CRUD feed \u2014 your handler MUST branch on EVERY value: append on \`create\`, drop on \`delete\`, replace-by-id on \`move\` / \`edit\`. Merging only the "edit" case silently loses created and deleted items. Reconcile into the SAME state that seeds from \`props\` (e.g. \`useState(() => props.tasks ?? [])\`) so the seed data and the live feed render as one list \u2014 and handle an event whose id is not yet present (a \`create\` for an unknown item) by inserting it, not ignoring it.
12935
+ - **Props re-sync on repaint**: props the agent owns are the source of truth for display \u2014 prefer rendering DIRECTLY from \`props\` (controlled, no local copy). When local optimistic state genuinely needs a prop seed (a click bumps a count before the agent confirms), it MUST re-sync on prop change \u2014 \`useEffect(() => setCount(props.count ?? 0), [props.count])\` \u2014 or a \`ggui_amend\` repaint applies the new props while the display keeps the stale local value. BAD: \`const [count, setCount] = useState(props.count ?? 0)\` alone. GOOD: the same seed + the one-line re-sync effect.
14201
12936
  - **Loading state**: while data is still absent, render \`<Skeleton>\` placeholders \u2014 never a blank screen. \`<Skeleton variant="text" />\` for a text line, \`variant="circle"\` for an avatar slot, default \`rect\` for a block.
14202
12937
  - **Empty state**: when a list or results array is empty, render \`<EmptyState title="\u2026" description="\u2026" />\` \u2014 a region that renders nothing when empty looks broken to the user.
14203
12938
 
@@ -14325,7 +13060,7 @@ Every value change is mirrored to the host LLM's context automatically (debounce
14325
13060
 
14326
13061
  **When NOT to use it.** Local UI state the contract did NOT declare \u2014 \`isDropdownOpen\`, hover flags, animation phase, ephemeral toggles. For those, use a plain \`useState\` directly. The runtime ignores undeclared state.
14327
13062
 
14328
- **\`contextSpec\` direction is one-way: client \u2192 agent.** The agent uses \`propsSpec\` (via \`ggui_update\`) and \`streamSpec\` (via the live channel) to push state TO the client. Don't try to write to the agent via \`contextSpec\` \u2014 there is no return path.
13063
+ **\`contextSpec\` direction is one-way: client \u2192 agent.** The agent uses \`propsSpec\` (via \`ggui_amend\` for in-place repaints of this mount, or \`ggui_update\` when it mints a new history card) and \`streamSpec\` (via the live channel) to push state TO the client. Don't try to write to the agent via \`contextSpec\` \u2014 there is no return path.
14329
13064
 
14330
13065
  **Schema mismatches drop silently.** If you set a value that doesn't match the slot's schema (e.g. a string into a \`{type: 'number'}\` slot), the runtime logs a dev \`console.warn\` and skips the post. Make sure your setter calls produce values that match the declared shape.
14331
13066
 
@@ -15432,6 +14167,31 @@ function runNoPhantomUseState(input) {
15432
14167
  }
15433
14168
  return issues;
15434
14169
  }
14170
+ function runPropSeedNoResync(input) {
14171
+ if (input.compiledCode === null) return [];
14172
+ const src = input.sourceCode;
14173
+ const issues = [];
14174
+ const re = /const\s*\[\s*(\w+)\s*,\s*(\w+)\s*\]\s*=\s*useState(?:<[^>]*>)?\s*\(\s*props\??\.(\w+)/g;
14175
+ for (const m of src.matchAll(re)) {
14176
+ const [full, stateVar, setter, propName] = m;
14177
+ const idx = m.index ?? 0;
14178
+ const after = src.slice(idx + full.length);
14179
+ if (!new RegExp(`\\b${setter}\\s*\\(`).test(after)) continue;
14180
+ const resync = new RegExp(
14181
+ `\\[[^\\[\\]]*props\\??\\.${propName}\\b[^\\[\\]]*\\]`
14182
+ );
14183
+ if (resync.test(src)) continue;
14184
+ issues.push(
14185
+ mkIssue(
14186
+ "universal.prop_seed_no_resync",
14187
+ `useState(props.${propName}) seeds "${stateVar}" and mutates it, but no effect depends on [props.${propName}] \u2014 a ggui_amend repaint pushes new props that never reach this display (#480).`,
14188
+ `Add \`useEffect(() => ${setter}(props.${propName}), [props.${propName}]);\` so agent repaints re-seed the state, or derive the display directly from props.${propName}.`,
14189
+ "warn"
14190
+ )
14191
+ );
14192
+ }
14193
+ return issues;
14194
+ }
15435
14195
  var UNIVERSAL_CHECKS = [
15436
14196
  {
15437
14197
  id: "universal.prop_coverage",
@@ -15450,6 +14210,12 @@ var UNIVERSAL_CHECKS = [
15450
14210
  axis: "render",
15451
14211
  values: ALL_RENDER_VALUES,
15452
14212
  run: runNoPhantomUseState
14213
+ },
14214
+ {
14215
+ id: "universal.prop_seed_no_resync",
14216
+ axis: "render",
14217
+ values: ALL_RENDER_VALUES,
14218
+ run: runPropSeedNoResync
15453
14219
  }
15454
14220
  ];
15455
14221
 
@@ -15469,7 +14235,7 @@ function runStateSeededFromProps(input) {
15469
14235
  mkIssue(
15470
14236
  "state.merge.seeded_from_props",
15471
14237
  `Entity collection "${e.name}" is not seeded from props \u2014 no useState initializer reads props.${e.name}.`,
15472
- `Add \`const [${e.name}, set${cap(e.name)}] = useState(props.${e.name});\` so stream/action updates can merge into live state.`
14238
+ `Add \`const [${e.name}, set${cap(e.name)}] = useState(props.${e.name});\` paired with \`useEffect(() => set${cap(e.name)}(props.${e.name}), [props.${e.name}]);\` so stream/action updates merge into live state AND agent repaints (ggui_amend) re-seed it (#480).`
15473
14239
  )
15474
14240
  );
15475
14241
  }
@@ -17128,8 +15894,8 @@ async function setupHappyDom() {
17128
15894
  };
17129
15895
  }
17130
15896
  const { Window } = await import('happy-dom');
17131
- const window2 = new Window({ url: "https://render-check.local" });
17132
- const windowAny = openRecord(window2);
15897
+ const window = new Window({ url: "https://render-check.local" });
15898
+ const windowAny = openRecord(window);
17133
15899
  const keys = [
17134
15900
  "window",
17135
15901
  "document",
@@ -18992,7 +17758,13 @@ async function runEvalRound(ctx, input) {
18992
17758
  },
18993
17759
  {
18994
17760
  provider: mapProviderForEvaluator(evaluationAgent.provider),
18995
- model: evaluationAgent.model
17761
+ model: evaluationAgent.model,
17762
+ // #484 — thread the coding-agent's routing override
17763
+ // through to the evaluator so its LLM call never falls
17764
+ // back to `process.env` either (the eval calls run
17765
+ // inside the same concurrent generation, so the race is
17766
+ // real here too, not just on the coding turn).
17767
+ routeOverride: evaluationAgent.routeOverride
18996
17768
  },
18997
17769
  preWarmedContext
18998
17770
  ) : null,
@@ -19640,7 +18412,7 @@ async function initSession(input) {
19640
18412
  await workspace.stage();
19641
18413
  await workspace.commit("scaffold: boilerplate");
19642
18414
  const systemPrompt = input.systemPromptOverride ?? harness.how.systemPrompt;
19643
- const codingAgent = createAgent(agents.coding.provider);
18415
+ const codingAgent = createAgent(agents.coding);
19644
18416
  await codingAgent.warmCache(
19645
18417
  agents.coding.model,
19646
18418
  systemPrompt,
@@ -19729,8 +18501,16 @@ async function dispatchGeneration(params) {
19729
18501
  }
19730
18502
  const routerProvider = mapProviderForLLMRouter(params.provider);
19731
18503
  const resolvedModel = params.models?.coding ?? params.models?.default ?? params.model;
19732
- const codingAgent = { provider: routerProvider, model: resolvedModel };
19733
- const evaluationAgent = params.models?.evaluation ? { provider: routerProvider, model: params.models.evaluation } : void 0;
18504
+ const codingAgent = {
18505
+ provider: routerProvider,
18506
+ model: resolvedModel,
18507
+ routeOverride: params.routeOverride
18508
+ };
18509
+ const evaluationAgent = params.models?.evaluation ? {
18510
+ provider: routerProvider,
18511
+ model: params.models.evaluation,
18512
+ routeOverride: params.routeOverride
18513
+ } : void 0;
19734
18514
  const effectiveContract = params.contract;
19735
18515
  const sessionParams = {
19736
18516
  userPrompt: params.originalPrompt ?? params.userPrompt,
@@ -20177,7 +18957,8 @@ function createUiGenerator(options = {}) {
20177
18957
  maxAttempts,
20178
18958
  maxEvalRounds,
20179
18959
  qualityConfig,
20180
- gadgetCatalog
18960
+ gadgetCatalog,
18961
+ disableEnvMutation = false
20181
18962
  } = options;
20182
18963
  const identity = resolveIdentity(options);
20183
18964
  return {
@@ -20206,16 +18987,22 @@ function createUiGenerator(options = {}) {
20206
18987
  });
20207
18988
  }
20208
18989
  const envBackup = {};
20209
- for (const k of Object.keys(route.env)) envBackup[k] = process.env[k];
20210
- const baseEnvForApply = {};
20211
- for (const [k, v] of Object.entries(process.env)) {
20212
- if (v !== void 0) baseEnvForApply[k] = v;
20213
- }
20214
- const routedEnv = applyRouteToEnv(baseEnvForApply, route);
20215
- for (const [k, v] of Object.entries(routedEnv)) process.env[k] = v;
20216
- for (const [k, v] of Object.entries(route.env)) {
20217
- if (v === void 0) delete process.env[k];
18990
+ if (!disableEnvMutation) {
18991
+ for (const k of Object.keys(route.env)) envBackup[k] = process.env[k];
18992
+ const baseEnvForApply = {};
18993
+ for (const [k, v] of Object.entries(process.env)) {
18994
+ if (v !== void 0) baseEnvForApply[k] = v;
18995
+ }
18996
+ const routedEnv = applyRouteToEnv(baseEnvForApply, route);
18997
+ for (const [k, v] of Object.entries(routedEnv)) process.env[k] = v;
18998
+ for (const [k, v] of Object.entries(route.env)) {
18999
+ if (v === void 0) delete process.env[k];
19000
+ }
20218
19001
  }
19002
+ const routeOverride = disableEnvMutation ? {
19003
+ apiKey: route.env["ANTHROPIC_API_KEY"] ?? route.env["OPENAI_API_KEY"] ?? route.env["GEMINI_API_KEY"] ?? route.env["OPENROUTER_API_KEY"],
19004
+ useBedrock: route.env["CLAUDE_CODE_USE_BEDROCK"] === "1"
19005
+ } : void 0;
20219
19006
  try {
20220
19007
  const tools = createGeneratorTools({
20221
19008
  ...input.contract ? { contract: input.contract } : {}
@@ -20248,7 +19035,8 @@ function createUiGenerator(options = {}) {
20248
19035
  // `Type:` lines and the coding-agent typecheck overlay via
20249
19036
  // `dispatchGeneration`.
20250
19037
  ...input.gadgetTypes !== void 0 ? { gadgetTypes: input.gadgetTypes } : {},
20251
- enableRuntimeRender
19038
+ enableRuntimeRender,
19039
+ ...routeOverride !== void 0 ? { routeOverride } : {}
20252
19040
  });
20253
19041
  const metadata = {
20254
19042
  provider: input.llm.provider,