@volcengine/veplayer-plugin 2.4.1-rc.0 → 2.5.0-rc.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.
Files changed (43) hide show
  1. package/esm/index.d.ts +1 -0
  2. package/esm/index.development.css +7 -0
  3. package/esm/index.development.js +31562 -23809
  4. package/esm/index.production.css +1 -1
  5. package/esm/index.production.js +13 -4
  6. package/esm/veplayer.plugin.abr.development.js +59 -3
  7. package/esm/veplayer.plugin.abr.production.js +1 -1
  8. package/esm/veplayer.plugin.ad.development.css +7 -0
  9. package/esm/veplayer.plugin.ad.development.js +9042 -0
  10. package/esm/veplayer.plugin.ad.production.css +1 -0
  11. package/esm/veplayer.plugin.ad.production.js +4 -0
  12. package/esm/veplayer.plugin.drm.development.js +59 -3
  13. package/esm/veplayer.plugin.drm.production.js +1 -1
  14. package/esm/veplayer.plugin.flv.development.js +63 -22
  15. package/esm/veplayer.plugin.flv.production.js +1 -1
  16. package/esm/veplayer.plugin.hls.development.js +398 -55
  17. package/esm/veplayer.plugin.hls.production.js +1 -1
  18. package/esm/veplayer.plugin.mp4.development.js +61 -5
  19. package/esm/veplayer.plugin.mp4.production.js +1 -1
  20. package/esm/veplayer.plugin.rtm.development.js +63 -13
  21. package/esm/veplayer.plugin.rtm.production.js +1 -1
  22. package/esm/veplayer.plugin.shaka.development.js +60 -4
  23. package/esm/veplayer.plugin.shaka.production.js +1 -1
  24. package/package.json +1 -1
  25. package/umd/index.d.ts +1 -0
  26. package/umd/veplayer.plugin.abr.development.js +59 -3
  27. package/umd/veplayer.plugin.abr.production.js +1 -1
  28. package/umd/veplayer.plugin.ad.development.css +7 -0
  29. package/umd/veplayer.plugin.ad.development.js +9045 -0
  30. package/umd/veplayer.plugin.ad.production.css +1 -0
  31. package/umd/veplayer.plugin.ad.production.js +1 -0
  32. package/umd/veplayer.plugin.drm.development.js +59 -3
  33. package/umd/veplayer.plugin.drm.production.js +1 -1
  34. package/umd/veplayer.plugin.flv.development.js +63 -22
  35. package/umd/veplayer.plugin.flv.production.js +1 -1
  36. package/umd/veplayer.plugin.hls.development.js +398 -55
  37. package/umd/veplayer.plugin.hls.production.js +1 -1
  38. package/umd/veplayer.plugin.mp4.development.js +61 -5
  39. package/umd/veplayer.plugin.mp4.production.js +1 -1
  40. package/umd/veplayer.plugin.rtm.development.js +63 -13
  41. package/umd/veplayer.plugin.rtm.production.js +1 -1
  42. package/umd/veplayer.plugin.shaka.development.js +60 -4
  43. package/umd/veplayer.plugin.shaka.production.js +1 -1
@@ -1016,8 +1016,7 @@ function hook(hookName, handler) {
1016
1016
  }
