fix(preview-download): declare remote service dependency
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ if [[ -f "${DSH_HOME}/profiles/web/package.json" ]]; then
|
||||
# pnpm otherwise probes registry metadata for the overlapping optional peer.
|
||||
# Restrict offline mode to profiles containing only our fixed archives.
|
||||
install_env=()
|
||||
if node -e 'const m=require(process.env.DSH_HOME+"/profiles/web/package.json"); const pins={"dsh-preview-download":"file:/usr/local/lib/dsh-mgr/dsh-preview-download-1.0.0.tgz","dsh-chat-manager":"file:/usr/local/lib/dsh-mgr/dsh-chat-manager-1.5.12-dsh-mgr.1.tgz","dsh-mgr-workspace":"file:/usr/local/lib/dsh-mgr/dsh-mgr-workspace-1.0.0.tgz","dsh-web-mobile":"file:/usr/local/lib/dsh-mgr/dsh-web-mobile-3.0.5.tgz","dsh-free-search":"file:/usr/local/lib/dsh-mgr/dsh-free-search-0.8.5.tgz"}; process.exit(Object.entries({...m.dependencies,...m.devDependencies,...m.optionalDependencies}).every(([n,v])=>pins[n]===v)?0:1)'; then
|
||||
if node -e 'const m=require(process.env.DSH_HOME+"/profiles/web/package.json"); const pins={"dsh-preview-download":"file:/usr/local/lib/dsh-mgr/dsh-preview-download-1.0.1.tgz","dsh-chat-manager":"file:/usr/local/lib/dsh-mgr/dsh-chat-manager-1.5.12-dsh-mgr.1.tgz","dsh-mgr-workspace":"file:/usr/local/lib/dsh-mgr/dsh-mgr-workspace-1.0.0.tgz","dsh-web-mobile":"file:/usr/local/lib/dsh-mgr/dsh-web-mobile-3.0.5.tgz","dsh-free-search":"file:/usr/local/lib/dsh-mgr/dsh-free-search-0.8.5.tgz"}; process.exit(Object.entries({...m.dependencies,...m.devDependencies,...m.optionalDependencies}).every(([n,v])=>pins[n]===v)?0:1)'; then
|
||||
install_env=(npm_config_offline=true)
|
||||
fi
|
||||
if timeout --signal=TERM --kill-after=5s 120s env CI=true "${install_env[@]}" dsh plugin --profile web install --ignore-scripts; then
|
||||
|
||||
@@ -14,7 +14,7 @@ if (!existsSync(profile) || readdirSync(profile).length === 0) {
|
||||
mkdirSync(profile, { recursive: true });
|
||||
writeFileSync(join(profile, 'package.json'), JSON.stringify({
|
||||
name: 'dsh-profile-web', private: true,
|
||||
dependencies: { 'dsh-preview-download': 'file:/usr/local/lib/dsh-mgr/dsh-preview-download-1.0.0.tgz', 'dsh-chat-manager': 'file:/usr/local/lib/dsh-mgr/dsh-chat-manager-1.5.12-dsh-mgr.1.tgz', 'dsh-mgr-workspace': 'file:/usr/local/lib/dsh-mgr/dsh-mgr-workspace-1.0.0.tgz', 'dsh-web-mobile': 'file:/usr/local/lib/dsh-mgr/dsh-web-mobile-3.0.5.tgz', 'dsh-free-search': 'file:/usr/local/lib/dsh-mgr/dsh-free-search-0.8.5.tgz' },
|
||||
dependencies: { 'dsh-preview-download': 'file:/usr/local/lib/dsh-mgr/dsh-preview-download-1.0.1.tgz', 'dsh-chat-manager': 'file:/usr/local/lib/dsh-mgr/dsh-chat-manager-1.5.12-dsh-mgr.1.tgz', 'dsh-mgr-workspace': 'file:/usr/local/lib/dsh-mgr/dsh-mgr-workspace-1.0.0.tgz', 'dsh-web-mobile': 'file:/usr/local/lib/dsh-mgr/dsh-web-mobile-3.0.5.tgz', 'dsh-free-search': 'file:/usr/local/lib/dsh-mgr/dsh-free-search-0.8.5.tgz' },
|
||||
pnpm: { overrides: {
|
||||
'dsh-chat-manager>clsx': 'file:/usr/local/lib/dsh-mgr/clsx-2.1.1.tgz',
|
||||
'dsh-free-search>@deepseek-ai/schemastery': 'file:/usr/local/lib/dsh-mgr/schemastery-3.18.4.tgz',
|
||||
|
||||
@@ -11,7 +11,7 @@ test('new profile enables bundle once and preserves existing configuration', ()
|
||||
run();
|
||||
const file=join(home,'profiles/web/package.json');
|
||||
const original=readFileSync(file,'utf8');
|
||||
assert.equal(JSON.parse(original).dependencies['dsh-preview-download'], 'file:/usr/local/lib/dsh-mgr/dsh-preview-download-1.0.0.tgz');
|
||||
assert.equal(JSON.parse(original).dependencies['dsh-preview-download'], 'file:/usr/local/lib/dsh-mgr/dsh-preview-download-1.0.1.tgz');
|
||||
assert.equal(JSON.parse(original).dsh.profile.bundles.filter(name => name === 'dsh-preview-download').length, 1);
|
||||
assert.ok(JSON.parse(original).dsh.profile.bundles.includes('dsh-chat-manager'));
|
||||
assert.equal(JSON.parse(original).dependencies['dsh-chat-manager'], 'file:/usr/local/lib/dsh-mgr/dsh-chat-manager-1.5.12-dsh-mgr.1.tgz');
|
||||
|
||||
@@ -5,4 +5,4 @@ const host = JSON.parse(readFileSync('/usr/local/lib/node_modules/@deepseek-ai/d
|
||||
if (host.version !== '0.2.0-rc.2') throw new Error('Unverified preview download host');
|
||||
mkdirSync(root + '/preview-download-package', { recursive: true });
|
||||
cpSync(new URL('./preview-download', import.meta.url), root + '/preview-download-package/package', { recursive: true });
|
||||
execFileSync('tar', ['-czf', root + '/dsh-preview-download-1.0.0.tgz', '-C', root + '/preview-download-package', 'package']);
|
||||
execFileSync('tar', ['-czf', root + '/dsh-preview-download-1.0.1.tgz', '-C', root + '/preview-download-package', 'package']);
|
||||
|
||||
@@ -45,3 +45,27 @@ test('plugin registers only the supported preview action slot', () => {
|
||||
assert.equal(registration.id, 'dsh-preview-download');
|
||||
assert.equal(typeof registration.inject('session-A').download, 'function');
|
||||
});
|
||||
|
||||
test('registered download declares every service used by its callback', async () => {
|
||||
const plugin = load();
|
||||
assert.ok(plugin.inject.includes('remote'));
|
||||
assert.ok(plugin.inject.includes('remote.workspaceFiles'));
|
||||
let registration;
|
||||
let calls = 0;
|
||||
const data = new Uint8Array([1, 2, 255]);
|
||||
const ctx = {
|
||||
effect: fn => fn(),
|
||||
locale: { register: () => () => {} },
|
||||
slots: { inject: (_name, fn) => fn(), register(options) { registration = options; return () => {}; } },
|
||||
get remote() {
|
||||
assert.ok(plugin.inject.includes('remote'), 'Cordis requires explicit remote injection');
|
||||
return { workspaceFiles: { async readBytes(session, path) {
|
||||
assert.equal(session, 'session-A'); assert.equal(path, '/file.bin'); calls++;
|
||||
return { ok: true, value: { offset: 0, eof: true, bytes: 3, data } };
|
||||
} } };
|
||||
}
|
||||
};
|
||||
plugin.apply(ctx);
|
||||
assert.equal(await registration.inject('session-A').download('/file.bin', new AbortController().signal), data);
|
||||
assert.equal(calls, 1);
|
||||
});
|
||||
|
||||
@@ -60,7 +60,7 @@ window.__ModuleLoader__.load({ id: 'dsh-preview-download', factory: require => {
|
||||
}
|
||||
|
||||
return {
|
||||
inject: ['slots', 'locale', 'remote.workspaceFiles'],
|
||||
inject: ['slots', 'locale', 'remote', 'remote.workspaceFiles'],
|
||||
apply(ctx) {
|
||||
ctx.effect(() => ctx.locale.register(namespace, {
|
||||
zh: { download: '下载原文件', loading: '下载中…', failed: '下载失败,请检查文件权限或重试。', tooLarge: '文件超过下载大小限制。' },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dsh-preview-download",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
|
||||
Reference in New Issue
Block a user