From aa75f1cc1ac444cc888ddcff724a9e77fdc75013 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 10:04:48 -0800 Subject: [PATCH 01/87] Start console class for console plugin --- core/src/plugins/debuggerPlugin/Console.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 core/src/plugins/debuggerPlugin/Console.ts diff --git a/core/src/plugins/debuggerPlugin/Console.ts b/core/src/plugins/debuggerPlugin/Console.ts new file mode 100644 index 000000000..0a2b449d2 --- /dev/null +++ b/core/src/plugins/debuggerPlugin/Console.ts @@ -0,0 +1,16 @@ +import { IRunContextEditor, ThothNode } from '../../../types' +import { ThothComponent } from '../../thoth-component' + +type ConsoleConstructor = { + component: ThothComponent + editor: IRunContextEditor + node: ThothNode +} + +export class Console { + node: ThothNode + editor: IRunContextEditor + component: ThothComponent + + constructor({ component, editor, node }: ConsoleConstructor) {} +} From 6af8d35b62d999bcef15bcda52e7034073c73b72 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 10:07:14 -0800 Subject: [PATCH 02/87] Construct class properties --- core/src/plugins/debuggerPlugin/Console.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/plugins/debuggerPlugin/Console.ts b/core/src/plugins/debuggerPlugin/Console.ts index 0a2b449d2..d97759de7 100644 --- a/core/src/plugins/debuggerPlugin/Console.ts +++ b/core/src/plugins/debuggerPlugin/Console.ts @@ -12,5 +12,9 @@ export class Console { editor: IRunContextEditor component: ThothComponent - constructor({ component, editor, node }: ConsoleConstructor) {} + constructor({ component, editor, node }: ConsoleConstructor) { + this.component = component + this.editor = editor + this.node = node + } } From 7b3c08b87f21c63bfc8aad5f0dbf0a2c5116b561 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 10:10:13 -0800 Subject: [PATCH 03/87] Attache node view to console class --- core/src/plugins/debuggerPlugin/Console.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/src/plugins/debuggerPlugin/Console.ts b/core/src/plugins/debuggerPlugin/Console.ts index d97759de7..fb9184d15 100644 --- a/core/src/plugins/debuggerPlugin/Console.ts +++ b/core/src/plugins/debuggerPlugin/Console.ts @@ -1,3 +1,4 @@ +import { NodeView } from 'rete/types/view/node' import { IRunContextEditor, ThothNode } from '../../../types' import { ThothComponent } from '../../thoth-component' @@ -11,10 +12,23 @@ export class Console { node: ThothNode editor: IRunContextEditor component: ThothComponent + nodeView: NodeView constructor({ component, editor, node }: ConsoleConstructor) { this.component = component this.editor = editor this.node = node + + const nodeValues = Array.from(editor.view.nodes) + const foundNode = nodeValues.find(([, n]) => n.node.id === node.id) + + if (!foundNode) return + + this.nodeView = foundNode[1] + } + + updateNodeView() { + this.nodeView.onStart() + this.nodeView.node.update() } } From cd5155f2dd65e03c67d360c438ef6b9ca4f822ca Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 10:24:35 -0800 Subject: [PATCH 04/87] Rename console class to thoth console --- .../{Console.ts => ThothConsole.ts} | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) rename core/src/plugins/debuggerPlugin/{Console.ts => ThothConsole.ts} (62%) diff --git a/core/src/plugins/debuggerPlugin/Console.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts similarity index 62% rename from core/src/plugins/debuggerPlugin/Console.ts rename to core/src/plugins/debuggerPlugin/ThothConsole.ts index fb9184d15..6f4c54619 100644 --- a/core/src/plugins/debuggerPlugin/Console.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -1,23 +1,36 @@ import { NodeView } from 'rete/types/view/node' -import { IRunContextEditor, ThothNode } from '../../../types' +import { IRunContextEditor, NodeData } from '../../../types' import { ThothComponent } from '../../thoth-component' type ConsoleConstructor = { component: ThothComponent editor: IRunContextEditor - node: ThothNode + node: NodeData + server: boolean + throwError?: Function } -export class Console { - node: ThothNode +export class ThothConsole { + node: NodeData editor: IRunContextEditor component: ThothComponent nodeView: NodeView + isServer: boolean + throwError?: Function - constructor({ component, editor, node }: ConsoleConstructor) { + constructor({ + component, + editor, + node, + server, + throwError, + }: ConsoleConstructor) { this.component = component this.editor = editor this.node = node + this.isServer = server + + if (throwError) this.throwError = throwError const nodeValues = Array.from(editor.view.nodes) const foundNode = nodeValues.find(([, n]) => n.node.id === node.id) From 4c6474a5767103db187a95f7da279655930f228b Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 10:37:04 -0800 Subject: [PATCH 05/87] Add format message class function --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index 6f4c54619..f9db8db8e 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -44,4 +44,15 @@ export class ThothConsole { this.nodeView.onStart() this.nodeView.node.update() } + + formatErrorMessage(error: any) { + const message = { + errorIn: this.node.name, + nodeId: this.node.id, + errorMessage: error.message, + } + + return message + } + } From 13cf1f1364d4e8c292eaf26035f14e079d2851ad Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 10:37:38 -0800 Subject: [PATCH 06/87] Add throw server error function --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index f9db8db8e..221223b2c 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -55,4 +55,7 @@ export class ThothConsole { return message } + throwServerError(message: any) { + if (this.isServer && this.throwError) this.throwError(message) + } } From 8bca81a342cb6dedd81da9e1a08aa082b7759542 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 10:38:08 -0800 Subject: [PATCH 07/87] Add send to debug class function --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index 221223b2c..f4a0aafb6 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -55,6 +55,10 @@ export class ThothConsole { return message } + sendToDebug(message: any) { + if (this.editor.thoth.sendToDebug) this.editor.thoth.sendToDebug(message) + } + throwServerError(message: any) { if (this.isServer && this.throwError) this.throwError(message) } From 9a5158540d422a1a381de06eea871913551e4581 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 10:38:27 -0800 Subject: [PATCH 08/87] Add send to error claass function --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index f4a0aafb6..78e663f94 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -55,6 +55,13 @@ export class ThothConsole { return message } + sendError(error: any) { + const message = this.formatErrorMessage(error) + this.sendToDebug(message) + this.throwServerError(message) + this.updateNodeView() + } + sendToDebug(message: any) { if (this.editor.thoth.sendToDebug) this.editor.thoth.sendToDebug(message) } From c6df55051642504a0682248003b5cc15da24f8cf Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:07:27 -0800 Subject: [PATCH 09/87] Add render error class function --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index 78e663f94..e6bfc9ae9 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -55,6 +55,12 @@ export class ThothConsole { return message } + renderError() { + this.node.data.error = true + this.updateNodeView() + this.node.data.error = false + } + sendError(error: any) { const message = this.formatErrorMessage(error) this.sendToDebug(message) From 82ca7061390d55dd8974fd4829c0705324a37ec9 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:07:40 -0800 Subject: [PATCH 10/87] Add render success class function --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index e6bfc9ae9..552632f9f 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -61,6 +61,12 @@ export class ThothConsole { this.node.data.error = false } + renderSuccess() { + this.node.data.success = true + this.updateNodeView() + this.node.data.success = false + } + sendError(error: any) { const message = this.formatErrorMessage(error) this.sendToDebug(message) From 51bddc68bf35f3eee01ba1ee494942e4285eec3e Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:07:53 -0800 Subject: [PATCH 11/87] Use new render error in send error function --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index 552632f9f..8c5f96384 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -71,7 +71,7 @@ export class ThothConsole { const message = this.formatErrorMessage(error) this.sendToDebug(message) this.throwServerError(message) - this.updateNodeView() + this.renderError() } sendToDebug(message: any) { From 06eba9e45927f393c650ea8d5aed1912cfc4073d Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:08:07 -0800 Subject: [PATCH 12/87] Add thoth console type to node type --- core/types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/types.ts b/core/types.ts index 25f4bf848..9f517d248 100644 --- a/core/types.ts +++ b/core/types.ts @@ -16,6 +16,7 @@ import { TaskOutputTypes } from './src/plugins/taskPlugin/task' import { SocketNameType, SocketType } from './src/sockets' import { EngineContext } from './src/engine' import { ThothTask } from './src/thoth-component' +import { ThothConsole } from './src/plugins/debuggerPlugin/ThothConsole' export type EventsTypes = { run: void @@ -54,6 +55,7 @@ export type ThothNode = Node & { displayName?: string info: string subscription: Function + console: ThothConsole } export type ModuleType = { @@ -126,6 +128,7 @@ export type NodeData = ReteNodeData & { fewshot?: string display: Function error?: boolean + console: ThothConsole } // export type Node = { From 7ca7ed21fb4d6a12301e68c92bcdb7a3842c4724 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:08:39 -0800 Subject: [PATCH 13/87] Use new thoth console in debugger plugin --- core/src/plugins/debuggerPlugin/index.ts | 36 +++++++----------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 5e3e5b378..3791fbab6 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -1,5 +1,6 @@ import { IRunContextEditor } from '../../../types' import { ThothComponent } from '../../thoth-component' +import { ThothConsole } from './ThothConsole' function install( editor: IRunContextEditor, @@ -16,7 +17,15 @@ function install( } component.worker = (node, inputs, outputs, data, ...args) => { + node.console = new ThothConsole({ + node, + component, + editor, + server, + throwError, + }) node.data.error = false + try { const result = worker.apply(component, [ node, @@ -28,32 +37,7 @@ function install( return result } catch (error: any) { - const message = { - errorIn: node.name, - errorMessage: error.message, - } - - if (throwError) { - throwError(message) - return - } - - if (editor.thoth.sendToDebug) editor.thoth.sendToDebug(message) - - if (!server) { - node.data.error = true - - const nodeValues = Array.from(editor.view.nodes) - const foundNode = nodeValues.find(([, n]) => n.node.id === node.id) - - if (!foundNode) return - - const nodeView = foundNode[1] - - nodeView?.onStart() - nodeView?.node.update() - throw error - } + node.console.sendError(error) } } }) From 662e2689d98867f29157b12805dc7f15f24cbda7 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:11:05 -0800 Subject: [PATCH 14/87] Add success styling to node --- client/src/features/common/Node/Node.module.css | 3 +++ client/src/features/common/Node/Node.module.css.d.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/client/src/features/common/Node/Node.module.css b/client/src/features/common/Node/Node.module.css index 7ce4e2a00..dc203d3af 100644 --- a/client/src/features/common/Node/Node.module.css +++ b/client/src/features/common/Node/Node.module.css @@ -101,6 +101,9 @@ border-color: var(--red) !important; /* backdrop-filter: blur(15px); */ } +.node.success { + border-color: var(--green) !important; +} .node.selected .node-title { opacity: 1; border-bottom: 1px solid var(--dark-1); diff --git a/client/src/features/common/Node/Node.module.css.d.ts b/client/src/features/common/Node/Node.module.css.d.ts index b58176e1d..06b95ee1f 100644 --- a/client/src/features/common/Node/Node.module.css.d.ts +++ b/client/src/features/common/Node/Node.module.css.d.ts @@ -15,6 +15,7 @@ interface CssExports { 'out': string; 'output': string; 'selected': string; + 'success': string; } export const cssExports: CssExports; export default cssExports; From b7ef2dc90a36723f8b429f52fc10d301df8e5488 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:11:19 -0800 Subject: [PATCH 15/87] Handle node success state in node component --- client/src/features/common/Node/Node.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/features/common/Node/Node.js b/client/src/features/common/Node/Node.js index a4496fd32..6a28c2e03 100644 --- a/client/src/features/common/Node/Node.js +++ b/client/src/features/common/Node/Node.js @@ -12,12 +12,13 @@ export class MyNode extends Node { const name = node.displayName ? node.displayName : node.name const fullName = node.data.name ? `${name} - ${node.data.name}` : name const hasError = node.data.error + const hasSuccess = node.data.success return (
{node.deprecated &&
}
From 6490c1aae956642b932baad6a597b559ab67404f Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:25:12 -0800 Subject: [PATCH 16/87] Clean up debugger plugin. Remove builder. --- core/src/plugins/debuggerPlugin/index.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 3791fbab6..783ec0ab2 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -8,13 +8,6 @@ function install( ) { editor.on('componentregister', (component: ThothComponent) => { const worker = component.worker - const builder = component.builder - - component.builder = node => { - node.data.error = false - - return builder.call(component, node) - } component.worker = (node, inputs, outputs, data, ...args) => { node.console = new ThothConsole({ @@ -24,7 +17,6 @@ function install( server, throwError, }) - node.data.error = false try { const result = worker.apply(component, [ @@ -35,6 +27,8 @@ function install( ...args, ]) + node.console.renderSuccess() + return result } catch (error: any) { node.console.sendError(error) From e60e0e0a346429b54cdca97cb3b473dde4250360 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:25:32 -0800 Subject: [PATCH 17/87] Switch back to ternary for css properties in node --- client/src/features/common/Node/Node.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/features/common/Node/Node.js b/client/src/features/common/Node/Node.js index 6a28c2e03..07dde1b9c 100644 --- a/client/src/features/common/Node/Node.js +++ b/client/src/features/common/Node/Node.js @@ -17,8 +17,8 @@ export class MyNode extends Node { return (
{node.deprecated &&
}
From 77fa16ae99ae339ae3e5d6e7cb44232d4f0ee5b9 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:37:09 -0800 Subject: [PATCH 18/87] Display node number and component name in error message --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index dc0902804..5ec2a3e1a 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -38,7 +38,9 @@ const DebugConsole = ({ tab }) => { terminal.pushToStdout( ` - > Error in ${data.errorIn} component. + > Node ${data.nodeId}: Error in ${data.errorIn} component ${ + data.name ?? '' + }. > ${data.errorMessage} ` ) From 1515713602b4c34d8cea85dd8ef07d4af8c5dd54 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:37:29 -0800 Subject: [PATCH 19/87] Add name to error message --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index 8c5f96384..5b5bd1703 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -49,6 +49,7 @@ export class ThothConsole { const message = { errorIn: this.node.name, nodeId: this.node.id, + name: this.node.data.name || null, errorMessage: error.message, } From 26953047d7260eed4fc3591d88727b830cc7f481 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:37:52 -0800 Subject: [PATCH 20/87] Name send error to error in thoth console --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index 5b5bd1703..9f719a3c3 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -68,7 +68,7 @@ export class ThothConsole { this.node.data.success = false } - sendError(error: any) { + error(error: any) { const message = this.formatErrorMessage(error) this.sendToDebug(message) this.throwServerError(message) From 022a56c7a394c0611d2ab61b1e48cc7bde818009 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:38:09 -0800 Subject: [PATCH 21/87] Stub send success for now --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index 9f719a3c3..9a994de91 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -75,6 +75,8 @@ export class ThothConsole { this.renderError() } + sendSuccess(result: any) {} + sendToDebug(message: any) { if (this.editor.thoth.sendToDebug) this.editor.thoth.sendToDebug(message) } From 5f4fe4520353f3deb2d1741b9ffb9aadef160f0f Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 11:38:21 -0800 Subject: [PATCH 22/87] Add console log --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index 9a994de91..ac795b067 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -68,6 +68,10 @@ export class ThothConsole { this.node.data.success = false } + log(message: any) { + this.sendToDebug(message) + } + error(error: any) { const message = this.formatErrorMessage(error) this.sendToDebug(message) From b5c7073ccca14c46c969d0b1f94a8135cff47a59 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 12:02:40 -0800 Subject: [PATCH 23/87] Add console log overwrite to debugger plugin --- core/src/plugins/debuggerPlugin/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 783ec0ab2..ea7ea2863 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -6,6 +6,13 @@ function install( editor: IRunContextEditor, { server = false, throwError }: { server?: boolean; throwError?: Function } ) { + const consoleLog = console.log + + console.log = function (message) { + // if (editor.thoth.sendToDebug) editor.thoth.sendToDebug(message) + consoleLog.apply(console, arguments) + } + editor.on('componentregister', (component: ThothComponent) => { const worker = component.worker From 054c4414acd747f6c595ec919d1d26773980a5b3 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 12:05:29 -0800 Subject: [PATCH 24/87] Call error not send error --- core/src/plugins/debuggerPlugin/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index ea7ea2863..b682b1359 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -38,7 +38,7 @@ function install( return result } catch (error: any) { - node.console.sendError(error) + node.console.error(error) } } }) From f077bdecf3431e5e5813357ebfce0090c189722c Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 12:06:27 -0800 Subject: [PATCH 25/87] Throw error after catching it --- core/src/plugins/debuggerPlugin/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index b682b1359..b36993696 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -39,6 +39,7 @@ function install( return result } catch (error: any) { node.console.error(error) + throw error } } }) From 21864facfa087b6153e27ae07e8e6d656773bc3b Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 9 Mar 2022 13:00:06 -0800 Subject: [PATCH 26/87] fix type error with activeTab being potentially null --- client/src/features/common/TabBar/TabBar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/common/TabBar/TabBar.tsx b/client/src/features/common/TabBar/TabBar.tsx index 9a6bbb970..884b8c7ee 100644 --- a/client/src/features/common/TabBar/TabBar.tsx +++ b/client/src/features/common/TabBar/TabBar.tsx @@ -10,7 +10,7 @@ import css from './tabBar.module.css' const Tab = ({ tab, activeTab }) => { const navigate = useNavigate() const { closeTab } = useTabManager() - const active = tab.id === activeTab.id + const active = tab.id === activeTab?.id const title = `${tab.type}- ${tab.name}` const tabClass = classnames({ From c434005fa9dc755f2ccba6779a16559c13f430e8 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 13:10:16 -0800 Subject: [PATCH 27/87] Rename data to message in print to debugger function --- .../src/features/Thoth/windows/DebugConsole/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 5ec2a3e1a..c757d595b 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -32,16 +32,18 @@ const DebugConsole = ({ tab }) => { setScrollToBottom(true) } - const printToDebugger = useCallback((_, data) => { + // const formatErrorMessage = message => ({}) + + const printToDebugger = useCallback((_, message) => { const terminal = terminalRef.current if (!terminal) return terminal.pushToStdout( ` - > Node ${data.nodeId}: Error in ${data.errorIn} component ${ - data.name ?? '' + > Node ${message.nodeId}: Error in ${message.errorIn} component ${ + message.name ?? '' }. - > ${data.errorMessage} + > ${message.errorMessage} ` ) From 4bb59ca94b8a8e71349997bc98af363d42c30f84 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 13:30:14 -0800 Subject: [PATCH 28/87] Turn on danger mode for terminal --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index c757d595b..40ceaf85c 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -79,6 +79,7 @@ const DebugConsole = ({ tab }) => { Date: Wed, 9 Mar 2022 13:36:26 -0800 Subject: [PATCH 29/87] add red trash icon --- client/src/features/common/Icon/dangerTrash.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 client/src/features/common/Icon/dangerTrash.svg diff --git a/client/src/features/common/Icon/dangerTrash.svg b/client/src/features/common/Icon/dangerTrash.svg new file mode 100644 index 000000000..d2cde2409 --- /dev/null +++ b/client/src/features/common/Icon/dangerTrash.svg @@ -0,0 +1 @@ + \ No newline at end of file From 38f91f57293ae289e837b19b21dbfacba812eda1 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 9 Mar 2022 13:36:33 -0800 Subject: [PATCH 30/87] add white trash icon --- client/src/features/common/Icon/trash.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 client/src/features/common/Icon/trash.svg diff --git a/client/src/features/common/Icon/trash.svg b/client/src/features/common/Icon/trash.svg new file mode 100644 index 000000000..99ef061df --- /dev/null +++ b/client/src/features/common/Icon/trash.svg @@ -0,0 +1 @@ + \ No newline at end of file From 99188b2e5d032c53abffb1a538ed62eb8398e778 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 9 Mar 2022 13:37:01 -0800 Subject: [PATCH 31/87] add trash and trash:hover to icon css module --- client/src/features/common/Icon/icon.module.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/src/features/common/Icon/icon.module.css b/client/src/features/common/Icon/icon.module.css index 94da10af8..64f115710 100644 --- a/client/src/features/common/Icon/icon.module.css +++ b/client/src/features/common/Icon/icon.module.css @@ -129,3 +129,10 @@ .tiles { background-image: url('tiles.svg'); } +.trash { + background-image: url('trash.svg'); +} + +.trash:hover { + background-image: url('dangerTrash.svg'); +} From f1c205c4b3928a691d654a42135fa2fe82550dee Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 9 Mar 2022 13:37:21 -0800 Subject: [PATCH 32/87] add trash as spell icon --- client/src/features/HomeScreen/components/ProjectRow.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/HomeScreen/components/ProjectRow.jsx b/client/src/features/HomeScreen/components/ProjectRow.jsx index d620f7d41..bbecd3865 100644 --- a/client/src/features/HomeScreen/components/ProjectRow.jsx +++ b/client/src/features/HomeScreen/components/ProjectRow.jsx @@ -25,7 +25,7 @@ const ProjectRow = ({ {label} {onDelete && ( { onDelete(spell.name) }} From 797f513f794c9cde014350343222a0c384e3958f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 9 Mar 2022 13:37:37 -0800 Subject: [PATCH 33/87] add trash to icon css types --- client/src/features/common/Icon/icon.module.css.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/features/common/Icon/icon.module.css.d.ts b/client/src/features/common/Icon/icon.module.css.d.ts index f29150496..59645227f 100644 --- a/client/src/features/common/Icon/icon.module.css.d.ts +++ b/client/src/features/common/Icon/icon.module.css.d.ts @@ -37,6 +37,7 @@ interface CssExports { 'text': string; 'tiles': string; 'time': string; + 'trash': string; 'warn': string; 'water': string; 'water-play': string; From f55a384937c17490118e8d0111596f6cc1ff716b Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 9 Mar 2022 13:39:07 -0800 Subject: [PATCH 34/87] commit yarn lock --- yarn.lock | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/yarn.lock b/yarn.lock index 0a4aec1cd..725c00ebe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1483,6 +1483,26 @@ "@types/yargs" "^16.0.0" chalk "^4.0.0" +"@latitudegames/thoth-core@0.0.63": + version "0.0.63" + resolved "https://npm.pkg.github.com/download/@latitudegames/thoth-core/0.0.63/5988af56490f1c09d18e9c0397c84fd817c0b34967f4d10fc08b5ab11acd0d39#e543c0120b14911fcb89a703ca4b012744166370" + integrity sha512-ZkqyFlV/UU+CrbP4iISwYiVGXdiWkk9A9CnnZifkgXTMriQ5hH9twQqACr2H1OEvS7uLthX+7YtCT5VJNDYs0g== + dependencies: + deep-equal "^2.0.5" + handlebars "^4.7.7" + jsdom "^17.0.0" + license-webpack-plugin "^4.0.2" + path "^0.12.7" + react "^17.0.2" + regenerator-runtime "^0.13.9" + rete "https://github.com/latitudegames/rete.git#master" + rete-area-plugin "^0.2.1" + rete-connection-plugin "^0.9.0" + rete-context-menu-plugin "^0.6.0-rc.1" + rete-module-plugin "^0.4.1" + rete-react-render-plugin "^0.2.1" + uuid "^8.3.2" + "@lerna/add@4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/@lerna/add/-/add-4.0.0.tgz#c36f57d132502a57b9e7058d1548b7a565ef183f" @@ -12435,6 +12455,14 @@ rete-react-render-plugin@^0.2.1: resolved "https://registry.yarnpkg.com/rete-react-render-plugin/-/rete-react-render-plugin-0.2.1.tgz#71a6d73f18f850b85262563f678b40080a7b0e32" integrity sha512-2ZMXUP0v+EiejHVMqdrOmUwyDBHC2UDOJ/pFkElaZL1Kn/E40JZA5yzdBXi6ajYZI2DCzoW5ZBcA2Ihjtur8MQ== +"rete@git+https://github.com/latitudegames/rete.git#master": + version "1.4.5" + uid "24565a81a2bbcdd4cd73b0a725977550cc8ff988" + resolved "git+https://github.com/latitudegames/rete.git#24565a81a2bbcdd4cd73b0a725977550cc8ff988" + dependencies: + lodash "^4.17.21" + watch "^1.0.2" + "rete@https://github.com/latitudegames/rete.git#master": version "1.4.5" resolved "https://github.com/latitudegames/rete.git#24565a81a2bbcdd4cd73b0a725977550cc8ff988" From df783dcd31d5447a428182b05056fc0721695af7 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 16:57:21 -0800 Subject: [PATCH 35/87] Add error message types --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index ac795b067..f5bea96e9 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -10,6 +10,19 @@ type ConsoleConstructor = { throwError?: Function } +type ErrorMessage = { + errorIn: string + message: string +} + +type Message = { + errorIn: string + nodeId: number + name: string | null + error: ErrorMessage + type: 'error' | '' +} + export class ThothConsole { node: NodeData editor: IRunContextEditor From 928d1e5f046b38e3f7641d0c0934369d72b94ddc Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 16:57:40 -0800 Subject: [PATCH 36/87] Add format message helper class function --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index f5bea96e9..2c7780467 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -58,12 +58,14 @@ export class ThothConsole { this.nodeView.node.update() } - formatErrorMessage(error: any) { - const message = { - errorIn: this.node.name, + formatMessage(_message: string, type: 'error' | 'log') { + return { + from: this.node.name, nodeId: this.node.id, name: this.node.data.name || null, - errorMessage: error.message, + errorMessage: _message, + type, + } } return message From f73d5c7d717b9fbd113900aeecbfebb36c39c2c1 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 16:58:00 -0800 Subject: [PATCH 37/87] Use new format message function to format error --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index 2c7780467..5f99a3763 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -68,7 +68,8 @@ export class ThothConsole { } } - return message + formatErrorMessage(error: any) { + return this.formatMessage(error.message, 'error') } renderError() { From 98d754362da9d27cd99f59ac5e78a612962c58c2 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 17:06:02 -0800 Subject: [PATCH 38/87] Add format error message helper --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 40ceaf85c..96fdb3c88 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -32,7 +32,11 @@ const DebugConsole = ({ tab }) => { setScrollToBottom(true) } - // const formatErrorMessage = message => ({}) + const formatErrorMessage = message => + `> Node ${message.nodeId}: Error in ${message.from} component ${ + message.name ?? 'unnamed' + }.` + const printToDebugger = useCallback((_, message) => { const terminal = terminalRef.current From 0cf3bc812513fdf4ceac8d72306b0ec442f45724 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 17:06:19 -0800 Subject: [PATCH 39/87] Add format log message helper --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 96fdb3c88..45f6ab5cd 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -37,6 +37,11 @@ const DebugConsole = ({ tab }) => { message.name ?? 'unnamed' }.` + const formatLogMessage = message => + `> Node ${message.nodeId}: Message from ${message.from} component ${ + message.name ?? 'unnamed' + }.` + const printToDebugger = useCallback((_, message) => { const terminal = terminalRef.current From 0629f0956207c23f9d5555934b29125eac616e1a Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 17:06:44 -0800 Subject: [PATCH 40/87] Add error message helper function --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 45f6ab5cd..4d9c105aa 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -42,6 +42,13 @@ const DebugConsole = ({ tab }) => { message.name ?? 'unnamed' }.` + const ErrorMessage = message => ( +
+

{formatErrorMessage(message)}

+

Error message: ${message.errorMessage}

+
+
+ ) const printToDebugger = useCallback((_, message) => { const terminal = terminalRef.current From 7913464faaf639ed198d1b5d7f1b1f961698a84c Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 17:06:56 -0800 Subject: [PATCH 41/87] Add log message rendering function --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 4d9c105aa..1702053ff 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -50,6 +50,14 @@ const DebugConsole = ({ tab }) => {
) + const LogMessage = message => ( +
+

{formatLogMessage(message)}

+

${message.content}

+
+
+ ) + const printToDebugger = useCallback((_, message) => { const terminal = terminalRef.current if (!terminal) return From 0842ded48fcad993d4dcc1307e7e7d3b77346c35 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 17:07:12 -0800 Subject: [PATCH 42/87] Add get message helper function --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 1702053ff..ae9d4ddff 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -58,6 +58,11 @@ const DebugConsole = ({ tab }) => {
) + const getMessage = message => { + if (message.type === 'error') return renderToString(ErrorMessage(message)) + if (message.type === 'log') return renderToString(LogMessage(message)) + } + const printToDebugger = useCallback((_, message) => { const terminal = terminalRef.current if (!terminal) return From ae4e0f810d4fa8fb977bd3080805dc7a5104efbf Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 17:07:40 -0800 Subject: [PATCH 43/87] Use new helpers in print to debugger to log messages --- .../src/features/Thoth/windows/DebugConsole/index.tsx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index ae9d4ddff..7d2b2d757 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -67,14 +67,9 @@ const DebugConsole = ({ tab }) => { const terminal = terminalRef.current if (!terminal) return - terminal.pushToStdout( - ` - > Node ${message.nodeId}: Error in ${message.errorIn} component ${ - message.name ?? '' - }. - > ${message.errorMessage} - ` - ) + const msg = getMessage(message) + + terminal.pushToStdout(msg) scroll() }, []) From 6d8930b6e368e933cedce4b516e2942433116a6a Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 17:07:58 -0800 Subject: [PATCH 44/87] Success formating in node logic update --- client/src/features/common/Node/Node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/common/Node/Node.js b/client/src/features/common/Node/Node.js index 07dde1b9c..f507b6123 100644 --- a/client/src/features/common/Node/Node.js +++ b/client/src/features/common/Node/Node.js @@ -18,7 +18,7 @@ export class MyNode extends Node {
{node.deprecated &&
}
From f285cb7174d629e42d29d1f0e290454594911f56 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 17:08:17 -0800 Subject: [PATCH 45/87] Add terminal options and render to string import --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 7d2b2d757..1f628d6ed 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -1,4 +1,5 @@ import { useCallback, useEffect, useRef, useState } from 'react' +import { renderToString } from 'react-dom/server' import Terminal from 'react-console-emulator' import { useAuth } from '@/contexts/AuthProvider' import { usePubSub } from '@/contexts/PubSubProvider' @@ -103,8 +104,9 @@ const DebugConsole = ({ tab }) => { Date: Wed, 9 Mar 2022 17:08:34 -0800 Subject: [PATCH 46/87] Comment out console override --- core/src/plugins/debuggerPlugin/index.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index b36993696..2aef0a13f 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -6,12 +6,13 @@ function install( editor: IRunContextEditor, { server = false, throwError }: { server?: boolean; throwError?: Function } ) { - const consoleLog = console.log + // const _log = console.log - console.log = function (message) { - // if (editor.thoth.sendToDebug) editor.thoth.sendToDebug(message) - consoleLog.apply(console, arguments) - } + // console.log = function (message) { + // // if (editor.thoth.sendToDebug) editor.thoth.sendToDebug(message) + // console.warn('testing') + // return Function.prototype.bind.call(_log, arguments) + // } editor.on('componentregister', (component: ThothComponent) => { const worker = component.worker From 5153ea50bd04028fe5100f6790fd8d468a080f47 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 9 Mar 2022 17:09:06 -0800 Subject: [PATCH 47/87] Updatr thoth console --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index 5f99a3763..cb6c7b55f 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -66,7 +66,7 @@ export class ThothConsole { errorMessage: _message, type, } - } + } formatErrorMessage(error: any) { return this.formatMessage(error.message, 'error') From fff5c08803acca59bad8c505bb2810d75a21673f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 11:57:03 -0700 Subject: [PATCH 48/87] remove unused function --- client/src/features/Thoth/windows/StateManagerWindow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/StateManagerWindow.tsx b/client/src/features/Thoth/windows/StateManagerWindow.tsx index 5f924a7ec..d6422bc8c 100644 --- a/client/src/features/Thoth/windows/StateManagerWindow.tsx +++ b/client/src/features/Thoth/windows/StateManagerWindow.tsx @@ -1,9 +1,9 @@ import Editor from '@monaco-editor/react' import jsonFormat from 'json-format' +// import debounce from 'lodash.debounce' import { useSnackbar } from 'notistack' import { useState, useEffect } from 'react' import { useSelector } from 'react-redux' - import { selectSpellById, useSaveSpellMutation, From 3f927193ea12801e2947ad9e4e2e0d612f65562a Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 13:55:36 -0700 Subject: [PATCH 49/87] change debounce time to 1 second --- client/src/features/Thoth/windows/StateManagerWindow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/StateManagerWindow.tsx b/client/src/features/Thoth/windows/StateManagerWindow.tsx index d6422bc8c..53afd652c 100644 --- a/client/src/features/Thoth/windows/StateManagerWindow.tsx +++ b/client/src/features/Thoth/windows/StateManagerWindow.tsx @@ -72,7 +72,7 @@ const StateManager = ({ tab, ...props }) => { // Send Axios request here onSave() setTyping(false) - }, 2000) + }, 1000) return () => clearTimeout(delayDebounceFn) }, [code]) From 9514b218ff3540eb6432eb33beca89cbf4d5abb5 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 13:56:23 -0700 Subject: [PATCH 50/87] set response to state if no error --- client/src/features/Thoth/windows/StateManagerWindow.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/StateManagerWindow.tsx b/client/src/features/Thoth/windows/StateManagerWindow.tsx index 53afd652c..b3e751217 100644 --- a/client/src/features/Thoth/windows/StateManagerWindow.tsx +++ b/client/src/features/Thoth/windows/StateManagerWindow.tsx @@ -100,7 +100,10 @@ const StateManager = ({ tab, ...props }) => { ...spell, gameState: parsedState, } - saveSpell(spellUpdate) + const res = await saveSpell(spellUpdate) + if ('error' in res) return + res.data.gameState && setCode(JSON.stringify(res.data.gameState?.state)) + enqueueSnackbar('State saved', { preventDuplicate: true, variant: 'success', From a3a1c6e1d1bc819514af293408f2c24edb9467b2 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 13:57:19 -0700 Subject: [PATCH 51/87] add async to onSave --- client/src/features/Thoth/windows/StateManagerWindow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/StateManagerWindow.tsx b/client/src/features/Thoth/windows/StateManagerWindow.tsx index b3e751217..68410a11a 100644 --- a/client/src/features/Thoth/windows/StateManagerWindow.tsx +++ b/client/src/features/Thoth/windows/StateManagerWindow.tsx @@ -93,7 +93,7 @@ const StateManager = ({ tab, ...props }) => { setTyping(true) } - const onSave = () => { + const onSave = async () => { if (!gameState) return const parsedState = JSON.parse(code) const spellUpdate = { From 4280ba2d9fae2d62b5de527b01b4d00b70fa0819 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 13:58:00 -0700 Subject: [PATCH 52/87] hook up saving to manual save button --- client/src/features/Thoth/windows/StateManagerWindow.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/StateManagerWindow.tsx b/client/src/features/Thoth/windows/StateManagerWindow.tsx index 68410a11a..ddab16489 100644 --- a/client/src/features/Thoth/windows/StateManagerWindow.tsx +++ b/client/src/features/Thoth/windows/StateManagerWindow.tsx @@ -112,7 +112,9 @@ const StateManager = ({ tab, ...props }) => { const toolbar = ( <> - + From 4c75b24d2e363dbc4e941715e0e09b3973d29e5b Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 13:59:08 -0700 Subject: [PATCH 53/87] add a setGameSatte reducer --- client/src/state/gameState.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client/src/state/gameState.ts b/client/src/state/gameState.ts index 95105d563..566447d5f 100644 --- a/client/src/state/gameState.ts +++ b/client/src/state/gameState.ts @@ -21,6 +21,19 @@ const gameStateSlice = createSlice({ name: 'gameState', initialState, reducers: { + setGameState: (state, action) => { + const gameState = selectGameStateBySpellId(state, action.payload.spellId) + + if (!gameState) { + gameStateAdapater.addOne(state, { id: uuidv4(), ...action.payload }) + } else { + const payload = { + id: gameState.id, + ...action.payload.state, + } + gameStateAdapater.setOne(state, payload) + } + }, updateGameState: (state, action) => { const gameState = selectGameStateBySpellId(state, action.payload.spellId) From b58ab255a602aa299949421b147ac8367491ef23 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 13:59:37 -0700 Subject: [PATCH 54/87] export and destructure new setGameState --- client/src/state/gameState.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/state/gameState.ts b/client/src/state/gameState.ts index 566447d5f..8cba491a9 100644 --- a/client/src/state/gameState.ts +++ b/client/src/state/gameState.ts @@ -71,5 +71,6 @@ export const selectGameStateBySpellId = createDraftSafeSelector( ) export const { selectById } = gameStateSelectors -export const { updateGameState, createGameState } = gameStateSlice.actions +export const { updateGameState, createGameState, setGameState } = + gameStateSlice.actions export default gameStateSlice.reducer From 0c2c8c74a664e8280b9053e2115ad2313f44e74f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 13:59:57 -0700 Subject: [PATCH 55/87] import setGameState into spells --- client/src/state/api/spells.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/state/api/spells.ts b/client/src/state/api/spells.ts index b26758a6d..4b2451b27 100644 --- a/client/src/state/api/spells.ts +++ b/client/src/state/api/spells.ts @@ -4,7 +4,7 @@ import { Spell as SpellType } from '@latitudegames/thoth-core/types' import { initDB } from '../../database' import { QueryReturnValue } from '@reduxjs/toolkit/dist/query/baseQueryTypes' -import { updateGameState } from '../gameState' +import { setGameState, updateGameState } from '../gameState' import { Module } from '../../database/schemas/module' import { rootApi } from './api' // function camelize(str) { From 249f651c2bbf5b0504a6544e1a36f6d89d7092e8 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 14:02:08 -0700 Subject: [PATCH 56/87] swap save spell to use setGameState --- client/src/state/api/spells.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/state/api/spells.ts b/client/src/state/api/spells.ts index 4b2451b27..dfede47d9 100644 --- a/client/src/state/api/spells.ts +++ b/client/src/state/api/spells.ts @@ -85,7 +85,7 @@ export const spellApi = rootApi.injectEndpoints({ if (spell.gameState) dispatch( - updateGameState({ state: spell.gameState, spellId: spell.name }) + setGameState({ state: spell.gameState, spellId: spell.name }) ) spell.modules = modules From 0cf7423d315c2a829e3d3d7c6c3f32f52dab6be5 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 15:40:05 -0700 Subject: [PATCH 57/87] import useNewSpell mutation into FileInput --- client/src/features/HomeScreen/HomeScreen.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/features/HomeScreen/HomeScreen.tsx b/client/src/features/HomeScreen/HomeScreen.tsx index ae8b30412..59312de16 100644 --- a/client/src/features/HomeScreen/HomeScreen.tsx +++ b/client/src/features/HomeScreen/HomeScreen.tsx @@ -4,6 +4,7 @@ import { Route, Routes, useNavigate } from 'react-router-dom' import { useGetSpellsQuery, useDeleteSpellMutation, + useNewSpellMutation, } from '../../state/api/spells' import { useDB } from '../../contexts/DatabaseProvider' import { useTabManager } from '../../contexts/TabManagerProvider' From 04611abd12835116d636bbba20c25755bc09dc55 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 15:40:16 -0700 Subject: [PATCH 58/87] implement newSpell hook --- client/src/features/HomeScreen/HomeScreen.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/features/HomeScreen/HomeScreen.tsx b/client/src/features/HomeScreen/HomeScreen.tsx index 59312de16..cbbd77568 100644 --- a/client/src/features/HomeScreen/HomeScreen.tsx +++ b/client/src/features/HomeScreen/HomeScreen.tsx @@ -24,6 +24,7 @@ const StartScreen = () => { const [deleteSpell] = useDeleteSpellMutation() const { data: spells } = useGetSpellsQuery() + const [newSpell] = useNewSpellMutation() const onReaderLoad = async event => { const spellData = JSON.parse(event.target.result) From cc0bec05e9cca4571e345a7625744fb2e94c2b32 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 14 Mar 2022 15:40:40 -0700 Subject: [PATCH 59/87] add in missing newSpell mutation when importing file --- client/src/features/HomeScreen/HomeScreen.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/src/features/HomeScreen/HomeScreen.tsx b/client/src/features/HomeScreen/HomeScreen.tsx index cbbd77568..86e327db8 100644 --- a/client/src/features/HomeScreen/HomeScreen.tsx +++ b/client/src/features/HomeScreen/HomeScreen.tsx @@ -42,6 +42,12 @@ const StartScreen = () => { }) ) + // Create new spell + await newSpell({ + chain: spellData.chain, + name: spellData.name, + }) + await openTab({ name: spellData.name, spellId: spellData.name, From 953e434eb6db14edd97bb08fb71a32f22979c45c Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:28:54 -0700 Subject: [PATCH 60/87] Clean up message component in debug window --- .../Thoth/windows/DebugConsole/index.tsx | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 1f628d6ed..39a8af5c9 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -43,25 +43,28 @@ const DebugConsole = ({ tab }) => { message.name ?? 'unnamed' }.` - const ErrorMessage = message => ( -
-

{formatErrorMessage(message)}

-

Error message: ${message.errorMessage}

-
-
- ) - - const LogMessage = message => ( -
-

{formatLogMessage(message)}

+ const Message = (message, type) => ( +
+

+ {type === 'error' + ? formatErrorMessage(message) + : formatLogMessage(message)} +

${message.content}


) const getMessage = message => { - if (message.type === 'error') return renderToString(ErrorMessage(message)) - if (message.type === 'log') return renderToString(LogMessage(message)) + if (message.type === 'error') + return renderToString(Message(message, message.type)) + if (message.type === 'log') + return renderToString(Message(message, message.type)) } const printToDebugger = useCallback((_, message) => { From 4d6e03e24fc72f859b5625c8360754a810eebd06 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:29:53 -0700 Subject: [PATCH 61/87] Clean up message types --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index cb6c7b55f..5601fd7ff 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -10,17 +10,12 @@ type ConsoleConstructor = { throwError?: Function } -type ErrorMessage = { - errorIn: string - message: string -} - -type Message = { - errorIn: string +export type Message = { + from: string nodeId: number name: string | null - error: ErrorMessage - type: 'error' | '' + content?: string + type: 'error' | 'log' } export class ThothConsole { From 9b45f740ec6150f1c122b9b3fd44883d716d8894 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:30:09 -0700 Subject: [PATCH 62/87] Use message type in format message --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index 5601fd7ff..e1509e8fd 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -53,12 +53,12 @@ export class ThothConsole { this.nodeView.node.update() } - formatMessage(_message: string, type: 'error' | 'log') { + formatMessage(_message: string, type: 'error' | 'log'): Message { return { from: this.node.name, nodeId: this.node.id, - name: this.node.data.name || null, - errorMessage: _message, + name: (this.node?.data?.name as string) ?? null, + content: _message, type, } } From 8d3c520167a668114cf741717a84a35eaa5caa14 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:30:22 -0700 Subject: [PATCH 63/87] Rename render success to render log --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index e1509e8fd..d7b5217e7 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -73,7 +73,7 @@ export class ThothConsole { this.node.data.error = false } - renderSuccess() { + renderLog() { this.node.data.success = true this.updateNodeView() this.node.data.success = false From 62037c32af8c404f54528840492bf694563452ec Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:30:33 -0700 Subject: [PATCH 64/87] Fill out log function on terminal --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index d7b5217e7..ee3e22c9a 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -79,8 +79,11 @@ export class ThothConsole { this.node.data.success = false } - log(message: any) { - this.sendToDebug(message) + log(_message: any) { + const message = + typeof _message !== 'string' ? JSON.stringify(_message) : _message + this.sendToDebug(this.formatMessage(message, 'log')) + this.renderLog() } error(error: any) { From 297ecd5b68910243ab83d2c455b62791e38ffd6e Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:37:06 -0700 Subject: [PATCH 65/87] Rename debugger window to console --- client/src/contexts/layouts/defaultLayout.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/contexts/layouts/defaultLayout.json b/client/src/contexts/layouts/defaultLayout.json index eabd99f28..a526a2fb5 100644 --- a/client/src/contexts/layouts/defaultLayout.json +++ b/client/src/contexts/layouts/defaultLayout.json @@ -48,7 +48,7 @@ { "type": "tab", "id": "44", - "name": "Debug Console", + "name": "Console", "component": "debugConsole", "className": "debug-console" } From b4651f59e101e2bd6bd6ab5a8203e3d29cd9a85a Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:37:32 -0700 Subject: [PATCH 66/87] Use ndoe.console.log in debugger plugin --- core/src/plugins/debuggerPlugin/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 2aef0a13f..c68d5b30b 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -35,7 +35,7 @@ function install( ...args, ]) - node.console.renderSuccess() + node.console.log(result) return result } catch (error: any) { From 525d7a96f37c3d3e3a57e627eca6ac91b36181ae Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:51:57 -0700 Subject: [PATCH 67/87] Add node ID to each node --- client/src/features/common/Node/Node.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/src/features/common/Node/Node.js b/client/src/features/common/Node/Node.js index f507b6123..76d1ad3ca 100644 --- a/client/src/features/common/Node/Node.js +++ b/client/src/features/common/Node/Node.js @@ -21,6 +21,9 @@ export class MyNode extends Node { } ${css[hasSuccess ? 'success' : '']}`} > {node.deprecated &&
} +
+

{node.id}

+
Date: Mon, 14 Mar 2022 16:52:11 -0700 Subject: [PATCH 68/87] Add position styling to node id in node --- client/src/features/common/Node/Node.module.css | 5 +++++ client/src/features/common/Node/Node.module.css.d.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/client/src/features/common/Node/Node.module.css b/client/src/features/common/Node/Node.module.css index dc203d3af..9e6b9e006 100644 --- a/client/src/features/common/Node/Node.module.css +++ b/client/src/features/common/Node/Node.module.css @@ -38,6 +38,11 @@ bottom: 0; opacity: 0.2; } +.node-id { + position: absolute; + top: -5px; + right: 10px; +} .node-title { /* font-family: 'IBM Plex Mono', monospace !important; */ /* text-transform: uppercase; */ diff --git a/client/src/features/common/Node/Node.module.css.d.ts b/client/src/features/common/Node/Node.module.css.d.ts index 06b95ee1f..46fdd2f27 100644 --- a/client/src/features/common/Node/Node.module.css.d.ts +++ b/client/src/features/common/Node/Node.module.css.d.ts @@ -10,6 +10,7 @@ interface CssExports { 'input': string; 'node': string; 'node-depricated': string; + 'node-id': string; 'node-title': string; 'nodeGenesis': string; 'out': string; From 21a1ecd9d240b27a038ec7616616c33222ded4a1 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:55:06 -0700 Subject: [PATCH 69/87] Add error showing for NODE id --- client/src/features/common/Node/Node.module.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/features/common/Node/Node.module.css b/client/src/features/common/Node/Node.module.css index 9e6b9e006..eecfd6342 100644 --- a/client/src/features/common/Node/Node.module.css +++ b/client/src/features/common/Node/Node.module.css @@ -42,6 +42,10 @@ position: absolute; top: -5px; right: 10px; + color: var(--dark-4); +} +.node-id.error { + color: var(--red); } .node-title { /* font-family: 'IBM Plex Mono', monospace !important; */ From 16428e73d6095c90f19055409d65529da2c7de18 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:57:48 -0700 Subject: [PATCH 70/87] Add error highlting to node id --- client/src/features/common/Node/Node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/common/Node/Node.js b/client/src/features/common/Node/Node.js index 76d1ad3ca..b4bee87fc 100644 --- a/client/src/features/common/Node/Node.js +++ b/client/src/features/common/Node/Node.js @@ -21,7 +21,7 @@ export class MyNode extends Node { } ${css[hasSuccess ? 'success' : '']}`} > {node.deprecated &&
} -
+

{node.id}

From 69ef2027dcdafe1e7449dbe6b19a894080a996e8 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:59:11 -0700 Subject: [PATCH 71/87] Add success style to node id --- client/src/features/common/Node/Node.module.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/src/features/common/Node/Node.module.css b/client/src/features/common/Node/Node.module.css index eecfd6342..d2fcbeadc 100644 --- a/client/src/features/common/Node/Node.module.css +++ b/client/src/features/common/Node/Node.module.css @@ -47,6 +47,9 @@ .node-id.error { color: var(--red); } +.node-id.success { + color: var(--green); +} .node-title { /* font-family: 'IBM Plex Mono', monospace !important; */ /* text-transform: uppercase; */ From 136bf252b71c00b22308d4817fbd51f219e5abd2 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 14 Mar 2022 16:59:20 -0700 Subject: [PATCH 72/87] highlight node id with success color --- client/src/features/common/Node/Node.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/features/common/Node/Node.js b/client/src/features/common/Node/Node.js index b4bee87fc..668924a95 100644 --- a/client/src/features/common/Node/Node.js +++ b/client/src/features/common/Node/Node.js @@ -21,7 +21,11 @@ export class MyNode extends Node { } ${css[hasSuccess ? 'success' : '']}`} > {node.deprecated &&
} -
+

{node.id}

From 22335fe27a8e65297f755a02f030d81fa293e4af Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 15 Mar 2022 10:22:25 -0700 Subject: [PATCH 73/87] Fix for server run error in console --- core/src/plugins/debuggerPlugin/ThothConsole.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/ThothConsole.ts b/core/src/plugins/debuggerPlugin/ThothConsole.ts index ee3e22c9a..02336b4e7 100644 --- a/core/src/plugins/debuggerPlugin/ThothConsole.ts +++ b/core/src/plugins/debuggerPlugin/ThothConsole.ts @@ -39,6 +39,7 @@ export class ThothConsole { this.isServer = server if (throwError) this.throwError = throwError + if (server) return const nodeValues = Array.from(editor.view.nodes) const foundNode = nodeValues.find(([, n]) => n.node.id === node.id) @@ -80,6 +81,8 @@ export class ThothConsole { } log(_message: any) { + if (this.isServer) return + const message = typeof _message !== 'string' ? JSON.stringify(_message) : _message this.sendToDebug(this.formatMessage(message, 'log')) @@ -88,9 +91,12 @@ export class ThothConsole { error(error: any) { const message = this.formatErrorMessage(error) - this.sendToDebug(message) this.throwServerError(message) - this.renderError() + + if (!this.isServer) { + this.sendToDebug(message) + this.renderError() + } } sendSuccess(result: any) {} From d2e88f6af93a82bfc7b47b3c3e5f850b0a54e4ea Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 16 Mar 2022 10:51:10 -0700 Subject: [PATCH 74/87] Update gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bc67036a9..e7ee0a97d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ build .vscode/chrome # Generated Styles for AreaPlugin -core/src/plugins/areaPlugin/style.css.d.ts \ No newline at end of file +core/src/plugins/areaPlugin/style.css.d.ts +.idea \ No newline at end of file From cbecf206e36950fabc0a68ee330441ff48db2e83 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 16 Mar 2022 10:51:55 -0700 Subject: [PATCH 75/87] One more gitignore update --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e7ee0a97d..2a5910af1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ build # Generated Styles for AreaPlugin core/src/plugins/areaPlugin/style.css.d.ts -.idea \ No newline at end of file +.idea +server/.env \ No newline at end of file From f465b84a29229c327044b7a7bc6b4b5ba4884863 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 16 Mar 2022 12:35:45 -0700 Subject: [PATCH 76/87] import EngineContext into Code component --- core/src/components/Code.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/components/Code.ts b/core/src/components/Code.ts index 8c7d86cc6..d13b53ad6 100644 --- a/core/src/components/Code.ts +++ b/core/src/components/Code.ts @@ -12,6 +12,7 @@ import { CodeControl } from '../dataControls/CodeControl' //@ts-ignore import { InputControl } from '../dataControls/InputControl' import { SocketGeneratorControl } from '../dataControls/SocketGenerator' +import { EngineContext } from '../engine' import { triggerSocket } from '../sockets' import { ThothComponent } from '../thoth-component' From 5f891f7744b862d98535e4c2ffe96c4062c192f2 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 16 Mar 2022 12:37:10 -0700 Subject: [PATCH 77/87] destructure thoth into code worker --- core/src/components/Code.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/components/Code.ts b/core/src/components/Code.ts index d13b53ad6..040f902f6 100644 --- a/core/src/components/Code.ts +++ b/core/src/components/Code.ts @@ -89,7 +89,11 @@ export class Code extends ThothComponent { node: NodeData, inputs: ThothWorkerInputs, outputs: ThothWorkerOutputs, - { silent, data }: { silent: boolean; data: { code: unknown } } + { + silent, + data, + thoth, + }: { silent: boolean; thoth: EngineContext; data: { code: unknown } } ) { function runCodeWithArguments(obj: unknown) { const flattenedInputs = Object.entries(inputs).reduce( From a534cd7ac62a667b0bc30f25cb3c81168ffe81f0 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 16 Mar 2022 12:37:41 -0700 Subject: [PATCH 78/87] uitilize processCode from interface rather than in component --- core/src/components/Code.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/core/src/components/Code.ts b/core/src/components/Code.ts index 040f902f6..0ef3353c7 100644 --- a/core/src/components/Code.ts +++ b/core/src/components/Code.ts @@ -95,20 +95,8 @@ export class Code extends ThothComponent { thoth, }: { silent: boolean; thoth: EngineContext; data: { code: unknown } } ) { - function runCodeWithArguments(obj: unknown) { - const flattenedInputs = Object.entries(inputs).reduce( - (acc, [key, value]) => { - acc[key as string] = value[0] - return acc - }, - {} as Record - ) - // eslint-disable-next-line no-new-func - return Function('"use strict";return (' + obj + ')')()( - flattenedInputs, - data - ) - } + const { processCode } = thoth + if (!processCode) return try { const value = runCodeWithArguments(node.data.code) From 2006d68406f587382cc5ede98500570ab080423b Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 16 Mar 2022 12:38:08 -0700 Subject: [PATCH 79/87] call processCode with arguments --- core/src/components/Code.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/components/Code.ts b/core/src/components/Code.ts index 0ef3353c7..59ba6ed59 100644 --- a/core/src/components/Code.ts +++ b/core/src/components/Code.ts @@ -99,7 +99,9 @@ export class Code extends ThothComponent { if (!processCode) return try { - const value = runCodeWithArguments(node.data.code) + // const value = runCodeWithArguments(node.data.code) + const value = processCode(node.data.code, inputs, data) + if (!silent) node.display(`${JSON.stringify(value)}`) return value From 69175db2ec5583fe9339b977ff7024996fe80003 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 16 Mar 2022 12:38:26 -0700 Subject: [PATCH 80/87] add processCode to engine context --- core/src/engine.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/engine.ts b/core/src/engine.ts index 259ab8d00..4d3242967 100644 --- a/core/src/engine.ts +++ b/core/src/engine.ts @@ -63,6 +63,11 @@ export type EngineContext = { onInspector?: Function sendToInspector?: Function clearTextEditor?: Function + processCode?: ( + code: unknown, + inputs: ThothWorkerInputs, + data: Record + ) => void } export type InitEngineArguments = { From 3ff843540898e3de1e41968084ebbbffa88e6521 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 16 Mar 2022 12:38:56 -0700 Subject: [PATCH 81/87] import ThothWorkerInputs type into rete provider --- client/src/features/Thoth/contexts/ReteProvider.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index bd3f171fd..1095f0dc4 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -14,6 +14,8 @@ import { useDB } from '../../../contexts/DatabaseProvider' import { usePubSub } from '../../../contexts/PubSubProvider' import { useFetchFromImageCacheMutation } from '@/state/api/visualGenerationsApi' import { ModelsType } from '../../../types' +import { ThothWorkerInputs } from '@latitudegames/thoth-core/types' + /* Some notes here. The new rete provider, not to be confused with the old rete provider renamed to the editor provider, is designed to serve as the single source of truth for interfacing with the rete internal system. This unified interface will also allow us to replicate the same API in the server, where rete expects certain functions to exist but doesn't care what is behind these functions so long as they work. Not all functions will be needed on the server, and functions which are not will be labeled as such. From 50e25266650fa4f3fd3605f4eddb305f2fda5436 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 16 Mar 2022 12:39:11 -0700 Subject: [PATCH 82/87] add processCode to rete context --- client/src/features/Thoth/contexts/ReteProvider.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index 1095f0dc4..73ae28255 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -35,6 +35,11 @@ export interface ReteContext extends EngineContext { getCurrentGameState: () => Record updateCurrentGameState: (update) => void readFromImageCache: (caption, cacheTag, topK) => Promise> + processCode: ( + code: unknown, + inputs: ThothWorkerInputs, + data: Record + ) => void } const Context = createContext(undefined!) From e4da7a0e0635ad55302e0b2aae2af27b284abc61 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 16 Mar 2022 12:39:33 -0700 Subject: [PATCH 83/87] add processCode helper --- .../src/features/Thoth/contexts/ReteProvider.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index 73ae28255..82bff7a73 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -144,6 +144,21 @@ const ReteProvider = ({ children, tab }) => { return result } + const processCode = (code, inputs, data) => { + const flattenedInputs = Object.entries(inputs as ThothWorkerInputs).reduce( + (acc, [key, value]) => { + acc[key as string] = value[0] + return acc + }, + {} as Record + ) + // eslint-disable-next-line no-new-func + return Function('"use strict";return (' + code + ')')()( + flattenedInputs, + data + ) + } + const clearTextEditor = () => { publish($TEXT_EDITOR_CLEAR(tab.id)) } From 2fc68c03b4d352a8fc796400fca5ab7902f408ea Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 16 Mar 2022 12:39:48 -0700 Subject: [PATCH 84/87] add processCode to public interface --- client/src/features/Thoth/contexts/ReteProvider.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index 82bff7a73..8fc076d16 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -197,6 +197,7 @@ const ReteProvider = ({ children, tab }) => { readFromImageCache, getCurrentGameState, updateCurrentGameState, + processCode, ...models.modules, // going to need to manuall create theses From 4eda946be6038de7d5e726348d245410d771bfa0 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 16 Mar 2022 15:14:30 -0700 Subject: [PATCH 85/87] fix readFromImage cache output --- client/src/features/Thoth/contexts/ReteProvider.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index 8fc076d16..51c4948b5 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -141,7 +141,8 @@ const ReteProvider = ({ children, tab }) => { cacheTag, topK, }) - return result + if ('error' in result) return {} + return { outputs: [result.data] } } const processCode = (code, inputs, data) => { From fadf2292a945f7beb2adcec3b3ecf590c46d2a3e Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 16 Mar 2022 16:01:29 -0700 Subject: [PATCH 86/87] Bump core to 0.0.65 --- core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index c4fdcc956..ec81926bc 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@latitudegames/thoth-core", - "version": "0.0.64", + "version": "0.0.65", "license": "Apache-2.0", "author": "Michael Sharpe (https://www.project89.org)", "contributors": [ From 90a706c59ca9c83b16c7b2df6e59b4b7d072d297 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Wed, 16 Mar 2022 16:19:49 -0700 Subject: [PATCH 87/87] Bump 0.0.64 back --- core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index ec81926bc..c4fdcc956 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@latitudegames/thoth-core", - "version": "0.0.65", + "version": "0.0.64", "license": "Apache-2.0", "author": "Michael Sharpe (https://www.project89.org)", "contributors": [