ranui 0.1.9 → 0.1.10-alpha.1

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 (171) hide show
  1. package/dist/_commonjs-dynamic-modules-DLbDWi6a.js +12 -0
  2. package/dist/arrow-down-C9jBUUt3.js +30 -0
  3. package/dist/assets/image/failImage.d.ts +2 -0
  4. package/dist/button.js +7 -0
  5. package/dist/checkbox.js +7 -0
  6. package/dist/colorpicker.js +13 -0
  7. package/dist/{colz-746223ab.js → colz-CRDozfZA.js} +1 -5
  8. package/dist/components/button/index.d.ts +7 -3
  9. package/dist/components/checkbox/index.d.ts +27 -0
  10. package/dist/components/colorpicker/index.d.ts +122 -0
  11. package/dist/components/content/index.d.ts +15 -0
  12. package/dist/components/input/index.d.ts +65 -41
  13. package/dist/components/message/index.d.ts +2 -0
  14. package/dist/components/option/index.d.ts +2 -1
  15. package/dist/components/player/index.d.ts +31 -6
  16. package/dist/components/popover/index.d.ts +39 -0
  17. package/dist/components/preview/docx.d.ts +1 -1
  18. package/dist/components/preview/index.d.ts +2 -0
  19. package/dist/components/preview/pptx/process_pptx.d.ts +1 -1
  20. package/dist/components/progress/index.d.ts +11 -5
  21. package/dist/components/radar/index.d.ts +1 -1
  22. package/dist/components/scratch/index.d.ts +5 -1
  23. package/dist/components/select/index.d.ts +15 -7
  24. package/dist/content.js +6 -0
  25. package/dist/docx-ajDUtnbM.js +3665 -0
  26. package/dist/global-DOfcrQ2N.js +4 -0
  27. package/dist/icon.js +6 -0
  28. package/dist/iconShadowless.js +6 -0
  29. package/dist/image.js +4 -0
  30. package/dist/index-0fvHQjmN.js +298 -0
  31. package/dist/{index-1b73beee.js → index-BLepXisd.js} +55 -90
  32. package/dist/{index-e2e5d725.js → index-BOoNI-Al.js} +113 -305
  33. package/dist/{index-2d16a084.js → index-BPBRPxND.js} +8 -10
  34. package/dist/{index-e03d23e7.js → index-BpOERe9M.js} +1 -1
  35. package/dist/index-Bv6Z6rIe.js +498 -0
  36. package/dist/index-ByJ7zZdQ.js +65641 -0
  37. package/dist/{index-b7790662.js → index-C1x9Popy.js} +1 -1
  38. package/dist/index-CCNK5H8T.js +103 -0
  39. package/dist/{index-458debf7.js → index-CD09p_mF.js} +7 -31
  40. package/dist/{index-1048a998.js → index-CFnsLnrb.js} +68 -19
  41. package/dist/{index-4443363f.js → index-CJZp9lE4.js} +29 -50
  42. package/dist/{index-57492b9b.js → index-CSnBqUsQ.js} +48 -1
  43. package/dist/index-CWWI8SHO.js +206 -0
  44. package/dist/{index-7b8840f9.js → index-CZlEoE62.js} +220 -1010
  45. package/dist/index-CbyMC6Yz.js +59 -0
  46. package/dist/index-CiBVH-oH.js +258 -0
  47. package/dist/{index-3cf72afd.js → index-DUMmFdJ7.js} +9 -23
  48. package/dist/{index-01b17e26.js → index-Du-Biu-I.js} +1 -1
  49. package/dist/index-EnzWG8R0.js +521 -0
  50. package/dist/index-F2RO3OU4.js +501 -0
  51. package/dist/{index-7216d6b0.js → index-GavQwMDL.js} +11 -29
  52. package/dist/{index-0d5b9435.js → index-suip9eAw.js} +2 -2
  53. package/dist/index.d.ts +18 -14
  54. package/dist/index.js +23 -19
  55. package/dist/info-circle-fill-CFeVMdci.js +4 -0
  56. package/dist/input.js +6 -0
  57. package/dist/inputShadowless.js +6 -0
  58. package/dist/jszip.min-Ca6PjkYs.js +2674 -0
  59. package/dist/message.js +5 -0
  60. package/dist/modal.js +4 -0
  61. package/dist/{components/option/index.js → option.js} +3 -6
  62. package/dist/{pdf-bdb7818a.js → pdf-B2a6ll8f.js} +1 -1
  63. package/dist/player.js +8 -0
  64. package/dist/popover.js +6 -0
  65. package/dist/preview.js +7 -0
  66. package/dist/progress.js +7 -0
  67. package/dist/radar.js +6 -0
  68. package/dist/select.js +10 -0
  69. package/dist/selectShadowless.js +10 -0
  70. package/dist/{umd/components/image → shadowless/icon}/index.d.ts +1 -0
  71. package/dist/{umd/components → shadowless}/input/index.d.ts +33 -8
  72. package/dist/{umd/components → shadowless}/select/index.d.ts +16 -12
  73. package/dist/shadowless/shadowless/index.js +14 -0
  74. package/dist/shadowless.d.ts +3 -0
  75. package/dist/skeleton.js +4 -0
  76. package/dist/sprite-CH2zLtZy.js +141 -0
  77. package/dist/style.css +1 -1
  78. package/dist/tab.js +6 -0
  79. package/dist/tabpane.js +4 -0
  80. package/dist/tsconfig.json +29 -0
  81. package/dist/umd/index.umd.cjs +21 -32
  82. package/dist/umd/shadowless/shadowless.umd.cjs +1 -0
  83. package/dist/umd/shadowless/style.css +1 -0
  84. package/dist/umd/style.css +1 -1
  85. package/dist/utils/color.d.ts +52 -0
  86. package/dist/utils/index.d.ts +9 -1
  87. package/dist/{index-7913ec46.js → utils-BMBEcoPj.js} +279 -162
  88. package/dist/vite.config.d.ts +1 -0
  89. package/package.json +61 -36
  90. package/readme.md +14 -14
  91. package/typings.d.ts +101 -0
  92. package/dist/components/button/index.js +0 -8
  93. package/dist/components/icon/index.js +0 -6
  94. package/dist/components/image/index.js +0 -4
  95. package/dist/components/input/index.js +0 -6
  96. package/dist/components/message/index.js +0 -4
  97. package/dist/components/modal/index.js +0 -4
  98. package/dist/components/player/index.js +0 -12
  99. package/dist/components/preview/index.js +0 -8
  100. package/dist/components/progress/index.js +0 -8
  101. package/dist/components/radar/index.js +0 -7
  102. package/dist/components/select/index.js +0 -11
  103. package/dist/components/skeleton/index.js +0 -4
  104. package/dist/components/tab/index.js +0 -7
  105. package/dist/components/tabpane/index.js +0 -4
  106. package/dist/docx-c5d02d8c.js +0 -21
  107. package/dist/index-73ce455b.js +0 -264
  108. package/dist/index-c14450a9.js +0 -662
  109. package/dist/info-circle-fill-90ec9aa9.js +0 -14
  110. package/dist/umd/build/config.d.ts +0 -3
  111. package/dist/umd/build/config.umd.d.ts +0 -2
  112. package/dist/umd/components/button/index.d.ts +0 -35
  113. package/dist/umd/components/form/index.d.ts +0 -2
  114. package/dist/umd/components/icon/index.d.ts +0 -2
  115. package/dist/umd/components/message/index.d.ts +0 -14
  116. package/dist/umd/components/modal/index.d.ts +0 -2
  117. package/dist/umd/components/option/index.d.ts +0 -2
  118. package/dist/umd/components/player/index.d.ts +0 -213
  119. package/dist/umd/components/preview/colz.d.ts +0 -72
  120. package/dist/umd/components/preview/docx.d.ts +0 -8
  121. package/dist/umd/components/preview/excel/excel.d.ts +0 -2
  122. package/dist/umd/components/preview/excel/index.d.ts +0 -1
  123. package/dist/umd/components/preview/excel/media.d.ts +0 -37
  124. package/dist/umd/components/preview/index.d.ts +0 -6
  125. package/dist/umd/components/preview/pdf.d.ts +0 -1
  126. package/dist/umd/components/preview/pptx/index.d.ts +0 -16
  127. package/dist/umd/components/preview/pptx/process_pptx.d.ts +0 -23
  128. package/dist/umd/components/preview/pptx/t_xml.d.ts +0 -1
  129. package/dist/umd/components/preview/pptx/worker.d.ts +0 -1
  130. package/dist/umd/components/progress/index.d.ts +0 -36
  131. package/dist/umd/components/radar/index.d.ts +0 -2
  132. package/dist/umd/components/scratch/index.d.ts +0 -19
  133. package/dist/umd/components/skeleton/index.d.ts +0 -2
  134. package/dist/umd/components/tab/index.d.ts +0 -408
  135. package/dist/umd/components/tabpane/index.d.ts +0 -352
  136. package/dist/umd/index.d.ts +0 -14
  137. package/dist/umd/playwright.config.d.ts +0 -9
  138. package/dist/umd/plugins/auto-import-file.d.ts +0 -0
  139. package/dist/umd/plugins/load-style.d.ts +0 -6
  140. package/dist/umd/plugins/load-svg.d.ts +0 -9
  141. package/dist/umd/tests/button.spec.d.ts +0 -1
  142. package/dist/umd/utils/image.d.ts +0 -32
  143. package/dist/umd/utils/index.d.ts +0 -64
  144. package/dist/umd/utils/math.d.ts +0 -26
  145. package/dist/umd/utils/tween.d.ts +0 -21
  146. package/dist/umd/vite.config.d.ts +0 -6
  147. package/dist/vendor-f71e6f68.js +0 -92126
  148. /package/dist/{add-user-b2bed3e7.js → add-user-BN1JlY7e.js} +0 -0
  149. /package/dist/{book-b11a68eb.js → book-nTEFXU2x.js} +0 -0
  150. /package/dist/{umd/build/config.es.d.ts → build/config.sha.d.ts} +0 -0
  151. /package/dist/{check-circle-fill-dc284144.js → check-circle-fill-B_pd8ZSs.js} +0 -0
  152. /package/dist/{check-circle-74bd09c3.js → check-circle-szyAJiap.js} +0 -0
  153. /package/dist/{close-20925345.js → close-CFnkhudp.js} +0 -0
  154. /package/dist/{close-circle-720c18be.js → close-circle-CwmuN2C6.js} +0 -0
  155. /package/dist/{close-circle-fill-238a66b1.js → close-circle-fill-jSqPPw9i.js} +0 -0
  156. /package/dist/{eye-5e742329.js → eye-D_mEt17f.js} +0 -0
  157. /package/dist/{eye-close-3874f1ae.js → eye-close-BVr3NJtg.js} +0 -0
  158. /package/dist/{home-c4a05e8b.js → home-BUQ4USMk.js} +0 -0
  159. /package/dist/{index-8e1e2573.js → index-CQTJoWhb.js} +0 -0
  160. /package/dist/{info-circle-5826decc.js → info-circle-COnL5bTJ.js} +0 -0
  161. /package/dist/{loading-09ca52df.js → loading-Dcc5RApI.js} +0 -0
  162. /package/dist/{lock-1d2487c9.js → lock-Cr7BnmWN.js} +0 -0
  163. /package/dist/{message-b2bfdea7.js → message-D36_Zo2l.js} +0 -0
  164. /package/dist/{power-off-6ade5a91.js → power-off-lQRbiBak.js} +0 -0
  165. /package/dist/{preview-b291aea8.js → preview-CJbz9GjO.js} +0 -0
  166. /package/dist/{setting-1e5ccb6d.js → setting-DemlgzVC.js} +0 -0
  167. /package/dist/{team-ca6a12e1.js → team-tl4NJXPC.js} +0 -0
  168. /package/dist/{unlock-f56086fd.js → unlock-CeU74z9n.js} +0 -0
  169. /package/dist/{user-5c01e665.js → user-B-eVXwuk.js} +0 -0
  170. /package/dist/{warning-circle-035e025c.js → warning-circle-DDUgEDIv.js} +0 -0
  171. /package/dist/{warning-circle-fill-d17c37c9.js → warning-circle-fill-lODUKz0i.js} +0 -0
