@coherent.js/devtools 1.1.2 → 2.0.0-rc.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.
- package/README.md +16 -12
- package/dist/index.js +317 -206
- package/dist/index.js.map +3 -3
- package/dist/profiler.js +107 -39
- package/dist/profiler.js.map +2 -2
- package/package.json +2 -2
- package/types/index.d.ts +74 -12
package/README.md
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@coherent.js/devtools)
|
|
4
4
|
[](../../LICENSE)
|
|
5
|
-
[](https://nodejs.org)
|
|
6
6
|
|
|
7
7
|
Developer tools for Coherent.js applications: inspector, profiler, and logger utilities.
|
|
8
8
|
|
|
9
|
-
- ESM-only, Node
|
|
9
|
+
- ESM-only, Node 22.12+
|
|
10
10
|
- Lightweight debugging and profiling helpers
|
|
11
11
|
- Designed to pair with `@coherent.js/core`
|
|
12
12
|
|
|
13
|
+
**Stability:** development-only tooling. Don't ship it in production bundles or rely on it in production servers: `createDevTools()` is off unless `NODE_ENV=development` (or a localhost page in the browser) or `{ enabled: true }` is passed, and profilers record nothing until enabled.
|
|
14
|
+
|
|
13
15
|
For a high-level overview and repository-wide instructions, see the root README: ../../README.md
|
|
14
16
|
|
|
15
17
|
## Installation
|
|
@@ -50,28 +52,30 @@ import { LRUCache, memoize } from '@coherent.js/devtools/performance/cache';
|
|
|
50
52
|
|
|
51
53
|
JavaScript (ESM):
|
|
52
54
|
```js
|
|
53
|
-
import {
|
|
55
|
+
import { createLogger, LogLevel } from '@coherent.js/devtools/logger';
|
|
54
56
|
import { createProfiler } from '@coherent.js/devtools/profiler';
|
|
55
57
|
|
|
58
|
+
const logger = createLogger({ level: LogLevel.DEBUG });
|
|
56
59
|
logger.info('Starting app');
|
|
57
60
|
|
|
58
|
-
|
|
59
|
-
profiler
|
|
61
|
+
// Profilers record nothing until enabled
|
|
62
|
+
const profiler = createProfiler({ enabled: true });
|
|
63
|
+
const session = profiler.start('render');
|
|
60
64
|
// ... render work ...
|
|
61
|
-
profiler.stop();
|
|
65
|
+
console.log(profiler.stop(session).duration); // ms, from performance.now()
|
|
62
66
|
```
|
|
63
67
|
|
|
64
|
-
TypeScript:
|
|
68
|
+
TypeScript (the declarations ship with the root entry point):
|
|
65
69
|
```ts
|
|
66
|
-
import {
|
|
67
|
-
import { createProfiler } from '@coherent.js/devtools/profiler';
|
|
70
|
+
import { createLogger, createProfiler, LogLevel } from '@coherent.js/devtools';
|
|
68
71
|
|
|
72
|
+
const logger = createLogger({ level: LogLevel.DEBUG });
|
|
69
73
|
logger.debug('Bootstrapping');
|
|
70
74
|
|
|
71
|
-
const profiler = createProfiler('
|
|
72
|
-
profiler.start();
|
|
75
|
+
const profiler = createProfiler({ enabled: process.env.NODE_ENV !== 'production' });
|
|
76
|
+
const session = profiler.start('render');
|
|
73
77
|
// ... work ...
|
|
74
|
-
profiler.stop();
|
|
78
|
+
profiler.stop(session);
|
|
75
79
|
```
|
|
76
80
|
|
|
77
81
|
## Exports
|