@miragon/dmn-modeler 0.1.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/LICENSE +201 -0
- package/README.md +142 -0
- package/dist/darkTheme.css +1 -0
- package/dist/dmn-modeler.css +2 -0
- package/dist/dmn.eot +0 -0
- package/dist/dmn.svg +90 -0
- package/dist/index.d.ts +274 -0
- package/dist/index.js +470 -0
- package/dist/lightTheme.css +1 -0
- package/package.json +82 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { TranslateModule as e, i18n as t } from "@miragon/bpmn-modeler-i18n";
|
|
2
|
+
import n from "dmn-js/lib/Modeler";
|
|
3
|
+
import { CamundaPropertiesProviderModule as r, DmnPropertiesPanelModule as i, DmnPropertiesProviderModule as a } from "dmn-js-properties-panel";
|
|
4
|
+
import o from "@emaarco/dmn-js-simulation";
|
|
5
|
+
import s from "camunda-dmn-moddle/resources/camunda.json";
|
|
6
|
+
import "lodash";
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region ../../libs/bpmn-i18n-extras/src/languages/index.ts
|
|
9
|
+
var c = {
|
|
10
|
+
de: {
|
|
11
|
+
"Being edited in": "Wird bearbeitet in",
|
|
12
|
+
Design: "Entwurf",
|
|
13
|
+
"Element actions": "Elementaktionen",
|
|
14
|
+
Implement: "Implementieren",
|
|
15
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "Für „Implementieren“ wird eine Camunda-Ausführungsplattform benötigt – dieses Modell hat keine. Weisen Sie eine zu, um es zu aktivieren.",
|
|
16
|
+
Mode: "Modus",
|
|
17
|
+
"Read-only": "Schreibgeschützt",
|
|
18
|
+
View: "Ansicht",
|
|
19
|
+
double: "double",
|
|
20
|
+
integer: "integer",
|
|
21
|
+
"{mode} — open properties panel": "{mode} – Eigenschaftenbereich öffnen"
|
|
22
|
+
},
|
|
23
|
+
en: {
|
|
24
|
+
"Being edited in": "Being edited in",
|
|
25
|
+
Design: "Design",
|
|
26
|
+
"Element actions": "Element actions",
|
|
27
|
+
Implement: "Implement",
|
|
28
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "Implement needs a Camunda execution platform — this model has none. Assign one to enable it.",
|
|
29
|
+
Mode: "Mode",
|
|
30
|
+
"Read-only": "Read-only",
|
|
31
|
+
View: "View",
|
|
32
|
+
double: "double",
|
|
33
|
+
integer: "integer",
|
|
34
|
+
"{mode} — open properties panel": "{mode} — open properties panel"
|
|
35
|
+
},
|
|
36
|
+
es: {
|
|
37
|
+
"Being edited in": "Se está editando en",
|
|
38
|
+
Design: "Diseño",
|
|
39
|
+
"Element actions": "Acciones del elemento",
|
|
40
|
+
Implement: "Implementar",
|
|
41
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "Implementar necesita una plataforma de ejecución de Camunda; este modelo no tiene ninguna. Asigne una para habilitarlo.",
|
|
42
|
+
Mode: "Modo",
|
|
43
|
+
"Read-only": "Solo lectura",
|
|
44
|
+
View: "Ver",
|
|
45
|
+
double: "double",
|
|
46
|
+
integer: "integer",
|
|
47
|
+
"{mode} — open properties panel": "{mode}: abrir el panel de propiedades"
|
|
48
|
+
},
|
|
49
|
+
fr: {
|
|
50
|
+
"Being edited in": "En cours d'édition dans",
|
|
51
|
+
Design: "Conception",
|
|
52
|
+
"Element actions": "Actions de l'élément",
|
|
53
|
+
Implement: "Implémenter",
|
|
54
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "« Implémenter » nécessite une plateforme d'exécution Camunda ; ce modèle n'en a aucune. Attribuez-en une pour l'activer.",
|
|
55
|
+
Mode: "Mode",
|
|
56
|
+
"Read-only": "Lecture seule",
|
|
57
|
+
View: "Vue",
|
|
58
|
+
double: "double",
|
|
59
|
+
integer: "integer",
|
|
60
|
+
"{mode} — open properties panel": "{mode} — ouvrir le panneau des propriétés"
|
|
61
|
+
},
|
|
62
|
+
it: {
|
|
63
|
+
"Being edited in": "In modifica in",
|
|
64
|
+
Design: "Progettazione",
|
|
65
|
+
"Element actions": "Azioni elemento",
|
|
66
|
+
Implement: "Implementa",
|
|
67
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "«Implementa» richiede una piattaforma di esecuzione Camunda; questo modello non ne ha una. Assegnane una per abilitarla.",
|
|
68
|
+
Mode: "Modalità",
|
|
69
|
+
"Read-only": "Sola lettura",
|
|
70
|
+
View: "Visualizza",
|
|
71
|
+
double: "double",
|
|
72
|
+
integer: "integer",
|
|
73
|
+
"{mode} — open properties panel": "{mode} — apri il pannello delle proprietà"
|
|
74
|
+
},
|
|
75
|
+
ja: {
|
|
76
|
+
"Being edited in": "編集中:",
|
|
77
|
+
Design: "デザイン",
|
|
78
|
+
"Element actions": "要素アクション",
|
|
79
|
+
Implement: "実装",
|
|
80
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "実装には Camunda 実行プラットフォームが必要ですが、このモデルにはありません。有効にするには割り当ててください。",
|
|
81
|
+
Mode: "モード",
|
|
82
|
+
"Read-only": "読み取り専用",
|
|
83
|
+
View: "表示",
|
|
84
|
+
double: "double",
|
|
85
|
+
integer: "integer",
|
|
86
|
+
"{mode} — open properties panel": "{mode} — プロパティパネルを開く"
|
|
87
|
+
},
|
|
88
|
+
ko: {
|
|
89
|
+
"Being edited in": "편집 중:",
|
|
90
|
+
Design: "디자인",
|
|
91
|
+
"Element actions": "요소 작업",
|
|
92
|
+
Implement: "구현",
|
|
93
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "구현하려면 Camunda 실행 플랫폼이 필요하지만 이 모델에는 없습니다. 사용하려면 하나를 지정하세요.",
|
|
94
|
+
Mode: "모드",
|
|
95
|
+
"Read-only": "읽기 전용",
|
|
96
|
+
View: "보기",
|
|
97
|
+
double: "double",
|
|
98
|
+
integer: "integer",
|
|
99
|
+
"{mode} — open properties panel": "{mode} — 속성 패널 열기"
|
|
100
|
+
},
|
|
101
|
+
"nl-nl": {
|
|
102
|
+
"Being edited in": "Wordt bewerkt in",
|
|
103
|
+
Design: "Ontwerp",
|
|
104
|
+
"Element actions": "Elementacties",
|
|
105
|
+
Implement: "Implementeren",
|
|
106
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "Voor Implementeren is een Camunda-uitvoeringsplatform nodig; dit model heeft er geen. Wijs er een toe om het in te schakelen.",
|
|
107
|
+
Mode: "Modus",
|
|
108
|
+
"Read-only": "Alleen-lezen",
|
|
109
|
+
View: "Weergave",
|
|
110
|
+
double: "double",
|
|
111
|
+
integer: "integer",
|
|
112
|
+
"{mode} — open properties panel": "{mode} — eigenschappenpaneel openen"
|
|
113
|
+
},
|
|
114
|
+
"pt-br": {
|
|
115
|
+
"Being edited in": "Sendo editado em",
|
|
116
|
+
Design: "Design",
|
|
117
|
+
"Element actions": "Ações do elemento",
|
|
118
|
+
Implement: "Implementar",
|
|
119
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "Implementar precisa de uma plataforma de execução Camunda; este modelo não tem nenhuma. Atribua uma para habilitá-la.",
|
|
120
|
+
Mode: "Modo",
|
|
121
|
+
"Read-only": "Somente leitura",
|
|
122
|
+
View: "Visualizar",
|
|
123
|
+
double: "double",
|
|
124
|
+
integer: "integer",
|
|
125
|
+
"{mode} — open properties panel": "{mode} — abrir o painel de propriedades"
|
|
126
|
+
},
|
|
127
|
+
ru: {
|
|
128
|
+
"Being edited in": "Редактируется в",
|
|
129
|
+
Design: "Проектирование",
|
|
130
|
+
"Element actions": "Действия элемента",
|
|
131
|
+
Implement: "Реализация",
|
|
132
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "Для «Реализации» нужна платформа исполнения Camunda, но у этой модели её нет. Назначьте её, чтобы включить.",
|
|
133
|
+
Mode: "Режим",
|
|
134
|
+
"Read-only": "Только чтение",
|
|
135
|
+
View: "Просмотр",
|
|
136
|
+
double: "double",
|
|
137
|
+
integer: "integer",
|
|
138
|
+
"{mode} — open properties panel": "{mode} — открыть панель свойств"
|
|
139
|
+
},
|
|
140
|
+
"zh-Hans": {
|
|
141
|
+
"Being edited in": "正在编辑于",
|
|
142
|
+
Design: "设计",
|
|
143
|
+
"Element actions": "元素操作",
|
|
144
|
+
Implement: "实现",
|
|
145
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "“实现”需要 Camunda 执行平台,但此模型没有。请分配一个以启用。",
|
|
146
|
+
Mode: "模式",
|
|
147
|
+
"Read-only": "只读",
|
|
148
|
+
View: "查看",
|
|
149
|
+
double: "double",
|
|
150
|
+
integer: "integer",
|
|
151
|
+
"{mode} — open properties panel": "{mode} — 打开属性面板"
|
|
152
|
+
},
|
|
153
|
+
"zh-Hant": {
|
|
154
|
+
"Being edited in": "正在編輯於",
|
|
155
|
+
Design: "設計",
|
|
156
|
+
"Element actions": "元素操作",
|
|
157
|
+
Implement: "實作",
|
|
158
|
+
"Implement needs a Camunda execution platform — this model has none. Assign one to enable it.": "「實作」需要 Camunda 執行平台,但此模型沒有。請指派一個以啟用。",
|
|
159
|
+
Mode: "模式",
|
|
160
|
+
"Read-only": "唯讀",
|
|
161
|
+
View: "檢視",
|
|
162
|
+
double: "double",
|
|
163
|
+
integer: "integer",
|
|
164
|
+
"{mode} — open properties panel": "{mode} — 開啟屬性面板"
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region ../../libs/modeler-types/src/canvasResize.ts
|
|
169
|
+
function l(e, t, n = {}) {
|
|
170
|
+
let r = n.createObserver ?? u();
|
|
171
|
+
if (!r) return () => void 0;
|
|
172
|
+
let i = n.applyInitialViewport === void 0, a = r(() => {
|
|
173
|
+
e.resized(), i ||= n.applyInitialViewport();
|
|
174
|
+
});
|
|
175
|
+
return a.observe(t), () => a.disconnect();
|
|
176
|
+
}
|
|
177
|
+
function u() {
|
|
178
|
+
let e = globalThis.ResizeObserver;
|
|
179
|
+
return e ? (t) => new e(t) : void 0;
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region ../../libs/modeler-types/src/canvasFocusIndicator.ts
|
|
183
|
+
var d = "<svg class=\"canvas-focus-indicator__off\" viewBox=\"0 -960 960 960\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M367-367q-47-47-47-113t47-113q47-47 113-47t113 47q47 47 47 113t-47 113q-47 47-113 47t-113-47Zm169.5-56.5Q560-447 560-480t-23.5-56.5Q513-560 480-560t-56.5 23.5Q400-513 400-480t23.5 56.5Q447-400 480-400t56.5-23.5ZM480-480ZM200-120q-33 0-56.5-23.5T120-200v-160h80v160h160v80H200Zm400 0v-80h160v-160h80v160q0 33-23.5 56.5T760-120H600ZM120-600v-160q0-33 23.5-56.5T200-840h160v80H200v160h-80Zm640 0v-160H600v-80h160q33 0 56.5 23.5T840-760v160h-80Z\"/></svg>", f = "<svg class=\"canvas-focus-indicator__on\" viewBox=\"0 -960 960 960\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M200-120q-33 0-56.5-23.5T120-200v-160h80v160h160v80H200Zm400 0v-80h160v-160h80v160q0 33-23.5 56.5T760-120H600ZM120-600v-160q0-33 23.5-56.5T200-840h160v80H200v160h-80Zm640 0v-160H600v-80h160q33 0 56.5 23.5T840-760v160h-80ZM338.5-338.5Q280-397 280-480t58.5-141.5Q397-680 480-680t141.5 58.5Q680-563 680-480t-58.5 141.5Q563-280 480-280t-141.5-58.5Z\"/></svg>";
|
|
184
|
+
function p(e) {
|
|
185
|
+
let t = document.createElement("div");
|
|
186
|
+
t.className = "canvas-focus-indicator", t.setAttribute("aria-hidden", "true"), t.innerHTML = d + f;
|
|
187
|
+
let n = e.isFocused(), r = e.hasSelection(), i = () => {
|
|
188
|
+
t.classList.toggle("is-focused", n && !r);
|
|
189
|
+
};
|
|
190
|
+
return i(), e.onFocusChanged((e) => {
|
|
191
|
+
n = e, i();
|
|
192
|
+
}), e.onSelectionChanged((e) => {
|
|
193
|
+
r = e, i();
|
|
194
|
+
}), e.parent.append(t), () => t.remove();
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/typeof.js
|
|
198
|
+
function m(e) {
|
|
199
|
+
"@babel/helpers - typeof";
|
|
200
|
+
return m = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
201
|
+
return typeof e;
|
|
202
|
+
} : function(e) {
|
|
203
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
204
|
+
}, m(e);
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPrimitive.js
|
|
208
|
+
function h(e, t) {
|
|
209
|
+
if (m(e) != "object" || !e) return e;
|
|
210
|
+
var n = e[Symbol.toPrimitive];
|
|
211
|
+
if (n !== void 0) {
|
|
212
|
+
var r = n.call(e, t || "default");
|
|
213
|
+
if (m(r) != "object") return r;
|
|
214
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
215
|
+
}
|
|
216
|
+
return (t === "string" ? String : Number)(e);
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPropertyKey.js
|
|
220
|
+
function g(e) {
|
|
221
|
+
var t = h(e, "string");
|
|
222
|
+
return m(t) == "symbol" ? t : t + "";
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/defineProperty.js
|
|
226
|
+
function _(e, t, n) {
|
|
227
|
+
return (t = g(t)) in e ? Object.defineProperty(e, t, {
|
|
228
|
+
value: n,
|
|
229
|
+
enumerable: !0,
|
|
230
|
+
configurable: !0,
|
|
231
|
+
writable: !0
|
|
232
|
+
}) : e[t] = n, e;
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/theme.ts
|
|
236
|
+
var v = "data-dmn-theme", y = class {
|
|
237
|
+
constructor(e) {
|
|
238
|
+
_(this, "scopeRoots", void 0), _(this, "mode", void 0), _(this, "mediaQuery", void 0), _(this, "mediaListener", void 0), this.scopeRoots = e;
|
|
239
|
+
}
|
|
240
|
+
setMode(e) {
|
|
241
|
+
e !== this.mode && (this.mode = e, e === "automatic" ? this.startFollowingPreferredScheme() : (this.stopFollowingPreferredScheme(), this.apply(e)));
|
|
242
|
+
}
|
|
243
|
+
dispose() {
|
|
244
|
+
this.stopFollowingPreferredScheme();
|
|
245
|
+
for (let e of this.scopeRoots) e.removeAttribute(v);
|
|
246
|
+
}
|
|
247
|
+
apply(e) {
|
|
248
|
+
for (let t of this.scopeRoots) t.setAttribute(v, e);
|
|
249
|
+
b(e);
|
|
250
|
+
}
|
|
251
|
+
startFollowingPreferredScheme() {
|
|
252
|
+
let e = window.matchMedia("(prefers-color-scheme: dark)");
|
|
253
|
+
this.apply(e.matches ? "dark" : "light"), !this.mediaListener && (this.mediaQuery = e, this.mediaListener = (e) => {
|
|
254
|
+
this.mode === "automatic" && this.apply(e.matches ? "dark" : "light");
|
|
255
|
+
}, this.mediaQuery.addEventListener("change", this.mediaListener));
|
|
256
|
+
}
|
|
257
|
+
stopFollowingPreferredScheme() {
|
|
258
|
+
this.mediaQuery && this.mediaListener && this.mediaQuery.removeEventListener("change", this.mediaListener), this.mediaQuery = void 0, this.mediaListener = void 0;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
function b(e) {
|
|
262
|
+
let t = document.querySelector("#theme-link");
|
|
263
|
+
if (!t) return;
|
|
264
|
+
let n = t.href, r = n.split("/").pop();
|
|
265
|
+
e === "dark" && r === "lightTheme.css" ? t.href = n.replace(/lightTheme\.css$/, "darkTheme.css") : e === "light" && r === "darkTheme.css" && (t.href = n.replace(/darkTheme\.css$/, "lightTheme.css"));
|
|
266
|
+
}
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region src/modeler.ts
|
|
269
|
+
var x = {
|
|
270
|
+
options: [
|
|
271
|
+
{
|
|
272
|
+
value: "feel",
|
|
273
|
+
label: "FEEL"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
value: "juel",
|
|
277
|
+
label: "JUEL"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
value: "javascript",
|
|
281
|
+
label: "JavaScript"
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
value: "groovy",
|
|
285
|
+
label: "Groovy"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
value: "python",
|
|
289
|
+
label: "Python"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
value: "jruby",
|
|
293
|
+
label: "JRuby"
|
|
294
|
+
}
|
|
295
|
+
],
|
|
296
|
+
defaults: { editor: "feel" }
|
|
297
|
+
}, S = [
|
|
298
|
+
"string",
|
|
299
|
+
"boolean",
|
|
300
|
+
"integer",
|
|
301
|
+
"long",
|
|
302
|
+
"double",
|
|
303
|
+
"date"
|
|
304
|
+
], C = class {
|
|
305
|
+
constructor(t, c) {
|
|
306
|
+
_(this, "container", void 0), _(this, "options", void 0), _(this, "modeler", void 0), _(this, "stopObservingSize", void 0), _(this, "activeEventBus", void 0), _(this, "disposeFocusIndicator", void 0), _(this, "destroyed", !1), _(this, "themeController", void 0), _(this, "handleViewsChanged", (e) => {
|
|
307
|
+
this.destroyed || (this.bindActiveViewer(), this.options.onViewChanged?.(e));
|
|
308
|
+
}), _(this, "handleContentChanged", () => {
|
|
309
|
+
this.destroyed || this.options.onContentChanged?.();
|
|
310
|
+
}), this.container = t, this.options = c;
|
|
311
|
+
let u = c.additionalModules ?? {};
|
|
312
|
+
this.modeler = new n({
|
|
313
|
+
container: t,
|
|
314
|
+
drd: {
|
|
315
|
+
propertiesPanel: {
|
|
316
|
+
...c.propertiesPanel,
|
|
317
|
+
feelPopupContainer: t
|
|
318
|
+
},
|
|
319
|
+
additionalModules: [
|
|
320
|
+
e,
|
|
321
|
+
i,
|
|
322
|
+
a,
|
|
323
|
+
r,
|
|
324
|
+
o.decisionRequirementsDiagram,
|
|
325
|
+
...u.drd ?? []
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
decisionTable: { additionalModules: [
|
|
329
|
+
e,
|
|
330
|
+
o.decisionTable,
|
|
331
|
+
...u.decisionTable ?? []
|
|
332
|
+
] },
|
|
333
|
+
literalExpression: { additionalModules: [e, ...u.literalExpression ?? []] },
|
|
334
|
+
boxedExpression: { additionalModules: [e, ...u.boxedExpression ?? []] },
|
|
335
|
+
common: {
|
|
336
|
+
expressionLanguages: c.expressionLanguages ?? x,
|
|
337
|
+
dataTypes: c.dataTypes ?? S,
|
|
338
|
+
keyboard: c.keyboard
|
|
339
|
+
},
|
|
340
|
+
moddleExtensions: {
|
|
341
|
+
camunda: s,
|
|
342
|
+
...c.moddleExtensions
|
|
343
|
+
}
|
|
344
|
+
}), this.modeler.on("views.changed", this.handleViewsChanged), this.stopObservingSize = l({ resized: () => {
|
|
345
|
+
this.destroyed || this.getActiveCanvas()?.resized();
|
|
346
|
+
} }, t);
|
|
347
|
+
}
|
|
348
|
+
async loadDiagram(e) {
|
|
349
|
+
this.assertLive();
|
|
350
|
+
try {
|
|
351
|
+
let t = await this.modeler.importXML(e);
|
|
352
|
+
return this.bindActiveViewer(), this.reportWarnings(t.warnings), t;
|
|
353
|
+
} catch (e) {
|
|
354
|
+
throw w("Unable to import DMN", e);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
async exportDiagram() {
|
|
358
|
+
this.assertLive();
|
|
359
|
+
let e = await this.modeler.saveXML({ format: !0 });
|
|
360
|
+
if (e.xml) return e.xml;
|
|
361
|
+
throw Error("Failed to save changes made to the diagram!");
|
|
362
|
+
}
|
|
363
|
+
getActiveView() {
|
|
364
|
+
return this.assertLive(), this.modeler.getActiveView();
|
|
365
|
+
}
|
|
366
|
+
getViews() {
|
|
367
|
+
return this.assertLive(), this.modeler.getViews();
|
|
368
|
+
}
|
|
369
|
+
async openView(e) {
|
|
370
|
+
this.assertLive();
|
|
371
|
+
try {
|
|
372
|
+
let t = await this.modeler.open(e);
|
|
373
|
+
return this.bindActiveViewer(), this.reportWarnings(t.warnings), t;
|
|
374
|
+
} catch (t) {
|
|
375
|
+
throw w(`Unable to open DMN view <${e.id}>`, t);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
isDrdViewActive() {
|
|
379
|
+
return this.assertLive(), this.modeler.getActiveView()?.type === "drd";
|
|
380
|
+
}
|
|
381
|
+
focusCanvas() {
|
|
382
|
+
this.assertLive(), this.getActiveFocusableCanvas()?.focus();
|
|
383
|
+
}
|
|
384
|
+
isCanvasFocused() {
|
|
385
|
+
return this.assertLive(), this.getActiveFocusableCanvas()?.isFocused() ?? !1;
|
|
386
|
+
}
|
|
387
|
+
async setLocale(e) {
|
|
388
|
+
this.assertLive();
|
|
389
|
+
let n = t.getLocale();
|
|
390
|
+
if (t.setLanguage(e), t.getLocale() === n) return;
|
|
391
|
+
let r = this.modeler.getActiveView();
|
|
392
|
+
if (!r) return;
|
|
393
|
+
let i = this.isDrdViewActive() ? this.getActiveViewboxCanvas()?.viewbox() : void 0;
|
|
394
|
+
await this.openView(r), i && this.getActiveViewboxCanvas()?.viewbox(i);
|
|
395
|
+
}
|
|
396
|
+
setTheme(e) {
|
|
397
|
+
this.assertLive(), this.themeController ||= new y([this.container, this.options.propertiesPanel.parent]), this.themeController.setMode(e);
|
|
398
|
+
}
|
|
399
|
+
getService(e) {
|
|
400
|
+
this.assertLive();
|
|
401
|
+
let t = this.getActiveViewer();
|
|
402
|
+
if (!t) throw Error("No active DMN view is available");
|
|
403
|
+
return t.get(e);
|
|
404
|
+
}
|
|
405
|
+
destroy() {
|
|
406
|
+
this.destroyed || (this.destroyed = !0, this.disposeFocusIndicator?.(), this.themeController?.dispose(), this.modeler.off("views.changed", this.handleViewsChanged), this.unbindCommandStack(), this.stopObservingSize(), this.modeler.destroy());
|
|
407
|
+
}
|
|
408
|
+
bindActiveViewer() {
|
|
409
|
+
if (this.destroyed) return;
|
|
410
|
+
let e = this.getActiveViewer()?.get("eventBus");
|
|
411
|
+
e !== this.activeEventBus && (this.unbindCommandStack(), this.activeEventBus = e, this.activeEventBus?.on("commandStack.changed", this.handleContentChanged), this.syncCanvasFocusIndicator());
|
|
412
|
+
}
|
|
413
|
+
syncCanvasFocusIndicator() {
|
|
414
|
+
if (this.disposeFocusIndicator?.(), this.disposeFocusIndicator = void 0, this.modeler.getActiveView()?.type !== "drd") return;
|
|
415
|
+
let e = this.getActiveViewer(), t = e?.get("canvas", !1), n = e?.get("selection", !1), r = e?.get("eventBus", !1);
|
|
416
|
+
!t || !n || !r || (this.disposeFocusIndicator = p({
|
|
417
|
+
parent: t.getContainer(),
|
|
418
|
+
isFocused: () => t.isFocused(),
|
|
419
|
+
onFocusChanged: (e) => r.on("canvas.focus.changed", (t) => e(t.focused)),
|
|
420
|
+
hasSelection: () => n.get().length > 0,
|
|
421
|
+
onSelectionChanged: (e) => r.on("selection.changed", (t) => e(t.newSelection.length > 0))
|
|
422
|
+
}));
|
|
423
|
+
}
|
|
424
|
+
unbindCommandStack() {
|
|
425
|
+
this.activeEventBus?.off("commandStack.changed", this.handleContentChanged), this.activeEventBus = void 0;
|
|
426
|
+
}
|
|
427
|
+
reportWarnings(e) {
|
|
428
|
+
if (!this.destroyed) for (let t of e) this.options.onWarning?.(E(t));
|
|
429
|
+
}
|
|
430
|
+
getActiveViewer() {
|
|
431
|
+
return this.modeler.getActiveViewer();
|
|
432
|
+
}
|
|
433
|
+
getActiveCanvas() {
|
|
434
|
+
return this.getActiveViewer()?.get("canvas", !1);
|
|
435
|
+
}
|
|
436
|
+
getActiveViewboxCanvas() {
|
|
437
|
+
return this.getActiveViewer()?.get("canvas", !1);
|
|
438
|
+
}
|
|
439
|
+
getActiveFocusableCanvas() {
|
|
440
|
+
if (this.modeler.getActiveView()?.type === "drd") return this.getActiveViewer()?.get("canvas", !1);
|
|
441
|
+
}
|
|
442
|
+
assertLive() {
|
|
443
|
+
if (this.destroyed) throw Error("DMN modeler has been destroyed");
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
function w(e, t) {
|
|
447
|
+
let n = t instanceof Error ? t.message : String(t), r = T(t).map(E).filter(Boolean), i = r.length > 0 ? `\n${r.join("\n")}` : "";
|
|
448
|
+
return Error(`${e}: ${n}${i}`, { cause: t });
|
|
449
|
+
}
|
|
450
|
+
function T(e) {
|
|
451
|
+
if (typeof e != "object" || !e || !("warnings" in e)) return [];
|
|
452
|
+
let t = e.warnings;
|
|
453
|
+
return Array.isArray(t) ? t : [];
|
|
454
|
+
}
|
|
455
|
+
function E(e) {
|
|
456
|
+
return [
|
|
457
|
+
e.message,
|
|
458
|
+
e.error?.message,
|
|
459
|
+
e.error?.stack
|
|
460
|
+
].filter((e) => !!e).join("\n");
|
|
461
|
+
}
|
|
462
|
+
//#endregion
|
|
463
|
+
//#region src/createModeler.ts
|
|
464
|
+
async function D(e, n) {
|
|
465
|
+
t.extend(c);
|
|
466
|
+
let r = new C(e, n);
|
|
467
|
+
return r.setTheme(n.theme ?? "automatic"), n.locale && t.setLanguage(n.locale), r;
|
|
468
|
+
}
|
|
469
|
+
//#endregion
|
|
470
|
+
export { D as createModeler };
|