@codespark/react 1.0.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.
@@ -0,0 +1,712 @@
1
+ import { Framework, Output } from "@codespark/framework";
2
+ import * as React$1 from "react";
3
+ import { ComponentProps, ComponentType, JSX, ReactElement, ReactNode, RefObject } from "react";
4
+ import { LoaderType } from "@codespark/framework/loaders";
5
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
6
+ import { Tabs } from "radix-ui";
7
+ import { ReactCodeMirrorProps, ReactCodeMirrorRef } from "@uiw/react-codemirror";
8
+ import { EditorProps } from "@monaco-editor/react";
9
+ import * as monaco from "monaco-editor";
10
+
11
+ //#region src/lib/editor-adapter/index.d.ts
12
+ declare enum EditorEngine {
13
+ Monaco = 0,
14
+ CodeMirror = 1,
15
+ }
16
+ interface EditorInstance {
17
+ [EditorEngine.Monaco]: monaco.editor.IStandaloneCodeEditor;
18
+ [EditorEngine.CodeMirror]: ReactCodeMirrorRef;
19
+ }
20
+ interface EditorAdapter<E extends EditorEngine = any> {
21
+ kind: E;
22
+ instance: EditorInstance[E];
23
+ getValue(): string;
24
+ setValue(value: string, addToHistory?: boolean): void;
25
+ format(): Promise<void>;
26
+ }
27
+ interface EditorEngineComponent<E extends EditorEngine = any, P = object, I = unknown> {
28
+ kind: E;
29
+ Component: ComponentType<P>;
30
+ createAdapter: (instance: I) => EditorAdapter<E>;
31
+ }
32
+ //#endregion
33
+ //#region src/components/editor/codemirror/index.d.ts
34
+ interface CodeMirrorProps extends ReactCodeMirrorProps {
35
+ readonly id?: string;
36
+ onMount?: (editor: ReactCodeMirrorRef) => void;
37
+ fontFamily?: string;
38
+ }
39
+ declare const CodeMirror: EditorEngineComponent<EditorEngine.CodeMirror, CodeMirrorProps, ReactCodeMirrorRef>;
40
+ //#endregion
41
+ //#region src/components/editor/monaco/index.d.ts
42
+ interface MonacoProps extends EditorProps {
43
+ readonly id?: string;
44
+ files?: Record<string, string>;
45
+ imports?: Record<string, string>;
46
+ }
47
+ declare const Monaco: EditorEngineComponent<EditorEngine.Monaco, MonacoProps, monaco.editor.IStandaloneCodeEditor>;
48
+ //#endregion
49
+ //#region src/lib/workspace/internals.d.ts
50
+ declare const INTERNAL_SUBSCRIBE: unique symbol;
51
+ declare const INTERNAL_REGISTER_EDITOR: unique symbol;
52
+ declare const INTERNAL_UNREGISTER_EDITOR: unique symbol;
53
+ declare const INTERNAL_BOUND: unique symbol;
54
+ declare const INTERNAL_SET_ID: unique symbol;
55
+ declare const INTERNAL_EMIT: unique symbol;
56
+ //#endregion
57
+ //#region src/lib/workspace/opfs.d.ts
58
+ declare abstract class OPFS {
59
+ abstract id: string;
60
+ protected dir: FileSystemDirectoryHandle | null;
61
+ initOPFS(files: Record<string, string>): Promise<void>;
62
+ protected writeToOPFS(path: string, content: string): Promise<void>;
63
+ protected getFileHandle(path: string): Promise<FileSystemFileHandle | null>;
64
+ }
65
+ //#endregion
66
+ //#region src/lib/workspace/index.d.ts
67
+ interface CollectResult {
68
+ entry: {
69
+ code: string;
70
+ locals: string[];
71
+ imports: string[];
72
+ };
73
+ files: Record<string, string>;
74
+ }
75
+ type FileTreeNode = FileNode | FolderNode;
76
+ interface FileNode {
77
+ type: 'file';
78
+ name: string;
79
+ path: string;
80
+ code: string;
81
+ language?: string;
82
+ }
83
+ interface FolderNode {
84
+ type: 'folder';
85
+ name: string;
86
+ path: string;
87
+ children?: FileTreeNode[];
88
+ }
89
+ interface WorkspaceInit {
90
+ /**
91
+ * Unique identifier for the workspace instance
92
+ */
93
+ id?: string;
94
+ /**
95
+ * Framework to use for code analysis and compilation.
96
+ * Can be a Framework instance, a Framework constructor, or a registered framework name
97
+ */
98
+ framework?: Framework | (new () => Framework) | string;
99
+ /**
100
+ * Entry file path, the main file to compile and render
101
+ *
102
+ * @example './App.tsx'
103
+ */
104
+ entry: string;
105
+ /**
106
+ * Initial files mapping, where keys are file paths and values are file contents
107
+ */
108
+ files: Record<string, string>;
109
+ /**
110
+ * Whether to use Origin Private File System (OPFS) for file persistence
111
+ *
112
+ * @default false
113
+ */
114
+ OPFS?: boolean;
115
+ }
116
+ interface WorkspaceEvent {
117
+ /**
118
+ * Fired when code compilation succeeds
119
+ *
120
+ * @param code - The compiled code string
121
+ */
122
+ compiled: (code: string) => void;
123
+ /**
124
+ * Fired when code compilation fails
125
+ *
126
+ * @param error - The compilation error
127
+ */
128
+ compileError: (error: Error) => void;
129
+ /**
130
+ * Fired when a single file is changed
131
+ *
132
+ * @param path - The file path that was changed
133
+ * @param content - The new file content
134
+ */
135
+ fileChange: (path: string, content: string) => void;
136
+ /**
137
+ * Fired when all files are replaced via setFiles()
138
+ *
139
+ * @param files - The new files mapping
140
+ */
141
+ filesChange: (files: Record<string, string>) => void;
142
+ /**
143
+ * Fired when a file or folder is renamed
144
+ *
145
+ * @param oldPath - The original file path
146
+ * @param newPath - The new file path
147
+ */
148
+ fileRename: (oldPath: string, newPath: string) => void;
149
+ /**
150
+ * Fired when a file or folder is deleted
151
+ *
152
+ * @param path - The deleted file path
153
+ */
154
+ fileDelete: (path: string) => void;
155
+ /**
156
+ * Fired when the currently active file changes
157
+ *
158
+ * @param file - The new current file node
159
+ */
160
+ currentFileChange: (file: FileNode) => void;
161
+ }
162
+ /**
163
+ * Workspace - Core class for managing files, compilation, and editor state.
164
+ *
165
+ * Manages a virtual file system for code editing and live preview.
166
+ * Handles file CRUD operations, tracks the currently active file,
167
+ * and emits events for file changes and compilation results.
168
+ * Supports optional Origin Private File System (OPFS) for persistence.
169
+ */
170
+ declare class Workspace extends OPFS {
171
+ private config;
172
+ id: string;
173
+ initialFiles: Record<string, string>;
174
+ private listeners;
175
+ private events;
176
+ private _currentFile;
177
+ private _editors;
178
+ private _bound;
179
+ constructor(config: WorkspaceInit);
180
+ private notifyListeners;
181
+ private createEntryFileNode;
182
+ private normalizePath;
183
+ private getFile;
184
+ get entry(): string;
185
+ get files(): Record<string, string>;
186
+ get framework(): string | Framework | (new () => Framework);
187
+ get currentFile(): FileNode;
188
+ get editors(): ReadonlyMap<string, EditorAdapter>;
189
+ setFile(path: string, content: string): void;
190
+ setFiles(files: Record<string, string>): void;
191
+ renameFile(oldPath: string, newName: string): void;
192
+ deleteFile(path: string): void;
193
+ setCurrentFile(path: string): void;
194
+ on<E extends keyof WorkspaceEvent>(event: E, callback: WorkspaceEvent[E]): () => void;
195
+ off<E extends keyof WorkspaceEvent>(event: E, callback: WorkspaceEvent[E]): void;
196
+ private emit;
197
+ [INTERNAL_SUBSCRIBE](listener: () => void): () => boolean;
198
+ [INTERNAL_REGISTER_EDITOR](id: string, editor: EditorAdapter): void;
199
+ [INTERNAL_UNREGISTER_EDITOR](id: string): void;
200
+ [INTERNAL_BOUND](): boolean;
201
+ [INTERNAL_SET_ID](id: string): void;
202
+ [INTERNAL_EMIT]<E extends keyof WorkspaceEvent>(event: E, ...args: Parameters<WorkspaceEvent[E]>): void;
203
+ }
204
+ interface WorkspaceDerivedState {
205
+ /**
206
+ * Hierarchical file tree structure for rendering file explorer
207
+ */
208
+ fileTree: FileTreeNode[];
209
+ /**
210
+ * Compiled code string ready for execution in the preview iframe
211
+ */
212
+ compiled: string;
213
+ /**
214
+ * Compilation error if the code failed to compile, null otherwise
215
+ */
216
+ compileError: Error | null;
217
+ /**
218
+ * Vendor resources extracted from the compilation process
219
+ */
220
+ vendor: {
221
+ /**
222
+ * ES modules extracted from the code
223
+ */
224
+ modules: Output<LoaderType.ESModule>[];
225
+ /**
226
+ * Style resources to inject into the preview
227
+ */
228
+ styles: Output<LoaderType.Style>[];
229
+ /**
230
+ * Script resources to inject into the preview
231
+ */
232
+ scripts: Output<LoaderType.Script>[];
233
+ /**
234
+ * Import map for external dependencies
235
+ */
236
+ imports: Record<string, string>;
237
+ };
238
+ }
239
+ interface UseWorkspaceReturn extends WorkspaceDerivedState {
240
+ /**
241
+ * Current files in the workspace, where keys are file paths and values are file contents
242
+ */
243
+ files: Record<string, string>;
244
+ /**
245
+ * Currently active file in the editor
246
+ */
247
+ currentFile: FileNode;
248
+ /**
249
+ * The Workspace instance for programmatic control
250
+ */
251
+ workspace: Workspace;
252
+ }
253
+ /**
254
+ * Hook to manage workspace state and compilation.
255
+ * Provides reactive access to files, compilation results, and workspace methods.
256
+ *
257
+ * @param init - WorkspaceInit config object or existing Workspace instance
258
+ * @returns Workspace state including files, compiled code, and the workspace instance
259
+ */
260
+ declare function useWorkspace(init?: WorkspaceInit | Workspace): UseWorkspaceReturn;
261
+ /**
262
+ * Configuration options for createWorkspace function
263
+ */
264
+ interface CreateWorkspaceConfig extends Pick<WorkspaceInit, 'id' | 'framework'> {
265
+ /**
266
+ * Entry file name/path
267
+ *
268
+ * @default './App.tsx'
269
+ */
270
+ name?: string;
271
+ /**
272
+ * Code processing mode:
273
+ * - 'raw': Use the raw scanned code as-is
274
+ * - 'source': Use only the source file content
275
+ * - 'packed': Bundle imports, locals, and component into a single file
276
+ *
277
+ * @default 'packed'
278
+ */
279
+ mode?: 'raw' | 'source' | 'packed';
280
+ }
281
+ /**
282
+ * Creates a Workspace instance from a React component or element.
283
+ * Typically used with the rollup plugin to create workspaces from components.
284
+ *
285
+ * @param this - Context containing scanned code information (injected by rollup plugin)
286
+ * @param source - React component or element to create workspace from
287
+ * @param config - Configuration options
288
+ * @returns A new Workspace instance
289
+ *
290
+ * @example
291
+ * ```tsx
292
+ * // Used with rollup plugin
293
+ * const workspace = createWorkspace(MyComponent, {
294
+ * name: './App.tsx',
295
+ * mode: 'packed'
296
+ * });
297
+ * ```
298
+ */
299
+ declare function createWorkspace(this: {
300
+ __scanned?: CollectResult;
301
+ } | void, source: ComponentType | ReactElement, config?: CreateWorkspaceConfig): Workspace;
302
+ //#endregion
303
+ //#region src/context/index.d.ts
304
+ interface ConfigContextValue {
305
+ /**
306
+ * Theme mode for the editor and preview
307
+ *
308
+ * @default 'light'
309
+ */
310
+ theme?: 'light' | 'dark';
311
+ /**
312
+ * Global import map for external dependencies, where keys are module names and values are CDN URLs
313
+ *
314
+ * @example
315
+ * ```tsx
316
+ * <ConfigProvider imports={{ 'lodash': 'https://esm.sh/lodash' }}>
317
+ * ...
318
+ * </ConfigProvider>
319
+ * ```
320
+ */
321
+ imports?: Record<string, string>;
322
+ /**
323
+ * Font family for the code editor
324
+ *
325
+ * @default 'Fira Code'
326
+ */
327
+ fontFamily?: string;
328
+ /**
329
+ * Default editor engine component to use (Monaco or CodeMirror)
330
+ *
331
+ * @default CodeMirror
332
+ */
333
+ editor?: typeof CodeMirror | typeof Monaco;
334
+ }
335
+ interface CodesparkContextValue extends ConfigContextValue, WorkspaceDerivedState, Pick<WorkspaceInit, 'framework'> {
336
+ workspace?: Workspace;
337
+ files: Record<string, string>;
338
+ currentFile: FileNode;
339
+ }
340
+ interface ConfigProviderProps extends ConfigContextValue {
341
+ children?: ReactNode;
342
+ }
343
+ declare function ConfigProvider(props: ConfigProviderProps): react_jsx_runtime1.JSX.Element;
344
+ interface CodesparkProviderProps extends Omit<CodesparkContextValue, 'files' | 'currentFile' | keyof WorkspaceDerivedState> {
345
+ children?: ReactNode;
346
+ }
347
+ /**
348
+ * CodesparkProvider - A context provider that shares workspace state and configuration.
349
+ *
350
+ * Provides workspace instance, theme, framework type, and import maps to child components.
351
+ * Required when using CodesparkEditor, CodesparkPreview, or CodesparkFileExplorer independently.
352
+ * Automatically manages workspace state synchronization across all child components.
353
+ */
354
+ declare function CodesparkProvider(props: CodesparkProviderProps): react_jsx_runtime1.JSX.Element;
355
+ //#endregion
356
+ //#region src/components/editor/index.d.ts
357
+ type ToolboxItemId = 'reset' | 'format' | 'copy';
358
+ interface ToolboxItemConfig {
359
+ tooltip?: string;
360
+ icon?: ReactNode;
361
+ asChild?: boolean;
362
+ onClick?: (editor: EditorAdapter | null) => void;
363
+ render?: (editor: EditorAdapter | null) => ReactNode;
364
+ }
365
+ interface CodesparkEditorBaseProps extends Pick<ConfigContextValue, 'theme'> {
366
+ /**
367
+ * Unique identifier for the editor instance
368
+ */
369
+ readonly id?: string;
370
+ /**
371
+ * Initial code content for the editor
372
+ */
373
+ value?: string;
374
+ /**
375
+ * CSS class name for the editor element
376
+ */
377
+ className?: string;
378
+ /**
379
+ * Workspace instance to use for file management and compilation
380
+ */
381
+ workspace?: Workspace;
382
+ /**
383
+ * Toolbar configuration. Set to false to hide, true to show default tools, or pass a custom array of tool items
384
+ *
385
+ * @default ['reset', 'format', 'copy']
386
+ */
387
+ toolbox?: boolean | (ToolboxItemId | ToolboxItemConfig | ReactElement)[];
388
+ /**
389
+ * Props to pass to the container div element
390
+ */
391
+ containerProps?: ComponentProps<'div'>;
392
+ /**
393
+ * Debounce wait time in milliseconds for triggering workspace updates on code changes
394
+ *
395
+ * @default 500
396
+ */
397
+ debounceWait?: number;
398
+ }
399
+ interface CodesparkEditorEngineProps {
400
+ [EditorEngine.Monaco]: Pick<MonacoProps, 'width' | 'height' | 'onChange' | 'onMount' | 'wrapperProps' | 'options'>;
401
+ [EditorEngine.CodeMirror]: Pick<CodeMirrorProps, 'width' | 'height' | 'extensions' | 'onChange' | 'onMount' | 'readOnly' | 'fontFamily' | 'basicSetup'>;
402
+ }
403
+ type CodesparkEditorEngineComponents = typeof Monaco | typeof CodeMirror;
404
+ type CodesparkEditorProps<E extends EditorEngine = EditorEngine.CodeMirror> = CodesparkEditorBaseProps & CodesparkEditorEngineProps[E];
405
+ /**
406
+ * CodesparkEditor - A flexible code editor component supporting multiple editor engines.
407
+ *
408
+ * Supports both Monaco Editor and CodeMirror as the underlying editor engine.
409
+ * Integrates with Workspace for file management and automatic compilation.
410
+ * Includes a customizable toolbar with reset, format, and copy functionality.
411
+ */
412
+ declare function CodesparkEditor(props: CodesparkEditorProps<EditorEngine.CodeMirror> & {
413
+ editor?: typeof CodeMirror;
414
+ }): JSX.Element;
415
+ declare function CodesparkEditor(props: CodesparkEditorProps<EditorEngine.Monaco> & {
416
+ editor: typeof Monaco;
417
+ }): JSX.Element;
418
+ declare function CodesparkEditor<E extends EditorEngine = never>(props: CodesparkEditorProps<E>): JSX.Element;
419
+ //#endregion
420
+ //#region src/components/preview/index.d.ts
421
+ interface OnConsoleData {
422
+ /**
423
+ * The console method level (e.g., 'log', 'warn', 'error', 'info', 'debug')
424
+ */
425
+ level: string;
426
+ /**
427
+ * The arguments passed to the console method
428
+ */
429
+ args: unknown[];
430
+ /**
431
+ * Whether this is a duplicate of a previous console call
432
+ */
433
+ duplicate?: boolean;
434
+ }
435
+ interface CodesparkPreviewProps extends ConfigContextValue, Pick<WorkspaceInit, 'framework'> {
436
+ /**
437
+ * Source code to preview. Used when not providing a workspace instance
438
+ */
439
+ code?: string;
440
+ /**
441
+ * Workspace instance to use for compilation and file management
442
+ */
443
+ workspace?: Workspace;
444
+ /**
445
+ * CSS class name for the preview container
446
+ */
447
+ className?: string;
448
+ /**
449
+ * Whether to enable Tailwind CSS support in the preview
450
+ *
451
+ * @default true
452
+ */
453
+ tailwindcss?: boolean;
454
+ /**
455
+ * Child elements to inject into the preview iframe, such as Script, Style, Link components
456
+ *
457
+ * @example
458
+ * ```tsx
459
+ * <CodesparkPreview>
460
+ * <Script src="https://example.com/script.js" />
461
+ * <Style>{`.custom { color: red; }`}</Style>
462
+ * </CodesparkPreview>
463
+ * ```
464
+ */
465
+ children?: ReactNode;
466
+ /**
467
+ * Height of the preview area. Accepts a number (pixels) or CSS string (e.g., '200px', '50%')
468
+ *
469
+ * @default 200
470
+ */
471
+ height?: string | number;
472
+ /**
473
+ * Callback fired when a runtime error occurs in the preview
474
+ */
475
+ onError?: (error: unknown) => void;
476
+ /**
477
+ * Callback fired when the preview iframe is loaded and ready
478
+ */
479
+ onLoad?: (iframe: HTMLIFrameElement) => void;
480
+ /**
481
+ * Callback fired when the preview has finished rendering
482
+ */
483
+ onRendered?: () => void;
484
+ /**
485
+ * Callback fired when console methods are called in the preview.
486
+ * Useful for capturing and displaying console output
487
+ */
488
+ onConsole?: (data: OnConsoleData) => void;
489
+ }
490
+ /**
491
+ * CodesparkPreview - A sandboxed preview component that renders compiled code in an iframe.
492
+ *
493
+ * Executes compiled React code in an isolated iframe environment with ES module support.
494
+ * Supports Tailwind CSS, custom scripts/styles injection, and console output capture.
495
+ * Displays a loading indicator during code compilation and execution.
496
+ */
497
+ declare function CodesparkPreview(props: CodesparkPreviewProps): react_jsx_runtime1.JSX.Element;
498
+ //#endregion
499
+ //#region src/ui/tabs.d.ts
500
+ declare function Tabs$1({
501
+ className,
502
+ ...props
503
+ }: React$1.ComponentProps<typeof Tabs.Root>): react_jsx_runtime1.JSX.Element;
504
+ //#endregion
505
+ //#region src/components/file-explorer/index.d.ts
506
+ interface FileExplorerItemRenderContext {
507
+ node: FileTreeNode;
508
+ depth: number;
509
+ isSelected: boolean;
510
+ isOpen?: boolean;
511
+ }
512
+ interface CodesparkFileExplorerProps extends React.ComponentPropsWithoutRef<typeof Tabs$1> {
513
+ /**
514
+ * Additional CSS class name(s) to apply to the file explorer container.
515
+ */
516
+ className?: string;
517
+ /**
518
+ * Whether folders should be expanded by default.
519
+ *
520
+ * @default false
521
+ */
522
+ defaultOpen?: boolean;
523
+ /**
524
+ * Custom render function for file tree items.
525
+ * Return a ReactNode to replace the default content (icon and name).
526
+ * Return undefined or null to use the default rendering.
527
+ */
528
+ renderItem?: (context: FileExplorerItemRenderContext) => ReactNode;
529
+ }
530
+ /**
531
+ * CodesparkFileExplorer - A file tree explorer component for navigating multi-file workspaces.
532
+ *
533
+ * Displays a hierarchical view of files and folders in the workspace.
534
+ * Supports file selection to switch the active file in the editor.
535
+ * Automatically sorts items with folders first, then files alphabetically.
536
+ */
537
+ declare const CodesparkFileExplorer: React$1.ForwardRefExoticComponent<CodesparkFileExplorerProps & React$1.RefAttributes<HTMLDivElement>>;
538
+ //#endregion
539
+ //#region src/components/inject/index.d.ts
540
+ interface StyleProps extends Omit<React.StyleHTMLAttributes<HTMLStyleElement>, 'children'> {
541
+ children?: string;
542
+ }
543
+ /**
544
+ * Style - Injects custom CSS styles into the preview iframe.
545
+ *
546
+ * A declarative component for adding inline styles to the sandboxed preview.
547
+ * Renders nothing in the React tree but injects a `<style>` tag into the iframe.
548
+ *
549
+ * @example
550
+ * ```tsx
551
+ * <CodesparkPreview>
552
+ * <Style>{`.custom { color: red; }`}</Style>
553
+ * </CodesparkPreview>
554
+ * ```
555
+ */
556
+ declare function Style(_props: StyleProps): null;
557
+ interface ScriptProps extends Omit<React.ScriptHTMLAttributes<HTMLScriptElement>, 'children'> {
558
+ children?: string;
559
+ }
560
+ /**
561
+ * Script - Injects custom JavaScript into the preview iframe.
562
+ *
563
+ * A declarative component for adding inline or external scripts to the sandboxed preview.
564
+ * Renders nothing in the React tree but injects a `<script>` tag into the iframe.
565
+ *
566
+ * @example
567
+ * ```tsx
568
+ * // Inline script
569
+ * <CodesparkPreview>
570
+ * <Script>{`console.log('Hello from preview');`}</Script>
571
+ * </CodesparkPreview>
572
+ *
573
+ * // External script
574
+ * <CodesparkPreview>
575
+ * <Script src="https://example.com/script.js" />
576
+ * </CodesparkPreview>
577
+ * ```
578
+ */
579
+ declare function Script(_props: ScriptProps): null;
580
+ interface LinkProps extends React.LinkHTMLAttributes<HTMLLinkElement> {}
581
+ /**
582
+ * Link - Injects external resources into the preview iframe.
583
+ *
584
+ * A declarative component for adding `<link>` tags to the sandboxed preview.
585
+ * Commonly used for external stylesheets, fonts, or other linked resources.
586
+ * Renders nothing in the React tree but injects a `<link>` tag into the iframe.
587
+ *
588
+ * @example
589
+ * ```tsx
590
+ * // External stylesheet
591
+ * <CodesparkPreview>
592
+ * <Link rel="stylesheet" href="https://example.com/styles.css" />
593
+ * </CodesparkPreview>
594
+ *
595
+ * // Google Fonts
596
+ * <CodesparkPreview>
597
+ * <Link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter" />
598
+ * </CodesparkPreview>
599
+ * ```
600
+ */
601
+ declare function Link(_props: LinkProps): null;
602
+ //#endregion
603
+ //#region src/index.d.ts
604
+ interface CodesparkProps extends Pick<ConfigContextValue, 'theme'>, Pick<CodesparkContextValue, 'framework' | 'imports'>, Pick<CodesparkEditorProps, 'toolbox'>, Pick<CodesparkPreviewProps, 'tailwindcss' | 'onConsole' | 'onError' | 'children'> {
605
+ /**
606
+ * Source code content for single-file mode
607
+ *
608
+ * @example
609
+ * ```tsx
610
+ * <Codespark code="export default () => <div>Hello</div>" />
611
+ * ```
612
+ */
613
+ code?: string;
614
+ /**
615
+ * File mapping for multi-file mode, where keys are file paths and values are file contents
616
+ *
617
+ * @example
618
+ * ```tsx
619
+ * <Codespark files={{ './App.tsx': 'export default () => <div>Hello</div>', './utils.ts': 'export const foo = 1' }} />
620
+ * ```
621
+ */
622
+ files?: Record<string, string>;
623
+ /**
624
+ * Entry file path
625
+ *
626
+ * @default './App.tsx'
627
+ */
628
+ name?: string;
629
+ /**
630
+ * CSS class name for the container
631
+ */
632
+ className?: string;
633
+ /**
634
+ * Whether to show the code editor
635
+ *
636
+ * @default true
637
+ */
638
+ showEditor?: boolean;
639
+ /**
640
+ * Whether to show the preview area
641
+ *
642
+ * @default true
643
+ */
644
+ showPreview?: boolean;
645
+ /**
646
+ * Whether to show the file explorer
647
+ *
648
+ * @default true
649
+ */
650
+ showFileExplorer?: boolean;
651
+ /**
652
+ * Whether to set the editor to read-only mode
653
+ *
654
+ * @default false
655
+ */
656
+ readonly?: boolean;
657
+ /**
658
+ * Whether the file explorer is expanded by default. When not set, it is automatically determined based on the number of files
659
+ */
660
+ defaultExpanded?: boolean;
661
+ /**
662
+ * Ref to get the Workspace instance for external control
663
+ *
664
+ * @example
665
+ * ```tsx
666
+ * const workspaceRef = useRef<Workspace | null>(null);
667
+ * <Codespark getWorkspace={workspaceRef} />
668
+ * ```
669
+ */
670
+ getWorkspace?: RefObject<Workspace | null>;
671
+ /**
672
+ * Editor engine component, supports Monaco or CodeMirror
673
+ *
674
+ * @default CodeMirror
675
+ */
676
+ editor?: CodesparkEditorEngineComponents;
677
+ /**
678
+ * Editor height. Accepts a number (pixels) or CSS string (e.g., '200px', '50%')
679
+ *
680
+ * @default 200
681
+ */
682
+ editorHeight?: string | number;
683
+ /**
684
+ * Preview area height. Accepts a number (pixels) or CSS string (e.g., '200px', '50%')
685
+ *
686
+ * @default 200
687
+ */
688
+ previewHeight?: string | number;
689
+ /**
690
+ * Layout orientation of the editor and preview areas.
691
+ * - `vertical`: Preview on top, editor on bottom
692
+ * - `horizontal`: Editor on left (2/3 width), preview on right (1/3 width)
693
+ *
694
+ * @default 'vertical'
695
+ */
696
+ orientation?: 'vertical' | 'horizontal';
697
+ }
698
+ /**
699
+ * Codespark - A browser-based React code playground with live preview.
700
+ *
701
+ * This component integrates a code editor, file explorer, and preview area
702
+ * to provide a complete interactive code demonstration experience.
703
+ * Supports both single-file mode (via `code` prop) and multi-file mode (via `files` prop).
704
+ */
705
+ declare function Codespark(props: CodesparkProps): react_jsx_runtime1.JSX.Element;
706
+ declare const useMDXComponents: () => {
707
+ Codespark: typeof Codespark;
708
+ CodesparkEditor: typeof CodesparkEditor;
709
+ CodesparkPreview: typeof CodesparkPreview;
710
+ };
711
+ //#endregion
712
+ export { Codespark, CodesparkEditor, CodesparkEditorBaseProps, CodesparkEditorEngineComponents, CodesparkEditorEngineProps, CodesparkEditorProps, CodesparkFileExplorer, CodesparkFileExplorerProps, CodesparkPreview, CodesparkPreviewProps, CodesparkProps, CodesparkProvider, type CodesparkProviderProps, ConfigProvider, type ConfigProviderProps, CreateWorkspaceConfig, EditorAdapter, EditorEngine, EditorEngineComponent, FileExplorerItemRenderContext, FileNode, FileTreeNode, FolderNode, Link, type LinkProps, OnConsoleData, Script, type ScriptProps, Style, type StyleProps, ToolboxItemConfig, UseWorkspaceReturn, Workspace, WorkspaceDerivedState, WorkspaceEvent, WorkspaceInit, createWorkspace, useMDXComponents, useWorkspace };