@lvce-editor/shared-process 0.85.2 → 0.86.0

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.
Files changed (461) hide show
  1. package/index.js +1 -1
  2. package/package.json +12 -12
  3. package/src/parts/AddCustomPathsToIndexHtml/AddCustomPathsToIndexHtml.js +2 -2
  4. package/src/parts/AddSemiColon/AddSemiColon.js +4 -3
  5. package/src/parts/AppWindow/AppWindow.js +30 -22
  6. package/src/parts/ApplyEdit/ApplyEdit.js +7 -6
  7. package/src/parts/ApplyIncomingIpcResponse/ApplyIncomingIpcResponse.js +13 -12
  8. package/src/parts/Assert/Assert.js +1 -1
  9. package/src/parts/AttachDebugger/AttachDebugger.ipc.js +6 -4
  10. package/src/parts/AttachDebugger/AttachDebugger.js +5 -4
  11. package/src/parts/AuthProcess/AuthProcess.js +14 -12
  12. package/src/parts/AuthProcessPath/AuthProcessPath.js +4 -3
  13. package/src/parts/AuthProcessState/AuthProcessState.js +12 -9
  14. package/src/parts/Authority/Authority.js +1 -1
  15. package/src/parts/AutoUpdateType/AutoUpdateType.js +4 -4
  16. package/src/parts/AutoUpdater/AutoUpdater.ipc.js +5 -4
  17. package/src/parts/AutoUpdater/AutoUpdater.js +31 -31
  18. package/src/parts/AutoUpdaterAppImage/AutoUpdaterAppImage.ipc.js +7 -5
  19. package/src/parts/AutoUpdaterAppImage/AutoUpdaterAppImage.js +50 -49
  20. package/src/parts/AutoUpdaterWindowsNsis/AutoUpdaterWindowsNsis.ipc.js +5 -4
  21. package/src/parts/AutoUpdaterWindowsNsis/AutoUpdaterWindowsNsis.js +59 -58
  22. package/src/parts/BrowserWindowV8CacheOptions/BrowserWindowV8CacheOptions.js +4 -3
  23. package/src/parts/BuiltinExtensionsPath/BuiltinExtensionsPath.js +7 -6
  24. package/src/parts/BulkReplacement/BulkReplacement.ipc.js +6 -4
  25. package/src/parts/BulkReplacement/BulkReplacement.js +16 -16
  26. package/src/parts/BulkReplacementContent/BulkReplacementContent.js +27 -26
  27. package/src/parts/ByteSize/ByteSize.js +4 -4
  28. package/src/parts/Callback/Callback.js +1 -1
  29. package/src/parts/Character/Character.js +12 -12
  30. package/src/parts/Clamp/Clamp.js +2 -2
  31. package/src/parts/Cli/Cli.js +14 -14
  32. package/src/parts/CliCommandType/CliCommandType.js +11 -11
  33. package/src/parts/CliHelp/CliHelp.js +9 -8
  34. package/src/parts/CliInstall/CliInstall.js +24 -24
  35. package/src/parts/CliLink/CliLink.js +17 -17
  36. package/src/parts/CliList/CliList.js +18 -15
  37. package/src/parts/CliModule/CliModule.js +27 -26
  38. package/src/parts/CliStatus/CliStatus.js +5 -4
  39. package/src/parts/CliUnlink/CliUnlink.js +17 -17
  40. package/src/parts/CliVersion/CliVersion.js +8 -7
  41. package/src/parts/ClipBoard/ClipBoard.ipc.js +7 -5
  42. package/src/parts/ClipBoard/ClipBoard.js +7 -5
  43. package/src/parts/ClipBoardProcess/ClipBoardProcess.js +19 -16
  44. package/src/parts/ClipBoardProcessPath/ClipBoardProcessPath.js +13 -3
  45. package/src/parts/ColorTheme/ColorTheme.js +18 -15
  46. package/src/parts/Command/Command.js +69 -62
  47. package/src/parts/CommandNotFoundError/CommandNotFoundError.js +10 -7
  48. package/src/parts/CompareVersion/CompareVersion.js +2 -2
  49. package/src/parts/ConnectIpcToElectron/ConnectIpcToElectron.js +20 -18
  50. package/src/parts/ContentSecurityPolicy/ContentSecurityPolicy.ipc.js +6 -4
  51. package/src/parts/ContentSecurityPolicy/ContentSecurityPolicy.js +7 -6
  52. package/src/parts/ContentSecurityPolicyDocument/ContentSecurityPolicyDocument.js +45 -39
  53. package/src/parts/ContentSecurityPolicyState/ContentSecurityPolicyState.js +7 -5
  54. package/src/parts/CpuProfile/CpuProfile.js +25 -22
  55. package/src/parts/Crash/Crash.ipc.js +5 -4
  56. package/src/parts/Crash/Crash.js +11 -8
  57. package/src/parts/CreateTestOverview/CreateTestOverview.js +7 -6
  58. package/src/parts/CreateTestOverviewHtml/CreateTestOverviewHtml.js +24 -21
  59. package/src/parts/CreateUtilityProcessRpc/CreateUtilityProcessRpc.js +6 -5
  60. package/src/parts/CrossOriginEmbedderPolicy/CrossOriginEmbedderPolicy.js +1 -1
  61. package/src/parts/CrossOriginOpenerPolicy/CrossOriginOpenerPolicy.js +2 -2
  62. package/src/parts/CrossOriginResourcePolicy/CrossOriginResourcePolicy.js +1 -1
  63. package/src/parts/DeduplicateExtensions/DeduplicateExtensions.js +13 -13
  64. package/src/parts/DefaultUrl/DefaultUrl.js +4 -3
  65. package/src/parts/Desktop/Desktop.js +19 -18
  66. package/src/parts/DesktopCapturer/DesktopCapturer.ipc.js +6 -4
  67. package/src/parts/DesktopCapturer/DesktopCapturer.js +4 -3
  68. package/src/parts/DesktopType/DesktopType.js +3 -3
  69. package/src/parts/DestroySocket/DestroySocket.js +4 -5
  70. package/src/parts/Developer/Developer.ipc.js +12 -11
  71. package/src/parts/Developer/Developer.js +40 -33
  72. package/src/parts/DirentType/DirentType.js +12 -12
  73. package/src/parts/Download/Download.ipc.js +6 -4
  74. package/src/parts/Download/Download.js +4 -3
  75. package/src/parts/DownloadAndExtract/DownloadAndExtract.js +5 -4
  76. package/src/parts/ElectronApplicationMenu/ElectronApplicationMenu.ipc.js +6 -5
  77. package/src/parts/ElectronApplicationMenu/ElectronApplicationMenu.js +23 -20
  78. package/src/parts/ElectronContentTracing/ElectronContentTracing.ipc.js +7 -5
  79. package/src/parts/ElectronContentTracing/ElectronContentTracing.js +7 -5
  80. package/src/parts/ElectronContextMenu/ElectronContextMenu.ipc.js +6 -4
  81. package/src/parts/ElectronContextMenu/ElectronContextMenu.js +8 -7
  82. package/src/parts/ElectronDeveloper/ElectronDeveloper.ipc.js +6 -4
  83. package/src/parts/ElectronDeveloper/ElectronDeveloper.js +4 -3
  84. package/src/parts/ElectronDialog/ElectronDialog.ipc.js +8 -6
  85. package/src/parts/ElectronDialog/ElectronDialog.js +10 -7
  86. package/src/parts/ElectronInitialize/ElectronInitialize.ipc.js +6 -4
  87. package/src/parts/ElectronInitialize/ElectronInitialize.js +10 -9
  88. package/src/parts/ElectronNet/ElectronNet.ipc.js +6 -4
  89. package/src/parts/ElectronNet/ElectronNet.js +4 -3
  90. package/src/parts/ElectronNetLog/ElectronNetLog.ipc.js +7 -5
  91. package/src/parts/ElectronNetLog/ElectronNetLog.js +7 -5
  92. package/src/parts/ElectronPowerSaveBlocker/ElectronPowerSaveBlocker.ipc.js +7 -5
  93. package/src/parts/ElectronPowerSaveBlocker/ElectronPowerSaveBlocker.js +7 -5
  94. package/src/parts/ElectronProcess/ElectronProcess.ipc.js +7 -5
  95. package/src/parts/ElectronProcess/ElectronProcess.js +7 -5
  96. package/src/parts/ElectronSafeStorage/ElectronSafeStorage.ipc.js +8 -6
  97. package/src/parts/ElectronSafeStorage/ElectronSafeStorage.js +13 -10
  98. package/src/parts/ElectronShell/ElectronShell.ipc.js +6 -4
  99. package/src/parts/ElectronShell/ElectronShell.js +4 -3
  100. package/src/parts/ElectronWindow/ElectronWindow.ipc.js +18 -15
  101. package/src/parts/ElectronWindow/ElectronWindow.js +87 -61
  102. package/src/parts/ElectronWindowAbout/ElectronWindowAbout.ipc.js +6 -4
  103. package/src/parts/ElectronWindowAbout/ElectronWindowAbout.js +4 -3
  104. package/src/parts/ElectronWindowProcessExplorer/ElectronWindowProcessExplorer.ipc.js +6 -4
  105. package/src/parts/ElectronWindowProcessExplorer/ElectronWindowProcessExplorer.js +33 -31
  106. package/src/parts/EmbedsProcess/EmbedsProcess.js +14 -12
  107. package/src/parts/EmbedsProcessPath/EmbedsProcessPath.js +13 -3
  108. package/src/parts/EmbedsProcessState/EmbedsProcessState.js +12 -9
  109. package/src/parts/EncodingType/EncodingType.js +2 -2
  110. package/src/parts/Env/Env.js +16 -11
  111. package/src/parts/Error/FileSystemError.js +9 -6
  112. package/src/parts/ErrorCodes/ErrorCodes.js +22 -22
  113. package/src/parts/ErrorHandling/ErrorHandling.js +61 -53
  114. package/src/parts/Exec/Exec.ipc.js +6 -4
  115. package/src/parts/Exec/Exec.js +6 -5
  116. package/src/parts/ExecCommand/ExecCommand.js +22 -19
  117. package/src/parts/ExecPromise/ExecPromise.js +4 -3
  118. package/src/parts/Exit/Exit.ipc.js +6 -4
  119. package/src/parts/Exit/Exit.js +4 -3
  120. package/src/parts/ExitCode/ExitCode.js +5 -3
  121. package/src/parts/ExportStatic/ExportStatic.js +696 -558
  122. package/src/parts/ExtensionHostHelperProcessIpc/ExtensionHostHelperProcessIpc.js +15 -14
  123. package/src/parts/ExtensionHostRpc/ExtensionHostRpc.js +79 -70
  124. package/src/parts/ExtensionInstall/ExtensionInstall.ipc.js +6 -4
  125. package/src/parts/ExtensionInstall/ExtensionInstall.js +23 -21
  126. package/src/parts/ExtensionInstallFromFile/ExtensionInstallFromFile.js +34 -33
  127. package/src/parts/ExtensionInstallFromGitHub/ExtensionInstallFromGitHub.js +31 -31
  128. package/src/parts/ExtensionInstallFromUrl/ExtensionInstallFromUrl.js +32 -32
  129. package/src/parts/ExtensionInstallParseInput/ExtensionInstallParseInput.js +46 -43
  130. package/src/parts/ExtensionInstallType/ExtensionInstallType.js +7 -4
  131. package/src/parts/ExtensionLink/ExtensionLink.js +40 -40
  132. package/src/parts/ExtensionList/ExtensionList.js +72 -66
  133. package/src/parts/ExtensionManagement/ExtensionManagement.ipc.js +21 -20
  134. package/src/parts/ExtensionManagement/ExtensionManagement.js +157 -133
  135. package/src/parts/ExtensionManagement/ExtensionManagementColorTheme.js +70 -62
  136. package/src/parts/ExtensionManagement/ExtensionManagementIconTheme.js +26 -26
  137. package/src/parts/ExtensionManagement/ExtensionManagementLanguages.js +63 -58
  138. package/src/parts/ExtensionManifest/ExtensionManifest.js +54 -56
  139. package/src/parts/ExtensionManifestInputType/ExtensionManifestInputType.js +7 -4
  140. package/src/parts/ExtensionManifestStatus/ExtensionManifestStatus.js +3 -2
  141. package/src/parts/ExtensionManifests/ExtensionManifests.js +46 -41
  142. package/src/parts/ExtensionManifests/ExtensionManifestsFromFolder.js +21 -21
  143. package/src/parts/ExtensionManifests/ExtensionManifestsFromLinkedExtension.js +17 -16
  144. package/src/parts/ExtensionManifests/ExtensionManifestsFromLinkedExtensionsFolder.js +36 -35
  145. package/src/parts/ExtensionManifests/ExtensionManifestsFromOnlyExtension.js +8 -7
  146. package/src/parts/ExtensionUninstall/ExtensionUninstall.js +15 -15
  147. package/src/parts/ExtensionUnlink/ExtensionUnlink.js +19 -19
  148. package/src/parts/Extract/Extract.js +12 -10
  149. package/src/parts/FileNotFoundError/FileNotFoundError.js +15 -11
  150. package/src/parts/FileSystem/FileSystem.ipc.js +33 -30
  151. package/src/parts/FileSystem/FileSystem.js +269 -257
  152. package/src/parts/FileSystemDisk/FileSystemDisk.ipc.js +17 -15
  153. package/src/parts/FileSystemDisk/FileSystemDisk.js +226 -217
  154. package/src/parts/FileSystemProcess/FileSystemProcess.js +19 -16
  155. package/src/parts/FileSystemProcessPath/FileSystemProcessPath.js +3 -2
  156. package/src/parts/FileWatcher/FileWatcher.ipc.js +8 -6
  157. package/src/parts/FileWatcher/FileWatcher.js +40 -35
  158. package/src/parts/FileWatcherProcess/FileWatcherProcess.js +19 -16
  159. package/src/parts/FileWatcherProcessPath/FileWatcherProcessPath.js +3 -2
  160. package/src/parts/FirstNodeWorkerEventType/FirstNodeWorkerEventType.js +3 -3
  161. package/src/parts/FixElectronParameters/FixElectronParameters.js +10 -9
  162. package/src/parts/GetAppImageDownloadUrl/GetAppImageDownloadUrl.js +5 -4
  163. package/src/parts/GetAppImagePath/GetAppImagePath.js +4 -3
  164. package/src/parts/GetAppWindowOptions/GetAppWindowOptions.js +63 -53
  165. package/src/parts/GetBrowserWindowOptions/GetBrowserWindowOptions.js +28 -27
  166. package/src/parts/GetContentResponse/GetContentResponse.js +11 -10
  167. package/src/parts/GetContentSecurityPolicy/GetContentSecurityPolicy.js +5 -4
  168. package/src/parts/GetCustomPathsConfig/GetCustomPathsConfig.js +14 -13
  169. package/src/parts/GetDirentType/GetDirentType.js +25 -24
  170. package/src/parts/GetElectronFileResponse/GetElectronFileResponse.ipc.js +6 -4
  171. package/src/parts/GetElectronFileResponse/GetElectronFileResponse.js +48 -47
  172. package/src/parts/GetElectronFileResponseAbsolutePath/GetElectronFileResponseAbsolutePath.js +61 -58
  173. package/src/parts/GetElectronFileResponseContent/GetElectronFileResponseContent.js +31 -29
  174. package/src/parts/GetElectronFileResponseRelativePath/GetElectronFileResponseRelativePath.js +33 -30
  175. package/src/parts/GetElectronRebuildPath/GetElectronRebuildPath.js +9 -8
  176. package/src/parts/GetEtag/GetEtag.js +2 -2
  177. package/src/parts/GetEtagFromStats/GetEtagFromStats.js +10 -9
  178. package/src/parts/GetExtensionEtags/GetExtensionEtags.js +66 -60
  179. package/src/parts/GetExtensions/GetExtensions.ipc.js +6 -4
  180. package/src/parts/GetExtensions/GetExtensions.js +4 -3
  181. package/src/parts/GetExtraHeaders/GetExtraHeaders.js +8 -7
  182. package/src/parts/GetFirstEvent/GetFirstEvent.js +21 -20
  183. package/src/parts/GetFirstSpawnedProcessEvent/GetFirstSpawnedProcessEvent.js +8 -7
  184. package/src/parts/GetFolderSizeInternal/GetFolderSizeInternal.js +20 -20
  185. package/src/parts/GetHeaders/GetHeaders.js +34 -33
  186. package/src/parts/GetHeadersDefault/GetHeadersDefault.js +2 -2
  187. package/src/parts/GetHeadersOtherWorker/GetHeadersOtherWorker.js +13 -12
  188. package/src/parts/GetHelpString/GetHelpString.js +5 -4
  189. package/src/parts/GetHttpErrorMessage/GetHttpErrorMessage.js +19 -20
  190. package/src/parts/GetIcon/GetIcon.js +21 -20
  191. package/src/parts/GetLatestReleaseVersion/GetLatestReleaseVersion.js +33 -32
  192. package/src/parts/GetMimeType/GetMimeType.js +31 -30
  193. package/src/parts/GetMultipleChoiceResponse/GetMultipleChoiceResponse.js +11 -10
  194. package/src/parts/GetNewLineIndex/GetNewLineIndex.js +5 -4
  195. package/src/parts/GetNotFoundResponse/GetNotFoundResponse.js +11 -10
  196. package/src/parts/GetNotModifiedResponse/GetNotModifiedResponse.js +11 -10
  197. package/src/parts/GetNsisUpdateArgs/GetNsisUpdateArgs.js +6 -6
  198. package/src/parts/GetNsisUpdateDownloadPath/GetNsisUpdateDownloadPath.js +10 -9
  199. package/src/parts/GetPathEtag/GetPathEtag.js +11 -10
  200. package/src/parts/GetPathName/GetPathName.js +3 -3
  201. package/src/parts/GetPortTuple/GetPortTuple.js +10 -10
  202. package/src/parts/GetProcessExplorerUrl/GetProcessExplorerUrl.js +4 -3
  203. package/src/parts/GetRemoteUrl/GetRemoteUrl.js +5 -4
  204. package/src/parts/GetResolvedTestPath/GetResolvedTestPath.js +19 -17
  205. package/src/parts/GetServerErrorResponse/GetServerErrorResponse.js +11 -10
  206. package/src/parts/GetStatusString/GetStatusString.js +62 -54
  207. package/src/parts/GetTerminalProcessPath/GetTerminalProcessPath.js +5 -4
  208. package/src/parts/GetTerminalSpawnOptions/GetTerminalSpawnOptions.ipc.js +6 -4
  209. package/src/parts/GetTerminalSpawnOptions/GetTerminalSpawnOptions.js +17 -16
  210. package/src/parts/GetTestPath/GetTestPath.js +4 -3
  211. package/src/parts/GetTestRequestResponse/GetTestRequestResponse.js +72 -72
  212. package/src/parts/GetTitleBarItems/GetTitleBarItems.js +41 -40
  213. package/src/parts/GetTransferrables/GetTransferrables.js +7 -6
  214. package/src/parts/GetTypeFromUrl/GetTypeFromUrl.js +19 -18
  215. package/src/parts/GetTypeScriptPath/GetTypeScriptPath.js +21 -12
  216. package/src/parts/GetVersionString/GetVersionString.js +5 -4
  217. package/src/parts/GetWebViewsFromExtensions/GetWebViewsFromExtensions.js +23 -22
  218. package/src/parts/GetWindowId/GetWindowId.ipc.js +6 -4
  219. package/src/parts/GetWindowId/GetWindowId.js +6 -5
  220. package/src/parts/GetWindowsNsisDownloadUrl/GetWindowsNsisDownloadUrl.js +7 -6
  221. package/src/parts/GetWorkspaceId/GetWorkspaceId.js +4 -3
  222. package/src/parts/GitLsFiles/GitLsFiles.ipc.js +8 -6
  223. package/src/parts/GitLsFiles/GitLsFiles.js +22 -19
  224. package/src/parts/HandleCliArgs/HandleCliArgs.ipc.js +6 -4
  225. package/src/parts/HandleCliArgs/HandleCliArgs.js +11 -11
  226. package/src/parts/HandleDisconnect/HandleDisconnect.js +6 -5
  227. package/src/parts/HandleElectronMessagePort/HandleElectronMessagePort.ipc.js +6 -4
  228. package/src/parts/HandleElectronMessagePort/HandleElectronMessagePort.js +10 -9
  229. package/src/parts/HandleElectronReady/HandleElectronReady.ipc.js +6 -4
  230. package/src/parts/HandleElectronReady/HandleElectronReady.js +21 -21
  231. package/src/parts/HandleIncomingIpc/HandleIncomingIpc.js +40 -38
  232. package/src/parts/HandleIncomingIpcMessagePort/HandleIncomingIpcMessagePort.js +7 -7
  233. package/src/parts/HandleIncomingIpcWebSocket/HandleIncomingIpcWebSocket.js +7 -7
  234. package/src/parts/HandleIpc/HandleIpc.js +24 -23
  235. package/src/parts/HandleIpcAuthProcess/HandleIpcAuthProcess.js +11 -9
  236. package/src/parts/HandleIpcClipBoardProcess/HandleIpcClipBoardProcess.js +21 -17
  237. package/src/parts/HandleIpcEmbedsProcess/HandleIpcEmbedsProcess.js +11 -9
  238. package/src/parts/HandleIpcExtensionHostHelperProcess/HandleIpcExtensionHostHelperProcess.js +28 -24
  239. package/src/parts/HandleIpcFileSystemProcess/HandleIpcFileSystemProcess.js +21 -17
  240. package/src/parts/HandleIpcFileWatcher/HandleIpcFileWatcher.js +22 -18
  241. package/src/parts/HandleIpcModule/HandleIpcModule.js +36 -35
  242. package/src/parts/HandleIpcProcessExplorer/HandleIpcProcessExplorer.js +23 -19
  243. package/src/parts/HandleIpcSearchProcess/HandleIpcSearchProcess.js +21 -17
  244. package/src/parts/HandleIpcSharedProcess/HandleIpcSharedProcess.js +40 -36
  245. package/src/parts/HandleIpcTerminalProcess/HandleIpcTerminalProcess.js +22 -18
  246. package/src/parts/HandleMessage/HandleMessage.js +25 -14
  247. package/src/parts/HandleMessagePortForAuthProcess/HandleMessagePortForAuthProcess.ipc.js +7 -5
  248. package/src/parts/HandleMessagePortForAuthProcess/HandleMessagePortForAuthProcess.js +20 -18
  249. package/src/parts/HandleMessagePortForClipBoardProcess/HandleMessagePortForClipBoardProcess.ipc.js +6 -4
  250. package/src/parts/HandleMessagePortForClipBoardProcess/HandleMessagePortForClipBoardProcess.js +7 -6
  251. package/src/parts/HandleMessagePortForEmbedsProcess/HandleMessagePortForEmbedsProcess.ipc.js +7 -5
  252. package/src/parts/HandleMessagePortForEmbedsProcess/HandleMessagePortForEmbedsProcess.js +20 -18
  253. package/src/parts/HandleMessagePortForExtensionHostHelperProcess/HandleMessagePortForExtensionHostHelperProcess.ipc.js +6 -4
  254. package/src/parts/HandleMessagePortForExtensionHostHelperProcess/HandleMessagePortForExtensionHostHelperProcess.js +19 -18
  255. package/src/parts/HandleMessagePortForFileSystemProcess/HandleMessagePortForFileSystemProcess.ipc.js +6 -4
  256. package/src/parts/HandleMessagePortForFileSystemProcess/HandleMessagePortForFileSystemProcess.js +7 -6
  257. package/src/parts/HandleMessagePortForProcessExplorer/HandleMessagePortForProcessExplorer.ipc.js +6 -4
  258. package/src/parts/HandleMessagePortForProcessExplorer/HandleMessagePortForProcessExplorer.js +7 -7
  259. package/src/parts/HandleMessagePortForSearchProcess/HandleMessagePortForSearchProcess.ipc.js +6 -4
  260. package/src/parts/HandleMessagePortForSearchProcess/HandleMessagePortForSearchProcess.js +5 -4
  261. package/src/parts/HandleMessagePortForTerminalProcess/HandleMessagePortForTerminalProcess.ipc.js +6 -4
  262. package/src/parts/HandleMessagePortForTerminalProcess/HandleMessagePortForTerminalProcess.js +7 -6
  263. package/src/parts/HandleNodeMessagePort/HandleNodeMessagePort.ipc.js +6 -4
  264. package/src/parts/HandleNodeMessagePort/HandleNodeMessagePort.js +10 -9
  265. package/src/parts/HandleRemoteRequest/HandleRemoteRequest.ipc.js +6 -4
  266. package/src/parts/HandleRemoteRequest/HandleRemoteRequest.js +11 -10
  267. package/src/parts/HandleRequest/HandleRequest.ipc.js +6 -4
  268. package/src/parts/HandleRequest/HandleRequest.js +21 -20
  269. package/src/parts/HandleRequestTest/HandleRequestTest.ipc.js +6 -4
  270. package/src/parts/HandleRequestTest/HandleRequestTest.js +10 -9
  271. package/src/parts/HandleSocketError/HandleSocketError.js +11 -10
  272. package/src/parts/HandleUncaughtExceptionMonitor/HandleUncaughtExceptionMonitor.js +12 -9
  273. package/src/parts/HandleWebSocket/HandleWebSocket.ipc.js +6 -4
  274. package/src/parts/HandleWebSocket/HandleWebSocket.js +24 -24
  275. package/src/parts/HandleWebSocketForClipBoardProcess/HandleWebSocketForClipBoardProcess.js +5 -4
  276. package/src/parts/HandleWebSocketForExtensionHostHelperProcess/HandleWebSocketForExtensionHostHelperProcess.js +5 -4
  277. package/src/parts/HandleWebSocketForFileSystemProcess/HandleWebSocketForFileSystemProcess.js +5 -4
  278. package/src/parts/HandleWebSocketForProcessExplorer/HandleWebSocketForProcessExplorer.js +5 -4
  279. package/src/parts/HandleWebSocketForSearchProcess/HandleWebSocketForSearchProcess.js +5 -4
  280. package/src/parts/HandleWebSocketForSharedProcess/HandleWebSocketForSharedProcess.js +5 -4
  281. package/src/parts/HandleWebSocketForTerminalProcess/HandleWebSocketForTerminalProcess.js +5 -4
  282. package/src/parts/HandleWebSocketForUnknown/HandleWebSocketForUnknown.js +6 -5
  283. package/src/parts/HandleWebSocketModule/HandleWebSocketModule.js +33 -32
  284. package/src/parts/HandleWindowAllClosed/HandleWindowAllClosed.ipc.js +6 -4
  285. package/src/parts/HandleWindowAllClosed/HandleWindowAllClosed.js +7 -6
  286. package/src/parts/Hash/Hash.js +6 -4
  287. package/src/parts/HeapSnapshot/HeapSnapshot.ipc.js +4 -3
  288. package/src/parts/HeapSnapshot/HeapSnapshot.js +9 -6
  289. package/src/parts/HttpHeader/HttpHeader.js +9 -9
  290. package/src/parts/HttpServerResponse/HttpServerResponse.js +22 -19
  291. package/src/parts/HttpStatusCode/HttpStatusCode.js +6 -6
  292. package/src/parts/Id/Id.js +6 -5
  293. package/src/parts/IndexHtmlPath/IndexHtmlPath.js +4 -3
  294. package/src/parts/InferExtensionId/InferExtensionId.js +8 -7
  295. package/src/parts/InstallExtension/InstallExtension.ipc.js +4 -3
  296. package/src/parts/InstallExtension/InstallExtension.js +28 -28
  297. package/src/parts/IpcChild/IpcChild.js +14 -13
  298. package/src/parts/IpcChildModule/IpcChildModule.js +26 -19
  299. package/src/parts/IpcChildType/IpcChildType.js +19 -18
  300. package/src/parts/IpcChildWithNodeMessagePort/IpcChildWithNodeMessagePort.js +46 -45
  301. package/src/parts/IpcError/IpcError.js +4 -4
  302. package/src/parts/IpcId/IpcId.js +18 -17
  303. package/src/parts/IpcParent/IpcParent.js +10 -9
  304. package/src/parts/IpcParentModule/IpcParentModule.js +14 -13
  305. package/src/parts/IpcParentType/IpcParentType.js +3 -3
  306. package/src/parts/IpcParentWithElectronUtilityProcess/IpcParentWithElectronUtilityProcess.js +81 -76
  307. package/src/parts/IpcTransferState/IpcTransferState.js +14 -11
  308. package/src/parts/IsAbsolutePath/IsAbsolutePath.js +4 -3
  309. package/src/parts/IsAllowedWebSocketOrigin/IsAllowedWebSocketOrigin.js +39 -37
  310. package/src/parts/IsAppImage/IsAppImage.js +4 -3
  311. package/src/parts/IsAutoUpdateSupported/IsAutoUpdateSupported.ipc.js +6 -4
  312. package/src/parts/IsAutoUpdateSupported/IsAutoUpdateSupported.js +8 -6
  313. package/src/parts/IsBuiltServer/IsBuiltServer.js +1 -1
  314. package/src/parts/IsElectron/IsElectron.js +3 -1
  315. package/src/parts/IsEnoentError/IsEnoentError.js +11 -9
  316. package/src/parts/IsEnoentErrorWindows/IsEnoentErrorWindows.js +6 -4
  317. package/src/parts/IsEsrchError/IsEsrchError.js +4 -3
  318. package/src/parts/IsIgnoredError/IsIgnoredError.js +17 -16
  319. package/src/parts/IsLinux/IsLinux.js +3 -2
  320. package/src/parts/IsMessagePort/IsMessagePort.js +2 -2
  321. package/src/parts/IsMessagePortMain/IsMessagePortMain.js +2 -2
  322. package/src/parts/IsProduction/IsProduction.js +3 -2
  323. package/src/parts/IsSocket/IsSocket.js +4 -3
  324. package/src/parts/IsTransferrable/IsTransferrable.js +8 -7
  325. package/src/parts/IsTypeScriptPath/IsTypeScriptPath.js +5 -4
  326. package/src/parts/IsWindows/IsWindows.js +1 -1
  327. package/src/parts/JoinLines/JoinLines.js +4 -3
  328. package/src/parts/Json/Json.js +17 -15
  329. package/src/parts/JsonFile/JsonFile.js +12 -10
  330. package/src/parts/JsonRpc/JsonRpc.js +1 -1
  331. package/src/parts/JsonRpcVersion/JsonRpcVersion.js +1 -1
  332. package/src/parts/Jsonc/Jsonc.js +2 -1
  333. package/src/parts/JsoncFile/JsoncFile.js +8 -7
  334. package/src/parts/LaunchAuthProcess/LaunchAuthProcess.js +14 -13
  335. package/src/parts/LaunchClipBoardProcess/LaunchClipBoardProcess.js +14 -13
  336. package/src/parts/LaunchEmbedsProcess/LaunchEmbedsProcess.js +17 -16
  337. package/src/parts/LaunchFileSystemProcess/LaunchFileSystemProcess.js +21 -20
  338. package/src/parts/LaunchFileWatcherProcess/LaunchFileWatcherProcess.js +14 -13
  339. package/src/parts/LaunchNetworkProcess/LaunchNetworkProcess.js +13 -12
  340. package/src/parts/LaunchPreviewProcess/LaunchPreviewProcess.js +13 -12
  341. package/src/parts/LaunchProcess/LaunchProcess.js +34 -32
  342. package/src/parts/LaunchProcessExplorer/LaunchProcessExplorer.js +22 -21
  343. package/src/parts/LaunchPtyHost/LaunchPtyHost.js +16 -15
  344. package/src/parts/LaunchSearchProcess/LaunchSearchProcess.js +13 -12
  345. package/src/parts/LaunchTypeScriptCompileProcess/LaunchTypeScriptCompileProcess.js +25 -24
  346. package/src/parts/LimitString/LimitString.js +14 -13
  347. package/src/parts/LoadTypeScript/LoadTypeScript.js +12 -12
  348. package/src/parts/Logger/Logger.js +43 -35
  349. package/src/parts/Main/Main.js +16 -15
  350. package/src/parts/MainProcess/MainProcess.js +26 -20
  351. package/src/parts/MakeExecutable/MakeExecutable.js +9 -9
  352. package/src/parts/MergeWithSymlinks/MergeWithSymlinks.js +14 -14
  353. package/src/parts/MimeType/MimeType.js +38 -38
  354. package/src/parts/Module/Module.js +155 -154
  355. package/src/parts/ModuleId/ModuleId.js +80 -80
  356. package/src/parts/ModuleMap/ModuleMap.js +339 -337
  357. package/src/parts/NetworkProcess/NetworkProcess.js +19 -16
  358. package/src/parts/NetworkProcessPath/NetworkProcessPath.js +3 -2
  359. package/src/parts/OpenExternal/OpenExternal.ipc.js +7 -5
  360. package/src/parts/OpenExternal/OpenExternal.js +7 -5
  361. package/src/parts/OpenNativeFolder/OpenNativeFolder.ipc.js +6 -4
  362. package/src/parts/OpenNativeFolder/OpenNativeFolder.js +9 -9
  363. package/src/parts/Os/Os.ipc.js +4 -3
  364. package/src/parts/Os/Os.js +4 -3
  365. package/src/parts/OutputChannel/OutputChannel.ipc.js +39 -35
  366. package/src/parts/OutputChannel/OutputChannel.js +35 -32
  367. package/src/parts/OutputChannelState/OutputChannelState.js +15 -11
  368. package/src/parts/ParseUrlGithub/ParseUrlGithub.js +51 -49
  369. package/src/parts/Path/Path.js +16 -11
  370. package/src/parts/Performance/Performance.ipc.js +6 -4
  371. package/src/parts/Performance/Performance.js +27 -16
  372. package/src/parts/Platform/Platform.ipc.js +35 -33
  373. package/src/parts/Platform/Platform.js +76 -48
  374. package/src/parts/PlatformPaths/PlatformPaths.ipc.js +26 -24
  375. package/src/parts/PlatformPaths/PlatformPaths.js +140 -97
  376. package/src/parts/Preferences/Preferences.ipc.js +6 -4
  377. package/src/parts/Preferences/Preferences.js +83 -81
  378. package/src/parts/PreloadUrl/PreloadUrl.js +5 -4
  379. package/src/parts/PrettyError/PrettyError.js +1 -1
  380. package/src/parts/PreviewProcess/PreviewProcess.js +23 -19
  381. package/src/parts/PreviewProcessPath/PreviewProcessPath.js +3 -2
  382. package/src/parts/PrintPrettyError/PrintPrettyError.js +5 -4
  383. package/src/parts/Process/Process.ipc.js +10 -9
  384. package/src/parts/Process/Process.js +58 -45
  385. package/src/parts/ProcessDisplayName/ProcessDisplayName.js +1 -1
  386. package/src/parts/ProcessExitEventType/ProcessExitEventType.js +2 -2
  387. package/src/parts/ProcessExplorer/ProcessExplorer.ipc.js +6 -4
  388. package/src/parts/ProcessExplorer/ProcessExplorer.js +45 -42
  389. package/src/parts/ProcessExplorerPath/ProcessExplorerPath.js +3 -2
  390. package/src/parts/ProcessId/ProcessId.ipc.js +7 -5
  391. package/src/parts/ProcessId/ProcessId.js +5 -4
  392. package/src/parts/ProcessListeners/ProcessListeners.js +10 -8
  393. package/src/parts/Promises/Promises.js +18 -18
  394. package/src/parts/ProtocolType/ProtocolType.js +8 -8
  395. package/src/parts/PtyHost/PtyHost.js +28 -24
  396. package/src/parts/PtyHostPath/PtyHostPath.js +3 -2
  397. package/src/parts/PtyHostState/PtyHostState.js +17 -17
  398. package/src/parts/Queue/Queue.js +32 -31
  399. package/src/parts/RebuildNodePty/RebuildNodePty.ipc.js +6 -4
  400. package/src/parts/RebuildNodePty/RebuildNodePty.js +4 -3
  401. package/src/parts/RecentlyOpened/RecentlyOpened.ipc.js +6 -4
  402. package/src/parts/RecentlyOpened/RecentlyOpened.js +53 -54
  403. package/src/parts/RegisterWebViewProtocol/RegisterWebViewProtocol.js +13 -11
  404. package/src/parts/RejectWebSocket/RejectWebSocket.js +10 -9
  405. package/src/parts/RemoveQueryParameters/RemoveQueryParameters.js +6 -6
  406. package/src/parts/RemoveSymlink/RemoveSymlink.js +11 -11
  407. package/src/parts/RemoveValues/RemoveValues.js +21 -21
  408. package/src/parts/RequiresSocket/RequiresSocket.js +18 -16
  409. package/src/parts/ResolveBin/ResolveBin.js +10 -10
  410. package/src/parts/ResolveRoot/ResolveRoot.js +81 -78
  411. package/src/parts/Restart/Restart.js +10 -9
  412. package/src/parts/Root/Root.js +6 -4
  413. package/src/parts/Scheme/Scheme.js +1 -1
  414. package/src/parts/Screen/Screen.ipc.js +8 -6
  415. package/src/parts/Screen/Screen.js +10 -7
  416. package/src/parts/SearchProcess/SearchProcess.js +19 -16
  417. package/src/parts/SearchProcessPath/SearchProcessPath.js +3 -2
  418. package/src/parts/SendIncomingIpc/SendIncomingIpc.js +27 -24
  419. package/src/parts/SetHeaders/SetHeaders.js +4 -4
  420. package/src/parts/ShouldLogError/ShouldLogError.js +7 -6
  421. package/src/parts/ShouldTranspileTypescript/ShouldTranspileTypescript.js +11 -10
  422. package/src/parts/Signal/Signal.js +3 -3
  423. package/src/parts/SplitLines/SplitLines.js +4 -3
  424. package/src/parts/StaticPath/StaticPath.js +13 -12
  425. package/src/parts/StaticServerPath/StaticServerPath.js +4 -3
  426. package/src/parts/SymLink/SymLink.js +4 -3
  427. package/src/parts/TemporaryMessagePort/TemporaryMessagePort.ipc.js +9 -7
  428. package/src/parts/TemporaryMessagePort/TemporaryMessagePort.js +69 -64
  429. package/src/parts/Terminal/Terminal.ipc.js +9 -7
  430. package/src/parts/Terminal/Terminal.js +73 -68
  431. package/src/parts/TerminalState/TerminalState.js +12 -9
  432. package/src/parts/TextDocument/TextDocument.ipc.js +4 -3
  433. package/src/parts/TextDocument/TextDocument.js +23 -18
  434. package/src/parts/Timeout/Timeout.js +5 -4
  435. package/src/parts/TmpFile/TmpFile.js +13 -11
  436. package/src/parts/ToAbsolutePaths/ToAbsolutePaths.js +8 -7
  437. package/src/parts/Transferrables/Transferrables.js +5 -4
  438. package/src/parts/TransientLinkedExtensions/TransientLinkedExtensions.js +64 -58
  439. package/src/parts/TranspileTypeScript/TranspileTypeScript.js +8 -7
  440. package/src/parts/TranspileTypeScriptCached/TranspileTypeScriptCached.js +20 -19
  441. package/src/parts/Trash/Trash.js +11 -9
  442. package/src/parts/TrashElectron/TrashElectron.js +8 -7
  443. package/src/parts/TrashNode/TrashNode.js +9 -9
  444. package/src/parts/TypeScriptCompileCachePath/TypeScriptCompileCachePath.js +4 -3
  445. package/src/parts/TypeScriptCompileProcess/TypeScriptCompileProcess.js +19 -16
  446. package/src/parts/TypeScriptCompileProcessPath/TypeScriptCompileProcessPath.js +3 -2
  447. package/src/parts/UpdateState/UpdateState.js +11 -8
  448. package/src/parts/UpdateStateType/UpdateStateType.js +9 -9
  449. package/src/parts/V8CacheOptions/V8CacheOptions.js +2 -2
  450. package/src/parts/VError/VError.js +1 -1
  451. package/src/parts/WaitForProcessToExit/WaitForProcessToExit.js +8 -7
  452. package/src/parts/WalkValue/WalkValue.js +18 -18
  453. package/src/parts/WatchFile/WatchFile.js +12 -12
  454. package/src/parts/WatchForHotReload/WatchForHotReload.js +20 -16
  455. package/src/parts/WebViewProtocolState/WebViewProtocolState.js +9 -8
  456. package/src/parts/WebViewServer/WebViewServer.ipc.js +11 -9
  457. package/src/parts/WebViewServer/WebViewServer.js +26 -14
  458. package/src/parts/Workspace/Workspace.ipc.js +7 -5
  459. package/src/parts/Workspace/Workspace.js +23 -20
  460. package/src/parts/WorkspaceSource/WorkspaceSource.js +3 -3
  461. package/src/sharedProcessMain.js +3 -2
