@seljs/editor 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.
Files changed (54) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +190 -0
  3. package/dist/completion/completion-items.d.ts +8 -0
  4. package/dist/completion/completion-items.d.ts.map +1 -0
  5. package/dist/completion/completion-items.js +29 -0
  6. package/dist/completion/index.d.ts +2 -0
  7. package/dist/completion/index.d.ts.map +1 -0
  8. package/dist/completion/index.js +1 -0
  9. package/dist/completion/schema-completion.d.ts +22 -0
  10. package/dist/completion/schema-completion.d.ts.map +1 -0
  11. package/dist/completion/schema-completion.js +220 -0
  12. package/dist/completion/tree-context.d.ts +23 -0
  13. package/dist/completion/tree-context.d.ts.map +1 -0
  14. package/dist/completion/tree-context.js +154 -0
  15. package/dist/editor/create-editor.d.ts +4 -0
  16. package/dist/editor/create-editor.d.ts.map +1 -0
  17. package/dist/editor/create-editor.js +14 -0
  18. package/dist/editor/editor-config.d.ts +4 -0
  19. package/dist/editor/editor-config.d.ts.map +1 -0
  20. package/dist/editor/editor-config.js +64 -0
  21. package/dist/editor/index.d.ts +6 -0
  22. package/dist/editor/index.d.ts.map +1 -0
  23. package/dist/editor/index.js +3 -0
  24. package/dist/editor/theme.d.ts +3 -0
  25. package/dist/editor/theme.d.ts.map +1 -0
  26. package/dist/editor/theme.js +43 -0
  27. package/dist/editor/type-display.d.ts +4 -0
  28. package/dist/editor/type-display.d.ts.map +1 -0
  29. package/dist/editor/type-display.js +75 -0
  30. package/dist/editor/types.d.ts +28 -0
  31. package/dist/editor/types.d.ts.map +1 -0
  32. package/dist/editor/types.js +1 -0
  33. package/dist/index.d.ts +5 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +4 -0
  36. package/dist/language/index.d.ts +2 -0
  37. package/dist/language/index.d.ts.map +1 -0
  38. package/dist/language/index.js +1 -0
  39. package/dist/language/semantic-highlighter.d.ts +4 -0
  40. package/dist/language/semantic-highlighter.d.ts.map +1 -0
  41. package/dist/language/semantic-highlighter.js +76 -0
  42. package/dist/language/tokenizer-config.d.ts +9 -0
  43. package/dist/language/tokenizer-config.d.ts.map +1 -0
  44. package/dist/language/tokenizer-config.js +6 -0
  45. package/dist/linting/diagnostic-mapper.d.ts +28 -0
  46. package/dist/linting/diagnostic-mapper.d.ts.map +1 -0
  47. package/dist/linting/diagnostic-mapper.js +46 -0
  48. package/dist/linting/index.d.ts +3 -0
  49. package/dist/linting/index.d.ts.map +1 -0
  50. package/dist/linting/index.js +2 -0
  51. package/dist/linting/sel-linter.d.ts +12 -0
  52. package/dist/linting/sel-linter.d.ts.map +1 -0
  53. package/dist/linting/sel-linter.js +28 -0
  54. package/package.json +71 -0
