@lvce-editor/shared-process 0.7.5 → 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
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "builtin.language-basics-docker",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "name": "Language Basics Docker",
5
5
  "description": "Provides syntax highlighting and bracket matching in Dockerfile files.",
6
6
  "languages": [
@@ -15,6 +15,7 @@ export const State = {
15
15
  InsideRound: 11,
16
16
  AfterQueryWithRules: 12,
17
17
  InsideLineComment: 5,
18
+ InsideString: 2,
18
19
  }
19
20
 
20
21
  /**
@@ -27,6 +28,8 @@ export const TokenType = {
27
28
  Keyword: 3,
28
29
  Whitespace: 4,
29
30
  Comment: 885,
31
+ String: 886,
32
+ PunctuationString: 13,
30
33
  }
31
34
 
32
35
  export const TokenMap = {
@@ -35,6 +38,8 @@ export const TokenMap = {
35
38
  [TokenType.Whitespace]: 'Whitespace',
36
39
  [TokenType.Keyword]: 'Keyword',
37
40
  [TokenType.Comment]: 'Comment',
41
+ [TokenType.String]: 'String',
42
+ [TokenType.PunctuationString]: 'PunctuationString',
38
43
  }
39
44
 
40
45
  export const initialLineState = {
@@ -47,8 +52,11 @@ const RE_ANYTHING = /^.*/
47
52
  const RE_KEYWORD =
48
53
  /^(?:ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)\b/
49
54
  const RE_LINE_COMMENT_START = /^#/
55
+ const RE_PLAIN_TEXT = /^[^"\\]+/
56
+ const RE_QUOTE_DOUBLE = /^"/
57
+ const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"]+/
50
58
 
51
- export const hasArrayReturnValue = true
59
+ export const hasArrayReturn = true
52
60
 
53
61
  /**
54
62
  * @param {string} line
@@ -73,6 +81,12 @@ export const tokenizeLine = (line, lineState) => {
73
81
  } else if ((next = part.match(RE_LINE_COMMENT_START))) {
74
82
  token = TokenType.Comment
75
83
  state = State.InsideLineComment
84
+ } else if ((next = part.match(RE_QUOTE_DOUBLE))) {
85
+ token = TokenType.PunctuationString
86
+ state = State.InsideString
87
+ } else if ((next = part.match(RE_PLAIN_TEXT))) {
88
+ token = TokenType.Text
89
+ state = State.TopLevelContent
76
90
  } else if ((next = part.match(RE_ANYTHING))) {
77
91
  token = TokenType.Text
78
92
  state = State.TopLevelContent
@@ -88,15 +102,24 @@ export const tokenizeLine = (line, lineState) => {
88
102
  throw new Error('no')
89
103
  }
90
104
  break
105
+ case State.InsideString:
106
+ if ((next = part.match(RE_QUOTE_DOUBLE))) {
107
+ token = TokenType.PunctuationString
108
+ state = State.TopLevelContent
109
+ } else if ((next = part.match(RE_STRING_DOUBLE_QUOTE_CONTENT))) {
110
+ token = TokenType.String
111
+ state = State.InsideString
112
+ } else {
113
+ throw new Error('no')
114
+ }
115
+ break
91
116
  default:
92
117
  console.log({ state, line })
93
118
  throw new Error('no')
94
119
  }
95
- index += next[0].length
96
- tokens.push({
97
- type: token,
98
- length: next[0].length,
99
- })
120
+ const tokenLength = next[0].length
121
+ index += tokenLength
122
+ tokens.push(token, tokenLength)
100
123
  }
101
124
  if (state === State.InsideLineComment) {
102
125
  state = State.TopLevelContent
@@ -5,7 +5,8 @@
5
5
  "languages": [
6
6
  {
7
7
  "id": "dotenv",
8
- "extensions": [".env", ".env.local"],
8
+ "extensions": [".env"],
9
+ "fileNames": ["sampledotenv", ".env.local", ".env.example"],
9
10
  "configuration": "./languageConfiguration.json",
10
11
  "tokenize": "src/tokenizeDotenv.js"
11
12
  }
@@ -65,8 +65,8 @@ export const TokenMap = {
65
65
  [TokenType.KeywordExport]: 'KeywordExport',
66
66
  [TokenType.VariableValueString]: 'String',
67
67
  [TokenType.LanguageConstant]: 'LanguageConstant',
68
- [TokenType.VariableValue]: 'VariableValue',
69
- [TokenType.VariableName]: 'VariableName',
68
+ [TokenType.VariableValue]: 'String',
69
+ [TokenType.VariableName]: 'JsonPropertyName',
70
70
  [TokenType.NewLine]: 'NewLine',
71
71
  }
72
72
 
@@ -125,6 +125,8 @@ export const initialLineState = {
125
125
  state: State.TopLevelContent,
126
126
  }
127
127
 
128
+ export const hasArrayReturn = true
129
+
128
130
  /**
129
131
  * @param {string} line
130
132
  */
@@ -277,11 +279,17 @@ export const tokenizeLine = (line, lineState) => {
277
279
  state
278
280
  throw new Error('no')
279
281
  }
280
- index += next[0].length
281
- tokens.push({
282
- type: token,
283
- length: next[0].length,
284
- })
282
+ const tokenLength = next[0].length
283
+ index += tokenLength
284
+ tokens.push(token, tokenLength)
285
+ }
286
+ switch (state) {
287
+ case State.AfterVariableName:
288
+ case State.AfterAssignmentEqualSign:
289
+ state = State.TopLevelContent
290
+ break
291
+ default:
292
+ break
285
293
  }
286
294
  if (state === State.AfterVariableValue) {
287
295
  state = State.TopLevelContent
@@ -291,7 +299,3 @@ export const tokenizeLine = (line, lineState) => {
291
299
  tokens,
292
300
  }
293
301
  }
294
-
295
- // tokenizeLine(initialContext, '# comment') //?
296
-
297
- // tokenizeLine('KEY=42"', initialLineState) //?
@@ -30,7 +30,15 @@
30
30
  ".sublime-project",
31
31
  ".code-snippets"
32
32
  ],
