vite 8.0.0-beta.7 → 8.0.0-beta.9

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.
@@ -1,17 +1,17 @@
1
1
  import "@vite/env";
2
2
 
3
- //#region \0@oxc-project+runtime@0.107.0/helpers/typeof.js
3
+ //#region \0@oxc-project+runtime@0.110.0/helpers/typeof.js
4
4
  function _typeof(o) {
5
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;
6
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
7
+ return typeof o;
8
+ } : function(o) {
9
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
10
10
  }, _typeof(o);
11
11
  }
12
12
 
13
13
  //#endregion
14
- //#region \0@oxc-project+runtime@0.107.0/helpers/toPrimitive.js
14
+ //#region \0@oxc-project+runtime@0.110.0/helpers/toPrimitive.js
15
15
  function toPrimitive(t, r) {
16
16
  if ("object" != _typeof(t) || !t) return t;
17
17
  var e = t[Symbol.toPrimitive];
@@ -24,14 +24,14 @@ function toPrimitive(t, r) {
24
24
  }
25
25
 
26
26
  //#endregion
27
- //#region \0@oxc-project+runtime@0.107.0/helpers/toPropertyKey.js
27
+ //#region \0@oxc-project+runtime@0.110.0/helpers/toPropertyKey.js
28
28
  function toPropertyKey(t) {
29
29
  var i = toPrimitive(t, "string");
30
30
  return "symbol" == _typeof(i) ? i : i + "";
31
31
  }
32
32
 
33
33
  //#endregion
34
- //#region \0@oxc-project+runtime@0.107.0/helpers/defineProperty.js
34
+ //#region \0@oxc-project+runtime@0.110.0/helpers/defineProperty.js
35
35
  function _defineProperty(e, r, t) {
36
36
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
37
37
  value: t,
@@ -44,20 +44,20 @@ function _defineProperty(e, r, t) {
44
44
  //#endregion
45
45
  //#region src/shared/hmr.ts
46
46
  var HMRContext = class {
47
- constructor(hmrClient$1, ownerPath) {
48
- this.hmrClient = hmrClient$1;
47
+ constructor(hmrClient, ownerPath) {
48
+ this.hmrClient = hmrClient;
49
49
  this.ownerPath = ownerPath;
50
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);
51
+ if (!hmrClient.dataMap.has(ownerPath)) hmrClient.dataMap.set(ownerPath, {});
52
+ const mod = hmrClient.hotModulesMap.get(ownerPath);
53
53
  if (mod) mod.callbacks = [];
54
- const staleListeners = hmrClient$1.ctxToListenersMap.get(ownerPath);
54
+ const staleListeners = hmrClient.ctxToListenersMap.get(ownerPath);
55
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)));
56
+ const listeners = hmrClient.customListenersMap.get(event);
57
+ if (listeners) hmrClient.customListenersMap.set(event, listeners.filter((l) => !staleFns.includes(l)));
58
58
  }
59
59
  this.newListeners = /* @__PURE__ */ new Map();
60
- hmrClient$1.ctxToListenersMap.set(ownerPath, this.newListeners);
60
+ hmrClient.ctxToListenersMap.set(ownerPath, this.newListeners);
61
61
  }
62
62
  get data() {
63
63
  return this.hmrClient.dataMap.get(this.ownerPath);
@@ -135,9 +135,9 @@ var HMRContext = class {
135
135
  }
136
136
  };
