@agentix-e/spel-editor 0.1.0 → 1.0.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/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/dist/index.js +55 -68
- package/package.json +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.1.1] - 2026-07-14
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Remove unused imports across source files
|
|
9
|
+
- Add `.prettierrc` configuration for consistent formatting
|
|
10
|
+
- Tighten `tsconfig.json` strictness checks
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Playwright browser integration tests (`test:browser` / `test:browser:ui`)
|
|
14
|
+
- nl2spel integration tests with DeepSeek provider
|
|
15
|
+
- `DEEPSEEK_API_KEY` secret handling for integration tests
|
|
16
|
+
|
|
5
17
|
## [0.1.0] - 2026-07-12
|
|
6
18
|
|
|
7
19
|
### Added
|
|
@@ -16,4 +28,5 @@ All notable changes to this project will be documented in this file.
|
|
|
16
28
|
- `change` event with `value` and `isValid` detail
|
|
17
29
|
- Framework-agnostic — works with React, Vue, Angular, Svelte, or plain HTML
|
|
18
30
|
|
|
31
|
+
[0.1.1]: https://github.com/AgentiX-E/spel-editor/releases/tag/v0.1.1
|
|
19
32
|
[0.1.0]: https://github.com/AgentiX-E/spel-editor/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Web-embeddable Spring Expression Language (SpEL) editor.
|
|
4
4
|
> Based on CodeMirror 6 + spel-ts v1.1.0. Framework-agnostic Web Component.
|
|
5
5
|
|
|
6
|
-
[](https://www.npmjs.com/package/@agentix-e/spel-editor)
|
|
7
7
|
|
|
8
8
|
## Quick Start
|
|
9
9
|
|
package/dist/index.js
CHANGED
|
@@ -20,11 +20,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
20
20
|
// src/spel-editor.ts
|
|
21
21
|
import { LitElement, html, css } from "lit";
|
|
22
22
|
import { customElement, property, query } from "lit/decorators.js";
|
|
23
|
-
import {
|
|
24
|
-
EditorView,
|
|
25
|
-
keymap,
|
|
26
|
-
placeholder as cmPlaceholder
|
|
27
|
-
} from "@codemirror/view";
|
|
23
|
+
import { EditorView, keymap, placeholder as cmPlaceholder } from "@codemirror/view";
|
|
28
24
|
import { EditorState } from "@codemirror/state";
|
|
29
25
|
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
|
30
26
|
import { closeBrackets, autocompletion } from "@codemirror/autocomplete";
|
|
@@ -117,64 +113,66 @@ function tokenKindToStyle(kind) {
|
|
|
117
113
|
}
|
|
118
114
|
}
|
|
119
115
|
function createSpelStreamParser() {
|
|
116
|
+
return StreamLanguage.define(createTokenParser());
|
|
117
|
+
}
|
|
118
|
+
function createTokenParser() {
|
|
120
119
|
let _tokenizer = null;
|
|
121
120
|
let _tokens = [];
|
|
122
121
|
let _tokenIndex = 0;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
} catch {
|
|
132
|
-
_tokens = [];
|
|
133
|
-
_tokenIndex = 0;
|
|
134
|
-
stream.skipToEnd();
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
122
|
+
const startState = () => null;
|
|
123
|
+
const token = (stream) => {
|
|
124
|
+
if (!_tokenizer || _tokenIndex === 0) {
|
|
125
|
+
_tokenizer = new SpelTokenizer(stream.string);
|
|
126
|
+
let rawTokens;
|
|
127
|
+
try {
|
|
128
|
+
rawTokens = _tokenizer.tokenize();
|
|
129
|
+
} catch {
|
|
137
130
|
_tokens = [];
|
|
138
131
|
_tokenIndex = 0;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
132
|
+
stream.skipToEnd();
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
_tokens = [];
|
|
136
|
+
_tokenIndex = 0;
|
|
137
|
+
for (let i = 0; i < rawTokens.length - 1; i++) {
|
|
138
|
+
const tok = rawTokens[i];
|
|
139
|
+
const style = tokenKindToStyle(tok.kind);
|
|
140
|
+
if (tok.kind === TokenKind.IDENTIFIER) {
|
|
141
|
+
const prevTok = i > 0 ? rawTokens[i - 1] : null;
|
|
142
|
+
if (prevTok?.kind === TokenKind.HASH) {
|
|
143
|
+
_tokens.push({
|
|
144
|
+
from: tok.startPos,
|
|
145
|
+
to: tok.endPos,
|
|
146
|
+
style: "variableName"
|
|
147
|
+
});
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (prevTok?.kind === TokenKind.DOT || prevTok?.kind === TokenKind.SAFE_NAV) {
|
|
151
|
+
_tokens.push({
|
|
152
|
+
from: tok.startPos,
|
|
153
|
+
to: tok.endPos,
|
|
154
|
+
style: "propertyName"
|
|
155
|
+
});
|
|
156
|
+
continue;
|
|
160
157
|
}
|
|
161
|
-
_tokens.push({ from: tok.startPos, to: tok.endPos, style });
|
|
162
158
|
}
|
|
159
|
+
_tokens.push({ from: tok.startPos, to: tok.endPos, style });
|
|
163
160
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return t.style || null;
|
|
170
|
-
}
|
|
161
|
+
}
|
|
162
|
+
while (_tokenIndex < _tokens.length) {
|
|
163
|
+
const t = _tokens[_tokenIndex];
|
|
164
|
+
if (t.from >= stream.pos) {
|
|
165
|
+
stream.pos = t.to;
|
|
171
166
|
_tokenIndex++;
|
|
167
|
+
return t.style || null;
|
|
172
168
|
}
|
|
173
|
-
|
|
174
|
-
_tokenIndex = 0;
|
|
175
|
-
return null;
|
|
169
|
+
_tokenIndex++;
|
|
176
170
|
}
|
|
177
|
-
|
|
171
|
+
stream.skipToEnd();
|
|
172
|
+
_tokenIndex = 0;
|
|
173
|
+
return null;
|
|
174
|
+
};
|
|
175
|
+
return { startState, token };
|
|
178
176
|
}
|
|
179
177
|
|
|
180
178
|
// src/cm6/spel-language.ts
|
|
@@ -184,19 +182,13 @@ function spelLanguage() {
|
|
|
184
182
|
|
|
185
183
|
// src/cm6/completion-source.ts
|
|
186
184
|
import "@codemirror/autocomplete";
|
|
187
|
-
import {
|
|
188
|
-
SpelCompletionEngine
|
|
189
|
-
} from "@agentix-e/spel-ts";
|
|
185
|
+
import { SpelCompletionEngine } from "@agentix-e/spel-ts";
|
|
190
186
|
function spelCompletion(getContextSchema) {
|
|
191
187
|
return (context) => {
|
|
192
188
|
const expression = context.state.sliceDoc();
|
|
193
189
|
const position = context.pos;
|
|
194
190
|
const schema = getContextSchema?.() ?? void 0;
|
|
195
|
-
const items = SpelCompletionEngine.getCompletions(
|
|
196
|
-
expression,
|
|
197
|
-
position,
|
|
198
|
-
schema
|
|
199
|
-
);
|
|
191
|
+
const items = SpelCompletionEngine.getCompletions(expression, position, schema);
|
|
200
192
|
const validFor = /\w*/;
|
|
201
193
|
return {
|
|
202
194
|
from: context.matchBefore(validFor)?.from ?? position,
|
|
@@ -336,7 +328,7 @@ var EDITOR_STYLES = css`
|
|
|
336
328
|
}
|
|
337
329
|
.cm-editor {
|
|
338
330
|
height: 100%;
|
|
339
|
-
font-family: var(--spel-font-family,
|
|
331
|
+
font-family: var(--spel-font-family, 'JetBrains Mono', monospace);
|
|
340
332
|
font-size: var(--spel-font-size, 14px);
|
|
341
333
|
line-height: var(--spel-line-height, 1.6);
|
|
342
334
|
}
|
|
@@ -525,10 +517,7 @@ runDiagnostics_fn = function() {
|
|
|
525
517
|
__privateSet(this, _diagnosticCache, []);
|
|
526
518
|
return;
|
|
527
519
|
}
|
|
528
|
-
__privateSet(this, _diagnosticCache, SpelDiagnosticEngine2.validate(
|
|
529
|
-
expr,
|
|
530
|
-
this.contextSchema ?? void 0
|
|
531
|
-
));
|
|
520
|
+
__privateSet(this, _diagnosticCache, SpelDiagnosticEngine2.validate(expr, this.contextSchema ?? void 0));
|
|
532
521
|
this.dispatchEvent(
|
|
533
522
|
new CustomEvent("validate", {
|
|
534
523
|
detail: { diagnostics: __privateGet(this, _diagnosticCache) },
|
|
@@ -576,9 +565,7 @@ fireChange_fn = function() {
|
|
|
576
565
|
value: this.value,
|
|
577
566
|
isValid: syntaxDiags.length === 0
|
|
578
567
|
};
|
|
579
|
-
this.dispatchEvent(
|
|
580
|
-
new CustomEvent("change", { detail, bubbles: true, composed: true })
|
|
581
|
-
);
|
|
568
|
+
this.dispatchEvent(new CustomEvent("change", { detail, bubbles: true, composed: true }));
|
|
582
569
|
};
|
|
583
570
|
SpelEditor.styles = EDITOR_STYLES;
|
|
584
571
|
__decorateClass([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentix-e/spel-editor",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Web-embeddable Spring Expression Language (SpEL) editor — CodeMirror 6 + spel-ts powered",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
22
22
|
"test": "vitest run --coverage",
|
|
23
|
+
"test:browser": "playwright test",
|
|
24
|
+
"test:browser:ui": "playwright test --ui",
|
|
25
|
+
"test:all": "pnpm test && pnpm test:browser",
|
|
23
26
|
"test:watch": "vitest",
|
|
24
27
|
"typecheck": "tsc --noEmit",
|
|
25
28
|
"format": "prettier --write 'src/**/*.ts' 'tests/**/*.ts'",
|
|
@@ -49,11 +52,15 @@
|
|
|
49
52
|
}
|
|
50
53
|
},
|
|
51
54
|
"devDependencies": {
|
|
55
|
+
"@agentix-e/nl2spel": "^1.1.2",
|
|
56
|
+
"@agentix-e/nl2spel-openai": "^1.1.2",
|
|
57
|
+
"@playwright/test": "^1.61.1",
|
|
52
58
|
"@vitest/coverage-v8": "^3.0.0",
|
|
53
59
|
"jsdom": "^29.1.1",
|
|
54
60
|
"prettier": "^3.9.5",
|
|
55
61
|
"tsup": "^8.0.0",
|
|
56
62
|
"typescript": "^5.8.3",
|
|
63
|
+
"vite": "^8.1.4",
|
|
57
64
|
"vitest": "^3.0.0"
|
|
58
65
|
},
|
|
59
66
|
"keywords": [
|
|
@@ -75,6 +82,9 @@
|
|
|
75
82
|
"url": "https://github.com/AgentiX-E/spel-editor/issues"
|
|
76
83
|
},
|
|
77
84
|
"homepage": "https://github.com/AgentiX-E/spel-editor#readme",
|
|
85
|
+
"pnpm": {
|
|
86
|
+
"onlyBuiltDependencies": ["esbuild"]
|
|
87
|
+
},
|
|
78
88
|
"publishConfig": {
|
|
79
89
|
"access": "public"
|
|
80
90
|
}
|