@js-toolkit/web-utils 1.62.0 → 1.62.2

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.
@@ -1,3 +1,5 @@
1
+ import { getMediaSource } from './getMediaSource';
2
+ type ManagedMediaSourceOption = Parameters<typeof getMediaSource>[0];
1
3
  export declare abstract class Capabilities {
2
4
  private static readonly supportMap;
3
5
  private static readonly canPlayMap;
@@ -6,6 +8,7 @@ export declare abstract class Capabilities {
6
8
  /** Check video element. Mime type and optional codecs. */
7
9
  static isCanPlayType(type: string): boolean;
8
10
  /** Check MediaSource. */
9
- static isTypeSupported(type: string): boolean;
11
+ static isTypeSupported(type: string, managedMediaSource?: ManagedMediaSourceOption): boolean;
10
12
  static reset(): void;
11
13
  }
14
+ export {};
@@ -1 +1 @@
1
- import{getMediaSource}from"./getMediaSource";export class Capabilities{static supportMap=new Map;static canPlayMap=new Map;static tmpVideo;static cacheTimer;static isCanPlayType(t){if(this.canPlayMap.has(t))return!!this.canPlayMap.get(t);this.tmpVideo||(this.tmpVideo=document.getElementsByTagName("video")[0]||document.createElement("video"),window.clearTimeout(this.cacheTimer),this.cacheTimer=window.setTimeout((()=>{this.tmpVideo=void 0}),1e3));const e=!!this.tmpVideo.canPlayType(t);return this.supportMap.set(t,e),e}static isTypeSupported(t){if(this.supportMap.has(t))return!!this.supportMap.get(t);const e=getMediaSource();if(e){const i=e.isTypeSupported(t);return this.supportMap.set(t,i),i}return!1}static reset(){window.clearTimeout(this.cacheTimer),this.tmpVideo=void 0,this.supportMap.clear(),this.canPlayMap.clear()}}
1
+ import{getMediaSource}from"./getMediaSource";export class Capabilities{static supportMap=new Map;static canPlayMap=new Map;static tmpVideo;static cacheTimer;static isCanPlayType(t){if(this.canPlayMap.has(t))return!!this.canPlayMap.get(t);this.tmpVideo||(this.tmpVideo=document.getElementsByTagName("video")[0]||document.createElement("video"),window.clearTimeout(this.cacheTimer),this.cacheTimer=window.setTimeout((()=>{this.tmpVideo=void 0}),1e3));const e=!!this.tmpVideo.canPlayType(t);return this.supportMap.set(t,e),e}static isTypeSupported(t,e){if(this.supportMap.has(t))return!!this.supportMap.get(t);const i=getMediaSource(e);if(i){const e=i.isTypeSupported(t);return this.supportMap.set(t,e),e}return!1}static reset(){window.clearTimeout(this.cacheTimer),this.tmpVideo=void 0,this.supportMap.clear(),this.canPlayMap.clear()}}
@@ -16,8 +16,8 @@ declare global {
16
16
  }
17
17
  export declare function getMediaSource(
18
18
  /**
19
- * `prefer` - If has support.
20
- * `maybe` - If has support but mse is unsupported.
21
- * Otherwise returns mse MediaSource.
19
+ * `prefer` - returns ManagedMediaSource or MediaSource.
20
+ * `maybe` - returns ManagedMediaSource.
21
+ * Otherwise returns MediaSource.
22
22
  */
23
23
  managedMediaSource?: 'prefer' | 'maybe'): typeof MediaSource | undefined;
@@ -1 +1 @@
1
- export function getMediaSource(e){return"prefer"===e&&window.ManagedMediaSource||"maybe"===e&&window.ManagedMediaSource&&!window.MediaSource?window.ManagedMediaSource:window.MediaSource}
1
+ export function getMediaSource(e){return"maybe"===e?window.ManagedMediaSource:"prefer"===e&&window.ManagedMediaSource||window.MediaSource}
@@ -13,5 +13,5 @@ declare global {
13
13
  }
14
14
  }
15
15
  type ManagedMediaSourceOption = Parameters<typeof getMediaSource>[0];
16
- export declare function getSourceBuffer(managedSourceBuffer?: ManagedMediaSourceOption): typeof SourceBuffer | undefined;
16
+ export declare function getSourceBuffer(managedMediaSource?: ManagedMediaSourceOption): typeof SourceBuffer | undefined;
17
17
  export {};
@@ -1 +1 @@
1
- export function getSourceBuffer(e){return"prefer"===e&&window.ManagedSourceBuffer||"maybe"===e&&window.ManagedSourceBuffer&&!window.SourceBuffer?window.ManagedSourceBuffer:window.SourceBuffer}
1
+ export function getSourceBuffer(e){return"maybe"===e?window.ManagedSourceBuffer:"prefer"===e&&window.ManagedSourceBuffer||window.SourceBuffer}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@js-toolkit/web-utils",
3
- "version": "1.62.0",
3
+ "version": "1.62.2",
4
4
  "description": "Web utils",
5
5
  "author": "VZH",
6
6
  "license": "MIT",
@@ -43,7 +43,7 @@
43
43
  "typescript": "^5.7.3",
44
44
  "typescript-eslint": "^8.24.1",
45
45
  "ua-parser-js": "^2.0.2",
46
- "uuid": "^11.0.5",
46
+ "uuid": "^11.1.0",
47
47
  "webpack": "^5.98.0",
48
48
  "yargs": "^17.7.2"
49
49
  }