@danielx/civet 0.9.3 → 0.9.4

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.
@@ -20,9 +20,14 @@ try {
20
20
  throw `Unknown operation: ${op}`;
21
21
  }
22
22
  }
23
- return parentPort.postMessage({ id, result });
23
+ return parentPort.postMessage({ id, result, errors: args[1]?.errors });
24
24
  } catch (error) {
25
- return parentPort.postMessage({ id, error });
25
+ console.log(`Civet worker failed to compile:`, error);
26
+ return parentPort.postMessage({ id, error: {
27
+ type: error.constructor.name,
28
+ name: error.name,
29
+ message: error.message
30
+ } });
26
31
  }
27
32
  });
28
33
  }
package/dist/types.d.ts CHANGED
@@ -62,14 +62,15 @@ declare module "@danielx/civet" {
62
62
 
63
63
  export type SourceMapping = [number] | [number, number, number, number]
64
64
 
65
- export interface SourceMap {
65
+ export class SourceMap {
66
+ constructor(source: string)
66
67
  updateSourceMap?(outputStr: string, inputPos: number): void
67
68
  json(srcFileName: string, outFileName: string): unknown
68
- data: {
69
- lines: SourceMapping[][]
70
- }
69
+ source: string
70
+ lines: SourceMapping[][]
71
+ /** @deprecated */
72
+ data: { lines: SourceMapping[][] }
71
73
  }
72
- export function SourceMap(source: string): SourceMap
73
74
 
74
75
  // TODO: Import ParseError class from Hera
75
76
  export type ParseError = {
@@ -121,7 +122,7 @@ declare module "@danielx/civet" {
121
122
  sourcemap: {
122
123
  locationTable(input: string): number[]
123
124
  lookupLineColumn(table: number[], pos: number): [number, number]
124
- SourceMap(input: string): SourceMap
125
+ SourceMap: typeof SourceMap
125
126
  }
126
127
  }
127
128
 
@@ -290,7 +290,7 @@ var rawPlugin = (options = {}, meta) => {
290
290
  if (!file) return diagnostic;
291
291
  const sourceMap = sourceMaps.get(file.fileName);
292
292
  if (!sourceMap) return diagnostic;
293
- const sourcemapLines = sourceMap.data.lines;
293
+ const sourcemapLines = sourceMap.lines ?? sourceMap.data.lines;
294
294
  const range = (0, import_ts_diagnostic.remapRange)(
295
295
  {
296
296
  start: diagnostic.start || 0,
@@ -462,7 +462,7 @@ var rawPlugin = (options = {}, meta) => {
462
462
  ...civetOptions,
463
463
  ast: true
464
464
  });
465
- const civetSourceMap = (0, import_civet.SourceMap)(rawCivetSource);
465
+ const civetSourceMap = new import_civet.SourceMap(rawCivetSource);
466
466
  if (ts === "civet") {
467
467
  compiled = await import_civet.default.generate(ast, {
468
468
  ...civetOptions,
@@ -258,7 +258,7 @@ var rawPlugin = (options = {}, meta) => {
258
258
  if (!file) return diagnostic;
259
259
  const sourceMap = sourceMaps.get(file.fileName);
260
260
  if (!sourceMap) return diagnostic;
261
- const sourcemapLines = sourceMap.data.lines;
261
+ const sourcemapLines = sourceMap.lines ?? sourceMap.data.lines;
262
262
  const range = remapRange(
263
263
  {
264
264
  start: diagnostic.start || 0,
@@ -430,7 +430,7 @@ var rawPlugin = (options = {}, meta) => {
430
430
  ...civetOptions,
431
431
  ast: true
432
432
  });
433
- const civetSourceMap = SourceMap(rawCivetSource);
433
+ const civetSourceMap = new SourceMap(rawCivetSource);
434
434
  if (ts === "civet") {
435
435
  compiled = await civet.generate(ast, {
436
436
  ...civetOptions,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.9.3",
4
+ "version": "0.9.4",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",