From 7508685af5469c339644617f887368549e728982 Mon Sep 17 00:00:00 2001 From: Mark Williams Date: Fri, 16 Jan 2026 09:20:31 +0000 Subject: [PATCH] LIMS-2042: Remove zlibjs --- client/package-lock.json | 11 +---------- client/package.json | 3 +-- .../src/js/modules/dc/views/mapmodelview.js | 13 +++++++------ .../src/js/modules/dc/views/reciprocalview.js | 19 +++++++++---------- client/webpack.config.js | 4 ---- 5 files changed, 18 insertions(+), 32 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index 3c41082c6..d6a0a2b4b 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -48,8 +48,7 @@ "vee-validate": "^2.2.15", "vue": "^2.6.10", "vue-router": "^3.4.3", - "vuex": "^3.5.1", - "zlibjs": "^0.1.7" + "vuex": "^3.5.1" }, "devDependencies": { "@babel/preset-env": "^7.21.5", @@ -17591,14 +17590,6 @@ "dependencies": { "cwise-compiler": "^1.0.0" } - }, - "node_modules/zlibjs": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/zlibjs/-/zlibjs-0.1.8.tgz", - "integrity": "sha512-K6TlrudzpjDHG6/uzyq8X9/2UFrcSLKhqxZc2nP1fc85vJdhPVehsyElowkI6sqYdF/QA3HA81oEBBLKXCyENA==", - "engines": { - "node": "*" - } } } } diff --git a/client/package.json b/client/package.json index 4808d17de..d292fece6 100644 --- a/client/package.json +++ b/client/package.json @@ -96,8 +96,7 @@ "vee-validate": "^2.2.15", "vue": "^2.6.10", "vue-router": "^3.4.3", - "vuex": "^3.5.1", - "zlibjs": "^0.1.7" + "vuex": "^3.5.1" }, "engines": { "node": "^18.0.0" diff --git a/client/src/js/modules/dc/views/mapmodelview.js b/client/src/js/modules/dc/views/mapmodelview.js index 595135562..52a4810ab 100644 --- a/client/src/js/modules/dc/views/mapmodelview.js +++ b/client/src/js/modules/dc/views/mapmodelview.js @@ -1,11 +1,11 @@ define(['marionette', - 'uglymol', 'gzip', + 'uglymol', 'modules/dc/collections/downstreams', 'modules/dc/collections/dimplepeaks', 'modules/dc/views/dimplepeaktable', 'templates/dc/mapmodelview.html', "./uglymolhelper" - ], function(Marionette, Uglymol, zlib, + ], function(Marionette, Uglymol, DownStreams, DIMPLEPeaks, DIMPLEPeakTable, template, defaultViewerOptions) { return Marionette.LayoutView.extend({ @@ -42,14 +42,15 @@ define(['marionette', doLoadMaps: function(id, cb) { var self = this var xhr = this.xhrWithStatus('Downloading Map '+id) - xhr.onload = function() { + xhr.onload = async function() { if (xhr.status == 0 || xhr.status != 200) { this.onerror(xhr.status) } else { - var gunzip = new zlib.Zlib.Gunzip(new Uint8Array(this.response)) - var plain = gunzip.decompress() - self.viewer.load_map_from_buffer(plain.buffer, { format: 'ccp4', diff_map: id == 2 }) + const ds = new DecompressionStream('gzip') + const stream = new Response(this.response).body.pipeThrough(ds) + const plain = await new Response(stream).arrayBuffer() + self.viewer.load_map_from_buffer(plain, { format: 'ccp4', diff_map: id == 2 }) } self.mapsLoaded++ diff --git a/client/src/js/modules/dc/views/reciprocalview.js b/client/src/js/modules/dc/views/reciprocalview.js index d80f4763a..39bfc8b90 100644 --- a/client/src/js/modules/dc/views/reciprocalview.js +++ b/client/src/js/modules/dc/views/reciprocalview.js @@ -1,8 +1,8 @@ define(['marionette', 'collections/attachments', - 'uglymol', 'gzip', + 'uglymol', 'templates/dc/mapmodelview.html', - "./uglymolhelper"], function(Marionette, Attachments, Uglymol, zlib, + "./uglymolhelper"], function(Marionette, Attachments, Uglymol, template, defaultViewerOptions) { return Marionette.LayoutView.extend({ @@ -23,7 +23,6 @@ define(['marionette', res: 'select[name=residue]', }, - loadData: function() { if (!this.attachments.length) { this.ui.hud.text('No reciprocal space data for this datacollection') @@ -32,14 +31,14 @@ define(['marionette', var xhr = this.xhrWithStatus('Downloading Reciprocal Space Data') var self = this - - xhr.onload = function() { - var gunzip = new zlib.Zlib.Gunzip(new Uint8Array(this.response)) - var plain = gunzip.decompress() - var url = URL.createObjectURL(new Blob([plain], {type: 'text'})) + + xhr.onload = async function () { + const ds = new DecompressionStream('gzip') + const stream = new Response(this.response).body.pipeThrough(ds) + const plain = await new Response(stream).arrayBuffer() + const url = URL.createObjectURL(new Blob([plain], {type: 'text'})) self.viewer.load_data(url) } - var attachment = this.attachments.at(0) xhr.open('GET', app.apiurl+'/download/attachment/id/'+this.model.get('ID')+'/aid/'+attachment.get('DATACOLLECTIONFILEATTACHMENTID')) @@ -76,4 +75,4 @@ define(['marionette', }) -}) \ No newline at end of file +}) diff --git a/client/webpack.config.js b/client/webpack.config.js index 2604ca63a..4b5026a6d 100644 --- a/client/webpack.config.js +++ b/client/webpack.config.js @@ -66,10 +66,6 @@ module.exports = (env, argv) => ({ // heatmap in npm has dependency on canvas/node-gyp... so use old one for now heatmap: 'vendor/hmap', - // gunzip is actually the zlib library - // https://npm.taobao.org/package/zlibjs - gzip: 'zlibjs/bin/gunzip.min', - markdown: 'markdown/lib/markdown', // Vue packages from npm (vee-validate requires promise polyfill - also npm)