@run-trace/duckdb-wasm 0.1.2 → 0.3.0

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.
Files changed (93) hide show
  1. package/README.md +24 -20
  2. package/dist/duckdb-browser-blocking.cjs +14 -0
  3. package/dist/duckdb-browser-blocking.cjs.map +7 -0
  4. package/dist/duckdb-browser-blocking.d.ts +1 -0
  5. package/dist/duckdb-browser-blocking.mjs +14 -0
  6. package/dist/duckdb-browser-blocking.mjs.map +7 -0
  7. package/dist/duckdb-browser-coi.pthread.worker.js +1 -18
  8. package/dist/duckdb-browser-coi.pthread.worker.js.map +4 -4
  9. package/dist/duckdb-browser-coi.worker.js +1 -18
  10. package/dist/duckdb-browser-coi.worker.js.map +4 -4
  11. package/dist/duckdb-browser-eh.worker.js +1 -14
  12. package/dist/duckdb-browser-eh.worker.js.map +4 -4
  13. package/dist/duckdb-browser-mvp.worker.js +1 -14
  14. package/dist/duckdb-browser.cjs +2 -0
  15. package/dist/duckdb-browser.cjs.map +7 -0
  16. package/dist/duckdb-browser.d.ts +1 -1
  17. package/dist/duckdb-browser.mjs +2 -0
  18. package/dist/duckdb-browser.mjs.map +7 -0
  19. package/dist/duckdb-coi.wasm +0 -0
  20. package/dist/duckdb-eh.wasm +0 -0
  21. package/dist/duckdb-mvp.wasm +0 -0
  22. package/dist/duckdb-node-blocking.cjs +53 -0
  23. package/dist/duckdb-node-blocking.cjs.map +7 -0
  24. package/dist/duckdb-node-blocking.d.ts +1 -0
  25. package/dist/duckdb-node-eh.worker.cjs +4 -2
  26. package/dist/duckdb-node-eh.worker.cjs.map +4 -4
  27. package/dist/duckdb-node-mvp.worker.cjs +3 -2
  28. package/dist/duckdb-node-mvp.worker.cjs.map +4 -4
  29. package/dist/duckdb-node.cjs +2 -0
  30. package/dist/duckdb-node.cjs.map +7 -0
  31. package/dist/duckdb-node.d.ts +1 -1
  32. package/dist/types/{bindings → src/bindings}/bindings_base.d.ts +3 -2
  33. package/dist/types/{bindings → src/bindings}/bindings_browser_base.d.ts +2 -1
  34. package/dist/types/{bindings → src/bindings}/bindings_interface.d.ts +2 -0
  35. package/dist/types/{bindings → src/bindings}/bindings_node_base.d.ts +2 -1
  36. package/dist/types/{bindings → src/bindings}/connection.d.ts +18 -6
  37. package/dist/types/{bindings → src/bindings}/duckdb_module.d.ts +1 -3
  38. package/dist/types/src/bindings/index.d.ts +11 -0
  39. package/dist/types/{bindings → src/bindings}/insert_options.d.ts +10 -3
  40. package/dist/types/{bindings → src/bindings}/runtime.d.ts +1 -7
  41. package/dist/types/{bindings → src/bindings}/udf_function.d.ts +3 -2
  42. package/dist/types/src/index.d.ts +7 -0
  43. package/dist/types/{sql_field.d.ts → src/json_typedef.d.ts} +6 -3
  44. package/dist/types/{parallel → src/parallel}/async_bindings_interface.d.ts +2 -2
  45. package/dist/types/{parallel → src/parallel}/async_connection.d.ts +17 -6
  46. package/dist/types/src/parallel/index.d.ts +5 -0
  47. package/dist/types/{platform.d.ts → src/platform.d.ts} +1 -0
  48. package/dist/types/src/targets/duckdb-browser-blocking.d.ts +12 -0
  49. package/dist/types/src/targets/duckdb-browser-coi.pthread.worker.d.ts +1 -0
  50. package/dist/types/src/targets/duckdb-node-blocking.d.ts +13 -0
  51. package/dist/types/src/targets/duckdb.d.ts +9 -0
  52. package/dist/types/src/version.d.ts +5 -0
  53. package/package.json +97 -42
  54. package/dist/duckdb-browser-mvp.worker.js.map +0 -7
  55. package/dist/duckdb-node.mjs +0 -8
  56. package/dist/duckdb-node.mjs.map +0 -7
  57. package/dist/duckdb-wasm.mjs +0 -1160
  58. package/dist/duckdb-wasm.umd.js +0 -1
  59. package/dist/types/bindings/index.d.ts +0 -11
  60. package/dist/types/duckdb.d.ts +0 -8
  61. package/dist/types/index.d.ts +0 -11
  62. package/dist/types/parallel/index.d.ts +0 -5
  63. package/dist/types/targets/duckdb.d.ts +0 -10
  64. package/dist/types/worker_node.d.ts +0 -6
  65. /package/dist/types/{bindings → src/bindings}/bindings_browser_coi.d.ts +0 -0
  66. /package/dist/types/{bindings → src/bindings}/bindings_browser_eh.d.ts +0 -0
  67. /package/dist/types/{bindings → src/bindings}/bindings_browser_mvp.d.ts +0 -0
  68. /package/dist/types/{bindings → src/bindings}/bindings_node_eh.d.ts +0 -0
  69. /package/dist/types/{bindings → src/bindings}/bindings_node_mvp.d.ts +0 -0
  70. /package/dist/types/{bindings → src/bindings}/config.d.ts +0 -0
  71. /package/dist/types/{bindings → src/bindings}/file_stats.d.ts +0 -0
  72. /package/dist/types/{bindings → src/bindings}/progress.d.ts +0 -0
  73. /package/dist/types/{bindings → src/bindings}/runtime_browser.d.ts +0 -0
  74. /package/dist/types/{bindings → src/bindings}/runtime_node.d.ts +0 -0
  75. /package/dist/types/{bindings → src/bindings}/tokens.d.ts +0 -0
  76. /package/dist/types/{bindings → src/bindings}/udf_runtime.d.ts +0 -0
  77. /package/dist/types/{bindings → src/bindings}/web_file.d.ts +0 -0
  78. /package/dist/types/{targets/duckdb-browser-coi.pthread.worker.d.ts → src/index_docs.d.ts} +0 -0
  79. /package/dist/types/{log.d.ts → src/log.d.ts} +0 -0
  80. /package/dist/types/{parallel → src/parallel}/async_bindings.d.ts +0 -0
  81. /package/dist/types/{parallel → src/parallel}/worker_dispatcher.d.ts +0 -0
  82. /package/dist/types/{parallel → src/parallel}/worker_request.d.ts +0 -0
  83. /package/dist/types/{status.d.ts → src/status.d.ts} +0 -0
  84. /package/dist/types/{targets → src/targets}/duckdb-browser-coi.worker.d.ts +0 -0
  85. /package/dist/types/{targets → src/targets}/duckdb-browser-eh.worker.d.ts +0 -0
  86. /package/dist/types/{targets → src/targets}/duckdb-browser-mvp.worker.d.ts +0 -0
  87. /package/dist/types/{targets → src/targets}/duckdb-node-eh.worker.d.ts +0 -0
  88. /package/dist/types/{targets → src/targets}/duckdb-node-mvp.worker.d.ts +0 -0
  89. /package/dist/types/{utils → src/utils}/binary_dump.d.ts +0 -0
  90. /package/dist/types/{utils → src/utils}/index.d.ts +0 -0
  91. /package/dist/types/{utils → src/utils}/opfs_util.d.ts +0 -0
  92. /package/dist/types/{utils → src/utils}/s3_helper.d.ts +0 -0
  93. /package/dist/types/{worker.d.ts → src/worker.d.ts} +0 -0
