@d34dman/flowdrop 0.0.30 → 0.0.32

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 (53) hide show
  1. package/dist/components/App.svelte +54 -6
  2. package/dist/components/NodeSidebar.svelte +1 -1
  3. package/dist/components/SchemaForm.svelte +14 -14
  4. package/dist/components/SchemaForm.svelte.d.ts +1 -1
  5. package/dist/components/form/FormFieldLight.svelte +66 -66
  6. package/dist/components/form/FormFieldLight.svelte.d.ts +1 -1
  7. package/dist/components/form/types.d.ts +1 -1
  8. package/dist/components/playground/ChatPanel.svelte +523 -0
  9. package/dist/components/playground/ChatPanel.svelte.d.ts +20 -0
  10. package/dist/components/playground/ExecutionLogs.svelte +486 -0
  11. package/dist/components/playground/ExecutionLogs.svelte.d.ts +14 -0
  12. package/dist/components/playground/InputCollector.svelte +444 -0
  13. package/dist/components/playground/InputCollector.svelte.d.ts +16 -0
  14. package/dist/components/playground/MessageBubble.svelte +398 -0
  15. package/dist/components/playground/MessageBubble.svelte.d.ts +15 -0
  16. package/dist/components/playground/Playground.svelte +861 -0
  17. package/dist/components/playground/Playground.svelte.d.ts +25 -0
  18. package/dist/components/playground/PlaygroundModal.svelte +220 -0
  19. package/dist/components/playground/PlaygroundModal.svelte.d.ts +25 -0
  20. package/dist/components/playground/SessionManager.svelte +537 -0
  21. package/dist/components/playground/SessionManager.svelte.d.ts +20 -0
  22. package/dist/config/endpoints.d.ts +16 -0
  23. package/dist/config/endpoints.js +9 -0
  24. package/dist/core/index.d.ts +25 -23
  25. package/dist/core/index.js +13 -12
  26. package/dist/display/index.d.ts +2 -2
  27. package/dist/display/index.js +2 -2
  28. package/dist/editor/index.d.ts +58 -49
  29. package/dist/editor/index.js +53 -42
  30. package/dist/form/code.d.ts +4 -4
  31. package/dist/form/code.js +11 -11
  32. package/dist/form/fieldRegistry.d.ts +2 -2
  33. package/dist/form/fieldRegistry.js +8 -10
  34. package/dist/form/full.d.ts +5 -5
  35. package/dist/form/full.js +7 -7
  36. package/dist/form/index.d.ts +16 -16
  37. package/dist/form/index.js +14 -14
  38. package/dist/form/markdown.d.ts +3 -3
  39. package/dist/form/markdown.js +6 -6
  40. package/dist/index.d.ts +6 -4
  41. package/dist/index.js +9 -4
  42. package/dist/playground/index.d.ts +125 -0
  43. package/dist/playground/index.js +147 -0
  44. package/dist/playground/mount.d.ts +184 -0
  45. package/dist/playground/mount.js +209 -0
  46. package/dist/services/playgroundService.d.ts +129 -0
  47. package/dist/services/playgroundService.js +317 -0
  48. package/dist/stores/playgroundStore.d.ts +199 -0
  49. package/dist/stores/playgroundStore.js +350 -0
  50. package/dist/types/playground.d.ts +230 -0
  51. package/dist/types/playground.js +28 -0
  52. package/dist/utils/colors.js +4 -4
  53. package/package.json +6 -1
@@ -42,27 +42,27 @@
42
42
  // ============================================================================
43
43
  // Main Components
44
44
  // ============================================================================
45
- export { default as SchemaForm } from "../components/SchemaForm.svelte";
45
+ export { default as SchemaForm } from '../components/SchemaForm.svelte';
46
46
  // ============================================================================
47
47
  // Form Field Components (Light - no heavy dependencies)
48
48
  // ============================================================================
49
49
  // Use the light version of FormField that uses the registry for heavy editors
