@bpmn-io/lang-feel 2.4.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2022-current Nico Rehwaldt <https://github.com/nikku>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @bpmn-io/lang-feel
2
+
3
+ [![CI](https://github.com/bpmn-io/lang-feel/actions/workflows/CI.yml/badge.svg)](https://github.com/bpmn-io/lang-feel/actions/workflows/CI.yml)
4
+
5
+ > NOTE: This is a fork of [nikku/lezer-feel](https://github.com/nikku/lezer-feel)
6
+
7
+ This package implements the [DMN](https://www.omg.org/spec/DMN/) FEEL language support for the [CodeMirror code editor](https://codemirror.net/).
8
+
9
+
10
+ ## Related
11
+
12
+ * [@bpmn-io/lezer-feel](https://github.com/bpmn-io/lezer-feel) - FEEL grammar
13
+ * [@bpmn-io/feelin](https://github.com/bpmn-io/feelin) - FEEL parser + interpreter
14
+
15
+
16
+ ## License
17
+
18
+ MIT
@@ -0,0 +1,22 @@
1
+ import { SyntaxNode } from '@lezer/common';
2
+ import { CompletionSource, Completion } from '@codemirror/autocomplete';
3
+ export declare function contextualKeyword(options: {
4
+ before?: string;
5
+ after?: string;
6
+ context: string;
7
+ keyword: string;
8
+ }): CompletionSource;
9
+ export declare const keywordCompletions: CompletionSource[];
10
+ export declare const dontComplete: string[];
11
+ export declare const doComplete: string[];
12
+ export declare function ifExpression(completionSource: CompletionSource): CompletionSource;
13
+ export declare function snippetCompletion(snippets: readonly Completion[]): CompletionSource;
14
+ export declare function matchLeft(node: SyntaxNode, position: number, nodes: (string | undefined)[]): SyntaxNode | null;
15
+ export declare function matchRight(node: SyntaxNode, position: number, nodes: (string | undefined)[]): SyntaxNode | null;
16
+ export declare function matchChildren(node: SyntaxNode, position: number, nodes: (string | undefined)[], direction: 1 | -1): SyntaxNode | null;
17
+ export declare function ifInside(options: {
18
+ nodes: string | string[];
19
+ keyword: string;
20
+ before?: string;
21
+ after?: string;
22
+ }, source: CompletionSource): CompletionSource;
package/dist/feel.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { LRLanguage, LanguageSupport } from '@codemirror/language';
2
+ import { CompletionSource } from '@codemirror/autocomplete';
3
+ /**
4
+ * A FEEL language provider based on the
5
+ * [Lezer FEEL parser](https://github.com/nikku/lezer-feel),
6
+ * extended with highlighting and indentation information.
7
+ */
8
+ export declare const feelLanguage: LRLanguage;
9
+ /**
10
+ * A language provider for FEEL Unary Tests
11
+ */
12
+ export declare const unaryTestsLanguage: LRLanguage;
13
+ /**
14
+ * Language provider for FEEL Expression
15
+ */
16
+ export declare const expressionLanguage: LRLanguage;
17
+ /**
18
+ * Feel language support for CodeMirror.
19
+ *
20
+ * Includes [snippet](#lang-feel.snippets)
21
+ */
22
+ export declare function feel(config?: {
23
+ dialect?: 'expression' | 'unaryTests';
24
+ parserDialect?: string;
25
+ completions?: CompletionSource[];
26
+ context?: Record<string, any>;
27
+ }): LanguageSupport;
package/dist/index.cjs ADDED
@@ -0,0 +1,270 @@
1
+ var lezerFeel = require('@bpmn-io/lezer-feel');
2
+ var language = require('@codemirror/language');
3
+ var autocomplete = require('@codemirror/autocomplete');
4
+
5
+ /**
6
+ * A collection of FEEL-related [snippets](#autocomplete.snippet).
7
+ */
8
+ const snippets = [autocomplete.snippetCompletion('function(${params}) ${body}', {
9
+ label: 'function',
10
+ detail: 'definition',
11
+ type: 'keyword'
12
+ }), autocomplete.snippetCompletion('for ${var} in ${collection} return ${value}', {
13
+ label: 'for',
14
+ detail: 'expression',
15
+ type: 'keyword'
16
+ }), autocomplete.snippetCompletion('every ${var} in ${collection} satisfies ${condition}', {
17
+ label: 'every',
18
+ detail: 'quantified expression',
19
+ type: 'keyword'
20
+ }), autocomplete.snippetCompletion('some ${var} in ${collection} satisfies ${condition}', {
21
+ label: 'some',
22
+ detail: 'quantified expression',
23
+ type: 'keyword'
24
+ }), autocomplete.snippetCompletion('if ${condition} then ${value} else ${other value}', {
25
+ label: 'if',
26
+ detail: 'block',
27
+ type: 'keyword'
28
+ }), autocomplete.snippetCompletion('{ ${key}: ${value} }', {
29
+ label: 'context',
30
+ detail: 'block',
31
+ type: 'keyword'
32
+ }), autocomplete.snippetCompletion('null', {
33
+ label: 'null',
34
+ detail: 'literal',
35
+ type: 'keyword'
36
+ }), autocomplete.snippetCompletion('true', {
37
+ label: 'true',
38
+ detail: 'literal',
39
+ type: 'keyword'
40
+ }), autocomplete.snippetCompletion('false', {
41
+ label: 'false',
42
+ detail: 'literal',
43
+ type: 'keyword'
44
+ })];
45
+
46
+ function contextualKeyword(options) {
47
+ const {
48
+ context: nodes,
49
+ after,
50
+ before,
51
+ keyword
52
+ } = options;
53
+ return ifInside({
54
+ nodes,
55
+ before,
56
+ after,
57
+ keyword
58
+ }, autocomplete.completeFromList([{
59
+ label: keyword,
60
+ type: 'keyword',
61
+ boost: 10
62
+ }]));
63
+ }
64
+ const keywordCompletions = [contextualKeyword({
65
+ context: 'InExpression',
66
+ keyword: 'in'
67
+ }), contextualKeyword({
68
+ context: 'IfExpression',
69
+ keyword: 'then',
70
+ after: 'if',
71
+ before: 'else'
72
+ }), contextualKeyword({
73
+ context: 'IfExpression',
74
+ keyword: 'else',
75
+ after: 'then'
76
+ }), contextualKeyword({
77
+ context: 'QuantifiedExpression',
78
+ keyword: 'satisfies'
79
+ }), contextualKeyword({
80
+ context: 'ForExpression',
81
+ after: 'InExpressions',
82
+ keyword: 'return'
83
+ })];
84
+ const dontComplete = ['StringLiteral', 'Identifier', 'LineComment', 'BlockComment', 'PathExpression', 'Context', 'Key', 'ParameterName'];
85
+ const doComplete = ['Expr', 'ContextEntry'];
86
+ function ifExpression(completionSource) {
87
+ const allNodes = [...dontComplete, ...doComplete];
88
+ return context => {
89
+ const {
90
+ state,
91
+ pos
92
+ } = context;
93
+ const match = matchUp(language.syntaxTree(state).resolveInner(pos, -1), allNodes);
94
+ if (match) {
95
+ const [_, name] = match;
96
+ if (dontComplete.includes(name)) {
97
+ return null;
98
+ }
99
+ }
100
+ return completionSource(context);
101
+ };
102
+ }
103
+ function snippetCompletion(snippets) {
104
+ return ifExpression(autocomplete.completeFromList(snippets.map(s => ({
105
+ ...s,
106
+ type: 'text'
107
+ }))));
108
+ }
109
+ function matchLeft(node, position, nodes) {
110
+ return matchChildren(node, position, nodes, -1);
111
+ }
112
+ function matchRight(node, position, nodes) {
113
+ return matchChildren(node, position, nodes, 1);
114
+ }
115
+ function matchChildren(node, position, nodes, direction) {
116
+ let child = node[direction > 0 ? 'childAfter' : 'childBefore'](position);
117
+ while (child) {
118
+ if (nodes.includes(child.name)) {
119
+ return child;
120
+ }
121
+ if (child.type.isError && child.firstChild) {
122
+ if (nodes.includes(child.firstChild.name)) {
123
+ return child.firstChild;
124
+ }
125
+ }
126
+ child = child[direction > 0 ? 'nextSibling' : 'prevSibling'];
127
+ }
128
+ return null;
129
+ }
130
+ function matchUp(node, nodeNames) {
131
+ if (!Array.isArray(nodeNames)) {
132
+ nodeNames = [nodeNames];
133
+ }
134
+ for (; node; node = node.parent) {
135
+ const nodeType = node.type;
136
+ const matchedName = nodeNames.find(name => name && nodeType.is(name));
137
+ if (matchedName) {
138
+ return [node, matchedName];
139
+ }
140
+ if (nodeType.isTop) {
141
+ break;
142
+ }
143
+ }
144
+ return null;
145
+ }
146
+ function ifInside(options, source) {
147
+ const {
148
+ nodes,
149
+ before,
150
+ after,
151
+ keyword
152
+ } = options;
153
+ return context => {
154
+ const {
155
+ state,
156
+ pos
157
+ } = context;
158
+ const match = matchUp(language.syntaxTree(state).resolveInner(pos, -1), nodes);
159
+ if (!match) {
160
+ return null;
161
+ }
162
+ const [node] = match;
163
+ if (matchLeft(node, pos, [keyword, before])) {
164
+ return null;
165
+ }
166
+ if (matchRight(node, pos, [keyword, after])) {
167
+ return null;
168
+ }
169
+ if (after && !matchLeft(node, pos, [after])) {
170
+ return null;
171
+ }
172
+ return source(context);
173
+ };
174
+ }
175
+
176
+ /**
177
+ * A FEEL language provider based on the
178
+ * [Lezer FEEL parser](https://github.com/nikku/lezer-feel),
179
+ * extended with highlighting and indentation information.
180
+ */
181
+ const feelLanguage = language.LRLanguage.define({
182
+ parser: lezerFeel.parser.configure({
183
+ props: [language.indentNodeProp.add({
184
+ 'Context': language.delimitedIndent({
185
+ closing: '}'
186
+ }),
187
+ 'List FilterExpression': language.delimitedIndent({
188
+ closing: ']'
189
+ }),
190
+ 'ParenthesizedExpression FunctionInvocation': language.continuedIndent({
191
+ except: /^\s*\)/
192
+ }),
193
+ 'ForExpression QuantifiedExpression IfExpression': language.continuedIndent({
194
+ except: /^\s*(then|else|return|satisfies)\b/
195
+ }),
196
+ 'FunctionDefinition': language.continuedIndent({
197
+ except: /^\s*(\(|\))/
198
+ })
199
+ }), language.foldNodeProp.add({
200
+ Context: language.foldInside,
201
+ List: language.foldInside,
202
+ ParenthesizedExpression: language.foldInside,
203
+ FunctionDefinition(node) {
204
+ const last = node.getChild(')');
205
+ if (!last) return null;
206
+ return {
207
+ from: last.to,
208
+ to: node.to
209
+ };
210
+ }
211
+ })]
212
+ }),
213
+ languageData: {
214
+ indentOnInput: /^\s*(\)|\}|\]|then|else|return|satisfies)$/,
215
+ commentTokens: {
216
+ line: '//',
217
+ block: {
218
+ open: '/*',
219
+ close: '*/'
220
+ }
221
+ }
222
+ }
223
+ });
224
+ /**
225
+ * A language provider for FEEL Unary Tests
226
+ */
227
+ const unaryTestsLanguage = feelLanguage.configure({
228
+ top: 'UnaryTests'
229
+ }, 'FEEL unary tests');
230
+ /**
231
+ * Language provider for FEEL Expression
232
+ */
233
+ const expressionLanguage = feelLanguage.configure({
234
+ top: 'Expression'
235
+ }, 'FEEL expression');
236
+ /**
237
+ * Feel language support for CodeMirror.
238
+ *
239
+ * Includes [snippet](#lang-feel.snippets)
240
+ */
241
+ function feel(config = {}) {
242
+ const language$1 = config.dialect === 'unaryTests' ? unaryTestsLanguage : expressionLanguage;
243
+ const dialect = config.parserDialect;
244
+ const contextTracker = lezerFeel.trackVariables(config.context);
245
+ const contextualLang = language$1.configure({
246
+ contextTracker,
247
+ dialect
248
+ });
249
+ const completions = config.completions || [snippetCompletion(snippets), keywordCompletions].flat();
250
+ return new language.LanguageSupport(contextualLang, [...completions.map(autocomplete => contextualLang.data.of({
251
+ autocomplete
252
+ }))]);
253
+ }
254
+
255
+ exports.contextualKeyword = contextualKeyword;
256
+ exports.doComplete = doComplete;
257
+ exports.dontComplete = dontComplete;
258
+ exports.expressionLanguage = expressionLanguage;
259
+ exports.feel = feel;
260
+ exports.feelLanguage = feelLanguage;
261
+ exports.ifExpression = ifExpression;
262
+ exports.ifInside = ifInside;
263
+ exports.keywordCompletions = keywordCompletions;
264
+ exports.matchChildren = matchChildren;
265
+ exports.matchLeft = matchLeft;
266
+ exports.matchRight = matchRight;
267
+ exports.snippetCompletion = snippetCompletion;
268
+ exports.snippets = snippets;
269
+ exports.unaryTestsLanguage = unaryTestsLanguage;
270
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/snippets.ts","../src/completion.ts","../src/feel.ts"],"sourcesContent":["import { Completion, snippetCompletion } from '@codemirror/autocomplete';\n\n/**\n * A collection of FEEL-related [snippets](#autocomplete.snippet).\n */\nexport const snippets: readonly Completion[] = [\n snippetCompletion('function(${params}) ${body}', {\n label: 'function',\n detail: 'definition',\n type: 'keyword'\n }),\n snippetCompletion('for ${var} in ${collection} return ${value}', {\n label: 'for',\n detail: 'expression',\n type: 'keyword'\n }),\n snippetCompletion('every ${var} in ${collection} satisfies ${condition}', {\n label: 'every',\n detail: 'quantified expression',\n type: 'keyword'\n }),\n snippetCompletion('some ${var} in ${collection} satisfies ${condition}', {\n label: 'some',\n detail: 'quantified expression',\n type: 'keyword'\n }),\n snippetCompletion('if ${condition} then ${value} else ${other value}', {\n label: 'if',\n detail: 'block',\n type: 'keyword'\n }),\n snippetCompletion('{ ${key}: ${value} }', {\n label: 'context',\n detail: 'block',\n type: 'keyword'\n }),\n snippetCompletion('null', {\n label: 'null',\n detail: 'literal',\n type: 'keyword'\n }),\n snippetCompletion('true', {\n label: 'true',\n detail: 'literal',\n type: 'keyword'\n }),\n snippetCompletion('false', {\n label: 'false',\n detail: 'literal',\n type: 'keyword'\n })\n];\n","import { syntaxTree } from '@codemirror/language';\nimport { SyntaxNode } from '@lezer/common';\n\nimport {\n CompletionSource,\n Completion,\n completeFromList,\n CompletionContext\n} from '@codemirror/autocomplete';\n\n\nexport function contextualKeyword(options: {\n before?: string,\n after?: string,\n context: string,\n keyword: string\n}) : CompletionSource {\n\n const {\n context: nodes,\n after,\n before,\n keyword\n } = options;\n\n return ifInside({ nodes, before, after, keyword }, completeFromList([\n { label: keyword, type: 'keyword', boost: 10 }\n ]));\n}\n\nexport const keywordCompletions = [\n contextualKeyword({\n context: 'InExpression',\n keyword: 'in'\n }),\n contextualKeyword({\n context: 'IfExpression',\n keyword: 'then',\n after: 'if',\n before: 'else'\n }),\n contextualKeyword({\n context: 'IfExpression',\n keyword: 'else',\n after: 'then'\n }),\n contextualKeyword({\n context: 'QuantifiedExpression',\n keyword: 'satisfies'\n }),\n contextualKeyword({\n context: 'ForExpression',\n after: 'InExpressions',\n keyword: 'return'\n })\n];\n\nexport const dontComplete = [\n 'StringLiteral', 'Identifier',\n 'LineComment', 'BlockComment',\n 'PathExpression', 'Context',\n 'Key', 'ParameterName'\n];\n\nexport const doComplete = [\n 'Expr',\n 'ContextEntry'\n];\n\nexport function ifExpression(completionSource: CompletionSource) : CompletionSource {\n\n const allNodes = [ ...dontComplete, ...doComplete ];\n\n return (context: CompletionContext) => {\n\n const { state, pos } = context;\n\n const match = matchUp(syntaxTree(state).resolveInner(pos, -1), allNodes);\n\n if (match) {\n\n const [ _, name ] = match;\n\n if (dontComplete.includes(name)) {\n return null;\n }\n }\n\n return completionSource(context);\n };\n}\n\nexport function snippetCompletion(snippets: readonly Completion[]) : CompletionSource {\n return ifExpression(\n completeFromList(snippets.map(s => ({ ...s, type: 'text' })))\n );\n}\n\nexport function matchLeft(node: SyntaxNode, position: number, nodes: (string|undefined)[]) : SyntaxNode | null {\n return matchChildren(node, position, nodes, -1);\n}\n\nexport function matchRight(node: SyntaxNode, position: number, nodes: (string|undefined)[]) : SyntaxNode | null {\n return matchChildren(node, position, nodes, 1);\n}\n\nexport function matchChildren(node: SyntaxNode, position: number, nodes: (string|undefined)[], direction: 1 | -1) : SyntaxNode | null {\n\n let child = node[direction > 0 ? 'childAfter' : 'childBefore'](position);\n\n while (child) {\n if (nodes.includes(child.name)) {\n return child;\n }\n\n if (child.type.isError && child.firstChild) {\n if (nodes.includes(child.firstChild.name)) {\n return child.firstChild;\n }\n }\n\n child = child[direction > 0 ? 'nextSibling' : 'prevSibling'];\n }\n\n return null;\n}\n\nfunction matchUp(node: SyntaxNode, nodeNames: string | string[]) : [ SyntaxNode, string ] | null {\n\n if (!Array.isArray(nodeNames)) {\n nodeNames = [ nodeNames ];\n }\n\n for (; node; node = node.parent!) {\n\n const nodeType = node.type;\n\n const matchedName = nodeNames.find(name => name && nodeType.is(name));\n\n if (matchedName) {\n return [ node, matchedName ];\n }\n\n if (nodeType.isTop) {\n break;\n }\n }\n\n return null;\n}\n\nexport function ifInside(options: {\n nodes: string | string[],\n keyword: string,\n before?: string,\n after?: string\n}, source: CompletionSource): CompletionSource {\n\n const {\n nodes,\n before,\n after,\n keyword\n } = options;\n\n return (context) => {\n\n const { state, pos } = context;\n\n const match = matchUp(syntaxTree(state).resolveInner(pos, -1), nodes);\n\n if (!match) {\n return null;\n }\n\n const [ node ] = match;\n\n if (matchLeft(node, pos, [ keyword, before ])) {\n return null;\n }\n\n if (matchRight(node, pos, [ keyword, after ])) {\n return null;\n }\n\n if (after && !matchLeft(node, pos, [ after ])) {\n return null;\n }\n\n return source(context);\n };\n}","import {\n parser,\n trackVariables\n} from '@bpmn-io/lezer-feel';\n\nimport {\n LRLanguage,\n LanguageSupport,\n delimitedIndent,\n continuedIndent,\n indentNodeProp,\n foldNodeProp,\n foldInside\n} from '@codemirror/language';\n\nimport {\n snippets\n} from './snippets';\n\nimport {\n keywordCompletions,\n snippetCompletion\n} from './completion';\n\nimport {\n CompletionSource\n} from '@codemirror/autocomplete';\n\n\n/**\n * A FEEL language provider based on the\n * [Lezer FEEL parser](https://github.com/nikku/lezer-feel),\n * extended with highlighting and indentation information.\n */\nexport const feelLanguage = LRLanguage.define({\n parser: parser.configure({\n props: [\n indentNodeProp.add({\n 'Context': delimitedIndent({\n closing: '}'\n }),\n 'List FilterExpression': delimitedIndent({\n closing: ']'\n }),\n 'ParenthesizedExpression FunctionInvocation': continuedIndent({\n except: /^\\s*\\)/\n }),\n 'ForExpression QuantifiedExpression IfExpression': continuedIndent({\n except: /^\\s*(then|else|return|satisfies)\\b/\n }),\n 'FunctionDefinition': continuedIndent({\n except: /^\\s*(\\(|\\))/\n })\n }),\n foldNodeProp.add({\n Context: foldInside,\n List: foldInside,\n ParenthesizedExpression: foldInside,\n FunctionDefinition(node) {\n const last = node.getChild(')');\n\n if (!last) return null;\n\n return {\n from: last.to,\n to: node.to\n };\n }\n })\n ]\n }),\n languageData: {\n indentOnInput: /^\\s*(\\)|\\}|\\]|then|else|return|satisfies)$/,\n commentTokens: {\n line: '//',\n block: {\n open: '/*',\n close: '*/'\n }\n }\n }\n});\n\n/**\n * A language provider for FEEL Unary Tests\n */\nexport const unaryTestsLanguage = feelLanguage.configure({\n top: 'UnaryTests',\n}, 'FEEL unary tests');\n\n/**\n * Language provider for FEEL Expression\n */\nexport const expressionLanguage = feelLanguage.configure({\n top: 'Expression'\n}, 'FEEL expression');\n\n\n\n/**\n * Feel language support for CodeMirror.\n *\n * Includes [snippet](#lang-feel.snippets)\n */\nexport function feel(config: {\n dialect?: 'expression' | 'unaryTests',\n parserDialect?: string,\n completions?: CompletionSource[],\n context?: Record<string, any>\n} = {}) {\n const language = config.dialect === 'unaryTests' ? unaryTestsLanguage : expressionLanguage;\n\n const dialect = config.parserDialect;\n const contextTracker = trackVariables(config.context);\n\n const contextualLang = language.configure({\n contextTracker,\n dialect\n });\n\n const completions = config.completions || [\n snippetCompletion(snippets),\n keywordCompletions,\n ].flat();\n\n return new LanguageSupport(contextualLang, [\n ...(\n completions.map(autocomplete => contextualLang.data.of({\n autocomplete\n }))\n )\n ]);\n\n}"],"names":["snippets","snippetCompletion","label","detail","type","contextualKeyword","options","context","nodes","after","before","keyword","ifInside","completeFromList","boost","keywordCompletions","dontComplete","doComplete","ifExpression","completionSource","allNodes","state","pos","match","matchUp","syntaxTree","resolveInner","_","name","includes","map","s","matchLeft","node","position","matchChildren","matchRight","direction","child","isError","firstChild","nodeNames","Array","isArray","parent","nodeType","matchedName","find","is","isTop","source","feelLanguage","LRLanguage","define","parser","configure","props","indentNodeProp","add","delimitedIndent","closing","continuedIndent","except","foldNodeProp","Context","foldInside","List","ParenthesizedExpression","FunctionDefinition","last","getChild","from","to","languageData","indentOnInput","commentTokens","line","block","open","close","unaryTestsLanguage","top","expressionLanguage","feel","config","language","dialect","parserDialect","contextTracker","trackVariables","contextualLang","completions","flat","LanguageSupport","autocomplete","data","of"],"mappings":";;;;AAEA;;AAEG;MACUA,QAAQ,GAA0B,CAC7CC,8BAAiB,CAAC,6BAA6B,EAAE;AAC/CC,EAAAA,KAAK,EAAE,UAAU;AACjBC,EAAAA,MAAM,EAAE,YAAY;AACpBC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,8BAAiB,CAAC,6CAA6C,EAAE;AAC/DC,EAAAA,KAAK,EAAE,KAAK;AACZC,EAAAA,MAAM,EAAE,YAAY;AACpBC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,8BAAiB,CAAC,sDAAsD,EAAE;AACxEC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,MAAM,EAAE,uBAAuB;AAC/BC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,8BAAiB,CAAC,qDAAqD,EAAE;AACvEC,EAAAA,KAAK,EAAE,MAAM;AACbC,EAAAA,MAAM,EAAE,uBAAuB;AAC/BC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,8BAAiB,CAAC,mDAAmD,EAAE;AACrEC,EAAAA,KAAK,EAAE,IAAI;AACXC,EAAAA,MAAM,EAAE,OAAO;AACfC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,8BAAiB,CAAC,sBAAsB,EAAE;AACxCC,EAAAA,KAAK,EAAE,SAAS;AAChBC,EAAAA,MAAM,EAAE,OAAO;AACfC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,8BAAiB,CAAC,MAAM,EAAE;AACxBC,EAAAA,KAAK,EAAE,MAAM;AACbC,EAAAA,MAAM,EAAE,SAAS;AACjBC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,8BAAiB,CAAC,MAAM,EA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AAA;GACD,CAAC,CACH,CACF,CAAC,CAAA;AAEJ;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,3 @@
1
+ export { feel, feelLanguage, expressionLanguage, unaryTestsLanguage } from './feel';
2
+ export { snippets } from './snippets';
3
+ export * from './completion';
package/dist/index.js ADDED
@@ -0,0 +1,270 @@
1
+ import { parser, trackVariables } from '@bpmn-io/lezer-feel';
2
+ import { syntaxTree, LRLanguage, indentNodeProp, delimitedIndent, continuedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';
3
+ import { snippetCompletion as snippetCompletion$1, completeFromList } from '@codemirror/autocomplete';
4
+
5
+ /**
6
+ * A collection of FEEL-related [snippets](#autocomplete.snippet).
7
+ */
8
+ const snippets = [snippetCompletion$1('function(${params}) ${body}', {
9
+ label: 'function',
10
+ detail: 'definition',
11
+ type: 'keyword'
12
+ }), snippetCompletion$1('for ${var} in ${collection} return ${value}', {
13
+ label: 'for',
14
+ detail: 'expression',
15
+ type: 'keyword'
16
+ }), snippetCompletion$1('every ${var} in ${collection} satisfies ${condition}', {
17
+ label: 'every',
18
+ detail: 'quantified expression',
19
+ type: 'keyword'
20
+ }), snippetCompletion$1('some ${var} in ${collection} satisfies ${condition}', {
21
+ label: 'some',
22
+ detail: 'quantified expression',
23
+ type: 'keyword'
24
+ }), snippetCompletion$1('if ${condition} then ${value} else ${other value}', {
25
+ label: 'if',
26
+ detail: 'block',
27
+ type: 'keyword'
28
+ }), snippetCompletion$1('{ ${key}: ${value} }', {
29
+ label: 'context',
30
+ detail: 'block',
31
+ type: 'keyword'
32
+ }), snippetCompletion$1('null', {
33
+ label: 'null',
34
+ detail: 'literal',
35
+ type: 'keyword'
36
+ }), snippetCompletion$1('true', {
37
+ label: 'true',
38
+ detail: 'literal',
39
+ type: 'keyword'
40
+ }), snippetCompletion$1('false', {
41
+ label: 'false',
42
+ detail: 'literal',
43
+ type: 'keyword'
44
+ })];
45
+
46
+ function _extends() {
47
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
48
+ for (var i = 1; i < arguments.length; i++) {
49
+ var source = arguments[i];
50
+ for (var key in source) {
51
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
52
+ target[key] = source[key];
53
+ }
54
+ }
55
+ }
56
+ return target;
57
+ };
58
+ return _extends.apply(this, arguments);
59
+ }
60
+
61
+ function contextualKeyword(options) {
62
+ const {
63
+ context: nodes,
64
+ after,
65
+ before,
66
+ keyword
67
+ } = options;
68
+ return ifInside({
69
+ nodes,
70
+ before,
71
+ after,
72
+ keyword
73
+ }, completeFromList([{
74
+ label: keyword,
75
+ type: 'keyword',
76
+ boost: 10
77
+ }]));
78
+ }
79
+ const keywordCompletions = [contextualKeyword({
80
+ context: 'InExpression',
81
+ keyword: 'in'
82
+ }), contextualKeyword({
83
+ context: 'IfExpression',
84
+ keyword: 'then',
85
+ after: 'if',
86
+ before: 'else'
87
+ }), contextualKeyword({
88
+ context: 'IfExpression',
89
+ keyword: 'else',
90
+ after: 'then'
91
+ }), contextualKeyword({
92
+ context: 'QuantifiedExpression',
93
+ keyword: 'satisfies'
94
+ }), contextualKeyword({
95
+ context: 'ForExpression',
96
+ after: 'InExpressions',
97
+ keyword: 'return'
98
+ })];
99
+ const dontComplete = ['StringLiteral', 'Identifier', 'LineComment', 'BlockComment', 'PathExpression', 'Context', 'Key', 'ParameterName'];
100
+ const doComplete = ['Expr', 'ContextEntry'];
101
+ function ifExpression(completionSource) {
102
+ const allNodes = [...dontComplete, ...doComplete];
103
+ return context => {
104
+ const {
105
+ state,
106
+ pos
107
+ } = context;
108
+ const match = matchUp(syntaxTree(state).resolveInner(pos, -1), allNodes);
109
+ if (match) {
110
+ const [_, name] = match;
111
+ if (dontComplete.includes(name)) {
112
+ return null;
113
+ }
114
+ }
115
+ return completionSource(context);
116
+ };
117
+ }
118
+ function snippetCompletion(snippets) {
119
+ return ifExpression(completeFromList(snippets.map(s => _extends({}, s, {
120
+ type: 'text'
121
+ }))));
122
+ }
123
+ function matchLeft(node, position, nodes) {
124
+ return matchChildren(node, position, nodes, -1);
125
+ }
126
+ function matchRight(node, position, nodes) {
127
+ return matchChildren(node, position, nodes, 1);
128
+ }
129
+ function matchChildren(node, position, nodes, direction) {
130
+ let child = node[direction > 0 ? 'childAfter' : 'childBefore'](position);
131
+ while (child) {
132
+ if (nodes.includes(child.name)) {
133
+ return child;
134
+ }
135
+ if (child.type.isError && child.firstChild) {
136
+ if (nodes.includes(child.firstChild.name)) {
137
+ return child.firstChild;
138
+ }
139
+ }
140
+ child = child[direction > 0 ? 'nextSibling' : 'prevSibling'];
141
+ }
142
+ return null;
143
+ }
144
+ function matchUp(node, nodeNames) {
145
+ if (!Array.isArray(nodeNames)) {
146
+ nodeNames = [nodeNames];
147
+ }
148
+ for (; node; node = node.parent) {
149
+ const nodeType = node.type;
150
+ const matchedName = nodeNames.find(name => name && nodeType.is(name));
151
+ if (matchedName) {
152
+ return [node, matchedName];
153
+ }
154
+ if (nodeType.isTop) {
155
+ break;
156
+ }
157
+ }
158
+ return null;
159
+ }
160
+ function ifInside(options, source) {
161
+ const {
162
+ nodes,
163
+ before,
164
+ after,
165
+ keyword
166
+ } = options;
167
+ return context => {
168
+ const {
169
+ state,
170
+ pos
171
+ } = context;
172
+ const match = matchUp(syntaxTree(state).resolveInner(pos, -1), nodes);
173
+ if (!match) {
174
+ return null;
175
+ }
176
+ const [node] = match;
177
+ if (matchLeft(node, pos, [keyword, before])) {
178
+ return null;
179
+ }
180
+ if (matchRight(node, pos, [keyword, after])) {
181
+ return null;
182
+ }
183
+ if (after && !matchLeft(node, pos, [after])) {
184
+ return null;
185
+ }
186
+ return source(context);
187
+ };
188
+ }
189
+
190
+ /**
191
+ * A FEEL language provider based on the
192
+ * [Lezer FEEL parser](https://github.com/nikku/lezer-feel),
193
+ * extended with highlighting and indentation information.
194
+ */
195
+ const feelLanguage = LRLanguage.define({
196
+ parser: parser.configure({
197
+ props: [indentNodeProp.add({
198
+ 'Context': delimitedIndent({
199
+ closing: '}'
200
+ }),
201
+ 'List FilterExpression': delimitedIndent({
202
+ closing: ']'
203
+ }),
204
+ 'ParenthesizedExpression FunctionInvocation': continuedIndent({
205
+ except: /^\s*\)/
206
+ }),
207
+ 'ForExpression QuantifiedExpression IfExpression': continuedIndent({
208
+ except: /^\s*(then|else|return|satisfies)\b/
209
+ }),
210
+ 'FunctionDefinition': continuedIndent({
211
+ except: /^\s*(\(|\))/
212
+ })
213
+ }), foldNodeProp.add({
214
+ Context: foldInside,
215
+ List: foldInside,
216
+ ParenthesizedExpression: foldInside,
217
+ FunctionDefinition(node) {
218
+ const last = node.getChild(')');
219
+ if (!last) return null;
220
+ return {
221
+ from: last.to,
222
+ to: node.to
223
+ };
224
+ }
225
+ })]
226
+ }),
227
+ languageData: {
228
+ indentOnInput: /^\s*(\)|\}|\]|then|else|return|satisfies)$/,
229
+ commentTokens: {
230
+ line: '//',
231
+ block: {
232
+ open: '/*',
233
+ close: '*/'
234
+ }
235
+ }
236
+ }
237
+ });
238
+ /**
239
+ * A language provider for FEEL Unary Tests
240
+ */
241
+ const unaryTestsLanguage = feelLanguage.configure({
242
+ top: 'UnaryTests'
243
+ }, 'FEEL unary tests');
244
+ /**
245
+ * Language provider for FEEL Expression
246
+ */
247
+ const expressionLanguage = feelLanguage.configure({
248
+ top: 'Expression'
249
+ }, 'FEEL expression');
250
+ /**
251
+ * Feel language support for CodeMirror.
252
+ *
253
+ * Includes [snippet](#lang-feel.snippets)
254
+ */
255
+ function feel(config = {}) {
256
+ const language = config.dialect === 'unaryTests' ? unaryTestsLanguage : expressionLanguage;
257
+ const dialect = config.parserDialect;
258
+ const contextTracker = trackVariables(config.context);
259
+ const contextualLang = language.configure({
260
+ contextTracker,
261
+ dialect
262
+ });
263
+ const completions = config.completions || [snippetCompletion(snippets), keywordCompletions].flat();
264
+ return new LanguageSupport(contextualLang, [...completions.map(autocomplete => contextualLang.data.of({
265
+ autocomplete
266
+ }))]);
267
+ }
268
+
269
+ export { contextualKeyword, doComplete, dontComplete, expressionLanguage, feel, feelLanguage, ifExpression, ifInside, keywordCompletions, matchChildren, matchLeft, matchRight, snippetCompletion, snippets, unaryTestsLanguage };
270
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/snippets.ts","../src/completion.ts","../src/feel.ts"],"sourcesContent":["import { Completion, snippetCompletion } from '@codemirror/autocomplete';\n\n/**\n * A collection of FEEL-related [snippets](#autocomplete.snippet).\n */\nexport const snippets: readonly Completion[] = [\n snippetCompletion('function(${params}) ${body}', {\n label: 'function',\n detail: 'definition',\n type: 'keyword'\n }),\n snippetCompletion('for ${var} in ${collection} return ${value}', {\n label: 'for',\n detail: 'expression',\n type: 'keyword'\n }),\n snippetCompletion('every ${var} in ${collection} satisfies ${condition}', {\n label: 'every',\n detail: 'quantified expression',\n type: 'keyword'\n }),\n snippetCompletion('some ${var} in ${collection} satisfies ${condition}', {\n label: 'some',\n detail: 'quantified expression',\n type: 'keyword'\n }),\n snippetCompletion('if ${condition} then ${value} else ${other value}', {\n label: 'if',\n detail: 'block',\n type: 'keyword'\n }),\n snippetCompletion('{ ${key}: ${value} }', {\n label: 'context',\n detail: 'block',\n type: 'keyword'\n }),\n snippetCompletion('null', {\n label: 'null',\n detail: 'literal',\n type: 'keyword'\n }),\n snippetCompletion('true', {\n label: 'true',\n detail: 'literal',\n type: 'keyword'\n }),\n snippetCompletion('false', {\n label: 'false',\n detail: 'literal',\n type: 'keyword'\n })\n];\n","import { syntaxTree } from '@codemirror/language';\nimport { SyntaxNode } from '@lezer/common';\n\nimport {\n CompletionSource,\n Completion,\n completeFromList,\n CompletionContext\n} from '@codemirror/autocomplete';\n\n\nexport function contextualKeyword(options: {\n before?: string,\n after?: string,\n context: string,\n keyword: string\n}) : CompletionSource {\n\n const {\n context: nodes,\n after,\n before,\n keyword\n } = options;\n\n return ifInside({ nodes, before, after, keyword }, completeFromList([\n { label: keyword, type: 'keyword', boost: 10 }\n ]));\n}\n\nexport const keywordCompletions = [\n contextualKeyword({\n context: 'InExpression',\n keyword: 'in'\n }),\n contextualKeyword({\n context: 'IfExpression',\n keyword: 'then',\n after: 'if',\n before: 'else'\n }),\n contextualKeyword({\n context: 'IfExpression',\n keyword: 'else',\n after: 'then'\n }),\n contextualKeyword({\n context: 'QuantifiedExpression',\n keyword: 'satisfies'\n }),\n contextualKeyword({\n context: 'ForExpression',\n after: 'InExpressions',\n keyword: 'return'\n })\n];\n\nexport const dontComplete = [\n 'StringLiteral', 'Identifier',\n 'LineComment', 'BlockComment',\n 'PathExpression', 'Context',\n 'Key', 'ParameterName'\n];\n\nexport const doComplete = [\n 'Expr',\n 'ContextEntry'\n];\n\nexport function ifExpression(completionSource: CompletionSource) : CompletionSource {\n\n const allNodes = [ ...dontComplete, ...doComplete ];\n\n return (context: CompletionContext) => {\n\n const { state, pos } = context;\n\n const match = matchUp(syntaxTree(state).resolveInner(pos, -1), allNodes);\n\n if (match) {\n\n const [ _, name ] = match;\n\n if (dontComplete.includes(name)) {\n return null;\n }\n }\n\n return completionSource(context);\n };\n}\n\nexport function snippetCompletion(snippets: readonly Completion[]) : CompletionSource {\n return ifExpression(\n completeFromList(snippets.map(s => ({ ...s, type: 'text' })))\n );\n}\n\nexport function matchLeft(node: SyntaxNode, position: number, nodes: (string|undefined)[]) : SyntaxNode | null {\n return matchChildren(node, position, nodes, -1);\n}\n\nexport function matchRight(node: SyntaxNode, position: number, nodes: (string|undefined)[]) : SyntaxNode | null {\n return matchChildren(node, position, nodes, 1);\n}\n\nexport function matchChildren(node: SyntaxNode, position: number, nodes: (string|undefined)[], direction: 1 | -1) : SyntaxNode | null {\n\n let child = node[direction > 0 ? 'childAfter' : 'childBefore'](position);\n\n while (child) {\n if (nodes.includes(child.name)) {\n return child;\n }\n\n if (child.type.isError && child.firstChild) {\n if (nodes.includes(child.firstChild.name)) {\n return child.firstChild;\n }\n }\n\n child = child[direction > 0 ? 'nextSibling' : 'prevSibling'];\n }\n\n return null;\n}\n\nfunction matchUp(node: SyntaxNode, nodeNames: string | string[]) : [ SyntaxNode, string ] | null {\n\n if (!Array.isArray(nodeNames)) {\n nodeNames = [ nodeNames ];\n }\n\n for (; node; node = node.parent!) {\n\n const nodeType = node.type;\n\n const matchedName = nodeNames.find(name => name && nodeType.is(name));\n\n if (matchedName) {\n return [ node, matchedName ];\n }\n\n if (nodeType.isTop) {\n break;\n }\n }\n\n return null;\n}\n\nexport function ifInside(options: {\n nodes: string | string[],\n keyword: string,\n before?: string,\n after?: string\n}, source: CompletionSource): CompletionSource {\n\n const {\n nodes,\n before,\n after,\n keyword\n } = options;\n\n return (context) => {\n\n const { state, pos } = context;\n\n const match = matchUp(syntaxTree(state).resolveInner(pos, -1), nodes);\n\n if (!match) {\n return null;\n }\n\n const [ node ] = match;\n\n if (matchLeft(node, pos, [ keyword, before ])) {\n return null;\n }\n\n if (matchRight(node, pos, [ keyword, after ])) {\n return null;\n }\n\n if (after && !matchLeft(node, pos, [ after ])) {\n return null;\n }\n\n return source(context);\n };\n}","import {\n parser,\n trackVariables\n} from '@bpmn-io/lezer-feel';\n\nimport {\n LRLanguage,\n LanguageSupport,\n delimitedIndent,\n continuedIndent,\n indentNodeProp,\n foldNodeProp,\n foldInside\n} from '@codemirror/language';\n\nimport {\n snippets\n} from './snippets';\n\nimport {\n keywordCompletions,\n snippetCompletion\n} from './completion';\n\nimport {\n CompletionSource\n} from '@codemirror/autocomplete';\n\n\n/**\n * A FEEL language provider based on the\n * [Lezer FEEL parser](https://github.com/nikku/lezer-feel),\n * extended with highlighting and indentation information.\n */\nexport const feelLanguage = LRLanguage.define({\n parser: parser.configure({\n props: [\n indentNodeProp.add({\n 'Context': delimitedIndent({\n closing: '}'\n }),\n 'List FilterExpression': delimitedIndent({\n closing: ']'\n }),\n 'ParenthesizedExpression FunctionInvocation': continuedIndent({\n except: /^\\s*\\)/\n }),\n 'ForExpression QuantifiedExpression IfExpression': continuedIndent({\n except: /^\\s*(then|else|return|satisfies)\\b/\n }),\n 'FunctionDefinition': continuedIndent({\n except: /^\\s*(\\(|\\))/\n })\n }),\n foldNodeProp.add({\n Context: foldInside,\n List: foldInside,\n ParenthesizedExpression: foldInside,\n FunctionDefinition(node) {\n const last = node.getChild(')');\n\n if (!last) return null;\n\n return {\n from: last.to,\n to: node.to\n };\n }\n })\n ]\n }),\n languageData: {\n indentOnInput: /^\\s*(\\)|\\}|\\]|then|else|return|satisfies)$/,\n commentTokens: {\n line: '//',\n block: {\n open: '/*',\n close: '*/'\n }\n }\n }\n});\n\n/**\n * A language provider for FEEL Unary Tests\n */\nexport const unaryTestsLanguage = feelLanguage.configure({\n top: 'UnaryTests',\n}, 'FEEL unary tests');\n\n/**\n * Language provider for FEEL Expression\n */\nexport const expressionLanguage = feelLanguage.configure({\n top: 'Expression'\n}, 'FEEL expression');\n\n\n\n/**\n * Feel language support for CodeMirror.\n *\n * Includes [snippet](#lang-feel.snippets)\n */\nexport function feel(config: {\n dialect?: 'expression' | 'unaryTests',\n parserDialect?: string,\n completions?: CompletionSource[],\n context?: Record<string, any>\n} = {}) {\n const language = config.dialect === 'unaryTests' ? unaryTestsLanguage : expressionLanguage;\n\n const dialect = config.parserDialect;\n const contextTracker = trackVariables(config.context);\n\n const contextualLang = language.configure({\n contextTracker,\n dialect\n });\n\n const completions = config.completions || [\n snippetCompletion(snippets),\n keywordCompletions,\n ].flat();\n\n return new LanguageSupport(contextualLang, [\n ...(\n completions.map(autocomplete => contextualLang.data.of({\n autocomplete\n }))\n )\n ]);\n\n}"],"names":["snippets","snippetCompletion","label","detail","type","contextualKeyword","options","context","nodes","after","before","keyword","ifInside","completeFromList","boost","keywordCompletions","dontComplete","doComplete","ifExpression","completionSource","allNodes","state","pos","match","matchUp","syntaxTree","resolveInner","_","name","includes","map","s","_extends","matchLeft","node","position","matchChildren","matchRight","direction","child","isError","firstChild","nodeNames","Array","isArray","parent","nodeType","matchedName","find","is","isTop","source","feelLanguage","LRLanguage","define","parser","configure","props","indentNodeProp","add","delimitedIndent","closing","continuedIndent","except","foldNodeProp","Context","foldInside","List","ParenthesizedExpression","FunctionDefinition","last","getChild","from","to","languageData","indentOnInput","commentTokens","line","block","open","close","unaryTestsLanguage","top","expressionLanguage","feel","config","language","dialect","parserDialect","contextTracker","trackVariables","contextualLang","completions","flat","LanguageSupport","autocomplete","data","of"],"mappings":";;;;AAEA;;AAEG;MACUA,QAAQ,GAA0B,CAC7CC,mBAAiB,CAAC,6BAA6B,EAAE;AAC/CC,EAAAA,KAAK,EAAE,UAAU;AACjBC,EAAAA,MAAM,EAAE,YAAY;AACpBC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,mBAAiB,CAAC,6CAA6C,EAAE;AAC/DC,EAAAA,KAAK,EAAE,KAAK;AACZC,EAAAA,MAAM,EAAE,YAAY;AACpBC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,mBAAiB,CAAC,sDAAsD,EAAE;AACxEC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,MAAM,EAAE,uBAAuB;AAC/BC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,mBAAiB,CAAC,qDAAqD,EAAE;AACvEC,EAAAA,KAAK,EAAE,MAAM;AACbC,EAAAA,MAAM,EAAE,uBAAuB;AAC/BC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,mBAAiB,CAAC,mDAAmD,EAAE;AACrEC,EAAAA,KAAK,EAAE,IAAI;AACXC,EAAAA,MAAM,EAAE,OAAO;AACfC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,mBAAiB,CAAC,sBAAsB,EAAE;AACxCC,EAAAA,KAAK,EAAE,SAAS;AAChBC,EAAAA,MAAM,EAAE,OAAO;AACfC,EAAAA,IAAI,EAAE,SAAA;CACP,CAAC,EACFH,mBAAiB,CAAC,MAAM,EAAE;AACxBC,EAAAA,KAAK,EAAE,MAAM;AACbC,EAAAA,MAAM,EAAE,SAAS;AACjBC,EAAAA,IAAI,EAAE,SA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,IAAIJ,cAAc,CAACK,IAAI,CAACC,EAAE,CAAC;AACrDF,IAAAA,YAAAA;GACD,CAAC,CACH,CACF,CAAC,CAAA;AAEJ;;;;"}
@@ -0,0 +1,5 @@
1
+ import { Completion } from '@codemirror/autocomplete';
2
+ /**
3
+ * A collection of FEEL-related [snippets](#autocomplete.snippet).
4
+ */
5
+ export declare const snippets: readonly Completion[];
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@bpmn-io/lang-feel",
3
+ "version": "2.4.0",
4
+ "description": "FEEL language support for the CodeMirror code editor",
5
+ "scripts": {
6
+ "all": "run-s lint build test",
7
+ "test": "karma start karma.conf.cjs",
8
+ "start": "SINGLE_START=1 npm run dev",
9
+ "dev": "run-p 'build -- watch' 'test -- --no-single-run --auto-watch'",
10
+ "lint": "eslint . --ext ts",
11
+ "build": "microbundle -f modern,cjs --target node",
12
+ "prepare": "npm run build"
13
+ },
14
+ "keywords": [
15
+ "editor",
16
+ "code"
17
+ ],
18
+ "author": {
19
+ "name": "Nico Rehwaldt",
20
+ "url": "https://github.com/nikku"
21
+ },
22
+ "type": "module",
23
+ "source": "src/index.ts",
24
+ "main": "dist/index.cjs",
25
+ "exports": {
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.cjs"
28
+ },
29
+ "types": "dist/index.d.ts",
30
+ "module": "dist/index.js",
31
+ "sideEffects": false,
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "@codemirror/autocomplete": "^6.18.4",
35
+ "@codemirror/language": "^6.10.8",
36
+ "@lezer/common": "^1.2.3",
37
+ "@bpmn-io/lezer-feel": "^1.9.0"
38
+ },
39
+ "devDependencies": {
40
+ "@codemirror/state": "^6.5.1",
41
+ "@codemirror/view": "^6.36.2",
42
+ "@lezer/lr": "^1.4.2",
43
+ "@types/karma-chai": "^0.1.7",
44
+ "@types/karma-mocha": "^1.3.4",
45
+ "@types/mocha": "^10.0.10",
46
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
47
+ "@typescript-eslint/parser": "^7.18.0",
48
+ "chai": "^4.5.0",
49
+ "codemirror": "^6.0.1",
50
+ "eslint": "^8.57.0",
51
+ "eslint-plugin-bpmn-io": "^1.0.0",
52
+ "karma": "^6.4.4",
53
+ "karma-chai": "^0.1.0",
54
+ "karma-chrome-launcher": "^3.2.0",
55
+ "karma-debug-launcher": "^0.0.5",
56
+ "karma-env-preprocessor": "^0.1.1",
57
+ "karma-mocha": "^2.0.1",
58
+ "karma-webpack": "^5.0.1",
59
+ "microbundle": "^0.15.1",
60
+ "min-dom": "^5.1.1",
61
+ "mocha": "^10.8.2",
62
+ "npm-run-all2": "^8.0.0",
63
+ "puppeteer": "^23.11.1",
64
+ "ts-loader": "^9.5.2",
65
+ "typescript": "^5.7.3",
66
+ "webpack": "^5.97.1"
67
+ },
68
+ "repository": {
69
+ "type": "git",
70
+ "url": "https://github.com/bpmn-io/lang-feel.git"
71
+ },
72
+ "engines": {
73
+ "node": "*"
74
+ },
75
+ "files": [
76
+ "dist"
77
+ ]
78
+ }