binja 0.5.2 → 0.5.3

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
@@ -117,6 +117,82 @@ function tokenizeNative(source) {
117
117
  return tokens;
118
118
  }
119
119
 
120
+ // src/errors/index.ts
121
+ var colors = {
122
+ red: "\x1B[31m",
123
+ yellow: "\x1B[33m",
124
+ cyan: "\x1B[36m",
125
+ gray: "\x1B[90m",
126
+ bold: "\x1B[1m",
127
+ dim: "\x1B[2m",
128
+ reset: "\x1B[0m"
129
+ };
130
+ var useColors = process.stdout?.isTTY !== false;
131
+ function c(color, text) {
132
+ return useColors ? `${colors[color]}${text}${colors.reset}` : text;
133
+ }
134
+ class TemplateSyntaxError extends Error {
135
+ line;
136
+ column;
137
+ source;
138
+ templateName;
139
+ suggestion;
140
+ constructor(message, options) {
141
+ const formatted = formatError("TemplateSyntaxError", message, options);
142
+ super(formatted);
143
+ this.name = "TemplateSyntaxError";
144
+ this.line = options.line;
145
+ this.column = options.column;
146
+ this.source = options.source;
147
+ this.templateName = options.templateName;
148
+ this.suggestion = options.suggestion;
149
+ }
150
+ }
151
+ function formatError(type, message, options) {
152
+ const parts = [];
153
+ const location = options.templateName ? `${options.templateName}:${options.line}:${options.column}` : `line ${options.line}, column ${options.column}`;
154
+ parts.push(`${c("red", c("bold", type))}: ${message} at ${c("cyan", location)}`);
155
+ if (options.source) {
156
+ parts.push("");
157
+ parts.push(generateSnippet(options.source, options.line, options.column));
158
+ }
159
+ if (options.suggestion) {
160
+ parts.push("");
161
+ parts.push(`${c("yellow", "Did you mean")}: ${c("cyan", options.suggestion)}?`);
162
+ }
163
+ if (options.availableOptions && options.availableOptions.length > 0) {
164
+ parts.push("");
165
+ const truncated = options.availableOptions.slice(0, 8);
166
+ const more = options.availableOptions.length > 8 ? ` ${c("gray", `... and ${options.availableOptions.length - 8} more`)}` : "";
167
+ parts.push(`${c("gray", "Available")}: ${truncated.join(", ")}${more}`);
168
+ }
169
+ return parts.join(`
170
+ `);
171
+ }
172
+ function generateSnippet(source, errorLine, errorColumn) {
173
+ const lines = source.split(`
174
+ `);
175
+ const parts = [];
176
+ const startLine = Math.max(1, errorLine - 2);
177
+ const endLine = Math.min(lines.length, errorLine + 1);
178
+ const gutterWidth = String(endLine).length;
179
+ for (let i = startLine;i <= endLine; i++) {
180
+ const lineContent = lines[i - 1] || "";
181
+ const lineNum = String(i).padStart(gutterWidth, " ");
182
+ const isErrorLine = i === errorLine;
183
+ if (isErrorLine) {
184
+ parts.push(`${c("red", " \u2192")} ${c("gray", lineNum)} ${c("dim", "\u2502")} ${lineContent}`);
185
+ const caretPadding = " ".repeat(gutterWidth + 4 + Math.max(0, errorColumn - 1));
186
+ const caret = c("red", "^");
187
+ parts.push(`${caretPadding}${caret}`);
188
+ } else {
189
+ parts.push(` ${c("gray", lineNum)} ${c("dim", "\u2502")} ${c("gray", lineContent)}`);
190
+ }
191
+ }
192
+ return parts.join(`
193
+ `);
194
+ }
195
+
120
196
  // src/lexer/index.ts
