@yh-ui/flow 1.0.1 → 1.0.4

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.
Files changed (70) hide show
  1. package/dist/__tests__/bpmn-engine.test.cjs +357 -0
  2. package/dist/__tests__/bpmn-engine.test.d.ts +1 -0
  3. package/dist/__tests__/bpmn-engine.test.mjs +406 -0
  4. package/dist/__tests__/bpmn-utils.test.cjs +268 -0
  5. package/dist/__tests__/bpmn-utils.test.d.ts +1 -0
  6. package/dist/__tests__/bpmn-utils.test.mjs +227 -0
  7. package/dist/__tests__/bpmn-xml.test.cjs +150 -0
  8. package/dist/__tests__/bpmn-xml.test.d.ts +1 -0
  9. package/dist/__tests__/bpmn-xml.test.mjs +112 -0
  10. package/dist/__tests__/collaboration.test.cjs +487 -0
  11. package/dist/__tests__/collaboration.test.d.ts +1 -0
  12. package/dist/__tests__/collaboration.test.mjs +424 -0
  13. package/dist/__tests__/edge-types.test.cjs +275 -0
  14. package/dist/__tests__/edge-types.test.d.ts +1 -0
  15. package/dist/__tests__/edge-types.test.mjs +234 -0
  16. package/dist/__tests__/edge-utils.test.cjs +375 -0
  17. package/dist/__tests__/edge-utils.test.d.ts +1 -0
  18. package/dist/__tests__/edge-utils.test.mjs +376 -0
  19. package/dist/__tests__/events-types.test.cjs +184 -0
  20. package/dist/__tests__/events-types.test.d.ts +1 -0
  21. package/dist/__tests__/events-types.test.mjs +184 -0
  22. package/dist/__tests__/export-image-plugin.test.cjs +142 -0
  23. package/dist/__tests__/export-image-plugin.test.d.ts +1 -0
  24. package/dist/__tests__/export-image-plugin.test.mjs +118 -0
  25. package/dist/__tests__/export.test.cjs +237 -0
  26. package/dist/__tests__/export.test.d.ts +1 -0
  27. package/dist/__tests__/export.test.mjs +171 -0
  28. package/dist/__tests__/flow-context.test.cjs +16 -0
  29. package/dist/__tests__/flow-context.test.d.ts +1 -0
  30. package/dist/__tests__/flow-context.test.mjs +16 -0
  31. package/dist/__tests__/flow-props.test.cjs +94 -0
  32. package/dist/__tests__/flow-props.test.d.ts +1 -0
  33. package/dist/__tests__/flow-props.test.mjs +92 -0
  34. package/dist/__tests__/layout-plugin.test.cjs +233 -0
  35. package/dist/__tests__/layout-plugin.test.d.ts +1 -0
  36. package/dist/__tests__/layout-plugin.test.mjs +215 -0
  37. package/dist/__tests__/node-types.test.cjs +368 -0
  38. package/dist/__tests__/node-types.test.d.ts +1 -0
  39. package/dist/__tests__/node-types.test.mjs +292 -0
  40. package/dist/__tests__/performance.test.cjs +313 -0
  41. package/dist/__tests__/performance.test.d.ts +1 -0
  42. package/dist/__tests__/performance.test.mjs +218 -0
  43. package/dist/__tests__/plugin-advanced.test.cjs +301 -0
  44. package/dist/__tests__/plugin-advanced.test.d.ts +1 -0
  45. package/dist/__tests__/plugin-advanced.test.mjs +225 -0
  46. package/dist/__tests__/plugins.test.cjs +412 -0
  47. package/dist/__tests__/plugins.test.d.ts +1 -0
  48. package/dist/__tests__/plugins.test.mjs +402 -0
  49. package/dist/__tests__/screenshot-capture.test.cjs +183 -0
  50. package/dist/__tests__/screenshot-capture.test.d.ts +1 -0
  51. package/dist/__tests__/screenshot-capture.test.mjs +124 -0
  52. package/dist/__tests__/screenshot.test.cjs +74 -0
  53. package/dist/__tests__/screenshot.test.d.ts +1 -0
  54. package/dist/__tests__/screenshot.test.mjs +69 -0
  55. package/dist/__tests__/theme.test.cjs +185 -0
  56. package/dist/__tests__/theme.test.d.ts +1 -0
  57. package/dist/__tests__/theme.test.mjs +191 -0
  58. package/dist/__tests__/transform.test.cjs +376 -50
  59. package/dist/__tests__/transform.test.mjs +229 -28
  60. package/dist/__tests__/useAlignment.test.cjs +37 -0
  61. package/dist/__tests__/useAlignment.test.mjs +20 -0
  62. package/dist/__tests__/useNodeDistribution.test.cjs +643 -0
  63. package/dist/__tests__/useNodeDistribution.test.d.ts +1 -0
  64. package/dist/__tests__/useNodeDistribution.test.mjs +297 -0
  65. package/dist/__tests__/viewport-types.test.cjs +324 -0
  66. package/dist/__tests__/viewport-types.test.d.ts +1 -0
  67. package/dist/__tests__/viewport-types.test.mjs +207 -0
  68. package/dist/utils/bpmn.cjs +27 -16
  69. package/dist/utils/bpmn.mjs +27 -19
  70. package/package.json +3 -3
