@bpmnkit/plugins 0.0.8

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 (140) hide show
  1. package/README.md +153 -0
  2. package/dist/ai-bridge/css.d.ts +2 -0
  3. package/dist/ai-bridge/css.js +366 -0
  4. package/dist/ai-bridge/index.d.ts +44 -0
  5. package/dist/ai-bridge/index.js +132 -0
  6. package/dist/ai-bridge/panel.d.ts +27 -0
  7. package/dist/ai-bridge/panel.js +715 -0
  8. package/dist/ascii-view/css.d.ts +4 -0
  9. package/dist/ascii-view/css.js +83 -0
  10. package/dist/ascii-view/index.d.ts +25 -0
  11. package/dist/ascii-view/index.js +92 -0
  12. package/dist/command-palette/css.d.ts +4 -0
  13. package/dist/command-palette/css.js +157 -0
  14. package/dist/command-palette/index.d.ts +53 -0
  15. package/dist/command-palette/index.js +378 -0
  16. package/dist/command-palette-editor/index.d.ts +35 -0
  17. package/dist/command-palette-editor/index.js +60 -0
  18. package/dist/config-panel/css.d.ts +4 -0
  19. package/dist/config-panel/css.js +719 -0
  20. package/dist/config-panel/index.d.ts +36 -0
  21. package/dist/config-panel/index.js +73 -0
  22. package/dist/config-panel/renderer.d.ts +127 -0
  23. package/dist/config-panel/renderer.js +1162 -0
  24. package/dist/config-panel/types.d.ts +118 -0
  25. package/dist/config-panel/types.js +2 -0
  26. package/dist/config-panel-bpmn/index.d.ts +58 -0
  27. package/dist/config-panel-bpmn/index.js +1320 -0
  28. package/dist/config-panel-bpmn/template-engine.d.ts +17 -0
  29. package/dist/config-panel-bpmn/template-engine.js +307 -0
  30. package/dist/config-panel-bpmn/template-to-service-task.d.ts +30 -0
  31. package/dist/config-panel-bpmn/template-to-service-task.js +92 -0
  32. package/dist/config-panel-bpmn/template-types.d.ts +126 -0
  33. package/dist/config-panel-bpmn/template-types.js +6 -0
  34. package/dist/config-panel-bpmn/templates/generated.d.ts +3 -0
  35. package/dist/config-panel-bpmn/templates/generated.js +57865 -0
  36. package/dist/config-panel-bpmn/util.d.ts +46 -0
  37. package/dist/config-panel-bpmn/util.js +195 -0
  38. package/dist/dmn-editor/css.d.ts +3 -0
  39. package/dist/dmn-editor/css.js +667 -0
  40. package/dist/dmn-editor/dmn-editor.d.ts +34 -0
  41. package/dist/dmn-editor/dmn-editor.js +646 -0
  42. package/dist/dmn-editor/drd-canvas.d.ts +85 -0
  43. package/dist/dmn-editor/drd-canvas.js +1087 -0
  44. package/dist/dmn-editor/index.d.ts +3 -0
  45. package/dist/dmn-editor/index.js +2 -0
  46. package/dist/dmn-viewer/css.d.ts +3 -0
  47. package/dist/dmn-viewer/css.js +151 -0
  48. package/dist/dmn-viewer/dmn-viewer.d.ts +30 -0
  49. package/dist/dmn-viewer/dmn-viewer.js +160 -0
  50. package/dist/dmn-viewer/feel.d.ts +3 -0
  51. package/dist/dmn-viewer/feel.js +2 -0
  52. package/dist/dmn-viewer/index.d.ts +14 -0
  53. package/dist/dmn-viewer/index.js +12 -0
  54. package/dist/element-docs/content.d.ts +20 -0
  55. package/dist/element-docs/content.js +1032 -0
  56. package/dist/element-docs/index.d.ts +7 -0
  57. package/dist/element-docs/index.js +643 -0
  58. package/dist/feel-playground/css.d.ts +4 -0
  59. package/dist/feel-playground/css.js +292 -0
  60. package/dist/feel-playground/index.d.ts +4 -0
  61. package/dist/feel-playground/index.js +3 -0
  62. package/dist/feel-playground/playground-plugin.d.ts +14 -0
  63. package/dist/feel-playground/playground-plugin.js +292 -0
  64. package/dist/form-editor/css.d.ts +3 -0
  65. package/dist/form-editor/css.js +703 -0
  66. package/dist/form-editor/form-editor.d.ts +48 -0
  67. package/dist/form-editor/form-editor.js +1039 -0
  68. package/dist/form-editor/index.d.ts +3 -0
  69. package/dist/form-editor/index.js +2 -0
  70. package/dist/form-viewer/css.d.ts +3 -0
  71. package/dist/form-viewer/css.js +303 -0
  72. package/dist/form-viewer/form-viewer.d.ts +29 -0
  73. package/dist/form-viewer/form-viewer.js +376 -0
  74. package/dist/form-viewer/index.d.ts +12 -0
  75. package/dist/form-viewer/index.js +11 -0
  76. package/dist/history/checkpoint.d.ts +10 -0
  77. package/dist/history/checkpoint.js +92 -0
  78. package/dist/history/css.d.ts +2 -0
  79. package/dist/history/css.js +130 -0
  80. package/dist/history/history-panel.d.ts +12 -0
  81. package/dist/history/history-panel.js +142 -0
  82. package/dist/history/index.d.ts +5 -0
  83. package/dist/history/index.js +3 -0
  84. package/dist/main-menu/css.d.ts +4 -0
  85. package/dist/main-menu/css.js +272 -0
  86. package/dist/main-menu/index.d.ts +59 -0
  87. package/dist/main-menu/index.js +285 -0
  88. package/dist/minimap/css.d.ts +10 -0
  89. package/dist/minimap/css.js +54 -0
  90. package/dist/minimap/index.d.ts +38 -0
  91. package/dist/minimap/index.js +69 -0
  92. package/dist/minimap/minimap.d.ts +35 -0
  93. package/dist/minimap/minimap.js +166 -0
  94. package/dist/optimize/index.d.ts +21 -0
  95. package/dist/optimize/index.js +304 -0
  96. package/dist/process-runner/css.d.ts +2 -0
  97. package/dist/process-runner/css.js +467 -0
  98. package/dist/process-runner/index.d.ts +56 -0
  99. package/dist/process-runner/index.js +549 -0
  100. package/dist/storage/auto-save.d.ts +11 -0
  101. package/dist/storage/auto-save.js +44 -0
  102. package/dist/storage/css.d.ts +2 -0
  103. package/dist/storage/css.js +2 -0
  104. package/dist/storage/db.d.ts +99 -0
  105. package/dist/storage/db.js +116 -0
  106. package/dist/storage/dialog.d.ts +15 -0
  107. package/dist/storage/dialog.js +201 -0
  108. package/dist/storage/export.d.ts +3 -0
  109. package/dist/storage/export.js +137 -0
  110. package/dist/storage/index.d.ts +44 -0
  111. package/dist/storage/index.js +201 -0
  112. package/dist/storage/sidebar.d.ts +2 -0
  113. package/dist/storage/sidebar.js +2 -0
  114. package/dist/storage/storage-api.d.ts +76 -0
  115. package/dist/storage/storage-api.js +342 -0
  116. package/dist/storage/types.d.ts +44 -0
  117. package/dist/storage/types.js +2 -0
  118. package/dist/storage-tabs-bridge/index.d.ts +96 -0
  119. package/dist/storage-tabs-bridge/index.js +502 -0
  120. package/dist/tabs/css.d.ts +3 -0
  121. package/dist/tabs/css.js +642 -0
  122. package/dist/tabs/file-resolver.d.ts +71 -0
  123. package/dist/tabs/file-resolver.js +46 -0
  124. package/dist/tabs/index.d.ts +15 -0
  125. package/dist/tabs/index.js +13 -0
  126. package/dist/tabs/tabs-plugin.d.ts +250 -0
  127. package/dist/tabs/tabs-plugin.js +1119 -0
  128. package/dist/token-highlight/css.d.ts +2 -0
  129. package/dist/token-highlight/css.js +81 -0
  130. package/dist/token-highlight/index.d.ts +44 -0
  131. package/dist/token-highlight/index.js +164 -0
  132. package/dist/watermark/css.d.ts +10 -0
  133. package/dist/watermark/css.js +54 -0
  134. package/dist/watermark/index.d.ts +48 -0
  135. package/dist/watermark/index.js +64 -0
  136. package/dist/zoom-controls/css.d.ts +4 -0
  137. package/dist/zoom-controls/css.js +48 -0
  138. package/dist/zoom-controls/index.d.ts +36 -0
  139. package/dist/zoom-controls/index.js +111 -0
  140. package/package.json +121 -0
