@qxs-bns/utils 0.0.9 → 0.0.11

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 (68) hide show
  1. package/README.md +65 -0
  2. package/es/_virtual/ans-javascript-sdk/sdk/AnalysysAgent_JS_SDK.es6.min.mjs +2142 -0
  3. package/es/_virtual/ans-javascript-sdk/sdk/AnalysysAgent_JS_SDK.es6.min.mjs.map +1 -0
  4. package/es/index.d.ts +7 -0
  5. package/es/index.mjs +26 -0
  6. package/es/index.mjs.map +1 -0
  7. package/es/src/argo-log.d.ts +32 -0
  8. package/es/src/argo-log.mjs +56 -0
  9. package/es/src/argo-log.mjs.map +1 -0
  10. package/es/src/device.d.ts +4 -0
  11. package/{src/device.js → es/src/device.mjs} +2 -1
  12. package/es/src/device.mjs.map +1 -0
  13. package/es/src/file-operations.d.ts +42 -0
  14. package/es/src/file-operations.mjs +79 -0
  15. package/es/src/file-operations.mjs.map +1 -0
  16. package/es/src/json.d.ts +16 -0
  17. package/es/src/json.mjs +37 -0
  18. package/es/src/json.mjs.map +1 -0
  19. package/es/src/storage.d.ts +31 -0
  20. package/{src/storage.js → es/src/storage.mjs} +9 -8
  21. package/es/src/storage.mjs.map +1 -0
  22. package/es/src/types.d.ts +20 -0
  23. package/es/src/types.mjs +30 -0
  24. package/es/src/types.mjs.map +1 -0
  25. package/es/src/use-api.d.ts +0 -0
  26. package/es/src/watermark.d.ts +47 -0
  27. package/es/src/watermark.mjs +147 -0
  28. package/es/src/watermark.mjs.map +1 -0
  29. package/lib/_virtual/ans-javascript-sdk/sdk/AnalysysAgent_JS_SDK.es6.min.js +30 -0
  30. package/lib/_virtual/ans-javascript-sdk/sdk/AnalysysAgent_JS_SDK.es6.min.js.map +1 -0
  31. package/lib/index.d.ts +7 -0
  32. package/lib/index.js +2 -0
  33. package/lib/index.js.map +1 -0
  34. package/lib/src/argo-log.d.ts +32 -0
  35. package/lib/src/argo-log.js +2 -0
  36. package/lib/src/argo-log.js.map +1 -0
  37. package/lib/src/device.d.ts +4 -0
  38. package/lib/src/device.js +2 -0
  39. package/lib/src/device.js.map +1 -0
  40. package/lib/src/file-operations.d.ts +42 -0
  41. package/lib/src/file-operations.js +2 -0
  42. package/lib/src/file-operations.js.map +1 -0
  43. package/lib/src/json.d.ts +16 -0
  44. package/lib/src/json.js +2 -0
  45. package/lib/src/json.js.map +1 -0
  46. package/lib/src/storage.d.ts +31 -0
  47. package/{src/storage.cjs → lib/src/storage.js} +2 -1
  48. package/lib/src/storage.js.map +1 -0
  49. package/lib/src/types.d.ts +20 -0
  50. package/lib/src/types.js +2 -0
  51. package/lib/src/types.js.map +1 -0
  52. package/lib/src/use-api.d.ts +0 -0
  53. package/lib/src/watermark.d.ts +47 -0
  54. package/lib/src/watermark.js +32 -0
  55. package/lib/src/watermark.js.map +1 -0
  56. package/package.json +22 -47
  57. package/index.cjs +0 -1
  58. package/index.js +0 -21
  59. package/src/device.cjs +0 -1
  60. package/src/file-operations.cjs +0 -1
  61. package/src/file-operations.js +0 -90
  62. package/src/media.cjs +0 -1
  63. package/src/media.js +0 -6
  64. package/src/types.cjs +0 -1
  65. package/src/types.js +0 -16
  66. package/src/watermark.cjs +0 -31
  67. package/src/watermark.js +0 -157
  68. package/types/index.d.ts +0 -140
