Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import behave flow + flow side by side model viewer #159

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"argsIgnorePattern": "^_"
}
],
"import/extensions": ["error", "always", {"ignorePackages": true} ],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bhouston this is kind of a difficult rule to follow, it means you need to add the file extension whenever you import in typescript.

Is it ok to get rid of this rule? Makes the code easier to write/read when you can just do:

import { useRegistry } from './hooks/useRegistry';

wheras before you would need to do:

import { useRegistry } from './hooks/useRegistry.js';

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this because it allows for many loaders to load JavaScript files in the browser without bundling. This explains the reasoning: https://stackoverflow.com/questions/70461497/why-do-i-need-to-add-the-js-extension-when-importing-files-in-typescript-but-no?utm_source=feedburner&utm_medium=email

That said, I can just always use a bundler.

On that topic, right now if there are errors in the code, say when I run exec-graph, I do not see any source maps. It makes it a bit harder to track down the errors to the original line in the typescript file.

Copy link
Collaborator Author

@oveddan oveddan Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would you want to load js files in the browser? I think we could just use the chrome debugger and it loads the typescript files via its sourcemaps?

Yes seeing source maps would be ideal when running exec-graph. A nice way to do this is to just use ts-node - then you get all errors showing up in the original source code location. And you get rid of the need for the step to build the files before. I originally wanted to setup running the exec-graph scripts using ts-node, but it will not work when you want to import .js files:
TypeStrong/ts-node#783

"simple-import-sort/imports": "error",
"promise/always-return": "error",
"promise/no-return-wrap": "error",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ package-lock.json
node-spec.json
*.blend1
node-spec.csv
yarn.lock
24 changes: 24 additions & 0 deletions examples/flow/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions examples/flow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Behave-Graph Flow Editor

This example contains a real-time flow-editor for behave-graph originally created by @beeglebug in a separate repository [behave-flow](https://github.com/beeglebug/behave-flow) by @beeglebug. It has been imported into this monorepo to enable both the editor code and core framework code to be developed against/update in tandem.

It is built in react and typescript, with the front-end hosted in a a serverless vite app.

To Build:

npm run build

To Run:

npm run dev
13 changes: 13 additions & 0 deletions examples/flow/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Behave Graph Flow Editor</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
47 changes: 47 additions & 0 deletions examples/flow/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@behave-graph/examples-flow",
"private": true,
"version": "0.0.1",
"type": "module",
"scripts": {
"start": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@behave-graph/core": "*",
"@fortawesome/fontawesome-svg-core": "^6.2.0",
"@fortawesome/free-solid-svg-icons": "^6.2.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@headlessui/react": "^1.7.4",
"@heroicons/react": "^2.0.13",
"@react-three/drei": "^9.42.2",
"@react-three/fiber": "^8.9.1",
"clsx": "^1.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-icons": "^4.6.0",
"react-router-dom": "^6.4.3",
"react-split-pane": "^0.1.92",
"reactflow": "^11.2.0",
"three": "^0.146.0",
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/react": "^18.0.22",
"@types/react-dom": "^18.0.7",
"@types/three": "^0.146.0",
"@types/uuid": "^8.3.4",
"@typescript-eslint/parser": "^5.42.0",
"@vitejs/plugin-react": "^2.2.0",
"autoprefixer": "^10.4.13",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.1",
"postcss": "^8.4.18",
"tailwindcss": "^3.2.2",
"typescript": "^4.6.4",
"vite": "^3.2.0"
}
}
6 changes: 6 additions & 0 deletions examples/flow/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
130 changes: 130 additions & 0 deletions examples/flow/public/examples/graphs/ClickButtonToAnimate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"nodes": [
{
"id": "d71ccb9c-0fea-4ce9-bf92-a31485e9b5a6",
"type": "scene/set/color",
"metadata": {
"positionX": "184.79620709295074",
"positionY": "18.913444261875217"
},
"parameters": {
"jsonPath": {
"value": "materials/2/color"
},
"value": {
"link": {
"nodeId": "5394babc-dcc0-4735-9daf-465c73a66e80",
"socket": "result"
}
}
}
},
{
"id": "5394babc-dcc0-4735-9daf-465c73a66e80",
"type": "math/toColor/rgb",
"metadata": {
"positionX": "-145.20682021207682",
"positionY": "90.16020188760152"
},
"parameters": {
"g": {
"value": ".9"
}
}
},
{
"id": "267d676e-79d4-49e5-9be8-c7dd8b157f00",
"type": "math/toColor/rgb",
"metadata": {
"positionX": "-140.0557507122972",
"positionY": "344.03584956239894"
},
"parameters": {
"r": {
"value": ".9"
}
}
},
{
"id": "98da1b8b-b49e-489d-80ff-24ce601ac0c0",
"type": "scene/set/color",
"metadata": {
"positionX": "181.70354627203167",
"positionY": "272.5116315772409"
},
"parameters": {
"jsonPath": {
"value": "materials/2/color"
},
"value": {
"link": {
"nodeId": "267d676e-79d4-49e5-9be8-c7dd8b157f00",
"socket": "result"
}
}
}
},
{
"id": "d326d57f-198b-41e8-9d2b-182130f1398f",
"type": "flow/flipFlop",
"metadata": {
"positionX": "-51.98681837156558",
"positionY": "-342.24335289662594"
},
"flows": {
"on": {
"nodeId": "d71ccb9c-0fea-4ce9-bf92-a31485e9b5a6",
"socket": "flow"
},
"off": {
"nodeId": "98da1b8b-b49e-489d-80ff-24ce601ac0c0",
"socket": "flow"
}
}
},
{
"id": "85179702-7634-4cf5-95ca-5908224cd4f0",
"type": "scene/nodeClick",
"metadata": {
"positionX": "-517.3783747475436",
"positionY": "-184.38358132733035"
},
"parameters": {
"jsonPath": {
"value": "nodes/2"
}
},
"flows": {
"secondFlow": {
"nodeId": "fcb81837-650c-42fb-a708-236f2ee64abc",
"socket": "flow"
},
"flow": {
"nodeId": "d326d57f-198b-41e8-9d2b-182130f1398f",
"socket": "flow"
}
}
},
{
"id": "fcb81837-650c-42fb-a708-236f2ee64abc",
"type": "scene/set/boolean",
"metadata": {
"positionX": "174.3147945277493",
"positionY": "-187.0779606350799"
},
"parameters": {
"jsonPath": {
"value": "animations/0/playing"
},
"value": {
"link": {
"nodeId": "d326d57f-198b-41e8-9d2b-182130f1398f",
"socket": "isOn"
}
}
}
}
],
"variables": [],
"customEvents": []
}
Loading