diff --git a/src/lib/components/panels/NodeLibrary.svelte b/src/lib/components/panels/NodeLibrary.svelte index 0e4b0aba..0c1e9094 100644 --- a/src/lib/components/panels/NodeLibrary.svelte +++ b/src/lib/components/panels/NodeLibrary.svelte @@ -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'; @@ -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( diff --git a/src/lib/constants/python.ts b/src/lib/constants/python.ts index 0a5664e2..985b7364 100644 --- a/src/lib/constants/python.ts +++ b/src/lib/constants/python.ts @@ -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) */