datafolder 1.0.14 → 1.0.15

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.
@@ -43,7 +43,7 @@ export default class extends a {
43
43
  super(s = {
44
44
  ...e("QySnapshotCompactor_Worker"),
45
45
  ...s
46
- }, [], [ "compactSnapshots", "saveSnapshotInfos" ]);
46
+ });
47
47
  var o = t(a, "snapshot");
48
48
  Object.assign(this, {
49
49
  kvFolder: a,
@@ -82,7 +82,7 @@ export default class extends a {
82
82
  qySnapshots: e,
83
83
  vLInfoMap: p
84
84
  } = a;
85
- await M(a, s) && (await m(a, s), await e.saveKeyValueMap(s), {
85
+ await M(a, s) && (await y(a, s), await e.saveKeyValueMap(s), {
86
86
  snapshotNum: a,
87
87
  info: e,
88
88
  posMap: s,
@@ -102,13 +102,13 @@ export default class extends a {
102
102
  snapshotNum: i,
103
103
  info: r,
104
104
  keyValueMap: f
105
- } = (await m(t, n), n);
105
+ } = (await y(t, n), n);
106
106
  Object.assign(n, {
107
107
  posMap: void 0,
108
108
  prefixPM: void 0
109
109
  });
110
110
  for (var h of a) if (h != n) {
111
- await m(t, h);
111
+ await y(t, h);
112
112
  let {
113
113
  snapshotNum: a,
114
114
  info: s,
@@ -169,7 +169,7 @@ async function M(a, s) {
169
169
  return n.close(), !0;
170
170
  }
171
171
 
172
- async function m(a, s) {
172
+ async function y(a, s) {
173
173
  var o, a = a.qySnapshots, t = s.posMap, e = s.keyValueMap = {}, p = a.getVLFilePath(s), n = await f(p);
174
174
  for (o of Object.keys(t).sort()) {
175
175
  var [ i, r ] = t[o];
@@ -12,7 +12,7 @@ export default class QySnapshotSaver_Worker extends QyMessageWorker {
12
12
  options: any;
13
13
  });
14
14
  _op_start(maxChangeId: any, loadedMaxAclNum: any, aclKeyValueMap: any): void;
15
- castSave(changeId: any, cmdArgAsListObj: any, syncList: any): void;
15
+ castSave(changeId: any, cmdArgAsListObjStr: any, syncListStr: any): void;
16
16
  saveSnapshot(maxSnapshotNum: any): Promise<void>;
17
17
  releaseSnapshot(snapshotNum: any): void;
18
18
  _op_stop(): Promise<number>;
@@ -37,7 +37,7 @@ export default class extends a {
37
37
  super(s = {
38
38
  ...o("QySnapshotSaver_Worker"),
39
39
  ...s
40
- }, [], [ "waitForSnapshotSaved" ]);
40
+ });
41
41
  var e = t(a, "snapshot");
42
42
  Object.assign(this, {
43
43
  kvFolder: a,
@@ -54,7 +54,7 @@ export default class extends a {
54
54
  aclKeyValueMap: t,
55
55
  qySnapshots: o
56
56
  } = this;
57
- o.applyCmdObj(s, t, e), this.maxChangeId = a;
57
+ o.applyCmdObj(JSON.parse(s), t, e ? JSON.parse(e) : void 0), this.maxChangeId = a;
58
58
  }
59
59
  async saveSnapshot(a) {
60
60
  var {
@@ -10,7 +10,7 @@ export declare class QySnapshots {
10
10
  snapshotMaxChangeId: number;
11
11
  maxSnapshotNum: number;
12
12
  snapshotCount: number;
13
- constructor(snapshotFolder: any, options: any);
13
+ constructor(snapshotFolder: any, options?: any);
14
14
  loadSnapshotInfos(): Promise<void>;
15
15
  closeAllFDs(): void;
16
16
  saveKeyValueMap(snapshot: any): Promise<[[any, any], any]>;
@@ -13,7 +13,7 @@ import {
13
13
  join as n
14
14
  } from "node:path";
15
15
 
16
- import m from "node:zlib";
16
+ import d from "node:zlib";
17
17
 
18
18
  import {
19
19
  getDefaultOptions as s
@@ -21,7 +21,7 @@ import {
21
21
 
22
22
  import {
23
23
  Hash_Key_Length as u,
24
- folderOrFileExists as d,
24
+ folderOrFileExists as m,
25
25
  listToMap as f,
26
26
  isEmptyObj as h,
27
27
  isString as v
@@ -60,7 +60,7 @@ class t {
60
60
  snapshotMaxChangeId = 0;
61
61
  maxSnapshotNum = 0;
62
62
  snapshotCount = 0;
63
- constructor(t, o) {
63
+ constructor(t, o = void 0) {
64
64
  (o = {
65
65
  ...s("QySnapshots"),
66
66
  ...o
@@ -79,7 +79,7 @@ class t {
79
79
  qyJsonSaver: s,
80
80
  numToSnapshotMap: r
81
81
  } = this;
82
- if (await d(t)) {
82
+ if (await m(t)) {
83
83
  var o = await (async (t, o) => {
84
84
  var a = {};
85
85
  for (s of await l(o)) {
@@ -131,7 +131,7 @@ class t {
131
131
  var l = e[o];
132
132
  let t;
133
133
  null == l ? t = K : (h = Buffer.isBuffer(l) ? (f = l, 0) : v(l) ? (f = l.length >= a ? (s.save(O),
134
- m.zstdCompressSync(l)) : (s.save(L), Buffer.from(l)), 1) : (f = Buffer.from(JSON.stringify(I(o) && !x(l) ? Object.keys(l) : l)),
134
+ d.zstdCompressSync(l)) : (s.save(L), Buffer.from(l)), 1) : (f = Buffer.from(JSON.stringify(I(o) && !x(l) ? Object.keys(l) : l)),
135
135
  0), s.save([ f, F ]), l = h + f.length, t = [ p, l ], p += l + 1), i[o] = t,
136
136
  ++u;
137
137
  }
@@ -207,7 +207,7 @@ class t {
207
207
  var [ e, a ] = a;
208
208
  if (0 != a) {
209
209
  var n = this;
210
- if (o = n.getVLFilePath(o), n = T(n, o, e, a)) return (o = n[0]) == j ? n.toString("utf8", 1) : o == J ? m.zstdDecompressSync(n.subarray(1)).toString() : (e = JSON.parse(n),
210
+ if (o = n.getVLFilePath(o), n = T(n, o, e, a)) return (o = n[0]) == j ? n.toString("utf8", 1) : o == J ? d.zstdDecompressSync(n.subarray(1)).toString() : (e = JSON.parse(n),
211
211
  I(t) ? f(e) : e);
212
212
  }
213
213
  }
@@ -20,7 +20,7 @@ export declare class QyUnionNode extends QyQueryNode {
20
20
  checkedDirMap: any;
21
21
  constructor(dir?: undefined);
22
22
  containsFile(fileName: any): boolean;
23
- getFiles(queryCounter: any, resultMap?: {}): Generator<any, void, any>;
23
+ getFiles(queryCounter?: any, resultMap?: {}): Generator<any, void, any>;
24
24
  addNode(node: any): void;
25
25
  addDir(dir: any): void;
26
26
  }
@@ -52,7 +52,7 @@ class o extends e {
52
52
  }
53
53
  return !1;
54
54
  }
55
- *getFiles(i, e = {}) {
55
+ *getFiles(i = void 0, e = {}) {
56
56
  var r, t, {
57
57
  dirMap: n,
58
58
  nodeList: s
@@ -8198,11 +8198,12 @@
8198
8198
  // Handle the case where closest matched a higher element on the
8199
8199
  // same line as an element below/above the coords
8200
8200
  if (closestDx) {
8201
- if (above && above.bottom > closestRect.top) {
8201
+ let { top, bottom } = closestRect;
8202
+ if (above && above.bottom > (top + top + bottom) / 3) {
8202
8203
  this.y = above.bottom - 1;
8203
8204
  return this.scan(positions, getRects);
8204
8205
  }
8205
- if (below && below.top < closestRect.bottom) {
8206
+ if (below && below.top < (top + bottom + bottom) / 3) {
8206
8207
  this.y = below.top + 1;
8207
8208
  return this.scan(positions, getRects);
8208
8209
  }
@@ -9573,8 +9574,8 @@
9573
9574
  const appliedFirefoxHack = /*@__PURE__*/new Set;
9574
9575
  // In Firefox, when cut/copy handlers are added to the document, that
9575
9576
  // somehow avoids a bug where those events aren't fired when the
9576
- // selection is empty. See https://github.com/codemirror/dev/issues/1082
9577
- // and https://bugzilla.mozilla.org/show_bug.cgi?id=995961
9577
+ // selection is empty. See issue #1082 and
9578
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=995961
9578
9579
  function firefoxCopyCutHack(doc) {
9579
9580
  if (!appliedFirefoxHack.has(doc)) {
9580
9581
  appliedFirefoxHack.add(doc);
@@ -11060,7 +11061,7 @@
11060
11061
  flexShrink: 0,
11061
11062
  display: "block",
11062
11063
  whiteSpace: "pre",
11063
- wordWrap: "normal", // https://github.com/codemirror/dev/issues/456
11064
+ wordWrap: "normal", // Issue #456
11064
11065
  boxSizing: "border-box",
11065
11066
  minHeight: "100%",
11066
11067
  padding: "4px 0",
@@ -11479,7 +11480,7 @@
11479
11480
  readSelectionRange() {
11480
11481
  let { view } = this;
11481
11482
  // The Selection object is broken in shadow roots in Safari. See
11482
- // https://github.com/codemirror/dev/issues/414
11483
+ // issue #414
11483
11484
  let selection = getSelection(view.root);
11484
11485
  if (!selection)
11485
11486
  return false;
@@ -12948,7 +12949,7 @@
12948
12949
  }
12949
12950
  /**
12950
12951
  Create a theme extension. The first argument can be a
12951
- [`style-mod`](https://github.com/marijnh/style-mod#documentation)
12952
+ [`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)
12952
12953
  style spec providing the styles for the theme. These will be
12953
12954
  prefixed with a generated class for the style.
12954
12955
 
@@ -12994,7 +12995,7 @@
12994
12995
  }
12995
12996
  /**
12996
12997
  Facet to add a [style
12997
- module](https://github.com/marijnh/style-mod#documentation) to
12998
+ module](https://code.haverbeke.berlin/marijn/style-mod#documentation) to
12998
12999
  an editor view. The view will ensure that the module is
12999
13000
  mounted in its [document
13000
13001
  root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
@@ -21869,8 +21870,13 @@
21869
21870
  The current match (only holds a meaningful value after
21870
21871
  [`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when
21871
21872
  `done` is false).
21873
+
21874
+ The `precise` flag will be set to false if the match starts or
21875
+ ends _inside_ a character that, when normalized, expands to
21876
+ multiple characters. It indicates that the `from`-`to` range
21877
+ covers content that isn't part of the actual match.
21872
21878
  */
21873
- this.value = { from: 0, to: 0 };
21879
+ this.value = { from: 0, to: 0, precise: false };
21874
21880
  /**
21875
21881
  Whether the end of the iterated region has been reached.
21876
21882
  */
@@ -21921,44 +21927,45 @@
21921
21927
  this.bufferPos += codePointSize(next);
21922
21928
  let norm = this.normalize(str);
21923
21929
  if (norm.length)
21924
- for (let i = 0, pos = start;; i++) {
21930
+ for (let i = 0, pos = start, posPrecise = true;; i++) {
21925
21931
  let code = norm.charCodeAt(i);
21926
- let match = this.match(code, pos, this.bufferPos + this.bufferStart);
21927
- if (i == norm.length - 1) {
21928
- if (match) {
21929
- this.value = match;
21930
- return this;
21931
- }
21932
- break;
21932
+ let match = this.match(code, pos, posPrecise, this.bufferPos + this.bufferStart, i == norm.length - 1);
21933
+ if (match) {
21934
+ this.value = match;
21935
+ return this;
21933
21936
  }
21934
- if (pos == start && i < str.length && str.charCodeAt(i) == code)
21937
+ if (i == norm.length - 1)
21938
+ break;
21939
+ if (posPrecise && i < str.length && str.charCodeAt(i) == code)
21935
21940
  pos++;
21941
+ else
21942
+ posPrecise = false;
21936
21943
  }
21937
21944
  }
21938
21945
  }
21939
- match(code, pos, end) {
21946
+ match(code, pos, posPrecise, end, endPrecise) {
21940
21947
  let match = null;
21941
- for (let i = 0; i < this.matches.length; i += 2) {
21942
- let index = this.matches[i], keep = false;
21943
- if (this.query.charCodeAt(index) == code) {
21944
- if (index == this.query.length - 1) {
21945
- match = { from: this.matches[i + 1], to: end };
21948
+ for (let i = 0; i < this.matches.length;) {
21949
+ let partial = this.matches[i], keep = false;
21950
+ if (this.query.charCodeAt(partial.index) == code) {
21951
+ if (partial.index == this.query.length - 1) {
21952
+ match = { from: partial.from, to: end, precise: endPrecise && partial.precise };
21946
21953
  }
21947
21954
  else {
21948
- this.matches[i]++;
21955
+ partial.index++;
21949
21956
  keep = true;
21950
21957
  }
21951
21958
  }
21952
- if (!keep) {
21953
- this.matches.splice(i, 2);
21954
- i -= 2;
21955
- }
21959
+ if (keep)
21960
+ i++;
21961
+ else
21962
+ this.matches.splice(i, 1);
21956
21963
  }
21957
21964
  if (this.query.charCodeAt(0) == code) {
21958
21965
  if (this.query.length == 1)
21959
- match = { from: pos, to: end };
21966
+ match = { from: pos, to: end, precise: posPrecise && endPrecise };
21960
21967
  else
21961
- this.matches.push(1, pos);
21968
+ this.matches.push({ from: pos, index: 1, precise: posPrecise });
21962
21969
  }
21963
21970
  if (match && this.test && !this.test(match.from, match.to, this.buffer, this.bufferStart))
21964
21971
  match = null;
@@ -21968,7 +21975,7 @@
21968
21975
  if (typeof Symbol != "undefined")
21969
21976
  SearchCursor.prototype[Symbol.iterator] = function () { return this; };
21970
21977
 
21971
- const empty = { from: -1, to: -1, match: /*@__PURE__*//.*/.exec("") };
21978
+ const empty = { from: -1, to: -1, match: /*@__PURE__*//.*/.exec(""), precise: true };
21972
21979
  const baseFlags = "gm" + (/x/.unicode == null ? "" : "u");
21973
21980
  /**
21974
21981
  This class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)
@@ -21993,7 +22000,9 @@
21993
22000
  /**
21994
22001
  Will contain an object with the extent of the match and the
21995
22002
  match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)
21996
- sucessfully finds a match.
22003
+ sucessfully finds a match. The `precise` flag is always true for
22004
+ this type of cursor, and only there to make sure this cursor is
22005
+ a subtype of `SearchCursor`.
21997
22006
  */
21998
22007
  this.value = empty;
21999
22008
  if (/\\[sWDnr]|\n|\r|\[\^/.test(query))
@@ -22038,7 +22047,7 @@
22038
22047
  if (from == this.curLineStart + this.curLine.length)
22039
22048
  this.nextLine();
22040
22049
  if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {
22041
- this.value = { from, to, match };
22050
+ this.value = { from, to, precise: true, match };
22042
22051
  return this;
22043
22052
  }
22044
22053
  off = this.matchPos - this.curLineStart;
@@ -22111,7 +22120,7 @@
22111
22120
  // again, since it'll likely be able to match more
22112
22121
  if ((this.flat.to >= this.to || match.index + match[0].length <= this.flat.text.length - 10) &&
22113
22122
  (!this.test || this.test(from, to, match))) {
22114
- this.value = { from, to, match };
22123
+ this.value = { from, to, precise: true, match };
22115
22124
  this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
22116
22125
  return this;
22117
22126
  }
@@ -22730,10 +22739,12 @@
22730
22739
  let next = match;
22731
22740
  let changes = [], selection, replacement;
22732
22741
  let effects = [];
22733
- if (next.from == from && next.to == to) {
22742
+ if (!next.precise) {
22743
+ next = query.nextMatch(state, next.from, next.to);
22744
+ }
22745
+ else if (next.from == from && next.to == to) {
22734
22746
  replacement = state.toText(query.getReplacement(next));
22735
22747
  changes.push({ from: next.from, to: next.to, insert: replacement });
22736
- next = query.nextMatch(state, next.from, next.to);
22737
22748
  effects.push(EditorView.announce.of(state.phrase("replaced match on line $", state.doc.lineAt(from).number) + "."));
22738
22749
  }
22739
22750
  let changeSet = view.state.changes(changes);
@@ -22757,10 +22768,12 @@
22757
22768
  const replaceAll = /*@__PURE__*/searchCommand((view, { query }) => {
22758
22769
  if (view.state.readOnly)
22759
22770
  return false;
22760
- let changes = query.matchAll(view.state, 1e9).map(match => {
22761
- let { from, to } = match;
22762
- return { from, to, insert: query.getReplacement(match) };
22763
- });
22771
+ let changes = [];
22772
+ for (let match of query.matchAll(view.state, 1e9)) {
22773
+ let { from, to, precise } = match;
22774
+ if (precise)
22775
+ changes.push({ from, to, insert: query.getReplacement(match) });
22776
+ }
22764
22777
  if (!changes.length)
22765
22778
  return false;
22766
22779
  let announceText = view.state.phrase("replaced $ matches", changes.length) + ".";
@@ -25874,16 +25887,12 @@
25874
25887
  if (term == 0 /* Term.Err */ &&
25875
25888
  (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
25876
25889
  // Try to omit/merge adjacent error nodes
25877
- let cur = this, top = this.buffer.length;
25878
- if (top == 0 && cur.parent) {
25879
- top = cur.bufferBase - cur.parent.bufferBase;
25880
- cur = cur.parent;
25881
- }
25882
- if (top > 0 && cur.buffer[top - 4] == 0 /* Term.Err */ && cur.buffer[top - 1] > -1) {
25890
+ let top = this.buffer.length;
25891
+ if (top > 0 && this.buffer[top - 4] == 0 /* Term.Err */ && this.buffer[top - 1] > -1) {
25883
25892
  if (start == end)
25884
25893
  return;
25885
- if (cur.buffer[top - 2] >= start) {
25886
- cur.buffer[top - 2] = end;
25894
+ if (this.buffer[top - 2] >= start) {
25895
+ this.buffer[top - 2] = end;
25887
25896
  return;
25888
25897
  }
25889
25898
  }
@@ -25982,6 +25991,10 @@
25982
25991
  split() {
25983
25992
  let parent = this;
25984
25993
  let off = parent.buffer.length;
25994
+ // Leave off top error node, if there, because that might be
25995
+ // merged with other nodes.
25996
+ if (off && parent.buffer[off - 4] == 0 /* Term.Err */)
25997
+ off -= 4;
25985
25998
  // Because the top of the buffer (after this.pos) may be mutated
25986
25999
  // to reorder reductions and skipped tokens, and shared buffers
25987
26000
  // should be immutable, this copies any outstanding skipped tokens