@gracile-labs/better-errors 0.1.2-next.0 → 0.1.2-next.2

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.
@@ -1,7 +1,7 @@
1
1
  export declare const openNewWindowIcon = "<svg xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" width=\"16\" height=\"16\" fill=\"none\"><path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" d=\"M14 2h-4m4 0L8 8m6-6v4\"/><path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-width=\"1.5\" d=\"M14 8.667V12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h3.333\"/></svg>";
2
- export declare const iconTablerSun: import("lit").TemplateResult<1>;
3
- export declare const hintIcon: import("lit").TemplateResult<1>;
4
- export declare const messageIcon: import("lit").TemplateResult<1>;
5
- export declare const iconTablerMoon: import("lit").TemplateResult<1>;
6
- export declare const logo: import("lit").TemplateResult<1>;
2
+ export declare const iconTablerSun: import("lit").TemplateResult;
3
+ export declare const hintIcon: import("lit").TemplateResult;
4
+ export declare const messageIcon: import("lit").TemplateResult;
5
+ export declare const iconTablerMoon: import("lit").TemplateResult;
6
+ export declare const logo: import("lit").TemplateResult;
7
7
  //# sourceMappingURL=assets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/dev/custom-overlay/assets.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,2YAC+U,CAAC;AAE9W,eAAO,MAAM,aAAa,iCAkBnB,CAAC;AAER,eAAO,MAAM,QAAQ,iCAgBpB,CAAC;AAEF,eAAO,MAAM,WAAW,iCAgBvB,CAAC;AAEF,eAAO,MAAM,cAAc,iCAiBpB,CAAC;AAER,eAAO,MAAM,IAAI,iCAuCV,CAAC"}
