@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.mjs CHANGED
@@ -1,5 +1,107 @@
1
+ // package.json
2
+ var name = "@duckdb/duckdb-wasm-shell";
3
+ var version = "1.13.1-dev98.0";
4
+ var description = "";
5
+ var author = "Andre Kohn <kohn.a@outlook.com>";
6
+ var license = "MPL-2.0";
7
+ var repository = {
8
+ type: "git",
9
+ url: "https://github.com/duckdb/duckdb-wasm.git"
10
+ };
11
+ var keywords = [
12
+ "sql",
13
+ "duckdb",
14
+ "relational",
15
+ "database",
16
+ "data",
17
+ "query",
18
+ "wasm",
19
+ "analytics",
20
+ "olap",
21
+ "arrow",
22
+ "parquet",
23
+ "json",
24
+ "csv"
25
+ ];
26
+ var dependencies = {
27
+ "@duckdb/duckdb-wasm": "^1.13.1-dev98.0",
28
+ xterm: "^4.16.0",
29
+ "xterm-addon-fit": "^0.5.0",
30
+ "xterm-addon-web-links": "^0.5.0",
31
+ "xterm-addon-webgl": "^0.11.4"
32
+ };
33
+ var devDependencies = {
34
+ esbuild: "^0.14.12",
35
+ eslint: "^8.7.0",
36
+ "eslint-plugin-jasmine": "^4.1.3",
37
+ "eslint-plugin-react": "^7.28.0",
38
+ jasmine: "^4.0.2",
39
+ "jasmine-core": "^4.0.0",
40
+ "jasmine-spec-reporter": "^7.0.0",
41
+ "make-dir": "^3.1.0",
42
+ prettier: "^2.5.1",
43
+ rimraf: "^3.0.2",
44
+ "wasm-pack": "^0.10.2"
45
+ };
46
+ var scripts = {
47
+ postinstall: "node ../../node_modules/wasm-pack/install.js",
48
+ "build:debug": "node bundle.mjs debug && tsc --emitDeclarationOnly",
49
+ "build:release": "node bundle.mjs release && tsc --emitDeclarationOnly",
50
+ lint: "eslint src"
51
+ };
52
+ var files = [
53
+ "dist",
54
+ "!dist/types/test"
55
+ ];
56
+ var main = "dist/shell.cjs";
57
+ var module = "dist/shell.mjs";
58
+ var types = "dist/shell.d.ts";
59
+ var jsdelivr = "dist/shell.cjs";
60
+ var unpkg = "dist/shell.mjs";
61
+ var sideEffects = false;
62
+ var exports = {
63
+ "./dist/shell_bg.wasm": "./dist/shell_bg.wasm",
64
+ "./dist/shell.js": "./dist/shell_bg.js",
65
+ "./dist/shell.cjs": "./dist/shell_bg.cjs",
66
+ "./dist/shell.mjs": "./dist/shell_bg.mjs",
67
+ "./dist/shell": "./dist/shell_bg.mjs",
68
+ ".": {
69
+ types: "./dist/shell.d.ts",
70
+ import: "./dist/shell.mjs",
71
+ require: "./dist/shell.cjs"
72
+ }
73
+ };
74
+ var package_default = {
75
+ name,
76
+ version,
77
+ description,
78
+ author,
79
+ license,
80
+ repository,
81
+ keywords,
82
+ dependencies,
83
+ devDependencies,
84
+ scripts,
85
+ files,
86
+ main,
87
+ module,
88
+ types,
89
+ jsdelivr,
90
+ unpkg,
91
+ sideEffects,
92
+ exports
93
+ };
94
+
95
+ // src/version.ts
96
+ var PACKAGE_NAME = package_default.name;
97
+ var PACKAGE_VERSION = package_default.version;
98
+ var VERSION_PARTS = package_default.version.split(".");
99
+ var PACKAGE_VERSION_MAJOR = VERSION_PARTS[0];
100
+ var PACKAGE_VERSION_MINOR = VERSION_PARTS[1];
101
+ var PACKAGE_VERSION_PATCH = VERSION_PARTS[2];
102
+
1
103
  // crate/pkg/shell.js
2
- import { getPlatformFeatures, PACKAGE_NAME, PACKAGE_VERSION } from "@duckdb/duckdb-wasm";
104
+ import { getPlatformFeatures, PACKAGE_NAME as PACKAGE_NAME2, PACKAGE_VERSION as PACKAGE_VERSION2 } from "@duckdb/duckdb-wasm";
3
105
  import { Terminal } from "xterm";
