promptslide 0.3.2 → 0.3.3
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/vite/plugin.mjs +35 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.3](https://github.com/prompticeu/promptslide/compare/promptslide-v0.3.2...promptslide-v0.3.3) (2026-03-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* forward browser ESM import errors to terminal logs ([#61](https://github.com/prompticeu/promptslide/issues/61)) ([4925013](https://github.com/prompticeu/promptslide/commit/49250131469061b4ca102644e8a7cbf6f63ac2c9))
|
|
9
|
+
|
|
3
10
|
## [0.3.2](https://github.com/prompticeu/promptslide/compare/promptslide-v0.3.1...promptslide-v0.3.2) (2026-03-07)
|
|
4
11
|
|
|
5
12
|
|
package/package.json
CHANGED
package/src/vite/plugin.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bold, dim } from "../utils/ansi.mjs"
|
|
2
|
+
|
|
1
3
|
const VIRTUAL_ENTRY_ID = "virtual:promptslide-entry"
|
|
2
4
|
const RESOLVED_VIRTUAL_ENTRY_ID = "\0" + VIRTUAL_ENTRY_ID
|
|
3
5
|
const VIRTUAL_EXPORT_ID = "virtual:promptslide-export"
|
|
@@ -5,6 +7,21 @@ const RESOLVED_VIRTUAL_EXPORT_ID = "\0" + VIRTUAL_EXPORT_ID
|
|
|
5
7
|
const VIRTUAL_EMBED_ID = "virtual:promptslide-embed"
|
|
6
8
|
const RESOLVED_VIRTUAL_EMBED_ID = "\0" + VIRTUAL_EMBED_ID
|
|
7
9
|
|
|
10
|
+
// Inline script that catches module load errors (e.g. missing named exports)
|
|
11
|
+
// and forwards them to the Vite dev server so they appear in terminal logs.
|
|
12
|
+
// Must be a regular script (not type="module") to run before module evaluation.
|
|
13
|
+
const ERROR_FORWARD_SCRIPT = `<script>
|
|
14
|
+
window.addEventListener("error", function(e) {
|
|
15
|
+
if (e.message) {
|
|
16
|
+
fetch("/__promptslide_error", {
|
|
17
|
+
method: "POST",
|
|
18
|
+
headers: { "Content-Type": "application/json" },
|
|
19
|
+
body: JSON.stringify({ message: e.message, filename: e.filename || "" })
|
|
20
|
+
}).catch(function() {});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
</script>`
|
|
24
|
+
|
|
8
25
|
function getHtmlTemplate() {
|
|
9
26
|
return `<!doctype html>
|
|
10
27
|
<html lang="en">
|
|
@@ -15,6 +32,7 @@ function getHtmlTemplate() {
|
|
|
15
32
|
</head>
|
|
16
33
|
<body>
|
|
17
34
|
<div id="root"></div>
|
|
35
|
+
${ERROR_FORWARD_SCRIPT}
|
|
18
36
|
<script type="module" src="/@id/${VIRTUAL_ENTRY_ID}"></script>
|
|
19
37
|
</body>
|
|
20
38
|
</html>`
|
|
@@ -155,6 +173,23 @@ export function promptslidePlugin({ root: initialRoot } = {}) {
|
|
|
155
173
|
},
|
|
156
174
|
|
|
157
175
|
configureServer(server) {
|
|
176
|
+
// Pre-middleware: receive browser errors and log them to the terminal
|
|
177
|
+
server.middlewares.use((req, res, next) => {
|
|
178
|
+
if (req.method !== "POST" || req.url !== "/__promptslide_error") return next()
|
|
179
|
+
|
|
180
|
+
let body = ""
|
|
181
|
+
req.on("data", chunk => { body += chunk })
|
|
182
|
+
req.on("end", () => {
|
|
183
|
+
try {
|
|
184
|
+
const { message, filename } = JSON.parse(body)
|
|
185
|
+
const location = filename ? ` ${dim(`(${filename})`)}` : ""
|
|
186
|
+
server.config.logger.error(`${bold("Browser error:")} ${message}${location}`, { timestamp: true })
|
|
187
|
+
} catch {}
|
|
188
|
+
res.statusCode = 204
|
|
189
|
+
res.end()
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
|
|
158
193
|
// Pre-middleware: serve /embed route
|
|
159
194
|
server.middlewares.use(async (req, res, next) => {
|
|
160
195
|
const url = new URL(req.url, "http://localhost")
|