This commit is contained in:
ochafik 2023-03-26 21:36:47 +01:00
commit 8e33e4ed7e
4 changed files with 11 additions and 5 deletions

View file

@ -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
},
{

View file

@ -2,6 +2,8 @@
import { zipArchives } from "./zip-archives";
export const librariesFolder = '/libraries'
declare var BrowserFS: BrowserFSInterface
export type FSMounts = {

View file

@ -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']

View file

@ -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[],