@meituan-nocode/vite-plugin-nocode-compiler 0.2.4-beta.15 → 0.2.4-beta.16

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