vite 6.3.4 → 7.0.0-beta.0
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 +29 -0
- package/dist/client/client.mjs +796 -924
- package/dist/client/env.mjs +14 -19
- package/dist/node/chunks/dep-3jlWaCfC.js +5 -0
- package/dist/node/chunks/dep-B4i1tHPo.js +30 -0
- package/dist/node/chunks/dep-CCzsqxOh.js +5597 -0
- package/dist/node/chunks/dep-Ccq9jQdz.js +5 -0
- package/dist/node/chunks/dep-Ctugieod.js +150 -0
- package/dist/node/chunks/dep-D5HXLrlI.js +378 -0
- package/dist/node/chunks/dep-D_UgUiRQ.js +5 -0
- package/dist/node/chunks/dep-FHYvcJhE.js +446 -0
- package/dist/node/chunks/dep-P8c3Tybu.js +5 -0
- package/dist/node/chunks/dep-RiwDEHuV.js +7345 -0
- package/dist/node/chunks/dep-bvBD1i2C.js +36517 -0
- package/dist/node/cli.js +617 -865
- package/dist/node/constants.js +3 -148
- package/dist/node/index.d.ts +2730 -3081
- package/dist/node/index.js +25 -188
- package/dist/node/module-runner.d.ts +241 -229
- package/dist/node/module-runner.js +1041 -1175
- package/dist/node/moduleRunnerTransport-CnL9s_k9.d.ts +88 -0
- package/package.json +36 -38
- package/types/internal/cssPreprocessorOptions.d.ts +0 -19
- package/dist/node/chunks/dep-3RmXg9uo.js +0 -553
- package/dist/node/chunks/dep-Bn81Esdm.js +0 -49496
- package/dist/node/chunks/dep-CvfTChi5.js +0 -8218
- package/dist/node/chunks/dep-D5ITTxnT.js +0 -7113
- package/dist/node/chunks/dep-SOJpRpBL.js +0 -822
- package/dist/node/moduleRunnerTransport.d-DJ_mE5sf.d.ts +0 -87
- package/dist/node-cjs/publicUtils.cjs +0 -3986
- package/index.cjs +0 -96
- package/index.d.cts +0 -6
package/dist/client/client.mjs
CHANGED
@@ -1,539 +1,502 @@
|
|
1
|
-
import
|
1
|
+
import "@vite/env";
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
);
|
23
|
-
}
|
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
|
-
const firstInvalidatedBy = this.hmrClient.currentFirstInvalidatedBy ?? this.ownerPath;
|
60
|
-
this.hmrClient.notifyListeners("vite:invalidate", {
|
61
|
-
path: this.ownerPath,
|
62
|
-
message,
|
63
|
-
firstInvalidatedBy
|
64
|
-
});
|
65
|
-
this.send("vite:invalidate", {
|
66
|
-
path: this.ownerPath,
|
67
|
-
message,
|
68
|
-
firstInvalidatedBy
|
69
|
-
});
|
70
|
-
this.hmrClient.logger.debug(
|
71
|
-
`invalidate ${this.ownerPath}${message ? `: ${message}` : ""}`
|
72
|
-
);
|
73
|
-
}
|
74
|
-
on(event, cb) {
|
75
|
-
const addToMap = (map) => {
|
76
|
-
const existing = map.get(event) || [];
|
77
|
-
existing.push(cb);
|
78
|
-
map.set(event, existing);
|
79
|
-
};
|
80
|
-
addToMap(this.hmrClient.customListenersMap);
|
81
|
-
addToMap(this.newListeners);
|
82
|
-
}
|
83
|
-
off(event, cb) {
|
84
|
-
const removeFromMap = (map) => {
|
85
|
-
const existing = map.get(event);
|
86
|
-
if (existing === void 0) {
|
87
|
-
return;
|
88
|
-
}
|
89
|
-
const pruned = existing.filter((l) => l !== cb);
|
90
|
-
if (pruned.length === 0) {
|
91
|
-
map.delete(event);
|
92
|
-
return;
|
93
|
-
}
|
94
|
-
map.set(event, pruned);
|
95
|
-
};
|
96
|
-
removeFromMap(this.hmrClient.customListenersMap);
|
97
|
-
removeFromMap(this.newListeners);
|
98
|
-
}
|
99
|
-
send(event, data) {
|
100
|
-
this.hmrClient.send({ type: "custom", event, data });
|
101
|
-
}
|
102
|
-
acceptDeps(deps, callback = () => {
|
103
|
-
}) {
|
104
|
-
const mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {
|
105
|
-
id: this.ownerPath,
|
106
|
-
callbacks: []
|
107
|
-
};
|
108
|
-
mod.callbacks.push({
|
109
|
-
deps,
|
110
|
-
fn: callback
|
111
|
-
});
|
112
|
-
this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
|
113
|
-
}
|
3
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.70.0/node_modules/@oxc-project/runtime/src/helpers/esm/typeof.js
|
4
|
+
function _typeof(o) {
|
5
|
+
"@babel/helpers - typeof";
|
6
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
7
|
+
return typeof o$1;
|
8
|
+
} : function(o$1) {
|
9
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
10
|
+
}, _typeof(o);
|
114
11
|
}
|
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
|
-
this.customListenersMap.clear();
|
146
|
-
this.ctxToListenersMap.clear();
|
147
|
-
}
|
148
|
-
// After an HMR update, some modules are no longer imported on the page
|
149
|
-
// but they may have left behind side effects that need to be cleaned up
|
150
|
-
// (e.g. style injections)
|
151
|
-
async prunePaths(paths) {
|
152
|
-
await Promise.all(
|
153
|
-
paths.map((path) => {
|
154
|
-
const disposer = this.disposeMap.get(path);
|
155
|
-
if (disposer) return disposer(this.dataMap.get(path));
|
156
|
-
})
|
157
|
-
);
|
158
|
-
paths.forEach((path) => {
|
159
|
-
const fn = this.pruneMap.get(path);
|
160
|
-
if (fn) {
|
161
|
-
fn(this.dataMap.get(path));
|
162
|
-
}
|
163
|
-
});
|
164
|
-
}
|
165
|
-
warnFailedUpdate(err, path) {
|
166
|
-
if (!(err instanceof Error) || !err.message.includes("fetch")) {
|
167
|
-
this.logger.error(err);
|
168
|
-
}
|
169
|
-
this.logger.error(
|
170
|
-
`Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`
|
171
|
-
);
|
172
|
-
}
|
173
|
-
/**
|
174
|
-
* buffer multiple hot updates triggered by the same src change
|
175
|
-
* so that they are invoked in the same order they were sent.
|
176
|
-
* (otherwise the order may be inconsistent because of the http request round trip)
|
177
|
-
*/
|
178
|
-
async queueUpdate(payload) {
|
179
|
-
this.updateQueue.push(this.fetchUpdate(payload));
|
180
|
-
if (!this.pendingUpdateQueue) {
|
181
|
-
this.pendingUpdateQueue = true;
|
182
|
-
await Promise.resolve();
|
183
|
-
this.pendingUpdateQueue = false;
|
184
|
-
const loading = [...this.updateQueue];
|
185
|
-
this.updateQueue = [];
|
186
|
-
(await Promise.all(loading)).forEach((fn) => fn && fn());
|
187
|
-
}
|
188
|
-
}
|
189
|
-
async fetchUpdate(update) {
|
190
|
-
const { path, acceptedPath, firstInvalidatedBy } = update;
|
191
|
-
const mod = this.hotModulesMap.get(path);
|
192
|
-
if (!mod) {
|
193
|
-
return;
|
194
|
-
}
|
195
|
-
let fetchedModule;
|
196
|
-
const isSelfUpdate = path === acceptedPath;
|
197
|
-
const qualifiedCallbacks = mod.callbacks.filter(
|
198
|
-
({ deps }) => deps.includes(acceptedPath)
|
199
|
-
);
|
200
|
-
if (isSelfUpdate || qualifiedCallbacks.length > 0) {
|
201
|
-
const disposer = this.disposeMap.get(acceptedPath);
|
202
|
-
if (disposer) await disposer(this.dataMap.get(acceptedPath));
|
203
|
-
try {
|
204
|
-
fetchedModule = await this.importUpdatedModule(update);
|
205
|
-
} catch (e) {
|
206
|
-
this.warnFailedUpdate(e, acceptedPath);
|
207
|
-
}
|
208
|
-
}
|
209
|
-
return () => {
|
210
|
-
try {
|
211
|
-
this.currentFirstInvalidatedBy = firstInvalidatedBy;
|
212
|
-
for (const { deps, fn } of qualifiedCallbacks) {
|
213
|
-
fn(
|
214
|
-
deps.map(
|
215
|
-
(dep) => dep === acceptedPath ? fetchedModule : void 0
|
216
|
-
)
|
217
|
-
);
|
218
|
-
}
|
219
|
-
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
220
|
-
this.logger.debug(`hot updated: ${loggedPath}`);
|
221
|
-
} finally {
|
222
|
-
this.currentFirstInvalidatedBy = void 0;
|
223
|
-
}
|
224
|
-
};
|
225
|
-
}
|
12
|
+
|
13
|
+
//#endregion
|
14
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.70.0/node_modules/@oxc-project/runtime/src/helpers/esm/toPrimitive.js
|
15
|
+
function toPrimitive(t, r) {
|
16
|
+
if ("object" != _typeof(t) || !t) return t;
|
17
|
+
var e = t[Symbol.toPrimitive];
|
18
|
+
if (void 0 !== e) {
|
19
|
+
var i = e.call(t, r || "default");
|
20
|
+
if ("object" != _typeof(i)) return i;
|
21
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
22
|
+
}
|
23
|
+
return ("string" === r ? String : Number)(t);
|
24
|
+
}
|
25
|
+
|
26
|
+
//#endregion
|
27
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.70.0/node_modules/@oxc-project/runtime/src/helpers/esm/toPropertyKey.js
|
28
|
+
function toPropertyKey(t) {
|
29
|
+
var i = toPrimitive(t, "string");
|
30
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
31
|
+
}
|
32
|
+
|
33
|
+
//#endregion
|
34
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.70.0/node_modules/@oxc-project/runtime/src/helpers/esm/defineProperty.js
|
35
|
+
function _defineProperty(e, r, t) {
|
36
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
37
|
+
value: t,
|
38
|
+
enumerable: !0,
|
39
|
+
configurable: !0,
|
40
|
+
writable: !0
|
41
|
+
}) : e[r] = t, e;
|
226
42
|
}
|
227
43
|
|
228
|
-
|
229
|
-
|
230
|
-
|
44
|
+
//#endregion
|
45
|
+
//#region src/shared/hmr.ts
|
46
|
+
var HMRContext = class {
|
47
|
+
constructor(hmrClient$1, ownerPath) {
|
48
|
+
this.hmrClient = hmrClient$1;
|
49
|
+
this.ownerPath = ownerPath;
|
50
|
+
_defineProperty(this, "newListeners", void 0);
|
51
|
+
if (!hmrClient$1.dataMap.has(ownerPath)) hmrClient$1.dataMap.set(ownerPath, {});
|
52
|
+
const mod = hmrClient$1.hotModulesMap.get(ownerPath);
|
53
|
+
if (mod) mod.callbacks = [];
|
54
|
+
const staleListeners = hmrClient$1.ctxToListenersMap.get(ownerPath);
|
55
|
+
if (staleListeners) for (const [event, staleFns] of staleListeners) {
|
56
|
+
const listeners = hmrClient$1.customListenersMap.get(event);
|
57
|
+
if (listeners) hmrClient$1.customListenersMap.set(event, listeners.filter((l) => !staleFns.includes(l)));
|
58
|
+
}
|
59
|
+
this.newListeners = new Map();
|
60
|
+
hmrClient$1.ctxToListenersMap.set(ownerPath, this.newListeners);
|
61
|
+
}
|
62
|
+
get data() {
|
63
|
+
return this.hmrClient.dataMap.get(this.ownerPath);
|
64
|
+
}
|
65
|
+
accept(deps, callback) {
|
66
|
+
if (typeof deps === "function" || !deps) this.acceptDeps([this.ownerPath], ([mod]) => deps?.(mod));
|
67
|
+
else if (typeof deps === "string") this.acceptDeps([deps], ([mod]) => callback?.(mod));
|
68
|
+
else if (Array.isArray(deps)) this.acceptDeps(deps, callback);
|
69
|
+
else throw new Error(`invalid hot.accept() usage.`);
|
70
|
+
}
|
71
|
+
acceptExports(_, callback) {
|
72
|
+
this.acceptDeps([this.ownerPath], ([mod]) => callback?.(mod));
|
73
|
+
}
|
74
|
+
dispose(cb) {
|
75
|
+
this.hmrClient.disposeMap.set(this.ownerPath, cb);
|
76
|
+
}
|
77
|
+
prune(cb) {
|
78
|
+
this.hmrClient.pruneMap.set(this.ownerPath, cb);
|
79
|
+
}
|
80
|
+
decline() {}
|
81
|
+
invalidate(message) {
|
82
|
+
const firstInvalidatedBy = this.hmrClient.currentFirstInvalidatedBy ?? this.ownerPath;
|
83
|
+
this.hmrClient.notifyListeners("vite:invalidate", {
|
84
|
+
path: this.ownerPath,
|
85
|
+
message,
|
86
|
+
firstInvalidatedBy
|
87
|
+
});
|
88
|
+
this.send("vite:invalidate", {
|
89
|
+
path: this.ownerPath,
|
90
|
+
message,
|
91
|
+
firstInvalidatedBy
|
92
|
+
});
|
93
|
+
this.hmrClient.logger.debug(`invalidate ${this.ownerPath}${message ? `: ${message}` : ""}`);
|
94
|
+
}
|
95
|
+
on(event, cb) {
|
96
|
+
const addToMap = (map) => {
|
97
|
+
const existing = map.get(event) || [];
|
98
|
+
existing.push(cb);
|
99
|
+
map.set(event, existing);
|
100
|
+
};
|
101
|
+
addToMap(this.hmrClient.customListenersMap);
|
102
|
+
addToMap(this.newListeners);
|
103
|
+
}
|
104
|
+
off(event, cb) {
|
105
|
+
const removeFromMap = (map) => {
|
106
|
+
const existing = map.get(event);
|
107
|
+
if (existing === void 0) return;
|
108
|
+
const pruned = existing.filter((l) => l !== cb);
|
109
|
+
if (pruned.length === 0) {
|
110
|
+
map.delete(event);
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
map.set(event, pruned);
|
114
|
+
};
|
115
|
+
removeFromMap(this.hmrClient.customListenersMap);
|
116
|
+
removeFromMap(this.newListeners);
|
117
|
+
}
|
118
|
+
send(event, data) {
|
119
|
+
this.hmrClient.send({
|
120
|
+
type: "custom",
|
121
|
+
event,
|
122
|
+
data
|
123
|
+
});
|
124
|
+
}
|
125
|
+
acceptDeps(deps, callback = () => {}) {
|
126
|
+
const mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {
|
127
|
+
id: this.ownerPath,
|
128
|
+
callbacks: []
|
129
|
+
};
|
130
|
+
mod.callbacks.push({
|
131
|
+
deps,
|
132
|
+
fn: callback
|
133
|
+
});
|
134
|
+
this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
|
135
|
+
}
|
136
|
+
};
|
137
|
+
var HMRClient = class {
|
138
|
+
constructor(logger, transport$1, importUpdatedModule) {
|
139
|
+
this.logger = logger;
|
140
|
+
this.transport = transport$1;
|
141
|
+
this.importUpdatedModule = importUpdatedModule;
|
142
|
+
_defineProperty(this, "hotModulesMap", new Map());
|
143
|
+
_defineProperty(this, "disposeMap", new Map());
|
144
|
+
_defineProperty(this, "pruneMap", new Map());
|
145
|
+
_defineProperty(this, "dataMap", new Map());
|
146
|
+
_defineProperty(this, "customListenersMap", new Map());
|
147
|
+
_defineProperty(this, "ctxToListenersMap", new Map());
|
148
|
+
_defineProperty(this, "currentFirstInvalidatedBy", void 0);
|
149
|
+
_defineProperty(this, "updateQueue", []);
|
150
|
+
_defineProperty(this, "pendingUpdateQueue", false);
|
151
|
+
}
|
152
|
+
async notifyListeners(event, data) {
|
153
|
+
const cbs = this.customListenersMap.get(event);
|
154
|
+
if (cbs) await Promise.allSettled(cbs.map((cb) => cb(data)));
|
155
|
+
}
|
156
|
+
send(payload) {
|
157
|
+
this.transport.send(payload).catch((err) => {
|
158
|
+
this.logger.error(err);
|
159
|
+
});
|
160
|
+
}
|
161
|
+
clear() {
|
162
|
+
this.hotModulesMap.clear();
|
163
|
+
this.disposeMap.clear();
|
164
|
+
this.pruneMap.clear();
|
165
|
+
this.dataMap.clear();
|
166
|
+
this.customListenersMap.clear();
|
167
|
+
this.ctxToListenersMap.clear();
|
168
|
+
}
|
169
|
+
async prunePaths(paths) {
|
170
|
+
await Promise.all(paths.map((path) => {
|
171
|
+
const disposer = this.disposeMap.get(path);
|
172
|
+
if (disposer) return disposer(this.dataMap.get(path));
|
173
|
+
}));
|
174
|
+
paths.forEach((path) => {
|
175
|
+
const fn = this.pruneMap.get(path);
|
176
|
+
if (fn) fn(this.dataMap.get(path));
|
177
|
+
});
|
178
|
+
}
|
179
|
+
warnFailedUpdate(err, path) {
|
180
|
+
if (!(err instanceof Error) || !err.message.includes("fetch")) this.logger.error(err);
|
181
|
+
this.logger.error(`Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`);
|
182
|
+
}
|
183
|
+
/**
|
184
|
+
* buffer multiple hot updates triggered by the same src change
|
185
|
+
* so that they are invoked in the same order they were sent.
|
186
|
+
* (otherwise the order may be inconsistent because of the http request round trip)
|
187
|
+
*/
|
188
|
+
async queueUpdate(payload) {
|
189
|
+
this.updateQueue.push(this.fetchUpdate(payload));
|
190
|
+
if (!this.pendingUpdateQueue) {
|
191
|
+
this.pendingUpdateQueue = true;
|
192
|
+
await Promise.resolve();
|
193
|
+
this.pendingUpdateQueue = false;
|
194
|
+
const loading = [...this.updateQueue];
|
195
|
+
this.updateQueue = [];
|
196
|
+
(await Promise.all(loading)).forEach((fn) => fn && fn());
|
197
|
+
}
|
198
|
+
}
|
199
|
+
async fetchUpdate(update) {
|
200
|
+
const { path, acceptedPath, firstInvalidatedBy } = update;
|
201
|
+
const mod = this.hotModulesMap.get(path);
|
202
|
+
if (!mod) return;
|
203
|
+
let fetchedModule;
|
204
|
+
const isSelfUpdate = path === acceptedPath;
|
205
|
+
const qualifiedCallbacks = mod.callbacks.filter(({ deps }) => deps.includes(acceptedPath));
|
206
|
+
if (isSelfUpdate || qualifiedCallbacks.length > 0) {
|
207
|
+
const disposer = this.disposeMap.get(acceptedPath);
|
208
|
+
if (disposer) await disposer(this.dataMap.get(acceptedPath));
|
209
|
+
try {
|
210
|
+
fetchedModule = await this.importUpdatedModule(update);
|
211
|
+
} catch (e) {
|
212
|
+
this.warnFailedUpdate(e, acceptedPath);
|
213
|
+
}
|
214
|
+
}
|
215
|
+
return () => {
|
216
|
+
try {
|
217
|
+
this.currentFirstInvalidatedBy = firstInvalidatedBy;
|
218
|
+
for (const { deps, fn } of qualifiedCallbacks) fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
|
219
|
+
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
220
|
+
this.logger.debug(`hot updated: ${loggedPath}`);
|
221
|
+
} finally {
|
222
|
+
this.currentFirstInvalidatedBy = void 0;
|
223
|
+
}
|
224
|
+
};
|
225
|
+
}
|
226
|
+
};
|
227
|
+
|
228
|
+
//#endregion
|
229
|
+
//#region ../../node_modules/.pnpm/nanoid@5.1.5/node_modules/nanoid/non-secure/index.js
|
230
|
+
let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
231
231
|
let nanoid = (size = 21) => {
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
}
|
237
|
-
return id
|
232
|
+
let id = "";
|
233
|
+
let i = size | 0;
|
234
|
+
while (i--) id += urlAlphabet[Math.random() * 64 | 0];
|
235
|
+
return id;
|
238
236
|
};
|
239
237
|
|
240
|
-
|
238
|
+
//#endregion
|
239
|
+
//#region src/shared/constants.ts
|
240
|
+
let SOURCEMAPPING_URL = "sourceMa";
|
241
|
+
SOURCEMAPPING_URL += "ppingURL";
|
242
|
+
|
243
|
+
//#endregion
|
244
|
+
//#region src/shared/utils.ts
|
245
|
+
const isWindows = typeof process !== "undefined" && process.platform === "win32";
|
246
|
+
const AsyncFunction = async function() {}.constructor;
|
241
247
|
function promiseWithResolvers() {
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
248
|
+
let resolve;
|
249
|
+
let reject;
|
250
|
+
const promise = new Promise((_resolve, _reject) => {
|
251
|
+
resolve = _resolve;
|
252
|
+
reject = _reject;
|
253
|
+
});
|
254
|
+
return {
|
255
|
+
promise,
|
256
|
+
resolve,
|
257
|
+
reject
|
258
|
+
};
|
249
259
|
}
|
250
260
|
|
261
|
+
//#endregion
|
262
|
+
//#region src/shared/moduleRunnerTransport.ts
|
251
263
|
function reviveInvokeError(e) {
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
const
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
)
|
350
|
-
);
|
351
|
-
}, timeout);
|
352
|
-
timeoutId?.unref?.();
|
353
|
-
}
|
354
|
-
rpcPromises.set(promiseId, { resolve, reject, name, timeoutId });
|
355
|
-
if (sendPromise) {
|
356
|
-
sendPromise.catch((err) => {
|
357
|
-
clearTimeout(timeoutId);
|
358
|
-
rpcPromises.delete(promiseId);
|
359
|
-
reject(err);
|
360
|
-
});
|
361
|
-
}
|
362
|
-
try {
|
363
|
-
return await promise;
|
364
|
-
} catch (err) {
|
365
|
-
throw reviveInvokeError(err);
|
366
|
-
}
|
367
|
-
}
|
368
|
-
};
|
264
|
+
const error = new Error(e.message || "Unknown invoke error");
|
265
|
+
Object.assign(error, e, { runnerError: new Error("RunnerError") });
|
266
|
+
return error;
|
267
|
+
}
|
268
|
+
const createInvokeableTransport = (transport$1) => {
|
269
|
+
if (transport$1.invoke) return {
|
270
|
+
...transport$1,
|
271
|
+
async invoke(name, data) {
|
272
|
+
const result = await transport$1.invoke({
|
273
|
+
type: "custom",
|
274
|
+
event: "vite:invoke",
|
275
|
+
data: {
|
276
|
+
id: "send",
|
277
|
+
name,
|
278
|
+
data
|
279
|
+
}
|
280
|
+
});
|
281
|
+
if ("error" in result) throw reviveInvokeError(result.error);
|
282
|
+
return result.result;
|
283
|
+
}
|
284
|
+
};
|
285
|
+
if (!transport$1.send || !transport$1.connect) throw new Error("transport must implement send and connect when invoke is not implemented");
|
286
|
+
const rpcPromises = new Map();
|
287
|
+
return {
|
288
|
+
...transport$1,
|
289
|
+
connect({ onMessage, onDisconnection }) {
|
290
|
+
return transport$1.connect({
|
291
|
+
onMessage(payload) {
|
292
|
+
if (payload.type === "custom" && payload.event === "vite:invoke") {
|
293
|
+
const data = payload.data;
|
294
|
+
if (data.id.startsWith("response:")) {
|
295
|
+
const invokeId = data.id.slice(9);
|
296
|
+
const promise = rpcPromises.get(invokeId);
|
297
|
+
if (!promise) return;
|
298
|
+
if (promise.timeoutId) clearTimeout(promise.timeoutId);
|
299
|
+
rpcPromises.delete(invokeId);
|
300
|
+
const { error, result } = data.data;
|
301
|
+
if (error) promise.reject(error);
|
302
|
+
else promise.resolve(result);
|
303
|
+
return;
|
304
|
+
}
|
305
|
+
}
|
306
|
+
onMessage(payload);
|
307
|
+
},
|
308
|
+
onDisconnection
|
309
|
+
});
|
310
|
+
},
|
311
|
+
disconnect() {
|
312
|
+
rpcPromises.forEach((promise) => {
|
313
|
+
promise.reject(new Error(`transport was disconnected, cannot call ${JSON.stringify(promise.name)}`));
|
314
|
+
});
|
315
|
+
rpcPromises.clear();
|
316
|
+
return transport$1.disconnect?.();
|
317
|
+
},
|
318
|
+
send(data) {
|
319
|
+
return transport$1.send(data);
|
320
|
+
},
|
321
|
+
async invoke(name, data) {
|
322
|
+
const promiseId = nanoid();
|
323
|
+
const wrappedData = {
|
324
|
+
type: "custom",
|
325
|
+
event: "vite:invoke",
|
326
|
+
data: {
|
327
|
+
name,
|
328
|
+
id: `send:${promiseId}`,
|
329
|
+
data
|
330
|
+
}
|
331
|
+
};
|
332
|
+
const sendPromise = transport$1.send(wrappedData);
|
333
|
+
const { promise, resolve, reject } = promiseWithResolvers();
|
334
|
+
const timeout = transport$1.timeout ?? 6e4;
|
335
|
+
let timeoutId;
|
336
|
+
if (timeout > 0) {
|
337
|
+
timeoutId = setTimeout(() => {
|
338
|
+
rpcPromises.delete(promiseId);
|
339
|
+
reject(new Error(`transport invoke timed out after ${timeout}ms (data: ${JSON.stringify(wrappedData)})`));
|
340
|
+
}, timeout);
|
341
|
+
timeoutId?.unref?.();
|
342
|
+
}
|
343
|
+
rpcPromises.set(promiseId, {
|
344
|
+
resolve,
|
345
|
+
reject,
|
346
|
+
name,
|
347
|
+
timeoutId
|
348
|
+
});
|
349
|
+
if (sendPromise) sendPromise.catch((err) => {
|
350
|
+
clearTimeout(timeoutId);
|
351
|
+
rpcPromises.delete(promiseId);
|
352
|
+
reject(err);
|
353
|
+
});
|
354
|
+
try {
|
355
|
+
return await promise;
|
356
|
+
} catch (err) {
|
357
|
+
throw reviveInvokeError(err);
|
358
|
+
}
|
359
|
+
}
|
360
|
+
};
|
369
361
|
};
|
370
|
-
const normalizeModuleRunnerTransport = (transport) => {
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
} else {
|
414
|
-
throw new Error("send was called before connect");
|
415
|
-
}
|
416
|
-
}
|
417
|
-
await invokeableTransport.send(data);
|
418
|
-
},
|
419
|
-
async invoke(name, data) {
|
420
|
-
if (!isConnected) {
|
421
|
-
if (connectingPromise) {
|
422
|
-
await connectingPromise;
|
423
|
-
} else {
|
424
|
-
throw new Error("invoke was called before connect");
|
425
|
-
}
|
426
|
-
}
|
427
|
-
return invokeableTransport.invoke(name, data);
|
428
|
-
}
|
429
|
-
};
|
362
|
+
const normalizeModuleRunnerTransport = (transport$1) => {
|
363
|
+
const invokeableTransport = createInvokeableTransport(transport$1);
|
364
|
+
let isConnected = !invokeableTransport.connect;
|
365
|
+
let connectingPromise;
|
366
|
+
return {
|
367
|
+
...transport$1,
|
368
|
+
...invokeableTransport.connect ? { async connect(onMessage) {
|
369
|
+
if (isConnected) return;
|
370
|
+
if (connectingPromise) {
|
371
|
+
await connectingPromise;
|
372
|
+
return;
|
373
|
+
}
|
374
|
+
const maybePromise = invokeableTransport.connect({
|
375
|
+
onMessage: onMessage ?? (() => {}),
|
376
|
+
onDisconnection() {
|
377
|
+
isConnected = false;
|
378
|
+
}
|
379
|
+
});
|
380
|
+
if (maybePromise) {
|
381
|
+
connectingPromise = maybePromise;
|
382
|
+
await connectingPromise;
|
383
|
+
connectingPromise = void 0;
|
384
|
+
}
|
385
|
+
isConnected = true;
|
386
|
+
} } : {},
|
387
|
+
...invokeableTransport.disconnect ? { async disconnect() {
|
388
|
+
if (!isConnected) return;
|
389
|
+
if (connectingPromise) await connectingPromise;
|
390
|
+
isConnected = false;
|
391
|
+
await invokeableTransport.disconnect();
|
392
|
+
} } : {},
|
393
|
+
async send(data) {
|
394
|
+
if (!invokeableTransport.send) return;
|
395
|
+
if (!isConnected) if (connectingPromise) await connectingPromise;
|
396
|
+
else throw new Error("send was called before connect");
|
397
|
+
await invokeableTransport.send(data);
|
398
|
+
},
|
399
|
+
async invoke(name, data) {
|
400
|
+
if (!isConnected) if (connectingPromise) await connectingPromise;
|
401
|
+
else throw new Error("invoke was called before connect");
|
402
|
+
return invokeableTransport.invoke(name, data);
|
403
|
+
}
|
404
|
+
};
|
430
405
|
};
|
431
406
|
const createWebSocketModuleRunnerTransport = (options) => {
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
disconnect() {
|
479
|
-
clearInterval(pingIntervalId);
|
480
|
-
ws?.close();
|
481
|
-
},
|
482
|
-
send(data) {
|
483
|
-
ws.send(JSON.stringify(data));
|
484
|
-
}
|
485
|
-
};
|
407
|
+
const pingInterval = options.pingInterval ?? 3e4;
|
408
|
+
let ws;
|
409
|
+
let pingIntervalId;
|
410
|
+
return {
|
411
|
+
async connect({ onMessage, onDisconnection }) {
|
412
|
+
const socket = options.createConnection();
|
413
|
+
socket.addEventListener("message", async ({ data }) => {
|
414
|
+
onMessage(JSON.parse(data));
|
415
|
+
});
|
416
|
+
let isOpened = socket.readyState === socket.OPEN;
|
417
|
+
if (!isOpened) await new Promise((resolve, reject) => {
|
418
|
+
socket.addEventListener("open", () => {
|
419
|
+
isOpened = true;
|
420
|
+
resolve();
|
421
|
+
}, { once: true });
|
422
|
+
socket.addEventListener("close", async () => {
|
423
|
+
if (!isOpened) {
|
424
|
+
reject(new Error("WebSocket closed without opened."));
|
425
|
+
return;
|
426
|
+
}
|
427
|
+
onMessage({
|
428
|
+
type: "custom",
|
429
|
+
event: "vite:ws:disconnect",
|
430
|
+
data: { webSocket: socket }
|
431
|
+
});
|
432
|
+
onDisconnection();
|
433
|
+
});
|
434
|
+
});
|
435
|
+
onMessage({
|
436
|
+
type: "custom",
|
437
|
+
event: "vite:ws:connect",
|
438
|
+
data: { webSocket: socket }
|
439
|
+
});
|
440
|
+
ws = socket;
|
441
|
+
pingIntervalId = setInterval(() => {
|
442
|
+
if (socket.readyState === socket.OPEN) socket.send(JSON.stringify({ type: "ping" }));
|
443
|
+
}, pingInterval);
|
444
|
+
},
|
445
|
+
disconnect() {
|
446
|
+
clearInterval(pingIntervalId);
|
447
|
+
ws?.close();
|
448
|
+
},
|
449
|
+
send(data) {
|
450
|
+
ws.send(JSON.stringify(data));
|
451
|
+
}
|
452
|
+
};
|
486
453
|
};
|
487
454
|
|
455
|
+
//#endregion
|
456
|
+
//#region src/shared/hmrHandler.ts
|
488
457
|
function createHMRHandler(handler) {
|
489
|
-
|
490
|
-
|
491
|
-
}
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
});
|
520
|
-
return true;
|
521
|
-
}
|
522
|
-
}
|
458
|
+
const queue = new Queue();
|
459
|
+
return (payload) => queue.enqueue(() => handler(payload));
|
460
|
+
}
|
461
|
+
var Queue = class {
|
462
|
+
constructor() {
|
463
|
+
_defineProperty(this, "queue", []);
|
464
|
+
_defineProperty(this, "pending", false);
|
465
|
+
}
|
466
|
+
enqueue(promise) {
|
467
|
+
return new Promise((resolve, reject) => {
|
468
|
+
this.queue.push({
|
469
|
+
promise,
|
470
|
+
resolve,
|
471
|
+
reject
|
472
|
+
});
|
473
|
+
this.dequeue();
|
474
|
+
});
|
475
|
+
}
|
476
|
+
dequeue() {
|
477
|
+
if (this.pending) return false;
|
478
|
+
const item = this.queue.shift();
|
479
|
+
if (!item) return false;
|
480
|
+
this.pending = true;
|
481
|
+
item.promise().then(item.resolve).catch(item.reject).finally(() => {
|
482
|
+
this.pending = false;
|
483
|
+
this.dequeue();
|
484
|
+
});
|
485
|
+
return true;
|
486
|
+
}
|
487
|
+
};
|
523
488
|
|
489
|
+
//#endregion
|
490
|
+
//#region src/client/overlay.ts
|
524
491
|
const hmrConfigName = __HMR_CONFIG_NAME__;
|
525
492
|
const base$1 = __BASE__ || "/";
|
526
493
|
function h(e, attrs = {}, ...children) {
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
elem.append(...children);
|
532
|
-
return elem;
|
494
|
+
const elem = document.createElement(e);
|
495
|
+
for (const [k, v] of Object.entries(attrs)) elem.setAttribute(k, v);
|
496
|
+
elem.append(...children);
|
497
|
+
return elem;
|
533
498
|
}
|
534
|
-
const templateStyle =
|
535
|
-
/*css*/
|
536
|
-
`
|
499
|
+
const templateStyle = `
|
537
500
|
:host {
|
538
501
|
position: fixed;
|
539
502
|
top: 0;
|
@@ -673,119 +636,100 @@ kbd {
|
|
673
636
|
border-color: rgb(54, 57, 64);
|
674
637
|
border-image: initial;
|
675
638
|
}
|
676
|
-
|
677
|
-
)
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
"."
|
707
|
-
)
|
708
|
-
),
|
709
|
-
h("style", {}, templateStyle)
|
710
|
-
);
|
711
|
-
const fileRE = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;
|
639
|
+
`;
|
640
|
+
const createTemplate = () => h("div", {
|
641
|
+
class: "backdrop",
|
642
|
+
part: "backdrop"
|
643
|
+
}, h("div", {
|
644
|
+
class: "window",
|
645
|
+
part: "window"
|
646
|
+
}, h("pre", {
|
647
|
+
class: "message",
|
648
|
+
part: "message"
|
649
|
+
}, h("span", {
|
650
|
+
class: "plugin",
|
651
|
+
part: "plugin"
|
652
|
+
}), h("span", {
|
653
|
+
class: "message-body",
|
654
|
+
part: "message-body"
|
655
|
+
})), h("pre", {
|
656
|
+
class: "file",
|
657
|
+
part: "file"
|
658
|
+
}), h("pre", {
|
659
|
+
class: "frame",
|
660
|
+
part: "frame"
|
661
|
+
}), h("pre", {
|
662
|
+
class: "stack",
|
663
|
+
part: "stack"
|
664
|
+
}), h("div", {
|
665
|
+
class: "tip",
|
666
|
+
part: "tip"
|
667
|
+
}, "Click outside, press ", h("kbd", {}, "Esc"), " key, or fix the code to dismiss.", h("br"), "You can also disable this overlay by setting ", h("code", { part: "config-option-name" }, "server.hmr.overlay"), " to ", h("code", { part: "config-option-value" }, "false"), " in ", h("code", { part: "config-file-name" }, hmrConfigName), ".")), h("style", {}, templateStyle));
|
668
|
+
const fileRE = /(?:file:\/\/)?(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;
|
712
669
|
const codeframeRE = /^(?:>?\s*\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm;
|
713
|
-
const { HTMLElement = class {
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
)
|
771
|
-
);
|
772
|
-
};
|
773
|
-
el.appendChild(link);
|
774
|
-
curIndex += frag.length + file.length;
|
775
|
-
}
|
776
|
-
}
|
777
|
-
}
|
778
|
-
close() {
|
779
|
-
this.parentNode?.removeChild(this);
|
780
|
-
document.removeEventListener("keydown", this.closeOnEsc);
|
781
|
-
}
|
782
|
-
}
|
670
|
+
const { HTMLElement = class {} } = globalThis;
|
671
|
+
var ErrorOverlay = class extends HTMLElement {
|
672
|
+
constructor(err, links = true) {
|
673
|
+
super();
|
674
|
+
_defineProperty(this, "root", void 0);
|
675
|
+
_defineProperty(this, "closeOnEsc", void 0);
|
676
|
+
this.root = this.attachShadow({ mode: "open" });
|
677
|
+
this.root.appendChild(createTemplate());
|
678
|
+
codeframeRE.lastIndex = 0;
|
679
|
+
const hasFrame = err.frame && codeframeRE.test(err.frame);
|
680
|
+
const message = hasFrame ? err.message.replace(codeframeRE, "") : err.message;
|
681
|
+
if (err.plugin) this.text(".plugin", `[plugin:${err.plugin}] `);
|
682
|
+
this.text(".message-body", message.trim());
|
683
|
+
const [file] = (err.loc?.file || err.id || "unknown file").split(`?`);
|
684
|
+
if (err.loc) this.text(".file", `${file}:${err.loc.line}:${err.loc.column}`, links);
|
685
|
+
else if (err.id) this.text(".file", file);
|
686
|
+
if (hasFrame) this.text(".frame", err.frame.trim());
|
687
|
+
this.text(".stack", err.stack, links);
|
688
|
+
this.root.querySelector(".window").addEventListener("click", (e) => {
|
689
|
+
e.stopPropagation();
|
690
|
+
});
|
691
|
+
this.addEventListener("click", () => {
|
692
|
+
this.close();
|
693
|
+
});
|
694
|
+
this.closeOnEsc = (e) => {
|
695
|
+
if (e.key === "Escape" || e.code === "Escape") this.close();
|
696
|
+
};
|
697
|
+
document.addEventListener("keydown", this.closeOnEsc);
|
698
|
+
}
|
699
|
+
text(selector, text, linkFiles = false) {
|
700
|
+
const el = this.root.querySelector(selector);
|
701
|
+
if (!linkFiles) el.textContent = text;
|
702
|
+
else {
|
703
|
+
let curIndex = 0;
|
704
|
+
let match;
|
705
|
+
fileRE.lastIndex = 0;
|
706
|
+
while (match = fileRE.exec(text)) {
|
707
|
+
const { 0: file, index } = match;
|
708
|
+
const frag = text.slice(curIndex, index);
|
709
|
+
el.appendChild(document.createTextNode(frag));
|
710
|
+
const link = document.createElement("a");
|
711
|
+
link.textContent = file;
|
712
|
+
link.className = "file-link";
|
713
|
+
link.onclick = () => {
|
714
|
+
fetch(new URL(`${base$1}__open-in-editor?file=${encodeURIComponent(file)}`, import.meta.url));
|
715
|
+
};
|
716
|
+
el.appendChild(link);
|
717
|
+
curIndex += frag.length + file.length;
|
718
|
+
}
|
719
|
+
if (curIndex < text.length) el.appendChild(document.createTextNode(text.slice(curIndex)));
|
720
|
+
}
|
721
|
+
}
|
722
|
+
close() {
|
723
|
+
this.parentNode?.removeChild(this);
|
724
|
+
document.removeEventListener("keydown", this.closeOnEsc);
|
725
|
+
}
|
726
|
+
};
|
783
727
|
const overlayId = "vite-error-overlay";
|
784
728
|
const { customElements } = globalThis;
|
785
|
-
if (customElements && !customElements.get(overlayId))
|
786
|
-
customElements.define(overlayId, ErrorOverlay);
|
787
|
-
}
|
729
|
+
if (customElements && !customElements.get(overlayId)) customElements.define(overlayId, ErrorOverlay);
|
788
730
|
|
731
|
+
//#endregion
|
732
|
+
//#region src/client/client.ts
|
789
733
|
console.debug("[vite] connecting...");
|
790
734
|
const importMetaUrl = new URL(import.meta.url);
|
791
735
|
const serverHost = __SERVER_HOST__;
|
@@ -796,339 +740,267 @@ const directSocketHost = __HMR_DIRECT_TARGET__;
|
|
796
740
|
const base = __BASE__ || "/";
|
797
741
|
const hmrTimeout = __HMR_TIMEOUT__;
|
798
742
|
const wsToken = __WS_TOKEN__;
|
799
|
-
const transport = normalizeModuleRunnerTransport(
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
await wsTransport.connect(handlers);
|
823
|
-
console.info(
|
824
|
-
"[vite] Direct websocket connection fallback. Check out https://vite.dev/config/server-options.html#server-hmr to remove the previous connection error."
|
825
|
-
);
|
826
|
-
} catch (e2) {
|
827
|
-
if (e2 instanceof Error && e2.message.includes("WebSocket closed without opened.")) {
|
828
|
-
const currentScriptHostURL = new URL(import.meta.url);
|
829
|
-
const currentScriptHost = currentScriptHostURL.host + currentScriptHostURL.pathname.replace(/@vite\/client$/, "");
|
830
|
-
console.error(
|
831
|
-
`[vite] failed to connect to websocket.
|
743
|
+
const transport = normalizeModuleRunnerTransport((() => {
|
744
|
+
let wsTransport = createWebSocketModuleRunnerTransport({
|
745
|
+
createConnection: () => new WebSocket(`${socketProtocol}://${socketHost}?token=${wsToken}`, "vite-hmr"),
|
746
|
+
pingInterval: hmrTimeout
|
747
|
+
});
|
748
|
+
return {
|
749
|
+
async connect(handlers) {
|
750
|
+
try {
|
751
|
+
await wsTransport.connect(handlers);
|
752
|
+
} catch (e) {
|
753
|
+
if (!hmrPort) {
|
754
|
+
wsTransport = createWebSocketModuleRunnerTransport({
|
755
|
+
createConnection: () => new WebSocket(`${socketProtocol}://${directSocketHost}?token=${wsToken}`, "vite-hmr"),
|
756
|
+
pingInterval: hmrTimeout
|
757
|
+
});
|
758
|
+
try {
|
759
|
+
await wsTransport.connect(handlers);
|
760
|
+
console.info("[vite] Direct websocket connection fallback. Check out https://vite.dev/config/server-options.html#server-hmr to remove the previous connection error.");
|
761
|
+
} catch (e$1) {
|
762
|
+
if (e$1 instanceof Error && e$1.message.includes("WebSocket closed without opened.")) {
|
763
|
+
const currentScriptHostURL = new URL(import.meta.url);
|
764
|
+
const currentScriptHost = currentScriptHostURL.host + currentScriptHostURL.pathname.replace(/@vite\/client$/, "");
|
765
|
+
console.error(`[vite] failed to connect to websocket.
|
832
766
|
your current setup:
|
833
|
-
(browser) ${currentScriptHost} <--[HTTP]--> ${serverHost} (server)
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
}
|
851
|
-
};
|
852
|
-
})()
|
853
|
-
);
|
767
|
+
(browser) ${currentScriptHost} <--[HTTP]--> ${serverHost} (server)\n (browser) ${socketHost} <--[WebSocket (failing)]--> ${directSocketHost} (server)\nCheck out your Vite / network configuration and https://vite.dev/config/server-options.html#server-hmr .`);
|
768
|
+
}
|
769
|
+
}
|
770
|
+
return;
|
771
|
+
}
|
772
|
+
console.error(`[vite] failed to connect to websocket (${e}). `);
|
773
|
+
throw e;
|
774
|
+
}
|
775
|
+
},
|
776
|
+
async disconnect() {
|
777
|
+
await wsTransport.disconnect();
|
778
|
+
},
|
779
|
+
send(data) {
|
780
|
+
wsTransport.send(data);
|
781
|
+
}
|
782
|
+
};
|
783
|
+
})());
|
854
784
|
let willUnload = false;
|
855
|
-
if (typeof window !== "undefined") {
|
856
|
-
|
857
|
-
|
858
|
-
});
|
859
|
-
}
|
785
|
+
if (typeof window !== "undefined") window.addEventListener("beforeunload", () => {
|
786
|
+
willUnload = true;
|
787
|
+
});
|
860
788
|
function cleanUrl(pathname) {
|
861
|
-
|
862
|
-
|
863
|
-
|
789
|
+
const url = new URL(pathname, "http://vite.dev");
|
790
|
+
url.searchParams.delete("direct");
|
791
|
+
return url.pathname + url.search;
|
864
792
|
}
|
865
793
|
let isFirstUpdate = true;
|
866
|
-
const outdatedLinkTags =
|
794
|
+
const outdatedLinkTags = new WeakSet();
|
867
795
|
const debounceReload = (time) => {
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
796
|
+
let timer;
|
797
|
+
return () => {
|
798
|
+
if (timer) {
|
799
|
+
clearTimeout(timer);
|
800
|
+
timer = null;
|
801
|
+
}
|
802
|
+
timer = setTimeout(() => {
|
803
|
+
location.reload();
|
804
|
+
}, time);
|
805
|
+
};
|
878
806
|
};
|
879
807
|
const pageReload = debounceReload(50);
|
880
|
-
const hmrClient = new HMRClient(
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
/* @vite-ignore */
|
895
|
-
base + acceptedPathWithoutQuery.slice(1) + `?${explicitImportRequired ? "import&" : ""}t=${timestamp}${query ? `&${query}` : ""}`
|
896
|
-
);
|
897
|
-
if (isWithinCircularImport) {
|
898
|
-
importPromise.catch(() => {
|
899
|
-
console.info(
|
900
|
-
`[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.`
|
901
|
-
);
|
902
|
-
pageReload();
|
903
|
-
});
|
904
|
-
}
|
905
|
-
return await importPromise;
|
906
|
-
}
|
907
|
-
);
|
808
|
+
const hmrClient = new HMRClient({
|
809
|
+
error: (err) => console.error("[vite]", err),
|
810
|
+
debug: (...msg) => console.debug("[vite]", ...msg)
|
811
|
+
}, transport, async function importUpdatedModule({ acceptedPath, timestamp, explicitImportRequired, isWithinCircularImport }) {
|
812
|
+
const [acceptedPathWithoutQuery, query] = acceptedPath.split(`?`);
|
813
|
+
const importPromise = import(
|
814
|
+
/* @vite-ignore */
|
815
|
+
base + acceptedPathWithoutQuery.slice(1) + `?${explicitImportRequired ? "import&" : ""}t=${timestamp}${query ? `&${query}` : ""}`);
|
816
|
+
if (isWithinCircularImport) importPromise.catch(() => {
|
817
|
+
console.info(`[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.`);
|
818
|
+
pageReload();
|
819
|
+
});
|
820
|
+
return await importPromise;
|
821
|
+
});
|
908
822
|
transport.connect(createHMRHandler(handleMessage));
|
909
823
|
async function handleMessage(payload) {
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
break;
|
989
|
-
case "prune":
|
990
|
-
await hmrClient.notifyListeners("vite:beforePrune", payload);
|
991
|
-
await hmrClient.prunePaths(payload.paths);
|
992
|
-
break;
|
993
|
-
case "error": {
|
994
|
-
await hmrClient.notifyListeners("vite:error", payload);
|
995
|
-
if (hasDocument) {
|
996
|
-
const err = payload.err;
|
997
|
-
if (enableOverlay) {
|
998
|
-
createErrorOverlay(err);
|
999
|
-
} else {
|
1000
|
-
console.error(
|
1001
|
-
`[vite] Internal Server Error
|
1002
|
-
${err.message}
|
1003
|
-
${err.stack}`
|
1004
|
-
);
|
1005
|
-
}
|
1006
|
-
}
|
1007
|
-
break;
|
1008
|
-
}
|
1009
|
-
case "ping":
|
1010
|
-
break;
|
1011
|
-
default: {
|
1012
|
-
const check = payload;
|
1013
|
-
return check;
|
1014
|
-
}
|
1015
|
-
}
|
824
|
+
switch (payload.type) {
|
825
|
+
case "connected":
|
826
|
+
console.debug(`[vite] connected.`);
|
827
|
+
break;
|
828
|
+
case "update":
|
829
|
+
await hmrClient.notifyListeners("vite:beforeUpdate", payload);
|
830
|
+
if (hasDocument) if (isFirstUpdate && hasErrorOverlay()) {
|
831
|
+
location.reload();
|
832
|
+
return;
|
833
|
+
} else {
|
834
|
+
if (enableOverlay) clearErrorOverlay();
|
835
|
+
isFirstUpdate = false;
|
836
|
+
}
|
837
|
+
await Promise.all(payload.updates.map(async (update) => {
|
838
|
+
if (update.type === "js-update") return hmrClient.queueUpdate(update);
|
839
|
+
const { path, timestamp } = update;
|
840
|
+
const searchUrl = cleanUrl(path);
|
841
|
+
const el = Array.from(document.querySelectorAll("link")).find((e) => !outdatedLinkTags.has(e) && cleanUrl(e.href).includes(searchUrl));
|
842
|
+
if (!el) return;
|
843
|
+
const newPath = `${base}${searchUrl.slice(1)}${searchUrl.includes("?") ? "&" : "?"}t=${timestamp}`;
|
844
|
+
return new Promise((resolve) => {
|
845
|
+
const newLinkTag = el.cloneNode();
|
846
|
+
newLinkTag.href = new URL(newPath, el.href).href;
|
847
|
+
const removeOldEl = () => {
|
848
|
+
el.remove();
|
849
|
+
console.debug(`[vite] css hot updated: ${searchUrl}`);
|
850
|
+
resolve();
|
851
|
+
};
|
852
|
+
newLinkTag.addEventListener("load", removeOldEl);
|
853
|
+
newLinkTag.addEventListener("error", removeOldEl);
|
854
|
+
outdatedLinkTags.add(el);
|
855
|
+
el.after(newLinkTag);
|
856
|
+
});
|
857
|
+
}));
|
858
|
+
await hmrClient.notifyListeners("vite:afterUpdate", payload);
|
859
|
+
break;
|
860
|
+
case "custom": {
|
861
|
+
await hmrClient.notifyListeners(payload.event, payload.data);
|
862
|
+
if (payload.event === "vite:ws:disconnect") {
|
863
|
+
if (hasDocument && !willUnload) {
|
864
|
+
console.log(`[vite] server connection lost. Polling for restart...`);
|
865
|
+
const socket = payload.data.webSocket;
|
866
|
+
const url = new URL(socket.url);
|
867
|
+
url.search = "";
|
868
|
+
await waitForSuccessfulPing(url.href);
|
869
|
+
location.reload();
|
870
|
+
}
|
871
|
+
}
|
872
|
+
break;
|
873
|
+
}
|
874
|
+
case "full-reload":
|
875
|
+
await hmrClient.notifyListeners("vite:beforeFullReload", payload);
|
876
|
+
if (hasDocument) if (payload.path && payload.path.endsWith(".html")) {
|
877
|
+
const pagePath = decodeURI(location.pathname);
|
878
|
+
const payloadPath = base + payload.path.slice(1);
|
879
|
+
if (pagePath === payloadPath || payload.path === "/index.html" || pagePath.endsWith("/") && pagePath + "index.html" === payloadPath) pageReload();
|
880
|
+
return;
|
881
|
+
} else pageReload();
|
882
|
+
break;
|
883
|
+
case "prune":
|
884
|
+
await hmrClient.notifyListeners("vite:beforePrune", payload);
|
885
|
+
await hmrClient.prunePaths(payload.paths);
|
886
|
+
break;
|
887
|
+
case "error": {
|
888
|
+
await hmrClient.notifyListeners("vite:error", payload);
|
889
|
+
if (hasDocument) {
|
890
|
+
const err = payload.err;
|
891
|
+
if (enableOverlay) createErrorOverlay(err);
|
892
|
+
else console.error(`[vite] Internal Server Error\n${err.message}\n${err.stack}`);
|
893
|
+
}
|
894
|
+
break;
|
895
|
+
}
|
896
|
+
case "ping": break;
|
897
|
+
default: {
|
898
|
+
const check = payload;
|
899
|
+
return check;
|
900
|
+
}
|
901
|
+
}
|
1016
902
|
}
|
1017
903
|
const enableOverlay = __HMR_ENABLE_OVERLAY__;
|
1018
904
|
const hasDocument = "document" in globalThis;
|
1019
905
|
function createErrorOverlay(err) {
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
906
|
+
clearErrorOverlay();
|
907
|
+
const { customElements: customElements$1 } = globalThis;
|
908
|
+
if (customElements$1) {
|
909
|
+
const ErrorOverlayConstructor = customElements$1.get(overlayId);
|
910
|
+
document.body.appendChild(new ErrorOverlayConstructor(err));
|
911
|
+
}
|
1026
912
|
}
|
1027
913
|
function clearErrorOverlay() {
|
1028
|
-
|
914
|
+
document.querySelectorAll(overlayId).forEach((n) => n.close());
|
1029
915
|
}
|
1030
916
|
function hasErrorOverlay() {
|
1031
|
-
|
917
|
+
return document.querySelectorAll(overlayId).length;
|
1032
918
|
}
|
1033
919
|
async function waitForSuccessfulPing(socketUrl, ms = 1e3) {
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
if (await ping()) {
|
1061
|
-
break;
|
1062
|
-
}
|
1063
|
-
await wait(ms);
|
1064
|
-
} else {
|
1065
|
-
await waitForWindowShow();
|
1066
|
-
}
|
1067
|
-
}
|
920
|
+
async function ping() {
|
921
|
+
const socket = new WebSocket(socketUrl, "vite-ping");
|
922
|
+
return new Promise((resolve) => {
|
923
|
+
function onOpen() {
|
924
|
+
resolve(true);
|
925
|
+
close();
|
926
|
+
}
|
927
|
+
function onError() {
|
928
|
+
resolve(false);
|
929
|
+
close();
|
930
|
+
}
|
931
|
+
function close() {
|
932
|
+
socket.removeEventListener("open", onOpen);
|
933
|
+
socket.removeEventListener("error", onError);
|
934
|
+
socket.close();
|
935
|
+
}
|
936
|
+
socket.addEventListener("open", onOpen);
|
937
|
+
socket.addEventListener("error", onError);
|
938
|
+
});
|
939
|
+
}
|
940
|
+
if (await ping()) return;
|
941
|
+
await wait(ms);
|
942
|
+
while (true) if (document.visibilityState === "visible") {
|
943
|
+
if (await ping()) break;
|
944
|
+
await wait(ms);
|
945
|
+
} else await waitForWindowShow();
|
1068
946
|
}
|
1069
947
|
function wait(ms) {
|
1070
|
-
|
948
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
1071
949
|
}
|
1072
950
|
function waitForWindowShow() {
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
}
|
1083
|
-
const sheetsMap =
|
1084
|
-
if ("document" in globalThis) {
|
1085
|
-
|
1086
|
-
|
1087
|
-
});
|
1088
|
-
}
|
951
|
+
return new Promise((resolve) => {
|
952
|
+
const onChange = async () => {
|
953
|
+
if (document.visibilityState === "visible") {
|
954
|
+
resolve();
|
955
|
+
document.removeEventListener("visibilitychange", onChange);
|
956
|
+
}
|
957
|
+
};
|
958
|
+
document.addEventListener("visibilitychange", onChange);
|
959
|
+
});
|
960
|
+
}
|
961
|
+
const sheetsMap = new Map();
|
962
|
+
if ("document" in globalThis) document.querySelectorAll("style[data-vite-dev-id]").forEach((el) => {
|
963
|
+
sheetsMap.set(el.getAttribute("data-vite-dev-id"), el);
|
964
|
+
});
|
1089
965
|
const cspNonce = "document" in globalThis ? document.querySelector("meta[property=csp-nonce]")?.nonce : void 0;
|
1090
966
|
let lastInsertedStyle;
|
1091
967
|
function updateStyle(id, content) {
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
}
|
1109
|
-
lastInsertedStyle = style;
|
1110
|
-
} else {
|
1111
|
-
style.textContent = content;
|
1112
|
-
}
|
1113
|
-
sheetsMap.set(id, style);
|
968
|
+
let style = sheetsMap.get(id);
|
969
|
+
if (!style) {
|
970
|
+
style = document.createElement("style");
|
971
|
+
style.setAttribute("type", "text/css");
|
972
|
+
style.setAttribute("data-vite-dev-id", id);
|
973
|
+
style.textContent = content;
|
974
|
+
if (cspNonce) style.setAttribute("nonce", cspNonce);
|
975
|
+
if (!lastInsertedStyle) {
|
976
|
+
document.head.appendChild(style);
|
977
|
+
setTimeout(() => {
|
978
|
+
lastInsertedStyle = void 0;
|
979
|
+
}, 0);
|
980
|
+
} else lastInsertedStyle.insertAdjacentElement("afterend", style);
|
981
|
+
lastInsertedStyle = style;
|
982
|
+
} else style.textContent = content;
|
983
|
+
sheetsMap.set(id, style);
|
1114
984
|
}
|
1115
985
|
function removeStyle(id) {
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
986
|
+
const style = sheetsMap.get(id);
|
987
|
+
if (style) {
|
988
|
+
document.head.removeChild(style);
|
989
|
+
sheetsMap.delete(id);
|
990
|
+
}
|
1121
991
|
}
|
1122
992
|
function createHotContext(ownerPath) {
|
1123
|
-
|
993
|
+
return new HMRContext(hmrClient, ownerPath);
|
1124
994
|
}
|
995
|
+
/**
|
996
|
+
* urls here are dynamic import() urls that couldn't be statically analyzed
|
997
|
+
*/
|
1125
998
|
function injectQuery(url, queryToInject) {
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
const { search, hash } = new URL(url, "http://vite.dev");
|
1131
|
-
return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ""}${hash || ""}`;
|
999
|
+
if (url[0] !== "." && url[0] !== "/") return url;
|
1000
|
+
const pathname = url.replace(/[?#].*$/, "");
|
1001
|
+
const { search, hash } = new URL(url, "http://vite.dev");
|
1002
|
+
return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ""}${hash || ""}`;
|
1132
1003
|
}
|
1133
1004
|
|
1134
|
-
|
1005
|
+
//#endregion
|
1006
|
+
export { ErrorOverlay, createHotContext, injectQuery, removeStyle, updateStyle };
|