@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 CHANGED
@@ -2,14 +2,16 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@coherent.js/devtools.svg)](https://www.npmjs.com/package/@coherent.js/devtools)
4
4
  [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](../../LICENSE)
5
- [![Node >= 20](https://img.shields.io/badge/node-%3E%3D20-brightgreen)](https://nodejs.org)
5
+ [![Node >= 22.12](https://img.shields.io/badge/node-%3E%3D22.12-brightgreen)](https://nodejs.org)
6
6
 
7
7
  Developer tools for Coherent.js applications: inspector, profiler, and logger utilities.
8
8
 
9
- - ESM-only, Node 20+
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 { logger } from '@coherent.js/devtools/logger';
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
- const profiler = createProfiler('render');
59
- profiler.start();
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 { logger } from '@coherent.js/devtools/logger';
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('render');
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