@qxs-bns/utils 0.0.8 → 0.0.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qxs-bns/utils",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "main": "./index.cjs",
5
5
  "module": "./index.js",
6
6
  "types": "./types/index.d.ts",
@@ -1 +1 @@
1
- "use strict";var u=(o,a,n)=>new Promise((d,t)=>{var i=e=>{try{r(n.next(e))}catch(c){t(c)}},s=e=>{try{r(n.throw(e))}catch(c){t(c)}},r=e=>e.done?d(e.value):Promise.resolve(e.value).then(i,s);r((n=n.apply(o,a)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(o){return u(this,null,function*(){return new Promise((a,n)=>{try{const d=document.createElement("script");d.src=o,d.onload=()=>{a()},d.onerror=()=>{n(new Error(`Failed to load script from ${o}`))},document.head.appendChild(d)}catch(d){n(d)}})})}function f(){return u(this,null,function*(){try{if(yield y("https://gosspublic.alicdn.com/aliyun-oss-sdk.min.js"),yield y("https://cdnfile.yaomaitong.cn/cdn/js/aliyun-upload-sdk1.3.1.min.js"),!window.AliyunUpload)throw new Error("SDK 加载成功但未找到 AliyunUpload 对象")}catch(o){throw o}})}function h(o){return u(this,null,function*(){if(typeof window=="undefined")throw new TypeError("VideoUploader 只能在浏览器环境中使用");window.AliyunUpload||(yield f());const a=new window.AliyunUpload.Vod({onUploadFailed:o.onUploadFailed,onUploadSucceed:o.onUploadSucceed,onUploadProgress:o.onUploadProgress,onUploadTokenExpired:o.onUploadTokenExpired||(()=>{}),onUploadstarted:d=>u(this,null,function*(){var r;const{uploadAuth:t,uploadAddress:i,videoId:s}=(yield(r=o.onUploadstarted)==null?void 0:r.call(o,d))||{};t&&i&&s&&a.setUploadAuthAndAddress(d,t,i,s)})});return{uploader:a,upload:d=>u(this,null,function*(){return new Promise((t,i)=>{const s=JSON.stringify({Vod:{UserData:{IsShowWaterMark:"false",Priority:"7"}}});a.addFile(d,null,null,null,s),a.startUpload();const r=l=>{t({videoId:l.videoId})},e=(l,w,p)=>{i(new Error(p||"上传失败"))},c=a.onUploadSucceed,U=a.onUploadFailed;a.onUploadSucceed=l=>{r(l),c==null||c(l)},a.onUploadFailed=(l,w,p)=>{e(l,w,p),U==null||U(l,w,p)}})})}})}exports.createVideoUploader=h;
1
+ "use strict";var s=(r,l,a)=>new Promise((o,c)=>{var e=n=>{try{d(a.next(n))}catch(i){c(i)}},t=n=>{try{d(a.throw(n))}catch(i){c(i)}},d=n=>n.done?o(n.value):Promise.resolve(n.value).then(e,t);d((a=a.apply(r,l)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(r){return s(this,null,function*(){return new Promise((l,a)=>{try{const o=document.createElement("script");o.src=r,o.onload=()=>{l()},o.onerror=()=>{a(new Error(`Failed to load script from ${r}`))},document.head.appendChild(o)}catch(o){a(o)}})})}function p(){return s(this,null,function*(){try{if(yield u("https://gosspublic.alicdn.com/aliyun-oss-sdk.min.js"),yield u("https://cdnfile.yaomaitong.cn/cdn/js/aliyun-upload-sdk1.3.1.min.js"),!window.AliyunUpload)throw new Error("SDK 加载成功但未找到 AliyunUpload 对象")}catch(r){throw r}})}function w(r){return s(this,null,function*(){if(typeof window=="undefined")throw new TypeError("VideoUploader 只能在浏览器环境中使用");window.AliyunUpload||(yield p());let l=null,a=null;const o=new window.AliyunUpload.Vod({onUploadProgress:r.onUploadProgress,onUploadTokenExpired:r.onUploadTokenExpired||(()=>{}),onUploadstarted:e=>s(this,null,function*(){var t;try{const{uploadAuth:d,uploadAddress:n,videoId:i}=(yield(t=r.onUploadstarted)==null?void 0:t.call(r,e))||{};d&&n&&i&&o.setUploadAuthAndAddress(e,d,n,i)}catch(d){throw d}}),onUploadSucceed:e=>{l==null||l(e)},onUploadFailed:(e,t,d)=>{a==null||a(new Error(`${d} ${t}`))}});return{uploader:o,upload:e=>s(this,null,function*(){return new Promise((t,d)=>{l=t,a=d;const n=JSON.stringify({Vod:{UserData:{IsShowWaterMark:"false",Priority:"7"}}});o.addFile(e,null,null,null,n),o.startUpload()})})}})}exports.createVideoUploader=w;
@@ -1,67 +1,77 @@
1
- var p = (o, a, e) => new Promise((d, t) => {
2
- var i = (n) => {
1
+ var s = (r, l, a) => new Promise((o, c) => {
2
+ var e = (d) => {
3
3
  try {
4
- r(e.next(n));
5
- } catch (c) {
6
- t(c);
4
+ n(a.next(d));
5
+ } catch (i) {
6
+ c(i);
7
7
  }
8
- }, s = (n) => {
8
+ }, t = (d) => {
9
9
  try {
10
- r(e.throw(n));
11
- } catch (c) {
12
- t(c);
10
+ n(a.throw(d));
11
+ } catch (i) {
12
+ c(i);
13
13
  }
14
- }, r = (n) => n.done ? d(n.value) : Promise.resolve(n.value).then(i, s);
15
- r((e = e.apply(o, a)).next());
14
+ }, n = (d) => d.done ? o(d.value) : Promise.resolve(d.value).then(e, t);
15
+ n((a = a.apply(r, l)).next());
16
16
  });
17
- function y(o) {
18
- return p(this, null, function* () {
19
- return new Promise((a, e) => {
17
+ function p(r) {
18
+ return s(this, null, function* () {
19
+ return new Promise((l, a) => {
20
20
  try {
21
- const d = document.createElement("script");
22
- d.src = o, d.onload = () => {
23
- a();
24
- }, d.onerror = () => {
25
- e(new Error(`Failed to load script from ${o}`));
26
- }, document.head.appendChild(d);
27
- } catch (d) {
28
- e(d);
21
+ const o = document.createElement("script");
22
+ o.src = r, o.onload = () => {
23
+ l();
24
+ }, o.onerror = () => {
25
+ a(new Error(`Failed to load script from ${r}`));
26
+ }, document.head.appendChild(o);
27
+ } catch (o) {
28
+ a(o);
29
29
  }
30
30
  });
31
31
  });
32
32
  }
33
- function f() {
34
- return p(this, null, function* () {
33
+ function u() {
34
+ return s(this, null, function* () {
35
35
  try {
36
- if (yield y("https://gosspublic.alicdn.com/aliyun-oss-sdk.min.js"), yield y("https://cdnfile.yaomaitong.cn/cdn/js/aliyun-upload-sdk1.3.1.min.js"), !window.AliyunUpload)
36
+ if (yield p("https://gosspublic.alicdn.com/aliyun-oss-sdk.min.js"), yield p("https://cdnfile.yaomaitong.cn/cdn/js/aliyun-upload-sdk1.3.1.min.js"), !window.AliyunUpload)
37
37
  throw new Error("SDK 加载成功但未找到 AliyunUpload 对象");
38
- } catch (o) {
39
- throw o;
38
+ } catch (r) {
39
+ throw r;
40
40
  }
41
41
  });
42
42
  }
43
- function A(o) {
44
- return p(this, null, function* () {
43
+ function y(r) {
44
+ return s(this, null, function* () {
45
45
  if (typeof window == "undefined")
46
46
  throw new TypeError("VideoUploader 只能在浏览器环境中使用");
47
- window.AliyunUpload || (yield f());
48
- const a = new window.AliyunUpload.Vod({
49
- onUploadFailed: o.onUploadFailed,
50
- onUploadSucceed: o.onUploadSucceed,
51
- onUploadProgress: o.onUploadProgress,
52
- onUploadTokenExpired: o.onUploadTokenExpired || (() => {
47
+ window.AliyunUpload || (yield u());
48
+ let l = null, a = null;
49
+ const o = new window.AliyunUpload.Vod({
50
+ onUploadProgress: r.onUploadProgress,
51
+ onUploadTokenExpired: r.onUploadTokenExpired || (() => {
53
52
  }),
54
- onUploadstarted: (d) => p(this, null, function* () {
55
- var r;
56
- const { uploadAuth: t, uploadAddress: i, videoId: s } = (yield (r = o.onUploadstarted) == null ? void 0 : r.call(o, d)) || {};
57
- t && i && s && a.setUploadAuthAndAddress(d, t, i, s);
58
- })
53
+ onUploadstarted: (e) => s(this, null, function* () {
54
+ var t;
55
+ try {
56
+ const { uploadAuth: n, uploadAddress: d, videoId: i } = (yield (t = r.onUploadstarted) == null ? void 0 : t.call(r, e)) || {};
57
+ n && d && i && o.setUploadAuthAndAddress(e, n, d, i);
58
+ } catch (n) {
59
+ throw n;
60
+ }
61
+ }),
62
+ onUploadSucceed: (e) => {
63
+ l == null || l(e);
64
+ },
65
+ onUploadFailed: (e, t, n) => {
66
+ a == null || a(new Error(`${n} ${t}`));
67
+ }
59
68
  });
60
69
  return {
61
- uploader: a,
62
- upload: (d) => p(this, null, function* () {
63
- return new Promise((t, i) => {
64
- const s = JSON.stringify({
70
+ uploader: o,
71
+ upload: (e) => s(this, null, function* () {
72
+ return new Promise((t, n) => {
73
+ l = t, a = n;
74
+ const d = JSON.stringify({
65
75
  Vod: {
66
76
  UserData: {
67
77
  IsShowWaterMark: "false",
@@ -69,22 +79,12 @@ function A(o) {
69
79
  }
70
80
  }
71
81
  });
72
- a.addFile(d, null, null, null, s), a.startUpload();
73
- const r = (l) => {
74
- t({ videoId: l.videoId });
75
- }, n = (l, U, u) => {
76
- i(new Error(u || "上传失败"));
77
- }, c = a.onUploadSucceed, w = a.onUploadFailed;
78
- a.onUploadSucceed = (l) => {
79
- r(l), c == null || c(l);
80
- }, a.onUploadFailed = (l, U, u) => {
81
- n(l, U, u), w == null || w(l, U, u);
82
- };
82
+ o.addFile(e, null, null, null, d), o.startUpload();
83
83
  });
84
84
  })
85
85
  };
86
86
  });
87
87
  }
88
88
  export {
89
- A as createVideoUploader
89
+ y as createVideoUploader
90
90
  };
package/types/index.d.ts CHANGED
@@ -121,6 +121,7 @@ declare interface VideoUploadOptions {
121
121
 
122
122
  declare interface VideoUploadResult {
123
123
  videoId: string;
124
+ uploadInfo: any;
124
125
  }
125
126
 
126
127
  export declare function watermark(): {