@d34dman/flowdrop 0.0.28 → 0.0.30

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.
@@ -0,0 +1,50 @@
1
+ /**
2
+ * FlowDrop Core Module
3
+ *
4
+ * This module exports types, utilities, and lightweight functionality
5
+ * with zero heavy dependencies. Safe to import without bundling
6
+ * @xyflow/svelte, codemirror, easymde, or marked.
7
+ *
8
+ * @module core
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Import types and utilities without heavy dependencies
13
+ * import type { Workflow, WorkflowNode, NodeMetadata } from "@d34dman/flowdrop/core";
14
+ * import { getStatusColor, createDefaultExecutionInfo } from "@d34dman/flowdrop/core";
15
+ * ```
16
+ */
17
+ // ============================================================================
18
+ // Authentication Providers (no dependencies)
19
+ // ============================================================================
20
+ export { StaticAuthProvider, CallbackAuthProvider, NoAuthProvider } from "../types/auth.js";
21
+ // ============================================================================
22
+ // Event Utilities
23
+ // ============================================================================
24
+ export { DEFAULT_FEATURES, mergeFeatures } from "../types/events.js";
25
+ // ============================================================================
26
+ // Utility Functions (no heavy dependencies)
27
+ // ============================================================================
28
+ // Node status utilities
29
+ export { getStatusColor, getStatusIcon, getStatusLabel, getStatusBackgroundColor, getStatusTextColor, createDefaultExecutionInfo, updateExecutionStart, updateExecutionComplete, updateExecutionFailed, resetExecutionInfo, formatExecutionDuration, formatLastExecuted } from "../utils/nodeStatus.js";
30
+ // Node wrapper utilities
31
+ export { createNodeWrapperConfig, shouldShowNodeStatus, getOptimalStatusPosition, getOptimalStatusSize, DEFAULT_NODE_STATUS_CONFIG } from "../utils/nodeWrapper.js";
32
+ // Color utilities
33
+ export * from "../utils/colors.js";
34
+ // Icon utilities
35
+ export * from "../utils/icons.js";
36
+ // Config utilities
37
+ export * from "../utils/config.js";
38
+ // Node type utilities
39
+ export * from "../utils/nodeTypes.js";
40
+ // Form type utilities
41
+ export { isFieldOptionArray, normalizeOptions } from "../components/form/types.js";
42
+ // ============================================================================
43
+ // Configuration
44
+ // ============================================================================
45
+ export { DEFAULT_PORT_CONFIG } from "../config/defaultPortConfig.js";
46
+ export { defaultEndpointConfig, createEndpointConfig } from "../config/endpoints.js";
47
+ // ============================================================================
48
+ // Adapters
49
+ // ============================================================================
50
+ export * from "../adapters/WorkflowAdapter.js";
@@ -0,0 +1,29 @@
1
+ /**
2
+ * FlowDrop Display Module
3
+ *
4
+ * Provides display components for rendering content.
5
+ * This module includes the marked library for markdown rendering.
6
+ *
7
+ * @module display
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { MarkdownDisplay } from "@d34dman/flowdrop/display";
12
+ * ```
13
+ *
14
+ * @example In Svelte:
15
+ * ```svelte
16
+ * <script>
17
+ * import { MarkdownDisplay } from "@d34dman/flowdrop/display";
18
+ *
19
+ * const markdown = `
20
+ * # Hello World
21
+ * This is **markdown** content.
22
+ * `;
23
+ * </script>
24
+ *
25
+ * <MarkdownDisplay content={markdown} />
26
+ * ```
27
+ */
28
+ export { default as MarkdownDisplay } from "../components/MarkdownDisplay.svelte";
29
+ export { marked } from "marked";
@@ -0,0 +1,36 @@
1
+ /**
2
+ * FlowDrop Display Module
3
+ *
4
+ * Provides display components for rendering content.
5
+ * This module includes the marked library for markdown rendering.
6
+ *
7
+ * @module display
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { MarkdownDisplay } from "@d34dman/flowdrop/display";
12
+ * ```
13
+ *
14
+ * @example In Svelte:
15
+ * ```svelte
16
+ * <script>
17
+ * import { MarkdownDisplay } from "@d34dman/flowdrop/display";
18
+ *
19
+ * const markdown = `
20
+ * # Hello World
21
+ * This is **markdown** content.
22
+ * `;
23
+ * </script>
24
+ *
25
+ * <MarkdownDisplay content={markdown} />
26
+ * ```
27
+ */
28
+ // ============================================================================
29
+ // Display Components
30
+ // ============================================================================
31
+ export { default as MarkdownDisplay } from "../components/MarkdownDisplay.svelte";
32
+ // ============================================================================
33
+ // Re-export marked for advanced usage
34
+ // ============================================================================
35
+ // Users can use marked directly if they need more control
36
+ export { marked } from "marked";
@@ -0,0 +1,78 @@
1
+ /**
2
+ * FlowDrop Editor Module
3
+ *
4
+ * Provides the WorkflowEditor component and related functionality for
5
+ * building visual workflow editors. This module includes @xyflow/svelte
6
+ * and all node components.
7
+ *
8
+ * @module editor
9
+ *
10
+ * @example Mounting a standalone workflow editor:
11
+ * ```typescript
12
+ * import { mountFlowDropApp, WorkflowEditor } from "@d34dman/flowdrop/editor";
13
+ * import "@d34dman/flowdrop/styles";
14
+ *
15
+ * const app = await mountFlowDropApp(document.getElementById("editor"), {
16
+ * workflow: myWorkflow,
17
+ * nodes: availableNodes
18
+ * });
19
+ * ```
20
+ *
21
+ * @example Using WorkflowEditor in Svelte:
22
+ * ```svelte
23
+ * <script>
24
+ * import { WorkflowEditor } from "@d34dman/flowdrop/editor";
25
+ * </script>
26
+ *
27
+ * <WorkflowEditor nodes={availableNodes} />
28
+ * ```
29
+ */
30
+ import "../registry/builtinNodes.js";
31
+ export { default as WorkflowEditor } from "../components/WorkflowEditor.svelte";
32
+ export { default as App } from "../components/App.svelte";
33
+ export { default as WorkflowNodeComponent } from "../components/nodes/WorkflowNode.svelte";
34
+ export { default as SimpleNodeComponent } from "../components/nodes/SimpleNode.svelte";
35
+ export { default as ToolNodeComponent } from "../components/nodes/ToolNode.svelte";
36
+ export { default as NotesNodeComponent } from "../components/nodes/NotesNode.svelte";
37
+ export { default as GatewayNode } from "../components/nodes/GatewayNode.svelte";
38
+ export { default as SquareNode } from "../components/nodes/SquareNode.svelte";
39
+ export { default as TerminalNode } from "../components/nodes/TerminalNode.svelte";
40
+ export { default as UniversalNode } from "../components/UniversalNode.svelte";
41
+ export { default as NodeSidebar } from "../components/NodeSidebar.svelte";
42
+ export { default as CanvasBanner } from "../components/CanvasBanner.svelte";
43
+ export { default as LoadingSpinner } from "../components/LoadingSpinner.svelte";
44
+ export { default as StatusIcon } from "../components/StatusIcon.svelte";
45
+ export { default as StatusLabel } from "../components/StatusLabel.svelte";
46
+ export { default as NodeStatusOverlay } from "../components/NodeStatusOverlay.svelte";
47
+ export { default as ConfigForm } from "../components/ConfigForm.svelte";
48
+ export { default as ConfigModal } from "../components/ConfigModal.svelte";
49
+ export { default as ConfigPanel } from "../components/ConfigPanel.svelte";
50
+ export { default as ReadOnlyDetails } from "../components/ReadOnlyDetails.svelte";
51
+ export { default as ConnectionLine } from "../components/ConnectionLine.svelte";
52
+ export { default as LogsSidebar } from "../components/LogsSidebar.svelte";
53
+ export { default as PipelineStatus } from "../components/PipelineStatus.svelte";
54
+ export { default as Navbar } from "../components/Navbar.svelte";
55
+ export { default as Logo } from "../components/Logo.svelte";
56
+ export { mountWorkflowEditor, mountFlowDropApp, unmountFlowDropApp } from "../svelte-app.js";
57
+ export { nodeComponentRegistry, createNamespacedType, parseNamespacedType, BUILTIN_NODE_COMPONENTS, BUILTIN_NODE_TYPES, FLOWDROP_SOURCE, registerBuiltinNodes, areBuiltinsRegistered, isBuiltinType, getBuiltinTypes, resolveBuiltinAlias, registerFlowDropPlugin, unregisterFlowDropPlugin, registerCustomNode, createPlugin, isValidNamespace, getRegisteredPlugins, getPluginNodeCount } from "../registry/index.js";
58
+ export { EdgeStylingHelper, NodeOperationsHelper, WorkflowOperationsHelper, ConfigurationHelper } from "../helpers/workflowEditorHelper.js";
59
+ export { workflowStore, workflowActions, workflowId, workflowName, workflowNodes, workflowEdges, workflowMetadata, workflowChanged, workflowValidation, workflowMetadataChanged, connectedHandles, isDirtyStore, isDirty, markAsSaved, getWorkflow as getWorkflowFromStore, setOnDirtyStateChange, setOnWorkflowChange } from "../stores/workflowStore.js";
60
+ export * from "../services/api.js";
61
+ export { showSuccess, showError, showWarning, showInfo, showLoading, dismissToast, dismissAllToasts, showPromise, showConfirmation, apiToasts, workflowToasts, pipelineToasts } from "../services/toastService.js";
62
+ export { NodeExecutionService, nodeExecutionService } from "../services/nodeExecutionService.js";
63
+ export { saveWorkflow, updateWorkflow, getWorkflow, getWorkflows, deleteWorkflow, getWorkflowCount, initializeSampleWorkflows } from "../services/workflowStorage.js";
64
+ export { globalSaveWorkflow, globalExportWorkflow, initializeGlobalSave } from "../services/globalSave.js";
65
+ export { fetchPortConfig, validatePortConfig } from "../services/portConfigApi.js";
66
+ export { fetchDynamicSchema, resolveExternalEditUrl, getEffectiveConfigEditOptions, clearSchemaCache, invalidateSchemaCache, hasConfigEditOptions, shouldShowExternalEdit, shouldUseDynamicSchema } from "../services/dynamicSchemaService.js";
67
+ export { getDraftStorageKey, saveDraft, loadDraft, deleteDraft, hasDraft, getDraftMetadata, DraftAutoSaveManager } from "../services/draftStorage.js";
68
+ export { FlowDropApiClient } from "../api/client.js";
69
+ export { EnhancedFlowDropApiClient, ApiError } from "../api/enhanced-client.js";
70
+ export * from "../utils/connections.js";
71
+ export * from "../config/runtimeConfig.js";
72
+ export type { Workflow, WorkflowNode, WorkflowEdge, NodeMetadata, NodePort, DynamicPort, Branch, ExecutionStatus, ExecutionResult, FlowDropConfig, PortConfig, ConfigSchema, ConfigProperty, ConfigEditOptions } from "../types/index.js";
73
+ export type { WorkflowEditorConfig, EditorFeatures, UIConfig, APIConfig } from "../types/config.js";
74
+ export type { AuthProvider, StaticAuthConfig, CallbackAuthConfig } from "../types/auth.js";
75
+ export type { FlowDropEventHandlers, FlowDropFeatures, WorkflowChangeType } from "../types/events.js";
76
+ export type { EndpointConfig } from "../config/endpoints.js";
77
+ export type { FlowDropMountOptions, MountedFlowDropApp, NavbarAction } from "../svelte-app.js";
78
+ export type { NodeComponentProps, NodeComponentRegistration, FlowDropPluginConfig, PluginNodeDefinition } from "../registry/index.js";
@@ -0,0 +1,117 @@
1
+ /**
2
+ * FlowDrop Editor Module
3
+ *
4
+ * Provides the WorkflowEditor component and related functionality for
5
+ * building visual workflow editors. This module includes @xyflow/svelte
6
+ * and all node components.
7
+ *
8
+ * @module editor
9
+ *
10
+ * @example Mounting a standalone workflow editor:
11
+ * ```typescript
12
+ * import { mountFlowDropApp, WorkflowEditor } from "@d34dman/flowdrop/editor";
13
+ * import "@d34dman/flowdrop/styles";
14
+ *
15
+ * const app = await mountFlowDropApp(document.getElementById("editor"), {
16
+ * workflow: myWorkflow,
17
+ * nodes: availableNodes
18
+ * });
19
+ * ```
20
+ *
21
+ * @example Using WorkflowEditor in Svelte:
22
+ * ```svelte
23
+ * <script>
24
+ * import { WorkflowEditor } from "@d34dman/flowdrop/editor";
25
+ * </script>
26
+ *
27
+ * <WorkflowEditor nodes={availableNodes} />
28
+ * ```
29
+ */
30
+ // ============================================================================
31
+ // Initialize Built-in Nodes
32
+ // This side effect is intentional for the editor module - users importing
33
+ // the editor expect all node types to be available.
34
+ // ============================================================================
35
+ import "../registry/builtinNodes.js";
36
+ // ============================================================================
37
+ // Main Editor Components
38
+ // ============================================================================
39
+ export { default as WorkflowEditor } from "../components/WorkflowEditor.svelte";
40
+ export { default as App } from "../components/App.svelte";
41
+ // ============================================================================
42
+ // Node Components
43
+ // ============================================================================
44
+ export { default as WorkflowNodeComponent } from "../components/nodes/WorkflowNode.svelte";
45
+ export { default as SimpleNodeComponent } from "../components/nodes/SimpleNode.svelte";
46
+ export { default as ToolNodeComponent } from "../components/nodes/ToolNode.svelte";
47
+ export { default as NotesNodeComponent } from "../components/nodes/NotesNode.svelte";
48
+ export { default as GatewayNode } from "../components/nodes/GatewayNode.svelte";
49
+ export { default as SquareNode } from "../components/nodes/SquareNode.svelte";
50
+ export { default as TerminalNode } from "../components/nodes/TerminalNode.svelte";
51
+ export { default as UniversalNode } from "../components/UniversalNode.svelte";
52
+ // ============================================================================
53
+ // Supporting Editor Components
54
+ // ============================================================================
55
+ export { default as NodeSidebar } from "../components/NodeSidebar.svelte";
56
+ export { default as CanvasBanner } from "../components/CanvasBanner.svelte";
57
+ export { default as LoadingSpinner } from "../components/LoadingSpinner.svelte";
58
+ export { default as StatusIcon } from "../components/StatusIcon.svelte";
59
+ export { default as StatusLabel } from "../components/StatusLabel.svelte";
60
+ export { default as NodeStatusOverlay } from "../components/NodeStatusOverlay.svelte";
61
+ export { default as ConfigForm } from "../components/ConfigForm.svelte";
62
+ export { default as ConfigModal } from "../components/ConfigModal.svelte";
63
+ export { default as ConfigPanel } from "../components/ConfigPanel.svelte";
64
+ export { default as ReadOnlyDetails } from "../components/ReadOnlyDetails.svelte";
65
+ export { default as ConnectionLine } from "../components/ConnectionLine.svelte";
66
+ export { default as LogsSidebar } from "../components/LogsSidebar.svelte";
67
+ export { default as PipelineStatus } from "../components/PipelineStatus.svelte";
68
+ export { default as Navbar } from "../components/Navbar.svelte";
69
+ export { default as Logo } from "../components/Logo.svelte";
70
+ // ============================================================================
71
+ // Mount Functions
72
+ // ============================================================================
73
+ export { mountWorkflowEditor, mountFlowDropApp, unmountFlowDropApp } from "../svelte-app.js";
74
+ // ============================================================================
75
+ // Node Component Registry
76
+ // ============================================================================
77
+ export {
78
+ // Core registry
79
+ nodeComponentRegistry, createNamespacedType, parseNamespacedType,
80
+ // Built-in nodes
81
+ BUILTIN_NODE_COMPONENTS, BUILTIN_NODE_TYPES, FLOWDROP_SOURCE, registerBuiltinNodes, areBuiltinsRegistered, isBuiltinType, getBuiltinTypes, resolveBuiltinAlias,
82
+ // Plugin system
83
+ registerFlowDropPlugin, unregisterFlowDropPlugin, registerCustomNode, createPlugin, isValidNamespace, getRegisteredPlugins, getPluginNodeCount } from "../registry/index.js";
84
+ // ============================================================================
85
+ // Editor Helpers
86
+ // ============================================================================
87
+ export { EdgeStylingHelper, NodeOperationsHelper, WorkflowOperationsHelper, ConfigurationHelper } from "../helpers/workflowEditorHelper.js";
88
+ // ============================================================================
89
+ // Stores
90
+ // ============================================================================
91
+ export { workflowStore, workflowActions, workflowId, workflowName, workflowNodes, workflowEdges, workflowMetadata, workflowChanged, workflowValidation, workflowMetadataChanged, connectedHandles,
92
+ // Dirty state tracking
93
+ isDirtyStore, isDirty, markAsSaved, getWorkflow as getWorkflowFromStore, setOnDirtyStateChange, setOnWorkflowChange } from "../stores/workflowStore.js";
94
+ // ============================================================================
95
+ // Services
96
+ // ============================================================================
97
+ export * from "../services/api.js";
98
+ export { showSuccess, showError, showWarning, showInfo, showLoading, dismissToast, dismissAllToasts, showPromise, showConfirmation, apiToasts, workflowToasts, pipelineToasts } from "../services/toastService.js";
99
+ export { NodeExecutionService, nodeExecutionService } from "../services/nodeExecutionService.js";
100
+ export { saveWorkflow, updateWorkflow, getWorkflow, getWorkflows, deleteWorkflow, getWorkflowCount, initializeSampleWorkflows } from "../services/workflowStorage.js";
101
+ export { globalSaveWorkflow, globalExportWorkflow, initializeGlobalSave } from "../services/globalSave.js";
102
+ export { fetchPortConfig, validatePortConfig } from "../services/portConfigApi.js";
103
+ export { fetchDynamicSchema, resolveExternalEditUrl, getEffectiveConfigEditOptions, clearSchemaCache, invalidateSchemaCache, hasConfigEditOptions, shouldShowExternalEdit, shouldUseDynamicSchema } from "../services/dynamicSchemaService.js";
104
+ export { getDraftStorageKey, saveDraft, loadDraft, deleteDraft, hasDraft, getDraftMetadata, DraftAutoSaveManager } from "../services/draftStorage.js";
105
+ // ============================================================================
106
+ // API Clients
107
+ // ============================================================================
108
+ export { FlowDropApiClient } from "../api/client.js";
109
+ export { EnhancedFlowDropApiClient, ApiError } from "../api/enhanced-client.js";
110
+ // ============================================================================
111
+ // Connection Utilities
112
+ // ============================================================================
113
+ export * from "../utils/connections.js";
114
+ // ============================================================================
115
+ // Runtime Configuration
116
+ // ============================================================================
117
+ export * from "../config/runtimeConfig.js";
@@ -0,0 +1,100 @@
1
+ /**
2
+ * FlowDrop Form Code Editor Module
3
+ *
4
+ * Adds CodeMirror-based code/JSON editor support to SchemaForm.
5
+ * This module bundles CodeMirror dependencies (~300KB).
6
+ *
7
+ * @module form/code
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { SchemaForm } from "@d34dman/flowdrop/form";
12
+ * import { registerCodeEditorField, registerTemplateEditorField } from "@d34dman/flowdrop/form/code";
13
+ *
14
+ * // Register code editor support (call once at app startup)
15
+ * registerCodeEditorField();
16
+ *
17
+ * // Optionally also register template editor
18
+ * registerTemplateEditorField();
19
+ *
20
+ * // Now SchemaForm will render code editors for format: "json", "code", or "template"
21
+ * ```
22
+ */
23
+ import type { FieldSchema } from "../components/form/types.js";
24
+ export { default as FormCodeEditor } from "../components/form/FormCodeEditor.svelte";
25
+ export { default as FormTemplateEditor } from "../components/form/FormTemplateEditor.svelte";
26
+ export type { CodeEditorFieldProps, TemplateEditorFieldProps } from "../components/form/types.js";
27
+ /**
28
+ * Matcher for code/JSON editor fields
29
+ * Matches: format "json", "code", or type "object" without specific format
30
+ */
31
+ export declare function codeEditorFieldMatcher(schema: FieldSchema): boolean;
32
+ /**
33
+ * Matcher for template editor fields
34
+ * Matches: format "template" (Twig/Liquid-style templates)
35
+ */
36
+ export declare function templateEditorFieldMatcher(schema: FieldSchema): boolean;
37
+ /**
38
+ * Register the code/JSON editor field component
39
+ *
40
+ * Call this function once at application startup to enable
41
+ * code editor fields in SchemaForm. This loads CodeMirror dependencies.
42
+ *
43
+ * @param priority - Priority for field matching (default: 100)
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * // In your app's entry point:
48
+ * import { registerCodeEditorField } from "@d34dman/flowdrop/form/code";
49
+ *
50
+ * registerCodeEditorField();
51
+ * ```
52
+ */
53
+ export declare function registerCodeEditorField(priority?: number): void;
54
+ /**
55
+ * Register the template editor field component
56
+ *
57
+ * Call this function once at application startup to enable
58
+ * template editor fields (Twig/Liquid syntax) in SchemaForm.
59
+ *
60
+ * @param priority - Priority for field matching (default: 100)
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * // In your app's entry point:
65
+ * import { registerTemplateEditorField } from "@d34dman/flowdrop/form/code";
66
+ *
67
+ * registerTemplateEditorField();
68
+ * ```
69
+ */
70
+ export declare function registerTemplateEditorField(priority?: number): void;
71
+ /**
72
+ * Register all code-related editor fields (code + template)
73
+ *
74
+ * Convenience function to register both code editor types at once.
75
+ *
76
+ * @param priority - Priority for field matching (default: 100)
77
+ */
78
+ export declare function registerAllCodeEditors(priority?: number): void;
79
+ /**
80
+ * Synchronously register code editor field using the imported component
81
+ *
82
+ * Use this when you've already imported the component and want immediate registration.
83
+ *
84
+ * @param priority - Priority for field matching (default: 100)
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * import { registerCodeEditorFieldWithComponent, FormCodeEditor } from "@d34dman/flowdrop/form/code";
89
+ * registerCodeEditorFieldWithComponent(FormCodeEditor);
90
+ * ```
91
+ */
92
+ export declare function registerCodeEditorFieldWithComponent(component: any, priority?: number): void;
93
+ /**
94
+ * Check if code editor field is registered
95
+ */
96
+ export declare function isCodeEditorRegistered(): boolean;
97
+ /**
98
+ * Check if template editor field is registered
99
+ */
100
+ export declare function isTemplateEditorRegistered(): boolean;
@@ -0,0 +1,153 @@
1
+ /**
2
+ * FlowDrop Form Code Editor Module
3
+ *
4
+ * Adds CodeMirror-based code/JSON editor support to SchemaForm.
5
+ * This module bundles CodeMirror dependencies (~300KB).
6
+ *
7
+ * @module form/code
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { SchemaForm } from "@d34dman/flowdrop/form";
12
+ * import { registerCodeEditorField, registerTemplateEditorField } from "@d34dman/flowdrop/form/code";
13
+ *
14
+ * // Register code editor support (call once at app startup)
15
+ * registerCodeEditorField();
16
+ *
17
+ * // Optionally also register template editor
18
+ * registerTemplateEditorField();
19
+ *
20
+ * // Now SchemaForm will render code editors for format: "json", "code", or "template"
21
+ * ```
22
+ */
23
+ import { registerFieldComponent } from "./fieldRegistry.js";
24
+ // Re-export the components for direct usage if needed
25
+ export { default as FormCodeEditor } from "../components/form/FormCodeEditor.svelte";
26
+ export { default as FormTemplateEditor } from "../components/form/FormTemplateEditor.svelte";
27
+ /**
28
+ * Matcher for code/JSON editor fields
29
+ * Matches: format "json", "code", or type "object" without specific format
30
+ */
31
+ export function codeEditorFieldMatcher(schema) {
32
+ // JSON/code format
33
+ if (schema.format === "json" || schema.format === "code") {
34
+ return true;
35
+ }
36
+ // Object type without specific format (render as JSON editor)
37
+ if (schema.type === "object" && !schema.format) {
38
+ return true;
39
+ }
40
+ return false;
41
+ }
42
+ /**
43
+ * Matcher for template editor fields
44
+ * Matches: format "template" (Twig/Liquid-style templates)
45
+ */
46
+ export function templateEditorFieldMatcher(schema) {
47
+ return schema.format === "template";
48
+ }
49
+ /**
50
+ * Track if code editor is registered
51
+ */
52
+ let codeEditorRegistered = false;
53
+ /**
54
+ * Track if template editor is registered
55
+ */
56
+ let templateEditorRegistered = false;
57
+ /**
58
+ * Register the code/JSON editor field component
59
+ *
60
+ * Call this function once at application startup to enable
61
+ * code editor fields in SchemaForm. This loads CodeMirror dependencies.
62
+ *
63
+ * @param priority - Priority for field matching (default: 100)
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * // In your app's entry point:
68
+ * import { registerCodeEditorField } from "@d34dman/flowdrop/form/code";
69
+ *
70
+ * registerCodeEditorField();
71
+ * ```
72
+ */
73
+ export function registerCodeEditorField(priority = 100) {
74
+ if (codeEditorRegistered) {
75
+ return;
76
+ }
77
+ // Dynamic import to ensure proper code splitting
78
+ import("../components/form/FormCodeEditor.svelte").then((module) => {
79
+ registerFieldComponent("code-editor", module.default, codeEditorFieldMatcher, priority);
80
+ codeEditorRegistered = true;
81
+ });
82
+ }
83
+ /**
84
+ * Register the template editor field component
85
+ *
86
+ * Call this function once at application startup to enable
87
+ * template editor fields (Twig/Liquid syntax) in SchemaForm.
88
+ *
89
+ * @param priority - Priority for field matching (default: 100)
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * // In your app's entry point:
94
+ * import { registerTemplateEditorField } from "@d34dman/flowdrop/form/code";
95
+ *
96
+ * registerTemplateEditorField();
97
+ * ```
98
+ */
99
+ export function registerTemplateEditorField(priority = 100) {
100
+ if (templateEditorRegistered) {
101
+ return;
102
+ }
103
+ // Dynamic import to ensure proper code splitting
104
+ import("../components/form/FormTemplateEditor.svelte").then((module) => {
105
+ registerFieldComponent("template-editor", module.default, templateEditorFieldMatcher, priority);
106
+ templateEditorRegistered = true;
107
+ });
108
+ }
109
+ /**
110
+ * Register all code-related editor fields (code + template)
111
+ *
112
+ * Convenience function to register both code editor types at once.
113
+ *
114
+ * @param priority - Priority for field matching (default: 100)
115
+ */
116
+ export function registerAllCodeEditors(priority = 100) {
117
+ registerCodeEditorField(priority);
118
+ registerTemplateEditorField(priority);
119
+ }
120
+ /**
121
+ * Synchronously register code editor field using the imported component
122
+ *
123
+ * Use this when you've already imported the component and want immediate registration.
124
+ *
125
+ * @param priority - Priority for field matching (default: 100)
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * import { registerCodeEditorFieldWithComponent, FormCodeEditor } from "@d34dman/flowdrop/form/code";
130
+ * registerCodeEditorFieldWithComponent(FormCodeEditor);
131
+ * ```
132
+ */
133
+ export function registerCodeEditorFieldWithComponent(
134
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
135
+ component, priority = 100) {
136
+ if (codeEditorRegistered) {
137
+ return;
138
+ }
139
+ registerFieldComponent("code-editor", component, codeEditorFieldMatcher, priority);
140
+ codeEditorRegistered = true;
141
+ }
142
+ /**
143
+ * Check if code editor field is registered
144
+ */
145
+ export function isCodeEditorRegistered() {
146
+ return codeEditorRegistered;
147
+ }
148
+ /**
149
+ * Check if template editor field is registered
150
+ */
151
+ export function isTemplateEditorRegistered() {
152
+ return templateEditorRegistered;
153
+ }