@realsee/vreo 1.0.0-alpha.23 → 1.0.0-alpha.24

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 (48) hide show
  1. package/lib/PlayController/createHTMLAudioElement.js +6 -11
  2. package/lib/PlayController/index.js +15 -80
  3. package/lib/Player/App.js +0 -24
  4. package/lib/Player/Controller.js +17 -93
  5. package/lib/Player/custom/SpatialScenePanel/index.js +42 -68
  6. package/lib/Player/hooks.js +0 -10
  7. package/lib/Player/index.js +24 -84
  8. package/lib/Player/modules/Drawer/index.js +0 -17
  9. package/lib/Player/modules/PopUp/index.js +0 -10
  10. package/lib/Player/modules/ResizeObserver/index.js +0 -8
  11. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +17 -111
  12. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -24
  13. package/lib/Player/modules/VideoAgent/index.js +0 -17
  14. package/lib/Player/modules/Wave/index.js +7 -32
  15. package/lib/Player/modules/keyframes/BgMusic/index.js +3 -22
  16. package/lib/Player/modules/keyframes/CameraMovement/index.js +3 -27
  17. package/lib/Player/modules/keyframes/InfoPanel/index.js +8 -25
  18. package/lib/Player/modules/keyframes/ModelVideo/index.js +3 -29
  19. package/lib/Player/modules/keyframes/PanoEffect/index.js +15 -43
  20. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +0 -7
  21. package/lib/Player/modules/keyframes/PanoTag/index.js +4 -20
  22. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +22 -47
  23. package/lib/Player/modules/keyframes/Prompter/index.js +10 -32
  24. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +18 -25
  25. package/lib/Player/modules/keyframes/VideoEffect/index.js +12 -47
  26. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +0 -2
  27. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +0 -1
  28. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +0 -1
  29. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +19 -60
  30. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +2 -5
  31. package/lib/fivePlugins/CameraMovementPlugin/index.js +28 -75
  32. package/lib/fivePlugins/CameraMovementPlugin/typings.js +0 -4
  33. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +11 -60
  34. package/lib/index.js +0 -1
  35. package/lib/react/index.js +7 -34
  36. package/lib/shared-utils/Audio.js +8 -49
  37. package/lib/shared-utils/AudioLike.js +5 -39
  38. package/lib/shared-utils/Preloader.js +0 -7
  39. package/lib/shared-utils/addResizeListener.js +0 -5
  40. package/lib/shared-utils/animationFrame/BetterTween.js +2 -38
  41. package/lib/shared-utils/animationFrame/index.js +2 -10
  42. package/lib/shared-utils/animationFrame/tween.js +2 -15
  43. package/lib/shared-utils/createTransMatrix.js +2 -17
  44. package/lib/shared-utils/getFileExpandedName.js +0 -1
  45. package/lib/shared-utils/getMediaInfo.js +0 -9
  46. package/lib/shared-utils/setElementDataset.js +0 -2
  47. package/lib/typings/VreoUnit.js +0 -15
  48. package/package.json +1 -2
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -9,46 +8,30 @@ exports.VreoProvider = void 0;
9
8
  exports.useVreoAction = useVreoAction;
10
9
  exports.useVreoEventCallback = useVreoEventCallback;
11
10
  exports.useVreoPausedState = useVreoPausedState;
12
-
13
11
  var _react = require("@realsee/five/react");
14
-
15
12
  var React = _interopRequireWildcard(require("react"));
16
-
17
13
  var _Player = require("../Player");
18
-
19
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
-
21
15
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
22
-
23
16
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
24
-
25
17
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
26
-
27
18
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
28
-
29
19
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
30
-
31
20
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
32
-
33
21
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
34
-
35
22
  var VreoContext = /*#__PURE__*/React.createContext(null);
