diff --git a/deno.json b/deno.json index 0d3d32f..a843f76 100644 --- a/deno.json +++ b/deno.json @@ -8,7 +8,7 @@ ], "tasks": { "build": "deno run --allow-env --allow-read --allow-write --allow-run packages/cli/main.ts build", - "dev": "deno run --allow-env --allow-read --allow-write --allow-run packages/cli/main.ts dev" + "dev": "deno run --watch --unstable-broadcast-channel --allow-net --allow-env --allow-read --allow-write --allow-run packages/cli/main.ts dev" }, "compilerOptions": { "lib": [ diff --git a/packages/cli/deno.json b/packages/cli/deno.json index 4c83116..38d8fba 100644 --- a/packages/cli/deno.json +++ b/packages/cli/deno.json @@ -4,7 +4,5 @@ "exports": "./main.ts", "imports": { "@cliffy/command": "jsr:@cliffy/command@1.0.0-rc.8", - "@morkdeck/core": "../core/mod.ts", - "@morkdeck/server": "../server/mod.ts" } } diff --git a/packages/core/renderer.ts b/packages/core/renderer.ts index 33b5f72..710c937 100644 --- a/packages/core/renderer.ts +++ b/packages/core/renderer.ts @@ -1,9 +1,12 @@ import Markdoc, { Node } from "@markdoc/markdoc"; import { createMarkdocConfig } from "./markdoc-config.ts"; import { Eta } from "@eta-dev/eta"; +import { resolve } from "@std/path"; import type { RenderOptions } from "./types.ts"; -const eta = new Eta({ views: Deno.cwd() + "/templates" }); +const eta = new Eta({ + views: resolve(import.meta.dirname ?? "", "./templates"), +}); export async function renderPresentationHtml( path: string, diff --git a/packages/server/deno.json b/packages/server/deno.json index c9aa115..f6779c4 100644 --- a/packages/server/deno.json +++ b/packages/server/deno.json @@ -9,6 +9,5 @@ "@std/http": "jsr:@std/http@^1.0.20", "@std/path": "jsr:@std/path@^1.1.1", "esbuild": "npm:esbuild@^0.25.9", - "@morkdeck/core": "../core/mod.ts" } } diff --git a/packages/wc/components/slide.ts b/packages/wc/components/slide.ts index cf4b71b..6248dd5 100644 --- a/packages/wc/components/slide.ts +++ b/packages/wc/components/slide.ts @@ -31,7 +31,7 @@ export class Slide extends MorkdeckElement { align-items: center; padding: 6cqmin; - background: #191724; + background: #1f1d2e; } `; diff --git a/packages/wc/deno.json b/packages/wc/deno.json index 37cfd60..84cb4d2 100644 --- a/packages/wc/deno.json +++ b/packages/wc/deno.json @@ -7,6 +7,5 @@ "lit": "npm:lit@^3.3.1", "@lit/context": "npm:@lit/context@^1.1.6", "motion": "npm:motion@^12.23.12", - "@morkdeck/runtime": "../runtime/mod.ts" } } diff --git a/scripts/dev.ts b/scripts/dev.ts deleted file mode 100644 index 2accb2b..0000000 --- a/scripts/dev.ts +++ /dev/null @@ -1,100 +0,0 @@ -import * as esbuild from "esbuild"; -import { globToRegExp } from "@std/path"; -import { denoPlugin } from "@deno/esbuild-plugin"; -import { debounce } from "@std/async/debounce"; - -const devCommand = new Deno.Command(Deno.execPath(), { - args: [ - "run", - "--unstable-broadcast-channel", - "--allow-env", - "--allow-read", - "--allow-net", - "main.ts", - "dev", - "./slides.mdoc", - ], -}); - -// Watch esbuild watching `runtime/` -async function rebuildRuntime() { - const context = await esbuild.context({ - entryPoints: ["runtime/morkdeck.ts"], - outfile: "dist/morkdeck.js", - bundle: true, - plugins: [denoPlugin()], - }); - - await context.rebuild(); - - return context; -} - -async function dev() { - const watcher = Deno.watchFs("."); - - // Runtime goes first to Morkdeck can serve the output - const ctx = await rebuildRuntime(); - let child = devCommand.spawn(); - - const runtimeGlob = globToRegExp("**/runtime/**/*.ts"); - const rebuild = debounce(async () => { - performance.mark("rebuild-start"); - await ctx.rebuild(); - performance.mark("rebuild-finish"); - const { duration } = performance.measure( - "rebuild-duration", - "rebuild-start", - "rebuild-finish", - ); - - console.log( - `runtime: change detected. rebuilt in ${duration.toFixed(0)}ms`, - ); - }, 150); - - const coreGlob = globToRegExp("**/{core,server,cli}/**/*.ts"); - const restart = debounce(() => { - performance.mark("restart-start"); - child.kill(); - child = devCommand.spawn(); - performance.mark("restart-finish"); - const { duration } = performance.measure( - "restart-duration", - "restart-start", - "restart-finish", - ); - - console.log( - ` core: change detected. restarted in ${duration.toFixed(0)}ms`, - ); - }, 150); - - async function handleEvents() { - for await (const e of watcher) { - if (e.kind === "any" || e.kind === "access" || e.kind === "other") { - continue; - } - - if (e.paths.some((s) => runtimeGlob.test(s))) { - rebuild(); - } - - if (e.paths.some((s) => coreGlob.test(s))) { - restart(); - } - } - } - - handleEvents(); - - Deno.addSignalListener("SIGINT", async () => { - await Promise.all([ - watcher.close(), - child.kill(), - ctx.dispose(), - ]); - }); -} - -if (import.meta.main) await dev();