@berlysia/vertical-writing-slide-system 0.0.11 → 0.0.13

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 CHANGED
@@ -34,6 +34,14 @@ async function runBuild() {
34
34
  configFile: resolve(import.meta.dirname, "vite.config.ts"),
35
35
  build: {
36
36
  outDir: resolve(process.cwd(), "pages"),
37
+ rollupOptions: {
38
+ input: resolve(import.meta.dirname, "src/main.tsx"),
39
+ output: {
40
+ assetFileNames: "assets/[name]-[hash][extname]",
41
+ },
42
+ },
43
+ cssCodeSplit: true,
44
+ assetsInlineLimit: 0,
37
45
  },
38
46
  });
39
47
  } catch (error) {
package/index.html CHANGED
@@ -5,12 +5,12 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Vite + React + TS</title>
8
- <link rel="preconnect" href="https://fonts.googleapis.com">
9
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
- <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
11
- <link rel="stylesheet" href="/src/index.css" />
12
- <link rel="stylesheet" media="screen" href="/src/screen.css" />
13
- <link rel="stylesheet" media="print" href="/src/print.css" />
8
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
9
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
10
+ <link
11
+ href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Noto+Sans+Mono:wght@100..900&display=swap"
12
+ rel="stylesheet"
13
+ />
14
14
  </head>
15
15
  <body>
16
16
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@berlysia/vertical-writing-slide-system",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "vertical-slides": "./cli.js"
package/src/index.css CHANGED
@@ -1,3 +1,6 @@
1
+ @import "screen.css" screen;
2
+ @import "print.css" print;
3
+
1
4
  * {
2
5
  box-sizing: border-box;
3
6
  }
package/src/main.tsx CHANGED
@@ -1,6 +1,7 @@
1
1
  import { StrictMode } from "react";
2
2
  import { createRoot } from "react-dom/client";
3
3
  import App from "./App.tsx";
4
+ import "./index.css";
4
5
 
5
6
  createRoot(document.getElementById("root")!).render(
6
7
  <StrictMode>
@@ -171,7 +171,7 @@ export default async function slidesPlugin(
171
171
  nullPrefixedVirtualFilePageIdPattern.test(id)
172
172
  ) {
173
173
  return {
174
- code: `import React from 'react';\n${code}`,
174
+ code: `import * as React from 'react';\n${code}`,
175
175
  map: null,
176
176
  };
177
177
  }
@@ -222,6 +222,8 @@ export default async function slidesPlugin(
222
222
  const result = await compile(slideContent, {
223
223
  outputFormat: "program",
224
224
  development: false,
225
+ jsxImportSource: "react",
226
+ jsxRuntime: "automatic",
225
227
  remarkPlugins: [[remarkSlideImages, { base }]],
226
228
  });
227
229
  return result.value as string;
@@ -284,45 +286,6 @@ export default async function slidesPlugin(
284
286
  }
285
287
  },
286
288
  async buildStart() {
287
- // Ensure index.html exists in consumer project
288
- const consumerIndexHtml = path.resolve(resolvedConfig.root, "index.html");
289
-
290
- if (!fs.existsSync(consumerIndexHtml)) {
291
- try {
292
- // Create a consumer-specific index.html that points to library sources
293
- const libraryRoot = path.resolve(import.meta.dirname, "..");
294
- const relativePath = path.relative(resolvedConfig.root, libraryRoot);
295
-
296
- const indexHtmlContent = `<!doctype html>
297
- <html lang="ja">
298
- <head>
299
- <meta charset="UTF-8" />
300
- <link rel="icon" type="image/svg+xml" href="/${relativePath}/vite.svg" />
301
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
302
- <title>Vertical Writing Slides</title>
303
- <link rel="preconnect" href="https://fonts.googleapis.com">
304
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
305
- <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
306
- <link rel="stylesheet" href="/${relativePath}/src/index.css" />
307
- <link rel="stylesheet" media="screen" href="/${relativePath}/src/screen.css" />
308
- <link rel="stylesheet" media="print" href="/${relativePath}/src/print.css" />
309
- </head>
310
- <body>
311
- <div id="root"></div>
312
- <script type="module" src="/${relativePath}/src/main.tsx"></script>
313
- </body>
314
- </html>`;
315
-
316
- fs.writeFileSync(consumerIndexHtml, indexHtmlContent);
317
- logger.info("Generated index.html for consumer project");
318
- } catch (error) {
319
- if (error instanceof Error) {
320
- logger.error("Failed to create index.html", error);
321
- }
322
- throw error;
323
- }
324
- }
325
-
326
289
  // Handle images during dev mode
327
290
  if (resolvedConfig.command === "serve") {
328
291
  const targetImagesDir = path.resolve(
@@ -359,7 +322,59 @@ export default async function slidesPlugin(
359
322
  }
360
323
  },
361
324
 
362
- generateBundle() {
325
+ generateBundle(_options, bundle) {
326
+ // Generate HTML file if none exists in consumer project
327
+ const consumerIndexHtml = path.resolve(resolvedConfig.root, "index.html");
328
+
329
+ if (!fs.existsSync(consumerIndexHtml)) {
330
+ // Find the main JS and CSS files in the bundle
331
+ const mainJsFile = Object.keys(bundle).find(
332
+ (fileName) =>
333
+ fileName.startsWith("assets/") &&
334
+ fileName.includes("main-") &&
335
+ fileName.endsWith(".js"),
336
+ );
337
+ const mainCssFile = Object.keys(bundle).find(
338
+ (fileName) =>
339
+ fileName.startsWith("assets/") && fileName.endsWith(".css"),
340
+ );
341
+
342
+ if (!mainJsFile) {
343
+ logger.error("Could not find main JS file in bundle");
344
+ return;
345
+ }
346
+
347
+ const cssLink = mainCssFile
348
+ ? `<link rel="stylesheet" href="./${mainCssFile}">`
349
+ : "<!-- CSS is included in the JS bundle -->";
350
+
351
+ const virtualIndexHtml = `<!doctype html>
352
+ <html lang="ja">
353
+ <head>
354
+ <meta charset="UTF-8" />
355
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
356
+ <title>Vertical Writing Slides</title>
357
+ <link rel="preconnect" href="https://fonts.googleapis.com">
358
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
359
+ <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
360
+ ${cssLink}
361
+ </head>
362
+ <body>
363
+ <div id="root"></div>
364
+ <script type="module" src="./${mainJsFile}"></script>
365
+ </body>
366
+ </html>`;
367
+
368
+ // Emit HTML file as part of the build output
369
+ this.emitFile({
370
+ type: "asset",
371
+ fileName: "index.html",
372
+ source: virtualIndexHtml,
373
+ });
374
+
375
+ logger.info("Generated index.html for build output");
376
+ }
377
+
363
378
  // Handle images during build mode
364
379
  if (resolvedConfig.command === "build") {
365
380
  const sourceImagesDir = path.resolve(