fng-jq-upload 0.12.0-beta.340 → 0.12.0-beta.341

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.
@@ -128,7 +128,15 @@ export function createThumbnailStreamIfNeeded(opts, filename) {
128
128
  // you never know...
129
129
  size += ">";
130
130
  // unsharp can improve the image quality after the resize. See https://legacy.imagemagick.org/Usage/thumbnails/#height.
131
- return ims().thumbnail(size).autoOrient().op("unsharp", "0x.5").inputFormat(type).outputFormat(type);
131
+ var thumbnailStream = ims().thumbnail(size).autoOrient().op("unsharp", "0x.5").inputFormat(type).outputFormat(type);
132
+ // imagemagick-stream's own onerror calls util.isError, which was removed in Node 24, so any ImageMagick error output
133
+ // would throw a TypeError instead of being emitted. Our patches/ fix only applies when developing this package (not
134
+ // in consumers), so replace onerror on the instance - imagemagick-stream reads this.onerror when it wires up the
135
+ // child process. An arrow function also keeps the right `this` where imagemagick-stream passes onerror unbound.
136
+ thumbnailStream.onerror = function (err) {
137
+ thumbnailStream.emit("error", err instanceof Error ? err : new Error(String(err)));
138
+ };
139
+ return thumbnailStream;
132
140
  }
133
141
  function storeInMongoDB(fng, resource, file, filename, schemaThumbnailOpts) {
134
142
  var mongo = fng.mongoose.mongo;
@@ -172,7 +172,15 @@ export function createThumbnailStreamIfNeeded(opts: ISchemaThumbnailOpts, filena
172
172
  // you never know...
173
173
  size += ">";
174
174
  // unsharp can improve the image quality after the resize. See https://legacy.imagemagick.org/Usage/thumbnails/#height.
175
- return ims().thumbnail(size).autoOrient().op("unsharp", "0x.5").inputFormat(type).outputFormat(type);
175
+ const thumbnailStream = ims().thumbnail(size).autoOrient().op("unsharp", "0x.5").inputFormat(type).outputFormat(type);
176
+ // imagemagick-stream's own onerror calls util.isError, which was removed in Node 24, so any ImageMagick error output
177
+ // would throw a TypeError instead of being emitted. Our patches/ fix only applies when developing this package (not
178
+ // in consumers), so replace onerror on the instance - imagemagick-stream reads this.onerror when it wires up the
179
+ // child process. An arrow function also keeps the right `this` where imagemagick-stream passes onerror unbound.
180
+ thumbnailStream.onerror = (err: unknown) => {
181
+ thumbnailStream.emit("error", err instanceof Error ? err : new Error(String(err)));
182
+ };
183
+ return thumbnailStream;
176
184
  }
177
185
 
178
186
  function storeInMongoDB(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fng-jq-upload",
3
- "version": "0.12.0-beta.340",
3
+ "version": "0.12.0-beta.341",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Mark Chapman",
@@ -9,7 +9,7 @@
9
9
  "description": "jQuery file upload plugin for forms-angular, storing data in Mongo. Pretty much a wrapper for BlueImp jquery-file-upload",
10
10
  "scripts": {
11
11
  "test": "grunt test",
12
- "postinstall": "patch-package"
12
+ "prepare": "patch-package"
13
13
  },
14
14
  "dependencies": {
15
15
  "blueimp-file-upload": "^9.34.0",
@@ -22,17 +22,13 @@
22
22
  "@types/busboy": "^1.5.4",
23
23
  "@types/express": "^4.17.21",
24
24
  "@types/node": "^20.14.8",
25
- "angular": "^1.8.3",
26
- "angular-animate": "^1.8.3",
25
+ "angular": "npm:@brickhouse-tech/angular-lts@^1.10.4",
27
26
  "angular-elastic": "^2.5.1",
28
- "angular-messages": "^1.8.3",
29
- "angular-mocks": "^1.8.3",
30
- "angular-sanitize": "^1.8.3",
31
27
  "angular-ui-bootstrap": "1.3.2 || 2.5.6",
32
28
  "async": "^3.2.5",
33
29
  "body-parser": "^1.20.2",
34
30
  "express": "^4.19.2",
35
- "forms-angular": "0.12.0-beta.340",
31
+ "forms-angular": "0.12.0-beta.341",
36
32
  "grunt": "^1.6.1",
37
33
  "grunt-angular-templates": "^1.2.0",
38
34
  "grunt-cli": "^1.5.0",
@@ -68,7 +64,14 @@
68
64
  "path-parse": "npm:@socketregistry/path-parse@^1",
69
65
  "safe-buffer": "npm:@socketregistry/safe-buffer@^1",
70
66
  "safer-buffer": "npm:@socketregistry/safer-buffer@^1",
71
- "side-channel": "npm:@socketregistry/side-channel@^1"
67
+ "side-channel": "npm:@socketregistry/side-channel@^1",
68
+ "angular": "$angular",
69
+ "angular-sanitize": "npm:@brickhouse-tech/angular-lts@^1.10.4",
70
+ "angular-messages": "npm:@brickhouse-tech/angular-lts@^1.10.4",
71
+ "angular-route": "npm:@brickhouse-tech/angular-lts@^1.10.4",
72
+ "angular-cookies": "npm:@brickhouse-tech/angular-lts@^1.10.4",
73
+ "angular-mocks": "npm:@brickhouse-tech/angular-lts@^1.10.4",
74
+ "angular-animate": "npm:@brickhouse-tech/angular-lts@^1.10.4"
72
75
  },
73
76
  "resolutions": {
74
77
  "array-flatten": "npm:@socketregistry/array-flatten@^1",
@@ -98,4 +101,4 @@
98
101
  "uploader"
99
102
  ],
100
103
  "license": "MIT"
101
- }
104
+ }
@@ -97,4 +97,24 @@ describe('API', function () {
97
97
 
98
98
  });
