@nimbalyst/extension-sdk 0.1.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 (57) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +151 -0
  3. package/dist/MaterialSymbol.d.ts +2 -0
  4. package/dist/MaterialSymbol.d.ts.map +1 -0
  5. package/dist/MaterialSymbol.js +1 -0
  6. package/dist/clipboard.d.ts +14 -0
  7. package/dist/clipboard.d.ts.map +1 -0
  8. package/dist/clipboard.js +27 -0
  9. package/dist/createReadOnlyHost.d.ts +45 -0
  10. package/dist/createReadOnlyHost.d.ts.map +1 -0
  11. package/dist/createReadOnlyHost.js +81 -0
  12. package/dist/documentPath.d.ts +6 -0
  13. package/dist/documentPath.d.ts.map +1 -0
  14. package/dist/documentPath.js +4 -0
  15. package/dist/externals.d.ts +23 -0
  16. package/dist/externals.d.ts.map +1 -0
  17. package/dist/externals.js +42 -0
  18. package/dist/externalsPlugin.d.ts +39 -0
  19. package/dist/externalsPlugin.d.ts.map +1 -0
  20. package/dist/externalsPlugin.js +251 -0
  21. package/dist/index.d.ts +33 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +39 -0
  24. package/dist/tailwind.d.ts +112 -0
  25. package/dist/tailwind.d.ts.map +1 -0
  26. package/dist/tailwind.js +129 -0
  27. package/dist/testing.d.ts +122 -0
  28. package/dist/testing.d.ts.map +1 -0
  29. package/dist/testing.js +199 -0
  30. package/dist/types/editor.d.ts +385 -0
  31. package/dist/types/editor.d.ts.map +1 -0
  32. package/dist/types/editor.js +15 -0
  33. package/dist/types/editors.d.ts +56 -0
  34. package/dist/types/editors.d.ts.map +1 -0
  35. package/dist/types/editors.js +19 -0
  36. package/dist/types/extension.d.ts +744 -0
  37. package/dist/types/extension.d.ts.map +1 -0
  38. package/dist/types/extension.js +4 -0
  39. package/dist/types/index.d.ts +9 -0
  40. package/dist/types/index.d.ts.map +1 -0
  41. package/dist/types/index.js +8 -0
  42. package/dist/types/panel.d.ts +575 -0
  43. package/dist/types/panel.d.ts.map +1 -0
  44. package/dist/types/panel.js +14 -0
  45. package/dist/types/theme.d.ts +148 -0
  46. package/dist/types/theme.d.ts.map +1 -0
  47. package/dist/types/theme.js +7 -0
  48. package/dist/useEditorLifecycle.d.ts +166 -0
  49. package/dist/useEditorLifecycle.d.ts.map +1 -0
  50. package/dist/useEditorLifecycle.js +327 -0
  51. package/dist/validate.d.ts +31 -0
  52. package/dist/validate.d.ts.map +1 -0
  53. package/dist/validate.js +128 -0
  54. package/dist/vite.d.ts +92 -0
  55. package/dist/vite.d.ts.map +1 -0
  56. package/dist/vite.js +179 -0
  57. package/package.json +91 -0
