@bpmnkit/core 0.1.2 → 0.3.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.
Files changed (63) hide show
  1. package/README.md +30 -1
  2. package/dist/bpmn/bpmn-builder.d.ts +209 -3
  3. package/dist/bpmn/bpmn-builder.js +456 -16
  4. package/dist/bpmn/bpmn-model.d.ts +110 -0
  5. package/dist/bpmn/bpmn-parser.js +1413 -528
  6. package/dist/bpmn/bpmn-serializer.js +171 -19
  7. package/dist/bpmn/compact.d.ts +17 -2
  8. package/dist/bpmn/compact.js +3 -3
  9. package/dist/bpmn/diagram-diff.d.ts +71 -0
  10. package/dist/bpmn/diagram-diff.js +124 -0
  11. package/dist/bpmn/full-operations.d.ts +89 -0
  12. package/dist/bpmn/full-operations.js +478 -0
  13. package/dist/bpmn/index.d.ts +19 -0
  14. package/dist/bpmn/index.js +21 -0
  15. package/dist/bpmn/lint.d.ts +97 -0
  16. package/dist/bpmn/lint.js +135 -0
  17. package/dist/bpmn/optimize/feel.js +2 -2
  18. package/dist/bpmn/optimize/patterns.js +23 -16
  19. package/dist/bpmn/optimize/tasks.js +30 -7
  20. package/dist/bpmn/optimize/utils.js +2 -4
  21. package/dist/bpmn/optimize/variable-flow.js +58 -67
  22. package/dist/bpmn/preserving-writer.d.ts +64 -0
  23. package/dist/bpmn/preserving-writer.js +70 -0
  24. package/dist/bpmn/semantic-hash.d.ts +93 -0
  25. package/dist/bpmn/semantic-hash.js +155 -0
  26. package/dist/bpmn/sha256.d.ts +17 -0
  27. package/dist/bpmn/sha256.js +95 -0
  28. package/dist/bpmn/zeebe-extensions.d.ts +56 -0
  29. package/dist/bpmn/zeebe-extensions.js +79 -0
  30. package/dist/bpmn/zeebe-placement.d.ts +12 -0
  31. package/dist/bpmn/zeebe-placement.js +140 -0
  32. package/dist/dmn/dmn-serializer.js +7 -2
  33. package/dist/dmn/preserving-writer.d.ts +31 -0
  34. package/dist/dmn/preserving-writer.js +36 -0
  35. package/dist/errors.d.ts +40 -1
  36. package/dist/errors.js +41 -0
  37. package/dist/form/preserving-writer.d.ts +47 -0
  38. package/dist/form/preserving-writer.js +50 -0
  39. package/dist/index.d.ts +22 -5
  40. package/dist/index.js +14 -4
  41. package/dist/json/index.d.ts +5 -0
  42. package/dist/json/index.js +3 -0
  43. package/dist/json/json-patch.d.ts +65 -0
  44. package/dist/json/json-patch.js +416 -0
  45. package/dist/json/json-spans.d.ts +48 -0
  46. package/dist/json/json-spans.js +153 -0
  47. package/dist/layout/semantic/graph.d.ts +9 -1
  48. package/dist/layout/semantic/graph.js +42 -17
  49. package/dist/layout/semantic/route.js +102 -42
  50. package/dist/node/index.d.ts +10 -0
  51. package/dist/node/index.js +9 -0
  52. package/dist/node/write.d.ts +81 -0
  53. package/dist/node/write.js +167 -0
  54. package/dist/types/id-generator.js +11 -3
  55. package/dist/xml/index.d.ts +7 -1
  56. package/dist/xml/index.js +4 -1
  57. package/dist/xml/xml-parser.d.ts +71 -0
  58. package/dist/xml/xml-parser.js +437 -145
  59. package/dist/xml/xml-patch.d.ts +109 -0
  60. package/dist/xml/xml-patch.js +459 -0
  61. package/dist/xml/xml-spans.d.ts +45 -0
  62. package/dist/xml/xml-spans.js +74 -0
  63. package/package.json +8 -1
