@lvce-editor/shared-process 0.4.1 → 0.4.3

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.
@@ -343,7 +343,7 @@
343
343
  },
344
344
  {
345
345
  "key": "Space",
346
- "command": "Explorer.handleClickCurrent",
346
+ "command": "Explorer.handleClickCurrentButKeepFocus",
347
347
  "when": "focus.Explorer"
348
348
  },
349
349
  {
@@ -0,0 +1,14 @@
1
+ # Language Basics Gitattributes
2
+
3
+ ## Contributing
4
+
5
+ ```sh
6
+ git clone git@github.com:lvce-editor/language-basics-gitattributes.git &&
7
+ cd language-basics-gitattributes &&
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-gitattributes)
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "builtin.language-basics-gitattributes",
3
+ "name": "Language Basics Gitattributes",
4
+ "description": "Provides syntax highlighting and bracket matching in gitattributes files.",
5
+ "languages": [
6
+ {
7
+ "id": "gitattributes",
8
+ "extensions": [".gitattributes"],
9
+ "tokenize": "src/tokenizeGitAttributes.js"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,132 @@
1
+ /**
2
+ * @enum number
3
+ */
4
+ export const State = {
5
+ TopLevelContent: 1,
6
+ InsideLineComment: 2,
7
+ AfterPropertyName: 3,
8
+ }
9
+
10
+ /**
11
+ * @enum number
12
+ */
13
+ export const TokenType = {
14
+ Comment: 885,
15
+ LanguageConstant: 11,
16
+ NewLine: 884,
17
+ None: 57,
18
+ Numeric: 15,
19
+ PropertyName: 12,
20
+ PropertyValueString: 14,
21
+ Punctuation: 13,
22
+ Query: 886,
23
+ Text: 887,
24
+ Unknown: 881,
25
+ Whitespace: 2,
26
+ }
27
+
28
+ export const TokenMap = {
29
+ [TokenType.Text]: 'Text',
30
+ [TokenType.Comment]: 'Comment',
31
+ }
32
+
33
+ const RE_LINE_COMMENT_START = /^#/
34
+ const RE_WHITESPACE = /^ +/
35
+ const RE_CURLY_OPEN = /^\{/
36
+ const RE_CURLY_CLOSE = /^\}/
37
+ const RE_PROPERTY_NAME = /^[a-zA-Z\-\_\d\s]+\b(?=\s*:)/
38
+ const RE_PROPERTY_VALUE = /^[^;\}]+/
39
+ const RE_SEMICOLON = /^;/
40
+ const RE_COMMA = /^,/
41
+ const RE_ANYTHING = /^.*/
42
+ const RE_ANYTHING_BUT_COMMENT = /^[^#]+/
43
+ const RE_NUMERIC = /^(([0-9]+\.?[0-9]*)|(\.[0-9]+))/
44
+ const RE_ANYTHING_UNTIL_CLOSE_BRACE = /^[^\}]+/
45
+ const RE_BLOCK_COMMENT_START = /^\/\*/
46
+ const RE_BLOCK_COMMENT_END = /^\*\//
47
+ const RE_BLOCK_COMMENT_CONTENT = /^.+?(?=\*\/|$)/s
48
+ const RE_ROUND_OPEN = /^\(/
49
+ const RE_ROUND_CLOSE = /^\)/
50
+ const RE_PSEUDO_SELECTOR_CONTENT = /^[^\)]+/
51
+ const RE_SQUARE_OPEN = /^\[/
52
+ const RE_SQUARE_CLOSE = /^\]/
53
+ const RE_ATTRIBUTE_SELECTOR_CONTENT = /^[^\]]+/
54
+ const RE_QUERY = /^@[a-z\-]+/
55
+ const RE_STAR = /^\*/
56
+ const RE_QUERY_NAME = /^[a-z\-]+/
57
+ const RE_QUERY_CONTENT = /^[^\)]+/
58
+ const RE_COMBINATOR = /^[\+\>\~]/
59
+ const RE_LANGUAGE_CONSTANT = /^(?:true|false)/
60
+ const RE_COLON = /^:/
61
+ const RE_DASH = /^\-/
62
+ const RE_WORDS = /^[\w\s]*\w/
63
+
64
+ export const initialLineState = {
65
+ state: 1,
66
+ tokens: [],
67
+ }
68
+
69
+ export const hasArrayReturn = true
70
+
71
+ /**
72
+ * @param {string} line
73
+ * @param {any} lineState
74
+ */
75
+ export const tokenizeLine = (line, lineState) => {
76
+ let next = null
77
+ let index = 0
78
+ let tokens = []
79
+ let token = TokenType.None
80
+ let state = lineState.state
81
+ while (index < line.length) {
82
+ const part = line.slice(index)
83
+ switch (state) {
84
+ case State.TopLevelContent:
85
+ if ((next = part.match(RE_LINE_COMMENT_START))) {
86
+ token = TokenType.Comment
87
+ state = State.InsideLineComment
88
+ } else if ((next = part.match(RE_WHITESPACE))) {
89
+ token = TokenType.Whitespace
90
+ state = State.TopLevelContent
91
+ } else if ((next = part.match(RE_ANYTHING))) {
92
+ token = TokenType.Text
93
+ state = State.TopLevelContent
94
+ } else {
95
+ throw new Error('no')
96
+ }
97
+ break
98
+ case State.InsideLineComment:
99
+ if ((next = part.match(RE_ANYTHING))) {
100
+ token = TokenType.Comment
101
+ state = State.TopLevelContent
102
+ } else {
103
+ throw new Error('no')
104
+ }
105
+ break
106
+ case State.AfterPropertyName:
107
+ if ((next = part.match(RE_COLON))) {
108
+ token = TokenType.Punctuation
109
+ state = State.AfterPropertyNameAfterColon
110
+ } else if ((next = part.match(RE_WHITESPACE))) {
111
+ token = TokenType.Whitespace
112
+ state = State.AfterPropertyName
113
+ } else {
114
+ throw new Error('no')
115
+ }
116
+ break
117
+ default:
118
+ console.log({ state, line })
119
+ throw new Error('no')
120
+ }
121
+ const tokenLength = next[0].length
122
+ index += tokenLength
123
+ tokens.push(token, tokenLength)
124
+ }
125
+ if (state === State.AfterPropertyNameAfterColon) {
126
+ state = State.TopLevelContent
127
+ }
128
+ return {
129
+ state,
130
+ tokens,
131
+ }
132
+ }
@@ -53,7 +53,7 @@ const RE_LINE_COMMENT_START = /^#/
53
53
  const RE_WHITESPACE = /^ +/
54
54
  const RE_CURLY_OPEN = /^\{/
55
55
  const RE_CURLY_CLOSE = /^\}/
56
- const RE_PROPERTY_NAME = /^[a-zA-Z\-\_]+(?=\s*:)/
56
+ const RE_PROPERTY_NAME = /^[a-zA-Z\-\_\d\s]+\b(?=\s*:)/
57
57
  const RE_PROPERTY_VALUE = /^[^;\}]+/
58
58
  const RE_SEMICOLON = /^;/
59
59
  const RE_COMMA = /^,/
@@ -84,6 +84,8 @@ export const initialLineState = {
84
84
  stack: [],
85
85
  }
86
86
 
87
+ export const hasArrayReturn = true
88
+
87
89
  /**
88
90
  * @param {string} line
89
91
  * @param {any} lineState
@@ -107,15 +109,15 @@ export const tokenizeLine = (line, lineState) => {
107
109
  } else if ((next = part.match(RE_LANGUAGE_CONSTANT))) {
108
110
  token = TokenType.LanguageConstant
109
111
  state = State.TopLevelContent
112
+ } else if ((next = part.match(RE_DASH))) {
113
+ token = TokenType.Punctuation
114
+ state = State.AfterDash
110
115
  } else if ((next = part.match(RE_PROPERTY_NAME))) {
111
116
  token = TokenType.PropertyName
112
117
  state = State.AfterPropertyName
113
118
  } else if ((next = part.match(RE_NUMERIC))) {
114
119
  token = TokenType.Numeric
115
120
  state = State.TopLevelContent
116
- } else if ((next = part.match(RE_DASH))) {
117
- token = TokenType.Punctuation
118
- state = State.AfterDash
119
121
  } else if ((next = part.match(RE_ANYTHING))) {
120
122
  token = TokenType.Text
121
123
  state = State.TopLevelContent
@@ -184,11 +186,9 @@ export const tokenizeLine = (line, lineState) => {
184
186
  console.log({ state, line })
185
187
  throw new Error('no')
186
188
  }
187
- index += next[0].length
188
- tokens.push({
189
- type: token,
190
- length: next[0].length,
191
- })
189
+ const length = next[0].length
190
+ index += length
191
+ tokens.push(token, length)
192
192
  }
193
193
  if (state === State.AfterPropertyNameAfterColon) {
194
194
  state = State.TopLevelContent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -38,8 +38,8 @@
38
38
  "verror": "^1.10.1",
39
39
  "ws": "^8.8.1",
40
40
  "xdg-basedir": "^5.1.0",
41
- "@lvce-editor/pty-host": "0.4.1",
42
- "@lvce-editor/extension-host": "0.4.1"
41
+ "@lvce-editor/pty-host": "0.4.3",
42
+ "@lvce-editor/extension-host": "0.4.3"
43
43
  },
44
44
  "optionalDependencies": {
45
45
  "electron-clipboard-ex": "^1.3.3",
@@ -92,7 +92,7 @@ export const getRecentlyOpenedPath = () => {
92
92
  }
93
93
 
94
94
  export const getDefaultSettingsPath = () => {
95
- return Path.join(appDir, 'static', 'config', 'defaultSettings.json')
95
+ return Path.join(Root.root, 'config', 'defaultSettings.json')
96
96
  }
97
97
 
98
98
  export const setEnvironmentVariables = (variables) => {