@lvce-editor/shared-process 0.85.3 → 0.86.1

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 +13 -13
  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 +48 -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 +695 -552
  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 +16 -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,383 +1,491 @@
1
- import { existsSync } from 'node:fs';
2
- import { stripTypeScriptTypes } from 'node:module';
3
- import { isAbsolute, join } 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' };
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
+
10
11
  const staticContentSecurityPolicy = GetContentSecurityPolicy.getContentSecurityPolicy([
11
- `default-src 'none'`,
12
- `font-src 'self'`,
13
- `img-src 'self' https: data: blob:`, // TODO maybe disallow https and data images
14
- `manifest-src 'self'`,
15
- `media-src 'self' blob:`,
16
- `script-src 'self'`,
17
- `style-src 'self' 'unsafe-inline'`,
18
- `frame-src 'self' blob:`,
19
- ]);
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
+
20
22
  const readExtensionManifest = async (path) => {
21
- const json = await JsonFile.readJson(path);
22
- return { ...json, path };
23
- };
23
+ const json = await JsonFile.readJson(path)
24
+ return { ...json, path }
25
+ }
26
+
24
27
  const getThemeName = (dirent) => {
25
- return dirent.slice('builtin.theme-'.length);
26
- };
28
+ return dirent.slice('builtin.theme-'.length)
29
+ }
30
+
27
31
  const replace = async (path, occurrence, replacement) => {
28
- const oldContent = await FileSystem.readFile(path);
29
- if (!oldContent.includes(occurrence)) {
30
- throw new Error(`failed to replace occurrence ${occurrence} in ${path}: Not found`);
31
- }
32
- // @ts-ignore
33
- const newContent = oldContent.replaceAll(occurrence, replacement);
34
- await FileSystem.writeFile(path, newContent);
35
- };
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
+
36
41
  const getWorkerById = (id) => {
37
- const worker = workers.find((item) => {
38
- return item.id === id;
39
- });
40
- if (!worker) {
41
- throw new Error(`worker not found: ${id}`);
42
- }
43
- return worker;
44
- };
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
+
45
51
  const getDistPathFromWorkerPath = (path) => {
46
- return path.split('/').filter(Boolean);
47
- };
52
+ return path.split('/').filter(Boolean)
53
+ }
54
+
48
55
  const getWorkerDistPath = (root, commitHash, id) => {
49
- const worker = getWorkerById(id);
50
- return Path.join(root, 'dist', commitHash, ...getDistPathFromWorkerPath(worker.productionPath));
51
- };
56
+ const worker = getWorkerById(id)
57
+ return Path.join(root, 'dist', commitHash, ...getDistPathFromWorkerPath(worker.productionPath))
58
+ }
59
+
52
60
  /**
53
61
  * @param {string} dirent
54
62
  */
55
63
  const isLanguageBasics = (dirent) => {
56
- return dirent.startsWith('builtin.language-basics');
57
- };
64
+ return dirent.startsWith('builtin.language-basics')
65
+ }
66
+
58
67
  /**
59
68
  * @param {string} dirent
60
69
  */
61
70
  const isTheme = (dirent) => {
62
- return dirent.startsWith('builtin.theme-');
63
- };
71
+ return dirent.startsWith('builtin.theme-')
72
+ }
73
+
64
74
  /**
65
75
  * @param {string} dirent
66
76
  */
67
77
  const isIconTheme = (dirent) => {
68
- return dirent === 'builtin.vscode-icons';
69
- };
78
+ return dirent === 'builtin.vscode-icons'
79
+ }
80
+
70
81
  const compare = (a, b) => {
71
- return a.localeCompare(b);
72
- };
82
+ return a.localeCompare(b)
83
+ }
84
+
73
85
  const toSorted = (objects, compare) => {
74
- return [...objects].sort(compare);
75
- };
86
+ return [...objects].sort(compare)
87
+ }
88
+
76
89
  const mergeThemes = (builtinThemes, extensionThemes) => {
77
- const seen = [];
78
- const merged = [];
79
- for (const extensionTheme of extensionThemes) {
80
- seen.push(extensionTheme);
81
- merged.push(extensionTheme);
82
- }
83
- for (const builtinTheme of builtinThemes) {
84
- if (seen.includes(builtinTheme)) {
85
- continue;
86
- }
87
- merged.push(builtinTheme);
88
- }
89
- const sorted = toSorted(merged, compare);
90
- return sorted;
91
- };
92
- 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]+$/
93
107
  const isCommitHash = (dirent) => {
94
- return dirent.length === 7 && dirent.match(RE_COMMIT_HASH);
95
- };
108
+ return dirent.length === 7 && dirent.match(RE_COMMIT_HASH)
109
+ }
110
+
96
111
  /**
97
112
  * @param {string} root
98
113
  */