package/src/watermark.cjs DELETED
@@ -1,31 +0,0 @@
1
- "use strict";var B=Object.defineProperty;var k=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var _=(t,e,n)=>e in t?B(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$=(t,e)=>{for(var n in e||(e={}))E.call(e,n)&&_(t,n,e[n]);if(k)for(var n of k(e))D.call(e,n)&&_(t,n,e[n]);return t};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z={id:"wm_div_id",prefix:"mask_div_id",text:"测试水印",x:0,y:0,rows:0,cols:0,width:0,height:0,x_space:100,y_space:40,font:"微软雅黑",color:"black",fontsize:"18px",alpha:.15,angle:15,parent_width:0,parent_height:0,parent_node:null,monitor:!0};function S(t,e,n){const u=document.createElement("canvas").getContext("2d");if(!u)return{width:100,height:100};u.font=`${n} ${e}`;const c=u.measureText(t.trim()),l=Number.parseFloat(n),p=c.actualBoundingBoxAscent!==void 0&&c.actualBoundingBoxDescent!==void 0?c.actualBoundingBoxAscent+c.actualBoundingBoxDescent:l;return{width:Math.ceil(c.width),height:Math.ceil(p)}}function W(){const t=$({},z);let e=!1;const n=new MutationObserver(C),w=new ResizeObserver(()=>{e||l(t)});function u(a,i){const h=a-t.x,o=i-t.y,s=t.x_space||20,d=t.y_space||20,m=Math.ceil(h/(t.width+s)),g=Math.ceil(o/(t.height+d));return{cols:m,rows:g,x_space:s,y_space:d}}function c(a,i,h){const o=document.createElement("div");return o.textContent=t.text,o.id=`${t.prefix}${h}`,o.style.cssText=`
2
- transform: rotate(-${t.angle}deg);
3
- position: absolute;
4
- left: ${a}px;
5
- top: ${i}px;
6
- overflow: hidden;
7
- z-index: 9999999;
8
- opacity: ${t.alpha};
9
- font-size: ${t.fontsize};
10
- font-family: ${t.font};
11
- color: ${t.color};
12
- text-align: center;
13
- width: ${t.width}px;
14
- height: ${t.height}px;
15
- line-height: ${t.height}px;
16
- display: flex;
17
- align-items: center;
18
- justify-content: center;
19
- user-select: none;
20
- visibility: visible;
21
- `.replace(/\s+/g," ").trim(),o}function l(a){if(p(),Object.assign(t,a),t.width===0&&t.height===0||t.width===0||t.height===0){const r=S(t.text,t.font,t.fontsize),f=10;t.width===0&&(t.width=r.width+f),t.height===0&&(t.height=r.height+f)}const i=t.parent_node||document.body,h=Math.max(i.scrollWidth,i.clientWidth),o=Math.max(i.scrollHeight,i.clientHeight),s=document.createElement("div");s.id=t.id,i.closest("body")&&getComputedStyle(i).position==="static"&&(i.style.position="relative"),s.style.cssText=`
22
- pointer-events: none;
23
- display: block;
24
- position: absolute;
25
- top: 0;
26
- left: 0;
27
- width: 100%;
28
- height: 100%;
29
- z-index: 9999999;
30
- overflow: hidden;
31
- `.replace(/\s+/g," ").trim();const d=s.attachShadow?s.attachShadow({mode:"open"}):s;i.appendChild(s);const{cols:m,rows:g,x_space:v,y_space:y}=u(h,o);t.cols=m,t.rows=g,t.x_space=v,t.y_space=y;const b=document.createDocumentFragment();for(let r=0;r<g;r++){const f=t.y+(t.height+y)*r;for(let x=0;x<m;x++){const M=t.x+(t.width+v)*x;b.appendChild(c(M,f,r*m+x))}}if(d.appendChild(b),t.monitor){w.observe(i);const r={attributes:!0,childList:!0,subtree:!0,characterData:!0};n.observe(s,r),d!==s&&n.observe(d,r)}}function p(){var i;const a=document.getElementById(t.id);n.disconnect(),a&&((i=a.parentNode)==null||i.removeChild(a))}function C(a){if(e){e=!1;return}if(!document.getElementById(t.id)){l(t);return}a.some(o=>o.type==="childList"||o.type==="attributes"||o.type==="characterData")&&l(t)}return{addMark:l,removeMark:()=>{e=!0,p()}}}exports.watermark=W;
package/src/watermark.js DELETED
@@ -1,157 +0,0 @@
1
- var B = Object.defineProperty;
2
- var _ = Object.getOwnPropertySymbols;
3
- var E = Object.prototype.hasOwnProperty, D = Object.prototype.propertyIsEnumerable;
4
- var k = (t, e, n) => e in t ? B(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, $ = (t, e) => {
5
- for (var n in e || (e = {}))
6
- E.call(e, n) && k(t, n, e[n]);
7
- if (_)
8
- for (var n of _(e))
9
- D.call(e, n) && k(t, n, e[n]);
10
- return t;
11
- };
12
- const z = {
13
- id: "wm_div_id",
14
- prefix: "mask_div_id",
15
- text: "测试水印",
16
- x: 0,
17
- y: 0,
18
- rows: 0,
19
- cols: 0,
20
- width: 0,
21
- height: 0,
22
- x_space: 100,
23
- y_space: 40,
24
- font: "微软雅黑",
25
- color: "black",
26
- fontsize: "18px",
27
- alpha: 0.15,
28
- angle: 15,
29
- parent_width: 0,
30
- parent_height: 0,
31
- parent_node: null,
32
- monitor: !0
33
- };
34
- function W(t, e, n) {
35
- const u = document.createElement("canvas").getContext("2d");
36
- if (!u)
37
- return { width: 100, height: 100 };
38
- u.font = `${n} ${e}`;
39
- const r = u.measureText(t.trim()), l = Number.parseFloat(n), p = r.actualBoundingBoxAscent !== void 0 && r.actualBoundingBoxDescent !== void 0 ? r.actualBoundingBoxAscent + r.actualBoundingBoxDescent : l;
40
- return {
41
- width: Math.ceil(r.width),
42
- height: Math.ceil(p)
43
- };
44
- }
45
- function H() {
46
- const t = $({}, z);
47
- let e = !1;
48
- const n = new MutationObserver(C), w = new ResizeObserver(() => {
49
- e || l(t);
50
- });
51
- function u(a, i) {
52
- const h = a - t.x, o = i - t.y, s = t.x_space || 20, d = t.y_space || 20, m = Math.ceil(h / (t.width + s)), f = Math.ceil(o / (t.height + d));
53
- return {
54
- cols: m,
55
- rows: f,
56
- x_space: s,
57
- y_space: d
58
- };
59
- }
60
- function r(a, i, h) {
61
- const o = document.createElement("div");
62
- return o.textContent = t.text, o.id = `${t.prefix}${h}`, o.style.cssText = `
63
- transform: rotate(-${t.angle}deg);
64
- position: absolute;
65
- left: ${a}px;
66
- top: ${i}px;
67
- overflow: hidden;
68
- z-index: 9999999;
69
- opacity: ${t.alpha};
70
- font-size: ${t.fontsize};
71
- font-family: ${t.font};
72
- color: ${t.color};
73
- text-align: center;
74
- width: ${t.width}px;
75
- height: ${t.height}px;
76
- line-height: ${t.height}px;
77
- display: flex;
78
- align-items: center;
79
- justify-content: center;
80
- user-select: none;
81
- visibility: visible;
82
- `.replace(/\s+/g, " ").trim(), o;
83
- }
84
- function l(a) {
85
- if (p(), Object.assign(t, a), t.width === 0 && t.height === 0 || t.width === 0 || t.height === 0) {
86
- const c = W(
87
- t.text,
88
- t.font,
89
- t.fontsize
90
- ), g = 10;
91
- t.width === 0 && (t.width = c.width + g), t.height === 0 && (t.height = c.height + g);
92
- }
93
- const i = t.parent_node || document.body, h = Math.max(i.scrollWidth, i.clientWidth), o = Math.max(i.scrollHeight, i.clientHeight), s = document.createElement("div");
94
- s.id = t.id, i.closest("body") && getComputedStyle(i).position === "static" && (i.style.position = "relative"), s.style.cssText = `
95
- pointer-events: none;
96
- display: block;
97
- position: absolute;
98
- top: 0;
99
- left: 0;
100
- width: 100%;
101
- height: 100%;
102
- z-index: 9999999;
103
- overflow: hidden;
104
- `.replace(/\s+/g, " ").trim();
105
- const d = s.attachShadow ? s.attachShadow({ mode: "open" }) : s;
106
- i.appendChild(s);
107
- const { cols: m, rows: f, x_space: v, y_space: y } = u(h, o);
108
- t.cols = m, t.rows = f, t.x_space = v, t.y_space = y;
109
- const b = document.createDocumentFragment();
110
- for (let c = 0; c < f; c++) {
111
- const g = t.y + (t.height + y) * c;
112
- for (let x = 0; x < m; x++) {
113
- const M = t.x + (t.width + v) * x;
114
- b.appendChild(r(M, g, c * m + x));
115
- }
116
- }
117
- if (d.appendChild(b), t.monitor) {
118
- w.observe(i);
119
- const c = {
120
- attributes: !0,
121
- // 监听属性变化
122
- childList: !0,
123
- // 监听子元素变化
124
- subtree: !0,
125
- // 监听子树变化
126
- characterData: !0
127
- // 监听文本内容变化
128
- };
129
- n.observe(s, c), d !== s && n.observe(d, c);
130
- }
131
- }
132
- function p() {
133
- var i;
134
- const a = document.getElementById(t.id);
135
- n.disconnect(), a && ((i = a.parentNode) == null || i.removeChild(a));
136
- }
137
- function C(a) {
138
- if (e) {
139
- e = !1;
140
- return;
141
- }
142
- if (!document.getElementById(t.id)) {
143
- l(t);
144
- return;
145
- }
146
- a.some((o) => o.type === "childList" || o.type === "attributes" || o.type === "characterData") && l(t);
147
- }
148
- return {
149
- addMark: l,
150
- removeMark: () => {
151
- e = !0, p();
152
- }
153
- };
154
- }
155
- export {
156
- H as watermark
157
- };
package/types/index.d.ts DELETED
@@ -1,140 +0,0 @@
1
- import { isVNode } from 'vue';
2
-
3
- export declare function createVideoUploader(options: VideoUploadOptions): Promise<IVideoUploader>;
4
-
5
- export declare const initStorage: typeof Storage_2.init;
6
-
7
- export declare const isBoolean: (val: any) => val is boolean;
8
-
9
- export declare function isElement(e: unknown): e is Element;
10
-
11
- export declare function isImageByMimeType(file: File): boolean;
12
-
13
- /**
14
- * 判断是移动端还是pc端
15
- */
16
- export declare function isMobile(): boolean | "确保在浏览器环境中";
17
-
18
- export declare const isNumber: (val: any) => val is number;
19
-
20
- export declare const isUndefined: (val: any) => val is undefined;
21
-
22
- export { isVNode }
23
-
24
- export declare function isWindow(val: unknown): val is Window;
25
-
26
- export declare interface IVideoUploader {
27
- uploader: any;
28
- upload: (file: File) => Promise<VideoUploadResult>;
29
- }
30
-
31
- declare interface SettingsType {
32
- /** 水印总体的id */
33
- id?: string;
34
- /** 小水印的id前缀 */
35
- prefix?: string;
36
- /** 水印文案 */
37
- text?: string;
38
- /** 水印起始位置x轴坐标 */
39
- x?: number;
40
- /** 水印起始位置Y轴坐标 */
41
- y?: number;
42
- /** 水印行数 */
43
- rows?: number;
44
- /** 水印列数 */
45
- cols?: number;
46
- /** 水印x轴间隔 */
47
- x_space?: number;
48
- /** 水印y轴间隔 */
49
- y_space?: number;
50
- /** 水印字体 */
51
- font?: string;
52
- /** 水印字体颜色 */
53
- color?: string;
54
- /** 水印字体大小 */
55
- fontsize?: string;
56
- /** 水印透明度,要求设置在大于等于0.005 */
57
- alpha?: number;
58
- /** 水印宽度 */
59
- width?: number;
60
- /** 水印长度 */
61
- height?: number;
62
- /** 水印倾斜度数 */
63
- angle?: number;
64
- /** 水印的总体宽度(默认值:body的scrollWidth和clientWidth的较大值) */
65
- parent_width?: number;
66
- /** 水印的总体高度(默认值:body的scrollHeight和clientHeight的较大值) */
67
- parent_height?: number;
68
- /** 水印插件挂载的父元素element,不输入则默认挂在body */
69
- parent_node?: HTMLElement | null;
70
- /** 是否监控,true: 不可删除水印; false: 可删水印 */
71
- monitor?: boolean;
72
- }
73
-
74
- declare class Storage_2 {
75
- private readonly prefix;
76
- private constructor();
77
- static init(prefix?: string): Storage_2;
78
- static getInstance(): Storage_2;
79
- private getTopLevelDomain;
80
- local: {
81
- has: (key: string) => boolean;
82
- get: (key: string) => string | null;
83
- set: (key: string, value: string) => void;
84
- remove: (key: string) => void;
85
- clear: () => void;
86
- };
87
- session: {
88
- has: (key: string) => boolean;
89
- get: (key: string) => string | null;
90
- set: (key: string, value: string) => void;
91
- remove: (key: string) => void;
92
- clear: () => void;
93
- };
94
- cookie: {
95
- has: (key: string) => boolean;
96
- get: (key: string) => string | null;
97
- set: (key: string, value: string, expires?: number, path?: string, domain?: string) => void;
98
- remove: (key: string, path?: string, domain?: string) => void;
99
- clear: () => void;
100
- };
101
- }
102
-
103
- export declare interface UploadInfo {
104
- file: File;
105
- videoId?: string;
106
- }
107
-
108
- export declare const useStorage: typeof Storage_2.getInstance;
109
-
110
- declare interface VideoUploadOptions {
111
- onUploadFailed?: (uploadInfo: any, code: string, message: string) => void;
112
- onUploadSucceed?: (uploadInfo: any) => void;
113
- onUploadProgress?: (uploadInfo: UploadInfo, totalSize: number, percent: number) => void;
114
- onUploadTokenExpired?: (response: any) => void;
115
- onUploadstarted?: (uploadInfo: UploadInfo) => Promise<{
116
- uploadAuth: string;
117
- uploadAddress: string;
118
- videoId: string;
119
- }>;
120
- }
121
-
122
- declare interface VideoUploadResult {
123
- videoId: string;
124
- uploadInfo: any;
125
- }
126
-
127
- export declare function watermark(): {
128
- addMark: (settings: Partial<SettingsType>) => void;
129
- removeMark: () => void;
130
- };
131
-
132
- export { }
133
-
134
- declare global {
135
- interface Window {
136
- AliyunUpload: any;
137
- OSS: any;
138
- }
139
- }
140
-