Merge pull request #33 from ochafik/rel-imports

Fix relative imports
This commit is contained in:
Olivier Chafik 2024-06-29 01:30:36 +01:00 committed by GitHub
commit 38806c13f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 7 additions and 9 deletions

View file

@ -97,7 +97,7 @@ libs/NopSCADlib:
public/libraries/NopSCADlib.zip: libs/NopSCADlib
mkdir -p public/libraries
( cd libs/NopSCADlib ; zip -r ../../public/libraries/NopSCADlib.zip `find . -name '*.scad' | grep -v tests` COPYING )
( cd libs/NopSCADlib ; zip -r ../../public/libraries/NopSCADlib.zip `find . -name '*.scad'` COPYING )
libs/funcutils:
git clone --recurse https://github.com/thehans/funcutils.git ${SHALLOW} ${SINGLE_BRANCH} $@

View file

@ -14,7 +14,6 @@ export const getParentDir = (path: string) => {
let d = path.split('/').slice(0, -1).join('/');
return d === '' ? (path.startsWith('/') ? '/' : '.') : d;
}
export const getFileName = (path: string) => path.split('/').splice(-1)[0];
export function readDirAsArray(fs: FS, path: string): Promise<string[] | undefined> {
return new Promise((res, rej) => fs.readdir(path, (err, files) => err ? rej(err) : res(files)));

View file

@ -1,7 +1,7 @@
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
import { getFileName, getParentDir } from '../fs/filesystem';
import { getParentDir } from '../fs/filesystem';
import { spawnOpenSCAD } from "./openscad-runner";
import { processMergedOutputs } from "./output-parser";
import { AbortablePromise, turnIntoDelayableExecution } from '../utils';
@ -14,7 +14,6 @@ export const checkSyntax =
// const timestamp = Date.now();
source = '$preview=true;\n' + source;
sourcePath = getFileName(sourcePath);
const job = spawnOpenSCAD({
inputs: [[sourcePath, source + '\n']],
@ -58,7 +57,6 @@ export const render =
prefixLines.push('$preview=true;');
}
source = [...prefixLines, source].join('\n');
sourcePath = getFileName(sourcePath);
const args = [
sourcePath,

View file

@ -1,5 +1,4 @@
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
import { getFileName } from '../fs/filesystem';
import { MergedOutputs } from "./openscad-worker";
const ignoredLogs = new Set([
@ -45,10 +44,10 @@ export function parseMergedOutputs(mergedOutputs: MergedOutputs, opts: MergedOut
severity: monaco.MarkerSeverity.Error
})
}
const shiftSourceName = opts.shiftSourceLines && getFileName(opts.shiftSourceLines.sourcePath);
const shiftSourceName = opts.shiftSourceLines && opts.shiftSourceLines.sourcePath;
const getLine = (path: string, lineStr: string) => {
const line = Number(lineStr);
if (shiftSourceName && getFileName(path) == shiftSourceName) {
if (shiftSourceName && (path == shiftSourceName)) {
return line - opts.shiftSourceLines!.skipLines;
} else {
return line;

View file

@ -17,6 +17,7 @@ async function compressString(input: string): Promise<string> {
controller.close();
}
});
// @ts-ignore
const compressedStream = stream.pipeThrough(new CompressionStream('gzip'));
const compressedData = await new Response(compressedStream).arrayBuffer();
return btoa(String.fromCharCode(...new Uint8Array(compressedData)));
@ -31,6 +32,7 @@ async function decompressString(compressedInput: string): Promise<string> {
}
});
// @ts-ignore
const decompressedStream = stream.pipeThrough(new DecompressionStream('gzip'));
const decompressedData = await new Response(decompressedStream).arrayBuffer();
return new TextDecoder().decode(decompressedData);

View file

@ -4,7 +4,7 @@
"lib": [
"dom",
"dom.iterable",
"ES2023",
"ES2021",
"WebWorker",
],
"rootDir": "src",