@@ -0,0 +1,132 @@
1
+ import { DEFAULT_SERVER, createAiPanel } from "./panel.js";
2
+ function searchContainer(container, id) {
3
+ for (const el of container.flowElements) {
4
+ if (el.id === id)
5
+ return { id: el.id, type: el.type, name: el.name };
6
+ if (el.flowElements) {
7
+ const nested = searchContainer(el, id);
8
+ if (nested)
9
+ return nested;
10
+ }
11
+ }
12
+ for (const sf of container.sequenceFlows) {
13
+ if (sf.id === id)
14
+ return { id: sf.id, type: "sequenceFlow", name: sf.name };
15
+ }
16
+ for (const ann of container.textAnnotations) {
17
+ if (ann.id === id)
18
+ return { id: ann.id, type: "textAnnotation", name: ann.text };
19
+ }
20
+ return null;
21
+ }
22
+ function findElementById(defs, id) {
23
+ if (!defs)
24
+ return null;
25
+ for (const proc of defs.processes) {
26
+ const found = searchContainer(proc, id);
27
+ if (found)
28
+ return found;
29
+ }
30
+ return null;
31
+ }
32
+ const AI_ICON = `<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="8" r="6"/><path d="M5.5 6.5C5.5 5.4 6.4 4.5 7.5 4.5h1C9.6 4.5 10.5 5.4 10.5 6.5S9.6 8.5 8.5 8.5H8V10"/><circle cx="8" cy="12" r="0.5" fill="currentColor" stroke="none"/></svg>`;
33
+ /**
34
+ * Creates an AI bridge plugin that provides a chat panel for AI-assisted
35
+ * BPMN diagram creation and modification.
36
+ *
37
+ * The returned `button` should be passed to `initEditorHud` as `aiButton`.
38
+ * The panel is injected into `document.body` on first open.
39
+ */
40
+ export function createAiBridgePlugin(options) {
41
+ const serverUrl = options.serverUrl ?? DEFAULT_SERVER;
42
+ let panelInstance = null;
43
+ let panelOpen = false;
44
+ let _pendingContext = null;
45
+ let _canvasApi = null;
46
+ function getOrCreatePanel() {
47
+ if (!panelInstance) {
48
+ panelInstance = createAiPanel({
49
+ serverUrl,
50
+ getDefinitions: options.getDefinitions,
51
+ loadXml: options.loadXml,
52
+ getCurrentContext: options.getCurrentContext,
53
+ createCompanionFile: options.createCompanionFile,
54
+ getTheme: options.getTheme
55
+ ? options.getTheme
56
+ : _canvasApi
57
+ ? () => {
58
+ const t = _canvasApi?.getTheme();
59
+ return t === "light" ? "light" : "dark";
60
+ }
61
+ : undefined,
62
+ });
63
+ if (_pendingContext !== null) {
64
+ panelInstance.setContext(_pendingContext);
65
+ }
66
+ if (options.container) {
67
+ panelInstance.panel.classList.add("ai-panel--docked");
68
+ options.container.append(panelInstance.panel);
69
+ }
70
+ else {
71
+ document.body.append(panelInstance.panel);
72
+ }
73
+ }
74
+ return panelInstance;
75
+ }
76
+ const button = document.createElement("button");
77
+ button.title = "AI Assistant";
78
+ button.innerHTML = AI_ICON;
79
+ button.addEventListener("click", () => {
80
+ const p = getOrCreatePanel();
81
+ if (options.container) {
82
+ options.onOpen?.();
83
+ p.open();
84
+ }
85
+ else if (panelOpen) {
86
+ p.close();
87
+ panelOpen = false;
88
+ }
89
+ else {
90
+ p.open();
91
+ panelOpen = true;
92
+ }
93
+ });
94
+ function openPanel() {
95
+ const p = getOrCreatePanel();
96
+ if (options.container) {
97
+ options.onOpen?.();
98
+ p.open();
99
+ }
100
+ else {
101
+ p.open();
102
+ panelOpen = true;
103
+ }
104
+ }
105
+ function setContext(node) {
106
+ _pendingContext = node;
107
+ panelInstance?.setContext(node);
108
+ }
109
+ function install(api) {
110
+ _canvasApi = api;
111
+ const on = api.on.bind(api);
112
+ on("editor:select", (rawIds) => {
113
+ const ids = rawIds;
114
+ if (ids.length !== 1) {
115
+ setContext(null);
116
+ return;
117
+ }
118
+ const id = ids[0];
119
+ if (!id)
120
+ return;
121
+ setContext(findElementById(options.getDefinitions(), id));
122
+ });
123
+ }
124
+ return {
125
+ name: "ai-bridge",
126
+ install,
127
+ button,
128
+ openPanel,
129
+ setContext,
130
+ };
131
+ }
132
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,27 @@
1
+ import type { BpmnDefinitions } from "@bpmnkit/core";
2
+ declare const DEFAULT_SERVER = "http://localhost:3033";
3
+ export interface NodeContext {
4
+ id: string;
5
+ type: string;
6
+ name?: string;
7
+ }
8
+ interface PanelOptions {
9
+ serverUrl: string;
10
+ getDefinitions(): BpmnDefinitions | null;
11
+ loadXml(xml: string): void;
12
+ getCurrentContext?(): {
13
+ projectId: string;
14
+ fileId: string;
15
+ } | null;
16
+ getTheme?(): "dark" | "light";
17
+ /** Called when the user requests creation of a companion DMN or Form file. */
18
+ createCompanionFile?(name: string, type: "dmn" | "form", content: string): Promise<void>;
19
+ }
20
+ export declare function createAiPanel(options: PanelOptions): {
21
+ panel: HTMLElement;
22
+ open(): void;
23
+ close(): void;
24
+ setContext(node: NodeContext | null): void;
25
+ };
26
+ export { DEFAULT_SERVER };
27
+ //# sourceMappingURL=panel.d.ts.map