@tano.page/workbench 0.14.0 → 0.16.0
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/package.json +50 -16
- package/src/App.vue +82 -752
- package/src/appearance/appearance.ts +14 -4
- package/src/appearance/components/ThemePresetPreview.vue +52 -8
- package/src/appearance/interface-font.ts +99 -0
- package/src/appearance/theme.ts +26 -10
- package/src/appearance/use-interface-font.ts +30 -0
- package/src/assets/mail-provider-icons/NOTICE.txt +27 -0
- package/src/assets/mail-provider-icons/aliyun-mail.svg +3 -0
- package/src/assets/mail-provider-icons/gmail.svg +1 -0
- package/src/assets/mail-provider-icons/icloud.svg +12 -0
- package/src/assets/mail-provider-icons/netease-126.svg +5 -0
- package/src/assets/mail-provider-icons/netease-163.svg +5 -0
- package/src/assets/mail-provider-icons/qq.svg +9 -0
- package/src/assets/mail-provider-icons/tencent-exmail.svg +4 -0
- package/src/assistant/agent-identities.ts +1 -97
- package/src/assistant/agent-task-context.ts +1 -54
- package/src/assistant/attachments.ts +1 -1
- package/src/assistant/completion.ts +1 -61
- package/src/assistant/components/AssistantChangeList.vue +98 -21
- package/src/assistant/components/AssistantPanel.vue +425 -8
- package/src/assistant/components/PluginToolProposalCard.vue +235 -0
- package/src/assistant/connection-actions.ts +237 -0
- package/src/assistant/document-mentions.ts +1 -33
- package/src/assistant/engine.ts +1 -532
- package/src/assistant/execution.ts +6 -33
- package/src/assistant/files.ts +5 -13
- package/src/assistant/hash.ts +1 -4
- package/src/assistant/inbox.ts +1 -148
- package/src/assistant/language.ts +10 -37
- package/src/assistant/mention-autocomplete.ts +69 -0
- package/src/assistant/plugin-bridge-builder.ts +146 -0
- package/src/assistant/prompts.ts +1 -58
- package/src/assistant/proposal-actions.ts +336 -0
- package/src/assistant/results.ts +20 -86
- package/src/assistant/store.ts +167 -327
- package/src/assistant/structures.ts +1 -155
- package/src/assistant/tasks.ts +8 -96
- package/src/assistant/tool-rules.ts +1 -7
- package/src/assistant/workspace-bridge.ts +1 -1
- package/src/composables/use-document-actions.ts +38 -20
- package/src/composables/use-file-tree-controller.ts +7 -12
- package/src/composables/use-workbench-help.ts +177 -0
- package/src/composables/use-workbench-history.ts +2 -4
- package/src/composables/use-workbench-lifecycle.ts +249 -0
- package/src/composables/use-workbench-modals.ts +6 -1
- package/src/composables/use-workbench-outline.ts +0 -5
- package/src/composables/use-workbench-settings.ts +185 -0
- package/src/composables/use-workbench-shortcuts.ts +40 -1021
- package/src/composables/use-workbench-views.ts +325 -0
- package/src/data-tables/data-tables.ts +1 -2
- package/src/documents/components/DocumentActionMenu.vue +279 -0
- package/src/documents/components/DocumentHistoryPanel.vue +3 -1
- package/src/documents/components/DocumentInspector.vue +168 -0
- package/src/documents/components/DocumentPane.vue +482 -0
- package/src/documents/description-merge.ts +1 -9
- package/src/features.ts +1 -0
- package/src/files/components/FileMetadataPanel.vue +49 -15
- package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
- package/src/fonts/Inter-Latin.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
- package/src/help/help-milestones.ts +3 -5
- package/src/i18n/locale-catalogs.ts +7 -6
- package/src/i18n/locale-registry.ts +8 -6
- package/src/i18n/locales/de-DE.json +371 -3
- package/src/i18n/locales/en-US.json +371 -2
- package/src/i18n/locales/es-ES.json +371 -3
- package/src/i18n/locales/ja-JP.json +370 -2
- package/src/i18n/locales/zh-TW.json +370 -2
- package/src/mail/components/MailAccountDialog.vue +450 -0
- package/src/mail/components/MailComposerDialog.vue +326 -0
- package/src/mail/components/MailProviderIcon.vue +30 -0
- package/src/mail/components/MailWorkspaceView.vue +821 -0
- package/src/mail/components/SidebarMail.vue +134 -0
- package/src/mail/mail-avatar.ts +17 -0
- package/src/mail/mail-bridge.ts +68 -0
- package/src/mail/mail-calendar.ts +208 -0
- package/src/mail/mail-markdown.ts +195 -0
- package/src/mail/types.ts +226 -0
- package/src/objects/components/ObjectDetailModal.vue +1001 -0
- package/src/objects/content-references.ts +6 -56
- package/src/objects/wiki-links.ts +1 -48
- package/src/objects/workspace-objects.ts +3 -4
- package/src/plan-sync/types.ts +6 -3
- package/src/plans/calendar-interaction.ts +194 -0
- package/src/plans/calendar.ts +65 -9
- package/src/plans/components/CalendarAgendaView.vue +165 -0
- package/src/plans/components/CalendarDayPopover.vue +172 -39
- package/src/plans/components/CalendarFilterBar.vue +128 -0
- package/src/plans/components/CalendarMonthView.vue +224 -0
- package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
- package/src/plans/components/CalendarTimelineView.vue +517 -0
- package/src/plans/components/CalendarTopbarControls.vue +101 -0
- package/src/plans/components/CalendarView.vue +264 -748
- package/src/plans/components/CalendarYearView.vue +138 -0
- package/src/plans/components/PlanArchiveDialog.vue +295 -0
- package/src/plans/components/PlanConnectionsDialog.vue +1 -1
- package/src/plans/components/PlanDateField.vue +6 -4
- package/src/plans/components/PlanDetailPanel.vue +227 -32
- package/src/plans/components/PlanEventList.vue +16 -4
- package/src/plans/components/SidebarPlan.vue +22 -15
- package/src/plans/components/TaskRepeatControls.vue +169 -30
- package/src/plans/components/calendar-shared.css +192 -0
- package/src/plans/composables/use-calendar-interactions.ts +396 -0
- package/src/plans/composables/use-calendar-scroll.ts +420 -0
- package/src/plans/local-reminders.ts +149 -0
- package/src/plans/personal-plans.ts +10 -1
- package/src/plans/plan-date.ts +8 -1
- package/src/plans/plan-migration.ts +95 -0
- package/src/plans/recurrence.ts +95 -0
- package/src/plans/task-repeat.ts +8 -8
- package/src/plans/timeline-layout.ts +92 -0
- package/src/plugins/assistant-bridge.ts +520 -0
- package/src/plugins/attachment-reader.ts +3 -1
- package/src/plugins/cache-storage.ts +42 -2
- package/src/plugins/components/PluginAutomations.vue +3 -3
- package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
- package/src/plugins/components/PluginChangeSummary.vue +16 -3
- package/src/plugins/components/PluginConnections.vue +1 -1
- package/src/plugins/components/PluginCustomView.vue +2 -2
- package/src/plugins/components/PluginDetailPage.vue +136 -57
- package/src/plugins/components/PluginDeveloperArea.vue +192 -0
- package/src/plugins/components/PluginDocumentSlot.vue +63 -0
- package/src/plugins/components/PluginExplorer.vue +21 -25
- package/src/plugins/components/PluginImportDialog.vue +410 -0
- package/src/plugins/components/PluginInstaller.vue +273 -288
- package/src/plugins/components/PluginListItem.vue +3 -0
- package/src/plugins/components/PluginMaintenance.vue +37 -34
- package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
- package/src/plugins/components/PluginRuntimePanel.vue +3 -3
- package/src/plugins/components/PluginSettingsForm.vue +112 -0
- package/src/plugins/components/PluginStatusBar.vue +161 -0
- package/src/plugins/components/PluginSurface.vue +18 -6
- package/src/plugins/components/PluginUiDialog.vue +452 -0
- package/src/plugins/components/PluginsTabPage.vue +61 -0
- package/src/plugins/components/plugin-center.css +5 -0
- package/src/plugins/data.ts +9 -86
- package/src/plugins/editor-plugin-adapters.ts +169 -0
- package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
- package/src/plugins/excalidraw/manifest.json +12 -1
- package/src/plugins/host.ts +662 -43
- package/src/plugins/native.ts +2 -10
- package/src/plugins/overlay-mapping.ts +125 -0
- package/src/plugins/packages.ts +73 -1
- package/src/plugins/plugin-data.ts +2 -3
- package/src/plugins/plugin-permissions.ts +57 -0
- package/src/plugins/plugin-rpc-router.ts +558 -0
- package/src/plugins/plugin-sdk.ts +1 -94
- package/src/plugins/plugin-ui-dialogs.ts +167 -0
- package/src/plugins/policy.ts +53 -3
- package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
- package/src/plugins/presentation-preview/manifest.json +2 -1
- package/src/plugins/queries.ts +1 -73
- package/src/plugins/sandbox.ts +15 -1
- package/src/plugins/use-plugin-actions.ts +67 -20
- package/src/plugins/user-plugins.ts +254 -0
- package/src/plugins/view-header.ts +2 -7
- package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
- package/src/plugins/word-preview/manifest.json +13 -1
- package/src/plugins/workbench.ts +175 -2
- package/src/plugins/worker.js +105 -8
- package/src/plugins/workspace-plugin-runtime.ts +23 -7
- package/src/plugins/workspace-plugins.ts +212 -21
- package/src/runtime.ts +103 -4
- package/src/settings/components/SettingsAppearancePage.vue +46 -0
- package/src/settings/components/SettingsDocumentsPage.vue +0 -1
- package/src/settings/components/SettingsPanel.vue +8 -3
- package/src/settings/components/WorkbenchSettings.vue +20 -7
- package/src/settings/components/settings-context.ts +1 -1
- package/src/settings/components/settings-search.ts +2 -3
- package/src/settings/settings-tab.ts +1 -0
- package/src/shell/command-palette.ts +3 -3
- package/src/shell/components/EditorToolbar.vue +8 -9
- package/src/shell/components/EditorTools.vue +1 -5
- package/src/shell/components/PaneTopbar.vue +393 -0
- package/src/shell/components/SelectionToolbar.vue +0 -2
- package/src/shell/components/SidebarNavigation.vue +22 -2
- package/src/shell/components/WorkbenchContextMenus.vue +58 -34
- package/src/shell/components/WorkbenchModals.vue +47 -62
- package/src/shell/components/WorkbenchPanes.vue +371 -1342
- package/src/shell/components/WorkbenchSidebar.vue +486 -0
- package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
- package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
- package/src/shell/pane-registry.ts +69 -0
- package/src/shell/use-surface-dismissal.ts +219 -0
- package/src/shell/use-workbench-commands.ts +599 -0
- package/src/shell/use-workbench-keybindings.ts +337 -0
- package/src/shell/use-workbench.ts +531 -1153
- package/src/shell/workbench-async-components.ts +14 -5
- package/src/shell/workbench-context.ts +30 -3
- package/src/stores/mail.ts +414 -0
- package/src/stores/plan-sync.ts +2 -1
- package/src/stores/plans.ts +2 -9
- package/src/stores/workspace-document-io.ts +807 -0
- package/src/stores/workspace-file-ops.ts +1 -1
- package/src/stores/workspace-knowledge.ts +2 -114
- package/src/stores/workspace-lifecycle.ts +459 -0
- package/src/stores/workspace-plugins-state.ts +254 -259
- package/src/stores/workspace-session.ts +287 -0
- package/src/stores/workspace-tabs-layout.ts +6 -44
- package/src/stores/workspace-types.ts +50 -0
- package/src/stores/workspace.ts +184 -1363
- package/src/styles/agent-diff-modals.css +0 -7
- package/src/styles/dark-theme.css +3 -3
- package/src/styles/inspector.css +0 -59
- package/src/styles/layout-themes.css +346 -0
- package/src/styles/mail.css +1568 -0
- package/src/styles/mobile.css +2 -2
- package/src/styles/recent-and-media.css +0 -17
- package/src/styles/theme-contract.css +3 -3
- package/src/styles/workbench-shell.css +110 -17
- package/src/styles/workspace-states.css +9 -33
- package/src/styles.css +0 -1
- package/src/tabs/components/DesktopTabs.vue +19 -14
- package/src/tabs/components/NewTabPicker.vue +10 -4
- package/src/tabs/tab-label.ts +0 -1
- package/src/windows/AuxiliaryWindows.vue +2 -2
- package/src/windows/use-window-event-bridge.ts +152 -0
- package/src/workspace/components/TemplateLibrary.vue +1 -1
- package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
- package/src/workspace/components/WorkspaceIconPicker.vue +30 -7
- package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
- package/src/workspace/workspace-comments.ts +11 -151
- package/src/workspace/workspace-welcome.ts +1 -1
- package/src/assistant/locales/de-DE.json +0 -126
- package/src/assistant/locales/en-US.json +0 -126
- package/src/assistant/locales/es-ES.json +0 -126
- package/src/assistant/locales/ja-JP.json +0 -126
- package/src/assistant/locales/zh-CN.json +0 -126
- package/src/assistant/locales/zh-TW.json +0 -126
- package/src/assistant/task-prompts.json +0 -39
- package/src/documents/components/FormulaMenu.vue +0 -50
- package/src/files/components/FileDatabasePage.vue +0 -152
- package/src/files/components/FolderHomeIcon.vue +0 -12
- package/src/objects/components/ObjectDatabasePage.vue +0 -100
- package/src/objects/components/ObjectPanel.vue +0 -554
- package/src/plans/components/PersonalPlanDialog.vue +0 -105
- package/src/shell/components/WorkspaceViewPage.vue +0 -127
- package/src/shell/components/WorkspaceViewTab.vue +0 -24
- package/src/styles/object-panel.css +0 -163
- package/src/workspace/components/GitInspectionPanel.vue +0 -35
- package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
- package/src/workspace/welcome-slogans.ts +0 -11
- package/src/workspace/workspace-git.ts +0 -35
- package/src/workspace/workspace-sync.ts +0 -46
- package/src/workspace/workspace-views.ts +0 -48
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { shallowRef } from 'vue';
|
|
2
|
+
import type {
|
|
3
|
+
PluginUiConfirmOptions,
|
|
4
|
+
PluginUiPickOptions,
|
|
5
|
+
PluginUiPromptOptions,
|
|
6
|
+
PluginUiTone,
|
|
7
|
+
} from '@tano/protocol';
|
|
8
|
+
|
|
9
|
+
export type PluginUiDialogRequest =
|
|
10
|
+
| {
|
|
11
|
+
id: string;
|
|
12
|
+
kind: 'pick';
|
|
13
|
+
pluginId: string;
|
|
14
|
+
pluginName: string;
|
|
15
|
+
options: PluginUiPickOptions;
|
|
16
|
+
}
|
|
17
|
+
| {
|
|
18
|
+
id: string;
|
|
19
|
+
kind: 'prompt';
|
|
20
|
+
pluginId: string;
|
|
21
|
+
pluginName: string;
|
|
22
|
+
options: PluginUiPromptOptions;
|
|
23
|
+
}
|
|
24
|
+
| {
|
|
25
|
+
id: string;
|
|
26
|
+
kind: 'confirm';
|
|
27
|
+
pluginId: string;
|
|
28
|
+
pluginName: string;
|
|
29
|
+
options: PluginUiConfirmOptions;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export interface PluginUiToastItem {
|
|
33
|
+
id: string;
|
|
34
|
+
pluginId: string;
|
|
35
|
+
pluginName: string;
|
|
36
|
+
message: string;
|
|
37
|
+
tone: PluginUiTone;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function createPluginUiDialogs() {
|
|
41
|
+
const activePluginDialog = shallowRef<PluginUiDialogRequest | null>(null);
|
|
42
|
+
const pluginToasts = shallowRef<PluginUiToastItem[]>([]);
|
|
43
|
+
const toastTimers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
44
|
+
|
|
45
|
+
let activeDialogControl: {
|
|
46
|
+
id: string;
|
|
47
|
+
resolve: (value: string | boolean | null) => void;
|
|
48
|
+
reject: (error: Error) => void;
|
|
49
|
+
cleanup: () => void;
|
|
50
|
+
} | null = null;
|
|
51
|
+
|
|
52
|
+
function cancelActivePluginDialog(reason = '插件交互已取消') {
|
|
53
|
+
const current = activeDialogControl;
|
|
54
|
+
if (!current) return;
|
|
55
|
+
activeDialogControl = null;
|
|
56
|
+
activePluginDialog.value = null;
|
|
57
|
+
current.cleanup();
|
|
58
|
+
current.reject(new Error(reason));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function resolvePluginDialog(id: string, value: string | boolean | null) {
|
|
62
|
+
const current = activeDialogControl;
|
|
63
|
+
if (!current || current.id !== id) return;
|
|
64
|
+
activeDialogControl = null;
|
|
65
|
+
activePluginDialog.value = null;
|
|
66
|
+
current.cleanup();
|
|
67
|
+
current.resolve(value);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function dismissPluginToast(id: string) {
|
|
71
|
+
const timer = toastTimers.get(id);
|
|
72
|
+
if (timer) {
|
|
73
|
+
clearTimeout(timer);
|
|
74
|
+
toastTimers.delete(id);
|
|
75
|
+
}
|
|
76
|
+
pluginToasts.value = pluginToasts.value.filter((item) => item.id !== id);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function clearPluginToasts() {
|
|
80
|
+
for (const timer of toastTimers.values()) clearTimeout(timer);
|
|
81
|
+
toastTimers.clear();
|
|
82
|
+
pluginToasts.value = [];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function showPluginToast(params: Record<string, unknown>) {
|
|
86
|
+
const id = crypto.randomUUID();
|
|
87
|
+
const item: PluginUiToastItem = {
|
|
88
|
+
id,
|
|
89
|
+
pluginId: String(params.pluginId ?? ''),
|
|
90
|
+
pluginName: String(params.pluginName ?? ''),
|
|
91
|
+
message: String(params.message ?? ''),
|
|
92
|
+
tone: (params.tone as PluginUiTone | undefined) ?? 'info',
|
|
93
|
+
};
|
|
94
|
+
const next = [...pluginToasts.value, item];
|
|
95
|
+
while (next.length > 3) {
|
|
96
|
+
const removed = next.shift();
|
|
97
|
+
if (removed) {
|
|
98
|
+
const timer = toastTimers.get(removed.id);
|
|
99
|
+
if (timer) {
|
|
100
|
+
clearTimeout(timer);
|
|
101
|
+
toastTimers.delete(removed.id);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
pluginToasts.value = next;
|
|
106
|
+
toastTimers.set(
|
|
107
|
+
id,
|
|
108
|
+
setTimeout(() => dismissPluginToast(id), 4500),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function openPluginDialog(
|
|
113
|
+
method: 'ui.pick' | 'ui.prompt' | 'ui.confirm',
|
|
114
|
+
params: Record<string, unknown>,
|
|
115
|
+
): Promise<string | boolean | null> {
|
|
116
|
+
if (activeDialogControl) {
|
|
117
|
+
return Promise.reject(new Error('当前已有插件交互弹窗正在等待响应,请稍后重试'));
|
|
118
|
+
}
|
|
119
|
+
const id = crypto.randomUUID();
|
|
120
|
+
const signal = params.signal instanceof AbortSignal ? params.signal : undefined;
|
|
121
|
+
if (signal?.aborted) return Promise.reject(new Error('插件已停止'));
|
|
122
|
+
return new Promise<string | boolean | null>((resolve, reject) => {
|
|
123
|
+
const onAbort = () => cancelActivePluginDialog('插件已停止');
|
|
124
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
125
|
+
const cleanup = () => signal?.removeEventListener('abort', onAbort);
|
|
126
|
+
activeDialogControl = { id, resolve, reject, cleanup };
|
|
127
|
+
const pluginId = String(params.pluginId ?? '');
|
|
128
|
+
const pluginName = String(params.pluginName ?? '');
|
|
129
|
+
if (method === 'ui.pick') {
|
|
130
|
+
activePluginDialog.value = {
|
|
131
|
+
id,
|
|
132
|
+
kind: 'pick',
|
|
133
|
+
pluginId,
|
|
134
|
+
pluginName,
|
|
135
|
+
options: params.options as PluginUiPickOptions,
|
|
136
|
+
};
|
|
137
|
+
} else if (method === 'ui.prompt') {
|
|
138
|
+
activePluginDialog.value = {
|
|
139
|
+
id,
|
|
140
|
+
kind: 'prompt',
|
|
141
|
+
pluginId,
|
|
142
|
+
pluginName,
|
|
143
|
+
options: params.options as PluginUiPromptOptions,
|
|
144
|
+
};
|
|
145
|
+
} else {
|
|
146
|
+
activePluginDialog.value = {
|
|
147
|
+
id,
|
|
148
|
+
kind: 'confirm',
|
|
149
|
+
pluginId,
|
|
150
|
+
pluginName,
|
|
151
|
+
options: params.options as PluginUiConfirmOptions,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
activePluginDialog,
|
|
159
|
+
pluginToasts,
|
|
160
|
+
cancelActivePluginDialog,
|
|
161
|
+
resolvePluginDialog,
|
|
162
|
+
dismissPluginToast,
|
|
163
|
+
clearPluginToasts,
|
|
164
|
+
showPluginToast,
|
|
165
|
+
openPluginDialog,
|
|
166
|
+
};
|
|
167
|
+
}
|
package/src/plugins/policy.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { canonicalPluginJson, parsePluginPolicy, workspacePluginPath } from '@tano/protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
FileSnapshot,
|
|
4
|
+
Workspace,
|
|
5
|
+
WorkspaceAdapter,
|
|
6
|
+
WorkspacePersonalPluginPolicy,
|
|
7
|
+
WorkspacePluginPolicy,
|
|
8
|
+
WorkspacePluginRule,
|
|
9
|
+
} from '@tano/protocol';
|
|
3
10
|
|
|
4
11
|
export interface PluginPolicySnapshot { snapshot: FileSnapshot | null; policy: WorkspacePluginPolicy }
|
|
5
12
|
export function canManageWorkspacePlugins(adapter: WorkspaceAdapter, workspace: Workspace) {
|
|
@@ -25,7 +32,7 @@ export async function savePluginRule(adapter: WorkspaceAdapter, base: PluginPoli
|
|
|
25
32
|
if (!original || !latest || !desired) conflict = !equal(original, latest) && !equal(latest, desired);
|
|
26
33
|
else {
|
|
27
34
|
merged = structuredClone(latest);
|
|
28
|
-
for (const field of ['manifest', 'mode', 'integrity', 'sourceUrl', 'settings', 'history'] as const) {
|
|
35
|
+
for (const field of ['manifest', 'mode', 'integrity', 'sourceUrl', 'settings', 'pathScopes', 'history'] as const) {
|
|
29
36
|
if (equal(original[field], desired[field])) continue;
|
|
30
37
|
if (!equal(original[field], latest[field]) && !equal(desired[field], latest[field])) { conflict = true; break; }
|
|
31
38
|
Object.assign(merged, { [field]: desired[field] });
|
|
@@ -38,7 +45,11 @@ export async function savePluginRule(adapter: WorkspaceAdapter, base: PluginPoli
|
|
|
38
45
|
await adapter.create(path, JSON.stringify(proposed, null, 2) + '\n');
|
|
39
46
|
throw new Error(`插件规则已被其他人修改;你的版本已保存在 ${path},请刷新后比较。`);
|
|
40
47
|
}
|
|
41
|
-
const policy = parsePluginPolicy(JSON.stringify({
|
|
48
|
+
const policy = parsePluginPolicy(JSON.stringify({
|
|
49
|
+
version: 1,
|
|
50
|
+
...(current.policy.personalCodePlugins ? { personalCodePlugins: current.policy.personalCodePlugins } : {}),
|
|
51
|
+
plugins: [...current.policy.plugins.filter(row => row.manifest.id !== id), ...(merged ? [merged] : [])],
|
|
52
|
+
}));
|
|
42
53
|
const content = JSON.stringify(policy, null, 2) + '\n';
|
|
43
54
|
assertCurrent();
|
|
44
55
|
if (current.snapshot) {
|
|
@@ -61,3 +72,42 @@ export async function savePluginRule(adapter: WorkspaceAdapter, base: PluginPoli
|
|
|
61
72
|
}
|
|
62
73
|
throw new Error('插件规则正在持续变化,请刷新后重试');
|
|
63
74
|
}
|
|
75
|
+
|
|
76
|
+
export async function saveWorkspacePersonalPluginPolicy(
|
|
77
|
+
adapter: WorkspaceAdapter,
|
|
78
|
+
base: PluginPolicySnapshot,
|
|
79
|
+
personalCodePlugins: WorkspacePersonalPluginPolicy,
|
|
80
|
+
assertCurrent: () => void,
|
|
81
|
+
): Promise<PluginPolicySnapshot> {
|
|
82
|
+
let current = base;
|
|
83
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
84
|
+
assertCurrent();
|
|
85
|
+
const policy = parsePluginPolicy(
|
|
86
|
+
JSON.stringify({
|
|
87
|
+
version: 1,
|
|
88
|
+
...(personalCodePlugins !== 'allow' ? { personalCodePlugins } : {}),
|
|
89
|
+
plugins: current.policy.plugins,
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
const content = JSON.stringify(policy, null, 2) + '\n';
|
|
93
|
+
if (current.snapshot) {
|
|
94
|
+
const result = await adapter.write(workspacePluginPath, content, current.snapshot.hash);
|
|
95
|
+
if (result.status === 'saved') return { policy, snapshot: result.snapshot };
|
|
96
|
+
if (result.status === 'missing') throw new Error('工作区插件规则已被移除,请刷新后重试');
|
|
97
|
+
current = { snapshot: result.snapshot, policy: parsePluginPolicy(result.snapshot.content) };
|
|
98
|
+
} else {
|
|
99
|
+
try {
|
|
100
|
+
await adapter.create(workspacePluginPath, content);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
assertCurrent();
|
|
103
|
+
let snapshot: FileSnapshot;
|
|
104
|
+
try { snapshot = await adapter.read(workspacePluginPath); } catch { throw error; }
|
|
105
|
+
current = { snapshot, policy: parsePluginPolicy(snapshot.content) };
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const snapshot = await adapter.read(workspacePluginPath);
|
|
109
|
+
return { snapshot, policy: parsePluginPolicy(snapshot.content) };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
throw new Error('插件规则正在持续变化,请刷新后重试');
|
|
113
|
+
}
|