@peter.prib/renderengine 0.15.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/renderengine-workspace.umd.js +6030 -3766
- package/dist/renderengine.umd.js +5930 -3772
- package/documentation/REFERENCE.md +37 -3
- package/package.json +1 -1
- package/src/archimateArchiFormat.js +114 -10
- package/src/archimateArchive.js +27 -4
- package/src/archimateExchangeFormat.js +12 -4
- package/src/archimateSpecializations.js +11 -1
- package/src/chartCatalog.js +6 -4
- package/src/charting/ArchimateDiagramEditor.js +5 -108
- package/src/charting/DiagramTypeRegistry.js +20 -1
- package/src/charting/DiagramViewPropertiesDialog.js +54 -10
- package/src/charting/Legend.js +1 -2
- package/src/charting/Statistics.js +14 -0
- package/src/charting/charts/BarChart.js +59 -8
- package/src/charting/charts/HexbinChart.js +15 -0
- package/src/charting/charts/LollipopChart.js +42 -7
- package/src/charting/decision/DecisionWorkbench.js +137 -4
- package/src/charting/diagramModel/DiagramView.js +7 -2
- package/src/charting/diagrams/GraphDiagram3D.js +15 -0
- package/src/charting/graph/GraphSource.js +72 -0
- package/src/charting/modelTree/NavigatorModel.js +22 -8
- package/src/charting/report/TemplatedReport.js +27 -377
- package/src/charting/report/ViewsReport.js +118 -0
- package/src/charting/report/reportWriters.js +496 -0
- package/src/charting/templates/C4BoundaryTemplate.js +34 -0
- package/src/charting/templates/C4ComponentTemplate.js +30 -0
- package/src/charting/templates/C4ContainerTemplate.js +49 -0
- package/src/charting/templates/C4PersonTemplate.js +35 -0
- package/src/charting/templates/C4SystemTemplate.js +32 -0
- package/src/charting/templates/C4Template.js +95 -0
- package/src/charting/templates/index.js +6 -0
- package/src/charting/templates/templateRegistry.js +7 -0
- package/src/compute/ComputeBackend.js +132 -0
- package/src/compute/CpuBackend.js +209 -0
- package/src/compute/WebGpuBackend.js +630 -0
- package/src/compute/index.js +5 -0
- package/src/compute/selectBackend.js +85 -0
- package/src/index.js +3403 -3371
- package/src/kernelExpr.js +80 -5
- package/src/workspace/parts/DiagramEditorPart.js +3 -1
- package/src/workspace/parts/ViewsPart.js +106 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Copyright 2026 Jaroslav Peter Prib, Purveyor of Excellence
|
|
2
|
+
import { CpuBackend } from './CpuBackend.js';
|
|
3
|
+
import { WebGpuBackend } from './WebGpuBackend.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Registry of available compute backends.
|
|
7
|
+
*/
|
|
8
|
+
export const BACKENDS = {
|
|
9
|
+
cpu: CpuBackend,
|
|
10
|
+
webgpu: WebGpuBackend,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const _navigatorGpu = () => (typeof navigator !== 'undefined' ? navigator.gpu : null);
|
|
14
|
+
|
|
15
|
+
async function _available(name, Backend, { gpu } = {}) {
|
|
16
|
+
if (name === 'webgpu') return Backend.isAvailable(gpu ?? _navigatorGpu());
|
|
17
|
+
return Backend.isAvailable();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function _construct(name, { gpu } = {}) {
|
|
21
|
+
if (name === 'webgpu') return new WebGpuBackend({ gpu: gpu ?? _navigatorGpu() });
|
|
22
|
+
return new CpuBackend();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Returns list of backend names available in the current runtime without initializing them.
|
|
27
|
+
* @param {object} [options]
|
|
28
|
+
* @param {object} [options.gpu]
|
|
29
|
+
* @returns {Promise<string[]>}
|
|
30
|
+
*/
|
|
31
|
+
export async function availableBackends({ gpu } = {}) {
|
|
32
|
+
const out = [];
|
|
33
|
+
for (const [name, Backend] of Object.entries(BACKENDS)) {
|
|
34
|
+
if (await _available(name, Backend, { gpu })) out.push(name);
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Select and optionally initialize the fastest available compute backend.
|
|
41
|
+
* Falls back gracefully to CpuBackend if WebGPU is unavailable or fails to initialize.
|
|
42
|
+
*
|
|
43
|
+
* @param {object} [options]
|
|
44
|
+
* @param {string[]} [options.prefer=['webgpu', 'cpu']]
|
|
45
|
+
* @param {object} [options.gpu]
|
|
46
|
+
* @param {boolean} [options.init=true]
|
|
47
|
+
* @returns {Promise<{backend: import('./ComputeBackend.js').ComputeBackend, attempts: Array<{backend: string, ok: boolean, reason?: string}>}>}
|
|
48
|
+
*/
|
|
49
|
+
export async function selectBackend({
|
|
50
|
+
prefer = ['webgpu', 'cpu'],
|
|
51
|
+
gpu,
|
|
52
|
+
init = true,
|
|
53
|
+
} = {}) {
|
|
54
|
+
const attempts = [];
|
|
55
|
+
|
|
56
|
+
for (const name of prefer) {
|
|
57
|
+
const Backend = BACKENDS[name];
|
|
58
|
+
if (!Backend) {
|
|
59
|
+
attempts.push({ backend: name, ok: false, reason: `unknown backend '${name}'` });
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const available = await _available(name, Backend, { gpu });
|
|
64
|
+
if (!available) {
|
|
65
|
+
attempts.push({ backend: name, ok: false, reason: 'not available here' });
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const backend = _construct(name, { gpu });
|
|
69
|
+
if (init) await backend.init();
|
|
70
|
+
return { backend, attempts: [...attempts, { backend: name, ok: true }] };
|
|
71
|
+
} catch (err) {
|
|
72
|
+
attempts.push({ backend: name, ok: false, reason: err.message });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Default fallback to CPU
|
|
77
|
+
if (!prefer.includes('cpu')) {
|
|
78
|
+
const cpu = new CpuBackend();
|
|
79
|
+
return { backend: cpu, attempts: [...attempts, { backend: 'cpu', ok: true, reason: 'fallback' }] };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
throw new Error(
|
|
83
|
+
`No compute backend could be started. Tried: ${attempts.map(a => `${a.backend} (${a.reason})`).join(', ')}`
|
|
84
|
+
);
|
|
85
|
+
}
|