@@ -0,0 +1,3 @@
1
+ export { createSELLinter, type SELLinterOptions } from "./sel-linter";
2
+ export { mapCheckResult, type SELDiagnostic } from "./diagnostic-mapper";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/linting/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { createSELLinter } from "./sel-linter";
2
+ export { mapCheckResult } from "./diagnostic-mapper";
@@ -0,0 +1,12 @@
1
+ import type { SELDiagnostic } from "./diagnostic-mapper";
2
+ import type { Extension } from "@codemirror/state";
3
+ interface SELLinterOptions {
4
+ /** Validate an expression, return diagnostics */
5
+ validate: (expression: string) => SELDiagnostic[] | Promise<SELDiagnostic[]>;
6
+ /** Debounce delay in ms (default: 300) */
7
+ delay?: number;
8
+ }
9
+ declare function createSELLinter(options: SELLinterOptions): Extension;
10
+ export { createSELLinter };
11
+ export type { SELLinterOptions };
12
+ //# sourceMappingURL=sel-linter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sel-linter.d.ts","sourceRoot":"","sources":["../../src/linting/sel-linter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,UAAU,gBAAgB;IACzB,iDAAiD;IACjD,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAE7E,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAqBD,iBAAS,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAe7D;AAED,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { linter } from "@codemirror/lint";
2
+ const SEVERITY_MAP = {
3
+ error: "error",
4
+ warning: "warning",
5
+ info: "info",
6
+ };
7
+ function mapToCMDiagnostic(diag, docLength) {
8
+ const from = diag.from ?? 0;
9
+ const to = diag.to ?? docLength;
10
+ return {
11
+ from: Math.max(0, Math.min(from, docLength)),
12
+ to: Math.max(0, Math.min(to, docLength)),
13
+ severity: SEVERITY_MAP[diag.severity],
14
+ message: diag.message,
15
+ };
16
+ }
17
+ function createSELLinter(options) {
18
+ return linter(async (view) => {
19
+ const doc = view.state.doc.toString();
20
+ if (!doc) {
21
+ return [];
22
+ }
23
+ const diagnostics = await options.validate(doc);
24
+ const docLength = doc.length;
25
+ return diagnostics.map((d) => mapToCMDiagnostic(d, docLength));
26
+ }, { delay: options.delay ?? 300 });
27
+ }
28
+ export { createSELLinter };
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@seljs/editor",
3
+ "version": "1.0.0",
4
+ "license": "Apache-2.0",
5
+ "author": {
6
+ "name": "abi group GmbH",
7
+ "email": "info@abigroup.io",
8
+ "url": "https://abigroup.io/"
9
+ },
10
+ "repository": {
11
+ "url": "https://github.com/abinnovision/seljs"
12
+ },
13
+ "type": "module",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/index.js",
17
+ "types": "./dist/index.d.ts"
18
+ }
19
+ },
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "dist",
24
+ "LICENSE.md"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsc -p tsconfig.build.json",
28
+ "format:check": "prettier --check '{{src,test}/**/*,*}.{{t,j}s{,x},json{,5},md,y{,a}ml}'",
29
+ "format:fix": "prettier --write '{{src,test}/**/*,*}.{{t,j}s{,x},json{,5},md,y{,a}ml}'",
30
+ "lint:check": "eslint '{{src,test}/**/*,*}.{t,j}s{,x}'",
31
+ "lint:fix": "eslint '{{src,test}/**/*,*}.{t,j}s{,x}' --fix",
32
+ "test-unit": "vitest run",
33
+ "test-unit:watch": "vitest watch",
34
+ "typecheck": "tsc --noEmit"
35
+ },
36
+ "dependencies": {
37
+ "@codemirror/autocomplete": "^6.20.1",
38
+ "@codemirror/commands": "^6.0.0",
39
+ "@codemirror/language": "^6.0.0",
40
+ "@codemirror/lint": "^6.9.5",
41
+ "@codemirror/state": "^6.0.0",
42
+ "@codemirror/view": "^6.0.0",
43
+ "@lezer/common": "^1.5.1",
44
+ "@lezer/highlight": "^1.0.0",
45
+ "@seljs/cel-lezer": "1.0.0",
46
+ "@seljs/checker": "1.0.0",
47
+ "@seljs/schema": "1.0.0"
48
+ },
49
+ "lint-staged": {
50
+ "{{src,test}/**/*,*}.{{t,j}s{,x},json{,5},md,y{,a}ml}": [
51
+ "prettier --write"
52
+ ],
53
+ "{{src,test}/**/*,*}.{t,j}s{,x}": [
54
+ "eslint --fix"
55
+ ]
56
+ },
57
+ "devDependencies": {
58
+ "@abinnovision/eslint-config-base": "^3.2.0",
59
+ "@abinnovision/prettier-config": "^2.1.5",
60
+ "@seljs-internal/tsconfig": "^0.0.0",
61
+ "eslint": "^9.39.4",
62
+ "jsdom": "^28.1.0",
63
+ "prettier": "^3.8.1",
64
+ "typescript": "^5.9.3",
65
+ "vitest": "^4.0.18"
66
+ },
67
+ "publishConfig": {
68
+ "npm": true,
69
+ "npmAccess": "public"
70
+ }
71
+ }