executable-stories-react 0.2.0 → 0.2.1

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/dist/index.d.cts CHANGED
@@ -223,6 +223,14 @@ declare function MermaidDiagram({ entry, load }: {
223
223
  load?: MermaidLoader;
224
224
  }): react.JSX.Element;
225
225
 
226
+ /**
227
+ * A screenshot that's still an absolute local filesystem path by the time it
228
+ * reaches this component means the report's asset bundler couldn't find the
229
+ * file to inline/copy it (deleted, moved, or never captured — see
230
+ * inlineScreenshotIfPossible in executable-stories-playwright). `<img src>`
231
+ * would 404 against a path from the machine that generated the report, so
232
+ * show a placeholder instead of a broken image.
233
+ */
226
234
  declare function DocScreenshot({ entry }: {
227
235
  entry: ReportDocScreenshot;
228
236
  }): react.JSX.Element;
@@ -232,6 +240,10 @@ declare function DocScreenshot({ entry }: {
232
240
  * a URL or a path that resolves alongside the report. Both `path` and `poster`
233
241
  * are adapter-supplied, so they go through the same scheme allow-list as the
234
242
  * DocHtml iframe src (no `javascript:`/`data:` URLs reach the DOM).
243
+ *
244
+ * An absolute local filesystem path means the report's asset bundler
245
+ * couldn't find/copy the file — a `<video src>` pointed at a runner-local
246
+ * path would just fail to load, so show a placeholder instead.
235
247
  */
236
248
  declare function DocVideo({ entry }: {
237
249
  entry: ReportDocVideo;
package/dist/index.d.ts CHANGED
@@ -223,6 +223,14 @@ declare function MermaidDiagram({ entry, load }: {
223
223
  load?: MermaidLoader;
224
224
  }): react.JSX.Element;
225
225
 
226
+ /**
227
+ * A screenshot that's still an absolute local filesystem path by the time it
228
+ * reaches this component means the report's asset bundler couldn't find the
229
+ * file to inline/copy it (deleted, moved, or never captured — see
230
+ * inlineScreenshotIfPossible in executable-stories-playwright). `<img src>`
231
+ * would 404 against a path from the machine that generated the report, so
232
+ * show a placeholder instead of a broken image.
233
+ */
226
234
  declare function DocScreenshot({ entry }: {
227
235
  entry: ReportDocScreenshot;
228
236
  }): react.JSX.Element;
@@ -232,6 +240,10 @@ declare function DocScreenshot({ entry }: {
232
240
  * a URL or a path that resolves alongside the report. Both `path` and `poster`
233
241
  * are adapter-supplied, so they go through the same scheme allow-list as the
234
242
  * DocHtml iframe src (no `javascript:`/`data:` URLs reach the DOM).
243
+ *
244
+ * An absolute local filesystem path means the report's asset bundler
245
+ * couldn't find/copy the file — a `<video src>` pointed at a runner-local
246
+ * path would just fail to load, so show a placeholder instead.
235
247
  */
236
248
  declare function DocVideo({ entry }: {
237
249
  entry: ReportDocVideo;
package/dist/index.js CHANGED
@@ -208,6 +208,15 @@ function safeUrl(value) {
208
208
  if (scheme && !/^https?$/i.test(scheme[1] ?? "")) return void 0;
209
209
  return trimmed;
210
210
  }
211
+ function safeImageUrl(value) {
212
+ if (!value) return void 0;
213
+ const trimmed = value.trim();
214
+ if (/^data:image\//i.test(trimmed)) return trimmed;
215
+ return safeUrl(trimmed);
216
+ }
217
+ function isLocalFsPath(value) {
218
+ return /^(?:[/\\]|[A-Za-z]:[/\\])/.test(value);
219
+ }
211
220
 
212
221
  // src/components/doc/DocSection.tsx
213
222
  import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
@@ -263,11 +272,19 @@ function DocMermaid({ entry }) {
263
272
  // src/components/doc/DocScreenshot.tsx
264
273
  import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
265
274
  function DocScreenshot({ entry }) {
275
+ const src = isLocalFsPath(entry.path) ? void 0 : safeImageUrl(entry.path);
276
+ if (!src) {
277
+ return /* @__PURE__ */ jsxs6("figure", { className: "my-3 rounded-md border border-dashed border-border p-3 text-sm text-muted-foreground", children: [
278
+ /* @__PURE__ */ jsx10("div", { className: "font-medium", children: "Screenshot unavailable" }),
279
+ /* @__PURE__ */ jsx10("div", { className: "mt-1 break-all font-mono text-xs", children: entry.path }),
280
+ entry.alt ? /* @__PURE__ */ jsx10("figcaption", { className: "mt-1.5 text-xs", children: entry.alt }) : null
281
+ ] });
282
+ }
266
283
  return /* @__PURE__ */ jsxs6("figure", { className: "my-3", children: [
267
284
  /* @__PURE__ */ jsx10(
268
285
  "img",
269
286
  {
270
- src: entry.path,
287
+ src,
271
288
  alt: entry.alt ?? "",
272
289
  loading: "lazy",
273
290
  className: "max-w-full rounded-md border border-border"
@@ -280,6 +297,13 @@ function DocScreenshot({ entry }) {
280
297
  // src/components/doc/DocVideo.tsx
281
298
  import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
282
299
  function DocVideo({ entry }) {
300
+ if (isLocalFsPath(entry.path)) {
301
+ return /* @__PURE__ */ jsxs7("figure", { className: "my-3 rounded-md border border-dashed border-border p-3 text-sm text-muted-foreground", children: [
302
+ /* @__PURE__ */ jsx11("div", { className: "font-medium", children: "Video unavailable" }),
303
+ /* @__PURE__ */ jsx11("div", { className: "mt-1 break-all font-mono text-xs", children: entry.path }),
304
+ entry.caption ? /* @__PURE__ */ jsx11("figcaption", { className: "mt-1.5 text-xs", children: entry.caption }) : null
305
+ ] });
306
+ }
283
307
  const src = safeUrl(entry.path);
284
308
  const poster = safeUrl(entry.poster);
285
309
  return /* @__PURE__ */ jsxs7("figure", { className: "my-3", children: [