schematex 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/ai-sdk.cjs +7 -7
- package/dist/ai/ai-sdk.js +2 -2
- package/dist/ai/index.cjs +16 -16
- package/dist/ai/index.js +3 -3
- package/dist/browser.cjs +8 -8
- package/dist/browser.js +2 -2
- package/dist/{chunk-4W75FGWO.js → chunk-3K4WCRVI.js} +89 -20
- package/dist/chunk-3K4WCRVI.js.map +1 -0
- package/dist/{chunk-KH5GRKUM.cjs → chunk-6X7MVZZT.cjs} +89 -20
- package/dist/chunk-6X7MVZZT.cjs.map +1 -0
- package/dist/{chunk-CVTHUOAM.js → chunk-DVRB64CN.js} +33 -8
- package/dist/chunk-DVRB64CN.js.map +1 -0
- package/dist/{chunk-HX64QWB6.cjs → chunk-ECHPMEZX.cjs} +35 -10
- package/dist/chunk-ECHPMEZX.cjs.map +1 -0
- package/dist/index.cjs +34 -34
- package/dist/index.js +2 -2
- package/dist/react.cjs +2 -2
- package/dist/react.js +1 -1
- package/package.json +3 -1
- package/dist/chunk-4W75FGWO.js.map +0 -1
- package/dist/chunk-CVTHUOAM.js.map +0 -1
- package/dist/chunk-HX64QWB6.cjs.map +0 -1
- package/dist/chunk-KH5GRKUM.cjs.map +0 -1
package/dist/ai/ai-sdk.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkECHPMEZX_cjs = require('../chunk-ECHPMEZX.cjs');
|
|
4
|
+
require('../chunk-6X7MVZZT.cjs');
|
|
5
5
|
require('../chunk-4OC3CTGE.cjs');
|
|
6
6
|
require('../chunk-4AC6I7KJ.cjs');
|
|
7
7
|
require('../chunk-C4Y24X3U.cjs');
|
|
@@ -31,7 +31,7 @@ var schematexTools = {
|
|
|
31
31
|
listDiagrams: ai.tool({
|
|
32
32
|
description: "List every Schematex diagram type with a tagline, 'use when' hint, domain cluster, and authoritative standard. Call this first to discover what's available.",
|
|
33
33
|
inputSchema: zod.z.object({}),
|
|
34
|
-
execute: async () =>
|
|
34
|
+
execute: async () => chunkECHPMEZX_cjs.listDiagrams()
|
|
35
35
|
}),
|
|
36
36
|
getSyntax: ai.tool({
|
|
37
37
|
description: "Return syntax for one diagram type. Default `detail: canonical` is the compact first-shot generation path: canonical header, preferred forms, rules, and repair checks. Request `detail: reference` only for advanced forms or imported adapters after choosing a type.",
|
|
@@ -46,7 +46,7 @@ var schematexTools = {
|
|
|
46
46
|
execute: async ({
|
|
47
47
|
type,
|
|
48
48
|
detail
|
|
49
|
-
}) =>
|
|
49
|
+
}) => chunkECHPMEZX_cjs.getSyntax(type, { detail })
|
|
50
50
|
}),
|
|
51
51
|
getExamples: ai.tool({
|
|
52
52
|
description: "Return curated real-world DSL examples for a diagram type, each with scenario notes and tags. Use as few-shot context before generating DSL.",
|
|
@@ -56,7 +56,7 @@ var schematexTools = {
|
|
|
56
56
|
preferFeatured: zod.z.boolean().optional().describe("Rank featured examples first."),
|
|
57
57
|
maxComplexity: zod.z.number().int().min(1).max(5).optional().describe("Only return examples with complexity <= this value (1=simplest).")
|
|
58
58
|
}),
|
|
59
|
-
execute: async (args) =>
|
|
59
|
+
execute: async (args) => chunkECHPMEZX_cjs.getExamples(args.type, {
|
|
60
60
|
limit: args.limit,
|
|
61
61
|
preferFeatured: args.preferFeatured,
|
|
62
62
|
maxComplexity: args.maxComplexity
|
|
@@ -70,7 +70,7 @@ var schematexTools = {
|
|
|
70
70
|
),
|
|
71
71
|
dsl: zod.z.string().describe("The DSL source text to validate.")
|
|
72
72
|
}),
|
|
73
|
-
execute: async ({ type, dsl }) =>
|
|
73
|
+
execute: async ({ type, dsl }) => chunkECHPMEZX_cjs.validateDsl(type, dsl)
|
|
74
74
|
}),
|
|
75
75
|
renderDsl: ai.tool({
|
|
76
76
|
description: "Render Schematex DSL to an SVG string. Returns { ok: true, svg } or { ok: false, errors }. Use when the caller needs the actual diagram output, not just validation.",
|
|
@@ -85,7 +85,7 @@ var schematexTools = {
|
|
|
85
85
|
dsl,
|
|
86
86
|
theme,
|
|
87
87
|
padding
|
|
88
|
-
}) =>
|
|
88
|
+
}) => chunkECHPMEZX_cjs.renderDsl(type, dsl, { theme, padding })
|
|
89
89
|
})
|
|
90
90
|
};
|
|
91
91
|
|
package/dist/ai/ai-sdk.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { renderDsl, validateDsl, getExamples, getSyntax, listDiagrams } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
import { renderDsl, validateDsl, getExamples, getSyntax, listDiagrams } from '../chunk-DVRB64CN.js';
|
|
2
|
+
import '../chunk-3K4WCRVI.js';
|
|
3
3
|
import '../chunk-3J4DZPZC.js';
|
|
4
4
|
import '../chunk-RDYACU2G.js';
|
|
5
5
|
import '../chunk-3PH2MQGN.js';
|
package/dist/ai/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkECHPMEZX_cjs = require('../chunk-ECHPMEZX.cjs');
|
|
4
|
+
require('../chunk-6X7MVZZT.cjs');
|
|
5
5
|
require('../chunk-4OC3CTGE.cjs');
|
|
6
6
|
require('../chunk-4AC6I7KJ.cjs');
|
|
7
7
|
require('../chunk-C4Y24X3U.cjs');
|
|
@@ -27,10 +27,10 @@ require('../chunk-3WNW5Y7P.cjs');
|
|
|
27
27
|
|
|
28
28
|
// src/ai/prompt-context.ts
|
|
29
29
|
function buildPromptContext(type, opts = {}) {
|
|
30
|
-
const resolved =
|
|
30
|
+
const resolved = chunkECHPMEZX_cjs.resolveDiagramType(type) ?? type;
|
|
31
31
|
const detail = opts.detail ?? "canonical";
|
|
32
32
|
const limit = opts.examples ?? 2;
|
|
33
|
-
const { type: canonical, name, standard, syntax } =
|
|
33
|
+
const { type: canonical, name, standard, syntax } = chunkECHPMEZX_cjs.getSyntax(resolved, {
|
|
34
34
|
detail
|
|
35
35
|
});
|
|
36
36
|
const parts = [
|
|
@@ -41,7 +41,7 @@ function buildPromptContext(type, opts = {}) {
|
|
|
41
41
|
];
|
|
42
42
|
let exampleCount = 0;
|
|
43
43
|
if (limit > 0) {
|
|
44
|
-
const examples =
|
|
44
|
+
const examples = chunkECHPMEZX_cjs.getExamples(canonical, {
|
|
45
45
|
preferFeatured: opts.preferFeatured ?? true,
|
|
46
46
|
limit,
|
|
47
47
|
maxComplexity: opts.maxComplexity
|
|
@@ -67,47 +67,47 @@ function buildPromptContext(type, opts = {}) {
|
|
|
67
67
|
|
|
68
68
|
Object.defineProperty(exports, "DIAGRAM_REGISTRY", {
|
|
69
69
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunkECHPMEZX_cjs.DIAGRAM_REGISTRY; }
|
|
71
71
|
});
|
|
72
72
|
Object.defineProperty(exports, "DIAGRAM_SINCE", {
|
|
73
73
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkECHPMEZX_cjs.DIAGRAM_SINCE; }
|
|
75
75
|
});
|
|
76
76
|
Object.defineProperty(exports, "getAllDiagramTypes", {
|
|
77
77
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkECHPMEZX_cjs.getAllDiagramTypes; }
|
|
79
79
|
});
|
|
80
80
|
Object.defineProperty(exports, "getDiagramMeta", {
|
|
81
81
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunkECHPMEZX_cjs.getDiagramMeta; }
|
|
83
83
|
});
|
|
84
84
|
Object.defineProperty(exports, "getDiagramSince", {
|
|
85
85
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkECHPMEZX_cjs.getDiagramSince; }
|
|
87
87
|
});
|
|
88
88
|
Object.defineProperty(exports, "getExamples", {
|
|
89
89
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkECHPMEZX_cjs.getExamples; }
|
|
91
91
|
});
|
|
92
92
|
Object.defineProperty(exports, "getSyntax", {
|
|
93
93
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkECHPMEZX_cjs.getSyntax; }
|
|
95
95
|
});
|
|
96
96
|
Object.defineProperty(exports, "listDiagrams", {
|
|
97
97
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkECHPMEZX_cjs.listDiagrams; }
|
|
99
99
|
});
|
|
100
100
|
Object.defineProperty(exports, "renderDsl", {
|
|
101
101
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkECHPMEZX_cjs.renderDsl; }
|
|
103
103
|
});
|
|
104
104
|
Object.defineProperty(exports, "resolveDiagramType", {
|
|
105
105
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
106
|
+
get: function () { return chunkECHPMEZX_cjs.resolveDiagramType; }
|
|
107
107
|
});
|
|
108
108
|
Object.defineProperty(exports, "validateDsl", {
|
|
109
109
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkECHPMEZX_cjs.validateDsl; }
|
|
111
111
|
});
|
|
112
112
|
exports.buildPromptContext = buildPromptContext;
|
|
113
113
|
//# sourceMappingURL=index.cjs.map
|
package/dist/ai/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { resolveDiagramType, getSyntax, getExamples } from '../chunk-
|
|
2
|
-
export { DIAGRAM_REGISTRY, DIAGRAM_SINCE, getAllDiagramTypes, getDiagramMeta, getDiagramSince, getExamples, getSyntax, listDiagrams, renderDsl, resolveDiagramType, validateDsl } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
import { resolveDiagramType, getSyntax, getExamples } from '../chunk-DVRB64CN.js';
|
|
2
|
+
export { DIAGRAM_REGISTRY, DIAGRAM_SINCE, getAllDiagramTypes, getDiagramMeta, getDiagramSince, getExamples, getSyntax, listDiagrams, renderDsl, resolveDiagramType, validateDsl } from '../chunk-DVRB64CN.js';
|
|
3
|
+
import '../chunk-3K4WCRVI.js';
|
|
4
4
|
import '../chunk-3J4DZPZC.js';
|
|
5
5
|
import '../chunk-RDYACU2G.js';
|
|
6
6
|
import '../chunk-3PH2MQGN.js';
|
package/dist/browser.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk6X7MVZZT_cjs = require('./chunk-6X7MVZZT.cjs');
|
|
4
4
|
require('./chunk-4OC3CTGE.cjs');
|
|
5
5
|
require('./chunk-4AC6I7KJ.cjs');
|
|
6
6
|
require('./chunk-C4Y24X3U.cjs');
|
|
@@ -26,10 +26,10 @@ require('./chunk-3WNW5Y7P.cjs');
|
|
|
26
26
|
|
|
27
27
|
// src/browser.ts
|
|
28
28
|
function renderToElement(text, config) {
|
|
29
|
-
return svgStringToElement(
|
|
29
|
+
return svgStringToElement(chunk6X7MVZZT_cjs.render(text, config));
|
|
30
30
|
}
|
|
31
31
|
function renderPreviewToElement(text, config) {
|
|
32
|
-
return svgStringToElement(
|
|
32
|
+
return svgStringToElement(chunk6X7MVZZT_cjs.renderPreview(text, config));
|
|
33
33
|
}
|
|
34
34
|
function svgStringToElement(svgString) {
|
|
35
35
|
const parser = new DOMParser();
|
|
@@ -42,23 +42,23 @@ function svgStringToElement(svgString) {
|
|
|
42
42
|
return el;
|
|
43
43
|
}
|
|
44
44
|
function renderToContainer(text, container, config) {
|
|
45
|
-
container.innerHTML =
|
|
45
|
+
container.innerHTML = chunk6X7MVZZT_cjs.render(text, config);
|
|
46
46
|
}
|
|
47
47
|
function renderPreviewToContainer(text, container, config) {
|
|
48
|
-
container.innerHTML =
|
|
48
|
+
container.innerHTML = chunk6X7MVZZT_cjs.renderPreview(text, config);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
Object.defineProperty(exports, "render", {
|
|
52
52
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunk6X7MVZZT_cjs.render; }
|
|
54
54
|
});
|
|
55
55
|
Object.defineProperty(exports, "renderPreview", {
|
|
56
56
|
enumerable: true,
|
|
57
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunk6X7MVZZT_cjs.renderPreview; }
|
|
58
58
|
});
|
|
59
59
|
Object.defineProperty(exports, "renderResult", {
|
|
60
60
|
enumerable: true,
|
|
61
|
-
get: function () { return
|
|
61
|
+
get: function () { return chunk6X7MVZZT_cjs.renderResult; }
|
|
62
62
|
});
|
|
63
63
|
exports.renderPreviewToContainer = renderPreviewToContainer;
|
|
64
64
|
exports.renderPreviewToElement = renderPreviewToElement;
|
package/dist/browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { render, renderPreview } from './chunk-
|
|
2
|
-
export { render, renderPreview, renderResult } from './chunk-
|
|
1
|
+
import { render, renderPreview } from './chunk-3K4WCRVI.js';
|
|
2
|
+
export { render, renderPreview, renderResult } from './chunk-3K4WCRVI.js';
|
|
3
3
|
import './chunk-3J4DZPZC.js';
|
|
4
4
|
import './chunk-RDYACU2G.js';
|
|
5
5
|
import './chunk-3PH2MQGN.js';
|
|
@@ -17464,6 +17464,19 @@ function truncate3(s, n) {
|
|
|
17464
17464
|
return s.length <= n ? s : s.slice(0, n - 1) + "\u2026";
|
|
17465
17465
|
}
|
|
17466
17466
|
|
|
17467
|
+
// src/core/format.ts
|
|
17468
|
+
function formatProbability(n) {
|
|
17469
|
+
if (!Number.isFinite(n)) return String(n);
|
|
17470
|
+
if (n <= 0) return "0";
|
|
17471
|
+
if (n >= 1) return "1";
|
|
17472
|
+
if (n < 1e-3) return n.toExponential(2);
|
|
17473
|
+
for (let p = 3; p <= 9; p++) {
|
|
17474
|
+
const s = parseFloat(n.toPrecision(p));
|
|
17475
|
+
if (s > 0 && s < 1) return String(s);
|
|
17476
|
+
}
|
|
17477
|
+
return String(parseFloat(n.toPrecision(9)));
|
|
17478
|
+
}
|
|
17479
|
+
|
|
17467
17480
|
// src/diagrams/faulttree/analysis.ts
|
|
17468
17481
|
var EXPANSION_CAP = 5e4;
|
|
17469
17482
|
var EXACT_CUTSET_CAP = 20;
|
|
@@ -18217,9 +18230,7 @@ function summarise2(layout) {
|
|
|
18217
18230
|
return parts.join(" ");
|
|
18218
18231
|
}
|
|
18219
18232
|
function fmtProb(n) {
|
|
18220
|
-
|
|
18221
|
-
if (n >= 1e-3) return String(parseFloat(n.toPrecision(3)));
|
|
18222
|
-
return n.toExponential(2);
|
|
18233
|
+
return formatProbability(n);
|
|
18223
18234
|
}
|
|
18224
18235
|
function clip2(s, n) {
|
|
18225
18236
|
return s.length <= n ? s : s.slice(0, n - 1) + "\u2026";
|
|
@@ -20682,6 +20693,7 @@ function parseRbd(text2) {
|
|
|
20682
20693
|
seenIds.add(id);
|
|
20683
20694
|
let label;
|
|
20684
20695
|
let R;
|
|
20696
|
+
let dist;
|
|
20685
20697
|
if (peek()?.t === "string") {
|
|
20686
20698
|
label = tokens[pos++].v;
|
|
20687
20699
|
}
|
|
@@ -20690,10 +20702,16 @@ function parseRbd(text2) {
|
|
|
20690
20702
|
const attr = parseAttr(w);
|
|
20691
20703
|
if (!attr) break;
|
|
20692
20704
|
pos++;
|
|
20693
|
-
if (attr.
|
|
20694
|
-
else R = clamp01(attr.value, w, warnings);
|
|
20705
|
+
if (attr.kind === "dist") dist = attr.dist;
|
|
20706
|
+
else R = clamp01(attr.failure ? 1 - attr.value : attr.value, w, warnings);
|
|
20695
20707
|
}
|
|
20696
|
-
return {
|
|
20708
|
+
return {
|
|
20709
|
+
kind: "block",
|
|
20710
|
+
id,
|
|
20711
|
+
...label !== void 0 ? { label } : {},
|
|
20712
|
+
...R !== void 0 ? { R } : {},
|
|
20713
|
+
...dist !== void 0 ? { dist } : {}
|
|
20714
|
+
};
|
|
20697
20715
|
};
|
|
20698
20716
|
const parseGroup = (kwRaw) => {
|
|
20699
20717
|
const kw = kwRaw.toLowerCase();
|
|
@@ -20767,10 +20785,19 @@ function parseRbd(text2) {
|
|
|
20767
20785
|
} else {
|
|
20768
20786
|
root = { kind: "series", children: top };
|
|
20769
20787
|
}
|
|
20788
|
+
let mission;
|
|
20789
|
+
if (metadata.mission !== void 0) {
|
|
20790
|
+
const v = parseFloat(metadata.mission);
|
|
20791
|
+
if (!Number.isFinite(v) || v < 0) {
|
|
20792
|
+
throw new RbdParseError(`mission time must be a non-negative number (got '${metadata.mission}')`);
|
|
20793
|
+
}
|
|
20794
|
+
mission = v;
|
|
20795
|
+
}
|
|
20770
20796
|
return {
|
|
20771
20797
|
type: "rbd",
|
|
20772
20798
|
...title2 ? { title: title2 } : {},
|
|
20773
20799
|
root,
|
|
20800
|
+
...mission !== void 0 ? { mission } : {},
|
|
20774
20801
|
warnings,
|
|
20775
20802
|
...Object.keys(metadata).length > 0 ? { metadata } : {}
|
|
20776
20803
|
};
|
|
@@ -20823,11 +20850,10 @@ function tokenize6(src) {
|
|
|
20823
20850
|
}
|
|
20824
20851
|
function stripBodyDirectives(body, metadata) {
|
|
20825
20852
|
return body.split("\n").filter((line2) => {
|
|
20826
|
-
const m = line2.match(/^\s*(title|standard|note)\s*:\s*(.+)$/i);
|
|
20853
|
+
const m = line2.match(/^\s*(title|standard|note|mission)\s*:\s*(.+)$/i);
|
|
20827
20854
|
if (m) {
|
|
20828
20855
|
const key = m[1].toLowerCase();
|
|
20829
|
-
|
|
20830
|
-
else metadata.title = m[2].trim();
|
|
20856
|
+
metadata[key] = m[2].trim();
|
|
20831
20857
|
return false;
|
|
20832
20858
|
}
|
|
20833
20859
|
return true;
|
|
@@ -20839,15 +20865,33 @@ function extractQuoted(s) {
|
|
|
20839
20865
|
return s.length > 0 ? s.trim() : void 0;
|
|
20840
20866
|
}
|
|
20841
20867
|
function parseAttr(w) {
|
|
20868
|
+
const wb = w.match(/^weibull\s*[=:]\s*(.+)$/i);
|
|
20869
|
+
if (wb) {
|
|
20870
|
+
const parts = wb[1].split(",").map((s) => parseFloat(s.trim()));
|
|
20871
|
+
if (parts.length === 2 && parts.every((x) => Number.isFinite(x) && x > 0)) {
|
|
20872
|
+
return { kind: "dist", dist: { kind: "weibull", beta: parts[0], eta: parts[1] } };
|
|
20873
|
+
}
|
|
20874
|
+
return null;
|
|
20875
|
+
}
|
|
20876
|
+
const rt = w.match(/^rate\s*[=:]\s*(.+)$/i);
|
|
20877
|
+
if (rt) {
|
|
20878
|
+
const v = parseFloat(rt[1].trim());
|
|
20879
|
+
return Number.isFinite(v) && v >= 0 ? { kind: "dist", dist: { kind: "exp", rate: v } } : null;
|
|
20880
|
+
}
|
|
20881
|
+
const mt = w.match(/^(mtbf|mttf)\s*[=:]\s*(.+)$/i);
|
|
20882
|
+
if (mt) {
|
|
20883
|
+
const v = parseFloat(mt[2].trim());
|
|
20884
|
+
return Number.isFinite(v) && v > 0 ? { kind: "dist", dist: { kind: "exp", rate: 1 / v } } : null;
|
|
20885
|
+
}
|
|
20842
20886
|
const m = w.match(/^(R|r|p|prob|q)\s*[=:]\s*(.+)$/);
|
|
20843
20887
|
if (m) {
|
|
20844
20888
|
const key = m[1].toLowerCase();
|
|
20845
20889
|
const value = parseNum(m[2]);
|
|
20846
20890
|
if (value === void 0) return null;
|
|
20847
|
-
return {
|
|
20891
|
+
return { kind: "R", value, failure: key === "p" || key === "q" };
|
|
20848
20892
|
}
|
|
20849
20893
|
const bare = parseNum(w);
|
|
20850
|
-
if (bare !== void 0) return {
|
|
20894
|
+
if (bare !== void 0) return { kind: "R", value: bare, failure: false };
|
|
20851
20895
|
return null;
|
|
20852
20896
|
}
|
|
20853
20897
|
function parseNum(s) {
|
|
@@ -20876,8 +20920,11 @@ var KOFN_ENUM_CAP = 18;
|
|
|
20876
20920
|
function analyseRbd(ast) {
|
|
20877
20921
|
const notes = [];
|
|
20878
20922
|
const warnings = [...ast.warnings];
|
|
20923
|
+
if (ast.mission !== void 0) {
|
|
20924
|
+
notes.push(`Mission time t = ${ast.mission}; block reliabilities with a rate/MTBF/Weibull are evaluated as R(t).`);
|
|
20925
|
+
}
|
|
20879
20926
|
const blocks = [];
|
|
20880
|
-
collectBlocks(ast.root, blocks);
|
|
20927
|
+
collectBlocks(ast.root, blocks, ast.mission, warnings);
|
|
20881
20928
|
const missing = blocks.filter((b) => b.R === void 0).map((b) => b.id);
|
|
20882
20929
|
const baseEnv = new Map(blocks.map((b) => [b.id, b.R]));
|
|
20883
20930
|
const systemReliability = evalStructure(ast.root, baseEnv, notes);
|
|
@@ -20893,10 +20940,15 @@ function analyseRbd(ast) {
|
|
|
20893
20940
|
const rDown = evalStructure(ast.root, down, notes);
|
|
20894
20941
|
const importance = rUp !== void 0 && rDown !== void 0 ? rUp - rDown : void 0;
|
|
20895
20942
|
const isSpof = rDown === 0;
|
|
20943
|
+
let criticality;
|
|
20944
|
+
if (importance !== void 0 && b.R !== void 0 && systemReliability < 1) {
|
|
20945
|
+
criticality = importance * (1 - b.R) / (1 - systemReliability);
|
|
20946
|
+
}
|
|
20896
20947
|
return {
|
|
20897
20948
|
id: b.id,
|
|
20898
20949
|
...b.R !== void 0 ? { R: b.R } : {},
|
|
20899
20950
|
...importance !== void 0 ? { importance } : {},
|
|
20951
|
+
...criticality !== void 0 ? { criticality } : {},
|
|
20900
20952
|
isSpof
|
|
20901
20953
|
};
|
|
20902
20954
|
});
|
|
@@ -20921,12 +20973,25 @@ function analyseRbd(ast) {
|
|
|
20921
20973
|
notes
|
|
20922
20974
|
};
|
|
20923
20975
|
}
|
|
20924
|
-
function collectBlocks(s, out) {
|
|
20976
|
+
function collectBlocks(s, out, mission, warnings) {
|
|
20925
20977
|
if (s.kind === "block") {
|
|
20926
|
-
|
|
20978
|
+
const R = resolveBlockR(s, mission, warnings);
|
|
20979
|
+
out.push({ id: s.id, ...R !== void 0 ? { R } : {} });
|
|
20927
20980
|
return;
|
|
20928
20981
|
}
|
|
20929
|
-
for (const c of s.children) collectBlocks(c, out);
|
|
20982
|
+
for (const c of s.children) collectBlocks(c, out, mission, warnings);
|
|
20983
|
+
}
|
|
20984
|
+
function resolveBlockR(b, mission, warnings) {
|
|
20985
|
+
if (b.dist) {
|
|
20986
|
+
if (mission === void 0) {
|
|
20987
|
+
warnings.push(`Block "${b.id}" has a failure distribution but no mission time \u2014 add 'mission: <t>' to evaluate R(t)${b.R !== void 0 ? ", falling back to its constant R" : ""}.`);
|
|
20988
|
+
return b.R;
|
|
20989
|
+
}
|
|
20990
|
+
const t = mission;
|
|
20991
|
+
if (b.dist.kind === "exp") return Math.exp(-b.dist.rate * t);
|
|
20992
|
+
return Math.exp(-Math.pow(t / b.dist.eta, b.dist.beta));
|
|
20993
|
+
}
|
|
20994
|
+
return b.R;
|
|
20930
20995
|
}
|
|
20931
20996
|
function evalStructure(s, env, notes) {
|
|
20932
20997
|
if (s.kind === "block") return env.get(s.id);
|
|
@@ -21157,7 +21222,7 @@ function renderRbdLayout(layout, config) {
|
|
|
21157
21222
|
class: "sx-rbd-rsys",
|
|
21158
21223
|
"text-anchor": "middle"
|
|
21159
21224
|
},
|
|
21160
|
-
systemLabel(analysis)
|
|
21225
|
+
systemLabel(analysis, ast.mission)
|
|
21161
21226
|
)
|
|
21162
21227
|
);
|
|
21163
21228
|
for (const w of layout.wires) inner.push(path({ d: w.path, class: "sx-rbd-wire" }));
|
|
@@ -21227,12 +21292,16 @@ function renderBlock(b) {
|
|
|
21227
21292
|
parts
|
|
21228
21293
|
);
|
|
21229
21294
|
}
|
|
21230
|
-
function systemLabel(analysis) {
|
|
21295
|
+
function systemLabel(analysis, mission) {
|
|
21231
21296
|
if (analysis.systemReliability === void 0) {
|
|
21232
21297
|
const miss = analysis.missing.length > 0 ? ` \u2014 missing R on ${analysis.missing.join(", ")}` : "";
|
|
21233
21298
|
return `System reliability: n/a${miss}`;
|
|
21234
21299
|
}
|
|
21235
|
-
|
|
21300
|
+
const arg = mission !== void 0 ? `(t=${fmtVal3(mission)})` : "";
|
|
21301
|
+
return `System reliability R${arg} = ${fmtR(analysis.systemReliability)}`;
|
|
21302
|
+
}
|
|
21303
|
+
function fmtVal3(n) {
|
|
21304
|
+
return String(parseFloat(n.toFixed(2)));
|
|
21236
21305
|
}
|
|
21237
21306
|
function fmtR(n) {
|
|
21238
21307
|
if (n >= 1) return "1";
|
|
@@ -41246,5 +41315,5 @@ function renderWithPlugin(prepared, plugin, config) {
|
|
|
41246
41315
|
}
|
|
41247
41316
|
|
|
41248
41317
|
export { FLOORPLAN_SYMBOLS, GEOMETRY, bowtie2 as bowtie, causalloop, decisiontree, drawDeviceIcon, epc, eventtree, faulttree, fmea, gitgraph, iconSize, idef0, markov, network, parse, parseResult, pert, petri, pid, prisma, rbd, render, renderEquip, renderPreview, renderResult, sequence, state, threatmodel, timeline, umlclass, usecase, welding };
|
|
41249
|
-
//# sourceMappingURL=chunk-
|
|
41250
|
-
//# sourceMappingURL=chunk-
|
|
41318
|
+
//# sourceMappingURL=chunk-3K4WCRVI.js.map
|
|
41319
|
+
//# sourceMappingURL=chunk-3K4WCRVI.js.map
|