@ozdemirburak/morse-code-translator 5.0.3 → 6.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 Burak Özdemir
3
+ Copyright (c) 2025 Burak Özdemir
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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
- audio.play(); // play audio
27
- audio.stop(); // stop audio (cannot resume)
28
- audio.exportWave(); // download audio wave file (promise)
29
- const url = await audio.getWaveUrl(); // get audio wave url (promise)
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', or 'stopped'
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, // value in hertz
69
- onended: function () { // event that fires when the tone stops playing
70
- console.log('ended');
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
- arabicAudio.play(); // will start playing Morse audio
78
- arabicAudio.stop(); // will stop playing Morse audio
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
- ## References
112
+ ## License & Attribution
89
113
 
90
- Please consider referencing the website of this project, if you find this package useful for your work.
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
- ## License
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
@@ -0,0 +1,4 @@
1
+ import { Options, AudioResult } from './types.js';
2
+ declare const audio: (morse: string, options: Options) => AudioResult;
3
+ export default audio;
4
+ //# sourceMappingURL=audio.d.ts.map
@@ -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;AAyHhF,QAAA,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,SAAS,OAAO,KAAG,WAqQhD,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Characters, Options } from './types.js';
2
+ declare const getCharacters: (options: Options) => {
3
+ '0': Record<string, string>;
4
+ '1': {
5
+ [x: string]: string;
6
+ };
7
+ };
8
+ declare const getMappedCharacters: (options: Options, usePriority: boolean) => Characters;
9
+ declare const swapCharacters: (options: Options) => Record<string, string>;
10
+ export { getCharacters, getMappedCharacters, swapCharacters };
11
+ //# 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;AAmGtD,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,2BAWvC,CAAC;AAEF,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,cAAc,EACf,CAAC"}
@@ -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;AAEnE,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,EAAE,OAAO,OAAO,CAAC,OAAO,CAAC,KAAG,MAgB9D,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,EAAE,OAAO,OAAO,CAAC,OAAO,CAAC,KAAG,MAc/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;;mBA7C3E,MAAM,SAAS,OAAO,CAAC,OAAO,CAAC,KAAG,MAAM;oBAkBvC,MAAM,SAAS,OAAO,CAAC,OAAO,CAAC,KAAG,MAAM;2BAgBjC,OAAO,CAAC,OAAO,CAAC,gBAAe,OAAO,KAAW,UAAU;kBAIpE,MAAM,SAAS,OAAO,CAAC,OAAO,CAAC,gBAAgB,MAAM,KAAG,WAAW;;AAS/F,wBAKE"}