neoplayer 1.0.0 → 1.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.
@@ -2284,6 +2284,7 @@
2284
2284
  AxiosHeaders$1.accessor([
2285
2285
  'Content-Type',
2286
2286
  'Content-Length',
2287
+ 'Content-Encoding',
2287
2288
  'Accept',
2288
2289
  'Accept-Encoding',
2289
2290
  'User-Agent',
@@ -3040,8 +3041,13 @@
3040
3041
  const handler = {
3041
3042
  fulfilled,
3042
3043
  rejected,
3043
- synchronous: options ? options.synchronous : false,
3044
- runWhen: options ? options.runWhen : null,
3044
+ // Options from a class or template object are read as usual; a value
3045
+ // only inherited from Object.prototype is ignored.
3046
+ synchronous:
3047
+ options && utils$1.hasOwnInPrototypeChain(options, 'synchronous')
3048
+ ? options.synchronous
3049
+ : false,
3050
+ runWhen: options && utils$1.hasOwnInPrototypeChain(options, 'runWhen') ? options.runWhen : null,
3045
3051
  };
3046
3052
  const internals = this[$internals];
3047
3053
 
@@ -3938,6 +3944,14 @@
3938
3944
  end--;
3939
3945
  }
3940
3946
 
3947
+ if (end === 0) {
3948
+ // A base made only of slashes points at the root of the current origin.
3949
+ // Drop leading slashes, backslashes, tabs and newlines from the relative
3950
+ // URL as well: URL parsers ignore tabs and newlines and treat '\\' as '/',
3951
+ // so leaving them would turn the result into a protocol-relative URL.
3952
+ return '/' + relativeURL.replace(/^[/\\\t\n\r]+/, '');
3953
+ }
3954
+
3941
3955
  return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
3942
3956
  }
3943
3957
 
@@ -4934,6 +4948,11 @@
4934
4948
  }
4935
4949
  controller.enqueue(new Uint8Array(value));
4936
4950
  } catch (err) {
4951
+ // A progress callback can fail while the source iterator is suspended at
4952
+ // a yield. Close it without delaying or replacing the original error.
4953
+ // This return() call has no cancellation reason, so the source's cancel()
4954
+ // receives undefined, as it does from the cancel() hook below.
4955
+ iterator.return().catch(() => {});
4937
4956
  _onFinish(err);
4938
4957
  throw err;
4939
4958
  }
@@ -5252,7 +5271,7 @@
5252
5271
  );
5253
5272
  }
5254
5273
 
5255
- const VERSION$1 = "1.21.1";
5274
+ const VERSION$1 = "1.22.0";
5256
5275
 
5257
5276
  const DEFAULT_CHUNK_SIZE = 64 * 1024;
5258
5277
 
@@ -5307,6 +5326,45 @@
5307
5326
  }
5308
5327
  };
5309
5328
 
5329
+ // Marks a probe body's cancellation result as handled. Reads `then` once and
5330
+ // does not go through the global Promise or `Promise.prototype.catch`, so a
5331
+ // rejected cancellation from a custom body cannot surface as an unhandled
5332
+ // rejection.
5333
+ const ignoreRejection = (result) => {
5334
+ try {
5335
+ if (result !== null && (typeof result === 'object' || typeof result === 'function')) {
5336
+ const then = result.then;
5337
+
5338
+ if (isFunction(then)) {
5339
+ then.call(result, undefined, utils$1.noop);
5340
+ }
5341
+ }
5342
+ } catch (e) {
5343
+ // Ignored: the cancellation has already been requested.
5344
+ }
5345
+ };
5346
+
5347
+ // On Node.js 22 and older, the body of the throwaway `new Response('')` used by
5348
+ // the response-stream probe leaves its stream's internal closed promise pending
5349
+ // until the stream is cancelled, which async-leak detectors report for every
5350
+ // realm that loads axios. This cleanup runs in `finally`, whether the check
5351
+ // returned or threw, and is best-effort so it never affects the probe result.
5352
+ const cancelProbeBody = (body) => {
5353
+ if (body == null) {
5354
+ return;
5355
+ }
5356
+
5357
+ try {
5358
+ const cancel = body.cancel;
5359
+
5360
+ if (isFunction(cancel)) {
5361
+ ignoreRejection(cancel.call(body));
5362
+ }
5363
+ } catch (e) {
5364
+ // Ignored: an uncancellable probe body is still a valid probe result.
5365
+ }
5366
+ };
5367
+
5310
5368
  const maybeWithAuthCredentials = (url) => {
5311
5369
  const protocolIndex = url.indexOf('://');
5312
5370
  let urlToCheck = url;
@@ -5372,7 +5430,7 @@
5372
5430
  const hasContentType = request.headers.has('Content-Type');
5373
5431
 
5374
5432
  if (request.body != null) {
5375
- request.body.cancel();
5433
+ ignoreRejection(request.body.cancel());
5376
5434
  }
5377
5435
 
5378
5436
  return duplexAccessed && !hasContentType;
@@ -5381,7 +5439,15 @@
5381
5439
  const supportsResponseStream =
5382
5440
  isResponseSupported &&
5383
5441
  isReadableStreamSupported &&
5384
- test(() => utils$1.isReadableStream(new Response('').body));
5442
+ test(() => {
5443
+ const probeBody = new Response('').body;
5444
+
5445
+ try {
5446
+ return utils$1.isReadableStream(probeBody);
5447
+ } finally {
5448
+ cancelProbeBody(probeBody);
5449
+ }
5450
+ });
5385
5451
 
5386
5452
  // Some runtimes reject every explicit cache mode. Use own defaults for both
5387
5453
  // probes so unrelated polluted options cannot affect cache-mode detection.
@@ -5953,6 +6019,28 @@
5953
6019
 
5954
6020
  const seedCache = new Map();
5955
6021
 
6022
+ // Every adapter the factory has created. The adapter is cached per
6023
+ // environment, so one created for another environment, such as by
6024
+ // `axios.getAdapter('fetch')` without a config, is still recognized.
6025
+ const createdAdapters = new WeakSet();
6026
+
6027
+ const createAdapter = (env) => {
6028
+ const adapter = factory(env);
6029
+
6030
+ adapter && createdAdapters.add(adapter);
6031
+
6032
+ return adapter;
6033
+ };
6034
+
6035
+ /**
6036
+ * Check whether a function was created by the fetch adapter factory.
6037
+ *
6038
+ * @param {*} adapter The value to check
6039
+ *
6040
+ * @returns {boolean} `true` for a built-in fetch adapter
6041
+ */
6042
+ const isFetchAdapter = (adapter) => createdAdapters.has(adapter);
6043
+
5956
6044
  const getFetch = (config) => {
5957
6045
  const env = Object.create(null);
5958
6046
  const configuredEnv = config && utils$1.hasOwnProp(config, 'env') && config.env;
@@ -5974,7 +6062,7 @@
5974
6062
  seed = seeds[i];
5975
6063
  target = map.get(seed);
5976
6064
 
5977
- target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
6065
+ target === undefined && map.set(seed, (target = i ? new Map() : createAdapter(env)));
5978
6066
 
5979
6067
  map = target;
5980
6068
  }
@@ -6094,6 +6182,21 @@
6094
6182
  return adapter;
6095
6183
  }
