@atlassian/clientside-extensions-debug
Advanced tools
Comparing version
@@ -19,3 +19,2 @@ "use strict"; | ||
const defineDebugGlobal = (previousGlobal) => { | ||
// initialize as boolean | ||
const debugGlobal = Object.create(null); | ||
@@ -31,3 +30,3 @@ const debugStates = { | ||
}; | ||
const debugStateSubject = (0, debug_subjects_1.registerDebugSubject)("state" /* State */, () => new clientside_extensions_base_1.ReplaySubject(1)); | ||
const debugStateSubject = (0, debug_subjects_1.registerDebugSubject)("state" /* DebugSubjects.State */, () => new clientside_extensions_base_1.ReplaySubject(1)); | ||
const properties = { | ||
@@ -89,3 +88,3 @@ debug: { | ||
Object.defineProperty(window, '____c_p_d', { | ||
configurable: true, | ||
configurable: true, // needed for testing :( | ||
get() { | ||
@@ -123,3 +122,3 @@ return debugGlobal; | ||
} | ||
const observeStateChange = (observer) => (0, debug_subjects_1.observeDebugSubject)("state" /* State */, observer); | ||
const observeStateChange = (observer) => (0, debug_subjects_1.observeDebugSubject)("state" /* DebugSubjects.State */, observer); | ||
exports.observeStateChange = observeStateChange; | ||
@@ -144,4 +143,4 @@ const isDebugEnabled = () => { | ||
const getLogLevel = () => { | ||
const logLevel = window.____c_p_d.logLevel; | ||
return logLevel !== null && logLevel !== void 0 ? logLevel : logger_1.LogLevel.info; | ||
var _a; | ||
return (_a = window.____c_p_d.logLevel) !== null && _a !== void 0 ? _a : logger_1.LogLevel.info; | ||
}; | ||
@@ -148,0 +147,0 @@ exports.getLogLevel = getLogLevel; |
"use strict"; | ||
/* eslint-disable no-console */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +4,0 @@ exports.consoleLogger = void 0; |
@@ -14,3 +14,3 @@ "use strict"; | ||
const observeLogger = (observer) => { | ||
return (0, debug_subjects_1.observeDebugSubject)("logger" /* Logger */, observer); | ||
return (0, debug_subjects_1.observeDebugSubject)("logger" /* DebugSubjects.Logger */, observer); | ||
}; | ||
@@ -46,3 +46,3 @@ exports.observeLogger = observeLogger; | ||
logger_1._loggerSubject.prune(); | ||
(0, debug_subjects_1.observeDebugSubject)("logger" /* Logger */, logger); | ||
(0, debug_subjects_1.observeDebugSubject)("logger" /* DebugSubjects.Logger */, logger); | ||
}; | ||
@@ -49,0 +49,0 @@ exports.setLogger = setLogger; |
@@ -13,5 +13,5 @@ "use strict"; | ||
LogLevel["info"] = "INFO"; | ||
})(LogLevel = exports.LogLevel || (exports.LogLevel = {})); | ||
const loggerSubject = (0, debug_subjects_1.registerDebugSubject)("logger" /* Logger */, () => new clientside_extensions_base_1.ReplaySubject(20)); | ||
})(LogLevel || (exports.LogLevel = LogLevel = {})); | ||
const loggerSubject = (0, debug_subjects_1.registerDebugSubject)("logger" /* DebugSubjects.Logger */, () => new clientside_extensions_base_1.ReplaySubject(20)); | ||
exports._loggerSubject = loggerSubject; | ||
//# sourceMappingURL=logger.js.map |
@@ -16,3 +16,2 @@ /* eslint-disable no-underscore-dangle */ | ||
const defineDebugGlobal = (previousGlobal) => { | ||
// initialize as boolean | ||
const debugGlobal = Object.create(null); | ||
@@ -28,3 +27,3 @@ const debugStates = { | ||
}; | ||
const debugStateSubject = registerDebugSubject("state" /* State */, () => new ReplaySubject(1)); | ||
const debugStateSubject = registerDebugSubject("state" /* DebugSubjects.State */, () => new ReplaySubject(1)); | ||
const properties = { | ||
@@ -86,3 +85,3 @@ debug: { | ||
Object.defineProperty(window, '____c_p_d', { | ||
configurable: true, | ||
configurable: true, // needed for testing :( | ||
get() { | ||
@@ -120,3 +119,3 @@ return debugGlobal; | ||
} | ||
export const observeStateChange = (observer) => observeDebugSubject("state" /* State */, observer); | ||
export const observeStateChange = (observer) => observeDebugSubject("state" /* DebugSubjects.State */, observer); | ||
export const isDebugEnabled = () => { | ||
@@ -136,4 +135,4 @@ return window.____c_p_d.debug; | ||
export const getLogLevel = () => { | ||
const logLevel = window.____c_p_d.logLevel; | ||
return logLevel !== null && logLevel !== void 0 ? logLevel : LogLevel.info; | ||
var _a; | ||
return (_a = window.____c_p_d.logLevel) !== null && _a !== void 0 ? _a : LogLevel.info; | ||
}; | ||
@@ -140,0 +139,0 @@ export const setDebugEnabled = (value) => { |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable no-console */ | ||
import { LogLevel } from './logger'; | ||
@@ -2,0 +3,0 @@ import { getLogLevel } from '../debug-state'; |
@@ -11,3 +11,3 @@ import { consoleLogger } from './console'; | ||
export const observeLogger = (observer) => { | ||
return observeDebugSubject("logger" /* Logger */, observer); | ||
return observeDebugSubject("logger" /* DebugSubjects.Logger */, observer); | ||
}; | ||
@@ -42,3 +42,3 @@ const registerConsoleLogger = () => { | ||
_loggerSubject.prune(); | ||
observeDebugSubject("logger" /* Logger */, logger); | ||
observeDebugSubject("logger" /* DebugSubjects.Logger */, logger); | ||
}; | ||
@@ -45,0 +45,0 @@ const deregisterDefaultLogger = () => defaultLogger.unsubscribe(); |
@@ -11,5 +11,5 @@ import { ReplaySubject } from '@atlassian/clientside-extensions-base'; | ||
})(LogLevel || (LogLevel = {})); | ||
const loggerSubject = registerDebugSubject("logger" /* Logger */, () => new ReplaySubject(20)); | ||
const loggerSubject = registerDebugSubject("logger" /* DebugSubjects.Logger */, () => new ReplaySubject(20)); | ||
// Exported for internal use only | ||
export { loggerSubject as _loggerSubject }; | ||
//# sourceMappingURL=logger.js.map |
@@ -1,2 +0,1 @@ | ||
/// <reference types="jest" /> | ||
declare const observeStateChange: jest.Mock<any, any>; | ||
@@ -3,0 +2,0 @@ declare const isDebugEnabled: jest.Mock<any, any>; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="jest" /> | ||
declare const observeDebugSubject: jest.Mock<any, any>; | ||
@@ -3,0 +2,0 @@ declare const registerDebugSubject: jest.Mock<any, any>; |
@@ -11,4 +11,4 @@ import type { Observer } from '@atlassian/clientside-extensions-base'; | ||
} | ||
declare type DebugTypeKeys = Exclude<keyof typeof ClientExtensionDebugTypes, 'logLevel'>; | ||
export declare type ClientExtensionDebug = { | ||
type DebugTypeKeys = Exclude<keyof typeof ClientExtensionDebugTypes, 'logLevel'>; | ||
export type ClientExtensionDebug = { | ||
[key in DebugTypeKeys]: boolean; | ||
@@ -18,6 +18,4 @@ } & { | ||
}; | ||
export declare type ExposedClientExtensionDebug = { | ||
[key in keyof ClientExtensionDebug]: PropertyDescriptor; | ||
} & { | ||
__initialized: PropertyDescriptor; | ||
export type ExposedClientExtensionDebug = ClientExtensionDebug & { | ||
__initialized: boolean; | ||
}; | ||
@@ -24,0 +22,0 @@ declare global { |
import type { Observer, Subject } from '@atlassian/clientside-extensions-base'; | ||
declare type ExposedClientExtensionSubjects = { | ||
type ExposedClientExtensionSubjects = { | ||
__initialized: PropertyDescriptor; | ||
@@ -15,3 +15,3 @@ subjects: PropertyDescriptor; | ||
} | ||
declare type UnpackPayloadType<SubjectType> = SubjectType extends Subject<infer U> ? U : never; | ||
type UnpackPayloadType<SubjectType> = SubjectType extends Subject<infer U> ? U : never; | ||
/** | ||
@@ -18,0 +18,0 @@ * Registers a debug subject as singleton |
import { ReplaySubject } from '@atlassian/clientside-extensions-base'; | ||
export declare enum LogLevel { | ||
debug = "DEBUG", | ||
debug = "DEBUG",// Logs all the things | ||
error = "ERROR", | ||
@@ -9,4 +9,4 @@ warn = "WARN", | ||
} | ||
export declare type LoggerCallback = (levels: typeof LogLevel) => LoggerPayload; | ||
export declare type LoggerPayload = { | ||
export type LoggerCallback = (levels: typeof LogLevel) => LoggerPayload; | ||
export type LoggerPayload = { | ||
level: LogLevel; | ||
@@ -13,0 +13,0 @@ message: string; |
@@ -25,6 +25,12 @@ /* eslint-disable no-underscore-dangle */ | ||
export type ExposedClientExtensionDebug = { [key in keyof ClientExtensionDebug]: PropertyDescriptor } & { | ||
// Type for the internal property descriptors used during setup | ||
type DebugPropertyDescriptors = { [key in keyof ClientExtensionDebug]: PropertyDescriptor } & { | ||
__initialized: PropertyDescriptor; | ||
}; | ||
// Type for the runtime interface - what you actually get when accessing the properties | ||
export type ExposedClientExtensionDebug = ClientExtensionDebug & { | ||
__initialized: boolean; | ||
}; | ||
declare global { | ||
@@ -40,4 +46,3 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const defineDebugGlobal = (previousGlobal: unknown) => { | ||
// initialize as boolean | ||
const debugGlobal = Object.create(null); | ||
const debugGlobal: DebugPropertyDescriptors = Object.create(null); | ||
const debugStates: ClientExtensionDebug = { | ||
@@ -55,3 +60,3 @@ debug: false, | ||
const properties: ExposedClientExtensionDebug = { | ||
const properties: DebugPropertyDescriptors = { | ||
debug: { | ||
@@ -158,15 +163,15 @@ get() { | ||
export const isDebugEnabled = () => { | ||
return window.____c_p_d.debug as boolean; | ||
return window.____c_p_d.debug; | ||
}; | ||
export const isLoggingEnabled = () => { | ||
return window.____c_p_d.logging as boolean; | ||
return window.____c_p_d.logging; | ||
}; | ||
export const isValidationEnabled = () => { | ||
return window.____c_p_d.validation as boolean; | ||
return window.____c_p_d.validation; | ||
}; | ||
export const isDiscoveryEnabled = () => { | ||
return window.____c_p_d.discovery as boolean; | ||
return window.____c_p_d.discovery; | ||
}; | ||
@@ -176,21 +181,19 @@ | ||
export const getLogLevel = (): LogLevel => { | ||
const logLevel = window.____c_p_d.logLevel as LogLevel; | ||
return logLevel ?? LogLevel.info; | ||
return window.____c_p_d.logLevel ?? LogLevel.info; | ||
}; | ||
export const setDebugEnabled = (value: boolean) => { | ||
(window.____c_p_d.debug as boolean) = value; | ||
window.____c_p_d.debug = value; | ||
}; | ||
export const setLoggingEnabled = (value: boolean) => { | ||
(window.____c_p_d.logging as boolean) = value; | ||
window.____c_p_d.logging = value; | ||
}; | ||
export const setValidationEnabled = (value: boolean) => { | ||
(window.____c_p_d.validation as boolean) = value; | ||
window.____c_p_d.validation = value; | ||
}; | ||
export const setDiscoveryEnabled = (value: boolean) => { | ||
(window.____c_p_d.discovery as boolean) = value; | ||
window.____c_p_d.discovery = value; | ||
}; | ||
@@ -202,3 +205,3 @@ | ||
(window.____c_p_d.logLevel as LogLevel) = level; | ||
window.____c_p_d.logLevel = level; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { mocked } from 'ts-jest/utils'; | ||
import { mocked } from 'jest-mock'; | ||
import { getLogLevel, isDebugEnabled, isLoggingEnabled } from './debug-state'; | ||
@@ -3,0 +3,0 @@ import { onDebug } from './debug'; |
@@ -1,2 +0,2 @@ | ||
import { mocked } from 'ts-jest/utils'; | ||
import { mocked } from 'jest-mock'; | ||
import type { LoggerPayload } from './logger'; | ||
@@ -3,0 +3,0 @@ import { LogLevel } from './logger'; |
@@ -0,1 +1,3 @@ | ||
/* eslint-disable no-console */ | ||
import type { LoggerPayload } from './logger'; | ||
@@ -2,0 +4,0 @@ import { LogLevel } from './logger'; |
{ | ||
"name": "@atlassian/clientside-extensions-debug", | ||
"version": "5.0.0", | ||
"version": "5.1.0-5a180d69-mdyn784a", | ||
"description": "Implements debug capabilities for client-side extensions.", | ||
@@ -55,3 +55,3 @@ "license": "BSD-3-Clause", | ||
"access": "public", | ||
"@atlassian:registry": "https://registry.npmjs.org/" | ||
"@atlassian:registry": "https://packages.atlassian.com/api/npm/npm-public/" | ||
}, | ||
@@ -72,12 +72,13 @@ "scripts": { | ||
"jest-in-case": "1.0.2", | ||
"ts-jest": "27.0.7" | ||
"jest-mock": "30.0.5", | ||
"ts-jest": "29.4.1" | ||
}, | ||
"dependencies": { | ||
"@atlassian/clientside-extensions-base": "^5.0.0", | ||
"@atlassian/clientside-extensions-base": "^5.1.0-5a180d69-mdyn784a", | ||
"tslib": "^2.2.0" | ||
}, | ||
"engines": { | ||
"node": ">=20.16.0" | ||
"node": ">=20.18.1" | ||
}, | ||
"gitHead": "797ed863b536adc5806a0f9438ee9501d710a467" | ||
"gitHead": "5a180d69885a02ac1d96b980893b6a5c77e9459a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
136128
0.6%5
25%1
Infinity%1
Infinity%