@scaleflex/widget-core 4.8.5 → 4.8.7
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/LICENSE +21 -21
- package/README.md +1201 -1201
- package/dist/style.css +10 -6
- package/dist/style.min.css +1 -1
- package/lib/Client.js +7 -7
- package/lib/Plugin.js +40 -40
- package/lib/Providers.js +8 -8
- package/lib/SassKeyRenewer.js +12 -12
- package/lib/_common.scss +243 -243
- package/lib/_utils.scss +38 -38
- package/lib/_variables.scss +63 -63
- package/lib/index.js +203 -197
- package/lib/slices/common.slice.js +9 -9
- package/lib/slices/info.slice.js +10 -10
- package/lib/slices/uploads.slice.js +9 -9
- package/lib/slices/user.slice.js +9 -9
- package/lib/style.scss +3 -3
- package/package.json +38 -38
- package/types/index.d.ts +301 -301
- package/CHANGELOG.md +0 -7660
package/lib/index.js
CHANGED
|
@@ -40,6 +40,7 @@ import { getBackendTranslations } from '@scaleflex/widget-utils/lib/i18n.client'
|
|
|
40
40
|
import extractFileDataNoBlob from '@scaleflex/widget-utils/lib/extractFileDataNoBlob';
|
|
41
41
|
import getFileExtension from '@scaleflex/widget-utils/lib/getFileExtension';
|
|
42
42
|
import convertBytesToMb from '@scaleflex/widget-utils/lib/convertBytesToMb';
|
|
43
|
+
import getNonce from '@scaleflex/widget-utils/lib/getNonce';
|
|
43
44
|
import { justErrorsLogger, debugLogger } from './loggers';
|
|
44
45
|
import Plugin from './Plugin'; // Exported from here.
|
|
45
46
|
import defaultLocale from './defaultLocale';
|
|
@@ -79,16 +80,16 @@ var RestrictionError = /*#__PURE__*/function (_Error) {
|
|
|
79
80
|
_inherits(RestrictionError, _Error);
|
|
80
81
|
return _createClass(RestrictionError);
|
|
81
82
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
82
|
-
/**
|
|
83
|
-
* filerobot Core module.
|
|
84
|
-
* Manages plugins, state updates, acts as an event bus,
|
|
85
|
-
* adds/removes files and metadata.
|
|
83
|
+
/**
|
|
84
|
+
* filerobot Core module.
|
|
85
|
+
* Manages plugins, state updates, acts as an event bus,
|
|
86
|
+
* adds/removes files and metadata.
|
|
86
87
|
*/
|
|
87
88
|
var ScaleflexWidget = /*#__PURE__*/function () {
|
|
88
|
-
/**
|
|
89
|
-
* Instantiate filerobot
|
|
90
|
-
*
|
|
91
|
-
* @param {object} opts — filerobot options
|
|
89
|
+
/**
|
|
90
|
+
* Instantiate filerobot
|
|
91
|
+
*
|
|
92
|
+
* @param {object} opts — filerobot options
|
|
92
93
|
*/
|
|
93
94
|
function ScaleflexWidget(opts) {
|
|
94
95
|
var _this2 = this;
|
|
@@ -238,7 +239,8 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
238
239
|
photo_uri: '',
|
|
239
240
|
uuid: ''
|
|
240
241
|
},
|
|
241
|
-
sassKeyRenewerEnabled: true
|
|
242
|
+
sassKeyRenewerEnabled: true,
|
|
243
|
+
nonce: undefined
|
|
242
244
|
};
|
|
243
245
|
|
|
244
246
|
// Merge default options with the ones set by user,
|
|
@@ -249,6 +251,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
249
251
|
restrictions: _objectSpread(_objectSpread({}, defaultOptions.restrictions), opts && opts.restrictions),
|
|
250
252
|
userInfo: _objectSpread(_objectSpread({}, defaultOptions.userInfo), (opts === null || opts === void 0 ? void 0 : opts.userInfo) || {})
|
|
251
253
|
});
|
|
254
|
+
this.opts.nonce = getNonce(this.opts.nonce);
|
|
255
|
+
if (this.opts.nonce && typeof globalThis !== 'undefined') {
|
|
256
|
+
globalThis.__webpack_nonce__ = this.opts.nonce;
|
|
257
|
+
}
|
|
252
258
|
this.opts.apiEndpoint = (this.opts.apiEndpoint || '').trim().replace(/\/$/, '');
|
|
253
259
|
this.opts.adminApiEndpoint = (this.opts.adminApiEndpoint || '').trim().replace(/\/$/, '');
|
|
254
260
|
this.opts.shareApiEndpoint = (this.opts.shareApiEndpoint || '').trim().replace(/\/$/, '');
|
|
@@ -286,9 +292,9 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
286
292
|
throw new TypeError('`restrictions.allowedFileTypes` must be an array');
|
|
287
293
|
}
|
|
288
294
|
|
|
289
|
-
/**
|
|
290
|
-
* saveMissing translations is temporary disabled. Until we find a good solution how to improve automation.
|
|
291
|
-
* Previous approach doesn't work thus we switched to manual translations adding to Wordplex directly by developers.
|
|
295
|
+
/**
|
|
296
|
+
* saveMissing translations is temporary disabled. Until we find a good solution how to improve automation.
|
|
297
|
+
* Previous approach doesn't work thus we switched to manual translations adding to Wordplex directly by developers.
|
|
292
298
|
*/
|
|
293
299
|
// Translator.IS_DEV = this.opts.dev
|
|
294
300
|
|
|
@@ -296,10 +302,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
296
302
|
|
|
297
303
|
// Container for different types of plugins
|
|
298
304
|
this.plugins = {};
|
|
299
|
-
/*
|
|
300
|
-
* Container for the current uploads operations
|
|
301
|
-
* (not files but the upload process/operation itself that can contain multiple files)
|
|
302
|
-
* made as a property in the class as it doesn't need to cause a render or accessed externally.
|
|
305
|
+
/*
|
|
306
|
+
* Container for the current uploads operations
|
|
307
|
+
* (not files but the upload process/operation itself that can contain multiple files)
|
|
308
|
+
* made as a property in the class as it doesn't need to cause a render or accessed externally.
|
|
303
309
|
*/
|
|
304
310
|
this.uploadOperations = {};
|
|
305
311
|
this.getGlobalState = this.getGlobalState.bind(this);
|
|
@@ -403,10 +409,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
403
409
|
}));
|
|
404
410
|
}
|
|
405
411
|
|
|
406
|
-
/**
|
|
407
|
-
* Iterate on all plugins and run `update` on them.
|
|
408
|
-
* Called each time state changes.
|
|
409
|
-
*
|
|
412
|
+
/**
|
|
413
|
+
* Iterate on all plugins and run `update` on them.
|
|
414
|
+
* Called each time state changes.
|
|
415
|
+
*
|
|
410
416
|
*/
|
|
411
417
|
}, {
|
|
412
418
|
key: "updateAll",
|
|
@@ -416,9 +422,9 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
416
422
|
});
|
|
417
423
|
}
|
|
418
424
|
|
|
419
|
-
/**
|
|
420
|
-
* creates & assigns the redux store
|
|
421
|
-
*
|
|
425
|
+
/**
|
|
426
|
+
* creates & assigns the redux store
|
|
427
|
+
*
|
|
422
428
|
*/
|
|
423
429
|
}, {
|
|
424
430
|
key: "_storeInit",
|
|
@@ -433,9 +439,9 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
433
439
|
}
|
|
434
440
|
}
|
|
435
441
|
|
|
436
|
-
/**
|
|
437
|
-
* injects a sub-reducer into the root reducer (mostly used for injecting a plugin's reducer)
|
|
438
|
-
*
|
|
442
|
+
/**
|
|
443
|
+
* injects a sub-reducer into the root reducer (mostly used for injecting a plugin's reducer)
|
|
444
|
+
*
|
|
439
445
|
*/
|
|
440
446
|
}, {
|
|
441
447
|
key: "_injectReducer",
|
|
@@ -443,9 +449,9 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
443
449
|
this.store.injectReducer(key, reducerFn);
|
|
444
450
|
}
|
|
445
451
|
|
|
446
|
-
/**
|
|
447
|
-
* injects a sub-reducer into the root reducer (mostly used for injecting a plugin's reducer)
|
|
448
|
-
*
|
|
452
|
+
/**
|
|
453
|
+
* injects a sub-reducer into the root reducer (mostly used for injecting a plugin's reducer)
|
|
454
|
+
*
|
|
449
455
|
*/
|
|
450
456
|
}, {
|
|
451
457
|
key: "_removeReducer",
|
|
@@ -453,9 +459,9 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
453
459
|
this.store.removeReducer(key);
|
|
454
460
|
}
|
|
455
461
|
|
|
456
|
-
/**
|
|
457
|
-
* Triggers the action to call store's reducers
|
|
458
|
-
* @param {Function} actionCreator
|
|
462
|
+
/**
|
|
463
|
+
* Triggers the action to call store's reducers
|
|
464
|
+
* @param {Function} actionCreator
|
|
459
465
|
*/
|
|
460
466
|
}, {
|
|
461
467
|
key: "dispatch",
|
|
@@ -463,12 +469,12 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
463
469
|
return this.store.dispatch(actionCreator);
|
|
464
470
|
}
|
|
465
471
|
|
|
466
|
-
/**
|
|
467
|
-
* Updates common state with a patch
|
|
468
|
-
* any state that not organized in a sub-reducer/slice
|
|
469
|
-
*
|
|
470
|
-
* @param {object} patch {foo: 'bar'}
|
|
471
|
-
// * TODO: To check it
|
|
472
|
+
/**
|
|
473
|
+
* Updates common state with a patch
|
|
474
|
+
* any state that not organized in a sub-reducer/slice
|
|
475
|
+
*
|
|
476
|
+
* @param {object} patch {foo: 'bar'}
|
|
477
|
+
// * TODO: To check it
|
|
472
478
|
*/
|
|
473
479
|
}, {
|
|
474
480
|
key: "setCoreCommonState",
|
|
@@ -476,10 +482,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
476
482
|
this.dispatch(coreCommonStateUpdated(patch));
|
|
477
483
|
}
|
|
478
484
|
|
|
479
|
-
/**
|
|
480
|
-
* Returns current state of whole redux's store (global state).
|
|
481
|
-
*
|
|
482
|
-
* @returns {object}
|
|
485
|
+
/**
|
|
486
|
+
* Returns current state of whole redux's store (global state).
|
|
487
|
+
*
|
|
488
|
+
* @returns {object}
|
|
483
489
|
*/
|
|
484
490
|
}, {
|
|
485
491
|
key: "getGlobalState",
|
|
@@ -487,10 +493,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
487
493
|
return this.store.getState();
|
|
488
494
|
}
|
|
489
495
|
|
|
490
|
-
/**
|
|
491
|
-
* Returns current core's slice state.
|
|
492
|
-
*
|
|
493
|
-
* @returns {object}
|
|
496
|
+
/**
|
|
497
|
+
* Returns current core's slice state.
|
|
498
|
+
*
|
|
499
|
+
* @returns {object}
|
|
494
500
|
*/
|
|
495
501
|
}, {
|
|
496
502
|
key: "getCoreState",
|
|
@@ -498,10 +504,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
498
504
|
return this.getGlobalState()[PLUGINS_IDS.CORE];
|
|
499
505
|
}
|
|
500
506
|
|
|
501
|
-
/**
|
|
502
|
-
* Returns current core's slice state.
|
|
503
|
-
*
|
|
504
|
-
* @returns {object}
|
|
507
|
+
/**
|
|
508
|
+
* Returns current core's slice state.
|
|
509
|
+
*
|
|
510
|
+
* @returns {object}
|
|
505
511
|
*/
|
|
506
512
|
}, {
|
|
507
513
|
key: "getCoreCommonState",
|
|
@@ -509,10 +515,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
509
515
|
return selectCommonState(this.getGlobalState());
|
|
510
516
|
}
|
|
511
517
|
|
|
512
|
-
/**
|
|
513
|
-
* Returns current uploads
|
|
514
|
-
*
|
|
515
|
-
* @returns {object}
|
|
518
|
+
/**
|
|
519
|
+
* Returns current uploads
|
|
520
|
+
*
|
|
521
|
+
* @returns {object}
|
|
516
522
|
*/
|
|
517
523
|
}, {
|
|
518
524
|
key: "getUploadOperations",
|
|
@@ -520,10 +526,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
520
526
|
return this.uploadOperations;
|
|
521
527
|
}
|
|
522
528
|
|
|
523
|
-
/**
|
|
524
|
-
* Returns current uploads' meta
|
|
525
|
-
*
|
|
526
|
-
* @returns {object}
|
|
529
|
+
/**
|
|
530
|
+
* Returns current uploads' meta
|
|
531
|
+
*
|
|
532
|
+
* @returns {object}
|
|
527
533
|
*/
|
|
528
534
|
}, {
|
|
529
535
|
key: "getUploadCapabilities",
|
|
@@ -531,10 +537,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
531
537
|
return selectUploadCapabilities(this.getGlobalState());
|
|
532
538
|
}
|
|
533
539
|
|
|
534
|
-
/**
|
|
535
|
-
* Returns the current files that will get uploaded
|
|
536
|
-
*
|
|
537
|
-
* @returns {object}
|
|
540
|
+
/**
|
|
541
|
+
* Returns the current files that will get uploaded
|
|
542
|
+
*
|
|
543
|
+
* @returns {object}
|
|
538
544
|
*/
|
|
539
545
|
}, {
|
|
540
546
|
key: "getUploads",
|
|
@@ -548,10 +554,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
548
554
|
return files;
|
|
549
555
|
}
|
|
550
556
|
|
|
551
|
-
/**
|
|
552
|
-
* Returns the current files that will get uploaded in a type of array
|
|
553
|
-
*
|
|
554
|
-
* @returns {Array}
|
|
557
|
+
/**
|
|
558
|
+
* Returns the current files that will get uploaded in a type of array
|
|
559
|
+
*
|
|
560
|
+
* @returns {Array}
|
|
555
561
|
*/
|
|
556
562
|
}, {
|
|
557
563
|
key: "getUploadsArray",
|
|
@@ -574,8 +580,8 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
574
580
|
this.setFileStateBeforeUpload.apply(this, arguments);
|
|
575
581
|
}
|
|
576
582
|
|
|
577
|
-
/**
|
|
578
|
-
* Shorthand to set state for a specific file.
|
|
583
|
+
/**
|
|
584
|
+
* Shorthand to set state for a specific file.
|
|
579
585
|
*/
|
|
580
586
|
}, {
|
|
581
587
|
key: "setFileStateBeforeUpload",
|
|
@@ -697,10 +703,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
697
703
|
}));
|
|
698
704
|
}
|
|
699
705
|
|
|
700
|
-
/**
|
|
701
|
-
* Get file uploading object.
|
|
702
|
-
*
|
|
703
|
-
* @param {string} fileId The ID of the file object to return.
|
|
706
|
+
/**
|
|
707
|
+
* Get file uploading object.
|
|
708
|
+
*
|
|
709
|
+
* @param {string} fileId The ID of the file object to return.
|
|
704
710
|
*/
|
|
705
711
|
}, {
|
|
706
712
|
key: "getFileUploading",
|
|
@@ -718,10 +724,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
718
724
|
});
|
|
719
725
|
}
|
|
720
726
|
|
|
721
|
-
/**
|
|
722
|
-
* Get a file object before upload.
|
|
723
|
-
*
|
|
724
|
-
* @param {string} fileId The ID of the file object to return.
|
|
727
|
+
/**
|
|
728
|
+
* Get a file object before upload.
|
|
729
|
+
*
|
|
730
|
+
* @param {string} fileId The ID of the file object to return.
|
|
725
731
|
*/
|
|
726
732
|
}, {
|
|
727
733
|
key: "getFileBeforeUpload",
|
|
@@ -729,10 +735,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
729
735
|
return selectUploadById(this.getGlobalState(), fileId);
|
|
730
736
|
}
|
|
731
737
|
|
|
732
|
-
/**
|
|
733
|
-
* Check if minNumberOfFiles restriction is reached before uploading.
|
|
734
|
-
*
|
|
735
|
-
* @private
|
|
738
|
+
/**
|
|
739
|
+
* Check if minNumberOfFiles restriction is reached before uploading.
|
|
740
|
+
*
|
|
741
|
+
* @private
|
|
736
742
|
*/
|
|
737
743
|
}, {
|
|
738
744
|
key: "_checkMinNumberOfFiles",
|
|
@@ -745,13 +751,13 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
745
751
|
}
|
|
746
752
|
}
|
|
747
753
|
|
|
748
|
-
/**
|
|
749
|
-
* Check if file passes a set of restrictions set in options: maxFileSize,
|
|
750
|
-
* maxNumberOfFiles and allowedFileTypes.
|
|
751
|
-
*
|
|
752
|
-
* @param {object} files Object of files already added
|
|
753
|
-
* @param {object} file object to check
|
|
754
|
-
* @private
|
|
754
|
+
/**
|
|
755
|
+
* Check if file passes a set of restrictions set in options: maxFileSize,
|
|
756
|
+
* maxNumberOfFiles and allowedFileTypes.
|
|
757
|
+
*
|
|
758
|
+
* @param {object} files Object of files already added
|
|
759
|
+
* @param {object} file object to check
|
|
760
|
+
* @private
|
|
755
761
|
*/
|
|
756
762
|
}, {
|
|
757
763
|
key: "_checkRestrictions",
|
|
@@ -843,16 +849,16 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
843
849
|
}
|
|
844
850
|
}
|
|
845
851
|
|
|
846
|
-
/**
|
|
847
|
-
* Logs an error, sets Informer message, then throws the error.
|
|
848
|
-
* Emits a 'restriction-failed' event if it’s a restriction error
|
|
849
|
-
*
|
|
850
|
-
* @param {object | string} err — Error object or plain string message
|
|
851
|
-
* @param {object} [options]
|
|
852
|
-
* @param {boolean} [options.showInformer=true] — Sometimes developer might want to show Informer manually
|
|
853
|
-
* @param {object} [options.file=null] — File object used to emit the restriction error
|
|
854
|
-
* @param {boolean} [options.throwErr=true] — Errors shouldn’t be thrown, for example, in `upload-error` event
|
|
855
|
-
* @private
|
|
852
|
+
/**
|
|
853
|
+
* Logs an error, sets Informer message, then throws the error.
|
|
854
|
+
* Emits a 'restriction-failed' event if it’s a restriction error
|
|
855
|
+
*
|
|
856
|
+
* @param {object | string} err — Error object or plain string message
|
|
857
|
+
* @param {object} [options]
|
|
858
|
+
* @param {boolean} [options.showInformer=true] — Sometimes developer might want to show Informer manually
|
|
859
|
+
* @param {object} [options.file=null] — File object used to emit the restriction error
|
|
860
|
+
* @param {boolean} [options.throwErr=true] — Errors shouldn’t be thrown, for example, in `upload-error` event
|
|
861
|
+
* @private
|
|
856
862
|
*/
|
|
857
863
|
}, {
|
|
858
864
|
key: "_showOrLogErrorAndThrow",
|
|
@@ -905,12 +911,12 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
905
911
|
}
|
|
906
912
|
}
|
|
907
913
|
|
|
908
|
-
/**
|
|
909
|
-
* Create a file state object based on user-provided `addFile()` options.
|
|
910
|
-
*
|
|
911
|
-
* Note this is extremely side-effectful and should only be done when a file state object will be added to state immediately afterward!
|
|
912
|
-
*
|
|
913
|
-
* The `files` value is passed in because it may be updated by the caller without updating the store.
|
|
914
|
+
/**
|
|
915
|
+
* Create a file state object based on user-provided `addFile()` options.
|
|
916
|
+
*
|
|
917
|
+
* Note this is extremely side-effectful and should only be done when a file state object will be added to state immediately afterward!
|
|
918
|
+
*
|
|
919
|
+
* The `files` value is passed in because it may be updated by the caller without updating the store.
|
|
914
920
|
*/
|
|
915
921
|
}, {
|
|
916
922
|
key: "_checkAndCreateFileStateObject",
|
|
@@ -998,12 +1004,12 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
998
1004
|
return newFile;
|
|
999
1005
|
}
|
|
1000
1006
|
|
|
1001
|
-
/**
|
|
1002
|
-
* check if file is available and if not it will throw an error
|
|
1003
|
-
*
|
|
1004
|
-
* @param {string} error — Error message
|
|
1005
|
-
* @param {object} file — File object
|
|
1006
|
-
* @private
|
|
1007
|
+
/**
|
|
1008
|
+
* check if file is available and if not it will throw an error
|
|
1009
|
+
*
|
|
1010
|
+
* @param {string} error — Error message
|
|
1011
|
+
* @param {object} file — File object
|
|
1012
|
+
* @private
|
|
1007
1013
|
*/
|
|
1008
1014
|
}, {
|
|
1009
1015
|
key: "_checkIfFileIsAvailable",
|
|
@@ -1060,13 +1066,13 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1060
1066
|
}
|
|
1061
1067
|
}
|
|
1062
1068
|
|
|
1063
|
-
/**
|
|
1064
|
-
* Add a new file to `state.files`. This will run `onBeforeFileAdded`,
|
|
1065
|
-
* try to guess file type in a clever way, check file against restrictions,
|
|
1066
|
-
* and start an upload if `autoProceed === true`.
|
|
1067
|
-
*
|
|
1068
|
-
* @param {object} file object to add
|
|
1069
|
-
* @returns {string} id for the added file
|
|
1069
|
+
/**
|
|
1070
|
+
* Add a new file to `state.files`. This will run `onBeforeFileAdded`,
|
|
1071
|
+
* try to guess file type in a clever way, check file against restrictions,
|
|
1072
|
+
* and start an upload if `autoProceed === true`.
|
|
1073
|
+
*
|
|
1074
|
+
* @param {object} file object to add
|
|
1075
|
+
* @returns {string} id for the added file
|
|
1070
1076
|
*/
|
|
1071
1077
|
}, {
|
|
1072
1078
|
key: "addFile",
|
|
@@ -1101,12 +1107,12 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1101
1107
|
return newFile.id;
|
|
1102
1108
|
}
|
|
1103
1109
|
|
|
1104
|
-
/**
|
|
1105
|
-
* Add multiple files to `state.files`. See the `addFile()` documentation.
|
|
1106
|
-
*
|
|
1107
|
-
* This cuts some corners for performance, so should typically only be used in cases where there may be a lot of files.
|
|
1108
|
-
*
|
|
1109
|
-
* If an error occurs while adding a file, it is logged and the user is notified. This is good for UI plugins, but not for programmatic use. Programmatic users should usually still use `addFile()` on individual files.
|
|
1110
|
+
/**
|
|
1111
|
+
* Add multiple files to `state.files`. See the `addFile()` documentation.
|
|
1112
|
+
*
|
|
1113
|
+
* This cuts some corners for performance, so should typically only be used in cases where there may be a lot of files.
|
|
1114
|
+
*
|
|
1115
|
+
* If an error occurs while adding a file, it is logged and the user is notified. This is good for UI plugins, but not for programmatic use. Programmatic users should usually still use `addFile()` on individual files.
|
|
1110
1116
|
*/
|
|
1111
1117
|
}, {
|
|
1112
1118
|
key: "addFiles",
|
|
@@ -1295,9 +1301,9 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1295
1301
|
return this.upload(_defineProperty({}, file.id, file));
|
|
1296
1302
|
}
|
|
1297
1303
|
|
|
1298
|
-
/**
|
|
1299
|
-
* Registers listeners for all global actions, like:
|
|
1300
|
-
* `error`, `file-removed`, `upload-progress`
|
|
1304
|
+
/**
|
|
1305
|
+
* Registers listeners for all global actions, like:
|
|
1306
|
+
* `error`, `file-removed`, `upload-progress`
|
|
1301
1307
|
*/
|
|
1302
1308
|
}, {
|
|
1303
1309
|
key: "_addListeners",
|
|
@@ -1396,12 +1402,12 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1396
1402
|
return this.opts.id;
|
|
1397
1403
|
}
|
|
1398
1404
|
|
|
1399
|
-
/**
|
|
1400
|
-
* Registers a plugin with Core.
|
|
1401
|
-
*
|
|
1402
|
-
* @param {object} Plugin object
|
|
1403
|
-
* @param {object} [opts] object with options to be passed to Plugin
|
|
1404
|
-
* @returns {object} self for chaining
|
|
1405
|
+
/**
|
|
1406
|
+
* Registers a plugin with Core.
|
|
1407
|
+
*
|
|
1408
|
+
* @param {object} Plugin object
|
|
1409
|
+
* @param {object} [opts] object with options to be passed to Plugin
|
|
1410
|
+
* @returns {object} self for chaining
|
|
1405
1411
|
*/
|
|
1406
1412
|
}, {
|
|
1407
1413
|
key: "use",
|
|
@@ -1439,11 +1445,11 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1439
1445
|
return this;
|
|
1440
1446
|
}
|
|
1441
1447
|
|
|
1442
|
-
/**
|
|
1443
|
-
* Find one Plugin by name.
|
|
1444
|
-
*
|
|
1445
|
-
* @param {string} id plugin id
|
|
1446
|
-
* @returns {object|boolean}
|
|
1448
|
+
/**
|
|
1449
|
+
* Find one Plugin by name.
|
|
1450
|
+
*
|
|
1451
|
+
* @param {string} id plugin id
|
|
1452
|
+
* @returns {object|boolean}
|
|
1447
1453
|
*/
|
|
1448
1454
|
}, {
|
|
1449
1455
|
key: "getPlugin",
|
|
@@ -1458,10 +1464,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1458
1464
|
return foundPlugin;
|
|
1459
1465
|
}
|
|
1460
1466
|
|
|
1461
|
-
/**
|
|
1462
|
-
* Get all the pre-processor plugins
|
|
1463
|
-
*
|
|
1464
|
-
* @returns array
|
|
1467
|
+
/**
|
|
1468
|
+
* Get all the pre-processor plugins
|
|
1469
|
+
*
|
|
1470
|
+
* @returns array
|
|
1465
1471
|
*/
|
|
1466
1472
|
}, {
|
|
1467
1473
|
key: "getPreProcessors",
|
|
@@ -1469,10 +1475,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1469
1475
|
return this.preProcessors;
|
|
1470
1476
|
}
|
|
1471
1477
|
|
|
1472
|
-
/**
|
|
1473
|
-
* Get all the post-processor plugins
|
|
1474
|
-
*
|
|
1475
|
-
* @returns array
|
|
1478
|
+
/**
|
|
1479
|
+
* Get all the post-processor plugins
|
|
1480
|
+
*
|
|
1481
|
+
* @returns array
|
|
1476
1482
|
*/
|
|
1477
1483
|
}, {
|
|
1478
1484
|
key: "getPostProcessors",
|
|
@@ -1480,10 +1486,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1480
1486
|
return this.postProcessors;
|
|
1481
1487
|
}
|
|
1482
1488
|
|
|
1483
|
-
/**
|
|
1484
|
-
* Iterate through all `use`d plugins.
|
|
1485
|
-
*
|
|
1486
|
-
* @param {Function} method that will be run on each plugin
|
|
1489
|
+
/**
|
|
1490
|
+
* Iterate through all `use`d plugins.
|
|
1491
|
+
*
|
|
1492
|
+
* @param {Function} method that will be run on each plugin
|
|
1487
1493
|
*/
|
|
1488
1494
|
}, {
|
|
1489
1495
|
key: "iteratePlugins",
|
|
@@ -1513,10 +1519,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1513
1519
|
return Boolean(this.getPlugin(pluginIdToCheck));
|
|
1514
1520
|
}
|
|
1515
1521
|
|
|
1516
|
-
/**
|
|
1517
|
-
* Uninstall and remove a plugin.
|
|
1518
|
-
*
|
|
1519
|
-
* @param {object} instance The plugin instance to remove.
|
|
1522
|
+
/**
|
|
1523
|
+
* Uninstall and remove a plugin.
|
|
1524
|
+
*
|
|
1525
|
+
* @param {object} instance The plugin instance to remove.
|
|
1520
1526
|
*/
|
|
1521
1527
|
}, {
|
|
1522
1528
|
key: "removePlugin",
|
|
@@ -1536,8 +1542,8 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1536
1542
|
this.emit('plugins-updated', this._getInstalledPkgs());
|
|
1537
1543
|
}
|
|
1538
1544
|
|
|
1539
|
-
/**
|
|
1540
|
-
* Uninstall all plugins and close down this filerobot instance.
|
|
1545
|
+
/**
|
|
1546
|
+
* Uninstall all plugins and close down this filerobot instance.
|
|
1541
1547
|
*/
|
|
1542
1548
|
}, {
|
|
1543
1549
|
key: "close",
|
|
@@ -1553,13 +1559,13 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1553
1559
|
});
|
|
1554
1560
|
}
|
|
1555
1561
|
|
|
1556
|
-
/**
|
|
1557
|
-
* Set info message in `state.info`, so that UI plugins like `Informer`
|
|
1558
|
-
* can display the message.
|
|
1559
|
-
*
|
|
1560
|
-
* @param {string | object} message Message to be displayed by the informer
|
|
1561
|
-
* @param {string} [type]
|
|
1562
|
-
* @param {number} [duration]
|
|
1562
|
+
/**
|
|
1563
|
+
* Set info message in `state.info`, so that UI plugins like `Informer`
|
|
1564
|
+
* can display the message.
|
|
1565
|
+
*
|
|
1566
|
+
* @param {string | object} message Message to be displayed by the informer
|
|
1567
|
+
* @param {string} [type]
|
|
1568
|
+
* @param {number} [duration]
|
|
1563
1569
|
*/
|
|
1564
1570
|
}, {
|
|
1565
1571
|
key: "info",
|
|
@@ -1598,12 +1604,12 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1598
1604
|
this.emit('info-hidden');
|
|
1599
1605
|
}
|
|
1600
1606
|
|
|
1601
|
-
/**
|
|
1602
|
-
* Passes messages to a function, provided in `opts.logger`.
|
|
1603
|
-
* If `opts.logger: filerobot.debugLogger` or `opts.debug: true`, logs to the browser console.
|
|
1604
|
-
*
|
|
1605
|
-
* @param {string|object} message to log
|
|
1606
|
-
* @param {string} [type] optional `error` or `warning`
|
|
1607
|
+
/**
|
|
1608
|
+
* Passes messages to a function, provided in `opts.logger`.
|
|
1609
|
+
* If `opts.logger: filerobot.debugLogger` or `opts.debug: true`, logs to the browser console.
|
|
1610
|
+
*
|
|
1611
|
+
* @param {string|object} message to log
|
|
1612
|
+
* @param {string} [type] optional `error` or `warning`
|
|
1607
1613
|
*/
|
|
1608
1614
|
}, {
|
|
1609
1615
|
key: "log",
|
|
@@ -1625,8 +1631,8 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1625
1631
|
}
|
|
1626
1632
|
}
|
|
1627
1633
|
|
|
1628
|
-
/**
|
|
1629
|
-
* Obsolete, event listeners are now added in the constructor.
|
|
1634
|
+
/**
|
|
1635
|
+
* Obsolete, event listeners are now added in the constructor.
|
|
1630
1636
|
*/
|
|
1631
1637
|
}, {
|
|
1632
1638
|
key: "run",
|
|
@@ -1635,8 +1641,8 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1635
1641
|
return this;
|
|
1636
1642
|
}
|
|
1637
1643
|
|
|
1638
|
-
/**
|
|
1639
|
-
* Restore an upload by its ID.
|
|
1644
|
+
/**
|
|
1645
|
+
* Restore an upload by its ID.
|
|
1640
1646
|
*/
|
|
1641
1647
|
}, {
|
|
1642
1648
|
key: "restore",
|
|
@@ -1649,11 +1655,11 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1649
1655
|
return this._runUploadOperation(uploadId);
|
|
1650
1656
|
}
|
|
1651
1657
|
|
|
1652
|
-
/**
|
|
1653
|
-
* Create an upload for a bunch of files.
|
|
1654
|
-
*
|
|
1655
|
-
* @param {Object} files Files to include in this upload.
|
|
1656
|
-
* @returns {string} ID of this upload.
|
|
1658
|
+
/**
|
|
1659
|
+
* Create an upload for a bunch of files.
|
|
1660
|
+
*
|
|
1661
|
+
* @param {Object} files Files to include in this upload.
|
|
1662
|
+
* @returns {string} ID of this upload.
|
|
1657
1663
|
*/
|
|
1658
1664
|
}, {
|
|
1659
1665
|
key: "_createUploadOperation",
|
|
@@ -1692,11 +1698,11 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1692
1698
|
return this.getUploadOperations()[uploadId];
|
|
1693
1699
|
}
|
|
1694
1700
|
|
|
1695
|
-
/**
|
|
1696
|
-
* Add data to an upload's result object.
|
|
1697
|
-
*
|
|
1698
|
-
* @param {string} uploadId The ID of the upload.
|
|
1699
|
-
* @param {object} data Data properties to add to the result object.
|
|
1701
|
+
/**
|
|
1702
|
+
* Add data to an upload's result object.
|
|
1703
|
+
*
|
|
1704
|
+
* @param {string} uploadId The ID of the upload.
|
|
1705
|
+
* @param {object} data Data properties to add to the result object.
|
|
1700
1706
|
*/
|
|
1701
1707
|
}, {
|
|
1702
1708
|
key: "addResultData",
|
|
@@ -1712,10 +1718,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1712
1718
|
});
|
|
1713
1719
|
}
|
|
1714
1720
|
|
|
1715
|
-
/**
|
|
1716
|
-
* Remove an upload, eg. if it has been canceled or completed.
|
|
1717
|
-
*
|
|
1718
|
-
* @param {string} uploadId The ID of the upload.
|
|
1721
|
+
/**
|
|
1722
|
+
* Remove an upload, eg. if it has been canceled or completed.
|
|
1723
|
+
*
|
|
1724
|
+
* @param {string} uploadId The ID of the upload.
|
|
1719
1725
|
*/
|
|
1720
1726
|
}, {
|
|
1721
1727
|
key: "_removeUploadOperation",
|
|
@@ -1723,10 +1729,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1723
1729
|
delete this.uploadOperations[uploadId];
|
|
1724
1730
|
}
|
|
1725
1731
|
|
|
1726
|
-
/**
|
|
1727
|
-
* Edit an upload, eg. if its step/phase is being updated.
|
|
1728
|
-
*
|
|
1729
|
-
* @param {string} updatedUpload - the updated/changed upload operation must contain `id` for the upload's id to be changed.
|
|
1732
|
+
/**
|
|
1733
|
+
* Edit an upload, eg. if its step/phase is being updated.
|
|
1734
|
+
*
|
|
1735
|
+
* @param {string} updatedUpload - the updated/changed upload operation must contain `id` for the upload's id to be changed.
|
|
1730
1736
|
*/
|
|
1731
1737
|
}, {
|
|
1732
1738
|
key: "_updateUploadOperation",
|
|
@@ -1758,10 +1764,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1758
1764
|
});
|
|
1759
1765
|
}
|
|
1760
1766
|
|
|
1761
|
-
/**
|
|
1762
|
-
* Run an upload. This picks up where it left off in case the upload is being restored.
|
|
1763
|
-
*
|
|
1764
|
-
* @private
|
|
1767
|
+
/**
|
|
1768
|
+
* Run an upload. This picks up where it left off in case the upload is being restored.
|
|
1769
|
+
*
|
|
1770
|
+
* @private
|
|
1765
1771
|
*/
|
|
1766
1772
|
}, {
|
|
1767
1773
|
key: "_runUploadOperation",
|
|
@@ -1845,10 +1851,10 @@ var ScaleflexWidget = /*#__PURE__*/function () {
|
|
|
1845
1851
|
});
|
|
1846
1852
|
}
|
|
1847
1853
|
|
|
1848
|
-
/**
|
|
1849
|
-
* Start an upload for all the files that are not currently being uploaded.
|
|
1850
|
-
*
|
|
1851
|
-
* @returns {Promise}
|
|
1854
|
+
/**
|
|
1855
|
+
* Start an upload for all the files that are not currently being uploaded.
|
|
1856
|
+
*
|
|
1857
|
+
* @returns {Promise}
|
|
1852
1858
|
*/
|
|
1853
1859
|
}, {
|
|
1854
1860
|
key: "upload",
|