footprint-explainable-ui 0.16.0 → 0.17.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 +114 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -1
- package/dist/index.d.ts +92 -1
- package/dist/index.js +103 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -39,6 +49,7 @@ __export(src_exports, {
|
|
|
39
49
|
StoryNarrative: () => StoryNarrative,
|
|
40
50
|
SubflowTree: () => SubflowTree,
|
|
41
51
|
TimeTravelControls: () => TimeTravelControls,
|
|
52
|
+
TraceViewer: () => TraceViewer,
|
|
42
53
|
buildEntryRangeIndex: () => buildEntryRangeIndex,
|
|
43
54
|
computeRevealedEntryCount: () => computeRevealedEntryCount,
|
|
44
55
|
coolDark: () => coolDark,
|
|
@@ -5367,6 +5378,108 @@ function ExplainableShell({
|
|
|
5367
5378
|
}
|
|
5368
5379
|
);
|
|
5369
5380
|
}
|
|
5381
|
+
|
|
5382
|
+
// src/components/TraceViewer/TraceViewer.tsx
|
|
5383
|
+
var React = __toESM(require("react"), 1);
|
|
5384
|
+
var import_react25 = require("react");
|
|
5385
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
5386
|
+
function parseTrace(input) {
|
|
5387
|
+
if (input == null) {
|
|
5388
|
+
return {
|
|
5389
|
+
ok: false,
|
|
5390
|
+
error: { kind: "invalid-json", message: "No trace provided." }
|
|
5391
|
+
};
|
|
5392
|
+
}
|
|
5393
|
+
let candidate = input;
|
|
5394
|
+
if (typeof input === "string") {
|
|
5395
|
+
if (!input.trim()) {
|
|
5396
|
+
return { ok: false, error: { kind: "invalid-json", message: "Empty input." } };
|
|
5397
|
+
}
|
|
5398
|
+
try {
|
|
5399
|
+
candidate = JSON.parse(input);
|
|
5400
|
+
} catch (err) {
|
|
5401
|
+
return {
|
|
5402
|
+
ok: false,
|
|
5403
|
+
error: { kind: "invalid-json", message: err.message }
|
|
5404
|
+
};
|
|
5405
|
+
}
|
|
5406
|
+
}
|
|
5407
|
+
if (!candidate || typeof candidate !== "object") {
|
|
5408
|
+
return {
|
|
5409
|
+
ok: false,
|
|
5410
|
+
error: { kind: "not-object", message: "Trace must be a JSON object." }
|
|
5411
|
+
};
|
|
5412
|
+
}
|
|
5413
|
+
const t = candidate;
|
|
5414
|
+
if (typeof t.schemaVersion !== "number") {
|
|
5415
|
+
return {
|
|
5416
|
+
ok: false,
|
|
5417
|
+
error: {
|
|
5418
|
+
kind: "missing-version",
|
|
5419
|
+
message: "Trace is missing required field `schemaVersion`. Did you pass an exportTrace() output?"
|
|
5420
|
+
}
|
|
5421
|
+
};
|
|
5422
|
+
}
|
|
5423
|
+
if (t.schemaVersion !== 1) {
|
|
5424
|
+
return {
|
|
5425
|
+
ok: false,
|
|
5426
|
+
error: {
|
|
5427
|
+
kind: "unsupported-version",
|
|
5428
|
+
message: `Unsupported schemaVersion ${t.schemaVersion}. This TraceViewer renders schemaVersion 1.`,
|
|
5429
|
+
version: t.schemaVersion
|
|
5430
|
+
}
|
|
5431
|
+
};
|
|
5432
|
+
}
|
|
5433
|
+
return { ok: true, trace: t };
|
|
5434
|
+
}
|
|
5435
|
+
var DEFAULT_TABS = ["explainable"];
|
|
5436
|
+
function TraceViewer({
|
|
5437
|
+
trace,
|
|
5438
|
+
onError,
|
|
5439
|
+
fallback,
|
|
5440
|
+
tabs = DEFAULT_TABS,
|
|
5441
|
+
defaultTab = "narrative",
|
|
5442
|
+
hideTabs,
|
|
5443
|
+
size,
|
|
5444
|
+
panelLabels,
|
|
5445
|
+
recorderViews,
|
|
5446
|
+
renderFlowchart
|
|
5447
|
+
}) {
|
|
5448
|
+
const parsed = (0, import_react25.useMemo)(() => parseTrace(trace), [trace]);
|
|
5449
|
+
React.useEffect(() => {
|
|
5450
|
+
if (!parsed.ok && onError) onError(parsed.error);
|
|
5451
|
+
}, [parsed, onError]);
|
|
5452
|
+
const snapshots = (0, import_react25.useMemo)(() => {
|
|
5453
|
+
if (!parsed.ok || !parsed.trace.snapshot) return [];
|
|
5454
|
+
try {
|
|
5455
|
+
return toVisualizationSnapshots(
|
|
5456
|
+
parsed.trace.snapshot,
|
|
5457
|
+
parsed.trace.narrativeEntries ?? void 0
|
|
5458
|
+
);
|
|
5459
|
+
} catch {
|
|
5460
|
+
return [];
|
|
5461
|
+
}
|
|
5462
|
+
}, [parsed]);
|
|
5463
|
+
if (!parsed.ok || snapshots.length === 0) {
|
|
5464
|
+
return fallback ?? null;
|
|
5465
|
+
}
|
|
5466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
5467
|
+
ExplainableShell,
|
|
5468
|
+
{
|
|
5469
|
+
snapshots,
|
|
5470
|
+
spec: parsed.trace.spec,
|
|
5471
|
+
narrative: parsed.trace.narrative,
|
|
5472
|
+
narrativeEntries: parsed.trace.narrativeEntries,
|
|
5473
|
+
tabs,
|
|
5474
|
+
defaultTab,
|
|
5475
|
+
hideTabs,
|
|
5476
|
+
size,
|
|
5477
|
+
panelLabels,
|
|
5478
|
+
recorderViews,
|
|
5479
|
+
renderFlowchart
|
|
5480
|
+
}
|
|
5481
|
+
);
|
|
5482
|
+
}
|
|
5370
5483
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5371
5484
|
0 && (module.exports = {
|
|
5372
5485
|
CompactTimeline,
|
|
@@ -5388,6 +5501,7 @@ function ExplainableShell({
|
|
|
5388
5501
|
StoryNarrative,
|
|
5389
5502
|
SubflowTree,
|
|
5390
5503
|
TimeTravelControls,
|
|
5504
|
+
TraceViewer,
|
|
5391
5505
|
buildEntryRangeIndex,
|
|
5392
5506
|
computeRevealedEntryCount,
|
|
5393
5507
|
coolDark,
|