svelte-firekit 0.0.25 → 0.1.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 +445 -213
- package/dist/components/Collection.svelte +150 -0
- package/dist/components/Collection.svelte.d.ts +27 -0
- package/dist/components/Ddoc.svelte +131 -0
- package/dist/components/Ddoc.svelte.d.ts +28 -0
- package/dist/components/Node.svelte +97 -0
- package/dist/components/Node.svelte.d.ts +23 -0
- package/dist/components/auth-guard.svelte +89 -0
- package/dist/components/auth-guard.svelte.d.ts +26 -0
- package/dist/components/custom-guard.svelte +122 -0
- package/dist/components/custom-guard.svelte.d.ts +31 -0
- package/dist/components/download-url.svelte +92 -0
- package/dist/components/download-url.svelte.d.ts +19 -0
- package/dist/components/firebase-app.svelte +30 -0
- package/dist/components/firebase-app.svelte.d.ts +7 -0
- package/dist/components/node-list.svelte +102 -0
- package/dist/components/node-list.svelte.d.ts +27 -0
- package/dist/components/signed-in.svelte +42 -0
- package/dist/components/signed-in.svelte.d.ts +11 -0
- package/dist/components/signed-out.svelte +42 -0
- package/dist/components/signed-out.svelte.d.ts +11 -0
- package/dist/components/storage-list.svelte +97 -0
- package/dist/components/storage-list.svelte.d.ts +26 -0
- package/dist/components/upload-task.svelte +108 -0
- package/dist/components/upload-task.svelte.d.ts +24 -0
- package/dist/config.js +17 -39
- package/dist/firebase.d.ts +43 -21
- package/dist/firebase.js +121 -35
- package/dist/index.d.ts +21 -13
- package/dist/index.js +27 -15
- package/dist/services/auth.d.ts +397 -0
- package/dist/services/auth.js +882 -0
- package/dist/services/collection.svelte.d.ts +286 -0
- package/dist/services/collection.svelte.js +871 -0
- package/dist/services/document.svelte.d.ts +288 -0
- package/dist/services/document.svelte.js +555 -0
- package/dist/services/mutations.d.ts +336 -0
- package/dist/services/mutations.js +1079 -0
- package/dist/services/presence.svelte.d.ts +141 -0
- package/dist/services/presence.svelte.js +727 -0
- package/dist/{realtime → services}/realtime.svelte.d.ts +3 -1
- package/dist/{realtime → services}/realtime.svelte.js +13 -7
- package/dist/services/storage.svelte.d.ts +257 -0
- package/dist/services/storage.svelte.js +374 -0
- package/dist/services/user.svelte.d.ts +296 -0
- package/dist/services/user.svelte.js +609 -0
- package/dist/types/auth.d.ts +158 -0
- package/dist/types/auth.js +106 -0
- package/dist/types/collection.d.ts +360 -0
- package/dist/types/collection.js +167 -0
- package/dist/types/document.d.ts +342 -0
- package/dist/types/document.js +148 -0
- package/dist/types/firebase.d.ts +44 -0
- package/dist/types/firebase.js +33 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +4 -0
- package/dist/types/mutations.d.ts +387 -0
- package/dist/types/mutations.js +205 -0
- package/dist/types/presence.d.ts +282 -0
- package/dist/types/presence.js +80 -0
- package/dist/utils/errors.d.ts +21 -0
- package/dist/utils/errors.js +35 -0
- package/dist/utils/firestore.d.ts +9 -0
- package/dist/utils/firestore.js +33 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/providers.d.ts +16 -0
- package/dist/utils/providers.js +30 -0
- package/dist/utils/user.d.ts +8 -0
- package/dist/utils/user.js +29 -0
- package/package.json +64 -64
- package/dist/auth/auth.d.ts +0 -117
- package/dist/auth/auth.js +0 -194
- package/dist/auth/presence.svelte.d.ts +0 -139
- package/dist/auth/presence.svelte.js +0 -373
- package/dist/auth/user.svelte.d.ts +0 -112
- package/dist/auth/user.svelte.js +0 -155
- package/dist/firestore/awaitable-doc.svelte.d.ts +0 -141
- package/dist/firestore/awaitable-doc.svelte.js +0 -183
- package/dist/firestore/batch-mutations.svelte.d.ts +0 -140
- package/dist/firestore/batch-mutations.svelte.js +0 -218
- package/dist/firestore/collection-group.svelte.d.ts +0 -78
- package/dist/firestore/collection-group.svelte.js +0 -120
- package/dist/firestore/collection.svelte.d.ts +0 -96
- package/dist/firestore/collection.svelte.js +0 -137
- package/dist/firestore/doc.svelte.d.ts +0 -90
- package/dist/firestore/doc.svelte.js +0 -131
- package/dist/firestore/document-mutations.svelte.d.ts +0 -164
- package/dist/firestore/document-mutations.svelte.js +0 -273
- package/dist/storage/download-url.svelte.d.ts +0 -83
- package/dist/storage/download-url.svelte.js +0 -114
- package/dist/storage/storage-list.svelte.d.ts +0 -89
- package/dist/storage/storage-list.svelte.js +0 -123
- package/dist/storage/upload-task.svelte.d.ts +0 -94
- package/dist/storage/upload-task.svelte.js +0 -138
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module FirekitStorageList
|
|
3
|
-
*/
|
|
4
|
-
import { type StorageReference } from "firebase/storage";
|
|
5
|
-
/**
|
|
6
|
-
* Manages Firebase Storage directory listing with reactive state
|
|
7
|
-
* @class
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* // List contents of images directory
|
|
12
|
-
* const imagesList = firekitStorageList('images');
|
|
13
|
-
*
|
|
14
|
-
* // Access items and folders
|
|
15
|
-
* console.log('Files:', imagesList.items);
|
|
16
|
-
* console.log('Folders:', imagesList.prefixes);
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
declare class FirekitStorageList {
|
|
20
|
-
/** List of files in directory */
|
|
21
|
-
private _items;
|
|
22
|
-
/** List of subdirectories */
|
|
23
|
-
private _prefixes;
|
|
24
|
-
/** Loading state */
|
|
25
|
-
private _loading;
|
|
26
|
-
/** Error state */
|
|
27
|
-
private _error;
|
|
28
|
-
/** Storage reference */
|
|
29
|
-
private storageRef;
|
|
30
|
-
/**
|
|
31
|
-
* Creates a storage directory lister
|
|
32
|
-
* @param {string} path Storage directory path
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* const list = new FirekitStorageList('uploads/2024');
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
constructor(path: string);
|
|
40
|
-
/**
|
|
41
|
-
* Initializes directory listing
|
|
42
|
-
* @private
|
|
43
|
-
* @param {string} path Storage directory path
|
|
44
|
-
*/
|
|
45
|
-
private initializeList;
|
|
46
|
-
/** Gets list of files */
|
|
47
|
-
get items(): StorageReference[];
|
|
48
|
-
/** Gets list of subdirectories */
|
|
49
|
-
get prefixes(): StorageReference[];
|
|
50
|
-
/** Gets loading state */
|
|
51
|
-
get loading(): boolean;
|
|
52
|
-
/** Gets error state */
|
|
53
|
-
get error(): Error | null;
|
|
54
|
-
/**
|
|
55
|
-
* Refreshes directory listing
|
|
56
|
-
* Useful when directory contents have changed
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* // Refresh after upload
|
|
61
|
-
* await uploadFile('images/new.jpg');
|
|
62
|
-
* imagesList.refresh();
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
refresh(): void;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Creates a storage directory lister
|
|
69
|
-
* @param {string} path Storage directory path
|
|
70
|
-
* @returns {FirekitStorageList} Storage list instance
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* const documents = firekitStorageList('documents');
|
|
75
|
-
*
|
|
76
|
-
* // Use in template
|
|
77
|
-
* {#if documents.loading}
|
|
78
|
-
* <p>Loading...</p>
|
|
79
|
-
* {:else}
|
|
80
|
-
* <ul>
|
|
81
|
-
* {#each documents.items as item}
|
|
82
|
-
* <li>{item.name}</li>
|
|
83
|
-
* {/each}
|
|
84
|
-
* </ul>
|
|
85
|
-
* {/if}
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
export declare function firekitStorageList(path: string): FirekitStorageList;
|
|
89
|
-
export {};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module FirekitStorageList
|
|
3
|
-
*/
|
|
4
|
-
import { ref, listAll } from "firebase/storage";
|
|
5
|
-
import { browser } from "$app/environment";
|
|
6
|
-
import { firebaseService } from "../firebase.js";
|
|
7
|
-
/**
|
|
8
|
-
* Manages Firebase Storage directory listing with reactive state
|
|
9
|
-
* @class
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // List contents of images directory
|
|
14
|
-
* const imagesList = firekitStorageList('images');
|
|
15
|
-
*
|
|
16
|
-
* // Access items and folders
|
|
17
|
-
* console.log('Files:', imagesList.items);
|
|
18
|
-
* console.log('Folders:', imagesList.prefixes);
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
class FirekitStorageList {
|
|
22
|
-
/** List of files in directory */
|
|
23
|
-
_items = $state([]);
|
|
24
|
-
/** List of subdirectories */
|
|
25
|
-
_prefixes = $state([]);
|
|
26
|
-
/** Loading state */
|
|
27
|
-
_loading = $state(true);
|
|
28
|
-
/** Error state */
|
|
29
|
-
_error = $state(null);
|
|
30
|
-
/** Storage reference */
|
|
31
|
-
storageRef = null;
|
|
32
|
-
/**
|
|
33
|
-
* Creates a storage directory lister
|
|
34
|
-
* @param {string} path Storage directory path
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* const list = new FirekitStorageList('uploads/2024');
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
constructor(path) {
|
|
42
|
-
if (browser) {
|
|
43
|
-
this.initializeList(path);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Initializes directory listing
|
|
48
|
-
* @private
|
|
49
|
-
* @param {string} path Storage directory path
|
|
50
|
-
*/
|
|
51
|
-
async initializeList(path) {
|
|
52
|
-
try {
|
|
53
|
-
const storage = firebaseService.getStorageInstance();
|
|
54
|
-
this.storageRef = ref(storage, path);
|
|
55
|
-
const result = await listAll(this.storageRef);
|
|
56
|
-
this._items = result.items;
|
|
57
|
-
this._prefixes = result.prefixes;
|
|
58
|
-
this._loading = false;
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
this._error = error;
|
|
62
|
-
this._loading = false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/** Gets list of files */
|
|
66
|
-
get items() {
|
|
67
|
-
return this._items;
|
|
68
|
-
}
|
|
69
|
-
/** Gets list of subdirectories */
|
|
70
|
-
get prefixes() {
|
|
71
|
-
return this._prefixes;
|
|
72
|
-
}
|
|
73
|
-
/** Gets loading state */
|
|
74
|
-
get loading() {
|
|
75
|
-
return this._loading;
|
|
76
|
-
}
|
|
77
|
-
/** Gets error state */
|
|
78
|
-
get error() {
|
|
79
|
-
return this._error;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Refreshes directory listing
|
|
83
|
-
* Useful when directory contents have changed
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* // Refresh after upload
|
|
88
|
-
* await uploadFile('images/new.jpg');
|
|
89
|
-
* imagesList.refresh();
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
refresh() {
|
|
93
|
-
if (this.storageRef) {
|
|
94
|
-
this._loading = true;
|
|
95
|
-
this._error = null;
|
|
96
|
-
this.initializeList(this.storageRef.fullPath);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Creates a storage directory lister
|
|
102
|
-
* @param {string} path Storage directory path
|
|
103
|
-
* @returns {FirekitStorageList} Storage list instance
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```typescript
|
|
107
|
-
* const documents = firekitStorageList('documents');
|
|
108
|
-
*
|
|
109
|
-
* // Use in template
|
|
110
|
-
* {#if documents.loading}
|
|
111
|
-
* <p>Loading...</p>
|
|
112
|
-
* {:else}
|
|
113
|
-
* <ul>
|
|
114
|
-
* {#each documents.items as item}
|
|
115
|
-
* <li>{item.name}</li>
|
|
116
|
-
* {/each}
|
|
117
|
-
* </ul>
|
|
118
|
-
* {/if}
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
export function firekitStorageList(path) {
|
|
122
|
-
return new FirekitStorageList(path);
|
|
123
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module FirekitUploadTask
|
|
3
|
-
*/
|
|
4
|
-
import { type UploadTaskSnapshot } from "firebase/storage";
|
|
5
|
-
/**
|
|
6
|
-
* Manages Firebase Storage upload operations with reactive state and progress tracking
|
|
7
|
-
* @class
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* // Create upload task
|
|
12
|
-
* const upload = firekitUploadTask('images/photo.jpg', file);
|
|
13
|
-
*
|
|
14
|
-
* // Monitor progress
|
|
15
|
-
* console.log(`Upload progress: ${upload.progress}%`);
|
|
16
|
-
*
|
|
17
|
-
* // Control upload
|
|
18
|
-
* upload.pause();
|
|
19
|
-
* upload.resume();
|
|
20
|
-
* upload.cancel();
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
declare class FirekitUploadTask {
|
|
24
|
-
/** Upload progress percentage */
|
|
25
|
-
private _progress;
|
|
26
|
-
/** Error state */
|
|
27
|
-
private _error;
|
|
28
|
-
/** Current upload snapshot */
|
|
29
|
-
private _snapshot;
|
|
30
|
-
/** Download URL of uploaded file */
|
|
31
|
-
private _downloadURL;
|
|
32
|
-
/** Upload completion state */
|
|
33
|
-
private _completed;
|
|
34
|
-
/** Upload task reference */
|
|
35
|
-
private uploadTask;
|
|
36
|
-
/** Storage reference */
|
|
37
|
-
private storageRef;
|
|
38
|
-
/** Derived download URL */
|
|
39
|
-
readonly URLdownload: string | null;
|
|
40
|
-
/**
|
|
41
|
-
* Creates an upload task
|
|
42
|
-
* @param {string} path Storage path for upload
|
|
43
|
-
* @param {File} file File to upload
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* const task = new FirekitUploadTask('documents/report.pdf', file);
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
constructor(path: string, file: File);
|
|
51
|
-
/**
|
|
52
|
-
* Initializes file upload
|
|
53
|
-
* @private
|
|
54
|
-
* @param {string} path Storage path
|
|
55
|
-
* @param {File} file File to upload
|
|
56
|
-
*/
|
|
57
|
-
private initializeUpload;
|
|
58
|
-
/** Pauses upload */
|
|
59
|
-
pause(): void;
|
|
60
|
-
/** Resumes upload */
|
|
61
|
-
resume(): void;
|
|
62
|
-
/** Cancels upload */
|
|
63
|
-
cancel(): void;
|
|
64
|
-
/** Gets upload progress percentage */
|
|
65
|
-
get progress(): number;
|
|
66
|
-
/** Gets error state */
|
|
67
|
-
get error(): Error | null;
|
|
68
|
-
/** Gets current upload snapshot */
|
|
69
|
-
get snapshot(): UploadTaskSnapshot | null;
|
|
70
|
-
/** Gets download URL */
|
|
71
|
-
get downloadURL(): string | null;
|
|
72
|
-
/** Gets completion state */
|
|
73
|
-
get completed(): boolean;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Creates an upload task
|
|
77
|
-
* @param {string} path Storage path for upload
|
|
78
|
-
* @param {File} file File to upload
|
|
79
|
-
* @returns {FirekitUploadTask} Upload task instance
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const uploadTask = firekitUploadTask('images/profile.jpg', imageFile);
|
|
84
|
-
*
|
|
85
|
-
* // Template usage
|
|
86
|
-
* {#if !uploadTask.completed}
|
|
87
|
-
* <progress value={uploadTask.progress} max="100" />
|
|
88
|
-
* {:else}
|
|
89
|
-
* <img src={uploadTask.downloadURL} alt="Uploaded file" />
|
|
90
|
-
* {/if}
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
export declare function firekitUploadTask(path: string, file: File): FirekitUploadTask;
|
|
94
|
-
export {};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module FirekitUploadTask
|
|
3
|
-
*/
|
|
4
|
-
import { ref, uploadBytesResumable, getDownloadURL } from "firebase/storage";
|
|
5
|
-
import { browser } from "$app/environment";
|
|
6
|
-
import { firebaseService } from "../firebase.js";
|
|
7
|
-
/**
|
|
8
|
-
* Manages Firebase Storage upload operations with reactive state and progress tracking
|
|
9
|
-
* @class
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // Create upload task
|
|
14
|
-
* const upload = firekitUploadTask('images/photo.jpg', file);
|
|
15
|
-
*
|
|
16
|
-
* // Monitor progress
|
|
17
|
-
* console.log(`Upload progress: ${upload.progress}%`);
|
|
18
|
-
*
|
|
19
|
-
* // Control upload
|
|
20
|
-
* upload.pause();
|
|
21
|
-
* upload.resume();
|
|
22
|
-
* upload.cancel();
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
class FirekitUploadTask {
|
|
26
|
-
/** Upload progress percentage */
|
|
27
|
-
_progress = $state(0);
|
|
28
|
-
/** Error state */
|
|
29
|
-
_error = $state(null);
|
|
30
|
-
/** Current upload snapshot */
|
|
31
|
-
_snapshot = $state(null);
|
|
32
|
-
/** Download URL of uploaded file */
|
|
33
|
-
_downloadURL = $state(null);
|
|
34
|
-
/** Upload completion state */
|
|
35
|
-
_completed = $state(false);
|
|
36
|
-
/** Upload task reference */
|
|
37
|
-
uploadTask = null;
|
|
38
|
-
/** Storage reference */
|
|
39
|
-
storageRef = null;
|
|
40
|
-
/** Derived download URL */
|
|
41
|
-
URLdownload = $derived(this._downloadURL);
|
|
42
|
-
/**
|
|
43
|
-
* Creates an upload task
|
|
44
|
-
* @param {string} path Storage path for upload
|
|
45
|
-
* @param {File} file File to upload
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```typescript
|
|
49
|
-
* const task = new FirekitUploadTask('documents/report.pdf', file);
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
constructor(path, file) {
|
|
53
|
-
if (browser) {
|
|
54
|
-
this.initializeUpload(path, file);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Initializes file upload
|
|
59
|
-
* @private
|
|
60
|
-
* @param {string} path Storage path
|
|
61
|
-
* @param {File} file File to upload
|
|
62
|
-
*/
|
|
63
|
-
initializeUpload(path, file) {
|
|
64
|
-
try {
|
|
65
|
-
const storage = firebaseService.getStorageInstance();
|
|
66
|
-
this.storageRef = ref(storage, path);
|
|
67
|
-
this.uploadTask = uploadBytesResumable(this.storageRef, file);
|
|
68
|
-
this.uploadTask.on("state_changed", (snapshot) => {
|
|
69
|
-
this._snapshot = snapshot;
|
|
70
|
-
this._progress =
|
|
71
|
-
(snapshot.bytesTransferred / snapshot.totalBytes) * 100;
|
|
72
|
-
}, (error) => {
|
|
73
|
-
this._error = error;
|
|
74
|
-
}, async () => {
|
|
75
|
-
if (this.storageRef) {
|
|
76
|
-
this._downloadURL = await getDownloadURL(this.storageRef);
|
|
77
|
-
this._completed = true;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
this._error = error;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/** Pauses upload */
|
|
86
|
-
pause() {
|
|
87
|
-
this.uploadTask?.pause();
|
|
88
|
-
}
|
|
89
|
-
/** Resumes upload */
|
|
90
|
-
resume() {
|
|
91
|
-
this.uploadTask?.resume();
|
|
92
|
-
}
|
|
93
|
-
/** Cancels upload */
|
|
94
|
-
cancel() {
|
|
95
|
-
this.uploadTask?.cancel();
|
|
96
|
-
}
|
|
97
|
-
/** Gets upload progress percentage */
|
|
98
|
-
get progress() {
|
|
99
|
-
return this._progress;
|
|
100
|
-
}
|
|
101
|
-
/** Gets error state */
|
|
102
|
-
get error() {
|
|
103
|
-
return this._error;
|
|
104
|
-
}
|
|
105
|
-
/** Gets current upload snapshot */
|
|
106
|
-
get snapshot() {
|
|
107
|
-
return this._snapshot;
|
|
108
|
-
}
|
|
109
|
-
/** Gets download URL */
|
|
110
|
-
get downloadURL() {
|
|
111
|
-
return this._downloadURL;
|
|
112
|
-
}
|
|
113
|
-
/** Gets completion state */
|
|
114
|
-
get completed() {
|
|
115
|
-
return this._completed;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Creates an upload task
|
|
120
|
-
* @param {string} path Storage path for upload
|
|
121
|
-
* @param {File} file File to upload
|
|
122
|
-
* @returns {FirekitUploadTask} Upload task instance
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```typescript
|
|
126
|
-
* const uploadTask = firekitUploadTask('images/profile.jpg', imageFile);
|
|
127
|
-
*
|
|
128
|
-
* // Template usage
|
|
129
|
-
* {#if !uploadTask.completed}
|
|
130
|
-
* <progress value={uploadTask.progress} max="100" />
|
|
131
|
-
* {:else}
|
|
132
|
-
* <img src={uploadTask.downloadURL} alt="Uploaded file" />
|
|
133
|
-
* {/if}
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
export function firekitUploadTask(path, file) {
|
|
137
|
-
return new FirekitUploadTask(path, file);
|
|
138
|
-
}
|