xframelib 1.0.3 → 1.0.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.
- package/README.md +4 -0
- package/dist/assets/worker-bigimage-DeV0Ac8X.js +6 -0
- package/dist/assets/worker-xmath-BJNVXVMo.js +15 -0
- package/dist/controls/vuewindow/window/index.vue.d.ts +1 -1
- package/dist/index.css +43 -43
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/workers/index.d.ts +7 -1
- package/dist/workers/worker-bigimage.d.ts +17 -0
- package/package.json +6 -6
- package/dist/assets/worker-xmath-DUFCrWrO.js +0 -15
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
> 基于 VUE3+Hprose+Typescript+Widget 的前端框架,与ElementUI、AntDesign VUE、Quasar等界面库无关,一直是来源于项目和服务于项目。
|
|
15
15
|
|
|
16
|
+
- v1.0.4 新增支持大图前端分片加载展示的webworker;增加默认mitt导出;更新基础依赖库版本;
|
|
16
17
|
- v1.0.3 新增支持Webworker Service开发模式(取代vite-plugin-webworker-service功能,解决插件与@quasar/app-vite不兼容);增加基于lru-cache的前端缓存工具类WebCacheTool和webCacheWorker;批量使用globThis代替window全局对象,以支持node和webworker里使用本库;更新基础依赖库版本;
|
|
17
18
|
- v1.0.2 更新依赖库版本;解决XWindow图标离线化问题,修改窗体图标间距;
|
|
18
19
|
- v1.0.1 更新依赖库版本,修改复制粘贴与textarea粘贴功能冲突问题;
|
|
@@ -130,6 +131,8 @@
|
|
|
130
131
|
|
|
131
132
|
- 前端缓存功能(WebCacheTool和webCacheWorker)
|
|
132
133
|
|
|
134
|
+
- maplibre加载大图展示(使用bigImageWorker)
|
|
135
|
+
|
|
133
136
|
## 使用
|
|
134
137
|
|
|
135
138
|
`pnpm add xframelib`
|
|
@@ -260,3 +263,4 @@ export default boot(({ app }) => {
|
|
|
260
263
|
|
|
261
264
|

|
|
262
265
|
|
|
266
|
+

|
|
@@ -0,0 +1,6 @@
|
|
|
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,t){const n=new Map;return e.addEventListener("message",function(e){const{data:t}=e;if(!t||!t.id)return;const r=n.get(t.id);if(r)try{r(t)}finally{n.delete(t.id)}}),p(e,n,[],t)}(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 t=0;t<f;t++)for(let r=0;r<u;r++){m.clearRect(0,0,p.width,p.height),m.drawImage(i,r*h,t*g,h,g,0,0,h,g);const a=await p.convertToBlob(),o=URL.createObjectURL(a),s={id:`${e}_${t}_${r}`,coords:E(n,r,t,l),imgURL:o};d.push(s)}return w}}));
|