1
+ {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/dev/custom-overlay/assets.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,2YAC+U,CAAC;AAE9W,eAAO,MAAM,aAAa,8BAkBnB,CAAC;AAER,eAAO,MAAM,QAAQ,8BAgBpB,CAAC;AAEF,eAAO,MAAM,WAAW,8BAgBvB,CAAC;AAEF,eAAO,MAAM,cAAc,8BAiBpB,CAAC;AAER,eAAO,MAAM,IAAI,8BAuCV,CAAC"}
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'lit/static-html.js';
2
2
  // const houstonLogo = `<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="175" height="131" fill="none"><path fill="currentColor" d="M55.977 81.512c0 8.038-6.516 14.555-14.555 14.555S26.866 89.55 26.866 81.512c0-8.04 6.517-14.556 14.556-14.556 8.039 0 14.555 6.517 14.555 14.556Zm24.745-5.822c0-.804.651-1.456 1.455-1.456h11.645c.804 0 1.455.652 1.455 1.455v11.645c0 .804-.651 1.455-1.455 1.455H82.177a1.456 1.456 0 0 1-1.455-1.455V75.689Zm68.411 5.822c0 8.038-6.517 14.555-14.556 14.555-8.039 0-14.556-6.517-14.556-14.555 0-8.04 6.517-14.556 14.556-14.556 8.039 0 14.556 6.517 14.556 14.556Z"/><rect width="168.667" height="125" x="3.667" y="3" stroke="currentColor" stroke-width="4" rx="20.289"/></svg>`;
3
3
  /* prettier-ignore */
4
4
  export const openNewWindowIcon = `<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="16" height="16" fill="none"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M14 2h-4m4 0L8 8m6-6v4"/><path stroke="currentColor" stroke-linecap="round" stroke-width="1.5" d="M14 8.667V12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h3.333"/></svg>`;
@@ -1,18 +1 @@
1
- import { LitElement } from 'lit';
2
- import type { BetterErrorPayload } from '../vite.js';
3
- export declare class ViteCustomOverlay extends LitElement {
4
- static styles: import("lit").CSSResult[];
5
- accessor errorPayload: BetterErrorPayload['err'] | null;
6
- root: ShadowRoot;
7
- protected firstUpdated(): void;
8
- initTheme(): void;
9
- static createLink(text: string, href: string | undefined): HTMLDivElement;
10
- appendCode(): void;
11
- render(): import("lit").TemplateResult<1>;
12
- }
13
- declare global {
14
- interface HTMLElementTagNameMap {
15
- 'vite-custom-overlay': ViteCustomOverlay;
16
- }
17
- }
18
1
  //# sourceMappingURL=vite-custom-overlay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-custom-overlay.d.ts","sourceRoot":"","sources":["../../../src/dev/custom-overlay/vite-custom-overlay.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAK5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGrD,qBACa,iBAAkB,SAAQ,UAAU;IAChD,MAAM,CAAC,MAAM,4BAOX;IAE0B,QAAQ,CAAC,YAAY,EAC9C,kBAAkB,CAAC,KAAK,CAAC,GACzB,IAAI,CAAQ;IAEf,IAAI,aAAoB;IAExB,SAAS,CAAC,YAAY,IAAI,IAAI;IAQ9B,SAAS;IAyBT,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,cAAc;IAkBzE,UAAU;IA2FV,MAAM;CAqEN;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,qBAAqB,EAAE,iBAAiB,CAAC;KACzC;CACD"}
1
+ {"version":3,"file":"vite-custom-overlay.d.ts","sourceRoot":"","sources":["../../../src/dev/custom-overlay/vite-custom-overlay.ts"],"names":[],"mappings":""}
@@ -1,208 +1,217 @@
1
- // TODO: Convert remaining imperative code
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var ViteCustomOverlay_1;
9
- import { css, html, LitElement } from 'lit';
10
- import { customElement, property } from 'lit/decorators.js';
11
- import * as assets from './assets.js';
12
- import { style } from './vite-custom-overlay.styles.js';
13
- import { unsafeHTML } from 'lit/directives/unsafe-html.js';
14
- let ViteCustomOverlay = class ViteCustomOverlay extends LitElement {
15
- constructor() {
16
- super(...arguments);
17
- this.#errorPayload_accessor_storage = null;
18
- this.root = this.shadowRoot;
19
- }
20
- static { ViteCustomOverlay_1 = this; }
21
- static { this.styles = [
22
- style,
23
- css `
24
- :host {
25
- display: contents;
26
- }
27
- `,
28
- ]; }
29
- #errorPayload_accessor_storage;
30
- get errorPayload() { return this.#errorPayload_accessor_storage; }
31
- set errorPayload(value) { this.#errorPayload_accessor_storage = value; }
32
- firstUpdated() {
33
- this?.classList.add('betterr-dark');
34
- this.root = this.shadowRoot;
35
- this.appendCode();
36
- this.initTheme();
37
- }
38
- initTheme() {
39
- const themeToggle = this.root.querySelector('.theme-toggle-checkbox');
40
- if (localStorage['betterrErrorOverlayTheme'] === 'dark' ||
41
- (!('betterrErrorOverlayTheme' in localStorage) &&
42
- window.matchMedia('(prefers-color-scheme: dark)').matches)) {
43
- this?.classList.add('betterr-dark');
44
- localStorage['betterrErrorOverlayTheme'] = 'dark';
45
- themeToggle.checked = true;
46
- }
47
- else {
48
- this?.classList.remove('betterr-dark');
49
- themeToggle.checked = false;
50
- }
51
- themeToggle?.addEventListener('click', () => {
52
- const isDark = localStorage['betterrErrorOverlayTheme'] === 'dark' ||
53
- this?.classList.contains('betterr-dark');
54
- this?.classList.toggle('betterr-dark', !isDark);
55
- localStorage['betterrErrorOverlayTheme'] = isDark ? 'light' : 'dark';
56
- });
57
- }
58
- static createLink(text, href) {
59
- const linkContainer = document.createElement('div');
60
- const linkElement = href
61
- ? document.createElement('a')
62
- : document.createElement('button');
63
- linkElement.innerHTML = text;
64
- if (href && linkElement instanceof HTMLAnchorElement) {
65
- linkElement.href = href;
66
- linkElement.target = '_blank';
67
- }
68
- linkContainer.appendChild(linkElement);
69
- linkContainer.className = 'link';
70
- return linkContainer;
71
- }
72
- appendCode() {
73
- const err = this.errorPayload;
74
- if (!err)
75
- throw new ReferenceError();
76
- const code = this.root.querySelector('#code');
77
- if (code && err.loc?.file) {
78
- code.style.display = 'block';
79
- const codeHeader = code.querySelector('#code header');
80
- const codeContent = code.querySelector('#code-content');
81
- if (codeHeader) {
82
- const separator = err.loc.file.includes('/') ? '/' : '\\';
83
- const cleanFile = err.loc.file.split(separator).slice(-2).join('/');
84
- const fileLocation = [cleanFile, err.loc.line, err.loc.column]
85
- .filter(Boolean)
86
- .join(':');
87
- const absoluteFileLocation = [
88
- err.loc.file,
89
- err.loc.line,
90
- err.loc.column,
91
- ]
92
- .filter(Boolean)
93
- .join(':');
94
- const codeFile = codeHeader.getElementsByTagName('h2')[0];
95
- if (codeFile) {
96
- codeFile.textContent = fileLocation;
97
- codeFile.title = absoluteFileLocation;
98
- }
99
- const editorLink = ViteCustomOverlay_1.createLink(`Open in editor${assets.openNewWindowIcon}`, undefined);
100
- editorLink.onclick = () => {
101
- fetch(`/__open-in-editor?file=${encodeURIComponent(absoluteFileLocation)}`).catch(console.error);
102
- };
103
- codeHeader.appendChild(editorLink);
104
- }
105
- const hint = this.root.querySelector('#hint');
106
- if (hint && err.hint) {
107
- hint.style.display = 'flex';
108
- }
109
- const docslink = this.root.querySelector('#message');
110
- if (docslink && err.docslink) {
111
- docslink.appendChild(ViteCustomOverlay_1.createLink(`See Docs Reference${assets.openNewWindowIcon}`, err.docslink));
112
- }
113
- if (codeContent && err.highlightedCode) {
114
- codeContent.innerHTML = err.highlightedCode;
115
- window.requestAnimationFrame(() => {
116
- // NOTE: This cannot be `codeContent.querySelector` because `codeContent` still contain the old HTML
117
- const errorLine = this.root.querySelector('.error-line');
118
- if (errorLine) {
119
- if (errorLine.parentElement?.parentElement) {
120
- errorLine.parentElement.parentElement.scrollTop =
121
- errorLine.offsetTop -
122
- errorLine.parentElement.parentElement.offsetTop -
123
- 8;
124
- }
125
- // Add an empty line below the error line so we can show a caret under the error
126
- if (err.loc?.column) {
127
- errorLine.insertAdjacentHTML('afterend', `\n<span class="line error-caret"><span style="padding-left:${err.loc.column - 1}ch;">^</span></span>`);
128
- }
129
- }
130
- });
131
- }
132
- }
133
- }
134
- render() {
135
- if (!this.errorPayload)
136
- throw new ReferenceError('Missing payload!');
137
- return html `
138
- <div id="backdrop" class="betterr-dark">
139
- <div id="layout">
140
- <div id="theme-toggle-wrapper">
141
- <div>
142
- <input type="checkbox" class="theme-toggle-checkbox" id="chk" />
143
- <label id="theme-toggle-label" for="chk">
144
- ${assets.iconTablerSun} ${assets.iconTablerMoon}
145
-
146
- <div id="theme-toggle-ball">
147
- <span class="sr-only">Use dark theme</span>
148
- </div>
149
- </label>
150
- </div>
151
- </div>
152
-
153
- <header id="header">
154
- <section id="header-left">
155
- <h2 id="name">${this.errorPayload.name}</h2>
156
- <h1 id="title">
157
- ${this.errorPayload.title || 'An error occurred.'}
158
- </h1>
159
- </section>
160
- <div id="betterr-logo-overlay"></div>
161
- <div id="betterr-logo">${assets.logo}</div>
162
- </header>
163
-
164
- <section id="message-hints">
165
- <section id="message">
166
- <span id="message-icon">${assets.messageIcon}</span>
167
- <!-- prettier-ignore -->
168
- <div id="message-content">${unsafeHTML(this.errorPayload['message'])}</div>
169
- </section>
170
-
171
- <section id="hint">
172
- <span id="hint-icon"> ${assets.hintIcon} </span>
173
- <div id="hint-content">${this.errorPayload.hint}</div>
174
- </section>
175
- </section>
176
-
177
- <section id="code">
178
- <header>
179
- <h2></h2>
180
- </header>
181
-
182
- <div id="code-content"></div>
183
- </section>
184
-
185
- <section id="stack">
186
- <h2>Stack Trace</h2>
187
- <div id="stack-content">${this.errorPayload['stack']}</div>
188
- </section>
189
-
190
- ${this.errorPayload.cause
191
- ? html ` <!-- -->
192
- <section id="cause">
193
- <h2>Cause</h2>
194
- <div id="cause-content">${this.errorPayload.cause}</div>
195
- </section>`
196
- : null}
197
- </div>
198
- </div>
199
- `;
200
- }
201
- };
202
- __decorate([
203
- property({ type: Object })
204
- ], ViteCustomOverlay.prototype, "errorPayload", null);
205
- ViteCustomOverlay = ViteCustomOverlay_1 = __decorate([
206
- customElement('vite-custom-overlay')
207
- ], ViteCustomOverlay);
208
- export { ViteCustomOverlay };
1
+ "use strict";
2
+ // // TODO: Convert remaining imperative code
3
+ // // import { customElement, property } from 'lit/decorators.js';
4
+ // import type { BetterErrorPayload } from '../vite.js';
5
+ // import * as assets from './assets.js';
6
+ // import { style } from './vite-custom-overlay.styles.js';
7
+ // // import { unsafeHTML } from 'lit/directives/unsafe-html.js';
8
+ // // import { render } from 'lit/html.js';
9
+ // // import { html } from 'lit/static-html.js';
10
+ // export class ViteCustomOverlay extends HTMLElement {
11
+ // // static styles = [
12
+ // // style,
13
+ // // css`
14
+ // // :host {
15
+ // // display: contents;
16
+ // // }
17
+ // // `,
18
+ // // ];
19
+ // errorPayload: BetterErrorPayload['err'] | null = null;
20
+ // root = this.shadowRoot!;
21
+ // // protected firstUpdated(): void {
22
+ // // }
23
+ // initTheme() {
24
+ // const themeToggle = this.root.querySelector<HTMLInputElement>(
25
+ // '.theme-toggle-checkbox',
26
+ // );
27
+ // if (
28
+ // localStorage['betterrErrorOverlayTheme'] === 'dark' ||
29
+ // (!('betterrErrorOverlayTheme' in localStorage) &&
30
+ // globalThis.matchMedia('(prefers-color-scheme: dark)').matches)
31
+ // ) {
32
+ // this?.classList.add('betterr-dark');
33
+ // localStorage['betterrErrorOverlayTheme'] = 'dark';
34
+ // themeToggle!.checked = true;
35
+ // } else {
36
+ // this?.classList.remove('betterr-dark');
37
+ // themeToggle!.checked = false;
38
+ // }
39
+ // themeToggle?.addEventListener('click', () => {
40
+ // const isDark =
41
+ // localStorage['betterrErrorOverlayTheme'] === 'dark' ||
42
+ // this?.classList.contains('betterr-dark');
43
+ // this?.classList.toggle('betterr-dark', !isDark);
44
+ // localStorage['betterrErrorOverlayTheme'] = isDark ? 'light' : 'dark';
45
+ // });
46
+ // }
47
+ // static createLink(text: string, href: string | undefined): HTMLDivElement {
48
+ // const linkContainer = document.createElement('div');
49
+ // const linkElement = href
50
+ // ? document.createElement('a')
51
+ // : document.createElement('button');
52
+ // linkElement.innerHTML = text;
53
+ // if (href && linkElement instanceof HTMLAnchorElement) {
54
+ // linkElement.href = href;
55
+ // linkElement.target = '_blank';
56
+ // }
57
+ // linkContainer.append(linkElement);
58
+ // linkContainer.className = 'link';
59
+ // return linkContainer;
60
+ // }
61
+ // appendCode() {
62
+ // const error = this.errorPayload;
63
+ // if (!error) throw new ReferenceError('No error.');
64
+ // const code = this.root.querySelector<HTMLElement>('#code');
65
+ // if (code && error.loc?.file) {
66
+ // const codeHeader = code.querySelector<HTMLHeadingElement>('#code header');
67
+ // if (codeHeader) {
68
+ // const separator = error.loc.file.includes('/') ? '/' : '\\';
69
+ // const cleanFile = error.loc.file.split(separator).slice(-2).join('/');
70
+ // const fileLocation = [cleanFile, error.loc.line, error.loc.column]
71
+ // .filter(Boolean)
72
+ // .join(':');
73
+ // const absoluteFileLocation = [
74
+ // error.loc.file,
75
+ // error.loc.line,
76
+ // error.loc.column,
77
+ // ]
78
+ // .filter(Boolean)
79
+ // .join(':');
80
+ // const codeFile = codeHeader.querySelectorAll('h2')[0];
81
+ // if (codeFile) {
82
+ // codeFile.textContent = fileLocation;
83
+ // codeFile.title = absoluteFileLocation;
84
+ // }
85
+ // const editorLink = ViteCustomOverlay.createLink(
86
+ // `Open in editor${assets.openNewWindowIcon}`,
87
+ // );
88
+ // editorLink.addEventListener('click', () => {
89
+ // fetch(
90
+ // `/__open-in-editor?file=${encodeURIComponent(
91
+ // absoluteFileLocation,
92
+ // )}`,
93
+ // ).catch(console.error);
94
+ // });
95
+ // codeHeader.append(editorLink);
96
+ // }
97
+ // const hint = this.root.querySelector<HTMLElement>('#hint');
98
+ // if (hint && error.hint) {
99
+ // hint.style.display = 'flex';
100
+ // }
101
+ // const docslink = this.root.querySelector<HTMLElement>('#message');
102
+ // if (docslink && error.docslink) {
103
+ // docslink.append(
104
+ // ViteCustomOverlay.createLink(
105
+ // `See Docs Reference${assets.openNewWindowIcon}`,
106
+ // error.docslink,
107
+ // ),
108
+ // );
109
+ // }
110
+ // if (error.highlightedCode) {
111
+ // globalThis.requestAnimationFrame(() => {
112
+ // // NOTE: This cannot be `codeContent.querySelector` because `codeContent` still contain the old HTML
113
+ // const errorLine =
114
+ // this.root.querySelector<HTMLSpanElement>('.error-line');
115
+ // if (errorLine) {
116
+ // if (errorLine.parentElement?.parentElement) {
117
+ // errorLine.parentElement.parentElement.scrollTop =
118
+ // errorLine.offsetTop -
119
+ // errorLine.parentElement.parentElement.offsetTop -
120
+ // 8;
121
+ // }
122
+ // // Add an empty line below the error line so we can show a caret under the error
123
+ // if (error.loc?.column) {
124
+ // errorLine.insertAdjacentHTML(
125
+ // 'afterend',
126
+ // `\n<span class="line error-caret"><span style="padding-left:${
127
+ // error.loc.column - 1
128
+ // }ch;">^</span></span>`,
129
+ // );
130
+ // }
131
+ // }
132
+ // });
133
+ // }
134
+ // }
135
+ // }
136
+ // connectedCallback() {
137
+ // if (!this.errorPayload) throw new ReferenceError('Missing payload!');
138
+ // this.root = this.attachShadow({ mode: 'open' });
139
+ // // this.classList.add('betterr-dark');
140
+ // // // this.root = this.shadowRoot!;
141
+ // // const s = new CSSStyleSheet()
142
+ // // s.replaceSync(style.styleSheet)
143
+ // this.shadowRoot?.adoptedStyleSheets.push(style.styleSheet!);
144
+ // // const tpl = html`
145
+ // // <div id="backdrop" class="betterr-dark">
146
+ // // <div id="layout">
147
+ // // <div id="theme-toggle-wrapper">
148
+ // // <div>
149
+ // // <input type="checkbox" class="theme-toggle-checkbox" id="chk" />
150
+ // // <label id="theme-toggle-label" for="chk">
151
+ // // ${assets.iconTablerSun} ${assets.iconTablerMoon}
152
+ // // <div id="theme-toggle-ball">
153
+ // // <span class="sr-only">Use dark theme</span>
154
+ // // </div>
155
+ // // </label>
156
+ // // </div>
157
+ // // </div>
158
+ // // <header id="header">
159
+ // // <section id="header-left">
160
+ // // <h2 id="name">${this.errorPayload.name}</h2>
161
+ // // <h1 id="title">
162
+ // // ${this.errorPayload.title || 'An error occurred.'}
163
+ // // </h1>
164
+ // // </section>
165
+ // // <div id="betterr-logo-overlay"></div>
166
+ // // <div id="betterr-logo">${assets.logo}</div>
167
+ // // </header>
168
+ // // <section id="message-hints">
169
+ // // <section id="message">
170
+ // // <span id="message-icon">${assets.messageIcon}</span>
171
+ // // <!-- prettier-ignore -->
172
+ // // <div id="message-content">${unsafeHTML(
173
+ // // this.errorPayload['message'],
174
+ // // )}</div>
175
+ // // </section>
176
+ // // <section id="hint">
177
+ // // <span id="hint-icon"> ${assets.hintIcon} </span>
178
+ // // <div id="hint-content">${this.errorPayload.hint}</div>
179
+ // // </section>
180
+ // // </section>
181
+ // // <section id="code">
182
+ // // <header>
183
+ // // <h2></h2>
184
+ // // </header>
185
+ // // ${this.errorPayload.highlightedCode
186
+ // // ? html`<div id="code-content">
187
+ // // ${unsafeHTML(this.errorPayload.highlightedCode)}
188
+ // // </div>`
189
+ // // : null}
190
+ // // </section>
191
+ // // <section id="stack">
192
+ // // <h2>Stack Trace</h2>
193
+ // // <div id="stack-content">${this.errorPayload['stack']}</div>
194
+ // // </section>
195
+ // // ${this.errorPayload.cause
196
+ // // ? html` <!-- -->
197
+ // // <section id="cause">
198
+ // // <h2>Cause</h2>
199
+ // // <div id="cause-content">${this.errorPayload.cause}</div>
200
+ // // </section>`
201
+ // // : null}
202
+ // // </div>
203
+ // // </div>
204
+ // // `;
205
+ // // render(tpl, this.root);
206
+ // // this.appendCode();
207
+ // // this.initTheme();
208
+ // this.root.innerHTML = 'TEST';
209
+ // }
210
+ // }
211
+ // customElements.define('vite-custom-overlay', ViteCustomOverlay);
212
+ // declare global {
213
+ // interface HTMLElementTagNameMap {
214
+ // 'vite-custom-overlay': ViteCustomOverlay;
215
+ // }
216
+ // }
217
+ throw new Error('Empty');
@@ -1 +1 @@
1
- {"version":3,"file":"vite-custom-overlay.styles.d.ts","sourceRoot":"","sources":["../../../src/dev/custom-overlay/vite-custom-overlay.styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,yBAkiBjB,CAAC"}
1
+ {"version":3,"file":"vite-custom-overlay.styles.d.ts","sourceRoot":"","sources":["../../../src/dev/custom-overlay/vite-custom-overlay.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,yBAkiBjB,CAAC"}
@@ -1,4 +1,3 @@
1
- /* eslint-disable max-lines */
2
1
  import { css } from 'lit';
3
2
  export const style = css `
4
3
  :host {
@@ -1,5 +1,5 @@
1
1
  import { type ErrorWithMetadata } from '../errors.js';
2
2
  import type { BetterErrorData } from '../errors-data.js';
3
3
  export declare function padMultilineString(source: string, n?: number): string;
4
- export declare function formatErrorMessage(err: ErrorWithMetadata, showFullStacktrace: boolean, errorsData: Record<string, BetterErrorData>, docsBaseUrl?: string): string;
4
+ export declare function formatErrorMessage(error: ErrorWithMetadata, showFullStacktrace: boolean, errorsData: Record<string, BetterErrorData>, docsBaseUrl?: string): string;
5
5
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/dev/logger.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AA+CzD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,SAAI,UAGvD;AAED,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,iBAAiB,EACtB,kBAAkB,EAAE,OAAO,EAC3B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAC3C,WAAW,CAAC,EAAE,MAAM,GAClB,MAAM,CAiDR"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/dev/logger.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAiDzD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,SAAI,UAGvD;AAED,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,iBAAiB,EACxB,kBAAkB,EAAE,OAAO,EAC3B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAC3C,WAAW,CAAC,EAAE,MAAM,GAClB,MAAM,CA4CR"}
@@ -1,12 +1,15 @@
1
- import { getDocsForError, renderErrorMarkdown } from './utils.js';
1
+ // TODO: Refactor with Gracile code-base style.
2
+ /* eslint-disable unicorn/no-abusive-eslint-disable */
3
+ /* eslint-disable */
2
4
  import picocolors from 'picocolors';
3
5
  import { BetterError } from '../errors.js';
6
+ import { getDocsForError, renderErrorMarkdown } from './utils.js';
4
7
  const { yellow, bold, cyan, dim, underline, red } = picocolors;
5
8
  // a regex to match the first line of a stack trace
6
9
  const STACK_LINE_REGEXP = /^\s+at /g;
7
10
  const IRRELEVANT_STACK_REGEXP = /node_modules|astro[/\\]dist/g;
8
- function formatErrorStackTrace(err, showFullStacktrace) {
9
- const stackLines = (err.stack || '')
11
+ function formatErrorStackTrace(error, showFullStacktrace) {
12
+ const stackLines = (error.stack || '')
10
13
  .split('\n')
11
14
  .filter((line) => STACK_LINE_REGEXP.test(line));
12
15
  // If full details are required, just return the entire stack trace.
@@ -16,8 +19,8 @@ function formatErrorStackTrace(err, showFullStacktrace) {
16
19
  // Grab every string from the user's codebase, exit when you hit node_modules or astro/dist
17
20
  const irrelevantStackIndex = stackLines.findIndex((line) => IRRELEVANT_STACK_REGEXP.test(line));
18
21
  if (irrelevantStackIndex <= 0) {
19
- const errorId = err.id;
20
- const errorLoc = err.loc;
22
+ const errorId = error.id;
23
+ const errorLoc = error.loc;
21
24
  if (errorId || errorLoc?.file) {
22
25
  const prettyLocation = ` at ${errorId ?? errorLoc?.file}${errorLoc?.line && errorLoc.column
23
26
  ? `:${errorLoc.line}:${errorLoc.column}`
@@ -38,44 +41,37 @@ export function padMultilineString(source, n = 2) {
38
41
  const lines = source.split(/\r?\n/);
39
42
  return lines.map((l) => ` `.repeat(n) + l).join(`\n`);
40
43
  }
41
- export function formatErrorMessage(err, showFullStacktrace, errorsData, docsBaseUrl) {
42
- const isOurError = BetterError.is(err); /* || CompilerError.is(err) || AstroUserError.is(err) */
44
+ export function formatErrorMessage(error, showFullStacktrace, errorsData, docsBaseUrl) {
45
+ const isOurError = BetterError.is(error); /* || CompilerError.is(err) || AstroUserError.is(err) */
43
46
  let message = '';
44
- if (isOurError) {
45
- message +=
46
- red(`[${err.name}]`) + ' ' + renderErrorMarkdown(err.message, 'cli');
47
- }
48
- else {
49
- message += err.message;
50
- }
47
+ message += isOurError
48
+ ? red(`[${error.name}]`) + ' ' + renderErrorMarkdown(error.message, 'cli')
49
+ : error.message;
51
50
  const output = [message];
52
- if (err.hint) {
51
+ if (error.hint) {
53
52
  output.push(` ${bold('Hint:')}`);
54
- output.push(yellow(padMultilineString(renderErrorMarkdown(err.hint, 'cli'), 4)));
53
+ output.push(yellow(padMultilineString(renderErrorMarkdown(error.hint, 'cli'), 4)));
55
54
  }
56
55
  if (docsBaseUrl) {
57
- const docsLink = getDocsForError(err, errorsData, docsBaseUrl);
56
+ const docsLink = getDocsForError(error, errorsData, docsBaseUrl);
58
57
  if (docsLink) {
59
58
  output.push(` ${bold('Error reference:')}`);
60
59
  output.push(` ${cyan(underline(docsLink))}`);
61
60
  }
62
61
  }
63
- if (err.stack) {
62
+ if (error.stack) {
64
63
  output.push(` ${bold('Stack trace:')}`);
65
- output.push(dim(formatErrorStackTrace(err, showFullStacktrace)));
64
+ output.push(dim(formatErrorStackTrace(error, showFullStacktrace)));
66
65
  }
67
- if (err.cause) {
66
+ if (error.cause) {
68
67
  output.push(` ${bold('Caused by:')}`);
69
68
  let causeMessage = ' ';
70
- if (err.cause instanceof Error) {
71
- causeMessage +=
72
- err.cause.message +
69
+ causeMessage +=
70
+ error.cause instanceof Error
71
+ ? error.cause.message +
73
72
  '\n' +
74
- formatErrorStackTrace(err.cause, showFullStacktrace);
75
- }
76
- else {
77
- causeMessage += JSON.stringify(err.cause);
78
- }
73
+ formatErrorStackTrace(error.cause, showFullStacktrace)
74
+ : JSON.stringify(error.cause);
79
75
  output.push(dim(causeMessage));
80
76
  }
81
77
  return output.join('\n');
@@ -1,5 +1,5 @@
1
1
  import type { ErrorLocation } from '../errors.js';
2
2
  export declare function normalizeLF(code: string): string;
3
3
  /** Generate a code frame from string and an error location */
4
- export declare function codeFrame(src: string, loc: ErrorLocation): string;
4
+ export declare function codeFrame(source: string, loc: ErrorLocation): string;
5
5
  //# sourceMappingURL=printer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../../src/dev/printer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAEvC;AAED,8DAA8D;AAC9D,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,MAAM,CAgCjE"}
1
+ {"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../../src/dev/printer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAEvC;AAED,8DAA8D;AAC9D,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,MAAM,CAgCpE"}
@@ -1,15 +1,14 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  export function normalizeLF(code) {
3
- return code.replace(/\r\n|\r(?!\n)|\n/g, '\n');
2
+ return code.replaceAll(/\r\n|\r(?!\n)|\n/g, '\n');
4
3
  }
5
4
  /** Generate a code frame from string and an error location */
6
- export function codeFrame(src, loc) {
5
+ export function codeFrame(source, loc) {
7
6
  if (!loc || loc.line === undefined || loc.column === undefined) {
8
7
  return '';
9
8
  }
10
- const lines = normalizeLF(src)
9
+ const lines = normalizeLF(source)
11
10
  .split('\n')
12
- .map((ln) => ln.replace(/\t/g, ' '));
11
+ .map((ln) => ln.replaceAll('\t', ' '));
13
12
  // grab 2 lines before, and 3 lines after focused line
14
13
  const visibleLines = [];
15
14
  for (let n = -2; n <= 2; n += 1) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/dev/utils.ts"],"names":[],"mappings":"AAeA,OAAO,EAEN,KAAK,iBAAiB,EAEtB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAezD,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,KAAK,CAW/C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAEvC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,CAAC,EAAE,GAAG,EACN,UAAU,CAAC,EAAE,GAAG,GAAG,SAAS,GAC1B,iBAAiB,CAuInB;AAqGD,wBAAgB,eAAe,CAC9B,GAAG,EAAE,iBAAiB,EACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAC3C,WAAW,EAAE,MAAM,GACjB,MAAM,GAAG,SAAS,CAcpB;AAQD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,UAc3E"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/dev/utils.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEN,KAAK,iBAAiB,EAEtB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAezD,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,KAAK,CAW/C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAEvC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,CAAC,EAAE,GAAG,EACN,UAAU,CAAC,EAAE,GAAG,GAAG,SAAS,GAC1B,iBAAiB,CAuInB;AAqGD,wBAAgB,eAAe,CAC9B,GAAG,EAAE,iBAAiB,EACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAC3C,WAAW,EAAE,MAAM,GACjB,MAAM,GAAG,SAAS,CAcpB;AAQD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,UAc3E"}
package/dist/dev/utils.js CHANGED
@@ -1,3 +1,5 @@
1
+ // TODO: Refactor with Gracile code-base style.
2
+ /* eslint-disable unicorn/no-abusive-eslint-disable */
1
3
  /* eslint-disable */
2
4
  import c from 'picocolors';
3
5
  import * as fs from 'node:fs';
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/dev/vite.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AASxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD,wBAAgB,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AAE,MAAM,cAAc,CAAC;AAGtD,wBAAgB,mBAAmB,CAAC,EACnC,KAAK,EACL,QAAQ,EACR,IAAI,GAEJ,EAAE;IACF,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;IAC3B,IAAI,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CAEjC,GAAG,KAAK,CAuFR;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC3B,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG;QACvC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,GAAG,CAAC,EAAE;YACL,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,MAAM,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;QACF,KAAK,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;CACF;AAcD;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,EACzC,GAAG,EACH,UAAU,EACV,WAAW,GACX,EAAE;IACF,GAAG,EAAE,iBAAiB,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC7C,WAAW,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkF9B"}
package/dist/dev/vite.js CHANGED
@@ -1,3 +1,5 @@
1
+ // TODO: Refactor with Gracile code-base style.
2
+ /* eslint-disable unicorn/no-abusive-eslint-disable */
1
3
  /* eslint-disable */
2
4
  import * as fs from 'node:fs';
3
5
  import { fileURLToPath } from 'node:url';
@@ -1,8 +1,8 @@
1
1
  export interface BetterErrorData {
2
2
  name: string;
3
3
  title: string;
4
- message?: string | ((...params: any) => string) | undefined;
5
- hint?: string | ((...params: any) => string) | undefined;
4
+ message?: string | ((...parameters: any) => string) | undefined;
5
+ hint?: string | ((...parameters: any) => string) | undefined;
6
6
  }
7
7
  /**
8
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"errors-data.d.ts","sourceRoot":"","sources":["../src/errors-data.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;IAC5D,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;CACzD;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;0BAGX,MAAM;;CAEF,CAAC"}
1
+ {"version":3,"file":"errors-data.d.ts","sourceRoot":"","sources":["../src/errors-data.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,UAAU,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;IAChE,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,UAAU,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;CAC7D;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;0BAGX,MAAM;;CAEF,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -44,23 +44,23 @@ export declare class BetterError<ConsumerErrorTypes extends string = string> ext
44
44
  hint: string | undefined;
45
45
  frame: string | undefined;
46
46
  type: BuiltinErrorTypes | ConsumerErrorTypes;
47
- constructor(props: ErrorProperties, options?: ErrorOptions);
47
+ constructor(properties: ErrorProperties, options?: ErrorOptions);
48
48
  setLocation(location: ErrorLocation): void;
49
49
  setName(name: string): void;
50
50
  setMessage(message: string): void;
51
51
  setHint(hint: string): void;
52
52
  setFrame(source: string, location: ErrorLocation): void;
53
- static is(err: unknown): err is BetterError;
53
+ static is(error: unknown): error is BetterError;
54
54
  }
55
55
  export declare class AggregateError extends BetterError {
56
56
  type: BuiltinErrorTypes;
57
57
  errors: BetterError[];
58
- constructor(props: ErrorProperties & {
58
+ constructor(properties: ErrorProperties & {
59
59
  errors: BetterError[];
60
60
  }, options?: ErrorOptions);
61
- static is(err: unknown): err is AggregateError;
61
+ static is(error: unknown): error is AggregateError;
62
62
  }
63
- export declare function isBetterError(e: unknown): e is BetterError;
63
+ export declare function isBetterError(error: unknown): error is BetterError;
64
64
  export type SSRError = Error & ErrorPayload['err'];
65
65
  export {};
66
66
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAGzC,MAAM,MAAM,iBAAiB,GAC1B,aAAa,GAGb,eAAe,GACf,gBAAgB,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAC3D,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,iBAAiB,GAAG,CAAC,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,E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UAAU,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,YAAY;IAgBxD,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAI1C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI3B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI3B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAI9D,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW;CAG/C;AAED,qBAAa,cAAe,SAAQ,WAAW;IAC9C,IAAI,EAAE,iBAAiB,CAAoB;IAC3C,MAAM,EAAE,WAAW,EAAE,CAAC;gBAKrB,UAAU,EAAE,eAAe,GAAG;QAAE,MAAM,EAAE,WAAW,EAAE,CAAA;KAAE,EACvD,OAAO,CAAC,EAAE,YAAY;IAQvB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc;CAGlD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC"}
package/dist/errors.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { codeFrame } from './dev/printer.js';
2
2
  export class BetterError extends Error {
3
- constructor(props, options) {
4
- const { name, title, message, stack, location, hint, frame } = props;
3
+ constructor(properties, options) {
4
+ const { name, title, message, stack, location, hint, frame } = properties;
5
5
  super(message, options);
6
6
  this.type = 'BetterError';
7
7
  this.title = title;
8
+ // eslint-disable-next-line unicorn/custom-error-definition
8
9
  this.name = name;
9
10
  if (message)
10
11
  this.message = message;
@@ -30,22 +31,22 @@ export class BetterError extends Error {
30
31
  setFrame(source, location) {
31
32
  this.frame = codeFrame(source, location);
32
33
  }
33
- static is(err) {
34
- return err.type === 'BetterError';
34
+ static is(error) {
35
+ return error.type === 'BetterError';
35
36
  }
36
37
  }
37
38
  export class AggregateError extends BetterError {
38
39
  // Despite being a collection of errors, AggregateError still needs to have a main error attached to it
39
40
  // This is because Vite expects every thrown errors handled during HMR to be, well, Error and have a message
40
- constructor(props, options) {
41
- super(props, options);
41
+ constructor(properties, options) {
42
+ super(properties, options);
42
43
  this.type = 'AggregateError';
43
- this.errors = props.errors;
44
+ this.errors = properties.errors;
44
45
  }
45
- static is(err) {
46
- return err.type === 'AggregateError';
46
+ static is(error) {
47
+ return error.type === 'AggregateError';
47
48
  }
48
49
  }
49
- export function isBetterError(e) {
50
- return e instanceof BetterError;
50
+ export function isBetterError(error) {
51
+ return error instanceof BetterError;
51
52
  }
package/dist/plugin.d.ts CHANGED
@@ -1,5 +1 @@
1
- export declare function patchOverlay(code: string, importPath?: string): string;
2
- export declare function betterErrors(options?: {
3
- overlayImportPath: string;
4
- }): any[];
5
1
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAeA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,UA6B7D;AAED,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE;IACtC,iBAAiB,EAAE,MAAM,CAAC;CAK1B,GAAG,GAAG,EAAE,CAgER"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":""}
package/dist/plugin.js CHANGED
@@ -1,84 +1,108 @@
1
- import { createLogger as createViteLogger } from 'vite';
2
- // @ts-expect-error No typings at all
3
- import launchMiddleware from 'launch-editor-middleware';
4
- import { getLogger } from '@gracile/internal-utils/logger/helpers';
5
- const VITE_PLUGIN_NAME = 'vite-plugin-better-errors';
6
- // const virtualModuleId = 'better-errors:overlay';
7
- // const resolvedVirtualModuleId = `\0${virtualModuleId}`;
8
- const GRACILE_OVERLAY_PATH = '@gracile-labs/better-errors/dev/custom-overlay/vite-custom-overlay';
9
- export function patchOverlay(code, importPath) {
10
- // NOTE: Make HTMLElement available in non-browser environments
11
- const { HTMLElement = class {
12
- } } = globalThis;
13
- class ErrorOverlay extends HTMLElement {
14
- constructor(err) {
15
- super();
16
- this.root = this.attachShadow({ mode: 'open' });
17
- this.dir = 'ltr';
18
- const customOverlay = document.createElement('vite-custom-overlay');
19
- customOverlay.errorPayload = err;
20
- this.root.append(customOverlay);
21
- }
22
- }
23
- const overlayCode = `
24
- import('${importPath ?? GRACILE_OVERLAY_PATH}');
25
-
26
- ${ErrorOverlay.toString()};
27
- `;
28
- return code.replace('class ErrorOverlay', overlayCode + '\nclass ViteErrorOverlay');
29
- }
30
- export function betterErrors(options) {
31
- // const logger = getLogger();
32
- // NOTE: Used to filter out redundant Vite errors, which are
33
- // noisy and less detailed than ours.
34
- // This should be refined on a case-by-case-basis.
35
- // Also, keep in mind that the user could use their own Vite
36
- // logger. Which is fine, but maybe the Gracile one should be
37
- // disabled in that case.
38
- const viteLogger = createViteLogger();
39
- const customLogger = createViteLogger();
40
- customLogger.error = (msg /* options */) => {
41
- if (msg.startsWith('\x1B[31mError when evaluating SSR module '))
42
- return;
43
- viteLogger.error(msg);
44
- };
45
- return [
46
- {
47
- name: VITE_PLUGIN_NAME,
48
- enforce: 'pre',
49
- apply: 'serve',
50
- config() {
51
- return {
52
- customLogger,
53
- };
54
- },
55
- configureServer(server) {
56
- server.middlewares.use('/__open-in-editor',
57
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
58
- launchMiddleware());
59
- },
60
- transform(code, id, opts = {}) {
61
- if (opts.ssr)
62
- return null;
63
- if (!id.includes('vite/dist/client/client.mjs'))
64
- return null;
65
- // Replace the Vite overlay with ours
66
- return patchOverlay(code, options?.overlayImportPath);
67
- },
68
- // resolveId(id) {
69
- // if (id === virtualModuleId) {
70
- // return resolvedVirtualModuleId;
71
- // }
72
- // return null;
73
- // },
74
- // load(id) {
75
- // if (id === resolvedVirtualModuleId) {
76
- // return `
77
- // const routeImports = new Map(
78
- // );
79
- // `;
80
- // }
81
- // },
82
- },
83
- ];
84
- }
1
+ "use strict";
2
+ // import { createLogger as createViteLogger, type PluginOption } from 'vite';
3
+ // // @\ts-expect-error No typings at all
4
+ // // import launchMiddleware from 'launch-editor-middleware';
5
+ // // import { getLogger } from '@gracile/internal-utils/logger/helpers';
6
+ // import type { BetterErrorPayload } from './dev/vite.js';
7
+ // const VITE_PLUGIN_NAME = 'vite-plugin-better-errors';
8
+ // // const virtualModuleId = 'better-errors:overlay';
9
+ // // const resolvedVirtualModuleId = `\0${virtualModuleId}`;
10
+ // // static GRACILE_OVERLAY_PATH =
11
+ // // '@gracile-labs/better-errors/dev/custom-overlay/vite-custom-overlay';
12
+ // export function patchOverlay(code: string, importPath?: string) {
13
+ // // NOTE: Make HTMLElement available in non-browser environments
14
+ // // eslint-disable-next-line @typescript-eslint/no-extraneous-class
15
+ // const { HTMLElement = class {} as typeof globalThis.HTMLElement } =
16
+ // globalThis;
17
+ // class ErrorOverlay extends HTMLElement {
18
+ // root: ShadowRoot;
19
+ // constructor(error: BetterErrorPayload['err']) {
20
+ // super();
21
+ // this.root = this.attachShadow({ mode: 'open' });
22
+ // this.dir = 'ltr';
23
+ // const customOverlay = document.createElement('vite-custom-overlay');
24
+ // customOverlay.errorPayload = error;
25
+ // // ;
26
+ // // // @ts-expect-error .
27
+ // // setTimeout(() => {
28
+ // // // __gracile_importOverlay();
29
+ // // }, 100);
30
+ // this.root.append(customOverlay);
31
+ // }
32
+ // }
33
+ // const overlayCode = `
34
+ // const BETTERR_OVERLAY_PATH =
35
+ // '@gracile-labs/better-errors/dev/custom-overlay/vite-custom-overlay';
36
+ // const BETTERR_CUSTOM_IMPORT_PATH = '${importPath}';
37
+ // // const __gracile_importOverlay = () => import(BETTERR_CUSTOM_IMPORT_PATH ?? BETTERR_OVERLAY_PATH);
38
+ // import('${importPath}')
39
+ // ${ErrorOverlay.toString()};
40
+ // `;
41
+ // return code.replace(
42
+ // 'class ErrorOverlay',
43
+ // overlayCode + '\nclass ViteErrorOverlay',
44
+ // );
45
+ // }
46
+ // export function betterErrors(options?: {
47
+ // overlayImportPath: string;
48
+ // // MarkdownRenderer: typeof MarkdownDocumentRendererEmpty;
49
+ // // NOTE: for Vite versions mismatches with `exactOptionalPropertyTypes`?
50
+ // // This `any[]` AND with a plugin -array- makes ESLint and TS shut up.
51
+ // // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ // }): any[] {
53
+ // // const logger = getLogger();
54
+ // // NOTE: Used to filter out redundant Vite errors, which are
55
+ // // noisy and less detailed than ours.
56
+ // // This should be refined on a case-by-case-basis.
57
+ // // Also, keep in mind that the user could use their own Vite
58
+ // // logger. Which is fine, but maybe the Gracile one should be
59
+ // // disabled in that case.
60
+ // const viteLogger = createViteLogger();
61
+ // const customLogger = createViteLogger();
62
+ // customLogger.error = (message /* options */) => {
63
+ // if (message.startsWith('\u001B[31mError when evaluating SSR module '))
64
+ // return;
65
+ // viteLogger.error(message);
66
+ // };
67
+ // return [
68
+ // {
69
+ // name: VITE_PLUGIN_NAME,
70
+ // enforce: 'pre',
71
+ // apply: 'serve',
72
+ // config() {
73
+ // return {
74
+ // customLogger,
75
+ // };
76
+ // },
77
+ // // NOTE: VITE ALREADY PROVIDE THIS!
78
+ // // configureServer(server) {
79
+ // // server.middlewares.use(
80
+ // // '/__open-in-editor',
81
+ // // // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
82
+ // // launchMiddleware(),
83
+ // // );
84
+ // // },
85
+ // transform(code, id, options_ = {}) {
86
+ // if (options_.ssr) return null;
87
+ // if (!id.includes('vite/dist/client/client.mjs')) return null;
88
+ // // Replace the Vite overlay with ours
89
+ // return patchOverlay(code, options?.overlayImportPath);
90
+ // },
91
+ // // resolveId(id) {
92
+ // // if (id === virtualModuleId) {
93
+ // // return resolvedVirtualModuleId;
94
+ // // }
95
+ // // return null;
96
+ // // },
97
+ // // load(id) {
98
+ // // if (id === resolvedVirtualModuleId) {
99
+ // // return `
100
+ // // const routeImports = new Map(
101
+ // // );
102
+ // // `;
103
+ // // }
104
+ // // },
105
+ // } satisfies PluginOption,
106
+ // ];
107
+ // }
108
+ throw new Error('Empty');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gracile-labs/better-errors",
3
- "version": "0.1.2-next.0",
3
+ "version": "0.1.2-next.2",
4
4
  "description": "A thin, full-stack, web framework",
5
5
  "keywords": [
6
6
  "vite",
@@ -39,17 +39,16 @@
39
39
  "!/dist/typedoc-entrypoint.*"
40
40
  ],
41
41
  "dependencies": {
42
- "@gracile/internal-utils": "^0.5.0-next.0",
42
+ "@gracile/internal-utils": "^0.5.0-next.2",
43
43
  "@lit-labs/ssr": "^3.2.2",
44
44
  "@lit-labs/ssr-client": "^1.1.7",
45
- "launch-editor-middleware": "^2.8.1",
46
45
  "lit": "^3.1.3",
47
46
  "picocolors": "^1.0.1",
48
- "vite": "^5.3.5"
47
+ "vite": "^6.0.5"
49
48
  },
50
49
  "publishConfig": {
51
50
  "access": "public",
52
51
  "provenance": true
53
52
  },
54
- "gitHead": "0213fc15f6295bf86234735a57aac32fea3ca489"
53
+ "gitHead": "b4c0be43ac4e41d69b5219b6a1b87333dc46b7f0"
55
54
  }
package/ambient.d.ts DELETED
File without changes