-
Notifications
You must be signed in to change notification settings - Fork 28.4k
feat(editor): Migrate codemirror-lang-n8n-expression
into this monorepo (no-changelog)
#9087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4fd1731
Initial commit
ivov 6a54a29
Update setup code
ivov 2b2278c
Expand char range
ivov 79cf61c
move into packages/@n8n/codemirror-lang
netroy f6f5e9a
Merge codemirror-lang-n8n repo into monorepo
netroy 9cf74b3
rename package
netroy 2903072
remove rollup
netroy 64a9b5a
sync with upstream
netroy 5468f13
move expressions into their own folder
netroy 22935db
Merge remote-tracking branch 'origin/master' into codemirror-lang
netroy 0d2bcda
include @n8n/codemirror-lang in frontend tasks
netroy dfdf315
fix build
netroy 37b8802
Merge remote-tracking branch 'origin/master' into codemirror-lang
netroy ae2e6d3
address PR comments
netroy 14c7896
Merge remote-tracking branch 'origin/master' into codemirror-lang
netroy af215f0
Merge remote-tracking branch 'origin/master' into codemirror-lang
netroy 43e5b93
remove unused code
netroy f0f79db
fix(editor): Fix removal in codemirror-lang package
ivov 77ba8a3
Merge remote-tracking branch 'origin/master' into codemirror-lang
netroy ca4d406
Merge branch 'master' into codemirror-lang
ivov e5c5a35
fix(editor): Fix e2e for `codemirror-lang` package migration (#9362)
ivov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const sharedOptions = require('@n8n_io/eslint-config/shared'); | ||
|
||
/** | ||
* @type {import('@types/eslint').ESLint.ConfigData} | ||
*/ | ||
module.exports = { | ||
extends: ['@n8n_io/eslint-config/base'], | ||
|
||
...sharedOptions(__dirname), | ||
|
||
ignorePatterns: [ | ||
'src/expressions/grammar*.ts' | ||
] | ||
}; |
netroy marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# @n8n/codemirror-lang | ||
|
||
Language support package for CodeMirror 6 in n8n | ||
|
||
[n8n Expression Language support](./src/expressions/README.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** @type {import('jest').Config} */ | ||
module.exports = require('../../../jest.config'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@n8n/codemirror-lang", | ||
"version": "0.3.0", | ||
"description": "Language support package for CodeMirror 6 in n8n", | ||
"private": true, | ||
"sideEffects": false, | ||
"main": "dist/index.js", | ||
"module": "src/index.ts", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"require": "./dist/index.js", | ||
"import": "./src/index.ts", | ||
"types": "./dist/index.d.ts" | ||
}, | ||
"./*": "./*" | ||
}, | ||
"scripts": { | ||
"clean": "rimraf dist .turbo", | ||
"typecheck": "tsc --noEmit", | ||
"generate:expressions:grammar": "lezer-generator --typeScript --output src/expressions/grammar.ts src/expressions/expressions.grammar", | ||
"generate": "pnpm generate:expressions:grammar && pnpm format", | ||
"build": "tsc -p tsconfig.build.json", | ||
"test": "jest", | ||
"lint": "eslint . --ext .ts --quiet", | ||
"lintfix": "eslint . --ext .ts --fix", | ||
"format": "prettier --write --ignore-path ../../.prettierignore src test" | ||
}, | ||
"peerDependencies": { | ||
"@codemirror/language": "*", | ||
"@lezer/highlight": "*" | ||
}, | ||
"devDependencies": { | ||
"@lezer/generator": "^1.7.0" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# n8n Expression language support | ||
|
||
## Usage | ||
|
||
```js | ||
import { parserWithMetaData as n8nParser } from '@n8n/codemirror-lang'; | ||
import { LanguageSupport, LRLanguage } from '@codemirror/language'; | ||
import { parseMixed } from '@lezer/common'; | ||
import { parser as jsParser } from '@lezer/javascript'; | ||
|
||
const n8nPlusJsParser = n8nParser.configure({ | ||
wrap: parseMixed((node) => { | ||
if (node.type.isTop) return null; | ||
|
||
return node.name === 'Resolvable' | ||
? { parser: jsParser, overlay: (node) => node.type.name === 'Resolvable' } | ||
: null; | ||
}), | ||
}); | ||
|
||
const n8nLanguage = LRLanguage.define({ parser: n8nPlusJsParser }); | ||
|
||
export function n8nExpressionLanguageSupport() { | ||
return new LanguageSupport(n8nLanguage); | ||
} | ||
``` |
21 changes: 21 additions & 0 deletions
21
packages/@n8n/codemirror-lang/src/expressions/expressions.grammar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@top Program { entity* } | ||
|
||
entity { Plaintext | Resolvable } | ||
|
||
@tokens { | ||
Plaintext { ![{] Plaintext? | "{" (@eof | ![{] Plaintext?) } | ||
|
||
OpenMarker[closedBy="CloseMarker"] { "{{" } | ||
|
||
CloseMarker[openedBy="OpenMarker"] { "}}" } | ||
|
||
Resolvable { | ||
OpenMarker resolvableChar* CloseMarker | ||
} | ||
|
||
resolvableChar { unicodeChar | "}" ![}] | "\\}}" } | ||
|
||
unicodeChar { $[\u0000-\u007C] | $[\u007E-\u1FFF] | $[\u20A0-\u20CF] | $[\u{1F300}-\u{1F64F}] } | ||
} | ||
|
||
@detectDelim |
4 changes: 4 additions & 0 deletions
4
packages/@n8n/codemirror-lang/src/expressions/grammar.terms.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This file was generated by lezer-generator. You probably shouldn't edit it. | ||
export const Program = 1, | ||
Plaintext = 2, | ||
Resolvable = 3; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This file was generated by lezer-generator. You probably shouldn't edit it. | ||
import { LRParser } from '@lezer/lr'; | ||
export const parser = LRParser.deserialize({ | ||
version: 14, | ||
states: "nQQOPOOOOOO'#Cb'#CbOOOO'#C`'#C`QQOPOOOOOO-E6^-E6^", | ||
stateData: 'Y~OQPORPO~O', | ||
goto: 'bVPPPPWP^QRORSRTQOR', | ||
nodeNames: '⚠ Program Plaintext Resolvable', | ||
maxTerm: 6, | ||
skippedNodes: [0], | ||
repeatNodeCount: 1, | ||
tokenData: | ||
"&U~RTO#ob#o#p!h#p;'Sb;'S;=`!]<%lOb~gTQ~O#ob#o#pv#p;'Sb;'S;=`!]<%lOb~yUO#ob#p;'Sb;'S;=`!]<%l~b~Ob~~!c~!`P;=`<%lb~!hOQ~~!kVO#ob#o#p#Q#p;'Sb;'S;=`!]<%l~b~Ob~~!c~#TWO#O#Q#O#P#m#P#q#Q#q#r%Z#r$IS#Q$Lj$Ml#Q;(b;(c%x;(c;(d&O~#pWO#O#Q#O#P#m#P#q#Q#q#r$Y#r$IS#Q$Lj$Ml#Q;(b;(c%x;(c;(d&O~$]TO#q#Q#q#r$l#r;'S#Q;'S;=`%r<%lO#Q~$qWR~O#O#Q#O#P#m#P#q#Q#q#r%Z#r$IS#Q$Lj$Ml#Q;(b;(c%x;(c;(d&O~%^TO#q#Q#q#r%m#r;'S#Q;'S;=`%r<%lO#Q~%rOR~~%uP;=`<%l#Q~%{P;NQ<%l#Q~&RP;=`;JY#Q", | ||
tokenizers: [0], | ||
topRules: { Program: [0, 1] }, | ||
tokenPrec: 0, | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { LRLanguage, LanguageSupport, foldNodeProp, foldInside } from '@codemirror/language'; | ||
import { styleTags, tags as t } from '@lezer/highlight'; | ||
import { parser } from './grammar'; | ||
|
||
export const parserWithMetaData = parser.configure({ | ||
props: [ | ||
foldNodeProp.add({ | ||
Application: foldInside, | ||
}), | ||
styleTags({ | ||
OpenMarker: t.brace, | ||
CloseMarker: t.brace, | ||
Plaintext: t.content, | ||
Resolvable: t.string, | ||
}), | ||
], | ||
}); | ||
|
||
export const n8nLanguage = LRLanguage.define({ | ||
parser: parserWithMetaData, | ||
languageData: { | ||
commentTokens: { line: ';' }, | ||
}, | ||
}); | ||
|
||
export function n8nExpression() { | ||
return new LanguageSupport(n8nLanguage); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { parserWithMetaData, n8nLanguage } from './expressions'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.