Code editor language support
This commit is contained in:
@@ -65,6 +65,9 @@
|
|||||||
"@gradio/theme": "workspace:*",
|
"@gradio/theme": "workspace:*",
|
||||||
"@gradio/upload": "workspace:*",
|
"@gradio/upload": "workspace:*",
|
||||||
"@gradio/utils": "workspace:*",
|
"@gradio/utils": "workspace:*",
|
||||||
|
"@lezer/generator": "^1.2.3",
|
||||||
|
"@lezer/highlight": "^1.1.3",
|
||||||
|
"@lezer/lr": "^1.3.6",
|
||||||
"@litegraph-ts/core": "workspace:*",
|
"@litegraph-ts/core": "workspace:*",
|
||||||
"@litegraph-ts/nodes-basic": "workspace:*",
|
"@litegraph-ts/nodes-basic": "workspace:*",
|
||||||
"@litegraph-ts/nodes-events": "workspace:*",
|
"@litegraph-ts/nodes-events": "workspace:*",
|
||||||
|
|||||||
58
pnpm-lock.yaml
generated
58
pnpm-lock.yaml
generated
@@ -70,6 +70,15 @@ importers:
|
|||||||
'@gradio/utils':
|
'@gradio/utils':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:gradio/js/utils
|
version: link:gradio/js/utils
|
||||||
|
'@lezer/generator':
|
||||||
|
specifier: ^1.2.3
|
||||||
|
version: 1.2.3
|
||||||
|
'@lezer/highlight':
|
||||||
|
specifier: ^1.1.3
|
||||||
|
version: 1.1.4
|
||||||
|
'@lezer/lr':
|
||||||
|
specifier: ^1.3.6
|
||||||
|
version: 1.3.6
|
||||||
'@litegraph-ts/core':
|
'@litegraph-ts/core':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:litegraph/packages/core
|
version: link:litegraph/packages/core
|
||||||
@@ -105,10 +114,10 @@ importers:
|
|||||||
version: 1.0.3
|
version: 1.0.3
|
||||||
cm6-theme-basic-dark:
|
cm6-theme-basic-dark:
|
||||||
specifier: ^0.2.0
|
specifier: ^0.2.0
|
||||||
version: 0.2.0(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.0)
|
version: 0.2.0(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.0)(@lezer/highlight@1.1.4)
|
||||||
cm6-theme-basic-light:
|
cm6-theme-basic-light:
|
||||||
specifier: ^0.2.0
|
specifier: ^0.2.0
|
||||||
version: 0.2.0(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.0)
|
version: 0.2.0(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.0)(@lezer/highlight@1.1.4)
|
||||||
codemirror:
|
codemirror:
|
||||||
specifier: ^6.0.1
|
specifier: ^6.0.1
|
||||||
version: 6.0.1
|
version: 6.0.1
|
||||||
@@ -1363,7 +1372,6 @@ packages:
|
|||||||
'@codemirror/language': ^6.0.0
|
'@codemirror/language': ^6.0.0
|
||||||
'@codemirror/state': ^6.0.0
|
'@codemirror/state': ^6.0.0
|
||||||
'@codemirror/view': ^6.0.0
|
'@codemirror/view': ^6.0.0
|
||||||
'@lezer/common': ^1.0.0
|
|
||||||
dependencies:
|
dependencies:
|
||||||
'@codemirror/language': 6.6.0
|
'@codemirror/language': 6.6.0
|
||||||
'@codemirror/state': 6.2.0
|
'@codemirror/state': 6.2.0
|
||||||
@@ -1469,7 +1477,7 @@ packages:
|
|||||||
'@codemirror/view': 6.11.0
|
'@codemirror/view': 6.11.0
|
||||||
'@lezer/common': 1.0.2
|
'@lezer/common': 1.0.2
|
||||||
'@lezer/highlight': 1.1.4
|
'@lezer/highlight': 1.1.4
|
||||||
'@lezer/lr': 1.3.4
|
'@lezer/lr': 1.3.6
|
||||||
style-mod: 4.0.3
|
style-mod: 4.0.3
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
@@ -2035,6 +2043,14 @@ packages:
|
|||||||
'@lezer/lr': 1.3.4
|
'@lezer/lr': 1.3.4
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@lezer/generator@1.2.3:
|
||||||
|
resolution: {integrity: sha512-xRmNryYbJpWs7novjWtQLCGHOj71B4X1QHQ4SgJqwm11tl6COEVAGhuFTXKX16JMJUhumdXaX8We6hEMd4clDg==}
|
||||||
|
hasBin: true
|
||||||
|
dependencies:
|
||||||
|
'@lezer/common': 1.0.2
|
||||||
|
'@lezer/lr': 1.3.6
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@lezer/highlight@1.1.4:
|
/@lezer/highlight@1.1.4:
|
||||||
resolution: {integrity: sha512-IECkFmw2l7sFcYXrV8iT9GeY4W0fU4CxX0WMwhmhMIVjoDdD1Hr6q3G2NqVtLg/yVe5n7i4menG3tJ2r4eCrPQ==}
|
resolution: {integrity: sha512-IECkFmw2l7sFcYXrV8iT9GeY4W0fU4CxX0WMwhmhMIVjoDdD1Hr6q3G2NqVtLg/yVe5n7i4menG3tJ2r4eCrPQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -2069,6 +2085,12 @@ packages:
|
|||||||
'@lezer/common': 1.0.2
|
'@lezer/common': 1.0.2
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@lezer/lr@1.3.6:
|
||||||
|
resolution: {integrity: sha512-IDhcWjfxwWACnatUi0GzWBCbochfqxo3LZZlS27LbJh8RVYYXXyR5Ck9659IhkWkhSW/kZlaaiJpUO+YZTUK+Q==}
|
||||||
|
dependencies:
|
||||||
|
'@lezer/common': 1.0.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@lezer/markdown@1.0.2:
|
/@lezer/markdown@1.0.2:
|
||||||
resolution: {integrity: sha512-8CY0OoZ6V5EzPjSPeJ4KLVbtXdLBd8V6sRCooN5kHnO28ytreEGTyrtU/zUwo/XLRzGr/e1g44KlzKi3yWGB5A==}
|
resolution: {integrity: sha512-8CY0OoZ6V5EzPjSPeJ4KLVbtXdLBd8V6sRCooN5kHnO28ytreEGTyrtU/zUwo/XLRzGr/e1g44KlzKi3yWGB5A==}
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -3045,19 +3067,6 @@ packages:
|
|||||||
wrap-ansi: 7.0.0
|
wrap-ansi: 7.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/cm6-theme-basic-dark@0.2.0(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.0):
|
|
||||||
resolution: {integrity: sha512-+mNNJecRtxS/KkloMDCQF0oTrT6aFGRZTjnBcdT5UG1pcDO4Brq8l1+0KR/8dZ7hub2gOGOzoi3rGFD8GzlH7Q==}
|
|
||||||
peerDependencies:
|
|
||||||
'@codemirror/language': ^6.0.0
|
|
||||||
'@codemirror/state': ^6.0.0
|
|
||||||
'@codemirror/view': ^6.0.0
|
|
||||||
'@lezer/highlight': ^1.0.0
|
|
||||||
dependencies:
|
|
||||||
'@codemirror/language': 6.6.0
|
|
||||||
'@codemirror/state': 6.2.0
|
|
||||||
'@codemirror/view': 6.11.0
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/cm6-theme-basic-dark@0.2.0(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.0)(@lezer/highlight@1.1.4):
|
/cm6-theme-basic-dark@0.2.0(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.0)(@lezer/highlight@1.1.4):
|
||||||
resolution: {integrity: sha512-+mNNJecRtxS/KkloMDCQF0oTrT6aFGRZTjnBcdT5UG1pcDO4Brq8l1+0KR/8dZ7hub2gOGOzoi3rGFD8GzlH7Q==}
|
resolution: {integrity: sha512-+mNNJecRtxS/KkloMDCQF0oTrT6aFGRZTjnBcdT5UG1pcDO4Brq8l1+0KR/8dZ7hub2gOGOzoi3rGFD8GzlH7Q==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -3072,19 +3081,6 @@ packages:
|
|||||||
'@lezer/highlight': 1.1.4
|
'@lezer/highlight': 1.1.4
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/cm6-theme-basic-light@0.2.0(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.0):
|
|
||||||
resolution: {integrity: sha512-1prg2gv44sYfpHscP26uLT/ePrh0mlmVwMSoSd3zYKQ92Ab3jPRLzyCnpyOCQLJbK+YdNs4HvMRqMNYdy4pMhA==}
|
|
||||||
peerDependencies:
|
|
||||||
'@codemirror/language': ^6.0.0
|
|
||||||
'@codemirror/state': ^6.0.0
|
|
||||||
'@codemirror/view': ^6.0.0
|
|
||||||
'@lezer/highlight': ^1.0.0
|
|
||||||
dependencies:
|
|
||||||
'@codemirror/language': 6.6.0
|
|
||||||
'@codemirror/state': 6.2.0
|
|
||||||
'@codemirror/view': 6.11.0
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/cm6-theme-basic-light@0.2.0(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.0)(@lezer/highlight@1.1.4):
|
/cm6-theme-basic-light@0.2.0(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.0)(@lezer/highlight@1.1.4):
|
||||||
resolution: {integrity: sha512-1prg2gv44sYfpHscP26uLT/ePrh0mlmVwMSoSd3zYKQ92Ab3jPRLzyCnpyOCQLJbK+YdNs4HvMRqMNYdy4pMhA==}
|
resolution: {integrity: sha512-1prg2gv44sYfpHscP26uLT/ePrh0mlmVwMSoSd3zYKQ92Ab3jPRLzyCnpyOCQLJbK+YdNs4HvMRqMNYdy4pMhA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -3118,8 +3114,6 @@ packages:
|
|||||||
'@codemirror/search': 6.4.0
|
'@codemirror/search': 6.4.0
|
||||||
'@codemirror/state': 6.2.0
|
'@codemirror/state': 6.2.0
|
||||||
'@codemirror/view': 6.11.0
|
'@codemirror/view': 6.11.0
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@lezer/common'
|
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/codemirror@6.0.1(@lezer/common@1.0.2):
|
/codemirror@6.0.1(@lezer/common@1.0.2):
|
||||||
|
|||||||
36
src/lib/widgets/ComfyUI.grammar
Normal file
36
src/lib/widgets/ComfyUI.grammar
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
@top Program { expression* }
|
||||||
|
|
||||||
|
@skip {} {
|
||||||
|
BlockComment { "/*" (blockCommentContent | blockCommentNewline)* blockCommentEnd }
|
||||||
|
}
|
||||||
|
|
||||||
|
@skip { space | LineComment | BlockComment }
|
||||||
|
|
||||||
|
@local tokens {
|
||||||
|
blockCommentEnd { "*/" }
|
||||||
|
blockCommentNewline { "\n" }
|
||||||
|
@else blockCommentContent
|
||||||
|
}
|
||||||
|
|
||||||
|
expression {
|
||||||
|
Identifier |
|
||||||
|
String |
|
||||||
|
Boolean |
|
||||||
|
Application { "(" expression* ")" }
|
||||||
|
}
|
||||||
|
|
||||||
|
@tokens {
|
||||||
|
Identifier { $[a-zA-Z_\-0-9]+ }
|
||||||
|
|
||||||
|
String { '"' (!["\\] | "\\" _)* '"' }
|
||||||
|
|
||||||
|
Boolean { "#t" | "#f" }
|
||||||
|
|
||||||
|
LineComment { "//" ![\n]* }
|
||||||
|
|
||||||
|
space { $[ \t\n\r]+ }
|
||||||
|
|
||||||
|
"(" ")"
|
||||||
|
}
|
||||||
|
|
||||||
|
@detectDelim
|
||||||
3
src/lib/widgets/ComfyUI.grammar.d.ts
vendored
Normal file
3
src/lib/widgets/ComfyUI.grammar.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { LRParser } from "@lezer/lr"
|
||||||
|
|
||||||
|
export declare const parser: LRParser
|
||||||
@@ -14,7 +14,8 @@ import {
|
|||||||
indentOnInput,
|
indentOnInput,
|
||||||
syntaxHighlighting,
|
syntaxHighlighting,
|
||||||
defaultHighlightStyle,
|
defaultHighlightStyle,
|
||||||
foldKeymap
|
foldKeymap,
|
||||||
|
LRLanguage, LanguageSupport, indentNodeProp, foldNodeProp, foldInside, delimitedIndent
|
||||||
} from "@codemirror/language";
|
} from "@codemirror/language";
|
||||||
import { history, defaultKeymap, historyKeymap } from "@codemirror/commands";
|
import { history, defaultKeymap, historyKeymap } from "@codemirror/commands";
|
||||||
import {
|
import {
|
||||||
@@ -27,8 +28,26 @@ import {
|
|||||||
type CompletionSource, autocompletion, CompletionContext, startCompletion,
|
type CompletionSource, autocompletion, CompletionContext, startCompletion,
|
||||||
currentCompletions, completionStatus, completeFromList, acceptCompletion
|
currentCompletions, completionStatus, completeFromList, acceptCompletion
|
||||||
} from "@codemirror/autocomplete"
|
} from "@codemirror/autocomplete"
|
||||||
|
import { styleTags, tags as t } from "@lezer/highlight"
|
||||||
import DanbooruTags from "$lib/DanbooruTags";
|
import DanbooruTags from "$lib/DanbooruTags";
|
||||||
|
|
||||||
|
import { parser } from "./ComfyUI.grammar"
|
||||||
|
|
||||||
|
export const comfyUILanguage = LRLanguage.define({
|
||||||
|
name: "ComfyUI",
|
||||||
|
parser: parser.configure({
|
||||||
|
props: [
|
||||||
|
styleTags({
|
||||||
|
LineComment: t.lineComment,
|
||||||
|
BlockComment: t.blockComment,
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
languageData: {
|
||||||
|
commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
export const basicSetup: Extension = /*@__PURE__*/ (() => [
|
export const basicSetup: Extension = /*@__PURE__*/ (() => [
|
||||||
lineNumbers(),
|
lineNumbers(),
|
||||||
highlightSpecialChars(),
|
highlightSpecialChars(),
|
||||||
@@ -43,6 +62,7 @@ export const basicSetup: Extension = /*@__PURE__*/ (() => [
|
|||||||
crosshairCursor(),
|
crosshairCursor(),
|
||||||
EditorView.lineWrapping,
|
EditorView.lineWrapping,
|
||||||
DanbooruTags.getCompletionExt(),
|
DanbooruTags.getCompletionExt(),
|
||||||
|
new LanguageSupport(comfyUILanguage),
|
||||||
|
|
||||||
keymap.of([
|
keymap.of([
|
||||||
...closeBracketsKeymap,
|
...closeBracketsKeymap,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import removeConsole from 'vite-plugin-svelte-console-remover';
|
|||||||
import glsl from 'vite-plugin-glsl';
|
import glsl from 'vite-plugin-glsl';
|
||||||
import { execSync } from "child_process"
|
import { execSync } from "child_process"
|
||||||
import { visualizer } from "rollup-plugin-visualizer";
|
import { visualizer } from "rollup-plugin-visualizer";
|
||||||
|
import { lezer } from "@lezer/generator/rollup"
|
||||||
|
|
||||||
const isProduction = process.env.NODE_ENV === "production";
|
const isProduction = process.env.NODE_ENV === "production";
|
||||||
console.log("Production build: " + isProduction)
|
console.log("Production build: " + isProduction)
|
||||||
@@ -31,6 +32,7 @@ export default defineConfig({
|
|||||||
isProduction && removeConsole(),
|
isProduction && removeConsole(),
|
||||||
glsl(),
|
glsl(),
|
||||||
svelte(),
|
svelte(),
|
||||||
|
lezer(),
|
||||||
visualizer(),
|
visualizer(),
|
||||||
viteStaticCopy({
|
viteStaticCopy({
|
||||||
targets: [
|
targets: [
|
||||||
|
|||||||
Reference in New Issue
Block a user