3232NODE_RUNTIME_VERSION = '22.18.0'
3333NODE_DIST_URL = 'https://nodejs.org/dist/v{version}/{filename}'
3434
35+ CUSTOM_NODE_RUNTIME_VERSION = '24.15.0'
36+ CUSTOM_NODE_DIST_URL = 'https://github.com/sublimelsp/node-pointer-compression-builds/releases/download/v{version}/{filename}'
37+
3538ELECTRON_RUNTIME_VERSION = '37.3.1'
3639ELECTRON_NODE_VERSION = '22.18.0'
3740ELECTRON_DIST_URL = 'https://github.com/electron/electron/releases/download/v{version}/{filename}'
@@ -71,7 +74,7 @@ def _resolve_node_runtime(
7174 cls , package_name : str , storage_path : Path , required_node_version : NpmSpec ,
7275 ) -> NodeRuntime :
7376 resolved_runtime : NodeRuntime | None = None
74- default_runtimes = ['system' , 'local' ]
77+ default_runtimes = ['system' , 'local' , 'local-test' ]
7578 settings = sublime .load_settings (SETTINGS_FILENAME )
7679 selected_runtimes = cast ('list[str]' , settings .get ('nodejs_runtime' ) or default_runtimes )
7780 log_lines = ['--- lsp_utils Node.js resolving start ---' ]
@@ -90,11 +93,17 @@ def _resolve_node_runtime(
9093 break
9194 except Exception as ex :
9295 log_lines .append (f' * { ex } ' )
93- elif runtime_type == 'local' :
96+ elif runtime_type in { 'local' , 'local-test' } :
9497 log_lines .append (f'Resolving Node.js Runtime from lsp_utils for package { package_name } ...' )
95- use_electron = cast ('bool' , settings .get ('local_use_electron' ) or False )
98+ use_electron = runtime_type == 'local' and cast ('bool' , settings .get ('local_use_electron' ) or False )
9699 runtime_dir = storage_path / 'lsp_utils' / 'node-runtime'
97- local_runtime = ElectronRuntimeLocal (runtime_dir ) if use_electron else NodeRuntimeLocal (runtime_dir )
100+ node_version = NODE_RUNTIME_VERSION if runtime_type == 'local' else CUSTOM_NODE_RUNTIME_VERSION
101+ node_dist_url = NODE_DIST_URL if runtime_type == 'local' else CUSTOM_NODE_DIST_URL
102+ local_runtime = (
103+ ElectronRuntimeLocal (runtime_dir )
104+ if use_electron
105+ else NodeRuntimeLocal (runtime_dir , node_version , node_dist_url )
106+ )
98107 try :
99108 local_runtime .check_binary_present ()
100109 except Exception as ex :
@@ -256,11 +265,14 @@ def __init__(self) -> None:
256265@final
257266class NodeRuntimeLocal (NodeRuntime ):
258267
259- def __init__ (self , base_dir : Path , node_version : str = NODE_RUNTIME_VERSION ) -> None :
268+ def __init__ (
269+ self , base_dir : Path , node_version : str = NODE_RUNTIME_VERSION , node_dist_url : str = NODE_DIST_URL ,
270+ ) -> None :
260271 super ().__init__ ()
261272 self ._base_dir = (base_dir / node_version ).resolve ()
262273 self ._node_version = node_version
263274 self ._node_dir = self ._base_dir / 'node'
275+ self ._node_dist_url = node_dist_url
264276 self ._install_in_progress_marker_file = self ._base_dir / '.installing'
265277 self ._resolve_paths ()
266278
@@ -278,7 +290,7 @@ def install_node(self) -> None:
278290 self ._install_in_progress_marker_file .parent .mkdir (exist_ok = True , parents = True )
279291 self ._install_in_progress_marker_file .open ('a' , encoding = 'utf-8' ).close ()
280292 with ActivityIndicator (sublime .active_window (), '[LSP] Setting up local Node.js' ):
281- install_node = NodeInstaller (self ._base_dir , self ._node_version )
293+ install_node = NodeInstaller (self ._base_dir , self ._node_version , self . _node_dist_url )
282294 install_node .run ()
283295 self ._install_in_progress_marker_file .unlink ()
284296 self ._resolve_paths ()
@@ -314,7 +326,7 @@ def _resolve_lib(self) -> Path:
314326class NodeInstaller :
315327 """Command to install a local copy of Node.js."""
316328
317- def __init__ (self , base_dir : Path , node_version : str = NODE_RUNTIME_VERSION ) -> None :
329+ def __init__ (self , base_dir : Path , node_version : str , node_dist_url : str ) -> None :
318330 """
319331 Init NodeInstaller.
320332
@@ -323,6 +335,7 @@ def __init__(self, base_dir: Path, node_version: str = NODE_RUNTIME_VERSION) ->
323335 """
324336 self ._base_dir = base_dir
325337 self ._node_version = node_version
338+ self ._node_dist_url = node_dist_url
326339 self ._cache_dir = self ._base_dir / 'cache'
327340
328341 def run (self ) -> None :
@@ -352,7 +365,7 @@ def _node_archive(self) -> tuple[str, str]:
352365 msg = f'{ arch } { platform } is not supported'
353366 raise Exception (msg )
354367 filename = f'node-v{ self ._node_version } -{ node_os } -{ arch } .{ archive } '
355- dist_url = NODE_DIST_URL .format (version = self ._node_version , filename = filename )
368+ dist_url = self . _node_dist_url .format (version = self ._node_version , filename = filename )
356369 return filename , dist_url
357370
358371 def _install_node (self , archive_path : Path ) -> None :
0 commit comments