sqlui 0.1.16 → 0.1.18

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.
@@ -5198,57 +5198,31 @@ var sqlui = (function (exports) {
5198
5198
  parent.length += view.length;
5199
5199
  }
5200
5200
  function coordsInChildren(view, pos, side) {
5201
- if (!view.children.length)
5202
- return fallbackRect(view);
5203
- return (side <= 0 ? coordsInChildrenBefore : coordsInChildrenAfter)(view, pos);
5204
- }
5205
- function coordsInChildrenBefore(view, pos) {
5206
- // Find the last leaf in the tree that touches pos and doesn't have getSide() > 0
5207
- let found = null, foundPos = -1;
5201
+ let before = null, beforePos = -1, after = null, afterPos = -1;
5208
5202
  function scan(view, pos) {
5209
5203
  for (let i = 0, off = 0; i < view.children.length && off <= pos; i++) {
5210
5204
  let child = view.children[i], end = off + child.length;
5211
5205
  if (end >= pos) {
5212
5206
  if (child.children.length) {
5213
- if (scan(child, pos - off))
5214
- return true;
5215
- }
5216
- else if (end >= pos) {
5217
- if (end == pos && child.getSide() > 0)
5218
- return true;
5219
- found = child;
5220
- foundPos = pos - off;
5207
+ scan(child, pos - off);
5221
5208
  }
5222
- }
5223
- off = end;
5224
- }
5225
- }
5226
- scan(view, pos);
5227
- return found ? found.coordsAt(Math.max(0, foundPos), -1) : coordsInChildrenAfter(view, pos);
5228
- }
5229
- function coordsInChildrenAfter(view, pos) {
5230
- // Find the first leaf in the tree that touches pos and doesn't have getSide() < 0
5231
- let found = null, foundPos = -1;
5232
- function scan(view, pos) {
5233
- for (let i = view.children.length - 1, off = view.length; i >= 0 && off >= pos; i--) {
5234
- let child = view.children[i];
5235
- off -= child.length;
5236
- if (off <= pos) {
5237
- if (child.children.length) {
5238
- if (scan(child, pos - off))
5239
- return true;
5209
+ else if (!after && (end > pos || off == end && child.getSide() > 0)) {
5210
+ after = child;
5211
+ afterPos = pos - off;
5240
5212
  }
5241
- else if (off <= pos) {
5242
- if (off == pos && child.getSide() < 0)
5243
- return true;
5244
- found = child;
5245
- foundPos = pos - off;
5213
+ else if (off < pos || (off == end && child.getSide() < 0)) {
5214
+ before = child;
5215
+ beforePos = pos - off;
5246
5216
  }
5247
5217
  }
5218
+ off = end;
5248
5219
  }
5249
5220
  }
5250
5221
  scan(view, pos);
5251
- return found ? found.coordsAt(Math.max(0, foundPos), 1) : coordsInChildrenBefore(view, pos);
5222
+ let target = (side < 0 ? before : after) || before || after;
5223
+ if (target)
5224
+ return target.coordsAt(Math.max(0, target == before ? beforePos : afterPos), side);
5225
+ return fallbackRect(view);
5252
5226
  }
5253
5227
  function fallbackRect(view) {
5254
5228
  let last = view.dom.lastChild;
@@ -9713,6 +9687,15 @@ var sqlui = (function (exports) {
9713
9687
  newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
9714
9688
  change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
9715
9689
  }
9690
+ else if (browser.chrome && change && change.from == change.to && change.from == sel.head &&
9691
+ change.insert.toString() == "\n " && view.lineWrapping) {
9692
+ // In Chrome, if you insert a space at the start of a wrapped
9693
+ // line, it will actually insert a newline and a space, causing a
9694
+ // bogus new line to be created in CodeMirror (#968)
9695
+ if (newSel)
9696
+ newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
9697
+ change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
9698
+ }
9716
9699
  if (change) {
9717
9700
  let startState = view.state;
9718
9701
  if (browser.ios && view.inputState.flushIOSKey(view))
@@ -10637,17 +10620,19 @@ var sqlui = (function (exports) {
10637
10620
  logException(this.state, e);
10638
10621
  }
10639
10622
  }
10640
- if (this.viewState.scrollTarget) {
10641
- this.docView.scrollIntoView(this.viewState.scrollTarget);
10642
- this.viewState.scrollTarget = null;
10643
- scrolled = true;
10644
- }
10645
- else {
10646
- let diff = this.viewState.lineBlockAt(refBlock.from).top - refBlock.top;
10647
- if (diff > 1 || diff < -1) {
10648
- this.scrollDOM.scrollTop += diff;
10623
+ if (this.viewState.editorHeight) {
10624
+ if (this.viewState.scrollTarget) {
10625
+ this.docView.scrollIntoView(this.viewState.scrollTarget);
10626
+ this.viewState.scrollTarget = null;
10649
10627
  scrolled = true;
10650
10628
  }
10629
+ else {
10630
+ let diff = this.viewState.lineBlockAt(refBlock.from).top - refBlock.top;
10631
+ if (diff > 1 || diff < -1) {
10632
+ this.scrollDOM.scrollTop += diff;
10633
+ scrolled = true;
10634
+ }
10635
+ }
10651
10636
  }
10652
10637
  if (redrawn)
10653
10638
  this.docView.updateSelection(true);
@@ -12129,7 +12114,10 @@ var sqlui = (function (exports) {
12129
12114
  for (let i = startLine; i <= endLine; i++) {
12130
12115
  let line = state.doc.line(i);
12131
12116
  let start = findColumn(line.text, startCol, state.tabSize, true);
12132
- if (start > -1) {
12117
+ if (start < 0) {
12118
+ ranges.push(EditorSelection.cursor(line.to));
12119
+ }
12120
+ else {
12133
12121
  let end = findColumn(line.text, endCol, state.tabSize);
12134
12122
  ranges.push(EditorSelection.range(line.from + start, line.from + end));
12135
12123
  }
@@ -12241,6 +12229,7 @@ var sqlui = (function (exports) {
12241
12229
  this.tooltipViews = this.tooltips.map(createTooltipView);
12242
12230
  }
12243
12231
  update(update) {
12232
+ var _a;
12244
12233
  let input = update.state.facet(this.facet);
12245
12234
  let tooltips = input.filter(x => x);
12246
12235
  if (input === this.input) {
@@ -12269,8 +12258,10 @@ var sqlui = (function (exports) {
12269
12258
  }
12270
12259
  }
12271
12260
  for (let t of this.tooltipViews)
12272
- if (tooltipViews.indexOf(t) < 0)
12261
+ if (tooltipViews.indexOf(t) < 0) {
12273
12262
  t.dom.remove();
12263
+ (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
12264
+ }
12274
12265
  this.input = input;
12275
12266
  this.tooltips = tooltips;
12276
12267
  this.tooltipViews = tooltipViews;
@@ -12383,11 +12374,13 @@ var sqlui = (function (exports) {
12383
12374
  return tooltipView;
12384
12375
  }
12385
12376
  destroy() {
12386
- var _a;
12377
+ var _a, _b;
12387
12378
  this.view.win.removeEventListener("resize", this.measureSoon);
12388
- for (let { dom } of this.manager.tooltipViews)
12389
- dom.remove();
12390
- (_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
12379
+ for (let tooltipView of this.manager.tooltipViews) {
12380
+ tooltipView.dom.remove();
12381
+ (_a = tooltipView.destroy) === null || _a === void 0 ? void 0 : _a.call(tooltipView);
12382
+ }
12383
+ (_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
12391
12384
  clearTimeout(this.measureTimeout);
12392
12385
  }
12393
12386
  readMeasure() {
@@ -14811,23 +14804,25 @@ var sqlui = (function (exports) {
14811
14804
  let set = [], tag = new Tag(set, base, mods);
14812
14805
  for (let m of mods)
14813
14806
  m.instances.push(tag);
14814
- let configs = permute(mods);
14807
+ let configs = powerSet(mods);
14815
14808
  for (let parent of base.set)
14816
- for (let config of configs)
14817
- set.push(Modifier.get(parent, config));
14809
+ if (!parent.modified.length)
14810
+ for (let config of configs)
14811
+ set.push(Modifier.get(parent, config));
14818
14812
  return tag;
14819
14813
  }
14820
14814
  }
14821
14815
  function sameArray(a, b) {
14822
14816
  return a.length == b.length && a.every((x, i) => x == b[i]);
14823
14817
  }
14824
- function permute(array) {
14825
- let result = [array];
14818
+ function powerSet(array) {
14819
+ let sets = [[]];
14826
14820
  for (let i = 0; i < array.length; i++) {
14827
- for (let a of permute(array.slice(0, i).concat(array.slice(i + 1))))
14828
- result.push(a);
14821
+ for (let j = 0, e = sets.length; j < e; j++) {
14822
+ sets.push(sets[j].concat(array[i]));
14823
+ }
14829
14824
  }
14830
- return result;
14825
+ return sets.sort((a, b) => b.length - a.length);
14831
14826
  }
14832
14827
  /// This function is used to add a set of tags to a language syntax
14833
14828
  /// via [`NodeSet.extend`](#common.NodeSet.extend) or
@@ -18630,7 +18625,7 @@ var sqlui = (function (exports) {
18630
18625
  if (match) {
18631
18626
  let from = this.curLineStart + match.index, to = from + match[0].length;
18632
18627
  this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
18633
- if (from == this.curLine.length)
18628
+ if (from == this.curLineStart + this.curLine.length)
18634
18629
  this.nextLine();
18635
18630
  if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {
18636
18631
  this.value = { from, to, match };
@@ -19015,10 +19010,17 @@ var sqlui = (function (exports) {
19015
19010
  this.regexp = !!config.regexp;
19016
19011
  this.replace = config.replace || "";
19017
19012
  this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
19018
- this.unquoted = this.literal ? this.search : this.search.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\");
19013
+ this.unquoted = this.unquote(this.search);
19019
19014
  this.wholeWord = !!config.wholeWord;
19020
19015
  }
19021
19016
  /**
19017
+ @internal
19018
+ */
19019
+ unquote(text) {
19020
+ return this.literal ? text :
19021
+ text.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\");
19022
+ }
19023
+ /**
19022
19024
  Compare this query to another query.
19023
19025
  */
19024
19026
  eq(other) {
@@ -19092,7 +19094,7 @@ var sqlui = (function (exports) {
19092
19094
  return this.prevMatchInRange(state, 0, curFrom) ||
19093
19095
  this.prevMatchInRange(state, curTo, state.doc.length);
19094
19096
  }
19095
- getReplacement(_result) { return this.spec.replace; }
19097
+ getReplacement(_result) { return this.spec.unquote(this.spec.replace); }
19096
19098
  matchAll(state, limit) {
19097
19099
  let cursor = stringCursor(this.spec, state, 0, state.doc.length), ranges = [];
19098
19100
  while (!cursor.next().done) {
@@ -19151,10 +19153,10 @@ var sqlui = (function (exports) {
19151
19153
  this.prevMatchInRange(state, curTo, state.doc.length);
19152
19154
  }
19153
19155
  getReplacement(result) {
19154
- return this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
19156
+ return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
19155
19157
  : i == "&" ? result.match[0]
19156
19158
  : i != "0" && +i < result.match.length ? result.match[i]
19157
- : m);
19159
+ : m));
19158
19160
  }
19159
19161
  matchAll(state, limit) {
19160
19162
  let cursor = regexpCursor(this.spec, state, 0, state.doc.length), ranges = [];
@@ -19446,6 +19448,7 @@ var sqlui = (function (exports) {
19446
19448
  "aria-label": phrase(view, "Find"),
19447
19449
  class: "cm-textfield",
19448
19450
  name: "search",
19451
+ form: "",
19449
19452
  "main-field": "true",
19450
19453
  onchange: this.commit,
19451
19454
  onkeyup: this.commit
@@ -19456,24 +19459,28 @@ var sqlui = (function (exports) {
19456
19459
  "aria-label": phrase(view, "Replace"),
19457
19460
  class: "cm-textfield",
19458
19461
  name: "replace",
19462
+ form: "",
19459
19463
  onchange: this.commit,
19460
19464
  onkeyup: this.commit
19461
19465
  });
19462
19466
  this.caseField = crelt("input", {
19463
19467
  type: "checkbox",
19464
19468
  name: "case",
19469
+ form: "",
19465
19470
  checked: query.caseSensitive,
19466
19471
  onchange: this.commit
19467
19472
  });
19468
19473
  this.reField = crelt("input", {
19469
19474
  type: "checkbox",
19470
19475
  name: "re",
19476
+ form: "",
19471
19477
  checked: query.regexp,
19472
19478
  onchange: this.commit
19473
19479
  });
19474
19480
  this.wordField = crelt("input", {
19475
19481
  type: "checkbox",
19476
19482
  name: "word",
19483
+ form: "",
19477
19484
  checked: query.wholeWord,
19478
19485
  onchange: this.commit
19479
19486
  });
@@ -23266,10 +23273,10 @@ var sqlui = (function (exports) {
23266
23273
  Builtin = 24;
23267
23274
 
23268
23275
  function isAlpha(ch) {
23269
- return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */;
23276
+ return ch >= 65 /* Ch.A */ && ch <= 90 /* Ch.Z */ || ch >= 97 /* Ch.a */ && ch <= 122 /* Ch.z */ || ch >= 48 /* Ch._0 */ && ch <= 57 /* Ch._9 */;
23270
23277
  }
23271
23278
  function isHexDigit(ch) {
23272
- return ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch >= 97 /* a */ && ch <= 102 /* f */ || ch >= 65 /* A */ && ch <= 70 /* F */;
23279
+ return ch >= 48 /* Ch._0 */ && ch <= 57 /* Ch._9 */ || ch >= 97 /* Ch.a */ && ch <= 102 /* Ch.f */ || ch >= 65 /* Ch.A */ && ch <= 70 /* Ch.F */;
23273
23280
  }
23274
23281
  function readLiteral(input, endQuote, backslashEscapes) {
23275
23282
  for (let escaped = false;;) {
@@ -23279,7 +23286,7 @@ var sqlui = (function (exports) {
23279
23286
  input.advance();
23280
23287
  return;
23281
23288
  }
23282
- escaped = backslashEscapes && !escaped && input.next == 92 /* Backslash */;
23289
+ escaped = backslashEscapes && !escaped && input.next == 92 /* Ch.Backslash */;
23283
23290
  input.advance();
23284
23291
  }
23285
23292
  }
@@ -23287,7 +23294,7 @@ var sqlui = (function (exports) {
23287
23294
  for (;;) {
23288
23295
  if (input.next < 0 || input.peek(1) < 0)
23289
23296
  return;
23290
- if (input.next == 36 /* Dollar */ && input.peek(1) == 36 /* Dollar */) {
23297
+ if (input.next == 36 /* Ch.Dollar */ && input.peek(1) == 36 /* Ch.Dollar */) {
23291
23298
  input.advance(2);
23292
23299
  return;
23293
23300
  }
@@ -23296,7 +23303,7 @@ var sqlui = (function (exports) {
23296
23303
  }
23297
23304
  function readWord(input, result) {
23298
23305
  for (;;) {
23299
- if (input.next != 95 /* Underscore */ && !isAlpha(input.next))
23306
+ if (input.next != 95 /* Ch.Underscore */ && !isAlpha(input.next))
23300
23307
  break;
23301
23308
  if (result != null)
23302
23309
  result += String.fromCharCode(input.next);
@@ -23305,7 +23312,7 @@ var sqlui = (function (exports) {
23305
23312
  return result;
23306
23313
  }
23307
23314
  function readWordOrQuoted(input) {
23308
- if (input.next == 39 /* SingleQuote */ || input.next == 34 /* DoubleQuote */ || input.next == 96 /* Backtick */) {
23315
+ if (input.next == 39 /* Ch.SingleQuote */ || input.next == 34 /* Ch.DoubleQuote */ || input.next == 96 /* Ch.Backtick */) {
23309
23316
  let quote = input.next;
23310
23317
  input.advance();
23311
23318
  readLiteral(input, quote, false);
@@ -23315,33 +23322,33 @@ var sqlui = (function (exports) {
23315
23322
  }
23316
23323
  }
23317
23324
  function readBits(input, endQuote) {
23318
- while (input.next == 48 /* _0 */ || input.next == 49 /* _1 */)
23325
+ while (input.next == 48 /* Ch._0 */ || input.next == 49 /* Ch._1 */)
23319
23326
  input.advance();
23320
23327
  if (endQuote && input.next == endQuote)
23321
23328
  input.advance();
23322
23329
  }
23323
23330
  function readNumber(input, sawDot) {
23324
23331
  for (;;) {
23325
- if (input.next == 46 /* Dot */) {
23332
+ if (input.next == 46 /* Ch.Dot */) {
23326
23333
  if (sawDot)
23327
23334
  break;
23328
23335
  sawDot = true;
23329
23336
  }
23330
- else if (input.next < 48 /* _0 */ || input.next > 57 /* _9 */) {
23337
+ else if (input.next < 48 /* Ch._0 */ || input.next > 57 /* Ch._9 */) {
23331
23338
  break;
23332
23339
  }
23333
23340
  input.advance();
23334
23341
  }
23335
- if (input.next == 69 /* E */ || input.next == 101 /* e */) {
23342
+ if (input.next == 69 /* Ch.E */ || input.next == 101 /* Ch.e */) {
23336
23343
  input.advance();
23337
- if (input.next == 43 /* Plus */ || input.next == 45 /* Dash */)
23344
+ if (input.next == 43 /* Ch.Plus */ || input.next == 45 /* Ch.Dash */)
23338
23345
  input.advance();
23339
- while (input.next >= 48 /* _0 */ && input.next <= 57 /* _9 */)
23346
+ while (input.next >= 48 /* Ch._0 */ && input.next <= 57 /* Ch._9 */)
23340
23347
  input.advance();
23341
23348
  }
23342
23349
  }
23343
23350
  function eol(input) {
23344
- while (!(input.next < 0 || input.next == 10 /* Newline */))
23351
+ while (!(input.next < 0 || input.next == 10 /* Ch.Newline */))
23345
23352
  input.advance();
23346
23353
  }
23347
23354
  function inString(ch, str) {
@@ -23401,31 +23408,31 @@ var sqlui = (function (exports) {
23401
23408
  input.advance();
23402
23409
  input.acceptToken(whitespace);
23403
23410
  }
23404
- else if (next == 36 /* Dollar */ && input.next == 36 /* Dollar */ && d.doubleDollarStrings) {
23411
+ else if (next == 36 /* Ch.Dollar */ && input.next == 36 /* Ch.Dollar */ && d.doubleDollarStrings) {
23405
23412
  readDoubleDollarLiteral(input);
23406
23413
  input.acceptToken(String$1);
23407
23414
  }
23408
- else if (next == 39 /* SingleQuote */ || next == 34 /* DoubleQuote */ && d.doubleQuotedStrings) {
23415
+ else if (next == 39 /* Ch.SingleQuote */ || next == 34 /* Ch.DoubleQuote */ && d.doubleQuotedStrings) {
23409
23416
  readLiteral(input, next, d.backslashEscapes);
23410
23417
  input.acceptToken(String$1);
23411
23418
  }
23412
- else if (next == 35 /* Hash */ && d.hashComments ||
23413
- next == 47 /* Slash */ && input.next == 47 /* Slash */ && d.slashComments) {
23419
+ else if (next == 35 /* Ch.Hash */ && d.hashComments ||
23420
+ next == 47 /* Ch.Slash */ && input.next == 47 /* Ch.Slash */ && d.slashComments) {
23414
23421
  eol(input);
23415
23422
  input.acceptToken(LineComment);
23416
23423
  }
23417
- else if (next == 45 /* Dash */ && input.next == 45 /* Dash */ &&
23418
- (!d.spaceAfterDashes || input.peek(2) == 32 /* Space */)) {
23424
+ else if (next == 45 /* Ch.Dash */ && input.next == 45 /* Ch.Dash */ &&
23425
+ (!d.spaceAfterDashes || input.peek(1) == 32 /* Ch.Space */)) {
23419
23426
  eol(input);
23420
23427
  input.acceptToken(LineComment);
23421
23428
  }
23422
- else if (next == 47 /* Slash */ && input.next == 42 /* Star */) {
23429
+ else if (next == 47 /* Ch.Slash */ && input.next == 42 /* Ch.Star */) {
23423
23430
  input.advance();
23424
23431
  for (let prev = -1, depth = 1;;) {
23425
23432
  if (input.next < 0)
23426
23433
  break;
23427
23434
  input.advance();
23428
- if (prev == 42 /* Star */ && input.next == 47 /* Slash */) {
23435
+ if (prev == 42 /* Ch.Star */ && input.next == 47 /* Ch.Slash */) {
23429
23436
  depth--;
23430
23437
  if (!depth) {
23431
23438
  input.advance();
@@ -23433,7 +23440,7 @@ var sqlui = (function (exports) {
23433
23440
  }
23434
23441
  prev = -1;
23435
23442
  }
23436
- else if (prev == 47 /* Slash */ && input.next == 42 /* Star */) {
23443
+ else if (prev == 47 /* Ch.Slash */ && input.next == 42 /* Ch.Star */) {
23437
23444
  depth++;
23438
23445
  prev = -1;
23439
23446
  }
@@ -23443,21 +23450,21 @@ var sqlui = (function (exports) {
23443
23450
  }
23444
23451
  input.acceptToken(BlockComment);
23445
23452
  }
23446
- else if ((next == 101 /* e */ || next == 69 /* E */) && input.next == 39 /* SingleQuote */) {
23453
+ else if ((next == 101 /* Ch.e */ || next == 69 /* Ch.E */) && input.next == 39 /* Ch.SingleQuote */) {
23447
23454
  input.advance();
23448
- readLiteral(input, 39 /* SingleQuote */, true);
23455
+ readLiteral(input, 39 /* Ch.SingleQuote */, true);
23449
23456
  }
23450
- else if ((next == 110 /* n */ || next == 78 /* N */) && input.next == 39 /* SingleQuote */ &&
23457
+ else if ((next == 110 /* Ch.n */ || next == 78 /* Ch.N */) && input.next == 39 /* Ch.SingleQuote */ &&
23451
23458
  d.charSetCasts) {
23452
23459
  input.advance();
23453
- readLiteral(input, 39 /* SingleQuote */, d.backslashEscapes);
23460
+ readLiteral(input, 39 /* Ch.SingleQuote */, d.backslashEscapes);
23454
23461
  input.acceptToken(String$1);
23455
23462
  }
23456
- else if (next == 95 /* Underscore */ && d.charSetCasts) {
23463
+ else if (next == 95 /* Ch.Underscore */ && d.charSetCasts) {
23457
23464
  for (let i = 0;; i++) {
23458
- if (input.next == 39 /* SingleQuote */ && i > 1) {
23465
+ if (input.next == 39 /* Ch.SingleQuote */ && i > 1) {
23459
23466
  input.advance();
23460
- readLiteral(input, 39 /* SingleQuote */, d.backslashEscapes);
23467
+ readLiteral(input, 39 /* Ch.SingleQuote */, d.backslashEscapes);
23461
23468
  input.acceptToken(String$1);
23462
23469
  break;
23463
23470
  }
@@ -23466,33 +23473,33 @@ var sqlui = (function (exports) {
23466
23473
  input.advance();
23467
23474
  }
23468
23475
  }
23469
- else if (next == 40 /* ParenL */) {
23476
+ else if (next == 40 /* Ch.ParenL */) {
23470
23477
  input.acceptToken(ParenL);
23471
23478
  }
23472
- else if (next == 41 /* ParenR */) {
23479
+ else if (next == 41 /* Ch.ParenR */) {
23473
23480
  input.acceptToken(ParenR);
23474
23481
  }
23475
- else if (next == 123 /* BraceL */) {
23482
+ else if (next == 123 /* Ch.BraceL */) {
23476
23483
  input.acceptToken(BraceL);
23477
23484
  }
23478
- else if (next == 125 /* BraceR */) {
23485
+ else if (next == 125 /* Ch.BraceR */) {
23479
23486
  input.acceptToken(BraceR);
23480
23487
  }
23481
- else if (next == 91 /* BracketL */) {
23488
+ else if (next == 91 /* Ch.BracketL */) {
23482
23489
  input.acceptToken(BracketL);
23483
23490
  }
23484
- else if (next == 93 /* BracketR */) {
23491
+ else if (next == 93 /* Ch.BracketR */) {
23485
23492
  input.acceptToken(BracketR);
23486
23493
  }
23487
- else if (next == 59 /* Semi */) {
23494
+ else if (next == 59 /* Ch.Semi */) {
23488
23495
  input.acceptToken(Semi);
23489
23496
  }
23490
- else if (d.unquotedBitLiterals && next == 48 /* _0 */ && input.next == 98 /* b */) {
23497
+ else if (d.unquotedBitLiterals && next == 48 /* Ch._0 */ && input.next == 98 /* Ch.b */) {
23491
23498
  input.advance();
23492
23499
  readBits(input);
23493
23500
  input.acceptToken(Bits);
23494
23501
  }
23495
- else if ((next == 98 /* b */ || next == 66 /* B */) && (input.next == 39 /* SingleQuote */ || input.next == 34 /* DoubleQuote */)) {
23502
+ else if ((next == 98 /* Ch.b */ || next == 66 /* Ch.B */) && (input.next == 39 /* Ch.SingleQuote */ || input.next == 34 /* Ch.DoubleQuote */)) {
23496
23503
  const quoteStyle = input.next;
23497
23504
  input.advance();
23498
23505
  if (d.treatBitsAsBytes) {
@@ -23504,24 +23511,24 @@ var sqlui = (function (exports) {
23504
23511
  input.acceptToken(Bits);
23505
23512
  }
23506
23513
  }
23507
- else if (next == 48 /* _0 */ && (input.next == 120 /* x */ || input.next == 88 /* X */) ||
23508
- (next == 120 /* x */ || next == 88 /* X */) && input.next == 39 /* SingleQuote */) {
23509
- let quoted = input.next == 39 /* SingleQuote */;
23514
+ else if (next == 48 /* Ch._0 */ && (input.next == 120 /* Ch.x */ || input.next == 88 /* Ch.X */) ||
23515
+ (next == 120 /* Ch.x */ || next == 88 /* Ch.X */) && input.next == 39 /* Ch.SingleQuote */) {
23516
+ let quoted = input.next == 39 /* Ch.SingleQuote */;
23510
23517
  input.advance();
23511
23518
  while (isHexDigit(input.next))
23512
23519
  input.advance();
23513
- if (quoted && input.next == 39 /* SingleQuote */)
23520
+ if (quoted && input.next == 39 /* Ch.SingleQuote */)
23514
23521
  input.advance();
23515
23522
  input.acceptToken(Number);
23516
23523
  }
23517
- else if (next == 46 /* Dot */ && input.next >= 48 /* _0 */ && input.next <= 57 /* _9 */) {
23524
+ else if (next == 46 /* Ch.Dot */ && input.next >= 48 /* Ch._0 */ && input.next <= 57 /* Ch._9 */) {
23518
23525
  readNumber(input, true);
23519
23526
  input.acceptToken(Number);
23520
23527
  }
23521
- else if (next == 46 /* Dot */) {
23528
+ else if (next == 46 /* Ch.Dot */) {
23522
23529
  input.acceptToken(Dot);
23523
23530
  }
23524
- else if (next >= 48 /* _0 */ && next <= 57 /* _9 */) {
23531
+ else if (next >= 48 /* Ch._0 */ && next <= 57 /* Ch._9 */) {
23525
23532
  readNumber(input, false);
23526
23533
  input.acceptToken(Number);
23527
23534
  }
@@ -23540,12 +23547,12 @@ var sqlui = (function (exports) {
23540
23547
  readLiteral(input, next, false);
23541
23548
  input.acceptToken(QuotedIdentifier);
23542
23549
  }
23543
- else if (next == 58 /* Colon */ || next == 44 /* Comma */) {
23550
+ else if (next == 58 /* Ch.Colon */ || next == 44 /* Ch.Comma */) {
23544
23551
  input.acceptToken(Punctuation);
23545
23552
  }
23546
23553
  else if (isAlpha(next)) {
23547
23554
  let word = readWord(input, String.fromCharCode(next));
23548
- input.acceptToken(input.next == 46 /* Dot */ ? Identifier : (_a = d.words[word.toLowerCase()]) !== null && _a !== void 0 ? _a : Identifier);
23555
+ input.acceptToken(input.next == 46 /* Ch.Dot */ ? Identifier : (_a = d.words[word.toLowerCase()]) !== null && _a !== void 0 ? _a : Identifier);
23549
23556
  }
23550
23557
  });
23551
23558
  }
@@ -23841,177 +23848,179 @@ var sqlui = (function (exports) {
23841
23848
  */
23842
23849
  const StandardSQL = /*@__PURE__*/SQLDialect.define({});
23843
23850
 
23844
- function init(parent, onSubmit) {
23851
+ /* global google */
23852
+
23853
+ function init (parent, onSubmit) {
23845
23854
  const fixedHeightEditor = EditorView.theme({
23846
- ".cm-scroller": { height: "200px", overflow: "auto", resize: "vertical" },
23855
+ '.cm-scroller': { height: '200px', overflow: 'auto', resize: 'vertical' }
23847
23856
  });
23848
23857
  window.editorView = new EditorView({
23849
23858
  state: EditorState.create({
23850
23859
  extensions: [
23851
23860
  keymap.of([
23852
- {key: "Ctrl-Enter", run: onSubmit, preventDefault: true},
23861
+ { key: 'Ctrl-Enter', run: onSubmit, preventDefault: true },
23853
23862
  ...defaultKeymap
23854
23863
  ]),
23855
23864
  basicSetup,
23856
23865
  sql(),
23857
23866
  fixedHeightEditor,
23858
- placeholder("Ctrl-Enter to submit")
23867
+ placeholder('Ctrl-Enter to submit')
23859
23868
  ]
23860
23869
  }),
23861
- parent: parent
23870
+ parent
23862
23871
  });
23863
23872
  }
23864
23873
 
23865
- function getCursor() {
23866
- return window.editorView.state.selection.main.head;
23874
+ function getCursor () {
23875
+ return window.editorView.state.selection.main.head
23867
23876
  }
23868
23877
 
23869
- function setCursor(cursor) {
23870
- window.editorView.dispatch({selection: {anchor: Math.min(cursor, window.editorView.state.doc.length)}});
23878
+ function setCursor (cursor) {
23879
+ window.editorView.dispatch({ selection: { anchor: Math.min(cursor, window.editorView.state.doc.length) } });
23871
23880
  }
23872
23881
 
23873
- function focus() {
23882
+ function focus () {
23874
23883
  window.editorView.focus();
23875
23884
  }
23876
23885
 
23877
- function getValue() {
23878
- return window.editorView.state.doc.toString();
23886
+ function getValue () {
23887
+ return window.editorView.state.doc.toString()
23879
23888
  }
23880
23889
 
23881
- function setValue(value) {
23890
+ function setValue (value) {
23882
23891
  window.editorView.dispatch({
23883
23892
  changes: {
23884
23893
  from: 0,
23885
23894
  to: window.editorView.state.doc.length,
23886
23895
  insert: value
23887
- },
23896
+ }
23888
23897
  });
23889
23898
  }
23890
23899
 
23891
- function selectTab(tab) {
23900
+ function selectTab (tab) {
23892
23901
  window.tab = tab;
23893
23902
  const url = new URL(window.location);
23894
- if (url.searchParams.has("tab")) {
23895
- if (url.searchParams.get("tab") !== tab) {
23896
- if (tab === "query") {
23897
- url.searchParams.delete("tab");
23898
- window.history.pushState({}, "", url);
23899
- return route();
23903
+ if (url.searchParams.has('tab')) {
23904
+ if (url.searchParams.get('tab') !== tab) {
23905
+ if (tab === 'query') {
23906
+ url.searchParams.delete('tab');
23907
+ window.history.pushState({}, '', url);
23908
+ return route()
23900
23909
  } else {
23901
- url.searchParams.set("tab", tab);
23902
- window.history.pushState({}, "", url);
23903
- return route();
23910
+ url.searchParams.set('tab', tab);
23911
+ window.history.pushState({}, '', url);
23912
+ return route()
23904
23913
  }
23905
23914
  }
23906
23915
  } else {
23907
- if (tab !== "query") {
23908
- url.searchParams.set("tab", tab);
23909
- window.history.pushState({}, "", url);
23910
- return route();
23916
+ if (tab !== 'query') {
23917
+ url.searchParams.set('tab', tab);
23918
+ window.history.pushState({}, '', url);
23919
+ return route()
23911
23920
  }
23912
23921
  }
23913
23922
 
23914
23923
  const tabElement = document.getElementById(`${tab}-tab-button`);
23915
- Array.prototype.forEach.call(document.getElementsByClassName("selected-tab-button"), function(selected) {
23916
- selected.classList.remove("selected-tab-button");
23917
- selected.classList.add("tab-button");
23924
+ Array.prototype.forEach.call(document.getElementsByClassName('selected-tab-button'), function (selected) {
23925
+ selected.classList.remove('selected-tab-button');
23926
+ selected.classList.add('tab-button');
23918
23927
  });
23919
- tabElement.classList.remove("tab-button");
23920
- tabElement.classList.add("selected-tab-button");
23928
+ tabElement.classList.remove('tab-button');
23929
+ tabElement.classList.add('selected-tab-button');
23921
23930
 
23922
- Array.prototype.forEach.call(document.getElementsByClassName("tab-content-element"), function(selected) {
23923
- selected.style.display = "none";
23931
+ Array.prototype.forEach.call(document.getElementsByClassName('tab-content-element'), function (selected) {
23932
+ selected.style.display = 'none';
23924
23933
  });
23925
23934
 
23926
23935
  switch (tab) {
23927
- case "query":
23936
+ case 'query':
23928
23937
  selectQueryTab();
23929
- break;
23930
- case "graph":
23938
+ break
23939
+ case 'graph':
23931
23940
  selectGraphTab();
23932
- break;
23933
- case "saved":
23941
+ break
23942
+ case 'saved':
23934
23943
  selectSavedTab();
23935
- break;
23936
- case "structure":
23944
+ break
23945
+ case 'structure':
23937
23946
  selectStructureTab();
23938
- break;
23947
+ break
23939
23948
  default:
23940
- throw `Unexpected tab: ${tab}`;
23949
+ throw new Error(`Unexpected tab: ${tab}`)
23941
23950
  }
23942
23951
  }
23943
23952
 
23944
- function selectStructureTab() {
23945
- Array.prototype.forEach.call(document.getElementsByClassName("structure-element"), function(selected) {
23946
- selected.style.display = "flex";
23953
+ function selectStructureTab () {
23954
+ Array.prototype.forEach.call(document.getElementsByClassName('structure-element'), function (selected) {
23955
+ selected.style.display = 'flex';
23947
23956
  });
23948
23957
 
23949
23958
  if (window.structureLoaded) {
23950
- return;
23959
+ return
23951
23960
  }
23952
23961
 
23953
- const schemasElement = document.getElementById("schemas");
23954
- const tablesElement = document.getElementById("tables");
23955
- const columnsElement = document.getElementById("columns");
23956
- const indexesElement = document.getElementById("indexes");
23962
+ const schemasElement = document.getElementById('schemas');
23963
+ const tablesElement = document.getElementById('tables');
23964
+ const columnsElement = document.getElementById('columns');
23965
+ const indexesElement = document.getElementById('indexes');
23957
23966
 
23958
- const schemaNames = Object.keys(window.metadata["schemas"]);
23959
- if (schemaNames.length == 1) {
23967
+ const schemaNames = Object.keys(window.metadata.schemas);
23968
+ if (schemaNames.length === 1) {
23960
23969
  schemasElement.style.display = 'none';
23961
23970
  // TODO: duplicate code
23962
- while(tablesElement.firstChild) {
23971
+ while (tablesElement.firstChild) {
23963
23972
  tablesElement.removeChild(tablesElement.firstChild);
23964
23973
  }
23965
23974
  const schemaName = schemaNames[0];
23966
- const schema = window.metadata["schemas"][schemaName];
23967
- const tableNames = Object.keys(schema["tables"]);
23968
- tableNames.forEach(function(tableName) {
23969
- const optionElement = document.createElement("option");
23975
+ const schema = window.metadata.schemas[schemaName];
23976
+ const tableNames = Object.keys(schema.tables);
23977
+ tableNames.forEach(function (tableName) {
23978
+ const optionElement = document.createElement('option');
23970
23979
  optionElement.value = tableName;
23971
23980
  optionElement.innerText = tableName;
23972
23981
  tablesElement.appendChild(optionElement);
23973
23982
  });
23974
23983
  } else {
23975
23984
  schemasElement.style.display = 'flex';
23976
- schemaNames.forEach(function(schemaName) {
23977
- const optionElement = document.createElement("option");
23985
+ schemaNames.forEach(function (schemaName) {
23986
+ const optionElement = document.createElement('option');
23978
23987
  optionElement.value = schemaName;
23979
23988
  optionElement.innerText = schemaName;
23980
23989
  schemasElement.appendChild(optionElement);
23981
23990
  });
23982
- schemasElement.addEventListener("change", function() {
23983
- while(tablesElement.firstChild) {
23991
+ schemasElement.addEventListener('change', function () {
23992
+ while (tablesElement.firstChild) {
23984
23993
  tablesElement.removeChild(tablesElement.firstChild);
23985
23994
  }
23986
23995
  const schemaName = schemasElement.value;
23987
- const schema = window.metadata["schemas"][schemaName];
23988
- const tableNames = Object.keys(schema["tables"]);
23989
- tableNames.forEach(function(tableName) {
23990
- const optionElement = document.createElement("option");
23996
+ const schema = window.metadata.schemas[schemaName];
23997
+ const tableNames = Object.keys(schema.tables);
23998
+ tableNames.forEach(function (tableName) {
23999
+ const optionElement = document.createElement('option');
23991
24000
  optionElement.value = tableName;
23992
24001
  optionElement.innerText = tableName;
23993
24002
  tablesElement.appendChild(optionElement);
23994
24003
  });
23995
24004
  });
23996
24005
  }
23997
- tablesElement.addEventListener("change", function() {
23998
- while(columnsElement.firstChild) {
24006
+ tablesElement.addEventListener('change', function () {
24007
+ while (columnsElement.firstChild) {
23999
24008
  columnsElement.removeChild(columnsElement.firstChild);
24000
24009
  }
24001
- while(indexesElement.firstChild) {
24010
+ while (indexesElement.firstChild) {
24002
24011
  indexesElement.removeChild(indexesElement.firstChild);
24003
24012
  }
24004
- const schemaName = schemaNames.length == 1 ? schemaNames[0] : schemasElement.value;
24013
+ const schemaName = schemaNames.length === 1 ? schemaNames[0] : schemasElement.value;
24005
24014
  const tableName = tablesElement.value;
24006
- const table = window.metadata["schemas"][schemaName]["tables"][tableName];
24015
+ const table = window.metadata.schemas[schemaName].tables[tableName];
24007
24016
 
24008
- const columnEntries = Object.entries(table["columns"]);
24017
+ const columnEntries = Object.entries(table.columns);
24009
24018
  if (columnEntries.length > 0) {
24010
24019
  const columns = Object.keys(columnEntries[0][1]);
24011
24020
  const rows = [];
24012
- for (const [_, column] of columnEntries) {
24021
+ for (const [, column] of columnEntries) {
24013
24022
  const row = [];
24014
- for (const [_, value] of Object.entries(column)) {
24023
+ for (const [, value] of Object.entries(column)) {
24015
24024
  row.push(value);
24016
24025
  }
24017
24026
  rows.push(row);
@@ -24019,7 +24028,7 @@ var sqlui = (function (exports) {
24019
24028
  createTable(columnsElement, columns, rows);
24020
24029
  }
24021
24030
 
24022
- const indexEntries = Object.entries(table["indexes"]);
24031
+ const indexEntries = Object.entries(table.indexes);
24023
24032
  if (indexEntries.length > 0) {
24024
24033
  const firstIndex = indexEntries[0][1];
24025
24034
  const indexColumns = Object.keys(firstIndex);
@@ -24027,10 +24036,10 @@ var sqlui = (function (exports) {
24027
24036
  const columns = indexColumnKeys;
24028
24037
 
24029
24038
  const rows = [];
24030
- for (const [_, index] of indexEntries) {
24031
- for (const [_, column] of Object.entries(index)) {
24039
+ for (const [, index] of indexEntries) {
24040
+ for (const [, column] of Object.entries(index)) {
24032
24041
  const row = [];
24033
- for (const [_, value] of Object.entries(column)) {
24042
+ for (const [, value] of Object.entries(column)) {
24034
24043
  row.push(value);
24035
24044
  }
24036
24045
  rows.push(row);
@@ -24042,32 +24051,34 @@ var sqlui = (function (exports) {
24042
24051
  window.structureLoaded = true;
24043
24052
  }
24044
24053
 
24045
- function createTable(parent, columns, rows) {
24046
- const tableElement = document.createElement("table");
24047
- const theadElement = document.createElement("thead");
24048
- const headerTrElement = document.createElement("tr");
24049
- const tbodyElement = document.createElement("tbody");
24054
+ function createTable (parent, columns, rows) {
24055
+ const tableElement = document.createElement('table');
24056
+ const theadElement = document.createElement('thead');
24057
+ const headerTrElement = document.createElement('tr');
24058
+ const tbodyElement = document.createElement('tbody');
24050
24059
  theadElement.appendChild(headerTrElement);
24051
24060
  tableElement.appendChild(theadElement);
24052
24061
  tableElement.appendChild(tbodyElement);
24053
24062
  parent.appendChild(tableElement);
24054
24063
 
24055
- columns.forEach(function(columnName) {
24056
- const headerElement = document.createElement("th");
24064
+ columns.forEach(function (columnName) {
24065
+ const headerElement = document.createElement('th');
24066
+ headerElement.classList.add('cell');
24057
24067
  headerElement.innerText = columnName;
24058
24068
  headerTrElement.appendChild(headerElement);
24059
24069
  });
24060
24070
  headerTrElement.appendChild(document.createElement('th'));
24061
24071
  let highlight = false;
24062
- rows.forEach(function(row) {
24063
- const rowElement = document.createElement("tr");
24072
+ rows.forEach(function (row) {
24073
+ const rowElement = document.createElement('tr');
24064
24074
  if (highlight) {
24065
- rowElement.classList.add("highlighted-row");
24075
+ rowElement.classList.add('highlighted-row');
24066
24076
  }
24067
24077
  highlight = !highlight;
24068
24078
  tbodyElement.appendChild(rowElement);
24069
- row.forEach(function(value) {
24070
- const cellElement = document.createElement("td");
24079
+ row.forEach(function (value) {
24080
+ const cellElement = document.createElement('td');
24081
+ cellElement.classList.add('cell');
24071
24082
  cellElement.innerText = value;
24072
24083
  rowElement.appendChild(cellElement);
24073
24084
  });
@@ -24075,13 +24086,13 @@ var sqlui = (function (exports) {
24075
24086
  });
24076
24087
  }
24077
24088
 
24078
- function selectGraphTab() {
24079
- Array.prototype.forEach.call(document.getElementsByClassName("graph-element"), function(selected) {
24080
- selected.style.display = "flex";
24089
+ function selectGraphTab () {
24090
+ Array.prototype.forEach.call(document.getElementsByClassName('graph-element'), function (selected) {
24091
+ selected.style.display = 'flex';
24081
24092
  });
24082
24093
 
24083
- google.charts.load('current', {packages: ['corechart', 'line']});
24084
- google.charts.setOnLoadCallback(function() {
24094
+ google.charts.load('current', { packages: ['corechart', 'line'] });
24095
+ google.charts.setOnLoadCallback(function () {
24085
24096
  loadQueryOrGraphTab(loadGraphResult);
24086
24097
  });
24087
24098
 
@@ -24090,9 +24101,9 @@ var sqlui = (function (exports) {
24090
24101
  setCursor(cursor);
24091
24102
  }
24092
24103
 
24093
- function selectQueryTab() {
24094
- Array.prototype.forEach.call(document.getElementsByClassName("query-element"), function(selected) {
24095
- selected.style.display = "flex";
24104
+ function selectQueryTab () {
24105
+ Array.prototype.forEach.call(document.getElementsByClassName('query-element'), function (selected) {
24106
+ selected.style.display = 'flex';
24096
24107
  });
24097
24108
 
24098
24109
  const cursor = getCursor();
@@ -24102,43 +24113,43 @@ var sqlui = (function (exports) {
24102
24113
  loadQueryOrGraphTab(loadQueryResult);
24103
24114
  }
24104
24115
 
24105
- function selectSavedTab() {
24106
- Array.prototype.forEach.call(document.getElementsByClassName("saved-element"), function(selected) {
24107
- selected.style.display = "flex";
24116
+ function selectSavedTab () {
24117
+ Array.prototype.forEach.call(document.getElementsByClassName('saved-element'), function (selected) {
24118
+ selected.style.display = 'flex';
24108
24119
  });
24109
24120
 
24110
24121
  if (window.savedLoaded) {
24111
- return;
24122
+ return
24112
24123
  }
24113
24124
 
24114
- const savedElement = document.getElementById("saved-box");
24125
+ const savedElement = document.getElementById('saved-box');
24115
24126
  if (savedElement.children.length > 0) {
24116
- return;
24127
+ return
24117
24128
  }
24118
24129
 
24119
- const saved = window.metadata["saved"];
24130
+ const saved = window.metadata.saved;
24120
24131
  if (saved && saved.length === 1) {
24121
- setSavedStatus("1 file");
24132
+ setSavedStatus('1 file');
24122
24133
  } else {
24123
24134
  setSavedStatus(`${saved.length} files`);
24124
24135
  }
24125
24136
  saved.forEach(file => {
24126
- const divElement = document.createElement("div");
24127
- divElement.addEventListener("click", function(event) {
24137
+ const divElement = document.createElement('div');
24138
+ divElement.addEventListener('click', function (event) {
24128
24139
  clearResult();
24129
24140
  const url = new URL(window.location);
24130
- url.searchParams.delete("sql");
24131
- url.searchParams.delete("tab");
24132
- url.searchParams.set("file", file["filename"]);
24133
- window.history.pushState({}, "", url);
24141
+ url.searchParams.delete('sql');
24142
+ url.searchParams.delete('tab');
24143
+ url.searchParams.set('file', file.filename);
24144
+ window.history.pushState({}, '', url);
24134
24145
  route();
24135
24146
  });
24136
- const nameElement = document.createElement("h1");
24137
- nameElement.innerText = file["filename"];
24147
+ const nameElement = document.createElement('h1');
24148
+ nameElement.innerText = file.filename;
24138
24149
  divElement.appendChild(nameElement);
24139
24150
 
24140
- const descriptionElement = document.createElement("p");
24141
- descriptionElement.innerText = file["description"];
24151
+ const descriptionElement = document.createElement('p');
24152
+ descriptionElement.innerText = file.description;
24142
24153
  divElement.appendChild(descriptionElement);
24143
24154
 
24144
24155
  savedElement.appendChild(divElement);
@@ -24146,38 +24157,38 @@ var sqlui = (function (exports) {
24146
24157
  window.savedLoaded = true;
24147
24158
  }
24148
24159
 
24149
- function submit() {
24160
+ function submit () {
24150
24161
  const url = new URL(window.location);
24151
- url.searchParams.set("cursor", getCursor());
24162
+ url.searchParams.set('cursor', getCursor());
24152
24163
 
24153
24164
  let sql = getValue().trim();
24154
- sql = sql === "" ? null : sql;
24165
+ sql = sql === '' ? null : sql;
24155
24166
 
24156
- if (url.searchParams.has("file")) {
24157
- url.searchParams.delete("file");
24158
- url.searchParams.set("sql", sql);
24159
- window.history.pushState({}, "", url);
24167
+ if (url.searchParams.has('file')) {
24168
+ url.searchParams.delete('file');
24169
+ url.searchParams.set('sql', sql);
24170
+ window.history.pushState({}, '', url);
24160
24171
  } else {
24161
- let sqlParam = url.searchParams.get("sql")?.trim();
24162
- sqlParam = sqlParam === "" ? null : sqlParam;
24172
+ let sqlParam = url.searchParams.get('sql')?.trim();
24173
+ sqlParam = sqlParam === '' ? null : sqlParam;
24163
24174
 
24164
24175
  if (sqlParam !== sql) {
24165
24176
  if (sql === null) {
24166
- url.searchParams.delete("sql");
24167
- window.history.pushState({}, "", url);
24177
+ url.searchParams.delete('sql');
24178
+ window.history.pushState({}, '', url);
24168
24179
  } else {
24169
- url.searchParams.set("sql", sql);
24170
- window.history.pushState({}, "", url);
24180
+ url.searchParams.set('sql', sql);
24181
+ window.history.pushState({}, '', url);
24171
24182
  }
24172
24183
  } else {
24173
- window.history.replaceState({}, "", url);
24184
+ window.history.replaceState({}, '', url);
24174
24185
  }
24175
24186
  }
24176
24187
  clearResult();
24177
24188
  route();
24178
24189
  }
24179
24190
 
24180
- function clearResult() {
24191
+ function clearResult () {
24181
24192
  clearGraphStatus();
24182
24193
  clearQueryStatus();
24183
24194
  clearGraphBox();
@@ -24185,266 +24196,267 @@ var sqlui = (function (exports) {
24185
24196
  window.result = null;
24186
24197
  }
24187
24198
 
24188
- function clearQueryStatus() {
24189
- document.getElementById("query-status").innerText = "";
24199
+ function clearQueryStatus () {
24200
+ document.getElementById('query-status').innerText = '';
24190
24201
  }
24191
24202
 
24192
- function clearGraphStatus() {
24193
- document.getElementById("graph-status").innerText = "";
24203
+ function clearGraphStatus () {
24204
+ document.getElementById('graph-status').innerText = '';
24194
24205
  }
24195
24206
 
24196
- function clearResultBox() {
24197
- const resultElement = document.getElementById("result-box");
24198
- while(resultElement.firstChild) {
24207
+ function clearResultBox () {
24208
+ const resultElement = document.getElementById('result-box');
24209
+ while (resultElement.firstChild) {
24199
24210
  resultElement.removeChild(resultElement.firstChild);
24200
24211
  }
24201
24212
  }
24202
24213
 
24203
- function clearGraphBox() {
24204
- const graphElement = document.getElementById("graph-box");
24205
- while(graphElement.firstChild) {
24214
+ function clearGraphBox () {
24215
+ const graphElement = document.getElementById('graph-box');
24216
+ while (graphElement.firstChild) {
24206
24217
  graphElement.removeChild(graphElement.firstChild);
24207
24218
  }
24208
24219
  }
24209
24220
 
24210
- function fetchSql(sql, cursor, callback) {
24211
- fetch("query", {
24212
- "headers": {
24213
- "Accept": "application/json",
24214
- "Content-Type": "application/json"
24221
+ function fetchSql (sql, cursor, callback) {
24222
+ fetch('query', {
24223
+ headers: {
24224
+ Accept: 'application/json',
24225
+ 'Content-Type': 'application/json'
24215
24226
  },
24216
- "method":"POST",
24217
- "body": JSON.stringify({
24218
- "sql": sql,
24219
- "cursor": cursor
24227
+ method: 'POST',
24228
+ body: JSON.stringify({
24229
+ sql,
24230
+ cursor
24220
24231
  })
24221
24232
  })
24222
- .then((response) => response.json())
24223
- .then((result) => callback(result));
24233
+ .then((response) => response.json())
24234
+ .then((result) => callback(result));
24224
24235
  }
24225
24236
 
24226
- function fetchFile(name, callback) {
24237
+ function fetchFile (name, callback) {
24227
24238
  fetch(`query_file?file=${name}`, {
24228
- "headers": {
24229
- "Accept": "application/json"
24239
+ headers: {
24240
+ Accept: 'application/json'
24230
24241
  },
24231
- "method":"GET"
24242
+ method: 'GET'
24232
24243
  })
24233
- .then((response) => response.json())
24234
- .then((result) => callback(result));
24244
+ .then((response) => response.json())
24245
+ .then((result) => callback(result));
24235
24246
  }
24236
24247
 
24237
- function fetchMetadata(callback) {
24238
- fetch("metadata", {
24239
- "headers": {
24240
- "Accept": "application/json"
24248
+ function fetchMetadata (callback) {
24249
+ fetch('metadata', {
24250
+ headers: {
24251
+ Accept: 'application/json'
24241
24252
  },
24242
- "method":"GET"
24253
+ method: 'GET'
24243
24254
  })
24244
- .then((response) => response.json())
24245
- .then((result) => callback(result));
24255
+ .then((response) => response.json())
24256
+ .then((result) => callback(result));
24246
24257
  }
24247
24258
 
24248
- function loadQueryOrGraphTab(callback) {
24259
+ function loadQueryOrGraphTab (callback) {
24249
24260
  const params = new URLSearchParams(window.location.search);
24250
- const sql = params.get("sql");
24251
- const file = params.get("file");
24252
- const cursor = params.has("cursor") ? params.get("cursor") : 0;
24261
+ const sql = params.get('sql');
24262
+ const file = params.get('file');
24263
+ const cursor = params.has('cursor') ? params.get('cursor') : 0;
24253
24264
 
24254
- if (params.has("sql") && window.result && sql === window.result["query"]) {
24265
+ if (params.has('sql') && window.result && sql === window.result.query) {
24255
24266
  callback();
24256
- return;
24257
- } else if (params.has("file") && window.result && file === window.result["file"]) {
24267
+ return
24268
+ } else if (params.has('file') && window.result && file === window.result.file) {
24258
24269
  callback();
24259
- return;
24270
+ return
24260
24271
  }
24261
24272
 
24262
- if (params.has("file") && params.has("sql") && cursor === window.result["cursor"]) {
24273
+ if (params.has('file') && params.has('sql') && cursor === window.result.cursor) {
24263
24274
  // TODO: show an error.
24264
- throw "You can only specify a file or sql, not both."
24275
+ throw new Error('You can only specify a file or sql, not both.')
24265
24276
  }
24266
24277
 
24267
- if (params.has("sql")) {
24278
+ clearResult();
24279
+
24280
+ if (params.has('sql')) {
24268
24281
  setValue(sql);
24269
- const cursor = params.has("cursor") ? params.get("cursor") : 0;
24270
- fetchSql(params.get("sql"), cursor, function(result) {
24282
+ const cursor = params.has('cursor') ? params.get('cursor') : 0;
24283
+ fetchSql(params.get('sql'), cursor, function (result) {
24271
24284
  window.result = result;
24272
24285
  callback();
24273
24286
  });
24274
- } else if (params.has("file")) {
24275
- setValue("");
24276
- fetchFile(file, function(result) {
24287
+ } else if (params.has('file')) {
24288
+ setValue('');
24289
+ fetchFile(file, function (result) {
24277
24290
  window.result = result;
24278
- if (window.result["query"]) {
24279
- setValue(result["query"]);
24291
+ if (window.result.query) {
24292
+ setValue(result.query);
24280
24293
  }
24281
24294
  callback();
24282
24295
  });
24283
24296
  }
24284
- if (params.has("cursor")) {
24297
+ if (params.has('cursor')) {
24285
24298
  focus();
24286
24299
  setCursor(cursor);
24287
24300
  }
24288
24301
  }
24289
24302
 
24290
- function loadQueryResult() {
24291
- const resultElement = document.getElementById("result-box");
24303
+ function loadQueryResult () {
24304
+ const resultElement = document.getElementById('result-box');
24292
24305
  if (resultElement.children.length > 0) {
24293
- return;
24306
+ return
24294
24307
  }
24295
24308
 
24296
24309
  setQueryStatus(window.result);
24297
24310
 
24298
- if (!window.result["rows"]) {
24299
- return;
24311
+ if (!window.result.rows) {
24312
+ return
24300
24313
  }
24301
24314
 
24302
- const tableElement = document.createElement("table");
24303
- const theadElement = document.createElement("thead");
24304
- const headerElement = document.createElement("tr");
24305
- const tbodyElement = document.createElement("tbody");
24315
+ const tableElement = document.createElement('table');
24316
+ const theadElement = document.createElement('thead');
24317
+ const headerElement = document.createElement('tr');
24318
+ const tbodyElement = document.createElement('tbody');
24306
24319
  theadElement.appendChild(headerElement);
24307
24320
  tableElement.appendChild(theadElement);
24308
24321
  tableElement.appendChild(tbodyElement);
24309
24322
  resultElement.appendChild(tableElement);
24310
-
24311
- window.result["columns"].forEach(column => {
24312
- const template = document.createElement("template");
24313
- template.innerHTML = `<th>${column}</th>`;
24323
+
24324
+ window.result.columns.forEach(column => {
24325
+ const template = document.createElement('template');
24326
+ template.innerHTML = `<th class="cell">${column}</th>`;
24314
24327
  headerElement.appendChild(template.content.firstChild);
24315
24328
  });
24316
24329
  headerElement.appendChild(document.createElement('th'));
24317
24330
  let highlight = false;
24318
- window.result["rows"].forEach(function(row) {
24319
- const rowElement = document.createElement("tr");
24331
+ window.result.rows.forEach(function (row) {
24332
+ const rowElement = document.createElement('tr');
24320
24333
  if (highlight) {
24321
- rowElement.classList.add("highlighted-row");
24334
+ rowElement.classList.add('highlighted-row');
24322
24335
  }
24323
24336
  highlight = !highlight;
24324
24337
  tbodyElement.appendChild(rowElement);
24325
- row.forEach(function(value) {
24326
- const template = document.createElement("template");
24327
- template.innerHTML = `<td>${value}</td>`;
24338
+ row.forEach(function (value) {
24339
+ const template = document.createElement('template');
24340
+ template.innerHTML = `<td class="cell">${value}</td>`;
24328
24341
  rowElement.appendChild(template.content.firstChild);
24329
24342
  });
24330
24343
  rowElement.appendChild(document.createElement('td'));
24331
24344
  });
24332
24345
 
24333
- document.getElementById("result-box").style.display = "flex";
24346
+ document.getElementById('result-box').style.display = 'flex';
24334
24347
  }
24335
24348
 
24336
- function loadGraphResult() {
24349
+ function loadGraphResult () {
24337
24350
  setGraphStatus(window.result);
24338
24351
 
24339
- if (!window.result["rows"]) {
24340
- return;
24352
+ if (!window.result.rows) {
24353
+ return
24341
24354
  }
24342
- if (window.result["rows"].length == 0 || window.result["columns"].length < 2) {
24343
- return;
24355
+ if (window.result.rows.length === 0 || window.result.columns.length < 2) {
24356
+ return
24344
24357
  }
24345
24358
  const dataTable = new google.visualization.DataTable();
24346
- window.result["columns"].forEach((column, index) => {
24347
- dataTable.addColumn(window.result["column_types"][index], column);
24359
+ window.result.columns.forEach((column, index) => {
24360
+ dataTable.addColumn(window.result.column_types[index], column);
24348
24361
  });
24349
24362
 
24350
- window.result["rows"].forEach((row) => {
24363
+ window.result.rows.forEach((row) => {
24351
24364
  const rowValues = row.map((value, index) => {
24352
- if (window.result["column_types"][index] === "date") {
24353
- return new Date(value);
24365
+ if (window.result.column_types[index] === 'date') {
24366
+ return new Date(value)
24354
24367
  } else {
24355
- return value;
24368
+ return value
24356
24369
  }
24357
24370
  });
24358
24371
  dataTable.addRow(rowValues);
24359
24372
  });
24360
24373
 
24361
- const graphBoxElement = document.getElementById("graph-box");
24374
+ const graphBoxElement = document.getElementById('graph-box');
24362
24375
 
24363
24376
  const chart = new google.visualization.LineChart(graphBoxElement);
24364
24377
  const options = {
24365
- "hAxis": {
24366
- "title": window.result["columns"][0]
24378
+ hAxis: {
24379
+ title: window.result.columns[0]
24367
24380
  },
24368
- "vAxis": {
24369
- "title": window.result["columns"][1]
24381
+ vAxis: {
24382
+ title: window.result.columns[1]
24370
24383
  }
24371
24384
  };
24372
24385
  chart.draw(dataTable, options);
24373
24386
  }
24374
24387
 
24375
- function setGraphStatus(result) {
24376
- const statusElement = document.getElementById("graph-status");
24377
- if (!result["rows"]) {
24388
+ function setGraphStatus (result) {
24389
+ const statusElement = document.getElementById('graph-status');
24390
+ if (!result.rows) {
24378
24391
  // TODO use a popup
24379
- console.log("error parsing graph result");
24392
+ console.log('error parsing graph result');
24380
24393
  console.log(JSON.stringify(result, null, 2));
24381
- statusElement.innerText = "error, check console";
24382
- return;
24394
+ statusElement.innerText = 'error, check console';
24395
+ return
24383
24396
  }
24384
24397
 
24385
- if (result["total_rows"] == 1) {
24386
- statusElement.innerText = `${result["total_rows"]} row`;
24398
+ if (result.total_rows === 1) {
24399
+ statusElement.innerText = `${result.total_rows} row`;
24387
24400
  } else {
24388
- statusElement.innerText = `${result["total_rows"]} rows`;
24401
+ statusElement.innerText = `${result.total_rows} rows`;
24389
24402
  }
24390
24403
 
24391
- if (result["total_rows"] > result["rows"].length) {
24392
- statusElement.innerText += ` (truncated to ${result["rows"].length})`;
24404
+ if (result.total_rows > result.rows.length) {
24405
+ statusElement.innerText += ` (truncated to ${result.rows.length})`;
24393
24406
  }
24394
24407
  }
24395
24408
 
24396
- function setQueryStatus(result) {
24397
- const statusElement = document.getElementById("query-status");
24398
- if (!result["rows"]) {
24409
+ function setQueryStatus (result) {
24410
+ const statusElement = document.getElementById('query-status');
24411
+ if (!result.rows) {
24399
24412
  // TODO use a popup
24400
- console.log("error parsing query result");
24413
+ console.log('error parsing query result');
24401
24414
  console.log(JSON.stringify(result, null, 2));
24402
- statusElement.innerText = "error, check console";
24403
- return;
24415
+ statusElement.innerText = 'error, check console';
24416
+ return
24404
24417
  }
24405
24418
 
24406
- if (result["total_rows"] == 1) {
24407
- statusElement.innerText = `${result["total_rows"]} row`;
24419
+ if (result.total_rows === 1) {
24420
+ statusElement.innerText = `${result.total_rows} row`;
24408
24421
  } else {
24409
- statusElement.innerText = `${result["total_rows"]} rows`;
24422
+ statusElement.innerText = `${result.total_rows} rows`;
24410
24423
  }
24411
24424
 
24412
- if (result["total_rows"] > result["rows"].length) {
24413
- statusElement.innerText += ` (truncated to ${result["rows"].length})`;
24425
+ if (result.total_rows > result.rows.length) {
24426
+ statusElement.innerText += ` (truncated to ${result.rows.length})`;
24414
24427
  }
24415
24428
  }
24416
24429
 
24417
- function setSavedStatus(status) {
24418
- document.getElementById("saved-status").innerText = status;
24430
+ function setSavedStatus (status) {
24431
+ document.getElementById('saved-status').innerText = status;
24419
24432
  }
24420
24433
 
24421
- window.addEventListener("popstate", function(event) {
24434
+ window.addEventListener('popstate', function (event) {
24422
24435
  route();
24423
24436
  });
24424
24437
 
24425
- window.addEventListener("resize", function(event) {
24426
- if (window.tab === "graph" && window.result) {
24438
+ window.addEventListener('resize', function (event) {
24439
+ if (window.tab === 'graph' && window.result) {
24427
24440
  clearGraphBox();
24428
24441
  loadGraphResult();
24429
24442
  }
24430
24443
  });
24431
24444
 
24432
- function route() {
24433
- selectTab(new URLSearchParams(window.location.search).get("tab") || "query");
24445
+ function route () {
24446
+ selectTab(new URLSearchParams(window.location.search).get('tab') || 'query');
24434
24447
  }
24435
24448
 
24436
24449
  window.onload = function () {
24437
- fetchMetadata(function(result) {
24450
+ fetchMetadata(function (result) {
24438
24451
  window.metadata = result;
24439
- if (!result["server"]) {
24452
+ if (!result.server) {
24440
24453
  // TODO show error
24441
- throw "unexpected metadata response";
24454
+ throw new Error('unexpected metadata response')
24442
24455
  }
24443
- document.getElementById("header").innerText = result["server"];
24444
- new URLSearchParams(window.location.search);
24445
- const queryElement = document.getElementById("query");
24456
+ document.getElementById('header').innerText = result.server;
24457
+ const queryElement = document.getElementById('query');
24446
24458
 
24447
- init(queryElement, function() {
24459
+ init(queryElement, function () {
24448
24460
  submit();
24449
24461
  });
24450
24462
  route();