@meituan-nocode/vite-plugin-nocode-compiler 0.2.4-beta.8 → 0.2.4
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 +7 -31
- package/dist/index.d.cts +0 -6
- package/dist/index.d.ts +0 -6
- package/dist/index.js +8 -32
- package/package.json +2 -2
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
|
|
50
|
+
var version = "0.2.4";
|
|
51
51
|
|
|
52
52
|
// src/index.ts
|
|
53
53
|
var overrideMap = /* @__PURE__ */ new Map();
|
|
@@ -74,18 +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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
pluginVersion: version
|
|
87
|
-
});
|
|
88
|
-
}
|
|
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);
|
|
89
85
|
const vueCompiler = new import_nocode_compiler_core.VueCompiler(options);
|
|
90
86
|
const jsxCompiler = new import_nocode_compiler_core.JSXCompiler(options);
|
|
91
87
|
let server;
|
|
@@ -107,8 +103,6 @@ function componentCompiler(options = {}) {
|
|
|
107
103
|
server = _server;
|
|
108
104
|
server.ws.on("connection", () => {
|
|
109
105
|
if (overrideMap.size === 0) return;
|
|
110
|
-
const reporter = (0, import_nocode_compiler_core.getReporter)();
|
|
111
|
-
const overrideCount = overrideMap.size;
|
|
112
106
|
for (const filePath of overrideMap.keys()) {
|
|
113
107
|
const mods = server.moduleGraph.getModulesByFile(filePath);
|
|
114
108
|
if (mods && mods.size > 0) {
|
|
@@ -118,16 +112,11 @@ function componentCompiler(options = {}) {
|
|
|
118
112
|
}
|
|
119
113
|
}
|
|
120
114
|
overrideMap.clear();
|
|
121
|
-
reporter == null ? void 0 : reporter.reportOverride({
|
|
122
|
-
action: "clear",
|
|
123
|
-
overrideCount
|
|
124
|
-
});
|
|
125
115
|
});
|
|
126
116
|
server.middlewares.use("/__nocode_file_override", async (req, res, next) => {
|
|
127
117
|
if (req.method !== "POST") {
|
|
128
118
|
return next();
|
|
129
119
|
}
|
|
130
|
-
const reporter = (0, import_nocode_compiler_core.getReporter)();
|
|
131
120
|
try {
|
|
132
121
|
const { file, code } = await readJsonBody(req);
|
|
133
122
|
if (!file || typeof code !== "string") {
|
|
@@ -140,10 +129,6 @@ function componentCompiler(options = {}) {
|
|
|
140
129
|
console.warn("[nocode-compiler] file not found:", file, server.config.root);
|
|
141
130
|
res.statusCode = 404;
|
|
142
131
|
res.end(JSON.stringify({ error: "file not found" }));
|
|
143
|
-
reporter == null ? void 0 : reporter.reportOverride({
|
|
144
|
-
action: "notfound",
|
|
145
|
-
filePath: file
|
|
146
|
-
});
|
|
147
132
|
return;
|
|
148
133
|
}
|
|
149
134
|
overrideMap.set(absolutePath, code);
|
|
@@ -164,18 +149,9 @@ function componentCompiler(options = {}) {
|
|
|
164
149
|
});
|
|
165
150
|
}
|
|
166
151
|
}
|
|
167
|
-
reporter == null ? void 0 : reporter.reportOverride({
|
|
168
|
-
action: "set",
|
|
169
|
-
filePath: absolutePath,
|
|
170
|
-
overrideCount: overrideMap.size
|
|
171
|
-
});
|
|
172
152
|
res.statusCode = 200;
|
|
173
153
|
res.end(JSON.stringify({ success: true }));
|
|
174
154
|
} catch (error) {
|
|
175
|
-
reporter == null ? void 0 : reporter.reportOverride({
|
|
176
|
-
action: "error",
|
|
177
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
178
|
-
});
|
|
179
155
|
res.statusCode = 500;
|
|
180
156
|
res.end(JSON.stringify({ error: String(error) }));
|
|
181
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,
|
|
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
|
|
25
|
+
var version = "0.2.4";
|
|
26
26
|
|
|
27
27
|
// src/index.ts
|
|
28
28
|
var overrideMap = /* @__PURE__ */ new Map();
|
|
@@ -49,18 +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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
pluginVersion: version
|
|
62
|
-
});
|
|
63
|
-
}
|
|
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);
|
|
64
60
|
const vueCompiler = new VueCompiler(options);
|
|
65
61
|
const jsxCompiler = new JSXCompiler(options);
|
|
66
62
|
let server;
|
|
@@ -82,8 +78,6 @@ function componentCompiler(options = {}) {
|
|
|
82
78
|
server = _server;
|
|
83
79
|
server.ws.on("connection", () => {
|
|
84
80
|
if (overrideMap.size === 0) return;
|
|
85
|
-
const reporter = getReporter();
|
|
86
|
-
const overrideCount = overrideMap.size;
|
|
87
81
|
for (const filePath of overrideMap.keys()) {
|
|
88
82
|
const mods = server.moduleGraph.getModulesByFile(filePath);
|
|
89
83
|
if (mods && mods.size > 0) {
|
|
@@ -93,16 +87,11 @@ function componentCompiler(options = {}) {
|
|
|
93
87
|
}
|
|
94
88
|
}
|
|
95
89
|
overrideMap.clear();
|
|
96
|
-
reporter == null ? void 0 : reporter.reportOverride({
|
|
97
|
-
action: "clear",
|
|
98
|
-
overrideCount
|
|
99
|
-
});
|
|
100
90
|
});
|
|
101
91
|
server.middlewares.use("/__nocode_file_override", async (req, res, next) => {
|
|
102
92
|
if (req.method !== "POST") {
|
|
103
93
|
return next();
|
|
104
94
|
}
|
|
105
|
-
const reporter = getReporter();
|
|
106
95
|
try {
|
|
107
96
|
const { file, code } = await readJsonBody(req);
|
|
108
97
|
if (!file || typeof code !== "string") {
|
|
@@ -115,10 +104,6 @@ function componentCompiler(options = {}) {
|
|
|
115
104
|
console.warn("[nocode-compiler] file not found:", file, server.config.root);
|
|
116
105
|
res.statusCode = 404;
|
|
117
106
|
res.end(JSON.stringify({ error: "file not found" }));
|
|
118
|
-
reporter == null ? void 0 : reporter.reportOverride({
|
|
119
|
-
action: "notfound",
|
|
120
|
-
filePath: file
|
|
121
|
-
});
|
|
122
107
|
return;
|
|
123
108
|
}
|
|
124
109
|
overrideMap.set(absolutePath, code);
|
|
@@ -139,18 +124,9 @@ function componentCompiler(options = {}) {
|
|
|
139
124
|
});
|
|
140
125
|
}
|
|
141
126
|
}
|
|
142
|
-
reporter == null ? void 0 : reporter.reportOverride({
|
|
143
|
-
action: "set",
|
|
144
|
-
filePath: absolutePath,
|
|
145
|
-
overrideCount: overrideMap.size
|
|
146
|
-
});
|
|
147
127
|
res.statusCode = 200;
|
|
148
128
|
res.end(JSON.stringify({ success: true }));
|
|
149
129
|
} catch (error) {
|
|
150
|
-
reporter == null ? void 0 : reporter.reportOverride({
|
|
151
|
-
action: "error",
|
|
152
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
153
|
-
});
|
|
154
130
|
res.statusCode = 500;
|
|
155
131
|
res.end(JSON.stringify({ error: String(error) }));
|
|
156
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
|
|
3
|
+
"version": "0.2.4",
|
|
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
|
|
26
|
+
"@meituan-nocode/nocode-compiler-core": "0.2.5"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"dev": "tsup --watch",
|