dsh-crate 0.5.4 → 0.5.6
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/client/client.js +1832 -617
- package/lib/changelog.js +71 -28
- package/lib/gist.js +1 -1
- package/lib/hot.js +18 -6
- package/lib/index.js +10 -3
- package/lib/install.js +200 -9
- package/lib/official-desktop.js +80 -16
- package/lib/patch.js +223 -25
- package/lib/pending-checkout-links.js +123 -0
- package/lib/pending-updates.js +7 -4
- package/lib/profile.js +36 -0
- package/lib/registry.js +53 -22
- package/lib/release-blockers.js +177 -0
- package/lib/release-history.js +149 -0
- package/lib/release-updates.js +1 -34
- package/lib/routes.js +843 -166
- package/lib/sources.js +42 -2
- package/lib/startup-repair-report.js +46 -0
- package/lib/themes.js +7 -5
- package/lib/types/changelog.d.ts +4 -1
- package/lib/types/dsh-cli.d.ts +8 -0
- package/lib/types/gist.d.ts +1 -1
- package/lib/types/hot.d.ts +2 -1
- package/lib/types/install.d.ts +22 -4
- package/lib/types/official-desktop.d.ts +4 -0
- package/lib/types/patch.d.ts +36 -0
- package/lib/types/pending-checkout-links.d.ts +35 -0
- package/lib/types/pending-updates.d.ts +2 -0
- package/lib/types/profile.d.ts +3 -0
- package/lib/types/registry.d.ts +6 -8
- package/lib/types/release-blockers.d.ts +34 -0
- package/lib/types/release-history.d.ts +34 -0
- package/lib/types/release-updates.d.ts +2 -11
- package/lib/types/routes.d.ts +3 -0
- package/lib/types/sources.d.ts +11 -0
- package/lib/types/startup-repair-report.d.ts +20 -0
- package/lib/types/themes.d.ts +2 -2
- package/lib/types/update-notifications.d.ts +6 -0
- package/lib/types/updates.d.ts +19 -0
- package/lib/update-notifications.js +6 -4
- package/lib/updates.js +16 -0
- package/locale/en.json +1 -1
- package/locale/ja.json +5 -0
- package/package.json +2 -2
package/lib/sources.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* installable pnpm target. Pure string logic, no I/O.
|
|
4
4
|
*/
|
|
5
5
|
const REPO_RE = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
|
|
6
|
+
const MARKET_REPO = 'dsh-crate/dsh-crate';
|
|
7
|
+
const MARKET_NPM_NAME = 'dsh-crate';
|
|
6
8
|
function validSubpath(subpath) {
|
|
7
9
|
if (!/^[A-Za-z0-9_./-]+$/.test(subpath))
|
|
8
10
|
return false;
|
|
@@ -505,8 +507,13 @@ export function installTargetFor(entry) {
|
|
|
505
507
|
const source = parseSourceUrl(entry.url);
|
|
506
508
|
if (source === null)
|
|
507
509
|
return null;
|
|
508
|
-
//
|
|
509
|
-
//
|
|
510
|
+
// The market manages its own installation and is published to npm. Keep
|
|
511
|
+
// legacy catalog snapshots and self-update requests on that prebuilt
|
|
512
|
+
// registry package even when the entry has not yet gained its generated
|
|
513
|
+
// `npm` mapping; installing the repository URL runs its `prepare` script
|
|
514
|
+
// before the market can show the build-approval UI.
|
|
515
|
+
if (source.subpath === null && source.repo.toLowerCase() === MARKET_REPO)
|
|
516
|
+
return MARKET_NPM_NAME;
|
|
510
517
|
if (typeof entry.npm === 'string' && NPM_NAME_RE.test(entry.npm))
|
|
511
518
|
return entry.npm;
|
|
512
519
|
const tarball = releaseTarballTarget(entry.tarball, source.repo);
|
|
@@ -514,6 +521,39 @@ export function installTargetFor(entry) {
|
|
|
514
521
|
return tarball;
|
|
515
522
|
return githubSourceTarget(source);
|
|
516
523
|
}
|
|
524
|
+
/** Only the catalog's own floating asset opts an existing archive into updates. */
|
|
525
|
+
export function catalogReleaseSourceOf(spec, entry) {
|
|
526
|
+
if (entry.npm !== null && entry.npm !== undefined)
|
|
527
|
+
return null;
|
|
528
|
+
const source = parseSourceUrl(entry.url);
|
|
529
|
+
if (source === null || typeof entry.tarball !== 'string' || installTargetFor(entry) !== entry.tarball)
|
|
530
|
+
return null;
|
|
531
|
+
try {
|
|
532
|
+
const approved = new URL(entry.tarball);
|
|
533
|
+
const installed = new URL(spec);
|
|
534
|
+
const asset = /^\/[^/]+\/[^/]+\/releases\/latest\/download\/([A-Za-z0-9._-]+\.(?:tgz|tar\.gz))$/.exec(approved.pathname)?.[1];
|
|
535
|
+
if (asset === undefined)
|
|
536
|
+
return null;
|
|
537
|
+
for (const url of [approved, installed]) {
|
|
538
|
+
if (url.protocol !== 'https:' || url.host !== 'github.com' || url.username !== '' || url.password !== '' || url.search !== '' || url.hash !== '')
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
const match = /^\/([^/]+\/[^/]+)\/releases\/(?:latest\/download|download\/([^/]+))\/([^/]+)$/.exec(installed.pathname);
|
|
542
|
+
if (match === null || match[1].toLowerCase() !== source.repo.toLowerCase())
|
|
543
|
+
return null;
|
|
544
|
+
const [, , tag, installedAsset] = match;
|
|
545
|
+
if (installedAsset !== asset) {
|
|
546
|
+
// A legacy filename can only add the version from its own stable release tag.
|
|
547
|
+
const version = /^v?(\d+\.\d+\.\d+)$/.exec(tag ?? '')?.[1];
|
|
548
|
+
if (version === undefined || installedAsset !== asset.replace(/\.(?:tgz|tar\.gz)$/, extension => `-${version}${extension}`))
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
return { repo: source.repo, asset, manifest: source.subpath === null ? 'package.json' : `${source.subpath}/package.json` };
|
|
552
|
+
}
|
|
553
|
+
catch {
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
517
557
|
function githubSourceTarget(source) {
|
|
518
558
|
return source.subpath !== null
|
|
519
559
|
? `github:${source.repo}#path:/${source.subpath}`
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { NPM_NAME_RE } from './sources.js';
|
|
4
|
+
// The host can unload and evaluate the market module again during a repair.
|
|
5
|
+
const REPORTS = Symbol.for('dsh-crate.startup-update-repair-reports');
|
|
6
|
+
function entriesOf(report) {
|
|
7
|
+
const abandoned = new Set(report.abandoned);
|
|
8
|
+
return [
|
|
9
|
+
...report.reinstalled.map(name => ({ name, state: 'reinstalled' })),
|
|
10
|
+
...report.finished.map(name => ({ name, state: 'verified' })),
|
|
11
|
+
...report.failed.filter(({ name }) => !abandoned.has(name))
|
|
12
|
+
.map(({ name, cause }) => ({ name, cause, state: 'pending' })),
|
|
13
|
+
...report.abandoned.map(name => ({ name, state: 'abandoned' })),
|
|
14
|
+
].filter(({ name }) => NPM_NAME_RE.test(name));
|
|
15
|
+
}
|
|
16
|
+
/** Track what the existing startup repair found, without owning any package writes. */
|
|
17
|
+
export function observeStartupRepair(profile, directory) {
|
|
18
|
+
const global = globalThis;
|
|
19
|
+
const reports = global[REPORTS] ??= new Map();
|
|
20
|
+
const absolute = resolve(directory);
|
|
21
|
+
const key = JSON.stringify([profile, process.platform === 'win32' ? absolute.toLowerCase() : absolute]);
|
|
22
|
+
const state = reports.get(key) ?? { id: randomUUID(), revision: 0, outstanding: new Set(), entries: new Map() };
|
|
23
|
+
reports.set(key, state);
|
|
24
|
+
const attempt = ++state.revision;
|
|
25
|
+
state.outstanding.add(attempt);
|
|
26
|
+
return {
|
|
27
|
+
read: () => ({
|
|
28
|
+
id: state.id,
|
|
29
|
+
revision: state.revision,
|
|
30
|
+
checking: state.outstanding.size > 0,
|
|
31
|
+
entries: [...state.entries.values()].map(({ entry }) => entry),
|
|
32
|
+
}),
|
|
33
|
+
finish: report => {
|
|
34
|
+
if (!state.outstanding.delete(attempt))
|
|
35
|
+
return;
|
|
36
|
+
state.revision += 1;
|
|
37
|
+
if (report === undefined)
|
|
38
|
+
return;
|
|
39
|
+
for (const entry of entriesOf(report)) {
|
|
40
|
+
const previous = state.entries.get(entry.name);
|
|
41
|
+
if (previous === undefined || previous.attempt <= attempt)
|
|
42
|
+
state.entries.set(entry.name, { attempt, entry });
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
package/lib/themes.js
CHANGED
|
@@ -204,7 +204,7 @@ export function createThemeManager(host, profile, disabledThemes, explicitDir) {
|
|
|
204
204
|
*
|
|
205
205
|
* @returns true when a matching live entry was found and updated.
|
|
206
206
|
*/
|
|
207
|
-
async function setEntryDisabled(name, disabledFlag, requireLive = false, rejectPending = false) {
|
|
207
|
+
async function setEntryDisabled(name, disabledFlag, requireLive = false, rejectPending = false, keepOff) {
|
|
208
208
|
const previous = [];
|
|
209
209
|
try {
|
|
210
210
|
let found = false;
|
|
@@ -231,9 +231,11 @@ export function createThemeManager(host, profile, disabledThemes, explicitDir) {
|
|
|
231
231
|
? null
|
|
232
232
|
: new Set(bundleExpressionRowIds(join(activeProfileDir, 'node_modules', name)));
|
|
233
233
|
for (const entry of matchingEntries(name)) {
|
|
234
|
-
if (expressionIds !== null && expressionIds.has(entry
|
|
234
|
+
if (expressionIds !== null && expressionIds.has(loaderEntryId(entry)))
|
|
235
235
|
continue;
|
|
236
236
|
matched = true;
|
|
237
|
+
if (!disabledFlag && keepOff?.has(loaderEntryId(entry).split(':').at(-1) ?? ''))
|
|
238
|
+
continue;
|
|
237
239
|
if (!disabledFlag && uncertainEntries.has(entry)) {
|
|
238
240
|
throw new LifecycleWaitError('loader entry: runtime state is uncertain; retry disabling before enabling');
|
|
239
241
|
}
|
|
@@ -328,7 +330,7 @@ export function createThemeManager(host, profile, disabledThemes, explicitDir) {
|
|
|
328
330
|
* theme keeps neither: it never came up, and leaving it out of the disable
|
|
329
331
|
* set is what lets the next attempt try it again.
|
|
330
332
|
*/
|
|
331
|
-
async function activateTheme(name) {
|
|
333
|
+
async function activateTheme(name, keepOff) {
|
|
332
334
|
const stopFailedMount = async (theme) => !listHotMounts().includes(theme) || await hotUnmount(theme);
|
|
333
335
|
const themes = await installedThemeNames();
|
|
334
336
|
const stopped = [];
|
|
@@ -354,9 +356,9 @@ export function createThemeManager(host, profile, disabledThemes, explicitDir) {
|
|
|
354
356
|
return { ok: true };
|
|
355
357
|
}
|
|
356
358
|
else {
|
|
357
|
-
if (await setEntryDisabled(name, false))
|
|
359
|
+
if (await setEntryDisabled(name, false, false, false, keepOff))
|
|
358
360
|
return { ok: true };
|
|
359
|
-
const mount = await hotMount(host, activeProfileDir, name);
|
|
361
|
+
const mount = await hotMount(host, activeProfileDir, name, keepOff);
|
|
360
362
|
if (mount.ok)
|
|
361
363
|
return { ok: true };
|
|
362
364
|
reason = mount.retained === true ? mount.reason : null;
|
package/lib/types/changelog.d.ts
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* `source` instead: its history is where it came from, and the market says
|
|
21
21
|
* it has none on hand rather than that the plugin publishes none (#819).
|
|
22
22
|
*/
|
|
23
|
+
import { type ReleaseHistory } from './release-history.ts';
|
|
23
24
|
export interface ReleaseNotes {
|
|
24
25
|
tag: string | null;
|
|
25
26
|
name: string | null;
|
|
@@ -35,6 +36,7 @@ export interface CommitNote {
|
|
|
35
36
|
interface UpdatesEntry {
|
|
36
37
|
release?: ReleaseNotes | null;
|
|
37
38
|
commits?: CommitNote[];
|
|
39
|
+
releaseHistory?: true;
|
|
38
40
|
}
|
|
39
41
|
interface UpdatesPayload {
|
|
40
42
|
count?: number;
|
|
@@ -100,6 +102,7 @@ export interface UpdateNotes {
|
|
|
100
102
|
kind: 'release' | 'commits' | 'npm' | 'source' | 'none';
|
|
101
103
|
/** Present for `release`: the author's own notes for the latest release. */
|
|
102
104
|
release?: ReleaseNotes;
|
|
105
|
+
history?: ReleaseHistory;
|
|
103
106
|
/** Present for `commits`: the tail, sliced when the boundary was found. */
|
|
104
107
|
commits?: {
|
|
105
108
|
items: CommitNote[];
|
|
@@ -135,6 +138,6 @@ export interface UpdateNotes {
|
|
|
135
138
|
* a neutral statement, not an error.
|
|
136
139
|
*/
|
|
137
140
|
export declare function updateNotesFor(profile: string, explicitDir: string | undefined, name: string,
|
|
138
|
-
/**
|
|
141
|
+
/** Exact version or Git SHA displayed as the update target. */
|
|
139
142
|
target?: string): Promise<UpdateNotes>;
|
|
140
143
|
export {};
|
package/lib/types/dsh-cli.d.ts
CHANGED
|
@@ -194,6 +194,12 @@ export interface InstallResult {
|
|
|
194
194
|
* an ordinary failure without parsing a sentence.
|
|
195
195
|
*/
|
|
196
196
|
refusalCode?: string;
|
|
197
|
+
/**
|
|
198
|
+
* The desktop host refused with `bundle-in-use` after an update already
|
|
199
|
+
* settled behind a restart in this process (#1253): the answer is "restart",
|
|
200
|
+
* not "that plugin is in use".
|
|
201
|
+
*/
|
|
202
|
+
needsRestart?: boolean;
|
|
197
203
|
/** Package names pnpm reported as having ignored build scripts (ndjson). */
|
|
198
204
|
ignoredBuilds?: string[];
|
|
199
205
|
/**
|
|
@@ -262,6 +268,8 @@ export interface PluginCommandRuntime {
|
|
|
262
268
|
* "nothing else is running".
|
|
263
269
|
*/
|
|
264
270
|
busy?(): boolean;
|
|
271
|
+
/** A managed package command can still write after its caller times out. */
|
|
272
|
+
packageWritesSettled?(): boolean;
|
|
265
273
|
}
|
|
266
274
|
/** One running package operation, however it was started. */
|
|
267
275
|
export interface DesktopPnpmHandleLike {
|
package/lib/types/gist.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export declare function ghAuthSpawnOptions(platform?: NodeJS.Platform): {
|
|
|
67
67
|
detached: boolean;
|
|
68
68
|
windowsHide: boolean;
|
|
69
69
|
};
|
|
70
|
-
/** Create a
|
|
70
|
+
/** Create a secret Gist carrying one backup file. */
|
|
71
71
|
export declare function createGist(token: string, content: string, signal?: AbortSignal): Promise<GistRef>;
|
|
72
72
|
/** Overwrite the backup file inside an existing Gist (other files kept). */
|
|
73
73
|
export declare function updateGist(token: string, gistId: string, content: string, signal?: AbortSignal): Promise<GistRef>;
|
package/lib/types/hot.d.ts
CHANGED
|
@@ -455,11 +455,12 @@ export declare function hotUnmount(packageName: string): Promise<boolean>;
|
|
|
455
455
|
* @param ctx - market host context; the subtree unwinds with the market's fiber.
|
|
456
456
|
* @param profileDir - profile the package was installed into.
|
|
457
457
|
* @param packageName - installed package to activate.
|
|
458
|
+
* @param keepOff - component ids the user's profile keeps disabled.
|
|
458
459
|
* @returns whether the plugin is live without a restart, plus the reason
|
|
459
460
|
* when it is not (P0-2: the UI must distinguish "restart will fix it" from
|
|
460
461
|
* "this package can never hot-mount").
|
|
461
462
|
*/
|
|
462
|
-
export declare function hotMount(ctx: HotContext, profileDir: string, packageName: string): Promise<HotMountResult>;
|
|
463
|
+
export declare function hotMount(ctx: HotContext, profileDir: string, packageName: string, keepOff?: ReadonlySet<string>): Promise<HotMountResult>;
|
|
463
464
|
/**
|
|
464
465
|
* Mount every installed client-only package (`dsh.client` without
|
|
465
466
|
* `dsh.bundle`) at market startup. The bundle reconcile skips these packages
|
package/lib/types/install.d.ts
CHANGED
|
@@ -344,6 +344,25 @@ export declare function hostNodeModulesRoot(directory: string): string;
|
|
|
344
344
|
* outside Node — but a comparison must not silently miss because of them.
|
|
345
345
|
*/
|
|
346
346
|
export declare function normalizedLinkTarget(target: string): string;
|
|
347
|
+
export interface DetachedCheckoutLink {
|
|
348
|
+
readonly path: string;
|
|
349
|
+
readonly rawTarget: string;
|
|
350
|
+
readonly moduleRoot: string;
|
|
351
|
+
}
|
|
352
|
+
/** Reconstruct a saved link using only the active profile and matching checkout. */
|
|
353
|
+
export declare function recordedCheckoutLink(profileDirectory: string, name: string, spec: string, rawTarget: string): DetachedCheckoutLink;
|
|
354
|
+
/** Check the saved checkout without creating its profile link. */
|
|
355
|
+
export declare function checkoutSourceExists(link: DetachedCheckoutLink): boolean;
|
|
356
|
+
/** Disconnect only the profile junction that still matches the recorded local checkout. */
|
|
357
|
+
export declare function detachCheckoutLink(profileDirectory: string, name: string, spec: string, record: (link: DetachedCheckoutLink) => void): DetachedCheckoutLink | null;
|
|
358
|
+
/** Recheck the slot before a pnpm recovery retry can replace it again. */
|
|
359
|
+
export declare function keepCheckoutDetached(link: DetachedCheckoutLink): void;
|
|
360
|
+
/**
|
|
361
|
+
* Restore the captured checkout link without asking pnpm to touch it. On
|
|
362
|
+
* rollback a package materialized inside the profile can be staged until the
|
|
363
|
+
* link and the caller's saved manifest are restored.
|
|
364
|
+
*/
|
|
365
|
+
export declare function restoreCheckoutLink(link: DetachedCheckoutLink, replacePackage: boolean, restoreMetadata: () => void): void;
|
|
347
366
|
/**
|
|
348
367
|
* Remove the host-side bridge link a confirmed uninstall leaves dangling
|
|
349
368
|
* (#662). The official boot projects profile packages into the host
|
|
@@ -375,10 +394,9 @@ export declare function removeDanglingHostBridge(name: string, profileDirectory:
|
|
|
375
394
|
* release) makes pnpm rename `<name>_tmp_*` over it, which Windows refuses
|
|
376
395
|
* with EPERM.
|
|
377
396
|
*
|
|
378
|
-
* Only a link is
|
|
379
|
-
* `name`
|
|
380
|
-
*
|
|
381
|
-
* at (the same measurement the host-bridge cleanup above relies on).
|
|
397
|
+
* Only a link is touched, and only when the manifest no longer lists
|
|
398
|
+
* `name`. `unlinkSync` also handles directory junctions in Desktop's
|
|
399
|
+
* embedded Node, which reports EISDIR for nonrecursive `rmSync`.
|
|
382
400
|
*
|
|
383
401
|
* @returns the checkout path the removed link pointed at, or null when there
|
|
384
402
|
* was nothing to remove. Never throws: the uninstall already succeeded.
|
|
@@ -13,6 +13,8 @@ interface ManagedResult {
|
|
|
13
13
|
* must not try to "restore" it through the same stuck manager.
|
|
14
14
|
*/
|
|
15
15
|
repairOnRestart?: boolean;
|
|
16
|
+
/** The refusal is the host's restart-first state, not a plugin in use (#1253). */
|
|
17
|
+
needsRestart?: boolean;
|
|
16
18
|
}
|
|
17
19
|
export interface OfficialPluginManagerLike {
|
|
18
20
|
installBundle(spec: string, options?: {
|
|
@@ -30,6 +32,8 @@ export interface OfficialPluginManagerLike {
|
|
|
30
32
|
export declare const OFFICIAL_PAGE_HINT = "\u5B98\u65B9\u684C\u9762\u5BA2\u6237\u7AEF\u7684\u8FD9\u4E2A\u63D2\u4EF6\u64CD\u4F5C\u9700\u8981\u5728\u300C\u8BBE\u7F6E \u2192 \u63D2\u4EF6\u300D\u91CC\u5B8C\u6210\uFF1B\u5E02\u573A\u65E0\u6CD5\u901A\u8FC7\u547D\u4EE4\u884C\u4FEE\u6539\u684C\u9762\u7AEF\u7684 profile\u3002 / On the official desktop app, do this from Settings \u2192 Plugins; the market cannot change the desktop profile through the command line.";
|
|
31
33
|
/** `dsh-crate@1.66.32` → `dsh-crate`; anything that is not a registry name stays unparsed. */
|
|
32
34
|
export declare function registryNameOf(spec: string): string | undefined;
|
|
35
|
+
/** Test seam: a new host process starts with nothing pending. */
|
|
36
|
+
export declare function forgetRestartPending(): void;
|
|
33
37
|
/** The official runtime's own surface, plus the repair a later start owes the profile. */
|
|
34
38
|
export interface OfficialDesktopRuntime extends DesktopPluginRuntime {
|
|
35
39
|
/**
|
package/lib/types/patch.d.ts
CHANGED
|
@@ -178,6 +178,41 @@ export declare function packagePatchFlags(host: PatchHost, profileDirectory: str
|
|
|
178
178
|
disabled: string[];
|
|
179
179
|
forced: string[];
|
|
180
180
|
};
|
|
181
|
+
interface ComponentSwitchPatch {
|
|
182
|
+
before: string;
|
|
183
|
+
resumed: string;
|
|
184
|
+
rows: ReadonlyMap<string, string | null>;
|
|
185
|
+
suspended: boolean;
|
|
186
|
+
customized: boolean;
|
|
187
|
+
keepOff: ReadonlySet<string>;
|
|
188
|
+
ownOff: ReadonlySet<string>;
|
|
189
|
+
legacyAllOff: boolean;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* View the user's component choices without the temporary package-wide
|
|
193
|
+
* disable overrides. A named override the official page changed to false
|
|
194
|
+
* is a new choice, so only the still-disabled market overrides are removed.
|
|
195
|
+
*/
|
|
196
|
+
export declare function readComponentSwitchPatch(patchPath: string, packageName: string, rows: ReadonlyMap<string, string | null>, bundleDecides: ReadonlySet<string>): ComponentSwitchPatch | null;
|
|
197
|
+
interface ComponentPatchChange {
|
|
198
|
+
before: string | null;
|
|
199
|
+
after: string;
|
|
200
|
+
}
|
|
201
|
+
type PatchWrite = {
|
|
202
|
+
ok: boolean;
|
|
203
|
+
reason: string | null;
|
|
204
|
+
};
|
|
205
|
+
/** Roll back only an unchanged file this switch wrote. */
|
|
206
|
+
export declare function rollbackComponentSwitchPatch(patchPath: string, change: ComponentPatchChange): PatchWrite;
|
|
207
|
+
/** Only the switch's own overrides are written or removed. Keep the user's
|
|
208
|
+
* component flags and accompanying configuration in the file verbatim. */
|
|
209
|
+
export declare function writeComponentSwitchPatch(patchPath: string, packageName: string, patch: ComponentSwitchPatch, enabled: boolean): Promise<PatchWrite & {
|
|
210
|
+
change?: ComponentPatchChange;
|
|
211
|
+
}>;
|
|
212
|
+
/** The OFF transaction calls this while holding the host profile lock. */
|
|
213
|
+
export declare function commitComponentSwitchPatch(patchPath: string, packageName: string, patch: ComponentSwitchPatch, enabled: boolean): PatchWrite & {
|
|
214
|
+
change?: ComponentPatchChange;
|
|
215
|
+
};
|
|
181
216
|
/**
|
|
182
217
|
* Disable one row: `- id: X` + `disabled: true` (idempotent).
|
|
183
218
|
*
|
|
@@ -220,3 +255,4 @@ export declare function removeRowBlocks(patchPath: string, rowIds: readonly stri
|
|
|
220
255
|
ok: boolean;
|
|
221
256
|
reason: string | null;
|
|
222
257
|
};
|
|
258
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Checkout links disconnected before replacing a local build. */
|
|
2
|
+
export interface PendingCheckoutLink {
|
|
3
|
+
name: string;
|
|
4
|
+
spec: string;
|
|
5
|
+
rawTarget: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CheckoutRecoveryEntry {
|
|
8
|
+
name: string;
|
|
9
|
+
reason: 'profile-busy' | 'package-run' | 'writer-lock' | 'check-failed';
|
|
10
|
+
sourceExists: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface CheckoutRecoveryStatus {
|
|
13
|
+
checking: boolean;
|
|
14
|
+
entries: CheckoutRecoveryEntry[];
|
|
15
|
+
}
|
|
16
|
+
export declare class PendingCheckoutLinks {
|
|
17
|
+
readonly file: string;
|
|
18
|
+
constructor(profileDirectory: string);
|
|
19
|
+
list(): PendingCheckoutLink[];
|
|
20
|
+
record(item: PendingCheckoutLink): void;
|
|
21
|
+
save(operations: PendingCheckoutLink[]): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Claim the same exclusive profile writer lock as rc.3's plugin manager.
|
|
25
|
+
* An occupied lock is left for the host to release or take over.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withIdleProfile<T>(profileDirectory: string, action: () => T): T | null;
|
|
28
|
+
type HostProfileLock = <T>(file: string, action: () => Promise<T>, options: {
|
|
29
|
+
waitMs: number;
|
|
30
|
+
}) => Promise<T>;
|
|
31
|
+
/** Resolve the lock implementation from the host's own plugin manager. */
|
|
32
|
+
export declare function loadHostProfileLock(installDirectory: string | null): Promise<HostProfileLock | null>;
|
|
33
|
+
/** A pnpm child may survive the process that owned the writer lock. */
|
|
34
|
+
export declare function hasUnsettledPackageRun(profileDirectory: string): boolean;
|
|
35
|
+
export {};
|
|
@@ -111,6 +111,7 @@ export interface RepairOptions {
|
|
|
111
111
|
journal?: PendingUpdateJournal;
|
|
112
112
|
timeoutMs?: number;
|
|
113
113
|
}
|
|
114
|
+
export type RepairFailureCause = 'version-changed' | 'refused' | 'not-composed' | 'timeout' | 'unknown' | 'abandoned';
|
|
114
115
|
export interface RepairReport {
|
|
115
116
|
/** Packages a previous start removed and this one put back. */
|
|
116
117
|
reinstalled: string[];
|
|
@@ -119,6 +120,7 @@ export interface RepairReport {
|
|
|
119
120
|
failed: Array<{
|
|
120
121
|
name: string;
|
|
121
122
|
reason: string;
|
|
123
|
+
cause: RepairFailureCause;
|
|
122
124
|
}>;
|
|
123
125
|
/** Packages the market has stopped retrying by itself (see MAX_AUTO_REPAIR_ATTEMPTS). */
|
|
124
126
|
abandoned: string[];
|
package/lib/types/profile.d.ts
CHANGED
|
@@ -419,6 +419,9 @@ export declare function readProfileBundles(profileDirectory: string): string[];
|
|
|
419
419
|
* @returns true when the bundle was present and removed.
|
|
420
420
|
*/
|
|
421
421
|
export declare function removeProfileBundle(profileDirectory: string, name: string): boolean;
|
|
422
|
+
/** Undo one switch's removal without replacing other manifest fields or a
|
|
423
|
+
* bundle order edited by another writer. The caller holds the profile lock. */
|
|
424
|
+
export declare function restoreRemovedProfileBundle(profileDirectory: string, name: string, before: ProfileManifestSnapshot): boolean;
|
|
422
425
|
/**
|
|
423
426
|
* Re-add a bundle to `dsh.profile.bundles` after a carrier toggle-off (#224).
|
|
424
427
|
* Idempotent: a bundle already present is left untouched. The name is appended
|
package/lib/types/registry.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* behind it any more.
|
|
2
|
+
* Access to the curated list from awesome-dsh-plugin.com. Each new load
|
|
3
|
+
* revalidates the catalog with its source.
|
|
5
4
|
*/
|
|
6
5
|
import { type Region } from './regions.ts';
|
|
7
6
|
export interface RegistryPlugin {
|
|
@@ -117,14 +116,13 @@ export interface Registry {
|
|
|
117
116
|
*/
|
|
118
117
|
export declare function pluginPreviousNpm(plugin: Pick<RegistryPlugin, 'name' | 'npm' | 'previousNpm'>): string[];
|
|
119
118
|
/**
|
|
120
|
-
* Drop
|
|
121
|
-
*
|
|
122
|
-
* Exists for tests: the memo is module state, and a spec that asserted a
|
|
123
|
-
* 304 would otherwise leak a validator into the next one.
|
|
119
|
+
* Drop the validator and detach any earlier load, so the next call starts an
|
|
120
|
+
* unconditional request. Earlier callers can still receive their own result.
|
|
124
121
|
*/
|
|
125
122
|
export declare function forgetCatalog(): void;
|
|
126
123
|
/**
|
|
127
|
-
* The catalog, revalidated
|
|
124
|
+
* The catalog, revalidated on each new load. Discovery and the update check
|
|
125
|
+
* share a revalidation while it is in flight for the same configured sources.
|
|
128
126
|
*
|
|
129
127
|
* There used to be three answers here — live, a one-hour in-memory cache,
|
|
130
128
|
* and a snapshot bundled into the npm package — and only the first was
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface ReleaseBlocker {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
/** ISO time pnpm printed, or null when it printed none we can read. */
|
|
5
|
+
publishedAt: string | null;
|
|
6
|
+
/** ISO time the safety wait ends, or null when it cannot be worked out. */
|
|
7
|
+
readyAt: string | null;
|
|
8
|
+
}
|
|
9
|
+
/** How long a blocker with an unknown end time is believed (same as #961). */
|
|
10
|
+
export declare const UNKNOWN_BLOCKER_TTL_MS: number;
|
|
11
|
+
/**
|
|
12
|
+
* Read the entries pnpm refused out of its violation output.
|
|
13
|
+
* @param output - pnpm's combined stdout and stderr.
|
|
14
|
+
* @param windowMs - the profile's effective wait, or null when it is unknown.
|
|
15
|
+
* @param now - epoch ms, injectable for tests.
|
|
16
|
+
* @returns one blocker per `name@version`; empty when the output names none.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseReleaseAgeBlockers(output: string, windowMs: number | null, now?: number): ReleaseBlocker[];
|
|
19
|
+
/** Remember what pnpm just refused, replacing whatever was known for this profile. */
|
|
20
|
+
export declare function recordReleaseBlockers(dir: string, blockers: readonly ReleaseBlocker[], now?: number): void;
|
|
21
|
+
/** Forget every blocker of this profile (a mutation went through without a bypass). */
|
|
22
|
+
export declare function clearReleaseBlockers(dir: string): void;
|
|
23
|
+
/** Test seam: drop the in-memory copy so the next read comes from disk (a restart). */
|
|
24
|
+
export declare function forgetReleaseBlockerMemory(): void;
|
|
25
|
+
/**
|
|
26
|
+
* The blockers that still hold, with the ended and the departed dropped.
|
|
27
|
+
* A blocker ends at its time, or after {@link UNKNOWN_BLOCKER_TTL_MS} when
|
|
28
|
+
* the time is unknown, or as soon as the lockfile no longer pins it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function activeReleaseBlockers(dir: string, now?: number): ReleaseBlocker[];
|
|
31
|
+
/** The one blocker to name: an unknown time first (nothing is certain), else the last to end. */
|
|
32
|
+
export declare function headlineBlocker(blockers: readonly ReleaseBlocker[]): ReleaseBlocker | null;
|
|
33
|
+
/** What the update route says when it declines to start (bilingual, `zh / en`). */
|
|
34
|
+
export declare function releaseBlockedMessage(blocker: ReleaseBlocker): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReleaseNotes } from './changelog.ts';
|
|
2
|
+
interface HistoryRelease extends ReleaseNotes {
|
|
3
|
+
tag: string;
|
|
4
|
+
commit: string | null;
|
|
5
|
+
}
|
|
6
|
+
interface RepositoryHistory {
|
|
7
|
+
complete: boolean;
|
|
8
|
+
releases: HistoryRelease[];
|
|
9
|
+
}
|
|
10
|
+
export interface ReleaseHistory {
|
|
11
|
+
items: VersionedRelease[];
|
|
12
|
+
partial: boolean;
|
|
13
|
+
}
|
|
14
|
+
type VersionedRelease = ReleaseNotes & {
|
|
15
|
+
version: string;
|
|
16
|
+
};
|
|
17
|
+
export interface ReleaseHistorySource {
|
|
18
|
+
repo: string;
|
|
19
|
+
packageName: string;
|
|
20
|
+
allowPlainTag: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function isCommitId(value: string): boolean;
|
|
23
|
+
export declare function invalidateReleaseHistory(): void;
|
|
24
|
+
export declare function loadReleaseHistory(origin: string, repo: string): Promise<RepositoryHistory | null>;
|
|
25
|
+
/** A sibling's version or a number embedded in an unrelated tag is not a package release. */
|
|
26
|
+
export declare function packageReleaseVersion(tag: string | null, source: ReleaseHistorySource): string | null;
|
|
27
|
+
/** Installed and target versions are given by npm, or by exact release-tag SHAs for Git. */
|
|
28
|
+
export declare function releaseHistoryBetween(data: RepositoryHistory | null, source: ReleaseHistorySource, installed: string, target: string, current: string | null): {
|
|
29
|
+
history: ReleaseHistory;
|
|
30
|
+
targetVersion: string | null;
|
|
31
|
+
targetCommit: string | null;
|
|
32
|
+
preview: VersionedRelease | null;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
asset: string;
|
|
4
|
-
manifest: string;
|
|
5
|
-
}
|
|
6
|
-
/** Only the catalog's own floating asset opts an existing archive into updates. */
|
|
7
|
-
export declare function catalogReleaseSourceOf(spec: string, entry: {
|
|
8
|
-
url: string;
|
|
9
|
-
npm?: unknown;
|
|
10
|
-
tarball?: unknown;
|
|
11
|
-
}): CatalogReleaseSource | null;
|
|
1
|
+
import type { CatalogReleaseSource } from './sources.ts';
|
|
2
|
+
export { catalogReleaseSourceOf, type CatalogReleaseSource } from './sources.ts';
|
|
12
3
|
export declare function publishedReleaseUpdate(source: CatalogReleaseSource, name: string): Promise<{
|
|
13
4
|
version: string;
|
|
14
5
|
target: string;
|
package/lib/types/routes.d.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
11
11
|
import { type PluginCommandRuntime } from './dsh-cli.ts';
|
|
12
12
|
import { type AgentsLookup } from './agents.ts';
|
|
13
|
+
import type { StartupRepairSnapshot } from './startup-repair-report.ts';
|
|
13
14
|
import { type Channel } from './channels.ts';
|
|
14
15
|
import { type Region } from './regions.ts';
|
|
15
16
|
import { type LoaderEntry } from './themes.ts';
|
|
@@ -62,6 +63,8 @@ export interface HostPluginActivation {
|
|
|
62
63
|
export interface MarketConfig {
|
|
63
64
|
/** Profile the market installs into; matches the profile serving this UI. */
|
|
64
65
|
profile: string;
|
|
66
|
+
/** Read the official Desktop profile's startup repair results. */
|
|
67
|
+
startupRepair?: () => StartupRepairSnapshot;
|
|
65
68
|
/** Host-authoritative profile directory; ordinary DSH derives it from DSH_HOME. */
|
|
66
69
|
profileDirectory?: string;
|
|
67
70
|
/** Installation-owned bundles live beside this host, outside the Desktop profile. */
|
package/lib/types/sources.d.ts
CHANGED
|
@@ -232,6 +232,17 @@ export declare function installTargetFor(entry: {
|
|
|
232
232
|
npm?: unknown;
|
|
233
233
|
tarball?: unknown;
|
|
234
234
|
}): string | null;
|
|
235
|
+
export interface CatalogReleaseSource {
|
|
236
|
+
repo: string;
|
|
237
|
+
asset: string;
|
|
238
|
+
manifest: string;
|
|
239
|
+
}
|
|
240
|
+
/** Only the catalog's own floating asset opts an existing archive into updates. */
|
|
241
|
+
export declare function catalogReleaseSourceOf(spec: string, entry: {
|
|
242
|
+
url: string;
|
|
243
|
+
npm?: unknown;
|
|
244
|
+
tarball?: unknown;
|
|
245
|
+
}): CatalogReleaseSource | null;
|
|
235
246
|
/**
|
|
236
247
|
* The target to retry with when a prebuilt release tarball could not be
|
|
237
248
|
* installed — the entry's own GitHub source, which is what it would have
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RepairFailureCause, RepairReport } from './pending-updates.ts';
|
|
2
|
+
export type StartupRepairEntry = {
|
|
3
|
+
name: string;
|
|
4
|
+
} & ({
|
|
5
|
+
state: 'reinstalled' | 'verified' | 'abandoned';
|
|
6
|
+
} | {
|
|
7
|
+
state: 'pending';
|
|
8
|
+
cause: RepairFailureCause;
|
|
9
|
+
});
|
|
10
|
+
export interface StartupRepairSnapshot {
|
|
11
|
+
id: string;
|
|
12
|
+
revision: number;
|
|
13
|
+
checking: boolean;
|
|
14
|
+
entries: StartupRepairEntry[];
|
|
15
|
+
}
|
|
16
|
+
/** Track what the existing startup repair found, without owning any package writes. */
|
|
17
|
+
export declare function observeStartupRepair(profile: string, directory: string): {
|
|
18
|
+
read: () => StartupRepairSnapshot;
|
|
19
|
+
finish: (report?: RepairReport) => void;
|
|
20
|
+
};
|
package/lib/types/themes.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ export interface ThemeHost {
|
|
|
35
35
|
/** Manages theme exclusivity for one profile. */
|
|
36
36
|
export interface ThemeManager {
|
|
37
37
|
installedThemeNames(): Promise<Set<string>>;
|
|
38
|
-
setEntryDisabled(name: string, disabledFlag: boolean, requireLive?: boolean, rejectPending?: boolean): Promise<boolean>;
|
|
39
|
-
activateTheme(name: string): Promise<ThemeActivationResult>;
|
|
38
|
+
setEntryDisabled(name: string, disabledFlag: boolean, requireLive?: boolean, rejectPending?: boolean, keepOff?: ReadonlySet<string>): Promise<boolean>;
|
|
39
|
+
activateTheme(name: string, keepOff?: ReadonlySet<string>): Promise<ThemeActivationResult>;
|
|
40
40
|
}
|
|
41
41
|
interface ThemeActivationResult {
|
|
42
42
|
ok: boolean;
|
|
@@ -38,6 +38,12 @@ interface MonitorDependencies {
|
|
|
38
38
|
updates: Record<string, UpdateStatus>;
|
|
39
39
|
error?: string;
|
|
40
40
|
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Applied to every answer on the way out, never stored: facts that change
|
|
43
|
+
* between checks (a profile-level wait learned from a failed click, #1252)
|
|
44
|
+
* must show on the next read, not the next poll.
|
|
45
|
+
*/
|
|
46
|
+
overlay?(updates: Record<string, UpdateStatus>): Record<string, UpdateStatus>;
|
|
41
47
|
}
|
|
42
48
|
export interface UpdateNotificationMonitor {
|
|
43
49
|
snapshot(): UpdateNotificationSnapshot;
|
package/lib/types/updates.d.ts
CHANGED
|
@@ -84,6 +84,18 @@ export interface UpdateStatus {
|
|
|
84
84
|
until: string;
|
|
85
85
|
estimated?: true;
|
|
86
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* An update exists, but ANOTHER release already in this profile's lockfile
|
|
89
|
+
* is still inside the safety wait, and pnpm refuses every change until it is
|
|
90
|
+
* past (#1252). Separate from {@link heldUpdate}, which is about this
|
|
91
|
+
* plugin's own target. `readyAt` is null when the end time is unknown.
|
|
92
|
+
* `updateAvailable` is false while this is set.
|
|
93
|
+
*/
|
|
94
|
+
profileBlocked?: {
|
|
95
|
+
name: string;
|
|
96
|
+
version: string;
|
|
97
|
+
readyAt: string | null;
|
|
98
|
+
};
|
|
87
99
|
/**
|
|
88
100
|
* The version this package's channel points at, when it differs from what
|
|
89
101
|
* is installed and is NOT newer.
|
|
@@ -241,6 +253,13 @@ export declare function fetchNpmLatest(name: string): Promise<string | null>;
|
|
|
241
253
|
* without the market volunteering anyone's prerelease as an update.
|
|
242
254
|
*/
|
|
243
255
|
export declare function newerPrereleaseFor(name: string, installed: string | null): Promise<string | null>;
|
|
256
|
+
/**
|
|
257
|
+
* Mark the updates a known profile-level blocker would turn into a failed
|
|
258
|
+
* click (#1252). Applied to what is served, not to the cached registry
|
|
259
|
+
* answer, so a blocker learned a second ago and one that just ended both show
|
|
260
|
+
* on the very next read without another round of registry traffic.
|
|
261
|
+
*/
|
|
262
|
+
export declare function applyProfileBlockers(statuses: Record<string, UpdateStatus>, activeProfileDir: string, now?: number): Record<string, UpdateStatus>;
|
|
244
263
|
/** Check each plugin independently so a failed lookup leaves the other results usable. */
|
|
245
264
|
export declare function checkUpdates(profile: string, force?: boolean, explicitDir?: string,
|
|
246
265
|
/**
|