diff --git a/compiler/compiler.ts b/compiler/compiler.ts index 1e760da2..b2d9071e 100644 --- a/compiler/compiler.ts +++ b/compiler/compiler.ts @@ -5144,8 +5144,7 @@ export class Compiler { // first part of scope until the stream starts controller.enqueue(await Compiler.createBlockFromScope(SCOPE)); - - + // read stream and insert const reader = SCOPE.streaming!; let next:ReadableStreamReadResult, diff --git a/js_adapter/js_class_adapter.ts b/js_adapter/js_class_adapter.ts index 9121b186..28611c67 100644 --- a/js_adapter/js_class_adapter.ts +++ b/js_adapter/js_class_adapter.ts @@ -1261,7 +1261,6 @@ export function proxyClass(original_clas else { const instance:any = Reflect.construct(target, args, newTarget); if (args[0]?.[INIT_PROPS]) { - console.log("auto init props"); args[0][INIT_PROPS](instance); } return instance; diff --git a/runtime/pointers.ts b/runtime/pointers.ts index 34844a02..548878e7 100644 --- a/runtime/pointers.ts +++ b/runtime/pointers.ts @@ -3176,6 +3176,9 @@ export class Pointer extends Ref { public addSubscriber(subscriber: Endpoint) { + // already subscribed + if (this.subscribers.has(subscriber)) return; + // TODO also check pointer permission for 'to' // request sync endpoint is self, cannot subscribe to own pointers! diff --git a/runtime/runtime.ts b/runtime/runtime.ts index 48a827db..abcfa236 100644 --- a/runtime/runtime.ts +++ b/runtime/runtime.ts @@ -497,8 +497,8 @@ export class Runtime { private static STD_TYPES_ABOUT:Map; - static #datex_out_handler_initialized_resolve:(value: void | PromiseLike) => void - static #datex_out_init_promise = new Promise(resolve=>this.#datex_out_handler_initialized_resolve=resolve); + static #datex_out_handler_initialized_resolve?:(value: void | PromiseLike) => void + static #datex_out_init_promise:Promise|undefined = new Promise(resolve=>this.#datex_out_handler_initialized_resolve=resolve); private static local_input_handler = Runtime.getDatexInputHandler(); diff --git a/runtime/storage-locations/deno-kv.ts b/runtime/storage-locations/deno-kv.ts index 9071dda3..521f9db9 100644 --- a/runtime/storage-locations/deno-kv.ts +++ b/runtime/storage-locations/deno-kv.ts @@ -53,7 +53,7 @@ export class DenoKVStorageLocation extends AsyncStorageLocation { const entries = itemDB!.list({prefix: []}); const keys = []; for await (const entry of entries) { - keys.push(entry.value); + keys.push(entry.key[0]); } return keys.values() as Generator } @@ -62,7 +62,7 @@ export class DenoKVStorageLocation extends AsyncStorageLocation { const entries = pointerDB!.list({prefix: []}); const keys = []; for await (const entry of entries) { - keys.push(entry.value); + keys.push(entry.key[0]); } return keys.values() as Generator } diff --git a/types/function.ts b/types/function.ts index 7454e306..206e99b7 100644 --- a/types/function.ts +++ b/types/function.ts @@ -298,8 +298,13 @@ export class Function any = (...args: any) => any> e // call the function either from JS directly (meta data is automatically generated, sender is always the current endpoint) or from a DATEX scope handleApply(value:any, SCOPE?: datex_scope):Promise>|ReturnType{ - // call function remotely - if (!Runtime.endpoint.equals(this.location) && this.location != LOCAL_ENDPOINT) this.setRemoteEndpoint(this.location); + // call function remotely if not + if (!( + Runtime.endpoint.equals(this.location) || // location is own endpoint instance + Runtime.endpoint.main.equals(this.location) || // location is own endpoint + this.location == LOCAL_ENDPOINT || // location is local + this.fn // already has a local function + )) this.setRemoteEndpoint(this.location); let meta:any; // meta (scope variables) @@ -315,7 +320,10 @@ export class Function any = (...args: any) => any> e // is proxy function: call remote, only if has impersonation permission! if (this.proxy_fn) { if (SCOPE.impersonation_permission) return this.proxy_fn(value); - else throw new PermissionError("No permission to execute functions on external endpoints ("+this.name+","+this.proxy_fn.name+")", SCOPE) + else { + console.error(this.proxy_fn) + throw new PermissionError("No permission to execute functions on external endpoints ("+this.name+","+this.proxy_fn.name+")", SCOPE) + } } // else local call ... meta = SCOPE.meta; diff --git a/utils/message_logger.ts b/utils/message_logger.ts index 358a2575..c272193c 100644 --- a/utils/message_logger.ts +++ b/utils/message_logger.ts @@ -13,7 +13,7 @@ export class MessageLogger { static logger:Logger - static decompile(dxb:ArrayBuffer, has_header = true, colorized = true){ + static decompile(dxb:ArrayBuffer, has_header = true, colorized = true, resolve_slots = true){ try { // extract body (TODO: just temporary, rust impl does not yet support header decompilation) if (has_header) { @@ -22,7 +22,7 @@ export class MessageLogger { dxb = res[1]; } - return wasm_decompile(new Uint8Array(dxb), true, colorized, true).replace(/\r\n$/, ''); + return wasm_decompile(new Uint8Array(dxb), true, colorized, resolve_slots).replace(/\r\n$/, ''); } catch (e) { return "Decompiler Error: "+ e.message; } @@ -36,11 +36,17 @@ export class MessageLogger { // ignore incoming requests from own endpoint to own endpoint const receivers = header.routing?.receivers; if (header.sender == Runtime.endpoint && (receivers instanceof Logical && receivers?.size == 1 && receivers.has(Runtime.endpoint)) && header.type != ProtocolDataType.RESPONSE && header.type != ProtocolDataType.DEBUGGER) return; - + + // ignore hello messages + if (header.type == ProtocolDataType.HELLO || header.type == ProtocolDataType.GOODBYE) { + this.logger.plain(`\n#color(blue)⭠ ${header.sender||'@*'} ${header.type!=undefined? `(${ProtocolDataType[header.type]}) ` : ''}`); + return; + }; + const content = MessageLogger.decompile(dxb); if (content.trim() == "\x1b[38;2;219;45;129mvoid\x1b[39m;") return; // dont log void; messages - this.logger.plain(`\n#color(blue)⭠ ${header.sender||'@*'} `.padEnd(70, '─')); + this.logger.plain(`\n#color(blue)⭠ ${header.sender||'@*'} ${header.type!=undefined ? `(${ProtocolDataType[header.type]}) ` : ''}`.padEnd(70, '─')); console.log(content); this.logger.plain(`#color(blue)─────────────────────────────────────────────────────────\n`); }); @@ -50,10 +56,16 @@ export class MessageLogger { const receivers = header.routing?.receivers; if (header.sender == Runtime.endpoint && (receivers instanceof Logical && receivers?.size == 1 && receivers.has(Runtime.endpoint)) && header.type != ProtocolDataType.RESPONSE && header.type != ProtocolDataType.DEBUGGER) return; + // ignore hello messages + if (header.type == ProtocolDataType.HELLO || header.type == ProtocolDataType.GOODBYE) { + this.logger.plain(`\n#color(green)${header.sender||'@*'} ⭢ ${receivers||'@*'} ${header.type!=undefined ? `(${ProtocolDataType[header.type]}) ` : ''}`); + return; + }; + const content = MessageLogger.decompile(dxb); if (content.trim() == "\x1b[38;2;219;45;129mvoid\x1b[39m;") return; // dont log void; messages - this.logger.plain(`\n#color(green)⭢ ${receivers||'@*'} `.padEnd(70, '─')); + this.logger.plain(`\n#color(green)⭢ ${receivers||'@*'} ${header.type!=undefined ? `(${ProtocolDataType[header.type]}) ` : ''}`.padEnd(70, '─')); console.log(content); this.logger.plain(`#color(green)─────────────────────────────────────────────────────────\n`); }); diff --git a/wasm/adapter/pkg/datex_wasm_bg.wasm b/wasm/adapter/pkg/datex_wasm_bg.wasm index 1cb3ad2a..ec11a9ac 100644 Binary files a/wasm/adapter/pkg/datex_wasm_bg.wasm and b/wasm/adapter/pkg/datex_wasm_bg.wasm differ