5392320Interactive illustration of Floater-Hormann barycentric rational interpolationJeremy Magland 1// The MATLAB sources, inlined into the bundle at build time.
2//
3// driver.m is not a workspace file of its own: it is prepended to whichever
4// method script is in the editor, so that the functions the method defines are
5// local functions of the driver and are visible to it. Everything in
6// src/matlab/lib is a genuine function file and goes into the session as is.
7import type { BootFile } from 'numbl/browser'
9import driverSrc from '../matlab/driver.m?raw'
11const libRaw = import.meta.glob('../matlab/lib/*.m', {
12 query: '?raw',
13 import: 'default',
14 eager: true,
15}) as Record<string, string>
17export const DRIVER = driverSrc
19export const LIB_FILES: BootFile[] = Object.entries(libRaw).map(([path, content]) => ({
20 path: path.slice(path.lastIndexOf('/') + 1),
21 content,
22}))
24/** The files a session boots with, for a given method script. */
25export function bootFiles(methodScript: string): BootFile[] {
26 return [
27 ...LIB_FILES,
28 { path: 'main.m', content: `${DRIVER}\n${methodScript}` },
29 // params.json is overwritten before every run; it only needs to exist so
30 // that the first fileread has something to find.
31 { path: 'params.json', content: '{}' },
32 ]
33}