@ozdemirburak/morse-code-translator 5.0.4 → 7.0.0
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/LICENSE +1 -1
- package/README.md +39 -16
- package/dist/audio.d.ts +4 -0
- package/dist/audio.d.ts.map +1 -0
- package/dist/characters.d.ts +12 -0
- package/dist/characters.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/morse-code-translator.es.js +616 -0
- package/dist/morse-code-translator.es.js.map +1 -0
- package/dist/morse-code-translator.umd.js +2 -0
- package/dist/morse-code-translator.umd.js.map +1 -0
- package/dist/options.d.ts +4 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +33 -28
- package/dist/morse-code-translator.min.js +0 -1
- package/src/audio.ts +0 -191
- package/src/characters.ts +0 -139
- package/src/index.d.ts +0 -26
- package/src/index.js +0 -353
- package/src/index.ts +0 -58
- package/src/options.ts +0 -24
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -23,10 +23,23 @@ const decoded = morse.decode('... --- ...'); // SOS
|
|
|
23
23
|
const characters = morse.characters(); // {'1': {'A': '.-', ...}, ..., '11': {'ㄱ': '.-..', ...}}
|
|
24
24
|
|
|
25
25
|
const audio = morse.audio('SOS');
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
audio.
|
|
29
|
-
|
|
26
|
+
|
|
27
|
+
// Playback control
|
|
28
|
+
await audio.play(); // play audio (returns Promise)
|
|
29
|
+
audio.pause(); // pause audio
|
|
30
|
+
await audio.play(); // resume from paused position
|
|
31
|
+
await audio.seek(1.5); // seek to 1.5 seconds
|
|
32
|
+
audio.stop(); // stop audio and reset to beginning
|
|
33
|
+
audio.dispose(); // cleanup and dispose audio resources
|
|
34
|
+
|
|
35
|
+
// Playback state and info
|
|
36
|
+
audio.getState(); // 'ready', 'playing', 'paused', 'stopped', or 'disposed'
|
|
37
|
+
audio.getCurrentTime(); // current playback position in seconds
|
|
38
|
+
audio.getTotalTime(); // total duration in seconds
|
|
39
|
+
|
|
40
|
+
// Export audio
|
|
41
|
+
await audio.exportWave(); // download audio wave file (promise)
|
|
42
|
+
const url = await audio.getWaveUrl(); // get audio wave url (promise)
|
|
30
43
|
const blob = await audio.getWaveBlob(); // get audio wave blob (promise)
|
|
31
44
|
```
|
|
32
45
|
|
|
@@ -65,17 +78,28 @@ const arabicAudio = morse.audio('البراق', { // generates the Morse .- .-..
|
|
|
65
78
|
volume: 100, // the volume in percent (0-100)
|
|
66
79
|
oscillator: {
|
|
67
80
|
type: 'sine', // sine, square, sawtooth, triangle
|
|
68
|
-
frequency: 500
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
frequency: 500 // value in hertz
|
|
82
|
+
},
|
|
83
|
+
events: {
|
|
84
|
+
onready: () => console.log('Audio is ready'),
|
|
85
|
+
onstarted: () => console.log('Playback started'),
|
|
86
|
+
onpaused: () => console.log('Playback paused'),
|
|
87
|
+
onstopped: () => console.log('Playback stopped'),
|
|
88
|
+
onended: () => console.log('Playback completed naturally'),
|
|
89
|
+
onseeked: (time) => console.log('Seeked to:', time)
|
|
72
90
|
}
|
|
73
91
|
});
|
|
92
|
+
|
|
93
|
+
// Access to Web Audio API nodes (for advanced users)
|
|
74
94
|
const oscillator = arabicAudio.oscillator; // OscillatorNode
|
|
75
|
-
const context = arabicAudio.context; // AudioContext
|
|
95
|
+
const context = arabicAudio.context; // AudioContext
|
|
76
96
|
const gainNode = arabicAudio.gainNode; // GainNode
|
|
77
|
-
|
|
78
|
-
|
|
97
|
+
|
|
98
|
+
// Playback control
|
|
99
|
+
await arabicAudio.play(); // will start playing Morse audio
|
|
100
|
+
arabicAudio.pause(); // will pause Morse audio
|
|
101
|
+
await arabicAudio.play(); // will resume from where it was paused
|
|
102
|
+
arabicAudio.stop(); // will stop and reset to beginning
|
|
79
103
|
```
|
|
80
104
|
|
|
81
105
|
## Contributions
|
|
@@ -85,17 +109,16 @@ with extensive feedback and contributions from [numerous developers](https://git
|
|
|
85
109
|
|
|
86
110
|
Special thanks to [Chris Jones](https://github.com/chris--jones), who added many great features.
|
|
87
111
|
|
|
88
|
-
##
|
|
112
|
+
## License & Attribution
|
|
89
113
|
|
|
90
|
-
|
|
114
|
+
[MIT licensed](LICENSE), use it however you want. But if this library saved you time, link back to
|
|
115
|
+
the project homepage. It is how open-source maintainers get credit for their work.
|
|
91
116
|
|
|
92
117
|
```html
|
|
93
118
|
<a href="https://morsecodetranslator.com">Morse Code Translator</a>
|
|
94
119
|
```
|
|
95
120
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
The MIT License (MIT). Please see [License File](LICENSE) for more information.
|
|
121
|
+
Takes 30 seconds. Appreciated, not required.
|
|
99
122
|
|
|
100
123
|
[npm-version]: https://img.shields.io/npm/v/@ozdemirburak/morse-code-translator.svg?style=flat-square
|
|
101
124
|
[npm-downloads]: https://img.shields.io/npm/dm/@ozdemirburak/morse-code-translator.svg?style=flat-square
|
package/dist/audio.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio.d.ts","sourceRoot":"","sources":["../src/audio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAA2B,MAAM,YAAY,CAAC;AA6IhF,QAAA,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,SAAS,OAAO,KAAG,WAuVhD,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Characters, Options } from './types.js';
|
|
2
|
+
declare const baseCharacters: Characters;
|
|
3
|
+
declare const getCharacters: (options: Options) => {
|
|
4
|
+
'0': Record<string, string>;
|
|
5
|
+
'1': {
|
|
6
|
+
[x: string]: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
declare const getMappedCharacters: (options: Options, usePriority: boolean) => Characters;
|
|
10
|
+
declare const swapCharacters: (options: Options) => Record<string, string>;
|
|
11
|
+
export { baseCharacters, getCharacters, getMappedCharacters, swapCharacters };
|
|
12
|
+
//# sourceMappingURL=characters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"characters.d.ts","sourceRoot":"","sources":["../src/characters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEtD,QAAA,MAAM,cAAc,EAAE,UA+FrB,CAAC;AAEF,QAAA,MAAM,aAAa,GAAI,SAAS,OAAO;;;;;CAOrC,CAAC;AAEH,QAAA,MAAM,mBAAmB,GAAI,SAAS,OAAO,EAAE,aAAa,OAAO,eAgBlE,CAAC;AAEF,QAAA,MAAM,cAAc,GAAI,SAAS,OAAO,2BAqBvC,CAAC;AAEF,OAAO,EACL,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,cAAc,EACf,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Options, Characters, AudioResult } from './types.js';
|
|
2
|
+
export declare const encode: (text: string, opts?: Partial<Options>) => string;
|
|
3
|
+
export declare const decode: (morse: string, opts?: Partial<Options>) => string;
|
|
4
|
+
export declare const characters: (options?: Partial<Options>, usePriority?: boolean) => Characters;
|
|
5
|
+
export declare const audio: (text: string, opts?: Partial<Options>, morseString?: string) => AudioResult;
|
|
6
|
+
export type { Options, Characters, AudioResult, Oscillator, AudioState, AudioEvents } from './types.js';
|
|
7
|
+
declare const _default: {
|
|
8
|
+
encode: (text: string, opts?: Partial<Options>) => string;
|
|
9
|
+
decode: (morse: string, opts?: Partial<Options>) => string;
|
|
10
|
+
characters: (options?: Partial<Options>, usePriority?: boolean) => Characters;
|
|
11
|
+
audio: (text: string, opts?: Partial<Options>, morseString?: string) => AudioResult;
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuBnE,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,EAAE,OAAO,OAAO,CAAC,OAAO,CAAC,KAAG,MAuC9D,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,EAAE,OAAO,OAAO,CAAC,OAAO,CAAC,KAAG,MAe/D,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,UAAU,OAAO,CAAC,OAAO,CAAC,EAAE,cAAa,OAAe,KAAG,UAErF,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,MAAM,KAAG,WAInF,CAAC;AAGF,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;;mBArE3E,MAAM,SAAS,OAAO,CAAC,OAAO,CAAC,KAAG,MAAM;oBAyCvC,MAAM,SAAS,OAAO,CAAC,OAAO,CAAC,KAAG,MAAM;2BAiBjC,OAAO,CAAC,OAAO,CAAC,gBAAe,OAAO,KAAW,UAAU;kBAIpE,MAAM,SAAS,OAAO,CAAC,OAAO,CAAC,gBAAgB,MAAM,KAAG,WAAW;;AAS/F,wBAKE"}
|