@berlysia/vertical-writing-slide-system 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +14 -46
- package/package.json +1 -1
- package/src/index.css +6 -6
- package/src/screen.css +1 -1
- package/src/vite-plugin-slides.ts +16 -16
package/cli.js
CHANGED
|
@@ -1,61 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// @ts-check
|
|
3
3
|
|
|
4
|
-
import { writeFile, access } from "node:fs/promises";
|
|
5
4
|
import { resolve } from "node:path";
|
|
6
5
|
import { parseArgs } from "node:util";
|
|
7
6
|
import { build, createServer } from "vite";
|
|
8
7
|
|
|
9
|
-
async function ensureIndexHtml() {
|
|
10
|
-
const indexHtmlPath = resolve(process.cwd(), "index.html");
|
|
11
|
-
try {
|
|
12
|
-
await access(indexHtmlPath);
|
|
13
|
-
// index.html already exists
|
|
14
|
-
return;
|
|
15
|
-
} catch {
|
|
16
|
-
// index.html doesn't exist, create it
|
|
17
|
-
// Use absolute paths from the library location for external projects
|
|
18
|
-
const libPath = import.meta.dirname;
|
|
19
|
-
const libSrcPath = resolve(libPath, "src");
|
|
20
|
-
|
|
21
|
-
// Convert to relative paths from project root that Vite can resolve
|
|
22
|
-
const relativeSrcPath = `/@fs${libSrcPath}`;
|
|
23
|
-
|
|
24
|
-
const indexHtmlContent = `<!doctype html>
|
|
25
|
-
<html lang="ja">
|
|
26
|
-
<head>
|
|
27
|
-
<meta charset="UTF-8" />
|
|
28
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
29
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
30
|
-
<title>Vertical Writing Slides</title>
|
|
31
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
32
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
33
|
-
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
|
34
|
-
<link rel="stylesheet" href="${relativeSrcPath}/index.css" />
|
|
35
|
-
<link rel="stylesheet" media="screen" href="${relativeSrcPath}/screen.css" />
|
|
36
|
-
<link rel="stylesheet" media="print" href="${relativeSrcPath}/print.css" />
|
|
37
|
-
</head>
|
|
38
|
-
<body>
|
|
39
|
-
<div id="root"></div>
|
|
40
|
-
<script type="module" src="${relativeSrcPath}/main.tsx"></script>
|
|
41
|
-
</body>
|
|
42
|
-
</html>`;
|
|
43
|
-
|
|
44
|
-
await writeFile(indexHtmlPath, indexHtmlContent);
|
|
45
|
-
console.log("Generated index.html for external project");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
8
|
async function runDev() {
|
|
50
9
|
try {
|
|
51
10
|
const libPath = import.meta.dirname;
|
|
52
11
|
const projectPath = process.cwd();
|
|
53
12
|
|
|
54
|
-
//
|
|
55
|
-
|
|
13
|
+
// Set environment variables for external project
|
|
14
|
+
if (!process.env.SLIDES_DIR) {
|
|
15
|
+
process.env.SLIDES_DIR = resolve(projectPath, "./slides");
|
|
16
|
+
}
|
|
56
17
|
|
|
57
18
|
const server = await createServer({
|
|
58
|
-
root:
|
|
19
|
+
root: libPath, // Use library as root to serve its index.html
|
|
59
20
|
configFile: resolve(libPath, "vite.config.ts"),
|
|
60
21
|
server: {
|
|
61
22
|
fs: {
|
|
@@ -98,13 +59,20 @@ async function runBuildAll() {
|
|
|
98
59
|
|
|
99
60
|
async function runBuild() {
|
|
100
61
|
try {
|
|
62
|
+
const projectPath = process.cwd();
|
|
63
|
+
|
|
64
|
+
// Set environment variables for external project
|
|
65
|
+
if (!process.env.SLIDES_DIR) {
|
|
66
|
+
process.env.SLIDES_DIR = resolve(projectPath, "./slides");
|
|
67
|
+
}
|
|
68
|
+
|
|
101
69
|
await build({
|
|
102
|
-
root:
|
|
70
|
+
root: import.meta.dirname, // Use library as root like dev mode
|
|
103
71
|
configFile: resolve(import.meta.dirname, "vite.config.ts"),
|
|
104
72
|
build: {
|
|
105
73
|
outDir: resolve(process.cwd(), "pages"),
|
|
106
74
|
rollupOptions: {
|
|
107
|
-
input: resolve(import.meta.dirname, "
|
|
75
|
+
input: resolve(import.meta.dirname, "index.html"),
|
|
108
76
|
output: {
|
|
109
77
|
assetFileNames: "assets/[name]-[hash][extname]",
|
|
110
78
|
},
|
package/package.json
CHANGED
package/src/index.css
CHANGED
|
@@ -40,7 +40,7 @@ code {
|
|
|
40
40
|
.wrapper {
|
|
41
41
|
width: 100%;
|
|
42
42
|
height: 100%;
|
|
43
|
-
padding:
|
|
43
|
+
padding: 0.833%;
|
|
44
44
|
|
|
45
45
|
position: relative;
|
|
46
46
|
|
|
@@ -60,20 +60,20 @@ code {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
h1 {
|
|
63
|
-
font-size: 1.
|
|
63
|
+
font-size: 1.4em;
|
|
64
64
|
font-weight: bold;
|
|
65
65
|
margin: 0;
|
|
66
|
-
margin-block-end: 0.
|
|
66
|
+
margin-block-end: 0.2em;
|
|
67
67
|
}
|
|
68
68
|
ul,
|
|
69
69
|
ol {
|
|
70
70
|
list-style-position: outside;
|
|
71
71
|
margin: 0;
|
|
72
|
-
margin-block-end:
|
|
72
|
+
margin-block-end: 1em;
|
|
73
73
|
}
|
|
74
74
|
ul ul,
|
|
75
75
|
ol ol {
|
|
76
|
-
margin-block-end:
|
|
76
|
+
margin-block-end: 1em;
|
|
77
77
|
}
|
|
78
78
|
ul ul ul,
|
|
79
79
|
ol ol ol {
|
|
@@ -81,7 +81,7 @@ code {
|
|
|
81
81
|
}
|
|
82
82
|
p {
|
|
83
83
|
margin: 0;
|
|
84
|
-
margin-block-end: 0.
|
|
84
|
+
margin-block-end: 0.5em;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
.wm-toggle {
|
package/src/screen.css
CHANGED
|
@@ -534,14 +534,18 @@ export default async function slidesPlugin(
|
|
|
534
534
|
});
|
|
535
535
|
};
|
|
536
536
|
|
|
537
|
+
// Explicitly add external slides directory to watcher
|
|
538
|
+
const absoluteSlidesDir = path.resolve(config.slidesDir);
|
|
539
|
+
if (fs.existsSync(absoluteSlidesDir)) {
|
|
540
|
+
server.watcher.add(absoluteSlidesDir);
|
|
541
|
+
logger.info(`Added slides directory to watcher: ${absoluteSlidesDir}`);
|
|
542
|
+
}
|
|
543
|
+
|
|
537
544
|
// Use Vite's built-in watcher for better compatibility
|
|
538
545
|
server.watcher.on("change", (filePath: string) => {
|
|
539
|
-
//
|
|
540
|
-
const absolutePath = path.resolve(
|
|
541
|
-
const absoluteSlidesDir = path.resolve(
|
|
542
|
-
resolvedConfig.root,
|
|
543
|
-
config.slidesDir,
|
|
544
|
-
);
|
|
546
|
+
// filePath is already absolute when coming from watcher
|
|
547
|
+
const absolutePath = path.resolve(filePath);
|
|
548
|
+
const absoluteSlidesDir = path.resolve(config.slidesDir);
|
|
545
549
|
|
|
546
550
|
if (
|
|
547
551
|
absolutePath.includes(absoluteSlidesDir) &&
|
|
@@ -554,11 +558,9 @@ export default async function slidesPlugin(
|
|
|
554
558
|
|
|
555
559
|
// Also watch for new files
|
|
556
560
|
server.watcher.on("add", (filePath: string) => {
|
|
557
|
-
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
config.slidesDir,
|
|
561
|
-
);
|
|
561
|
+
// filePath is already absolute when coming from watcher
|
|
562
|
+
const absolutePath = path.resolve(filePath);
|
|
563
|
+
const absoluteSlidesDir = path.resolve(config.slidesDir);
|
|
562
564
|
|
|
563
565
|
if (
|
|
564
566
|
absolutePath.includes(absoluteSlidesDir) &&
|
|
@@ -571,11 +573,9 @@ export default async function slidesPlugin(
|
|
|
571
573
|
|
|
572
574
|
// Watch for deleted files
|
|
573
575
|
server.watcher.on("unlink", (filePath: string) => {
|
|
574
|
-
|
|
575
|
-
const
|
|
576
|
-
|
|
577
|
-
config.slidesDir,
|
|
578
|
-
);
|
|
576
|
+
// filePath is already absolute when coming from watcher
|
|
577
|
+
const absolutePath = path.resolve(filePath);
|
|
578
|
+
const absoluteSlidesDir = path.resolve(config.slidesDir);
|
|
579
579
|
|
|
580
580
|
if (
|
|
581
581
|
absolutePath.includes(absoluteSlidesDir) &&
|