36
-
37
23
  var VreoProvider = function VreoProvider(props) {
38
24
  var five = (0, _react.unsafe__useFiveInstance)();
39
-
40
25
  var _React$useState = React.useState(null),
41
- _React$useState2 = _slicedToArray(_React$useState, 2),
42
- player = _React$useState2[0],
43
- setPlayer = _React$useState2[1];
44
-
26
+ _React$useState2 = _slicedToArray(_React$useState, 2),
27
+ player = _React$useState2[0],
28
+ setPlayer = _React$useState2[1];
45
29
  var playerRef = React.useRef(null);
46
30
  React.useEffect(function () {
47
31
  playerRef.current = new _Player.Player(five, props.configs || {});
48
32
  setPlayer(playerRef.current);
49
33
  return function () {
50
34
  var _playerRef$current;
51
-
52
35
  (_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : _playerRef$current.dispose();
53
36
  };
54
37
  }, []);
@@ -57,23 +40,19 @@ var VreoProvider = function VreoProvider(props) {
57
40
  value: player
58
41
  }, props.children);
59
42
  };
60
-
61
43
  exports.VreoProvider = VreoProvider;
62
-
63
44
  function useVreoInstance() {
64
45
  var context = React.useContext(VreoContext);
65
-
66
46
  if (!context) {
67
47
  throw new Error('VreoProvider never found.');
68
48
  }
69
-
70
49
  return context;
71
50
  }
51
+
72
52
  /**
73
53
  * VreoPlayer 命令集合。
74
54
  */
75
55
 
