diff --git a/src/components/FilePicker.tsx b/src/components/FilePicker.tsx index df37229..25521cc 100644 --- a/src/components/FilePicker.tsx +++ b/src/components/FilePicker.tsx @@ -8,7 +8,9 @@ import { ModelContext, FSContext } from './contexts'; export const isFileWritable = (path: string) => getParentDir(path) === '/home' -function listFilesAsNodes(fs: FS, path: string): TreeNode[] { +// export const isFileWritable = (path: string) => !path.startsWith(librariesFolder + '/'); + +function listFilesAsNodes(fs: FS, path: string, accept?: (path: string) => boolean): TreeNode[] { const files: [string, string][] = [] const dirs: [string, string][] = [] for (const name of fs.readdirSync(path)) { @@ -16,6 +18,9 @@ function listFilesAsNodes(fs: FS, path: string): TreeNode[] { continue; } const childPath = `${path}/${name}`; + if (accept && !accept(childPath)) { + continue; + } const stat = fs.lstatSync(childPath); const isDirectory = stat.isDirectory(); if (!isDirectory && !name.endsWith('.scad')) { @@ -58,7 +63,8 @@ export default function FilePicker({className, style}: {className?: string, styl icon: 'pi pi-home', label: 'User files', key: '/home', - children: listFilesAsNodes(fs, '/home'), + children: listFilesAsNodes(fs, '/home'),// + // children: listFilesAsNodes(fs, '/', f => f != librariesFolder && !f.startsWith(`${librariesFolder}/`)), selectable: false }, { diff --git a/src/fs/filesystem.ts b/src/fs/filesystem.ts index 9eaded9..3344e7a 100644 --- a/src/fs/filesystem.ts +++ b/src/fs/filesystem.ts @@ -2,6 +2,8 @@ import { zipArchives } from "./zip-archives"; +export const librariesFolder = '/libraries' + declare var BrowserFS: BrowserFSInterface export type FSMounts = { diff --git a/src/runner/actions.ts b/src/runner/actions.ts index dadae26..a7a72f8 100644 --- a/src/runner/actions.ts +++ b/src/runner/actions.ts @@ -16,7 +16,6 @@ export const checkSyntax = source = '$preview=true;\n' + source; const job = spawnOpenSCAD({ - workingDir: getParentDir(sourcePath), inputs: [[sourcePath, source + '\n']], args: [sourcePath, "-o", "out.ast"], }); @@ -67,7 +66,6 @@ export const render = const job = spawnOpenSCAD({ // wasmMemory, - workingDir: getParentDir(params.sourcePath), inputs: [[params.sourcePath, source]], args, outputPaths: ['/home/out.stl'] diff --git a/src/runner/openscad-runner.ts b/src/runner/openscad-runner.ts index 39eca33..9be83cf 100644 --- a/src/runner/openscad-runner.ts +++ b/src/runner/openscad-runner.ts @@ -18,7 +18,7 @@ export function createWasmMemory({maximumMegabytes, maximumBytes}: {maximumMegab // Output is {outputs: [name, content][], mergedOutputs: [{(stderr|stdout|error)?: string}], exitCode: number} export type OpenSCADInvocation = { wasmMemory?: WebAssembly.Memory, - workingDir: string, + // workingDir: string, inputs?: [string, string][], args: string[], outputPaths?: string[],