@duckdb/duckdb-wasm-shell 1.13.1-dev20.0 → 1.13.1-dev98.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.
package/dist/shell.js CHANGED
@@ -7,6 +7,108 @@
7
7
  throw new Error('Dynamic require of "' + x + '" is not supported');
8
8
  });
9
9
 
10
+ // package.json
11
+ var name = "@duckdb/duckdb-wasm-shell";
12
+ var version = "1.13.1-dev98.0";
13
+ var description = "";
14
+ var author = "Andre Kohn <kohn.a@outlook.com>";
15
+ var license = "MPL-2.0";
16
+ var repository = {
17
+ type: "git",
18
+ url: "https://github.com/duckdb/duckdb-wasm.git"
19
+ };
20
+ var keywords = [
21
+ "sql",
22
+ "duckdb",
23
+ "relational",
24
+ "database",
25
+ "data",
26
+ "query",
27
+ "wasm",
28
+ "analytics",
29
+ "olap",
30
+ "arrow",
31
+ "parquet",
32
+ "json",
33
+ "csv"
34
+ ];
35
+ var dependencies = {
36
+ "@duckdb/duckdb-wasm": "^1.13.1-dev98.0",
37
+ xterm: "^4.16.0",
38
+ "xterm-addon-fit": "^0.5.0",
39
+ "xterm-addon-web-links": "^0.5.0",
40
+ "xterm-addon-webgl": "^0.11.4"
41
+ };
42
+ var devDependencies = {
43
+ esbuild: "^0.14.12",
44
+ eslint: "^8.7.0",
45
+ "eslint-plugin-jasmine": "^4.1.3",
46
+ "eslint-plugin-react": "^7.28.0",
47
+ jasmine: "^4.0.2",
48
+ "jasmine-core": "^4.0.0",
49
+ "jasmine-spec-reporter": "^7.0.0",
50
+ "make-dir": "^3.1.0",
51
+ prettier: "^2.5.1",
52
+ rimraf: "^3.0.2",
53
+ "wasm-pack": "^0.10.2"
54
+ };
55
+ var scripts = {
56
+ postinstall: "node ../../node_modules/wasm-pack/install.js",
57
+ "build:debug": "node bundle.mjs debug && tsc --emitDeclarationOnly",
58
+ "build:release": "node bundle.mjs release && tsc --emitDeclarationOnly",
59
+ lint: "eslint src"
60
+ };
61
+ var files = [
62
+ "dist",
63
+ "!dist/types/test"
64
+ ];
65
+ var main = "dist/shell.cjs";
66
+ var module = "dist/shell.mjs";
67
+ var types = "dist/shell.d.ts";
68
+ var jsdelivr = "dist/shell.cjs";
69
+ var unpkg = "dist/shell.mjs";
70
+ var sideEffects = false;
71
+ var exports = {
72
+ "./dist/shell_bg.wasm": "./dist/shell_bg.wasm",
73
+ "./dist/shell.js": "./dist/shell_bg.js",
74
+ "./dist/shell.cjs": "./dist/shell_bg.cjs",
75
+ "./dist/shell.mjs": "./dist/shell_bg.mjs",
76
+ "./dist/shell": "./dist/shell_bg.mjs",
77
+ ".": {
78
+ types: "./dist/shell.d.ts",
79
+ import: "./dist/shell.mjs",
80
+ require: "./dist/shell.cjs"
81
+ }
82
+ };
83
+ var package_default = {
84
+ name,
85
+ version,
86
+ description,
87
+ author,
88
+ license,
89
+ repository,
90
+ keywords,
91
+ dependencies,
92
+ devDependencies,
93
+ scripts,
94
+ files,
95
+ main,
96
+ module,
97
+ types,
98
+ jsdelivr,
99
+ unpkg,
100
+ sideEffects,
101
+ exports
102
+ };
103
+
104
+ // src/version.ts
105
+ var PACKAGE_NAME = package_default.name;
106
+ var PACKAGE_VERSION = package_default.version;
107
+ var VERSION_PARTS = package_default.version.split(".");
108
+ var PACKAGE_VERSION_MAJOR = VERSION_PARTS[0];
109
+ var PACKAGE_VERSION_MINOR = VERSION_PARTS[1];
110
+ var PACKAGE_VERSION_PATCH = VERSION_PARTS[2];
111
+
10
112
  // crate/pkg/shell.js
