From d3e8c0d4348cea929a59208e6d7ac38456148525 Mon Sep 17 00:00:00 2001 From: Jack <34489450+fenjalien@users.noreply.github.com> Date: Fri, 18 Aug 2023 19:47:22 +0100 Subject: [PATCH] restructure project --- .gitignore | 10 +++++----- Cargo.lock => compiler/Cargo.lock | 0 Cargo.toml => compiler/Cargo.toml | 0 .../assets}/fonts/DejaVuSansMono-Bold.ttf | Bin .../assets}/fonts/DejaVuSansMono-BoldOblique.ttf | Bin .../assets}/fonts/DejaVuSansMono-Oblique.ttf | Bin .../assets}/fonts/DejaVuSansMono.ttf | Bin .../assets}/fonts/LinLibertine_R.ttf | Bin .../assets}/fonts/LinLibertine_RB.ttf | Bin .../assets}/fonts/LinLibertine_RBI.ttf | Bin .../assets}/fonts/LinLibertine_RI.ttf | Bin .../assets}/fonts/NewCMMath-Book.otf | Bin .../assets}/fonts/NewCMMath-Regular.otf | Bin {src => compiler/src}/lib.rs | 0 {src => compiler/src}/paths.rs | 0 esbuild.config.mjs | 2 +- package.json | 9 +++++---- compiler.worker.ts => src/compiler.worker.ts | 6 +++--- main.ts => src/main.ts | 4 ++-- types.d.ts => src/types.d.ts | 0 .../typst-canvas-element.ts | 0 21 files changed, 16 insertions(+), 15 deletions(-) rename Cargo.lock => compiler/Cargo.lock (100%) rename Cargo.toml => compiler/Cargo.toml (100%) rename {assets => compiler/assets}/fonts/DejaVuSansMono-Bold.ttf (100%) rename {assets => compiler/assets}/fonts/DejaVuSansMono-BoldOblique.ttf (100%) rename {assets => compiler/assets}/fonts/DejaVuSansMono-Oblique.ttf (100%) rename {assets => compiler/assets}/fonts/DejaVuSansMono.ttf (100%) rename {assets => compiler/assets}/fonts/LinLibertine_R.ttf (100%) rename {assets => compiler/assets}/fonts/LinLibertine_RB.ttf (100%) rename {assets => compiler/assets}/fonts/LinLibertine_RBI.ttf (100%) rename {assets => compiler/assets}/fonts/LinLibertine_RI.ttf (100%) rename {assets => compiler/assets}/fonts/NewCMMath-Book.otf (100%) rename {assets => compiler/assets}/fonts/NewCMMath-Regular.otf (100%) rename {src => compiler/src}/lib.rs (100%) rename {src => compiler/src}/paths.rs (100%) rename compiler.worker.ts => src/compiler.worker.ts (89%) rename main.ts => src/main.ts (99%) rename types.d.ts => src/types.d.ts (100%) rename typst-canvas-element.ts => src/typst-canvas-element.ts (100%) diff --git a/.gitignore b/.gitignore index 2bdd00a..0558e7b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,8 +20,8 @@ data.json # Exclude macOS Finder (System Explorer) View States .DS_Store - - -# Added by cargo - -/target + + +# Added by cargo + +target diff --git a/Cargo.lock b/compiler/Cargo.lock similarity index 100% rename from Cargo.lock rename to compiler/Cargo.lock diff --git a/Cargo.toml b/compiler/Cargo.toml similarity index 100% rename from Cargo.toml rename to compiler/Cargo.toml diff --git a/assets/fonts/DejaVuSansMono-Bold.ttf b/compiler/assets/fonts/DejaVuSansMono-Bold.ttf similarity index 100% rename from assets/fonts/DejaVuSansMono-Bold.ttf rename to compiler/assets/fonts/DejaVuSansMono-Bold.ttf diff --git a/assets/fonts/DejaVuSansMono-BoldOblique.ttf b/compiler/assets/fonts/DejaVuSansMono-BoldOblique.ttf similarity index 100% rename from assets/fonts/DejaVuSansMono-BoldOblique.ttf rename to compiler/assets/fonts/DejaVuSansMono-BoldOblique.ttf diff --git a/assets/fonts/DejaVuSansMono-Oblique.ttf b/compiler/assets/fonts/DejaVuSansMono-Oblique.ttf similarity index 100% rename from assets/fonts/DejaVuSansMono-Oblique.ttf rename to compiler/assets/fonts/DejaVuSansMono-Oblique.ttf diff --git a/assets/fonts/DejaVuSansMono.ttf b/compiler/assets/fonts/DejaVuSansMono.ttf similarity index 100% rename from assets/fonts/DejaVuSansMono.ttf rename to compiler/assets/fonts/DejaVuSansMono.ttf diff --git a/assets/fonts/LinLibertine_R.ttf b/compiler/assets/fonts/LinLibertine_R.ttf similarity index 100% rename from assets/fonts/LinLibertine_R.ttf rename to compiler/assets/fonts/LinLibertine_R.ttf diff --git a/assets/fonts/LinLibertine_RB.ttf b/compiler/assets/fonts/LinLibertine_RB.ttf similarity index 100% rename from assets/fonts/LinLibertine_RB.ttf rename to compiler/assets/fonts/LinLibertine_RB.ttf diff --git a/assets/fonts/LinLibertine_RBI.ttf b/compiler/assets/fonts/LinLibertine_RBI.ttf similarity index 100% rename from assets/fonts/LinLibertine_RBI.ttf rename to compiler/assets/fonts/LinLibertine_RBI.ttf diff --git a/assets/fonts/LinLibertine_RI.ttf b/compiler/assets/fonts/LinLibertine_RI.ttf similarity index 100% rename from assets/fonts/LinLibertine_RI.ttf rename to compiler/assets/fonts/LinLibertine_RI.ttf diff --git a/assets/fonts/NewCMMath-Book.otf b/compiler/assets/fonts/NewCMMath-Book.otf similarity index 100% rename from assets/fonts/NewCMMath-Book.otf rename to compiler/assets/fonts/NewCMMath-Book.otf diff --git a/assets/fonts/NewCMMath-Regular.otf b/compiler/assets/fonts/NewCMMath-Regular.otf similarity index 100% rename from assets/fonts/NewCMMath-Regular.otf rename to compiler/assets/fonts/NewCMMath-Regular.otf diff --git a/src/lib.rs b/compiler/src/lib.rs similarity index 100% rename from src/lib.rs rename to compiler/src/lib.rs diff --git a/src/paths.rs b/compiler/src/paths.rs similarity index 100% rename from src/paths.rs rename to compiler/src/paths.rs diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 98bb03a..e379414 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -47,7 +47,7 @@ const context = await esbuild.context({ banner: { js: banner, }, - entryPoints: ["main.ts"], + entryPoints: ["src/main.ts"], bundle: true, external: [ "obsidian", diff --git a/package.json b/package.json index ea50be5..784ea74 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,12 @@ "description": "Renders `typst` code blocks to images with Typst.", "main": "main.js", "scripts": { - "wasm": "wasm-pack build --target web", - "dev": "node esbuild.config.mjs", - "wasm-dev": "wasm-pack build --target web --dev && node esbuild.config.mjs", - "wasm-build": "wasm-pack build --target web && tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", + "build-dev": "node esbuild.config.mjs", "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", + "wasm": "wasm-pack build compiler --target web", + "wasm-dev": "wasm-pack build compiler --target web --dev", + "wasm-build-dev": "npm run wasm-dev && npm run build-dev", + "wasm-build": "npm run wasm && npm run build", "version": "node version-bump.mjs && git add manifest.json versions.json" }, "keywords": [], diff --git a/compiler.worker.ts b/src/compiler.worker.ts similarity index 89% rename from compiler.worker.ts rename to src/compiler.worker.ts index 4a75663..85dc438 100644 --- a/compiler.worker.ts +++ b/src/compiler.worker.ts @@ -1,8 +1,8 @@ //@ts-ignore -import wasmBin from './pkg/obsidian_typst_bg.wasm' -import * as typst from './pkg' +import wasmBin from '../pkg/obsidian_typst_bg.wasm' +import * as typst from '../pkg' -import { CompileCommand, WorkerRequest } from "types"; +import { CompileCommand, WorkerRequest } from "src/types"; typst.initSync(wasmBin); diff --git a/main.ts b/src/main.ts similarity index 99% rename from main.ts rename to src/main.ts index 13bcdca..d0cb6e5 100644 --- a/main.ts +++ b/src/main.ts @@ -3,8 +3,8 @@ import { App, renderMath, HexString, Platform, Plugin, PluginSettingTab, Setting // @ts-ignore import CompilerWorker from "./compiler.worker.ts" -import TypstCanvasElement from 'typst-canvas-element'; -import { WorkerRequest } from 'types.js'; +import TypstCanvasElement from './typst-canvas-element'; +import { WorkerRequest } from './types'; interface TypstPluginSettings { noFill: boolean, diff --git a/types.d.ts b/src/types.d.ts similarity index 100% rename from types.d.ts rename to src/types.d.ts diff --git a/typst-canvas-element.ts b/src/typst-canvas-element.ts similarity index 100% rename from typst-canvas-element.ts rename to src/typst-canvas-element.ts