callman-core 1.28.0 → 1.29.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/ai-packs/scenario-nodes.md +451 -0
- package/dist/ai/index.d.ts +2 -1
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +1 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/outputSchemas.d.ts +3 -0
- package/dist/ai/outputSchemas.d.ts.map +1 -1
- package/dist/ai/outputSchemas.js +1 -0
- package/dist/ai/outputSchemas.js.map +1 -1
- package/dist/ai/parse/diagram.d.ts.map +1 -1
- package/dist/ai/parse/diagram.js +6 -3
- package/dist/ai/parse/diagram.js.map +1 -1
- package/dist/ai/prompts/diagram.d.ts +7 -3
- package/dist/ai/prompts/diagram.d.ts.map +1 -1
- package/dist/ai/prompts/diagram.js +44 -5
- package/dist/ai/prompts/diagram.js.map +1 -1
- package/dist/ai/prompts/scenario.d.ts.map +1 -1
- package/dist/ai/prompts/scenario.js +9 -8
- package/dist/ai/prompts/scenario.js.map +1 -1
- package/dist/ai/prompts/scenarioNodeReference.d.ts +16 -0
- package/dist/ai/prompts/scenarioNodeReference.d.ts.map +1 -0
- package/dist/ai/prompts/scenarioNodeReference.js +882 -0
- package/dist/ai/prompts/scenarioNodeReference.js.map +1 -0
- package/dist/ai/types.d.ts +6 -0
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/diagram/bpmn/derive.d.ts +74 -0
- package/dist/diagram/bpmn/derive.d.ts.map +1 -0
- package/dist/diagram/bpmn/derive.js +392 -0
- package/dist/diagram/bpmn/derive.js.map +1 -0
- package/dist/diagram/bpmn/index.d.ts +7 -0
- package/dist/diagram/bpmn/index.d.ts.map +1 -0
- package/dist/diagram/bpmn/index.js +12 -0
- package/dist/diagram/bpmn/index.js.map +1 -0
- package/dist/diagram/bpmn/patch.d.ts +14 -0
- package/dist/diagram/bpmn/patch.d.ts.map +1 -0
- package/dist/diagram/bpmn/patch.js +770 -0
- package/dist/diagram/bpmn/patch.js.map +1 -0
- package/dist/diagram/bpmn/place.d.ts +4 -0
- package/dist/diagram/bpmn/place.d.ts.map +1 -0
- package/dist/diagram/bpmn/place.js +65 -0
- package/dist/diagram/bpmn/place.js.map +1 -0
- package/dist/diagram/bpmn/serialize.d.ts +12 -0
- package/dist/diagram/bpmn/serialize.d.ts.map +1 -0
- package/dist/diagram/bpmn/serialize.js +292 -0
- package/dist/diagram/bpmn/serialize.js.map +1 -0
- package/dist/diagram/bpmn/types.d.ts +42 -0
- package/dist/diagram/bpmn/types.d.ts.map +1 -0
- package/dist/diagram/bpmn/types.js +84 -0
- package/dist/diagram/bpmn/types.js.map +1 -0
- package/dist/diagram/bpmn/xml.d.ts +60 -0
- package/dist/diagram/bpmn/xml.d.ts.map +1 -0
- package/dist/diagram/bpmn/xml.js +342 -0
- package/dist/diagram/bpmn/xml.js.map +1 -0
- package/dist/diagram/elkGraph.d.ts +1 -3
- package/dist/diagram/elkGraph.d.ts.map +1 -1
- package/dist/diagram/elkGraph.js +1 -0
- package/dist/diagram/elkGraph.js.map +1 -1
- package/dist/diagram/fixtures.d.ts +10 -0
- package/dist/diagram/fixtures.d.ts.map +1 -0
- package/dist/diagram/fixtures.js +113 -0
- package/dist/diagram/fixtures.js.map +1 -0
- package/dist/diagram/geometry.d.ts +27 -0
- package/dist/diagram/geometry.d.ts.map +1 -0
- package/dist/diagram/geometry.js +122 -0
- package/dist/diagram/geometry.js.map +1 -0
- package/dist/diagram/history.d.ts +36 -0
- package/dist/diagram/history.d.ts.map +1 -0
- package/dist/diagram/history.js +54 -0
- package/dist/diagram/history.js.map +1 -0
- package/dist/diagram/ids.d.ts +5 -0
- package/dist/diagram/ids.d.ts.map +1 -0
- package/dist/diagram/ids.js +52 -0
- package/dist/diagram/ids.js.map +1 -0
- package/dist/diagram/index.d.ts +14 -2
- package/dist/diagram/index.d.ts.map +1 -1
- package/dist/diagram/index.js +20 -8
- package/dist/diagram/index.js.map +1 -1
- package/dist/diagram/layout.d.ts +107 -0
- package/dist/diagram/layout.d.ts.map +1 -0
- package/dist/diagram/layout.js +356 -0
- package/dist/diagram/layout.js.map +1 -0
- package/dist/diagram/mermaid/derive.d.ts +55 -0
- package/dist/diagram/mermaid/derive.d.ts.map +1 -0
- package/dist/diagram/mermaid/derive.js +343 -0
- package/dist/diagram/mermaid/derive.js.map +1 -0
- package/dist/diagram/mermaid/index.d.ts +8 -0
- package/dist/diagram/mermaid/index.d.ts.map +1 -0
- package/dist/diagram/mermaid/index.js +24 -0
- package/dist/diagram/mermaid/index.js.map +1 -0
- package/dist/diagram/mermaid/parse.d.ts +96 -0
- package/dist/diagram/mermaid/parse.d.ts.map +1 -0
- package/dist/diagram/mermaid/parse.js +672 -0
- package/dist/diagram/mermaid/parse.js.map +1 -0
- package/dist/diagram/mermaid/patch.d.ts +16 -0
- package/dist/diagram/mermaid/patch.d.ts.map +1 -0
- package/dist/diagram/mermaid/patch.js +463 -0
- package/dist/diagram/mermaid/patch.js.map +1 -0
- package/dist/diagram/mermaid/serialize.d.ts +14 -0
- package/dist/diagram/mermaid/serialize.d.ts.map +1 -0
- package/dist/diagram/mermaid/serialize.js +125 -0
- package/dist/diagram/mermaid/serialize.js.map +1 -0
- package/dist/diagram/mermaid/shapes.d.ts +11 -0
- package/dist/diagram/mermaid/shapes.d.ts.map +1 -0
- package/dist/diagram/mermaid/shapes.js +320 -0
- package/dist/diagram/mermaid/shapes.js.map +1 -0
- package/dist/diagram/migrations.d.ts +1 -0
- package/dist/diagram/migrations.d.ts.map +1 -1
- package/dist/diagram/migrations.js +7 -2
- package/dist/diagram/migrations.js.map +1 -1
- package/dist/diagram/normalize.d.ts +9 -1
- package/dist/diagram/normalize.d.ts.map +1 -1
- package/dist/diagram/normalize.js +194 -0
- package/dist/diagram/normalize.js.map +1 -1
- package/dist/diagram/ops.d.ts +146 -0
- package/dist/diagram/ops.d.ts.map +1 -0
- package/dist/diagram/ops.js +823 -0
- package/dist/diagram/ops.js.map +1 -0
- package/dist/diagram/opsReference.d.ts +3 -0
- package/dist/diagram/opsReference.d.ts.map +1 -0
- package/dist/diagram/opsReference.js +51 -0
- package/dist/diagram/opsReference.js.map +1 -0
- package/dist/diagram/patchInput.d.ts +193 -0
- package/dist/diagram/patchInput.d.ts.map +1 -0
- package/dist/diagram/patchInput.js +621 -0
- package/dist/diagram/patchInput.js.map +1 -0
- package/dist/diagram/routing/batch.d.ts +45 -0
- package/dist/diagram/routing/batch.d.ts.map +1 -0
- package/dist/diagram/routing/batch.js +136 -0
- package/dist/diagram/routing/batch.js.map +1 -0
- package/dist/diagram/routing/curves.d.ts +7 -0
- package/dist/diagram/routing/curves.d.ts.map +1 -0
- package/dist/diagram/routing/curves.js +120 -0
- package/dist/diagram/routing/curves.js.map +1 -0
- package/dist/diagram/routing/grid.d.ts +15 -0
- package/dist/diagram/routing/grid.d.ts.map +1 -0
- package/dist/diagram/routing/grid.js +245 -0
- package/dist/diagram/routing/grid.js.map +1 -0
- package/dist/diagram/routing/index.d.ts +10 -0
- package/dist/diagram/routing/index.d.ts.map +1 -0
- package/dist/diagram/routing/index.js +10 -0
- package/dist/diagram/routing/index.js.map +1 -0
- package/dist/diagram/routing/legacy.d.ts +6 -0
- package/dist/diagram/routing/legacy.d.ts.map +1 -0
- package/dist/diagram/routing/legacy.js +27 -0
- package/dist/diagram/routing/legacy.js.map +1 -0
- package/dist/diagram/routing/nudge.d.ts +4 -0
- package/dist/diagram/routing/nudge.d.ts.map +1 -0
- package/dist/diagram/routing/nudge.js +96 -0
- package/dist/diagram/routing/nudge.js.map +1 -0
- package/dist/diagram/routing/orthogonal.d.ts +6 -0
- package/dist/diagram/routing/orthogonal.d.ts.map +1 -0
- package/dist/diagram/routing/orthogonal.js +56 -0
- package/dist/diagram/routing/orthogonal.js.map +1 -0
- package/dist/diagram/routing/path.d.ts +16 -0
- package/dist/diagram/routing/path.d.ts.map +1 -0
- package/dist/diagram/routing/path.js +128 -0
- package/dist/diagram/routing/path.js.map +1 -0
- package/dist/diagram/routing/sides.d.ts +22 -0
- package/dist/diagram/routing/sides.d.ts.map +1 -0
- package/dist/diagram/routing/sides.js +74 -0
- package/dist/diagram/routing/sides.js.map +1 -0
- package/dist/diagram/routing/types.d.ts +46 -0
- package/dist/diagram/routing/types.d.ts.map +1 -0
- package/dist/diagram/routing/types.js +11 -0
- package/dist/diagram/routing/types.js.map +1 -0
- package/dist/diagram/schema.d.ts +70 -37
- package/dist/diagram/schema.d.ts.map +1 -1
- package/dist/diagram/schema.js +62 -8
- package/dist/diagram/schema.js.map +1 -1
- package/dist/diagram/styleInput.d.ts +41 -0
- package/dist/diagram/styleInput.d.ts.map +1 -0
- package/dist/diagram/styleInput.js +105 -0
- package/dist/diagram/styleInput.js.map +1 -0
- package/dist/diagram/views.d.ts +9 -0
- package/dist/diagram/views.d.ts.map +1 -0
- package/dist/diagram/views.js +42 -0
- package/dist/diagram/views.js.map +1 -0
- package/dist/http-file/flatImport.d.ts +1 -0
- package/dist/http-file/flatImport.d.ts.map +1 -1
- package/dist/http-file/flatImport.js.map +1 -1
- package/dist/http-file/index.d.ts +1 -1
- package/dist/http-file/index.d.ts.map +1 -1
- package/dist/http-file/index.js +1 -1
- package/dist/http-file/index.js.map +1 -1
- package/dist/http-file/parseHttpFile.d.ts +1 -0
- package/dist/http-file/parseHttpFile.d.ts.map +1 -1
- package/dist/http-file/parseHttpFile.js +40 -8
- package/dist/http-file/parseHttpFile.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/request/requestBody.d.ts +55 -0
- package/dist/request/requestBody.d.ts.map +1 -0
- package/dist/request/requestBody.js +198 -0
- package/dist/request/requestBody.js.map +1 -0
- package/dist/runner/requestRunner.d.ts.map +1 -1
- package/dist/runner/requestRunner.js +127 -43
- package/dist/runner/requestRunner.js.map +1 -1
- package/dist/runner/runCollection.d.ts +1 -1
- package/dist/runner/runCollection.d.ts.map +1 -1
- package/dist/runner/runCollection.js +9 -2
- package/dist/runner/runCollection.js.map +1 -1
- package/dist/scenario-runner/adapters/helpers/request-helpers.d.ts +2 -1
- package/dist/scenario-runner/adapters/helpers/request-helpers.d.ts.map +1 -1
- package/dist/scenario-runner/adapters/helpers/request-helpers.js +8 -40
- package/dist/scenario-runner/adapters/helpers/request-helpers.js.map +1 -1
- package/dist/scenario-runner/adapters/request-executor.d.ts.map +1 -1
- package/dist/scenario-runner/adapters/request-executor.js +2 -29
- package/dist/scenario-runner/adapters/request-executor.js.map +1 -1
- package/dist/scenario-runner/index.d.ts +1 -0
- package/dist/scenario-runner/index.d.ts.map +1 -1
- package/dist/scenario-runner/index.js +1 -0
- package/dist/scenario-runner/index.js.map +1 -1
- package/dist/scenario-runner/labels.d.ts +3 -0
- package/dist/scenario-runner/labels.d.ts.map +1 -0
- package/dist/scenario-runner/labels.js +20 -0
- package/dist/scenario-runner/labels.js.map +1 -0
- package/dist/scenario-runner/runScenario.d.ts.map +1 -1
- package/dist/scenario-runner/runScenario.js +4 -11
- package/dist/scenario-runner/runScenario.js.map +1 -1
- package/dist/script/legacy.d.ts.map +1 -1
- package/dist/script/legacy.js +24 -9
- package/dist/script/legacy.js.map +1 -1
- package/dist/types/index.d.ts +18 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/variables/resolver.d.ts.map +1 -1
- package/dist/variables/resolver.js +27 -5
- package/dist/variables/resolver.js.map +1 -1
- package/dist-cjs/ai/index.js +4 -1
- package/dist-cjs/ai/index.js.map +1 -1
- package/dist-cjs/ai/outputSchemas.js +1 -0
- package/dist-cjs/ai/outputSchemas.js.map +1 -1
- package/dist-cjs/ai/parse/diagram.js +6 -3
- package/dist-cjs/ai/parse/diagram.js.map +1 -1
- package/dist-cjs/ai/prompts/diagram.js +44 -5
- package/dist-cjs/ai/prompts/diagram.js.map +1 -1
- package/dist-cjs/ai/prompts/scenario.js +9 -8
- package/dist-cjs/ai/prompts/scenario.js.map +1 -1
- package/dist-cjs/ai/prompts/scenarioNodeReference.js +886 -0
- package/dist-cjs/ai/prompts/scenarioNodeReference.js.map +1 -0
- package/dist-cjs/diagram/bpmn/derive.js +398 -0
- package/dist-cjs/diagram/bpmn/derive.js.map +1 -0
- package/dist-cjs/diagram/bpmn/index.js +31 -0
- package/dist-cjs/diagram/bpmn/index.js.map +1 -0
- package/dist-cjs/diagram/bpmn/patch.js +774 -0
- package/dist-cjs/diagram/bpmn/patch.js.map +1 -0
- package/dist-cjs/diagram/bpmn/place.js +69 -0
- package/dist-cjs/diagram/bpmn/place.js.map +1 -0
- package/dist-cjs/diagram/bpmn/serialize.js +299 -0
- package/dist-cjs/diagram/bpmn/serialize.js.map +1 -0
- package/dist-cjs/diagram/bpmn/types.js +99 -0
- package/dist-cjs/diagram/bpmn/types.js.map +1 -0
- package/dist-cjs/diagram/bpmn/xml.js +367 -0
- package/dist-cjs/diagram/bpmn/xml.js.map +1 -0
- package/dist-cjs/diagram/elkGraph.js +1 -0
- package/dist-cjs/diagram/elkGraph.js.map +1 -1
- package/dist-cjs/diagram/fixtures.js +117 -0
- package/dist-cjs/diagram/fixtures.js.map +1 -0
- package/dist-cjs/diagram/geometry.js +143 -0
- package/dist-cjs/diagram/geometry.js.map +1 -0
- package/dist-cjs/diagram/history.js +65 -0
- package/dist-cjs/diagram/history.js.map +1 -0
- package/dist-cjs/diagram/ids.js +58 -0
- package/dist-cjs/diagram/ids.js.map +1 -0
- package/dist-cjs/diagram/index.js +23 -8
- package/dist-cjs/diagram/index.js.map +1 -1
- package/dist-cjs/diagram/layout.js +364 -0
- package/dist-cjs/diagram/layout.js.map +1 -0
- package/dist-cjs/diagram/mermaid/derive.js +353 -0
- package/dist-cjs/diagram/mermaid/derive.js.map +1 -0
- package/dist-cjs/diagram/mermaid/index.js +44 -0
- package/dist-cjs/diagram/mermaid/index.js.map +1 -0
- package/dist-cjs/diagram/mermaid/parse.js +681 -0
- package/dist-cjs/diagram/mermaid/parse.js.map +1 -0
- package/dist-cjs/diagram/mermaid/patch.js +468 -0
- package/dist-cjs/diagram/mermaid/patch.js.map +1 -0
- package/dist-cjs/diagram/mermaid/serialize.js +133 -0
- package/dist-cjs/diagram/mermaid/serialize.js.map +1 -0
- package/dist-cjs/diagram/mermaid/shapes.js +327 -0
- package/dist-cjs/diagram/mermaid/shapes.js.map +1 -0
- package/dist-cjs/diagram/migrations.js +9 -3
- package/dist-cjs/diagram/migrations.js.map +1 -1
- package/dist-cjs/diagram/normalize.js +198 -1
- package/dist-cjs/diagram/normalize.js.map +1 -1
- package/dist-cjs/diagram/ops.js +829 -0
- package/dist-cjs/diagram/ops.js.map +1 -0
- package/dist-cjs/diagram/opsReference.js +55 -0
- package/dist-cjs/diagram/opsReference.js.map +1 -0
- package/dist-cjs/diagram/patchInput.js +636 -0
- package/dist-cjs/diagram/patchInput.js.map +1 -0
- package/dist-cjs/diagram/routing/batch.js +142 -0
- package/dist-cjs/diagram/routing/batch.js.map +1 -0
- package/dist-cjs/diagram/routing/curves.js +127 -0
- package/dist-cjs/diagram/routing/curves.js.map +1 -0
- package/dist-cjs/diagram/routing/grid.js +250 -0
- package/dist-cjs/diagram/routing/grid.js.map +1 -0
- package/dist-cjs/diagram/routing/index.js +29 -0
- package/dist-cjs/diagram/routing/index.js.map +1 -0
- package/dist-cjs/diagram/routing/legacy.js +32 -0
- package/dist-cjs/diagram/routing/legacy.js.map +1 -0
- package/dist-cjs/diagram/routing/nudge.js +100 -0
- package/dist-cjs/diagram/routing/nudge.js.map +1 -0
- package/dist-cjs/diagram/routing/orthogonal.js +62 -0
- package/dist-cjs/diagram/routing/orthogonal.js.map +1 -0
- package/dist-cjs/diagram/routing/path.js +137 -0
- package/dist-cjs/diagram/routing/path.js.map +1 -0
- package/dist-cjs/diagram/routing/sides.js +82 -0
- package/dist-cjs/diagram/routing/sides.js.map +1 -0
- package/dist-cjs/diagram/routing/types.js +15 -0
- package/dist-cjs/diagram/routing/types.js.map +1 -0
- package/dist-cjs/diagram/schema.js +64 -9
- package/dist-cjs/diagram/schema.js.map +1 -1
- package/dist-cjs/diagram/styleInput.js +113 -0
- package/dist-cjs/diagram/styleInput.js.map +1 -0
- package/dist-cjs/diagram/views.js +46 -0
- package/dist-cjs/diagram/views.js.map +1 -0
- package/dist-cjs/http-file/flatImport.js.map +1 -1
- package/dist-cjs/http-file/index.js +2 -1
- package/dist-cjs/http-file/index.js.map +1 -1
- package/dist-cjs/http-file/parseHttpFile.js +42 -9
- package/dist-cjs/http-file/parseHttpFile.js.map +1 -1
- package/dist-cjs/index.js +9 -1
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/request/requestBody.js +206 -0
- package/dist-cjs/request/requestBody.js.map +1 -0
- package/dist-cjs/runner/requestRunner.js +127 -43
- package/dist-cjs/runner/requestRunner.js.map +1 -1
- package/dist-cjs/runner/runCollection.js +9 -2
- package/dist-cjs/runner/runCollection.js.map +1 -1
- package/dist-cjs/scenario-runner/adapters/helpers/request-helpers.js +7 -42
- package/dist-cjs/scenario-runner/adapters/helpers/request-helpers.js.map +1 -1
- package/dist-cjs/scenario-runner/adapters/request-executor.js +3 -30
- package/dist-cjs/scenario-runner/adapters/request-executor.js.map +1 -1
- package/dist-cjs/scenario-runner/index.js +4 -1
- package/dist-cjs/scenario-runner/index.js.map +1 -1
- package/dist-cjs/scenario-runner/labels.js +24 -0
- package/dist-cjs/scenario-runner/labels.js.map +1 -0
- package/dist-cjs/scenario-runner/runScenario.js +4 -11
- package/dist-cjs/scenario-runner/runScenario.js.map +1 -1
- package/dist-cjs/script/legacy.js +24 -9
- package/dist-cjs/script/legacy.js.map +1 -1
- package/dist-cjs/variables/resolver.js +27 -5
- package/dist-cjs/variables/resolver.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.patchBpmnSource = void 0;
|
|
4
|
+
// Apply diagram OPS to BPMN 2.0 XML as minimal text edits. The AI and MCP
|
|
5
|
+
// emit model ops; for a BPMN diagram the same ops land here, on the element
|
|
6
|
+
// they concern, and every other byte (extension elements, annotations, the
|
|
7
|
+
// modeler's formatting) stays exactly as it was.
|
|
8
|
+
//
|
|
9
|
+
// Mapping (structure + geometry — BPMN keeps positions in its DI):
|
|
10
|
+
// addNode → a flow node inside its process / subprocess (+ lane
|
|
11
|
+
// membership), a participant (+ collaboration) or a lane,
|
|
12
|
+
// and its BPMNShape
|
|
13
|
+
// updateNode → name, element kind (tag rename), event definition,
|
|
14
|
+
// boundary attachment, expanded state, bioc colors
|
|
15
|
+
// removeNode → the element, its shape, every flow touching it, boundary
|
|
16
|
+
// events attached to it, lane refs and default-flow attrs
|
|
17
|
+
// addEdge → a sequenceFlow (or messageFlow across pools) with
|
|
18
|
+
// incoming/outgoing refs, condition, default, and its BPMNEdge
|
|
19
|
+
// updateEdge → name, ends, condition, default, waypoints, color
|
|
20
|
+
// removeEdge → the flow, its BPMNEdge, refs and default attrs
|
|
21
|
+
// moveNodes / resizeNode → BPMNShape bounds (+ waypoints of touched flows)
|
|
22
|
+
// reparent → lane refs, and the element moved between containers
|
|
23
|
+
// setTitle → the main process name
|
|
24
|
+
// Ops are applied one at a time against a fresh parse, so an op can refer to
|
|
25
|
+
// what the previous one inserted. Everything else is reported in `unmapped`.
|
|
26
|
+
const geometry_js_1 = require("../geometry.js");
|
|
27
|
+
const derive_js_1 = require("./derive.js");
|
|
28
|
+
const serialize_js_1 = require("./serialize.js");
|
|
29
|
+
const types_js_1 = require("./types.js");
|
|
30
|
+
const xml_js_1 = require("./xml.js");
|
|
31
|
+
const round = (value) => Math.round(value * 100) / 100;
|
|
32
|
+
const tag = (env, local) => (0, xml_js_1.qualify)(env.bp, local);
|
|
33
|
+
const ensureNamespace = (env, prefix, uri) => {
|
|
34
|
+
if ((0, xml_js_1.prefixForNamespace)(env.root, uri) !== null)
|
|
35
|
+
return;
|
|
36
|
+
const edit = (0, xml_js_1.setAttributeEdit)(env.root, `xmlns:${prefix}`, uri, env.text);
|
|
37
|
+
if (edit)
|
|
38
|
+
env.edits.push(edit);
|
|
39
|
+
};
|
|
40
|
+
const elementOf = (env, id) => env.parsed.elements.get(id);
|
|
41
|
+
const isProcessLike = (element) => element.local === "process" || element.local === "subProcess";
|
|
42
|
+
const ancestorProcess = (element) => {
|
|
43
|
+
let current = element.parent;
|
|
44
|
+
while (current && current.local !== "process")
|
|
45
|
+
current = current.parent;
|
|
46
|
+
return current;
|
|
47
|
+
};
|
|
48
|
+
const nearestContainerElement = (element) => {
|
|
49
|
+
let current = element.parent;
|
|
50
|
+
while (current && !isProcessLike(current))
|
|
51
|
+
current = current.parent;
|
|
52
|
+
return current;
|
|
53
|
+
};
|
|
54
|
+
const mainProcess = (env) => {
|
|
55
|
+
const referenced = new Set();
|
|
56
|
+
if (env.parsed.collaboration) {
|
|
57
|
+
for (const child of (0, xml_js_1.childElements)(env.parsed.collaboration)) {
|
|
58
|
+
const ref = (0, xml_js_1.attr)(child, "processRef");
|
|
59
|
+
if (child.local === "participant" && ref)
|
|
60
|
+
referenced.add(ref);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return env.parsed.processes.find((process) => !referenced.has((0, xml_js_1.attr)(process, "id") ?? "")) ?? env.parsed.processes[0] ?? null;
|
|
64
|
+
};
|
|
65
|
+
const processForPool = (env, poolId) => {
|
|
66
|
+
const participant = elementOf(env, poolId);
|
|
67
|
+
const ref = participant ? (0, xml_js_1.attr)(participant, "processRef") : undefined;
|
|
68
|
+
return ref ? (elementOf(env, ref) ?? null) : null;
|
|
69
|
+
};
|
|
70
|
+
// The XML element new flow nodes of `node` go into.
|
|
71
|
+
const containerFor = (env, node) => {
|
|
72
|
+
const parent = node.parentId ? env.afterById.get(node.parentId) : undefined;
|
|
73
|
+
if (!parent)
|
|
74
|
+
return mainProcess(env);
|
|
75
|
+
if (parent.type === "bpmn.pool")
|
|
76
|
+
return processForPool(env, parent.id);
|
|
77
|
+
if (parent.type === "bpmn.lane") {
|
|
78
|
+
const lane = elementOf(env, parent.id);
|
|
79
|
+
return lane ? ancestorProcess(lane) : null;
|
|
80
|
+
}
|
|
81
|
+
if (parent.type === "bpmn.subprocess")
|
|
82
|
+
return elementOf(env, parent.id) ?? null;
|
|
83
|
+
return containerFor(env, parent);
|
|
84
|
+
};
|
|
85
|
+
const laneFor = (env, node) => {
|
|
86
|
+
const parent = node.parentId ? env.afterById.get(node.parentId) : undefined;
|
|
87
|
+
return parent?.type === "bpmn.lane" ? elementOf(env, parent.id) : undefined;
|
|
88
|
+
};
|
|
89
|
+
const freshId = (env, base) => {
|
|
90
|
+
let candidate = (0, types_js_1.ncName)(base);
|
|
91
|
+
while (env.parsed.elements.has(candidate))
|
|
92
|
+
candidate = `${candidate}_1`;
|
|
93
|
+
return candidate;
|
|
94
|
+
};
|
|
95
|
+
const rectOf = (env, id) => {
|
|
96
|
+
const rect = env.afterRects.get(id);
|
|
97
|
+
if (rect)
|
|
98
|
+
return rect;
|
|
99
|
+
const node = env.afterById.get(id);
|
|
100
|
+
return { x: 0, y: 0, width: node?.size.width ?? 100, height: node?.size.height ?? 80 };
|
|
101
|
+
};
|
|
102
|
+
const shapeXml = (env, id, rect, extra, indent) => {
|
|
103
|
+
const attrsText = extra.filter((entry) => entry[1] !== undefined).map(([name, value]) => ` ${name}="${(0, xml_js_1.escapeXml)(value)}"`).join("");
|
|
104
|
+
return [
|
|
105
|
+
`<${(0, xml_js_1.qualify)(env.di, "BPMNShape")} id="${freshId(env, `${id}_di`)}" bpmnElement="${(0, xml_js_1.escapeXml)(id)}"${attrsText}>`,
|
|
106
|
+
`${indent}${env.unit}<${(0, xml_js_1.qualify)(env.dc, "Bounds")} x="${round(rect.x)}" y="${round(rect.y)}" width="${round(rect.width)}" height="${round(rect.height)}" />`,
|
|
107
|
+
`${indent}</${(0, xml_js_1.qualify)(env.di, "BPMNShape")}>`,
|
|
108
|
+
].join("\n");
|
|
109
|
+
};
|
|
110
|
+
const edgeXml = (env, id, waypoints, indent) => [
|
|
111
|
+
`<${(0, xml_js_1.qualify)(env.di, "BPMNEdge")} id="${freshId(env, `${id}_di`)}" bpmnElement="${(0, xml_js_1.escapeXml)(id)}">`,
|
|
112
|
+
...waypoints.map((point) => `${indent}${env.unit}<${(0, xml_js_1.qualify)(env.dd, "waypoint")} x="${round(point.x)}" y="${round(point.y)}" />`),
|
|
113
|
+
`${indent}</${(0, xml_js_1.qualify)(env.di, "BPMNEdge")}>`,
|
|
114
|
+
].join("\n");
|
|
115
|
+
const waypointsFor = (env, edge) => {
|
|
116
|
+
if (edge.waypoints && edge.waypoints.length >= 2)
|
|
117
|
+
return edge.waypoints;
|
|
118
|
+
return (0, serialize_js_1.defaultBpmnWaypoints)(rectOf(env, edge.source), rectOf(env, edge.target));
|
|
119
|
+
};
|
|
120
|
+
const appendToPlane = (env, xml) => {
|
|
121
|
+
const plane = env.parsed.plane;
|
|
122
|
+
if (!plane) {
|
|
123
|
+
env.warnings.push("The BPMN document has no BPMNPlane; the shape was not drawn.");
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const indent = (0, xml_js_1.childIndentOf)(plane, env.text, env.unit);
|
|
127
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(plane, xml(indent), env.text, env.unit));
|
|
128
|
+
return true;
|
|
129
|
+
};
|
|
130
|
+
// Rewrite a DI edge's waypoints.
|
|
131
|
+
const setWaypoints = (env, edgeId, waypoints) => {
|
|
132
|
+
const di = env.parsed.diEdges.get(edgeId);
|
|
133
|
+
if (!di)
|
|
134
|
+
return;
|
|
135
|
+
const indent = (0, xml_js_1.indentOf)(env.text, di.element.span.start);
|
|
136
|
+
const open = env.text.slice(di.element.span.start, di.element.openEnd).replace(/\/>$/, ">");
|
|
137
|
+
const body = waypoints.map((point) => `${indent}${env.unit}<${(0, xml_js_1.qualify)(env.dd, "waypoint")} x="${round(point.x)}" y="${round(point.y)}" />`).join("\n");
|
|
138
|
+
// Keep a BPMNLabel child when there is one.
|
|
139
|
+
const label = (0, xml_js_1.childElements)(di.element).find((child) => child.local === "BPMNLabel");
|
|
140
|
+
const labelText = label ? `\n${indent}${env.unit}${env.text.slice(label.span.start, label.span.end)}` : "";
|
|
141
|
+
env.edits.push({ span: di.element.span, replacement: `${open}\n${body}${labelText}\n${indent}</${di.element.name}>` });
|
|
142
|
+
};
|
|
143
|
+
const setBounds = (env, id, rect) => {
|
|
144
|
+
const shape = env.parsed.shapes.get(id);
|
|
145
|
+
if (!shape)
|
|
146
|
+
return;
|
|
147
|
+
const bounds = (0, xml_js_1.childElements)(shape.element).find((child) => child.local === "Bounds");
|
|
148
|
+
if (!bounds)
|
|
149
|
+
return;
|
|
150
|
+
for (const [name, value] of [
|
|
151
|
+
["x", rect.x],
|
|
152
|
+
["y", rect.y],
|
|
153
|
+
["width", rect.width],
|
|
154
|
+
["height", rect.height],
|
|
155
|
+
]) {
|
|
156
|
+
const edit = (0, xml_js_1.setAttributeEdit)(bounds, name, String(round(value)), env.text);
|
|
157
|
+
if (edit)
|
|
158
|
+
env.edits.push(edit);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const refreshIncidentEdges = (env, nodeIds) => {
|
|
162
|
+
for (const edge of env.afterById.size ? env.parsed.structure.edges : []) {
|
|
163
|
+
if (!nodeIds.has(edge.source) && !nodeIds.has(edge.target))
|
|
164
|
+
continue;
|
|
165
|
+
const model = ctxEdge(env, edge.id);
|
|
166
|
+
if (!model)
|
|
167
|
+
continue;
|
|
168
|
+
setWaypoints(env, edge.id, waypointsFor(env, model));
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
let afterEdgesRef = new Map();
|
|
172
|
+
const ctxEdge = (_env, id) => afterEdgesRef.get(id);
|
|
173
|
+
const removeElement = (env, element) => {
|
|
174
|
+
if (env.removed.has(element))
|
|
175
|
+
return;
|
|
176
|
+
env.removed.add(element);
|
|
177
|
+
env.edits.push((0, xml_js_1.removeElementEdit)(element, env.text));
|
|
178
|
+
};
|
|
179
|
+
const removeRefsTo = (env, flowId) => {
|
|
180
|
+
for (const ref of (0, xml_js_1.findElements)(env.root, (element) => (element.local === "incoming" || element.local === "outgoing") && (0, xml_js_1.textContent)(element).trim() === flowId))
|
|
181
|
+
removeElement(env, ref);
|
|
182
|
+
for (const owner of (0, xml_js_1.findElements)(env.root, (element) => (0, xml_js_1.attr)(element, "default") === flowId)) {
|
|
183
|
+
const edit = (0, xml_js_1.setAttributeEdit)(owner, "default", null, env.text);
|
|
184
|
+
if (edit)
|
|
185
|
+
env.edits.push(edit);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const removeFlowElement = (env, flowId) => {
|
|
189
|
+
const element = elementOf(env, flowId);
|
|
190
|
+
if (element)
|
|
191
|
+
removeElement(env, element);
|
|
192
|
+
const di = env.parsed.diEdges.get(flowId);
|
|
193
|
+
if (di)
|
|
194
|
+
removeElement(env, di.element);
|
|
195
|
+
removeRefsTo(env, flowId);
|
|
196
|
+
};
|
|
197
|
+
const removeNodeElement = (env, id) => {
|
|
198
|
+
const element = elementOf(env, id);
|
|
199
|
+
if (!element)
|
|
200
|
+
return;
|
|
201
|
+
removeElement(env, element);
|
|
202
|
+
const shape = env.parsed.shapes.get(id);
|
|
203
|
+
if (shape)
|
|
204
|
+
removeElement(env, shape.element);
|
|
205
|
+
// Flows touching it, boundary events on it, lane refs to it.
|
|
206
|
+
for (const flow of (0, xml_js_1.findElements)(env.root, (candidate) => (candidate.local === "sequenceFlow" || candidate.local === "messageFlow") && ((0, xml_js_1.attr)(candidate, "sourceRef") === id || (0, xml_js_1.attr)(candidate, "targetRef") === id))) {
|
|
207
|
+
const flowId = (0, xml_js_1.attr)(flow, "id");
|
|
208
|
+
if (flowId)
|
|
209
|
+
removeFlowElement(env, flowId);
|
|
210
|
+
else
|
|
211
|
+
removeElement(env, flow);
|
|
212
|
+
}
|
|
213
|
+
for (const boundary of (0, xml_js_1.findElements)(env.root, (candidate) => candidate.local === "boundaryEvent" && (0, xml_js_1.attr)(candidate, "attachedToRef") === id)) {
|
|
214
|
+
const boundaryId = (0, xml_js_1.attr)(boundary, "id");
|
|
215
|
+
if (boundaryId)
|
|
216
|
+
removeNodeElement(env, boundaryId);
|
|
217
|
+
}
|
|
218
|
+
for (const ref of (0, xml_js_1.findElements)(env.root, (candidate) => candidate.local === "flowNodeRef" && (0, xml_js_1.textContent)(candidate).trim() === id))
|
|
219
|
+
removeElement(env, ref);
|
|
220
|
+
// Associations to annotations would dangle; the annotation itself stays.
|
|
221
|
+
for (const association of (0, xml_js_1.findElements)(env.root, (candidate) => candidate.local === "association" && ((0, xml_js_1.attr)(candidate, "sourceRef") === id || (0, xml_js_1.attr)(candidate, "targetRef") === id))) {
|
|
222
|
+
removeElement(env, association);
|
|
223
|
+
const associationId = (0, xml_js_1.attr)(association, "id");
|
|
224
|
+
const di = associationId ? env.parsed.diEdges.get(associationId) : undefined;
|
|
225
|
+
if (di)
|
|
226
|
+
removeElement(env, di.element);
|
|
227
|
+
}
|
|
228
|
+
if (element.local === "participant") {
|
|
229
|
+
const process = processForPool(env, id);
|
|
230
|
+
if (process && env.parsed.collaboration && (0, xml_js_1.childElements)(env.parsed.collaboration).filter((child) => child.local === "participant").length > 1) {
|
|
231
|
+
// Other pools keep the collaboration; the process of this one goes with it.
|
|
232
|
+
removeElement(env, process);
|
|
233
|
+
for (const child of (0, xml_js_1.findElements)(process, (candidate) => Boolean((0, xml_js_1.attr)(candidate, "id")))) {
|
|
234
|
+
const childId = (0, xml_js_1.attr)(child, "id");
|
|
235
|
+
const shape = env.parsed.shapes.get(childId);
|
|
236
|
+
if (shape)
|
|
237
|
+
removeElement(env, shape.element);
|
|
238
|
+
const di = env.parsed.diEdges.get(childId);
|
|
239
|
+
if (di)
|
|
240
|
+
removeElement(env, di.element);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (element.local === "subProcess" && (0, xml_js_1.childElements)(element).some((child) => (0, xml_js_1.attr)(child, "id"))) {
|
|
245
|
+
env.warnings.push(`Removing subprocess "${id}" removed its contents from the XML as well.`);
|
|
246
|
+
for (const child of (0, xml_js_1.findElements)(element, (candidate) => Boolean((0, xml_js_1.attr)(candidate, "id")))) {
|
|
247
|
+
const childId = (0, xml_js_1.attr)(child, "id");
|
|
248
|
+
const shape = env.parsed.shapes.get(childId);
|
|
249
|
+
if (shape)
|
|
250
|
+
removeElement(env, shape.element);
|
|
251
|
+
const di = env.parsed.diEdges.get(childId);
|
|
252
|
+
if (di)
|
|
253
|
+
removeElement(env, di.element);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const nodeElementXml = (env, node, indent) => {
|
|
258
|
+
const element = (0, types_js_1.bpmnElementForType)(node.type);
|
|
259
|
+
if (!element || element === "participant" || element === "lane")
|
|
260
|
+
return null;
|
|
261
|
+
const data = (0, types_js_1.bpmnNodeData)(node.data);
|
|
262
|
+
const attrsText = [
|
|
263
|
+
["id", node.id],
|
|
264
|
+
["name", node.label],
|
|
265
|
+
...(element === "boundaryEvent" ? [["attachedToRef", data?.attachedTo], ["cancelActivity", data?.cancelActivity === false ? "false" : undefined]] : []),
|
|
266
|
+
...(element === "subProcess" && data?.triggeredByEvent ? [["triggeredByEvent", "true"]] : []),
|
|
267
|
+
]
|
|
268
|
+
.filter((entry) => typeof entry[1] === "string" && entry[1] !== "")
|
|
269
|
+
.map(([name, value]) => ` ${name}="${(0, xml_js_1.escapeXml)(value)}"`)
|
|
270
|
+
.join("");
|
|
271
|
+
const definition = data?.eventDefinition && (0, types_js_1.getBpmnType)(node.type)?.kind === "event" ? data.eventDefinition : undefined;
|
|
272
|
+
if (!definition)
|
|
273
|
+
return `<${tag(env, element)}${attrsText} />`;
|
|
274
|
+
return [`<${tag(env, element)}${attrsText}>`, `${indent}${env.unit}<${tag(env, (0, types_js_1.eventDefinitionElement)(definition))} id="${freshId(env, `${node.id}_def`)}" />`, `${indent}</${tag(env, element)}>`].join("\n");
|
|
275
|
+
};
|
|
276
|
+
const addPool = (env, node) => {
|
|
277
|
+
const collaboration = env.parsed.collaboration;
|
|
278
|
+
const rect = rectOf(env, node.id);
|
|
279
|
+
const name = node.label ? ` name="${(0, xml_js_1.escapeXml)(node.label)}"` : "";
|
|
280
|
+
if (!collaboration) {
|
|
281
|
+
// First pool: wrap the main process (or a new one) in a collaboration.
|
|
282
|
+
const main = mainProcess(env);
|
|
283
|
+
const processId = main ? ((0, xml_js_1.attr)(main, "id") ?? "Process_1") : freshId(env, `Process_${node.id}`);
|
|
284
|
+
const indent = (0, xml_js_1.childIndentOf)(env.root, env.text, env.unit);
|
|
285
|
+
const collaborationId = freshId(env, "Collaboration_1");
|
|
286
|
+
const xml = [
|
|
287
|
+
`<${tag(env, "collaboration")} id="${collaborationId}">`,
|
|
288
|
+
`${indent}${env.unit}<${tag(env, "participant")} id="${(0, xml_js_1.escapeXml)(node.id)}"${name} processRef="${(0, xml_js_1.escapeXml)(processId)}" />`,
|
|
289
|
+
`${indent}</${tag(env, "collaboration")}>`,
|
|
290
|
+
].join("\n");
|
|
291
|
+
const firstChild = (0, xml_js_1.childElements)(env.root)[0];
|
|
292
|
+
if (firstChild)
|
|
293
|
+
env.edits.push({ span: { start: firstChild.span.start, end: firstChild.span.start }, replacement: `${xml}\n${indent}` });
|
|
294
|
+
else
|
|
295
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(env.root, xml, env.text, env.unit));
|
|
296
|
+
if (!main) {
|
|
297
|
+
const processXml = `<${tag(env, "process")} id="${(0, xml_js_1.escapeXml)(processId)}" isExecutable="false" />`;
|
|
298
|
+
env.edits.push(firstChild ? { span: { start: firstChild.span.start, end: firstChild.span.start }, replacement: `${processXml}\n${indent}` } : (0, xml_js_1.appendChildEdit)(env.root, processXml, env.text, env.unit));
|
|
299
|
+
}
|
|
300
|
+
if (env.parsed.plane) {
|
|
301
|
+
const edit = (0, xml_js_1.setAttributeEdit)(env.parsed.plane, "bpmnElement", collaborationId, env.text);
|
|
302
|
+
if (edit)
|
|
303
|
+
env.edits.push(edit);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
const processId = freshId(env, `Process_${node.id}`);
|
|
308
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(collaboration, `<${tag(env, "participant")} id="${(0, xml_js_1.escapeXml)(node.id)}"${name} processRef="${processId}" />`, env.text, env.unit));
|
|
309
|
+
const lastProcess = env.parsed.processes[env.parsed.processes.length - 1];
|
|
310
|
+
const processXml = `<${tag(env, "process")} id="${processId}" isExecutable="false" />`;
|
|
311
|
+
env.edits.push(lastProcess ? (0, xml_js_1.insertAfterEdit)(lastProcess, processXml, env.text) : (0, xml_js_1.insertAfterEdit)(collaboration, processXml, env.text));
|
|
312
|
+
}
|
|
313
|
+
appendToPlane(env, (indent) => shapeXml(env, node.id, rect, [["isHorizontal", "true"]], indent));
|
|
314
|
+
return true;
|
|
315
|
+
};
|
|
316
|
+
const addLane = (env, node) => {
|
|
317
|
+
const parent = node.parentId ? env.afterById.get(node.parentId) : undefined;
|
|
318
|
+
if (!parent) {
|
|
319
|
+
env.warnings.push(`Lane "${node.id}" needs a pool or a lane as its parent.`);
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
const name = node.label ? ` name="${(0, xml_js_1.escapeXml)(node.label)}"` : "";
|
|
323
|
+
const laneXml = `<${tag(env, "lane")} id="${(0, xml_js_1.escapeXml)(node.id)}"${name} />`;
|
|
324
|
+
if (parent.type === "bpmn.pool") {
|
|
325
|
+
const process = processForPool(env, parent.id);
|
|
326
|
+
if (!process)
|
|
327
|
+
return false;
|
|
328
|
+
const laneSet = (0, xml_js_1.childElements)(process).find((child) => child.local === "laneSet");
|
|
329
|
+
if (laneSet)
|
|
330
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(laneSet, laneXml, env.text, env.unit));
|
|
331
|
+
else {
|
|
332
|
+
const indent = (0, xml_js_1.childIndentOf)(process, env.text, env.unit);
|
|
333
|
+
const xml = [`<${tag(env, "laneSet")} id="${freshId(env, `${(0, xml_js_1.attr)(process, "id") ?? "Process"}_lanes`)}">`, `${indent}${env.unit}${laneXml}`, `${indent}</${tag(env, "laneSet")}>`].join("\n");
|
|
334
|
+
const first = (0, xml_js_1.childElements)(process)[0];
|
|
335
|
+
if (first)
|
|
336
|
+
env.edits.push({ span: { start: first.span.start, end: first.span.start }, replacement: `${xml}\n${indent}` });
|
|
337
|
+
else
|
|
338
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(process, xml, env.text, env.unit));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else if (parent.type === "bpmn.lane") {
|
|
342
|
+
const parentLane = elementOf(env, parent.id);
|
|
343
|
+
if (!parentLane)
|
|
344
|
+
return false;
|
|
345
|
+
const childSet = (0, xml_js_1.childElements)(parentLane).find((child) => child.local === "childLaneSet");
|
|
346
|
+
if (childSet)
|
|
347
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(childSet, laneXml, env.text, env.unit));
|
|
348
|
+
else {
|
|
349
|
+
const indent = (0, xml_js_1.childIndentOf)(parentLane, env.text, env.unit);
|
|
350
|
+
const xml = [`<${tag(env, "childLaneSet")} id="${freshId(env, `${parent.id}_lanes`)}">`, `${indent}${env.unit}${laneXml}`, `${indent}</${tag(env, "childLaneSet")}>`].join("\n");
|
|
351
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(parentLane, xml, env.text, env.unit));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
env.warnings.push(`Lane "${node.id}" needs a pool or a lane as its parent.`);
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
appendToPlane(env, (indent) => shapeXml(env, node.id, rectOf(env, node.id), [["isHorizontal", "true"]], indent));
|
|
359
|
+
return true;
|
|
360
|
+
};
|
|
361
|
+
const addNode = (env, id) => {
|
|
362
|
+
const node = env.afterById.get(id);
|
|
363
|
+
if (!node)
|
|
364
|
+
return false;
|
|
365
|
+
if (elementOf(env, id))
|
|
366
|
+
return true; // already there (an undo re-adding it, or a duplicate id)
|
|
367
|
+
if (node.type === "bpmn.pool")
|
|
368
|
+
return addPool(env, node);
|
|
369
|
+
if (node.type === "bpmn.lane")
|
|
370
|
+
return addLane(env, node);
|
|
371
|
+
const container = containerFor(env, node);
|
|
372
|
+
if (!container) {
|
|
373
|
+
env.warnings.push(`No process to add "${id}" to.`);
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
const indent = (0, xml_js_1.childIndentOf)(container, env.text, env.unit);
|
|
377
|
+
const xml = nodeElementXml(env, node, indent);
|
|
378
|
+
if (!xml) {
|
|
379
|
+
env.warnings.push(`"${node.type}" is not a BPMN element; "${id}" was not written to the XML.`);
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
// Before the first sequence flow of the container keeps the modeler's usual order.
|
|
383
|
+
const firstFlow = (0, xml_js_1.childElements)(container).find((child) => child.local === "sequenceFlow");
|
|
384
|
+
if (firstFlow)
|
|
385
|
+
env.edits.push({ span: { start: firstFlow.span.start, end: firstFlow.span.start }, replacement: `${xml}\n${indent}` });
|
|
386
|
+
else
|
|
387
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(container, xml, env.text, env.unit));
|
|
388
|
+
const lane = laneFor(env, node);
|
|
389
|
+
if (lane)
|
|
390
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(lane, `<${tag(env, "flowNodeRef")}>${(0, xml_js_1.escapeXml)(id)}</${tag(env, "flowNodeRef")}>`, env.text, env.unit));
|
|
391
|
+
const extra = node.type === "bpmn.subprocess" ? [["isExpanded", node.collapsed ? "false" : "true"]] : [];
|
|
392
|
+
appendToPlane(env, (planeIndent) => shapeXml(env, id, rectOf(env, id), extra, planeIndent));
|
|
393
|
+
return true;
|
|
394
|
+
};
|
|
395
|
+
const setColor = (env, id, fill, stroke) => {
|
|
396
|
+
const shape = env.parsed.shapes.get(id)?.element ?? env.parsed.diEdges.get(id)?.element;
|
|
397
|
+
if (!shape)
|
|
398
|
+
return;
|
|
399
|
+
if (fill !== undefined || stroke !== undefined)
|
|
400
|
+
ensureNamespace(env, "bioc", derive_js_1.BIOC_NS);
|
|
401
|
+
for (const [name, value] of [
|
|
402
|
+
["bioc:fill", fill],
|
|
403
|
+
["bioc:stroke", stroke],
|
|
404
|
+
]) {
|
|
405
|
+
if (value === undefined)
|
|
406
|
+
continue;
|
|
407
|
+
const edit = (0, xml_js_1.setAttributeEdit)(shape, name, value, env.text);
|
|
408
|
+
if (edit)
|
|
409
|
+
env.edits.push(edit);
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
const rawColor = (value) => {
|
|
413
|
+
if (value === undefined)
|
|
414
|
+
return undefined;
|
|
415
|
+
if (value === null)
|
|
416
|
+
return null;
|
|
417
|
+
if (typeof value === "object" && value && "raw" in value && typeof value.raw === "string")
|
|
418
|
+
return value.raw;
|
|
419
|
+
return undefined; // a token color has no XML form
|
|
420
|
+
};
|
|
421
|
+
const updateNode = (env, op) => {
|
|
422
|
+
const element = elementOf(env, op.id);
|
|
423
|
+
if (!element)
|
|
424
|
+
return false;
|
|
425
|
+
const changes = op.changes;
|
|
426
|
+
let handled = false;
|
|
427
|
+
if (changes.label !== undefined) {
|
|
428
|
+
const edit = (0, xml_js_1.setAttributeEdit)(element, "name", changes.label ?? null, env.text);
|
|
429
|
+
if (edit)
|
|
430
|
+
env.edits.push(edit);
|
|
431
|
+
handled = true;
|
|
432
|
+
}
|
|
433
|
+
if (changes.type !== undefined) {
|
|
434
|
+
const local = (0, types_js_1.bpmnElementForType)(changes.type);
|
|
435
|
+
if (local && local !== element.local && local !== "participant" && local !== "lane") {
|
|
436
|
+
env.edits.push(...(0, xml_js_1.renameElementEdits)(element, tag(env, local)));
|
|
437
|
+
handled = true;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
const data = changes.data && typeof changes.data === "object" ? changes.data.bpmn : undefined;
|
|
441
|
+
if (data && typeof data === "object") {
|
|
442
|
+
const wantedDefinition = data.eventDefinition;
|
|
443
|
+
const current = (0, xml_js_1.childElements)(element).find((child) => (0, types_js_1.eventDefinitionFromElement)(child.local));
|
|
444
|
+
if ("eventDefinition" in data) {
|
|
445
|
+
if (!wantedDefinition && current)
|
|
446
|
+
removeElement(env, current);
|
|
447
|
+
else if (wantedDefinition && current && (0, types_js_1.eventDefinitionFromElement)(current.local) !== wantedDefinition)
|
|
448
|
+
env.edits.push(...(0, xml_js_1.renameElementEdits)(current, tag(env, (0, types_js_1.eventDefinitionElement)(wantedDefinition))));
|
|
449
|
+
else if (wantedDefinition && !current)
|
|
450
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(element, `<${tag(env, (0, types_js_1.eventDefinitionElement)(wantedDefinition))} id="${freshId(env, `${op.id}_def`)}" />`, env.text, env.unit));
|
|
451
|
+
}
|
|
452
|
+
if ("attachedTo" in data) {
|
|
453
|
+
const edit = (0, xml_js_1.setAttributeEdit)(element, "attachedToRef", typeof data.attachedTo === "string" ? data.attachedTo : null, env.text);
|
|
454
|
+
if (edit)
|
|
455
|
+
env.edits.push(edit);
|
|
456
|
+
}
|
|
457
|
+
if ("cancelActivity" in data) {
|
|
458
|
+
const edit = (0, xml_js_1.setAttributeEdit)(element, "cancelActivity", data.cancelActivity === false ? "false" : null, env.text);
|
|
459
|
+
if (edit)
|
|
460
|
+
env.edits.push(edit);
|
|
461
|
+
}
|
|
462
|
+
if ("isExpanded" in data) {
|
|
463
|
+
const shape = env.parsed.shapes.get(op.id);
|
|
464
|
+
const edit = shape ? (0, xml_js_1.setAttributeEdit)(shape.element, "isExpanded", data.isExpanded ? "true" : "false", env.text) : null;
|
|
465
|
+
if (edit)
|
|
466
|
+
env.edits.push(edit);
|
|
467
|
+
}
|
|
468
|
+
handled = true;
|
|
469
|
+
}
|
|
470
|
+
if (changes.collapsed !== undefined && element.local === "subProcess") {
|
|
471
|
+
const shape = env.parsed.shapes.get(op.id);
|
|
472
|
+
const edit = shape ? (0, xml_js_1.setAttributeEdit)(shape.element, "isExpanded", changes.collapsed ? "false" : "true", env.text) : null;
|
|
473
|
+
if (edit)
|
|
474
|
+
env.edits.push(edit);
|
|
475
|
+
handled = true;
|
|
476
|
+
}
|
|
477
|
+
if (changes.style !== undefined) {
|
|
478
|
+
if (changes.style === null)
|
|
479
|
+
setColor(env, op.id, null, null);
|
|
480
|
+
else
|
|
481
|
+
setColor(env, op.id, rawColor(changes.style.fill), rawColor(changes.style.stroke));
|
|
482
|
+
handled = true;
|
|
483
|
+
}
|
|
484
|
+
return handled;
|
|
485
|
+
};
|
|
486
|
+
const moveNodes = (env, ids) => {
|
|
487
|
+
const touched = new Set();
|
|
488
|
+
for (const id of ids) {
|
|
489
|
+
touched.add(id);
|
|
490
|
+
for (const child of (0, geometry_js_1.descendantIds)(id, env.afterById.size ? [...env.afterById.values()] : []))
|
|
491
|
+
touched.add(child);
|
|
492
|
+
}
|
|
493
|
+
let handled = false;
|
|
494
|
+
for (const id of touched) {
|
|
495
|
+
if (!env.parsed.shapes.has(id))
|
|
496
|
+
continue;
|
|
497
|
+
setBounds(env, id, rectOf(env, id));
|
|
498
|
+
handled = true;
|
|
499
|
+
}
|
|
500
|
+
refreshIncidentEdges(env, touched);
|
|
501
|
+
return handled;
|
|
502
|
+
};
|
|
503
|
+
const flowElementFor = (env, edge) => {
|
|
504
|
+
const source = elementOf(env, edge.source);
|
|
505
|
+
const target = elementOf(env, edge.target);
|
|
506
|
+
if (!source || !target)
|
|
507
|
+
return null;
|
|
508
|
+
const message = (0, types_js_1.bpmnEdgeData)(edge.data)?.flow === "message" || source.local === "participant" || target.local === "participant" || ancestorProcess(source) !== ancestorProcess(target);
|
|
509
|
+
if (message) {
|
|
510
|
+
if (!env.parsed.collaboration) {
|
|
511
|
+
env.warnings.push(`Message flow "${edge.id}" needs pools (a collaboration); it was not written to the XML.`);
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
return { container: env.parsed.collaboration, kind: "messageFlow" };
|
|
515
|
+
}
|
|
516
|
+
// Deepest container both ends share.
|
|
517
|
+
const chain = (element) => {
|
|
518
|
+
const out = [];
|
|
519
|
+
let current = element.parent;
|
|
520
|
+
while (current) {
|
|
521
|
+
if (isProcessLike(current))
|
|
522
|
+
out.push(current);
|
|
523
|
+
current = current.parent;
|
|
524
|
+
}
|
|
525
|
+
return out;
|
|
526
|
+
};
|
|
527
|
+
const targetChain = new Set(chain(target));
|
|
528
|
+
const shared = chain(source).find((candidate) => targetChain.has(candidate));
|
|
529
|
+
return shared ? { container: shared, kind: "sequenceFlow" } : null;
|
|
530
|
+
};
|
|
531
|
+
const refChild = (env, nodeId, kind, flowId) => {
|
|
532
|
+
const element = elementOf(env, nodeId);
|
|
533
|
+
if (!element || element.local === "participant")
|
|
534
|
+
return;
|
|
535
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(element, `<${tag(env, kind)}>${(0, xml_js_1.escapeXml)(flowId)}</${tag(env, kind)}>`, env.text, env.unit));
|
|
536
|
+
};
|
|
537
|
+
const addEdge = (env, id) => {
|
|
538
|
+
const edge = afterEdgesRef.get(id);
|
|
539
|
+
if (!edge || !edge.source || !edge.target)
|
|
540
|
+
return false;
|
|
541
|
+
if (elementOf(env, id))
|
|
542
|
+
return true;
|
|
543
|
+
const placement = flowElementFor(env, edge);
|
|
544
|
+
if (!placement)
|
|
545
|
+
return false;
|
|
546
|
+
const data = (0, types_js_1.bpmnEdgeData)(edge.data);
|
|
547
|
+
const indent = (0, xml_js_1.childIndentOf)(placement.container, env.text, env.unit);
|
|
548
|
+
const open = `<${tag(env, placement.kind)} id="${(0, xml_js_1.escapeXml)(id)}"${edge.label ? ` name="${(0, xml_js_1.escapeXml)(edge.label)}"` : ""} sourceRef="${(0, xml_js_1.escapeXml)(edge.source)}" targetRef="${(0, xml_js_1.escapeXml)(edge.target)}"`;
|
|
549
|
+
const xml = data?.conditionExpression
|
|
550
|
+
? [`${open}>`, `${indent}${env.unit}<${tag(env, "conditionExpression")} xsi:type="${tag(env, "tFormalExpression")}">${(0, xml_js_1.escapeXml)(data.conditionExpression)}</${tag(env, "conditionExpression")}>`, `${indent}</${tag(env, placement.kind)}>`].join("\n")
|
|
551
|
+
: `${open} />`;
|
|
552
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(placement.container, xml, env.text, env.unit));
|
|
553
|
+
if (placement.kind === "sequenceFlow") {
|
|
554
|
+
refChild(env, edge.source, "outgoing", id);
|
|
555
|
+
refChild(env, edge.target, "incoming", id);
|
|
556
|
+
if (data?.isDefault) {
|
|
557
|
+
const source = elementOf(env, edge.source);
|
|
558
|
+
const edit = source ? (0, xml_js_1.setAttributeEdit)(source, "default", id, env.text) : null;
|
|
559
|
+
if (edit)
|
|
560
|
+
env.edits.push(edit);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
appendToPlane(env, (planeIndent) => edgeXml(env, id, waypointsFor(env, edge), planeIndent));
|
|
564
|
+
return true;
|
|
565
|
+
};
|
|
566
|
+
const updateEdge = (env, op) => {
|
|
567
|
+
const element = elementOf(env, op.id);
|
|
568
|
+
if (!element)
|
|
569
|
+
return false;
|
|
570
|
+
const after = afterEdgesRef.get(op.id);
|
|
571
|
+
const changes = op.changes;
|
|
572
|
+
let handled = false;
|
|
573
|
+
if (changes.label !== undefined) {
|
|
574
|
+
const edit = (0, xml_js_1.setAttributeEdit)(element, "name", changes.label ?? null, env.text);
|
|
575
|
+
if (edit)
|
|
576
|
+
env.edits.push(edit);
|
|
577
|
+
handled = true;
|
|
578
|
+
}
|
|
579
|
+
const previousSource = (0, xml_js_1.attr)(element, "sourceRef");
|
|
580
|
+
const previousTarget = (0, xml_js_1.attr)(element, "targetRef");
|
|
581
|
+
if (changes.source !== undefined && changes.source !== previousSource) {
|
|
582
|
+
const edit = (0, xml_js_1.setAttributeEdit)(element, "sourceRef", changes.source, env.text);
|
|
583
|
+
if (edit)
|
|
584
|
+
env.edits.push(edit);
|
|
585
|
+
for (const ref of (0, xml_js_1.findElements)(env.root, (candidate) => candidate.local === "outgoing" && (0, xml_js_1.textContent)(candidate).trim() === op.id))
|
|
586
|
+
removeElement(env, ref);
|
|
587
|
+
if (element.local === "sequenceFlow")
|
|
588
|
+
refChild(env, changes.source, "outgoing", op.id);
|
|
589
|
+
handled = true;
|
|
590
|
+
}
|
|
591
|
+
if (changes.target !== undefined && changes.target !== previousTarget) {
|
|
592
|
+
const edit = (0, xml_js_1.setAttributeEdit)(element, "targetRef", changes.target, env.text);
|
|
593
|
+
if (edit)
|
|
594
|
+
env.edits.push(edit);
|
|
595
|
+
for (const ref of (0, xml_js_1.findElements)(env.root, (candidate) => candidate.local === "incoming" && (0, xml_js_1.textContent)(candidate).trim() === op.id))
|
|
596
|
+
removeElement(env, ref);
|
|
597
|
+
if (element.local === "sequenceFlow")
|
|
598
|
+
refChild(env, changes.target, "incoming", op.id);
|
|
599
|
+
handled = true;
|
|
600
|
+
}
|
|
601
|
+
if ((changes.source !== undefined || changes.target !== undefined || changes.waypoints !== undefined) && after) {
|
|
602
|
+
setWaypoints(env, op.id, waypointsFor(env, after));
|
|
603
|
+
handled = true;
|
|
604
|
+
}
|
|
605
|
+
const data = changes.data && typeof changes.data === "object" ? changes.data.bpmn : undefined;
|
|
606
|
+
if (data && typeof data === "object") {
|
|
607
|
+
if ("conditionExpression" in data) {
|
|
608
|
+
const current = (0, xml_js_1.childElements)(element).find((child) => child.local === "conditionExpression");
|
|
609
|
+
const expression = typeof data.conditionExpression === "string" && data.conditionExpression.trim() ? data.conditionExpression : null;
|
|
610
|
+
if (!expression && current)
|
|
611
|
+
removeElement(env, current);
|
|
612
|
+
else if (expression && current)
|
|
613
|
+
env.edits.push({ span: current.span, replacement: `<${current.name} xsi:type="${tag(env, "tFormalExpression")}">${(0, xml_js_1.escapeXml)(expression)}</${current.name}>` });
|
|
614
|
+
else if (expression)
|
|
615
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(element, `<${tag(env, "conditionExpression")} xsi:type="${tag(env, "tFormalExpression")}">${(0, xml_js_1.escapeXml)(expression)}</${tag(env, "conditionExpression")}>`, env.text, env.unit));
|
|
616
|
+
}
|
|
617
|
+
if ("isDefault" in data) {
|
|
618
|
+
const sourceId = changes.source ?? previousSource;
|
|
619
|
+
const source = sourceId ? elementOf(env, sourceId) : undefined;
|
|
620
|
+
if (source) {
|
|
621
|
+
const edit = (0, xml_js_1.setAttributeEdit)(source, "default", data.isDefault ? op.id : null, env.text);
|
|
622
|
+
if (edit)
|
|
623
|
+
env.edits.push(edit);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
handled = true;
|
|
627
|
+
}
|
|
628
|
+
if (changes.style !== undefined) {
|
|
629
|
+
setColor(env, op.id, undefined, changes.style === null ? null : rawColor(changes.style.stroke));
|
|
630
|
+
handled = true;
|
|
631
|
+
}
|
|
632
|
+
return handled;
|
|
633
|
+
};
|
|
634
|
+
const reparent = (env, op) => {
|
|
635
|
+
const element = elementOf(env, op.id);
|
|
636
|
+
const node = env.afterById.get(op.id);
|
|
637
|
+
if (!element || !node)
|
|
638
|
+
return false;
|
|
639
|
+
if (element.local === "participant")
|
|
640
|
+
return false;
|
|
641
|
+
const before = env.beforeById.get(op.id);
|
|
642
|
+
const previousParent = before?.parentId ? env.beforeById.get(before.parentId) : undefined;
|
|
643
|
+
// Lane membership.
|
|
644
|
+
for (const ref of (0, xml_js_1.findElements)(env.root, (candidate) => candidate.local === "flowNodeRef" && (0, xml_js_1.textContent)(candidate).trim() === op.id))
|
|
645
|
+
removeElement(env, ref);
|
|
646
|
+
const lane = laneFor(env, node);
|
|
647
|
+
if (lane)
|
|
648
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(lane, `<${tag(env, "flowNodeRef")}>${(0, xml_js_1.escapeXml)(op.id)}</${tag(env, "flowNodeRef")}>`, env.text, env.unit));
|
|
649
|
+
// Container (process / subprocess) change: move the element's text.
|
|
650
|
+
const target = element.local === "lane" ? null : containerFor(env, node);
|
|
651
|
+
const current = nearestContainerElement(element);
|
|
652
|
+
if (target && current && target !== current) {
|
|
653
|
+
const xml = env.text.slice(element.span.start, element.span.end);
|
|
654
|
+
removeElement(env, element);
|
|
655
|
+
const firstFlow = (0, xml_js_1.childElements)(target).find((child) => child.local === "sequenceFlow");
|
|
656
|
+
const indent = (0, xml_js_1.childIndentOf)(target, env.text, env.unit);
|
|
657
|
+
const reindented = xml.replace(/\n[ \t]*/g, `\n${indent}`);
|
|
658
|
+
if (firstFlow)
|
|
659
|
+
env.edits.push({ span: { start: firstFlow.span.start, end: firstFlow.span.start }, replacement: `${reindented}\n${indent}` });
|
|
660
|
+
else
|
|
661
|
+
env.edits.push((0, xml_js_1.appendChildEdit)(target, reindented, env.text, env.unit));
|
|
662
|
+
}
|
|
663
|
+
void previousParent;
|
|
664
|
+
setBounds(env, op.id, rectOf(env, op.id));
|
|
665
|
+
for (const child of (0, geometry_js_1.descendantIds)(op.id, [...env.afterById.values()]))
|
|
666
|
+
setBounds(env, child, rectOf(env, child));
|
|
667
|
+
refreshIncidentEdges(env, new Set([op.id]));
|
|
668
|
+
return true;
|
|
669
|
+
};
|
|
670
|
+
const setTitle = (env, title) => {
|
|
671
|
+
const process = env.parsed.processes.length === 1 ? env.parsed.processes[0] : mainProcess(env);
|
|
672
|
+
if (!process || env.parsed.collaboration)
|
|
673
|
+
return false;
|
|
674
|
+
const edit = (0, xml_js_1.setAttributeEdit)(process, "name", title, env.text);
|
|
675
|
+
if (edit)
|
|
676
|
+
env.edits.push(edit);
|
|
677
|
+
return true;
|
|
678
|
+
};
|
|
679
|
+
const applyOne = (env, op) => {
|
|
680
|
+
switch (op.op) {
|
|
681
|
+
case "addNode":
|
|
682
|
+
return addNode(env, op.node.id);
|
|
683
|
+
case "updateNode":
|
|
684
|
+
return updateNode(env, op);
|
|
685
|
+
case "removeNode":
|
|
686
|
+
if (!elementOf(env, op.id))
|
|
687
|
+
return false;
|
|
688
|
+
removeNodeElement(env, op.id);
|
|
689
|
+
return true;
|
|
690
|
+
case "moveNodes":
|
|
691
|
+
return moveNodes(env, op.moves.map((move) => move.id));
|
|
692
|
+
case "resizeNode":
|
|
693
|
+
return moveNodes(env, [op.id]);
|
|
694
|
+
case "reparent":
|
|
695
|
+
return reparent(env, op);
|
|
696
|
+
case "addEdge":
|
|
697
|
+
return addEdge(env, op.edge.id);
|
|
698
|
+
case "updateEdge":
|
|
699
|
+
return updateEdge(env, op);
|
|
700
|
+
case "removeEdge":
|
|
701
|
+
if (!elementOf(env, op.id))
|
|
702
|
+
return false;
|
|
703
|
+
removeFlowElement(env, op.id);
|
|
704
|
+
return true;
|
|
705
|
+
case "setTitle":
|
|
706
|
+
return setTitle(env, op.title);
|
|
707
|
+
default:
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
const flatten = (ops, out) => {
|
|
712
|
+
for (const op of ops) {
|
|
713
|
+
if (op.op === "batch")
|
|
714
|
+
flatten(op.ops, out);
|
|
715
|
+
else
|
|
716
|
+
out.push(op);
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
const patchBpmnSource = (text, ops, context) => {
|
|
720
|
+
const flat = [];
|
|
721
|
+
flatten(ops, flat);
|
|
722
|
+
const unmapped = [];
|
|
723
|
+
const warnings = [];
|
|
724
|
+
const afterById = (0, geometry_js_1.indexNodes)(context.after.nodes);
|
|
725
|
+
const afterRects = (0, geometry_js_1.absoluteRects)(context.after);
|
|
726
|
+
const beforeById = (0, geometry_js_1.indexNodes)(context.before.nodes);
|
|
727
|
+
afterEdgesRef = new Map(context.after.edges.map((edge) => [edge.id, edge]));
|
|
728
|
+
let current = text;
|
|
729
|
+
let changed = false;
|
|
730
|
+
for (const op of flat) {
|
|
731
|
+
const parsed = (0, derive_js_1.parseBpmn)(current);
|
|
732
|
+
const root = parsed.definitions;
|
|
733
|
+
if (!parsed.ok || !root) {
|
|
734
|
+
unmapped.push(op);
|
|
735
|
+
continue;
|
|
736
|
+
}
|
|
737
|
+
const bp = (0, xml_js_1.prefixForNamespace)(root, derive_js_1.BPMN_NS) ?? (root.prefix || null);
|
|
738
|
+
const env = {
|
|
739
|
+
parsed,
|
|
740
|
+
text: current,
|
|
741
|
+
root,
|
|
742
|
+
unit: (0, xml_js_1.indentUnit)(root, current),
|
|
743
|
+
bp,
|
|
744
|
+
di: (0, xml_js_1.prefixForNamespace)(root, derive_js_1.BPMNDI_NS) ?? "bpmndi",
|
|
745
|
+
dc: (0, xml_js_1.prefixForNamespace)(root, derive_js_1.DC_NS) ?? "dc",
|
|
746
|
+
dd: (0, xml_js_1.prefixForNamespace)(root, derive_js_1.DI_NS) ?? "di",
|
|
747
|
+
bioc: (0, xml_js_1.prefixForNamespace)(root, derive_js_1.BIOC_NS),
|
|
748
|
+
afterById,
|
|
749
|
+
afterRects,
|
|
750
|
+
beforeById,
|
|
751
|
+
warnings,
|
|
752
|
+
edits: [],
|
|
753
|
+
removed: new Set(),
|
|
754
|
+
};
|
|
755
|
+
if ((0, xml_js_1.prefixForNamespace)(root, derive_js_1.BPMNDI_NS) === null)
|
|
756
|
+
ensureNamespace(env, "bpmndi", derive_js_1.BPMNDI_NS);
|
|
757
|
+
if ((0, xml_js_1.prefixForNamespace)(root, derive_js_1.DC_NS) === null)
|
|
758
|
+
ensureNamespace(env, "dc", derive_js_1.DC_NS);
|
|
759
|
+
if ((0, xml_js_1.prefixForNamespace)(root, derive_js_1.DI_NS) === null)
|
|
760
|
+
ensureNamespace(env, "di", derive_js_1.DI_NS);
|
|
761
|
+
const handled = applyOne(env, op);
|
|
762
|
+
if (!handled) {
|
|
763
|
+
unmapped.push(op);
|
|
764
|
+
continue;
|
|
765
|
+
}
|
|
766
|
+
if (env.edits.length > 0) {
|
|
767
|
+
current = (0, xml_js_1.applyEdits)(current, env.edits);
|
|
768
|
+
changed = true;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return { text: current, unmapped, changed, warnings };
|
|
772
|
+
};
|
|
773
|
+
exports.patchBpmnSource = patchBpmnSource;
|
|
774
|
+
//# sourceMappingURL=patch.js.map
|