{ const ts = new Date().toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' }); pm.handleCreateProject( structuredClone(templates.defaultPlant) as unknown as Graph, `Tutorial Project (${ts})` ); }, 'load-tutorial-template': () => { if (!pm.graph) return; const g = structuredClone(templates.tutorial) as unknown as Graph; g.id = pm.graph.id; g.meta = { ...pm.graph.meta }; pm.graph = g; pm.saveGraph(g); graphInterface.state.centerNode(graphInterface.manager.getAllNodes()[0]); }, 'open-github-nodes': () => { window.open( 'https://github.com/jim-fx/nodarium/tree/main/nodes/max/plantarium', '__blank' ); } }} hooks={{ 'action:add_stem_node': (cb) => { const unsub = manager.on('save', () => { const allNodes = graphInterface.manager.getAllNodes(); const stemNode = allNodes.find(n => n.type === 'max/plantarium/stem'); if (stemNode && graphInterface.manager.edges.length) { unsub(); (cb as () => void)(); } }); }, 'action:add_noise_node': (cb) => { const unsub = manager.on('save', () => { const allNodes = graphInterface.manager.getAllNodes(); const noiseNode = allNodes.find(n => n.type === 'max/plantarium/noise'); if (noiseNode && graphInterface.manager.edges.length > 1) { unsub(); (cb as () => void)(); } }); }, 'action:add_random_node': (cb) => { const unsub = manager.on('save', () => { const allNodes = graphInterface.manager.getAllNodes(); const noiseNode = allNodes.find(n => n.type === 'max/plantarium/random'); if (noiseNode && graphInterface.manager.edges.length > 2) { unsub(); (cb as () => void)(); } }); }, 'action:prompt_regenerate': (cb) => { function handleKeydown(e: KeyboardEvent) { if (e.key === 'r') { window.removeEventListener('keydown', handleKeydown); (cb as () => void)(); } } window.addEventListener('keydown', handleKeydown); }, 'before:save_project': () => panelState.setActivePanel('projects'), 'before:export_tour': () => panelState.setActivePanel('exports'), 'before:shortcuts_tour': () => panelState.setActivePanel('shortcuts'), 'after:save_project': () => panelState.setActivePanel('graph-settings'), 'before:tour_runtime_nerd': () => panelState.setActivePanel('general') }} />
{#if pm.graph} pm.saveGraph(g)} onresult={(result) => handleUpdate(result as Graph)} /> {/if} {#if 0 > 1} {/if}