50
- export { default as FormField } from "../components/form/FormFieldLight.svelte";
50
+ export { default as FormField } from '../components/form/FormFieldLight.svelte';
51
51
  // Also export the original (full) version for users who want everything
52
- export { default as FormFieldFull } from "../components/form/FormField.svelte";
53
- export { default as FormFieldWrapper } from "../components/form/FormFieldWrapper.svelte";
54
- export { default as FormTextField } from "../components/form/FormTextField.svelte";
55
- export { default as FormTextarea } from "../components/form/FormTextarea.svelte";
56
- export { default as FormNumberField } from "../components/form/FormNumberField.svelte";
57
- export { default as FormRangeField } from "../components/form/FormRangeField.svelte";
58
- export { default as FormToggle } from "../components/form/FormToggle.svelte";
59
- export { default as FormSelect } from "../components/form/FormSelect.svelte";
60
- export { default as FormCheckboxGroup } from "../components/form/FormCheckboxGroup.svelte";
61
- export { default as FormArray } from "../components/form/FormArray.svelte";
62
- export { isFieldOptionArray, normalizeOptions } from "../components/form/types.js";
52
+ export { default as FormFieldFull } from '../components/form/FormField.svelte';
53
+ export { default as FormFieldWrapper } from '../components/form/FormFieldWrapper.svelte';
54
+ export { default as FormTextField } from '../components/form/FormTextField.svelte';
55
+ export { default as FormTextarea } from '../components/form/FormTextarea.svelte';
56
+ export { default as FormNumberField } from '../components/form/FormNumberField.svelte';
57
+ export { default as FormRangeField } from '../components/form/FormRangeField.svelte';
58
+ export { default as FormToggle } from '../components/form/FormToggle.svelte';
59
+ export { default as FormSelect } from '../components/form/FormSelect.svelte';
60
+ export { default as FormCheckboxGroup } from '../components/form/FormCheckboxGroup.svelte';
61
+ export { default as FormArray } from '../components/form/FormArray.svelte';
62
+ export { isFieldOptionArray, normalizeOptions } from '../components/form/types.js';
63
63
  // ============================================================================
64
64
  // Field Registry (for dynamic field registration)
65
65
  // ============================================================================
66
66
  export { registerFieldComponent, unregisterFieldComponent, resolveFieldComponent, getRegisteredFieldTypes, isFieldTypeRegistered, clearFieldRegistry, getFieldRegistrySize,
67
67
  // Built-in matchers for custom components
68
- hiddenFieldMatcher, checkboxGroupMatcher, enumSelectMatcher, textareaMatcher, rangeMatcher, textFieldMatcher, numberFieldMatcher, toggleMatcher, selectOptionsMatcher, arrayMatcher } from "./fieldRegistry.js";
68
+ hiddenFieldMatcher, checkboxGroupMatcher, enumSelectMatcher, textareaMatcher, rangeMatcher, textFieldMatcher, numberFieldMatcher, toggleMatcher, selectOptionsMatcher, arrayMatcher } from './fieldRegistry.js';
@@ -23,9 +23,9 @@
23
23
  * };
24
24
  * ```
25
25
  */
26
- import type { FieldSchema } from "../components/form/types.js";
27
- export { default as FormMarkdownEditor } from "../components/form/FormMarkdownEditor.svelte";
28
- export type { MarkdownEditorFieldProps } from "../components/form/types.js";
26
+ import type { FieldSchema } from '../components/form/types.js';
27
+ export { default as FormMarkdownEditor } from '../components/form/FormMarkdownEditor.svelte';
28
+ export type { MarkdownEditorFieldProps } from '../components/form/types.js';
29
29
  /**
30
30
  * Matcher for markdown editor fields
31
31
  * Matches: format "markdown"
@@ -23,15 +23,15 @@
23
23
  * };
24
24
  * ```
25
25
  */