137
137
  var HMRClient = class {
138
- constructor(logger, transport$1, importUpdatedModule) {
138
+ constructor(logger, transport, importUpdatedModule) {
139
139
  this.logger = logger;
140
- this.transport = transport$1;
140
+ this.transport = transport;
141
141
  this.importUpdatedModule = importUpdatedModule;
142
142
  _defineProperty(this, "hotModulesMap", /* @__PURE__ */ new Map());
143
143
  _defineProperty(this, "disposeMap", /* @__PURE__ */ new Map());
@@ -264,11 +264,11 @@ function reviveInvokeError(e) {
264
264
  Object.assign(error, e, { runnerError: /* @__PURE__ */ new Error("RunnerError") });
265
265
  return error;
266
266
  }
267
- const createInvokeableTransport = (transport$1) => {
268
- if (transport$1.invoke) return {
269
- ...transport$1,
267
+ const createInvokeableTransport = (transport) => {
268
+ if (transport.invoke) return {
269
+ ...transport,
270
270
  async invoke(name, data) {
271
- const result = await transport$1.invoke({
271
+ const result = await transport.invoke({
272
272
  type: "custom",
273
273
  event: "vite:invoke",
274
274
  data: {
@@ -281,12 +281,12 @@ const createInvokeableTransport = (transport$1) => {
281
281
  return result.result;
282
282
  }
283
283
  };
284
- if (!transport$1.send || !transport$1.connect) throw new Error("transport must implement send and connect when invoke is not implemented");
284
+ if (!transport.send || !transport.connect) throw new Error("transport must implement send and connect when invoke is not implemented");
285
285
  const rpcPromises = /* @__PURE__ */ new Map();
286
286
  return {
287
- ...transport$1,
287
+ ...transport,
288
288
  connect({ onMessage, onDisconnection }) {
289
- return transport$1.connect({
289
+ return transport.connect({
290
290
  onMessage(payload) {
291
291
  if (payload.type === "custom" && payload.event === "vite:invoke") {
292
292
  const data = payload.data;
@@ -312,10 +312,10 @@ const createInvokeableTransport = (transport$1) => {
312
312
  promise.reject(/* @__PURE__ */ new Error(`transport was disconnected, cannot call ${JSON.stringify(promise.name)}`));
313
313
  });
314
314
  rpcPromises.clear();
315
- return transport$1.disconnect?.();
315
+ return transport.disconnect?.();
316
316
  },
317
317
  send(data) {
318
- return transport$1.send(data);
318
+ return transport.send(data);
319
319
  },
320
320
  async invoke(name, data) {
321
321
  const promiseId = nanoid();
@@ -328,9 +328,9 @@ const createInvokeableTransport = (transport$1) => {
328
328
  data
329
329
  }
330
330
  };
331
- const sendPromise = transport$1.send(wrappedData);
331
+ const sendPromise = transport.send(wrappedData);
332
332
  const { promise, resolve, reject } = promiseWithResolvers();
333
- const timeout = transport$1.timeout ?? 6e4;
333
+ const timeout = transport.timeout ?? 6e4;
334
334
  let timeoutId;
335
335
  if (timeout > 0) {
336
336
  timeoutId = setTimeout(() => {
@@ -358,12 +358,12 @@ const createInvokeableTransport = (transport$1) => {
358
358
  }
359
359
  };
360
360
  };
361
- const normalizeModuleRunnerTransport = (transport$1) => {
362
- const invokeableTransport = createInvokeableTransport(transport$1);
361
+ const normalizeModuleRunnerTransport = (transport) => {
362
+ const invokeableTransport = createInvokeableTransport(transport);
363
363
  let isConnected = !invokeableTransport.connect;
364
364
  let connectingPromise;
365
365
  return {
366
- ...transport$1,
366
+ ...transport,
367
367
  ...invokeableTransport.connect ? { async connect(onMessage) {
368
368
  if (isConnected) return;
369
369
  if (connectingPromise) {
@@ -671,8 +671,6 @@ const { HTMLElement = class {} } = globalThis;
671
671
  var ErrorOverlay = class extends HTMLElement {
672
672
  constructor(err, links = true) {
673
673
  super();
674
- _defineProperty(this, "root", void 0);
675
- _defineProperty(this, "closeOnEsc", void 0);
676
674
  this.root = this.attachShadow({ mode: "open" });
677
675
  this.root.appendChild(createTemplate());
678
676
  codeframeRE.lastIndex = 0;
@@ -759,8 +757,8 @@ const transport = normalizeModuleRunnerTransport((() => {
759
757
  try {
760
758
  await wsTransport.connect(handlers);
761
759
  console.info("[vite] Direct websocket connection fallback. Check out https://vite.dev/config/server-options.html#server-hmr to remove the previous connection error.");
762
- } catch (e$1) {
763
- if (e$1 instanceof Error && e$1.message.includes("WebSocket closed without opened.")) {
760
+ } catch (e) {
761
+ if (e instanceof Error && e.message.includes("WebSocket closed without opened.")) {
764
762
  const currentScriptHostURL = new URL(import.meta.url);
765
763
  const currentScriptHost = currentScriptHostURL.host + currentScriptHostURL.pathname.replace(/@vite\/client$/, "");
766
764
  console.error(`[vite] failed to connect to websocket.
@@ -908,9 +906,9 @@ const enableOverlay = __HMR_ENABLE_OVERLAY__;
908
906
  const hasDocument = "document" in globalThis;
909
907
  function createErrorOverlay(err) {
910
908
  clearErrorOverlay();
911
- const { customElements: customElements$1 } = globalThis;
912
- if (customElements$1) {
913
- const ErrorOverlayConstructor = customElements$1.get(overlayId);
909
+ const { customElements } = globalThis;
910
+ if (customElements) {
911
+ const ErrorOverlayConstructor = customElements.get(overlayId);
914
912
  document.body.appendChild(new ErrorOverlayConstructor(err));
915
913
  }
916
914
  }
@@ -999,18 +997,18 @@ function pingWorkerContentMain(socketUrl) {
999
997
  type: "error",
1000
998
  error
1001
999
  });
1002
- } catch (error$1) {
1000
+ } catch (error) {
1003
1001
  port.postMessage({
1004
1002
  type: "error",
1005
- error: error$1
1003
+ error
1006
1004
  });
1007
1005
  }
1008
1006
  });
1009
1007
  });
1010
1008
  }
1011
1009
  async function waitForSuccessfulPingInternal(socketUrl, visibilityManager, ms = 1e3) {
1012
- function wait(ms$1) {
1013
- return new Promise((resolve) => setTimeout(resolve, ms$1));
1010
+ function wait(ms) {
1011
+ return new Promise((resolve) => setTimeout(resolve, ms));
1014
1012
  }
1015
1013
  async function ping() {
1016
1014
  try {
@@ -1036,15 +1034,15 @@ async function waitForSuccessfulPingInternal(socketUrl, visibilityManager, ms =
1036
1034
  return false;
1037
1035
  }
1038
1036
  }
1039
- function waitForWindowShow(visibilityManager$1) {
1037
+ function waitForWindowShow(visibilityManager) {
1040
1038
  return new Promise((resolve) => {
1041
1039
  const onChange = (newVisibility) => {
1042
1040
  if (newVisibility === "visible") {
1043
1041
  resolve();
1044
- visibilityManager$1.listeners.delete(onChange);
1042
+ visibilityManager.listeners.delete(onChange);
1045
1043
  }
1046
1044
  };
1047
- visibilityManager$1.listeners.add(onChange);
1045
+ visibilityManager.listeners.add(onChange);
1048
1046
  });
1049
1047
  }
1050
1048
  if (await ping()) return;