@webpieces/nx-webpieces-rules 0.4.898 → 0.4.900
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/package.json +7 -7
- package/src/configs/tag-truth-configs.d.ts +31 -5
- package/src/configs/tag-truth-configs.js +37 -6
- package/src/configs/tag-truth-configs.js.map +1 -1
- package/src/executors/generate/executor.js +3 -3
- package/src/executors/generate/executor.js.map +1 -1
- package/src/executors/visualize/executor.js +3 -1
- package/src/executors/visualize/executor.js.map +1 -1
- package/src/index.d.ts +3 -2
- package/src/index.js +5 -1
- package/src/index.js.map +1 -1
- package/src/lib/graph-color-modes.d.ts +8 -0
- package/src/lib/graph-color-modes.js +7 -0
- package/src/lib/graph-color-modes.js.map +1 -1
- package/src/lib/graph-filter.client.d.ts +5 -2
- package/src/lib/graph-filter.client.js +9 -4
- package/src/lib/graph-filter.client.js.map +1 -1
- package/src/lib/graph-generator.d.ts +3 -1
- package/src/lib/graph-generator.js +22 -3
- package/src/lib/graph-generator.js.map +1 -1
- package/src/lib/graph-legend.d.ts +8 -0
- package/src/lib/graph-legend.js +24 -2
- package/src/lib/graph-legend.js.map +1 -1
- package/src/lib/graph-products.d.ts +14 -0
- package/src/lib/graph-products.js +22 -1
- package/src/lib/graph-products.js.map +1 -1
- package/src/lib/graph-render-model.d.ts +19 -2
- package/src/lib/graph-render-model.js +19 -4
- package/src/lib/graph-render-model.js.map +1 -1
- package/src/lib/graph-visualizer.client.d.ts +2 -0
- package/src/lib/graph-visualizer.client.js +6 -0
- package/src/lib/graph-visualizer.client.js.map +1 -1
- package/src/lib/graph-visualizer.d.ts +11 -1
- package/src/lib/graph-visualizer.js +26 -7
- package/src/lib/graph-visualizer.js.map +1 -1
- package/src/lib/product-dependencies.d.ts +52 -0
- package/src/lib/product-dependencies.js +128 -0
- package/src/lib/product-dependencies.js.map +1 -0
- package/src/lib/tag-truth.d.ts +12 -3
- package/src/lib/tag-truth.js +27 -4
- package/src/lib/tag-truth.js.map +1 -1
- package/src/lib/visible-transitive-reduction.d.ts +33 -0
- package/src/lib/visible-transitive-reduction.js +60 -0
- package/src/lib/visible-transitive-reduction.js.map +1 -0
- package/src/rule-help.js +1 -1
- package/src/rule-help.js.map +1 -1
- package/src/rule-settings.js +1 -0
- package/src/rule-settings.js.map +1 -1
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
* - ProductPalette — the Product color mode's colors: a fixed palette of eight assigned in sorted
|
|
25
25
|
* product-name order, a neutral fill for a box shared by EVERY product, and a dashed white box for
|
|
26
26
|
* one in no product.
|
|
27
|
+
* - ProductBoundary — which dependency edges cross from one product into another (#1204), drawn
|
|
28
|
+
* dashed in the target product's color in the Product color mode.
|
|
27
29
|
*
|
|
28
30
|
* Membership is stable per checkout (it depends on tags and edges, never on a diff), so it is written
|
|
29
31
|
* into the committed dependencies.json / runtime-dependencies.json rather than into a sidecar.
|
|
@@ -61,6 +63,18 @@ export declare class ProductPalette {
|
|
|
61
63
|
/** True when some product is past the palette's eight, so the legend must say it is neutral. */
|
|
62
64
|
overflows(): boolean;
|
|
63
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Where a dependency edge crosses a product boundary (#1204), for the Product color mode: an edge
|
|
68
|
+
* A -> B crosses when B does not carry every product of A, and it is drawn dashed in the color of the
|
|
69
|
+
* product it crosses INTO, so the boundaries read at a glance while same-product edges stay quiet.
|
|
70
|
+
* Whether a crossing is ALLOWED is the product dependency matrix's call (product-dependencies.ts):
|
|
71
|
+
* with `product-tags` ON, generation already refused every crossing the matrix does not allow, so
|
|
72
|
+
* every crossing drawn is an allowed one.
|
|
73
|
+
*/
|
|
74
|
+
export declare class ProductBoundary {
|
|
75
|
+
/** The product the edge crosses into, or null when the target carries every product of the source. */
|
|
76
|
+
crossedInto(from: readonly string[], to: readonly string[]): string | null;
|
|
77
|
+
}
|
|
64
78
|
/**
|
|
65
79
|
* The architecture graph's product membership: declared seeds walked DOWN over `dependsOn`, where a
|
|
66
80
|
* project's own declared products are final.
|
|
@@ -25,12 +25,14 @@
|
|
|
25
25
|
* - ProductPalette — the Product color mode's colors: a fixed palette of eight assigned in sorted
|
|
26
26
|
* product-name order, a neutral fill for a box shared by EVERY product, and a dashed white box for
|
|
27
27
|
* one in no product.
|
|
28
|
+
* - ProductBoundary — which dependency edges cross from one product into another (#1204), drawn
|
|
29
|
+
* dashed in the target product's color in the Product color mode.
|
|
28
30
|
*
|
|
29
31
|
* Membership is stable per checkout (it depends on tags and edges, never on a diff), so it is written
|
|
30
32
|
* into the committed dependencies.json / runtime-dependencies.json rather than into a sidecar.
|
|
31
33
|
*/
|
|
32
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.RuntimeProductMembership = exports.ProductMembership = exports.ProductPalette = exports.PRODUCT_NONE_BORDER = exports.PRODUCT_NONE_FILL = exports.PRODUCT_SHARED_FILL = exports.PRODUCT_PALETTE_SIZE = exports.ProductColor = void 0;
|
|
35
|
+
exports.RuntimeProductMembership = exports.ProductMembership = exports.ProductBoundary = exports.ProductPalette = exports.PRODUCT_NONE_BORDER = exports.PRODUCT_NONE_FILL = exports.PRODUCT_SHARED_FILL = exports.PRODUCT_PALETTE_SIZE = exports.ProductColor = void 0;
|
|
34
36
|
// The same two text colors graph-color-modes.ts writes on every fill. Spelled here rather than
|
|
35
37
|
// imported because graph-color-modes.ts imports THIS file (for the palette), and a file-import cycle
|
|
36
38
|
// is refused by `no-file-import-cycles`.
|
|
@@ -107,6 +109,25 @@ class ProductPalette {
|
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
exports.ProductPalette = ProductPalette;
|
|
112
|
+
/**
|
|
113
|
+
* Where a dependency edge crosses a product boundary (#1204), for the Product color mode: an edge
|
|
114
|
+
* A -> B crosses when B does not carry every product of A, and it is drawn dashed in the color of the
|
|
115
|
+
* product it crosses INTO, so the boundaries read at a glance while same-product edges stay quiet.
|
|
116
|
+
* Whether a crossing is ALLOWED is the product dependency matrix's call (product-dependencies.ts):
|
|
117
|
+
* with `product-tags` ON, generation already refused every crossing the matrix does not allow, so
|
|
118
|
+
* every crossing drawn is an allowed one.
|
|
119
|
+
*/
|
|
120
|
+
class ProductBoundary {
|
|
121
|
+
/** The product the edge crosses into, or null when the target carries every product of the source. */
|
|
122
|
+
crossedInto(from, to) {
|
|
123
|
+
if (from.length === 0 || to.length === 0)
|
|
124
|
+
return null;
|
|
125
|
+
if (from.every((product) => to.includes(product)))
|
|
126
|
+
return null;
|
|
127
|
+
return to.find((product) => !from.includes(product)) ?? to[0];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.ProductBoundary = ProductBoundary;
|
|
110
131
|
/**
|
|
111
132
|
* The architecture graph's product membership: declared seeds walked DOWN over `dependsOn`, where a
|
|
112
133
|
* project's own declared products are final.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-products.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-products.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAKH,+FAA+F;AAC/F,qGAAqG;AACrG,yCAAyC;AACzC,MAAM,SAAS,GAAG,SAAS,CAAC;AAC5B,MAAM,UAAU,GAAG,SAAS,CAAC;AAE7B,2EAA2E;AAC3E,MAAa,YAAY;IAED;IACA;IACA;IAEA;IALpB,YACoB,OAAe,EACf,KAAa,EACb,SAAiB;IACjC,4FAA4F;IAC5E,SAAkB;QAJlB,YAAO,GAAP,OAAO,CAAQ;QACf,UAAK,GAAL,KAAK,CAAQ;QACb,cAAS,GAAT,SAAS,CAAQ;QAEjB,cAAS,GAAT,SAAS,CAAS;IACnC,CAAC;CACP;AARD,oCAQC;AAED,iGAAiG;AACjG,MAAM,cAAc,GAA2C;IAC3D,CAAC,SAAS,EAAE,UAAU,CAAC;IACvB,CAAC,SAAS,EAAE,SAAS,CAAC;IACtB,CAAC,SAAS,EAAE,UAAU,CAA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;gBACnE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACf,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;oBAAE,SAAS;gBAC9B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAClB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;QACL,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,kGAAkG;IAC1F,OAAO,CAAC,IAAY,EAAE,KAAmB;QAC7C,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,IAAI,EAAE,EAAE,CAAC;YACtD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,SAAS;YACb,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA7DD,4DA6DC","sourcesContent":["/**\n * Products on the architecture graphs (#1179).\n *\n * A monorepo can hold several PRODUCTS, each with its own clients and servers. A product is declared\n * on its entry points with the nx tag `product:<name>` (product-resolver.ts); everything else a\n * product consists of is DERIVED here, never declared:\n *\n * - ProductMembership — the dependency graph. A project's OWN `product:` tags are FINAL (#1201): a\n * project that declares any keeps exactly its declared set. An UNTAGGED project belongs to every\n * product whose tagged project reaches it by a downward walk over `dependsOn` — and that walk stops\n * at a tagged project, whose own dependencies are reached by its own seed walk. That closure is\n * everything that can change the product's behaviour, so it is what a reviewer of that product\n * reviews. It must start from EVERY entry point, clients and servers both: a client reaches its\n * server only over HTTP, never through an nx edge, so a server is in its product only because it is\n * tagged. Why final: a project is one product's, never two by accident — the example apps depend on\n * the platform libraries, and a platform library tagged `product:platform` must not be painted\n * `example` because an example reaches it. A published library whose entry points live in OTHER\n * repos carries its own tag for exactly that reason: no in-repo walk can ever reach it correctly.\n * - RuntimeProductMembership — the runtime graph, under the same rule. A service that already carries\n * products (declared, or derived on the dependency graph above) keeps exactly them; a service with\n * none belongs to every product whose service reaches it over RUNTIME `dependsOn`, including through\n * a queue to its consumers, and that walk stops at a service with products of its own. A call from\n * one product into another product's service still shows — as the runtime EDGE between them.\n * - ProductPalette — the Product color mode's colors: a fixed palette of eight assigned in sorted\n * product-name order, a neutral fill for a box shared by EVERY product, and a dashed white box for\n * one in no product.\n *\n * Membership is stable per checkout (it depends on tags and edges, never on a diff), so it is written\n * into the committed dependencies.json / runtime-dependencies.json rather than into a sidecar.\n */\n\nimport type { EnhancedGraph } from './graph-sorter';\nimport type { RuntimeGraph } from './runtime-graph-model';\n\n// The same two text colors graph-color-modes.ts writes on every fill. Spelled here rather than\n// imported because graph-color-modes.ts imports THIS file (for the palette), and a file-import cycle\n// is refused by `no-file-import-cycles`.\nconst DARK_TEXT = '#1a1c22';\nconst LIGHT_TEXT = '#ffffff';\n\n/** One product's color, and the text color that reads on it. Data-only. */\nexport class ProductColor {\n constructor(\n public readonly product: string,\n public readonly color: string,\n public readonly fontColor: string,\n /** False for a product past the palette's eight, which is painted with the neutral fill. */\n public readonly inPalette: boolean,\n ) {}\n}\n\n/** The eight product colors, in assignment order. Distinct from every runtime and role color. */\nconst PRODUCT_COLORS: readonly (readonly [string, string])[] = [\n ['#3f6fb5', LIGHT_TEXT],\n ['#f28e2b', DARK_TEXT],\n ['#c0392b', LIGHT_TEXT],\n ['#5cb8b2', DARK_TEXT],\n ['#3d8b3d', LIGHT_TEXT],\n ['#edc948', DARK_TEXT],\n ['#8e5ea2', LIGHT_TEXT],\n ['#ff9da7', DARK_TEXT],\n];\n\n/** How many products get a color of their own; any further product uses the neutral fill. */\nexport const PRODUCT_PALETTE_SIZE = PRODUCT_COLORS.length;\n\n/** A box shared by EVERY product, and every product past the palette's eight. */\nexport const PRODUCT_SHARED_FILL = '#c9ced8';\n/** A box in no product: white, with a dashed border. */\nexport const PRODUCT_NONE_FILL = '#ffffff';\nexport const PRODUCT_NONE_BORDER = '#8a90a0';\n\nexport class ProductPalette {\n /** Every declared product, sorted, each with its color. */\n readonly colors: ProductColor[];\n\n constructor(products: readonly string[]) {\n const sorted = [...new Set(products)].sort();\n this.colors = sorted.map((product: string, index: number): ProductColor => {\n const entry = PRODUCT_COLORS[index];\n if (entry === undefined) return new ProductColor(product, PRODUCT_SHARED_FILL, DARK_TEXT, false);\n return new ProductColor(product, entry[0], entry[1], true);\n });\n }\n\n /** Every product carried by a project of the graph, as one palette. */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static fromGraph(graph: EnhancedGraph): ProductPalette {\n const all: string[] = [];\n for (const entry of Object.values(graph)) all.push(...(entry.products ?? []));\n return new ProductPalette(all);\n }\n\n names(): string[] {\n return this.colors.map((color: ProductColor): string => color.product);\n }\n\n colorOf(product: string): ProductColor {\n return (\n this.colors.find((color: ProductColor): boolean => color.product === product) ??\n new ProductColor(product, PRODUCT_SHARED_FILL, DARK_TEXT, false)\n );\n }\n\n /** True for a box carrying every product of a workspace that declares two or more. */\n sharedByAll(products: readonly string[]): boolean {\n return this.colors.length > 1 && this.colors.every((color: ProductColor): boolean => products.includes(color.product));\n }\n\n /** True when some product is past the palette's eight, so the legend must say it is neutral. */\n overflows(): boolean {\n return this.colors.some((color: ProductColor): boolean => !color.inPalette);\n }\n}\n\n/**\n * The architecture graph's product membership: declared seeds walked DOWN over `dependsOn`, where a\n * project's own declared products are final.\n */\nexport class ProductMembership {\n /**\n * @param seeds project → the products it DECLARES (its `product:` tags)\n * @returns project → its sorted products: exactly its declared set when it declares any; otherwise\n * every product whose tagged project reaches it without passing through another tagged\n * project. A project in no product is absent, so with no tag anywhere the map is empty.\n */\n compute(seeds: ReadonlyMap<string, readonly string[]>, graph: EnhancedGraph): Map<string, string[]> {\n const declared = new Map<string, readonly string[]>();\n seeds.forEach((products: readonly string[], seed: string): void => {\n if (products.length > 0 && graph[seed] !== undefined) declared.set(seed, products);\n });\n const members = new Map<string, Set<string>>();\n declared.forEach((products: readonly string[], seed: string): void => {\n members.set(seed, new Set(products));\n });\n declared.forEach((products: readonly string[], seed: string): void => {\n for (const project of this.closure(seed, graph, declared)) {\n const set = members.get(project) ?? new Set<string>();\n for (const product of products) set.add(product);\n members.set(project, set);\n }\n });\n const result = new Map<string, string[]>();\n members.forEach((set: Set<string>, project: string): void => {\n result.set(project, [...set].sort());\n });\n return result;\n }\n\n /**\n * Every UNTAGGED project `seed` reaches through `dependsOn`. A tagged project is neither collected\n * nor walked through: its products are final, and its own seed walk covers its dependencies.\n */\n private closure(seed: string, graph: EnhancedGraph, declared: ReadonlyMap<string, readonly string[]>): Set<string> {\n const seen = new Set<string>([seed]);\n const reached = new Set<string>();\n const stack = [seed];\n while (stack.length > 0) {\n const project = stack.pop() as string;\n for (const dep of graph[project]?.dependsOn ?? []) {\n if (seen.has(dep)) continue;\n seen.add(dep);\n if (declared.has(dep)) continue;\n reached.add(dep);\n stack.push(dep);\n }\n }\n return reached;\n }\n}\n\n/**\n * The runtime graph's product membership: services that carry products walked over RUNTIME\n * `dependsOn`, where a service's own products are final.\n */\nexport class RuntimeProductMembership {\n /**\n * Stamp `products` onto every service of `graph` that some product reaches. Seeds are the\n * services whose dependencies.json entry carries `products`, and each keeps exactly those; a\n * service with none gets every product whose seed reaches it without passing through another\n * seed. A `queue:<Api.method>` dependency is followed to that queue's consumers. A service in no\n * product gets no field.\n */\n apply(graph: RuntimeGraph, projects: EnhancedGraph): void {\n const seeds = new Map<string, readonly string[]>();\n for (const name of Object.keys(graph.services)) {\n const own = projects[name]?.products ?? [];\n if (own.length > 0) seeds.set(name, own);\n }\n const members = new Map<string, Set<string>>();\n seeds.forEach((own: readonly string[], name: string): void => {\n members.set(name, new Set(own));\n });\n seeds.forEach((own: readonly string[], name: string): void => {\n for (const reached of this.closure(name, graph, seeds)) {\n const set = members.get(reached) ?? new Set<string>();\n for (const product of own) set.add(product);\n members.set(reached, set);\n }\n });\n members.forEach((set: Set<string>, name: string): void => {\n const service = graph.services[name];\n if (service !== undefined) service.products = [...set].sort();\n });\n }\n\n /** Every service WITHOUT products of its own that `seed` reaches; a seed is neither collected nor walked through. */\n private closure(seed: string, graph: RuntimeGraph, seeds: ReadonlyMap<string, readonly string[]>): Set<string> {\n const seen = new Set<string>([seed]);\n const reached = new Set<string>();\n const stack = [seed];\n while (stack.length > 0) {\n const name = stack.pop() as string;\n for (const next of this.callees(name, graph)) {\n if (seen.has(next) || graph.services[next] === undefined) continue;\n seen.add(next);\n if (seeds.has(next)) continue;\n reached.add(next);\n stack.push(next);\n }\n }\n return reached;\n }\n\n /** The services one service calls: direct ones, and the consumers behind every queue it feeds. */\n private callees(name: string, graph: RuntimeGraph): string[] {\n const callees: string[] = [];\n for (const dep of graph.services[name]?.dependsOn ?? []) {\n if (!dep.startsWith('queue:')) {\n callees.push(dep);\n continue;\n }\n callees.push(...(graph.queues[dep.slice('queue:'.length)]?.consumedBy ?? []));\n }\n return callees;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"graph-products.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-products.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AAKH,+FAA+F;AAC/F,qGAAqG;AACrG,yCAAyC;AACzC,MAAM,SAAS,GAAG,SAAS,CAAC;AAC5B,MAAM,UAAU,GAAG,SAAS,CAAC;AAE7B,2EAA2E;AAC3E,MAAa,YAAY;IAED;IACA;IACA;IAEA;IALpB,YACoB,OAAe,EACf,KAAa,EACb,SAAiB;IACjC,4FAA4F;IAC5E,SAAkB;QAJlB,YAAO,GAAP,OAAO,CAAQ;QACf,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ACtD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,SAAS;YACb,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA7DD,4DA6DC","sourcesContent":["/**\n * Products on the architecture graphs (#1179).\n *\n * A monorepo can hold several PRODUCTS, each with its own clients and servers. A product is declared\n * on its entry points with the nx tag `product:<name>` (product-resolver.ts); everything else a\n * product consists of is DERIVED here, never declared:\n *\n * - ProductMembership — the dependency graph. A project's OWN `product:` tags are FINAL (#1201): a\n * project that declares any keeps exactly its declared set. An UNTAGGED project belongs to every\n * product whose tagged project reaches it by a downward walk over `dependsOn` — and that walk stops\n * at a tagged project, whose own dependencies are reached by its own seed walk. That closure is\n * everything that can change the product's behaviour, so it is what a reviewer of that product\n * reviews. It must start from EVERY entry point, clients and servers both: a client reaches its\n * server only over HTTP, never through an nx edge, so a server is in its product only because it is\n * tagged. Why final: a project is one product's, never two by accident — the example apps depend on\n * the platform libraries, and a platform library tagged `product:platform` must not be painted\n * `example` because an example reaches it. A published library whose entry points live in OTHER\n * repos carries its own tag for exactly that reason: no in-repo walk can ever reach it correctly.\n * - RuntimeProductMembership — the runtime graph, under the same rule. A service that already carries\n * products (declared, or derived on the dependency graph above) keeps exactly them; a service with\n * none belongs to every product whose service reaches it over RUNTIME `dependsOn`, including through\n * a queue to its consumers, and that walk stops at a service with products of its own. A call from\n * one product into another product's service still shows — as the runtime EDGE between them.\n * - ProductPalette — the Product color mode's colors: a fixed palette of eight assigned in sorted\n * product-name order, a neutral fill for a box shared by EVERY product, and a dashed white box for\n * one in no product.\n * - ProductBoundary — which dependency edges cross from one product into another (#1204), drawn\n * dashed in the target product's color in the Product color mode.\n *\n * Membership is stable per checkout (it depends on tags and edges, never on a diff), so it is written\n * into the committed dependencies.json / runtime-dependencies.json rather than into a sidecar.\n */\n\nimport type { EnhancedGraph } from './graph-sorter';\nimport type { RuntimeGraph } from './runtime-graph-model';\n\n// The same two text colors graph-color-modes.ts writes on every fill. Spelled here rather than\n// imported because graph-color-modes.ts imports THIS file (for the palette), and a file-import cycle\n// is refused by `no-file-import-cycles`.\nconst DARK_TEXT = '#1a1c22';\nconst LIGHT_TEXT = '#ffffff';\n\n/** One product's color, and the text color that reads on it. Data-only. */\nexport class ProductColor {\n constructor(\n public readonly product: string,\n public readonly color: string,\n public readonly fontColor: string,\n /** False for a product past the palette's eight, which is painted with the neutral fill. */\n public readonly inPalette: boolean,\n ) {}\n}\n\n/** The eight product colors, in assignment order. Distinct from every runtime and role color. */\nconst PRODUCT_COLORS: readonly (readonly [string, string])[] = [\n ['#3f6fb5', LIGHT_TEXT],\n ['#f28e2b', DARK_TEXT],\n ['#c0392b', LIGHT_TEXT],\n ['#5cb8b2', DARK_TEXT],\n ['#3d8b3d', LIGHT_TEXT],\n ['#edc948', DARK_TEXT],\n ['#8e5ea2', LIGHT_TEXT],\n ['#ff9da7', DARK_TEXT],\n];\n\n/** How many products get a color of their own; any further product uses the neutral fill. */\nexport const PRODUCT_PALETTE_SIZE = PRODUCT_COLORS.length;\n\n/** A box shared by EVERY product, and every product past the palette's eight. */\nexport const PRODUCT_SHARED_FILL = '#c9ced8';\n/** A box in no product: white, with a dashed border. */\nexport const PRODUCT_NONE_FILL = '#ffffff';\nexport const PRODUCT_NONE_BORDER = '#8a90a0';\n\nexport class ProductPalette {\n /** Every declared product, sorted, each with its color. */\n readonly colors: ProductColor[];\n\n constructor(products: readonly string[]) {\n const sorted = [...new Set(products)].sort();\n this.colors = sorted.map((product: string, index: number): ProductColor => {\n const entry = PRODUCT_COLORS[index];\n if (entry === undefined) return new ProductColor(product, PRODUCT_SHARED_FILL, DARK_TEXT, false);\n return new ProductColor(product, entry[0], entry[1], true);\n });\n }\n\n /** Every product carried by a project of the graph, as one palette. */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static fromGraph(graph: EnhancedGraph): ProductPalette {\n const all: string[] = [];\n for (const entry of Object.values(graph)) all.push(...(entry.products ?? []));\n return new ProductPalette(all);\n }\n\n names(): string[] {\n return this.colors.map((color: ProductColor): string => color.product);\n }\n\n colorOf(product: string): ProductColor {\n return (\n this.colors.find((color: ProductColor): boolean => color.product === product) ??\n new ProductColor(product, PRODUCT_SHARED_FILL, DARK_TEXT, false)\n );\n }\n\n /** True for a box carrying every product of a workspace that declares two or more. */\n sharedByAll(products: readonly string[]): boolean {\n return this.colors.length > 1 && this.colors.every((color: ProductColor): boolean => products.includes(color.product));\n }\n\n /** True when some product is past the palette's eight, so the legend must say it is neutral. */\n overflows(): boolean {\n return this.colors.some((color: ProductColor): boolean => !color.inPalette);\n }\n}\n\n/**\n * Where a dependency edge crosses a product boundary (#1204), for the Product color mode: an edge\n * A -> B crosses when B does not carry every product of A, and it is drawn dashed in the color of the\n * product it crosses INTO, so the boundaries read at a glance while same-product edges stay quiet.\n * Whether a crossing is ALLOWED is the product dependency matrix's call (product-dependencies.ts):\n * with `product-tags` ON, generation already refused every crossing the matrix does not allow, so\n * every crossing drawn is an allowed one.\n */\nexport class ProductBoundary {\n /** The product the edge crosses into, or null when the target carries every product of the source. */\n crossedInto(from: readonly string[], to: readonly string[]): string | null {\n if (from.length === 0 || to.length === 0) return null;\n if (from.every((product: string): boolean => to.includes(product))) return null;\n return to.find((product: string): boolean => !from.includes(product)) ?? to[0];\n }\n}\n\n/**\n * The architecture graph's product membership: declared seeds walked DOWN over `dependsOn`, where a\n * project's own declared products are final.\n */\nexport class ProductMembership {\n /**\n * @param seeds project → the products it DECLARES (its `product:` tags)\n * @returns project → its sorted products: exactly its declared set when it declares any; otherwise\n * every product whose tagged project reaches it without passing through another tagged\n * project. A project in no product is absent, so with no tag anywhere the map is empty.\n */\n compute(seeds: ReadonlyMap<string, readonly string[]>, graph: EnhancedGraph): Map<string, string[]> {\n const declared = new Map<string, readonly string[]>();\n seeds.forEach((products: readonly string[], seed: string): void => {\n if (products.length > 0 && graph[seed] !== undefined) declared.set(seed, products);\n });\n const members = new Map<string, Set<string>>();\n declared.forEach((products: readonly string[], seed: string): void => {\n members.set(seed, new Set(products));\n });\n declared.forEach((products: readonly string[], seed: string): void => {\n for (const project of this.closure(seed, graph, declared)) {\n const set = members.get(project) ?? new Set<string>();\n for (const product of products) set.add(product);\n members.set(project, set);\n }\n });\n const result = new Map<string, string[]>();\n members.forEach((set: Set<string>, project: string): void => {\n result.set(project, [...set].sort());\n });\n return result;\n }\n\n /**\n * Every UNTAGGED project `seed` reaches through `dependsOn`. A tagged project is neither collected\n * nor walked through: its products are final, and its own seed walk covers its dependencies.\n */\n private closure(seed: string, graph: EnhancedGraph, declared: ReadonlyMap<string, readonly string[]>): Set<string> {\n const seen = new Set<string>([seed]);\n const reached = new Set<string>();\n const stack = [seed];\n while (stack.length > 0) {\n const project = stack.pop() as string;\n for (const dep of graph[project]?.dependsOn ?? []) {\n if (seen.has(dep)) continue;\n seen.add(dep);\n if (declared.has(dep)) continue;\n reached.add(dep);\n stack.push(dep);\n }\n }\n return reached;\n }\n}\n\n/**\n * The runtime graph's product membership: services that carry products walked over RUNTIME\n * `dependsOn`, where a service's own products are final.\n */\nexport class RuntimeProductMembership {\n /**\n * Stamp `products` onto every service of `graph` that some product reaches. Seeds are the\n * services whose dependencies.json entry carries `products`, and each keeps exactly those; a\n * service with none gets every product whose seed reaches it without passing through another\n * seed. A `queue:<Api.method>` dependency is followed to that queue's consumers. A service in no\n * product gets no field.\n */\n apply(graph: RuntimeGraph, projects: EnhancedGraph): void {\n const seeds = new Map<string, readonly string[]>();\n for (const name of Object.keys(graph.services)) {\n const own = projects[name]?.products ?? [];\n if (own.length > 0) seeds.set(name, own);\n }\n const members = new Map<string, Set<string>>();\n seeds.forEach((own: readonly string[], name: string): void => {\n members.set(name, new Set(own));\n });\n seeds.forEach((own: readonly string[], name: string): void => {\n for (const reached of this.closure(name, graph, seeds)) {\n const set = members.get(reached) ?? new Set<string>();\n for (const product of own) set.add(product);\n members.set(reached, set);\n }\n });\n members.forEach((set: Set<string>, name: string): void => {\n const service = graph.services[name];\n if (service !== undefined) service.products = [...set].sort();\n });\n }\n\n /** Every service WITHOUT products of its own that `seed` reaches; a seed is neither collected nor walked through. */\n private closure(seed: string, graph: RuntimeGraph, seeds: ReadonlyMap<string, readonly string[]>): Set<string> {\n const seen = new Set<string>([seed]);\n const reached = new Set<string>();\n const stack = [seed];\n while (stack.length > 0) {\n const name = stack.pop() as string;\n for (const next of this.callees(name, graph)) {\n if (seen.has(next) || graph.services[next] === undefined) continue;\n seen.add(next);\n if (seeds.has(next)) continue;\n reached.add(next);\n stack.push(next);\n }\n }\n return reached;\n }\n\n /** The services one service calls: direct ones, and the consumers behind every queue it feeds. */\n private callees(name: string, graph: RuntimeGraph): string[] {\n const callees: string[] = [];\n for (const dep of graph.services[name]?.dependsOn ?? []) {\n if (!dep.startsWith('queue:')) {\n callees.push(dep);\n continue;\n }\n callees.push(...(graph.queues[dep.slice('queue:'.length)]?.consumedBy ?? []));\n }\n return callees;\n }\n}\n"]}
|
|
@@ -31,7 +31,19 @@ export declare class RenderEdge {
|
|
|
31
31
|
readonly to: string;
|
|
32
32
|
readonly dot: string;
|
|
33
33
|
readonly id: string;
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* The statement the architecture page's Product color mode draws instead of `dot` (#1204): a
|
|
36
|
+
* dependency crossing into another product, dashed in that product's color. Null for every
|
|
37
|
+
* other edge, which draws `dot` in every mode.
|
|
38
|
+
*/
|
|
39
|
+
readonly productDot: string | null;
|
|
40
|
+
constructor(from: string, to: string, dot: string, id: string,
|
|
41
|
+
/**
|
|
42
|
+
* The statement the architecture page's Product color mode draws instead of `dot` (#1204): a
|
|
43
|
+
* dependency crossing into another product, dashed in that product's color. Null for every
|
|
44
|
+
* other edge, which draws `dot` in every mode.
|
|
45
|
+
*/
|
|
46
|
+
productDot?: string | null);
|
|
35
47
|
}
|
|
36
48
|
/** The immutable drawable snapshot carried by a generated page. */
|
|
37
49
|
export declare class GraphRenderModel {
|
|
@@ -55,7 +67,12 @@ export declare class GraphRenderModel {
|
|
|
55
67
|
/** A box drawn differently per color mode; `fullDot` carries its RUNTIME statement. */
|
|
56
68
|
styledNode(facts: NodeFacts, modes: NodeModeDots): string;
|
|
57
69
|
completeEndpoints(): void;
|
|
58
|
-
|
|
70
|
+
/**
|
|
71
|
+
* One edge. `productAttrs`, when not empty, is the attribute list the Product color mode adds to
|
|
72
|
+
* the statement (a later list overrides an earlier one in DOT), e.g. a cross-product dependency's
|
|
73
|
+
* dash and color; `fullDot` always carries the plain statement.
|
|
74
|
+
*/
|
|
75
|
+
edge(from: string, to: string, dot: string, productAttrs?: string): string;
|
|
59
76
|
}
|
|
60
77
|
/** Shared filter chrome and script-safe JSON for pages opened directly from disk. */
|
|
61
78
|
export declare class GraphFilterAssets {
|
|
@@ -47,11 +47,19 @@ class RenderEdge {
|
|
|
47
47
|
to;
|
|
48
48
|
dot;
|
|
49
49
|
id;
|
|
50
|
-
|
|
50
|
+
productDot;
|
|
51
|
+
constructor(from, to, dot, id,
|
|
52
|
+
/**
|
|
53
|
+
* The statement the architecture page's Product color mode draws instead of `dot` (#1204): a
|
|
54
|
+
* dependency crossing into another product, dashed in that product's color. Null for every
|
|
55
|
+
* other edge, which draws `dot` in every mode.
|
|
56
|
+
*/
|
|
57
|
+
productDot = null) {
|
|
51
58
|
this.from = from;
|
|
52
59
|
this.to = to;
|
|
53
60
|
this.dot = dot;
|
|
54
61
|
this.id = id;
|
|
62
|
+
this.productDot = productDot;
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
exports.RenderEdge = RenderEdge;
|
|
@@ -113,10 +121,17 @@ class GraphRenderModel {
|
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
123
|
}
|
|
116
|
-
|
|
124
|
+
/**
|
|
125
|
+
* One edge. `productAttrs`, when not empty, is the attribute list the Product color mode adds to
|
|
126
|
+
* the statement (a later list overrides an earlier one in DOT), e.g. a cross-product dependency's
|
|
127
|
+
* dash and color; `fullDot` always carries the plain statement.
|
|
128
|
+
*/
|
|
129
|
+
edge(from, to, dot, productAttrs = '') {
|
|
117
130
|
const id = `wp-real-edge-${this.edges.length}`;
|
|
118
|
-
const
|
|
119
|
-
|
|
131
|
+
const base = `${dot.slice(0, -2)} [id="${id}"]`;
|
|
132
|
+
const statement = `${base};\n`;
|
|
133
|
+
const productDot = productAttrs === '' ? null : `${base} [${productAttrs}];\n`;
|
|
134
|
+
this.edges.push(new RenderEdge(from, to, statement, id, productDot));
|
|
120
135
|
return statement;
|
|
121
136
|
}
|
|
122
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-render-model.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-render-model.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,2DAA2E;AAE3E;;;;;;;;;GASG;AACH,MAAa,UAAU;IAEC;IACA;IACA;IACA;IACA;IACA;IANpB,YACoB,EAAU,EACV,GAAW,EACX,KAA0B,EAC1B,IAAqB,EACrB,QAAkB,EAClB,YAAsB,EAAE;QALxB,OAAE,GAAF,EAAE,CAAQ;QACV,QAAG,GAAH,GAAG,CAAQ;QACX,UAAK,GAAL,KAAK,CAAqB;QAC1B,SAAI,GAAJ,IAAI,CAAiB;QACrB,aAAQ,GAAR,QAAQ,CAAU;QAClB,cAAS,GAAT,SAAS,CAAe;IACzC,CAAC;CACP;AATD,gCASC;AAED,gGAAgG;AAChG,MAAa,QAAQ;IAEG;IACA;IACA;IAHpB,YACoB,KAAa,EACb,IAAY,EACZ,UAAoB;QAFpB,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IA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AC;IAC1D,CAAC;IAED,IAAI;QACA,OAAO,CACH,qFAAqF;YACrF,uEAAuE;YACvE,iDAAiD,CACpD,CAAC;IACN,CAAC;IAED,MAAM;QACF,OAAO,CACH,8EAA8E;YAC9E,mEAAmE;YACnE,sEAAsE,CACzE,CAAC;IACN,CAAC;CACJ;AApBD,8CAoBC","sourcesContent":["import { dotValue } from './dot-syntax';\nimport { LevelBand } from './graph-level-bands';\nimport { LegendFacts, NodeFacts, NodeModeDots } from './graph-color-modes';\n\n/**\n * Renderer-owned records, captured while emitting DOT, never recovered by parsing labels.\n *\n * `dot` is the statement `fullDot` carries. `modes` carries per-mode statements in both viewers; `tags` carries declared service/project\n * metadata. Runtime auxiliary entities leave tags null so facets count services and retain context\n * separately.\n *\n * `products` is set on BOTH graphs (#1179): the products a box belongs to, which each page's product\n * filter matches on. Empty for a box in no product.\n */\nexport class RenderNode {\n constructor(\n public readonly id: string,\n public readonly dot: string,\n public readonly modes: NodeModeDots | null,\n public readonly tags: NodeTags | null,\n public readonly products: string[],\n public readonly queueKeys: string[] = [],\n ) {}\n}\n\n/** What the architecture page's Filter matches a box on: its level, role and framework tags. */\nexport class NodeTags {\n constructor(\n public readonly level: number,\n public readonly role: string,\n public readonly frameworks: string[],\n ) {}\n}\n\nexport class RenderEdge {\n constructor(\n public readonly from: string,\n public readonly to: string,\n public readonly dot: string,\n public readonly id: string,\n ) {}\n}\n\n/** The immutable drawable snapshot carried by a generated page. */\nexport class GraphRenderModel {\n viewer: 'architecture' | 'runtime' = 'architecture';\n readonly nodes: RenderNode[] = [];\n readonly edges: RenderEdge[] = [];\n bands: LevelBand[] = [];\n fullDot = '';\n header = '';\n footer = '';\n /** The colors and roles in use, so the page's legend lists exactly those (architecture graph). */\n legend = new LegendFacts();\n\n node(id: string, dot: string, products: string[] = [], queueKeys: string[] = []): string {\n this.nodes.push(new RenderNode(id, dot, null, null, products, queueKeys));\n return dot;\n }\n\n /**\n * Every product a declared box (a queue, a cron trigger, an external system) inherits from the\n * services its edges touch (#1179): it belongs to whichever product's services it is attached to.\n * Called by the runtime graph once every edge is emitted; RenderNode is immutable, so a node gains\n * its products by being replaced.\n */\n attachProducts(isService: (id: string) => boolean): void {\n const byId = new Map<string, RenderNode>();\n for (const node of this.nodes) byId.set(node.id, node);\n for (let index = 0; index < this.nodes.length; index++) {\n const node = this.nodes[index];\n if (isService(node.id)) continue;\n const inherited = new Set<string>();\n for (const edge of this.edges) {\n const other =\n edge.from === node.id ? edge.to : edge.to === node.id ? edge.from : null;\n if (other === null || !isService(other)) continue;\n for (const product of byId.get(other)?.products ?? []) inherited.add(product);\n }\n if (inherited.size === 0) continue;\n this.nodes[index] = new RenderNode(\n node.id,\n node.dot,\n node.modes,\n node.tags,\n [...inherited].sort(),\n node.queueKeys,\n );\n }\n }\n\n /** A box drawn differently per color mode; `fullDot` carries its RUNTIME statement. */\n styledNode(facts: NodeFacts, modes: NodeModeDots): string {\n this.nodes.push(\n new RenderNode(\n facts.nodeId,\n modes.runtime,\n modes,\n new NodeTags(facts.level, facts.role, facts.frameworks),\n facts.products,\n ),\n );\n return modes.runtime;\n }\n\n completeEndpoints(): void {\n const ids = new Set(this.nodes.map((node) => node.id));\n for (const edge of this.edges) {\n for (const id of [edge.from, edge.to]) {\n if (ids.has(id)) continue;\n ids.add(id);\n this.node(id, ` \"${dotValue(id)}\";\\n`);\n }\n }\n }\n\n edge(from: string, to: string, dot: string): string {\n const id = `wp-real-edge-${this.edges.length}`;\n const statement = `${dot.slice(0, -2)} [id=\"${id}\"];\\n`;\n this.edges.push(new RenderEdge(from, to, statement, id));\n return statement;\n }\n}\n\n/** Shared filter chrome and script-safe JSON for pages opened directly from disk. */\nexport class GraphFilterAssets {\n json<T>(value: T): string {\n return JSON.stringify(value).replace(/</g, '\\\\u003c');\n }\n\n html(): string {\n return (\n '<p id=\"wp-filter-status\" hidden>Filtering: <strong id=\"wp-filter-anchor\"></strong> ' +\n '<button id=\"wp-filter-off\" type=\"button\">Turn off Filter</button></p>' +\n '<p id=\"wp-graph-error\" role=\"alert\" hidden></p>'\n );\n }\n\n styles(): string {\n return (\n '#wp-filter-status { text-align:center; } #wp-graph-error { color:#b71c1c; } ' +\n '#graph .wp-filter-anchor polygon, #graph .wp-filter-anchor path, ' +\n '#graph .wp-filter-anchor ellipse { stroke:#8b3cf0; stroke-width:3; }'\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"graph-render-model.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-render-model.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,2DAA2E;AAE3E;;;;;;;;;GASG;AACH,MAAa,UAAU;IAEC;IACA;IACA;IACA;IACA;IACA;IANpB,YACoB,EAAU,EACV,GAAW,EACX,KAA0B,EAC1B,IAAqB,EACrB,QAAkB,EAClB,YAAsB,EAAE;QALxB,OAAE,GAAF,EAAE,CAAQ;QACV,QAAG,GAAH,GAAG,CAAQ;QACX,UAAK,GAAL,KAAK,CAAqB;QAC1B,SAAI,GAAJ,IAAI,CAAiB;QACrB,aAAQ,GAAR,QAAQ,CAAU;QAClB,cAAS,GAAT,SAAS,CAAe;IACzC,CAAC;CACP;AATD,gCASC;AAED,gGAAgG;AAChG,MAAa,QAAQ;IAEG;IACA;IACA;IAHpB,YACoB,KAAa,EACb,IAAY,EACZ,UAAoB;QAFpB,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAU;IACrC,CAAC;CACP;AAND,4BAMC;AAED,MAAa,UAAU;IAEC;IACA;IACA;IACA;IAMA;IAVpB,YACoB,IAAY,EACZ,EAAU,EACV,GAAW,EACX,EAAU;IAC1B;;;;OAIG;IACa,aAA4B,IAAI;QAThC,SAAI,GAAJ,IAAI,CAAQ;QACZ,OAAE,GAAF,EAAE,CAAQ;QACV,QAAG,GAAH,GAAG,CAAQ;QACX,OAAE,GAAF,EAAE,CAAQ;QAMV,eAAU,GA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ACrF,uEAAuE;YACvE,iDAAiD,CACpD,CAAC;IACN,CAAC;IAED,MAAM;QACF,OAAO,CACH,8EAA8E;YAC9E,mEAAmE;YACnE,sEAAsE,CACzE,CAAC;IACN,CAAC;CACJ;AApBD,8CAoBC","sourcesContent":["import { dotValue } from './dot-syntax';\nimport { LevelBand } from './graph-level-bands';\nimport { LegendFacts, NodeFacts, NodeModeDots } from './graph-color-modes';\n\n/**\n * Renderer-owned records, captured while emitting DOT, never recovered by parsing labels.\n *\n * `dot` is the statement `fullDot` carries. `modes` carries per-mode statements in both viewers; `tags` carries declared service/project\n * metadata. Runtime auxiliary entities leave tags null so facets count services and retain context\n * separately.\n *\n * `products` is set on BOTH graphs (#1179): the products a box belongs to, which each page's product\n * filter matches on. Empty for a box in no product.\n */\nexport class RenderNode {\n constructor(\n public readonly id: string,\n public readonly dot: string,\n public readonly modes: NodeModeDots | null,\n public readonly tags: NodeTags | null,\n public readonly products: string[],\n public readonly queueKeys: string[] = [],\n ) {}\n}\n\n/** What the architecture page's Filter matches a box on: its level, role and framework tags. */\nexport class NodeTags {\n constructor(\n public readonly level: number,\n public readonly role: string,\n public readonly frameworks: string[],\n ) {}\n}\n\nexport class RenderEdge {\n constructor(\n public readonly from: string,\n public readonly to: string,\n public readonly dot: string,\n public readonly id: string,\n /**\n * The statement the architecture page's Product color mode draws instead of `dot` (#1204): a\n * dependency crossing into another product, dashed in that product's color. Null for every\n * other edge, which draws `dot` in every mode.\n */\n public readonly productDot: string | null = null,\n ) {}\n}\n\n/** The immutable drawable snapshot carried by a generated page. */\nexport class GraphRenderModel {\n viewer: 'architecture' | 'runtime' = 'architecture';\n readonly nodes: RenderNode[] = [];\n readonly edges: RenderEdge[] = [];\n bands: LevelBand[] = [];\n fullDot = '';\n header = '';\n footer = '';\n /** The colors and roles in use, so the page's legend lists exactly those (architecture graph). */\n legend = new LegendFacts();\n\n node(id: string, dot: string, products: string[] = [], queueKeys: string[] = []): string {\n this.nodes.push(new RenderNode(id, dot, null, null, products, queueKeys));\n return dot;\n }\n\n /**\n * Every product a declared box (a queue, a cron trigger, an external system) inherits from the\n * services its edges touch (#1179): it belongs to whichever product's services it is attached to.\n * Called by the runtime graph once every edge is emitted; RenderNode is immutable, so a node gains\n * its products by being replaced.\n */\n attachProducts(isService: (id: string) => boolean): void {\n const byId = new Map<string, RenderNode>();\n for (const node of this.nodes) byId.set(node.id, node);\n for (let index = 0; index < this.nodes.length; index++) {\n const node = this.nodes[index];\n if (isService(node.id)) continue;\n const inherited = new Set<string>();\n for (const edge of this.edges) {\n const other =\n edge.from === node.id ? edge.to : edge.to === node.id ? edge.from : null;\n if (other === null || !isService(other)) continue;\n for (const product of byId.get(other)?.products ?? []) inherited.add(product);\n }\n if (inherited.size === 0) continue;\n this.nodes[index] = new RenderNode(\n node.id,\n node.dot,\n node.modes,\n node.tags,\n [...inherited].sort(),\n node.queueKeys,\n );\n }\n }\n\n /** A box drawn differently per color mode; `fullDot` carries its RUNTIME statement. */\n styledNode(facts: NodeFacts, modes: NodeModeDots): string {\n this.nodes.push(\n new RenderNode(\n facts.nodeId,\n modes.runtime,\n modes,\n new NodeTags(facts.level, facts.role, facts.frameworks),\n facts.products,\n ),\n );\n return modes.runtime;\n }\n\n completeEndpoints(): void {\n const ids = new Set(this.nodes.map((node) => node.id));\n for (const edge of this.edges) {\n for (const id of [edge.from, edge.to]) {\n if (ids.has(id)) continue;\n ids.add(id);\n this.node(id, ` \"${dotValue(id)}\";\\n`);\n }\n }\n }\n\n /**\n * One edge. `productAttrs`, when not empty, is the attribute list the Product color mode adds to\n * the statement (a later list overrides an earlier one in DOT), e.g. a cross-product dependency's\n * dash and color; `fullDot` always carries the plain statement.\n */\n edge(from: string, to: string, dot: string, productAttrs: string = ''): string {\n const id = `wp-real-edge-${this.edges.length}`;\n const base = `${dot.slice(0, -2)} [id=\"${id}\"]`;\n const statement = `${base};\\n`;\n const productDot = productAttrs === '' ? null : `${base} [${productAttrs}];\\n`;\n this.edges.push(new RenderEdge(from, to, statement, id, productDot));\n return statement;\n }\n}\n\n/** Shared filter chrome and script-safe JSON for pages opened directly from disk. */\nexport class GraphFilterAssets {\n json<T>(value: T): string {\n return JSON.stringify(value).replace(/</g, '\\\\u003c');\n }\n\n html(): string {\n return (\n '<p id=\"wp-filter-status\" hidden>Filtering: <strong id=\"wp-filter-anchor\"></strong> ' +\n '<button id=\"wp-filter-off\" type=\"button\">Turn off Filter</button></p>' +\n '<p id=\"wp-graph-error\" role=\"alert\" hidden></p>'\n );\n }\n\n styles(): string {\n return (\n '#wp-filter-status { text-align:center; } #wp-graph-error { color:#b71c1c; } ' +\n '#graph .wp-filter-anchor polygon, #graph .wp-filter-anchor path, ' +\n '#graph .wp-filter-anchor ellipse { stroke:#8b3cf0; stroke-width:3; }'\n );\n }\n}\n"]}
|
|
@@ -126,6 +126,8 @@ declare class GraphPage extends WpFilterPage {
|
|
|
126
126
|
protected captureBinding(_svg: SVGSVGElement | null): () => void;
|
|
127
127
|
protected wireControls(): void;
|
|
128
128
|
protected nodeDot(node: RenderNodeJson): string;
|
|
129
|
+
/** Product mode dashes a dependency that crosses into another product (#1204); every other mode draws it plain. */
|
|
130
|
+
protected edgeDot(edge: RenderEdgeJson): string;
|
|
129
131
|
protected usesFullDot(): boolean;
|
|
130
132
|
protected narrow(retained: Set<string>): Set<string>;
|
|
131
133
|
/** Filtering keeps every box in its own L-row: an emptied level stays as a thin labeled band. */
|
|
@@ -678,6 +678,12 @@ class GraphPage extends WpFilterPage {
|
|
|
678
678
|
return modes.product;
|
|
679
679
|
return modes.runtime;
|
|
680
680
|
}
|
|
681
|
+
/** Product mode dashes a dependency that crosses into another product (#1204); every other mode draws it plain. */
|
|
682
|
+
edgeDot(edge) {
|
|
683
|
+
if (this.modes.mode === 'product' && edge.productDot !== null)
|
|
684
|
+
return edge.productDot;
|
|
685
|
+
return edge.dot;
|
|
686
|
+
}
|
|
681
687
|
usesFullDot() {
|
|
682
688
|
return this.modes.mode === 'runtime' && this.applied.count() === 0;
|
|
683
689
|
}
|