@qxs-bns/utils 0.0.7 → 0.0.8

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.8",
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 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,65 +1,67 @@
1
- var s = (d, o, l) => new Promise((e, t) => {
2
- var i = (a) => {
1
+ var p = (o, a, e) => new Promise((d, t) => {
2
+ var i = (n) => {
3
3
  try {
4
- r(l.next(a));
4
+ r(e.next(n));
5
5
  } catch (c) {
6
6
  t(c);
7
7
  }
8
- }, p = (a) => {
8
+ }, s = (n) => {
9
9
  try {
10
- r(l.throw(a));
10
+ r(e.throw(n));
11
11
  } catch (c) {
12
12
  t(c);
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
+ }, r = (n) => n.done ? d(n.value) : Promise.resolve(n.value).then(i, s);
15
+ r((e = e.apply(o, a)).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) {
20
- return s(this, null, function* () {
21
- return new Promise((o, l) => {
17
+ function y(o) {
18
+ return p(this, null, function* () {
19
+ return new Promise((a, e) => {
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 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);
27
29
  }
28
30
  });
29
31
  });
30
32
  }
31
- function A() {
32
- return s(this, null, function* () {
33
+ function f() {
34
+ return p(this, null, function* () {
33
35
  try {
34
- if (yield y(h), yield y(f), !window.AliyunUpload)
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)
35
37
  throw new Error("SDK 加载成功但未找到 AliyunUpload 对象");
36
- } catch (d) {
37
- throw d;
38
+ } catch (o) {
39
+ throw o;
38
40
  }
39
41
  });
40
42
  }
41
- function P(d) {
42
- return s(this, null, function* () {
43
+ function A(o) {
44
+ return p(this, null, function* () {
43
45
  if (typeof window == "undefined")
44
46
  throw new TypeError("VideoUploader 只能在浏览器环境中使用");
45
- window.AliyunUpload || (yield A());
46
- const o = new window.AliyunUpload.Vod({
47
- onUploadFailed: d.onUploadFailed,
48
- onUploadSucceed: d.onUploadSucceed,
49
- onUploadProgress: d.onUploadProgress,
50
- onUploadTokenExpired: d.onUploadTokenExpired || (() => {
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 || (() => {
51
53
  }),
52
- onUploadstarted: (e) => s(this, null, function* () {
54
+ onUploadstarted: (d) => p(this, null, function* () {
53
55
  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
+ 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);
56
58
  })
57
59
  });
58
60
  return {
59
- uploader: o,
60
- upload: (e) => s(this, null, function* () {
61
+ uploader: a,
62
+ upload: (d) => p(this, null, function* () {
61
63
  return new Promise((t, i) => {
62
- const p = JSON.stringify({
64
+ const s = JSON.stringify({
63
65
  Vod: {
64
66
  UserData: {
65
67
  IsShowWaterMark: "false",
@@ -67,16 +69,16 @@ function P(d) {
67
69
  }
68
70
  }
69
71
  });
70
- o.addFile(e, null, null, null, p), o.startUpload();
71
- const r = (n) => {
72
- t({ videoId: n.videoId });
73
- }, a = (n, w, u) => {
72
+ a.addFile(d, null, null, null, s), a.startUpload();
73
+ const r = (l) => {
74
+ t({ videoId: l.videoId });
75
+ }, n = (l, U, u) => {
74
76
  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);
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);
80
82
  };
81
83
  });
82
84
  })
@@ -84,5 +86,5 @@ function P(d) {
84
86
  });
85
87
  }
86
88
  export {
87
- P as createVideoUploader
89
+ A as createVideoUploader
88
90
  };
package/types/index.d.ts CHANGED
@@ -130,16 +130,10 @@ export declare function watermark(): {
130
130
 
131
131
  export { }
132
132
 
133
-
134
- declare module '*.js?raw' {
135
- const content: string;
136
- }
137
-
138
-
139
133
  declare global {
140
134
  interface Window {
141
135
  AliyunUpload: any;
142
- OSS: typeof OSS;
136
+ OSS: any;
143
137
  }
144
138
  }
145
139