@duckdb/duckdb-wasm-shell 1.13.1-dev20.0 → 1.13.1-dev240.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
@@ -1,4 +1,11 @@
1
1
  (() => {
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
2
9
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
10
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
11
  }) : x)(function(x) {
@@ -6,6 +13,122 @@
6
13
  return require.apply(this, arguments);
7
14
  throw new Error('Dynamic require of "' + x + '" is not supported');
8
15
  });
16
+ var __reExport = (target, module2, copyDefault, desc) => {
17
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
18
+ for (let key of __getOwnPropNames(module2))
19
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
20
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
21
+ }
22
+ return target;
23
+ };
24
+ var __toESM = (module2, isNodeMode) => {
25
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
26
+ };
27
+
28
+ // package.json
29
+ var name = "@duckdb/duckdb-wasm-shell";
30
+ var version = "1.13.1-dev240.0";
31
+ var description = "";
32
+ var author = "Andre Kohn <kohn.a@outlook.com>";
33
+ var license = "MPL-2.0";
34
+ var repository = {
35
+ type: "git",
36
+ url: "https://github.com/duckdb/duckdb-wasm.git"
37
+ };
38
+ var keywords = [
39
+ "sql",
40
+ "duckdb",
41
+ "relational",
42
+ "database",
43
+ "data",
44
+ "query",
45
+ "wasm",
46
+ "analytics",
47
+ "olap",
48
+ "arrow",
49
+ "parquet",
50
+ "json",
51
+ "csv"
52
+ ];
53
+ var dependencies = {
54
+ "@duckdb/duckdb-wasm": "^1.13.1-dev240.0",
55
+ xterm: "^4.17.0",
56
+ "xterm-addon-fit": "^0.5.0",
57
+ "xterm-addon-web-links": "^0.5.1",
58
+ "xterm-addon-webgl": "^0.11.4"
59
+ };
60
+ var devDependencies = {
61
+ esbuild: "^0.14.23",
62
+ eslint: "^8.10.0",
63
+ "eslint-plugin-jasmine": "^4.1.3",
64
+ "eslint-plugin-react": "^7.29.2",
65
+ jasmine: "^4.0.2",
66
+ "jasmine-core": "^4.0.1",
67
+ "jasmine-spec-reporter": "^7.0.0",
68
+ "make-dir": "^3.1.0",
69
+ prettier: "^2.5.1",
70
+ rimraf: "^3.0.2",
71
+ "wasm-pack": "^0.10.2"
72
+ };
73
+ var scripts = {
74
+ "install:wasmpack": "node ../../node_modules/wasm-pack/install.js",
75
+ "build:debug": "node bundle.mjs debug && tsc --emitDeclarationOnly",
76
+ "build:release": "node bundle.mjs release && tsc --emitDeclarationOnly",
77
+ lint: "eslint src"
78
+ };
79
+ var files = [
80
+ "dist",
81
+ "!dist/types/test"
82
+ ];
83
+ var main = "dist/shell.cjs";
84
+ var module = "dist/shell.mjs";
85
+ var types = "dist/shell.d.ts";
86
+ var jsdelivr = "dist/shell.cjs";
87
+ var unpkg = "dist/shell.mjs";
88
+ var sideEffects = false;
89
+ var exports = {
90
+ "./dist/shell_bg.wasm": "./dist/shell_bg.wasm",
91
+ "./dist/shell.js": "./dist/shell.js",
92
+ "./dist/shell.cjs": "./dist/shell.cjs",
93
+ "./dist/shell.mjs": "./dist/shell.mjs",
94
+ "./dist/shell": "./dist/shell.mjs",
95
+ ".": {
96
+ types: "./dist/shell.d.ts",
97
+ import: "./dist/shell.mjs",
98
+ require: "./dist/shell.cjs"
99
+ }
100
+ };
101
+ var package_default = {
102
+ name,
103
+ version,
104
+ description,
105
+ author,
106
+ license,
107
+ repository,
108
+ keywords,
109
+ dependencies,
110
+ devDependencies,
111
+ scripts,
112
+ files,
113
+ main,
114
+ module,
115
+ types,
116
+ jsdelivr,
117
+ unpkg,
118
+ sideEffects,
119
+ exports
120
+ };
121
+
122
+ // src/version.ts
123
+ var PACKAGE_NAME = package_default.name;
124
+ var PACKAGE_VERSION = package_default.version;
125
+ var VERSION_PARTS = package_default.version.split(".");
126
+ var PACKAGE_VERSION_MAJOR = VERSION_PARTS[0];
127
+ var PACKAGE_VERSION_MINOR = VERSION_PARTS[1];
128
+ var PACKAGE_VERSION_PATCH = VERSION_PARTS[2];
129
+
130
+ // src/shell.ts
131
+ var duckdb = __toESM(__require("@duckdb/duckdb-wasm"));
9
132
 