26
- import { registerFieldComponent } from "./fieldRegistry.js";
26
+ import { registerFieldComponent } from './fieldRegistry.js';
27
27
  // Re-export the component for direct usage if needed
28
- export { default as FormMarkdownEditor } from "../components/form/FormMarkdownEditor.svelte";
28
+ export { default as FormMarkdownEditor } from '../components/form/FormMarkdownEditor.svelte';
29
29
  /**
30
30
  * Matcher for markdown editor fields
31
31
  * Matches: format "markdown"
32
32
  */
33
33
  export function markdownEditorFieldMatcher(schema) {
34
- return schema.format === "markdown";
34
+ return schema.format === 'markdown';
35
35
  }
36
36
  /**
37
37
  * Track if markdown editor is registered
@@ -58,8 +58,8 @@ export function registerMarkdownEditorField(priority = 100) {
58
58
  return;
59
59
  }
60
60
  // Dynamic import to ensure proper code splitting
61
- import("../components/form/FormMarkdownEditor.svelte").then((module) => {
62
- registerFieldComponent("markdown-editor", module.default, markdownEditorFieldMatcher, priority);
61
+ import('../components/form/FormMarkdownEditor.svelte').then((module) => {
62
+ registerFieldComponent('markdown-editor', module.default, markdownEditorFieldMatcher, priority);
63
63
  markdownEditorRegistered = true;
64
64
  });
65
65
  }
@@ -82,7 +82,7 @@ component, priority = 100) {
82
82
  if (markdownEditorRegistered) {
83
83
  return;
84
84
  }
85
- registerFieldComponent("markdown-editor", component, markdownEditorFieldMatcher, priority);
85
+ registerFieldComponent('markdown-editor', component, markdownEditorFieldMatcher, priority);
86
86
  markdownEditorRegistered = true;
87
87
  }
88
88
  /**
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@
13
13
  * - `@d34dman/flowdrop/form/code` - Code editor support (adds CodeMirror)
14
14
  * - `@d34dman/flowdrop/form/markdown` - Markdown editor support (adds EasyMDE)
15
15
  * - `@d34dman/flowdrop/display` - MarkdownDisplay (adds marked)
16
+ * - `@d34dman/flowdrop/playground` - Playground for interactive workflow testing
16
17
  * - `@d34dman/flowdrop/styles` - CSS styles
17
18
  *
18
19
  * ## Legacy Import (Full Bundle)
@@ -28,7 +29,8 @@
28
29
  *
29
30
  * @module flowdrop
30
31
  */
31
- export * from "./core/index.js";
32
- export * from "./form/index.js";
33
- export * from "./display/index.js";
34
- export * from "./editor/index.js";
32
+ export * from './core/index.js';
33
+ export * from './form/index.js';
34
+ export * from './display/index.js';
35
+ export * from './playground/index.js';
36
+ export * from './editor/index.js';
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@
13
13
  * - `@d34dman/flowdrop/form/code` - Code editor support (adds CodeMirror)
14
14
  * - `@d34dman/flowdrop/form/markdown` - Markdown editor support (adds EasyMDE)
15
15
  * - `@d34dman/flowdrop/display` - MarkdownDisplay (adds marked)
16
+ * - `@d34dman/flowdrop/playground` - Playground for interactive workflow testing
16
17
  * - `@d34dman/flowdrop/styles` - CSS styles
17
18
  *
18
19
  * ## Legacy Import (Full Bundle)
@@ -35,18 +36,22 @@
35
36
  // ============================================================================
36
37
  // Core Exports (Types & Utilities - No Heavy Dependencies)
37
38
  // ============================================================================
38
- export * from "./core/index.js";
39
+ export * from './core/index.js';
39
40
  // ============================================================================
40
41
  // Form Exports
41
42
  // ============================================================================
42
- export * from "./form/index.js";
43
+ export * from './form/index.js';
43
44
  // Note: Heavy form fields (code, markdown) are NOT auto-registered.
