vite 5.3.0-beta.0 → 5.3.0-beta.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.
- package/LICENSE.md +111 -144
- package/dist/client/client.mjs +608 -606
- package/dist/client/env.mjs +18 -24
- package/dist/node/chunks/{dep-CTAUzmEN.js → dep-CkqaOKeN.js} +1 -1
- package/dist/node/chunks/{dep-BBErwUJM.js → dep-DxsHXWQ1.js} +23862 -20690
- package/dist/node/chunks/{dep-BPjeYeh_.js → dep-E0jGEM7W.js} +1 -1
- package/dist/node/cli.js +235 -244
- package/dist/node/constants.js +79 -83
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +186 -198
- package/dist/node/runtime.js +139 -99
- package/dist/node-cjs/publicUtils.cjs +514 -575
- package/package.json +11 -12
- package/dist/client/client.mjs.map +0 -1
- package/dist/client/env.mjs.map +0 -1
package/dist/client/client.mjs
CHANGED
@@ -1,245 +1,243 @@
|
|
1
1
|
import '@vite/env';
|
2
2
|
|
3
3
|
class HMRContext {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
constructor(hmrClient, ownerPath) {
|
5
|
+
this.hmrClient = hmrClient;
|
6
|
+
this.ownerPath = ownerPath;
|
7
|
+
if (!hmrClient.dataMap.has(ownerPath)) {
|
8
|
+
hmrClient.dataMap.set(ownerPath, {});
|
9
|
+
}
|
10
|
+
const mod = hmrClient.hotModulesMap.get(ownerPath);
|
11
|
+
if (mod) {
|
12
|
+
mod.callbacks = [];
|
13
|
+
}
|
14
|
+
const staleListeners = hmrClient.ctxToListenersMap.get(ownerPath);
|
15
|
+
if (staleListeners) {
|
16
|
+
for (const [event, staleFns] of staleListeners) {
|
17
|
+
const listeners = hmrClient.customListenersMap.get(event);
|
18
|
+
if (listeners) {
|
19
|
+
hmrClient.customListenersMap.set(
|
20
|
+
event,
|
21
|
+
listeners.filter((l) => !staleFns.includes(l))
|
22
|
+
);
|
9
23
|
}
|
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
|
-
this.hmrClient.messenger.send(JSON.stringify({ type: 'custom', event, data }));
|
97
|
-
}
|
98
|
-
acceptDeps(deps, callback = () => { }) {
|
99
|
-
const mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {
|
100
|
-
id: this.ownerPath,
|
101
|
-
callbacks: [],
|
102
|
-
};
|
103
|
-
mod.callbacks.push({
|
104
|
-
deps,
|
105
|
-
fn: callback,
|
106
|
-
});
|
107
|
-
this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
|
108
|
-
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
this.newListeners = /* @__PURE__ */ new Map();
|
27
|
+
hmrClient.ctxToListenersMap.set(ownerPath, this.newListeners);
|
28
|
+
}
|
29
|
+
get data() {
|
30
|
+
return this.hmrClient.dataMap.get(this.ownerPath);
|
31
|
+
}
|
32
|
+
accept(deps, callback) {
|
33
|
+
if (typeof deps === "function" || !deps) {
|
34
|
+
this.acceptDeps([this.ownerPath], ([mod]) => deps?.(mod));
|
35
|
+
} else if (typeof deps === "string") {
|
36
|
+
this.acceptDeps([deps], ([mod]) => callback?.(mod));
|
37
|
+
} else if (Array.isArray(deps)) {
|
38
|
+
this.acceptDeps(deps, callback);
|
39
|
+
} else {
|
40
|
+
throw new Error(`invalid hot.accept() usage.`);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
// export names (first arg) are irrelevant on the client side, they're
|
44
|
+
// extracted in the server for propagation
|
45
|
+
acceptExports(_, callback) {
|
46
|
+
this.acceptDeps([this.ownerPath], ([mod]) => callback?.(mod));
|
47
|
+
}
|
48
|
+
dispose(cb) {
|
49
|
+
this.hmrClient.disposeMap.set(this.ownerPath, cb);
|
50
|
+
}
|
51
|
+
prune(cb) {
|
52
|
+
this.hmrClient.pruneMap.set(this.ownerPath, cb);
|
53
|
+
}
|
54
|
+
// Kept for backward compatibility (#11036)
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
56
|
+
decline() {
|
57
|
+
}
|
58
|
+
invalidate(message) {
|
59
|
+
this.hmrClient.notifyListeners("vite:invalidate", {
|
60
|
+
path: this.ownerPath,
|
61
|
+
message
|
62
|
+
});
|
63
|
+
this.send("vite:invalidate", { path: this.ownerPath, message });
|
64
|
+
this.hmrClient.logger.debug(
|
65
|
+
`[vite] invalidate ${this.ownerPath}${message ? `: ${message}` : ""}`
|
66
|
+
);
|
67
|
+
}
|
68
|
+
on(event, cb) {
|
69
|
+
const addToMap = (map) => {
|
70
|
+
const existing = map.get(event) || [];
|
71
|
+
existing.push(cb);
|
72
|
+
map.set(event, existing);
|
73
|
+
};
|
74
|
+
addToMap(this.hmrClient.customListenersMap);
|
75
|
+
addToMap(this.newListeners);
|
76
|
+
}
|
77
|
+
off(event, cb) {
|
78
|
+
const removeFromMap = (map) => {
|
79
|
+
const existing = map.get(event);
|
80
|
+
if (existing === void 0) {
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
const pruned = existing.filter((l) => l !== cb);
|
84
|
+
if (pruned.length === 0) {
|
85
|
+
map.delete(event);
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
map.set(event, pruned);
|
89
|
+
};
|
90
|
+
removeFromMap(this.hmrClient.customListenersMap);
|
91
|
+
removeFromMap(this.newListeners);
|
92
|
+
}
|
93
|
+
send(event, data) {
|
94
|
+
this.hmrClient.messenger.send(
|
95
|
+
JSON.stringify({ type: "custom", event, data })
|
96
|
+
);
|
97
|
+
}
|
98
|
+
acceptDeps(deps, callback = () => {
|
99
|
+
}) {
|
100
|
+
const mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {
|
101
|
+
id: this.ownerPath,
|
102
|
+
callbacks: []
|
103
|
+
};
|
104
|
+
mod.callbacks.push({
|
105
|
+
deps,
|
106
|
+
fn: callback
|
107
|
+
});
|
108
|
+
this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
|
109
|
+
}
|
109
110
|
}
|
110
111
|
class HMRMessenger {
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
112
|
+
constructor(connection) {
|
113
|
+
this.connection = connection;
|
114
|
+
this.queue = [];
|
115
|
+
}
|
116
|
+
send(message) {
|
117
|
+
this.queue.push(message);
|
118
|
+
this.flush();
|
119
|
+
}
|
120
|
+
flush() {
|
121
|
+
if (this.connection.isReady()) {
|
122
|
+
this.queue.forEach((msg) => this.connection.send(msg));
|
123
|
+
this.queue = [];
|
124
|
+
}
|
125
|
+
}
|
125
126
|
}
|
126
127
|
class HMRClient {
|
127
|
-
|
128
|
-
|
129
|
-
importUpdatedModule
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
clear()
|
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
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
fetchedModule = await this.importUpdatedModule(update);
|
215
|
-
}
|
216
|
-
catch (e) {
|
217
|
-
this.warnFailedUpdate(e, acceptedPath);
|
218
|
-
}
|
219
|
-
}
|
220
|
-
return () => {
|
221
|
-
for (const { deps, fn } of qualifiedCallbacks) {
|
222
|
-
fn(deps.map((dep) => (dep === acceptedPath ? fetchedModule : undefined)));
|
223
|
-
}
|
224
|
-
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
225
|
-
this.logger.debug(`[vite] hot updated: ${loggedPath}`);
|
226
|
-
};
|
128
|
+
constructor(logger, connection, importUpdatedModule) {
|
129
|
+
this.logger = logger;
|
130
|
+
this.importUpdatedModule = importUpdatedModule;
|
131
|
+
this.hotModulesMap = /* @__PURE__ */ new Map();
|
132
|
+
this.disposeMap = /* @__PURE__ */ new Map();
|
133
|
+
this.pruneMap = /* @__PURE__ */ new Map();
|
134
|
+
this.dataMap = /* @__PURE__ */ new Map();
|
135
|
+
this.customListenersMap = /* @__PURE__ */ new Map();
|
136
|
+
this.ctxToListenersMap = /* @__PURE__ */ new Map();
|
137
|
+
this.updateQueue = [];
|
138
|
+
this.pendingUpdateQueue = false;
|
139
|
+
this.messenger = new HMRMessenger(connection);
|
140
|
+
}
|
141
|
+
async notifyListeners(event, data) {
|
142
|
+
const cbs = this.customListenersMap.get(event);
|
143
|
+
if (cbs) {
|
144
|
+
await Promise.allSettled(cbs.map((cb) => cb(data)));
|
145
|
+
}
|
146
|
+
}
|
147
|
+
clear() {
|
148
|
+
this.hotModulesMap.clear();
|
149
|
+
this.disposeMap.clear();
|
150
|
+
this.pruneMap.clear();
|
151
|
+
this.dataMap.clear();
|
152
|
+
this.customListenersMap.clear();
|
153
|
+
this.ctxToListenersMap.clear();
|
154
|
+
}
|
155
|
+
// After an HMR update, some modules are no longer imported on the page
|
156
|
+
// but they may have left behind side effects that need to be cleaned up
|
157
|
+
// (.e.g style injections)
|
158
|
+
async prunePaths(paths) {
|
159
|
+
await Promise.all(
|
160
|
+
paths.map((path) => {
|
161
|
+
const disposer = this.disposeMap.get(path);
|
162
|
+
if (disposer) return disposer(this.dataMap.get(path));
|
163
|
+
})
|
164
|
+
);
|
165
|
+
paths.forEach((path) => {
|
166
|
+
const fn = this.pruneMap.get(path);
|
167
|
+
if (fn) {
|
168
|
+
fn(this.dataMap.get(path));
|
169
|
+
}
|
170
|
+
});
|
171
|
+
}
|
172
|
+
warnFailedUpdate(err, path) {
|
173
|
+
if (!err.message.includes("fetch")) {
|
174
|
+
this.logger.error(err);
|
175
|
+
}
|
176
|
+
this.logger.error(
|
177
|
+
`[hmr] Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`
|
178
|
+
);
|
179
|
+
}
|
180
|
+
/**
|
181
|
+
* buffer multiple hot updates triggered by the same src change
|
182
|
+
* so that they are invoked in the same order they were sent.
|
183
|
+
* (otherwise the order may be inconsistent because of the http request round trip)
|
184
|
+
*/
|
185
|
+
async queueUpdate(payload) {
|
186
|
+
this.updateQueue.push(this.fetchUpdate(payload));
|
187
|
+
if (!this.pendingUpdateQueue) {
|
188
|
+
this.pendingUpdateQueue = true;
|
189
|
+
await Promise.resolve();
|
190
|
+
this.pendingUpdateQueue = false;
|
191
|
+
const loading = [...this.updateQueue];
|
192
|
+
this.updateQueue = [];
|
193
|
+
(await Promise.all(loading)).forEach((fn) => fn && fn());
|
194
|
+
}
|
195
|
+
}
|
196
|
+
async fetchUpdate(update) {
|
197
|
+
const { path, acceptedPath } = update;
|
198
|
+
const mod = this.hotModulesMap.get(path);
|
199
|
+
if (!mod) {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
let fetchedModule;
|
203
|
+
const isSelfUpdate = path === acceptedPath;
|
204
|
+
const qualifiedCallbacks = mod.callbacks.filter(
|
205
|
+
({ deps }) => deps.includes(acceptedPath)
|
206
|
+
);
|
207
|
+
if (isSelfUpdate || qualifiedCallbacks.length > 0) {
|
208
|
+
const disposer = this.disposeMap.get(acceptedPath);
|
209
|
+
if (disposer) await disposer(this.dataMap.get(acceptedPath));
|
210
|
+
try {
|
211
|
+
fetchedModule = await this.importUpdatedModule(update);
|
212
|
+
} catch (e) {
|
213
|
+
this.warnFailedUpdate(e, acceptedPath);
|
214
|
+
}
|
227
215
|
}
|
216
|
+
return () => {
|
217
|
+
for (const { deps, fn } of qualifiedCallbacks) {
|
218
|
+
fn(
|
219
|
+
deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0)
|
220
|
+
);
|
221
|
+
}
|
222
|
+
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
223
|
+
this.logger.debug(`[vite] hot updated: ${loggedPath}`);
|
224
|
+
};
|
225
|
+
}
|
228
226
|
}
|
229
227
|
|
230
228
|
const hmrConfigName = __HMR_CONFIG_NAME__;
|
231
|
-
const base$1 = __BASE__ ||
|
232
|
-
// Create an element with provided attributes and optional children
|
229
|
+
const base$1 = __BASE__ || "/";
|
233
230
|
function h(e, attrs = {}, ...children) {
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
}
|
241
|
-
|
242
|
-
|
231
|
+
const elem = document.createElement(e);
|
232
|
+
for (const [k, v] of Object.entries(attrs)) {
|
233
|
+
elem.setAttribute(k, v);
|
234
|
+
}
|
235
|
+
elem.append(...children);
|
236
|
+
return elem;
|
237
|
+
}
|
238
|
+
const templateStyle = (
|
239
|
+
/*css*/
|
240
|
+
`
|
243
241
|
:host {
|
244
242
|
position: fixed;
|
245
243
|
top: 0;
|
@@ -379,445 +377,449 @@ kbd {
|
|
379
377
|
border-color: rgb(54, 57, 64);
|
380
378
|
border-image: initial;
|
381
379
|
}
|
382
|
-
|
383
|
-
|
384
|
-
const createTemplate = () => h(
|
380
|
+
`
|
381
|
+
);
|
382
|
+
const createTemplate = () => h(
|
383
|
+
"div",
|
384
|
+
{ class: "backdrop", part: "backdrop" },
|
385
|
+
h(
|
386
|
+
"div",
|
387
|
+
{ class: "window", part: "window" },
|
388
|
+
h(
|
389
|
+
"pre",
|
390
|
+
{ class: "message", part: "message" },
|
391
|
+
h("span", { class: "plugin", part: "plugin" }),
|
392
|
+
h("span", { class: "message-body", part: "message-body" })
|
393
|
+
),
|
394
|
+
h("pre", { class: "file", part: "file" }),
|
395
|
+
h("pre", { class: "frame", part: "frame" }),
|
396
|
+
h("pre", { class: "stack", part: "stack" }),
|
397
|
+
h(
|
398
|
+
"div",
|
399
|
+
{ class: "tip", part: "tip" },
|
400
|
+
"Click outside, press ",
|
401
|
+
h("kbd", {}, "Esc"),
|
402
|
+
" key, or fix the code to dismiss.",
|
403
|
+
h("br"),
|
404
|
+
"You can also disable this overlay by setting ",
|
405
|
+
h("code", { part: "config-option-name" }, "server.hmr.overlay"),
|
406
|
+
" to ",
|
407
|
+
h("code", { part: "config-option-value" }, "false"),
|
408
|
+
" in ",
|
409
|
+
h("code", { part: "config-file-name" }, hmrConfigName),
|
410
|
+
"."
|
411
|
+
)
|
412
|
+
),
|
413
|
+
h("style", {}, templateStyle)
|
414
|
+
);
|
385
415
|
const fileRE = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;
|
386
416
|
const codeframeRE = /^(?:>?\s*\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm;
|
387
|
-
// Allow `ErrorOverlay` to extend `HTMLElement` even in environments where
|
388
|
-
// `HTMLElement` was not originally defined.
|
389
417
|
const { HTMLElement = class {
|
390
418
|
} } = globalThis;
|
391
419
|
class ErrorOverlay extends HTMLElement {
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
}
|
453
|
-
}
|
420
|
+
constructor(err, links = true) {
|
421
|
+
super();
|
422
|
+
this.root = this.attachShadow({ mode: "open" });
|
423
|
+
this.root.appendChild(createTemplate());
|
424
|
+
codeframeRE.lastIndex = 0;
|
425
|
+
const hasFrame = err.frame && codeframeRE.test(err.frame);
|
426
|
+
const message = hasFrame ? err.message.replace(codeframeRE, "") : err.message;
|
427
|
+
if (err.plugin) {
|
428
|
+
this.text(".plugin", `[plugin:${err.plugin}] `);
|
429
|
+
}
|
430
|
+
this.text(".message-body", message.trim());
|
431
|
+
const [file] = (err.loc?.file || err.id || "unknown file").split(`?`);
|
432
|
+
if (err.loc) {
|
433
|
+
this.text(".file", `${file}:${err.loc.line}:${err.loc.column}`, links);
|
434
|
+
} else if (err.id) {
|
435
|
+
this.text(".file", file);
|
436
|
+
}
|
437
|
+
if (hasFrame) {
|
438
|
+
this.text(".frame", err.frame.trim());
|
439
|
+
}
|
440
|
+
this.text(".stack", err.stack, links);
|
441
|
+
this.root.querySelector(".window").addEventListener("click", (e) => {
|
442
|
+
e.stopPropagation();
|
443
|
+
});
|
444
|
+
this.addEventListener("click", () => {
|
445
|
+
this.close();
|
446
|
+
});
|
447
|
+
this.closeOnEsc = (e) => {
|
448
|
+
if (e.key === "Escape" || e.code === "Escape") {
|
449
|
+
this.close();
|
450
|
+
}
|
451
|
+
};
|
452
|
+
document.addEventListener("keydown", this.closeOnEsc);
|
453
|
+
}
|
454
|
+
text(selector, text, linkFiles = false) {
|
455
|
+
const el = this.root.querySelector(selector);
|
456
|
+
if (!linkFiles) {
|
457
|
+
el.textContent = text;
|
458
|
+
} else {
|
459
|
+
let curIndex = 0;
|
460
|
+
let match;
|
461
|
+
fileRE.lastIndex = 0;
|
462
|
+
while (match = fileRE.exec(text)) {
|
463
|
+
const { 0: file, index } = match;
|
464
|
+
if (index != null) {
|
465
|
+
const frag = text.slice(curIndex, index);
|
466
|
+
el.appendChild(document.createTextNode(frag));
|
467
|
+
const link = document.createElement("a");
|
468
|
+
link.textContent = file;
|
469
|
+
link.className = "file-link";
|
470
|
+
link.onclick = () => {
|
471
|
+
fetch(
|
472
|
+
new URL(
|
473
|
+
`${base$1}__open-in-editor?file=${encodeURIComponent(file)}`,
|
474
|
+
import.meta.url
|
475
|
+
)
|
476
|
+
);
|
477
|
+
};
|
478
|
+
el.appendChild(link);
|
479
|
+
curIndex += frag.length + file.length;
|
454
480
|
}
|
481
|
+
}
|
455
482
|
}
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
483
|
+
}
|
484
|
+
close() {
|
485
|
+
this.parentNode?.removeChild(this);
|
486
|
+
document.removeEventListener("keydown", this.closeOnEsc);
|
487
|
+
}
|
461
488
|
}
|
462
|
-
const overlayId =
|
463
|
-
const { customElements } = globalThis;
|
489
|
+
const overlayId = "vite-error-overlay";
|
490
|
+
const { customElements } = globalThis;
|
464
491
|
if (customElements && !customElements.get(overlayId)) {
|
465
|
-
|
492
|
+
customElements.define(overlayId, ErrorOverlay);
|
466
493
|
}
|
467
494
|
|
468
|
-
|
469
|
-
console.debug('[vite] connecting...');
|
495
|
+
console.debug("[vite] connecting...");
|
470
496
|
const importMetaUrl = new URL(import.meta.url);
|
471
|
-
// use server configuration, then fallback to inference
|
472
497
|
const serverHost = __SERVER_HOST__;
|
473
|
-
const socketProtocol = __HMR_PROTOCOL__ || (importMetaUrl.protocol ===
|
498
|
+
const socketProtocol = __HMR_PROTOCOL__ || (importMetaUrl.protocol === "https:" ? "wss" : "ws");
|
474
499
|
const hmrPort = __HMR_PORT__;
|
475
500
|
const socketHost = `${__HMR_HOSTNAME__ || importMetaUrl.hostname}:${hmrPort || importMetaUrl.port}${__HMR_BASE__}`;
|
476
501
|
const directSocketHost = __HMR_DIRECT_TARGET__;
|
477
|
-
const base = __BASE__ ||
|
502
|
+
const base = __BASE__ || "/";
|
478
503
|
let socket;
|
479
504
|
try {
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
+
let fallback;
|
506
|
+
if (!hmrPort) {
|
507
|
+
fallback = () => {
|
508
|
+
socket = setupWebSocket(socketProtocol, directSocketHost, () => {
|
509
|
+
const currentScriptHostURL = new URL(import.meta.url);
|
510
|
+
const currentScriptHost = currentScriptHostURL.host + currentScriptHostURL.pathname.replace(/@vite\/client$/, "");
|
511
|
+
console.error(
|
512
|
+
`[vite] failed to connect to websocket.
|
513
|
+
your current setup:
|
514
|
+
(browser) ${currentScriptHost} <--[HTTP]--> ${serverHost} (server)
|
515
|
+
(browser) ${socketHost} <--[WebSocket (failing)]--> ${directSocketHost} (server)
|
516
|
+
Check out your Vite / network configuration and https://vitejs.dev/config/server-options.html#server-hmr .`
|
517
|
+
);
|
518
|
+
});
|
519
|
+
socket.addEventListener(
|
520
|
+
"open",
|
521
|
+
() => {
|
522
|
+
console.info(
|
523
|
+
"[vite] Direct websocket connection fallback. Check out https://vitejs.dev/config/server-options.html#server-hmr to remove the previous connection error."
|
524
|
+
);
|
525
|
+
},
|
526
|
+
{ once: true }
|
527
|
+
);
|
528
|
+
};
|
529
|
+
}
|
530
|
+
socket = setupWebSocket(socketProtocol, socketHost, fallback);
|
531
|
+
} catch (error) {
|
532
|
+
console.error(`[vite] failed to connect to websocket (${error}). `);
|
505
533
|
}
|
506
534
|
function setupWebSocket(protocol, hostAndPath, onCloseWithoutOpen) {
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
}
|
532
|
-
|
535
|
+
const socket2 = new WebSocket(`${protocol}://${hostAndPath}`, "vite-hmr");
|
536
|
+
let isOpened = false;
|
537
|
+
socket2.addEventListener(
|
538
|
+
"open",
|
539
|
+
() => {
|
540
|
+
isOpened = true;
|
541
|
+
notifyListeners("vite:ws:connect", { webSocket: socket2 });
|
542
|
+
},
|
543
|
+
{ once: true }
|
544
|
+
);
|
545
|
+
socket2.addEventListener("message", async ({ data }) => {
|
546
|
+
handleMessage(JSON.parse(data));
|
547
|
+
});
|
548
|
+
socket2.addEventListener("close", async ({ wasClean }) => {
|
549
|
+
if (wasClean) return;
|
550
|
+
if (!isOpened && onCloseWithoutOpen) {
|
551
|
+
onCloseWithoutOpen();
|
552
|
+
return;
|
553
|
+
}
|
554
|
+
notifyListeners("vite:ws:disconnect", { webSocket: socket2 });
|
555
|
+
if (hasDocument) {
|
556
|
+
console.log(`[vite] server connection lost. polling for restart...`);
|
557
|
+
await waitForSuccessfulPing(protocol, hostAndPath);
|
558
|
+
location.reload();
|
559
|
+
}
|
560
|
+
});
|
561
|
+
return socket2;
|
533
562
|
}
|
534
563
|
function cleanUrl(pathname) {
|
535
|
-
|
536
|
-
|
537
|
-
|
564
|
+
const url = new URL(pathname, "http://vitejs.dev");
|
565
|
+
url.searchParams.delete("direct");
|
566
|
+
return url.pathname + url.search;
|
538
567
|
}
|
539
568
|
let isFirstUpdate = true;
|
540
|
-
const outdatedLinkTags = new WeakSet();
|
569
|
+
const outdatedLinkTags = /* @__PURE__ */ new WeakSet();
|
541
570
|
const debounceReload = (time) => {
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
571
|
+
let timer;
|
572
|
+
return () => {
|
573
|
+
if (timer) {
|
574
|
+
clearTimeout(timer);
|
575
|
+
timer = null;
|
576
|
+
}
|
577
|
+
timer = setTimeout(() => {
|
578
|
+
location.reload();
|
579
|
+
}, time);
|
580
|
+
};
|
552
581
|
};
|
553
582
|
const pageReload = debounceReload(50);
|
554
|
-
const hmrClient = new HMRClient(
|
583
|
+
const hmrClient = new HMRClient(
|
584
|
+
console,
|
585
|
+
{
|
555
586
|
isReady: () => socket && socket.readyState === 1,
|
556
|
-
send: (message) => socket.send(message)
|
557
|
-
},
|
587
|
+
send: (message) => socket.send(message)
|
588
|
+
},
|
589
|
+
async function importUpdatedModule({
|
590
|
+
acceptedPath,
|
591
|
+
timestamp,
|
592
|
+
explicitImportRequired,
|
593
|
+
isWithinCircularImport
|
594
|
+
}) {
|
558
595
|
const [acceptedPathWithoutQuery, query] = acceptedPath.split(`?`);
|
559
596
|
const importPromise = import(
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
`?${explicitImportRequired ? 'import&' : ''}t=${timestamp}${query ? `&${query}` : ''}`);
|
597
|
+
/* @vite-ignore */
|
598
|
+
base + acceptedPathWithoutQuery.slice(1) + `?${explicitImportRequired ? "import&" : ""}t=${timestamp}${query ? `&${query}` : ""}`
|
599
|
+
);
|
564
600
|
if (isWithinCircularImport) {
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
601
|
+
importPromise.catch(() => {
|
602
|
+
console.info(
|
603
|
+
`[hmr] ${acceptedPath} failed to apply HMR as it's within a circular import. Reloading page to reset the execution order. To debug and break the circular import, you can run \`vite --debug hmr\` to log the circular dependency path if a file change triggered it.`
|
604
|
+
);
|
605
|
+
pageReload();
|
606
|
+
});
|
570
607
|
}
|
571
608
|
return await importPromise;
|
572
|
-
}
|
609
|
+
}
|
610
|
+
);
|
573
611
|
async function handleMessage(payload) {
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
return;
|
596
|
-
}
|
597
|
-
else {
|
598
|
-
if (enableOverlay) {
|
599
|
-
clearErrorOverlay();
|
600
|
-
}
|
601
|
-
isFirstUpdate = false;
|
602
|
-
}
|
603
|
-
}
|
604
|
-
await Promise.all(payload.updates.map(async (update) => {
|
605
|
-
if (update.type === 'js-update') {
|
606
|
-
return hmrClient.queueUpdate(update);
|
607
|
-
}
|
608
|
-
// css-update
|
609
|
-
// this is only sent when a css file referenced with <link> is updated
|
610
|
-
const { path, timestamp } = update;
|
611
|
-
const searchUrl = cleanUrl(path);
|
612
|
-
// can't use querySelector with `[href*=]` here since the link may be
|
613
|
-
// using relative paths so we need to use link.href to grab the full
|
614
|
-
// URL for the include check.
|
615
|
-
const el = Array.from(document.querySelectorAll('link')).find((e) => !outdatedLinkTags.has(e) && cleanUrl(e.href).includes(searchUrl));
|
616
|
-
if (!el) {
|
617
|
-
return;
|
618
|
-
}
|
619
|
-
const newPath = `${base}${searchUrl.slice(1)}${searchUrl.includes('?') ? '&' : '?'}t=${timestamp}`;
|
620
|
-
// rather than swapping the href on the existing tag, we will
|
621
|
-
// create a new link tag. Once the new stylesheet has loaded we
|
622
|
-
// will remove the existing link tag. This removes a Flash Of
|
623
|
-
// Unstyled Content that can occur when swapping out the tag href
|
624
|
-
// directly, as the new stylesheet has not yet been loaded.
|
625
|
-
return new Promise((resolve) => {
|
626
|
-
const newLinkTag = el.cloneNode();
|
627
|
-
newLinkTag.href = new URL(newPath, el.href).href;
|
628
|
-
const removeOldEl = () => {
|
629
|
-
el.remove();
|
630
|
-
console.debug(`[vite] css hot updated: ${searchUrl}`);
|
631
|
-
resolve();
|
632
|
-
};
|
633
|
-
newLinkTag.addEventListener('load', removeOldEl);
|
634
|
-
newLinkTag.addEventListener('error', removeOldEl);
|
635
|
-
outdatedLinkTags.add(el);
|
636
|
-
el.after(newLinkTag);
|
637
|
-
});
|
638
|
-
}));
|
639
|
-
notifyListeners('vite:afterUpdate', payload);
|
640
|
-
break;
|
641
|
-
case 'custom': {
|
642
|
-
notifyListeners(payload.event, payload.data);
|
643
|
-
break;
|
612
|
+
switch (payload.type) {
|
613
|
+
case "connected":
|
614
|
+
console.debug(`[vite] connected.`);
|
615
|
+
hmrClient.messenger.flush();
|
616
|
+
setInterval(() => {
|
617
|
+
if (socket.readyState === socket.OPEN) {
|
618
|
+
socket.send('{"type":"ping"}');
|
619
|
+
}
|
620
|
+
}, __HMR_TIMEOUT__);
|
621
|
+
break;
|
622
|
+
case "update":
|
623
|
+
notifyListeners("vite:beforeUpdate", payload);
|
624
|
+
if (hasDocument) {
|
625
|
+
if (isFirstUpdate && hasErrorOverlay()) {
|
626
|
+
window.location.reload();
|
627
|
+
return;
|
628
|
+
} else {
|
629
|
+
if (enableOverlay) {
|
630
|
+
clearErrorOverlay();
|
631
|
+
}
|
632
|
+
isFirstUpdate = false;
|
644
633
|
}
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
634
|
+
}
|
635
|
+
await Promise.all(
|
636
|
+
payload.updates.map(async (update) => {
|
637
|
+
if (update.type === "js-update") {
|
638
|
+
return hmrClient.queueUpdate(update);
|
639
|
+
}
|
640
|
+
const { path, timestamp } = update;
|
641
|
+
const searchUrl = cleanUrl(path);
|
642
|
+
const el = Array.from(
|
643
|
+
document.querySelectorAll("link")
|
644
|
+
).find(
|
645
|
+
(e) => !outdatedLinkTags.has(e) && cleanUrl(e.href).includes(searchUrl)
|
646
|
+
);
|
647
|
+
if (!el) {
|
648
|
+
return;
|
649
|
+
}
|
650
|
+
const newPath = `${base}${searchUrl.slice(1)}${searchUrl.includes("?") ? "&" : "?"}t=${timestamp}`;
|
651
|
+
return new Promise((resolve) => {
|
652
|
+
const newLinkTag = el.cloneNode();
|
653
|
+
newLinkTag.href = new URL(newPath, el.href).href;
|
654
|
+
const removeOldEl = () => {
|
655
|
+
el.remove();
|
656
|
+
console.debug(`[vite] css hot updated: ${searchUrl}`);
|
657
|
+
resolve();
|
658
|
+
};
|
659
|
+
newLinkTag.addEventListener("load", removeOldEl);
|
660
|
+
newLinkTag.addEventListener("error", removeOldEl);
|
661
|
+
outdatedLinkTags.add(el);
|
662
|
+
el.after(newLinkTag);
|
663
|
+
});
|
664
|
+
})
|
665
|
+
);
|
666
|
+
notifyListeners("vite:afterUpdate", payload);
|
667
|
+
break;
|
668
|
+
case "custom": {
|
669
|
+
notifyListeners(payload.event, payload.data);
|
670
|
+
break;
|
671
|
+
}
|
672
|
+
case "full-reload":
|
673
|
+
notifyListeners("vite:beforeFullReload", payload);
|
674
|
+
if (hasDocument) {
|
675
|
+
if (payload.path && payload.path.endsWith(".html")) {
|
676
|
+
const pagePath = decodeURI(location.pathname);
|
677
|
+
const payloadPath = base + payload.path.slice(1);
|
678
|
+
if (pagePath === payloadPath || payload.path === "/index.html" || pagePath.endsWith("/") && pagePath + "index.html" === payloadPath) {
|
679
|
+
pageReload();
|
680
|
+
}
|
681
|
+
return;
|
682
|
+
} else {
|
683
|
+
pageReload();
|
681
684
|
}
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
+
}
|
686
|
+
break;
|
687
|
+
case "prune":
|
688
|
+
notifyListeners("vite:beforePrune", payload);
|
689
|
+
await hmrClient.prunePaths(payload.paths);
|
690
|
+
break;
|
691
|
+
case "error": {
|
692
|
+
notifyListeners("vite:error", payload);
|
693
|
+
if (hasDocument) {
|
694
|
+
const err = payload.err;
|
695
|
+
if (enableOverlay) {
|
696
|
+
createErrorOverlay(err);
|
697
|
+
} else {
|
698
|
+
console.error(
|
699
|
+
`[vite] Internal Server Error
|
700
|
+
${err.message}
|
701
|
+
${err.stack}`
|
702
|
+
);
|
685
703
|
}
|
704
|
+
}
|
705
|
+
break;
|
706
|
+
}
|
707
|
+
default: {
|
708
|
+
const check = payload;
|
709
|
+
return check;
|
686
710
|
}
|
711
|
+
}
|
687
712
|
}
|
688
713
|
function notifyListeners(event, data) {
|
689
|
-
|
714
|
+
hmrClient.notifyListeners(event, data);
|
690
715
|
}
|
691
716
|
const enableOverlay = __HMR_ENABLE_OVERLAY__;
|
692
|
-
const hasDocument =
|
717
|
+
const hasDocument = "document" in globalThis;
|
693
718
|
function createErrorOverlay(err) {
|
694
|
-
|
695
|
-
|
719
|
+
clearErrorOverlay();
|
720
|
+
document.body.appendChild(new ErrorOverlay(err));
|
696
721
|
}
|
697
722
|
function clearErrorOverlay() {
|
698
|
-
|
723
|
+
document.querySelectorAll(overlayId).forEach((n) => n.close());
|
699
724
|
}
|
700
725
|
function hasErrorOverlay() {
|
701
|
-
|
702
|
-
}
|
703
|
-
async function waitForSuccessfulPing(
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
// Custom headers won't be included in a request with no-cors so (ab)use one of the
|
714
|
-
// safelisted headers to identify the ping request
|
715
|
-
Accept: 'text/x-vite-ping',
|
716
|
-
},
|
717
|
-
});
|
718
|
-
return true;
|
719
|
-
}
|
720
|
-
catch { }
|
721
|
-
return false;
|
722
|
-
};
|
723
|
-
if (await ping()) {
|
724
|
-
return;
|
725
|
-
}
|
726
|
-
await wait(ms);
|
727
|
-
// eslint-disable-next-line no-constant-condition
|
728
|
-
while (true) {
|
729
|
-
if (document.visibilityState === 'visible') {
|
730
|
-
if (await ping()) {
|
731
|
-
break;
|
732
|
-
}
|
733
|
-
await wait(ms);
|
734
|
-
}
|
735
|
-
else {
|
736
|
-
await waitForWindowShow();
|
726
|
+
return document.querySelectorAll(overlayId).length;
|
727
|
+
}
|
728
|
+
async function waitForSuccessfulPing(socketProtocol2, hostAndPath, ms = 1e3) {
|
729
|
+
const pingHostProtocol = socketProtocol2 === "wss" ? "https" : "http";
|
730
|
+
const ping = async () => {
|
731
|
+
try {
|
732
|
+
await fetch(`${pingHostProtocol}://${hostAndPath}`, {
|
733
|
+
mode: "no-cors",
|
734
|
+
headers: {
|
735
|
+
// Custom headers won't be included in a request with no-cors so (ab)use one of the
|
736
|
+
// safelisted headers to identify the ping request
|
737
|
+
Accept: "text/x-vite-ping"
|
737
738
|
}
|
738
|
-
|
739
|
+
});
|
740
|
+
return true;
|
741
|
+
} catch {
|
742
|
+
}
|
743
|
+
return false;
|
744
|
+
};
|
745
|
+
if (await ping()) {
|
746
|
+
return;
|
747
|
+
}
|
748
|
+
await wait(ms);
|
749
|
+
while (true) {
|
750
|
+
if (document.visibilityState === "visible") {
|
751
|
+
if (await ping()) {
|
752
|
+
break;
|
753
|
+
}
|
754
|
+
await wait(ms);
|
755
|
+
} else {
|
756
|
+
await waitForWindowShow();
|
757
|
+
}
|
758
|
+
}
|
739
759
|
}
|
740
760
|
function wait(ms) {
|
741
|
-
|
761
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
742
762
|
}
|
743
763
|
function waitForWindowShow() {
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
764
|
+
return new Promise((resolve) => {
|
765
|
+
const onChange = async () => {
|
766
|
+
if (document.visibilityState === "visible") {
|
767
|
+
resolve();
|
768
|
+
document.removeEventListener("visibilitychange", onChange);
|
769
|
+
}
|
770
|
+
};
|
771
|
+
document.addEventListener("visibilitychange", onChange);
|
772
|
+
});
|
753
773
|
}
|
754
|
-
const sheetsMap = new Map();
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
.querySelectorAll('style[data-vite-dev-id]')
|
760
|
-
.forEach((el) => {
|
761
|
-
sheetsMap.set(el.getAttribute('data-vite-dev-id'), el);
|
762
|
-
});
|
774
|
+
const sheetsMap = /* @__PURE__ */ new Map();
|
775
|
+
if ("document" in globalThis) {
|
776
|
+
document.querySelectorAll("style[data-vite-dev-id]").forEach((el) => {
|
777
|
+
sheetsMap.set(el.getAttribute("data-vite-dev-id"), el);
|
778
|
+
});
|
763
779
|
}
|
764
|
-
const cspNonce =
|
765
|
-
? (_a = document.querySelector('meta[property=csp-nonce]')) === null || _a === void 0 ? void 0 : _a.nonce
|
766
|
-
: undefined;
|
767
|
-
// all css imports should be inserted at the same position
|
768
|
-
// because after build it will be a single css file
|
780
|
+
const cspNonce = "document" in globalThis ? document.querySelector("meta[property=csp-nonce]")?.nonce : void 0;
|
769
781
|
let lastInsertedStyle;
|
770
782
|
function updateStyle(id, content) {
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
else {
|
794
|
-
style.textContent = content;
|
795
|
-
}
|
796
|
-
sheetsMap.set(id, style);
|
783
|
+
let style = sheetsMap.get(id);
|
784
|
+
if (!style) {
|
785
|
+
style = document.createElement("style");
|
786
|
+
style.setAttribute("type", "text/css");
|
787
|
+
style.setAttribute("data-vite-dev-id", id);
|
788
|
+
style.textContent = content;
|
789
|
+
if (cspNonce) {
|
790
|
+
style.setAttribute("nonce", cspNonce);
|
791
|
+
}
|
792
|
+
if (!lastInsertedStyle) {
|
793
|
+
document.head.appendChild(style);
|
794
|
+
setTimeout(() => {
|
795
|
+
lastInsertedStyle = void 0;
|
796
|
+
}, 0);
|
797
|
+
} else {
|
798
|
+
lastInsertedStyle.insertAdjacentElement("afterend", style);
|
799
|
+
}
|
800
|
+
lastInsertedStyle = style;
|
801
|
+
} else {
|
802
|
+
style.textContent = content;
|
803
|
+
}
|
804
|
+
sheetsMap.set(id, style);
|
797
805
|
}
|
798
806
|
function removeStyle(id) {
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
807
|
+
const style = sheetsMap.get(id);
|
808
|
+
if (style) {
|
809
|
+
document.head.removeChild(style);
|
810
|
+
sheetsMap.delete(id);
|
811
|
+
}
|
804
812
|
}
|
805
813
|
function createHotContext(ownerPath) {
|
806
|
-
|
814
|
+
return new HMRContext(hmrClient, ownerPath);
|
807
815
|
}
|
808
|
-
/**
|
809
|
-
* urls here are dynamic import() urls that couldn't be statically analyzed
|
810
|
-
*/
|
811
816
|
function injectQuery(url, queryToInject) {
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
const { search, hash } = new URL(url, 'http://vitejs.dev');
|
819
|
-
return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${hash || ''}`;
|
817
|
+
if (url[0] !== "." && url[0] !== "/") {
|
818
|
+
return url;
|
819
|
+
}
|
820
|
+
const pathname = url.replace(/[?#].*$/, "");
|
821
|
+
const { search, hash } = new URL(url, "http://vitejs.dev");
|
822
|
+
return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ""}${hash || ""}`;
|
820
823
|
}
|
821
824
|
|
822
825
|
export { ErrorOverlay, createHotContext, injectQuery, removeStyle, updateStyle };
|
823
|
-
//# sourceMappingURL=client.mjs.map
|