lynx-console 0.0.0 → 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 +132 -0
- package/package.json +8 -1
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# lynx-console
|
|
2
|
+
|
|
3
|
+
An in-app developer console that can be embedded in Lynx apps. View console logs, network requests, and performance metrics in real time.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
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
|
+
- **Network Monitor** — Inspect method, headers, body, and response of `fetch` requests
|
|
10
|
+
- **Performance Monitor** — Track performance metrics such as FCP (First Contentful Paint)
|
|
11
|
+
- **Floating Button** — Open and close the console with a floating button that displays the FCP value
|
|
12
|
+
- **Light/Dark Theme** support
|
|
13
|
+
- **Seed Design** based UI
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn add lynx-console
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Peer Dependencies
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @lynx-js/react @lynx-js/types
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### 1. Initialize Monitors
|
|
30
|
+
|
|
31
|
+
Call the monitoring functions at your app's entry point. This setup must run **before** the `LynxConsole` component is rendered.
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import {
|
|
35
|
+
initLogMonitor,
|
|
36
|
+
initMainThreadConsole,
|
|
37
|
+
initNetworkMonitor,
|
|
38
|
+
initPerformanceMonitor,
|
|
39
|
+
} from "lynx-console/setup";
|
|
40
|
+
|
|
41
|
+
initLogMonitor();
|
|
42
|
+
initMainThreadConsole();
|
|
43
|
+
initNetworkMonitor();
|
|
44
|
+
initPerformanceMonitor();
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 2. Render the Component
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import LynxConsole from "lynx-console";
|
|
51
|
+
|
|
52
|
+
function App() {
|
|
53
|
+
return (
|
|
54
|
+
<view>
|
|
55
|
+
{/* Your app content */}
|
|
56
|
+
<LynxConsole theme="light" safeAreaInsetBottom="34px" />
|
|
57
|
+
</view>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
const LynxConsole = lazy(() => import("lynx-console"));
|
|
64
|
+
|
|
65
|
+
function App() {
|
|
66
|
+
return (
|
|
67
|
+
<view>
|
|
68
|
+
{/* Your app content */}
|
|
69
|
+
<Suspense>
|
|
70
|
+
<LynxConsole theme="light" safeAreaInsetBottom="34px" />
|
|
71
|
+
<Suspense>
|
|
72
|
+
</view>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Controlling with ref
|
|
78
|
+
|
|
79
|
+
You can programmatically open and close the console using `LynxConsoleHandle`.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { type LynxConsoleHandle } from "lynx-console";
|
|
83
|
+
import { useRef } from "@lynx-js/react";
|
|
84
|
+
|
|
85
|
+
const LynxConsole = lazy(() => import("lynx-console"));
|
|
86
|
+
|
|
87
|
+
function App() {
|
|
88
|
+
const consoleRef = useRef<LynxConsoleHandle>(null);
|
|
89
|
+
|
|
90
|
+
const toggleConsole = () => {
|
|
91
|
+
if (consoleRef.current?.isOpen()) {
|
|
92
|
+
consoleRef.current.close();
|
|
93
|
+
} else {
|
|
94
|
+
consoleRef.current?.open();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<view>
|
|
100
|
+
<Suspense>
|
|
101
|
+
<LynxConsole ref={consoleRef} />
|
|
102
|
+
<Suspense>
|
|
103
|
+
</view>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## API
|
|
109
|
+
|
|
110
|
+
### `LynxConsole` Props
|
|
111
|
+
|
|
112
|
+
| Prop | Type | Default | Description |
|
|
113
|
+
|------|------|---------|-------------|
|
|
114
|
+
| `theme` | `"light" \| "dark"` | `"light"` | Console UI theme |
|
|
115
|
+
| `safeAreaInsetBottom` | `string` | `"50px"` | Bottom safe area inset |
|
|
116
|
+
|
|
117
|
+
### `LynxConsoleHandle`
|
|
118
|
+
|
|
119
|
+
| Method | Description |
|
|
120
|
+
|--------|-------------|
|
|
121
|
+
| `open()` | Opens the console |
|
|
122
|
+
| `close()` | Closes the console |
|
|
123
|
+
| `isOpen()` | Returns whether the console is open |
|
|
124
|
+
|
|
125
|
+
### Monitor Initialization Functions
|
|
126
|
+
|
|
127
|
+
| Function | Description |
|
|
128
|
+
|----------|-------------|
|
|
129
|
+
| `initLogMonitor()` | Captures `console.log`, `console.error`, etc. |
|
|
130
|
+
| `initMainThreadConsole()` | Captures console output from the main thread |
|
|
131
|
+
| `initNetworkMonitor()` | Intercepts and records `fetch` requests |
|
|
132
|
+
| `initPerformanceMonitor()` | Collects performance metrics |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lynx-console",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css",
|
|
@@ -47,5 +47,12 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"javascript-stringify": "^2.1.0"
|
|
50
|
+
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/daangn/lynx-console"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"provenance": true
|
|
50
57
|
}
|
|
51
58
|
}
|