@gracile-labs/better-errors 0.1.2-next.0 → 0.1.2-next.1
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/dev/custom-overlay/assets.d.ts +5 -5
- package/dist/dev/custom-overlay/assets.d.ts.map +1 -1
- package/dist/dev/custom-overlay/assets.js +1 -1
- package/dist/dev/custom-overlay/vite-custom-overlay.d.ts +0 -17
- package/dist/dev/custom-overlay/vite-custom-overlay.d.ts.map +1 -1
- package/dist/dev/custom-overlay/vite-custom-overlay.js +217 -208
- package/dist/dev/custom-overlay/vite-custom-overlay.styles.d.ts.map +1 -1
- package/dist/dev/custom-overlay/vite-custom-overlay.styles.js +0 -1
- package/dist/dev/logger.d.ts +1 -1
- package/dist/dev/logger.d.ts.map +1 -1
- package/dist/dev/logger.js +24 -28
- package/dist/dev/printer.d.ts +1 -1
- package/dist/dev/printer.d.ts.map +1 -1
- package/dist/dev/printer.js +4 -5
- package/dist/dev/utils.d.ts.map +1 -1
- package/dist/dev/utils.js +2 -0
- package/dist/dev/vite.d.ts.map +1 -1
- package/dist/dev/vite.js +2 -0
- package/dist/errors-data.d.ts +2 -2
- package/dist/errors-data.d.ts.map +1 -1
- package/dist/errors.d.ts +5 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +12 -11
- package/dist/plugin.d.ts +0 -4
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +108 -84
- package/package.json +4 -5
- package/ambient.d.ts +0 -0
|
@@ -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
|
|
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
|
|
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,
|
|
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":"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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":"
|
|
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"}
|
package/dist/dev/logger.d.ts
CHANGED
|
@@ -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(
|
|
4
|
+
export declare function formatErrorMessage(error: ErrorWithMetadata, showFullStacktrace: boolean, errorsData: Record<string, BetterErrorData>, docsBaseUrl?: string): string;
|
|
5
5
|
//# sourceMappingURL=logger.d.ts.map
|
package/dist/dev/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/dev/logger.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/dev/logger.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
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(
|
|
9
|
-
const stackLines = (
|
|
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 =
|
|
20
|
-
const errorLoc =
|
|
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(
|
|
42
|
-
const isOurError = BetterError.is(
|
|
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
|
-
|
|
45
|
-
message
|
|
46
|
-
|
|
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 (
|
|
51
|
+
if (error.hint) {
|
|
53
52
|
output.push(` ${bold('Hint:')}`);
|
|
54
|
-
output.push(yellow(padMultilineString(renderErrorMarkdown(
|
|
53
|
+
output.push(yellow(padMultilineString(renderErrorMarkdown(error.hint, 'cli'), 4)));
|
|
55
54
|
}
|
|
56
55
|
if (docsBaseUrl) {
|
|
57
|
-
const docsLink = getDocsForError(
|
|
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 (
|
|
62
|
+
if (error.stack) {
|
|
64
63
|
output.push(` ${bold('Stack trace:')}`);
|
|
65
|
-
output.push(dim(formatErrorStackTrace(
|
|
64
|
+
output.push(dim(formatErrorStackTrace(error, showFullStacktrace)));
|
|
66
65
|
}
|
|
67
|
-
if (
|
|
66
|
+
if (error.cause) {
|
|
68
67
|
output.push(` ${bold('Caused by:')}`);
|
|
69
68
|
let causeMessage = ' ';
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
causeMessage +=
|
|
70
|
+
error.cause instanceof Error
|
|
71
|
+
? error.cause.message +
|
|
73
72
|
'\n' +
|
|
74
|
-
formatErrorStackTrace(
|
|
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');
|
package/dist/dev/printer.d.ts
CHANGED
|
@@ -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(
|
|
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":"
|
|
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"}
|
package/dist/dev/printer.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
/* eslint-disable no-restricted-syntax */
|
|
2
1
|
export function normalizeLF(code) {
|
|
3
|
-
return code.
|
|
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(
|
|
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(
|
|
9
|
+
const lines = normalizeLF(source)
|
|
11
10
|
.split('\n')
|
|
12
|
-
.map((ln) => ln.
|
|
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) {
|
package/dist/dev/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/dev/utils.ts"],"names":[],"mappings":"
|
|
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
package/dist/dev/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/dev/vite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/dev/vite.ts"],"names":[],"mappings":"AAKA,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,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
package/dist/errors-data.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface BetterErrorData {
|
|
2
2
|
name: string;
|
|
3
3
|
title: string;
|
|
4
|
-
message?: string | ((...
|
|
5
|
-
hint?: string | ((...
|
|
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,
|
|
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(
|
|
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(
|
|
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(
|
|
58
|
+
constructor(properties: ErrorProperties & {
|
|
59
59
|
errors: BetterError[];
|
|
60
60
|
}, options?: ErrorOptions);
|
|
61
|
-
static is(
|
|
61
|
+
static is(error: unknown): error is AggregateError;
|
|
62
62
|
}
|
|
63
|
-
export declare function isBetterError(
|
|
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
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"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"}
|
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(
|
|
4
|
-
const { name, title, message, stack, location, hint, frame } =
|
|
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(
|
|
34
|
-
return
|
|
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(
|
|
41
|
-
super(
|
|
41
|
+
constructor(properties, options) {
|
|
42
|
+
super(properties, options);
|
|
42
43
|
this.type = 'AggregateError';
|
|
43
|
-
this.errors =
|
|
44
|
+
this.errors = properties.errors;
|
|
44
45
|
}
|
|
45
|
-
static is(
|
|
46
|
-
return
|
|
46
|
+
static is(error) {
|
|
47
|
+
return error.type === 'AggregateError';
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
export function isBetterError(
|
|
50
|
-
return
|
|
50
|
+
export function isBetterError(error) {
|
|
51
|
+
return error instanceof BetterError;
|
|
51
52
|
}
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":""}
|
package/dist/plugin.js
CHANGED
|
@@ -1,84 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
// const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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.
|
|
3
|
+
"version": "0.1.2-next.1",
|
|
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.
|
|
42
|
+
"@gracile/internal-utils": "^0.5.0-next.1",
|
|
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.
|
|
47
|
+
"vite": "^5.4.10"
|
|
49
48
|
},
|
|
50
49
|
"publishConfig": {
|
|
51
50
|
"access": "public",
|
|
52
51
|
"provenance": true
|
|
53
52
|
},
|
|
54
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "918ea2107304571493be80ada5e07496fae472f5"
|
|
55
54
|
}
|
package/ambient.d.ts
DELETED
|
File without changes
|