@opencraw/studio 0.0.12 → 0.0.13

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 (2) hide show
  1. package/dist/index.esm.js +11 -7
  2. package/package.json +3 -3
package/dist/index.esm.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { join, dirname, basename, extname, normalize, sep, resolve } from 'node:path';
2
2
  import { createServer } from 'node:http';
3
+ import { promisify, stripVTControlCharacters } from 'node:util';
3
4
  import { fileURLToPath, pathToFileURL } from 'node:url';
4
5
  import { z } from 'zod';
5
6
  import { BODY_KINDS, HttpClient, BrowserClient, NODE_ID_ATTRIBUTE, sessionStateOf, rowsOfCells, parseXml, findDeckTables, findGridTables, analyzeTables, parseRegion, regionText, deckRegionText, isDeckDocument, readRecipeSource, parseInputRecipe, parseOutputRecipe, bindRecipeSet, memorySink, createCrawler, traceLine, UnknownHookError, resolveMissingPolicy, isWorkbookDocument, RecipeBindingError, RecipeValidationError, countMatches, matchesOf, tryParseJson, isPdfDocument, BrowserProfiles } from '@opencraw/core';
6
7
  import { randomBytes, createHash } from 'node:crypto';
7
8
  import { execFile } from 'node:child_process';
8
9
  import { createRequire } from 'node:module';
9
- import { promisify } from 'node:util';
10
10
  import { load } from 'cheerio';
11
11
  import { readFile, writeFile, mkdir } from 'node:fs/promises';
12
12
  import { describeJson } from '@opencraw/probe';
@@ -2125,9 +2125,9 @@ async function runToResult(crawler, set, recipeId, records, rejectedRecords, ste
2125
2125
  }
2126
2126
  /** What a run that could not start reports. A hook is the author's own code, which Studio never loads (issue #150): say so, instead of leaving "unknown hook" to read as a typo. */
2127
2127
  function failureMessage(error) {
2128
- if (error instanceof UnknownHookError) return `${error.message}. Studio does not load hooks, so a recipe that uses one cannot be sample-run here; run it with the cli or the mcp server, or temporarily replace the hook step to preview the rest.`;
2129
- if (error instanceof Error) return error.message;
2130
- return String(error);
2128
+ if (error instanceof UnknownHookError) return `${stripVTControlCharacters(error.message)}. Studio does not load hooks, so a recipe that uses one cannot be sample-run here; run it with the cli or the mcp server, or temporarily replace the hook step to preview the rest.`;
2129
+ if (error instanceof Error) return stripVTControlCharacters(error.message);
2130
+ return stripVTControlCharacters(String(error));
2131
2131
  }
2132
2132
 
2133
2133
  /** @returns A fresh, empty cache. */
@@ -5090,7 +5090,7 @@ async function handlePdfBytesRequest(response, state, query) {
5090
5090
  response.end(Buffer.from(bytes));
5091
5091
  } catch (error) {
5092
5092
  respondJson(response, 500, {
5093
- error: error instanceof Error ? error.message : String(error)
5093
+ error: messageOf(error)
5094
5094
  });
5095
5095
  }
5096
5096
  }
@@ -5108,7 +5108,7 @@ async function handleCommand(request, response, state) {
5108
5108
  command = parsed.data;
5109
5109
  } catch (error) {
5110
5110
  respondJson(response, 400, {
5111
- error: error instanceof Error ? error.message : String(error)
5111
+ error: messageOf(error)
5112
5112
  });
5113
5113
  return;
5114
5114
  }
@@ -5116,7 +5116,7 @@ async function handleCommand(request, response, state) {
5116
5116
  respondJson(response, 200, await dispatch(command, state));
5117
5117
  } catch (error) {
5118
5118
  respondJson(response, 500, {
5119
- error: error instanceof Error ? error.message : String(error)
5119
+ error: messageOf(error)
5120
5120
  });
5121
5121
  }
5122
5122
  }
@@ -5246,6 +5246,10 @@ function handleUpgrade(request, socket, token, state) {
5246
5246
  state.sockets.delete(connection);
5247
5247
  });
5248
5248
  }
5249
+ /** An error's message as plain text: Playwright colours its call logs with ANSI codes, which a browser would show as raw escapes (issue #187). */
5250
+ function messageOf(error) {
5251
+ return stripVTControlCharacters(error instanceof Error ? error.message : String(error));
5252
+ }
5249
5253
 
5250
5254
  /**
5251
5255
  * Runs `opencraw-studio`: starts the server, opens `folder` (if given) as
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencraw/studio",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.esm.js",
6
6
  "module": "./dist/index.esm.js",
@@ -24,8 +24,8 @@
24
24
  "!**/*.js.map"
25
25
  ],
26
26
  "dependencies": {
27
- "@opencraw/core": "^0.1.23",
28
- "@opencraw/probe": "^0.0.6",
27
+ "@opencraw/core": "^0.1.24",
28
+ "@opencraw/probe": "^0.0.7",
29
29
  "cheerio": "^1.2.0",
30
30
  "playwright": "^1.63.0",
31
31
  "zod": "^4.6.5",