@tellaro/tql 0.1.5 → 0.1.6

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.
@@ -11,15 +11,15 @@ function Te(V) {
11
11
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
12
  snippets: pe,
13
13
  // Reserved for future snippet support
14
- fieldValues: x,
14
+ fieldValues: w,
15
15
  validateOnInput: j = !0,
16
16
  debounceMs: Q = 300,
17
17
  completionDebounceMs: _ = 50,
18
18
  // Faster debounce for completions
19
- autocomplete: k = !0,
20
- onValidation: y,
21
- onParse: A
22
- } = V, f = v([]), q = v(null), g = v(null), c = v(0), d = v([]), p = v(!1), C = v(!1);
19
+ autocomplete: C = !0,
20
+ onValidation: x,
21
+ onParse: y
22
+ } = V, f = v([]), q = v(null), g = v(null), c = v(0), d = v([]), p = v(!1), A = v(!1);
23
23
  let P = 0;
24
24
  const $ = T(() => {
25
25
  var e;
@@ -36,12 +36,12 @@ function Te(V) {
36
36
  }
37
37
  function H() {
38
38
  const e = ae(i.value);
39
- return q.value = e, A == null || A(e), e;
39
+ return q.value = e, y == null || y(e), e;
40
40
  }
41
41
  function E() {
42
- var s, r;
43
- C.value = !0;
44
- const e = (s = u == null ? void 0 : u.value) == null ? void 0 : s.map((l) => l.name), t = (r = u == null ? void 0 : u.value) == null ? void 0 : r.reduce(
42
+ var o, r;
43
+ A.value = !0;
44
+ const e = (o = u == null ? void 0 : u.value) == null ? void 0 : o.map((l) => l.name), t = (r = u == null ? void 0 : u.value) == null ? void 0 : r.reduce(
45
45
  (l, m) => (l[m.name] = m.type, l),
46
46
  {}
47
47
  ), n = ce(i.value, {
@@ -49,11 +49,11 @@ function Te(V) {
49
49
  fieldTypes: t,
50
50
  strictMode: !1
51
51
  });
52
- return g.value = n, C.value = !1, y == null || y(n), n;
52
+ return g.value = n, A.value = !1, x == null || x(n), n;
53
53
  }
54
54
  const J = R(E, Q), K = R(I, _);
55
55
  function I() {
56
- if (!k) {
56
+ if (!C) {
57
57
  d.value = [], p.value = !1;
58
58
  return;
59
59
  }
@@ -68,7 +68,7 @@ function Te(V) {
68
68
  },
69
69
  {
70
70
  fields: u == null ? void 0 : u.value,
71
- fieldValues: x == null ? void 0 : x.value,
71
+ fieldValues: w == null ? void 0 : w.value,
72
72
  includeSnippets: !0,
73
73
  maxItems: 15
74
74
  }
@@ -78,50 +78,50 @@ function Te(V) {
78
78
  function L() {
79
79
  I(), p.value = d.value.length > 0;
80
80
  }
81
- function W() {
81
+ function O() {
82
82
  p.value = !1;
83
83
  }
84
- function z(e) {
85
- M(), j && J(), k && le(e, c.value) && (K(), d.value.length > 0 && (p.value = !0));
84
+ function W(e) {
85
+ M(), j && J(), C && le(e, c.value) && (K(), d.value.length > 0 && (p.value = !0));
86
86
  }
87
87
  function N(e) {
88
88
  c.value = e, I();
89
89
  }
90
90
  function X(e) {
91
- const t = i.value, n = c.value, s = U(f.value, n);
91
+ const t = i.value, n = c.value, o = U(f.value, n);
92
92
  let r = n, l = n;
93
- if (s && s.type !== "whitespace")
94
- r = s.start, l = s.end;
93
+ if (o && o.type !== "whitespace")
94
+ r = o.start, l = o.end;
95
95
  else {
96
- const a = f.value.filter((o) => o.end <= n && o.type !== "whitespace");
96
+ const a = f.value.filter((s) => s.end <= n && s.type !== "whitespace");
97
97
  if (a.length > 0) {
98
- const o = a[a.length - 1];
99
- o.end === n && (r = o.start, l = o.end);
98
+ const s = a[a.length - 1];
99
+ s.end === n && (r = s.start, l = s.end);
100
100
  }
101
101
  }
102
- const m = t.substring(0, r), te = t.substring(l), w = [];
102
+ const m = t.substring(0, r), te = t.substring(l), k = [];
103
103
  let h = e.insertText;
104
104
  const ne = [...e.insertText.matchAll(/\$(\d+)/g)].sort(
105
- (a, o) => parseInt(a[1]) - parseInt(o[1])
105
+ (a, s) => parseInt(a[1]) - parseInt(s[1])
106
106
  );
107
- let F = 0;
107
+ let z = 0;
108
108
  for (const a of ne) {
109
- const o = h.indexOf(a[0]);
110
- if (o !== -1) {
111
- const O = r + o - F;
112
- w.push({
113
- start: O,
114
- end: O
109
+ const s = h.indexOf(a[0]);
110
+ if (s !== -1) {
111
+ const F = r + s - z;
112
+ k.push({
113
+ start: F,
114
+ end: F
115
115
  // Zero-width cursor position
116
- }), h = h.replace(a[0], ""), F += a[0].length;
116
+ }), h = h.replace(a[0], ""), z += a[0].length;
117
117
  }
118
118
  }
119
- const se = m + h + te, oe = w.length > 0 ? w[0].start : r + h.length;
120
- return W(), P = Date.now() + 150, { query: se, newCursorPosition: oe, placeholders: w };
119
+ const oe = m + h + te, se = k.length > 0 ? k[0].start : r + h.length;
120
+ return O(), e.kind === "logicalOp" && (P = Date.now() + 150), { query: oe, newCursorPosition: se, placeholders: k };
121
121
  }
122
122
  function Y(e) {
123
- const t = i.value, n = c.value, s = t.substring(0, n), r = t.substring(n), m = s.length > 0 && !s.endsWith(" ") && !s.endsWith("(") ? " " : "";
124
- return s + m + e.insertText + r;
123
+ const t = i.value, n = c.value, o = t.substring(0, n), r = t.substring(n), m = o.length > 0 && !o.endsWith(" ") && !o.endsWith("(") ? " " : "";
124
+ return o + m + e.insertText + r;
125
125
  }
126
126
  function Z() {
127
127
  return U(f.value, c.value);
@@ -135,7 +135,7 @@ function Te(V) {
135
135
  return re(
136
136
  i,
137
137
  (e) => {
138
- e !== void 0 && z(e);
138
+ e !== void 0 && W(e);
139
139
  },
140
140
  { immediate: !0 }
141
141
  ), {
@@ -146,7 +146,7 @@ function Te(V) {
146
146
  cursorPosition: c,
147
147
  completionItems: d,
148
148
  showAutocomplete: p,
149
- isValidating: C,
149
+ isValidating: A,
150
150
  // Computed
151
151
  isValid: $,
152
152
  errors: b,
@@ -159,8 +159,8 @@ function Te(V) {
159
159
  validate: E,
160
160
  updateCompletions: I,
161
161
  triggerAutocomplete: L,
162
- hideAutocomplete: W,
163
- handleInput: z,
162
+ hideAutocomplete: O,
163
+ handleInput: W,
164
164
  handleCursorChange: N,
165
165
  insertCompletion: X,
166
166
  insertSnippet: Y,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellaro/tql",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Tellaro Query Language (TQL) parser, validator, and autocomplete for JavaScript/TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",