miaoda-react-devkit 0.1.1-beta.0 → 0.1.1-beta.1

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.
@@ -18,7 +18,66 @@ function withSentryStub() {
18
18
  }
19
19
  };
20
20
  }
21
+
22
+ // src/vite/hmrTogglePlugin.ts
23
+ function hmrTogglePlugin() {
24
+ return {
25
+ name: "miaoda-devkit:hmr-toggle",
26
+ configureServer(server) {
27
+ let hmrEnabled = true;
28
+ const origSend = server.ws.send.bind(server.ws);
29
+ server.ws.send = (payload) => {
30
+ if (hmrEnabled) {
31
+ origSend(payload);
32
+ } else {
33
+ console.log("[HMR disabled] skipped payload:", payload.type);
34
+ }
35
+ };
36
+ server.middlewares.use("/innerapi/v1/sourcecode/__hmr_off", (_req, res) => {
37
+ hmrEnabled = false;
38
+ res.setHeader("Content-Type", "application/json");
39
+ res.end(JSON.stringify({ status: 0, msg: "HMR disabled" }));
40
+ });
41
+ server.middlewares.use("/innerapi/v1/sourcecode/__hmr_on", (_req, res) => {
42
+ hmrEnabled = true;
43
+ res.setHeader("Content-Type", "application/json");
44
+ res.end(JSON.stringify({ status: 0, msg: "HMR enabled" }));
45
+ });
46
+ server.middlewares.use("/innerapi/v1/sourcecode/__hmr_reload", (_req, res) => {
47
+ if (hmrEnabled) {
48
+ server.ws.send({ type: "full-reload", path: "*" });
49
+ }
50
+ res.setHeader("Content-Type", "application/json");
51
+ res.end(JSON.stringify({ status: 0, msg: "Manual full reload triggered" }));
52
+ });
53
+ },
54
+ load(id) {
55
+ if (id === "virtual:after-update") {
56
+ return `
57
+ if (import.meta.hot) {
58
+ import.meta.hot.on('vite:afterUpdate', () => {
59
+ window.postMessage({ type: 'editor-update' }, '*');
60
+ });
61
+ }
62
+ `;
63
+ }
64
+ },
65
+ transformIndexHtml(html) {
66
+ return {
67
+ html,
68
+ tags: [
69
+ {
70
+ tag: "script",
71
+ attrs: { type: "module", src: "/@id/virtual:after-update" },
72
+ injectTo: "body"
73
+ }
74
+ ]
75
+ };
76
+ }
77
+ };
78
+ }
21
79
  export {
80
+ hmrTogglePlugin,
22
81
  withSentryStub
23
82
  };
24
83
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-react-devkit",
3
- "version": "0.1.1-beta.0",
3
+ "version": "0.1.1-beta.1",
4
4
  "description": "React admin 应用开发工具集",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,12 +22,14 @@
22
22
  },
23
23
  "files": [
24
24
  "dist",
25
+ "cloud",
25
26
  "tsconfig-base.json",
26
27
  "!dist/**/*.map"
27
28
  ],
28
29
  "peerDependencies": {
29
30
  "@sentry/core": ">=8.0.0",
30
31
  "@sentry/react": ">=8.0.0",
32
+ "miaoda-sc-plugin": ">=1.0.0",
31
33
  "vite": ">=5.0.0"
32
34
  },
33
35
  "peerDependenciesMeta": {
@@ -37,6 +39,9 @@
37
39
  "@sentry/react": {
38
40
  "optional": true
39
41
  },
42
+ "miaoda-sc-plugin": {
43
+ "optional": true
44
+ },
40
45
  "vite": {
41
46
  "optional": true
42
47
  }