@capgo/capacitor-uploader 7.1.22 → 7.2.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.
package/README.md CHANGED
@@ -180,6 +180,7 @@ Documentation for the [Capacitor Camera preview](https://github.com/Cap-go/camer
180
180
  * [`startUpload(...)`](#startupload)
181
181
  * [`removeUpload(...)`](#removeupload)
182
182
  * [`addListener('events', ...)`](#addlistenerevents-)
183
+ * [`getPluginVersion()`](#getpluginversion)
183
184
  * [Interfaces](#interfaces)
184
185
 
185
186
  </docgen-index>
@@ -237,6 +238,19 @@ addListener(eventName: 'events', listenerFunc: (state: UploadEvent) => void) =>
237
238
  --------------------
238
239
 
239
240
 
241
+ ### getPluginVersion()
242
+
243
+ ```typescript
244
+ getPluginVersion() => Promise<{ version: string; }>
245
+ ```
246
+
247
+ Get the native Capacitor plugin version
248
+
249
+ **Returns:** <code>Promise&lt;{ version: string; }&gt;</code>
250
+
251
+ --------------------
252
+
253
+
240
254
  ### Interfaces
241
255
 
242
256
 
@@ -21,6 +21,8 @@ import net.gotev.uploadservice.observer.request.RequestObserverDelegate;
21
21
  @CapacitorPlugin(name = "Uploader")
22
22
  public class UploaderPlugin extends Plugin {
23
23
 
24
+ private final String PLUGIN_VERSION = "7.2.1";
25
+
24
26
  private Uploader implementation;
25
27
 
26
28
  private static final String CHANNEL_ID = "ee.forgr.capacitor.uploader.notification_channel_id";
@@ -166,4 +168,15 @@ public class UploaderPlugin extends Plugin {
166
168
  }
167
169
  return map;
168
170
  }
171
+
172
+ @PluginMethod
173
+ public void getPluginVersion(final PluginCall call) {
174
+ try {
175
+ final JSObject ret = new JSObject();
176
+ ret.put("version", this.PLUGIN_VERSION);
177
+ call.resolve(ret);
178
+ } catch (final Exception e) {
179
+ call.reject("Could not get plugin version", e);
180
+ }
181
+ }
169
182
  }
package/dist/docs.json CHANGED
@@ -115,6 +115,25 @@
115
115
  "UploadEvent"
116
116
  ],
117
117
  "slug": "addlistenerevents-"
118
+ },
119
+ {
120
+ "name": "getPluginVersion",
121
+ "signature": "() => Promise<{ version: string; }>",
122
+ "parameters": [],
123
+ "returns": "Promise<{ version: string; }>",
124
+ "tags": [
125
+ {
126
+ "name": "returns",
127
+ "text": "an Promise with version for this device"
128
+ },
129
+ {
130
+ "name": "throws",
131
+ "text": "An error if the something went wrong"
132
+ }
133
+ ],
134
+ "docs": "Get the native Capacitor plugin version",
135
+ "complexTypes": [],
136
+ "slug": "getpluginversion"
118
137
  }
119
138
  ],
120
139
  "properties": []
@@ -122,4 +122,13 @@ export interface UploaderPlugin {
122
122
  * @returns { PluginListenerHandle }
123
123
  */
124
124
  addListener(eventName: 'events', listenerFunc: (state: UploadEvent) => void): Promise<PluginListenerHandle>;
125
+ /**
126
+ * Get the native Capacitor plugin version
127
+ *
128
+ * @returns {Promise<{ id: string }>} an Promise with version for this device
129
+ * @throws An error if the something went wrong
130
+ */
131
+ getPluginVersion(): Promise<{
132
+ version: string;
133
+ }>;
125
134
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface uploadOption {\n /**\n * @since 0.0.1\n * @description The file path of the file to upload\n */\n filePath: string;\n /**\n * @since 0.0.1\n * @description The url of the server\n */\n serverUrl: string;\n /**\n * @since 0.0.1\n * @default 'Uploading'\n * @description The title of the notification\n * Android only\n */\n notificationTitle?: number;\n /**\n * @since 0.0.1\n * @description The headers to send with the request\n */\n headers: {\n [key: string]: string;\n };\n /**\n * @since 0.0.1\n * @description The method to use for the request\n * @default 'POST'\n */\n method?: 'PUT' | 'POST';\n /**\n * @since 0.0.1\n * @description The mime type to use for the request\n */\n mimeType?: string;\n /**\n * @since 0.0.1\n * @description The parameters to send with the request\n */\n parameters?: { [key: string]: string };\n /**\n * @since 0.0.1\n * @description The maximum number of retries\n */\n maxRetries?: number;\n /**\n * @since 0.0.2\n * @description The type of upload to use\n * @default 'binary'\n */\n uploadType?: 'binary' | 'multipart';\n /**\n * @since 0.0.2\n * @description The form field name for the file when using multipart\n * @default 'file'\n */\n fileField?: string;\n}\nexport interface UploadEvent {\n /**\n * Current status of upload, between 0 and 100.\n *\n * @since 0.0.1\n */\n name: 'uploading' | 'completed' | 'failed';\n /**\n * @since 0.0.1\n * @description The payload of the event\n * @default { percent: 0, error: '', statusCode: 0 }\n */\n payload: {\n /**\n * @since 0.0.1\n * @description The percent of the upload\n */\n percent?: number;\n /**\n * @since 0.0.1\n * @description The error of the upload\n */\n error?: string;\n /**\n * @since 0.0.1\n * @description The status code of the upload\n */\n statusCode?: number;\n };\n /**\n * @since 0.0.1\n * @description The id of the upload\n */\n id: string;\n}\n\nexport interface UploaderPlugin {\n /**\n * @since 0.0.1\n * @description Start the upload\n * @param options uploadOption\n * @returns { id: string }\n */\n startUpload(options: uploadOption): Promise<{ id: string }>;\n /**\n * @since 0.0.1\n * @description Remove the upload\n * @param options\n * @returns { void }\n */\n removeUpload(options: { id: string }): Promise<void>;\n /**\n * @since 0.0.1\n * @description Add a listener for the upload events\n * @param eventName\n * @param listenerFunc\n * @returns { PluginListenerHandle }\n */\n addListener(eventName: 'events', listenerFunc: (state: UploadEvent) => void): Promise<PluginListenerHandle>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface uploadOption {\n /**\n * @since 0.0.1\n * @description The file path of the file to upload\n */\n filePath: string;\n /**\n * @since 0.0.1\n * @description The url of the server\n */\n serverUrl: string;\n /**\n * @since 0.0.1\n * @default 'Uploading'\n * @description The title of the notification\n * Android only\n */\n notificationTitle?: number;\n /**\n * @since 0.0.1\n * @description The headers to send with the request\n */\n headers: {\n [key: string]: string;\n };\n /**\n * @since 0.0.1\n * @description The method to use for the request\n * @default 'POST'\n */\n method?: 'PUT' | 'POST';\n /**\n * @since 0.0.1\n * @description The mime type to use for the request\n */\n mimeType?: string;\n /**\n * @since 0.0.1\n * @description The parameters to send with the request\n */\n parameters?: { [key: string]: string };\n /**\n * @since 0.0.1\n * @description The maximum number of retries\n */\n maxRetries?: number;\n /**\n * @since 0.0.2\n * @description The type of upload to use\n * @default 'binary'\n */\n uploadType?: 'binary' | 'multipart';\n /**\n * @since 0.0.2\n * @description The form field name for the file when using multipart\n * @default 'file'\n */\n fileField?: string;\n}\nexport interface UploadEvent {\n /**\n * Current status of upload, between 0 and 100.\n *\n * @since 0.0.1\n */\n name: 'uploading' | 'completed' | 'failed';\n /**\n * @since 0.0.1\n * @description The payload of the event\n * @default { percent: 0, error: '', statusCode: 0 }\n */\n payload: {\n /**\n * @since 0.0.1\n * @description The percent of the upload\n */\n percent?: number;\n /**\n * @since 0.0.1\n * @description The error of the upload\n */\n error?: string;\n /**\n * @since 0.0.1\n * @description The status code of the upload\n */\n statusCode?: number;\n };\n /**\n * @since 0.0.1\n * @description The id of the upload\n */\n id: string;\n}\n\nexport interface UploaderPlugin {\n /**\n * @since 0.0.1\n * @description Start the upload\n * @param options uploadOption\n * @returns { id: string }\n */\n startUpload(options: uploadOption): Promise<{ id: string }>;\n /**\n * @since 0.0.1\n * @description Remove the upload\n * @param options\n * @returns { void }\n */\n removeUpload(options: { id: string }): Promise<void>;\n /**\n * @since 0.0.1\n * @description Add a listener for the upload events\n * @param eventName\n * @param listenerFunc\n * @returns { PluginListenerHandle }\n */\n addListener(eventName: 'events', listenerFunc: (state: UploadEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -10,4 +10,7 @@ export declare class UploaderWeb extends WebPlugin implements UploaderPlugin {
10
10
  }): Promise<void>;
11
11
  private doUpload;
12
12
  private getFileFromPath;
13
+ getPluginVersion(): Promise<{
14
+ version: string;
15
+ }>;
13
16
  }
package/dist/esm/web.js CHANGED
@@ -88,5 +88,8 @@ export class UploaderWeb extends WebPlugin {
88
88
  return null;
89
89
  }
90
90
  }
91
+ async getPluginVersion() {
92
+ return { version: 'web' };
93
+ }
91
94
  }
92
95
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,WAAY,SAAQ,SAAS;IAA1C;;QACU,YAAO,GAAkE,IAAI,GAAG,EAAE,CAAC;IA8F7F,CAAC;IA5FC,KAAK,CAAC,WAAW,CAAC,OAAqB;QACrC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAEpC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QAE1D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAE3B,OAAO,EAAE,EAAE,EAAE,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAAuB;QACxC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5C,IAAI,MAAM,EAAE,CAAC;YACX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CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,MAAM,EAAE;gBAC3D,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;YAC5C,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { UploaderPlugin, uploadOption } from './definitions';\n\nexport class UploaderWeb extends WebPlugin implements UploaderPlugin {\n private uploads: Map<string, { controller: AbortController; retries: number }> = new Map();\n\n async startUpload(options: uploadOption): Promise<{ id: string }> {\n console.log('startUpload', options);\n\n const id = Math.random().toString(36).substring(2, 15);\n const controller = new AbortController();\n const maxRetries = options.maxRetries || 3;\n this.uploads.set(id, { controller, retries: maxRetries });\n\n this.doUpload(id, options);\n\n return { id };\n }\n\n async removeUpload(options: { id: string }): Promise<void> {\n console.log('removeUpload', options);\n const upload = this.uploads.get(options.id);\n if (upload) {\n upload.controller.abort();\n this.uploads.delete(options.id);\n this.notifyListeners('events', {\n name: 'cancelled',\n id: options.id,\n payload: {},\n });\n }\n }\n\n private async doUpload(id: string, options: uploadOption) {\n const { filePath, serverUrl, headers = {}, method = 'POST', parameters = {} } = options;\n const upload = this.uploads.get(id);\n\n if (!upload) return;\n\n try {\n const file = await this.getFileFromPath(filePath);\n if (!file) throw new Error('File not found');\n\n const formData = new FormData();\n formData.append('file', file);\n\n for (const [key, value] of Object.entries(parameters)) {\n formData.append(key, value);\n }\n\n const response = await fetch(serverUrl, {\n method,\n headers,\n body: method === 'PUT' ? file : formData,\n signal: upload.controller.signal,\n });\n\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);\n\n this.notifyListeners('events', {\n name: 'completed',\n id,\n payload: { statusCode: response.status },\n });\n\n this.uploads.delete(id);\n } catch (error) {\n if ((error as Error).name === 'AbortError') return;\n\n if (upload.retries > 0) {\n upload.retries--;\n console.log(`Retrying upload (retries left: ${upload.retries})`);\n setTimeout(() => this.doUpload(id, options), 1000);\n } else {\n this.notifyListeners('events', {\n name: 'failed',\n id,\n payload: { error: (error as Error).message },\n });\n this.uploads.delete(id);\n }\n }\n }\n\n private async getFileFromPath(filePath: string): Promise<File | null> {\n // This is a simplified version. In a real-world scenario,\n // you might need to handle different types of paths or use a file system API.\n try {\n const response = await fetch(filePath);\n const blob = await response.blob();\n return new File([blob], filePath.split('/').pop() || 'file', {\n type: blob.type,\n });\n } catch (error) {\n console.error('Error getting file:', error);\n return null;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,WAAY,SAAQ,SAAS;IAA1C;;QACU,YAAO,GAAkE,IAAI,GAAG,EAAE,CAAC;IAkG7F,CAAC;IAhGC,KAAK,CAAC,WAAW,CAAC,OAAqB;QACrC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAEpC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QAE1D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAE3B,OAAO,EA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AC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,QAAgB;QAC5C,0DAA0D;QAC1D,8EAA8E;QAC9E,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;YACvC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,MAAM,EAAE;gBAC3D,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;YAC5C,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { UploaderPlugin, uploadOption } from './definitions';\n\nexport class UploaderWeb extends WebPlugin implements UploaderPlugin {\n private uploads: Map<string, { controller: AbortController; retries: number }> = new Map();\n\n async startUpload(options: uploadOption): Promise<{ id: string }> {\n console.log('startUpload', options);\n\n const id = Math.random().toString(36).substring(2, 15);\n const controller = new AbortController();\n const maxRetries = options.maxRetries || 3;\n this.uploads.set(id, { controller, retries: maxRetries });\n\n this.doUpload(id, options);\n\n return { id };\n }\n\n async removeUpload(options: { id: string }): Promise<void> {\n console.log('removeUpload', options);\n const upload = this.uploads.get(options.id);\n if (upload) {\n upload.controller.abort();\n this.uploads.delete(options.id);\n this.notifyListeners('events', {\n name: 'cancelled',\n id: options.id,\n payload: {},\n });\n }\n }\n\n private async doUpload(id: string, options: uploadOption) {\n const { filePath, serverUrl, headers = {}, method = 'POST', parameters = {} } = options;\n const upload = this.uploads.get(id);\n\n if (!upload) return;\n\n try {\n const file = await this.getFileFromPath(filePath);\n if (!file) throw new Error('File not found');\n\n const formData = new FormData();\n formData.append('file', file);\n\n for (const [key, value] of Object.entries(parameters)) {\n formData.append(key, value);\n }\n\n const response = await fetch(serverUrl, {\n method,\n headers,\n body: method === 'PUT' ? file : formData,\n signal: upload.controller.signal,\n });\n\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);\n\n this.notifyListeners('events', {\n name: 'completed',\n id,\n payload: { statusCode: response.status },\n });\n\n this.uploads.delete(id);\n } catch (error) {\n if ((error as Error).name === 'AbortError') return;\n\n if (upload.retries > 0) {\n upload.retries--;\n console.log(`Retrying upload (retries left: ${upload.retries})`);\n setTimeout(() => this.doUpload(id, options), 1000);\n } else {\n this.notifyListeners('events', {\n name: 'failed',\n id,\n payload: { error: (error as Error).message },\n });\n this.uploads.delete(id);\n }\n }\n }\n\n private async getFileFromPath(filePath: string): Promise<File | null> {\n // This is a simplified version. In a real-world scenario,\n // you might need to handle different types of paths or use a file system API.\n try {\n const response = await fetch(filePath);\n const blob = await response.blob();\n return new File([blob], filePath.split('/').pop() || 'file', {\n type: blob.type,\n });\n } catch (error) {\n console.error('Error getting file:', error);\n return null;\n }\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
@@ -95,6 +95,9 @@ class UploaderWeb extends core.WebPlugin {
95
95
  return null;
96
96
  }
97
97
  }
98
+ async getPluginVersion() {
99
+ return { version: 'web' };
100
+ }
98
101
  }
99
102
 
100
103
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Uploader = registerPlugin('Uploader', {\n web: () => import('./web').then((m) => new m.UploaderWeb()),\n});\nexport * from './definitions';\nexport { Uploader };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class UploaderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.uploads = new Map();\n }\n async startUpload(options) {\n console.log('startUpload', options);\n const id = Math.random().toString(36).substring(2, 15);\n const controller = new AbortController();\n const maxRetries = options.maxRetries || 3;\n this.uploads.set(id, { controller, retries: maxRetries });\n this.doUpload(id, options);\n return { id };\n }\n async removeUpload(options) {\n console.log('removeUpload', options);\n const upload = this.uploads.get(options.id);\n if (upload) {\n upload.controller.abort();\n this.uploads.delete(options.id);\n this.notifyListeners('events', {\n name: 'cancelled',\n id: options.id,\n payload: {},\n });\n }\n }\n async doUpload(id, options) {\n const { filePath, serverUrl, headers = {}, method = 'POST', parameters = {} } = options;\n const upload = this.uploads.get(id);\n if (!upload)\n return;\n try {\n const file = await this.getFileFromPath(filePath);\n if (!file)\n throw new Error('File not found');\n const formData = new FormData();\n formData.append('file', file);\n for (const [key, value] of Object.entries(parameters)) {\n formData.append(key, value);\n }\n const response = await fetch(serverUrl, {\n method,\n headers,\n body: method === 'PUT' ? file : formData,\n signal: upload.controller.signal,\n });\n if (!response.ok)\n throw new Error(`HTTP error! status: ${response.status}`);\n this.notifyListeners('events', {\n name: 'completed',\n id,\n payload: { statusCode: response.status },\n });\n this.uploads.delete(id);\n }\n catch (error) {\n if (error.name === 'AbortError')\n return;\n if (upload.retries > 0) {\n upload.retries--;\n console.log(`Retrying upload (retries left: ${upload.retries})`);\n setTimeout(() => this.doUpload(id, options), 1000);\n }\n else {\n this.notifyListeners('events', {\n name: 'failed',\n id,\n payload: { error: error.message },\n });\n this.uploads.delete(id);\n }\n }\n }\n async getFileFromPath(filePath) {\n // This is a simplified version. In a real-world scenario,\n // you might need to handle different types of paths or use a file system API.\n try {\n const response = await fetch(filePath);\n const blob = await response.blob();\n return new File([blob], filePath.split('/').pop() || 'file', {\n type: blob.type,\n });\n }\n catch (error) {\n console.error('Error getting file:', error);\n return null;\n }\n }\n}\n//# sour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Q,EAAE;AACpC;AACA;AACA,QAAQ,IAAI;AACZ,YAAY,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC;AAClD,YAAY,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE;AAC9C,YAAY,OAAO,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,MAAM,EAAE;AACzE,gBAAgB,IAAI,EAAE,IAAI,CAAC,IAAI;AAC/B,aAAa,CAAC;AACd,QAAQ;AACR,QAAQ,OAAO,KAAK,EAAE;AACtB,YAAY,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC;AACvD,YAAY,OAAO,IAAI;AACvB,QAAQ;AACR,IAAI;AACJ;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Uploader = registerPlugin('Uploader', {\n web: () => import('./web').then((m) => new m.UploaderWeb()),\n});\nexport * from './definitions';\nexport { Uploader };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class UploaderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.uploads = new Map();\n }\n async startUpload(options) {\n console.log('startUpload', options);\n const id = Math.random().toString(36).substring(2, 15);\n const controller = new AbortController();\n const maxRetries = options.maxRetries || 3;\n this.uploads.set(id, { controller, retries: maxRetries });\n this.doUpload(id, options);\n return { id };\n }\n async removeUpload(options) {\n console.log('removeUpload', options);\n const upload = this.uploads.get(options.id);\n if (upload) {\n upload.controller.abort();\n this.uploads.delete(options.id);\n this.notifyListeners('events', {\n name: 'cancelled',\n id: options.id,\n payload: {},\n });\n }\n }\n async doUpload(id, options) {\n const { filePath, serverUrl, headers = {}, method = 'POST', parameters = {} } = options;\n const upload = this.uploads.get(id);\n if (!upload)\n return;\n try {\n const file = await this.getFileFromPath(filePath);\n if (!file)\n throw new Error('File not found');\n const formData = new FormData();\n formData.append('file', file);\n for (const [key, value] of Object.entries(parameters)) {\n formData.append(key, value);\n }\n const response = await fetch(serverUrl, {\n method,\n headers,\n body: method === 'PUT' ? file : formData,\n signal: upload.controller.signal,\n });\n if (!response.ok)\n throw new Error(`HTTP error! status: ${response.status}`);\n this.notifyListeners('events', {\n name: 'completed',\n id,\n payload: { statusCode: response.status },\n });\n this.uploads.delete(id);\n }\n catch (error) {\n if (error.name === 'AbortError')\n return;\n if (upload.retries > 0) {\n upload.retries--;\n console.log(`Retrying upload (retries left: ${upload.retries})`);\n setTimeout(() => this.doUpload(id, options), 1000);\n }\n else {\n this.notifyListeners('events', {\n name: 'failed',\n id,\n payload: { error: error.message },\n });\n this.uploads.delete(id);\n }\n }\n }\n async getFileFromPath(filePath) {\n // This is a simplified version. In a real-world scenario,\n // you might need to handle different types of paths or use a file system API.\n try {\n const response = await fetch(filePath);\n const blob = await response.blob();\n return new File([blob], filePath.split('/').pop() || 'file', {\n type: blob.type,\n });\n }\n catch (error) {\n console.error('Error getting file:', error);\n return null;\n }\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,QAAQ,GAAGA,mBAAc,CAAC,UAAU,EAAE;AAC5C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC/D,CAAC;;ACFM,MAAM,WAAW,SAASC,cAAS,CAAC;AAC3C,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC;AAC3B,QAAQ,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE;AAChC,IAAI;AACJ,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE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ACvB,QAAQ;AACR,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -94,6 +94,9 @@ var capacitorCapacitorUpdater = (function (exports, core) {
94
94
  return null;
95
95
  }
96
96
  }
