webamp 0.0.0-next-c1d68b5 → 0.0.0-next-a618b04

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.
@@ -13090,7 +13090,7 @@
13090
13090
  /**
13091
13091
  * Constructs the windows to render
13092
13092
  */
13093
- function App({ media, filePickers }) {
13093
+ function App({ media, filePickers, onMount, parentDomNode, }) {
13094
13094
  const closed = useTypedSelector(getClosed);
13095
13095
  const genWindowsInfo = useTypedSelector(getGenWindows);
13096
13096
  const zIndex = useTypedSelector(getZIndex);
@@ -13107,11 +13107,11 @@
13107
13107
  webampNode.style.zIndex = String(zIndex);
13108
13108
  }, [webampNode, zIndex]);
13109
13109
  reactExports.useLayoutEffect(() => {
13110
- document.body.appendChild(webampNode);
13110
+ parentDomNode.appendChild(webampNode);
13111
13111
  return () => {
13112
- document.body.removeChild(webampNode);
13112
+ parentDomNode.removeChild(webampNode);
13113
13113
  };
13114
- }, [webampNode]);
13114
+ }, [webampNode, parentDomNode]);
13115
13115
  reactExports.useEffect(() => {
13116
13116
  const handleWindowResize = () => {
13117
13117
  if (webampNode == null) {
@@ -13139,6 +13139,11 @@
13139
13139
  window.removeEventListener("resize", handleWindowResize);
13140
13140
  };
13141
13141
  }, [browserWindowSizeChanged$1, webampNode]);
13142
+ reactExports.useEffect(() => {
13143
+ if (onMount != null) {
13144
+ onMount();
13145
+ }
13146
+ }, [onMount]);
13142
13147
  const renderWindows = reactExports.useCallback(() => {
13143
13148
  return objectMap(genWindowsInfo, (w, id) => {
13144
13149
  if (!w.open) {
@@ -13855,10 +13860,7 @@
13855
13860
  this._actionEmitter = new Emitter();
13856
13861
  this.options = options;
13857
13862
  const { initialTracks, initialSkin, availableSkins, enableHotkeys = false, zIndex, requireJSZip, requireMusicMetadata, handleTrackDropEvent, handleAddUrlEvent, handleLoadListEvent, handleSaveListEvent, enableDoubleSizeMode, __butterchurnOptions, __customMediaClass, } = this.options;
13858
- if (options.enableMediaSession) {
13859
- enableMediaSession(this);
13860
- }
13861
- // TODO: Make this much cleaner
13863
+ // TODO: Make this much cleaner.
13862
13864
  let convertPreset = null;
13863
13865
  if (__butterchurnOptions != null) {
13864
13866
  const { importConvertPreset, presetConverterEndpoint } = __butterchurnOptions;
@@ -13869,18 +13871,21 @@
13869
13871
  };
13870
13872
  }
13871
13873
  }
13872
- // TODO: Validate required options
13874
+ // TODO: Validate required options.
13873
13875
  this.media = new (__customMediaClass || Media)();
13874
13876
  this.store = createWebampStore(this.media, this._actionEmitter, this.options.__customMiddlewares, this.options.__initialState, {
13875
13877
  requireJSZip,
13876
13878
  requireMusicMetadata,
13877
13879
  convertPreset,
13878
- // @ts-ignore Typescript is drunk
13880
+ // @ts-ignore Typescript is drunk.
13879
13881
  handleTrackDropEvent,
13880
13882
  handleAddUrlEvent,
13881
13883
  handleLoadListEvent,
13882
13884
  handleSaveListEvent,
13883
13885
  });
13886
+ if (options.enableMediaSession) {
13887
+ enableMediaSession(this);
13888
+ }
13884
13889
  if (enableDoubleSizeMode) {
13885
13890
  this.store.dispatch(toggleDoubleSizeMode());
13886
13891
  }
@@ -13933,49 +13938,49 @@
13933
13938
  }
13934
13939
  }
13935
13940
  /**
13936
- * Play the current tack
13941
+ * Play the current track.
13937
13942
  */
13938
13943
  play() {
13939
13944
  this.store.dispatch(play());
13940
13945
  }
13941
13946
  /**
13942
- * Pause the current tack
13947
+ * Pause the current track.
13943
13948
  */
13944
13949
  pause() {
13945
13950
  this.store.dispatch(pause());
13946
13951
  }
13947
13952
  /**
13948
- * Stop the currently playing audio. Equivalent to pressing the "stop" button
13953
+ * Stop the currently playing audio. Equivalent to pressing the "stop" button.
13949
13954
  */
13950
13955
  stop() {
13951
13956
  this.store.dispatch(stop());
13952
13957
  }
13953
13958
  /**
13954
- * Set volume from 0 - 100
13959
+ * Set volume from 0 - 100.
13955
13960
  */
13956
13961
  setVolume(volume) {
13957
13962
  this.store.dispatch(setVolume(volume));
13958
13963
  }
13959
13964
  /**
13960
- * Seek backward n seconds in the current track
13965
+ * Seek backward n seconds in the current track.
13961
13966
  */
13962
13967
  seekBackward(seconds) {
13963
13968
  this.store.dispatch(seekBackward(seconds));
13964
13969
  }
13965
13970
  /**
13966
- * Seek forward n seconds in the current track
13971
+ * Seek forward n seconds in the current track.
13967
13972
  */
13968
13973
  seekForward(seconds) {
13969
13974
  this.store.dispatch(seekForward(seconds));
13970
13975
  }
13971
13976
  /**
13972
- * Seek to a given time within the current track
13977
+ * Seek to a given time within the current track.
13973
13978
  */
13974
13979
  seekToTime(seconds) {
13975
13980
  this.store.dispatch(seekToTime(seconds));
13976
13981
  }
13977
13982
  /**
13978
- * Check if shuffle is enabled
13983
+ * Check if shuffle is enabled.
13979
13984
  */
13980
13985
  isShuffleEnabled() {
13981
13986
  return getShuffle(this.store.getState());
@@ -13987,7 +13992,7 @@
13987
13992
  this.store.dispatch(toggleShuffle());
13988
13993
  }
13989
13994
  /**
13990
- * Check if repeat is enabled
13995
+ * Check if repeat is enabled.
13991
13996
  */
13992
13997
  isRepeatEnabled() {
13993
13998
  return getRepeat(this.store.getState());
@@ -13999,19 +14004,19 @@
13999
14004
  this.store.dispatch(toggleRepeat());
14000
14005
  }
14001
14006
  /**
14002
- * Play the next track
14007
+ * Play the next track.
14003
14008
  */
14004
14009
  nextTrack() {
14005
14010
  this.store.dispatch(next());
14006
14011
  }
14007
14012
  /**
14008
- * Play the previous track
14013
+ * Play the previous track.
14009
14014
  */
14010
14015
  previousTrack() {
14011
14016
  this.store.dispatch(previous());
14012
14017
  }
14013
14018
  /**
14014
- * Set the current track a specific track in the playlist by zero-based index.
14019
+ * Set the current track to a specific track in the playlist by zero-based index.
14015
14020
  *
14016
14021
  * Note: If Webamp is currently playing, the track will begin playing. If
14017
14022
  * Webamp is not playing, the track will not start playing. You can use
@@ -14067,7 +14072,7 @@
14067
14072
  return this._actionEmitter.on(CLOSE_WINAMP, cb);
14068
14073
  }
14069
14074
  /**
14070
- * Equivalent to selection "Close" from Webamp's options menu. Once closed,
14075
+ * Equivalent to selecting "Close" from Webamp's options menu. Once closed,
14071
14076
  * you can open it again with `.reopen()`.
14072
14077
  */
14073
14078
  close() {
@@ -14094,7 +14099,7 @@
14094
14099
  */
14095
14100
  onTrackDidChange(cb) {
14096
14101
  let previousTrackId = null;
14097
- // TODO #leak
14102
+ // TODO #leak.
14098
14103
  return this.store.subscribe(() => {
14099
14104
  const state = this.store.getState();
14100
14105
  const trackId = getCurrentlyPlayingTrackIdIfLoaded(state);
@@ -14130,7 +14135,7 @@
14130
14135
  */
14131
14136
  async skinIsLoaded() {
14132
14137
  // Wait for the skin to load.
14133
- // TODO #leak
14138
+ // TODO #leak.
14134
14139
  await storeHas(this.store, (state) => !state.display.loading);
14135
14140
  // We attempt to pre-resolve these promises before we declare the skin
14136
14141
  // loaded. That's because `<EqGraph>` needs these in order to render fully.
@@ -14169,7 +14174,12 @@
14169
14174
  this._root = null;
14170
14175
  }
14171
14176
  });
14172
- this._root.render(jsxRuntimeExports.jsx(Provider, { store: this.store, children: jsxRuntimeExports.jsx(App, { media: this.media, filePickers: this.options.filePickers || [] }) }));
14177
+ let onMount;
14178
+ const mountPromise = new Promise((resolve) => {
14179
+ onMount = resolve;
14180
+ });
14181
+ this._root.render(jsxRuntimeExports.jsx(Provider, { store: this.store, children: jsxRuntimeExports.jsx(App, { media: this.media, filePickers: this.options.filePickers || [], onMount: onMount, parentDomNode: document.body }) }));
14182
+ await mountPromise;
14173
14183
  }
14174
14184
  /**
14175
14185
  * **Note:** _This method is not fully functional. It is currently impossible to
@@ -14181,8 +14191,8 @@
14181
14191
  * attempt to clean itself up to avoid memory leaks.
14182
14192
  */
14183
14193
  dispose() {
14184
- // TODO: Clean up store subscription in onTrackDidChange
14185
- // TODO: Every storeHas call represents a potential race condition
14194
+ // TODO: Clean up store subscription in onTrackDidChange.
14195
+ // TODO: Every storeHas call represents a potential race condition.
14186
14196
  this.media.dispose();
14187
14197
  this._actionEmitter.dispose();
14188
14198
  this._disposable.dispose();
@@ -14194,7 +14204,7 @@
14194
14204
  return getSerlializedState(this.store.getState());
14195
14205
  }
14196
14206
  __onStateChange(cb) {
14197
- // TODO #leak
14207
+ // TODO #leak.
14198
14208
  return this.store.subscribe(cb);
14199
14209
  }
14200
14210
  _bufferTracks(tracks) {
@@ -14203,7 +14213,7 @@
14203
14213
  }
14204
14214
  }
14205
14215
  // Return a promise that resolves when the store matches a predicate.
14206
- // TODO #leak
14216
+ // TODO #leak.
14207
14217
  const storeHas = (store, predicate) => new Promise((resolve) => {
14208
14218
  if (predicate(store.getState())) {
14209
14219
  resolve();