@ibm-aspera/sdk 0.7.0 → 0.7.4

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,6 +1,5 @@
1
1
  import { AsperaSdkInfo, TransferResponse } from '../models/aspera-sdk.model';
2
- import { CustomBrandingOptions, DataTransferResponse, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, InitOptions, ModifyTransferOptions, Pagination, PaginatedFilesResponse, ResumeTransferOptions, TransferSpec, WebsocketEvent, ReadChunkAsArrayBufferResponse, ReadAsArrayBufferResponse, SdkCapabilities, GetChecksumOptions, ChecksumFileResponse } from '../models/models';
3
- import * as ConnectTypes from '@ibm-aspera/connect-sdk-js/dist/esm/core/types';
2
+ import { CustomBrandingOptions, DataTransferResponse, DropzoneEventData, DropzoneOptions, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, InitOptions, ModifyTransferOptions, Pagination, PaginatedFilesResponse, ResumeTransferOptions, TransferSpec, WebsocketEvent, ReadChunkAsArrayBufferResponse, ReadAsArrayBufferResponse, SdkCapabilities, GetChecksumOptions, ChecksumFileResponse } from '../models/models';
4
3
  /**
5
4
  * Check if IBM Aspera for Desktop connection works. This function is called by init
6
5
  * when initializing the SDK. This function can be used at any point for checking.
@@ -180,12 +179,9 @@ export declare const setBranding: (id: string, options: CustomBrandingOptions) =
180
179
  *
181
180
  * @param callback the function to call once the files are dropped
182
181
  * @param elementSelector the selector of the element on the page that should watch for drop events
183
- * @param connectOptions options for connect
182
+ * @param options options to configure which drag and drop events trigger the listener
184
183
  */
185
- export declare const createDropzone: (callback: (data: {
186
- event: DragEvent;
187
- files: DataTransferResponse;
188
- }) => void, elementSelector: string, connectOptions?: ConnectTypes.DragDropOptions) => void;
184
+ export declare const createDropzone: (callback: (data: DropzoneEventData) => void, elementSelector: string, options?: DropzoneOptions) => void;
189
185
  /**
190
186
  * Remove dropzone.
191
187
  *
@@ -113,8 +113,7 @@ var init = function (options) {
113
113
  var _a, _b, _c;
114
114
  var appId = (_a = options === null || options === void 0 ? void 0 : options.appId) !== null && _a !== void 0 ? _a : (0, helpers_1.randomUUID)();
115
115
  index_1.asperaSdk.globals.appId = appId;
116
- // For now ignore multi user support in Safari
117
- if ((options === null || options === void 0 ? void 0 : options.supportMultipleUsers) && !(0, helpers_1.isSafari)()) {
116
+ if (options === null || options === void 0 ? void 0 : options.supportMultipleUsers) {
118
117
  index_1.asperaSdk.globals.supportMultipleUsers = true;
119
118
  index_1.asperaSdk.globals.sessionId = (0, helpers_1.randomUUID)();
120
119
  }
@@ -133,6 +132,7 @@ var init = function (options) {
133
132
  sdkLocation: options.connectSettings.sdkLocation,
134
133
  correlationId: options.connectSettings.correlationId,
135
134
  style: 'carbon',
135
+ version: options.connectSettings.version,
136
136
  });
137
137
  index_1.asperaSdk.globals.connectAW4 = {
138
138
  Connect: connect_sdk_js_1.Connect,
@@ -654,10 +654,27 @@ exports.setBranding = setBranding;
654
654
  *
655
655
  * @param callback the function to call once the files are dropped
656
656
  * @param elementSelector the selector of the element on the page that should watch for drop events
657
- * @param connectOptions options for connect
657
+ * @param options options to configure which drag and drop events trigger the listener
658
658
  */