44
45
  // Users must import from form/code or form/markdown and register explicitly.
45
46
  // ============================================================================
46
47
  // Display Exports
47
48
  // ============================================================================
48
- export * from "./display/index.js";
49
+ export * from './display/index.js';
50
+ // ============================================================================
51
+ // Playground Exports
52
+ // ============================================================================
53
+ export * from './playground/index.js';
49
54
  // ============================================================================
50
55
  // Editor Exports (includes @xyflow/svelte and auto-registers builtin nodes)
51
56
  // ============================================================================
52
- export * from "./editor/index.js";
57
+ export * from './editor/index.js';
@@ -0,0 +1,125 @@
1
+ /**
2
+ * FlowDrop Playground Module
3
+ *
4
+ * Provides the Playground feature for interactive workflow testing with
5
+ * chat interface, session management, and real-time execution logs.
6
+ *
7
+ * @module playground
8
+ *
9
+ * @example Using mountPlayground for vanilla JS / Drupal / IIFE:
10
+ * ```typescript
11
+ * import { mountPlayground, createEndpointConfig } from "@d34dman/flowdrop/playground";
12
+ *
13
+ * const app = await mountPlayground(
14
+ * document.getElementById("playground-container"),
15
+ * {
16
+ * workflowId: "wf-123",
17
+ * endpointConfig: createEndpointConfig("/api/flowdrop"),
18
+ * mode: "standalone"
19
+ * }
20
+ * );
21
+ *
22
+ * // Later, to cleanup:
23
+ * app.destroy();
24
+ * ```
25
+ *
26
+ * @example Drupal Behaviors integration:
27
+ * ```javascript
28
+ * (function (Drupal, FlowDrop) {
29
+ * Drupal.behaviors.flowdropPlayground = {
30
+ * attach: function (context, settings) {
31
+ * var container = document.getElementById("playground-container");
32
+ * if (!container || container.dataset.initialized) return;
33
+ * container.dataset.initialized = "true";
34
+ *
35
+ * FlowDrop.mountPlayground(container, {
36
+ * workflowId: settings.flowdrop.workflowId,
37
+ * endpointConfig: FlowDrop.createEndpointConfig(settings.flowdrop.apiBaseUrl),
38
+ * mode: "standalone"
39
+ * }).then(function (app) {
40
+ * container._flowdropApp = app;
41
+ * });
42
+ * },
43
+ * detach: function (context, settings, trigger) {
44
+ * if (trigger === "unload") {
45
+ * var container = document.getElementById("playground-container");
46
+ * if (container && container._flowdropApp) {
47
+ * container._flowdropApp.destroy();
48
+ * }
49
+ * }
50
+ * }
51
+ * };
52
+ * })(Drupal, window.FlowDrop);
53
+ * ```
54
+ *
55
+ * @example In Svelte (Standalone mode):
56
+ * ```svelte
57
+ * <script>
58
+ * import { Playground } from "@d34dman/flowdrop/playground";
59
+ * </script>
60
+ *
61
+ * <Playground workflowId="wf-123" mode="standalone" />
62
+ * ```
63
+ *
64
+ * @example In Svelte (Embedded mode):
65
+ * ```svelte
66
+ * <script>
67
+ * import { Playground } from "@d34dman/flowdrop/playground";
68
+ * let showPlayground = false;
69
+ * </script>
70
+ *
71
+ * {#if showPlayground}
72
+ * <Playground
73
+ * workflowId="wf-123"
74
+ * workflow={myWorkflow}
75
+ * mode="embedded"
76
+ * onClose={() => showPlayground = false}
77
+ * />
78
+ * {/if}
79
+ * ```
80
+ *
81
+ * @example In Svelte (Modal mode):
82
+ * ```svelte
83
+ * <script>
84
+ * import { PlaygroundModal } from "@d34dman/flowdrop/playground";
85
+ * let showPlayground = false;
86
+ * </script>
87
+ *
88
+ * <PlaygroundModal
89
+ * isOpen={showPlayground}
90
+ * workflowId="wf-123"
91
+ * workflow={myWorkflow}
92
+ * onClose={() => showPlayground = false}
93
+ * />
94
+ * ```
95
+ *
96
+ * @example Using mountPlayground with modal mode:
97
+ * ```typescript
98
+ * import { mountPlayground, createEndpointConfig } from "@d34dman/flowdrop/playground";
99
+ *
100
+ * const app = await mountPlayground(
101
+ * document.getElementById("playground-container"),
102
+ * {
103
+ * workflowId: "wf-123",
104
+ * endpointConfig: createEndpointConfig("/api/flowdrop"),
105
+ * mode: "modal",
106
+ * onClose: () => {
107
+ * app.destroy();
108
+ * }
109
+ * }
110
+ * );
111
+ * ```
112
+ */
113
+ export { default as Playground } from '../components/playground/Playground.svelte';
114
+ export { default as PlaygroundModal } from '../components/playground/PlaygroundModal.svelte';
115
+ export { default as ChatPanel } from '../components/playground/ChatPanel.svelte';
116
+ export { default as SessionManager } from '../components/playground/SessionManager.svelte';
117
+ export { default as InputCollector } from '../components/playground/InputCollector.svelte';
118
+ export { default as ExecutionLogs } from '../components/playground/ExecutionLogs.svelte';
119
+ export { default as MessageBubble } from '../components/playground/MessageBubble.svelte';
120
+ export { PlaygroundService, playgroundService } from '../services/playgroundService.js';
121
+ export { currentSession, sessions, messages, isExecuting, isLoading, error as playgroundError, currentWorkflow, lastPollTimestamp, sessionStatus, messageCount, chatMessages, logMessages, latestMessage, inputFields, hasChatInput, sessionCount, playgroundActions, getCurrentSessionId, isSessionSelected, getMessagesSnapshot, getLatestMessageTimestamp } from '../stores/playgroundStore.js';
122
+ export type { PlaygroundSession, PlaygroundMessage, PlaygroundInputField, PlaygroundMessageRequest, PlaygroundMessagesResult, PlaygroundConfig, PlaygroundMode, PlaygroundSessionStatus, PlaygroundMessageRole, PlaygroundMessageLevel, PlaygroundMessageMetadata, PlaygroundApiResponse, PlaygroundSessionsResponse, PlaygroundSessionResponse, PlaygroundMessageResponse, PlaygroundMessagesApiResponse } from '../types/playground.js';
123
+ export { isChatInputNode, CHAT_INPUT_PATTERNS } from '../types/playground.js';
124
+ export { mountPlayground, unmountPlayground, type PlaygroundMountOptions, type MountedPlayground } from './mount.js';
125
+ export { createEndpointConfig, defaultEndpointConfig, buildEndpointUrl, type EndpointConfig } from '../config/endpoints.js';
@@ -0,0 +1,147 @@
1
+ /**
2
+ * FlowDrop Playground Module
3
+ *
4
+ * Provides the Playground feature for interactive workflow testing with
5
+ * chat interface, session management, and real-time execution logs.
6
+ *
7
+ * @module playground
8
+ *
9
+ * @example Using mountPlayground for vanilla JS / Drupal / IIFE:
10
+ * ```typescript
11
+ * import { mountPlayground, createEndpointConfig } from "@d34dman/flowdrop/playground";
12
+ *
13
+ * const app = await mountPlayground(
14
+ * document.getElementById("playground-container"),
15
+ * {
16
+ * workflowId: "wf-123",
17
+ * endpointConfig: createEndpointConfig("/api/flowdrop"),
18
+ * mode: "standalone"
19
+ * }
20
+ * );
21
+ *
22
+ * // Later, to cleanup:
23
+ * app.destroy();
24
+ * ```
25
+ *
26
+ * @example Drupal Behaviors integration:
27
+ * ```javascript
28
+ * (function (Drupal, FlowDrop) {
29
+ * Drupal.behaviors.flowdropPlayground = {
30
+ * attach: function (context, settings) {
31
+ * var container = document.getElementById("playground-container");
32
+ * if (!container || container.dataset.initialized) return;
33
+ * container.dataset.initialized = "true";
34
+ *
35
+ * FlowDrop.mountPlayground(container, {
36
+ * workflowId: settings.flowdrop.workflowId,
37
+ * endpointConfig: FlowDrop.createEndpointConfig(settings.flowdrop.apiBaseUrl),
38
+ * mode: "standalone"
39
+ * }).then(function (app) {
40
+ * container._flowdropApp = app;
41
+ * });
42
+ * },
43
+ * detach: function (context, settings, trigger) {
44
+ * if (trigger === "unload") {
45
+ * var container = document.getElementById("playground-container");
46
+ * if (container && container._flowdropApp) {
47
+ * container._flowdropApp.destroy();
48
+ * }
49
+ * }
50
+ * }
51
+ * };
52
+ * })(Drupal, window.FlowDrop);
53
+ * ```
54
+ *
55
+ * @example In Svelte (Standalone mode):
56
+ * ```svelte
57
+ * <script>
58
+ * import { Playground } from "@d34dman/flowdrop/playground";
59
+ * </script>
60
+ *
61
+ * <Playground workflowId="wf-123" mode="standalone" />
62
+ * ```
63
+ *
64
+ * @example In Svelte (Embedded mode):
65
+ * ```svelte
66
+ * <script>
67
+ * import { Playground } from "@d34dman/flowdrop/playground";
68
+ * let showPlayground = false;
69
+ * </script>
70
+ *
71
+ * {#if showPlayground}
72
+ * <Playground
73
+ * workflowId="wf-123"
74
+ * workflow={myWorkflow}
75
+ * mode="embedded"
76
+ * onClose={() => showPlayground = false}
77
+ * />
78
+ * {/if}
79
+ * ```
80
+ *
81
+ * @example In Svelte (Modal mode):
82
+ * ```svelte
83
+ * <script>
84
+ * import { PlaygroundModal } from "@d34dman/flowdrop/playground";
85
+ * let showPlayground = false;
86
+ * </script>
87
+ *
88
+ * <PlaygroundModal
89
+ * isOpen={showPlayground}
90
+ * workflowId="wf-123"
91
+ * workflow={myWorkflow}
92
+ * onClose={() => showPlayground = false}
93
+ * />
94
+ * ```
95
+ *
96
+ * @example Using mountPlayground with modal mode:
97
+ * ```typescript
98
+ * import { mountPlayground, createEndpointConfig } from "@d34dman/flowdrop/playground";
99
+ *
100
+ * const app = await mountPlayground(
101
+ * document.getElementById("playground-container"),
102
+ * {
103
+ * workflowId: "wf-123",
104
+ * endpointConfig: createEndpointConfig("/api/flowdrop"),
105
+ * mode: "modal",
106
+ * onClose: () => {
107
+ * app.destroy();
108
+ * }
109
+ * }
110
+ * );
111
+ * ```
112
+ */
113
+ // ============================================================================
114
+ // Playground Components
115
+ // ============================================================================
116
+ export { default as Playground } from '../components/playground/Playground.svelte';
117
+ export { default as PlaygroundModal } from '../components/playground/PlaygroundModal.svelte';
118
+ export { default as ChatPanel } from '../components/playground/ChatPanel.svelte';
119
+ export { default as SessionManager } from '../components/playground/SessionManager.svelte';
120
+ export { default as InputCollector } from '../components/playground/InputCollector.svelte';
121
+ export { default as ExecutionLogs } from '../components/playground/ExecutionLogs.svelte';
122
+ export { default as MessageBubble } from '../components/playground/MessageBubble.svelte';
123
+ // ============================================================================
124
+ // Playground Service
125
+ // ============================================================================
126
+ export { PlaygroundService, playgroundService } from '../services/playgroundService.js';
127
+ // ============================================================================
128
+ // Playground Store
129
+ // ============================================================================
130
+ export {
131
+ // Core stores
132
+ currentSession, sessions, messages, isExecuting, isLoading, error as playgroundError, currentWorkflow, lastPollTimestamp,
133
+ // Derived stores
134
+ sessionStatus, messageCount, chatMessages, logMessages, latestMessage, inputFields, hasChatInput, sessionCount,
135
+ // Actions
136
+ playgroundActions,
137
+ // Utilities
138
+ getCurrentSessionId, isSessionSelected, getMessagesSnapshot, getLatestMessageTimestamp } from '../stores/playgroundStore.js';
139
+ export { isChatInputNode, CHAT_INPUT_PATTERNS } from '../types/playground.js';
140
+ // ============================================================================
141
+ // Playground Mount Functions (for vanilla JS / Drupal / IIFE integration)
142
+ // ============================================================================
143
+ export { mountPlayground, unmountPlayground } from './mount.js';
144
+ // ============================================================================
145
+ // Endpoint Configuration (re-exported for convenience)
146
+ // ============================================================================
147
+ export { createEndpointConfig, defaultEndpointConfig, buildEndpointUrl } from '../config/endpoints.js';
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Playground Mount Functions
3
+ *
4
+ * Provides mount/unmount functions for integrating the Playground component
5
+ * into any web application. Particularly useful for integration with
6
+ * vanilla JS, Drupal, WordPress, or other frameworks.
7
+ *
8
+ * @module playground/mount
9
+ *
10
+ * @example Basic usage in vanilla JavaScript:
11
+ * ```javascript
12
+ * const app = await FlowDrop.mountPlayground(
13
+ * document.getElementById("playground-container"),
14
+ * {
15
+ * workflowId: "wf-123",
16
+ * endpointConfig: FlowDrop.createEndpointConfig("/api/flowdrop"),
17
+ * mode: "standalone"
18
+ * }
19
+ * );
20
+ *
21
+ * // Later, to cleanup:
22
+ * app.destroy();
23
+ * ```
24
+ *
25
+ * @example Drupal integration:
26
+ * ```javascript
27
+ * (function (Drupal, FlowDrop) {
28
+ * Drupal.behaviors.flowdropPlayground = {
29
+ * attach: function (context, settings) {
30
+ * const container = document.getElementById("playground-container");
31
+ * if (!container || container.dataset.initialized) return;
32
+ * container.dataset.initialized = "true";
33
+ *
34
+ * FlowDrop.mountPlayground(container, {
35
+ * workflowId: settings.flowdrop.workflowId,
36
+ * endpointConfig: FlowDrop.createEndpointConfig(settings.flowdrop.apiBaseUrl),
37
+ * mode: "standalone"
38
+ * }).then(function (app) {
39
+ * container._flowdropApp = app;
40
+ * });
41
+ * }
42
+ * };
43
+ * })(Drupal, window.FlowDrop);
44
+ * ```
45
+ */
46
+ import type { Workflow } from "../types/index.js";
47
+ import type { EndpointConfig } from "../config/endpoints.js";
48
+ import type { PlaygroundMode, PlaygroundConfig, PlaygroundSession } from "../types/playground.js";
49
+ /**
50
+ * Mount options for Playground component
51
+ */
52
+ export interface PlaygroundMountOptions {
53
+ /**
54
+ * Target workflow ID (required)
55
+ * The workflow that the playground will interact with
56
+ */
57
+ workflowId: string;
58
+ /**
59
+ * Pre-loaded workflow data (optional)
60
+ * If not provided, the component will fetch it from the API
61
+ */
62
+ workflow?: Workflow;
63
+ /**
64
+ * Display mode
65
+ * - "standalone": Full-page playground experience
66
+ * - "embedded": Panel mode for embedding alongside other content
67
+ * - "modal": Modal dialog mode with backdrop
68
+ * @default "standalone"
69
+ */
70
+ mode?: PlaygroundMode;
71
+ /**
72
+ * Resume a specific session by ID
73
+ * If provided, the playground will load this session on mount
74
+ */
75
+ initialSessionId?: string;
76
+ /**
77
+ * API endpoint configuration
78
+ * Use createEndpointConfig() to create this
79
+ */
80
+ endpointConfig?: EndpointConfig;
81
+ /**
82
+ * Playground-specific configuration options
83
+ */
84
+ config?: PlaygroundConfig;
85
+ /**
86
+ * Container height (CSS value)
87
+ * @default "100%"
88
+ */
89
+ height?: string;
90
+ /**
91
+ * Container width (CSS value)
92
+ * @default "100%"
93
+ */
94
+ width?: string;
95
+ /**
96
+ * Callback when playground is closed (required for embedded and modal modes)
97
+ */
98
+ onClose?: () => void;
99
+ }
100
+ /**
101
+ * Return type for mounted Playground instance
102
+ */
103
+ export interface MountedPlayground {
104
+ /**
105
+ * Destroy the playground and clean up resources
106
+ * Should be called when removing the playground from the DOM
107
+ */
108
+ destroy: () => void;
109
+ /**
110
+ * Get the current session
111
+ * @returns The current session or null if none selected
112
+ */
113
+ getCurrentSession: () => PlaygroundSession | null;
114
+ /**
115
+ * Get all sessions for the workflow
116
+ * @returns Array of playground sessions
117
+ */
118
+ getSessions: () => PlaygroundSession[];
119
+ /**
120
+ * Get the message count in the current session
121
+ * @returns Number of messages
122
+ */
123
+ getMessageCount: () => number;
124
+ /**
125
+ * Check if the playground is currently executing
126
+ * @returns True if a workflow execution is in progress
127
+ */
128
+ isExecuting: () => boolean;
129
+ /**
130
+ * Stop any active polling
131
+ */
132
+ stopPolling: () => void;
133
+ /**
134
+ * Reset the playground state
135
+ * Clears the current session and messages
136
+ */
137
+ reset: () => void;
138
+ }
139
+ /**
140
+ * Mount the Playground component in a container
141
+ *
142
+ * This function mounts the Playground Svelte component into a DOM container,
143
+ * enabling interactive workflow testing with a chat interface.
144
+ *
145
+ * @param container - DOM element to mount the playground into
146
+ * @param options - Configuration options for the playground
147
+ * @returns Promise resolving to a MountedPlayground instance
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * import { mountPlayground, createEndpointConfig } from "@d34dman/flowdrop/playground";
152
+ *
153
+ * const app = await mountPlayground(
154
+ * document.getElementById("playground"),
155
+ * {
156
+ * workflowId: "wf-123",
157
+ * endpointConfig: createEndpointConfig("/api/flowdrop"),
158
+ * mode: "standalone",
159
+ * config: {
160
+ * showTimestamps: true,
161
+ * autoScroll: true,
162
+ * pollingInterval: 1500
163
+ * }
164
+ * }
165
+ * );
166
+ * ```
167
+ */
168
+ export declare function mountPlayground(container: HTMLElement, options: PlaygroundMountOptions): Promise<MountedPlayground>;
169
+ /**
170
+ * Unmount a Playground instance
171
+ *
172
+ * Convenience function for destroying a mounted playground.
173
+ * Equivalent to calling `app.destroy()`.
174
+ *
175
+ * @param app - The mounted playground to unmount
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const app = await mountPlayground(container, options);
180
+ * // ... later
181
+ * unmountPlayground(app);
182
+ * ```
183
+ */
184
+ export declare function unmountPlayground(app: MountedPlayground): void;