@lvce-editor/shared-process 0.21.3 → 0.21.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.21.3",
3
+ "version": "0.21.4",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -18,12 +18,13 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/code-frame": "^7.23.5",
21
- "@lvce-editor/extension-host": "0.21.3",
22
- "@lvce-editor/extension-host-helper-process": "0.21.3",
21
+ "@lvce-editor/assert": "^1.0.1",
22
+ "@lvce-editor/extension-host": "0.21.4",
23
+ "@lvce-editor/extension-host-helper-process": "0.21.4",
23
24
  "@lvce-editor/json-rpc": "^0.4.0",
24
25
  "@lvce-editor/jsonc-parser": "^1.1.0",
25
26
  "@lvce-editor/pretty-error": "^1.3.0",
26
- "@lvce-editor/pty-host": "0.21.3",
27
+ "@lvce-editor/pty-host": "0.21.4",
27
28
  "@lvce-editor/verror": "^1.1.2",
28
29
  "debug": "^4.3.4",
29
30
  "execa": "^8.0.1",
@@ -1,59 +1 @@
1
- import { AssertionError } from '../AssertionError/AssertionError.js'
2
-
3
- const getType = (value) => {
4
- switch (typeof value) {
5
- case 'number':
6
- return 'number'
7
- case 'function':
8
- return 'function'
9
- case 'string':
10
- return 'string'
11
- case 'object':
12
- if (value === null) {
13
- return 'null'
14
- }
15
- if (Array.isArray(value)) {
16
- return 'array'
17
- }
18
- return 'object'
19
- case 'boolean':
20
- return 'boolean'
21
- default:
22
- return 'unknown'
23
- }
24
- }
25
-
26
- export const object = (value) => {
27
- const type = getType(value)
28
- if (type !== 'object') {
29
- throw new AssertionError('expected value to be of type object')
30
- }
31
- }
32
-
33
- export const number = (value) => {
34
- const type = getType(value)
35
- if (type !== 'number') {
36
- throw new AssertionError('expected value to be of type number')
37
- }
38
- }
39
-
40
- export const array = (value) => {
41
- const type = getType(value)
42
- if (type !== 'array') {
43
- throw new AssertionError('expected value to be of type array')
44
- }
45
- }
46
-
47
- export const string = (value) => {
48
- const type = getType(value)
49
- if (type !== 'string') {
50
- throw new AssertionError('expected value to be of type string')
51
- }
52
- }
53
-
54
- export const boolean = (value) => {
55
- const type = getType(value)
56
- if (type !== 'boolean') {
57
- throw new AssertionError('expected value to be of type boolean')
58
- }
59
- }
1
+ export * from '@lvce-editor/assert'
@@ -1,6 +1,6 @@
1
+ import { writeFileSync } from 'node:fs'
1
2
  import { Session } from 'node:inspector'
2
3
  import * as Timeout from '../Timeout/Timeout.js'
3
- import { writeFileSync } from 'node:fs'
4
4
 
