refactor(cmdline): keep readiness in web app
This commit is contained in:
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/boot/cmdline/README.md
|
||||
README.md: 571ea7acf9f7be1ee2bdadafae2fc71b99d4536a
|
||||
README.zh.md: 271acd6be4d58bf12d41bc02dd3ccabc7359a269
|
||||
README.md: a1512ae3357f06cd4de6347ea5ec2197fea40a90
|
||||
README.zh.md: e27060db433e5c234febb28d6c120d75f82072cc
|
||||
|
||||
@@ -10,7 +10,6 @@ A launcher calls `provideCmdline(ctx, host)` before any tree entry mounts, which
|
||||
|
||||
- `ctx.cmdlineArgs` — the invocation's inner arguments. `get()` is the whole interface, and it returns a snapshot: `dsh --profile tui --resume abc` yields `['--resume', 'abc']`.
|
||||
- `ctx.appExit` — a bounded process-exit request, wired to the launcher's shutdown controller.
|
||||
- `ctx.appReady` — settles when the launcher has finished mounting, for a row that publishes readiness (a URL line a supervisor waits for).
|
||||
|
||||
An embedding host with no command line provides an empty list; that is the honest answer, not a missing value.
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ dsh 启动器交给它所引导应用的那条命令行。启动器只解析属
|
||||
|
||||
- `ctx.cmdlineArgs`:本次调用的内层参数。`get()` 就是它的全部接口,返回一份快照:`dsh --profile tui --resume abc` 得到 `['--resume', 'abc']`。
|
||||
- `ctx.appExit`:一个有边界的进程退出请求,接到启动器的关停控制器上。
|
||||
- `ctx.appReady`:在启动器挂载完毕时结算,供需要公布就绪信号的行使用(例如督程会等待的 URL 行)。
|
||||
|
||||
没有命令行的嵌入宿主提供空列表;这是诚实的答案,而不是缺失的值。
|
||||
|
||||
|
||||
@@ -53,8 +53,6 @@ declare module 'cordis' {
|
||||
cmdlineArgs?: CmdlineArgs
|
||||
/** Bounded process-exit request; provided by a launcher before the tree mounts. */
|
||||
appExit?: AppExit
|
||||
/** Settles when the launcher has mounted the whole composition; see {@link CmdlineHost.ready}. */
|
||||
appReady?: Promise<void>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,15 +62,6 @@ export interface CmdlineHost {
|
||||
args: readonly string[]
|
||||
/** Bounded process-exit request. */
|
||||
exit: AppExit
|
||||
/**
|
||||
* Settles when the launcher has finished mounting, which a row that
|
||||
* publishes readiness (a URL line a supervisor waits for) must await.
|
||||
*
|
||||
* Loader mounts sibling rows concurrently, so one row can become active
|
||||
* while another is still mounting or while the whole boot is rolling back.
|
||||
* Rejects with the boot failure.
|
||||
*/
|
||||
ready?: Promise<void>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +75,6 @@ export function provideCmdline(ctx: Context, host: CmdlineHost): void {
|
||||
const snapshot = [...host.args]
|
||||
ctx.provide('cmdlineArgs', { get: () => snapshot })
|
||||
ctx.provide('appExit', host.exit)
|
||||
if (host.ready !== undefined) ctx.provide('appReady', host.ready)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -297,11 +297,9 @@ describe('provideCmdline', () => {
|
||||
it('hands the app a snapshot the caller cannot mutate afterwards', () => {
|
||||
const ctx = new Context()
|
||||
const args = ['--resume', 'abc']
|
||||
const ready = Promise.resolve()
|
||||
provideCmdline(ctx, { args, exit: () => {}, ready })
|
||||
provideCmdline(ctx, { args, exit: () => {} })
|
||||
args.push('--tampered')
|
||||
expect(ctx.cmdlineArgs?.get()).toEqual(['--resume', 'abc'])
|
||||
expect(ctx.appReady).toBe(ready)
|
||||
})
|
||||
|
||||
it('fails loud when a startup row runs without the launcher values', () => {
|
||||
|
||||
Reference in New Issue
Block a user