1 | import { c as getConfig, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, l as log, v as clear$1, i as configureSvgSize, e as common } from "./mermaid-6dc72991.js";
|
2 | import { select, line } from "d3";
|
3 | import { layout } from "dagre-d3-es/src/dagre/index.js";
|
4 | import * as graphlib from "dagre-d3-es/src/graphlib/index.js";
|
5 | import "ts-dedent";
|
6 | import "dayjs";
|
7 | import "@braintree/sanitize-url";
|
8 | import "dompurify";
|
9 | import "khroma";
|
10 | import "lodash-es/memoize.js";
|
11 | import "lodash-es/merge.js";
|
12 | import "stylis";
|
13 | import "lodash-es/isEmpty.js";
|
14 | var parser = function() {
|
15 | var o = function(k, v, o2, l) {
|
16 | for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
|
17 | ;
|
18 | return o2;
|
19 | }, $V0 = [1, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [5, 6, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 62, 63], $V5 = [1, 18], $V6 = [2, 7], $V7 = [1, 22], $V8 = [1, 23], $V9 = [1, 24], $Va = [1, 25], $Vb = [1, 26], $Vc = [1, 27], $Vd = [1, 20], $Ve = [1, 28], $Vf = [1, 29], $Vg = [62, 63], $Vh = [5, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 51, 53, 62, 63], $Vi = [1, 47], $Vj = [1, 48], $Vk = [1, 49], $Vl = [1, 50], $Vm = [1, 51], $Vn = [1, 52], $Vo = [1, 53], $Vp = [53, 54], $Vq = [1, 64], $Vr = [1, 60], $Vs = [1, 61], $Vt = [1, 62], $Vu = [1, 63], $Vv = [1, 65], $Vw = [1, 69], $Vx = [1, 70], $Vy = [1, 67], $Vz = [1, 68], $VA = [5, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 62, 63];
|
20 | var parser2 = {
|
21 | trace: function trace() {
|
22 | },
|
23 | yy: {},
|
24 | symbols_: { "error": 2, "start": 3, "directive": 4, "NEWLINE": 5, "RD": 6, "diagram": 7, "EOF": 8, "acc_title": 9, "acc_title_value": 10, "acc_descr": 11, "acc_descr_value": 12, "acc_descr_multiline_value": 13, "requirementDef": 14, "elementDef": 15, "relationshipDef": 16, "requirementType": 17, "requirementName": 18, "STRUCT_START": 19, "requirementBody": 20, "ID": 21, "COLONSEP": 22, "id": 23, "TEXT": 24, "text": 25, "RISK": 26, "riskLevel": 27, "VERIFYMTHD": 28, "verifyType": 29, "STRUCT_STOP": 30, "REQUIREMENT": 31, "FUNCTIONAL_REQUIREMENT": 32, "INTERFACE_REQUIREMENT": 33, "PERFORMANCE_REQUIREMENT": 34, "PHYSICAL_REQUIREMENT": 35, "DESIGN_CONSTRAINT": 36, "LOW_RISK": 37, "MED_RISK": 38, "HIGH_RISK": 39, "VERIFY_ANALYSIS": 40, "VERIFY_DEMONSTRATION": 41, "VERIFY_INSPECTION": 42, "VERIFY_TEST": 43, "ELEMENT": 44, "elementName": 45, "elementBody": 46, "TYPE": 47, "type": 48, "DOCREF": 49, "ref": 50, "END_ARROW_L": 51, "relationship": 52, "LINE": 53, "END_ARROW_R": 54, "CONTAINS": 55, "COPIES": 56, "DERIVES": 57, "SATISFIES": 58, "VERIFIES": 59, "REFINES": 60, "TRACES": 61, "unqString": 62, "qString": 63, "$accept": 0, "$end": 1 },
|
25 | terminals_: { 2: "error", 5: "NEWLINE", 6: "RD", 8: "EOF", 9: "acc_title", 10: "acc_title_value", 11: "acc_descr", 12: "acc_descr_value", 13: "acc_descr_multiline_value", 19: "STRUCT_START", 21: "ID", 22: "COLONSEP", 24: "TEXT", 26: "RISK", 28: "VERIFYMTHD", 30: "STRUCT_STOP", 31: "REQUIREMENT", 32: "FUNCTIONAL_REQUIREMENT", 33: "INTERFACE_REQUIREMENT", 34: "PERFORMANCE_REQUIREMENT", 35: "PHYSICAL_REQUIREMENT", 36: "DESIGN_CONSTRAINT", 37: "LOW_RISK", 38: "MED_RISK", 39: "HIGH_RISK", 40: "VERIFY_ANALYSIS", 41: "VERIFY_DEMONSTRATION", 42: "VERIFY_INSPECTION", 43: "VERIFY_TEST", 44: "ELEMENT", 47: "TYPE", 49: "DOCREF", 51: "END_ARROW_L", 53: "LINE", 54: "END_ARROW_R", 55: "CONTAINS", 56: "COPIES", 57: "DERIVES", 58: "SATISFIES", 59: "VERIFIES", 60: "REFINES", 61: "TRACES", 62: "unqString", 63: "qString" },
|
26 | productions_: [0, [3, 3], [3, 2], [3, 4], [4, 2], [4, 2], [4, 1], [7, 0], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [14, 5], [20, 5], [20, 5], [20, 5], [20, 5], [20, 2], [20, 1], [17, 1], [17, 1], [17, 1], [17, 1], [17, 1], [17, 1], [27, 1], [27, 1], [27, 1], [29, 1], [29, 1], [29, 1], [29, 1], [15, 5], [46, 5], [46, 5], [46, 2], [46, 1], [16, 5], [16, 5], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [18, 1], [18, 1], [23, 1], [23, 1], [25, 1], [25, 1], [45, 1], [45, 1], [48, 1], [48, 1], [50, 1], [50, 1]],
|
27 | performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
|
28 | var $0 = $$.length - 1;
|
29 | switch (yystate) {
|
30 | case 4:
|
31 | this.$ = $$[$0].trim();
|
32 | yy.setAccTitle(this.$);
|
33 | break;
|
34 | case 5:
|
35 | case 6:
|
36 | this.$ = $$[$0].trim();
|
37 | yy.setAccDescription(this.$);
|
38 | break;
|
39 | case 7:
|
40 | this.$ = [];
|
41 | break;
|
42 | case 13:
|
43 | yy.addRequirement($$[$0 - 3], $$[$0 - 4]);
|
44 | break;
|
45 | case 14:
|
46 | yy.setNewReqId($$[$0 - 2]);
|
47 | break;
|
48 | case 15:
|
49 | yy.setNewReqText($$[$0 - 2]);
|
50 | break;
|
51 | case 16:
|
52 | yy.setNewReqRisk($$[$0 - 2]);
|
53 | break;
|
54 | case 17:
|
55 | yy.setNewReqVerifyMethod($$[$0 - 2]);
|
56 | break;
|
57 | case 20:
|
58 | this.$ = yy.RequirementType.REQUIREMENT;
|
59 | break;
|
60 | case 21:
|
61 | this.$ = yy.RequirementType.FUNCTIONAL_REQUIREMENT;
|
62 | break;
|
63 | case 22:
|
64 | this.$ = yy.RequirementType.INTERFACE_REQUIREMENT;
|
65 | break;
|
66 | case 23:
|
67 | this.$ = yy.RequirementType.PERFORMANCE_REQUIREMENT;
|
68 | break;
|
69 | case 24:
|
70 | this.$ = yy.RequirementType.PHYSICAL_REQUIREMENT;
|
71 | break;
|
72 | case 25:
|
73 | this.$ = yy.RequirementType.DESIGN_CONSTRAINT;
|
74 | break;
|
75 | case 26:
|
76 | this.$ = yy.RiskLevel.LOW_RISK;
|
77 | break;
|
78 | case 27:
|
79 | this.$ = yy.RiskLevel.MED_RISK;
|
80 | break;
|
81 | case 28:
|
82 | this.$ = yy.RiskLevel.HIGH_RISK;
|
83 | break;
|
84 | case 29:
|
85 | this.$ = yy.VerifyType.VERIFY_ANALYSIS;
|
86 | break;
|
87 | case 30:
|
88 | this.$ = yy.VerifyType.VERIFY_DEMONSTRATION;
|
89 | break;
|
90 | case 31:
|
91 | this.$ = yy.VerifyType.VERIFY_INSPECTION;
|
92 | break;
|
93 | case 32:
|
94 | this.$ = yy.VerifyType.VERIFY_TEST;
|
95 | break;
|
96 | case 33:
|
97 | yy.addElement($$[$0 - 3]);
|
98 | break;
|
99 | case 34:
|
100 | yy.setNewElementType($$[$0 - 2]);
|
101 | break;
|
102 | case 35:
|
103 | yy.setNewElementDocRef($$[$0 - 2]);
|
104 | break;
|
105 | case 38:
|
106 | yy.addRelationship($$[$0 - 2], $$[$0], $$[$0 - 4]);
|
107 | break;
|
108 | case 39:
|
109 | yy.addRelationship($$[$0 - 2], $$[$0 - 4], $$[$0]);
|
110 | break;
|
111 | case 40:
|
112 | this.$ = yy.Relationships.CONTAINS;
|
113 | break;
|
114 | case 41:
|
115 | this.$ = yy.Relationships.COPIES;
|
116 | break;
|
117 | case 42:
|
118 | this.$ = yy.Relationships.DERIVES;
|
119 | break;
|
120 | case 43:
|
121 | this.$ = yy.Relationships.SATISFIES;
|
122 | break;
|
123 | case 44:
|
124 | this.$ = yy.Relationships.VERIFIES;
|
125 | break;
|
126 | case 45:
|
127 | this.$ = yy.Relationships.REFINES;
|
128 | break;
|
129 | case 46:
|
130 | this.$ = yy.Relationships.TRACES;
|
131 | break;
|
132 | }
|
133 | },
|
134 | table: [{ 3: 1, 4: 2, 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 1: [3] }, { 3: 8, 4: 2, 5: [1, 7], 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 5: [1, 9] }, { 10: [1, 10] }, { 12: [1, 11] }, o($V4, [2, 6]), { 3: 12, 4: 2, 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 1: [2, 2] }, { 4: 17, 5: $V5, 7: 13, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, o($V4, [2, 4]), o($V4, [2, 5]), { 1: [2, 1] }, { 8: [1, 30] }, { 4: 17, 5: $V5, 7: 31, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 32, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 33, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 34, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 35, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 18: 36, 62: [1, 37], 63: [1, 38] }, { 45: 39, 62: [1, 40], 63: [1, 41] }, { 51: [1, 42], 53: [1, 43] }, o($Vg, [2, 20]), o($Vg, [2, 21]), o($Vg, [2, 22]), o($Vg, [2, 23]), o($Vg, [2, 24]), o($Vg, [2, 25]), o($Vh, [2, 49]), o($Vh, [2, 50]), { 1: [2, 3] }, { 8: [2, 8] }, { 8: [2, 9] }, { 8: [2, 10] }, { 8: [2, 11] }, { 8: [2, 12] }, { 19: [1, 44] }, { 19: [2, 47] }, { 19: [2, 48] }, { 19: [1, 45] }, { 19: [2, 53] }, { 19: [2, 54] }, { 52: 46, 55: $Vi, 56: $Vj, 57: $Vk, 58: $Vl, 59: $Vm, 60: $Vn, 61: $Vo }, { 52: 54, 55: $Vi, 56: $Vj, 57: $Vk, 58: $Vl, 59: $Vm, 60: $Vn, 61: $Vo }, { 5: [1, 55] }, { 5: [1, 56] }, { 53: [1, 57] }, o($Vp, [2, 40]), o($Vp, [2, 41]), o($Vp, [2, 42]), o($Vp, [2, 43]), o($Vp, [2, 44]), o($Vp, [2, 45]), o($Vp, [2, 46]), { 54: [1, 58] }, { 5: $Vq, 20: 59, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vw, 30: $Vx, 46: 66, 47: $Vy, 49: $Vz }, { 23: 71, 62: $Ve, 63: $Vf }, { 23: 72, 62: $Ve, 63: $Vf }, o($VA, [2, 13]), { 22: [1, 73] }, { 22: [1, 74] }, { 22: [1, 75] }, { 22: [1, 76] }, { 5: $Vq, 20: 77, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, o($VA, [2, 19]), o($VA, [2, 33]), { 22: [1, 78] }, { 22: [1, 79] }, { 5: $Vw, 30: $Vx, 46: 80, 47: $Vy, 49: $Vz }, o($VA, [2, 37]), o($VA, [2, 38]), o($VA, [2, 39]), { 23: 81, 62: $Ve, 63: $Vf }, { 25: 82, 62: [1, 83], 63: [1, 84] }, { 27: 85, 37: [1, 86], 38: [1, 87], 39: [1, 88] }, { 29: 89, 40: [1, 90], 41: [1, 91], 42: [1, 92], 43: [1, 93] }, o($VA, [2, 18]), { 48: 94, 62: [1, 95], 63: [1, 96] }, { 50: 97, 62: [1, 98], 63: [1, 99] }, o($VA, [2, 36]), { 5: [1, 100] }, { 5: [1, 101] }, { 5: [2, 51] }, { 5: [2, 52] }, { 5: [1, 102] }, { 5: [2, 26] }, { 5: [2, 27] }, { 5: [2, 28] }, { 5: [1, 103] }, { 5: [2, 29] }, { 5: [2, 30] }, { 5: [2, 31] }, { 5: [2, 32] }, { 5: [1, 104] }, { 5: [2, 55] }, { 5: [2, 56] }, { 5: [1, 105] }, { 5: [2, 57] }, { 5: [2, 58] }, { 5: $Vq, 20: 106, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 107, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 108, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 109, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vw, 30: $Vx, 46: 110, 47: $Vy, 49: $Vz }, { 5: $Vw, 30: $Vx, 46: 111, 47: $Vy, 49: $Vz }, o($VA, [2, 14]), o($VA, [2, 15]), o($VA, [2, 16]), o($VA, [2, 17]), o($VA, [2, 34]), o($VA, [2, 35])],
|
135 | defaultActions: { 8: [2, 2], 12: [2, 1], 30: [2, 3], 31: [2, 8], 32: [2, 9], 33: [2, 10], 34: [2, 11], 35: [2, 12], 37: [2, 47], 38: [2, 48], 40: [2, 53], 41: [2, 54], 83: [2, 51], 84: [2, 52], 86: [2, 26], 87: [2, 27], 88: [2, 28], 90: [2, 29], 91: [2, 30], 92: [2, 31], 93: [2, 32], 95: [2, 55], 96: [2, 56], 98: [2, 57], 99: [2, 58] },
|
136 | parseError: function parseError(str, hash) {
|
137 | if (hash.recoverable) {
|
138 | this.trace(str);
|
139 | } else {
|
140 | var error = new Error(str);
|
141 | error.hash = hash;
|
142 | throw error;
|
143 | }
|
144 | },
|
145 | parse: function parse(input) {
|
146 | var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
|
147 | var args = lstack.slice.call(arguments, 1);
|
148 | var lexer2 = Object.create(this.lexer);
|
149 | var sharedState = { yy: {} };
|
150 | for (var k in this.yy) {
|
151 | if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
152 | sharedState.yy[k] = this.yy[k];
|
153 | }
|
154 | }
|
155 | lexer2.setInput(input, sharedState.yy);
|
156 | sharedState.yy.lexer = lexer2;
|
157 | sharedState.yy.parser = this;
|
158 | if (typeof lexer2.yylloc == "undefined") {
|
159 | lexer2.yylloc = {};
|
160 | }
|
161 | var yyloc = lexer2.yylloc;
|
162 | lstack.push(yyloc);
|
163 | var ranges = lexer2.options && lexer2.options.ranges;
|
164 | if (typeof sharedState.yy.parseError === "function") {
|
165 | this.parseError = sharedState.yy.parseError;
|
166 | } else {
|
167 | this.parseError = Object.getPrototypeOf(this).parseError;
|
168 | }
|
169 | function lex() {
|
170 | var token;
|
171 | token = tstack.pop() || lexer2.lex() || EOF;
|
172 | if (typeof token !== "number") {
|
173 | if (token instanceof Array) {
|
174 | tstack = token;
|
175 | token = tstack.pop();
|
176 | }
|
177 | token = self.symbols_[token] || token;
|
178 | }
|
179 | return token;
|
180 | }
|
181 | var symbol, state, action, r, yyval = {}, p, len, newState, expected;
|
182 | while (true) {
|
183 | state = stack[stack.length - 1];
|
184 | if (this.defaultActions[state]) {
|
185 | action = this.defaultActions[state];
|
186 | } else {
|
187 | if (symbol === null || typeof symbol == "undefined") {
|
188 | symbol = lex();
|
189 | }
|
190 | action = table[state] && table[state][symbol];
|
191 | }
|
192 | if (typeof action === "undefined" || !action.length || !action[0]) {
|
193 | var errStr = "";
|
194 | expected = [];
|
195 | for (p in table[state]) {
|
196 | if (this.terminals_[p] && p > TERROR) {
|
197 | expected.push("'" + this.terminals_[p] + "'");
|
198 | }
|
199 | }
|
200 | if (lexer2.showPosition) {
|
201 | errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
|
202 | } else {
|
203 | errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
|
204 | }
|
205 | this.parseError(errStr, {
|
206 | text: lexer2.match,
|
207 | token: this.terminals_[symbol] || symbol,
|
208 | line: lexer2.yylineno,
|
209 | loc: yyloc,
|
210 | expected
|
211 | });
|
212 | }
|
213 | if (action[0] instanceof Array && action.length > 1) {
|
214 | throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
215 | }
|
216 | switch (action[0]) {
|
217 | case 1:
|
218 | stack.push(symbol);
|
219 | vstack.push(lexer2.yytext);
|
220 | lstack.push(lexer2.yylloc);
|
221 | stack.push(action[1]);
|
222 | symbol = null;
|
223 | {
|
224 | yyleng = lexer2.yyleng;
|
225 | yytext = lexer2.yytext;
|
226 | yylineno = lexer2.yylineno;
|
227 | yyloc = lexer2.yylloc;
|
228 | }
|
229 | break;
|
230 | case 2:
|
231 | len = this.productions_[action[1]][1];
|
232 | yyval.$ = vstack[vstack.length - len];
|
233 | yyval._$ = {
|
234 | first_line: lstack[lstack.length - (len || 1)].first_line,
|
235 | last_line: lstack[lstack.length - 1].last_line,
|
236 | first_column: lstack[lstack.length - (len || 1)].first_column,
|
237 | last_column: lstack[lstack.length - 1].last_column
|
238 | };
|
239 | if (ranges) {
|
240 | yyval._$.range = [
|
241 | lstack[lstack.length - (len || 1)].range[0],
|
242 | lstack[lstack.length - 1].range[1]
|
243 | ];
|
244 | }
|
245 | r = this.performAction.apply(yyval, [
|
246 | yytext,
|
247 | yyleng,
|
248 | yylineno,
|
249 | sharedState.yy,
|
250 | action[1],
|
251 | vstack,
|
252 | lstack
|
253 | ].concat(args));
|
254 | if (typeof r !== "undefined") {
|
255 | return r;
|
256 | }
|
257 | if (len) {
|
258 | stack = stack.slice(0, -1 * len * 2);
|
259 | vstack = vstack.slice(0, -1 * len);
|
260 | lstack = lstack.slice(0, -1 * len);
|
261 | }
|
262 | stack.push(this.productions_[action[1]][0]);
|
263 | vstack.push(yyval.$);
|
264 | lstack.push(yyval._$);
|
265 | newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
266 | stack.push(newState);
|
267 | break;
|
268 | case 3:
|
269 | return true;
|
270 | }
|
271 | }
|
272 | return true;
|
273 | }
|
274 | };
|
275 | var lexer = function() {
|
276 | var lexer2 = {
|
277 | EOF: 1,
|
278 | parseError: function parseError(str, hash) {
|
279 | if (this.yy.parser) {
|
280 | this.yy.parser.parseError(str, hash);
|
281 | } else {
|
282 | throw new Error(str);
|
283 | }
|
284 | },
|
285 |
|
286 | setInput: function(input, yy) {
|
287 | this.yy = yy || this.yy || {};
|
288 | this._input = input;
|
289 | this._more = this._backtrack = this.done = false;
|
290 | this.yylineno = this.yyleng = 0;
|
291 | this.yytext = this.matched = this.match = "";
|
292 | this.conditionStack = ["INITIAL"];
|
293 | this.yylloc = {
|
294 | first_line: 1,
|
295 | first_column: 0,
|
296 | last_line: 1,
|
297 | last_column: 0
|
298 | };
|
299 | if (this.options.ranges) {
|
300 | this.yylloc.range = [0, 0];
|
301 | }
|
302 | this.offset = 0;
|
303 | return this;
|
304 | },
|
305 |
|
306 | input: function() {
|
307 | var ch = this._input[0];
|
308 | this.yytext += ch;
|
309 | this.yyleng++;
|
310 | this.offset++;
|
311 | this.match += ch;
|
312 | this.matched += ch;
|
313 | var lines = ch.match(/(?:\r\n?|\n).*/g);
|
314 | if (lines) {
|
315 | this.yylineno++;
|
316 | this.yylloc.last_line++;
|
317 | } else {
|
318 | this.yylloc.last_column++;
|
319 | }
|
320 | if (this.options.ranges) {
|
321 | this.yylloc.range[1]++;
|
322 | }
|
323 | this._input = this._input.slice(1);
|
324 | return ch;
|
325 | },
|
326 |
|
327 | unput: function(ch) {
|
328 | var len = ch.length;
|
329 | var lines = ch.split(/(?:\r\n?|\n)/g);
|
330 | this._input = ch + this._input;
|
331 | this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
332 | this.offset -= len;
|
333 | var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
334 | this.match = this.match.substr(0, this.match.length - 1);
|
335 | this.matched = this.matched.substr(0, this.matched.length - 1);
|
336 | if (lines.length - 1) {
|
337 | this.yylineno -= lines.length - 1;
|
338 | }
|
339 | var r = this.yylloc.range;
|
340 | this.yylloc = {
|
341 | first_line: this.yylloc.first_line,
|
342 | last_line: this.yylineno + 1,
|
343 | first_column: this.yylloc.first_column,
|
344 | last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
|
345 | };
|
346 | if (this.options.ranges) {
|
347 | this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
348 | }
|
349 | this.yyleng = this.yytext.length;
|
350 | return this;
|
351 | },
|
352 |
|
353 | more: function() {
|
354 | this._more = true;
|
355 | return this;
|
356 | },
|
357 |
|
358 | reject: function() {
|
359 | if (this.options.backtrack_lexer) {
|
360 | this._backtrack = true;
|
361 | } else {
|
362 | return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
|
363 | text: "",
|
364 | token: null,
|
365 | line: this.yylineno
|
366 | });
|
367 | }
|
368 | return this;
|
369 | },
|
370 |
|
371 | less: function(n) {
|
372 | this.unput(this.match.slice(n));
|
373 | },
|
374 |
|
375 | pastInput: function() {
|
376 | var past = this.matched.substr(0, this.matched.length - this.match.length);
|
377 | return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
378 | },
|
379 |
|
380 | upcomingInput: function() {
|
381 | var next = this.match;
|
382 | if (next.length < 20) {
|
383 | next += this._input.substr(0, 20 - next.length);
|
384 | }
|
385 | return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
386 | },
|
387 |
|
388 | showPosition: function() {
|
389 | var pre = this.pastInput();
|
390 | var c = new Array(pre.length + 1).join("-");
|
391 | return pre + this.upcomingInput() + "\n" + c + "^";
|
392 | },
|
393 |
|
394 | test_match: function(match, indexed_rule) {
|
395 | var token, lines, backup;
|
396 | if (this.options.backtrack_lexer) {
|
397 | backup = {
|
398 | yylineno: this.yylineno,
|
399 | yylloc: {
|
400 | first_line: this.yylloc.first_line,
|
401 | last_line: this.last_line,
|
402 | first_column: this.yylloc.first_column,
|
403 | last_column: this.yylloc.last_column
|
404 | },
|
405 | yytext: this.yytext,
|
406 | match: this.match,
|
407 | matches: this.matches,
|
408 | matched: this.matched,
|
409 | yyleng: this.yyleng,
|
410 | offset: this.offset,
|
411 | _more: this._more,
|
412 | _input: this._input,
|
413 | yy: this.yy,
|
414 | conditionStack: this.conditionStack.slice(0),
|
415 | done: this.done
|
416 | };
|
417 | if (this.options.ranges) {
|
418 | backup.yylloc.range = this.yylloc.range.slice(0);
|
419 | }
|
420 | }
|
421 | lines = match[0].match(/(?:\r\n?|\n).*/g);
|
422 | if (lines) {
|
423 | this.yylineno += lines.length;
|
424 | }
|
425 | this.yylloc = {
|
426 | first_line: this.yylloc.last_line,
|
427 | last_line: this.yylineno + 1,
|
428 | first_column: this.yylloc.last_column,
|
429 | last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
|
430 | };
|
431 | this.yytext += match[0];
|
432 | this.match += match[0];
|
433 | this.matches = match;
|
434 | this.yyleng = this.yytext.length;
|
435 | if (this.options.ranges) {
|
436 | this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
437 | }
|
438 | this._more = false;
|
439 | this._backtrack = false;
|
440 | this._input = this._input.slice(match[0].length);
|
441 | this.matched += match[0];
|
442 | token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
443 | if (this.done && this._input) {
|
444 | this.done = false;
|
445 | }
|
446 | if (token) {
|
447 | return token;
|
448 | } else if (this._backtrack) {
|
449 | for (var k in backup) {
|
450 | this[k] = backup[k];
|
451 | }
|
452 | return false;
|
453 | }
|
454 | return false;
|
455 | },
|
456 |
|
457 | next: function() {
|
458 | if (this.done) {
|
459 | return this.EOF;
|
460 | }
|
461 | if (!this._input) {
|
462 | this.done = true;
|
463 | }
|
464 | var token, match, tempMatch, index;
|
465 | if (!this._more) {
|
466 | this.yytext = "";
|
467 | this.match = "";
|
468 | }
|
469 | var rules = this._currentRules();
|
470 | for (var i = 0; i < rules.length; i++) {
|
471 | tempMatch = this._input.match(this.rules[rules[i]]);
|
472 | if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
473 | match = tempMatch;
|
474 | index = i;
|
475 | if (this.options.backtrack_lexer) {
|
476 | token = this.test_match(tempMatch, rules[i]);
|
477 | if (token !== false) {
|
478 | return token;
|
479 | } else if (this._backtrack) {
|
480 | match = false;
|
481 | continue;
|
482 | } else {
|
483 | return false;
|
484 | }
|
485 | } else if (!this.options.flex) {
|
486 | break;
|
487 | }
|
488 | }
|
489 | }
|
490 | if (match) {
|
491 | token = this.test_match(match, rules[index]);
|
492 | if (token !== false) {
|
493 | return token;
|
494 | }
|
495 | return false;
|
496 | }
|
497 | if (this._input === "") {
|
498 | return this.EOF;
|
499 | } else {
|
500 | return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
|
501 | text: "",
|
502 | token: null,
|
503 | line: this.yylineno
|
504 | });
|
505 | }
|
506 | },
|
507 |
|
508 | lex: function lex() {
|
509 | var r = this.next();
|
510 | if (r) {
|
511 | return r;
|
512 | } else {
|
513 | return this.lex();
|
514 | }
|
515 | },
|
516 |
|
517 | begin: function begin(condition) {
|
518 | this.conditionStack.push(condition);
|
519 | },
|
520 |
|
521 | popState: function popState() {
|
522 | var n = this.conditionStack.length - 1;
|
523 | if (n > 0) {
|
524 | return this.conditionStack.pop();
|
525 | } else {
|
526 | return this.conditionStack[0];
|
527 | }
|
528 | },
|
529 |
|
530 | _currentRules: function _currentRules() {
|
531 | if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
532 | return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
533 | } else {
|
534 | return this.conditions["INITIAL"].rules;
|
535 | }
|
536 | },
|
537 |
|
538 | topState: function topState(n) {
|
539 | n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
540 | if (n >= 0) {
|
541 | return this.conditionStack[n];
|
542 | } else {
|
543 | return "INITIAL";
|
544 | }
|
545 | },
|
546 |
|
547 | pushState: function pushState(condition) {
|
548 | this.begin(condition);
|
549 | },
|
550 |
|
551 | stateStackSize: function stateStackSize() {
|
552 | return this.conditionStack.length;
|
553 | },
|
554 | options: { "case-insensitive": true },
|
555 | performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
|
556 | switch ($avoiding_name_collisions) {
|
557 | case 0:
|
558 | return "title";
|
559 | case 1:
|
560 | this.begin("acc_title");
|
561 | return 9;
|
562 | case 2:
|
563 | this.popState();
|
564 | return "acc_title_value";
|
565 | case 3:
|
566 | this.begin("acc_descr");
|
567 | return 11;
|
568 | case 4:
|
569 | this.popState();
|
570 | return "acc_descr_value";
|
571 | case 5:
|
572 | this.begin("acc_descr_multiline");
|
573 | break;
|
574 | case 6:
|
575 | this.popState();
|
576 | break;
|
577 | case 7:
|
578 | return "acc_descr_multiline_value";
|
579 | case 8:
|
580 | return 5;
|
581 | case 9:
|
582 | break;
|
583 | case 10:
|
584 | break;
|
585 | case 11:
|
586 | break;
|
587 | case 12:
|
588 | return 8;
|
589 | case 13:
|
590 | return 6;
|
591 | case 14:
|
592 | return 19;
|
593 | case 15:
|
594 | return 30;
|
595 | case 16:
|
596 | return 22;
|
597 | case 17:
|
598 | return 21;
|
599 | case 18:
|
600 | return 24;
|
601 | case 19:
|
602 | return 26;
|
603 | case 20:
|
604 | return 28;
|
605 | case 21:
|
606 | return 31;
|
607 | case 22:
|
608 | return 32;
|
609 | case 23:
|
610 | return 33;
|
611 | case 24:
|
612 | return 34;
|
613 | case 25:
|
614 | return 35;
|
615 | case 26:
|
616 | return 36;
|
617 | case 27:
|
618 | return 37;
|
619 | case 28:
|
620 | return 38;
|
621 | case 29:
|
622 | return 39;
|
623 | case 30:
|
624 | return 40;
|
625 | case 31:
|
626 | return 41;
|
627 | case 32:
|
628 | return 42;
|
629 | case 33:
|
630 | return 43;
|
631 | case 34:
|
632 | return 44;
|
633 | case 35:
|
634 | return 55;
|
635 | case 36:
|
636 | return 56;
|
637 | case 37:
|
638 | return 57;
|
639 | case 38:
|
640 | return 58;
|
641 | case 39:
|
642 | return 59;
|
643 | case 40:
|
644 | return 60;
|
645 | case 41:
|
646 | return 61;
|
647 | case 42:
|
648 | return 47;
|
649 | case 43:
|
650 | return 49;
|
651 | case 44:
|
652 | return 51;
|
653 | case 45:
|
654 | return 54;
|
655 | case 46:
|
656 | return 53;
|
657 | case 47:
|
658 | this.begin("string");
|
659 | break;
|
660 | case 48:
|
661 | this.popState();
|
662 | break;
|
663 | case 49:
|
664 | return "qString";
|
665 | case 50:
|
666 | yy_.yytext = yy_.yytext.trim();
|
667 | return 62;
|
668 | }
|
669 | },
|
670 | rules: [/^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:(\r?\n)+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:$)/i, /^(?:requirementDiagram\b)/i, /^(?:\{)/i, /^(?:\})/i, /^(?::)/i, /^(?:id\b)/i, /^(?:text\b)/i, /^(?:risk\b)/i, /^(?:verifyMethod\b)/i, /^(?:requirement\b)/i, /^(?:functionalRequirement\b)/i, /^(?:interfaceRequirement\b)/i, /^(?:performanceRequirement\b)/i, /^(?:physicalRequirement\b)/i, /^(?:designConstraint\b)/i, /^(?:low\b)/i, /^(?:medium\b)/i, /^(?:high\b)/i, /^(?:analysis\b)/i, /^(?:demonstration\b)/i, /^(?:inspection\b)/i, /^(?:test\b)/i, /^(?:element\b)/i, /^(?:contains\b)/i, /^(?:copies\b)/i, /^(?:derives\b)/i, /^(?:satisfies\b)/i, /^(?:verifies\b)/i, /^(?:refines\b)/i, /^(?:traces\b)/i, /^(?:type\b)/i, /^(?:docref\b)/i, /^(?:<-)/i, /^(?:->)/i, /^(?:-)/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[\w][^\r\n\{\<\>\-\=]*)/i],
|
671 | conditions: { "acc_descr_multiline": { "rules": [6, 7], "inclusive": false }, "acc_descr": { "rules": [4], "inclusive": false }, "acc_title": { "rules": [2], "inclusive": false }, "unqString": { "rules": [], "inclusive": false }, "token": { "rules": [], "inclusive": false }, "string": { "rules": [48, 49], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 50], "inclusive": true } }
|
672 | };
|
673 | return lexer2;
|
674 | }();
|
675 | parser2.lexer = lexer;
|
676 | function Parser() {
|
677 | this.yy = {};
|
678 | }
|
679 | Parser.prototype = parser2;
|
680 | parser2.Parser = Parser;
|
681 | return new Parser();
|
682 | }();
|
683 | parser.parser = parser;
|
684 | const parser$1 = parser;
|
685 | let relations = [];
|
686 | let latestRequirement = {};
|
687 | let requirements = {};
|
688 | let latestElement = {};
|
689 | let elements = {};
|
690 | const RequirementType = {
|
691 | REQUIREMENT: "Requirement",
|
692 | FUNCTIONAL_REQUIREMENT: "Functional Requirement",
|
693 | INTERFACE_REQUIREMENT: "Interface Requirement",
|
694 | PERFORMANCE_REQUIREMENT: "Performance Requirement",
|
695 | PHYSICAL_REQUIREMENT: "Physical Requirement",
|
696 | DESIGN_CONSTRAINT: "Design Constraint"
|
697 | };
|
698 | const RiskLevel = {
|
699 | LOW_RISK: "Low",
|
700 | MED_RISK: "Medium",
|
701 | HIGH_RISK: "High"
|
702 | };
|
703 | const VerifyType = {
|
704 | VERIFY_ANALYSIS: "Analysis",
|
705 | VERIFY_DEMONSTRATION: "Demonstration",
|
706 | VERIFY_INSPECTION: "Inspection",
|
707 | VERIFY_TEST: "Test"
|
708 | };
|
709 | const Relationships = {
|
710 | CONTAINS: "contains",
|
711 | COPIES: "copies",
|
712 | DERIVES: "derives",
|
713 | SATISFIES: "satisfies",
|
714 | VERIFIES: "verifies",
|
715 | REFINES: "refines",
|
716 | TRACES: "traces"
|
717 | };
|
718 | const addRequirement = (name, type) => {
|
719 | if (requirements[name] === void 0) {
|
720 | requirements[name] = {
|
721 | name,
|
722 | type,
|
723 | id: latestRequirement.id,
|
724 | text: latestRequirement.text,
|
725 | risk: latestRequirement.risk,
|
726 | verifyMethod: latestRequirement.verifyMethod
|
727 | };
|
728 | }
|
729 | latestRequirement = {};
|
730 | return requirements[name];
|
731 | };
|
732 | const getRequirements = () => requirements;
|
733 | const setNewReqId = (id) => {
|
734 | if (latestRequirement !== void 0) {
|
735 | latestRequirement.id = id;
|
736 | }
|
737 | };
|
738 | const setNewReqText = (text) => {
|
739 | if (latestRequirement !== void 0) {
|
740 | latestRequirement.text = text;
|
741 | }
|
742 | };
|
743 | const setNewReqRisk = (risk) => {
|
744 | if (latestRequirement !== void 0) {
|
745 | latestRequirement.risk = risk;
|
746 | }
|
747 | };
|
748 | const setNewReqVerifyMethod = (verifyMethod) => {
|
749 | if (latestRequirement !== void 0) {
|
750 | latestRequirement.verifyMethod = verifyMethod;
|
751 | }
|
752 | };
|
753 | const addElement = (name) => {
|
754 | if (elements[name] === void 0) {
|
755 | elements[name] = {
|
756 | name,
|
757 | type: latestElement.type,
|
758 | docRef: latestElement.docRef
|
759 | };
|
760 | log.info("Added new requirement: ", name);
|
761 | }
|
762 | latestElement = {};
|
763 | return elements[name];
|
764 | };
|
765 | const getElements = () => elements;
|
766 | const setNewElementType = (type) => {
|
767 | if (latestElement !== void 0) {
|
768 | latestElement.type = type;
|
769 | }
|
770 | };
|
771 | const setNewElementDocRef = (docRef) => {
|
772 | if (latestElement !== void 0) {
|
773 | latestElement.docRef = docRef;
|
774 | }
|
775 | };
|
776 | const addRelationship = (type, src, dst) => {
|
777 | relations.push({
|
778 | type,
|
779 | src,
|
780 | dst
|
781 | });
|
782 | };
|
783 | const getRelationships = () => relations;
|
784 | const clear = () => {
|
785 | relations = [];
|
786 | latestRequirement = {};
|
787 | requirements = {};
|
788 | latestElement = {};
|
789 | elements = {};
|
790 | clear$1();
|
791 | };
|
792 | const db = {
|
793 | RequirementType,
|
794 | RiskLevel,
|
795 | VerifyType,
|
796 | Relationships,
|
797 | getConfig: () => getConfig().req,
|
798 | addRequirement,
|
799 | getRequirements,
|
800 | setNewReqId,
|
801 | setNewReqText,
|
802 | setNewReqRisk,
|
803 | setNewReqVerifyMethod,
|
804 | setAccTitle,
|
805 | getAccTitle,
|
806 | setAccDescription,
|
807 | getAccDescription,
|
808 | addElement,
|
809 | getElements,
|
810 | setNewElementType,
|
811 | setNewElementDocRef,
|
812 | addRelationship,
|
813 | getRelationships,
|
814 | clear
|
815 | };
|
816 | const getStyles = (options) => `
|
817 |
|
818 | marker {
|
819 | fill: ${options.relationColor};
|
820 | stroke: ${options.relationColor};
|
821 | }
|
822 |
|
823 | marker.cross {
|
824 | stroke: ${options.lineColor};
|
825 | }
|
826 |
|
827 | svg {
|
828 | font-family: ${options.fontFamily};
|
829 | font-size: ${options.fontSize};
|
830 | }
|
831 |
|
832 | .reqBox {
|
833 | fill: ${options.requirementBackground};
|
834 | fill-opacity: 1.0;
|
835 | stroke: ${options.requirementBorderColor};
|
836 | stroke-width: ${options.requirementBorderSize};
|
837 | }
|
838 |
|
839 | .reqTitle, .reqLabel{
|
840 | fill: ${options.requirementTextColor};
|
841 | }
|
842 | .reqLabelBox {
|
843 | fill: ${options.relationLabelBackground};
|
844 | fill-opacity: 1.0;
|
845 | }
|
846 |
|
847 | .req-title-line {
|
848 | stroke: ${options.requirementBorderColor};
|
849 | stroke-width: ${options.requirementBorderSize};
|
850 | }
|
851 | .relationshipLine {
|
852 | stroke: ${options.relationColor};
|
853 | stroke-width: 1;
|
854 | }
|
855 | .relationshipLabel {
|
856 | fill: ${options.relationLabelColor};
|
857 | }
|
858 |
|
859 | `;
|
860 | const styles = getStyles;
|
861 | const ReqMarkers = {
|
862 | CONTAINS: "contains",
|
863 | ARROW: "arrow"
|
864 | };
|
865 | const insertLineEndings = (parentNode, conf2) => {
|
866 | let containsNode = parentNode.append("defs").append("marker").attr("id", ReqMarkers.CONTAINS + "_line_ending").attr("refX", 0).attr("refY", conf2.line_height / 2).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("g");
|
867 | containsNode.append("circle").attr("cx", conf2.line_height / 2).attr("cy", conf2.line_height / 2).attr("r", conf2.line_height / 2).attr("fill", "none");
|
868 | containsNode.append("line").attr("x1", 0).attr("x2", conf2.line_height).attr("y1", conf2.line_height / 2).attr("y2", conf2.line_height / 2).attr("stroke-width", 1);
|
869 | containsNode.append("line").attr("y1", 0).attr("y2", conf2.line_height).attr("x1", conf2.line_height / 2).attr("x2", conf2.line_height / 2).attr("stroke-width", 1);
|
870 | parentNode.append("defs").append("marker").attr("id", ReqMarkers.ARROW + "_line_ending").attr("refX", conf2.line_height).attr("refY", 0.5 * conf2.line_height).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("path").attr(
|
871 | "d",
|
872 | `M0,0
|
873 | L${conf2.line_height},${conf2.line_height / 2}
|
874 | M${conf2.line_height},${conf2.line_height / 2}
|
875 | L0,${conf2.line_height}`
|
876 | ).attr("stroke-width", 1);
|
877 | };
|
878 | const markers = {
|
879 | ReqMarkers,
|
880 | insertLineEndings
|
881 | };
|
882 | let conf = {};
|
883 | let relCnt = 0;
|
884 | const newRectNode = (parentNode, id) => {
|
885 | return parentNode.insert("rect", "#" + id).attr("class", "req reqBox").attr("x", 0).attr("y", 0).attr("width", conf.rect_min_width + "px").attr("height", conf.rect_min_height + "px");
|
886 | };
|
887 | const newTitleNode = (parentNode, id, txts) => {
|
888 | let x = conf.rect_min_width / 2;
|
889 | let title = parentNode.append("text").attr("class", "req reqLabel reqTitle").attr("id", id).attr("x", x).attr("y", conf.rect_padding).attr("dominant-baseline", "hanging");
|
890 | let i = 0;
|
891 | txts.forEach((textStr) => {
|
892 | if (i == 0) {
|
893 | title.append("tspan").attr("text-anchor", "middle").attr("x", conf.rect_min_width / 2).attr("dy", 0).text(textStr);
|
894 | } else {
|
895 | title.append("tspan").attr("text-anchor", "middle").attr("x", conf.rect_min_width / 2).attr("dy", conf.line_height * 0.75).text(textStr);
|
896 | }
|
897 | i++;
|
898 | });
|
899 | let yPadding = 1.5 * conf.rect_padding;
|
900 | let linePadding = i * conf.line_height * 0.75;
|
901 | let totalY = yPadding + linePadding;
|
902 | parentNode.append("line").attr("class", "req-title-line").attr("x1", "0").attr("x2", conf.rect_min_width).attr("y1", totalY).attr("y2", totalY);
|
903 | return {
|
904 | titleNode: title,
|
905 | y: totalY
|
906 | };
|
907 | };
|
908 | const newBodyNode = (parentNode, id, txts, yStart) => {
|
909 | let body = parentNode.append("text").attr("class", "req reqLabel").attr("id", id).attr("x", conf.rect_padding).attr("y", yStart).attr("dominant-baseline", "hanging");
|
910 | let currentRow = 0;
|
911 | const charLimit = 30;
|
912 | let wrappedTxts = [];
|
913 | txts.forEach((textStr) => {
|
914 | let currentTextLen = textStr.length;
|
915 | while (currentTextLen > charLimit && currentRow < 3) {
|
916 | let firstPart = textStr.substring(0, charLimit);
|
917 | textStr = textStr.substring(charLimit, textStr.length);
|
918 | currentTextLen = textStr.length;
|
919 | wrappedTxts[wrappedTxts.length] = firstPart;
|
920 | currentRow++;
|
921 | }
|
922 | if (currentRow == 3) {
|
923 | let lastStr = wrappedTxts[wrappedTxts.length - 1];
|
924 | wrappedTxts[wrappedTxts.length - 1] = lastStr.substring(0, lastStr.length - 4) + "...";
|
925 | } else {
|
926 | wrappedTxts[wrappedTxts.length] = textStr;
|
927 | }
|
928 | currentRow = 0;
|
929 | });
|
930 | wrappedTxts.forEach((textStr) => {
|
931 | body.append("tspan").attr("x", conf.rect_padding).attr("dy", conf.line_height).text(textStr);
|
932 | });
|
933 | return body;
|
934 | };
|
935 | const addEdgeLabel = (parentNode, svgPath, conf2, txt) => {
|
936 | const len = svgPath.node().getTotalLength();
|
937 | const labelPoint = svgPath.node().getPointAtLength(len * 0.5);
|
938 | const labelId = "rel" + relCnt;
|
939 | relCnt++;
|
940 | const labelNode = parentNode.append("text").attr("class", "req relationshipLabel").attr("id", labelId).attr("x", labelPoint.x).attr("y", labelPoint.y).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(txt);
|
941 | const labelBBox = labelNode.node().getBBox();
|
942 | parentNode.insert("rect", "#" + labelId).attr("class", "req reqLabelBox").attr("x", labelPoint.x - labelBBox.width / 2).attr("y", labelPoint.y - labelBBox.height / 2).attr("width", labelBBox.width).attr("height", labelBBox.height).attr("fill", "white").attr("fill-opacity", "85%");
|
943 | };
|
944 | const drawRelationshipFromLayout = function(svg, rel, g, insert, diagObj) {
|
945 | const edge = g.edge(elementString(rel.src), elementString(rel.dst));
|
946 | const lineFunction = line().x(function(d) {
|
947 | return d.x;
|
948 | }).y(function(d) {
|
949 | return d.y;
|
950 | });
|
951 | const svgPath = svg.insert("path", "#" + insert).attr("class", "er relationshipLine").attr("d", lineFunction(edge.points)).attr("fill", "none");
|
952 | if (rel.type == diagObj.db.Relationships.CONTAINS) {
|
953 | svgPath.attr(
|
954 | "marker-start",
|
955 | "url(" + common.getUrl(conf.arrowMarkerAbsolute) + "#" + rel.type + "_line_ending)"
|
956 | );
|
957 | } else {
|
958 | svgPath.attr("stroke-dasharray", "10,7");
|
959 | svgPath.attr(
|
960 | "marker-end",
|
961 | "url(" + common.getUrl(conf.arrowMarkerAbsolute) + "#" + markers.ReqMarkers.ARROW + "_line_ending)"
|
962 | );
|
963 | }
|
964 | addEdgeLabel(svg, svgPath, conf, `<<${rel.type}>>`);
|
965 | return;
|
966 | };
|
967 | const drawReqs = (reqs, graph, svgNode) => {
|
968 | Object.keys(reqs).forEach((reqName) => {
|
969 | let req = reqs[reqName];
|
970 | reqName = elementString(reqName);
|
971 | log.info("Added new requirement: ", reqName);
|
972 | const groupNode = svgNode.append("g").attr("id", reqName);
|
973 | const textId = "req-" + reqName;
|
974 | const rectNode = newRectNode(groupNode, textId);
|
975 | let titleNodeInfo = newTitleNode(groupNode, reqName + "_title", [
|
976 | `<<${req.type}>>`,
|
977 | `${req.name}`
|
978 | ]);
|
979 | newBodyNode(
|
980 | groupNode,
|
981 | reqName + "_body",
|
982 | [
|
983 | `Id: ${req.id}`,
|
984 | `Text: ${req.text}`,
|
985 | `Risk: ${req.risk}`,
|
986 | `Verification: ${req.verifyMethod}`
|
987 | ],
|
988 | titleNodeInfo.y
|
989 | );
|
990 | const rectBBox = rectNode.node().getBBox();
|
991 | graph.setNode(reqName, {
|
992 | width: rectBBox.width,
|
993 | height: rectBBox.height,
|
994 | shape: "rect",
|
995 | id: reqName
|
996 | });
|
997 | });
|
998 | };
|
999 | const drawElements = (els, graph, svgNode) => {
|
1000 | Object.keys(els).forEach((elName) => {
|
1001 | let el = els[elName];
|
1002 | const id = elementString(elName);
|
1003 | const groupNode = svgNode.append("g").attr("id", id);
|
1004 | const textId = "element-" + id;
|
1005 | const rectNode = newRectNode(groupNode, textId);
|
1006 | let titleNodeInfo = newTitleNode(groupNode, textId + "_title", [`<<Element>>`, `${elName}`]);
|
1007 | newBodyNode(
|
1008 | groupNode,
|
1009 | textId + "_body",
|
1010 | [`Type: ${el.type || "Not Specified"}`, `Doc Ref: ${el.docRef || "None"}`],
|
1011 | titleNodeInfo.y
|
1012 | );
|
1013 | const rectBBox = rectNode.node().getBBox();
|
1014 | graph.setNode(id, {
|
1015 | width: rectBBox.width,
|
1016 | height: rectBBox.height,
|
1017 | shape: "rect",
|
1018 | id
|
1019 | });
|
1020 | });
|
1021 | };
|
1022 | const addRelationships = (relationships, g) => {
|
1023 | relationships.forEach(function(r) {
|
1024 | let src = elementString(r.src);
|
1025 | let dst = elementString(r.dst);
|
1026 | g.setEdge(src, dst, { relationship: r });
|
1027 | });
|
1028 | return relationships;
|
1029 | };
|
1030 | const adjustEntities = function(svgNode, graph) {
|
1031 | graph.nodes().forEach(function(v) {
|
1032 | if (v !== void 0 && graph.node(v) !== void 0) {
|
1033 | svgNode.select("#" + v);
|
1034 | svgNode.select("#" + v).attr(
|
1035 | "transform",
|
1036 | "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y - graph.node(v).height / 2) + " )"
|
1037 | );
|
1038 | }
|
1039 | });
|
1040 | return;
|
1041 | };
|
1042 | const elementString = (str) => {
|
1043 | return str.replace(/\s/g, "").replace(/\./g, "_");
|
1044 | };
|
1045 | const draw = (text, id, _version, diagObj) => {
|
1046 | conf = getConfig().requirement;
|
1047 | const securityLevel = conf.securityLevel;
|
1048 | let sandboxElement;
|
1049 | if (securityLevel === "sandbox") {
|
1050 | sandboxElement = select("#i" + id);
|
1051 | }
|
1052 | const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
|
1053 | const svg = root.select(`[id='${id}']`);
|
1054 | markers.insertLineEndings(svg, conf);
|
1055 | const g = new graphlib.Graph({
|
1056 | multigraph: false,
|
1057 | compound: false,
|
1058 | directed: true
|
1059 | }).setGraph({
|
1060 | rankdir: conf.layoutDirection,
|
1061 | marginx: 20,
|
1062 | marginy: 20,
|
1063 | nodesep: 100,
|
1064 | edgesep: 100,
|
1065 | ranksep: 100
|
1066 | }).setDefaultEdgeLabel(function() {
|
1067 | return {};
|
1068 | });
|
1069 | let requirements2 = diagObj.db.getRequirements();
|
1070 | let elements2 = diagObj.db.getElements();
|
1071 | let relationships = diagObj.db.getRelationships();
|
1072 | drawReqs(requirements2, g, svg);
|
1073 | drawElements(elements2, g, svg);
|
1074 | addRelationships(relationships, g);
|
1075 | layout(g);
|
1076 | adjustEntities(svg, g);
|
1077 | relationships.forEach(function(rel) {
|
1078 | drawRelationshipFromLayout(svg, rel, g, id, diagObj);
|
1079 | });
|
1080 | const padding = conf.rect_padding;
|
1081 | const svgBounds = svg.node().getBBox();
|
1082 | const width = svgBounds.width + padding * 2;
|
1083 | const height = svgBounds.height + padding * 2;
|
1084 | configureSvgSize(svg, height, width, conf.useMaxWidth);
|
1085 | svg.attr("viewBox", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`);
|
1086 | };
|
1087 | const renderer = {
|
1088 | draw
|
1089 | };
|
1090 | const diagram = {
|
1091 | parser: parser$1,
|
1092 | db,
|
1093 | renderer,
|
1094 | styles
|
1095 | };
|
1096 | export {
|
1097 | diagram
|
1098 | };
|
1099 |
|
\ | No newline at end of file |