@swiftuijs/twill-highlight 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +41 -2
- package/dist/index.d.ts +24 -0
- package/dist/index.js +2 -0
- package/dist/shiki.d.ts +2 -0
- package/dist/shiki.js +24 -0
- package/dist/shiki.js.map +1 -0
- package/dist/src-B8qil4uJ.js +245 -0
- package/dist/src-B8qil4uJ.js.map +1 -0
- package/grammars/twill.tmLanguage.json +217 -0
- package/grammars/twillx.tmLanguage.json +223 -0
- package/package.json +75 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Saiya and twill contributors
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Twill highlighting
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Portable TextMate grammars and a browser-compatible Shiki entry. The package imports no compiler, TypeScript engine, VS Code APIs or UI framework. The docs site and VSIX use the same grammar files.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add shiki @swiftuijs/twill-highlight
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Create one highlighter, reuse it for code blocks and dispose it when its owner is destroyed:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createTwillHighlighter } from '@swiftuijs/twill-highlight/shiki';
|
|
13
|
+
|
|
14
|
+
const highlighter = await createTwillHighlighter();
|
|
15
|
+
const html = highlighter.codeToHtml('const active = users.filter { .active };', {
|
|
16
|
+
lang: 'twill', // use twillx for JSX
|
|
17
|
+
theme: 'github-dark', // or github-light
|
|
18
|
+
});
|
|
19
|
+
highlighter.dispose();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The helper loads only TS/TSX grammars and two themes, using Shiki's Oniguruma engine. Initial creation loads its WASM; tokenization is synchronous afterward. Shiki is an optional peer, separate from the grammar-only entry. Reuse the instance, and lazy-load the helper if highlighting is not needed on every page. Published archive size excludes Shiki and its WASM.
|
|
23
|
+
|
|
24
|
+
## Existing Shiki integrations
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { createHighlighter } from 'shiki';
|
|
28
|
+
import { twillLanguages } from '@swiftuijs/twill-highlight';
|
|
29
|
+
|
|
30
|
+
const highlighter = await createHighlighter({
|
|
31
|
+
themes: ['nord'],
|
|
32
|
+
langs: ['typescript', 'tsx', ...twillLanguages],
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Both native base grammars are required. For VitePress, use `markdown.languages: twillLanguages`; its built-in grammars supply TS/TSX. Shiki 2.5, 3 and 4 are supported; the packaged consumer tests exercise the pinned versions. Custom themes, token output and transformers remain ordinary Shiki APIs.
|
|
37
|
+
|
|
38
|
+
For other TextMate-compatible engines, use the JSON exports `@swiftuijs/twill-highlight/grammars/twill` and `/grammars/twillx`; load `source.ts` and `source.tsx` too. Prism and highlight.js use different grammar formats and cannot consume TextMate registrations directly.
|
|
39
|
+
|
|
40
|
+
Shiki escapes code text in generated HTML. This does not sanitize arbitrary custom transformers, themes or surrounding markup. Highlighting is lexical; it supplies neither compiler diagnostics nor semantic completion. The editable playground continues to use CodeMirror for its incremental editing model.
|
|
41
|
+
|
|
42
|
+
[Documentation](https://swiftuijs.github.io/twill/highlighting) · [Playground](https://swiftuijs.github.io/twill/playground) · [Issues](https://github.com/swiftuijs/twill/issues) · MIT licensed · Built by [forth.ink](https://forth.ink).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** The TextMate rule fields used by Twill, independent of an engine's types. */
|
|
2
|
+
export interface TextMateRule {
|
|
3
|
+
name?: string;
|
|
4
|
+
include?: string;
|
|
5
|
+
match?: string;
|
|
6
|
+
begin?: string;
|
|
7
|
+
end?: string;
|
|
8
|
+
captures?: Record<string, TextMateRule>;
|
|
9
|
+
beginCaptures?: Record<string, TextMateRule>;
|
|
10
|
+
endCaptures?: Record<string, TextMateRule>;
|
|
11
|
+
patterns?: TextMateRule[];
|
|
12
|
+
}
|
|
13
|
+
export interface TwillGrammar {
|
|
14
|
+
name: string;
|
|
15
|
+
aliases: string[];
|
|
16
|
+
scopeName: string;
|
|
17
|
+
patterns: TextMateRule[];
|
|
18
|
+
repository: Record<string, TextMateRule>;
|
|
19
|
+
injections: Record<string, TextMateRule>;
|
|
20
|
+
}
|
|
21
|
+
/** Engine-independent TextMate grammars; load the TS/TSX base grammars too. */
|
|
22
|
+
export declare const twill: TwillGrammar;
|
|
23
|
+
export declare const twillx: TwillGrammar;
|
|
24
|
+
export declare const twillLanguages: TwillGrammar[];
|
package/dist/index.js
ADDED
package/dist/shiki.d.ts
ADDED
package/dist/shiki.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { n as twillLanguages } from "./src-B8qil4uJ.js";
|
|
2
|
+
import { createHighlighterCore } from "shiki/core";
|
|
3
|
+
import { createOnigurumaEngine } from "shiki/engine/oniguruma";
|
|
4
|
+
import typescript from "shiki/langs/typescript.mjs";
|
|
5
|
+
import tsx from "shiki/langs/tsx.mjs";
|
|
6
|
+
import githubDark from "shiki/themes/github-dark.mjs";
|
|
7
|
+
import githubLight from "shiki/themes/github-light.mjs";
|
|
8
|
+
//#region src/shiki.ts
|
|
9
|
+
/** Create once and reuse. This entry loads only TS/TSX and two themes. */
|
|
10
|
+
function createTwillHighlighter() {
|
|
11
|
+
return createHighlighterCore({
|
|
12
|
+
langs: [
|
|
13
|
+
...typescript,
|
|
14
|
+
...tsx,
|
|
15
|
+
...twillLanguages
|
|
16
|
+
],
|
|
17
|
+
themes: [githubLight, githubDark],
|
|
18
|
+
engine: createOnigurumaEngine(import("shiki/wasm"))
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { createTwillHighlighter };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=shiki.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shiki.js","names":[],"sources":["../src/shiki.ts"],"sourcesContent":["import { createHighlighterCore } from 'shiki/core';\nimport { createOnigurumaEngine } from 'shiki/engine/oniguruma';\nimport typescript from 'shiki/langs/typescript.mjs';\nimport tsx from 'shiki/langs/tsx.mjs';\nimport githubDark from 'shiki/themes/github-dark.mjs';\nimport githubLight from 'shiki/themes/github-light.mjs';\nimport { twillLanguages } from './index.js';\n\n/** Create once and reuse. This entry loads only TS/TSX and two themes. */\nexport function createTwillHighlighter() {\n return createHighlighterCore({\n langs: [...typescript, ...tsx, ...twillLanguages],\n themes: [githubLight, githubDark],\n engine: createOnigurumaEngine(import('shiki/wasm')),\n });\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,yBAAyB;CACvC,OAAO,sBAAsB;EAC3B,OAAO;GAAC,GAAG;GAAY,GAAG;GAAK,GAAG;EAAc;EAChD,QAAQ,CAAC,aAAa,UAAU;EAChC,QAAQ,sBAAsB,OAAO,aAAa;CACpD,CAAC;AACH"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
var twill_tmLanguage_default = {
|
|
2
|
+
name: "Twill ts",
|
|
3
|
+
scopeName: "source.twill.ts",
|
|
4
|
+
patterns: [
|
|
5
|
+
{ "include": "#implicit-member" },
|
|
6
|
+
{ "include": "#defer" },
|
|
7
|
+
{ "include": "#guard-binding" },
|
|
8
|
+
{ "include": "#guard" },
|
|
9
|
+
{ "include": "#switch-expression" },
|
|
10
|
+
{ "include": "#closure-header" },
|
|
11
|
+
{
|
|
12
|
+
"match": "(?<=\\})\\s*\\b([A-Za-z_$][\\w$]*)(\\s*:)(?=\\s*\\{)",
|
|
13
|
+
"captures": {
|
|
14
|
+
"1": { "name": "entity.name.function.twill" },
|
|
15
|
+
"2": { "name": "punctuation.separator.twill" }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{ "include": "source.ts" }
|
|
19
|
+
],
|
|
20
|
+
repository: {
|
|
21
|
+
"implicit-member": {
|
|
22
|
+
"match": "(?<![\\w$.)}\\]])(\\.)([A-Za-z_$][\\w$]*)",
|
|
23
|
+
"captures": {
|
|
24
|
+
"1": { "name": "punctuation.accessor.twill" },
|
|
25
|
+
"2": { "name": "variable.other.property.twill" }
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"defer": {
|
|
29
|
+
"match": "(?<![\\w$.])\\bdefer\\b(?=(?:[^\\S\\r\\n]|/\\*[^\\r\\n]*?\\*/)*\\{)",
|
|
30
|
+
"name": "keyword.control.twill"
|
|
31
|
+
},
|
|
32
|
+
"guard": {
|
|
33
|
+
"match": "(?<![\\w$.])\\bguard\\b(?=\\s+(?:const\\b|[^\\s;=:]))",
|
|
34
|
+
"name": "keyword.control.twill"
|
|
35
|
+
},
|
|
36
|
+
"guard-binding": {
|
|
37
|
+
"name": "meta.guard.binding.twill",
|
|
38
|
+
"begin": "(?<![\\w$.])\\b(guard)\\s+(const)\\b",
|
|
39
|
+
"beginCaptures": {
|
|
40
|
+
"1": { "name": "keyword.control.twill" },
|
|
41
|
+
"2": { "name": "storage.type.ts" }
|
|
42
|
+
},
|
|
43
|
+
"end": "(?<![\\w$.])\\belse\\b(?=\\s*\\{)",
|
|
44
|
+
"endCaptures": { "0": { "name": "keyword.control.twill" } },
|
|
45
|
+
"patterns": [
|
|
46
|
+
{ "include": "source.ts#object-binding-pattern-const" },
|
|
47
|
+
{ "include": "source.ts#array-binding-pattern-const" },
|
|
48
|
+
{ "include": "source.ts" }
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
"switch-expression": {
|
|
52
|
+
"name": "meta.switch.expression.twill",
|
|
53
|
+
"begin": "(?<![\\w$.])(switch)\\b(?=\\s*\\()",
|
|
54
|
+
"beginCaptures": { "1": { "name": "keyword.control.twill" } },
|
|
55
|
+
"end": "\\}",
|
|
56
|
+
"endCaptures": { "0": { "name": "punctuation.section.block.end.twill" } },
|
|
57
|
+
"patterns": [
|
|
58
|
+
{ "include": "source.ts#comment" },
|
|
59
|
+
{
|
|
60
|
+
"begin": "\\(",
|
|
61
|
+
"end": "\\)",
|
|
62
|
+
"patterns": [{ "include": "source.ts#expression" }]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"begin": "\\{",
|
|
66
|
+
"end": "(?=\\})",
|
|
67
|
+
"patterns": [{
|
|
68
|
+
"begin": "(?<![\\w$.])(case|default)\\b",
|
|
69
|
+
"beginCaptures": { "1": { "name": "keyword.control.twill" } },
|
|
70
|
+
"end": "(?=:)",
|
|
71
|
+
"patterns": [{ "include": "source.ts#expression" }]
|
|
72
|
+
}, { "include": "source.ts#statements" }]
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"closure-header": {
|
|
77
|
+
"begin": "(\\{)(?=\\s*(?:async\\s+)?(?:[A-Za-z_$][\\w$]*(?:\\s*,\\s*[A-Za-z_$][\\w$]*)*|\\((?:[^;()]|\\([^()]*\\))*\\)(?:\\s*:[^;{}]*?)?)\\s+in\\b)",
|
|
78
|
+
"beginCaptures": { "1": { "name": "punctuation.section.block.begin.twill" } },
|
|
79
|
+
"end": "\\}",
|
|
80
|
+
"endCaptures": { "0": { "name": "punctuation.section.block.end.twill" } },
|
|
81
|
+
"name": "meta.trailing.closure.twill",
|
|
82
|
+
"patterns": [{
|
|
83
|
+
"begin": "(?<=\\{)",
|
|
84
|
+
"end": "\\bin\\b",
|
|
85
|
+
"endCaptures": { "0": { "name": "keyword.control.twill" } },
|
|
86
|
+
"patterns": [
|
|
87
|
+
{ "include": "source.ts#comment" },
|
|
88
|
+
{
|
|
89
|
+
"match": "\\basync\\b",
|
|
90
|
+
"name": "storage.modifier.ts"
|
|
91
|
+
},
|
|
92
|
+
{ "include": "source.ts#function-parameters" },
|
|
93
|
+
{
|
|
94
|
+
"begin": ":",
|
|
95
|
+
"end": "(?=\\bin\\b)",
|
|
96
|
+
"patterns": [{ "include": "source.ts#type" }]
|
|
97
|
+
},
|
|
98
|
+
{ "include": "source.ts#parameter-name" }
|
|
99
|
+
]
|
|
100
|
+
}, { "include": "source.ts#statements" }]
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
injections: { "L:source.twill.ts -comment -string, L:source.twill.ts meta.template.expression -comment -(meta.template.expression string)": { "patterns": [
|
|
104
|
+
{ "include": "#implicit-member" },
|
|
105
|
+
{ "include": "#defer" },
|
|
106
|
+
{ "include": "#guard-binding" },
|
|
107
|
+
{ "include": "#guard" },
|
|
108
|
+
{ "include": "#switch-expression" },
|
|
109
|
+
{ "include": "#closure-header" }
|
|
110
|
+
] } }
|
|
111
|
+
};
|
|
112
|
+
var twillx_tmLanguage_default = {
|
|
113
|
+
name: "Twill tsx",
|
|
114
|
+
scopeName: "source.twill.tsx",
|
|
115
|
+
patterns: [
|
|
116
|
+
{ "include": "#implicit-member" },
|
|
117
|
+
{ "include": "#defer" },
|
|
118
|
+
{ "include": "#guard-binding" },
|
|
119
|
+
{ "include": "#guard" },
|
|
120
|
+
{ "include": "#switch-expression" },
|
|
121
|
+
{ "include": "#closure-header" },
|
|
122
|
+
{
|
|
123
|
+
"match": "(?<=\\})\\s*\\b([A-Za-z_$][\\w$]*)(\\s*:)(?=\\s*\\{)",
|
|
124
|
+
"captures": {
|
|
125
|
+
"1": { "name": "entity.name.function.twill" },
|
|
126
|
+
"2": { "name": "punctuation.separator.twill" }
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
{ "include": "source.tsx" }
|
|
130
|
+
],
|
|
131
|
+
repository: {
|
|
132
|
+
"implicit-member": {
|
|
133
|
+
"match": "(?<![\\w$.)}\\]])(\\.)([A-Za-z_$][\\w$]*)",
|
|
134
|
+
"captures": {
|
|
135
|
+
"1": { "name": "punctuation.accessor.twill" },
|
|
136
|
+
"2": { "name": "variable.other.property.twill" }
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"defer": {
|
|
140
|
+
"match": "(?<![\\w$.])\\bdefer\\b(?=(?:[^\\S\\r\\n]|/\\*[^\\r\\n]*?\\*/)*\\{)",
|
|
141
|
+
"name": "keyword.control.twill"
|
|
142
|
+
},
|
|
143
|
+
"guard": {
|
|
144
|
+
"match": "(?<![\\w$.])\\bguard\\b(?=\\s+(?:const\\b|[^\\s;=:]))",
|
|
145
|
+
"name": "keyword.control.twill"
|
|
146
|
+
},
|
|
147
|
+
"guard-binding": {
|
|
148
|
+
"name": "meta.guard.binding.twill",
|
|
149
|
+
"begin": "(?<![\\w$.])\\b(guard)\\s+(const)\\b",
|
|
150
|
+
"beginCaptures": {
|
|
151
|
+
"1": { "name": "keyword.control.twill" },
|
|
152
|
+
"2": { "name": "storage.type.tsx" }
|
|
153
|
+
},
|
|
154
|
+
"end": "(?<![\\w$.])\\belse\\b(?=\\s*\\{)",
|
|
155
|
+
"endCaptures": { "0": { "name": "keyword.control.twill" } },
|
|
156
|
+
"patterns": [
|
|
157
|
+
{ "include": "source.tsx#object-binding-pattern-const" },
|
|
158
|
+
{ "include": "source.tsx#array-binding-pattern-const" },
|
|
159
|
+
{ "include": "source.tsx" }
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
"switch-expression": {
|
|
163
|
+
"name": "meta.switch.expression.twill",
|
|
164
|
+
"begin": "(?<![\\w$.])(switch)\\b(?=\\s*\\()",
|
|
165
|
+
"beginCaptures": { "1": { "name": "keyword.control.twill" } },
|
|
166
|
+
"end": "\\}",
|
|
167
|
+
"endCaptures": { "0": { "name": "punctuation.section.block.end.twill" } },
|
|
168
|
+
"patterns": [
|
|
169
|
+
{ "include": "source.tsx#comment" },
|
|
170
|
+
{
|
|
171
|
+
"begin": "\\(",
|
|
172
|
+
"end": "\\)",
|
|
173
|
+
"patterns": [{ "include": "source.tsx#expression" }]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"begin": "\\{",
|
|
177
|
+
"end": "(?=\\})",
|
|
178
|
+
"patterns": [{
|
|
179
|
+
"begin": "(?<![\\w$.])(case|default)\\b",
|
|
180
|
+
"beginCaptures": { "1": { "name": "keyword.control.twill" } },
|
|
181
|
+
"end": "(?=:)",
|
|
182
|
+
"patterns": [{ "include": "source.tsx#expression" }]
|
|
183
|
+
}, { "include": "source.tsx#statements" }]
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
"closure-header": {
|
|
188
|
+
"begin": "(\\{)(?=\\s*(?:async\\s+)?(?:[A-Za-z_$][\\w$]*(?:\\s*,\\s*[A-Za-z_$][\\w$]*)*|\\((?:[^;()]|\\([^()]*\\))*\\)(?:\\s*:[^;{}]*?)?)\\s+in\\b)",
|
|
189
|
+
"beginCaptures": { "1": { "name": "punctuation.section.block.begin.twill" } },
|
|
190
|
+
"end": "\\}",
|
|
191
|
+
"endCaptures": { "0": { "name": "punctuation.section.block.end.twill" } },
|
|
192
|
+
"name": "meta.trailing.closure.twill",
|
|
193
|
+
"patterns": [
|
|
194
|
+
{
|
|
195
|
+
"begin": "(?<=\\{)",
|
|
196
|
+
"end": "\\bin\\b",
|
|
197
|
+
"endCaptures": { "0": { "name": "keyword.control.twill" } },
|
|
198
|
+
"patterns": [
|
|
199
|
+
{ "include": "source.tsx#comment" },
|
|
200
|
+
{
|
|
201
|
+
"match": "\\basync\\b",
|
|
202
|
+
"name": "storage.modifier.tsx"
|
|
203
|
+
},
|
|
204
|
+
{ "include": "source.tsx#function-parameters" },
|
|
205
|
+
{
|
|
206
|
+
"begin": ":",
|
|
207
|
+
"end": "(?=\\bin\\b)",
|
|
208
|
+
"patterns": [{ "include": "source.tsx#type" }]
|
|
209
|
+
},
|
|
210
|
+
{ "include": "source.tsx#parameter-name" }
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
{ "include": "source.tsx#jsx-tag-without-attributes" },
|
|
214
|
+
{ "include": "source.tsx#jsx-tag" },
|
|
215
|
+
{ "include": "source.tsx#statements" }
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
injections: { "L:source.twill.tsx -comment -string, L:source.twill.tsx meta.template.expression -comment -(meta.template.expression string)": { "patterns": [
|
|
220
|
+
{ "include": "#implicit-member" },
|
|
221
|
+
{ "include": "#defer" },
|
|
222
|
+
{ "include": "#guard-binding" },
|
|
223
|
+
{ "include": "#guard" },
|
|
224
|
+
{ "include": "#switch-expression" },
|
|
225
|
+
{ "include": "#closure-header" }
|
|
226
|
+
] } }
|
|
227
|
+
};
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/index.ts
|
|
230
|
+
/** Engine-independent TextMate grammars; load the TS/TSX base grammars too. */
|
|
231
|
+
var twill = {
|
|
232
|
+
...twill_tmLanguage_default,
|
|
233
|
+
name: "twill",
|
|
234
|
+
aliases: ["Twill"]
|
|
235
|
+
};
|
|
236
|
+
var twillx = {
|
|
237
|
+
...twillx_tmLanguage_default,
|
|
238
|
+
name: "twillx",
|
|
239
|
+
aliases: ["TwillX"]
|
|
240
|
+
};
|
|
241
|
+
var twillLanguages = [twill, twillx];
|
|
242
|
+
//#endregion
|
|
243
|
+
export { twillLanguages as n, twillx as r, twill as t };
|
|
244
|
+
|
|
245
|
+
//# sourceMappingURL=src-B8qil4uJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-B8qil4uJ.js","names":["name","scopeName","patterns","repository","injections","ts","tsx"],"sources":["../grammars/twill.tmLanguage.json","../grammars/twillx.tmLanguage.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"Twill ts\",\n \"scopeName\": \"source.twill.ts\",\n \"patterns\": [\n {\n \"include\": \"#implicit-member\"\n },\n {\n \"include\": \"#defer\"\n },\n {\n \"include\": \"#guard-binding\"\n },\n {\n \"include\": \"#guard\"\n },\n {\n \"include\": \"#switch-expression\"\n },\n {\n \"include\": \"#closure-header\"\n },\n {\n \"match\": \"(?<=\\\\})\\\\s*\\\\b([A-Za-z_$][\\\\w$]*)(\\\\s*:)(?=\\\\s*\\\\{)\",\n \"captures\": {\n \"1\": {\n \"name\": \"entity.name.function.twill\"\n },\n \"2\": {\n \"name\": \"punctuation.separator.twill\"\n }\n }\n },\n {\n \"include\": \"source.ts\"\n }\n ],\n \"repository\": {\n \"implicit-member\": {\n \"match\": \"(?<![\\\\w$.)}\\\\]])(\\\\.)([A-Za-z_$][\\\\w$]*)\",\n \"captures\": {\n \"1\": {\n \"name\": \"punctuation.accessor.twill\"\n },\n \"2\": {\n \"name\": \"variable.other.property.twill\"\n }\n }\n },\n \"defer\": {\n \"match\": \"(?<![\\\\w$.])\\\\bdefer\\\\b(?=(?:[^\\\\S\\\\r\\\\n]|/\\\\*[^\\\\r\\\\n]*?\\\\*/)*\\\\{)\",\n \"name\": \"keyword.control.twill\"\n },\n \"guard\": {\n \"match\": \"(?<![\\\\w$.])\\\\bguard\\\\b(?=\\\\s+(?:const\\\\b|[^\\\\s;=:]))\",\n \"name\": \"keyword.control.twill\"\n },\n \"guard-binding\": {\n \"name\": \"meta.guard.binding.twill\",\n \"begin\": \"(?<![\\\\w$.])\\\\b(guard)\\\\s+(const)\\\\b\",\n \"beginCaptures\": {\n \"1\": {\n \"name\": \"keyword.control.twill\"\n },\n \"2\": {\n \"name\": \"storage.type.ts\"\n }\n },\n \"end\": \"(?<![\\\\w$.])\\\\belse\\\\b(?=\\\\s*\\\\{)\",\n \"endCaptures\": {\n \"0\": {\n \"name\": \"keyword.control.twill\"\n }\n },\n \"patterns\": [\n {\n \"include\": \"source.ts#object-binding-pattern-const\"\n },\n {\n \"include\": \"source.ts#array-binding-pattern-const\"\n },\n {\n \"include\": \"source.ts\"\n }\n ]\n },\n \"switch-expression\": {\n \"name\": \"meta.switch.expression.twill\",\n \"begin\": \"(?<![\\\\w$.])(switch)\\\\b(?=\\\\s*\\\\()\",\n \"beginCaptures\": {\n \"1\": {\n \"name\": \"keyword.control.twill\"\n }\n },\n \"end\": \"\\\\}\",\n \"endCaptures\": {\n \"0\": {\n \"name\": \"punctuation.section.block.end.twill\"\n }\n },\n \"patterns\": [\n {\n \"include\": \"source.ts#comment\"\n },\n {\n \"begin\": \"\\\\(\",\n \"end\": \"\\\\)\",\n \"patterns\": [\n {\n \"include\": \"source.ts#expression\"\n }\n ]\n },\n {\n \"begin\": \"\\\\{\",\n \"end\": \"(?=\\\\})\",\n \"patterns\": [\n {\n \"begin\": \"(?<![\\\\w$.])(case|default)\\\\b\",\n \"beginCaptures\": {\n \"1\": {\n \"name\": \"keyword.control.twill\"\n }\n },\n \"end\": \"(?=:)\",\n \"patterns\": [\n {\n \"include\": \"source.ts#expression\"\n }\n ]\n },\n {\n \"include\": \"source.ts#statements\"\n }\n ]\n }\n ]\n },\n \"closure-header\": {\n \"begin\": \"(\\\\{)(?=\\\\s*(?:async\\\\s+)?(?:[A-Za-z_$][\\\\w$]*(?:\\\\s*,\\\\s*[A-Za-z_$][\\\\w$]*)*|\\\\((?:[^;()]|\\\\([^()]*\\\\))*\\\\)(?:\\\\s*:[^;{}]*?)?)\\\\s+in\\\\b)\",\n \"beginCaptures\": {\n \"1\": {\n \"name\": \"punctuation.section.block.begin.twill\"\n }\n },\n \"end\": \"\\\\}\",\n \"endCaptures\": {\n \"0\": {\n \"name\": \"punctuation.section.block.end.twill\"\n }\n },\n \"name\": \"meta.trailing.closure.twill\",\n \"patterns\": [\n {\n \"begin\": \"(?<=\\\\{)\",\n \"end\": \"\\\\bin\\\\b\",\n \"endCaptures\": {\n \"0\": {\n \"name\": \"keyword.control.twill\"\n }\n },\n \"patterns\": [\n {\n \"include\": \"source.ts#comment\"\n },\n {\n \"match\": \"\\\\basync\\\\b\",\n \"name\": \"storage.modifier.ts\"\n },\n {\n \"include\": \"source.ts#function-parameters\"\n },\n {\n \"begin\": \":\",\n \"end\": \"(?=\\\\bin\\\\b)\",\n \"patterns\": [\n {\n \"include\": \"source.ts#type\"\n }\n ]\n },\n {\n \"include\": \"source.ts#parameter-name\"\n }\n ]\n },\n {\n \"include\": \"source.ts#statements\"\n }\n ]\n }\n },\n \"injections\": {\n \"L:source.twill.ts -comment -string, L:source.twill.ts meta.template.expression -comment -(meta.template.expression string)\": {\n \"patterns\": [\n {\n \"include\": \"#implicit-member\"\n },\n {\n \"include\": \"#defer\"\n },\n {\n \"include\": \"#guard-binding\"\n },\n {\n \"include\": \"#guard\"\n },\n {\n \"include\": \"#switch-expression\"\n },\n {\n \"include\": \"#closure-header\"\n }\n ]\n }\n }\n}\n","{\n \"name\": \"Twill tsx\",\n \"scopeName\": \"source.twill.tsx\",\n \"patterns\": [\n {\n \"include\": \"#implicit-member\"\n },\n {\n \"include\": \"#defer\"\n },\n {\n \"include\": \"#guard-binding\"\n },\n {\n \"include\": \"#guard\"\n },\n {\n \"include\": \"#switch-expression\"\n },\n {\n \"include\": \"#closure-header\"\n },\n {\n \"match\": \"(?<=\\\\})\\\\s*\\\\b([A-Za-z_$][\\\\w$]*)(\\\\s*:)(?=\\\\s*\\\\{)\",\n \"captures\": {\n \"1\": {\n \"name\": \"entity.name.function.twill\"\n },\n \"2\": {\n \"name\": \"punctuation.separator.twill\"\n }\n }\n },\n {\n \"include\": \"source.tsx\"\n }\n ],\n \"repository\": {\n \"implicit-member\": {\n \"match\": \"(?<![\\\\w$.)}\\\\]])(\\\\.)([A-Za-z_$][\\\\w$]*)\",\n \"captures\": {\n \"1\": {\n \"name\": \"punctuation.accessor.twill\"\n },\n \"2\": {\n \"name\": \"variable.other.property.twill\"\n }\n }\n },\n \"defer\": {\n \"match\": \"(?<![\\\\w$.])\\\\bdefer\\\\b(?=(?:[^\\\\S\\\\r\\\\n]|/\\\\*[^\\\\r\\\\n]*?\\\\*/)*\\\\{)\",\n \"name\": \"keyword.control.twill\"\n },\n \"guard\": {\n \"match\": \"(?<![\\\\w$.])\\\\bguard\\\\b(?=\\\\s+(?:const\\\\b|[^\\\\s;=:]))\",\n \"name\": \"keyword.control.twill\"\n },\n \"guard-binding\": {\n \"name\": \"meta.guard.binding.twill\",\n \"begin\": \"(?<![\\\\w$.])\\\\b(guard)\\\\s+(const)\\\\b\",\n \"beginCaptures\": {\n \"1\": {\n \"name\": \"keyword.control.twill\"\n },\n \"2\": {\n \"name\": \"storage.type.tsx\"\n }\n },\n \"end\": \"(?<![\\\\w$.])\\\\belse\\\\b(?=\\\\s*\\\\{)\",\n \"endCaptures\": {\n \"0\": {\n \"name\": \"keyword.control.twill\"\n }\n },\n \"patterns\": [\n {\n \"include\": \"source.tsx#object-binding-pattern-const\"\n },\n {\n \"include\": \"source.tsx#array-binding-pattern-const\"\n },\n {\n \"include\": \"source.tsx\"\n }\n ]\n },\n \"switch-expression\": {\n \"name\": \"meta.switch.expression.twill\",\n \"begin\": \"(?<![\\\\w$.])(switch)\\\\b(?=\\\\s*\\\\()\",\n \"beginCaptures\": {\n \"1\": {\n \"name\": \"keyword.control.twill\"\n }\n },\n \"end\": \"\\\\}\",\n \"endCaptures\": {\n \"0\": {\n \"name\": \"punctuation.section.block.end.twill\"\n }\n },\n \"patterns\": [\n {\n \"include\": \"source.tsx#comment\"\n },\n {\n \"begin\": \"\\\\(\",\n \"end\": \"\\\\)\",\n \"patterns\": [\n {\n \"include\": \"source.tsx#expression\"\n }\n ]\n },\n {\n \"begin\": \"\\\\{\",\n \"end\": \"(?=\\\\})\",\n \"patterns\": [\n {\n \"begin\": \"(?<![\\\\w$.])(case|default)\\\\b\",\n \"beginCaptures\": {\n \"1\": {\n \"name\": \"keyword.control.twill\"\n }\n },\n \"end\": \"(?=:)\",\n \"patterns\": [\n {\n \"include\": \"source.tsx#expression\"\n }\n ]\n },\n {\n \"include\": \"source.tsx#statements\"\n }\n ]\n }\n ]\n },\n \"closure-header\": {\n \"begin\": \"(\\\\{)(?=\\\\s*(?:async\\\\s+)?(?:[A-Za-z_$][\\\\w$]*(?:\\\\s*,\\\\s*[A-Za-z_$][\\\\w$]*)*|\\\\((?:[^;()]|\\\\([^()]*\\\\))*\\\\)(?:\\\\s*:[^;{}]*?)?)\\\\s+in\\\\b)\",\n \"beginCaptures\": {\n \"1\": {\n \"name\": \"punctuation.section.block.begin.twill\"\n }\n },\n \"end\": \"\\\\}\",\n \"endCaptures\": {\n \"0\": {\n \"name\": \"punctuation.section.block.end.twill\"\n }\n },\n \"name\": \"meta.trailing.closure.twill\",\n \"patterns\": [\n {\n \"begin\": \"(?<=\\\\{)\",\n \"end\": \"\\\\bin\\\\b\",\n \"endCaptures\": {\n \"0\": {\n \"name\": \"keyword.control.twill\"\n }\n },\n \"patterns\": [\n {\n \"include\": \"source.tsx#comment\"\n },\n {\n \"match\": \"\\\\basync\\\\b\",\n \"name\": \"storage.modifier.tsx\"\n },\n {\n \"include\": \"source.tsx#function-parameters\"\n },\n {\n \"begin\": \":\",\n \"end\": \"(?=\\\\bin\\\\b)\",\n \"patterns\": [\n {\n \"include\": \"source.tsx#type\"\n }\n ]\n },\n {\n \"include\": \"source.tsx#parameter-name\"\n }\n ]\n },\n {\n \"include\": \"source.tsx#jsx-tag-without-attributes\"\n },\n {\n \"include\": \"source.tsx#jsx-tag\"\n },\n {\n \"include\": \"source.tsx#statements\"\n }\n ]\n }\n },\n \"injections\": {\n \"L:source.twill.tsx -comment -string, L:source.twill.tsx meta.template.expression -comment -(meta.template.expression string)\": {\n \"patterns\": [\n {\n \"include\": \"#implicit-member\"\n },\n {\n \"include\": \"#defer\"\n },\n {\n \"include\": \"#guard-binding\"\n },\n {\n \"include\": \"#guard\"\n },\n {\n \"include\": \"#switch-expression\"\n },\n {\n \"include\": \"#closure-header\"\n }\n ]\n }\n }\n}\n","import ts from '../grammars/twill.tmLanguage.json';\nimport tsx from '../grammars/twillx.tmLanguage.json';\n\n/** The TextMate rule fields used by Twill, independent of an engine's types. */\nexport interface TextMateRule {\n name?: string;\n include?: string;\n match?: string;\n begin?: string;\n end?: string;\n captures?: Record<string, TextMateRule>;\n beginCaptures?: Record<string, TextMateRule>;\n endCaptures?: Record<string, TextMateRule>;\n patterns?: TextMateRule[];\n}\n\nexport interface TwillGrammar {\n name: string;\n aliases: string[];\n scopeName: string;\n patterns: TextMateRule[];\n repository: Record<string, TextMateRule>;\n injections: Record<string, TextMateRule>;\n}\n\n/** Engine-independent TextMate grammars; load the TS/TSX base grammars too. */\nexport const twill: TwillGrammar = { ...ts, name: 'twill', aliases: ['Twill'] };\nexport const twillx: TwillGrammar = { ...tsx, name: 'twillx', aliases: ['TwillX'] };\nexport const twillLanguages = [twill, twillx];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AE0BA,IAAa,QAAsB;CAAE,GAAGK;CAAI,MAAM;CAAS,SAAS,CAAC,OAAO;AAAE;AAC9E,IAAa,SAAuB;CAAE,GAAGC;CAAK,MAAM;CAAU,SAAS,CAAC,QAAQ;AAAE;AAClF,IAAa,iBAAiB,CAAC,OAAO,MAAM"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Twill ts",
|
|
3
|
+
"scopeName": "source.twill.ts",
|
|
4
|
+
"patterns": [
|
|
5
|
+
{
|
|
6
|
+
"include": "#implicit-member"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"include": "#defer"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"include": "#guard-binding"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"include": "#guard"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"include": "#switch-expression"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"include": "#closure-header"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"match": "(?<=\\})\\s*\\b([A-Za-z_$][\\w$]*)(\\s*:)(?=\\s*\\{)",
|
|
25
|
+
"captures": {
|
|
26
|
+
"1": {
|
|
27
|
+
"name": "entity.name.function.twill"
|
|
28
|
+
},
|
|
29
|
+
"2": {
|
|
30
|
+
"name": "punctuation.separator.twill"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"include": "source.ts"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"repository": {
|
|
39
|
+
"implicit-member": {
|
|
40
|
+
"match": "(?<![\\w$.)}\\]])(\\.)([A-Za-z_$][\\w$]*)",
|
|
41
|
+
"captures": {
|
|
42
|
+
"1": {
|
|
43
|
+
"name": "punctuation.accessor.twill"
|
|
44
|
+
},
|
|
45
|
+
"2": {
|
|
46
|
+
"name": "variable.other.property.twill"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"defer": {
|
|
51
|
+
"match": "(?<![\\w$.])\\bdefer\\b(?=(?:[^\\S\\r\\n]|/\\*[^\\r\\n]*?\\*/)*\\{)",
|
|
52
|
+
"name": "keyword.control.twill"
|
|
53
|
+
},
|
|
54
|
+
"guard": {
|
|
55
|
+
"match": "(?<![\\w$.])\\bguard\\b(?=\\s+(?:const\\b|[^\\s;=:]))",
|
|
56
|
+
"name": "keyword.control.twill"
|
|
57
|
+
},
|
|
58
|
+
"guard-binding": {
|
|
59
|
+
"name": "meta.guard.binding.twill",
|
|
60
|
+
"begin": "(?<![\\w$.])\\b(guard)\\s+(const)\\b",
|
|
61
|
+
"beginCaptures": {
|
|
62
|
+
"1": {
|
|
63
|
+
"name": "keyword.control.twill"
|
|
64
|
+
},
|
|
65
|
+
"2": {
|
|
66
|
+
"name": "storage.type.ts"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"end": "(?<![\\w$.])\\belse\\b(?=\\s*\\{)",
|
|
70
|
+
"endCaptures": {
|
|
71
|
+
"0": {
|
|
72
|
+
"name": "keyword.control.twill"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"patterns": [
|
|
76
|
+
{
|
|
77
|
+
"include": "source.ts#object-binding-pattern-const"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"include": "source.ts#array-binding-pattern-const"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"include": "source.ts"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"switch-expression": {
|
|
88
|
+
"name": "meta.switch.expression.twill",
|
|
89
|
+
"begin": "(?<![\\w$.])(switch)\\b(?=\\s*\\()",
|
|
90
|
+
"beginCaptures": {
|
|
91
|
+
"1": {
|
|
92
|
+
"name": "keyword.control.twill"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"end": "\\}",
|
|
96
|
+
"endCaptures": {
|
|
97
|
+
"0": {
|
|
98
|
+
"name": "punctuation.section.block.end.twill"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"patterns": [
|
|
102
|
+
{
|
|
103
|
+
"include": "source.ts#comment"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"begin": "\\(",
|
|
107
|
+
"end": "\\)",
|
|
108
|
+
"patterns": [
|
|
109
|
+
{
|
|
110
|
+
"include": "source.ts#expression"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"begin": "\\{",
|
|
116
|
+
"end": "(?=\\})",
|
|
117
|
+
"patterns": [
|
|
118
|
+
{
|
|
119
|
+
"begin": "(?<![\\w$.])(case|default)\\b",
|
|
120
|
+
"beginCaptures": {
|
|
121
|
+
"1": {
|
|
122
|
+
"name": "keyword.control.twill"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"end": "(?=:)",
|
|
126
|
+
"patterns": [
|
|
127
|
+
{
|
|
128
|
+
"include": "source.ts#expression"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"include": "source.ts#statements"
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"closure-header": {
|
|
140
|
+
"begin": "(\\{)(?=\\s*(?:async\\s+)?(?:[A-Za-z_$][\\w$]*(?:\\s*,\\s*[A-Za-z_$][\\w$]*)*|\\((?:[^;()]|\\([^()]*\\))*\\)(?:\\s*:[^;{}]*?)?)\\s+in\\b)",
|
|
141
|
+
"beginCaptures": {
|
|
142
|
+
"1": {
|
|
143
|
+
"name": "punctuation.section.block.begin.twill"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"end": "\\}",
|
|
147
|
+
"endCaptures": {
|
|
148
|
+
"0": {
|
|
149
|
+
"name": "punctuation.section.block.end.twill"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"name": "meta.trailing.closure.twill",
|
|
153
|
+
"patterns": [
|
|
154
|
+
{
|
|
155
|
+
"begin": "(?<=\\{)",
|
|
156
|
+
"end": "\\bin\\b",
|
|
157
|
+
"endCaptures": {
|
|
158
|
+
"0": {
|
|
159
|
+
"name": "keyword.control.twill"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"patterns": [
|
|
163
|
+
{
|
|
164
|
+
"include": "source.ts#comment"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"match": "\\basync\\b",
|
|
168
|
+
"name": "storage.modifier.ts"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"include": "source.ts#function-parameters"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"begin": ":",
|
|
175
|
+
"end": "(?=\\bin\\b)",
|
|
176
|
+
"patterns": [
|
|
177
|
+
{
|
|
178
|
+
"include": "source.ts#type"
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"include": "source.ts#parameter-name"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"include": "source.ts#statements"
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
"injections": {
|
|
194
|
+
"L:source.twill.ts -comment -string, L:source.twill.ts meta.template.expression -comment -(meta.template.expression string)": {
|
|
195
|
+
"patterns": [
|
|
196
|
+
{
|
|
197
|
+
"include": "#implicit-member"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"include": "#defer"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"include": "#guard-binding"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"include": "#guard"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"include": "#switch-expression"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"include": "#closure-header"
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Twill tsx",
|
|
3
|
+
"scopeName": "source.twill.tsx",
|
|
4
|
+
"patterns": [
|
|
5
|
+
{
|
|
6
|
+
"include": "#implicit-member"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"include": "#defer"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"include": "#guard-binding"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"include": "#guard"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"include": "#switch-expression"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"include": "#closure-header"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"match": "(?<=\\})\\s*\\b([A-Za-z_$][\\w$]*)(\\s*:)(?=\\s*\\{)",
|
|
25
|
+
"captures": {
|
|
26
|
+
"1": {
|
|
27
|
+
"name": "entity.name.function.twill"
|
|
28
|
+
},
|
|
29
|
+
"2": {
|
|
30
|
+
"name": "punctuation.separator.twill"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"include": "source.tsx"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"repository": {
|
|
39
|
+
"implicit-member": {
|
|
40
|
+
"match": "(?<![\\w$.)}\\]])(\\.)([A-Za-z_$][\\w$]*)",
|
|
41
|
+
"captures": {
|
|
42
|
+
"1": {
|
|
43
|
+
"name": "punctuation.accessor.twill"
|
|
44
|
+
},
|
|
45
|
+
"2": {
|
|
46
|
+
"name": "variable.other.property.twill"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"defer": {
|
|
51
|
+
"match": "(?<![\\w$.])\\bdefer\\b(?=(?:[^\\S\\r\\n]|/\\*[^\\r\\n]*?\\*/)*\\{)",
|
|
52
|
+
"name": "keyword.control.twill"
|
|
53
|
+
},
|
|
54
|
+
"guard": {
|
|
55
|
+
"match": "(?<![\\w$.])\\bguard\\b(?=\\s+(?:const\\b|[^\\s;=:]))",
|
|
56
|
+
"name": "keyword.control.twill"
|
|
57
|
+
},
|
|
58
|
+
"guard-binding": {
|
|
59
|
+
"name": "meta.guard.binding.twill",
|
|
60
|
+
"begin": "(?<![\\w$.])\\b(guard)\\s+(const)\\b",
|
|
61
|
+
"beginCaptures": {
|
|
62
|
+
"1": {
|
|
63
|
+
"name": "keyword.control.twill"
|
|
64
|
+
},
|
|
65
|
+
"2": {
|
|
66
|
+
"name": "storage.type.tsx"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"end": "(?<![\\w$.])\\belse\\b(?=\\s*\\{)",
|
|
70
|
+
"endCaptures": {
|
|
71
|
+
"0": {
|
|
72
|
+
"name": "keyword.control.twill"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"patterns": [
|
|
76
|
+
{
|
|
77
|
+
"include": "source.tsx#object-binding-pattern-const"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"include": "source.tsx#array-binding-pattern-const"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"include": "source.tsx"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"switch-expression": {
|
|
88
|
+
"name": "meta.switch.expression.twill",
|
|
89
|
+
"begin": "(?<![\\w$.])(switch)\\b(?=\\s*\\()",
|
|
90
|
+
"beginCaptures": {
|
|
91
|
+
"1": {
|
|
92
|
+
"name": "keyword.control.twill"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"end": "\\}",
|
|
96
|
+
"endCaptures": {
|
|
97
|
+
"0": {
|
|
98
|
+
"name": "punctuation.section.block.end.twill"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"patterns": [
|
|
102
|
+
{
|
|
103
|
+
"include": "source.tsx#comment"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"begin": "\\(",
|
|
107
|
+
"end": "\\)",
|
|
108
|
+
"patterns": [
|
|
109
|
+
{
|
|
110
|
+
"include": "source.tsx#expression"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"begin": "\\{",
|
|
116
|
+
"end": "(?=\\})",
|
|
117
|
+
"patterns": [
|
|
118
|
+
{
|
|
119
|
+
"begin": "(?<![\\w$.])(case|default)\\b",
|
|
120
|
+
"beginCaptures": {
|
|
121
|
+
"1": {
|
|
122
|
+
"name": "keyword.control.twill"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"end": "(?=:)",
|
|
126
|
+
"patterns": [
|
|
127
|
+
{
|
|
128
|
+
"include": "source.tsx#expression"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"include": "source.tsx#statements"
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"closure-header": {
|
|
140
|
+
"begin": "(\\{)(?=\\s*(?:async\\s+)?(?:[A-Za-z_$][\\w$]*(?:\\s*,\\s*[A-Za-z_$][\\w$]*)*|\\((?:[^;()]|\\([^()]*\\))*\\)(?:\\s*:[^;{}]*?)?)\\s+in\\b)",
|
|
141
|
+
"beginCaptures": {
|
|
142
|
+
"1": {
|
|
143
|
+
"name": "punctuation.section.block.begin.twill"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"end": "\\}",
|
|
147
|
+
"endCaptures": {
|
|
148
|
+
"0": {
|
|
149
|
+
"name": "punctuation.section.block.end.twill"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"name": "meta.trailing.closure.twill",
|
|
153
|
+
"patterns": [
|
|
154
|
+
{
|
|
155
|
+
"begin": "(?<=\\{)",
|
|
156
|
+
"end": "\\bin\\b",
|
|
157
|
+
"endCaptures": {
|
|
158
|
+
"0": {
|
|
159
|
+
"name": "keyword.control.twill"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"patterns": [
|
|
163
|
+
{
|
|
164
|
+
"include": "source.tsx#comment"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"match": "\\basync\\b",
|
|
168
|
+
"name": "storage.modifier.tsx"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"include": "source.tsx#function-parameters"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"begin": ":",
|
|
175
|
+
"end": "(?=\\bin\\b)",
|
|
176
|
+
"patterns": [
|
|
177
|
+
{
|
|
178
|
+
"include": "source.tsx#type"
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"include": "source.tsx#parameter-name"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"include": "source.tsx#jsx-tag-without-attributes"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"include": "source.tsx#jsx-tag"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"include": "source.tsx#statements"
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"injections": {
|
|
200
|
+
"L:source.twill.tsx -comment -string, L:source.twill.tsx meta.template.expression -comment -(meta.template.expression string)": {
|
|
201
|
+
"patterns": [
|
|
202
|
+
{
|
|
203
|
+
"include": "#implicit-member"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"include": "#defer"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"include": "#guard-binding"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"include": "#guard"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"include": "#switch-expression"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"include": "#closure-header"
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swiftuijs/twill-highlight",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Portable Twill and TwillX TextMate grammars and browser-compatible Shiki highlighting.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/swiftuijs/twill.git",
|
|
10
|
+
"directory": "packages/highlight"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://swiftuijs.github.io/twill/",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/swiftuijs/twill/issues"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"grammars",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./shiki": {
|
|
29
|
+
"types": "./dist/shiki.d.ts",
|
|
30
|
+
"import": "./dist/shiki.js"
|
|
31
|
+
},
|
|
32
|
+
"./grammars/twill": "./grammars/twill.tmLanguage.json",
|
|
33
|
+
"./grammars/twillx": "./grammars/twillx.tmLanguage.json"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=20"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"shiki": "^2.5.0 || ^3.0.0 || ^4.0.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"shiki": {
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"shiki": "^4.5.0",
|
|
51
|
+
"typescript": "5.9.3",
|
|
52
|
+
"vite": "^8.3.2",
|
|
53
|
+
"vite-plugin-dts": "^5.1.2",
|
|
54
|
+
"@types/node": "^26.6.4",
|
|
55
|
+
"vitest": "^5.0.3",
|
|
56
|
+
"@vitest/coverage-v8": "^5.0.3",
|
|
57
|
+
"@playwright/test": "^1.63.0"
|
|
58
|
+
},
|
|
59
|
+
"author": {
|
|
60
|
+
"name": "forth.ink",
|
|
61
|
+
"url": "https://forth.ink"
|
|
62
|
+
},
|
|
63
|
+
"keywords": [
|
|
64
|
+
"twill",
|
|
65
|
+
"shiki",
|
|
66
|
+
"syntax-highlighting",
|
|
67
|
+
"textmate",
|
|
68
|
+
"typescript"
|
|
69
|
+
],
|
|
70
|
+
"scripts": {
|
|
71
|
+
"build": "vite build",
|
|
72
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
73
|
+
"test:unit": "vitest run",
|
|
74
|
+
"test:coverage": "vitest run --coverage",
|
|
75
|
+
"test:package": "node tests/consumer.mjs",
|
|
76
|
+
"test:browser": "playwright test"
|
|
77
|
+
}
|
|
6
78
|
}
|