659
- var createDropzone = function (callback, elementSelector, connectOptions) {
659
+ var createDropzone = function (callback, elementSelector, options) {
660
+ var _a, _b, _c, _d, _e, _f;
661
+ var resolvedOptions = {
662
+ dragEnter: (_a = options === null || options === void 0 ? void 0 : options.dragEnter) !== null && _a !== void 0 ? _a : false,
663
+ dragOver: (_b = options === null || options === void 0 ? void 0 : options.dragOver) !== null && _b !== void 0 ? _b : false,
664
+ dragLeave: (_c = options === null || options === void 0 ? void 0 : options.dragLeave) !== null && _c !== void 0 ? _c : false,
665
+ drop: (_d = options === null || options === void 0 ? void 0 : options.drop) !== null && _d !== void 0 ? _d : true,
666
+ allowPropagation: (_e = options === null || options === void 0 ? void 0 : options.allowPropagation) !== null && _e !== void 0 ? _e : true,
667
+ allowDefaultBehavior: (_f = options === null || options === void 0 ? void 0 : options.allowDefaultBehavior) !== null && _f !== void 0 ? _f : false,
668
+ };
660
669
  if (index_1.asperaSdk.useConnect) {
670
+ var connectOptions = {
671
+ dragenter: resolvedOptions.dragEnter,
672
+ dragover: resolvedOptions.dragOver,
673
+ dragleave: resolvedOptions.dragLeave,
674
+ drop: resolvedOptions.drop,
675
+ allowPropagation: resolvedOptions.allowPropagation,
676
+ disablePreventDefault: resolvedOptions.allowDefaultBehavior,
677
+ };
661
678
  index_1.asperaSdk.globals.connect.setDragDropTargets(elementSelector, connectOptions, function (result) {
662
679
  callback({
663
680
  event: result.event,
@@ -671,43 +688,91 @@ var createDropzone = function (callback, elementSelector, connectOptions) {
671
688
  (0, helpers_1.errorLog)(messages_1.messages.unableToFindElementOnPage);
672
689
  return;
673
690
  }
674
- var dragEvent = function (event) {
675
- event.preventDefault();
691
+ var handleEventDefaults = function (event) {
692
+ if (!resolvedOptions.allowDefaultBehavior) {
693
+ event.preventDefault();
694
+ }
695
+ if (!resolvedOptions.allowPropagation) {
696
+ event.stopPropagation();
697
+ }
676
698
  };
677
- var dropEvent = function (event) {
699
+ var handleRequiredEventDefaults = function (event) {
678
700
  event.preventDefault();
679
- if (event.dataTransfer && event.dataTransfer.files && event.dataTransfer.files.length && event.dataTransfer.files[0]) {
680
- var files = [];
681
- for (var i = 0; i < event.dataTransfer.files.length; i++) {
682
- var file = event.dataTransfer.files[i];
683
- files.push({
684
- lastModified: file.lastModified,
685
- name: file.name,
686
- size: file.size,
687
- type: file.type
688
- });
689
- }
690
- var payload = {
691
- files: files,
692
- app_id: index_1.asperaSdk.globals.appId,
693
- };
694
- if (index_1.asperaSdk.isReady) {
695
- client_1.client.request('dropped_files', payload)
696
- .then(function (data) { return callback({ event: event, files: data }); })
697
- .catch(function (error) {
698
- (0, helpers_1.errorLog)(messages_1.messages.unableToReadDropped, error);
699
- });
700
- }
701
- else if (index_1.asperaSdk.httpGatewayIsReady) {
702
- (0, core_1.handleHttpGatewayDrop)(event.dataTransfer.items, callback, event);
703
- }
701
+ if (!resolvedOptions.allowPropagation) {
702
+ event.stopPropagation();
704
703
  }
705
704
  };
705
+ var registeredListeners = [];
706
+ if (resolvedOptions.dragEnter) {
707
+ registeredListeners.push({
708
+ event: 'dragenter',
709
+ callback: function (event) {
710
+ handleEventDefaults(event);
711
+ callback({ event: event });
712
+ },
713
+ });
714
+ }
715
+ if (resolvedOptions.dragLeave) {
716
+ registeredListeners.push({
717
+ event: 'dragleave',
718
+ callback: function (event) {
719
+ handleEventDefaults(event);
720
+ callback({ event: event });
721
+ },
722
+ });
723
+ }
724
+ if (resolvedOptions.drop || resolvedOptions.dragOver) {
725
+ registeredListeners.push({
726
+ event: 'dragover',
727
+ callback: function (event) {
728
+ handleRequiredEventDefaults(event);
729
+ if (resolvedOptions.dragOver) {
730
+ callback({ event: event });
731
+ }
732
+ },
733
+ });
734
+ }
735
+ if (resolvedOptions.drop) {
736
+ registeredListeners.push({
737
+ event: 'drop',
738
+ callback: function (event) {
739
+ handleRequiredEventDefaults(event);
740
+ if (event.dataTransfer && event.dataTransfer.files && event.dataTransfer.files.length && event.dataTransfer.files[0]) {
741
+ var files = [];
742
+ for (var i = 0; i < event.dataTransfer.files.length; i++) {
743
+ var file = event.dataTransfer.files[i];
744
+ files.push({
745
+ lastModified: file.lastModified,
746
+ name: file.name,
747
+ size: file.size,
748
+ type: file.type
749
+ });
750
+ }
751
+ var payload = {
752
+ files: files,
753
+ app_id: index_1.asperaSdk.globals.appId,
754
+ };
755
+ if (index_1.asperaSdk.isReady) {
756
+ client_1.client.request('dropped_files', payload)
757
+ .then(function (data) { return callback({ event: event, files: data }); })
758
+ .catch(function (error) {
759
+ (0, helpers_1.errorLog)(messages_1.messages.unableToReadDropped, error);
760
+ });
761
+ }
762
+ else if (index_1.asperaSdk.httpGatewayIsReady) {
763
+ (0, core_1.handleHttpGatewayDrop)(event.dataTransfer.items, callback, event);
764
+ }
765
+ }
766
+ },
767
+ });
768
+ }
706
769
  elements.forEach(function (element) {
707
- element.addEventListener('dragover', dragEvent);
708
- element.addEventListener('drop', dropEvent);
709
- index_1.asperaSdk.globals.dropZonesCreated.set(elementSelector, [{ event: 'dragover', callback: dragEvent }, { event: 'drop', callback: dropEvent }]);
770
+ registeredListeners.forEach(function (_a) {
771
+ var event = _a.event, listener = _a.callback;
772
+ element.addEventListener(event, listener);
773
+ });
710
774
  });
775
+ index_1.asperaSdk.globals.dropZonesCreated.set(elementSelector, registeredListeners);
711
776
  };
712
777
  exports.createDropzone = createDropzone;
713
778
  /**
@@ -718,14 +783,15 @@ exports.createDropzone = createDropzone;
718
783
  var removeDropzone = function (elementSelector) {
719
784
  var foundDropzone = index_1.asperaSdk.globals.dropZonesCreated.get(elementSelector);
720
785
  if (foundDropzone) {
786
+ var elements_1 = document.querySelectorAll(elementSelector);
721
787
  foundDropzone.forEach(function (data) {
722
- var elements = document.querySelectorAll(elementSelector);
723
- if (elements && elements.length) {
724
- elements.forEach(function (element) {
788
+ if (elements_1 && elements_1.length) {
789
+ elements_1.forEach(function (element) {
725
790
  element.removeEventListener(data.event, data.callback);
726
791
  });
727
792
  }
728
793
  });
794
+ index_1.asperaSdk.globals.dropZonesCreated.delete(elementSelector);
729
795
  }
730
796
  };
731
797
  exports.removeDropzone = removeDropzone;
@@ -1,4 +1,4 @@
1
- import { FileDialogOptions, DataTransferResponse, TransferSpec, AsperaSdkTransfer, ReadAsArrayBufferResponse, ReadChunkAsArrayBufferResponse } from '../models/models';
1
+ import { FileDialogOptions, DataTransferResponse, DropzoneEventData, TransferSpec, AsperaSdkTransfer, ReadAsArrayBufferResponse, ReadChunkAsArrayBufferResponse } from '../models/models';
2
2
  import { HttpGatewayInfo } from './models';
3
3
  /**
4
4
  * HTTP Gateway Core Logic
@@ -64,10 +64,7 @@ export declare const createHtmlInputElement: () => HTMLInputElement;
64
64
  * Handle drop events and store files for HTTP Gateway
65
65
  * This works on top of desktop.
66
66
  */
67
- export declare const handleHttpGatewayDrop: (items: DataTransferItemList, callback: (data: {
68
- event: DragEvent;
69
- files: DataTransferResponse;
70
- }) => void, event: DragEvent) => void;
67
+ export declare const handleHttpGatewayDrop: (items: DataTransferItemList, callback: (data: DropzoneEventData) => void, event: DragEvent) => void;
71
68
  /**
72
69
  * Open native browser file or folder picker for files
73
70
  *
@@ -5,7 +5,7 @@ import { getInstallerUrls, isSafari } from './helpers/helpers';
5
5
  export declare const asperaSdk: AsperaSdk;
6
6
  declare const launch: () => void;
7
7
  export { isSafari, init, testConnection, startTransfer, launch, registerActivityCallback, deregisterActivityCallback, removeTransfer, showDirectory, stopTransfer, resumeTransfer, getAllTransfers, getTransfer, getFilesList, showSelectFileDialog, showSelectFolderDialog, showPreferences, modifyTransfer, createDropzone, removeDropzone, initDragDrop, getInstallerInfo, registerStatusCallback, deregisterStatusCallback, setBranding, getInfo, readAsArrayBuffer, readChunkAsArrayBuffer, getInstallerUrls, getCapabilities, getChecksum, };
8
- export type { AsperaSdkSpec, AsperaSdkTransfer, BrowserStyleFile, ChecksumFileResponse, CustomBrandingOptions, CustomTheme, CustomThemeItems, DataTransferResponse, FileDialogOptions, FileError, FileFilter, FileStat, FileStatus, FolderDialogOptions, GetChecksumOptions, InitOptions, InstallerInfo, InstallerInfoResponse, InstallerOptions, InstallerUrlInfo, ModifyTransferOptions, OverwritePolicy, PaginatedFilesResponse, Pagination, Path, ReadAsArrayBufferResponse, ReadChunkAsArrayBufferResponse, ResumePolicy, ResumeTransferOptions, SafariExtensionEvent, SdkCapabilities, TransferSpec, TransferStatus, WebsocketEvent, } from './models/models';
8
+ export type { AsperaSdkSpec, AsperaSdkTransfer, BrowserStyleFile, ChecksumFileResponse, CustomBrandingOptions, CustomTheme, CustomThemeItems, DataTransferResponse, DropzoneEventData, DropzoneEventType, DropzoneOptions, FileDialogOptions, FileError, FileFilter, FileStat, FileStatus, FolderDialogOptions, GetChecksumOptions, InitOptions, InstallerInfo, InstallerInfoResponse, InstallerOptions, InstallerUrlInfo, ModifyTransferOptions, OverwritePolicy, PaginatedFilesResponse, Pagination, Path, ReadAsArrayBufferResponse, ReadChunkAsArrayBufferResponse, ResumePolicy, ResumeTransferOptions, SafariExtensionEvent, SdkCapabilities, TransferSpec, TransferStatus, WebsocketEvent, } from './models/models';
9
9
  export type { ActivityMessage, ActivityMessageTypes, AsperaSdkClientInfo, AsperaSdkInfo, TransferResponse, } from './models/aspera-sdk.model';
10
10
  export { AsperaSdk, AsperaSdkGlobals } from './models/aspera-sdk.model';
11
11
  export type { HttpGatewayInfo } from './http-gateway/models';
@@ -1,4 +1,4 @@
1
- import { CustomBrandingOptions, DataTransferResponse, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, InitOptions, InstallerInfoResponse, InstallerOptions, ModifyTransferOptions, Pagination, PaginatedFilesResponse, ResumeTransferOptions, SafariExtensionEvent, TransferSpec, WebsocketEvent, InstallerUrlInfo, SdkCapabilities, GetChecksumOptions, ChecksumFileResponse } from './models';
1
+ import { CustomBrandingOptions, DataTransferResponse, DropzoneEventData, DropzoneEventType, DropzoneOptions, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, InitOptions, InstallerInfoResponse, InstallerOptions, ModifyTransferOptions, Pagination, PaginatedFilesResponse, ResumeTransferOptions, SafariExtensionEvent, TransferSpec, WebsocketEvent, InstallerUrlInfo, SdkCapabilities, GetChecksumOptions, ChecksumFileResponse } from './models';
2
2
  import { HttpGatewayInfo } from '../http-gateway/models';
3
3
  import * as ConnectTypes from '@ibm-aspera/connect-sdk-js/dist/esm/core/types';
4
4
  import { Connect, ConnectInstaller } from '@ibm-aspera/connect-sdk-js';
@@ -23,8 +23,8 @@ export declare class AsperaSdkGlobals {
23
23
  sessionId?: string;
24
24
  /** Map of drop zones created by querySelector */
25
25
  dropZonesCreated: Map<string, {
26
- event: string;
27
- callback: (event: any) => void;
26
+ event: DropzoneEventType;
27
+ callback: (event: DragEvent) => void;
28
28
  }[]>;
29
29
  /** HTTP Gateway URL after successful passing */
30
30
  httpGatewayUrl?: string;
@@ -208,10 +208,7 @@ export declare class AsperaSdk {
208
208
  /** Function to set custom branding for IBM Aspera */
209
209
  setBranding: (id: string, options: CustomBrandingOptions) => Promise<any>;
210
210
  /** Create dropzone for drop events of files */
211
- createDropzone: (callback: (data: {
212
- event: any;
213
- files: DataTransferResponse;
214
- }) => void, elementSelector: string) => void;
211
+ createDropzone: (callback: (data: DropzoneEventData) => void, elementSelector: string, options?: DropzoneOptions) => void;
215
212
  /** Remove dropzone for drop events of files */
216
213
  removeDropzone: (elementSelector: string) => void;
217
214
  /** Function to get latest installer information */
@@ -58,6 +58,57 @@ export interface DataTransferResponse {
58
58
  files: BrowserStyleFile[];
59
59
  };
60
60
  }
61
+ /** Drag and drop event types supported by the dropzone. */
62
+ export type DropzoneEventType = 'dragenter' | 'dragleave' | 'dragover' | 'drop';
63
+ /** Callback data for dropzone drag and drop events. */
64
+ export interface DropzoneEventData {
65
+ event: DragEvent;
66
+ files?: DataTransferResponse;
67
+ }
68
+ /** Options to configure the behavior of a dropzone created with {@link createDropzone}. */
69
+ export interface DropzoneOptions {
70
+ /**
71
+ * Whether the listener is invoked when a drag enters the dropzone element.
72
+ * Useful for applying visual feedback on the drop target.
73
+ * Default: false.
74
+ */
75
+ dragEnter?: boolean;
76
+ /**
77
+ * Whether the listener is invoked while a drag is held over the dropzone element.
78
+ * Default: false.
79
+ */
80
+ dragOver?: boolean;
81
+ /**
82
+ * Whether the listener is invoked when a drag leaves the dropzone element.
83
+ * Useful for reverting visual feedback applied on `dragEnter`.
84
+ * Default: false.
85
+ */
86
+ dragLeave?: boolean;
87
+ /**
88
+ * Whether the listener is invoked when files are dropped onto the dropzone element.
89
+ * The dropped files are provided via the callback's `files` property.
90
+ * Default: true.
91
+ */
92
+ drop?: boolean;
93
+ /**
94
+ * Whether drag and drop events propagate to parent elements after being handled.
95
+ * When false, `event.stopPropagation()` is called on all enabled events (`dragenter`, `dragleave`,
96
+ * `dragover`, `drop`). Note that `dragover` is always registered internally when `drop` is true,
97
+ * so this setting also affects that internal listener even if `dragOver` is not enabled.
98
+ * Set to false when the dropzone is nested inside another draggable or interactive element.
99
+ * Default: true.
100
+ */
101
+ allowPropagation?: boolean;
102
+ /**
103
+ * Whether the browser's default action is preserved on `dragenter` and `dragleave` events.
104
+ * When false (default), the SDK calls `event.preventDefault()` on these events automatically.
105
+ * When true, the caller is responsible for calling `event.preventDefault()` in the listener.
106
+ * Note: `dragover` and `drop` always call `event.preventDefault()` regardless of this setting,
107
+ * as it is required for drops to function correctly in the browser.
108
+ * Default: false.
109
+ */
110
+ allowDefaultBehavior?: boolean;
111
+ }
61
112
  export interface BrowserStyleFile {
62
113
  /** Last modified date of the file in milliseconds since the UNIX epoch */
63
114
  lastModified: number;
@@ -795,6 +846,8 @@ export interface InitOptions {
795
846
  correlationId?: string;
796
847
  /** Indicate if default Connect installer window should not be shown */
797
848
  hideIncludedInstaller?: boolean;
849
+ /** Connect installer version to offer for downloads. This option is ignored if `sdkLocation` is specified. Only supports versions `4.x.x`. */
850
+ version?: string;
798
851
  };
799
852
  }
800
853
  export interface InstallerUrlInfo {