dsh-crate 0.0.0-stage → 0.5.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.
- package/LICENSE +27 -0
- package/README.md +288 -2
- package/README.zh.md +263 -0
- package/UPDATE-API-V1.md +207 -0
- package/assets/logo.svg +37 -0
- package/client/client.js +18964 -0
- package/cordis.patch.yml +4 -0
- package/lib/accelerate.js +194 -0
- package/lib/agents.js +67 -0
- package/lib/backup.js +688 -0
- package/lib/body-progress.js +173 -0
- package/lib/catalog-local-match.js +160 -0
- package/lib/catalog-npm.js +180 -0
- package/lib/changelog.js +462 -0
- package/lib/channels.js +64 -0
- package/lib/check.js +1557 -0
- package/lib/compatibility.js +265 -0
- package/lib/crate-catalog.js +179 -0
- package/lib/diagnostics.js +49 -0
- package/lib/discovery-compatibility.js +476 -0
- package/lib/drain-journal.js +164 -0
- package/lib/drain.js +1043 -0
- package/lib/dsh-cli.js +1373 -0
- package/lib/dsh-install.js +259 -0
- package/lib/entry-identity.js +85 -0
- package/lib/gist.js +369 -0
- package/lib/groups.js +108 -0
- package/lib/home-paths.js +29 -0
- package/lib/host-recovery.js +187 -0
- package/lib/hot.js +918 -0
- package/lib/http.js +252 -0
- package/lib/index.js +394 -0
- package/lib/install.js +1147 -0
- package/lib/lifecycle.js +37 -0
- package/lib/log-redaction.js +24 -0
- package/lib/log.js +204 -0
- package/lib/ndjson.js +154 -0
- package/lib/net.js +174 -0
- package/lib/official-desktop.js +619 -0
- package/lib/order.js +284 -0
- package/lib/patch.js +943 -0
- package/lib/pending-rows.js +142 -0
- package/lib/pending-updates.js +346 -0
- package/lib/pnpm-compat.js +972 -0
- package/lib/presets.js +282 -0
- package/lib/probe-context.js +20 -0
- package/lib/proc-text.js +69 -0
- package/lib/profile.js +1989 -0
- package/lib/recovery.js +1059 -0
- package/lib/region-probe.js +93 -0
- package/lib/regions.js +283 -0
- package/lib/registry.js +308 -0
- package/lib/release-candidates.js +115 -0
- package/lib/release-updates.js +70 -0
- package/lib/restart.js +688 -0
- package/lib/routes.js +7960 -0
- package/lib/settings.js +164 -0
- package/lib/shelfry-catalog.js +179 -0
- package/lib/snapshot.js +506 -0
- package/lib/source-migration.js +164 -0
- package/lib/sources.js +1005 -0
- package/lib/state.js +38 -0
- package/lib/store.js +163 -0
- package/lib/themes.js +350 -0
- package/lib/trial.js +125 -0
- package/lib/types/accelerate.d.ts +85 -0
- package/lib/types/agents.d.ts +52 -0
- package/lib/types/backup.d.ts +171 -0
- package/lib/types/body-progress.d.ts +94 -0
- package/lib/types/catalog-local-match.d.ts +39 -0
- package/lib/types/catalog-npm.d.ts +77 -0
- package/lib/types/changelog.d.ts +131 -0
- package/lib/types/channels.d.ts +56 -0
- package/lib/types/check.d.ts +381 -0
- package/lib/types/compatibility.d.ts +83 -0
- package/lib/types/crate-catalog.d.ts +48 -0
- package/lib/types/diagnostics.d.ts +29 -0
- package/lib/types/discovery-compatibility.d.ts +145 -0
- package/lib/types/drain-journal.d.ts +25 -0
- package/lib/types/drain.d.ts +306 -0
- package/lib/types/dsh-cli.d.ts +481 -0
- package/lib/types/dsh-install.d.ts +106 -0
- package/lib/types/entry-identity.d.ts +68 -0
- package/lib/types/gist.d.ts +79 -0
- package/lib/types/groups.d.ts +34 -0
- package/lib/types/home-paths.d.ts +13 -0
- package/lib/types/host-recovery.d.ts +95 -0
- package/lib/types/hot.d.ts +434 -0
- package/lib/types/http.d.ts +114 -0
- package/lib/types/index.d.ts +52 -0
- package/lib/types/install.d.ts +463 -0
- package/lib/types/lifecycle.d.ts +14 -0
- package/lib/types/log-redaction.d.ts +2 -0
- package/lib/types/log.d.ts +43 -0
- package/lib/types/ndjson.d.ts +52 -0
- package/lib/types/net.d.ts +94 -0
- package/lib/types/official-desktop.d.ts +59 -0
- package/lib/types/order.d.ts +100 -0
- package/lib/types/patch.d.ts +218 -0
- package/lib/types/pending-rows.d.ts +81 -0
- package/lib/types/pending-updates.d.ts +161 -0
- package/lib/types/pnpm-compat.d.ts +102 -0
- package/lib/types/presets.d.ts +94 -0
- package/lib/types/probe-context.d.ts +14 -0
- package/lib/types/proc-text.d.ts +29 -0
- package/lib/types/profile.d.ts +551 -0
- package/lib/types/recovery.d.ts +342 -0
- package/lib/types/region-probe.d.ts +50 -0
- package/lib/types/regions.d.ts +134 -0
- package/lib/types/registry.d.ts +160 -0
- package/lib/types/release-candidates.d.ts +42 -0
- package/lib/types/release-updates.d.ts +15 -0
- package/lib/types/restart.d.ts +279 -0
- package/lib/types/routes.d.ts +130 -0
- package/lib/types/settings.d.ts +112 -0
- package/lib/types/shelfry-catalog.d.ts +48 -0
- package/lib/types/snapshot.d.ts +93 -0
- package/lib/types/source-migration.d.ts +100 -0
- package/lib/types/sources.d.ts +391 -0
- package/lib/types/state.d.ts +20 -0
- package/lib/types/store.d.ts +47 -0
- package/lib/types/themes.d.ts +46 -0
- package/lib/types/trial.d.ts +61 -0
- package/lib/types/update-api-v1.d.ts +83 -0
- package/lib/types/updates.d.ts +273 -0
- package/lib/types/verify.d.ts +277 -0
- package/lib/update-api-v1.js +273 -0
- package/lib/updates.js +981 -0
- package/lib/verify.js +930 -0
- package/locale/en.json +5 -0
- package/locale/zh.json +6 -0
- package/package.json +113 -4
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process layer: re-invoking the dsh CLI that launched this host, spawning
|
|
3
|
+
* `dsh plugin` commands with timeouts and live progress, and provisioning
|
|
4
|
+
* pnpm. This is the only module that starts child processes.
|
|
5
|
+
*
|
|
6
|
+
* Installs run through node:child_process, not ctx.shell: the shell service is
|
|
7
|
+
* the agent's sandboxed executor and denies writes to the profile directory.
|
|
8
|
+
*/
|
|
9
|
+
import type { ChildProcess } from 'node:child_process';
|
|
10
|
+
import { type ProgressPhase } from './ndjson.ts';
|
|
11
|
+
import { type Region } from './regions.ts';
|
|
12
|
+
/**
|
|
13
|
+
* The real Node executable for spawning children. On Android the kernel runs
|
|
14
|
+
* node through the dynamic linker, so `process.execPath` is
|
|
15
|
+
* `/apex/.../linker64` — spawning IT with `--expose-internals` makes the
|
|
16
|
+
* linker treat the flag as the program path and die with
|
|
17
|
+
* `error: expected absolute path: "--expose-internals"`. `process.argv0`
|
|
18
|
+
* carries the real node binary; prefer it whenever it is an existing
|
|
19
|
+
* absolute path, and fall back to execPath everywhere else.
|
|
20
|
+
* @param argv0 - `process.argv0`, injectable for tests.
|
|
21
|
+
* @param execPath - `process.execPath`, injectable for tests.
|
|
22
|
+
*/
|
|
23
|
+
export declare function nodeExecutable(argv0?: string | undefined, execPath?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* The directory holding the Node binary running this process. `npm`,
|
|
26
|
+
* `npm.cmd` and `corepack` are installed alongside it by every official Node
|
|
27
|
+
* distribution, so it is the one place the toolchain can be looked for
|
|
28
|
+
* without guessing — and unlike a PATH entry it cannot be absent, because
|
|
29
|
+
* this process is executing out of it.
|
|
30
|
+
*
|
|
31
|
+
* #167: a Windows desktop host spawned dsh without the Node install
|
|
32
|
+
* directory on PATH. Node itself was running (v24.18.1 in the log) while
|
|
33
|
+
* both `corepack` and `npm` came back "not recognized as an internal or
|
|
34
|
+
* external command", so the one-click setup had no way to succeed.
|
|
35
|
+
*/
|
|
36
|
+
export declare const nodeBinDir: string;
|
|
37
|
+
/**
|
|
38
|
+
* Translate the machine's proxy environment into the ONE form pnpm reads.
|
|
39
|
+
*
|
|
40
|
+
* `HTTPS_PROXY` / `http_proxy` are what every other tool honours, and what
|
|
41
|
+
* `net.ts` already routes the market's own catalog fetches through — but
|
|
42
|
+
* pnpm ignores them completely. It reads npm config, so a proxy reaches it
|
|
43
|
+
* only as `npm_config_https_proxy` / `npm_config_proxy` (or an .npmrc entry,
|
|
44
|
+
* which is the user's file and not ours to rewrite).
|
|
45
|
+
*
|
|
46
|
+
* That gap is why the market could load its catalog through a proxy and
|
|
47
|
+
* then hang installing anything at all — reported four separate times
|
|
48
|
+
* (#148, #161, #188, #232), always from a network that needs one.
|
|
49
|
+
*
|
|
50
|
+
* An `npm_config_*` value the caller already set always wins: it is the more
|
|
51
|
+
* specific statement of intent, and on Windows env keys are case-insensitive
|
|
52
|
+
* so the check has to be too. NO_PROXY is forwarded verbatim because pnpm
|
|
53
|
+
* reads `npm_config_noproxy` and a host excluding its own registry mirror
|
|
54
|
+
* must keep excluding it.
|
|
55
|
+
*/
|
|
56
|
+
export declare function proxyEnvForPnpm(env?: NodeJS.ProcessEnv, region?: Region): NodeJS.ProcessEnv;
|
|
57
|
+
/**
|
|
58
|
+
* Directories to append to PATH so a spawned pnpm can be found (#32, #38,
|
|
59
|
+
* #167, #292).
|
|
60
|
+
*
|
|
61
|
+
* A GUI or desktop launch inherits none of the shell profile, so PATH holds
|
|
62
|
+
* whatever the launcher had — usually not the directory the user's package
|
|
63
|
+
* manager lives in. The market appends the places it is actually installed
|
|
64
|
+
* to rather than telling the user to fix their environment.
|
|
65
|
+
*
|
|
66
|
+
* Windows used to get only the Node directory, which made the market's own
|
|
67
|
+
* advice unfollowable: the error it prints recommends installing pnpm with
|
|
68
|
+
* `iwr https://get.pnpm.io/install.ps1`, and then it did not look where that
|
|
69
|
+
* installer puts it (#292). Both Windows layouts are covered now — the
|
|
70
|
+
* standalone installer's `%LOCALAPPDATA%\pnpm`, and `%APPDATA%\npm` where
|
|
71
|
+
* `npm i -g pnpm` writes `pnpm.cmd`.
|
|
72
|
+
*
|
|
73
|
+
* `PNPM_HOME` comes first on every platform: the installer sets it, so it is
|
|
74
|
+
* the one answer that is right even when the layout is not the default one.
|
|
75
|
+
*
|
|
76
|
+
* @param platform - `process.platform`, injectable for tests.
|
|
77
|
+
* @param env - environment, for PNPM_HOME and the Windows app-data roots.
|
|
78
|
+
* @param home - home directory, injectable for tests.
|
|
79
|
+
*/
|
|
80
|
+
export declare function toolSearchDirs(platform?: string, env?: NodeJS.ProcessEnv, home?: string): string[];
|
|
81
|
+
/**
|
|
82
|
+
* `core.sshCommand` from the user's git configuration, or null.
|
|
83
|
+
*
|
|
84
|
+
* The third place an ssh identity hides, and the one the environment cannot
|
|
85
|
+
* show: `git config --get` answers it. Memoized for the process — a user
|
|
86
|
+
* does not reconfigure git mid-install, and this runs on every spawn.
|
|
87
|
+
*
|
|
88
|
+
* @returns the configured command, or null when git has none (including
|
|
89
|
+
* when git is absent — an unreadable answer is not a choice).
|
|
90
|
+
*/
|
|
91
|
+
export declare function probeCoreSshCommand(env?: NodeJS.ProcessEnv): string | null;
|
|
92
|
+
export declare function gitEnvForPnpm(env?: NodeJS.ProcessEnv, coreSshCommand?: string | null): NodeJS.ProcessEnv;
|
|
93
|
+
/**
|
|
94
|
+
* Every `--config.<key>=<value>` override in the argv, repeated as the
|
|
95
|
+
* `PNPM_CONFIG_<KEY>` environment variable that pnpm 12 still reads.
|
|
96
|
+
*
|
|
97
|
+
* pnpm 12 ignores some `--config.<key>` overrides on the command line, in
|
|
98
|
+
* either spelling, without a word: `fetchTimeout` (#615; measured on
|
|
99
|
+
* 12.2.1, 12.3.0 and 12.4.1) and `auto-install-peers` (12.4.1 auto-installs
|
|
100
|
+
* the peer with the flag present and not with the variable), so the retries
|
|
101
|
+
* that carry them ran exactly like the first attempt. `PNPM_CONFIG_*` is
|
|
102
|
+
* honoured by 11.8, 11.21 and 12.4 alike, so the argument stays for the
|
|
103
|
+
* versions that read it and the variable carries the same value for the
|
|
104
|
+
* ones that do not. Scoped to the run that carries the flag; nothing is set
|
|
105
|
+
* otherwise, so a user's own values are untouched on every other run. Keys
|
|
106
|
+
* are accepted in either spelling, so respelling a constant (as #600 did
|
|
107
|
+
* for the release-age one) cannot silently drop the variable.
|
|
108
|
+
*/
|
|
109
|
+
export declare function pnpmConfigEnvForArgs(pluginArgs: readonly string[]): NodeJS.ProcessEnv;
|
|
110
|
+
/**
|
|
111
|
+
* Point every future child spawn at the configured build environment.
|
|
112
|
+
* @param source - Live source of the config's `buildEnv` object, re-read on
|
|
113
|
+
* every spawn so a settings change reaches the next child immediately.
|
|
114
|
+
* @returns the previous source, so a caller can restore it on teardown.
|
|
115
|
+
*/
|
|
116
|
+
export declare function setBuildEnvSource(source: () => Readonly<Record<string, string>>): () => Readonly<Record<string, string>>;
|
|
117
|
+
/**
|
|
118
|
+
* Windows npm/corepack/pnpm are `.cmd` shims. Node's `spawn` without a shell
|
|
119
|
+
* cannot start them (ENOENT / EINVAL). Same pattern as dsh's `plugin` forwarder.
|
|
120
|
+
*/
|
|
121
|
+
export declare const winCmdShim: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Quote one argv token for a cmd.exe `/c` command line. cmd only groups with
|
|
124
|
+
* double quotes, so a token that needs quoting gets wrapped and embedded
|
|
125
|
+
* quotes are doubled.
|
|
126
|
+
*/
|
|
127
|
+
export declare function quoteCmdArg(arg: string): string;
|
|
128
|
+
/**
|
|
129
|
+
* Build a cmd.exe command line from argv. Only the Windows shim path uses
|
|
130
|
+
* this: cmd re-parses the joined string, so every token is quoted before
|
|
131
|
+
* joining.
|
|
132
|
+
*/
|
|
133
|
+
export declare function cmdCommandLine(argv: readonly string[]): string;
|
|
134
|
+
/**
|
|
135
|
+
* Whether a profile name can cross the rare Windows `dsh.cmd` fallback.
|
|
136
|
+
*
|
|
137
|
+
* cmd.exe expands percent-delimited environment variables even inside a
|
|
138
|
+
* quoted argument. Keep that fallback to names made only of letters, marks,
|
|
139
|
+
* numbers, spaces, dots, underscores, and hyphens. The normal direct-Node
|
|
140
|
+
* launcher remains argv-safe and accepts every DSH-valid profile name.
|
|
141
|
+
*/
|
|
142
|
+
export declare function isCmdSafeProfileName(profile: string): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Argv re-invoking the CLI that launched this host process, so installs work
|
|
145
|
+
* whether dsh runs from a global bin, a local install, or repo source
|
|
146
|
+
* (`node --import tsx/esm .../bin.ts`). Falls back to a PATH `dsh`.
|
|
147
|
+
*/
|
|
148
|
+
export declare function dshArgv(): {
|
|
149
|
+
file: string;
|
|
150
|
+
args: string[];
|
|
151
|
+
cwd: string | undefined;
|
|
152
|
+
viaShell: boolean;
|
|
153
|
+
};
|
|
154
|
+
/** Outcome of one spawned plugin command. */
|
|
155
|
+
export interface InstallResult {
|
|
156
|
+
exitCode: number | null;
|
|
157
|
+
timedOut: boolean;
|
|
158
|
+
stdout: string;
|
|
159
|
+
stderr: string;
|
|
160
|
+
/** True when the run ended because the user cancelled it. */
|
|
161
|
+
cancelled: boolean;
|
|
162
|
+
/** Desktop's generation-wide package-operation gate rejected the start. */
|
|
163
|
+
busy?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* The host refused before it ran the package manager, so the profile is
|
|
166
|
+
* exactly as it was.
|
|
167
|
+
*
|
|
168
|
+
* The update route answers a failed run by reinstalling the previous build
|
|
169
|
+
* and, when that cannot be verified, tells the user to inspect a profile
|
|
170
|
+
* nothing touched. Desktop's manager has refusals of this kind of its own —
|
|
171
|
+
* it declines a spec it considers already installed before pnpm starts
|
|
172
|
+
* (#897) — and their only true account is "nothing happened".
|
|
173
|
+
*/
|
|
174
|
+
wroteNothing?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* The desktop manager stopped answering, and the profile may be
|
|
177
|
+
* half-updated: a removal it was asked to perform can already be on disk.
|
|
178
|
+
*
|
|
179
|
+
* The update route normally answers a failed run by restoring the previous
|
|
180
|
+
* build through the same manager. That is exactly wrong here — the manager
|
|
181
|
+
* is what stopped answering, and its profile write lock is still held — so
|
|
182
|
+
* the route leaves the profile alone and the market's journal
|
|
183
|
+
* (`src/pending-updates.ts`) finishes or undoes the removal on the next
|
|
184
|
+
* start (#928).
|
|
185
|
+
*/
|
|
186
|
+
repairOnRestart?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* The host's own refusal code, when it stopped before running pnpm.
|
|
189
|
+
*
|
|
190
|
+
* The desktop manager answers with structured codes — `already-installed`,
|
|
191
|
+
* `bundle-in-use`, `market-self-update` — but they used to survive only as
|
|
192
|
+
* text inside `stderr`. The update route forwards this to `failureCode`,
|
|
193
|
+
* so a client can tell "the market cannot update itself here" (#909) from
|
|
194
|
+
* an ordinary failure without parsing a sentence.
|
|
195
|
+
*/
|
|
196
|
+
refusalCode?: string;
|
|
197
|
+
/** Package names pnpm reported as having ignored build scripts (ndjson). */
|
|
198
|
+
ignoredBuilds?: string[];
|
|
199
|
+
/**
|
|
200
|
+
* pnpm's OWN error message and code, from its structured ndjson stream
|
|
201
|
+
* (#244).
|
|
202
|
+
*
|
|
203
|
+
* Without this the only thing a failure could report was the tail of
|
|
204
|
+
* stderr — which for a market install is dsh's wrapper line, "pnpm failed
|
|
205
|
+
* in profile directory …", identical for every possible cause. pnpm's
|
|
206
|
+
* real error never went to stderr at all; it goes to the ndjson stdout
|
|
207
|
+
* this already parses for progress, and was being thrown away on the way
|
|
208
|
+
* out. Three separate reports (#244, #192, #138) are all "the UI shows a
|
|
209
|
+
* stack tail and nothing else".
|
|
210
|
+
*/
|
|
211
|
+
pnpmError?: string;
|
|
212
|
+
pnpmErrorCode?: string;
|
|
213
|
+
/**
|
|
214
|
+
* Exact npm version this Desktop run actually handed to the host (#496).
|
|
215
|
+
*
|
|
216
|
+
* Anywhere Labs' install boundary rewrites a floating dist-tag (or bare
|
|
217
|
+
* name) to `name@x.y.z` with its own registry fetch. The update route
|
|
218
|
+
* normally pins that version itself before `add`, so this field matches
|
|
219
|
+
* the request and is unused for verification. It matters when registry
|
|
220
|
+
* metadata was unavailable and the add still carried `@latest`/`@beta`:
|
|
221
|
+
* verification then adopts this pin instead of leaving the expected
|
|
222
|
+
* version unset. When the route already sent an exact pin, callers must
|
|
223
|
+
* keep that pin authoritative and must not let this field lower it.
|
|
224
|
+
*/
|
|
225
|
+
resolvedNpmVersion?: string;
|
|
226
|
+
}
|
|
227
|
+
/** The shape every orchestration function takes to run plugin commands (injectable in tests). */
|
|
228
|
+
export type PluginRunner = (profile: string, pluginArgs: string[]) => Promise<InstallResult>;
|
|
229
|
+
/** Package-operation boundary consumed by the HTTP route layer. */
|
|
230
|
+
export interface PluginCommandRuntime {
|
|
231
|
+
runPlugin: PluginRunner;
|
|
232
|
+
probePnpm(): Promise<boolean>;
|
|
233
|
+
provisionPnpm(): Promise<{
|
|
234
|
+
ok: boolean;
|
|
235
|
+
hint?: string;
|
|
236
|
+
}>;
|
|
237
|
+
cancelActive(): boolean;
|
|
238
|
+
/** Whether this host can execute an immutable rollback add target. */
|
|
239
|
+
supportsExactRollbackTarget?(target: string): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Whether this runtime runs pnpm itself and therefore accepts the market's
|
|
242
|
+
* own arguments — `--config.*` overrides, `--force`, `--no-frozen-lockfile`.
|
|
243
|
+
*
|
|
244
|
+
* The official Electron profile does not (#732): its in-process manager
|
|
245
|
+
* takes exactly `add <target>` or `remove <target>` and answers any other
|
|
246
|
+
* argv with exit 127. Every recovery step that decorates a command with an
|
|
247
|
+
* option is impossible there, and sending it anyway turned a pnpm failure
|
|
248
|
+
* into "this desktop operation is not supported" — a message about an
|
|
249
|
+
* operation that is in fact supported, which sent the reporter looking for
|
|
250
|
+
* a broken profile instead of the option. Absent means "accepts".
|
|
251
|
+
*/
|
|
252
|
+
acceptsMarketPnpmFlags?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Whether this runtime is already running an operation of its own, so the
|
|
255
|
+
* market's next one would be refused with `busy: true` (#1140).
|
|
256
|
+
*
|
|
257
|
+
* The official Desktop manager is the case: it holds `active`/`repairing`
|
|
258
|
+
* while its own install runs for minutes, and `/dsh-crate/status` reported
|
|
259
|
+
* `busy: false` the whole time because it only knew about the market's own
|
|
260
|
+
* route flag. The client's queue then retried every 2s and re-showed the
|
|
261
|
+
* "another operation is running" banner on each refusal. Absent means
|
|
262
|
+
* "nothing else is running".
|
|
263
|
+
*/
|
|
264
|
+
busy?(): boolean;
|
|
265
|
+
}
|
|
266
|
+
/** One running package operation, however it was started. */
|
|
267
|
+
export interface DesktopPnpmHandleLike {
|
|
268
|
+
readonly stdout: NodeJS.ReadableStream;
|
|
269
|
+
readonly stderr: NodeJS.ReadableStream;
|
|
270
|
+
readonly done: Promise<{
|
|
271
|
+
readonly exitCode: number | null;
|
|
272
|
+
readonly signal: NodeJS.Signals | null;
|
|
273
|
+
}>;
|
|
274
|
+
cancel(): void;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Structural subset of DSH Desktop's public `desktopPnpm` contract.
|
|
278
|
+
*
|
|
279
|
+
* Anywhere Labs' DSH Desktop is ONE third-party client among several, and
|
|
280
|
+
* this interface exists only for it. Nothing here is part of the official
|
|
281
|
+
* DSH protocol — `desktopPnpm`, `installPlugin` and the install boundary
|
|
282
|
+
* below appear nowhere in `@deepseek-ai/*`. Every other client the market
|
|
283
|
+
* runs under, including other desktop apps, installs through the ordinary
|
|
284
|
+
* `dsh plugin --profile <p> add` CLI, and so does the market itself when
|
|
285
|
+
* none of these services are present.
|
|
286
|
+
*
|
|
287
|
+
* That is why every member past `runPlugin` is optional and reached by
|
|
288
|
+
* feature detection. A host that does not publish one simply never enters
|
|
289
|
+
* the branch, and the ordinary path it already used stays untouched — the
|
|
290
|
+
* cost of accommodating one vendor must not be paid by the others, or by
|
|
291
|
+
* the far larger number of people on plain `dsh web`.
|
|
292
|
+
*/
|
|
293
|
+
export interface DesktopPnpmLike {
|
|
294
|
+
runPlugin(args: readonly string[], invokingDir: string, signal?: AbortSignal): DesktopPnpmHandleLike;
|
|
295
|
+
/**
|
|
296
|
+
* Desktop 2.x refuses `add` through `runPlugin` — "plugin add must use the
|
|
297
|
+
* recoverable install boundary" (#215, #219, #272) — and offers this
|
|
298
|
+
* instead, which their launcher enables only for the selected market
|
|
299
|
+
* provider. Same arguments, same handle, no recovery receipt and no
|
|
300
|
+
* write-ahead log for the caller to reconcile.
|
|
301
|
+
*
|
|
302
|
+
* Optional because it is theirs: absent on every other host, including
|
|
303
|
+
* the other third-party desktop client in #292, which installs perfectly
|
|
304
|
+
* well through the ordinary CLI.
|
|
305
|
+
*
|
|
306
|
+
* Read from their published source rather than assumed: it accepts ONLY
|
|
307
|
+
* `add` with exactly one target of the form `name@exact.version`
|
|
308
|
+
* (`validateExternalMarketInstallArgs` in dsh-plugin-desktop/src/pnpm.ts).
|
|
309
|
+
* A `github:owner/repo` target is rejected before any process starts, so
|
|
310
|
+
* the 1085 catalog entries with no npm package — 57% of it — cannot be
|
|
311
|
+
* installed on that host by any spelling this market could send. That is
|
|
312
|
+
* a gap in their contract, not something to work around here.
|
|
313
|
+
*/
|
|
314
|
+
runExternalMarketPluginInstall?(args: readonly string[], invokingDir: string, signal?: AbortSignal): DesktopPnpmHandleLike;
|
|
315
|
+
}
|
|
316
|
+
/** Desktop runtime also owns cleanup of any operation started by this fiber. */
|
|
317
|
+
export interface DesktopPluginRuntime extends PluginCommandRuntime {
|
|
318
|
+
dispose(): Promise<void>;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Kill a spawned child and, on Windows, its whole process tree — `kill()`
|
|
322
|
+
* there only terminates the wrapper, leaving pnpm children running.
|
|
323
|
+
* (Contributed in #7 by @mraing.)
|
|
324
|
+
*/
|
|
325
|
+
export declare function killChild(child: ChildProcess): void;
|
|
326
|
+
/**
|
|
327
|
+
* Remove the profile's `package.json.lock` when it is provably ours (#914).
|
|
328
|
+
*
|
|
329
|
+
* The dsh CLI writes that lock through the host's atomic-write, whose
|
|
330
|
+
* `finally` releases it. A timeout kills the whole tree with `taskkill /F`,
|
|
331
|
+
* so that release never runs and the file outlives the child — and on
|
|
332
|
+
* Windows the host cannot reliably tell a dead PID from a live one, so every
|
|
333
|
+
* later change waits the full lock timeout and fails.
|
|
334
|
+
*
|
|
335
|
+
* Only a lock naming OUR killed child is removed: that PID is provably dead
|
|
336
|
+
* because we just killed its whole tree, and it cannot belong to another
|
|
337
|
+
* operation. A lock naming anything else is left for the classifier to name
|
|
338
|
+
* (#914), because deleting a live operation's lock would race it.
|
|
339
|
+
*/
|
|
340
|
+
export declare function clearOwnedProfileLock(profile: string, pid: number | undefined): boolean;
|
|
341
|
+
/**
|
|
342
|
+
* Cancel the plugin command currently running.
|
|
343
|
+
* @returns true when there was one to cancel.
|
|
344
|
+
*/
|
|
345
|
+
export declare function cancelActive(): boolean;
|
|
346
|
+
/**
|
|
347
|
+
* The package manager the host itself supplies, as the launcher hands it
|
|
348
|
+
* over (`profileContext.packageManager`).
|
|
349
|
+
*
|
|
350
|
+
* This is not a PATH executable. A packaged host ships its own runtime and
|
|
351
|
+
* describes it as a whole invocation — command, args AND env — because each
|
|
352
|
+
* part carries meaning: the desktop host passes the location of its embedded
|
|
353
|
+
* Node through `env`, so an implementation that keeps only `command` reaches
|
|
354
|
+
* a tool it still cannot execute, which is the reported failure (#653).
|
|
355
|
+
*/
|
|
356
|
+
export interface HostPackageManager {
|
|
357
|
+
readonly command: string;
|
|
358
|
+
readonly args: readonly string[];
|
|
359
|
+
readonly env: NodeJS.ProcessEnv;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Register the host's package manager for this process, or clear it with
|
|
363
|
+
* `null`. Cached probe answers are dropped only when the invocation really
|
|
364
|
+
* changes, so a repeated mount does not re-probe a toolchain that works.
|
|
365
|
+
*/
|
|
366
|
+
export declare function setHostPackageManager(invocation: HostPackageManager | null): void;
|
|
367
|
+
/** The host-supplied package manager, for callers that must name it. */
|
|
368
|
+
export declare function hostPackageManagerInvocation(): HostPackageManager | null;
|
|
369
|
+
/** Why the host-supplied package manager last failed, or null. */
|
|
370
|
+
export declare function lastHostPackageManagerFailure(): {
|
|
371
|
+
command: string;
|
|
372
|
+
output: string;
|
|
373
|
+
} | null;
|
|
374
|
+
/** Why `pnpm --version` last failed, or null when it has not failed. */
|
|
375
|
+
export declare function lastPnpmProbeFailure(): {
|
|
376
|
+
kind: 'missing' | 'failed';
|
|
377
|
+
output: string;
|
|
378
|
+
} | null;
|
|
379
|
+
/**
|
|
380
|
+
* Whether a package manager is usable — the host-supplied one first.
|
|
381
|
+
*
|
|
382
|
+
* The tiers are ordered by what the machine can actually run: a packaged
|
|
383
|
+
* host's bundled runtime exists whether or not PATH was inherited from a
|
|
384
|
+
* shell, and on the reported machine only that tier can work at all (#653).
|
|
385
|
+
* A host tier that fails falls through to the PATH probe, so a host that
|
|
386
|
+
* publishes a broken invocation cannot make things worse than they were.
|
|
387
|
+
*/
|
|
388
|
+
export declare function probePnpm(): Promise<boolean>;
|
|
389
|
+
/**
|
|
390
|
+
* Provision pnpm without user involvement: corepack (ships with Node) first,
|
|
391
|
+
* a global npm install as fallback.
|
|
392
|
+
* @returns true when `pnpm --version` succeeds afterwards.
|
|
393
|
+
*/
|
|
394
|
+
export declare function provisionPnpm(): Promise<{
|
|
395
|
+
ok: boolean;
|
|
396
|
+
hint?: string;
|
|
397
|
+
}>;
|
|
398
|
+
/**
|
|
399
|
+
* Whether a bare command name resolves to a file on the PATH the market
|
|
400
|
+
* hands its children.
|
|
401
|
+
*
|
|
402
|
+
* The market cannot read the reason a spawn failed out of the child's
|
|
403
|
+
* message: cmd.exe reports a missing command in the console's ANSI codepage
|
|
404
|
+
* ("'npm' 不是内部或外部命令" on a Chinese Windows), which is neither the
|
|
405
|
+
* string `ENOENT` nor even valid UTF-8 — so the #32 hint, written against
|
|
406
|
+
* Node's own ENOENT wording, could never fire on Windows and the user was
|
|
407
|
+
* left with no guidance at all (#167). Looking on disk answers the same
|
|
408
|
+
* question in every locale.
|
|
409
|
+
*/
|
|
410
|
+
export declare function toolOnPath(name: string): boolean;
|
|
411
|
+
/**
|
|
412
|
+
* Why the one-click pnpm setup failed, in terms the user can act on.
|
|
413
|
+
*
|
|
414
|
+
* Every one of these was a real report where the market said only "自动准备
|
|
415
|
+
* 没成功" while the log held the actual cause: EEXIST (#142 — corepack had
|
|
416
|
+
* already placed a pnpm shim, so `npm -g` refused to overwrite it), EPERM
|
|
417
|
+
* (#108 — Node installed somewhere the user cannot write), ENOENT (#32 —
|
|
418
|
+
* a GUI launch with no Node on PATH at all).
|
|
419
|
+
* @returns a bilingual, actionable hint, or undefined when unrecognized.
|
|
420
|
+
*/
|
|
421
|
+
export declare function provisionHint(corepackOutput: string, npmOutput: string, npmFound?: boolean, probeFailure?: {
|
|
422
|
+
kind: 'missing' | 'failed';
|
|
423
|
+
output: string;
|
|
424
|
+
} | null): string | undefined;
|
|
425
|
+
/** Live progress of the running plugin command, for the status route. */
|
|
426
|
+
export interface InstallProgress {
|
|
427
|
+
active: boolean;
|
|
428
|
+
target: string;
|
|
429
|
+
startedAt: number;
|
|
430
|
+
lastLine: string;
|
|
431
|
+
/** Parsed from pnpm's ndjson stage events; null when none arrived. */
|
|
432
|
+
phase: ProgressPhase;
|
|
433
|
+
/** Distinct packages resolved/fetched so far. */
|
|
434
|
+
done: number;
|
|
435
|
+
total: number | null;
|
|
436
|
+
currentPackage: string | null;
|
|
437
|
+
downloaded: number | null;
|
|
438
|
+
size: number | null;
|
|
439
|
+
/** True when structured ndjson progress has been observed. */
|
|
440
|
+
ndjson: boolean;
|
|
441
|
+
/** Last fatal error from the stream (only meaningful after a failure). */
|
|
442
|
+
error: string | null;
|
|
443
|
+
/** True from the moment the user asks to cancel until the run ends. */
|
|
444
|
+
cancelling: boolean;
|
|
445
|
+
}
|
|
446
|
+
/** Singleton progress state; the status route reads it, runDshPlugin writes it. */
|
|
447
|
+
export declare const progress: InstallProgress;
|
|
448
|
+
/** Identifies this host process; the client scopes its pending-restart flags to it. */
|
|
449
|
+
export declare const BOOT_ID: string;
|
|
450
|
+
/**
|
|
451
|
+
* Central allowlist for every spawn target, regardless of which route built
|
|
452
|
+
* it (defense in depth on top of per-route validation — the win32 bare-dsh
|
|
453
|
+
* fallback runs through a shell). Suggested in #16 by @anupamme.
|
|
454
|
+
*
|
|
455
|
+
* `^`, `~` and `=` are intentionally allowed: restore/install flows turn
|
|
456
|
+
* manifest specs such as "dsh-better-sidebar": "^0.14.0" into targets like
|
|
457
|
+
* `dsh-better-sidebar@^0.14.0`, and regex-valid semver ranges must not be
|
|
458
|
+
* mistaken for shell injection (whitespace and shell metacharacters remain
|
|
459
|
+
* rejected — the win32 bare-dsh fallback is the reason to keep them out).
|
|
460
|
+
*/
|
|
461
|
+
export declare const TARGET_RE: RegExp;
|
|
462
|
+
/**
|
|
463
|
+
* Run the host-supplied package manager in a profile directory.
|
|
464
|
+
*
|
|
465
|
+
* Official Desktop publishes this invocation on `profileContext` and uses it
|
|
466
|
+
* for every managed install. The market's official branch must not send
|
|
467
|
+
* `dsh plugin --profile desktop`, and must not go through the manager for the
|
|
468
|
+
* market's own package (#900). This is that remaining door: `pnpm add` (or
|
|
469
|
+
* whatever argv the caller names) against the bundled Node, with the
|
|
470
|
+
* invocation's own env. Callers must not add `--config.minimum-release-age=0`
|
|
471
|
+
* here — that is the #944 lockfile write.
|
|
472
|
+
*/
|
|
473
|
+
export declare function runHostPnpm(invocation: HostPackageManager, cwd: string, args: readonly string[]): Promise<InstallResult>;
|
|
474
|
+
/** Run one `dsh plugin --profile <p> …` command with timeout and progress tracking. */
|
|
475
|
+
export declare function runDshPlugin(profile: string, pluginArgs: string[]): Promise<InstallResult>;
|
|
476
|
+
/**
|
|
477
|
+
* Adapt DSH Desktop's generation-scoped package manager to the existing
|
|
478
|
+
* market runner. There is no runtime import or dependency on Desktop: the
|
|
479
|
+
* Host supplies this public service only when the package is mounted there.
|
|
480
|
+
*/
|
|
481
|
+
export declare function createDesktopPluginRuntime(service: DesktopPnpmLike, activeProfileDir: string, invokingDir?: string, timeoutMs?: number): DesktopPluginRuntime;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** Locate the DSH host package in CLI and packaged Desktop runtimes. */
|
|
2
|
+
/** Where the host package was found, and the version its manifest declares. */
|
|
3
|
+
export interface DshHostInfo {
|
|
4
|
+
version: string;
|
|
5
|
+
directory: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Directories that can hold the DSH installation's OWN bundle layer — the
|
|
9
|
+
* Desktop shell's package root and its `cordis.patch.yml`.
|
|
10
|
+
*
|
|
11
|
+
* The shell applies that file itself rather than declaring it through
|
|
12
|
+
* `dsh.profile.bundles`: dsh-plugin-desktop's launcher loads it by hand and
|
|
13
|
+
* splices it in directly behind the `@deepseek-ai/dsh-web-app` layer
|
|
14
|
+
* (`src/profile.ts`, `DESKTOP_PATCH_PATH`), which is where the rows
|
|
15
|
+
* `desktop-shell`, `desktop-notifications`, `desktop-terminal` and the rest
|
|
16
|
+
* come from at all.
|
|
17
|
+
*
|
|
18
|
+
* Its package root is NOT where {@link findDshInstallDir} points. On the
|
|
19
|
+
* official Desktop the market's `desktopProfiles` branch hands the analysis no
|
|
20
|
+
* install dir at all, and the directory the lookup does answer with is
|
|
21
|
+
* `node_modules/@deepseek-ai/dsh` — whose own manifest declares no bundle
|
|
22
|
+
* patch. So the application root is offered from the two directions the host
|
|
23
|
+
* lookup already knows, and the caller reads each candidate's own manifest:
|
|
24
|
+
*
|
|
25
|
+
* - the located install package's ancestors:
|
|
26
|
+
* `<app>/node_modules/@deepseek-ai/dsh` walks up to `<app>`;
|
|
27
|
+
* - Electron's resources directory under each application-root name — which
|
|
28
|
+
* is the same directory {@link findDshInstallDir} probes for the in-box
|
|
29
|
+
* bundles, one level up.
|
|
30
|
+
*
|
|
31
|
+
* This is the layering #405 fixed one level down: the in-box bundles are read
|
|
32
|
+
* from that application root, and the shell's own overlay file lives beside
|
|
33
|
+
* them.
|
|
34
|
+
*
|
|
35
|
+
* @param dshInstallDir - install directory to walk up from, when one is known.
|
|
36
|
+
* @returns candidate directories, most specific first, duplicates removed.
|
|
37
|
+
*/
|
|
38
|
+
export declare function desktopApplicationRoots(dshInstallDir: string | null): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Point host detection at the install anchor the launcher published.
|
|
41
|
+
* @param source - live source of `profileContext.installAnchor`, re-read on
|
|
42
|
+
* every lookup; it answers null when the host publishes no anchor.
|
|
43
|
+
* @returns the previous source, so a caller can restore it on teardown.
|
|
44
|
+
*/
|
|
45
|
+
export declare function setLauncherInstallAnchorSource(source: () => string | null): () => string | null;
|
|
46
|
+
/**
|
|
47
|
+
* Host info read from the anchor a launcher published.
|
|
48
|
+
*
|
|
49
|
+
* An embedded host — a packaged app that boots the dsh core tree in-process
|
|
50
|
+
* instead of exec'ing the CLI — is neither layout {@link dshHostInfo} probes:
|
|
51
|
+
* `process.argv[1]` is the app's own entry point, and there is no Electron
|
|
52
|
+
* resources directory. Its launcher still knows where the runtime lives and
|
|
53
|
+
* publishes that as `profileContext.installAnchor`, normally the dsh
|
|
54
|
+
* package's own `package.json` — the very file the CLI probe would have read.
|
|
55
|
+
* The same identity check applies, and an anchor that names a flat Desktop
|
|
56
|
+
* root still has to corroborate its version with the in-box runtime: an
|
|
57
|
+
* anchor is a place to look, not a thing to trust.
|
|
58
|
+
*
|
|
59
|
+
* @param anchor - the published anchor path, or null/undefined when none was.
|
|
60
|
+
* @returns the host info, or null when the anchor names no dsh host.
|
|
61
|
+
*/
|
|
62
|
+
export declare function hostInfoFromAnchor(anchor: string | null | undefined): DshHostInfo | null;
|
|
63
|
+
/**
|
|
64
|
+
* The version of the DSH host this market is running inside.
|
|
65
|
+
*
|
|
66
|
+
* CLI versions come from the host manifest. Flat Desktop shells additionally
|
|
67
|
+
* require agreement with their bundled split runtime, never profile packages.
|
|
68
|
+
*
|
|
69
|
+
* Worth reporting because the host version has repeatedly been the thing
|
|
70
|
+
* neither side could see. #293 turned on it (the reporter was on
|
|
71
|
+
* 0.1.1-rc.2 while every attempt to reproduce had been on 0.1.0-rc.8, which
|
|
72
|
+
* nobody knew until three rounds in), and #404 is entirely about a plugin
|
|
73
|
+
* that requires a host newer than the Desktop build it was installed on.
|
|
74
|
+
*
|
|
75
|
+
* The directory comes back too, because WHERE it was found is the other half
|
|
76
|
+
* of the answer: a path under Electron's resources is a Desktop-bundled host,
|
|
77
|
+
* which #139 established can be older than whatever `npm ls` would report.
|
|
78
|
+
* Asking the user is not a substitute — that is the number they do not have.
|
|
79
|
+
* When both layouts miss — an embedded host has neither — the launcher's
|
|
80
|
+
* published install anchor is tried last ({@link hostInfoFromAnchor}).
|
|
81
|
+
* @returns the host version and the directory it was read from, or null when
|
|
82
|
+
* no host package is locatable (a plain `dsh web` from a global install can
|
|
83
|
+
* legitimately land here).
|
|
84
|
+
*/
|
|
85
|
+
export declare function dshHostInfo(entry?: string): DshHostInfo | null;
|
|
86
|
+
/**
|
|
87
|
+
* Walk up from the CLI entry first, then inspect Electron's authoritative
|
|
88
|
+
* resources directory. Desktop distributions may keep node_modules outside
|
|
89
|
+
* the ASAR, expose them through ASAR's virtual filesystem, or disable ASAR.
|
|
90
|
+
*
|
|
91
|
+
* The entry is resolved through symlinks before the walk, because for a
|
|
92
|
+
* globally installed dsh it IS one. `npm i -g` and Homebrew both put a link
|
|
93
|
+
* in a `bin/` directory pointing at the real package, so `process.argv[1]`
|
|
94
|
+
* is `/opt/homebrew/bin/dsh` and walking up from there reaches `/` without
|
|
95
|
+
* ever passing the package. Measured: the same call answers `null` for the
|
|
96
|
+
* link and the correct directory for its target.
|
|
97
|
+
*
|
|
98
|
+
* That was not a cosmetic gap. Everything downstream reads the host version
|
|
99
|
+
* from here — the exported log's `dsh host:` line (#426), Discover's
|
|
100
|
+
* host-requirement column and filter (#473), and the pre-update check
|
|
101
|
+
* (#404) — and a null version makes every one of them answer "unknown",
|
|
102
|
+
* silently, on exactly the ordinary global install. A bundled Desktop host
|
|
103
|
+
* is reached by the resources branch below and was never affected, which is
|
|
104
|
+
* why this survived: the case that worked is the one that gets tested.
|
|
105
|
+
*/
|
|
106
|
+
export declare function findDshInstallDir(entry?: string): string | null;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which loader entry belongs to which installed package (#646).
|
|
3
|
+
*
|
|
4
|
+
* The ecosystem does not require a bundle patch's row `name:` to be the
|
|
5
|
+
* package name. Two shapes are ordinary:
|
|
6
|
+
*
|
|
7
|
+
* - id: aegis-method-pack
|
|
8
|
+
* name: aegis/extensions/dsh/index.js ← a SUBPATH inside the package
|
|
9
|
+
* - id: filesystem
|
|
10
|
+
* name: @deepseek-ai/dsh-skill-filesystem ← another package entirely
|
|
11
|
+
*
|
|
12
|
+
* `dsh-chat-import`, `meow-memory` and `dsh-context` all name themselves, so
|
|
13
|
+
* the simple `name === packageName` comparison worked for years. `aegis`
|
|
14
|
+
* names an entry inside itself, and every site that compared the two
|
|
15
|
+
* directly concluded the plugin had no entry — the market reported "no
|
|
16
|
+
* bundle patch … nothing to hot-mount" on enable (#646) and could not see
|
|
17
|
+
* the entry was already live.
|
|
18
|
+
*
|
|
19
|
+
* Three such sites had grown independently (`src/themes.ts`, `src/verify.ts`,
|
|
20
|
+
* `src/routes.ts`), each restating the rule from memory. That is the shape
|
|
21
|
+
* the identity bugs #485→#605 came from: one assumption, several copies,
|
|
22
|
+
* each fixed at a different time. The rule lives here now, once.
|
|
23
|
+
*
|
|
24
|
+
* The carrier case (#156) is NOT decided here. A bundle that mounts someone
|
|
25
|
+
* else's package has no name relation at all, and is recognised by the entry
|
|
26
|
+
* ID its own patch inserts — see `bundlePatchInsertedIds`. The two rules
|
|
27
|
+
* compose; neither replaces the other.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Whether a loader entry name refers to `packageName`.
|
|
31
|
+
*
|
|
32
|
+
* The `/` bound is load-bearing: without it `toolshrink` would match an
|
|
33
|
+
* entry named `toolshrink-extra`, a different installed package.
|
|
34
|
+
*
|
|
35
|
+
* @param name - an entry's `options.name`, in any shape.
|
|
36
|
+
* @param packageName - the installed package name to match against.
|
|
37
|
+
* @returns true for the bare name and for a subpath entry inside it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function nameMatchesPackage(name: unknown, packageName: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The same rule for a loader entry object.
|
|
42
|
+
*
|
|
43
|
+
* @param entry - anything with `options.name`, as the host's loader stores it.
|
|
44
|
+
* @param packageName - the installed package name to match against.
|
|
45
|
+
* @returns whether this entry is the one `packageName` refers to.
|
|
46
|
+
*/
|
|
47
|
+
export declare function entryMatchesPackage(entry: {
|
|
48
|
+
options?: {
|
|
49
|
+
name?: unknown;
|
|
50
|
+
};
|
|
51
|
+
}, packageName: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The package a subpath entry name belongs to — `aegis/x/y.js` → `aegis`.
|
|
54
|
+
*
|
|
55
|
+
* The inverse of {@link nameMatchesPackage}, for building a set of live
|
|
56
|
+
* packages from a set of live entry names: an entry that is up proves its
|
|
57
|
+
* package is up, and its name alone does not say so.
|
|
58
|
+
*
|
|
59
|
+
* Names that are not npm package names return null rather than a guess: a
|
|
60
|
+
* relative path, an absolute path, a URL or a cordis builtin would otherwise
|
|
61
|
+
* "belong to" a package that does not exist, which is worse than no answer.
|
|
62
|
+
* A scoped name needs three segments (`@scope/pkg/sub`) to have a subpath at
|
|
63
|
+
* all, and a lone `@scope/pkg` has no package to return.
|
|
64
|
+
*
|
|
65
|
+
* @param name - an entry's `options.name`.
|
|
66
|
+
* @returns the package name, or null when the name cannot imply one.
|
|
67
|
+
*/
|
|
68
|
+
export declare function packageOfEntryName(name: string): string | null;
|