@pipelex/mthds-ui 0.34.1 → 0.36.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/README.md +26 -4
- package/dist/{chunk-TMZ2JR2J.js → chunk-4KLE62AN.js} +13 -1
- package/dist/chunk-4KLE62AN.js.map +1 -0
- package/dist/{chunk-ABUDTHWF.js → chunk-AGFLCOWW.js} +47 -5
- package/dist/chunk-AGFLCOWW.js.map +1 -0
- package/dist/{chunk-K2C5FU4W.js → chunk-ENRYQOCO.js} +2 -2
- package/dist/chunk-ILZJIORT.js +54 -0
- package/dist/chunk-ILZJIORT.js.map +1 -0
- package/dist/chunk-JJG2TO7P.js +473 -0
- package/dist/chunk-JJG2TO7P.js.map +1 -0
- package/dist/form/react/index.d.ts +2 -1
- package/dist/form/react/index.js +2 -2
- package/dist/graph/index.d.ts +3 -2
- package/dist/graph/index.js +7 -3
- package/dist/graph/react/detail/DetailPanel.css +37 -11
- package/dist/graph/react/graph-core.css +39 -0
- package/dist/graph/react/index.d.ts +5 -2
- package/dist/graph/react/index.js +596 -589
- package/dist/graph/react/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -3
- package/dist/progressSnapshot-VZ4PLul9.d.ts +191 -0
- package/dist/standalone/graph-standalone.html +191 -126
- package/dist/standalone/graph-viewer.css +77 -12
- package/dist/standalone/graph-viewer.js +114 -114
- package/dist/static-graph/index.d.ts +2 -1
- package/dist/static-graph/index.js +1 -1
- package/dist/timeline/index.d.ts +339 -0
- package/dist/timeline/index.js +70 -0
- package/dist/timeline/index.js.map +1 -0
- package/dist/timeline/react/RunTimeline.css +503 -0
- package/dist/timeline/react/index.d.ts +69 -0
- package/dist/timeline/react/index.js +402 -0
- package/dist/timeline/react/index.js.map +1 -0
- package/dist/{types-MvxsDLCo.d.ts → types-DsrzH6gM.d.ts} +43 -7
- package/package.json +12 -2
- package/dist/chunk-ABUDTHWF.js.map +0 -1
- package/dist/chunk-TMZ2JR2J.js.map +0 -1
- /package/dist/{chunk-K2C5FU4W.js.map → chunk-ENRYQOCO.js.map} +0 -0
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
GRAPH_THEME,
|
|
6
6
|
GRAPH_THEME_MODE,
|
|
7
7
|
TOOLBAR_POSITION
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4KLE62AN.js";
|
|
9
9
|
import {
|
|
10
10
|
__spreadProps,
|
|
11
11
|
__spreadValues
|
|
@@ -195,4 +195,4 @@ export {
|
|
|
195
195
|
DEFAULT_GRAPH_CONFIG,
|
|
196
196
|
getPaletteColors
|
|
197
197
|
};
|
|
198
|
-
//# sourceMappingURL=chunk-
|
|
198
|
+
//# sourceMappingURL=chunk-ENRYQOCO.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GRAPH_THEME
|
|
3
|
+
} from "./chunk-4KLE62AN.js";
|
|
4
|
+
|
|
5
|
+
// src/graph/react/viewer/useSystemTheme.ts
|
|
6
|
+
import React from "react";
|
|
7
|
+
var PREFERS_DARK_QUERY = "(prefers-color-scheme: dark)";
|
|
8
|
+
function prefersDarkToTheme(prefersDark) {
|
|
9
|
+
return prefersDark ? GRAPH_THEME.DARK : GRAPH_THEME.LIGHT;
|
|
10
|
+
}
|
|
11
|
+
function detectSystemTheme() {
|
|
12
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
13
|
+
return GRAPH_THEME.DARK;
|
|
14
|
+
}
|
|
15
|
+
return prefersDarkToTheme(window.matchMedia(PREFERS_DARK_QUERY).matches);
|
|
16
|
+
}
|
|
17
|
+
function subscribeToSystemTheme(onChange) {
|
|
18
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
19
|
+
return () => {
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const mql = window.matchMedia(PREFERS_DARK_QUERY);
|
|
23
|
+
if (typeof mql.addEventListener === "function") {
|
|
24
|
+
mql.addEventListener("change", onChange);
|
|
25
|
+
return () => mql.removeEventListener("change", onChange);
|
|
26
|
+
}
|
|
27
|
+
mql.addListener(onChange);
|
|
28
|
+
return () => mql.removeListener(onChange);
|
|
29
|
+
}
|
|
30
|
+
function systemThemeStore(injected) {
|
|
31
|
+
if (injected !== void 0) {
|
|
32
|
+
return {
|
|
33
|
+
subscribe: () => () => {
|
|
34
|
+
},
|
|
35
|
+
getSnapshot: () => injected,
|
|
36
|
+
getServerSnapshot: () => injected
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
subscribe: subscribeToSystemTheme,
|
|
41
|
+
getSnapshot: detectSystemTheme,
|
|
42
|
+
getServerSnapshot: () => GRAPH_THEME.DARK
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function useSystemTheme(injected) {
|
|
46
|
+
const store = React.useMemo(() => systemThemeStore(injected), [injected]);
|
|
47
|
+
return React.useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
detectSystemTheme,
|
|
52
|
+
useSystemTheme
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=chunk-ILZJIORT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graph/react/viewer/useSystemTheme.ts"],"sourcesContent":["/**\n * Resolve the host environment's color scheme to a binary `GraphTheme`.\n *\n * In a browser this follows `prefers-color-scheme` live. Non-browser hosts (a\n * VS Code webview, where `prefers-color-scheme` is historically flaky) stay\n * authoritative by injecting `systemTheme` — the hook then returns it verbatim\n * and re-renders are driven by the host updating that value.\n *\n * Keeping the `matchMedia` logic in a hook (not inline in GraphViewer) mirrors\n * how the standalone isolated it for testing, and lets the pure\n * `detectSystemTheme` seam be unit-tested without rendering.\n */\nimport React from \"react\";\nimport { GRAPH_THEME, type GraphTheme } from \"@graph/types\";\n\nconst PREFERS_DARK_QUERY = \"(prefers-color-scheme: dark)\";\n\n/** Map a `prefers-color-scheme: dark` match result to a resolved theme. */\nexport function prefersDarkToTheme(prefersDark: boolean): GraphTheme {\n return prefersDark ? GRAPH_THEME.DARK : GRAPH_THEME.LIGHT;\n}\n\n/**\n * Read the environment's current color scheme once. SSR / no-`matchMedia` safe:\n * defaults to `dark` when `window.matchMedia` is unavailable. Exported so\n * non-React callers (e.g. the standalone adapter's initial body-palette paint,\n * before any `onThemeChange` fires) can resolve `system` the same way the hook does.\n */\nexport function detectSystemTheme(): GraphTheme {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") {\n return GRAPH_THEME.DARK;\n }\n return prefersDarkToTheme(window.matchMedia(PREFERS_DARK_QUERY).matches);\n}\n\n/**\n * Subscribe to `prefers-color-scheme` changes, invoking `onChange` on each flip.\n * Returns an unsubscribe. SSR / no-`matchMedia` safe: returns a no-op.\n *\n * Older WebKit, some Electron builds, and certain VS Code webview hosts expose\n * a `MediaQueryList` with only the legacy `addListener`/`removeListener` API.\n * Calling `addEventListener` unconditionally throws there — and because this\n * runs inside the `useSyncExternalStore` subscribe during render, the throw\n * crashes the whole GraphViewer (blank graph) on exactly the webview host\n * class the `systemTheme` prop exists to support. Prefer the modern API, fall\n * back to the legacy one (mirrors the deleted standalone `pageTheme.ts`).\n *\n * Exported as a pure seam so the modern/legacy/SSR branches can be unit-tested\n * in a node env (no renderer) — see `__tests__/useSystemTheme.test.ts`.\n */\nexport function subscribeToSystemTheme(onChange: () => void): () => void {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") {\n return () => {};\n }\n const mql = window.matchMedia(PREFERS_DARK_QUERY);\n if (typeof mql.addEventListener === \"function\") {\n mql.addEventListener(\"change\", onChange);\n return () => mql.removeEventListener(\"change\", onChange);\n }\n mql.addListener(onChange);\n return () => mql.removeListener(onChange);\n}\n\n/** The `useSyncExternalStore` triple `useSystemTheme` drives. */\nexport interface SystemThemeStore {\n subscribe: (onChange: () => void) => () => void;\n getSnapshot: () => GraphTheme;\n getServerSnapshot: () => GraphTheme;\n}\n\n/**\n * Build the `useSyncExternalStore` triple for a given `injected` value.\n *\n * - `injected` set → host owns detection: `subscribe` is a no-op (no live\n * `matchMedia` listener is ever registered) and both snapshots return\n * `injected`. Spending an OS listener + per-render `detectSystemTheme` on a\n * result we'd discard is pure waste — and wrong to keep alive on the very\n * webview hosts where `prefers-color-scheme` is unreliable.\n * - otherwise → subscribe to `prefers-color-scheme` live; the server snapshot\n * falls back to `dark` (see `docs/theming.md` → \"SSR\").\n *\n * Pure + exported so the injected-skip path is unit-testable without a renderer.\n */\nexport function systemThemeStore(injected?: GraphTheme): SystemThemeStore {\n if (injected !== undefined) {\n return {\n subscribe: () => () => {},\n getSnapshot: () => injected,\n getServerSnapshot: () => injected,\n };\n }\n return {\n subscribe: subscribeToSystemTheme,\n getSnapshot: detectSystemTheme,\n getServerSnapshot: () => GRAPH_THEME.DARK,\n };\n}\n\n/**\n * Resolved environment theme.\n *\n * - `injected` set → return it (host owns detection; host re-renders drive\n * updates). No live `matchMedia` subscription is registered.\n * - otherwise → subscribe to `prefers-color-scheme` and re-render on `change`.\n *\n * Uses `useSyncExternalStore` so the subscription is concurrent-safe. The hook\n * is always called (rules-of-hooks); only the `systemThemeStore` triple branches\n * on `injected`, memoized so the `subscribe` reference stays stable across\n * renders (no re-subscribe churn). SSR with no injected value falls back to\n * `dark` via the server snapshot — see `docs/theming.md` → \"SSR\" for the\n * consequence and the recommended `theme` / `systemTheme` pinning.\n */\nexport function useSystemTheme(injected?: GraphTheme): GraphTheme {\n const store = React.useMemo(() => systemThemeStore(injected), [injected]);\n return React.useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);\n}\n"],"mappings":";;;;;AAYA,OAAO,WAAW;AAGlB,IAAM,qBAAqB;AAGpB,SAAS,mBAAmB,aAAkC;AACnE,SAAO,cAAc,YAAY,OAAO,YAAY;AACtD;AAQO,SAAS,oBAAgC;AAC9C,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAC5E,WAAO,YAAY;AAAA,EACrB;AACA,SAAO,mBAAmB,OAAO,WAAW,kBAAkB,EAAE,OAAO;AACzE;AAiBO,SAAS,uBAAuB,UAAkC;AACvE,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAC5E,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACA,QAAM,MAAM,OAAO,WAAW,kBAAkB;AAChD,MAAI,OAAO,IAAI,qBAAqB,YAAY;AAC9C,QAAI,iBAAiB,UAAU,QAAQ;AACvC,WAAO,MAAM,IAAI,oBAAoB,UAAU,QAAQ;AAAA,EACzD;AACA,MAAI,YAAY,QAAQ;AACxB,SAAO,MAAM,IAAI,eAAe,QAAQ;AAC1C;AAsBO,SAAS,iBAAiB,UAAyC;AACxE,MAAI,aAAa,QAAW;AAC1B,WAAO;AAAA,MACL,WAAW,MAAM,MAAM;AAAA,MAAC;AAAA,MACxB,aAAa,MAAM;AAAA,MACnB,mBAAmB,MAAM;AAAA,IAC3B;AAAA,EACF;AACA,SAAO;AAAA,IACL,WAAW;AAAA,IACX,aAAa;AAAA,IACb,mBAAmB,MAAM,YAAY;AAAA,EACvC;AACF;AAgBO,SAAS,eAAe,UAAmC;AAChE,QAAM,QAAQ,MAAM,QAAQ,MAAM,iBAAiB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AACxE,SAAO,MAAM,qBAAqB,MAAM,WAAW,MAAM,aAAa,MAAM,iBAAiB;AAC/F;","names":[]}
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
// src/timeline/progressSnapshot.ts
|
|
2
|
+
var PROGRESS_MODE = {
|
|
3
|
+
LIVE: "live",
|
|
4
|
+
DRY: "dry"
|
|
5
|
+
};
|
|
6
|
+
var RUN_PROGRESS_STATUS = {
|
|
7
|
+
PENDING: "pending",
|
|
8
|
+
RUNNING: "running",
|
|
9
|
+
SUCCEEDED: "succeeded",
|
|
10
|
+
FAILED: "failed",
|
|
11
|
+
CANCELED: "canceled"
|
|
12
|
+
};
|
|
13
|
+
var INVOCATION_STATUS = {
|
|
14
|
+
SCHEDULED: "scheduled",
|
|
15
|
+
RUNNING: "running",
|
|
16
|
+
SUCCEEDED: "succeeded",
|
|
17
|
+
FAILED: "failed",
|
|
18
|
+
SKIPPED: "skipped",
|
|
19
|
+
CANCELED: "canceled"
|
|
20
|
+
};
|
|
21
|
+
var DEGRADATION_REASON = {
|
|
22
|
+
WORKFLOW_TASK_FAILING: "workflow_task_failing",
|
|
23
|
+
STATUS_UNAVAILABLE: "status_unavailable"
|
|
24
|
+
};
|
|
25
|
+
function isRunEnded(status) {
|
|
26
|
+
return status === RUN_PROGRESS_STATUS.SUCCEEDED || status === RUN_PROGRESS_STATUS.FAILED || status === RUN_PROGRESS_STATUS.CANCELED;
|
|
27
|
+
}
|
|
28
|
+
var TIMESTAMP_PATTERN = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d+))?(Z|[+-]\d{2}:\d{2})$/;
|
|
29
|
+
function parseTimestamp(timestamp) {
|
|
30
|
+
if (!timestamp) return null;
|
|
31
|
+
const match = TIMESTAMP_PATTERN.exec(timestamp);
|
|
32
|
+
if (!match) return null;
|
|
33
|
+
const [, base, fraction = "", offset] = match;
|
|
34
|
+
const millis = fraction.slice(0, 3).padEnd(3, "0");
|
|
35
|
+
const wholeMs = Date.parse(`${base}.${millis}${offset}`);
|
|
36
|
+
if (Number.isNaN(wholeMs)) return null;
|
|
37
|
+
return { wholeMs, subMsDigits: fraction.slice(3).replace(/0+$/, "") };
|
|
38
|
+
}
|
|
39
|
+
function timestampMs(timestamp) {
|
|
40
|
+
const parsed = parseTimestamp(timestamp);
|
|
41
|
+
if (!parsed) return null;
|
|
42
|
+
return parsed.subMsDigits ? parsed.wholeMs + Number(`0.${parsed.subMsDigits}`) : parsed.wholeMs;
|
|
43
|
+
}
|
|
44
|
+
function compareTimestamps(a, b) {
|
|
45
|
+
const left = parseTimestamp(a);
|
|
46
|
+
const right = parseTimestamp(b);
|
|
47
|
+
if (!left || !right) return null;
|
|
48
|
+
if (left.wholeMs !== right.wholeMs) return left.wholeMs < right.wholeMs ? -1 : 1;
|
|
49
|
+
const width = Math.max(left.subMsDigits.length, right.subMsDigits.length);
|
|
50
|
+
const leftDigits = left.subMsDigits.padEnd(width, "0");
|
|
51
|
+
const rightDigits = right.subMsDigits.padEnd(width, "0");
|
|
52
|
+
if (leftDigits === rightDigits) return 0;
|
|
53
|
+
return leftDigits < rightDigits ? -1 : 1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/timeline/invocationPath.ts
|
|
57
|
+
var PATH_SEGMENT_KIND = {
|
|
58
|
+
STEP: "step",
|
|
59
|
+
BRANCH: "branch",
|
|
60
|
+
ITEM: "item",
|
|
61
|
+
OUTCOME: "outcome",
|
|
62
|
+
DEFAULT: "default",
|
|
63
|
+
UNKNOWN: "unknown"
|
|
64
|
+
};
|
|
65
|
+
var PATH_SEPARATOR = "/";
|
|
66
|
+
var ORDINAL_SEGMENT = /^(step|branch|item)_([1-9][0-9]*)$/;
|
|
67
|
+
var OUTCOME_PREFIX = "outcome_";
|
|
68
|
+
var DEFAULT_SEGMENT = "default";
|
|
69
|
+
function splitInvocationPath(path) {
|
|
70
|
+
const [root, ...segments] = path.split(PATH_SEPARATOR);
|
|
71
|
+
return { root, segments };
|
|
72
|
+
}
|
|
73
|
+
function invocationPathDepth(path) {
|
|
74
|
+
return path.split(PATH_SEPARATOR).length;
|
|
75
|
+
}
|
|
76
|
+
function parentInvocationPath(path) {
|
|
77
|
+
const cut = path.lastIndexOf(PATH_SEPARATOR);
|
|
78
|
+
return cut < 0 ? null : path.slice(0, cut);
|
|
79
|
+
}
|
|
80
|
+
function lastPathSegment(path) {
|
|
81
|
+
const cut = path.lastIndexOf(PATH_SEPARATOR);
|
|
82
|
+
return cut < 0 ? null : parsePathSegment(path.slice(cut + 1));
|
|
83
|
+
}
|
|
84
|
+
function decodeOutcomeKey(encoded) {
|
|
85
|
+
try {
|
|
86
|
+
return decodeURIComponent(encoded);
|
|
87
|
+
} catch (e) {
|
|
88
|
+
return encoded;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function parsePathSegment(raw) {
|
|
92
|
+
const ordinal = ORDINAL_SEGMENT.exec(raw);
|
|
93
|
+
if (ordinal) {
|
|
94
|
+
const kind = ordinal[1];
|
|
95
|
+
return { kind, ordinal: Number.parseInt(ordinal[2], 10), raw };
|
|
96
|
+
}
|
|
97
|
+
if (raw.startsWith(OUTCOME_PREFIX)) {
|
|
98
|
+
return {
|
|
99
|
+
kind: PATH_SEGMENT_KIND.OUTCOME,
|
|
100
|
+
key: decodeOutcomeKey(raw.slice(OUTCOME_PREFIX.length)),
|
|
101
|
+
raw
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (raw === DEFAULT_SEGMENT) return { kind: PATH_SEGMENT_KIND.DEFAULT, raw };
|
|
105
|
+
return { kind: PATH_SEGMENT_KIND.UNKNOWN, raw };
|
|
106
|
+
}
|
|
107
|
+
function isOrdinalSegment(segment) {
|
|
108
|
+
return segment !== null && (segment.kind === PATH_SEGMENT_KIND.STEP || segment.kind === PATH_SEGMENT_KIND.BRANCH || segment.kind === PATH_SEGMENT_KIND.ITEM);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/timeline/snapshotFreshness.ts
|
|
112
|
+
function progressStreamKey(snapshot) {
|
|
113
|
+
var _a;
|
|
114
|
+
return JSON.stringify([snapshot.pipeline_run_id, snapshot.mode, (_a = snapshot.root_path) != null ? _a : null]);
|
|
115
|
+
}
|
|
116
|
+
function isSameProgressStream(a, b) {
|
|
117
|
+
return progressStreamKey(a) === progressStreamKey(b);
|
|
118
|
+
}
|
|
119
|
+
function fresherSnapshot(held, incoming) {
|
|
120
|
+
if (!held || held === incoming) return incoming;
|
|
121
|
+
if (!isSameProgressStream(held, incoming)) return incoming;
|
|
122
|
+
const heldEnded = isRunEnded(held.status);
|
|
123
|
+
const incomingEnded = isRunEnded(incoming.status);
|
|
124
|
+
if (heldEnded !== incomingEnded) return heldEnded ? held : incoming;
|
|
125
|
+
if (incoming.version !== held.version) {
|
|
126
|
+
return incoming.version > held.version ? incoming : held;
|
|
127
|
+
}
|
|
128
|
+
const order = compareTimestamps(incoming.assembled_at, held.assembled_at);
|
|
129
|
+
if (order === null) return timestampMs(incoming.assembled_at) === null ? held : incoming;
|
|
130
|
+
return order > 0 ? incoming : held;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/timeline/timelineRows.ts
|
|
134
|
+
var DEFAULT_WIDE_BATCH_THRESHOLD = 10;
|
|
135
|
+
var KEPT_VISIBLE_REASON = {
|
|
136
|
+
FAILED: "failed",
|
|
137
|
+
DEGRADED: "degraded"
|
|
138
|
+
};
|
|
139
|
+
function compareSiblings(a, b) {
|
|
140
|
+
const aOrdinal = isOrdinalSegment(a.segment) ? a.segment.ordinal : null;
|
|
141
|
+
const bOrdinal = isOrdinalSegment(b.segment) ? b.segment.ordinal : null;
|
|
142
|
+
if (aOrdinal !== null && bOrdinal !== null && aOrdinal !== bOrdinal) return aOrdinal - bOrdinal;
|
|
143
|
+
if (aOrdinal !== null && bOrdinal === null) return -1;
|
|
144
|
+
if (aOrdinal === null && bOrdinal !== null) return 1;
|
|
145
|
+
return a.order - b.order;
|
|
146
|
+
}
|
|
147
|
+
function buildTree(snapshot) {
|
|
148
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
149
|
+
snapshot.invocations.forEach((invocation, order) => {
|
|
150
|
+
if (byPath.has(invocation.path)) return;
|
|
151
|
+
byPath.set(invocation.path, {
|
|
152
|
+
invocation,
|
|
153
|
+
order,
|
|
154
|
+
segment: lastPathSegment(invocation.path),
|
|
155
|
+
parentPath: null,
|
|
156
|
+
children: [],
|
|
157
|
+
trouble: null
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
const roots = [];
|
|
161
|
+
for (const node of byPath.values()) {
|
|
162
|
+
let ancestor = parentInvocationPath(node.invocation.path);
|
|
163
|
+
while (ancestor !== null && !byPath.has(ancestor)) ancestor = parentInvocationPath(ancestor);
|
|
164
|
+
const parent = ancestor === null ? void 0 : byPath.get(ancestor);
|
|
165
|
+
if (parent) {
|
|
166
|
+
node.parentPath = parent.invocation.path;
|
|
167
|
+
parent.children.push(node);
|
|
168
|
+
} else {
|
|
169
|
+
roots.push(node);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
for (const node of byPath.values()) node.children.sort(compareSiblings);
|
|
173
|
+
roots.sort((a, b) => a.order - b.order);
|
|
174
|
+
for (const root of roots) markTrouble(root);
|
|
175
|
+
return roots;
|
|
176
|
+
}
|
|
177
|
+
function markTrouble(node) {
|
|
178
|
+
let failed = node.invocation.status === INVOCATION_STATUS.FAILED;
|
|
179
|
+
let degraded = node.invocation.degradation !== void 0;
|
|
180
|
+
for (const child of node.children) {
|
|
181
|
+
const reason = markTrouble(child);
|
|
182
|
+
if (reason === KEPT_VISIBLE_REASON.FAILED) failed = true;
|
|
183
|
+
if (reason === KEPT_VISIBLE_REASON.DEGRADED) degraded = true;
|
|
184
|
+
}
|
|
185
|
+
if (failed) node.trouble = KEPT_VISIBLE_REASON.FAILED;
|
|
186
|
+
else if (degraded) node.trouble = KEPT_VISIBLE_REASON.DEGRADED;
|
|
187
|
+
else node.trouble = null;
|
|
188
|
+
return node.trouble;
|
|
189
|
+
}
|
|
190
|
+
function isItemNode(node) {
|
|
191
|
+
var _a;
|
|
192
|
+
return ((_a = node.segment) == null ? void 0 : _a.kind) === PATH_SEGMENT_KIND.ITEM;
|
|
193
|
+
}
|
|
194
|
+
function placeLabelOf(segment, parent, outcome) {
|
|
195
|
+
var _a;
|
|
196
|
+
if (!segment) return null;
|
|
197
|
+
const of = (count) => count === void 0 ? "" : ` of ${count}`;
|
|
198
|
+
switch (segment.kind) {
|
|
199
|
+
case PATH_SEGMENT_KIND.STEP:
|
|
200
|
+
return `step ${segment.ordinal}${of(parent == null ? void 0 : parent.step_count)}`;
|
|
201
|
+
case PATH_SEGMENT_KIND.BRANCH:
|
|
202
|
+
return `branch ${segment.ordinal}${of(parent == null ? void 0 : parent.branch_count)}`;
|
|
203
|
+
case PATH_SEGMENT_KIND.ITEM:
|
|
204
|
+
return `item ${segment.ordinal}${of((_a = parent == null ? void 0 : parent.batch) == null ? void 0 : _a.total)}`;
|
|
205
|
+
case PATH_SEGMENT_KIND.OUTCOME:
|
|
206
|
+
case PATH_SEGMENT_KIND.DEFAULT:
|
|
207
|
+
return outcome && outcome.key !== null ? `outcome ${outcome.key}` : "default outcome";
|
|
208
|
+
default:
|
|
209
|
+
return segment.raw;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function outcomeOf(node, parent) {
|
|
213
|
+
const segment = node.segment;
|
|
214
|
+
if ((segment == null ? void 0 : segment.kind) !== PATH_SEGMENT_KIND.OUTCOME && (segment == null ? void 0 : segment.kind) !== PATH_SEGMENT_KIND.DEFAULT) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
const resolution = parent == null ? void 0 : parent.invocation.condition;
|
|
218
|
+
const outcomeSiblings = parent ? parent.children.filter(
|
|
219
|
+
(child) => {
|
|
220
|
+
var _a, _b;
|
|
221
|
+
return ((_a = child.segment) == null ? void 0 : _a.kind) === PATH_SEGMENT_KIND.OUTCOME || ((_b = child.segment) == null ? void 0 : _b.kind) === PATH_SEGMENT_KIND.DEFAULT;
|
|
222
|
+
}
|
|
223
|
+
).length : 0;
|
|
224
|
+
if (resolution && outcomeSiblings === 1) {
|
|
225
|
+
return { key: resolution.selected_outcome, fromResolution: true };
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
key: segment.kind === PATH_SEGMENT_KIND.OUTCOME ? segment.key : null,
|
|
229
|
+
fromResolution: false
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function stripOf(items) {
|
|
233
|
+
const strip = [];
|
|
234
|
+
items.forEach((item, index) => {
|
|
235
|
+
const status = item.invocation.status;
|
|
236
|
+
const firstItem = isOrdinalSegment(item.segment) ? item.segment.ordinal : index + 1;
|
|
237
|
+
const last = strip[strip.length - 1];
|
|
238
|
+
if (last && last.status === status && last.firstItem + last.count === firstItem) {
|
|
239
|
+
last.count += 1;
|
|
240
|
+
} else {
|
|
241
|
+
strip.push({ status, firstItem, count: 1 });
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
return strip;
|
|
245
|
+
}
|
|
246
|
+
function buildTimelineRows(snapshot, options = {}) {
|
|
247
|
+
var _a, _b;
|
|
248
|
+
const threshold = (_a = options.wideBatchThreshold) != null ? _a : DEFAULT_WIDE_BATCH_THRESHOLD;
|
|
249
|
+
const expandedBatches = (_b = options.expandedBatches) != null ? _b : {};
|
|
250
|
+
const rows = [];
|
|
251
|
+
const visit = (node, parent, depth, keptVisible) => {
|
|
252
|
+
var _a2, _b2, _c, _d, _e;
|
|
253
|
+
const invocation = node.invocation;
|
|
254
|
+
const items = node.children.filter(isItemNode);
|
|
255
|
+
const isBatch = invocation.batch !== void 0 || items.length > 0;
|
|
256
|
+
let batch = null;
|
|
257
|
+
let expanded = true;
|
|
258
|
+
if (isBatch) {
|
|
259
|
+
const total = (_b2 = (_a2 = invocation.batch) == null ? void 0 : _a2.total) != null ? _b2 : items.length;
|
|
260
|
+
const wide = total > threshold;
|
|
261
|
+
expanded = (_c = expandedBatches[invocation.path]) != null ? _c : !wide;
|
|
262
|
+
const keptCount = expanded ? 0 : items.filter((item) => item.trouble !== null).length;
|
|
263
|
+
batch = {
|
|
264
|
+
counts: (_d = invocation.batch) != null ? _d : null,
|
|
265
|
+
total,
|
|
266
|
+
strip: stripOf(items),
|
|
267
|
+
wide,
|
|
268
|
+
expanded,
|
|
269
|
+
hiddenItemCount: expanded ? 0 : items.length - keptCount
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
const owner = parent && parentInvocationPath(invocation.path) === parent.invocation.path ? parent : null;
|
|
273
|
+
const outcome = outcomeOf(node, owner);
|
|
274
|
+
rows.push({
|
|
275
|
+
path: invocation.path,
|
|
276
|
+
parentPath: node.parentPath,
|
|
277
|
+
depth,
|
|
278
|
+
segment: node.segment,
|
|
279
|
+
placeLabel: placeLabelOf(node.segment, (_e = owner == null ? void 0 : owner.invocation) != null ? _e : null, outcome),
|
|
280
|
+
outcome,
|
|
281
|
+
invocation,
|
|
282
|
+
childCount: node.children.length,
|
|
283
|
+
batch,
|
|
284
|
+
keptVisible
|
|
285
|
+
});
|
|
286
|
+
for (const child of node.children) {
|
|
287
|
+
if (expanded || !isItemNode(child)) {
|
|
288
|
+
visit(child, node, depth + 1, null);
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (child.trouble) visit(child, node, depth + 1, child.trouble);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
for (const root of buildTree(snapshot)) visit(root, null, 0, null);
|
|
295
|
+
return rows;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// src/timeline/timelineTime.ts
|
|
299
|
+
function readingClockMs(snapshot, now) {
|
|
300
|
+
var _a;
|
|
301
|
+
if (typeof now === "number") return Number.isFinite(now) ? now : null;
|
|
302
|
+
if (typeof now === "string") return (_a = timestampMs(now)) != null ? _a : timestampMs(snapshot.assembled_at);
|
|
303
|
+
return timestampMs(snapshot.assembled_at);
|
|
304
|
+
}
|
|
305
|
+
function invocationTimes(invocation) {
|
|
306
|
+
var _a;
|
|
307
|
+
return {
|
|
308
|
+
startedMs: timestampMs(invocation.started_at),
|
|
309
|
+
endedMs: timestampMs(invocation.ended_at),
|
|
310
|
+
failedMs: timestampMs((_a = invocation.last_failure) == null ? void 0 : _a.at)
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function snapshotTimes(snapshot) {
|
|
314
|
+
const invocations = /* @__PURE__ */ new Map();
|
|
315
|
+
let startMs = Number.POSITIVE_INFINITY;
|
|
316
|
+
let endMs = Number.NEGATIVE_INFINITY;
|
|
317
|
+
for (const invocation of snapshot.invocations) {
|
|
318
|
+
const times = invocationTimes(invocation);
|
|
319
|
+
if (!invocations.has(invocation.path)) invocations.set(invocation.path, times);
|
|
320
|
+
if (times.startedMs !== null) {
|
|
321
|
+
startMs = Math.min(startMs, times.startedMs);
|
|
322
|
+
endMs = Math.max(endMs, times.startedMs);
|
|
323
|
+
}
|
|
324
|
+
if (times.endedMs !== null) endMs = Math.max(endMs, times.endedMs);
|
|
325
|
+
if (times.failedMs !== null) endMs = Math.max(endMs, times.failedMs);
|
|
326
|
+
}
|
|
327
|
+
const recorded = startMs === Number.POSITIVE_INFINITY ? null : { startMs, endMs: endMs > startMs ? endMs : startMs + 1 };
|
|
328
|
+
return {
|
|
329
|
+
invocations,
|
|
330
|
+
recorded,
|
|
331
|
+
assembledMs: timestampMs(snapshot.assembled_at),
|
|
332
|
+
ended: isRunEnded(snapshot.status)
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function timelineWindowAt(times, nowMs) {
|
|
336
|
+
const recorded = times.recorded;
|
|
337
|
+
if (!recorded || times.ended) return recorded;
|
|
338
|
+
const clock = typeof nowMs === "number" && Number.isFinite(nowMs) ? nowMs : times.assembledMs;
|
|
339
|
+
if (clock === null || clock <= recorded.endMs) return recorded;
|
|
340
|
+
return { startMs: recorded.startMs, endMs: clock };
|
|
341
|
+
}
|
|
342
|
+
function timelineWindow(snapshot, nowMs) {
|
|
343
|
+
return timelineWindowAt(snapshotTimes(snapshot), nowMs);
|
|
344
|
+
}
|
|
345
|
+
function barFollowsClock(invocation, times = invocationTimes(invocation)) {
|
|
346
|
+
if (times.startedMs === null || times.endedMs !== null) return false;
|
|
347
|
+
return invocation.status === INVOCATION_STATUS.RUNNING || invocation.status === INVOCATION_STATUS.CANCELED;
|
|
348
|
+
}
|
|
349
|
+
function invocationBar(invocation, window, nowMs, times = invocationTimes(invocation)) {
|
|
350
|
+
var _a;
|
|
351
|
+
const startMs = times.startedMs;
|
|
352
|
+
if (startMs === null) return null;
|
|
353
|
+
const endedMs = times.endedMs;
|
|
354
|
+
const clock = typeof nowMs === "number" && Number.isFinite(nowMs) ? nowMs : null;
|
|
355
|
+
let endMs;
|
|
356
|
+
let growing = false;
|
|
357
|
+
let openEnded = false;
|
|
358
|
+
switch (invocation.status) {
|
|
359
|
+
case INVOCATION_STATUS.RUNNING:
|
|
360
|
+
endMs = (_a = endedMs != null ? endedMs : clock) != null ? _a : window.endMs;
|
|
361
|
+
growing = endedMs === null;
|
|
362
|
+
break;
|
|
363
|
+
case INVOCATION_STATUS.CANCELED:
|
|
364
|
+
endMs = endedMs != null ? endedMs : window.endMs;
|
|
365
|
+
openEnded = endedMs === null;
|
|
366
|
+
break;
|
|
367
|
+
default:
|
|
368
|
+
endMs = endedMs != null ? endedMs : startMs;
|
|
369
|
+
}
|
|
370
|
+
return { startMs, endMs: Math.max(startMs, endMs), growing, openEnded };
|
|
371
|
+
}
|
|
372
|
+
function axisPercent(ms, window) {
|
|
373
|
+
const span = window.endMs - window.startMs;
|
|
374
|
+
if (span <= 0) return 0;
|
|
375
|
+
return Math.min(100, Math.max(0, (ms - window.startMs) / span * 100));
|
|
376
|
+
}
|
|
377
|
+
var DAY_MS = 864e5;
|
|
378
|
+
var TICK_STEPS_MS = [
|
|
379
|
+
100,
|
|
380
|
+
200,
|
|
381
|
+
500,
|
|
382
|
+
1e3,
|
|
383
|
+
2e3,
|
|
384
|
+
5e3,
|
|
385
|
+
1e4,
|
|
386
|
+
15e3,
|
|
387
|
+
3e4,
|
|
388
|
+
6e4,
|
|
389
|
+
12e4,
|
|
390
|
+
3e5,
|
|
391
|
+
6e5,
|
|
392
|
+
9e5,
|
|
393
|
+
18e5,
|
|
394
|
+
36e5,
|
|
395
|
+
72e5,
|
|
396
|
+
144e5,
|
|
397
|
+
216e5,
|
|
398
|
+
432e5,
|
|
399
|
+
DAY_MS
|
|
400
|
+
];
|
|
401
|
+
function timelineTicks(window, maxTicks = 6) {
|
|
402
|
+
var _a;
|
|
403
|
+
const span = window.endMs - window.startMs;
|
|
404
|
+
if (!Number.isFinite(span) || span <= 0) return [];
|
|
405
|
+
const budget = Math.max(1, maxTicks);
|
|
406
|
+
const step = (_a = TICK_STEPS_MS.find((candidate) => span / candidate <= budget)) != null ? _a : Math.ceil(span / budget / DAY_MS) * DAY_MS;
|
|
407
|
+
const ticks = [];
|
|
408
|
+
for (let offsetMs = 0; offsetMs <= span; offsetMs += step) {
|
|
409
|
+
ticks.push({
|
|
410
|
+
offsetMs,
|
|
411
|
+
percent: axisPercent(window.startMs + offsetMs, window),
|
|
412
|
+
label: formatDuration(offsetMs)
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
return ticks;
|
|
416
|
+
}
|
|
417
|
+
function formatDuration(ms) {
|
|
418
|
+
const safe = Math.max(0, ms);
|
|
419
|
+
if (safe === 0) return "0s";
|
|
420
|
+
if (Math.round(safe) < 1e3) return `${Math.round(safe)}ms`;
|
|
421
|
+
const tenths = Math.round(safe / 100) / 10;
|
|
422
|
+
if (tenths < 10) return `${tenths}s`;
|
|
423
|
+
const totalSeconds = Math.round(safe / 1e3);
|
|
424
|
+
if (totalSeconds < 60) return `${totalSeconds}s`;
|
|
425
|
+
if (totalSeconds < 3600) {
|
|
426
|
+
const minutes2 = Math.floor(totalSeconds / 60);
|
|
427
|
+
const seconds = totalSeconds % 60;
|
|
428
|
+
return seconds === 0 ? `${minutes2}m` : `${minutes2}m ${String(seconds).padStart(2, "0")}s`;
|
|
429
|
+
}
|
|
430
|
+
const totalMinutes = Math.round(totalSeconds / 60);
|
|
431
|
+
const hours = Math.floor(totalMinutes / 60);
|
|
432
|
+
const minutes = totalMinutes % 60;
|
|
433
|
+
return minutes === 0 ? `${hours}h` : `${hours}h ${String(minutes).padStart(2, "0")}m`;
|
|
434
|
+
}
|
|
435
|
+
function formatClockTime(ms) {
|
|
436
|
+
return `${new Date(ms).toISOString().slice(11, 23)} UTC`;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export {
|
|
440
|
+
PROGRESS_MODE,
|
|
441
|
+
RUN_PROGRESS_STATUS,
|
|
442
|
+
INVOCATION_STATUS,
|
|
443
|
+
DEGRADATION_REASON,
|
|
444
|
+
isRunEnded,
|
|
445
|
+
timestampMs,
|
|
446
|
+
compareTimestamps,
|
|
447
|
+
PATH_SEGMENT_KIND,
|
|
448
|
+
splitInvocationPath,
|
|
449
|
+
invocationPathDepth,
|
|
450
|
+
parentInvocationPath,
|
|
451
|
+
lastPathSegment,
|
|
452
|
+
decodeOutcomeKey,
|
|
453
|
+
parsePathSegment,
|
|
454
|
+
isOrdinalSegment,
|
|
455
|
+
progressStreamKey,
|
|
456
|
+
isSameProgressStream,
|
|
457
|
+
fresherSnapshot,
|
|
458
|
+
DEFAULT_WIDE_BATCH_THRESHOLD,
|
|
459
|
+
KEPT_VISIBLE_REASON,
|
|
460
|
+
buildTimelineRows,
|
|
461
|
+
readingClockMs,
|
|
462
|
+
invocationTimes,
|
|
463
|
+
snapshotTimes,
|
|
464
|
+
timelineWindowAt,
|
|
465
|
+
timelineWindow,
|
|
466
|
+
barFollowsClock,
|
|
467
|
+
invocationBar,
|
|
468
|
+
axisPercent,
|
|
469
|
+
timelineTicks,
|
|
470
|
+
formatDuration,
|
|
471
|
+
formatClockTime
|
|
472
|
+
};
|
|
473
|
+
//# sourceMappingURL=chunk-JJG2TO7P.js.map
|