@@ -4,8 +4,9 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { c as createDocumentFragment, S as SyncHook, r as removeClassToElement, a as addClassToElement, d as timeFormat, e as range, b as generateThrottle } from "./index-7913ec46.js";
8
- import "./index-1b73beee.js";
7
+ import { b as createDocumentFragment, S as SyncHook, r as removeClassToElement, a as addClassToElement, t as timeFormat, e as range, d as generateThrottle } from "./utils-BMBEcoPj.js";
8
+ import "./index-BLepXisd.js";
9
+ import { H as HTMLElementSSR } from "./index-CSnBqUsQ.js";
9
10
  !function t(e) {
10
11
  var r, i;
11
12
  r = this, i = function() {
@@ -9312,18 +9313,18 @@ import "./index-1b73beee.js";
9312
9313
  return Xa.defaultConfig = void 0, Xa;
9313
9314
  }, "object" == typeof exports && "undefined" != typeof module ? module.exports = i() : "function" == typeof define && define.amd ? define(i) : (r = "undefined" != typeof globalThis ? globalThis : r || self).Hls = i();
9314
9315
  }(false);
9315
- const index$2 = "";
9316
9316
  const PLAY_STATE_LIST = ["play", "playing", "timeupdate"];
9317
9317
  const throttle = generateThrottle();