@@ -0,0 +1,207 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import {
3
+ getViewportForBounds,
4
+ project,
5
+ unproject,
6
+ isNodeVisible
7
+ } from "../types/viewport.mjs";
8
+ describe("flow/types/viewport", () => {
9
+ describe("ViewportTransform", () => {
10
+ it("should define viewport with x, y, zoom", () => {
11
+ const transform = { x: 100, y: 50, zoom: 1.5 };
12
+ expect(transform.x).toBe(100);
13
+ expect(transform.y).toBe(50);
14
+ expect(transform.zoom).toBe(1.5);
15
+ });
16
+ it("should allow negative coordinates", () => {
17
+ const transform = { x: -100, y: -50, zoom: 0.5 };
18
+ expect(transform.x).toBe(-100);
19
+ expect(transform.y).toBe(-50);
20
+ });
21
+ it("should allow zoom less than 1", () => {
22
+ const transform = { x: 0, y: 0, zoom: 0.1 };
23
+ expect(transform.zoom).toBe(0.1);
24
+ });
25
+ it("should allow zoom greater than 1", () => {
26
+ const transform = { x: 0, y: 0, zoom: 5 };
27
+ expect(transform.zoom).toBe(5);
28
+ });
29
+ });
30
+ describe("ViewportOptions", () => {
31
+ it("should define full viewport options", () => {
32
+ const options = {
33
+ minZoom: 0.1,
34
+ maxZoom: 5,
35
+ translateExtent: [[0, 0], [1e3, 1e3]],
36
+ zoomStep: 0.1,
37
+ panZoomSpeed: 1,
38
+ zoomInMultiplier: 1.2,
39
+ zoomOutMultiplier: 0.8,
40
+ panning: true,
41
+ zooming: true,
42
+ zoomOnScroll: true,
43
+ zoomOnPinch: true,
44
+ panOnScroll: true,
45
+ panOnDrag: true,
46
+ fitViewOnInit: true,
47
+ fitViewOnInitOptions: { padding: 0.2 }
48
+ };
49
+ expect(options.minZoom).toBe(0.1);
50
+ expect(options.maxZoom).toBe(5);
51
+ expect(options.fitViewOnInit).toBe(true);
52
+ });
53
+ it("should allow partial options", () => {
54
+ const options = {
55
+ minZoom: 0.2,
56
+ maxZoom: 3
57
+ };
58
+ expect(options.minZoom).toBe(0.2);
59
+ expect(options.maxZoom).toBe(3);
60
+ });
61
+ });
62
+ describe("FitViewOptions", () => {
63
+ it("should define fit view options", () => {
64
+ const options = {
65
+ padding: 0.3,
66
+ includeHiddenNodes: false,
67
+ minZoom: 0.5,
68
+ maxZoom: 2
69
+ };
70
+ expect(options.padding).toBe(0.3);
71
+ expect(options.includeHiddenNodes).toBe(false);
72
+ });
73
+ });
74
+ describe("ScreenToFlowPositionOptions", () => {
75
+ it("should define screen to flow position options", () => {
76
+ const options = {
77
+ offset: { x: 10, y: 20 },
78
+ snapToGrid: true,
79
+ gridSize: 15
80
+ };
81
+ expect(options.offset?.x).toBe(10);
82
+ expect(options.snapToGrid).toBe(true);
83
+ expect(options.gridSize).toBe(15);
84
+ });
85
+ });
86
+ describe("getViewportForBounds", () => {
87
+ it("should calculate viewport to fit bounds within container", () => {
88
+ const bounds = { x: 0, y: 0, width: 200, height: 200 };
89
+ const viewport = getViewportForBounds(bounds, 800, 600, 0.1, 5, 0.2);
90
+ expect(viewport).toHaveProperty("x");
91
+ expect(viewport).toHaveProperty("y");
92
+ expect(viewport).toHaveProperty("zoom");
93
+ expect(viewport.zoom).toBeGreaterThanOrEqual(0.1);
94
+ expect(viewport.zoom).toBeLessThanOrEqual(5);
95
+ });
96
+ it("should use default padding of 0.2", () => {
97
+ const bounds = { x: 100, y: 100, width: 100, height: 100 };
98
+ const viewport1 = getViewportForBounds(bounds, 400, 300, 0.1, 5);
99
+ const viewport2 = getViewportForBounds(bounds, 400, 300, 0.1, 5, 0.2);
100
+ expect(viewport1.zoom).toBe(viewport2.zoom);
101
+ });
102
+ it("should handle bounds at origin", () => {
103
+ const bounds = { x: 0, y: 0, width: 100, height: 50 };
104
+ const viewport = getViewportForBounds(bounds, 800, 400, 0.1, 5, 0.1);
105
+ expect(viewport.zoom).toBeGreaterThan(0);
106
+ });
107
+ it("should respect minZoom constraint", () => {
108
+ const bounds = { x: 0, y: 0, width: 1e4, height: 1e4 };
109
+ const viewport = getViewportForBounds(bounds, 800, 600, 0.5, 5, 0.2);
110
+ expect(viewport.zoom).toBeGreaterThanOrEqual(0.5);
111
+ });
112
+ it("should respect maxZoom constraint", () => {
113
+ const bounds = { x: 0, y: 0, width: 10, height: 10 };
114
+ const viewport = getViewportForBounds(bounds, 800, 600, 0.1, 2, 0.2);
115
+ expect(viewport.zoom).toBeLessThanOrEqual(2);
116
+ });
117
+ });
118
+ describe("project", () => {
119
+ it("should project screen coordinates to canvas coordinates", () => {
120
+ const transform = { x: 100, y: 50, zoom: 2 };
121
+ const screenPos = { x: 300, y: 250 };
122
+ const canvasPos = project(screenPos, transform);
123
+ expect(canvasPos).toEqual({ x: 100, y: 100 });
124
+ });
125
+ it("should handle zoom of 1", () => {
126
+ const transform = { x: 0, y: 0, zoom: 1 };
127
+ const screenPos = { x: 100, y: 200 };
128
+ const canvasPos = project(screenPos, transform);
129
+ expect(canvasPos).toEqual({ x: 100, y: 200 });
130
+ });
131
+ it("should handle negative viewport offset", () => {
132
+ const transform = { x: -100, y: -50, zoom: 1 };
133
+ const screenPos = { x: 0, y: 0 };
134
+ const canvasPos = project(screenPos, transform);
135
+ expect(canvasPos.x).toBe(100);
136
+ expect(canvasPos.y).toBe(50);
137
+ });
138
+ it("should handle fractional zoom", () => {
139
+ const transform = { x: 0, y: 0, zoom: 0.5 };
140
+ const screenPos = { x: 100, y: 100 };
141
+ const canvasPos = project(screenPos, transform);
142
+ expect(canvasPos.x).toBe(200);
143
+ expect(canvasPos.y).toBe(200);
144
+ });
145
+ });
146
+ describe("unproject", () => {
147
+ it("should unproject canvas coordinates to screen coordinates", () => {
148
+ const transform = { x: 100, y: 50, zoom: 2 };
149
+ const canvasPos = { x: 100, y: 100 };
150
+ const screenPos = unproject(canvasPos, transform);
151
+ expect(screenPos).toEqual({ x: 300, y: 250 });
152
+ });
153
+ it("should be inverse of project", () => {
154
+ const transform = { x: 100, y: 50, zoom: 2 };
155
+ const originalScreen = { x: 500, y: 300 };
156
+ const canvas = project(originalScreen, transform);
157
+ const restored = unproject(canvas, transform);
158
+ expect(restored).toEqual(originalScreen);
159
+ });
160
+ });
161
+ describe("isNodeVisible", () => {
162
+ const transform = { x: 0, y: 0, zoom: 1 };
163
+ const viewportWidth = 800;
164
+ const viewportHeight = 600;
165
+ it("should return true for node within viewport", () => {
166
+ const node = {
167
+ position: { x: 100, y: 100 },
168
+ width: 100,
169
+ height: 100
170
+ };
171
+ expect(isNodeVisible(node, transform, viewportWidth, viewportHeight)).toBe(true);
172
+ });
173
+ it("should return true for node at viewport edge", () => {
174
+ const node = {
175
+ position: { x: 0, y: 0 },
176
+ width: 100,
177
+ height: 100
178
+ };
179
+ expect(isNodeVisible(node, transform, viewportWidth, viewportHeight)).toBe(true);
180
+ });
181
+ it("should return false for node completely outside viewport", () => {
182
+ const node = {
183
+ position: { x: 2e3, y: 2e3 },
184
+ width: 100,
185
+ height: 100
186
+ };
187
+ expect(isNodeVisible(node, transform, viewportWidth, viewportHeight)).toBe(false);
188
+ });
189
+ it("should return true for node with zero dimensions", () => {
190
+ const node = {
191
+ position: { x: 100, y: 100 },
192
+ width: 0,
193
+ height: 0
194
+ };
195
+ expect(isNodeVisible(node, transform, viewportWidth, viewportHeight)).toBe(true);
196
+ });
197
+ it("should handle zoomed viewport", () => {
198
+ const zoomedTransform = { x: 0, y: 0, zoom: 2 };
199
+ const node = {
200
+ position: { x: 100, y: 100 },
201
+ width: 100,
202
+ height: 100
203
+ };
204
+ expect(isNodeVisible(node, zoomedTransform, viewportWidth, viewportHeight)).toBe(true);
205
+ });
206
+ });
207
+ });
@@ -10,6 +10,23 @@ exports.validateBpmnXml = validateBpmnXml;
10
10
  const BPMN_NS = "http://www.omg.org/spec/BPMN/20100524/MODEL";
