@demlik/tea 0.8.0 → 0.9.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/chart/lane/server.d.ts +79 -0
- package/dist/chart/lane/server.js +118 -0
- package/dist/chart/lane/server.js.map +1 -0
- package/dist/chart/lane/viewer/assets/abnfDiagram-N423BO3Z-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/architectureDiagram-T3A2C74G-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/blockDiagram-VBNYF7ZC-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/c4Diagram-5PPSVZJV-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/chunk-2GRJ4B5K-HdDf8SI3.js +1 -0
- package/dist/chart/lane/viewer/assets/chunk-5RXB4S5H-IPzIfiJ6.js +231 -0
- package/dist/chart/lane/viewer/assets/chunk-5VM5RSS4-BP4fRS_5.js +15 -0
- package/dist/chart/lane/viewer/assets/chunk-KBJHAD2P-DZOw7xU6.js +1 -0
- package/dist/chart/lane/viewer/assets/chunk-NSK5VX7P-CBCyTZMs.js +128 -0
- package/dist/chart/lane/viewer/assets/classDiagram-JCYQIIEL-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/classDiagram-v2-OCEON4UE-DnUXz1Pv.js +206 -0
- package/dist/chart/lane/viewer/assets/cose-bilkent-JH36ORCC-DOwCrGXH.js +1 -0
- package/dist/chart/lane/viewer/assets/cynefinDiagram-MW4NZA55-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/dagre-K_PewWfS.js +1 -0
- package/dist/chart/lane/viewer/assets/dagre-VZM6K2ZE-Og2UIoWg.js +4 -0
- package/dist/chart/lane/viewer/assets/diagram-7IWD3JNH-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/diagram-B4RE2ZJO-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/diagram-LBJQPF4R-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/diagram-Q27KOJAE-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/diagram-UB23O5K3-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/ebnfDiagram-BXEA7PRR-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/erDiagram-JOGREHBK-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/flowDiagram-UKHOOZJN-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/ganttDiagram-PKOTCBZU-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/gitGraphDiagram-DS77QQ5N-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/index-Obj05Jex.js +195 -0
- package/dist/chart/lane/viewer/assets/index-sP-6AD57.css +1 -0
- package/dist/chart/lane/viewer/assets/infoDiagram-6WML65LV-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/ishikawaDiagram-WSZJBQD7-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/journeyDiagram-NVQOT4AX-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/kanban-definition-27J2QSJJ-CxkCxJUN.js +89 -0
- package/dist/chart/lane/viewer/assets/katex-DOwCrGXH.js +1 -0
- package/dist/chart/lane/viewer/assets/mindmap-definition-FAOFIHXS-DvgvXZhp.js +96 -0
- package/dist/chart/lane/viewer/assets/path-fybaL0A-.js +1 -0
- package/dist/chart/lane/viewer/assets/pegDiagram-VL7TDLO6-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/pieDiagram-7S7Q4E2Y-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/quadrantDiagram-CIZ2JOQS-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/railroadDiagram-AXF67PYL-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/requirementDiagram-LRYGKXZP-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/sankeyDiagram-W5VNT64P-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/sequenceDiagram-SI44F4Z6-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/stateDiagram-OKZ733FA-CIZQWK5X.js +1 -0
- package/dist/chart/lane/viewer/assets/stateDiagram-v2-UEYNNEHI-Sm6p0NoR.js +1 -0
- package/dist/chart/lane/viewer/assets/swimlanes-SLNWSIFB-B4xK-rwg.js +1 -0
- package/dist/chart/lane/viewer/assets/swimlanesDiagram-ULZ7WXOC-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/timeline-definition-Z64GVDOM-CV3KwSb-.js +120 -0
- package/dist/chart/lane/viewer/assets/vennDiagram-T6HMQDX7-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/wardleyDiagram-T6FBY63Y-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/assets/xychartDiagram-ELKLHX3M-C729LI31.js +1 -0
- package/dist/chart/lane/viewer/index.html +15 -0
- package/package.json +12 -3
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** One lane, as the two files a host already has on disk. */
|
|
2
|
+
interface LaneFiles {
|
|
3
|
+
/** The lane key — the issue number, or whatever the host names lanes by. */
|
|
4
|
+
readonly id: string;
|
|
5
|
+
/** `workflow.json`, verbatim. */
|
|
6
|
+
readonly workflow: string;
|
|
7
|
+
/** `events.jsonl`, verbatim. Empty for a lane that has not run yet. */
|
|
8
|
+
readonly events: string;
|
|
9
|
+
/**
|
|
10
|
+
* Who sends each event, when the host knows.
|
|
11
|
+
*
|
|
12
|
+
* A workflow document records topology and never provenance, so without
|
|
13
|
+
* this the page can see that a task cannot move and not that it is WAITING
|
|
14
|
+
* ON SOMEONE — which is the question a reader opened it to answer.
|
|
15
|
+
*/
|
|
16
|
+
readonly origins?: unknown;
|
|
17
|
+
}
|
|
18
|
+
/** What the host is asked to do when a reader presses a button. */
|
|
19
|
+
interface TransitionRequest {
|
|
20
|
+
readonly lane: string;
|
|
21
|
+
readonly event: string;
|
|
22
|
+
/** Absent on a single-task lane, exactly as the CLI verb allows. */
|
|
23
|
+
readonly task?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The host's answer. A refusal is a legitimate one — the machine said no —
|
|
27
|
+
* and `message` is shown to the reader verbatim, so write it for them.
|
|
28
|
+
*/
|
|
29
|
+
interface TransitionResult {
|
|
30
|
+
readonly ok: boolean;
|
|
31
|
+
readonly message: string;
|
|
32
|
+
}
|
|
33
|
+
/** Who holds a lane, when the host can say. */
|
|
34
|
+
interface LaneDriver {
|
|
35
|
+
/** A person or account — what a reader recognises. */
|
|
36
|
+
readonly login: string;
|
|
37
|
+
/** The claim token, or any stable handle for the session holding it. */
|
|
38
|
+
readonly session: string;
|
|
39
|
+
readonly at?: string | null;
|
|
40
|
+
}
|
|
41
|
+
interface LaneViewerOptions {
|
|
42
|
+
/** Every lane the reader should see. Called on each request; cache if slow. */
|
|
43
|
+
readonly lanes: () => readonly LaneFiles[] | Promise<readonly LaneFiles[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Record one event. OMIT IT and the page becomes read-only — every lane is
|
|
46
|
+
* still shown, and nothing offers to act. That is a real mode, not a
|
|
47
|
+
* degraded one: a report of a run that finished has nothing to dispatch.
|
|
48
|
+
*/
|
|
49
|
+
readonly transition?: (req: TransitionRequest) => TransitionResult | Promise<TransitionResult>;
|
|
50
|
+
/** Ownership, when it is knowable. `null` for a lane nobody holds. */
|
|
51
|
+
readonly drivers?: () => Promise<Readonly<Record<string, LaneDriver | null>>>;
|
|
52
|
+
/** Shown in the footer — where these lanes were read from. */
|
|
53
|
+
readonly source?: string;
|
|
54
|
+
/**
|
|
55
|
+
* How often to re-ask `lanes()` for the live stream, in ms. Default 2000.
|
|
56
|
+
*
|
|
57
|
+
* LIVENESS IS OURS, NOT THE HOST'S. A host could watch its own files and
|
|
58
|
+
* push, and then every host would write that code and get it subtly
|
|
59
|
+
* different. Re-asking is uninteresting and correct: `lanes()` is a read of
|
|
60
|
+
* two files a driver appends to, the answer is compared before anything is
|
|
61
|
+
* sent, and a quiet fleet costs one stat per lane per tick.
|
|
62
|
+
*/
|
|
63
|
+
readonly pollMs?: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The page, plus the small JSON contract it speaks.
|
|
67
|
+
*
|
|
68
|
+
* ```ts
|
|
69
|
+
* const handle = laneViewer({
|
|
70
|
+
* lanes: () => readMyLanes(),
|
|
71
|
+
* transition: (r) => myTransitionVerb(r),
|
|
72
|
+
* });
|
|
73
|
+
* // Node:
|
|
74
|
+
* createServer(async (req, res) => { … await handle(request) … });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
declare function laneViewer(opts: LaneViewerOptions): (request: Request) => Promise<Response>;
|
|
78
|
+
|
|
79
|
+
export { type LaneDriver, type LaneFiles, type LaneViewerOptions, type TransitionRequest, type TransitionResult, laneViewer };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
import { resolve, normalize, join, extname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
// src/chart/lane/server.ts
|
|
6
|
+
var MIME = {
|
|
7
|
+
".html": "text/html; charset=utf-8",
|
|
8
|
+
".js": "text/javascript; charset=utf-8",
|
|
9
|
+
".css": "text/css; charset=utf-8",
|
|
10
|
+
".json": "application/json; charset=utf-8",
|
|
11
|
+
".svg": "image/svg+xml",
|
|
12
|
+
".woff2": "font/woff2"
|
|
13
|
+
};
|
|
14
|
+
var json = (body, status = 200) => new Response(JSON.stringify(body), {
|
|
15
|
+
status,
|
|
16
|
+
headers: { "content-type": "application/json; charset=utf-8" }
|
|
17
|
+
});
|
|
18
|
+
var ASSETS = resolve(fileURLToPath(import.meta.url), "..", "viewer");
|
|
19
|
+
function laneViewer(opts) {
|
|
20
|
+
return async (request) => {
|
|
21
|
+
const url = new URL(request.url);
|
|
22
|
+
const path = url.pathname;
|
|
23
|
+
if (path === "/api/lanes") {
|
|
24
|
+
return json({ lanes: await opts.lanes(), source: opts.source ?? "" });
|
|
25
|
+
}
|
|
26
|
+
if (path === "/api/drivers") {
|
|
27
|
+
if (opts.drivers === void 0) return json({ drivers: {} });
|
|
28
|
+
try {
|
|
29
|
+
return json({ drivers: await opts.drivers() });
|
|
30
|
+
} catch {
|
|
31
|
+
return json({ drivers: {} });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (path === "/api/stream") {
|
|
35
|
+
const every = Math.max(250, opts.pollMs ?? 2e3);
|
|
36
|
+
let last = "";
|
|
37
|
+
let timer;
|
|
38
|
+
const stream = new ReadableStream({
|
|
39
|
+
start(controller) {
|
|
40
|
+
const enc = new TextEncoder();
|
|
41
|
+
const beat = async () => {
|
|
42
|
+
try {
|
|
43
|
+
const next = JSON.stringify(await opts.lanes());
|
|
44
|
+
if (next === last) return;
|
|
45
|
+
last = next;
|
|
46
|
+
controller.enqueue(enc.encode(`data: ${next}
|
|
47
|
+
|
|
48
|
+
`));
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
void beat();
|
|
53
|
+
timer = setInterval(() => void beat(), every);
|
|
54
|
+
},
|
|
55
|
+
cancel() {
|
|
56
|
+
if (timer !== void 0) clearInterval(timer);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return new Response(stream, {
|
|
60
|
+
headers: {
|
|
61
|
+
"content-type": "text/event-stream; charset=utf-8",
|
|
62
|
+
"cache-control": "no-store",
|
|
63
|
+
connection: "keep-alive"
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (path === "/api/transition") {
|
|
68
|
+
if (request.method !== "POST") return json({ ok: false }, 405);
|
|
69
|
+
if (opts.transition === void 0) {
|
|
70
|
+
return json(
|
|
71
|
+
{
|
|
72
|
+
ok: false,
|
|
73
|
+
exit: 1,
|
|
74
|
+
stdout: "",
|
|
75
|
+
stderr: "this viewer is read-only"
|
|
76
|
+
},
|
|
77
|
+
200
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
let body;
|
|
81
|
+
try {
|
|
82
|
+
body = await request.json();
|
|
83
|
+
} catch {
|
|
84
|
+
return json(
|
|
85
|
+
{ ok: false, exit: 1, stdout: "", stderr: "malformed request" },
|
|
86
|
+
400
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const out = await opts.transition(body);
|
|
90
|
+
return json({
|
|
91
|
+
ok: out.ok,
|
|
92
|
+
exit: out.ok ? 0 : 1,
|
|
93
|
+
stdout: out.ok ? out.message : "",
|
|
94
|
+
stderr: out.ok ? "" : out.message
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const rel = path === "/" ? "index.html" : path.replace(/^\/+/, "");
|
|
98
|
+
const file = normalize(join(ASSETS, rel));
|
|
99
|
+
if (!file.startsWith(ASSETS)) return new Response("no", { status: 403 });
|
|
100
|
+
try {
|
|
101
|
+
const bytes = await readFile(file);
|
|
102
|
+
return new Response(new Uint8Array(bytes), {
|
|
103
|
+
headers: {
|
|
104
|
+
"content-type": MIME[extname(file)] ?? "application/octet-stream"
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
} catch {
|
|
108
|
+
const html = await readFile(join(ASSETS, "index.html"));
|
|
109
|
+
return new Response(new Uint8Array(html), {
|
|
110
|
+
headers: { "content-type": MIME[".html"] }
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { laneViewer };
|
|
117
|
+
//# sourceMappingURL=server.js.map
|
|
118
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/chart/lane/server.ts"],"names":[],"mappings":"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","file":"server.js","sourcesContent":["// ═══════════════════════════════════════════════════════════════════════════\n// chart/lane/server — the dashboard, as something a host can SERVE.\n//\n// `./chart/lane/react` gives you the components and assumes you have a\n// bundler. A CLI does not, and the consumer this was written for — fabrika —\n// is a CLI: it already knows where the lanes are, how to fold one and how to\n// record an event, and what it does not have is a page.\n//\n// So this ships the page prebuilt and asks the host for the three facts only\n// the host can know:\n//\n// WHERE THE LANES ARE — it reads its own root; we never touch a filesystem.\n// HOW TO RECORD AN EVENT — its own verb, which stays the ONLY writer. The\n// page proposes and the host disposes; a refusal is an answer, not an\n// error, and it is displayed in the host's own words.\n// WHO HOLDS A LANE — optional, because ownership is not in the lane files at\n// all (fabrika keeps claims on GitHub), so plenty of hosts cannot answer\n// it. Absent means UNKNOWN and the page says nothing, never \"free\".\n//\n// Everything else — folding, deriving what is stuck, drawing the machines,\n// the attention ordering, the scrubbing — is the library's and is already\n// tested here. The host writes an adapter, not a dashboard.\n//\n// The handler is `(Request) => Promise<Response>`, so it mounts under Node's\n// `http`, Bun.serve, Hono, or a Worker without an adapter per framework.\n// ═══════════════════════════════════════════════════════════════════════════\nimport { readFile } from \"node:fs/promises\";\nimport { extname, join, normalize, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/** One lane, as the two files a host already has on disk. */\nexport interface LaneFiles {\n /** The lane key — the issue number, or whatever the host names lanes by. */\n readonly id: string;\n /** `workflow.json`, verbatim. */\n readonly workflow: string;\n /** `events.jsonl`, verbatim. Empty for a lane that has not run yet. */\n readonly events: string;\n /**\n * Who sends each event, when the host knows.\n *\n * A workflow document records topology and never provenance, so without\n * this the page can see that a task cannot move and not that it is WAITING\n * ON SOMEONE — which is the question a reader opened it to answer.\n */\n readonly origins?: unknown;\n}\n\n/** What the host is asked to do when a reader presses a button. */\nexport interface TransitionRequest {\n readonly lane: string;\n readonly event: string;\n /** Absent on a single-task lane, exactly as the CLI verb allows. */\n readonly task?: string;\n}\n\n/**\n * The host's answer. A refusal is a legitimate one — the machine said no —\n * and `message` is shown to the reader verbatim, so write it for them.\n */\nexport interface TransitionResult {\n readonly ok: boolean;\n readonly message: string;\n}\n\n/** Who holds a lane, when the host can say. */\nexport interface LaneDriver {\n /** A person or account — what a reader recognises. */\n readonly login: string;\n /** The claim token, or any stable handle for the session holding it. */\n readonly session: string;\n readonly at?: string | null;\n}\n\nexport interface LaneViewerOptions {\n /** Every lane the reader should see. Called on each request; cache if slow. */\n readonly lanes: () => readonly LaneFiles[] | Promise<readonly LaneFiles[]>;\n /**\n * Record one event. OMIT IT and the page becomes read-only — every lane is\n * still shown, and nothing offers to act. That is a real mode, not a\n * degraded one: a report of a run that finished has nothing to dispatch.\n */\n readonly transition?: (\n req: TransitionRequest,\n ) => TransitionResult | Promise<TransitionResult>;\n /** Ownership, when it is knowable. `null` for a lane nobody holds. */\n readonly drivers?: () => Promise<Readonly<Record<string, LaneDriver | null>>>;\n /** Shown in the footer — where these lanes were read from. */\n readonly source?: string;\n /**\n * How often to re-ask `lanes()` for the live stream, in ms. Default 2000.\n *\n * LIVENESS IS OURS, NOT THE HOST'S. A host could watch its own files and\n * push, and then every host would write that code and get it subtly\n * different. Re-asking is uninteresting and correct: `lanes()` is a read of\n * two files a driver appends to, the answer is compared before anything is\n * sent, and a quiet fleet costs one stat per lane per tick.\n */\n readonly pollMs?: number;\n}\n\nconst MIME: Readonly<Record<string, string>> = {\n \".html\": \"text/html; charset=utf-8\",\n \".js\": \"text/javascript; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".json\": \"application/json; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".woff2\": \"font/woff2\",\n};\n\nconst json = (body: unknown, status = 200): Response =>\n new Response(JSON.stringify(body), {\n status,\n headers: { \"content-type\": \"application/json; charset=utf-8\" },\n });\n\n/** Where the prebuilt page lives inside this package. */\nconst ASSETS = resolve(fileURLToPath(import.meta.url), \"..\", \"viewer\");\n\n/**\n * The page, plus the small JSON contract it speaks.\n *\n * ```ts\n * const handle = laneViewer({\n * lanes: () => readMyLanes(),\n * transition: (r) => myTransitionVerb(r),\n * });\n * // Node:\n * createServer(async (req, res) => { … await handle(request) … });\n * ```\n */\nexport function laneViewer(\n opts: LaneViewerOptions,\n): (request: Request) => Promise<Response> {\n return async (request: Request): Promise<Response> => {\n const url = new URL(request.url);\n const path = url.pathname;\n\n if (path === \"/api/lanes\") {\n return json({ lanes: await opts.lanes(), source: opts.source ?? \"\" });\n }\n\n if (path === \"/api/drivers\") {\n if (opts.drivers === undefined) return json({ drivers: {} });\n try {\n return json({ drivers: await opts.drivers() });\n } catch {\n // UNKNOWN is not \"nobody\" — an empty answer renders nothing, and a\n // lane shown free while someone holds it is what starts a second\n // driver on one piece of work.\n return json({ drivers: {} });\n }\n }\n\n if (path === \"/api/stream\") {\n const every = Math.max(250, opts.pollMs ?? 2000);\n let last = \"\";\n let timer: ReturnType<typeof setInterval> | undefined;\n const stream = new ReadableStream<Uint8Array>({\n start(controller) {\n const enc = new TextEncoder();\n const beat = async () => {\n try {\n const next = JSON.stringify(await opts.lanes());\n if (next === last) return;\n last = next;\n controller.enqueue(enc.encode(`data: ${next}\\n\\n`));\n } catch {\n // a half-written append is the next event arriving, not a fault\n }\n };\n void beat();\n timer = setInterval(() => void beat(), every);\n },\n cancel() {\n if (timer !== undefined) clearInterval(timer);\n },\n });\n return new Response(stream, {\n headers: {\n \"content-type\": \"text/event-stream; charset=utf-8\",\n \"cache-control\": \"no-store\",\n connection: \"keep-alive\",\n },\n });\n }\n\n if (path === \"/api/transition\") {\n if (request.method !== \"POST\") return json({ ok: false }, 405);\n if (opts.transition === undefined) {\n return json(\n {\n ok: false,\n exit: 1,\n stdout: \"\",\n stderr: \"this viewer is read-only\",\n },\n 200,\n );\n }\n let body: TransitionRequest;\n try {\n body = (await request.json()) as TransitionRequest;\n } catch {\n return json(\n { ok: false, exit: 1, stdout: \"\", stderr: \"malformed request\" },\n 400,\n );\n }\n const out = await opts.transition(body);\n // the page reads `{ok, exit, stdout, stderr}` — a host that speaks in\n // sentences rather than exit codes says the same thing in `stderr`.\n return json({\n ok: out.ok,\n exit: out.ok ? 0 : 1,\n stdout: out.ok ? out.message : \"\",\n stderr: out.ok ? \"\" : out.message,\n });\n }\n\n // ── the page itself ────────────────────────────────────────────────\n // Anything that is not the contract is an asset, and anything that is\n // not an asset is the page — a dashboard is one screen, so an unknown\n // path is a reader who typed something, not a 404 worth showing them.\n const rel = path === \"/\" ? \"index.html\" : path.replace(/^\\/+/, \"\");\n const file = normalize(join(ASSETS, rel));\n if (!file.startsWith(ASSETS)) return new Response(\"no\", { status: 403 });\n\n try {\n const bytes = await readFile(file);\n return new Response(new Uint8Array(bytes), {\n headers: {\n \"content-type\": MIME[extname(file)] ?? \"application/octet-stream\",\n },\n });\n } catch {\n const html = await readFile(join(ASSETS, \"index.html\"));\n return new Response(new Uint8Array(html), {\n headers: { \"content-type\": MIME[\".html\"] as string },\n });\n }\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={};export{e as diagram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={};export{e as diagram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={};export{e as diagram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={};export{e as diagram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ht as e,U as t,_ as n}from"./chunk-NSK5VX7P-CBCyTZMs.js";n();var r=e(()=>{let e=t(`.mermaidTooltip`);return e.empty()&&(e=t(`body`).append(`div`).attr(`class`,`mermaidTooltip`).style(`opacity`,0).style(`position`,`absolute`).style(`text-align`,`center`).style(`max-width`,`200px`).style(`padding`,`2px`).style(`font-size`,`12px`).style(`background`,`#ffffde`).style(`border`,`1px solid #333`).style(`border-radius`,`2px`).style(`pointer-events`,`none`).style(`z-index`,`100`)),e},`createTooltip`);export{r as t};
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import{Et as e,Ft as t,Ht as n,Ot as r,Tt as i,U as a,Y as o,a as s,at as c,f as l,it as u,q as d,st as f,ut as p,zt as m}from"./chunk-NSK5VX7P-CBCyTZMs.js";import{n as h}from"./index-Obj05Jex.js";import{n as g,t as _}from"./chunk-KBJHAD2P-DZOw7xU6.js";import{t as v}from"./chunk-2GRJ4B5K-HdDf8SI3.js";var y=(function(){var e=n(function(e,t,n,r){for(n||={},r=e.length;r--;n[e[r]]=t);return n},`o`),t=[1,2],r=[1,3],i=[1,4],a=[2,4],o=[1,9],s=[1,11],c=[1,16],l=[1,17],u=[1,18],d=[1,19],f=[1,33],p=[1,20],m=[1,21],h=[1,22],g=[1,23],_=[1,24],v=[1,26],y=[1,27],b=[1,28],x=[1,29],S=[1,30],C=[1,31],w=[1,32],T=[1,35],E=[1,36],D=[1,37],O=[1,38],k=[1,34],A=[1,4,5,16,17,19,21,22,24,25,26,27,28,29,33,35,37,38,41,45,48,51,52,53,54,57],j=[1,4,5,14,15,16,17,19,21,22,24,25,26,27,28,29,33,35,37,38,39,40,41,45,48,51,52,53,54,57],M=[4,5,16,17,19,21,22,24,25,26,27,28,29,33,35,37,38,41,45,48,51,52,53,54,57],N={trace:n(function(){},`trace`),yy:{},symbols_:{error:2,start:3,SPACE:4,NL:5,SD:6,document:7,line:8,statement:9,classDefStatement:10,styleStatement:11,cssClassStatement:12,idStatement:13,DESCR:14,"-->":15,HIDE_EMPTY:16,scale:17,WIDTH:18,COMPOSIT_STATE:19,STRUCT_START:20,STRUCT_STOP:21,STATE_DESCR:22,AS:23,ID:24,FORK:25,JOIN:26,CHOICE:27,CONCURRENT:28,note:29,notePosition:30,NOTE_TEXT:31,direction:32,acc_title:33,acc_title_value:34,acc_descr:35,acc_descr_value:36,acc_descr_multiline_value:37,CLICK:38,STRING:39,HREF:40,classDef:41,CLASSDEF_ID:42,CLASSDEF_STYLEOPTS:43,DEFAULT:44,style:45,STYLE_IDS:46,STYLEDEF_STYLEOPTS:47,class:48,CLASSENTITY_IDS:49,STYLECLASS:50,direction_tb:51,direction_bt:52,direction_rl:53,direction_lr:54,eol:55,";":56,EDGE_STATE:57,STYLE_SEPARATOR:58,left_of:59,right_of:60,$accept:0,$end:1},terminals_:{2:`error`,4:`SPACE`,5:`NL`,6:`SD`,14:`DESCR`,15:`-->`,16:`HIDE_EMPTY`,17:`scale`,18:`WIDTH`,19:`COMPOSIT_STATE`,20:`STRUCT_START`,21:`STRUCT_STOP`,22:`STATE_DESCR`,23:`AS`,24:`ID`,25:`FORK`,26:`JOIN`,27:`CHOICE`,28:`CONCURRENT`,29:`note`,31:`NOTE_TEXT`,33:`acc_title`,34:`acc_title_value`,35:`acc_descr`,36:`acc_descr_value`,37:`acc_descr_multiline_value`,38:`CLICK`,39:`STRING`,40:`HREF`,41:`classDef`,42:`CLASSDEF_ID`,43:`CLASSDEF_STYLEOPTS`,44:`DEFAULT`,45:`style`,46:`STYLE_IDS`,47:`STYLEDEF_STYLEOPTS`,48:`class`,49:`CLASSENTITY_IDS`,50:`STYLECLASS`,51:`direction_tb`,52:`direction_bt`,53:`direction_rl`,54:`direction_lr`,56:`;`,57:`EDGE_STATE`,58:`STYLE_SEPARATOR`,59:`left_of`,60:`right_of`},productions_:[0,[3,2],[3,2],[3,2],[7,0],[7,2],[8,2],[8,1],[8,1],[9,1],[9,1],[9,1],[9,1],[9,2],[9,3],[9,4],[9,1],[9,2],[9,1],[9,4],[9,3],[9,6],[9,1],[9,1],[9,1],[9,1],[9,4],[9,4],[9,1],[9,2],[9,2],[9,1],[9,5],[9,5],[10,3],[10,3],[11,3],[12,3],[32,1],[32,1],[32,1],[32,1],[55,1],[55,1],[13,1],[13,1],[13,3],[13,3],[30,1],[30,1]],performAction:n(function(e,t,n,r,i,a,o){var s=a.length-1;switch(i){case 3:return r.setRootDoc(a[s]),a[s];case 4:this.$=[];break;case 5:a[s]!=`nl`&&(a[s-1].push(a[s]),this.$=a[s-1]);break;case 6:case 7:this.$=a[s];break;case 8:this.$=`nl`;break;case 12:this.$=a[s];break;case 13:let e=a[s-1];e.description=r.trimColon(a[s]),this.$=e;break;case 14:this.$={stmt:`relation`,state1:a[s-2],state2:a[s]};break;case 15:let t=r.trimColon(a[s]);this.$={stmt:`relation`,state1:a[s-3],state2:a[s-1],description:t};break;case 19:this.$={stmt:`state`,id:a[s-3],type:`default`,description:``,doc:a[s-1]};break;case 20:var c=a[s],l=a[s-2].trim();if(a[s].match(`:`)){var u=a[s].split(`:`);c=u[0],l=[l,u[1]]}this.$={stmt:`state`,id:c,type:`default`,description:l};break;case 21:this.$={stmt:`state`,id:a[s-3],type:`default`,description:a[s-5],doc:a[s-1]};break;case 22:this.$={stmt:`state`,id:a[s],type:`fork`};break;case 23:this.$={stmt:`state`,id:a[s],type:`join`};break;case 24:this.$={stmt:`state`,id:a[s],type:`choice`};break;case 25:this.$={stmt:`state`,id:r.getDividerId(),type:`divider`};break;case 26:this.$={stmt:`state`,id:a[s-1].trim(),note:{position:a[s-2].trim(),text:a[s].trim()}};break;case 29:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 30:case 31:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 32:this.$={stmt:`click`,id:a[s-3],url:a[s-2],tooltip:a[s-1]};break;case 33:this.$={stmt:`click`,id:a[s-3],url:a[s-1],tooltip:``};break;case 34:case 35:this.$={stmt:`classDef`,id:a[s-1].trim(),classes:a[s].trim()};break;case 36:this.$={stmt:`style`,id:a[s-1].trim(),styleClass:a[s].trim()};break;case 37:this.$={stmt:`applyClass`,id:a[s-1].trim(),styleClass:a[s].trim()};break;case 38:r.setDirection(`TB`),this.$={stmt:`dir`,value:`TB`};break;case 39:r.setDirection(`BT`),this.$={stmt:`dir`,value:`BT`};break;case 40:r.setDirection(`RL`),this.$={stmt:`dir`,value:`RL`};break;case 41:r.setDirection(`LR`),this.$={stmt:`dir`,value:`LR`};break;case 44:case 45:this.$={stmt:`state`,id:a[s].trim(),type:`default`,description:``};break;case 46:this.$={stmt:`state`,id:a[s-2].trim(),classes:[a[s].trim()],type:`default`,description:``};break;case 47:this.$={stmt:`state`,id:a[s-2].trim(),classes:[a[s].trim()],type:`default`,description:``}}},`anonymous`),table:[{3:1,4:t,5:r,6:i},{1:[3]},{3:5,4:t,5:r,6:i},{3:6,4:t,5:r,6:i},e([1,4,5,16,17,19,22,24,25,26,27,28,29,33,35,37,38,41,45,48,51,52,53,54,57],a,{7:7}),{1:[2,1]},{1:[2,2]},{1:[2,3],4:o,5:s,8:8,9:10,10:12,11:13,12:14,13:15,16:c,17:l,19:u,22:d,24:f,25:p,26:m,27:h,28:g,29:_,32:25,33:v,35:y,37:b,38:x,41:S,45:C,48:w,51:T,52:E,53:D,54:O,57:k},e(A,[2,5]),{9:39,10:12,11:13,12:14,13:15,16:c,17:l,19:u,22:d,24:f,25:p,26:m,27:h,28:g,29:_,32:25,33:v,35:y,37:b,38:x,41:S,45:C,48:w,51:T,52:E,53:D,54:O,57:k},e(A,[2,7]),e(A,[2,8]),e(A,[2,9]),e(A,[2,10]),e(A,[2,11]),e(A,[2,12],{14:[1,40],15:[1,41]}),e(A,[2,16]),{18:[1,42]},e(A,[2,18],{20:[1,43]}),{23:[1,44]},e(A,[2,22]),e(A,[2,23]),e(A,[2,24]),e(A,[2,25]),{30:45,31:[1,46],59:[1,47],60:[1,48]},e(A,[2,28]),{34:[1,49]},{36:[1,50]},e(A,[2,31]),{13:51,24:f,57:k},{42:[1,52],44:[1,53]},{46:[1,54]},{49:[1,55]},e(j,[2,44],{58:[1,56]}),e(j,[2,45],{58:[1,57]}),e(A,[2,38]),e(A,[2,39]),e(A,[2,40]),e(A,[2,41]),e(A,[2,6]),e(A,[2,13]),{13:58,24:f,57:k},e(A,[2,17]),e(M,a,{7:59}),{24:[1,60]},{24:[1,61]},{23:[1,62]},{24:[2,48]},{24:[2,49]},e(A,[2,29]),e(A,[2,30]),{39:[1,63],40:[1,64]},{43:[1,65]},{43:[1,66]},{47:[1,67]},{50:[1,68]},{24:[1,69]},{24:[1,70]},e(A,[2,14],{14:[1,71]}),{4:o,5:s,8:8,9:10,10:12,11:13,12:14,13:15,16:c,17:l,19:u,21:[1,72],22:d,24:f,25:p,26:m,27:h,28:g,29:_,32:25,33:v,35:y,37:b,38:x,41:S,45:C,48:w,51:T,52:E,53:D,54:O,57:k},e(A,[2,20],{20:[1,73]}),{31:[1,74]},{24:[1,75]},{39:[1,76]},{39:[1,77]},e(A,[2,34]),e(A,[2,35]),e(A,[2,36]),e(A,[2,37]),e(j,[2,46]),e(j,[2,47]),e(A,[2,15]),e(A,[2,19]),e(M,a,{7:78}),e(A,[2,26]),e(A,[2,27]),{5:[1,79]},{5:[1,80]},{4:o,5:s,8:8,9:10,10:12,11:13,12:14,13:15,16:c,17:l,19:u,21:[1,81],22:d,24:f,25:p,26:m,27:h,28:g,29:_,32:25,33:v,35:y,37:b,38:x,41:S,45:C,48:w,51:T,52:E,53:D,54:O,57:k},e(A,[2,32]),e(A,[2,33]),e(A,[2,21])],defaultActions:{5:[2,1],6:[2,2],47:[2,48],48:[2,49]},parseError:n(function(e,t){if(t.recoverable)this.trace(e);else{var n=Error(e);throw n.hash=t,n}},`parseError`),parse:n(function(e){var t=this,r=[0],i=[],a=[null],o=[],s=this.table,c=``,l=0,u=0,d=0,f=2,p=1,m=o.slice.call(arguments,1),h=Object.create(this.lexer),g={yy:{}};for(var _ in this.yy)Object.prototype.hasOwnProperty.call(this.yy,_)&&(g.yy[_]=this.yy[_]);h.setInput(e,g.yy),g.yy.lexer=h,g.yy.parser=this,h.yylloc===void 0&&(h.yylloc={});var v=h.yylloc;o.push(v);var y=h.options&&h.options.ranges;this.parseError=typeof g.yy.parseError==`function`?g.yy.parseError:Object.getPrototypeOf(this).parseError;function b(e){r.length-=2*e,a.length-=e,o.length-=e}n(b,`popStack`);function x(){var e=i.pop()||h.lex()||p;return typeof e!=`number`&&(e instanceof Array&&(i=e,e=i.pop()),e=t.symbols_[e]||e),e}n(x,`lex`);for(var S,C,w,T,E,D={},O,k,A,j;;){if(w=r[r.length-1],this.defaultActions[w]?T=this.defaultActions[w]:(S??=x(),T=s[w]&&s[w][S]),T===void 0||!T.length||!T[0]){var M=``;for(O in j=[],s[w])this.terminals_[O]&&O>f&&j.push(`'`+this.terminals_[O]+`'`);M=h.showPosition?`Parse error on line `+(l+1)+`:
|
|
2
|
+
`+h.showPosition()+`
|
|
3
|
+
Expecting `+j.join(`, `)+`, got '`+(this.terminals_[S]||S)+`'`:`Parse error on line `+(l+1)+`: Unexpected `+(S==p?`end of input`:`'`+(this.terminals_[S]||S)+`'`),this.parseError(M,{text:h.match,token:this.terminals_[S]||S,line:h.yylineno,loc:v,expected:j})}if(T[0]instanceof Array&&T.length>1)throw Error(`Parse Error: multiple actions possible at state: `+w+`, token: `+S);switch(T[0]){case 1:r.push(S),a.push(h.yytext),o.push(h.yylloc),r.push(T[1]),S=null,C?(S=C,C=null):(u=h.yyleng,c=h.yytext,l=h.yylineno,v=h.yylloc,d>0&&d--);break;case 2:if(k=this.productions_[T[1]][1],D.$=a[a.length-k],D._$={first_line:o[o.length-(k||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(k||1)].first_column,last_column:o[o.length-1].last_column},y&&(D._$.range=[o[o.length-(k||1)].range[0],o[o.length-1].range[1]]),E=this.performAction.apply(D,[c,u,l,g.yy,T[1],a,o].concat(m)),E!==void 0)return E;k&&(r=r.slice(0,-1*k*2),a=a.slice(0,-1*k),o=o.slice(0,-1*k)),r.push(this.productions_[T[1]][0]),a.push(D.$),o.push(D._$),A=s[r[r.length-2]][r[r.length-1]],r.push(A);break;case 3:return!0}}return!0},`parse`)};N.lexer=(function(){return{EOF:1,parseError:n(function(e,t){if(this.yy.parser)this.yy.parser.parseError(e,t);else throw Error(e)},`parseError`),setInput:n(function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match=``,this.conditionStack=[`INITIAL`],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},`setInput`),input:n(function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},`input`),unput:n(function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},`unput`),more:n(function(){return this._more=!0,this},`more`),reject:n(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError(`Lexical error on line `+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
|
+
`+this.showPosition(),{text:``,token:null,line:this.yylineno});return this},`reject`),less:n(function(e){this.unput(this.match.slice(e))},`less`),pastInput:n(function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?`...`:``)+e.substr(-20).replace(/\n/g,``)},`pastInput`),upcomingInput:n(function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?`...`:``)).replace(/\n/g,``)},`upcomingInput`),showPosition:n(function(){var e=this.pastInput(),t=Array(e.length+1).join(`-`);return e+this.upcomingInput()+`
|
|
5
|
+
`+t+`^`},`showPosition`),test_match:n(function(e,t){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),r=e[0].match(/(?:\r\n?|\n).*/g),r&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return!1}return!1},`test_match`),next:n(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var e,t,n,r;this._more||(this.yytext=``,this.match=``);for(var i=this._currentRules(),a=0;a<i.length;a++)if(n=this._input.match(this.rules[i[a]]),n&&(!t||n[0].length>t[0].length)){if(t=n,r=a,this.options.backtrack_lexer){if(e=this.test_match(n,i[a]),e!==!1)return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?(e=this.test_match(t,i[r]),e!==!1&&e):this._input===``?this.EOF:this.parseError(`Lexical error on line `+(this.yylineno+1)+`. Unrecognized text.
|
|
6
|
+
`+this.showPosition(),{text:``,token:null,line:this.yylineno})},`next`),lex:n(function(){return this.next()||this.lex()},`lex`),begin:n(function(e){this.conditionStack.push(e)},`begin`),popState:n(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},`popState`),_currentRules:n(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},`_currentRules`),topState:n(function(e){return e=this.conditionStack.length-1-Math.abs(e||0),e>=0?this.conditionStack[e]:`INITIAL`},`topState`),pushState:n(function(e){this.begin(e)},`pushState`),stateStackSize:n(function(){return this.conditionStack.length},`stateStackSize`),options:{"case-insensitive":!0},performAction:n(function(e,t,r,i){function a(){let n=t.yytext.indexOf(`%%`);if(n===0)return!1;if(n>0){let r=t.yytext.slice(0,n),i=t.yytext.slice(n);i&&e.lexer.unput(i),t.yytext=r}return!0}switch(n(a,`processId`),r){case 0:return 38;case 1:return 40;case 2:return 39;case 3:return 44;case 4:return 51;case 5:return 52;case 6:return 53;case 7:return 54;case 8:return 5;case 9:break;case 10:break;case 11:break;case 12:break;case 13:return this.pushState(`SCALE`),17;case 14:return 18;case 15:this.popState();break;case 16:return this.begin(`acc_title`),33;case 17:return this.popState(),`acc_title_value`;case 18:return this.begin(`acc_descr`),35;case 19:return this.popState(),`acc_descr_value`;case 20:this.begin(`acc_descr_multiline`);break;case 21:this.popState();break;case 22:return`acc_descr_multiline_value`;case 23:return this.pushState(`CLASSDEF`),41;case 24:return this.popState(),this.pushState(`CLASSDEFID`),`DEFAULT_CLASSDEF_ID`;case 25:return this.popState(),this.pushState(`CLASSDEFID`),42;case 26:return this.popState(),43;case 27:return this.pushState(`CLASS`),48;case 28:return this.popState(),this.pushState(`CLASS_STYLE`),49;case 29:return this.popState(),50;case 30:return this.pushState(`STYLE`),45;case 31:return this.popState(),this.pushState(`STYLEDEF_STYLES`),46;case 32:return this.popState(),47;case 33:return this.pushState(`SCALE`),17;case 34:return 18;case 35:this.popState();break;case 36:this.pushState(`STATE`);break;case 37:return this.popState(),t.yytext=t.yytext.slice(0,-8).trim(),25;case 38:return this.popState(),t.yytext=t.yytext.slice(0,-8).trim(),26;case 39:return this.popState(),t.yytext=t.yytext.slice(0,-10).trim(),27;case 40:return this.popState(),t.yytext=t.yytext.slice(0,-8).trim(),25;case 41:return this.popState(),t.yytext=t.yytext.slice(0,-8).trim(),26;case 42:return this.popState(),t.yytext=t.yytext.slice(0,-10).trim(),27;case 43:return 51;case 44:return 52;case 45:return 53;case 46:return 54;case 47:this.pushState(`STATE_STRING`);break;case 48:return this.pushState(`STATE_ID`),`AS`;case 49:return a()?(this.popState(),`ID`):void 0;case 50:this.popState();break;case 51:return`STATE_DESCR`;case 52:throw Error(`Error: State name must be a single word. Found: "`+t.yytext.trim()+`"`);case 53:return 19;case 54:this.popState();break;case 55:return this.popState(),this.pushState(`struct`),20;case 56:return this.popState(),21;case 57:break;case 58:return this.begin(`NOTE`),29;case 59:return this.popState(),this.pushState(`NOTE_ID`),59;case 60:return this.popState(),this.pushState(`NOTE_ID`),60;case 61:this.popState(),this.pushState(`FLOATING_NOTE`);break;case 62:return this.popState(),this.pushState(`FLOATING_NOTE_ID`),`AS`;case 63:break;case 64:return`NOTE_TEXT`;case 65:return a()?(this.popState(),`ID`):void 0;case 66:return a()?(this.popState(),this.pushState(`NOTE_TEXT`),24):void 0;case 67:return this.popState(),t.yytext=t.yytext.substr(2).trim(),31;case 68:return this.popState(),t.yytext=t.yytext.slice(0,-8).trim(),31;case 69:return 6;case 70:return 6;case 71:return 16;case 72:return 57;case 73:return a()?24:void 0;case 74:return t.yytext=t.yytext.trim(),14;case 75:return 15;case 76:return 28;case 77:return 58;case 78:return 5;case 79:return`INVALID`}},`anonymous`),rules:[/^(?:click\b)/i,/^(?:href\b)/i,/^(?:"[^"]*")/i,/^(?:default\b)/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:[\n]+)/i,/^(?:[\s]+)/i,/^(?:((?!\n)\s)+)/i,/^(?:#[^\n]*)/i,/^(?:%%(?!\{)[^\n]*)/i,/^(?:scale\s+)/i,/^(?:\d+)/i,/^(?:\s+width\b)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:classDef\s+)/i,/^(?:DEFAULT\s+)/i,/^(?:\w+\s+)/i,/^(?:[^\n]*)/i,/^(?:class\s+)/i,/^(?:(\w+)+((,\s*\w+)*))/i,/^(?:[^\n]*)/i,/^(?:style\s+)/i,/^(?:[\w,]+\s+)/i,/^(?:[^\n]*)/i,/^(?:scale\s+)/i,/^(?:\d+)/i,/^(?:\s+width\b)/i,/^(?:state\s+)/i,/^(?:.*<<fork>>)/i,/^(?:.*<<join>>)/i,/^(?:.*<<choice>>)/i,/^(?:.*\[\[fork\]\])/i,/^(?:.*\[\[join\]\])/i,/^(?:.*\[\[choice\]\])/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:["])/i,/^(?:\s*as\s+)/i,/^(?:[^\n\{]*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:\w+\s+\w+.*?\{)/i,/^(?:[^\n\s\{]+)/i,/^(?:\n)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:[\n])/i,/^(?:note\s+)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:")/i,/^(?:\s*as\s*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[^\n]*)/i,/^(?:\s*[^:\n\s\-]+)/i,/^(?:\s*:[^:\n;]+)/i,/^(?:[\s\S]*?\n\s*end note\b)/i,/^(?:stateDiagram\s+)/i,/^(?:stateDiagram-v2\s+)/i,/^(?:hide empty description\b)/i,/^(?:\[\*\])/i,/^(?:[^:\n\s\-\{]+)/i,/^(?:\s*:(?:[^:\n;]|:[^:\n;])+)/i,/^(?:-->)/i,/^(?:--)/i,/^(?::::)/i,/^(?:$)/i,/^(?:.)/i],conditions:{LINE:{rules:[10,11,12],inclusive:!1},struct:{rules:[10,11,12,23,27,30,36,43,44,45,46,56,57,58,72,73,74,75,76,77],inclusive:!1},FLOATING_NOTE_ID:{rules:[65],inclusive:!1},FLOATING_NOTE:{rules:[62,63,64],inclusive:!1},NOTE_TEXT:{rules:[67,68],inclusive:!1},NOTE_ID:{rules:[66],inclusive:!1},NOTE:{rules:[59,60,61],inclusive:!1},STYLEDEF_STYLEOPTS:{rules:[],inclusive:!1},STYLEDEF_STYLES:{rules:[32],inclusive:!1},STYLE_IDS:{rules:[],inclusive:!1},STYLE:{rules:[31],inclusive:!1},CLASS_STYLE:{rules:[29],inclusive:!1},CLASS:{rules:[28],inclusive:!1},CLASSDEFID:{rules:[26],inclusive:!1},CLASSDEF:{rules:[24,25],inclusive:!1},acc_descr_multiline:{rules:[21,22],inclusive:!1},acc_descr:{rules:[19],inclusive:!1},acc_title:{rules:[17],inclusive:!1},SCALE:{rules:[14,15,34,35],inclusive:!1},ALIAS:{rules:[],inclusive:!1},STATE_ID:{rules:[49],inclusive:!1},STATE_STRING:{rules:[50,51],inclusive:!1},FORK_STATE:{rules:[],inclusive:!1},STATE:{rules:[10,11,12,37,38,39,40,41,42,47,48,52,53,54,55],inclusive:!1},ID:{rules:[10,11,12],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,11,12,13,16,18,20,23,27,30,33,36,55,58,69,70,71,72,73,74,75,77,78,79],inclusive:!0}}}})();function P(){this.yy={}}return n(P,`Parser`),P.prototype=N,N.Parser=P,new P})();y.parser=y;var b=y,x=`TB`,S=`TB`,C=`dir`,w=`state`,T=`root`,E=`relation`,D=`classDef`,O=`style`,k=`applyClass`,A=`default`,j=`divider`,M=`fill:none`,N=`fill: #333`,P=`c`,ee=`markdown`,F=`normal`,I=`rect`,L=`rectWithTitle`,te=`stateStart`,ne=`stateEnd`,R=`divider`,re=`roundedWithTitle`,ie=`note`,ae=`noteGroup`,z=`statediagram`,oe=`${z}-state`,B=`transition`,se=`note`,ce=`${B} note-edge`,le=`${z}-${se}`,ue=`${z}-cluster`,de=`${z}-cluster-alt`,V=`parent`,H=`note`,fe=`state`,U=`----`,pe=`${U}${H}`,W=`${U}${V}`,G=n((e,t=S)=>{if(!e.doc)return t;let n=t;for(let t of e.doc)t.stmt===`dir`&&(n=t.value);return n},`getDir`),me={getClasses:n(function(e,t){return t.db.getClasses()},`getClasses`),draw:n(async function(e,t,n,r){m.info(`REF0:`),m.info(`Drawing state diagram (v2)`,t);let{securityLevel:i,state:a,layout:o}=f();r.db.extract(r.db.getRootDocV2());let s=r.db.getData(),c=g(t,i);s.type=r.type,s.layoutAlgorithm=o,s.nodeSpacing=a?.nodeSpacing||50,s.rankSpacing=a?.rankSpacing||50,s.markers=f().look===`neo`?[`barbNeo`]:[`barb`],s.diagramId=t,await h(s,c);try{(typeof r.db.getLinks==`function`?r.db.getLinks():new Map).forEach((e,t)=>{let n=typeof t==`string`?t:typeof t?.id==`string`?t.id:``,r=s.nodes.find(e=>e.id===n);if(!n){m.warn(`⚠️ Invalid or missing stateId from key:`,JSON.stringify(t));return}let i=c.node()?.querySelectorAll(`g.node, g.rough-node`),a;if(i?.forEach(e=>{let t=e.textContent?.trim();(e.id===r?.domId||t===n)&&(a=e)}),!a){m.warn(`⚠️ Could not find node matching text:`,n);return}let o=a.parentNode;if(!o){m.warn(`⚠️ Node has no parent, cannot wrap:`,n);return}let l=document.createElementNS(`http://www.w3.org/2000/svg`,`a`),u=e.url.replace(/^"+|"+$/g,``);if(l.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,u),l.setAttribute(`target`,`_blank`),e.tooltip){let t=e.tooltip.replace(/^"+|"+$/g,``);l.setAttribute(`title`,t),a.setAttribute(`title`,t)}o.replaceChild(l,a),l.appendChild(a),m.info(`🔗 Wrapped node in <a> tag for:`,n,e.url)})}catch(e){m.error(`❌ Error injecting clickable links:`,e)}l.insertTitle(c,`statediagramTitleText`,a?.titleTopMargin??25,r.db.getDiagramTitle()),_(c,8,z,a?.useMaxWidth??!0)},`draw`),getDir:G},K=new Map,q=0;function J(e=``,t=0,n=``,r=U){return`${fe}-${e}${n!==null&&n.length>0?`${r}${n}`:``}-${t}`}n(J,`stateDomId`);var he=n((e,t,n,r,i,a,s,c)=>{m.trace(`items`,t),t.forEach(t=>{switch(t.stmt){case w:Z(e,t,n,r,i,a,s,c);break;case A:Z(e,t,n,r,i,a,s,c);break;case E:{Z(e,t.state1,n,r,i,a,s,c),Z(e,t.state2,n,r,i,a,s,c);let l=s===`neo`,u={id:`edge`+q,start:t.state1.id,end:t.state2.id,arrowhead:`normal`,arrowTypeEnd:l?`arrow_barb_neo`:`arrow_barb`,style:M,labelStyle:``,label:o.sanitizeText(t.description??``,f()),arrowheadStyle:N,labelpos:P,labelType:ee,thickness:F,classes:B,look:s};i.push(u),q++}}})},`setupDoc`),ge=n((e,t=S)=>{let n=t;if(e.doc)for(let t of e.doc)t.stmt===`dir`&&(n=t.value);return n},`getDir`);function Y(e,t,n){if(!t.id||t.id===`</join></fork>`||t.id===`</choice>`)return;t.cssClasses&&(Array.isArray(t.cssCompiledStyles)||(t.cssCompiledStyles=[]),t.cssClasses.split(` `).forEach(e=>{let r=n.get(e);r&&(t.cssCompiledStyles=[...t.cssCompiledStyles??[],...r.styles])}));let r=e.find(e=>e.id===t.id);r?Object.assign(r,t):e.push(t)}n(Y,`insertOrUpdateNode`);function X(e){return e?.classes?.join(` `)??``}n(X,`getClassesFromDbInfo`);function _e(e){return e?.styles??[]}n(_e,`getStylesFromDbInfo`);var Z=n((e,t,n,r,i,a,s,c)=>{let l=t.id,u=n.get(l),d=X(u),p=_e(u),h=f();if(m.info(`dataFetcher parsedItem`,t,u,p),l!==`root`){let n=I;t.start===!0?n=te:t.start===!1&&(n=ne),t.type!==A&&(n=t.type),K.get(l)||K.set(l,{id:l,shape:n,description:o.sanitizeText(l,h),cssClasses:`${d} ${oe}`,cssStyles:p});let u=K.get(l);t.description&&(Array.isArray(u.description)?(u.shape=L,u.description.push(t.description)):u.description?.length&&u.description.length>0?(u.shape=L,u.description=u.description===l?[t.description]:[u.description,t.description]):(u.shape=I,u.description=t.description),u.description=o.sanitizeTextOrArray(u.description,h)),u.description?.length===1&&u.shape===L&&(u.shape=u.type===`group`?re:I),!u.type&&t.doc&&(m.info(`Setting cluster for XCX`,l,ge(t)),u.type=`group`,u.isGroup=!0,u.dir=ge(t),u.explicitDir=t.doc.some(e=>e.stmt===`dir`),u.shape=t.type===j?R:re,u.cssClasses=`${u.cssClasses} ${ue} ${a?de:``}`);let f={labelStyle:``,shape:u.shape,label:u.description,cssClasses:u.cssClasses,cssCompiledStyles:[],cssStyles:u.cssStyles,id:l,dir:u.dir,domId:J(l,q),type:u.type,isGroup:u.type===`group`,padding:8,rx:10,ry:10,look:s,labelType:`markdown`};if(f.shape===R&&(f.label=``),e&&e.id!==`root`&&(m.trace(`Setting node `,l,` to be child of its parent `,e.id),f.parentId=e.id),f.centerLabel=!0,t.note){let e={labelStyle:``,shape:ie,label:t.note.text,labelType:`markdown`,cssClasses:le,cssStyles:[],cssCompiledStyles:[],id:l+pe+`-`+q,domId:J(l,q,H),type:u.type,isGroup:u.type===`group`,padding:h.flowchart?.padding,look:s,position:t.note.position},n=l+W,a={labelStyle:``,shape:ae,label:t.note.text,cssClasses:u.cssClasses,cssStyles:[],id:l+W,domId:J(l,q,V),type:`group`,isGroup:!0,padding:16,look:s,position:t.note.position};q++,a.id=n,e.parentId=n,Y(r,a,c),Y(r,e,c),Y(r,f,c);let o=l,d=e.id;t.note.position===`left of`&&(o=e.id,d=l),i.push({id:o+`-`+d,start:o,end:d,arrowhead:`none`,arrowTypeEnd:``,style:M,labelStyle:``,classes:ce,arrowheadStyle:N,labelpos:P,labelType:ee,thickness:F,look:s})}else Y(r,f,c)}t.doc&&(m.trace(`Adding nodes children `),he(t,t.doc,n,r,i,!a,s,c))},`dataFetcher`),ve=n(()=>{K.clear(),q=0},`reset`),Q={START_NODE:`[*]`,START_TYPE:`start`,END_NODE:`[*]`,END_TYPE:`end`,COLOR_KEYWORD:`color`,FILL_KEYWORD:`fill`,BG_FILL:`bgFill`,STYLECLASS_SEP:`,`},ye=n(()=>new Map,`newClassesList`),be=n(()=>({relations:[],states:new Map,documents:{}}),`newDoc`),$=n(e=>JSON.parse(JSON.stringify(e)),`clone`),xe=class{constructor(t){this.version=t,this.nodes=[],this.edges=[],this.rootDoc=[],this.classes=ye(),this.documents={root:be()},this.currentDocument=this.documents.root,this.startEndCount=0,this.dividerCnt=0,this.links=new Map,this.funs=[],this.getAccTitle=c,this.setAccTitle=e,this.getAccDescription=u,this.setAccDescription=i,this.setDiagramTitle=r,this.getDiagramTitle=p,this.clear(),this.setRootDoc=this.setRootDoc.bind(this),this.getDividerId=this.getDividerId.bind(this),this.setDirection=this.setDirection.bind(this),this.trimColon=this.trimColon.bind(this),this.bindFunctions=this.bindFunctions.bind(this)}static{n(this,`StateDB`)}static{this.relationType={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3}}extract(e){this.clear(!0);for(let t of Array.isArray(e)?e:e.doc)switch(t.stmt){case w:this.addState(t.id.trim(),t.type,t.doc,t.description,t.note);break;case E:this.addRelation(t.state1,t.state2,t.description);break;case D:this.addStyleClass(t.id.trim(),t.classes);break;case O:this.handleStyleDef(t);break;case k:this.setCssClass(t.id.trim(),t.styleClass);break;case`click`:this.addLink(t.id,t.url,t.tooltip)}let t=this.getStates(),n=f();ve(),Z(void 0,this.getRootDocV2(),t,this.nodes,this.edges,!0,n.look,this.classes);for(let e of this.nodes)if(Array.isArray(e.label)){if(e.description=e.label.slice(1),e.isGroup&&e.description.length>0)throw Error(`Group nodes can only have label. Remove the additional description for node [${e.id}]`);e.label=e.label[0]}}handleStyleDef(e){let t=e.id.trim().split(`,`),n=e.styleClass.split(`,`);for(let e of t){let t=this.getState(e);if(!t){let n=e.trim();this.addState(n),t=this.getState(n)}t&&(t.styles=n.map(e=>e.replace(/;/g,``)?.trim()))}}setRootDoc(e){m.info(`Setting root doc`,e),this.rootDoc=e,this.version===1?this.extract(e):this.extract(this.getRootDocV2())}docTranslator(e,t,n){if(t.stmt===E){this.docTranslator(e,t.state1,!0),this.docTranslator(e,t.state2,!1);return}if(t.stmt===w&&(t.id===Q.START_NODE?(t.id=e.id+(n?`_start`:`_end`),t.start=n):t.id=t.id.trim()),t.stmt!==T&&t.stmt!==w||!t.doc)return;let r=[],i=[];for(let e of t.doc)if(e.type===j){let t=$(e);t.doc=$(i),r.push(t),i=[]}else i.push(e);if(r.length>0&&i.length>0){let e={stmt:w,id:s(),type:`divider`,doc:$(i)};r.push($(e)),t.doc=r}t.doc.forEach(e=>this.docTranslator(t,e,!0))}getRootDocV2(){return this.docTranslator({id:T,stmt:T},{id:T,stmt:T,doc:this.rootDoc},!0),{id:T,doc:this.rootDoc}}addState(e,t=A,n=void 0,r=void 0,i=void 0,a=void 0,s=void 0,c=void 0){let l=e?.trim();if(!this.currentDocument.states.has(l))m.info(`Adding state `,l,r),this.currentDocument.states.set(l,{stmt:w,id:l,descriptions:[],type:t,doc:n,note:i,classes:[],styles:[],textStyles:[]});else{let e=this.currentDocument.states.get(l);if(!e)throw Error(`State not found: ${l}`);e.doc||=n,e.type||=t}if(r&&(m.info(`Setting state description`,l,r),(Array.isArray(r)?r:[r]).forEach(e=>this.addDescription(l,e.trim()))),i){let e=this.currentDocument.states.get(l);if(!e)throw Error(`State not found: ${l}`);e.note=i,e.note.text=o.sanitizeText(e.note.text,f())}a&&(m.info(`Setting state classes`,l,a),(Array.isArray(a)?a:[a]).forEach(e=>this.setCssClass(l,e.trim()))),s&&(m.info(`Setting state styles`,l,s),(Array.isArray(s)?s:[s]).forEach(e=>this.setStyle(l,e.trim()))),c&&(m.info(`Setting state styles`,l,s),(Array.isArray(c)?c:[c]).forEach(e=>this.setTextStyle(l,e.trim())))}clear(e){this.nodes=[],this.edges=[],this.funs=[this.setupToolTips.bind(this)],this.documents={root:be()},this.currentDocument=this.documents.root,this.startEndCount=0,this.classes=ye(),e||(this.links=new Map,d())}getState(e){return this.currentDocument.states.get(e)}getStates(){return this.currentDocument.states}logDocuments(){m.info(`Documents = `,this.documents)}getRelations(){return this.currentDocument.relations}addLink(e,t,n){this.links.set(e,{url:t,tooltip:n}),m.warn(`Adding link`,e,t,n)}getLinks(){return this.links}startIdIfNeeded(e=``){return e===Q.START_NODE?(this.startEndCount++,`${Q.START_TYPE}${this.startEndCount}`):e}startTypeIfNeeded(e=``,t=A){return e===Q.START_NODE?Q.START_TYPE:t}endIdIfNeeded(e=``){return e===Q.END_NODE?(this.startEndCount++,`${Q.END_TYPE}${this.startEndCount}`):e}endTypeIfNeeded(e=``,t=A){return e===Q.END_NODE?Q.END_TYPE:t}addRelationObjs(e,t,n=``){let r=this.startIdIfNeeded(e.id.trim()),i=this.startTypeIfNeeded(e.id.trim(),e.type),a=this.startIdIfNeeded(t.id.trim()),s=this.startTypeIfNeeded(t.id.trim(),t.type);this.addState(r,i,e.doc,e.description,e.note,e.classes,e.styles,e.textStyles),this.addState(a,s,t.doc,t.description,t.note,t.classes,t.styles,t.textStyles),this.currentDocument.relations.push({id1:r,id2:a,relationTitle:o.sanitizeText(n,f())})}addRelation(e,t,n){if(typeof e==`object`&&typeof t==`object`)this.addRelationObjs(e,t,n);else if(typeof e==`string`&&typeof t==`string`){let r=this.startIdIfNeeded(e.trim()),i=this.startTypeIfNeeded(e),a=this.endIdIfNeeded(t.trim()),s=this.endTypeIfNeeded(t);this.addState(r,i),this.addState(a,s),this.currentDocument.relations.push({id1:r,id2:a,relationTitle:n?o.sanitizeText(n,f()):void 0})}}addDescription(e,t){let n=this.currentDocument.states.get(e),r=t.startsWith(`:`)?t.replace(`:`,``).trim():t;n?.descriptions?.push(o.sanitizeText(r,f()))}cleanupLabel(e){return e.startsWith(`:`)?e.slice(2).trim():e.trim()}getDividerId(){return this.dividerCnt++,`divider-id-${this.dividerCnt}`}addStyleClass(e,t=``){this.classes.has(e)||this.classes.set(e,{id:e,styles:[],textStyles:[]});let n=this.classes.get(e);t&&n&&t.split(Q.STYLECLASS_SEP).forEach(e=>{let t=e.replace(/([^;]*);/,`$1`).trim();if(RegExp(Q.COLOR_KEYWORD).exec(e)){let e=t.replace(Q.FILL_KEYWORD,Q.BG_FILL).replace(Q.COLOR_KEYWORD,Q.FILL_KEYWORD);n.textStyles.push(e)}n.styles.push(t)})}getClasses(){return this.classes}setupToolTips(e){let n=v();a(e).select(`svg`).selectAll(`g.node, g.rough-node`).on(`mouseover`,e=>{let r=a(e.currentTarget),i=r.attr(`title`);if(i===null)return;let o=e.currentTarget?.getBoundingClientRect();n.transition().duration(200).style(`opacity`,`.9`),n.style(`left`,window.scrollX+o.left+(o.right-o.left)/2+`px`).style(`top`,window.scrollY+o.bottom+`px`),n.html(t.sanitize(i)),r.classed(`hover`,!0)}).on(`mouseout`,e=>{n.transition().duration(500).style(`opacity`,0),a(e.currentTarget).classed(`hover`,!1)})}setCssClass(e,t){e.split(`,`).forEach(e=>{let n=this.getState(e);if(!n){let t=e.trim();this.addState(t),n=this.getState(t)}n?.classes?.push(t)})}setStyle(e,t){this.getState(e)?.styles?.push(t)}setTextStyle(e,t){this.getState(e)?.textStyles?.push(t)}bindFunctions(e){this.funs.forEach(t=>{t(e)})}getDirectionStatement(){return this.rootDoc.find(e=>e.stmt===C)}getDirection(){return this.getDirectionStatement()?.value??x}setDirection(e){let t=this.getDirectionStatement();t?t.value=e:this.rootDoc.unshift({stmt:C,value:e})}trimColon(e){return e.startsWith(`:`)?e.slice(1).trim():e.trim()}getData(){let e=f();return{nodes:this.nodes,edges:this.edges,other:{},config:e,direction:G(this.getRootDocV2())}}getConfig(){return f().state}},Se=n(e=>`
|
|
7
|
+
defs [id$="-barbEnd"] {
|
|
8
|
+
fill: ${e.transitionColor};
|
|
9
|
+
stroke: ${e.transitionColor};
|
|
10
|
+
}
|
|
11
|
+
g.stateGroup text {
|
|
12
|
+
fill: ${e.nodeBorder};
|
|
13
|
+
stroke: none;
|
|
14
|
+
font-size: 10px;
|
|
15
|
+
}
|
|
16
|
+
g.stateGroup text {
|
|
17
|
+
fill: ${e.textColor};
|
|
18
|
+
stroke: none;
|
|
19
|
+
font-size: 10px;
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
g.stateGroup .state-title {
|
|
23
|
+
font-weight: bolder;
|
|
24
|
+
fill: ${e.stateLabelColor};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
g.stateGroup rect {
|
|
28
|
+
fill: ${e.mainBkg};
|
|
29
|
+
stroke: ${e.nodeBorder};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
g.stateGroup line {
|
|
33
|
+
stroke: ${e.lineColor};
|
|
34
|
+
stroke-width: ${e.strokeWidth||1};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.transition {
|
|
38
|
+
stroke: ${e.transitionColor};
|
|
39
|
+
stroke-width: ${e.strokeWidth||1};
|
|
40
|
+
fill: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.stateGroup .composit {
|
|
44
|
+
fill: ${e.background};
|
|
45
|
+
border-bottom: 1px
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.stateGroup .alt-composit {
|
|
49
|
+
fill: #e0e0e0;
|
|
50
|
+
border-bottom: 1px
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.state-note {
|
|
54
|
+
stroke: ${e.noteBorderColor};
|
|
55
|
+
fill: ${e.noteBkgColor};
|
|
56
|
+
|
|
57
|
+
text {
|
|
58
|
+
fill: ${e.noteTextColor};
|
|
59
|
+
stroke: none;
|
|
60
|
+
font-size: 10px;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.stateLabel .box {
|
|
65
|
+
stroke: none;
|
|
66
|
+
stroke-width: 0;
|
|
67
|
+
fill: ${e.mainBkg};
|
|
68
|
+
opacity: 0.5;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.edgeLabel .label rect {
|
|
72
|
+
fill: ${e.labelBackgroundColor};
|
|
73
|
+
opacity: 0.5;
|
|
74
|
+
}
|
|
75
|
+
.edgeLabel {
|
|
76
|
+
background-color: ${e.edgeLabelBackground};
|
|
77
|
+
p {
|
|
78
|
+
background-color: ${e.edgeLabelBackground};
|
|
79
|
+
}
|
|
80
|
+
rect {
|
|
81
|
+
opacity: 0.5;
|
|
82
|
+
background-color: ${e.edgeLabelBackground};
|
|
83
|
+
fill: ${e.edgeLabelBackground};
|
|
84
|
+
}
|
|
85
|
+
text-align: center;
|
|
86
|
+
}
|
|
87
|
+
.edgeLabel .label text {
|
|
88
|
+
fill: ${e.transitionLabelColor||e.tertiaryTextColor};
|
|
89
|
+
}
|
|
90
|
+
.label div .edgeLabel {
|
|
91
|
+
color: ${e.transitionLabelColor||e.tertiaryTextColor};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.stateLabel text {
|
|
95
|
+
fill: ${e.stateLabelColor};
|
|
96
|
+
font-size: 10px;
|
|
97
|
+
font-weight: bold;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.node circle.state-start {
|
|
101
|
+
fill: ${e.specialStateColor};
|
|
102
|
+
stroke: ${e.specialStateColor};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.node .fork-join {
|
|
106
|
+
fill: ${e.specialStateColor};
|
|
107
|
+
stroke: ${e.specialStateColor};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.node circle.state-end {
|
|
111
|
+
fill: ${e.innerEndBackground};
|
|
112
|
+
stroke: ${e.background};
|
|
113
|
+
stroke-width: 1.5
|
|
114
|
+
}
|
|
115
|
+
.end-state-inner {
|
|
116
|
+
fill: ${e.compositeBackground||e.background};
|
|
117
|
+
// stroke: ${e.background};
|
|
118
|
+
stroke-width: 1.5
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.node rect {
|
|
122
|
+
fill: ${e.stateBkg||e.mainBkg};
|
|
123
|
+
stroke: ${e.stateBorder||e.nodeBorder};
|
|
124
|
+
stroke-width: ${e.strokeWidth||1}px;
|
|
125
|
+
}
|
|
126
|
+
.node polygon {
|
|
127
|
+
fill: ${e.mainBkg};
|
|
128
|
+
stroke: ${e.stateBorder||e.nodeBorder};;
|
|
129
|
+
stroke-width: ${e.strokeWidth||1}px;
|
|
130
|
+
}
|
|
131
|
+
[id$="-barbEnd"] {
|
|
132
|
+
fill: ${e.lineColor};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.statediagram-cluster rect {
|
|
136
|
+
fill: ${e.compositeTitleBackground};
|
|
137
|
+
stroke: ${e.stateBorder||e.nodeBorder};
|
|
138
|
+
stroke-width: ${e.strokeWidth||1}px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.cluster-label, .nodeLabel {
|
|
142
|
+
color: ${e.stateLabelColor};
|
|
143
|
+
// line-height: 1;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.statediagram-cluster rect.outer {
|
|
147
|
+
rx: 5px;
|
|
148
|
+
ry: 5px;
|
|
149
|
+
}
|
|
150
|
+
.statediagram-state .divider {
|
|
151
|
+
stroke: ${e.stateBorder||e.nodeBorder};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.statediagram-state .title-state {
|
|
155
|
+
rx: 5px;
|
|
156
|
+
ry: 5px;
|
|
157
|
+
}
|
|
158
|
+
.statediagram-cluster.statediagram-cluster .inner {
|
|
159
|
+
fill: ${e.compositeBackground||e.background};
|
|
160
|
+
}
|
|
161
|
+
.statediagram-cluster.statediagram-cluster-alt .inner {
|
|
162
|
+
fill: ${e.altBackground?e.altBackground:`#efefef`};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.statediagram-cluster .inner {
|
|
166
|
+
rx:0;
|
|
167
|
+
ry:0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.statediagram-state rect.basic {
|
|
171
|
+
rx: 5px;
|
|
172
|
+
ry: 5px;
|
|
173
|
+
}
|
|
174
|
+
.statediagram-state rect.divider {
|
|
175
|
+
stroke-dasharray: 10,10;
|
|
176
|
+
fill: ${e.altBackground?e.altBackground:`#efefef`};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.note-edge {
|
|
180
|
+
stroke-dasharray: 5;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.statediagram-note rect {
|
|
184
|
+
fill: ${e.noteBkgColor};
|
|
185
|
+
stroke: ${e.noteBorderColor};
|
|
186
|
+
stroke-width: 1px;
|
|
187
|
+
rx: 0;
|
|
188
|
+
ry: 0;
|
|
189
|
+
}
|
|
190
|
+
.statediagram-note rect {
|
|
191
|
+
fill: ${e.noteBkgColor};
|
|
192
|
+
stroke: ${e.noteBorderColor};
|
|
193
|
+
stroke-width: 1px;
|
|
194
|
+
rx: 0;
|
|
195
|
+
ry: 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.statediagram-note text {
|
|
199
|
+
fill: ${e.noteTextColor};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.statediagram-note .nodeLabel {
|
|
203
|
+
color: ${e.noteTextColor};
|
|
204
|
+
}
|
|
205
|
+
.statediagram .edgeLabel {
|
|
206
|
+
color: red; // ${e.noteTextColor};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
[id$="-dependencyStart"], [id$="-dependencyEnd"] {
|
|
210
|
+
fill: ${e.lineColor};
|
|
211
|
+
stroke: ${e.lineColor};
|
|
212
|
+
stroke-width: ${e.strokeWidth||1};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.statediagramTitleText {
|
|
216
|
+
text-anchor: middle;
|
|
217
|
+
font-size: 18px;
|
|
218
|
+
fill: ${e.textColor};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
[data-look="neo"].statediagram-cluster rect {
|
|
222
|
+
fill: ${e.mainBkg};
|
|
223
|
+
stroke: ${e.useGradient?`url(`+e.svgId+`-gradient)`:e.stateBorder||e.nodeBorder};
|
|
224
|
+
stroke-width: ${e.strokeWidth??1};
|
|
225
|
+
}
|
|
226
|
+
[data-look="neo"].statediagram-cluster rect.outer {
|
|
227
|
+
rx: ${e.radius}px;
|
|
228
|
+
ry: ${e.radius}px;
|
|
229
|
+
filter: ${e.dropShadow?e.dropShadow.replace(`url(#drop-shadow)`,`url(${e.svgId}-drop-shadow)`):`none`}
|
|
230
|
+
}
|
|
231
|
+
`,`getStyles`);export{Se as i,b as n,me as r,xe as t};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{Ht as e}from"./chunk-NSK5VX7P-CBCyTZMs.js";var t=e(()=>`
|
|
2
|
+
/* Font Awesome icon styling - consolidated */
|
|
3
|
+
.label-icon {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
height: 1em;
|
|
6
|
+
overflow: visible;
|
|
7
|
+
vertical-align: -0.125em;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.node .label-icon path {
|
|
11
|
+
fill: currentColor;
|
|
12
|
+
stroke: revert;
|
|
13
|
+
stroke-width: revert;
|
|
14
|
+
}
|
|
15
|
+
`,`getIconStyles`);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ht as e,U as t,X as n,zt as r}from"./chunk-NSK5VX7P-CBCyTZMs.js";var i=e((e,n)=>{let r;return n===`sandbox`&&(r=t(`#i`+e)),t(n===`sandbox`?r.nodes()[0].contentDocument.body:`body`).select(`[id="${e}"]`)},`getDiagramElement`),a=e((e,t,i,a)=>{e.attr(`class`,i);let{width:c,height:l,x:u,y:d}=o(e,t);n(e,l,c,a);let f=s(u,d,c,l,t);e.attr(`viewBox`,f),r.debug(`viewBox configured: ${f} with padding: ${t}`)},`setupViewPortForSVG`),o=e((e,t)=>{let n=e.node()?.getBBox()||{width:0,height:0,x:0,y:0};return{width:n.width+t*2,height:n.height+t*2,x:n.x,y:n.y}},`calculateDimensionsWithPadding`),s=e((e,t,n,r,i)=>`${e-i} ${t-i} ${n} ${r}`,`createViewBox`);export{i as n,a as t};
|