@pulse-editor/cli 0.1.1-beta.35 → 0.1.1-beta.36
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.
|
@@ -20,7 +20,7 @@ class MFServerPlugin {
|
|
|
20
20
|
let isFirstRun = true;
|
|
21
21
|
// Before build starts
|
|
22
22
|
compiler.hooks.watchRun.tap("ReloadMessagePlugin", async (compilation) => {
|
|
23
|
-
this.
|
|
23
|
+
this.cleanServerDist();
|
|
24
24
|
if (!isFirstRun) {
|
|
25
25
|
console.log(`[Server] 🔄 Reloading app...`);
|
|
26
26
|
const isServerFunctionChange = compilation.modifiedFiles
|
|
@@ -69,7 +69,6 @@ class MFServerPlugin {
|
|
|
69
69
|
console.log(`[Server] ❌ Failed to build server.`);
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
|
-
this.cleanDist();
|
|
73
72
|
try {
|
|
74
73
|
await this.compileServerFunctions(compiler);
|
|
75
74
|
this.compileAppActionSkills();
|
|
@@ -83,7 +82,7 @@ class MFServerPlugin {
|
|
|
83
82
|
});
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
|
-
|
|
85
|
+
cleanServerDist() {
|
|
87
86
|
// Remove existing entry points
|
|
88
87
|
try {
|
|
89
88
|
fs.rmSync("dist/server", { recursive: true, force: true });
|
|
@@ -231,46 +230,41 @@ ${Object.entries(funcs)
|
|
|
231
230
|
const allJSDocs = sourceFile.getDescendantsOfKind(SyntaxKind.JSDoc);
|
|
232
231
|
const typeDefs = this.parseTypeDefs(allJSDocs);
|
|
233
232
|
/* Extract parameter descriptions from JSDoc */
|
|
234
|
-
// Check if the function's first param is an object
|
|
235
|
-
if (funcDecl.getParameters().length !== 1) {
|
|
236
|
-
throw new Error(`[Action Registration] Function ${funcName} should have exactly one parameter which is an object. Skipping...`);
|
|
237
|
-
}
|
|
238
|
-
else if (!funcDecl.getParameters()[0]?.getType().isObject()) {
|
|
239
|
-
throw new Error(`[Action Registration] Function ${funcName}'s parameter should be an object. Skipping...`);
|
|
240
|
-
}
|
|
241
233
|
const funcParam = funcDecl.getParameters()[0];
|
|
242
234
|
const params = {};
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
235
|
+
if (funcParam) {
|
|
236
|
+
/**
|
|
237
|
+
* Extract default values from the destructured parameter
|
|
238
|
+
* (ObjectBindingPattern → BindingElement initializer)
|
|
239
|
+
*/
|
|
240
|
+
const defaults = new Map();
|
|
241
|
+
const nameNode = funcParam.getNameNode();
|
|
242
|
+
if (Node.isObjectBindingPattern(nameNode)) {
|
|
243
|
+
nameNode.getElements().forEach((el) => {
|
|
244
|
+
if (!Node.isBindingElement(el))
|
|
245
|
+
return;
|
|
246
|
+
const name = el.getName();
|
|
247
|
+
const initializer = el.getInitializer()?.getText();
|
|
248
|
+
if (initializer) {
|
|
249
|
+
defaults.set(name, initializer);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
funcParam
|
|
254
|
+
.getType()
|
|
255
|
+
.getProperties()
|
|
256
|
+
.forEach((prop) => {
|
|
257
|
+
const name = prop.getName();
|
|
258
|
+
const inputTypeDef = typeDefs["input"] ?? {};
|
|
259
|
+
const variable = {
|
|
260
|
+
description: inputTypeDef[name]?.description ?? "",
|
|
261
|
+
type: this.getType(inputTypeDef[name]?.type ?? ""),
|
|
262
|
+
optional: prop.isOptional() ? true : undefined,
|
|
263
|
+
defaultValue: defaults.get(name),
|
|
264
|
+
};
|
|
265
|
+
params[name] = variable;
|
|
258
266
|
});
|
|
259
267
|
}
|
|
260
|
-
funcParam
|
|
261
|
-
.getType()
|
|
262
|
-
.getProperties()
|
|
263
|
-
.forEach((prop) => {
|
|
264
|
-
const name = prop.getName();
|
|
265
|
-
const inputTypeDef = typeDefs["input"] ?? {};
|
|
266
|
-
const variable = {
|
|
267
|
-
description: inputTypeDef[name]?.description ?? "",
|
|
268
|
-
type: this.getType(inputTypeDef[name]?.type ?? ""),
|
|
269
|
-
optional: prop.isOptional() ? true : undefined,
|
|
270
|
-
defaultValue: defaults.get(name),
|
|
271
|
-
};
|
|
272
|
-
params[name] = variable;
|
|
273
|
-
});
|
|
274
268
|
/* Extract return type from JSDoc */
|
|
275
269
|
// Check if the return type is an object
|
|
276
270
|
if (!funcDecl.getReturnType().isObject()) {
|
|
@@ -347,6 +341,8 @@ ${Object.entries(funcs)
|
|
|
347
341
|
return "object";
|
|
348
342
|
if (text.endsWith("[]"))
|
|
349
343
|
return [this.getType(text.slice(0, -2))];
|
|
344
|
+
if (text.length === 0)
|
|
345
|
+
return "undefined";
|
|
350
346
|
console.warn(`[Type Warning] Unrecognized type "${text}". Consider adding explicit types in your action's JSDoc comments for better type safety and documentation.`);
|
|
351
347
|
return text;
|
|
352
348
|
}
|