x-star-design 0.0.38 → 0.0.39

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.
@@ -15,9 +15,9 @@ export interface AliplayerInstance {
15
15
  pause: () => void;
16
16
  seek: (time: number) => void;
17
17
  getCurrentTime: () => number;
18
- setPlayerSize: (width: string, height: string) => void;
18
+ setPlayerSize: (w: string, h: string) => void;
19
19
  dispose: () => void;
20
- on: (event: string, handler: () => void) => void;
20
+ on: (name: string, handler: () => void) => void;
21
21
  }
22
22
  interface AliplayerProps {
23
23
  config: AliplayerConfig;
@@ -1,5 +1,5 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { useMemoizedFn, useSize, useUnmount } from 'ahooks';
2
+ import { useMemoizedFn, useSize } from 'ahooks';
3
3
  import React, { useEffect, useMemo, useRef } from 'react';
4
4
  import { randomString } from 'x-star-utils';
5
5
 
@@ -17,8 +17,8 @@ var Aliplayer = function Aliplayer(_ref) {
17
17
  var id = useMemo(function () {
18
18
  return "aliplayer-".concat(randomString(8));
19
19
  }, []);
20
- var wrapper = useRef(null);
21
20
  var player = useRef();
21
+ var wrapper = useRef(null);
22
22
  var size = useSize(wrapper);
23
23
  var importAliPlayer = function importAliPlayer() {
24
24
  var link = window.document.createElement('link');
@@ -34,18 +34,15 @@ var Aliplayer = function Aliplayer(_ref) {
34
34
  if (!window.Aliplayer) {
35
35
  importAliPlayer();
36
36
  }
37
+
37
38
  /**
38
39
  * 根据宽度调整高度,比例为 16:9
39
40
  */
40
41
  var resize = useMemoizedFn(function () {
41
42
  return player.current && size && player.current.setPlayerSize("".concat(size.width, "px"), "".concat(size.width / 16 * 9, "px"));
42
43
  });
43
- useEffect(resize, [size, resize]);
44
+ useEffect(resize, [size]);
44
45
  useEffect(function () {
45
- if (player.current) {
46
- player.current.dispose();
47
- player.current = undefined;
48
- }
49
46
  var create = function create() {
50
47
  var run = function run(retry) {
51
48
  var Aliplayer = window.Aliplayer;
@@ -69,17 +66,13 @@ var Aliplayer = function Aliplayer(_ref) {
69
66
  });
70
67
  };
71
68
  create();
72
- }, [config === null || config === void 0 ? void 0 : config.vid, config === null || config === void 0 ? void 0 : config.playauth, id, resize, onCreate]);
73
-
74
- /**
75
- * 组件卸载时销毁 Aliplayer
76
- */
77
- useUnmount(function () {
78
- if (player.current) {
79
- player.current.dispose();
80
- player.current = undefined;
81
- }
82
- });
69
+ return function () {
70
+ if (player.current) {
71
+ player.current.dispose();
72
+ player.current = undefined;
73
+ }
74
+ };
75
+ }, [config.vid, config.playauth]);
83
76
  return /*#__PURE__*/React.createElement("div", {
84
77
  ref: wrapper
85
78
  }, /*#__PURE__*/React.createElement("div", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-star-design",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "description": "A react component library developed by turingstar",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",