5
5
  export const createProfile = async () => {
6
6
  const session = new Session()
@@ -1,7 +1,7 @@
1
1
  import { writeFile } from 'node:fs/promises'
2
- import got from 'got'
3
2
  import { tmpdir } from 'node:os'
4
3
  import { join } from 'node:path'
4
+ import got from 'got'
5
5
  import { WebSocket } from 'ws'
6
6
  import * as DevtoolsProtocolRpc from '../DevtoolsProtocolRpc/DevtoolsProtocolRpc.js'
7
7
 
@@ -29,7 +29,7 @@ export const createCpuProfile = async (pid) => {
29
29
  // AttachDebugger.attachDebugger(pid)
30
30
  const response = await got('http://localhost:9229/json/list').json()
31
31
  const first = response[0]
32
- const webSocketDebuggerUrl = first.webSocketDebuggerUrl
32
+ const { webSocketDebuggerUrl } = first
33
33
  const ipc = createConnection(webSocketDebuggerUrl)
34
34
 
35
35
  await new Promise((r) => {
@@ -37,7 +37,7 @@ export const createCpuProfile = async (pid) => {
37
37
  })
38
38
  const rpc = DevtoolsProtocolRpc.create(ipc)
39
39
  const result = await rpc.invoke('Debugger.enable')
40
- const debuggerId = result.result.debuggerId
40
+ const { debuggerId } = result.result
41
41
  console.log({ debuggerId })
42
42
  const p = await rpc.invoke('Profiler.enable')
43
43
  await rpc.invoke('Profiler.start')
@@ -46,7 +46,7 @@ export const createCpuProfile = async (pid) => {
46
46
  })
47
47
  const profileResult = await rpc.invoke('Profiler.stop')
48
48
  console.log({ profileResult })
49
- const profile = profileResult.result.profile
49
+ const { profile } = profileResult.result
50
50
  const profilePath = join(tmpdir(), 'node-profile.cpuprofile')
51
51
  const profileString = JSON.stringify(profile)
52
52
  await writeFile(profilePath, profileString)
@@ -18,4 +18,4 @@ export const getRipGrepPath = () => {
18
18
  return process.env.RIP_GREP_PATH
19
19
  }
20
20
 
21
- export const env = process.env
21
+ export const {env} = process
@@ -1,5 +1,5 @@
1
- import * as Assert from '../Assert/Assert.js'
2
1
  import { execa } from 'execa'
2
+ import * as Assert from '../Assert/Assert.js'
3
3
 
4
4
  /**
5
5
  *
@@ -1,8 +1,8 @@
1
- import { isAbsolute, join } from 'path'
1
+ import { existsSync } from 'node:fs'
2
+ import { isAbsolute, join } from 'node:path'
2
3
  import * as FileSystem from '../FileSystem/FileSystem.js'
3
4
  import * as JsonFile from '../JsonFile/JsonFile.js'
4
5
  import * as Path from '../Path/Path.js'
5
- import { existsSync } from 'fs'
6
6
 
7
7
  // TODO
8
8
  // - implement this for syntax highlighting projects
@@ -1,4 +1,4 @@
1
- import { readlink } from 'fs/promises'
1
+ import { readlink } from 'node:fs/promises'
2
2
  import * as ExtensionManifest from '../ExtensionManifest/ExtensionManifest.js'
3
3
  import * as ExtensionManifestStatus from '../ExtensionManifestStatus/ExtensionManifestStatus.js'
4
4
  import * as FileSystem from '../FileSystem/FileSystem.js'
@@ -20,7 +20,7 @@ const readSymlinks = (absolutePaths) => {
20
20
  }
21
21
 
22
22
  const mergeWithSymLinks = (manifests, symlinks) => {
23
- const length = manifests.length
23
+ const {length} = manifests
24
24
  const merged = []
25
25
  for (let i = 0; i < length; i++) {
26
26
  const manifest = manifests[i]
@@ -1,4 +1,5 @@
1
1
  import * as FirstWebSocketEventType from '../FirstWebSocketEventType/FirstWebSocketEventType.js'
2
+ import * as GetFirstEvent from '../GetFirstEvent/GetFirstEvent.js'
2
3
  import * as WebSocketReadyState from '../WebSocketReadyState/WebSocketReadyState.js'
3
4
 
4
5
  export const getFirstWebSocketEvent = async (webSocket) => {
@@ -16,26 +17,9 @@ export const getFirstWebSocketEvent = async (webSocket) => {
16
17
  default:
17
18
  break
18
19
  }
19
- const { type, event } = await new Promise((resolve) => {
20
- const cleanup = (value) => {
21
- webSocket.off('open', handleOpen)
22
- webSocket.off('close', handleClose)
23
- resolve(value)
24
- }
25
- const handleOpen = (event) => {
26
- cleanup({
27
- type: FirstWebSocketEventType.Open,
28
- event,
29
- })
30
- }
31
- const handleClose = (event) => {
32
- cleanup({
33
- type: FirstWebSocketEventType.Close,
34
- event,
35
- })
36
- }
37
- webSocket.on('open', handleOpen)
38
- webSocket.on('close', handleClose)
20
+ const { type, event } = await GetFirstEvent.getFirstEvent(webSocket, {
21
+ open: FirstWebSocketEventType.Open,
22
+ close: FirstWebSocketEventType.Close,
39
23
  })
40
24
  return { type, event }
41
25
  }
@@ -1,7 +1,7 @@
1
- import { VError } from '../VError/VError.js'
2
1
  import { execFile as _execFile } from 'node:child_process'
3
- import * as Signal from '../Signal/Signal.js'
4
2
  import { promisify } from 'node:util'
3
+ import * as Signal from '../Signal/Signal.js'
4
+ import { VError } from '../VError/VError.js'
5
5
 
6
6
  const execFile = promisify(_execFile)
7
7
 
@@ -14,7 +14,6 @@ export const getPsOutput = async () => {
14
14
  if (error && error.signal === Signal.SIGINT) {
15
15
  return ''
16
16
  }
17
- // @ts-ignore
18
17
  throw new VError(error, `Failed to execute ps`)
19
18
  }
20
19
  }
@@ -1,6 +1,6 @@
1
+ import * as Os from 'node:os'
1
2
  import * as Platform from '../Platform/Platform.js'
2
3
  import * as ByteSize from '../ByteSize/ByteSize.js'
3
- import * as Os from 'node:os'
4
4
 
5
5
  const UiStrings = {
6
6
  OsVersion: 'Os Version',
@@ -11,7 +11,7 @@ const UiStrings = {
11
11
  const visitVersion = {
12
12
  key: UiStrings.OsVersion,
13
13
  getValue() {
14
- const version = Platform.version
14
+ const { version } = Platform
15
15
  return version
16
16
  },
17
17
  }
@@ -24,9 +24,9 @@ const visitCpus = {
24
24
  return ''
25
25
  }
26
26
  const firstCpu = cpus[0]
27
- const model = firstCpu.model
27
+ const { model } = firstCpu
28
28
  const cpuLength = cpus.length
29
- const speed = firstCpu.speed
29
+ const { speed } = firstCpu
30
30
  return `${model} (${cpuLength} x ${speed})`
31
31
  },
32
32
  }
@@ -56,7 +56,7 @@ const combineVisitors = (visitors) => {
56
56
  const longestKeyLength = getLongestKeyLength(visitors)
57
57
  const result = []
58
58
  for (const visitor of visitors) {
59
- const key = visitor.key
59
+ const { key } = visitor
60
60
  const value = visitor.getValue()
61
61
  result.push(`${key}: ${value}`)
62
62
  }
@@ -7,7 +7,7 @@ export const handleWebSocket = async (message, handle) => {
7
7
  try {
8
8
  Assert.object(message)
9
9
  Assert.object(handle)
10
- const headers = message.headers
10
+ const { headers } = message
11
11
  if (!headers) {
12
12
  throw new VError('missing websocket headers')
13
13
  }
@@ -1,6 +1,6 @@
1
1
  export const listen = () => {
2
2
  // @ts-ignore
3
- const parentPort = process.parentPort
3
+ const { parentPort } = process
4
4
  if (!parentPort) {
5
5
  throw new Error('parent port must be defined')
6
6
  }
@@ -1,8 +1,8 @@
1
- import * as Assert from '../Assert/Assert.js'
2
1
  import { fork } from 'node:child_process'
3
- import * as GetFirstNodeChildProcessEvent from '../GetFirstNodeChildProcessEvent/GetFirstNodeChildProcessEvent.js'
4
- import * as FirstNodeWorkerEventType from '../FirstNodeWorkerEventType/FirstNodeWorkerEventType.js'
2
+ import * as Assert from '../Assert/Assert.js'
5
3
  import { ChildProcessError } from '../ChildProcessError/ChildProcessError.js'
4
+ import * as FirstNodeWorkerEventType from '../FirstNodeWorkerEventType/FirstNodeWorkerEventType.js'
5
+ import * as GetFirstNodeChildProcessEvent from '../GetFirstNodeChildProcessEvent/GetFirstNodeChildProcessEvent.js'
6
6
  import { VError } from '../VError/VError.js'
7
7
 
8
8
  export const create = async ({ path, argv = [], env, execArgv = [], stdio = 'inherit', name = 'child process' }) => {
@@ -61,11 +61,11 @@ export const getSetupName = () => {
61
61
  return 'Lvce-Setup'
62
62
  }
63
63
 
64
- export const version = '0.21.3'
64
+ export const version = '0.21.4'
65
65
 
66
- export const commit = '21796c8'
66
+ export const commit = 'f091269'
67
67
 
68
- export const date = '2023-12-16T09:10:52.000Z'
68
+ export const date = '2023-12-18T23:35:44.000Z'
69
69
 
70
70
  export const getVersion = () => {
71
71
  return version
@@ -6,11 +6,11 @@ export const toTextSearchResult = (parsedLine, remaining, charsBefore, charsAfte
6
6
  const parsedLineData = parsedLine.data
7
7
  const lines = ParseRipGrepLines.parseRipGrepLines(parsedLineData)
8
8
  const lineNumber = parsedLineData.line_number
9
- const submatches = parsedLineData.submatches
9
+ const { submatches } = parsedLineData
10
10
  const linesLength = lines.length
11
11
  for (const submatch of submatches) {
12
12
  const previewStart = Math.max(submatch.start - charsBefore, 0)
13
- let actualStart = previewStart
13
+ const actualStart = previewStart
14
14
  const previewEnd = Math.min(submatch.end + charsAfter, linesLength)
15
15
  const previewText = lines.slice(actualStart, previewEnd)
16
16
  results.push({
@@ -1,6 +0,0 @@
1
- export class AssertionError extends Error {
2
- constructor(message) {
3
- super(message)
4
- this.name = 'AssertionError'
5
- }
6
- }