@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.
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="140" height="20" role="img" aria-label="duckdb: v0.3.1-dev973"><title>duckdb: v0.3.1-dev973</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="140" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="49" height="20" fill="#555"/><rect x="49" width="91" height="20" fill="#007ec6"/><rect width="140" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="255" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="390">duckdb</text><text x="255" y="140" transform="scale(.1)" fill="#fff" textLength="390">duckdb</text><text aria-hidden="true" x="935" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="810">v0.3.1-dev973</text><text x="935" y="140" transform="scale(.1)" fill="#fff" textLength="810">v0.3.1-dev973</text></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="148" height="20" role="img" aria-label="duckdb: v0.3.1-dev1197"><title>duckdb: v0.3.1-dev1197</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="148" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="49" height="20" fill="#555"/><rect x="49" width="99" height="20" fill="#007ec6"/><rect width="148" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="255" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="390">duckdb</text><text x="255" y="140" transform="scale(.1)" fill="#fff" textLength="390">duckdb</text><text aria-hidden="true" x="975" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="890">v0.3.1-dev1197</text><text x="975" y="140" transform="scale(.1)" fill="#fff" textLength="890">v0.3.1-dev1197</text></g></svg>
package/dist/shell.cjs CHANGED
@@ -4,29 +4,137 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
6
6
  var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
7
+ for (var name2 in all)
8
+ __defProp(target, name2, { get: all[name2], enumerable: true });
9
9
  };