10
133
  // crate/pkg/shell.js
11
134
  var import_duckdb_wasm = __require("@duckdb/duckdb-wasm");
@@ -115,17 +238,17 @@
115
238
  return `"${val}"`;
116
239
  }
117
240
  if (type == "symbol") {
118
- const description = val.description;
119
- if (description == null) {
241
+ const description2 = val.description;
242
+ if (description2 == null) {
120
243
  return "Symbol";
121
244
  } else {
122
- return `Symbol(${description})`;
245
+ return `Symbol(${description2})`;
123
246
  }
124
247
  }
125
248
  if (type == "function") {
126
- const name = val.name;
127
- if (typeof name == "string" && name.length > 0) {
128
- return `Function(${name})`;
249
+ const name2 = val.name;
250
+ if (typeof name2 == "string" && name2.length > 0) {
251
+ return `Function(${name2})`;
129
252
  } else {
130
253
  return "Function";
131
254
  }
@@ -203,6 +326,11 @@ ${val.stack}`;
203
326
  function embed(elem, runtime, options) {
204
327
  wasm.embed(addHeapObject(elem), addHeapObject(runtime), addHeapObject(options));
205
328
  }
329
+ function write(text) {
330
+ var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
331
+ var len0 = WASM_VECTOR_LEN;
332
+ wasm.write(ptr0, len0);
333
+ }
206
334
  function writeln(text) {
207
335
  var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
208
336
  var len0 = WASM_VECTOR_LEN;
@@ -248,30 +376,30 @@ ${val.stack}`;
248
376
  WASM_VECTOR_LEN = arg.length;
249
377
  return ptr;
250
378
  }
251
- function __wbg_adapter_195(arg0, arg1, arg2, arg3) {
379
+ function __wbg_adapter_199(arg0, arg1, arg2, arg3) {
252
380
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h445be38df5ff7a40(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
253
381
  }
254
382
  var ShellInputContext = Object.freeze({ FileInput: 0, "0": "FileInput" });
255
383
  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) {
384
+ async function load(module2, imports) {
385
+ if (typeof Response === "function" && module2 instanceof Response) {
258
386
  if (typeof WebAssembly.instantiateStreaming === "function") {
259
387
  try {
260
- return await WebAssembly.instantiateStreaming(module, imports);
388
+ return await WebAssembly.instantiateStreaming(module2, imports);
261
389
  } catch (e) {
262
- if (module.headers.get("Content-Type") != "application/wasm") {
390
+ if (module2.headers.get("Content-Type") != "application/wasm") {
263
391
  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
392
  } else {
265
393
  throw e;
266
394
  }
267
395
  }
268
396
  }
269
- const bytes = await module.arrayBuffer();
397
+ const bytes = await module2.arrayBuffer();
270
398
  return await WebAssembly.instantiate(bytes, imports);
271
399
  } else {
272
- const instance = await WebAssembly.instantiate(module, imports);
400
+ const instance = await WebAssembly.instantiate(module2, imports);
273
401
  if (instance instanceof WebAssembly.Instance) {
274
- return { instance, module };
402
+ return { instance, module: module2 };
275
403
  } else {
276
404
  return instance;
277
405
  }
@@ -455,6 +583,12 @@ ${val.stack}`;
455
583
  return addHeapObject(ret);
456
584
  }, arguments);
457
585
  };
586
+ imports.wbg.__wbg_copyFileToBuffer_e4a7050307f57c30 = function() {
587
+ return handleError(function(arg0, arg1, arg2) {
588
+ var ret = getObject(arg0).copyFileToBuffer(getStringFromWasm0(arg1, arg2));
589
+ return addHeapObject(ret);
590
+ }, arguments);
591
+ };
458
592
  imports.wbg.__wbg_dropFiles_4d857401e3dd75ab = function() {
459
593
  return handleError(function(arg0) {
460
594
  var ret = getObject(arg0).dropFiles();
@@ -479,6 +613,12 @@ ${val.stack}`;
479
613
  return addHeapObject(ret);
480
614
  }, arguments);
481
615
  };
616
+ imports.wbg.__wbg_downloadFile_223fed31724de5a9 = function() {
617
+ return handleError(function(arg0, arg1, arg2, arg3) {
618
+ var ret = getObject(arg0).downloadFile(getStringFromWasm0(arg1, arg2), takeObject(arg3));
619
+ return addHeapObject(ret);
620
+ }, arguments);
621
+ };
482
622
  imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
483
623
  const obj = getObject(arg1);
484
624
  var ret = JSON.stringify(obj === void 0 ? null : obj);
@@ -667,7 +807,7 @@ ${val.stack}`;
667
807
  const a = state0.a;
668
808
  state0.a = 0;
669
809
  try {
670
- return __wbg_adapter_195(a, state0.b, arg02, arg12);
810
+ return __wbg_adapter_199(a, state0.b, arg02, arg12);
671
811
  } finally {
672
812
  state0.a = a;
673
813
  }
@@ -764,20 +904,20 @@ ${val.stack}`;
764
904
  var ret = wasm.memory;
765
905
  return addHeapObject(ret);
766
906
  };
767
- imports.wbg.__wbindgen_closure_wrapper220 = function(arg0, arg1, arg2) {
907
+ imports.wbg.__wbindgen_closure_wrapper222 = function(arg0, arg1, arg2) {
768
908
  var ret = makeMutClosure(arg0, arg1, 4, __wbg_adapter_24);
769
909
  return addHeapObject(ret);
770
910
  };
771
- imports.wbg.__wbindgen_closure_wrapper905 = function(arg0, arg1, arg2) {
772
- var ret = makeMutClosure(arg0, arg1, 148, __wbg_adapter_27);
911
+ imports.wbg.__wbindgen_closure_wrapper918 = function(arg0, arg1, arg2) {
912
+ var ret = makeMutClosure(arg0, arg1, 150, __wbg_adapter_27);
773
913
  return addHeapObject(ret);
774
914
  };
775
915
  if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
776
916
  input = fetch(input);
777
917
  }
778
- const { instance, module } = await load(await input, imports);
918
+ const { instance, module: module2 } = await load(await input, imports);
779
919
  wasm = instance.exports;
780
- init.__wbindgen_wasm_module = module;
920
+ init.__wbindgen_wasm_module = module2;
781
921
  wasm.__wbindgen_start();
782
922
  return wasm;
783
923
  }
@@ -899,12 +1039,6 @@ ${val.stack}`;
899
1039
  }
900
1040
  };
901
1041
 
902
- // src/utils/platform.ts
903
- var isNode = typeof navigator === "undefined" ? true : false;
904
- var userAgent = isNode ? "node" : navigator.userAgent;
905
- var isFirefox = userAgent.includes("Firefox");
906
- var isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);
907
-
908
1042
  // src/utils/files.ts
909
1043
  function pickFiles(db) {
910
1044
  return new Promise((resolve, _reject) => {
@@ -914,13 +1048,13 @@ ${val.stack}`;
914
1048
  const finish = async () => {
915
1049
  console.log(input.files);
916
1050
  closed = true;
917
- const files = input.files;
918
- for (let i = 0; i < files.length; ++i) {
919
- const file = files.item(i);
1051
+ const files2 = input.files;
1052
+ for (let i = 0; i < files2.length; ++i) {
1053
+ const file = files2.item(i);
920
1054
  await db.dropFile(file.name);
921
1055
  await db.registerFileHandle(file.name, file);
922
1056
  }
923
- resolve(files.length);
1057
+ resolve(files2.length);
924
1058
  };
925
1059
  const deferredFinish = async () => {
926
1060
  window.removeEventListener("focus", deferredFinish);
@@ -945,7 +1079,7 @@ ${val.stack}`;
945
1079
 
946
1080
  // src/shell.ts
947
1081
  var hasWebGL = () => {
948
- if (isSafari) {
1082
+ if (duckdb.isSafari()) {
949
1083
  return false;
950
1084
  }
951
1085
  const canvas = document.createElement("canvas");
@@ -972,6 +1106,13 @@ ${val.stack}`;
972
1106
  }
973
1107
  return await pickFiles(this.database);
974
1108
  }
1109
+ async downloadFile(name2, buffer) {
1110
+ const blob = new Blob([buffer]);
1111
+ const link = document.createElement("a");
1112
+ link.href = URL.createObjectURL(blob);
1113
+ link.download = name2;
1114
+ link.click();
1115
+ }
975
1116
  async readClipboardText() {
976
1117
  return await navigator.clipboard.readText();
977
1118
  }
@@ -982,24 +1123,40 @@ ${val.stack}`;
982
1123
  this.history.push(value);
983
1124
  }
984
1125
  };
1126
+ function formatBytes(value) {
1127
+ const [multiple, k, suffix] = [1e3, "k", "B"];
1128
+ const exp = Math.log(value) / Math.log(multiple) | 0;
1129
+ const size = Number((value / Math.pow(multiple, exp)).toFixed(2));
1130
+ return `${size} ${exp ? `${k}MGTPEZY`[exp - 1] + suffix : `byte${size !== 1 ? "s" : ""}`}`;
1131
+ }
985
1132
  async function embed2(props) {
986
- await shell_default(props.wasmSource);
1133
+ await shell_default(props.shellModule);
987
1134
  const runtime = new ShellRuntime(props.container);
988
1135
  embed(props.container, runtime, {
989
1136
  backgroundColor: "#333",
990
1137
  withWebGL: hasWebGL()
991
1138
  });
992
1139
  props.container.onresize = runtime.resizeHandler;
1140
+ const TERM_BOLD = "\x1B[1m";
1141
+ const TERM_NORMAL = "\x1B[m";
1142
+ const TERM_CLEAR = "\x1B[2K\r";
1143
+ const progressHandler = (progress) => {
1144
+ if (progress.bytesTotal > 0) {
1145
+ const blocks = Math.floor(progress.bytesLoaded / progress.bytesTotal * 10);
1146
+ const bar = `${"#".repeat(blocks)}${"-".repeat(10 - blocks)}`;
1147
+ write(`${TERM_CLEAR}${TERM_BOLD}[ RUN ]${TERM_NORMAL} Loading ${bar}`);
1148
+ } else {
1149
+ write(`${TERM_CLEAR}${TERM_BOLD}[ RUN ]${TERM_NORMAL} Loading ${formatBytes(progress.bytesLoaded)}`);
1150
+ }
1151
+ };
1152
+ writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} Instantiating DuckDB`);
1153
+ runtime.database = await props.resolveDatabase(progressHandler);
1154
+ writeln(`${TERM_CLEAR}${TERM_BOLD}[ OK ]${TERM_NORMAL} Instantiating DuckDB`);
993
1155
  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}`);
1156
+ writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} ${label}`);
997
1157
  await work();
998
- writeln(`${TERM_BOLD}[ OK ]${TERM_NORMAL} ${label}`);
1158
+ writeln(`${TERM_BOLD}[ OK ]${TERM_NORMAL} ${label}`);
999
1159
  };
1000
- await step("Resolving DuckDB", async () => {
1001
- runtime.database = await props.resolveDatabase();
1002
- });
1003
1160
  await step("Loading Shell History", async () => {
1004
1161
  await runtime.history.open();
1005
1162
  const [hist, histCursor] = await runtime.history.load();
@@ -1009,5 +1166,11 @@ ${val.stack}`;
1009
1166
  configureDatabase(runtime.database);
1010
1167
  });
1011
1168
  }
1169
+
1170
+ // src/platform.ts
1171
+ function getJsDelivrModule() {
1172
+ const jsdelivr_dist_url = `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${PACKAGE_VERSION}/dist/`;
1173
+ return new URL(`${jsdelivr_dist_url}dist/shell_bg.wasm`);
1174
+ }
1012
1175
  })();
1013
1176
  //# sourceMappingURL=shell.js.map