wesl 0.7.4 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -1
- package/package.json +1 -1
- package/src/ClickableError.ts +17 -1
- package/src/ModuleResolver.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -699,7 +699,7 @@ interface BatchModuleResolver extends ModuleResolver {
|
|
|
699
699
|
allModules(): Iterable<[string, WeslAST]>;
|
|
700
700
|
}
|
|
701
701
|
interface RecordResolverOptions {
|
|
702
|
-
/**
|
|
702
|
+
/** Recognize this name as alias for package:: (e.g., "lygia" makes lygia::foo resolve locally) */
|
|
703
703
|
packageName?: string;
|
|
704
704
|
/** Debug path prefix for error messages */
|
|
705
705
|
debugWeslRoot?: string;
|
package/dist/index.js
CHANGED
|
@@ -287,8 +287,15 @@ const isBrowser = "document" in globalThis;
|
|
|
287
287
|
/** Throw an error with an embedded source map so that browser users can
|
|
288
288
|
* click on the error in the browser debug console and see the wesl source code. */
|
|
289
289
|
function throwClickableError(params) {
|
|
290
|
-
if (!debug || !isBrowser) throw params.error;
|
|
291
290
|
const { url, text, lineNumber, lineColumn, length, error } = params;
|
|
291
|
+
const weslLocation = {
|
|
292
|
+
file: url,
|
|
293
|
+
line: lineNumber,
|
|
294
|
+
column: lineColumn,
|
|
295
|
+
length
|
|
296
|
+
};
|
|
297
|
+
error.weslLocation = weslLocation;
|
|
298
|
+
if (!debug || !isBrowser) throw error;
|
|
292
299
|
const mappings = encodeVlq([
|
|
293
300
|
0,
|
|
294
301
|
0,
|
|
@@ -322,6 +329,7 @@ function throwClickableError(params) {
|
|
|
322
329
|
if ("stackTraceLimit" in Error) Error.stackTraceLimit = oldLimit;
|
|
323
330
|
error.message = "";
|
|
324
331
|
if (debug) e.cause = error;
|
|
332
|
+
e.weslLocation = weslLocation;
|
|
325
333
|
throw e;
|
|
326
334
|
}
|
|
327
335
|
}
|
package/package.json
CHANGED
package/src/ClickableError.ts
CHANGED
|
@@ -3,6 +3,14 @@ import { debug, srcLog } from "./Logging.ts";
|
|
|
3
3
|
import { offsetToLineNumber } from "./Util.ts";
|
|
4
4
|
import { encodeVlq } from "./vlq/vlq.ts";
|
|
5
5
|
|
|
6
|
+
/** Structured location info attached to WESL errors for IDE integration. */
|
|
7
|
+
export interface WeslErrorLocation {
|
|
8
|
+
file: string;
|
|
9
|
+
line: number;
|
|
10
|
+
column: number;
|
|
11
|
+
length: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
6
14
|
export interface ClickableErrorParams {
|
|
7
15
|
/** url of the source file (e.g. `shaders/app.wesl`) */
|
|
8
16
|
url: string;
|
|
@@ -28,8 +36,15 @@ const isBrowser = "document" in globalThis;
|
|
|
28
36
|
/** Throw an error with an embedded source map so that browser users can
|
|
29
37
|
* click on the error in the browser debug console and see the wesl source code. */
|
|
30
38
|
export function throwClickableError(params: ClickableErrorParams): void {
|
|
31
|
-
if (!debug || !isBrowser) throw params.error;
|
|
32
39
|
const { url, text, lineNumber, lineColumn, length, error } = params;
|
|
40
|
+
const weslLocation: WeslErrorLocation = {
|
|
41
|
+
file: url,
|
|
42
|
+
line: lineNumber,
|
|
43
|
+
column: lineColumn,
|
|
44
|
+
length,
|
|
45
|
+
};
|
|
46
|
+
(error as any).weslLocation = weslLocation;
|
|
47
|
+
if (!debug || !isBrowser) throw error;
|
|
33
48
|
|
|
34
49
|
// Based on https://stackoverflow.com/questions/65274147/sourceurl-for-css
|
|
35
50
|
|
|
@@ -91,6 +106,7 @@ export function throwClickableError(params: ClickableErrorParams): void {
|
|
|
91
106
|
}
|
|
92
107
|
error.message = "";
|
|
93
108
|
if (debug) e.cause = error; // users don't want to see this, but WESL developers might
|
|
109
|
+
e.weslLocation = weslLocation;
|
|
94
110
|
throw e;
|
|
95
111
|
}
|
|
96
112
|
}
|
package/src/ModuleResolver.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface BatchModuleResolver extends ModuleResolver {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface RecordResolverOptions {
|
|
19
|
-
/**
|
|
19
|
+
/** Recognize this name as alias for package:: (e.g., "lygia" makes lygia::foo resolve locally) */
|
|
20
20
|
packageName?: string;
|
|
21
21
|
/** Debug path prefix for error messages */
|
|
22
22
|
debugWeslRoot?: string;
|