@christianriedl/utils 1.0.169 → 1.0.170
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/dummyLogger.js.map +1 -1
- package/dist/iMarshal.d.ts +4 -4
- package/dist/logger/src/iLogger.d.ts +62 -0
- package/dist/logger/src/iLogger.js +10 -0
- package/dist/logger/src/iLogger.js.map +1 -0
- package/dist/marshalBE.d.ts +7 -6
- package/dist/marshalBE.js +1 -0
- package/dist/marshalBE.js.map +1 -1
- package/dist/marshalLE.d.ts +7 -6
- package/dist/marshalLE.js +1 -0
- package/dist/marshalLE.js.map +1 -1
- package/dist/useSpeechRecognition.d.ts +104 -0
- package/dist/useSpeechRecognition.js +79 -0
- package/dist/useSpeechRecognition.js.map +1 -0
- package/dist/useSpeechSynthesis.d.ts +49 -0
- package/dist/useSpeechSynthesis.js +96 -0
- package/dist/useSpeechSynthesis.js.map +1 -0
- package/dist/utils/src/helper.d.ts +28 -0
- package/dist/utils/src/helper.js +144 -0
- package/dist/utils/src/helper.js.map +1 -0
- package/dist/utils/src/iLocalStorage.d.ts +7 -0
- package/dist/utils/src/iLocalStorage.js +2 -0
- package/dist/utils/src/iLocalStorage.js.map +1 -0
- package/dist/utils/src/index.d.ts +4 -0
- package/dist/utils/src/index.js +5 -0
- package/dist/utils/src/index.js.map +1 -0
- package/dist/utils/src/localStorage.d.ts +20 -0
- package/dist/utils/src/localStorage.js +57 -0
- package/dist/utils/src/localStorage.js.map +1 -0
- package/dist/utils/src/reactiveStorage.d.ts +18 -0
- package/dist/utils/src/reactiveStorage.js +49 -0
- package/dist/utils/src/reactiveStorage.js.map +1 -0
- package/dist/utils/src/registerServiceWorker.d.ts +31 -0
- package/dist/utils/src/registerServiceWorker.js +251 -0
- package/dist/utils/src/registerServiceWorker.js.map +1 -0
- package/package.json +6 -5
- package/src/components/ThemeSettings.vue +4 -4
package/dist/dummyLogger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dummyLogger.js","sourceRoot":"","sources":["../src/dummyLogger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dummyLogger.js","sourceRoot":"","sources":["../src/dummyLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE5D,MAAM,OAAO,WAAW;IACpB,IAAI,CAAS;IACb,QAAQ,CAAS;IACjB,YAAY,CAAS;IACrB,WAAW,CAAW;IACtB,KAAK,CAAC,GAAW;QACpB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC1B,CAAC;IACD,IAAI,CAAC,GAAW;QACnB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;IAChC,CAAC;IACD,OAAO,CAAC,GAAW;QACtB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAC5B,CAAC;IACD,KAAK,CAAC,GAAW;QACpB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC1B,CAAC;IACD,GAAG,CAAC,QAAkB,EAAE,GAAW;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,IAAI,GAAG,EAAE,CAAC,CAAC;IAC/B,CAAC;IACD,QAAQ,CAAC,QAAsB;QAClC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,gBAAgB;IAChB,CAAC;IACD,WAAW,CAAC,GAAW;IACvB,CAAC;CACJ"}
|
package/dist/iMarshal.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export interface IMarshal {
|
|
|
6
6
|
writeUInt16(val: number): void;
|
|
7
7
|
writeInt32(val: number): void;
|
|
8
8
|
writeUInt32(val: number): void;
|
|
9
|
-
writeInt64(val:
|
|
10
|
-
writeUInt64(val:
|
|
9
|
+
writeInt64(val: number): void;
|
|
10
|
+
writeUInt64(val: number): void;
|
|
11
11
|
writeFloat(val: number): void;
|
|
12
12
|
writeDouble(val: number): void;
|
|
13
13
|
writeString(val: string): void;
|
|
@@ -18,8 +18,8 @@ export interface IMarshal {
|
|
|
18
18
|
readUInt16(): number;
|
|
19
19
|
readInt32(): number;
|
|
20
20
|
readUInt32(): number;
|
|
21
|
-
readInt64():
|
|
22
|
-
readUInt64():
|
|
21
|
+
readInt64(): BigInt;
|
|
22
|
+
readUInt64(): BigInt;
|
|
23
23
|
readFloat(): number;
|
|
24
24
|
readDouble(): number;
|
|
25
25
|
readString(): string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
Trace = 0,
|
|
3
|
+
Debug = 1,
|
|
4
|
+
Information = 2,
|
|
5
|
+
Warning = 3,
|
|
6
|
+
Error = 4,
|
|
7
|
+
Critical = 5
|
|
8
|
+
}
|
|
9
|
+
export interface ILoggerEntry {
|
|
10
|
+
uniqueId: number;
|
|
11
|
+
logLevel: LogLevel;
|
|
12
|
+
now: Date;
|
|
13
|
+
categoryName: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ILoggerEntryEx extends ILoggerEntry {
|
|
17
|
+
timeAsc: string;
|
|
18
|
+
severityAsc: string;
|
|
19
|
+
styleObject: any;
|
|
20
|
+
}
|
|
21
|
+
export interface ILoggerInfo {
|
|
22
|
+
name: string;
|
|
23
|
+
countAll: number;
|
|
24
|
+
countEnabled: number;
|
|
25
|
+
minLogLevel: LogLevel;
|
|
26
|
+
}
|
|
27
|
+
export interface ILogger extends ILoggerInfo {
|
|
28
|
+
trace(msg: string): void;
|
|
29
|
+
info(msg: string): void;
|
|
30
|
+
warning(msg: string): void;
|
|
31
|
+
error(msg: string): void;
|
|
32
|
+
log(severity: LogLevel, msg: string): void;
|
|
33
|
+
startPerformance(): void;
|
|
34
|
+
performance(msg: string): void;
|
|
35
|
+
}
|
|
36
|
+
export interface IProviderInfo extends ILoggerInfo {
|
|
37
|
+
info: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ILoggerProvider extends IProviderInfo {
|
|
40
|
+
log(logEntry: ILoggerEntry, formatedMessage: string): void;
|
|
41
|
+
}
|
|
42
|
+
export interface ILoggerQueueEntries {
|
|
43
|
+
lastUniqueId: number;
|
|
44
|
+
readPointerStart: number;
|
|
45
|
+
readPointerNext: number;
|
|
46
|
+
writePointer: number;
|
|
47
|
+
size: number;
|
|
48
|
+
firstTime: Date;
|
|
49
|
+
lastTime: Date;
|
|
50
|
+
minLogLevel: LogLevel;
|
|
51
|
+
entries: ILoggerEntry[];
|
|
52
|
+
}
|
|
53
|
+
export interface ILoggerService {
|
|
54
|
+
name: string;
|
|
55
|
+
getLoggers(): Promise<ILoggerInfo[]>;
|
|
56
|
+
getProviders(): Promise<IProviderInfo[]>;
|
|
57
|
+
setLoggerLevel(logger: string, level: LogLevel): Promise<boolean>;
|
|
58
|
+
setProviderLevel(provider: string, level: LogLevel): Promise<boolean>;
|
|
59
|
+
getQueuedLogs(minLogLevel: LogLevel, maxCount: number, maxMinutes: number, reverse: boolean, trimCategory: boolean, readPointer: number): Promise<ILoggerQueueEntries>;
|
|
60
|
+
clearCounter(): Promise<boolean>;
|
|
61
|
+
clearQueue(): Promise<boolean>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var LogLevel;
|
|
2
|
+
(function (LogLevel) {
|
|
3
|
+
LogLevel[LogLevel["Trace"] = 0] = "Trace";
|
|
4
|
+
LogLevel[LogLevel["Debug"] = 1] = "Debug";
|
|
5
|
+
LogLevel[LogLevel["Information"] = 2] = "Information";
|
|
6
|
+
LogLevel[LogLevel["Warning"] = 3] = "Warning";
|
|
7
|
+
LogLevel[LogLevel["Error"] = 4] = "Error";
|
|
8
|
+
LogLevel[LogLevel["Critical"] = 5] = "Critical";
|
|
9
|
+
})(LogLevel || (LogLevel = {}));
|
|
10
|
+
//# sourceMappingURL=iLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iLogger.js","sourceRoot":"","sources":["../../../../logger/src/iLogger.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAChB,yCAAS,CAAA;IACT,yCAAS,CAAA;IACT,qDAAe,CAAA;IACf,6CAAW,CAAA;IACX,yCAAS,CAAA;IACT,+CAAY,CAAA;AAChB,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB"}
|
package/dist/marshalBE.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { IMarshal } from './iMarshal';
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
2
3
|
export declare class MarshalBE implements IMarshal {
|
|
3
4
|
_buffer: Buffer;
|
|
4
|
-
_encoding:
|
|
5
|
+
_encoding: string;
|
|
5
6
|
_writeOffset: number;
|
|
6
7
|
_readOffset: number;
|
|
7
|
-
constructor(buffer: Buffer, encoding?:
|
|
8
|
+
constructor(buffer: Buffer, encoding?: string);
|
|
8
9
|
writeBoolean(val: boolean): void;
|
|
9
10
|
writeInt8(val: number): void;
|
|
10
11
|
writeUInt8(val: number): void;
|
|
@@ -12,8 +13,8 @@ export declare class MarshalBE implements IMarshal {
|
|
|
12
13
|
writeUInt16(val: number): void;
|
|
13
14
|
writeInt32(val: number): void;
|
|
14
15
|
writeUInt32(val: number): void;
|
|
15
|
-
writeInt64(val:
|
|
16
|
-
writeUInt64(val:
|
|
16
|
+
writeInt64(val: number): void;
|
|
17
|
+
writeUInt64(val: number): void;
|
|
17
18
|
writeFloat(val: number): void;
|
|
18
19
|
writeDouble(val: number): void;
|
|
19
20
|
writeString(val: string): void;
|
|
@@ -24,8 +25,8 @@ export declare class MarshalBE implements IMarshal {
|
|
|
24
25
|
readUInt16(): number;
|
|
25
26
|
readInt32(): number;
|
|
26
27
|
readUInt32(): number;
|
|
27
|
-
readInt64():
|
|
28
|
-
readUInt64():
|
|
28
|
+
readInt64(): BigInt;
|
|
29
|
+
readUInt64(): BigInt;
|
|
29
30
|
readFloat(): number;
|
|
30
31
|
readDouble(): number;
|
|
31
32
|
readString(): string;
|
package/dist/marshalBE.js
CHANGED
package/dist/marshalBE.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marshalBE.js","sourceRoot":"","sources":["../src/marshalBE.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"marshalBE.js","sourceRoot":"","sources":["../src/marshalBE.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,wBAAwB;AACxB,MAAM,OAAO,SAAS;IAClB,OAAO,CAAS;IAChB,SAAS,CAAS;IAClB,YAAY,CAAS;IACrB,WAAW,CAAS;IACpB,YAAY,MAAc,EAAE,WAAmB,MAAM;QACjD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;IAC7C,CAAC;IACD,YAAY,CAAC,GAAY;QACrB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IACD,SAAS,CAAC,GAAW;QACjB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IACD,UAAU,CAAC,GAAW;QAClB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAChD,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IACD,UAAU,CAAC,GAAW;QAClB,IAAI,CA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AI,CAAC,SAAS,EAAE,CAAC;QACpD,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IACtF,CAAC;IAED,KAAK;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;IACtD,CAAC;IACD,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC;IACvD,CAAC;CACJ"}
|
package/dist/marshalLE.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { IMarshal } from './iMarshal';
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
2
3
|
export declare class MarshalLE implements IMarshal {
|
|
3
4
|
_buffer: Buffer;
|
|
4
|
-
_encoding:
|
|
5
|
+
_encoding: string;
|
|
5
6
|
_writeOffset: number;
|
|
6
7
|
_readOffset: number;
|
|
7
|
-
constructor(buffer: Buffer, encoding?:
|
|
8
|
+
constructor(buffer: Buffer, encoding?: string);
|
|
8
9
|
writeBoolean(val: boolean): void;
|
|
9
10
|
writeInt8(val: number): void;
|
|
10
11
|
writeUInt8(val: number): void;
|
|
@@ -12,8 +13,8 @@ export declare class MarshalLE implements IMarshal {
|
|
|
12
13
|
writeUInt16(val: number): void;
|
|
13
14
|
writeInt32(val: number): void;
|
|
14
15
|
writeUInt32(val: number): void;
|
|
15
|
-
writeInt64(val:
|
|
16
|
-
writeUInt64(val:
|
|
16
|
+
writeInt64(val: number): void;
|
|
17
|
+
writeUInt64(val: number): void;
|
|
17
18
|
writeFloat(val: number): void;
|
|
18
19
|
writeDouble(val: number): void;
|
|
19
20
|
writeString(val: string): void;
|
|
@@ -24,8 +25,8 @@ export declare class MarshalLE implements IMarshal {
|
|
|
24
25
|
readUInt16(): number;
|
|
25
26
|
readInt32(): number;
|
|
26
27
|
readUInt32(): number;
|
|
27
|
-
readInt64():
|
|
28
|
-
readUInt64():
|
|
28
|
+
readInt64(): BigInt;
|
|
29
|
+
readUInt64(): BigInt;
|
|
29
30
|
readFloat(): number;
|
|
30
31
|
readDouble(): number;
|
|
31
32
|
readString(): string;
|
package/dist/marshalLE.js
CHANGED
package/dist/marshalLE.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marshalLE.js","sourceRoot":"","sources":["../src/marshalLE.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"marshalLE.js","sourceRoot":"","sources":["../src/marshalLE.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,wBAAwB;AACxB,MAAM,OAAO,SAAS;IAClB,OAAO,CAAS;IAChB,SAAS,CAAS;IAClB,YAAY,CAAS;IACrB,WAAW,CAAS;IACpB,YAAY,MAAc,EAAE,WAAmB,MAAM;QACjD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;IAC7C,CAAC;IACD,YAAY,CAAC,GAAY;QACrB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IACD,SAAS,CAAC,GAAW;QACjB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CA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KAAK,GAAG,IAAI,CAAC,IAAI,IAAI;YACtB,OAAO,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACpD,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IACtF,CAAC;IACD,KAAK;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;IACtD,CAAC;IACD,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC;IACvD,CAAC;CACJ"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
export type SpeechRecognitionErrorCode = 'aborted' | 'audio-capture' | 'bad-grammar' | 'language-not-supported' | 'network' | 'no-speech' | 'not-allowed' | 'service-not-allowed';
|
|
3
|
+
interface SpeechGrammar {
|
|
4
|
+
src: string;
|
|
5
|
+
weight: number;
|
|
6
|
+
}
|
|
7
|
+
interface SpeechGrammarList {
|
|
8
|
+
readonly length: number;
|
|
9
|
+
addFromString: (string: string, weight?: number) => void;
|
|
10
|
+
addFromURI: (src: string, weight?: number) => void;
|
|
11
|
+
item: (index: number) => SpeechGrammar;
|
|
12
|
+
[index: number]: SpeechGrammar;
|
|
13
|
+
}
|
|
14
|
+
export interface SpeechRecognitionErrorEvent extends Event {
|
|
15
|
+
readonly error: SpeechRecognitionErrorCode;
|
|
16
|
+
readonly message: string;
|
|
17
|
+
}
|
|
18
|
+
interface SpeechRecognitionEvent extends Event {
|
|
19
|
+
readonly resultIndex: number;
|
|
20
|
+
readonly results: SpeechRecognitionResultList;
|
|
21
|
+
}
|
|
22
|
+
interface SpeechRecognitionEventMap {
|
|
23
|
+
audioend: Event;
|
|
24
|
+
audiostart: Event;
|
|
25
|
+
end: Event;
|
|
26
|
+
error: SpeechRecognitionErrorEvent;
|
|
27
|
+
nomatch: SpeechRecognitionEvent;
|
|
28
|
+
result: SpeechRecognitionEvent;
|
|
29
|
+
soundend: Event;
|
|
30
|
+
soundstart: Event;
|
|
31
|
+
speechend: Event;
|
|
32
|
+
speechstart: Event;
|
|
33
|
+
start: Event;
|
|
34
|
+
}
|
|
35
|
+
export interface SpeechRecognition extends EventTarget {
|
|
36
|
+
continuous: boolean;
|
|
37
|
+
grammars: SpeechGrammarList;
|
|
38
|
+
interimResults: boolean;
|
|
39
|
+
lang: string;
|
|
40
|
+
maxAlternatives: number;
|
|
41
|
+
onaudioend: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
42
|
+
onaudiostart: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
43
|
+
onend: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
44
|
+
onerror: ((this: SpeechRecognition, ev: SpeechRecognitionErrorEvent) => any) | null;
|
|
45
|
+
onnomatch: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null;
|
|
46
|
+
onresult: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null;
|
|
47
|
+
onsoundend: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
48
|
+
onsoundstart: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
49
|
+
onspeechend: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
50
|
+
onspeechstart: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
51
|
+
onstart: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
52
|
+
abort: () => void;
|
|
53
|
+
start: () => void;
|
|
54
|
+
stop: () => void;
|
|
55
|
+
addEventListener: (<K extends keyof SpeechRecognitionEventMap>(type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | AddEventListenerOptions) => void) & ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);
|
|
56
|
+
removeEventListener: (<K extends keyof SpeechRecognitionEventMap>(type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | EventListenerOptions) => void) & ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void);
|
|
57
|
+
}
|
|
58
|
+
export interface UseSpeechRecognitionOptions {
|
|
59
|
+
/**
|
|
60
|
+
* Controls whether continuous results are returned for each recognition, or only a single result.
|
|
61
|
+
*
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
|
+
continuous?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Controls whether interim results should be returned (true) or not (false.) Interim results are results that are not yet final
|
|
67
|
+
*
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
interimResults?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Language for SpeechRecognition
|
|
73
|
+
*
|
|
74
|
+
* @default 'en-US'
|
|
75
|
+
*/
|
|
76
|
+
lang?: Ref<string>;
|
|
77
|
+
/**
|
|
78
|
+
* A number representing the maximum returned alternatives for each result.
|
|
79
|
+
*
|
|
80
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/maxAlternatives
|
|
81
|
+
* @default 1
|
|
82
|
+
*/
|
|
83
|
+
maxAlternatives?: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Reactive SpeechRecognition.
|
|
87
|
+
*
|
|
88
|
+
* @see https://vueuse.org/useSpeechRecognition
|
|
89
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition SpeechRecognition
|
|
90
|
+
* @param options
|
|
91
|
+
*/
|
|
92
|
+
export declare function useSpeechRecognition(options?: UseSpeechRecognitionOptions): {
|
|
93
|
+
isSupported: boolean;
|
|
94
|
+
isListening: Ref<boolean>;
|
|
95
|
+
isFinal: Ref<boolean>;
|
|
96
|
+
recognition: SpeechRecognition;
|
|
97
|
+
result: Ref<string>;
|
|
98
|
+
error: Ref<SpeechRecognitionErrorEvent>;
|
|
99
|
+
toggle: (value?: boolean) => void;
|
|
100
|
+
start: () => void;
|
|
101
|
+
stop: () => void;
|
|
102
|
+
};
|
|
103
|
+
export type UseSpeechRecognitionReturn = ReturnType<typeof useSpeechRecognition>;
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { toRef, toValue, ref, shallowRef, watch } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Reactive SpeechRecognition.
|
|
4
|
+
*
|
|
5
|
+
* @see https://vueuse.org/useSpeechRecognition
|
|
6
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition SpeechRecognition
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
export function useSpeechRecognition(options = {}) {
|
|
10
|
+
const { interimResults = true, continuous = true, maxAlternatives = 1 } = options;
|
|
11
|
+
const lang = toRef(options.lang || 'en-US');
|
|
12
|
+
const isListening = ref(false);
|
|
13
|
+
const isFinal = ref(false);
|
|
14
|
+
const result = ref('');
|
|
15
|
+
const error = shallowRef(undefined);
|
|
16
|
+
const toggle = (value = !isListening.value) => {
|
|
17
|
+
isListening.value = value;
|
|
18
|
+
};
|
|
19
|
+
const start = () => {
|
|
20
|
+
isListening.value = true;
|
|
21
|
+
};
|
|
22
|
+
const stop = () => {
|
|
23
|
+
isListening.value = false;
|
|
24
|
+
};
|
|
25
|
+
const SpeechRecognition = window && (window.SpeechRecognition || window.webkitSpeechRecognition);
|
|
26
|
+
const isSupported = !!SpeechRecognition;
|
|
27
|
+
let recognition;
|
|
28
|
+
if (isSupported) {
|
|
29
|
+
recognition = new SpeechRecognition();
|
|
30
|
+
recognition.continuous = continuous;
|
|
31
|
+
recognition.interimResults = interimResults;
|
|
32
|
+
recognition.lang = toValue(lang);
|
|
33
|
+
recognition.maxAlternatives = maxAlternatives;
|
|
34
|
+
recognition.onstart = () => {
|
|
35
|
+
isFinal.value = false;
|
|
36
|
+
};
|
|
37
|
+
watch(lang, (lang) => {
|
|
38
|
+
if (recognition && !isListening.value)
|
|
39
|
+
recognition.lang = lang;
|
|
40
|
+
});
|
|
41
|
+
recognition.onresult = (event) => {
|
|
42
|
+
const currentResult = event.results[event.resultIndex];
|
|
43
|
+
const { transcript } = currentResult[0];
|
|
44
|
+
isFinal.value = currentResult.isFinal;
|
|
45
|
+
result.value = transcript;
|
|
46
|
+
error.value = undefined;
|
|
47
|
+
};
|
|
48
|
+
recognition.onerror = (event) => {
|
|
49
|
+
error.value = event;
|
|
50
|
+
};
|
|
51
|
+
recognition.onend = () => {
|
|
52
|
+
isListening.value = false;
|
|
53
|
+
recognition.lang = toValue(lang);
|
|
54
|
+
};
|
|
55
|
+
watch(isListening, () => {
|
|
56
|
+
if (isListening.value)
|
|
57
|
+
recognition.start();
|
|
58
|
+
else
|
|
59
|
+
recognition.stop();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/*
|
|
63
|
+
tryOnScopeDispose(() => {
|
|
64
|
+
isListening.value = false
|
|
65
|
+
})
|
|
66
|
+
*/
|
|
67
|
+
return {
|
|
68
|
+
isSupported,
|
|
69
|
+
isListening,
|
|
70
|
+
isFinal,
|
|
71
|
+
recognition,
|
|
72
|
+
result,
|
|
73
|
+
error,
|
|
74
|
+
toggle,
|
|
75
|
+
start,
|
|
76
|
+
stop,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=useSpeechRecognition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSpeechRecognition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C,CAAA;KACL;IACD;;;;KAIC;IAED,OAAO;QACH,WAAW;QACX,WAAW;QACX,OAAO;QACP,WAAW;QACX,MAAM;QACN,KAAK;QAEL,MAAM;QACN,KAAK;QACL,IAAI;KACP,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
export type UseSpeechSynthesisStatus = 'init' | 'play' | 'pause' | 'end';
|
|
3
|
+
export interface UseSpeechSynthesisOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Language for SpeechSynthesis
|
|
6
|
+
*
|
|
7
|
+
* @default 'en-US'
|
|
8
|
+
*/
|
|
9
|
+
lang?: Ref<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Gets and sets the pitch at which the utterance will be spoken at.
|
|
12
|
+
*
|
|
13
|
+
* @default 1
|
|
14
|
+
*/
|
|
15
|
+
pitch?: Ref<SpeechSynthesisUtterance['pitch']>;
|
|
16
|
+
/**
|
|
17
|
+
* Gets and sets the speed at which the utterance will be spoken at.
|
|
18
|
+
*
|
|
19
|
+
* @default 1
|
|
20
|
+
*/
|
|
21
|
+
rate?: Ref<SpeechSynthesisUtterance['rate']>;
|
|
22
|
+
/**
|
|
23
|
+
* Gets and sets the voice that will be used to speak the utterance.
|
|
24
|
+
*/
|
|
25
|
+
voice?: Ref<SpeechSynthesisVoice>;
|
|
26
|
+
/**
|
|
27
|
+
* Gets and sets the volume that the utterance will be spoken at.
|
|
28
|
+
*
|
|
29
|
+
* @default 1
|
|
30
|
+
*/
|
|
31
|
+
volume?: SpeechSynthesisUtterance['volume'];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Reactive SpeechSynthesis.
|
|
35
|
+
*
|
|
36
|
+
* @see https://vueuse.org/useSpeechSynthesis
|
|
37
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis SpeechSynthesis
|
|
38
|
+
*/
|
|
39
|
+
export declare function useSpeechSynthesis(text: Ref<string>, options?: UseSpeechSynthesisOptions): {
|
|
40
|
+
isSupported: boolean;
|
|
41
|
+
isPlaying: Ref<boolean>;
|
|
42
|
+
status: Ref<UseSpeechSynthesisStatus>;
|
|
43
|
+
utterance: import("vue").ComputedRef<SpeechSynthesisUtterance>;
|
|
44
|
+
error: Ref<SpeechSynthesisErrorEvent>;
|
|
45
|
+
stop: () => void;
|
|
46
|
+
toggle: (value?: boolean) => void;
|
|
47
|
+
speak: () => void;
|
|
48
|
+
};
|
|
49
|
+
export type UseSpeechSynthesisReturn = ReturnType<typeof useSpeechSynthesis>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { computed, ref, shallowRef, watch, toRef, toValue } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Reactive SpeechSynthesis.
|
|
4
|
+
*
|
|
5
|
+
* @see https://vueuse.org/useSpeechSynthesis
|
|
6
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis SpeechSynthesis
|
|
7
|
+
*/
|
|
8
|
+
export function useSpeechSynthesis(text, options = {}) {
|
|
9
|
+
const { pitch = 1, rate = 1, volume = 1 } = options;
|
|
10
|
+
const synth = window && window.speechSynthesis;
|
|
11
|
+
const isSupported = !!synth;
|
|
12
|
+
const isPlaying = ref(false);
|
|
13
|
+
const status = ref('init');
|
|
14
|
+
const spokenText = toRef(text || '');
|
|
15
|
+
const lang = toRef(options.lang || 'en-US');
|
|
16
|
+
const error = shallowRef(undefined);
|
|
17
|
+
const toggle = (value = !isPlaying.value) => {
|
|
18
|
+
isPlaying.value = value;
|
|
19
|
+
};
|
|
20
|
+
const bindEventsForUtterance = (utterance) => {
|
|
21
|
+
utterance.lang = toValue(lang);
|
|
22
|
+
utterance.voice = toValue(options.voice) || null;
|
|
23
|
+
utterance.pitch = toValue(pitch);
|
|
24
|
+
utterance.rate = toValue(rate);
|
|
25
|
+
utterance.volume = volume;
|
|
26
|
+
utterance.onstart = () => {
|
|
27
|
+
isPlaying.value = true;
|
|
28
|
+
status.value = 'play';
|
|
29
|
+
};
|
|
30
|
+
utterance.onpause = () => {
|
|
31
|
+
isPlaying.value = false;
|
|
32
|
+
status.value = 'pause';
|
|
33
|
+
};
|
|
34
|
+
utterance.onresume = () => {
|
|
35
|
+
isPlaying.value = true;
|
|
36
|
+
status.value = 'play';
|
|
37
|
+
};
|
|
38
|
+
utterance.onend = () => {
|
|
39
|
+
isPlaying.value = false;
|
|
40
|
+
status.value = 'end';
|
|
41
|
+
};
|
|
42
|
+
utterance.onerror = (event) => {
|
|
43
|
+
error.value = event;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const utterance = computed(() => {
|
|
47
|
+
isPlaying.value = false;
|
|
48
|
+
status.value = 'init';
|
|
49
|
+
const newUtterance = new SpeechSynthesisUtterance(spokenText.value);
|
|
50
|
+
bindEventsForUtterance(newUtterance);
|
|
51
|
+
return newUtterance;
|
|
52
|
+
});
|
|
53
|
+
const speak = () => {
|
|
54
|
+
synth.cancel();
|
|
55
|
+
if (utterance)
|
|
56
|
+
synth.speak(utterance.value);
|
|
57
|
+
};
|
|
58
|
+
const stop = () => {
|
|
59
|
+
synth.cancel();
|
|
60
|
+
isPlaying.value = false;
|
|
61
|
+
};
|
|
62
|
+
if (isSupported) {
|
|
63
|
+
bindEventsForUtterance(utterance.value);
|
|
64
|
+
watch(lang, (lang) => {
|
|
65
|
+
if (utterance.value && !isPlaying.value)
|
|
66
|
+
utterance.value.lang = lang;
|
|
67
|
+
});
|
|
68
|
+
if (options.voice) {
|
|
69
|
+
watch(options.voice, () => {
|
|
70
|
+
synth.cancel();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
watch(isPlaying, () => {
|
|
74
|
+
if (isPlaying.value)
|
|
75
|
+
synth.resume();
|
|
76
|
+
else
|
|
77
|
+
synth.pause();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/*
|
|
81
|
+
tryOnScopeDispose(() => {
|
|
82
|
+
isPlaying.value = false
|
|
83
|
+
})
|
|
84
|
+
*/
|
|
85
|
+
return {
|
|
86
|
+
isSupported,
|
|
87
|
+
isPlaying,
|
|
88
|
+
status,
|
|
89
|
+
utterance,
|
|
90
|
+
error,
|
|
91
|
+
stop,
|
|
92
|
+
toggle,
|
|
93
|
+
speak,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=useSpeechSynthesis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSpeechSynthesis.js","sourceRoot":"","sources":["../src/useSpeechSynthesis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAO,OAAO,EAAE,MAAM,KAAK,CAAC;AAmC5E;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAC9B,IAAiB,EACjB,UAAqC,EAAE;IAEvC,MAAM,EACF,KAAK,GAAG,CAAC,EACT,IAAI,GAAG,CAAC,EACR,MAAM,GAAG,CAAC,EACb,GAAG,OAAO,CAAA;IAEX,MAAM,KAAK,GAAG,MAAM,IAAK,MAAc,CAAC,eAAkC,CAAA;IAC1E,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAA;IAC3B,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,CAAA;IAC5B,MAAM,MAAM,GAAG,GAAG,CAA2B,MAAM,CAAC,CAAA;IAEpD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;IACpC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,CAAA;IAC3C,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAA+C,CAAA;IAEjF,MAAM,MAAM,GAAG,CAAC,KAAK,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE;QACxC,SAAS,CAAC,KAAK,GAAG,KAAK,CAAA;IAC3B,CAAC,CAAA;IAED,MAA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|
|
3
|
+
};
|
|
4
|
+
export interface IValueText {
|
|
5
|
+
value: number;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class Helper {
|
|
9
|
+
static fromMilliseconds1970(ms: number): Date;
|
|
10
|
+
static toTicks(dt: Date): number;
|
|
11
|
+
static toUnixTime(dt: Date): number;
|
|
12
|
+
static fromTicks(ticks: number): Date;
|
|
13
|
+
static fromUnixTime(unixTime: number): Date;
|
|
14
|
+
static toUTC(dt: Date): Date;
|
|
15
|
+
static toLocal(dt: Date): Date;
|
|
16
|
+
static round(value: number, digits: number | undefined): string;
|
|
17
|
+
static formatTime(dt: Date, withSeconds?: boolean): string;
|
|
18
|
+
static formatDayTime(dt: Date, withSeconds?: boolean): string;
|
|
19
|
+
private static padNumber2;
|
|
20
|
+
static toColor(red: number, green: number, blue: number): string;
|
|
21
|
+
static generateUUID(): string;
|
|
22
|
+
static deepCompare(o: any, p: any): boolean;
|
|
23
|
+
static isMobileDevice(): boolean;
|
|
24
|
+
static wait(ms: number): Promise<void>;
|
|
25
|
+
static enumToString(en: any, value: unknown): string;
|
|
26
|
+
static stringToEnum(en: any, value: unknown): number;
|
|
27
|
+
static getEnumOptions(en: any): IValueText[];
|
|
28
|
+
}
|