@ciphore/radiocli 0.1.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/CODE_OF_CONDUCT.md +13 -0
  3. package/CONTRIBUTING.md +56 -0
  4. package/LICENSE +21 -0
  5. package/README.md +364 -0
  6. package/SECURITY.md +31 -0
  7. package/dist/activity/stats.js +122 -0
  8. package/dist/cli.js +143 -0
  9. package/dist/player/backend-install.js +122 -0
  10. package/dist/player/command.js +8 -0
  11. package/dist/player/player-controller.js +494 -0
  12. package/dist/playlists/playlist.js +169 -0
  13. package/dist/providers/cache.js +92 -0
  14. package/dist/providers/provider-manager.js +50 -0
  15. package/dist/providers/radio-browser.js +412 -0
  16. package/dist/providers/radio-garden.js +87 -0
  17. package/dist/storage/store.js +369 -0
  18. package/dist/types.js +55 -0
  19. package/dist/ui/App.js +770 -0
  20. package/dist/ui/AppContent.js +45 -0
  21. package/dist/ui/app-state.js +250 -0
  22. package/dist/ui/components/Logo.js +9 -0
  23. package/dist/ui/components/Menu.js +23 -0
  24. package/dist/ui/components/ScreenHeader.js +15 -0
  25. package/dist/ui/components/StationList.js +23 -0
  26. package/dist/ui/components/TopTabs.js +82 -0
  27. package/dist/ui/cosmo-land-data.js +4 -0
  28. package/dist/ui/cosmo-world-map.js +156 -0
  29. package/dist/ui/explore-map-layout.js +24 -0
  30. package/dist/ui/format.js +22 -0
  31. package/dist/ui/layout.js +27 -0
  32. package/dist/ui/list-window.js +8 -0
  33. package/dist/ui/page-footer.js +45 -0
  34. package/dist/ui/playback-footer.js +48 -0
  35. package/dist/ui/screen-items.js +26 -0
  36. package/dist/ui/screens/CountriesScreen.js +10 -0
  37. package/dist/ui/screens/ExploreScreen.js +44 -0
  38. package/dist/ui/screens/HomeScreen.js +9 -0
  39. package/dist/ui/screens/MapScreen.js +59 -0
  40. package/dist/ui/screens/NowPlayingScreen.js +79 -0
  41. package/dist/ui/screens/SearchScreen.js +12 -0
  42. package/dist/ui/screens/SettingsScreen.js +38 -0
  43. package/dist/ui/screens/StationScreen.js +7 -0
  44. package/dist/ui/screens/StatsScreen.js +90 -0
  45. package/dist/ui/terminal-mouse.js +38 -0
  46. package/dist/ui/theme.js +105 -0
  47. package/dist/ui/use-app-input.js +387 -0
  48. package/dist/ui/use-command-executor.js +156 -0
  49. package/dist/ui/visualizers/receiver-visualizers.js +2188 -0
  50. package/dist/ui/world-map.js +274 -0
  51. package/docs/THIRD_PARTY_NOTICES.md +33 -0
  52. package/package.json +83 -0