11
113
  var import_duckdb_wasm = __require("@duckdb/duckdb-wasm");
12
114
  var import_xterm = __require("xterm");
@@ -115,17 +217,17 @@
115
217
  return `"${val}"`;
116
218
  }
117
219
  if (type == "symbol") {
118
- const description = val.description;
119
- if (description == null) {
220
+ const description2 = val.description;
221
+ if (description2 == null) {
120
222
  return "Symbol";
121
223
  } else {
122
- return `Symbol(${description})`;
224
+ return `Symbol(${description2})`;
123
225
  }
124
226
  }
125
227
  if (type == "function") {
126
- const name = val.name;
127
- if (typeof name == "string" && name.length > 0) {
128
- return `Function(${name})`;
228
+ const name2 = val.name;
229
+ if (typeof name2 == "string" && name2.length > 0) {
230
+ return `Function(${name2})`;
129
231
  } else {
130
232
  return "Function";
131
233
  }
@@ -203,6 +305,11 @@ ${val.stack}`;
203
305
  function embed(elem, runtime, options) {
204
306
  wasm.embed(addHeapObject(elem), addHeapObject(runtime), addHeapObject(options));
205
307
  }
308
+ function write(text) {
309
+ var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
310
+ var len0 = WASM_VECTOR_LEN;
311
+ wasm.write(ptr0, len0);
312
+ }
206
313
  function writeln(text) {
207
314
  var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
208
315
  var len0 = WASM_VECTOR_LEN;
@@ -248,30 +355,30 @@ ${val.stack}`;
248
355
  WASM_VECTOR_LEN = arg.length;
249
356
  return ptr;
250
357
  }
251
- function __wbg_adapter_195(arg0, arg1, arg2, arg3) {
358
+ function __wbg_adapter_199(arg0, arg1, arg2, arg3) {
252
359
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h445be38df5ff7a40(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
253
360
  }
254
361
  var ShellInputContext = Object.freeze({ FileInput: 0, "0": "FileInput" });
255
362
  var WcWidth = Object.freeze({ Width0: 0, "0": "Width0", Width1: 1, "1": "Width1", Width2: 2, "2": "Width2" });
256
- async function load(module, imports) {
257
- if (typeof Response === "function" && module instanceof Response) {
363
+ async function load(module2, imports) {
364
+ if (typeof Response === "function" && module2 instanceof Response) {
258
365
  if (typeof WebAssembly.instantiateStreaming === "function") {
259
366
  try {
260
- return await WebAssembly.instantiateStreaming(module, imports);
367
+ return await WebAssembly.instantiateStreaming(module2, imports);
261
368
  } catch (e) {
262
- if (module.headers.get("Content-Type") != "application/wasm") {
369
+ if (module2.headers.get("Content-Type") != "application/wasm") {
263
370
  console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
264
371
  } else {
265
372
  throw e;
266
373
  }
267
374
  }
268
375
  }
269
- const bytes = await module.arrayBuffer();
376
+ const bytes = await module2.arrayBuffer();
270
377
  return await WebAssembly.instantiate(bytes, imports);
271
378
  } else {
272
- const instance = await WebAssembly.instantiate(module, imports);
379
+ const instance = await WebAssembly.instantiate(module2, imports);
273
380
  if (instance instanceof WebAssembly.Instance) {
274
- return { instance, module };
381
+ return { instance, module: module2 };
275
382
  } else {
276
383
  return instance;
277
384
  }
@@ -455,6 +562,12 @@ ${val.stack}`;
455
562
  return addHeapObject(ret);
456
563
  }, arguments);
457
564
  };
565
+ imports.wbg.__wbg_copyFileToBuffer_e4a7050307f57c30 = function() {
566
+ return handleError(function(arg0, arg1, arg2) {
567
+ var ret = getObject(arg0).copyFileToBuffer(getStringFromWasm0(arg1, arg2));
568
+ return addHeapObject(ret);
569
+ }, arguments);
570
+ };
458
571
  imports.wbg.__wbg_dropFiles_4d857401e3dd75ab = function() {
459
572
  return handleError(function(arg0) {
460
573
  var ret = getObject(arg0).dropFiles();
@@ -479,6 +592,12 @@ ${val.stack}`;
479
592
  return addHeapObject(ret);
480
593
  }, arguments);
481
594
  };
595
+ imports.wbg.__wbg_downloadFile_223fed31724de5a9 = function() {
596
+ return handleError(function(arg0, arg1, arg2, arg3) {
597
+ var ret = getObject(arg0).downloadFile(getStringFromWasm0(arg1, arg2), takeObject(arg3));
598
+ return addHeapObject(ret);
599
+ }, arguments);
600
+ };
482
601
  imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
483
602
  const obj = getObject(arg1);
484
603
  var ret = JSON.stringify(obj === void 0 ? null : obj);
@@ -667,7 +786,7 @@ ${val.stack}`;
667
786
  const a = state0.a;
668
787
  state0.a = 0;
669
788
  try {
670
- return __wbg_adapter_195(a, state0.b, arg02, arg12);
789
+ return __wbg_adapter_199(a, state0.b, arg02, arg12);
671
790
  } finally {
672
791
  state0.a = a;
673
792
  }
@@ -764,20 +883,20 @@ ${val.stack}`;
764
883
  var ret = wasm.memory;
765
884
  return addHeapObject(ret);
766
885
  };
767
- imports.wbg.__wbindgen_closure_wrapper220 = function(arg0, arg1, arg2) {
886
+ imports.wbg.__wbindgen_closure_wrapper222 = function(arg0, arg1, arg2) {
768
887
  var ret = makeMutClosure(arg0, arg1, 4, __wbg_adapter_24);
769
888
  return addHeapObject(ret);
770
889
  };
771
- imports.wbg.__wbindgen_closure_wrapper905 = function(arg0, arg1, arg2) {
772
- var ret = makeMutClosure(arg0, arg1, 148, __wbg_adapter_27);
890
+ imports.wbg.__wbindgen_closure_wrapper918 = function(arg0, arg1, arg2) {
891
+ var ret = makeMutClosure(arg0, arg1, 150, __wbg_adapter_27);
773
892
  return addHeapObject(ret);
774
893
  };
775
894
  if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
776
895
  input = fetch(input);
777
896
  }
778
- const { instance, module } = await load(await input, imports);
897
+ const { instance, module: module2 } = await load(await input, imports);
779
898
  wasm = instance.exports;
780
- init.__wbindgen_wasm_module = module;
899
+ init.__wbindgen_wasm_module = module2;
781
900
  wasm.__wbindgen_start();
782
901
  return wasm;
783
902
  }
@@ -899,11 +1018,15 @@ ${val.stack}`;
899
1018
  }
900
1019
  };
901
1020
 
902
- // src/utils/platform.ts
1021
+ // src/platform.ts
903
1022
  var isNode = typeof navigator === "undefined" ? true : false;
904
1023
  var userAgent = isNode ? "node" : navigator.userAgent;
905
1024
  var isFirefox = userAgent.includes("Firefox");
906
1025
  var isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);
1026
+ function getJsDelivrModule() {
1027
+ const jsdelivr_dist_url = `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${PACKAGE_VERSION}/dist/`;
1028
+ return new URL(`${jsdelivr_dist_url}dist/shell_bg.wasm`);
1029
+ }
907
1030
 
908
1031
  // src/utils/files.ts
909
1032
  function pickFiles(db) {
@@ -914,13 +1037,13 @@ ${val.stack}`;
914
1037
  const finish = async () => {
915
1038
  console.log(input.files);
916
1039
  closed = true;
917
- const files = input.files;
918
- for (let i = 0; i < files.length; ++i) {
919
- const file = files.item(i);
1040
+ const files2 = input.files;
1041
+ for (let i = 0; i < files2.length; ++i) {
1042
+ const file = files2.item(i);
920
1043
  await db.dropFile(file.name);
921
1044
  await db.registerFileHandle(file.name, file);
922
1045
  }
923
- resolve(files.length);
1046
+ resolve(files2.length);
924
1047
  };
925
1048
  const deferredFinish = async () => {
926
1049
  window.removeEventListener("focus", deferredFinish);
@@ -972,6 +1095,13 @@ ${val.stack}`;
972
1095
  }
973
1096
  return await pickFiles(this.database);
974
1097
  }
1098
+ async downloadFile(name2, buffer) {
1099
+ const blob = new Blob([buffer]);
1100
+ const link = document.createElement("a");
1101
+ link.href = URL.createObjectURL(blob);
1102
+ link.download = name2;
1103
+ link.click();
1104
+ }
975
1105
  async readClipboardText() {
976
1106
  return await navigator.clipboard.readText();
977
1107
  }
@@ -982,6 +1112,12 @@ ${val.stack}`;
982
1112
  this.history.push(value);
983
1113
  }
984
1114
  };
1115
+ function formatBytes(value) {
1116
+ const [multiple, k, suffix] = [1e3, "k", "B"];
1117
+ const exp = Math.log(value) / Math.log(multiple) | 0;
1118
+ const size = Number((value / Math.pow(multiple, exp)).toFixed(2));
1119
+ return `${size} ${exp ? `${k}MGTPEZY`[exp - 1] + suffix : `byte${size !== 1 ? "s" : ""}`}`;
1120
+ }
985
1121
  async function embed2(props) {
986
1122
  await shell_default(props.wasmSource);
987
1123
  const runtime = new ShellRuntime(props.container);
@@ -990,16 +1126,26 @@ ${val.stack}`;
990
1126
  withWebGL: hasWebGL()
991
1127
  });
992
1128
  props.container.onresize = runtime.resizeHandler;
1129
+ const TERM_BOLD = "\x1B[1m";
1130
+ const TERM_NORMAL = "\x1B[m";
1131
+ const TERM_CLEAR = "\x1B[2K\r";
1132
+ const progressHandler = (progress) => {
1133
+ if (progress.bytesTotal > 0) {
1134
+ const blocks = Math.floor(progress.bytesLoaded / progress.bytesTotal * 10);
1135
+ const bar = `${"#".repeat(blocks)}${"-".repeat(10 - blocks)}`;
1136
+ write(`${TERM_CLEAR}${TERM_BOLD}[ RUN ]${TERM_NORMAL} Loading ${bar}`);
1137
+ } else {
1138
+ write(`${TERM_CLEAR}${TERM_BOLD}[ RUN ]${TERM_NORMAL} Loading ${formatBytes(progress.bytesLoaded)}`);
1139
+ }
1140
+ };
1141
+ writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} Instantiating DuckDB`);
1142
+ runtime.database = await props.resolveDatabase(progressHandler);
1143
+ writeln(`${TERM_CLEAR}${TERM_BOLD}[ OK ]${TERM_NORMAL} Instantiating DuckDB`);
993
1144
  const step = async (label, work) => {
994
- const TERM_BOLD = "\x1B[1m";
995
- const TERM_NORMAL = "\x1B[m";
996
- writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} ${label}`);
1145
+ writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} ${label}`);
997
1146
  await work();
998
- writeln(`${TERM_BOLD}[ OK ]${TERM_NORMAL} ${label}`);
1147
+ writeln(`${TERM_BOLD}[ OK ]${TERM_NORMAL} ${label}`);
999
1148
  };
1000
- await step("Resolving DuckDB", async () => {
1001
- runtime.database = await props.resolveDatabase();
1002
- });
1003
1149
  await step("Loading Shell History", async () => {
1004
1150
  await runtime.history.open();
1005
1151
  const [hist, histCursor] = await runtime.history.load();