6096
6184
 
6185
+ /**
6186
+ * Check whether a resolved adapter function is one of the built-in adapters.
6187
+ *
6188
+ * @param {Function} adapter The adapter resolved by `getAdapter`
6189
+ * @returns {boolean} `true` for the built-in `xhr`, `http` or `fetch` adapter
6190
+ */
6191
+ function isBuiltinAdapter(adapter) {
6192
+ return (
6193
+ !!adapter &&
6194
+ (adapter === knownAdapters.xhr ||
6195
+ adapter === knownAdapters.http ||
6196
+ isFetchAdapter(adapter))
6197
+ );
6198
+ }
6199
+
6097
6200
  /**
6098
6201
  * Exports Axios adapters and utility to resolve an adapter
6099
6202
  */
@@ -6104,6 +6207,12 @@
6104
6207
  */
6105
6208
  getAdapter: getAdapter$1,
6106
6209
 
6210
+ /**
6211
+ * Check whether a resolved adapter is a built-in one.
6212
+ * @type {Function}
6213
+ */
6214
+ isBuiltinAdapter,
6215
+
6107
6216
  /**
6108
6217
  * Exposes all known adapters
6109
6218
  * @type {Object<string, Function|Object>}
@@ -6111,6 +6220,63 @@
6111
6220
  adapters: knownAdapters,
6112
6221
  };
6113
6222
 
6223
+ /**
6224
+ * Reject a `null` or `undefined` url that a built-in adapter would send
6225
+ * somewhere the caller did not choose.
6226
+ *
6227
+ * With params, the nullish url becomes a query-only url such as `?foo=bar`,
6228
+ * which a browser resolves against the current page. Without params, XHR
6229
+ * requests `./null` or `./undefined` and the Node adapter throws a native
6230
+ * `TypeError`.
6231
+ *
6232
+ * The request still has a destination when `baseURL` is set, or when the Node
6233
+ * HTTP adapter is given a `socketPath`. A caller-supplied adapter handles its
6234
+ * own destination and is not checked.
6235
+ *
6236
+ * `dispatchRequest` and `Axios#getUri` both call this, so `getUri` rejects
6237
+ * exactly the configs that a request would reject. Request interceptors are
6238
+ * not run by `getUri`, so a url that an interceptor would supply is still
6239
+ * missing there. Keep this out of `buildURL` and `buildFullPath`: they only
6240
+ * format urls and have other callers.
6241
+ *
6242
+ * @param {Object} config The merged request config
6243
+ * @param {Function} resolveAdapter Returns the adapter that handles the
6244
+ * request. Called only for a nullish url without `baseURL`, so a usable url
6245
+ * never depends on adapter resolution.
6246
+ *
6247
+ * @returns {void}
6248
+ */
6249
+ function assertValidRequestUrl(config, resolveAdapter) {
6250
+ const url = utils$1.getSafeProp(config, 'url');
6251
+
6252
+ if (url !== null && url !== undefined) {
6253
+ return;
6254
+ }
6255
+
6256
+ if (utils$1.getSafeProp(config, 'baseURL')) {
6257
+ return;
6258
+ }
6259
+
6260
+ const adapter = resolveAdapter();
6261
+
6262
+ // Only the Node HTTP adapter reads socketPath; XHR and fetch ignore it.
6263
+ const httpAdapter = adapters.adapters.http;
6264
+
6265
+ if (httpAdapter && adapter === httpAdapter && utils$1.getSafeProp(config, 'socketPath')) {
6266
+ return;
6267
+ }
6268
+
6269
+ if (!adapters.isBuiltinAdapter(adapter)) {
6270
+ return;
6271
+ }
6272
+
6273
+ throw new AxiosError$1(
6274
+ `Invalid URL: url cannot be ${url === null ? 'null' : 'undefined'} when baseURL is not set`,
6275
+ AxiosError$1.ERR_INVALID_URL,
6276
+ config
6277
+ );
6278
+ }
6279
+
6114
6280
  /**
6115
6281
  * Throws a `CanceledError` if cancellation has been requested.
6116
6282
  *
@@ -6185,6 +6351,9 @@
6185
6351
 
6186
6352
  const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
6187
6353
 
6354
+ // Runs after resolution so a custom adapter is recognized in any form.
6355
+ assertValidRequestUrl(config, () => adapter);
6356
+
6188
6357
  const now = resolveClock();
6189
6358
  const start = now();
6190
6359
 
@@ -6640,6 +6809,9 @@
6640
6809
 
6641
6810
  getUri(config) {
6642
6811
  config = mergeConfig$1(this.defaults, config);
6812
+ assertValidRequestUrl(config, () =>
6813
+ adapters.getAdapter(config.adapter || defaults.adapter, config)
6814
+ );
6643
6815
  const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls, config);
6644
6816
  return buildURL(fullPath, config.params, config.paramsSerializer);
6645
6817
  }
@@ -7076,7 +7248,7 @@
7076
7248
  },
7077
7249
  };
7078
7250
 
7079
- /* global "1.0.0" */
7251
+ /* global "1.1.0" */
7080
7252
  function handleOption(options) {
7081
7253
  var _a, _b, _c;
7082
7254
  const defaultOption = {
@@ -7150,7 +7322,7 @@
7150
7322
  link: 'https://github.com/Fluxonide',
7151
7323
  },
7152
7324
  {
7153
- text: `NeoPlayer v${"1.0.0"}`,
7325
+ text: `NeoPlayer v${"1.1.0"}`,
7154
7326
  link: 'https://github.com/Fluxonide/NeoPlayer',
7155
7327
  },
7156
7328
  ]);