@@ -1,4 +1,71 @@
1
1
  import type { XmlElement } from "../types/xml-element.js";
2
+ /** What a sink wants the scanner to do with an element after its start tag. */
3
+ export declare const Visit: {
4
+ /** Report child elements and character data. */
5
+ readonly All: 0;
6
+ /**
7
+ * Skip the element's content: the scanner fast-forwards past the matching
8
+ * end tag without building attributes or decoding text for anything inside,
9
+ * and `end` is not called for it.
10
+ */
11
+ readonly Skip: 1;
12
+ /** Report child elements but drop character data without decoding it. */
13
+ readonly ElementsOnly: 2;
14
+ };
15
+ export type Visit = (typeof Visit)[keyof typeof Visit];
16
+ /**
17
+ * Where the tag currently being reported sits in the source.
18
+ *
19
+ * A sink that wants source positions asks for them once, by implementing
20
+ * {@link XmlSink.cursor}; the scanner then records offsets as it goes. Sinks
21
+ * that do not ask pay nothing — recording attribute spans in particular costs
22
+ * a map write per attribute, and parsing is the hottest path in this toolkit.
23
+ *
24
+ * The values are only meaningful inside the `start` or `end` call they were
25
+ * reported for; the scanner overwrites them on the next tag.
26
+ */
27
+ export interface XmlCursor {
28
+ /** Offset of the `<` opening the start tag reported by `start`. */
29
+ readonly tagStart: number;
30
+ /** Offset just past the `>` closing that start tag. */
31
+ readonly tagEnd: number;
32
+ /** Offset of the `<` opening the end tag reported by `end`. */
33
+ readonly endTagStart: number;
34
+ /** Offset just past the `>` closing that end tag. */
35
+ readonly endTagEnd: number;
36
+ /**
37
+ * Where an attribute's value sits, between its quotes and excluding them.
38
+ * Only valid during the `start` call that reported the attribute.
39
+ */
40
+ attributeSpan(name: string): {
41
+ readonly start: number;
42
+ readonly end: number;
43
+ } | undefined;
44
+ }
45
+ /** Receives the events of one XML document from {@link scanXml}. */
46
+ export interface XmlSink {
47
+ /**
48
+ * Called once before scanning, when implemented, to hand the sink a cursor
49
+ * onto the source. Implementing it switches the scanner into recording
50
+ * source offsets; leaving it out is the fast path.
51
+ */
52
+ cursor?(cursor: XmlCursor): void;
53
+ /**
54
+ * @param name qualified name, e.g. "bpmn:task"
55
+ * @param local name without its prefix, e.g. "task" (same string as `name` when unprefixed)
56
+ * @param selfClosing true for `<a/>`; `end` follows immediately
57
+ */
58
+ start(name: string, local: string, attributes: Record<string, string>, selfClosing: boolean): Visit;
59
+ /** Character data or CDATA directly inside the current element, entities decoded. */
60
+ text(text: string): void;
61
+ end(name: string): void;
62
+ }
63
+ /**
64
+ * Scan an XML document, reporting the root element and everything inside it to
65
+ * `sink`. Returns false when the document has no root element. Content after
66
+ * the root element is ignored.
67
+ */
68
+ export declare function scanXml(xml: string, sink: XmlSink): boolean;
2
69
  /**
3
70
  * Parse an XML string into an XmlElement tree.
4
71
  * Returns the root element with all namespace prefixes preserved.
@@ -10,4 +77,8 @@ export declare function parseXml(xml: string): XmlElement;
10
77
  * Produces a well-formed XML document with declaration.
11
78
  */
12
79
  export declare function serializeXml(element: XmlElement): string;
80
+ /** Escapes a value for use between attribute quotes. */
81
+ export declare function escapeAttr(value: string): string;
82
+ /** Escapes a value for use as character data. */
83
+ export declare function escapeText(value: string): string;
13
84
  //# sourceMappingURL=xml-parser.d.ts.map