99
99
 
100
+ describe('createThumbnailStreamIfNeeded', function () {
101
+
102
+ it('should emit an error (not throw) when ImageMagick rejects the input', function (done) {
103
+ // imagemagick-stream's own onerror uses util.isError, which no longer exists in Node 24
104
+ const thumbnailStream = jqUploads.createThumbnailStreamIfNeeded({ required: true, height: 50 }, 'bad.png');
105
+ let finished = false;
106
+ thumbnailStream.on('error', function (err) {
107
+ if (finished) {
108
+ return;
109
+ }
110
+ finished = true;
111
+ assert.ok(err instanceof Error);
112
+ done();
113
+ });
114
+ thumbnailStream.resume();
115
+ thumbnailStream.end(Buffer.from('this is not a png'));
116
+ });
117
+
118
+ });
119
+
100
120
 
@@ -8,12 +8,12 @@ module.exports = function (config) {
8
8
  'node_modules/lodash/lodash.js',
9
9
  'node_modules/jquery/dist/jquery.js',
10
10
  'node_modules/angular/angular.js',
11
- 'node_modules/angular-mocks/angular-mocks.js',
11
+ 'node_modules/angular/angular-mocks.js',
12
12
  'node_modules/forms-angular/dist/client/forms-angular.js',
13
13
  'node_modules/angular-elastic/elastic.js',
14
- 'node_modules/angular-sanitize/angular-sanitize.js',
15
- 'node_modules/angular-animate/angular-animate.js',
16
- 'node_modules/angular-messages/angular-messages.js',
14
+ 'node_modules/angular/angular-sanitize.js',
15
+ 'node_modules/angular/angular-animate.js',
16
+ 'node_modules/angular/angular-messages.js',
17
17
  'node_modules/ng-infinite-scroll/build/ng-infinite-scroll.js',
18
18
  'node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js',
19
19
  'node_modules/blueimp-file-upload/js/cors/jquery.postmessage-transport.js',