chore: setup linting
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import "@nodarium/ui/app.css";
|
||||
import "../app.css";
|
||||
import type { Snippet } from "svelte";
|
||||
import * as config from "$lib/config";
|
||||
import '@nodarium/ui/app.css';
|
||||
import '../app.css';
|
||||
import * as config from '$lib/config';
|
||||
import type { Snippet } from 'svelte';
|
||||
const { children } = $props<{ children?: Snippet }>();
|
||||
</script>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
<svelte:head>
|
||||
{#if config.ANALYTIC_SCRIPT}
|
||||
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||
{@html config.ANALYTIC_SCRIPT}
|
||||
{/if}
|
||||
</svelte:head>
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export const prerender = true
|
||||
export const ssr = false
|
||||
export const prerender = true;
|
||||
export const ssr = false;
|
||||
|
||||
@@ -1,40 +1,35 @@
|
||||
<script lang="ts">
|
||||
import Grid from "$lib/grid";
|
||||
import GraphInterface from "$lib/graph-interface";
|
||||
import * as templates from "$lib/graph-templates";
|
||||
import type { Graph, NodeInstance } from "@nodarium/types";
|
||||
import Viewer from "$lib/result-viewer/Viewer.svelte";
|
||||
import {
|
||||
appSettings,
|
||||
AppSettingTypes,
|
||||
} from "$lib/settings/app-settings.svelte";
|
||||
import Keymap from "$lib/sidebar/panels/Keymap.svelte";
|
||||
import Sidebar from "$lib/sidebar/Sidebar.svelte";
|
||||
import { createKeyMap } from "$lib/helpers/createKeyMap";
|
||||
import NodeStore from "$lib/node-store/NodeStore.svelte";
|
||||
import ActiveNodeSettings from "$lib/sidebar/panels/ActiveNodeSettings.svelte";
|
||||
import PerformanceViewer from "$lib/performance/PerformanceViewer.svelte";
|
||||
import Panel from "$lib/sidebar/Panel.svelte";
|
||||
import NestedSettings from "$lib/settings/NestedSettings.svelte";
|
||||
import type { Group } from "three";
|
||||
import ExportSettings from "$lib/sidebar/panels/ExportSettings.svelte";
|
||||
import {
|
||||
MemoryRuntimeCache,
|
||||
WorkerRuntimeExecutor,
|
||||
MemoryRuntimeExecutor,
|
||||
} from "$lib/runtime";
|
||||
import { IndexDBCache, RemoteNodeRegistry } from "@nodarium/registry";
|
||||
import { createPerformanceStore } from "@nodarium/utils";
|
||||
import BenchmarkPanel from "$lib/sidebar/panels/BenchmarkPanel.svelte";
|
||||
import { debounceAsyncFunction } from "$lib/helpers";
|
||||
import GraphSource from "$lib/sidebar/panels/GraphSource.svelte";
|
||||
import { ProjectManager } from "$lib/project-manager/project-manager.svelte";
|
||||
import ProjectManagerEl from "$lib/project-manager/ProjectManager.svelte";
|
||||
import GraphInterface from '$lib/graph-interface';
|
||||
import * as templates from '$lib/graph-templates';
|
||||
import Grid from '$lib/grid';
|
||||
import { debounceAsyncFunction } from '$lib/helpers';
|
||||
import { createKeyMap } from '$lib/helpers/createKeyMap';
|
||||
import { IndexDBCache, RemoteNodeRegistry } from '$lib/node-registry/index';
|
||||
import NodeStore from '$lib/node-store/NodeStore.svelte';
|
||||
import PerformanceViewer from '$lib/performance/PerformanceViewer.svelte';
|
||||
import { ProjectManager } from '$lib/project-manager/project-manager.svelte';
|
||||
import ProjectManagerEl from '$lib/project-manager/ProjectManager.svelte';
|
||||
import Viewer from '$lib/result-viewer/Viewer.svelte';
|
||||
import { MemoryRuntimeCache, MemoryRuntimeExecutor, WorkerRuntimeExecutor } from '$lib/runtime';
|
||||
import type { SettingsValue } from '$lib/settings';
|
||||
import { appSettings, AppSettingTypes } from '$lib/settings/app-settings.svelte';
|
||||
import NestedSettings from '$lib/settings/NestedSettings.svelte';
|
||||
import Panel from '$lib/sidebar/Panel.svelte';
|
||||
import ActiveNodeSettings from '$lib/sidebar/panels/ActiveNodeSettings.svelte';
|
||||
import BenchmarkPanel from '$lib/sidebar/panels/BenchmarkPanel.svelte';
|
||||
import ExportSettings from '$lib/sidebar/panels/ExportSettings.svelte';
|
||||
import GraphSource from '$lib/sidebar/panels/GraphSource.svelte';
|
||||
import Keymap from '$lib/sidebar/panels/Keymap.svelte';
|
||||
import Sidebar from '$lib/sidebar/Sidebar.svelte';
|
||||
import type { Graph, NodeInstance } from '@nodarium/types';
|
||||
import { createPerformanceStore } from '@nodarium/utils';
|
||||
import { onMount } from 'svelte';
|
||||
import type { Group } from 'three';
|
||||
|
||||
let performanceStore = createPerformanceStore();
|
||||
|
||||
const registryCache = new IndexDBCache("node-registry");
|
||||
const nodeRegistry = new RemoteNodeRegistry("", registryCache);
|
||||
const registryCache = new IndexDBCache('node-registry');
|
||||
const nodeRegistry = new RemoteNodeRegistry('', registryCache);
|
||||
const workerRuntime = new WorkerRuntimeExecutor();
|
||||
const runtimeCache = new MemoryRuntimeCache();
|
||||
const memoryRuntime = new MemoryRuntimeExecutor(nodeRegistry, runtimeCache);
|
||||
@@ -42,14 +37,12 @@
|
||||
const pm = new ProjectManager();
|
||||
|
||||
const runtime = $derived(
|
||||
appSettings.value.debug.useWorker ? workerRuntime : memoryRuntime,
|
||||
appSettings.value.debug.useWorker ? workerRuntime : memoryRuntime
|
||||
);
|
||||
|
||||
$effect(() => {
|
||||
workerRuntime.useRegistryCache =
|
||||
appSettings.value.debug.cache.useRuntimeCache;
|
||||
workerRuntime.useRuntimeCache =
|
||||
appSettings.value.debug.cache.useRegistryCache;
|
||||
workerRuntime.useRegistryCache = appSettings.value.debug.cache.useRuntimeCache;
|
||||
workerRuntime.useRuntimeCache = appSettings.value.debug.cache.useRegistryCache;
|
||||
|
||||
if (appSettings.value.debug.cache.useRegistryCache) {
|
||||
nodeRegistry.cache = registryCache;
|
||||
@@ -80,15 +73,15 @@
|
||||
|
||||
let applicationKeymap = createKeyMap([
|
||||
{
|
||||
key: "r",
|
||||
description: "Regenerate the plant model",
|
||||
callback: () => randomGenerate(),
|
||||
},
|
||||
key: 'r',
|
||||
description: 'Regenerate the plant model',
|
||||
callback: () => randomGenerate()
|
||||
}
|
||||
]);
|
||||
|
||||
let graphSettings = $state<Record<string, any>>({});
|
||||
let graphSettings = $state<SettingsValue>({});
|
||||
let graphSettingTypes = $state({
|
||||
randomSeed: { type: "boolean", value: false },
|
||||
randomSeed: { type: 'boolean', value: false }
|
||||
});
|
||||
$effect(() => {
|
||||
if (graphSettings && graphSettingTypes) {
|
||||
@@ -98,7 +91,7 @@
|
||||
|
||||
async function update(
|
||||
g: Graph,
|
||||
s: Record<string, any> = $state.snapshot(graphSettings),
|
||||
s: Record<string, unknown> = $state.snapshot(graphSettings)
|
||||
) {
|
||||
performanceStore.startRun();
|
||||
try {
|
||||
@@ -114,14 +107,14 @@
|
||||
delete lastRun.total;
|
||||
performanceStore.mergeData(lastRun);
|
||||
performanceStore.addPoint(
|
||||
"worker-transfer",
|
||||
b - a - lastRun.runtime[0],
|
||||
'worker-transfer',
|
||||
b - a - lastRun.runtime[0]
|
||||
);
|
||||
}
|
||||
}
|
||||
viewerComponent?.update(graphResult);
|
||||
} catch (error) {
|
||||
console.log("errors", error);
|
||||
console.log('errors', error);
|
||||
} finally {
|
||||
performanceStore.stopRun();
|
||||
}
|
||||
@@ -129,31 +122,29 @@
|
||||
|
||||
const handleUpdate = debounceAsyncFunction(update);
|
||||
|
||||
$effect(() => {
|
||||
//@ts-ignore
|
||||
AppSettingTypes.debug.stressTest.loadGrid.callback = () => {
|
||||
manager.load(
|
||||
templates.grid(
|
||||
appSettings.value.debug.stressTest.amount,
|
||||
appSettings.value.debug.stressTest.amount,
|
||||
),
|
||||
);
|
||||
};
|
||||
//@ts-ignore
|
||||
AppSettingTypes.debug.stressTest.loadTree.callback = () => {
|
||||
manager.load(templates.tree(appSettings.value.debug.stressTest.amount));
|
||||
};
|
||||
//@ts-ignore
|
||||
AppSettingTypes.debug.stressTest.lottaFaces.callback = () => {
|
||||
manager.load(templates.lottaFaces as unknown as Graph);
|
||||
};
|
||||
//@ts-ignore
|
||||
AppSettingTypes.debug.stressTest.lottaNodes.callback = () => {
|
||||
manager.load(templates.lottaNodes as unknown as Graph);
|
||||
};
|
||||
//@ts-ignore
|
||||
AppSettingTypes.debug.stressTest.lottaNodesAndFaces.callback = () => {
|
||||
manager.load(templates.lottaNodesAndFaces as unknown as Graph);
|
||||
onMount(() => {
|
||||
appSettings.value.debug.stressTest = {
|
||||
...appSettings.value.debug.stressTest,
|
||||
loadGrid: () => {
|
||||
manager.load(
|
||||
templates.grid(
|
||||
appSettings.value.debug.stressTest.amount,
|
||||
appSettings.value.debug.stressTest.amount
|
||||
)
|
||||
);
|
||||
},
|
||||
loadTree: () => {
|
||||
manager.load(templates.tree(appSettings.value.debug.stressTest.amount));
|
||||
},
|
||||
lottaFaces: () => {
|
||||
manager.load(templates.lottaFaces as unknown as Graph);
|
||||
},
|
||||
lottaNodes: () => {
|
||||
manager.load(templates.lottaNodes as unknown as Graph);
|
||||
},
|
||||
lottaNodesAndFaces: () => {
|
||||
manager.load(templates.lottaNodesAndFaces as unknown as Graph);
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
@@ -184,7 +175,7 @@
|
||||
bind:settings={graphSettings}
|
||||
bind:settingTypes={graphSettingTypes}
|
||||
onsave={(g) => pm.saveGraph(g)}
|
||||
onresult={(result) => handleUpdate(result)}
|
||||
onresult={(result) => handleUpdate(result as Graph)}
|
||||
/>
|
||||
{/if}
|
||||
<Sidebar>
|
||||
@@ -202,8 +193,8 @@
|
||||
>
|
||||
<Keymap
|
||||
keymaps={[
|
||||
{ keymap: applicationKeymap, title: "Application" },
|
||||
{ keymap: graphInterface?.keymap, title: "Node-Editor" },
|
||||
{ keymap: applicationKeymap, title: 'Application' },
|
||||
{ keymap: graphInterface?.keymap, title: 'Node-Editor' }
|
||||
]}
|
||||
/>
|
||||
</Panel>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from "svelte";
|
||||
import type { Snippet } from 'svelte';
|
||||
const { children } = $props<{ children?: Snippet }>();
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
<script lang="ts">
|
||||
import NodeHTML from "$lib/graph-interface/node/NodeHTML.svelte";
|
||||
import { localState } from "$lib/helpers/localState.svelte";
|
||||
import Panel from "$lib/sidebar/Panel.svelte";
|
||||
import Sidebar from "$lib/sidebar/Sidebar.svelte";
|
||||
import { IndexDBCache, RemoteNodeRegistry } from "@nodarium/registry";
|
||||
import { type NodeId, type NodeInstance } from "@nodarium/types";
|
||||
import Code from "./Code.svelte";
|
||||
import Grid from "$lib/grid";
|
||||
import {
|
||||
concatEncodedArrays,
|
||||
createWasmWrapper,
|
||||
encodeNestedArray,
|
||||
} from "@nodarium/utils";
|
||||
import NodeHTML from '$lib/graph-interface/node/NodeHTML.svelte';
|
||||
import Grid from '$lib/grid';
|
||||
import { localState } from '$lib/helpers/localState.svelte';
|
||||
import { IndexDBCache, RemoteNodeRegistry } from '$lib/node-registry/index';
|
||||
import Panel from '$lib/sidebar/Panel.svelte';
|
||||
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);
|
||||
const registryCache = new IndexDBCache('node-registry');
|
||||
const nodeRegistry = new RemoteNodeRegistry('', registryCache);
|
||||
|
||||
let activeNode = localState<NodeId | undefined>(
|
||||
"node.dev.activeNode",
|
||||
undefined,
|
||||
'node.dev.activeNode',
|
||||
undefined
|
||||
);
|
||||
|
||||
let nodeWasm = $state<ArrayBuffer>();
|
||||
@@ -32,17 +28,21 @@
|
||||
if (!nodeId) return;
|
||||
|
||||
const data = await nodeRegistry.fetchNodeDefinition(nodeId);
|
||||
nodeWasm = await nodeRegistry.fetchArrayBuffer("nodes/" + nodeId + ".wasm");
|
||||
nodeWasm = await nodeRegistry.fetchArrayBuffer('nodes/' + nodeId + '.wasm');
|
||||
nodeInstance = {
|
||||
id: 0,
|
||||
type: nodeId,
|
||||
position: [0, 0] as [number, number],
|
||||
props: {},
|
||||
state: {
|
||||
type: data,
|
||||
},
|
||||
type: data
|
||||
}
|
||||
};
|
||||
nodeWasmWrapper = createWasmWrapper(nodeWasm);
|
||||
try {
|
||||
nodeWasmWrapper = createWasmWrapper(nodeWasm);
|
||||
} catch (e) {
|
||||
console.error(`Failed to create node wrapper for ${nodeId}`, e);
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
@@ -52,8 +52,8 @@
|
||||
$effect(() => {
|
||||
if (nodeInstance?.props && nodeWasmWrapper) {
|
||||
const keys = Object.keys(nodeInstance.state.type?.inputs || {});
|
||||
let ins = Object.values(nodeInstance.props) as number[];
|
||||
if (keys[0] === "plant") {
|
||||
let ins = Object.values(nodeInstance.props) as (number[] | number)[];
|
||||
if (keys[0] === 'plant') {
|
||||
ins = [[0, 0, 0, 0, 0, 0, 0, 0], ...ins];
|
||||
}
|
||||
const inputs = concatEncodedArrays(encodeNestedArray(ins));
|
||||
@@ -94,16 +94,20 @@
|
||||
icon="i-[tabler--database]"
|
||||
>
|
||||
<div class="p-4 flex flex-col gap-2">
|
||||
{#await nodeRegistry.fetchCollection("max/plantarium")}
|
||||
{#await nodeRegistry.fetchCollection('max/plantarium')}
|
||||
<p>Loading Nodes...</p>
|
||||
{:then result}
|
||||
{#each result.nodes as n}
|
||||
{#each result.nodes as n (n.id)}
|
||||
<button
|
||||
class="cursor-pointer p-2 bg-layer-1 {activeNode.value === n.id
|
||||
class="
|
||||
cursor-pointer p-2 bg-layer-1 {activeNode.value === n.id
|
||||
? 'outline outline-offset-1'
|
||||
: ''}"
|
||||
onclick={() => (activeNode.value = n.id)}>{n.id}</button
|
||||
: ''}
|
||||
"
|
||||
onclick={() => (activeNode.value = n.id)}
|
||||
>
|
||||
{n.id}
|
||||
</button>
|
||||
{/each}
|
||||
{/await}
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import wabtInit from "wabt";
|
||||
import wabtInit from 'wabt';
|
||||
|
||||
const { wasm } = $props<{ wasm: ArrayBuffer }>();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
const wabt = await wabtInit();
|
||||
|
||||
const module = wabt.readWasm(new Uint8Array(arrayBuffer), {
|
||||
readDebugNames: true,
|
||||
readDebugNames: true
|
||||
});
|
||||
|
||||
module.generateNames();
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
import { json } from "@sveltejs/kit";
|
||||
import type { EntryGenerator, RequestHandler } from "./$types";
|
||||
import * as registry from "$lib/node-registry";
|
||||
|
||||
import * as registry from '$lib/node-registry';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { EntryGenerator, RequestHandler } from './$types';
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export const entries: EntryGenerator = async () => {
|
||||
const users = await registry.getUsers();
|
||||
return users.map(user => {
|
||||
return { user: user.id }
|
||||
return { user: user.id };
|
||||
}).flat(2);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export const GET: RequestHandler = async function GET({ params }) {
|
||||
|
||||
const namespaces = await registry.getUser(params.user)
|
||||
const namespaces = await registry.getUser(params.user);
|
||||
|
||||
return json(namespaces);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { json } from "@sveltejs/kit";
|
||||
import type { EntryGenerator, RequestHandler } from "./$types";
|
||||
import * as registry from "$lib/node-registry";
|
||||
import * as registry from '$lib/node-registry';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { EntryGenerator, RequestHandler } from './$types';
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
@@ -8,15 +8,13 @@ export const entries: EntryGenerator = async () => {
|
||||
const users = await registry.getUsers();
|
||||
return users.map(user => {
|
||||
return user.collections.map(collection => {
|
||||
return { user: user.id, collection: collection.id.split("/")[1] }
|
||||
})
|
||||
return { user: user.id, collection: collection.id.split('/')[1] };
|
||||
});
|
||||
}).flat(2);
|
||||
}
|
||||
};
|
||||
|
||||
export const GET: RequestHandler = async function GET({ params }) {
|
||||
|
||||
const namespaces = await registry.getCollection(`${params.user}/${params.collection}`);
|
||||
|
||||
return json(namespaces);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
import { json } from "@sveltejs/kit";
|
||||
import type { EntryGenerator, RequestHandler } from "./$types";
|
||||
import { getNode } from "$lib/node-registry";
|
||||
import * as registry from "$lib/node-registry";
|
||||
import { getNode } from '$lib/node-registry';
|
||||
import * as registry from '$lib/node-registry';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { EntryGenerator, RequestHandler } from './$types';
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
|
||||
export const entries: EntryGenerator = async () => {
|
||||
const users = await registry.getUsers();
|
||||
return users.map(user => {
|
||||
return user.collections.map(collection => {
|
||||
return collection.nodes.map(node => {
|
||||
return { user: user.id, collection: collection.id.split("/")[1], node: node.id.split("/")[2] }
|
||||
return {
|
||||
user: user.id,
|
||||
collection: collection.id.split('/')[1],
|
||||
node: node.id.split('/')[2]
|
||||
};
|
||||
});
|
||||
})
|
||||
});
|
||||
}).flat(2);
|
||||
}
|
||||
};
|
||||
|
||||
export const GET: RequestHandler = async function GET({ params }) {
|
||||
|
||||
const nodeId = `${params.user}/${params.collection}/${params.node}` as const;
|
||||
|
||||
try {
|
||||
const node = await getNode(nodeId);
|
||||
return json(node);
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
return new Response("Not found", { status: 404 });
|
||||
console.log(err);
|
||||
return new Response('Not found', { status: 404 });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { EntryGenerator, RequestHandler } from "./$types";
|
||||
import * as registry from "$lib/node-registry";
|
||||
import * as registry from '$lib/node-registry';
|
||||
import type { EntryGenerator, RequestHandler } from './$types';
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
@@ -11,8 +11,8 @@ export const entries: EntryGenerator = async () => {
|
||||
return collection.nodes.map((node) => {
|
||||
return {
|
||||
user: user.id,
|
||||
collection: collection.id.split("/")[1],
|
||||
node: node.id.split("/")[2],
|
||||
collection: collection.id.split('/')[1],
|
||||
node: node.id.split('/')[2]
|
||||
};
|
||||
});
|
||||
});
|
||||
@@ -22,15 +22,15 @@ export const entries: EntryGenerator = async () => {
|
||||
|
||||
export const GET: RequestHandler = async function GET({ params }) {
|
||||
const wasm = await registry.getWasm(
|
||||
`${params.user}/${params.collection}/${params.node}`,
|
||||
`${params.user}/${params.collection}/${params.node}`
|
||||
);
|
||||
|
||||
if (!wasm) {
|
||||
return new Response("Not found", { status: 404 });
|
||||
return new Response('Not found', { status: 404 });
|
||||
}
|
||||
|
||||
return new Response(wasm, {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/wasm" },
|
||||
headers: { 'Content-Type': 'application/wasm' }
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { json } from "@sveltejs/kit";
|
||||
import type { RequestHandler } from "./$types";
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
import * as registry from "$lib/node-registry";
|
||||
import * as registry from '$lib/node-registry';
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export const GET: RequestHandler = async function GET() {
|
||||
|
||||
const users = await registry.getUsers();
|
||||
|
||||
return json(users);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user