@luxonis/ui-utils 0.0.1

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 (3) hide show
  1. package/dist/index.d.ts +122 -0
  2. package/dist/index.js +2150 -0
  3. package/package.json +44 -0
@@ -0,0 +1,122 @@
1
+ import React from 'react';
2
+ import { ErrorObject } from 'serialize-error';
3
+ export { serializeError } from 'serialize-error';
4
+
5
+ declare const SECOND = 1000;
6
+ declare const MINUTE: number;
7
+ declare const HOUR: number;
8
+ declare const DAY: number;
9
+ declare const WEEK: number;
10
+ declare const MONTH: number;
11
+ declare const YEAR: number;
12
+ declare function getShortTimeElapsed(uptime: number): string;
13
+ declare function formatDate(date: Date, format: "iso" | "time-dayofyear" | "full"): string;
14
+ declare function getDateWithTimezone(date: Date | string): Date;
15
+ declare function formatDateISOInTimezone(date: Date, timezone: string): string;
16
+ declare function getShortDateOrDistance(date: Date | null | undefined | string, opts?: {
17
+ addSuffix?: boolean;
18
+ }): string;
19
+ declare function getDistance(date: Date | null | string | undefined, opts?: {
20
+ addSuffix?: boolean;
21
+ }): string;
22
+ declare function getShortDate(date: Date | null | undefined | string, fallbackValue?: string): string;
23
+ declare function getTime(date: Date | null | string): string;
24
+ declare function getShortTime(date: Date | null | string): string;
25
+ declare function getShortDateTime(date: Date | null | string): string;
26
+ declare function unixTimestamp(): number;
27
+ declare function unixTimestampWithMillis(): number;
28
+ declare function unixTimestampAtUtc(): number;
29
+ declare function unixTimestampWithMillisAtUtc(): number;
30
+ declare function toTwoDigits(number: number): string;
31
+ declare function secondsToTime(seconds: number): string;
32
+ declare function newestFirstByCreatedAt<T extends {
33
+ createdAt: Date | string;
34
+ } | {
35
+ created: Date | string;
36
+ }>(a: T, b: T): number;
37
+ declare function oldestFirstByCreatedAt<T extends {
38
+ createdAt: Date | string;
39
+ }>(a: T, b: T): number;
40
+
41
+ type UseDebounceProps = {
42
+ effect: () => void;
43
+ dependencies: React.DependencyList;
44
+ debounceDelay: number;
45
+ };
46
+ declare const useDebounce: (props: UseDebounceProps) => void;
47
+
48
+ declare const formatBps: (valueRaw: unknown, fmt?: string) => string;
49
+ declare const formatBytes: (valueRaw: unknown, fmt?: string) => string;
50
+ declare function formatTemperature(value: number): string;
51
+ declare function formatIntTemperature(value: number): string;
52
+ declare function formatLastSeen(lastSeen: Date | string | undefined | null): string;
53
+ declare function formatUptime(uptimeInit: number, compact?: boolean): string;
54
+ declare function formatPrettyDate(date: Date): string;
55
+ declare function formatPlatform(platformString: string | null | undefined): string;
56
+ declare function formatCapitalizeFirstLetter(text: string): string;
57
+ declare function formatCapitalizeWords(sentence: string): string;
58
+ declare function formatMaxLength(value: string, maxLength: number, ellipsis?: boolean): string;
59
+ declare function formatUsbPort(value: string | null): string;
60
+ declare function formatRobotName(value: string | null): string;
61
+ declare function formatAgentVersion(version: string | number | bigint): string;
62
+ declare function formatFirmwareVersion(version: string | undefined | null): string;
63
+ declare function formatSlug(value: string): string;
64
+
65
+ declare global {
66
+ var ENV: Record<string, string> | undefined;
67
+ }
68
+ type LoggerConfig = {
69
+ level: number;
70
+ rootComponent: string;
71
+ format: 'pretty' | 'plain' | 'json';
72
+ runtime: 'development' | 'production' | 'test';
73
+ };
74
+ declare enum LogLevel {
75
+ trace = 10,
76
+ debug = 20,
77
+ info = 30,
78
+ warn = 40,
79
+ error = 50,
80
+ fatal = 60
81
+ }
82
+ type LogFnParamsBase = readonly [message: string];
83
+ type LogFnParamsCtx = readonly [ctx: MessageContext, message: string];
84
+ type LogFnParams = LogFnParamsBase | LogFnParamsCtx;
85
+ declare function isLogFnParamsCtx(params: LogFnParams): params is LogFnParamsCtx;
86
+ type Logger = {
87
+ readonly config: LoggerConfig;
88
+ readonly name: string;
89
+ serializeMessage: SerializeMessageFn;
90
+ configure: (config: Partial<LoggerConfig>) => void;
91
+ child: (component: string) => Logger;
92
+ canLogLevel: (level: LogLevel) => boolean;
93
+ trace: (...params: LogFnParams) => void;
94
+ debug: (...params: LogFnParams) => void;
95
+ info: (...params: LogFnParams) => void;
96
+ warn: (...params: LogFnParams) => void;
97
+ error: (...params: LogFnParams) => void;
98
+ fatal: (...params: LogFnParams) => void;
99
+ };
100
+ type MessageContext = {
101
+ [key: string]: SupportedContextValue;
102
+ };
103
+ type SupportedContextValue = string | number | Date | {
104
+ [key: string]: any;
105
+ } | unknown | undefined | null | Error | ErrorObject;
106
+ type Message = {
107
+ logger: Logger;
108
+ when: Date;
109
+ context: MessageContext;
110
+ message: string;
111
+ level: number;
112
+ component: string | null;
113
+ };
114
+ type SerializeMessageFn = (message: Message) => string;
115
+ declare function buildSerializeMessage(config: LoggerConfig): SerializeMessageFn;
116
+ declare const buildLogger: (name: string, initialConfig: LoggerConfig) => Logger;
117
+ declare const defaultLogger: Logger;
118
+ declare const errorAsContext: (e: unknown) => MessageContext;
119
+ declare function prettifyMessage(data: string): string;
120
+ declare const log: Logger;
121
+
122
+ export { DAY, HOUR, type LogFnParams, type LogFnParamsBase, type LogFnParamsCtx, LogLevel, type Logger, type LoggerConfig, MINUTE, MONTH, type Message, type MessageContext, SECOND, WEEK, YEAR, buildLogger, buildSerializeMessage, defaultLogger, errorAsContext, formatAgentVersion, formatBps, formatBytes, formatCapitalizeFirstLetter, formatCapitalizeWords, formatDate, formatDateISOInTimezone, formatFirmwareVersion, formatIntTemperature, formatLastSeen, formatMaxLength, formatPlatform, formatPrettyDate, formatRobotName, formatSlug, formatTemperature, formatUptime, formatUsbPort, getDateWithTimezone, getDistance, getShortDate, getShortDateOrDistance, getShortDateTime, getShortTime, getShortTimeElapsed, getTime, isLogFnParamsCtx, log, newestFirstByCreatedAt, oldestFirstByCreatedAt, prettifyMessage, secondsToTime, toTwoDigits, unixTimestamp, unixTimestampAtUtc, unixTimestampWithMillis, unixTimestampWithMillisAtUtc, useDebounce };