Skip to content

Commit

Permalink
doc: publish doc
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Sep 3, 2024
1 parent a18f53d commit b20d665
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 8 deletions.
77 changes: 70 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Upload file natively

WIP: this is a work in progress still not ready for use

## Install

```bash
Expand All @@ -13,25 +15,86 @@ npx cap sync

<docgen-index>

* [`echo(...)`](#echo)
* [`startUpload(...)`](#startupload)
* [`removeUpload(...)`](#removeupload)
* [`addListener('events', ...)`](#addlistenerevents-)
* [Interfaces](#interfaces)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### echo(...)
### startUpload(...)

```typescript
echo(options: { value: string; }) => Promise<{ value: string; }>
startUpload(options: uploadOption) => Promise<{ id: string; }>
```

| Param | Type |
| ------------- | ------------------------------- |
| **`options`** | <code>{ value: string; }</code> |
| Param | Type |
| ------------- | ----------------------------------------------------- |
| **`options`** | <code><a href="#uploadoption">uploadOption</a></code> |

**Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
**Returns:** <code>Promise&lt;{ id: string; }&gt;</code>

--------------------


### removeUpload(...)

```typescript
removeUpload(options: { id: string; }) => Promise<void>
```

| Param | Type |
| ------------- | ---------------------------- |
| **`options`** | <code>{ id: string; }</code> |

--------------------


### addListener('events', ...)

```typescript
addListener(eventName: "events", listenerFunc: (state: UploadEvent) => void) => Promise<PluginListenerHandle>
```

| Param | Type |
| ------------------ | ----------------------------------------------------------------------- |
| **`eventName`** | <code>'events'</code> |
| **`listenerFunc`** | <code>(state: <a href="#uploadevent">UploadEvent</a>) =&gt; void</code> |

**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>

--------------------


### Interfaces


#### uploadOption

| Prop | Type | Default | Since |
| ----------------------- | --------------------------------------- | ------------------------ | ----- |
| **`filePath`** | <code>string</code> | | 1.0.0 |
| **`serverUrl`** | <code>string</code> | | 1.0.0 |
| **`notificationTitle`** | <code>number</code> | <code>'Uploading'</code> | 1.0.0 |
| **`headers`** | <code>{ [key: string]: string; }</code> | | 1.0.0 |


#### PluginListenerHandle

| Prop | Type |
| ------------ | ----------------------------------------- |
| **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |


#### UploadEvent

| Prop | Type | Description |
| ------------- | ----------------------------------------------------------------------- | -------------------------------------------- |
| **`name`** | <code>'uploading' \| 'completed' \| 'failed'</code> | Current status of upload, between 0 and 100. |
| **`payload`** | <code>{ percent?: number; error?: string; statusCode?: number; }</code> | |
| **`id`** | <code>string</code> | |

</docgen-api>
12 changes: 11 additions & 1 deletion src/web.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { WebPlugin } from '@capacitor/core';

import type { UploaderPlugin } from './definitions';
import type { UploaderPlugin, uploadOption } from './definitions';

export class UploaderWeb extends WebPlugin implements UploaderPlugin {
async echo(options: { value: string }): Promise<{ value: string }> {
console.log('ECHO', options);
return options;
}
async startUpload(options: uploadOption): Promise<{ id: string }> {
console.log('startUpload', options);
this.unimplemented('startUpload');
return { id: '123' };
}
async removeUpload(options: { id: string }): Promise<void> {
console.log('removeUpload', options);
this.unimplemented('removeUpload');
return;
}
}

0 comments on commit b20d665

Please sign in to comment.