4
106
  import { FitAddon } from "xterm-addon-fit";
5
107
  import { WebLinksAddon } from "xterm-addon-web-links";
@@ -105,17 +207,17 @@ function debugString(val) {
105
207
  return `"${val}"`;
106
208
  }
107
209
  if (type == "symbol") {
108
- const description = val.description;
109
- if (description == null) {
210
+ const description2 = val.description;
211
+ if (description2 == null) {
110
212
  return "Symbol";
111
213
  } else {
112
- return `Symbol(${description})`;
214
+ return `Symbol(${description2})`;
113
215
  }
114
216
  }
115
217
  if (type == "function") {
116
- const name = val.name;
117
- if (typeof name == "string" && name.length > 0) {
118
- return `Function(${name})`;
218
+ const name2 = val.name;
219
+ if (typeof name2 == "string" && name2.length > 0) {
220
+ return `Function(${name2})`;
119
221
  } else {
120
222
  return "Function";
121
223
  }
@@ -193,6 +295,11 @@ function handleError(f, args) {
193
295
  function embed(elem, runtime, options) {
194
296
  wasm.embed(addHeapObject(elem), addHeapObject(runtime), addHeapObject(options));
195
297
  }
298
+ function write(text) {
299
+ var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
300
+ var len0 = WASM_VECTOR_LEN;
301
+ wasm.write(ptr0, len0);
302
+ }
196
303
  function writeln(text) {
197
304
  var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
198
305
  var len0 = WASM_VECTOR_LEN;
@@ -238,30 +345,30 @@ function passArray8ToWasm0(arg, malloc) {
238
345
  WASM_VECTOR_LEN = arg.length;
239
346
  return ptr;
240
347
  }
241
- function __wbg_adapter_195(arg0, arg1, arg2, arg3) {
348
+ function __wbg_adapter_199(arg0, arg1, arg2, arg3) {
242
349
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h445be38df5ff7a40(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
243
350
  }
244
351
  var ShellInputContext = Object.freeze({ FileInput: 0, "0": "FileInput" });
245
352
  var WcWidth = Object.freeze({ Width0: 0, "0": "Width0", Width1: 1, "1": "Width1", Width2: 2, "2": "Width2" });
246
- async function load(module, imports) {
247
- if (typeof Response === "function" && module instanceof Response) {
353
+ async function load(module2, imports) {
354
+ if (typeof Response === "function" && module2 instanceof Response) {
248
355
  if (typeof WebAssembly.instantiateStreaming === "function") {
249
356
  try {
250
- return await WebAssembly.instantiateStreaming(module, imports);
357
+ return await WebAssembly.instantiateStreaming(module2, imports);
251
358
  } catch (e) {
252
- if (module.headers.get("Content-Type") != "application/wasm") {
359
+ if (module2.headers.get("Content-Type") != "application/wasm") {
253
360
  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);
254
361
  } else {
255
362
  throw e;
256
363
  }
257
364
  }
258
365
  }
259
- const bytes = await module.arrayBuffer();
366
+ const bytes = await module2.arrayBuffer();
260
367
  return await WebAssembly.instantiate(bytes, imports);
261
368
  } else {
262
- const instance = await WebAssembly.instantiate(module, imports);
369
+ const instance = await WebAssembly.instantiate(module2, imports);
263
370
  if (instance instanceof WebAssembly.Instance) {
264
- return { instance, module };
371
+ return { instance, module: module2 };
265
372
  } else {
266
373
  return instance;
267
374
  }
@@ -445,6 +552,12 @@ async function init(input) {
445
552
  return addHeapObject(ret);
446
553
  }, arguments);
447
554
  };
555
+ imports.wbg.__wbg_copyFileToBuffer_e4a7050307f57c30 = function() {
556
+ return handleError(function(arg0, arg1, arg2) {
557
+ var ret = getObject(arg0).copyFileToBuffer(getStringFromWasm0(arg1, arg2));
558
+ return addHeapObject(ret);
559
+ }, arguments);
560
+ };
448
561
  imports.wbg.__wbg_dropFiles_4d857401e3dd75ab = function() {
449
562
  return handleError(function(arg0) {
450
563
  var ret = getObject(arg0).dropFiles();
@@ -469,6 +582,12 @@ async function init(input) {
469
582
  return addHeapObject(ret);
470
583
  }, arguments);
471
584
  };
585
+ imports.wbg.__wbg_downloadFile_223fed31724de5a9 = function() {
586
+ return handleError(function(arg0, arg1, arg2, arg3) {
587
+ var ret = getObject(arg0).downloadFile(getStringFromWasm0(arg1, arg2), takeObject(arg3));
588
+ return addHeapObject(ret);
589
+ }, arguments);
590
+ };
472
591
  imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
473
592
  const obj = getObject(arg1);
474
593
  var ret = JSON.stringify(obj === void 0 ? null : obj);
@@ -563,14 +682,14 @@ async function init(input) {
563
682
  getInt32Memory0()[arg0 / 4 + 0] = ptr0;
564
683
  };
565
684
  imports.wbg.__wbg_static_accessor_PACKAGE_NAME_da91149963a32187 = function(arg0) {
566
- var ret = PACKAGE_NAME;
685
+ var ret = PACKAGE_NAME2;
567
686
  var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
568
687
  var len0 = WASM_VECTOR_LEN;
569
688
  getInt32Memory0()[arg0 / 4 + 1] = len0;
570
689
  getInt32Memory0()[arg0 / 4 + 0] = ptr0;
571
690
  };
572
691
  imports.wbg.__wbg_static_accessor_PACKAGE_VERSION_8aa2f518d9081bf5 = function(arg0) {
573
- var ret = PACKAGE_VERSION;
692
+ var ret = PACKAGE_VERSION2;
574
693
  var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
575
694
  var len0 = WASM_VECTOR_LEN;
576
695
  getInt32Memory0()[arg0 / 4 + 1] = len0;
@@ -657,7 +776,7 @@ async function init(input) {
657
776
  const a = state0.a;
658
777
  state0.a = 0;
659
778
  try {
660
- return __wbg_adapter_195(a, state0.b, arg02, arg12);
779
+ return __wbg_adapter_199(a, state0.b, arg02, arg12);
661
780
  } finally {
662
781
  state0.a = a;
663
782
  }
@@ -754,20 +873,20 @@ async function init(input) {
754
873
  var ret = wasm.memory;
755
874
  return addHeapObject(ret);
756
875
  };
757
- imports.wbg.__wbindgen_closure_wrapper220 = function(arg0, arg1, arg2) {
876
+ imports.wbg.__wbindgen_closure_wrapper222 = function(arg0, arg1, arg2) {
758
877
  var ret = makeMutClosure(arg0, arg1, 4, __wbg_adapter_24);
759
878
  return addHeapObject(ret);
760
879
  };
761
- imports.wbg.__wbindgen_closure_wrapper905 = function(arg0, arg1, arg2) {
762
- var ret = makeMutClosure(arg0, arg1, 148, __wbg_adapter_27);
880
+ imports.wbg.__wbindgen_closure_wrapper918 = function(arg0, arg1, arg2) {
881
+ var ret = makeMutClosure(arg0, arg1, 150, __wbg_adapter_27);
763
882
  return addHeapObject(ret);
764
883
  };
765
884
  if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
766
885
  input = fetch(input);
767
886
  }
768
- const { instance, module } = await load(await input, imports);
887
+ const { instance, module: module2 } = await load(await input, imports);
769
888
  wasm = instance.exports;
770
- init.__wbindgen_wasm_module = module;
889
+ init.__wbindgen_wasm_module = module2;
771
890
  wasm.__wbindgen_start();
772
891
  return wasm;
773
892
  }
@@ -889,11 +1008,15 @@ var HistoryStore = class {
889
1008
  }
890
1009
  };
891
1010
 
892
- // src/utils/platform.ts
1011
+ // src/platform.ts
893
1012
  var isNode = typeof navigator === "undefined" ? true : false;
894
1013
  var userAgent = isNode ? "node" : navigator.userAgent;
895
1014
  var isFirefox = userAgent.includes("Firefox");
896
1015
  var isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);
1016
+ function getJsDelivrModule() {
1017
+ const jsdelivr_dist_url = `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${PACKAGE_VERSION}/dist/`;
1018
+ return new URL(`${jsdelivr_dist_url}dist/shell_bg.wasm`);
1019
+ }
897
1020
 
898
1021
  // src/utils/files.ts
899
1022
  function pickFiles(db) {
@@ -904,13 +1027,13 @@ function pickFiles(db) {
904
1027
  const finish = async () => {
905
1028
  console.log(input.files);
906
1029
  closed = true;
907
- const files = input.files;
908
- for (let i = 0; i < files.length; ++i) {
909
- const file = files.item(i);
1030
+ const files2 = input.files;
1031
+ for (let i = 0; i < files2.length; ++i) {
1032
+ const file = files2.item(i);
910
1033
  await db.dropFile(file.name);
911
1034
  await db.registerFileHandle(file.name, file);
912
1035
  }
913
- resolve(files.length);
1036
+ resolve(files2.length);
914
1037
  };
915
1038
  const deferredFinish = async () => {
916
1039
  window.removeEventListener("focus", deferredFinish);
@@ -962,6 +1085,13 @@ var ShellRuntime = class {
962
1085
  }
963
1086
  return await pickFiles(this.database);
964
1087
  }
1088
+ async downloadFile(name2, buffer) {
1089
+ const blob = new Blob([buffer]);
1090
+ const link = document.createElement("a");
1091
+ link.href = URL.createObjectURL(blob);
1092
+ link.download = name2;
1093
+ link.click();
1094
+ }
965
1095
  async readClipboardText() {
966
1096
  return await navigator.clipboard.readText();
967
1097
  }
@@ -972,6 +1102,12 @@ var ShellRuntime = class {
972
1102
  this.history.push(value);
973
1103
  }
974
1104
  };
1105
+ function formatBytes(value) {
1106
+ const [multiple, k, suffix] = [1e3, "k", "B"];
1107
+ const exp = Math.log(value) / Math.log(multiple) | 0;
1108
+ const size = Number((value / Math.pow(multiple, exp)).toFixed(2));
1109
+ return `${size} ${exp ? `${k}MGTPEZY`[exp - 1] + suffix : `byte${size !== 1 ? "s" : ""}`}`;
1110
+ }
975
1111
  async function embed2(props) {
976
1112
  await shell_default(props.wasmSource);
977
1113
  const runtime = new ShellRuntime(props.container);
@@ -980,16 +1116,26 @@ async function embed2(props) {
980
1116
  withWebGL: hasWebGL()
981
1117
  });
982
1118
  props.container.onresize = runtime.resizeHandler;
1119
+ const TERM_BOLD = "\x1B[1m";
1120
+ const TERM_NORMAL = "\x1B[m";
1121
+ const TERM_CLEAR = "\x1B[2K\r";
1122
+ const progressHandler = (progress) => {
1123
+ if (progress.bytesTotal > 0) {
1124
+ const blocks = Math.floor(progress.bytesLoaded / progress.bytesTotal * 10);
1125
+ const bar = `${"#".repeat(blocks)}${"-".repeat(10 - blocks)}`;
1126
+ write(`${TERM_CLEAR}${TERM_BOLD}[ RUN ]${TERM_NORMAL} Loading ${bar}`);
1127
+ } else {
1128
+ write(`${TERM_CLEAR}${TERM_BOLD}[ RUN ]${TERM_NORMAL} Loading ${formatBytes(progress.bytesLoaded)}`);
1129
+ }
1130
+ };
1131
+ writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} Instantiating DuckDB`);
1132
+ runtime.database = await props.resolveDatabase(progressHandler);
1133
+ writeln(`${TERM_CLEAR}${TERM_BOLD}[ OK ]${TERM_NORMAL} Instantiating DuckDB`);
983
1134
  const step = async (label, work) => {
984
- const TERM_BOLD = "\x1B[1m";
985
- const TERM_NORMAL = "\x1B[m";
986
- writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} ${label}`);
1135
+ writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} ${label}`);
987
1136
  await work();
988
- writeln(`${TERM_BOLD}[ OK ]${TERM_NORMAL} ${label}`);
1137
+ writeln(`${TERM_BOLD}[ OK ]${TERM_NORMAL} ${label}`);
989
1138
  };
990
- await step("Resolving DuckDB", async () => {
991
- runtime.database = await props.resolveDatabase();
992
- });
993
1139
  await step("Loading Shell History", async () => {
994
1140
  await runtime.history.open();
995
1141
  const [hist, histCursor] = await runtime.history.load();
@@ -1000,6 +1146,12 @@ async function embed2(props) {
1000
1146
  });
1001
1147
  }
1002
1148
  export {
1003
- embed2 as embed
1149
+ PACKAGE_NAME,
1150
+ PACKAGE_VERSION,
1151
+ PACKAGE_VERSION_MAJOR,
1152
+ PACKAGE_VERSION_MINOR,
1153
+ PACKAGE_VERSION_PATCH,
1154
+ embed2 as embed,
1155
+ getJsDelivrModule
1004
1156
  };
1005
1157
  //# sourceMappingURL=shell.mjs.map