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
9 changes: 9 additions & 0 deletions src/lib/components/panels/NodeLibrary.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import { onDestroy } from 'svelte';
import { nodeRegistry, blockConfig, registryVersion, type NodeCategory, type NodeTypeDefinition } from '$lib/nodes';
import { NODE_TYPES } from '$lib/constants/nodeTypes';
import { PYODIDE_HIDDEN_CATEGORIES } from '$lib/constants/python';
import { getBackendType } from '$lib/pyodide/backend';
import { createHoverDetail } from '$lib/actions/hoverDetail.svelte';
import NodePreview from '$lib/components/nodes/NodePreview.svelte';
import Icon from '$lib/components/icons/Icon.svelte';
Expand Down Expand Up @@ -71,6 +73,13 @@
void registryTick;
let nodes = nodeRegistry.getAll().filter((node) => node.type !== NODE_TYPES.INTERFACE);

// Hide backend-incompatible categories (e.g. FMI on the Pyodide backend:
// FMU blocks need the native FMI runtime, not available in the browser).
if (getBackendType() === 'pyodide' && PYODIDE_HIDDEN_CATEGORIES.length > 0) {
const hidden = new Set(PYODIDE_HIDDEN_CATEGORIES);
nodes = nodes.filter((node) => !hidden.has(node.category));
}

if (!searchQuery.trim()) return nodes;
const query = searchQuery.toLowerCase();
return nodes.filter(
Expand Down
16 changes: 16 additions & 0 deletions src/lib/constants/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,29 @@ export const CODE_SECTIONS = {
export const BLOCK_CATEGORY_ORDER: string[] = [
'Sources',
'Dynamic',
'DAE',
'Algebraic',
'Logic',
'Discrete',
'FMI',
'Recording',
'Subsystem'
];

/**
* Block categories hidden when running on the Pyodide (in-browser) backend,
* configurable per distribution via `VITE_PYODIDE_HIDDEN_CATEGORIES`
* (comma-separated). Empty by default. Use this for categories whose blocks
* can't work in the browser sandbox (e.g. FMI/FMU blocks that drive an external
* .fmu through a native runtime) so they're only offered on a native backend.
*/
export const PYODIDE_HIDDEN_CATEGORIES: string[] = (
(import.meta.env.VITE_PYODIDE_HIDDEN_CATEGORIES as string | undefined) ?? ''
)
.split(',')
.map((c) => c.trim())
.filter(Boolean);

/**
* Timeout constants for Pyodide operations (in milliseconds)
*/
Expand Down
Loading