1017
1017
  if (this.__hooks && this.__hooks[hookName]) {
1018
1018
  try {
1019
- var _this$__hooks$hookNam;
1020
- var preRet = (_this$__hooks$hookNam = this.__hooks[hookName]).call.apply(_this$__hooks$hookNam, [this, this].concat(Array.prototype.slice.call(arguments)));
1019
+ var preRet = runHooks(this, hookName, handler);
1021
1020
  if (preRet) {
1022
1021
  if (preRet.then) {
1023
1022
  preRet.then(function(isContinue) {
@@ -1042,6 +1041,19 @@ function hook(hookName, handler) {
1042
1041
  }
1043
1042
  }.bind(this);
1044
1043
  }
1044
+ function findHookIndex(hookName, handler) {
1045
+ var __hooks = this.__hooks;
1046
+ if (!__hooks || !Array.isArray(__hooks[hookName])) {
1047
+ return -1;
1048
+ }
1049
+ var hookHandlers = __hooks[hookName];
1050
+ for (var i = 0; i < hookHandlers.length; i++) {
1051
+ if (hookHandlers[i] === handler) {
1052
+ return i;
1053
+ }
1054
+ }
1055
+ return -1;
1056
+ }
1045
1057
  function useHooks(hookName, handler) {
1046
1058
  var __hooks = this.__hooks;
1047
1059
  if (!__hooks) {
@@ -1051,7 +1063,12 @@ function useHooks(hookName, handler) {
1051
1063
  console.warn("has no supported hook which name [".concat(hookName, "]"));
1052
1064
  return false;
1053
1065
  }
1054
- __hooks && (__hooks[hookName] = handler);
1066
+ if (!Array.isArray(__hooks[hookName])) {
1067
+ __hooks[hookName] = [];
1068
+ }
1069
+ if (findHookIndex.call(this, hookName, handler) === -1) {
1070
+ __hooks[hookName].push(handler);
1071
+ }
1055
1072
  return true;
1056
1073
  }
1057
1074
  function removeHooks(hookName, handler) {
@@ -1059,6 +1076,13 @@ function removeHooks(hookName, handler) {
1059
1076
  if (!__hooks) {
1060
1077
  return;
1061
1078
  }
1079
+ if (Array.isArray(__hooks[hookName])) {
1080
+ var hooks = __hooks[hookName];
1081
+ var index = findHookIndex.call(this, hookName, handler);
1082
+ if (index !== -1) {
1083
+ hooks.splice(index, 1);
1084
+ }
1085
+ }
1062
1086
  delete __hooks[hookName];
1063
1087
  }
1064
1088
  function hooksDescriptor(instance) {
@@ -1080,6 +1104,38 @@ function hooksDescriptor(instance) {
1080
1104
  function delHooksDescriptor(instance) {
1081
1105
  instance.__hooks = null;
1082
1106
  }
1107
+ function runHooks(obj, hookName, handler) {
1108
+ for (var _len5 = arguments.length, args = new Array(_len5 > 3 ? _len5 - 3 : 0), _key5 = 3; _key5 < _len5; _key5++) {
1109
+ args[_key5 - 3] = arguments[_key5];
1110
+ }
1111
+ if (obj.__hooks && Array.isArray(obj.__hooks[hookName])) {
1112
+ var hooks = obj.__hooks[hookName];
1113
+ var index = -1;
1114
+ var runHooksRecursive = function runHooksRecursive2(obj2, hookName2, handler2) {
1115
+ for (var _len6 = arguments.length, args2 = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) {
1116
+ args2[_key6 - 3] = arguments[_key6];
1117
+ }
1118
+ index++;
1119
+ if (hooks.length === 0 || index === hooks.length) {
1120
+ return handler2.call.apply(handler2, [obj2, obj2].concat(args2));
1121
+ }
1122
+ var hook2 = hooks[index];
1123
+ var ret = hook2.call.apply(hook2, [obj2, obj2].concat(args2));
1124
+ if (ret && ret.then) {
1125
+ return ret.then(function(data) {
1126
+ return data === false ? null : runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
1127
+ }).catch(function(e) {
1128
+ console.warn("[runHooks]".concat(hookName2, " reject"), e.message);
1129
+ });
1130
+ } else if (ret !== false) {
1131
+ return runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
1132
+ }
1133
+ };
1134
+ return runHooksRecursive.apply(void 0, [obj, hookName, handler].concat(args));
1135
+ } else {
1136
+ return handler.call.apply(handler, [obj, obj].concat(args));
1137
+ }
1138
+ }
1083
1139
  function showErrorMsg(pluginName, msg) {
1084
1140
  XG_DEBUG.logError("[".concat(pluginName, "] event or callback cant be undefined or null when call ").concat(msg));
1085
1141
  }