121
197
  class Lexer {
122
198
  state;
@@ -204,7 +280,11 @@ class Lexer {
204
280
  if (this.peek() === "-")
205
281
  this.advance();
206
282
  if (!this.match(this.blockEnd)) {
207
- throw new Error(`Expected ${this.blockEnd} after ${tagName} at line ${this.state.line}`);
283
+ throw new TemplateSyntaxError(`Expected '${this.blockEnd}' after '${tagName}'`, {
284
+ line: this.state.line,
285
+ column: this.state.column,
286
+ source: this.state.source
287
+ });
208
288
  }
209
289
  const endTag = `end${tagName}`;
210
290
  const contentStart = this.state.pos;
@@ -234,7 +314,11 @@ class Lexer {
234
314
  if (this.peek() === "-")
235
315
  this.advance();
236
316
  if (!this.match(this.blockEnd)) {
237
- throw new Error(`Expected ${this.blockEnd} after ${endTag} at line ${this.state.line}`);
317
+ throw new TemplateSyntaxError(`Expected '${this.blockEnd}' after '${endTag}'`, {
318
+ line: this.state.line,
319
+ column: this.state.column,
320
+ source: this.state.source
321
+ });
238
322
  }
239
323
  return;
240
324
  }
@@ -249,7 +333,12 @@ class Lexer {
249
333
  }
250
334
  this.advance();
251
335
  }
252
- throw new Error(`Unclosed ${tagName} block starting at line ${startLine}`);
336
+ throw new TemplateSyntaxError(`Unclosed '${tagName}' block`, {
337
+ line: startLine,
338
+ column: startColumn,
339
+ source: this.state.source,
340
+ suggestion: `Add {% end${tagName} %} to close the block`
341
+ });
253
342
  }
254
343
  scanText() {
255
344
  const start = this.state.pos;
@@ -289,22 +378,27 @@ class Lexer {
289
378
  }
290
379
  this.scanExpressionToken();
291
380
  }
292
- throw new Error(`Unclosed template tag at line ${this.state.line}`);
381
+ throw new TemplateSyntaxError(`Unclosed template tag`, {
382
+ line: this.state.line,
383
+ column: this.state.column,
384
+ source: this.state.source,
385
+ suggestion: `Add closing delimiter '${endDelimiter}'`
386
+ });
293
387
  }