9318
9318
  const SPEED = [
9319
9319
  { label: "2.0X", value: 2 },
9320
9320
  { label: "1.5X", value: 1.5 },
9321
9321
  { label: "1.0X", value: 1 },
9322
+ { label: "0.8X", value: 0.8 },
9322
9323
  { label: "0.5X", value: 0.5 }
9323
9324
  ];
9324
- class RanPlayer extends HTMLElement {
9325
+ class RanPlayer extends HTMLElementSSR() {
9325
9326
  /**
9326
- * @description: 初始化view和video的全局上下文
9327
+ * @description: 初始化 view video 的全局上下文
9327
9328
  * @return {*}
9328
9329
  */
9329
9330
  constructor() {
@@ -9425,6 +9426,7 @@ class RanPlayer extends HTMLElement {
9425
9426
  }
9426
9427
  this.ctx.url = url;
9427
9428
  this.createClaritySelect();
9429
+ this.change("hlsManifestLoaded", { data });
9428
9430
  }
9429
9431
  });
9430
9432
  /**
@@ -9450,25 +9452,36 @@ class RanPlayer extends HTMLElement {
9450
9452
  this._video.setAttribute("controls", "false");
9451
9453
  this._video.controls = false;
9452
9454
  this._video.setAttribute("initial-time", "0.01");
9453
- if ((Hls == null ? void 0 : Hls.isSupported()) && this.src) {
9454
- this._hls = new Hls();
9455
- if (this._hls) {
9456
- this._hls.off(Hls.Events.MANIFEST_LOADED, this.manifestLoaded);
9457
- this._hls.on(Hls.Events.MANIFEST_LOADED, this.manifestLoaded);
9458
- this._hls.loadSource(this.src);
9459
- this._hls.attachMedia(this._video);
9460
- }
9461
- this._container.appendChild(this._video);
9462
- (_a = this._video.parentElement) == null ? void 0 : _a.setAttribute(
9463
- "class",
9464
- "ran-player-contain"
9465
- );
9455
+ try {
9456
+ if (this._video.canPlayType("application/vnd.apple.mpegurl") && this.src) {
9457
+ this._video.src = this.src;
9458
+ } else if ((Hls == null ? void 0 : Hls.isSupported()) && this.src) {
9459
+ this._hls = new Hls();
9460
+ if (this._hls) {
9461
+ this._hls.off(Hls.Events.MANIFEST_LOADED, this.manifestLoaded);
9462
+ this._hls.on(Hls.Events.MANIFEST_LOADED, this.manifestLoaded);
9463
+ this._hls.off(Hls.Events.ERROR, this.hlsError);
9464
+ this._hls.on(Hls.Events.ERROR, this.hlsError);
9465
+ this._hls.loadSource(this.src);
9466
+ this._hls.attachMedia(this._video);
9467
+ }
9468
+ this._container.appendChild(this._video);
9469
+ (_a = this._video.parentElement) == null ? void 0 : _a.setAttribute("class", "ran-player-contain");
9470
+ }
9471
+ this.listenEvent();
9472
+ } catch (error) {
9473
+ }
9474
+ });
9475
+ __publicField(this, "hlsError", (event, data) => {
9476
+ this.change("hlsError", { event, data });
9477
+ if (this._video) {
9478
+ this._video.src = this.src;
9466
9479
  }
9467
- this.listenEvent();
9468
9480
  });
9469
9481
  __publicField(this, "change", (name, value) => {
9470
9482
  const currentTime = this.getCurrentTime();
9471
9483
  const duration = this.getTotalTime();
9484
+ this.debug && console.log(name, value);
9472
9485
  this.dispatchEvent(
9473
9486
  new CustomEvent("change", {
9474
9487
  detail: {
@@ -9483,14 +9496,8 @@ class RanPlayer extends HTMLElement {
9483
9496
  });
9484
9497
  __publicField(this, "onCanplay", (e) => {
9485
9498
  this.ctx.currentState = e.type;
9486
- removeClassToElement(
9487
- this._playerControllerBottomPlayBtn,
9488
- "ran-player-controller-bottom-left-btn-pause"
9489
- );
9490
- addClassToElement(
9491
- this._playerControllerBottomPlayBtn,
9492
- "ran-player-controller-bottom-left-btn-play"
9493
- );
9499
+ removeClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-pause");
9500
+ addClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-play");
9494
9501
  this.change("canplay", e);
9495
9502
  this.resize();
9496
9503
  });
@@ -9556,9 +9563,7 @@ class RanPlayer extends HTMLElement {
9556
9563
  this.ctx.duration = duration;
9557
9564
  this._playerControllerBottomTimeCurrent.innerText = "00:00";
9558
9565
  this._playerControllerBottomTimeDivide.innerText = "/";
9559
- this._playerControllerBottomTimeDuration.innerText = timeFormat(
9560
- this.ctx.duration
9561
- );
9566
+ this._playerControllerBottomTimeDuration.innerText = timeFormat(this.ctx.duration);
9562
9567
  this.change("loadeddata", e);
9563
9568
  });
9564
9569
  __publicField(this, "onTimeupdate", (e) => {
@@ -9576,28 +9581,16 @@ class RanPlayer extends HTMLElement {
9576
9581
  __publicField(this, "onPlay", (e) => {
9577
9582
  this.ctx.currentState = e.type;
9578
9583
  this.requestAnimationFrame(this.updateCurrentProgress);
9579
- removeClassToElement(
9580
- this._playerControllerBottomPlayBtn,
9581
- "ran-player-controller-bottom-left-btn-play"
9582
- );
9583
- addClassToElement(
9584
- this._playerControllerBottomPlayBtn,
9585
- "ran-player-controller-bottom-left-btn-pause"
9586
- );
9584
+ removeClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-play");
9585
+ addClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-pause");
9587
9586
  this.showControllerBar();
9588
9587
  this.change("play", e);
9589
9588
  });
9590
9589
  __publicField(this, "onPlaying", (e) => {
9591
9590
  this.ctx.currentState = e.type;
9592
9591
  this._playerBtn.style.setProperty("display", "none");
9593
- removeClassToElement(
9594
- this._playerControllerBottomPlayBtn,
9595
- "ran-player-controller-bottom-left-btn-play"
9596
- );
9597
- addClassToElement(
9598
- this._playerControllerBottomPlayBtn,
9599
- "ran-player-controller-bottom-left-btn-pause"
9600
- );
9592
+ removeClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-play");
9593
+ addClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-pause");
9601
9594
  this.requestAnimationFrame(this.updateCurrentProgress);
9602
9595
  this.showControllerBar();
9603
9596
  this.change("playing", e);
@@ -9606,14 +9599,8 @@ class RanPlayer extends HTMLElement {
9606
9599
  this.ctx.currentState = e.type;
9607
9600
  this._playerBtn.style.setProperty("display", "block");
9608
9601
  this.change("pause", e);
9609
- removeClassToElement(
9610
- this._playerControllerBottomPlayBtn,
9611
- "ran-player-controller-bottom-left-btn-pause"
9612
- );
9613
- addClassToElement(
9614
- this._playerControllerBottomPlayBtn,
9615
- "ran-player-controller-bottom-left-btn-play"
9616
- );
9602
+ removeClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-pause");
9603
+ addClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-play");
9617
9604
  this.cancelAnimationFrame();
9618
9605
  this._playerController.style.setProperty("opacity", "1");
9619
9606
  if (this.controllerBarTimeId) {
@@ -9625,23 +9612,14 @@ class RanPlayer extends HTMLElement {
9625
9612
  if (!this._video)
9626
9613
  return;
9627
9614
  this._video.removeEventListener("canplay", this.onCanplay);
9628
- this._video.removeEventListener(
9629
- "canplaythrough",
9630
- this.onCanplaythrough
9631
- );
9615
+ this._video.removeEventListener("canplaythrough", this.onCanplaythrough);
9632
9616
  this._video.removeEventListener("complete", this.onComplete);
9633
- this._video.removeEventListener(
9634
- "durationchange",
9635
- this.onDurationchange
9636
- );
9617
+ this._video.removeEventListener("durationchange", this.onDurationchange);
9637
9618
  this._video.removeEventListener("emptied", this.onEmptied);
9638
9619
  this._video.removeEventListener("ended", this.onEnded);
9639
9620
  this._video.removeEventListener("error", this.onError);
9640
9621
  this._video.removeEventListener("loadeddata", this.onLoadeddata);
9641
- this._video.removeEventListener(
9642
- "loadedmetadata",
9643
- this.onLoadedmetadata
9644
- );
9622
+ this._video.removeEventListener("loadedmetadata", this.onLoadedmetadata);
9645
9623
  this._video.removeEventListener("loadstart", this.onLoadstart);
9646
9624
  this._video.removeEventListener("pause", this.onPause);
9647
9625
  this._video.removeEventListener("play", this.onPlay);
@@ -9752,14 +9730,8 @@ class RanPlayer extends HTMLElement {
9752
9730
  const rect = this._progress.getBoundingClientRect();
9753
9731
  const offsetX = e.clientX - rect.left - 9;
9754
9732
  const percentage = range(offsetX / this._progress.offsetWidth);
9755
- this._progressWrapValue.style.setProperty(
9756
- "transform",
9757
- `scaleX(${percentage})`
9758
- );
9759
- this._progressDot.style.setProperty(
9760
- "transform",
9761
- `translateX(${percentage * this._progress.offsetWidth}px)`
9762
- );
9733
+ this._progressWrapValue.style.setProperty("transform", `scaleX(${percentage})`);
9734
+ this._progressDot.style.setProperty("transform", `translateX(${percentage * this._progress.offsetWidth}px)`);
9763
9735
  this.moveProgress.percentage = Math.floor(percentage * 100) / 100;
9764
9736
  });
9765
9737
  /**
@@ -9811,10 +9783,7 @@ class RanPlayer extends HTMLElement {
9811
9783
  const currentTime = this.getCurrentTime();
9812
9784
  this.ctx.currentTime = currentTime;
9813
9785
  const { duration } = this.ctx;
9814
- this._progressWrapValue.style.setProperty(
9815
- "transform",
9816
- `scaleX(${currentTime / duration})`
9817
- );
9786
+ this._progressWrapValue.style.setProperty("transform", `scaleX(${currentTime / duration})`);
9818
9787
  this._progressDot.style.setProperty(
9819
9788
  "transform",
9820
9789
  `translateX(${currentTime / duration * this._progress.offsetWidth}px)`
@@ -9871,7 +9840,7 @@ class RanPlayer extends HTMLElement {
9871
9840
  }
9872
9841
  });
9873
9842
  /**
9874
- * @description: 点击player-btn,触发的事件
9843
+ * @description: 点击 player-btn,触发的事件
9875
9844
  * @param {*} void
9876
9845
  * @return {*}
9877
9846
  */
