|
1 | | -#!/usr/bin/env powershell |
| 1 | +#!/usr/bin/env powershell |
2 | 2 | <# |
3 | 3 | .SYNOPSIS |
4 | 4 | 安装 automation 脚本到指定目录,供开发环境运行时使用。 |
@@ -273,21 +273,58 @@ try |
273 | 273 | $ToolboxPatchScanning = @" |
274 | 274 | macros, modules = {}, {} |
275 | 275 | aegisub.progress.task "Scanning available feeds..." |
276 | | - entries = crawlWithPrompt buildFeedInventory! |
| 276 | + entries = crawlWithPrompt buildFeedInventory!, (fetched, known) -> |
| 277 | + aegisub.progress.set math.floor fetched * 100 / known |
| 278 | + -- 用户取消时中断 crawl,error 穿透到 crawlWithPrompt 的 pcall 静默退出 |
| 279 | + error "cancelled", 0 if aegisub.progress.is_cancelled! |
| 280 | + -- 收尾到满格,抓取失败或被预算截断的 feed 不触发回调,进度会停在最后一次成功回调的值 |
| 281 | + aegisub.progress.set 100 |
| 282 | + return unless entries |
277 | 283 | "@ |
278 | 284 | $ToolboxPatchLoading = @" |
279 | 285 | aegisub.progress.task "Loading feed data..." |
280 | 286 | logger\log msgs.install.scanning, #entries |
| 287 | +"@ |
| 288 | + # FeedInventory 进度回调(crawl 每抓取一个 feed 通知调用方, |
| 289 | + # known 随 BFS 发现新 feed 动态增长,进度可能小幅回退属预期) |
| 290 | + $FeedInventoryPatchCrawl = @" |
| 291 | + crawl: (onProgress) => |
| 292 | + inventoryEntriesByUrl = @__collectConfigFeeds! |
| 293 | + stats = @__crawlKnownFeeds inventoryEntriesByUrl, onProgress |
| 294 | +"@ |
| 295 | + $FeedInventoryPatchSink = @" |
| 296 | + __crawlKnownFeeds: (inventoryEntriesByUrl, onProgress) => |
| 297 | +"@ |
| 298 | + $FeedInventoryPatchNotify = @" |
| 299 | + stats.fetched += 1 |
| 300 | + inventoryEntriesByUrl[feedUrl].fetched = true |
| 301 | + onProgress stats.fetched, #queue - head + 1 + stats.fetched if onProgress |
| 302 | +"@ |
| 303 | + $ToolboxPatchCrawlWithPrompt = @" |
| 304 | +crawlWithPrompt = (inventory, onProgress) -> |
| 305 | + feedTrust = DepCtrl.updater.feedTrust |
| 306 | + feedTrust\setPrompter promptUntrustedFeed |
| 307 | + ok, entries = pcall inventory.crawl, inventory, onProgress |
| 308 | + feedTrust\setPrompter nil |
| 309 | + if not ok and entries != "cancelled" |
| 310 | + error entries, 0 |
| 311 | + return nil unless ok |
| 312 | + entries |
281 | 313 | "@ |
282 | 314 | $ToolboxPatchEmpty = @" |
283 | | - unless next(macros) or next(modules) |
284 | | - aegisub.log 0, "All available scripts are already installed; nothing new to install." |
285 | | - return |
286 | | -
|
287 | 315 | moduleList, moduleMap = buildDlgList modules |
288 | 316 | macroList, macroMap = buildDlgList macros |
| 317 | +
|
| 318 | + if #moduleList == 0 and #macroList == 0 |
| 319 | + unfetched = #[entry for entry in *entries when not entry.fetched] |
| 320 | + message = unfetched > 0 and ("No scripts are available to install (%d of %d known feeds could not be fetched).")\format(unfetched, #entries) or "All available scripts are already installed." |
| 321 | + aegisub.dialog.display {{class: "label", x: 0, y: 0, width: 1, height: 1, label: message}}, |
| 322 | + {buttons.close}, {ok: buttons.close, cancel: buttons.close} |
| 323 | + return |
| 324 | +
|
| 325 | + btn, res = aegisub.dialog.display getScriptListDlg macroList, moduleList |
289 | 326 | "@ |
290 | | - Install-ReleaseScript -Name "DependencyControl" -Repo "TypesettingTools/DependencyControl" -Pattern "\.zip$" -PatchTag "v0.9.0" -PatchFiles @("autoload/l0.DependencyControl.Toolbox.moon", "autoload/l0.DependencyControl.Toolbox.moon", "autoload/l0.DependencyControl.Toolbox.moon") -PatchFroms @(" macros, modules = {}, {}`n entries = crawlWithPrompt buildFeedInventory!", " logger\log msgs.install.scanning, #entries", " moduleList, moduleMap = buildDlgList modules`n macroList, macroMap = buildDlgList macros") -PatchTos @($ToolboxPatchScanning, $ToolboxPatchLoading, $ToolboxPatchEmpty) |
| 327 | + Install-ReleaseScript -Name "DependencyControl" -Repo "TypesettingTools/DependencyControl" -Pattern "\.zip$" -PatchTag "v0.9.0" -PatchFiles @("autoload/l0.DependencyControl.Toolbox.moon", "autoload/l0.DependencyControl.Toolbox.moon", "autoload/l0.DependencyControl.Toolbox.moon", "autoload/l0.DependencyControl.Toolbox.moon", "include/l0/DependencyControl/FeedInventory.moon", "include/l0/DependencyControl/FeedInventory.moon", "include/l0/DependencyControl/FeedInventory.moon") -PatchFroms @(" macros, modules = {}, {}`n entries = crawlWithPrompt buildFeedInventory!", " logger\log msgs.install.scanning, #entries", "crawlWithPrompt = (inventory) ->`n feedTrust = DepCtrl.updater.feedTrust`n feedTrust\setPrompter promptUntrustedFeed`n entries = inventory\crawl!`n feedTrust\setPrompter nil`n entries", " moduleList, moduleMap = buildDlgList modules`n macroList, macroMap = buildDlgList macros`n`n btn, res = aegisub.dialog.display getScriptListDlg macroList, moduleList", " crawl: =>`n inventoryEntriesByUrl = @__collectConfigFeeds!`n stats = @__crawlKnownFeeds inventoryEntriesByUrl", " __crawlKnownFeeds: (inventoryEntriesByUrl) =>", " stats.fetched += 1`n inventoryEntriesByUrl[feedUrl].fetched = true") -PatchTos @($ToolboxPatchScanning, $ToolboxPatchLoading, $ToolboxPatchCrawlWithPrompt, $ToolboxPatchEmpty, $FeedInventoryPatchCrawl, $FeedInventoryPatchSink, $FeedInventoryPatchNotify) |
291 | 328 |
|
292 | 329 | # Aegisub-Motion(DepCtrl 分支) |
293 | 330 | Install-GitScript -Name "Aegisub-Motion" -Repo "https://github.com/TypesettingTools/Aegisub-Motion.git" -Branch "DepCtrl" -Copy @("a-mo.Aegisub-Motion.moon=autoload", "src=include/a-mo") |
|
0 commit comments