xframelib 0.6.1 → 0.6.4

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.
@@ -0,0 +1,67 @@
1
+ /** WSynchro object to synchronize windows
2
+ * - windows: array of windows to synchro (
3
+ * - source: the window source (undefined if first window)
4
+ */
5
+ if (!window.WSynchro) {
6
+ var WSynchro = { windows: [] };
7
+ }
8
+ /** Open a new window to synchronize
9
+ * @param {url|undefined} url to open, default current window url
10
+ * @param {specs|undefined|null} specs (as for window.open), undefined to open in a new window, null to open in a new tab, default new window
11
+ */
12
+ WSynchro.open = function (href, specs)
13
+ { var w = window.open (href || window.location.href, "_blank", typeof(specs)=="undefined"? "location=1,menubar=1,toolbar=1,scrollbars=1" : specs);
14
+ if (!w.WSynchro) w.WSynchro = { windows: [ window ], source:window };
15
+ else
16
+ { w.WSynchro.windows = [ window ];
17
+ w.WSynchro.source = window;
18
+ }
19
+ this.windows.push(w);
20
+ }
21
+ /** Trigger function
22
+ * @param {synchronize}
23
+ * @param {function} synchronize function
24
+ */
25
+ WSynchro.on = function (e, syncFn)
26
+ { if (!this.syncFn_) this.syncFn_ = [];
27
+ if (e==='synchronize') this.syncFn_.push(syncFn);
28
+ }
29
+ /** Synchronize windows
30
+ * @param {Object|undefined} if undefined stop synchro (when the window is synchronize)
31
+ */
32
+ WSynchro.synchronize = function(params)
33
+ { this.synchronize_ (params);
34
+ }
35
+ /** Synchronize windows:
36
+ * @param {Array} array of arguments to use with fn
37
+ * @param {} internal syncrho time to avoid stnchro loops
38
+ * @private
39
+ */
40
+ WSynchro.synchronize_ = function(args, sync) {
41
+ var i;
42
+ // Stop condition
43
+ if (!sync)
44
+ { if (this.synchronizing) sync = this.sync;
45
+ else this.sync = sync = (new Date()).getTime();
46
+ this.synchronizing = false;
47
+ }
48
+ else
49
+ { // Don't synchronize twice
50
+ if (sync == this.sync) return;
51
+ this.sync = sync;
52
+ this.synchronizing = true;
53
+ try
54
+ { if (WSynchro.syncFn_)
55
+ { args.type = "synchronize";
56
+ for (i=0; i<WSynchro.syncFn_.length; i++)
57
+ { WSynchro.syncFn_[i].apply (null, [args]);
58
+ }
59
+ }
60
+ } catch(e) { /* */ }
61
+ }
62
+ if (args) for (i=0; i<this.windows.length; i++)
63
+ { try
64
+ { this.windows[i].WSynchro.synchronize_(args, sync);
65
+ } catch(e) { /* */ }
66
+ }
67
+ }
@@ -21,7 +21,7 @@ export interface FileUploadOptions {
21
21
  /**
22
22
  * 文件上传类
23
23
  */
24
- export default class FileUpload {
24
+ export declare class FileUpload {
25
25
  endpoint: string | ((file?: File) => Promise<string>);
26
26
  file: File;
27
27
  headers: XhrHeaders;
@@ -79,7 +79,16 @@ export default class H5Tool {
79
79
  * @param fileObj file对象
80
80
  * @param handleMd5Result 处理文件MD5结果
81
81
  */
82
- static getFileShortMD5(fileObj: any, handleMd5Result: (data: {
82
+ static getFileShortMD5(fileObj: File, handleMd5Result: (data: {
83
+ isOK: boolean;
84
+ data: string;
85
+ }) => void): any;
86
+ /**
87
+ * 获取文件完整的MD5摘要
88
+ * @param fileObj
89
+ * @param handleMd5Result
90
+ */
91
+ static getFileMD5(fileObj: File, handleMd5Result: (data: {
83
92
  isOK: boolean;
84
93
  data: string;
85
94
  }) => void): any;
@@ -114,4 +123,15 @@ export default class H5Tool {
114
123
  * @param dom
115
124
  */
116
125
  static setCssVar(prop: string, val: any, dom?: HTMLElement): void;
126
+ /**
127
+ * 主动触发Windows的resize事件
128
+ */
129
+ static dispatchWindowResize(): void;
130
+ /**
131
+ * 主动触发HTML元素的事件
132
+ * @param element HTML元素
133
+ * @param evtName 事件名
134
+ * @param evtHandler 事件额外的处理函数
135
+ */
136
+ static dispatchElementEvent(element: HTMLElement | string, evtName?: string, evtHandler?: Function): void;
117
137
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xframelib",
3
- "version": "0.6.1",
3
+ "version": "0.6.4",
4
4
  "description": "积累的前端开发基础库",
5
5
  "main": "dist/index.js",
6
6
  "common": "dist/index.cjs",
@@ -26,7 +26,7 @@
26
26
  "@hprose/io": "^3.0.10",
27
27
  "@hprose/rpc-core": "^3.0.10",
28
28
  "@hprose/rpc-html5": "^3.0.10",
29
- "axios": "^0.26.1",
29
+ "axios": "^0.27.2",
30
30
  "localforage": "^1.10.0",
31
31
  "spark-md5": "^3.0.2",
32
32
  "streamsaver": "^2.0.6",
@@ -34,26 +34,26 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "@rollup/plugin-alias": "^3.1.9",
37
- "@rollup/plugin-commonjs": "^22.0.0",
37
+ "@rollup/plugin-commonjs": "^22.0.1",
38
38
  "@rollup/plugin-json": "^4.1.0",
39
- "@rollup/plugin-node-resolve": "^13.2.1",
40
- "@rollup/plugin-typescript": "^8.3.2",
39
+ "@rollup/plugin-node-resolve": "^13.3.0",
40
+ "@rollup/plugin-typescript": "^8.3.4",
41
41
  "@types/streamsaver": "^2.0.1",
42
- "@vitejs/plugin-vue": "^2.3.1",
43
- "@vue/compiler-sfc": "^3.2.33",
44
- "esbuild": "^0.14.38",
42
+ "@vitejs/plugin-vue": "^3.0.1",
43
+ "@vue/compiler-sfc": "^3.2.37",
44
+ "esbuild": "^0.14.53",
45
45
  "rimraf": "^3.0.2",
46
46
  "rollup-plugin-copy": "^3.4.0",
47
47
  "rollup-plugin-esbuild": "^4.9.1",
48
48
  "rollup-plugin-scss": "^3.0.0",
49
49
  "rollup-plugin-terser": "^7.0.2",
50
- "rollup-plugin-typescript2": "^0.31.2",
50
+ "rollup-plugin-typescript2": "^0.32.1",
51
51
  "rollup-plugin-vue": "^6.0.0",
52
- "sass": "^1.50.1",
53
- "typescript": "^4.6.3",
54
- "vite": "^2.9.5",
55
- "vue": "^3.2.33",
56
- "vue-router": "^4.0.14",
57
- "vue-tsc": "^0.34.10"
52
+ "sass": "^1.54.1",
53
+ "typescript": "^4.7.4",
54
+ "vite": "^3.0.4",
55
+ "vue": "^3.2.37",
56
+ "vue-router": "^4.1.3",
57
+ "vue-tsc": "^0.39.4"
58
58
  }
59
59
  }