Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magic-graphs",
"version": "1.0.0",
"scripts": {
"start": "cd packages/server && pnpm i --omit=dev && node dist/index.js",
"start": "cd packages/server && pnpm install && pnpm start",
"dev": "concurrently -c auto command 'pnpm:dev-*'",
"dev-client": "cd packages/client && pnpm dev",
"dev-server": "cd packages/server && pnpm dev",
Expand Down
80 changes: 40 additions & 40 deletions packages/products/src/markov-chains/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,56 @@
const markov = useMarkovChain(graph);
useMarkovColorizer(graph, markov).colorize();

const int = gsap.utils.interpolate(colors.RED_500, colors.RED_800);
// const int = gsap.utils.interpolate(colors.RED_500, colors.RED_800);

const { play, stop } = graph.defineTimeline({
forShapes: ["circle"],
durationMs: 2000,
customInterpolations: {
stroke: {
value: (progress, schema) => ({
color: progress < 0.5 ? int(progress * 2) : int(2 - progress * 2),
lineWidth: schema.stroke?.lineWidth ?? 10,
}),
easing: "in-out",
},
},
synchronize: true,
});
// const { play, stop } = graph.defineTimeline({
// forShapes: ["circle"],
// durationMs: 2000,
// customInterpolations: {
// stroke: {
// value: (progress, schema) => ({
// color: progress < 0.5 ? int(progress * 2) : int(2 - progress * 2),
// lineWidth: schema.stroke?.lineWidth ?? 10,
// }),
// easing: "in-out",
// },
// },
// synchronize: true,
// });

graph.subscribe("onFocusChange", (newIds, oldIds) => {
const newNodeIds = Array.from(newIds).filter(graph.getNode);
const oldNodeIds = Array.from(oldIds).filter(graph.getNode);
newNodeIds.forEach((nodeId) => {
stop({ shapeId: nodeId });
});
const noLongerFocused = Array.from(oldNodeIds).filter(
(nodeId) => !newNodeIds.includes(nodeId)
);
for (const nodeId of noLongerFocused) {
if (markov.invalidStates.value.has(nodeId)) play({ shapeId: nodeId });
}
});
// graph.subscribe("onFocusChange", (newIds, oldIds) => {
// const newNodeIds = Array.from(newIds).filter(graph.getNode);
// const oldNodeIds = Array.from(oldIds).filter(graph.getNode);
// newNodeIds.forEach((nodeId) => {
// stop({ shapeId: nodeId });
// });
// const noLongerFocused = Array.from(oldNodeIds).filter(
// (nodeId) => !newNodeIds.includes(nodeId)
// );
// for (const nodeId of noLongerFocused) {
// if (markov.invalidStates.value.has(nodeId)) play({ shapeId: nodeId });
// }
// });

watch(markov.invalidStates, () => {
for (const node of graph.nodes.value) {
stop({ shapeId: node.id });
if (markov.invalidStates.value.has(node.id)) play({ shapeId: node.id });
}
});
// watch(markov.invalidStates, () => {
// for (const node of graph.nodes.value) {
// stop({ shapeId: node.id });
// if (markov.invalidStates.value.has(node.id)) play({ shapeId: node.id });
// }
// });

const test = () => {
for (const nodeId of markov.invalidStates.value) {
play({ shapeId: nodeId });
}
};
// const test = () => {
// for (const nodeId of markov.invalidStates.value) {
// play({ shapeId: nodeId });
// }
// };
</script>

<template>
<GraphProduct v-bind="graphWithCanvas">
<template #top-center>
<MarkovChainInfo :markov="markov" />
<GButton @click="test">Test</GButton>
<!-- <GButton @click="test">Test</GButton> -->
</template>

<template #bottom-center>
Expand Down
5 changes: 2 additions & 3 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
"version": "1.0.0",
"private": true,
"description": "",
"main": "dist/types/index.js",
"type": "module",
"main": "dist/index.js",
"scripts": {
"start": "node .",
"start": "tsc && node .",
"dev": "nodemon --exec tsx src/index.ts",
"build:types": "tsc -b ."
},
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import dotenv from 'dotenv';
import express from 'express';
import { sockets } from './sockets.js';
import { sockets } from './sockets';
import { createServer } from 'http';
import { LOCALHOST_PORT } from './constants.js';
import { LOCALHOST_PORT } from './constants';

dotenv.config();

Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/sockets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Server } from 'socket.io'
import { createServer } from 'http'
import { trackGraphState } from './trackGraphState.js'
import { Collaborator, SocketEvents } from '@magic/graph/collab/types.js'
import { trackGraphState } from './trackGraphState'
import { Collaborator, SocketEvents } from '@magic/graph/collab/types'

export const sockets = (httpServer: ReturnType<typeof createServer>) => {
const io = new Server<SocketEvents, SocketEvents, {}, {}>(httpServer, {
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/trackGraphState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { GraphState } from "@magic/graph/collab/types.js"
import type { GEdge, GNode } from "@magic/graph/types.js"
import type { GraphState } from "@magic/graph/collab/types"
import type { GEdge, GNode } from "@magic/graph/types"

/**
* maps the room id to the live version of the graph for that room
Expand Down
23 changes: 14 additions & 9 deletions packages/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist/types",
"rootDir": "./src",
"outDir": "dist",
"target": "ES2022",
"module": "CommonJS",
"moduleResolution": "Node",
"strict": true,
"noImplicitAny": true,
"declaration": false,
"skipLibCheck": true,
"strictNullChecks": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"paths": {
"@magic/server/*": ["./src/*"],
"@magic/graph/*": ["../graph/src/*"]
},
"moduleResolution": "nodenext",
"module": "nodenext",
"emitDeclarationOnly": false
}
},
"references": [{ "path": "../graph" }],
"include": ["./src/**/*"],
"exclude": ["./dist", "**/node_modules"]
"include": ["src"],
"exclude": ["node_modules"]
}
Loading