chore: add some more logs
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m34s
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m34s
This commit is contained in:
25
.github/workflows/deploy.yaml
vendored
25
.github/workflows/deploy.yaml
vendored
@@ -12,31 +12,6 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Cache Rust compilation (cargo + target)
|
|
||||||
- name: Cache Rust build
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/registry
|
|
||||||
~/.cargo/git
|
|
||||||
target
|
|
||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-cargo-
|
|
||||||
|
|
||||||
# Prepare pnpm cache (store path)
|
|
||||||
- name: Get pnpm store path
|
|
||||||
id: pnpm-cache
|
|
||||||
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Cache pnpm store
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
|
||||||
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-pnpm-
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import type {
|
|||||||
import { fastHashString } from "@nodes/utils";
|
import { fastHashString } from "@nodes/utils";
|
||||||
import { SvelteMap } from "svelte/reactivity";
|
import { SvelteMap } from "svelte/reactivity";
|
||||||
import EventEmitter from "./helpers/EventEmitter";
|
import EventEmitter from "./helpers/EventEmitter";
|
||||||
import { createLogger } from "./helpers/index";
|
import { createLogger } from "@nodes/utils";
|
||||||
import throttle from "$lib/helpers/throttle";
|
import throttle from "$lib/helpers/throttle";
|
||||||
import { HistoryManager } from "./history-manager";
|
import { HistoryManager } from "./history-manager";
|
||||||
|
|
||||||
@@ -74,7 +74,6 @@ export class GraphManager extends EventEmitter<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
serialize(): Graph {
|
serialize(): Graph {
|
||||||
logger.group("serializing graph");
|
|
||||||
const nodes = Array.from(this.nodes.values()).map((node) => ({
|
const nodes = Array.from(this.nodes.values()).map((node) => ({
|
||||||
id: node.id,
|
id: node.id,
|
||||||
position: [...node.position],
|
position: [...node.position],
|
||||||
@@ -93,7 +92,7 @@ export class GraphManager extends EventEmitter<{
|
|||||||
nodes,
|
nodes,
|
||||||
edges,
|
edges,
|
||||||
};
|
};
|
||||||
logger.groupEnd();
|
logger.log("serializing graph", serialized);
|
||||||
return clone($state.snapshot(serialized));
|
return clone($state.snapshot(serialized));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,9 +197,13 @@ export class GraphManager extends EventEmitter<{
|
|||||||
this.status = "loading";
|
this.status = "loading";
|
||||||
this.id = graph.id;
|
this.id = graph.id;
|
||||||
|
|
||||||
|
logger.info("loading graph", graph);
|
||||||
|
|
||||||
const nodeIds = Array.from(new Set([...graph.nodes.map((n) => n.type)]));
|
const nodeIds = Array.from(new Set([...graph.nodes.map((n) => n.type)]));
|
||||||
await this.registry.load(nodeIds);
|
await this.registry.load(nodeIds);
|
||||||
|
|
||||||
|
logger.info("loaded node types", this.registry.status);
|
||||||
|
|
||||||
for (const node of this.graph.nodes) {
|
for (const node of this.graph.nodes) {
|
||||||
const nodeType = this.registry.getNode(node.type);
|
const nodeType = this.registry.getNode(node.type);
|
||||||
if (!nodeType) {
|
if (!nodeType) {
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ export function lerp(a: number, b: number, t: number) {
|
|||||||
return a + (b - a) * t;
|
return a + (b - a) * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function animate(duration: number, callback: (progress: number) => void | false) {
|
export function animate(
|
||||||
|
duration: number,
|
||||||
|
callback: (progress: number) => void | false,
|
||||||
|
) {
|
||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
const loop = (time: number) => {
|
const loop = (time: number) => {
|
||||||
const progress = (time - start) / duration;
|
const progress = (time - start) / duration;
|
||||||
@@ -18,7 +21,7 @@ export function animate(duration: number, callback: (progress: number) => void |
|
|||||||
} else {
|
} else {
|
||||||
callback(1);
|
callback(1);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
requestAnimationFrame(loop);
|
requestAnimationFrame(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,33 +36,37 @@ export function createNodePath({
|
|||||||
aspectRatio = 1,
|
aspectRatio = 1,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
return `M0,${cornerTop}
|
return `M0,${cornerTop}
|
||||||
${cornerTop
|
${
|
||||||
? ` V${cornerTop}
|
cornerTop
|
||||||
|
? ` V${cornerTop}
|
||||||
Q0,0 ${cornerTop * aspectRatio},0
|
Q0,0 ${cornerTop * aspectRatio},0
|
||||||
H${100 - cornerTop * aspectRatio}
|
H${100 - cornerTop * aspectRatio}
|
||||||
Q100,0 100,${cornerTop}
|
Q100,0 100,${cornerTop}
|
||||||
`
|
`
|
||||||
: ` V0
|
: ` V0
|
||||||
H100
|
H100
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
V${y - height / 2}
|
V${y - height / 2}
|
||||||
${rightBump
|
${
|
||||||
? ` C${100 - depth},${y - height / 2} ${100 - depth},${y + height / 2} 100,${y + height / 2}`
|
rightBump
|
||||||
: ` H100`
|
? ` C${100 - depth},${y - height / 2} ${100 - depth},${y + height / 2} 100,${y + height / 2}`
|
||||||
}
|
: ` H100`
|
||||||
${cornerBottom
|
}
|
||||||
? ` V${100 - cornerBottom}
|
${
|
||||||
|
cornerBottom
|
||||||
|
? ` V${100 - cornerBottom}
|
||||||
Q100,100 ${100 - cornerBottom * aspectRatio},100
|
Q100,100 ${100 - cornerBottom * aspectRatio},100
|
||||||
H${cornerBottom * aspectRatio}
|
H${cornerBottom * aspectRatio}
|
||||||
Q0,100 0,${100 - cornerBottom}
|
Q0,100 0,${100 - cornerBottom}
|
||||||
`
|
`
|
||||||
: `${leftBump ? `V100 H0` : `V100`}`
|
: `${leftBump ? `V100 H0` : `V100`}`
|
||||||
}
|
}
|
||||||
${leftBump
|
${
|
||||||
? ` V${y + height / 2} C${depth},${y + height / 2} ${depth},${y - height / 2} 0,${y - height / 2}`
|
leftBump
|
||||||
: ` H0`
|
? ` V${y + height / 2} C${depth},${y + height / 2} ${depth},${y - height / 2} 0,${y - height / 2}`
|
||||||
}
|
: ` H0`
|
||||||
|
}
|
||||||
Z`.replace(/\s+/g, " ");
|
Z`.replace(/\s+/g, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,35 +78,14 @@ export const debounce = (fn: Function, ms = 300) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const clone: <T>(v: T) => T = "structedClone" in globalThis ? globalThis.structuredClone : (obj) => JSON.parse(JSON.stringify(obj));
|
export const clone: <T>(v: T) => T =
|
||||||
|
"structedClone" in globalThis
|
||||||
export const createLogger = (() => {
|
? globalThis.structuredClone
|
||||||
let maxLength = 5;
|
: (obj) => JSON.parse(JSON.stringify(obj));
|
||||||
return (scope: string) => {
|
|
||||||
maxLength = Math.max(maxLength, scope.length);
|
|
||||||
let muted = false;
|
|
||||||
return {
|
|
||||||
log: (...args: any[]) => !muted && console.log(`[%c${scope.padEnd(maxLength, " ")}]:`, "color: #888", ...args),
|
|
||||||
group: (...args: any[]) => !muted && console.groupCollapsed(`[%c${scope.padEnd(maxLength, " ")}]:`, "color: #888", ...args),
|
|
||||||
groupEnd: () => !muted && console.groupEnd(),
|
|
||||||
info: (...args: any[]) => !muted && console.info(`[%c${scope.padEnd(maxLength, " ")}]:`, "color: #888", ...args),
|
|
||||||
warn: (...args: any[]) => !muted && console.warn(`[%c${scope.padEnd(maxLength, " ")}]:`, "color: #888", ...args),
|
|
||||||
error: (...args: any[]) => console.error(`[%c${scope.padEnd(maxLength, " ")}]:`, "color: #f88", ...args),
|
|
||||||
mute() {
|
|
||||||
muted = true;
|
|
||||||
},
|
|
||||||
unmute() {
|
|
||||||
muted = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
|
|
||||||
export function withSubComponents<A, B extends Record<string, any>>(
|
export function withSubComponents<A, B extends Record<string, any>>(
|
||||||
component: A,
|
component: A,
|
||||||
subcomponents: B
|
subcomponents: B,
|
||||||
): A & B {
|
): A & B {
|
||||||
Object.keys(subcomponents).forEach((key) => {
|
Object.keys(subcomponents).forEach((key) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { create, type Delta } from "jsondiffpatch";
|
import { create, type Delta } from "jsondiffpatch";
|
||||||
import type { Graph } from "@nodes/types";
|
import type { Graph } from "@nodes/types";
|
||||||
import { createLogger, clone } from "./helpers/index.js";
|
import { clone } from "./helpers/index.js";
|
||||||
|
import { createLogger } from "@nodes/utils";
|
||||||
|
|
||||||
const diff = create({
|
const diff = create({
|
||||||
objectHash: function (obj, index) {
|
objectHash: function (obj, index) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
import { createLogger, createWasmWrapper } from "@nodes/utils";
|
import { createLogger, createWasmWrapper } from "@nodes/utils";
|
||||||
|
|
||||||
const log = createLogger("node-registry");
|
const log = createLogger("node-registry");
|
||||||
log.mute();
|
// log.mute();
|
||||||
|
|
||||||
export class RemoteNodeRegistry implements NodeRegistry {
|
export class RemoteNodeRegistry implements NodeRegistry {
|
||||||
status: "loading" | "ready" | "error" = "loading";
|
status: "loading" | "ready" | "error" = "loading";
|
||||||
|
|||||||
Reference in New Issue
Block a user