codemirror-lang-glimmer 0.0.0-beta.1 → 0.0.0-beta.2

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.
@@ -0,0 +1,21 @@
1
+
2
+ > codemirror-lang-glimmer@0.0.0-beta.2 build /home/runner/work/glimdown/glimdown/packages/codemirror/glimmer
3
+ > rollup -c
4
+
5
+ (node:1869) ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language. Avoid relying on their current behavior and syntax as those might change in a future version of Node.js.
6
+ (Use `node --trace-warnings ...` to show where the warning was created)
7
+ 
8
+ src/index.ts → dist/index.cjs, ./dist...
9
+ (node:1869) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
10
+ (!) Plugin rollup-plugin-lezer: Unused rule 'Text' (/home/runner/work/glimdown/glimdown/packages/codemirror/glimmer/src/syntax.grammar 102:2)
11
+ (!) Plugin rollup-plugin-lezer: Unused rule 'space' (/home/runner/work/glimdown/glimdown/packages/codemirror/glimmer/src/syntax.grammar 103:2)
12
+ (!) Plugin rollup-plugin-lezer: Unused rule 'attributeValueContentCharDouble' (/home/runner/work/glimdown/glimdown/packages/codemirror/glimmer/src/syntax.grammar 122:2)
13
+ (!) Plugin rollup-plugin-lezer: Unused rule 'attributeValueContentCharSingle' (/home/runner/work/glimdown/glimdown/packages/codemirror/glimmer/src/syntax.grammar 123:2)
14
+ (!) Plugin rollup-plugin-lezer: Unused rule 'Function' (/home/runner/work/glimdown/glimdown/packages/codemirror/glimmer/src/syntax.grammar 25:0)
15
+ (!) Plugin rollup-plugin-lezer: Unused rule 'String' (/home/runner/work/glimdown/glimdown/packages/codemirror/glimmer/src/syntax.grammar 50:0)
16
+ (!) Plugin rollup-plugin-lezer: Unused rule 'attributeValueContentDouble' (/home/runner/work/glimdown/glimdown/packages/codemirror/glimmer/src/syntax.grammar 56:0)
17
+ (!) Plugin rollup-plugin-lezer: Unused rule 'attributeValueContentSingle' (/home/runner/work/glimdown/glimdown/packages/codemirror/glimmer/src/syntax.grammar 60:0)
18
+ (!) Plugin rollup-plugin-lezer: Unused rule 'attributeValueContentEntity' (/home/runner/work/glimdown/glimdown/packages/codemirror/glimmer/src/syntax.grammar 64:0)
19
+ (!) Plugin rollup-plugin-lezer: Precedence specified for unknown token attributeValueContentCharDouble (/home/runner/work/glimdown/glimdown/packages/codemirror/glimmer/src/syntax.grammar 125:16)
20
+ (!) Plugin rollup-plugin-lezer: Precedence specified for unknown token attributeValueContentCharSingle (/home/runner/work/glimdown/glimdown/packages/codemirror/glimmer/src/syntax.grammar 126:16)
21
+ created dist/index.cjs, ./dist in 1.8s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # codemirror-lang-glimmer
2
2
 
3
+ ## 0.0.0-beta.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 40fd2df: Shipped built assets in the npm package
8
+
3
9
  ## 0.0.0-beta.1
4
10
 
5
11
  ### Minor Changes
package/dev/package.json CHANGED
@@ -4,12 +4,12 @@
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "vite .",
7
- "_:lint:js": "pnpm -w exec lint js",
8
- "_:lint:js:fix": "pnpm -w exec lint js:fix",
9
- "_:lint:prettier:fix": "pnpm -w exec lint prettier:fix",
10
- "_:lint:prettier": "pnpm -w exec lint prettier",
11
7
  "lint": "pnpm -w exec lint",
12
- "lint:fix": "pnpm -w exec lint fix"
8
+ "lint:fix": "pnpm -w exec lint fix",
9
+ "lint:js": "pnpm -w exec lint js",
10
+ "lint:js:fix": "pnpm -w exec lint js:fix",
11
+ "lint:prettier:fix": "pnpm -w exec lint prettier:fix",
12
+ "lint:prettier": "pnpm -w exec lint prettier"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@glimdown/codemirror-dev-preview": "workspace:*",
@@ -20,11 +20,14 @@
20
20
  "vite": "^4.3.5",
21
21
  "@babel/eslint-parser": "^7.21.8",
22
22
  "@nullvoxpopuli/eslint-configs": "^3.1.3",
23
- "@typescript-eslint/eslint-plugin": "^5.59.2",
24
- "@typescript-eslint/parser": "^5.59.2",
23
+ "@typescript-eslint/eslint-plugin": "^5.59.5",
24
+ "@typescript-eslint/parser": "^5.59.5",
25
25
  "eslint": "^8.40.0",
26
26
  "prettier": "^2.8.8",
27
27
  "typescript": "^5.0.4",
28
28
  "@babel/core": "^7.21.8"
29
+ },
30
+ "volta": {
31
+ "extends": "../../../../package.json"
29
32
  }
30
33
  }
