@visactor/vquery 0.1.28 → 0.1.30
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/dist/db/duckDb.d.ts +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/package.json +1 -1
package/dist/db/duckDb.d.ts
CHANGED
@@ -15,7 +15,7 @@ export declare class DuckDB {
|
|
15
15
|
* @param fileName 文件名
|
16
16
|
* @param source 文件内容
|
17
17
|
*/
|
18
|
-
|
18
|
+
writeFile: <T extends string | ArrayBuffer | Uint8Array | Blob>(fileName: string, source: T) => Promise<void>;
|
19
19
|
/**
|
20
20
|
* @description 执行 SQL 查询
|
21
21
|
* @param sql SQL 语句
|
package/dist/index.cjs
CHANGED
@@ -56,7 +56,7 @@ class DuckDB {
|
|
56
56
|
this.db = null;
|
57
57
|
}
|
58
58
|
};
|
59
|
-
|
59
|
+
writeFile = async (fileName, source)=>{
|
60
60
|
if (!this.db) throw new Error('db is null');
|
61
61
|
let uint8Array;
|
62
62
|
if ('string' == typeof source) {
|
@@ -84,7 +84,7 @@ class DuckDB {
|
|
84
84
|
class IndexedDB {
|
85
85
|
db = null;
|
86
86
|
dbName;
|
87
|
-
storeName = '
|
87
|
+
storeName = 'vqueryFiles';
|
88
88
|
constructor(dbName){
|
89
89
|
this.dbName = dbName;
|
90
90
|
}
|
@@ -173,7 +173,7 @@ class VQuery {
|
|
173
173
|
await this.duckDB.close();
|
174
174
|
this.indexedDB.close();
|
175
175
|
};
|
176
|
-
|
176
|
+
writeFile = async (fileName, source)=>{
|
177
177
|
let blob;
|
178
178
|
if ('string' == typeof source) {
|
179
179
|
const response = await fetch(source);
|
@@ -187,11 +187,11 @@ class VQuery {
|
|
187
187
|
else if (source instanceof Blob) blob = source;
|
188
188
|
else throw new Error('Unsupported source type');
|
189
189
|
await this.indexedDB.writeFile(fileName, blob);
|
190
|
-
await this.duckDB.
|
190
|
+
await this.duckDB.writeFile(fileName, blob);
|
191
191
|
};
|
192
|
-
|
192
|
+
readFile = async (fileName)=>{
|
193
193
|
const blob = await this.indexedDB.readFile(fileName);
|
194
|
-
if (blob) await this.duckDB.
|
194
|
+
if (blob) await this.duckDB.writeFile(fileName, blob);
|
195
195
|
else throw new Error(`File ${fileName} not found in IndexedDB`);
|
196
196
|
};
|
197
197
|
listFiles = ()=>this.indexedDB.listFiles();
|
package/dist/index.d.ts
CHANGED
@@ -15,12 +15,12 @@ export declare class VQuery {
|
|
15
15
|
* @param fileName 文件名
|
16
16
|
* @param source 文件内容
|
17
17
|
*/
|
18
|
-
|
18
|
+
writeFile: (fileName: string, source: string | ArrayBuffer | Uint8Array | Blob) => Promise<void>;
|
19
19
|
/**
|
20
20
|
* @description 从 IndexedDB 读取文件并注册到 DuckDB
|
21
21
|
* @param fileName 文件名
|
22
22
|
*/
|
23
|
-
|
23
|
+
readFile: (fileName: string) => Promise<void>;
|
24
24
|
/**
|
25
25
|
* @description 列出 IndexedDB 中的所有文件
|
26
26
|
*/
|
package/dist/index.js
CHANGED
@@ -28,7 +28,7 @@ class DuckDB {
|
|
28
28
|
this.db = null;
|
29
29
|
}
|
30
30
|
};
|
31
|
-
|
31
|
+
writeFile = async (fileName, source)=>{
|
32
32
|
if (!this.db) throw new Error('db is null');
|
33
33
|
let uint8Array;
|
34
34
|
if ('string' == typeof source) {
|
@@ -56,7 +56,7 @@ class DuckDB {
|
|
56
56
|
class IndexedDB {
|
57
57
|
db = null;
|
58
58
|
dbName;
|
59
|
-
storeName = '
|
59
|
+
storeName = 'vqueryFiles';
|
60
60
|
constructor(dbName){
|
61
61
|
this.dbName = dbName;
|
62
62
|
}
|
@@ -145,7 +145,7 @@ class VQuery {
|
|
145
145
|
await this.duckDB.close();
|
146
146
|
this.indexedDB.close();
|
147
147
|
};
|
148
|
-
|
148
|
+
writeFile = async (fileName, source)=>{
|
149
149
|
let blob;
|
150
150
|
if ('string' == typeof source) {
|
151
151
|
const response = await fetch(source);
|
@@ -159,11 +159,11 @@ class VQuery {
|
|
159
159
|
else if (source instanceof Blob) blob = source;
|
160
160
|
else throw new Error('Unsupported source type');
|
161
161
|
await this.indexedDB.writeFile(fileName, blob);
|
162
|
-
await this.duckDB.
|
162
|
+
await this.duckDB.writeFile(fileName, blob);
|
163
163
|
};
|
164
|
-
|
164
|
+
readFile = async (fileName)=>{
|
165
165
|
const blob = await this.indexedDB.readFile(fileName);
|
166
|
-
if (blob) await this.duckDB.
|
166
|
+
if (blob) await this.duckDB.writeFile(fileName, blob);
|
167
167
|
else throw new Error(`File ${fileName} not found in IndexedDB`);
|
168
168
|
};
|
169
169
|
listFiles = ()=>this.indexedDB.listFiles();
|