vite 6.3.0-beta.0 → 6.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 CHANGED
@@ -1056,21 +1056,6 @@ Repository: git://github.com/primus/eventemitter3.git
1056
1056
 
1057
1057
  ---------------------------------------
1058
1058
 
1059
- ## fdir
1060
- License: MIT
1061
- By: thecodrr
1062
- Repository: git+https://github.com/thecodrr/fdir.git
1063
-
1064
- > Copyright 2023 Abdullah Atta
1065
- >
1066
- > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1067
- >
1068
- > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1069
- >
1070
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1071
-
1072
- ---------------------------------------
1073
-
1074
1059
  ## finalhandler
1075
1060
  License: MIT
1076
1061
  By: Douglas Christopher Wilson
@@ -160,7 +160,7 @@ class HMRClient {
160
160
  });
161
161
  }
162
162
  warnFailedUpdate(err, path) {
163
- if (!err.message.includes("fetch")) {
163
+ if (!(err instanceof Error) || !err.message.includes("fetch")) {
164
164
  this.logger.error(err);
165
165
  }
166
166
  this.logger.error(
@@ -475,6 +475,42 @@ const createWebSocketModuleRunnerTransport = (options) => {
475
475
  };
476
476
  };
477
477
 
478
+ function createHMRHandler(handler) {
479
+ const queue = new Queue();
480
+ return (payload) => queue.enqueue(() => handler(payload));
481
+ }
482
+ class Queue {
483
+ constructor() {
484
+ this.queue = [];
485
+ this.pending = false;
486
+ }
487
+ enqueue(promise) {
488
+ return new Promise((resolve, reject) => {
489
+ this.queue.push({
490
+ promise,
491
+ resolve,
492
+ reject
493
+ });
494
+ this.dequeue();
495
+ });
496
+ }
497
+ dequeue() {
498
+ if (this.pending) {
499
+ return false;
500
+ }
501
+ const item = this.queue.shift();
502
+ if (!item) {
503
+ return false;
504
+ }
505
+ this.pending = true;
506
+ item.promise().then(item.resolve).catch(item.reject).finally(() => {
507
+ this.pending = false;
508
+ this.dequeue();
509
+ });
510
+ return true;
511
+ }
512
+ }
513
+
478
514
  const hmrConfigName = __HMR_CONFIG_NAME__;
479
515
  const base$1 = __BASE__ || "/";
480
516
  function h(e, attrs = {}, ...children) {
@@ -859,14 +895,14 @@ const hmrClient = new HMRClient(
859
895
  return await importPromise;
860
896
  }
861
897
  );
862
- transport.connect(handleMessage);
898
+ transport.connect(createHMRHandler(handleMessage));
863
899
  async function handleMessage(payload) {
864
900
  switch (payload.type) {
865
901
  case "connected":
866
902
  console.debug(`[vite] connected.`);
867
903
  break;
868
904
  case "update":
869
- notifyListeners("vite:beforeUpdate", payload);
905
+ await hmrClient.notifyListeners("vite:beforeUpdate", payload);
870
906
  if (hasDocument) {
871
907
  if (isFirstUpdate && hasErrorOverlay()) {
872
908
  location.reload();
@@ -909,10 +945,10 @@ async function handleMessage(payload) {
909
945
  });
910
946
  })
911
947
  );
912
- notifyListeners("vite:afterUpdate", payload);
948
+ await hmrClient.notifyListeners("vite:afterUpdate", payload);
913
949
  break;
914
950
  case "custom": {
915
- notifyListeners(payload.event, payload.data);
951
+ await hmrClient.notifyListeners(payload.event, payload.data);
916
952
  if (payload.event === "vite:ws:disconnect") {
917
953
  if (hasDocument && !willUnload) {
918
954
  console.log(`[vite] server connection lost. Polling for restart...`);
@@ -926,7 +962,7 @@ async function handleMessage(payload) {
926
962
  break;
927
963
  }
928
964
  case "full-reload":
929
- notifyListeners("vite:beforeFullReload", payload);
965
+ await hmrClient.notifyListeners("vite:beforeFullReload", payload);
930
966
  if (hasDocument) {
931
967
  if (payload.path && payload.path.endsWith(".html")) {
932
968
  const pagePath = decodeURI(location.pathname);
@@ -941,11 +977,11 @@ async function handleMessage(payload) {
941
977
  }
942
978
  break;
943
979
  case "prune":
944
- notifyListeners("vite:beforePrune", payload);
980
+ await hmrClient.notifyListeners("vite:beforePrune", payload);
945
981
  await hmrClient.prunePaths(payload.paths);
946
982
  break;
947
983
  case "error": {
948
- notifyListeners("vite:error", payload);
984
+ await hmrClient.notifyListeners("vite:error", payload);
949
985
  if (hasDocument) {
950
986
  const err = payload.err;
951
987
  if (enableOverlay) {
@@ -968,9 +1004,6 @@ ${err.stack}`
968
1004
  }
969
1005
  }
970
1006
  }
971
- function notifyListeners(event, data) {
972
- hmrClient.notifyListeners(event, data);
973
- }
974
1007
  const enableOverlay = __HMR_ENABLE_OVERLAY__;
975
1008
  const hasDocument = "document" in globalThis;
976
1009
  function createErrorOverlay(err) {
@@ -1,4 +1,4 @@
1
- import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-Bt1yO2CH.js';
1
+ import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-jcjTW_IO.js';
2
2
  import require$$0$2 from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -1,4 +1,4 @@
1
- import { P as getDefaultExportFromCjs } from './dep-Bt1yO2CH.js';
1
+ import { P as getDefaultExportFromCjs } from './dep-jcjTW_IO.js';
2
2
  import require$$0 from 'path';
3
3
  import { l as lib } from './dep-3RmXg9uo.js';
4
4