@@ -9925,24 +9894,14 @@ class RanPlayer extends HTMLElement {
9925
9894
  const rect = this._progress.getBoundingClientRect();
9926
9895
  const offsetX = e.clientX - rect.left;
9927
9896
  if (this._playerTipText.innerText) {
9928
- this._playerTip.style.setProperty(
9929
- "transform",
9930
- `translate(calc(${offsetX}px - 50%),-20px)`
9931
- );
9897
+ this._playerTip.style.setProperty("transform", `translate(calc(${offsetX}px - 50%),-20px)`);
9932
9898
  } else {
9933
- this._playerTip.style.setProperty(
9934
- "transform",
9935
- `translateX(calc(${offsetX}px - 50%))`
9936
- );
9899
+ this._playerTip.style.setProperty("transform", `translateX(calc(${offsetX}px - 50%))`);
9937
9900
  }
9938
- this._playerTipTime.innerText = timeFormat(
9939
- offsetX / this._progress.clientWidth * this.ctx.duration
9940
- );
9901
+ this._playerTipTime.innerText = timeFormat(offsetX / this._progress.clientWidth * this.ctx.duration);
9941
9902
  });
9942
9903
  __publicField(this, "progressMouseLeave", (e) => {
9943
- if (e.target.classList.contains(
9944
- "ran-player-controller-progress-wrap-dot"
9945
- )) {
9904
+ if (e.target.classList.contains("ran-player-controller-progress-wrap-dot")) {
9946
9905
  return;
9947
9906
  }
9948
9907
  this._playerTip.style.setProperty("opacity", "0");
@@ -9952,29 +9911,18 @@ class RanPlayer extends HTMLElement {
9952
9911
  this._playerTip.style.setProperty("opacity", "1");
9953
9912
  const offsetX = e.clientX - rect.left;
9954
9913
  if (this._playerTipText.innerText) {
9955
- this._playerTip.style.setProperty(
9956
- "transform",
9957
- `translate(calc(${offsetX}px - 50%),-20px)`
9958
- );
9914
+ this._playerTip.style.setProperty("transform", `translate(calc(${offsetX}px - 50%),-20px)`);
9959
9915
  } else {
9960
- this._playerTip.style.setProperty(
9961
- "transform",
9962
- `translateX(calc(${offsetX}px - 50%))`
9963
- );
9916
+ this._playerTip.style.setProperty("transform", `translateX(calc(${offsetX}px - 50%))`);
9964
9917
  }
9965
- this._playerTipTime.innerText = timeFormat(
9966
- offsetX / this._progress.clientWidth * this.ctx.duration
9967
- );
9918
+ this._playerTipTime.innerText = timeFormat(offsetX / this._progress.clientWidth * this.ctx.duration);
9968
9919
  });
9969
9920
  __publicField(this, "changePlayerVolume", () => {
9970
9921
  if (!this._video)
9971
9922
  return;
9972
9923
  const { volume } = this.ctx;
9973
9924
  if (volume > 0) {
9974
- addClassToElement(
9975
- this._playControllerBottomSpeedIcon,
9976
- "ran-player-controller-bottom-right-volume-icon-mute"
9977
- );
9925
+ addClassToElement(this._playControllerBottomSpeedIcon, "ran-player-controller-bottom-right-volume-icon-mute");
9978
9926
  removeClassToElement(
9979
9927
  this._playControllerBottomSpeedIcon,
9980
9928
  "ran-player-controller-bottom-right-volume-icon-volume"
@@ -9983,18 +9931,9 @@ class RanPlayer extends HTMLElement {
9983
9931
  this.setVolume(0);
9984
9932
  this.change("volume", 0);
9985
9933
  } else {
9986
- addClassToElement(
9987
- this._playControllerBottomSpeedIcon,
9988
- "ran-player-controller-bottom-right-volume-icon-volume"
9989
- );
9990
- removeClassToElement(
9991
- this._playControllerBottomSpeedIcon,
9992
- "ran-player-controller-bottom-right-volume-icon-mute"
9993
- );
9994
- this._playControllerBottomVolumeProgress.setAttribute(
9995
- "percent",
9996
- `${this._volume || 0.5}`
9997
- );
9934
+ addClassToElement(this._playControllerBottomSpeedIcon, "ran-player-controller-bottom-right-volume-icon-volume");
9935
+ removeClassToElement(this._playControllerBottomSpeedIcon, "ran-player-controller-bottom-right-volume-icon-mute");
9936
+ this._playControllerBottomVolumeProgress.setAttribute("percent", `${this._volume || 0.5}`);
9998
9937
  this.setVolume(0.5);
9999
9938
  this.change("volume", this._volume || 0.5);
10000
9939
  }
@@ -10005,15 +9944,9 @@ class RanPlayer extends HTMLElement {
10005
9944
  this._video.style.setProperty("width", `${width}px`);
10006
9945
  this._video.style.setProperty("height", `${height}px`);
10007
9946
  if (document.body.clientWidth < 500) {
10008
- this._playControllerBottomVolume.style.setProperty(
10009
- "display",
10010
- "none"
10011
- );
9947
+ this._playControllerBottomVolume.style.setProperty("display", "none");
10012
9948
  } else {
10013
- this._playControllerBottomVolume.style.setProperty(
10014
- "display",
10015
- "flex"
10016
- );
9949
+ this._playControllerBottomVolume.style.setProperty("display", "flex");
10017
9950
  }
10018
9951
  }
10019
9952
  this.updateCurrentProgress();
@@ -10087,6 +10020,7 @@ class RanPlayer extends HTMLElement {
10087
10020
  this._video.pause();
10088
10021
  }
10089
10022
  });
10023
+ this.innerHTML = "";
10090
10024
  this._player = document.createElement("div");
10091
10025
  this._container = document.createElement("div");
10092
10026
  this._slot = document.createElement("slot");
@@ -10099,82 +10033,34 @@ class RanPlayer extends HTMLElement {
10099
10033
  this._playerControllerBottomRight = document.createElement("div");
10100
10034
  this._playerControllerBottomLeft = document.createElement("div");
10101
10035
  this._player.setAttribute("class", "ran-player");
10102
- this._player.setAttribute(
10103
- "id",
10104
- "ran-player" + `${performance.now()}`.replace(".", "")
10105
- );
10036
+ this._player.setAttribute("id", "ran-player" + `${performance.now()}`.replace(".", ""));
10106
10037
  this._playerBtn.setAttribute("class", "ran-player-play-btn");
10107
10038
  this._progress.setAttribute("class", "ran-player-controller-progress");
10108
- this._progressWrap.setAttribute(
10109
- "class",
10110
- "ran-player-controller-progress-wrap"
10111
- );
10112
- this._progressWrapValue.setAttribute(
10113
- "class",
10114
- "ran-player-controller-progress-wrap-value"
10115
- );
10116
- this._progressDot.setAttribute(
10117
- "class",
10118
- "ran-player-controller-progress-dot"
10119
- );
10120
- this._playerControllerBottom.setAttribute(
10121
- "class",
10122
- "ran-player-controller-bottom"
10123
- );
10124
- this._playerControllerBottomRight.setAttribute(
10125
- "class",
10126
- "ran-player-controller-bottom-right"
10127
- );
10128
- this._playerControllerBottomLeft.setAttribute(
10129
- "class",
10130
- "ran-player-controller-bottom-left"
10131
- );
10039
+ this._progressWrap.setAttribute("class", "ran-player-controller-progress-wrap");
10040
+ this._progressWrapValue.setAttribute("class", "ran-player-controller-progress-wrap-value");
10041
+ this._progressDot.setAttribute("class", "ran-player-controller-progress-dot");
10042
+ this._playerControllerBottom.setAttribute("class", "ran-player-controller-bottom");
10043
+ this._playerControllerBottomRight.setAttribute("class", "ran-player-controller-bottom-right");
10044
+ this._playerControllerBottomLeft.setAttribute("class", "ran-player-controller-bottom-left");
10132
10045
  this._playerControllerBottomPlayBtn = document.createElement("div");
10133
- this._playerControllerBottomPlayBtn.setAttribute(
10134
- "class",
10135
- "ran-player-controller-bottom-left-btn"
10136
- );
10046
+ this._playerControllerBottomPlayBtn.setAttribute("class", "ran-player-controller-bottom-left-btn");
10137
10047
  this._playerControllerBottomTimeCurrent = document.createElement("div");
10138
- this._playerControllerBottomTimeCurrent.setAttribute(
10139
- "class",
10140
- "ran-player-controller-bottom-left-time-current"
10141
- );
10048
+ this._playerControllerBottomTimeCurrent.setAttribute("class", "ran-player-controller-bottom-left-time-current");
10142
10049
  this._playerControllerBottomTimeDivide = document.createElement("div");
10143
- this._playerControllerBottomTimeDivide.setAttribute(
10144
- "class",
10145
- "ran-player-controller-bottom-left-time-divide"
10146
- );
10050
+ this._playerControllerBottomTimeDivide.setAttribute("class", "ran-player-controller-bottom-left-time-divide");
10147
10051
  this._playerControllerBottomTimeDuration = document.createElement("div");
10148
- this._playerControllerBottomTimeDuration.setAttribute(
10149
- "class",
10150
- "ran-player-controller-bottom-left-time-duration"
10151
- );
10052
+ this._playerControllerBottomTimeDuration.setAttribute("class", "ran-player-controller-bottom-left-time-duration");
10152
10053
  this._playControllerBottomSpeed = document.createElement("div");
10153
- this._playControllerBottomSpeed.setAttribute(
10154
- "class",
10155
- "ran-player-controller-bottom-right-speed"
10156
- );
10054
+ this._playControllerBottomSpeed.setAttribute("class", "ran-player-controller-bottom-right-speed");
10157
10055
  this._playControllerBottomSpeedPopover = document.createElement("r-select");
10158
10056
  this._playControllerBottomSpeedPopover.setAttribute("value", "1");
10159
- this._playControllerBottomSpeedPopover.setAttribute(
10160
- "action",
10161
- "hover,click"
10162
- );
10057
+ this._playControllerBottomSpeedPopover.setAttribute("action", "hover,click");
10163
10058
  this._playControllerBottomSpeedPopover.setAttribute("type", "text");
10164
10059
  this._playControllerBottomSpeedPopover.setAttribute("placement", "top");
10165
10060
  const id = this._player.getAttribute("id");
10166
- id && this._playControllerBottomSpeedPopover.setAttribute(
10167
- "getPopupContainerId",
10168
- id
10169
- );
10170
- this._playControllerBottomSpeedPopover.setAttribute(
10171
- "dropdownclass",
10172
- "video-speed-dropdown"
10173
- );
10174
- this._playControllerBottomSpeedPopover.addEventListener(
10175
- "change",
10176
- this.changeSpeed
10177
- );
10061
+ id && this._playControllerBottomSpeedPopover.setAttribute("getPopupContainerId", id);
10062
+ this._playControllerBottomSpeedPopover.setAttribute("dropdownclass", "video-speed-dropdown");
10063
+ this._playControllerBottomSpeedPopover.addEventListener("change", this.changeSpeed);
10178
10064
  const Fragment = document.createDocumentFragment();
10179
10065
  SPEED.forEach((item) => {
10180
10066
  const { label, value } = item;
@@ -10184,14 +10070,9 @@ class RanPlayer extends HTMLElement {
10184
10070
  Fragment.appendChild(option);
10185
10071
  });
10186
10072
  this._playControllerBottomSpeedPopover.appendChild(Fragment);
10187
- this._playControllerBottomSpeed.appendChild(
10188
- this._playControllerBottomSpeedPopover
10189
- );
10073
+ this._playControllerBottomSpeed.appendChild(this._playControllerBottomSpeedPopover);
10190
10074
  this._playControllerBottomVolume = document.createElement("div");
10191
- this._playControllerBottomVolume.setAttribute(
10192
- "class",
10193
- "ran-player-controller-bottom-right-volume"
10194
- );
10075
+ this._playControllerBottomVolume.setAttribute("class", "ran-player-controller-bottom-right-volume");
10195
10076
  this._playControllerBottomVolumeProgress = document.createElement("r-progress");
10196
10077
  this._playControllerBottomVolumeProgress.setAttribute(
10197
10078
  "class",
@@ -10205,56 +10086,28 @@ class RanPlayer extends HTMLElement {
10205
10086
  "ran-player-controller-bottom-right-volume-icon ran-player-controller-bottom-right-volume-icon-volume"
10206
10087
  );
10207
10088
  this._playControllerBottomClarity = document.createElement("div");
10208
- this._playControllerBottomClarity.setAttribute(
10209
- "class",
10210
- "ran-player-controller-bottom-right-clarity"
10211
- );
10089
+ this._playControllerBottomClarity.setAttribute("class", "ran-player-controller-bottom-right-clarity");
10212
10090
  this._playControllerBottomRightFullScreen = document.createElement("div");
10213
- this._playControllerBottomRightFullScreen.setAttribute(
10214
- "class",
10215
- "ran-player-controller-bottom-right-full"
10216
- );
10091
+ this._playControllerBottomRightFullScreen.setAttribute("class", "ran-player-controller-bottom-right-full");
10217
10092
  this._playerController = document.createElement("div");
10218
10093
  this._playerController.setAttribute("class", "ran-player-controller");
10219
10094
  this._playerTip = document.createElement("div");
10220
10095
  this._playerTip.setAttribute("class", "ran-player-controller-tip");
10221
10096
  this._playerTipTime = document.createElement("div");
10222
- this._playerTipTime.setAttribute(
10223
- "class",
10224
- "ran-player-controller-tip-time"
10225
- );
10097
+ this._playerTipTime.setAttribute("class", "ran-player-controller-tip-time");
10226
10098
  this._playerTipText = document.createElement("div");
10227
- this._playerTipText.setAttribute(
10228
- "class",
10229
- "ran-player-controller-tip-text"
10230
- );
10231
- this._playerTip.appendChild(
10232
- createDocumentFragment([this._playerTipTime, this._playerTipText])
10233
- );
10099
+ this._playerTipText.setAttribute("class", "ran-player-controller-tip-text");
10100
+ this._playerTip.appendChild(createDocumentFragment([this._playerTipTime, this._playerTipText]));
10234
10101
  this._playerController.appendChild(
10235
- createDocumentFragment([
10236
- this._playerTip,
10237
- this._progress,
10238
- this._playerControllerBottom
10239
- ])
10102
+ createDocumentFragment([this._playerTip, this._progress, this._playerControllerBottom])
10240
10103
  );
10241
10104
  this._player.appendChild(
10242
- createDocumentFragment([
10243
- this._container,
10244
- this._slot,
10245
- this._playerBtn,
10246
- this._playerController
10247
- ])
10105
+ createDocumentFragment([this._container, this._slot, this._playerBtn, this._playerController])
10248
10106
  );
10249
10107
  this._progressWrap.appendChild(this._progressWrapValue);
10250
- this._progress.appendChild(
10251
- createDocumentFragment([this._progressWrap, this._progressDot])
10252
- );
10108
+ this._progress.appendChild(createDocumentFragment([this._progressWrap, this._progressDot]));
10253
10109
  this._playerControllerBottom.appendChild(
10254
- createDocumentFragment([
10255
- this._playerControllerBottomLeft,
10256
- this._playerControllerBottomRight
10257
- ])
10110
+ createDocumentFragment([this._playerControllerBottomLeft, this._playerControllerBottomRight])
10258
10111
  );
10259
10112
  this._playerControllerBottomLeft.appendChild(
10260
10113
  createDocumentFragment([
@@ -10265,10 +10118,7 @@ class RanPlayer extends HTMLElement {
10265
10118
  ])
10266
10119
  );
10267
10120
  this._playControllerBottomVolume.appendChild(
10268
- createDocumentFragment([
10269
- this._playControllerBottomSpeedIcon,
10270
- this._playControllerBottomVolumeProgress
10271
- ])
10121
+ createDocumentFragment([this._playControllerBottomSpeedIcon, this._playControllerBottomVolumeProgress])
10272
10122
  );
10273
10123
  this._playerControllerBottomRight.appendChild(
10274
10124
  createDocumentFragment([
@@ -10308,7 +10158,7 @@ class RanPlayer extends HTMLElement {
10308
10158
  };
10309
10159
  }
10310
10160
  static get observedAttributes() {
10311
- return ["src", "volume", "currentTime", "playbackRate"];
10161
+ return ["src", "volume", "currentTime", "playbackRate", "debug"];
10312
10162
  }
10313
10163
  get src() {
10314
10164
  return this.getAttribute("src") || "";
@@ -10316,6 +10166,12 @@ class RanPlayer extends HTMLElement {
10316
10166
  set src(value) {
10317
10167
  this.setAttribute("src", value || "");
10318
10168
  }
10169
+ get debug() {
10170
+ return this.getAttribute("debug") || "";
10171
+ }
10172
+ set debug(value) {
10173
+ this.setAttribute("debug", value || "");
10174
+ }
10319
10175
  get volume() {
10320
10176
  return this.getAttribute("volume") || "";
10321
10177
  }
@@ -10335,87 +10191,39 @@ class RanPlayer extends HTMLElement {
10335
10191
  this.setAttribute("playbackRate", value || "");
10336
10192
  }
10337
10193
  connectedCallback() {
10338
- this._container.addEventListener(
10339
- "click",
10340
- this.dispatchClickPlayerContainerAction
10341
- );
10342
- this._playerBtn.addEventListener(
10343
- "click",
10344
- this.dispatchClickPlayerBtnAction
10345
- );
10194
+ this._container.addEventListener("click", this.dispatchClickPlayerContainerAction);
10195
+ this._playerBtn.addEventListener("click", this.dispatchClickPlayerBtnAction);
10346
10196
  this.addEventListener("keydown", this.SpaceKeyDown);
10347
- this._progressDot.addEventListener(
10348
- "mousedown",
10349
- this.progressDotMouseDown
10350
- );
10351
- this._playerControllerBottomPlayBtn.addEventListener(
10352
- "click",
10353
- this.dispatchClickPlayerBtnAction
10354
- );
10197
+ this._progressDot.addEventListener("mousedown", this.progressDotMouseDown);
10198
+ this._playerControllerBottomPlayBtn.addEventListener("click", this.dispatchClickPlayerBtnAction);
10355
10199
  this._progress.addEventListener("click", this.progressClick);
10356
10200
  this._progress.addEventListener("mouseenter", this.progressMouseEnter);
10357
10201
  this._progress.addEventListener("mousemove", this.progressMouseMove);
10358
10202
  this._progress.addEventListener("mouseleave", this.progressMouseLeave);
10359
10203
  this._player.addEventListener("mousemove", this.progressDotMouseMove);
10360
10204
  this._player.addEventListener("mouseup", this.progressDotMouseUp);
10361
- this._playControllerBottomVolumeProgress.addEventListener(
10362
- "change",
10363
- this.changeVolumeProgress
10364
- );
10365
- this._playControllerBottomRightFullScreen.addEventListener(
10366
- "click",
10367
- this.openFullScreen
10368
- );
10369
- this._playControllerBottomSpeedIcon.addEventListener(
10370
- "click",
10371
- this.changePlayerVolume
10372
- );
10205
+ this._playControllerBottomVolumeProgress.addEventListener("change", this.changeVolumeProgress);
10206
+ this._playControllerBottomRightFullScreen.addEventListener("click", this.openFullScreen);
10207
+ this._playControllerBottomSpeedIcon.addEventListener("click", this.changePlayerVolume);
10373
10208
  document.addEventListener("fullscreenchange", this.fullScreenChange);
10374
10209
  window.addEventListener("resize", this.resize);
10375
10210
  this.updatePlayer();
10376
10211
  }
10377
10212
  disconnectCallback() {
10378
- this._container.removeEventListener(
10379
- "click",
10380
- this.dispatchClickPlayerContainerAction
10381
- );
10382
- this._playerBtn.removeEventListener(
10383
- "click",
10384
- this.dispatchClickPlayerBtnAction
10385
- );
10386
- this._playerControllerBottomPlayBtn.removeEventListener(
10387
- "click",
10388
- this.dispatchClickPlayerBtnAction
10389
- );
10213
+ this._container.removeEventListener("click", this.dispatchClickPlayerContainerAction);
10214
+ this._playerBtn.removeEventListener("click", this.dispatchClickPlayerBtnAction);
10215
+ this._playerControllerBottomPlayBtn.removeEventListener("click", this.dispatchClickPlayerBtnAction);
10390
10216
  this.cancelAnimationFrame();
10391
10217
  this.removeEventListener("keydown", this.SpaceKeyDown);
10392
10218
  this._progress.removeEventListener("click", this.progressClick);
10393
- this._progress.removeEventListener(
10394
- "mouseenter",
10395
- this.progressMouseEnter
10396
- );
10219
+ this._progress.removeEventListener("mouseenter", this.progressMouseEnter);
10397
10220
  this._progress.removeEventListener("mousemove", this.progressMouseMove);
10398
- this._progress.removeEventListener(
10399
- "mouseleave",
10400
- this.progressMouseLeave
10401
- );
10402
- this._progressDot.removeEventListener(
10403
- "mousedown",
10404
- this.progressDotMouseDown
10405
- );
10406
- this._player.removeEventListener(
10407
- "mousemove",
10408
- this.progressDotMouseMove
10409
- );
10221
+ this._progress.removeEventListener("mouseleave", this.progressMouseLeave);
10222
+ this._progressDot.removeEventListener("mousedown", this.progressDotMouseDown);
10223
+ this._player.removeEventListener("mousemove", this.progressDotMouseMove);
10410
10224
  this._player.removeEventListener("mouseup", this.progressDotMouseUp);
10411
- this._playControllerBottomVolumeProgress.removeEventListener(
10412
- "change",
10413
- this.changeVolumeProgress
10414
- );
10415
- this._playControllerBottomRightFullScreen.removeEventListener(
10416
- "click",
10417
- this.openFullScreen
10418
- );
10225
+ this._playControllerBottomVolumeProgress.removeEventListener("change", this.changeVolumeProgress);
10226
+ this._playControllerBottomRightFullScreen.removeEventListener("click", this.openFullScreen);
10419
10227
  window.removeEventListener("resize", this.resize);
10420
10228
  document.removeEventListener("fullscreenchange", this.fullScreenChange);
10421
10229
  }