Skip to content

Commit

Permalink
Fix eslint; add sourcemaps for debugging; auto-load playground nodes …
Browse files Browse the repository at this point in the history
…from local cache.
  • Loading branch information
yojeek committed Jan 17, 2024
1 parent c38ef5a commit 3bfa34a
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 24 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
node_modules
webpack.config.js
**/vite.config.ts
3 changes: 2 additions & 1 deletion packages/core/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",
"sourceMap": true
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/engine/src/baseEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export abstract class BaseEngine<CalculationData, CalculationArgs extends Array<
});

this.editor.graphEvents.removeConnection.subscribe(this, (c, graph) => {
this.recalculateOrder = true;
this.recalculateOrder = true;
if (!graph.loading && graph.activeTransactions === 0) {
this.internalOnChange();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/src/dependencyEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class DependencyEngine<CalculationData = any> extends BaseEngine<Calculat
}

const inputValues: Record<string, any> = {};
let inputsChanged: Record<string, boolean> = {};
const inputsChanged: Record<string, boolean> = {};

Object.entries(node.inputs).forEach(([k, intf]: [string, NodeInterface]) => {
inputValues[k] = inputs.has(intf.id) ? inputs.get(intf.id) : intf.value;
Expand Down
3 changes: 2 additions & 1 deletion packages/engine/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",
"sourceMap": true
},
"include": ["src/**/*.ts"]
}
33 changes: 21 additions & 12 deletions packages/renderer-vue/playground/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ engine.events.afterRun.subscribe(token, (r) => {
engine.pause();
applyResult(r, editor);
engine.resume();
console.log(r);
});
engine.hooks.gatherCalculationData.subscribe(token, () => "def");
engine.start();
Expand All @@ -80,28 +79,36 @@ editor.registerNodeType(DynamicNode);
editor.registerNodeType(UpdateTestNode);
editor.registerNodeType(ReactiveOutputTestNode);
editor.graph.addNode(new TestNode());
editor.graph.addNode(new TestNode());
editor.graph.addNode(new TestNode());
editor.graph.addNode(new OutputNode());
editor.graph.addNode(new BuilderTestNode());
editor.graph.addNode(new AdvancedNode());
const calculate = async () => {
console.log(await engine.runOnce("def"));
};
const save = () => {
console.log(JSON.stringify(editor.save()));
let state = editor.save();
window.localStorage.setItem("baklava", JSON.stringify(state));
console.log('Saved state to localStorage');
};
const load = () => {
const s = prompt();
if (s) {
editor.load(JSON.parse(s));
let state;
try {
state = JSON.parse(window.localStorage.getItem("baklava")!);
if (state) {
editor.load(state);
return;
}
console.log('Loaded state from localStorage')
} catch (e) {
console.error(e);
return;
}
};
load();
const saveAndLoad = () => {
editor.load(editor.save());
};
Expand All @@ -117,6 +124,8 @@ const setSelectItems = () => {
];
}
}
state && editor.load(state);
};
const changeGridSize = () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/renderer-vue/src/graph/switchToMainGraph.command.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Graph } from "@baklavajs/core";
import { Ref } from "vue";
import type { ICommand, ICommandHandler } from "../commands";
import { SAVE_SUBGRAPH_COMMAND } from "./saveSubgraph.command";
import type { SwitchGraph } from "./switchGraph";

export const SWITCH_TO_MAIN_GRAPH_COMMAND = "SWITCH_TO_MAIN_GRAPH";
export type SwitchToMainGraphCommand = ICommand<void>;

Expand All @@ -15,7 +13,6 @@ export function registerSwitchToMainGraphCommand(
handler.registerCommand<SwitchToMainGraphCommand>(SWITCH_TO_MAIN_GRAPH_COMMAND, {
canExecute: () => displayedGraph.value !== displayedGraph.value.editor.graph,
execute: () => {
// handler.executeCommand(SAVE_SUBGRAPH_COMMAND);
switchGraph(displayedGraph.value.editor.graph);
},
});
Expand Down
5 changes: 3 additions & 2 deletions packages/renderer-vue/src/icons/Save.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
fill="currentColor"
>
<path
d="M1524.824 1242.353c93.402 0 169.411 76.01 169.411 169.412v338.823c0 93.403-76.01 169.412-169.411 169.412H395.412C302.009 1920 226 1843.99 226 1750.588v-338.823c0-93.403 76.01-169.412 169.412-169.412ZM1016.588 0v338.824h-112.94V0h112.94ZM564.824 1468.235c62.343 0 112.94 50.71 112.94 112.941s-50.597 112.942-112.94 112.942c-62.344 0-112.942-50.71-112.942-112.942 0-62.23 50.598-112.94 112.942-112.94ZM903.647 338.824v428.385L657.322 520.885l-79.85 79.85 382.646 382.644 382.644-382.645-79.85-79.85-246.324 246.325V338.824h508.236c93.74 0 169.411 75.67 169.411 169.411v677.647c-46.306-35.011-106.164-56.47-169.411-56.47H395.412c-63.247 0-123.106 21.459-169.412 56.47V508.235c0-93.74 75.67-169.411 169.412-169.411h508.235Z"
fill-rule="evenodd"></path>
d="M1524.824 1242.353c93.402 0 169.411 76.01 169.411 169.412v338.823c0 93.403-76.01 169.412-169.411 169.412H395.412C302.009 1920 226 1843.99 226 1750.588v-338.823c0-93.403 76.01-169.412 169.412-169.412ZM1016.588 0v338.824h-112.94V0h112.94ZM564.824 1468.235c62.343 0 112.94 50.71 112.94 112.941s-50.597 112.942-112.94 112.942c-62.344 0-112.942-50.71-112.942-112.942 0-62.23 50.598-112.94 112.942-112.94ZM903.647 338.824v428.385L657.322 520.885l-79.85 79.85 382.646 382.644 382.644-382.645-79.85-79.85-246.324 246.325V338.824h508.236c93.74 0 169.411 75.67 169.411 169.411v677.647c-46.306-35.011-106.164-56.47-169.411-56.47H395.412c-63.247 0-123.106 21.459-169.412 56.47V508.235c0-93.74 75.67-169.411 169.412-169.411h508.235Z"
fill-rule="evenodd"
/>
</svg>
</template>
6 changes: 3 additions & 3 deletions packages/renderer-vue/src/nodepalette/NodePalette.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import { AbstractNode, INodeTypeInformation } from "@baklavajs/core";
import PaletteEntry from "./PaletteEntry.vue";
import { useViewModel, useTransform } from "../utility";
import {
SUBGRAPH_CONTROL_NODE_TYPE,
SUBGRAPH_INPUT_NODE_TYPE,
SUBGRAPH_OUTPUT_NODE_TYPE
SUBGRAPH_CONTROL_NODE_TYPE,
SUBGRAPH_INPUT_NODE_TYPE,
SUBGRAPH_OUTPUT_NODE_TYPE
} from "../graph/subgraphInterfaceNodes";
import { checkRecursion } from "./checkRecursion";
Expand Down
1 change: 1 addition & 0 deletions packages/renderer-vue/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference types="@types/node" />
// @ts-nocheck

import * as path from "path";
import { defineConfig } from "vite";
Expand Down

0 comments on commit 3bfa34a

Please sign in to comment.