@@ -7695,14 +7867,6 @@
7695
7867
  : '';
7696
7868
  const infoDanmakuHtml = options.danmaku
7697
7869
  ? `
7698
- <div class="dplayer-info-panel-item dplayer-info-panel-item-danmaku-id">
7699
- <span class="dplayer-info-panel-item-title">Danmaku id</span>
7700
- <span class="dplayer-info-panel-item-data"></span>
7701
- </div>
7702
- <div class="dplayer-info-panel-item dplayer-info-panel-item-danmaku-api">
7703
- <span class="dplayer-info-panel-item-title">Danmaku api</span>
7704
- <span class="dplayer-info-panel-item-data"></span>
7705
- </div>
7706
7870
  <div class="dplayer-info-panel-item dplayer-info-panel-item-danmaku-amount">
7707
7871
  <span class="dplayer-info-panel-item-title">Danmaku amount</span>
7708
7872
  <span class="dplayer-info-panel-item-data"></span>
@@ -7836,29 +8000,56 @@
7836
8000
  </div>
7837
8001
  </div>
7838
8002
  <div class="dplayer-info-panel dplayer-info-panel-hide">
7839
- <div class="dplayer-info-panel-close">[x]</div>
8003
+ <div class="dplayer-info-panel-actions">
8004
+ <span class="dplayer-info-panel-copy" title="Copy stats">[Copy]</span>
8005
+ <span class="dplayer-info-panel-close" title="Close">[x]</span>
8006
+ </div>
7840
8007
  <div class="dplayer-info-panel-item dplayer-info-panel-item-version">
7841
8008
  <span class="dplayer-info-panel-item-title">Player version</span>
7842
8009
  <span class="dplayer-info-panel-item-data"></span>
7843
8010
  </div>
8011
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-url">
8012
+ <span class="dplayer-info-panel-item-title">Video url</span>
8013
+ <span class="dplayer-info-panel-item-data"></span>
8014
+ </div>
8015
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-resolution">
8016
+ <span class="dplayer-info-panel-item-title">Viewport / Res</span>
8017
+ <span class="dplayer-info-panel-item-data"></span>
8018
+ </div>
7844
8019
  <div class="dplayer-info-panel-item dplayer-info-panel-item-fps">
7845
- <span class="dplayer-info-panel-item-title">Player FPS</span>
8020
+ <span class="dplayer-info-panel-item-title">Video FPS</span>
7846
8021
  <span class="dplayer-info-panel-item-data"></span>
7847
8022
  </div>
7848
- <div class="dplayer-info-panel-item dplayer-info-panel-item-type">
7849
- <span class="dplayer-info-panel-item-title">Video type</span>
8023
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-codecs">
8024
+ <span class="dplayer-info-panel-item-title">Codecs</span>
7850
8025
  <span class="dplayer-info-panel-item-data"></span>
7851
8026
  </div>
7852
- <div class="dplayer-info-panel-item dplayer-info-panel-item-url">
7853
- <span class="dplayer-info-panel-item-title">Video url</span>
8027
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-bitrate">
8028
+ <span class="dplayer-info-panel-item-title">Bitrate</span>
7854
8029
  <span class="dplayer-info-panel-item-data"></span>
7855
8030
  </div>
7856
- <div class="dplayer-info-panel-item dplayer-info-panel-item-resolution">
7857
- <span class="dplayer-info-panel-item-title">Video resolution</span>
8031
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-connection">
8032
+ <span class="dplayer-info-panel-item-title">Connection</span>
7858
8033
  <span class="dplayer-info-panel-item-data"></span>
7859
8034
  </div>
7860
8035
  <div class="dplayer-info-panel-item dplayer-info-panel-item-duration">
7861
- <span class="dplayer-info-panel-item-title">Video duration</span>
8036
+ <span class="dplayer-info-panel-item-title">Time / Duration</span>
8037
+ <span class="dplayer-info-panel-item-data"></span>
8038
+ </div>
8039
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-frames">
8040
+ <span class="dplayer-info-panel-item-title">Dropped frames</span>
8041
+ <span class="dplayer-info-panel-item-data"></span>
8042
+ </div>
8043
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-buffer">
8044
+ <span class="dplayer-info-panel-item-title">Buffer health</span>
8045
+ <span class="dplayer-info-panel-item-data"></span>
8046
+ </div>
8047
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-playback">
8048
+ <span class="dplayer-info-panel-item-title">Playback</span>
8049
+ <span class="dplayer-info-panel-item-data"></span>
8050
+ </div>
8051
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-tracks">
8052
+ <span class="dplayer-info-panel-item-title">Tracks</span>
7862
8053
  <span class="dplayer-info-panel-item-data"></span>
7863
8054
  </div>
7864
8055
  ${infoDanmakuHtml}
@@ -7974,14 +8165,19 @@
7974
8165
  this.noticeList = q('.dplayer-notice-list');
7975
8166
  this.infoPanel = q('.dplayer-info-panel');
7976
8167
  this.infoPanelClose = q('.dplayer-info-panel-close');
8168
+ this.infoPanelCopy = q('.dplayer-info-panel-copy');
7977
8169
  this.infoVersion = q('.dplayer-info-panel-item-version .dplayer-info-panel-item-data');
7978
8170
  this.infoFPS = q('.dplayer-info-panel-item-fps .dplayer-info-panel-item-data');
7979
- this.infoType = q('.dplayer-info-panel-item-type .dplayer-info-panel-item-data');
7980
8171
  this.infoUrl = q('.dplayer-info-panel-item-url .dplayer-info-panel-item-data');
8172
+ this.infoCodecs = q('.dplayer-info-panel-item-codecs .dplayer-info-panel-item-data');
8173
+ this.infoBitrate = q('.dplayer-info-panel-item-bitrate .dplayer-info-panel-item-data');
8174
+ this.infoConnection = q('.dplayer-info-panel-item-connection .dplayer-info-panel-item-data');
7981
8175
  this.infoResolution = q('.dplayer-info-panel-item-resolution .dplayer-info-panel-item-data');
7982
8176
  this.infoDuration = q('.dplayer-info-panel-item-duration .dplayer-info-panel-item-data');
7983
- this.infoDanmakuId = q('.dplayer-info-panel-item-danmaku-id .dplayer-info-panel-item-data');
7984
- this.infoDanmakuApi = q('.dplayer-info-panel-item-danmaku-api .dplayer-info-panel-item-data');
8177
+ this.infoFrames = q('.dplayer-info-panel-item-frames .dplayer-info-panel-item-data');
8178
+ this.infoBuffer = q('.dplayer-info-panel-item-buffer .dplayer-info-panel-item-data');
8179
+ this.infoPlayback = q('.dplayer-info-panel-item-playback .dplayer-info-panel-item-data');
8180
+ this.infoTracks = q('.dplayer-info-panel-item-tracks .dplayer-info-panel-item-data');
7985
8181
  this.infoDanmakuAmount = q('.dplayer-info-panel-item-danmaku-amount .dplayer-info-panel-item-data');
7986
8182
  }
7987
8183
  /** Create a notice element */
@@ -10142,7 +10338,12 @@
10142
10338
 
10143
10339
  class InfoPanel {
10144
10340
  constructor(player) {
10145
- this.beginTime = 0;
10341
+ this.lastDecodedBytes = 0;
10342
+ this.lastBitrateTime = 0;
10343
+ this.lastBitrateBps = 0;
10344
+ this.lastTotalFrames = 0;
10345
+ this.lastFpsTime = 0;
10346
+ this.lastVideoFps = 0;
10146
10347
  this.container = player.template.infoPanel;
10147
10348
  this.template = player.template;
10148
10349
  this.video = player.video;
@@ -10150,17 +10351,17 @@
10150
10351
  this.template.infoPanelClose.addEventListener('click', () => {
10151
10352
  this.hide();
10152
10353
  });
10354
+ this.template.infoPanelCopy.addEventListener('click', () => {
10355
+ this.copyStats();
10356
+ });
10153
10357
  }
10154
10358
  show() {
10155
- this.beginTime = Date.now();
10156
10359
  this.update();
10157
10360
  this.player.timer.enable('info');
10158
- this.player.timer.enable('fps');
10159
10361
  this.container.classList.remove('dplayer-info-panel-hide');
10160
10362
  }
10161
10363
  hide() {
10162
10364
  this.player.timer.disable('info');
10163
- this.player.timer.disable('fps');
10164
10365
  this.container.classList.add('dplayer-info-panel-hide');
10165
10366
  }
10166
10367
  triggle() {
@@ -10173,23 +10374,304 @@
10173
10374
  }
10174
10375
  update() {
10175
10376
  var _a, _b;
10176
- this.template.infoVersion.innerHTML = `v${"1.0.0"} ${"55672b9"}`;
10177
- this.template.infoType.innerHTML = this.player.type;
10178
- this.template.infoUrl.innerHTML = this.player.options.video.url;
10179
- this.template.infoResolution.innerHTML = `${this.video.videoWidth} x ${this.video.videoHeight}`;
10180
- this.template.infoDuration.innerHTML = String(this.video.duration);
10377
+ const video = this.video;
10378
+ const url = this.player.options.video.url;
10379
+ const dpr = window.devicePixelRatio > 1 ? `@${window.devicePixelRatio.toFixed(1).replace(/\.0$/, '')}x` : '';
10380
+ this.template.infoVersion.textContent = `v${"1.1.0"} ${"af9d9ca"}`;
10381
+ this.template.infoUrl.textContent = url;
10382
+ this.template.infoUrl.title = url;
10383
+ this.template.infoResolution.textContent = `${video.clientWidth}x${video.clientHeight}${dpr} / ${video.videoWidth}x${video.videoHeight}`;
10384
+ this.template.infoFPS.textContent = this.formatVideoFPS();
10385
+ this.template.infoCodecs.textContent = this.formatCodecs(url);
10386
+ this.template.infoBitrate.textContent = this.formatBitrate();
10387
+ this.template.infoConnection.textContent = this.formatConnection();
10388
+ this.template.infoDuration.textContent = this.formatTimeDuration(video.currentTime, video.duration);
10389
+ this.template.infoFrames.textContent = this.formatFrameStats();
10390
+ this.template.infoBuffer.textContent = this.formatBufferHealth();
10391
+ const vol = video.muted ? 'Muted' : `${Math.round(video.volume * 100)}%`;
10392
+ const state = video.paused ? ' (Paused)' : '';
10393
+ this.template.infoPlayback.textContent = `${video.playbackRate}x | Vol ${vol}${state}`;
10394
+ this.template.infoTracks.textContent = this.formatTracks();
10181
10395
  if (this.player.options.danmaku) {
10182
- this.template.infoDanmakuId.innerHTML = this.player.options.danmaku.id;
10183
- this.template.infoDanmakuApi.innerHTML = this.player.options.danmaku.api;
10184
- this.template.infoDanmakuAmount.innerHTML = String((_b = (_a = this.player.danmaku) === null || _a === void 0 ? void 0 : _a.dan.length) !== null && _b !== void 0 ? _b : 0);
10396
+ this.template.infoDanmakuAmount.textContent = String((_b = (_a = this.player.danmaku) === null || _a === void 0 ? void 0 : _a.dan.length) !== null && _b !== void 0 ? _b : 0);
10397
+ }
10398
+ }
10399
+ fps(_value) {
10400
+ // Video FPS is updated via formatVideoFPS() on the 1s info tick.
10401
+ }
10402
+ copyStats() {
10403
+ var _a;
10404
+ const items = this.container.querySelectorAll('.dplayer-info-panel-item');
10405
+ const lines = [];
10406
+ items.forEach((item) => {
10407
+ var _a, _b, _c, _d;
10408
+ const title = (_b = (_a = item.querySelector('.dplayer-info-panel-item-title')) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
10409
+ const data = (_d = (_c = item.querySelector('.dplayer-info-panel-item-data')) === null || _c === void 0 ? void 0 : _c.textContent) === null || _d === void 0 ? void 0 : _d.trim();
10410
+ if (title && data) {
10411
+ lines.push(`${title}: ${data}`);
10412
+ }
10413
+ });
10414
+ const text = lines.join('\n');
10415
+ const flashCopied = () => {
10416
+ this.template.infoPanelCopy.textContent = '[Copied]';
10417
+ setTimeout(() => {
10418
+ this.template.infoPanelCopy.textContent = '[Copy]';
10419
+ }, 1500);
10420
+ };
10421
+ if ((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText) {
10422
+ navigator.clipboard.writeText(text).then(flashCopied).catch(() => { });
10185
10423
  }
10186
10424
  }
10187
- fps(value) {
10188
- this.template.infoFPS.innerHTML = value.toFixed(1);
10425
+ formatVideoFPS() {
10426
+ var _a, _b, _c, _d;
10427
+ const hls = this.player.plugins.hls;
10428
+ if ((hls === null || hls === void 0 ? void 0 : hls.levels) && hls.levels.length > 0) {
10429
+ const idx = hls.currentLevel !== undefined && hls.currentLevel >= 0 ? hls.currentLevel : ((_a = hls.loadLevel) !== null && _a !== void 0 ? _a : 0);
10430
+ const rate = (_c = (_b = hls.levels[idx]) === null || _b === void 0 ? void 0 : _b.attrs) === null || _c === void 0 ? void 0 : _c['FRAME-RATE'];
10431
+ if (rate)
10432
+ return `${Number(rate).toFixed(2).replace(/\.00$/, '')} fps`;
10433
+ }
10434
+ const flv = this.player.plugins.flvjs;
10435
+ if (((_d = flv === null || flv === void 0 ? void 0 : flv.mediaInfo) === null || _d === void 0 ? void 0 : _d.fps) && flv.mediaInfo.fps > 0) {
10436
+ return `${flv.mediaInfo.fps.toFixed(2).replace(/\.00$/, '')} fps`;
10437
+ }
10438
+ const totalFrames = this.getTotalVideoFrames();
10439
+ if (totalFrames !== null) {
10440
+ const now = Date.now();
10441
+ if (this.lastFpsTime > 0 && now > this.lastFpsTime && totalFrames >= this.lastTotalFrames) {
10442
+ const dt = (now - this.lastFpsTime) / 1000;
10443
+ const measured = (totalFrames - this.lastTotalFrames) / dt;
10444
+ if (measured > 0) {
10445
+ this.lastVideoFps = measured;
10446
+ }
10447
+ }
10448
+ this.lastTotalFrames = totalFrames;
10449
+ this.lastFpsTime = now;
10450
+ if (this.lastVideoFps > 0) {
10451
+ return `${this.lastVideoFps.toFixed(1)} fps (decoded)`;
10452
+ }
10453
+ }
10454
+ return 'N/A';
10455
+ }
10456
+ getTotalVideoFrames() {
10457
+ if (typeof this.video.getVideoPlaybackQuality === 'function') {
10458
+ return this.video.getVideoPlaybackQuality().totalVideoFrames;
10459
+ }
10460
+ const wk = this.video;
10461
+ return typeof wk.webkitDecodedFrameCount === 'number' ? wk.webkitDecodedFrameCount : null;
10462
+ }
10463
+ formatTracks() {
10464
+ const parts = [];
10465
+ const wk = this.video;
10466
+ if (wk.audioTracks && wk.audioTracks.length > 0) {
10467
+ let activeAudio = '';
10468
+ for (let i = 0; i < wk.audioTracks.length; i++) {
10469
+ const t = wk.audioTracks[i];
10470
+ if (t.enabled) {
10471
+ activeAudio = t.label || t.language || `#${i + 1}`;
10472
+ break;
10473
+ }
10474
+ }
10475
+ parts.push(`Audio: ${activeAudio || wk.audioTracks.length}`);
10476
+ }
10477
+ const textTracks = this.video.textTracks;
10478
+ if (textTracks && textTracks.length > 0) {
10479
+ let activeSub = 'Off';
10480
+ for (let i = 0; i < textTracks.length; i++) {
10481
+ const t = textTracks[i];
10482
+ if (t.mode === 'showing') {
10483
+ activeSub = t.label || t.language || 'On';
10484
+ break;
10485
+ }
10486
+ }
10487
+ parts.push(`Sub: ${activeSub}`);
10488
+ }
10489
+ else {
10490
+ parts.push('Sub: None');
10491
+ }
10492
+ return parts.join(' | ');
10493
+ }
10494
+ formatCodecs(url) {
10495
+ var _a, _b, _c;
10496
+ const hls = this.player.plugins.hls;
10497
+ if ((hls === null || hls === void 0 ? void 0 : hls.levels) && hls.levels.length > 0) {
10498
+ const idx = hls.currentLevel !== undefined && hls.currentLevel >= 0 ? hls.currentLevel : ((_a = hls.loadLevel) !== null && _a !== void 0 ? _a : 0);
10499
+ const level = hls.levels[idx];
10500
+ if (level) {
10501
+ const parts = [level.videoCodec, level.audioCodec].filter(Boolean);
10502
+ if (parts.length > 0)
10503
+ return parts.join(' / ');
10504
+ if (level.codecs)
10505
+ return level.codecs;
10506
+ }
10507
+ }
10508
+ const dash = this.player.plugins.dash;
10509
+ if (dash === null || dash === void 0 ? void 0 : dash.getCurrentTrackFor) {
10510
+ const vCodec = (_b = dash.getCurrentTrackFor('video')) === null || _b === void 0 ? void 0 : _b.codec;
10511
+ const aCodec = (_c = dash.getCurrentTrackFor('audio')) === null || _c === void 0 ? void 0 : _c.codec;
10512
+ const parts = [vCodec, aCodec].filter(Boolean);
10513
+ if (parts.length > 0)
10514
+ return parts.join(' / ');
10515
+ }
10516
+ const flv = this.player.plugins.flvjs;
10517
+ if (flv === null || flv === void 0 ? void 0 : flv.mediaInfo) {
10518
+ const parts = [flv.mediaInfo.videoCodec, flv.mediaInfo.audioCodec].filter(Boolean);
10519
+ if (parts.length > 0)
10520
+ return parts.join(' / ');
10521
+ if (flv.mediaInfo.mimeType)
10522
+ return flv.mediaInfo.mimeType;
10523
+ }
10524
+ const cleanUrl = (this.video.currentSrc || url).split(/[?#]/)[0].toLowerCase();
10525
+ const ext = cleanUrl.includes('.') ? cleanUrl.split('.').pop() : '';
10526
+ const mimeMap = {
10527
+ mp4: 'MP4 (video/mp4)',
10528
+ m4v: 'MP4 (video/mp4)',
10529
+ webm: 'WebM (video/webm)',
10530
+ ogv: 'Ogg (video/ogg)',
10531
+ ogg: 'Ogg (video/ogg)',
10532
+ mov: 'MOV (video/quicktime)',
10533
+ m3u8: 'HLS (application/vnd.apple.mpegurl)',
10534
+ mpd: 'DASH (application/dash+xml)',
10535
+ flv: 'FLV (video/x-flv)',
10536
+ };
10537
+ if (ext && mimeMap[ext]) {
10538
+ return `${mimeMap[ext]} · native`;
10539
+ }
10540
+ return 'Native (browser-managed)';
10541
+ }
10542
+ formatBitrate() {
10543
+ var _a, _b, _c, _d, _e, _f;
10544
+ const hls = this.player.plugins.hls;
10545
+ if ((hls === null || hls === void 0 ? void 0 : hls.levels) && hls.levels.length > 0) {
10546
+ const idx = hls.currentLevel !== undefined && hls.currentLevel >= 0 ? hls.currentLevel : ((_a = hls.loadLevel) !== null && _a !== void 0 ? _a : 0);
10547
+ const bitrate = (_b = hls.levels[idx]) === null || _b === void 0 ? void 0 : _b.bitrate;
10548
+ if (bitrate && bitrate > 0) {
10549
+ return this.formatBps(bitrate);
10550
+ }
10551
+ }
10552
+ const dash = this.player.plugins.dash;
10553
+ if ((dash === null || dash === void 0 ? void 0 : dash.getQualityFor) && dash.getBitrateInfoListFor) {
10554
+ const q = dash.getQualityFor('video');
10555
+ const list = dash.getBitrateInfoListFor('video');
10556
+ const bitrate = (_c = list === null || list === void 0 ? void 0 : list[q]) === null || _c === void 0 ? void 0 : _c.bitrate;
10557
+ if (bitrate && bitrate > 0) {
10558
+ return this.formatBps(bitrate);
10559
+ }
10560
+ }
10561
+ const flv = this.player.plugins.flvjs;
10562
+ if (flv === null || flv === void 0 ? void 0 : flv.mediaInfo) {
10563
+ const totalKbps = ((_d = flv.mediaInfo.videoDataRate) !== null && _d !== void 0 ? _d : 0) + ((_e = flv.mediaInfo.audioDataRate) !== null && _e !== void 0 ? _e : 0);
10564
+ if (totalKbps > 0) {
10565
+ return this.formatBps(totalKbps * 1000);
10566
+ }
10567
+ }
10568
+ const wk = this.video;
10569
+ if (typeof wk.webkitVideoDecodedByteCount === 'number') {
10570
+ const totalBytes = wk.webkitVideoDecodedByteCount + ((_f = wk.webkitAudioDecodedByteCount) !== null && _f !== void 0 ? _f : 0);
10571
+ const now = Date.now();
10572
+ if (this.lastBitrateTime > 0 && now > this.lastBitrateTime && totalBytes >= this.lastDecodedBytes) {
10573
+ const dt = (now - this.lastBitrateTime) / 1000;
10574
+ const bps = ((totalBytes - this.lastDecodedBytes) * 8) / dt;
10575
+ if (bps > 0) {
10576
+ this.lastBitrateBps = bps;
10577
+ }
10578
+ }
10579
+ this.lastDecodedBytes = totalBytes;
10580
+ this.lastBitrateTime = now;
10581
+ if (this.lastBitrateBps > 0) {
10582
+ return `${this.formatBps(this.lastBitrateBps)} (decoded)`;
10583
+ }
10584
+ }
10585
+ return 'N/A';
10586
+ }
10587
+ formatConnection() {
10588
+ var _a;
10589
+ const parts = [];
10590
+ const hls = this.player.plugins.hls;
10591
+ const dash = this.player.plugins.dash;
10592
+ const flv = this.player.plugins.flvjs;
10593
+ if ((hls === null || hls === void 0 ? void 0 : hls.bandwidthEstimate) && hls.bandwidthEstimate > 0) {
10594
+ parts.push(`${this.formatBps(hls.bandwidthEstimate)} est.`);
10595
+ }
10596
+ else if (dash === null || dash === void 0 ? void 0 : dash.getAverageThroughput) {
10597
+ const tp = dash.getAverageThroughput('video');
10598
+ if (tp > 0)
10599
+ parts.push(`${this.formatBps(tp * 1000)} est.`);
10600
+ }
10601
+ else if (((_a = flv === null || flv === void 0 ? void 0 : flv.statisticsInfo) === null || _a === void 0 ? void 0 : _a.speed) && flv.statisticsInfo.speed > 0) {
10602
+ parts.push(`${flv.statisticsInfo.speed.toFixed(1)} KB/s`);
10603
+ }
10604
+ const nav = navigator;
10605
+ if (nav.connection) {
10606
+ const net = [];
10607
+ if (typeof nav.connection.downlink === 'number' && nav.connection.downlink > 0) {
10608
+ net.push(`${nav.connection.downlink.toFixed(1)} Mbps`);
10609
+ }
10610
+ if (nav.connection.effectiveType) {
10611
+ net.push(nav.connection.effectiveType);
10612
+ }
10613
+ if (net.length > 0)
10614
+ parts.push(net.join(' · '));
10615
+ }
10616
+ return parts.length > 0 ? parts.join(' | ') : 'N/A';
10617
+ }
10618
+ formatBps(bps) {
10619
+ if (bps >= 1000000) {
10620
+ return `${(bps / 1000000).toFixed(2)} Mbps`;
10621
+ }
10622
+ return `${Math.round(bps / 1000)} kbps`;
10623
+ }
10624
+ formatTimeDuration(currentTime, duration) {
10625
+ const cur = utils$2.secondToTime(currentTime);
10626
+ if (duration === Infinity) {
10627
+ return `${cur} / Live`;
10628
+ }
10629
+ if (Number.isFinite(duration) && duration > 0) {
10630
+ return `${cur} / ${utils$2.secondToTime(duration)} (${duration.toFixed(1)}s)`;
10631
+ }
10632
+ return `${cur} / 00:00`;
10633
+ }
10634
+ formatFrameStats() {
10635
+ if (typeof this.video.getVideoPlaybackQuality === 'function') {
10636
+ const quality = this.video.getVideoPlaybackQuality();
10637
+ const dropped = quality.droppedVideoFrames;
10638
+ const total = quality.totalVideoFrames;
10639
+ if (total > 0) {
10640
+ const pct = ((dropped / total) * 100).toFixed(1);
10641
+ return `${dropped} / ${total} (${pct}%)`;
10642
+ }
10643
+ return `${dropped} / ${total}`;
10644
+ }
10645
+ const wk = this.video;
10646
+ if (typeof wk.webkitDroppedFrameCount === 'number' && typeof wk.webkitDecodedFrameCount === 'number') {
10647
+ const dropped = wk.webkitDroppedFrameCount;
10648
+ const total = wk.webkitDecodedFrameCount;
10649
+ const pct = total > 0 ? ((dropped / total) * 100).toFixed(1) : '0.0';
10650
+ return `${dropped} / ${total} (${pct}%)`;
10651
+ }
10652
+ return 'N/A';
10653
+ }
10654
+ formatBufferHealth() {
10655
+ const { buffered, currentTime, duration } = this.video;
10656
+ let ahead = 0;
10657
+ let totalBuffered = 0;
10658
+ for (let i = 0; i < buffered.length; i++) {
10659
+ const start = buffered.start(i);
10660
+ const end = buffered.end(i);
10661
+ totalBuffered += end - start;
10662
+ if (currentTime >= start - 0.1 && currentTime <= end) {
10663
+ ahead = Math.max(0, end - currentTime);
10664
+ }
10665
+ }
10666
+ if (Number.isFinite(duration) && duration > 0) {
10667
+ const pct = Math.min(100, (totalBuffered / duration) * 100).toFixed(0);
10668
+ return `${ahead.toFixed(1)}s ahead (${pct}% buffered)`;
10669
+ }
10670
+ return `${ahead.toFixed(1)}s ahead`;
10189
10671
  }
10190
10672
  }
10191
10673
 
10192
- /* global "1.0.0" */
10674
+ /* global "1.1.0" */
10193
10675
  let index = 0;
10194
10676
  const instances = [];
10195
10677
  class NeoPlayer {
@@ -10860,12 +11342,12 @@
10860
11342
  this.events.trigger('destroy');
10861
11343
  }
10862
11344
  static get version() {
10863
- return "1.0.0";
11345
+ return "1.1.0";
10864
11346
  }
10865
11347
  }
10866
11348
 
10867
- /* global "1.0.0" "55672b9" */
10868
- console.log(`${'\n'} %c NeoPlayer v${"1.0.0"} ${"55672b9"} %c https://github.com/Fluxonide/NeoPlayer ${'\n'}${'\n'}`, 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
11349
+ /* global "1.1.0" "af9d9ca" */
11350
+ console.log(`${'\n'} %c NeoPlayer v${"1.1.0"} ${"af9d9ca"} %c https://github.com/Fluxonide/NeoPlayer ${'\n'}${'\n'}`, 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
10869
11351
 
10870
11352
  return NeoPlayer;
10871
11353