@@ -1,382 +1,491 @@
1
- import { existsSync } from 'node:fs';
2
- import { isAbsolute, join } from 'node:path';
3
- import * as FileSystem from '../FileSystem/FileSystem.js';
4
- import * as GetContentSecurityPolicy from '../GetContentSecurityPolicy/GetContentSecurityPolicy.js';
5
- import * as JsonFile from '../JsonFile/JsonFile.js';
6
- import * as Path from '../Path/Path.js';
7
- import { readdir, readFile, rm, writeFile } from 'node:fs/promises';
8
- import workers from '../Workers/Workers.json' with { type: 'json' };
1
+ import { existsSync } from 'node:fs'
2
+ import { stripTypeScriptTypes } from 'node:module'
3
+ import { isAbsolute, join, relative } from 'node:path'
4
+ import * as FileSystem from '../FileSystem/FileSystem.js'
5
+ import * as GetContentSecurityPolicy from '../GetContentSecurityPolicy/GetContentSecurityPolicy.js'
6
+ import * as JsonFile from '../JsonFile/JsonFile.js'
7
+ import * as Path from '../Path/Path.js'
8
+ import { readdir, readFile, rm, writeFile } from 'node:fs/promises'
9
+ import workers from '../Workers/Workers.json' with { type: 'json' }
10
+
9
11
  const staticContentSecurityPolicy = GetContentSecurityPolicy.getContentSecurityPolicy([
10
- `default-src 'none'`,
11
- `font-src 'self'`,
12
- `img-src 'self' https: data: blob:`, // TODO maybe disallow https and data images
13
- `manifest-src 'self'`,
14
- `media-src 'self' blob:`,
15
- `script-src 'self'`,
16
- `style-src 'self' 'unsafe-inline'`,
17
- `frame-src 'self' blob:`,
18
- ]);
12
+ `default-src 'none'`,
13
+ `font-src 'self'`,
14
+ `img-src 'self' https: data: blob:`, // TODO maybe disallow https and data images
15
+ `manifest-src 'self'`,
16
+ `media-src 'self' blob:`,
17
+ `script-src 'self'`,
18
+ `style-src 'self' 'unsafe-inline'`,
19
+ `frame-src 'self' blob:`,
20
+ ])
21
+
19
22
  const readExtensionManifest = async (path) => {
20
- const json = await JsonFile.readJson(path);
21
- return { ...json, path };
22
- };
23
+ const json = await JsonFile.readJson(path)
24
+ return { ...json, path }
25
+ }
26
+
23
27
  const getThemeName = (dirent) => {
24
- return dirent.slice('builtin.theme-'.length);
25
- };
28
+ return dirent.slice('builtin.theme-'.length)
29
+ }
30
+
26
31
  const replace = async (path, occurrence, replacement) => {
27
- const oldContent = await FileSystem.readFile(path);
28
- if (!oldContent.includes(occurrence)) {
29
- throw new Error(`failed to replace occurrence ${occurrence} in ${path}: Not found`);
30
- }
31
- // @ts-ignore
32
- const newContent = oldContent.replaceAll(occurrence, replacement);
33
- await FileSystem.writeFile(path, newContent);
34
- };
32
+ const oldContent = await FileSystem.readFile(path)
33
+ if (!oldContent.includes(occurrence)) {
34
+ throw new Error(`failed to replace occurrence ${occurrence} in ${path}: Not found`)
35
+ }
36
+ // @ts-ignore
37
+ const newContent = oldContent.replaceAll(occurrence, replacement)
38
+ await FileSystem.writeFile(path, newContent)
39
+ }
40
+
35
41
  const getWorkerById = (id) => {
36
- const worker = workers.find((item) => {
37
- return item.id === id;
38
- });
39
- if (!worker) {
40
- throw new Error(`worker not found: ${id}`);
41
- }
42
- return worker;
43
- };
42
+ const worker = workers.find((item) => {
43
+ return item.id === id
44
+ })
45
+ if (!worker) {
46
+ throw new Error(`worker not found: ${id}`)
47
+ }
48
+ return worker
49
+ }
50
+
44
51
  const getDistPathFromWorkerPath = (path) => {
45
- return path.split('/').filter(Boolean);
46
- };
52
+ return path.split('/').filter(Boolean)
53
+ }
54
+
47
55
  const getWorkerDistPath = (root, commitHash, id) => {
48
- const worker = getWorkerById(id);
49
- return Path.join(root, 'dist', commitHash, ...getDistPathFromWorkerPath(worker.productionPath));
50
- };
56
+ const worker = getWorkerById(id)
57
+ return Path.join(root, 'dist', commitHash, ...getDistPathFromWorkerPath(worker.productionPath))
58
+ }
59
+
51
60
  /**
52
61
  * @param {string} dirent
53
62
  */