@@ -0,0 +1,274 @@
1
+ const latitudeRange = { min: -55, max: 75 };
2
+ const countryCoordinates = {
3
+ AD: { lat: 42.5, lon: 1.6 },
4
+ AE: { lat: 24.4, lon: 54.3 },
5
+ AF: { lat: 33.9, lon: 67.7 },
6
+ AG: { lat: 17.1, lon: -61.8 },
7
+ AI: { lat: 18.2, lon: -63.1 },
8
+ AL: { lat: 41.1, lon: 20.1 },
9
+ AM: { lat: 40.1, lon: 45 },
10
+ AO: { lat: -11.2, lon: 17.9 },
11
+ AR: { lat: -34.6, lon: -64 },
12
+ AT: { lat: 47.5, lon: 14.5 },
13
+ AU: { lat: -25.3, lon: 133.8 },
14
+ AZ: { lat: 40.1, lon: 47.6 },
15
+ BA: { lat: 44.2, lon: 17.7 },
16
+ BB: { lat: 13.2, lon: -59.5 },
17
+ BD: { lat: 23.7, lon: 90.4 },
18
+ BE: { lat: 50.8, lon: 4.5 },
19
+ BG: { lat: 42.7, lon: 25.5 },
20
+ BH: { lat: 26.1, lon: 50.6 },
21
+ BM: { lat: 32.3, lon: -64.8 },
22
+ BN: { lat: 4.5, lon: 114.7 },
23
+ BO: { lat: -16.3, lon: -63.6 },
24
+ BR: { lat: -10.8, lon: -53.1 },
25
+ BS: { lat: 25, lon: -77.4 },
26
+ BY: { lat: 53.7, lon: 27.9 },
27
+ BZ: { lat: 17.2, lon: -88.5 },
28
+ CA: { lat: 56.1, lon: -106.3 },
29
+ CD: { lat: -2.9, lon: 23.7 },
30
+ CH: { lat: 46.8, lon: 8.2 },
31
+ CL: { lat: -35.7, lon: -71.5 },
32
+ CN: { lat: 35.9, lon: 104.2 },
33
+ CO: { lat: 4.6, lon: -74.3 },
34
+ CR: { lat: 9.7, lon: -84.2 },
35
+ CU: { lat: 21.5, lon: -79.5 },
36
+ CY: { lat: 35.1, lon: 33.4 },
37
+ CZ: { lat: 49.8, lon: 15.5 },
38
+ DE: { lat: 51.2, lon: 10.5 },
39
+ DK: { lat: 56.3, lon: 9.5 },
40
+ DO: { lat: 18.7, lon: -70.2 },
41
+ DZ: { lat: 28, lon: 1.7 },
42
+ EC: { lat: -1.8, lon: -78.2 },
43
+ EE: { lat: 58.6, lon: 25 },
44
+ EG: { lat: 26.8, lon: 30.8 },
45
+ ES: { lat: 40.5, lon: -3.7 },
46
+ FI: { lat: 61.9, lon: 25.7 },
47
+ FR: { lat: 46.2, lon: 2.2 },
48
+ GB: { lat: 55.4, lon: -3.4 },
49
+ GE: { lat: 42.3, lon: 43.4 },
50
+ GH: { lat: 7.9, lon: -1 },
51
+ GR: { lat: 39.1, lon: 21.8 },
52
+ GT: { lat: 15.8, lon: -90.2 },
53
+ HK: { lat: 22.3, lon: 114.2 },
54
+ HR: { lat: 45.1, lon: 15.2 },
55
+ HU: { lat: 47.2, lon: 19.5 },
56
+ ID: { lat: -2.5, lon: 118 },
57
+ IE: { lat: 53.4, lon: -8.2 },
58
+ IL: { lat: 31, lon: 35 },
59
+ IN: { lat: 20.6, lon: 78.9 },
60
+ IQ: { lat: 33.2, lon: 43.7 },
61
+ IR: { lat: 32.4, lon: 53.7 },
62
+ IS: { lat: 64.9, lon: -18.6 },
63
+ IT: { lat: 42.8, lon: 12.6 },
64
+ JM: { lat: 18.1, lon: -77.3 },
65
+ JO: { lat: 31.2, lon: 36.2 },
66
+ JP: { lat: 36.2, lon: 138.3 },
67
+ KE: { lat: -0.1, lon: 37.9 },
68
+ KH: { lat: 12.6, lon: 104.9 },
69
+ KR: { lat: 36.5, lon: 127.8 },
70
+ KW: { lat: 29.3, lon: 47.5 },
71
+ KZ: { lat: 48, lon: 67 },
72
+ LB: { lat: 33.9, lon: 35.9 },
73
+ LK: { lat: 7.9, lon: 80.8 },
74
+ LT: { lat: 55.2, lon: 23.9 },
75
+ LU: { lat: 49.8, lon: 6.1 },
76
+ LV: { lat: 56.9, lon: 24.6 },
77
+ MA: { lat: 31.8, lon: -7.1 },
78
+ MD: { lat: 47.4, lon: 28.4 },
79
+ ME: { lat: 42.7, lon: 19.3 },
80
+ MK: { lat: 41.6, lon: 21.7 },
81
+ MT: { lat: 35.9, lon: 14.4 },
82
+ MX: { lat: 23.6, lon: -102.6 },
83
+ MY: { lat: 4.2, lon: 102 },
84
+ NG: { lat: 9.1, lon: 8.7 },
85
+ NI: { lat: 12.9, lon: -85.2 },
86
+ NL: { lat: 52.1, lon: 5.3 },
87
+ NO: { lat: 60.5, lon: 8.5 },
88
+ NP: { lat: 28.4, lon: 84.1 },
89
+ NZ: { lat: -40.9, lon: 174.9 },
90
+ PA: { lat: 8.5, lon: -80.8 },
91
+ PE: { lat: -9.2, lon: -75 },
92
+ PH: { lat: 12.9, lon: 121.8 },
93
+ PK: { lat: 30.4, lon: 69.3 },
94
+ PL: { lat: 51.9, lon: 19.1 },
95
+ PR: { lat: 18.2, lon: -66.6 },
96
+ PT: { lat: 39.4, lon: -8.2 },
97
+ PY: { lat: -23.4, lon: -58.4 },
98
+ QA: { lat: 25.4, lon: 51.2 },
99
+ RO: { lat: 45.9, lon: 24.9 },
100
+ RS: { lat: 44, lon: 20.9 },
101
+ RU: { lat: 61.5, lon: 96 },
102
+ SA: { lat: 23.9, lon: 45.1 },
103
+ SE: { lat: 60.1, lon: 18.6 },
104
+ SG: { lat: 1.4, lon: 103.8 },
105
+ SI: { lat: 46.1, lon: 14.9 },
106
+ SK: { lat: 48.7, lon: 19.7 },
107
+ TH: { lat: 15.9, lon: 101 },
108
+ TN: { lat: 34, lon: 9.5 },
109
+ TR: { lat: 39, lon: 35.2 },
110
+ TW: { lat: 23.7, lon: 121 },
111
+ UA: { lat: 48.4, lon: 31.2 },
112
+ US: { lat: 39.8, lon: -98.6 },
113
+ UY: { lat: -32.5, lon: -55.8 },
114
+ VE: { lat: 6.4, lon: -66.6 },
115
+ VN: { lat: 14.1, lon: 108.3 },
116
+ ZA: { lat: -30.6, lon: 22.9 }
117
+ };
118
+ export function buildWorldMap(countries, selectedCountry, mode, width) {
119
+ const mapWidth = Math.max(mode === 'full' ? 84 : 56, Math.min(mode === 'full' ? 124 : 72, width));
120
+ const mapHeight = mode === 'full' ? 14 : 9;
121
+ const grid = Array.from({ length: mapHeight }, (_, y) => Array.from({ length: mapWidth }, (_, x) => ({
122
+ char: baseMapChar(x, y, mapWidth, mapHeight),
123
+ kind: baseMapKind(x, y, mapWidth, mapHeight)
124
+ })));
125
+ const knownCountries = countries.filter(country => countryCoordinates[country.code]);
126
+ const stationCounts = knownCountries.map(country => country.stationCount);
127
+ const maxStations = Math.max(1, ...stationCounts);
128
+ const labeledCountries = new Set(Array.from(knownCountries)
129
+ .sort((a, b) => b.stationCount - a.stationCount)
130
+ .slice(0, mode === 'full' ? 34 : 18)
131
+ .map(country => country.code));
132
+ if (selectedCountry?.code && countryCoordinates[selectedCountry.code]) {
133
+ labeledCountries.add(selectedCountry.code);
134
+ }
135
+ for (const country of knownCountries) {
136
+ const coordinate = countryCoordinates[country.code];
137
+ const projected = projectCoordinate(coordinate, mapWidth, mapHeight);
138
+ const level = densityLevel(country.stationCount, maxStations);
139
+ if (labeledCountries.has(country.code)) {
140
+ placeCountryLabel(grid, country.code, projected.x, projected.y, country === selectedCountry, level);
141
+ }
142
+ else {
143
+ placeCountryDot(grid, projected.x, projected.y, level);
144
+ }
145
+ }
146
+ return {
147
+ rows: grid.map(cells => ({ cells })),
148
+ plotted: knownCountries.length,
149
+ unplotted: Math.max(0, countries.length - knownCountries.length)
150
+ };
151
+ }
152
+ function baseMapChar(x, y, width, height) {
153
+ const coordinate = unprojectCoordinate(x, y, width, height);
154
+ if (isApproximateLand(coordinate.lat, coordinate.lon)) {
155
+ return '·';
156
+ }
157
+ if (x % Math.max(10, Math.round(width / 8)) === 0 || y === Math.floor(height * 0.42)) {
158
+ return '·';
159
+ }
160
+ return ' ';
161
+ }
162
+ function baseMapKind(x, y, width, height) {
163
+ const coordinate = unprojectCoordinate(x, y, width, height);
164
+ return isApproximateLand(coordinate.lat, coordinate.lon) ? 'land' : 'grid';
165
+ }
166
+ function projectCoordinate(coordinate, width, height) {
167
+ const lon = Math.max(-180, Math.min(180, coordinate.lon));
168
+ const lat = Math.max(latitudeRange.min, Math.min(latitudeRange.max, coordinate.lat));
169
+ return {
170
+ x: Math.round(((lon + 180) / 360) * (width - 1)),
171
+ y: Math.round(((latitudeRange.max - lat) / (latitudeRange.max - latitudeRange.min)) * (height - 1))
172
+ };
173
+ }
174
+ function unprojectCoordinate(x, y, width, height) {
175
+ return {
176
+ lon: (x / Math.max(1, width - 1)) * 360 - 180,
177
+ lat: latitudeRange.max - (y / Math.max(1, height - 1)) * (latitudeRange.max - latitudeRange.min)
178
+ };
179
+ }
180
+ function placeCountryLabel(grid, code, x, y, selected, level) {
181
+ const label = code.slice(0, 2).toUpperCase();
182
+ const offsets = [
183
+ { x: 0, y: 0 },
184
+ { x: 1, y: 0 },
185
+ { x: -2, y: 0 },
186
+ { x: 0, y: -1 },
187
+ { x: 0, y: 1 },
188
+ { x: 2, y: -1 },
189
+ { x: -3, y: 1 },
190
+ { x: 2, y: 1 },
191
+ { x: -3, y: -1 }
192
+ ];
193
+ const kind = selected ? 'selected' : levelKind(level);
194
+ for (const offset of offsets) {
195
+ const startX = x + offset.x;
196
+ const labelY = y + offset.y;
197
+ if (canPlaceLabel(grid, label, startX, labelY)) {
198
+ for (let index = 0; index < label.length; index += 1) {
199
+ grid[labelY][startX + index] = { char: label[index], kind };
200
+ }
201
+ return;
202
+ }
203
+ }
204
+ placeCountryDot(grid, x, y, level);
205
+ }
206
+ function canPlaceLabel(grid, label, x, y) {
207
+ const width = grid[0]?.length ?? 0;
208
+ if (y < 0 || y >= grid.length || x < 0 || x + label.length > width) {
209
+ return false;
210
+ }
211
+ for (let index = 0; index < label.length; index += 1) {
212
+ const kind = grid[y][x + index].kind;
213
+ if (kind !== 'empty' && kind !== 'grid' && kind !== 'land') {
214
+ return false;
215
+ }
216
+ }
217
+ return true;
218
+ }
219
+ function placeCountryDot(grid, x, y, level) {
220
+ if (y < 0 || y >= grid.length || x < 0 || x >= (grid[0]?.length ?? 0)) {
221
+ return;
222
+ }
223
+ const existing = grid[y][x];
224
+ if (existing.kind === 'selected') {
225
+ return;
226
+ }
227
+ grid[y][x] = {
228
+ char: level >= 4 ? '●' : level >= 3 ? '•' : '·',
229
+ kind: levelKind(level)
230
+ };
231
+ }
232
+ function densityLevel(stationCount, maxStations) {
233
+ const ratio = stationCount / Math.max(1, maxStations);
234
+ if (ratio >= 0.7) {
235
+ return 4;
236
+ }
237
+ if (ratio >= 0.35) {
238
+ return 3;
239
+ }
240
+ if (ratio >= 0.12) {
241
+ return 2;
242
+ }
243
+ return 1;
244
+ }
245
+ function levelKind(level) {
246
+ if (level >= 4) {
247
+ return 'level4';
248
+ }
249
+ if (level >= 3) {
250
+ return 'level3';
251
+ }
252
+ if (level >= 2) {
253
+ return 'level2';
254
+ }
255
+ return 'level1';
256
+ }
257
+ function isApproximateLand(lat, lon) {
258
+ return (ellipse(lat, lon, 50, -110, 30, 62) ||
259
+ ellipse(lat, lon, 18, -92, 14, 28) ||
260
+ ellipse(lat, lon, -19, -61, 36, 21) ||
261
+ ellipse(lat, lon, 54, -42, 12, 22) ||
262
+ ellipse(lat, lon, 49, 15, 18, 28) ||
263
+ ellipse(lat, lon, 47, 78, 31, 88) ||
264
+ ellipse(lat, lon, 12, 20, 38, 30) ||
265
+ ellipse(lat, lon, 21, 78, 16, 28) ||
266
+ ellipse(lat, lon, 6, 115, 18, 30) ||
267
+ ellipse(lat, lon, -25, 134, 15, 26) ||
268
+ ellipse(lat, lon, -41, 173, 6, 9));
269
+ }
270
+ function ellipse(lat, lon, centerLat, centerLon, radiusLat, radiusLon) {
271
+ const dy = (lat - centerLat) / radiusLat;
272
+ const dx = (lon - centerLon) / radiusLon;
273
+ return dx * dx + dy * dy <= 1;
274
+ }
@@ -0,0 +1,33 @@
1
+ # Third-Party Notices
2
+
3
+ ## cosmo-tui World Map
4
+
5
+ RadioCLI's Explore braille world-map renderer and packaged land polygon data are
6
+ adapted from `irahulstomar/cosmo-tui`.
7
+
8
+ MIT License
9
+
10
+ Copyright (c) 2026 Rahul
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+
30
+ ## Natural Earth
31
+
32
+ The land polygon data is derived from Natural Earth 110m land data. Natural
33
+ Earth vector data is public domain.
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@ciphore/radiocli",
3
+ "version": "0.1.0",
4
+ "description": "A terminal-first world radio receiver built with Ink, mpv, and resilient public-radio providers.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Ciphore",
8
+ "homepage": "https://github.com/Ciphore/RadioCLI#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/Ciphore/RadioCLI.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/Ciphore/RadioCLI/issues"
15
+ },
16
+ "keywords": [
17
+ "terminal",
18
+ "tui",
19
+ "cli",
20
+ "radio",
21
+ "internet-radio",
22
+ "mpv",
23
+ "ink",
24
+ "react",
25
+ "radio-browser",
26
+ "playlist"
27
+ ],
28
+ "files": [
29
+ "dist",
30
+ "README.md",
31
+ "LICENSE",
32
+ "CHANGELOG.md",
33
+ "SECURITY.md",
34
+ "CONTRIBUTING.md",
35
+ "CODE_OF_CONDUCT.md",
36
+ "docs"
37
+ ],
38
+ "bin": {
39
+ "radiocli": "dist/cli.js"
40
+ },
41
+ "scripts": {
42
+ "dev": "tsx src/cli.tsx",
43
+ "clean": "node -e \"require('node:fs').rmSync('dist', {recursive: true, force: true})\"",
44
+ "build": "npm run clean && tsc -p tsconfig.build.json && node scripts/ensure-bin-executable.mjs",
45
+ "check": "tsc -p tsconfig.json --noEmit",
46
+ "check:unused": "tsc -p tsconfig.json --noEmit --noUnusedLocals --noUnusedParameters",
47
+ "check:whitespace": "node scripts/whitespace-check.mjs",
48
+ "check:exports": "knip",
49
+ "check:package": "publint",
50
+ "lint": "npm run check:unused && npm run check:whitespace && npm run check:exports",
51
+ "docs:dev": "npm --prefix apps/docs run dev",
52
+ "docs:build": "npm --prefix apps/docs run build",
53
+ "docs:check": "npm --prefix apps/docs run check",
54
+ "start": "node dist/cli.js",
55
+ "test": "vitest run",
56
+ "verify": "npm run check && npm run lint && npm run test && npm run build && npm run smoke:data",
57
+ "verify:release": "npm run verify && npm run smoke:playback && npm run pack:check && npm run fresh:check && npm run check:package",
58
+ "prepack": "npm run build",
59
+ "prepublishOnly": "npm run check && npm run lint && npm run test && npm run smoke:data && npm run fresh:check && npm run check:package",
60
+ "pack:check": "npm pack --dry-run",
61
+ "smoke:data": "tsx src/smoke/data-smoke.ts",
62
+ "smoke:playback": "tsx src/smoke/playback-smoke.ts",
63
+ "demo:script": "node scripts/demo-script.mjs",
64
+ "fresh:check": "node scripts/fresh-check.mjs"
65
+ },
66
+ "dependencies": {
67
+ "ink": "^7.0.5",
68
+ "react": "^19.2.6",
69
+ "zod": "^4.4.3"
70
+ },
71
+ "devDependencies": {
72
+ "@types/node": "^25.9.1",
73
+ "@types/react": "^19.2.15",
74
+ "knip": "^6.14.2",
75
+ "publint": "^0.3.21",
76
+ "tsx": "^4.22.3",
77
+ "typescript": "^6.0.3",
78
+ "vitest": "^4.1.7"
79
+ },
80
+ "engines": {
81
+ "node": ">=22"
82
+ }
83
+ }