@xiboplayer/utils 0.5.16 → 0.5.18

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.
Files changed (2) hide show
  1. package/package.json +3 -2
  2. package/src/index.d.ts +71 -0
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@xiboplayer/utils",
3
- "version": "0.5.16",
3
+ "version": "0.5.18",
4
4
  "description": "Shared utilities for Xibo Player packages",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
+ "types": "./src/index.d.ts",
7
8
  "exports": {
8
9
  ".": "./src/index.js",
9
10
  "./logger": "./src/logger.js",
@@ -11,7 +12,7 @@
11
12
  "./config": "./src/config.js"
12
13
  },
13
14
  "dependencies": {
14
- "@xiboplayer/crypto": "0.5.16"
15
+ "@xiboplayer/crypto": "0.5.18"
15
16
  },
16
17
  "devDependencies": {
17
18
  "vitest": "^2.0.0"
package/src/index.d.ts ADDED
@@ -0,0 +1,71 @@
1
+ export const VERSION: string;
2
+
3
+ export interface Logger {
4
+ debug(...args: any[]): void;
5
+ info(...args: any[]): void;
6
+ warn(...args: any[]): void;
7
+ error(...args: any[]): void;
8
+ setLevel(level: string): void;
9
+ getEffectiveLevel(): number;
10
+ }
11
+
12
+ export interface LogSinkEntry {
13
+ level: string;
14
+ name: string;
15
+ args: any[];
16
+ }
17
+
18
+ export function createLogger(name: string, level?: string | null): Logger;
19
+ export function setLogLevel(level: string): void;
20
+ export function getLogLevel(): string;
21
+ export function isDebug(): boolean;
22
+ export function applyCmsLogLevel(cmsLevel: string): boolean;
23
+ export function registerLogSink(fn: (entry: LogSinkEntry) => void): void;
24
+ export function unregisterLogSink(fn: (entry: LogSinkEntry) => void): void;
25
+
26
+ export class EventEmitter {
27
+ on(event: string, callback: (...args: any[]) => void): void;
28
+ once(event: string, callback: (...args: any[]) => void): void;
29
+ off(event: string, callback: (...args: any[]) => void): void;
30
+ emit(event: string, ...args: any[]): void;
31
+ removeAllListeners(event?: string): void;
32
+ }
33
+
34
+ export class Config {
35
+ load(): Record<string, string>;
36
+ save(): void;
37
+ isConfigured(): boolean;
38
+ generateStableHardwareKey(): string;
39
+ generateXmrChannel(): string;
40
+ ensureXmrKeyPair(): Promise<void>;
41
+ hash(str: string): string;
42
+ get cmsUrl(): string;
43
+ set cmsUrl(val: string);
44
+ get cmsKey(): string;
45
+ set cmsKey(val: string);
46
+ get displayName(): string;
47
+ set displayName(val: string);
48
+ get hardwareKey(): string;
49
+ get xmrChannel(): string;
50
+ get xmrPubKey(): string;
51
+ get xmrPrivKey(): string;
52
+ get googleGeoApiKey(): string;
53
+ set googleGeoApiKey(val: string);
54
+ macAddress?: string;
55
+ }
56
+
57
+ export const config: Config;
58
+
59
+ export function fetchWithRetry(
60
+ url: string,
61
+ options?: RequestInit,
62
+ retryOptions?: { maxRetries?: number; baseDelayMs?: number }
63
+ ): Promise<Response>;
64
+
65
+ export class CmsApiClient {
66
+ constructor(baseUrl: string, apiKey?: string);
67
+ get(path: string, params?: Record<string, string>): Promise<any>;
68
+ post(path: string, body?: any): Promise<any>;
69
+ put(path: string, body?: any): Promise<any>;
70
+ delete(path: string): Promise<any>;
71
+ }