33
- "fileNames": ["composer.lock", ".watchmanconfig"],
33
+ "fileNames": [
34
+ "composer.lock",
35
+ ".watchmanconfig",
36
+ ".all-contributorsrc",
37
+ ".imgbotconfig",
38
+ ".stylelintrc",
39
+ ".parcelrc",
40
+ ".publishrc"
41
+ ],
34
42
  "tokenize": "src/tokenizeJson.js"
35
43
  }
36
44
  ]
@@ -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,
@@ -12,6 +12,7 @@ export const State = {
12
12
  InsideMultiLineString: 8,
13
13
  InsideMultiLineStringAfterWhitespace: 9,
14
14
  AfterPropertyValue: 10,
15
+ InsidePropertyNameString: 11,
15
16
  }
16
17
 
17
18
  export const StateMap = {
@@ -60,7 +61,9 @@ const RE_LINE_COMMENT_START = /^#/
60
61
  const RE_WHITESPACE = /^ +/
61
62
  const RE_CURLY_OPEN = /^\{/
62
63
  const RE_CURLY_CLOSE = /^\}/
63
- const RE_PROPERTY_NAME = /^[a-zA-Z\-\_\d\s]+\b(?=\s*:(\s+|$))/
64
+ const RE_PROPERTY_NAME = /^[\:@\/\\a-zA-Z\-\_\d\.]+(?=\s*:(\s+|$))/
65
+ const RE_PROPERTY_NAME_2 =
66
+ /^[\:@\/\\a-zA-Z\-\_\d\.\s]*[@\/\\a-zA-Z\-\_\d\.](?=\s*:(\s+|$))/
64
67
  const RE_PROPERTY_VALUE_1 = /^.+(?=\s+#)/s
65
68
  const RE_SEMICOLON = /^;/
66
69
  const RE_COMMA = /^,/
@@ -88,6 +91,8 @@ const RE_DASH = /^\-/
88
91
  const RE_WORDS = /^[\w\s]*\w/
89
92
  const RE_MULTI_LINE_STRING_START = /^(?:\||>\-|>)/
90
93
  const RE_KEY_PRE = /^\s*(\-\s*)?/
94
+ const RE_SINGLE_QUOTE = /^'/
95
+ const RE_STRING_SINGLE_QUOTE_CONTENT = /^[^']+/
91
96
 
92
97
  export const initialLineState = {
93
98
  state: State.TopLevelContent,
@@ -141,12 +146,18 @@ export const tokenizeLine = (line, lineState) => {
141
146
  } else if ((next = part.match(RE_PROPERTY_NAME))) {
142
147
  token = TokenType.PropertyName
143
148
  state = State.AfterPropertyName
149
+ } else if ((next = part.match(RE_PROPERTY_NAME_2))) {
150
+ token = TokenType.PropertyName
151
+ state = State.AfterPropertyName
144
152
  } else if ((next = part.match(RE_NUMERIC))) {
145
153
  token = TokenType.Numeric
146
154
  state = State.TopLevelContent
147
155
  } else if ((next = part.match(RE_WORDS))) {
148
156
  token = TokenType.Text
149
157
  state = State.TopLevelContent
158
+ } else if ((next = part.match(RE_SINGLE_QUOTE))) {
159
+ token = TokenType.Punctuation
160
+ state = State.InsidePropertyNameString
150
161
  } else if ((next = part.match(RE_ANYTHING))) {
151
162
  token = TokenType.Text
152
163
  state = State.TopLevelContent
@@ -265,11 +276,25 @@ export const tokenizeLine = (line, lineState) => {
265
276
  } else if ((next = part.match(RE_LINE_COMMENT_START))) {
266
277
  token = TokenType.Comment
267
278
  state = State.InsideLineComment
279
+ } else if ((next = part.match(RE_SINGLE_QUOTE))) {
280
+ token = TokenType.Punctuation
281
+ state = State.InsidePropertyNameString
268
282
  } else {
269
283
  part
270
284
  throw new Error('no')
271
285
  }
272
286
  break
287
+ case State.InsidePropertyNameString:
288
+ if ((next = part.match(RE_SINGLE_QUOTE))) {
289
+ token = TokenType.Punctuation
290
+ state = State.AfterPropertyName
291
+ } else if ((next = part.match(RE_STRING_SINGLE_QUOTE_CONTENT))) {
292
+ token = TokenType.String
293
+ state = State.InsidePropertyNameString
294
+ } else {
295
+ throw new Error('no')
296
+ }
297
+ break
273
298
  case State.InsideMultiLineString:
274
299
  if ((next = part.match(RE_WHITESPACE))) {
275
300
  token = TokenType.Whitespace
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.7.5",
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.5",
24
- "@lvce-editor/pty-host": "0.7.5",
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",
@@ -1,17 +1,19 @@
1
1
  import VError from 'verror'
2
+ import * as ExtensionManifest from '../ExtensionManifest/ExtensionManifest.js'
3
+ import * as ExtensionManifestStatus from '../ExtensionManifestStatus/ExtensionManifestStatus.js'
2
4
  import * as FileSystem from '../FileSystem/FileSystem.js'
3
5
  import * as Path from '../Path/Path.js'
4
6
  import * as Platform from '../Platform/Platform.js'
5
7
 
6
8
  export const unlink = async (path) => {
7
9
  try {
8
- const manifestPath = Path.join(path, 'extension.json')
9
- if (!(await FileSystem.exists(manifestPath))) {
10
- throw new Error('no extension manifest found')
10
+ const manifest = await ExtensionManifest.get(path)
11
+ if (manifest.status === ExtensionManifestStatus.Rejected) {
12
+ throw manifest.reason
11
13
  }
12
14
  const linkedExtensionsPath = Platform.getLinkedExtensionsPath()
13
- const baseName = Path.basename(path)
14
- const to = Path.join(linkedExtensionsPath, baseName)
15
+ // @ts-ignore
16
+ const to = Path.join(linkedExtensionsPath, manifest.id)
15
17
  await FileSystem.remove(to)
16
18
  } catch (error) {
17
19
  throw new VError(error, `Failed to unlink extension`)