@exezt-/webamp 1.5.0-0x1
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/README.md +61 -0
- package/built/webamp.bundle.js +37228 -0
- package/built/webamp.bundle.min.js +70 -0
- package/built/webamp.lazy-bundle.js +19521 -0
- package/built/webamp.lazy-bundle.min.js +51 -0
- package/index.d.ts +277 -0
- package/package.json +147 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
interface TrackInfo {
|
|
2
|
+
/**
|
|
3
|
+
* Name to be used until ID3 tags can be resolved.
|
|
4
|
+
*
|
|
5
|
+
* If the track has a `url`, and this property is not given,
|
|
6
|
+
* the filename will be used instead.
|
|
7
|
+
*
|
|
8
|
+
* Example: `'My Song'`
|
|
9
|
+
*/
|
|
10
|
+
defaultName?: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Data to be used _instead_ of trying to fetch ID3 tags.
|
|
14
|
+
*
|
|
15
|
+
* Example: `{ artist: 'Jordan Eldredge', title: "Jordan's Song" }`
|
|
16
|
+
*/
|
|
17
|
+
metaData?: {
|
|
18
|
+
artist: string;
|
|
19
|
+
title: string;
|
|
20
|
+
album?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Duration (in seconds) to be used instead of fetching enough of the file to measure its length.
|
|
25
|
+
*
|
|
26
|
+
* Example: 95
|
|
27
|
+
*/
|
|
28
|
+
duration?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface URLTrack extends TrackInfo {
|
|
32
|
+
/**
|
|
33
|
+
* Source URL of the track
|
|
34
|
+
*
|
|
35
|
+
* Note: This URL must be served the with correct CORs headers.
|
|
36
|
+
*
|
|
37
|
+
* Example: `'https://example.com/song.mp3'`
|
|
38
|
+
*/
|
|
39
|
+
url: string | URL;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface BlobTrack extends TrackInfo {
|
|
43
|
+
/**
|
|
44
|
+
* Blob source of the track
|
|
45
|
+
*/
|
|
46
|
+
blob: Blob;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface LoadedURLTrack {
|
|
50
|
+
url: string;
|
|
51
|
+
metaData: {
|
|
52
|
+
artist: string | null;
|
|
53
|
+
title: string | null;
|
|
54
|
+
album: string | null;
|
|
55
|
+
albumArtUrl: string | null;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Many methods on the webamp instance deal with track.
|
|
61
|
+
*
|
|
62
|
+
* Either `url` or `blob` must be specified
|
|
63
|
+
*/
|
|
64
|
+
type Track = URLTrack | BlobTrack;
|
|
65
|
+
|
|
66
|
+
interface Options {
|
|
67
|
+
/**
|
|
68
|
+
* An object representing the initial skin to use.
|
|
69
|
+
*
|
|
70
|
+
* If omitted, the default skin, included in the bundle, will be used.
|
|
71
|
+
* Note: This URL must be served the with correct CORs headers.
|
|
72
|
+
*
|
|
73
|
+
* Example: `{ url: './path/to/skin.wsz' }`
|
|
74
|
+
*/
|
|
75
|
+
initialSkin?: {
|
|
76
|
+
url: string;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* An array of `Track`s to prepopulate the playlist with.
|
|
81
|
+
*/
|
|
82
|
+
initialTracks?: Track[];
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* An array of objects representing available skins.
|
|
86
|
+
*
|
|
87
|
+
* These will appear in the "Options" menu under "Skins".
|
|
88
|
+
* Note: These URLs must be served with the correct CORs headers.
|
|
89
|
+
*
|
|
90
|
+
* Example: `[ { url: "./green.wsz", name: "Green Dimension V2" } ]`
|
|
91
|
+
*/
|
|
92
|
+
availableSkins?: { url: string; name: string }[];
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Should global hotkeys be enabled?
|
|
96
|
+
*
|
|
97
|
+
* Default: `false`
|
|
98
|
+
*/
|
|
99
|
+
enableHotkeys?: boolean;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* An array of additional file pickers.
|
|
103
|
+
*
|
|
104
|
+
* These will appear in the "Options" menu under "Play".
|
|
105
|
+
*
|
|
106
|
+
* In the offical version, this option is used to provide a "Dropbox" file picker.
|
|
107
|
+
*/
|
|
108
|
+
filePickers?: [
|
|
109
|
+
{
|
|
110
|
+
/**
|
|
111
|
+
* The name that will appear in the context menu.
|
|
112
|
+
*
|
|
113
|
+
* Example: `"My File Picker..."`
|
|
114
|
+
*/
|
|
115
|
+
contextMenuName: string;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A function which returns a Promise that resolves to an array of `Track`s
|
|
119
|
+
*
|
|
120
|
+
* Example: `() => Promise.resolve([{ url: './rick_roll.mp3' }])`
|
|
121
|
+
*/
|
|
122
|
+
filePicker: () => Promise<Track[]>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Indicates if this options should be made available when the user is offline.
|
|
126
|
+
*/
|
|
127
|
+
requiresNetwork: boolean;
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
zIndex?: number;
|
|
131
|
+
|
|
132
|
+
handleTrackDropEvent?: (
|
|
133
|
+
e: React.DragEvent<HTMLDivElement>
|
|
134
|
+
) => Track[] | null | Promise<Track[] | null>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export default class Webamp {
|
|
138
|
+
constructor(options: Options);
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Returns a true if the current browser supports the features that Webamp depends upon.
|
|
142
|
+
*
|
|
143
|
+
* It is recommended to check this before you attempt to instantiate an instance of Winamp.
|
|
144
|
+
*/
|
|
145
|
+
public static browserIsSupported(): boolean;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Add an array of `Track`s to the end of the playlist.
|
|
149
|
+
*/
|
|
150
|
+
public appendTracks(tracks: Track[]): void;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Replace the playlist with an array of `Track`s and begin playing the first track.
|
|
154
|
+
*/
|
|
155
|
+
public setTracksToPlay(tracks: Track[]): void;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Play the previous track
|
|
159
|
+
*/
|
|
160
|
+
public previousTrack(): void;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Play the next track
|
|
164
|
+
*/
|
|
165
|
+
public nextTrack(): void;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Seek forward n seconds in the curent track
|
|
169
|
+
*/
|
|
170
|
+
public seekForward(seconds: number): void;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Seek backward n seconds in the curent track
|
|
174
|
+
*/
|
|
175
|
+
public seekBackward(seconds: number): void;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Seek to a given time within the current track
|
|
179
|
+
*/
|
|
180
|
+
public seekToTime(seconds: number): void;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Pause the current tack
|
|
184
|
+
*/
|
|
185
|
+
public pause(): void;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Play the current tack
|
|
189
|
+
*/
|
|
190
|
+
public play(): void;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Stop the currently playing audio. Equivilant to pressing the "stop" button
|
|
194
|
+
*/
|
|
195
|
+
public stop(): void;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Webamp will wait until it has fetched the skin and fully parsed it and then render itself.
|
|
199
|
+
*
|
|
200
|
+
* Webamp is rendered into a new DOM node at the end of the <body> tag with the id `#webamp`.
|
|
201
|
+
*
|
|
202
|
+
* If a domNode is passed, Webamp will place itself in the center of that DOM node.
|
|
203
|
+
*
|
|
204
|
+
* @returns A promise is returned which will resolve after the render is complete.
|
|
205
|
+
*/
|
|
206
|
+
public renderWhenReady(domNode: HTMLElement): Promise<void>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* A callback which will be called when a new track starts loading.
|
|
210
|
+
*
|
|
211
|
+
* This can happen on startup when the first track starts buffering, or when a subsequent track starts playing.
|
|
212
|
+
* The callback will be called with an object `({url: 'https://example.com/track.mp3'})` containing the URL of the track.
|
|
213
|
+
* Note: If the user drags in a track, the URL may be an ObjectURL.
|
|
214
|
+
*
|
|
215
|
+
* @returns An "unsubscribe" function. Useful if at some point in the future you want to stop listening to these events.
|
|
216
|
+
*/
|
|
217
|
+
public onTrackDidChange(
|
|
218
|
+
cb: (trackInfo: LoadedURLTrack | null) => void
|
|
219
|
+
): () => void;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Get the current "playing" status.
|
|
223
|
+
*/
|
|
224
|
+
public getMediaStatus(): "PLAYING" | "STOPPED" | "PAUSED";
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* A callback which will be called when Webamp is _about to_ close. Returns an
|
|
228
|
+
* "unsubscribe" function. The callback will be passed a `cancel` function
|
|
229
|
+
* which you can use to conditionally prevent Webamp from being closed.
|
|
230
|
+
*
|
|
231
|
+
* @returns An "unsubscribe" function. Useful if at some point in the future you want to stop listening to these events.
|
|
232
|
+
*/
|
|
233
|
+
public onWillClose(cb: (cancel: () => void) => void): () => void;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* A callback which will be called when Webamp is closed.
|
|
237
|
+
*
|
|
238
|
+
* @returns An "unsubscribe" function. Useful if at some point in the future you want to stop listening to these events.
|
|
239
|
+
*/
|
|
240
|
+
public onClose(cb: () => void): () => void;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Equivalent to selection "Close" from Webamp's options menu. Once closed,
|
|
244
|
+
* you can open it again with `.reopen()`.
|
|
245
|
+
*/
|
|
246
|
+
public close(): void;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* After `.close()`ing this instance, you can reopen it by calling this method.
|
|
250
|
+
*/
|
|
251
|
+
public reopen(): void;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* A callback which will be called when Webamp is minimized.
|
|
255
|
+
*
|
|
256
|
+
* @returns An "unsubscribe" function. Useful if at some point in the future you want to stop listening to these events.
|
|
257
|
+
*/
|
|
258
|
+
public onMinimize(callback: () => any): () => void;
|
|
259
|
+
|
|
260
|
+
public setSkinFromUrl(url: string): void;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Returns a promise that resolves when the skin is done loading.
|
|
264
|
+
*/
|
|
265
|
+
public skinIsLoaded(): Promise<void>;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* **Note:** _This method is not fully functional. It is currently impossible to
|
|
269
|
+
* clean up a Winamp instance. This method makes an effort, but it still leaks
|
|
270
|
+
* the whole instance. In the future the behavior of this method will improve,
|
|
271
|
+
* so you might as well call it._
|
|
272
|
+
*
|
|
273
|
+
* When you are done with a Webamp instance, call this method and Webamp will
|
|
274
|
+
* attempt to clean itself up to avoid memory leaks.
|
|
275
|
+
*/
|
|
276
|
+
public dispose(): void;
|
|
277
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@exezt-/webamp",
|
|
3
|
+
"version": "1.5.0-0x1",
|
|
4
|
+
"description": "Winamp 2 implemented in HTML5 and JavaScript",
|
|
5
|
+
"main": "built/webamp.bundle.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"built/webamp.bundle.js",
|
|
8
|
+
"built/webamp.bundle.min.js",
|
|
9
|
+
"built/webamp.bundle.min.js.map",
|
|
10
|
+
"built/webamp.lazy-bundle.js",
|
|
11
|
+
"built/webamp.lazy-bundle.min.js",
|
|
12
|
+
"built/webamp.lazy-bundle.min.js.map",
|
|
13
|
+
"index.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"pe": "npm i --legacy-peer-deps",
|
|
17
|
+
"lint-fix": "eslint . --ext ts,tsx,js --fix",
|
|
18
|
+
"lint": "eslint . --ext ts,tsx,js",
|
|
19
|
+
"type-check": "tsc",
|
|
20
|
+
"build": "NODE_OPTIONS=--openssl-legacy-provider webpack --config=demo/config/webpack.prod.js",
|
|
21
|
+
"build-library": "NODE_OPTIONS=--openssl-legacy-provider webpack --config=config/webpack.library.js",
|
|
22
|
+
"serve": "http-server ./demo/built",
|
|
23
|
+
"start": "webpack-dev-server --open --config=demo/config/webpack.dev.js",
|
|
24
|
+
"stats": "webpack --config=demo/config/webpack.prod.js --json > stats.json",
|
|
25
|
+
"stats-library": "webpack --config=config/webpack.library.js --json > stats.json",
|
|
26
|
+
"test": "jest --config=config/jest.unit.js",
|
|
27
|
+
"tdd": "jest --config=config/jest.unit.js --watch",
|
|
28
|
+
"format": "prettier --write \"**/*.{js,ts,tsx,d.ts,css}\"",
|
|
29
|
+
"integration-tests": "jest --config=config/jest.integration.js --runInBand",
|
|
30
|
+
"build-skin": "rm assets/skins/base-2.91.wsz && cd assets/skins/base-2.91 && zip -x .* -x 'Skining Updates.txt' -r ../base-2.91.wsz .",
|
|
31
|
+
"compile-skin": "node scripts/compileSkin.js > css/base-skin.css",
|
|
32
|
+
"skin-info": "unzip -vl assets/skins/base-2.91.wsz",
|
|
33
|
+
"build-presets": "node scripts/parsePresetFiles.js > presets/builtin.json"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"Winamp",
|
|
37
|
+
"HTML5",
|
|
38
|
+
"audio",
|
|
39
|
+
"web-audio-api"
|
|
40
|
+
],
|
|
41
|
+
"author": "Jordan Eldredge <jordan@jordaneldredge.com>",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@babel/core": "^7.7.2",
|
|
45
|
+
"@babel/node": "^7.0.0",
|
|
46
|
+
"@babel/plugin-proposal-class-properties": "^7.0.0",
|
|
47
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
|
|
48
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
|
|
49
|
+
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
|
|
50
|
+
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
|
|
51
|
+
"@babel/plugin-transform-modules-commonjs": "^7.0.0",
|
|
52
|
+
"@babel/plugin-transform-runtime": "^7.0.0",
|
|
53
|
+
"@babel/polyfill": "^7.7.0",
|
|
54
|
+
"@babel/preset-env": "^7.7.1",
|
|
55
|
+
"@babel/preset-react": "^7.7.0",
|
|
56
|
+
"@babel/preset-typescript": "^7.7.2",
|
|
57
|
+
"@babel/runtime": "^7.7.2",
|
|
58
|
+
"@sentry/browser": "5.9.1",
|
|
59
|
+
"@types/classnames": "^2.2.6",
|
|
60
|
+
"@types/css-font-loading-module": "^0.0.2",
|
|
61
|
+
"@types/fscreen": "^1.0.1",
|
|
62
|
+
"@types/invariant": "^2.2.29",
|
|
63
|
+
"@types/jest": "^23.3.2",
|
|
64
|
+
"@types/jszip": "^3.1.5",
|
|
65
|
+
"@types/lodash": "^4.14.116",
|
|
66
|
+
"@types/lodash-es": "^4.17.1",
|
|
67
|
+
"@types/node": "^14.0.1",
|
|
68
|
+
"@types/react": "^16.8.13",
|
|
69
|
+
"@types/react-dom": "^16.8.4",
|
|
70
|
+
"@types/react-redux": "^7.1.1",
|
|
71
|
+
"@types/webaudioapi": "^0.0.27",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^2.6.1",
|
|
73
|
+
"@typescript-eslint/parser": "^2.7.0",
|
|
74
|
+
"babel-core": "7.0.0-bridge.0",
|
|
75
|
+
"babel-eslint": "^9.0.0-beta.3",
|
|
76
|
+
"babel-jest": "^23.4.2",
|
|
77
|
+
"babel-loader": "^8.0.4",
|
|
78
|
+
"caniuse-lite": "^1.0.30001154",
|
|
79
|
+
"canvas-mock": "0.0.0",
|
|
80
|
+
"copy-webpack-plugin": "^4.6.0",
|
|
81
|
+
"css-loader": "^1.0.1",
|
|
82
|
+
"cssnano": "^4.1.10",
|
|
83
|
+
"data-uri-to-buffer": "^2.0.0",
|
|
84
|
+
"eslint": "^6.5.1",
|
|
85
|
+
"eslint-plugin-import": "^2.18.2",
|
|
86
|
+
"eslint-plugin-prettier": "^3.1.0",
|
|
87
|
+
"eslint-plugin-react": "^7.16.0",
|
|
88
|
+
"eslint-plugin-react-hooks": "^2.1.2",
|
|
89
|
+
"file-loader": "^2.0.0",
|
|
90
|
+
"git-revision-webpack-plugin": "^3.0.3",
|
|
91
|
+
"glob": "^7.1.4",
|
|
92
|
+
"html-webpack-inline-svg-plugin": "^2.3.0",
|
|
93
|
+
"html-webpack-plugin": "^4.5.0",
|
|
94
|
+
"http-server": "^0.11.1",
|
|
95
|
+
"imagemin": "^6.1.0",
|
|
96
|
+
"imagemin-optipng": "^6.0.0",
|
|
97
|
+
"jest": "^24.9.0",
|
|
98
|
+
"jest-image-snapshot": "^2.12.0",
|
|
99
|
+
"jest-puppeteer": "^4.4.0",
|
|
100
|
+
"postcss": "^8.2.10",
|
|
101
|
+
"postcss-loader": "^3.0.0",
|
|
102
|
+
"prettier": "^2.3.0",
|
|
103
|
+
"puppeteer": "^1.15.0",
|
|
104
|
+
"react-test-renderer": "^17.0.1",
|
|
105
|
+
"redux-devtools-extension": "^2.13.2",
|
|
106
|
+
"redux-sentry-middleware": "^0.1.3",
|
|
107
|
+
"redux-thunk": "^2.3.0",
|
|
108
|
+
"style-loader": "^0.23.1",
|
|
109
|
+
"terser-webpack-plugin": "^1.4.3",
|
|
110
|
+
"typescript": "^3.7.2",
|
|
111
|
+
"url-loader": "^1.1.2",
|
|
112
|
+
"webpack": "^4.41.2",
|
|
113
|
+
"webpack-bundle-analyzer": "^4.3.0",
|
|
114
|
+
"webpack-cli": "^3.1.2",
|
|
115
|
+
"webpack-dev-server": "^3.8.2",
|
|
116
|
+
"webpack-merge": "^4.1.2"
|
|
117
|
+
},
|
|
118
|
+
"jest": {
|
|
119
|
+
"globalSetup": "jest-environment-puppeteer/setup",
|
|
120
|
+
"globalTeardown": "jest-environment-puppeteer/teardown",
|
|
121
|
+
"projects": [
|
|
122
|
+
"config/jest.*.js"
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
"prettier": {
|
|
126
|
+
"trailingComma": "es5"
|
|
127
|
+
},
|
|
128
|
+
"dependencies": {
|
|
129
|
+
"ani-cursor": "^0.0.4",
|
|
130
|
+
"butterchurn": "^3.0.0-beta.3",
|
|
131
|
+
"butterchurn-presets": "3.0.0-beta.4",
|
|
132
|
+
"classnames": "^2.2.5",
|
|
133
|
+
"fscreen": "^1.0.2",
|
|
134
|
+
"invariant": "^2.2.3",
|
|
135
|
+
"jszip": "^3.1.3",
|
|
136
|
+
"lodash": "^4.17.21",
|
|
137
|
+
"milkdrop-preset-converter-aws": "^0.1.6",
|
|
138
|
+
"music-metadata-browser": "^0.6.1",
|
|
139
|
+
"react": "^17.0.1",
|
|
140
|
+
"react-dom": "^17.0.1",
|
|
141
|
+
"react-redux": "^7.2.2",
|
|
142
|
+
"redux": "^4.0.5",
|
|
143
|
+
"reselect": "^3.0.1",
|
|
144
|
+
"tinyqueue": "^1.2.3",
|
|
145
|
+
"winamp-eqf": "^1.0.0"
|
|
146
|
+
}
|
|
147
|
+
}
|