@lvce-editor/shared-process 0.15.16 → 0.15.17
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/config/builtinCommands.json +4 -0
- package/config/defaultSettings.json +2 -0
- package/extensions/builtin.language-basics-python/extension.json +1 -1
- package/extensions/builtin.language-basics-xml/extension.json +2 -1
- package/extensions/builtin.language-basics-xml/src/tokenizeXml.js +1 -1
- package/extensions/builtin.theme-atom-one-dark/color-theme.json +4 -0
- package/package.json +4 -4
- package/src/parts/ChildProcessError/ChildProcessError.js +4 -1
- package/src/parts/ElectronInitialize/ElectronInitialize.ipc.js +8 -0
- package/src/parts/ElectronInitialize/ElectronInitialize.js +40 -0
- package/src/parts/ErrorCodes/ErrorCodes.js +2 -0
- package/src/parts/FirstWebSocketEventType/FirstWebSocketEventType.js +2 -0
- package/src/parts/GetErrorResponse/GetErrorResponse.js +1 -0
- package/src/parts/GetHelpfulChildProcessError/GetHelpfulChildProcessError.js +13 -3
- package/src/parts/HandleIpc/HandleIpc.js +30 -0
- package/src/parts/HandleWebSocket/HandleWebSocket.ipc.js +7 -0
- package/src/parts/HandleWebSocket/HandleWebSocket.js +25 -0
- package/src/parts/HandleWebSocketForExtensionHost/HandleWebSocketForExtensionHost.js +15 -0
- package/src/parts/HandleWebSocketForExtensionHostHelperProcess/HandleWebSocketForExtensionHostHelperProcess.js +6 -0
- package/src/parts/HandleWebSocketForSharedProcess/HandleWebSocketForSharedProcess.js +16 -0
- package/src/parts/HandleWebSocketForTerminalProcess/HandleWebSocketForTerminalProcess.js +22 -0
- package/src/parts/HandleWebSocketForUnknown/HandleWebSocketForUnknown.js +10 -0
- package/src/parts/HandleWebSocketModule/HandleWebSocketModule.js +20 -0
- package/src/parts/IpcChild/IpcChild.js +3 -1
- package/src/parts/IpcChildModule/IpcChildModule.js +2 -0
- package/src/parts/IpcChildType/IpcChildType.js +4 -0
- package/src/parts/IpcChildWithElectronUtilityProcess/IpcChildWithElectronUtilityProcess.js +27 -0
- package/src/parts/IpcChildWithNodeForkedProcess/IpcChildWithNodeForkedProcess.js +4 -0
- package/src/parts/IpcParentWithNodeForkedProcess/IpcParentWithNodeForkedProcess.js +7 -3
- package/src/parts/IsElectron/IsElectron.js +3 -0
- package/src/parts/JsonRpc/JsonRpc.js +16 -0
- package/src/parts/Module/Module.js +6 -0
- package/src/parts/ModuleId/ModuleId.js +3 -0
- package/src/parts/ModuleMap/ModuleMap.js +6 -0
- package/src/parts/ParentIpc/ParentIpc.js +10 -188
- package/src/parts/PrettyError/PrettyError.js +1 -0
- package/src/parts/ProtocolType/ProtocolType.js +2 -1
- package/src/parts/PtyHost/PtyHost.js +81 -0
- package/src/parts/RebuildNodePty/RebuildNodePty.ipc.js +7 -0
- package/src/parts/RebuildNodePty/RebuildNodePty.js +48 -0
- package/src/parts/RequiresSocket/RequiresSocket.js +1 -0
- package/src/parts/Terminal/Terminal.js +36 -127
- package/src/parts/WebSocketServer/WebSocketServer.js +6 -25
- package/src/sharedProcessMain.js +1 -1
- package/extensions/builtin.language-basics-json5/README.md +0 -16
- package/extensions/builtin.language-basics-json5/extension.json +0 -12
- package/extensions/builtin.language-basics-json5/src/tokenizeJson5.js +0 -321
- /package/src/parts/{GetWindowsNsisDOwnloadUrl → GetWindowsNsisDownloadUrl}/GetWindowsNsisDownloadUrl.js +0 -0
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @enum number
|
|
3
|
-
*/
|
|
4
|
-
export const State = {
|
|
5
|
-
TopLevelContent: 1,
|
|
6
|
-
AfterCurlyOpen: 2,
|
|
7
|
-
InsideString: 3,
|
|
8
|
-
AfterPropertyName: 4,
|
|
9
|
-
AfterPropertyNameAfterColon: 5,
|
|
10
|
-
AfterPropertyValue: 6,
|
|
11
|
-
JsonPropertyKey: 7,
|
|
12
|
-
InsideLineComment: 8,
|
|
13
|
-
InsidePropertyNameString: 9,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const StateMap = {
|
|
17
|
-
[State.TopLevelContent]: 'TopLevelContent',
|
|
18
|
-
[State.AfterCurlyOpen]: 'AfterCurlyOpen',
|
|
19
|
-
[State.InsideString]: 'InsideString',
|
|
20
|
-
[State.AfterPropertyName]: 'AfterPropertyName',
|
|
21
|
-
[State.AfterPropertyNameAfterColon]: 'AfterPropertyNameAfterColon',
|
|
22
|
-
[State.AfterPropertyValue]: 'AfterPropertyValue',
|
|
23
|
-
[State.JsonPropertyKey]: 'JsonPropertyKey',
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @enum number
|
|
28
|
-
*/
|
|
29
|
-
export const TokenType = {
|
|
30
|
-
CssSelector: 1,
|
|
31
|
-
Whitespace: 2,
|
|
32
|
-
Punctuation: 3,
|
|
33
|
-
PropertyName: 4,
|
|
34
|
-
PropertyValue: 5,
|
|
35
|
-
CurlyOpen: 6,
|
|
36
|
-
CurlyClose: 7,
|
|
37
|
-
PropertyColon: 8,
|
|
38
|
-
PropertySemicolon: 9,
|
|
39
|
-
String: 10,
|
|
40
|
-
LanguageConstant: 11,
|
|
41
|
-
NewLine: 12,
|
|
42
|
-
JsonPropertyName: 13,
|
|
43
|
-
PropertyValueString: 14,
|
|
44
|
-
Numeric: 15,
|
|
45
|
-
LanguageConstantBoolean: 16,
|
|
46
|
-
Comment: 17,
|
|
47
|
-
Error: 18,
|
|
48
|
-
Unknown: 19,
|
|
49
|
-
Text: 20,
|
|
50
|
-
JsonPropertyValueString: 21,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const TokenMap = {
|
|
54
|
-
[TokenType.CssSelector]: 'CssSelector',
|
|
55
|
-
[TokenType.Whitespace]: 'Whitespace',
|
|
56
|
-
[TokenType.Punctuation]: 'Punctuation',
|
|
57
|
-
[TokenType.PropertyName]: 'PropertyName',
|
|
58
|
-
[TokenType.PropertyValue]: 'PropertyValue',
|
|
59
|
-
[TokenType.CurlyOpen]: 'CurlyOpen',
|
|
60
|
-
[TokenType.CurlyClose]: 'CurlyClose',
|
|
61
|
-
[TokenType.PropertyColon]: 'PropertyColon',
|
|
62
|
-
[TokenType.PropertySemicolon]: 'PropertySemicolon',
|
|
63
|
-
[TokenType.String]: 'String',
|
|
64
|
-
[TokenType.LanguageConstant]: 'LanguageConstant',
|
|
65
|
-
[TokenType.LanguageConstantBoolean]: 'LanguageConstantBoolean',
|
|
66
|
-
[TokenType.JsonPropertyName]: 'JsonPropertyName',
|
|
67
|
-
[TokenType.PropertyValueString]: 'PropertyValueString',
|
|
68
|
-
[TokenType.Comment]: 'Comment',
|
|
69
|
-
[TokenType.Error]: 'Error',
|
|
70
|
-
[TokenType.Unknown]: 'Unknown',
|
|
71
|
-
[TokenType.NewLine]: 'NewLine',
|
|
72
|
-
[TokenType.Text]: 'Text',
|
|
73
|
-
[TokenType.Numeric]: 'Numeric',
|
|
74
|
-
[TokenType.JsonPropertyValueString]: 'JsonPropertyValueString',
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const RE_SELECTOR = /^[\.a-zA-Z\d\-\:>]+/
|
|
78
|
-
const RE_WHITESPACE = /^\s+/
|
|
79
|
-
const RE_CURLY_OPEN = /^\{/
|
|
80
|
-
const RE_CURLY_CLOSE = /^\}/
|
|
81
|
-
const RE_COLON = /^:/
|
|
82
|
-
const RE_PROPERTY_VALUE = /^[^\n;]+/
|
|
83
|
-
const RE_SEMICOLON = /^;/
|
|
84
|
-
const RE_COMMA = /^,/
|
|
85
|
-
const RE_DOUBLE_QUOTE = /^"/
|
|
86
|
-
const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"\\]+/
|
|
87
|
-
const RE_LANGUAGE_CONSTANT = /^(?:true|false|null)/
|
|
88
|
-
const RE_SQUARE_OPEN = /^\[/
|
|
89
|
-
const RE_SQUARE_CLOSE = /^\]/
|
|
90
|
-
const RE_LINE_COMMENT = /^\/\/.*/
|
|
91
|
-
const RE_ANYTHING = /^.+/s
|
|
92
|
-
const RE_NUMERIC =
|
|
93
|
-
/^((0(x|X)[0-9a-fA-F]*)|(\-?([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b/
|
|
94
|
-
const RE_TEXT = /^[^\s\{\}\[\]]+/
|
|
95
|
-
// const RE_ESCAPED_QUOTE = /^\\"/
|
|
96
|
-
// const RE_BACK_SLASH = /^\\/
|
|
97
|
-
const RE_STRING_ESCAPE = /^\\.?/
|
|
98
|
-
const RE_WORD = /^\w+/
|
|
99
|
-
|
|
100
|
-
export const initialLineState = {
|
|
101
|
-
state: State.TopLevelContent,
|
|
102
|
-
stack: [],
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export const hasArrayReturn = true
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* @param {string} line
|
|
109
|
-
* @param {any} lineState
|
|
110
|
-
*/
|
|
111
|
-
export const tokenizeLine = (line, lineState) => {
|
|
112
|
-
let next
|
|
113
|
-
let index = 0
|
|
114
|
-
let token
|
|
115
|
-
let state = lineState.state
|
|
116
|
-
let __r = 0
|
|
117
|
-
const tokens = []
|
|
118
|
-
const stack = lineState.stack
|
|
119
|
-
state
|
|
120
|
-
while (index < line.length) {
|
|
121
|
-
if (__r++ > 100_000_000_000) {
|
|
122
|
-
throw new Error('endless loop')
|
|
123
|
-
}
|
|
124
|
-
const part = line.slice(index)
|
|
125
|
-
switch (state) {
|
|
126
|
-
case State.TopLevelContent:
|
|
127
|
-
if ((next = part.match(RE_CURLY_OPEN))) {
|
|
128
|
-
token = TokenType.Punctuation
|
|
129
|
-
state = State.AfterCurlyOpen
|
|
130
|
-
stack.push(State.TopLevelContent)
|
|
131
|
-
} else if ((next = part.match(RE_SQUARE_OPEN))) {
|
|
132
|
-
token = TokenType.Punctuation
|
|
133
|
-
state = State.TopLevelContent
|
|
134
|
-
stack.push(State.TopLevelContent)
|
|
135
|
-
} else if ((next = part.match(RE_WHITESPACE))) {
|
|
136
|
-
token = TokenType.Whitespace
|
|
137
|
-
state = State.TopLevelContent
|
|
138
|
-
} else if ((next = part.match(RE_SQUARE_CLOSE))) {
|
|
139
|
-
token = TokenType.Punctuation
|
|
140
|
-
state = stack.pop()
|
|
141
|
-
} else if ((next = part.match(RE_COMMA))) {
|
|
142
|
-
token = TokenType.Punctuation
|
|
143
|
-
state = State.TopLevelContent
|
|
144
|
-
} else if ((next = part.match(RE_NUMERIC))) {
|
|
145
|
-
token = TokenType.Numeric
|
|
146
|
-
state = State.TopLevelContent
|
|
147
|
-
} else if ((next = part.match(RE_LANGUAGE_CONSTANT))) {
|
|
148
|
-
token = TokenType.LanguageConstant
|
|
149
|
-
state = State.TopLevelContent
|
|
150
|
-
} else if ((next = part.match(RE_DOUBLE_QUOTE))) {
|
|
151
|
-
token = TokenType.Punctuation
|
|
152
|
-
state = State.InsideString
|
|
153
|
-
stack.push(State.TopLevelContent)
|
|
154
|
-
} else if ((next = part.match(RE_LINE_COMMENT))) {
|
|
155
|
-
token = TokenType.Comment
|
|
156
|
-
state = State.InsideLineComment
|
|
157
|
-
} else if ((next = part.match(RE_CURLY_CLOSE))) {
|
|
158
|
-
token = TokenType.CurlyClose
|
|
159
|
-
state = stack.pop()
|
|
160
|
-
} else if ((next = part.match(RE_ANYTHING))) {
|
|
161
|
-
token = TokenType.Text
|
|
162
|
-
state = State.TopLevelContent
|
|
163
|
-
} else {
|
|
164
|
-
part //?
|
|
165
|
-
throw new Error('no')
|
|
166
|
-
}
|
|
167
|
-
break
|
|
168
|
-
case State.AfterCurlyOpen:
|
|
169
|
-
if ((next = part.match(RE_WHITESPACE))) {
|
|
170
|
-
token = TokenType.Whitespace
|
|
171
|
-
state = State.AfterCurlyOpen
|
|
172
|
-
} else if ((next = part.match(RE_DOUBLE_QUOTE))) {
|
|
173
|
-
token = TokenType.Punctuation
|
|
174
|
-
state = State.InsidePropertyNameString
|
|
175
|
-
stack.push(State.AfterPropertyName)
|
|
176
|
-
} else if ((next = part.match(RE_CURLY_CLOSE))) {
|
|
177
|
-
token = TokenType.Punctuation
|
|
178
|
-
state = stack.pop()
|
|
179
|
-
if (!state) {
|
|
180
|
-
throw new Error('imbalanced json')
|
|
181
|
-
}
|
|
182
|
-
} else if ((next = part.match(RE_LINE_COMMENT))) {
|
|
183
|
-
token = TokenType.Comment
|
|
184
|
-
state = State.AfterCurlyOpen
|
|
185
|
-
} else if ((next = part.match(RE_WORD))) {
|
|
186
|
-
token = TokenType.PropertyName
|
|
187
|
-
state = State.AfterPropertyName
|
|
188
|
-
} else if ((next = part.match(RE_ANYTHING))) {
|
|
189
|
-
token = TokenType.Text
|
|
190
|
-
state = State.AfterCurlyOpen
|
|
191
|
-
} else {
|
|
192
|
-
part //?
|
|
193
|
-
throw new Error('no')
|
|
194
|
-
}
|
|
195
|
-
break
|
|
196
|
-
case State.InsidePropertyNameString:
|
|
197
|
-
if ((next = part.match(RE_STRING_DOUBLE_QUOTE_CONTENT))) {
|
|
198
|
-
token = TokenType.JsonPropertyName
|
|
199
|
-
state = State.InsidePropertyNameString
|
|
200
|
-
} else if ((next = part.match(RE_DOUBLE_QUOTE))) {
|
|
201
|
-
token = TokenType.Punctuation
|
|
202
|
-
state = stack.pop()
|
|
203
|
-
state
|
|
204
|
-
} else if ((next = part.match(RE_STRING_ESCAPE))) {
|
|
205
|
-
token = TokenType.JsonPropertyName
|
|
206
|
-
state = State.InsidePropertyNameString
|
|
207
|
-
} else {
|
|
208
|
-
throw new Error('no')
|
|
209
|
-
}
|
|
210
|
-
break
|
|
211
|
-
case State.InsideString:
|
|
212
|
-
if ((next = part.match(RE_STRING_DOUBLE_QUOTE_CONTENT))) {
|
|
213
|
-
token = TokenType.JsonPropertyValueString
|
|
214
|
-
state = State.InsideString
|
|
215
|
-
} else if ((next = part.match(RE_DOUBLE_QUOTE))) {
|
|
216
|
-
token = TokenType.Punctuation
|
|
217
|
-
state = stack.pop()
|
|
218
|
-
} else if ((next = part.match(RE_STRING_ESCAPE))) {
|
|
219
|
-
token = TokenType.String
|
|
220
|
-
state = State.InsideString
|
|
221
|
-
} else {
|
|
222
|
-
line.slice(0, index) //?
|
|
223
|
-
part //?
|
|
224
|
-
throw new Error('no')
|
|
225
|
-
}
|
|
226
|
-
break
|
|
227
|
-
case State.AfterPropertyName:
|
|
228
|
-
if ((next = part.match(RE_COLON))) {
|
|
229
|
-
token = TokenType.Punctuation
|
|
230
|
-
state = State.AfterPropertyNameAfterColon
|
|
231
|
-
} else if ((next = part.match(RE_WHITESPACE))) {
|
|
232
|
-
token = TokenType.Whitespace
|
|
233
|
-
state = State.AfterPropertyName
|
|
234
|
-
} else if ((next = part.match(RE_ANYTHING))) {
|
|
235
|
-
token = TokenType.Text
|
|
236
|
-
state = State.AfterCurlyOpen
|
|
237
|
-
} else {
|
|
238
|
-
throw new Error('no')
|
|
239
|
-
}
|
|
240
|
-
break
|
|
241
|
-
case State.AfterPropertyNameAfterColon:
|
|
242
|
-
if ((next = part.match(RE_WHITESPACE))) {
|
|
243
|
-
token = TokenType.Whitespace
|
|
244
|
-
state = State.AfterPropertyNameAfterColon
|
|
245
|
-
} else if ((next = part.match(RE_DOUBLE_QUOTE))) {
|
|
246
|
-
token = TokenType.Punctuation
|
|
247
|
-
state = State.InsideString
|
|
248
|
-
stack.push(State.AfterPropertyValue)
|
|
249
|
-
} else if ((next = part.match(RE_LANGUAGE_CONSTANT))) {
|
|
250
|
-
token = TokenType.LanguageConstant
|
|
251
|
-
state = State.AfterPropertyValue
|
|
252
|
-
} else if ((next = part.match(RE_NUMERIC))) {
|
|
253
|
-
token = TokenType.Numeric
|
|
254
|
-
state = State.AfterPropertyValue
|
|
255
|
-
} else if ((next = part.match(RE_TEXT))) {
|
|
256
|
-
token = TokenType.Text
|
|
257
|
-
state = State.AfterCurlyOpen
|
|
258
|
-
} else if ((next = part.match(RE_CURLY_OPEN))) {
|
|
259
|
-
token = TokenType.Punctuation
|
|
260
|
-
state = State.AfterCurlyOpen
|
|
261
|
-
stack.push(State.AfterPropertyValue)
|
|
262
|
-
} else if ((next = part.match(RE_SQUARE_OPEN))) {
|
|
263
|
-
token = TokenType.Punctuation
|
|
264
|
-
state = State.TopLevelContent
|
|
265
|
-
stack.push(State.AfterPropertyValue)
|
|
266
|
-
} else {
|
|
267
|
-
line.slice(0, index) //?
|
|
268
|
-
throw new Error('no')
|
|
269
|
-
}
|
|
270
|
-
break
|
|
271
|
-
case State.AfterPropertyValue:
|
|
272
|
-
if ((next = part.match(RE_CURLY_CLOSE))) {
|
|
273
|
-
token = TokenType.Punctuation
|
|
274
|
-
state = stack.pop()
|
|
275
|
-
if (!state) {
|
|
276
|
-
throw new Error('inbalanced json')
|
|
277
|
-
}
|
|
278
|
-
} else if ((next = part.match(RE_WHITESPACE))) {
|
|
279
|
-
token = TokenType.Whitespace
|
|
280
|
-
state = State.AfterPropertyValue
|
|
281
|
-
} else if ((next = part.match(RE_COMMA))) {
|
|
282
|
-
token = TokenType.Punctuation
|
|
283
|
-
state = State.AfterCurlyOpen
|
|
284
|
-
} else if ((next = part.match(RE_ANYTHING))) {
|
|
285
|
-
token = TokenType.Text
|
|
286
|
-
state = State.AfterCurlyOpen
|
|
287
|
-
} else {
|
|
288
|
-
part //?
|
|
289
|
-
throw new Error('no')
|
|
290
|
-
}
|
|
291
|
-
break
|
|
292
|
-
case State.InsideLineComment:
|
|
293
|
-
if ((next = part.match(RE_ANYTHING))) {
|
|
294
|
-
token = TokenType.Comment
|
|
295
|
-
state = State.TopLevelContent
|
|
296
|
-
} else {
|
|
297
|
-
throw new Error('no')
|
|
298
|
-
}
|
|
299
|
-
break
|
|
300
|
-
default:
|
|
301
|
-
state
|
|
302
|
-
throw new Error('no')
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const currentTokenText = next[0]
|
|
306
|
-
const currentTokenLength = currentTokenText.length
|
|
307
|
-
index += currentTokenLength
|
|
308
|
-
tokens.push(token, currentTokenLength)
|
|
309
|
-
}
|
|
310
|
-
if (state === State.InsideLineComment) {
|
|
311
|
-
state = State.TopLevelContent
|
|
312
|
-
}
|
|
313
|
-
if (state === State.AfterPropertyValue) {
|
|
314
|
-
state = State.AfterCurlyOpen
|
|
315
|
-
}
|
|
316
|
-
return {
|
|
317
|
-
state,
|
|
318
|
-
stack,
|
|
319
|
-
tokens,
|
|
320
|
-
}
|
|
321
|
-
}
|
|
File without changes
|