@berlysia/vertical-writing-slide-system 0.0.14 → 0.0.16
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 +1 -1
- package/package.json +1 -1
- package/src/screen.css +5 -5
- package/src/vite-plugin-slides.ts +50 -34
package/cli.js
CHANGED
|
@@ -47,7 +47,7 @@ async function runDev() {
|
|
|
47
47
|
const projectPath = process.cwd();
|
|
48
48
|
|
|
49
49
|
const server = await createServer({
|
|
50
|
-
root:
|
|
50
|
+
root: projectPath, // Use project as root for proper file watching
|
|
51
51
|
configFile: resolve(libPath, "vite.config.ts"),
|
|
52
52
|
server: {
|
|
53
53
|
fs: {
|
package/package.json
CHANGED
package/src/screen.css
CHANGED
|
@@ -12,8 +12,8 @@ body,
|
|
|
12
12
|
container-name: slide-container;
|
|
13
13
|
container-type: size;
|
|
14
14
|
|
|
15
|
-
width:
|
|
16
|
-
height:
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
17
|
|
|
18
18
|
position: relative;
|
|
19
19
|
|
|
@@ -82,10 +82,10 @@ body,
|
|
|
82
82
|
|
|
83
83
|
.controls {
|
|
84
84
|
position: fixed;
|
|
85
|
-
left:
|
|
86
|
-
bottom:
|
|
85
|
+
left: 16px;
|
|
86
|
+
bottom: 16px;
|
|
87
87
|
background-color: rgba(255, 255, 255, 0.9);
|
|
88
|
-
opacity: 0
|
|
88
|
+
opacity: 0;
|
|
89
89
|
padding: 1rem;
|
|
90
90
|
border-radius: 8px;
|
|
91
91
|
transition: opacity 0.2s ease-out;
|
|
@@ -55,32 +55,6 @@ function validateSlidesDir(dir: string): void {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
* Sets up file watcher for slides directory
|
|
60
|
-
*/
|
|
61
|
-
function watchSlidesDir(dir: string, server: ViteDevServer): () => void {
|
|
62
|
-
logger.info(`Watching slides directory: ${dir}`);
|
|
63
|
-
|
|
64
|
-
const watcher = fs.watch(dir, { recursive: true }, (_eventType, filename) => {
|
|
65
|
-
if (filename) {
|
|
66
|
-
server.ws.send({
|
|
67
|
-
type: "full-reload",
|
|
68
|
-
path: "*",
|
|
69
|
-
});
|
|
70
|
-
logger.info(`File changed: ${filename}`);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
watcher.on("error", (error) => {
|
|
75
|
-
logger.error(`Watch error:`, error);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
return () => {
|
|
79
|
-
watcher.close();
|
|
80
|
-
logger.info("Stopped watching slides directory");
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
58
|
const defaultOptions: Required<SlidesPluginOptions> = {
|
|
85
59
|
slidesDir: path.resolve(process.cwd(), "slides"),
|
|
86
60
|
collection: "",
|
|
@@ -430,9 +404,6 @@ export default async function slidesPlugin(
|
|
|
430
404
|
},
|
|
431
405
|
|
|
432
406
|
configureServer(server: ViteDevServer) {
|
|
433
|
-
// Watch slides directory
|
|
434
|
-
const watcher = watchSlidesDir(config.slidesDir, server);
|
|
435
|
-
|
|
436
407
|
const reloadModule = () => {
|
|
437
408
|
const mod = server.moduleGraph.getModuleById("\0" + virtualFileId);
|
|
438
409
|
const pageMods = compiledSlides.map((_, i) =>
|
|
@@ -452,16 +423,61 @@ export default async function slidesPlugin(
|
|
|
452
423
|
});
|
|
453
424
|
};
|
|
454
425
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
426
|
+
// Use Vite's built-in watcher for better compatibility
|
|
427
|
+
server.watcher.on("change", (filePath: string) => {
|
|
428
|
+
// Convert to absolute path for comparison
|
|
429
|
+
const absolutePath = path.resolve(resolvedConfig.root, filePath);
|
|
430
|
+
const absoluteSlidesDir = path.resolve(
|
|
431
|
+
resolvedConfig.root,
|
|
432
|
+
config.slidesDir,
|
|
433
|
+
);
|
|
434
|
+
|
|
435
|
+
if (
|
|
436
|
+
absolutePath.includes(absoluteSlidesDir) &&
|
|
437
|
+
/\.(?:md|mdx)$/.test(absolutePath)
|
|
438
|
+
) {
|
|
439
|
+
logger.info(`Slide file changed: ${absolutePath}`);
|
|
440
|
+
reloadModule();
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
// Also watch for new files
|
|
445
|
+
server.watcher.on("add", (filePath: string) => {
|
|
446
|
+
const absolutePath = path.resolve(resolvedConfig.root, filePath);
|
|
447
|
+
const absoluteSlidesDir = path.resolve(
|
|
448
|
+
resolvedConfig.root,
|
|
449
|
+
config.slidesDir,
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
if (
|
|
453
|
+
absolutePath.includes(absoluteSlidesDir) &&
|
|
454
|
+
/\.(?:md|mdx)$/.test(absolutePath)
|
|
455
|
+
) {
|
|
456
|
+
logger.info(`Slide file added: ${absolutePath}`);
|
|
457
|
+
reloadModule();
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
// Watch for deleted files
|
|
462
|
+
server.watcher.on("unlink", (filePath: string) => {
|
|
463
|
+
const absolutePath = path.resolve(resolvedConfig.root, filePath);
|
|
464
|
+
const absoluteSlidesDir = path.resolve(
|
|
465
|
+
resolvedConfig.root,
|
|
466
|
+
config.slidesDir,
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
if (
|
|
470
|
+
absolutePath.includes(absoluteSlidesDir) &&
|
|
471
|
+
/\.(?:md|mdx)$/.test(absolutePath)
|
|
472
|
+
) {
|
|
473
|
+
logger.info(`Slide file deleted: ${absolutePath}`);
|
|
458
474
|
reloadModule();
|
|
459
475
|
}
|
|
460
476
|
});
|
|
461
477
|
|
|
462
|
-
// Cleanup
|
|
478
|
+
// Cleanup function (no additional watchers to clean up now)
|
|
463
479
|
return () => {
|
|
464
|
-
watcher
|
|
480
|
+
// No additional cleanup needed since we're using Vite's built-in watcher
|
|
465
481
|
};
|
|
466
482
|
},
|
|
467
483
|
};
|