@d-mok/quasar-app-extension-quasar-axe 2.1.55 → 2.1.57
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-mok/quasar-app-extension-quasar-axe",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.57",
|
|
4
4
|
"description": "A Quasar App Extension",
|
|
5
5
|
"author": "d-mok <49301824+d-mok@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,13 +23,15 @@
|
|
|
23
23
|
"handsontable": "^12.4.0",
|
|
24
24
|
"jszip": "^3.10.1",
|
|
25
25
|
"lodash": "^4.17.21",
|
|
26
|
+
"mime-types": "^2.1.35",
|
|
26
27
|
"papaparse": "^5.4.1",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
28
|
+
"sapphire-js": "^2.0.24",
|
|
29
|
+
"vuedraggable": "^4.1.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@quasar/app": "^3.3.3",
|
|
32
33
|
"@quasar/extras": "^1.14.2",
|
|
34
|
+
"@types/mime-types": "^2.1.1",
|
|
33
35
|
"@types/node": "^20.2.5",
|
|
34
36
|
"core-js": "^3.30.2",
|
|
35
37
|
"quasar": "^2.12.0",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { supabase, HANDLE_ERROR, zipCreate, zipDownload } from '.'
|
|
2
2
|
import { reactive } from 'vue'
|
|
3
3
|
import { FileOptions } from '@supabase/storage-js'
|
|
4
|
+
import { exportFile } from 'quasar'
|
|
5
|
+
import mime from 'mime-types'
|
|
4
6
|
|
|
5
7
|
export class SupbaseBucket extends Map<string, string> {
|
|
6
8
|
constructor(public bucketName: string) {
|
|
@@ -93,41 +95,51 @@ export class SupbaseBucket extends Map<string, string> {
|
|
|
93
95
|
this.delete(path)
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
async
|
|
98
|
+
async save(path: string, filename: string): Promise<File> {
|
|
97
99
|
let url = this.get(path) ?? ''
|
|
98
100
|
if (url === '') throw 'url not found'
|
|
99
|
-
|
|
101
|
+
let file = await createFileObjectFromUrl(url, filename)
|
|
102
|
+
file = renameFileObject(file, filename)
|
|
103
|
+
file = addExtToFileObject(file)
|
|
104
|
+
return file
|
|
100
105
|
}
|
|
101
106
|
|
|
102
|
-
async downloadMany(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async downloadAll(zipName: string = this.bucketName) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
107
|
+
// async downloadMany(
|
|
108
|
+
// paths: string[],
|
|
109
|
+
// filenames: string[],
|
|
110
|
+
// zipName: string = this.bucketName
|
|
111
|
+
// ) {
|
|
112
|
+
// let urls = paths.map($ => this.get($) ?? '')
|
|
113
|
+
// let zip = await zipCreate(Object.fromEntries(filenames.zip(urls)))
|
|
114
|
+
// await zipDownload(zipName, zip)
|
|
115
|
+
// }
|
|
116
|
+
|
|
117
|
+
// async downloadAll(zipName: string = this.bucketName) {
|
|
118
|
+
// let zip = await zipCreate(Object.fromEntries(this))
|
|
119
|
+
// await zipDownload(zipName, zip)
|
|
120
|
+
// }
|
|
116
121
|
|
|
117
122
|
reactive(): this {
|
|
118
123
|
return reactive(this) as this
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
126
|
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
async function createFileObjectFromUrl(
|
|
128
|
+
url: string,
|
|
129
|
+
filename: string
|
|
130
|
+
): Promise<File> {
|
|
131
|
+
const response = await fetch(url)
|
|
132
|
+
const data = await response.blob()
|
|
133
|
+
const type = response.headers.get('content-type') ?? undefined
|
|
134
|
+
return new File([data], filename, { type })
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function renameFileObject(file: File, filename: string): File {
|
|
138
|
+
return new File([file], filename, { type: file.type })
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function addExtToFileObject(file: File): File {
|
|
142
|
+
let ext = mime.extension(file.type) || ''
|
|
143
|
+
if (file.name.endsWith(ext)) return file
|
|
144
|
+
return renameFileObject(file, `${file.name}.${ext}`)
|
|
133
145
|
}
|