@fideus-labs/ngff-zarr 0.7.1 → 0.7.3

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.
@@ -54,7 +54,23 @@ function getWorkerProxy() {
54
54
  // inline Blob URL code that assigns workerBlobUrl. In non-bundled mode,
55
55
  // we use a module URL and there's no Blob URL to clean up.
56
56
  workerBlobUrl = null; // Will be overwritten in bundled mode
57
- worker = new Worker(new URL("../workers/compute_omero_worker.js", import.meta.url), { type: "module" });
57
+ worker = (() => {
58
+ const workerCode = `var L=Symbol("Comlink.proxy"),q=Symbol("Comlink.endpoint"),v=Symbol("Comlink.releaseProxy"),y=Symbol("Comlink.finalizer"),B=Symbol("Comlink.thrown"),P=t=>typeof t=="object"&&t!==null||typeof t=="function",H={canHandle:t=>P(t)&&t[L],serialize(t){let{port1:e,port2:n}=new MessageChannel;return w(t,e),[n,[n]]},deserialize(t){return t.start(),j(t)}},\$={canHandle:t=>P(t)&&B in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},I=new Map([["proxy",H],["throw",\$]]);function U(t,e){for(let n of t)if(e===n||n==="*"||n instanceof RegExp&&n.test(e))return!0;return!1}function w(t,e=globalThis,n=["*"]){e.addEventListener("message",function o(r){if(!r||!r.data)return;if(!U(n,r.origin)){console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);return}let{id:a,type:c,path:u}=Object.assign({path:[]},r.data),l=(r.data.argumentList||[]).map(E),i;try{let s=u.slice(0,-1).reduce((f,A)=>f[A],t),F=u.reduce((f,A)=>f[A],t);switch(c){case"GET":i=F;break;case"SET":s[u.slice(-1)[0]]=E(r.data.value),i=!0;break;case"APPLY":i=F.apply(s,l);break;case"CONSTRUCT":{let f=new F(...l);i=Z(f)}break;case"ENDPOINT":{let{port1:f,port2:A}=new MessageChannel;w(t,A),i=V(f,[f])}break;case"RELEASE":i=void 0;break;default:return}}catch(s){i={value:s,[B]:0}}Promise.resolve(i).catch(s=>({value:s,[B]:0})).then(s=>{let[F,f]=p(s);e.postMessage(Object.assign(Object.assign({},F),{id:a}),f),c==="RELEASE"&&(e.removeEventListener("message",o),T(e),y in t&&typeof t[y]=="function"&&t[y]())}).catch(s=>{let[F,f]=p({value:new TypeError("Unserializable return value"),[B]:0});e.postMessage(Object.assign(Object.assign({},F),{id:a}),f)})}),e.start&&e.start()}function G(t){return t.constructor.name==="MessagePort"}function T(t){G(t)&&t.close()}function j(t,e){let n=new Map;return t.addEventListener("message",function(r){let{data:a}=r;if(!a||!a.id)return;let c=n.get(a.id);if(c)try{c(a)}finally{n.delete(a.id)}}),x(t,n,[],e)}function h(t){if(t)throw new Error("Proxy has been released and is not useable")}function k(t){return m(t,new Map,{type:"RELEASE"}).then(()=>{T(t)})}var g=new WeakMap,d="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{let e=(g.get(t)||0)-1;g.set(t,e),e===0&&k(t)});function Q(t,e){let n=(g.get(e)||0)+1;g.set(e,n),d&&d.register(t,e,t)}function W(t){d&&d.unregister(t)}function x(t,e,n=[],o=function(){}){let r=!1,a=new Proxy(o,{get(c,u){if(h(r),u===v)return()=>{W(a),k(t),e.clear(),r=!0};if(u==="then"){if(n.length===0)return{then:()=>a};let l=m(t,e,{type:"GET",path:n.map(i=>i.toString())}).then(E);return l.then.bind(l)}return x(t,e,[...n,u])},set(c,u,l){h(r);let[i,s]=p(l);return m(t,e,{type:"SET",path:[...n,u].map(F=>F.toString()),value:i},s).then(E)},apply(c,u,l){h(r);let i=n[n.length-1];if(i===q)return m(t,e,{type:"ENDPOINT"}).then(E);if(i==="bind")return x(t,e,n.slice(0,-1));let[s,F]=O(l);return m(t,e,{type:"APPLY",path:n.map(f=>f.toString()),argumentList:s},F).then(E)},construct(c,u){h(r);let[l,i]=O(u);return m(t,e,{type:"CONSTRUCT",path:n.map(s=>s.toString()),argumentList:l},i).then(E)}});return Q(a,t),a}function Y(t){return Array.prototype.concat.apply([],t)}function O(t){let e=t.map(p);return[e.map(n=>n[0]),Y(e.map(n=>n[1]))]}var z=new WeakMap;function V(t,e){return z.set(t,e),t}function Z(t){return Object.assign(t,{[L]:!0})}function p(t){for(let[e,n]of I)if(n.canHandle(t)){let[o,r]=n.serialize(t);return[{type:"HANDLER",name:e,value:o},r]}return[{type:"RAW",value:t},z.get(t)||[]]}function E(t){switch(t.type){case"HANDLER":return I.get(t.name).deserialize(t.value);case"RAW":return t.value}}function m(t,e,n,o){return new Promise(r=>{let a=X();e.set(a,r),t.start&&t.start(),t.postMessage(Object.assign({id:a},n),o)})}function X(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var _=["30A2DA","FC4F30","E5AE38","6D904F","8B8B8B","17BECF","9467BD","D62728","1F77B4","E377C2","8C564B","BCBD22","3A0183","004300","0FFFA9","5E0040","C6BDFF","425052","B80080","FFB7B3","7D0200","6126FF","FFFF9A","AEC9AB","00867C","553A00","94FCFF","00BF00","7D00A0","AB7200","91FF00","01BE8A","00457B","C8826F","FF1F83","DD00FF","057400","644461","888FFF","FFB6F4","536237","CE85FF","686A84","BEB4BE","A56089","95D3FF","0100F8","FF8002","8B2945","ADA06D","53458B","C8FFD9","AA4600","FF798F","83D371","909EBF","9400F5","EBD09B","AD8BB1","00634A","FFDC00","887751","7EABA3","000097","F500C6","653329","006678","04E3C8","A737AE","C5DBE1","4D6EFF","9B9301","CD586B","EFDEFE","795A00","5F889A","B4FF92","5E726B","520066","058751","84206F","3C9605","657300","F1A06C","5F5045","BD004A","D06827","D796AB","895DFF","826C76","2B55B9","6E7CBB","E7D5D3","5D0018","7C3B01","80B17D","C8D97D","00E83B","7CB2FF","FF55FF","A42721","1DE4FF","7DAF3B","7B4B91","E0FF48","6B00C4","CDA897","BE63C4","89CDCE","4603C8","5E9279","414A01","05A79D","CF8C37","FFF8D0","435471","B544FF","CF4993","CFA4DF","94D400","A794DA","2DA558","8DE3B6","A4A99D","6C5CB7","FF7E5E","A7838A","AFBED8","2AC4FF","A6683D","F691FE","874B64","FF0C4B","215E23","4292FF","87839D","672D45","B14F41","004E53","5F1B00","AD4167","503267","D6FFFD","7FB5D1","A9B969","FF96CB","C87495","365039","FFD063","5E5862","879476","A978FF","03C863","E7BED4","D4E3D0","876790","897C27","CDDCFF","AA676B","323474","FF5EA9","009BB0","71FFDD","785C38","50659B","CC00B3","577B55","516E7B","015F92","AABDBE","017F99","04DD97","873A2C","F0968E","75C6AA","70695D","CCDC09","AF8557","D80075","9D3F81","D94500","DD6754","5FFF79","D5B173","62265E","BAA23D","D9F2B3","57028F","A19BAA","4D4A27","A4A9FF","ACE8DB","995901","AC00E2","47822F","CBC3AD","00C5B6","615378","336D68","A59280","8499A2","FD5764","7096D2","728D07","7F004C","1530A0","D1C1E2","C985D0","6C454B","7F0024","00A279","B2A9CF","F90000","B0E9FF","939E50","727A82","D92E55","476101","0059FF","7740B5","ACE460","674525","525D51","957368","A9E49A","A30058","D962F6","8E7DCF","FFBD93","A30092","9AFFB9","A7C2FF","F46200","E5F0FF","B89CA4","609694","FF9F35","8C2900","726B32","DF824E","AF7BD5","BC2D00","7B6FA3","484362","C7A3FF","004D28","C4C68E","E048D7","E7E965","E5C10B","00F4F1","9F5BA2","4C41B7","65338E","767E6C","A98A36"];function K(t){return t===1?["FFFFFF"]:Array.from({length:t},(e,n)=>_[n%_.length])}function b(t){let[e,n]=t;if(!(e>=0&&e<=1))throw new Error(\`Low quantile must be between 0 and 1, got \${e}\`);if(!(n>=0&&n<=1))throw new Error(\`High quantile must be between 0 and 1, got \${n}\`);if(e>=n)throw new Error(\`Low quantile must be less than high quantile, got (\${e}, \${n})\`)}function tt(t){if(!/^[0-9A-Fa-f]{6}\$/.test(t))throw new Error(\`Color must be a 6-digit hexadecimal string without # prefix, got '\${t}'\`)}function R(t,e){if(t.length===0)return NaN;if(t.length===1)return t[0];let n=e*(t.length-1),o=Math.floor(n),r=Math.ceil(n),a=n-o;return o===r?t[o]:t[o]*(1-a)+t[r]*a}function N(){return{min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY,sample:[],count:0}}function D(t,e){for(let n=0;n<e.length;n++){let o=e[n];if(!Number.isNaN(o)){if(o<t.min&&(t.min=o),o>t.max&&(t.max=o),t.sample.length<1e4)t.sample.push(o);else{let r=Math.floor(Math.random()*(t.count+1));r<1e4&&(t.sample[r]=o)}t.count++}}}function et(t,e){if(t.count===0)return{min:NaN,max:NaN,qLow:NaN,qHigh:NaN};t.sample.sort((r,a)=>r-a);let n=R(t.sample,e[0]),o=R(t.sample,e[1]);return{min:t.min,max:t.max,qLow:n,qHigh:o}}function S(t,e,n,o){let r=e[o],a=1;for(let s=o+1;s<e.length;s++)a*=e[s];let c=1;for(let s=0;s<o;s++)c*=e[s];let u=c*a,l=new Array(u),i=0;for(let s=0;s<c;s++){let f=s*r*a+n*a;for(let A=0;A<a;A++)l[i++]=t[f+A]}return l}function M(t,e,n,o){let r=t.length,a;if(n!==void 0){if(n.length<r)throw new Error(\`Not enough colors provided. Got \${n.length}, need \${r}.\`);for(let l of n.slice(0,r))tt(l);a=n.slice(0,r)}else a=K(r);let c;if(o!==void 0){if(o.length<r)throw new Error(\`Not enough labels provided. Got \${o.length}, need \${r}.\`);c=o.slice(0,r)}else c=Array(r).fill("");return{channels:t.map((l,i)=>{let s=et(l,e),F={min:s.min,max:s.max,start:s.qLow,end:s.qHigh};return{color:a[i],window:F,label:c[i]}})}}var C=null,nt={initializeComputation(t){b(t.quantiles);let e=t.dims.indexOf("c"),n=e!==-1?t.shape[e]:1;C={accumulators:Array.from({length:n},()=>N()),input:t}},processChunk(t){if(!C)throw new Error("Computation not initialized. Call initializeComputation first.");let{accumulators:e,input:n}=C,{shape:o,dims:r}=n,{chunkData:a}=t,c=r.indexOf("c");if(c!==-1)for(let l=0;l<e.length;l++){let i=S(a,o,l,c);D(e[l],i)}else D(e[0],a)},finalizeComputation(){if(!C)throw new Error("Computation not initialized. Call initializeComputation first.");let{accumulators:t,input:e}=C,n=M(t,e.quantiles,e.colors,e.labels);return C=null,n},computeOmero(t,e){b(e.quantiles);let{shape:n,dims:o,quantiles:r,colors:a,labels:c}=e,u=o.indexOf("c"),l=u!==-1,i=l?n[u]:1,s=Array.from({length:i},()=>N());if(l)for(let F=0;F<i;F++){let f=S(t,n,F,u);D(s[F],f)}else D(s[0],t);return M(s,r,a,c)},ping(){return"pong"}};w(nt);
59
+ /*! Bundled license information:
60
+
61
+ comlink/dist/esm/comlink.mjs:
62
+ (**
63
+ * @license
64
+ * Copyright 2019 Google LLC
65
+ * SPDX-License-Identifier: Apache-2.0
66
+ *)
67
+ */
68
+ `;
69
+ const blob = new Blob([workerCode], { type: "application/javascript" });
70
+ const url = URL.createObjectURL(blob);
71
+ workerBlobUrl = url;
72
+ return new Worker(url, { type: "module" });
73
+ })();
58
74
  workerProxy = Comlink.wrap(worker);
59
75
  }
60
76
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fideus-labs/ngff-zarr",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "TypeScript implementation of ngff-zarr for reading and writing OME-Zarr files",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -8,12 +8,12 @@
8
8
  "types": "./esm/mod.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/thewtex/ngff-zarr.git"
11
+ "url": "git+https://github.com/fideus-labs/ngff-zarr.git"
12
12
  },
13
13
  "bugs": {
14
- "url": "https://github.com/thewtex/ngff-zarr/issues"
14
+ "url": "https://github.com/fideus-labs/ngff-zarr/issues"
15
15
  },
16
- "homepage": "https://github.com/thewtex/ngff-zarr#readme",
16
+ "homepage": "https://github.com/fideus-labs/ngff-zarr#readme",
17
17
  "keywords": [
18
18
  "ome-zarr",
19
19
  "zarr",
@@ -69,7 +69,7 @@
69
69
  "LICENSE.txt"
70
70
  ],
71
71
  "dependencies": {
72
- "@fideus-labs/fizarrita": "^1.0.2",
72
+ "@fideus-labs/fizarrita": "^1.1.1",
73
73
  "@fideus-labs/worker-pool": "^1.0.0",
74
74
  "@itk-wasm/downsample": "^1.8.1",
75
75
  "comlink": "^4.4.2",