@depup/vite 8.0.8-depup.0 → 8.2.0-depup.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 +94 -2
- package/README.md +4 -4
- package/bin/openChrome.js +1 -1
- package/changes.json +6 -6
- package/client.d.ts +3 -0
- package/dist/client/bundledDevClient.mjs +1463 -0
- package/dist/client/client.mjs +90 -87
- package/dist/node/chunks/build.js +5484 -2
- package/dist/node/chunks/dist.js +191 -126
- package/dist/node/chunks/lib.js +1 -1
- package/dist/node/chunks/moduleRunnerTransport.d.ts +25 -26
- package/dist/node/chunks/node.js +16515 -14186
- package/dist/node/chunks/postcss-import.js +11 -11
- package/dist/node/cli.js +6 -8
- package/dist/node/index.d.ts +1431 -1244
- package/dist/node/index.js +1 -2
- package/dist/node/module-runner.d.ts +78 -80
- package/dist/node/module-runner.js +61 -45
- package/package.json +85 -83
- package/types/customEvent.d.ts +3 -1
- package/types/hmrPayload.d.ts +20 -6
- package/types/importGlob.d.ts +48 -6
- package/dist/node/chunks/build2.js +0 -5378
- package/dist/node/chunks/chunk.js +0 -37
- package/dist/node/chunks/config.js +0 -2
- package/dist/node/chunks/logger.js +0 -322
- package/dist/node/chunks/optimizer.js +0 -2
- package/dist/node/chunks/preview.js +0 -2
- package/dist/node/chunks/server.js +0 -2
package/dist/client/client.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "@vite/env";
|
|
2
|
-
//#region \0@oxc-project+runtime@0.
|
|
2
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
3
3
|
function _typeof(o) {
|
|
4
4
|
"@babel/helpers - typeof";
|
|
5
5
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -9,7 +9,7 @@ function _typeof(o) {
|
|
|
9
9
|
}, _typeof(o);
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
|
-
//#region \0@oxc-project+runtime@0.
|
|
12
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
13
13
|
function toPrimitive(t, r) {
|
|
14
14
|
if ("object" != _typeof(t) || !t) return t;
|
|
15
15
|
var e = t[Symbol.toPrimitive];
|
|
@@ -21,13 +21,13 @@ function toPrimitive(t, r) {
|
|
|
21
21
|
return ("string" === r ? String : Number)(t);
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
24
|
-
//#region \0@oxc-project+runtime@0.
|
|
24
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
25
25
|
function toPropertyKey(t) {
|
|
26
26
|
var i = toPrimitive(t, "string");
|
|
27
27
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
|
-
//#region \0@oxc-project+runtime@0.
|
|
30
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
31
31
|
function _defineProperty(e, r, t) {
|
|
32
32
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
33
33
|
value: t,
|
|
@@ -162,14 +162,18 @@ var HMRClient = class {
|
|
|
162
162
|
this.ctxToListenersMap.clear();
|
|
163
163
|
}
|
|
164
164
|
async prunePaths(paths) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
165
|
+
try {
|
|
166
|
+
await Promise.all(paths.map((path) => {
|
|
167
|
+
const disposer = this.disposeMap.get(path);
|
|
168
|
+
if (disposer) return disposer(this.dataMap.get(path));
|
|
169
|
+
}));
|
|
170
|
+
await Promise.all(paths.map((path) => {
|
|
171
|
+
const fn = this.pruneMap.get(path);
|
|
172
|
+
if (fn) return fn(this.dataMap.get(path));
|
|
173
|
+
}));
|
|
174
|
+
} finally {
|
|
175
|
+
paths.forEach((path) => this.dataMap.delete(path));
|
|
176
|
+
}
|
|
173
177
|
}
|
|
174
178
|
warnFailedUpdate(err, path) {
|
|
175
179
|
if (!(err instanceof Error) || !err.message.includes("fetch")) this.logger.error(err);
|
|
@@ -220,12 +224,12 @@ var HMRClient = class {
|
|
|
220
224
|
}
|
|
221
225
|
};
|
|
222
226
|
//#endregion
|
|
223
|
-
//#region ../../node_modules/.pnpm/nanoid@5.1.
|
|
227
|
+
//#region ../../node_modules/.pnpm/nanoid@5.1.16/node_modules/nanoid/non-secure/index.js
|
|
224
228
|
let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
225
229
|
let nanoid = (size = 21) => {
|
|
226
230
|
let id = "";
|
|
227
231
|
let i = size | 0;
|
|
228
|
-
while (i--) id += urlAlphabet[Math.random() * 64 | 0];
|
|
232
|
+
while (i-- > 0) id += urlAlphabet[Math.random() * 64 | 0];
|
|
229
233
|
return id;
|
|
230
234
|
};
|
|
231
235
|
//#endregion
|
|
@@ -381,16 +385,22 @@ const normalizeModuleRunnerTransport = (transport) => {
|
|
|
381
385
|
async send(data) {
|
|
382
386
|
if (!invokeableTransport.send) return;
|
|
383
387
|
if (!isConnected) if (connectingPromise) await connectingPromise;
|
|
384
|
-
else throw new
|
|
388
|
+
else throw new SendBeforeConnectError("send was called before connect");
|
|
385
389
|
await invokeableTransport.send(data);
|
|
386
390
|
},
|
|
387
391
|
async invoke(name, data) {
|
|
388
392
|
if (!isConnected) if (connectingPromise) await connectingPromise;
|
|
389
|
-
else throw new
|
|
393
|
+
else throw new SendBeforeConnectError("invoke was called before connect");
|
|
390
394
|
return invokeableTransport.invoke(name, data);
|
|
391
395
|
}
|
|
392
396
|
};
|
|
393
397
|
};
|
|
398
|
+
var SendBeforeConnectError = class extends Error {
|
|
399
|
+
constructor(message) {
|
|
400
|
+
super(message);
|
|
401
|
+
this.name = "SendBeforeConnectError";
|
|
402
|
+
}
|
|
403
|
+
};
|
|
394
404
|
const createWebSocketModuleRunnerTransport = (options) => {
|
|
395
405
|
const pingInterval = options.pingInterval ?? 3e4;
|
|
396
406
|
let ws;
|
|
@@ -398,7 +408,7 @@ const createWebSocketModuleRunnerTransport = (options) => {
|
|
|
398
408
|
return {
|
|
399
409
|
async connect({ onMessage, onDisconnection }) {
|
|
400
410
|
const socket = options.createConnection();
|
|
401
|
-
socket.addEventListener("message",
|
|
411
|
+
socket.addEventListener("message", ({ data }) => {
|
|
402
412
|
onMessage(JSON.parse(data));
|
|
403
413
|
});
|
|
404
414
|
let isOpened = socket.readyState === socket.OPEN;
|
|
@@ -407,7 +417,7 @@ const createWebSocketModuleRunnerTransport = (options) => {
|
|
|
407
417
|
isOpened = true;
|
|
408
418
|
resolve();
|
|
409
419
|
}, { once: true });
|
|
410
|
-
socket.addEventListener("close",
|
|
420
|
+
socket.addEventListener("close", () => {
|
|
411
421
|
if (!isOpened) {
|
|
412
422
|
reject(/* @__PURE__ */ new Error("WebSocket closed without opened."));
|
|
413
423
|
return;
|
|
@@ -474,10 +484,10 @@ var Queue = class {
|
|
|
474
484
|
};
|
|
475
485
|
//#endregion
|
|
476
486
|
//#region src/shared/forwardConsole.ts
|
|
477
|
-
function setupForwardConsoleHandler(transport, options) {
|
|
487
|
+
function setupForwardConsoleHandler(transport, options, console = globalThis.console) {
|
|
478
488
|
if (!options.enabled) return;
|
|
479
|
-
function sendError(type, error) {
|
|
480
|
-
transport.send({
|
|
489
|
+
async function sendError(type, error) {
|
|
490
|
+
await transport.send({
|
|
481
491
|
type: "custom",
|
|
482
492
|
event: "vite:forward-console",
|
|
483
493
|
data: {
|
|
@@ -490,19 +500,28 @@ function setupForwardConsoleHandler(transport, options) {
|
|
|
490
500
|
}
|
|
491
501
|
});
|
|
492
502
|
}
|
|
493
|
-
function sendLog(level, args) {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
type: "log",
|
|
503
|
+
async function sendLog(level, args) {
|
|
504
|
+
try {
|
|
505
|
+
await transport.send({
|
|
506
|
+
type: "custom",
|
|
507
|
+
event: "vite:forward-console",
|
|
499
508
|
data: {
|
|
500
|
-
|
|
501
|
-
|
|
509
|
+
type: "log",
|
|
510
|
+
data: {
|
|
511
|
+
level,
|
|
512
|
+
message: formatConsoleArgs(args)
|
|
513
|
+
}
|
|
502
514
|
}
|
|
515
|
+
});
|
|
516
|
+
} catch (err) {
|
|
517
|
+
try {
|
|
518
|
+
await sendError("unhandled-rejection", err);
|
|
519
|
+
} catch (err) {
|
|
520
|
+
if (!(err instanceof SendBeforeConnectError)) originalConsoleError("Failed to send error to Vite server:", err);
|
|
503
521
|
}
|
|
504
|
-
}
|
|
522
|
+
}
|
|
505
523
|
}
|
|
524
|
+
const originalConsoleError = console.error;
|
|
506
525
|
for (const level of options.logLevels) {
|
|
507
526
|
const original = console[level];
|
|
508
527
|
if (typeof original !== "function") continue;
|
|
@@ -512,11 +531,20 @@ function setupForwardConsoleHandler(transport, options) {
|
|
|
512
531
|
};
|
|
513
532
|
}
|
|
514
533
|
if (options.unhandledErrors && typeof window !== "undefined") {
|
|
515
|
-
window.addEventListener("error", (event) => {
|
|
516
|
-
|
|
534
|
+
window.addEventListener("error", async (event) => {
|
|
535
|
+
const error = event.error ?? (event.message ? new Error(event.message) : event);
|
|
536
|
+
try {
|
|
537
|
+
await sendError("error", error);
|
|
538
|
+
} catch (err) {
|
|
539
|
+
if (!(err instanceof SendBeforeConnectError)) originalConsoleError("Failed to send error to Vite server:", err);
|
|
540
|
+
}
|
|
517
541
|
});
|
|
518
|
-
window.addEventListener("unhandledrejection", (event) => {
|
|
519
|
-
|
|
542
|
+
window.addEventListener("unhandledrejection", async (event) => {
|
|
543
|
+
try {
|
|
544
|
+
await sendError("unhandled-rejection", event.reason);
|
|
545
|
+
} catch (err) {
|
|
546
|
+
if (!(err instanceof SendBeforeConnectError)) originalConsoleError("Failed to send error to Vite server:", err);
|
|
547
|
+
}
|
|
520
548
|
});
|
|
521
549
|
}
|
|
522
550
|
}
|
|
@@ -672,7 +700,7 @@ pre.frame {
|
|
|
672
700
|
|
|
673
701
|
.message {
|
|
674
702
|
line-height: 1.3;
|
|
675
|
-
font-weight:
|
|
703
|
+
font-weight: 400;
|
|
676
704
|
white-space: pre-wrap;
|
|
677
705
|
}
|
|
678
706
|
|
|
@@ -834,7 +862,6 @@ const directSocketHost = __HMR_DIRECT_TARGET__;
|
|
|
834
862
|
const base = __BASE__ || "/";
|
|
835
863
|
const hmrTimeout = __HMR_TIMEOUT__;
|
|
836
864
|
const wsToken = __WS_TOKEN__;
|
|
837
|
-
const isBundleMode = __BUNDLED_DEV__;
|
|
838
865
|
const forwardConsole = __SERVER_FORWARD_CONSOLE__;
|
|
839
866
|
const transport = normalizeModuleRunnerTransport((() => {
|
|
840
867
|
let wsTransport = createWebSocketModuleRunnerTransport({
|
|
@@ -904,14 +931,7 @@ const pageReload = debounceReload(20);
|
|
|
904
931
|
const hmrClient = new HMRClient({
|
|
905
932
|
error: (err) => console.error("[vite]", err),
|
|
906
933
|
debug: (...msg) => console.debug("[vite]", ...msg)
|
|
907
|
-
}, transport,
|
|
908
|
-
const importPromise = import(base + url).then(() => globalThis.__rolldown_runtime__.loadExports(acceptedPath));
|
|
909
|
-
if (isWithinCircularImport) importPromise.catch(() => {
|
|
910
|
-
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.`);
|
|
911
|
-
pageReload();
|
|
912
|
-
});
|
|
913
|
-
return await importPromise;
|
|
914
|
-
} : async function importUpdatedModule({ acceptedPath, timestamp, explicitImportRequired, isWithinCircularImport }) {
|
|
934
|
+
}, transport, async function importUpdatedModule({ acceptedPath, timestamp, explicitImportRequired, isWithinCircularImport }) {
|
|
915
935
|
const [acceptedPathWithoutQuery, query] = acceptedPath.split(`?`);
|
|
916
936
|
const importPromise = import(
|
|
917
937
|
/* @vite-ignore */
|
|
@@ -923,22 +943,32 @@ const hmrClient = new HMRClient({
|
|
|
923
943
|
});
|
|
924
944
|
return await importPromise;
|
|
925
945
|
});
|
|
946
|
+
let bundledDevClient;
|
|
926
947
|
transport.connect(createHMRHandler(handleMessage));
|
|
927
948
|
setupForwardConsoleHandler(transport, forwardConsole);
|
|
949
|
+
function clearOverlayOrReloadOnFirstUpdate() {
|
|
950
|
+
if (hasDocument) {
|
|
951
|
+
if (isFirstUpdate && hasErrorOverlay()) {
|
|
952
|
+
location.reload();
|
|
953
|
+
return "reload";
|
|
954
|
+
}
|
|
955
|
+
if (enableOverlay) clearErrorOverlay();
|
|
956
|
+
isFirstUpdate = false;
|
|
957
|
+
}
|
|
958
|
+
return "continue";
|
|
959
|
+
}
|
|
928
960
|
async function handleMessage(payload) {
|
|
961
|
+
const activeHmrClient = hmrClient;
|
|
929
962
|
switch (payload.type) {
|
|
930
963
|
case "connected":
|
|
931
964
|
console.debug(`[vite] connected.`);
|
|
932
965
|
break;
|
|
966
|
+
case "bundled-dev-update":
|
|
967
|
+
bundledDevClient.handlePush(payload);
|
|
968
|
+
break;
|
|
933
969
|
case "update":
|
|
934
|
-
await
|
|
935
|
-
if (
|
|
936
|
-
location.reload();
|
|
937
|
-
return;
|
|
938
|
-
} else {
|
|
939
|
-
if (enableOverlay) clearErrorOverlay();
|
|
940
|
-
isFirstUpdate = false;
|
|
941
|
-
}
|
|
970
|
+
await activeHmrClient.notifyListeners("vite:beforeUpdate", payload);
|
|
971
|
+
if (clearOverlayOrReloadOnFirstUpdate() === "reload") return;
|
|
942
972
|
await Promise.all(payload.updates.map(async (update) => {
|
|
943
973
|
if (update.type === "js-update") return hmrClient.queueUpdate(update);
|
|
944
974
|
const { path, timestamp } = update;
|
|
@@ -960,10 +990,10 @@ async function handleMessage(payload) {
|
|
|
960
990
|
el.after(newLinkTag);
|
|
961
991
|
});
|
|
962
992
|
}));
|
|
963
|
-
await
|
|
993
|
+
await activeHmrClient.notifyListeners("vite:afterUpdate", payload);
|
|
964
994
|
break;
|
|
965
995
|
case "custom":
|
|
966
|
-
await
|
|
996
|
+
await activeHmrClient.notifyListeners(payload.event, payload.data);
|
|
967
997
|
if (payload.event === "vite:ws:disconnect") {
|
|
968
998
|
if (hasDocument && !willUnload) {
|
|
969
999
|
console.log(`[vite] server connection lost. Polling for restart...`);
|
|
@@ -976,7 +1006,8 @@ async function handleMessage(payload) {
|
|
|
976
1006
|
}
|
|
977
1007
|
break;
|
|
978
1008
|
case "full-reload":
|
|
979
|
-
|
|
1009
|
+
if (payload.ifFallback && !globalThis.__vite_is_fallback_page__) break;
|
|
1010
|
+
await activeHmrClient.notifyListeners("vite:beforeFullReload", payload);
|
|
980
1011
|
if (hasDocument) if (payload.path && payload.path.endsWith(".html")) {
|
|
981
1012
|
const pagePath = decodeURI(location.pathname);
|
|
982
1013
|
const payloadPath = base + payload.path.slice(1);
|
|
@@ -985,11 +1016,11 @@ async function handleMessage(payload) {
|
|
|
985
1016
|
} else pageReload();
|
|
986
1017
|
break;
|
|
987
1018
|
case "prune":
|
|
988
|
-
await
|
|
989
|
-
await
|
|
1019
|
+
await activeHmrClient.notifyListeners("vite:beforePrune", payload);
|
|
1020
|
+
await activeHmrClient.prunePaths(payload.paths);
|
|
990
1021
|
break;
|
|
991
1022
|
case "error":
|
|
992
|
-
await
|
|
1023
|
+
await activeHmrClient.notifyListeners("vite:error", payload);
|
|
993
1024
|
if (hasDocument) {
|
|
994
1025
|
const err = payload.err;
|
|
995
1026
|
if (enableOverlay) createErrorOverlay(err);
|
|
@@ -1182,9 +1213,7 @@ function updateStyle(id, content) {
|
|
|
1182
1213
|
}
|
|
1183
1214
|
function removeStyle(id) {
|
|
1184
1215
|
if (linkSheetsMap.has(id)) {
|
|
1185
|
-
document.querySelectorAll(`link[rel="stylesheet"][data-vite-dev-id]`).forEach((el) =>
|
|
1186
|
-
if (el.getAttribute("data-vite-dev-id") === id) el.remove();
|
|
1187
|
-
});
|
|
1216
|
+
document.querySelectorAll(`link[rel="stylesheet"][data-vite-dev-id="${CSS.escape(id)}"]`).forEach((el) => el.remove());
|
|
1188
1217
|
linkSheetsMap.delete(id);
|
|
1189
1218
|
}
|
|
1190
1219
|
const style = sheetsMap.get(id);
|
|
@@ -1205,31 +1234,5 @@ function injectQuery(url, queryToInject) {
|
|
|
1205
1234
|
const { search, hash } = new URL(url, "http://vite.dev");
|
|
1206
1235
|
return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ""}${hash || ""}`;
|
|
1207
1236
|
}
|
|
1208
|
-
if (isBundleMode && typeof DevRuntime !== "undefined") {
|
|
1209
|
-
var _ref;
|
|
1210
|
-
class ViteDevRuntime extends DevRuntime {
|
|
1211
|
-
createModuleHotContext(moduleId) {
|
|
1212
|
-
const ctx = createHotContext(moduleId);
|
|
1213
|
-
ctx._internal = {
|
|
1214
|
-
updateStyle,
|
|
1215
|
-
removeStyle
|
|
1216
|
-
};
|
|
1217
|
-
return ctx;
|
|
1218
|
-
}
|
|
1219
|
-
applyUpdates(_boundaries) {}
|
|
1220
|
-
}
|
|
1221
|
-
(_ref = globalThis).__rolldown_runtime__ ?? (_ref.__rolldown_runtime__ = new ViteDevRuntime({ send(message) {
|
|
1222
|
-
switch (message.type) {
|
|
1223
|
-
case "hmr:module-registered":
|
|
1224
|
-
transport.send({
|
|
1225
|
-
type: "custom",
|
|
1226
|
-
event: "vite:module-loaded",
|
|
1227
|
-
data: { modules: message.modules.slice() }
|
|
1228
|
-
});
|
|
1229
|
-
break;
|
|
1230
|
-
default: throw new Error(`Unknown message type: ${JSON.stringify(message)}`);
|
|
1231
|
-
}
|
|
1232
|
-
} }));
|
|
1233
|
-
}
|
|
1234
1237
|
//#endregion
|
|
1235
1238
|
export { ErrorOverlay, createHotContext, injectQuery, removeStyle, updateStyle };
|