lynx-console 0.2.3 → 0.3.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 +99 -22
- package/dist/index.cjs +87 -98
- package/dist/index.css +45 -243
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +87 -98
- package/dist/index.mjs.map +1 -1
- package/dist/setup.cjs +7 -3
- package/dist/setup.mjs +9 -5
- package/dist/setup.mjs.map +1 -1
- package/package.json +7 -8
- package/src/components/BottomSheet.css +2 -13
- package/src/components/BottomSheet.tsx +1 -1
- package/src/components/ConsolePanel.css +0 -84
- package/src/components/ConsolePanel.tsx +3 -2
- package/src/components/FloatingButton.css +1 -8
- package/src/components/FloatingButton.tsx +29 -35
- package/src/components/LogPanel.tsx +108 -48
- package/src/components/NetworkDetailSection.tsx +24 -12
- package/src/components/NetworkPanel.css +0 -53
- package/src/components/NetworkPanel.tsx +78 -34
- package/src/components/PerformancePanel.css +0 -64
- package/src/components/PerformancePanel.tsx +120 -48
- package/src/components/Tabs.css +1 -21
- package/src/components/Tabs.tsx +2 -2
- package/src/index.tsx +11 -2
- package/src/setup/_setupMainThreadConsole.ts +17 -4
- package/src/styles/ThemeContext.ts +1 -1
- package/src/styles/theme.ts +0 -14
- package/src/styles/tokens.css +40 -0
- package/src/components/FadeList.tsx +0 -31
- package/src/styles/getDimensionValue.ts +0 -7
- package/src/styles/tokens.json +0 -80
package/README.md
CHANGED
|
@@ -1,16 +1,37 @@
|
|
|
1
|
+
[한국어](https://github.com/daangn/lynx-console/blob/main/package/README_ko.md) | English
|
|
2
|
+
|
|
1
3
|
# lynx-console
|
|
2
4
|
|
|
3
5
|
An in-app developer console that can be embedded in Lynx apps. View console logs, network requests, and performance metrics in real time.
|
|
4
6
|
|
|
7
|
+
## Demo
|
|
8
|
+
|
|
9
|
+
https://github.com/user-attachments/assets/dcd874bf-ff2e-4a98-ae03-d83de5fae31c
|
|
10
|
+
|
|
11
|
+
<img width="450" height="450" alt="lynx_bundle_qrcode_fullscreen" src="https://github.com/user-attachments/assets/8bbb9bfe-df2b-436d-ad17-6e4eb4b672c9" />
|
|
12
|
+
|
|
13
|
+
Scan the QR code above with the [Lynx Explorer](https://lynxjs.org/guide/start/quick-start.html#via-lynx-explorer-app) app to try the demo.
|
|
14
|
+
|
|
5
15
|
## Features
|
|
6
16
|
|
|
7
|
-
- **Console Logs** — View output from `console.log`, `console.error`, and more in real time
|
|
8
|
-
- **Main Thread Console** — Capture logs from the main thread
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
17
|
+
- **Console Logs** — View output from `console.log`, `console.error`, and more in real time. Supports level filtering, keyword search, log clearing, and a built-in REPL
|
|
18
|
+
- **Main Thread Console** — Capture logs from the main thread alongside background thread logs
|
|
19
|
+
|
|
20
|
+
https://github.com/user-attachments/assets/539fe31a-aca4-468d-b673-3b070b21cd08
|
|
21
|
+
|
|
22
|
+
- **Network Monitor** — Inspect method, status, headers, request body, and response of `fetch` requests
|
|
23
|
+
|
|
24
|
+
https://github.com/user-attachments/assets/edda4778-ab8d-4cb9-a3c5-bd8c42c81bde
|
|
25
|
+
|
|
26
|
+
- **Performance Monitor** — Track FCP (First Contentful Paint) and other performance metrics with raw entry details
|
|
27
|
+
|
|
28
|
+
https://github.com/user-attachments/assets/d231bdf5-71bb-483f-9bdb-5843279c1308
|
|
29
|
+
|
|
30
|
+
- **Floating Button** — Displays the latest FCP value; tap to open the console, long-press and drag to reposition it
|
|
31
|
+
- **Resizable Panel** — Drag the handle to resize the console panel (200–700px); swipe down to dismiss
|
|
32
|
+
- **Tab Visibility** — Only tabs for initialized monitors are shown; uninitialized monitors are automatically hidden
|
|
33
|
+
- **Custom Tabs** — Add your own tabs to the console via the `customTabs` prop
|
|
12
34
|
- **Light/Dark Theme** support
|
|
13
|
-
- **Seed Design** based UI
|
|
14
35
|
|
|
15
36
|
## Installation
|
|
16
37
|
|
|
@@ -22,10 +43,29 @@ yarn add lynx-console
|
|
|
22
43
|
|
|
23
44
|
```bash
|
|
24
45
|
yarn add @lynx-js/react @lynx-js/types
|
|
46
|
+
yarn add -D @types/react
|
|
25
47
|
```
|
|
26
48
|
|
|
49
|
+
> **Note:** Each monitor requires the corresponding Lynx API to be available at runtime. If `lynx.fetch` is not present, `initNetworkMonitor()` will be skipped with a warning. Likewise, `initPerformanceMonitor()` requires `lynx.performance`.
|
|
50
|
+
|
|
27
51
|
## Usage
|
|
28
52
|
|
|
53
|
+
### 0. Configure Build (Required for iOS)
|
|
54
|
+
|
|
55
|
+
On iOS, the Lynx runtime (JSC) injects a separate `console` object that is different from `globalThis.console`. This means patches applied by `initLogMonitor()` won't take effect on iOS unless you explicitly replace the `console` identifier with `globalThis.console` at build time.
|
|
56
|
+
|
|
57
|
+
Add the following to your `lynx.config.ts`:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
export default defineConfig({
|
|
61
|
+
source: {
|
|
62
|
+
define: {
|
|
63
|
+
console: "globalThis.console",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
29
69
|
### 1. Initialize Monitors
|
|
30
70
|
|
|
31
71
|
Call the monitoring functions at your app's entry point. This setup must run **before** the `LynxConsole` component is rendered.
|
|
@@ -44,6 +84,8 @@ initNetworkMonitor();
|
|
|
44
84
|
initPerformanceMonitor();
|
|
45
85
|
```
|
|
46
86
|
|
|
87
|
+
> **Note:** `initLogMonitor()` must be called before `initMainThreadConsole()`, as the main thread console depends on the log monitor being initialized first.
|
|
88
|
+
|
|
47
89
|
### 2. Render the Component
|
|
48
90
|
|
|
49
91
|
```tsx
|
|
@@ -68,7 +110,31 @@ function App() {
|
|
|
68
110
|
{/* Your app content */}
|
|
69
111
|
<Suspense>
|
|
70
112
|
<LynxConsole theme="light" safeAreaInsetBottom="34px" />
|
|
71
|
-
|
|
113
|
+
</Suspense>
|
|
114
|
+
</view>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Adding Custom Tabs
|
|
120
|
+
|
|
121
|
+
You can add your own tabs to the console using the `customTabs` prop.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import LynxConsole, { type CustomTab } from "lynx-console";
|
|
125
|
+
|
|
126
|
+
const customTabs: CustomTab[] = [
|
|
127
|
+
{
|
|
128
|
+
key: "debug",
|
|
129
|
+
label: "Debug",
|
|
130
|
+
renderContent: () => <text>Custom debug content</text>,
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
function App() {
|
|
135
|
+
return (
|
|
136
|
+
<view>
|
|
137
|
+
<LynxConsole customTabs={customTabs} />
|
|
72
138
|
</view>
|
|
73
139
|
);
|
|
74
140
|
}
|
|
@@ -99,34 +165,45 @@ function App() {
|
|
|
99
165
|
<view>
|
|
100
166
|
<Suspense>
|
|
101
167
|
<LynxConsole ref={consoleRef} />
|
|
102
|
-
|
|
168
|
+
</Suspense>
|
|
103
169
|
</view>
|
|
104
170
|
);
|
|
105
171
|
}
|
|
106
172
|
```
|
|
107
173
|
|
|
174
|
+
You can also integrate it with a back press handler so that the console closes when the back button is pressed.
|
|
175
|
+
|
|
108
176
|
## API
|
|
109
177
|
|
|
110
178
|
### `LynxConsole` Props
|
|
111
179
|
|
|
112
|
-
| Prop
|
|
113
|
-
|
|
114
|
-
| `theme`
|
|
115
|
-
| `safeAreaInsetBottom` | `string`
|
|
180
|
+
| Prop | Type | Default | Description |
|
|
181
|
+
| --------------------- | ------------------- | ----------- | ------------------------------------------------ |
|
|
182
|
+
| `theme` | `"light" \| "dark"` | `"light"` | Console UI theme |
|
|
183
|
+
| `safeAreaInsetBottom` | `string` | `"50px"` | Bottom safe area inset |
|
|
184
|
+
| `customTabs` | `CustomTab[]` | `undefined` | Additional custom tabs to display in the console |
|
|
185
|
+
|
|
186
|
+
### `CustomTab`
|
|
187
|
+
|
|
188
|
+
| Property | Type | Description |
|
|
189
|
+
| --------------- | ----------------- | ------------------------------------- |
|
|
190
|
+
| `key` | `string` | Unique identifier for the tab |
|
|
191
|
+
| `label` | `string` | Tab label text |
|
|
192
|
+
| `renderContent` | `() => ReactNode` | Function that renders the tab content |
|
|
116
193
|
|
|
117
194
|
### `LynxConsoleHandle`
|
|
118
195
|
|
|
119
|
-
| Method
|
|
120
|
-
|
|
121
|
-
| `open()`
|
|
122
|
-
| `close()`
|
|
196
|
+
| Method | Description |
|
|
197
|
+
| ---------- | ----------------------------------- |
|
|
198
|
+
| `open()` | Opens the console |
|
|
199
|
+
| `close()` | Closes the console |
|
|
123
200
|
| `isOpen()` | Returns whether the console is open |
|
|
124
201
|
|
|
125
202
|
### Monitor Initialization Functions
|
|
126
203
|
|
|
127
|
-
| Function
|
|
128
|
-
|
|
129
|
-
| `initLogMonitor()`
|
|
130
|
-
| `initMainThreadConsole()`
|
|
131
|
-
| `initNetworkMonitor()`
|
|
132
|
-
| `initPerformanceMonitor()` | Collects performance metrics
|
|
204
|
+
| Function | Description |
|
|
205
|
+
| -------------------------- | --------------------------------------------- |
|
|
206
|
+
| `initLogMonitor()` | Captures `console.log`, `console.error`, etc. |
|
|
207
|
+
| `initMainThreadConsole()` | Captures console output from the main thread |
|
|
208
|
+
| `initNetworkMonitor()` | Intercepts and records `fetch` requests |
|
|
209
|
+
| `initPerformanceMonitor()` | Collects performance metrics |
|