+1
-1
deno.json
+1
-1
deno.json
···
8
8
],
9
9
"tasks": {
10
10
"build": "deno run --allow-env --allow-read --allow-write --allow-run packages/cli/main.ts build",
11
-
"dev": "deno run --allow-env --allow-read --allow-write --allow-run packages/cli/main.ts dev"
11
+
"dev": "deno run --watch --unstable-broadcast-channel --allow-net --allow-env --allow-read --allow-write --allow-run packages/cli/main.ts dev"
12
12
},
13
13
"compilerOptions": {
14
14
"lib": [
-2
packages/cli/deno.json
-2
packages/cli/deno.json
+4
-1
packages/core/renderer.ts
+4
-1
packages/core/renderer.ts
···
1
1
import Markdoc, { Node } from "@markdoc/markdoc";
2
2
import { createMarkdocConfig } from "./markdoc-config.ts";
3
3
import { Eta } from "@eta-dev/eta";
4
+
import { resolve } from "@std/path";
4
5
import type { RenderOptions } from "./types.ts";
5
6
6
-
const eta = new Eta({ views: Deno.cwd() + "/templates" });
7
+
const eta = new Eta({
8
+
views: resolve(import.meta.dirname ?? "", "./templates"),
9
+
});
7
10
8
11
export async function renderPresentationHtml(
9
12
path: string,
-1
packages/server/deno.json
-1
packages/server/deno.json
+1
-1
packages/wc/components/slide.ts
+1
-1
packages/wc/components/slide.ts
-1
packages/wc/deno.json
-1
packages/wc/deno.json
-100
scripts/dev.ts
-100
scripts/dev.ts
···
1
-
import * as esbuild from "esbuild";
2
-
import { globToRegExp } from "@std/path";
3
-
import { denoPlugin } from "@deno/esbuild-plugin";
4
-
import { debounce } from "@std/async/debounce";
5
-
6
-
const devCommand = new Deno.Command(Deno.execPath(), {
7
-
args: [
8
-
"run",
9
-
"--unstable-broadcast-channel",
10
-
"--allow-env",
11
-
"--allow-read",
12
-
"--allow-net",
13
-
"main.ts",
14
-
"dev",
15
-
"./slides.mdoc",
16
-
],
17
-
});
18
-
19
-
// Watch esbuild watching `runtime/`
20
-
async function rebuildRuntime() {
21
-
const context = await esbuild.context({
22
-
entryPoints: ["runtime/morkdeck.ts"],
23
-
outfile: "dist/morkdeck.js",
24
-
bundle: true,
25
-
plugins: [denoPlugin()],
26
-
});
27
-
28
-
await context.rebuild();
29
-
30
-
return context;
31
-
}
32
-
33
-
async function dev() {
34
-
const watcher = Deno.watchFs(".");
35
-
36
-
// Runtime goes first to Morkdeck can serve the output
37
-
const ctx = await rebuildRuntime();
38
-
let child = devCommand.spawn();
39
-
40
-
const runtimeGlob = globToRegExp("**/runtime/**/*.ts");
41
-
const rebuild = debounce(async () => {
42
-
performance.mark("rebuild-start");
43
-
await ctx.rebuild();
44
-
performance.mark("rebuild-finish");
45
-
const { duration } = performance.measure(
46
-
"rebuild-duration",
47
-
"rebuild-start",
48
-
"rebuild-finish",
49
-
);
50
-
51
-
console.log(
52
-
`runtime: change detected. rebuilt in ${duration.toFixed(0)}ms`,
53
-
);
54
-
}, 150);
55
-
56
-
const coreGlob = globToRegExp("**/{core,server,cli}/**/*.ts");
57
-
const restart = debounce(() => {
58
-
performance.mark("restart-start");
59
-
child.kill();
60
-
child = devCommand.spawn();
61
-
performance.mark("restart-finish");
62
-
const { duration } = performance.measure(
63
-
"restart-duration",
64
-
"restart-start",
65
-
"restart-finish",
66
-
);
67
-
68
-
console.log(
69
-
` core: change detected. restarted in ${duration.toFixed(0)}ms`,
70
-
);
71
-
}, 150);
72
-
73
-
async function handleEvents() {
74
-
for await (const e of watcher) {
75
-
if (e.kind === "any" || e.kind === "access" || e.kind === "other") {
76
-
continue;
77
-
}
78
-
79
-
if (e.paths.some((s) => runtimeGlob.test(s))) {
80
-
rebuild();
81
-
}
82
-
83
-
if (e.paths.some((s) => coreGlob.test(s))) {
84
-
restart();
85
-
}
86
-
}
87
-
}
88
-
89
-
handleEvents();
90
-
91
-
Deno.addSignalListener("SIGINT", async () => {
92
-
await Promise.all([
93
-
watcher.close(),
94
-
child.kill(),
95
-
ctx.dispose(),
96
-
]);
97
-
});
98
-
}
99
-
100
-
if (import.meta.main) await dev();