76
-
77
56
  function useVreoAction() {
78
57
  var player = useVreoInstance();
79
58
  var load = React.useCallback(function (vreoUnit, currentTime) {
@@ -103,15 +82,12 @@ function useVreoAction() {
103
82
  dispose: dispose
104
83
  };
105
84
  }
106
-
107
85
  function useVreoEventCallback(name, callback, deps) {
108
86
  var player = useVreoInstance();
109
87
  var dependencyList = [player, name];
110
-
111
88
  if (deps !== undefined) {
112
89
  dependencyList = dependencyList.concat(deps);
113
90
  }
114
-
115
91
  React.useEffect(function () {
116
92
  // @ts-ignore
117
93
  player.on(name, callback);
@@ -121,15 +97,12 @@ function useVreoEventCallback(name, callback, deps) {
121
97
  };
122
98
  }, dependencyList);
123
99
  }
124
-
125
100
  function useVreoPausedState() {
126
101
  var player = useVreoInstance();
127
-
128
102
  var _React$useState3 = React.useState(player.paused),
129
- _React$useState4 = _slicedToArray(_React$useState3, 2),
130
- state = _React$useState4[0],
131
- setState = _React$useState4[1];
132
-
103
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
104
+ state = _React$useState4[0],
105
+ setState = _React$useState4[1];
133
106
  useVreoEventCallback('paused', function () {
134
107
  return setState(true);
135
108
  });
@@ -1,114 +1,76 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.generateBlankAudio = generateBlankAudio;
9
8
  exports.getAudio = getAudio;
10
-
11
9
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
-
13
10
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14
-
15
11
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
-
17
12
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
18
-
19
13
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
20
-
21
14
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
22
-
23
15
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
24
-
25
16
  function set(target, property, value, receiver) { if (typeof Reflect !== "undefined" && Reflect.set) { set = Reflect.set; } else { set = function set(target, property, value, receiver) { var base = _superPropBase(target, property); var desc; if (base) { desc = Object.getOwnPropertyDescriptor(base, property); if (desc.set) { desc.set.call(receiver, value); return true; } else if (!desc.writable) { return false; } } desc = Object.getOwnPropertyDescriptor(receiver, property); if (desc) { if (!desc.writable) { return false; } desc.value = value; Object.defineProperty(receiver, property, desc); } else { _defineProperty(receiver, property, value); } return true; }; } return set(target, property, value, receiver); }
26
-
27
17
  function _set(target, property, value, receiver, isStrict) { var s = set(target, property, value, receiver || target); if (!s && isStrict) { throw new Error('failed to set property'); } return value; }
28
-
29
- function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
30
-
18
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
31
19
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
32
-
33
20
  function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
34
-
35
- function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
36
-
21
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
37
22
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
38
-
39
23
  function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
40
-
41
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
42
-
43
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
44
-
24
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
25
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
45
26
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
46
-
47
27
  var blankAudioSrc = 'data:audio/mpeg;base64,//AAAAHGZ0eXBNNEEgAAAAAE00QSBpc29tbXA0MgAAAAFtZGF0AAAAAAAAABwA0AAHANAABwDQAAcAAAM+bW9vdgAAAGxtdmhkAAAAAN+jti7fo7YuAACsRAAADAAAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAdB0cmFrAAAAXHRraGQAAAAB36O2Lt+jti4AAAABAAAAAAAADAAAAAAAAAAAAAAAAAABAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAFsbWRpYQAAACBtZGhkAAAAAN+jti7fo7YuAACsRAAADABVxAAAAAAAMWhkbHIAAAAAAAAAAHNvdW4AAAAAAAAAAAAAAABDb3JlIE1lZGlhIEF1ZGlvAAAAARNtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAANdzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAAABICAgBRAFAAYAAAA+gAAAPoABYCAgAISCAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAAADAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAwAAAAEAAAAgc3RzegAAAAAAAAAAAAAAAwAAAAQAAAAEAAAABAAAABRzdGNvAAAAAAAAAAEAAAAsAAAA+nVkdGEAAADybWV0YQAAAAAAAAAiaGRscgAAAAAAAAAAbWRpcgAAAAAAAAAAAAAAAAAAAAAAxGlsc3QAAAC8LS0tLQAAABxtZWFuAAAAAGNvbS5hcHBsZS5pVHVuZXMAAAAUbmFtZQAAAABpVHVuU01QQgAAAIRkYXRhAAAAAQAAAAAgMDAwMDAwMDAgMDAwMDA4NDAgMDAwMDAzQzAgMDAwMDAwMDAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMA==';
48
28
  var audioList = [];
49
-
50
29
  function getAudio(src) {
51
30
  var audio = audioList.find(function (audio) {
52
31
  return !audio.realSrc || audio.realSrc === blankAudioSrc;
53
32
  });
54
-
55
33
  if (!audio) {
56
34
  console.warn('未找到缓存音频,已新建');
57
35
  audio = new IAudio(blankAudioSrc);
58
36
  }
59
-
60
37
  if (src) audio.src = src;
61
38
  return audio;
62
39
  }
63
-
64
40
  function generateBlankAudio(length) {
65
41
  // 判断一下已经生成几个了,防止重复生成
66
42
  var generateLength = length - audioList.length;
67
43
  if (generateLength <= 0) return;
68
-
69
44
  for (var i = 0; i < generateLength; i++) {
70
45
  audioList.push(new IAudio(blankAudioSrc));
71
46
  }
72
47
  }
73
-
74
48
  var IAudio = /*#__PURE__*/function (_Audio) {
75
49
  _inherits(IAudio, _Audio);
76
-
77
50
  var _super = _createSuper(IAudio);
78
-
79
51
  function IAudio(src) {
80
52
  var _this;
81
-
82
53
  _classCallCheck(this, IAudio);
83
-
84
54
  _this = _super.call(this, src);
85
-
86
55
  _defineProperty(_assertThisInitialized(_this), "preload", 'auto');
87
-
88
56
  _defineProperty(_assertThisInitialized(_this), "realSrc", '');
89
-
90
57
  _defineProperty(_assertThisInitialized(_this), "inited", false);
91
-
92
58
  _this.realSrc = src !== null && src !== void 0 ? src : '';
93
59
  console.log('create audio', src);
94
-
95
60
  _this.addEventListener('end', function () {
96
61
  return _this.src = '';
97
62
  });
98
-
99
- var init = _this.init.bind(_assertThisInitialized(_this));
100
-
63
+ var init = function init() {
64
+ return _this.init();
65
+ };
101
66
  document.addEventListener('click', init);
102
67
  document.addEventListener('touchstart', init);
103
-
104
68
  _this.removeDocumentEventListener = function () {
105
69
  document.removeEventListener('click', init);
106
70
  document.removeEventListener('touchstart', init);
107
71
  };
108
-
109
72
  return _this;
110
73
  }
111
-
112
74
  _createClass(IAudio, [{
113
75
  key: "src",
114
76
  get: function get() {
@@ -116,24 +78,21 @@ var IAudio = /*#__PURE__*/function (_Audio) {
116
78
  },
117
79
  set: function set(paramsSrc) {
118
80
  _set(_getPrototypeOf(IAudio.prototype), "src", paramsSrc, this, true);
119
-
120
81
  this.realSrc = paramsSrc;
121
82
  }
122
83
  }, {
123
84
  key: "init",
124
85
  value: function init() {
86
+ console.log('init');
125
87
  if (this.inited) return;
126
-
127
88
  if (this.src) {
128
89
  this.inited = true;
129
90
  this.removeDocumentEventListener();
130
91
  }
131
-
132
92
  if (this.src === blankAudioSrc) {
133
93
  this.play();
134
94
  }
135
95
  }
136
96
  }]);
137
-
138
97
  return IAudio;
139
98
  }( /*#__PURE__*/_wrapNativeSuper(Audio));
@@ -1,90 +1,60 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = exports.AudioLike = void 0;
9
-
10
8
  var _five = require("@realsee/five");
11
-
12
9
  var _animationFrame = require("./animationFrame");
13
-
14
10
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
-
16
11
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17
-
18
12
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
19
-
20
13
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
21
-
22
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23
-
14
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
24
15
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
25
-
26
16
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
27
-
28
17
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
29
-
30
18
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
31
-
32
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
33
-
19
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
34
20
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
-
36
21
  /**
37
22
  * 模拟 `<Audio>` 功能:没有音频,但执行逻辑跟 `<Audio>` 相似。
38
23
  */
39
24
  var AudioLike = /*#__PURE__*/function (_Subscribe) {
40
25
  _inherits(AudioLike, _Subscribe);
41
-
42
26
  var _super = _createSuper(AudioLike);
43
-
44
27
  function AudioLike() {
45
28
  var _this;
46
-
47
29
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
48
- duration = _ref.duration;
49
-
30
+ duration = _ref.duration;
50
31
  _classCallCheck(this, AudioLike);
51
-
52
32
  _this = _super.call(this);
53
-
54
33
  _defineProperty(_assertThisInitialized(_this), "$timestamp", null);
55
-
56
34
  _defineProperty(_assertThisInitialized(_this), "$currentTime", 0);
57
-
58
35
  _defineProperty(_assertThisInitialized(_this), "$duration", 0);
59
-
60
36
  _defineProperty(_assertThisInitialized(_this), "muted", false);
61
-
62
37
  _defineProperty(_assertThisInitialized(_this), "src", '');
63
-
64
38
  if (duration) {
65
39
  _this.$duration = duration;
66
40
  }
67
-
68
41
  return _this;
69
42
  }
70
-
71
43
  _createClass(AudioLike, [{
72
44
  key: "setAttribute",
73
- value: function setAttribute(name, value) {// nothing todo
45
+ value: function setAttribute(name, value) {
46
+ // nothing todo
74
47
  }
75
48
  }, {
76
49
  key: "play",
77
50
  value: function play() {
78
51
  var _this2 = this;
79
-
80
52
  if (this.$currentTime === this.$duration) {
81
53
  this.$currentTime = 0;
82
54
  }
83
-
84
55
  if (this.$timestamp === null) {
85
56
  this.$timestamp = performance.now();
86
57
  }
87
-
88
58
  this.stopInterval = (0, _animationFrame.requestAnimationFrameInterval)(function () {
89
59
  return _this2.requestAnimationFrameLoop();
90
60
  });
@@ -98,7 +68,6 @@ var AudioLike = /*#__PURE__*/function (_Subscribe) {
98
68
  this.emit('pause');
99
69
  this.stopInterval = undefined;
100
70
  }
101
-
102
71
  this.$timestamp = null;
103
72
  }
104
73
  }, {
@@ -109,7 +78,6 @@ var AudioLike = /*#__PURE__*/function (_Subscribe) {
109
78
  this.$currentTime += now - this.$timestamp;
110
79
  this.$timestamp = now;
111
80
  this.emit('timeupdate');
112
-
113
81
  if (this.$currentTime >= this.$duration - 10) {
114
82
  this.$currentTime = this.$duration;
115
83
  this.pause();
@@ -155,10 +123,8 @@ var AudioLike = /*#__PURE__*/function (_Subscribe) {
155
123
  this.off(evtName, callback);
156
124
  }
157
125
  }]);
158
-
159
126
  return AudioLike;
160
127
  }(_five.Subscribe);
161
-
162
128
  exports.AudioLike = AudioLike;
163
129
  var _default = AudioLike;
164
130
  exports["default"] = _default;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Preloader = void 0;
7
-
8
7
  /**
9
8
  * 预载器
10
9
  */
@@ -13,26 +12,21 @@ var Preloader = {
13
12
  var noop = function noop() {
14
13
  return null;
15
14
  };
16
-
17
15
  return new Promise(function (resolve, reject) {
18
16
  var xhr = new XMLHttpRequest();
19
-
20
17
  var clear = function clear() {
21
18
  xhr.ontimeout = noop;
22
19
  xhr.onreadystatechange = noop;
23
20
  xhr.onprogress = noop;
24
21
  xhr.onabort = noop;
25
22
  };
26
-
27
23
  xhr.ontimeout = function () {
28
24
  reject(new Error('timeout'));
29
25
  clear();
30
26
  };
31
-
32
27
  xhr.onreadystatechange = function () {
33
28
  if (xhr.readyState !== 4) return;
34
29
  if (xhr.status === 0 && !xhr.response) return;
35
-
36
30
  if (xhr.status === 200 || xhr.status === 0) {
37
31
  resolve(xhr.response);
38
32
  clear();
@@ -41,7 +35,6 @@ var Preloader = {
41
35
  clear();
42
36
  }
43
37
  };
44
-
45
38
  xhr.open('GET', url, true);
46
39
  xhr.responseType = 'blob';
47
40
  xhr.send(null);
@@ -6,12 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.addResizeListener = addResizeListener;
7
7
  exports.hasResizeListener = hasResizeListener;
8
8
  var resizeObserverCache = new Map();
9
-
10
9
  function addResizeListener(element, resizeHandler) {
11
10
  var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
12
11
  if (!element) return function () {};
13
12
  if (immediate) resizeHandler(element.clientWidth, element.clientHeight);
14
-
15
13
  if (typeof ResizeObserver !== 'undefined' && ResizeObserver) {
16
14
  var resizeObserver = new ResizeObserver(function () {
17
15
  return resizeHandler(element.clientWidth, element.clientHeight);
@@ -20,7 +18,6 @@ function addResizeListener(element, resizeHandler) {
20
18
  resizeObserverCache.set(element, resizeObserverCache.get(element) || 0 + 1);
21
19
  return function () {
22
20
  if (element) resizeObserver.unobserve(element);
23
-
24
21
  if (resizeObserverCache.get(element) === 1) {
25
22
  resizeObserverCache["delete"](element);
26
23
  }
@@ -37,14 +34,12 @@ function addResizeListener(element, resizeHandler) {
37
34
  resizeObserverCache.set(element, resizeObserverCache.get(element) || 0 + 1);
38
35
  return function () {
39
36
  element.removeChild(iframe);
40
-
41
37
  if (resizeObserverCache.get(element) === 1) {
42
38
  resizeObserverCache["delete"](element);
43
39
  }
44
40
  };
45
41
  }
46
42
  }
47
-
48
43
  function hasResizeListener(element) {
49
44
  if (!element) return false;
50
45
  return resizeObserverCache.get(element) || 0 > 0;
@@ -1,98 +1,62 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.BetterTween = void 0;
9
8
  exports.tweenProgress = tweenProgress;
10
-
11
9
  var _tween = _interopRequireDefault(require("@tweenjs/tween.js"));
12
-
13
10
  var _ = require(".");
14
-
15
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
-
17
12
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
18
-
19
13
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
20
-
21
14
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
-
23
15
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
24
-
25
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
26
-
16
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
27
17
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
28
-
29
18
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
30
-
31
19
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
32
-
33
20
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
34
-
35
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
36
-
21
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
37
22
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
38
-
39
23
  var BetterTween = /*#__PURE__*/function (_TWEEN$Tween) {
40
24
  _inherits(BetterTween, _TWEEN$Tween);
41
-
42
25
  var _super = _createSuper(BetterTween);
43
-
44
26
  function BetterTween() {
45
27
  var _this;
46
-
47
28
  _classCallCheck(this, BetterTween);
48
-
49
29
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
50
30
  args[_key] = arguments[_key];
51
31
  }
52
-
53
32
  _this = _super.call.apply(_super, [this].concat(args));
54
-
55
33
  _defineProperty(_assertThisInitialized(_this), "disposeMethods", []);
56
-
57
34
  _defineProperty(_assertThisInitialized(_this), "onDispose", function (callback) {
58
35
  _this.disposeMethods.push(callback);
59
-
60
36
  return _assertThisInitialized(_this);
61
37
  });
62
-
63
38
  _defineProperty(_assertThisInitialized(_this), "play", function () {
64
39
  _this.start();
65
-
66
40
  _this.animationFrameDisposer = (0, _.requestAnimationFrameInterval)(function () {
67
41
  return _this.update();
68
42
  });
69
43
  return _assertThisInitialized(_this);
70
44
  });
71
-
72
45
  _defineProperty(_assertThisInitialized(_this), "dispose", function () {
73
46
  var _this$animationFrameD, _this2;
74
-
75
47
  _this.stop();
76
-
77
48
  (_this$animationFrameD = (_this2 = _this).animationFrameDisposer) === null || _this$animationFrameD === void 0 ? void 0 : _this$animationFrameD.call(_this2);
78
-
79
49
  _this.disposeMethods.forEach(function (fn) {
80
50
  return fn();
81
51
  });
82
-
83
52
  _this.disposeMethods = [];
84
-
85
53
  _tween["default"].remove(_assertThisInitialized(_this));
86
54
  });
87
-
88
55
  return _this;
89
56
  }
90
-
91
57
  return _createClass(BetterTween);
92
58
  }(_tween["default"].Tween);
93
-
94
59
  exports.BetterTween = BetterTween;
95
-
96
60
  function tweenProgress(duration) {
97
61
  var easing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _tween["default"].Easing.Linear.None;
98
62
  var tween = new BetterTween({
@@ -7,37 +7,31 @@ exports["default"] = void 0;
7
7
  exports.getFrameTime = getFrameTime;
8
8
  exports.nextFrame = nextFrame;
9
9
  exports.requestAnimationFrameInterval = requestAnimationFrameInterval;
10
-
11
10
  var _requestAnimationFrame = window.requestAnimationFrame || function (fn) {
12
11
  return setTimeout(fn, 16);
13
12
  };
14
-
15
13
  var _cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
16
-
17
14
  var _default = _requestAnimationFrame;
18
15
  exports["default"] = _default;
19
-
20
16
  function nextFrame(fn) {
21
17
  var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
22
18
  if (delay <= 0) _requestAnimationFrame(fn);else _requestAnimationFrame(function () {
23
19
  return nextFrame(fn, delay - 1);
24
20
  });
25
21
  }
22
+
26
23
  /**
27
24
  * 在每个 AnimationFrame 中调用传入的函数
28
25
  * @param callback 每次 AnimationFrame 中调用的函数
29
26
  * @param frame 每秒运行多少次
30
27
  * @returns 返回一个函数,调用可以停止 AnimationFrameLoop
31
28
  */
32
-
33
-
34
29
  function requestAnimationFrameInterval(callback) {
35
30
  var frame = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 60;
36
31
  var index = -1;
37
32
  var oldTime = 0;
38
33
  var startTime = -1;
39
34
  var minDeltaTime = 1000 / frame;
40
-
41
35
  function loop(time) {
42
36
  startTime === -1 && (startTime = time);
43
37
  index = _requestAnimationFrame(loop);
@@ -46,18 +40,16 @@ function requestAnimationFrameInterval(callback) {
46
40
  oldTime = time;
47
41
  callback && callback(time - startTime);
48
42
  }
49
-
50
43
  index = _requestAnimationFrame(loop);
51
44
  return function stop() {
52
45
  _cancelAnimationFrame(index);
53
46
  };
54
47
  }
48
+
55
49
  /**
56
50
  * 获取两个 AnimationFrame 间隔的时间
57
51
  * @returns 返回一个 Promise,resolve 的结果是两个 AnimationFrame 间隔的时间
58
52
  */
59
-
60
-
61
53
  function getFrameTime() {
62
54
  var start = Date.now();
63
55
  return new Promise(function (resolve) {