@qxs-bns/utils 0.0.4 → 0.0.6
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/index.cjs +1 -1
- package/index.js +5 -5
- package/package.json +41 -1
- package/src/file-operations.cjs +1 -1
- package/src/file-operations.js +77 -69
- package/types/index.d.ts +7 -7
- package/_virtual/_commonjs-dynamic-modules.cjs +0 -1
- package/_virtual/_commonjs-dynamic-modules.js +0 -6
- package/_virtual/_commonjsHelpers.cjs +0 -1
- package/_virtual/_commonjsHelpers.js +0 -6
- package/vendor/ali-oss/dist/aliyun-oss-sdk.js.cjs +0 -83
- package/vendor/ali-oss/dist/aliyun-oss-sdk.js.js +0 -20175
- package/vendor/ali-oss/dist/aliyun-oss-sdk.js?commonjs-module.cjs +0 -1
- package/vendor/ali-oss/dist/aliyun-oss-sdk.js?commonjs-module.js +0 -4
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./src/device.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./src/device.cjs"),t=require("./src/file-operations.cjs"),o=require("./src/media.cjs"),i=require("./src/storage.cjs"),e=require("./src/types.cjs"),s=require("./src/watermark.cjs"),a=require("vue");exports.isMobile=r.isMobile;exports.createVideoUploader=t.createVideoUploader;exports.isImageByMimeType=o.isImageByMimeType;exports.initStorage=i.initStorage;exports.useStorage=i.useStorage;exports.isBoolean=e.isBoolean;exports.isElement=e.isElement;exports.isNumber=e.isNumber;exports.isUndefined=e.isUndefined;exports.isWindow=e.isWindow;exports.watermark=s.watermark;Object.defineProperty(exports,"isVNode",{enumerable:!0,get:()=>a.isVNode});
|
package/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { isMobile as r } from "./src/device.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createVideoUploader as t } from "./src/file-operations.js";
|
|
3
3
|
import { isImageByMimeType as p } from "./src/media.js";
|
|
4
|
-
import { initStorage as
|
|
4
|
+
import { initStorage as a, useStorage as f } from "./src/storage.js";
|
|
5
5
|
import { isBoolean as d, isElement as n, isNumber as l, isUndefined as g, isWindow as b } from "./src/types.js";
|
|
6
6
|
import { watermark as w } from "./src/watermark.js";
|
|
7
7
|
import { isVNode as B } from "vue";
|
|
8
8
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
t as createVideoUploader,
|
|
10
|
+
a as initStorage,
|
|
11
11
|
d as isBoolean,
|
|
12
12
|
n as isElement,
|
|
13
13
|
p as isImageByMimeType,
|
|
@@ -16,6 +16,6 @@ export {
|
|
|
16
16
|
g as isUndefined,
|
|
17
17
|
B as isVNode,
|
|
18
18
|
b as isWindow,
|
|
19
|
-
|
|
19
|
+
f as useStorage,
|
|
20
20
|
w as watermark
|
|
21
21
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qxs-bns/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"main": "./index.cjs",
|
|
5
5
|
"module": "./index.js",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.js",
|
|
9
|
+
"index.cjs",
|
|
10
|
+
"src",
|
|
11
|
+
"types",
|
|
12
|
+
"lib"
|
|
13
|
+
],
|
|
7
14
|
"exports": {
|
|
8
15
|
".": {
|
|
9
16
|
"types": "./types/index.d.ts",
|
|
10
17
|
"import": "./index.js",
|
|
11
18
|
"require": "./index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./src/file-operations": {
|
|
21
|
+
"types": "./types/index.d.ts",
|
|
22
|
+
"import": "./src/file-operations.js",
|
|
23
|
+
"require": "./src/file-operations.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./src/media": {
|
|
26
|
+
"types": "./types/index.d.ts",
|
|
27
|
+
"import": "./src/media.js",
|
|
28
|
+
"require": "./src/media.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./src/device": {
|
|
31
|
+
"types": "./types/index.d.ts",
|
|
32
|
+
"import": "./src/device.js",
|
|
33
|
+
"require": "./src/device.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./src/storage": {
|
|
36
|
+
"types": "./types/index.d.ts",
|
|
37
|
+
"import": "./src/storage.js",
|
|
38
|
+
"require": "./src/storage.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./src/type": {
|
|
41
|
+
"types": "./types/index.d.ts",
|
|
42
|
+
"import": "./src/type.js",
|
|
43
|
+
"require": "./src/type.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./src/watermark": {
|
|
46
|
+
"types": "./types/index.d.ts",
|
|
47
|
+
"import": "./src/watermark.js",
|
|
48
|
+
"require": "./src/watermark.cjs"
|
|
12
49
|
}
|
|
13
50
|
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"ali-oss": "^6.22.0"
|
|
53
|
+
},
|
|
14
54
|
"publishConfig": {
|
|
15
55
|
"access": "public",
|
|
16
56
|
"registry": "https://registry.npmjs.org/"
|
package/src/file-operations.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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;
|
package/src/file-operations.js
CHANGED
|
@@ -1,80 +1,88 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var w = (l, d, o) => y(l, typeof d != "symbol" ? d + "" : d, o);
|
|
4
|
-
var u = (l, d, o) => new Promise((r, i) => {
|
|
5
|
-
var t = (e) => {
|
|
1
|
+
var s = (d, o, l) => new Promise((e, t) => {
|
|
2
|
+
var i = (a) => {
|
|
6
3
|
try {
|
|
7
|
-
|
|
8
|
-
} catch (
|
|
9
|
-
|
|
4
|
+
r(l.next(a));
|
|
5
|
+
} catch (c) {
|
|
6
|
+
t(c);
|
|
10
7
|
}
|
|
11
|
-
},
|
|
8
|
+
}, p = (a) => {
|
|
12
9
|
try {
|
|
13
|
-
|
|
14
|
-
} catch (
|
|
15
|
-
|
|
10
|
+
r(l.throw(a));
|
|
11
|
+
} catch (c) {
|
|
12
|
+
t(c);
|
|
16
13
|
}
|
|
17
|
-
},
|
|
18
|
-
|
|
14
|
+
}, r = (a) => a.done ? e(a.value) : Promise.resolve(a.value).then(i, p);
|
|
15
|
+
r((l = l.apply(d, o)).next());
|
|
19
16
|
});
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
return
|
|
24
|
-
|
|
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) => {
|
|
22
|
+
try {
|
|
23
|
+
const e = document.createElement("script");
|
|
24
|
+
e.text = d, document.head.appendChild(e), o();
|
|
25
|
+
} catch (e) {
|
|
26
|
+
l(e);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
25
29
|
});
|
|
26
30
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
r(new Error("请先调用 init 方法初始化上传器"));
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const i = JSON.stringify({
|
|
57
|
-
Vod: {
|
|
58
|
-
UserData: {
|
|
59
|
-
IsShowWaterMark: "false",
|
|
60
|
-
Priority: "7"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
this.uploader.addFile(d, null, null, null, i), this.uploader.startUpload();
|
|
65
|
-
const t = (a) => {
|
|
66
|
-
o({ videoId: a.videoId });
|
|
67
|
-
}, s = (a, U, p) => {
|
|
68
|
-
r(new Error(p || "上传失败"));
|
|
69
|
-
}, n = this.uploader.onUploadSucceed, e = this.uploader.onUploadFailed;
|
|
70
|
-
this.uploader.onUploadSucceed = (a) => {
|
|
71
|
-
t(a), n == null || n(a);
|
|
72
|
-
}, this.uploader.onUploadFailed = (a, U, p) => {
|
|
73
|
-
s(a, U, p), e == null || e(a, U, p);
|
|
74
|
-
};
|
|
31
|
+
function A() {
|
|
32
|
+
return s(this, null, function* () {
|
|
33
|
+
try {
|
|
34
|
+
if (yield y(h), yield y(f), !window.AliyunUpload)
|
|
35
|
+
throw new Error("SDK 加载成功但未找到 AliyunUpload 对象");
|
|
36
|
+
} catch (d) {
|
|
37
|
+
throw d;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function P(d) {
|
|
42
|
+
return s(this, null, function* () {
|
|
43
|
+
if (typeof window == "undefined")
|
|
44
|
+
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 || (() => {
|
|
51
|
+
}),
|
|
52
|
+
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
|
+
})
|
|
75
57
|
});
|
|
76
|
-
|
|
58
|
+
return {
|
|
59
|
+
uploader: o,
|
|
60
|
+
upload: (e) => s(this, null, function* () {
|
|
61
|
+
return new Promise((t, i) => {
|
|
62
|
+
const p = JSON.stringify({
|
|
63
|
+
Vod: {
|
|
64
|
+
UserData: {
|
|
65
|
+
IsShowWaterMark: "false",
|
|
66
|
+
Priority: "7"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
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
|
+
};
|
|
81
|
+
});
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
});
|
|
77
85
|
}
|
|
78
86
|
export {
|
|
79
|
-
|
|
87
|
+
P as createVideoUploader
|
|
80
88
|
};
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { isVNode } from 'vue';
|
|
2
2
|
|
|
3
|
+
export declare function createVideoUploader(options: VideoUploadOptions): Promise<IVideoUploader>;
|
|
4
|
+
|
|
3
5
|
export declare const initStorage: typeof Storage_2.init;
|
|
4
6
|
|
|
5
7
|
export declare const isBoolean: (val: any) => val is boolean;
|
|
@@ -105,13 +107,6 @@ export declare interface UploadInfo {
|
|
|
105
107
|
|
|
106
108
|
export declare const useStorage: typeof Storage_2.getInstance;
|
|
107
109
|
|
|
108
|
-
export declare class VideoUploader implements IVideoUploader {
|
|
109
|
-
uploader: any;
|
|
110
|
-
constructor(options: VideoUploadOptions);
|
|
111
|
-
private initialize;
|
|
112
|
-
upload(file: File): Promise<VideoUploadResult>;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
110
|
declare interface VideoUploadOptions {
|
|
116
111
|
onUploadFailed?: (uploadInfo: any, code: string, message: string) => void;
|
|
117
112
|
onUploadSucceed?: (uploadInfo: any) => void;
|
|
@@ -136,6 +131,11 @@ export declare function watermark(): {
|
|
|
136
131
|
export { }
|
|
137
132
|
|
|
138
133
|
|
|
134
|
+
declare module '*.js?raw' {
|
|
135
|
+
const content: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
139
|
declare global {
|
|
140
140
|
interface Window {
|
|
141
141
|
AliyunUpload: any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}exports.commonjsRequire=o;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
function r(o) {
|
|
2
|
-
throw new Error('Could not dynamically require "' + o + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
3
|
-
}
|
|
4
|
-
export {
|
|
5
|
-
r as commonjsRequire
|
|
6
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}exports.getDefaultExportFromCjs=e;
|