promptslide 0.3.17 → 0.3.18

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.
@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url"
5
5
  import tailwindcss from "@tailwindcss/postcss"
6
6
  import react from "@vitejs/plugin-react"
7
7
 
8
+ import { editorPlugin } from "../editor/plugin.mjs"
8
9
  import { promptslidePlugin } from "./plugin.mjs"
9
10
 
10
11
  const __dirname = dirname(fileURLToPath(import.meta.url))
@@ -17,13 +18,20 @@ const tailwindPath = resolve(dirname(require.resolve("tailwindcss")), "..")
17
18
  // Resolve promptslide core from source so Vite uses TS directly without a build step
18
19
  const promptslidePath = resolve(__dirname, "../core/index.ts")
19
20
 
20
- export function createViteConfig({ cwd, mode = "development" }) {
21
+ export function createViteConfig({ cwd, mode = "development", editor = true }) {
21
22
  return {
22
23
  configFile: false,
23
24
  root: cwd,
24
25
  mode,
25
- plugins: [react(), promptslidePlugin({ root: cwd })],
26
+ plugins: [
27
+ ...(mode === "development" && editor ? [editorPlugin({ root: cwd })] : []),
28
+ react(),
29
+ promptslidePlugin({ root: cwd })
30
+ ],
26
31
  resolve: {
32
+ // The CLI's core/editor and the deck must share one React dispatcher,
33
+ // including when the CLI is installed or linked outside the deck root.
34
+ dedupe: ["react", "react-dom"],
27
35
  alias: {
28
36
  "@": resolve(cwd, "src"),
29
37
  promptslide: promptslidePath,
@@ -31,6 +39,19 @@ export function createViteConfig({ cwd, mode = "development" }) {
31
39
  tailwindcss: tailwindPath
32
40
  }
33
41
  },
42
+ // These imports live in virtual entry modules, which dependency scanning
43
+ // cannot discover before the first page loads. Optimize them together so
44
+ // the viewer and editor never start with different dependency generations.
45
+ optimizeDeps: {
46
+ include: [
47
+ "react",
48
+ "react-dom/client",
49
+ "lucide-react",
50
+ "framer-motion",
51
+ "clsx",
52
+ "tailwind-merge"
53
+ ]
54
+ },
34
55
  css: {
35
56
  postcss: {
36
57
  plugins: [tailwindcss()]
@@ -384,7 +384,7 @@ export function promptslidePlugin({ root: initialRoot } = {}) {
384
384
  server.middlewares.use(async (req, res, next) => {
385
385
  const url = new URL(req.url, "http://localhost")
386
386
  if (url.searchParams.get("pdf") === "true") {
387
- const html = await server.transformIndexHtml("/index.html", getPdfHtmlTemplate())
387
+ const html = await server.transformIndexHtml("/index.html", getPdfHtmlTemplate(), req.url)
388
388
  res.setHeader("Content-Type", "text/html")
389
389
  res.statusCode = 200
390
390
  res.end(html)
@@ -402,7 +402,8 @@ export function promptslidePlugin({ root: initialRoot } = {}) {
402
402
  }
403
403
  const html = await server.transformIndexHtml(
404
404
  "/index.html",
405
- getExportHtmlTemplate(slidePath)
405
+ getExportHtmlTemplate(slidePath),
406
+ req.url
406
407
  )
407
408
  res.setHeader("Content-Type", "text/html")
408
409
  res.statusCode = 200