vite 3.2.1 → 3.2.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/LICENSE.md +2 -85
- package/dist/client/client.mjs +35 -30
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-d29b4e33.js → dep-51c4f80a.js} +2593 -3774
- package/dist/node/chunks/{dep-9055f77d.js → dep-7591464a.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/constants.js +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node-cjs/publicUtils.cjs +1 -1
- package/package.json +9 -6
- package/types/customEvent.d.ts +1 -0
- package/src/client/client.ts +0 -593
- package/src/client/env.ts +0 -29
- package/src/client/overlay.ts +0 -208
- package/src/client/tsconfig.json +0 -10
package/src/client/overlay.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import type { ErrorPayload } from 'types/hmrPayload'
|
|
2
|
-
|
|
3
|
-
// set :host styles to make playwright detect the element as visible
|
|
4
|
-
const template = /*html*/ `
|
|
5
|
-
<style>
|
|
6
|
-
:host {
|
|
7
|
-
position: fixed;
|
|
8
|
-
top: 0;
|
|
9
|
-
left: 0;
|
|
10
|
-
width: 100%;
|
|
11
|
-
height: 100%;
|
|
12
|
-
z-index: 99999;
|
|
13
|
-
--monospace: 'SFMono-Regular', Consolas,
|
|
14
|
-
'Liberation Mono', Menlo, Courier, monospace;
|
|
15
|
-
--red: #ff5555;
|
|
16
|
-
--yellow: #e2aa53;
|
|
17
|
-
--purple: #cfa4ff;
|
|
18
|
-
--cyan: #2dd9da;
|
|
19
|
-
--dim: #c9c9c9;
|
|
20
|
-
|
|
21
|
-
--window-background: #181818;
|
|
22
|
-
--window-color: #d8d8d8;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.backdrop {
|
|
26
|
-
position: fixed;
|
|
27
|
-
z-index: 99999;
|
|
28
|
-
top: 0;
|
|
29
|
-
left: 0;
|
|
30
|
-
width: 100%;
|
|
31
|
-
height: 100%;
|
|
32
|
-
overflow-y: scroll;
|
|
33
|
-
margin: 0;
|
|
34
|
-
background: rgba(0, 0, 0, 0.66);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.window {
|
|
38
|
-
font-family: var(--monospace);
|
|
39
|
-
line-height: 1.5;
|
|
40
|
-
width: 800px;
|
|
41
|
-
color: var(--window-color);
|
|
42
|
-
margin: 30px auto;
|
|
43
|
-
padding: 25px 40px;
|
|
44
|
-
position: relative;
|
|
45
|
-
background: var(--window-background);
|
|
46
|
-
border-radius: 6px 6px 8px 8px;
|
|
47
|
-
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
|
|
48
|
-
overflow: hidden;
|
|
49
|
-
border-top: 8px solid var(--red);
|
|
50
|
-
direction: ltr;
|
|
51
|
-
text-align: left;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
pre {
|
|
55
|
-
font-family: var(--monospace);
|
|
56
|
-
font-size: 16px;
|
|
57
|
-
margin-top: 0;
|
|
58
|
-
margin-bottom: 1em;
|
|
59
|
-
overflow-x: scroll;
|
|
60
|
-
scrollbar-width: none;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
pre::-webkit-scrollbar {
|
|
64
|
-
display: none;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.message {
|
|
68
|
-
line-height: 1.3;
|
|
69
|
-
font-weight: 600;
|
|
70
|
-
white-space: pre-wrap;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.message-body {
|
|
74
|
-
color: var(--red);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.plugin {
|
|
78
|
-
color: var(--purple);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.file {
|
|
82
|
-
color: var(--cyan);
|
|
83
|
-
margin-bottom: 0;
|
|
84
|
-
white-space: pre-wrap;
|
|
85
|
-
word-break: break-all;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.frame {
|
|
89
|
-
color: var(--yellow);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.stack {
|
|
93
|
-
font-size: 13px;
|
|
94
|
-
color: var(--dim);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.tip {
|
|
98
|
-
font-size: 13px;
|
|
99
|
-
color: #999;
|
|
100
|
-
border-top: 1px dotted #999;
|
|
101
|
-
padding-top: 13px;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
code {
|
|
105
|
-
font-size: 13px;
|
|
106
|
-
font-family: var(--monospace);
|
|
107
|
-
color: var(--yellow);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.file-link {
|
|
111
|
-
text-decoration: underline;
|
|
112
|
-
cursor: pointer;
|
|
113
|
-
}
|
|
114
|
-
</style>
|
|
115
|
-
<div class="backdrop" part="backdrop">
|
|
116
|
-
<div class="window" part="window">
|
|
117
|
-
<pre class="message" part="message"><span class="plugin"></span><span class="message-body"></span></pre>
|
|
118
|
-
<pre class="file" part="file"></pre>
|
|
119
|
-
<pre class="frame" part="frame"></pre>
|
|
120
|
-
<pre class="stack" part="stack"></pre>
|
|
121
|
-
<div class="tip" part="tip">
|
|
122
|
-
Click outside or fix the code to dismiss.<br>
|
|
123
|
-
You can also disable this overlay by setting
|
|
124
|
-
<code>server.hmr.overlay</code> to <code>false</code> in <code>vite.config.js.</code>
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
</div>
|
|
128
|
-
`
|
|
129
|
-
|
|
130
|
-
const fileRE = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g
|
|
131
|
-
const codeframeRE = /^(?:>?\s+\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm
|
|
132
|
-
|
|
133
|
-
// Allow `ErrorOverlay` to extend `HTMLElement` even in environments where
|
|
134
|
-
// `HTMLElement` was not originally defined.
|
|
135
|
-
const { HTMLElement = class {} as typeof globalThis.HTMLElement } = globalThis
|
|
136
|
-
export class ErrorOverlay extends HTMLElement {
|
|
137
|
-
root: ShadowRoot
|
|
138
|
-
|
|
139
|
-
constructor(err: ErrorPayload['err'], links = true) {
|
|
140
|
-
super()
|
|
141
|
-
this.root = this.attachShadow({ mode: 'open' })
|
|
142
|
-
this.root.innerHTML = template
|
|
143
|
-
|
|
144
|
-
codeframeRE.lastIndex = 0
|
|
145
|
-
const hasFrame = err.frame && codeframeRE.test(err.frame)
|
|
146
|
-
const message = hasFrame
|
|
147
|
-
? err.message.replace(codeframeRE, '')
|
|
148
|
-
: err.message
|
|
149
|
-
if (err.plugin) {
|
|
150
|
-
this.text('.plugin', `[plugin:${err.plugin}] `)
|
|
151
|
-
}
|
|
152
|
-
this.text('.message-body', message.trim())
|
|
153
|
-
|
|
154
|
-
const [file] = (err.loc?.file || err.id || 'unknown file').split(`?`)
|
|
155
|
-
if (err.loc) {
|
|
156
|
-
this.text('.file', `${file}:${err.loc.line}:${err.loc.column}`, links)
|
|
157
|
-
} else if (err.id) {
|
|
158
|
-
this.text('.file', file)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (hasFrame) {
|
|
162
|
-
this.text('.frame', err.frame!.trim())
|
|
163
|
-
}
|
|
164
|
-
this.text('.stack', err.stack, links)
|
|
165
|
-
|
|
166
|
-
this.root.querySelector('.window')!.addEventListener('click', (e) => {
|
|
167
|
-
e.stopPropagation()
|
|
168
|
-
})
|
|
169
|
-
this.addEventListener('click', () => {
|
|
170
|
-
this.close()
|
|
171
|
-
})
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
text(selector: string, text: string, linkFiles = false): void {
|
|
175
|
-
const el = this.root.querySelector(selector)!
|
|
176
|
-
if (!linkFiles) {
|
|
177
|
-
el.textContent = text
|
|
178
|
-
} else {
|
|
179
|
-
let curIndex = 0
|
|
180
|
-
let match: RegExpExecArray | null
|
|
181
|
-
while ((match = fileRE.exec(text))) {
|
|
182
|
-
const { 0: file, index } = match
|
|
183
|
-
if (index != null) {
|
|
184
|
-
const frag = text.slice(curIndex, index)
|
|
185
|
-
el.appendChild(document.createTextNode(frag))
|
|
186
|
-
const link = document.createElement('a')
|
|
187
|
-
link.textContent = file
|
|
188
|
-
link.className = 'file-link'
|
|
189
|
-
link.onclick = () => {
|
|
190
|
-
fetch('/__open-in-editor?file=' + encodeURIComponent(file))
|
|
191
|
-
}
|
|
192
|
-
el.appendChild(link)
|
|
193
|
-
curIndex += frag.length + file.length
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
close(): void {
|
|
200
|
-
this.parentNode?.removeChild(this)
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export const overlayId = 'vite-error-overlay'
|
|
205
|
-
const { customElements } = globalThis // Ensure `customElements` is defined before the next line.
|
|
206
|
-
if (customElements && !customElements.get(overlayId)) {
|
|
207
|
-
customElements.define(overlayId, ErrorOverlay)
|
|
208
|
-
}
|