@bpmnkit/core 0.8.0 → 1.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/README.md +49 -3
- package/dist/bpmn/agentic.js +3 -1
- package/dist/bpmn/auto-layout.js +184 -15
- package/dist/bpmn/bpmn-builder.d.ts +1 -12
- package/dist/bpmn/bpmn-builder.js +71 -10
- package/dist/bpmn/bpmn-model.d.ts +78 -0
- package/dist/bpmn/bpmn-parser.js +199 -41
- package/dist/bpmn/bpmn-serializer.js +121 -72
- package/dist/bpmn/bpmnlint.d.ts +153 -0
- package/dist/bpmn/bpmnlint.js +364 -0
- package/dist/bpmn/camunda-compat-data.d.ts +165 -0
- package/dist/bpmn/camunda-compat-data.js +423 -0
- package/dist/bpmn/camunda-compat-feel.d.ts +68 -0
- package/dist/bpmn/camunda-compat-feel.js +338 -0
- package/dist/bpmn/camunda-compat.d.ts +120 -0
- package/dist/bpmn/camunda-compat.js +1677 -0
- package/dist/bpmn/camunda7/juel.d.ts +41 -0
- package/dist/bpmn/camunda7/juel.js +333 -0
- package/dist/bpmn/camunda7/migrate.d.ts +72 -0
- package/dist/bpmn/camunda7/migrate.js +1152 -0
- package/dist/bpmn/compact-stream.d.ts +64 -0
- package/dist/bpmn/compact-stream.js +167 -0
- package/dist/bpmn/full-operations.js +5 -2
- package/dist/bpmn/label-style.d.ts +51 -0
- package/dist/bpmn/label-style.js +116 -0
- package/dist/bpmn/lint.d.ts +23 -3
- package/dist/bpmn/lint.js +47 -10
- package/dist/bpmn/optimize/bpmnlint-rules.d.ts +31 -0
- package/dist/bpmn/optimize/bpmnlint-rules.js +916 -0
- package/dist/bpmn/optimize/deploy.d.ts +8 -2
- package/dist/bpmn/optimize/deploy.js +16 -3
- package/dist/bpmn/optimize/index.js +11 -2
- package/dist/bpmn/optimize/types.d.ts +14 -0
- package/dist/bpmn/optimize/variable-flow.js +4 -1
- package/dist/bpmn/process-types.d.ts +112 -0
- package/dist/bpmn/process-types.js +490 -0
- package/dist/bpmn/svg.js +51 -22
- package/dist/dmn/dmn-parser.js +4 -3
- package/dist/doc/docx.d.ts +20 -0
- package/dist/doc/docx.js +253 -0
- package/dist/doc/html.d.ts +21 -0
- package/dist/doc/html.js +303 -0
- package/dist/doc/index.d.ts +7 -0
- package/dist/doc/index.js +5 -0
- package/dist/doc/markdown.d.ts +11 -0
- package/dist/doc/markdown.js +160 -0
- package/dist/doc/model.d.ts +129 -0
- package/dist/doc/model.js +617 -0
- package/dist/doc/zip.d.ts +5 -0
- package/dist/doc/zip.js +75 -0
- package/dist/form/form-parser.js +29 -28
- package/dist/index.d.ts +18 -0
- package/dist/index.js +9 -0
- package/dist/layout/annotations.d.ts +4 -2
- package/dist/layout/annotations.js +31 -2
- package/dist/layout/collaboration/ordering.d.ts +8 -0
- package/dist/layout/collaboration/ordering.js +57 -18
- package/dist/layout/orthogonal.d.ts +32 -0
- package/dist/layout/orthogonal.js +367 -0
- package/dist/layout/repair.d.ts +31 -0
- package/dist/layout/repair.js +220 -0
- package/dist/layout/semantic/route.js +45 -3
- package/dist/node/bpmnlint.d.ts +109 -0
- package/dist/node/bpmnlint.js +198 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +1 -0
- package/dist/xml/xml-patch.d.ts +21 -0
- package/dist/xml/xml-patch.js +27 -1
- package/package.json +5 -2
package/dist/form/form-parser.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ParseError } from "../errors.js";
|
|
1
2
|
const KNOWN_COMPONENT_TYPES = new Set([
|
|
2
3
|
"text",
|
|
3
4
|
"textfield",
|
|
@@ -29,20 +30,20 @@ export function parseForm(json) {
|
|
|
29
30
|
raw = JSON.parse(json);
|
|
30
31
|
}
|
|
31
32
|
catch (e) {
|
|
32
|
-
throw new
|
|
33
|
+
throw new ParseError(`Failed to parse form JSON: ${e.message}`);
|
|
33
34
|
}
|
|
34
35
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
35
|
-
throw new
|
|
36
|
+
throw new ParseError("Form JSON must be an object");
|
|
36
37
|
}
|
|
37
38
|
const obj = raw;
|
|
38
39
|
if (typeof obj.id !== "string" || obj.id.length === 0) {
|
|
39
|
-
throw new
|
|
40
|
+
throw new ParseError("Form must have a non-empty 'id' string");
|
|
40
41
|
}
|
|
41
42
|
if (typeof obj.type !== "string") {
|
|
42
|
-
throw new
|
|
43
|
+
throw new ParseError("Form must have a 'type' string");
|
|
43
44
|
}
|
|
44
45
|
if (!Array.isArray(obj.components)) {
|
|
45
|
-
throw new
|
|
46
|
+
throw new ParseError("Form must have a 'components' array");
|
|
46
47
|
}
|
|
47
48
|
const definition = {
|
|
48
49
|
id: obj.id,
|
|
@@ -72,14 +73,14 @@ export function parseForm(json) {
|
|
|
72
73
|
}
|
|
73
74
|
function parseComponent(raw, path) {
|
|
74
75
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
75
|
-
throw new
|
|
76
|
+
throw new ParseError(`${path}: component must be an object`);
|
|
76
77
|
}
|
|
77
78
|
const obj = raw;
|
|
78
79
|
if (typeof obj.type !== "string") {
|
|
79
|
-
throw new
|
|
80
|
+
throw new ParseError(`${path}: component must have a 'type' string`);
|
|
80
81
|
}
|
|
81
82
|
if (typeof obj.id !== "string" || obj.id.length === 0) {
|
|
82
|
-
throw new
|
|
83
|
+
throw new ParseError(`${path}: component must have a non-empty 'id'`);
|
|
83
84
|
}
|
|
84
85
|
const layout = parseLayout(obj.layout, path);
|
|
85
86
|
if (!KNOWN_COMPONENT_TYPES.has(obj.type)) {
|
|
@@ -88,7 +89,7 @@ function parseComponent(raw, path) {
|
|
|
88
89
|
switch (obj.type) {
|
|
89
90
|
case "text": {
|
|
90
91
|
if (typeof obj.text !== "string") {
|
|
91
|
-
throw new
|
|
92
|
+
throw new ParseError(`${path}: text component must have a 'text' string`);
|
|
92
93
|
}
|
|
93
94
|
const c = { type: "text", id: obj.id, text: obj.text };
|
|
94
95
|
if (typeof obj.label === "string")
|
|
@@ -147,7 +148,7 @@ function parseLayout(raw, path) {
|
|
|
147
148
|
if (raw === undefined || raw === null)
|
|
148
149
|
return undefined;
|
|
149
150
|
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
150
|
-
throw new
|
|
151
|
+
throw new ParseError(`${path}.layout: must be an object`);
|
|
151
152
|
}
|
|
152
153
|
const obj = raw;
|
|
153
154
|
const layout = {};
|
|
@@ -165,7 +166,7 @@ function parseValidation(raw, path) {
|
|
|
165
166
|
if (raw === undefined || raw === null)
|
|
166
167
|
return undefined;
|
|
167
168
|
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
168
|
-
throw new
|
|
169
|
+
throw new ParseError(`${path}.validate: must be an object`);
|
|
169
170
|
}
|
|
170
171
|
const obj = raw;
|
|
171
172
|
const v = {};
|
|
@@ -179,11 +180,11 @@ function parseValidation(raw, path) {
|
|
|
179
180
|
}
|
|
180
181
|
function parseValues(raw, path) {
|
|
181
182
|
if (!Array.isArray(raw)) {
|
|
182
|
-
throw new
|
|
183
|
+
throw new ParseError(`${path}.values: must be an array`);
|
|
183
184
|
}
|
|
184
185
|
return raw.map((v, i) => {
|
|
185
186
|
if (typeof v !== "object" || v === null) {
|
|
186
|
-
throw new
|
|
187
|
+
throw new ParseError(`${path}.values[${i}]: must be an object`);
|
|
187
188
|
}
|
|
188
189
|
const vo = v;
|
|
189
190
|
return {
|
|
@@ -194,10 +195,10 @@ function parseValues(raw, path) {
|
|
|
194
195
|
}
|
|
195
196
|
function parseFieldComponent(obj, type, path, layout) {
|
|
196
197
|
if (typeof obj.label !== "string") {
|
|
197
|
-
throw new
|
|
198
|
+
throw new ParseError(`${path}: ${type} must have a 'label' string`);
|
|
198
199
|
}
|
|
199
200
|
if (typeof obj.key !== "string") {
|
|
200
|
-
throw new
|
|
201
|
+
throw new ParseError(`${path}: ${type} must have a 'key' string`);
|
|
201
202
|
}
|
|
202
203
|
const validate = parseValidation(obj.validate, path);
|
|
203
204
|
const base = {
|
|
@@ -214,10 +215,10 @@ function parseFieldComponent(obj, type, path, layout) {
|
|
|
214
215
|
}
|
|
215
216
|
function parseSelectComponent(obj, path, layout) {
|
|
216
217
|
if (typeof obj.label !== "string") {
|
|
217
|
-
throw new
|
|
218
|
+
throw new ParseError(`${path}: select must have a 'label' string`);
|
|
218
219
|
}
|
|
219
220
|
if (typeof obj.key !== "string") {
|
|
220
|
-
throw new
|
|
221
|
+
throw new ParseError(`${path}: select must have a 'key' string`);
|
|
221
222
|
}
|
|
222
223
|
const c = {
|
|
223
224
|
type: "select",
|
|
@@ -243,10 +244,10 @@ function parseSelectComponent(obj, path, layout) {
|
|
|
243
244
|
}
|
|
244
245
|
function parseValuesComponent(obj, type, path, layout) {
|
|
245
246
|
if (typeof obj.label !== "string") {
|
|
246
|
-
throw new
|
|
247
|
+
throw new ParseError(`${path}: ${type} must have a 'label' string`);
|
|
247
248
|
}
|
|
248
249
|
if (typeof obj.key !== "string") {
|
|
249
|
-
throw new
|
|
250
|
+
throw new ParseError(`${path}: ${type} must have a 'key' string`);
|
|
250
251
|
}
|
|
251
252
|
const values = Array.isArray(obj.values) ? parseValues(obj.values, path) : undefined;
|
|
252
253
|
if (type === "radio") {
|
|
@@ -288,10 +289,10 @@ function parseValuesComponent(obj, type, path, layout) {
|
|
|
288
289
|
}
|
|
289
290
|
function parseCheckboxComponent(obj, path, layout) {
|
|
290
291
|
if (typeof obj.label !== "string") {
|
|
291
|
-
throw new
|
|
292
|
+
throw new ParseError(`${path}: checkbox must have a 'label' string`);
|
|
292
293
|
}
|
|
293
294
|
if (typeof obj.key !== "string") {
|
|
294
|
-
throw new
|
|
295
|
+
throw new ParseError(`${path}: checkbox must have a 'key' string`);
|
|
295
296
|
}
|
|
296
297
|
const c = {
|
|
297
298
|
type: "checkbox",
|
|
@@ -310,10 +311,10 @@ function parseCheckboxComponent(obj, path, layout) {
|
|
|
310
311
|
}
|
|
311
312
|
function parseGroupComponent(obj, path, layout) {
|
|
312
313
|
if (typeof obj.label !== "string") {
|
|
313
|
-
throw new
|
|
314
|
+
throw new ParseError(`${path}: group must have a 'label' string`);
|
|
314
315
|
}
|
|
315
316
|
if (!Array.isArray(obj.components)) {
|
|
316
|
-
throw new
|
|
317
|
+
throw new ParseError(`${path}: group must have a 'components' array`);
|
|
317
318
|
}
|
|
318
319
|
const components = obj.components.map((c, i) => parseComponent(c, `${path}.components[${i}]`));
|
|
319
320
|
const c = {
|
|
@@ -330,9 +331,9 @@ function parseGroupComponent(obj, path, layout) {
|
|
|
330
331
|
}
|
|
331
332
|
function parseNumberComponent(obj, path, layout) {
|
|
332
333
|
if (typeof obj.label !== "string")
|
|
333
|
-
throw new
|
|
334
|
+
throw new ParseError(`${path}: number must have a 'label' string`);
|
|
334
335
|
if (typeof obj.key !== "string")
|
|
335
|
-
throw new
|
|
336
|
+
throw new ParseError(`${path}: number must have a 'key' string`);
|
|
336
337
|
const c = { type: "number", id: obj.id, label: obj.label, key: obj.key };
|
|
337
338
|
const validate = parseValidation(obj.validate, path);
|
|
338
339
|
if (validate)
|
|
@@ -357,7 +358,7 @@ function parseDatetimeComponent(obj, _path, layout) {
|
|
|
357
358
|
}
|
|
358
359
|
function parseButtonComponent(obj, path, layout) {
|
|
359
360
|
if (typeof obj.label !== "string")
|
|
360
|
-
throw new
|
|
361
|
+
throw new ParseError(`${path}: button must have a 'label' string`);
|
|
361
362
|
const c = { type: "button", id: obj.id, label: obj.label };
|
|
362
363
|
if (typeof obj.action === "string")
|
|
363
364
|
c.action = obj.action;
|
|
@@ -367,9 +368,9 @@ function parseButtonComponent(obj, path, layout) {
|
|
|
367
368
|
}
|
|
368
369
|
function parseTaglistComponent(obj, path, layout) {
|
|
369
370
|
if (typeof obj.label !== "string")
|
|
370
|
-
throw new
|
|
371
|
+
throw new ParseError(`${path}: taglist must have a 'label' string`);
|
|
371
372
|
if (typeof obj.key !== "string")
|
|
372
|
-
throw new
|
|
373
|
+
throw new ParseError(`${path}: taglist must have a 'key' string`);
|
|
373
374
|
const c = {
|
|
374
375
|
type: "taglist",
|
|
375
376
|
id: obj.id,
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,16 @@ export { Bpmn, SAMPLE_BPMN_XML } from "./bpmn/index.js";
|
|
|
6
6
|
export { applyAutoLayout } from "./bpmn/auto-layout.js";
|
|
7
7
|
export { diffSemantics, projectSemantics, semanticHash } from "./bpmn/semantic-hash.js";
|
|
8
8
|
export type { JsonValue, SemanticDiff, SemanticProjection } from "./bpmn/semantic-hash.js";
|
|
9
|
+
export { extractProcessContract, generateProcessTypes } from "./bpmn/process-types.js";
|
|
10
|
+
export type { CodeContract, ContractElementRef, ContractHeader, ContractVariable, JobContract, MessageContract, ProcessContract, ProcessTypesOptions, } from "./bpmn/process-types.js";
|
|
9
11
|
export { detectExecutionPlatform, lintCategories, lintDiagram } from "./bpmn/lint.js";
|
|
10
12
|
export type { DetectedPlatform, ExecutionPlatform, LintDiagnostic, LintOptions, LintReport, } from "./bpmn/lint.js";
|
|
13
|
+
export { BPMNLINT_RULE_MAP, applyBpmnlintConfig, bpmnlintRuleForFinding, normalizeBpmnlintRuleName, parseBpmnlintConfig, resolveBpmnlintConfig, } from "./bpmn/bpmnlint.js";
|
|
14
|
+
export type { ApplyBpmnlintOptions, BpmnlintApplication, BpmnlintConfig, BpmnlintMatch, BpmnlintRuleMapping, BpmnlintRuleSetting, BpmnlintRuleValue, BpmnlintSeverity, ResolvedBpmnlintConfig, UnsupportedBpmnlintRule, } from "./bpmn/bpmnlint.js";
|
|
15
|
+
export { analyzeCamundaCompat, applyCamundaCompatConfig, isCamundaCompatFinding, normalizeCamundaVersion, splitCamundaCompatConfig, } from "./bpmn/camunda-compat.js";
|
|
16
|
+
export type { CamundaCompatConfig } from "./bpmn/camunda-compat.js";
|
|
17
|
+
export { CAMUNDA_COMPAT_PLUGIN_VERSION, CAMUNDA_COMPAT_RULES, CAMUNDA_COMPAT_VERSIONS, } from "./bpmn/camunda-compat-data.js";
|
|
18
|
+
export type { CamundaCompatCoverage, CamundaCompatRule, CamundaCompatVersion, } from "./bpmn/camunda-compat-data.js";
|
|
11
19
|
export { diffDiagram } from "./bpmn/diagram-diff.js";
|
|
12
20
|
export { exportPreserving, exportPreservingResult, preserveBpmnFormatting, } from "./bpmn/preserving-writer.js";
|
|
13
21
|
export type { PreservingWriteResult } from "./bpmn/preserving-writer.js";
|
|
@@ -45,6 +53,8 @@ export { exportFormPreserving, preserveFormFormatting } from "./form/preserving-
|
|
|
45
53
|
export type { JsonKind, JsonMember, JsonNode, PreservedJson } from "./json/index.js";
|
|
46
54
|
export { readDiColor, writeDiColor, BIOC_NS, COLOR_NS } from "./bpmn/di-color.js";
|
|
47
55
|
export type { DiColor } from "./bpmn/di-color.js";
|
|
56
|
+
export { collectLabelStyles, labelFontCss, resolveLabelFont } from "./bpmn/label-style.js";
|
|
57
|
+
export type { BpmnLabelFont, LabelFontCss } from "./bpmn/label-style.js";
|
|
48
58
|
export { optimize } from "./bpmn/optimize/index.js";
|
|
49
59
|
export { renderStoryHtml } from "./bpmn/story.js";
|
|
50
60
|
export type { StoryRenderOptions } from "./bpmn/story.js";
|
|
@@ -57,6 +67,8 @@ export type { BenchmarkResult, BoundingBox, ElementComparison, ElementPosition,
|
|
|
57
67
|
export type { Bounds, LayoutEdge, LayoutNode, LayoutResult, Waypoint } from "./layout/index.js";
|
|
58
68
|
export { ELEMENT_SIZES, GRID_CELL_HEIGHT, GRID_CELL_WIDTH } from "./layout/index.js";
|
|
59
69
|
export { compactify, expand } from "./bpmn/compact.js";
|
|
70
|
+
export { createCompactStream } from "./bpmn/compact-stream.js";
|
|
71
|
+
export type { CompactStream, CompactStreamOptions } from "./bpmn/compact-stream.js";
|
|
60
72
|
export { ELEMENT_GROUP_ORDER, ELEMENT_TYPE_GROUPS, allElementTypes, elementTypesInGroup, } from "./bpmn/element-catalog.js";
|
|
61
73
|
export type { ElementTypeGroup } from "./bpmn/element-catalog.js";
|
|
62
74
|
export { createFlowElement, retypeElement } from "./bpmn/element-shape.js";
|
|
@@ -66,8 +78,14 @@ export { applyBpmnOperations, reconcileCompact, OperationError } from "./bpmn/fu
|
|
|
66
78
|
export type { ApplyBpmnOperationsOptions, ApplyBpmnOperationsResult, OperationProblem, } from "./bpmn/full-operations.js";
|
|
67
79
|
export { buildValidationDmn, findValidationStructure, getValidationInputNames, insertValidationStructure, removeValidationStructure, validationDecisionId, } from "./bpmn/input-validation.js";
|
|
68
80
|
export type { InputVariableDef, ValidationStructure, ValidationVariableType, } from "./bpmn/input-validation.js";
|
|
81
|
+
export { analyzeCamunda7, convertCamunda7 } from "./bpmn/camunda7/migrate.js";
|
|
82
|
+
export type { Camunda7Conversion, Camunda7ConvertOptions, Camunda7Finding, Camunda7Report, Camunda7Severity, } from "./bpmn/camunda7/migrate.js";
|
|
83
|
+
export { translateJuelToFeel } from "./bpmn/camunda7/juel.js";
|
|
84
|
+
export type { JuelToFeelOptions, JuelToFeelResult } from "./bpmn/camunda7/juel.js";
|
|
69
85
|
export { exportSvg } from "./bpmn/svg.js";
|
|
70
86
|
export type { SvgExportOptions } from "./bpmn/svg.js";
|
|
87
|
+
export { buildProcessDocumentation, documentationToDocx, documentationToHtml, documentationToMarkdown, renderDocumentationDocx, renderDocumentationHtml, renderDocumentationMarkdown, } from "./doc/index.js";
|
|
88
|
+
export type { DocumentationLink, DocumentationOptions, DocumentedDecision, DocumentedElement, DocumentedForm, DocumentedFormField, DocumentedLane, DocumentedMessageFlow, DocumentedProcess, DocumentedProperty, DocxDocumentationOptions, ProcessDocumentation, } from "./doc/index.js";
|
|
71
89
|
export type { CompactDiagram, CompactElement, CompactFlow, CompactProcess, } from "./bpmn/compact.js";
|
|
72
90
|
export { compilePlan, extractPlan, mergePlan, slugify, uniqueId, } from "./plan/index.js";
|
|
73
91
|
export type { CompilePlanOptions, ConnectorApplyResult, ConnectorResolver, ExtractResult, PlanAgentTool, PlanAiAgentStep, PlanBranch, PlanBusinessRuleTaskStep, PlanCallActivityStep, PlanConnectorRef, PlanConnectorStep, PlanEndStep, PlanErrorBoundary, PlanGatewayStep, PlanInputVariable, PlanProblem, PlanRawStep, PlanReceiveTaskStep, PlanScenario, PlanScriptTaskStep, PlanSendTaskStep, PlanServiceTaskStep, PlanStartStep, PlanStep, PlanSubProcessStep, PlanTimerBoundary, PlanUserTaskStep, PlanWaitStep, ProcessPlan, SynthResult, UnsupportedElement, } from "./plan/index.js";
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,11 @@ export { findElement, findElementInProcess, findProcess, findSequenceFlow, getAl
|
|
|
4
4
|
export { Bpmn, SAMPLE_BPMN_XML } from "./bpmn/index.js";
|
|
5
5
|
export { applyAutoLayout } from "./bpmn/auto-layout.js";
|
|
6
6
|
export { diffSemantics, projectSemantics, semanticHash } from "./bpmn/semantic-hash.js";
|
|
7
|
+
export { extractProcessContract, generateProcessTypes } from "./bpmn/process-types.js";
|
|
7
8
|
export { detectExecutionPlatform, lintCategories, lintDiagram } from "./bpmn/lint.js";
|
|
9
|
+
export { BPMNLINT_RULE_MAP, applyBpmnlintConfig, bpmnlintRuleForFinding, normalizeBpmnlintRuleName, parseBpmnlintConfig, resolveBpmnlintConfig, } from "./bpmn/bpmnlint.js";
|
|
10
|
+
export { analyzeCamundaCompat, applyCamundaCompatConfig, isCamundaCompatFinding, normalizeCamundaVersion, splitCamundaCompatConfig, } from "./bpmn/camunda-compat.js";
|
|
11
|
+
export { CAMUNDA_COMPAT_PLUGIN_VERSION, CAMUNDA_COMPAT_RULES, CAMUNDA_COMPAT_VERSIONS, } from "./bpmn/camunda-compat-data.js";
|
|
8
12
|
export { diffDiagram } from "./bpmn/diagram-diff.js";
|
|
9
13
|
export { exportPreserving, exportPreservingResult, preserveBpmnFormatting, } from "./bpmn/preserving-writer.js";
|
|
10
14
|
export { exportDmnPreserving, preserveDmnFormatting } from "./dmn/preserving-writer.js";
|
|
@@ -24,6 +28,7 @@ export { parseXml, parseXmlSpans, preserveFormatting, preserveFormattingVerified
|
|
|
24
28
|
export { parseJsonSpans, preserveJsonFormatting } from "./json/index.js";
|
|
25
29
|
export { exportFormPreserving, preserveFormFormatting } from "./form/preserving-writer.js";
|
|
26
30
|
export { readDiColor, writeDiColor, BIOC_NS, COLOR_NS } from "./bpmn/di-color.js";
|
|
31
|
+
export { collectLabelStyles, labelFontCss, resolveLabelFont } from "./bpmn/label-style.js";
|
|
27
32
|
export { optimize } from "./bpmn/optimize/index.js";
|
|
28
33
|
export { renderStoryHtml } from "./bpmn/story.js";
|
|
29
34
|
export { analyzeVariableFlow, extractFeelIdentifiers } from "./bpmn/optimize/variable-flow.js";
|
|
@@ -31,11 +36,15 @@ export { layoutProcess, layoutFlowNodes } from "./layout/index.js";
|
|
|
31
36
|
export { benchmarkLayout, compareLayouts, formatBenchmarkResult, generateAutoLayout, parseReferenceLayout, } from "./layout/index.js";
|
|
32
37
|
export { ELEMENT_SIZES, GRID_CELL_HEIGHT, GRID_CELL_WIDTH } from "./layout/index.js";
|
|
33
38
|
export { compactify, expand } from "./bpmn/compact.js";
|
|
39
|
+
export { createCompactStream } from "./bpmn/compact-stream.js";
|
|
34
40
|
export { ELEMENT_GROUP_ORDER, ELEMENT_TYPE_GROUPS, allElementTypes, elementTypesInGroup, } from "./bpmn/element-catalog.js";
|
|
35
41
|
export { createFlowElement, retypeElement } from "./bpmn/element-shape.js";
|
|
36
42
|
export { applyOperations } from "./bpmn/operations.js";
|
|
37
43
|
export { applyBpmnOperations, reconcileCompact, OperationError } from "./bpmn/full-operations.js";
|
|
38
44
|
export { buildValidationDmn, findValidationStructure, getValidationInputNames, insertValidationStructure, removeValidationStructure, validationDecisionId, } from "./bpmn/input-validation.js";
|
|
45
|
+
export { analyzeCamunda7, convertCamunda7 } from "./bpmn/camunda7/migrate.js";
|
|
46
|
+
export { translateJuelToFeel } from "./bpmn/camunda7/juel.js";
|
|
39
47
|
export { exportSvg } from "./bpmn/svg.js";
|
|
48
|
+
export { buildProcessDocumentation, documentationToDocx, documentationToHtml, documentationToMarkdown, renderDocumentationDocx, renderDocumentationHtml, renderDocumentationMarkdown, } from "./doc/index.js";
|
|
40
49
|
export { compilePlan, extractPlan, mergePlan, slugify, uniqueId, } from "./plan/index.js";
|
|
41
50
|
//# sourceMappingURL=index.js.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* shapes. Constants, formulas and control flow match the reference exactly.
|
|
6
6
|
*/
|
|
7
7
|
import type { BpmnProcess } from "../bpmn/bpmn-model.js";
|
|
8
|
-
import type { Bounds, LayoutNode, Waypoint } from "./types.js";
|
|
8
|
+
import type { Bounds, LayoutEdge, LayoutNode, Waypoint } from "./types.js";
|
|
9
9
|
/**
|
|
10
10
|
* Sizes and packs text annotations around their linked elements without
|
|
11
11
|
* overlapping each other or any other layout node (incl. node labels).
|
|
@@ -15,7 +15,9 @@ import type { Bounds, LayoutNode, Waypoint } from "./types.js";
|
|
|
15
15
|
* origin and pushed clear of everything else already placed, mirroring the
|
|
16
16
|
* pre-port fallback in auto-layout.ts's computeAnnotationLocalBounds.
|
|
17
17
|
*/
|
|
18
|
-
export declare function packAnnotations(process: BpmnProcess, layoutNodes: LayoutNode[]
|
|
18
|
+
export declare function packAnnotations(process: BpmnProcess, layoutNodes: LayoutNode[],
|
|
19
|
+
/** Routed connections: an annotation box must not sit on top of one. */
|
|
20
|
+
layoutEdges?: LayoutEdge[]): Map<string, Bounds>;
|
|
19
21
|
/**
|
|
20
22
|
* Edge-to-edge, clamped association waypoints between a linked element and
|
|
21
23
|
* its annotation. Port of `chooseWaypoints` (tmp/01-annotation-layouting.cjs:365-389).
|
|
@@ -10,6 +10,8 @@ const MIN_HEIGHT = 30;
|
|
|
10
10
|
const HORIZONTAL_SHIFTS = [0, 60, -60, 120, -120, 180, -180, 240, -240];
|
|
11
11
|
/** Cost added to a candidate whose association line would cross a shape. */
|
|
12
12
|
const BLOCKED_LINE_COST = 10_000;
|
|
13
|
+
/** Cost added per routed connection the association line would cut across. */
|
|
14
|
+
const CROSSED_ROUTE_COST = 200;
|
|
13
15
|
function computeHeight(text, width) {
|
|
14
16
|
if (!text || !text.trim())
|
|
15
17
|
return MIN_HEIGHT;
|
|
@@ -105,7 +107,9 @@ function overlapsPadded(a, others, padding) {
|
|
|
105
107
|
* origin and pushed clear of everything else already placed, mirroring the
|
|
106
108
|
* pre-port fallback in auto-layout.ts's computeAnnotationLocalBounds.
|
|
107
109
|
*/
|
|
108
|
-
export function packAnnotations(process, layoutNodes
|
|
110
|
+
export function packAnnotations(process, layoutNodes,
|
|
111
|
+
/** Routed connections: an annotation box must not sit on top of one. */
|
|
112
|
+
layoutEdges = []) {
|
|
109
113
|
const result = new Map();
|
|
110
114
|
if (process.textAnnotations.length === 0)
|
|
111
115
|
return result;
|
|
@@ -145,6 +149,23 @@ export function packAnnotations(process, layoutNodes) {
|
|
|
145
149
|
if (n.labelBounds)
|
|
146
150
|
obstacles.push(n.labelBounds);
|
|
147
151
|
}
|
|
152
|
+
// Each segment of a route as a hairline box; the box packer then keeps
|
|
153
|
+
// annotations off routes the same way it keeps them off shapes.
|
|
154
|
+
const routeObstacles = [];
|
|
155
|
+
for (const edge of layoutEdges) {
|
|
156
|
+
for (let i = 0; i + 1 < edge.waypoints.length; i++) {
|
|
157
|
+
const a = edge.waypoints[i];
|
|
158
|
+
const b = edge.waypoints[i + 1];
|
|
159
|
+
if (!a || !b)
|
|
160
|
+
continue;
|
|
161
|
+
routeObstacles.push({
|
|
162
|
+
x: Math.min(a.x, b.x),
|
|
163
|
+
y: Math.min(a.y, b.y),
|
|
164
|
+
width: Math.abs(a.x - b.x),
|
|
165
|
+
height: Math.abs(a.y - b.y),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
148
169
|
function packSide(side) {
|
|
149
170
|
const list = items
|
|
150
171
|
.filter((it) => it.side === side)
|
|
@@ -180,6 +201,11 @@ export function packAnnotations(process, layoutNodes) {
|
|
|
180
201
|
continue;
|
|
181
202
|
intervals.push({ top: sh.y - ELEMENT_GAP, bottom: sh.y + sh.height + ELEMENT_GAP });
|
|
182
203
|
}
|
|
204
|
+
for (const r of routeObstacles) {
|
|
205
|
+
if (ax2 + ANN_GAP <= r.x || r.x + r.width + ANN_GAP <= ax1)
|
|
206
|
+
continue;
|
|
207
|
+
intervals.push({ top: r.y - ANN_GAP, bottom: r.y + r.height + ANN_GAP });
|
|
208
|
+
}
|
|
183
209
|
let y = naturalY;
|
|
184
210
|
let changed = true;
|
|
185
211
|
while (changed) {
|
|
@@ -201,7 +227,10 @@ export function packAnnotations(process, layoutNodes) {
|
|
|
201
227
|
};
|
|
202
228
|
const { pElem, pAnn } = associationWaypoints(linked.bounds, candidate);
|
|
203
229
|
const crosses = obstacles.some((sh) => sh !== linked.bounds && segmentHitsBox(pElem, pAnn, sh));
|
|
204
|
-
const
|
|
230
|
+
const cuts = routeObstacles.filter((r) => segmentHitsBox(pElem, pAnn, r)).length;
|
|
231
|
+
const cost = Math.hypot(candidateX - naturalX, y - naturalY) +
|
|
232
|
+
(crosses ? BLOCKED_LINE_COST : 0) +
|
|
233
|
+
cuts * CROSSED_ROUTE_COST;
|
|
205
234
|
if (cost < best.cost)
|
|
206
235
|
best = { x: candidateX, y, cost };
|
|
207
236
|
}
|
|
@@ -12,6 +12,14 @@ export interface PoolLink {
|
|
|
12
12
|
from: number;
|
|
13
13
|
to: number;
|
|
14
14
|
weight: number;
|
|
15
|
+
/**
|
|
16
|
+
* Where the message leaves inside its pool, 0 at the top to 1 at the bottom.
|
|
17
|
+
* A message whose element sits on the far side of its pool has to cross the
|
|
18
|
+
* whole process to get out, so the order that lets it leave from the near
|
|
19
|
+
* side wins. Absent for pools with no content to cross.
|
|
20
|
+
*/
|
|
21
|
+
fromDepth?: number;
|
|
22
|
+
toDepth?: number;
|
|
15
23
|
}
|
|
16
24
|
/**
|
|
17
25
|
* Order pools by their message-flow relationships. Returns indices into the
|
|
@@ -9,25 +9,63 @@
|
|
|
9
9
|
*/
|
|
10
10
|
/** Above this many pools, permuting every order costs more than it is worth. */
|
|
11
11
|
const EXHAUSTIVE_LIMIT = 8;
|
|
12
|
+
/** A full pool of process to cross costs this fraction of one pool step. */
|
|
13
|
+
const DEPTH_WEIGHT = 0.5;
|
|
14
|
+
function pairCosts(links) {
|
|
15
|
+
const pairs = new Map();
|
|
16
|
+
for (const link of links) {
|
|
17
|
+
if (link.from === link.to)
|
|
18
|
+
continue;
|
|
19
|
+
const a = Math.min(link.from, link.to);
|
|
20
|
+
const b = Math.max(link.from, link.to);
|
|
21
|
+
const key = `${a}:${b}`;
|
|
22
|
+
let pair = pairs.get(key);
|
|
23
|
+
if (!pair) {
|
|
24
|
+
pair = { a, b, weight: 0, aAbove: 0, aBelow: 0 };
|
|
25
|
+
pairs.set(key, pair);
|
|
26
|
+
}
|
|
27
|
+
pair.weight += link.weight;
|
|
28
|
+
// Leaving downward crosses what lies below the element, upward what lies above.
|
|
29
|
+
for (const [pool, depth] of [
|
|
30
|
+
[link.from, link.fromDepth],
|
|
31
|
+
[link.to, link.toDepth],
|
|
32
|
+
]) {
|
|
33
|
+
if (depth === undefined)
|
|
34
|
+
continue;
|
|
35
|
+
const down = link.weight * DEPTH_WEIGHT * (1 - depth);
|
|
36
|
+
const up = link.weight * DEPTH_WEIGHT * depth;
|
|
37
|
+
if (pool === a) {
|
|
38
|
+
pair.aAbove += down;
|
|
39
|
+
pair.aBelow += up;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
pair.aAbove += up;
|
|
43
|
+
pair.aBelow += down;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return [...pairs.values()];
|
|
48
|
+
}
|
|
12
49
|
/**
|
|
13
|
-
* How far the messages travel in this order, weighted by how many there are
|
|
14
|
-
*
|
|
15
|
-
*
|
|
50
|
+
* How far the messages travel in this order, weighted by how many there are,
|
|
51
|
+
* plus how much of their own pools they cross to get out. The declaration-order
|
|
52
|
+
* term is a tie-break: with nothing to gain from moving, the pools stay where
|
|
53
|
+
* the author put them.
|
|
16
54
|
*/
|
|
17
|
-
function cost(order,
|
|
18
|
-
const position =
|
|
55
|
+
function cost(order, pairs) {
|
|
56
|
+
const position = [];
|
|
19
57
|
for (let i = 0; i < order.length; i++) {
|
|
20
58
|
const id = order[i];
|
|
21
59
|
if (id !== undefined)
|
|
22
|
-
position
|
|
60
|
+
position[id] = i;
|
|
23
61
|
}
|
|
24
62
|
let total = 0;
|
|
25
|
-
for (const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
63
|
+
for (const pair of pairs) {
|
|
64
|
+
const a = position[pair.a];
|
|
65
|
+
const b = position[pair.b];
|
|
66
|
+
if (a === undefined || b === undefined)
|
|
29
67
|
continue;
|
|
30
|
-
total +=
|
|
68
|
+
total += pair.weight * Math.abs(a - b) + (a < b ? pair.aAbove : pair.aBelow);
|
|
31
69
|
}
|
|
32
70
|
let drift = 0;
|
|
33
71
|
for (let i = 0; i < order.length; i++)
|
|
@@ -42,15 +80,16 @@ export function orderPools(count, links) {
|
|
|
42
80
|
const identity = Array.from({ length: count }, (_, i) => i);
|
|
43
81
|
if (count < 3 || links.length === 0)
|
|
44
82
|
return identity;
|
|
45
|
-
|
|
83
|
+
const pairs = pairCosts(links);
|
|
84
|
+
return count <= EXHAUSTIVE_LIMIT ? exhaustive(identity, pairs) : refine(identity, pairs);
|
|
46
85
|
}
|
|
47
86
|
/** Every order, best first-found wins — so declaration order survives a tie. */
|
|
48
|
-
function exhaustive(identity,
|
|
87
|
+
function exhaustive(identity, pairs) {
|
|
49
88
|
let best = identity;
|
|
50
|
-
let bestCost = cost(identity,
|
|
89
|
+
let bestCost = cost(identity, pairs);
|
|
51
90
|
const permute = (prefix, rest) => {
|
|
52
91
|
if (rest.length === 0) {
|
|
53
|
-
const candidate = cost(prefix,
|
|
92
|
+
const candidate = cost(prefix, pairs);
|
|
54
93
|
if (candidate < bestCost) {
|
|
55
94
|
best = [...prefix];
|
|
56
95
|
bestCost = candidate;
|
|
@@ -71,9 +110,9 @@ function exhaustive(identity, links) {
|
|
|
71
110
|
* Take each pool out and put it back wherever it fits best, repeating until a
|
|
72
111
|
* full sweep changes nothing.
|
|
73
112
|
*/
|
|
74
|
-
function refine(identity,
|
|
113
|
+
function refine(identity, pairs) {
|
|
75
114
|
let order = [...identity];
|
|
76
|
-
let current = cost(order,
|
|
115
|
+
let current = cost(order, pairs);
|
|
77
116
|
for (let sweep = 0; sweep < order.length; sweep++) {
|
|
78
117
|
let improved = false;
|
|
79
118
|
for (let from = 0; from < order.length; from++) {
|
|
@@ -85,7 +124,7 @@ function refine(identity, links) {
|
|
|
85
124
|
if (to === from)
|
|
86
125
|
continue;
|
|
87
126
|
const candidate = [...without.slice(0, to), pool, ...without.slice(to)];
|
|
88
|
-
const candidateCost = cost(candidate,
|
|
127
|
+
const candidateCost = cost(candidate, pairs);
|
|
89
128
|
if (candidateCost < current) {
|
|
90
129
|
order = candidate;
|
|
91
130
|
current = candidateCost;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Bounds, Waypoint } from "./types.js";
|
|
2
|
+
/** Which side of a shape a route leaves or enters by. */
|
|
3
|
+
export type Side = "top" | "right" | "bottom" | "left";
|
|
4
|
+
/** A point on a shape's border a route may use, with an optional preference cost. */
|
|
5
|
+
export interface Port {
|
|
6
|
+
point: Waypoint;
|
|
7
|
+
side: Side;
|
|
8
|
+
/** Added to every route through this port, so preferred sides win ties. */
|
|
9
|
+
cost?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface OrthogonalRequest {
|
|
12
|
+
from: Port[];
|
|
13
|
+
to: Port[];
|
|
14
|
+
/** Shapes the route must not pass through; the endpoints themselves excluded. */
|
|
15
|
+
obstacles: Bounds[];
|
|
16
|
+
/** How many already-routed segments the segment a→b would cut across. */
|
|
17
|
+
crossings?: (a: Waypoint, b: Waypoint) => number;
|
|
18
|
+
/** Clearance kept from obstacles where the route has room for it. */
|
|
19
|
+
margin?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Obstacle-aware orthogonal routing: a shortest path, with bends and crossings
|
|
23
|
+
* charged as extra length, over the sparse grid of lines that run just clear of
|
|
24
|
+
* every obstacle edge (an orthogonal visibility graph). Used where the cheap
|
|
25
|
+
* candidate routes all hit something, so its cost only lands on the hard cases.
|
|
26
|
+
*
|
|
27
|
+
* Returns `null` when no clear route exists at all.
|
|
28
|
+
*/
|
|
29
|
+
export declare function routeOrthogonal(request: OrthogonalRequest): Waypoint[] | null;
|
|
30
|
+
/** The four side-centre ports of a rectangle, each charged `cost[side]` when given. */
|
|
31
|
+
export declare function sidePorts(b: Bounds, cost?: Partial<Record<Side, number>>): Port[];
|
|
32
|
+
//# sourceMappingURL=orthogonal.d.ts.map
|