This commit is contained in:
1-6
2023-07-27 01:02:21 +08:00
parent 615e543845
commit e31cae949b
4 changed files with 70 additions and 7 deletions
+5 -4
View File
@@ -313,9 +313,10 @@ func AddNodePlugin(path, name string) error {
}
senders.Store(id, s)
defer func() {
fmt.Println("senders.Delete(id)")
}()
// defer func() {
// fmt.Println("senders.Delete(id)")
// }()
senders.Delete(id)
defer processes.Delete(cmd)
err = cmd.Wait()
if err != nil {
@@ -446,7 +447,7 @@ declare class Adapter {
}
declare let sender: Sender;
declare function sleep(ms: number | undefined): Promise<unknown>;
export { Adapter, Bucket, sender, sleep };
export { Adapter, Bucket, sender, sleep, console };
`
func defaultScript(title string) string {
+7 -1
View File
@@ -90,4 +90,10 @@ declare let utils: {
params: any;
})[];
};
export { Adapter, Bucket, sender, sleep, utils };
declare let console: {
log(...args: any[]): void;
info(...args: any[]): void;
error(...args: any[]): void;
debug(...args: any[]): void;
};
export { Adapter, Bucket, sender, sleep, utils, console };
+22 -1
View File
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.utils = exports.sleep = exports.sender = exports.Bucket = exports.Adapter = void 0;
exports.console = exports.utils = exports.sleep = exports.sender = exports.Bucket = exports.Adapter = void 0;
const srpc_1 = require("./srpc");
const grpc_1 = __importStar(require("@grpc/grpc-js"));
let client = new srpc_1.srpc.SillyGirlServiceClient("localhost:50051", grpc_1.credentials.createInsecure());
@@ -676,3 +676,24 @@ let utils = {
},
};
exports.utils = utils;
let slog = (type, ...args) => {
};
let console = {
log(...args) {
const content = args.reduce((acc, arg) => acc + ' ' + arg, '');
client.Console(new srpc_1.srpc.ConsoleRequest({ type: "log", content, plugin_id }), (err, resp) => { });
},
info(...args) {
const content = args.reduce((acc, arg) => acc + ' ' + arg, '');
client.Console(new srpc_1.srpc.ConsoleRequest({ type: "info", content, plugin_id }), (err, resp) => { });
},
error(...args) {
const content = args.reduce((acc, arg) => acc + ' ' + arg, '');
client.Console(new srpc_1.srpc.ConsoleRequest({ type: "error", content, plugin_id }), (err, resp) => { });
},
debug(...args) {
const content = args.reduce((acc, arg) => acc + ' ' + arg, '');
client.Console(new srpc_1.srpc.ConsoleRequest({ type: "debug", content, plugin_id }), (err, resp) => { });
},
};
exports.console = console;
+36 -1
View File
@@ -784,4 +784,39 @@ let utils = {
},
};
export { Adapter, Bucket, sender, sleep, utils };
let slog = (type: string, ...args: any[]) => {
};
let console = {
log(...args: any[]) {
const content = args.reduce((acc, arg) => acc + ' ' + arg, '')
client.Console(
new srpc.ConsoleRequest({ type: "log", content, plugin_id }),
(err, resp) => {}
)
},
info(...args: any[]) {
const content = args.reduce((acc, arg) => acc + ' ' + arg, '')
client.Console(
new srpc.ConsoleRequest({ type: "info", content, plugin_id }),
(err, resp) => {}
)
},
error(...args: any[]) {
const content = args.reduce((acc, arg) => acc + ' ' + arg, '')
client.Console(
new srpc.ConsoleRequest({ type: "error", content, plugin_id }),
(err, resp) => {}
)
},
debug(...args: any[]) {
const content = args.reduce((acc, arg) => acc + ' ' + arg, '')
client.Console(
new srpc.ConsoleRequest({ type: "debug", content, plugin_id }),
(err, resp) => {}
)
},
};
export { Adapter, Bucket, sender, sleep, utils, console };