@react-devtools-plus/scan 0.2.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,23 @@
1
+
2
+ 
3
+ > @react-devtools-plus/scan@0.2.0 build /Users/wangzhichao/办公/code/github/react-devtools/packages/react-devtools-scan
4
+ > tsup
5
+
6
+ CLI Building entry: {"index":"src/index.ts"}
7
+ CLI Using tsconfig: tsconfig.json
8
+ CLI tsup v8.5.1
9
+ CLI Using tsup config: /Users/wangzhichao/办公/code/github/react-devtools/packages/react-devtools-scan/tsup.config.ts
10
+ CLI Target: es2017
11
+ CLI Cleaning output folder
12
+ ESM Build start
13
+ CJS Build start
14
+ ESM dist/index.js 701.46 KB
15
+ ESM dist/index.js.map 1.25 MB
16
+ ESM ⚡️ Build success in 101ms
17
+ CJS dist/index.cjs 703.26 KB
18
+ CJS dist/index.cjs.map 1.25 MB
19
+ CJS ⚡️ Build success in 102ms
20
+ DTS Build start
21
+ DTS ⚡️ Build success in 990ms
22
+ DTS dist/index.d.ts 7.19 KB
23
+ DTS dist/index.d.cts 7.19 KB
@@ -0,0 +1,6 @@
1
+
2
+ 
3
+ > @react-devtools-plus/scan@0.0.1 prepare:type /Users/wangzhichao/办公/code/github/react-devtools/packages/react-devtools-scan
4
+ > tsc --declaration --emitDeclarationOnly --outDir dist
5
+
6
+  ELIFECYCLE  Command failed with exit code 129.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 webfansplz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # @react-devtools-plus/scan
2
+
3
+ React Scan integration layer for React DevTools.
4
+
5
+ ## Overview
6
+
7
+ This package provides a seamless integration between [react-scan](https://github.com/aidenybai/react-scan) and React DevTools, making it easy to add powerful performance analysis capabilities to your React applications.
8
+
9
+ ## Features
10
+
11
+ - 🚀 **Easy Setup**: Single function call to enable React Scan
12
+ - 🎨 **Flexible Integration**: Choose between overlay, panel, or both modes
13
+ - ⚙️ **Full Configuration**: Access to all react-scan options
14
+ - 🔧 **Runtime Control**: Start, stop, and configure scan at runtime
15
+ - 📦 **Type Safe**: Full TypeScript support
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pnpm add @react-devtools-plus/scan
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ### Basic Usage
26
+
27
+ ```typescript
28
+ import { initScan } from '@react-devtools-plus/scan';
29
+
30
+ // Initialize with defaults (development only)
31
+ initScan();
32
+ ```
33
+
34
+ ### Custom Configuration
35
+
36
+ ```typescript
37
+ import { initScan } from '@react-devtools-plus/scan';
38
+
39
+ const scanInstance = initScan({
40
+ enabled: true,
41
+ showToolbar: true,
42
+ animationSpeed: 'fast',
43
+ trackUnnecessaryRenders: true,
44
+ integrationMode: 'overlay',
45
+ });
46
+
47
+ // Control at runtime
48
+ scanInstance.stop();
49
+ scanInstance.start();
50
+ ```
51
+
52
+ ### With React DevTools Plugin
53
+
54
+ ```typescript
55
+ // vite.config.ts
56
+ import { defineConfig } from 'vite';
57
+ import { reactDevtools } from 'react-devtools/vite';
58
+
59
+ export default defineConfig({
60
+ plugins: [
61
+ reactDevtools({
62
+ scan: {
63
+ enabled: true,
64
+ showToolbar: true,
65
+ },
66
+ }),
67
+ ],
68
+ });
69
+ ```
70
+
71
+ ## API
72
+
73
+ ### `initScan(options?)`
74
+
75
+ Initialize React Scan with optional configuration.
76
+
77
+ **Parameters:**
78
+
79
+ - `options` (optional): `ReactDevtoolsScanOptions`
80
+
81
+ **Returns:** `ScanInstance`
82
+
83
+ ### `getScan()`
84
+
85
+ Get the current scan instance.
86
+
87
+ **Returns:** `ScanInstance | null`
88
+
89
+ ### `ScanInstance` Methods
90
+
91
+ - `getOptions()`: Get current scan options
92
+ - `setOptions(options)`: Update scan options at runtime
93
+ - `start()`: Start scanning
94
+ - `stop()`: Stop scanning
95
+ - `isActive()`: Check if scanning is active
96
+
97
+ ## Configuration Options
98
+
99
+ All [react-scan options](https://github.com/aidenybai/react-scan#options) are supported, plus:
100
+
101
+ ```typescript
102
+ interface ReactDevtoolsScanOptions {
103
+ // ... all react-scan options
104
+
105
+ /**
106
+ * Integration mode
107
+ * @default 'overlay'
108
+ */
109
+ integrationMode?: 'overlay' | 'panel' | 'both';
110
+
111
+ /**
112
+ * Sync state with DevTools panel
113
+ * @default true
114
+ */
115
+ syncWithDevtools?: boolean;
116
+ }
117
+ ```
118
+
119
+ ## Examples
120
+
121
+ ### Conditional Enabling
122
+
123
+ ```typescript
124
+ import { initScan } from '@react-devtools-plus/scan';
125
+
126
+ if (process.env.NODE_ENV === 'development') {
127
+ initScan({
128
+ enabled: true,
129
+ log: false,
130
+ });
131
+ }
132
+ ```
133
+
134
+ ### Runtime Control
135
+
136
+ ```typescript
137
+ import { getScan } from '@react-devtools-plus/scan';
138
+
139
+ // Later in your code...
140
+ const scan = getScan();
141
+
142
+ if (scan?.isActive()) {
143
+ // Temporarily disable for screenshot
144
+ scan.stop();
145
+ takeScreenshot();
146
+ scan.start();
147
+ }
148
+ ```
149
+
150
+ ### Custom Animation Speed
151
+
152
+ ```typescript
153
+ import { initScan } from '@react-devtools-plus/scan';
154
+
155
+ initScan({
156
+ animationSpeed: 'slow', // 'slow' | 'fast' | 'off'
157
+ });
158
+ ```
159
+
160
+ ## Integration with React DevTools
161
+
162
+ This package is designed to work seamlessly with the React DevTools plugin system. When used together, you get:
163
+
164
+ - Unified configuration through the DevTools plugin
165
+ - Automatic injection in development builds
166
+ - Coordinated UI between DevTools panel and Scan overlay
167
+
168
+ See [React DevTools Scan Integration Guide](../../REACT_SCAN_INTEGRATION.md) for more details.
169
+
170
+ ## License
171
+
172
+ MIT