54
63
  const isLanguageBasics = (dirent) => {
55
- return dirent.startsWith('builtin.language-basics');
56
- };
64
+ return dirent.startsWith('builtin.language-basics')
65
+ }
66
+
57
67
  /**
58
68
  * @param {string} dirent
59
69
  */
60
70
  const isTheme = (dirent) => {
61
- return dirent.startsWith('builtin.theme-');
62
- };
71
+ return dirent.startsWith('builtin.theme-')
72
+ }
73
+
63
74
  /**
64
75
  * @param {string} dirent
65
76
  */
66
77
  const isIconTheme = (dirent) => {
67
- return dirent === 'builtin.vscode-icons';
68
- };
78
+ return dirent === 'builtin.vscode-icons'
79
+ }
80
+
69
81
  const compare = (a, b) => {
70
- return a.localeCompare(b);
71
- };
82
+ return a.localeCompare(b)
83
+ }
84
+
72
85
  const toSorted = (objects, compare) => {
73
- return [...objects].sort(compare);
74
- };
86
+ return [...objects].sort(compare)
87
+ }
88
+
75
89
  const mergeThemes = (builtinThemes, extensionThemes) => {
76
- const seen = [];
77
- const merged = [];
78
- for (const extensionTheme of extensionThemes) {
79
- seen.push(extensionTheme);
80
- merged.push(extensionTheme);
81
- }
82
- for (const builtinTheme of builtinThemes) {
83
- if (seen.includes(builtinTheme)) {
84
- continue;
85
- }
86
- merged.push(builtinTheme);
87
- }
88
- const sorted = toSorted(merged, compare);
89
- return sorted;
90
- };
91
- const RE_COMMIT_HASH = /^[a-z\d]+$/;
90
+ const seen = []
91
+ const merged = []
92
+ for (const extensionTheme of extensionThemes) {
93
+ seen.push(extensionTheme)
94
+ merged.push(extensionTheme)
95
+ }
96
+ for (const builtinTheme of builtinThemes) {
97
+ if (seen.includes(builtinTheme)) {
98
+ continue
99
+ }
100
+ merged.push(builtinTheme)
101
+ }
102
+ const sorted = toSorted(merged, compare)
103
+ return sorted
104
+ }
105
+
106
+ const RE_COMMIT_HASH = /^[a-z\d]+$/
92
107
  const isCommitHash = (dirent) => {
93
- return dirent.length === 7 && dirent.match(RE_COMMIT_HASH);
94
- };
108
+ return dirent.length === 7 && dirent.match(RE_COMMIT_HASH)
109
+ }
110
+
95
111
  /**
96
112
  * @param {string} root
97
113
  */
