@lvce-editor/shared-process 0.7.6 → 0.7.7

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,14 @@
1
+ # Language Basics Coffeescript
2
+
3
+ ## Contributing
4
+
5
+ ```sh
6
+ git clone git@github.com:lvce-editor/language-basics-coffeescript.git &&
7
+ cd language-basics-coffeescript &&
8
+ npm ci &&
9
+ npm test
10
+ ```
11
+
12
+ ## Gitpod
13
+
14
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/lvce-editor/language-basics-coffeescript)
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "builtin.language-basics-coffeescript",
3
+ "name": "Language Basics Coffeescript",
4
+ "description": "Provides syntax highlighting and bracket matching in Coffeescript files.",
5
+ "languages": [
6
+ {
7
+ "id": "coffeescript",
8
+ "extensions": [".coffee"],
9
+ "tokenize": "src/tokenizeCoffeeScript.js"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @enum number
3
+ */
4
+ export const TokenType = {
5
+ Text: 1,
6
+ }
7
+
8
+ export const TokenMap = {
9
+ [TokenType.Text]: 'Text',
10
+ }
11
+
12
+ export const initialLineState = {
13
+ state: 1,
14
+ tokens: [],
15
+ }
16
+
17
+ export const hasArrayReturn = true
18
+
19
+ /**
20
+ * @param {string} line
21
+ */
22
+ export const tokenizeLine = (line) => {
23
+ const tokens = [TokenType.Text, line.length]
24
+ return {
25
+ state: 1,
26
+ tokens,
27
+ }
28
+ }
@@ -34,7 +34,10 @@
34
34
  "composer.lock",
35
35
  ".watchmanconfig",
36
36
  ".all-contributorsrc",
37
- ".imgbotconfig"
37
+ ".imgbotconfig",
38
+ ".stylelintrc",
39
+ ".parcelrc",
40
+ ".publishrc"
38
41
  ],
39
42
  "tokenize": "src/tokenizeJson.js"
40
43
  }
@@ -15,6 +15,8 @@ const State = {
15
15
  None: 11,
16
16
  InsideDoubleQuoteString: 12,
17
17
  InsideSingleQuoteString: 13,
18
+ AfterTripleBackTick: 14,
19
+ AfterTripleBackTickAfterLanguageId: 15,
18
20
  }
19
21
 
20
22
  export const StateMap = {}
@@ -86,6 +88,8 @@ const RE_TEXT = /^[^<>\n]+/
86
88
  const RE_WHITESPACE = /^\s+/
87
89
  const RE_WORD = /^[^\s]+/
88
90
  const RE_HEADING = /^\#.*/s
91
+ const RE_TRIPLE_BACKTICK = /^`{3,}/
92
+ const RE_TRIPLE_QUOTED_STRING_CONTENT = /.*/s
89
93
 
90
94
  export const initialLineState = {
91
95
  state: State.TopLevelContent,
@@ -101,6 +105,8 @@ export const isLineStateEqual = (lineStateA, lineStateB) => {
101
105
  return lineStateA.state === lineStateB.state
102
106
  }
103
107
 
108
+ export const hasArrayReturn = true
109
+
104
110
  /**
105
111
  *
106
112
  * @param {string} line
@@ -125,6 +131,9 @@ export const tokenizeLine = (line, lineState) => {
125
131
  state = State.AfterOpeningAngleBracket
126
132
  } else if ((next = part.match(RE_HEADING))) {
127
133
  token = TokenType.Heading
134
+ } else if ((next = part.match(RE_TRIPLE_BACKTICK))) {
135
+ token = TokenType.PunctuationString
136
+ state = State.AfterTripleBackTick
128
137
  } else if ((next = part.match(RE_TEXT))) {
129
138
  token = TokenType.Text
130
139
  state = State.TopLevelContent
@@ -136,6 +145,7 @@ export const tokenizeLine = (line, lineState) => {
136
145
  state = State.TopLevelContent
137
146
  } else {
138
147
  part //?
148
+ console.log({ part })
139
149
  throw new Error('no')
140
150
  }
141
151
  break
@@ -291,15 +301,32 @@ export const tokenizeLine = (line, lineState) => {
291
301
  throw new Error('no')
292
302
  }
293
303
  break
304
+ case State.AfterTripleBackTick:
305
+ if ((next = part.match(RE_WORD))) {
306
+ token = TokenType.String
307
+ state = State.AfterTripleBackTickAfterLanguageId
308
+ } else {
309
+ throw new Error('no')
310
+ }
311
+ break
312
+ case State.AfterTripleBackTickAfterLanguageId:
313
+ if ((next = part.match(RE_TRIPLE_BACKTICK))) {
314
+ token = TokenType.PunctuationString
315
+ state = State.TopLevelContent
316
+ } else if ((next = part.match(RE_TRIPLE_QUOTED_STRING_CONTENT))) {
317
+ token = TokenType.String
318
+ state = State.AfterTripleBackTickAfterLanguageId
319
+ } else {
320
+ throw new Error('no')
321
+ }
322
+ break
294
323
  default:
295
324
  state
296
325
  throw new Error('no')
297
326
  }
298
- index += next[0].length
299
- tokens.push({
300
- type: token,
301
- length: next[0].length,
302
- })
327
+ const tokenLength = next[0].length
328
+ index += tokenLength
329
+ tokens.push(token, tokenLength)
303
330
  }
304
331
  return {
305
332
  state,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -20,8 +20,8 @@
20
20
  "node": ">=16"
21
21
  },
22
22
  "dependencies": {
23
- "@lvce-editor/extension-host": "0.7.6",
24
- "@lvce-editor/pty-host": "0.7.6",
23
+ "@lvce-editor/extension-host": "0.7.7",
24
+ "@lvce-editor/pty-host": "0.7.7",
25
25
  "chokidar": "^3.5.3",
26
26
  "debug": "^4.3.4",
27
27
  "execa": "^6.1.0",