99
114
  const clean = async (root) => {
100
- await FileSystem.forceRemove(Path.join(root, 'dist'));
101
- await FileSystem.mkdir(Path.join(root, 'dist'));
102
- };
115
+ await FileSystem.forceRemove(Path.join(root, 'dist'))
116
+ await FileSystem.mkdir(Path.join(root, 'dist'))
117
+ }
118
+
103
119
  /**
104
120
  * @param {string} root
105
121
  */
106
122
  const copyStaticFiles = async (root, serverStaticPath) => {
107
- await FileSystem.copy(serverStaticPath, Path.join(root, 'dist'));
108
- };
109
- const applyOverridesRendererProcess = async ({ root, commitHash, pathPrefix }) => {
110
- await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'), 'platform = Remote;', 'platform = Web');
111
- await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
112
- };
113
- const applyOverrides = async ({ root, commitHash, pathPrefix, serverStaticPath }) => {
114
- const extensionHostWorkerDistPath = getWorkerDistPath(root, commitHash, 'extensionHostWorker');
115
- await applyOverridesRendererProcess({ root, commitHash, pathPrefix });
116
- await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), 'platform = Remote;', 'platform = Web$1;');
117
- await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
118
- await replace(extensionHostWorkerDistPath, `return \`\${assetDir}/extensions/builtin.theme-\${colorThemeId}/color-theme.json\``, `return \`\${assetDir}/themes/\${colorThemeId}.json\``);
119
- await replace(extensionHostWorkerDistPath, `/${commitHash}`, `${pathPrefix}/${commitHash}`);
120
- await replace(extensionHostWorkerDistPath, `const platform = Remote`, `const platform = Web`);
121
- // await replace(
122
- // Path.join(root, 'dist', commitHash, 'packages', 'extension-host-worker', 'dist', 'extensionHostWorkerMain.js'),
123
- // `return \`\${assetDir}/extensions/builtin.\${iconThemeId}/icon-theme.json\``,
124
- // `return \`\${assetDir}/icon-themes/\${iconThemeId}.json\``,
125
- // )
126
- const extensionDirents = await FileSystem.readDir(Path.join(serverStaticPath, commitHash, 'extensions'));
127
- const languageBasicsDirents = extensionDirents.filter(isLanguageBasics);
128
- const themeDirents = extensionDirents.filter(isTheme);
129
- const iconThemeDirents = extensionDirents.filter(isIconTheme);
130
- const getLanguages = (extension) => {
131
- const languages = [];
132
- for (const language of extension.languages || []) {
133
- languages.push({
134
- ...language,
135
- tokenize: `${pathPrefix}/${commitHash}/extensions/${extension.id}/${language.tokenize}`,
136
- });
137
- }
138
- return languages;
139
- };
140
- const getWebViews = (extension) => {
141
- const webViews = [];
142
- for (const webView of extension.webViews || []) {
143
- webViews.push({
144
- ...webView,
145
- path: `${pathPrefix}/${commitHash}/extensions/${webView.path}`,
146
- remotePath: `${pathPrefix}/${commitHash}/extensions/${extension.id}`,
147
- });
148
- }
149
- return webViews;
150
- };
151
- /**
152
- * @param {string} dirent
153
- */
154
- const getManifestPath = (dirent) => {
155
- return Path.join(serverStaticPath, commitHash, 'extensions', dirent, 'extension.json');
156
- };
157
- const manifestPaths = languageBasicsDirents.map(getManifestPath);
158
- const manifests = await Promise.all(manifestPaths.map(readExtensionManifest));
159
- const languages = manifests.flatMap(getLanguages);
160
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'), languages);
161
- const webViews = manifests.flatMap(getWebViews);
162
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webViews.json'), webViews);
163
- for (const languageBasicsDirent of languageBasicsDirents) {
164
- await FileSystem.copy(Path.join(serverStaticPath, commitHash, 'extensions', languageBasicsDirent), Path.join(root, 'dist', commitHash, 'extensions', languageBasicsDirent));
165
- }
166
- for (const themeDirent of themeDirents) {
167
- const themeId = getThemeName(themeDirent);
168
- await FileSystem.copy(Path.join(serverStaticPath, commitHash, 'extensions', themeDirent, 'color-theme.json'), Path.join(root, 'dist', commitHash, 'themes', `${themeId}.json`));
169
- }
170
- const themeIds = mergeThemes(themeDirents.map(getThemeName), []);
171
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'), themeIds);
172
- for (const iconThemeDirent of iconThemeDirents) {
173
- const iconThemeId = iconThemeDirent.slice('builtin.'.length);
174
- await FileSystem.copy(Path.join(serverStaticPath, commitHash, 'extensions', iconThemeDirent, 'icon-theme.json'), Path.join(root, 'dist', commitHash, 'icon-themes', `${iconThemeId}.json`));
175
- }
176
- const indexHtmlPath = Path.join(root, 'dist', 'index.html');
177
- await replace(indexHtmlPath, `/${commitHash}`, `${pathPrefix}/${commitHash}`);
178
- await replace(indexHtmlPath, '#282e2f" />', `#282e2f" />
179
- <meta http-equiv="Content-Security-Policy" content="${staticContentSecurityPolicy}">`);
180
- if (pathPrefix) {
181
- await replace(indexHtmlPath, '</title>', `</title>
182
- <link rel="shortcut icon" type="image/x-icon" href="${pathPrefix}/favicon.ico">`);
183
- }
184
- else {
185
- await replace(indexHtmlPath, '</title>', `</title>
186
- <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">`);
187
- }
188
- if (pathPrefix) {
189
- await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
190
- await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"start_url": "/"`, `"start_url": "${pathPrefix}"`);
191
- await replace(Path.join(root, 'dist', commitHash, 'css', 'App.css'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
192
- }
193
- };
194
- const addExtensionSeo = async ({ root, name, description, commitHash }) => {
195
- await replace(Path.join(root, 'dist', 'index.html'), '<title>Lvce Editor</title>', `<title>${name}</title>`);
196
- await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"name": "Code Editor Web - OSS"`, `"name": "${name}"`);
197
- await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"short_name": "Web - OSS"`, `"short_name": "${name}"`);
198
- await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"description": "Web Code Editor."`, `"description": "${description}"`);
199
- 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}" />`);
200
- };
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
+
201
278
  const getId = (object) => {
202
- return object.id;
203
- };
204
- const addExtensionThemes = async ({ root, extensionPath, extensionJson, commitHash }) => {
205
- const colorThemes = extensionJson.colorThemes || [];
206
- if (colorThemes.length === 0) {
207
- return;
208
- }
209
- for (const colorTheme of colorThemes) {
210
- const { id, path } = colorTheme;
211
- const extensionId = `builtin.theme-${id}`;
212
- await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
213
- await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
214
- await FileSystem.copy(Path.join(extensionPath, path), Path.join(root, 'dist', commitHash, 'themes', `${id}.json`));
215
- await replace(Path.join(root, 'dist', commitHash, 'config', 'defaultSettings.json'), `"workbench.colorTheme": "slime"`, `"workbench.colorTheme": "${id}"`);
216
- await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'README.md'));
217
- await FileSystem.copyFile(Path.join(extensionPath, 'extension.json'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'extension.json'));
218
- await FileSystem.copyFile(Path.join(extensionPath, 'color-theme.json'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'color-theme.json'));
219
- }
220
- const themesJson = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'));
221
- const ids = colorThemes.map(getId);
222
- const mergedThemes = mergeThemes(themesJson, ids);
223
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'), mergedThemes);
224
- };
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
+
225
314
  const compareId = (a, b) => {
226
- return a.id.localeCompare(b.id);
227
- };
315
+ return a.id.localeCompare(b.id)
316
+ }
317
+
228
318
  const mergeLanguages = (languages, extensionLanguages) => {
229
- const seen = [];
230
- const merged = [];
231
- for (const language of extensionLanguages) {
232
- seen.push(language.id);
233
- merged.push(language);
234
- }
235
- for (const language of languages) {
236
- if (seen.includes(language.id)) {
237
- continue;
238
- }
239
- merged.push(language);
240
- }
241
- merged.sort(compareId);
242
- return merged;
243
- };
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
+
244
335
  const toPlaygroundFile = (file) => {
245
- return `/playground/${file}`;
246
- };
247
- const addExtensionLanguages = async ({ root, extensionPath, extensionJson, commitHash, pathPrefix }) => {
248
- const languages = extensionJson.languages || [];
249
- if (languages.length === 0) {
250
- return;
251
- }
252
- const extensionId = extensionJson.id;
253
- await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
254
- await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
255
- await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'README.md'));
256
- for (const file of ['src', 'data', 'extension.json']) {
257
- if (await FileSystem.exists(Path.join(extensionPath, file))) {
258
- await FileSystem.copy(Path.join(extensionPath, file), Path.join(root, 'dist', commitHash, 'extensions', extensionId, file));
259
- }
260
- }
261
- const extensionLanguages = [];
262
- for (const language of languages) {
263
- if (!language.tokenize) {
264
- continue;
265
- }
266
- extensionLanguages.push({
267
- ...language,
268
- tokenize: `${pathPrefix}/${commitHash}/extensions/${extensionId}/${language.tokenize}`,
269
- });
270
- }
271
- const builtinLanguages = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'));
272
- const mergedLanguages = mergeLanguages(builtinLanguages, extensionLanguages);
273
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'), mergedLanguages);
274
- if (await FileSystem.exists(Path.join(extensionPath, 'test', 'cases'))) {
275
- await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'playground'));
276
- await FileSystem.copy(Path.join(extensionPath, 'test', 'cases'), Path.join(root, 'dist', commitHash, 'playground'));
277
- const testFiles = await FileSystem.readDir(Path.join(extensionPath, 'test', 'cases'));
278
- const fileMap = testFiles.map(toPlaygroundFile);
279
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'fileMap.json'), fileMap);
280
- }
281
- };
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
+
282
375
  export const mergeExtensionManifests = (manifests, extraExtensions) => {
283
- const replacements = Object.create(null);
284
- for (const extension of extraExtensions) {
285
- replacements[extension.id] = extension;
286
- }
287
- const used = Object.create(null);
288
- const merged = manifests.map((manifest) => {
289
- const replacement = replacements[manifest.id];
290
- if (replacement) {
291
- used[manifest.id] = true;
292
- return replacement;
293
- }
294
- return manifest;
295
- });
296
- for (const extension of extraExtensions) {
297
- if (used[extension.id]) {
298
- continue;
299
- }
300
- merged.push(extension);
301
- }
302
- return merged;
303
- };
304
- const updateExtensionsJson = async ({ root, commitHash, pathPrefix, extraExtensions }) => {
305
- const dirents = await FileSystem.readDir(Path.join(root, 'dist', commitHash, 'extensions'));
306
- const manifests = await Promise.all(dirents.map(async (dirent) => {
307
- const json = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'extensions', dirent, 'extension.json'));
308
- const webExtensionPath = `${pathPrefix}/${commitHash}/extensions/${dirent}`;
309
- return {
310
- ...json,
311
- path: webExtensionPath,
312
- };
313
- }));
314
- const localExtensions = extraExtensions.map((extension) => {
315
- return {
316
- ...extension,
317
- path: `${pathPrefix}/${commitHash}/extensions/${extension.id}`,
318
- };
319
- });
320
- const newExtensions = mergeExtensionManifests(manifests, localExtensions);
321
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'extensions.json'), newExtensions);
322
- };
323
- const addExtensionWebExtension = async ({ root, extensionPath, commitHash, extensionJson, pathPrefix, useSimpleWebExtensionFile }) => {
324
- await updateExtensionsJson({ root, commitHash, pathPrefix, extraExtensions: [extensionJson] });
325
- if (!extensionJson.browser) {
326
- return;
327
- }
328
- const webExtensionPath = `${pathPrefix}/${commitHash}/extensions/${extensionJson.id}`;
329
- if (useSimpleWebExtensionFile) {
330
- const webExtensions = [webExtensionPath];
331
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webExtensions.json'), webExtensions);
332
- return;
333
- }
334
- const webExtensions = [
335
- {
336
- ...extensionJson,
337
- isWeb: true,
338
- path: webExtensionPath,
339
- },
340
- ];
341
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webExtensions.json'), webExtensions);
342
- await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionJson.id));
343
- for (const dirent of ['src', 'extension.json']) {
344
- await FileSystem.copy(Path.join(extensionPath, dirent), Path.join(root, 'dist', commitHash, 'extensions', extensionJson.id, dirent));
345
- }
346
- };
347
- const addExtension = async ({ root, extensionPath, commitHash, pathPrefix, useSimpleWebExtensionFile }) => {
348
- const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'));
349
- const name = extensionJson.name || extensionJson.id || '';
350
- const description = extensionJson.description || '';
351
- await addExtensionSeo({
352
- root,
353
- commitHash,
354
- name,
355
- description,
356
- });
357
- await addExtensionThemes({
358
- root,
359
- commitHash,
360
- extensionJson,
361
- extensionPath,
362
- });
363
- await addExtensionLanguages({
364
- root,
365
- extensionPath,
366
- commitHash,
367
- extensionJson,
368
- pathPrefix,
369
- });
370
- await addExtensionWebExtension({
371
- root,
372
- extensionPath,
373
- commitHash,
374
- extensionJson,
375
- pathPrefix,
376
- useSimpleWebExtensionFile,
377
- });
378
- };
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
+
379
487
  const generateTestOverviewHtml = (dirents) => {
380
- const pre = `<!DOCTYPE html>
488
+ const pre = `<!DOCTYPE html>
381
489
  <html lang="en">
382
490
  <head>
383
491
  <meta charset="UTF-8" />
@@ -388,227 +496,262 @@ const generateTestOverviewHtml = (dirents) => {
388
496
  <h1>Tests</h1>
389
497
  <p>Available Tests</p>
390
498
  <ul>
391
- `;
392
- let middle = ``;
393
- // TODO properly escape name
394
- for (const dirent of dirents) {
395
- const name = dirent;
396
- middle += ` <li><a href="./${name}.html">${name}</a></li>
397
- `;
398
- }
399
- 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>
400
509
  </body>
401
510
  </html>
402
- `;
403
- return pre + middle + post;
404
- };
511
+ `
512
+ return pre + middle + post
513
+ }
514
+
405
515
  const getName = (name) => {
406
- return name.replace(/\.(js|ts)$/, '');
407
- };
516
+ return name.replace(/\.(js|ts)$/, '')
517
+ }
408
518
  const isTestFile = (file) => {
409
- if (file.startsWith('_')) {
410
- return false;
411
- }
412
- return file.endsWith('.js') || file.endsWith('.ts');
413
- };
519
+ if (file.startsWith('_')) {
520
+ return false
521
+ }
522
+ return file.endsWith('.js') || file.endsWith('.ts')
523
+ }
524
+
414
525
  const getTestFiles = (testFilesRaw) => {
415
- return testFilesRaw.filter(isTestFile).map(getName);
416
- };
526
+ return testFilesRaw.filter(isTestFile).map(getName)
527
+ }
528
+
417
529
  export const transpileFile = (content) => {
418
- return stripTypeScriptTypes(content);
419
- };
530
+ return stripTypeScriptTypes(content)
531
+ }
532
+
420
533
  const transpileFiles = async (folder) => {
421
- const dirents = await readdir(folder);
422
- for (const dirent of dirents) {
423
- if (dirent.endsWith('.ts')) {
424
- const content = await readFile(join(folder, dirent), 'utf-8');
425
- const js = transpileFile(content);
426
- await writeFile(join(folder, dirent.slice(0, -2) + 'js'), js);
427
- }
428
- }
429
- for (const dirent of dirents) {
430
- if (dirent.endsWith('.ts')) {
431
- await rm(join(folder, dirent));
432
- }
433
- }
434
- };
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
+
435
549
  export const createFilemap = async (fixturesPath) => {
436
- const filemap = {};
437
- const dirents = await readdir(fixturesPath, { withFileTypes: true, recursive: true });
438
- for (const dirent of dirents) {
439
- if (dirent.isFile()) {
440
- // Calculate relative path by removing the fixturesPath prefix from parentPath
441
- const fullPath = join(dirent.parentPath, dirent.name);
442
- let relativeFilePath;
443
- if (dirent.parentPath === fixturesPath) {
444
- relativeFilePath = dirent.name;
445
- }
446
- else {
447
- // Manually calculate relative path for cross-platform compatibility
448
- // Remove the fixturesPath prefix from parentPath and normalize separators
449
- const normalizedFixturesPath = fixturesPath.replace(/\\/g, '/');
450
- const normalizedParentPath = dirent.parentPath.replace(/\\/g, '/');
451
- const relativeDir = normalizedParentPath.replace(normalizedFixturesPath + '/', '');
452
- relativeFilePath = join(relativeDir, dirent.name);
453
- }
454
- const content = await FileSystem.readFile(fullPath);
455
- filemap[relativeFilePath] = content;
456
- }
457
- }
458
- return filemap;
459
- };
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
+
460
577
  export const createFilemapsPerFixture = async (fixturesPath) => {
461
- const dirents = await readdir(fixturesPath, { withFileTypes: true });
462
- const fixtureDirectories = dirents.filter((dirent) => dirent.isDirectory());
463
- // Create filemaps in parallel
464
- await Promise.all(fixtureDirectories.map(async (dirent) => {
465
- const fixturePath = join(fixturesPath, dirent.name);
466
- const filemap = await createFilemap(fixturePath);
467
- // Create fileMap.json in the fixture directory
468
- const fileMapPath = join(fixturePath, 'fileMap.json');
469
- await FileSystem.writeFile(fileMapPath, JSON.stringify(filemap, null, 2));
470
- }));
471
- };
472
- const addTestFiles = async ({ testPath, commitHash, root, pathPrefix }) => {
473
- const testRoot = isAbsolute(testPath) ? testPath : join(root, testPath);
474
- await FileSystem.copy(`${testRoot}/src`, `${root}/dist/${commitHash}/packages/extension-host-worker-tests/src`);
475
- if (existsSync(`${testRoot}/fixtures`)) {
476
- await FileSystem.copy(`${testRoot}/fixtures`, `${root}/dist/${commitHash}/packages/extension-host-worker-tests/fixtures`);
477
- // Create fileMap.json for each fixture directory
478
- await createFilemapsPerFixture(`${root}/dist/${commitHash}/packages/extension-host-worker-tests/fixtures`);
479
- }
480
- const distDirentsPath = `${root}/dist/${commitHash}/packages/extension-host-worker-tests/src`;
481
- await transpileFiles(distDirentsPath);
482
- const testFilesRaw = await FileSystem.readDir(`${testRoot}/src`);
483
- const testFiles = getTestFiles(testFilesRaw);
484
- const hashTestsPath = `${root}/dist/${commitHash}/tests`;
485
- const rootTestsPath = `${root}/dist/tests`;
486
- await FileSystem.mkdir(hashTestsPath);
487
- await FileSystem.mkdir(rootTestsPath);
488
- await FileSystem.copyFile(`${root}/dist/index.html`, `${hashTestsPath}/_all.html`);
489
- await FileSystem.copyFile(`${root}/dist/index.html`, `${rootTestsPath}/_all.html`);
490
- for (const testFile of testFiles) {
491
- await FileSystem.copyFile(`${root}/dist/index.html`, `${hashTestsPath}/${testFile}.html`);
492
- await FileSystem.copyFile(`${root}/dist/index.html`, `${rootTestsPath}/${testFile}.html`);
493
- }
494
- const testOverviewHtml = generateTestOverviewHtml(testFiles);
495
- await FileSystem.writeFile(`${hashTestsPath}/index.html`, testOverviewHtml);
496
- await FileSystem.writeFile(`${rootTestsPath}/index.html`, testOverviewHtml);
497
- };
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
+
498
624
  const resolveServerStaticPath = (root) => {
499
- const guessOne = Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static');
500
- if (existsSync(guessOne)) {
501
- return guessOne;
502
- }
503
- const guessTwo = Path.join(root, 'packages', 'build', 'node_modules', '@lvce-editor', 'server', 'static');
504
- if (existsSync(guessTwo)) {
505
- return guessTwo;
506
- }
507
- const guessThree = Path.join(root, 'packages', 'server', 'node_modules', '@lvce-editor', 'server', 'static');
508
- if (existsSync(guessThree)) {
509
- return guessThree;
510
- }
511
- const guessFour = Path.join(root, 'packages', 'build', 'node_modules', '@lvce-editor', 'static-server', 'static');
512
- if (existsSync(guessFour)) {
513
- return guessFour;
514
- }
515
- const guessFive = Path.join(root, 'node_modules', '@lvce-editor', 'static-server', 'static');
516
- if (existsSync(guessFive)) {
517
- return guessFive;
518
- }
519
- const guessSix = Path.join(root, 'packages', 'server', 'node_modules', '@lvce-editor', 'static-server', 'static');
520
- if (existsSync(guessSix)) {
521
- return guessSix;
522
- }
523
- throw new Error(`server static path not found`);
524
- };
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
+
525
652
  const toArray = (value) => {
526
- if (!value) {
527
- return [];
528
- }
529
- if (Array.isArray(value)) {
530
- return value;
531
- }
532
- return [value];
533
- };
653
+ if (!value) {
654
+ return []
655
+ }
656
+ if (Array.isArray(value)) {
657
+ return value
658
+ }
659
+ return [value]
660
+ }
661
+
534
662
  const getExtensionPaths = (extensionPath, extensionPaths) => {
535
- const seen = Object.create(null);
536
- const allExtensionPaths = [];
537
- for (const path of [...toArray(extensionPath), ...toArray(extensionPaths)]) {
538
- if (!path || seen[path]) {
539
- continue;
540
- }
541
- seen[path] = true;
542
- allExtensionPaths.push(path);
543
- }
544
- return allExtensionPaths;
545
- };
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
+
546
675
  /**
547
676
  *
548
- * @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
549
678
  */
550
- export const exportStatic = async ({ root, pathPrefix, extensionPath, extensionPaths, testPath, useSimpleWebExtensionFile, serverStaticPath }) => {
551
- if (!existsSync(root)) {
552
- throw new Error(`root path does not exist: ${root}`);
553
- }
554
- const allExtensionPaths = getExtensionPaths(extensionPath, extensionPaths);
555
- for (const extensionPath of allExtensionPaths) {
556
- if (!existsSync(extensionPath)) {
557
- throw new Error(`extension path does not exist: ${extensionPath}`);
558
- }
559
- }
560
- if (!serverStaticPath) {
561
- serverStaticPath = resolveServerStaticPath(root);
562
- }
563
- if (pathPrefix === 'auto') {
564
- if (allExtensionPaths.length === 0) {
565
- throw new Error(`extension path is required when path prefix is auto`);
566
- }
567
- const [extensionPath] = allExtensionPaths;
568
- const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'));
569
- const { id } = extensionJson;
570
- const [author, name] = id.split('.');
571
- pathPrefix = `/${name}`;
572
- }
573
- const dirents = await FileSystem.readDir(serverStaticPath);
574
- const commitHash = dirents.find(isCommitHash) || '';
575
- console.time('clean');
576
- await clean(root);
577
- console.timeEnd('clean');
578
- console.time('copyStaticFiles');
579
- await copyStaticFiles(root, serverStaticPath);
580
- console.timeEnd('copyStaticFiles');
581
- console.time('applyOverrides');
582
- await applyOverrides({
583
- root,
584
- commitHash,
585
- pathPrefix,
586
- serverStaticPath,
587
- });
588
- console.timeEnd('applyOverrides');
589
- await updateExtensionsJson({ root, commitHash, pathPrefix, extraExtensions: [] });
590
- for (const extensionPath of allExtensionPaths) {
591
- console.time('addExtension');
592
- await addExtension({
593
- extensionPath,
594
- commitHash,
595
- pathPrefix,
596
- root,
597
- useSimpleWebExtensionFile,
598
- });
599
- console.timeEnd('addExtension');
600
- }
601
- if (testPath) {
602
- console.time('addTestFiles');
603
- await addTestFiles({
604
- testPath,
605
- commitHash,
606
- pathPrefix,
607
- root,
608
- });
609
- console.timeEnd('addTestFiles');
610
- }
611
- return {
612
- commitHash,
613
- };
614
- };
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
+ }