98
114
  const clean = async (root) => {
99
- await FileSystem.forceRemove(Path.join(root, 'dist'));
100
- await FileSystem.mkdir(Path.join(root, 'dist'));
101
- };
115
+ await FileSystem.forceRemove(Path.join(root, 'dist'))
116
+ await FileSystem.mkdir(Path.join(root, 'dist'))
117
+ }
118
+
102
119
  /**
103
120
  * @param {string} root
104
121
  */
105
122
  const copyStaticFiles = async (root, serverStaticPath) => {
106
- await FileSystem.copy(serverStaticPath, Path.join(root, 'dist'));
107
- };
108
- const applyOverridesRendererProcess = async ({ root, commitHash, pathPrefix }) => {
109
- await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'), 'platform = Remote;', 'platform = Web');
110
- await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
111
- };
112
- const applyOverrides = async ({ root, commitHash, pathPrefix, serverStaticPath }) => {
113
- const extensionHostWorkerDistPath = getWorkerDistPath(root, commitHash, 'extensionHostWorker');
114
- await applyOverridesRendererProcess({ root, commitHash, pathPrefix });
115
- await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), 'platform = Remote;', 'platform = Web$1;');
116
- await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
117
- await replace(extensionHostWorkerDistPath, `return \`\${assetDir}/extensions/builtin.theme-\${colorThemeId}/color-theme.json\``, `return \`\${assetDir}/themes/\${colorThemeId}.json\``);
118
- await replace(extensionHostWorkerDistPath, `/${commitHash}`, `${pathPrefix}/${commitHash}`);
119
- await replace(extensionHostWorkerDistPath, `const platform = Remote`, `const platform = Web`);
120
- // await replace(
121
- // Path.join(root, 'dist', commitHash, 'packages', 'extension-host-worker', 'dist', 'extensionHostWorkerMain.js'),
122
- // `return \`\${assetDir}/extensions/builtin.\${iconThemeId}/icon-theme.json\``,
123
- // `return \`\${assetDir}/icon-themes/\${iconThemeId}.json\``,
124
- // )
125
- const extensionDirents = await FileSystem.readDir(Path.join(serverStaticPath, commitHash, 'extensions'));
126
- const languageBasicsDirents = extensionDirents.filter(isLanguageBasics);
127
- const themeDirents = extensionDirents.filter(isTheme);
128
- const iconThemeDirents = extensionDirents.filter(isIconTheme);
129
- const getLanguages = (extension) => {
130
- const languages = [];
131
- for (const language of extension.languages || []) {
132
- languages.push({
133
- ...language,
134
- tokenize: `${pathPrefix}/${commitHash}/extensions/${extension.id}/${language.tokenize}`,
135
- });
136
- }
137
- return languages;
138
- };
139
- const getWebViews = (extension) => {
140
- const webViews = [];
141
- for (const webView of extension.webViews || []) {
142
- webViews.push({
143
- ...webView,
144
- path: `${pathPrefix}/${commitHash}/extensions/${webView.path}`,
145
- remotePath: `${pathPrefix}/${commitHash}/extensions/${extension.id}`,
146
- });
147
- }
148
- return webViews;
149
- };
150
- /**
151
- * @param {string} dirent
152
- */
153
- const getManifestPath = (dirent) => {
154
- return Path.join(serverStaticPath, commitHash, 'extensions', dirent, 'extension.json');
155
- };
156
- const manifestPaths = languageBasicsDirents.map(getManifestPath);
157
- const manifests = await Promise.all(manifestPaths.map(readExtensionManifest));
158
- const languages = manifests.flatMap(getLanguages);
159
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'), languages);
160
- const webViews = manifests.flatMap(getWebViews);
161
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webViews.json'), webViews);
162
- for (const languageBasicsDirent of languageBasicsDirents) {
163
- await FileSystem.copy(Path.join(serverStaticPath, commitHash, 'extensions', languageBasicsDirent), Path.join(root, 'dist', commitHash, 'extensions', languageBasicsDirent));
164
- }
165
- for (const themeDirent of themeDirents) {
166
- const themeId = getThemeName(themeDirent);
167
- await FileSystem.copy(Path.join(serverStaticPath, commitHash, 'extensions', themeDirent, 'color-theme.json'), Path.join(root, 'dist', commitHash, 'themes', `${themeId}.json`));
168
- }
169
- const themeIds = mergeThemes(themeDirents.map(getThemeName), []);
170
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'), themeIds);
171
- for (const iconThemeDirent of iconThemeDirents) {
172
- const iconThemeId = iconThemeDirent.slice('builtin.'.length);
173
- await FileSystem.copy(Path.join(serverStaticPath, commitHash, 'extensions', iconThemeDirent, 'icon-theme.json'), Path.join(root, 'dist', commitHash, 'icon-themes', `${iconThemeId}.json`));
174
- }
175
- const indexHtmlPath = Path.join(root, 'dist', 'index.html');
176
- await replace(indexHtmlPath, `/${commitHash}`, `${pathPrefix}/${commitHash}`);
177
- await replace(indexHtmlPath, '#282e2f" />', `#282e2f" />
178
- <meta http-equiv="Content-Security-Policy" content="${staticContentSecurityPolicy}">`);
179
- if (pathPrefix) {
180
- await replace(indexHtmlPath, '</title>', `</title>
181
- <link rel="shortcut icon" type="image/x-icon" href="${pathPrefix}/favicon.ico">`);
182
- }
183
- else {
184
- await replace(indexHtmlPath, '</title>', `</title>
185
- <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">`);
186
- }
187
- if (pathPrefix) {
188
- await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
189
- await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"start_url": "/"`, `"start_url": "${pathPrefix}"`);
190
- await replace(Path.join(root, 'dist', commitHash, 'css', 'App.css'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
191
- }
192
- };
193
- const addExtensionSeo = async ({ root, name, description, commitHash }) => {
194
- await replace(Path.join(root, 'dist', 'index.html'), '<title>Lvce Editor</title>', `<title>${name}</title>`);
195
- await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"name": "Code Editor Web - OSS"`, `"name": "${name}"`);
196
- await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"short_name": "Web - OSS"`, `"short_name": "${name}"`);
197
- await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"description": "Web Code Editor."`, `"description": "${description}"`);
198
- await replace(Path.join(root, 'dist', 'index.html'), '<meta name="description" content="VS Code inspired text editor that mostly runs in a webworker." />', `<meta name="description" content="${description}" />`);
199
- };
123
+ await FileSystem.copy(serverStaticPath, Path.join(root, 'dist'))
124
+ }
125
+
126
+ const applyOverridesRendererProcess = async ({ root, commitHash, pathPrefix } ) => {
127
+ await replace(
128
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'),
129
+ 'platform = Remote;',
130
+ 'platform = Web',
131
+ )
132
+ await replace(
133
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'),
134
+ `/${commitHash}`,
135
+ `${pathPrefix}/${commitHash}`,
136
+ )
137
+ }
138
+
139
+ const applyOverrides = async ({ root, commitHash, pathPrefix, serverStaticPath } ) => {
140
+ const extensionHostWorkerDistPath = getWorkerDistPath(root, commitHash, 'extensionHostWorker')
141
+ await applyOverridesRendererProcess({ root, commitHash, pathPrefix })
142
+ await replace(
143
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
144
+ 'platform = Remote;',
145
+ 'platform = Web$1;',
146
+ )
147
+ await replace(
148
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
149
+ `/${commitHash}`,
150
+ `${pathPrefix}/${commitHash}`,
151
+ )
152
+ await replace(
153
+ extensionHostWorkerDistPath,
154
+ `return \`\${assetDir}/extensions/builtin.theme-\${colorThemeId}/color-theme.json\``,
155
+ `return \`\${assetDir}/themes/\${colorThemeId}.json\``,
156
+ )
157
+ await replace(extensionHostWorkerDistPath, `/${commitHash}`, `${pathPrefix}/${commitHash}`)
158
+ await replace(extensionHostWorkerDistPath, `const platform = Remote`, `const platform = Web`)
159
+ // await replace(
160
+ // Path.join(root, 'dist', commitHash, 'packages', 'extension-host-worker', 'dist', 'extensionHostWorkerMain.js'),
161
+ // `return \`\${assetDir}/extensions/builtin.\${iconThemeId}/icon-theme.json\``,
162
+ // `return \`\${assetDir}/icon-themes/\${iconThemeId}.json\``,
163
+ // )
164
+
165
+ const extensionDirents = await FileSystem.readDir(Path.join(serverStaticPath, commitHash, 'extensions'))
166
+
167
+ const languageBasicsDirents = extensionDirents.filter(isLanguageBasics)
168
+ const themeDirents = extensionDirents.filter(isTheme)
169
+ const iconThemeDirents = extensionDirents.filter(isIconTheme)
170
+
171
+ const getLanguages = (extension) => {
172
+ const languages = []
173
+ for (const language of extension.languages || []) {
174
+ languages.push({
175
+ ...language,
176
+ tokenize: `${pathPrefix}/${commitHash}/extensions/${extension.id}/${language.tokenize}`,
177
+ })
178
+ }
179
+ return languages
180
+ }
181
+
182
+ const getWebViews = (extension) => {
183
+ const webViews = []
184
+ for (const webView of extension.webViews || []) {
185
+ webViews.push({
186
+ ...webView,
187
+ path: `${pathPrefix}/${commitHash}/extensions/${webView.path}`,
188
+ remotePath: `${pathPrefix}/${commitHash}/extensions/${extension.id}`,
189
+ })
190
+ }
191
+ return webViews
192
+ }
193
+
194
+ /**
195
+ * @param {string} dirent
196
+ */
197
+ const getManifestPath = (dirent) => {
198
+ return Path.join(serverStaticPath, commitHash, 'extensions', dirent, 'extension.json')
199
+ }
200
+
201
+ const manifestPaths = languageBasicsDirents.map(getManifestPath)
202
+ const manifests = await Promise.all(manifestPaths.map(readExtensionManifest))
203
+ const languages = manifests.flatMap(getLanguages)
204
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'), languages)
205
+
206
+ const webViews = manifests.flatMap(getWebViews)
207
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webViews.json'), webViews)
208
+
209
+ for (const languageBasicsDirent of languageBasicsDirents) {
210
+ await FileSystem.copy(
211
+ Path.join(serverStaticPath, commitHash, 'extensions', languageBasicsDirent),
212
+ Path.join(root, 'dist', commitHash, 'extensions', languageBasicsDirent),
213
+ )
214
+ }
215
+
216
+ for (const themeDirent of themeDirents) {
217
+ const themeId = getThemeName(themeDirent)
218
+ await FileSystem.copy(
219
+ Path.join(serverStaticPath, commitHash, 'extensions', themeDirent, 'color-theme.json'),
220
+ Path.join(root, 'dist', commitHash, 'themes', `${themeId}.json`),
221
+ )
222
+ }
223
+
224
+ const themeIds = mergeThemes(themeDirents.map(getThemeName), [])
225
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'), themeIds)
226
+
227
+ for (const iconThemeDirent of iconThemeDirents) {
228
+ const iconThemeId = iconThemeDirent.slice('builtin.'.length)
229
+ await FileSystem.copy(
230
+ Path.join(serverStaticPath, commitHash, 'extensions', iconThemeDirent, 'icon-theme.json'),
231
+ Path.join(root, 'dist', commitHash, 'icon-themes', `${iconThemeId}.json`),
232
+ )
233
+ }
234
+ const indexHtmlPath = Path.join(root, 'dist', 'index.html')
235
+ await replace(indexHtmlPath, `/${commitHash}`, `${pathPrefix}/${commitHash}`)
236
+
237
+ await replace(
238
+ indexHtmlPath,
239
+ '#282e2f" />',
240
+ `#282e2f" />
241
+ <meta http-equiv="Content-Security-Policy" content="${staticContentSecurityPolicy}">`,
242
+ )
243
+
244
+ if (pathPrefix) {
245
+ await replace(
246
+ indexHtmlPath,
247
+ '</title>',
248
+ `</title>
249
+ <link rel="shortcut icon" type="image/x-icon" href="${pathPrefix}/favicon.ico">`,
250
+ )
251
+ } else {
252
+ await replace(
253
+ indexHtmlPath,
254
+ '</title>',
255
+ `</title>
256
+ <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">`,
257
+ )
258
+ }
259
+ if (pathPrefix) {
260
+ await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
261
+ await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"start_url": "/"`, `"start_url": "${pathPrefix}"`)
262
+ await replace(Path.join(root, 'dist', commitHash, 'css', 'App.css'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
263
+ }
264
+ }
265
+
266
+ const addExtensionSeo = async ({ root, name, description, commitHash } ) => {
267
+ await replace(Path.join(root, 'dist', 'index.html'), '<title>Lvce Editor</title>', `<title>${name}</title>`)
268
+ await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"name": "Code Editor Web - OSS"`, `"name": "${name}"`)
269
+ await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"short_name": "Web - OSS"`, `"short_name": "${name}"`)
270
+ await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"description": "Web Code Editor."`, `"description": "${description}"`)
271
+ await replace(
272
+ Path.join(root, 'dist', 'index.html'),
273
+ '<meta name="description" content="VS Code inspired text editor that mostly runs in a webworker." />',
274
+ `<meta name="description" content="${description}" />`,
275
+ )
276
+ }
277
+
200
278
  const getId = (object) => {
201
- return object.id;
202
- };
203
- const addExtensionThemes = async ({ root, extensionPath, extensionJson, commitHash }) => {
204
- const colorThemes = extensionJson.colorThemes || [];
205
- if (colorThemes.length === 0) {
206
- return;
207
- }
208
- for (const colorTheme of colorThemes) {
209
- const { id, path } = colorTheme;
210
- const extensionId = `builtin.theme-${id}`;
211
- await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
212
- await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
213
- await FileSystem.copy(Path.join(extensionPath, path), Path.join(root, 'dist', commitHash, 'themes', `${id}.json`));
214
- await replace(Path.join(root, 'dist', commitHash, 'config', 'defaultSettings.json'), `"workbench.colorTheme": "slime"`, `"workbench.colorTheme": "${id}"`);
215
- await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'README.md'));
216
- await FileSystem.copyFile(Path.join(extensionPath, 'extension.json'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'extension.json'));
217
- await FileSystem.copyFile(Path.join(extensionPath, 'color-theme.json'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'color-theme.json'));
218
- }
219
- const themesJson = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'));
220
- const ids = colorThemes.map(getId);
221
- const mergedThemes = mergeThemes(themesJson, ids);
222
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'), mergedThemes);
223
- };
279
+ return object.id
280
+ }
281
+
282
+ const addExtensionThemes = async ({ root, extensionPath, extensionJson, commitHash } ) => {
283
+ const colorThemes = extensionJson.colorThemes || []
284
+ if (colorThemes.length === 0) {
285
+ return
286
+ }
287
+ for (const colorTheme of colorThemes) {
288
+ const { id, path } = colorTheme
289
+ const extensionId = `builtin.theme-${id}`
290
+ await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionId))
291
+ await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', extensionId))
292
+ await FileSystem.copy(Path.join(extensionPath, path), Path.join(root, 'dist', commitHash, 'themes', `${id}.json`))
293
+ await replace(
294
+ Path.join(root, 'dist', commitHash, 'config', 'defaultSettings.json'),
295
+ `"workbench.colorTheme": "slime"`,
296
+ `"workbench.colorTheme": "${id}"`,
297
+ )
298
+ await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'README.md'))
299
+ await FileSystem.copyFile(
300
+ Path.join(extensionPath, 'extension.json'),
301
+ Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'extension.json'),
302
+ )
303
+ await FileSystem.copyFile(
304
+ Path.join(extensionPath, 'color-theme.json'),
305
+ Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'color-theme.json'),
306
+ )
307
+ }
308
+ const themesJson = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'))
309
+ const ids = colorThemes.map(getId)
310
+ const mergedThemes = mergeThemes(themesJson, ids)
311
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'), mergedThemes)
312
+ }
313
+
224
314
  const compareId = (a, b) => {
225
- return a.id.localeCompare(b.id);
226
- };
315
+ return a.id.localeCompare(b.id)
316
+ }
317
+
227
318
  const mergeLanguages = (languages, extensionLanguages) => {
228
- const seen = [];
229
- const merged = [];
230
- for (const language of extensionLanguages) {
231
- seen.push(language.id);
232
- merged.push(language);
233
- }
234
- for (const language of languages) {
235
- if (seen.includes(language.id)) {
236
- continue;
237
- }
238
- merged.push(language);
239
- }
240
- merged.sort(compareId);
241
- return merged;
242
- };
319
+ const seen = []
320
+ const merged = []
321
+ for (const language of extensionLanguages) {
322
+ seen.push(language.id)
323
+ merged.push(language)
324
+ }
325
+ for (const language of languages) {
326
+ if (seen.includes(language.id)) {
327
+ continue
328
+ }
329
+ merged.push(language)
330
+ }
331
+ merged.sort(compareId)
332
+ return merged
333
+ }
334
+
243
335
  const toPlaygroundFile = (file) => {
244
- return `/playground/${file}`;
245
- };
246
- const addExtensionLanguages = async ({ root, extensionPath, extensionJson, commitHash, pathPrefix }) => {
247
- const languages = extensionJson.languages || [];
248
- if (languages.length === 0) {
249
- return;
250
- }
251
- const extensionId = extensionJson.id;
252
- await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
253
- await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
254
- await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'README.md'));
255
- for (const file of ['src', 'data', 'extension.json']) {
256
- if (await FileSystem.exists(Path.join(extensionPath, file))) {
257
- await FileSystem.copy(Path.join(extensionPath, file), Path.join(root, 'dist', commitHash, 'extensions', extensionId, file));
258
- }
259
- }
260
- const extensionLanguages = [];
261
- for (const language of languages) {
262
- if (!language.tokenize) {
263
- continue;
264
- }
265
- extensionLanguages.push({
266
- ...language,
267
- tokenize: `${pathPrefix}/${commitHash}/extensions/${extensionId}/${language.tokenize}`,
268
- });
269
- }
270
- const builtinLanguages = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'));
271
- const mergedLanguages = mergeLanguages(builtinLanguages, extensionLanguages);
272
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'), mergedLanguages);
273
- if (await FileSystem.exists(Path.join(extensionPath, 'test', 'cases'))) {
274
- await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'playground'));
275
- await FileSystem.copy(Path.join(extensionPath, 'test', 'cases'), Path.join(root, 'dist', commitHash, 'playground'));
276
- const testFiles = await FileSystem.readDir(Path.join(extensionPath, 'test', 'cases'));
277
- const fileMap = testFiles.map(toPlaygroundFile);
278
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'fileMap.json'), fileMap);
279
- }
280
- };
336
+ return `/playground/${file}`
337
+ }
338
+
339
+ const addExtensionLanguages = async ({ root, extensionPath, extensionJson, commitHash, pathPrefix } ) => {
340
+ const languages = extensionJson.languages || []
341
+ if (languages.length === 0) {
342
+ return
343
+ }
344
+ const extensionId = extensionJson.id
345
+ await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionId))
346
+ await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', extensionId))
347
+ await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'README.md'))
348
+ for (const file of ['src', 'data', 'extension.json']) {
349
+ if (await FileSystem.exists(Path.join(extensionPath, file))) {
350
+ await FileSystem.copy(Path.join(extensionPath, file), Path.join(root, 'dist', commitHash, 'extensions', extensionId, file))
351
+ }
352
+ }
353
+ const extensionLanguages = []
354
+ for (const language of languages) {
355
+ if (!language.tokenize) {
356
+ continue
357
+ }
358
+ extensionLanguages.push({
359
+ ...language,
360
+ tokenize: `${pathPrefix}/${commitHash}/extensions/${extensionId}/${language.tokenize}`,
361
+ })
362
+ }
363
+ const builtinLanguages = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'))
364
+ const mergedLanguages = mergeLanguages(builtinLanguages, extensionLanguages)
365
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'), mergedLanguages)
366
+ if (await FileSystem.exists(Path.join(extensionPath, 'test', 'cases'))) {
367
+ await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'playground'))
368
+ await FileSystem.copy(Path.join(extensionPath, 'test', 'cases'), Path.join(root, 'dist', commitHash, 'playground'))
369
+ const testFiles = await FileSystem.readDir(Path.join(extensionPath, 'test', 'cases'))
370
+ const fileMap = testFiles.map(toPlaygroundFile)
371
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'fileMap.json'), fileMap)
372
+ }
373
+ }
374
+
281
375
  export const mergeExtensionManifests = (manifests, extraExtensions) => {
282
- const replacements = Object.create(null);
283
- for (const extension of extraExtensions) {
284
- replacements[extension.id] = extension;
285
- }
286
- const used = Object.create(null);
287
- const merged = manifests.map((manifest) => {
288
- const replacement = replacements[manifest.id];
289
- if (replacement) {
290
- used[manifest.id] = true;
291
- return replacement;
292
- }
293
- return manifest;
294
- });
295
- for (const extension of extraExtensions) {
296
- if (used[extension.id]) {
297
- continue;
298
- }
299
- merged.push(extension);
300
- }
301
- return merged;
302
- };
303
- const updateExtensionsJson = async ({ root, commitHash, pathPrefix, extraExtensions }) => {
304
- const dirents = await FileSystem.readDir(Path.join(root, 'dist', commitHash, 'extensions'));
305
- const manifests = await Promise.all(dirents.map(async (dirent) => {
306
- const json = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'extensions', dirent, 'extension.json'));
307
- const webExtensionPath = `${pathPrefix}/${commitHash}/extensions/${dirent}`;
308
- return {
309
- ...json,
310
- path: webExtensionPath,
311
- };
312
- }));
313
- const localExtensions = extraExtensions.map((extension) => {
314
- return {
315
- ...extension,
316
- path: `${pathPrefix}/${commitHash}/extensions/${extension.id}`,
317
- };
318
- });
319
- const newExtensions = mergeExtensionManifests(manifests, localExtensions);
320
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'extensions.json'), newExtensions);
321
- };
322
- const addExtensionWebExtension = async ({ root, extensionPath, commitHash, extensionJson, pathPrefix, useSimpleWebExtensionFile }) => {
323
- await updateExtensionsJson({ root, commitHash, pathPrefix, extraExtensions: [extensionJson] });
324
- if (!extensionJson.browser) {
325
- return;
326
- }
327
- const webExtensionPath = `${pathPrefix}/${commitHash}/extensions/${extensionJson.id}`;
328
- if (useSimpleWebExtensionFile) {
329
- const webExtensions = [webExtensionPath];
330
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webExtensions.json'), webExtensions);
331
- return;
332
- }
333
- const webExtensions = [
334
- {
335
- ...extensionJson,
336
- isWeb: true,
337
- path: webExtensionPath,
338
- },
339
- ];
340
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webExtensions.json'), webExtensions);
341
- await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionJson.id));
342
- for (const dirent of ['src', 'extension.json']) {
343
- await FileSystem.copy(Path.join(extensionPath, dirent), Path.join(root, 'dist', commitHash, 'extensions', extensionJson.id, dirent));
344
- }
345
- };
346
- const addExtension = async ({ root, extensionPath, commitHash, pathPrefix, useSimpleWebExtensionFile }) => {
347
- const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'));
348
- const name = extensionJson.name || extensionJson.id || '';
349
- const description = extensionJson.description || '';
350
- await addExtensionSeo({
351
- root,
352
- commitHash,
353
- name,
354
- description,
355
- });
356
- await addExtensionThemes({
357
- root,
358
- commitHash,
359
- extensionJson,
360
- extensionPath,
361
- });
362
- await addExtensionLanguages({
363
- root,
364
- extensionPath,
365
- commitHash,
366
- extensionJson,
367
- pathPrefix,
368
- });
369
- await addExtensionWebExtension({
370
- root,
371
- extensionPath,
372
- commitHash,
373
- extensionJson,
374
- pathPrefix,
375
- useSimpleWebExtensionFile,
376
- });
377
- };
376
+ const replacements = Object.create(null)
377
+ for (const extension of extraExtensions) {
378
+ replacements[extension.id] = extension
379
+ }
380
+ const used = Object.create(null)
381
+ const merged = manifests.map((manifest) => {
382
+ const replacement = replacements[manifest.id]
383
+ if (replacement) {
384
+ used[manifest.id] = true
385
+ return replacement
386
+ }
387
+ return manifest
388
+ })
389
+ for (const extension of extraExtensions) {
390
+ if (used[extension.id]) {
391
+ continue
392
+ }
393
+ merged.push(extension)
394
+ }
395
+ return merged
396
+ }
397
+
398
+ const updateExtensionsJson = async ({ root, commitHash, pathPrefix, extraExtensions } ) => {
399
+ const dirents = await FileSystem.readDir(Path.join(root, 'dist', commitHash, 'extensions'))
400
+ const manifests = await Promise.all(
401
+ dirents.map(async (dirent) => {
402
+ const json = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'extensions', dirent, 'extension.json'))
403
+ const webExtensionPath = `${pathPrefix}/${commitHash}/extensions/${dirent}`
404
+ return {
405
+ ...json,
406
+ path: webExtensionPath,
407
+ }
408
+ }),
409
+ )
410
+ const localExtensions = extraExtensions.map((extension) => {
411
+ return {
412
+ ...extension,
413
+ path: `${pathPrefix}/${commitHash}/extensions/${extension.id}`,
414
+ }
415
+ })
416
+ const newExtensions = mergeExtensionManifests(manifests, localExtensions)
417
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'extensions.json'), newExtensions)
418
+ }
419
+
420
+ const addExtensionWebExtension = async ({
421
+ root,
422
+ extensionPath,
423
+ commitHash,
424
+ extensionJson,
425
+ pathPrefix,
426
+ useSimpleWebExtensionFile,
427
+ } ) => {
428
+ await updateExtensionsJson({ root, commitHash, pathPrefix, extraExtensions: [extensionJson] })
429
+
430
+ if (!extensionJson.browser) {
431
+ return
432
+ }
433
+ const webExtensionPath = `${pathPrefix}/${commitHash}/extensions/${extensionJson.id}`
434
+ if (useSimpleWebExtensionFile) {
435
+ const webExtensions = [webExtensionPath]
436
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webExtensions.json'), webExtensions)
437
+ return
438
+ }
439
+ const webExtensions = [
440
+ {
441
+ ...extensionJson,
442
+ isWeb: true,
443
+ path: webExtensionPath,
444
+ },
445
+ ]
446
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webExtensions.json'), webExtensions)
447
+ await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionJson.id))
448
+ for (const dirent of ['src', 'extension.json']) {
449
+ await FileSystem.copy(Path.join(extensionPath, dirent), Path.join(root, 'dist', commitHash, 'extensions', extensionJson.id, dirent))
450
+ }
451
+ }
452
+
453
+ const addExtension = async ({ root, extensionPath, commitHash, pathPrefix, useSimpleWebExtensionFile } ) => {
454
+ const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'))
455
+ const name = extensionJson.name || extensionJson.id || ''
456
+ const description = extensionJson.description || ''
457
+ await addExtensionSeo({
458
+ root,
459
+ commitHash,
460
+ name,
461
+ description,
462
+ })
463
+ await addExtensionThemes({
464
+ root,
465
+ commitHash,
466
+ extensionJson,
467
+ extensionPath,
468
+ })
469
+ await addExtensionLanguages({
470
+ root,
471
+ extensionPath,
472
+ commitHash,
473
+ extensionJson,
474
+ pathPrefix,
475
+ })
476
+
477
+ await addExtensionWebExtension({
478
+ root,
479
+ extensionPath,
480
+ commitHash,
481
+ extensionJson,
482
+ pathPrefix,
483
+ useSimpleWebExtensionFile,
484
+ })
485
+ }
486
+
378
487
  const generateTestOverviewHtml = (dirents) => {
379
- const pre = `<!DOCTYPE html>
488
+ const pre = `<!DOCTYPE html>
380
489
  <html lang="en">
381
490
  <head>
382
491
  <meta charset="UTF-8" />
@@ -387,233 +496,262 @@ const generateTestOverviewHtml = (dirents) => {
387
496
  <h1>Tests</h1>
388
497
  <p>Available Tests</p>
389
498
  <ul>
390
- `;
391
- let middle = ``;
392
- // TODO properly escape name
393
- for (const dirent of dirents) {
394
- const name = dirent;
395
- middle += ` <li><a href="./${name}.html">${name}</a></li>
396
- `;
397
- }
398
- const post = ` </ul>
499
+ `
500
+ let middle = ``
501
+ // TODO properly escape name
502
+ for (const dirent of dirents) {
503
+ const name = dirent
504
+ middle += ` <li><a href="./${name}.html">${name}</a></li>
505
+ `
506
+ }
507
+
508
+ const post = ` </ul>
399
509
  </body>
400
510
  </html>
401
- `;
402
- return pre + middle + post;
403
- };
511
+ `
512
+ return pre + middle + post
513
+ }
514
+
404
515
  const getName = (name) => {
405
- return name.replace(/\.(js|ts)$/, '');
406
- };
516
+ return name.replace(/\.(js|ts)$/, '')
517
+ }
407
518
  const isTestFile = (file) => {
408
- if (file.startsWith('_')) {
409
- return false;
410
- }
411
- return file.endsWith('.js') || file.endsWith('.ts');
412
- };
519
+ if (file.startsWith('_')) {
520
+ return false
521
+ }
522
+ return file.endsWith('.js') || file.endsWith('.ts')
523
+ }
524
+
413
525
  const getTestFiles = (testFilesRaw) => {
414
- return testFilesRaw.filter(isTestFile).map(getName);
415
- };
416
- const transpileFile = (typescript, content) => {
417
- const result = typescript.transpileModule(content, {
418
- compilerOptions: {
419
- target: 'esnext',
420
- },
421
- });
422
- return result.outputText;
423
- };
526
+ return testFilesRaw.filter(isTestFile).map(getName)
527
+ }
528
+
529
+ export const transpileFile = (content) => {
530
+ return stripTypeScriptTypes(content)
531
+ }
532
+
424
533
  const transpileFiles = async (folder) => {
425
- const typescript = await import('typescript');
426
- const dirents = await readdir(folder);
427
- for (const dirent of dirents) {
428
- if (dirent.endsWith('.ts')) {
429
- const content = await readFile(join(folder, dirent), 'utf-8');
430
- const js = transpileFile(typescript, content);
431
- await writeFile(join(folder, dirent.slice(0, -2) + 'js'), js);
432
- }
433
- }
434
- for (const dirent of dirents) {
435
- if (dirent.endsWith('.ts')) {
436
- await rm(join(folder, dirent));
437
- }
438
- }
439
- };
534
+ const dirents = await readdir(folder)
535
+ for (const dirent of dirents) {
536
+ if (dirent.endsWith('.ts')) {
537
+ const content = await readFile(join(folder, dirent), 'utf-8')
538
+ const js = transpileFile(content)
539
+ await writeFile(join(folder, dirent.slice(0, -2) + 'js'), js)
540
+ }
541
+ }
542
+ for (const dirent of dirents) {
543
+ if (dirent.endsWith('.ts')) {
544
+ await rm(join(folder, dirent))
545
+ }
546
+ }
547
+ }
548
+
440
549
  export const createFilemap = async (fixturesPath) => {
441
- const filemap = {};
442
- const dirents = await readdir(fixturesPath, { withFileTypes: true, recursive: true });
443
- for (const dirent of dirents) {
444
- if (dirent.isFile()) {
445
- // Calculate relative path by removing the fixturesPath prefix from parentPath
446
- const fullPath = join(dirent.parentPath, dirent.name);
447
- let relativeFilePath;
448
- if (dirent.parentPath === fixturesPath) {
449
- relativeFilePath = dirent.name;
450
- }
451
- else {
452
- // Manually calculate relative path for cross-platform compatibility
453
- // Remove the fixturesPath prefix from parentPath and normalize separators
454
- const normalizedFixturesPath = fixturesPath.replace(/\\/g, '/');
455
- const normalizedParentPath = dirent.parentPath.replace(/\\/g, '/');
456
- const relativeDir = normalizedParentPath.replace(normalizedFixturesPath + '/', '');
457
- relativeFilePath = join(relativeDir, dirent.name);
458
- }
459
- const content = await FileSystem.readFile(fullPath);
460
- filemap[relativeFilePath] = content;
461
- }
462
- }
463
- return filemap;
464
- };
550
+ const filemap = {}
551
+
552
+ const dirents = await readdir(fixturesPath, { withFileTypes: true, recursive: true })
553
+
554
+ for (const dirent of dirents) {
555
+ if (dirent.isFile()) {
556
+ // Calculate relative path by removing the fixturesPath prefix from parentPath
557
+ const fullPath = join(dirent.parentPath, dirent.name)
558
+ let relativeFilePath
559
+ if (dirent.parentPath === fixturesPath) {
560
+ relativeFilePath = dirent.name
561
+ } else {
562
+ // Manually calculate relative path for cross-platform compatibility
563
+ // Remove the fixturesPath prefix from parentPath and normalize separators
564
+ const normalizedFixturesPath = fixturesPath.replace(/\\/g, '/')
565
+ const normalizedParentPath = dirent.parentPath.replace(/\\/g, '/')
566
+ const relativeDir = normalizedParentPath.replace(normalizedFixturesPath + '/', '')
567
+ relativeFilePath = join(relativeDir, dirent.name)
568
+ }
569
+ const content = await FileSystem.readFile(fullPath)
570
+ filemap[relativeFilePath] = content
571
+ }
572
+ }
573
+
574
+ return filemap
575
+ }
576
+
465
577
  export const createFilemapsPerFixture = async (fixturesPath) => {
466
- const dirents = await readdir(fixturesPath, { withFileTypes: true });
467
- const fixtureDirectories = dirents.filter((dirent) => dirent.isDirectory());
468
- // Create filemaps in parallel
469
- await Promise.all(fixtureDirectories.map(async (dirent) => {
470
- const fixturePath = join(fixturesPath, dirent.name);
471
- const filemap = await createFilemap(fixturePath);
472
- // Create fileMap.json in the fixture directory
473
- const fileMapPath = join(fixturePath, 'fileMap.json');
474
- await FileSystem.writeFile(fileMapPath, JSON.stringify(filemap, null, 2));
475
- }));
476
- };
477
- const addTestFiles = async ({ testPath, commitHash, root, pathPrefix }) => {
478
- const testRoot = isAbsolute(testPath) ? testPath : join(root, testPath);
479
- await FileSystem.copy(`${testRoot}/src`, `${root}/dist/${commitHash}/packages/extension-host-worker-tests/src`);
480
- if (existsSync(`${testRoot}/fixtures`)) {
481
- await FileSystem.copy(`${testRoot}/fixtures`, `${root}/dist/${commitHash}/packages/extension-host-worker-tests/fixtures`);
482
- // Create fileMap.json for each fixture directory
483
- await createFilemapsPerFixture(`${root}/dist/${commitHash}/packages/extension-host-worker-tests/fixtures`);
484
- }
485
- const distDirentsPath = `${root}/dist/${commitHash}/packages/extension-host-worker-tests/src`;
486
- await transpileFiles(distDirentsPath);
487
- const testFilesRaw = await FileSystem.readDir(`${testRoot}/src`);
488
- const testFiles = getTestFiles(testFilesRaw);
489
- const hashTestsPath = `${root}/dist/${commitHash}/tests`;
490
- const rootTestsPath = `${root}/dist/tests`;
491
- await FileSystem.mkdir(hashTestsPath);
492
- await FileSystem.mkdir(rootTestsPath);
493
- await FileSystem.copyFile(`${root}/dist/index.html`, `${hashTestsPath}/_all.html`);
494
- await FileSystem.copyFile(`${root}/dist/index.html`, `${rootTestsPath}/_all.html`);
495
- for (const testFile of testFiles) {
496
- await FileSystem.copyFile(`${root}/dist/index.html`, `${hashTestsPath}/${testFile}.html`);
497
- await FileSystem.copyFile(`${root}/dist/index.html`, `${rootTestsPath}/${testFile}.html`);
498
- }
499
- const testOverviewHtml = generateTestOverviewHtml(testFiles);
500
- await FileSystem.writeFile(`${hashTestsPath}/index.html`, testOverviewHtml);
501
- await FileSystem.writeFile(`${rootTestsPath}/index.html`, testOverviewHtml);
502
- };
578
+ const dirents = await readdir(fixturesPath, { withFileTypes: true })
579
+
580
+ const fixtureDirectories = dirents.filter((dirent) => dirent.isDirectory())
581
+
582
+ // Create filemaps in parallel
583
+ await Promise.all(
584
+ fixtureDirectories.map(async (dirent) => {
585
+ const fixturePath = join(fixturesPath, dirent.name)
586
+ const filemap = await createFilemap(fixturePath)
587
+
588
+ // Create fileMap.json in the fixture directory
589
+ const fileMapPath = join(fixturePath, 'fileMap.json')
590
+ await FileSystem.writeFile(fileMapPath, JSON.stringify(filemap, null, 2))
591
+ }),
592
+ )
593
+ }
594
+
595
+ const addTestFiles = async ({ testPath, commitHash, root, pathPrefix } ) => {
596
+ const testRoot = isAbsolute(testPath) ? testPath : join(root, testPath)
597
+ await FileSystem.copy(`${testRoot}/src`, `${root}/dist/${commitHash}/packages/extension-host-worker-tests/src`)
598
+ if (existsSync(`${testRoot}/fixtures`)) {
599
+ await FileSystem.copy(`${testRoot}/fixtures`, `${root}/dist/${commitHash}/packages/extension-host-worker-tests/fixtures`)
600
+
601
+ // Create fileMap.json for each fixture directory
602
+ await createFilemapsPerFixture(`${root}/dist/${commitHash}/packages/extension-host-worker-tests/fixtures`)
603
+ }
604
+ const distDirentsPath = `${root}/dist/${commitHash}/packages/extension-host-worker-tests/src`
605
+ await transpileFiles(distDirentsPath)
606
+
607
+ const testFilesRaw = await FileSystem.readDir(`${testRoot}/src`)
608
+ const testFiles = getTestFiles(testFilesRaw)
609
+ const hashTestsPath = `${root}/dist/${commitHash}/tests`
610
+ const rootTestsPath = `${root}/dist/tests`
611
+ await FileSystem.mkdir(hashTestsPath)
612
+ await FileSystem.mkdir(rootTestsPath)
613
+ await FileSystem.copyFile(`${root}/dist/index.html`, `${hashTestsPath}/_all.html`)
614
+ await FileSystem.copyFile(`${root}/dist/index.html`, `${rootTestsPath}/_all.html`)
615
+ for (const testFile of testFiles) {
616
+ await FileSystem.copyFile(`${root}/dist/index.html`, `${hashTestsPath}/${testFile}.html`)
617
+ await FileSystem.copyFile(`${root}/dist/index.html`, `${rootTestsPath}/${testFile}.html`)
618
+ }
619
+ const testOverviewHtml = generateTestOverviewHtml(testFiles)
620
+ await FileSystem.writeFile(`${hashTestsPath}/index.html`, testOverviewHtml)
621
+ await FileSystem.writeFile(`${rootTestsPath}/index.html`, testOverviewHtml)
622
+ }
623
+
503
624
  const resolveServerStaticPath = (root) => {
504
- const guessOne = Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static');
505
- if (existsSync(guessOne)) {
506
- return guessOne;
507
- }
508
- const guessTwo = Path.join(root, 'packages', 'build', 'node_modules', '@lvce-editor', 'server', 'static');
509
- if (existsSync(guessTwo)) {
510
- return guessTwo;
511
- }
512
- const guessThree = Path.join(root, 'packages', 'server', 'node_modules', '@lvce-editor', 'server', 'static');
513
- if (existsSync(guessThree)) {
514
- return guessThree;
515
- }
516
- const guessFour = Path.join(root, 'packages', 'build', 'node_modules', '@lvce-editor', 'static-server', 'static');
517
- if (existsSync(guessFour)) {
518
- return guessFour;
519
- }
520
- const guessFive = Path.join(root, 'node_modules', '@lvce-editor', 'static-server', 'static');
521
- if (existsSync(guessFive)) {
522
- return guessFive;
523
- }
524
- const guessSix = Path.join(root, 'packages', 'server', 'node_modules', '@lvce-editor', 'static-server', 'static');
525
- if (existsSync(guessSix)) {
526
- return guessSix;
527
- }
528
- throw new Error(`server static path not found`);
529
- };
625
+ const guessOne = Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static')
626
+ if (existsSync(guessOne)) {
627
+ return guessOne
628
+ }
629
+ const guessTwo = Path.join(root, 'packages', 'build', 'node_modules', '@lvce-editor', 'server', 'static')
630
+ if (existsSync(guessTwo)) {
631
+ return guessTwo
632
+ }
633
+ const guessThree = Path.join(root, 'packages', 'server', 'node_modules', '@lvce-editor', 'server', 'static')
634
+ if (existsSync(guessThree)) {
635
+ return guessThree
636
+ }
637
+ const guessFour = Path.join(root, 'packages', 'build', 'node_modules', '@lvce-editor', 'static-server', 'static')
638
+ if (existsSync(guessFour)) {
639
+ return guessFour
640
+ }
641
+ const guessFive = Path.join(root, 'node_modules', '@lvce-editor', 'static-server', 'static')
642
+ if (existsSync(guessFive)) {
643
+ return guessFive
644
+ }
645
+ const guessSix = Path.join(root, 'packages', 'server', 'node_modules', '@lvce-editor', 'static-server', 'static')
646
+ if (existsSync(guessSix)) {
647
+ return guessSix
648
+ }
649
+ throw new Error(`server static path not found`)
650
+ }
651
+
530
652
  const toArray = (value) => {
531
- if (!value) {
532
- return [];
533
- }
534
- if (Array.isArray(value)) {
535
- return value;
536
- }
537
- return [value];
538
- };
653
+ if (!value) {
654
+ return []
655
+ }
656
+ if (Array.isArray(value)) {
657
+ return value
658
+ }
659
+ return [value]
660
+ }
661
+
539
662
  const getExtensionPaths = (extensionPath, extensionPaths) => {
540
- const seen = Object.create(null);
541
- const allExtensionPaths = [];
542
- for (const path of [...toArray(extensionPath), ...toArray(extensionPaths)]) {
543
- if (!path || seen[path]) {
544
- continue;
545
- }
546
- seen[path] = true;
547
- allExtensionPaths.push(path);
548
- }
549
- return allExtensionPaths;
550
- };
663
+ const seen = Object.create(null)
664
+ const allExtensionPaths = []
665
+ for (const path of [...toArray(extensionPath), ...toArray(extensionPaths)]) {
666
+ if (!path || seen[path]) {
667
+ continue
668
+ }
669
+ seen[path] = true
670
+ allExtensionPaths.push(path)
671
+ }
672
+ return allExtensionPaths
673
+ }
674
+
551
675
  /**
552
676
  *
553
- * @param {{root:string, pathPrefix:string , extensionPath:string, extensionPaths?:string[], testPath:string, useSimpleWebExtensionFile?:boolean, serverStaticPath?:string }} param0
677
+ * @param {{root:string, pathPrefix:string, extensionPath:string, extensionPaths?:string[], testPath:string, useSimpleWebExtensionFile?:boolean, serverStaticPath?:string }} param0
554
678
  */
