From 1eac6668e36132c89475ce9524df09bc822928b9 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 09:43:31 -0800 Subject: [PATCH 001/295] commit yarn lock --- yarn.lock | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index a95faa2e1..03d8cb8ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1476,6 +1476,25 @@ "@types/yargs" "^16.0.0" chalk "^4.0.0" +"@latitudegames/thoth-core@^0.0.59": + version "0.0.59" + resolved "https://npm.pkg.github.com/download/@latitudegames/thoth-core/0.0.59/4735bade8814e4d561b226d1a2eb92e23307bb24fe3e6242bc53774d4da44c4b#d225d3cc8bd5ec0a24b4b534731b0d8a9c7890ff" + integrity sha512-1SbwmWpTyO+f1wE/auXecAgUudEcCKb7giDWrSgCT3tflOKDYE1bb6RJvIVEUYRmCGvoeM8CQXt8aTPLoWvtJw== + dependencies: + deep-equal "^2.0.5" + handlebars "^4.7.7" + jsdom "^17.0.0" + 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" @@ -12375,14 +12394,6 @@ 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 944d91dedd9bd34b48a380aee99bfcf8703c7104 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 10:20:52 -0800 Subject: [PATCH 002/295] add react console emulator --- client/package.json | 1 + yarn.lock | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/client/package.json b/client/package.json index e515bdd25..0ff79aebd 100644 --- a/client/package.json +++ b/client/package.json @@ -39,6 +39,7 @@ "prismjs": "^1.24.0", "pubsub-js": "^1.9.3", "react": "^17.0.2", + "react-console-emulator": "^5.0.1", "react-custom-scrollbars": "^4.2.1", "react-dom": "^17.0.2", "react-hook-form": "^7.15.4", diff --git a/yarn.lock b/yarn.lock index 03d8cb8ec..c1e0c8741 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11772,6 +11772,17 @@ rc@^1.2.8, rc@~1.2.7: minimist "^1.2.0" strip-json-comments "~2.0.1" +react-console-emulator@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/react-console-emulator/-/react-console-emulator-5.0.1.tgz#c4fc8b298b6278d4fc4091ee612051ac8a569596" + integrity sha512-BgLkZhyOkx1RQJOzeQtsATFaAzDuBVKwKwrq1fLNcjoUQ5h+et7RmPTopIfpGI8kP9VzhcqawM5cYWDO47QP5w== + dependencies: + defaults "^1.0.3" + prop-types "^15.7.2" + react-fast-compare "^3.2.0" + react-inner-html "^1.0.1" + react-innertext "^1.1.5" + react-custom-scrollbars@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/react-custom-scrollbars/-/react-custom-scrollbars-4.2.1.tgz#830fd9502927e97e8a78c2086813899b2a8b66db" @@ -11790,6 +11801,11 @@ react-dom@^17.0.2: object-assign "^4.1.1" scheduler "^0.20.2" +react-fast-compare@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb" + integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA== + react-hook-form@^7.15.4: version "7.16.1" resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.16.1.tgz#669046df378a71949e5cf8a2398cbe20d5cb27bc" @@ -11807,6 +11823,16 @@ react-icons@^4.2.0: resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-4.2.0.tgz#6dda80c8a8f338ff96a1851424d63083282630d0" integrity sha512-rmzEDFt+AVXRzD7zDE21gcxyBizD/3NqjbX6cmViAgdqfJ2UiLer8927/QhhrXQV7dEj/1EGuOTPp7JnLYVJKQ== +react-inner-html@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/react-inner-html/-/react-inner-html-1.0.1.tgz#23258d44e151d3220f4aebbeb67c14a6b9980abb" + integrity sha512-q8d/OGRhk6gM6cfwzNj8IXwf5MKSDOpYAvpkCY5x/qHUCRmN4jVc4ah041QnsuEGakly4Gw7DhCQTswCf03rqg== + +react-innertext@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/react-innertext/-/react-innertext-1.1.5.tgz#8147ac54db3f7067d95f49e2d2c05a720d27d8d0" + integrity sha512-PWAqdqhxhHIv80dT9znP2KvS+hfkbRovFp4zFYHFFlOoQLRiawIic81gKb3U1wEyJZgMwgs3JoLtwryASRWP3Q== + react-input-autosize@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/react-input-autosize/-/react-input-autosize-3.0.0.tgz#6b5898c790d4478d69420b55441fcc31d5c50a85" From eaf65da5c84890d7c9cb7205a584b2dfaafbba5e Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 10:21:29 -0800 Subject: [PATCH 003/295] add CREATE_DEBUG_CONSOLE event to pubsub provider --- client/src/contexts/PubSubProvider.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/contexts/PubSubProvider.jsx b/client/src/contexts/PubSubProvider.jsx index 14e4ba120..3ed11ca3f 100644 --- a/client/src/contexts/PubSubProvider.jsx +++ b/client/src/contexts/PubSubProvider.jsx @@ -31,6 +31,7 @@ export const events = { $CREATE_PLAYTEST: tabId => `createPlaytest:${tabId}`, $CREATE_INSPECTOR: tabId => `createInspector:${tabId}`, $CREATE_TEXT_EDITOR: tabId => `createTextEditor:${tabId}`, + $CREATE_DEBUG_CONSOLE: tabId => `createDebugConsole:${tabId}`, $SERIALIZE: tabId => `serialize:${tabId}`, $EXPORT: tabId => `export:${tabId}`, $UNDO: tabId => `undo:${tabId}`, From a05eaf140b14816e2381fc42ed60614803b0d572 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 10:21:47 -0800 Subject: [PATCH 004/295] create initial DebugConsole component --- .../Thoth/windows/DebugConsole/index.tsx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 client/src/features/Thoth/windows/DebugConsole/index.tsx diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx new file mode 100644 index 000000000..4532237ca --- /dev/null +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -0,0 +1,25 @@ +import Terminal from 'react-console-emulator' +import { useAuth } from '@/contexts/AuthProvider' + +const commands = { + echo: { + description: 'Echo a passed string.', + usage: 'echo ', + fn: function () { + return `${Array.from(arguments).join(' ')}` + }, + }, +} + +const DebugConsole = props => { + const { user } = useAuth() + return ( + + ) +} + +export default DebugConsole From c07e695cd69c9fb5c62c468556528470d1f0f361 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 10:23:31 -0800 Subject: [PATCH 005/295] add debug console to factory --- client/src/features/Thoth/workspaces/composer/index.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/src/features/Thoth/workspaces/composer/index.tsx b/client/src/features/Thoth/workspaces/composer/index.tsx index b401d809e..dedac2ba4 100644 --- a/client/src/features/Thoth/workspaces/composer/index.tsx +++ b/client/src/features/Thoth/workspaces/composer/index.tsx @@ -16,6 +16,7 @@ import Inspector from '@thoth/windows/InspectorWindow' import Playtest from '@thoth/windows/PlaytestWindow' import StateManager from '@thoth/windows/StateManagerWindow' import TextEditor from '@thoth/windows/TextEditorWindow' +import DebugConsole from '@thoth/windows/DebugConsole' const Workspace = ({ tab, tabs, pubSub }) => { const [loadSpell, { data: spellData }] = useLazyGetSpellQuery() @@ -79,6 +80,8 @@ const Workspace = ({ tab, tabs, pubSub }) => { return case 'editorWindow': return + case 'debugConsole': + return default: return

} From 76c94061a731f9e0a4bc3c8c082baaae27653f3d Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 16:27:04 -0800 Subject: [PATCH 006/295] add debug console to default layout --- client/src/contexts/layouts/defaultLayout.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/src/contexts/layouts/defaultLayout.json b/client/src/contexts/layouts/defaultLayout.json index 9fc421550..4066e96c0 100644 --- a/client/src/contexts/layouts/defaultLayout.json +++ b/client/src/contexts/layouts/defaultLayout.json @@ -35,6 +35,21 @@ ], "active": true }, + { + "type": "tabset", + "id": "#17", + "weight": 50, + "children": [ + { + "type": "tab", + "id": "44", + "name": "Debug Console", + "component": "debugConsole", + "className": "debug-console" + } + ], + "active": true + }, { "type": "row", "id": "#7", From 296e287205799e66c969979d9e7a65d9bde38cff Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 16:28:07 -0800 Subject: [PATCH 007/295] add sendToDebug and onDebug to rete interface --- 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 35c0ad51a..b972f71ae 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -24,6 +24,8 @@ export interface ReteContext extends EngineContext { onGameState: () => void sendToPlaytest: () => void sendToInspector: () => void + sendToDebug: () => void + onDebug: () => void clearTextEditor: () => void getSpell: () => void getModule: () => void From bacfd12379689f759fbfbe31aa8f8adbad16ca25 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 16:28:28 -0800 Subject: [PATCH 008/295] add sendToDebug and onDebug to context --- 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 b972f71ae..e0f7078b6 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -46,6 +46,8 @@ const Context = createContext({ onModuleUpdated: () => {}, sendToPlaytest: () => {}, sendToInspector: () => {}, + sendToDebug: () => {}, + onDebug: () => {}, clearTextEditor: () => {}, getSpell: () => {}, getModule: () => {}, From 1f4cd74e824b1a468ec58de875f086b6bfd424d0 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 16:29:08 -0800 Subject: [PATCH 009/295] add DEBUG_PRINT and DEBUG_INPUT to rete events --- 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 e0f7078b6..5228d28cf 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -80,6 +80,8 @@ const ReteProvider = ({ children, tab }) => { $PLAYTEST_INPUT, $PLAYTEST_PRINT, $INSPECTOR_SET, + $DEBUG_PRINT, + $DEBUG_INPUT, $TEXT_EDITOR_CLEAR, $NODE_SET, ADD_MODULE, From 6a2f5face80f2d4b7cee29acf91d24b378ac9746 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 16:29:25 -0800 Subject: [PATCH 010/295] add sendToDebug helper --- client/src/features/Thoth/contexts/ReteProvider.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index 5228d28cf..6caa9e4f6 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -123,6 +123,10 @@ const ReteProvider = ({ children, tab }) => { publish($INSPECTOR_SET(tab.id), data) } + const sendToDebug = data => { + publish($DEBUG_PRINT(tab.id), data) + } + const sendToPlaytest = data => { publish($PLAYTEST_PRINT(tab.id), data) } From 3cb60307d6a40c705c9ea696a18ec0e05b348731 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 16:29:35 -0800 Subject: [PATCH 011/295] add onDebug helper --- client/src/features/Thoth/contexts/ReteProvider.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index 6caa9e4f6..27c184bed 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -127,6 +127,12 @@ const ReteProvider = ({ children, tab }) => { publish($DEBUG_PRINT(tab.id), data) } + const onDebug = (node, callback) => { + return subscribe($DEBUG_INPUT(tab.id, node.id), (event, data) => { + callback(data) + }) + } + const sendToPlaytest = data => { publish($PLAYTEST_PRINT(tab.id), data) } From bf504b47eb3cfa58fad6a931c402c78f54248235 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 16:29:50 -0800 Subject: [PATCH 012/295] add sendToDebug and onDebug to public interface --- 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 27c184bed..cfb2fa9f8 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -185,6 +185,8 @@ const ReteProvider = ({ children, tab }) => { onDeleteModule, onModuleUpdated, sendToInspector, + sendToDebug, + onDebug, sendToPlaytest, onPlaytest, clearTextEditor, From d0ad6995dd24b1f403953b29c927b920a89b0114 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 16:30:25 -0800 Subject: [PATCH 013/295] add DEBUG_PRINT and DEBUG_INPUT to pubsub events --- client/src/contexts/PubSubProvider.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/contexts/PubSubProvider.jsx b/client/src/contexts/PubSubProvider.jsx index 3ed11ca3f..689f92f05 100644 --- a/client/src/contexts/PubSubProvider.jsx +++ b/client/src/contexts/PubSubProvider.jsx @@ -21,6 +21,8 @@ export const events = { $MODULE_UPDATED: moduleName => `moduleUpdated:${moduleName}`, $PLAYTEST_INPUT: tabId => `playtestInput:${tabId}`, $PLAYTEST_PRINT: tabId => `playtestPrint:${tabId}`, + $DEBUG_PRINT: tabId => `debugPrint:${tabId}`, + $DEBUG_INPUT: tabId => `debugInput:${tabId}`, $INSPECTOR_SET: tabId => `inspectorSet:${tabId}`, $TEXT_EDITOR_SET: tabId => `textEditorSet:${tabId}`, $TEXT_EDITOR_CLEAR: tabId => `textEditorClear:${tabId}`, From 1b47d5694c2895632c0219dbf9cd372f45a56b98 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 18:03:05 -0800 Subject: [PATCH 014/295] import usePubSub into terminal component --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 4532237ca..a52354f12 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -1,5 +1,7 @@ import Terminal from 'react-console-emulator' import { useAuth } from '@/contexts/AuthProvider' +import { usePubSub } from '@/contexts/PubSubProvider' + const commands = { echo: { From 6dbfa5a30a824fea8fd978dccdfdcfce062d5ed8 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 18:03:26 -0800 Subject: [PATCH 015/295] add DebugMessag interface --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index a52354f12..0d8e8aaf0 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -2,6 +2,10 @@ import Terminal from 'react-console-emulator' import { useAuth } from '@/contexts/AuthProvider' import { usePubSub } from '@/contexts/PubSubProvider' +export type DebugMessage = { + message: string +} + const commands = { echo: { From aa906ffccbeb45b3e93254d9522524f72d7a05be Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 18:05:07 -0800 Subject: [PATCH 016/295] strip out welcome message and add docs comment --- .../src/features/Thoth/windows/DebugConsole/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 0d8e8aaf0..c68f6c4f1 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -6,6 +6,7 @@ export type DebugMessage = { message: string } +const DebugConsole = ({ tab }) => { const commands = { echo: { @@ -16,14 +17,13 @@ const commands = { }, }, } - -const DebugConsole = props => { - const { user } = useAuth() + // https://github.com/linuswillner/react-console-emulator/tree/e2b602f631e8b7c57c4a7407491cbfb84f357519 return ( ) } From a85fc46f59c77f6ce35244d2058a2359a46a734c Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 18:06:02 -0800 Subject: [PATCH 017/295] grab user from auth --- 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 c68f6c4f1..a24dbcbf6 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -7,6 +7,7 @@ export type DebugMessage = { } const DebugConsole = ({ tab }) => { + const { user } = useAuth() const commands = { echo: { From 5258d9cdc0abfb46b3746ecd4a6dba659182f3b6 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 18:06:21 -0800 Subject: [PATCH 018/295] grab subscribe and events from pubsub provider --- 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 a24dbcbf6..d174ad8f0 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -8,6 +8,7 @@ export type DebugMessage = { const DebugConsole = ({ tab }) => { const { user } = useAuth() + const { publish, subscribe, events } = usePubSub() const commands = { echo: { From 783c9ce20210daee32e528c066346ec2d10fe6d3 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 18:06:40 -0800 Subject: [PATCH 019/295] destructure debug events from events --- 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 d174ad8f0..1af946693 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -9,6 +9,7 @@ export type DebugMessage = { const DebugConsole = ({ tab }) => { const { user } = useAuth() const { publish, subscribe, events } = usePubSub() + const { $DEBUG_INPUT, $DEBUG_PRINT } = events const commands = { echo: { From 9931e19dd6a53dde76b02ad4f30a5c5aa8a44a83 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 18:06:57 -0800 Subject: [PATCH 020/295] add ref and message state --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 1af946693..a52f2f5d3 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -11,6 +11,9 @@ const DebugConsole = ({ tab }) => { const { publish, subscribe, events } = usePubSub() const { $DEBUG_INPUT, $DEBUG_PRINT } = events + const [messages, setMessages] = useState([]) + const terminalRef = useRef() + const commands = { echo: { description: 'Echo a passed string.', From 5b098b3ffa26300819f72ac9038cf345f340adc0 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 18:07:17 -0800 Subject: [PATCH 021/295] add printToDebugger callback --- .../features/Thoth/windows/DebugConsole/index.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index a52f2f5d3..4442c8531 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -14,6 +14,19 @@ const DebugConsole = ({ tab }) => { const [messages, setMessages] = useState([]) const terminalRef = useRef() + const printToDebugger = useCallback( + (_, message) => { + const newMessages = [...messages, message] + setMessages(newMessages) + const terminal = terminalRef.current + terminal && + (terminal as unknown as { pushToStdout: any }).pushToStdout( + `> ${messages}` + ) + }, + [messages] + ) + const commands = { echo: { description: 'Echo a passed string.', From b97d8b375e3934a4595f2296161ece5996f54e13 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 18:07:36 -0800 Subject: [PATCH 022/295] add comments to commands --- .../Thoth/windows/DebugConsole/index.tsx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 4442c8531..351053d5e 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -27,15 +27,19 @@ const DebugConsole = ({ tab }) => { [messages] ) -const commands = { - echo: { - description: 'Echo a passed string.', - usage: 'echo ', - fn: function () { - return `${Array.from(arguments).join(' ')}` + + /** + * Terminal commands + */ + const commands = { + echo: { + description: 'Echo a passed string.', + usage: 'echo ', + fn: function () { + return `${Array.from(arguments).join(' ')}` + }, }, - }, -} + } // https://github.com/linuswillner/react-console-emulator/tree/e2b602f631e8b7c57c4a7407491cbfb84f357519 return ( Date: Thu, 24 Feb 2022 18:08:09 -0800 Subject: [PATCH 023/295] add imports to debug console --- 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 351053d5e..b307782b6 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -1,3 +1,4 @@ +import { useState, useCallback, useEffect, useRef } from 'react' import Terminal from 'react-console-emulator' import { useAuth } from '@/contexts/AuthProvider' import { usePubSub } from '@/contexts/PubSubProvider' From d0b8f4e89719c9a5fe58d923f3eecd9d2cb7d79c Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 18:08:56 -0800 Subject: [PATCH 024/295] add use effect to subscribe to debug print messages --- 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 b307782b6..37b489b8f 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -28,6 +28,11 @@ const DebugConsole = ({ tab }) => { [messages] ) + useEffect(() => { + const unsubscribe = subscribe($DEBUG_PRINT(tab.id), printToDebugger) + + return unsubscribe + }, [subscribe, printToDebugger, $DEBUG_PRINT]) /** * Terminal commands From e10d8532c3c5b42b75b481c9c2c450a3cb979d8b Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 24 Feb 2022 18:09:47 -0800 Subject: [PATCH 025/295] comment out unused variables --- .../src/features/Thoth/windows/DebugConsole/index.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 37b489b8f..7b0f924f8 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -9,8 +9,15 @@ export type DebugMessage = { const DebugConsole = ({ tab }) => { const { user } = useAuth() - const { publish, subscribe, events } = usePubSub() - const { $DEBUG_INPUT, $DEBUG_PRINT } = events + const { + // publish, + subscribe, + events, + } = usePubSub() + const { + // $DEBUG_INPUT, + $DEBUG_PRINT, + } = events const [messages, setMessages] = useState([]) const terminalRef = useRef() From d03abb4f3bfcc4ec89ee60aecf353bb5b93e2514 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 25 Feb 2022 14:02:40 -0800 Subject: [PATCH 026/295] add debugger plugin to editor --- core/src/editor.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/editor.ts b/core/src/editor.ts index 44fd5a440..c44b863c0 100644 --- a/core/src/editor.ts +++ b/core/src/editor.ts @@ -18,6 +18,7 @@ import { ModuleManager } from './plugins/modulePlugin/module-manager' import SocketGenerator from './plugins/socketGenerator' import TaskPlugin from './plugins/taskPlugin' import { PubSubContext, ThothComponent } from './thoth-component' +import DebuggerPlugin from './plugins/debuggerPlugin' export class ThothEditor extends NodeEditor { pubSub: PubSubContext thoth: EngineContext @@ -127,6 +128,7 @@ export const initEditor = async function ({ // WARNING: ModulePlugin needs to be initialized before TaskPlugin during engine setup editor.use(ModulePlugin, { engine, modules } as unknown as void) editor.use(TaskPlugin) + editor.use(DebuggerPlugin) // ███╗ ███╗ ██████╗ ██████╗ ██╗ ██╗██╗ ███████╗███████╗ // ████╗ ████║██╔═══██╗██╔══██╗██║ ██║██║ ██╔════╝██╔════╝ From e902a0b7074dac08c2444601117cde57838a203f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 25 Feb 2022 14:02:54 -0800 Subject: [PATCH 027/295] add sendToDebug to engine type --- core/src/engine.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/engine.ts b/core/src/engine.ts index 57aa98262..7d725ae2b 100644 --- a/core/src/engine.ts +++ b/core/src/engine.ts @@ -47,6 +47,7 @@ export type EngineContext = { request: string ) => Promise<{ error: unknown; [key: string]: unknown }> onPlaytest?: Function + sendToDebug?: Function onAddModule?: Function onUpdateModule?: Function sendToPlaytest?: Function From 7af0b9d01b99c6c1976e235549038eae6beed7e2 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 25 Feb 2022 14:03:36 -0800 Subject: [PATCH 028/295] add throw error in code.ts --- core/src/components/Code.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/components/Code.ts b/core/src/components/Code.ts index 15b9f080e..77286c8c5 100644 --- a/core/src/components/Code.ts +++ b/core/src/components/Code.ts @@ -94,6 +94,7 @@ export class Code extends ThothComponent { return Function('"use strict";return (' + obj + ')')()(node, inputs, data) } + console.log('running') try { const value = runCodeWithArguments(node.data.code) if (!silent) node.display(`${JSON.stringify(value)}`) @@ -106,6 +107,7 @@ export class Code extends ThothComponent { ) // close the data socket so it doesnt error out this._task.closed = ['data'] + throw err } } } From 8b74c38ba1e240b0c6e94af81c8174610659755f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 25 Feb 2022 14:03:51 -0800 Subject: [PATCH 029/295] create debugger plugin --- core/src/plugins/debuggerPlugin/index.ts | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 core/src/plugins/debuggerPlugin/index.ts diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts new file mode 100644 index 000000000..17c8b0479 --- /dev/null +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -0,0 +1,29 @@ +import { Component, NodeEditor } from 'rete/types' +import { EngineContext } from '../../engine' + +interface IRunContextEditor extends NodeEditor { + thoth: EngineContext +} + +function install(editor: IRunContextEditor) { + editor.on('componentregister', (component: Component) => { + const worker = component.worker + + component.worker = (node, inputs, outputs, data, ...args) => { + try { + return worker.apply(component, [node, inputs, outputs, data, ...args]) + } catch (error: any) { + if (!editor.thoth.sendToDebug) return + editor.thoth.sendToDebug({ message: error }) + console.error(error) + } + } + }) +} + +const defaultExport = { + name: 'debuggerPlugin', + install, +} + +export default defaultExport From 71984768cd97b526e54886c9543580b8db789646 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 25 Feb 2022 16:51:37 -0800 Subject: [PATCH 030/295] move debugger above module plugin --- core/src/editor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/editor.ts b/core/src/editor.ts index c44b863c0..b5100e9db 100644 --- a/core/src/editor.ts +++ b/core/src/editor.ts @@ -126,9 +126,9 @@ export const initEditor = async function ({ // @seang TODO: update types for editor.use rather than casting as unknown here, we may want to bring our custom rete directly into the monorepo at this point // WARNING: ModulePlugin needs to be initialized before TaskPlugin during engine setup + editor.use(DebuggerPlugin) editor.use(ModulePlugin, { engine, modules } as unknown as void) editor.use(TaskPlugin) - editor.use(DebuggerPlugin) // ███╗ ███╗ ██████╗ ██████╗ ██╗ ██╗██╗ ███████╗███████╗ // ████╗ ████║██╔═══██╗██╔══██╗██║ ██║██║ ██╔════╝██╔════╝ From 11bd41b92b46efe98046d350f9f04894f8b1f3c7 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 25 Feb 2022 16:59:08 -0800 Subject: [PATCH 031/295] add terminal interface --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 7b0f924f8..d6601499a 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -7,6 +7,10 @@ export type DebugMessage = { message: string } +interface Terminal { + pushToStdout: any +} + const DebugConsole = ({ tab }) => { const { user } = useAuth() const { From 77843f5fd8f8e207d3d41857066998a5eff73c62 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 25 Feb 2022 16:59:24 -0800 Subject: [PATCH 032/295] add terminal type to ref --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index d6601499a..573c6e14e 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -23,8 +23,7 @@ const DebugConsole = ({ tab }) => { $DEBUG_PRINT, } = events - const [messages, setMessages] = useState([]) - const terminalRef = useRef() + const terminalRef = useRef() const printToDebugger = useCallback( (_, message) => { From 28c917b41a7e2d9f80738568c6ce231f1d4fb9aa Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 25 Feb 2022 16:59:38 -0800 Subject: [PATCH 033/295] clean up print to debugger --- .../Thoth/windows/DebugConsole/index.tsx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 573c6e14e..a05a41d56 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -25,18 +25,12 @@ const DebugConsole = ({ tab }) => { const terminalRef = useRef() - const printToDebugger = useCallback( - (_, message) => { - const newMessages = [...messages, message] - setMessages(newMessages) - const terminal = terminalRef.current - terminal && - (terminal as unknown as { pushToStdout: any }).pushToStdout( - `> ${messages}` - ) - }, - [messages] - ) + const printToDebugger = useCallback((_, data) => { + const terminal = terminalRef.current + if (!terminal) return + + terminal.pushToStdout(`> ${data.message}`) + }, []) useEffect(() => { const unsubscribe = subscribe($DEBUG_PRINT(tab.id), printToDebugger) From 46009b03c0a057701dd58018d7b8a337c40424a0 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 25 Feb 2022 16:59:55 -0800 Subject: [PATCH 034/295] add styles to terminal --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index a05a41d56..5ded4bffc 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -57,6 +57,12 @@ const DebugConsole = ({ tab }) => { commands={commands} promptLabel={`${user.id}@Thoth:~$`} // readOnly={true} + style={{ + overflow: 'scroll', + 'min-height': '15vh', + 'max-height': '100%', + height: '100%', + }} /> ) } From f2d5a6ca8fbd63115a5d68d2ee11b075c8eff1c6 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 25 Feb 2022 17:00:07 -0800 Subject: [PATCH 035/295] remove unused import --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 5ded4bffc..32cc25e16 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -1,4 +1,4 @@ -import { useState, useCallback, useEffect, useRef } from 'react' +import { useCallback, useEffect, useRef } from 'react' import Terminal from 'react-console-emulator' import { useAuth } from '@/contexts/AuthProvider' import { usePubSub } from '@/contexts/PubSubProvider' From e7ce54a521e01a8a5d95d353c4c23adc7e35c523 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 09:40:41 -0800 Subject: [PATCH 036/295] Add buillder return to display plugin --- core/src/plugins/displayPlugin/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/plugins/displayPlugin/index.js b/core/src/plugins/displayPlugin/index.js index 8e38a073f..33f1799be 100644 --- a/core/src/plugins/displayPlugin/index.js +++ b/core/src/plugins/displayPlugin/index.js @@ -18,7 +18,7 @@ function install(editor) { displayMap[node.id] = display } - builder.call(component, node) + return builder.call(component, node) } component.worker = (node, inputs, outputs, data, ...args) => { From 9a3ee9653d467b3372656f29796df4b4b6e65fa6 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 09:41:11 -0800 Subject: [PATCH 037/295] Start work on component error highlighting --- core/src/plugins/debuggerPlugin/index.ts | 34 ++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 17c8b0479..13d874136 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -1,21 +1,45 @@ -import { Component, NodeEditor } from 'rete/types' +import { NodeEditor } from 'rete/types' +import { Node } from 'rete' import { EngineContext } from '../../engine' - +import { ThothComponent } from '../../thoth-component' interface IRunContextEditor extends NodeEditor { thoth: EngineContext + abort: Function } function install(editor: IRunContextEditor) { - editor.on('componentregister', (component: Component) => { + 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.data.error = false try { - return worker.apply(component, [node, inputs, outputs, data, ...args]) + const result = worker.apply(component, [ + node, + inputs, + outputs, + data, + ...args, + ]) + + return result } catch (error: any) { if (!editor.thoth.sendToDebug) return + editor.thoth.sendToDebug({ message: error }) - console.error(error) + node.data.error = true + + const fullNode = Node.fromJSON(node) + console.log('node object', fullNode) + editor.selectNode(fullNode) + throw error } } }) From b2fa42b8e1968ae8fdd2971743f8c219897f4982 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 09:47:30 -0800 Subject: [PATCH 038/295] Add error to node data type --- core/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/types.ts b/core/types.ts index b8e18a6cb..138a6f846 100644 --- a/core/types.ts +++ b/core/types.ts @@ -114,6 +114,7 @@ export type NodeOutputs = { export type NodeData = ReteNodeData & { fewshot?: string display: Function + error?: boolean } // export type Node = { From 7a724708be7422179fc6fc2a72b11f11522fb8f8 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 09:47:51 -0800 Subject: [PATCH 039/295] Clean up console logger in debug console window --- .../Thoth/windows/DebugConsole/index.tsx | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 7b0f924f8..b0e85e7af 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -1,4 +1,4 @@ -import { useState, useCallback, useEffect, useRef } from 'react' +import { useCallback, useEffect, useRef } from 'react' import Terminal from 'react-console-emulator' import { useAuth } from '@/contexts/AuthProvider' import { usePubSub } from '@/contexts/PubSubProvider' @@ -7,6 +7,10 @@ export type DebugMessage = { message: string } +export type Terminal = { + pushToStdout: any +} + const DebugConsole = ({ tab }) => { const { user } = useAuth() const { @@ -19,21 +23,13 @@ const DebugConsole = ({ tab }) => { $DEBUG_PRINT, } = events - const [messages, setMessages] = useState([]) - const terminalRef = useRef() + const terminalRef = useRef() - const printToDebugger = useCallback( - (_, message) => { - const newMessages = [...messages, message] - setMessages(newMessages) - const terminal = terminalRef.current - terminal && - (terminal as unknown as { pushToStdout: any }).pushToStdout( - `> ${messages}` - ) - }, - [messages] - ) + const printToDebugger = useCallback((_, data) => { + const terminal = terminalRef.current + + terminal.pushToStdout(`> ${data.message.stack}`) + }, []) useEffect(() => { const unsubscribe = subscribe($DEBUG_PRINT(tab.id), printToDebugger) From 48f000b0a40a712072b526d3ab0a391e10cb67f2 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 09:47:59 -0800 Subject: [PATCH 040/295] Update css ds --- client/src/features/common/Node/Node.module.css.d.ts | 1 + 1 file changed, 1 insertion(+) 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 c22f5b09c..b58176e1d 100644 --- a/client/src/features/common/Node/Node.module.css.d.ts +++ b/client/src/features/common/Node/Node.module.css.d.ts @@ -6,6 +6,7 @@ interface CssExports { 'connections-container': string; 'control': string; 'deprecated-overlay': string; + 'error': string; 'input': string; 'node': string; 'node-depricated': string; From 66fca13a0353f3d3046d456b8fdb3bad37677787 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 09:48:09 -0800 Subject: [PATCH 041/295] Add error class to node styling --- 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 4010c2a4f..7ce4e2a00 100644 --- a/client/src/features/common/Node/Node.module.css +++ b/client/src/features/common/Node/Node.module.css @@ -97,6 +97,10 @@ border-color: var(--primary); /* backdrop-filter: blur(15px); */ } +.node.error { + border-color: var(--red) !important; + /* backdrop-filter: blur(15px); */ +} .node.selected .node-title { opacity: 1; border-bottom: 1px solid var(--dark-1); From a5c12bd99d6937685790c1265c86e6e189556fc8 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 09:48:37 -0800 Subject: [PATCH 042/295] Working on stylingh node based on node data error --- client/src/features/common/Node/Node.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/src/features/common/Node/Node.js b/client/src/features/common/Node/Node.js index 4d7c53229..fa9c0f461 100644 --- a/client/src/features/common/Node/Node.js +++ b/client/src/features/common/Node/Node.js @@ -11,9 +11,16 @@ 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 + + console.log('NODE ERROR', node.error) return ( -
+
{node.deprecated &&
}
Date: Mon, 28 Feb 2022 09:48:57 -0800 Subject: [PATCH 043/295] Increase wait time in concurrent start --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fea1d856c..9ef33326c 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "start:core": "lerna exec --scope @latitudegames/thoth-core -- yarn start", "start:client": "lerna exec --scope @thoth/client -- yarn start", - "start": "concurrently \"yarn start:core\" \"sleep 10s && yarn start:client\"", + "start": "concurrently \"yarn start:core\" \"sleep 15s && yarn start:client\"", "lint": "lerna run lint --parallel", "lint:fix": "lerna run lint:fix --parallel", "build": "lerna exec --scope @thoth/client -- yarn build", From de31eaf74818d7c01bd0af8de40351fd053eafaa Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 10:34:45 -0800 Subject: [PATCH 044/295] fix styling name error --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 32cc25e16..31d2120f3 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -59,8 +59,8 @@ const DebugConsole = ({ tab }) => { // readOnly={true} style={{ overflow: 'scroll', - 'min-height': '15vh', - 'max-height': '100%', + minHeight: '15vh', + maxHeight: '100%', height: '100%', }} /> From b4532960c6f8dbda74f020a3db0f4d005cde866b Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 10:48:31 -0800 Subject: [PATCH 045/295] Remove unused console log --- core/src/components/Code.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/components/Code.ts b/core/src/components/Code.ts index 77286c8c5..024d92002 100644 --- a/core/src/components/Code.ts +++ b/core/src/components/Code.ts @@ -94,7 +94,6 @@ export class Code extends ThothComponent { return Function('"use strict";return (' + obj + ')')()(node, inputs, data) } - console.log('running') try { const value = runCodeWithArguments(node.data.code) if (!silent) node.display(`${JSON.stringify(value)}`) From 6b8ee854aa4ec00c42453154b4e3859a7316d4be Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 11:18:47 -0800 Subject: [PATCH 046/295] Add default dark scheme to design globals root for now --- client/src/design-globals/design-globals.css | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/design-globals/design-globals.css b/client/src/design-globals/design-globals.css index de44100ff..8e6bfc179 100644 --- a/client/src/design-globals/design-globals.css +++ b/client/src/design-globals/design-globals.css @@ -1,11 +1,13 @@ -@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&display=swap"); -@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;700&display=swap"); +@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;700&display=swap'); * { - font-family: "IBM Plex Sans", "IBM Plex Mono", sans-serif; + font-family: 'IBM Plex Sans', 'IBM Plex Mono', sans-serif; cursor: default !important; } :root { + color-scheme: dark; + --primary: #1290ce; --dark-0: #000000; --dark-1: #191919; From 7f7143519d8887f44797f4b358300bb7031168a8 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 11:19:00 -0800 Subject: [PATCH 047/295] Make toolbar optional in window component --- client/src/features/common/Window/Window.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/features/common/Window/Window.tsx b/client/src/features/common/Window/Window.tsx index 3a14b24e0..cf5c7f070 100644 --- a/client/src/features/common/Window/Window.tsx +++ b/client/src/features/common/Window/Window.tsx @@ -19,7 +19,7 @@ type Props = { borderless?: boolean darker?: boolean grid?: boolean - toolbar: ReactElement + toolbar?: ReactElement | false children: ReactElement | ReactElement[] } @@ -30,6 +30,7 @@ const Window = (props: Props) => { borderless = false, darker = false, grid = false, + toolbar = false, } = props return ( @@ -43,7 +44,7 @@ const Window = (props: Props) => { ${css[grid ? 'grid' : '']} `} > - {props.toolbar} + {toolbar && {props.toolbar}} {props.children}
) From 7afbfe8c204c6e75eab2b2e522c00a3ecced285d Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 11:19:15 -0800 Subject: [PATCH 048/295] Wrap console debug in window --- .../Thoth/windows/DebugConsole/index.tsx | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 31d2120f3..a814668e1 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef } from 'react' import Terminal from 'react-console-emulator' import { useAuth } from '@/contexts/AuthProvider' import { usePubSub } from '@/contexts/PubSubProvider' +import Window from '@/features/common/Window/Window' export type DebugMessage = { message: string @@ -50,20 +51,23 @@ const DebugConsole = ({ tab }) => { }, }, } + // https://github.com/linuswillner/react-console-emulator/tree/e2b602f631e8b7c57c4a7407491cbfb84f357519 return ( - + + + ) } From d810e6582659426b74178134a738774550090a6b Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 11:28:00 -0800 Subject: [PATCH 049/295] Install react custom scrollbar 2 --- client/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/client/package.json b/client/package.json index 0ff79aebd..85acbd673 100644 --- a/client/package.json +++ b/client/package.json @@ -41,6 +41,7 @@ "react": "^17.0.2", "react-console-emulator": "^5.0.1", "react-custom-scrollbars": "^4.2.1", + "react-custom-scrollbars-2": "^4.4.0", "react-dom": "^17.0.2", "react-hook-form": "^7.15.4", "react-hotkeys-hook": "^3.3.2", From de639e6e0ba129a1af428b37a865b658a71b2643 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 11:29:05 -0800 Subject: [PATCH 050/295] Remove old custom scrollbar --- client/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/client/package.json b/client/package.json index 85acbd673..620864891 100644 --- a/client/package.json +++ b/client/package.json @@ -40,7 +40,6 @@ "pubsub-js": "^1.9.3", "react": "^17.0.2", "react-console-emulator": "^5.0.1", - "react-custom-scrollbars": "^4.2.1", "react-custom-scrollbars-2": "^4.4.0", "react-dom": "^17.0.2", "react-hook-form": "^7.15.4", From bfbdf3e9ca0d0d821eb8b0e6cf1ff609b1602900 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 11:29:15 -0800 Subject: [PATCH 051/295] Update yarn lock --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index c1e0c8741..32aff8e4f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11783,10 +11783,10 @@ react-console-emulator@^5.0.1: react-inner-html "^1.0.1" react-innertext "^1.1.5" -react-custom-scrollbars@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/react-custom-scrollbars/-/react-custom-scrollbars-4.2.1.tgz#830fd9502927e97e8a78c2086813899b2a8b66db" - integrity sha1-gw/ZUCkn6X6KeMIIaBOJmyqLZts= +react-custom-scrollbars-2@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/react-custom-scrollbars-2/-/react-custom-scrollbars-2-4.4.0.tgz#6cc237abc18f5ab32b5392b336e6f072c2b4cfc1" + integrity sha512-I+oxZ9rfHfvYm85jdH2lQqpzwNr/ZAdYB8htm6R/hwRGoIEK31jq+YE6MmFwBzuO7C5zcAtH5HN9vwZxnW61NQ== dependencies: dom-css "^2.0.0" prop-types "^15.5.10" From 20c776aebef21b1e9a16ca4123e789fac063d1bb Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 11:30:38 -0800 Subject: [PATCH 052/295] Update window scrollbar import --- client/src/features/common/Window/Window.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/common/Window/Window.tsx b/client/src/features/common/Window/Window.tsx index cf5c7f070..dba1c2c97 100644 --- a/client/src/features/common/Window/Window.tsx +++ b/client/src/features/common/Window/Window.tsx @@ -1,4 +1,4 @@ -import { Scrollbars } from 'react-custom-scrollbars' +import { Scrollbars } from 'react-custom-scrollbars-2' import WindowToolbar from './WindowToolbar' From c7bd48d35fa4fb0b09a3286d031fa22dac0bc97f Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 11:30:50 -0800 Subject: [PATCH 053/295] Update deployment scrollbar import --- client/src/features/Thoth/windows/EditorWindow/Deployment.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/EditorWindow/Deployment.tsx b/client/src/features/Thoth/windows/EditorWindow/Deployment.tsx index 1bd3c8a7e..ac20996b8 100644 --- a/client/src/features/Thoth/windows/EditorWindow/Deployment.tsx +++ b/client/src/features/Thoth/windows/EditorWindow/Deployment.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import { Scrollbars } from 'react-custom-scrollbars' +import { Scrollbars } from 'react-custom-scrollbars-2' import { useSelector } from 'react-redux' import { useSnackbar } from 'notistack' From a5c42304275e00c98f3fbc598d3a67243aa0e4cd Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 11:41:26 -0800 Subject: [PATCH 054/295] Update scrollbar import in all projects --- client/src/features/HomeScreen/screens/AllProjects.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/HomeScreen/screens/AllProjects.jsx b/client/src/features/HomeScreen/screens/AllProjects.jsx index c1890c050..e3b924966 100644 --- a/client/src/features/HomeScreen/screens/AllProjects.jsx +++ b/client/src/features/HomeScreen/screens/AllProjects.jsx @@ -1,4 +1,4 @@ -import { Scrollbars } from 'react-custom-scrollbars' +import { Scrollbars } from 'react-custom-scrollbars-2' import Icon from '../../common/Icon/Icon' import Panel from '../../common/Panel/Panel' From 2685aeb319fd7024d87cd7344c04dd80082a0816 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 11:41:38 -0800 Subject: [PATCH 055/295] Update playtest scrollbar import --- client/src/features/Thoth/windows/PlaytestWindow.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/PlaytestWindow.jsx b/client/src/features/Thoth/windows/PlaytestWindow.jsx index 32d87cac2..18d0eef61 100644 --- a/client/src/features/Thoth/windows/PlaytestWindow.jsx +++ b/client/src/features/Thoth/windows/PlaytestWindow.jsx @@ -1,5 +1,5 @@ import { useState, useEffect, useCallback, useRef } from 'react' -import { Scrollbars } from 'react-custom-scrollbars' +import { Scrollbars } from 'react-custom-scrollbars-2' import { useHotkeys } from 'react-hotkeys-hook' import { usePubSub } from '../../../contexts/PubSubProvider' From bc2dde11f5c2c272a5d4e74c3ad46d006a43dcc0 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 11:47:12 -0800 Subject: [PATCH 056/295] Update default layout for better console sizing --- .../src/contexts/layouts/defaultLayout.json | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/client/src/contexts/layouts/defaultLayout.json b/client/src/contexts/layouts/defaultLayout.json index 4066e96c0..eabd99f28 100644 --- a/client/src/contexts/layouts/defaultLayout.json +++ b/client/src/contexts/layouts/defaultLayout.json @@ -9,7 +9,7 @@ { "type": "tabset", "id": "#3", - "weight": 2.960539823751833, + "weight": 7.102489336164113, "children": [ { "type": "tab", @@ -20,40 +20,46 @@ ] }, { - "type": "tabset", - "id": "#15", - "weight": 10.981039034584375, + "type": "row", + "id": "#9", + "weight": 34.08645212404496, "children": [ { - "type": "tab", - "id": "#21", - "name": "Composer", - "component": "editorWindow", - "enableClose": false, - "className": "editor-tab" - } - ], - "active": true - }, - { - "type": "tabset", - "id": "#17", - "weight": 50, - "children": [ + "type": "tabset", + "id": "#15", + "weight": 77.96917497733455, + "children": [ + { + "type": "tab", + "id": "#21", + "name": "Composer", + "component": "editorWindow", + "enableClose": false, + "className": "editor-tab" + } + ], + "active": true + }, { - "type": "tab", - "id": "44", - "name": "Debug Console", - "component": "debugConsole", - "className": "debug-console" + "type": "tabset", + "id": "#8", + "weight": 22.030825022665457, + "children": [ + { + "type": "tab", + "id": "44", + "name": "Debug Console", + "component": "debugConsole", + "className": "debug-console" + } + ] } - ], - "active": true + ] }, { "type": "row", "id": "#7", - "weight": 3.030260106260639, + "weight": 7.945196793081777, "children": [ { "type": "tabset", From 622f473bf2ed23761e3ba312e65ded5a57d3bd4c Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 12:51:14 -0800 Subject: [PATCH 057/295] Remove to lower case in inpector --- core/src/plugins/inspectorPlugin/Inspector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/plugins/inspectorPlugin/Inspector.js b/core/src/plugins/inspectorPlugin/Inspector.js index 1ff535d13..4b75972de 100644 --- a/core/src/plugins/inspectorPlugin/Inspector.js +++ b/core/src/plugins/inspectorPlugin/Inspector.js @@ -116,7 +116,7 @@ export class Inspector { // use the provided information from the socket to generate it const newSocket = new SocketConstructor( - socket.socketKey || socket.name.toLowerCase(), + socket.socketKey || socket.name, socket.name, socketMap[socket.socketType], socket.socketType === 'triggerSocket' From a2aee7dc6e9ac37540cd0b347d48c824f15429c4 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 12:51:21 -0800 Subject: [PATCH 058/295] Remove to lower case in output generator --- core/src/dataControls/OutputGenerator.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/dataControls/OutputGenerator.js b/core/src/dataControls/OutputGenerator.js index 9009ed37e..5525230cf 100644 --- a/core/src/dataControls/OutputGenerator.js +++ b/core/src/dataControls/OutputGenerator.js @@ -54,7 +54,7 @@ export class OutputGeneratorControl extends DataControl { }) this.node.removeOutput(output) - delete this.component.task.outputs[key.toLowerCase()] + delete this.component.task.outputs[key] }) // any incoming outputs not already on the node are new and will be added. @@ -65,7 +65,7 @@ export class OutputGeneratorControl extends DataControl { // Here we are running over and ensuring that the outputs are in the task this.component.task.outputs = this.node.data.outputs.reduce( (acc, out) => { - acc[out.name.toLowerCase()] = out.taskType || 'output' + acc[out.name] = out.taskType || 'output' return acc }, { ...this.component.task.outputs } @@ -74,7 +74,7 @@ export class OutputGeneratorControl extends DataControl { // From these new outputs, we iterate and add an output socket to the node newOutputs.forEach(output => { const newOutput = new Rete.Output( - output.name.toLowerCase(), + output.name, output.name, sockets[output.socketType] ) From 6072607d23897b96e9128b39e55d9febb18e2cbc Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 12:51:31 -0800 Subject: [PATCH 059/295] Remove to lower case in string processor --- core/src/dataControls/InputGenerator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/dataControls/InputGenerator.js b/core/src/dataControls/InputGenerator.js index a8b69aaf4..fa201ae2f 100644 --- a/core/src/dataControls/InputGenerator.js +++ b/core/src/dataControls/InputGenerator.js @@ -63,7 +63,7 @@ export class InputGeneratorControl extends DataControl { // From these new inputs, we iterate and add an output socket to the node newInputs.forEach(output => { const newInput = new Rete.Input( - output.name.toLowerCase(), + output.name, output.name, sockets[output.socketType] ) From 676bca974ca4ce900c76822221d287792529583a Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 12:51:40 -0800 Subject: [PATCH 060/295] Remove to lower case in string processor --- core/src/components/StringProcessor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/StringProcessor.ts b/core/src/components/StringProcessor.ts index 03cf50472..d8115fec3 100644 --- a/core/src/components/StringProcessor.ts +++ b/core/src/components/StringProcessor.ts @@ -68,7 +68,7 @@ export class StringProcessor extends ThothComponent> { // their javascript snippet, it should return a dict with the keys // they typed in, then we lower-case the keys for them. const lowerCasedOutputs = Object.keys(outputs).reduce((prev, key) => { - return { ...prev, [key.toLowerCase()]: outputs[key] } + return { ...prev, [key]: outputs[key] } }, {}) return lowerCasedOutputs From 7581c625ec51081688d58fd41e234f21f0b6b61b Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 12:51:47 -0800 Subject: [PATCH 061/295] Remove to lower case in socket generator --- .../windows/InspectorWindow/DataControls/SocketGenerator.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/InspectorWindow/DataControls/SocketGenerator.jsx b/client/src/features/Thoth/windows/InspectorWindow/DataControls/SocketGenerator.jsx index 3bf1246cf..c238c87c9 100644 --- a/client/src/features/Thoth/windows/InspectorWindow/DataControls/SocketGenerator.jsx +++ b/client/src/features/Thoth/windows/InspectorWindow/DataControls/SocketGenerator.jsx @@ -68,7 +68,7 @@ const SocketGenerator = ({ updateData, control, initialValue }) => { name: socket, taskType: data.taskType, // might also want to camel case any spacing here too - socketKey: socket.toLowerCase(), + socketKey: socket, connectionType: data.connectionType, socketType: data.socketType, } From 2b368b6e9e84b019009aab7eb5f5e759ea898a1b Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 12:51:55 -0800 Subject: [PATCH 062/295] Remove to lower case in enki select --- .../Thoth/windows/InspectorWindow/DataControls/EnkiSelect.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/features/Thoth/windows/InspectorWindow/DataControls/EnkiSelect.jsx b/client/src/features/Thoth/windows/InspectorWindow/DataControls/EnkiSelect.jsx index 3ff83ba1e..8c9eb1dcd 100644 --- a/client/src/features/Thoth/windows/InspectorWindow/DataControls/EnkiSelect.jsx +++ b/client/src/features/Thoth/windows/InspectorWindow/DataControls/EnkiSelect.jsx @@ -124,7 +124,7 @@ const EnkiSelect = ({ updateData, control, initialValue }) => { inputsToAdd.forEach(input => { const newInput = { name: input, - socketKey: input.toLowerCase(), + socketKey: input, socketType: 'stringSocket', taskType: 'output', } @@ -134,7 +134,7 @@ const EnkiSelect = ({ updateData, control, initialValue }) => { outputsToAdd.forEach(output => { const newOutput = { name: output, - socketKey: output.toLowerCase(), + socketKey: output, socketType: 'stringSocket', taskType: 'output', } From 60dd9ad110bc2f319ba26129e9cefddf467512a2 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 13:43:56 -0800 Subject: [PATCH 063/295] Update arguments passed to code component --- core/src/components/Code.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/core/src/components/Code.ts b/core/src/components/Code.ts index 024d92002..ceb6c0080 100644 --- a/core/src/components/Code.ts +++ b/core/src/components/Code.ts @@ -16,8 +16,9 @@ import { triggerSocket } from '../sockets' import { ThothComponent } from '../thoth-component' const defaultCode = ` -// See component information in inspector for details. -function worker(node, inputs, data) { +// inputs: dictionary of inputs based on socket names +// data: internal data of the node to read or write to nodes data state +function worker(inputs, data) { // Keys of the object returned must match the names // of your outputs you defined. @@ -27,7 +28,7 @@ function worker(node, inputs, data) { const info = `The code component is your swiss army knife when other components won't cut it. You can define any number of inputs and outputs on it, and then write a custom worker function. You have access to the any data plugged into the inputs you created on your component, and can send data out along your outputs. -Please note that the return of your function must be an object whose keys are the same value as the names given to your output sockets. The incoming inputs argument is an object whose keys are the names you defined, aand each is an array. +Please note that the return of your function must be an object whose keys are the same value as the names given to your output sockets. The incoming inputs argument is an object whose keys are the names you defined. ` export class Code extends ThothComponent { constructor() { @@ -90,8 +91,18 @@ export class Code extends ThothComponent { { silent, data }: { silent: boolean; 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 + ')')()(node, inputs, data) + return Function('"use strict";return (' + obj + ')')()( + flattenedInputs, + data + ) } try { From f9ac6524e101d72e7dfaf37d658beea5963b48a6 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:36:49 -0800 Subject: [PATCH 064/295] remove console log from node --- client/src/features/common/Node/Node.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/src/features/common/Node/Node.js b/client/src/features/common/Node/Node.js index fa9c0f461..a4496fd32 100644 --- a/client/src/features/common/Node/Node.js +++ b/client/src/features/common/Node/Node.js @@ -13,8 +13,6 @@ export class MyNode extends Node { const fullName = node.data.name ? `${name} - ${node.data.name}` : name const hasError = node.data.error - console.log('NODE ERROR', node.error) - return (
Date: Mon, 28 Feb 2022 14:37:27 -0800 Subject: [PATCH 065/295] throw error in action module if action input is missing --- core/src/components/ActionType.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/components/ActionType.ts b/core/src/components/ActionType.ts index 2edb69a7c..db4a42195 100644 --- a/core/src/components/ActionType.ts +++ b/core/src/components/ActionType.ts @@ -85,6 +85,11 @@ export class ActionTypeComponent extends ThothComponent> { const fewshot = node.data.fewshot as string const prompt = fewshot + action + ',' + if (!action) + throw new Error( + 'ActionType Module requires action string to be passed into it.' + ) + const body = { prompt, stop: ['\n'], From bcf0ed4b75eebb08f6cc9fffaaf18d32eecbc43f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:38:10 -0800 Subject: [PATCH 066/295] wrap await completion with try catch in actionType --- core/src/components/ActionType.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/components/ActionType.ts b/core/src/components/ActionType.ts index db4a42195..2c42e0591 100644 --- a/core/src/components/ActionType.ts +++ b/core/src/components/ActionType.ts @@ -96,12 +96,17 @@ export class ActionTypeComponent extends ThothComponent> { maxTokens: 100, temperature: 0.0, } - const raw = (await completion(body)) as string - const result = raw?.trim() - if (!silent) node.display(result) - return { - actionType: result, + try { + const raw = (await completion(body)) as string + const result = raw?.trim() + if (!silent) node.display(result) + + return { + actionType: result, + } + } catch (err) { + throw new Error('Error in ActionType component') } } } From 0cbb5028eb2c796f046970af8ad4eefdce856a42 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:38:31 -0800 Subject: [PATCH 067/295] fix typos in code component --- core/src/components/Code.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/components/Code.ts b/core/src/components/Code.ts index 77286c8c5..6967659e3 100644 --- a/core/src/components/Code.ts +++ b/core/src/components/Code.ts @@ -25,9 +25,9 @@ function worker(node, inputs, data) { } ` -const info = `The code component is your swiss army knife when other components won't cut it. You can define any number of inputs and outputs on it, and then write a custom worker function. You have access to the any data plugged into the inputs you created on your component, and can send data out along your outputs. +const info = `The code component is your swiss army knife when other components won't cut it. You can define any number of inputs and outputs on it, and then write a custom worker function. You have access to the data plugged into the inputs you created on your component, and can send data out along your outputs. -Please note that the return of your function must be an object whose keys are the same value as the names given to your output sockets. The incoming inputs argument is an object whose keys are the names you defined, aand each is an array. +Please note that the return of your function must be an object whose keys are the same value as the names given to your output sockets. The incoming inputs argument is an object whose keys are the names you defined, and each is an array. ` export class Code extends ThothComponent { constructor() { @@ -94,7 +94,6 @@ export class Code extends ThothComponent { return Function('"use strict";return (' + obj + ')')()(node, inputs, data) } - console.log('running') try { const value = runCodeWithArguments(node.data.code) if (!silent) node.display(`${JSON.stringify(value)}`) From da1b0db9fe0755ca1c865eef7eeb98e168e9d9cb Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:39:12 -0800 Subject: [PATCH 068/295] add error handling for difficulty detector --- core/src/components/DifficultyDetector.ts | 26 +++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/core/src/components/DifficultyDetector.ts b/core/src/components/DifficultyDetector.ts index 18e1e6e3b..72fcc64cc 100644 --- a/core/src/components/DifficultyDetector.ts +++ b/core/src/components/DifficultyDetector.ts @@ -117,17 +117,21 @@ export class DifficultyDetectorComponent extends ThothComponent< maxTokens: 100, temperature: 0.0, } - const raw = (await completion(body)) as string - const result = raw?.trim() - if (!silent) node.display(result) - - const [difficulty, category] = result - ? result.split(', ') - : [undefined, undefined] - - return { - difficulty, - category, + try { + const raw = (await completion(body)) as string + const result = raw?.trim() + if (!silent) node.display(result) + + const [difficulty, category] = result + ? result.split(', ') + : [undefined, undefined] + + return { + difficulty, + category, + } + } catch (err) { + throw new Error('Error in Difficulty Detector component') } } } From 61f2f4ac63560f96ac8ea9d08dc39473ea4c05b1 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:39:27 -0800 Subject: [PATCH 069/295] fix typos in entity detector --- core/src/components/EntityDetector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/EntityDetector.ts b/core/src/components/EntityDetector.ts index add63c7c2..577811127 100644 --- a/core/src/components/EntityDetector.ts +++ b/core/src/components/EntityDetector.ts @@ -119,7 +119,7 @@ Action: ` const info = `The entity detector takes in an action as a string, and attempts to report any discrete entities are mentioned, and their general type. -The fewshot can be edited in the text edior, though note that the data structure must remian the same for proper processing.` +The fewshot can be edited in the text editor, though note that the data structure must remain the same for proper processing.` type Entity = { name: string From d5cc39eeaec66610186b3a47c6afad5ebb8db02a Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:39:46 -0800 Subject: [PATCH 070/295] add error handling for entity detector --- core/src/components/EntityDetector.ts | 45 +++++++++++++++------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/core/src/components/EntityDetector.ts b/core/src/components/EntityDetector.ts index 577811127..4223cd8c1 100644 --- a/core/src/components/EntityDetector.ts +++ b/core/src/components/EntityDetector.ts @@ -191,35 +191,40 @@ export class EntityDetector extends ThothComponent< maxTokens: 50, temperature: 0.0, } - const result = (await completion(body)) as string - const split = result?.replace('\n', '')?.trim()?.split('Types: ') + try { + const result = (await completion(body)) as string - const [entities, types] = split - ? split.map(item => item.split(', ').map(x => x.trim())) - : [undefined, undefined] + const split = result?.replace('\n', '')?.trim()?.split('Types: ') - if (!entities || entities.length === 0) return [] - if (!types) return [] + const [entities, types] = split + ? split.map(item => item.split(', ').map(x => x.trim())) + : [undefined, undefined] - for (let i = 0; i < entities.length; i++) { - if (types[i]?.includes('(dialog)')) { - types.splice(i, 1) - entities.splice(i, 1) + if (!entities || entities.length === 0) return [] + if (!types) return [] + + for (let i = 0; i < entities.length; i++) { + if (types[i]?.includes('(dialog)')) { + types.splice(i, 1) + entities.splice(i, 1) + } } - } - if (entities[0] === 'none') return [] + if (entities[0] === 'none') return [] - const allEntities = entities.map((entity, i) => ({ - name: entity, - type: types[i], - })) + const allEntities = entities.map((entity, i) => ({ + name: entity, + type: types[i], + })) - if (!silent) node.display(JSON.stringify(allEntities)) + if (!silent) node.display(JSON.stringify(allEntities)) - return { - entities: allEntities, + return { + entities: allEntities, + } + } catch (err) { + throw new Error('Error in Entitiy Detector component') } } } From e2e3056f7b29224e6f2c3254fe21f1a67b2a4145 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:40:00 -0800 Subject: [PATCH 071/295] fix typos in forEach --- core/src/components/ForEach.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/ForEach.ts b/core/src/components/ForEach.ts index f55bb66db..7c9b8377a 100644 --- a/core/src/components/ForEach.ts +++ b/core/src/components/ForEach.ts @@ -8,7 +8,7 @@ import { } from '../../types' import { arraySocket, triggerSocket, anySocket } from '../sockets' import { ThothComponent, ThothTask } from '../thoth-component' -const info = `The forEach component takes in an array, and will iterate over each item in the array, firing a new trigger signal with the appropriate value,until all items in the array have beeb processed.` +const info = `The forEach component takes in an array, and will iterate over each item in the array, firing a new trigger signal with the appropriate value, until all items in the array have been processed.` type WorkerReturn = { element: string | string[] | unknown From 02ece47764cc169cded5efc5a2af75638bbbe046 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:40:14 -0800 Subject: [PATCH 072/295] add error handling on forEach --- core/src/components/ForEach.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/core/src/components/ForEach.ts b/core/src/components/ForEach.ts index 7c9b8377a..309eeb3cb 100644 --- a/core/src/components/ForEach.ts +++ b/core/src/components/ForEach.ts @@ -47,13 +47,18 @@ export class ForEach extends ThothComponent> { if (element === undefined) { const inputsArray = inputs.array[0] as unknown[] - await Promise.all( - inputsArray.map((el: unknown) => - this._task - .clone(false, {} as ThothTask, {} as ThothTask) - .run({ element: el }) + try { + await Promise.all( + inputsArray.map((el: unknown) => + this._task + .clone(false, {} as ThothTask, {} as ThothTask) + .run({ element: el }) + ) ) - ) + } catch (err) { + throw new Error('Error in ForEach Componenet.') + } + this._task.closed = ['act'] } else { this._task.closed = ['done'] From 60e3ed943f4e3d1f8a5863146f792c841bfe53e9 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:40:27 -0800 Subject: [PATCH 073/295] fix typos in generator --- core/src/components/Generator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/Generator.ts b/core/src/components/Generator.ts index a2f12bcb3..6bf3ed128 100644 --- a/core/src/components/Generator.ts +++ b/core/src/components/Generator.ts @@ -13,7 +13,7 @@ import { SocketGeneratorControl } from '../dataControls/SocketGenerator' import { EngineContext } from '../engine' import { triggerSocket, stringSocket } from '../sockets' import { ThothComponent } from '../thoth-component' -const info = `The generator component is our general purpose completion component. You can define any number of inputs, and utilise those inputs in a templating language known as Handlebars. Any value which is wrapped like {{this}} in double braces will be replaced with the corresponding value coming in to the input with the same name. This allows you to write almost any fewshot you might need, and input values from anywhere else in your chain. +const info = `The generator component is our general purpose completion component. You can define any number of inputs, and utilize those inputs in a templating language known as Handlebars. Any value which is wrapped like {{this}} in double braces will be replaced with the corresponding value coming in to the input with the same name. This allows you to write almost any fewshot you might need, and input values from anywhere else in your chain. Controls have also been added which give you control of some of the fundamental settings of the OpenAI completion endpoint, including temperature, max tokens, and your stop sequence. From a2f1cf43c089174c7449deb8b18fb476beb5ce85 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:40:37 -0800 Subject: [PATCH 074/295] add error handling for generator --- core/src/components/Generator.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/core/src/components/Generator.ts b/core/src/components/Generator.ts index 6bf3ed128..ecc68c157 100644 --- a/core/src/components/Generator.ts +++ b/core/src/components/Generator.ts @@ -137,13 +137,17 @@ export class Generator extends ThothComponent> { temperature, frequencyPenalty, } - const raw = (await completion(body)) as string - const result = raw?.trim() - const composed = `${prompt} ${result}` - - return { - result, - composed, + try { + const raw = (await completion(body)) as string + const result = raw?.trim() + const composed = `${prompt} ${result}` + + return { + result, + composed, + } + } catch (err) { + throw new Error('Error in Generator component.') } } } From 3a89b4acc7ad1324e2adefd9cee4f547986816fd Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:40:52 -0800 Subject: [PATCH 075/295] fix typos in hugging face --- core/src/components/Huggingface.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/Huggingface.ts b/core/src/components/Huggingface.ts index 84d37eed5..dd343ccf1 100644 --- a/core/src/components/Huggingface.ts +++ b/core/src/components/Huggingface.ts @@ -15,7 +15,7 @@ import { triggerSocket, stringSocket } from '../sockets' import { ThothComponent } from '../thoth-component' const info = `The huggingface component is used to access models on huggingface.co. For now it is very simple. You define a number of inputs with the input generator, and you can use those in forming the request to your huggingface inference model. You input the name of the model from hugginface into the model name field, and you run it. It will call the model, and return the result. -NOTE: Hugginface models are on demand, and sometimes require time to "boot up". We have tried to trigger an initial request the cause the model to load in the background while you and working, but this will not always be done in time. If it is not done, we will notify you via the "error" trigger out. +NOTE: Hugginface models are on demand, and sometimes require time to "boot up". We have tried to trigger an initial request that causes the model to load in the background while you are working, but this will not always be done in time. If it is not done, we will notify you via the "error" trigger out. Also note that you will likely need to parse the return from huggingface yourself inside a code component, or similar.` From 454065ca267310204c4925f61d7616e76e856e42 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:41:13 -0800 Subject: [PATCH 076/295] change stopControl to modelControl --- core/src/components/Huggingface.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/components/Huggingface.ts b/core/src/components/Huggingface.ts index dd343ccf1..abec1b03f 100644 --- a/core/src/components/Huggingface.ts +++ b/core/src/components/Huggingface.ts @@ -73,8 +73,8 @@ export class HuggingfaceComponent extends ThothComponent< language: 'handlebars', }) - const stopControl = new InputControl({ - dataKey: 'modelName', + const modelControl = new InputControl({ + dataKey: 'model', name: 'Model Name', }) @@ -82,7 +82,7 @@ export class HuggingfaceComponent extends ThothComponent< .add(nameControl) .add(inputGenerator) .add(requestControl) - .add(stopControl) + .add(modelControl) return node } From 7ce24b463c76189a2db98841671b0b8295cc6813 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:41:33 -0800 Subject: [PATCH 077/295] add error handling for huggingface --- core/src/components/Huggingface.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/components/Huggingface.ts b/core/src/components/Huggingface.ts index abec1b03f..11c0a561b 100644 --- a/core/src/components/Huggingface.ts +++ b/core/src/components/Huggingface.ts @@ -108,15 +108,16 @@ export class HuggingfaceComponent extends ThothComponent< try { const result = await thoth.huggingface(model, request) - if (result.error) throw Error() + // This might cause bug + if (result.error) + throw new Error(`Huggingface result.error: ${result.error}`) return { result, } } catch (err) { this._task.closed = ['trigger'] - - return {} + throw new Error('Error in HuggingFace component') } } } From dc84badf8e73b7b3d2d2b0d9787345cdae2f1056 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:41:45 -0800 Subject: [PATCH 078/295] fix typos in input --- core/src/components/Input.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/Input.ts b/core/src/components/Input.ts index f0da1bb56..5898a8dd6 100644 --- a/core/src/components/Input.ts +++ b/core/src/components/Input.ts @@ -17,7 +17,7 @@ import { Task } from '../plugins/taskPlugin/task' import { anySocket } from '../sockets' import { ThothComponent, ThothTask } from '../thoth-component' -const info = `The input component allows you to pass a single value to your chain. You can set a default value to fall back to if no value is provided at runtim. You can also turn the input on to receive data from the playtest input.` +const info = `The input component allows you to pass a single value to your chain. You can set a default value to fall back to if no value is provided at runtime. You can also turn the input on to receive data from the playtest input.` type InputReturn = { output: unknown From aa667dd3ed4a7cbe53f828395cfdd481df1526fd Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:42:01 -0800 Subject: [PATCH 079/295] fix typo in itemDetector --- core/src/components/ItemDetector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/ItemDetector.ts b/core/src/components/ItemDetector.ts index 02a9b882c..131a48a5d 100644 --- a/core/src/components/ItemDetector.ts +++ b/core/src/components/ItemDetector.ts @@ -20,7 +20,7 @@ Action, Item: gather the valerian plant from the forest, valerian plant Action, Item: get the necklace from the box, necklace Action, Item: ` -const info = `The item detector attempts to recognize what item in a give text string is being mentioned or used. The input is a text string the output is a string of the object` +const info = `The item detector attempts to recognize what item in a given text string is being mentioned or used. The input is a text string the output is a string of the object` type WorkerReturn = { detectedItem: string From 5fda7bf21db2ceab74f0f6f945b28ffd0286a16b Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:42:12 -0800 Subject: [PATCH 080/295] add error handling for itemdetector --- core/src/components/ItemDetector.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/components/ItemDetector.ts b/core/src/components/ItemDetector.ts index 131a48a5d..a3a5807e4 100644 --- a/core/src/components/ItemDetector.ts +++ b/core/src/components/ItemDetector.ts @@ -75,12 +75,17 @@ export class ItemTypeComponent extends ThothComponent> { maxTokens: 100, temperature: 0.0, } - const raw = (await completion(body)) as string - const result = raw?.trim() - if (!silent) node.display(result) - return { - detectedItem: result, + try { + const raw = (await completion(body)) as string + const result = raw?.trim() + if (!silent) node.display(result) + + return { + detectedItem: result, + } + } catch (err) { + throw new Error('Error in Item Detector component') } } } From 4711a24b3f273f604cc178a4a20ba347420aa4f5 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:42:25 -0800 Subject: [PATCH 081/295] fix typo in output --- core/src/components/Output.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/Output.ts b/core/src/components/Output.ts index 62f860003..adffeb89b 100644 --- a/core/src/components/Output.ts +++ b/core/src/components/Output.ts @@ -12,7 +12,7 @@ import { SwitchControl } from '../dataControls/SwitchControl' import { EngineContext } from '../engine' import { triggerSocket, anySocket } from '../sockets' import { ThothComponent } from '../thoth-component' -const info = `The output component will pass values out from your spell. You can have multiple outputs in a spell and all output values willbe collected. It also has an option to send the output to the playtest area for easy testing.` +const info = `The output component will pass values out from your spell. You can have multiple outputs in a spell and all output values will be collected. It also has an option to send the output to the playtest area for easy testing.` export class Output extends ThothComponent { constructor() { From 9ec4b7fbc0bca4e96a89962f326afb81b7ec3dd0 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:42:41 -0800 Subject: [PATCH 082/295] add error handling in proseToScript --- core/src/components/ProseToScript.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/components/ProseToScript.ts b/core/src/components/ProseToScript.ts index 8c6ef0299..81e33450c 100644 --- a/core/src/components/ProseToScript.ts +++ b/core/src/components/ProseToScript.ts @@ -119,12 +119,17 @@ export class ProseToScript extends ThothComponent> { maxTokens: 300, temperature: 0.0, } - const raw = (await completion(body)) as string - const result = raw?.trim() - if (!silent) node.display(result) - return { - detectedItem: result, + try { + const raw = (await completion(body)) as string + const result = raw?.trim() + if (!silent) node.display(result) + + return { + detectedItem: result, + } + } catch (err) { + throw new Error('Error in ProseToScript component') } } } From 7dde9fc7e8e06a134257ac21ffd232eb5db33a1a Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:42:54 -0800 Subject: [PATCH 083/295] fix typo in safety verifier --- core/src/components/SafetyVerifier.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/SafetyVerifier.ts b/core/src/components/SafetyVerifier.ts index c46af35ee..e4f77a883 100644 --- a/core/src/components/SafetyVerifier.ts +++ b/core/src/components/SafetyVerifier.ts @@ -78,7 +78,7 @@ Action: ` const info = `The Safety Verifier component takes a string and attempts to classify if that string is safe or not. It returns a boolean value that represents whether or not the input is safe. -The fewshot can be edited in the text editor, however it contains content which may be triggering to some individuals. If you modify the fewshot, note that it must remian in the format for the processing to work.` +The fewshot can be edited in the text editor, however it contains content which may be triggering to some individuals. If you modify the fewshot, note that it must remain in the format for the processing to work.` type WorkerReturn = { boolean: boolean From dcbf16ffb42ca1bb1a3b0cba3c3c27114af6ca2f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:43:09 -0800 Subject: [PATCH 084/295] add error handling in safety verifier --- core/src/components/SafetyVerifier.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/components/SafetyVerifier.ts b/core/src/components/SafetyVerifier.ts index e4f77a883..b932404a9 100644 --- a/core/src/components/SafetyVerifier.ts +++ b/core/src/components/SafetyVerifier.ts @@ -136,13 +136,17 @@ export class SafetyVerifier extends ThothComponent> { maxTokens: 10, temperature: 0.0, } - const raw = (await completion(body)) as string - const result = raw?.trim() !== 'X' + try { + const raw = (await completion(body)) as string + const result = raw?.trim() !== 'X' - if (!silent) node.display(`${result}`) + if (!silent) node.display(`${result}`) - return { - boolean: result, + return { + boolean: result, + } + } catch (err) { + throw new Error('Error in Safety Verifier component') } } } From 24e8cfce5d0f3c9ac00def6e828860435cfcf727 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:43:21 -0800 Subject: [PATCH 085/295] fix typos in stateRead --- core/src/components/StateRead.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/StateRead.ts b/core/src/components/StateRead.ts index 6bf05169d..8181c8c80 100644 --- a/core/src/components/StateRead.ts +++ b/core/src/components/StateRead.ts @@ -7,7 +7,7 @@ import { import { SocketGeneratorControl } from '../dataControls/SocketGenerator' import { EngineContext } from '../engine' import { ThothComponent } from '../thoth-component' -const info = `The State Read component allows you to read values from the state. These can be found in and are managed by the State Manager window. This window consists of a JSON object. You can define any number ouf outputs where an outputs name corresponds to a key in the state manager. Whatever value is assigned to that key will be read ans passed into your chain.` +const info = `The State Read component allows you to read values from the state. These can be found in and are managed by the State Manager window. This window consists of a JSON object. You can define any number of outputs where an outputs name corresponds to a key in the state manager. Whatever value is assigned to that key will be read ans passed into your chain.` export class StateRead extends ThothComponent< Promise> > { From 6bb443853c018182a83b2c1a08810e4c09101f09 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:43:31 -0800 Subject: [PATCH 086/295] add error handling for stateRead --- core/src/components/StateRead.ts | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/core/src/components/StateRead.ts b/core/src/components/StateRead.ts index 8181c8c80..99efd88cc 100644 --- a/core/src/components/StateRead.ts +++ b/core/src/components/StateRead.ts @@ -43,18 +43,23 @@ export class StateRead extends ThothComponent< { thoth }: { silent: boolean; thoth: EngineContext } ) { const { getCurrentGameState } = thoth - const gameState = await getCurrentGameState() - - return Object.entries(gameState).reduce((acc, [key, value]) => { - const nodeOutputs = node.data.outputs as { - name: string - [key: string]: unknown - }[] - if (nodeOutputs.some(out => out.name === key)) { - acc[key] = value - } - - return acc - }, {} as { [key: string]: unknown }) + + try { + const gameState = await getCurrentGameState() + + return Object.entries(gameState).reduce((acc, [key, value]) => { + const nodeOutputs = node.data.outputs as { + name: string + [key: string]: unknown + }[] + if (nodeOutputs.some(out => out.name === key)) { + acc[key] = value + } + + return acc + }, {} as { [key: string]: unknown }) + } catch (err) { + throw new Error('Error in State Read component') + } } } From b2a1b8d8b19a405bd5590041e1deb5f915b40a5d Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:43:43 -0800 Subject: [PATCH 087/295] fix typos in state write --- core/src/components/StateWrite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/StateWrite.js b/core/src/components/StateWrite.js index 5e0b1e727..1e8343ed2 100644 --- a/core/src/components/StateWrite.js +++ b/core/src/components/StateWrite.js @@ -4,7 +4,7 @@ import { SocketGeneratorControl } from '../dataControls/SocketGenerator' import { triggerSocket } from '../sockets' import { ThothComponent } from '../thoth-component' -const info = `The State Write component allows you to define any number of inputs, and to write values to the state manager which correspond to the namesof thise inputs. If the value does not exist in the state, it willbe written. +const info = `The State Write component allows you to define any number of inputs, and to write values to the state manager which correspond to the names of those inputs. If the value does not exist in the state, it will be written. Note here that there are a few assumptions made, which will be changed once we have selectable socket types when generating inputs. If the key already exists in the state and it is an array, whatever value you insert will be added to the array. If the existing value is an object, the object will be updated by the incoming value.` From 7bf9ac7b3813b3e8f51c85a3f5fa75b99d84f188 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:43:56 -0800 Subject: [PATCH 088/295] add error handling for stateWrite --- core/src/components/StateWrite.js | 51 +++++++++++++++++-------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/core/src/components/StateWrite.js b/core/src/components/StateWrite.js index 1e8343ed2..ceb5b5fee 100644 --- a/core/src/components/StateWrite.js +++ b/core/src/components/StateWrite.js @@ -39,33 +39,38 @@ export class StateWrite extends ThothComponent { async worker(node, inputs, outputs, { thoth }) { const { getCurrentGameState, updateCurrentGameState } = thoth - const gameState = await getCurrentGameState() - let value - - const updates = Object.entries(inputs).reduce((acc, [key, val]) => { - // Check here what type of data structure the gameState for the key is - switch (typeof gameState[key]) { - case 'object': - // if we have an array, add the value to the array and reassign to the state - if (Array.isArray(gameState[key])) { - value = [...gameState[key], val[0]] - break - } - // if it is an object, we assume that the incoming data is an object update - value = { ...gameState[key], ...val[0] } + try { + const gameState = await getCurrentGameState() + let value + + const updates = Object.entries(inputs).reduce((acc, [key, val]) => { + // Check here what type of data structure the gameState for the key is + switch (typeof gameState[key]) { + case 'object': + // if we have an array, add the value to the array and reassign to the state + if (Array.isArray(gameState[key])) { + value = [...gameState[key], val[0]] + break + } - break - default: - // default is to just overwrite whatever value is there with a new one. - value = val[0] - } + // if it is an object, we assume that the incoming data is an object update + value = { ...gameState[key], ...val[0] } - acc[key] = value + break + default: + // default is to just overwrite whatever value is there with a new one. + value = val[0] + } - return acc - }, {}) + acc[key] = value - await updateCurrentGameState(updates) + return acc + }, {}) + + await updateCurrentGameState(updates) + } catch (err) { + throw new Error('Error in State Write component') + } } } From 80b2529657d63264f046743d139bdb53bc532039 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:44:11 -0800 Subject: [PATCH 089/295] fix typos in stringprocessor --- core/src/components/StringProcessor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/components/StringProcessor.ts b/core/src/components/StringProcessor.ts index 03cf50472..521b7c560 100644 --- a/core/src/components/StringProcessor.ts +++ b/core/src/components/StringProcessor.ts @@ -5,9 +5,9 @@ import { CodeControl } from '../dataControls/CodeControl' import { SocketGeneratorControl } from '../dataControls/SocketGenerator' import { stringSocket, triggerSocket } from '../sockets' import { ThothComponent } from '../thoth-component' -const info = `The String Processor component take s astring as an input and allows you to write a function in the text editor to parse that string in whatever way you need. You can define any number of outputs which you can pass the result of your parsing out through. +const info = `The String Processor component takes a string as an input and allows you to write a function in the text editor to parse that string in whatever way you need. You can define any number of outputs which you can pass the result of your parsing out through. -Note that the return value of your function must be an objetc whose keys match the names of your generated output sockets.` +Note that the return value of your function must be an object whose keys match the names of your generated output sockets.` export class StringProcessor extends ThothComponent> { constructor() { From 0ef7439109ca1211e547f500e0141b1486c9b0ea Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:44:21 -0800 Subject: [PATCH 090/295] fix typos in switch gate --- core/src/components/SwitchGate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/SwitchGate.ts b/core/src/components/SwitchGate.ts index 47653f9cd..cbc2d82e0 100644 --- a/core/src/components/SwitchGate.ts +++ b/core/src/components/SwitchGate.ts @@ -13,7 +13,7 @@ import { ThothComponent } from '../thoth-component' // return string.charAt(0).toUpperCase() + string.slice(1); // } -const info = `The Switch Gate component takes a single input, and allows you to define any number of outputs. Its works the same as the javascript switch. The component will try to match the value of the input to one of the output socketnames you have created. It will route the trigger signal through that socket.` +const info = `The Switch Gate component takes a single input, and allows you to define any number of outputs. It works the same as the javascript switch. The component will try to match the value of the input to one of the output socket names you have created. It will route the trigger signal through that socket.` export class SwitchGate extends ThothComponent { constructor() { From 5403f03230459887807967f5751e324bd9539b82 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:44:37 -0800 Subject: [PATCH 091/295] add error handling for tense transformer --- core/src/components/TenseTransformer.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/components/TenseTransformer.ts b/core/src/components/TenseTransformer.ts index 12ac7cebc..5d7afbf9f 100644 --- a/core/src/components/TenseTransformer.ts +++ b/core/src/components/TenseTransformer.ts @@ -139,13 +139,18 @@ export class TenseTransformer extends ThothComponent> { maxTokens: 100, temperature: 0.0, } - const raw = (await completion(body)) as string - const result = raw?.trim() - if (!silent) node.display(result) + try { + const raw = (await completion(body)) as string + const result = raw?.trim() - return { - action: result + if (!silent) node.display(result) + + return { + action: result, + } + } catch (err) { + throw new Error('Error in Tense Transformer component') } } } From a9e5214a73369fe708f4150cb51f5730f2a1a481 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:44:48 -0800 Subject: [PATCH 092/295] add error handling for time detector --- core/src/components/TimeDetector.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/components/TimeDetector.ts b/core/src/components/TimeDetector.ts index af157aedc..ccef9e25b 100644 --- a/core/src/components/TimeDetector.ts +++ b/core/src/components/TimeDetector.ts @@ -92,12 +92,17 @@ export class TimeDetectorComponent extends ThothComponent< maxTokens: 100, temperature: 0.0, } - const raw = (await completion(body)) as string - const result = raw?.trim() - if (!silent) node.display(result) - return { - detectedTime: result, + try { + const raw = (await completion(body)) as string + const result = raw?.trim() + if (!silent) node.display(result) + + return { + detectedTime: result, + } + } catch (err) { + throw new Error('Error in Time Detector component') } } } From abdbe2d4ac6549db8c29d6a7f75b1e7257dcab72 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 14:44:59 -0800 Subject: [PATCH 093/295] fix typos in trigger in --- core/src/components/TriggerIn.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/TriggerIn.ts b/core/src/components/TriggerIn.ts index 8ff4c8993..f1c04f742 100644 --- a/core/src/components/TriggerIn.ts +++ b/core/src/components/TriggerIn.ts @@ -9,7 +9,7 @@ import { InputControl } from '../dataControls/InputControl' import { TaskOptions } from '../plugins/taskPlugin/task' import { triggerSocket } from '../sockets' import { ThothComponent, ThothTask } from '../thoth-component' -const info = `The trigger in allows you to pass values into your spell either from a higher level component or fromthe server. Theremust be one single dtrigger in to a spell for now as the server does not support multiple triggers. Yet.` +const info = `The trigger in allows you to pass values into your spell either from a higher level component or from the server. There must be one single trigger into a spell for now as the server does not support multiple triggers. Yet.` export class TriggerIn extends ThothComponent { task: TaskOptions From 337a0d57c5caf2dccd23816095e8178ea4aea1a7 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 15:18:21 -0800 Subject: [PATCH 094/295] Pass scroll to bottom --- client/src/features/common/Window/Window.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/client/src/features/common/Window/Window.tsx b/client/src/features/common/Window/Window.tsx index dba1c2c97..875d3ab93 100644 --- a/client/src/features/common/Window/Window.tsx +++ b/client/src/features/common/Window/Window.tsx @@ -1,14 +1,22 @@ +import { ReactElement, useEffect, useRef } from 'react' import { Scrollbars } from 'react-custom-scrollbars-2' import WindowToolbar from './WindowToolbar' import css from './window.module.css' -import { ReactElement } from 'react' -const WindowLayout = props => { +const WindowLayout = ({ scrollToBottom, children }) => { + const scrollbars = useRef() + + useEffect(() => { + scrollbars.current.scrollToBottom() + }, [scrollToBottom]) + return (
- {props.children} + (scrollbars.current = ref)}> + {children} +
) } @@ -19,6 +27,7 @@ type Props = { borderless?: boolean darker?: boolean grid?: boolean + scrollToBottom?: boolean toolbar?: ReactElement | false children: ReactElement | ReactElement[] } @@ -31,6 +40,7 @@ const Window = (props: Props) => { darker = false, grid = false, toolbar = false, + scrollToBottom = false, } = props return ( @@ -45,7 +55,9 @@ const Window = (props: Props) => { `} > {toolbar && {props.toolbar}} - {props.children} + + {props.children} +
) } From 81cf6623d50bacac0b94afa9b7b665bc305713f0 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 15:18:50 -0800 Subject: [PATCH 095/295] Support scroll to bottom in debugger --- .../Thoth/windows/DebugConsole/index.tsx | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index a814668e1..71f0f4fa6 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useRef } from 'react' +import { useCallback, useEffect, useRef, useState } from 'react' import Terminal from 'react-console-emulator' import { useAuth } from '@/contexts/AuthProvider' import { usePubSub } from '@/contexts/PubSubProvider' @@ -13,6 +13,7 @@ interface Terminal { } const DebugConsole = ({ tab }) => { + const [scrollToBottom, setScrollToBottom] = useState(false) const { user } = useAuth() const { // publish, @@ -26,13 +27,22 @@ const DebugConsole = ({ tab }) => { const terminalRef = useRef() + const scroll = () => { + setScrollToBottom(!scrollToBottom) + } + const printToDebugger = useCallback((_, data) => { const terminal = terminalRef.current if (!terminal) return terminal.pushToStdout(`> ${data.message}`) + scroll() }, []) + const commandCallback = () => { + scroll() + } + useEffect(() => { const unsubscribe = subscribe($DEBUG_PRINT(tab.id), printToDebugger) @@ -54,17 +64,18 @@ const DebugConsole = ({ tab }) => { // https://github.com/linuswillner/react-console-emulator/tree/e2b602f631e8b7c57c4a7407491cbfb84f357519 return ( - + From 32ec2e3adb36135c2134dded7f7a5bb8849f4fd3 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 16:03:31 -0800 Subject: [PATCH 096/295] update error message in debugger --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 31d2120f3..3fe8fa6c0 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -29,7 +29,13 @@ const DebugConsole = ({ tab }) => { const terminal = terminalRef.current if (!terminal) return - terminal.pushToStdout(`> ${data.message}`) + terminal.pushToStdout( + ` + > Error in ${data.errorIn} component. + + > Stack: ${data.errorMessage} + ` + ) }, []) useEffect(() => { From eec95f7b9a89aa17b6eae6ac1cc869ac12a93904 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 16:04:16 -0800 Subject: [PATCH 097/295] update code error message --- core/src/components/Code.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/src/components/Code.ts b/core/src/components/Code.ts index 6967659e3..f9f9501f6 100644 --- a/core/src/components/Code.ts +++ b/core/src/components/Code.ts @@ -100,10 +100,8 @@ export class Code extends ThothComponent { return value } catch (err) { - if (!silent) - node.display( - 'Error evaluating code. Open your browser console for more information.' - ) + if (!silent) node.display(`Error evaluating code.`) + // close the data socket so it doesnt error out this._task.closed = ['data'] throw err From dd56c3d716ffbd52bacecaee7232438581f18864 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 16:04:42 -0800 Subject: [PATCH 098/295] remove console.log in debugger plugin --- core/src/plugins/debuggerPlugin/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 13d874136..27e91f985 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -37,7 +37,6 @@ function install(editor: IRunContextEditor) { node.data.error = true const fullNode = Node.fromJSON(node) - console.log('node object', fullNode) editor.selectNode(fullNode) throw error } From 876fe6d66443d61861b963ed76f6243a57e6aab0 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 16:04:57 -0800 Subject: [PATCH 099/295] update message sent to the debugger from plugin --- core/src/plugins/debuggerPlugin/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 27e91f985..f4f5bfea9 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -33,7 +33,10 @@ function install(editor: IRunContextEditor) { } catch (error: any) { if (!editor.thoth.sendToDebug) return - editor.thoth.sendToDebug({ message: error }) + editor.thoth.sendToDebug({ + errorIn: node.name, + errorMessage: error.stack, + }) node.data.error = true const fullNode = Node.fromJSON(node) From b4d41077f30e5a6b541ea0cb27ae07433061004c Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 16:12:49 -0800 Subject: [PATCH 100/295] Comment out breaking code --- core/src/plugins/debuggerPlugin/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 13d874136..050c81875 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -36,9 +36,9 @@ function install(editor: IRunContextEditor) { editor.thoth.sendToDebug({ message: error }) node.data.error = true - const fullNode = Node.fromJSON(node) - console.log('node object', fullNode) - editor.selectNode(fullNode) + // const fullNode = Node.fromJSON(node) + // console.log('node object', fullNode) + // editor.selectNode(fullNode) throw error } } From d068287c9675b033d3f663fb1b62468369e98ff4 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 16:16:30 -0800 Subject: [PATCH 101/295] Throw proper error in output when no input provided --- core/src/components/Output.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/Output.ts b/core/src/components/Output.ts index adffeb89b..80e1d2ed3 100644 --- a/core/src/components/Output.ts +++ b/core/src/components/Output.ts @@ -74,7 +74,7 @@ export class Output extends ThothComponent { outputs: ThothWorkerOutputs, { silent, thoth }: { silent: boolean; thoth: EngineContext } ) { - console.log('INPUTS', inputs) + if (!inputs.input) throw new Error('No input provided to output component') const text = inputs.input.filter(Boolean)[0] From 178b5810c52ab4624619dd993a901c54e5b34f18 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 16:24:59 -0800 Subject: [PATCH 102/295] Scroll after message --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 019df89f3..356d358f9 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -42,6 +42,8 @@ const DebugConsole = ({ tab }) => { > Stack: ${data.errorMessage} ` ) + + scroll() }, []) const commandCallback = () => { From fc73ac3b2726f5ff02b403b4c89325da68be6a78 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 16:36:17 -0800 Subject: [PATCH 103/295] remove stack from error message --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 4ea08d0bf..e561acfd2 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -33,8 +33,7 @@ const DebugConsole = ({ tab }) => { terminal.pushToStdout( ` > Error in ${data.errorIn} component. - - > Stack: ${data.errorMessage} + > ${data.errorMessage} ` ) }, []) @@ -72,6 +71,7 @@ const DebugConsole = ({ tab }) => { maxHeight: '100%', height: '100%', }} + messageStyle={{ color: 'red' }} /> ) From d8232ed9cc481d39505f988b39848bacf285015e Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 28 Feb 2022 16:38:07 -0800 Subject: [PATCH 104/295] remove stack from sendToDebug message --- 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 f4f5bfea9..0293a5660 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -35,7 +35,7 @@ function install(editor: IRunContextEditor) { editor.thoth.sendToDebug({ errorIn: node.name, - errorMessage: error.stack, + errorMessage: node.data.display, }) node.data.error = true From f4f83e91c88fa6b2943e24c53c180e5731c2f2b0 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 17:05:52 -0800 Subject: [PATCH 105/295] Highlight node in graph on error --- core/src/plugins/debuggerPlugin/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 9b694979e..6fc9d9a81 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -2,6 +2,7 @@ import { NodeEditor } from 'rete/types' import { Node } from 'rete' import { EngineContext } from '../../engine' import { ThothComponent } from '../../thoth-component' +import { NodeData } from '../../../types' interface IRunContextEditor extends NodeEditor { thoth: EngineContext abort: Function @@ -39,9 +40,12 @@ function install(editor: IRunContextEditor) { }) node.data.error = true - // const fullNode = Node.fromJSON(node) - // console.log('node object', fullNode) - // editor.selectNode(fullNode) + const nodeView = [...editor.view.nodes.values()].find( + n => n.node.id === node.id + ) + + nodeView?.onStart() + nodeView?.node.update() throw error } } From 242206c39a9a73261a9729eb1ebc4996fa70d42e Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Mon, 28 Feb 2022 17:06:05 -0800 Subject: [PATCH 106/295] Fix janky scroll to bottom to work --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 356d358f9..2e4c3790a 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -28,7 +28,8 @@ const DebugConsole = ({ tab }) => { const terminalRef = useRef() const scroll = () => { - setScrollToBottom(!scrollToBottom) + setScrollToBottom(false) + setScrollToBottom(true) } const printToDebugger = useCallback((_, data) => { @@ -38,8 +39,6 @@ const DebugConsole = ({ tab }) => { terminal.pushToStdout( ` > Error in ${data.errorIn} component. - - > Stack: ${data.errorMessage} ` ) From bddead82343b11400d9ddc45dd1da43da6d4b261 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 13:18:30 -0800 Subject: [PATCH 107/295] Remove unused imports in debugger plugin --- core/src/plugins/debuggerPlugin/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 3936b966a..f4b9854a8 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -1,8 +1,6 @@ import { NodeEditor } from 'rete/types' -import { Node } from 'rete' import { EngineContext } from '../../engine' import { ThothComponent } from '../../thoth-component' -import { NodeData } from '../../../types' interface IRunContextEditor extends NodeEditor { thoth: EngineContext abort: Function From fe711cb3cb7f7c74b942383f5ef310857e82d543 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 13:38:27 -0800 Subject: [PATCH 108/295] Update area plugin style d ts --- core/src/plugins/areaPlugin/style.css.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/plugins/areaPlugin/style.css.d.ts b/core/src/plugins/areaPlugin/style.css.d.ts index 54edab873..132b232e8 100644 --- a/core/src/plugins/areaPlugin/style.css.d.ts +++ b/core/src/plugins/areaPlugin/style.css.d.ts @@ -1,8 +1,7 @@ // This file is automatically generated. // Please do not change this file! interface CssExports { - 'degfault': string; - 'rete-background': string; + } export const cssExports: CssExports; export default cssExports; From c73b8a85530bbda08a555ecfe178ad514a17fd1b Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 13:39:22 -0800 Subject: [PATCH 109/295] Display proper error message in display 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 f4b9854a8..584d28e23 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -34,7 +34,7 @@ function install(editor: IRunContextEditor) { editor.thoth.sendToDebug({ errorIn: node.name, - errorMessage: node.data.display, + errorMessage: error.message, }) node.data.error = true From 7091041195a06f200bb737fa942def73c2657473 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 16:43:59 -0800 Subject: [PATCH 110/295] Add init engine arguments --- core/src/engine.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/engine.ts b/core/src/engine.ts index 7d725ae2b..968444f41 100644 --- a/core/src/engine.ts +++ b/core/src/engine.ts @@ -52,6 +52,14 @@ export type EngineContext = { onUpdateModule?: Function sendToPlaytest?: Function } + +export type InitEngineArguments = { + name: string + components: any[] + server: boolean + modules?: Record + throwError?: Function +} // @seang TODO: update this to not use positional arguments export const initSharedEngine = ( name: string, From 46871cd197a23d9a677875894f96e4717b72687d Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 16:44:29 -0800 Subject: [PATCH 111/295] Refactor init engine to take an object --- core/src/engine.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/engine.ts b/core/src/engine.ts index 968444f41..d9a5af93a 100644 --- a/core/src/engine.ts +++ b/core/src/engine.ts @@ -61,13 +61,14 @@ export type InitEngineArguments = { throwError?: Function } // @seang TODO: update this to not use positional arguments -export const initSharedEngine = ( - name: string, - components: any[], +export const initSharedEngine = ({ + name, + components, server = false, - modules: Record = {} -) => { - const engine = new Rete.Engine(name) + modules = {}, + throwError, +}: InitEngineArguments) => { + const engine = new Rete.Engine(name) as ThothEngine if (server) { // WARNING: ModulePlugin needs to be initialized before TaskPlugin during engine setup From 21e47691c995a3c1421d3467f3a7901f5d6d8114 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 16:45:40 -0800 Subject: [PATCH 112/295] Use new init engine interface in editor --- core/src/editor.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/editor.ts b/core/src/editor.ts index b5100e9db..0cc5d7667 100644 --- a/core/src/editor.ts +++ b/core/src/editor.ts @@ -122,7 +122,13 @@ export const initEditor = async function ({ }, {} as Record) // The engine is used to process/run the rete graph - const engine = initSharedEngine('demo@0.1.0', components, false, modules) + + const engine = initSharedEngine({ + name: 'demo@0.1.0', + components, + server: false, + modules: {}, + }) // @seang TODO: update types for editor.use rather than casting as unknown here, we may want to bring our custom rete directly into the monorepo at this point // WARNING: ModulePlugin needs to be initialized before TaskPlugin during engine setup From 5a7620e87fe923757a70f1c2a8639bd014a27159 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 16:45:54 -0800 Subject: [PATCH 113/295] Add thoth engine interface --- core/src/engine.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/engine.ts b/core/src/engine.ts index d9a5af93a..01f5c522f 100644 --- a/core/src/engine.ts +++ b/core/src/engine.ts @@ -15,6 +15,11 @@ import TaskPlugin from './plugins/taskPlugin' interface WorkerOutputs { [key: string]: unknown } + +export interface ThothEngine extends Engine { + activateDebugger?: Function + moduleManager?: any +} export abstract class ThothEngineComponent { // Original Class: https://github.com/latitudegames/rete/blob/master/src/engine/component.ts name: string From beb3c3953cfc0c2e198094be2e9f1bdfb1122225 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 16:46:05 -0800 Subject: [PATCH 114/295] Load debugger plugin into engine --- core/src/engine.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/engine.ts b/core/src/engine.ts index 01f5c522f..e3dd01c57 100644 --- a/core/src/engine.ts +++ b/core/src/engine.ts @@ -9,6 +9,7 @@ import { Spell, ThothWorkerInputs, } from '../types' +import debuggerPlugin from './plugins/debuggerPlugin' import ModulePlugin from './plugins/modulePlugin' import TaskPlugin from './plugins/taskPlugin' @@ -77,6 +78,7 @@ export const initSharedEngine = ({ if (server) { // WARNING: ModulePlugin needs to be initialized before TaskPlugin during engine setup + engine.use(debuggerPlugin, { server: true, throwError }) engine.use(ModulePlugin, { engine, modules } as any) engine.use(TaskPlugin) } From 4ad94311048330070e84f962b0500a4df73c9000 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 16:46:23 -0800 Subject: [PATCH 115/295] Pass in throw error and server to debugger install --- core/src/plugins/debuggerPlugin/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 584d28e23..602b3b4a3 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -6,7 +6,10 @@ interface IRunContextEditor extends NodeEditor { abort: Function } -function install(editor: IRunContextEditor) { +function install( + editor: IRunContextEditor, + { server = false, throwError }: { server?: boolean; throwError?: Function } +) { editor.on('componentregister', (component: ThothComponent) => { const worker = component.worker const builder = component.builder From a8d9ae1aee254a1dfa043a5b38c2369e21de9c01 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 16:47:00 -0800 Subject: [PATCH 116/295] Refactor message and add support for custom throw error and server --- core/src/plugins/debuggerPlugin/index.ts | 30 +++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/core/src/plugins/debuggerPlugin/index.ts b/core/src/plugins/debuggerPlugin/index.ts index 602b3b4a3..87354c8a2 100644 --- a/core/src/plugins/debuggerPlugin/index.ts +++ b/core/src/plugins/debuggerPlugin/index.ts @@ -33,21 +33,29 @@ function install( return result } catch (error: any) { - if (!editor.thoth.sendToDebug) return - - editor.thoth.sendToDebug({ + const message = { errorIn: node.name, errorMessage: error.message, - }) - node.data.error = true + } + + if (throwError) { + throwError(message) + return + } + + if (editor.thoth.sendToDebug) editor.thoth.sendToDebug(message) + + if (!server) { + node.data.error = true - const nodeView = [...editor.view.nodes.values()].find( - n => n.node.id === node.id - ) + const nodeView = [...editor.view.nodes.values()].find( + n => n.node.id === node.id + ) - nodeView?.onStart() - nodeView?.node.update() - throw error + nodeView?.onStart() + nodeView?.node.update() + throw error + } } } }) From eb1bbeffb7b333e26dd861e4051e5cd69996b542 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 16:54:31 -0800 Subject: [PATCH 117/295] Import unique name generator --- client/src/features/Thoth/components/EventHandler.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/features/Thoth/components/EventHandler.jsx b/client/src/features/Thoth/components/EventHandler.jsx index e8d8fb514..5a0c5083f 100644 --- a/client/src/features/Thoth/components/EventHandler.jsx +++ b/client/src/features/Thoth/components/EventHandler.jsx @@ -1,4 +1,11 @@ import { useEffect, useRef } from 'react' +import { useSelector } from 'react-redux' + +import { + uniqueNamesGenerator, + adjectives, + colors, +} from 'unique-names-generator' import { useSaveSpellMutation, @@ -8,7 +15,6 @@ import { import { useEditor } from '../contexts/EditorProvider' import { useLayout } from '../contexts/LayoutProvider' import { useModule } from '../../../contexts/ModuleProvider' -import { useSelector } from 'react-redux' const EventHandler = ({ pubSub, tab }) => { // only using this to handle events, so not rendering anything with it. From 514b783713bba9bf46eb1b7ec750a4c695a1d302 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 16:55:13 -0800 Subject: [PATCH 118/295] Add config for unique name generator --- client/src/features/Thoth/components/EventHandler.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/src/features/Thoth/components/EventHandler.jsx b/client/src/features/Thoth/components/EventHandler.jsx index 5a0c5083f..7a506a3f1 100644 --- a/client/src/features/Thoth/components/EventHandler.jsx +++ b/client/src/features/Thoth/components/EventHandler.jsx @@ -16,6 +16,13 @@ import { useEditor } from '../contexts/EditorProvider' import { useLayout } from '../contexts/LayoutProvider' import { useModule } from '../../../contexts/ModuleProvider' +// Config for unique name generator +const customConfig = { + dictionaries: [adjectives, colors], + separator: ' ', + length: 2, +} + const EventHandler = ({ pubSub, tab }) => { // only using this to handle events, so not rendering anything with it. const { createOrFocus, windowTypes } = useLayout() From b7720f4dfe1fecfd35339128b01eaa596c2e7e9c Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Tue, 1 Mar 2022 16:57:24 -0800 Subject: [PATCH 119/295] Change spell name to unique name on export --- client/src/features/Thoth/components/EventHandler.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/features/Thoth/components/EventHandler.jsx b/client/src/features/Thoth/components/EventHandler.jsx index 7a506a3f1..4cd94e2a8 100644 --- a/client/src/features/Thoth/components/EventHandler.jsx +++ b/client/src/features/Thoth/components/EventHandler.jsx @@ -104,6 +104,7 @@ const EventHandler = ({ pubSub, tab }) => { const modules = await getSpellModules(spell) // attach modules to spell to be exported spell.modules = modules + spell.name = uniqueNamesGenerator(customConfig) const json = JSON.stringify(spell) From be8c840772eb13d39cdf3336d8af70e9a139711c Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:14:22 -0800 Subject: [PATCH 120/295] add imports to rete provider --- 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 cfb2fa9f8..8abd6e068 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -12,7 +12,8 @@ import { store } from '../../../state/store' import { invokeInference } from '../../../utils/huggingfaceHelper' import { useDB } from '../../../contexts/DatabaseProvider' import { usePubSub } from '../../../contexts/PubSubProvider' - +import { useFetchFromImageCacheQuery } from '@/state/api/visualGenerationsApi' +import { ImageType } from '@latitudegames/thoth-core/src/components/VisualGeneration' /* 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 8f24682fe451ae1dc0256364e5efe68c93275baf Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:14:58 -0800 Subject: [PATCH 121/295] add readFromImageCache to rete context --- 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 8abd6e068..2e2e4dd81 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -35,6 +35,7 @@ export interface ReteContext extends EngineContext { getModules: () => void getCurrentGameState: () => Record updateCurrentGameState: () => Promise> + readFromImageCache: () => ImageType[] } const Context = createContext({ From 10e05c499c0c5754f02f9e0f37f46a9b38f073d3 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:15:27 -0800 Subject: [PATCH 122/295] add readFromImageCache to context --- client/src/features/Thoth/contexts/ReteProvider.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index 2e2e4dd81..e3465d815 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -67,6 +67,10 @@ const Context = createContext({ await new Promise(resolve => { resolve({} as { [key: string]: unknown; error: unknown }) }), + readFromImageCache: async (): Promise<{ outputs: ImageType[] }> => + await new Promise(resolve => { + resolve({} as { outputs: ImageType[] }) + }), }) export const useRete = () => useContext(Context) From 472c6ab14b4a7ebba53ef7080d2337085715a1dd Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:15:46 -0800 Subject: [PATCH 123/295] define readFromImageCache helper --- client/src/features/Thoth/contexts/ReteProvider.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index e3465d815..d675cbf88 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -164,6 +164,15 @@ const ReteProvider = ({ children, tab }) => { return result } + const readFromImageCache = async (caption, cacheTag, topK) => { + const result = await useFetchFromImageCacheQuery({ + caption, + cacheTag, + topK, + }) + return result + } + const clearTextEditor = () => { publish($TEXT_EDITOR_CLEAR(tab.id)) } From 2996856007378d1117d776b1f5221cf9ab0cd0d4 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:16:00 -0800 Subject: [PATCH 124/295] add readFromImageCache 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 d675cbf88..30437aa92 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -208,6 +208,7 @@ const ReteProvider = ({ children, tab }) => { completion, enkiCompletion, huggingface, + readFromImageCache, getCurrentGameState, updateCurrentGameState, ...modules, From de71711f75a7342cb9b1bd70676b70a815d0bb04 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:16:26 -0800 Subject: [PATCH 125/295] add visual generation api --- client/src/state/api/visualGenerationsApi.ts | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 client/src/state/api/visualGenerationsApi.ts diff --git a/client/src/state/api/visualGenerationsApi.ts b/client/src/state/api/visualGenerationsApi.ts new file mode 100644 index 000000000..16292d125 --- /dev/null +++ b/client/src/state/api/visualGenerationsApi.ts @@ -0,0 +1,22 @@ +import { rootApi } from './api' +import { ImageType } from '@latitudegames/thoth-core/src/components/VisualGeneration' + +export const visualGenerationsApi = rootApi.injectEndpoints({ + endpoints: builder => ({ + fetchFromImageCache: builder.query< + ImageType[], + { caption: string; cacheTag: string; topK: number } + >({ + query: searchOptions => ({ + url: '/image/cache/lookup', + method: 'POST', + body: { + searchOptions, + }, + }), + }), + }), +}) + +export const { useFetchFromImageCacheQuery, useLazyFetchFromImageCacheQuery } = + visualGenerationsApi From b58b911f7b47af3bbc407914858b5342bb9db3fa Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:16:41 -0800 Subject: [PATCH 126/295] add readFromImageCache to engine interface --- core/src/engine.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/engine.ts b/core/src/engine.ts index 7d725ae2b..092f71d1f 100644 --- a/core/src/engine.ts +++ b/core/src/engine.ts @@ -46,6 +46,7 @@ export type EngineContext = { model: string, request: string ) => Promise<{ error: unknown; [key: string]: unknown }> + readFromImageCache: Function onPlaytest?: Function sendToDebug?: Function onAddModule?: Function From d9797c88de56c546aff0c60dcb313fb98823c214 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:17:11 -0800 Subject: [PATCH 127/295] add imports to visual generation component --- core/src/components/VisualGeneration.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 core/src/components/VisualGeneration.ts diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts new file mode 100644 index 000000000..8a83abbaa --- /dev/null +++ b/core/src/components/VisualGeneration.ts @@ -0,0 +1,12 @@ +import Rete from 'rete' +import { + NodeData, + ThothNode, + ThothWorkerInputs, + ThothWorkerOutputs, +} from '../../types' +import { InputControl } from '../dataControls/InputControl' +import { EngineContext } from '../engine' +import { triggerSocket, stringSocket, arraySocket } from '../sockets' +import { ThothComponent } from '../thoth-component' + From 3d4f8de67382014d51d7b50af6b6525772e1843d Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:17:30 -0800 Subject: [PATCH 128/295] define info for visual generation --- core/src/components/VisualGeneration.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index 8a83abbaa..fcc1c8c50 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -10,3 +10,11 @@ import { EngineContext } from '../engine' import { triggerSocket, stringSocket, arraySocket } from '../sockets' import { ThothComponent } from '../thoth-component' +const info = `The VisualGeneration component is used to access the image cache. You pass it a caption, a cacheTag and an optional topK value and it returns an array of images that are related to your caption. + +caption- is a string related to what type of image you want to search for. + +cacheTag- {insert cacheTag description here}. + +topK- number of (k) matches for a particular description. IE: if you submit as a caption: "castle" and k was 5, it would return a fortress, a keep, a battlement, a gatehouse, and a tower. The k=5 images most similar to the word "castle` + From 2a4ded31f7117839ea9296d67dc3653d956b143d Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:17:44 -0800 Subject: [PATCH 129/295] define and export ImageType --- core/src/components/VisualGeneration.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index fcc1c8c50..18c134dda 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -18,3 +18,12 @@ cacheTag- {insert cacheTag description here}. topK- number of (k) matches for a particular description. IE: if you submit as a caption: "castle" and k was 5, it would return a fortress, a keep, a battlement, a gatehouse, and a tower. The k=5 images most similar to the word "castle` +export type ImageType = { + id: string + captionId: string + imageCaption: string + imageUrl: string + tag: string + score: number | string +} + From e938e201ecf01add09fc0f71ecb687c9c6556849 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:17:55 -0800 Subject: [PATCH 130/295] define wroker return type --- core/src/components/VisualGeneration.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index 18c134dda..81659eac1 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -27,3 +27,7 @@ export type ImageType = { score: number | string } +type WorkerReturn = { + images: ImageType[] +} + From f00d678df711b6dd6b1fc72262d085ca41796013 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:18:32 -0800 Subject: [PATCH 131/295] define VisualGeneration class --- core/src/components/VisualGeneration.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index 81659eac1..763ba3d4a 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -31,3 +31,5 @@ type WorkerReturn = { images: ImageType[] } +export class VisualGeneration extends ThothComponent> { +} From eeb563cc882ba410b8d6f8d4df3f318ea3f5e09f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:18:51 -0800 Subject: [PATCH 132/295] add constructor to visual generation class --- core/src/components/VisualGeneration.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index 763ba3d4a..a67e51575 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -32,4 +32,16 @@ type WorkerReturn = { } export class VisualGeneration extends ThothComponent> { + constructor() { + super('VisualGeneration') + this.task = { + outputs: { + images: 'output', + trigger: 'option', + }, + } + this.category = 'AI/ML' + this.info = info + } + } From 441a1128041f87a89fbcf329c81bbb62ad2b122d Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:19:18 -0800 Subject: [PATCH 133/295] define visualGeneration class builder --- core/src/components/VisualGeneration.ts | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index a67e51575..ac67520f7 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -44,4 +44,31 @@ export class VisualGeneration extends ThothComponent> { this.info = info } + builder(node: ThothNode) { + const triggerIn = new Rete.Input('trigger', 'Trigger', triggerSocket, true) + const caption = new Rete.Input('caption', 'Search Term', stringSocket) + const triggerOut = new Rete.Output('trigger', 'Trigger', triggerSocket) + const imagesOut = new Rete.Output('images', 'Images', arraySocket) + + node + .addInput(triggerIn) + .addInput(caption) + .addOutput(triggerOut) + .addOutput(imagesOut) + + const topK = new InputControl({ + dataKey: 'topK', + name: 'topK', + }) + + const cacheTag = new InputControl({ + dataKey: 'cacheTag', + name: 'Cache Tag', + }) + + node.inspector.add(cacheTag).add(topK) + + return node + } + } From a6e5deaf656b5c46ecf255bc0871a170323f10f4 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Tue, 1 Mar 2022 17:19:41 -0800 Subject: [PATCH 134/295] define VisualGeneration worker --- core/src/components/VisualGeneration.ts | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index ac67520f7..91c18214c 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -71,4 +71,32 @@ export class VisualGeneration extends ThothComponent> { return node } + async worker( + node: NodeData, + inputs: ThothWorkerInputs, + outputs: ThothWorkerOutputs, + { thoth }: { silent: boolean; thoth: EngineContext } + ) { + const { readFromImageCache } = thoth + + const caption = inputs.caption[0] + if (!caption) + throw new Error('Input Needed, Please provide a caption input') + + //Need to finish this + const cacheTag = node.data.cacheTag ?? 'some default here' + + try { + const images = await readFromImageCache({ + caption: caption, + cacheTag: cacheTag, + topK: node.data.topK, + }) + return { + images, + } + } catch (err) { + throw new Error('Error in VisualGeneration component') + } + } } From d3661cb68ef88944c21025ec17bd5307b33f2b6e Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 10:55:03 -0800 Subject: [PATCH 135/295] update rtk query for image cache look up --- client/src/state/api/visualGenerationsApi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/state/api/visualGenerationsApi.ts b/client/src/state/api/visualGenerationsApi.ts index 16292d125..b7dcb2e2d 100644 --- a/client/src/state/api/visualGenerationsApi.ts +++ b/client/src/state/api/visualGenerationsApi.ts @@ -5,7 +5,7 @@ export const visualGenerationsApi = rootApi.injectEndpoints({ endpoints: builder => ({ fetchFromImageCache: builder.query< ImageType[], - { caption: string; cacheTag: string; topK: number } + { caption: string; cacheTag?: string; topK?: number } >({ query: searchOptions => ({ url: '/image/cache/lookup', From 4583e41a4b4dc8ca8770a92111a58ed3fb23da47 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 10:55:41 -0800 Subject: [PATCH 136/295] strip out reference to cacheTag in visualgeneration component --- core/src/components/VisualGeneration.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index 91c18214c..850f76c44 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -10,12 +10,10 @@ import { EngineContext } from '../engine' import { triggerSocket, stringSocket, arraySocket } from '../sockets' import { ThothComponent } from '../thoth-component' -const info = `The VisualGeneration component is used to access the image cache. You pass it a caption, a cacheTag and an optional topK value and it returns an array of images that are related to your caption. +const info = `The VisualGeneration component is used to access the image cache. You pass it a caption and an optional topK value and it returns an array of images that are related to your caption. caption- is a string related to what type of image you want to search for. -cacheTag- {insert cacheTag description here}. - topK- number of (k) matches for a particular description. IE: if you submit as a caption: "castle" and k was 5, it would return a fortress, a keep, a battlement, a gatehouse, and a tower. The k=5 images most similar to the word "castle` export type ImageType = { From c7b6605d68b5e4c6ff623e798212974eeafc193c Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 10:56:17 -0800 Subject: [PATCH 137/295] comment out cacheTag varables from visual generation component --- core/src/components/VisualGeneration.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index 850f76c44..faec4cdae 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -81,13 +81,13 @@ export class VisualGeneration extends ThothComponent> { if (!caption) throw new Error('Input Needed, Please provide a caption input') - //Need to finish this - const cacheTag = node.data.cacheTag ?? 'some default here' + //Currently not using this yet + // const cacheTag = node.data.cacheTag ?? 'some default here' try { const images = await readFromImageCache({ caption: caption, - cacheTag: cacheTag, + // cacheTag: cacheTag, topK: node.data.topK, }) return { From 1ce70fbcd3f228eb50baa43b5cf481c91d3de981 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 13:07:56 -0800 Subject: [PATCH 138/295] add visual generation to components.ts --- core/src/components/components.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/components/components.ts b/core/src/components/components.ts index fab2cf41c..2ae1b5818 100644 --- a/core/src/components/components.ts +++ b/core/src/components/components.ts @@ -29,6 +29,7 @@ import { StringProcessor } from './StringProcessor' import { SwitchGate } from './SwitchGate' import { TenseTransformer } from './TenseTransformer' import { TimeDetectorComponent } from './TimeDetector' +import { VisualGeneration } from './VisualGeneration' // Here we load up all components of the builder into our editor for usage. // We might be able to programatically generate components from enki @@ -65,6 +66,7 @@ export const components = { timeDetectorComponent: () => new TimeDetectorComponent(), TriggerIn: () => new TriggerIn(), triggerOut: () => new TriggerOut(), + VisualGeneration: () => new VisualGeneration(), } export const getComponents = () => { From 976d0a237998001965eaa62bbf9bb633acdbc3e6 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 13:08:22 -0800 Subject: [PATCH 139/295] update return type in rete context for visual generation --- client/src/features/Thoth/contexts/ReteProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index 30437aa92..3c41d56e4 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -35,7 +35,7 @@ export interface ReteContext extends EngineContext { getModules: () => void getCurrentGameState: () => Record updateCurrentGameState: () => Promise> - readFromImageCache: () => ImageType[] + readFromImageCache: () => Promise> } const Context = createContext({ From 04a475167bc905ac4d93873f452bdde541899e60 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 14:32:20 -0800 Subject: [PATCH 140/295] add downLevelIteration to tsconfig --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 68ff11207..48e1d6471 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,8 @@ "strictNullChecks": true, "strict": false, "rootDir": ".", - "noEmit": true + "noEmit": true, + "downlevelIteration": true }, "exclude": ["node_modules", "dist", "*.d.ts"], "typeRoots": ["@types/@thoth"] From a8739be9ed8bd587bb48dc0cd26ef780350f5eab Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 14:32:41 -0800 Subject: [PATCH 141/295] update fetchImage import --- client/src/features/Thoth/contexts/ReteProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index 3c41d56e4..7012120c8 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -12,7 +12,7 @@ import { store } from '../../../state/store' import { invokeInference } from '../../../utils/huggingfaceHelper' import { useDB } from '../../../contexts/DatabaseProvider' import { usePubSub } from '../../../contexts/PubSubProvider' -import { useFetchFromImageCacheQuery } from '@/state/api/visualGenerationsApi' +import { useFetchFromImageCacheMutation } from '@/state/api/visualGenerationsApi' import { ImageType } from '@latitudegames/thoth-core/src/components/VisualGeneration' /* 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. From b8b177da66dc4eeeefa6461001d9ac2e01c51bdc Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 14:33:13 -0800 Subject: [PATCH 142/295] destructure fetchFromImage mutation in 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 7012120c8..8da5f2231 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -78,6 +78,8 @@ export const useRete = () => useContext(Context) const ReteProvider = ({ children, tab }) => { const { events, publish, subscribe } = usePubSub() const dispatch = useDispatch() + const [fetchFromImageCache] = useFetchFromImageCacheMutation() + const { models: { spells, modules }, } = useDB() From ec9b92ece9bab5297bbe45fe1c696259c40d5b26 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 14:33:39 -0800 Subject: [PATCH 143/295] update readFromImageCache helper to use new mutation --- client/src/features/Thoth/contexts/ReteProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index 8da5f2231..402c5edd1 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -167,7 +167,7 @@ const ReteProvider = ({ children, tab }) => { } const readFromImageCache = async (caption, cacheTag, topK) => { - const result = await useFetchFromImageCacheQuery({ + const result = await fetchFromImageCache({ caption, cacheTag, topK, From 41fc3aeb7bd33bece8cde78d9e93df453dbaf5e5 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 14:34:32 -0800 Subject: [PATCH 144/295] change fetchFromImageCache from query to mutation --- client/src/state/api/visualGenerationsApi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/state/api/visualGenerationsApi.ts b/client/src/state/api/visualGenerationsApi.ts index b7dcb2e2d..4cecfdc54 100644 --- a/client/src/state/api/visualGenerationsApi.ts +++ b/client/src/state/api/visualGenerationsApi.ts @@ -3,7 +3,7 @@ import { ImageType } from '@latitudegames/thoth-core/src/components/VisualGenera export const visualGenerationsApi = rootApi.injectEndpoints({ endpoints: builder => ({ - fetchFromImageCache: builder.query< + fetchFromImageCache: builder.mutation< ImageType[], { caption: string; cacheTag?: string; topK?: number } >({ From 9316f3e984e33631e522b9fd629f391a0455264e Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 14:34:50 -0800 Subject: [PATCH 145/295] spread mutation options into body --- client/src/state/api/visualGenerationsApi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/state/api/visualGenerationsApi.ts b/client/src/state/api/visualGenerationsApi.ts index 4cecfdc54..57d8c0a91 100644 --- a/client/src/state/api/visualGenerationsApi.ts +++ b/client/src/state/api/visualGenerationsApi.ts @@ -11,7 +11,7 @@ export const visualGenerationsApi = rootApi.injectEndpoints({ url: '/image/cache/lookup', method: 'POST', body: { - searchOptions, + ...searchOptions, }, }), }), From bd66e05959f91f9f87ed5bc90699893c89500d66 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 14:35:02 -0800 Subject: [PATCH 146/295] export the new mutation hook --- client/src/state/api/visualGenerationsApi.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/src/state/api/visualGenerationsApi.ts b/client/src/state/api/visualGenerationsApi.ts index 57d8c0a91..dae127db2 100644 --- a/client/src/state/api/visualGenerationsApi.ts +++ b/client/src/state/api/visualGenerationsApi.ts @@ -18,5 +18,4 @@ export const visualGenerationsApi = rootApi.injectEndpoints({ }), }) -export const { useFetchFromImageCacheQuery, useLazyFetchFromImageCacheQuery } = - visualGenerationsApi +export const { useFetchFromImageCacheMutation } = visualGenerationsApi From e7e9e725b30f0a556743632c0682e9bf4e3a240f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 14:35:48 -0800 Subject: [PATCH 147/295] comment out cacheTag control for now --- core/src/components/VisualGeneration.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index faec4cdae..f1785b2fe 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -59,12 +59,12 @@ export class VisualGeneration extends ThothComponent> { name: 'topK', }) - const cacheTag = new InputControl({ - dataKey: 'cacheTag', - name: 'Cache Tag', - }) + // const cacheTag = new InputControl({ + // dataKey: 'cacheTag', + // name: 'Cache Tag', + // }) - node.inspector.add(cacheTag).add(topK) + node.inspector.add(topK) return node } From 635811da0aff8259a6bf464b62a3fc566db26c6a Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 14:38:18 -0800 Subject: [PATCH 148/295] change searchTerm to caption --- core/src/components/VisualGeneration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index f1785b2fe..8f7b3c385 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -44,7 +44,7 @@ export class VisualGeneration extends ThothComponent> { builder(node: ThothNode) { const triggerIn = new Rete.Input('trigger', 'Trigger', triggerSocket, true) - const caption = new Rete.Input('caption', 'Search Term', stringSocket) + const caption = new Rete.Input('caption', 'Caption', stringSocket) const triggerOut = new Rete.Output('trigger', 'Trigger', triggerSocket) const imagesOut = new Rete.Output('images', 'Images', arraySocket) From a71b5668c95a683575ad1eba6c214b0925176a7a Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 14:39:13 -0800 Subject: [PATCH 149/295] pass in cacheTag as undefined and all arguments without an object wrapper --- core/src/components/VisualGeneration.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/src/components/VisualGeneration.ts b/core/src/components/VisualGeneration.ts index 8f7b3c385..ea23a2f6b 100644 --- a/core/src/components/VisualGeneration.ts +++ b/core/src/components/VisualGeneration.ts @@ -82,14 +82,10 @@ export class VisualGeneration extends ThothComponent> { throw new Error('Input Needed, Please provide a caption input') //Currently not using this yet - // const cacheTag = node.data.cacheTag ?? 'some default here' + const cacheTag = node.data.cacheTag ?? undefined try { - const images = await readFromImageCache({ - caption: caption, - // cacheTag: cacheTag, - topK: node.data.topK, - }) + const images = await readFromImageCache(caption, cacheTag, node.data.topK) return { images, } From e30bd4525d5e4ceb7ec28e70d3d9856b430a9851 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Wed, 2 Mar 2022 14:40:38 -0800 Subject: [PATCH 150/295] stringify display val if not a string to stop console error --- core/src/plugins/displayPlugin/DisplayControl.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/plugins/displayPlugin/DisplayControl.js b/core/src/plugins/displayPlugin/DisplayControl.js index dc930f155..4bf5991a1 100644 --- a/core/src/plugins/displayPlugin/DisplayControl.js +++ b/core/src/plugins/displayPlugin/DisplayControl.js @@ -18,8 +18,12 @@ export class DisplayControl extends Control { } display(val) { - this.props.display = val - this.putData('display', val) + const valIsString = typeof val === 'string' + + this.props.display = !valIsString ? JSON.stringify(val) : val + + this.putData('display', !valIsString ? JSON.stringify(val) : val) + this.update() } } From 0dae62c409e90ed02c44548dc9a604da890eea15 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 11:03:04 -0800 Subject: [PATCH 151/295] Add model notes --- model-notes.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 model-notes.md diff --git a/model-notes.md b/model-notes.md new file mode 100644 index 000000000..d39003063 --- /dev/null +++ b/model-notes.md @@ -0,0 +1,76 @@ +## Notes + +- Need a universal structure for models and options +- each model should have different defaults provided for itself +- model switcher needs to live in thoth-core, but is consumed on the react client to populate the data options +- provide all values needed and filter on frontend rather than programmatically add or remove inspector elements + +## MODEL DATA SHAPES + +GPT-J completion + +{ +"model": "gpt-j-6b-story-gutenberg-rw-bibliotik-raw", +"modelSource": "coreweave", +"text": "A long time ago, in a galaxy far far away there was", +"length": 45, +"topP": 0.9, +"n": 4, +"temperature": 1 +} + +ForeFront + +{ +"modelSource": "forefront", +"model": "forefront model", +"prompt": "A long time ago, in a galaxy far far away there was", +"maxTokens": 50, +"topP": 0.9, +"n": 2, +"universalFormat": true, +"temperature": 1 +} + +Jurassic 1 Jumbo + +{ +"model": "j1-jumbo", +"modelSource": "ai21", +"prompt": "A long time ago, in a galaxy far far away there was", +"maxTokens": 45, +"n": 3, +"temperature": 1, +"stop": "\n" +} + +Jurassic 1 large + +{ +"model": "j1-large", +"modelSource": "ai21", +"prompt": "A long time ago, in a galaxy far far away there was", +"maxTokens": 45, +"n": 3, +"temperature": 1, +"stop": "\n" +} + +Open AI + +{ +"universalFormat": true, +"prompt": "Once upon a time in a forgotten forest", +"presencePenalty": 0.0, +"temperature": 0.7, +"maxTokens": 120, +"n":3, +"logitBias":{}, +"getFullResponse":true, +"context": { +"productTaskName": "testTaskName", +"productRequestId": "textRequestId", +"userId": "225", +"fewshotText": "testFewshotText" +} +} From e40b45a70569e36e27143ebadc8460ef9cca7436 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 11:03:15 -0800 Subject: [PATCH 152/295] Add model helper data structure --- core/src/utils/modelHelper.ts | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 core/src/utils/modelHelper.ts diff --git a/core/src/utils/modelHelper.ts b/core/src/utils/modelHelper.ts new file mode 100644 index 000000000..517048b7e --- /dev/null +++ b/core/src/utils/modelHelper.ts @@ -0,0 +1,56 @@ +export const modelMap = { + gptj: { + name: 'GPT-J', + model: 'gpt-j-6b-story-gutenberg-rw-bibliotik-raw', + modelSource: 'coreweave', + text: 'A long time ago, in a galaxy far far away there was', + length: 45, + topP: 0.9, + n: 4, + temperature: 1, + universalFormat: true, + }, + jurassicJumbo: { + name: 'Jurassic Jumbo', + model: 'j1-jumbo', + modelSource: 'ai21', + prompt: 'A long time ago, in a galaxy far far away there was', + maxTokens: 45, + n: 3, + temperature: 1, + stop: '\n', + universalFormat: true, + }, + jurassicLarge: { + name: 'Jurassic Large', + model: 'j1-large', + modelSource: 'ai21', + prompt: 'A long time ago, in a galaxy far far away there was', + maxTokens: 45, + n: 3, + temperature: 1, + stop: '\n', + universalFormat: true, + }, + openai: { + modelSource: 'openai', + model: 'davinci', + prompt: 'Once upon a time in a forgotten forest', + temperature: 0.7, + maxTokens: 120, + stop: '\n', + n: 3, + universalFormat: true, + }, + forefront: { + name: 'forefront', + modelSource: 'forefront', + model: 'forefront model', + prompt: 'A long time ago, in a galaxy far far away there was', + maxTokens: 50, + topP: 0.9, + n: 2, + universalFormat: true, + temperature: 1, + }, +} From c9640fe8c0a98aef2516016db8fb95a51bc65316 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:18:09 -0800 Subject: [PATCH 153/295] Update react router dom to 6 --- client/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/package.json b/client/package.json index 620864891..143098e57 100644 --- a/client/package.json +++ b/client/package.json @@ -48,7 +48,7 @@ "react-pouchdb": "^2.1.0", "react-redux": "^7.2.5", "react-router": "^6.0.0-beta.8", - "react-router-dom": "^6.0.0-beta.8", + "react-router-dom": "6", "react-select": "^4.3.1", "react-simple-code-editor": "^0.11.0", "rebass": "^4.0.7", From aae168d55c911bcf76ce23e18a706f1d0994bd15 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:18:34 -0800 Subject: [PATCH 154/295] Update yarn lock --- yarn.lock | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index 32aff8e4f..f5e1bcb25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7572,6 +7572,13 @@ history@^5.0.1: dependencies: "@babel/runtime" "^7.7.6" +history@^5.2.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/history/-/history-5.3.0.tgz#1548abaa245ba47992f063a0783db91ef201c73b" + integrity sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ== + dependencies: + "@babel/runtime" "^7.7.6" + hmac-drbg@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" @@ -11876,14 +11883,22 @@ react-redux@^7.2.5: prop-types "^15.7.2" react-is "^16.13.1" -react-router-dom@^6.0.0-beta.8: - version "6.0.0-beta.8" - resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.0.0-beta.8.tgz#911c2dcaa746b589fb2085cfe41404b808629a76" - integrity sha512-WyiIc6EakJDCo6rUmb7VjCtOpEvm8+4V8CiJdmFPud0lppeNf37TNhTnDQszDbP2y29wBUGb94BOFU2X93uILA== +react-router-dom@6: + version "6.2.2" + resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.2.2.tgz#f1a2c88365593c76b9612ae80154a13fcb72e442" + integrity sha512-AtYEsAST7bDD4dLSQHDnk/qxWLJdad5t1HFa1qJyUrCeGgEuCSw0VB/27ARbF9Fi/W5598ujvJOm3ujUCVzuYQ== + dependencies: + history "^5.2.0" + react-router "6.2.2" + +react-router@6.2.2: + version "6.2.2" + resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.2.2.tgz#495e683a0c04461eeb3d705fe445d6cf42f0c249" + integrity sha512-/MbxyLzd7Q7amp4gDOGaYvXwhEojkJD5BtExkuKmj39VEE0m3l/zipf6h2WIB2jyAO0lI6NGETh4RDcktRm4AQ== dependencies: - react-router "6.0.0-beta.8" + history "^5.2.0" -react-router@6.0.0-beta.8, react-router@^6.0.0-beta.8: +react-router@^6.0.0-beta.8: version "6.0.0-beta.8" resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.0.0-beta.8.tgz#99d570b0eaadac9af590e08fd8229d8c3f5558fd" integrity sha512-pn3j01FA44yWP5gaHvz3CMVjFnmg5NS/BQ5IIalY7jw2yEKgr+OHB1gxTorakpiMaPOXXbfyUt3t4yZ4UBwE5Q== From 897d26c49354b791d73221c7a55071b09afc1a47 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:18:45 -0800 Subject: [PATCH 155/295] Add require auth component --- .../src/features/common/RequireAuth/RequireAuth.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 client/src/features/common/RequireAuth/RequireAuth.tsx diff --git a/client/src/features/common/RequireAuth/RequireAuth.tsx b/client/src/features/common/RequireAuth/RequireAuth.tsx new file mode 100644 index 000000000..282829a20 --- /dev/null +++ b/client/src/features/common/RequireAuth/RequireAuth.tsx @@ -0,0 +1,12 @@ +import { Outlet, Navigate } from 'react-router-dom' +import { useAuth } from '../../../contexts/AuthProvider' + +const RequireAuth = (props: Record) => { + const { user } = useAuth() + + const auth = user && user.accessToken + + return auth ? : +} + +export default RequireAuth From b4b43cf118f177bef97281229b9b3f85b355f175 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:33:25 -0800 Subject: [PATCH 156/295] add uuidv4 helper --- client/src/utils/uuid.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 client/src/utils/uuid.ts diff --git a/client/src/utils/uuid.ts b/client/src/utils/uuid.ts new file mode 100644 index 000000000..ae0d819e9 --- /dev/null +++ b/client/src/utils/uuid.ts @@ -0,0 +1,12 @@ +export const uuidv4 = () => { + return "10000000-1000-4000-8000-100000000000".replace( + /[018]/g, + (c: string) => { + const d = parseInt(c); + return ( + d ^ + (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (d / 4))) + ).toString(16); + } + ); +}; From 507103aaeea1614b6ad28c1bd0f90237151e2cfa Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:33:44 -0800 Subject: [PATCH 157/295] pull over async storage --- client/src/utils/AsyncStorage.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 client/src/utils/AsyncStorage.ts diff --git a/client/src/utils/AsyncStorage.ts b/client/src/utils/AsyncStorage.ts new file mode 100644 index 000000000..8bf936079 --- /dev/null +++ b/client/src/utils/AsyncStorage.ts @@ -0,0 +1,27 @@ +import AsyncStorage from '@callstack/async-storage' + +export const getItem = (key: string) => { + return AsyncStorage.getItem(key).then((value: string) => { + try { + if (value === 'undefined') { + return null + } + const parsedValue = JSON.parse(value) + return parsedValue + } catch { + return value + } + }) +} + +export const setItem = (key: string, value: string) => { + return AsyncStorage.setItem(key, value) +} + +export const removeItem = (item: string) => { + return AsyncStorage.removeItem(item) +} + +export const clearStorage = () => { + AsyncStorage.clear() +} From 0fb6471a1b19ca8f28e6688219195fe1b39cd103 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:34:39 -0800 Subject: [PATCH 158/295] import getAuthHeder into api --- client/src/state/api/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/state/api/api.ts b/client/src/state/api/api.ts index 32160f9df..a2340ef5c 100644 --- a/client/src/state/api/api.ts +++ b/client/src/state/api/api.ts @@ -1,5 +1,5 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react' -import { getAuthHeader } from '../../utils/authHelper' +import { getAuthHeader } from '../../contexts/NewAuthProvider' // initialize an empty api service that we'll inject endpoints into later as needed export const rootApi = createApi({ From 4daafb01ff241d180435a73461f07dce67d1ce35 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:35:23 -0800 Subject: [PATCH 159/295] use async getAuthHeaders helper in api --- client/src/state/api/api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/state/api/api.ts b/client/src/state/api/api.ts index a2340ef5c..43064dbdc 100644 --- a/client/src/state/api/api.ts +++ b/client/src/state/api/api.ts @@ -6,8 +6,8 @@ export const rootApi = createApi({ reducerPath: 'api', baseQuery: fetchBaseQuery({ baseUrl: `${process.env.REACT_APP_API_URL}/` || 'localhost:8000/', - prepareHeaders: headers => { - const authHeader = getAuthHeader() + prepareHeaders: async headers => { + const authHeader = await getAuthHeader() if (authHeader?.Authorization) headers.set('authorization', authHeader['Authorization']) return headers From 70e368657358341ce8267a5b42216aa9679c2245 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:35:33 -0800 Subject: [PATCH 160/295] add useQuery helper --- client/src/hooks/useQuery.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 client/src/hooks/useQuery.ts diff --git a/client/src/hooks/useQuery.ts b/client/src/hooks/useQuery.ts new file mode 100644 index 000000000..a4b671b8d --- /dev/null +++ b/client/src/hooks/useQuery.ts @@ -0,0 +1,5 @@ +import { useLocation } from "react-router-dom"; + +export const useQuery = () => { + return new URLSearchParams(useLocation().search); +}; From 6f5a4e75cc44523cf5428ba96daf83b59597d9ab Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:37:15 -0800 Subject: [PATCH 161/295] Import require auth --- client/src/App.js | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/App.js b/client/src/App.js index c629356cb..9a25c62e5 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -3,6 +3,7 @@ import { Routes, Route, Navigate, useNavigate } from 'react-router-dom' import { useAuth } from './contexts/AuthProvider' import { useTabManager } from './contexts/TabManagerProvider' +import RequireAuth from './features/common/RequireAuth/RequireAuth' import GuardedRoute from './features/common/GuardedRoute/GuardedRoute' import LoadingScreen from './features/common/LoadingScreen/LoadingScreen' import ThothPageWrapper from './features/common/ThothPage/ThothPageWrapper' From e6be84a160a6d560e4c8c5d402e5d5acd49ddafb Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:37:28 -0800 Subject: [PATCH 162/295] Set up require auth element --- client/src/App.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/App.js b/client/src/App.js index 9a25c62e5..4f7fedb8e 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -51,6 +51,8 @@ function App() { return ( + }> + } /> } /> } /> From 203de4ce3f428e9987a6a66649d285d980ec0b63 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:37:52 -0800 Subject: [PATCH 163/295] Drop route guards --- client/src/App.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/App.js b/client/src/App.js index 4f7fedb8e..924840b69 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -54,8 +54,8 @@ function App() { }> } /> - } /> - } /> + } /> + } /> From 958ed2713a8746d3d2d0a741ce9fc9f1710bc750 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:38:07 -0800 Subject: [PATCH 164/295] add expire helper --- client/src/helpers/Expire.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 client/src/helpers/Expire.ts diff --git a/client/src/helpers/Expire.ts b/client/src/helpers/Expire.ts new file mode 100644 index 000000000..561740834 --- /dev/null +++ b/client/src/helpers/Expire.ts @@ -0,0 +1,18 @@ +import { getSessionId } from '../contexts/NewAuthProvider' +import { latitudeApiRootUrl } from '../config' + +export const callExpire = async () => { + const sessionId = await getSessionId() + const endpoint = `${latitudeApiRootUrl}/user/expire` + await fetch(endpoint, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + Authorization: `session ${sessionId}`, + }, + }).catch(err => { + // throw new Error(err) + // eslint-disable-next-line no-console + console.log(err) + }) +} From 1a7cb79d4e3cc944ceeeb2f36c68aab47ce74193 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:38:25 -0800 Subject: [PATCH 165/295] create new Auth provider --- client/src/contexts/NewAuthProvider.tsx | 286 ++++++++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 client/src/contexts/NewAuthProvider.tsx diff --git a/client/src/contexts/NewAuthProvider.tsx b/client/src/contexts/NewAuthProvider.tsx new file mode 100644 index 000000000..4a06360cd --- /dev/null +++ b/client/src/contexts/NewAuthProvider.tsx @@ -0,0 +1,286 @@ +import { + createContext, + useEffect, + useState, + useContext, + ReactElement, +} from 'react' +import { uuidv4 } from '../utils/uuid' +import { setItem, getItem } from '../utils/AsyncStorage' +import { useQuery } from '../hooks/useQuery' +import { useLocation } from 'react-router-dom' +import { oAuthClientId, latitudeApiRootUrl, appRootUrl } from '../config' +// import { callQuery, callIncrement } from '../utils/queryApi' +import { callExpire } from '../helpers/Expire' +// import { useDB } from './DatabaseProvider' + +interface SessionInfoType { + id: number + email: string + expiresAt: number + username: string + appRootUrl: string +} + +interface UserInfoType { + id: number + email: string + groups: string[] + username: string +} + +const initialState = { + session: {} as SessionInfoType | null, + user: {} as UserInfoType | null, + logoutAndRedirect: () => {}, + loginRedirect: (force?: boolean, returnToPath?: string) => {}, + refreshSession: (origin: string) => {}, +} + +const AuthContext = createContext(initialState) + +export const useAuthContext = () => useContext(AuthContext) + +const AuthProvider = ({ children }: { children: ReactElement }) => { + const [done, setDone] = useState(false) + const [sessionInfo, setSessionInfo] = useState(null) + const [userInfo, setUserInfo] = useState(null) + const query = useQuery() + const code = query.get('code') + const state = query.get('state') + const location = useLocation() + // const { models } = useDB() + + const loginRedirect = async (force = false, returnToPath = '') => { + console.log('loginredirect') + // User not logged in or session expired, set state and send to login + const state = uuidv4() + await setOauthState(state) + await setStateStore(state, { + origin: returnToPath ? returnToPath : window.location.pathname, + }) + console.log( + 'redirecting too:', + `${latitudeApiRootUrl}/user/auth/authorize?client_id=${oAuthClientId}&state=${state}&redirect_uri=${encodeURIComponent( + `${appRootUrl}/callback` + )}${force ? `&force=true` : ''}` + ) + window.location.href = `${latitudeApiRootUrl}/user/auth/authorize?client_id=${oAuthClientId}&state=${state}&redirect_uri=${encodeURIComponent( + `${appRootUrl}/callback` + )}${force ? `&force=true` : ''}` + } + + const initialize = (search?: string) => { + // Remove auth specific query params after use + let queryString = '' + if (search) { + let queryDictionary = JSON.parse( + '{"' + + search.substring(1).replace(/&/g, '","').replace(/=/g, '":"') + + '"}', + function (key, value) { + return key === '' ? value : decodeURIComponent(value) + } + ) + + delete queryDictionary['client_id'] + delete queryDictionary['redirect_uri'] + // TODO @seang: only remove state after consumed by the callback origin logic elsewhere + // delete queryDictionary['state'] + delete queryDictionary['grant'] + delete queryDictionary['code'] + + queryString = + '?' + + Object.keys(queryDictionary) + .map(key => key + '=' + queryDictionary[key]) + .join('&') + } + + window.history.replaceState( + {}, + '', + window.location.origin + window.location.pathname + queryString + ) + // Clear query params from url bar + removeOauthState() + // Clean up Oauth variable + } + + const removeData = () => { + // removeUser() + removeSessionId() + } + + const approveOrRemove = async ( + sessionInfoParam: SessionInfoType, + userInfo: UserInfoType + ) => { + if ( + userInfo?.id && + new Date(sessionInfoParam.expiresAt).valueOf() > Date.now() + ) { + setSessionInfo(sessionInfoParam) + setUserInfo(userInfo) + console.log(userInfo) + + let search = window.location.search.toString() + initialize(search) + } + setDone(true) + } + + const logoutAndRedirect = async () => { + await callExpire() + removeData() + window.location.href = `${latitudeApiRootUrl}/user/logout?returnTo=${encodeURIComponent( + appRootUrl as string + )}` + } + + const refreshSession = async (origin: string) => { + const state = uuidv4() + removeData() + await setStateStore(state, { origin: origin }) + window.location.href = `${latitudeApiRootUrl}/user/auth/refresh?returnTo=${encodeURIComponent( + `${appRootUrl}/callback` + )}&state=${state}` + } + + useEffect(() => { + ;(async () => { + try { + // Check if User has an existing sessionId in local storage + const sessionId = await getSessionId() + + console.log('im running', sessionId) + if (sessionId) { + const sessionReq = await fetch( + `${latitudeApiRootUrl}/user/auth/info?access_token=${sessionId}` + ) + const userReq = await fetch(`${latitudeApiRootUrl}/user/info`, { + headers: { + authorization: `session ${sessionId}`, + }, + }) + + const sessionInfo = await sessionReq.json() + const userInfo = await userReq.json() + approveOrRemove(sessionInfo, userInfo) + } + } catch (error) { + // remove invalid sessionId from local storage to prevent loops, redirect to login and return to prevent further conditions + removeData() + await loginRedirect() + } + + // User has authenticated and was just redirected to the client + if (code) { + const authState = await getOauthState() + // This is a critical security gate. Do not remove. + if (authState && state === authState) { + const tokenRequest = await fetch( + `${latitudeApiRootUrl}/user/auth/token`, + { + method: 'POST', + body: JSON.stringify({ + code: code, + grant_type: 'authorization_code', + redirect_uri: `${appRootUrl}/callback`, + client_id: oAuthClientId, + }), + headers: { 'Content-Type': 'application/json' }, + } + ) + + try { + const tokenResponse = await tokenRequest.json() + const { access_token } = tokenResponse + if (!access_token) return + await setSessionId(access_token) + const sessionReq = await fetch( + `${latitudeApiRootUrl}/user/auth/info?access_token=${access_token}` + ) + const userReq = await fetch(`${latitudeApiRootUrl}/user/info`, { + headers: { + authorization: `session ${access_token}`, + }, + }) + const sessionInfo = await sessionReq.json() + const userInfo = await userReq.json() + approveOrRemove(sessionInfo, userInfo) + } catch (error) { + removeData() + } + } + } else { + setDone(true) + } + })() + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [location.pathname, code, state]) + + const publicInterface = { + session: sessionInfo, + user: userInfo, + logoutAndRedirect, + loginRedirect, + refreshSession, + } + + if (!done) return <> + + return ( + + {children} + + ) +} + +export default AuthProvider + +export const getAuthHeader = async () => { + const sessionId = await getSessionId() + const header = { + Authorization: `session ${sessionId}`, + } + return header +} + +export const setSessionId = async (sessionId: string) => { + await setItem('sessionId', sessionId) +} + +export const getSessionId = async () => { + const sessionId = await getItem('sessionId') + return sessionId +} + +export const removeSessionId = async () => { + window.localStorage.removeItem('sessionId') +} + +export const setOauthState = async (oauthState: string) => { + await setItem('oauthState', oauthState) +} + +export const setStateStore = async ( + state: string, + store: Record +) => { + await setItem(state, JSON.stringify(store)) +} + +export const getStateStore = async (state: string) => { + const store = await getItem(state) + window.localStorage.removeItem(state) + return store +} + +export const getOauthState = async () => { + return await getItem('oauthState') +} + +export const removeOauthState = async () => { + window.localStorage.removeItem('oauthState') +} From d510ac16fc4ae9f9ad5fa9bdae4eb6036a2cc08b Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:38:37 -0800 Subject: [PATCH 166/295] Move routes into require auth wrapper --- client/src/App.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/src/App.js b/client/src/App.js index 924840b69..0c0e59714 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -51,12 +51,12 @@ function App() { return ( - }> - - } /> - } /> - } /> - + }> + } /> + } /> + } /> + + ) From 073987bd3dab869119188d514c7c2f39a40affa0 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:38:46 -0800 Subject: [PATCH 167/295] add newAuthProver to app provider list --- client/src/contexts/AppProviders.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/contexts/AppProviders.jsx b/client/src/contexts/AppProviders.jsx index 5df77ca46..b18218820 100644 --- a/client/src/contexts/AppProviders.jsx +++ b/client/src/contexts/AppProviders.jsx @@ -1,6 +1,7 @@ import { createTheme, ThemeProvider } from '@material-ui/core/styles' import AuthProvider from './AuthProvider' +import NewAuthProvider from './NewAuthProvider' import DatabaseProvider from './DatabaseProvider' import ModuleProvider from './ModuleProvider' import PubSubProvider from './PubSubProvider' @@ -17,8 +18,9 @@ const providers = [ PubSubProvider, [ThemeProvider, { theme: darkTheme }], ToastProvider, + NewAuthProvider, DatabaseProvider, - AuthProvider, + // AuthProvider, ModuleProvider, TabManagerProvider, ] From 6188c9e283ad01e91dc3ca98fd58d1af6a6064e6 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:39:12 -0800 Subject: [PATCH 168/295] move newAuthProvider down one level --- client/src/contexts/AppProviders.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/contexts/AppProviders.jsx b/client/src/contexts/AppProviders.jsx index b18218820..d0dfd0cec 100644 --- a/client/src/contexts/AppProviders.jsx +++ b/client/src/contexts/AppProviders.jsx @@ -18,8 +18,8 @@ const providers = [ PubSubProvider, [ThemeProvider, { theme: darkTheme }], ToastProvider, - NewAuthProvider, DatabaseProvider, + NewAuthProvider, // AuthProvider, ModuleProvider, TabManagerProvider, From 90bff4a52e300b5871d595ca7f8a75e23868d97d Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:39:34 -0800 Subject: [PATCH 169/295] add config and update --- client/src/config.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 client/src/config.ts diff --git a/client/src/config.ts b/client/src/config.ts new file mode 100644 index 000000000..c1e20e01d --- /dev/null +++ b/client/src/config.ts @@ -0,0 +1,18 @@ +export const latitudeApiRootUrl = + process.env.NODE_ENV === 'production' + ? (process.env.REACT_APP_LAPI_ROOT_URL_PROD as string) + : (process.env.REACT_APP_LAPI_ROOT_URL as string) + +export const redirectUri = + process.env.NODE_ENV === 'production' + ? (process.env.REACT_APP_SITE_ROOT_URL_PROD as string) + : (process.env.REACT_APP_SITE_ROOT_URL as string) + +export const oAuthClientId = process.env.REACT_APP_OAUTH_CLIENT_ID + +export const appRootUrl = + process.env.NODE_ENV === 'production' + ? window.location.origin.includes('deploy-preview') + ? 'https://deploy-preview-148--optimistic-turing-def916.netlify.app/' + : process.env.REACT_APP_SITE_ROOT_URL_PROD + : process.env.REACT_APP_SITE_ROOT_URL From 4468a8246e106d8d3f5767c59e71683cc275f4f8 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:41:25 -0800 Subject: [PATCH 170/295] Add route params to thoth route --- client/src/App.js | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/App.js b/client/src/App.js index 0c0e59714..f3ac3cc1e 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -54,6 +54,7 @@ function App() { }> } /> } /> + } /> } /> From 4371c617477d05595219d5bb9568068704a20a5f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:41:54 -0800 Subject: [PATCH 171/295] update env --- client/.env | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/.env b/client/.env index d9cc8a9d6..8c379ed0e 100644 --- a/client/.env +++ b/client/.env @@ -2,3 +2,15 @@ # REACT_APP_API_URL=https://latitude-api-staging.herokuapp.com REACT_APP_API_URL=http://localhost:8000 EXTEND_ESLINT = true + +# Everything below is used for the new auth provider + +# This prod site root assumes the netlify build context $URL is available, replace for other hosts + +REACT_APP_SITE_ROOT_URL_PROD=$URL +REACT_APP_SITE_ROOT_URL=http://localhost:3001 +REACT_APP_LAPI_ROOT_URL=http://localhost:8000 +REACT_APP_LAPI_ROOT_URL_PROD=https://api.latitude.io + +# Oauth Client Id +REACT_APP_OAUTH_CLIENT_ID=a6b51c87-7565-42ab-a4b0-38a07f3b6c56 \ No newline at end of file From 036c52da082370ab113bec09196cbae528870494 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 13:42:10 -0800 Subject: [PATCH 172/295] add async storage package --- client/package.json | 1 + yarn.lock | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/client/package.json b/client/package.json index 620864891..9f03da32f 100644 --- a/client/package.json +++ b/client/package.json @@ -13,6 +13,7 @@ "install:canary": "yarn add @latitudegames/thoth-core@canary" }, "dependencies": { + "@callstack/async-storage": "^2.0.3", "@latitudegames/thoth-core": "^0.0.59", "@material-ui/core": "^4.12.1", "@material-ui/icons": "^4.11.2", diff --git a/yarn.lock b/yarn.lock index 32aff8e4f..6ed9df1e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1083,6 +1083,13 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@callstack/async-storage@^2.0.3": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@callstack/async-storage/-/async-storage-2.0.3.tgz#93fc98f768926024fe01d759acaba6c80feb5727" + integrity sha512-JK/cV/nRHdYDdBmT0GZ7otywZXFNpWMuzjkGgeyhd/Pc+alpaSspg73U6lxFBM5ndnY+T1iQ3RSfUZl3QG+nwQ== + dependencies: + lodash.merge "^4.6.0" + "@craco/craco@^5.5.0": version "5.9.0" resolved "https://registry.yarnpkg.com/@craco/craco/-/craco-5.9.0.tgz#dcd34330b558596a4841374743071b7fa041dce9" @@ -9550,6 +9557,11 @@ lodash.ismatch@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37" integrity sha1-dWy1FQyjum8RCFp4hJZF8Yj4Xzc= +lodash.merge@^4.6.0: + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== + lodash.template@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab" @@ -12420,6 +12432,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 e03942c496cb7f131349d47f487064db2d7c760c Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:42:14 -0800 Subject: [PATCH 173/295] Extract spell name from params in thoth component --- client/src/features/Thoth/Thoth.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/features/Thoth/Thoth.tsx b/client/src/features/Thoth/Thoth.tsx index 5e2bd2208..be6d74acd 100644 --- a/client/src/features/Thoth/Thoth.tsx +++ b/client/src/features/Thoth/Thoth.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react' import { useHotkeys } from 'react-hotkeys-hook' -import { useNavigate } from 'react-router-dom' +import { useNavigate, useParams } from 'react-router-dom' import { usePubSub } from '../../contexts/PubSubProvider' import { useTabManager } from '../../contexts/TabManagerProvider' @@ -12,6 +12,7 @@ const Thoth = ({ empty }) => { const navigate = useNavigate() const { activeTab, tabs } = useTabManager() const pubSub = usePubSub() + const { spellName } = useParams() const { events, publish } = pubSub From 440229c3a0ad5eb6c95a3d5c6b7296100c208396 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:43:08 -0800 Subject: [PATCH 174/295] Start use effect for spell params --- client/src/features/Thoth/Thoth.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/features/Thoth/Thoth.tsx b/client/src/features/Thoth/Thoth.tsx index be6d74acd..e5107350d 100644 --- a/client/src/features/Thoth/Thoth.tsx +++ b/client/src/features/Thoth/Thoth.tsx @@ -22,6 +22,8 @@ const Thoth = ({ empty }) => { if (!activeTab) navigate('/home') }, [tabs]) + useEffect(() => {}, [spellName]) + useHotkeys( 'Control+z', () => { From a873f034f7a04d9da11f3793988ed661db2ca20f Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:49:38 -0800 Subject: [PATCH 175/295] Update require auth --- .../common/RequireAuth/RequireAuth.tsx | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/client/src/features/common/RequireAuth/RequireAuth.tsx b/client/src/features/common/RequireAuth/RequireAuth.tsx index 282829a20..f88c210fa 100644 --- a/client/src/features/common/RequireAuth/RequireAuth.tsx +++ b/client/src/features/common/RequireAuth/RequireAuth.tsx @@ -1,12 +1,24 @@ -import { Outlet, Navigate } from 'react-router-dom' -import { useAuth } from '../../../contexts/AuthProvider' +import { Outlet } from 'react-router-dom' +import { appRootUrl } from '../../../config' +import { useAuthContext } from '../../../contexts/NewAuthProvider' + +const defaultGroups = ['internal', 'thoth'] const RequireAuth = (props: Record) => { - const { user } = useAuth() + const { user, loginRedirect } = useAuthContext() + const groups = props?.access + ? [...props?.access, ...defaultGroups] + : defaultGroups + + const auth = + user && + !user.groups.includes('public') && + user.groups.some(g => groups.includes(g)) - const auth = user && user.accessToken + if (!auth && user?.id) window.location.href = `${appRootUrl}` + else if (!auth) loginRedirect() - return auth ? : + return } export default RequireAuth From 6ba90a1be4e0e1971c896ef9509d9354fb3efce3 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:49:56 -0800 Subject: [PATCH 176/295] import use navigate --- client/src/features/common/RequireAuth/RequireAuth.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/common/RequireAuth/RequireAuth.tsx b/client/src/features/common/RequireAuth/RequireAuth.tsx index f88c210fa..ead2bfb51 100644 --- a/client/src/features/common/RequireAuth/RequireAuth.tsx +++ b/client/src/features/common/RequireAuth/RequireAuth.tsx @@ -1,4 +1,4 @@ -import { Outlet } from 'react-router-dom' +import { Outlet, useNavigate } from 'react-router-dom' import { appRootUrl } from '../../../config' import { useAuthContext } from '../../../contexts/NewAuthProvider' From 8c9218da2f5fd2a4e1836acb940b92c2777459cc Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:50:43 -0800 Subject: [PATCH 177/295] use navigate inside require auth --- client/src/features/common/RequireAuth/RequireAuth.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/features/common/RequireAuth/RequireAuth.tsx b/client/src/features/common/RequireAuth/RequireAuth.tsx index ead2bfb51..190ff5817 100644 --- a/client/src/features/common/RequireAuth/RequireAuth.tsx +++ b/client/src/features/common/RequireAuth/RequireAuth.tsx @@ -6,6 +6,7 @@ const defaultGroups = ['internal', 'thoth'] const RequireAuth = (props: Record) => { const { user, loginRedirect } = useAuthContext() + const navigate = useNavigate() const groups = props?.access ? [...props?.access, ...defaultGroups] : defaultGroups From b15483d4a8176bfaf7a31f426f868972a6e54483 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:52:06 -0800 Subject: [PATCH 178/295] Navigate to root with react router dom is not authenticated --- client/src/features/common/RequireAuth/RequireAuth.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/common/RequireAuth/RequireAuth.tsx b/client/src/features/common/RequireAuth/RequireAuth.tsx index 190ff5817..b04bd306d 100644 --- a/client/src/features/common/RequireAuth/RequireAuth.tsx +++ b/client/src/features/common/RequireAuth/RequireAuth.tsx @@ -16,7 +16,7 @@ const RequireAuth = (props: Record) => { !user.groups.includes('public') && user.groups.some(g => groups.includes(g)) - if (!auth && user?.id) window.location.href = `${appRootUrl}` + if (!auth && user?.id) navigate('/') else if (!auth) loginRedirect() return From 42e4f383866180a1fe233c13eea95ac3f1d2eeab Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:52:20 -0800 Subject: [PATCH 179/295] Switch auth const name to authorized --- client/src/features/common/RequireAuth/RequireAuth.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/features/common/RequireAuth/RequireAuth.tsx b/client/src/features/common/RequireAuth/RequireAuth.tsx index b04bd306d..3971abd60 100644 --- a/client/src/features/common/RequireAuth/RequireAuth.tsx +++ b/client/src/features/common/RequireAuth/RequireAuth.tsx @@ -11,13 +11,13 @@ const RequireAuth = (props: Record) => { ? [...props?.access, ...defaultGroups] : defaultGroups - const auth = + const authorized = user && !user.groups.includes('public') && user.groups.some(g => groups.includes(g)) - if (!auth && user?.id) navigate('/') - else if (!auth) loginRedirect() + if (!authorized && user?.id) navigate('/') + else if (!authorized) loginRedirect() return } From c3db79778482a8ebcaa971e6ac439e65753131b0 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:52:40 -0800 Subject: [PATCH 180/295] Remove app root constant --- client/src/features/common/RequireAuth/RequireAuth.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/client/src/features/common/RequireAuth/RequireAuth.tsx b/client/src/features/common/RequireAuth/RequireAuth.tsx index 3971abd60..7215acf8e 100644 --- a/client/src/features/common/RequireAuth/RequireAuth.tsx +++ b/client/src/features/common/RequireAuth/RequireAuth.tsx @@ -1,5 +1,4 @@ import { Outlet, useNavigate } from 'react-router-dom' -import { appRootUrl } from '../../../config' import { useAuthContext } from '../../../contexts/NewAuthProvider' const defaultGroups = ['internal', 'thoth'] From f089ccf6c5416aa845031a3fa3d13945b2f22692 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:54:31 -0800 Subject: [PATCH 181/295] Redirect to voyage instead of internally --- client/src/features/common/RequireAuth/RequireAuth.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/features/common/RequireAuth/RequireAuth.tsx b/client/src/features/common/RequireAuth/RequireAuth.tsx index 7215acf8e..a28d0286e 100644 --- a/client/src/features/common/RequireAuth/RequireAuth.tsx +++ b/client/src/features/common/RequireAuth/RequireAuth.tsx @@ -15,7 +15,8 @@ const RequireAuth = (props: Record) => { !user.groups.includes('public') && user.groups.some(g => groups.includes(g)) - if (!authorized && user?.id) navigate('/') + if (!authorized && user?.id) + window.location.href = 'https://voyage.latitude.io' else if (!authorized) loginRedirect() return From 9b3a2ea084e9f5f3e3569ea86fc8a200f957f382 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 13:54:46 -0800 Subject: [PATCH 182/295] Remove unused code --- client/src/features/common/RequireAuth/RequireAuth.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/src/features/common/RequireAuth/RequireAuth.tsx b/client/src/features/common/RequireAuth/RequireAuth.tsx index a28d0286e..193a9c480 100644 --- a/client/src/features/common/RequireAuth/RequireAuth.tsx +++ b/client/src/features/common/RequireAuth/RequireAuth.tsx @@ -1,11 +1,10 @@ -import { Outlet, useNavigate } from 'react-router-dom' +import { Outlet } from 'react-router-dom' import { useAuthContext } from '../../../contexts/NewAuthProvider' const defaultGroups = ['internal', 'thoth'] const RequireAuth = (props: Record) => { const { user, loginRedirect } = useAuthContext() - const navigate = useNavigate() const groups = props?.access ? [...props?.access, ...defaultGroups] : defaultGroups From a98e8feca49dbef0b0c23fbad325924fa12254c5 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:02:19 -0800 Subject: [PATCH 183/295] Update yarn lock --- yarn.lock | 8 -------- 1 file changed, 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 87cbe1ee3..8d6e0e609 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12447,14 +12447,6 @@ 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 b4ad8ea62c70d614b93662decb7d98660b2e8b7a Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:02:38 -0800 Subject: [PATCH 184/295] Update new auth provider callback uri --- client/src/contexts/NewAuthProvider.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/contexts/NewAuthProvider.tsx b/client/src/contexts/NewAuthProvider.tsx index 4a06360cd..b928c1ee3 100644 --- a/client/src/contexts/NewAuthProvider.tsx +++ b/client/src/contexts/NewAuthProvider.tsx @@ -62,11 +62,11 @@ const AuthProvider = ({ children }: { children: ReactElement }) => { console.log( 'redirecting too:', `${latitudeApiRootUrl}/user/auth/authorize?client_id=${oAuthClientId}&state=${state}&redirect_uri=${encodeURIComponent( - `${appRootUrl}/callback` + `${appRootUrl}/` )}${force ? `&force=true` : ''}` ) window.location.href = `${latitudeApiRootUrl}/user/auth/authorize?client_id=${oAuthClientId}&state=${state}&redirect_uri=${encodeURIComponent( - `${appRootUrl}/callback` + `${appRootUrl}/` )}${force ? `&force=true` : ''}` } @@ -186,7 +186,7 @@ const AuthProvider = ({ children }: { children: ReactElement }) => { body: JSON.stringify({ code: code, grant_type: 'authorization_code', - redirect_uri: `${appRootUrl}/callback`, + redirect_uri: `${appRootUrl}/`, client_id: oAuthClientId, }), headers: { 'Content-Type': 'application/json' }, From 82b3ab1d4a8ba60325e37d8464f62bc929d1e02d Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:05:55 -0800 Subject: [PATCH 185/295] Convert app.js to typescript --- client/src/{App.js => App.tsx} | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) rename client/src/{App.js => App.tsx} (85%) diff --git a/client/src/App.js b/client/src/App.tsx similarity index 85% rename from client/src/App.js rename to client/src/App.tsx index f3ac3cc1e..255688372 100644 --- a/client/src/App.js +++ b/client/src/App.tsx @@ -20,23 +20,10 @@ function App() { // Use our routes const [checked, setChecked] = useState(false) const { tabs, activeTab } = useTabManager() - const { user, getUser, checkIn } = useAuth() + const { user } = useAuth() const navigate = useNavigate() - const authCheck = user && user.accessToken - - useEffect(() => { - ;(async () => { - const currentUser = await getUser() - - if (currentUser) { - // checkin? - checkIn(currentUser) - } - - setChecked(true) - })() - }, []) + const authCheck = user && user.sessionId const redirect = () => { if (user && tabs.length > 0) { From 4f064b13e30b13312c217969f406558c5d18ecd6 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:07:11 -0800 Subject: [PATCH 186/295] Remove unused importRemove last unused dependencies --- client/src/App.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 255688372..28d08d368 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -1,10 +1,9 @@ -import { useEffect, useState } from 'react' -import { Routes, Route, Navigate, useNavigate } from 'react-router-dom' +import { useState } from 'react' +import { Routes, Route, Navigate } from 'react-router-dom' import { useAuth } from './contexts/AuthProvider' import { useTabManager } from './contexts/TabManagerProvider' import RequireAuth from './features/common/RequireAuth/RequireAuth' -import GuardedRoute from './features/common/GuardedRoute/GuardedRoute' import LoadingScreen from './features/common/LoadingScreen/LoadingScreen' import ThothPageWrapper from './features/common/ThothPage/ThothPageWrapper' import LoginScreen from './features/Login/LoginScreen' @@ -18,12 +17,9 @@ import './App.css' function App() { // Use our routes - const [checked, setChecked] = useState(false) + const [checked] = useState(false) const { tabs, activeTab } = useTabManager() const { user } = useAuth() - const navigate = useNavigate() - - const authCheck = user && user.sessionId const redirect = () => { if (user && tabs.length > 0) { From 3e5b5ff86a4c90d3b3f64a540b3749ca5e4ece4e Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:07:32 -0800 Subject: [PATCH 187/295] Show loading screen if there is no user --- client/src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 28d08d368..bdfb3ce05 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -29,7 +29,7 @@ function App() { return user ? : } - if (!checked) return + if (!user) return return ( From c32931ee8e0e4cd3124a8c864c4b284568ebe214 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:07:51 -0800 Subject: [PATCH 188/295] Sropped use of checked state --- client/src/App.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index bdfb3ce05..0264acea7 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -1,4 +1,3 @@ -import { useState } from 'react' import { Routes, Route, Navigate } from 'react-router-dom' import { useAuth } from './contexts/AuthProvider' @@ -17,7 +16,6 @@ import './App.css' function App() { // Use our routes - const [checked] = useState(false) const { tabs, activeTab } = useTabManager() const { user } = useAuth() From 5b6e5c7fc47812ad5ae0d9786ca4b388234020ba Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:08:26 -0800 Subject: [PATCH 189/295] Remove unused props from homescreen --- client/src/features/HomeScreen/HomeScreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/HomeScreen/HomeScreen.js b/client/src/features/HomeScreen/HomeScreen.js index e4debf842..8a5ca2e2b 100644 --- a/client/src/features/HomeScreen/HomeScreen.js +++ b/client/src/features/HomeScreen/HomeScreen.js @@ -16,7 +16,7 @@ import LoadingScreen from '../common/LoadingScreen/LoadingScreen' //MAIN -const StartScreen = ({ createNew, allProjects }) => { +const StartScreen = () => { const models = useDB() const { openTab, closeTabBySpellId } = useTabManager() const navigate = useNavigate() From 772c3af0f4e308d7ffd85e10a3c9868f8517c1d9 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:08:55 -0800 Subject: [PATCH 190/295] Add default to prop in thoth component --- client/src/features/Thoth/Thoth.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/Thoth.tsx b/client/src/features/Thoth/Thoth.tsx index e5107350d..b0386aa52 100644 --- a/client/src/features/Thoth/Thoth.tsx +++ b/client/src/features/Thoth/Thoth.tsx @@ -8,7 +8,7 @@ import LoadingScreen from '../common/LoadingScreen/LoadingScreen' import TabLayout from '../common/TabLayout/TabLayout' import Workspaces from './workspaces' -const Thoth = ({ empty }) => { +const Thoth = ({ empty = false }) => { const navigate = useNavigate() const { activeTab, tabs } = useTabManager() const pubSub = usePubSub() From c844d50e8c6ab38218d761d25f7d1dc9f7ba5eda Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:10:34 -0800 Subject: [PATCH 191/295] Delete guarded route --- .../features/common/GuardedRoute/GuardedRoute.tsx | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 client/src/features/common/GuardedRoute/GuardedRoute.tsx diff --git a/client/src/features/common/GuardedRoute/GuardedRoute.tsx b/client/src/features/common/GuardedRoute/GuardedRoute.tsx deleted file mode 100644 index 68c5e31c9..000000000 --- a/client/src/features/common/GuardedRoute/GuardedRoute.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { Route, Navigate } from 'react-router-dom' - -import { useAuth } from '../../../contexts/AuthProvider' - -const GuardedRoute = props => { - const { user } = useAuth() - - const auth = user && user.accessToken - - return auth ? : -} - -export default GuardedRoute From f3e9e198022f97864f309a2181951c0f9ff3b190 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:11:00 -0800 Subject: [PATCH 192/295] Convert homescreen to typescript --- .../src/features/HomeScreen/{HomeScreen.js => HomeScreen.tsx} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename client/src/features/HomeScreen/{HomeScreen.js => HomeScreen.tsx} (98%) diff --git a/client/src/features/HomeScreen/HomeScreen.js b/client/src/features/HomeScreen/HomeScreen.tsx similarity index 98% rename from client/src/features/HomeScreen/HomeScreen.js rename to client/src/features/HomeScreen/HomeScreen.tsx index 8a5ca2e2b..30db46cdf 100644 --- a/client/src/features/HomeScreen/HomeScreen.js +++ b/client/src/features/HomeScreen/HomeScreen.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import { useState } from 'react' import { Route, Routes, useNavigate } from 'react-router-dom' import { From 0aeeb4c4b650b8ddc9b93191cf7730ceccfae8e0 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:12:02 -0800 Subject: [PATCH 193/295] Drop unused spell usage from homescreen --- client/src/features/HomeScreen/HomeScreen.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/src/features/HomeScreen/HomeScreen.tsx b/client/src/features/HomeScreen/HomeScreen.tsx index 30db46cdf..58d66b744 100644 --- a/client/src/features/HomeScreen/HomeScreen.tsx +++ b/client/src/features/HomeScreen/HomeScreen.tsx @@ -2,7 +2,6 @@ import { useState } from 'react' import { Route, Routes, useNavigate } from 'react-router-dom' import { - useSaveSpellMutation, useGetSpellsQuery, useDeleteSpellMutation, } from '../../state/api/spells' @@ -21,7 +20,6 @@ const StartScreen = () => { const { openTab, closeTabBySpellId } = useTabManager() const navigate = useNavigate() - const [saveSpell] = useSaveSpellMutation() const [deleteSpell] = useDeleteSpellMutation() const { data: spells } = useGetSpellsQuery() @@ -31,7 +29,7 @@ const StartScreen = () => { spellData.chain = spellData.graph delete spellData.graph } - const spell = await saveSpell(spellData) + // TODO check for proper values here and throw errors // Load modules from the spell From 12928dcebbebd38dd38f8d9f0d4b14b8c5f161e4 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:15:05 -0800 Subject: [PATCH 194/295] Fix type error on homescreen --- client/src/features/HomeScreen/HomeScreen.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/features/HomeScreen/HomeScreen.tsx b/client/src/features/HomeScreen/HomeScreen.tsx index 58d66b744..5f838b9ee 100644 --- a/client/src/features/HomeScreen/HomeScreen.tsx +++ b/client/src/features/HomeScreen/HomeScreen.tsx @@ -15,8 +15,14 @@ import LoadingScreen from '../common/LoadingScreen/LoadingScreen' //MAIN +type ModelsType = { + modules: { + updateOrCreate: Function + } +} + const StartScreen = () => { - const models = useDB() + const models = useDB() as unknown as ModelsType const { openTab, closeTabBySpellId } = useTabManager() const navigate = useNavigate() From 529a7a5b187e6aeb0215ad74fcde7a3fb2d9324f Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:16:09 -0800 Subject: [PATCH 195/295] Add open tab to thoth component --- client/src/features/Thoth/Thoth.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/Thoth.tsx b/client/src/features/Thoth/Thoth.tsx index b0386aa52..8a36a84c8 100644 --- a/client/src/features/Thoth/Thoth.tsx +++ b/client/src/features/Thoth/Thoth.tsx @@ -10,7 +10,7 @@ import Workspaces from './workspaces' const Thoth = ({ empty = false }) => { const navigate = useNavigate() - const { activeTab, tabs } = useTabManager() + const { activeTab, tabs, openTab } = useTabManager() const pubSub = usePubSub() const { spellName } = useParams() From aff49f881a3111b5b7be6b5bce4e059347bf9030 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:17:45 -0800 Subject: [PATCH 196/295] Doint navigate home if there is a spellname --- client/src/features/Thoth/Thoth.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/Thoth.tsx b/client/src/features/Thoth/Thoth.tsx index 8a36a84c8..705f93637 100644 --- a/client/src/features/Thoth/Thoth.tsx +++ b/client/src/features/Thoth/Thoth.tsx @@ -19,7 +19,7 @@ const Thoth = ({ empty = false }) => { useEffect(() => { if (!tabs) return - if (!activeTab) navigate('/home') + if (!activeTab && !spellName) navigate('/home') }, [tabs]) useEffect(() => {}, [spellName]) From 4e66d9b9839cb918957d86c01a541dd0f0127e11 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:18:09 -0800 Subject: [PATCH 197/295] Break out of use effect if spellname isnt present --- client/src/features/Thoth/Thoth.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/features/Thoth/Thoth.tsx b/client/src/features/Thoth/Thoth.tsx index 705f93637..c39422555 100644 --- a/client/src/features/Thoth/Thoth.tsx +++ b/client/src/features/Thoth/Thoth.tsx @@ -22,7 +22,9 @@ const Thoth = ({ empty = false }) => { if (!activeTab && !spellName) navigate('/home') }, [tabs]) - useEffect(() => {}, [spellName]) + useEffect(() => { + if (!spellName) return + }, [spellName]) useHotkeys( 'Control+z', From 7bace074d54dea6e2760f7db3a8f4c9fb7ecb2f1 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:22:01 -0800 Subject: [PATCH 198/295] Add logic for new tab to support open new with spell --- client/src/contexts/TabManagerProvider.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/contexts/TabManagerProvider.jsx b/client/src/contexts/TabManagerProvider.jsx index c91c155ca..854900cea 100644 --- a/client/src/contexts/TabManagerProvider.jsx +++ b/client/src/contexts/TabManagerProvider.jsx @@ -80,11 +80,16 @@ const TabManager = ({ children }) => { openNew = true, }) => { // don't open a new tab if one is already open - if (!openNew) { + if (!openNew && type === 'module') { const tabOpened = await switchTab(null, { module: { $eq: moduleName } }) if (tabOpened) return } + if (!openNew && type === 'spell') { + const tabOpened = await switchTab(spellId) + if (tabOpened) return + } + const newTab = { layoutJson: workspaceMap[workspace], name, From db9db56352eeb29e8530c6d5433b41cacfafcf1d Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:25:57 -0800 Subject: [PATCH 199/295] remove old env code --- client/.env | 6 ------ 1 file changed, 6 deletions(-) diff --git a/client/.env b/client/.env index 8c379ed0e..6bc25a4c7 100644 --- a/client/.env +++ b/client/.env @@ -1,12 +1,6 @@ -# REACT_APP_API_URL=https://api.latitude.io -# REACT_APP_API_URL=https://latitude-api-staging.herokuapp.com - REACT_APP_API_URL=http://localhost:8000 EXTEND_ESLINT = true -# Everything below is used for the new auth provider - # This prod site root assumes the netlify build context $URL is available, replace for other hosts - REACT_APP_SITE_ROOT_URL_PROD=$URL REACT_APP_SITE_ROOT_URL=http://localhost:3001 REACT_APP_LAPI_ROOT_URL=http://localhost:8000 From ad5ed16159614b061609a1bd2bf1490e86a61c77 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:26:06 -0800 Subject: [PATCH 200/295] delete auth provider --- client/src/contexts/AuthProvider.tsx | 57 ---------------------------- 1 file changed, 57 deletions(-) delete mode 100644 client/src/contexts/AuthProvider.tsx diff --git a/client/src/contexts/AuthProvider.tsx b/client/src/contexts/AuthProvider.tsx deleted file mode 100644 index e270ccfb7..000000000 --- a/client/src/contexts/AuthProvider.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { useContext, createContext, useState } from 'react' - -import { setAuthHeader } from '../utils/authHelper' -import { login as userLogin } from './../services/game-api/auth' -import { useDB } from './DatabaseProvider' - -const Context = createContext({ - login: (email, password) => {}, - user: {} as any, - checkIn: user => {}, - getUser: () => {}, -}) - -export const useAuth = () => useContext(Context) - -const AuthProvider = ({ children }) => { - const [user, setUser] = useState(null) as any - const { models } = useDB() - - const login = async (email, password) => { - const response = await userLogin(email, password) - - if (response.accessToken) { - const authData = window.btoa(email + ':' + password) - const user = await models.user.getOrCreate(response.id) - - await models.user.setAuthData(user.id, authData) - const updatedUser = await models.user.updateUser(user.id, response) - const finalUser = updatedUser.toJSON() - - setUser(finalUser) - setAuthHeader(finalUser.authData) - } - - return response - } - - const getUser = async () => { - return await models.user.getUser() - } - - const checkIn = user => { - setUser(user) - setAuthHeader(user.authData) - } - - const publicInterface = { - login, - user, - checkIn, - getUser, - } - - return {children} -} - -export default AuthProvider From 7b2a8cb69cbc3bb7ec27a27381d82ef69b78703d Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:26:14 -0800 Subject: [PATCH 201/295] delete guarded route --- .../features/common/GuardedRoute/GuardedRoute.tsx | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 client/src/features/common/GuardedRoute/GuardedRoute.tsx diff --git a/client/src/features/common/GuardedRoute/GuardedRoute.tsx b/client/src/features/common/GuardedRoute/GuardedRoute.tsx deleted file mode 100644 index 68c5e31c9..000000000 --- a/client/src/features/common/GuardedRoute/GuardedRoute.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { Route, Navigate } from 'react-router-dom' - -import { useAuth } from '../../../contexts/AuthProvider' - -const GuardedRoute = props => { - const { user } = useAuth() - - const auth = user && user.accessToken - - return auth ? : -} - -export default GuardedRoute From 880f52a332e2ea5d189957f48a84611a67709d1d Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:26:24 -0800 Subject: [PATCH 202/295] delete login modal --- .../src/features/common/Modals/LoginModal.tsx | 80 ------------------- 1 file changed, 80 deletions(-) delete mode 100644 client/src/features/common/Modals/LoginModal.tsx diff --git a/client/src/features/common/Modals/LoginModal.tsx b/client/src/features/common/Modals/LoginModal.tsx deleted file mode 100644 index a24104626..000000000 --- a/client/src/features/common/Modals/LoginModal.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { useState } from 'react' -import { useForm } from 'react-hook-form' - -import { useAuth } from '../../../contexts/AuthProvider' -import { useModal } from '../../../contexts/ModalProvider' -import Modal from '../Modal/Modal' -import css from './modalForms.module.css' -import { useNavigate } from 'react-router-dom' - -const LoginModal = ({ title, onClose }) => { - const navigate = useNavigate() - const [error, setError] = useState('') - const { login } = useAuth() - const { closeModal } = useModal() - - const { - register, - handleSubmit, - formState: { errors }, - } = useForm() - - const onSubmit = handleSubmit(async data => { - const response: any = await login(data.email, data.password) - - if (response.error) { - setError(response.error.data.error.message) - } - - if (response.id) { - closeModal() - navigate('/home') - } - }) - - const options = [ - { - className: `${css['loginButton']} primary`, - label: 'login', - onClick: onSubmit, - }, - ] - - return ( - -
- {error && {error}} -
- {/* register your input into the hook by invoking the "register" function */} -
- - -
- - {/* include validation with required or other standard HTML validation rules */} -
- - -
- {/* errors will return when field validation fails */} - {errors.password && This field is required} -
-
-
- ) -} - -export default LoginModal From 2cb40620c7e4a395f3cd4aa48da1f6c74e293545 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:26:33 -0800 Subject: [PATCH 203/295] delete login screen --- .../src/features/Login/LoginScreen.module.css | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 client/src/features/Login/LoginScreen.module.css diff --git a/client/src/features/Login/LoginScreen.module.css b/client/src/features/Login/LoginScreen.module.css deleted file mode 100644 index b4e7cbc73..000000000 --- a/client/src/features/Login/LoginScreen.module.css +++ /dev/null @@ -1,25 +0,0 @@ -.overlay { - position: absolute; - top: 0; - left: 0; - width: 100vw; - height: 100vh; - background-color: rgba(20, 20, 20, 0.8); - z-index: 99; - display: flex; - align-items: center; - justify-content: center; -} -.template-panel:hover { - /* background-color: var(--dark-3); */ - border: 1px solid var(--primary); -} -.center-container { - display: flex; - flex-direction: column; - gap: var(--small); -} -.center-container h1 { - margin-top: var(--extraSmall); - margin-bottom: var(--small); -} From 9853af7fc828930eabc47fa41dbc172b1d5f6a98 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:26:43 -0800 Subject: [PATCH 204/295] delete login screen --- client/src/features/Login/LoginScreen.module.css.d.ts | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 client/src/features/Login/LoginScreen.module.css.d.ts diff --git a/client/src/features/Login/LoginScreen.module.css.d.ts b/client/src/features/Login/LoginScreen.module.css.d.ts deleted file mode 100644 index 76aae1b88..000000000 --- a/client/src/features/Login/LoginScreen.module.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'center-container': string; - 'overlay': string; - 'template-panel': string; -} -export const cssExports: CssExports; -export default cssExports; From 9aaba7393c57b7b125b1471c29832fbb0588a89a Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:26:56 -0800 Subject: [PATCH 205/295] delete login screen --- client/src/features/Login/LoginScreen.tsx | 24 ----------------------- 1 file changed, 24 deletions(-) delete mode 100644 client/src/features/Login/LoginScreen.tsx diff --git a/client/src/features/Login/LoginScreen.tsx b/client/src/features/Login/LoginScreen.tsx deleted file mode 100644 index 6594dacb2..000000000 --- a/client/src/features/Login/LoginScreen.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { useEffect } from 'react' - -import { useModal } from '../../contexts/ModalProvider' -import css from './LoginScreen.module.css' - -const LoginScreen = () => { - const { openModal } = useModal() - - const onClose = () => { - alert('closed') - } - - useEffect(() => { - openModal({ - modal: 'loginModal', - title: 'LOG IN', - onClose, - }) - }, []) - - return
-} - -export default LoginScreen From 954a88f191e509019aabb8c5a669f4068837b6ef Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:28:41 -0800 Subject: [PATCH 206/295] delete authHelper --- client/src/utils/authHelper.ts | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 client/src/utils/authHelper.ts diff --git a/client/src/utils/authHelper.ts b/client/src/utils/authHelper.ts deleted file mode 100644 index 270882815..000000000 --- a/client/src/utils/authHelper.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const setAuthHeader = authData => { - const authHeader = { - Authorization: 'Basic ' + authData, - } - window.localStorage.setItem('authHeader', JSON.stringify(authHeader)) -} - -export const getAuthHeader = () => { - const header = window.localStorage.getItem('authHeader') - return JSON.parse(header || '{}') -} From 3f849e236efe7409d28c0fecf97cfb28e1a00d6c Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:29:04 -0800 Subject: [PATCH 207/295] update api to use new config --- client/src/state/api/api.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/state/api/api.ts b/client/src/state/api/api.ts index 43064dbdc..16163cb70 100644 --- a/client/src/state/api/api.ts +++ b/client/src/state/api/api.ts @@ -1,11 +1,12 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react' import { getAuthHeader } from '../../contexts/NewAuthProvider' +import { latitudeApiRootUrl } from '../../config' // initialize an empty api service that we'll inject endpoints into later as needed export const rootApi = createApi({ reducerPath: 'api', baseQuery: fetchBaseQuery({ - baseUrl: `${process.env.REACT_APP_API_URL}/` || 'localhost:8000/', + baseUrl: latitudeApiRootUrl, prepareHeaders: async headers => { const authHeader = await getAuthHeader() if (authHeader?.Authorization) From 6eea553737efe6d071fb3e538a94f890fbcad376 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:29:17 -0800 Subject: [PATCH 208/295] update text to use new api --- client/src/services/game-api/text.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client/src/services/game-api/text.ts b/client/src/services/game-api/text.ts index 922774f64..e01132c7b 100644 --- a/client/src/services/game-api/text.ts +++ b/client/src/services/game-api/text.ts @@ -1,15 +1,14 @@ -import { getAuthHeader } from '../../utils/authHelper' +import { latitudeApiRootUrl } from '@/config' +import { getAuthHeader } from '../../contexts/NewAuthProvider' export const completion = async body => { - const url = process.env.REACT_APP_API_URL - try { - const response = await fetch(url + '/text/completions', { + const response = await fetch(latitudeApiRootUrl + '/text/completions', { method: 'POST', mode: 'cors', headers: { 'Content-Type': 'application/json', - ...getAuthHeader(), + ...(await getAuthHeader()), }, body: JSON.stringify({ ...body, prompt: body.prompt.trimEnd() }), }) From 422e95b84d41749413e61ecf2ecfd940de541886 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:29:41 -0800 Subject: [PATCH 209/295] import useAuthContext into debug consol --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 95e3bb791..bdb219c26 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -1,6 +1,6 @@ import { useCallback, useEffect, useRef, useState } from 'react' import Terminal from 'react-console-emulator' -import { useAuth } from '@/contexts/AuthProvider' +import { useAuthContext } from '@/contexts/NewAuthProvider' import { usePubSub } from '@/contexts/PubSubProvider' import Window from '@/features/common/Window/Window' From 6f003eeebb171f26eb3e827910f879ce3a377f49 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:29:59 -0800 Subject: [PATCH 210/295] update destructure to use the new auth context --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index bdb219c26..e068f65ec 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -1,6 +1,6 @@ import { useCallback, useEffect, useRef, useState } from 'react' import Terminal from 'react-console-emulator' -import { useAuthContext } from '@/contexts/NewAuthProvider' +import { useAuth } from '@/contexts/AuthProvider' import { usePubSub } from '@/contexts/PubSubProvider' import Window from '@/features/common/Window/Window' @@ -14,7 +14,7 @@ interface Terminal { const DebugConsole = ({ tab }) => { const [scrollToBottom, setScrollToBottom] = useState(false) - const { user } = useAuth() + const { user } = useAuthContext() const { // publish, subscribe, From 130e07762349f1ba8618aaf50b6649e6b76015e9 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:31:08 -0800 Subject: [PATCH 211/295] update useAuth import to useAuthContext --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index e068f65ec..96eb0398f 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -1,6 +1,6 @@ import { useCallback, useEffect, useRef, useState } from 'react' import Terminal from 'react-console-emulator' -import { useAuth } from '@/contexts/AuthProvider' +import { useAuthContext } from '@/contexts/NewAuthProvider' import { usePubSub } from '@/contexts/PubSubProvider' import Window from '@/features/common/Window/Window' From ec370d144c2b8778826fc983f0b36f8df29e7ef5 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:31:52 -0800 Subject: [PATCH 212/295] fix user may be undefined with a ? --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 96eb0398f..131629965 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -76,7 +76,7 @@ const DebugConsole = ({ tab }) => { ref={terminalRef} commands={commands} commandCallback={commandCallback} - promptLabel={`${user.id}@Thoth:~$`} + promptLabel={`${user?.id}@Thoth:~$`} // readOnly={true} style={{ overflow: 'hidden', From 029d847fcd7eca336cbed46280ae80db617ee478 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:32:19 -0800 Subject: [PATCH 213/295] strip out commented out imports --- client/src/contexts/NewAuthProvider.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/client/src/contexts/NewAuthProvider.tsx b/client/src/contexts/NewAuthProvider.tsx index b928c1ee3..c0331c83c 100644 --- a/client/src/contexts/NewAuthProvider.tsx +++ b/client/src/contexts/NewAuthProvider.tsx @@ -10,10 +10,7 @@ import { setItem, getItem } from '../utils/AsyncStorage' import { useQuery } from '../hooks/useQuery' import { useLocation } from 'react-router-dom' import { oAuthClientId, latitudeApiRootUrl, appRootUrl } from '../config' -// import { callQuery, callIncrement } from '../utils/queryApi' import { callExpire } from '../helpers/Expire' -// import { useDB } from './DatabaseProvider' - interface SessionInfoType { id: number email: string From 88b49946ca99f8640321efbea0cdb96d03befef7 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:32:46 -0800 Subject: [PATCH 214/295] strip out modal that no longer exists --- client/src/features/common/Modals/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/src/features/common/Modals/index.ts b/client/src/features/common/Modals/index.ts index e8bd6773e..21045f18b 100644 --- a/client/src/features/common/Modals/index.ts +++ b/client/src/features/common/Modals/index.ts @@ -1,6 +1,5 @@ import ExampleModal from './ExampleModal' import InfoModal from './InfoModal' -import LoginModal from './LoginModal' import DeployModal from './DeployModal' import EditSpellModal from './EditSpellModal' import SaveAsModal from './SaveAsModal' @@ -8,7 +7,6 @@ import SaveAsModal from './SaveAsModal' const modals = { example: ExampleModal, infoModal: InfoModal, - loginModal: LoginModal, deployModal: DeployModal, editSpellModal: EditSpellModal, saveAsModal: SaveAsModal, From bb2e07be020ec180b33c40a039188a43088f7053 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:33:13 -0800 Subject: [PATCH 215/295] update imports in enki --- client/src/services/game-api/enki.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/src/services/game-api/enki.js b/client/src/services/game-api/enki.js index fab994c8f..44d7c6b63 100644 --- a/client/src/services/game-api/enki.js +++ b/client/src/services/game-api/enki.js @@ -1,7 +1,6 @@ /* eslint-disable no-console */ -import { getAuthHeader } from '../../utils/authHelper' - -const url = process.env.REACT_APP_API_URL +import { latitudeApiRootUrl } from '@/config' +import { getAuthHeader } from '../../contexts/NewAuthProvider' export const getEnkiPrompt = async taskName => { try { From 84632877bef0535f52c889ba3237abc592f2ab6a Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:33:43 -0800 Subject: [PATCH 216/295] await getAuthHeader in getEnkiPrompt --- client/src/services/game-api/enki.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/services/game-api/enki.js b/client/src/services/game-api/enki.js index 44d7c6b63..e2db2f580 100644 --- a/client/src/services/game-api/enki.js +++ b/client/src/services/game-api/enki.js @@ -1,6 +1,7 @@ /* eslint-disable no-console */ -import { latitudeApiRootUrl } from '@/config' -import { getAuthHeader } from '../../contexts/NewAuthProvider' +import { getAuthHeader } from '../../utils/authHelper' + +const url = process.env.REACT_APP_API_URL export const getEnkiPrompt = async taskName => { try { @@ -10,7 +11,7 @@ export const getEnkiPrompt = async taskName => { mode: 'cors', headers: { 'Content-Type': 'application/json', - ...getAuthHeader(), + ...(await getAuthHeader()), }, }) From 540f10fd527c42dc2fee965724fe9b8141a921c8 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:34:02 -0800 Subject: [PATCH 217/295] Use proper query when switching tabs to an open tab --- client/src/contexts/TabManagerProvider.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/contexts/TabManagerProvider.jsx b/client/src/contexts/TabManagerProvider.jsx index 854900cea..434e981c3 100644 --- a/client/src/contexts/TabManagerProvider.jsx +++ b/client/src/contexts/TabManagerProvider.jsx @@ -86,7 +86,7 @@ const TabManager = ({ children }) => { } if (!openNew && type === 'spell') { - const tabOpened = await switchTab(spellId) + const tabOpened = await switchTab(null, { spell: { $eq: spellId } }) if (tabOpened) return } From 461f32a525dee09264f0f18d99c20cc69d9df127 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:34:15 -0800 Subject: [PATCH 218/295] Open tab in thoth if a spellname is present --- client/src/features/Thoth/Thoth.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/src/features/Thoth/Thoth.tsx b/client/src/features/Thoth/Thoth.tsx index c39422555..dfd7fe6fd 100644 --- a/client/src/features/Thoth/Thoth.tsx +++ b/client/src/features/Thoth/Thoth.tsx @@ -24,6 +24,13 @@ const Thoth = ({ empty = false }) => { useEffect(() => { if (!spellName) return + + openTab({ + spellId: spellName, + name: spellName, + openNew: false, + type: 'spell', + }) }, [spellName]) useHotkeys( From 510cfae169d3aa0414db88c228c49afef3b81df7 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:34:30 -0800 Subject: [PATCH 219/295] await getAuthHeader in getEnkis --- client/src/services/game-api/enki.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/services/game-api/enki.js b/client/src/services/game-api/enki.js index e2db2f580..15c86b1bb 100644 --- a/client/src/services/game-api/enki.js +++ b/client/src/services/game-api/enki.js @@ -31,7 +31,7 @@ export const getEnkis = async () => { mode: 'cors', headers: { 'Content-Type': 'application/json', - ...getAuthHeader(), + ...(await getAuthHeader()), }, }) From 02cb3543cb8b98d381544c67993755eb1cbf94ab Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:34:50 -0800 Subject: [PATCH 220/295] update imports in enki js --- client/src/services/game-api/enki.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/src/services/game-api/enki.js b/client/src/services/game-api/enki.js index 15c86b1bb..910fef422 100644 --- a/client/src/services/game-api/enki.js +++ b/client/src/services/game-api/enki.js @@ -1,7 +1,6 @@ /* eslint-disable no-console */ -import { getAuthHeader } from '../../utils/authHelper' - -const url = process.env.REACT_APP_API_URL +import { latitudeApiRootUrl } from '@/config' +import { getAuthHeader } from '../../contexts/NewAuthProvider' export const getEnkiPrompt = async taskName => { try { From a7a96af83de55456971840578983ad578f7b8786 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:35:30 -0800 Subject: [PATCH 221/295] swap env process for reliance on new config in getEnkiPrompt --- client/src/services/game-api/enki.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/services/game-api/enki.js b/client/src/services/game-api/enki.js index 910fef422..41f4be934 100644 --- a/client/src/services/game-api/enki.js +++ b/client/src/services/game-api/enki.js @@ -1,10 +1,11 @@ /* eslint-disable no-console */ -import { latitudeApiRootUrl } from '@/config' -import { getAuthHeader } from '../../contexts/NewAuthProvider' +import { getAuthHeader } from '../../utils/authHelper' + +const url = process.env.REACT_APP_API_URL export const getEnkiPrompt = async taskName => { try { - const response = await fetch(url + `/enki/${taskName}`, { + const response = await fetch(latitudeApiRootUrl + `/enki/${taskName}`, { method: 'GET', prompt, mode: 'cors', From 2651788fe2fbb7774e4f36eb3371fb04e7ac77d0 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:35:44 -0800 Subject: [PATCH 222/295] swap env process for reliance on new config in getEnkis --- client/src/services/game-api/enki.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/services/game-api/enki.js b/client/src/services/game-api/enki.js index 41f4be934..1680ce8ba 100644 --- a/client/src/services/game-api/enki.js +++ b/client/src/services/game-api/enki.js @@ -5,7 +5,7 @@ const url = process.env.REACT_APP_API_URL export const getEnkiPrompt = async taskName => { try { - const response = await fetch(latitudeApiRootUrl + `/enki/${taskName}`, { + const response = await fetch(url + `/enki/${taskName}`, { method: 'GET', prompt, mode: 'cors', @@ -25,7 +25,7 @@ export const getEnkiPrompt = async taskName => { export const getEnkis = async () => { try { - const response = await fetch(url + `/enki`, { + const response = await fetch(latitudeApiRootUrl + `/enki`, { method: 'GET', prompt, mode: 'cors', From cc31ff971e345ac3fd78b1fb0b78790461b5a652 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:36:24 -0800 Subject: [PATCH 223/295] await getAuthHeaders in postEnkiCompletion --- client/src/services/game-api/enki.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/src/services/game-api/enki.js b/client/src/services/game-api/enki.js index 1680ce8ba..6d64a27e6 100644 --- a/client/src/services/game-api/enki.js +++ b/client/src/services/game-api/enki.js @@ -25,7 +25,7 @@ export const getEnkiPrompt = async taskName => { export const getEnkis = async () => { try { - const response = await fetch(latitudeApiRootUrl + `/enki`, { + const response = await fetch(url + `/enki`, { method: 'GET', prompt, mode: 'cors', @@ -52,8 +52,7 @@ export const postEnkiCompletion = async (taskName, inputs) => { body: JSON.stringify({ inputs }), headers: { 'Content-Type': 'application/json', - ...getAuthHeader(), - }, + ...(await getAuthHeader()), }) const parsed = await response.json() From 3797719450e1b9840d6586b9abae17219c1fdf85 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:36:49 -0800 Subject: [PATCH 224/295] swap env process for reliance on new config in postEnkiCompletion --- client/src/services/game-api/enki.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/client/src/services/game-api/enki.js b/client/src/services/game-api/enki.js index 6d64a27e6..919b170c7 100644 --- a/client/src/services/game-api/enki.js +++ b/client/src/services/game-api/enki.js @@ -45,15 +45,19 @@ export const getEnkis = async () => { export const postEnkiCompletion = async (taskName, inputs) => { try { - const response = await fetch(url + `/enki/${taskName}/completion`, { - method: 'POST', - prompt, - mode: 'cors', - body: JSON.stringify({ inputs }), - headers: { - 'Content-Type': 'application/json', + const response = await fetch( + latitudeApiRootUrl + `/enki/${taskName}/completion`, + { + method: 'POST', + prompt, + mode: 'cors', + body: JSON.stringify({ inputs }), + headers: { + 'Content-Type': 'application/json', ...(await getAuthHeader()), - }) + }, + } + ) const parsed = await response.json() From 00ac4ce16f6cc3c29caa62575e33f2577f73a19a Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:37:43 -0800 Subject: [PATCH 225/295] update imports in enki js --- client/src/services/game-api/enki.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/src/services/game-api/enki.js b/client/src/services/game-api/enki.js index 919b170c7..84d6770f5 100644 --- a/client/src/services/game-api/enki.js +++ b/client/src/services/game-api/enki.js @@ -1,7 +1,6 @@ /* eslint-disable no-console */ -import { getAuthHeader } from '../../utils/authHelper' - -const url = process.env.REACT_APP_API_URL +import { latitudeApiRootUrl } from '@/config' +import { getAuthHeader } from '../../contexts/NewAuthProvider' export const getEnkiPrompt = async taskName => { try { From 675badc351ebdc4ee8d0299f2038b419a0de772d Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:38:14 -0800 Subject: [PATCH 226/295] await getAuthHeader in getEnkiPrompt and GetEnkis --- client/src/services/game-api/enki.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/services/game-api/enki.js b/client/src/services/game-api/enki.js index 84d6770f5..ef4149fa5 100644 --- a/client/src/services/game-api/enki.js +++ b/client/src/services/game-api/enki.js @@ -4,7 +4,7 @@ import { getAuthHeader } from '../../contexts/NewAuthProvider' export const getEnkiPrompt = async taskName => { try { - const response = await fetch(url + `/enki/${taskName}`, { + const response = await fetch(latitudeApiRootUrl + `/enki/${taskName}`, { method: 'GET', prompt, mode: 'cors', @@ -24,7 +24,7 @@ export const getEnkiPrompt = async taskName => { export const getEnkis = async () => { try { - const response = await fetch(url + `/enki`, { + const response = await fetch(latitudeApiRootUrl + `/enki`, { method: 'GET', prompt, mode: 'cors', From 0f25b12b6438aa42e1f1080ac080a34ca02efe02 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:44:48 -0800 Subject: [PATCH 227/295] convert enki js to ts and remove prompt references --- client/src/services/game-api/{enki.js => enki.ts} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename client/src/services/game-api/{enki.js => enki.ts} (97%) diff --git a/client/src/services/game-api/enki.js b/client/src/services/game-api/enki.ts similarity index 97% rename from client/src/services/game-api/enki.js rename to client/src/services/game-api/enki.ts index ef4149fa5..9580c8895 100644 --- a/client/src/services/game-api/enki.js +++ b/client/src/services/game-api/enki.ts @@ -6,7 +6,6 @@ export const getEnkiPrompt = async taskName => { try { const response = await fetch(latitudeApiRootUrl + `/enki/${taskName}`, { method: 'GET', - prompt, mode: 'cors', headers: { 'Content-Type': 'application/json', @@ -26,7 +25,6 @@ export const getEnkis = async () => { try { const response = await fetch(latitudeApiRootUrl + `/enki`, { method: 'GET', - prompt, mode: 'cors', headers: { 'Content-Type': 'application/json', @@ -48,7 +46,7 @@ export const postEnkiCompletion = async (taskName, inputs) => { latitudeApiRootUrl + `/enki/${taskName}/completion`, { method: 'POST', - prompt, + mode: 'cors', body: JSON.stringify({ inputs }), headers: { From a90626f677815a1862fd77d0fb47cf35c1e1e9cb Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:45:45 -0800 Subject: [PATCH 228/295] update build url to use config variable --- .../src/features/Thoth/windows/EditorWindow/Deployment.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/src/features/Thoth/windows/EditorWindow/Deployment.tsx b/client/src/features/Thoth/windows/EditorWindow/Deployment.tsx index ac20996b8..5d4bfe6ce 100644 --- a/client/src/features/Thoth/windows/EditorWindow/Deployment.tsx +++ b/client/src/features/Thoth/windows/EditorWindow/Deployment.tsx @@ -19,6 +19,7 @@ import { useSaveSpellMutation, } from '@/state/api/spells' import { useEditor } from '@thoth/contexts/EditorProvider' +import { latitudeApiRootUrl } from '@/config' const DeploymentView = ({ open, setOpen, spellId, close }) => { const [loadingVersion, setLoadingVersion] = useState(false) @@ -42,9 +43,7 @@ const DeploymentView = ({ open, setOpen, spellId, close }) => { } const buildUrl = version => { - return encodeURI( - `${process.env.REACT_APP_API_URL}/games/spells/${spellId}/${version}` - ) + return encodeURI(`${latitudeApiRootUrl}/games/spells/${spellId}/${version}`) } const loadVersion = async version => { From 1d952178133e725036dedf1d4a36dd587be60a39 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:50:43 -0800 Subject: [PATCH 229/295] change settings.js to ts --- client/src/database/schemas/{settings.js => settings.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename client/src/database/schemas/{settings.js => settings.ts} (100%) diff --git a/client/src/database/schemas/settings.js b/client/src/database/schemas/settings.ts similarity index 100% rename from client/src/database/schemas/settings.js rename to client/src/database/schemas/settings.ts From b696b4703e39f5f242ea41f797998902b1f7012d Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:50:53 -0800 Subject: [PATCH 230/295] change spell.js to ts --- client/src/database/schemas/{spell.js => spell.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename client/src/database/schemas/{spell.js => spell.ts} (100%) diff --git a/client/src/database/schemas/spell.js b/client/src/database/schemas/spell.ts similarity index 100% rename from client/src/database/schemas/spell.js rename to client/src/database/schemas/spell.ts From 54b3aa2f4258c46e6bc722b20d90639276d3a459 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 14:51:03 -0800 Subject: [PATCH 231/295] change tab js to ts --- client/src/database/schemas/{tab.js => tab.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename client/src/database/schemas/{tab.js => tab.ts} (100%) diff --git a/client/src/database/schemas/tab.js b/client/src/database/schemas/tab.ts similarity index 100% rename from client/src/database/schemas/tab.js rename to client/src/database/schemas/tab.ts From 8c6bfa28fba8ebae2e19f104eeb8db3f48e2181a Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 14:59:02 -0800 Subject: [PATCH 232/295] Add default for module name in open tab --- client/src/contexts/TabManagerProvider.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/contexts/TabManagerProvider.jsx b/client/src/contexts/TabManagerProvider.jsx index 434e981c3..c62cf38cf 100644 --- a/client/src/contexts/TabManagerProvider.jsx +++ b/client/src/contexts/TabManagerProvider.jsx @@ -75,7 +75,7 @@ const TabManager = ({ children }) => { workspace = 'default', name = 'Untitled', type = 'module', - moduleName, + moduleName = '', spellId = null, openNew = true, }) => { From dd057c534b7142745012e8e4c4d7c8cb09e9e769 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 15:25:05 -0800 Subject: [PATCH 233/295] deleted auth --- client/src/services/game-api/auth.js | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 client/src/services/game-api/auth.js diff --git a/client/src/services/game-api/auth.js b/client/src/services/game-api/auth.js deleted file mode 100644 index d0e901daa..000000000 --- a/client/src/services/game-api/auth.js +++ /dev/null @@ -1,19 +0,0 @@ -const url = process.env.REACT_APP_API_URL - -export const login = async (email, password) => { - const response = await fetch(url + `/auth/login.json`, { - method: 'POST', - mode: 'cors', - body: JSON.stringify({ - usernameOrEmail: email, - password: password, - }), - headers: { - 'Content-Type': 'application/json', - }, - }) - - const parsed = await response.json() - - return parsed -} From 9a7ff8ac7c7d185440101d47d76b2b29f53882fa Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 15:25:26 -0800 Subject: [PATCH 234/295] convert modals.js to ts --- client/src/services/{Modals.js => Modals.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename client/src/services/{Modals.js => Modals.ts} (100%) diff --git a/client/src/services/Modals.js b/client/src/services/Modals.ts similarity index 100% rename from client/src/services/Modals.js rename to client/src/services/Modals.ts From d314b30b5dc6247b2adf722e4411b22c691595ac Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 15:25:44 -0800 Subject: [PATCH 235/295] convert textInput js to ts --- .../z. Don't use/TextInput/{TextInput.js => TextInput.tsx} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename client/src/features/common/z. Don't use/TextInput/{TextInput.js => TextInput.tsx} (89%) diff --git a/client/src/features/common/z. Don't use/TextInput/TextInput.js b/client/src/features/common/z. Don't use/TextInput/TextInput.tsx similarity index 89% rename from client/src/features/common/z. Don't use/TextInput/TextInput.js rename to client/src/features/common/z. Don't use/TextInput/TextInput.tsx index 605495635..5e2a8e240 100644 --- a/client/src/features/common/z. Don't use/TextInput/TextInput.js +++ b/client/src/features/common/z. Don't use/TextInput/TextInput.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react' +import { useState, useEffect } from 'react' import css from './textinput.module.css' From 9f31adb9df6776d5daf898e66cc195a14f2701a6 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 15:26:01 -0800 Subject: [PATCH 236/295] convert windowToolbar from js to tsx --- .../common/Window/{WindowToolbar.js => WindowToolbar.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename client/src/features/common/Window/{WindowToolbar.js => WindowToolbar.tsx} (100%) diff --git a/client/src/features/common/Window/WindowToolbar.js b/client/src/features/common/Window/WindowToolbar.tsx similarity index 100% rename from client/src/features/common/Window/WindowToolbar.js rename to client/src/features/common/Window/WindowToolbar.tsx From 61395da5873616308b6039401b5560377668f37f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 15:26:19 -0800 Subject: [PATCH 237/295] convert toolbar from js to tsx --- client/src/features/common/Toolbar/{Toolbar.js => Toolbar.tsx} | 2 -- 1 file changed, 2 deletions(-) rename client/src/features/common/Toolbar/{Toolbar.js => Toolbar.tsx} (91%) diff --git a/client/src/features/common/Toolbar/Toolbar.js b/client/src/features/common/Toolbar/Toolbar.tsx similarity index 91% rename from client/src/features/common/Toolbar/Toolbar.js rename to client/src/features/common/Toolbar/Toolbar.tsx index 8b754e735..7b524c7ca 100644 --- a/client/src/features/common/Toolbar/Toolbar.js +++ b/client/src/features/common/Toolbar/Toolbar.tsx @@ -1,5 +1,3 @@ -import React from 'react' - import css from './toolbar.module.css' const Toolbar = ({ ...props }) => { From 924d97df9faa9b5fc92daf8b6f13e8d5ce61821e Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 15:26:40 -0800 Subject: [PATCH 238/295] convert thothPageWrapper from js to tsx --- .../ThothPage/{ThothPageWrapper.js => ThothPageWrapper.tsx} | 3 --- 1 file changed, 3 deletions(-) rename client/src/features/common/ThothPage/{ThothPageWrapper.js => ThothPageWrapper.tsx} (82%) diff --git a/client/src/features/common/ThothPage/ThothPageWrapper.js b/client/src/features/common/ThothPage/ThothPageWrapper.tsx similarity index 82% rename from client/src/features/common/ThothPage/ThothPageWrapper.js rename to client/src/features/common/ThothPage/ThothPageWrapper.tsx index c48bac3cc..7e2a41795 100644 --- a/client/src/features/common/ThothPage/ThothPageWrapper.js +++ b/client/src/features/common/ThothPage/ThothPageWrapper.tsx @@ -1,6 +1,3 @@ -import React from 'react' -// import ThothSidePanel from "../ThothSidePanel/ThothSidePanel"; - import ModalProvider from '../../../contexts/ModalProvider' import TabBar from '../TabBar/TabBar' import css from './pagewrapper.module.css' From 8b863da8c89aa95a53afc3f355ff4ddf6937f0af Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 15:27:36 -0800 Subject: [PATCH 239/295] convert tabbar from js to tsx --- client/src/features/common/TabBar/{TabBar.js => TabBar.tsx} | 4 ---- 1 file changed, 4 deletions(-) rename client/src/features/common/TabBar/{TabBar.js => TabBar.tsx} (91%) diff --git a/client/src/features/common/TabBar/TabBar.js b/client/src/features/common/TabBar/TabBar.tsx similarity index 91% rename from client/src/features/common/TabBar/TabBar.js rename to client/src/features/common/TabBar/TabBar.tsx index 4f9b1a5db..920a6b8e1 100644 --- a/client/src/features/common/TabBar/TabBar.js +++ b/client/src/features/common/TabBar/TabBar.tsx @@ -1,12 +1,10 @@ import classnames from 'classnames' -import React from 'react' import { VscClose } from 'react-icons/vsc' import { useTabManager } from '../../../contexts/TabManagerProvider' import Icon from '../Icon/Icon' import MenuBar from '../MenuBar/MenuBar' import css from './tabBar.module.css' -// import { useAuth } from "../../../contexts/AuthProvider"; const Tab = ({ tab, activeTab }) => { const { switchTab, closeTab } = useTabManager() @@ -40,8 +38,6 @@ const Tab = ({ tab, activeTab }) => { } const TabBar = ({ tabs, activeTab }) => { - // const { user } = useAuth(); - return (
From 1cf755f8230d23e2bf3effde1f04626d4e1ed81f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 15:27:49 -0800 Subject: [PATCH 240/295] convert panel js to tsx --- .../features/common/Panel/{Panel.js => Panel.tsx} | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) rename client/src/features/common/Panel/{Panel.js => Panel.tsx} (67%) diff --git a/client/src/features/common/Panel/Panel.js b/client/src/features/common/Panel/Panel.tsx similarity index 67% rename from client/src/features/common/Panel/Panel.js rename to client/src/features/common/Panel/Panel.tsx index 3e535d8bd..c3b204a35 100644 --- a/client/src/features/common/Panel/Panel.js +++ b/client/src/features/common/Panel/Panel.tsx @@ -1,5 +1,3 @@ -import React from 'react' - import css from './panel.module.css' const Panel = ({ @@ -19,17 +17,17 @@ const Panel = ({ return (
From 423436d50c5c481cdaf56b8deef240f59e60b89e Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 15:28:11 -0800 Subject: [PATCH 241/295] convert icon from js to tsx --- client/src/features/common/Icon/{Icon.js => Icon.tsx} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename client/src/features/common/Icon/{Icon.js => Icon.tsx} (84%) diff --git a/client/src/features/common/Icon/Icon.js b/client/src/features/common/Icon/Icon.tsx similarity index 84% rename from client/src/features/common/Icon/Icon.js rename to client/src/features/common/Icon/Icon.tsx index 7e7f3f97f..6ba9d31d6 100644 --- a/client/src/features/common/Icon/Icon.js +++ b/client/src/features/common/Icon/Icon.tsx @@ -1,5 +1,3 @@ -import React from 'react' - import css from './icon.module.css' export const componentCategories = { @@ -20,7 +18,7 @@ export const dataControlCategories = { 'Max Tokens': 'moon', } -const Icon = ({ name = 'warn', size = 16, style, onClick = () => {} }) => { +const Icon = ({ name = 'warn', size = 16, style = {}, onClick = () => {} }) => { return (
Date: Thu, 3 Mar 2022 15:28:26 -0800 Subject: [PATCH 242/295] convert accordion from js to tsx --- client/src/features/common/{Accordion.js => Accordion.tsx} | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) rename client/src/features/common/{Accordion.js => Accordion.tsx} (95%) diff --git a/client/src/features/common/Accordion.js b/client/src/features/common/Accordion.tsx similarity index 95% rename from client/src/features/common/Accordion.js rename to client/src/features/common/Accordion.tsx index daa2be22a..783e94c7d 100644 --- a/client/src/features/common/Accordion.js +++ b/client/src/features/common/Accordion.tsx @@ -4,7 +4,6 @@ import AccordionSummary from '@material-ui/core/AccordionSummary' import { makeStyles } from '@material-ui/core/styles' import Typography from '@material-ui/core/Typography' import ExpandMoreIcon from '@material-ui/icons/ExpandMore' -import React from 'react' import css from './accordion.module.css' import Icon from './Icon/Icon' @@ -38,7 +37,7 @@ const useStyles = makeStyles(theme => ({ }, })) -export const SimpleAccordion = ({ setExpanded = () => {}, ...props }) => { +export const SimpleAccordion = ({ setExpanded = x => {}, ...props }) => { const classes = useStyles() const onChange = (_, expanded) => { From 7c791c5dd2b00f2921e02752efab72489cb00a9c Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 15:29:11 -0800 Subject: [PATCH 243/295] update closeTab and switchTab context declaration to include an argument --- client/src/contexts/TabManagerProvider.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/contexts/TabManagerProvider.jsx b/client/src/contexts/TabManagerProvider.jsx index c91c155ca..573beb1c1 100644 --- a/client/src/contexts/TabManagerProvider.jsx +++ b/client/src/contexts/TabManagerProvider.jsx @@ -12,8 +12,8 @@ const Context = createContext({ activeTab: {}, // eslint-disable-next-line @typescript-eslint/no-unused-vars openTab: async options => {}, - switchTab: () => {}, - closeTab: () => {}, + switchTab: x => {}, + closeTab: x => {}, saveTabLayout: () => {}, clearTabs: () => {}, closeTabBySpellId: spellId => {}, From 9f8d7f8cbd86e79bdf73d1e0846166b8308b2858 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 17:26:12 -0800 Subject: [PATCH 244/295] convert app provider form js to ts --- client/src/contexts/AppProviders.tsx | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 client/src/contexts/AppProviders.tsx diff --git a/client/src/contexts/AppProviders.tsx b/client/src/contexts/AppProviders.tsx new file mode 100644 index 000000000..696d7c800 --- /dev/null +++ b/client/src/contexts/AppProviders.tsx @@ -0,0 +1,58 @@ +import { createTheme, ThemeProvider } from '@material-ui/core/styles' +import NewAuthProvider from './NewAuthProvider' +import DatabaseProvider from './DatabaseProvider' +import ModuleProvider from './ModuleProvider' +import PubSubProvider from './PubSubProvider' +import TabManagerProvider from './TabManagerProvider' +import ToastProvider from './ToastProvider' + +const darkTheme = createTheme({ + palette: { + type: 'dark', + }, +}) + +const providers = [ + PubSubProvider, + [ThemeProvider, { theme: darkTheme }], + ToastProvider, + DatabaseProvider, + NewAuthProvider, + // AuthProvider, + ModuleProvider, + TabManagerProvider, +] + +/** + * Provided that a list of providers [P1, P2, P3, P4] is passed as props, + * it renders + * + * + + + + {children} + + + + + * + */ + +function ComposeProviders({ providers, children }) { + const _providers = [...providers].reverse() + return _providers.reduce((acc, current) => { + const [Provider, props] = Array.isArray(current) + ? [current[0], current[1]] + : [current, {}] + + return {acc} + }, children) +} + +// Centralize all our providers to avoid nesting hell. +const AppProviders = ({ children }) => ( + {children} +) + +export default AppProviders From 9ac5597c80ff1351d14667bf5d7429a91ca67b07 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 17:28:54 -0800 Subject: [PATCH 245/295] convert database proivder to ts --- .../{DatabaseProvider.jsx => DatabaseProvider.tsx} | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) rename client/src/contexts/{DatabaseProvider.jsx => DatabaseProvider.tsx} (76%) diff --git a/client/src/contexts/DatabaseProvider.jsx b/client/src/contexts/DatabaseProvider.tsx similarity index 76% rename from client/src/contexts/DatabaseProvider.jsx rename to client/src/contexts/DatabaseProvider.tsx index 13984f380..2eb341ae5 100644 --- a/client/src/contexts/DatabaseProvider.jsx +++ b/client/src/contexts/DatabaseProvider.tsx @@ -1,11 +1,18 @@ import { useContext, createContext, useState, useEffect } from 'react' - import { initDB } from '../database' import LoadingScreen from '../features/common/LoadingScreen/LoadingScreen' +import { ModuleModal } from '@/database/models/moduleModel' + +interface ContextType { + db: {} + models: {} + modules?: ModuleModal[] | ModuleModal +} -const Context = createContext({ +const Context = createContext({ db: {}, models: {}, + modules: [] as ModuleModal[], }) export const useDB = () => useContext(Context) @@ -28,6 +35,7 @@ const DatabaseProvider = ({ children }) => { const publicInterface = { db, models, + // modules } if (!db || !models) return From 3dc4453dd984608a9abc8e52c1051dadcdbe1e50 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 17:29:06 -0800 Subject: [PATCH 246/295] convert home screen to ts --- .../HomeScreen/{HomeScreen.js => HomeScreen.tsx} | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) rename client/src/features/HomeScreen/{HomeScreen.js => HomeScreen.tsx} (91%) diff --git a/client/src/features/HomeScreen/HomeScreen.js b/client/src/features/HomeScreen/HomeScreen.tsx similarity index 91% rename from client/src/features/HomeScreen/HomeScreen.js rename to client/src/features/HomeScreen/HomeScreen.tsx index e4debf842..5e85ddf3f 100644 --- a/client/src/features/HomeScreen/HomeScreen.js +++ b/client/src/features/HomeScreen/HomeScreen.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import { useState } from 'react' import { Route, Routes, useNavigate } from 'react-router-dom' import { @@ -13,10 +13,11 @@ import CreateNew from './screens/CreateNew' import OpenProject from './screens/OpenProject' import css from './homeScreen.module.css' import LoadingScreen from '../common/LoadingScreen/LoadingScreen' +import { ModuleModal } from '@/database/models/moduleModel' //MAIN -const StartScreen = ({ createNew, allProjects }) => { +const StartScreen = () => { const models = useDB() const { openTab, closeTabBySpellId } = useTabManager() const navigate = useNavigate() @@ -31,14 +32,14 @@ const StartScreen = ({ createNew, allProjects }) => { spellData.chain = spellData.graph delete spellData.graph } - const spell = await saveSpell(spellData) + await saveSpell(spellData) // TODO check for proper values here and throw errors // Load modules from the spell if (spellData?.modules && spellData.modules.length > 0) await Promise.all( - spellData.modules.map(module => { - return models.modules.updateOrCreate(module) + spellData.modules.map((module: ModuleModal) => { + return (models.modules as ModuleModal).updateOrCreate(module) }) ) From d3a0798d8f7dd933cc3346174b0eba5239c1c1f9 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 17:32:03 -0800 Subject: [PATCH 247/295] converted appProvder to ts --- client/package.json | 2 +- client/src/contexts/AppProviders.jsx | 60 ---------------------------- yarn.lock | 19 --------- 3 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 client/src/contexts/AppProviders.jsx diff --git a/client/package.json b/client/package.json index 359a0e106..3ed6a38b7 100644 --- a/client/package.json +++ b/client/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@callstack/async-storage": "^2.0.3", - "@latitudegames/thoth-core": "^0.0.59", + "@latitudegames/thoth-core": "^0.0.61", "@material-ui/core": "^4.12.1", "@material-ui/icons": "^4.11.2", "@monaco-editor/react": "^4.2.1", diff --git a/client/src/contexts/AppProviders.jsx b/client/src/contexts/AppProviders.jsx deleted file mode 100644 index d0dfd0cec..000000000 --- a/client/src/contexts/AppProviders.jsx +++ /dev/null @@ -1,60 +0,0 @@ -import { createTheme, ThemeProvider } from '@material-ui/core/styles' - -import AuthProvider from './AuthProvider' -import NewAuthProvider from './NewAuthProvider' -import DatabaseProvider from './DatabaseProvider' -import ModuleProvider from './ModuleProvider' -import PubSubProvider from './PubSubProvider' -import TabManagerProvider from './TabManagerProvider' -import ToastProvider from './ToastProvider' - -const darkTheme = createTheme({ - palette: { - type: 'dark', - }, -}) - -const providers = [ - PubSubProvider, - [ThemeProvider, { theme: darkTheme }], - ToastProvider, - DatabaseProvider, - NewAuthProvider, - // AuthProvider, - ModuleProvider, - TabManagerProvider, -] - -/** - * Provided that a list of providers [P1, P2, P3, P4] is passed as props, - * it renders - * - * - - - - {children} - - - - - * - */ - -function ComposeProviders({ providers, children }) { - const _providers = [...providers].reverse() - return _providers.reduce((acc, current) => { - const [Provider, props] = Array.isArray(current) - ? [current[0], current[1]] - : [current, {}] - - return {acc} - }, children) -} - -// Centralize all our providers to avoid nesting hell. -const AppProviders = ({ children }) => ( - {children} -) - -export default AppProviders diff --git a/yarn.lock b/yarn.lock index 8d6e0e609..f64aaa931 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1483,25 +1483,6 @@ "@types/yargs" "^16.0.0" chalk "^4.0.0" -"@latitudegames/thoth-core@^0.0.59": - version "0.0.59" - resolved "https://npm.pkg.github.com/download/@latitudegames/thoth-core/0.0.59/4735bade8814e4d561b226d1a2eb92e23307bb24fe3e6242bc53774d4da44c4b#d225d3cc8bd5ec0a24b4b534731b0d8a9c7890ff" - integrity sha512-1SbwmWpTyO+f1wE/auXecAgUudEcCKb7giDWrSgCT3tflOKDYE1bb6RJvIVEUYRmCGvoeM8CQXt8aTPLoWvtJw== - dependencies: - deep-equal "^2.0.5" - handlebars "^4.7.7" - jsdom "^17.0.0" - 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" From 65fadd57130c3658e7e9498d1b67d72230658e4f Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 17:32:39 -0800 Subject: [PATCH 248/295] comment out ModuleModal --- client/src/database/models/moduleModel.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/src/database/models/moduleModel.ts b/client/src/database/models/moduleModel.ts index a85f38814..cb29430c9 100644 --- a/client/src/database/models/moduleModel.ts +++ b/client/src/database/models/moduleModel.ts @@ -1,4 +1,13 @@ import { v4 as uuidv4 } from 'uuid' +//Still need to type the returns +// export interface ModuleModal { +// getModule: (moduleName, callback) => {} +// findOneModule: (_query, callback) => {} +// updateModule: (moduleName: string, update: object) => {} +// updateOrCreate: (doc) => {} +// getNestedModules: (moduleNames: string[]) => {} +// getSpellModules: (spell) => {} +// } const loadModuleModel = db => { const getModules = async callback => { From 43d8577483623a02b5d5d60d1c717a215f5131ab Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 20:17:15 -0800 Subject: [PATCH 249/295] Rename new auth provider to auth provider --- client/src/contexts/{NewAuthProvider.tsx => AuthProvider.tsx} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename client/src/contexts/{NewAuthProvider.tsx => AuthProvider.tsx} (99%) diff --git a/client/src/contexts/NewAuthProvider.tsx b/client/src/contexts/AuthProvider.tsx similarity index 99% rename from client/src/contexts/NewAuthProvider.tsx rename to client/src/contexts/AuthProvider.tsx index c0331c83c..e732c0ec5 100644 --- a/client/src/contexts/NewAuthProvider.tsx +++ b/client/src/contexts/AuthProvider.tsx @@ -36,7 +36,7 @@ const initialState = { const AuthContext = createContext(initialState) -export const useAuthContext = () => useContext(AuthContext) +export const useAuth = () => useContext(AuthContext) const AuthProvider = ({ children }: { children: ReactElement }) => { const [done, setDone] = useState(false) From 1aaac144cb233f85715be072ada41728957d987d Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 20:19:46 -0800 Subject: [PATCH 250/295] Use authprovider and not new auth provider --- client/src/contexts/AppProviders.jsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/src/contexts/AppProviders.jsx b/client/src/contexts/AppProviders.jsx index d0dfd0cec..5df77ca46 100644 --- a/client/src/contexts/AppProviders.jsx +++ b/client/src/contexts/AppProviders.jsx @@ -1,7 +1,6 @@ import { createTheme, ThemeProvider } from '@material-ui/core/styles' import AuthProvider from './AuthProvider' -import NewAuthProvider from './NewAuthProvider' import DatabaseProvider from './DatabaseProvider' import ModuleProvider from './ModuleProvider' import PubSubProvider from './PubSubProvider' @@ -19,8 +18,7 @@ const providers = [ [ThemeProvider, { theme: darkTheme }], ToastProvider, DatabaseProvider, - NewAuthProvider, - // AuthProvider, + AuthProvider, ModuleProvider, TabManagerProvider, ] From 1a7580c8f2f03f10a55bf7c4b81df4baf7be080c Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 20:19:58 -0800 Subject: [PATCH 251/295] Remove login screen from app.tsx file --- client/src/App.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 0264acea7..c823bae61 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -5,7 +5,6 @@ import { useTabManager } from './contexts/TabManagerProvider' import RequireAuth from './features/common/RequireAuth/RequireAuth' import LoadingScreen from './features/common/LoadingScreen/LoadingScreen' import ThothPageWrapper from './features/common/ThothPage/ThothPageWrapper' -import LoginScreen from './features/Login/LoginScreen' import HomeScreen from './features/HomeScreen/HomeScreen' import Thoth from './features/Thoth/Thoth' @@ -33,7 +32,6 @@ function App() { }> - } /> } /> } /> } /> From c589722c9f7a7ee5c47b247ebb1bb1304837247a Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 20:20:15 -0800 Subject: [PATCH 252/295] Fix useAuth in require auth --- client/src/features/common/RequireAuth/RequireAuth.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/features/common/RequireAuth/RequireAuth.tsx b/client/src/features/common/RequireAuth/RequireAuth.tsx index 193a9c480..a5e5104e1 100644 --- a/client/src/features/common/RequireAuth/RequireAuth.tsx +++ b/client/src/features/common/RequireAuth/RequireAuth.tsx @@ -1,10 +1,10 @@ import { Outlet } from 'react-router-dom' -import { useAuthContext } from '../../../contexts/NewAuthProvider' +import { useAuth } from '../../../contexts/AuthProvider' const defaultGroups = ['internal', 'thoth'] const RequireAuth = (props: Record) => { - const { user, loginRedirect } = useAuthContext() + const { user, loginRedirect } = useAuth() const groups = props?.access ? [...props?.access, ...defaultGroups] : defaultGroups From b9d953284855e25cae28b0b98d5940da41bcb14b Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 20:20:27 -0800 Subject: [PATCH 253/295] Fixc use auth context in window --- client/src/features/Thoth/windows/DebugConsole/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/features/Thoth/windows/DebugConsole/index.tsx b/client/src/features/Thoth/windows/DebugConsole/index.tsx index 131629965..dc0902804 100644 --- a/client/src/features/Thoth/windows/DebugConsole/index.tsx +++ b/client/src/features/Thoth/windows/DebugConsole/index.tsx @@ -1,6 +1,6 @@ import { useCallback, useEffect, useRef, useState } from 'react' import Terminal from 'react-console-emulator' -import { useAuthContext } from '@/contexts/NewAuthProvider' +import { useAuth } from '@/contexts/AuthProvider' import { usePubSub } from '@/contexts/PubSubProvider' import Window from '@/features/common/Window/Window' @@ -14,7 +14,7 @@ interface Terminal { const DebugConsole = ({ tab }) => { const [scrollToBottom, setScrollToBottom] = useState(false) - const { user } = useAuthContext() + const { user } = useAuth() const { // publish, subscribe, From ba289773fbce695395581d80083bf7d4df6180aa Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 20:20:42 -0800 Subject: [PATCH 254/295] Fix use auth context import in expire helper --- client/src/helpers/Expire.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/helpers/Expire.ts b/client/src/helpers/Expire.ts index 561740834..9fbdfdbe9 100644 --- a/client/src/helpers/Expire.ts +++ b/client/src/helpers/Expire.ts @@ -1,4 +1,4 @@ -import { getSessionId } from '../contexts/NewAuthProvider' +import { getSessionId } from '../contexts/AuthProvider' import { latitudeApiRootUrl } from '../config' export const callExpire = async () => { From 3a8c2632c81789f1a0c10c59532d2352f146ba3e Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 20:20:56 -0800 Subject: [PATCH 255/295] Fix use auth context in game api service --- client/src/services/game-api/enki.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/services/game-api/enki.ts b/client/src/services/game-api/enki.ts index 9580c8895..e8161bf10 100644 --- a/client/src/services/game-api/enki.ts +++ b/client/src/services/game-api/enki.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import { latitudeApiRootUrl } from '@/config' -import { getAuthHeader } from '../../contexts/NewAuthProvider' +import { getAuthHeader } from '../../contexts/AuthProvider' export const getEnkiPrompt = async taskName => { try { From e78366edcdcd5bdd18bda18fdb5b5c3a524f918b Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 20:21:10 -0800 Subject: [PATCH 256/295] Ficx use auth context in text service --- client/src/services/game-api/text.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/services/game-api/text.ts b/client/src/services/game-api/text.ts index e01132c7b..8e1ee3ab0 100644 --- a/client/src/services/game-api/text.ts +++ b/client/src/services/game-api/text.ts @@ -1,5 +1,5 @@ import { latitudeApiRootUrl } from '@/config' -import { getAuthHeader } from '../../contexts/NewAuthProvider' +import { getAuthHeader } from '../../contexts/AuthProvider' export const completion = async body => { try { From df5d2ed96d512e9e1e3664baa34f30e31cd1cf8b Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Thu, 3 Mar 2022 20:21:22 -0800 Subject: [PATCH 257/295] Fix use auth in root api --- client/src/state/api/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/state/api/api.ts b/client/src/state/api/api.ts index 16163cb70..398119698 100644 --- a/client/src/state/api/api.ts +++ b/client/src/state/api/api.ts @@ -1,5 +1,5 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react' -import { getAuthHeader } from '../../contexts/NewAuthProvider' +import { getAuthHeader } from '../../contexts/AuthProvider' import { latitudeApiRootUrl } from '../../config' // initialize an empty api service that we'll inject endpoints into later as needed From fc37119eda1af66b923937d085346447cc7afca1 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Thu, 3 Mar 2022 21:52:04 -0800 Subject: [PATCH 258/295] remove deleted routes from app.tsx --- client/src/App.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 0264acea7..036ab18ef 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -1,13 +1,12 @@ import { Routes, Route, Navigate } from 'react-router-dom' -import { useAuth } from './contexts/AuthProvider' import { useTabManager } from './contexts/TabManagerProvider' import RequireAuth from './features/common/RequireAuth/RequireAuth' import LoadingScreen from './features/common/LoadingScreen/LoadingScreen' import ThothPageWrapper from './features/common/ThothPage/ThothPageWrapper' -import LoginScreen from './features/Login/LoginScreen' import HomeScreen from './features/HomeScreen/HomeScreen' import Thoth from './features/Thoth/Thoth' +import { useAuthContext } from './contexts/NewAuthProvider' import 'flexlayout-react/style/dark.css' import './design-globals/design-globals.css' @@ -17,7 +16,7 @@ import './App.css' function App() { // Use our routes const { tabs, activeTab } = useTabManager() - const { user } = useAuth() + const { user } = useAuthContext() const redirect = () => { if (user && tabs.length > 0) { @@ -33,7 +32,6 @@ function App() { }> - } /> } /> } /> } /> From 0a941d529b5a5f31590175ccb75335747a6a6409 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 10:46:37 -0800 Subject: [PATCH 259/295] Switch tabs by navigation --- client/src/features/common/TabBar/TabBar.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/features/common/TabBar/TabBar.js b/client/src/features/common/TabBar/TabBar.js index 4f9b1a5db..285b018e7 100644 --- a/client/src/features/common/TabBar/TabBar.js +++ b/client/src/features/common/TabBar/TabBar.js @@ -1,6 +1,7 @@ import classnames from 'classnames' import React from 'react' import { VscClose } from 'react-icons/vsc' +import { useNavigate } from 'react-router-dom' import { useTabManager } from '../../../contexts/TabManagerProvider' import Icon from '../Icon/Icon' @@ -9,6 +10,7 @@ import css from './tabBar.module.css' // import { useAuth } from "../../../contexts/AuthProvider"; const Tab = ({ tab, activeTab }) => { + const navigate = useNavigate() const { switchTab, closeTab } = useTabManager() const active = tab.id === activeTab.id @@ -20,7 +22,7 @@ const Tab = ({ tab, activeTab }) => { }) const onClick = () => { - switchTab(tab.id) + navigate(`/thoth/${tab.spell}`) } // Handle selecting the next tab down is none are active. From afe6f94802d7f820b6e124d85731301f2fdbed44 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 10:47:21 -0800 Subject: [PATCH 260/295] Rename tabbar to tsx --- client/src/features/common/TabBar/{TabBar.js => TabBar.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename client/src/features/common/TabBar/{TabBar.js => TabBar.tsx} (100%) diff --git a/client/src/features/common/TabBar/TabBar.js b/client/src/features/common/TabBar/TabBar.tsx similarity index 100% rename from client/src/features/common/TabBar/TabBar.js rename to client/src/features/common/TabBar/TabBar.tsx From 3a0af57f08337057ad408bc0bc010541d0d924a0 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 4 Mar 2022 11:53:54 -0800 Subject: [PATCH 261/295] add types.ts file --- client/src/types.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 client/src/types.ts diff --git a/client/src/types.ts b/client/src/types.ts new file mode 100644 index 000000000..802758882 --- /dev/null +++ b/client/src/types.ts @@ -0,0 +1,16 @@ +export type ModelsType = { + models: { + modules: { + updateOrCreate: Function + getModule: Function + getModules: Function + updateModule: Function + newModule: Function + findOneModule: Function + } + + spells: { + getSpell: Function + } + } +} From 421aaed8904a1492c659b98d6222ec4f38f67881 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 4 Mar 2022 11:54:12 -0800 Subject: [PATCH 262/295] change database provider back to js --- .../{DatabaseProvider.tsx => DatabaseProvider.jsx} | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) rename client/src/contexts/{DatabaseProvider.tsx => DatabaseProvider.jsx} (73%) diff --git a/client/src/contexts/DatabaseProvider.tsx b/client/src/contexts/DatabaseProvider.jsx similarity index 73% rename from client/src/contexts/DatabaseProvider.tsx rename to client/src/contexts/DatabaseProvider.jsx index 2eb341ae5..8f89bcd2e 100644 --- a/client/src/contexts/DatabaseProvider.tsx +++ b/client/src/contexts/DatabaseProvider.jsx @@ -1,19 +1,8 @@ import { useContext, createContext, useState, useEffect } from 'react' import { initDB } from '../database' import LoadingScreen from '../features/common/LoadingScreen/LoadingScreen' -import { ModuleModal } from '@/database/models/moduleModel' -interface ContextType { - db: {} - models: {} - modules?: ModuleModal[] | ModuleModal -} - -const Context = createContext({ - db: {}, - models: {}, - modules: [] as ModuleModal[], -}) +const Context = createContext(!undefined) export const useDB = () => useContext(Context) @@ -35,7 +24,6 @@ const DatabaseProvider = ({ children }) => { const publicInterface = { db, models, - // modules } if (!db || !models) return From 41de01ff545be7563c10a248be53c1e442357141 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 11:54:37 -0800 Subject: [PATCH 263/295] revert topbar to jsx --- client/src/features/common/TabBar/{TabBar.tsx => TabBar.jsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename client/src/features/common/TabBar/{TabBar.tsx => TabBar.jsx} (100%) diff --git a/client/src/features/common/TabBar/TabBar.tsx b/client/src/features/common/TabBar/TabBar.jsx similarity index 100% rename from client/src/features/common/TabBar/TabBar.tsx rename to client/src/features/common/TabBar/TabBar.jsx From ac1ad54eb1df8bdc227a8d6b4f180e996c8225e9 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 4 Mar 2022 11:54:41 -0800 Subject: [PATCH 264/295] update type on useDB --- client/src/contexts/ModuleProvider.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/contexts/ModuleProvider.tsx b/client/src/contexts/ModuleProvider.tsx index 19893516d..0fac9161c 100644 --- a/client/src/contexts/ModuleProvider.tsx +++ b/client/src/contexts/ModuleProvider.tsx @@ -1,3 +1,4 @@ +import { ModelsType } from '@/types' import { useSnackbar } from 'notistack' import { useContext, createContext, useState, useEffect } from 'react' @@ -18,8 +19,7 @@ const ModuleProvider = ({ children }) => { const { events, publish, subscribe } = usePubSub() const { enqueueSnackbar } = useSnackbar() - const { models } = useDB() - + const { models } = useDB() as unknown as ModelsType const { ADD_MODULE, UPDATE_MODULE, $MODULE_UPDATED } = events // Subscribe to all general update module events From 652e2212edc6105c864298894dfa1c9627abbbcc Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 4 Mar 2022 11:54:55 -0800 Subject: [PATCH 265/295] export userInfoType --- client/src/contexts/NewAuthProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/contexts/NewAuthProvider.tsx b/client/src/contexts/NewAuthProvider.tsx index c0331c83c..742ddec28 100644 --- a/client/src/contexts/NewAuthProvider.tsx +++ b/client/src/contexts/NewAuthProvider.tsx @@ -19,7 +19,7 @@ interface SessionInfoType { appRootUrl: string } -interface UserInfoType { +export interface UserInfoType { id: number email: string groups: string[] From 6d00e68365e1b8146dfaca25c249737b59411115 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 4 Mar 2022 11:55:22 -0800 Subject: [PATCH 266/295] remove modelsType into its own file and add type to useDB --- client/src/features/HomeScreen/HomeScreen.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/client/src/features/HomeScreen/HomeScreen.tsx b/client/src/features/HomeScreen/HomeScreen.tsx index 1cd96b72d..ae8b30412 100644 --- a/client/src/features/HomeScreen/HomeScreen.tsx +++ b/client/src/features/HomeScreen/HomeScreen.tsx @@ -12,17 +12,12 @@ import CreateNew from './screens/CreateNew' import OpenProject from './screens/OpenProject' import css from './homeScreen.module.css' import LoadingScreen from '../common/LoadingScreen/LoadingScreen' +import { ModelsType } from '../../types' //MAIN -type ModelsType = { - modules: { - updateOrCreate: Function - } -} - const StartScreen = () => { - const models = useDB() as unknown as ModelsType + const { models } = useDB() as unknown as ModelsType const { openTab, closeTabBySpellId } = useTabManager() const navigate = useNavigate() From bf1b80b10a5efdd73c1d939834e6db21d2f0d50e Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 4 Mar 2022 11:55:52 -0800 Subject: [PATCH 267/295] refactor rete provider --- .../features/Thoth/contexts/ReteProvider.tsx | 74 +++++-------------- 1 file changed, 18 insertions(+), 56 deletions(-) diff --git a/client/src/features/Thoth/contexts/ReteProvider.tsx b/client/src/features/Thoth/contexts/ReteProvider.tsx index 402c5edd1..bd3f171fd 100644 --- a/client/src/features/Thoth/contexts/ReteProvider.tsx +++ b/client/src/features/Thoth/contexts/ReteProvider.tsx @@ -13,65 +13,29 @@ import { invokeInference } from '../../../utils/huggingfaceHelper' import { useDB } from '../../../contexts/DatabaseProvider' import { usePubSub } from '../../../contexts/PubSubProvider' import { useFetchFromImageCacheMutation } from '@/state/api/visualGenerationsApi' -import { ImageType } from '@latitudegames/thoth-core/src/components/VisualGeneration' +import { ModelsType } from '../../../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. */ export interface ReteContext extends EngineContext { - onInspector: () => void - onPlayTest: () => void - onGameState: () => void - sendToPlaytest: () => void - sendToInspector: () => void - sendToDebug: () => void - onDebug: () => void + onInspector: (node, callback) => void + onPlaytest: (callback) => void + sendToPlaytest: (data) => void + sendToInspector: (data) => void + sendToDebug: (data) => void + onDebug: (node, callback) => void clearTextEditor: () => void - getSpell: () => void - getModule: () => void - getGameState: () => void - setGameState: () => void - getModules: () => void + getSpell: Function + getModule: Function + getModules: Function getCurrentGameState: () => Record - updateCurrentGameState: () => Promise> - readFromImageCache: () => Promise> + updateCurrentGameState: (update) => void + readFromImageCache: (caption, cacheTag, topK) => Promise> } -const Context = createContext({ - onInspector: () => {}, - onPlayTest: () => {}, - onGameState: () => {}, - onAddModule: () => {}, - onUpdateModule: () => {}, - onDeleteModule: () => {}, - onModuleUpdated: () => {}, - sendToPlaytest: () => {}, - sendToInspector: () => {}, - sendToDebug: () => {}, - onDebug: () => {}, - clearTextEditor: () => {}, - getSpell: () => {}, - getModule: () => {}, - getGameState: () => {}, - setGameState: () => {}, - getModules: async () => {}, - getCurrentGameState: () => ({} as Record), - updateCurrentGameState: () => ({} as Promise>), - completion: _completion, - enkiCompletion: async (): Promise<{ outputs: string[] }> => - await new Promise(resolve => { - resolve({} as { outputs: string[] }) - }), - huggingface: async (): Promise<{ [key: string]: unknown; error: unknown }> => - await new Promise(resolve => { - resolve({} as { [key: string]: unknown; error: unknown }) - }), - readFromImageCache: async (): Promise<{ outputs: ImageType[] }> => - await new Promise(resolve => { - resolve({} as { outputs: ImageType[] }) - }), -}) +const Context = createContext(undefined!) export const useRete = () => useContext(Context) @@ -80,9 +44,7 @@ const ReteProvider = ({ children, tab }) => { const dispatch = useDispatch() const [fetchFromImageCache] = useFetchFromImageCacheMutation() - const { - models: { spells, modules }, - } = useDB() + const { models } = useDB() as unknown as ModelsType const { $PLAYTEST_INPUT, @@ -184,10 +146,10 @@ const ReteProvider = ({ children, tab }) => { store.getState().gameState, tab.spell ) - return currentGameState?.state + return currentGameState?.state ?? {} } - const updateCurrentGameState = async update => { + const updateCurrentGameState = update => { const newState = { spellId: tab.spell, state: update, @@ -213,10 +175,10 @@ const ReteProvider = ({ children, tab }) => { readFromImageCache, getCurrentGameState, updateCurrentGameState, - ...modules, + ...models.modules, // going to need to manuall create theses - ...spells, + ...models.spells, } return {children} From ea7391389e10dfd58be3252908d47f4d9ca31740 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 4 Mar 2022 11:56:15 -0800 Subject: [PATCH 268/295] change updateCurrentGameState type in engine --- core/src/engine.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/engine.ts b/core/src/engine.ts index 82ce4f633..097416198 100644 --- a/core/src/engine.ts +++ b/core/src/engine.ts @@ -43,7 +43,7 @@ export type EngineContext = { body: ModelCompletionOpts ) => Promise getCurrentGameState: () => Record - updateCurrentGameState: () => Promise> + updateCurrentGameState: (update: Record) => void enkiCompletion: ( taskName: string, inputs: string[] From 05ad49f471219a17b8c8d2cf327d225e50d149d9 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 4 Mar 2022 12:09:34 -0800 Subject: [PATCH 269/295] add loading screen to auth provider --- client/src/contexts/AuthProvider.tsx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/client/src/contexts/AuthProvider.tsx b/client/src/contexts/AuthProvider.tsx index 0985f2b0f..a619247e7 100644 --- a/client/src/contexts/AuthProvider.tsx +++ b/client/src/contexts/AuthProvider.tsx @@ -11,6 +11,8 @@ import { useQuery } from '../hooks/useQuery' import { useLocation } from 'react-router-dom' import { oAuthClientId, latitudeApiRootUrl, appRootUrl } from '../config' import { callExpire } from '../helpers/Expire' +import LoadingScreen from '../features/common/LoadingScreen/LoadingScreen' + interface SessionInfoType { id: number email: string @@ -49,19 +51,12 @@ const AuthProvider = ({ children }: { children: ReactElement }) => { // const { models } = useDB() const loginRedirect = async (force = false, returnToPath = '') => { - console.log('loginredirect') // User not logged in or session expired, set state and send to login const state = uuidv4() await setOauthState(state) await setStateStore(state, { origin: returnToPath ? returnToPath : window.location.pathname, }) - console.log( - 'redirecting too:', - `${latitudeApiRootUrl}/user/auth/authorize?client_id=${oAuthClientId}&state=${state}&redirect_uri=${encodeURIComponent( - `${appRootUrl}/` - )}${force ? `&force=true` : ''}` - ) window.location.href = `${latitudeApiRootUrl}/user/auth/authorize?client_id=${oAuthClientId}&state=${state}&redirect_uri=${encodeURIComponent( `${appRootUrl}/` )}${force ? `&force=true` : ''}` @@ -225,7 +220,7 @@ const AuthProvider = ({ children }: { children: ReactElement }) => { refreshSession, } - if (!done) return <> + if (!done) return return ( From 3f387868f720fc2f03dc42f3ee004857e2fb2398 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Fri, 4 Mar 2022 12:09:53 -0800 Subject: [PATCH 270/295] fix imports and remove loading from app.ts --- client/src/App.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 036ab18ef..6fe2169ed 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -2,11 +2,10 @@ import { Routes, Route, Navigate } from 'react-router-dom' import { useTabManager } from './contexts/TabManagerProvider' import RequireAuth from './features/common/RequireAuth/RequireAuth' -import LoadingScreen from './features/common/LoadingScreen/LoadingScreen' import ThothPageWrapper from './features/common/ThothPage/ThothPageWrapper' import HomeScreen from './features/HomeScreen/HomeScreen' import Thoth from './features/Thoth/Thoth' -import { useAuthContext } from './contexts/NewAuthProvider' +import { useAuth } from './contexts/AuthProvider' import 'flexlayout-react/style/dark.css' import './design-globals/design-globals.css' @@ -16,7 +15,7 @@ import './App.css' function App() { // Use our routes const { tabs, activeTab } = useTabManager() - const { user } = useAuthContext() + const { user } = useAuth() const redirect = () => { if (user && tabs.length > 0) { @@ -26,8 +25,6 @@ function App() { return user ? : } - if (!user) return - return ( From 90085485f07b790a65fc5c0010bb72db6a064c4b Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 13:15:26 -0800 Subject: [PATCH 271/295] Add apache license to repo --- LICENSE.txt | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 000000000..7a4a3ea24 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file From c04cfd7617b7d0a354e3f608f745fdc120d73467 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 14:09:54 -0800 Subject: [PATCH 272/295] Add notice txt to root --- NOTICE.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 NOTICE.txt diff --git a/NOTICE.txt b/NOTICE.txt new file mode 100644 index 000000000..a876a2596 --- /dev/null +++ b/NOTICE.txt @@ -0,0 +1,4 @@ +Voyage Thoth +Copyright 2021 Latitude, Inc. + +License under Apache License 2.0 \ No newline at end of file From 0faf9b30fce41e757e0c4eaf8e6f146d41057c4d Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 14:10:03 -0800 Subject: [PATCH 273/295] Add contributors file --- CONTRIBUTORS.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 CONTRIBUTORS.txt diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt new file mode 100644 index 000000000..19b2cbb10 --- /dev/null +++ b/CONTRIBUTORS.txt @@ -0,0 +1,12 @@ +This file contains a list of people who have made large contributions +to the public version of Voyage Thoth. + +Original application concept and architecture: + Michael Sharpe + +Stargate Design System designed by: + Preston Gull <> + +Large code contributions by: + Sean Gillespie + Jakob Grant \ No newline at end of file From 47bf500777bb2f96eeb2e67cb71142e739bd9b7f Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 14:12:15 -0800 Subject: [PATCH 274/295] Add open source apache reference link to readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 6b72d3454..c717b27dc 100644 --- a/README.md +++ b/README.md @@ -59,3 +59,8 @@ Builds the @thoth/client app for production to the `client/build` folder. ### `yarn build:core` Builds the @thoth/core package for production to the `core/build` folder. + +## Apache license information + +Good example here for formatting apache license files for reference. +https://www.openntf.org/Internal/home.nsf/dx/Applying_Apache_License From 8ea281daea8fce7f4309606b7bb1114d78504638 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 14:21:03 -0800 Subject: [PATCH 275/295] Update contributors --- CONTRIBUTORS.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 19b2cbb10..38d78c80d 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -5,7 +5,7 @@ Original application concept and architecture: Michael Sharpe Stargate Design System designed by: - Preston Gull <> + Preston Gull Large code contributions by: Sean Gillespie From d92262841ab37d97b65e6aa1c9ca5a8ac46edff6 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 14:36:58 -0800 Subject: [PATCH 276/295] Bump core back to 0.60 --- core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index 16e7d0020..192e1d480 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@latitudegames/thoth-core", - "version": "0.0.61", + "version": "0.0.60", "description": "core shared code for thoth", "main": "dist/index.js", "module": "dist/index.esm.js", From df35ca89e91153dd248bec70d0ed16019cc750a8 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 14:37:16 -0800 Subject: [PATCH 277/295] reset client thoth core dependency to last published version --- client/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/package.json b/client/package.json index 3ed6a38b7..359a0e106 100644 --- a/client/package.json +++ b/client/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@callstack/async-storage": "^2.0.3", - "@latitudegames/thoth-core": "^0.0.61", + "@latitudegames/thoth-core": "^0.0.59", "@material-ui/core": "^4.12.1", "@material-ui/icons": "^4.11.2", "@monaco-editor/react": "^4.2.1", From 20396e4a6e379c4a9665ec2756590a16f00b44ef Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 14:41:13 -0800 Subject: [PATCH 278/295] Update yarn lock --- yarn.lock | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/yarn.lock b/yarn.lock index f64aaa931..87cbe1ee3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1483,6 +1483,25 @@ "@types/yargs" "^16.0.0" chalk "^4.0.0" +"@latitudegames/thoth-core@^0.0.59": + version "0.0.59" + resolved "https://npm.pkg.github.com/download/@latitudegames/thoth-core/0.0.59/4735bade8814e4d561b226d1a2eb92e23307bb24fe3e6242bc53774d4da44c4b#d225d3cc8bd5ec0a24b4b534731b0d8a9c7890ff" + integrity sha512-1SbwmWpTyO+f1wE/auXecAgUudEcCKb7giDWrSgCT3tflOKDYE1bb6RJvIVEUYRmCGvoeM8CQXt8aTPLoWvtJw== + dependencies: + deep-equal "^2.0.5" + handlebars "^4.7.7" + jsdom "^17.0.0" + 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" @@ -12428,6 +12447,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 dea9574087f6981f226b086f6d6abb1f52959bd8 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 15:03:36 -0800 Subject: [PATCH 279/295] Bump core version back to 0.0.61 --- core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index 192e1d480..16e7d0020 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@latitudegames/thoth-core", - "version": "0.0.60", + "version": "0.0.61", "description": "core shared code for thoth", "main": "dist/index.js", "module": "dist/index.esm.js", From 35d245cd81fd903d5daae0905eef303f99b75776 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:11:08 -0800 Subject: [PATCH 280/295] Remove terser plugin --- core/webpack.common.js | 1 - 1 file changed, 1 deletion(-) diff --git a/core/webpack.common.js b/core/webpack.common.js index 48556dfd7..ac5dc0930 100644 --- a/core/webpack.common.js +++ b/core/webpack.common.js @@ -1,7 +1,6 @@ /* eslint-disable no-undef */ /* eslint-disable @typescript-eslint/no-var-requires */ const path = require('path') -const TerserPlugin = require('terser-webpack-plugin') module.exports = () => { const config = { From 880c64dc8513ab4c8f4a9c5a8d21585db5dfe848 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:11:25 -0800 Subject: [PATCH 281/295] Add copyfiles package --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 9ef33326c..ec29fe643 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@typescript-eslint/eslint-plugin": "^4.31.1", "@typescript-eslint/parser": "^4.31.1", "concurrently": "^6.2.1", + "copyfiles": "^2.4.1", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.24.2", "eslint-plugin-prettier": "^4.0.0", From 44785b65968a2a33616face426759f3012adebe0 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:11:31 -0800 Subject: [PATCH 282/295] Update yarn lock --- yarn.lock | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 87cbe1ee3..fe8426958 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9424,6 +9424,13 @@ libnpmpublish@^4.0.0: semver "^7.1.3" ssri "^8.0.1" +license-webpack-plugin@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/license-webpack-plugin/-/license-webpack-plugin-4.0.2.tgz#1e18442ed20b754b82f1adeff42249b81d11aec6" + integrity sha512-771TFWFD70G1wLTC4oU2Cw4qvtmNrIw+wRvBtn+okgHl7slJVi7zfNcdmqDL72BojM30VNJ2UHylr1o77U37Jw== + dependencies: + webpack-sources "^3.0.0" + lie@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" @@ -12447,14 +12454,6 @@ 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" @@ -14425,6 +14424,11 @@ webpack-sources@^1.4.0, webpack-sources@^1.4.1: source-list-map "^2.0.0" source-map "~0.6.1" +webpack-sources@^3.0.0: + version "3.2.3" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" + integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== + webpack-sources@^3.2.0: version "3.2.1" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.1.tgz#251a7d9720d75ada1469ca07dbb62f3641a05b6d" From 8b14bc66c59b92146caffcb6e4239acce4907eac Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:11:46 -0800 Subject: [PATCH 283/295] Add copying of license files with build scripts --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ec29fe643..74ee73e8a 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "start": "concurrently \"yarn start:core\" \"sleep 15s && yarn start:client\"", "lint": "lerna run lint --parallel", "lint:fix": "lerna run lint:fix --parallel", - "build": "lerna exec --scope @thoth/client -- yarn build", - "build:core": "lerna exec --scope @latitudegames/thoth-core -- yarn build", + "build": "copyfiles LICENSE.txt NOTICE.txt CONTRIBUTORS.txt client && lerna exec --scope @thoth/client -- yarn build", + "build:core": "copyfiles LICENSE.txt NOTICE.txt CONTRIBUTORS.txt core && lerna exec --scope @latitudegames/thoth-core -- yarn build", "publish:canary": "lerna exec --scope @latitudegames/thoth-core -- yarn canary", "install:canary": "lerna exec --scope @thoth/client -- yarn install:canary" }, From 74b8715c61d78e7ffc89b7f34c723e6b579fe784 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:12:01 -0800 Subject: [PATCH 284/295] Ignore license files in client package --- client/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/.gitignore b/client/.gitignore index f2c421b2a..4d7f3bfa5 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -2,3 +2,6 @@ node_modules build .DS_Store dist +CONTRIBUTORS.txt +LICENSE.txt +NOTICE.txt \ No newline at end of file From 9ec425d9d0f1abf68f132d1af8f28648898486bd Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:12:14 -0800 Subject: [PATCH 285/295] Add webpack license to core package --- core/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/core/package.json b/core/package.json index 16e7d0020..74809c38b 100644 --- a/core/package.json +++ b/core/package.json @@ -22,6 +22,7 @@ "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", From 1b2d94e0a37002911f34bee723ed527b6179ec11 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:31:29 -0800 Subject: [PATCH 286/295] Update notice --- NOTICE.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NOTICE.txt b/NOTICE.txt index a876a2596..11b6ca683 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,4 +1,6 @@ Voyage Thoth Copyright 2021 Latitude, Inc. -License under Apache License 2.0 \ No newline at end of file +This product includes software developed at Latitude, Inc. (https://www.latitude.io). + +Licensed under Apache License 2.0 \ No newline at end of file From c59190bcf3a306b1d2682836685b0f8438111d87 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:31:44 -0800 Subject: [PATCH 287/295] Rename license and remove .txt suffix --- LICENSE.txt => LICENSE | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENSE.txt => LICENSE (100%) diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE From c327c85d10044935ce0c2ea65695ffe2abdb1a54 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:34:11 -0800 Subject: [PATCH 288/295] Add author and contributors to root package json --- package.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/package.json b/package.json index 74ee73e8a..5181a9d8f 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,13 @@ "name": "@thoth/root", "version": "0.0.1", "private": true, + "license": "apache 2.0", + "author": "Michael Sharpe (https://www.project89.org)", + "contributors": [ + "Sean Gillespie ", + "Jakob Grant ", + "Preston Gull " + ], "workspaces": { "packages": [ "client", From 8faca329745dde1586afb7200e3eab4436369b94 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:34:27 -0800 Subject: [PATCH 289/295] Dont copy contributors and notice --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5181a9d8f..227df424d 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ "start": "concurrently \"yarn start:core\" \"sleep 15s && yarn start:client\"", "lint": "lerna run lint --parallel", "lint:fix": "lerna run lint:fix --parallel", - "build": "copyfiles LICENSE.txt NOTICE.txt CONTRIBUTORS.txt client && lerna exec --scope @thoth/client -- yarn build", - "build:core": "copyfiles LICENSE.txt NOTICE.txt CONTRIBUTORS.txt core && lerna exec --scope @latitudegames/thoth-core -- yarn build", + "build": "copyfiles LICENSE.txt client && lerna exec --scope @thoth/client -- yarn build", + "build:core": "copyfiles LICENSE.txt core && lerna exec --scope @latitudegames/thoth-core -- yarn build", "publish:canary": "lerna exec --scope @latitudegames/thoth-core -- yarn canary", "install:canary": "lerna exec --scope @thoth/client -- yarn install:canary" }, From c3bda88383185c1363d00f47ef8c99788a0f678e Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:34:41 -0800 Subject: [PATCH 290/295] Update git ignores --- client/.gitignore | 4 +--- core/.gitignore | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/client/.gitignore b/client/.gitignore index 4d7f3bfa5..a4a2ded88 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -2,6 +2,4 @@ node_modules build .DS_Store dist -CONTRIBUTORS.txt -LICENSE.txt -NOTICE.txt \ No newline at end of file +LICENSE \ No newline at end of file diff --git a/core/.gitignore b/core/.gitignore index a2b879822..ae1662a57 100644 --- a/core/.gitignore +++ b/core/.gitignore @@ -1,3 +1,4 @@ dist src/plugins/areaPlugin/style.css.d.ts .env +LICENSE \ No newline at end of file From 24792403c0961c90867e3a17a60f886e9a13e972 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:34:58 -0800 Subject: [PATCH 291/295] Add authors and contributors to client package json --- client/package.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/package.json b/client/package.json index 359a0e106..e2abfa234 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,13 @@ { "name": "@thoth/client", "version": "0.1.0", + "license": "Apache-2.0", + "author": "Michael Sharpe (https://www.project89.org)", + "contributors": [ + "Sean Gillespie ", + "Jakob Grant ", + "Preston Gull " + ], "private": true, "scripts": { "start": "NODE_ENV=development webpack serve --config webpack.dev.js", From 554d84978098723836b0ab5dee57eb92d19506d4 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:35:06 -0800 Subject: [PATCH 292/295] Add authors and contributors to core package json --- core/package.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index 74809c38b..b4a0a949b 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,13 @@ { "name": "@latitudegames/thoth-core", "version": "0.0.61", + "license": "Apache-2.0", + "author": "Michael Sharpe (https://www.project89.org)", + "contributors": [ + "Sean Gillespie ", + "Jakob Grant ", + "Preston Gull " + ], "description": "core shared code for thoth", "main": "dist/index.js", "module": "dist/index.esm.js", @@ -61,7 +68,6 @@ "publishConfig": { "registry": "https://npm.pkg.github.com/" }, - "author": "Sean Gillespie ", "auto": { "plugins": [ "npm" From 0df9c2395156381992014e843dabaf4991c33148 Mon Sep 17 00:00:00 2001 From: Michael Sharpe Date: Fri, 4 Mar 2022 16:35:20 -0800 Subject: [PATCH 293/295] Copy licenses over in core build process --- core/webpack.common.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/webpack.common.js b/core/webpack.common.js index ac5dc0930..53a8cb607 100644 --- a/core/webpack.common.js +++ b/core/webpack.common.js @@ -1,6 +1,8 @@ /* eslint-disable no-undef */ /* eslint-disable @typescript-eslint/no-var-requires */ const path = require('path') +const LicenseWebpackPlugin = + require('license-webpack-plugin').LicenseWebpackPlugin module.exports = () => { const config = { @@ -53,6 +55,7 @@ module.exports = () => { }, ], }, + plugins: [new LicenseWebpackPlugin()], } const isAnalyze = typeof process.env.BUNDLE_ANALYZE !== 'undefined' From ef493a29efe245c4eb9bce6d8c231b0005a4f954 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 7 Mar 2022 11:22:13 -0800 Subject: [PATCH 294/295] add staging env reference --- client/.env | 1 + 1 file changed, 1 insertion(+) diff --git a/client/.env b/client/.env index 6bc25a4c7..d1294695d 100644 --- a/client/.env +++ b/client/.env @@ -5,6 +5,7 @@ REACT_APP_SITE_ROOT_URL_PROD=$URL REACT_APP_SITE_ROOT_URL=http://localhost:3001 REACT_APP_LAPI_ROOT_URL=http://localhost:8000 REACT_APP_LAPI_ROOT_URL_PROD=https://api.latitude.io +REACT_APP_SITE_STAGING=https://62264f21c3a9860ad1e5bdd3--optimistic-turing-def916.netlify.app/ # Oauth Client Id REACT_APP_OAUTH_CLIENT_ID=a6b51c87-7565-42ab-a4b0-38a07f3b6c56 \ No newline at end of file From 0730027eb57eb55b59432864b668a2d212a1f690 Mon Sep 17 00:00:00 2001 From: Jakob Grant Date: Mon, 7 Mar 2022 11:22:32 -0800 Subject: [PATCH 295/295] add staging reference form env into config --- client/src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/config.ts b/client/src/config.ts index c1e20e01d..2a431f85c 100644 --- a/client/src/config.ts +++ b/client/src/config.ts @@ -13,6 +13,6 @@ export const oAuthClientId = process.env.REACT_APP_OAUTH_CLIENT_ID export const appRootUrl = process.env.NODE_ENV === 'production' ? window.location.origin.includes('deploy-preview') - ? 'https://deploy-preview-148--optimistic-turing-def916.netlify.app/' + ? process.env.REACT_APP_SITE_STAGING : process.env.REACT_APP_SITE_ROOT_URL_PROD : process.env.REACT_APP_SITE_ROOT_URL