@qxs-bns/utils 0.0.7 → 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.7",
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 s=(e,d,l)=>new Promise((o,t)=>{var i=a=>{try{n(l.next(a))}catch(c){t(c)}},u=a=>{try{n(l.throw(a))}catch(c){t(c)}},n=a=>a.done?o(a.value):Promise.resolve(a.value).then(i,u);n((l=l.apply(e,d)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../public/aliyun-upload-sdk-1.5.6/aliyun-upload-sdk-1.5.6.min.cjs"),f=require("../public/aliyun-upload-sdk-1.5.6/lib/aliyun-oss-sdk-6.17.1.min.cjs");function y(e){return s(this,null,function*(){return new Promise((d,l)=>{try{const o=document.createElement("script");o.text=e,document.head.appendChild(o),d()}catch(o){l(o)}})})}function h(){return s(this,null,function*(){try{if(yield y(f),yield y(S),!window.AliyunUpload)throw new Error("SDK 加载成功但未找到 AliyunUpload 对象")}catch(e){throw e}})}function A(e){return s(this,null,function*(){if(typeof window=="undefined")throw new TypeError("VideoUploader 只能在浏览器环境中使用");window.AliyunUpload||(yield h());const d=new window.AliyunUpload.Vod({onUploadFailed:e.onUploadFailed,onUploadSucceed:e.onUploadSucceed,onUploadProgress:e.onUploadProgress,onUploadTokenExpired:e.onUploadTokenExpired||(()=>{}),onUploadstarted:o=>s(this,null,function*(){var n;const{uploadAuth:t,uploadAddress:i,videoId:u}=(yield(n=e.onUploadstarted)==null?void 0:n.call(e,o))||{};t&&i&&u&&d.setUploadAuthAndAddress(o,t,i,u)})});return{uploader:d,upload:o=>s(this,null,function*(){return new Promise((t,i)=>{const u=JSON.stringify({Vod:{UserData:{IsShowWaterMark:"false",Priority:"7"}}});d.addFile(o,null,null,null,u),d.startUpload();const n=r=>{t({videoId:r.videoId})},a=(r,w,p)=>{i(new Error(p||"上传失败"))},c=d.onUploadSucceed,U=d.onUploadFailed;d.onUploadSucceed=r=>{n(r),c==null||c(r)},d.onUploadFailed=(r,w,p)=>{a(r,w,p),U==null||U(r,w,p)}})})}})}exports.createVideoUploader=A;
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,65 +1,77 @@
1
- var s = (d, o, l) => new Promise((e, t) => {
2
- var i = (a) => {
1
+ var s = (r, l, a) => new Promise((o, c) => {
2
+ var e = (d) => {
3
3
  try {
4
- r(l.next(a));
5
- } catch (c) {
6
- t(c);
4
+ n(a.next(d));
5
+ } catch (i) {
6
+ c(i);
7
7
  }
8
- }, p = (a) => {
8
+ }, t = (d) => {
9
9
  try {
10
- r(l.throw(a));
11
- } catch (c) {
12
- t(c);
10
+ n(a.throw(d));
11
+ } catch (i) {
12
+ c(i);
13
13
  }
14
- }, r = (a) => a.done ? e(a.value) : Promise.resolve(a.value).then(i, p);
15
- r((l = l.apply(d, o)).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
- import f from "../public/aliyun-upload-sdk-1.5.6/aliyun-upload-sdk-1.5.6.min.js";
18
- import h from "../public/aliyun-upload-sdk-1.5.6/lib/aliyun-oss-sdk-6.17.1.min.js";
19
- function y(d) {
17
+ function p(r) {
20
18
  return s(this, null, function* () {
21
- return new Promise((o, l) => {
19
+ return new Promise((l, a) => {
22
20
  try {
23
- const e = document.createElement("script");
24
- e.text = d, document.head.appendChild(e), o();
25
- } catch (e) {
26
- l(e);
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);
27
29
  }
28
30
  });
29
31
  });
30
32
  }
31
- function A() {
33
+ function u() {
32
34
  return s(this, null, function* () {
33
35
  try {
34
- if (yield y(h), yield y(f), !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)
35
37
  throw new Error("SDK 加载成功但未找到 AliyunUpload 对象");
36
- } catch (d) {
37
- throw d;
38
+ } catch (r) {
39
+ throw r;
38
40
  }
39
41
  });
40
42
  }
41
- function P(d) {
43
+ function y(r) {
42
44
  return s(this, null, function* () {
43
45
  if (typeof window == "undefined")
44
46
  throw new TypeError("VideoUploader 只能在浏览器环境中使用");
45
- window.AliyunUpload || (yield A());
47
+ window.AliyunUpload || (yield u());
48
+ let l = null, a = null;
46
49
  const o = new window.AliyunUpload.Vod({
47
- onUploadFailed: d.onUploadFailed,
48
- onUploadSucceed: d.onUploadSucceed,
49
- onUploadProgress: d.onUploadProgress,
50
- onUploadTokenExpired: d.onUploadTokenExpired || (() => {
50
+ onUploadProgress: r.onUploadProgress,
51
+ onUploadTokenExpired: r.onUploadTokenExpired || (() => {
51
52
  }),
52
53
  onUploadstarted: (e) => s(this, null, function* () {
53
- var r;
54
- const { uploadAuth: t, uploadAddress: i, videoId: p } = (yield (r = d.onUploadstarted) == null ? void 0 : r.call(d, e)) || {};
55
- t && i && p && o.setUploadAuthAndAddress(e, t, i, p);
56
- })
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
+ }
57
68
  });
58
69
  return {
59
70
  uploader: o,
60
71
  upload: (e) => s(this, null, function* () {
61
- return new Promise((t, i) => {
62
- const p = JSON.stringify({
72
+ return new Promise((t, n) => {
73
+ l = t, a = n;
74
+ const d = JSON.stringify({
63
75
  Vod: {
64
76
  UserData: {
65
77
  IsShowWaterMark: "false",
@@ -67,22 +79,12 @@ function P(d) {
67
79
  }
68
80
  }
69
81
  });
70
- o.addFile(e, null, null, null, p), o.startUpload();
71
- const r = (n) => {
72
- t({ videoId: n.videoId });
73
- }, a = (n, w, u) => {
74
- i(new Error(u || "上传失败"));
75
- }, c = o.onUploadSucceed, U = o.onUploadFailed;
76
- o.onUploadSucceed = (n) => {
77
- r(n), c == null || c(n);
78
- }, o.onUploadFailed = (n, w, u) => {
79
- a(n, w, u), U == null || U(n, w, u);
80
- };
82
+ o.addFile(e, null, null, null, d), o.startUpload();
81
83
  });
82
84
  })
83
85
  };
84
86
  });
85
87
  }
86
88
  export {
87
- P as createVideoUploader
89
+ y as createVideoUploader
88
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(): {
@@ -130,16 +131,10 @@ export declare function watermark(): {
130
131
 
131
132
  export { }
132
133
 
133
-
134
- declare module '*.js?raw' {
135
- const content: string;
136
- }
137
-
138
-
139
134
  declare global {
140
135
  interface Window {
141
136
  AliyunUpload: any;
142
- OSS: typeof OSS;
137
+ OSS: any;
143
138
  }
144
139
  }
145
140