@@ -1,1160 +0,0 @@
1
- var P = /* @__PURE__ */ ((t) => (t[t.UNDEFINED = 0] = "UNDEFINED", t[t.AUTOMATIC = 1] = "AUTOMATIC", t[t.READ_ONLY = 2] = "READ_ONLY", t[t.READ_WRITE = 3] = "READ_WRITE", t))(P || {}), w = /* @__PURE__ */ ((t) => (t[t.IDENTIFIER = 0] = "IDENTIFIER", t[t.NUMERIC_CONSTANT = 1] = "NUMERIC_CONSTANT", t[t.STRING_CONSTANT = 2] = "STRING_CONSTANT", t[t.OPERATOR = 3] = "OPERATOR", t[t.KEYWORD = 4] = "KEYWORD", t[t.COMMENT = 5] = "COMMENT", t))(w || {}), h = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.DEBUG = 1] = "DEBUG", t[t.INFO = 2] = "INFO", t[t.WARNING = 3] = "WARNING", t[t.ERROR = 4] = "ERROR", t))(h || {}), S = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.CONNECT = 1] = "CONNECT", t[t.DISCONNECT = 2] = "DISCONNECT", t[t.OPEN = 3] = "OPEN", t[t.QUERY = 4] = "QUERY", t[t.INSTANTIATE = 5] = "INSTANTIATE", t))(S || {}), l = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.OK = 1] = "OK", t[t.ERROR = 2] = "ERROR", t[t.START = 3] = "START", t[t.RUN = 4] = "RUN", t[t.CAPTURE = 5] = "CAPTURE", t))(l || {}), N = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.WEB_WORKER = 1] = "WEB_WORKER", t[t.NODE_WORKER = 2] = "NODE_WORKER", t[t.BINDINGS = 3] = "BINDINGS", t[t.ASYNC_DUCKDB = 4] = "ASYNC_DUCKDB", t))(N || {});
2
- class f {
3
- log(s) {
4
- }
5
- }
6
- class v {
7
- constructor(s = 2) {
8
- this.level = s;
9
- }
10
- log(s) {
11
- s.level >= this.level && console.log(s);
12
- }
13
- }
14
- function B(t) {
15
- switch (t) {
16
- case 0:
17
- return "NONE";
18
- case 1:
19
- return "DEBUG";
20
- case 2:
21
- return "INFO";
22
- case 3:
23
- return "WARNING";
24
- case 4:
25
- return "ERROR";
26
- default:
27
- return "?";
28
- }
29
- }
30
- function x(t) {
31
- switch (t) {
32
- case 0:
33
- return "NONE";
34
- case 1:
35
- return "OK";
36
- case 2:
37
- return "ERROR";
38
- case 3:
39
- return "START";
40
- case 4:
41
- return "RUN";
42
- case 5:
43
- return "CAPTURE";
44
- default:
45
- return "?";
46
- }
47
- }
48
- function V(t) {
49
- switch (t) {
50
- case 1:
51
- return "CONNECT";
52
- case 2:
53
- return "DISCONNECT";
54
- case 5:
55
- return "INSTANTIATE";
56
- case 3:
57
- return "OPEN";
58
- case 4:
59
- return "QUERY";
60
- default:
61
- return "?";
62
- }
63
- }
64
- function W(t) {
65
- switch (t) {
66
- case 0:
67
- return "NONE";
68
- case 1:
69
- return "WEB WORKER";
70
- case 2:
71
- return "NODE WORKER";
72
- case 3:
73
- return "DUCKDB BINDINGS";
74
- case 4:
75
- return "DUCKDB";
76
- default:
77
- return "?";
78
- }
79
- }
80
- var u = /* @__PURE__ */ ((t) => (t[t.SUCCESS = 0] = "SUCCESS", t[t.MAX_ARROW_ERROR = 255] = "MAX_ARROW_ERROR", t[t.DUCKDB_WASM_RETRY = 256] = "DUCKDB_WASM_RETRY", t))(u || {});
81
- function X(t) {
82
- return t <= 255;
83
- }
84
- function J(t) {
85
- return t === 256;
86
- }
87
- class U {
88
- constructor(s, e) {
89
- this._bindings = s, this._conn = e;
90
- }
91
- /** Access the database bindings */
92
- get bindings() {
93
- return this._bindings;
94
- }
95
- /** Disconnect from the database */
96
- async close() {
97
- return this._bindings.disconnect(this._conn);
98
- }
99
- /** Brave souls may use this function to consume the underlying connection id */
100
- useUnsafe(s) {
101
- return s(this._bindings, this._conn);
102
- }
103
- /** Run a query */
104
- query(s) {
105
- return this._bindings.logger.log({
106
- timestamp: /* @__PURE__ */ new Date(),
107
- level: h.INFO,
108
- origin: N.ASYNC_DUCKDB,
109
- topic: S.QUERY,
110
- event: l.RUN,
111
- value: s
112
- }), this._bindings.runQuery(this._conn, s);
113
- }
114
- /** Send a query */
115
- async send(s, e = !1) {
116
- this._bindings.logger.log({
117
- timestamp: /* @__PURE__ */ new Date(),
118
- level: h.INFO,
119
- origin: N.ASYNC_DUCKDB,
120
- topic: S.QUERY,
121
- event: l.RUN,
122
- value: s
123
- });
124
- let n = await this._bindings.startPendingQuery(this._conn, s, e);
125
- for (; n == null; ) {
126
- if (this._bindings.isDetached()) {
127
- console.error("cannot send a message since the worker is not set!");
128
- return;
129
- }
130
- n = await this._bindings.pollPendingQuery(this._conn);
131
- }
132
- return new T(this._bindings, this._conn, n);
133
- }
134
- /** Cancel a query that was sent earlier */
135
- async cancelSent() {
136
- return await this._bindings.cancelPendingQuery(this._conn);
137
- }
138
- /** Get table names */
139
- async getTableNames(s) {
140
- return await this._bindings.getTableNames(this._conn, s);
141
- }
142
- /** Create a prepared statement */
143
- async prepare(s) {
144
- const e = await this._bindings.createPrepared(this._conn, s);
145
- return new C(this._bindings, this._conn, e);
146
- }
147
- /** Insert an arrow table from an ipc stream */
148
- async insertArrowFromIPCStream(s, e) {
149
- await this._bindings.insertArrowFromIPCStream(this._conn, s, e);
150
- }
151
- /** Insert csv file from path */
152
- async insertCSVFromPath(s, e) {
153
- await this._bindings.insertCSVFromPath(this._conn, s, e);
154
- }
155
- /** Insert json file from path */
156
- async insertJSONFromPath(s, e) {
157
- await this._bindings.insertJSONFromPath(this._conn, s, e);
158
- }
159
- }
160
- class T {
161
- constructor(s, e, n) {
162
- this.db = s, this.conn = e, this.header = n, this._first = !0, this._depleted = !1, this._inFlight = null;
163
- }
164
- async next() {
165
- if (this._first)
166
- return this._first = !1, { done: !1, value: this.header };
167
- if (this._depleted)
168
- return { done: !0, value: null };
169
- let s = null;
170
- for (this._inFlight != null && (s = await this._inFlight, this._inFlight = null); s == null; )
171
- s = await this.db.fetchQueryResults(this.conn);
172
- return this._depleted = s.length == 0, this._depleted || (this._inFlight = this.db.fetchQueryResults(this.conn)), {
173
- done: this._depleted,
174
- value: s
175
- };
176
- }
177
- [Symbol.asyncIterator]() {
178
- return this;
179
- }
180
- }
181
- class C {
182
- /** Constructor */
183
- constructor(s, e, n) {
184
- this.bindings = s, this.connectionId = e, this.statementId = n;
185
- }
186
- /** Close a prepared statement */
187
- async close() {
188
- await this.bindings.closePrepared(this.connectionId, this.statementId);
189
- }
190
- /** Run a prepared statement */
191
- query(...s) {
192
- return this.bindings.runPrepared(this.connectionId, this.statementId, s);
193
- }
194
- /** Send a prepared statement */
195
- async send(...s) {
196
- const e = await this.bindings.sendPrepared(this.connectionId, this.statementId, s);
197
- return new T(this.bindings, this.connectionId, e);
198
- }
199
- }
200
- var a = /* @__PURE__ */ ((t) => (t.CANCEL_PENDING_QUERY = "CANCEL_PENDING_QUERY", t.CLOSE_PREPARED = "CLOSE_PREPARED", t.COLLECT_FILE_STATISTICS = "COLLECT_FILE_STATISTICS", t.REGISTER_OPFS_FILE_NAME = "REGISTER_OPFS_FILE_NAME", t.CONNECT = "CONNECT", t.COPY_FILE_TO_BUFFER = "COPY_FILE_TO_BUFFER", t.COPY_FILE_TO_PATH = "COPY_FILE_TO_PATH", t.CREATE_PREPARED = "CREATE_PREPARED", t.DISCONNECT = "DISCONNECT", t.DROP_FILE = "DROP_FILE", t.DROP_FILES = "DROP_FILES", t.EXPORT_FILE_STATISTICS = "EXPORT_FILE_STATISTICS", t.FETCH_QUERY_RESULTS = "FETCH_QUERY_RESULTS", t.FLUSH_FILES = "FLUSH_FILES", t.GET_FEATURE_FLAGS = "GET_FEATURE_FLAGS", t.GET_TABLE_NAMES = "GET_TABLE_NAMES", t.GET_VERSION = "GET_VERSION", t.GLOB_FILE_INFOS = "GLOB_FILE_INFOS", t.INSERT_ARROW_FROM_IPC_STREAM = "INSERT_ARROW_FROM_IPC_STREAM", t.INSERT_CSV_FROM_PATH = "IMPORT_CSV_FROM_PATH", t.INSERT_JSON_FROM_PATH = "IMPORT_JSON_FROM_PATH", t.INSTANTIATE = "INSTANTIATE", t.OPEN = "OPEN", t.PING = "PING", t.POLL_PENDING_QUERY = "POLL_PENDING_QUERY", t.REGISTER_FILE_BUFFER = "REGISTER_FILE_BUFFER", t.REGISTER_FILE_HANDLE = "REGISTER_FILE_HANDLE", t.REGISTER_FILE_URL = "REGISTER_FILE_URL", t.RESET = "RESET", t.RUN_PREPARED = "RUN_PREPARED", t.RUN_QUERY = "RUN_QUERY", t.SEND_PREPARED = "SEND_PREPARED", t.START_PENDING_QUERY = "START_PENDING_QUERY", t.TOKENIZE = "TOKENIZE", t))(a || {}), i = /* @__PURE__ */ ((t) => (t.CONNECTION_INFO = "CONNECTION_INFO", t.ERROR = "ERROR", t.FEATURE_FLAGS = "FEATURE_FLAGS", t.FILE_BUFFER = "FILE_BUFFER", t.FILE_INFOS = "FILE_INFOS", t.FILE_SIZE = "FILE_SIZE", t.FILE_STATISTICS = "FILE_STATISTICS", t.INSTANTIATE_PROGRESS = "INSTANTIATE_PROGRESS", t.LOG = "LOG", t.PROGRESS_UPDATE = "PROGRESS_UPDATE", t.OK = "OK", t.PREPARED_STATEMENT_ID = "PREPARED_STATEMENT_ID", t.QUERY_PLAN = "QUERY_PLAN", t.QUERY_RESULT = "QUERY_RESULT", t.QUERY_RESULT_CHUNK = "QUERY_RESULT_CHUNK", t.QUERY_RESULT_HEADER = "QUERY_RESULT_HEADER", t.QUERY_RESULT_HEADER_OR_NULL = "QUERY_RESULT_HEADER_OR_NULL", t.REGISTERED_FILE = "REGISTERED_FILE", t.SCRIPT_TOKENS = "SCRIPT_TOKENS", t.SUCCESS = "SUCCESS", t.TABLE_NAMES = "TABLE_NAMES", t.VERSION_STRING = "VERSION_STRING", t))(i || {});
201
- class E {
202
- constructor(s, e) {
203
- this.promiseResolver = () => {
204
- }, this.promiseRejecter = () => {
205
- }, this.type = s, this.data = e, this.promise = new Promise(
206
- (n, r) => {
207
- this.promiseResolver = n, this.promiseRejecter = r;
208
- }
209
- );
210
- }
211
- }
212
- const L = /'(opfs:\/\/\S*?)'/g, m = /(opfs:\/\/\S*?)/g;
213
- function b(t) {
214
- return t.search(m) > -1;
215
- }
216
- function p(t) {
217
- return [...t.matchAll(L)].map((s) => s[1]);
218
- }
219
- const M = new TextEncoder();
220
- class y {
221
- constructor(s, e = null) {
222
- this._onInstantiationProgress = [], this._onExecutionProgress = [], this._worker = null, this._workerShutdownPromise = null, this._workerShutdownResolver = () => {
223
- }, this._nextMessageId = 0, this._pendingRequests = /* @__PURE__ */ new Map(), this._config = {}, this._logger = s, this._onMessageHandler = this.onMessage.bind(this), this._onErrorHandler = this.onError.bind(this), this._onCloseHandler = this.onClose.bind(this), e != null && this.attach(e);
224
- }
225
- /** Get the logger */
226
- get logger() {
227
- return this._logger;
228
- }
229
- /** Get the logger */
230
- get config() {
231
- return this._config;
232
- }
233
- /** Attach to worker */
234
- attach(s) {
235
- this._worker = s, this._worker.addEventListener("message", this._onMessageHandler), this._worker.addEventListener("error", this._onErrorHandler), this._worker.addEventListener("close", this._onCloseHandler), this._workerShutdownPromise = new Promise(
236
- (e, n) => {
237
- this._workerShutdownResolver = e;
238
- }
239
- );
240
- }
241
- /** Detach from worker */
242
- detach() {
243
- this._worker && (this._worker.removeEventListener("message", this._onMessageHandler), this._worker.removeEventListener("error", this._onErrorHandler), this._worker.removeEventListener("close", this._onCloseHandler), this._worker = null, this._workerShutdownResolver(null), this._workerShutdownPromise = null, this._workerShutdownResolver = () => {
244
- });
245
- }
246
- /** Kill the worker */
247
- async terminate() {
248
- this._worker && (this._worker.terminate(), this._worker = null, this._workerShutdownPromise = null, this._workerShutdownResolver = () => {
249
- });
250
- }
251
- /** Post a task */
252
- async postTask(s, e = []) {
253
- if (!this._worker) {
254
- console.error("cannot send a message since the worker is not set!:" + s.type + "," + s.data);
255
- return;
256
- }
257
- const n = this._nextMessageId++;
258
- return this._pendingRequests.set(n, s), this._worker.postMessage(
259
- {
260
- messageId: n,
261
- type: s.type,
262
- data: s.data
263
- },
264
- e
265
- ), await s.promise;
266
- }
267
- /** Received a message */
268
- onMessage(s) {
269
- var r;
270
- const e = s.data;
271
- switch (e.type) {
272
- // Request failed?
273
- case i.PROGRESS_UPDATE: {
274
- for (const _ of this._onExecutionProgress)
275
- _(e.data);
276
- return;
277
- }
278
- case i.LOG: {
279
- this._logger.log(e.data);
280
- return;
281
- }
282
- // Call progress callback
283
- case i.INSTANTIATE_PROGRESS: {
284
- for (const _ of this._onInstantiationProgress)
285
- _(e.data);
286
- return;
287
- }
288
- }
289
- const n = this._pendingRequests.get(e.requestId);
290
- if (!n) {
291
- console.warn(`unassociated response: [${e.requestId}, ${e.type.toString()}]`);
292
- return;
293
- }
294
- if (this._pendingRequests.delete(e.requestId), e.type == i.ERROR) {
295
- const _ = new Error(e.data.message);
296
- _.name = e.data.name, (r = Object.getOwnPropertyDescriptor(_, "stack")) != null && r.writable && (_.stack = e.data.stack), n.promiseRejecter(_);
297
- return;
298
- }
299
- switch (n.type) {
300
- case a.CLOSE_PREPARED:
301
- case a.COLLECT_FILE_STATISTICS:
302
- case a.REGISTER_OPFS_FILE_NAME:
303
- case a.COPY_FILE_TO_PATH:
304
- case a.DISCONNECT:
305
- case a.DROP_FILE:
306
- case a.DROP_FILES:
307
- case a.FLUSH_FILES:
308
- case a.INSERT_ARROW_FROM_IPC_STREAM:
309
- case a.INSERT_CSV_FROM_PATH:
310
- case a.INSERT_JSON_FROM_PATH:
311
- case a.OPEN:
312
- case a.PING:
313
- case a.REGISTER_FILE_BUFFER:
314
- case a.REGISTER_FILE_HANDLE:
315
- case a.REGISTER_FILE_URL:
316
- case a.RESET:
317
- if (e.type == i.OK) {
318
- n.promiseResolver(e.data);
319
- return;
320
- }
321
- break;
322
- case a.INSTANTIATE:
323
- if (this._onInstantiationProgress = [], e.type == i.OK) {
324
- n.promiseResolver(e.data);
325
- return;
326
- }
327
- break;
328
- case a.GLOB_FILE_INFOS:
329
- if (e.type == i.FILE_INFOS) {
330
- n.promiseResolver(e.data);
331
- return;
332
- }
333
- break;
334
- case a.GET_VERSION:
335
- if (e.type == i.VERSION_STRING) {
336
- n.promiseResolver(e.data);
337
- return;
338
- }
339
- break;
340
- case a.GET_FEATURE_FLAGS:
341
- if (e.type == i.FEATURE_FLAGS) {
342
- n.promiseResolver(e.data);
343
- return;
344
- }
345
- break;
346
- case a.GET_TABLE_NAMES:
347
- if (e.type == i.TABLE_NAMES) {
348
- n.promiseResolver(e.data);
349
- return;
350
- }
351
- break;
352
- case a.TOKENIZE:
353
- if (e.type == i.SCRIPT_TOKENS) {
354
- n.promiseResolver(e.data);
355
- return;
356
- }
357
- break;
358
- case a.COPY_FILE_TO_BUFFER:
359
- if (e.type == i.FILE_BUFFER) {
360
- n.promiseResolver(e.data);
361
- return;
362
- }
363
- break;
364
- case a.EXPORT_FILE_STATISTICS:
365
- if (e.type == i.FILE_STATISTICS) {
366
- n.promiseResolver(e.data);
367
- return;
368
- }
369
- break;
370
- case a.CONNECT:
371
- if (e.type == i.CONNECTION_INFO) {
372
- n.promiseResolver(e.data);
373
- return;
374
- }
375
- break;
376
- case a.RUN_PREPARED:
377
- case a.RUN_QUERY:
378
- if (e.type == i.QUERY_RESULT) {
379
- n.promiseResolver(e.data);
380
- return;
381
- }
382
- break;
383
- case a.SEND_PREPARED:
384
- if (e.type == i.QUERY_RESULT_HEADER) {
385
- n.promiseResolver(e.data);
386
- return;
387
- }
388
- break;
389
- case a.START_PENDING_QUERY:
390
- if (e.type == i.QUERY_RESULT_HEADER_OR_NULL) {
391
- n.promiseResolver(e.data);
392
- return;
393
- }
394
- break;
395
- case a.POLL_PENDING_QUERY:
396
- if (e.type == i.QUERY_RESULT_HEADER_OR_NULL) {
397
- n.promiseResolver(e.data);
398
- return;
399
- }
400
- break;
401
- case a.CANCEL_PENDING_QUERY:
402
- if (this._onInstantiationProgress = [], e.type == i.SUCCESS) {
403
- n.promiseResolver(e.data);
404
- return;
405
- }
406
- break;
407
- case a.FETCH_QUERY_RESULTS:
408
- if (e.type == i.QUERY_RESULT_CHUNK) {
409
- n.promiseResolver(e.data);
410
- return;
411
- }
412
- break;
413
- case a.CREATE_PREPARED:
414
- if (e.type == i.PREPARED_STATEMENT_ID) {
415
- n.promiseResolver(e.data);
416
- return;
417
- }
418
- break;
419
- }
420
- n.promiseRejecter(new Error(`unexpected response type: ${e.type.toString()}`));
421
- }
422
- /** Received an error */
423
- onError(s) {
424
- console.error(s), console.error(`error in duckdb worker: ${s.message}`), this._pendingRequests.clear();
425
- }
426
- /** The worker was closed */
427
- onClose() {
428
- if (this._workerShutdownResolver(null), this._pendingRequests.size != 0) {
429
- console.warn(`worker terminated with ${this._pendingRequests.size} pending requests`);
430
- return;
431
- }
432
- this._pendingRequests.clear();
433
- }
434
- /** Is in detached state, no worker defined */
435
- isDetached() {
436
- return !this._worker;
437
- }
438
- /** Reset the duckdb */
439
- async reset() {
440
- const s = new E(a.RESET, null);
441
- return await this.postTask(s);
442
- }
443
- /** Ping the worker thread */
444
- async ping() {
445
- const s = new E(a.PING, null);
446
- await this.postTask(s);
447
- }
448
- /** Try to drop a file */
449
- async dropFile(s) {
450
- const e = new E(a.DROP_FILE, s);
451
- return await this.postTask(e);
452
- }
453
- /** Try to drop files */
454
- async dropFiles(s) {
455
- const e = new E(a.DROP_FILES, s);
456
- return await this.postTask(e);
457
- }
458
- /** Flush all files */
459
- async flushFiles() {
460
- const s = new E(a.FLUSH_FILES, null);
461
- return await this.postTask(s);
462
- }
463
- /** Open the database */
464
- async instantiate(s, e = null, n = (r) => {
465
- }) {
466
- this._onInstantiationProgress.push(n);
467
- const r = new E(
468
- a.INSTANTIATE,
469
- [s, e]
470
- );
471
- return await this.postTask(r);
472
- }
473
- /** Get the version */
474
- async getVersion() {
475
- const s = new E(a.GET_VERSION, null);
476
- return await this.postTask(s);
477
- }
478
- /** Get the feature flags */
479
- async getFeatureFlags() {
480
- const s = new E(
481
- a.GET_FEATURE_FLAGS,
482
- null
483
- );
484
- return await this.postTask(s);
485
- }
486
- /** Open a new database */
487
- async open(s) {
488
- this._config = s;
489
- const e = new E(a.OPEN, s);
490
- await this.postTask(e);
491
- }
492
- /** Tokenize a script text */
493
- async tokenize(s) {
494
- const e = new E(a.TOKENIZE, s);
495
- return await this.postTask(e);
496
- }
497
- /** Connect to the database */
498
- async connectInternal() {
499
- const s = new E(a.CONNECT, null);
500
- return await this.postTask(s);
501
- }
502
- /** Connect to the database */
503
- async connect() {
504
- const s = await this.connectInternal();
505
- return new U(this, s);
506
- }
507
- /** Disconnect from the database */
508
- async disconnect(s) {
509
- const e = new E(
510
- a.DISCONNECT,
511
- s
512
- );
513
- await this.postTask(e);
514
- }
515
- /** Run a query */
516
- async runQuery(s, e) {
517
- if (this.shouldOPFSFileHandling()) {
518
- const n = await this.registerOPFSFileFromSQL(e);
519
- try {
520
- return await this._runQueryAsync(s, e);
521
- } finally {
522
- n.length > 0 && await this.dropFiles(n);
523
- }
524
- } else
525
- return await this._runQueryAsync(s, e);
526
- }
527
- async _runQueryAsync(s, e) {
528
- const n = new E(
529
- a.RUN_QUERY,
530
- [s, e]
531
- );
532
- return await this.postTask(n);
533
- }
534
- /** Start a pending query */
535
- async startPendingQuery(s, e, n = !1) {
536
- if (this.shouldOPFSFileHandling()) {
537
- const r = await this.registerOPFSFileFromSQL(e);
538
- try {
539
- return await this._startPendingQueryAsync(s, e, n);
540
- } finally {
541
- r.length > 0 && await this.dropFiles(r);
542
- }
543
- } else
544
- return await this._startPendingQueryAsync(s, e, n);
545
- }
546
- async _startPendingQueryAsync(s, e, n = !1) {
547
- const r = new E(a.START_PENDING_QUERY, [s, e, n]);
548
- return await this.postTask(r);
549
- }
550
- /** Poll a pending query */
551
- async pollPendingQuery(s) {
552
- const e = new E(
553
- a.POLL_PENDING_QUERY,
554
- s
555
- );
556
- return await this.postTask(e);
557
- }
558
- /** Cancel a pending query */
559
- async cancelPendingQuery(s) {
560
- const e = new E(
561
- a.CANCEL_PENDING_QUERY,
562
- s
563
- );
564
- return await this.postTask(e);
565
- }
566
- /** Fetch query results */
567
- async fetchQueryResults(s) {
568
- const e = new E(
569
- a.FETCH_QUERY_RESULTS,
570
- s
571
- );
572
- return await this.postTask(e);
573
- }
574
- /** Get table names */
575
- async getTableNames(s, e) {
576
- const n = new E(
577
- a.GET_TABLE_NAMES,
578
- [s, e]
579
- );
580
- return await this.postTask(n);
581
- }
582
- /** Prepare a statement and return its identifier */
583
- async createPrepared(s, e) {
584
- const n = new E(
585
- a.CREATE_PREPARED,
586
- [s, e]
587
- );
588
- return await this.postTask(n);
589
- }
590
- /** Close a prepared statement */
591
- async closePrepared(s, e) {
592
- const n = new E(
593
- a.CLOSE_PREPARED,
594
- [s, e]
595
- );
596
- await this.postTask(n);
597
- }
598
- /** Execute a prepared statement and return the full result */
599
- async runPrepared(s, e, n) {
600
- const r = new E(
601
- a.RUN_PREPARED,
602
- [s, e, n]
603
- );
604
- return await this.postTask(r);
605
- }
606
- /** Execute a prepared statement and stream the result */
607
- async sendPrepared(s, e, n) {
608
- const r = new E(
609
- a.SEND_PREPARED,
610
- [s, e, n]
611
- );
612
- return await this.postTask(r);
613
- }
614
- /** Glob file infos */
615
- async globFiles(s) {
616
- const e = new E(
617
- a.GLOB_FILE_INFOS,
618
- s
619
- );
620
- return await this.postTask(e);
621
- }
622
- /** Register file text */
623
- async registerFileText(s, e) {
624
- const n = M.encode(e);
625
- await this.registerFileBuffer(s, n);
626
- }
627
- /** Register a file path. */
628
- async registerFileURL(s, e, n, r) {
629
- e === void 0 && (e = s);
630
- const _ = new E(a.REGISTER_FILE_URL, [s, e, n, r]);
631
- await this.postTask(_);
632
- }
633
- /** Register an empty file buffer. */
634
- async registerEmptyFileBuffer(s) {
635
- }
636
- /** Register a file buffer. */
637
- async registerFileBuffer(s, e) {
638
- const n = new E(
639
- a.REGISTER_FILE_BUFFER,
640
- [s, e]
641
- );
642
- await this.postTask(n, [e.buffer]);
643
- }
644
- /** Register a file handle. */
645
- async registerFileHandle(s, e, n, r) {
646
- const _ = new E(a.REGISTER_FILE_HANDLE, [s, e, n, r]);
647
- await this.postTask(_, []);
648
- }
649
- /** Enable file statistics */
650
- async registerOPFSFileName(s) {
651
- const e = new E(
652
- a.REGISTER_OPFS_FILE_NAME,
653
- [s]
654
- );
655
- await this.postTask(e, []);
656
- }
657
- /** Enable file statistics */
658
- async collectFileStatistics(s, e) {
659
- const n = new E(
660
- a.COLLECT_FILE_STATISTICS,
661
- [s, e]
662
- );
663
- await this.postTask(n, []);
664
- }
665
- /** Export file statistics */
666
- async exportFileStatistics(s) {
667
- const e = new E(
668
- a.EXPORT_FILE_STATISTICS,
669
- s
670
- );
671
- return await this.postTask(e, []);
672
- }
673
- /** Copy a file to a buffer. */
674
- async copyFileToBuffer(s) {
675
- const e = new E(
676
- a.COPY_FILE_TO_BUFFER,
677
- s
678
- );
679
- return await this.postTask(e);
680
- }
681
- /** Copy a file to a path. */
682
- async copyFileToPath(s, e) {
683
- const n = new E(
684
- a.COPY_FILE_TO_PATH,
685
- [s, e]
686
- );
687
- await this.postTask(n);
688
- }
689
- /** Insert arrow from an ipc stream */
690
- async insertArrowFromIPCStream(s, e, n) {
691
- if (e.length == 0) return;
692
- const r = new E(a.INSERT_ARROW_FROM_IPC_STREAM, [s, e, n]);
693
- await this.postTask(r, [e.buffer]);
694
- }
695
- /** Insert a csv file */
696
- async insertCSVFromPath(s, e, n) {
697
- const r = new E(
698
- a.INSERT_CSV_FROM_PATH,
699
- [s, e, n]
700
- );
701
- await this.postTask(r);
702
- }
703
- /** Insert a json file */
704
- async insertJSONFromPath(s, e, n) {
705
- const r = new E(
706
- a.INSERT_JSON_FROM_PATH,
707
- [s, e, n]
708
- );
709
- await this.postTask(r);
710
- }
711
- shouldOPFSFileHandling() {
712
- var s;
713
- return b(this.config.path ?? "") ? ((s = this.config.opfs) == null ? void 0 : s.fileHandling) == "auto" : !1;
714
- }
715
- async registerOPFSFileFromSQL(s) {
716
- const e = p(s), n = [];
717
- for (const r of e)
718
- try {
719
- await this.registerOPFSFileName(r), n.push(r);
720
- } catch (_) {
721
- throw console.error(_), new Error("File Not found:" + r);
722
- }
723
- return n;
724
- }
725
- }
726
- function G() {
727
- const t = new TextDecoder();
728
- return (s) => (typeof SharedArrayBuffer < "u" && s.buffer instanceof SharedArrayBuffer && (s = new Uint8Array(s)), t.decode(s));
729
- }
730
- G();
731
- var O = /* @__PURE__ */ ((t) => (t[t.BUFFER = 0] = "BUFFER", t[t.NODE_FS = 1] = "NODE_FS", t[t.BROWSER_FILEREADER = 2] = "BROWSER_FILEREADER", t[t.BROWSER_FSACCESS = 3] = "BROWSER_FSACCESS", t[t.HTTP = 4] = "HTTP", t[t.S3 = 5] = "S3", t))(O || {});
732
- new TextEncoder();
733
- var F = /* @__PURE__ */ ((t) => (t[t.WASM_EXCEPTIONS = 1] = "WASM_EXCEPTIONS", t[t.WASM_THREADS = 2] = "WASM_THREADS", t[t.WASM_SIMD = 4] = "WASM_SIMD", t[t.WASM_BULK_MEMORY = 8] = "WASM_BULK_MEMORY", t[t.EMIT_BIGINT = 16] = "EMIT_BIGINT", t[t.WASMFS = 32] = "WASMFS", t))(F || {});
734
- class j {
735
- constructor() {
736
- this._bindings = null, this._nextMessageId = 0;
737
- }
738
- /** Send log entry to the main thread */
739
- log(s) {
740
- this.postMessage(
741
- {
742
- messageId: this._nextMessageId++,
743
- requestId: 0,
744
- type: i.LOG,
745
- data: s
746
- },
747
- []
748
- );
749
- }
750
- /** Send plain OK without further data */
751
- sendOK(s) {
752
- this.postMessage(
753
- {
754
- messageId: this._nextMessageId++,
755
- requestId: s.messageId,
756
- type: i.OK,
757
- data: null
758
- },
759
- []
760
- );
761
- }
762
- /** Fail with an error */
763
- failWith(s, e) {
764
- const n = {
765
- name: e.name,
766
- message: e.message,
767
- stack: e.stack || void 0
768
- };
769
- this.postMessage(
770
- {
771
- messageId: this._nextMessageId++,
772
- requestId: s.messageId,
773
- type: i.ERROR,
774
- data: n
775
- },
776
- []
777
- );
778
- }
779
- /** Process a request from the main thread */
780
- async onMessage(s) {
781
- switch (s.type) {
782
- case a.PING:
783
- this.sendOK(s);
784
- return;
785
- case a.INSTANTIATE:
786
- this._bindings != null && this.failWith(s, new Error("duckdb already initialized"));
787
- try {
788
- this._bindings = await this.instantiate(s.data[0], s.data[1], (e) => {
789
- this.postMessage(
790
- {
791
- messageId: this._nextMessageId++,
792
- requestId: s.messageId,
793
- type: i.INSTANTIATE_PROGRESS,
794
- data: e
795
- },
796
- []
797
- );
798
- }), this.sendOK(s);
799
- } catch (e) {
800
- console.log(e), this._bindings = null, this.failWith(s, e);
801
- }
802
- return;
803
- }
804
- if (!this._bindings)
805
- return this.failWith(s, new Error("duckdb is not initialized"));
806
- try {
807
- switch (s.type) {
808
- case a.GET_VERSION:
809
- this.postMessage(
810
- {
811
- messageId: this._nextMessageId++,
812
- requestId: s.messageId,
813
- type: i.VERSION_STRING,
814
- data: this._bindings.getVersion()
815
- },
816
- []
817
- );
818
- break;
819
- case a.GET_FEATURE_FLAGS:
820
- this.postMessage(
821
- {
822
- messageId: this._nextMessageId++,
823
- requestId: s.messageId,
824
- type: i.FEATURE_FLAGS,
825
- data: this._bindings.getFeatureFlags()
826
- },
827
- []
828
- );
829
- break;
830
- case a.RESET:
831
- this._bindings.reset(), this.sendOK(s);
832
- break;
833
- case a.OPEN: {
834
- const e = s.data.path, n = !!(this._bindings.getFeatureFlags() & F.WASM_THREADS);
835
- if (e != null && e.startsWith("opfs://") && !n) {
836
- const r = globalThis.DUCKDB_RUNTIME;
837
- r != null && r.prepareDBFileHandle && await r.prepareDBFileHandle(e, O.BROWSER_FSACCESS), s.data.useDirectIO = !0;
838
- }
839
- this._bindings.open(s.data), this.sendOK(s);
840
- break;
841
- }
842
- case a.DROP_FILE:
843
- this._bindings.dropFile(s.data), this.sendOK(s);
844
- break;
845
- case a.DROP_FILES:
846
- this._bindings.dropFiles(s.data), this.sendOK(s);
847
- break;
848
- case a.FLUSH_FILES:
849
- this._bindings.flushFiles(), this.sendOK(s);
850
- break;
851
- case a.CONNECT: {
852
- const e = this._bindings.connect();
853
- this.postMessage(
854
- {
855
- messageId: this._nextMessageId++,
856
- requestId: s.messageId,
857
- type: i.CONNECTION_INFO,
858
- data: e.useUnsafe((n, r) => r)
859
- },
860
- []
861
- );
862
- break;
863
- }
864
- case a.DISCONNECT:
865
- this._bindings.disconnect(s.data), this.sendOK(s);
866
- break;
867
- case a.CREATE_PREPARED: {
868
- const e = this._bindings.createPrepared(s.data[0], s.data[1]);
869
- this.postMessage(
870
- {
871
- messageId: this._nextMessageId++,
872
- requestId: s.messageId,
873
- type: i.PREPARED_STATEMENT_ID,
874
- data: e
875
- },
876
- []
877
- );
878
- break;
879
- }
880
- case a.CLOSE_PREPARED: {
881
- this._bindings.closePrepared(s.data[0], s.data[1]), this.sendOK(s);
882
- break;
883
- }
884
- case a.RUN_PREPARED: {
885
- const e = this._bindings.runPrepared(s.data[0], s.data[1], s.data[2]);
886
- this.postMessage(
887
- {
888
- messageId: this._nextMessageId++,
889
- requestId: s.messageId,
890
- type: i.QUERY_RESULT,
891
- data: e
892
- },
893
- [e.buffer]
894
- );
895
- break;
896
- }
897
- case a.RUN_QUERY: {
898
- const e = this._bindings.runQuery(s.data[0], s.data[1]);
899
- this.postMessage(
900
- {
901
- messageId: this._nextMessageId++,
902
- requestId: s.messageId,
903
- type: i.QUERY_RESULT,
904
- data: e
905
- },
906
- [e.buffer]
907
- );
908
- break;
909
- }
910
- case a.SEND_PREPARED: {
911
- const e = this._bindings.sendPrepared(s.data[0], s.data[1], s.data[2]);
912
- this.postMessage(
913
- {
914
- messageId: this._nextMessageId++,
915
- requestId: s.messageId,
916
- type: i.QUERY_RESULT_HEADER,
917
- data: e
918
- },
919
- [e.buffer]
920
- );
921
- break;
922
- }
923
- case a.START_PENDING_QUERY: {
924
- const e = this._bindings.startPendingQuery(s.data[0], s.data[1], s.data[2]), n = [];
925
- e && n.push(e.buffer), this.postMessage(
926
- {
927
- messageId: this._nextMessageId++,
928
- requestId: s.messageId,
929
- type: i.QUERY_RESULT_HEADER_OR_NULL,
930
- data: e
931
- },
932
- n
933
- );
934
- break;
935
- }
936
- case a.POLL_PENDING_QUERY: {
937
- const e = this._bindings.pollPendingQuery(s.data), n = [];
938
- e && n.push(e.buffer), this.postMessage(
939
- {
940
- messageId: this._nextMessageId++,
941
- requestId: s.messageId,
942
- type: i.QUERY_RESULT_HEADER_OR_NULL,
943
- data: e
944
- },
945
- n
946
- );
947
- break;
948
- }
949
- case a.CANCEL_PENDING_QUERY: {
950
- const e = this._bindings.cancelPendingQuery(s.data);
951
- this.postMessage(
952
- {
953
- messageId: this._nextMessageId++,
954
- requestId: s.messageId,
955
- type: i.SUCCESS,
956
- data: e
957
- },
958
- []
959
- );
960
- break;
961
- }
962
- case a.FETCH_QUERY_RESULTS: {
963
- const e = this._bindings.fetchQueryResults(s.data), n = e ? [e.buffer] : [];
964
- this.postMessage(
965
- {
966
- messageId: this._nextMessageId++,
967
- requestId: s.messageId,
968
- type: i.QUERY_RESULT_CHUNK,
969
- data: e
970
- },
971
- n
972
- );
973
- break;
974
- }
975
- case a.GET_TABLE_NAMES: {
976
- const e = this._bindings.getTableNames(s.data[0], s.data[1]);
977
- this.postMessage(
978
- {
979
- messageId: this._nextMessageId++,
980
- requestId: s.messageId,
981
- type: i.TABLE_NAMES,
982
- data: e
983
- },
984
- []
985
- );
986
- break;
987
- }
988
- case a.GLOB_FILE_INFOS: {
989
- const e = this._bindings.globFiles(s.data);
990
- this.postMessage(
991
- {
992
- messageId: this._nextMessageId++,
993
- requestId: s.messageId,
994
- type: i.FILE_INFOS,
995
- data: e
996
- },
997
- []
998
- );
999
- break;
1000
- }
1001
- case a.REGISTER_FILE_URL:
1002
- this._bindings.registerFileURL(s.data[0], s.data[1], s.data[2], s.data[3]), this.sendOK(s);
1003
- break;
1004
- case a.REGISTER_FILE_BUFFER:
1005
- this._bindings.registerFileBuffer(s.data[0], s.data[1]), this.sendOK(s);
1006
- break;
1007
- case a.REGISTER_FILE_HANDLE:
1008
- await this._bindings.registerFileHandleAsync(
1009
- s.data[0],
1010
- s.data[1],
1011
- s.data[2],
1012
- s.data[3]
1013
- ), this.sendOK(s);
1014
- break;
1015
- case a.COPY_FILE_TO_PATH:
1016
- this._bindings.copyFileToPath(s.data[0], s.data[1]), this.sendOK(s);
1017
- break;
1018
- case a.COPY_FILE_TO_BUFFER: {
1019
- const e = this._bindings.copyFileToBuffer(s.data);
1020
- this.postMessage(
1021
- {
1022
- messageId: this._nextMessageId++,
1023
- requestId: s.messageId,
1024
- type: i.FILE_BUFFER,
1025
- data: e
1026
- },
1027
- []
1028
- );
1029
- break;
1030
- }
1031
- case a.COLLECT_FILE_STATISTICS:
1032
- this._bindings.collectFileStatistics(s.data[0], s.data[1]), this.sendOK(s);
1033
- break;
1034
- case a.REGISTER_OPFS_FILE_NAME:
1035
- await this._bindings.registerOPFSFileName(s.data[0]), this.sendOK(s);
1036
- break;
1037
- case a.EXPORT_FILE_STATISTICS: {
1038
- this.postMessage(
1039
- {
1040
- messageId: this._nextMessageId++,
1041
- requestId: s.messageId,
1042
- type: i.FILE_STATISTICS,
1043
- data: this._bindings.exportFileStatistics(s.data)
1044
- },
1045
- []
1046
- );
1047
- break;
1048
- }
1049
- case a.INSERT_ARROW_FROM_IPC_STREAM: {
1050
- this._bindings.insertArrowFromIPCStream(s.data[0], s.data[1], s.data[2]), this.sendOK(s);
1051
- break;
1052
- }
1053
- case a.INSERT_CSV_FROM_PATH: {
1054
- this._bindings.insertCSVFromPath(s.data[0], s.data[1], s.data[2]), this.sendOK(s);
1055
- break;
1056
- }
1057
- case a.INSERT_JSON_FROM_PATH: {
1058
- this._bindings.insertJSONFromPath(s.data[0], s.data[1], s.data[2]), this.sendOK(s);
1059
- break;
1060
- }
1061
- case a.TOKENIZE: {
1062
- const e = this._bindings.tokenize(s.data);
1063
- this.postMessage(
1064
- {
1065
- messageId: this._nextMessageId++,
1066
- requestId: s.messageId,
1067
- type: i.SCRIPT_TOKENS,
1068
- data: e
1069
- },
1070
- []
1071
- );
1072
- break;
1073
- }
1074
- }
1075
- } catch (e) {
1076
- return console.log(e), this.failWith(s, e);
1077
- }
1078
- }
1079
- }
1080
- const k = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 5, 3, 1, 0, 1, 10, 14, 1, 12, 0, 65, 0, 65, 0, 65, 0, 252, 10, 0, 0, 11])), D = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 8, 1, 6, 0, 6, 64, 25, 11, 11])), Q = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 123, 3, 2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11])), Y = () => (async (t) => {
1081
- try {
1082
- return typeof MessageChannel < "u" && new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)), WebAssembly.validate(t);
1083
- } catch {
1084
- return !1;
1085
- }
1086
- })(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 5, 4, 1, 3, 1, 1, 10, 11, 1, 9, 0, 65, 0, 254, 16, 2, 0, 26, 11])), A = () => typeof navigator > "u", g = () => A() ? "node" : navigator.userAgent, Z = () => g().includes("Firefox"), z = () => /^((?!chrome|android).)*safari/i.test(g());
1087
- let d = null, R = null, o = null, I = null, c = null;
1088
- async function H() {
1089
- return d == null && (d = typeof BigInt64Array < "u"), R == null && (R = await D()), o == null && (o = await Y()), I == null && (I = await Q()), c == null && (c = await k()), {
1090
- bigInt64Array: d,
1091
- crossOriginIsolated: A() || globalThis.crossOriginIsolated || !1,
1092
- wasmExceptions: R,
1093
- wasmSIMD: I,
1094
- wasmThreads: o,
1095
- wasmBulkMemory: c
1096
- };
1097
- }
1098
- async function $(t) {
1099
- const s = await H();
1100
- if (s.wasmExceptions) {
1101
- if (s.wasmSIMD && s.wasmThreads && s.crossOriginIsolated && t.coi)
1102
- return {
1103
- mainModule: t.coi.mainModule,
1104
- mainWorker: t.coi.mainWorker,
1105
- pthreadWorker: t.coi.pthreadWorker
1106
- };
1107
- if (t.eh)
1108
- return {
1109
- mainModule: t.eh.mainModule,
1110
- mainWorker: t.eh.mainWorker,
1111
- pthreadWorker: null
1112
- };
1113
- }
1114
- return {
1115
- mainModule: t.mvp.mainModule,
1116
- mainWorker: t.mvp.mainWorker,
1117
- pthreadWorker: null
1118
- };
1119
- }
1120
- const K = typeof Worker < "u" ? Worker : void 0;
1121
- async function q(t) {
1122
- const s = new Request(t), e = await fetch(s), n = URL.createObjectURL(await e.blob());
1123
- return new K(n);
1124
- }
1125
- async function ss(t, s) {
1126
- const e = new Worker(t.mainWorker), n = new y(s ?? new f(), e);
1127
- return await n.instantiate(t.mainModule, t.pthreadWorker), n;
1128
- }
1129
- export {
1130
- y as AsyncDuckDB,
1131
- U as AsyncDuckDBConnection,
1132
- j as AsyncDuckDBDispatcher,
1133
- C as AsyncPreparedStatement,
1134
- T as AsyncResultStreamIterator,
1135
- v as ConsoleLogger,
1136
- P as DuckDBAccessMode,
1137
- X as IsArrowBuffer,
1138
- J as IsDuckDBWasmRetry,
1139
- l as LogEvent,
1140
- h as LogLevel,
1141
- N as LogOrigin,
1142
- S as LogTopic,
1143
- u as StatusCode,
1144
- w as TokenType,
1145
- f as VoidLogger,
1146
- a as WorkerRequestType,
1147
- i as WorkerResponseType,
1148
- E as WorkerTask,
1149
- q as createWorker,
1150
- ss as duckdb,
1151
- x as getLogEventLabel,
1152
- B as getLogLevelLabel,
1153
- W as getLogOriginLabel,
1154
- V as getLogTopicLabel,
1155
- H as getPlatformFeatures,
1156
- Z as isFirefox,
1157
- A as isNode,
1158
- z as isSafari,
1159
- $ as selectBundle
1160
- };