218 Commits

Author SHA1 Message Date
max 36f02cabd3 chore: format
📊 Benchmark the Runtime / benchmark (push) Successful in 1m21s
🚀 Lint & Test & Deploy / quality (push) Failing after 54s
🚀 Lint & Test & Deploy / test-unit (push) Successful in 30s
🚀 Lint & Test & Deploy / test-e2e (push) Successful in 1m52s
🚀 Lint & Test & Deploy / deploy (push) Has been skipped
2026-05-07 17:40:41 +02:00
max 3a78ad5ee3 docs: add ux guidelines 2026-05-07 17:40:30 +02:00
max 9a7a7166b7 fix: pasting nodes 2026-05-07 17:39:58 +02:00
max 4aff3874d3 feat: show toast on some errors 2026-05-07 17:19:08 +02:00
max f415edab57 fix: automatically update graph background on theme swtich 2026-05-07 17:03:02 +02:00
max 743959639f feat: no results state in add menu 2026-05-07 17:02:47 +02:00
max d9b8b36686 feat: update some inputs 2026-05-07 17:02:38 +02:00
max ebf13967a4 feat: use new button component everyhwerre 2026-05-07 17:02:17 +02:00
max a4f51efead feat: add spinning icon 2026-05-07 17:01:54 +02:00
max 308626bcdc feat: add toast component 2026-05-07 17:01:36 +02:00
max 73155dcb46 feat: show confirm when deleting project 2026-05-07 17:01:22 +02:00
max 84afd15746 feat: add #id to group name when duplicates exist 2026-05-07 17:00:57 +02:00
max af40db3386 feat: add ZoomIndicator to graph 2026-05-07 17:00:30 +02:00
nodarium-bot 091c0f0a83 chore(release): v0.0.6 2026-05-05 21:15:25 +00:00
max 82c2f08a56 chore: cleanup changelog
📊 Benchmark the Runtime / benchmark (push) Successful in 1m34s
🚀 Lint & Test & Deploy / deploy (push) Successful in 2m7s
🚀 Lint & Test & Deploy / test-unit (push) Successful in 47s
🚀 Lint & Test & Deploy / quality (push) Successful in 2m28s
🚀 Lint & Test & Deploy / test-e2e (push) Successful in 1m59s
2026-05-05 22:58:42 +02:00
max a00db400bb fix: dont crash when no groups exist
📊 Benchmark the Runtime / benchmark (push) Successful in 1m24s
🚀 Lint & Test & Deploy / test-unit (push) Successful in 48s
🚀 Lint & Test & Deploy / quality (push) Successful in 2m24s
🚀 Lint & Test & Deploy / test-e2e (push) Successful in 1m59s
🚀 Lint & Test & Deploy / deploy (push) Has been cancelled
2026-05-05 22:52:24 +02:00
max 2d9eb0c087 fix: make planty work
📊 Benchmark the Runtime / benchmark (push) Successful in 1m18s
🚀 Lint & Test & Deploy / quality (push) Successful in 2m9s
🚀 Lint & Test & Deploy / test-unit (push) Successful in 33s
🚀 Lint & Test & Deploy / test-e2e (push) Successful in 1m54s
🚀 Lint & Test & Deploy / deploy (push) Successful in 2m4s
2026-05-05 22:45:20 +02:00
nodarium-bot 1e28ded99b chore(release): v0.0.6 2026-05-05 20:33:26 +00:00
nodarium-bot 5fae518392 chore(release): v0.0.6 2026-05-05 20:23:21 +00:00
max 954f5726c3 Merge pull request 'feat: initial node groups' (#44) from feat/group-node-own into main
📊 Benchmark the Runtime / benchmark (push) Successful in 1m11s
🚀 Lint & Test & Deploy / quality (push) Successful in 2m14s
🚀 Lint & Test & Deploy / test-unit (push) Successful in 49s
🚀 Lint & Test & Deploy / test-e2e (push) Successful in 2m3s
🚀 Lint & Test & Deploy / deploy (push) Successful in 3m4s
Reviewed-on: #44
2026-05-05 22:08:17 +02:00
max 63d5b8079d chore: pnpm format
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m39s
🚀 Lint & Test & Deploy / quality (pull_request) Successful in 2m21s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 48s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Successful in 1m51s
🚀 Lint & Test & Deploy / deploy (pull_request) Successful in 2m1s
2026-05-05 21:55:32 +02:00
max 3e32ca419a feat: ungroup nodes
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m45s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 1m7s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 35s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Successful in 2m4s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-05 21:51:17 +02:00
max f0cb12a088 chore: fix some type issues 2026-05-05 21:28:03 +02:00
max 1d60090ffe chore: fixup graph manager tests 2026-05-05 21:27:53 +02:00
max 5b55056fc1 chore: remove graph element in graphManager 2026-05-05 21:27:42 +02:00
max e2c2b1a4d7 chore: remove e2e test screenshots (too flaky) 2026-05-05 21:27:23 +02:00
max 7f082ad8f6 feat: implement node sockets ui
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m22s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 1m6s
🚀 Lint & Test & Deploy / test-unit (pull_request) Failing after 43s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Successful in 2m5s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-05 21:07:57 +02:00
max ed11195327 chore: refactor graphStack to be simpler 2026-05-05 18:45:54 +02:00
max 8ad62cfc8e feat: add node group breadcrumbs 2026-05-05 12:44:44 +02:00
max bff140a764 feat: show different ui when inside group 2026-05-05 11:11:33 +02:00
max 85e2fd1a71 fix: use correct id for debug node 2026-05-04 23:54:43 +02:00
max 5beb03196d fix: broken format command for @nodarium/planty 2026-05-04 23:47:29 +02:00
max 83e0e47082 refactor: only show group/node panel when selected 2026-05-04 23:47:03 +02:00
max 106797de32 feat: make group input/output node work
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m11s
🚀 Lint & Test & Deploy / quality (pull_request) Successful in 2m7s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 32s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Successful in 1m50s
🚀 Lint & Test & Deploy / deploy (pull_request) Successful in 1m56s
2026-05-04 19:11:52 +02:00
max 1a56ba986d damn dude
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m17s
🚀 Lint & Test & Deploy / quality (pull_request) Successful in 2m16s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 49s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Successful in 1m57s
🚀 Lint & Test & Deploy / deploy (pull_request) Successful in 2m1s
2026-05-04 16:14:20 +02:00
max 703f531cd3 chore: make eslint and playwright happy
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m6s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 1m0s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 36s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Successful in 1m57s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 16:11:21 +02:00
max 0ed22f20b9 chore: pnpm upgrade
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m42s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 45s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 31s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 1m49s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 16:01:21 +02:00
max 733b0a2ceb chore: sync sveltekit app before e2e
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m4s
🚀 Lint & Test & Deploy / quality (pull_request) Successful in 2m25s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 38s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 2m1s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 15:49:55 +02:00
max 8f60816c78 chore: sync sveltekit app before e2e
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m4s
🚀 Lint & Test & Deploy / quality (pull_request) Successful in 2m30s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 44s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 47s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 15:43:38 +02:00
max cd7b51d86a chore: sync sveltekit app before e2e
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m8s
🚀 Lint & Test & Deploy / quality (pull_request) Successful in 2m24s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 41s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 45s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 15:37:52 +02:00
max 6c9cd1505d chore: sync sveltekit app before e2e
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m2s
🚀 Lint & Test & Deploy / quality (pull_request) Successful in 2m42s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 32s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 0s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 15:30:42 +02:00
max db5ee8ba29 fix: make eslint happy
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m4s
🚀 Lint & Test & Deploy / quality (pull_request) Successful in 2m24s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 30s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 32s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 15:19:18 +02:00
max a6b9ca4315 feat: capture system stats in benchmark
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m3s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 52s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 31s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 33s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 15:12:51 +02:00
max d4910aba8c chore: pnpm format
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m2s
🚀 Lint & Test & Deploy / quality (pull_request) Successful in 2m30s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 32s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 33s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 15:00:40 +02:00
max e695c76490 chore: make eslint happy
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m6s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 1m7s
🚀 Lint & Test & Deploy / test-unit (pull_request) Successful in 31s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 32s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 14:50:11 +02:00
max 2a54fa7590 feat: add name to groups
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m8s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 45s
🚀 Lint & Test & Deploy / test-unit (pull_request) Failing after 29s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 34s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 14:12:30 +02:00
max 6d5cac65e8 feat(ui): click-to-copy on node values in jsonviewer 2026-05-04 14:12:17 +02:00
max 3ee074b11c feat(ui): make inputselect also handle value+label options 2026-05-04 14:12:03 +02:00
max 59a1e63396 feat: add unit tests for graph state 2026-05-04 12:49:30 +02:00
max 317d1552ce fix: graph correctly restore html refs after exiting node group 2026-05-04 12:49:23 +02:00
max 78439b19e9 fix: make benchmark work 2026-05-04 12:45:06 +02:00
max ef217b1c40 feat: some updates
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m13s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 44s
🚀 Lint & Test & Deploy / test-unit (pull_request) Failing after 29s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 33s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-04 11:27:21 +02:00
max 7499b80789 fix: make the runtime work with groups 2026-05-03 17:49:14 +02:00
max a5b663f6fc feat(ci): split e2e and unit tests 2026-05-03 17:49:00 +02:00
max 05506704bf feat: let claude fix ci
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m1s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 42s
🚀 Lint & Test & Deploy / test (pull_request) Failing after 39s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-03 17:12:49 +02:00
max 63188e57fd feat: let claude fix ci
📊 Benchmark the Runtime / benchmark (pull_request) Failing after 1m0s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 41s
🚀 Lint & Test & Deploy / test (pull_request) Failing after 30s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-03 17:10:13 +02:00
max 4572d30005 feat: let claude refactor ci
📊 Benchmark the Runtime / benchmark (pull_request) Failing after 1s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 1s
🚀 Lint & Test & Deploy / test (pull_request) Failing after 1s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
2026-05-03 17:04:13 +02:00
max ccc376d158 feat: store total vertices/faces in benchmarkl
📊 Benchmark the Runtime / release (pull_request) Successful in 1m19s
🚀 Lint & Test & Deploy / release (pull_request) Failing after 49s
2026-05-03 16:46:18 +02:00
max 7e432e9033 chore: update ci workflow
📊 Benchmark the Runtime / release (pull_request) Successful in 2m24s
🚀 Lint & Test & Deploy / release (pull_request) Failing after 50s
2026-05-03 16:44:02 +02:00
max 01f58377c2 feat: make more node group features work
📊 Benchmark the Runtime / release (pull_request) Successful in 4m32s
🚀 Lint & Test & Deploy / release (pull_request) Failing after 1m5s
2026-05-03 16:34:52 +02:00
max 6ef5dc28ed chore: move jsonviewer into ui package 2026-05-03 16:28:40 +02:00
max 3450d70047 docs: add LLM.md 2026-05-03 13:51:33 +02:00
max 731b9e9b1e feat: upgrade graph source panel 2026-05-03 13:51:17 +02:00
max 72f07d0a50 feat: initial node groups 2026-04-26 18:41:25 +02:00
max a56e8f445e feat(ci): install openssh client
📊 Benchmark the Runtime / release (push) Successful in 44s
🚀 Lint & Test & Deploy / release (push) Successful in 4m17s
Build & Push CI Image / build-and-push (push) Successful in 11m54s
2026-04-24 13:56:07 +02:00
max 12572742eb fix(planty): remove debug span
📊 Benchmark the Runtime / release (push) Successful in 1m4s
🚀 Lint & Test & Deploy / release (push) Successful in 3m52s
2026-04-21 01:01:37 +02:00
max 7aa9979e35 chore: update e2e tests
📊 Benchmark the Runtime / release (push) Successful in 1m0s
🚀 Lint & Test & Deploy / release (push) Successful in 3m47s
2026-04-21 00:51:09 +02:00
max fc35a68826 fix: dont package ui library
📊 Benchmark the Runtime / release (push) Successful in 48s
🚀 Lint & Test & Deploy / release (push) Failing after 3m7s
2026-04-21 00:40:49 +02:00
max aba6f03bcc fix: dont package ui library
📊 Benchmark the Runtime / release (push) Successful in 57s
🚀 Lint & Test & Deploy / release (push) Failing after 1m53s
2026-04-21 00:33:56 +02:00
max 2d6fd00fd1 fix: dont package ui library
📊 Benchmark the Runtime / release (push) Successful in 50s
🚀 Lint & Test & Deploy / release (push) Failing after 2m8s
2026-04-21 00:09:49 +02:00
max d231946e50 fix: remove unused imports
📊 Benchmark the Runtime / release (push) Successful in 47s
🚀 Lint & Test & Deploy / release (push) Failing after 1m45s
2026-04-20 23:57:07 +02:00
max e2f4a24f75 fix(planty): make sure config is completely static
📊 Benchmark the Runtime / release (push) Successful in 54s
🚀 Lint & Test & Deploy / release (push) Failing after 57s
2026-04-20 21:34:24 +02:00
max 58d39cd101 feat: improve planty ux 2026-04-20 21:23:55 +02:00
max 7ebb1297ac feat(app): make zoom in nicer 2026-04-20 19:45:34 +02:00
max 23f65a1c63 fix: remove unused header div 2026-04-20 19:45:23 +02:00
max acdc582e95 feat: use ui and planty without build 2026-04-20 19:45:10 +02:00
max 7a3e9eb893 chore: update test screenshot
📊 Benchmark the Runtime / release (push) Successful in 1m20s
🚀 Lint & Test & Deploy / release (push) Successful in 4m48s
2026-04-20 02:06:13 +02:00
max be82312ea0 chore: update test screenshot
📊 Benchmark the Runtime / release (push) Successful in 1m33s
🚀 Lint & Test & Deploy / release (push) Has been cancelled
2026-04-20 02:04:07 +02:00
max 84f67e9c33 fix: update planty types
📊 Benchmark the Runtime / release (push) Successful in 1m8s
🚀 Lint & Test & Deploy / release (push) Failing after 4m18s
2026-04-20 01:57:56 +02:00
max 491e345c2f feat: build planty in post install
📊 Benchmark the Runtime / release (push) Successful in 1m24s
🚀 Lint & Test & Deploy / release (push) Failing after 1m41s
2026-04-20 01:53:40 +02:00
max ba501b211d fix: correct tsconfig for planty
📊 Benchmark the Runtime / release (push) Successful in 1m12s
🚀 Lint & Test & Deploy / release (push) Failing after 1m32s
2026-04-20 01:43:05 +02:00
max 7d76b9e1f7 fix: mark planty as type:module
📊 Benchmark the Runtime / release (push) Successful in 1m21s
🚀 Lint & Test & Deploy / release (push) Failing after 1m27s
2026-04-20 01:38:29 +02:00
max 5d4e2e9280 fix: make formatter happy
📊 Benchmark the Runtime / release (push) Successful in 1m3s
🚀 Lint & Test & Deploy / release (push) Failing after 1m32s
2026-04-20 01:32:30 +02:00
max 4de15b19c8 feat: wire up planty with nodarium/app
📊 Benchmark the Runtime / release (push) Successful in 3m55s
🚀 Lint & Test & Deploy / release (push) Failing after 56s
2026-04-20 01:08:52 +02:00
max 168e6fcc19 feat: update some node default settings 2026-04-20 01:08:41 +02:00
max c0eb75d53c feat: new planty package 2026-04-20 01:08:29 +02:00
max 2ec9bfc3c9 feat(ci): compress benchmark data
📊 Benchmark the Runtime / release (push) Successful in 1m20s
🚀 Lint & Test & Deploy / release (push) Successful in 4m7s
2026-02-13 15:21:57 +01:00
max c97520617a fix(ci): use older upload-artifact action
📊 Benchmark the Runtime / release (push) Successful in 1m16s
🚀 Lint & Test & Deploy / release (push) Successful in 4m23s
2026-02-13 15:01:59 +01:00
max 6475790176 fix(ci): build nodes before benchmarking
📊 Benchmark the Runtime / release (push) Failing after 1m16s
🚀 Lint & Test & Deploy / release (push) Has been cancelled
2026-02-13 14:57:07 +01:00
max 580ec73465 ci: run benchmark in ci
📊 Benchmark the Runtime / release (push) Failing after 42s
🚀 Lint & Test & Deploy / release (push) Successful in 4m20s
2026-02-13 14:46:21 +01:00
nodarium-bot fd98d457a3 chore(release): v0.0.5 2026-02-13 01:47:35 +00:00
max f16ba2601f fix(ci): still trying to get gpg to work
🚀 Lint & Test & Deploy / release (push) Successful in 3m54s
2026-02-13 02:43:02 +01:00
max cc6b832f15 fix(ci): trying to get gpg to work
🚀 Lint & Test & Deploy / release (push) Failing after 3m22s
2026-02-13 02:25:11 +01:00
max dd5fd5bf17 fix(ci): better add updates to package.json
🚀 Lint & Test & Deploy / release (push) Failing after 4m0s
2026-02-13 02:10:34 +01:00
max 38d0fffcf4 chore: update ci image
🚀 Lint & Test & Deploy / release (push) Failing after 3m48s
2026-02-13 01:58:16 +01:00
max bce06da456 ci: add gpg-agent to ci image
Build & Push CI Image / build-and-push (push) Successful in 8m43s
🚀 Lint & Test & Deploy / release (push) Has been cancelled
2026-02-13 01:47:32 +01:00
max af585d56ec feat: use new ci image with gpg
🚀 Lint & Test & Deploy / release (push) Failing after 3m45s
2026-02-13 01:24:19 +01:00
max 0aa73a27c1 feat: install gpg in ci image
Build & Push CI Image / build-and-push (push) Successful in 10m7s
🚀 Lint & Test & Deploy / release (push) Has been cancelled
2026-02-13 01:13:01 +01:00
max c1ae70282c feat: add color to sockets
🚀 Lint & Test & Deploy / release (push) Failing after 3m5s
Closes #34
2026-02-13 00:57:28 +01:00
max 4c7b03dfb8 feat: add gradient mesh line 2026-02-13 00:51:21 +01:00
max 144e8cc797 fix: correctly highlight possible outputs 2026-02-12 23:38:44 +01:00
max 12ff9c1518 Merge pull request 'feat/debug-node' (#41) from feat/debug-node into main
🚀 Lint & Test & Deploy / release (push) Successful in 3m58s
Reviewed-on: #41
2026-02-12 23:20:58 +01:00
max 8d3ffe84ab Merge branch 'main' into feat/debug-node
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m54s
2026-02-12 23:05:09 +01:00
max 95ec93eead feat: better handle ctrl+shift clicks and selections
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m45s
2026-02-12 22:46:50 +01:00
max d39185efaf feat: add "pnpm qa" command to check before commit
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m52s
2026-02-12 22:33:37 +01:00
max 81580ccd8c fix: cleanup some type errors 2026-02-12 22:33:25 +01:00
max bf6f632d27 feat: add shortcut to quick connect to debug
🚀 Lint & Test & Deploy / release (pull_request) Failing after 1m22s
2026-02-12 22:27:11 +01:00
release-bot e098be6013 fix: also execute all nodes before debug node
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m56s
2026-02-12 21:57:33 +01:00
release-bot ec13850e1c fix: make debug node work with runtime 2026-02-12 21:42:44 +01:00
release-bot 15e08a8163 feat: implement debug node
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m53s
Closes #39
2026-02-12 21:33:47 +01:00
release-bot 48cee58ad3 chore: update test snapshots
🚀 Lint & Test & Deploy / release (pull_request) Successful in 4m8s
2026-02-12 18:26:13 +01:00
release-bot 3235cae904 chore: fix lint and typecheck errors
🚀 Lint & Test & Deploy / release (pull_request) Failing after 3m15s
2026-02-12 18:19:27 +01:00
release-bot 3f440728fc feat: implement variable height for node shader
🚀 Lint & Test & Deploy / release (pull_request) Failing after 1m3s
2026-02-12 18:11:14 +01:00
release-bot da09f8ba1e refactor: move debug node into runtime 2026-02-12 16:18:29 +01:00
release-bot ddc3b4ce35 feat: allow variable height node parameters 2026-02-12 16:18:12 +01:00
release-bot 2690fc8712 chore: gitignore pnpm-store
🚀 Lint & Test & Deploy / release (push) Successful in 4m6s
2026-02-12 15:42:38 +01:00
release-bot 072ab9063b feat: add initial debug node 2026-02-12 14:00:18 +01:00
release-bot e23cad254d feat: add "*" datatype for inputs for debug node 2026-02-12 14:00:06 +01:00
release-bot 5b5c63c1a9 fix(ui): make arrows on inputnumber visible on lighttheme 2026-02-12 13:31:34 +01:00
release-bot c9021f2383 refactor: merge all dev settings into one setting 2026-02-12 13:10:14 +01:00
max 9eecdd4fb8 Merge pull request 'feat: merge localState recursively with initial' (#38) from feat/debug-node into main
🚀 Lint & Test & Deploy / release (push) Successful in 3m50s
Reviewed-on: #38
2026-02-12 12:51:28 +01:00
release-bot 7e71a41e52 feat: merge localState recursively with initial
🚀 Lint & Test & Deploy / release (pull_request) Successful in 4m0s
Closes #17
2026-02-12 12:50:58 +01:00
release-bot 07cd9e84eb feat: clamp AddMenu to viewport
🚀 Lint & Test & Deploy / release (push) Successful in 4m10s
2026-02-10 21:51:50 +01:00
release-bot a31a49ad50 ci: lint and typecheck before build
🚀 Lint & Test & Deploy / release (push) Successful in 3m42s
2026-02-10 15:54:50 +01:00
release-bot 850d641a25 chore: pnpm format
🚀 Lint & Test & Deploy / release (push) Has been cancelled
2026-02-10 15:54:01 +01:00
release-bot ee5ca81757 ci: sign release commits with pgp key
🚀 Lint & Test & Deploy / release (push) Failing after 2m10s
2026-02-10 15:47:42 +01:00
release-bot 22a11832b8 fix(ci): correctly format changelog 2026-02-10 15:24:23 +01:00
release-bot b5ce5723fa chore: format favicon svg
🚀 Lint & Test & Deploy / release (push) Successful in 3m53s
2026-02-10 15:14:35 +01:00
release-bot 102130cc77 feat: add favicon
🚀 Lint & Test & Deploy / release (push) Failing after 2m5s
2026-02-10 15:11:58 +01:00
release-bot 1668a2e6d5 chore: format changelog.md
🚀 Lint & Test & Deploy / release (push) Has been cancelled
2026-02-10 15:09:03 +01:00
release-bot b0af83004e chore(release): v0.0.4 2026-02-10 14:03:49 +00:00
release-bot 51de3ced13 fix(ci): update changelog before building
🚀 Lint & Test & Deploy / release (push) Successful in 3m47s
2026-02-10 14:59:17 +01:00
max 8d403ba803 Merge pull request 'feat/shape-node' (#36) from feat/shape-node into main
🚀 Lint & Test & Deploy / release (push) Successful in 4m0s
Reviewed-on: #36
2026-02-09 22:32:14 +01:00
release-bot 6bb301153a Merge remote-tracking branch 'origin/main' into feat/shape-node
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m47s
2026-02-09 22:27:43 +01:00
release-bot 02eee5f9bf fix: disable macro logs in wasm
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m47s
2026-02-09 22:21:28 +01:00
release-bot 4f48a519a9 feat(nodes): add rotation to instance node
🚀 Lint & Test & Deploy / release (pull_request) Successful in 4m9s
2026-02-09 22:16:20 +01:00
release-bot 97199ac20f feat(nodes): implement leaf node 2026-02-09 22:16:02 +01:00
release-bot f36f0cb230 feat(ui): show circles only when hovering InputShape 2026-02-09 22:15:39 +01:00
release-bot ed3d48e07f fix(runtime): correctly encode 2d shape for wasm nodes 2026-02-09 22:15:11 +01:00
release-bot c610d6c991 fix(app): show backside in three instances 2026-02-09 22:14:45 +01:00
max 8865b9b032 feat(node): initial leaf / shape nodes
🚀 Lint & Test & Deploy / release (pull_request) Successful in 4m1s
2026-02-09 18:32:52 +01:00
max 235ee5d979 fix(app): wrong linter errors in changelog
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m37s
2026-02-09 16:54:45 +01:00
max 23a48572f3 feat(app): dots background for node interface 2026-02-09 16:53:57 +01:00
max e89a46e146 feat(app): add error page
🚀 Lint & Test & Deploy / release (pull_request) Successful in 4m20s
2026-02-09 16:18:27 +01:00
max cefda41fcf feat(theme): optimize node readability 2026-02-09 16:18:19 +01:00
max 21d0f0da5a feat: add high-contrast-light theme 2026-02-09 16:04:17 +01:00
max 46202451ba ci: simplify ci quality checks
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m43s
2026-02-09 15:51:55 +01:00
max 0f4239d179 ci: simplify ci quality checks
🚀 Lint & Test & Deploy / release (pull_request) Failing after 38s
2026-02-09 15:50:05 +01:00
max d9c9bb5234 fix(theme): allow raw html in head style 2026-02-09 15:49:50 +01:00
max 18802fdc10 fix(ui): add missing types
🚀 Lint & Test & Deploy / release (pull_request) Failing after 2m45s
2026-02-09 15:37:37 +01:00
max b1cbd23542 feat(app): use same color for node outline and header
🚀 Lint & Test & Deploy / release (pull_request) Failing after 2m3s
2026-02-09 15:30:40 +01:00
max 33f10da396 feat(ui): make details stand out
🚀 Lint & Test & Deploy / release (pull_request) Failing after 2m6s
2026-02-09 15:26:48 +01:00
max af5b3b23ba fix: make sure that CHANGELOG.md is in correct place 2026-02-09 15:26:40 +01:00
max 64d75b9686 feat(ui): add InputColor and custom theme 2026-02-09 15:26:18 +01:00
release-bot 2e6466ceca chore: update dprint linters
🚀 Lint & Test & Deploy / release (pull_request) Successful in 4m17s
2026-02-09 01:58:05 +01:00
release-bot 20d8e2abed feat(theme): improve light theme a bit 2026-02-09 01:57:32 +01:00
release-bot 715e1d095b feat(theme): merge edge and connection color
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m35s
2026-02-09 01:35:41 +01:00
release-bot 07e2826f16 feat(ui): improve colors of input shape 2026-02-09 00:52:35 +01:00
release-bot e0ad97b003 feat(ui): highlight circle on hover on InputShape
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m53s
2026-02-09 00:21:58 +01:00
release-bot 93df4a19ff fix(ci): handle newline in commit messages for git.json
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m41s
2026-02-09 00:09:28 +01:00
release-bot d661a4e4a9 feat(ui): improve InputShape ux
🚀 Lint & Test & Deploy / release (pull_request) Successful in 4m17s
Allow interactions in mirrored side aswell. Use rightclick to delete
circles.
2026-02-08 23:59:39 +01:00
release-bot c7f808ce2d wip 2026-02-08 22:56:41 +01:00
release-bot 72d6cd6ea2 feat(ui): add initial InputShape element 2026-02-08 21:59:43 +01:00
release-bot 615f2d3c48 feat(ui): allow custom snippets in ui section header 2026-02-08 21:59:00 +01:00
release-bot 2fadb6802d refactor: make changelog code simpler 2026-02-08 21:58:01 +01:00
release-bot 9271d3a7e4 fix(app): handle error while parsing commit
🚀 Lint & Test & Deploy / release (push) Successful in 3m53s
2026-02-08 21:01:34 +01:00
release-bot 13c83efdb9 fix(app): handle error while parsing changelog 2026-02-08 21:00:30 +01:00
release-bot e44b73bebf feat: optimize changelog display
🚀 Lint & Test & Deploy / release (push) Successful in 4m5s
- Hide releases under a Detail
- Hide all commits under a Detail
2026-02-08 19:04:56 +01:00
max 979e9fd922 feat: improve changelog readbility
🚀 Lint & Test & Deploy / release (push) Failing after 2m41s
2026-02-07 17:40:49 +01:00
max 544500e7fe chore: remove pgp from changelog
Build & Push CI Image / build-and-push (push) Successful in 8m48s
🚀 Lint & Test & Deploy / release (push) Successful in 4m13s
2026-02-07 16:58:06 +01:00
max aaebbc4bc0 fix: some stuff with ci 2026-02-07 16:57:50 +01:00
release-bot 894ab70b79 chore(release): v0.0.3 2026-02-07 15:56:02 +00:00
max f8a2a95bc1 chore: clean CHANGELOG.md
Build & Push CI Image / build-and-push (push) Has been cancelled
🚀 Lint & Test & Deploy / release (push) Successful in 4m14s
2026-02-07 16:32:19 +01:00
max c9dd143916 fix(ci): correctly add release notes from tag to changelog 2026-02-07 16:29:59 +01:00
max 898dd49aee fix(ci): correctly copy changelog to build output
🚀 Lint & Test & Deploy / release (push) Successful in 4m7s
2026-02-07 16:20:28 +01:00
max 9fb69d760f feat: show commits since last release in changelog
🚀 Lint & Test & Deploy / release (push) Successful in 4m5s
2026-02-07 16:15:48 +01:00
max bafbcca2b8 fix: wrong socket was highlighted when dragging node
The old code had a bug that highlighted a socket from a node to which a
edge already exists which could not be connected to
2026-02-07 16:15:48 +01:00
max 8ad9e5535c feat: highlight possible sockets when dragging edge
Closes #14
2026-02-07 16:15:44 +01:00
release-bot 43a3c54838 chore(release): v0.0.3 2026-02-07 15:14:21 +00:00
max 11eaeb719b feat(app): display some git metadata in changelog
🚀 Lint & Test & Deploy / release (push) Successful in 3m35s
2026-02-06 16:30:21 +01:00
max 74c2978cd1 chore: cleanup git.json a bit 2026-02-06 16:16:07 +01:00
max 4fdc247904 ci: update build.sh to correct git.json
🚀 Lint & Test & Deploy / release (push) Successful in 4m21s
2026-02-06 15:57:19 +01:00
max c3f8b4b5aa ci: debug available env vars
🚀 Lint & Test & Deploy / release (push) Successful in 3m31s
2026-02-06 15:53:08 +01:00
max 67591c0572 chore: pnpm format
🚀 Lint & Test & Deploy / release (push) Successful in 4m3s
2026-02-06 15:46:54 +01:00
max de1f9d6ab6 feat(ui): change inputnumber to snap to values when alt is pressed
🚀 Lint & Test & Deploy / release (push) Has been cancelled
2026-02-06 15:44:24 +01:00
max 6acce72fb8 fix(ui): correctly initialize InputNumber
When the value is outside min/max the value should not be clamped.
2026-02-06 15:25:18 +01:00
max cf8943b205 chore: pnpm update 2026-02-06 15:18:32 +01:00
max 9e03d36482 chore: use newest ci image
🚀 Lint & Test & Deploy / release (push) Successful in 3m55s
2026-02-06 15:06:39 +01:00
max fd7268d620 ci: make dockerfile work
Build & Push CI Image / build-and-push (push) Successful in 8m42s
🚀 Lint & Test & Deploy / release (push) Failing after 2m31s
2026-02-06 14:43:31 +01:00
max 6358c22a85 ci: use tagged own image for ci
🚀 Lint & Test & Deploy / release (push) Failing after 3m17s
2026-02-06 13:22:33 +01:00
max 655b6a18b2 ci: make dockerfile work
Build & Push CI Image / build-and-push (push) Successful in 9m11s
🚀 Lint & Test & Deploy / release (push) Has been cancelled
2026-02-06 13:10:41 +01:00
max 37b2bdc8bd ci: update ci Dockerfile to work
Build & Push CI Image / build-and-push (push) Failing after 1m24s
🚀 Lint & Test & Deploy / release (push) Failing after 2m23s
2026-02-06 12:52:42 +01:00
max 94e01d4ea8 ci: correctly build and push ci image
Build & Push CI Image / build-and-push (push) Failing after 1m0s
🚀 Lint & Test & Deploy / release (push) Has been cancelled
2026-02-06 12:50:34 +01:00
max 35f5177884 feat: try to optimize the Dockerfile
Build & Push CI Image / build-and-push (push) Failing after 9s
🚀 Lint & Test & Deploy / release (push) Failing after 2m31s
2026-02-06 12:33:36 +01:00
max ac2c61f221 ci: use actual git url in ci
🚀 Lint & Test & Deploy / release (push) Failing after 2m16s
2026-02-06 12:22:51 +01:00
max ef3d46279f fix(ci): build before testing 2026-02-06 11:59:43 +01:00
max 703da324fa ci: automatically build ci image and store locally
Build & Push CI Image / build-and-push (push) Failing after 3m6s
🚀 Lint & Test & Deploy / release (push) Failing after 1m59s
2026-02-06 11:57:44 +01:00
max 1dae472253 ci: add a git.json metadata file during build
🚀 Lint & Test & Deploy / release (push) Failing after 3m14s
2026-02-06 11:48:12 +01:00
max 09fdfb88cd chore: update test screenshots
🚀 Lint & Test & Deploy / release (push) Successful in 4m35s
2026-02-06 00:53:58 +01:00
max 04b63cc7e2 feat: add changelog to sidebar
🚀 Lint & Test & Deploy / release (push) Failing after 4m36s
2026-02-06 00:45:33 +01:00
max cb6a35606d feat(ci): also cache cargo stuff
🚀 Lint & Test & Deploy / release (push) Successful in 4m15s
2026-02-04 21:13:10 +01:00
max 9c9f3ba3b7 fix(ci): use GITHUB_ instead of GITEA_ for env vars
🚀 Lint & Test & Deploy / release (push) Has been cancelled
2026-02-04 20:39:22 +01:00
max 08dda2b2cb chore: pnpm format
🚀 Lint & Test & Deploy / release (push) Failing after 4m46s
2026-02-04 20:30:59 +01:00
max 059129a738 fix(ci): deploy prs and main
🚀 Lint & Test & Deploy / release (push) Failing after 1m45s
2026-02-04 20:28:41 +01:00
max 437c9f4a25 feat(ci): add list of all commits to changelog entry 2026-02-04 20:14:38 +01:00
max 48bf447ce1 docs: straighten up changelog a bit 2026-02-04 20:08:29 +01:00
max 548fa4f0a1 fix(app): correctly initialize vec3 inputs in nestedsettings
Closes #32
2026-02-04 20:08:04 +01:00
release-bot 642cca30ad chore(release): v0.0.2 2026-02-04 18:37:09 +00:00
release-bot 419249aca3 chore(release): v0.0.2
🚀 Release / release (push) Failing after 4m24s
2026-02-03 23:40:36 +00:00
max c69cb94ac7 fix(ci): actually deploy on tags
🚀 Release / release (push) Successful in 4m12s
2026-02-04 00:34:39 +01:00
release-bot 4b652d885f chore(release): v0.0.2 2026-02-03 22:05:51 +00:00
max 381f784775 fix(app): correctly handle false value in settings
🚀 Release / release (push) Successful in 4m30s
This caused a bug where random seed could not be false.
2026-02-03 22:46:43 +01:00
max 91866b4e9a feat/e2e-testing (#31)
🚀 Release / release (push) Successful in 4m7s
Reviewed-on: #31
Co-authored-by: Max Richter <max@max-richter.dev>
Co-committed-by: Max Richter <max@max-richter.dev>
2026-02-03 22:29:43 +01:00
max 01f1568221 fix(ci): auto format changelog.md after release
🚀 Release / release (push) Successful in 3m41s
2026-02-03 15:47:38 +01:00
max 3e8d2768b3 chore: format
🚀 Release / release (push) Failing after 1m42s
2026-02-03 15:43:47 +01:00
max 16a832779a chore(ci): make release script work with sh 2026-02-03 15:43:47 +01:00
max d582915842 chore(ci): add jq and git to ci docker image 2026-02-03 15:43:47 +01:00
release-bot caaecd7a02 chore(release): v0.0.1 2026-02-03 14:43:26 +00:00
187 changed files with 13380 additions and 2986 deletions
+6 -12
View File
@@ -13,16 +13,12 @@
"markdown": {},
"toml": {},
"dockerfile": {},
"ruff": {},
"jupyter": {},
"malva": {},
"markup": {
// https://dprint.dev/plugins/markup_fmt/config/
"scriptIndent": true,
"styleIndent": true,
},
"yaml": {},
"graphql": {},
"exec": {
"cwd": "${configDir}",
"commands": [
@@ -46,20 +42,18 @@
"**/*-lock.yaml",
"**/yaml.lock",
"**/.DS_Store",
"**/.pnpm-store",
"**/.cargo",
"**/target",
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.95.13.wasm",
"https://plugins.dprint.dev/typescript-0.95.15.wasm",
"https://plugins.dprint.dev/json-0.21.1.wasm",
"https://plugins.dprint.dev/markdown-0.20.0.wasm",
"https://plugins.dprint.dev/markdown-0.21.1.wasm",
"https://plugins.dprint.dev/toml-0.7.0.wasm",
"https://plugins.dprint.dev/dockerfile-0.3.3.wasm",
"https://plugins.dprint.dev/ruff-0.6.11.wasm",
"https://plugins.dprint.dev/jupyter-0.2.1.wasm",
"https://plugins.dprint.dev/g-plane/malva-v0.15.1.wasm",
"https://plugins.dprint.dev/g-plane/markup_fmt-v0.25.3.wasm",
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm",
"https://plugins.dprint.dev/g-plane/pretty_graphql-v0.2.3.wasm",
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.6.0.wasm",
"https://plugins.dprint.dev/exec-0.6.0.json@a054130d458f124f9b5c91484833828950723a5af3f8ff2bd1523bd47b83b364",
"https://plugins.dprint.dev/biome-0.11.10.wasm",
],
}
+28
View File
@@ -0,0 +1,28 @@
name: Setup
description: Restore caches and install pnpm dependencies (run after checkout)
runs:
using: composite
steps:
- name: 💾 Setup pnpm Cache
uses: actions/cache@v4
with:
path: .pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: 🦀 Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: 📦 Install Dependencies
shell: bash
run: pnpm install --frozen-lockfile --store-dir .pnpm-store
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -euo pipefail
mkdir -p app/static
cp CHANGELOG.md app/static/CHANGELOG.md
# Derive branch/tag info
REF_TYPE="${GITHUB_REF_TYPE:-branch}"
REF_NAME="${GITHUB_REF_NAME:-$(basename "$GITHUB_REF")}"
BRANCH="${GITHUB_HEAD_REF:-}"
if [[ -z "$BRANCH" && "$REF_TYPE" == "branch" ]]; then
BRANCH="$REF_NAME"
fi
# Determine last tag and commits since
LAST_TAG="$(git describe --tags --abbrev=0 2>/dev/null || true)"
if [[ -n "$LAST_TAG" ]]; then
COMMITS_SINCE_LAST_RELEASE="$(git rev-list --count "${LAST_TAG}..HEAD")"
else
COMMITS_SINCE_LAST_RELEASE="0"
fi
commit_message=$(git log -1 --pretty=%B | tr -d '\n' | sed 's/"/\\"/g')
cat >app/static/git.json <<EOF
{
"ref": "${GITHUB_REF:-}",
"ref_name": "${REF_NAME}",
"ref_type": "${REF_TYPE}",
"sha": "${GITHUB_SHA:-}",
"run_number": "${GITHUB_RUN_NUMBER:-}",
"event_name": "${GITHUB_EVENT_NAME:-}",
"workflow": "${GITHUB_WORKFLOW:-}",
"job": "${GITHUB_JOB:-}",
"commit_message": "${commit_message}",
"commit_timestamp": "$(git log -1 --pretty=%cI)",
"branch": "${BRANCH}",
"commits_since_last_release": "${COMMITS_SINCE_LAST_RELEASE}"
}
EOF
pnpm build
cp -R packages/ui/build app/build/ui
+62 -33
View File
@@ -1,20 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
#!/bin/sh
set -eu
TAG="$GITHUB_REF_NAME"
VERSION="${TAG#v}"
VERSION=$(echo "$TAG" | sed 's/^v//')
DATE=$(date +%Y-%m-%d)
echo "🚀 Creating release for $TAG (safe mode)"
echo "🚀 Creating release for $TAG"
# -------------------------------------------------------------------
# 1. Extract release notes from annotated tag
# -------------------------------------------------------------------
NOTES=$(git tag -l "$TAG" --format='%(contents)')
# Ensure the local git knows this is an annotated tag with metadata
git fetch origin "refs/tags/$TAG:refs/tags/$TAG" --force
if [ -z "$NOTES" ]; then
echo "❌ Tag message is empty"
# %(contents) gets the whole message.
# If you want ONLY what you typed after the first line, use %(contents:body)
NOTES=$(git tag -l "$TAG" --format='%(contents)' | sed '/-----BEGIN PGP SIGNATURE-----/,/-----END PGP SIGNATURE-----/d')
if [ -z "$(echo "$NOTES" | tr -d '[:space:]')" ]; then
echo "❌ Tag message is empty or tag is not annotated"
exit 1
fi
@@ -23,51 +28,75 @@ git checkout main
# -------------------------------------------------------------------
# 2. Update all package.json versions
# -------------------------------------------------------------------
echo "🔧 Updating package.json versions to $VERSION"
find . -name package.json -not -path "*/node_modules/*" | while read -r file; do
jq --arg v "$VERSION" '.version = $v' "$file" >"$file.tmp"
mv "$file.tmp" "$file"
find . -name package.json ! -path "*/node_modules/*" | while read -r file; do
tmp_file="$file.tmp"
jq --arg v "$VERSION" '.version = $v' "$file" >"$tmp_file"
mv "$tmp_file" "$file"
done
# -------------------------------------------------------------------
# 3. Update CHANGELOG.md (prepend)
# 3. Generate commit list since last release
# -------------------------------------------------------------------
LAST_TAG=$(git tag --sort=-creatordate | grep -v "^$TAG$" | head -n 1 || echo "")
if [ -n "$LAST_TAG" ]; then
# Filter out previous 'chore(release)' commits so the list stays clean
COMMITS=$(git log "$LAST_TAG"..HEAD --pretty=format:'* [%h](https://git.max-richter.dev/max/nodarium/commit/%H) %s' | grep -v "chore(release)")
else
COMMITS=$(git log HEAD --pretty=format:'* [%h](https://git.max-richter.dev/max/nodarium/commit/%H) %s' | grep -v "chore(release)")
fi
# -------------------------------------------------------------------
# 4. Update CHANGELOG.md (prepend)
# -------------------------------------------------------------------
tmp_changelog="CHANGELOG.tmp"
{
echo "## $TAG ($DATE)"
echo "# $TAG ($DATE)"
echo ""
echo "$NOTES"
echo ""
echo "---"
if [ -n "$COMMITS" ]; then
echo "---"
echo ""
echo "$COMMITS"
echo ""
fi
echo ""
cat CHANGELOG.md 2>/dev/null || true
} >CHANGELOG.tmp
if [ -f CHANGELOG.md ]; then
cat CHANGELOG.md
fi
} >"$tmp_changelog"
mv CHANGELOG.tmp CHANGELOG.md
mv "$tmp_changelog" CHANGELOG.md
pnpm exec dprint fmt CHANGELOG.md
# -------------------------------------------------------------------
# 4. Create release commit
# 5. Setup GPG signing
# -------------------------------------------------------------------
echo "$BOT_PGP_PRIVATE_KEY" | base64 -d | gpg --batch --import
GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2)
git config user.name "release-bot"
git config user.email "release-bot@ci"
export GPG_TTY=$(tty)
echo "allow-loopback-pinentry" >>~/.gnupg/gpg-agent.conf
gpg-connect-agent reloadagent /bye
git add CHANGELOG.md $(find . -name package.json -not -path "*/node_modules/*")
git config user.name "nodarium-bot"
git config user.email "nodarium-bot@max-richter.dev"
git config --global user.signingkey "$GPG_KEY_ID"
git config --global commit.gpgsign true
# -------------------------------------------------------------------
# 6. Create release commit
# -------------------------------------------------------------------
git add CHANGELOG.md $(git ls-files '**/package.json')
# Skip commit if nothing changed
if git diff --cached --quiet; then
echo "No changes to commit for release $TAG"
exit 0
else
git commit -m "chore(release): $TAG"
git push origin main
fi
git commit -m "chore(release): $TAG"
# -------------------------------------------------------------------
# 5. Push changes
# -------------------------------------------------------------------
git push origin main
echo "✅ Release commit for $TAG created successfully (tag untouched)"
echo "✅ Release process for $TAG complete"
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -euo pipefail
echo "Configuring rclone"
KEY_FILE="$(mktemp)"
echo "${SSH_PRIVATE_KEY}" >"${KEY_FILE}"
chmod 600 "${KEY_FILE}"
mkdir -p ~/.config/rclone
cat >~/.config/rclone/rclone.conf <<EOF
[sftp-remote]
type = sftp
host = ${SSH_HOST}
user = ${SSH_USER}
port = ${SSH_PORT}
key_file = ${KEY_FILE}
EOF
if [[ "${GITHUB_REF_TYPE:-}" == "tag" ]]; then
TARGET_DIR="${REMOTE_DIR}"
elif [[ "${GITHUB_EVENT_NAME:-}" == "pull_request" ]]; then
SAFE_PR_NAME="${GITHUB_HEAD_REF//\//-}"
TARGET_DIR="${REMOTE_DIR}_${SAFE_PR_NAME}"
elif [[ "${GITHUB_REF_NAME:-}" == "main" ]]; then
TARGET_DIR="${REMOTE_DIR}_main"
else
SAFE_REF="${GITHUB_REF_NAME//\//-}"
TARGET_DIR="${REMOTE_DIR}_${SAFE_REF}"
fi
echo "Deploying to ${TARGET_DIR}"
rclone sync \
--update \
--verbose \
--progress \
--exclude _astro/** \
--stats 2s \
--stats-one-line \
--transfers 4 \
./app/build/ \
"sftp-remote:${TARGET_DIR}"
+67
View File
@@ -0,0 +1,67 @@
name: 📊 Benchmark the Runtime
on:
push:
branches: ["*"]
pull_request:
branches: ["*"]
env:
PNPM_CACHE_FOLDER: .pnpm-store
CARGO_HOME: .cargo
CARGO_TARGET_DIR: target
jobs:
benchmark:
runs-on: ubuntu-latest
container: git.max-richter.dev/max/nodarium-ci:a56e8f445edb6064ae7a7b3b783fb7445f1b4e69
steps:
- name: 📑 Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITEA_TOKEN }}
- name: 🔧 Setup
uses: ./.gitea/actions/setup
- name: 🛠️ Build Nodes
run: pnpm build:nodes
- name: 🏃 Execute Runtime
run: pnpm run --filter @nodarium/app bench
- name: 🔑 Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.GIT_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
cat >> ~/.ssh/config <<'EOF'
Host git.max-richter.dev
Port 2222
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
EOF
ssh-keyscan -p 2222 -H git.max-richter.dev >> ~/.ssh/known_hosts
- name: 📤 Push Results
env:
BENCH_REPO: "git@git.max-richter.dev:max/nodarium-benchmarks.git"
run: |
git config --global user.name "nodarium-bot"
git config --global user.email "nodarium-bot@max-richter.dev"
git clone git@git.max-richter.dev:max/nodarium-benchmarks.git target_bench_repo
BRANCH="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}"
SAFE_PR_NAME=$(printf "%s" "$BRANCH" | tr '/' '-')
DEST_DIR="target_bench_repo/data/$SAFE_PR_NAME/$(date +%s)"
mkdir -p "$DEST_DIR"
cp app/benchmark/out/*.json "$DEST_DIR/"
cd target_bench_repo
git add .
git commit -m "Update benchmarks for $SAFE_PR_NAME: ${{ gitea.sha }}"
git push origin main
+41
View File
@@ -0,0 +1,41 @@
name: Build & Push CI Image
on:
push:
branches:
- main
paths:
- "Dockerfile.ci"
- ".gitea/workflows/build-ci-image.yaml"
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[registry."git.max-richter.dev"]
https = true
insecure = false
- name: Login to Gitea Registry
uses: docker/login-action@v3
with:
registry: git.max-richter.dev
username: ${{ gitea.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.ci
push: true
tags: |
git.max-richter.dev/${{ gitea.repository }}-ci:latest
git.max-richter.dev/${{ gitea.repository }}-ci:${{ gitea.sha }}
+85 -25
View File
@@ -1,58 +1,118 @@
name: 🚀 Release
name: 🚀 Lint & Test & Deploy
on:
push:
branches: ["*"]
tags: ["*"]
pull_request:
branches: ["*"]
env:
PNPM_CACHE_FOLDER: ~/.pnpm-store
PNPM_CACHE_FOLDER: .pnpm-store
CARGO_HOME: .cargo
CARGO_TARGET_DIR: target
jobs:
release:
quality:
runs-on: ubuntu-latest
container: jimfx/nodes:latest
container: git.max-richter.dev/max/nodarium-ci:a56e8f445edb6064ae7a7b3b783fb7445f1b4e69
steps:
- name: 📑 Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITEA_TOKEN }}
- name: 💾 Setup pnpm Cache
uses: actions/cache@v4
- name: 🔧 Setup
uses: ./.gitea/actions/setup
- name: 🧹 Quality Control
run: |
pnpm lint
pnpm format:check
pnpm check
pnpm build
test-unit:
runs-on: ubuntu-latest
container: git.max-richter.dev/max/nodarium-ci:a56e8f445edb6064ae7a7b3b783fb7445f1b4e69
steps:
- name: 📑 Checkout Code
uses: actions/checkout@v4
with:
path: ${{ env.PNPM_CACHE_FOLDER }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
fetch-depth: 0
token: ${{ secrets.GITEA_TOKEN }}
- name: 📦 Install Dependencies
run: pnpm install --frozen-lockfile --store-dir ${{ env.PNPM_CACHE_FOLDER }}
- name: 🔧 Setup
uses: ./.gitea/actions/setup
- name: 🧹 Lint
run: pnpm lint
- name: 🧪 Run Tests
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" pnpm test:unit
- name: 🎨 Format Check
run: pnpm format:check
test-e2e:
runs-on: ubuntu-latest
container: git.max-richter.dev/max/nodarium-ci:a56e8f445edb6064ae7a7b3b783fb7445f1b4e69
- name: 🧬 Type Check
run: pnpm check
steps:
- name: 📑 Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITEA_TOKEN }}
- name: 🛠️ Build
run: pnpm build:deploy
- name: 🔧 Setup
uses: ./.gitea/actions/setup
- name: 🏗️ Build Web Assets
run: pnpm build
- name: 🧪 Run Tests
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" pnpm test:e2e
deploy:
runs-on: ubuntu-latest
needs: [quality, test-e2e, test-unit]
container: git.max-richter.dev/max/nodarium-ci:a56e8f445edb6064ae7a7b3b783fb7445f1b4e69
steps:
- name: 📑 Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITEA_TOKEN }}
- name: 🔧 Setup
uses: ./.gitea/actions/setup
- name: 🏗️ Build Web Assets
run: pnpm build
- name: 🚀 Create Release Commit
if: github.ref_type == 'tag'
if: gitea.ref_type == 'tag'
run: ./.gitea/scripts/create-release.sh
env:
BOT_PGP_PRIVATE_KEY: ${{ secrets.BOT_PGP_PRIVATE_KEY }}
- name: 🛠️ Build
run: ./.gitea/scripts/build.sh
- name: 🏷️ Create Gitea Release
if: github.ref_type == 'tag'
if: gitea.ref_type == 'tag'
uses: akkuman/gitea-release-action@v1
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
tag_name: ${{ gitea.ref_name }}
release_name: Release ${{ gitea.ref_name }}
body_path: CHANGELOG.md
draft: false
prerelease: false
- name: 🚀 Deploy Changed Files via rclone
run: ./.gitea/scripts/deploy-files.sh
env:
REMOTE_DIR: ${{ vars.REMOTE_DIR }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{ vars.SSH_HOST }}
SSH_PORT: ${{ vars.SSH_PORT }}
SSH_USER: ${{ vars.SSH_USER }}
+2
View File
@@ -5,3 +5,5 @@ node_modules/
/target
.direnv/
.pnpm-store/
+329
View File
@@ -0,0 +1,329 @@
# v0.0.6 (2026-05-05)
## Features
- Upgrade graph source panel and JSON viewer with click-to-copy and improved select handling.
- Capture system stats in benchmark runs.
- Split CI into unit and end-to-end pipelines.
- Add `LLM.md` documentation.
- Add 🍀 Planty Tutorial Helper
- Add a way to group nodes
## Node Groups
Node Groups introduce a way to structure graphs into nested, navigable subgraphs for better organization and reuse.
- Nested graph workflows with full runtime support
- Group input and output nodes defining clear boundaries
- Named groups for organization and identification
- Breadcrumb navigation for navigating nested levels
- Context-aware UI when editing inside groups
- Reliable enter/exit transitions with state restoration
- Ability to ungroup nodes back into the main graph
## Planty
Planty is a Clippy-inspired in-app tutorial and guidance system that helps users understand and use the graph editor through contextual assistance.
- Context-aware hints based on user actions in the graph
- Step-by-step onboarding flows for core features
- Inline guidance tied to nodes, sockets, and interactions
- Lightweight runtime integration without external build requirements
## Fixes
- Fix benchmark execution and CI integration issues
- Resolve debug node ID mismatch
- Fix ESLint, TypeScript, Playwright, and test synchronization issues
- Fix packaging issues in `@nodarium/planty` and UI library
- Restore correct graph references after exiting node groups
## Refactors
- Remove graph element handling from `graphManager`
- Restrict panel rendering to selected nodes only
- Move JSON viewer into shared UI package
- Clean up CI workflows
## Chores
- Upgrade dependencies via `pnpm upgrade`
- Add SvelteKit sync before E2E tests
- Remove flaky screenshot artifacts
- General formatting, linting, and test maintenance
---
- [82c2f08](https://git.max-richter.dev/max/nodarium/commit/82c2f08a5653ccd596c6982a1d9efa4b20a0b624) chore: cleanup changelog
- [a00db40](https://git.max-richter.dev/max/nodarium/commit/a00db400bba909db5da499e8484d6ed5541c4ad7) fix: dont crash when no groups exist
- [2d9eb0c](https://git.max-richter.dev/max/nodarium/commit/2d9eb0c0879611c2355e52100b150dd39b924684) fix: make planty work
- [954f572](https://git.max-richter.dev/max/nodarium/commit/954f5726c305508329856b6707a41b77f297c4bf) Merge pull request 'feat: initial node groups' (#44) from feat/group-node-own into main
- [63d5b80](https://git.max-richter.dev/max/nodarium/commit/63d5b8079d785b4fe1e689611cd38e5dd4d3ecb6) chore: pnpm format
- [3e32ca4](https://git.max-richter.dev/max/nodarium/commit/3e32ca419a1b914cbe64d98d887a89f4f5abb0e2) feat: ungroup nodes
- [f0cb12a](https://git.max-richter.dev/max/nodarium/commit/f0cb12a088609f5bd56096f7c1f244af0a1f91d8) chore: fix some type issues
- [1d60090](https://git.max-richter.dev/max/nodarium/commit/1d60090ffe1a93af4c0df6f36741957ac13b1a73) chore: fixup graph manager tests
- [5b55056](https://git.max-richter.dev/max/nodarium/commit/5b55056fc12271b87393cf9ef3b61cdf518a9857) chore: remove graph element in graphManager
- [e2c2b1a](https://git.max-richter.dev/max/nodarium/commit/e2c2b1a4d73e0953ddd0125cabe83649b58c8996) chore: remove e2e test screenshots (too flaky)
- [7f082ad](https://git.max-richter.dev/max/nodarium/commit/7f082ad8f6f144b92947000b91ceddce3c52704b) feat: implement node sockets ui
- [ed11195](https://git.max-richter.dev/max/nodarium/commit/ed1119532750d47a1395ced92fe310a6aa5e070e) chore: refactor graphStack to be simpler
- [8ad62cf](https://git.max-richter.dev/max/nodarium/commit/8ad62cfc8e8c60e4e72fdaa3d8caca75a7472da6) feat: add node group breadcrumbs
- [bff140a](https://git.max-richter.dev/max/nodarium/commit/bff140a764ff0b6ed2c6e42814a088ca9e2ef1ee) feat: show different ui when inside group
- [85e2fd1](https://git.max-richter.dev/max/nodarium/commit/85e2fd1a7126aab4a544eea3d185cfc63754cb73) fix: use correct id for debug node
- [5beb031](https://git.max-richter.dev/max/nodarium/commit/5beb03196d46434f617442cc55d721c7d3eebe33) fix: broken format command for @nodarium/planty
- [83e0e47](https://git.max-richter.dev/max/nodarium/commit/83e0e47082ed0d9fbd60e67a6d6c9ed65a9f4f24) refactor: only show group/node panel when selected
- [106797d](https://git.max-richter.dev/max/nodarium/commit/106797de32f0d57059c481770e734b555900421d) feat: make group input/output node work
- [1a56ba9](https://git.max-richter.dev/max/nodarium/commit/1a56ba986d761be545c2cf0236f9c374222da6b1) damn dude
- [703f531](https://git.max-richter.dev/max/nodarium/commit/703f531cd370c2d440a696a68413ea6d5f54019f) chore: make eslint and playwright happy
- [0ed22f2](https://git.max-richter.dev/max/nodarium/commit/0ed22f20b913837b8e90d45aa1a4ada1a90a9313) chore: pnpm upgrade
- [733b0a2](https://git.max-richter.dev/max/nodarium/commit/733b0a2ceb3be6fac1eda5bbf856a4bd1f724e36) chore: sync sveltekit app before e2e
- [8f60816](https://git.max-richter.dev/max/nodarium/commit/8f60816c7841c845120e71590e1c4672d218703e) chore: sync sveltekit app before e2e
- [cd7b51d](https://git.max-richter.dev/max/nodarium/commit/cd7b51d86a1243e0714d9be73588db56c844086c) chore: sync sveltekit app before e2e
- [6c9cd15](https://git.max-richter.dev/max/nodarium/commit/6c9cd1505d72c1c0600910f56ee158d07b7e4811) chore: sync sveltekit app before e2e
- [db5ee8b](https://git.max-richter.dev/max/nodarium/commit/db5ee8ba29812e6865706966ff690ef335ff5e4f) fix: make eslint happy
- [a6b9ca4](https://git.max-richter.dev/max/nodarium/commit/a6b9ca43155b5e9357570705b6f45ba4fc3490a8) feat: capture system stats in benchmark
- [d4910ab](https://git.max-richter.dev/max/nodarium/commit/d4910aba8c5408fb9321b1a22d4c35eae8142309) chore: pnpm format
- [e695c76](https://git.max-richter.dev/max/nodarium/commit/e695c7649015b88d8ca6662bfee5dc0329dd89ac) chore: make eslint happy
- [2a54fa7](https://git.max-richter.dev/max/nodarium/commit/2a54fa7590c1834904a45fb0fc1fd0aa371f0120) feat: add name to groups
- [6d5cac6](https://git.max-richter.dev/max/nodarium/commit/6d5cac65e8acf013ac0a4a61baf3bbc423252d53) feat(ui): click-to-copy on node values in jsonviewer
- [3ee074b](https://git.max-richter.dev/max/nodarium/commit/3ee074b11c9bc216ce7221f5611c8177cef9b313) feat(ui): make inputselect also handle value+label options
- [59a1e63](https://git.max-richter.dev/max/nodarium/commit/59a1e63396635d05543fa4636de5800ce4899a2a) feat: add unit tests for graph state
- [317d155](https://git.max-richter.dev/max/nodarium/commit/317d1552cea5a234ab1ab87684be9a3724b1976f) fix: graph correctly restore html refs after exiting node group
- [78439b1](https://git.max-richter.dev/max/nodarium/commit/78439b19e96e6dbdfb31cc794f5b6e1ff005e26e) fix: make benchmark work
- [ef217b1](https://git.max-richter.dev/max/nodarium/commit/ef217b1c409c25d6054515e1f705831ddbf5a24b) feat: some updates
- [7499b80](https://git.max-richter.dev/max/nodarium/commit/7499b80789e99b87df54d6891597fac7edb56b0f) fix: make the runtime work with groups
- [a5b663f](https://git.max-richter.dev/max/nodarium/commit/a5b663f6fc5e67d5ef67b128c22cdc7363232de5) feat(ci): split e2e and unit tests
- [0550670](https://git.max-richter.dev/max/nodarium/commit/05506704bf68dfd289a1c5130d5d86ddd98954b1) feat: let claude fix ci
- [63188e5](https://git.max-richter.dev/max/nodarium/commit/63188e57fd2cf055161508ee88cbef0cd941e662) feat: let claude fix ci
- [4572d30](https://git.max-richter.dev/max/nodarium/commit/4572d30005d3538f357d4e9f1fb637c1a6559fb1) feat: let claude refactor ci
- [ccc376d](https://git.max-richter.dev/max/nodarium/commit/ccc376d158f209b85a62d98919ac716e46e3e253) feat: store total vertices/faces in benchmarkl
- [7e432e9](https://git.max-richter.dev/max/nodarium/commit/7e432e9033f7fdc73c21bb363cf502c1d8085407) chore: update ci workflow
- [01f5837](https://git.max-richter.dev/max/nodarium/commit/01f58377c21048f95c839504a3e8c46c27ba12ae) feat: make more node group features work
- [6ef5dc2](https://git.max-richter.dev/max/nodarium/commit/6ef5dc28ed9a4874a7b5fb2a9dca73efd1632519) chore: move jsonviewer into ui package
- [3450d70](https://git.max-richter.dev/max/nodarium/commit/3450d7004781ea58f61d563967441a251c817a9b) docs: add LLM.md
- [731b9e9](https://git.max-richter.dev/max/nodarium/commit/731b9e9b1e52598e11044874a46976e517a1150c) feat: upgrade graph source panel
- [72f07d0](https://git.max-richter.dev/max/nodarium/commit/72f07d0a501fa715c40cf0e7c17527ef3f98e96b) feat: initial node groups
- [a56e8f4](https://git.max-richter.dev/max/nodarium/commit/a56e8f445edb6064ae7a7b3b783fb7445f1b4e69) feat(ci): install openssh client
- [1257274](https://git.max-richter.dev/max/nodarium/commit/12572742eb3ba1641cc744a18d330e88df50e9d0) fix(planty): remove debug span
- [7aa9979](https://git.max-richter.dev/max/nodarium/commit/7aa9979e355fcf90342e8b5f1d233b879bb6c71f) chore: update e2e tests
- [fc35a68](https://git.max-richter.dev/max/nodarium/commit/fc35a68826885ac7e9c624b39a5c0fe7d1cb83f0) fix: dont package ui library
- [aba6f03](https://git.max-richter.dev/max/nodarium/commit/aba6f03bcce3e4363f0f22337d0000083bfff9a9) fix: dont package ui library
- [2d6fd00](https://git.max-richter.dev/max/nodarium/commit/2d6fd00fd1ba31bfa943b6d3a4a628bd5132f668) fix: dont package ui library
- [d231946](https://git.max-richter.dev/max/nodarium/commit/d231946e50975dfa1b41696cefbbc2f742480ea8) fix: remove unused imports
- [e2f4a24](https://git.max-richter.dev/max/nodarium/commit/e2f4a24f759b917d3c7c1ca0b8347312785a03e5) fix(planty): make sure config is completely static
- [58d39cd](https://git.max-richter.dev/max/nodarium/commit/58d39cd101298e6a41922d18466899f7bf4a0f97) feat: improve planty ux
- [7ebb129](https://git.max-richter.dev/max/nodarium/commit/7ebb1297ac75987b3348dd81a57e0d25ed0a7405) feat(app): make zoom in nicer
- [23f65a1](https://git.max-richter.dev/max/nodarium/commit/23f65a1c63650faba2051a2c87f7625378b4b0c6) fix: remove unused header div
- [acdc582](https://git.max-richter.dev/max/nodarium/commit/acdc582e957df149ab723d268ac2e205595db199) feat: use ui and planty without build
- [7a3e9eb](https://git.max-richter.dev/max/nodarium/commit/7a3e9eb893182e46e72e203df1eb7532a4652ddd) chore: update test screenshot
- [be82312](https://git.max-richter.dev/max/nodarium/commit/be82312ea049b21e5ff859163e54ba6da88328a0) chore: update test screenshot
- [84f67e9](https://git.max-richter.dev/max/nodarium/commit/84f67e9c33a1141d7e0c3332375576cd0898a47a) fix: update planty types
- [491e345](https://git.max-richter.dev/max/nodarium/commit/491e345c2ff1893916848380e8941fa77dff44ec) feat: build planty in post install
- [ba501b2](https://git.max-richter.dev/max/nodarium/commit/ba501b211db1d70930fa461e1fd82abb5b639c00) fix: correct tsconfig for planty
- [7d76b9e](https://git.max-richter.dev/max/nodarium/commit/7d76b9e1f77ab934289bb18df6197bfd58ce3eeb) fix: mark planty as type:module
- [5d4e2e9](https://git.max-richter.dev/max/nodarium/commit/5d4e2e928093cac39192960d9de21a0e1710904e) fix: make formatter happy
- [4de15b1](https://git.max-richter.dev/max/nodarium/commit/4de15b19c8bdb35e53ba0d3e3e459cdbb12aee9d) feat: wire up planty with nodarium/app
- [168e6fc](https://git.max-richter.dev/max/nodarium/commit/168e6fcc19dc55383b0b21d2b3ebab733058fb94) feat: update some node default settings
- [c0eb75d](https://git.max-richter.dev/max/nodarium/commit/c0eb75d53c4251d041744b19a37c44d0d4a1728c) feat: new planty package
- [2ec9bfc](https://git.max-richter.dev/max/nodarium/commit/2ec9bfc3c96a97aaf29557c70f76b7bf08156e15) feat(ci): compress benchmark data
- [c975206](https://git.max-richter.dev/max/nodarium/commit/c97520617a0d48a765544feebf2d510400db8fb8) fix(ci): use older upload-artifact action
- [6475790](https://git.max-richter.dev/max/nodarium/commit/64757901766efb7ccbd3693ebc63ba1367fe6d88) fix(ci): build nodes before benchmarking
- [580ec73](https://git.max-richter.dev/max/nodarium/commit/580ec7346599e5d538ff53f31808ff770b4a8095) ci: run benchmark in ci
# v0.0.5 (2026-02-13)
## Features
- Implement debug node with full runtime integration, wildcard (`*`) inputs, variable-height nodes and parameters, and a quick-connect shortcut.
- Add color-coded node sockets and edges to visually indicate data types.
- Recursively merge `localState` with the initial state to safely handle outdated settings stored in `localStorage` when the settings schema changes.
- Clamp the Add Menu to the viewport.
- Add application favicon.
- Consolidate all developer settings into a single **Advanced Mode** setting.
## Fixes
- Fix InputNumber arrow visibility in the light theme.
- Correct changelog formatting issues.
## Chores
- Add `pnpm qa` pre-commit command.
- Run linting and type checks before build in CI.
- Sign release commits with a PGP key.
- General formatting, lint/type cleanup, test snapshot updates, and `.gitignore` maintenance.
---
- [f16ba26](https://git.max-richter.dev/max/nodarium/commit/f16ba2601ff0e8f0f4454e24689499112a2a257a) fix(ci): still trying to get gpg to work
- [cc6b832](https://git.max-richter.dev/max/nodarium/commit/cc6b832f1576356e5453ee4289b02f854152ff9a) fix(ci): trying to get gpg to work
- [dd5fd5b](https://git.max-richter.dev/max/nodarium/commit/dd5fd5bf1715d371566bd40419b72ca05e63401e) fix(ci): better add updates to package.json
- [38d0fff](https://git.max-richter.dev/max/nodarium/commit/38d0fffcf4ca0a346857c3658ccefdfcdf16e217) chore: update ci image
- [bce06da](https://git.max-richter.dev/max/nodarium/commit/bce06da456e3c008851ac006033cfff256015a47) ci: add gpg-agent to ci image
- [af585d5](https://git.max-richter.dev/max/nodarium/commit/af585d56ec825662961c8796226ed9d8cb900795) feat: use new ci image with gpg
- [0aa73a2](https://git.max-richter.dev/max/nodarium/commit/0aa73a27c1f23bea177ecc66034f8e0384c29a8e) feat: install gpg in ci image
- [c1ae702](https://git.max-richter.dev/max/nodarium/commit/c1ae70282cb5d58527180614a80823d80ca478c5) feat: add color to sockets
- [4c7b03d](https://git.max-richter.dev/max/nodarium/commit/4c7b03dfb82174317d8ba01f4725af804201154d) feat: add gradient mesh line
- [144e8cc](https://git.max-richter.dev/max/nodarium/commit/144e8cc797cfcc5a7a1fd9a0a2098dc99afb6170) fix: correctly highlight possible outputs
- [12ff9c1](https://git.max-richter.dev/max/nodarium/commit/12ff9c151873d253ed2e54dcf56aa9c9c4716c7c) Merge pull request 'feat/debug-node' (#41) from feat/debug-node into main
- [8d3ffe8](https://git.max-richter.dev/max/nodarium/commit/8d3ffe84ab9ca9e6d6d28333752e34da878fd3ea) Merge branch 'main' into feat/debug-node
- [95ec93e](https://git.max-richter.dev/max/nodarium/commit/95ec93eeada9bf062e01e1e77b67b8f0343a51bf) feat: better handle ctrl+shift clicks and selections
- [d39185e](https://git.max-richter.dev/max/nodarium/commit/d39185efafc360f49ab9437c0bad1f64665df167) feat: add "pnpm qa" command to check before commit
- [81580cc](https://git.max-richter.dev/max/nodarium/commit/81580ccd8c1db30ce83433c4c4df84bd660d3460) fix: cleanup some type errors
- [bf6f632](https://git.max-richter.dev/max/nodarium/commit/bf6f632d2772c3da812d5864c401f17e1aa8666a) feat: add shortcut to quick connect to debug
- [e098be6](https://git.max-richter.dev/max/nodarium/commit/e098be60135f57cf863904a58489e032ed27e8b4) fix: also execute all nodes before debug node
- [ec13850](https://git.max-richter.dev/max/nodarium/commit/ec13850e1c0ca5846da614d25887ff492cf8be04) fix: make debug node work with runtime
- [15e08a8](https://git.max-richter.dev/max/nodarium/commit/15e08a816339bdf9de9ecb6a57a7defff42dbe8c) feat: implement debug node
- [48cee58](https://git.max-richter.dev/max/nodarium/commit/48cee58ad337c1c6c59a0eb55bf9b5ecd16b99d0) chore: update test snapshots
- [3235cae](https://git.max-richter.dev/max/nodarium/commit/3235cae9049e193c242b6091cee9f01e67ee850e) chore: fix lint and typecheck errors
- [3f44072](https://git.max-richter.dev/max/nodarium/commit/3f440728fc8a94d59022bb545f418be049a1f1ba) feat: implement variable height for node shader
- [da09f8b](https://git.max-richter.dev/max/nodarium/commit/da09f8ba1eda5ed347433d37064a3b4ab49e627e) refactor: move debug node into runtime
- [ddc3b4c](https://git.max-richter.dev/max/nodarium/commit/ddc3b4ce357ef1c1e8066c0a52151713d0b6ed95) feat: allow variable height node parameters
- [2690fc8](https://git.max-richter.dev/max/nodarium/commit/2690fc871291e73d3d028df9668e8fffb1e77476) chore: gitignore pnpm-store
- [072ab90](https://git.max-richter.dev/max/nodarium/commit/072ab9063ba56df0673020eb639548f3a8601e04) feat: add initial debug node
- [e23cad2](https://git.max-richter.dev/max/nodarium/commit/e23cad254d610e00f196b7fdb4532f36fd735a4b) feat: add "*" datatype for inputs for debug node
- [5b5c63c](https://git.max-richter.dev/max/nodarium/commit/5b5c63c1a9c4ef757382bd4452149dc9777693ff) fix(ui): make arrows on inputnumber visible on lighttheme
- [c9021f2](https://git.max-richter.dev/max/nodarium/commit/c9021f2383828f2e2b5594d125165bbc8f70b8e7) refactor: merge all dev settings into one setting
- [9eecdd4](https://git.max-richter.dev/max/nodarium/commit/9eecdd4fb85dc60b8196101050334e26732c9a34) Merge pull request 'feat: merge localState recursively with initial' (#38) from feat/debug-node into main
- [7e71a41](https://git.max-richter.dev/max/nodarium/commit/7e71a41e5229126d404f56598c624709961dbf3b) feat: merge localState recursively with initial
- [07cd9e8](https://git.max-richter.dev/max/nodarium/commit/07cd9e84eb51bc02b7fed39c36cf83caba175ad7) feat: clamp AddMenu to viewport
- [a31a49a](https://git.max-richter.dev/max/nodarium/commit/a31a49ad503d69f92f2491dd685729060ea49896) ci: lint and typecheck before build
- [850d641](https://git.max-richter.dev/max/nodarium/commit/850d641a25cd0c781478c58c117feaf085bdbc62) chore: pnpm format
- [ee5ca81](https://git.max-richter.dev/max/nodarium/commit/ee5ca817573b83cacfa3709e0ae88c6263bc39c1) ci: sign release commits with pgp key
- [22a1183](https://git.max-richter.dev/max/nodarium/commit/22a11832b861ae8b44e2d374b55d12937ecab247) fix(ci): correctly format changelog
- [b5ce572](https://git.max-richter.dev/max/nodarium/commit/b5ce5723fa4a35443df39a9096d0997f808f0b4f) chore: format favicon svg
- [102130c](https://git.max-richter.dev/max/nodarium/commit/102130cc7777ceebcdb3de8466c90cef5b380111) feat: add favicon
- [1668a2e](https://git.max-richter.dev/max/nodarium/commit/1668a2e6d59db071ab3da45204c2b7bfcd2150a2) chore: format changelog.md
# v0.0.4 (2026-02-10)
## Features
- Added shape and leaf nodes, including rotation support.
- Added high-contrast light theme and improved overall node readability.
- Enhanced UI with dots background, clearer details, and consistent node coloring.
- Improved changelog display and parsing robustness.
## Fixes
- Fixed UI issues (backside rendering, missing types, linter errors).
- Improved CI handling of commit messages and changelog placement.
## Chores
- Simplified CI quality checks.
- Updated dprint linters.
- Refactored changelog code.
---
- [51de3ce](https://git.max-richter.dev/max/nodarium/commit/51de3ced133af07b9432e1137068ef43ddfecbc9) fix(ci): update changelog before building
- [8d403ba](https://git.max-richter.dev/max/nodarium/commit/8d403ba8039a05b687f050993a6afca7fb743e12) Merge pull request 'feat/shape-node' (#36) from feat/shape-node into main
- [6bb3011](https://git.max-richter.dev/max/nodarium/commit/6bb301153ac13c31511b6b28ae95c6e0d4c03e9e) Merge remote-tracking branch 'origin/main' into feat/shape-node
- [02eee5f](https://git.max-richter.dev/max/nodarium/commit/02eee5f9bf4b1bc813d5d28673c4d5d77b392a92) fix: disable macro logs in wasm
- [4f48a51](https://git.max-richter.dev/max/nodarium/commit/4f48a519a950123390530f1b6040e2430a767745) feat(nodes): add rotation to instance node
- [97199ac](https://git.max-richter.dev/max/nodarium/commit/97199ac20fb079d6c157962d1a998d63670d8797) feat(nodes): implement leaf node
- [f36f0cb](https://git.max-richter.dev/max/nodarium/commit/f36f0cb2305692c7be60889bcde7f91179e18b81) feat(ui): show circles only when hovering InputShape
- [ed3d48e](https://git.max-richter.dev/max/nodarium/commit/ed3d48e07fa6db84bbb24db6dbe044cbc36f049f) fix(runtime): correctly encode 2d shape for wasm nodes
- [c610d6c](https://git.max-richter.dev/max/nodarium/commit/c610d6c99152d8233235064b81503c2b0dc4ada8) fix(app): show backside in three instances
- [8865b9b](https://git.max-richter.dev/max/nodarium/commit/8865b9b032bdf5a1385b4e9db0b1923f0e224fdd) feat(node): initial leaf / shape nodes
- [235ee5d](https://git.max-richter.dev/max/nodarium/commit/235ee5d979fbd70b3e0fb6f09a352218c3ff1e6d) fix(app): wrong linter errors in changelog
- [23a4857](https://git.max-richter.dev/max/nodarium/commit/23a48572f3913d91d839873cc155a16139c286a6) feat(app): dots background for node interface
- [e89a46e](https://git.max-richter.dev/max/nodarium/commit/e89a46e146e9e95de57ffdf55b05d16d6fe975f4) feat(app): add error page
- [cefda41](https://git.max-richter.dev/max/nodarium/commit/cefda41fcf3d5d011c9f7598a4f3f37136602dbd) feat(theme): optimize node readability
- [21d0f0d](https://git.max-richter.dev/max/nodarium/commit/21d0f0da5a26492fa68ad4897a9b1d9e88857030) feat: add high-contrast-light theme
- [4620245](https://git.max-richter.dev/max/nodarium/commit/46202451ba3eea73bd1bc6ef5129b3e26ee9315c) ci: simplify ci quality checks
- [0f4239d](https://git.max-richter.dev/max/nodarium/commit/0f4239d179ddedd3d012ca98b5bc3312afbc8f10) ci: simplify ci quality checks
- [d9c9bb5](https://git.max-richter.dev/max/nodarium/commit/d9c9bb5234bc8776daf26be99ba77a2145c70649) fix(theme): allow raw html in head style
- [18802fd](https://git.max-richter.dev/max/nodarium/commit/18802fdc10294a58425f052a4fde4bcf4be58caf) fix(ui): add missing types
- [b1cbd23](https://git.max-richter.dev/max/nodarium/commit/b1cbd235420c99a11154ef6a899cc7e14faf1c37) feat(app): use same color for node outline and header
- [33f10da](https://git.max-richter.dev/max/nodarium/commit/33f10da396fdc13edcb8faaee212280102b24f3a) feat(ui): make details stand out
- [af5b3b2](https://git.max-richter.dev/max/nodarium/commit/af5b3b23ba18d73d6abec60949fb0c9edfc25ff8) fix: make sure that CHANGELOG.md is in correct place
- [64d75b9](https://git.max-richter.dev/max/nodarium/commit/64d75b9686c494075223a0a318297fe59ec99e81) feat(ui): add InputColor and custom theme
- [2e6466c](https://git.max-richter.dev/max/nodarium/commit/2e6466ceca1d2131581d1862e93c756affdf6cd6) chore: update dprint linters
- [20d8e2a](https://git.max-richter.dev/max/nodarium/commit/20d8e2abedf0de30299d947575afef9c8ffd61d9) feat(theme): improve light theme a bit
- [715e1d0](https://git.max-richter.dev/max/nodarium/commit/715e1d095b8a77feb0cf66bbb444baf0f163adcb) feat(theme): merge edge and connection color
- [07e2826](https://git.max-richter.dev/max/nodarium/commit/07e2826f16dafa6a07377c9fb591168fa5c2abcf) feat(ui): improve colors of input shape
- [e0ad97b](https://git.max-richter.dev/max/nodarium/commit/e0ad97b003fd8cb4d950c03e5488a5accf6a37d0) feat(ui): highlight circle on hover on InputShape
- [93df4a1](https://git.max-richter.dev/max/nodarium/commit/93df4a19ff816e2bdfa093594721f0829f84c9e6) fix(ci): handle newline in commit messages for git.json
- [d661a4e](https://git.max-richter.dev/max/nodarium/commit/d661a4e4a9dfa6c9c73b5e24a3edcf56e1bbf48c) feat(ui): improve InputShape ux
- [c7f808c](https://git.max-richter.dev/max/nodarium/commit/c7f808ce2d52925425b49f92edf49d9557f8901d) wip
- [72d6cd6](https://git.max-richter.dev/max/nodarium/commit/72d6cd6ea2886626823e6e86856f19338c7af3c1) feat(ui): add initial InputShape element
- [615f2d3](https://git.max-richter.dev/max/nodarium/commit/615f2d3c4866a9e85f3eca398f3f02100c4df355) feat(ui): allow custom snippets in ui section header
- [2fadb68](https://git.max-richter.dev/max/nodarium/commit/2fadb6802de640d692fdab7d654311df0d7b4836) refactor: make changelog code simpler
- [9271d3a](https://git.max-richter.dev/max/nodarium/commit/9271d3a7e4cb0cc751b635c2adb518de7b4100c7) fix(app): handle error while parsing commit
- [13c83ef](https://git.max-richter.dev/max/nodarium/commit/13c83efdb962a6578ade59f10cc574fef0e17534) fix(app): handle error while parsing changelog
- [e44b73b](https://git.max-richter.dev/max/nodarium/commit/e44b73bebfb1cc8e872cd2fa7d8b6ff3565df374) feat: optimize changelog display
- [979e9fd](https://git.max-richter.dev/max/nodarium/commit/979e9fd92289eba9f77221c563337c00028e4cf5) feat: improve changelog readbility
- [544500e](https://git.max-richter.dev/max/nodarium/commit/544500e7fe9ee14412cef76f3c7a32ba6f291656) chore: remove pgp from changelog
- [aaebbc4](https://git.max-richter.dev/max/nodarium/commit/aaebbc4bc082ee93c2317ce45071c9bc61b0b77e) fix: some stuff with ci
# v0.0.3 (2026-02-07)
## Features
- Edge dragging now highlights valid connection sockets, improving graph editing clarity.
- InputNumber supports snapping to predefined values while holding Alt.
- Changelog is accessible directly from the sidebar and now includes git metadata and a list of commits.
## Fixes
- Fixed incorrect socket highlighting when an edge already existed.
- Corrected initialization of `InputNumber` values outside min/max bounds.
- Fixed initialization of nested vec3 inputs.
- Multiple CI fixes to ensure reliable builds, correct environment variables, and proper image handling.
## Maintenance / CI
- Significant CI and Dockerfile cleanup and optimization.
- Improved git metadata generation during builds.
- Dependency updates, formatting, and test snapshot updates.
---
- [f8a2a95](https://git.max-richter.dev/max/nodarium/commit/f8a2a95bc18fa3c8c1db67dc0c2b66db1ff0d866) chore: clean CHANGELOG.md
- [c9dd143](https://git.max-richter.dev/max/nodarium/commit/c9dd143916d758991f3ba30723a32c18b6f98bb5) fix(ci): correctly add release notes from tag to changelog
- [898dd49](https://git.max-richter.dev/max/nodarium/commit/898dd49aee930350af8645382ef5042765a1fac7) fix(ci): correctly copy changelog to build output
- [9fb69d7](https://git.max-richter.dev/max/nodarium/commit/9fb69d760fdf92ecc2448e468242970ec48443b0) feat: show commits since last release in changelog
- [bafbcca](https://git.max-richter.dev/max/nodarium/commit/bafbcca2b8a7cd9f76e961349f11ec84d1e4da63) fix: wrong socket was highlighted when dragging node
- [8ad9e55](https://git.max-richter.dev/max/nodarium/commit/8ad9e5535cd752ef111504226b4dac57b5adcf3d) feat: highlight possible sockets when dragging edge
- [11eaeb7](https://git.max-richter.dev/max/nodarium/commit/11eaeb719be7f34af8db8b7908008a15308c0cac) feat(app): display some git metadata in changelog
- [74c2978](https://git.max-richter.dev/max/nodarium/commit/74c2978cd16d2dd95ce1ae8019dfb9098e52b4b6) chore: cleanup git.json a bit
- [4fdc247](https://git.max-richter.dev/max/nodarium/commit/4fdc24790490d3f13ee94a557159617f4077a2f9) ci: update build.sh to correct git.json
- [c3f8b4b](https://git.max-richter.dev/max/nodarium/commit/c3f8b4b5aad7a525fb11ab14c9236374cb60442d) ci: debug available env vars
- [67591c0](https://git.max-richter.dev/max/nodarium/commit/67591c0572b873d8c7cd00db8efb7dac2d6d4de2) chore: pnpm format
- [de1f9d6](https://git.max-richter.dev/max/nodarium/commit/de1f9d6ab669b8e699d98b8855e125e21030b5b3) feat(ui): change inputnumber to snap to values when alt is pressed
- [6acce72](https://git.max-richter.dev/max/nodarium/commit/6acce72fb8c416cc7f6eec99c2ae94d6529e960c) fix(ui): correctly initialize InputNumber
- [cf8943b](https://git.max-richter.dev/max/nodarium/commit/cf8943b2059aa286e41865caf75058d35498daf7) chore: pnpm update
- [9e03d36](https://git.max-richter.dev/max/nodarium/commit/9e03d36482bb4f972c384b66b2dcf258f0cd18be) chore: use newest ci image
- [fd7268d](https://git.max-richter.dev/max/nodarium/commit/fd7268d6208aede435e1685817ae6b271c68bd83) ci: make dockerfile work
- [6358c22](https://git.max-richter.dev/max/nodarium/commit/6358c22a853ec340be5223fabb8289092e4f4afe) ci: use tagged own image for ci
- [655b6a1](https://git.max-richter.dev/max/nodarium/commit/655b6a18b282f0cddcc750892e575ee6c311036b) ci: make dockerfile work
- [37b2bdc](https://git.max-richter.dev/max/nodarium/commit/37b2bdc8bdbd8ded6b22b89214b49de46f788351) ci: update ci Dockerfile to work
- [94e01d4](https://git.max-richter.dev/max/nodarium/commit/94e01d4ea865f15ce06b52827a1ae6906de5be5e) ci: correctly build and push ci image
- [35f5177](https://git.max-richter.dev/max/nodarium/commit/35f5177884b62bbf119af1bbf4df61dd0291effb) feat: try to optimize the Dockerfile
- [ac2c61f](https://git.max-richter.dev/max/nodarium/commit/ac2c61f2211ba96bbdbb542179905ca776537cec) ci: use actual git url in ci
- [ef3d462](https://git.max-richter.dev/max/nodarium/commit/ef3d46279f4ff9c04d80bb2d9a9e7cfec63b224e) fix(ci): build before testing
- [703da32](https://git.max-richter.dev/max/nodarium/commit/703da324fabbef0e2c017f0f7a925209fa26bd03) ci: automatically build ci image and store locally
- [1dae472](https://git.max-richter.dev/max/nodarium/commit/1dae472253ccb5e3766f2270adc053b922f46738) ci: add a git.json metadata file during build
- [09fdfb8](https://git.max-richter.dev/max/nodarium/commit/09fdfb88cd203ace0e36663ebdb2c8c7ba53f190) chore: update test screenshots
- [04b63cc](https://git.max-richter.dev/max/nodarium/commit/04b63cc7e2fc4fcfa0973cf40592d11457179db3) feat: add changelog to sidebar
- [cb6a356](https://git.max-richter.dev/max/nodarium/commit/cb6a35606dfda50b0c81b04902d7a6c8e59458d2) feat(ci): also cache cargo stuff
- [9c9f3ba](https://git.max-richter.dev/max/nodarium/commit/9c9f3ba3b7c94215a86b0a338a5cecdd87b96b28) fix(ci): use GITHUB_instead of GITEA_ for env vars
- [08dda2b](https://git.max-richter.dev/max/nodarium/commit/08dda2b2cb4d276846abe30bc260127626bb508a) chore: pnpm format
- [059129a](https://git.max-richter.dev/max/nodarium/commit/059129a738d02b8b313bb301a515697c7c4315ac) fix(ci): deploy prs and main
- [437c9f4](https://git.max-richter.dev/max/nodarium/commit/437c9f4a252125e1724686edace0f5f006f58439) feat(ci): add list of all commits to changelog entry
- [48bf447](https://git.max-richter.dev/max/nodarium/commit/48bf447ce12949d7c29a230806d160840b7847e1) docs: straighten up changelog a bit
- [548fa4f](https://git.max-richter.dev/max/nodarium/commit/548fa4f0a1a14adc40a74da1182fa6da81eab3df) fix(app): correctly initialize vec3 inputs in nestedsettings
# v0.0.2 (2026-02-04)
## Fixes
---
- []() fix(ci): actually deploy on tags
- []() fix(app): correctly handle false value in settings
# v0.0.1 (2026-02-03)
chore: format
Generated
+16
View File
@@ -62,6 +62,14 @@ version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
[[package]]
name = "leaf"
version = "0.1.0"
dependencies = [
"nodarium_macros",
"nodarium_utils",
]
[[package]]
name = "math"
version = "0.1.0"
@@ -245,6 +253,14 @@ dependencies = [
"zmij",
]
[[package]]
name = "shape"
version = "0.1.0"
dependencies = [
"nodarium_macros",
"nodarium_utils",
]
[[package]]
name = "stem"
version = "0.1.0"
-15
View File
@@ -1,15 +0,0 @@
FROM node:24-alpine
RUN apk add --no-cache --update curl rclone g++
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUN curl --silent --show-error --location --fail --retry 3 \
--proto '=https' --tlsv1.2 \
--output /tmp/rustup-init.sh https://sh.rustup.rs \
&& sh /tmp/rustup-init.sh -y --no-modify-path --profile minimal \
&& rm /tmp/rustup-init.sh \
&& rustup target add wasm32-unknown-unknown \
&& npm i -g pnpm
+33
View File
@@ -0,0 +1,33 @@
FROM node:25-bookworm-slim
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUN apt-get update && apt-get install -y \
openssh-client \
ca-certificates=20230311+deb12u1 \
gpg=2.2.40-1.1+deb12u2 \
gpg-agent=2.2.40-1.1+deb12u2 \
curl=7.88.1-10+deb12u14 \
git=1:2.39.5-0+deb12u3 \
jq=1.6-2.1+deb12u1 \
g++=4:12.2.0-3 \
rclone=1.60.1+dfsg-2+b5 \
xvfb=2:21.1.7-3+deb12u11 \
xauth=1:1.1.2-1 \
--no-install-recommends \
# Install Rust
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
--default-toolchain stable \
--profile minimal \
&& rustup target add wasm32-unknown-unknown \
# Setup Playwright
&& npm i -g pnpm \
&& pnpm dlx playwright install --with-deps firefox \
# Final Cleanup
&& rm -rf /usr/local/rustup/downloads /usr/local/rustup/tmp \
&& rm -rf /usr/local/cargo/registry/index /usr/local/cargo/registry/cache \
&& rm -rf /usr/local/rustup/toolchains/*/share/doc \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*
+2
View File
@@ -27,3 +27,5 @@ dist-ssr
*.sln
*.sw?
build/
test-results/
+1
View File
@@ -0,0 +1 @@
out/
+47
View File
@@ -0,0 +1,47 @@
import { NodeDefinition, NodeId, NodeRegistry } from '@nodarium/types';
import { createWasmWrapper } from '@nodarium/utils';
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';
export class BenchmarkRegistry implements NodeRegistry {
status: 'loading' | 'ready' | 'error' = 'loading';
private nodes = new Map<string, NodeDefinition>();
async load(nodeIds: NodeId[]): Promise<NodeDefinition[]> {
const nodes = await Promise.all(nodeIds.map(async id => {
const p = resolve('static/nodes/' + id + '.wasm');
const file = await readFile(p);
const node = createWasmWrapper(file as unknown as ArrayBuffer);
const d = node.get_definition();
return {
...d,
execute: node.execute
};
}));
for (const n of nodes) {
this.nodes.set(n.id, n);
}
this.status = 'ready';
return nodes;
}
async register(id: string, wasmBuffer: ArrayBuffer): Promise<NodeDefinition> {
const wasm = createWasmWrapper(wasmBuffer);
const d = wasm.get_definition();
const node = {
...d,
execute: wasm.execute
};
this.nodes.set(id, node);
return node;
}
getNode(id: NodeId | string): NodeDefinition | undefined {
return this.nodes.get(id);
}
getAllNodes(): NodeDefinition[] {
return [];
}
}
+206
View File
@@ -0,0 +1,206 @@
import type { Graph, Graph as GraphType, NodeId } from '@nodarium/types';
import { createLogger, createPerformanceStore, splitNestedArray } from '@nodarium/utils';
import { mkdir, writeFile } from 'node:fs/promises';
import { freemem, loadavg, totalmem } from 'node:os';
import { resolve } from 'node:path';
import { MemoryRuntimeExecutor } from '../src/lib/runtime/runtime-executor.ts';
import { BenchmarkRegistry } from './benchmarkRegistry.ts';
import {
getMachineInfo,
measureCpuUsage,
readCgroupCpuStat,
readCpuSnapshot,
readProcMemInfo,
SystemSample
} from './systemStats.ts';
import defaultPlantTemplate from './templates/default.json' assert { type: 'json' };
import lottaFacesTemplate from './templates/lotta-faces.json' assert { type: 'json' };
import plantTemplate from './templates/plant.json' assert { type: 'json' };
const registry = new BenchmarkRegistry();
const r = new MemoryRuntimeExecutor(registry);
const log = createLogger('bench');
const templates: Record<string, Graph> = {
plant: plantTemplate as unknown as GraphType,
'lotta-faces': lottaFacesTemplate as unknown as GraphType,
default: defaultPlantTemplate as unknown as GraphType
};
function average(values: number[]) {
if (values.length === 0) return 0;
return values.reduce((a, b) => a + b, 0) / values.length;
}
function countGeometry(result: Int32Array): {
totalVertices: number;
totalFaces: number;
} {
const parts = splitNestedArray(result);
let totalVertices = 0;
let totalFaces = 0;
for (const part of parts) {
const type = part[0];
const vertexCount = part[1] >>> 0;
const faceCount = part[2] >>> 0;
if (type === 2) {
const instanceCount = part[3] >>> 0;
totalVertices += vertexCount * instanceCount;
totalFaces += faceCount * instanceCount;
} else {
totalVertices += vertexCount;
totalFaces += faceCount;
}
}
return {
totalVertices,
totalFaces
};
}
async function run(g: GraphType, amount: number) {
await registry.load(g.nodes.map(n => n.type) as NodeId[]);
log.log('loaded ' + g.nodes.length + ' nodes');
log.log('warming up');
for (let index = 0; index < 10; index++) {
await r.execute(g, { randomSeed: true });
}
const systemSamples: SystemSample[] = [];
let previousCpuSnapshot = await readCpuSnapshot();
const sampler = setInterval(async () => {
try {
const cpu = await measureCpuUsage(previousCpuSnapshot);
previousCpuSnapshot = cpu.snapshot;
const [l1, l5, l15] = loadavg();
systemSamples.push({
timestamp: Date.now(),
cpuUsagePercent: cpu.usagePercent,
cpuStealPercent: cpu.stealPercent,
load1: l1,
load5: l5,
load15: l15,
freeMemory: freemem(),
totalMemory: totalmem()
});
} catch (err) {
console.error(err);
}
}, 1000);
log.log('executing');
const perfStore = createPerformanceStore();
r.perf = perfStore;
let res: Int32Array | undefined;
const cgroupBefore = await readCgroupCpuStat();
for (let i = 0; i < amount; i++) {
r.perf?.startRun();
res = await r.execute(g, { randomSeed: true });
r.perf?.stopRun();
const { totalVertices, totalFaces } = countGeometry(res!);
r.perf?.addToLastRun('total-vertices', totalVertices);
r.perf?.addToLastRun('total-faces', totalFaces);
}
const cgroupAfter = await readCgroupCpuStat();
clearInterval(sampler);
log.log('finished');
return {
data: r.perf.get(),
metadata: {
timestamp: new Date().toISOString(),
machine: getMachineInfo(),
process: {
pid: process.pid,
uptime: process.uptime(),
memoryUsage: process.memoryUsage()
},
system: {
averages: {
cpuUsagePercent: average(
systemSamples.map(s => s.cpuUsagePercent)
),
cpuStealPercent: average(
systemSamples.map(s => s.cpuStealPercent)
),
load1: average(systemSamples.map(s => s.load1)),
load5: average(systemSamples.map(s => s.load5)),
load15: average(systemSamples.map(s => s.load15)),
freeMemory: average(
systemSamples.map(s => s.freeMemory)
)
},
samples: systemSamples,
meminfo: await readProcMemInfo()
},
cgroup: {
before: cgroupBefore,
after: cgroupAfter
}
}
};
}
async function main() {
const outPath = resolve('benchmark/out/');
await mkdir(outPath, { recursive: true });
for (const key in templates) {
log.log('executing ' + key);
const perfData = await run(templates[key], 100);
await writeFile(
resolve(outPath, key + '.json'),
JSON.stringify(perfData, null, 2)
);
await new Promise(res => setTimeout(res, 200));
}
}
main();
+129
View File
@@ -0,0 +1,129 @@
import { readFile } from 'node:fs/promises';
import { cpus, totalmem } from 'node:os';
export type CpuSnapshot = {
idle: number;
total: number;
steal: number;
};
export type SystemSample = {
timestamp: number;
cpuUsagePercent: number;
cpuStealPercent: number;
load1: number;
load5: number;
load15: number;
freeMemory: number;
totalMemory: number;
};
export async function readCpuSnapshot(): Promise<CpuSnapshot> {
const stat = await readFile('/proc/stat', 'utf8');
const line = stat.split('\n')[0];
const parts: number[] = line
.trim()
.split(/\s+/)
.slice(1)
.map((v: unknown) => Number(v));
const idle = parts[3];
const iowait = parts[4];
const steal = parts[7];
return {
idle: idle + iowait,
total: parts.reduce((a, b) => a + b, 0),
steal: steal ?? 0
};
}
export async function measureCpuUsage(
previous: CpuSnapshot
): Promise<{
snapshot: CpuSnapshot;
usagePercent: number;
stealPercent: number;
}> {
const current = await readCpuSnapshot();
const idle = current.idle - previous.idle;
const total = current.total - previous.total;
const steal = current.steal - previous.steal;
return {
snapshot: current,
usagePercent: total === 0 ? 0 : 100 * (1 - idle / total),
stealPercent: total === 0 ? 0 : 100 * (steal / total)
};
}
export async function readCgroupCpuStat() {
const possiblePaths = [
'/sys/fs/cgroup/cpu.stat',
'/sys/fs/cgroup/cpu/cpu.stat'
];
for (const path of possiblePaths) {
try {
const txt: string = await readFile(path, 'utf8');
return Object.fromEntries(
txt
.trim()
.split('\n')
.map(line => {
const [k, v] = line.trim().split(/\s+/);
return [k, Number(v)];
})
);
} catch {
// continue
}
}
return null;
}
export async function readProcMemInfo() {
try {
const txt = await readFile('/proc/meminfo', 'utf8');
const result: Record<string, number> = {};
for (const line of txt.split('\n')) {
const match = line.match(/^(\w+):\s+(\d+)/);
if (!match) continue;
result[match[1]] = Number(match[2]);
}
return result;
} catch {
return null;
}
}
export function getMachineInfo() {
const cpuInfo = cpus();
return {
platform: process.platform,
arch: process.arch,
nodeVersion: process.version,
cpuModel: cpuInfo[0]?.model ?? 'unknown',
cpuCount: cpuInfo.length,
totalMemory: totalmem(),
ci: {
githubActions: process.env.GITHUB_ACTIONS ?? false,
runnerName: process.env.RUNNER_NAME ?? null,
runnerOs: process.env.RUNNER_OS ?? null,
runnerArch: process.env.RUNNER_ARCH ?? null
}
};
}
+95
View File
@@ -0,0 +1,95 @@
{
"settings": { "resolution.circle": 26, "resolution.curve": 39 },
"nodes": [
{ "id": 9, "position": [220, 80], "type": "max/plantarium/output", "props": {} },
{
"id": 10,
"position": [95, 80],
"type": "max/plantarium/stem",
"props": { "amount": 5, "length": 11, "thickness": 0.1 }
},
{
"id": 14,
"position": [195, 80],
"type": "max/plantarium/gravity",
"props": {
"strength": 0.38,
"scale": 39,
"fixBottom": 0,
"directionalStrength": [1, 1, 1],
"depth": 1,
"curviness": 1
}
},
{
"id": 15,
"position": [120, 80],
"type": "max/plantarium/noise",
"props": {
"strength": 4.9,
"scale": 2.2,
"fixBottom": 1,
"directionalStrength": [1, 1, 1],
"depth": 1,
"octaves": 1
}
},
{
"id": 16,
"position": [70, 80],
"type": "max/plantarium/vec3",
"props": { "0": 0, "1": 0, "2": 0 }
},
{
"id": 17,
"position": [45, 80],
"type": "max/plantarium/random",
"props": { "min": -2, "max": 2 }
},
{
"id": 18,
"position": [170, 80],
"type": "max/plantarium/branch",
"props": {
"length": 1.6,
"thickness": 0.69,
"amount": 36,
"offsetSingle": 0.5,
"lowestBranch": 0.46,
"highestBranch": 1,
"depth": 1,
"rotation": 180
}
},
{
"id": 19,
"position": [145, 80],
"type": "max/plantarium/gravity",
"props": {
"strength": 0.38,
"scale": 39,
"fixBottom": 0,
"directionalStrength": [1, 1, 1],
"depth": 1,
"curviness": 1
}
},
{
"id": 20,
"position": [70, 120],
"type": "max/plantarium/random",
"props": { "min": 0.073, "max": 0.15 }
}
],
"edges": [
[14, 0, 9, "input"],
[10, 0, 15, "plant"],
[16, 0, 10, "origin"],
[17, 0, 16, "0"],
[17, 0, 16, "2"],
[18, 0, 14, "plant"],
[15, 0, 19, "plant"],
[19, 0, 18, "plant"],
[20, 0, 10, "thickness"]
]
}
+44
View File
@@ -0,0 +1,44 @@
{
"settings": { "resolution.circle": 64, "resolution.curve": 64, "randomSeed": false },
"nodes": [
{ "id": 9, "position": [260, 0], "type": "max/plantarium/output", "props": {} },
{
"id": 18,
"position": [185, 0],
"type": "max/plantarium/stem",
"props": { "amount": 64, "length": 12, "thickness": 0.15 }
},
{
"id": 19,
"position": [210, 0],
"type": "max/plantarium/noise",
"props": { "scale": 1.3, "strength": 5.4 }
},
{
"id": 20,
"position": [235, 0],
"type": "max/plantarium/branch",
"props": { "length": 0.8, "thickness": 0.8, "amount": 3 }
},
{
"id": 21,
"position": [160, 0],
"type": "max/plantarium/vec3",
"props": { "0": 0.39, "1": 0, "2": 0.41 }
},
{
"id": 22,
"position": [130, 0],
"type": "max/plantarium/random",
"props": { "min": -2, "max": 2 }
}
],
"edges": [
[18, 0, 19, "plant"],
[19, 0, 20, "plant"],
[20, 0, 9, "input"],
[21, 0, 18, "origin"],
[22, 0, 21, "0"],
[22, 0, 21, "2"]
]
}
+71
View File
@@ -0,0 +1,71 @@
{
"settings": { "resolution.circle": 26, "resolution.curve": 39 },
"nodes": [
{ "id": 9, "position": [180, 80], "type": "max/plantarium/output", "props": {} },
{
"id": 10,
"position": [55, 80],
"type": "max/plantarium/stem",
"props": { "amount": 1, "length": 11, "thickness": 0.71 }
},
{
"id": 11,
"position": [80, 80],
"type": "max/plantarium/noise",
"props": {
"strength": 35,
"scale": 4.6,
"fixBottom": 1,
"directionalStrength": [1, 0.74, 0.083],
"depth": 1
}
},
{
"id": 12,
"position": [105, 80],
"type": "max/plantarium/branch",
"props": {
"length": 3,
"thickness": 0.6,
"amount": 10,
"rotation": 180,
"offsetSingle": 0.34,
"lowestBranch": 0.53,
"highestBranch": 1,
"depth": 1
}
},
{
"id": 13,
"position": [130, 80],
"type": "max/plantarium/noise",
"props": {
"strength": 8,
"scale": 7.7,
"fixBottom": 1,
"directionalStrength": [1, 0, 1],
"depth": 1
}
},
{
"id": 14,
"position": [155, 80],
"type": "max/plantarium/gravity",
"props": {
"strength": 0.11,
"scale": 39,
"fixBottom": 0,
"directionalStrength": [1, 1, 1],
"depth": 1,
"curviness": 1
}
}
],
"edges": [
[10, 0, 11, "plant"],
[11, 0, 12, "plant"],
[12, 0, 13, "plant"],
[13, 0, 14, "plant"],
[14, 0, 9, "input"]
]
}
+59
View File
@@ -0,0 +1,59 @@
import { expect, test } from '@playwright/test';
test('test', async ({ page }) => {
// Listen for console messages
page.on('console', msg => {
console.log(`[Browser Console] ${msg.type()}: ${msg.text()}`);
});
await page.goto('http://localhost:4173', { waitUntil: 'load' });
await page.getByRole('button', { name: 'projects' }).click();
await page.getByRole('button', { name: 'New', exact: true }).click();
await page.getByRole('combobox').selectOption('2');
await page.getByRole('textbox', { name: 'Project name' }).click();
await page.getByRole('textbox', { name: 'Project name' }).fill('Test Project');
await page.getByRole('button', { name: 'Create' }).click();
const expectedNodes = [
{
id: '10',
type: 'max/plantarium/stem',
props: {
amount: 4,
length: 4,
thickness: 0.2
}
},
{
id: '11',
type: 'max/plantarium/noise',
props: {
scale: 0.5,
strength: 5
}
},
{
id: '9',
type: 'max/plantarium/output'
}
];
for (const node of expectedNodes) {
const wrapper = page.locator(
`div.wrapper[data-node-id="${node.id}"][data-node-type="${node.type}"]`
);
await expect(wrapper).toBeVisible();
if ('props' in node) {
const props = node.props as unknown as Record<string, number>;
for (const propId in node.props) {
const expectedValue = props[propId];
const inputElement = page.locator(
`div.wrapper[data-node-type="${node.type}"][data-node-input="${propId}"] input[type="number"]`
);
const value = parseFloat(await inputElement.inputValue());
expect(value).toBe(expectedValue);
}
}
}
});
+39 -30
View File
@@ -1,57 +1,66 @@
{
"name": "@nodarium/app",
"private": true,
"version": "0.0.0",
"version": "0.0.6",
"type": "module",
"scripts": {
"dev": "vite dev",
"predev": "rm static/CHANGELOG.md && ln -s ../../CHANGELOG.md static/CHANGELOG.md",
"build": "svelte-kit sync && vite build",
"test": "vitest",
"test:unit": "vitest --browser=false",
"test": "npm run test:unit -- --run && npm run test:e2e",
"test:e2e": "playwright test",
"preview": "vite preview",
"format": "dprint fmt -c '../.dprint.jsonc' .",
"format:check": "dprint check -c '../.dprint.jsonc' .",
"lint": "eslint .",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json"
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"bench": "tsx ./benchmark/index.ts"
},
"dependencies": {
"@nodarium/planty": "workspace:*",
"@nodarium/ui": "workspace:*",
"@nodarium/utils": "workspace:*",
"@sveltejs/kit": "^2.50.0",
"@tailwindcss/vite": "^4.1.18",
"@threlte/core": "8.3.1",
"@threlte/extras": "9.7.1",
"@sveltejs/kit": "^2.59.0",
"@tailwindcss/vite": "^4.2.4",
"@threlte/core": "8.5.11",
"@threlte/extras": "9.15.1",
"comlink": "^4.4.2",
"file-saver": "^2.0.5",
"idb": "^8.0.3",
"jsondiffpatch": "^0.7.3",
"tailwindcss": "^4.1.18",
"three": "^0.182.0",
"wabt": "^1.0.39"
"micromark": "^4.0.2",
"tailwindcss": "^4.2.4",
"three": "^0.184.0"
},
"devDependencies": {
"@eslint/compat": "^2.0.2",
"@eslint/js": "^9.39.2",
"@iconify-json/tabler": "^1.2.26",
"@iconify/tailwind4": "^1.2.1",
"@nodarium/types": "workspace:",
"@eslint/compat": "^2.0.5",
"@eslint/js": "^10.0.1",
"@iconify-json/tabler": "^1.2.33",
"@iconify/tailwind4": "^1.2.3",
"@nodarium/types": "workspace:^",
"@playwright/test": "^1.59.1",
"@sveltejs/adapter-static": "^3.0.10",
"@sveltejs/vite-plugin-svelte": "^6.2.4",
"@tsconfig/svelte": "^5.0.6",
"@sveltejs/vite-plugin-svelte": "^7.0.0",
"@tsconfig/svelte": "^5.0.8",
"@types/file-saver": "^2.0.7",
"@types/three": "^0.182.0",
"dprint": "^0.51.1",
"eslint": "^9.39.2",
"eslint-plugin-svelte": "^3.14.0",
"globals": "^17.3.0",
"svelte": "^5.46.4",
"svelte-check": "^4.3.5",
"@types/three": "^0.184.0",
"@vitest/browser-playwright": "^4.1.5",
"dprint": "^0.54.0",
"eslint": "^10.3.0",
"eslint-plugin-svelte": "^3.17.1",
"globals": "^17.6.0",
"svelte": "^5.55.5",
"svelte-check": "^4.4.7",
"tslib": "^2.8.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.54.0",
"vite": "^7.3.1",
"tsx": "^4.21.0",
"typescript": "^6.0.3",
"typescript-eslint": "^8.59.1",
"vite": "^8.0.10",
"vite-plugin-comlink": "^5.3.0",
"vite-plugin-glsl": "^1.5.5",
"vite-plugin-wasm": "^3.5.0",
"vitest": "^4.0.17"
"vite-plugin-glsl": "^1.6.0",
"vite-plugin-wasm": "^3.6.0",
"vitest": "^4.1.5",
"vitest-browser-svelte": "^2.1.1"
}
}
+20
View File
@@ -0,0 +1,20 @@
import { defineConfig } from '@playwright/test';
export default defineConfig({
webServer: { command: 'pnpm build && pnpm preview', port: 4173 },
testDir: 'e2e',
use: {
browserName: 'firefox',
launchOptions: {
firefoxUserPrefs: {
// Force WebGL even without a GPU
'webgl.force-enabled': true,
'webgl.disabled': false,
// Use software rendering (Mesa) instead of hardware
'layers.acceleration.disabled': true,
'gfx.webrender.software': true,
'webgl.enable-webgl2': true
}
}
}
});
+3 -1
View File
@@ -1,8 +1,10 @@
@import "tailwindcss";
@source "../../packages/ui/**/*.svelte";
@source "../../packages/planty/src/lib/**/*.svelte";
@plugin "@iconify/tailwind4" {
prefix: "i";
icon-sets: from-folder(custom, "./src/lib/icons");
icon-sets: from-folder("custom", "./src/lib/icons");
}
body * {
+2 -1
View File
@@ -2,7 +2,8 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/svelte.svg" />
<link rel="icon" href="%sveltekit.assets%/favicon.svg" />
<meta name="color-scheme" content="light dark">
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
<title>Nodes</title>
@@ -11,6 +11,7 @@ uniform vec3 camPos;
uniform vec2 zoomLimits;
uniform vec3 backgroundColor;
uniform vec3 lineColor;
uniform int gridType; // 0 = grid lines, 1 = dots
// Anti-aliased step: threshold in the same units as `value`
float aaStep(float threshold, float value, float deriv) {
@@ -78,35 +79,51 @@ void main(void) {
float ux = (vUv.x - 0.5) * width + cx * cz;
float uy = (vUv.y - 0.5) * height - cy * cz;
// extra small grid
float m1 = grid(ux, uy, divisions * 4.0, thickness * 4.0) * 0.9;
float m2 = grid(ux, uy, divisions * 16.0, thickness * 16.0) * 0.5;
float xsmall = max(m1, m2);
if(gridType == 0) {
// extra small grid
float m1 = grid(ux, uy, divisions * 4.0, thickness * 4.0) * 0.9;
float m2 = grid(ux, uy, divisions * 16.0, thickness * 16.0) * 0.5;
float xsmall = max(m1, m2);
float s3 = circle_grid(ux, uy, cz / 1.6, 1.0) * 0.5;
xsmall = max(xsmall, s3);
float s3 = circle_grid(ux, uy, cz / 1.6, 1.0) * 0.5;
xsmall = max(xsmall, s3);
// small grid
float c1 = grid(ux, uy, divisions, thickness) * 0.6;
float c2 = grid(ux, uy, divisions * 2.0, thickness * 2.0) * 0.5;
float small = max(c1, c2);
// small grid
float c1 = grid(ux, uy, divisions, thickness) * 0.6;
float c2 = grid(ux, uy, divisions * 2.0, thickness * 2.0) * 0.5;
float small = max(c1, c2);
float s1 = circle_grid(ux, uy, cz * 10.0, 2.0) * 0.5;
small = max(small, s1);
float s1 = circle_grid(ux, uy, cz * 10.0, 2.0) * 0.5;
small = max(small, s1);
// large grid
float c3 = grid(ux, uy, divisions / 8.0, thickness / 8.0) * 0.5;
float c4 = grid(ux, uy, divisions / 2.0, thickness / 4.0) * 0.4;
float large = max(c3, c4);
// large grid
float c3 = grid(ux, uy, divisions / 8.0, thickness / 8.0) * 0.5;
float c4 = grid(ux, uy, divisions / 2.0, thickness / 4.0) * 0.4;
float large = max(c3, c4);
float s2 = circle_grid(ux, uy, cz * 20.0, 1.0) * 0.4;
large = max(large, s2);
float s2 = circle_grid(ux, uy, cz * 20.0, 1.0) * 0.4;
large = max(large, s2);
float c = mix(large, small, min(nz * 2.0 + 0.05, 1.0));
c = mix(c, xsmall, clamp((nz - 0.3) / 0.7, 0.0, 1.0));
float c = mix(large, small, min(nz * 2.0 + 0.05, 1.0));
c = mix(c, xsmall, clamp((nz - 0.3) / 0.7, 0.0, 1.0));
vec3 color = mix(backgroundColor, lineColor, c);
vec3 color = mix(backgroundColor, lineColor, c);
gl_FragColor = vec4(color, 1.0);
} else {
float large = circle_grid(ux, uy, cz * 20.0, 1.0) * 0.4;
float medium = circle_grid(ux, uy, cz * 10.0, 1.0) * 0.6;
float small = circle_grid(ux, uy, cz * 2.5, 1.0) * 0.8;
float c = mix(large, medium, min(nz * 2.0 + 0.05, 1.0));
c = mix(c, small, clamp((nz - 0.3) / 0.7, 0.0, 1.0));
vec3 color = mix(backgroundColor, lineColor, c);
gl_FragColor = vec4(color, 1.0);
}
gl_FragColor = vec4(color, 1.0);
}
@@ -1,16 +1,19 @@
<script lang="ts">
import { appSettings } from '$lib/settings/app-settings.svelte';
import { T } from '@threlte/core';
import { T, useThrelte } from '@threlte/core';
import { colors } from '../graph/colors.svelte';
import BackgroundFrag from './Background.frag';
import BackgroundVert from './Background.vert';
const { invalidate } = useThrelte();
type Props = {
minZoom: number;
maxZoom: number;
cameraPosition: [number, number, number];
width: number;
height: number;
minZoom?: number;
maxZoom?: number;
cameraPosition?: [number, number, number];
width?: number;
height?: number;
type?: 'grid' | 'dots' | 'none';
};
let {
@@ -18,14 +21,30 @@
maxZoom = 150,
cameraPosition = [0, 1, 0],
width = globalThis?.innerWidth || 100,
height = globalThis?.innerHeight || 100
height = globalThis?.innerHeight || 100,
type = 'grid'
}: Props = $props();
const typeMap = new Map([
['grid', 0],
['dots', 1],
['none', 2]
]);
const gridType = $derived(typeMap.get(type) || 0);
let bw = $derived(width / cameraPosition[2]);
let bh = $derived(height / cameraPosition[2]);
$effect(() => {
if (appSettings.value.theme) {
setTimeout(() => invalidate(), 10);
}
});
</script>
<T.Group
visible={!appSettings.value.theme.includes('contrast')}
position.x={cameraPosition[0]}
position.z={cameraPosition[1]}
position.y={-1.0}
@@ -51,6 +70,9 @@
},
dimensions: {
value: [100, 100]
},
gridType: {
value: 0
}
}}
uniforms.camPos.value={cameraPosition}
@@ -59,6 +81,7 @@
uniforms.lineColor.value={appSettings.value.theme && colors['outline']}
uniforms.zoomLimits.value={[minZoom, maxZoom]}
uniforms.dimensions.value={[width, height]}
uniforms.gridType.value={gridType}
/>
</T.Mesh>
</T.Group>
@@ -5,19 +5,33 @@
import { getGraphManager, getGraphState } from '../graph-state.svelte';
type Props = {
paddingLeft?: number;
paddingRight?: number;
paddingTop?: number;
paddingBottom?: number;
onnode: (n: NodeInstance) => void;
};
const { onnode }: Props = $props();
const padding = 10;
const {
paddingLeft = padding,
paddingRight = padding,
paddingTop = padding,
paddingBottom = padding,
onnode
}: Props = $props();
const graph = getGraphManager();
const graphState = getGraphState();
let input: HTMLInputElement;
let wrapper: HTMLDivElement;
let value = $state<string>();
let activeNodeId = $state<NodeId>();
const MENU_WIDTH = 150;
const MENU_HEIGHT = 350;
const allNodes = graphState.activeSocket
? graph.getPossibleNodes(graphState.activeSocket)
: graph.getNodeDefinitions();
@@ -79,19 +93,52 @@
}
}
function clampAddMenuPosition() {
if (!graphState.addMenuPosition) return;
const camX = graphState.cameraPosition[0];
const camY = graphState.cameraPosition[1];
const zoom = graphState.cameraPosition[2];
const halfViewportWidth = (graphState.width / 2) / zoom;
const halfViewportHeight = (graphState.height / 2) / zoom;
const halfMenuWidth = (MENU_WIDTH / 2) / zoom;
const halfMenuHeight = (MENU_HEIGHT / 2) / zoom;
const minX = camX - halfViewportWidth - halfMenuWidth + paddingLeft / zoom;
const maxX = camX + halfViewportWidth - halfMenuWidth - paddingRight / zoom;
const minY = camY - halfViewportHeight - halfMenuHeight + paddingTop / zoom;
const maxY = camY + halfViewportHeight - halfMenuHeight - paddingBottom / zoom;
const clampedX = Math.max(
minX + halfMenuWidth,
Math.min(graphState.addMenuPosition[0], maxX - halfMenuWidth)
);
const clampedY = Math.max(
minY + halfMenuHeight,
Math.min(graphState.addMenuPosition[1], maxY - halfMenuHeight)
);
if (clampedX !== graphState.addMenuPosition[0] || clampedY !== graphState.addMenuPosition[1]) {
graphState.addMenuPosition = [clampedX, clampedY];
}
}
$effect(() => {
const pos = graphState.addMenuPosition;
const zoom = graphState.cameraPosition[2];
const width = graphState.width;
const height = graphState.height;
if (pos && zoom && width && height) {
clampAddMenuPosition();
}
});
onMount(() => {
input.disabled = false;
setTimeout(() => input.focus(), 50);
const rect = wrapper.getBoundingClientRect();
const deltaY = rect.bottom - window.innerHeight;
const deltaX = rect.right - window.innerWidth;
if (deltaY > 0) {
wrapper.style.marginTop = `-${deltaY + 30}px`;
}
if (deltaX > 0) {
wrapper.style.marginLeft = `-${deltaX + 30}px`;
}
});
</script>
@@ -100,7 +147,7 @@
position.z={graphState.addMenuPosition?.[1]}
transform={false}
>
<div class="add-menu-wrapper" bind:this={wrapper}>
<div class="add-menu-wrapper">
<div class="header">
<input
id="add-menu"
@@ -136,8 +183,10 @@
activeNodeId = node.id;
}}
>
{node.id.split('/').at(-1)}
{node.meta?.title ?? node.id.split('/').at(-1)}
</div>
{:else}
<div class="no-results">No results for "{value}"</div>
{/each}
</div>
</div>
@@ -194,4 +243,11 @@
background: var(--color-layer-2);
opacity: 1;
}
.no-results {
padding: 1em 0.9em;
font-size: 0.85em;
opacity: 0.45;
font-style: italic;
}
</style>
@@ -0,0 +1,68 @@
<script lang="ts">
import { Button } from '@nodarium/ui';
import { getGraphManager } from '../graph-state.svelte';
const graph = getGraphManager();
function getGroupName(groupId: number) {
const group = graph.getGroup(groupId);
return group?.name || `Group#${groupId}`;
}
function exitToGroup(targetId?: number) {
while (graph.currentGroupId !== (targetId ?? null)) {
graph.exitGroup();
}
}
// Intermediate groups: parent stack entries that are groups (not the root graph).
const intermediateGroups = $derived(
graph.parentStack.filter(e => e.id !== graph.id)
);
</script>
<div class="shadow" class:is-inside-group={graph.isInsideGroup}></div>
{#if graph.isInsideGroup}
<div class="group-name flex gap-1 items-center">
<Button variant="ghost" size="sm" onclick={() => exitToGroup()}>Root</Button>
{#each intermediateGroups as entry (entry.id)}
<span class="i-[tabler--arrow-right]"></span>
<Button variant="ghost" size="sm" onclick={() => exitToGroup(entry.id)}>
{getGroupName(entry.id)}
</Button>
{/each}
<span class="i-[tabler--arrow-right]"></span>
<Button variant="ghost" size="sm" class="opacity-100!">
{getGroupName(graph.currentGroupId!)}
</Button>
</div>
{/if}
<style>
.shadow {
position: absolute;
top: -5px;
left: -5px;
right: calc(var(--padding-right) - 5px);
bottom: -5px;
z-index: 1;
transition: box-shadow 0.3s ease;
box-shadow: 0 0 0px 0px var(--color-layer-2) inset;
pointer-events: none;
}
.shadow.is-inside-group {
box-shadow: 0 0 0px 8px var(--color-layer-2) inset;
}
.group-name {
position: absolute;
left: calc(50% - var(--padding-right) / 2);
transition: left 0.3s ease;
top: 12px;
transform: translateX(-50%);
z-index: 1000;
}
</style>
+19 -9
View File
@@ -2,19 +2,16 @@
import { colors } from '../graph/colors.svelte';
const circleMaterial = new MeshBasicMaterial({
color: colors.edge.clone(),
color: colors.outline.clone(),
toneMapped: false
});
let lineColor = $state(colors.edge.clone().convertSRGBToLinear());
$effect.root(() => {
$effect(() => {
if (appSettings.value.theme === undefined) {
return;
}
circleMaterial.color = colors.edge.clone().convertSRGBToLinear();
lineColor = colors.edge.clone().convertSRGBToLinear();
circleMaterial.color = colors.outline.clone().convertSRGBToLinear();
});
});
@@ -35,6 +32,7 @@
import { CubicBezierCurve } from 'three/src/extras/curves/CubicBezierCurve.js';
import { Vector2 } from 'three/src/math/Vector2.js';
import { getGraphState } from '../graph-state.svelte';
import MeshGradientLineMaterial from './MeshGradientLine/MeshGradientLineMaterial.svelte';
const graphState = getGraphState();
@@ -45,12 +43,17 @@
y2: number;
z: number;
id?: string;
inputType?: string;
outputType?: string;
};
const { x1, y1, x2, y2, z, id }: Props = $props();
const { x1, y1, x2, y2, z, inputType = 'unknown', outputType = 'unknown', id }: Props = $props();
const thickness = $derived(Math.max(0.001, 0.00082 * Math.exp(0.055 * z)));
const inputColor = $derived(graphState.colors.getColor(inputType));
const outputColor = $derived(graphState.colors.getColor(outputType));
let points = $state<Vector3[]>([]);
let lastId: string | null = null;
@@ -106,9 +109,9 @@
position.z={y1}
position.y={0.8}
rotation.x={-Math.PI / 2}
material={circleMaterial}
>
<T.CircleGeometry args={[0.5, 16]} />
<T.MeshBasicMaterial color={inputColor} toneMapped={false} />
</T.Mesh>
<T.Mesh
@@ -119,6 +122,7 @@
material={circleMaterial}
>
<T.CircleGeometry args={[0.5, 16]} />
<T.MeshBasicMaterial color={outputColor} toneMapped={false} />
</T.Mesh>
{#if graphState.hoveredEdgeId === id}
@@ -126,7 +130,8 @@
<MeshLineGeometry {points} />
<MeshLineMaterial
width={thickness * 5}
color={lineColor}
color={inputColor}
tonemapped={false}
opacity={0.5}
transparent
/>
@@ -135,5 +140,10 @@
<T.Mesh position.x={x1} position.z={y1} position.y={0.1}>
<MeshLineGeometry {points} />
<MeshLineMaterial width={thickness} color={lineColor} />
<MeshGradientLineMaterial
width={thickness}
colorStart={inputColor}
colorEnd={outputColor}
tonemapped={false}
/>
</T.Mesh>
@@ -0,0 +1,112 @@
<script lang="ts">
import { T, useThrelte } from '@threlte/core';
import { Color, ShaderMaterial, Vector2 } from 'three';
import fragmentShader from './fragment.frag';
import type { MeshLineMaterialProps } from './types';
import vertexShader from './vertex.vert';
let {
opacity = 1,
colorStart = '#ffffff',
colorEnd = '#ffffff',
dashOffset = 0,
dashArray = 0,
dashRatio = 0,
attenuate = true,
width = 1,
scaleDown = 0,
alphaMap,
ref = $bindable(),
children,
...props
}: MeshLineMaterialProps = $props();
let { invalidate, size } = useThrelte();
// svelte-ignore state_referenced_locally
const uniforms = {
lineWidth: { value: width },
colorStart: { value: new Color(colorStart) },
colorEnd: { value: new Color(colorEnd) },
opacity: { value: opacity },
resolution: { value: new Vector2(1, 1) },
sizeAttenuation: { value: attenuate ? 1 : 0 },
dashArray: { value: dashArray },
useDash: { value: dashArray > 0 ? 1 : 0 },
dashOffset: { value: dashOffset },
dashRatio: { value: dashRatio },
scaleDown: { value: scaleDown / 10 },
alphaTest: { value: 0 },
alphaMap: { value: alphaMap },
useAlphaMap: { value: alphaMap ? 1 : 0 }
};
const material = new ShaderMaterial({ uniforms });
$effect.pre(() => {
uniforms.lineWidth.value = width;
invalidate();
});
$effect.pre(() => {
uniforms.opacity.value = opacity;
invalidate();
});
$effect.pre(() => {
uniforms.resolution.value.set($size.width, $size.height);
invalidate();
});
$effect.pre(() => {
uniforms.sizeAttenuation.value = attenuate ? 1 : 0;
invalidate();
});
$effect.pre(() => {
uniforms.dashArray.value = dashArray;
uniforms.useDash.value = dashArray > 0 ? 1 : 0;
invalidate();
});
$effect.pre(() => {
uniforms.dashOffset.value = dashOffset;
invalidate();
});
$effect.pre(() => {
uniforms.dashRatio.value = dashRatio;
invalidate();
});
$effect.pre(() => {
uniforms.scaleDown.value = scaleDown / 10;
invalidate();
});
$effect.pre(() => {
uniforms.alphaMap.value = alphaMap;
uniforms.useAlphaMap.value = alphaMap ? 1 : 0;
invalidate();
});
$effect.pre(() => {
uniforms.colorStart.value.set(colorStart);
invalidate();
});
$effect.pre(() => {
uniforms.colorEnd.value.set(colorEnd);
invalidate();
});
</script>
<T
is={material}
bind:ref
{fragmentShader}
{vertexShader}
{...props}
>
{@render children?.({ ref: material })}
</T>
@@ -0,0 +1,30 @@
uniform vec3 colorStart;
uniform vec3 colorEnd;
uniform float useDash;
uniform float dashArray;
uniform float dashOffset;
uniform float dashRatio;
uniform sampler2D alphaMap;
uniform float useAlphaMap;
varying vec2 vUV;
varying vec4 vColor;
varying float vCounters;
vec4 CustomLinearTosRGB( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}
void main() {
vec4 c = mix(vec4(colorStart,1.0),vec4(colorEnd, 1.0), vCounters);
if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV ).r;
if( useDash == 1. ){
c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));
}
gl_FragColor = CustomLinearTosRGB(c);
}
@@ -0,0 +1,68 @@
import type { Props } from '@threlte/core';
import type { BufferGeometry, Vector3 } from 'three';
import type { ColorRepresentation, ShaderMaterial, Texture } from 'three';
export type MeshLineGeometryProps = Props<BufferGeometry> & {
/**
* @default []
*/
points: Vector3[];
/**
* @default 'none'
*/
shape?: 'none' | 'taper' | 'custom';
/**
* @default () => 1
*/
shapeFunction?: (p: number) => number;
};
export type MeshLineMaterialProps =
& Omit<
Props<ShaderMaterial>,
'uniforms' | 'fragmentShader' | 'vertexShader'
>
& {
/**
* @default 1
*/
opacity?: number;
/**
* @default '#ffffff'
*/
color?: ColorRepresentation;
/**
* @default 0
*/
dashOffset?: number;
/**
* @default 0
*/
dashArray?: number;
/**
* @default 0
*/
dashRatio?: number;
/**
* @default true
*/
attenuate?: boolean;
/**
* @default 1
*/
width?: number;
/**
* @default 0
*/
scaleDown?: number;
alphaMap?: Texture | undefined;
};
@@ -0,0 +1,83 @@
attribute vec3 previous;
attribute vec3 next;
attribute float side;
attribute float width;
attribute float counters;
uniform vec2 resolution;
uniform float lineWidth;
uniform vec3 color;
uniform float opacity;
uniform float sizeAttenuation;
uniform float scaleDown;
varying vec2 vUV;
varying vec4 vColor;
varying float vCounters;
vec2 intoScreen(vec4 i) {
return resolution * (0.5 * i.xy / i.w + 0.5);
}
void main() {
float aspect = resolution.y / resolution.x;
mat4 m = projectionMatrix * modelViewMatrix;
vec4 currentClip = m * vec4( position, 1.0 );
vec4 prevClip = m * vec4( previous, 1.0 );
vec4 nextClip = m * vec4( next, 1.0 );
vec4 currentNormed = currentClip / currentClip.w;
vec4 prevNormed = prevClip / prevClip.w;
vec4 nextNormed = nextClip / nextClip.w;
vec2 currentScreen = intoScreen(currentNormed);
vec2 prevScreen = intoScreen(prevNormed);
vec2 nextScreen = intoScreen(nextNormed);
float actualWidth = lineWidth * width;
vec2 dir;
if(nextScreen == currentScreen) {
dir = normalize( currentScreen - prevScreen );
} else if(prevScreen == currentScreen) {
dir = normalize( nextScreen - currentScreen );
} else {
vec2 inDir = currentScreen - prevScreen;
vec2 outDir = nextScreen - currentScreen;
vec2 fullDir = nextScreen - prevScreen;
if(length(fullDir) > 0.0) {
dir = normalize(fullDir);
} else if(length(inDir) > 0.0){
dir = normalize(inDir);
} else {
dir = normalize(outDir);
}
}
vec2 normal = vec2(-dir.y, dir.x);
if(sizeAttenuation != 0.0) {
normal /= currentClip.w;
normal *= min(resolution.x, resolution.y);
}
if (scaleDown > 0.0) {
float dist = length(nextNormed - prevNormed);
normal *= smoothstep(0.0, scaleDown, dist);
}
vec2 offsetInScreen = actualWidth * normal * side * 0.5;
vec2 withOffsetScreen = currentScreen + offsetInScreen;
vec3 withOffsetNormed = vec3((2.0 * withOffsetScreen/resolution - 1.0), currentNormed.z);
vCounters = counters;
vColor = vec4( color, opacity );
vUV = uv;
gl_Position = currentClip.w * vec4(withOffsetNormed, 1.0);
}
@@ -0,0 +1,407 @@
import { assert, describe, expect, it } from 'vitest';
import { GraphManager } from './graph-manager.svelte';
import {
createMockNodeRegistry,
mockFloatInputNode,
mockFloatOutputNode,
mockGeometryOutputNode,
mockPathInputNode,
mockVec3OutputNode
} from './test-utils';
describe('groupNodes', () => {
it('should not do anything if no nodes are selected', () => {
const registry = createMockNodeRegistry([
mockFloatOutputNode,
mockFloatInputNode,
mockGeometryOutputNode,
mockPathInputNode
]);
const manager = new GraphManager(registry);
const floatInputNode = manager.createNode({
type: 'test/node/input',
position: [100, 100],
props: {}
});
assert.isDefined(floatInputNode);
const floatOutputNode = manager.createNode({
type: 'test/node/output',
position: [0, 0],
props: {}
});
assert.isDefined(floatOutputNode);
const edge = manager.createEdge(floatInputNode, 0, floatOutputNode, 'input');
assert.isDefined(edge);
manager.save();
manager.groupNodes([]);
const graph = manager.serialize();
expect(graph.nodes.length).toBe(2);
expect(graph.edges.length).toBe(1);
expect(graph.groups.length).toBe(0);
});
it('should group selected nodes and create a group node', () => {
const registry = createMockNodeRegistry([
mockFloatOutputNode,
mockFloatInputNode,
mockGeometryOutputNode,
mockPathInputNode
]);
const manager = new GraphManager(registry);
const floatInputNode = manager.createNode({
type: 'test/node/input',
position: [100, 100],
props: {}
});
assert.isDefined(floatInputNode);
const floatOutputNode = manager.createNode({
type: 'test/node/output',
position: [0, 0],
props: {}
});
assert.isDefined(floatOutputNode);
const edge = manager.createEdge(floatInputNode, 0, floatOutputNode, 'input');
assert.isDefined(edge);
manager.save();
const groupNode = manager.groupNodes([floatInputNode.id]);
assert.isDefined(groupNode);
const graph = manager.serialize();
expect(graph.nodes.map(n => n.id), 'graph to contain group node').to.contain(groupNode.id);
expect(graph.groups[0].nodes.map(n => n.id), 'group graph to contain float node').to.contain(
floatInputNode.id
);
expect(graph.nodes.map(n => n.id)).not.to.contain(floatInputNode.id);
expect(graph.nodes.length).toBe(2);
expect(graph.edges.length).toBe(1);
expect(graph.groups.length).toBe(1);
});
it('should rewire external edges when grouping a middle node in a chain', () => {
const registry = createMockNodeRegistry([mockFloatOutputNode, mockFloatInputNode]);
const manager = new GraphManager(registry);
// A → B → C (float chain: output → middle → input)
const nodeA = manager.createNode({ type: 'test/node/output', position: [0, 0], props: {} });
const nodeB = manager.createNode({ type: 'test/node/output', position: [100, 0], props: {} });
const nodeC = manager.createNode({ type: 'test/node/input', position: [200, 0], props: {} });
assert.isDefined(nodeA);
assert.isDefined(nodeB);
assert.isDefined(nodeC);
manager.createEdge(nodeA, 0, nodeB, 'input');
manager.createEdge(nodeB, 0, nodeC, 'value');
const groupNode = manager.groupNodes([nodeB.id]);
assert.isDefined(groupNode);
const graph = manager.serialize();
// Top-level: A, C, groupNode — B is gone
expect(graph.nodes.length, 'top-level node count').toBe(3);
const topLevelIds = graph.nodes.map(n => n.id);
expect(topLevelIds).toContain(nodeA.id);
expect(topLevelIds).toContain(nodeC.id);
expect(topLevelIds).toContain(groupNode.id);
expect(topLevelIds).not.toContain(nodeB.id);
// Both original edges survive, now routing through the group node
expect(graph.edges.length, 'edge count unchanged').toBe(2);
const edgeSources = graph.edges.map(e => e[0]);
const edgeTargets = graph.edges.map(e => e[2]);
expect(edgeTargets).toContain(groupNode.id); // A → groupNode
expect(edgeSources).toContain(groupNode.id); // groupNode → C
// One group definition was created
expect(graph.groups.length).toBe(1);
const group = graph.groups[0];
// Group contains B plus the two boundary nodes
const groupNodeIds = group.nodes.map(n => n.id);
expect(groupNodeIds).toContain(nodeB.id);
const inputBoundary = group.nodes.find(n => n.type === '__internal/group/input');
const outputBoundary = group.nodes.find(n => n.type === '__internal/group/output');
expect(inputBoundary, 'group input boundary node').toBeDefined();
expect(outputBoundary, 'group output boundary node').toBeDefined();
// Group declares one input slot and one output slot
expect(Object.keys(group.inputs ?? {}).length, 'group input count').toBe(1);
expect(group.outputs?.length, 'group output count').toBe(1);
// Internal edges wire: inputBoundary → B → outputBoundary
expect(group.edges.length, 'internal edge count').toBe(2);
const internalSources = group.edges.map(e => e[0]);
const internalTargets = group.edges.map(e => e[2]);
expect(internalTargets).toContain(nodeB.id);
expect(internalSources).toContain(nodeB.id);
});
});
describe('getPossibleSockets', () => {
describe('when dragging an output socket', () => {
it('should return compatible input sockets based on type', () => {
const registry = createMockNodeRegistry([
mockFloatOutputNode,
mockFloatInputNode,
mockGeometryOutputNode,
mockPathInputNode
]);
const manager = new GraphManager(registry);
const floatInputNode = manager.createNode({
type: 'test/node/input',
position: [100, 100],
props: {}
});
const floatOutputNode = manager.createNode({
type: 'test/node/output',
position: [0, 0],
props: {}
});
expect(floatInputNode).toBeDefined();
expect(floatOutputNode).toBeDefined();
const possibleSockets = manager.getPossibleSockets({
node: floatOutputNode!,
index: 0,
position: [0, 0]
});
expect(possibleSockets.length).toBe(1);
const socketNodeIds = possibleSockets.map(([node]) => node.id);
expect(socketNodeIds).toContain(floatInputNode!.id);
});
it('should exclude self node from possible sockets', () => {
const registry = createMockNodeRegistry([
mockFloatOutputNode,
mockFloatInputNode
]);
const manager = new GraphManager(registry);
const floatInputNode = manager.createNode({
type: 'test/node/input',
position: [100, 100],
props: {}
});
expect(floatInputNode).toBeDefined();
const possibleSockets = manager.getPossibleSockets({
node: floatInputNode!,
index: 'value',
position: [0, 0]
});
const socketNodeIds = possibleSockets.map(([node]) => node.id);
expect(socketNodeIds).not.toContain(floatInputNode!.id);
});
it('should exclude parent nodes from possible sockets when dragging output', () => {
const registry = createMockNodeRegistry([
mockFloatOutputNode,
mockFloatInputNode
]);
const manager = new GraphManager(registry);
const parentNode = manager.createNode({
type: 'test/node/output',
position: [0, 0],
props: {}
});
const childNode = manager.createNode({
type: 'test/node/input',
position: [100, 100],
props: {}
});
expect(parentNode).toBeDefined();
expect(childNode).toBeDefined();
if (parentNode && childNode) {
manager.createEdge(parentNode, 0, childNode, 'value');
}
const possibleSockets = manager.getPossibleSockets({
node: parentNode!,
index: 0,
position: [0, 0]
});
const socketNodeIds = possibleSockets.map(([node]) => node.id);
expect(socketNodeIds).not.toContain(childNode!.id);
});
it('should return sockets compatible with accepts property', () => {
const registry = createMockNodeRegistry([
mockGeometryOutputNode,
mockPathInputNode
]);
const manager = new GraphManager(registry);
const geometryOutputNode = manager.createNode({
type: 'test/node/geometry',
position: [0, 0],
props: {}
});
const pathInputNode = manager.createNode({
type: 'test/node/path',
position: [100, 100],
props: {}
});
expect(geometryOutputNode).toBeDefined();
expect(pathInputNode).toBeDefined();
const possibleSockets = manager.getPossibleSockets({
node: geometryOutputNode!,
index: 0,
position: [0, 0]
});
const socketNodeIds = possibleSockets.map(([node]) => node.id);
expect(socketNodeIds).toContain(pathInputNode!.id);
});
it('should return empty array when no compatible sockets exist', () => {
const registry = createMockNodeRegistry([
mockVec3OutputNode,
mockFloatInputNode
]);
const manager = new GraphManager(registry);
const vec3OutputNode = manager.createNode({
type: 'test/node/vec3',
position: [0, 0],
props: {}
});
const floatInputNode = manager.createNode({
type: 'test/node/input',
position: [100, 100],
props: {}
});
expect(vec3OutputNode).toBeDefined();
expect(floatInputNode).toBeDefined();
const possibleSockets = manager.getPossibleSockets({
node: vec3OutputNode!,
index: 0,
position: [0, 0]
});
const socketNodeIds = possibleSockets.map(([node]) => node.id);
expect(socketNodeIds).not.toContain(floatInputNode!.id);
expect(possibleSockets.length).toBe(0);
});
it('should return socket info with correct socket key for inputs', () => {
const registry = createMockNodeRegistry([
mockFloatOutputNode,
mockFloatInputNode
]);
const manager = new GraphManager(registry);
const floatOutputNode = manager.createNode({
type: 'test/node/output',
position: [0, 0],
props: {}
});
const floatInputNode = manager.createNode({
type: 'test/node/input',
position: [100, 100],
props: {}
});
expect(floatOutputNode).toBeDefined();
expect(floatInputNode).toBeDefined();
const possibleSockets = manager.getPossibleSockets({
node: floatOutputNode!,
index: 0,
position: [0, 0]
});
const matchingSocket = possibleSockets.find(([node]) => node.id === floatInputNode!.id);
expect(matchingSocket).toBeDefined();
expect(matchingSocket![1]).toBe('value');
});
it('should return multiple compatible sockets', () => {
const registry = createMockNodeRegistry([
mockFloatOutputNode,
mockFloatInputNode,
mockGeometryOutputNode,
mockPathInputNode
]);
const manager = new GraphManager(registry);
const floatOutputNode = manager.createNode({
type: 'test/node/output',
position: [0, 0],
props: {}
});
const geometryOutputNode = manager.createNode({
type: 'test/node/geometry',
position: [200, 0],
props: {}
});
const floatInputNode = manager.createNode({
type: 'test/node/input',
position: [100, 100],
props: {}
});
const pathInputNode = manager.createNode({
type: 'test/node/path',
position: [300, 100],
props: {}
});
expect(floatOutputNode).toBeDefined();
expect(geometryOutputNode).toBeDefined();
expect(floatInputNode).toBeDefined();
expect(pathInputNode).toBeDefined();
const possibleSocketsForFloat = manager.getPossibleSockets({
node: floatOutputNode!,
index: 0,
position: [0, 0]
});
expect(possibleSocketsForFloat.length).toBe(1);
expect(possibleSocketsForFloat.map(([n]) => n.id)).toContain(floatInputNode!.id);
});
});
});
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,262 @@
import { assert, describe, expect, it } from 'vitest';
import { GraphManager } from './graph-manager.svelte';
import { GraphState } from './graph-state.svelte';
import { createMockNodeRegistry, mockFloatInputNode, mockFloatOutputNode } from './test-utils';
// GraphState constructor reads localStorage synchronously — mock before any instantiation
Object.defineProperty(globalThis, 'localStorage', {
value: {
getItem: () => null,
setItem: () => {},
removeItem: () => {},
clear: () => {},
length: 0,
key: () => null
} as Storage,
writable: true,
configurable: true
});
function createFixture() {
const registry = createMockNodeRegistry([mockFloatOutputNode, mockFloatInputNode]);
const manager = new GraphManager(registry);
const state = new GraphState(manager);
return { manager, state };
}
describe('clearSelection', () => {
it('empties selectedNodes', () => {
const { state } = createFixture();
state.selectedNodes.add(1);
state.selectedNodes.add(2);
state.clearSelection();
expect(state.selectedNodes.size).toBe(0);
});
});
describe('projectScreenToWorld', () => {
it('maps the viewport centre to the camera position', () => {
const { state } = createFixture();
// cameraPosition default: [140, 100, 3.5], width=100, height=100
state.width = 100;
state.height = 100;
state.cameraPosition = [140, 100, 3.5];
const [wx, wy] = state.projectScreenToWorld(50, 50);
expect(wx).toBeCloseTo(140);
expect(wy).toBeCloseTo(100);
});
it('offsets correctly for a point not at centre', () => {
const { state } = createFixture();
state.width = 100;
state.height = 100;
state.cameraPosition = [0, 0, 2];
const [wx, wy] = state.projectScreenToWorld(100, 50);
// x: 0 + (100 - 50) / 2 = 25
expect(wx).toBeCloseTo(25);
expect(wy).toBeCloseTo(0);
});
});
describe('groupSelectedNodes', () => {
it('delegates to graph.groupNodes with selected IDs and activeNodeId', () => {
const { manager, state } = createFixture();
const nodeA = manager.createNode({ type: 'test/node/output', position: [0, 0], props: {} });
const nodeB = manager.createNode({ type: 'test/node/input', position: [100, 0], props: {} });
assert.isDefined(nodeA);
assert.isDefined(nodeB);
state.selectedNodes.add(nodeA!.id);
state.activeNodeId = nodeB!.id;
const groupNode = state.groupSelectedNodes();
assert.isDefined(groupNode);
const graph = manager.serialize();
expect(graph.groups.length).toBe(1);
expect(graph.nodes.map(n => n.id)).toContain(groupNode!.id);
});
it('works when only activeNodeId is set with no extra selection', () => {
const { manager, state } = createFixture();
const nodeA = manager.createNode({ type: 'test/node/output', position: [0, 0], props: {} });
assert.isDefined(nodeA);
state.activeNodeId = nodeA!.id;
const groupNode = state.groupSelectedNodes();
assert.isDefined(groupNode);
expect(manager.groups.length).toBe(1);
});
});
describe('enterGroupNode', () => {
it('does nothing when activeNodeId is -1', () => {
const { manager, state } = createFixture();
state.activeNodeId = -1;
state.enterGroupNode();
expect(manager.parentStack.length).toBe(0);
});
it('does nothing when the active node is not a group instance', () => {
const { manager, state } = createFixture();
const node = manager.createNode({ type: 'test/node/output', position: [0, 0], props: {} });
assert.isDefined(node);
state.activeNodeId = node!.id;
state.enterGroupNode();
expect(manager.parentStack.length).toBe(0);
});
it('enters the group, pushes graphStack, and clears UI state', () => {
const { manager, state } = createFixture();
const nodeA = manager.createNode({ type: 'test/node/output', position: [0, 0], props: {} });
assert.isDefined(nodeA);
const groupNode = manager.groupNodes([nodeA!.id]);
assert.isDefined(groupNode);
state.selectedNodes.add(nodeA!.id);
state.activeNodeId = groupNode!.id;
state.cameraPosition = [10, 20, 5];
state.enterGroupNode();
expect(manager.parentStack.length).toBe(1);
expect(state.activeNodeId).toBe(-1);
expect(state.selectedNodes.size).toBe(0);
expect(manager.isInsideGroup).toBe(true);
});
});
describe('exitGroupNode', () => {
it('does nothing when not inside a group', () => {
const { manager, state } = createFixture();
const before = [...state.cameraPosition];
state.exitGroupNode();
expect(manager.parentStack.length).toBe(0);
expect(state.cameraPosition).toEqual(before);
});
it('clears activeNodeId and selection after exit', () => {
const { manager, state } = createFixture();
const nodeA = manager.createNode({ type: 'test/node/output', position: [0, 0], props: {} });
assert.isDefined(nodeA);
const groupNode = manager.groupNodes([nodeA!.id]);
assert.isDefined(groupNode);
state.activeNodeId = groupNode!.id;
state.enterGroupNode();
state.activeNodeId = 99;
state.selectedNodes.add(99);
state.exitGroupNode();
// Group instance node is re-selected on exit; internal selection is cleared
expect(state.activeNodeId).toBe(groupNode!.id);
expect(state.selectedNodes.size).toBe(0);
});
it('restores outer nodes to manager after exit', () => {
const { manager, state } = createFixture();
const nodeA = manager.createNode({ type: 'test/node/output', position: [0, 0], props: {} });
const nodeB = manager.createNode({ type: 'test/node/input', position: [100, 0], props: {} });
assert.isDefined(nodeA);
assert.isDefined(nodeB);
manager.createEdge(nodeA!, 0, nodeB!, 'value');
const groupNode = manager.groupNodes([nodeA!.id]);
assert.isDefined(groupNode);
state.activeNodeId = groupNode!.id;
state.enterGroupNode();
// Inside the group: nodeA is an internal node so it IS active; the outer
// nodes (nodeB, groupNode) are saved and no longer in the active Map.
expect(manager.nodes.has(nodeA!.id)).toBe(true);
expect(manager.nodes.has(nodeB!.id)).toBe(false);
state.exitGroupNode();
// After exit: outer nodes are restored
expect(manager.nodes.has(nodeB!.id)).toBe(true);
expect(manager.nodes.has(groupNode!.id)).toBe(true);
expect(manager.isInsideGroup).toBe(false);
});
it('isInsideGroup is false after exiting the only group level', () => {
const { manager, state } = createFixture();
const nodeA = manager.createNode({ type: 'test/node/output', position: [0, 0], props: {} });
assert.isDefined(nodeA);
const groupNode = manager.groupNodes([nodeA!.id]);
assert.isDefined(groupNode);
state.activeNodeId = groupNode!.id;
state.enterGroupNode();
expect(manager.isInsideGroup).toBe(true);
state.exitGroupNode();
expect(manager.isInsideGroup).toBe(false);
});
});
describe('copyNodes / pasteNodes', () => {
it('copies the active node into the clipboard', () => {
const { manager, state } = createFixture();
const node = manager.createNode({ type: 'test/node/output', position: [10, 20], props: {} });
assert.isDefined(node);
state.activeNodeId = node!.id;
state.mousePosition = [0, 0];
state.copyNodes();
assert.isNotNull(state.clipboard);
expect(state.clipboard!.nodes.map(n => n.id)).toContain(node!.id);
});
it('includes edges between copied nodes', () => {
const { manager, state } = createFixture();
const nodeA = manager.createNode({ type: 'test/node/output', position: [0, 0], props: {} });
const nodeB = manager.createNode({ type: 'test/node/input', position: [100, 0], props: {} });
assert.isDefined(nodeA);
assert.isDefined(nodeB);
manager.createEdge(nodeA!, 0, nodeB!, 'value');
state.activeNodeId = nodeA!.id;
state.selectedNodes.add(nodeB!.id);
state.mousePosition = [0, 0];
state.copyNodes();
assert.isNotNull(state.clipboard);
expect(state.clipboard!.edges.length).toBe(1);
});
it('pastes nodes and adds them to the graph', () => {
const { manager, state } = createFixture();
const node = manager.createNode({ type: 'test/node/output', position: [10, 20], props: {} });
assert.isDefined(node);
state.activeNodeId = node!.id;
state.mousePosition = [0, 0];
state.copyNodes();
const countBefore = manager.nodes.size;
state.mousePosition = [50, 50];
state.pasteNodes();
expect(manager.nodes.size).toBe(countBefore + 1);
});
it('does nothing when clipboard is empty', () => {
const { manager, state } = createFixture();
manager.createNode({ type: 'test/node/output', position: [0, 0], props: {} });
const countBefore = manager.nodes.size;
state.pasteNodes();
expect(manager.nodes.size).toBe(countBefore);
});
});
+154 -70
View File
@@ -1,8 +1,16 @@
import type { NodeInstance, Socket } from '@nodarium/types';
import { animate, lerp } from '$lib/helpers';
import type { NodeInstance, SerializedEdge, SerializedNode, Socket } from '@nodarium/types';
import { getContext, setContext } from 'svelte';
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
import type { OrthographicCamera, Vector3 } from 'three';
import type { GraphManager } from './graph-manager.svelte';
import { ColorGenerator } from './graph/colors';
import {
getNodeHeight,
getParameterHeight,
serializeEdge,
serializeNode
} from './helpers/nodeHelpers';
const graphStateKey = Symbol('graph-state');
export function getGraphState() {
@@ -27,7 +35,32 @@ type EdgeData = {
points: Vector3[];
};
const predefinedColors = {
path: {
hue: 80,
lightness: 20,
saturation: 80
},
float: {
hue: 70,
lightness: 10,
saturation: 0
},
geometry: {
hue: 0,
lightness: 50,
saturation: 70
},
'*': {
hue: 200,
lightness: 20,
saturation: 100
}
} as const;
export class GraphState {
colors = new ColorGenerator(predefinedColors);
constructor(private graph: GraphManager) {
$effect.root(() => {
$effect(() => {
@@ -67,8 +100,8 @@ export class GraphState {
cameraPosition: [number, number, number] = $state([140, 100, 3.5]);
clipboard: null | {
nodes: NodeInstance[];
edges: [number, number, number, string][];
nodes: SerializedNode[];
edges: SerializedEdge[];
} = null;
cameraBounds = $derived([
@@ -83,7 +116,7 @@ export class GraphState {
addMenuPosition = $state<[number, number] | null>(null);
snapToGrid = $state(false);
showGrid = $state(true);
backgroundType = $state<'grid' | 'dots' | 'none'>('grid');
showHelp = $state(false);
cameraDown = [0, 0];
@@ -97,6 +130,9 @@ export class GraphState {
activeNodeId = $state(-1);
selectedNodes = new SvelteSet<number>();
activeSocket = $state<Socket | null>(null);
safePadding = $state<{ left?: number; right?: number; bottom?: number; top?: number } | null>(
null
);
hoveredSocket = $state<Socket | null>(null);
possibleSockets = $state<Socket[]>([]);
possibleSocketIds = $derived(
@@ -121,10 +157,6 @@ export class GraphState {
this.edges.delete(edgeId);
}
getEdgeData() {
return this.edges;
}
updateNodePosition(node: NodeInstance) {
if (
node.state.x === node.position[0]
@@ -159,56 +191,14 @@ export class GraphState {
return 1;
}
getSocketPosition(
node: NodeInstance,
index: string | number
): [number, number] {
if (typeof index === 'number') {
return [
(node?.state?.x ?? node.position[0]) + 20,
(node?.state?.y ?? node.position[1]) + 2.5 + 10 * index
];
} else {
const _index = Object.keys(node.state?.type?.inputs || {}).indexOf(index);
return [
node?.state?.x ?? node.position[0],
(node?.state?.y ?? node.position[1]) + 10 + 10 * _index
];
}
}
private nodeHeightCache: Record<string, number> = {};
getNodeHeight(nodeTypeId: string) {
if (nodeTypeId in this.nodeHeightCache) {
return this.nodeHeightCache[nodeTypeId];
}
const node = this.graph.getNodeType(nodeTypeId);
if (!node?.inputs) {
return 5;
}
const height = 5
+ 10
* Object.keys(node.inputs).filter(
(p) =>
p !== 'seed'
&& node?.inputs
&& !(node?.inputs?.[p] !== undefined && 'setting' in node.inputs[p])
&& node.inputs[p].hidden !== true
).length;
this.nodeHeightCache[nodeTypeId] = height;
return height;
}
copyNodes() {
if (this.activeNodeId === -1 && !this.selectedNodes?.size) {
return;
}
let nodes = [
this.activeNodeId,
...(this.selectedNodes?.values() || [])
]
const ids = new SvelteSet([this.activeNodeId, ...(this.selectedNodes?.values() || [])]);
let nodes = [...ids]
.map((id) => this.graph.getNode(id))
.filter(b => !!b);
.filter((b): b is NodeInstance => !!b);
const edges = this.graph.getEdgesBetweenNodes(nodes);
nodes = nodes.map((node) => ({
@@ -216,26 +206,67 @@ export class GraphState {
position: [
this.mousePosition[0] - node.position[0],
this.mousePosition[1] - node.position[1]
],
tmp: undefined
]
}));
this.clipboard = {
nodes: nodes,
edges: edges
nodes: nodes.map(n => serializeNode(n)),
edges: edges.map(e => serializeEdge(e))
};
}
unGroupSelectedNodes() {
return this.graph.ungroupNode(this.activeNodeId);
}
groupSelectedNodes() {
return this.graph.groupNodes([...this.selectedNodes.keys(), this.activeNodeId]);
}
centerNode(node?: NodeInstance) {
const average = [0, 0, 4];
if (node) {
average[0] = node.position[0] + (this.safePadding?.right || 0) / 10;
average[1] = node.position[1];
average[2] = 10;
} else {
for (const node of this.graph.nodes.values()) {
average[0] += node.position[0];
average[1] += node.position[1];
}
average[0] = (average[0] / this.graph.nodes.size)
+ (this.safePadding?.right || 0) / (average[2] * 2);
average[1] /= this.graph.nodes.size;
}
const camX = this.cameraPosition[0];
const camY = this.cameraPosition[1];
const camZ = this.cameraPosition[2];
const ease = (t: number) => (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t);
const easeZoom = (t: number) => t * t * (3 - 2 * t);
animate(500, (a: number) => {
this.cameraPosition[0] = lerp(camX, average[0], ease(a));
this.cameraPosition[1] = lerp(camY, average[1], ease(a));
this.cameraPosition[2] = lerp(camZ, average[2], easeZoom(a));
if (this.mouseDown) return false;
});
}
pasteNodes() {
if (!this.clipboard) return;
const nodes = this.clipboard.nodes
.map((node) => {
node.position[0] = this.mousePosition[0] - node.position[0];
node.position[1] = this.mousePosition[1] - node.position[1];
return node;
})
.filter(Boolean) as NodeInstance[];
// Create fresh node objects — never mutate clipboard so repeat pastes work correctly.
// State is also spread (with cleared parents/children) so createGraph's mutations
// don't corrupt the clipboard's stored state references.
const nodes = this.clipboard.nodes.map((node) => ({
...node,
position: [
this.mousePosition[0] - node.position[0],
this.mousePosition[1] - node.position[1]
] as [number, number]
}));
const newNodes = this.graph.createGraph(nodes, this.clipboard.edges);
this.selectedNodes.clear();
@@ -313,7 +344,8 @@ export class GraphState {
for (const node of this.graph.nodes.values()) {
const x = node.position[0];
const y = node.position[1];
const height = this.getNodeHeight(node.type);
const nodeType = this.graph.getNodeType(node);
const height = nodeType ? getNodeHeight(nodeType) : 20;
if (downX > x && downX < x + 20 && downY > y && downY < y + height) {
clickedNodeId = node.id;
break;
@@ -325,17 +357,69 @@ export class GraphState {
}
isNodeInView(node: NodeInstance) {
const height = this.getNodeHeight(node.type);
if (!node) return false;
const height = getNodeHeight(this.graph.getNodeType(node)!);
const width = 20;
return (
node.position[0] > this.cameraBounds[0] - width
return node.position[0] > this.cameraBounds[0] - width
&& node.position[0] < this.cameraBounds[1]
&& node.position[1] > this.cameraBounds[2] - height
&& node.position[1] < this.cameraBounds[3]
);
&& node.position[1] < this.cameraBounds[3];
}
openNodePalette() {
this.addMenuPosition = [this.mousePosition[0], this.mousePosition[1]];
}
enterGroupNode() {
if (this.activeNodeId === -1) return;
const node = this.graph.getNode(this.activeNodeId);
if (!node || node.type !== '__internal/group/instance') return;
const ok = this.graph.enterGroup(this.activeNodeId);
if (ok) {
this.activeNodeId = -1;
this.clearSelection();
}
}
exitGroupNode() {
const result = this.graph.exitGroup();
if (!result) return;
this.activeNodeId = result.nodeId;
this.clearSelection();
}
getSocketPosition(
node: NodeInstance,
index: string | number
): [number, number] {
if (node.type === '__internal/group/input' && typeof index === 'number') {
return [
(node?.state?.x ?? node.position[0]) + 20,
(node?.state?.y ?? node.position[1]) + 2.5 + 5 * index + 5
];
}
if (typeof index === 'number') {
return [
(node?.state?.x ?? node.position[0]) + 20,
(node?.state?.y ?? node.position[1]) + 2.5 + 10 * index
];
} else {
let height = 5;
const nodeType = this.graph.getNodeType(node)!;
const inputs = nodeType.inputs || {};
for (const inputKey in inputs) {
const h = getParameterHeight(nodeType, inputKey) / 10;
if (inputKey === index) {
height += h / 2;
break;
}
height += h;
}
return [
node?.state?.x ?? node.position[0],
(node?.state?.y ?? node.position[1]) + height
];
}
}
}
+41 -7
View File
@@ -7,6 +7,7 @@
import AddMenu from '../components/AddMenu.svelte';
import BoxSelection from '../components/BoxSelection.svelte';
import Camera from '../components/Camera.svelte';
import GroupBreadcrumps from '../components/GroupBreadcrumps.svelte';
import HelpView from '../components/HelpView.svelte';
import Debug from '../debug/Debug.svelte';
import EdgeEl from '../edges/Edge.svelte';
@@ -15,11 +16,14 @@
import { maxZoom, minZoom } from './constants';
import { FileDropEventManager } from './drop.events';
import { MouseEventManager } from './mouse.events';
import ZoomIndicator from './ZoomIndicator.svelte';
const {
keymap
keymap,
safePadding
}: {
keymap: ReturnType<typeof createKeyMap>;
safePadding?: { left?: number; right?: number; bottom?: number; top?: number };
} = $props();
const graph = getGraphManager();
@@ -92,6 +96,20 @@
graphState.activeSocket = null;
graphState.addMenuPosition = null;
}
function getSocketType(node: NodeInstance, index: number | string): string {
const nodeType = graph.getNodeType(node);
if (typeof index === 'string') {
return nodeType?.inputs?.[index].type || 'unknown';
}
if (node.type === '__internal/group/input') {
const key = Object.keys(nodeType?.inputs || {})[index];
return nodeType?.inputs?.[key].type || 'unknown';
}
return nodeType?.outputs?.[index] || 'unknown';
}
</script>
<svelte:window
@@ -104,6 +122,7 @@
bind:this={graphState.wrapper}
class="graph-wrapper"
style="height: 100%"
class:is-inside-group={graph.isInsideGroup}
class:is-panning={graphState.isPanning}
class:is-hovering={graphState.hoveredNodeId !== -1}
aria-label="Graph"
@@ -111,6 +130,7 @@
tabindex="0"
bind:clientWidth={graphState.width}
bind:clientHeight={graphState.height}
style:--padding-right="{safePadding?.right || 0}px"
onkeydown={(ev) => keymap.handleKeyboardEvent(ev)}
onmousedown={(ev) => mouseEvents.handleMouseDown(ev)}
oncontextmenu={(ev) => mouseEvents.handleContextMenu(ev)}
@@ -126,14 +146,17 @@
/>
<label for="drop-zone"></label>
<GroupBreadcrumps />
<Canvas shadows={false} renderMode="on-demand" colorManagementEnabled={false}>
<Camera
bind:camera={graphState.camera}
position={graphState.cameraPosition}
/>
{#if graphState.showGrid !== false}
{#if graphState.backgroundType !== 'none'}
<Background
type={graphState.backgroundType}
cameraPosition={graphState.cameraPosition}
{maxZoom}
{minZoom}
@@ -159,12 +182,20 @@
{#if graph.status === 'idle'}
{#if graphState.addMenuPosition}
<AddMenu onnode={handleNodeCreation} />
<AddMenu
onnode={handleNodeCreation}
paddingTop={safePadding?.top}
paddingRight={safePadding?.right}
paddingBottom={safePadding?.bottom}
paddingLeft={safePadding?.left}
/>
{/if}
{#if graphState.activeSocket}
<EdgeEl
z={graphState.cameraPosition[2]}
inputType={getSocketType(graphState.activeSocket.node, graphState.activeSocket.index)}
outputType={getSocketType(graphState.activeSocket.node, graphState.activeSocket.index)}
x1={graphState.activeSocket.position[0]}
y1={graphState.activeSocket.position[1]}
x2={graphState.edgeEndPosition?.[0] ?? graphState.mousePosition[0]}
@@ -177,6 +208,8 @@
<EdgeEl
id={graph.getEdgeId(edge)}
z={graphState.cameraPosition[2]}
inputType={getSocketType(edge[0], edge[1])}
outputType={getSocketType(edge[2], edge[3])}
{x1}
{y1}
{x2}
@@ -195,11 +228,10 @@
style:transform={`scale(${graphState.cameraPosition[2] * 0.1})`}
class:hovering-sockets={graphState.activeSocket}
>
{#each graph.nodes.values() as node (node.id)}
{#each graph.nodeArray as node, index (node)}
<NodeEl
{node}
inView={graphState.isNodeInView(node)}
z={graphState.cameraPosition[2]}
bind:node={graph.nodeArray[index]}
inView={node ? graphState.isNodeInView(node) : false}
/>
{/each}
</div>
@@ -216,6 +248,8 @@
<HelpView registry={graph.registry} />
{/if}
<ZoomIndicator {safePadding} />
<style>
.graph-wrapper {
position: relative;
@@ -1,6 +1,7 @@
<script lang="ts">
import { createKeyMap } from '$lib/helpers/createKeyMap';
import type { Graph, NodeInstance, NodeRegistry } from '@nodarium/types';
import { onMount } from 'svelte';
import { GraphManager } from '../graph-manager.svelte';
import { GraphState, setGraphManager, setGraphState } from '../graph-state.svelte';
import { setupKeymaps } from '../keymaps';
@@ -13,11 +14,13 @@
settings?: Record<string, unknown>;
activeNode?: NodeInstance;
showGrid?: boolean;
backgroundType?: 'grid' | 'dots' | 'none';
snapToGrid?: boolean;
showHelp?: boolean;
settingTypes?: Record<string, unknown>;
safePadding?: { left?: number; right?: number; bottom?: number; top?: number };
onsave?: (save: Graph) => void;
onresult?: (result: unknown) => void;
};
@@ -25,9 +28,11 @@
let {
graph,
registry,
safePadding,
// eslint-disable-next-line no-useless-assignment
settings = $bindable(),
activeNode = $bindable(),
showGrid = $bindable(true),
backgroundType = $bindable('grid'),
snapToGrid = $bindable(true),
showHelp = $bindable(false),
settingTypes = $bindable(),
@@ -41,29 +46,32 @@
export const manager = new GraphManager(registry);
setGraphManager(manager);
const graphState = new GraphState(manager);
export const state = new GraphState(manager);
$effect(() => {
graphState.showGrid = showGrid;
graphState.snapToGrid = snapToGrid;
graphState.showHelp = showHelp;
if (safePadding) {
state.safePadding = safePadding;
}
state.backgroundType = backgroundType;
state.snapToGrid = snapToGrid;
state.showHelp = showHelp;
});
setGraphState(graphState);
setGraphState(state);
setupKeymaps(keymap, manager, graphState);
setupKeymaps(keymap, manager, state);
$effect(() => {
if (graphState.activeNodeId !== -1) {
activeNode = manager.getNode(graphState.activeNodeId);
if (state.activeNodeId !== -1) {
activeNode = manager.getNode(state.activeNodeId);
} else if (activeNode) {
activeNode = undefined;
}
});
$effect(() => {
if (!graphState.addMenuPosition) {
graphState.edgeEndPosition = null;
graphState.activeSocket = null;
if (!state.addMenuPosition) {
state.edgeEndPosition = null;
state.activeSocket = null;
}
});
@@ -76,11 +84,11 @@
manager.on('save', (save) => onsave?.(save));
$effect(() => {
onMount(() => {
if (graph) {
manager.load(graph);
}
});
</script>
<GraphEl {keymap} />
<GraphEl {keymap} {safePadding} />
@@ -0,0 +1,52 @@
<script lang="ts">
import { getGraphState } from '../graph-state.svelte';
const { safePadding }: {
safePadding?: { left?: number; right?: number; bottom?: number; top?: number };
} = $props();
const graphState = getGraphState();
</script>
<div class="zoom-indicator" style:right="calc({safePadding?.right ?? 0}px + 10px)">
<button
class="fit-btn"
title="Fit to view (.)"
onclick={() => graphState.centerNode()}
aria-label="Fit nodes to view"
>
</button>
<span>{Math.round(graphState.cameraPosition[2] * 10)}%</span>
</div>
<style>
.zoom-indicator {
position: absolute;
bottom: 10px;
display: flex;
align-items: center;
gap: 4px;
font-family: var(--font-family);
font-size: 0.75em;
color: var(--color-text);
opacity: 0.35;
z-index: 10;
transition: opacity 0.15s, right 0.2s;
pointer-events: auto;
}
.zoom-indicator:hover {
opacity: 0.9;
}
.fit-btn {
background: none;
border: none;
color: inherit;
cursor: pointer;
font-size: 1.1em;
line-height: 1;
padding: 0;
}
</style>
@@ -9,7 +9,7 @@ const variables = [
'outline',
'active',
'selected',
'edge'
'connection'
] as const;
function getColor(variable: (typeof variables)[number]) {
@@ -0,0 +1,52 @@
type Color = { hue: number; saturation: number; lightness: number };
export class ColorGenerator {
private colors: Map<string, Color> = new Map();
// private lightnessLevels = [10, 60];
constructor(predefined: Record<string, Color>) {
for (const [id, colorStr] of Object.entries(predefined)) {
this.colors.set(id, colorStr);
}
}
public getColors() {
return Object.fromEntries(
this.colors.entries().map(([key, col]) => {
return [key, this.colorToHsl(col)];
})
);
}
public getColor(id: string): string {
if (this.colors.has(id)) {
return this.colorToHsl(this.colors.get(id)!);
}
const newColor = this.generateNewColor();
this.colors.set(id, newColor);
return this.colorToHsl(newColor);
}
private generateNewColor(): Color {
const existingHues = Array.from(this.colors.values()).map(c => c.hue).sort();
let hue = existingHues[0];
let attempts = 0;
while (
existingHues.some(h => Math.abs(h - hue) < 30 || Math.abs(h - hue) > 330)
&& attempts < 360
) {
hue = (hue + 30) % 360;
attempts++;
}
const lightness = 60;
return { hue, lightness, saturation: 100 };
}
private colorToHsl(c: Color): string {
return `hsl(${c.hue}, ${c.saturation}%, ${c.lightness}%)`;
}
}
@@ -3,6 +3,7 @@ import { type NodeInstance } from '@nodarium/types';
import type { GraphManager } from '../graph-manager.svelte';
import { type GraphState } from '../graph-state.svelte';
import { snapToGrid as snapPointToGrid } from '../helpers';
import { getNodeHeight } from '../helpers/nodeHelpers';
import { maxZoom, minZoom, zoomSpeed } from './constants';
import { EdgeInteractionManager } from './edge.events';
@@ -166,15 +167,14 @@ export class MouseEventManager {
if (this.state.mouseDown) return;
this.state.edgeEndPosition = null;
const target = event.target as HTMLElement;
if (event.target instanceof HTMLElement) {
if (
event.target.nodeName !== 'CANVAS'
&& !event.target.classList.contains('node')
&& !event.target.classList.contains('content')
) {
return;
}
if (
target.nodeName !== 'CANVAS'
&& !target.classList.contains('node')
&& !target.classList.contains('content')
) {
return;
}
const mx = event.clientX - this.state.rect.x;
@@ -189,6 +189,10 @@ export class MouseEventManager {
// if we clicked on a node
if (clickedNodeId !== -1) {
if (event.ctrlKey && event.shiftKey) {
this.graph.tryConnectToDebugNode(clickedNodeId);
return;
}
if (this.state.activeNodeId === -1) {
this.state.activeNodeId = clickedNodeId;
// if the selected node is the same as the clicked node
@@ -265,7 +269,7 @@ export class MouseEventManager {
}
}
if (_socket && smallestDist < 0.9) {
if (_socket && smallestDist < 1.5) {
this.state.mousePosition = _socket.position;
this.state.hoveredSocket = _socket;
} else {
@@ -290,7 +294,7 @@ export class MouseEventManager {
if (!node?.state) continue;
const x = node.position[0];
const y = node.position[1];
const height = this.state.getNodeHeight(node.type);
const height = getNodeHeight(node.state.type!);
if (x > x1 - 20 && x < x2 && y > y1 - height && y < y2) {
this.state.selectedNodes?.add(node.id);
} else {
+4 -3
View File
@@ -35,6 +35,9 @@ export function createNodePath({
rightBump = false,
aspectRatio = 1
} = {}) {
const leftBumpTopY = y + height / 2;
const leftBumpBottomY = y - height / 2;
return `M0,${cornerTop}
${
cornerTop
@@ -64,9 +67,7 @@ export function createNodePath({
}
${
leftBump
? ` V${y + height / 2} C${depth},${y + height / 2} ${depth},${y - height / 2} 0,${
y - height / 2
}`
? ` V${leftBumpTopY} C${depth},${leftBumpTopY} ${depth},${leftBumpBottomY} 0,${leftBumpBottomY}`
: ` H0`
}
Z`.replace(/\s+/g, ' ');
@@ -0,0 +1,101 @@
import type {
Edge,
NodeDefinition,
NodeInstance,
SerializedEdge,
SerializedNode
} from '@nodarium/types';
export function getParameterHeight(node: NodeDefinition, inputKey: string) {
if (node.id === '__internal/group/input') {
return 50;
}
const input = node.inputs?.[inputKey];
if (!input) {
return 0;
}
if (inputKey === 'seed') return 0;
if (!node.inputs) return 0;
if ('setting' in input) return 0;
if (input.hidden) return 0;
if (input.type === 'shape' && input.external !== true) {
return 200;
}
if (
input?.label !== '' && !input.external && input.type !== 'path'
&& input.type !== 'geometry'
) {
return 100;
}
return 50;
}
export function serializeNode(node: SerializedNode | NodeInstance): SerializedNode {
return {
id: node.id,
position: [...node.position],
type: node.type,
props: node.props
};
}
export function serializeEdge(edge: SerializedEdge | Edge): SerializedEdge {
if (typeof edge[0] === 'number' && typeof edge[2] === 'number') {
return [edge[0], edge[1], edge[2], edge[3]];
}
const e = edge as Edge;
return [e[0].id, e[1], e[2].id, e[3]];
}
const nodeHeightCache: Record<string, number> = {};
export function getNodeHeight(node: NodeDefinition) {
if (!node || !('inputs' in node)) {
return 5;
}
if (node.id in nodeHeightCache) {
return nodeHeightCache[node.id];
}
let height = 5;
for (const key in node.inputs) {
const h = getParameterHeight(node, key) / 10;
height += h;
}
nodeHeightCache[node.id] = height;
return height;
}
export function areSocketsCompatible(
output: string | undefined,
inputs: string | (string | undefined)[] | undefined
) {
if (output === '*') return true;
if (Array.isArray(inputs) && output) {
return inputs.includes('*') || inputs.includes(output);
}
return inputs === output;
}
export function areEdgesEqual(firstEdge: Edge, secondEdge: Edge) {
if (firstEdge[0].id !== secondEdge[0].id) {
return false;
}
if (firstEdge[1] !== secondEdge[1]) {
return false;
}
if (firstEdge[2].id !== secondEdge[2].id) {
return false;
}
if (firstEdge[3] !== secondEdge[3]) {
return false;
}
return true;
}
+30 -22
View File
@@ -1,6 +1,6 @@
import { animate, lerp } from '$lib/helpers';
import type { createKeyMap } from '$lib/helpers/createKeyMap';
import { panelState } from '$lib/sidebar/PanelState.svelte';
import { toast } from '@nodarium/ui';
import FileSaver from 'file-saver';
import type { GraphManager } from './graph-manager.svelte';
import type { GraphState } from './graph-state.svelte';
@@ -48,6 +48,10 @@ export function setupKeymaps(keymap: Keymap, graph: GraphManager, graphState: Gr
key: 'Escape',
description: 'Deselect nodes',
callback: () => {
if (graph.isInsideGroup) {
graphState.exitGroupNode();
return;
}
graphState.activeNodeId = -1;
graphState.clearSelection();
graphState.edgeEndPosition = null;
@@ -55,6 +59,29 @@ export function setupKeymaps(keymap: Keymap, graph: GraphManager, graphState: Gr
}
});
keymap.addShortcut({
key: 'g',
ctrl: true,
preventDefault: true,
description: 'Group selected nodes',
callback: () => graphState.groupSelectedNodes()
});
keymap.addShortcut({
key: 'g',
alt: true,
preventDefault: true,
description: 'Ungroup selected nodes',
callback: () => graphState.unGroupSelectedNodes()
});
keymap.addShortcut({
key: 'Tab',
preventDefault: true,
description: 'Enter selected node group',
callback: () => graphState.enterGroupNode()
});
keymap.addShortcut({
key: 'A',
shift: true,
@@ -67,27 +94,7 @@ export function setupKeymaps(keymap: Keymap, graph: GraphManager, graphState: Gr
description: 'Center camera',
callback: () => {
if (!graphState.isBodyFocused()) return;
const average = [0, 0];
for (const node of graph.nodes.values()) {
average[0] += node.position[0];
average[1] += node.position[1];
}
average[0] = average[0] ? average[0] / graph.nodes.size : 0;
average[1] = average[1] ? average[1] / graph.nodes.size : 0;
const camX = graphState.cameraPosition[0];
const camY = graphState.cameraPosition[1];
const camZ = graphState.cameraPosition[2];
const ease = (t: number) => (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t);
animate(500, (a: number) => {
graphState.cameraPosition[0] = lerp(camX, average[0], ease(a));
graphState.cameraPosition[1] = lerp(camY, average[1], ease(a));
graphState.cameraPosition[2] = lerp(camZ, 2, ease(a));
if (graphState.mouseDown) return false;
});
graphState.centerNode(graph.getNode(graphState.activeNodeId));
}
});
@@ -140,6 +147,7 @@ export function setupKeymaps(keymap: Keymap, graph: GraphManager, graphState: Gr
type: 'application/json;charset=utf-8'
});
FileSaver.saveAs(blob, 'nodarium-graph.json');
toast('Graph downloaded', 'success', 1500);
}
});
+56 -24
View File
@@ -1,56 +1,88 @@
varying vec2 vUv;
uniform float uWidth;
uniform float uHeight;
uniform float uZoom;
uniform vec3 uColorDark;
uniform vec3 uColorBright;
uniform vec3 uStrokeColor;
uniform float uStrokeWidth;
const float uHeaderHeight = 5.0;
uniform float uSectionHeights[16];
uniform int uNumSections;
float msign(in float x) { return (x < 0.0) ? -1.0 : 1.0; }
float sdCircle(vec2 p, float r) { return length(p) - r; }
vec4 roundedBoxSDF( in vec2 p, in vec2 b, in float r, in float s) {
vec2 q = abs(p) - b + r;
float l = b.x + b.y + 1.570796 * r;
float k1 = min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r;
float k2 = ((q.x > 0.0) ? atan(q.y, q.x) : 1.570796);
float k3 = 3.0 + 2.0 * msign(min(p.x, -p.y)) - msign(p.x);
float k4 = msign(p.x * p.y);
float k5 = r * k2 + max(-q.x, 0.0);
float ra = s * round(k1 / s);
float l2 = l + 1.570796 * ra;
return vec4(k1 - ra, k3 * l2 + k4 * (b.y + ((q.y > 0.0) ? k5 + k2 * ra : q.y)), 4.0 * l2, k1);
}
void main(){
float strokeWidth = mix(2.0, 0.5, uZoom);
float y = (1.0-vUv.y) * uHeight;
float borderRadius = 0.5;
float dentRadius = 0.8;
float y = (1.0 - vUv.y) * uHeight;
float x = vUv.x * uWidth;
vec2 size = vec2(uWidth, uHeight);
vec2 uv = (vUv - 0.5) * 2.0;
vec2 uvCenter = (vUv - 0.5) * 2.0;
float u_border_radius = 0.4;
vec4 distance = roundedBoxSDF(uv * size, size, u_border_radius*2.0, 0.0);
vec4 boxData = roundedBoxSDF(uvCenter * size, size, borderRadius * 2.0, 0.0);
float sceneSDF = boxData.w;
if (distance.w > 0.0 ) {
// outside
gl_FragColor = vec4(0.0,0.0,0.0, 0.0);
}else{
if (distance.w > -uStrokeWidth || mod(y+5.0, 10.0) < uStrokeWidth/2.0) {
// draw the outer stroke
gl_FragColor = vec4(uStrokeColor, 1.0);
}else if (y<5.0){
// draw the header
gl_FragColor = vec4(uColorBright, 1.0);
}else{
gl_FragColor = vec4(uColorDark, 1.0);
}
vec2 headerDentPos = vec2(uWidth, uHeaderHeight * 0.5);
float headerDentDist = sdCircle(vec2(x, y) - headerDentPos, dentRadius);
sceneSDF = max(sceneSDF, -headerDentDist*2.0);
float currentYBoundary = uHeaderHeight;
float previousYBoundary = uHeaderHeight;
for (int i = 0; i < 16; i++) {
if (i >= uNumSections) break;
float sectionHeight = uSectionHeights[i];
currentYBoundary += sectionHeight;
float centerY = previousYBoundary + (sectionHeight * 0.5);
vec2 circlePos = vec2(0.0, centerY);
float circleDist = sdCircle(vec2(x, y) - circlePos, dentRadius);
sceneSDF = max(sceneSDF, -circleDist*2.0);
previousYBoundary = currentYBoundary;
}
if (sceneSDF > 0.05) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
return;
}
vec3 finalColor = (y < uHeaderHeight) ? uColorBright : uColorDark;
bool isDivider = false;
float dividerY = uHeaderHeight;
if (abs(y - dividerY) < strokeWidth * 0.25) isDivider = true;
for (int i = 0; i < 16; i++) {
if (i >= uNumSections - 1) break;
dividerY += uSectionHeights[i];
if (abs(y - dividerY) < strokeWidth * 0.25) isDivider = true;
}
if (sceneSDF > -strokeWidth || isDivider) {
gl_FragColor = vec4(uStrokeColor, 1.0);
} else {
gl_FragColor = vec4(finalColor, 1.0);
}
}
+33 -10
View File
@@ -3,20 +3,23 @@
import type { NodeInstance } from '@nodarium/types';
import { T } from '@threlte/core';
import { type Mesh } from 'three';
import { getGraphState } from '../graph-state.svelte';
import { getGraphManager, getGraphState } from '../graph-state.svelte';
import { colors } from '../graph/colors.svelte';
import { getNodeHeight, getParameterHeight } from '../helpers/nodeHelpers';
import NodeFrag from './Node.frag';
import NodeVert from './Node.vert';
import NodeHtml from './NodeHTML.svelte';
const graph = getGraphManager();
const graphState = getGraphState();
type Props = {
node: NodeInstance;
inView: boolean;
z: number;
};
let { node = $bindable(), inView, z }: Props = $props();
let { node = $bindable(), inView }: Props = $props();
const nodeType = $derived(node ? graph.getNodeType(node) : undefined);
const isActive = $derived(graphState.activeNodeId === node.id);
const isSelected = $derived(graphState.selectedNodes.has(node.id));
@@ -29,9 +32,20 @@
: colors.outline)
);
const sectionHeights = $derived(
nodeType
? Object
.keys(nodeType?.inputs || {})
.map(key => getParameterHeight(nodeType, key) / 10)
.filter(b => !!b)
: [5]
);
let meshRef: Mesh | undefined = $state();
const height = graphState.getNodeHeight(node.type);
const height = $derived(nodeType ? getNodeHeight(nodeType) : 20);
const zoom = $derived(graphState.cameraPosition[2]);
$effect(() => {
if (meshRef && !node.state?.mesh) {
@@ -39,6 +53,10 @@
graphState.updateNodePosition(node);
}
});
const zoomValue = $derived(
(Math.log(graphState.cameraPosition[2]) - Math.log(1)) / (Math.log(40) - Math.log(1))
);
// const zoomValue = (graphState.cameraPosition[2] - 1) / 39;
</script>
<T.Mesh
@@ -47,7 +65,7 @@
position.y={0.8}
rotation.x={-Math.PI / 2}
bind:ref={meshRef}
visible={inView && z < 7}
visible={inView && zoom < 7}
>
<T.PlaneGeometry args={[20, height]} radius={1} />
<T.ShaderMaterial
@@ -58,13 +76,18 @@
uColorBright: { value: colors['layer-2'] },
uColorDark: { value: colors['layer-1'] },
uStrokeColor: { value: colors.outline.clone() },
uStrokeWidth: { value: 1.0 },
uSectionHeights: { value: [5, 10] },
uNumSections: { value: 2 },
uWidth: { value: 20 },
uHeight: { value: height }
uHeight: { value: 200 },
uZoom: { value: 1.0 }
}}
uniforms.uStrokeColor.value={strokeColor.clone()}
uniforms.uStrokeWidth.value={(7 - z) / 3}
uniforms.uZoom.value={zoomValue}
uniforms.uHeight.value={height}
uniforms.uSectionHeights.value={sectionHeights}
uniforms.uNumSections.value={sectionHeights.length}
uniforms.uStrokeColor.value={strokeColor}
/>
</T.Mesh>
<NodeHtml bind:node {inView} {isActive} {isSelected} {z} />
<NodeHtml bind:node {inView} {isActive} {isSelected} z={zoom} />
@@ -1,11 +1,12 @@
<script lang="ts">
import type { NodeInstance } from '@nodarium/types';
import { getGraphState } from '../graph-state.svelte';
import { getGraphManager, getGraphState } from '../graph-state.svelte';
import NodeHeader from './NodeHeader.svelte';
import NodeParameter from './NodeParameter.svelte';
let ref: HTMLDivElement;
const graph = getGraphManager();
const graphState = getGraphState();
type Props = {
@@ -30,8 +31,12 @@
const zOffset = Math.random() - 0.5;
const zLimit = 2 - zOffset;
const parameters = Object.entries(node.state?.type?.inputs || {}).filter(
(p) => p[1].type !== 'seed' && !('setting' in p[1]) && p[1]?.hidden !== true
const nodeType = $derived(graph.getNodeType(node));
const parameters = $derived(
Object.entries(nodeType?.inputs || {}).filter(
(p) => p[1].type !== 'seed' && !('setting' in p[1]) && p[1]?.hidden !== true
) || {}
);
$effect(() => {
@@ -1,9 +1,11 @@
<script lang="ts">
import type { NodeInstance } from '@nodarium/types';
import { getGraphState } from '../graph-state.svelte';
import { appSettings } from '$lib/settings/app-settings.svelte';
import type { NodeInstance, Socket } from '@nodarium/types';
import { getGraphManager, getGraphState } from '../graph-state.svelte';
import { createNodePath } from '../helpers/index.js';
const graphState = getGraphState();
const graph = getGraphManager();
const { node }: { node: NodeInstance } = $props();
@@ -20,7 +22,18 @@
}
const cornerTop = 10;
const rightBump = $derived(!!node?.state?.type?.outputs?.length);
const nodeType = $derived(graph.getNodeType(node));
const rightBump = $derived(
!!nodeType?.outputs?.length && node.type !== '__internal/group/input'
);
const cornerBottom = $derived(
node.type === '__internal/group/input'
? (Object.keys(nodeType?.inputs ?? {}).length ? 0 : 10)
: node.type === '__internal/group/output'
? (nodeType?.outputs?.length ? 0 : 10)
: 0
);
const aspectRatio = 0.25;
const path = $derived(
@@ -29,33 +42,58 @@
height: 34,
y: 49,
cornerTop,
cornerBottom,
rightBump,
aspectRatio
})
);
const pathHover = $derived(
createNodePath({
depth: 8.5,
height: 50,
depth: 7,
height: 40,
y: 49,
cornerTop,
cornerBottom,
rightBump,
aspectRatio
})
);
const socketId = $derived(`${node.id}-${0}`);
function getSocketType(s: Socket | null) {
if (!s) return 'unknown';
if (typeof s.index === 'string') {
return s.node.state.type?.inputs?.[s.index].type || 'unknown';
}
return s.node.state.type?.outputs?.[s.index] || 'unknown';
}
const socketType = $derived(getSocketType(graphState.activeSocket));
const hoverColor = $derived(graphState.colors.getColor(socketType));
</script>
<div class="wrapper" data-node-id={node.id} data-node-type={node.type}>
<div
class="wrapper"
data-node-id={node.id}
data-node-type={node.type}
style:--socket-color={hoverColor}
class:possible-socket={graphState?.possibleSocketIds.has(socketId)}
>
<div class="content">
{node.type.split('/').pop()}
</div>
<div
class="click-target"
role="button"
tabindex="0"
onmousedown={handleMouseDown}
>
{#if appSettings.value.debug.advancedMode}
<span class="bg-white text-black! mr-2 px-1 rounded-sm opacity-30">{node.id}</span>
{/if}
{nodeType?.meta?.title || node.type?.split('/').pop()}
</div>
{#if rightBump}
<div
class="target"
role="button"
tabindex="0"
onmousedown={handleMouseDown}
>
</div>
{/if}
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 100 100"
@@ -78,7 +116,20 @@
height: 50px;
}
.click-target {
.possible-socket .target::before {
content: "";
position: absolute;
width: 30px;
height: 30px;
border-radius: 100%;
box-shadow: 0px 0px 10px var(--socket-color);
background-color: var(--socket-color);
outline: solid thin var(--socket-color);
opacity: 0.7;
z-index: -10;
}
.target {
position: absolute;
right: 0px;
top: 50%;
@@ -87,11 +138,9 @@
width: 30px;
z-index: 100;
border-radius: 50%;
/* background: red; */
/* opacity: 0.2; */
}
.click-target:hover + svg path {
.target:hover + svg path {
d: var(--hover-path);
}
@@ -108,11 +157,16 @@
svg path {
stroke-width: 0.2px;
transition: d 0.3s ease, fill 0.3s ease;
transition:
d 0.3s ease,
fill 0.3s ease;
fill: var(--color-layer-2);
stroke: var(--stroke);
stroke-width: var(--stroke-width);
d: var(--path);
stroke-linejoin: round;
shape-rendering: geometricPrecision;
}
.content {
@@ -31,11 +31,24 @@
return 0;
}
let value = $state(getDefaultValue());
let value = $state(structuredClone($state.snapshot(getDefaultValue())));
function diffArray(a: number[], b?: number[] | number) {
if (!Array.isArray(b)) return true;
if (Array.isArray(a) !== Array.isArray(b)) return true;
if (a.length !== b.length) return true;
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) return true;
}
return false;
}
$effect(() => {
if (value !== undefined && node?.props?.[id] !== value) {
node.props = { ...node.props, [id]: value };
const a = $state.snapshot(value);
const b = $state.snapshot(node?.props?.[id]);
const isDiff = Array.isArray(a) ? diffArray(a, b) : a !== b;
if (value !== undefined && isDiff) {
node.props = { ...node.props, [id]: a };
if (graph) {
graph.save();
graph.execute();
@@ -1,7 +1,8 @@
<script lang="ts">
import type { NodeInput, NodeInstance } from '@nodarium/types';
import type { NodeInput, NodeInstance, Socket } from '@nodarium/types';
import { getGraphManager, getGraphState } from '../graph-state.svelte';
import { createNodePath } from '../helpers';
import { getParameterHeight } from '../helpers/nodeHelpers';
import NodeInputEl from './NodeInput.svelte';
type Props = {
@@ -12,89 +13,104 @@
};
const graph = getGraphManager();
const graphState = getGraphState();
const graphId = graph?.id;
const elementId = `input-${Math.random().toString(36).substring(7)}`;
let { node = $bindable(), input, id, isLast }: Props = $props();
const inputType = $derived(node?.state?.type?.inputs?.[id]);
let nodeType = $derived(graph.getNodeType(node)!);
const inputType = $derived(nodeType.inputs?.[id]);
const socketId = $derived(`${node.id}-${id}`);
const graphState = getGraphState();
const graphId = graph?.id;
const elementId = `input-${Math.random().toString(36).substring(7)}`;
const height = $derived(getParameterHeight(nodeType, id));
function handleMouseDown(ev: MouseEvent) {
ev.preventDefault();
ev.stopPropagation();
graphState.setDownSocket({
node,
index: id,
position: graphState.getSocketPosition?.(node, id)
});
if (node.type === '__internal/group/input') {
const outputIndex = Object.entries(nodeType?.inputs ?? {}).findIndex(([key]) => key === id);
graphState.setDownSocket({
node,
index: outputIndex,
position: graphState.getSocketPosition(node, outputIndex)
});
} else {
graphState.setDownSocket({
node,
index: id,
position: graphState.getSocketPosition(node, id)
});
}
}
const leftBump = $derived(node.state?.type?.inputs?.[id].internal !== true);
const leftBump = $derived(
nodeType.inputs?.[id].internal !== true && node.type !== '__internal/group/input'
);
const rightBump = $derived(node.type === '__internal/group/input');
const cornerBottom = $derived(isLast ? 5 : 0);
const aspectRatio = 0.5;
const path = $derived(
createNodePath({
depth: 7,
height: 20,
y: 50.5,
cornerBottom,
leftBump,
aspectRatio
})
);
const pathDisabled = $derived(
createNodePath({
depth: 6,
height: 18,
height: 2000 / height,
y: 50.5,
cornerBottom,
rightBump,
leftBump,
aspectRatio
})
);
const pathHover = $derived(
createNodePath({
depth: 8,
height: 25,
depth: 7,
height: 2200 / height,
y: 50.5,
rightBump,
cornerBottom,
leftBump,
aspectRatio
})
);
function getSocketType(s: Socket | null) {
if (!s) return 'unknown';
if (typeof s.index === 'string') {
return s.node.state.type?.inputs?.[s.index].type || 'unknown';
}
return s.node.state.type?.outputs?.[s.index] || 'unknown';
}
const socketType = $derived(getSocketType(graphState.activeSocket));
const hoverColor = $derived(graphState.colors.getColor(socketType));
</script>
<div
class="wrapper"
data-node-type={node.type}
class:is-group-input={node.type === '__internal/group/input'}
data-node-input={id}
class:disabled={!graphState?.possibleSocketIds.has(socketId)}
style:height="{height}px"
style:--socket-color={hoverColor}
class:possible-socket={graphState?.possibleSocketIds.has(socketId)}
>
{#key id && graphId}
<div class="content" class:disabled={graph?.inputSockets?.has(socketId)}>
{#if inputType?.label !== ''}
<label for={elementId} title={input.description}>{input.label || id}</label>
{/if}
<span
class="absolute i-[tabler--help-circle] size-4 block top-2 right-2 opacity-30"
title={JSON.stringify(input, null, 2)}
></span>
{#if inputType?.external !== true}
<NodeInputEl {graph} {elementId} bind:node {input} {id} />
{/if}
</div>
{#if node?.state?.type?.inputs?.[id]?.internal !== true}
<div data-node-socket class="large target"></div>
<div
data-node-socket
class="small target"
class="target"
onmousedown={handleMouseDown}
role="button"
tabindex="0"
@@ -106,14 +122,9 @@
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 100 100"
width="100"
height="100"
preserveAspectRatio="none"
style={`
--path: path("${path}");
--hover-path: path("${pathHover}");
--hover-path-disabled: path("${pathDisabled}");
`}
style:--path={`path("${path}")`}
style:--hover-path={`path("${pathHover}")`}
>
<path vector-effect="non-scaling-stroke"></path>
</svg>
@@ -123,42 +134,48 @@
.wrapper {
position: relative;
width: 100%;
height: 100px;
transform: translateY(-0.5px);
}
.target {
width: 30px;
height: 30px;
position: absolute;
border-radius: 50%;
top: 50%;
transform: translateY(-50%) translateX(-50%);
/* background: red; */
/* opacity: 0.1; */
}
.small.target {
.is-group-input .target {
right: 0px;
transform: translateY(-50%) translateX(50%);
}
.possible-socket .target::before {
content: "";
position: absolute;
width: 30px;
height: 30px;
border-radius: 100%;
box-shadow: 0px 0px 10px var(--socket-color);
background-color: var(--socket-color);
outline: solid thin var(--socket-color);
opacity: 0.5;
z-index: -10;
}
.large.target {
width: 60px;
height: 60px;
cursor: unset;
pointer-events: none;
}
:global(.hovering-sockets) .large.target {
pointer-events: all;
.target:hover ~ svg path{
d: var(--hover-path);
}
.content {
position: relative;
padding: 10px 20px;
display: flex;
flex-direction: column;
padding-inline: 20px;
height: 100%;
justify-content: space-around;
justify-content: center;
gap: 10px;
box-sizing: border-box;
}
@@ -179,19 +196,16 @@
stroke: var(--stroke);
stroke-width: var(--stroke-width);
d: var(--path);
}
:global {
.hovering-sockets .large:hover ~ svg path {
d: var(--hover-path);
}
stroke-linejoin: round;
shape-rendering: geometricPrecision;
}
.content.disabled {
opacity: 0.2;
}
.disabled svg path {
d: var(--hover-path-disabled) !important;
.possible-socket svg path {
d: var(--hover-path);
}
</style>
+90
View File
@@ -0,0 +1,90 @@
import type { NodeDefinition, NodeId, NodeRegistry } from '@nodarium/types';
export function createMockNodeRegistry(nodes: NodeDefinition[]): NodeRegistry {
const nodesMap = new Map(nodes.map(n => [n.id, n]));
return {
status: 'ready' as const,
load: async (nodeIds: NodeId[]) => {
const loaded: NodeDefinition[] = [];
for (const id of nodeIds) {
if (nodesMap.has(id)) {
loaded.push(nodesMap.get(id)!);
}
}
return loaded;
},
getNode: (id: string) => nodesMap.get(id as NodeId),
getAllNodes: () => Array.from(nodesMap.values()),
register: async () => {
throw new Error('Not implemented in mock');
}
};
}
export const mockFloatOutputNode: NodeDefinition = {
id: 'test/node/output',
inputs: {
'input': {
type: 'float'
}
},
outputs: ['float'],
meta: { title: 'Float Output' },
execute: () => new Int32Array()
};
export const mockFloatInputNode: NodeDefinition = {
id: 'test/node/input',
inputs: { value: { type: 'float' } },
outputs: ['float'],
meta: { title: 'Float Input' },
execute: () => new Int32Array()
};
export const mockGeometryOutputNode: NodeDefinition = {
id: 'test/node/geometry',
inputs: {},
outputs: ['geometry'],
meta: { title: 'Geometry Output' },
execute: () => new Int32Array()
};
export const mockPathInputNode: NodeDefinition = {
id: 'test/node/path',
inputs: { input: { type: 'path', accepts: ['geometry'] } },
outputs: [],
meta: { title: 'Path Input' },
execute: () => new Int32Array()
};
export const mockVec3OutputNode: NodeDefinition = {
id: 'test/node/vec3',
inputs: {},
outputs: ['vec3'],
meta: { title: 'Vec3 Output' },
execute: () => new Int32Array()
};
export const mockIntegerInputNode: NodeDefinition = {
id: 'test/node/integer',
inputs: { value: { type: 'integer' } },
outputs: [],
meta: { title: 'Integer Input' },
execute: () => new Int32Array()
};
export const mockBooleanOutputNode: NodeDefinition = {
id: 'test/node/boolean',
inputs: {},
outputs: ['boolean'],
meta: { title: 'Boolean Output' },
execute: () => new Int32Array()
};
export const mockBooleanInputNode: NodeDefinition = {
id: 'test/node/boolean-input',
inputs: { value: { type: 'boolean' } },
outputs: [],
meta: { title: 'Boolean Input' },
execute: () => new Int32Array()
};
+110
View File
@@ -0,0 +1,110 @@
import { grid } from '$lib/graph-templates/grid';
import { tree } from '$lib/graph-templates/tree';
import { describe, expect, it } from 'vitest';
describe('graph-templates', () => {
describe('grid', () => {
it('should create a grid graph with nodes and edges', () => {
const result = grid(2, 3);
expect(result.nodes.length).toBeGreaterThan(0);
expect(result.edges.length).toBeGreaterThan(0);
});
it('should have output node at the end', () => {
const result = grid(1, 1);
const outputNode = result.nodes.find(n => n.type === 'max/plantarium/output');
expect(outputNode).toBeDefined();
});
it('should create nodes based on grid dimensions', () => {
const result = grid(2, 2);
const mathNodes = result.nodes.filter(n => n.type === 'max/plantarium/math');
expect(mathNodes.length).toBeGreaterThan(0);
const outputNode = result.nodes.find(n => n.type === 'max/plantarium/output');
expect(outputNode).toBeDefined();
});
it('should have output node at the end', () => {
const result = grid(1, 1);
const outputNode = result.nodes.find(n => n.type === 'max/plantarium/output');
expect(outputNode).toBeDefined();
});
it('should create nodes based on grid dimensions', () => {
const result = grid(2, 2);
const mathNodes = result.nodes.filter(n => n.type === 'max/plantarium/math');
expect(mathNodes.length).toBeGreaterThan(0);
const outputNode = result.nodes.find(n => n.type === 'max/plantarium/output');
expect(outputNode).toBeDefined();
});
it('should have valid node positions', () => {
const result = grid(3, 2);
result.nodes.forEach(node => {
expect(node.position).toHaveLength(2);
expect(typeof node.position[0]).toBe('number');
expect(typeof node.position[1]).toBe('number');
});
});
it('should generate valid graph structure', () => {
const result = grid(2, 2);
result.nodes.forEach(node => {
expect(typeof node.id).toBe('number');
expect(node.type).toBeTruthy();
});
result.edges.forEach(edge => {
expect(edge).toHaveLength(4);
});
});
});
describe('tree', () => {
it('should create a tree graph with specified depth', () => {
const result = tree(0);
expect(result.nodes.length).toBeGreaterThan(0);
expect(result.edges.length).toBeGreaterThan(0);
});
it('should have root output node', () => {
const result = tree(2);
const outputNode = result.nodes.find(n => n.type === 'max/plantarium/output');
expect(outputNode).toBeDefined();
expect(outputNode?.id).toBe(0);
});
it('should increase node count with depth', () => {
const tree0 = tree(0);
const tree1 = tree(1);
const tree2 = tree(2);
expect(tree0.nodes.length).toBeLessThan(tree1.nodes.length);
expect(tree1.nodes.length).toBeLessThan(tree2.nodes.length);
});
it('should create binary tree structure', () => {
const result = tree(2);
const mathNodes = result.nodes.filter(n => n.type === 'max/plantarium/math');
expect(mathNodes.length).toBeGreaterThan(0);
const edgeCount = result.edges.length;
expect(edgeCount).toBe(result.nodes.length - 1);
});
it('should have valid node positions', () => {
const result = tree(3);
result.nodes.forEach(node => {
expect(node.position).toHaveLength(2);
expect(typeof node.position[0]).toBe('number');
expect(typeof node.position[1]).toBe('number');
});
});
});
});
+2 -1
View File
@@ -4,7 +4,8 @@ export function grid(width: number, height: number) {
const graph: Graph = {
id: Math.floor(Math.random() * 100000),
edges: [],
nodes: []
nodes: [],
groups: []
};
const amount = width * height;
+2
View File
@@ -4,4 +4,6 @@ export { default as lottaFaces } from './lotta-faces.json';
export { default as lottaNodesAndFaces } from './lotta-nodes-and-faces.json';
export { default as lottaNodes } from './lotta-nodes.json';
export { plant } from './plant';
export { default as simple } from './simple.json';
export { tree } from './tree';
export { default as tutorial } from './tutorial.json';
+63
View File
@@ -0,0 +1,63 @@
{
"id": 0,
"settings": {
"resolution.circle": 54,
"resolution.curve": 20,
"randomSeed": false
},
"meta": {
"title": "New Project",
"lastModified": "2026-02-03T16:56:40.375Z"
},
"nodes": [
{
"id": 9,
"position": [
215,
85
],
"type": "max/plantarium/output",
"props": {}
},
{
"id": 10,
"position": [
165,
72.5
],
"type": "max/plantarium/stem",
"props": {
"amount": 4,
"length": 4,
"thickness": 0.2
}
},
{
"id": 11,
"position": [
190,
77.5
],
"type": "max/plantarium/noise",
"props": {
"plant": 0,
"scale": 0.5,
"strength": 5
}
}
],
"edges": [
[
10,
0,
11,
"plant"
],
[
11,
0,
9,
"input"
]
]
}
+2 -1
View File
@@ -47,6 +47,7 @@ export function tree(depth: number): Graph {
return {
id: Math.floor(Math.random() * 100000),
nodes,
edges
edges,
groups: []
};
}
+24
View File
@@ -0,0 +1,24 @@
{
"id": 0,
"settings": {
"resolution.circle": 54,
"resolution.curve": 20,
"randomSeed": false
},
"meta": {
"title": "New Project",
"lastModified": "2026-02-03T16:56:40.375Z"
},
"nodes": [
{
"id": 9,
"position": [
215,
85
],
"type": "max/plantarium/output",
"props": {}
}
],
"edges": []
}
+145
View File
@@ -0,0 +1,145 @@
import { clone, debounce, humanizeDuration, humanizeNumber, lerp, snapToGrid } from '$lib/helpers';
import { describe, expect, it } from 'vitest';
describe('helpers', () => {
describe('snapToGrid', () => {
it('should snap to nearest grid point', () => {
expect(snapToGrid(5, 10)).toBe(10);
expect(snapToGrid(15, 10)).toBe(20);
expect(snapToGrid(0, 10)).toBe(0);
expect(snapToGrid(-10, 10)).toBe(-10);
});
it('should snap exact midpoint values', () => {
expect(snapToGrid(5, 10)).toBe(10);
});
it('should use default grid size of 10', () => {
expect(snapToGrid(5)).toBe(10);
expect(snapToGrid(15)).toBe(20);
});
it('should handle values exactly on grid', () => {
expect(snapToGrid(10, 10)).toBe(10);
expect(snapToGrid(20, 10)).toBe(20);
});
});
describe('lerp', () => {
it('should linearly interpolate between two values', () => {
expect(lerp(0, 100, 0)).toBe(0);
expect(lerp(0, 100, 0.5)).toBe(50);
expect(lerp(0, 100, 1)).toBe(100);
});
it('should handle negative values', () => {
expect(lerp(-50, 50, 0.5)).toBe(0);
expect(lerp(-100, 0, 0.5)).toBe(-50);
});
it('should handle t values outside 0-1 range', () => {
expect(lerp(0, 100, -0.5)).toBe(-50);
expect(lerp(0, 100, 1.5)).toBe(150);
});
});
describe('humanizeNumber', () => {
it('should return unchanged numbers below 1000', () => {
expect(humanizeNumber(0)).toBe('0');
expect(humanizeNumber(999)).toBe('999');
});
it('should add K suffix for thousands', () => {
expect(humanizeNumber(1000)).toBe('1K');
expect(humanizeNumber(1500)).toBe('1.5K');
expect(humanizeNumber(999999)).toBe('1000K');
});
it('should add M suffix for millions', () => {
expect(humanizeNumber(1000000)).toBe('1M');
expect(humanizeNumber(2500000)).toBe('2.5M');
});
it('should add B suffix for billions', () => {
expect(humanizeNumber(1000000000)).toBe('1B');
});
});
describe('humanizeDuration', () => {
it('should return ms for very short durations', () => {
expect(humanizeDuration(100)).toBe('100ms');
expect(humanizeDuration(999)).toBe('999ms');
});
it('should format seconds', () => {
expect(humanizeDuration(1000)).toBe('1s');
expect(humanizeDuration(1500)).toBe('1s500ms');
expect(humanizeDuration(59000)).toBe('59s');
});
it('should format minutes', () => {
expect(humanizeDuration(60000)).toBe('1m');
expect(humanizeDuration(90000)).toBe('1m 30s');
});
it('should format hours', () => {
expect(humanizeDuration(3600000)).toBe('1h');
expect(humanizeDuration(3661000)).toBe('1h 1m 1s');
});
it('should format days', () => {
expect(humanizeDuration(86400000)).toBe('1d');
expect(humanizeDuration(90061000)).toBe('1d 1h 1m 1s');
});
it('should handle zero', () => {
expect(humanizeDuration(0)).toBe('0ms');
});
});
describe('debounce', () => {
it('should return a function', () => {
const fn = debounce(() => {}, 100);
expect(typeof fn).toBe('function');
});
it('should only call once when invoked multiple times within delay', () => {
let callCount = 0;
const fn = debounce(() => {
callCount++;
}, 100);
fn();
const firstCall = callCount;
fn();
fn();
expect(callCount).toBe(firstCall);
});
});
describe('clone', () => {
it('should deep clone objects', () => {
const original = { a: 1, b: { c: 2 } };
const cloned = clone(original);
expect(cloned).toEqual(original);
expect(cloned).not.toBe(original);
expect(cloned.b).not.toBe(original.b);
});
it('should handle arrays', () => {
const original = [1, 2, [3, 4]];
const cloned = clone(original);
expect(cloned).toEqual(original);
expect(cloned).not.toBe(original);
expect(cloned[2]).not.toBe(original[2]);
});
it('should handle primitives', () => {
expect(clone(42)).toBe(42);
expect(clone('hello')).toBe('hello');
expect(clone(true)).toBe(true);
expect(clone(null)).toBe(null);
});
});
});
+72
View File
@@ -0,0 +1,72 @@
import { isObject, mergeDeep } from '$lib/helpers/deepMerge';
import { describe, expect, it } from 'vitest';
describe('deepMerge', () => {
describe('isObject', () => {
it('should return true for plain objects', () => {
expect(isObject({})).toBe(true);
expect(isObject({ a: 1 })).toBe(true);
});
it('should return false for non-objects', () => {
expect(isObject([])).toBe(false);
expect(isObject('string')).toBe(false);
expect(isObject(42)).toBe(false);
expect(isObject(undefined)).toBe(false);
});
});
describe('mergeDeep', () => {
it('should merge two flat objects', () => {
const target = { a: 1, b: 2 };
const source = { b: 3, c: 4 };
const result = mergeDeep(target, source);
expect(result).toEqual({ a: 1, b: 3, c: 4 });
});
it('should deeply merge nested objects', () => {
const target = { a: { x: 1 }, b: { y: 2 } };
const source = { a: { y: 2 }, c: { z: 3 } };
const result = mergeDeep(target, source);
expect(result).toEqual({
a: { x: 1, y: 2 },
b: { y: 2 },
c: { z: 3 }
});
});
it('should handle multiple sources', () => {
const target = { a: 1 };
const source1 = { b: 2 };
const source2 = { c: 3 };
const result = mergeDeep(target, source1, source2);
expect(result).toEqual({ a: 1, b: 2, c: 3 });
});
it('should return target if no sources provided', () => {
const target = { a: 1 };
const result = mergeDeep(target);
expect(result).toBe(target);
});
it('should overwrite non-object values', () => {
const target = { a: { b: 1 } };
const source = { a: 'string' };
const result = mergeDeep(target, source);
expect(result.a).toBe('string');
});
it('should handle arrays by replacing', () => {
const target = { a: [1, 2] };
const source = { a: [3, 4] };
const result = mergeDeep(target, source);
expect(result.a).toEqual([3, 4]);
});
});
});
+36 -1
View File
@@ -1,5 +1,37 @@
import { browser } from '$app/environment';
function mergeRecursive<T>(current: T, initial: T): T {
if (typeof initial === 'number') {
if (typeof current === 'number') return current;
return initial;
}
if (typeof initial === 'boolean') {
if (typeof current === 'boolean') return current;
return initial;
}
if (Array.isArray(initial)) {
if (Array.isArray(current)) return current;
return initial;
}
if (typeof initial === 'object' && initial) {
const merged = initial;
if (typeof current === 'object' && current) {
for (const key of Object.keys(initial)) {
if (key in current) {
// @ts-expect-error It's safe dont worry about it
merged[key] = mergeRecursive(current[key], initial[key]);
}
}
}
return merged;
}
return current;
}
export class LocalStore<T> {
value = $state<T>() as T;
key = '';
@@ -10,7 +42,10 @@ export class LocalStore<T> {
if (browser) {
const item = localStorage.getItem(key);
if (item) this.value = this.deserialize(item);
if (item) {
const storedValue = this.deserialize(item);
this.value = mergeRecursive(storedValue, value);
}
}
$effect.root(() => {
+15
View File
@@ -0,0 +1,15 @@
export const debugNode = {
id: '__internal/node/debug',
meta: {
title: 'Debug'
},
inputs: {
input: {
type: '*',
label: ''
}
},
execute(_data: Int32Array): Int32Array {
return _data;
}
} as const;
+14
View File
@@ -0,0 +1,14 @@
export const groupNode = {
id: '__internal/group/instance',
meta: { title: 'Group' },
inputs: {
groupId: {
label: '',
type: 'select',
values: []
}
},
execute(_data: Int32Array): Int32Array {
return _data;
}
} as const;
@@ -15,8 +15,15 @@ export class RemoteNodeRegistry implements NodeRegistry {
constructor(
private url: string,
public cache?: AsyncCache<ArrayBuffer | string>
) {}
public cache?: AsyncCache<ArrayBuffer | string>,
nodes?: NodeDefinition[]
) {
if (nodes?.length) {
for (const node of nodes) {
this.nodes.set(node.id, node);
}
}
}
async fetchJson(url: string, skipCache = false) {
const finalUrl = `${this.url}/${url}`;
@@ -81,6 +88,7 @@ export class RemoteNodeRegistry implements NodeRegistry {
}
async fetchNodeDefinition(nodeId: `${string}/${string}/${string}`) {
if (nodeId.startsWith('__internal/')) return;
return this.fetchJson(`nodes/${nodeId}.json`);
}
@@ -102,6 +110,8 @@ export class RemoteNodeRegistry implements NodeRegistry {
return this.nodes.get(id)!;
}
if (id.startsWith('__internal/')) return;
const wasmBuffer = await this.fetchNodeWasm(id);
try {
+1 -1
View File
@@ -86,7 +86,7 @@
position: absolute;
}
svg {
height: 124px;
height: 126px;
margin: 24px 0px;
border-top: solid thin var(--color-outline);
border-bottom: solid thin var(--color-outline);
@@ -1,13 +1,13 @@
<script lang="ts">
import { defaultPlant, lottaFaces, plant } from '$lib/graph-templates';
import { defaultPlant, lottaFaces, plant, simple } from '$lib/graph-templates';
import type { Graph } from '$lib/types';
import { Button, ConfirmDialog, InputSelect, Spinner } from '@nodarium/ui';
import type { ProjectManager } from './project-manager.svelte';
const { projectManager } = $props<{ projectManager: ProjectManager }>();
let showNewProject = $state(false);
let newProjectName = $state('');
let selectedTemplate = $state('defaultPlant');
const templates = [
{
@@ -16,71 +16,70 @@
graph: defaultPlant as unknown as Graph
},
{ name: 'Plant', value: 'plant', graph: plant as unknown as Graph },
{ name: 'Simple', value: 'simple', graph: simple as unknown as Graph },
{
name: 'Lotta Faces',
value: 'lottaFaces',
graph: lottaFaces as unknown as Graph
}
];
let selectedTemplateIndex = $state(0);
function handleCreate() {
const template = templates.find((t) => t.value === selectedTemplate) || templates[0];
const template = templates[selectedTemplateIndex] || templates[0];
projectManager.handleCreateProject(template.graph, newProjectName);
newProjectName = '';
showNewProject = false;
}
let pendingDeleteId = $state<number | null>(null);
let confirmOpen = $state(false);
function requestDelete(id: number, e: MouseEvent) {
e.stopPropagation();
pendingDeleteId = id;
confirmOpen = true;
}
function confirmDelete() {
if (pendingDeleteId !== null) {
projectManager.handleDeleteProject(pendingDeleteId);
pendingDeleteId = null;
}
}
</script>
<header class="flex justify-between px-4 h-[70px] border-b-1 border-outline items-center">
<header class="flex justify-between px-4 h-[70px] border-b-1 border-outline items-center bg-layer-2">
<h3>Project</h3>
<button
class="px-3 py-1 bg-layer-0 rounded"
onclick={() => (showNewProject = !showNewProject)}
>
New
</button>
<Button onclick={() => (showNewProject = !showNewProject)}>New</Button>
</header>
{#if showNewProject}
<div class="flex flex-col px-4 py-3 border-b-1 border-outline gap-2">
<div class="flex flex-col px-4 py-3.5 mt-[1px] border-b-1 border-outline gap-3">
<input
type="text"
bind:value={newProjectName}
placeholder="Project name"
class="w-full px-2 py-2 bg-gray-800 border border-gray-700 rounded"
class="w-full px-2 py-2 bg-layer-2 rounded"
onkeydown={(e) => e.key === 'Enter' && handleCreate()}
/>
<select
bind:value={selectedTemplate}
class="w-full px-2 py-2 bg-gray-800 border border-gray-700 rounded"
>
{#each templates as template (template.name)}
<option value={template.value}>{template.name}</option>
{/each}
</select>
<button
class="cursor-pointer self-end px-3 py-1 bg-blue-600 rounded"
onclick={() => handleCreate()}
>
Create
</button>
<InputSelect options={templates.map(t => t.name)} bind:value={selectedTemplateIndex} />
<Button variant="primary" class="self-end" onclick={() => handleCreate()}>Create</Button>
</div>
{/if}
<div class="p-4 text-white min-h-screen">
{#if projectManager.loading}
<p>Loading...</p>
{/if}
<ul class="space-y-2">
<div class="text-white min-h-screen">
<ul>
{#each projectManager.projects as project (project.id)}
<li>
<div
class="
w-full text-left px-3 py-2 rounded cursor-pointer {projectManager
h-[70px] border-b-1 border-b-outline
flex
w-full text-left px-3 py-2 cursor-pointer {projectManager
.activeProjectId.value === project.id
? 'bg-blue-600'
: 'bg-gray-800 hover:bg-gray-700'}
? 'border-l-2 border-l-selected pl-2.5!'
: ''}
"
onclick={() => projectManager.handleSelectProject(project.id!)}
role="button"
@@ -89,19 +88,38 @@
e.key === 'Enter'
&& projectManager.handleSelectProject(project.id!)}
>
<div class="flex justify-between items-center">
<div class="flex justify-between items-center grow">
<span>{project.meta?.title || 'Untitled'}</span>
<button
class="text-red-400 hover:text-red-300"
onclick={() => {
projectManager.handleDeleteProject(project.id!);
}}
class="opacity-20 hover:opacity-70 transition-opacity cursor-pointer p-1 rounded text-red-400"
onclick={(e) => requestDelete(project.id!, e)}
aria-label="Delete project"
>
×
<span class="i-[tabler--trash] w-4 h-4 block"></span>
</button>
</div>
</div>
</li>
{:else}
{#if projectManager.loading}
<div class="flex items-center gap-2 p-4">
<Spinner size={12} />
<p>Loading</p>
</div>
{:else}
<li class="px-4 py-8 text-center opacity-40 text-sm">
No projects yet.<br />Press <b>New</b> to create one.
</li>
{/if}
{/each}
</ul>
</div>
<ConfirmDialog
bind:open={confirmOpen}
title="Delete project?"
message="This cannot be undone. The project and all its data will be permanently removed."
confirmLabel="Delete"
cancelLabel="Cancel"
onconfirm={confirmDelete}
/>
@@ -10,7 +10,9 @@ export class ProjectManager {
'node.activeProjectId',
undefined
);
public readonly loading = $derived(this.graph?.id !== this.activeProjectId.value);
public readonly loading = $derived(
this.projects.length && this.graph?.id !== this.activeProjectId.value
);
constructor() {
this.init();
@@ -54,7 +56,7 @@ export class ProjectManager {
g.id = id;
if (!g.meta) g.meta = {};
if (!g.meta.title) g.meta.title = title;
g.meta.title = title;
db.saveGraph(g);
this.projects = [...this.projects, g];
+19
View File
@@ -0,0 +1,19 @@
<script lang="ts">
import { T } from '@threlte/core';
import type { Group } from 'three';
import { updateDebugScene } from './debug';
type Props = {
debugData?: Record<number, { type: string; data: Int32Array }>;
};
let group = $state<Group>(null!);
const { debugData }: Props = $props();
$effect(() => {
if (!group || !debugData) return;
updateDebugScene(group, $state.snapshot(debugData));
});
</script>
<T.Group bind:ref={group} />
+9 -53
View File
@@ -1,33 +1,26 @@
<script lang="ts">
import { colors } from '$lib/graph-interface/graph/colors.svelte';
import { T, useTask, useThrelte } from '@threlte/core';
import { Grid, MeshLineGeometry, MeshLineMaterial, Text } from '@threlte/extras';
import {
Box3,
type BufferGeometry,
type Group,
Mesh,
MeshBasicMaterial,
Vector3,
type Vector3Tuple
} from 'three';
import { Grid } from '@threlte/extras';
import { Box3, type BufferGeometry, type Group, Mesh, MeshBasicMaterial, Vector3 } from 'three';
import { appSettings } from '../settings/app-settings.svelte';
import Camera from './Camera.svelte';
import Debug from './Debug.svelte';
const { renderStage, invalidate: _invalidate } = useThrelte();
type Props = {
fps: number[];
lines: Vector3[][];
debugData?: Record<number, { type: string; data: Int32Array }>;
scene: Group;
centerCamera: boolean;
};
let {
lines,
centerCamera,
fps = $bindable(),
scene = $bindable()
scene = $bindable(),
debugData
}: Props = $props();
let geometries = $state.raw<BufferGeometry[]>([]);
@@ -91,18 +84,12 @@
});
_invalidate();
});
function getPosition(geo: BufferGeometry, i: number) {
return [
geo.attributes.position.array[i],
geo.attributes.position.array[i + 1],
geo.attributes.position.array[i + 2]
] as Vector3Tuple;
}
</script>
<Camera {center} {centerCamera} />
<Debug {debugData} />
{#if appSettings.value.showGrid}
<Grid
cellColor={colors['outline']}
@@ -116,35 +103,4 @@
fadeOrigin={new Vector3(0, 0, 0)}
/>
{/if}
<T.Group>
{#if geometries}
{#each geometries as geo (geo.id)}
{#if appSettings.value.debug.showIndices}
{#each geo.attributes.position.array, i (i)}
{#if i % 3 === 0}
<Text fontSize={0.25} position={getPosition(geo, i)} />
{/if}
{/each}
{/if}
{#if appSettings.value.debug.showVertices}
<T.Points visible={true}>
<T is={geo} />
<T.PointsMaterial size={0.25} />
</T.Points>
{/if}
{/each}
{/if}
<T.Group bind:ref={scene}></T.Group>
</T.Group>
{#if appSettings.value.debug.showStemLines && lines}
{#each lines as line (line[0].x + '-' + line[0].y + '-' + '' + line[0].z)}
<T.Mesh>
<MeshLineGeometry points={line} />
<MeshLineMaterial width={0.1} color="red" depthTest={false} />
</T.Mesh>
{/each}
{/if}
<T.Group bind:ref={scene}></T.Group>
+13 -35
View File
@@ -1,10 +1,10 @@
<script lang="ts">
import SmallPerformanceViewer from '$lib/performance/SmallPerformanceViewer.svelte';
import { appSettings } from '$lib/settings/app-settings.svelte';
import { decodeFloat, splitNestedArray } from '@nodarium/utils';
import { splitNestedArray } from '@nodarium/utils';
import type { PerformanceStore } from '@nodarium/utils';
import { Canvas } from '@threlte/core';
import { Vector3 } from 'three';
import { DoubleSide } from 'three';
import { type Group, MeshMatcapMaterial, TextureLoader } from 'three';
import { createGeometryPool, createInstancedGeometryPool } from './geometryPool';
import Scene from './Scene.svelte';
@@ -14,7 +14,8 @@
matcap.colorSpace = 'srgb';
const material = new MeshMatcapMaterial({
color: 0xffffff,
matcap
matcap,
side: DoubleSide
});
let sceneComponent = $state<ReturnType<typeof Scene>>();
@@ -22,6 +23,11 @@
let geometryPool: ReturnType<typeof createGeometryPool>;
let instancePool: ReturnType<typeof createInstancedGeometryPool>;
export function invalidate() {
sceneComponent?.invalidate();
}
export function updateGeometries(inputs: Int32Array[], group: Group) {
geometryPool = geometryPool || createGeometryPool(group, material);
instancePool = instancePool || createInstancedGeometryPool(group, material);
@@ -39,44 +45,16 @@
scene: Group;
centerCamera: boolean;
perf: PerformanceStore;
debugData?: Record<number, { type: string; data: Int32Array }>;
};
let { scene = $bindable(), centerCamera, perf }: Props = $props();
let lines = $state<Vector3[][]>([]);
function createLineGeometryFromEncodedData(encodedData: Int32Array) {
const positions: Vector3[] = [];
const amount = (encodedData.length - 1) / 4;
for (let i = 0; i < amount; i++) {
const x = decodeFloat(encodedData[2 + i * 4 + 0]);
const y = decodeFloat(encodedData[2 + i * 4 + 1]);
const z = decodeFloat(encodedData[2 + i * 4 + 2]);
positions.push(new Vector3(x, y, z));
}
return positions;
}
let { scene = $bindable(), centerCamera, debugData, perf }: Props = $props();
export const update = function update(result: Int32Array) {
perf.addPoint('split-result');
const inputs = splitNestedArray(result);
perf.endPoint();
if (appSettings.value.debug.showStemLines) {
perf.addPoint('create-lines');
lines = inputs
.map((input) => {
if (input[0] === 0) {
return createLineGeometryFromEncodedData(input);
}
})
.filter(Boolean) as Vector3[][];
perf.endPoint();
}
perf.addPoint('update-geometries');
const { totalVertices, totalFaces } = updateGeometries(inputs, scene);
@@ -88,7 +66,7 @@
};
</script>
{#if appSettings.value.debug.showPerformancePanel}
{#if appSettings.value.debug.advancedMode}
<SmallPerformanceViewer {fps} store={perf} />
{/if}
@@ -96,8 +74,8 @@
<Canvas>
<Scene
bind:this={sceneComponent}
{lines}
{centerCamera}
{debugData}
bind:scene
bind:fps
/>
+90
View File
@@ -0,0 +1,90 @@
import { splitNestedArray } from '@nodarium/utils';
import {
BufferGeometry,
type Group,
InstancedMesh,
Line,
LineBasicMaterial,
Matrix4,
MeshBasicMaterial,
SphereGeometry,
Vector3
} from 'three';
function writePath(scene: Group, data: Int32Array): Vector3[] {
const positions: Vector3[] = [];
const f32 = new Float32Array(data.buffer);
for (let i = 2; i + 2 < f32.length; i += 4) {
const vec = new Vector3(f32[i], f32[i + 1], f32[i + 2]);
positions.push(vec);
}
// Path line
if (positions.length >= 2) {
const geometry = new BufferGeometry().setFromPoints(positions);
const line = new Line(
geometry,
new LineBasicMaterial({ color: 0xff0000, depthTest: false })
);
scene.add(line);
}
// Instanced spheres at points
if (positions.length > 0) {
const sphereGeometry = new SphereGeometry(0.05, 8, 8); // keep low-poly
const sphereMaterial = new MeshBasicMaterial({
color: 0xff0000,
depthTest: false
});
const spheres = new InstancedMesh(
sphereGeometry,
sphereMaterial,
positions.length
);
const matrix = new Matrix4();
for (let i = 0; i < positions.length; i++) {
matrix.makeTranslation(
positions[i].x,
positions[i].y,
positions[i].z
);
spheres.setMatrixAt(i, matrix);
}
spheres.instanceMatrix.needsUpdate = true;
scene.add(spheres);
}
return positions;
}
function clearGroup(group: Group) {
for (let i = group.children.length - 1; i >= 0; i--) {
const child = group.children[i];
group.remove(child);
// optional but correct: free GPU memory
// @ts-expect-error three.js runtime fields
child.geometry?.dispose?.();
// @ts-expect-error three.js runtime fields
child.material?.dispose?.();
}
}
export function updateDebugScene(
group: Group,
data: Record<number, { type: string; data: Int32Array }>
) {
clearGroup(group);
return Object.entries(data || {}).map(([, d]) => {
switch (d.type) {
case 'path':
splitNestedArray(d.data)
.forEach(p => writePath(group, p));
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return (_g: Group) => {};
}).flat();
}
@@ -80,7 +80,6 @@ export function createGeometryPool(parentScene: Group, material: Material) {
}
const normals = new Float32Array(data.buffer, index * 4, vertexCount * 3);
index = index + vertexCount * 3;
if (
geometry.userData?.faceCount !== faceCount
@@ -0,0 +1,164 @@
import type { Graph } from '@nodarium/types';
import { describe, expect, it } from 'vitest';
import { expandGroups } from './runtime-executor';
// Helpers to build minimal serialized nodes/edges
function node(id: number, type: string, props?: Record<string, number>) {
return {
id,
type: type as Graph['nodes'][0]['type'],
position: [0, 0] as [number, number],
...(props ? { props } : {})
};
}
function edge(
from: number,
fromSocket: number,
to: number,
toSocket: string
): [number, number, number, string] {
return [from, fromSocket, to, toSocket];
}
describe('expandGroups', () => {
it('returns graph unchanged when there are no groups', () => {
const graph: Graph = {
id: 1,
nodes: [node(0, 'test/node/output'), node(1, 'test/node/input')],
edges: [edge(0, 0, 1, 'value')],
groups: []
};
const result = expandGroups(graph);
expect(result.nodes.length).toBe(2);
expect(result.edges.length).toBe(1);
expect(result).toBe(graph); // same reference — no copy needed
});
it('expands a simple group: A → [B] → C rewires to A → B → C', () => {
// IDs: A=1, B=2, C=3, groupNode=4, group.id=5, inputBoundary=6, outputBoundary=7
const groupId = 5;
const groupNodeId = 4;
const remappedB = (groupNodeId + 1) * 1_000_000 + 2; // 5_000_002
const graph: Graph = {
id: 1,
nodes: [
node(1, 'test/node/output'),
node(groupNodeId, '__internal/group/instance', { groupId }),
node(3, 'test/node/input')
],
edges: [
edge(1, 0, groupNodeId, 'input_0'), // A → group
edge(groupNodeId, 0, 3, 'value') // group → C
],
groups: [{
id: groupId,
nodes: [
node(6, '__internal/group/input'),
node(2, 'test/node/output'),
node(7, '__internal/group/output')
],
edges: [
edge(6, 0, 2, 'input'), // inputBoundary → B
edge(2, 0, 7, 'Out') // B → outputBoundary
],
inputs: { input_0: { type: 'float' } },
outputs: [{ type: 'float', label: 'Output 0' }]
}]
};
const result = expandGroups(graph);
const ids = result.nodes.map(n => n.id);
expect(ids).not.toContain(groupNodeId);
expect(ids).toContain(remappedB);
expect(ids).toContain(1); // A
expect(ids).toContain(3); // C
expect(result.nodes.length).toBe(3); // A, B(remapped), C
expect(result.edges).toContainEqual(edge(1, 0, remappedB, 'input')); // A → B
expect(result.edges).toContainEqual(edge(remappedB, 0, 3, 'value')); // B → C
expect(result.edges.length).toBe(2);
});
it('expands a group with two internal nodes (B→D) and preserves the internal edge', () => {
// A → [B → D] → C
const groupId = 10;
const groupNodeId = 5;
const remappedB = (groupNodeId + 1) * 1_000_000 + 1; // 6_000_001
const remappedD = (groupNodeId + 1) * 1_000_000 + 2; // 6_000_002
const graph: Graph = {
id: 1,
nodes: [
node(0, 'test/node/output'),
node(groupNodeId, '__internal/group/instance', { groupId }),
node(9, 'test/node/input')
],
edges: [
edge(0, 0, groupNodeId, 'input_0'),
edge(groupNodeId, 0, 9, 'value')
],
groups: [{
id: groupId,
nodes: [
node(3, '__internal/group/input'),
node(1, 'test/node/output'), // B
node(2, 'test/node/output'), // D
node(4, '__internal/group/output')
],
edges: [
edge(3, 0, 1, 'input'), // inputBoundary → B
edge(1, 0, 2, 'input'), // B → D (internal)
edge(2, 0, 4, 'Out') // D → outputBoundary
],
inputs: { input_0: { type: 'float' } },
outputs: [{ type: 'float' }]
}]
};
const result = expandGroups(graph);
expect(result.nodes.map(n => n.id)).not.toContain(groupNodeId);
expect(result.nodes.map(n => n.id)).toContain(remappedB);
expect(result.nodes.map(n => n.id)).toContain(remappedD);
expect(result.edges).toContainEqual(edge(0, 0, remappedB, 'input')); // A → B
expect(result.edges).toContainEqual(edge(remappedB, 0, remappedD, 'input')); // B → D (internal)
expect(result.edges).toContainEqual(edge(remappedD, 0, 9, 'value')); // D → C
expect(result.edges.length).toBe(3);
});
it('expands a group with no external connections (isolated)', () => {
const groupId = 20;
const groupNodeId = 1;
const remappedB = (groupNodeId + 1) * 1_000_000 + 2; // 2_000_002
const graph: Graph = {
id: 1,
nodes: [node(groupNodeId, '__internal/group/instance', { groupId })],
edges: [],
groups: [{
id: groupId,
nodes: [
node(3, '__internal/group/input'),
node(2, 'test/node/output'),
node(4, '__internal/group/output')
],
edges: [
edge(3, 0, 2, 'input'),
edge(2, 0, 4, 'Out')
]
}]
};
const result = expandGroups(graph);
expect(result.nodes.map(n => n.id)).not.toContain(groupNodeId);
expect(result.nodes.map(n => n.id)).toContain(remappedB);
expect(result.edges.length).toBe(0);
});
});
+153 -7
View File
@@ -18,6 +18,113 @@ import type { RuntimeNode } from './types';
const log = createLogger('runtime-executor');
log.mute();
export function expandGroups(graph: Graph): Graph {
if (!graph.groups || graph.groups.length === 0) return graph;
function groupContainsSelf(groupId: number, visited = new Set<number>()): boolean {
if (visited.has(groupId)) return true;
visited.add(groupId);
const group = graph.groups!.find(g => g.id === groupId);
if (!group) return false;
for (const n of group.nodes) {
if (n.type === '__internal/group/instance') {
const nestedId = n.props?.groupId as number | undefined;
if (nestedId !== undefined && groupContainsSelf(nestedId, visited)) return true;
}
}
return false;
}
for (const group of graph.groups) {
if (groupContainsSelf(group.id)) {
throw new Error(`Circular group reference: group ${group.id} contains itself`);
}
}
const nodes = [...graph.nodes];
let edges = [...graph.edges];
let changed = true;
while (changed) {
changed = false;
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i];
if (node.type !== '__internal/group/instance') continue;
const groupId = node.props?.groupId as number | undefined;
if (groupId === undefined) continue;
const group = graph.groups.find(g => g.id === groupId);
if (!group) continue;
changed = true;
const ID_OFFSET = (node.id + 1) * 1_000_000;
const idMap = new Map<number, number>();
const inputBoundary = group.nodes.find(n => n.type === '__internal/group/input');
const outputBoundary = group.nodes.find(n => n.type === '__internal/group/output');
const realNodes = group.nodes.filter(
n => n.type !== '__internal/group/input' && n.type !== '__internal/group/output'
);
for (const n of realNodes) idMap.set(n.id, ID_OFFSET + n.id);
const incomingExternal = edges.filter(e => e[2] === node.id);
const outgoingExternal = edges.filter(e => e[0] === node.id);
const newEdges: Graph['edges'] = [];
// external_source → [inputBoundary →] internal_target
//
// External socket names are "input_N" where N equals the input boundary's
// output index. Match each external edge only to the internal edges that
// originate from that specific output slot — not a cartesian product of all.
if (inputBoundary) {
const fromInput = group.edges.filter(e => e[0] === inputBoundary.id);
for (const extEdge of incomingExternal) {
const inputIndex = parseInt((extEdge[3] as string).replace('input_', ''), 10);
const matchingIntEdges = fromInput.filter(e => e[1] === inputIndex);
for (const intEdge of matchingIntEdges) {
const toId = idMap.get(intEdge[2]);
if (toId !== undefined) newEdges.push([extEdge[0], extEdge[1], toId, intEdge[3]]);
}
}
}
// internal_source → [outputBoundary →] external_target
if (outputBoundary) {
const toOutput = group.edges.filter(e => e[2] === outputBoundary.id);
for (const extEdge of outgoingExternal) {
for (const intEdge of toOutput) {
const fromId = idMap.get(intEdge[0]);
if (fromId !== undefined) newEdges.push([fromId, intEdge[1], extEdge[2], extEdge[3]]);
}
}
}
// internal-to-internal edges (skip boundary edges)
for (const e of group.edges) {
if (e[0] === inputBoundary?.id || e[2] === outputBoundary?.id) continue;
const fromId = idMap.get(e[0]);
const toId = idMap.get(e[2]);
if (fromId !== undefined && toId !== undefined) newEdges.push([fromId, e[1], toId, e[3]]);
}
nodes.splice(i, 1);
for (const n of realNodes) nodes.push({ ...n, id: idMap.get(n.id)! });
edges = edges.filter(e => e[0] !== node.id && e[2] !== node.id);
edges.push(...newEdges);
break;
}
}
return { ...graph, nodes, edges };
}
function getValue(input: NodeInput, value?: unknown) {
if (value === undefined && 'value' in input) {
value = input.value;
@@ -28,7 +135,7 @@ function getValue(input: NodeInput, value?: unknown) {
}
if (Array.isArray(value)) {
if (input.type === 'vec3') {
if (input.type === 'vec3' || input.type === 'shape') {
return [
0,
value.length + 1,
@@ -59,6 +166,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
private definitionMap: Map<string, NodeDefinition> = new Map();
private seed = Math.floor(Math.random() * 100000000);
private debugData: Record<number, { type: string; data: Int32Array }> = {};
perf?: PerformanceStore;
@@ -74,7 +182,11 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
throw new Error('Node registry is not ready');
}
await this.registry.load(graph.nodes.map((node) => node.type));
// Only load non-virtual types (virtual nodes are resolved locally)
const nonVirtualTypes = graph.nodes
.map(node => node.type)
.filter(t => !t.startsWith('__internal/'));
await this.registry.load(nonVirtualTypes);
const typeMap = new Map<string, NodeDefinition>();
for (const node of graph.nodes) {
@@ -124,10 +236,10 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
}
}
const nodes = [];
const nodes = new Map<number, RuntimeNode>();
// loop through all the nodes and assign each nodes its depth
const stack = [outputNode];
const stack = [outputNode, ...graphNodes.filter(n => n.type.endsWith('/debug'))];
while (stack.length) {
const node = stack.pop();
if (!node) continue;
@@ -136,16 +248,34 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
parent.state.depth = node.state.depth + 1;
stack.push(parent);
}
nodes.push(node);
nodes.set(node.id, node);
}
return [outputNode, nodes] as const;
for (const node of graphNodes) {
if (node.type.endsWith('/debug')) {
node.state = node.state || {};
const parent = node.state.parents[0];
if (parent) {
node.state.depth = parent.state.depth - 1;
parent.state.debugNode = true;
}
nodes.set(node.id, node);
}
}
const _nodes = [...nodes.values()];
return [outputNode, _nodes] as const;
}
async execute(graph: Graph, settings: Record<string, unknown>) {
this.perf?.addPoint('runtime');
let a = performance.now();
this.debugData = {};
// Expand group nodes into a flat graph before execution
graph = expandGroups(graph);
// Then we add some metadata to the graph
const [outputNode, nodes] = await this.addMetaData(graph);
@@ -203,7 +333,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
if (inputNode) {
if (results[inputNode.id] === undefined) {
throw new Error(
`Node ${node.type} is missing input from node ${inputNode.type}`
`Node ${node.type} is missing input from node ${inputNode.type}#${inputNode.id}`
);
}
return results[inputNode.id];
@@ -237,6 +367,12 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
log.log(`Using cached value for ${node_type.id || node.id}`);
this.perf?.addPoint('cache-hit', 1);
results[node.id] = cachedValue as Int32Array;
if (node.state.debugNode && node_type.outputs) {
this.debugData[node.id] = {
type: node_type.outputs[0],
data: cachedValue
};
}
continue;
}
this.perf?.addPoint('cache-hit', 0);
@@ -245,6 +381,12 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
log.log(`Inputs:`, inputs);
a = performance.now();
results[node.id] = node_type.execute(encoded_inputs);
if (node.state.debugNode && node_type.outputs) {
this.debugData[node.id] = {
type: node_type.outputs[0],
data: results[node.id]
};
}
log.log('Executed', node.type, node.id);
b = performance.now();
@@ -273,6 +415,10 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
return res as unknown as Int32Array;
}
getDebugData() {
return this.debugData;
}
getPerformanceData() {
return this.perf?.get();
}
+1
View File
@@ -5,6 +5,7 @@ type RuntimeState = {
parents: RuntimeNode[];
children: RuntimeNode[];
inputNodes: Record<string, RuntimeNode>;
debugNode?: boolean;
};
export type RuntimeNode = SerializedNode & { state: RuntimeState };
@@ -1,3 +1,4 @@
import { debugNode } from '$lib/node-registry/debugNode';
import { IndexDBCache, RemoteNodeRegistry } from '$lib/node-registry/index';
import type { Graph } from '@nodarium/types';
import { createPerformanceStore } from '@nodarium/utils';
@@ -5,7 +6,7 @@ import { MemoryRuntimeExecutor } from './runtime-executor';
import { MemoryRuntimeCache } from './runtime-executor-cache';
const indexDbCache = new IndexDBCache('node-registry');
const nodeRegistry = new RemoteNodeRegistry('', indexDbCache);
const nodeRegistry = new RemoteNodeRegistry('', indexDbCache, [debugNode]);
const cache = new MemoryRuntimeCache();
const executor = new MemoryRuntimeExecutor(nodeRegistry, cache);
@@ -43,3 +44,7 @@ export async function executeGraph(
export function getPerformanceData() {
return performanceStore.get();
}
export function getDebugData() {
return executor.getDebugData();
}
@@ -6,12 +6,15 @@ export class WorkerRuntimeExecutor implements RuntimeExecutor {
new URL(`./worker-runtime-executor-backend.ts`, import.meta.url)
);
async execute(graph: Graph, settings: Record<string, unknown>) {
execute(graph: Graph, settings: Record<string, unknown>) {
return this.worker.executeGraph(graph, settings);
}
async getPerformanceData() {
getPerformanceData() {
return this.worker.getPerformanceData();
}
getDebugData() {
return this.worker.getDebugData();
}
set useRuntimeCache(useCache: boolean) {
this.worker.setUseRuntimeCache(useCache);
}
+20 -18
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { localState } from '$lib/helpers/localState.svelte';
import type { NodeInput } from '@nodarium/types';
import Input from '@nodarium/ui';
import Input, { Button as UiButton } from '@nodarium/ui';
import { onMount } from 'svelte';
import NestedSettings from './NestedSettings.svelte';
@@ -28,13 +28,14 @@
key?: string;
value: SettingsValue;
type: SettingsType;
onButtonClick?: (id: string) => void;
depth?: number;
};
// Local persistent state for <details> sections
const openSections = localState<Record<string, boolean>>('open-details', {});
let { id, key = '', value = $bindable(), type, depth = 0 }: Props = $props();
let { id, key = '', value = $bindable(), type, onButtonClick, depth = 0 }: Props = $props();
function isNodeInput(v: SettingsNode | undefined): v is InputType {
return !!v && typeof v === 'object' && 'type' in v;
@@ -56,6 +57,10 @@
return 0;
}
if (Array.isArray(inputValue) && node.type === 'vec3') {
return inputValue;
}
// If the component is supplied with a default value use that
if (inputValue !== undefined && typeof inputValue !== 'object') {
return inputValue;
@@ -98,16 +103,11 @@
&& typeof internalValue === 'number'
) {
value[key] = node?.options?.[internalValue];
} else if (internalValue) {
} else if (internalValue !== undefined) {
value[key] = internalValue;
}
});
function handleClick() {
const callback = value[key] as unknown as () => void;
callback();
}
onMount(() => {
open = openSections.value[id];
@@ -124,12 +124,11 @@
{#if key && isNodeInput(type?.[key])}
{@const inputType = type[key]}
<!-- Leaf input -->
<div class="input input-{inputType.type}" class:first-level={depth === 1}>
{#if inputType.type === 'button'}
<button onclick={handleClick}>
<UiButton onclick={() => onButtonClick?.(id)}>
{inputType.label || key}
</button>
</UiButton>
{:else}
{#if inputType.label !== ''}
<label for={id}>{inputType.label || key}</label>
@@ -138,9 +137,9 @@
{/if}
</div>
{:else if depth === 0}
<!-- Root: iterate over top-level keys -->
{#each Object.keys(type ?? {}).filter((k) => k !== 'title') as childKey (childKey)}
<NestedSettings
{onButtonClick}
id={`${id}.${childKey}`}
key={childKey}
bind:value
@@ -150,7 +149,6 @@
{/each}
<hr />
{:else if key && type?.[key]}
<!-- Group -->
{#if depth > 0}
<hr />
{/if}
@@ -159,6 +157,7 @@
<div class="content">
{#each Object.keys(type[key] as SettingsGroup).filter((k) => k !== 'title') as childKey (childKey)}
<NestedSettings
{onButtonClick}
id={`${id}.${childKey}`}
key={childKey}
bind:value={value[key] as SettingsValue}
@@ -205,12 +204,19 @@
.input-boolean > label {
order: 2;
font-size: 1em;
opacity: 0.9;
}
label {
font-size: 0.8em;
opacity: 0.7;
}
.first-level.input {
padding-left: 1em;
padding-right: 1em;
padding-bottom: 1px;
padding-bottom: 0.5px;
gap: 3px;
}
@@ -218,10 +224,6 @@
gap: 10px;
}
button {
cursor: pointer;
}
hr {
margin: 0;
left: 0;
+14 -34
View File
@@ -6,6 +6,7 @@ const themes = [
'catppuccin',
'solarized',
'high-contrast',
'high-contrast-light',
'nord',
'dracula'
] as const;
@@ -27,12 +28,17 @@ export const AppSettingTypes = {
label: 'Center Camera',
value: true
},
clippy: {
type: 'button',
label: '🌱 Open Planty'
},
nodeInterface: {
title: 'Node Interface',
showNodeGrid: {
type: 'boolean',
label: 'Show Grid',
value: true
backgroundType: {
type: 'select',
label: 'Background',
options: ['grid', 'dots', 'none'],
value: 'grid'
},
snapToGrid: {
type: 'boolean',
@@ -57,34 +63,9 @@ export const AppSettingTypes = {
label: 'Execute in WebWorker',
value: true
},
showIndices: {
advancedMode: {
type: 'boolean',
label: 'Show Indices',
value: false
},
showPerformancePanel: {
type: 'boolean',
label: 'Show Performance Panel',
value: false
},
showBenchmarkPanel: {
type: 'boolean',
label: 'Show Benchmark Panel',
value: false
},
showVertices: {
type: 'boolean',
label: 'Show Vertices',
value: false
},
showStemLines: {
type: 'boolean',
label: 'Show Stem Lines',
value: false
},
showGraphJson: {
type: 'boolean',
label: 'Show Graph Source',
label: 'Advanced Mode',
value: false
},
cache: {
@@ -132,9 +113,8 @@ export const AppSettingTypes = {
}
} as const;
type SettingsToStore<T> = T extends { type: 'button' } ? () => void
: T extends { value: infer V } ? V extends readonly string[] ? V[number]
: V
type SettingsToStore<T> = T extends { value: infer V } ? V extends readonly string[] ? V[number]
: V
: T extends object ? {
-readonly [K in keyof T as T[K] extends object ? K : never]: SettingsToStore<T[K]>;
}
+1 -1
View File
@@ -34,7 +34,7 @@
<div class="wrapper" class:hidden>
{#if title}
<header class="bg-layer-2">
<h3 class="font-bold">{title}</h3>
<h3>{title}</h3>
</header>
{/if}
{@render children?.()}
+6 -1
View File
@@ -2,7 +2,12 @@
import { type Snippet } from 'svelte';
import { panelState as state } from './PanelState.svelte';
const { children } = $props<{ children?: Snippet }>();
// eslint-disable-next-line no-useless-assignment
let { children, open = $bindable(false) } = $props<{ children?: Snippet; open?: boolean }>();
$effect(() => {
open = !!state.activePanel.value;
});
</script>
<div class="wrapper" class:visible={state.activePanel.value}>
@@ -1,99 +0,0 @@
<script lang="ts">
import type { GraphManager } from '$lib/graph-interface/graph-manager.svelte';
import NestedSettings from '$lib/settings/NestedSettings.svelte';
import type { NodeId, NodeInput, NodeInstance } from '@nodarium/types';
type InternalNodeInput = NodeInput & {
__node_type?: NodeId;
__node_input: string;
};
type Props = {
manager: GraphManager;
node: NodeInstance;
};
const { manager, node = $bindable() }: Props = $props();
function filterInputs(inputs?: Record<string, NodeInput>) {
const _inputs = $state.snapshot(
inputs as Record<string, InternalNodeInput>
);
return Object.fromEntries(
Object.entries(structuredClone(_inputs ?? {}))
.filter(([, value]) => {
return value.hidden === true;
})
.map(([key, value]) => {
value.__node_type = node.state.type?.id;
value.__node_input = key;
return [key, value];
})
);
}
const nodeDefinition = filterInputs(node.state.type?.inputs);
type Store = Record<string, number | number[]>;
let store = $state<Store>(createStore(node?.props, nodeDefinition));
function createStore(
props: NodeInstance['props'],
inputs: Record<string, NodeInput>
): Store {
const store: Store = {};
Object.keys(inputs).forEach((key) => {
if (props) {
const value = props[key] || inputs[key].value;
if (Array.isArray(value) || typeof value === 'number') {
store[key] = value;
} else {
console.error('Wrong error');
}
}
});
return store;
}
let lastPropsHash = '';
function updateNode() {
if (!node || !store) return;
let needsUpdate = false;
Object.keys(store).forEach((_key: string) => {
node.props = node.props || {};
const key = _key as keyof typeof store;
if (node && store) {
needsUpdate = true;
const value = store[key];
if (value !== undefined) {
node.props[key] = value;
}
}
});
let propsHash = JSON.stringify(node.props);
if (propsHash === lastPropsHash) {
return;
}
lastPropsHash = propsHash;
if (needsUpdate) {
manager.save();
manager.execute();
}
}
$effect(() => {
if (store) {
updateNode();
}
});
</script>
{#if Object.keys(nodeDefinition).length}
<NestedSettings
id="activeNodeSettings"
bind:value={store}
type={nodeDefinition}
/>
{:else}
<p class="mx-4 mt-4">Node has no settings</p>
{/if}
@@ -1,26 +1,103 @@
<script lang="ts">
import type { GraphManager } from '$lib/graph-interface/graph-manager.svelte';
import type { NodeInstance } from '@nodarium/types';
import ActiveNodeSelected from './ActiveNodeSelected.svelte';
import NestedSettings from '$lib/settings/NestedSettings.svelte';
import type { NodeId, NodeInput, NodeInstance } from '@nodarium/types';
type InternalNodeInput = NodeInput & {
__node_type?: NodeId;
__node_input: string;
};
type Props = {
manager: GraphManager;
node: NodeInstance | undefined;
};
let { manager, node = $bindable() }: Props = $props();
const { manager, node = $bindable() }: Props = $props();
function filterInputs(inputs?: Record<string, NodeInput>) {
if (!node) return {};
return Object.fromEntries(
Object.entries(inputs ?? {})
.filter(([, value]) => {
return value.hidden === true;
})
.map(([key, value]) => {
const v = value as InternalNodeInput;
v.__node_type = node.state.type?.id;
v.__node_input = key;
return [key, v];
})
);
}
const nodeDefinition = node ? filterInputs(node.state.type?.inputs) : {};
type Store = Record<string, number | number[]>;
let store = $state<Store>(createStore(node?.props, nodeDefinition));
function createStore(
props: NodeInstance['props'],
inputs: Record<string, NodeInput>
): Store {
const store: Store = {};
Object.keys(inputs).forEach((key) => {
if (props) {
const value = props[key] !== undefined ? props[key] : inputs[key].value;
if (Array.isArray(value) || typeof value === 'number') {
store[key] = value;
} else if (typeof value === 'boolean') {
store[key] = value ? 1 : 0;
} else {
console.error('Wrong error', { value });
}
}
});
return store;
}
let lastPropsHash = '';
function updateNode() {
if (!node || !store) return;
let needsUpdate = false;
Object.keys(store).forEach((_key: string) => {
node.props = node.props || {};
const key = _key as keyof typeof store;
if (node && store) {
needsUpdate = true;
const value = store[key];
if (value !== undefined) {
node.props[key] = value;
}
}
});
let propsHash = JSON.stringify(node.props);
if (propsHash === lastPropsHash) {
return;
}
lastPropsHash = propsHash;
if (needsUpdate) {
manager.save();
manager.execute();
}
}
const isGroupInstance = $derived(node?.type === '__internal/group/instance');
$effect(() => {
if (store) {
updateNode();
}
});
</script>
<div class='{node?"border-l-2 pl-3.5!":""} bg-layer-2 flex items-center h-[70px] border-b-1 border-l-selected border-b-outline pl-4'>
<h3 class="font-bold">Node Settings</h3>
</div>
{#if node}
{#key node.id}
{#if node}
<ActiveNodeSelected {manager} bind:node />
{/if}
{/key}
{:else}
<p class="mx-4 mt-4">No node selected</p>
{#if !isGroupInstance && Object.keys(nodeDefinition).length}
<div class='{node?"border-l-2 pl-3.5!":""} bg-layer-2 flex items-center h-[70px] border-b-1 border-l-selected border-b-outline pl-4'>
<h3>Node Settings</h3>
</div>
<NestedSettings
id="activeNodeSettings"
bind:value={store}
type={nodeDefinition}
/>
{/if}
@@ -8,7 +8,7 @@
import { humanizeDuration } from '$lib/helpers';
import { localState } from '$lib/helpers/localState.svelte';
import Monitor from '$lib/performance/Monitor.svelte';
import { InputNumber } from '@nodarium/ui';
import { Button, InputNumber } from '@nodarium/ui';
import { writable } from 'svelte/store';
function calculateStandardDeviation(array: number[]) {
@@ -112,7 +112,7 @@
onclick={() => copyContent(result?.stdev + '')}
>(click to copy)</i>
<div>
<button onclick={() => (isRunning = false)}>reset</button>
<Button onclick={() => (isRunning = false)}>reset</Button>
</div>
{:else if isRunning}
<p>WarmUp ({$warmUp}/{warmUpAmount})</p>
@@ -126,7 +126,7 @@
{:else}
<label for="bench-samples">Samples</label>
<InputNumber id="bench-sample" bind:value={amount.value} max={1000} step={1} />
<button onclick={benchmark} disabled={isRunning}>start</button>
<Button variant="primary" onclick={benchmark} disabled={isRunning}>start</Button>
{/if}
</div>
+185
View File
@@ -0,0 +1,185 @@
<script lang="ts">
import { Details } from '@nodarium/ui';
import { micromark } from 'micromark';
type Props = {
git?: Record<string, string>;
changelog?: string;
};
const {
git,
changelog
}: Props = $props();
const typeMap = new Map([
['fix', 'border-l-red-800'],
['feat', 'border-l-green-800'],
['chore', 'border-l-gray-800'],
['docs', 'border-l-blue-800'],
['refactor', 'border-l-purple-800'],
['ci', 'border-l-red-400']
]);
function detectCommitType(commit: string) {
for (const key of typeMap.keys()) {
if (commit.startsWith(key)) {
return key;
}
}
return '';
}
function parseCommit(line?: string) {
if (!line) return;
const regex = /^\s*-\s*\[([a-f0-9]+)\]\((https?:\/\/[^\s)]+)\)\s+(.+)$/;
const match = line.match(regex);
if (!match) {
return;
}
const [, sha, link, description] = match;
return {
sha,
link,
description,
type: detectCommitType(description)
};
}
function parseChangelog(md: string) {
return md.split(/^# v/gm)
.filter(l => !!l.length)
.map(release => {
const [firstLine, ...rest] = release.split('\n');
const title = firstLine.trim();
const blocks = rest
.join('\n')
.split('---');
const commits = blocks.length > 1
? blocks
.at(-1)
?.split('\n')
?.map(line => parseCommit(line))
?.filter(c => !!c)
: [];
const description = (
blocks.length > 1
? blocks
.slice(0, -1)
.join('\n')
: blocks[0]
).trim();
return {
description: micromark(description),
title,
commits
};
});
}
</script>
<div id="changelog" class="p-4 font-mono text-text overflow-y-auto max-h-full space-y-5">
{#if git}
<div class="mb-4 p-3 bg-layer-2 text-xs rounded">
<p><strong>Branch:</strong> {git.branch}</p>
<p>
<strong>Commit:</strong>
<a
href="https://git.max-richter.dev/max/nodarium/commit/{git.sha}"
class="link"
target="_blank"
>
{git.sha.slice(0, 7)}
</a>
{git.commit_message}
</p>
<p>
<strong>Commits since last release:</strong>
{git.commits_since_last_release}
</p>
<p>
<strong>Timestamp:</strong>
{new Date(git.commit_timestamp).toLocaleString()}
</p>
</div>
{/if}
{#if changelog}
{#each parseChangelog(changelog) as release (release)}
<Details title={release.title}>
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<div id="description" class="pb-5">{@html release.description}</div>
{#if release?.commits?.length}
<Details
title="All Commits"
class="commits"
>
{#each release.commits as commit (commit)}
<p class="py-1 leading-7 text-xs border-b-1 border-l-1 border-b-outline last:border-b-0 -ml-2 pl-2 {typeMap.get(commit.type)}">
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
<a href={commit.link} class="link" target="_blank">{commit.sha}</a>
{commit.description}
</p>
{/each}
</Details>
{/if}
</Details>
{/each}
{/if}
</div>
<style lang="postcss">
@reference "tailwindcss";
#changelog :global(.commits) {
margin-left: -16px;
margin-right: -16px;
border-radius: 0px 0px 2px 2px !important;
}
#changelog :global(details > div){
padding-bottom: 0px;
}
#changelog :global(.commits > div) {
padding-bottom: 0px;
padding-top: 0px;
}
#description :global(h2) {
@apply font-bold mt-4 mb-1;
}
#description :global(h2:first-child) {
margin-top: 0px !important;
}
#description :global(ul) {
padding-left: 1em;
}
#description :global(li),
#description :global(p) {
@apply text-xs!;
list-style-type: disc;
}
#changelog :global(details > details[open] > summary){
margin-bottom: 20px !important;
}
.link {
color: #60a5fa;
text-decoration: none;
}
.link:hover {
text-decoration: underline;
}
</style>
@@ -1,4 +1,5 @@
<script lang="ts">
import { Button, toast } from '@nodarium/ui';
import FileSaver from 'file-saver';
import type { Group } from 'three';
import type { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
@@ -28,11 +29,12 @@
exporter.parse(
scene,
(gltf) => {
// download .gltf file
download(gltf as ArrayBuffer, 'plant', 'text/plain', 'gltf');
toast('Exported as GLTF', 'success');
},
(err) => {
console.log(err);
const msg = err instanceof Error ? err.message : String(err);
toast(`GLTF export failed: ${msg}`, 'error');
}
);
}
@@ -45,13 +47,18 @@
objExporter = new m.OBJExporter();
return objExporter;
}));
const result = exporter.parse(scene);
// download .obj file
download(result, 'plant', 'text/plain', 'obj');
try {
const result = exporter.parse(scene);
download(result, 'plant', 'text/plain', 'obj');
toast('Exported as OBJ', 'success');
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
toast(`OBJ export failed: ${msg}`, 'error');
}
}
</script>
<div class="p-4">
<button onclick={exportObj}>export obj</button>
<button onclick={exportGltf}>export gltf</button>
<div class="p-4 flex gap-2">
<Button onclick={exportObj}>export obj</Button>
<Button onclick={exportGltf}>export gltf</Button>
</div>
+16 -13
View File
@@ -1,20 +1,23 @@
<script lang="ts">
import type { Graph } from '$lib/types';
import { JsonViewer } from '@nodarium/ui';
const { graph }: { graph?: Graph } = $props();
function convert(g: Graph): string {
return JSON.stringify(
{
...g,
nodes: g.nodes.map((n: object) => ({ ...n, tmp: undefined }))
},
null,
2
);
}
const data = $derived(
graph
? {
...graph,
nodes: graph.nodes.map((n: object) => ({ ...n, state: undefined }))
}
: null
);
</script>
<pre>
{graph ? convert(graph) : "No graph loaded"}
</pre>
<div class="overflow-auto p-2">
{#if data}
<JsonViewer value={data} path="graph" />
{:else}
<span class="font-mono text-xs text-neutral-500">No graph loaded</span>
{/if}
</div>
@@ -0,0 +1,156 @@
<script lang="ts">
import type { GraphManager } from '$lib/graph-interface/graph-manager.svelte';
import { GraphState } from '$lib/graph-interface/graph-state.svelte';
import type { NodeInstance } from '@nodarium/types';
import { SocketTable } from '@nodarium/ui';
import UnusedGroupsPanel from './UnusedGroupsPanel.svelte';
type Props = {
manager: GraphManager;
graphState: GraphState;
node?: NodeInstance;
};
const { manager, graphState, node = $bindable() }: Props = $props();
const activeGroup = $derived.by(() => {
if (node?.type === '__internal/group/instance') {
let group = manager.getGroup(node.props?.groupId as number);
if (group) return group;
}
if (manager?.isInsideGroup && manager.currentGroupId !== null) {
return manager.getGroup(manager.currentGroupId);
}
});
const groupName = $derived(activeGroup?.name ?? '');
function handleRename(e: Event) {
const name = (e.target as HTMLInputElement).value;
if (activeGroup) manager.renameGroup(activeGroup.id, name);
}
function handleRemoveInput(key: string) {
if (!activeGroup) return;
const group = manager.getGroup(activeGroup?.id);
const inputs = $state.snapshot(group?.inputs ?? {});
delete inputs[key];
activeGroup.inputs = inputs;
manager.nodes = manager.nodes;
manager.save();
}
const types = $derived(
Array.from(
new Set(
manager?.registry
? manager.registry.getAllNodes()
.flatMap(n =>
Object.values(n.inputs ?? {})
.map(v => v.type)
)
: []
)
)
);
let outputType = $derived(activeGroup?.outputs?.[0]?.type ?? 'unknown');
$effect(() => {
if (!activeGroup) return;
const group = manager.getGroup(activeGroup?.id);
const outputs = $state.snapshot(group?.outputs ?? []);
if (outputs?.[0]?.type === outputType) return;
activeGroup.outputs = [
{
label: outputs[0]?.label ?? 'Output',
type: outputType
}
];
manager.nodes = manager.nodes;
manager.save();
});
</script>
{#if activeGroup}
<div class='{node?"border-l-2 pl-3.5!":""} bg-layer-2 flex items-center h-[70px] border-b-1 border-l-selected border-b-outline pl-4'>
<h3>Group Settings</h3>
</div>
{/if}
{#if activeGroup}
{#key activeGroup.id}
<div class="p-4 group-settings">
<label for="group-name">Group name</label>
<input
id="group-name"
type="text"
placeholder="Group {activeGroup.id}"
value={groupName}
oninput={handleRename}
/>
<label for="group-name">Group Inputs</label>
<div>
<SocketTable
{types}
onremove={handleRemoveInput}
bind:inputs={activeGroup.inputs}
colors={graphState?.colors?.getColors()}
/>
</div>
<label for="group-name mb-2">Group output</label>
<div class="flex bg-layer-2 rounded-sm outline outline-outline w-min">
<span
style:background={graphState?.colors?.getColor(outputType)}
class="block opacity-50 min-w-2 ml-2 w-2 h-2 my-auto rounded-sm"
></span>
<select
class="text-[0.9em] shrink-0 px-2 py-1 border-outline"
bind:value={outputType}
>
{#each types as type (type)}
<option>
<span
style="background: {graphState?.colors?.getColor(type)}; width: 5px; height: 5px; border-radius: 5px;"
></span>
{type}
</option>
{/each}
</select>
</div>
</div>
{/key}
{/if}
{#if manager && !manager.isInsideGroup}
<UnusedGroupsPanel {manager} />
{/if}
<style>
.group-settings {
display: flex;
flex-direction: column;
gap: 0.4em;
}
label {
font-size: 0.8em;
opacity: 0.7;
}
.group-settings input {
background: var(--color-layer-1);
border: 1px solid var(--color-outline);
border-radius: 4px;
color: var(--color-text);
font-family: var(--font-family);
font-size: 0.9em;
padding: 0.4em 0.6em;
}
.group-settings input:focus {
outline: 1px solid var(--color-active);
}
</style>
@@ -0,0 +1,122 @@
<script lang="ts">
import type { GraphManager } from '$lib/graph-interface/graph-manager.svelte';
import type { GroupDefinition } from '@nodarium/types';
import { Button } from '@nodarium/ui';
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
type Props = { manager: GraphManager };
const { manager }: Props = $props();
type GroupNode = { group: GroupDefinition; children: GroupNode[] };
const unusedTree = $derived.by((): GroupNode[] => {
const unused = manager.getUnusedGroups();
if (!unused.length) return [];
const unusedIds = new Set(unused.map(g => g.id));
// Build child map: which unused groups reference which other unused groups
const childrenOf = new SvelteMap<number, number[]>();
const referencedBy = new SvelteSet<number>();
for (const group of unused) {
const refs: number[] = [];
for (const node of group.nodes) {
if (node.type === '__internal/group/instance' && node.props?.groupId !== undefined) {
const childId = node.props.groupId as number;
if (unusedIds.has(childId)) {
refs.push(childId);
referencedBy.add(childId);
}
}
}
childrenOf.set(group.id, refs);
}
const byId = new Map(unused.map(g => [g.id, g]));
function buildNode(g: GroupDefinition): GroupNode {
return {
group: g,
children: (childrenOf.get(g.id) ?? []).map(id => buildNode(byId.get(id)!))
};
}
return unused
.filter(g => !referencedBy.has(g.id))
.map(buildNode);
});
</script>
{#if unusedTree.length}
<div class="panel p-4">
<div class="header">
<span>Unused groups</span>
<Button size="sm" variant="destructive" onclick={() => manager.removeUnusedGroups()}>
Remove all
</Button>
</div>
<ul class="tree">
{#snippet treeNode(node: GroupNode)}
<li>
<span class="group-name">{node.group.name || `Group #${node.group.id}`}</span>
{#if node.children.length}
<ul>
{#each node.children as child (child.group.id)}
{@render treeNode(child)}
{/each}
</ul>
{/if}
</li>
{/snippet}
{#each unusedTree as node (node.group.id)}
{@render treeNode(node)}
{/each}
</ul>
</div>
{/if}
<style>
.panel {
border-top: 1px solid var(--color-outline);
margin-top: -1px;
border-bottom: 1px solid var(--color-outline);
}
.header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5em;
font-size: 0.8em;
opacity: 0.7;
}
.tree {
list-style: none;
margin: 0;
padding: 0;
}
.tree ul {
list-style: none;
margin: 0;
padding-left: 1.2em;
border-left: 1px solid var(--color-outline);
}
.tree li {
padding: 0.15em 0;
}
.group-name {
font-size: 0.85em;
}
.tree ul .group-name::before {
content: '└ ';
opacity: 0.4;
}
</style>
+240
View File
@@ -0,0 +1,240 @@
import type { PlantyConfig } from '@nodarium/planty';
export const tutorialConfig: PlantyConfig = {
id: 'nodarium-tutorial',
avatar: {
name: 'Planty',
defaultPosition: 'bottom-right'
},
start: 'intro',
nodes: {
// ── Entry ──────────────────────────────────────────────────────────────
intro: {
position: 'center',
text:
"# Hi, I'm Planty! 🌱\nI'll show you around Nodarium — a tool for building 3D plants by connecting nodes together.\nHow much detail do you want?",
choices: [
{ label: '🌱 Show me the basics', next: 'tour_canvas' },
{ label: '🤓 I want the technical details', next: 'tour_canvas_nerd' },
{ label: 'Skip the tour for now', next: null }
]
},
// ── Simple path ────────────────────────────────────────────────────────
tour_canvas: {
position: 'bottom-left',
action: 'setup-default',
highlight: { selector: '.graph-wrapper', padding: 12 },
text:
'This is the **graph canvas**. Nodes connect together to build a plant — the 3D model updates automatically whenever you make a change.\nEach node does one specific job: grow stems, add noise, produce output.',
next: 'tour_viewer'
},
tour_viewer: {
position: 'top-left',
highlight: { selector: '.cell:first-child', padding: 8 },
text:
'This is the **3D viewer** — the live preview of your plant.\nLeft-click to rotate · right-click to pan · scroll to zoom.',
next: 'try_params'
},
try_params: {
position: 'bottom-right',
highlight: { selector: '.graph-wrapper', padding: 12 },
text:
'Click a node to select it. Its settings appear **directly on the node** — try changing a value and watch the plant update.\nThe sidebar shows extra hidden settings for the selected node.',
next: 'start_building'
},
start_building: {
position: 'center',
action: 'load-tutorial-template',
text:
"Now let's build your own plant from scratch!\nI've loaded a blank project — it only has an **Output** node. Your goal: connect nodes to make a plant.",
next: 'add_stem_node'
},
add_stem_node: {
position: 'bottom-right',
highlight: { selector: '.graph-wrapper', padding: 12 },
text:
"Open the **Add Menu** with **Shift+A** or **right-click** on the canvas.\nAdd a **Stem** node, then connect its output socket to the Output node's input.",
next: 'add_noise_node'
},
add_noise_node: {
position: 'bottom-right',
highlight: { selector: '.graph-wrapper', padding: 12 },
text:
'Add a **Noise** node the same way.\nConnect: Stem → Noise input, then Noise output → Output.\nThis makes the stems grow in organic, curved shapes.',
next: 'add_random_node'
},
add_random_node: {
position: 'bottom-right',
highlight: { selector: '.graph-wrapper', padding: 12 },
text:
"Let's add some randomness! Add a **Random** node and connect its output to the **thickness** or **length** input of the Stem node.\nThe default min/max range is small — **Ctrl+drag** any number field to exceed its normal limits.",
next: 'prompt_regenerate'
},
prompt_regenerate: {
position: 'bottom-right',
highlight: { selector: '.graph-wrapper', padding: 12 },
text:
'Now press **R** to regenerate. Each press gives the Random node a new value — your plant changes every run!',
next: 'tour_sidebar'
},
tour_sidebar: {
position: 'right',
highlight: { selector: '.tabs', padding: 4 },
text:
'The **sidebar** holds all your tools:\n⚙️ Settings · ⌨️ Shortcuts · 📦 Export · 📁 Projects · 📊 Graph Settings\nEnable **Advanced Mode** in Settings to unlock performance and benchmark panels.',
next: 'save_project'
},
save_project: {
position: 'right',
text:
'Your work is saved in the **Projects panel** — rename it, create new projects, or switch between them anytime.',
next: 'congrats'
},
congrats: {
position: 'center',
text:
"# You're all set! 🎉\nYou know how to build plants, tweak parameters, and save your work.\nWant to explore more?",
choices: [
{ label: '🔗 How do node connections work?', next: 'connections_intro' },
{ label: '💡 Ideas for improving this plant', next: 'improvements_hint' },
{ label: '⌨️ Keyboard shortcuts', next: 'shortcuts_tour' },
{ label: "I'm ready to build!", next: null }
]
},
// ── Technical / nerd path ──────────────────────────────────────────────
tour_canvas_nerd: {
position: 'bottom-left',
action: 'setup-default',
highlight: { selector: '.graph-wrapper', padding: 12 },
text:
"The **graph canvas** renders a directed acyclic graph. Each node is an individual **WASM module** executed in isolation — inputs in, output out. The 3D model updates automatically on every change.\nI've loaded a starter graph so you can see it in action.",
choices: [
{
label: '🔍 Explore Node Sourcecode',
action: 'open-github-nodes'
}
],
next: 'tour_viewer_nerd'
},
tour_viewer_nerd: {
position: 'top-left',
highlight: { selector: '.cell:first-child', padding: 8 },
text:
'The **3D viewer** uses `@threlte/core` (Svelte + Three.js). Mesh data streams from WASM execution results. OrbitControls: left-drag rotate, right-drag pan, scroll zoom.',
next: 'tour_runtime_nerd'
},
tour_runtime_nerd: {
position: 'bottom-right',
text:
'By default, nodes execute in a **WebWorker** for better performance. You can switch to main-thread execution by disabling **Debug → Execute in WebWorker** in Settings.\nEnable **Advanced Mode** to unlock the Performance and Benchmark panels.',
next: 'start_building'
},
// ── Deep dives (shared between paths) ─────────────────────────────────
connections_intro: {
position: 'bottom-right',
text:
'Node sockets are **type-checked**. The coloured dots tell you what kind of data flows through:\n🔵 `number` · 🟢 `vec3` · 🟣 `shape` · ⚪ `*` (wildcard)',
next: 'connections_rules'
},
connections_rules: {
position: 'right',
text:
'Drag from an output socket to an input socket to connect them.\n• Types must match (or use `*`)\n• No circular loops\n• Optional inputs can stay empty\nInvalid connections snap back automatically.',
choices: [
{ label: '🔧 Node parameters', next: 'params_intro' },
{ label: '🐛 Debug node', next: 'debug_intro' },
{ label: 'Start building!', next: null }
]
},
params_intro: {
position: 'bottom-right',
highlight: { selector: '.graph-wrapper', padding: 12 },
text:
'Click any node to select it. Basic settings are shown **on the node itself**.\nThe sidebar under *Graph Settings → Active Node* shows the full list:\n**Number** — drag or type · **Vec3** — X/Y/Z · **Select** — dropdown · **Color** — picker',
next: 'params_tip'
},
params_tip: {
position: 'right',
text:
'Pro tips:\n• Parameters can be connected from other nodes — drag an edge to the input socket\n• The **Random Seed** in Graph Settings gives you the same result every run\n• **f** key smart-connects two selected nodes · **Ctrl+Delete** removes a node and restores its edges',
choices: [
{ label: '🔗 How connections work', next: 'connections_intro' },
{ label: '💡 Plant improvement ideas', next: 'improvements_hint' },
{ label: 'Start building!', next: null }
]
},
debug_intro: {
position: 'bottom-right',
text:
'Add a **Debug node** from the Add Menu (Shift+A or right-click). It accepts `*` wildcard inputs — connect any socket to inspect the data flowing through.\nEnable **Advanced Mode** in Settings to also see Performance and Graph Source panels.',
next: 'debug_done'
},
debug_done: {
position: 'center',
text: 'The Debug node is your best friend when building complex graphs.\nAnything else?',
choices: [
{ label: '🔗 Connection types', next: 'connections_intro' },
{ label: '🔧 Node parameters', next: 'params_intro' },
{ label: 'Start building!', next: null }
]
},
shortcuts_tour: {
position: 'bottom-right',
text:
'**Essential shortcuts:**\n`R` — Regenerate\n`Shift+A` / right-click — Add node\n`f` — Smart-connect selected nodes\n`.` — Center camera\n`Ctrl+Z` / `Ctrl+Y` — Undo / Redo\n`Delete` — Remove selected · `Ctrl+Delete` — Remove and restore edges',
next: 'shortcuts_done'
},
shortcuts_done: {
position: 'right',
text:
'All shortcuts are also listed in the sidebar under the ⌨️ icon.\nReady to build something?',
choices: [
{ label: '🔗 Node connections', next: 'connections_intro' },
{ label: '🔧 Parameters', next: 'params_intro' },
{ label: "Let's build! 🌿", next: null }
]
},
export_tour: {
position: 'right',
text:
'Export your 3D model from the **📦 Export** panel:\n**GLB** — standard for 3D apps (Blender, Three.js)\n**OBJ** — legacy format · **STL** — 3D printing · **PNG** — screenshot',
next: 'congrats'
},
improvements_hint: {
position: 'center',
text:
'# Ideas to grow your plant 🌿\n• Add a **Vec3** node → connect to *origin* on the Stem to spread stems across 3D space\n• Use a **Random** node on a parameter so each run produces a unique shape\n• Chain **multiple Stem nodes** with different settings for complex branching\n• Add a **Gravity** or **Branch** node for even more organic results',
choices: [
{ label: '⌨️ Keyboard shortcuts', next: 'shortcuts_tour' },
{ label: "Let's build! 🌿", next: null }
]
}
}
};
+20
View File
@@ -0,0 +1,20 @@
<script lang="ts">
import { page } from '$app/state';
</script>
<main class="w-screen h-screen flex flex-col items-center justify-center">
<div class="outline-1 outline-outline bg-layer-2">
<h1 class="p-8 text-3xl">@nodarium/error</h1>
<hr>
<pre class="p-8">{JSON.stringify(page.error, null, 2)}</pre>
<hr>
<div class="flex p-4">
<button
class="bg-layer-2 outline-1 outline-outline p-3 px-6 rounded-sm cursor-pointer"
on:click={() => window.location.reload()}
>
reload
</button>
</div>
</div>
</main>
+27
View File
@@ -1 +1,28 @@
export const prerender = true;
export async function load({ fetch }) {
async function fetchChangelog() {
try {
const res = await fetch('/CHANGELOG.md');
return await res.text();
} catch (error) {
console.log('Failed to fetch CHANGELOG.md', error);
return;
}
}
async function fetchGitInfo() {
try {
const res = await fetch('/git.json');
return await res.json();
} catch (error) {
console.log('Failed to fetch git.json', error);
return;
}
}
return {
git: await fetchGitInfo(),
changelog: await fetchChangelog()
};
}
+217 -51
View File
@@ -4,6 +4,8 @@
import Grid from '$lib/grid';
import { debounceAsyncFunction } from '$lib/helpers';
import { createKeyMap } from '$lib/helpers/createKeyMap';
import { debugNode } from '$lib/node-registry/debugNode';
import { groupNode } from '$lib/node-registry/groupNode.js';
import { IndexDBCache, RemoteNodeRegistry } from '$lib/node-registry/index';
import NodeStore from '$lib/node-store/NodeStore.svelte';
import PerformanceViewer from '$lib/performance/PerformanceViewer.svelte';
@@ -17,19 +19,28 @@
import Panel from '$lib/sidebar/Panel.svelte';
import ActiveNodeSettings from '$lib/sidebar/panels/ActiveNodeSettings.svelte';
import BenchmarkPanel from '$lib/sidebar/panels/BenchmarkPanel.svelte';
import Changelog from '$lib/sidebar/panels/Changelog.svelte';
import ExportSettings from '$lib/sidebar/panels/ExportSettings.svelte';
import GraphSource from '$lib/sidebar/panels/GraphSource.svelte';
import GroupSettings from '$lib/sidebar/panels/GroupSettings.svelte';
import Keymap from '$lib/sidebar/panels/Keymap.svelte';
import { panelState } from '$lib/sidebar/PanelState.svelte';
import Sidebar from '$lib/sidebar/Sidebar.svelte';
import { tutorialConfig } from '$lib/tutorial/tutorial-config';
import { Planty } from '@nodarium/planty';
import type { Graph, NodeInstance } from '@nodarium/types';
import { Spinner, Toast, toast } from '@nodarium/ui';
import { createPerformanceStore } from '@nodarium/utils';
import { onMount } from 'svelte';
import type { Group } from 'three';
let performanceStore = createPerformanceStore();
let planty = $state<ReturnType<typeof Planty>>();
const { data } = $props();
const registryCache = new IndexDBCache('node-registry');
const nodeRegistry = new RemoteNodeRegistry('', registryCache);
const nodeRegistry = new RemoteNodeRegistry('', registryCache, [debugNode, groupNode]);
const workerRuntime = new WorkerRuntimeExecutor();
const runtimeCache = new MemoryRuntimeCache();
const memoryRuntime = new MemoryRuntimeExecutor(nodeRegistry, runtimeCache);
@@ -59,9 +70,12 @@
let activeNode = $state<NodeInstance | undefined>(undefined);
let scene = $state<Group>(null!);
let isExecuting = $state(false);
let sidebarOpen = $state(false);
let graphInterface = $state<ReturnType<typeof GraphInterface>>(null!);
let viewerComponent = $state<ReturnType<typeof Viewer>>();
let debugData = $state<Record<number, { type: string; data: Int32Array }>>();
const manager = $derived(graphInterface?.manager);
async function randomGenerate() {
@@ -84,15 +98,21 @@
randomSeed: { type: 'boolean', value: false }
});
$effect(() => {
if (graphSettings && graphSettingTypes) {
if (graphSettings && graphSettingTypes && manager?.loaded) {
manager?.setSettings($state.snapshot(graphSettings));
}
});
let timeout: ReturnType<typeof setTimeout>;
async function update(
g: Graph,
s: Record<string, unknown> = $state.snapshot(graphSettings)
) {
if (timeout) clearTimeout(timeout);
timeout = setTimeout(() => {
isExecuting = true;
}, 100);
performanceStore.startRun();
try {
let a = performance.now();
@@ -101,6 +121,7 @@
if (appSettings.value.debug.useWorker) {
let perfData = await runtime.getPerformanceData();
debugData = await runtime.getDebugData();
let lastRun = perfData?.at(-1);
if (lastRun?.total) {
lastRun.runtime = lastRun.total;
@@ -114,74 +135,169 @@
}
viewerComponent?.update(graphResult);
} catch (error) {
console.log('errors', error);
const msg = error instanceof Error ? error.message : String(error);
toast(`Execution failed: ${msg}`, 'error');
} finally {
clearTimeout(timeout);
isExecuting = false;
performanceStore.stopRun();
}
}
const handleUpdate = debounceAsyncFunction(update);
onMount(() => {
appSettings.value.debug.stressTest = {
...appSettings.value.debug.stressTest,
loadGrid: () => {
function handleSettingsButton(id: string) {
switch (id) {
case 'general.clippy':
planty?.start();
break;
case 'general.debug.stressTest.loadGrid':
manager.load(
templates.grid(
appSettings.value.debug.stressTest.amount,
appSettings.value.debug.stressTest.amount
)
);
},
loadTree: () => {
break;
case 'general.debug.stressTest.loadTree':
manager.load(templates.tree(appSettings.value.debug.stressTest.amount));
},
lottaFaces: () => {
break;
case 'general.debug.stressTest.lottaFaces':
manager.load(templates.lottaFaces as unknown as Graph);
},
lottaNodes: () => {
break;
case 'general.debug.stressTest.lottaNodes':
manager.load(templates.lottaNodes as unknown as Graph);
},
lottaNodesAndFaces: () => {
break;
case 'general.debug.stressTest.lottaNodesAndFaces':
manager.load(templates.lottaNodesAndFaces as unknown as Graph);
}
};
});
break;
default:
}
}
</script>
<svelte:document onkeydown={applicationKeymap.handleKeyboardEvent} />
<Planty
bind:this={planty}
config={tutorialConfig}
actions={{
'setup-default': () => {
console.log('setup-default');
const ts = new Date().toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' });
pm.handleCreateProject(
structuredClone(templates.defaultPlant) as unknown as Graph,
`Tutorial Project (${ts})`
);
},
'load-tutorial-template': () => {
console.log('load-tutorial-template');
if (!pm.graph) return;
const g = structuredClone(templates.tutorial) as unknown as Graph;
g.id = pm.graph.id;
g.meta = { ...pm.graph.meta };
manager.load(g);
graphInterface.state.centerNode(graphInterface.manager.getAllNodes()[0]);
},
'open-github-nodes': () => {
console.log('open-github-nodes');
window.open(
'https://github.com/jim-fx/nodarium/tree/main/nodes/max/plantarium',
'__blank'
);
}
}}
hooks={{
'action:add_stem_node': (cb) => {
const unsub = manager.on('save', () => {
const allNodes = graphInterface.manager.getAllNodes();
const stemNode = allNodes.find(n => n.type === 'max/plantarium/stem');
if (stemNode && graphInterface.manager.edges.length) {
unsub();
(cb as () => void)();
}
});
},
'action:add_noise_node': (cb) => {
const unsub = manager.on('save', () => {
const allNodes = graphInterface.manager.getAllNodes();
const noiseNode = allNodes.find(n => n.type === 'max/plantarium/noise');
if (noiseNode && graphInterface.manager.edges.length > 1) {
unsub();
(cb as () => void)();
}
});
},
'action:add_random_node': (cb) => {
const unsub = manager.on('save', () => {
const allNodes = graphInterface.manager.getAllNodes();
const noiseNode = allNodes.find(n => n.type === 'max/plantarium/random');
if (noiseNode && graphInterface.manager.edges.length > 2) {
unsub();
(cb as () => void)();
}
});
},
'action:prompt_regenerate': (cb) => {
function handleKeydown(e: KeyboardEvent) {
if (e.key === 'r') {
window.removeEventListener('keydown', handleKeydown);
(cb as () => void)();
}
}
window.addEventListener('keydown', handleKeydown);
},
'before:save_project': () => panelState.setActivePanel('projects'),
'before:export_tour': () => panelState.setActivePanel('exports'),
'before:shortcuts_tour': () => panelState.setActivePanel('shortcuts'),
'after:save_project': () => panelState.setActivePanel('graph-settings'),
'before:tour_runtime_nerd': () => panelState.setActivePanel('general')
}}
/>
<div class="wrapper manager-{manager?.status}">
<header></header>
<Grid.Row>
<Grid.Cell>
<Viewer
bind:scene
bind:this={viewerComponent}
perf={performanceStore}
centerCamera={appSettings.value.centerCamera}
/>
<div class="viewer-cell">
<Viewer
bind:scene
bind:this={viewerComponent}
perf={performanceStore}
debugData={debugData}
centerCamera={appSettings.value.centerCamera}
/>
{#if isExecuting}
<div class="viewer-spinner" aria-label="Executing graph">
<Spinner size={28} />
</div>
{/if}
</div>
</Grid.Cell>
<Grid.Cell>
{#if pm.graph}
<GraphInterface
graph={pm.graph}
bind:this={graphInterface}
registry={nodeRegistry}
showGrid={appSettings.value.nodeInterface.showNodeGrid}
snapToGrid={appSettings.value.nodeInterface.snapToGrid}
bind:activeNode
bind:showHelp={appSettings.value.nodeInterface.showHelp}
bind:settings={graphSettings}
bind:settingTypes={graphSettingTypes}
onsave={(g) => pm.saveGraph(g)}
onresult={(result) => handleUpdate(result as Graph)}
/>
{#key pm.graph.id}
<GraphInterface
graph={pm.graph}
bind:this={graphInterface}
registry={nodeRegistry}
safePadding={{ right: sidebarOpen ? 321 : undefined }}
backgroundType={appSettings.value.nodeInterface.backgroundType}
snapToGrid={appSettings.value.nodeInterface.snapToGrid}
bind:activeNode
bind:showHelp={appSettings.value.nodeInterface.showHelp}
bind:settings={graphSettings}
bind:settingTypes={graphSettingTypes}
onsave={(g) => pm.saveGraph(g)}
onresult={(result) => handleUpdate(result as Graph)}
/>
{/key}
{/if}
<Sidebar>
<Sidebar bind:open={sidebarOpen}>
<Panel id="general" title="General" icon="i-[tabler--settings]">
<NestedSettings
id="general"
onButtonClick={handleSettingsButton}
bind:value={appSettings.value}
type={AppSettingTypes}
/>
@@ -201,17 +317,19 @@
<Panel id="exports" title="Exporter" icon="i-[tabler--package-export]">
<ExportSettings {scene} />
</Panel>
<Panel
id="node-store"
title="Node Store"
icon="i-[tabler--database] bg-green-400"
>
<NodeStore registry={nodeRegistry} />
</Panel>
{#if 0 > 1}
<Panel
id="node-store"
title="Node Store"
icon="i-[tabler--database] bg-green-400"
>
<NodeStore registry={nodeRegistry} />
</Panel>
{/if}
<Panel
id="performance"
title="Performance"
hidden={!appSettings.value.debug.showPerformancePanel}
hidden={!appSettings.value.debug.advancedMode}
icon="i-[tabler--brand-speedtest] bg-red-400"
>
{#if $performanceStore}
@@ -224,15 +342,17 @@
<Panel
id="graph-source"
title="Graph Source"
hidden={!appSettings.value.debug.showGraphJson}
hidden={!appSettings.value.debug.advancedMode}
icon="i-[tabler--code]"
>
<GraphSource graph={pm.graph ?? manager?.serialize()} />
{#if manager?.status === 'idle'}
<GraphSource graph={manager.serialize()} />
{/if}
</Panel>
<Panel
id="benchmark"
title="Benchmark"
hidden={!appSettings.value.debug.showBenchmarkPanel}
hidden={!appSettings.value.debug.advancedMode}
icon="i-[tabler--graph] bg-red-400"
>
<BenchmarkPanel run={randomGenerate} />
@@ -242,21 +362,53 @@
title="Graph Settings"
icon="i-[custom--graph] bg-blue-400"
>
<span class="block h-[1px]"></span>
<NestedSettings
id="graph-settings"
type={graphSettingTypes}
bind:value={graphSettings}
/>
<ActiveNodeSettings {manager} bind:node={activeNode} />
{#key activeNode}
<ActiveNodeSettings {manager} bind:node={activeNode} />
<GroupSettings graphState={graphInterface?.state} {manager} bind:node={activeNode} />
{/key}
</Panel>
<Panel
id="changelog"
title="Changelog"
icon="i-[tabler--file-text-spark] bg-green-400"
>
<Changelog git={data.git} changelog={data.changelog} />
</Panel>
</Sidebar>
</Grid.Cell>
</Grid.Row>
</div>
<Toast />
<style>
header {
background-color: var(--color-layer-1);
display: flex;
align-items: center;
padding: 0 8px;
}
.tutorial-btn {
background: none;
border: none;
cursor: pointer;
font-size: 18px;
padding: 4px 6px;
border-radius: 6px;
opacity: 0.7;
transition: opacity 0.15s, background 0.15s;
}
.tutorial-btn:hover {
opacity: 1;
background: rgba(255, 255, 255, 0.08);
}
.wrapper {
@@ -267,6 +419,20 @@
grid-template-rows: 0px 1fr;
}
.viewer-cell {
position: relative;
height: 100%;
}
.viewer-spinner {
position: absolute;
bottom: 12px;
right: 12px;
color: var(--color-text, #cecece);
opacity: 0.6;
pointer-events: none;
}
.wrapper :global(canvas) {
transition: opacity 0.3s ease;
opacity: 1;
+1 -6
View File
@@ -7,7 +7,6 @@
import Sidebar from '$lib/sidebar/Sidebar.svelte';
import { type NodeId, type NodeInstance } from '@nodarium/types';
import { concatEncodedArrays, createWasmWrapper, encodeNestedArray } from '@nodarium/utils';
import Code from './Code.svelte';
const registryCache = new IndexDBCache('node-registry');
const nodeRegistry = new RemoteNodeRegistry('', registryCache);
@@ -78,11 +77,7 @@
</Grid.Cell>
<Grid.Cell>
<div class="h-screen w-[80vw] overflow-y-auto">
{#if nodeWasm}
<Code wasm={nodeWasm} />
{/if}
</div>
<div class="h-screen w-[80vw] overflow-y-auto"></div>
</Grid.Cell>
</Grid.Row>
-26
View File
@@ -1,26 +0,0 @@
<script lang="ts">
import wabtInit from 'wabt';
const { wasm } = $props<{ wasm: ArrayBuffer }>();
async function toWat(arrayBuffer: ArrayBuffer) {
const wabt = await wabtInit();
const module = wabt.readWasm(new Uint8Array(arrayBuffer), {
readDebugNames: true
});
module.generateNames();
module.applyNames();
return module.toText({ foldExprs: false, inlineExport: false });
}
</script>
{#await toWat(wasm)}
<p>Converting to WAT</p>
{:then c}
<pre>
<code class="text-gray-50">{c}</code>
</pre>
{/await}
+2
View File
@@ -1 +1,3 @@
nodes/
CHANGELOG.md
git.json
+19
View File
@@ -0,0 +1,19 @@
<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M55.2154 77.6602L52.2788 78.3944L49.2607 60.6933L52.2788 33.0404L47.6293 18.0312L45.9162 18.6838L41.6745 28.7987L31.6412 33.4483H20.2211L21.6894 24.0675L31.6412 15.9919L45.9162 15.1762L49.7501 15.9919L55.2154 32.6326L54.5628 38.5873L64.8409 33.0404L69.5721 37.69L80.1764 43.1553L84.1734 52.8624L83.113 64.1193L73.8954 61.8353L66.3092 52.4545V38.5873L64.1068 36.7112L54.155 42.4212L52.2788 60.6933L55.2154 77.6602Z"
fill="url(#paint0_linear)"
/>
<defs>
<linearGradient
id="paint0_linear"
x1="34.3903"
y1="15.1762"
x2="52.1972"
y2="78.3944"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#4CAF7B" />
<stop offset="1" stop-color="#347452" />
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 861 B

Some files were not shown because too many files have changed in this diff Show More