@scaleflex/widget-thumbnail-generator 4.0.7 → 4.1.0
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.
- package/CHANGELOG.md +6994 -6982
- package/LICENSE +21 -21
- package/README.md +181 -181
- package/assets/CHECKERED_BACKGROUND.svg +2507 -2507
- package/lib/index.js +37 -37
- package/package.json +3 -3
- package/types/index.d.ts +16 -16
package/lib/index.js
CHANGED
|
@@ -35,8 +35,8 @@ import defaultLocale from './defaultLocale';
|
|
|
35
35
|
// import { version } from '../package.json'
|
|
36
36
|
// import packageInfo from '../package.json'
|
|
37
37
|
|
|
38
|
-
/**
|
|
39
|
-
* The Thumbnail Generator plugin
|
|
38
|
+
/**
|
|
39
|
+
* The Thumbnail Generator plugin
|
|
40
40
|
*/
|
|
41
41
|
var ThumbnailGenerator = /*#__PURE__*/function (_Plugin) {
|
|
42
42
|
// static VERSION = packageInfo.version
|
|
@@ -59,8 +59,8 @@ var ThumbnailGenerator = /*#__PURE__*/function (_Plugin) {
|
|
|
59
59
|
_this.addToQueue(file.id);
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
|
-
/**
|
|
63
|
-
* Cancel a lazy request for a thumbnail if the thumbnail has not yet been generated.
|
|
62
|
+
/**
|
|
63
|
+
* Cancel a lazy request for a thumbnail if the thumbnail has not yet been generated.
|
|
64
64
|
*/
|
|
65
65
|
_defineProperty(_this, "onCancelRequest", function (file) {
|
|
66
66
|
var index = _this.queue.indexOf(file.id);
|
|
@@ -68,8 +68,8 @@ var ThumbnailGenerator = /*#__PURE__*/function (_Plugin) {
|
|
|
68
68
|
_this.queue.splice(index, 1);
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
-
/**
|
|
72
|
-
* Clean up the thumbnail for a file. Cancel lazy requests and free the thumbnail URL.
|
|
71
|
+
/**
|
|
72
|
+
* Clean up the thumbnail for a file. Cancel lazy requests and free the thumbnail URL.
|
|
73
73
|
*/
|
|
74
74
|
_defineProperty(_this, "onFileRemoved", function (file) {
|
|
75
75
|
var index = _this.queue.indexOf(file.id);
|
|
@@ -150,13 +150,13 @@ var ThumbnailGenerator = /*#__PURE__*/function (_Plugin) {
|
|
|
150
150
|
this.i18n = this.translator.translate.bind(this.translator);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
/**
|
|
154
|
-
* Create a thumbnail for the given Filerobot file object.
|
|
155
|
-
*
|
|
156
|
-
* @param {{data: Blob}} file
|
|
157
|
-
* @param {number} targetWidth
|
|
158
|
-
* @param {number} targetHeight
|
|
159
|
-
* @returns {Promise}
|
|
153
|
+
/**
|
|
154
|
+
* Create a thumbnail for the given Filerobot file object.
|
|
155
|
+
*
|
|
156
|
+
* @param {{data: Blob}} file
|
|
157
|
+
* @param {number} targetWidth
|
|
158
|
+
* @param {number} targetHeight
|
|
159
|
+
* @returns {Promise}
|
|
160
160
|
*/
|
|
161
161
|
}, {
|
|
162
162
|
key: "createThumbnail",
|
|
@@ -191,11 +191,11 @@ var ThumbnailGenerator = /*#__PURE__*/function (_Plugin) {
|
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
/**
|
|
195
|
-
* Get the new calculated dimensions for the given image and a target width
|
|
196
|
-
* or height. If both width and height are given, only width is taken into
|
|
197
|
-
* account. If neither width nor height are given, the default dimension
|
|
198
|
-
* is used.
|
|
194
|
+
/**
|
|
195
|
+
* Get the new calculated dimensions for the given image and a target width
|
|
196
|
+
* or height. If both width and height are given, only width is taken into
|
|
197
|
+
* account. If neither width nor height are given, the default dimension
|
|
198
|
+
* is used.
|
|
199
199
|
*/
|
|
200
200
|
}, {
|
|
201
201
|
key: "getProportionalDimensions",
|
|
@@ -215,9 +215,9 @@ var ThumbnailGenerator = /*#__PURE__*/function (_Plugin) {
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
/**
|
|
219
|
-
* Make sure the image doesn’t exceed browser/device canvas limits.
|
|
220
|
-
* For ios with 256 RAM and ie
|
|
218
|
+
/**
|
|
219
|
+
* Make sure the image doesn’t exceed browser/device canvas limits.
|
|
220
|
+
* For ios with 256 RAM and ie
|
|
221
221
|
*/
|
|
222
222
|
}, {
|
|
223
223
|
key: "protect",
|
|
@@ -248,10 +248,10 @@ var ThumbnailGenerator = /*#__PURE__*/function (_Plugin) {
|
|
|
248
248
|
return image;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
/**
|
|
252
|
-
* Resize an image to the target `width` and `height`.
|
|
253
|
-
*
|
|
254
|
-
* Returns a Canvas with the resized image on it.
|
|
251
|
+
/**
|
|
252
|
+
* Resize an image to the target `width` and `height`.
|
|
253
|
+
*
|
|
254
|
+
* Returns a Canvas with the resized image on it.
|
|
255
255
|
*/
|
|
256
256
|
}, {
|
|
257
257
|
key: "resizeImage",
|
|
@@ -292,11 +292,11 @@ var ThumbnailGenerator = /*#__PURE__*/function (_Plugin) {
|
|
|
292
292
|
ctx.drawImage(image, canvas.width / 2 - imgWidth / 2, canvas.height / 2 - imgHeight / 2, imgWidth, imgHeight);
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
/**
|
|
296
|
-
* Makes sure that the image dimensions wouldn't exceed the limits &
|
|
297
|
-
* Adds a blurry background of the image to the target `width` and `height`.
|
|
298
|
-
*
|
|
299
|
-
* adds a Canvas with the image and checkered or blurry background.
|
|
295
|
+
/**
|
|
296
|
+
* Makes sure that the image dimensions wouldn't exceed the limits &
|
|
297
|
+
* Adds a blurry background of the image to the target `width` and `height`.
|
|
298
|
+
*
|
|
299
|
+
* adds a Canvas with the image and checkered or blurry background.
|
|
300
300
|
*/
|
|
301
301
|
}, {
|
|
302
302
|
key: "addBackground",
|
|
@@ -349,11 +349,11 @@ var ThumbnailGenerator = /*#__PURE__*/function (_Plugin) {
|
|
|
349
349
|
});
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
/**
|
|
353
|
-
* Save a <canvas> element's content to a Blob object.
|
|
354
|
-
*
|
|
355
|
-
* @param {HTMLCanvasElement} canvas
|
|
356
|
-
* @returns {Promise}
|
|
352
|
+
/**
|
|
353
|
+
* Save a <canvas> element's content to a Blob object.
|
|
354
|
+
*
|
|
355
|
+
* @param {HTMLCanvasElement} canvas
|
|
356
|
+
* @returns {Promise}
|
|
357
357
|
*/
|
|
358
358
|
}, {
|
|
359
359
|
key: "canvasToBlob",
|
|
@@ -385,8 +385,8 @@ var ThumbnailGenerator = /*#__PURE__*/function (_Plugin) {
|
|
|
385
385
|
});
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
-
/**
|
|
389
|
-
* Set the preview URL for a file.
|
|
388
|
+
/**
|
|
389
|
+
* Set the preview URL for a file.
|
|
390
390
|
*/
|
|
391
391
|
}, {
|
|
392
392
|
key: "setPreviewURL",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/widget-thumbnail-generator",
|
|
3
3
|
"description": "Scaleflex plugin that generates small previews of images to show on your upload UI.",
|
|
4
|
-
"version": "4.0
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@scaleflex/widget-utils": "^4.0
|
|
18
|
+
"@scaleflex/widget-utils": "^4.1.0",
|
|
19
19
|
"math-log2": "^2.0.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@scaleflex/widget-core": "^0.0.3"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "471120d67066617a0d8824eae11b07d1f2259473"
|
|
25
25
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import Filerobot = require("@scaleflex/widget-core");
|
|
2
|
-
import ThumbnailGeneratorLocale = require("./generatedLocale");
|
|
3
|
-
|
|
4
|
-
declare module ThumbnailGenerator {
|
|
5
|
-
interface ThumbnailGeneratorOptions extends Filerobot.PluginOptions {
|
|
6
|
-
thumbnailWidth?: number;
|
|
7
|
-
thumbnailHeight?: number;
|
|
8
|
-
waitForThumbnailsBeforeUpload?: boolean;
|
|
9
|
-
lazy?: boolean;
|
|
10
|
-
locale?: ThumbnailGeneratorLocale;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare class ThumbnailGenerator extends Filerobot.Plugin<ThumbnailGenerator.ThumbnailGeneratorOptions> {}
|
|
15
|
-
|
|
16
|
-
export = ThumbnailGenerator;
|
|
1
|
+
import Filerobot = require("@scaleflex/widget-core");
|
|
2
|
+
import ThumbnailGeneratorLocale = require("./generatedLocale");
|
|
3
|
+
|
|
4
|
+
declare module ThumbnailGenerator {
|
|
5
|
+
interface ThumbnailGeneratorOptions extends Filerobot.PluginOptions {
|
|
6
|
+
thumbnailWidth?: number;
|
|
7
|
+
thumbnailHeight?: number;
|
|
8
|
+
waitForThumbnailsBeforeUpload?: boolean;
|
|
9
|
+
lazy?: boolean;
|
|
10
|
+
locale?: ThumbnailGeneratorLocale;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare class ThumbnailGenerator extends Filerobot.Plugin<ThumbnailGenerator.ThumbnailGeneratorOptions> {}
|
|
15
|
+
|
|
16
|
+
export = ThumbnailGenerator;
|