package/dist/index.cjs ADDED
@@ -0,0 +1,407 @@
1
+ 'use strict';
2
+
3
+ var langHtml = require('@codemirror/lang-html');
4
+ var language = require('@codemirror/language');
5
+ var common = require('@lezer/common');
6
+ var html = require('@lezer/html');
7
+ var lr = require('@lezer/lr');
8
+ var highlight = require('@lezer/highlight');
9
+
10
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
11
+ const shortCommentContent$1 = 56,
12
+ longCommentContent$1 = 57,
13
+ htmlCommentContent$1 = 58,
14
+ templateTagContent$1 = 59,
15
+ MoustacheExpression = 9;
16
+
17
+ // Ascii values
18
+ const parenOpen = 40;
19
+ const parenClose = 41;
20
+ const squareOpen = 91;
21
+ const squareClose = 93;
22
+ const curlyOpen = 123;
23
+ const curlyClose = 125;
24
+ const colon = 58;
25
+ const hash = 35;
26
+ const at = 64;
27
+ const slash = 47;
28
+ const greaterThan = 62;
29
+ const dash = 45;
30
+ const quoteDouble = 34;
31
+ const quoteSingle = 39;
32
+ const backslash = 92;
33
+ const newline = 10;
34
+ const asterisk = 42;
35
+ const tick = 96;
36
+ const prefixes = [colon, hash, at, slash];
37
+ const shortCommentEnd = [curlyClose, curlyClose];
38
+ const longCommentEnd = [dash, dash, curlyClose, curlyClose];
39
+ const htmlCommentEnd = [dash, dash, greaterThan];
40
+ // Is there a way to make this a build time (rather than eval-time?) operation?
41
+ const closingTemplateTag = '</template>'.split('').map((char) => char.charCodeAt(0));
42
+ function matchForComment(commentEndPattern, commentToken, input) {
43
+ for (let found = 0, i = 0;; i++) {
44
+ if (input.next < 0) {
45
+ if (i)
46
+ input.acceptToken(commentToken);
47
+ break;
48
+ }
49
+ let hasMatch = commentEndPattern[found] === input.next;
50
+ if (!hasMatch) {
51
+ found = 0;
52
+ input.advance();
53
+ break;
54
+ }
55
+ if (found === commentEndPattern.length - 1) {
56
+ if (i > commentEndPattern.length - 1) {
57
+ input.acceptToken(commentToken, 1 - commentEndPattern.length);
58
+ break;
59
+ }
60
+ else {
61
+ console.warn('Reached end of comment but there is still content left');
62
+ }
63
+ break;
64
+ }
65
+ found++;
66
+ input.advance();
67
+ }
68
+ }
69
+ const shortCommentContent = new lr.ExternalTokenizer((input) => {
70
+ return matchForComment(shortCommentEnd, shortCommentContent$1, input);
71
+ });
72
+ const longCommentContent = new lr.ExternalTokenizer((input) => {
73
+ return matchForComment(longCommentEnd, longCommentContent$1, input);
74
+ });
75
+ const htmlCommentContent = new lr.ExternalTokenizer((input) => {
76
+ return matchForComment(htmlCommentEnd, htmlCommentContent$1, input);
77
+ });
78
+ const templateTagContent = new lr.ExternalTokenizer((input) => {
79
+ return matchForComment(closingTemplateTag, templateTagContent$1, input);
80
+ });
81
+ // TODO: string handler does not handle interpolation
82
+ function createStringHandler(input) {
83
+ let inString = false;
84
+ let inStringType = null;
85
+ let inStringIgnoreNext = false;
86
+ return () => {
87
+ if (inString) {
88
+ if (inStringIgnoreNext) {
89
+ inStringIgnoreNext = false;
90
+ return true;
91
+ }
92
+ if (input.next === backslash) {
93
+ inStringIgnoreNext = true;
94
+ return true;
95
+ }
96
+ if (inStringType === 'double' && input.next === quoteDouble) {
97
+ inString = false;
98
+ inStringType = null;
99
+ return true;
100
+ }
101
+ if (inStringType === 'single' && input.next === quoteSingle) {
102
+ inString = false;
103
+ inStringType = null;
104
+ return true;
105
+ }
106
+ if (inStringType === 'template' && input.next === tick) {
107
+ inString = false;
108
+ inStringType = null;
109
+ return true;
110
+ }
111
+ return true;
112
+ }
113
+ if (input.next === quoteDouble) {
114
+ inString = true;
115
+ inStringType = 'double';
116
+ return true;
117
+ }
118
+ if (input.next === quoteSingle) {
119
+ inString = true;
120
+ inStringType = 'single';
121
+ return true;
122
+ }
123
+ if (input.next === tick) {
124
+ inString = true;
125
+ inStringType = 'template';
126
+ return true;
127
+ }
128
+ return false;
129
+ };
130
+ }
131
+ function createCommentHandler(input) {
132
+ let inLineComment = false;
133
+ let inBlockComment = false;
134
+ return () => {
135
+ if (inLineComment) {
136
+ if (input.next === newline) {
137
+ inLineComment = false;
138
+ return true;
139
+ }
140
+ return true;
141
+ }
142
+ if (inBlockComment) {
143
+ if (input.next === asterisk && input.peek(1) === slash) {
144
+ inBlockComment = false;
145
+ return true;
146
+ }
147
+ return true;
148
+ }
149
+ if (input.next === slash && input.peek(1) === slash) {
150
+ inLineComment = true;
151
+ return true;
152
+ }
153
+ if (input.next === slash && input.peek(1) === asterisk) {
154
+ inBlockComment = true;
155
+ return true;
156
+ }
157
+ return false;
158
+ };
159
+ }
160
+ // closes on a delimiter that probably isn't in the expression
161
+ new lr.ExternalTokenizer((input) => {
162
+ if (prefixes.includes(input.next)) {
163
+ return;
164
+ }
165
+ const commentHandler = createCommentHandler(input);
166
+ const stringHandler = createStringHandler(input);
167
+ let stack = [];
168
+ const popIfMatch = (match) => {
169
+ const idx = stack.lastIndexOf(match);
170
+ if (idx !== -1) {
171
+ while (stack.length > idx) {
172
+ stack.pop();
173
+ }
174
+ }
175
+ };
176
+ for (let pos = 0;; pos++) {
177
+ // end of input
178
+ if (input.next < 0) {
179
+ if (pos > 0)
180
+ input.acceptToken(MoustacheExpression);
181
+ break;
182
+ }
183
+ if (commentHandler() || stringHandler()) {
184
+ input.advance();
185
+ continue;
186
+ }
187
+ if (stack.length === 0 &&
188
+ (input.next === curlyClose || input.next === parenClose || input.next === squareClose)) {
189
+ input.acceptToken(MoustacheExpression);
190
+ break;
191
+ }
192
+ switch (input.next) {
193
+ case parenOpen:
194
+ stack.push('(');
195
+ break;
196
+ case parenClose:
197
+ popIfMatch('(');
198
+ break;
199
+ case squareOpen:
200
+ stack.push('[');
201
+ break;
202
+ case squareClose:
203
+ popIfMatch('[');
204
+ break;
205
+ case curlyOpen:
206
+ stack.push('{');
207
+ break;
208
+ case curlyClose:
209
+ popIfMatch('{');
210
+ break;
211
+ }
212
+ input.advance();
213
+ }
214
+ });
215
+
216
+ const glimmerHighlighting = highlight.styleTags({
217
+ 'Text RawText': highlight.tags.content,
218
+ 'StartTag StartCloseTag SelfClosingEndTag EndTag': highlight.tags.angleBracket,
219
+ TagName: highlight.tags.tagName,
220
+ 'MismatchedCloseTag/TagName': [highlight.tags.tagName, highlight.tags.invalid],
221
+ AttributeName: highlight.tags.attributeName,
222
+ // Glimmer
223
+ TemplateTag: highlight.tags.definition(highlight.tags.annotation),
224
+ '{{ }}': highlight.tags.bracket,
225
+ '( )': highlight.tags.paren,
226
+ Function: highlight.tags.function(highlight.tags.name),
227
+ Splattributes: highlight.tags.derefOperator,
228
+ Comment: highlight.tags.blockComment,
229
+ ShortComment: highlight.tags.blockComment,
230
+ LongComment: highlight.tags.blockComment,
231
+ HtmlComment: highlight.tags.blockComment,
232
+ ArgName: highlight.tags.attributeName,
233
+ Argument: highlight.tags.propertyName,
234
+ NamedBlock: highlight.tags.tagName,
235
+ Is: highlight.tags.definitionOperator,
236
+ Pipe: highlight.tags.definitionOperator,
237
+ as: highlight.tags.definitionOperator,
238
+ let: highlight.tags.function(highlight.tags.definitionOperator),
239
+ this: highlight.tags.self,
240
+ yield: highlight.tags.operatorKeyword,
241
+ outlet: highlight.tags.operatorKeyword,
242
+ component: highlight.tags.function(highlight.tags.definitionKeyword),
243
+ modifier: highlight.tags.function(highlight.tags.definitionKeyword),
244
+ helper: highlight.tags.function(highlight.tags.definitionKeyword),
245
+ hash: highlight.tags.function(highlight.tags.definitionKeyword),
246
+ array: highlight.tags.function(highlight.tags.definitionKeyword),
247
+ on: highlight.tags.function(highlight.tags.definitionKeyword),
248
+ concat: highlight.tags.function(highlight.tags.operatorKeyword),
249
+ 'if then catch unless else each each-in': highlight.tags.controlKeyword,
250
+ // TODO:
251
+ UnquotedAttributeValue: highlight.tags.attributeValue,
252
+ 'DoubleQuote SingleQuote AttributeValueContent': highlight.tags.attributeValue,
253
+ 'EntityReference CharacterReference': highlight.tags.character,
254
+ '[ ]': highlight.tags.squareBracket,
255
+ ComponentName: highlight.tags.className,
256
+ StyleAttributeName: highlight.tags.propertyName,
257
+ BlockType: highlight.tags.controlKeyword,
258
+ BlockPrefix: highlight.tags.typeOperator,
259
+ 'UnknownBlock/BlockType': highlight.tags.invalid,
260
+ UnknownBlockContent: highlight.tags.invalid,
261
+ Variable: highlight.tags.variableName,
262
+ Modifier: highlight.tags.modifier,
263
+ ModifierValue: highlight.tags.function(highlight.tags.modifier),
264
+ });
265
+
266
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
267
+ const spec_identifier = {__proto__:null,this:36, as:38, if:40, unless:42, else:44, let:46, and:48, or:50, not:52, eq:54, neq:56, "not-eq":58, gt:60, gte:62, lt:64, lte:66, array:68, concat:70, hash:72, each:74, "each-in":76, on:78, modifier:80, component:82, helper:84, "in-element":86, yield:88, outlet:90};
268
+ const parser = lr.LRParser.deserialize({
269
+ version: 14,
270
+ states: "(dQVQ`OOOwQhO'#C^O!PQaO'#CbO!XQbO'#CcO!aQ`O'#CmO$oOpO'#CeO$vO`O'#CeO${QdO'#CdOOQO'#Ca'#CaOOQO'#D]'#D]O%^Q`O'#D^OOQO'#Dl'#DlOOQO'#D_'#D_QVQ`OOOOQW'#D`'#D`O%cQhO,58xOOQO,58x,58xOOQP'#Da'#DaO%kQaO,58|OOQO,58|,58|OOQQ'#Db'#DbO%sQbO,58}OOQO,58},58}OOQO,59X,59XO(RQ`O'#ChOOOO'#Cg'#CgOOOO'#Dd'#DdO(]OpO,59POOQS,59P,59POOOO'#Dt'#DtO(dOpO,59POOQS'#Dc'#DcO(iQdO,59OOOQO,59O,59OOOQO,59x,59xOOQO-E7]-E7]OOQW-E7^-E7^OOQO1G.d1G.dOOQP-E7_-E7_OOQO1G.h1G.hOOQQ-E7`-E7`OOQO1G.i1G.iOOOO,59S,59SO(zQ`O,59SO)VQ`O,59SOOOO-E7b-E7bOOQS1G.k1G.kOOQS-E7a-E7aOOQO1G.j1G.jO!fQ`O1G.nOOOO1G.n1G.nO)_Q`O1G.nO)dQ`O7+$YO!fQ`O7+$YOOOO<<Gt<<GtO)iQ`O<<GtOOOOAN=`AN=`",
271
+ stateData: ")p~O!_OS~ORPOYTO!aQO!cRO!eVO!gSO!iTO!jUO!lXO!mYO~OS`O!]^O~O!YaO!bcO~O!ZdO!dfO~O!fgO~O]hO^iO`iObmOcmOdmOemOfmOgmOhmOimOjmOkmOlmOmmOnmOomOpmOqmOrmOsmOtmOumOvmOwmOxmOymOzmO{mO|mO}mO!fiO!gSO~O!OlO~P!fO!fnO~OYTO![oO!iTO!jUO!kqO~O!frO~OSuO!]^O~O!YaO!bwO~O!ZdO!dyO~O]hO^iO`iObmOcmOdmOemOfmOgmOhmOimOjmOkmOlmOmmOnmOomOpmOqmOrmOsmOtmOumOvmOwmOxmOymOzmO{mO|mO}mO!gSO~O_zO!f{O~P%{O!O!OO~P!fO!O!OO~OYTO![oO!iTO!jUO!k!QO~O^!RO_ZX!fZX~O_!SO!f!TO~O^!VO~O_!WO~O_!YO~O!_~",
272
+ goto: "$e!iPP!jPP!j!n!n!n!rP!z#XPPPP#`PPPPPPPPPPPPPPPPPPPPPPPPPPPPP!j!j#k#q#w#}$T$ZPPPPPPP$aPPPPPPP#XTZO]TWO]SZO]ToVpSjTkQ|hQ!U!RR!X!VZiThk!R!VSZO]ZiThk!R!VQ]ORs]Q_PRt_QbQRvbQeRRxeQpVR!PpQkTR}kT[O]",
273
+ nodeNames: "⚠ Template GlimmerTemplateTag TemplateTag TemplateTag Comment ShortComment LongComment HtmlComment MoustacheExpression {{ SExpression CallExpression ( Is ) Pipe Argument this as if unless else let and or not eq neq not-eq gt gte lt lte array concat hash each each-in on modifier component helper in-element yield outlet }} Splattributes NamedBlock",
274
+ maxTerm: 75,
275
+ nodeProps: [
276
+ ["closedBy", 3,"templateTagEnd",10,"}}",13,"("],
277
+ ["openedBy", 4,"templateTagStart",15,")",46,"{{"]
278
+ ],
279
+ propSources: [glimmerHighlighting],
280
+ skippedNodes: [0],
281
+ repeatNodeCount: 6,
282
+ tokenData: "+W~RhX^!mpq!mxy#eyz#j|}!m}!O#o!O!P$`![!]&P!^!_&U!_!`)X!b!c)^!c!})c#T#o)c#o#p)q#p#q*t#q#r*y#y#z!m$f$g!m#BY#BZ!m$IS$I_!m$I|$JO!m$JT$JU!m$KV$KW!m&FU&FV!m~!rZ!_~X^!mpq!m|}!m#y#z!m$f$g!m#BY#BZ!m$IS$I_!m$I|$JO!m$JT$JU!m$KV$KW!m&FU&FV!m~#jO]~~#oO_~~#rP}!O#u~#xQ!`!a$O#q#r$T~$TO!k~~$WP#q#r$Z~$`O!d~~$cP!O!P$f~$iP!O!P$l~$oP#T#U$r~$uP#h#i$x~${P#h#i%O~%RP#f#g%U~%XP#]#^%[~%_P#U#V%b~%eP#i#j%h~%kP#h#i%n~%qP#X#Y%t~%wP#g#h%z~&PO!l~~&UO!m~~&XRqr&b!P!Q&s#h#i(Q~&eP}!O&h~&kP}!O&n~&sO!e~~&vP#h#i&y~&|P#X#Y'P~'SP#a#b'V~'YP#d#e']~'`P#`#a'c~'fP#T#U'i~'lP#h#i'o~'rP#X#Y'u~'xP!`!a'{~(QOS~~(TP#X#Y(W~(ZP#a#b(^~(aP#d#e(d~(gP#`#a(j~(mP#T#U(p~(sP#h#i(v~(yP#X#Y(|~)PP!`!a)S~)XOR~~)^O^~~)cO!g~~)hR!f~!Q![)c!c!})c#T#o)c~)tP#o#p)w~)|RY~qr*Vst*j!P!Q*o~*[P!a~}!O*_~*bP}!O*e~*jO!c~~*oO!i~~*tO!j~~*yO`~R*|P#q#r+PR+WO!OQ!bP",
283
+ tokenizers: [shortCommentContent, longCommentContent, htmlCommentContent, templateTagContent, 0, 1],
284
+ topRules: {"Template":[0,1]},
285
+ specialized: [{term: 68, get: value => spec_identifier[value] || -1}],
286
+ tokenPrec: 398
287
+ });
288
+
289
+ const glimmerParser = parser;
290
+ const glimmerLanguage = language.LRLanguage.define({
291
+ parser: parser.configure({
292
+ wrap: common.parseMixed((node) => {
293
+ let { name } = node.type;
294
+ switch (name) {
295
+ case 'Template':
296
+ return null;
297
+ case 'Comment':
298
+ case 'MoustacheExpression':
299
+ case 'NamedBlock':
300
+ case 'Splattributes':
301
+ case 'Argument':
302
+ return { parser };
303
+ }
304
+ return { parser: html.parser };
305
+ }),
306
+ props: [
307
+ language.indentNodeProp.add({
308
+ Element: (context) => {
309
+ let after = /^(\s*)(<\/)?/.exec(context.textAfter);
310
+ if (context.node.to <= context.pos + (after?.[0].length || 0))
311
+ return context.continue();
312
+ return context.lineIndent(context.node.from) + (after?.[2] ? 0 : context.unit);
313
+ },
314
+ Block: (context) => {
315
+ const node = context.node;
316
+ const text = context.textAfter.trim();
317
+ if (text.startsWith('{/')) {
318
+ const name = node.name;
319
+ if ((name === 'IfBlock' && text.startsWith('{/if')) ||
320
+ (name === 'EachBlock' && text.startsWith('{/each')) ||
321
+ (name === 'KeyBlock' && text.startsWith('{/key'))) {
322
+ return context.lineIndent(context.node.from);
323
+ }
324
+ return null;
325
+ }
326
+ if (node.name === 'IfBlock' || node.name === 'EachBlock') {
327
+ if (text.startsWith('{{:else'))
328
+ return context.lineIndent(node.from);
329
+ if (text.startsWith('{{else'))
330
+ return context.lineIndent(node.from);
331
+ }
332
+ // not sure if this needed to be duplicated
333
+ let after = /^(\s*)(<\/)?/.exec(context.textAfter);
334
+ if (context.node.to <= context.pos + (after?.[0].length || 0))
335
+ return context.continue();
336
+ return context.lineIndent(context.node.from) + (after?.[2] ? 0 : context.unit);
337
+ },
338
+ 'BlockOpen BlockClose BlockInline': (context) => {
339
+ return context.column(context.node.from) + context.unit;
340
+ },
341
+ 'OpenTag CloseTag SelfClosingTag': (context) => {
342
+ return context.column(context.node.from) + context.unit;
343
+ },
344
+ Document: (context) => {
345
+ if (context.pos + (/\s*/.exec(context.textAfter)?.[0].length || 0) < context.node.to) {
346
+ return context.continue();
347
+ }
348
+ let endElt = null;
349
+ let close;
350
+ for (let cur = context.node;;) {
351
+ let last = cur.lastChild;
352
+ if (!last || last.name != 'Element' || last.to != cur.to)
353
+ break;
354
+ endElt = cur = last;
355
+ }
356
+ if (endElt?.lastChild &&
357
+ !((close = endElt.lastChild) &&
358
+ (close.name === 'CloseTag' || close.name === 'SelfClosingTag'))) {
359
+ return context.lineIndent(endElt.from) + context.unit;
360
+ }
361
+ return null;
362
+ },
363
+ }),
364
+ language.foldNodeProp.add({
365
+ Block: (node) => {
366
+ const open = `${node.name}Open`;
367
+ const close = `${node.name}Close`;
368
+ const first = node.firstChild;
369
+ const last = node.lastChild;
370
+ if (!first || first.name !== open)
371
+ return null;
372
+ return {
373
+ from: first.to,
374
+ to: last?.name === close ? last.from : node.to,
375
+ };
376
+ },
377
+ Element: (node) => {
378
+ let first = node.firstChild;
379
+ let last = node.lastChild;
380
+ if (!first || first.name != 'OpenTag')
381
+ return null;
382
+ return {
383
+ from: first.to,
384
+ to: last?.name === 'CloseTag' ? last.from : node.to,
385
+ };
386
+ },
387
+ }),
388
+ ],
389
+ }),
390
+ languageData: {
391
+ commentTokens: {
392
+ block: { open: '<!--', close: '-->' },
393
+ devBlock: { open: '{{!--', close: '--}}' },
394
+ devBlockShort: { open: '{{!', close: '}}' },
395
+ },
396
+ indentOnInput: /^\s*((<\/\w+\W)|(\{:(else|then|catch))|(\{\/(if|unless|each|await|key)))$/,
397
+ wordChars: '-._',
398
+ autocomplete: langHtml.htmlCompletionSource,
399
+ },
400
+ });
401
+ function glimmer() {
402
+ return new language.LanguageSupport(glimmerLanguage, [langHtml.html().support]);
403
+ }
404
+
405
+ exports.glimmer = glimmer;
406
+ exports.glimmerLanguage = glimmerLanguage;
407
+ exports.glimmerParser = glimmerParser;
@@ -0,0 +1,6 @@
1
+ import { LanguageSupport, LRLanguage } from '@codemirror/language';
2
+ declare const glimmerParser: import("@lezer/lr").LRParser;
3
+ declare const glimmerLanguage: LRLanguage;
4
+ declare function glimmer(): LanguageSupport;
5
+ export { glimmerParser, glimmerLanguage, glimmer };
6
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts","../src/tokens.ts","../src/highlight.ts"],"names":[],"mappings":"AACA,OAAO,+BAA6D,MAAM,sBAAsB,CAAC;AAQjG,QAAO,MAAM,aAAa,8BAAS,CAAC;AAEpC,QAAO,MAAM,eAAe,YA0I1B,CAAC;AAEH,iBAAgB,OAAO,oBAEtB"}
@@ -0,0 +1,6 @@
1
+ import { LanguageSupport, LRLanguage } from '@codemirror/language';
2
+ declare const glimmerParser: import("@lezer/lr").LRParser;
3
+ declare const glimmerLanguage: LRLanguage;
4
+ declare function glimmer(): LanguageSupport;
5
+ export { glimmerParser, glimmerLanguage, glimmer };
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts","../src/tokens.ts","../src/highlight.ts"],"names":[],"mappings":"AACA,OAAO,+BAA6D,MAAM,sBAAsB,CAAC;AAQjG,QAAO,MAAM,aAAa,8BAAS,CAAC;AAEpC,QAAO,MAAM,eAAe,YA0I1B,CAAC;AAEH,iBAAgB,OAAO,oBAEtB"}
package/dist/index.js ADDED
@@ -0,0 +1,403 @@
1
+ import { htmlCompletionSource, html } from '@codemirror/lang-html';
2
+ import { LRLanguage, indentNodeProp, foldNodeProp, LanguageSupport } from '@codemirror/language';
3
+ import { parseMixed } from '@lezer/common';
4
+ import { parser as parser$1 } from '@lezer/html';
5
+ import { ExternalTokenizer, LRParser } from '@lezer/lr';
6
+ import { styleTags, tags } from '@lezer/highlight';
7
+
8
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
9
+ const shortCommentContent$1 = 56,
10
+ longCommentContent$1 = 57,
11
+ htmlCommentContent$1 = 58,
12
+ templateTagContent$1 = 59,
13
+ MoustacheExpression = 9;
14
+
15
+ // Ascii values
16
+ const parenOpen = 40;
17
+ const parenClose = 41;
18
+ const squareOpen = 91;
19
+ const squareClose = 93;
20
+ const curlyOpen = 123;
21
+ const curlyClose = 125;
22
+ const colon = 58;
23
+ const hash = 35;
24
+ const at = 64;
25
+ const slash = 47;
26
+ const greaterThan = 62;
27
+ const dash = 45;
28
+ const quoteDouble = 34;
29
+ const quoteSingle = 39;
30
+ const backslash = 92;
31
+ const newline = 10;
32
+ const asterisk = 42;
33
+ const tick = 96;
34
+ const prefixes = [colon, hash, at, slash];
35
+ const shortCommentEnd = [curlyClose, curlyClose];
36
+ const longCommentEnd = [dash, dash, curlyClose, curlyClose];
37
+ const htmlCommentEnd = [dash, dash, greaterThan];
38
+ // Is there a way to make this a build time (rather than eval-time?) operation?
39
+ const closingTemplateTag = '</template>'.split('').map((char) => char.charCodeAt(0));
40
+ function matchForComment(commentEndPattern, commentToken, input) {
41
+ for (let found = 0, i = 0;; i++) {
42
+ if (input.next < 0) {
43
+ if (i)
44
+ input.acceptToken(commentToken);
45
+ break;
46
+ }
47
+ let hasMatch = commentEndPattern[found] === input.next;
48
+ if (!hasMatch) {
49
+ found = 0;
50
+ input.advance();
51
+ break;
52
+ }
53
+ if (found === commentEndPattern.length - 1) {
54
+ if (i > commentEndPattern.length - 1) {
55
+ input.acceptToken(commentToken, 1 - commentEndPattern.length);
56
+ break;
57
+ }
58
+ else {
59
+ console.warn('Reached end of comment but there is still content left');
60
+ }
61
+ break;
62
+ }
63
+ found++;
64
+ input.advance();
65
+ }
66
+ }
67
+ const shortCommentContent = new ExternalTokenizer((input) => {
68
+ return matchForComment(shortCommentEnd, shortCommentContent$1, input);
69
+ });
70
+ const longCommentContent = new ExternalTokenizer((input) => {
71
+ return matchForComment(longCommentEnd, longCommentContent$1, input);
72
+ });
73
+ const htmlCommentContent = new ExternalTokenizer((input) => {
74
+ return matchForComment(htmlCommentEnd, htmlCommentContent$1, input);
75
+ });
76
+ const templateTagContent = new ExternalTokenizer((input) => {
77
+ return matchForComment(closingTemplateTag, templateTagContent$1, input);
78
+ });
79
+ // TODO: string handler does not handle interpolation
80
+ function createStringHandler(input) {
81
+ let inString = false;
82
+ let inStringType = null;
83
+ let inStringIgnoreNext = false;
84
+ return () => {
85
+ if (inString) {
86
+ if (inStringIgnoreNext) {
87
+ inStringIgnoreNext = false;
88
+ return true;
89
+ }
90
+ if (input.next === backslash) {
91
+ inStringIgnoreNext = true;
92
+ return true;
93
+ }
94
+ if (inStringType === 'double' && input.next === quoteDouble) {
95
+ inString = false;
96
+ inStringType = null;
97
+ return true;
98
+ }
99
+ if (inStringType === 'single' && input.next === quoteSingle) {
100
+ inString = false;
101
+ inStringType = null;
102
+ return true;
103
+ }
104
+ if (inStringType === 'template' && input.next === tick) {
105
+ inString = false;
106
+ inStringType = null;
107
+ return true;
108
+ }
109
+ return true;
110
+ }
111
+ if (input.next === quoteDouble) {
112
+ inString = true;
113
+ inStringType = 'double';
114
+ return true;
115
+ }
116
+ if (input.next === quoteSingle) {
117
+ inString = true;
118
+ inStringType = 'single';
119
+ return true;
120
+ }
121
+ if (input.next === tick) {
122
+ inString = true;
123
+ inStringType = 'template';
124
+ return true;
125
+ }
126
+ return false;
127
+ };
128
+ }
129
+ function createCommentHandler(input) {
130
+ let inLineComment = false;
131
+ let inBlockComment = false;
132
+ return () => {
133
+ if (inLineComment) {
134
+ if (input.next === newline) {
135
+ inLineComment = false;
136
+ return true;
137
+ }
138
+ return true;
139
+ }
140
+ if (inBlockComment) {
141
+ if (input.next === asterisk && input.peek(1) === slash) {
142
+ inBlockComment = false;
143
+ return true;
144
+ }
145
+ return true;
146
+ }
147
+ if (input.next === slash && input.peek(1) === slash) {
148
+ inLineComment = true;
149
+ return true;
150
+ }
151
+ if (input.next === slash && input.peek(1) === asterisk) {
152
+ inBlockComment = true;
153
+ return true;
154
+ }
155
+ return false;
156
+ };
157
+ }
158
+ // closes on a delimiter that probably isn't in the expression
159
+ new ExternalTokenizer((input) => {
160
+ if (prefixes.includes(input.next)) {
161
+ return;
162
+ }
163
+ const commentHandler = createCommentHandler(input);
164
+ const stringHandler = createStringHandler(input);
165
+ let stack = [];
166
+ const popIfMatch = (match) => {
167
+ const idx = stack.lastIndexOf(match);
168
+ if (idx !== -1) {
169
+ while (stack.length > idx) {
170
+ stack.pop();
171
+ }
172
+ }
173
+ };
174
+ for (let pos = 0;; pos++) {
175
+ // end of input
176
+ if (input.next < 0) {
177
+ if (pos > 0)
178
+ input.acceptToken(MoustacheExpression);
179
+ break;
180
+ }
181
+ if (commentHandler() || stringHandler()) {
182
+ input.advance();
183
+ continue;
184
+ }
185
+ if (stack.length === 0 &&
186
+ (input.next === curlyClose || input.next === parenClose || input.next === squareClose)) {
187
+ input.acceptToken(MoustacheExpression);
188
+ break;
189
+ }
190
+ switch (input.next) {
191
+ case parenOpen:
192
+ stack.push('(');
193
+ break;
194
+ case parenClose:
195
+ popIfMatch('(');
196
+ break;
197
+ case squareOpen:
198
+ stack.push('[');
199
+ break;
200
+ case squareClose:
201
+ popIfMatch('[');
202
+ break;
203
+ case curlyOpen:
204
+ stack.push('{');
205
+ break;
206
+ case curlyClose:
207
+ popIfMatch('{');
208
+ break;
209
+ }
210
+ input.advance();
211
+ }
212
+ });
213
+
214
+ const glimmerHighlighting = styleTags({
215
+ 'Text RawText': tags.content,
216
+ 'StartTag StartCloseTag SelfClosingEndTag EndTag': tags.angleBracket,
217
+ TagName: tags.tagName,
218
+ 'MismatchedCloseTag/TagName': [tags.tagName, tags.invalid],
219
+ AttributeName: tags.attributeName,
220
+ // Glimmer
221
+ TemplateTag: tags.definition(tags.annotation),
222
+ '{{ }}': tags.bracket,
223
+ '( )': tags.paren,
224
+ Function: tags.function(tags.name),
225
+ Splattributes: tags.derefOperator,
226
+ Comment: tags.blockComment,
227
+ ShortComment: tags.blockComment,
228
+ LongComment: tags.blockComment,
229
+ HtmlComment: tags.blockComment,
230
+ ArgName: tags.attributeName,
231
+ Argument: tags.propertyName,
232
+ NamedBlock: tags.tagName,
233
+ Is: tags.definitionOperator,
234
+ Pipe: tags.definitionOperator,
235
+ as: tags.definitionOperator,
236
+ let: tags.function(tags.definitionOperator),
237
+ this: tags.self,
238
+ yield: tags.operatorKeyword,
239
+ outlet: tags.operatorKeyword,
240
+ component: tags.function(tags.definitionKeyword),
241
+ modifier: tags.function(tags.definitionKeyword),
242
+ helper: tags.function(tags.definitionKeyword),
243
+ hash: tags.function(tags.definitionKeyword),
244
+ array: tags.function(tags.definitionKeyword),
245
+ on: tags.function(tags.definitionKeyword),
246
+ concat: tags.function(tags.operatorKeyword),
247
+ 'if then catch unless else each each-in': tags.controlKeyword,
248
+ // TODO:
249
+ UnquotedAttributeValue: tags.attributeValue,
250
+ 'DoubleQuote SingleQuote AttributeValueContent': tags.attributeValue,
251
+ 'EntityReference CharacterReference': tags.character,
252
+ '[ ]': tags.squareBracket,
253
+ ComponentName: tags.className,
254
+ StyleAttributeName: tags.propertyName,
255
+ BlockType: tags.controlKeyword,
256
+ BlockPrefix: tags.typeOperator,
257
+ 'UnknownBlock/BlockType': tags.invalid,
258
+ UnknownBlockContent: tags.invalid,
259
+ Variable: tags.variableName,
260
+ Modifier: tags.modifier,
261
+ ModifierValue: tags.function(tags.modifier),
262
+ });
263
+
264
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
265
+ const spec_identifier = {__proto__:null,this:36, as:38, if:40, unless:42, else:44, let:46, and:48, or:50, not:52, eq:54, neq:56, "not-eq":58, gt:60, gte:62, lt:64, lte:66, array:68, concat:70, hash:72, each:74, "each-in":76, on:78, modifier:80, component:82, helper:84, "in-element":86, yield:88, outlet:90};
266
+ const parser = LRParser.deserialize({
267
+ version: 14,
268
+ states: "(dQVQ`OOOwQhO'#C^O!PQaO'#CbO!XQbO'#CcO!aQ`O'#CmO$oOpO'#CeO$vO`O'#CeO${QdO'#CdOOQO'#Ca'#CaOOQO'#D]'#D]O%^Q`O'#D^OOQO'#Dl'#DlOOQO'#D_'#D_QVQ`OOOOQW'#D`'#D`O%cQhO,58xOOQO,58x,58xOOQP'#Da'#DaO%kQaO,58|OOQO,58|,58|OOQQ'#Db'#DbO%sQbO,58}OOQO,58},58}OOQO,59X,59XO(RQ`O'#ChOOOO'#Cg'#CgOOOO'#Dd'#DdO(]OpO,59POOQS,59P,59POOOO'#Dt'#DtO(dOpO,59POOQS'#Dc'#DcO(iQdO,59OOOQO,59O,59OOOQO,59x,59xOOQO-E7]-E7]OOQW-E7^-E7^OOQO1G.d1G.dOOQP-E7_-E7_OOQO1G.h1G.hOOQQ-E7`-E7`OOQO1G.i1G.iOOOO,59S,59SO(zQ`O,59SO)VQ`O,59SOOOO-E7b-E7bOOQS1G.k1G.kOOQS-E7a-E7aOOQO1G.j1G.jO!fQ`O1G.nOOOO1G.n1G.nO)_Q`O1G.nO)dQ`O7+$YO!fQ`O7+$YOOOO<<Gt<<GtO)iQ`O<<GtOOOOAN=`AN=`",
269
+ stateData: ")p~O!_OS~ORPOYTO!aQO!cRO!eVO!gSO!iTO!jUO!lXO!mYO~OS`O!]^O~O!YaO!bcO~O!ZdO!dfO~O!fgO~O]hO^iO`iObmOcmOdmOemOfmOgmOhmOimOjmOkmOlmOmmOnmOomOpmOqmOrmOsmOtmOumOvmOwmOxmOymOzmO{mO|mO}mO!fiO!gSO~O!OlO~P!fO!fnO~OYTO![oO!iTO!jUO!kqO~O!frO~OSuO!]^O~O!YaO!bwO~O!ZdO!dyO~O]hO^iO`iObmOcmOdmOemOfmOgmOhmOimOjmOkmOlmOmmOnmOomOpmOqmOrmOsmOtmOumOvmOwmOxmOymOzmO{mO|mO}mO!gSO~O_zO!f{O~P%{O!O!OO~P!fO!O!OO~OYTO![oO!iTO!jUO!k!QO~O^!RO_ZX!fZX~O_!SO!f!TO~O^!VO~O_!WO~O_!YO~O!_~",
270
+ goto: "$e!iPP!jPP!j!n!n!n!rP!z#XPPPP#`PPPPPPPPPPPPPPPPPPPPPPPPPPPPP!j!j#k#q#w#}$T$ZPPPPPPP$aPPPPPPP#XTZO]TWO]SZO]ToVpSjTkQ|hQ!U!RR!X!VZiThk!R!VSZO]ZiThk!R!VQ]ORs]Q_PRt_QbQRvbQeRRxeQpVR!PpQkTR}kT[O]",
271
+ nodeNames: "⚠ Template GlimmerTemplateTag TemplateTag TemplateTag Comment ShortComment LongComment HtmlComment MoustacheExpression {{ SExpression CallExpression ( Is ) Pipe Argument this as if unless else let and or not eq neq not-eq gt gte lt lte array concat hash each each-in on modifier component helper in-element yield outlet }} Splattributes NamedBlock",
272
+ maxTerm: 75,
273
+ nodeProps: [
274
+ ["closedBy", 3,"templateTagEnd",10,"}}",13,"("],
275
+ ["openedBy", 4,"templateTagStart",15,")",46,"{{"]
276
+ ],
277
+ propSources: [glimmerHighlighting],
278
+ skippedNodes: [0],
279
+ repeatNodeCount: 6,
280
+ tokenData: "+W~RhX^!mpq!mxy#eyz#j|}!m}!O#o!O!P$`![!]&P!^!_&U!_!`)X!b!c)^!c!})c#T#o)c#o#p)q#p#q*t#q#r*y#y#z!m$f$g!m#BY#BZ!m$IS$I_!m$I|$JO!m$JT$JU!m$KV$KW!m&FU&FV!m~!rZ!_~X^!mpq!m|}!m#y#z!m$f$g!m#BY#BZ!m$IS$I_!m$I|$JO!m$JT$JU!m$KV$KW!m&FU&FV!m~#jO]~~#oO_~~#rP}!O#u~#xQ!`!a$O#q#r$T~$TO!k~~$WP#q#r$Z~$`O!d~~$cP!O!P$f~$iP!O!P$l~$oP#T#U$r~$uP#h#i$x~${P#h#i%O~%RP#f#g%U~%XP#]#^%[~%_P#U#V%b~%eP#i#j%h~%kP#h#i%n~%qP#X#Y%t~%wP#g#h%z~&PO!l~~&UO!m~~&XRqr&b!P!Q&s#h#i(Q~&eP}!O&h~&kP}!O&n~&sO!e~~&vP#h#i&y~&|P#X#Y'P~'SP#a#b'V~'YP#d#e']~'`P#`#a'c~'fP#T#U'i~'lP#h#i'o~'rP#X#Y'u~'xP!`!a'{~(QOS~~(TP#X#Y(W~(ZP#a#b(^~(aP#d#e(d~(gP#`#a(j~(mP#T#U(p~(sP#h#i(v~(yP#X#Y(|~)PP!`!a)S~)XOR~~)^O^~~)cO!g~~)hR!f~!Q![)c!c!})c#T#o)c~)tP#o#p)w~)|RY~qr*Vst*j!P!Q*o~*[P!a~}!O*_~*bP}!O*e~*jO!c~~*oO!i~~*tO!j~~*yO`~R*|P#q#r+PR+WO!OQ!bP",
281
+ tokenizers: [shortCommentContent, longCommentContent, htmlCommentContent, templateTagContent, 0, 1],
282
+ topRules: {"Template":[0,1]},
283
+ specialized: [{term: 68, get: value => spec_identifier[value] || -1}],
284
+ tokenPrec: 398
285
+ });
286
+
287
+ const glimmerParser = parser;
288
+ const glimmerLanguage = LRLanguage.define({
289
+ parser: parser.configure({
290
+ wrap: parseMixed((node) => {
291
+ let { name } = node.type;
292
+ switch (name) {
293
+ case 'Template':
294
+ return null;
295
+ case 'Comment':
296
+ case 'MoustacheExpression':
297
+ case 'NamedBlock':
298
+ case 'Splattributes':
299
+ case 'Argument':
300
+ return { parser };
301
+ }
302
+ return { parser: parser$1 };
303
+ }),
304
+ props: [
305
+ indentNodeProp.add({
306
+ Element: (context) => {
307
+ let after = /^(\s*)(<\/)?/.exec(context.textAfter);
308
+ if (context.node.to <= context.pos + (after?.[0].length || 0))
309
+ return context.continue();
310
+ return context.lineIndent(context.node.from) + (after?.[2] ? 0 : context.unit);
311
+ },
312
+ Block: (context) => {
313
+ const node = context.node;
314
+ const text = context.textAfter.trim();
315
+ if (text.startsWith('{/')) {
316
+ const name = node.name;
317
+ if ((name === 'IfBlock' && text.startsWith('{/if')) ||
318
+ (name === 'EachBlock' && text.startsWith('{/each')) ||
319
+ (name === 'KeyBlock' && text.startsWith('{/key'))) {
320
+ return context.lineIndent(context.node.from);
321
+ }
322
+ return null;
323
+ }
324
+ if (node.name === 'IfBlock' || node.name === 'EachBlock') {
325
+ if (text.startsWith('{{:else'))
326
+ return context.lineIndent(node.from);
327
+ if (text.startsWith('{{else'))
328
+ return context.lineIndent(node.from);
329
+ }
330
+ // not sure if this needed to be duplicated
331
+ let after = /^(\s*)(<\/)?/.exec(context.textAfter);
332
+ if (context.node.to <= context.pos + (after?.[0].length || 0))
333
+ return context.continue();
334
+ return context.lineIndent(context.node.from) + (after?.[2] ? 0 : context.unit);
335
+ },
336
+ 'BlockOpen BlockClose BlockInline': (context) => {
337
+ return context.column(context.node.from) + context.unit;
338
+ },
339
+ 'OpenTag CloseTag SelfClosingTag': (context) => {
340
+ return context.column(context.node.from) + context.unit;
341
+ },
342
+ Document: (context) => {
343
+ if (context.pos + (/\s*/.exec(context.textAfter)?.[0].length || 0) < context.node.to) {
344
+ return context.continue();
345
+ }
346
+ let endElt = null;
347
+ let close;
348
+ for (let cur = context.node;;) {
349
+ let last = cur.lastChild;
350
+ if (!last || last.name != 'Element' || last.to != cur.to)
351
+ break;
352
+ endElt = cur = last;
353
+ }
354
+ if (endElt?.lastChild &&
355
+ !((close = endElt.lastChild) &&
356
+ (close.name === 'CloseTag' || close.name === 'SelfClosingTag'))) {
357
+ return context.lineIndent(endElt.from) + context.unit;
358
+ }
359
+ return null;
360
+ },
361
+ }),
362
+ foldNodeProp.add({
363
+ Block: (node) => {
364
+ const open = `${node.name}Open`;
365
+ const close = `${node.name}Close`;
366
+ const first = node.firstChild;
367
+ const last = node.lastChild;
368
+ if (!first || first.name !== open)
369
+ return null;
370
+ return {
371
+ from: first.to,
372
+ to: last?.name === close ? last.from : node.to,
373
+ };
374
+ },
375
+ Element: (node) => {
376
+ let first = node.firstChild;
377
+ let last = node.lastChild;
378
+ if (!first || first.name != 'OpenTag')
379
+ return null;
380
+ return {
381
+ from: first.to,
382
+ to: last?.name === 'CloseTag' ? last.from : node.to,
383
+ };
384
+ },
385
+ }),
386
+ ],
387
+ }),
388
+ languageData: {
389
+ commentTokens: {
390
+ block: { open: '<!--', close: '-->' },
391
+ devBlock: { open: '{{!--', close: '--}}' },
392
+ devBlockShort: { open: '{{!', close: '}}' },
393
+ },
394
+ indentOnInput: /^\s*((<\/\w+\W)|(\{:(else|then|catch))|(\{\/(if|unless|each|await|key)))$/,
395
+ wordChars: '-._',
396
+ autocomplete: htmlCompletionSource,
397
+ },
398
+ });
399
+ function glimmer() {
400
+ return new LanguageSupport(glimmerLanguage, [html().support]);
401
+ }
402
+
403
+ export { glimmer, glimmerLanguage, glimmerParser };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemirror-lang-glimmer",
3
- "version": "0.0.0-beta.1",
3
+ "version": "0.0.0-beta.2",
4
4
  "author": "NullVoxPopuli",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -20,14 +20,18 @@
20
20
  "@babel/core": "^7.21.8",
21
21
  "@babel/eslint-parser": "^7.21.8",
22
22
  "@codemirror/buildhelper": "^0.1.16",
23
+ "@codemirror/language": "^6.6.0",
23
24
  "@lezer/generator": "^1.2.3",
24
25
  "@nullvoxpopuli/eslint-configs": "^3.1.3",
25
- "@typescript-eslint/eslint-plugin": "^5.59.2",
26
- "@typescript-eslint/parser": "^5.59.2",
26
+ "@tsconfig/ember": "^2.0.0",
27
+ "@typescript-eslint/eslint-plugin": "^5.59.5",
28
+ "@typescript-eslint/parser": "^5.59.5",
27
29
  "codemirror": "^6.0.1",
28
30
  "concurrently": "^8.0.1",
29
31
  "eslint": "^8.40.0",
30
32
  "prettier": "^2.8.8",
33
+ "rollup": "^3.21.5",
34
+ "rollup-plugin-ts": "^3.2.0",
31
35
  "typescript": "^5.0.4"
32
36
  },
33
37
  "dependencies": {
@@ -43,12 +47,12 @@
43
47
  },
44
48
  "scripts": {
45
49
  "dev": "node ./dev/watch.cjs src/index.ts",
46
- "build": "cm-buildhelper src/index.ts",
50
+ "build": "rollup -c",
47
51
  "lint": "pnpm -w exec lint",
48
- "_:lint:js": "pnpm -w exec lint js",
49
- "_:lint:js:fix": "pnpm -w exec lint js:fix",
50
- "_:lint:prettier:fix": "pnpm -w exec lint prettier:fix",
51
- "_:lint:prettier": "pnpm -w exec lint prettier",
52
- "lint:fix": "pnpm -w exec lint fix"
52
+ "lint:fix": "pnpm -w exec lint fix",
53
+ "lint:js": "pnpm -w exec lint js",
54
+ "lint:js:fix": "pnpm -w exec lint js:fix",
55
+ "lint:prettier:fix": "pnpm -w exec lint prettier:fix",
56
+ "lint:prettier": "pnpm -w exec lint prettier"
53
57
  }
54
58
  }
@@ -0,0 +1,12 @@
1
+ import { lezer } from "@lezer/generator/rollup";
2
+ import typescript from "rollup-plugin-ts";
3
+
4
+ export default {
5
+ input: "src/index.ts",
6
+ external: (id) => id != "tslib" && !/^(\.?\/|\w:)/.test(id),
7
+ output: [
8
+ { file: "dist/index.cjs", format: "cjs" },
9
+ { dir: "./dist", format: "es" },
10
+ ],
11
+ plugins: [lezer(), typescript()],
12
+ };
package/src/index.ts CHANGED
@@ -33,9 +33,9 @@ export const glimmerLanguage = LRLanguage.define({
33
33
  Element: (context) => {
34
34
  let after = /^(\s*)(<\/)?/.exec(context.textAfter);
35
35
 
36
- if (context.node.to <= context.pos + after[0].length) return context.continue();
36
+ if (context.node.to <= context.pos + (after?.[0].length || 0)) return context.continue();
37
37
 
38
- return context.lineIndent(context.node.from) + (after[2] ? 0 : context.unit);
38
+ return context.lineIndent(context.node.from) + (after?.[2] ? 0 : context.unit);
39
39
  },
40
40
 
41
41
  Block: (context) => {
@@ -64,9 +64,9 @@ export const glimmerLanguage = LRLanguage.define({
64
64
  // not sure if this needed to be duplicated
65
65
  let after = /^(\s*)(<\/)?/.exec(context.textAfter);
66
66
 
67
- if (context.node.to <= context.pos + after[0].length) return context.continue();
67
+ if (context.node.to <= context.pos + (after?.[0].length || 0)) return context.continue();
68
68
 
69
- return context.lineIndent(context.node.from) + (after[2] ? 0 : context.unit);
69
+ return context.lineIndent(context.node.from) + (after?.[2] ? 0 : context.unit);
70
70
  },
71
71
 
72
72
  'BlockOpen BlockClose BlockInline': (context) => {
@@ -78,7 +78,7 @@ export const glimmerLanguage = LRLanguage.define({
78
78
  },
79
79
 
80
80
  Document: (context) => {
81
- if (context.pos + /\s*/.exec(context.textAfter)[0].length < context.node.to) {
81
+ if (context.pos + (/\s*/.exec(context.textAfter)?.[0].length || 0) < context.node.to) {
82
82
  return context.continue();
83
83
  }
84
84
 
@@ -93,7 +93,7 @@ export const glimmerLanguage = LRLanguage.define({
93
93
  }
94
94
 
95
95
  if (
96
- endElt &&
96
+ endElt?.lastChild &&
97
97
  !(
98
98
  (close = endElt.lastChild) &&
99
99
  (close.name === 'CloseTag' || close.name === 'SelfClosingTag')
@@ -130,7 +130,7 @@ export const glimmerLanguage = LRLanguage.define({
130
130
 
131
131
  return {
132
132
  from: first.to,
133
- to: last.name === 'CloseTag' ? last.from : node.to,
133
+ to: last?.name === 'CloseTag' ? last.from : node.to,
134
134
  };
135
135
  },
136
136
  }),
@@ -1,3 +1,3 @@
1
- import type { Parser } from '@lezer/common';
1
+ import type { LRParser } from '@lezer/lr';
2
2
 
3
- export declare const parser: Parser;
3
+ export declare const parser: LRParser;
package/src/tokens.ts CHANGED
@@ -39,7 +39,7 @@ const htmlCommentEnd = [dash, dash, greaterThan];
39
39
  // Is there a way to make this a build time (rather than eval-time?) operation?
40
40
  const closingTemplateTag = '</template>'.split('').map((char) => char.charCodeAt(0));
41
41
 
42
- export function matchForComment(commentEndPattern, commentToken, input) {
42
+ export function matchForComment(commentEndPattern: number[], commentToken: number, input: any) {
43
43
  for (let found = 0, i = 0; ; i++) {
44
44
  if (input.next < 0) {
45
45
  if (i) input.acceptToken(commentToken);
@@ -5,8 +5,8 @@
5
5
  "extends": "../../../../package.json"
6
6
  },
7
7
  "devDependencies": {
8
- "@typescript-eslint/eslint-plugin": "^5.59.2",
9
- "@typescript-eslint/parser": "^5.59.2",
8
+ "@typescript-eslint/eslint-plugin": "^5.59.5",
9
+ "@typescript-eslint/parser": "^5.59.5",
10
10
  "eslint": "^8.40.0",
11
11
  "prettier": "^2.8.8",
12
12
  "typescript": "^5.0.4",
@@ -15,11 +15,11 @@
15
15
  "@babel/core": "^7.21.8"
16
16
  },
17
17
  "scripts": {
18
- "_:lint:js": "pnpm -w exec lint js",
19
- "_:lint:js:fix": "pnpm -w exec lint js:fix",
20
- "_:lint:prettier:fix": "pnpm -w exec lint prettier:fix",
21
- "_:lint:prettier": "pnpm -w exec lint prettier",
22
18
  "lint": "pnpm -w exec lint",
23
- "lint:fix": "pnpm -w exec lint fix"
19
+ "lint:fix": "pnpm -w exec lint fix",
20
+ "lint:js": "pnpm -w exec lint js",
21
+ "lint:js:fix": "pnpm -w exec lint js:fix",
22
+ "lint:prettier:fix": "pnpm -w exec lint prettier:fix",
23
+ "lint:prettier": "pnpm -w exec lint prettier"
24
24
  }
25
25
  }
package/tsconfig.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "@tsconfig/ember/tsconfig.json"
3
+ }