@meituan-nocode/vite-plugin-nocode-compiler 0.2.4-beta.7 → 0.2.4-beta.8

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/dist/index.cjs CHANGED
@@ -46,6 +46,9 @@ function readJsonBody(req) {
46
46
  });
47
47
  }
48
48
 
49
+ // package.json
50
+ var version = "0.2.4-beta.8";
51
+
49
52
  // src/index.ts
50
53
  var overrideMap = /* @__PURE__ */ new Map();
51
54
  function resolveFileToAbsPath(file, viteRoot) {
@@ -71,8 +74,18 @@ function resolveFileToAbsPath(file, viteRoot) {
71
74
  function componentCompiler(options = {}) {
72
75
  options = {
73
76
  enableLogging: false,
77
+ enableReporting: true,
74
78
  ...options
75
79
  };
80
+ if (options.enableReporting) {
81
+ console.log("[vite compiler] init");
82
+ (0, import_nocode_compiler_core.initReporter)({
83
+ appName: options.reporterAppName || "nocode-compiler-plugin",
84
+ enabled: true,
85
+ framework: "vite",
86
+ pluginVersion: version
87
+ });
88
+ }
76
89
  const vueCompiler = new import_nocode_compiler_core.VueCompiler(options);
77
90
  const jsxCompiler = new import_nocode_compiler_core.JSXCompiler(options);
78
91
  let server;
@@ -94,6 +107,8 @@ function componentCompiler(options = {}) {
94
107
  server = _server;
95
108
  server.ws.on("connection", () => {
96
109
  if (overrideMap.size === 0) return;
110
+ const reporter = (0, import_nocode_compiler_core.getReporter)();
111
+ const overrideCount = overrideMap.size;
97
112
  for (const filePath of overrideMap.keys()) {
98
113
  const mods = server.moduleGraph.getModulesByFile(filePath);
99
114
  if (mods && mods.size > 0) {
@@ -103,11 +118,16 @@ function componentCompiler(options = {}) {
103
118
  }
104
119
  }
105
120
  overrideMap.clear();
121
+ reporter == null ? void 0 : reporter.reportOverride({
122
+ action: "clear",
123
+ overrideCount
124
+ });
106
125
  });
107
126
  server.middlewares.use("/__nocode_file_override", async (req, res, next) => {
108
127
  if (req.method !== "POST") {
109
128
  return next();
110
129
  }
130
+ const reporter = (0, import_nocode_compiler_core.getReporter)();
111
131
  try {
112
132
  const { file, code } = await readJsonBody(req);
113
133
  if (!file || typeof code !== "string") {
@@ -120,6 +140,10 @@ function componentCompiler(options = {}) {
120
140
  console.warn("[nocode-compiler] file not found:", file, server.config.root);
121
141
  res.statusCode = 404;
122
142
  res.end(JSON.stringify({ error: "file not found" }));
143
+ reporter == null ? void 0 : reporter.reportOverride({
144
+ action: "notfound",
145
+ filePath: file
146
+ });
123
147
  return;
124
148
  }
125
149
  overrideMap.set(absolutePath, code);
@@ -140,9 +164,18 @@ function componentCompiler(options = {}) {
140
164
  });
141
165
  }
142
166
  }
167
+ reporter == null ? void 0 : reporter.reportOverride({
168
+ action: "set",
169
+ filePath: absolutePath,
170
+ overrideCount: overrideMap.size
171
+ });
143
172
  res.statusCode = 200;
144
173
  res.end(JSON.stringify({ success: true }));
145
174
  } catch (error) {
175
+ reporter == null ? void 0 : reporter.reportOverride({
176
+ action: "error",
177
+ error: error instanceof Error ? error : new Error(String(error))
178
+ });
146
179
  res.statusCode = 500;
147
180
  res.end(JSON.stringify({ error: String(error) }));
148
181
  }
package/dist/index.d.cts CHANGED
@@ -1,8 +1,14 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
3
  interface NocodeCompilerOptions {
4
+ /** 是否启用日志 */
4
5
  enableLogging?: boolean;
6
+ /** 项目根目录 */
5
7
  rootPath?: string;
8
+ /** 是否启用埋点上报,默认 true */
9
+ enableReporting?: boolean;
10
+ /** 自定义 Cat appName */
11
+ reporterAppName?: string;
6
12
  }
7
13
  declare function componentCompiler(options?: NocodeCompilerOptions): Plugin;
8
14
 
package/dist/index.d.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
3
  interface NocodeCompilerOptions {
4
+ /** 是否启用日志 */
4
5
  enableLogging?: boolean;
6
+ /** 项目根目录 */
5
7
  rootPath?: string;
8
+ /** 是否启用埋点上报,默认 true */
9
+ enableReporting?: boolean;
10
+ /** 自定义 Cat appName */
11
+ reporterAppName?: string;
6
12
  }
7
13
  declare function componentCompiler(options?: NocodeCompilerOptions): Plugin;
8
14
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/index.ts
2
2
  import { normalize, dirname, isAbsolute, join } from "path";
3
3
  import { existsSync } from "fs";
4
- import { JSXCompiler, VueCompiler, detectCompileScenario, PackageVersionRegistry } from "@meituan-nocode/nocode-compiler-core";
4
+ import { JSXCompiler, VueCompiler, detectCompileScenario, PackageVersionRegistry, initReporter, getReporter } from "@meituan-nocode/nocode-compiler-core";
5
5
 
6
6
  // src/utils.ts
7
7
  function readJsonBody(req) {
@@ -21,6 +21,9 @@ function readJsonBody(req) {
21
21
  });
22
22
  }
23
23
 
24
+ // package.json
25
+ var version = "0.2.4-beta.8";
26
+
24
27
  // src/index.ts
25
28
  var overrideMap = /* @__PURE__ */ new Map();
26
29
  function resolveFileToAbsPath(file, viteRoot) {
@@ -46,8 +49,18 @@ function resolveFileToAbsPath(file, viteRoot) {
46
49
  function componentCompiler(options = {}) {
47
50
  options = {
48
51
  enableLogging: false,
52
+ enableReporting: true,
49
53
  ...options
50
54
  };
55
+ if (options.enableReporting) {
56
+ console.log("[vite compiler] init");
57
+ initReporter({
58
+ appName: options.reporterAppName || "nocode-compiler-plugin",
59
+ enabled: true,
60
+ framework: "vite",
61
+ pluginVersion: version
62
+ });
63
+ }
51
64
  const vueCompiler = new VueCompiler(options);
52
65
  const jsxCompiler = new JSXCompiler(options);
53
66
  let server;
@@ -69,6 +82,8 @@ function componentCompiler(options = {}) {
69
82
  server = _server;
70
83
  server.ws.on("connection", () => {
71
84
  if (overrideMap.size === 0) return;
85
+ const reporter = getReporter();
86
+ const overrideCount = overrideMap.size;
72
87
  for (const filePath of overrideMap.keys()) {
73
88
  const mods = server.moduleGraph.getModulesByFile(filePath);
74
89
  if (mods && mods.size > 0) {
@@ -78,11 +93,16 @@ function componentCompiler(options = {}) {
78
93
  }
79
94
  }
80
95
  overrideMap.clear();
96
+ reporter == null ? void 0 : reporter.reportOverride({
97
+ action: "clear",
98
+ overrideCount
99
+ });
81
100
  });
82
101
  server.middlewares.use("/__nocode_file_override", async (req, res, next) => {
83
102
  if (req.method !== "POST") {
84
103
  return next();
85
104
  }
105
+ const reporter = getReporter();
86
106
  try {
87
107
  const { file, code } = await readJsonBody(req);
88
108
  if (!file || typeof code !== "string") {
@@ -95,6 +115,10 @@ function componentCompiler(options = {}) {
95
115
  console.warn("[nocode-compiler] file not found:", file, server.config.root);
96
116
  res.statusCode = 404;
97
117
  res.end(JSON.stringify({ error: "file not found" }));
118
+ reporter == null ? void 0 : reporter.reportOverride({
119
+ action: "notfound",
120
+ filePath: file
121
+ });
98
122
  return;
99
123
  }
100
124
  overrideMap.set(absolutePath, code);
@@ -115,9 +139,18 @@ function componentCompiler(options = {}) {
115
139
  });
116
140
  }
117
141
  }
142
+ reporter == null ? void 0 : reporter.reportOverride({
143
+ action: "set",
144
+ filePath: absolutePath,
145
+ overrideCount: overrideMap.size
146
+ });
118
147
  res.statusCode = 200;
119
148
  res.end(JSON.stringify({ success: true }));
120
149
  } catch (error) {
150
+ reporter == null ? void 0 : reporter.reportOverride({
151
+ action: "error",
152
+ error: error instanceof Error ? error : new Error(String(error))
153
+ });
121
154
  res.statusCode = 500;
122
155
  res.end(JSON.stringify({ error: String(error) }));
123
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meituan-nocode/vite-plugin-nocode-compiler",
3
- "version": "0.2.4-beta.7",
3
+ "version": "0.2.4-beta.8",
4
4
  "description": "Vite plugin for nocode compiler",
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,7 +23,7 @@
23
23
  "tsup": "8.5.0"
24
24
  },
25
25
  "dependencies": {
26
- "@meituan-nocode/nocode-compiler-core": "0.2.5-beta.1"
26
+ "@meituan-nocode/nocode-compiler-core": "0.2.5-beta.2"
27
27
  },
28
28
  "scripts": {
29
29
  "dev": "tsup --watch",