@yh-ui/flow 0.1.27 → 0.1.29

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.
@@ -35,6 +35,12 @@ const GATEWAY_DIRECTION = {
35
35
  "bpmn-parallel-gateway": "diverging",
36
36
  "bpmn-inclusive-gateway": "diverging"
37
37
  };
38
+ const getDomParser = () => {
39
+ if (typeof DOMParser === "undefined") {
40
+ return null;
41
+ }
42
+ return new DOMParser();
43
+ };
38
44
  function flowToBpmnXml(nodes, edges, options = {}) {
39
45
  const {
40
46
  processId = "Process_" + Date.now(),
@@ -151,7 +157,13 @@ function bpmnXmlToFlow(xml, options = {}) {
151
157
  } = options;
152
158
  const nodes = [];
153
159
  const edges = [];
154
- const parser = new DOMParser();
160
+ const parser = getDomParser();
161
+ if (!parser) {
162
+ return {
163
+ nodes,
164
+ edges
165
+ };
166
+ }
155
167
  const doc = parser.parseFromString(xml, "text/xml");
156
168
  const parseError = doc.querySelector("parsererror");
157
169
  if (parseError) {
@@ -334,7 +346,13 @@ function applySimpleLayout(nodes, edges, spacing) {
334
346
  }
335
347
  function validateBpmnXml(xml) {
336
348
  try {
337
- const parser = new DOMParser();
349
+ const parser = getDomParser();
350
+ if (!parser) {
351
+ return {
352
+ valid: false,
353
+ error: "DOMParser is not available in the current environment"
354
+ };
355
+ }
338
356
  const doc = parser.parseFromString(xml, "text/xml");
339
357
  const parseError = doc.querySelector("parsererror");
340
358
  if (parseError) {
@@ -26,6 +26,12 @@ const GATEWAY_DIRECTION = {
26
26
  "bpmn-parallel-gateway": "diverging",
27
27
  "bpmn-inclusive-gateway": "diverging"
28
28
  };
29
+ const getDomParser = () => {
30
+ if (typeof DOMParser === "undefined") {
31
+ return null;
32
+ }
33
+ return new DOMParser();
34
+ };
29
35
  export function flowToBpmnXml(nodes, edges, options = {}) {
30
36
  const {
31
37
  processId = "Process_" + Date.now(),
@@ -135,7 +141,10 @@ export function bpmnXmlToFlow(xml, options = {}) {
135
141
  const { defaultPosition = { x: 100, y: 100 }, nodeSpacing = 150 } = options;
136
142
  const nodes = [];
137
143
  const edges = [];
138
- const parser = new DOMParser();
144
+ const parser = getDomParser();
145
+ if (!parser) {
146
+ return { nodes, edges };
147
+ }
139
148
  const doc = parser.parseFromString(xml, "text/xml");
140
149
  const parseError = doc.querySelector("parsererror");
141
150
  if (parseError) {
@@ -315,7 +324,10 @@ function applySimpleLayout(nodes, edges, spacing) {
315
324
  }
316
325
  export function validateBpmnXml(xml) {
317
326
  try {
318
- const parser = new DOMParser();
327
+ const parser = getDomParser();
328
+ if (!parser) {
329
+ return { valid: false, error: "DOMParser is not available in the current environment" };
330
+ }
319
331
  const doc = parser.parseFromString(xml, "text/xml");
320
332
  const parseError = doc.querySelector("parsererror");
321
333
  if (parseError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yh-ui/flow",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "YH-UI High-performance Flow Chart Component",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -23,8 +23,8 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@yh-ui/utils": "^0.1.27",
27
- "@yh-ui/hooks": "^0.1.27"
26
+ "@yh-ui/utils": "^0.1.29",
27
+ "@yh-ui/hooks": "^0.1.29"
28
28
  },
29
29
  "devDependencies": {
30
30
  "vue": "^3.5.27",