@reticular/speakable 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -240,8 +240,15 @@ var ParsingError = class extends Error {
240
240
  this.name = "ParsingError";
241
241
  }
242
242
  };
243
+ var MAX_INPUT_SIZE = 10 * 1024 * 1024;
243
244
  function parseHTML(html) {
244
245
  const warnings = [];
246
+ const inputSize = Buffer.byteLength(html, "utf-8");
247
+ if (inputSize > MAX_INPUT_SIZE) {
248
+ throw new ParsingError(
249
+ `Input exceeds maximum size of ${MAX_INPUT_SIZE / (1024 * 1024)} MB (received ${(inputSize / (1024 * 1024)).toFixed(1)} MB). Use CSS selectors to analyze specific sections of large documents.`
250
+ );
251
+ }
245
252
  try {
246
253
  const dom = new JSDOM(html, {
247
254
  contentType: "text/html",
@@ -2554,14 +2561,22 @@ function processHTML(html, options, diffHTML) {
2554
2561
  }
2555
2562
  return processNormal(html, options, warnings, colorize);
2556
2563
  } catch (error) {
2557
- if (error instanceof Error) {
2564
+ if (error instanceof ParsingError) {
2558
2565
  return {
2559
- output: `Error: ${error.message}`,
2566
+ output: `Parse error: ${error.message}`,
2560
2567
  exitCode: 2,
2561
2568
  // Content error
2562
2569
  warnings
2563
2570
  };
2564
2571
  }
2572
+ if (error instanceof Error) {
2573
+ return {
2574
+ output: `Error: ${error.message}`,
2575
+ exitCode: 3,
2576
+ // System error
2577
+ warnings
2578
+ };
2579
+ }
2565
2580
  throw error;
2566
2581
  }
2567
2582
  }