97
+ async getPluginVersion() {
98
+ return { version: 'web' };
99
+ }
97
100
  }
98
101
 
99
102
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Uploader = registerPlugin('Uploader', {\n web: () => import('./web').then((m) => new m.UploaderWeb()),\n});\nexport * from './definitions';\nexport { Uploader };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class UploaderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.uploads = new Map();\n }\n async startUpload(options) {\n console.log('startUpload', options);\n const id = Math.random().toString(36).substring(2, 15);\n const controller = new AbortController();\n const maxRetries = options.maxRetries || 3;\n this.uploads.set(id, { controller, retries: maxRetries });\n this.doUpload(id, options);\n return { id };\n }\n async removeUpload(options) {\n console.log('removeUpload', options);\n const upload = this.uploads.get(options.id);\n if (upload) {\n upload.controller.abort();\n this.uploads.delete(options.id);\n this.notifyListeners('events', {\n name: 'cancelled',\n id: options.id,\n payload: {},\n });\n }\n }\n async doUpload(id, options) {\n const { filePath, serverUrl, headers = {}, method = 'POST', parameters = {} } = options;\n const upload = this.uploads.get(id);\n if (!upload)\n return;\n try {\n const file = await this.getFileFromPath(filePath);\n if (!file)\n throw new Error('File not found');\n const formData = new FormData();\n formData.append('file', file);\n for (const [key, value] of Object.entries(parameters)) {\n formData.append(key, value);\n }\n const response = await fetch(serverUrl, {\n method,\n headers,\n body: method === 'PUT' ? file : formData,\n signal: upload.controller.signal,\n });\n if (!response.ok)\n throw new Error(`HTTP error! status: ${response.status}`);\n this.notifyListeners('events', {\n name: 'completed',\n id,\n payload: { statusCode: response.status },\n });\n this.uploads.delete(id);\n }\n catch (error) {\n if (error.name === 'AbortError')\n return;\n if (upload.retries > 0) {\n upload.retries--;\n console.log(`Retrying upload (retries left: ${upload.retries})`);\n setTimeout(() => this.doUpload(id, options), 1000);\n }\n else {\n this.notifyListeners('events', {\n name: 'failed',\n id,\n payload: { error: error.message },\n });\n this.uploads.delete(id);\n }\n }\n }\n async getFileFromPath(filePath) {\n // This is a simplified version. In a real-world scenario,\n // you might need to handle different types of paths or use a file system API.\n try {\n const response = await fetch(filePath);\n const blob = await response.blob();\n return new File([blob], filePath.split('/').pop() || 'file', {\n type: blob.type,\n });\n }\n catch (error) {\n console.error('Error getting file:', error);\n return null;\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,QAAQ,GAAGA,mBAAc,CAAC,UAAU,EAAE;IAC5C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/D,CAAC;;ICFM,MAAM,WAAW,SAASC,cAAS,CAAC;IAC3C,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC;IAC3B,QAAQ,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE;IAChC,IAAI;IACJ,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC;IAC3C,QAAQ,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;IAC9D,QAAQ,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE;IAChD,QAAQ,MAAM,UAAU,GAAG,OAAO,CAA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+B,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAChF,gBAAgB,UAAU,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC;IAClE,YAAY;IACZ,iBAAiB;IACjB,gBAAgB,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;IAC/C,oBAAoB,IAAI,EAAE,QAAQ;IAClC,oBAAoB,EAAE;IACtB,oBAAoB,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE;IACrD,iBAAiB,CAAC;IAClB,gBAAgB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IACvC,YAAY;IACZ,QAAQ;IACR,IAAI;IACJ,IAAI,MAAM,eAAe,CAAC,QAAQ,EAAE;IACpC;IACA;IACA,QAAQ,IAAI;IACZ,YAAY,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC;IAClD,YAAY,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE;IAC9C,YAAY,OAAO,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,MAAM,EAAE;IACzE,gBAAgB,IAAI,EAAE,IAAI,CAAC,IAAI;IAC/B,aAAa,CAAC;IACd,QAAQ;IACR,QAAQ,OAAO,KAAK,EAAE;IACtB,YAAY,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC;IACvD,YAAY,OAAO,IAAI;IACvB,QAAQ;IACR,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Uploader = registerPlugin('Uploader', {\n web: () => import('./web').then((m) => new m.UploaderWeb()),\n});\nexport * from './definitions';\nexport { Uploader };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class UploaderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.uploads = new Map();\n }\n async startUpload(options) {\n console.log('startUpload', options);\n const id = Math.random().toString(36).substring(2, 15);\n const controller = new AbortController();\n const maxRetries = options.maxRetries || 3;\n this.uploads.set(id, { controller, retries: maxRetries });\n this.doUpload(id, options);\n return { id };\n }\n async removeUpload(options) {\n console.log('removeUpload', options);\n const upload = this.uploads.get(options.id);\n if (upload) {\n upload.controller.abort();\n this.uploads.delete(options.id);\n this.notifyListeners('events', {\n name: 'cancelled',\n id: options.id,\n payload: {},\n });\n }\n }\n async doUpload(id, options) {\n const { filePath, serverUrl, headers = {}, method = 'POST', parameters = {} } = options;\n const upload = this.uploads.get(id);\n if (!upload)\n return;\n try {\n const file = await this.getFileFromPath(filePath);\n if (!file)\n throw new Error('File not found');\n const formData = new FormData();\n formData.append('file', file);\n for (const [key, value] of Object.entries(parameters)) {\n formData.append(key, value);\n }\n const response = await fetch(serverUrl, {\n method,\n headers,\n body: method === 'PUT' ? file : formData,\n signal: upload.controller.signal,\n });\n if (!response.ok)\n throw new Error(`HTTP error! status: ${response.status}`);\n this.notifyListeners('events', {\n name: 'completed',\n id,\n payload: { statusCode: response.status },\n });\n this.uploads.delete(id);\n }\n catch (error) {\n if (error.name === 'AbortError')\n return;\n if (upload.retries > 0) {\n upload.retries--;\n console.log(`Retrying upload (retries left: ${upload.retries})`);\n setTimeout(() => this.doUpload(id, options), 1000);\n }\n else {\n this.notifyListeners('events', {\n name: 'failed',\n id,\n payload: { error: error.message },\n });\n this.uploads.delete(id);\n }\n }\n }\n async getFileFromPath(filePath) {\n // This is a simplified version. In a real-world scenario,\n // you might need to handle different types of paths or use a file system API.\n try {\n const response = await fetch(filePath);\n const blob = await response.blob();\n return new File([blob], filePath.split('/').pop() || 'file', {\n type: blob.type,\n });\n }\n catch (error) {\n console.error('Error getting file:', error);\n return null;\n }\n }\n async getPluginVersion() {\n return { version: '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,eAAe,CAAC,QAAQ,EAAE;IACpC;IACA;IACA,QAAQ,IAAI;IACZ,YAAY,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC;IAClD,YAAY,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE;IAC9C,YAAY,OAAO,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,MAAM,EAAE;IACzE,gBAAgB,IAAI,EAAE,IAAI,CAAC,IAAI;IAC/B,aAAa,CAAC;IACd,QAAQ;IACR,QAAQ,OAAO,KAAK,EAAE;IACtB,YAAY,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC;IACvD,YAAY,OAAO,IAAI;IACvB,QAAQ;IACR,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -3,11 +3,13 @@ import Capacitor
3
3
 
4
4
  @objc(UploaderPlugin)
5
5
  public class UploaderPlugin: CAPPlugin, CAPBridgedPlugin {
6
+ private let PLUGIN_VERSION: String = "7.2.1"
6
7
  public let identifier = "UploaderPlugin"
7
8
  public let jsName = "Uploader"
8
9
  public let pluginMethods: [CAPPluginMethod] = [
9
10
  CAPPluginMethod(name: "startUpload", returnType: CAPPluginReturnPromise),
10
- CAPPluginMethod(name: "removeUpload", returnType: CAPPluginReturnPromise)
11
+ CAPPluginMethod(name: "removeUpload", returnType: CAPPluginReturnPromise),
12
+ CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
11
13
  ]
12
14
  private let implementation = Uploader()
13
15
 
@@ -58,4 +60,9 @@ public class UploaderPlugin: CAPPlugin, CAPBridgedPlugin {
58
60
  }
59
61
  }
60
62
  }
63
+
64
+ @objc func getPluginVersion(_ call: CAPPluginCall) {
65
+ call.resolve(["version": self.PLUGIN_VERSION])
66
+ }
67
+
61
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-uploader",
3
- "version": "7.1.22",
3
+ "version": "7.2.1",
4
4
  "description": "Upload file natively",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",