From 6ec20c801954731c7a962a1aea6731e6114aef6a Mon Sep 17 00:00:00 2001 From: godlikemouse Date: Mon, 15 Jun 2020 10:09:37 -0600 Subject: [PATCH 01/10] APP-2163 updated jszip version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8bf6a416..9f9aa5ad 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ }, "dependencies": { "dbf": "0.1.4", - "jszip": "2.5.0" + "jszip": "3.2.0" }, "devDependencies": { "browserify": "^13.0.0", From b9e9d1be431a4c07e5d1065ea833bdea2a755950 Mon Sep 17 00:00:00 2001 From: godlikemouse Date: Mon, 15 Jun 2020 10:11:12 -0600 Subject: [PATCH 02/10] 0.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f9aa5ad..5cb0d3d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shp-write", - "version": "0.3.2", + "version": "0.3.3", "description": "write shapefiles from pure javascript", "main": "index.js", "scripts": { From 642928e693773f7ab213ec03664b0c786886f25f Mon Sep 17 00:00:00 2001 From: godlikemouse Date: Mon, 15 Jun 2020 11:19:25 -0600 Subject: [PATCH 03/10] APP-2163 Added file saver dep and save as --- package.json | 3 ++- src/download.js | 10 ++++++++-- src/zip.js | 7 +++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 5cb0d3d6..75a006a5 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ }, "dependencies": { "dbf": "0.1.4", - "jszip": "3.2.0" + "jszip": "3.2.0", + "file-saver": "^2.0.2" }, "devDependencies": { "browserify": "^13.0.0", diff --git a/src/download.js b/src/download.js index d198addf..feb6f4bc 100644 --- a/src/download.js +++ b/src/download.js @@ -1,6 +1,12 @@ var zip = require('./zip'); +var FileSaver = require('file-saver'); module.exports = function(gj, options) { - var content = zip(gj, options); - location.href = 'data:application/zip;base64,' + content; + + zip(gj, options) + .then(content => { + options = options ? options : {}; + const filename = options.filename ? options.filename : "download.zip"; + FileSaver.saveAs(content, filename) + }); }; diff --git a/src/zip.js b/src/zip.js index b8e89d85..85ca2a5a 100644 --- a/src/zip.js +++ b/src/zip.js @@ -28,11 +28,14 @@ module.exports = function(gj, options) { } }); - var generateOptions = { compression:'STORE' }; + const generateOptions = { + type: "base64" + }; if (!process.browser) { generateOptions.type = 'nodebuffer'; } - return zip.generate(generateOptions); + //return zip.generate(generateOptions); + return zip.generateAsync(generateOptions); }; From 7a19daa7d5820378df8331e1806183bf9932a2b2 Mon Sep 17 00:00:00 2001 From: godlikemouse Date: Mon, 15 Jun 2020 11:19:51 -0600 Subject: [PATCH 04/10] 0.3.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 75a006a5..9cab83db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shp-write", - "version": "0.3.3", + "version": "0.3.4", "description": "write shapefiles from pure javascript", "main": "index.js", "scripts": { From 0849f103caa3c7f0927a470c96e6f861941c3a60 Mon Sep 17 00:00:00 2001 From: godlikemouse Date: Mon, 15 Jun 2020 12:34:02 -0600 Subject: [PATCH 05/10] APP-2163 Fixed download type and file name --- src/download.js | 5 ++--- src/zip.js | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/download.js b/src/download.js index feb6f4bc..3b2b8382 100644 --- a/src/download.js +++ b/src/download.js @@ -2,11 +2,10 @@ var zip = require('./zip'); var FileSaver = require('file-saver'); module.exports = function(gj, options) { - zip(gj, options) .then(content => { options = options ? options : {}; - const filename = options.filename ? options.filename : "download.zip"; - FileSaver.saveAs(content, filename) + const filename = options.filename ? `${options.filename}.zip` : "download.zip"; + FileSaver.saveAs(content, filename); }); }; diff --git a/src/zip.js b/src/zip.js index 85ca2a5a..1fc9ac63 100644 --- a/src/zip.js +++ b/src/zip.js @@ -19,7 +19,7 @@ module.exports = function(gj, options) { // geometries l.geometries, function(err, files) { - var fileName = options && options.types[l.type.toLowerCase()] ? options.types[l.type.toLowerCase()] : l.type; + var fileName = options && options.types && options.types[l.type.toLowerCase()] ? options.types[l.type.toLowerCase()] : l.type; layers.file(fileName + '.shp', files.shp.buffer, { binary: true }); layers.file(fileName + '.shx', files.shx.buffer, { binary: true }); layers.file(fileName + '.dbf', files.dbf.buffer, { binary: true }); @@ -29,13 +29,12 @@ module.exports = function(gj, options) { }); const generateOptions = { - type: "base64" + type: "blob" }; if (!process.browser) { generateOptions.type = 'nodebuffer'; } - //return zip.generate(generateOptions); return zip.generateAsync(generateOptions); }; From 9039712b106fa61972e050145223e7828f13730f Mon Sep 17 00:00:00 2001 From: godlikemouse Date: Mon, 15 Jun 2020 12:34:36 -0600 Subject: [PATCH 06/10] 0.3.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9cab83db..7b52e449 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shp-write", - "version": "0.3.4", + "version": "0.3.5", "description": "write shapefiles from pure javascript", "main": "index.js", "scripts": { From ed2263169e61e224ea375a02f24e8b410c5f9fd9 Mon Sep 17 00:00:00 2001 From: Jason Graves <52926753+novi-jgraves@users.noreply.github.com> Date: Mon, 15 Jun 2020 12:42:31 -0600 Subject: [PATCH 07/10] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b04c03e0..630d4ac1 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # shp-write Writes shapefile in pure javascript. Uses [dbf](https://github.com/tmcw/dbf) -for the data component, and [jsZIP](http://stuk.github.io/jszip/) to generate +for the data component, [FileSaver](https://github.com/eligrey/FileSaver.js/) and [jsZIP](http://stuk.github.io/jszip/) to generate ZIP file downloads in-browser. ## Usage @@ -22,7 +22,7 @@ Or in a browser support * Geometries: Point, LineString, Polygon, MultiLineString, MultiPolygon * Tabular-style properties export with Shapefile's field name length limit -* Uses jsZip for ZIP files, but [compression is buggy](https://github.com/Stuk/jszip/issues/53) so it uses STORE instead of DEFLATE. +* Uses jsZip for ZIP files. ## Example @@ -36,7 +36,8 @@ var options = { point: 'mypoints', polygon: 'mypolygons', line: 'mylines' - } + }, + filename: 'my-filename' } // a GeoJSON bridge for features shpwrite.download({ From 698fa03755b42582f6787764c56d99f5a5f1fdb7 Mon Sep 17 00:00:00 2001 From: Jason Graves <52926753+novi-jgraves@users.noreply.github.com> Date: Mon, 15 Jun 2020 12:43:32 -0600 Subject: [PATCH 08/10] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 630d4ac1..8ceb59eb 100644 --- a/README.md +++ b/README.md @@ -105,3 +105,4 @@ object. ## Contributors * Nick Baugh +* Jason Graves From 2c4114d352793ed5a7efb5e62db7d5a51b3dbe71 Mon Sep 17 00:00:00 2001 From: godlikemouse Date: Mon, 15 Jun 2020 12:44:25 -0600 Subject: [PATCH 09/10] APP-2163 Updated contributors --- package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7b52e449..e91c22e2 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,11 @@ { "name": "Nick Baugh", "email": "niftylettuce@gmail.com" - } + }, + { + "name": "Jason Graves", + "email": "jgraves@novilabs.com" + }, ], "license": "BSD-2-Clause", "bugs": { From 25a4fe427c966e1058f16749f957b69b66e4a29e Mon Sep 17 00:00:00 2001 From: godlikemouse Date: Mon, 15 Jun 2020 12:51:30 -0600 Subject: [PATCH 10/10] APP-2163 Fixed trailing comma --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e91c22e2..513f7267 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ { "name": "Jason Graves", "email": "jgraves@novilabs.com" - }, + } ], "license": "BSD-2-Clause", "bugs": {