11
11
  const BPMN_DI_NS = "http://www.omg.org/spec/BPMN/20100524/DI";
12
12
  const BPMN_DC_NS = "http://www.omg.org/spec/BPMN/20100524/DC";
13
+ function firstByLocalNS(doc, ns, localName) {
14
+ const all = allByLocalNS(doc, ns, localName);
15
+ return all.length > 0 ? all[0] : null;
16
+ }
17
+ function allByLocalNS(root, ns, localName) {
18
+ const fromNs = root.getElementsByTagNameNS(ns, localName);
19
+ if (fromNs.length > 0) return Array.from(fromNs);
20
+ const out = [];
21
+ const all = root.getElementsByTagName("*");
22
+ for (let i = 0; i < all.length; i++) {
23
+ const el = all[i];
24
+ if (el.localName === localName && el.namespaceURI === ns) {
25
+ out.push(el);
26
+ }
27
+ }
28
+ return out;
29
+ }
13
30
  const NODE_TYPE_TO_BPMN = {
14
31
  "bpmn-start": "startEvent",
15
32
  "bpmn-end": "endEvent",
@@ -169,14 +186,14 @@ function bpmnXmlToFlow(xml, options = {}) {
169
186
  if (parseError) {
170
187
  throw new Error(`BPMN XML \u89E3\u6790\u5931\u8D25: ${parseError.textContent}`);
171
188
  }
172
- const process = doc.querySelector("bpmn\\:process, process");
189
+ const process = firstByLocalNS(doc, BPMN_NS, "process");
173
190
  const processId = process?.getAttribute("id") || "";
174
191
  const processName = process?.getAttribute("name") || "";
175
192
  const diShapes = /* @__PURE__ */new Map();
176
- const bpmnShapes = Array.from(doc.querySelectorAll("bpmndi\\:BPMNShape, BPMNShape"));
193
+ const bpmnShapes = allByLocalNS(doc, BPMN_DI_NS, "BPMNShape");
177
194
  for (const shape of bpmnShapes) {
178
195
  const bpmnElement = shape.getAttribute("bpmnElement");
179
- const bounds = shape.querySelector("dc\\:Bounds, Bounds");
196
+ const bounds = firstByLocalNS(shape, BPMN_DC_NS, "Bounds");
180
197
  if (bpmnElement && bounds) {
181
198
  diShapes.set(bpmnElement, {
182
199
  x: parseFloat(bounds.getAttribute("x") || "0"),
@@ -189,15 +206,9 @@ function bpmnXmlToFlow(xml, options = {}) {
189
206
  const findBpmnElements = root => {
190
207
  const tags = ["startEvent", "endEvent", "task", "serviceTask", "userTask", "exclusiveGateway", "parallelGateway", "inclusiveGateway"];
191
208
  const elements = [];
192
- tags.forEach(tag => {
193
- const perTagElements = [];
194
- perTagElements.push(...Array.from(root.getElementsByTagNameNS(BPMN_NS, tag)));
195
- perTagElements.push(...Array.from(root.getElementsByTagName(tag)).filter(el => !el.prefix));
196
- if (perTagElements.length === 0) {
197
- perTagElements.push(...Array.from(root.querySelectorAll(`[localName="${tag}"]`)));
198
- }
199
- elements.push(...perTagElements);
200
- });
209
+ for (const tag of tags) {
210
+ elements.push(...allByLocalNS(root, BPMN_NS, tag));
211
+ }
201
212
  return elements;
202
213
  };
203
214
  const bpmnElements = findBpmnElements(doc);
@@ -249,13 +260,13 @@ function bpmnXmlToFlow(xml, options = {}) {
249
260
  });
250
261
  maxY += nodeSpacing;
251
262
  }
252
- const sequenceFlows = [...Array.from(doc.getElementsByTagNameNS(BPMN_NS, "sequenceFlow")), ...Array.from(doc.getElementsByTagName("sequenceFlow")).filter(el => !el.prefix)];
263
+ const sequenceFlows = allByLocalNS(doc, BPMN_NS, "sequenceFlow");
253
264
  for (const flow of sequenceFlows) {
254
265
  const id = flow.getAttribute("id");
255
266
  const sourceRef = flow.getAttribute("sourceRef");
256
267
  const targetRef = flow.getAttribute("targetRef");
257
268
  if (!id || !sourceRef || !targetRef) continue;
258
- const conditionExpr = flow.querySelector("bpmn\\:conditionExpression, conditionExpression");
269
+ const conditionExpr = firstByLocalNS(flow, BPMN_NS, "conditionExpression");
259
270
  const conditionText = conditionExpr?.textContent?.trim();
260
271
  const sourceNode = nodeMap.get(sourceRef);
261
272
  if (sourceNode) {
@@ -361,14 +372,14 @@ function validateBpmnXml(xml) {
361
372
  error: "XML \u683C\u5F0F\u9519\u8BEF"
362
373
  };
363
374
  }
364
- const definitions = doc.querySelector("bpmn\\:definitions, definitions");
375
+ const definitions = firstByLocalNS(doc, BPMN_NS, "definitions");
365
376
  if (!definitions) {
366
377
  return {
367
378
  valid: false,
368
379
  error: "\u7F3A\u5C11 BPMN definitions \u6839\u5143\u7D20"
369
380
  };
370
381
  }
371
- const process = doc.querySelector("bpmn\\:process, process");
382
+ const process = firstByLocalNS(doc, BPMN_NS, "process");
372
383
  if (!process) {
373
384
  return {
374
385
  valid: false,
@@ -1,6 +1,23 @@
1
1
  const BPMN_NS = "http://www.omg.org/spec/BPMN/20100524/MODEL";
2
2
  const BPMN_DI_NS = "http://www.omg.org/spec/BPMN/20100524/DI";
3
3
  const BPMN_DC_NS = "http://www.omg.org/spec/BPMN/20100524/DC";
4
+ function firstByLocalNS(doc, ns, localName) {
5
+ const all = allByLocalNS(doc, ns, localName);
6
+ return all.length > 0 ? all[0] : null;
7
+ }
8
+ function allByLocalNS(root, ns, localName) {
9
+ const fromNs = root.getElementsByTagNameNS(ns, localName);
10
+ if (fromNs.length > 0) return Array.from(fromNs);
11
+ const out = [];
12
+ const all = root.getElementsByTagName("*");
13
+ for (let i = 0; i < all.length; i++) {
14
+ const el = all[i];
15
+ if (el.localName === localName && el.namespaceURI === ns) {
16
+ out.push(el);
17
+ }
18
+ }
19
+ return out;
20
+ }
4
21
  const NODE_TYPE_TO_BPMN = {
5
22
  "bpmn-start": "startEvent",
6
23
  "bpmn-end": "endEvent",
@@ -150,14 +167,14 @@ export function bpmnXmlToFlow(xml, options = {}) {
150
167
  if (parseError) {
151
168
  throw new Error(`BPMN XML \u89E3\u6790\u5931\u8D25: ${parseError.textContent}`);
152
169
  }
153
- const process = doc.querySelector("bpmn\\:process, process");
170
+ const process = firstByLocalNS(doc, BPMN_NS, "process");
154
171
  const processId = process?.getAttribute("id") || "";
155
172
  const processName = process?.getAttribute("name") || "";
156
173
  const diShapes = /* @__PURE__ */ new Map();
157
- const bpmnShapes = Array.from(doc.querySelectorAll("bpmndi\\:BPMNShape, BPMNShape"));
174
+ const bpmnShapes = allByLocalNS(doc, BPMN_DI_NS, "BPMNShape");
158
175
  for (const shape of bpmnShapes) {
159
176
  const bpmnElement = shape.getAttribute("bpmnElement");
160
- const bounds = shape.querySelector("dc\\:Bounds, Bounds");
177
+ const bounds = firstByLocalNS(shape, BPMN_DC_NS, "Bounds");
161
178
  if (bpmnElement && bounds) {
162
179
  diShapes.set(bpmnElement, {
163
180
  x: parseFloat(bounds.getAttribute("x") || "0"),
@@ -179,15 +196,9 @@ export function bpmnXmlToFlow(xml, options = {}) {
179
196
  "inclusiveGateway"
180
197
  ];
181
198
  const elements = [];
182
- tags.forEach((tag) => {
183
- const perTagElements = [];
184
- perTagElements.push(...Array.from(root.getElementsByTagNameNS(BPMN_NS, tag)));
185
- perTagElements.push(...Array.from(root.getElementsByTagName(tag)).filter((el) => !el.prefix));
186
- if (perTagElements.length === 0) {
187
- perTagElements.push(...Array.from(root.querySelectorAll(`[localName="${tag}"]`)));
188
- }
189
- elements.push(...perTagElements);
190
- });
199
+ for (const tag of tags) {
200
+ elements.push(...allByLocalNS(root, BPMN_NS, tag));
201
+ }
191
202
  return elements;
192
203
  };
193
204
  const bpmnElements = findBpmnElements(doc);
@@ -231,16 +242,13 @@ export function bpmnXmlToFlow(xml, options = {}) {
231
242
  });
232
243
  maxY += nodeSpacing;
233
244
  }
234
- const sequenceFlows = [
235
- ...Array.from(doc.getElementsByTagNameNS(BPMN_NS, "sequenceFlow")),
236
- ...Array.from(doc.getElementsByTagName("sequenceFlow")).filter((el) => !el.prefix)
237
- ];
245
+ const sequenceFlows = allByLocalNS(doc, BPMN_NS, "sequenceFlow");
238
246
  for (const flow of sequenceFlows) {
239
247
  const id = flow.getAttribute("id");
240
248
  const sourceRef = flow.getAttribute("sourceRef");
241
249
  const targetRef = flow.getAttribute("targetRef");
242
250
  if (!id || !sourceRef || !targetRef) continue;
243
- const conditionExpr = flow.querySelector("bpmn\\:conditionExpression, conditionExpression");
251
+ const conditionExpr = firstByLocalNS(flow, BPMN_NS, "conditionExpression");
244
252
  const conditionText = conditionExpr?.textContent?.trim();
245
253
  const sourceNode = nodeMap.get(sourceRef);
246
254
  if (sourceNode) {
@@ -333,11 +341,11 @@ export function validateBpmnXml(xml) {
333
341
  if (parseError) {
334
342
  return { valid: false, error: "XML \u683C\u5F0F\u9519\u8BEF" };
335
343
  }
336
- const definitions = doc.querySelector("bpmn\\:definitions, definitions");
344
+ const definitions = firstByLocalNS(doc, BPMN_NS, "definitions");
337
345
  if (!definitions) {
338
346
  return { valid: false, error: "\u7F3A\u5C11 BPMN definitions \u6839\u5143\u7D20" };
339
347
  }
340
- const process = doc.querySelector("bpmn\\:process, process");
348
+ const process = firstByLocalNS(doc, BPMN_NS, "process");
341
349
  if (!process) {
342
350
  return { valid: false, error: "\u7F3A\u5C11 BPMN process \u5143\u7D20" };
343
351
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yh-ui/flow",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
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": "^1.0.1",
27
- "@yh-ui/hooks": "^1.0.1"
26
+ "@yh-ui/utils": "^1.0.4",
27
+ "@yh-ui/hooks": "^1.0.4"
28
28
  },
29
29
  "devDependencies": {
30
30
  "vue": "^3.5.27",