@molecule/app-file-upload-filepond 1.1.0 → 1.1.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAGV,kBAAkB,EAKnB,MAAM,2BAA2B,CAAA;AAIlC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAsrBhD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,GAAE,cAAmB,GAAG,kBAAkB,CAMtF;AAED,sDAAsD;AACtD,eAAO,MAAM,QAAQ,EAAE,kBAA6C,CAAA"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAGV,kBAAkB,EAKnB,MAAM,2BAA2B,CAAA;AAIlC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AA0rBhD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,GAAE,cAAmB,GAAG,kBAAkB,CAMtF;AAED,sDAAsD;AACtD,eAAO,MAAM,QAAQ,EAAE,kBAA6C,CAAA"}
package/dist/provider.js CHANGED
@@ -227,9 +227,11 @@ function uploadWithFetch(url, method, body, headers, timeout) {
227
227
  * @returns A promise resolving to the data URL string, or undefined.
228
228
  */
229
229
  async function generatePreview(source, maxSize) {
230
- if (typeof FileReader === 'undefined' || typeof FormData.prototype.get !== 'function')
230
+ if (typeof FileReader === 'undefined')
231
231
  return undefined;
232
232
  const formData = new FormData();
233
+ if (typeof formData.get !== 'function')
234
+ return undefined;
233
235
  source.appendTo(formData, 'file');
234
236
  const file = formData.get('file');
235
237
  if (file === null || typeof file === 'string')
@@ -242,12 +244,15 @@ async function generatePreview(source, maxSize) {
242
244
  resolve(undefined);
243
245
  return;
244
246
  }
245
- // If no canvas available (Node), return the raw data URL
246
- if (typeof document === 'undefined' || typeof HTMLCanvasElement === 'undefined') {
247
+ // Return the original preview where canvas resizing is unavailable.
248
+ if (typeof document === 'undefined' ||
249
+ typeof HTMLCanvasElement === 'undefined' ||
250
+ typeof Image !== 'function') {
247
251
  resolve(dataUrl);
248
252
  return;
249
253
  }
250
254
  // Resize using canvas in browser environments
255
+ const browserDocument = document;
251
256
  const img = new Image();
252
257
  img.onload = () => {
253
258
  let { width, height } = img;
@@ -256,7 +261,7 @@ async function generatePreview(source, maxSize) {
256
261
  width = Math.round(width * ratio);
257
262
  height = Math.round(height * ratio);
258
263
  }
259
- const canvas = document.createElement('canvas');
264
+ const canvas = browserDocument.createElement('canvas');
260
265
  canvas.width = width;
261
266
  canvas.height = height;
262
267
  const ctx = canvas.getContext('2d');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-file-upload-filepond",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "FilePond-style file upload provider for @molecule/app-file-upload",
5
5
  "homepage": "https://www.molecule.dev/packages/app-file-upload-filepond",
6
6
  "type": "module",
@@ -40,8 +40,8 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "@molecule/app-file-upload": "1.1.0",
43
- "@molecule/app-filesystem": "1.1.0",
44
- "@molecule/app-i18n": "1.3.0",
43
+ "@molecule/app-filesystem": "1.1.1",
44
+ "@molecule/app-i18n": "1.4.0",
45
45
  "@types/node": "26.6.5",
46
46
  "typescript": "6.0.3",
47
47
  "vitest": "4.1.12"