555
- export const exportStatic = async ({ root, pathPrefix, extensionPath, extensionPaths, testPath, useSimpleWebExtensionFile, serverStaticPath }) => {
556
- if (!existsSync(root)) {
557
- throw new Error(`root path does not exist: ${root}`);
558
- }
559
- const allExtensionPaths = getExtensionPaths(extensionPath, extensionPaths);
560
- for (const extensionPath of allExtensionPaths) {
561
- if (!existsSync(extensionPath)) {
562
- throw new Error(`extension path does not exist: ${extensionPath}`);
563
- }
564
- }
565
- if (!serverStaticPath) {
566
- serverStaticPath = resolveServerStaticPath(root);
567
- }
568
- if (pathPrefix === 'auto') {
569
- if (allExtensionPaths.length === 0) {
570
- throw new Error(`extension path is required when path prefix is auto`);
571
- }
572
- const [extensionPath] = allExtensionPaths;
573
- const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'));
574
- const { id } = extensionJson;
575
- const [author, name] = id.split('.');
576
- pathPrefix = `/${name}`;
577
- }
578
- const dirents = await FileSystem.readDir(serverStaticPath);
579
- const commitHash = dirents.find(isCommitHash) || '';
580
- console.time('clean');
581
- await clean(root);
582
- console.timeEnd('clean');
583
- console.time('copyStaticFiles');
584
- await copyStaticFiles(root, serverStaticPath);
585
- console.timeEnd('copyStaticFiles');
586
- console.time('applyOverrides');
587
- await applyOverrides({
588
- root,
589
- commitHash,
590
- pathPrefix,
591
- serverStaticPath,
592
- });
593
- console.timeEnd('applyOverrides');
594
- await updateExtensionsJson({ root, commitHash, pathPrefix, extraExtensions: [] });
595
- for (const extensionPath of allExtensionPaths) {
596
- console.time('addExtension');
597
- await addExtension({
598
- extensionPath,
599
- commitHash,
600
- pathPrefix,
601
- root,
602
- useSimpleWebExtensionFile,
603
- });
604
- console.timeEnd('addExtension');
605
- }
606
- if (testPath) {
607
- console.time('addTestFiles');
608
- await addTestFiles({
609
- testPath,
610
- commitHash,
611
- pathPrefix,
612
- root,
613
- });
614
- console.timeEnd('addTestFiles');
615
- }
616
- return {
617
- commitHash,
618
- };
619
- };
679
+ export const exportStatic = async ({
680
+ root,
681
+ pathPrefix,
682
+ extensionPath,
683
+ extensionPaths,
684
+ testPath,
685
+ useSimpleWebExtensionFile,
686
+ serverStaticPath,
687
+ } ) => {
688
+ if (!existsSync(root)) {
689
+ throw new Error(`root path does not exist: ${root}`)
690
+ }
691
+ const allExtensionPaths = getExtensionPaths(extensionPath, extensionPaths)
692
+ for (const extensionPath of allExtensionPaths) {
693
+ if (!existsSync(extensionPath)) {
694
+ throw new Error(`extension path does not exist: ${extensionPath}`)
695
+ }
696
+ }
697
+ if (!serverStaticPath) {
698
+ serverStaticPath = resolveServerStaticPath(root)
699
+ }
700
+ if (pathPrefix === 'auto') {
701
+ if (allExtensionPaths.length === 0) {
702
+ throw new Error(`extension path is required when path prefix is auto`)
703
+ }
704
+ const [extensionPath] = allExtensionPaths
705
+ const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'))
706
+ const { id } = extensionJson
707
+ const [author, name] = id.split('.')
708
+ pathPrefix = `/${name}`
709
+ }
710
+ const dirents = await FileSystem.readDir(serverStaticPath)
711
+ const commitHash = dirents.find(isCommitHash) || ''
712
+
713
+ console.time('clean')
714
+ await clean(root)
715
+ console.timeEnd('clean')
716
+
717
+ console.time('copyStaticFiles')
718
+ await copyStaticFiles(root, serverStaticPath)
719
+ console.timeEnd('copyStaticFiles')
720
+
721
+ console.time('applyOverrides')
722
+ await applyOverrides({
723
+ root,
724
+ commitHash,
725
+ pathPrefix,
726
+ serverStaticPath,
727
+ })
728
+ console.timeEnd('applyOverrides')
729
+
730
+ await updateExtensionsJson({ root, commitHash, pathPrefix, extraExtensions: [] })
731
+
732
+ for (const extensionPath of allExtensionPaths) {
733
+ console.time('addExtension')
734
+ await addExtension({
735
+ extensionPath,
736
+ commitHash,
737
+ pathPrefix,
738
+ root,
739
+ useSimpleWebExtensionFile,
740
+ })
741
+ console.timeEnd('addExtension')
742
+ }
743
+
744
+ if (testPath) {
745
+ console.time('addTestFiles')
746
+ await addTestFiles({
747
+ testPath,
748
+ commitHash,
749
+ pathPrefix,
750
+ root,
751
+ })
752
+ console.timeEnd('addTestFiles')
753
+ }
754
+ return {
755
+ commitHash,
756
+ }
757
+ }