@react-trace-enhancer/plugin-preview 0.0.1

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.
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # @react-trace-enhancer/plugin-preview
2
+
3
+ Monaco-based source preview plugin for `@react-trace-enhancer/core`.
4
+
5
+ This package adds a toolbar control for connecting the current project folder and an action-panel preview for the selected source file.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pnpm add --dev @react-trace-enhancer/core @react-trace-enhancer/ui-components @react-trace-enhancer/plugin-preview
11
+ ```
12
+
13
+ If you are already using `@react-trace-enhancer/kit`, this plugin is included there by default.
14
+
15
+ ## Usage
16
+
17
+ ```tsx
18
+ import { Trace } from '@react-trace-enhancer/core'
19
+ import { PreviewPlugin } from '@react-trace-enhancer/plugin-preview'
20
+
21
+ import App from './App'
22
+
23
+ export function AppWithTrace() {
24
+ return (
25
+ <>
26
+ <App />
27
+ <Trace
28
+ root={import.meta.env.VITE_ROOT}
29
+ plugins={[PreviewPlugin({ theme: 'one-dark-pro' })]}
30
+ />
31
+ </>
32
+ )
33
+ }
34
+ ```
35
+
36
+ `root` should be the absolute project root passed to Trace so the plugin can resolve relative file paths for comments.
37
+
38
+ ## What it adds
39
+
40
+ - A toolbar button for project-folder access.
41
+ - An action-panel source preview for the currently selected component source.
42
+ - An inline Monaco editor with syntax highlighting.
43
+ - Optional save and expand controls when editing is enabled.
44
+ - A plugin settings UI for preview theme and editing mode.
45
+
46
+ ## Folder access expectations
47
+
48
+ The preview plugin reads files from the project through Trace's file-system service, so users must grant folder access before the preview can load file contents.
49
+
50
+ - Pass the absolute project root to `<Trace root="..." />`.
51
+ - When prompted, select the same project folder that contains the source files Trace resolves.
52
+ - If a root path is available, the plugin copies that path to the clipboard to make the folder picker easier to use.
53
+ - Until access is granted, the toolbar button and action panel show the access flow instead of a live file preview.
54
+ - When editing is enabled, saves are written back through the same file-system access.
55
+
56
+ If you only want inspection without file writes, start the plugin in read-only mode with `disabled: true`.
57
+
58
+ ## Options
59
+
60
+ `PreviewPlugin(options?: PreviewPluginOptions)`
61
+
62
+ ```ts
63
+ interface PreviewPluginOptions {
64
+ disabled?: boolean
65
+ theme?: BundledTheme
66
+ }
67
+ ```
68
+
69
+ - `disabled` — defaults to `false`. Starts the preview in read-only mode and removes editing controls.
70
+ - `theme` — defaults to `'one-dark-pro'`. Accepts any bundled Shiki theme id.
71
+
72
+ ## Settings
73
+
74
+ The plugin also contributes a settings panel inside Trace where users can:
75
+
76
+ - toggle code editing on or off
77
+ - switch the preview theme
78
+
79
+ These controls let users adjust preview behavior without changing the plugin registration code.