xframelib 1.0.9 → 1.1.0
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/README.md +1 -0
- package/dist/assets/worker-iconv-BsNle8M5.js +22 -0
- package/dist/assets/{worker-webcache-CO9_r3iY.js → worker-webcache-Csuv6kAg.js} +1 -1
- package/dist/assets/worker-xmath-AxRk6MsK.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -3
- package/dist/plugins/NavigatorPlugin.d.ts +141 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/utils/CommonTool.d.ts +8 -0
- package/dist/workers/index.d.ts +5 -11
- package/dist/workers/worker-iconv.d.ts +26 -0
- package/dist/workers/worker-xmath.d.ts +15 -29
- package/package.json +14 -13
- package/dist/assets/worker-XXTEA-CMYO_oW7.js +0 -6
- package/dist/assets/worker-bigimage-ULYc5DiH.js +0 -6
- package/dist/assets/worker-xmath-DRrB1AaK.js +0 -14
- package/dist/workers/worker-XXTEA.d.ts +0 -1
- package/dist/workers/worker-bigimage.d.ts +0 -17
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export interface IBatteryStatus {
|
|
2
|
+
/**
|
|
3
|
+
* 电池电量 0-1
|
|
4
|
+
*/
|
|
5
|
+
level: number;
|
|
6
|
+
/**
|
|
7
|
+
* 是否充电中
|
|
8
|
+
*/
|
|
9
|
+
charging: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* 充电时间
|
|
12
|
+
*/
|
|
13
|
+
chargingTime?: number;
|
|
14
|
+
/**
|
|
15
|
+
* 续航时间
|
|
16
|
+
*/
|
|
17
|
+
dischargingTime?: number;
|
|
18
|
+
}
|
|
19
|
+
export type BatteryCallbackFunc = (battery: IBatteryStatus) => void;
|
|
20
|
+
/**
|
|
21
|
+
* 提供通用浏览器全局方法封装
|
|
22
|
+
* 浏览器插件
|
|
23
|
+
*/
|
|
24
|
+
declare class NavigatorPlugin {
|
|
25
|
+
private static batteryStatusCallback;
|
|
26
|
+
private static _battery;
|
|
27
|
+
/**
|
|
28
|
+
* 电池电量发生变化
|
|
29
|
+
* @param status
|
|
30
|
+
*/
|
|
31
|
+
private static batteryStatusChange;
|
|
32
|
+
/**
|
|
33
|
+
* 监听电池电量发生变化
|
|
34
|
+
* @param pbatteryStatusCallback
|
|
35
|
+
*/
|
|
36
|
+
static OnBatteryStatusHandler(pbatteryStatusCallback: BatteryCallbackFunc): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* 移除电池电量变化
|
|
39
|
+
*/
|
|
40
|
+
static OffBatteryStatusHandler(): void;
|
|
41
|
+
private static onlineChangeCallback;
|
|
42
|
+
private static networkStatusChange;
|
|
43
|
+
/**
|
|
44
|
+
* 联网状态
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
static isOnline(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* 监听网络变化
|
|
50
|
+
*/
|
|
51
|
+
static OnNetworkHandle(onlineChange: (status: boolean) => void): void;
|
|
52
|
+
/**
|
|
53
|
+
* 移除监听
|
|
54
|
+
* @param onlineChange
|
|
55
|
+
*/
|
|
56
|
+
static OffNetworkHandle(): void;
|
|
57
|
+
/**
|
|
58
|
+
* 下载网速(估算)
|
|
59
|
+
* @param speadCallback
|
|
60
|
+
* @returns 单位Mbps
|
|
61
|
+
*/
|
|
62
|
+
static downloadSpead(speadCallback?: Function): number;
|
|
63
|
+
/**
|
|
64
|
+
* 振动设备
|
|
65
|
+
* @param duration 多少ms,默认300
|
|
66
|
+
*/
|
|
67
|
+
static vibrate(duration?: number | number[]): Promise<void>;
|
|
68
|
+
private static defaultSpeakOption;
|
|
69
|
+
/**
|
|
70
|
+
* 改变默认设置
|
|
71
|
+
* @param volume 音量,默认0.2 (0-1.0)
|
|
72
|
+
* @param rate 音速,默认1 (0.1~2)
|
|
73
|
+
* @param pitch 音调,默认1 (0~2)
|
|
74
|
+
* @param voice 类型,默认0
|
|
75
|
+
*/
|
|
76
|
+
static changeSpeakOptions(volume?: number, rate?: number, pitch?: number, voice?: number): void;
|
|
77
|
+
/**
|
|
78
|
+
* 获取所支持的声音列表
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
static getSupportedVoices(): string[];
|
|
82
|
+
/**
|
|
83
|
+
* 获取所支持的语言列表
|
|
84
|
+
* @returns
|
|
85
|
+
*/
|
|
86
|
+
static getSupportedLanguages(): readonly string[];
|
|
87
|
+
/**
|
|
88
|
+
* 说中文
|
|
89
|
+
* @param text_zhCN 中文文字
|
|
90
|
+
* @param lang 语言类型,默认为zh-CN
|
|
91
|
+
*/
|
|
92
|
+
static speak(text_zhCN: string, lang?: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* 其他文字转声音
|
|
95
|
+
* @param text 文字
|
|
96
|
+
* @param lang 语音类型
|
|
97
|
+
*/
|
|
98
|
+
static speakEnglish(text: string): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* 停止说话
|
|
101
|
+
*/
|
|
102
|
+
static stopSpeak(): void;
|
|
103
|
+
/**
|
|
104
|
+
* 请求和打开通知提示窗体
|
|
105
|
+
* @param title 标题
|
|
106
|
+
* @param body 内容
|
|
107
|
+
* @param pOptions 更多选项
|
|
108
|
+
* @param closeCallback 关闭回调
|
|
109
|
+
* @param clickCallback 点击回调
|
|
110
|
+
*/
|
|
111
|
+
static openNotification(title: string, body?: string, pOptions?: NotificationOptions, closeCallback?: Function, clickCallback?: Function): void;
|
|
112
|
+
/**
|
|
113
|
+
* 页面是否可见
|
|
114
|
+
* @returns
|
|
115
|
+
*/
|
|
116
|
+
static isPageVisible(): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* 当页面可见性变化(例如:页面不可见,关闭音乐)
|
|
119
|
+
* @param callbackFunc 回调函数
|
|
120
|
+
*/
|
|
121
|
+
static onPageVisibleChange(callbackFunc: (visible: boolean) => any): void;
|
|
122
|
+
/**
|
|
123
|
+
* 复制
|
|
124
|
+
* 到剪切板上
|
|
125
|
+
* @param value
|
|
126
|
+
*/
|
|
127
|
+
static copyText(value: string): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* 读剪切板里内容
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
132
|
+
static readText(): Promise<string>;
|
|
133
|
+
/**
|
|
134
|
+
*
|
|
135
|
+
* 页面内容切换变化 (例如:图片切换)
|
|
136
|
+
* @param updateHtmlContent
|
|
137
|
+
* @returns
|
|
138
|
+
*/
|
|
139
|
+
static viewTransition(updateHtmlContent: Function): void;
|
|
140
|
+
}
|
|
141
|
+
export default NavigatorPlugin;
|
|
@@ -76,3 +76,11 @@ export declare function convertToDecimalismByString(value: string, digit?: numbe
|
|
|
76
76
|
* 方位的度分秒字符串 转成十进制
|
|
77
77
|
*/
|
|
78
78
|
export declare function convertToDecimalismByString2(value: string): number;
|
|
79
|
+
/**
|
|
80
|
+
* 二维数组
|
|
81
|
+
* 从内向外遍历
|
|
82
|
+
* @param xRows 第1个一维数组长度
|
|
83
|
+
* @param yCols 第2个一维数组长度
|
|
84
|
+
* @param callback 遍历到每个元素时的回调函数,参数为 ( row, col)
|
|
85
|
+
*/
|
|
86
|
+
export declare function traverseXYArrayFromInsideOut(xRows: number, yCols: number, callback?: (row: number, col: number) => any): Array<[number, number]>;
|
package/dist/workers/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 编码/解码
|
|
3
3
|
*/
|
|
4
|
-
declare const
|
|
4
|
+
declare const iconvWorker: {
|
|
5
5
|
readonly [x: number]: Worker;
|
|
6
|
-
} & import('comlink').RemoteObject<typeof import("./worker-
|
|
6
|
+
} & import('comlink').RemoteObject<typeof import("./worker-iconv")> & import('comlink').ProxyMethods;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* 通用数学计算;前端大图片,瓦片化加载-webworker
|
|
9
9
|
*/
|
|
10
10
|
declare const xmathWorker: {
|
|
11
11
|
readonly [x: number]: Worker;
|
|
@@ -16,10 +16,4 @@ declare const xmathWorker: {
|
|
|
16
16
|
declare const webCacheWorker: {
|
|
17
17
|
readonly [x: number]: Worker;
|
|
18
18
|
} & import('comlink').RemoteObject<typeof import("./worker-webcache")> & import('comlink').ProxyMethods;
|
|
19
|
-
|
|
20
|
-
* 前端大图片,瓦片化加载-webworker
|
|
21
|
-
*/
|
|
22
|
-
declare const bigImageWorker: {
|
|
23
|
-
readonly [x: number]: Worker;
|
|
24
|
-
} & import('comlink').RemoteObject<typeof import("./worker-bigimage")> & import('comlink').ProxyMethods;
|
|
25
|
-
export { xmathWorker, xxteaWorker, webCacheWorker, bigImageWorker };
|
|
19
|
+
export { xmathWorker, iconvWorker, webCacheWorker, };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EncodeOptions, DecodeOptions } from 'iconv-lite';
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
|
+
/**
|
|
4
|
+
* Iconv进行文本编码转换,
|
|
5
|
+
* @param content
|
|
6
|
+
* @param srcEncoding
|
|
7
|
+
* @param targetEncoding
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertEncodeByIconv(content: string, srcEncoding: string, targetEncoding: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* 文字——编码——Iconv
|
|
13
|
+
* @param content
|
|
14
|
+
* @param encoding
|
|
15
|
+
* @param options
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare function encodeByIconv(content: string, encoding: string, options?: EncodeOptions | undefined): Buffer;
|
|
19
|
+
/**
|
|
20
|
+
* 文字——解码——Iconv
|
|
21
|
+
* @param buffer
|
|
22
|
+
* @param encoding
|
|
23
|
+
* @param options
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
export declare function decodeByIconv(buffer: Buffer, encoding: string, options?: DecodeOptions | undefined): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export { toBytes, toString, encrypt, encryptToString, decrypt, decryptToString } from '../utils/XXTEA';
|
|
2
2
|
/**
|
|
3
3
|
* 差集
|
|
4
4
|
* @param a
|
|
@@ -13,33 +13,19 @@ export declare function getMinus(a: any[], b: any[]): any[];
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function getIntersect(a: any[], b: any[]): any[];
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @
|
|
20
|
-
|
|
21
|
-
export declare function MD5(content: string, needRawHash?: boolean): string;
|
|
22
|
-
/**
|
|
23
|
-
* Iconv进行文本编码转换,
|
|
24
|
-
* @param content
|
|
25
|
-
* @param srcEncoding
|
|
26
|
-
* @param targetEncoding
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
export declare function convertEncodeByIconv(content: string, srcEncoding: string, targetEncoding: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* 文字——编码——Iconv
|
|
32
|
-
* @param content
|
|
33
|
-
* @param encoding
|
|
34
|
-
* @param options
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
export declare function encodeByIconv(content: string, encoding: string, options?: EncodeOptions | undefined): Buffer;
|
|
38
|
-
/**
|
|
39
|
-
* 文字——解码——Iconv
|
|
40
|
-
* @param buffer
|
|
41
|
-
* @param encoding
|
|
42
|
-
* @param options
|
|
16
|
+
* 以前端切片方式加载大图片,只支持图片格式 jpg\png 不支持tif
|
|
17
|
+
* @param imageID
|
|
18
|
+
* @param imageUrl
|
|
19
|
+
* @param imageGeoBounds
|
|
20
|
+
* @param maxUnitSize
|
|
43
21
|
* @returns
|
|
44
22
|
*/
|
|
45
|
-
export declare function
|
|
23
|
+
export declare function loadBigImage(imageID: string, imageUrl: string, imageGeoBounds: number[], maxUnitSize?: number): Promise<{
|
|
24
|
+
id: string;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
maxUnitSize: number;
|
|
28
|
+
colNum: number;
|
|
29
|
+
rowNum: number;
|
|
30
|
+
items: any[];
|
|
31
|
+
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xframelib",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "积累的前端开发基础库,来源于项目,服务于项目。",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"common": "dist/index.cjs",
|
|
@@ -33,40 +33,41 @@
|
|
|
33
33
|
"@iconify-icons/ant-design": "^1.2.7",
|
|
34
34
|
"@iconify/vue": "^5.0.0",
|
|
35
35
|
"@microsoft/signalr": "^10.0.0",
|
|
36
|
-
"axios": "^1.13.
|
|
36
|
+
"axios": "^1.13.4",
|
|
37
|
+
"buffer": "^6.0.3",
|
|
37
38
|
"fflate": "^0.8.2",
|
|
38
|
-
"iconv-lite": "^0.7.
|
|
39
|
+
"iconv-lite": "^0.7.2",
|
|
39
40
|
"localforage": "^1.10.0",
|
|
40
41
|
"loglevel": "^1.9.2",
|
|
41
|
-
"lru-cache": "^11.2.
|
|
42
|
-
"qs": "^6.14.
|
|
42
|
+
"lru-cache": "^11.2.5",
|
|
43
|
+
"qs": "^6.14.1",
|
|
43
44
|
"spark-md5": "^3.0.2",
|
|
44
45
|
"xhr": "^2.6.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@rollup/plugin-alias": "^6.0.0",
|
|
48
|
-
"@rollup/plugin-commonjs": "^
|
|
49
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
49
50
|
"@rollup/plugin-json": "^6.1.0",
|
|
50
51
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
51
52
|
"@rollup/plugin-terser": "^0.4.4",
|
|
52
53
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
53
|
-
"@types/node": "^25.0
|
|
54
|
+
"@types/node": "^25.1.0",
|
|
54
55
|
"@vitejs/plugin-vue": "^6.0.3",
|
|
55
|
-
"esbuild": "^0.27.
|
|
56
|
+
"esbuild": "^0.27.2",
|
|
56
57
|
"rollup-plugin-copy": "^3.5.0",
|
|
57
58
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
58
59
|
"rollup-plugin-scss": "^4.0.1",
|
|
59
60
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
60
61
|
"rollup-plugin-vue": "^6.0.0",
|
|
61
|
-
"sass": "^1.
|
|
62
|
+
"sass": "^1.97.3",
|
|
62
63
|
"typescript": "^5.9.3",
|
|
63
|
-
"vite": "^7.3.
|
|
64
|
+
"vite": "^7.3.1",
|
|
64
65
|
"vite-plugin-comlink": "^5.3.0",
|
|
65
66
|
"vite-plugin-commonjs": "^0.10.4",
|
|
66
67
|
"vite-plugin-dts": "^4.5.4",
|
|
67
|
-
"vite-plugin-node-polyfills": "^0.
|
|
68
|
-
"vite-plugin-static-copy": "^3.
|
|
69
|
-
"vue": "^3.5.
|
|
68
|
+
"vite-plugin-node-polyfills": "^0.25.0",
|
|
69
|
+
"vite-plugin-static-copy": "^3.2.0",
|
|
70
|
+
"vue": "^3.5.27",
|
|
70
71
|
"vue-router": "^4.6.4"
|
|
71
72
|
}
|
|
72
73
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2019 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
const e=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),n=Symbol("Comlink.releaseProxy"),t=Symbol("Comlink.finalizer"),a=Symbol("Comlink.thrown"),o=e=>"object"==typeof e&&null!==e||"function"==typeof e,i={canHandle:r=>o(r)&&r[e],serialize(e){const{port1:r,port2:n}=new MessageChannel;return c(e,r),[n,[n]]},deserialize:e=>(e.start(),function(e){const r=new Map;return e.addEventListener("message",(function(e){const{data:n}=e;if(!n||!n.id)return;const t=r.get(n.id);if(t)try{t(n)}finally{r.delete(n.id)}})),p(e,r,[],void 0)}(e))},s=new Map([["proxy",i],["throw",{canHandle:e=>o(e)&&a in e,serialize({value:e}){let r;return r=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[r,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function c(r,n=globalThis,o=["*"]){n.addEventListener("message",(function i(s){if(!s||!s.data)return;if(!function(e,r){for(const n of e){if(r===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(r))return!0}return!1}(o,s.origin))return void console.warn(`Invalid origin '${s.origin}' for comlink proxy`);const{id:l,type:f,path:g}=Object.assign({path:[]},s.data),h=(s.data.argumentList||[]).map(v);let p;try{const n=g.slice(0,-1).reduce(((e,r)=>e[r]),r),t=g.reduce(((e,r)=>e[r]),r);switch(f){case"GET":p=t;break;case"SET":n[g.slice(-1)[0]]=v(s.data.value),p=!0;break;case"APPLY":p=t.apply(n,h);break;case"CONSTRUCT":p=function(r){return Object.assign(r,{[e]:!0})}(new t(...h));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;c(r,n),p=function(e,r){return d.set(e,r),e}(e,[e])}break;case"RELEASE":p=void 0;break;default:return}}catch(e){p={value:e,[a]:0}}Promise.resolve(p).catch((e=>({value:e,[a]:0}))).then((e=>{const[a,o]=w(e);n.postMessage(Object.assign(Object.assign({},a),{id:l}),o),"RELEASE"===f&&(n.removeEventListener("message",i),u(n),t in r&&"function"==typeof r[t]&&r[t]())})).catch((e=>{const[r,t]=w({value:new TypeError("Unserializable return value"),[a]:0});n.postMessage(Object.assign(Object.assign({},r),{id:l}),t)}))})),n.start&&n.start()}function u(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function l(e){if(e)throw new Error("Proxy has been released and is not useable")}function f(e){return m(e,new Map,{type:"RELEASE"}).then((()=>{u(e)}))}const g=new WeakMap,h="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const r=(g.get(e)||0)-1;g.set(e,r),0===r&&f(e)}));function p(e,t,a=[],o=function(){}){let i=!1;const s=new Proxy(o,{get(r,o){if(l(i),o===n)return()=>{!function(e){h&&h.unregister(e)}(s),f(e),t.clear(),i=!0};if("then"===o){if(0===a.length)return{then:()=>s};const r=m(e,t,{type:"GET",path:a.map((e=>e.toString()))}).then(v);return r.then.bind(r)}return p(e,t,[...a,o])},set(r,n,o){l(i);const[s,c]=w(o);return m(e,t,{type:"SET",path:[...a,n].map((e=>e.toString())),value:s},c).then(v)},apply(n,o,s){l(i);const c=a[a.length-1];if(c===r)return m(e,t,{type:"ENDPOINT"}).then(v);if("bind"===c)return p(e,t,a.slice(0,-1));const[u,f]=y(s);return m(e,t,{type:"APPLY",path:a.map((e=>e.toString())),argumentList:u},f).then(v)},construct(r,n){l(i);const[o,s]=y(n);return m(e,t,{type:"CONSTRUCT",path:a.map((e=>e.toString())),argumentList:o},s).then(v)}});return function(e,r){const n=(g.get(r)||0)+1;g.set(r,n),h&&h.register(e,r,e)}(s,e),s}function y(e){const r=e.map(w);return[r.map((e=>e[0])),(n=r.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const d=new WeakMap;function w(e){for(const[r,n]of s)if(n.canHandle(e)){const[t,a]=n.serialize(e);return[{type:"HANDLER",name:r,value:t},a]}return[{type:"RAW",value:e},d.get(e)||[]]}function v(e){switch(e.type){case"HANDLER":return s.get(e.name).deserialize(e.value);case"RAW":return e.value}}function m(e,r,n,t){return new Promise((a=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");r.set(o,a),e.start&&e.start(),e.postMessage(Object.assign({id:o},n),t)}))}let b=!0;try{String.fromCharCode.apply(String,[1,2])}catch(e){b=!1,Object.defineProperty(Array.prototype,"subarray",{value:Array.prototype.slice})}var E=2654435769;function S(e,r){var n=e.length,t=n<<2;if(r){var a=e[n-1];if(a<(t-=4)-3||a>t)return null;t=a}for(var o=new Uint8Array(t),i=0;i<t;++i)o[i]=e[i>>2]>>((3&i)<<3);return o}function C(e,r){var n,t=e.length,a=t>>2;3&t&&++a,r?(n=new Uint32Array(a+1))[a]=t:n=new Uint32Array(a);for(var o=0;o<t;++o)n[o>>2]|=e[o]<<((3&o)<<3);return n}function A(e){return 4294967295&e}function T(e,r,n,t,a,o){return(n>>>5^r<<2)+(r>>>3^n<<4)^(e^r)+(o[3&t^a]^n)}function U(e){if(e.length<16){var r=new Uint8Array(16);r.set(e),e=r}return e}function k(e){for(var r=e.length,n=new Uint8Array(3*r),t=0,a=0;a<r;a++){var o=e.charCodeAt(a);if(o<128)n[t++]=o;else if(o<2048)n[t++]=192|o>>6,n[t++]=128|63&o;else{if(!(o<55296||o>57343)){if(a+1<r){var i=e.charCodeAt(a+1);if(o<56320&&56320<=i&&i<=57343){var s=65536+((1023&o)<<10|1023&i);n[t++]=240|s>>18,n[t++]=128|s>>12&63,n[t++]=128|s>>6&63,n[t++]=128|63&s,a++;continue}}throw new Error("Malformed string")}n[t++]=224|o>>12,n[t++]=128|o>>6&63,n[t++]=128|63&o}}return n.subarray(0,t)}function M(e){var r=e.length;return 0===r?"":r<32767?function(e,r){for(var n=new Array(r),t=0,a=0,o=e.length;t<r&&a<o;t++){var i=e[a++];switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n[t]=i;break;case 12:case 13:if(!(a<o))throw new Error("Unfinished UTF-8 octet sequence");n[t]=(31&i)<<6|63&e[a++];break;case 14:if(!(a+1<o))throw new Error("Unfinished UTF-8 octet sequence");n[t]=(15&i)<<12|(63&e[a++])<<6|63&e[a++];break;case 15:if(!(a+2<o))throw new Error("Unfinished UTF-8 octet sequence");var s=((7&i)<<18|(63&e[a++])<<12|(63&e[a++])<<6|63&e[a++])-65536;if(!(0<=s&&s<=1048575))throw new Error("Character outside valid Unicode range: 0x"+s.toString(16));n[t++]=s>>10&1023|55296,n[t]=1023&s|56320;break;default:throw new Error("Bad UTF-8 encoding 0x"+i.toString(16))}}return t<r&&(n.length=t),String.fromCharCode.apply(String,n)}(e,r):function(e,r){for(var n=[],t=new Array(32768),a=0,o=0,i=e.length;a<r&&o<i;a++){var s=e[o++];switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t[a]=s;break;case 12:case 13:if(!(o<i))throw new Error("Unfinished UTF-8 octet sequence");t[a]=(31&s)<<6|63&e[o++];break;case 14:if(!(o+1<i))throw new Error("Unfinished UTF-8 octet sequence");t[a]=(15&s)<<12|(63&e[o++])<<6|63&e[o++];break;case 15:if(!(o+2<i))throw new Error("Unfinished UTF-8 octet sequence");var c=((7&s)<<18|(63&e[o++])<<12|(63&e[o++])<<6|63&e[o++])-65536;if(!(0<=c&&c<=1048575))throw new Error("Character outside valid Unicode range: 0x"+c.toString(16));t[a++]=c>>10&1023|55296,t[a]=1023&c|56320;break;default:throw new Error("Bad UTF-8 encoding 0x"+s.toString(16))}if(a>=32766){var u=a+1;t.length=u,n.push(String.fromCharCode.apply(String,t)),r-=u,a=-1}}return a>0&&(t.length=a,n.push(String.fromCharCode.apply(String,t))),n.join("")}(e,r)}function j(e,r){return"string"==typeof e&&(e=k(e)),"string"==typeof r&&(r=k(r)),null==e||0===e.length?e:S(function(e,r){var n,t,a,o,i,s,c=e.length,u=c-1;for(t=e[u],a=0,s=0|Math.floor(6+52/c);s>0;--s){for(o=(a=A(a+E))>>>2&3,i=0;i<u;++i)n=e[i+1],t=e[i]=A(e[i]+T(a,n,t,i,o,r));n=e[0],t=e[u]=A(e[u]+T(a,n,t,u,o,r))}return e}(C(e,!0),C(U(r),!1)),!1)}function O(e,r){return"string"==typeof e&&(e=function(e){for(var r=globalThis.atob(e),n=r.length,t=new Uint8Array(n),a=0;a<n;a++)t[a]=r.charCodeAt(a);return t}(e)),"string"==typeof r&&(r=k(r)),null==e||0===e.length?e:S(function(e,r){var n,t,a,o,i,s=e.length,c=s-1;for(n=e[0],a=A(Math.floor(6+52/s)*E);0!==a;a=A(a-E)){for(o=a>>>2&3,i=c;i>0;--i)t=e[i-1],n=e[i]=A(e[i]-T(a,n,t,i,o,r));t=e[c],n=e[0]=A(e[0]-T(a,n,t,0,o,r))}return e}(C(e,!1),C(U(r),!1)),!0)}c(Object.freeze({__proto__:null,decrypt:O,decryptToString:function(e,r){return M(O(e,r))},encrypt:j,encryptToString:function(e,r){return globalThis.btoa(function(e){var r=e.length;if(0===r)return"";var n=b?e:function(e){for(var r=e.length,n=new Array(e.length),t=0;t<r;++t)n[t]=e[t];return n}(e);if(r<65535)return String.fromCharCode.apply(String,n);for(var t=32767&r,a=r>>15,o=new Array(t?a+1:a),i=0;i<a;++i)o[i]=String.fromCharCode.apply(String,n.subarray(i<<15,i+1<<15));return t&&(o[a]=String.fromCharCode.apply(String,n.subarray(a<<15,r))),o.join("")}(j(e,r)))},toBytes:k,toString:M}));
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2019 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
const e=Symbol("Comlink.proxy"),t=Symbol("Comlink.endpoint"),n=Symbol("Comlink.releaseProxy"),r=Symbol("Comlink.finalizer"),a=Symbol("Comlink.thrown"),o=e=>"object"==typeof e&&null!==e||"function"==typeof e,i={canHandle:t=>o(t)&&t[e],serialize(e){const{port1:t,port2:n}=new MessageChannel;return c(e,t),[n,[n]]},deserialize:e=>(e.start(),function(e){const t=new Map;return e.addEventListener("message",(function(e){const{data:n}=e;if(!n||!n.id)return;const r=t.get(n.id);if(r)try{r(n)}finally{t.delete(n.id)}})),p(e,t,[],void 0)}(e))},s=new Map([["proxy",i],["throw",{canHandle:e=>o(e)&&a in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function c(t,n=globalThis,o=["*"]){n.addEventListener("message",(function i(s){if(!s||!s.data)return;if(!function(e,t){for(const n of e){if(t===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}return!1}(o,s.origin))return void console.warn(`Invalid origin '${s.origin}' for comlink proxy`);const{id:u,type:f,path:h}=Object.assign({path:[]},s.data),g=(s.data.argumentList||[]).map(y);let p;try{const n=h.slice(0,-1).reduce(((e,t)=>e[t]),t),r=h.reduce(((e,t)=>e[t]),t);switch(f){case"GET":p=r;break;case"SET":n[h.slice(-1)[0]]=y(s.data.value),p=!0;break;case"APPLY":p=r.apply(n,g);break;case"CONSTRUCT":p=function(t){return Object.assign(t,{[e]:!0})}(new r(...g));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;c(t,n),p=function(e,t){return d.set(e,t),e}(e,[e])}break;case"RELEASE":p=void 0;break;default:return}}catch(e){p={value:e,[a]:0}}Promise.resolve(p).catch((e=>({value:e,[a]:0}))).then((e=>{const[a,o]=w(e);n.postMessage(Object.assign(Object.assign({},a),{id:u}),o),"RELEASE"===f&&(n.removeEventListener("message",i),l(n),r in t&&"function"==typeof t[r]&&t[r]())})).catch((e=>{const[t,r]=w({value:new TypeError("Unserializable return value"),[a]:0});n.postMessage(Object.assign(Object.assign({},t),{id:u}),r)}))})),n.start&&n.start()}function l(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function u(e){if(e)throw new Error("Proxy has been released and is not useable")}function f(e){return b(e,new Map,{type:"RELEASE"}).then((()=>{l(e)}))}const h=new WeakMap,g="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(h.get(e)||0)-1;h.set(e,t),0===t&&f(e)}));function p(e,r,a=[],o=function(){}){let i=!1;const s=new Proxy(o,{get(t,o){if(u(i),o===n)return()=>{!function(e){g&&g.unregister(e)}(s),f(e),r.clear(),i=!0};if("then"===o){if(0===a.length)return{then:()=>s};const t=b(e,r,{type:"GET",path:a.map((e=>e.toString()))}).then(y);return t.then.bind(t)}return p(e,r,[...a,o])},set(t,n,o){u(i);const[s,c]=w(o);return b(e,r,{type:"SET",path:[...a,n].map((e=>e.toString())),value:s},c).then(y)},apply(n,o,s){u(i);const c=a[a.length-1];if(c===t)return b(e,r,{type:"ENDPOINT"}).then(y);if("bind"===c)return p(e,r,a.slice(0,-1));const[l,f]=m(s);return b(e,r,{type:"APPLY",path:a.map((e=>e.toString())),argumentList:l},f).then(y)},construct(t,n){u(i);const[o,s]=m(n);return b(e,r,{type:"CONSTRUCT",path:a.map((e=>e.toString())),argumentList:o},s).then(y)}});return function(e,t){const n=(h.get(t)||0)+1;h.set(t,n),g&&g.register(e,t,e)}(s,e),s}function m(e){const t=e.map(w);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const d=new WeakMap;function w(e){for(const[t,n]of s)if(n.canHandle(e)){const[r,a]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},a]}return[{type:"RAW",value:e},d.get(e)||[]]}function y(e){switch(e.type){case"HANDLER":return s.get(e.name).deserialize(e.value);case"RAW":return e.value}}function b(e,t,n,r){return new Promise((a=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(o,a),e.start&&e.start(),e.postMessage(Object.assign({id:o},n),r)}))}function E(e,t=0,n=0,r=2){if(!e||4!=e.length)return;const a=(e[2]-e[0])/r,o=(e[3]-e[1])/r,i=e[0]+t*a,s=e[3]-n*o,c=i+a,l=s-o;return[[i,s],[c,s],[c,l],[i,l]]}c(Object.freeze({__proto__:null,loadBigImage:async function(e,t,n,r=1024){const a=await fetch(t);if(!a)throw new Error("加载失败:"+t);let o=await a.blob();if(!o)throw new Error("Blob数据对象为空!");const i=await createImageBitmap(o);o=null;const s=Math.ceil(i.width/r),c=Math.ceil(i.height/r),l=Math.max(s,c),u=l,f=l,h=i.width/u,g=i.height/f,p=new OffscreenCanvas(h,g),m=p.getContext("2d");if(!m)throw new Error("获取canvas的Context对象为空!");const d=[],w={id:e,width:i.width,height:i.height,maxUnitSize:r,colNum:u,rowNum:f,items:d};for(let y=0;y<f;y++)for(let t=0;t<u;t++){m.clearRect(0,0,p.width,p.height),m.drawImage(i,t*h,y*g,h,g,0,0,h,g);const r=await p.convertToBlob(),a=URL.createObjectURL(r),o={id:`${e}_${y}_${t}`,coords:E(n,t,y,l),imgURL:a};d.push(o)}return w}}));
|