From a01a409b978fced18f7f3a406753f10c37b3f57f Mon Sep 17 00:00:00 2001 From: Max Richter Date: Sun, 5 May 2024 15:11:53 +0200 Subject: [PATCH] feat: move registry and runtime into separate packages --- README.md | 2 + app/package.json | 2 + app/src/lib/helpers/index.ts | 29 --------------- .../lib/performance/PerformanceViewer.svelte | 2 +- .../performance/SmallPerformanceViewer.svelte | 26 +++---------- app/src/lib/performance/index.ts | 1 - app/src/lib/result-viewer/Viewer.svelte | 2 +- .../lib/settings/panels/BenchmarkPanel.svelte | 10 ----- app/src/routes/+page.svelte | 14 +++---- app/src/routes/runtime/server.ts | 34 ----------------- packages/registry/package.json | 17 +++++++++ packages/registry/src/index.ts | 2 + .../registry/src}/node-registry-cache.ts | 4 +- .../registry/src}/node-registry-client.ts | 7 ++-- packages/runtime/package.json | 21 +++++++++++ packages/runtime/src/index.ts | 3 ++ .../runtime/src}/remote-runtime-executor.ts | 0 .../runtime/src/runtime-executor-cache.ts | 19 ++++++++++ .../runtime/src}/runtime-executor.ts | 26 ++----------- .../src}/worker-runtime-executor-backend.ts | 8 ++-- .../runtime/src}/worker-runtime-executor.ts | 0 packages/types/package.json | 2 +- packages/types/src/components.ts | 36 ++++++++++++++---- packages/types/src/index.ts | 2 +- packages/utils/package.json | 2 +- packages/utils/src/index.ts | 2 + packages/utils/src/logger.ts | 29 +++++++++++++++ .../utils/src/performance.ts | 22 +++++++---- pnpm-lock.yaml | 37 +++++++++++++++++++ 29 files changed, 205 insertions(+), 156 deletions(-) delete mode 100644 app/src/routes/runtime/server.ts create mode 100644 packages/registry/package.json create mode 100644 packages/registry/src/index.ts rename {app/src/lib => packages/registry/src}/node-registry-cache.ts (86%) rename {app/src/lib => packages/registry/src}/node-registry-client.ts (94%) create mode 100644 packages/runtime/package.json create mode 100644 packages/runtime/src/index.ts rename {app/src/lib => packages/runtime/src}/remote-runtime-executor.ts (100%) create mode 100644 packages/runtime/src/runtime-executor-cache.ts rename {app/src/lib => packages/runtime/src}/runtime-executor.ts (91%) rename {app/src/lib => packages/runtime/src}/worker-runtime-executor-backend.ts (74%) rename {app/src/lib => packages/runtime/src}/worker-runtime-executor.ts (100%) create mode 100644 packages/utils/src/logger.ts rename app/src/lib/performance/store.ts => packages/utils/src/performance.ts (79%) diff --git a/README.md b/README.md index c369e5e..7a9749f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ Nodarium +Currently this visual programming language is used to develop https://nodes.max-richter.dev, a procedural modelling tool for 3d-plants. + # Table of contents - [Architecture](./docs/ARCHITECTURE.md) diff --git a/app/package.json b/app/package.json index 9466fb3..65227cb 100644 --- a/app/package.json +++ b/app/package.json @@ -10,6 +10,8 @@ "preview": "vite preview" }, "dependencies": { + "@nodes/registry": "link:../packages/registry", + "@nodes/runtime": "link:../packages/runtime", "@nodes/ui": "link:../packages/ui", "@nodes/utils": "link:../packages/utils", "@sveltejs/kit": "^2.5.7", diff --git a/app/src/lib/helpers/index.ts b/app/src/lib/helpers/index.ts index 5799ac5..fb59137 100644 --- a/app/src/lib/helpers/index.ts +++ b/app/src/lib/helpers/index.ts @@ -73,35 +73,6 @@ export const debounce = (fn: Function, ms = 300) => { export const clone: (v: T) => T = "structedClone" in globalThis ? globalThis.structuredClone : (obj) => JSON.parse(JSON.stringify(obj)); -export const createLogger = (() => { - let maxLength = 5; - return (scope: string) => { - maxLength = Math.max(maxLength, scope.length); - let muted = false; - - let isGrouped = false; - - function s(color: string, ...args: any) { - return isGrouped ? [...args] : [`[%c${scope.padEnd(maxLength, " ")}]:`, `color: ${color}`, ...args]; - } - - return { - log: (...args: any[]) => !muted && console.log(...s("#888", ...args)), - info: (...args: any[]) => !muted && console.info(...s("#888", ...args)), - warn: (...args: any[]) => !muted && console.warn(...s("#888", ...args)), - error: (...args: any[]) => console.error(...s("#f88", ...args)), - group: (...args: any[]) => { if (!muted) { console.groupCollapsed(...s("#888", ...args)); isGrouped = true; } }, - groupEnd: () => { if (!muted) { console.groupEnd(); isGrouped = false } }, - mute() { - muted = true; - }, - unmute() { - muted = false; - } - - } - } -})(); export function withSubComponents>( diff --git a/app/src/lib/performance/PerformanceViewer.svelte b/app/src/lib/performance/PerformanceViewer.svelte index 83fa37e..e89998b 100644 --- a/app/src/lib/performance/PerformanceViewer.svelte +++ b/app/src/lib/performance/PerformanceViewer.svelte @@ -3,7 +3,7 @@ import { humanizeNumber } from "$lib/helpers"; import { Checkbox } from "@nodes/ui"; import localStore from "$lib/helpers/localStore"; - import { type PerformanceData } from "./store"; + import { type PerformanceData } from "@nodes/utils"; import BarSplit from "./BarSplit.svelte"; export let data: PerformanceData; diff --git a/app/src/lib/performance/SmallPerformanceViewer.svelte b/app/src/lib/performance/SmallPerformanceViewer.svelte index ab042b6..347c105 100644 --- a/app/src/lib/performance/SmallPerformanceViewer.svelte +++ b/app/src/lib/performance/SmallPerformanceViewer.svelte @@ -2,15 +2,13 @@ import { humanizeDuration, humanizeNumber } from "$lib/helpers"; import localStore from "$lib/helpers/localStore"; import SmallGraph from "./SmallGraph.svelte"; - import type { PerformanceData, PerformanceStore } from "./store"; + import type { PerformanceData, PerformanceStore } from "@nodes/utils"; export let store: PerformanceStore; const open = localStore("node.performance.small.open", { runtime: false, fps: false, - vertices: false, - faces: false, }); $: vertices = $store?.at(-1)?.["total-vertices"][0] || 0; @@ -54,29 +52,15 @@ {/if} - ($open.vertices = !$open.vertices)}> - {$open.vertices ? "-" : "+"} vertices + + vertices {humanizeNumber(vertices || 0)} - {#if $open.vertices} - - - - - - {/if} - ($open.faces = !$open.faces)}> - {$open.faces ? "-" : "+"} faces + + faces {humanizeNumber(faces || 0)} - {#if $open.faces} - - - - - - {/if} diff --git a/app/src/lib/performance/index.ts b/app/src/lib/performance/index.ts index 0d8ab3d..767e4ef 100644 --- a/app/src/lib/performance/index.ts +++ b/app/src/lib/performance/index.ts @@ -1,2 +1 @@ -export * from "./store"; export { default as PerformanceViewer } from "./PerformanceViewer.svelte"; diff --git a/app/src/lib/result-viewer/Viewer.svelte b/app/src/lib/result-viewer/Viewer.svelte index 5a3b945..b610c7a 100644 --- a/app/src/lib/result-viewer/Viewer.svelte +++ b/app/src/lib/result-viewer/Viewer.svelte @@ -5,7 +5,7 @@ import { updateGeometries } from "./updateGeometries"; import { decodeFloat, splitNestedArray } from "@nodes/utils"; - import type { PerformanceStore } from "$lib/performance"; + import type { PerformanceStore } from "@nodes/utils"; import { AppSettings } from "$lib/settings/app-settings"; import SmallPerformanceViewer from "$lib/performance/SmallPerformanceViewer.svelte"; diff --git a/app/src/lib/settings/panels/BenchmarkPanel.svelte b/app/src/lib/settings/panels/BenchmarkPanel.svelte index ac03549..bae4d05 100644 --- a/app/src/lib/settings/panels/BenchmarkPanel.svelte +++ b/app/src/lib/settings/panels/BenchmarkPanel.svelte @@ -136,16 +136,6 @@ border: solid thin var(--outline); border-bottom: none; } - textarea { - width: 100%; - height: 1em; - font-size: 1em; - padding: 0.5em; - border: solid thin var(--outline); - background: var(--layer-2); - box-sizing: border-box; - height: 2.5em; - } i { opacity: 0.5; font-size: 0.8em; diff --git a/app/src/routes/+page.svelte b/app/src/routes/+page.svelte index 09b24f0..d3edc4c 100644 --- a/app/src/routes/+page.svelte +++ b/app/src/routes/+page.svelte @@ -1,8 +1,6 @@