@@ -0,0 +1,385 @@
1
+ /**
2
+ * Types for custom editor extensions.
3
+ *
4
+ * The EditorHost interface is the primary API for custom editors.
5
+ * External extensions should import from @nimbalyst/extension-sdk:
6
+ *
7
+ * ```typescript
8
+ * import type { EditorHost, EditorHostProps } from '@nimbalyst/extension-sdk';
9
+ * ```
10
+ *
11
+ * At runtime, Nimbalyst provides the implementation via the externals system.
12
+ * Your extension code imports from @nimbalyst/runtime, which is externalized
13
+ * and provided by the host.
14
+ */
15
+ import type { ExtensionStorage } from './panel.js';
16
+ /**
17
+ * Context that an editor pushes to the chat panel.
18
+ * When set, the chat UI shows an indicator and includes this context
19
+ * in the AI prompt when the user sends a message.
20
+ */
21
+ export interface EditorContext {
22
+ /** Short label shown in the chat indicator (e.g., "Screen: Login Page") */
23
+ label: string;
24
+ /**
25
+ * Descriptive context included in the AI prompt.
26
+ * Should describe what's selected and any relevant details.
27
+ */
28
+ description: string;
29
+ }
30
+ /**
31
+ * Menu item that can be added to the editor's "..." actions menu.
32
+ * Extensions can register these to add custom actions to the header bar.
33
+ */
34
+ export interface EditorMenuItem {
35
+ /** Display text for the menu item */
36
+ label: string;
37
+ /** Optional Material Symbols icon name (e.g., 'cloud_upload', 'settings') */
38
+ icon?: string;
39
+ /** Callback when the menu item is clicked */
40
+ onClick: () => void;
41
+ }
42
+ /**
43
+ * Configuration for diff mode display (AI edit review)
44
+ */
45
+ export interface DiffConfig {
46
+ /** Pre-edit content (the baseline before AI changes) */
47
+ originalContent: string;
48
+ /** AI's proposed content (what's now on disk) */
49
+ modifiedContent: string;
50
+ /** History tag ID for tracking this diff */
51
+ tagId: string;
52
+ /** AI session ID that made the edit */
53
+ sessionId: string;
54
+ }
55
+ /**
56
+ * Result of accepting/rejecting a diff
57
+ */
58
+ export interface DiffResult {
59
+ /** The content after user's decision */
60
+ content: string;
61
+ /** Whether user accepted or rejected the changes */
62
+ action: 'accept' | 'reject';
63
+ }
64
+ /**
65
+ * Host service for custom editors.
66
+ *
67
+ * Provides all communication between editor and host (TabEditor).
68
+ * Editors receive this as a prop and use it for all host interactions.
69
+ *
70
+ * @example
71
+ * ```tsx
72
+ * import type { EditorHostProps } from '@nimbalyst/extension-sdk';
73
+ *
74
+ * function MyEditor({ host }: EditorHostProps) {
75
+ * useEffect(() => {
76
+ * host.loadContent().then(content => {
77
+ * // Parse and display content
78
+ * });
79
+ * }, [host]);
80
+ *
81
+ * useEffect(() => {
82
+ * return host.onSaveRequested(async () => {
83
+ * const content = serialize(myData);
84
+ * await host.saveContent(content);
85
+ * });
86
+ * }, [host]);
87
+ * }
88
+ * ```
89
+ */
90
+ export interface EditorHost {
91
+ /** Absolute path to the file being edited */
92
+ readonly filePath: string;
93
+ /** File name (for display) */
94
+ readonly fileName: string;
95
+ /** Current theme */
96
+ readonly theme: string;
97
+ /** Whether this editor's tab is active */
98
+ readonly isActive: boolean;
99
+ /**
100
+ * Whether the editor is in read-only mode.
101
+ * When true, editors should hide editing UI (toolbars, inline editing,
102
+ * keyboard shortcuts for mutation) and only allow viewing interactions
103
+ * (pan, zoom, scroll, select text).
104
+ *
105
+ * Defaults to false (undefined treated as false for backwards compatibility).
106
+ * Set to true by the web share viewer's ReadOnlyEditorHost.
107
+ */
108
+ readonly readOnly?: boolean;
109
+ /**
110
+ * Subscribe to theme changes.
111
+ * Called when the application theme changes.
112
+ * Editor should update its visual appearance in response.
113
+ *
114
+ * @param callback Called with new theme when it changes
115
+ * @returns Unsubscribe function
116
+ */
117
+ onThemeChanged(callback: (theme: string) => void): () => void;
118
+ /** Workspace identifier (if in a workspace) */
119
+ readonly workspaceId?: string;
120
+ /**
121
+ * Load file content from disk as a string.
122
+ * Editor should call this on mount instead of receiving initialContent.
123
+ * For text files (code, markdown, HTML, etc.)
124
+ */
125
+ loadContent(): Promise<string>;
126
+ /**
127
+ * Load file content from disk as binary data.
128
+ * For binary files (PDFs, images, etc.)
129
+ * Returns an ArrayBuffer containing the raw file bytes.
130
+ */
131
+ loadBinaryContent(): Promise<ArrayBuffer>;
132
+ /**
133
+ * Subscribe to file change notifications.
134
+ * Called when the file changes on disk (external edit, AI edit, etc.)
135
+ *
136
+ * Editor decides whether to reload based on comparing against its
137
+ * last known disk state. Returns unsubscribe function.
138
+ *
139
+ * @param callback Called with new content when file changes
140
+ * @returns Unsubscribe function
141
+ */
142
+ onFileChanged(callback: (newContent: string) => void): () => void;
143
+ /**
144
+ * Report dirty state to host.
145
+ * Host uses this for tab indicator and save prompts.
146
+ */
147
+ setDirty(isDirty: boolean): void;
148
+ /**
149
+ * Save content to disk.
150
+ * Editor calls this when it wants to save (autosave, manual save, etc.)
151
+ * Host handles writing to disk and creating history snapshots.
152
+ * Content can be string (text files) or ArrayBuffer (binary files).
153
+ */
154
+ saveContent(content: string | ArrayBuffer): Promise<void>;
155
+ /**
156
+ * Subscribe to save requests from the host.
157
+ * Host calls this when autosave timer fires or user triggers manual save.
158
+ * Editor should call saveContent() in response.
159
+ * Returns unsubscribe function.
160
+ */
161
+ onSaveRequested(callback: () => void): () => void;
162
+ /**
163
+ * Open history dialog for this file.
164
+ */
165
+ openHistory(): void;
166
+ /**
167
+ * Subscribe to diff mode requests.
168
+ * Called when AI edits are pending review.
169
+ * Only implement if editor supports diff display.
170
+ *
171
+ * @param callback Called with diff config when diff should be shown
172
+ * @returns Unsubscribe function
173
+ */
174
+ onDiffRequested?(callback: (config: DiffConfig) => void): () => void;
175
+ /**
176
+ * Report diff result when user accepts or rejects.
177
+ * Host will save the resulting content and update history.
178
+ */
179
+ reportDiffResult?(result: DiffResult): void;
180
+ /**
181
+ * Check if diff mode is currently active.
182
+ */
183
+ isDiffModeActive?(): boolean;
184
+ /**
185
+ * Subscribe to diff mode being cleared externally.
186
+ * Called when the user accepts/rejects diff via the unified diff header.
187
+ * Editor should clear its diff state when this fires.
188
+ *
189
+ * @param callback Called when diff mode should be cleared
190
+ * @returns Unsubscribe function
191
+ */
192
+ onDiffCleared?(callback: () => void): () => void;
193
+ /**
194
+ * Request to toggle source mode on/off.
195
+ * When source mode is active, TabEditor renders Monaco to edit raw source
196
+ * instead of the custom editor's visual representation.
197
+ *
198
+ * Only available if supportsSourceMode is true.
199
+ */
200
+ toggleSourceMode?(): void;
201
+ /**
202
+ * Subscribe to source mode state changes.
203
+ * Called when source mode is toggled (either by editor request or external).
204
+ *
205
+ * @param callback Called with new source mode state
206
+ * @returns Unsubscribe function
207
+ */
208
+ onSourceModeChanged?(callback: (isSourceMode: boolean) => void): () => void;
209
+ /**
210
+ * Check if source mode is currently active.
211
+ */
212
+ isSourceModeActive?(): boolean;
213
+ /**
214
+ * Whether this editor supports source mode.
215
+ * If true, a "View Source" button will be available.
216
+ */
217
+ readonly supportsSourceMode?: boolean;
218
+ /**
219
+ * Get a configuration value for the extension.
220
+ * Only available if the extension has configuration contributions defined.
221
+ * Returns the workspace value if set, otherwise the user value, otherwise the default.
222
+ */
223
+ getConfig?<T>(key: string, defaultValue?: T): T;
224
+ /**
225
+ * Namespaced storage for persisting editor state.
226
+ * Automatically scoped to this extension.
227
+ * Use for preferences, history, cached data, etc.
228
+ */
229
+ readonly storage: ExtensionStorage;
230
+ /**
231
+ * Push context to the chat panel.
232
+ * When set, the chat UI shows an indicator (e.g., "+ Screen: Login Page")
233
+ * and includes the description in the AI prompt on the next message.
234
+ *
235
+ * Call with null to clear the context (e.g., when selection is deselected).
236
+ *
237
+ * @example
238
+ * ```tsx
239
+ * // Report selected screen in a project editor
240
+ * host.setEditorContext({
241
+ * label: 'Screen: Login Page',
242
+ * description: 'Selected screen "Login Page" (login.mockup.html) in the mockup project.'
243
+ * });
244
+ *
245
+ * // Clear when nothing is selected
246
+ * host.setEditorContext(null);
247
+ * ```
248
+ */
249
+ setEditorContext(context: EditorContext | null): void;
250
+ /**
251
+ * Register an imperative API that AI tools can use to interact with this editor.
252
+ *
253
+ * Call this when your editor's library has fully initialized and its API is ready.
254
+ * The host makes this API available to AI tool handlers via a central registry
255
+ * keyed by filePath. This enables AI tools to work against files that aren't
256
+ * open in a visible tab (the system mounts a hidden editor on demand).
257
+ *
258
+ * Call with `null` to unregister (e.g., in a cleanup function).
259
+ *
260
+ * @example
261
+ * ```tsx
262
+ * // In your editor component, register when the library callback fires:
263
+ * <MyLibrary
264
+ * onReady={(api) => {
265
+ * host.registerEditorAPI(api);
266
+ * }}
267
+ * />
268
+ *
269
+ * // Clean up on unmount:
270
+ * useEffect(() => {
271
+ * return () => host.registerEditorAPI(null);
272
+ * }, [host]);
273
+ * ```
274
+ */
275
+ registerEditorAPI(api: unknown | null): void;
276
+ /**
277
+ * Register menu items to appear in the editor's "..." actions menu.
278
+ * Items appear in a dedicated "Extension" section of the dropdown.
279
+ *
280
+ * Call this once during editor initialization.
281
+ * Call again with an empty array to remove all items.
282
+ *
283
+ * @param items Array of menu items to register
284
+ *
285
+ * @example
286
+ * ```tsx
287
+ * useEffect(() => {
288
+ * host.registerMenuItems([
289
+ * {
290
+ * label: 'Save to Cloud',
291
+ * icon: 'cloud_upload',
292
+ * onClick: () => saveToCloud()
293
+ * },
294
+ * {
295
+ * label: 'Export as PDF',
296
+ * icon: 'picture_as_pdf',
297
+ * onClick: () => exportPdf()
298
+ * }
299
+ * ]);
300
+ *
301
+ * return () => host.registerMenuItems([]); // Cleanup
302
+ * }, [host]);
303
+ * ```
304
+ */
305
+ registerMenuItems(items: EditorMenuItem[]): void;
306
+ }
307
+ /**
308
+ * Props for custom editor components using the EditorHost API.
309
+ */
310
+ export interface EditorHostProps {
311
+ /** Host service for all editor-host communication */
312
+ host: EditorHost;
313
+ }
314
+ /**
315
+ * @deprecated Use EditorHostProps instead.
316
+ *
317
+ * The old CustomEditorProps used a pull-based model where the host would call
318
+ * onGetContentReady to get content. The new EditorHost uses a push-based model
319
+ * where the editor calls host.saveContent() directly.
320
+ *
321
+ * Old pattern (deprecated):
322
+ * ```typescript
323
+ * function MyEditor({ initialContent, onContentChange, onGetContentReady }: CustomEditorProps) {
324
+ * useEffect(() => {
325
+ * onGetContentReady?.(() => getContent());
326
+ * }, []);
327
+ * }
328
+ * ```
329
+ *
330
+ * New pattern (recommended):
331
+ * ```typescript
332
+ * import type { EditorHostProps } from '@nimbalyst/runtime';
333
+ *
334
+ * function MyEditor({ host }: EditorHostProps) {
335
+ * useEffect(() => {
336
+ * return host.onSaveRequested(async () => {
337
+ * const content = getContent();
338
+ * await host.saveContent(content);
339
+ * });
340
+ * }, [host]);
341
+ * }
342
+ * ```
343
+ */
344
+ export interface CustomEditorProps {
345
+ /** Absolute path to the file being edited */
346
+ filePath: string;
347
+ /** File name (basename) */
348
+ fileName: string;
349
+ /** Initial file content (may be empty for binary files) */
350
+ initialContent: string;
351
+ /** Current theme */
352
+ theme: string;
353
+ /** Whether this editor tab is currently active/focused */
354
+ isActive: boolean;
355
+ /** Workspace path (if in a workspace) */
356
+ workspaceId?: string;
357
+ /**
358
+ * @deprecated Use host.setDirty() instead
359
+ */
360
+ onContentChange?: () => void;
361
+ /**
362
+ * @deprecated Use host.setDirty() instead
363
+ */
364
+ onDirtyChange?: (isDirty: boolean) => void;
365
+ /**
366
+ * @deprecated Use host.onSaveRequested() and host.saveContent() instead
367
+ */
368
+ onGetContentReady?: (getContentFn: () => string) => void;
369
+ /** Called when user requests to view file history */
370
+ onViewHistory?: () => void;
371
+ /** Called when user requests to rename the document */
372
+ onRenameDocument?: () => void;
373
+ }
374
+ /**
375
+ * For editors that support the Monaco-style wrapper interface.
376
+ */
377
+ export interface EditorWrapper {
378
+ /** Get current content */
379
+ getContent: () => string;
380
+ /** Set content programmatically */
381
+ setContent: (content: string) => void;
382
+ /** Focus the editor */
383
+ focus: () => void;
384
+ }
385
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/types/editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMnD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IAEd,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,6CAA6C;IAC7C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,wDAAwD;IACxD,eAAe,EAAE,MAAM,CAAC;IAExB,iDAAiD;IACjD,eAAe,EAAE,MAAM,CAAC;IAExB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IAEd,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAEhB,oDAAoD;IACpD,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,UAAU;IAGzB,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,8BAA8B;IAC9B,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,CAAC;IAElB,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAE7B;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAE3C;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;IAEzD,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAE3B,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,0BAA0B;IAC1B,UAAU,EAAE,MAAM,MAAM,CAAC;IAEzB,mCAAmC;IACnC,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtC,uBAAuB;IACvB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Types for custom editor extensions.
3
+ *
4
+ * The EditorHost interface is the primary API for custom editors.
5
+ * External extensions should import from @nimbalyst/extension-sdk:
6
+ *
7
+ * ```typescript
8
+ * import type { EditorHost, EditorHostProps } from '@nimbalyst/extension-sdk';
9
+ * ```
10
+ *
11
+ * At runtime, Nimbalyst provides the implementation via the externals system.
12
+ * Your extension code imports from @nimbalyst/runtime, which is externalized
13
+ * and provided by the host.
14
+ */
15
+ export {};
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Types for shared editor components.
3
+ *
4
+ * These types correspond to the MarkdownEditor and MonacoEditor components
5
+ * available from `@nimbalyst/runtime`. Extensions import the components at
6
+ * runtime (they're provided by the host via the externals system) and use
7
+ * these types for type checking.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import { MonacoEditor } from '@nimbalyst/runtime';
12
+ * import type { EditorHostProps, MonacoEditorProps } from '@nimbalyst/extension-sdk';
13
+ *
14
+ * export const MyEditor = ({ host }: EditorHostProps) => {
15
+ * return <MonacoEditor host={host} fileName={host.fileName} />;
16
+ * };
17
+ * ```
18
+ */
19
+ import type { EditorHost } from './editor.js';
20
+ export interface MonacoEditorConfig {
21
+ /** Theme for the editor */
22
+ theme?: string;
23
+ /** Extension theme ID for custom Monaco themes (e.g., 'sample-themes:solarized-light') */
24
+ extensionThemeId?: string;
25
+ /** Whether this editor's tab is active */
26
+ isActive?: boolean;
27
+ }
28
+ export interface MonacoEditorProps {
29
+ /** Host service for all editor-host communication */
30
+ host: EditorHost;
31
+ /** File name for language detection */
32
+ fileName: string;
33
+ /** Optional configuration */
34
+ config?: MonacoEditorConfig;
35
+ /** Callback when editor is ready (passes editor instance with diff controls) */
36
+ onEditorReady?: (editor: any) => void;
37
+ /** Callback when getContent function is available */
38
+ onGetContent?: (getContentFn: () => string) => void;
39
+ /** Callback when diff change count updates (for diff header UI) */
40
+ onDiffChangeCountUpdate?: (count: number) => void;
41
+ }
42
+ export interface MarkdownEditorConfig {
43
+ /** Whether the editor is read-only */
44
+ editable?: boolean;
45
+ /** Show the toolbar */
46
+ showToolbar?: boolean;
47
+ /** Show the debug tree view (dev mode only) */
48
+ showTreeView?: boolean;
49
+ }
50
+ export interface MarkdownEditorProps {
51
+ /** Host service for all editor-host communication */
52
+ host: EditorHost;
53
+ /** Optional configuration */
54
+ config?: MarkdownEditorConfig;
55
+ }
56
+ //# sourceMappingURL=editors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editors.d.ts","sourceRoot":"","sources":["../../src/types/editors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM9C,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,0FAA0F;IAC1F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,IAAI,EAAE,UAAU,CAAC;IAEjB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IAEjB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAE5B,gFAAgF;IAChF,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAEtC,qDAAqD;IACrD,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;IAEpD,mEAAmE;IACnE,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnD;AAMD,MAAM,WAAW,oBAAoB;IACnC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,uBAAuB;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,qDAAqD;IACrD,IAAI,EAAE,UAAU,CAAC;IAEjB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Types for shared editor components.
3
+ *
4
+ * These types correspond to the MarkdownEditor and MonacoEditor components
5
+ * available from `@nimbalyst/runtime`. Extensions import the components at
6
+ * runtime (they're provided by the host via the externals system) and use
7
+ * these types for type checking.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import { MonacoEditor } from '@nimbalyst/runtime';
12
+ * import type { EditorHostProps, MonacoEditorProps } from '@nimbalyst/extension-sdk';
13
+ *
14
+ * export const MyEditor = ({ host }: EditorHostProps) => {
15
+ * return <MonacoEditor host={host} fileName={host.fileName} />;
16
+ * };
17
+ * ```
18
+ */
19
+ export {};