diff --git a/core/grpc_plugins.go b/core/grpc_plugins.go index 56c48d2..8b40d00 100644 --- a/core/grpc_plugins.go +++ b/core/grpc_plugins.go @@ -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; -export { Adapter, Bucket, sender, sleep }; +export { Adapter, Bucket, sender, sleep, console }; ` func defaultScript(title string) string { diff --git a/proto3/sillygirl.d.ts b/proto3/sillygirl.d.ts index 5d64cb2..6798556 100644 --- a/proto3/sillygirl.d.ts +++ b/proto3/sillygirl.d.ts @@ -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 }; diff --git a/proto3/sillygirl.js b/proto3/sillygirl.js index ef92445..b9ebf21 100644 --- a/proto3/sillygirl.js +++ b/proto3/sillygirl.js @@ -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; diff --git a/proto3/sillygirl.ts b/proto3/sillygirl.ts index 34694ae..fa1a34b 100644 --- a/proto3/sillygirl.ts +++ b/proto3/sillygirl.ts @@ -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 };