Make Project Management a native feature
- Move the storage and model of the plugin into src/lib/features/pm/ as pure TypeScript, so the skill can still bundle them. - Move the DOM interface onto the host menus, the shared tooltip, and the host icons. - A ribbon button opens Project Management. Board tabs keep the owner runestone.pm and the board-<hex> view IDs through view patterns. - Read only .runestone/pm/. Offer the plugin migration, with backups, for legacy notes. - A save, move, or delete reads only that card again. Watcher paths reach the feature. - Add Settings → Project Management and the projectManagement section. View states move to localStorage. - Background reads the boards from workspace.json. Remove api.backgrounds and the boards service. - Add yaml 2.9.1. Use the host markdown-it. - Move 18 plugin test files to tests/unit/features/pm/ and add native tests.
This commit is contained in:
@@ -3,7 +3,8 @@ import { readFileSync } from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { BackgroundHub, backgroundHub } from '../../../src/lib/plugins/backgrounds.ts';
|
||||
import { ExternalSession } from '../../../src/lib/plugins/externalSession.ts';
|
||||
import type { BackgroundFrame, PluginApi } from '../../../src/lib/plugins/sdk.ts';
|
||||
import type { PluginApi } from '../../../src/lib/plugins/sdk.ts';
|
||||
import type { BackgroundFrame } from '../../../src/lib/plugins/backgroundContracts.ts';
|
||||
|
||||
const frame: BackgroundFrame = { url: 'blob:http://localhost/example', overlay: 0.3, position: 'center', size: 'cover' };
|
||||
|
||||
@@ -103,36 +104,23 @@ test('subscriber errors do not prevent frame cleanup or remaining notifications'
|
||||
assert.equal(hub.get('pm-all'), null);
|
||||
});
|
||||
|
||||
test('disable removes frames and subscriptions before cleanup', async () => {
|
||||
test('plugins get no background API, and the frames stay with the host', async () => {
|
||||
let api!: PluginApi;
|
||||
const session = new ExternalSession('org.test.backgrounds', {
|
||||
workspace: { list: async () => [], read: async () => '', write: async () => {} },
|
||||
settings: { read: async () => null, write: async () => {} },
|
||||
assets: { read: async () => new Uint8Array() },
|
||||
backgrounds: true,
|
||||
}, () => {}, () => {});
|
||||
let notifications = 0;
|
||||
await session.start({ activate(value) {
|
||||
api = value;
|
||||
api.backgrounds!.subscribe(() => { notifications++; });
|
||||
api.backgrounds!.set('app', frame);
|
||||
api.backgrounds!.set('pm-all', frame);
|
||||
api.onDispose(() => {
|
||||
assert.equal(backgroundHub.get('app'), null);
|
||||
assert.equal(backgroundHub.get('pm-all'), null);
|
||||
assert.throws(() => api.backgrounds!.get('app'), /disabled/);
|
||||
});
|
||||
} });
|
||||
// The deprecated folder methods are gone. Plugins use the folder grants of `api.files`.
|
||||
for (const name of ['chooseFolder', 'defaultFolder', 'list', 'read', 'readImageSettings', 'writeImageSettings']) assert.equal(name in api.backgrounds!, false, name);
|
||||
await session.start({ activate(value) { api = value; } });
|
||||
// Project Management was the last plugin user of `api.backgrounds`. It reads `backgroundHub` as a native feature.
|
||||
assert.equal('backgrounds' in api, false);
|
||||
const owner = Symbol();
|
||||
backgroundHub.set(owner, 'pm-all', frame);
|
||||
await session.stop();
|
||||
assert.equal(notifications, 2);
|
||||
assert.throws(() => api.backgrounds!.set('app', frame), /disabled/);
|
||||
assert.throws(() => api.backgrounds!.subscribe(() => {}), /disabled/);
|
||||
assert.equal(backgroundHub.get('app'), null);
|
||||
assert.deepEqual(backgroundHub.get('pm-all'), frame);
|
||||
backgroundHub.removeOwner(owner);
|
||||
});
|
||||
|
||||
|
||||
test('the Background commands are allowed in the windows that use them, and the old plugin commands are gone', () => {
|
||||
const build = readFileSync(new URL('../../../src-tauri/build.rs', import.meta.url), 'utf8');
|
||||
const all = ['background_choose_folder', 'background_folder', 'background_clear_folder', 'background_list', 'background_read', 'background_read_sidecar', 'background_write_sidecar', 'background_migrate'];
|
||||
|
||||
Reference in New Issue
Block a user