10
- var __reExport = (target, module2, copyDefault, desc) => {
11
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
12
- for (let key of __getOwnPropNames(module2))
10
+ var __reExport = (target, module3, copyDefault, desc) => {
11
+ if (module3 && typeof module3 === "object" || typeof module3 === "function") {
12
+ for (let key of __getOwnPropNames(module3))
13
13
  if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
14
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
14
+ __defProp(target, key, { get: () => module3[key], enumerable: !(desc = __getOwnPropDesc(module3, key)) || desc.enumerable });
15
15
  }
16
16
  return target;
17
17
  };
18
18
  var __toCommonJS = /* @__PURE__ */ ((cache) => {
19
- return (module2, temp) => {
20
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
19
+ return (module3, temp) => {
20
+ return cache && cache.get(module3) || (temp = __reExport(__markAsModule({}), module3, 1), cache && cache.set(module3, temp), temp);
21
21
  };
22
22
  })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
23
23
 
24
- // src/shell.ts
25
- var shell_exports = {};
26
- __export(shell_exports, {
27
- embed: () => embed2
24
+ // src/index.ts
25
+ var src_exports = {};
26
+ __export(src_exports, {
27
+ PACKAGE_NAME: () => PACKAGE_NAME,
28
+ PACKAGE_VERSION: () => PACKAGE_VERSION,
29
+ PACKAGE_VERSION_MAJOR: () => PACKAGE_VERSION_MAJOR,
30
+ PACKAGE_VERSION_MINOR: () => PACKAGE_VERSION_MINOR,
31
+ PACKAGE_VERSION_PATCH: () => PACKAGE_VERSION_PATCH,
32
+ embed: () => embed2,
33
+ getJsDelivrModule: () => getJsDelivrModule
28
34
  });
29
35
 
36
+ // package.json
37
+ var name = "@duckdb/duckdb-wasm-shell";
38
+ var version = "1.13.1-dev98.0";
39
+ var description = "";
40
+ var author = "Andre Kohn <kohn.a@outlook.com>";
41
+ var license = "MPL-2.0";
42
+ var repository = {
43
+ type: "git",
44
+ url: "https://github.com/duckdb/duckdb-wasm.git"
45
+ };
46
+ var keywords = [
47
+ "sql",
48
+ "duckdb",
49
+ "relational",
50
+ "database",
51
+ "data",
52
+ "query",
53
+ "wasm",
54
+ "analytics",
55
+ "olap",
56
+ "arrow",
57
+ "parquet",
58
+ "json",
59
+ "csv"
60
+ ];
61
+ var dependencies = {
62
+ "@duckdb/duckdb-wasm": "^1.13.1-dev98.0",
63
+ xterm: "^4.16.0",
64
+ "xterm-addon-fit": "^0.5.0",
65
+ "xterm-addon-web-links": "^0.5.0",
66
+ "xterm-addon-webgl": "^0.11.4"
67
+ };
68
+ var devDependencies = {
69
+ esbuild: "^0.14.12",
70
+ eslint: "^8.7.0",
71
+ "eslint-plugin-jasmine": "^4.1.3",
72
+ "eslint-plugin-react": "^7.28.0",
73
+ jasmine: "^4.0.2",
74
+ "jasmine-core": "^4.0.0",
75
+ "jasmine-spec-reporter": "^7.0.0",
76
+ "make-dir": "^3.1.0",
77
+ prettier: "^2.5.1",
78
+ rimraf: "^3.0.2",
79
+ "wasm-pack": "^0.10.2"
80
+ };
81
+ var scripts = {
82
+ postinstall: "node ../../node_modules/wasm-pack/install.js",
83
+ "build:debug": "node bundle.mjs debug && tsc --emitDeclarationOnly",
84
+ "build:release": "node bundle.mjs release && tsc --emitDeclarationOnly",
85
+ lint: "eslint src"
86
+ };
87
+ var files = [
88
+ "dist",
89
+ "!dist/types/test"
90
+ ];
91
+ var main = "dist/shell.cjs";
92
+ var module2 = "dist/shell.mjs";
93
+ var types = "dist/shell.d.ts";
94
+ var jsdelivr = "dist/shell.cjs";
95
+ var unpkg = "dist/shell.mjs";
96
+ var sideEffects = false;
97
+ var exports = {
98
+ "./dist/shell_bg.wasm": "./dist/shell_bg.wasm",
99
+ "./dist/shell.js": "./dist/shell_bg.js",
100
+ "./dist/shell.cjs": "./dist/shell_bg.cjs",
101
+ "./dist/shell.mjs": "./dist/shell_bg.mjs",
102
+ "./dist/shell": "./dist/shell_bg.mjs",
103
+ ".": {
104
+ types: "./dist/shell.d.ts",
105
+ import: "./dist/shell.mjs",
106
+ require: "./dist/shell.cjs"
107
+ }
108
+ };
109
+ var package_default = {
110
+ name,
111
+ version,
112
+ description,
113
+ author,
114
+ license,
115
+ repository,
116
+ keywords,
117
+ dependencies,
118
+ devDependencies,
119
+ scripts,
120
+ files,
121
+ main,
122
+ module: module2,
123
+ types,
124
+ jsdelivr,
125
+ unpkg,
126
+ sideEffects,
127
+ exports
128
+ };
129
+
130
+ // src/version.ts
131
+ var PACKAGE_NAME = package_default.name;
132
+ var PACKAGE_VERSION = package_default.version;
133
+ var VERSION_PARTS = package_default.version.split(".");
134
+ var PACKAGE_VERSION_MAJOR = VERSION_PARTS[0];
135
+ var PACKAGE_VERSION_MINOR = VERSION_PARTS[1];
136
+ var PACKAGE_VERSION_PATCH = VERSION_PARTS[2];
137
+
30
138
  // crate/pkg/shell.js
31
139
  var import_duckdb_wasm = require("@duckdb/duckdb-wasm");
32
140
  var import_xterm = require("xterm");
@@ -135,17 +243,17 @@ function debugString(val) {
135
243
  return `"${val}"`;
136
244
  }
137
245
  if (type == "symbol") {
138
- const description = val.description;
139
- if (description == null) {
246
+ const description2 = val.description;
247
+ if (description2 == null) {
140
248
  return "Symbol";
141
249
  } else {
142
- return `Symbol(${description})`;
250
+ return `Symbol(${description2})`;
143
251
  }
144
252
  }
145
253
  if (type == "function") {
146
- const name = val.name;
147
- if (typeof name == "string" && name.length > 0) {
148
- return `Function(${name})`;
254
+ const name2 = val.name;
255
+ if (typeof name2 == "string" && name2.length > 0) {
256
+ return `Function(${name2})`;
149
257
  } else {
150
258
  return "Function";
151
259
  }
@@ -223,6 +331,11 @@ function handleError(f, args) {
223
331
  function embed(elem, runtime, options) {
224
332
  wasm.embed(addHeapObject(elem), addHeapObject(runtime), addHeapObject(options));
225
333
  }
334
+ function write(text) {
335
+ var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
336
+ var len0 = WASM_VECTOR_LEN;
337
+ wasm.write(ptr0, len0);
338
+ }
226
339
  function writeln(text) {
227
340
  var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
228
341
  var len0 = WASM_VECTOR_LEN;
@@ -268,30 +381,30 @@ function passArray8ToWasm0(arg, malloc) {
268
381
  WASM_VECTOR_LEN = arg.length;
269
382
  return ptr;
270
383
  }
271
- function __wbg_adapter_195(arg0, arg1, arg2, arg3) {
384
+ function __wbg_adapter_199(arg0, arg1, arg2, arg3) {
272
385
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h445be38df5ff7a40(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
273
386
  }
274
387
  var ShellInputContext = Object.freeze({ FileInput: 0, "0": "FileInput" });
275
388
  var WcWidth = Object.freeze({ Width0: 0, "0": "Width0", Width1: 1, "1": "Width1", Width2: 2, "2": "Width2" });
276
- async function load(module2, imports) {
277
- if (typeof Response === "function" && module2 instanceof Response) {
389
+ async function load(module3, imports) {
390
+ if (typeof Response === "function" && module3 instanceof Response) {
278
391
  if (typeof WebAssembly.instantiateStreaming === "function") {
279
392
  try {
280
- return await WebAssembly.instantiateStreaming(module2, imports);
393
+ return await WebAssembly.instantiateStreaming(module3, imports);
281
394
  } catch (e) {
282
- if (module2.headers.get("Content-Type") != "application/wasm") {
395
+ if (module3.headers.get("Content-Type") != "application/wasm") {
283
396
  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);
284
397
  } else {
285
398
  throw e;
286
399
  }
287
400
  }
288
401
  }
289
- const bytes = await module2.arrayBuffer();
402
+ const bytes = await module3.arrayBuffer();
290
403
  return await WebAssembly.instantiate(bytes, imports);
291
404
  } else {
292
- const instance = await WebAssembly.instantiate(module2, imports);
405
+ const instance = await WebAssembly.instantiate(module3, imports);
293
406
  if (instance instanceof WebAssembly.Instance) {
294
- return { instance, module: module2 };
407
+ return { instance, module: module3 };
295
408
  } else {
296
409
  return instance;
297
410
  }
@@ -475,6 +588,12 @@ async function init(input) {
475
588
  return addHeapObject(ret);
476
589
  }, arguments);
477
590
  };
591
+ imports.wbg.__wbg_copyFileToBuffer_e4a7050307f57c30 = function() {
592
+ return handleError(function(arg0, arg1, arg2) {
593
+ var ret = getObject(arg0).copyFileToBuffer(getStringFromWasm0(arg1, arg2));
594
+ return addHeapObject(ret);
595
+ }, arguments);
596
+ };
478
597
  imports.wbg.__wbg_dropFiles_4d857401e3dd75ab = function() {
479
598
  return handleError(function(arg0) {
480
599
  var ret = getObject(arg0).dropFiles();
@@ -499,6 +618,12 @@ async function init(input) {
499
618
  return addHeapObject(ret);
500
619
  }, arguments);
501
620
  };
621
+ imports.wbg.__wbg_downloadFile_223fed31724de5a9 = function() {
622
+ return handleError(function(arg0, arg1, arg2, arg3) {
623
+ var ret = getObject(arg0).downloadFile(getStringFromWasm0(arg1, arg2), takeObject(arg3));
624
+ return addHeapObject(ret);
625
+ }, arguments);
626
+ };
502
627
  imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
503
628
  const obj = getObject(arg1);
504
629
  var ret = JSON.stringify(obj === void 0 ? null : obj);
@@ -687,7 +812,7 @@ async function init(input) {
687
812
  const a = state0.a;
688
813
  state0.a = 0;
689
814
  try {
690
- return __wbg_adapter_195(a, state0.b, arg02, arg12);
815
+ return __wbg_adapter_199(a, state0.b, arg02, arg12);
691
816
  } finally {
692
817
  state0.a = a;
693
818
  }
@@ -784,20 +909,20 @@ async function init(input) {
784
909
  var ret = wasm.memory;
785
910
  return addHeapObject(ret);
786
911
  };
787
- imports.wbg.__wbindgen_closure_wrapper220 = function(arg0, arg1, arg2) {
912
+ imports.wbg.__wbindgen_closure_wrapper222 = function(arg0, arg1, arg2) {
788
913
  var ret = makeMutClosure(arg0, arg1, 4, __wbg_adapter_24);
789
914
  return addHeapObject(ret);
790
915
  };
791
- imports.wbg.__wbindgen_closure_wrapper905 = function(arg0, arg1, arg2) {
792
- var ret = makeMutClosure(arg0, arg1, 148, __wbg_adapter_27);
916
+ imports.wbg.__wbindgen_closure_wrapper918 = function(arg0, arg1, arg2) {
917
+ var ret = makeMutClosure(arg0, arg1, 150, __wbg_adapter_27);
793
918
  return addHeapObject(ret);
794
919
  };
795
920
  if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
796
921
  input = fetch(input);
797
922
  }
798
- const { instance, module: module2 } = await load(await input, imports);
923
+ const { instance, module: module3 } = await load(await input, imports);
799
924
  wasm = instance.exports;
800
- init.__wbindgen_wasm_module = module2;
925
+ init.__wbindgen_wasm_module = module3;
801
926
  wasm.__wbindgen_start();
802
927
  return wasm;
803
928
  }
@@ -919,11 +1044,15 @@ var HistoryStore = class {
919
1044
  }
920
1045
  };
921
1046
 
922
- // src/utils/platform.ts
1047
+ // src/platform.ts
923
1048
  var isNode = typeof navigator === "undefined" ? true : false;
924
1049
  var userAgent = isNode ? "node" : navigator.userAgent;
925
1050
  var isFirefox = userAgent.includes("Firefox");
926
1051
  var isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);
1052
+ function getJsDelivrModule() {
1053
+ const jsdelivr_dist_url = `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${PACKAGE_VERSION}/dist/`;
1054
+ return new URL(`${jsdelivr_dist_url}dist/shell_bg.wasm`);
1055
+ }
927
1056
 
928
1057
  // src/utils/files.ts
929
1058
  function pickFiles(db) {
@@ -934,13 +1063,13 @@ function pickFiles(db) {
934
1063
  const finish = async () => {
935
1064
  console.log(input.files);
936
1065
  closed = true;
937
- const files = input.files;
938
- for (let i = 0; i < files.length; ++i) {
939
- const file = files.item(i);
1066
+ const files2 = input.files;
1067
+ for (let i = 0; i < files2.length; ++i) {
1068
+ const file = files2.item(i);
940
1069
  await db.dropFile(file.name);
941
1070
  await db.registerFileHandle(file.name, file);
942
1071
  }
943
- resolve(files.length);
1072
+ resolve(files2.length);
944
1073
  };
945
1074
  const deferredFinish = async () => {
946
1075
  window.removeEventListener("focus", deferredFinish);
@@ -992,6 +1121,13 @@ var ShellRuntime = class {
992
1121
  }
993
1122
  return await pickFiles(this.database);
994
1123
  }
1124
+ async downloadFile(name2, buffer) {
1125
+ const blob = new Blob([buffer]);
1126
+ const link = document.createElement("a");
1127
+ link.href = URL.createObjectURL(blob);
1128
+ link.download = name2;
1129
+ link.click();
1130
+ }
995
1131
  async readClipboardText() {
996
1132
  return await navigator.clipboard.readText();
997
1133
  }
@@ -1002,6 +1138,12 @@ var ShellRuntime = class {
1002
1138
  this.history.push(value);
1003
1139
  }
1004
1140
  };
1141
+ function formatBytes(value) {
1142
+ const [multiple, k, suffix] = [1e3, "k", "B"];
1143
+ const exp = Math.log(value) / Math.log(multiple) | 0;
1144
+ const size = Number((value / Math.pow(multiple, exp)).toFixed(2));
1145
+ return `${size} ${exp ? `${k}MGTPEZY`[exp - 1] + suffix : `byte${size !== 1 ? "s" : ""}`}`;
1146
+ }
1005
1147
  async function embed2(props) {
1006
1148
  await shell_default(props.wasmSource);
1007
1149
  const runtime = new ShellRuntime(props.container);
@@ -1010,16 +1152,26 @@ async function embed2(props) {
1010
1152
  withWebGL: hasWebGL()
1011
1153
  });
1012
1154
  props.container.onresize = runtime.resizeHandler;
1155
+ const TERM_BOLD = "\x1B[1m";
1156
+ const TERM_NORMAL = "\x1B[m";
1157
+ const TERM_CLEAR = "\x1B[2K\r";
1158
+ const progressHandler = (progress) => {
1159
+ if (progress.bytesTotal > 0) {
1160
+ const blocks = Math.floor(progress.bytesLoaded / progress.bytesTotal * 10);
1161
+ const bar = `${"#".repeat(blocks)}${"-".repeat(10 - blocks)}`;
1162
+ write(`${TERM_CLEAR}${TERM_BOLD}[ RUN ]${TERM_NORMAL} Loading ${bar}`);
1163
+ } else {
1164
+ write(`${TERM_CLEAR}${TERM_BOLD}[ RUN ]${TERM_NORMAL} Loading ${formatBytes(progress.bytesLoaded)}`);
1165
+ }
1166
+ };
1167
+ writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} Instantiating DuckDB`);
1168
+ runtime.database = await props.resolveDatabase(progressHandler);
1169
+ writeln(`${TERM_CLEAR}${TERM_BOLD}[ OK ]${TERM_NORMAL} Instantiating DuckDB`);
1013
1170
  const step = async (label, work) => {
1014
- const TERM_BOLD = "\x1B[1m";
1015
- const TERM_NORMAL = "\x1B[m";
1016
- writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} ${label}`);
1171
+ writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} ${label}`);
1017
1172
  await work();
1018
- writeln(`${TERM_BOLD}[ OK ]${TERM_NORMAL} ${label}`);
1173
+ writeln(`${TERM_BOLD}[ OK ]${TERM_NORMAL} ${label}`);
1019
1174
  };
1020
- await step("Resolving DuckDB", async () => {
1021
- runtime.database = await props.resolveDatabase();
1022
- });
1023
1175
  await step("Loading Shell History", async () => {
1024
1176
  await runtime.history.open();
1025
1177
  const [hist, histCursor] = await runtime.history.load();
@@ -1029,5 +1181,5 @@ async function embed2(props) {
1029
1181
  configureDatabase(runtime.database);
1030
1182
  });
1031
1183
  }
1032
- module.exports = __toCommonJS(shell_exports);
1184
+ module.exports = __toCommonJS(src_exports);
1033
1185
  //# sourceMappingURL=shell.cjs.map