dequel-editor 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{de-ChXK8h97.js → de-7qfktOGD.js} +0 -2
- package/dist/dequel-editor.js +5289 -4059
- package/dist/dequel-lang.js +91 -101
- package/package.json +4 -3
package/dist/dequel-lang.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { syntaxTree as
|
|
2
|
-
import { Tag as
|
|
3
|
-
import { buildParser as
|
|
4
|
-
import { Facet as
|
|
5
|
-
const
|
|
1
|
+
import { syntaxTree as P, LRLanguage as O, indentNodeProp as I, foldNodeProp as V, foldInside as w, HighlightStyle as A, LanguageSupport as E, syntaxHighlighting as D } from "@codemirror/language";
|
|
2
|
+
import { Tag as m, tags as i, styleTags as L } from "@lezer/highlight";
|
|
3
|
+
import { buildParser as Q } from "@lezer/generator";
|
|
4
|
+
import { Facet as T, StateEffect as k, StateField as q } from "@codemirror/state";
|
|
5
|
+
const j = Q(`
|
|
6
6
|
@top QueryList { Query }
|
|
7
7
|
@skip { "
|
|
8
8
|
" | Comment }
|
|
@@ -11,12 +11,11 @@ Query {
|
|
|
11
11
|
anyCondition ((" " | " ")+ anyCondition)*
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
anyCondition { Condition | ExcludeCondition
|
|
14
|
+
anyCondition { Condition | ExcludeCondition }
|
|
15
15
|
Condition { Field ":" Predicate }
|
|
16
16
|
ExcludeCondition { "-" Field ":" Predicate }
|
|
17
|
-
IgnoredCondition { "!" Field ":" Predicate }
|
|
18
17
|
|
|
19
|
-
Predicate {
|
|
18
|
+
Predicate { Value | Command }
|
|
20
19
|
Command { Identifier "(" Argument ("," Argument)* ")" }
|
|
21
20
|
Argument { Identifier | Number | String }
|
|
22
21
|
Value { Identifier | Number | String }
|
|
@@ -24,149 +23,140 @@ Value { Identifier | Number | String }
|
|
|
24
23
|
@tokens {
|
|
25
24
|
":"
|
|
26
25
|
Field { Identifier }
|
|
27
|
-
Function { Identifier }
|
|
28
26
|
Identifier { $[a-zA-Z_]+ ("." $[a-zA-Z_]+)* }
|
|
29
27
|
Number { std.digit+ }
|
|
30
28
|
String { '"' !["]* '"' }
|
|
31
|
-
Regex { RegexContent (RegexFlag)* }
|
|
32
|
-
RegexFlag { std.asciiLetter+ }
|
|
33
|
-
RegexContent { "/" (![/] | "\\/")* "/" }
|
|
34
29
|
Comment { "#" (![
|
|
35
30
|
])* }
|
|
36
31
|
}
|
|
37
|
-
`),
|
|
38
|
-
Condition:
|
|
39
|
-
Field:
|
|
40
|
-
Command:
|
|
41
|
-
Predicate:
|
|
42
|
-
Value:
|
|
43
|
-
Operator:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return i.parent;
|
|
50
|
-
i = i.parent;
|
|
32
|
+
`), n = {
|
|
33
|
+
Condition: m.define(i.keyword),
|
|
34
|
+
Field: m.define(i.propertyName),
|
|
35
|
+
Command: i.function(i.variableName),
|
|
36
|
+
Predicate: m.define(i.variableName),
|
|
37
|
+
Value: m.define(i.attributeValue),
|
|
38
|
+
Operator: m.define(i.operator)
|
|
39
|
+
}, B = T.define(), H = (e, o) => {
|
|
40
|
+
for (; o.parent; ) {
|
|
41
|
+
if (o.parent.name === e)
|
|
42
|
+
return o.parent;
|
|
43
|
+
o = o.parent;
|
|
51
44
|
}
|
|
52
45
|
return null;
|
|
53
46
|
};
|
|
54
|
-
async function
|
|
55
|
-
let
|
|
56
|
-
for (const
|
|
57
|
-
const a =
|
|
58
|
-
if (a?.type !== "relationship" || !a.
|
|
47
|
+
async function $(e, o, t) {
|
|
48
|
+
let r = o;
|
|
49
|
+
for (const s of e) {
|
|
50
|
+
const a = r.fields[s];
|
|
51
|
+
if (a?.type !== "relationship" || !a.schema)
|
|
59
52
|
return null;
|
|
60
|
-
|
|
53
|
+
r = await t.get(a.schema);
|
|
61
54
|
}
|
|
62
|
-
return
|
|
55
|
+
return r;
|
|
63
56
|
}
|
|
64
|
-
const
|
|
65
|
-
create: () => ({ fields:
|
|
66
|
-
update: (e,
|
|
67
|
-
for (const
|
|
68
|
-
if (
|
|
69
|
-
return
|
|
57
|
+
const z = k.define(), Z = q.define({
|
|
58
|
+
create: () => ({ fields: {} }),
|
|
59
|
+
update: (e, o) => {
|
|
60
|
+
for (const t of o.effects)
|
|
61
|
+
if (t.is(z))
|
|
62
|
+
return t.value;
|
|
70
63
|
return e;
|
|
71
64
|
}
|
|
72
|
-
}),
|
|
65
|
+
}), _ = b.data.of({
|
|
73
66
|
autocomplete: async (e) => {
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
76
|
-
const a =
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
const
|
|
81
|
-
label:
|
|
67
|
+
const t = P(e.state).resolveInner(e.pos, -1), r = e.state.sliceDoc(t.from, e.pos), s = /[\w.]*$/.exec(r);
|
|
68
|
+
if (!s && !e.explicit) return null;
|
|
69
|
+
const a = s ? t.from + s.index : e.pos, l = e.state.field(Z, !1), h = e.state.facet(B)[0]?.schemaCache, C = H("Condition", t), u = C?.getChild("Field"), y = C?.getChild(":");
|
|
70
|
+
if (u && y && e.pos > y.to) {
|
|
71
|
+
const p = e.state.doc.sliceString(u.from, u.to), d = l?.fields[p]?.values;
|
|
72
|
+
if (d?.length) {
|
|
73
|
+
const g = d.map((c) => ({
|
|
74
|
+
label: c,
|
|
82
75
|
type: "value"
|
|
83
76
|
}));
|
|
84
77
|
return {
|
|
85
78
|
from: a,
|
|
86
|
-
options:
|
|
79
|
+
options: g
|
|
87
80
|
};
|
|
88
81
|
}
|
|
89
82
|
}
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
const
|
|
94
|
-
|
|
83
|
+
if (t.name === "Field" && l && Object.keys(l.fields).length) {
|
|
84
|
+
const p = e.state.doc.sliceString(t.from, e.pos), d = p.split(".");
|
|
85
|
+
if (d.length > 1 && h) {
|
|
86
|
+
const c = d.slice(0, -1), f = t.from + p.lastIndexOf(".") + 1, F = await $(
|
|
87
|
+
c,
|
|
95
88
|
l,
|
|
96
|
-
|
|
89
|
+
h
|
|
97
90
|
);
|
|
98
|
-
if (
|
|
99
|
-
const
|
|
100
|
-
label:
|
|
101
|
-
type:
|
|
102
|
-
info:
|
|
91
|
+
if (F) {
|
|
92
|
+
const v = Object.entries(F.fields).map(([N, S]) => ({
|
|
93
|
+
label: N,
|
|
94
|
+
type: S.type,
|
|
95
|
+
info: S.info
|
|
103
96
|
}));
|
|
104
97
|
return {
|
|
105
|
-
from:
|
|
106
|
-
options:
|
|
98
|
+
from: f,
|
|
99
|
+
options: v
|
|
107
100
|
};
|
|
108
101
|
}
|
|
109
102
|
return {
|
|
110
|
-
from:
|
|
103
|
+
from: f,
|
|
111
104
|
options: []
|
|
112
105
|
};
|
|
113
106
|
}
|
|
114
|
-
const
|
|
115
|
-
label:
|
|
116
|
-
type:
|
|
117
|
-
info:
|
|
107
|
+
const g = Object.entries(l.fields).map(([c, f]) => ({
|
|
108
|
+
label: c,
|
|
109
|
+
type: f.type,
|
|
110
|
+
info: f.info
|
|
118
111
|
}));
|
|
119
112
|
return {
|
|
120
113
|
from: a,
|
|
121
|
-
options:
|
|
114
|
+
options: g
|
|
122
115
|
};
|
|
123
116
|
}
|
|
124
|
-
return
|
|
117
|
+
return t.name === "Field" ? {
|
|
125
118
|
from: a,
|
|
126
119
|
options: []
|
|
127
120
|
} : null;
|
|
128
121
|
}
|
|
129
|
-
}),
|
|
130
|
-
{ tag:
|
|
131
|
-
{ tag:
|
|
132
|
-
{ tag:
|
|
133
|
-
{ tag:
|
|
134
|
-
{ tag:
|
|
135
|
-
{ tag:
|
|
136
|
-
{ tag:
|
|
137
|
-
|
|
138
|
-
]), _ = T.configure({
|
|
122
|
+
}), M = A.define([
|
|
123
|
+
{ tag: n.Condition, class: "cnd" },
|
|
124
|
+
{ tag: n.Operator, class: "cnd-op" },
|
|
125
|
+
{ tag: n.Value, class: "cnd-val" },
|
|
126
|
+
{ tag: n.Command, class: "cnd-val cnd-cmd" },
|
|
127
|
+
{ tag: n.Field, class: "cnd-fld" },
|
|
128
|
+
{ tag: i.string, class: "string" },
|
|
129
|
+
{ tag: i.lineComment, class: "comment" }
|
|
130
|
+
]), R = j.configure({
|
|
139
131
|
props: [
|
|
140
|
-
|
|
141
|
-
"Condition/:":
|
|
142
|
-
"ExcludeCondition/:":
|
|
143
|
-
"Condition/Field/...":
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
Field: t.Field,
|
|
150
|
-
"Value!": t.Value
|
|
132
|
+
L({
|
|
133
|
+
"Condition/:": n.Operator,
|
|
134
|
+
"ExcludeCondition/:": n.Operator,
|
|
135
|
+
"Condition/Field/...": n.Field,
|
|
136
|
+
"Command!": n.Command,
|
|
137
|
+
"Separator!": n.Operator,
|
|
138
|
+
Comment: i.lineComment,
|
|
139
|
+
Field: n.Field,
|
|
140
|
+
"Value!": n.Value
|
|
151
141
|
}),
|
|
152
|
-
|
|
142
|
+
I.add({
|
|
153
143
|
Query: (e) => e.column(e.node.from) + e.unit
|
|
154
144
|
}),
|
|
155
|
-
|
|
156
|
-
Query:
|
|
145
|
+
V.add({
|
|
146
|
+
Query: w
|
|
157
147
|
})
|
|
158
148
|
]
|
|
159
|
-
}),
|
|
160
|
-
parser:
|
|
149
|
+
}), b = O.define({
|
|
150
|
+
parser: R,
|
|
161
151
|
languageData: {}
|
|
162
152
|
});
|
|
163
|
-
function
|
|
164
|
-
return new
|
|
165
|
-
|
|
166
|
-
|
|
153
|
+
function U() {
|
|
154
|
+
return new E(b, [
|
|
155
|
+
D(M),
|
|
156
|
+
_
|
|
167
157
|
]);
|
|
168
158
|
}
|
|
169
159
|
export {
|
|
170
|
-
|
|
171
|
-
|
|
160
|
+
U as DequelLang,
|
|
161
|
+
b as dequelParser
|
|
172
162
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dequel-editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "CodeMirror-based editor for Dequel query language",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/dequel-editor.js",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"@lezer/common": "^1.5.0",
|
|
41
41
|
"@lezer/generator": "^1.8.0",
|
|
42
42
|
"@lezer/highlight": "^1.2.3",
|
|
43
|
-
"@preact/preset-vite": "^2.10.3",
|
|
44
|
-
"@tailwindcss/vite": "^4.1.18",
|
|
45
43
|
"axios": "^1.13.4",
|
|
46
44
|
"preact": "^10.28.3"
|
|
47
45
|
},
|
|
48
46
|
"devDependencies": {
|
|
49
47
|
"@open-wc/testing": "^4.0.0",
|
|
48
|
+
"@preact/preset-vite": "^2.10.3",
|
|
50
49
|
"@remcovaes/web-test-runner-vite-plugin": "^1.4.0",
|
|
50
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
51
51
|
"@types/node": "^20.19.31",
|
|
52
52
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
53
53
|
"@typescript-eslint/parser": "^7.18.0",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"eslint": "^8.57.1",
|
|
58
58
|
"gettext-parser": "^8.0.0",
|
|
59
59
|
"http-proxy-middleware": "^3.0.5",
|
|
60
|
+
"jsdom": "^28.1.0",
|
|
60
61
|
"tailwindcss": "^4.1.18",
|
|
61
62
|
"tsx": "^4.19.4",
|
|
62
63
|
"typescript": "^5.9.3",
|