@lvce-editor/shared-process 0.91.17 → 0.91.18

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.91.17",
3
+ "version": "0.91.18",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@lvce-editor/assert": "1.7.0",
21
21
  "@lvce-editor/auth-process": "1.10.0",
22
- "@lvce-editor/extension-host-helper-process": "0.91.17",
22
+ "@lvce-editor/extension-host-helper-process": "0.91.18",
23
23
  "@lvce-editor/ipc": "16.4.0",
24
24
  "@lvce-editor/json-rpc": "8.3.0",
25
25
  "@lvce-editor/jsonc-parser": "1.5.0",
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "optionalDependencies": {
35
35
  "@lvce-editor/embeds-process": "4.10.0",
36
- "@lvce-editor/file-system-process": "5.5.0",
37
- "@lvce-editor/file-watcher-process": "4.6.0",
36
+ "@lvce-editor/file-system-process": "5.5.1",
37
+ "@lvce-editor/file-watcher-process": "4.6.3",
38
38
  "@lvce-editor/network-process": "5.2.0",
39
39
  "@lvce-editor/preload": "1.5.0",
40
40
  "@lvce-editor/preview-process": "11.0.0",
@@ -3,6 +3,6 @@ import { fileURLToPath } from 'url'
3
3
 
4
4
  export const getBuiltinExtensionsPath = () => {
5
5
  const staticServerPath = fileURLToPath(import.meta.resolve('@lvce-editor/static-server'))
6
- const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '247291e', 'extensions')
6
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '79ee513', 'extensions')
7
7
  return builtinExtensionsPath
8
8
  }
@@ -3,6 +3,7 @@ import * as FileWatcher from '../FileWatcher/FileWatcher.js'
3
3
  export const name = 'FileWatcher'
4
4
 
5
5
  export const Commands = {
6
+ dispose: FileWatcher.dispose,
6
7
  handleChange: FileWatcher.handleChange,
7
8
  watch: FileWatcher.watch,
8
9
  watchFile2: FileWatcher.watchFile2,
@@ -10,9 +10,31 @@ const handleEvents = (id, ipc, event) => {
10
10
  // TODO remove ipc and dispose file watcher when socket / messageport closes
11
11
  const internalIdMap = Object.create(null)
12
12
 
13
+ const addCloseListener = (ipc, listener) => {
14
+ if (ipc.addEventListener) {
15
+ ipc.addEventListener('close', listener)
16
+ } else {
17
+ ipc.on('close', listener)
18
+ }
19
+ }
20
+
21
+ const removeCloseListener = (ipc, listener) => {
22
+ if (ipc.removeEventListener) {
23
+ ipc.removeEventListener('close', listener)
24
+ } else {
25
+ ipc.off('close', listener)
26
+ }
27
+ }
28
+
13
29
  export const watch = async (ipc, id, { exclude, roots } ) => {
14
30
  const internalId = Id.create()
15
- internalIdMap[internalId] = { id, ipc }
31
+ const handleClose = async () => {
32
+ removeCloseListener(ipc, handleClose)
33
+ delete internalIdMap[internalId]
34
+ await disposeFileWatcher(internalId)
35
+ }
36
+ addCloseListener(ipc, handleClose)
37
+ internalIdMap[internalId] = { handleClose, id, ipc }
16
38
  return FileWatcherProcess.invoke('FileWatcher.watchFolders', {
17
39
  exclude,
18
40
  id: internalId,
@@ -28,19 +50,34 @@ const disposeFileWatcher = async (internalId) => {
28
50
  }
29
51
  }
30
52
 
53
+ export const dispose = async (ipc, id) => {
54
+ for (const [internalId, ref] of Object.entries(internalIdMap)) {
55
+ if ((ref).id === id && (ref).ipc === ipc) {
56
+ removeCloseListener(ipc, (ref).handleClose)
57
+ delete internalIdMap[internalId]
58
+ await disposeFileWatcher(Number(internalId))
59
+ return
60
+ }
61
+ }
62
+ }
63
+
31
64
  export const watchFile2 = async (ipc, id, uri) => {
32
65
  const internalId = Id.create()
33
66
  const handleClose = async () => {
34
- ipc.off('close', handleClose)
67
+ removeCloseListener(ipc, handleClose)
68
+ delete internalIdMap[internalId]
35
69
  await disposeFileWatcher(internalId)
36
70
  }
37
- ipc.on('close', handleClose)
38
- internalIdMap[internalId] = { id, ipc }
71
+ addCloseListener(ipc, handleClose)
72
+ internalIdMap[internalId] = { handleClose, id, ipc }
39
73
  // TODO promise never resolves, should resolve as soon as watcher has been set up
40
74
  await FileWatcherProcess.invoke('FileWatcher.watchFile2', internalId, uri)
41
75
  }
42
76
 
43
77
  export const handleChange = (event) => {
44
78
  const ref = internalIdMap[event.id]
79
+ if (!ref) {
80
+ return
81
+ }
45
82
  handleEvents(ref.id, ref.ipc, event)
46
83
  }
@@ -61,11 +61,11 @@ export const getSetupName = () => {
61
61
  return 'Lvce-Setup'
62
62
  }
63
63
 
64
- export const version = '0.91.17'
64
+ export const version = '0.91.18'
65
65
 
66
- export const commit = '247291e'
66
+ export const commit = '79ee513'
67
67
 
68
- export const date = '2026-07-16T17:28:32.000Z'
68
+ export const date = '2026-07-17T07:11:20.000Z'
69
69
 
70
70
  export const getVersion = () => {
71
71
  return version
@@ -2,5 +2,5 @@ import { join } from 'node:path'
2
2
  import * as Root from '../Root/Root.js'
3
3
 
4
4
  export const getPreloadUrl = () => {
5
- return join(Root.root, 'static', '247291e', 'packages', 'preload', 'dist', 'index.js')
5
+ return join(Root.root, 'static', '79ee513', 'packages', 'preload', 'dist', 'index.js')
6
6
  }
@@ -15,6 +15,7 @@ const METHODS_THAT_REQUIRE_SOCKET = new Set([
15
15
  'HandleMessagePortForExtensionHostHelperProcess.handleMessagePortForExtensionHostHelperProcess',
16
16
  'ElectronBrowserView.createBrowserView',
17
17
  'ElectronWebContentsView.createWebContentsView',
18
+ 'FileWatcher.dispose',
18
19
  'FileWatcher.watch',
19
20
  'FileWatcher.watchFile2',
20
21
  ])