@lvce-editor/shared-process 0.7.5 → 0.7.6

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.
@@ -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,12 @@
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
+ ],
34
39
  "tokenize": "src/tokenizeJson.js"
35
40
  }
36
41
  ]
@@ -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.6",
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.6",
24
+ "@lvce-editor/pty-host": "0.7.6",
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`)