executable-stories-react 0.18.0 → 0.19.0
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.cjs +58 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +58 -20
- package/dist/index.js.map +1 -1
- package/dist/interactive.cjs +54 -20
- package/dist/interactive.cjs.map +1 -1
- package/dist/interactive.js +54 -20
- package/dist/interactive.js.map +1 -1
- package/dist/parse.cjs +4 -0
- package/dist/parse.cjs.map +1 -1
- package/dist/parse.js +4 -0
- package/dist/parse.js.map +1 -1
- package/dist/report-island.global.js +61 -58
- package/dist/ssr.cjs +54 -20
- package/dist/ssr.cjs.map +1 -1
- package/dist/ssr.js +54 -20
- package/dist/ssr.js.map +1 -1
- package/dist/tailwind.css +1 -1
- package/package.json +20 -20
package/dist/index.d.cts
CHANGED
|
@@ -100,9 +100,9 @@ declare function ReportSummaryView({ summary, className, ariaLabel }: ReportSumm
|
|
|
100
100
|
declare function ReportMeta(): react.JSX.Element | null;
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
-
* Renders scenario attachments.
|
|
104
|
-
*
|
|
105
|
-
*
|
|
103
|
+
* Renders scenario attachments. Images embed inline; text documents preview
|
|
104
|
+
* above their download link; other types get a labelled download link. An
|
|
105
|
+
* `external` attachment links to its file path and shows no preview.
|
|
106
106
|
*/
|
|
107
107
|
declare function ReportAttachments({ attachments }: {
|
|
108
108
|
attachments: ReportAttachment[];
|
package/dist/index.d.ts
CHANGED
|
@@ -100,9 +100,9 @@ declare function ReportSummaryView({ summary, className, ariaLabel }: ReportSumm
|
|
|
100
100
|
declare function ReportMeta(): react.JSX.Element | null;
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
-
* Renders scenario attachments.
|
|
104
|
-
*
|
|
105
|
-
*
|
|
103
|
+
* Renders scenario attachments. Images embed inline; text documents preview
|
|
104
|
+
* above their download link; other types get a labelled download link. An
|
|
105
|
+
* `external` attachment links to its file path and shows no preview.
|
|
106
106
|
*/
|
|
107
107
|
declare function ReportAttachments({ attachments }: {
|
|
108
108
|
attachments: ReportAttachment[];
|
package/dist/index.js
CHANGED
|
@@ -859,42 +859,76 @@ function StateCardView({ card }) {
|
|
|
859
859
|
|
|
860
860
|
// src/components/ReportAttachments.tsx
|
|
861
861
|
import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
862
|
+
function attachmentText(att) {
|
|
863
|
+
if (att.contentEncoding !== "BASE64") return att.body;
|
|
864
|
+
try {
|
|
865
|
+
return new TextDecoder().decode(Uint8Array.from(atob(att.body), (c) => c.charCodeAt(0)));
|
|
866
|
+
} catch {
|
|
867
|
+
return void 0;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
function preview(att) {
|
|
871
|
+
const type = att.mediaType.split(";")[0].trim().toLowerCase();
|
|
872
|
+
const text = attachmentText(att);
|
|
873
|
+
if (text === void 0) return null;
|
|
874
|
+
if (type === "text/plain") {
|
|
875
|
+
return /* @__PURE__ */ jsx21("pre", { className: "max-h-96 overflow-auto rounded-md border border-border bg-muted/40 p-3 text-xs whitespace-pre-wrap", children: text });
|
|
876
|
+
}
|
|
877
|
+
if (type === "text/markdown") {
|
|
878
|
+
return /* @__PURE__ */ jsx21(
|
|
879
|
+
"div",
|
|
880
|
+
{
|
|
881
|
+
className: "es-doc-prose prose prose-sm max-w-none rounded-md border border-border p-3",
|
|
882
|
+
dangerouslySetInnerHTML: { __html: safeMarkdownHtml(text) }
|
|
883
|
+
}
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
if (type === "text/html") {
|
|
887
|
+
return /* @__PURE__ */ jsx21(DocHtml, { entry: { kind: "html", content: text, title: att.name, phase: "runtime" } });
|
|
888
|
+
}
|
|
889
|
+
return null;
|
|
890
|
+
}
|
|
862
891
|
function ReportAttachments({ attachments }) {
|
|
863
892
|
if (attachments.length === 0) return null;
|
|
864
893
|
return (
|
|
865
894
|
// role="group" (not a labelled <section>) so multiple scenarios' attachment
|
|
866
895
|
// blocks don't create duplicate "Attachments" region landmarks.
|
|
867
896
|
/* @__PURE__ */ jsx21("div", { role: "group", "aria-label": "Attachments", className: "mt-3 flex flex-col gap-2", children: attachments.map((att, i) => {
|
|
868
|
-
const dataUri = att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
|
|
869
|
-
const
|
|
897
|
+
const dataUri = att.external ? void 0 : att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
|
|
898
|
+
const href = dataUri ?? safeUrl(att.body);
|
|
899
|
+
const imageSrc = dataUri ?? safeImageUrl(att.body);
|
|
900
|
+
const isImage = att.mediaType.startsWith("image/") && imageSrc !== void 0;
|
|
870
901
|
return /* @__PURE__ */ jsx21("figure", { className: "m-0", children: isImage ? /* @__PURE__ */ jsxs13(Fragment6, { children: [
|
|
871
902
|
/* @__PURE__ */ jsx21(
|
|
872
903
|
"img",
|
|
873
904
|
{
|
|
874
|
-
src:
|
|
905
|
+
src: imageSrc,
|
|
875
906
|
alt: att.name,
|
|
876
907
|
loading: "lazy",
|
|
877
908
|
className: "max-w-full rounded-md border border-border"
|
|
878
909
|
}
|
|
879
910
|
),
|
|
880
911
|
/* @__PURE__ */ jsx21("figcaption", { className: "mt-1 text-xs text-muted-foreground", children: att.name })
|
|
881
|
-
] }) : /* @__PURE__ */ jsxs13(
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
"
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
912
|
+
] }) : /* @__PURE__ */ jsxs13(Fragment6, { children: [
|
|
913
|
+
att.external ? null : preview(att),
|
|
914
|
+
/* @__PURE__ */ jsxs13(
|
|
915
|
+
"a",
|
|
916
|
+
{
|
|
917
|
+
href,
|
|
918
|
+
download: att.name,
|
|
919
|
+
className: "text-xs text-link underline underline-offset-2",
|
|
920
|
+
children: [
|
|
921
|
+
att.name,
|
|
922
|
+
" ",
|
|
923
|
+
/* @__PURE__ */ jsxs13("span", { className: "text-muted-foreground", children: [
|
|
924
|
+
"(",
|
|
925
|
+
att.mediaType,
|
|
926
|
+
")"
|
|
927
|
+
] })
|
|
928
|
+
]
|
|
929
|
+
}
|
|
930
|
+
)
|
|
931
|
+
] }) }, `${att.name}-${i}`);
|
|
898
932
|
}) })
|
|
899
933
|
);
|
|
900
934
|
}
|
|
@@ -2528,6 +2562,10 @@ var story_report_v1_default = {
|
|
|
2528
2562
|
contentEncoding: {
|
|
2529
2563
|
type: "string",
|
|
2530
2564
|
enum: ["BASE64", "IDENTITY"]
|
|
2565
|
+
},
|
|
2566
|
+
external: {
|
|
2567
|
+
const: true,
|
|
2568
|
+
description: "body holds the file's path or URL (file missing or too large to embed)."
|
|
2531
2569
|
}
|
|
2532
2570
|
},
|
|
2533
2571
|
required: ["name", "mediaType", "body", "contentEncoding"],
|