miaoda-react-devkit 0.1.1-beta.19 → 0.1.1-beta.20

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.
@@ -37,7 +37,7 @@ __export(vite_exports, {
37
37
  });
38
38
  module.exports = __toCommonJS(vite_exports);
39
39
 
40
- // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.26_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js
40
+ // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js
41
41
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
42
42
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
43
43
 
@@ -86,14 +86,29 @@ function hmrTogglePlugin() {
86
86
  name: "miaoda-devkit:hmr-toggle",
87
87
  configureServer(server) {
88
88
  let hmrEnabled = true;
89
+ let pendingFullReload = false;
89
90
  const origSend = server.ws.send.bind(server.ws);
91
+ const flushPendingFullReload = () => {
92
+ if (!hmrEnabled || !pendingFullReload) {
93
+ return;
94
+ }
95
+ if (server.ws.clients.size === 0) {
96
+ return;
97
+ }
98
+ pendingFullReload = false;
99
+ origSend({ type: "full-reload", path: "*" });
100
+ };
90
101
  server.ws.send = (payload) => {
91
102
  if (hmrEnabled) {
92
103
  origSend(payload);
93
104
  } else {
105
+ if (payload.type === "full-reload") {
106
+ pendingFullReload = true;
107
+ }
94
108
  console.log("[HMR disabled] skipped payload:", payload.type);
95
109
  }
96
110
  };
111
+ server.ws.on?.("connection", flushPendingFullReload);
97
112
  server.middlewares.use("/innerapi/v1/sourcecode/__hmr_off", (_req, res) => {
98
113
  hmrEnabled = false;
99
114
  res.setHeader("Content-Type", "application/json");
@@ -101,12 +116,15 @@ function hmrTogglePlugin() {
101
116
  });
102
117
  server.middlewares.use("/innerapi/v1/sourcecode/__hmr_on", (_req, res) => {
103
118
  hmrEnabled = true;
119
+ flushPendingFullReload();
104
120
  res.setHeader("Content-Type", "application/json");
105
121
  res.end(JSON.stringify({ status: 0, msg: "HMR enabled" }));
106
122
  });
107
123
  server.middlewares.use("/innerapi/v1/sourcecode/__hmr_reload", (_req, res) => {
108
124
  if (hmrEnabled) {
109
125
  server.ws.send({ type: "full-reload", path: "*" });
126
+ } else {
127
+ pendingFullReload = true;
110
128
  }
111
129
  res.setHeader("Content-Type", "application/json");
112
130
  res.end(JSON.stringify({ status: 0, msg: "Manual full reload triggered" }));
@@ -43,14 +43,29 @@ function hmrTogglePlugin() {
43
43
  name: "miaoda-devkit:hmr-toggle",
44
44
  configureServer(server) {
45
45
  let hmrEnabled = true;
46
+ let pendingFullReload = false;
46
47
  const origSend = server.ws.send.bind(server.ws);
48
+ const flushPendingFullReload = () => {
49
+ if (!hmrEnabled || !pendingFullReload) {
50
+ return;
51
+ }
52
+ if (server.ws.clients.size === 0) {
53
+ return;
54
+ }
55
+ pendingFullReload = false;
56
+ origSend({ type: "full-reload", path: "*" });
57
+ };
47
58
  server.ws.send = (payload) => {
48
59
  if (hmrEnabled) {
49
60
  origSend(payload);
50
61
  } else {
62
+ if (payload.type === "full-reload") {
63
+ pendingFullReload = true;
64
+ }
51
65
  console.log("[HMR disabled] skipped payload:", payload.type);
52
66
  }
53
67
  };
68
+ server.ws.on?.("connection", flushPendingFullReload);
54
69
  server.middlewares.use("/innerapi/v1/sourcecode/__hmr_off", (_req, res) => {
55
70
  hmrEnabled = false;
56
71
  res.setHeader("Content-Type", "application/json");
@@ -58,12 +73,15 @@ function hmrTogglePlugin() {
58
73
  });
59
74
  server.middlewares.use("/innerapi/v1/sourcecode/__hmr_on", (_req, res) => {
60
75
  hmrEnabled = true;
76
+ flushPendingFullReload();
61
77
  res.setHeader("Content-Type", "application/json");
62
78
  res.end(JSON.stringify({ status: 0, msg: "HMR enabled" }));
63
79
  });
64
80
  server.middlewares.use("/innerapi/v1/sourcecode/__hmr_reload", (_req, res) => {
65
81
  if (hmrEnabled) {
66
82
  server.ws.send({ type: "full-reload", path: "*" });
83
+ } else {
84
+ pendingFullReload = true;
67
85
  }
68
86
  res.setHeader("Content-Type", "application/json");
69
87
  res.end(JSON.stringify({ status: 0, msg: "Manual full reload triggered" }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-react-devkit",
3
- "version": "0.1.1-beta.19",
3
+ "version": "0.1.1-beta.20",
4
4
  "description": "React admin 应用开发工具集",
5
5
  "license": "MIT",
6
6
  "type": "module",