294
388
  scanExpressionToken() {
295
389
  this.skipWhitespace();
296
390
  if (this.isAtEnd())
297
391
  return;
298
- const c = this.peek();
299
- if (c === '"' || c === "'") {
300
- this.scanString(c);
392
+ const c2 = this.peek();
393
+ if (c2 === '"' || c2 === "'") {
394
+ this.scanString(c2);
301
395
  return;
302
396
  }
303
- if (this.isDigit(c)) {
397
+ if (this.isDigit(c2)) {
304
398
  this.scanNumber();
305
399
  return;
306
400
  }
307
- if (this.isAlpha(c) || c === "_") {
401
+ if (this.isAlpha(c2) || c2 === "_") {
308
402
  this.scanIdentifier();
309
403
  return;
310
404
  }
@@ -325,7 +419,12 @@ class Lexer {
325
419
  this.advance();
326
420
  }
327
421
  if (this.isAtEnd()) {
328
- throw new Error(`Unterminated string at line ${this.state.line}`);
422
+ throw new TemplateSyntaxError(`Unterminated string literal`, {
423
+ line: this.state.line,
424
+ column: this.state.column,
425
+ source: this.state.source,
426
+ suggestion: `Add closing quote '${quote}'`
427
+ });
329
428
  }
330
429
  const value = this.state.source.slice(start, this.state.pos);
331
430
  this.advance();
@@ -355,55 +454,55 @@ class Lexer {
355
454
  this.addToken(type, value);
356
455
  }
357
456
  scanOperator() {
358
- const c = this.advance();
359
- switch (c) {
457
+ const c2 = this.advance();
458
+ switch (c2) {
360
459
  case ".":
361
- this.addToken("DOT" /* DOT */, c);
460
+ this.addToken("DOT" /* DOT */, c2);
362
461
  break;
363
462
  case ",":
364
- this.addToken("COMMA" /* COMMA */, c);
463
+ this.addToken("COMMA" /* COMMA */, c2);
365
464
  break;
366
465
  case ":":
367
- this.addToken("COLON" /* COLON */, c);
466
+ this.addToken("COLON" /* COLON */, c2);
368
467
  break;
369
468
  case "|":
370
- this.addToken("PIPE" /* PIPE */, c);
469
+ this.addToken("PIPE" /* PIPE */, c2);
371
470
  break;
372
471
  case "(":
373
- this.addToken("LPAREN" /* LPAREN */, c);
472
+ this.addToken("LPAREN" /* LPAREN */, c2);
374
473
  break;
375
474
  case ")":
376
- this.addToken("RPAREN" /* RPAREN */, c);
475
+ this.addToken("RPAREN" /* RPAREN */, c2);
377
476
  break;
378
477
  case "[":
379
- this.addToken("LBRACKET" /* LBRACKET */, c);
478
+ this.addToken("LBRACKET" /* LBRACKET */, c2);
380
479
  break;
381
480
  case "]":
382
- this.addToken("RBRACKET" /* RBRACKET */, c);
481
+ this.addToken("RBRACKET" /* RBRACKET */, c2);
383
482
  break;
384
483
  case "{":
385
- this.addToken("LBRACE" /* LBRACE */, c);
484
+ this.addToken("LBRACE" /* LBRACE */, c2);
386
485
  break;
387
486
  case "}":
388
- this.addToken("RBRACE" /* RBRACE */, c);
487
+ this.addToken("RBRACE" /* RBRACE */, c2);
389
488
  break;
390
489
  case "+":
391
- this.addToken("ADD" /* ADD */, c);
490
+ this.addToken("ADD" /* ADD */, c2);
392
491
  break;
393
492
  case "-":
394
- this.addToken("SUB" /* SUB */, c);
493
+ this.addToken("SUB" /* SUB */, c2);
395
494
  break;
396
495
  case "*":
397
- this.addToken("MUL" /* MUL */, c);
496
+ this.addToken("MUL" /* MUL */, c2);
398
497
  break;
399
498
  case "/":
400
- this.addToken("DIV" /* DIV */, c);
499
+ this.addToken("DIV" /* DIV */, c2);
401
500
  break;
402
501
  case "%":
403
- this.addToken("MOD" /* MOD */, c);
502
+ this.addToken("MOD" /* MOD */, c2);
404
503
  break;
405
504
  case "~":
406
- this.addToken("TILDE" /* TILDE */, c);
505
+ this.addToken("TILDE" /* TILDE */, c2);
407
506
  break;
408
507
  case "=":
409
508
  if (this.match("=")) {
@@ -416,7 +515,12 @@ class Lexer {
416
515
  if (this.match("=")) {
417
516
  this.addToken("NE" /* NE */, "!=");
418
517
  } else {
419
- throw new Error(`Unexpected character '!' at line ${this.state.line}`);
518
+ throw new TemplateSyntaxError(`Unexpected character '!'`, {
519
+ line: this.state.line,
520
+ column: this.state.column - 1,
521
+ source: this.state.source,
522
+ suggestion: `Use '!=' for not-equal comparison or 'not' for negation`
523
+ });
420
524
  }
421
525
  break;
422
526
  case "<":
@@ -434,8 +538,12 @@ class Lexer {
434
538
  }
435
539
  break;
436
540
  default:
437
- if (!this.isWhitespace(c)) {
438
- throw new Error(`Unexpected character '${c}' at line ${this.state.line}`);
541
+ if (!this.isWhitespace(c2)) {
542
+ throw new TemplateSyntaxError(`Unexpected character '${c2}'`, {
543
+ line: this.state.line,
544
+ column: this.state.column - 1,
545
+ source: this.state.source
546
+ });
439
547
  }
440
548
  }
441
549
  }
@@ -466,10 +574,10 @@ class Lexer {
466
574
  return this.state.source[this.state.pos + 1];
467
575
  }
468
576
  advance() {
469
- const c = this.state.source[this.state.pos];
577
+ const c2 = this.state.source[this.state.pos];
470
578
  this.state.pos++;
471
579
  this.state.column++;
472
- return c;
580
+ return c2;
473
581
  }
474
582
  match(expected, offset = 0) {
475
583
  const source = this.state.source;
@@ -509,20 +617,20 @@ class Lexer {
509
617
  this.advance();
510
618
  }
511
619
  }
512
- isWhitespace(c) {
513
- return c === " " || c === "\t" || c === `
514
- ` || c === "\r";
620
+ isWhitespace(c2) {
621
+ return c2 === " " || c2 === "\t" || c2 === `
622
+ ` || c2 === "\r";
515
623
  }
516
- isDigit(c) {
517
- const code = c.charCodeAt(0);
624
+ isDigit(c2) {
625
+ const code = c2.charCodeAt(0);
518
626
  return code >= 48 && code <= 57;
519
627
  }
520
- isAlpha(c) {
521
- const code = c.charCodeAt(0);
628
+ isAlpha(c2) {
629
+ const code = c2.charCodeAt(0);
522
630
  return code >= 97 && code <= 122 || code >= 65 && code <= 90;
523
631
  }
524
- isAlphaNumeric(c) {
525
- const code = c.charCodeAt(0);
632
+ isAlphaNumeric(c2) {
633
+ const code = c2.charCodeAt(0);
526
634
  return code >= 48 && code <= 57 || code >= 97 && code <= 122 || code >= 65 && code <= 90;
527
635
  }
528
636
  addToken(type, value) {
@@ -539,8 +647,10 @@ class Lexer {
539
647
  class Parser {
540
648
  tokens;
541
649
  current = 0;
542
- constructor(tokens) {
650
+ source;
651
+ constructor(tokens, source) {
543
652
  this.tokens = tokens;
653
+ this.source = source;
544
654
  }
545
655
  parse() {
546
656
  const body = [];
@@ -1632,7 +1742,11 @@ class Parser {
1632
1742
  }
1633
1743
  error(message) {
1634
1744
  const token = this.peek();
1635
- return new Error(`Parse error at line ${token.line}, column ${token.column}: ${message}`);
1745
+ return new TemplateSyntaxError(message, {
1746
+ line: token.line,
1747
+ column: token.column,
1748
+ source: this.source
1749
+ });
1636
1750
  }
1637
1751
  }
1638
1752
 
@@ -2316,7 +2430,7 @@ class StaticChecker {
2316
2430
 
2317
2431
  // src/cli.ts
2318
2432
  var VERSION = "0.1.1";
2319
- var colors = {
2433
+ var colors2 = {
2320
2434
  reset: "\x1B[0m",
2321
2435
  green: "\x1B[32m",
2322
2436
  yellow: "\x1B[33m",
@@ -2328,25 +2442,25 @@ function log(msg) {
2328
2442
  console.log(msg);
2329
2443
  }
2330
2444
  function success(msg) {
2331
- console.log(`${colors.green}\u2713${colors.reset} ${msg}`);
2445
+ console.log(`${colors2.green}\u2713${colors2.reset} ${msg}`);
2332
2446
  }
2333
2447
  function warn(msg) {
2334
- console.log(`${colors.yellow}\u26A0${colors.reset} ${msg}`);
2448
+ console.log(`${colors2.yellow}\u26A0${colors2.reset} ${msg}`);
2335
2449
  }
2336
2450
  function error(msg) {
2337
- console.error(`${colors.red}\u2717${colors.reset} ${msg}`);
2451
+ console.error(`${colors2.red}\u2717${colors2.reset} ${msg}`);
2338
2452
  }
2339
2453
  function printHelp() {
2340
2454
  console.log(`
2341
- ${colors.cyan}binja${colors.reset} - High-performance template compiler
2455
+ ${colors2.cyan}binja${colors2.reset} - High-performance template compiler
2342
2456
 
2343
- ${colors.yellow}Usage:${colors.reset}
2457
+ ${colors2.yellow}Usage:${colors2.reset}
2344
2458
  binja compile <source> [options] Compile templates to JavaScript
2345
2459
  binja check <source> Check if templates can be AOT compiled
2346
2460
  binja --help Show this help
2347
2461
  binja --version Show version
2348
2462
 
2349
- ${colors.yellow}Compile Options:${colors.reset}
2463
+ ${colors2.yellow}Compile Options:${colors2.reset}
2350
2464
  -o, --output <dir> Output directory (required)
2351
2465
  -n, --name <name> Function name for single file compilation
2352
2466
  -m, --minify Minify output
@@ -2354,26 +2468,26 @@ ${colors.yellow}Compile Options:${colors.reset}
2354
2468
  -v, --verbose Verbose output
2355
2469
  -w, --watch Watch for changes and recompile
2356
2470
 
2357
- ${colors.yellow}Examples:${colors.reset}
2358
- ${colors.dim}# Compile all templates in a directory${colors.reset}
2471
+ ${colors2.yellow}Examples:${colors2.reset}
2472
+ ${colors2.dim}# Compile all templates in a directory${colors2.reset}
2359
2473
  binja compile ./templates -o ./dist/templates
2360
2474
 
2361
- ${colors.dim}# Compile with minification${colors.reset}
2475
+ ${colors2.dim}# Compile with minification${colors2.reset}
2362
2476
  binja compile ./views -o ./compiled --minify
2363
2477
 
2364
- ${colors.dim}# Compile single file with custom function name${colors.reset}
2478
+ ${colors2.dim}# Compile single file with custom function name${colors2.reset}
2365
2479
  binja compile ./templates/home.html -o ./dist --name renderHome
2366
2480
 
2367
- ${colors.dim}# Watch mode for development${colors.reset}
2481
+ ${colors2.dim}# Watch mode for development${colors2.reset}
2368
2482
  binja compile ./templates -o ./dist --watch
2369
2483
 
2370
- ${colors.yellow}Output:${colors.reset}
2484
+ ${colors2.yellow}Output:${colors2.reset}
2371
2485
  Generated files export a render function:
2372
2486
 
2373
- ${colors.dim}// dist/templates/home.js${colors.reset}
2487
+ ${colors2.dim}// dist/templates/home.js${colors2.reset}
2374
2488
  export function render(ctx) { ... }
2375
2489
 
2376
- ${colors.dim}// Usage${colors.reset}
2490
+ ${colors2.dim}// Usage${colors2.reset}
2377
2491
  import { render } from './dist/templates/home.js'
2378
2492
  const html = render({ title: 'Hello' })
2379
2493
  `);
@@ -2502,7 +2616,7 @@ async function compileFile(filePath, outputDir, baseDir, options) {
2502
2616
  finalAst = flattenTemplate(ast, { loader });
2503
2617
  }
2504
2618
  const relativePath = path.relative(baseDir, filePath);
2505
- const functionName = options.name || "render" + relativePath.replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9]/g, "_").replace(/^_+|_+$/g, "").replace(/_([a-z])/g, (_, c) => c.toUpperCase());
2619
+ const functionName = options.name || "render" + relativePath.replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9]/g, "_").replace(/^_+|_+$/g, "").replace(/_([a-z])/g, (_, c2) => c2.toUpperCase());
2506
2620
  const code = compileToString(finalAst, {
2507
2621
  functionName,
2508
2622
  minify: options.minify
@@ -2591,14 +2705,14 @@ async function checkTemplates(sourceDir, options) {
2591
2705
  walkDir(sourceDir);
2592
2706
  log("");
2593
2707
  log(`Total: ${total} templates`);
2594
- log(`${colors.green}AOT compatible: ${canCompile}${colors.reset}`);
2708
+ log(`${colors2.green}AOT compatible: ${canCompile}${colors2.reset}`);
2595
2709
  if (cannotCompile > 0) {
2596
- log(`${colors.yellow}Require runtime: ${cannotCompile}${colors.reset}`);
2710
+ log(`${colors2.yellow}Require runtime: ${cannotCompile}${colors2.reset}`);
2597
2711
  }
2598
2712
  }
2599
2713
  async function watchAndCompile(sourceDir, outputDir, options) {
2600
- log(`${colors.cyan}Watching${colors.reset} ${sourceDir} for changes...`);
2601
- log(`${colors.dim}Press Ctrl+C to stop${colors.reset}`);
2714
+ log(`${colors2.cyan}Watching${colors2.reset} ${sourceDir} for changes...`);
2715
+ log(`${colors2.dim}Press Ctrl+C to stop${colors2.reset}`);
2602
2716
  log("");
2603
2717
  const { compiled, failed } = await compileDirectory(sourceDir, outputDir, { ...options, verbose: true });
2604
2718
  log("");
@@ -2613,7 +2727,7 @@ async function watchAndCompile(sourceDir, outputDir, options) {
2613
2727
  const fullPath = path.join(sourceDir, filename);
2614
2728
  if (!fs.existsSync(fullPath))
2615
2729
  return;
2616
- log(`${colors.dim}[${new Date().toLocaleTimeString()}]${colors.reset} ${filename} changed`);
2730
+ log(`${colors2.dim}[${new Date().toLocaleTimeString()}]${colors2.reset} ${filename} changed`);
2617
2731
  const result = await compileFile(fullPath, outputDir, sourceDir, options);
2618
2732
  if (result.success) {
2619
2733
  success(`Compiled ${filename}`);
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Rich Error Formatting for binja
3
+ *
4
+ * Provides detailed error messages with:
5
+ * - Source code context (snippet)
6
+ * - Caret pointer to exact location
7
+ * - "Did you mean?" suggestions
8
+ * - ANSI colors for terminal output
9
+ */
10
+ export interface ErrorLocation {
11
+ line: number;
12
+ column: number;
13
+ source?: string;
14
+ templateName?: string;
15
+ }
16
+ export interface ErrorOptions extends ErrorLocation {
17
+ suggestion?: string;
18
+ availableOptions?: string[];
19
+ }
20
+ /**
21
+ * Base template error with rich formatting
22
+ */
23
+ export declare class TemplateError extends Error {
24
+ line: number;
25
+ column: number;
26
+ source?: string;
27
+ templateName?: string;
28
+ suggestion?: string;
29
+ availableOptions?: string[];
30
+ constructor(message: string, options: ErrorOptions);
31
+ }
32
+ /**
33
+ * Syntax errors (lexer/parser)
34
+ */
35
+ export declare class TemplateSyntaxError extends Error {
36
+ line: number;
37
+ column: number;
38
+ source?: string;
39
+ templateName?: string;
40
+ suggestion?: string;
41
+ constructor(message: string, options: ErrorOptions);
42
+ }
43
+ /**
44
+ * Runtime errors (undefined variables, filter errors)
45
+ */
46
+ export declare class TemplateRuntimeError extends Error {
47
+ line: number;
48
+ column: number;
49
+ source?: string;
50
+ templateName?: string;
51
+ suggestion?: string;
52
+ availableOptions?: string[];
53
+ constructor(message: string, options: ErrorOptions);
54
+ }
55
+ /**
56
+ * Find similar string (for "Did you mean?" suggestions)
57
+ * Uses Levenshtein distance
58
+ */
59
+ export declare function findSimilar(input: string, candidates: string[], maxDistance?: number): string | null;
60
+ /**
61
+ * Helper to create errors with source context
62
+ */
63
+ export declare function createSyntaxError(message: string, line: number, column: number, source?: string, suggestion?: string): TemplateSyntaxError;
64
+ export declare function createRuntimeError(message: string, line: number, column: number, source?: string, suggestion?: string, availableOptions?: string[]): TemplateRuntimeError;
65
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoBH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC5B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;gBAEtB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY;CAWnD;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;gBAEd,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY;CAUnD;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;gBAEtB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY;CAWnD;AA4ED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,SAAI,GAAG,MAAM,GAAG,IAAI,CAe/F;AAqCD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,GAClB,mBAAmB,CAErB;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B,oBAAoB,CAEtB"}
package/dist/index.d.ts CHANGED
@@ -199,6 +199,7 @@ export type { TemplateNode, ASTNode, ExpressionNode } from './parser/nodes';
199
199
  export { Runtime, Context } from './runtime';
200
200
  export { builtinFilters } from './filters';
201
201
  export type { FilterFunction } from './filters';
202
+ export { TemplateError, TemplateSyntaxError, TemplateRuntimeError } from './errors';
202
203
  export type { CompileOptions } from './compiler';
203
204
  export { builtinTests } from './tests';
204
205
  export type { TestFunction } from './tests';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAU,YAAY,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,EAAkB,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1D,OAAO,EAAsC,cAAc,EAAE,MAAM,YAAY,CAAA;AAG/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAM3C,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uCAAuC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,qBAAqB;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACxC,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC7B,qCAAqC;IACrC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAA;IAChF,gDAAgD;IAChD,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IACzC,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,oDAAoD;IACpD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,0BAA0B;IAC1B,Y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