archidocs 1.3.3 → 1.4.0-beta.2
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/cli/dev.js +4 -1
- package/dist/core/load.js +7 -1
- package/dist/core/rules.js +2 -2
- package/dist/core/views/deployment.d.ts +4 -0
- package/dist/core/views/deployment.js +15 -1
- package/dist/core/views/generated.d.ts +3 -1
- package/dist/core/views/generated.js +9 -2
- package/dist/core/views/index.d.ts +1 -0
- package/dist/core/views/index.js +1 -0
- package/dist/core/views/resolve.js +3 -3
- package/dist/core/views/save-as-view.d.ts +8 -3
- package/dist/core/views/save-as-view.js +16 -6
- package/dist/core/views/types.d.ts +9 -1
- package/dist/mcp/server.js +8 -4
- package/dist/mcp/writes.js +4 -1
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.js +1 -1
- package/dist/render/layout.d.ts +3 -1
- package/dist/render/layout.js +6 -1
- package/dist/render/sequence.d.ts +6 -3
- package/dist/render/sequence.js +7 -4
- package/dist/render/svg.d.ts +3 -1
- package/dist/render/svg.js +48 -10
- package/dist/render/tokens.d.ts +8 -0
- package/dist/render/tokens.js +12 -0
- package/dist/schema/bundle.d.ts +8 -0
- package/dist/schema/bundle.js +2 -0
- package/dist/schema/workspace.d.ts +17 -0
- package/dist/schema/workspace.js +19 -1
- package/dist/viewer/assets/font-BEgf3E5J.js +1 -0
- package/dist/viewer/assets/index-CzXU8F_3.css +1 -0
- package/dist/viewer/assets/index-DmVLe9LK.js +75 -0
- package/dist/viewer/assets/layout.worker-ueOYAv7N.js +63 -0
- package/dist/viewer/assets/png-D-pNKY71.js +1 -0
- package/dist/viewer/assets/rolldown-runtime-pP25SEvz.js +1 -0
- package/dist/viewer/assets/sequence-svg-BtEmwvN4.js +2 -0
- package/dist/viewer/assets/svg-DXIkkkSu.js +2 -0
- package/dist/viewer/assets/teams-N-WbqOXA.js +66 -0
- package/dist/viewer/index.html +5 -2
- package/guide/topics/deployments.md +17 -3
- package/package.json +1 -1
- package/schemas/model.schema.json +35 -1
- package/dist/viewer/assets/index-BhiW2o_9.js +0 -138
- package/dist/viewer/assets/index-YFA-pYjQ.css +0 -1
- package/dist/viewer/assets/layout.worker-BRHAGJrD.js +0 -26
- package/dist/viewer/assets/png-CJovcggr.js +0 -1
- package/dist/viewer/assets/svg-Cg6M1xWg.js +0 -2
package/dist/cli/dev.js
CHANGED
|
@@ -166,7 +166,10 @@ export async function serveDev({ checkout, viewerDir, host = "127.0.0.1", port =
|
|
|
166
166
|
watcher.close();
|
|
167
167
|
for (const res of clients)
|
|
168
168
|
res.end();
|
|
169
|
-
|
|
169
|
+
const closed = new Promise((done) => server.close(() => done()));
|
|
170
|
+
// A browser holds idle keep-alive sockets open; without this, close waits on them.
|
|
171
|
+
server.closeAllConnections();
|
|
172
|
+
await closed;
|
|
170
173
|
},
|
|
171
174
|
};
|
|
172
175
|
}
|
package/dist/core/load.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { basename, dirname, join, relative, sep } from "node:path";
|
|
2
2
|
import { Bundle, SCHEMA_VERSION } from "../schema/bundle.js";
|
|
3
|
-
import { DynamicView, ProjectFile, StructuralView, WorkspaceFile, childKindOf, collectionOf, kindOfCollection, lensSchemaFor, selectorSchemaFor, shallow, workspaceOnlyKeys } from "../schema/workspace.js";
|
|
3
|
+
import { DynamicView, Instances, ProjectFile, StructuralView, WorkspaceFile, childKindOf, collectionOf, kindOfCollection, lensSchemaFor, selectorSchemaFor, shallow, workspaceOnlyKeys } from "../schema/workspace.js";
|
|
4
4
|
import { indexByQualifiedId, qualified, qualify, referenceResolver } from "./refs.js";
|
|
5
5
|
import { rules } from "./rules.js";
|
|
6
6
|
import { checkSchema } from "./schema-check.js";
|
|
@@ -376,6 +376,7 @@ function toBundle(ws, options) {
|
|
|
376
376
|
target: qualify(d.data.target, d.project) ?? String(d.data.target ?? ""),
|
|
377
377
|
url: str(d.data.url),
|
|
378
378
|
endpoints: Array.isArray(d.data.endpoints) ? d.data.endpoints.map(asRecord).map((e) => ({ name: String(e.name ?? ""), url: String(e.url ?? "") })) : [],
|
|
379
|
+
instances: instancesOf(d.data.instances),
|
|
379
380
|
owner: d.service ? ownerOf(d.service) : (d.project.owner ?? ""),
|
|
380
381
|
source: source(d),
|
|
381
382
|
}));
|
|
@@ -462,3 +463,8 @@ function toBundle(ws, options) {
|
|
|
462
463
|
}
|
|
463
464
|
const asRecord = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
464
465
|
const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
466
|
+
/** A Deployment's `instances` as the Bundle carries it: 1 when absent or invalid (Load has already reported an invalid one). */
|
|
467
|
+
function instancesOf(value) {
|
|
468
|
+
const parsed = Instances.safeParse(value);
|
|
469
|
+
return parsed.success ? parsed.data : 1;
|
|
470
|
+
}
|
package/dist/core/rules.js
CHANGED
|
@@ -756,11 +756,11 @@ export const rules = [
|
|
|
756
756
|
since: "1.0.0",
|
|
757
757
|
summary: `A View has more than ${MAX_VIEW_NODES} nodes, too many for a readable diagram. A Generated View is reported at its System or Service, or at \`workspace.yaml\` for the Landscapes; a Saved View at its id.`,
|
|
758
758
|
why: `A View is a diagram for people to read. With more than ${MAX_VIEW_NODES} nodes the boxes and lines are too many to follow, so the View answers no question at a glance.`,
|
|
759
|
-
fix: "Split the System, or group top-level Services and Systems, so each Generated View stays within the limit; narrow a Saved View's selectors or raise its `level`.",
|
|
759
|
+
fix: "Split the System, or group top-level Services and Systems, so each Generated View stays within the limit; narrow a Saved View's selectors or raise its `level`. The C2 Landscape opens every System, so it stays within the limit only while the Workspace's Systems, Services and Persons do.",
|
|
760
760
|
related: ["empty-view"],
|
|
761
761
|
example: {
|
|
762
762
|
failing: withServices(`systems:\n big:\n name: Big\n services:\n${numbered(MAX_VIEW_NODES, "s", 6)}`),
|
|
763
|
-
passing: withServices(`systems:\n big:\n name: Big\n services:\n${numbered(MAX_VIEW_NODES / 2, "s", 6)} more:\n name: More\n services:\n${numbered(MAX_VIEW_NODES / 2, "s", 6, MAX_VIEW_NODES / 2)}`),
|
|
763
|
+
passing: withServices(`systems:\n big:\n name: Big\n services:\n${numbered(MAX_VIEW_NODES / 2 - 1, "s", 6)} more:\n name: More\n services:\n${numbered(MAX_VIEW_NODES / 2 - 1, "s", 6, MAX_VIEW_NODES / 2)}`),
|
|
764
764
|
},
|
|
765
765
|
check: (ws, bundle) => {
|
|
766
766
|
const workspaceFile = ws.files.find((f) => f.role === "workspace");
|
|
@@ -8,6 +8,10 @@ export interface DeploymentScope {
|
|
|
8
8
|
/** A Service this rejects is left out, with its Relationships. */
|
|
9
9
|
keep?: (service: string) => boolean;
|
|
10
10
|
}
|
|
11
|
+
/** True when a Deployment runs, or may run, more than one instance. */
|
|
12
|
+
export declare const isScaled: (instances: BundleDeployment["instances"]) => boolean;
|
|
13
|
+
/** A scaled Deployment's chip text: `×3` for a fixed count, `2–10` for an autoscale range. */
|
|
14
|
+
export declare const instancesChip: (instances: BundleDeployment["instances"]) => string;
|
|
11
15
|
/**
|
|
12
16
|
* Resolves the Deployment View of one Environment:
|
|
13
17
|
* - every Target holding a drawn Deployment is a container, nested in its parent Targets;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { cmp, lifter } from "../query.js";
|
|
2
|
+
/** True when a Deployment runs, or may run, more than one instance. */
|
|
3
|
+
export const isScaled = (instances) => (typeof instances === "number" ? instances > 1 : instances.max > 1);
|
|
4
|
+
/** A scaled Deployment's chip text: `×3` for a fixed count, `2–10` for an autoscale range. */
|
|
5
|
+
export const instancesChip = (instances) => (typeof instances === "number" ? `×${instances}` : `${instances.min}–${instances.max}`);
|
|
2
6
|
/** A Deployment's node id: its Service and Target, as `<service>@<target>`. */
|
|
3
7
|
const deploymentNodeId = (d) => `${d.service}@${d.target}`;
|
|
4
8
|
/**
|
|
@@ -36,7 +40,17 @@ export function resolveDeployment(bundle, model, head, environment, scope = {})
|
|
|
36
40
|
nodes.set(parent, { id: parent, kind: "system", name: s.name, parent: d.target, element: system, collapsed: false, external: "external" in s && s.external });
|
|
37
41
|
}
|
|
38
42
|
const service = model.byId.get(d.service);
|
|
39
|
-
nodes.set(deploymentNodeId(d), {
|
|
43
|
+
nodes.set(deploymentNodeId(d), {
|
|
44
|
+
id: deploymentNodeId(d),
|
|
45
|
+
kind: "deployment",
|
|
46
|
+
name: service.name,
|
|
47
|
+
parent,
|
|
48
|
+
element: d.service,
|
|
49
|
+
target: d.target,
|
|
50
|
+
...(isScaled(d.instances) ? { instances: d.instances } : {}),
|
|
51
|
+
collapsed: false,
|
|
52
|
+
external: "external" in service && service.external,
|
|
53
|
+
});
|
|
40
54
|
byService.set(d.service, [...(byService.get(d.service) ?? []), { d, chain }]);
|
|
41
55
|
}
|
|
42
56
|
const lift = lifter(bundle, "service");
|
|
@@ -5,8 +5,10 @@ import type { ResolvedView, ViewKind, ViewSummary } from "./types.ts";
|
|
|
5
5
|
* Resolves a Generated View by id: `c1`, `c2`, `c2/<system>`, `c3/<service>`
|
|
6
6
|
* (only for a Service with Components) or `deployment/<env>`. Undefined for
|
|
7
7
|
* any other id, and for one naming an Element or Environment that isn't there.
|
|
8
|
+
* The C2 Landscape opens every System but those in `collapse`; `collapse`
|
|
9
|
+
* applies to no other View.
|
|
8
10
|
*/
|
|
9
|
-
export declare function resolveGenerated(bundle: Bundle, model: ModelIndex, id: string, expand: readonly string[]): ResolvedView | undefined;
|
|
11
|
+
export declare function resolveGenerated(bundle: Bundle, model: ModelIndex, id: string, expand: readonly string[], collapse?: readonly string[]): ResolvedView | undefined;
|
|
10
12
|
/**
|
|
11
13
|
* Every Generated View's id, in the order `c1`, `c2`, then `c2/<system>` and
|
|
12
14
|
* `c3/<service>` by id, then `deployment/<env>` by Environment id.
|
|
@@ -5,13 +5,15 @@ import { build } from "./model.js";
|
|
|
5
5
|
* Resolves a Generated View by id: `c1`, `c2`, `c2/<system>`, `c3/<service>`
|
|
6
6
|
* (only for a Service with Components) or `deployment/<env>`. Undefined for
|
|
7
7
|
* any other id, and for one naming an Element or Environment that isn't there.
|
|
8
|
+
* The C2 Landscape opens every System but those in `collapse`; `collapse`
|
|
9
|
+
* applies to no other View.
|
|
8
10
|
*/
|
|
9
|
-
export function resolveGenerated(bundle, model, id, expand) {
|
|
11
|
+
export function resolveGenerated(bundle, model, id, expand, collapse = []) {
|
|
10
12
|
const ref = parseViewId(id);
|
|
11
13
|
if (ref === undefined || ref.form === "saved")
|
|
12
14
|
return undefined;
|
|
13
15
|
if (ref.form === "landscape")
|
|
14
|
-
return
|
|
16
|
+
return ref.level === "c1" ? landscape(model, "c1", "C1 Landscape", []) : landscape(model, "c2", "C2 Landscape", [...systemsOpen(model, collapse), ...expand]);
|
|
15
17
|
if (ref.form === "deployment") {
|
|
16
18
|
const env = bundle.environments.find((e) => e.id === ref.environment);
|
|
17
19
|
return env ? resolveDeployment(bundle, model, { id, title: `${env.name} (Deployment)` }, env.id) : undefined;
|
|
@@ -46,6 +48,11 @@ export function summarise(id, bundle) {
|
|
|
46
48
|
throw new Error(`"${id}" is not a Generated View id`);
|
|
47
49
|
return { id, kind: ref.level, title: `${bundle.elements.find((e) => e.id === ref.element).name} (${ref.level.toUpperCase()})` };
|
|
48
50
|
}
|
|
51
|
+
/** Every System not in `collapse`: the boxes the C2 Landscape opens before its `expand`. */
|
|
52
|
+
function systemsOpen(model, collapse) {
|
|
53
|
+
const closed = new Set(collapse);
|
|
54
|
+
return model.elements.filter((e) => e.kind === "system" && !closed.has(e.id)).map((e) => e.id);
|
|
55
|
+
}
|
|
49
56
|
/** Every top-level Element, each standing for everything beneath it, with the `expand`ed boxes open. */
|
|
50
57
|
function landscape(model, kind, title, expand) {
|
|
51
58
|
const shown = new Set(model.elements.filter((e) => e.parent === null).map((e) => e.id));
|
|
@@ -8,6 +8,7 @@ export { compareView } from "./compare.ts";
|
|
|
8
8
|
export { saveAsView, type Screen, type SavedScreen, type SavedViewDefinition } from "./save-as-view.ts";
|
|
9
9
|
export { parseViewId, formatViewId, ownViewId, type ViewRef } from "./ids.ts";
|
|
10
10
|
export { describeLens } from "./lens.ts";
|
|
11
|
+
export { instancesChip, isScaled } from "./deployment.ts";
|
|
11
12
|
export { stepViews, dynamicViewsUsing, type DynamicResolution, type DynamicProblem, type ResolvedDynamicView, type ResolvedStep, type StepKind } from "./dynamic.ts";
|
|
12
13
|
export type { SavedResolution, BadExpand, UnresolvedPath } from "./saved.ts";
|
|
13
14
|
export { MAX_VIEW_NODES, type CompareMark, type ImpactSide, type LensChoice, type ListedKind, type NodeMark, type ResolveOptions, type ResolvedView, type ViewDirection, type ViewEdge, type ViewKind, type ViewNode, type ViewSummary, } from "./types.ts";
|
package/dist/core/views/index.js
CHANGED
|
@@ -8,5 +8,6 @@ export { compareView } from "./compare.js";
|
|
|
8
8
|
export { saveAsView } from "./save-as-view.js";
|
|
9
9
|
export { parseViewId, formatViewId, ownViewId } from "./ids.js";
|
|
10
10
|
export { describeLens } from "./lens.js";
|
|
11
|
+
export { instancesChip, isScaled } from "./deployment.js";
|
|
11
12
|
export { stepViews, dynamicViewsUsing } from "./dynamic.js";
|
|
12
13
|
export { MAX_VIEW_NODES, } from "./types.js";
|
|
@@ -19,17 +19,17 @@ export function resolveView(bundle, id, options = {}) {
|
|
|
19
19
|
/** Resolves a Structural View by id over an index of its Bundle; undefined for an unknown id or a Dynamic View's. */
|
|
20
20
|
export function resolveStructural(bundle, model, id, options = {}) {
|
|
21
21
|
const lens = options.lens ?? "own";
|
|
22
|
-
const view = unlensed(bundle, model, id, options
|
|
22
|
+
const view = unlensed(bundle, model, id, options, lens);
|
|
23
23
|
if (view && typeof lens === "object")
|
|
24
24
|
applyLens(bundle, model, view, lens);
|
|
25
25
|
return view;
|
|
26
26
|
}
|
|
27
27
|
/** A Structural View with no Lens, except a Saved View's own when the choice is `"own"`. */
|
|
28
|
-
function unlensed(bundle, model, id,
|
|
28
|
+
function unlensed(bundle, model, id, options, lens) {
|
|
29
29
|
const saved = bundle.views.find((v) => v.id === id);
|
|
30
30
|
if (saved)
|
|
31
31
|
return saved.kind === "structural" ? resolveSaved(bundle, model, lens === "own" ? saved : { ...saved, lens: null }).view : undefined;
|
|
32
|
-
return resolveGenerated(bundle, model, id, expand);
|
|
32
|
+
return resolveGenerated(bundle, model, id, options.expand ?? [], options.collapse ?? []);
|
|
33
33
|
}
|
|
34
34
|
export function checkView(bundle, def) {
|
|
35
35
|
return def.kind === "dynamic" ? resolveDynamic(bundle, def) : resolveSaved(bundle, new ModelIndex(bundle), def);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { Bundle, BundleLens } from "../../schema/bundle.ts";
|
|
2
2
|
import type { ViewDirection } from "./types.ts";
|
|
3
|
-
/** What the viewer shows, as its URL holds it: the View, its open boxes, the Lens, the picks and a turned direction. */
|
|
3
|
+
/** What the viewer shows, as its URL holds it: the View, its open and closed boxes, the Lens, the picks and a turned direction. */
|
|
4
4
|
export interface Screen {
|
|
5
5
|
view: string;
|
|
6
6
|
open: readonly string[];
|
|
7
|
+
/** Systems closed on the C2 Landscape, which opens every other System. */
|
|
8
|
+
closed: readonly string[];
|
|
7
9
|
lens: BundleLens | null;
|
|
8
10
|
picks: readonly string[];
|
|
9
11
|
/** The direction the viewer turned the View to; null keeps the View's own. */
|
|
@@ -30,8 +32,11 @@ export interface SavedScreen {
|
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* Save as View: turns the screen into a Saved View definition that the core
|
|
33
|
-
* engine resolves to the same nodes. The
|
|
34
|
-
*
|
|
35
|
+
* engine resolves to the same nodes. The whole C2 Landscape, with no picks or
|
|
36
|
+
* Lens, is `level: c2` with no `include`, its closed Systems as `collapse`
|
|
37
|
+
* and its open boxes as `expand`. Otherwise the picks (with their open
|
|
38
|
+
* containers), or else every node, become ids; open boxes (on the C2
|
|
39
|
+
* Landscape, every System not closed too) whose children are all kept
|
|
35
40
|
* become `expand`; the Lens becomes an include selector (an Impact Lens
|
|
36
41
|
* `upstream`/`downstream: all`, a Team Lens `{team}`, Connect to… a path
|
|
37
42
|
* selector) and is kept as `lens:`. Nodes the Lens selector would add beyond
|
|
@@ -7,8 +7,11 @@ const kindLevel = { person: "c1", system: "c1", service: "c2", component: "c3" }
|
|
|
7
7
|
const levelDepth = { c1: 1, c2: 2, c3: 3 };
|
|
8
8
|
/**
|
|
9
9
|
* Save as View: turns the screen into a Saved View definition that the core
|
|
10
|
-
* engine resolves to the same nodes. The
|
|
11
|
-
*
|
|
10
|
+
* engine resolves to the same nodes. The whole C2 Landscape, with no picks or
|
|
11
|
+
* Lens, is `level: c2` with no `include`, its closed Systems as `collapse`
|
|
12
|
+
* and its open boxes as `expand`. Otherwise the picks (with their open
|
|
13
|
+
* containers), or else every node, become ids; open boxes (on the C2
|
|
14
|
+
* Landscape, every System not closed too) whose children are all kept
|
|
12
15
|
* become `expand`; the Lens becomes an include selector (an Impact Lens
|
|
13
16
|
* `upstream`/`downstream: all`, a Team Lens `{team}`, Connect to… a path
|
|
14
17
|
* selector) and is kept as `lens:`. Nodes the Lens selector would add beyond
|
|
@@ -17,7 +20,7 @@ const levelDepth = { c1: 1, c2: 2, c3: 3 };
|
|
|
17
20
|
*/
|
|
18
21
|
export function saveAsView(bundle, screen, target) {
|
|
19
22
|
const model = new ModelIndex(bundle);
|
|
20
|
-
const view = resolveStructural(bundle, model, screen.view, { expand: screen.open });
|
|
23
|
+
const view = resolveStructural(bundle, model, screen.view, { expand: screen.open, collapse: screen.closed });
|
|
21
24
|
if (!view)
|
|
22
25
|
throw new Error(`No View ${screen.view} to save.`);
|
|
23
26
|
const own = bundle.views.find((v) => v.id === screen.view && v.kind === "structural");
|
|
@@ -41,9 +44,11 @@ export function saveAsView(bundle, screen, target) {
|
|
|
41
44
|
else {
|
|
42
45
|
const kept = new Set((screen.picks.length === 0 ? view : pickedView(view, screen.picks)).nodes.map((n) => n.id));
|
|
43
46
|
const depthOf = (id) => model.ancestry(id).length;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
const opens = (id) => kept.has(id) && model.children(id).length > 0 && model.children(id).every((c) => kept.has(c.id));
|
|
48
|
+
// On the C2 Landscape every System is open unless closed, as `resolveGenerated` opens them.
|
|
49
|
+
const landscape = !own && view.id === "c2";
|
|
50
|
+
const systems = landscape ? model.elements.filter((e) => e.kind === "system" && !screen.closed.includes(e.id)).map((e) => e.id) : [];
|
|
51
|
+
const expand = [...new Set([...systems, ...screen.open])].filter(opens).sort((a, b) => depthOf(a) - depthOf(b));
|
|
47
52
|
const byExpand = new Set(expand.flatMap((id) => model.children(id).map((c) => c.id)));
|
|
48
53
|
const ids = [...kept].filter((id) => !byExpand.has(id)).sort();
|
|
49
54
|
const deepest = ids.reduce((d, id) => Math.max(d, levelDepth[kindLevel[model.byId.get(id).kind]]), levelDepth[view.kind]);
|
|
@@ -51,6 +56,11 @@ export function saveAsView(bundle, screen, target) {
|
|
|
51
56
|
const plain = { level, include: ids, ...nonEmpty({ expand }) };
|
|
52
57
|
const selector = screen.lens ? lensSelector(screen.lens) : undefined;
|
|
53
58
|
body = plain;
|
|
59
|
+
if (landscape && screen.picks.length === 0 && !selector) {
|
|
60
|
+
// The whole Landscape: every Element at `c2`, which opens every System, less those closed.
|
|
61
|
+
const collapse = screen.closed.filter((id) => kept.has(id) && model.children(id).length > 0 && !screen.open.includes(id));
|
|
62
|
+
body = { level: "c2", ...nonEmpty({ expand: expand.filter((id) => !systems.includes(id)), collapse }) };
|
|
63
|
+
}
|
|
54
64
|
if (selector) {
|
|
55
65
|
const reached = nodesOf(bundle, model, { level, include: [selector] });
|
|
56
66
|
const include = [selector, ...ids.filter((id) => !reached.has(id))];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BundleElement, BundleLens, BundleRelationship } from "../../schema/bundle.ts";
|
|
1
|
+
import type { BundleDeployment, BundleElement, BundleLens, BundleRelationship } from "../../schema/bundle.ts";
|
|
2
2
|
/** The most nodes a View may have before `oversized-view` warns. */
|
|
3
3
|
export declare const MAX_VIEW_NODES = 150;
|
|
4
4
|
/** The kinds of Structural View: the three levels, and the Deployment View. */
|
|
@@ -19,6 +19,8 @@ export interface ViewNode {
|
|
|
19
19
|
element?: string;
|
|
20
20
|
/** A Deployment's Deployment Target. */
|
|
21
21
|
target?: string;
|
|
22
|
+
/** A scaled Deployment's `instances` (a count above 1, or an autoscale range); absent for one instance. */
|
|
23
|
+
instances?: BundleDeployment["instances"];
|
|
22
24
|
/** The nearest ancestor that is itself a node of this View, else null. */
|
|
23
25
|
parent: string | null;
|
|
24
26
|
/** True when the Element has children in the Model that this View hides inside it. */
|
|
@@ -71,6 +73,12 @@ export interface ResolveOptions {
|
|
|
71
73
|
* stays shut inside a closed System. C1 opens nothing.
|
|
72
74
|
*/
|
|
73
75
|
expand?: readonly string[];
|
|
76
|
+
/**
|
|
77
|
+
* Systems the C2 Landscape shows closed; it opens every other System.
|
|
78
|
+
* Viewer state, like `expand`, and read by no other View. A System that is
|
|
79
|
+
* also in `expand` is open.
|
|
80
|
+
*/
|
|
81
|
+
collapse?: readonly string[];
|
|
74
82
|
/**
|
|
75
83
|
* The Lens over the View, which marks nodes and lights edges without
|
|
76
84
|
* changing which nodes the View holds: `"own"` (the default) is a Saved
|
package/dist/mcp/server.js
CHANGED
|
@@ -5,7 +5,7 @@ import { withDocs } from "../core/rules.js";
|
|
|
5
5
|
import { search } from "../core/search.js";
|
|
6
6
|
import { changeKinds, countChanges, deriveEdges, diff, filterChanges, findPaths, getImpact, levelOf, listOwned, resolveScope, scopeMatcher, } from "../core/index.js";
|
|
7
7
|
import { suggest } from "../core/suggest.js";
|
|
8
|
-
import { describeLens, listViews, resolveView } from "../core/views/index.js";
|
|
8
|
+
import { describeLens, isScaled, listViews, resolveView } from "../core/views/index.js";
|
|
9
9
|
import { listAdrs } from "../core/adrs.js";
|
|
10
10
|
import { AdrStatus } from "../schema/adr.js";
|
|
11
11
|
import { BundleAdr, BundleDeployment, BundleElement, BundleLens, BundleRelationship } from "../schema/bundle.js";
|
|
@@ -214,7 +214,7 @@ export function createServer(options) {
|
|
|
214
214
|
});
|
|
215
215
|
tool("get_deployments", {
|
|
216
216
|
title: "Get Deployments",
|
|
217
|
-
description: "Where a Service runs: each Deployment's Environment, its full Deployment Target chain (outermost first), main url and
|
|
217
|
+
description: "Where a Service runs: each Deployment's Environment, its full Deployment Target chain (outermost first), main url, named endpoints and `instances` (a count, or {min, max} for autoscale). Pass `environment` for one Environment, e.g. a Service's URL in staging.",
|
|
218
218
|
input: z.object({
|
|
219
219
|
service: QualifiedId.describe("The Service's qualified id, project:id"),
|
|
220
220
|
environment: z.string().min(1).optional().describe("An Environment id, such as prod or staging"),
|
|
@@ -245,7 +245,7 @@ export function createServer(options) {
|
|
|
245
245
|
...items.map((d) => {
|
|
246
246
|
const chain = d.targetPath.length ? d.targetPath.map((t) => t.id).join(" › ") : d.target;
|
|
247
247
|
const urls = [d.url ?? "no URL", ...d.endpoints.map((e) => `${e.name}: ${e.url}`)].join("; ");
|
|
248
|
-
return `- ${d.environment} on ${chain}: ${urls}`;
|
|
248
|
+
return `- ${d.environment} on ${chain}${instancesLabel(d.instances)}: ${urls}`;
|
|
249
249
|
}),
|
|
250
250
|
].join("\n"));
|
|
251
251
|
});
|
|
@@ -310,6 +310,7 @@ export function createServer(options) {
|
|
|
310
310
|
name: z.string(),
|
|
311
311
|
element: z.string().optional(),
|
|
312
312
|
target: z.string().optional(),
|
|
313
|
+
instances: BundleDeployment.shape.instances.optional(),
|
|
313
314
|
parent: z.string().nullable(),
|
|
314
315
|
collapsed: z.boolean(),
|
|
315
316
|
external: z.boolean(),
|
|
@@ -711,7 +712,7 @@ const ElementKind = z.enum(["person", "system", "service", "component"]);
|
|
|
711
712
|
const ViewKind = z.enum(["c1", "c2", "c3", "deployment", "dynamic"]);
|
|
712
713
|
const ViewSummary = z.object({ id: z.string(), kind: ViewKind, title: z.string() });
|
|
713
714
|
const nodeKind = (n) => (n.kind === "deployment" ? `Deployment of ${n.element}` : n.kind === "target" ? "Deployment Target" : kindName[n.kind]);
|
|
714
|
-
const nodeLine = (n) => `- ${label(n)}: ${nodeKind(n)}${n.external ? ", external" : ""}${n.parent ? ` in ${n.parent}` : ""}${n.collapsed ? ", collapsed" : ""}${n.mark?.hit ? `, hit${n.mark.distance === undefined ? "" : ` at distance ${n.mark.distance}`}${n.mark.side === undefined || n.mark.side === "origin" ? "" : ` ${n.mark.side}`}` : ""}`;
|
|
715
|
+
const nodeLine = (n) => `- ${label(n)}: ${nodeKind(n)}${n.instances === undefined ? "" : instancesLabel(n.instances)}${n.external ? ", external" : ""}${n.parent ? ` in ${n.parent}` : ""}${n.collapsed ? ", collapsed" : ""}${n.mark?.hit ? `, hit${n.mark.distance === undefined ? "" : ` at distance ${n.mark.distance}`}${n.mark.side === undefined || n.mark.side === "origin" ? "" : ` ${n.mark.side}`}` : ""}`;
|
|
715
716
|
/** A Step as one line: a return drawn dashed (⇠), an event with its broker and channel. */
|
|
716
717
|
const stepLine = (s) => {
|
|
717
718
|
const how = s.kind === "event" ? ` (event${s.via ? ` via ${s.via}` : ""}${s.channel ? ` · ${s.channel}` : ""})` : s.kind === "return" ? " (return)" : s.interaction === "async" ? " (async)" : "";
|
|
@@ -735,9 +736,12 @@ const deploymentResult = (d) => ({
|
|
|
735
736
|
targetPath: d.targetPath,
|
|
736
737
|
url: d.url,
|
|
737
738
|
endpoints: d.endpoints,
|
|
739
|
+
instances: d.instances,
|
|
738
740
|
owner: d.owner,
|
|
739
741
|
source: d.source,
|
|
740
742
|
});
|
|
743
|
+
/** ` (×3)` or ` (2–10 instances)`; empty for a single instance. */
|
|
744
|
+
const instancesLabel = (i) => (!isScaled(i) ? "" : typeof i === "number" ? ` (×${i})` : ` (${i.min}–${i.max} instances)`);
|
|
741
745
|
const summary = (e) => ({ id: e.id, kind: e.kind, name: e.name });
|
|
742
746
|
const label = (e) => `${e.id} (${e.name})`;
|
|
743
747
|
const kindName = { person: "Person", system: "System", service: "Service", component: "Component" };
|
package/dist/mcp/writes.js
CHANGED
|
@@ -106,6 +106,7 @@ export function registerWriteTools(server, source, readOnly, logged) {
|
|
|
106
106
|
description: [
|
|
107
107
|
"Adds a Deployment Target, or updates the fields of an existing one (name, kind, description, owner, tags, links); comments and formatting are kept.",
|
|
108
108
|
"A new Target nests under `parent` in the parent's file. A new top-level one goes into `file` (relative to the Project's folder), else `model.yaml`.",
|
|
109
|
+
"`kind` is free text printed as written in the Target's header, so keep it short: `region`, `az`, `vnet`, `snet`, `vm`, `aks`, `ns`, `asp`, not `availability-zone` or `subnet`.",
|
|
109
110
|
].join(" "),
|
|
110
111
|
input: z.object({
|
|
111
112
|
project: Project,
|
|
@@ -130,7 +131,9 @@ export function registerWriteTools(server, source, readOnly, logged) {
|
|
|
130
131
|
writeTool("upsert_deployment", {
|
|
131
132
|
title: "Add or update a Deployment",
|
|
132
133
|
description: [
|
|
133
|
-
"Adds a Deployment, or updates the fields (url, endpoints) of the one its (service, environment, target) triple names, in this Project's YAML; comments and formatting are kept.",
|
|
134
|
+
"Adds a Deployment, or updates the fields (url, endpoints, instances) of the one its (service, environment, target) triple names, in this Project's YAML; comments and formatting are kept.",
|
|
135
|
+
"`instances` is a whole number for a fixed count, such as 3, or {min, max} for an autoscale range, such as {min: 2, max: 10}; leave it out for one instance.",
|
|
136
|
+
"Use it for interchangeable copies on one Target (an App Service plan running N workers); when placement matters (one per availability zone or VM), add separate Deployments on separate Targets instead.",
|
|
134
137
|
"A new one goes into `file` (relative to the Project's folder), else beside the Project's other Deployments, else into `model.yaml`.",
|
|
135
138
|
].join(" "),
|
|
136
139
|
input: z.object({
|
package/dist/render/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { renderPng, type PngOptions } from "./png.ts";
|
|
|
5
5
|
export { layoutSequence, sequenceMessages, sequenceParticipants, viaLine, SEQUENCE, type SequenceLayout, type SequenceMessage, type SequenceColumn, type SequenceRow, type Activation, type MessageStyle, type SequenceOptions } from "./sequence.ts";
|
|
6
6
|
export { textWidth, cut } from "./text.ts";
|
|
7
7
|
export { renderSequenceSvg, type SequenceRenderInput } from "./sequence-svg.ts";
|
|
8
|
-
export { PALETTES, themes, type Palette, type Theme } from "./tokens.ts";
|
|
8
|
+
export { PALETTES, themes, targetStep, TARGET_STEPS, type Palette, type Theme } from "./tokens.ts";
|
package/dist/render/index.js
CHANGED
|
@@ -5,4 +5,4 @@ export { renderPng } from "./png.js";
|
|
|
5
5
|
export { layoutSequence, sequenceMessages, sequenceParticipants, viaLine, SEQUENCE } from "./sequence.js";
|
|
6
6
|
export { textWidth, cut } from "./text.js";
|
|
7
7
|
export { renderSequenceSvg } from "./sequence-svg.js";
|
|
8
|
-
export { PALETTES, themes } from "./tokens.js";
|
|
8
|
+
export { PALETTES, themes, targetStep, TARGET_STEPS } from "./tokens.js";
|
package/dist/render/layout.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ELK } from "elkjs/lib/elk-api.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type ResolvedView, type ViewNode } from "../core/views/index.ts";
|
|
3
3
|
/** Which way a View's edges flow: top to bottom, bottom to top, left to right or right to left. */
|
|
4
4
|
export type Direction = "TB" | "BT" | "LR" | "RL";
|
|
5
5
|
export declare const directions: readonly Direction[];
|
|
@@ -44,6 +44,8 @@ export declare const NODE_SIZES: Record<ViewNode["kind"], {
|
|
|
44
44
|
export declare const NODE_MAX_WIDTH = 360;
|
|
45
45
|
/** The extra height a box gets for a second line of name. */
|
|
46
46
|
export declare const NAME_LINE = 18;
|
|
47
|
+
/** A scaled Deployment's count chip, `×3` or `2–10`, as wide as the viewer and the SVG draw it. */
|
|
48
|
+
export declare function chipWidth(chip: string): number;
|
|
47
49
|
/** The width a box of `width` leaves for its name. */
|
|
48
50
|
export declare function nameRoom(n: ViewNode, width: number): number;
|
|
49
51
|
/**
|
package/dist/render/layout.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ElkBundled from "elkjs/lib/elk.bundled.js";
|
|
2
|
+
import { instancesChip } from "../core/views/index.js";
|
|
2
3
|
import { textWidth } from "./text.js";
|
|
3
4
|
export const directions = ["TB", "BT", "LR", "RL"];
|
|
4
5
|
/** The least size of a node per kind; `nodeSize` widens it for a long name. Containers are sized by their contents. */
|
|
@@ -23,7 +24,11 @@ const WAY_IN_CHROME = 30;
|
|
|
23
24
|
/** The room a box of this kind and state needs beside its name. */
|
|
24
25
|
function headChrome(n) {
|
|
25
26
|
const opens = n.kind === "system" || (n.kind === "service" && n.collapsed);
|
|
26
|
-
return HEAD_CHROME + (n.collapsed && opens ? TOGGLE_CHROME : 0) + (n.kind === "person" ? 12 : 0);
|
|
27
|
+
return HEAD_CHROME + (n.collapsed && opens ? TOGGLE_CHROME : 0) + (n.kind === "person" ? 12 : 0) + (n.instances === undefined ? 0 : chipWidth(instancesChip(n.instances)) + 8);
|
|
28
|
+
}
|
|
29
|
+
/** A scaled Deployment's count chip, `×3` or `2–10`, as wide as the viewer and the SVG draw it. */
|
|
30
|
+
export function chipWidth(chip) {
|
|
31
|
+
return Math.ceil(textWidth(chip, 10, 700)) + 12;
|
|
27
32
|
}
|
|
28
33
|
/** The width a box of `width` leaves for its name. */
|
|
29
34
|
export function nameRoom(n, width) {
|
|
@@ -39,10 +39,13 @@ export declare const SEQUENCE: {
|
|
|
39
39
|
readonly nameSize: 13;
|
|
40
40
|
readonly labelSize: 12;
|
|
41
41
|
readonly subSize: 11;
|
|
42
|
-
/**
|
|
43
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Room in a header beside its name: the border, padding, the gaps either
|
|
44
|
+
* side of the name, and the widest Team code tile (three capitals). Headers
|
|
45
|
+
* have no maximum width, so a name is never cut.
|
|
46
|
+
*/
|
|
47
|
+
readonly headerPad: 88;
|
|
44
48
|
readonly minColumn: 116;
|
|
45
|
-
readonly maxColumn: 200;
|
|
46
49
|
readonly margin: 24;
|
|
47
50
|
};
|
|
48
51
|
export interface SequenceColumn {
|
package/dist/render/sequence.js
CHANGED
|
@@ -17,10 +17,13 @@ export const SEQUENCE = {
|
|
|
17
17
|
nameSize: 13,
|
|
18
18
|
labelSize: 12,
|
|
19
19
|
subSize: 11,
|
|
20
|
-
/**
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Room in a header beside its name: the border, padding, the gaps either
|
|
22
|
+
* side of the name, and the widest Team code tile (three capitals). Headers
|
|
23
|
+
* have no maximum width, so a name is never cut.
|
|
24
|
+
*/
|
|
25
|
+
headerPad: 88,
|
|
22
26
|
minColumn: 116,
|
|
23
|
-
maxColumn: 200,
|
|
24
27
|
margin: 24,
|
|
25
28
|
};
|
|
26
29
|
/**
|
|
@@ -72,7 +75,7 @@ export function layoutSequence(view, options) {
|
|
|
72
75
|
const messages = sequenceMessages(view, options);
|
|
73
76
|
const ids = sequenceParticipants(view, options);
|
|
74
77
|
const index = new Map(ids.map((id, i) => [id, i]));
|
|
75
|
-
const widths = ids.map((id) => Math.
|
|
78
|
+
const widths = ids.map((id) => Math.max(S.minColumn, textWidth(options.name(id), S.nameSize, 700) + S.headerPad));
|
|
76
79
|
const labelWidths = messages.map((m) => {
|
|
77
80
|
const via = viaLine(m, options.name);
|
|
78
81
|
return Math.max(textWidth(m.label, S.labelSize), via ? textWidth(via, S.subSize) : 0, m.note ? textWidth(m.note, S.subSize) : 0);
|
package/dist/render/svg.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ResolvedView } from "../core/views/index.ts";
|
|
2
2
|
import type { Bundle } from "../schema/bundle.ts";
|
|
3
|
-
import type
|
|
3
|
+
import { type Layout } from "./layout.ts";
|
|
4
4
|
import { type TeamStyle } from "./teams.ts";
|
|
5
5
|
import { type Palette, type Theme } from "./tokens.ts";
|
|
6
6
|
/** Where a picture comes from, for its source line: the Workspace's name, the commit and its date (both null before the first commit). */
|
|
@@ -34,3 +34,5 @@ export declare const opening: (width: number, height: number, ground: string, de
|
|
|
34
34
|
export declare function renderSvg({ bundle, view, layout, source, theme, label }: RenderInput): string;
|
|
35
35
|
/** A reversed Team code tile with the Team colour as its leading band, its right edge at `right`. */
|
|
36
36
|
export declare function codeTile(c: Palette, team: TeamStyle, right: number, top: number): string;
|
|
37
|
+
/** How far each copy behind a scaled Deployment sits from the one in front, down and to the right. */
|
|
38
|
+
export declare const STACK_OFFSET = 5;
|
package/dist/render/svg.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { describeLens } from "../core/views/index.js";
|
|
1
|
+
import { describeLens, instancesChip } from "../core/views/index.js";
|
|
2
2
|
import { FONT_FAMILY, FONTS } from "./font.js";
|
|
3
|
+
import { chipWidth } from "./layout.js";
|
|
3
4
|
import { teamStyles } from "./teams.js";
|
|
4
5
|
import { cut, fmt, text, textWidth } from "./text.js";
|
|
5
|
-
import { flatten, PALETTES } from "./tokens.js";
|
|
6
|
+
import { flatten, PALETTES, targetStep } from "./tokens.js";
|
|
6
7
|
const PAD = 24;
|
|
7
8
|
const HEADER = 72;
|
|
8
9
|
const KEY = 44;
|
|
@@ -35,19 +36,27 @@ export function renderSvg({ bundle, view, layout, source, theme = "light", label
|
|
|
35
36
|
const containers = new Set(view.nodes.map((n) => n.parent).filter((p) => p !== null));
|
|
36
37
|
const title = view.title;
|
|
37
38
|
const subtitle = sourceLine(source, label);
|
|
38
|
-
const key = drawKey(c, bundle, view.lens);
|
|
39
|
+
const key = drawKey(c, bundle, view.lens, view.nodes.some((n) => n.instances !== undefined));
|
|
39
40
|
const width = Math.ceil(Math.max(layout.width, key.width, textWidth(title, 20, 700), textWidth(subtitle, 12)) + 2 * PAD);
|
|
40
41
|
const height = Math.ceil(HEADER + layout.height + PAD + KEY);
|
|
41
42
|
const depth = (n) => (n.parent === null ? 0 : 1 + depth(view.nodes.find((p) => p.id === n.parent)));
|
|
42
43
|
const byDepth = view.nodes.map((n) => ({ n, d: depth(n) })).sort((a, b) => a.d - b.d).map(({ n }) => n);
|
|
43
44
|
const ring = view.lens !== undefined && "team" in view.lens;
|
|
45
|
+
const byId = new Map(view.nodes.map((n) => [n.id, n]));
|
|
46
|
+
const targetDepth = (n) => (n.kind !== "target" ? 0 : 1 + (n.parent === null ? 0 : targetDepth(byId.get(n.parent))));
|
|
47
|
+
/** What a box is drawn on: its nearest enclosing Target's Target Depth ground, else the canvas. */
|
|
48
|
+
const groundOf = (n) => {
|
|
49
|
+
const parent = n.parent === null ? undefined : byId.get(n.parent);
|
|
50
|
+
return parent === undefined ? c.ground : parent.kind === "target" ? c[`target-${targetStep(targetDepth(parent))}`] : groundOf(parent);
|
|
51
|
+
};
|
|
52
|
+
const targetGround = (n) => c[`target-${targetStep(targetDepth(n))}`];
|
|
44
53
|
let clips = 0;
|
|
45
54
|
const drawn = (n) => {
|
|
46
55
|
const box = boxes.get(n.id);
|
|
47
56
|
const element = elements.get(n.element ?? n.id);
|
|
48
57
|
const target = n.kind === "target" ? targets.get(n.id) : undefined;
|
|
49
58
|
const team = teams.get(element?.owner ?? target?.owner ?? "");
|
|
50
|
-
return containers.has(n.id) ? drawContainer(c, n, box, team, target?.kind) : drawNode(c, n, box, element, team, ring, `clip-${clips++}`);
|
|
59
|
+
return containers.has(n.id) ? drawContainer(c, n, box, team, groundOf(n), n.kind === "target" ? targetGround(n) : undefined, target?.kind) : drawNode(c, n, box, element, team, ring, `clip-${clips++}`);
|
|
51
60
|
};
|
|
52
61
|
return [
|
|
53
62
|
...opening(width, height, c.ground, `${marker("arrow", c.edge)}${view.lens ? marker("arrow-faint", c["edge-faint"]) + marker("arrow-lit", c.ink) : ""}${brokerPattern(c)}`),
|
|
@@ -128,10 +137,13 @@ function drawNode(c, n, box, element, team, ringLens, clip) {
|
|
|
128
137
|
const dash = n.external ? ` stroke-dasharray="6 4"` : "";
|
|
129
138
|
const frameWidth = system ? 2 : FRAME;
|
|
130
139
|
const tileWidth = team ? textWidth(team.code, 10, 700) + 16 + 8 : 0;
|
|
140
|
+
const chip = n.instances === undefined ? undefined : instancesChip(n.instances);
|
|
141
|
+
const chipRoom = chip === undefined ? 0 : chipWidth(chip) + 8;
|
|
131
142
|
const left = x + EDGE + (n.kind === "person" ? 12 : 8);
|
|
132
143
|
const right = n.kind === "person" ? x + w - 16 : x + w - 10;
|
|
133
144
|
return [
|
|
134
145
|
`<g>`,
|
|
146
|
+
...(chip === undefined ? [] : stack(l, x, y, w, h)),
|
|
135
147
|
...(l.ring ? [`<path d="${shape(x - 4, y - 4, w + 8, h + 8, r ? [r + 4, r + 4, r + 4, r + 4] : type === "datastore" ? [0, 0, 16, 16] : [0, 0, 0, 0])}" fill="${l.ring}"/>`] : []),
|
|
136
148
|
`<clipPath id="${clip}"><path d="${d}"/></clipPath>`,
|
|
137
149
|
`<path d="${d}" fill="${l.fill}"/>`,
|
|
@@ -139,21 +151,41 @@ function drawNode(c, n, box, element, team, ringLens, clip) {
|
|
|
139
151
|
`<path d="${d}" fill="none" stroke="${l.frame}" stroke-width="${frameWidth}"${dash}/>`,
|
|
140
152
|
...(l.double ? [`<path d="${shape(x + 3, y + 3, w - 6, h - 6, [0, 0, type === "datastore" ? 9 : 0, type === "datastore" ? 9 : 0])}" fill="none" stroke="${l.frame}" stroke-width="${FRAME}"/>`] : []),
|
|
141
153
|
`<rect x="${fmt(x - 1)}" y="${fmt(y - 1)}" width="${EDGE + 1}" height="${fmt(h + 2)}" fill="${l.edge}" clip-path="url(#${clip})"/>`,
|
|
142
|
-
text(left, y + h / 2 - 4, cut(n.name, 13, right - left - tileWidth, 700), { size: 13, fill: l.name, weight: 700 }),
|
|
154
|
+
text(left, y + h / 2 - 4, cut(n.name, 13, right - left - tileWidth - chipRoom, 700), { size: 13, fill: l.name, weight: 700 }),
|
|
143
155
|
text(left, y + h / 2 + 13, cut(subLabel(n, element), 11, right - left), { size: 11, fill: l.sub }),
|
|
144
156
|
...(team ? [codeTile(c, team, right, y + 8)] : []),
|
|
157
|
+
...(chip === undefined ? [] : [countChip(c, l, chip, right - tileWidth, y + 8)]),
|
|
145
158
|
...badge(c, n, box),
|
|
146
159
|
...(n.mark?.hit && n.collapsed ? [`<rect x="${fmt(x + w - 42)}" y="${fmt(y + h - 18)}" width="10" height="10" fill="${c.ink}" stroke="${c.paper}" stroke-width="2"/>`] : []),
|
|
147
160
|
`</g>`,
|
|
148
161
|
].join("");
|
|
149
162
|
}
|
|
150
|
-
/**
|
|
151
|
-
|
|
163
|
+
/** How far each copy behind a scaled Deployment sits from the one in front, down and to the right. */
|
|
164
|
+
export const STACK_OFFSET = 5;
|
|
165
|
+
/** A scaled Deployment's two copies behind its box, back to front, each framed like the box. */
|
|
166
|
+
function stack(l, x, y, w, h) {
|
|
167
|
+
return [2, 1].map((i) => `<rect x="${fmt(x + i * STACK_OFFSET)}" y="${fmt(y + i * STACK_OFFSET)}" width="${fmt(w)}" height="${fmt(h)}" fill="${l.fill}" stroke="${l.frame}" stroke-width="${FRAME}"/>`);
|
|
168
|
+
}
|
|
169
|
+
/** A scaled Deployment's count chip, `×3` or `2–10`, framed in ink, its right edge at `right`. */
|
|
170
|
+
function countChip(c, l, chip, right, top) {
|
|
171
|
+
const w = chipWidth(chip);
|
|
172
|
+
const x = right - w;
|
|
173
|
+
return [
|
|
174
|
+
`<rect x="${fmt(x)}" y="${fmt(top)}" width="${fmt(w)}" height="16" fill="${c.paper}" stroke="${l.frame}" stroke-width="1"/>`,
|
|
175
|
+
text(x + 6, top + 12, chip, { size: 10, fill: l.name, weight: 700 }),
|
|
176
|
+
].join("");
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* An open box: a quiet line frame on the open-box tint (flattened onto `under`,
|
|
180
|
+
* what it sits on), its head row at the top. A Deployment Target is a quiet
|
|
181
|
+
* frame on its Target Depth ground, headed by its name and kind alone.
|
|
182
|
+
*/
|
|
183
|
+
function drawContainer(c, n, box, team, under, targetGround, targetKind) {
|
|
152
184
|
const { x, y, width: w, height: h } = box;
|
|
153
185
|
const target = n.kind === "target";
|
|
154
186
|
const dimmed = n.mark && !n.mark.hit;
|
|
155
187
|
const frame = n.external ? c.ink : c.line;
|
|
156
|
-
const fill =
|
|
188
|
+
const fill = targetGround ?? (dimmed ? "none" : flatten(c.container, under));
|
|
157
189
|
const dash = n.external ? ` stroke-dasharray="6 4"` : "";
|
|
158
190
|
const tileWidth = team ? textWidth(team.code, 10, 700) + 16 + 8 : 0;
|
|
159
191
|
const left = x + (target ? 12 : EDGE + 10);
|
|
@@ -176,8 +208,8 @@ function drawEdge(c, points, edge) {
|
|
|
176
208
|
return `<path d="${d}" fill="none" stroke="${c["edge-faint"]}" stroke-width="${FRAME}" marker-end="url(#arrow-faint)"/>`;
|
|
177
209
|
return `<path d="${d}" fill="none" stroke="${c.edge}" stroke-width="${FRAME}" marker-end="url(#arrow)"/>`;
|
|
178
210
|
}
|
|
179
|
-
/** The key, in the canvas's own vocabulary: the Team tile, External, broker, and the Lens if there is one. */
|
|
180
|
-
function drawKey(c, bundle, lens) {
|
|
211
|
+
/** The key, in the canvas's own vocabulary: the Team tile, External, broker, the stack when a Deployment is scaled, and the Lens if there is one. */
|
|
212
|
+
function drawKey(c, bundle, lens, scaled) {
|
|
181
213
|
const parts = [];
|
|
182
214
|
let x = 0;
|
|
183
215
|
const label = (s) => {
|
|
@@ -196,6 +228,12 @@ function drawKey(c, bundle, lens) {
|
|
|
196
228
|
parts.push(`<rect x="${fmt(x)}" y="4" width="28" height="16" fill="${c.paper}"/><rect x="${fmt(x)}" y="4" width="28" height="16" fill="url(#broker)" stroke="${c.ink}" stroke-width="${FRAME}"/>`);
|
|
197
229
|
x += 36;
|
|
198
230
|
label("Broker");
|
|
231
|
+
if (scaled) {
|
|
232
|
+
for (const i of [2, 1, 0])
|
|
233
|
+
parts.push(`<rect x="${fmt(x + i * 3)}" y="${fmt(1 + i * 3)}" width="22" height="12" fill="${c.paper}" stroke="${c.ink}" stroke-width="${FRAME}"/>`);
|
|
234
|
+
x += 36;
|
|
235
|
+
label("Stacked: scaled (×3 fixed, 2–10 autoscale)");
|
|
236
|
+
}
|
|
199
237
|
if (lens) {
|
|
200
238
|
if ("impact" in lens) {
|
|
201
239
|
swatch(`fill="${c.herebg}" stroke="${c.here}" stroke-width="2.5"`);
|
package/dist/render/tokens.d.ts
CHANGED
|
@@ -43,7 +43,15 @@ export interface Palette {
|
|
|
43
43
|
"edge-faint": string;
|
|
44
44
|
/** An open box's translucent tint, as the viewer's CSS writes it. */
|
|
45
45
|
container: string;
|
|
46
|
+
/** Target Depth grounds: a Deployment Target's fill, one step off its parent's per nesting level (see `targetStep`). */
|
|
47
|
+
"target-1": string;
|
|
48
|
+
"target-2": string;
|
|
49
|
+
"target-3": string;
|
|
46
50
|
}
|
|
51
|
+
/** How many Target Depth grounds there are; Targets nested deeper reuse the last. */
|
|
52
|
+
export declare const TARGET_STEPS = 3;
|
|
53
|
+
/** The Target Depth ground a Deployment Target at `depth` (1 for an outermost Target) draws on: 1 to `TARGET_STEPS`. */
|
|
54
|
+
export declare function targetStep(depth: number): 1 | 2 | 3;
|
|
47
55
|
export declare const PALETTES: Record<Theme, Palette>;
|
|
48
56
|
/**
|
|
49
57
|
* `rgba(r, g, b, a)` painted over a solid hex colour, as one solid hex. The
|