@flighthq/debug 0.3.0-next.906.07cea63 → 0.3.1-next.1041.35b950c
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/dist/debug.d.ts +2 -1
- package/dist/debug.d.ts.map +1 -1
- package/dist/debug.js +8 -23
- package/dist/debug.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- package/src/debug.test.ts +23 -1
package/dist/debug.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { DebugOptions, DebugSubsystemHooks, DebugSubsystemName } from '@flighthq/types/contract';
|
|
1
|
+
import type { DebugOptions, DebugSubsystemHooks, DebugSubsystemName, RenderState } from '@flighthq/types/contract';
|
|
2
2
|
export declare function disableDebug(): void;
|
|
3
3
|
export declare function enableDebug(options?: Readonly<DebugOptions>): void;
|
|
4
|
+
export declare function enableFlightDiagnostics(state: RenderState): void;
|
|
4
5
|
export declare function isDebugEnabled(): boolean;
|
|
5
6
|
export declare function registerDebugSubsystem(name: DebugSubsystemName, hooks: Readonly<DebugSubsystemHooks>): void;
|
|
6
7
|
export declare function unregisterDebugSubsystem(name: DebugSubsystemName): boolean;
|
package/dist/debug.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAElB,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAOlC,wBAAgB,YAAY,IAAI,IAAI,CAOnC;AASD,wBAAgB,WAAW,CAAC,OAAO,GAAE,QAAQ,CAAC,YAAY,CAAM,GAAG,IAAI,CActE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAIhE;AAGD,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAOD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAE3G;AAID,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAE1E"}
|
package/dist/debug.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { addLogSink, clearLogChannelLevels,
|
|
1
|
+
import { addLogSink, clearLogChannelLevels, createConsoleLogSink, getLogLevel, removeLogSink, setLogChannelLevel, setLogLevel, } from '@flighthq/log/contract';
|
|
2
|
+
import { enableColorAdjustmentGuards, enableRenderRegistryGuards } from '@flighthq/render/contract';
|
|
2
3
|
import { LogLevel } from '@flighthq/types/contract';
|
|
3
4
|
// The one call that returns Flight to the zero-debug baseline: removes the sink enableDebug
|
|
4
5
|
// installed, restores the log levels it raised, and runs the disable-guards binding of every
|
|
@@ -29,13 +30,18 @@ export function enableDebug(options = {}) {
|
|
|
29
30
|
const channels = _collectDebugChannels(subsystems, options.channels);
|
|
30
31
|
_savedGlobalLevel = getLogLevel();
|
|
31
32
|
_applyDebugLevels(level, channels);
|
|
32
|
-
_installDebugSink(options.sink ??
|
|
33
|
+
_installDebugSink(options.sink ?? createConsoleLogSink());
|
|
33
34
|
for (const hooks of subsystems) {
|
|
34
35
|
hooks.enableGuards?.();
|
|
35
36
|
_enabledSubsystems.push(hooks);
|
|
36
37
|
}
|
|
37
38
|
_enabled = true;
|
|
38
39
|
}
|
|
40
|
+
export function enableFlightDiagnostics(state) {
|
|
41
|
+
enableDebug();
|
|
42
|
+
enableColorAdjustmentGuards(state);
|
|
43
|
+
enableRenderRegistryGuards(state);
|
|
44
|
+
}
|
|
39
45
|
// Whether enableDebug is currently in effect (a sink is installed and levels/guards are raised).
|
|
40
46
|
export function isDebugEnabled() {
|
|
41
47
|
return _enabled;
|
|
@@ -75,19 +81,6 @@ function _collectDebugChannels(subsystems, extra) {
|
|
|
75
81
|
channels.push(...extra);
|
|
76
82
|
return channels;
|
|
77
83
|
}
|
|
78
|
-
// The default dev sink: formats each entry as a human-readable line and writes it to the matching
|
|
79
|
-
// console method. Dev-only — this is the one place @flighthq/debug touches the console, and the
|
|
80
|
-
// package is never in a shipping bundle.
|
|
81
|
-
function _createDefaultDebugSink() {
|
|
82
|
-
const formatter = createTextLogFormatter({ levelPrefix: true });
|
|
83
|
-
return (entry) => {
|
|
84
|
-
if (typeof console === 'undefined')
|
|
85
|
-
return;
|
|
86
|
-
const method = _consoleMethods[entry.level] ?? 'log';
|
|
87
|
-
// eslint-disable-next-line no-console -- the dev debug sink; writing to the console is its job.
|
|
88
|
-
console[method](formatter(entry));
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
84
|
// Installs the debug sink and records it so disableDebug can remove exactly this one.
|
|
92
85
|
function _installDebugSink(sink) {
|
|
93
86
|
_installedSink = sink;
|
|
@@ -120,12 +113,4 @@ function _restoreDebugLevels() {
|
|
|
120
113
|
setLogLevel(_savedGlobalLevel);
|
|
121
114
|
clearLogChannelLevels();
|
|
122
115
|
}
|
|
123
|
-
const _consoleMethods = {
|
|
124
|
-
[LogLevel.None]: 'log',
|
|
125
|
-
[LogLevel.Error]: 'error',
|
|
126
|
-
[LogLevel.Warn]: 'warn',
|
|
127
|
-
[LogLevel.Info]: 'info',
|
|
128
|
-
[LogLevel.Debug]: 'debug',
|
|
129
|
-
[LogLevel.Verbose]: 'log',
|
|
130
|
-
};
|
|
131
116
|
//# sourceMappingURL=debug.js.map
|
package/dist/debug.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot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ableDebug, enableDebug, endDebugSpan, isDebugEnabled, markDebugFrame, measureDebugSpan, registerDebugSubsystem, unregisterDebugSubsystem, } from './contract';
|
|
1
|
+
export { beginDebugSpan, disableDebug, enableDebug, enableFlightDiagnostics, endDebugSpan, isDebugEnabled, markDebugFrame, measureDebugSpan, registerDebugSubsystem, unregisterDebugSubsystem, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,WAAW,EACX,uBAAuB,EACvB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { beginDebugSpan, disableDebug, enableDebug, endDebugSpan, isDebugEnabled, markDebugFrame, measureDebugSpan, registerDebugSubsystem, unregisterDebugSubsystem, } from './contract';
|
|
1
|
+
export { beginDebugSpan, disableDebug, enableDebug, enableFlightDiagnostics, endDebugSpan, isDebugEnabled, markDebugFrame, measureDebugSpan, registerDebugSubsystem, unregisterDebugSubsystem, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,WAAW,EACX,uBAAuB,EACvB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/debug",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1-next.1041.35b950c",
|
|
4
|
+
"author": "Joshua Granick and other contributors",
|
|
5
|
+
"license": "MIT",
|
|
4
6
|
"repository": {
|
|
5
7
|
"type": "git",
|
|
6
8
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -36,8 +38,9 @@
|
|
|
36
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
37
39
|
},
|
|
38
40
|
"dependencies": {
|
|
39
|
-
"@flighthq/log": "0.3.
|
|
40
|
-
"@flighthq/
|
|
41
|
+
"@flighthq/log": "0.3.1-next.1041.35b950c",
|
|
42
|
+
"@flighthq/render": "0.3.1-next.1041.35b950c",
|
|
43
|
+
"@flighthq/types": "0.3.1-next.1041.35b950c"
|
|
41
44
|
},
|
|
42
45
|
"devDependencies": {
|
|
43
46
|
"typescript": "^5.3.0"
|
package/src/debug.test.ts
CHANGED
|
@@ -8,11 +8,23 @@ import {
|
|
|
8
8
|
log,
|
|
9
9
|
setLogLevel,
|
|
10
10
|
} from '@flighthq/log/contract';
|
|
11
|
+
import {
|
|
12
|
+
areColorAdjustmentGuardsEnabled,
|
|
13
|
+
areRenderRegistryGuardsEnabled,
|
|
14
|
+
createRenderState,
|
|
15
|
+
} from '@flighthq/render/contract';
|
|
11
16
|
import type { MemoryLogSink } from '@flighthq/types/contract';
|
|
12
17
|
import { LogLevel } from '@flighthq/types/contract';
|
|
13
18
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
14
19
|
|
|
15
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
disableDebug,
|
|
22
|
+
enableDebug,
|
|
23
|
+
enableFlightDiagnostics,
|
|
24
|
+
isDebugEnabled,
|
|
25
|
+
registerDebugSubsystem,
|
|
26
|
+
unregisterDebugSubsystem,
|
|
27
|
+
} from './debug';
|
|
16
28
|
|
|
17
29
|
// Subsystem names touched by the tests, unregistered between each so the module-global registry
|
|
18
30
|
// never leaks state across cases.
|
|
@@ -147,6 +159,16 @@ describe('enableDebug', () => {
|
|
|
147
159
|
});
|
|
148
160
|
});
|
|
149
161
|
|
|
162
|
+
describe('enableFlightDiagnostics', () => {
|
|
163
|
+
it('enables the console diagnostics session and every generic render guard for the state', () => {
|
|
164
|
+
const state = createRenderState();
|
|
165
|
+
enableFlightDiagnostics(state);
|
|
166
|
+
expect(isDebugEnabled()).toBe(true);
|
|
167
|
+
expect(areColorAdjustmentGuardsEnabled(state)).toBe(true);
|
|
168
|
+
expect(areRenderRegistryGuardsEnabled(state)).toBe(true);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
150
172
|
describe('isDebugEnabled', () => {
|
|
151
173
|
it('reports the enable/disable lifecycle', () => {
|
|
152
174
|
expect(isDebugEnabled()).toBe(false);
|