@tano.page/workbench 0.15.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.
Files changed (118) hide show
  1. package/package.json +35 -14
  2. package/src/App.vue +68 -797
  3. package/src/assistant/agent-identities.ts +1 -97
  4. package/src/assistant/agent-task-context.ts +1 -54
  5. package/src/assistant/attachments.ts +1 -1
  6. package/src/assistant/completion.ts +1 -61
  7. package/src/assistant/components/AssistantPanel.vue +1 -1
  8. package/src/assistant/connection-actions.ts +237 -0
  9. package/src/assistant/document-mentions.ts +1 -33
  10. package/src/assistant/engine.ts +1 -585
  11. package/src/assistant/execution.ts +6 -33
  12. package/src/assistant/hash.ts +1 -4
  13. package/src/assistant/language.ts +10 -37
  14. package/src/assistant/plugin-bridge-builder.ts +146 -0
  15. package/src/assistant/prompts.ts +1 -65
  16. package/src/assistant/proposal-actions.ts +336 -0
  17. package/src/assistant/store.ts +87 -554
  18. package/src/assistant/structures.ts +1 -157
  19. package/src/assistant/tasks.ts +8 -94
  20. package/src/assistant/tool-rules.ts +1 -7
  21. package/src/composables/use-workbench-help.ts +177 -0
  22. package/src/composables/use-workbench-lifecycle.ts +249 -0
  23. package/src/composables/use-workbench-settings.ts +185 -0
  24. package/src/composables/use-workbench-shortcuts.ts +37 -1022
  25. package/src/composables/use-workbench-views.ts +325 -0
  26. package/src/documents/components/DocumentActionMenu.vue +279 -0
  27. package/src/documents/components/DocumentInspector.vue +168 -0
  28. package/src/documents/components/DocumentPane.vue +482 -0
  29. package/src/documents/description-merge.ts +1 -9
  30. package/src/files/components/FileMetadataPanel.vue +49 -15
  31. package/src/i18n/locale-catalogs.ts +7 -6
  32. package/src/i18n/locale-registry.ts +8 -6
  33. package/src/i18n/locales/de-DE.json +23 -1
  34. package/src/i18n/locales/en-US.json +23 -1
  35. package/src/i18n/locales/es-ES.json +23 -1
  36. package/src/i18n/locales/ja-JP.json +23 -1
  37. package/src/i18n/locales/zh-TW.json +23 -1
  38. package/src/mail/components/MailAccountDialog.vue +1 -0
  39. package/src/mail/components/MailComposerDialog.vue +1 -0
  40. package/src/mail/components/MailWorkspaceView.vue +1 -0
  41. package/src/mail/components/SidebarMail.vue +1 -0
  42. package/src/objects/content-references.ts +6 -56
  43. package/src/objects/wiki-links.ts +1 -48
  44. package/src/objects/workspace-objects.ts +2 -3
  45. package/src/plans/calendar.ts +2 -2
  46. package/src/plans/components/CalendarAgendaView.vue +165 -0
  47. package/src/plans/components/CalendarFilterBar.vue +128 -0
  48. package/src/plans/components/CalendarMonthView.vue +224 -0
  49. package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
  50. package/src/plans/components/CalendarTimelineView.vue +517 -0
  51. package/src/plans/components/CalendarTopbarControls.vue +101 -0
  52. package/src/plans/components/CalendarView.vue +162 -2106
  53. package/src/plans/components/CalendarYearView.vue +138 -0
  54. package/src/plans/components/PlanConnectionsDialog.vue +1 -1
  55. package/src/plans/components/calendar-shared.css +192 -0
  56. package/src/plans/composables/use-calendar-interactions.ts +396 -0
  57. package/src/plans/composables/use-calendar-scroll.ts +420 -0
  58. package/src/plugins/components/PluginDetailPage.vue +10 -6
  59. package/src/plugins/components/PluginDeveloperArea.vue +192 -0
  60. package/src/plugins/components/PluginExplorer.vue +6 -4
  61. package/src/plugins/components/PluginImportDialog.vue +1 -1
  62. package/src/plugins/components/PluginInstaller.vue +269 -178
  63. package/src/plugins/components/PluginMaintenance.vue +37 -49
  64. package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
  65. package/src/plugins/components/PluginSettingsForm.vue +2 -1
  66. package/src/plugins/components/PluginsTabPage.vue +61 -0
  67. package/src/plugins/components/plugin-center.css +5 -0
  68. package/src/plugins/data.ts +9 -86
  69. package/src/plugins/editor-plugin-adapters.ts +169 -0
  70. package/src/plugins/plugin-data.ts +2 -3
  71. package/src/plugins/plugin-rpc-router.ts +558 -0
  72. package/src/plugins/plugin-sdk.ts +1 -260
  73. package/src/plugins/plugin-ui-dialogs.ts +167 -0
  74. package/src/plugins/queries.ts +1 -75
  75. package/src/plugins/view-header.ts +2 -7
  76. package/src/runtime.ts +3 -2
  77. package/src/settings/components/SettingsPanel.vue +8 -3
  78. package/src/settings/components/WorkbenchSettings.vue +20 -7
  79. package/src/settings/components/settings-context.ts +1 -1
  80. package/src/settings/settings-tab.ts +1 -0
  81. package/src/shell/command-palette.ts +3 -3
  82. package/src/shell/components/EditorToolbar.vue +8 -9
  83. package/src/shell/components/EditorTools.vue +1 -5
  84. package/src/shell/components/PaneTopbar.vue +393 -0
  85. package/src/shell/components/SelectionToolbar.vue +0 -2
  86. package/src/shell/components/WorkbenchContextMenus.vue +37 -26
  87. package/src/shell/components/WorkbenchModals.vue +22 -18
  88. package/src/shell/components/WorkbenchPanes.vue +358 -1512
  89. package/src/shell/components/WorkbenchSidebar.vue +486 -0
  90. package/src/shell/pane-registry.ts +69 -0
  91. package/src/shell/use-surface-dismissal.ts +219 -0
  92. package/src/shell/use-workbench-commands.ts +599 -0
  93. package/src/shell/use-workbench-keybindings.ts +337 -0
  94. package/src/shell/use-workbench.ts +488 -1081
  95. package/src/shell/workbench-context.ts +30 -3
  96. package/src/stores/workspace-document-io.ts +807 -0
  97. package/src/stores/workspace-file-ops.ts +1 -1
  98. package/src/stores/workspace-knowledge.ts +1 -1
  99. package/src/stores/workspace-lifecycle.ts +459 -0
  100. package/src/stores/workspace-plugins-state.ts +71 -599
  101. package/src/stores/workspace-session.ts +287 -0
  102. package/src/stores/workspace-tabs-layout.ts +1 -1
  103. package/src/stores/workspace-types.ts +50 -0
  104. package/src/stores/workspace.ts +163 -1345
  105. package/src/styles.css +0 -1
  106. package/src/tabs/components/DesktopTabs.vue +19 -11
  107. package/src/windows/AuxiliaryWindows.vue +2 -2
  108. package/src/windows/use-window-event-bridge.ts +152 -0
  109. package/src/workspace/components/TemplateLibrary.vue +1 -1
  110. package/src/workspace/components/WorkspaceIconPicker.vue +5 -4
  111. package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
  112. package/src/assistant/locales/de-DE.json +0 -129
  113. package/src/assistant/locales/en-US.json +0 -129
  114. package/src/assistant/locales/es-ES.json +0 -129
  115. package/src/assistant/locales/ja-JP.json +0 -129
  116. package/src/assistant/locales/zh-CN.json +0 -129
  117. package/src/assistant/locales/zh-TW.json +0 -129
  118. package/src/assistant/task-prompts.json +0 -39
@@ -0,0 +1,420 @@
1
+ import { computed, nextTick, onMounted, onUnmounted, ref, watch, type ComputedRef, type Ref } from 'vue';
2
+ import {
3
+ localDayKey,
4
+ shiftCalendarDate,
5
+ visibleCalendarDays,
6
+ weekDays,
7
+ type CalendarViewMode,
8
+ } from '../calendar';
9
+
10
+ export const CALENDAR_HOUR_HEIGHT = 56;
11
+
12
+ const ZOOM_MODES: CalendarViewMode[] = ['day', 'four-days', 'week', 'month', 'year'];
13
+
14
+ export interface CalendarScrollOptions {
15
+ date: () => Date;
16
+ mode: () => CalendarViewMode;
17
+ scroll: Ref<HTMLElement | undefined>;
18
+ window: Window;
19
+ onVisibleMonth: (date: Date) => void;
20
+ onVisibleYear: (date: Date) => void;
21
+ onVisibleTimeline: (date: Date) => void;
22
+ onSelectMode: (mode: CalendarViewMode) => void;
23
+ onBeforeViewChange: () => void;
24
+ onScrolled: () => void;
25
+ }
26
+
27
+ export interface CalendarScrollState {
28
+ timeline: ComputedRef<boolean>;
29
+ timelineDays: Ref<Date[]>;
30
+ timelineDayWidth: Ref<number>;
31
+ timelineVisibleCount: ComputedRef<number>;
32
+ scrollingWeeks: Ref<Date[]>;
33
+ scrollingYears: Ref<number[]>;
34
+ visibleWindow: ComputedRef<[Date, Date]>;
35
+ onCalendarScroll: () => void;
36
+ onCalendarWheel: (event: WheelEvent) => void;
37
+ }
38
+
39
+ export function useCalendarScroll(options: CalendarScrollOptions): CalendarScrollState {
40
+ const { date: getDate, mode: getMode, scroll, window } = options;
41
+ const ResizeObserverCtor = (window as Window & typeof globalThis).ResizeObserver;
42
+
43
+ const timeline = computed(() => {
44
+ const mode = getMode();
45
+ return mode === 'day' || mode === 'four-days' || mode === 'week';
46
+ });
47
+ const timelineDays = ref<Date[]>([]);
48
+ const timelineDayWidth = ref(120);
49
+ const timelineVisibleCount = computed(() => {
50
+ const mode = getMode();
51
+ return mode === 'week' ? 7 : mode === 'four-days' ? 4 : 1;
52
+ });
53
+ const scrollingWeeks = ref<Date[]>([]);
54
+ const scrollingYears = ref<number[]>([]);
55
+
56
+ const visibleWindow = computed<[Date, Date]>(() => {
57
+ if (timeline.value && timelineDays.value.length) {
58
+ return [timelineDays.value[0]!, timelineDays.value.at(-1)!];
59
+ }
60
+ if (getMode() === 'month' && scrollingWeeks.value.length) {
61
+ const last = scrollingWeeks.value.at(-1)!;
62
+ return [scrollingWeeks.value[0]!, new Date(last.getFullYear(), last.getMonth(), last.getDate() + 6)];
63
+ }
64
+ if (getMode() === 'year' && scrollingYears.value.length) {
65
+ return [new Date(scrollingYears.value[0]!, 0, 1), new Date(scrollingYears.value.at(-1)!, 11, 31)];
66
+ }
67
+ const current = getDate();
68
+ return [
69
+ new Date(current.getFullYear(), current.getMonth(), 1),
70
+ new Date(current.getFullYear(), current.getMonth() + 1, 0),
71
+ ];
72
+ });
73
+
74
+ const monthKey = (d: Date) => `${d.getFullYear()}-${d.getMonth()}`;
75
+ const weekKey = localDayKey;
76
+ const weekOffset = (d: Date, weeks: number) =>
77
+ new Date(d.getFullYear(), d.getMonth(), d.getDate() + weeks * 7);
78
+ const dayOffset = (d: Date, days: number) =>
79
+ new Date(d.getFullYear(), d.getMonth(), d.getDate() + days);
80
+
81
+ let reportedMonthKey = '';
82
+ let extendingWeeks = false;
83
+ let reportedYear: number | undefined;
84
+ let extendingYears = false;
85
+ let positioningYear = false;
86
+ let reportedTimelineKey = '';
87
+ let extendingTimeline = false;
88
+ let positioningTimeline = false;
89
+ let timelineResizeObserver: ResizeObserver | undefined;
90
+
91
+ let zoomDelta = 0;
92
+ let lastZoomWheel = -Infinity;
93
+ let lastZoomChange = -Infinity;
94
+
95
+ function fillTimelineDays(d: Date) {
96
+ const first = visibleCalendarDays(d, getMode())[0]!;
97
+ timelineDays.value = Array.from({ length: 42 }, (_, index) => dayOffset(first, index - 14));
98
+ }
99
+
100
+ async function scrollToTimelineDate(d: Date) {
101
+ positioningTimeline = true;
102
+ const first = visibleCalendarDays(d, getMode())[0]!;
103
+ let index = timelineDays.value.findIndex((day) => localDayKey(day) === localDayKey(first));
104
+ if (index < 0) {
105
+ fillTimelineDays(d);
106
+ index = 14;
107
+ }
108
+ await nextTick();
109
+ if (scroll.value) scroll.value.scrollLeft = index * timelineDayWidth.value;
110
+ positioningTimeline = false;
111
+ }
112
+
113
+ async function extendTimelineDays(direction: -1 | 1) {
114
+ const container = scroll.value;
115
+ if (extendingTimeline || !container || !timelineDays.value.length) return;
116
+ extendingTimeline = true;
117
+ const width = timelineDayWidth.value;
118
+ const anchorIndex = Math.min(timelineDays.value.length - 1, Math.floor(container.scrollLeft / width));
119
+ const anchorKey = localDayKey(timelineDays.value[anchorIndex]!);
120
+ const anchorOffset = container.scrollLeft - anchorIndex * width;
121
+ const edge = direction < 0 ? timelineDays.value[0]! : timelineDays.value.at(-1)!;
122
+ const additions = Array.from({ length: 14 }, (_, index) => dayOffset(edge, direction * (index + 1)));
123
+ const expanded = direction < 0
124
+ ? [...additions.reverse(), ...timelineDays.value]
125
+ : [...timelineDays.value, ...additions];
126
+ timelineDays.value = direction < 0 ? expanded.slice(0, 70) : expanded.slice(-70);
127
+ await nextTick();
128
+ const retainedIndex = timelineDays.value.findIndex((day) => localDayKey(day) === anchorKey);
129
+ if (retainedIndex >= 0) container.scrollLeft = retainedIndex * width + anchorOffset;
130
+ extendingTimeline = false;
131
+ }
132
+
133
+ function onTimelineScroll() {
134
+ const container = scroll.value;
135
+ if (!timeline.value || !container || !timelineDays.value.length || positioningTimeline || extendingTimeline) return;
136
+ const width = timelineDayWidth.value;
137
+ const index = Math.min(timelineDays.value.length - 1, Math.max(0, Math.round(container.scrollLeft / width)));
138
+ const visible = timelineDays.value[index]!;
139
+ const mode = getMode();
140
+ const d = visibleCalendarDays(visible, mode)[0]!;
141
+ const key = localDayKey(d);
142
+ if (key !== localDayKey(visibleCalendarDays(getDate(), mode)[0]!)) {
143
+ reportedTimelineKey = key;
144
+ options.onVisibleTimeline(d);
145
+ }
146
+ const edgeDistance = Math.max(container.clientWidth, width * 2);
147
+ if (container.scrollLeft < edgeDistance)
148
+ void extendTimelineDays(-1);
149
+ else if (container.scrollWidth - container.scrollLeft - container.clientWidth < edgeDistance)
150
+ void extendTimelineDays(1);
151
+ }
152
+
153
+ function onCalendarWheel(event: WheelEvent) {
154
+ const mode = getMode();
155
+ if (event.ctrlKey) {
156
+ // Keep browser zoom disabled here, even at the smallest/largest calendar scale.
157
+ event.preventDefault();
158
+ event.stopPropagation();
159
+ if (!event.deltaY || Math.abs(event.deltaX) > Math.abs(event.deltaY)) return;
160
+ const now = performance.now();
161
+ if (now - lastZoomWheel > 200 || Math.sign(zoomDelta) !== Math.sign(event.deltaY)) zoomDelta = 0;
162
+ lastZoomWheel = now;
163
+ if (now - lastZoomChange < 200) return;
164
+ const unit = event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? scroll.value?.clientHeight || 800 : 1;
165
+ zoomDelta += event.deltaY * unit;
166
+ if (Math.abs(zoomDelta) < 40) return;
167
+ // The agenda lists one month, so zoom from the same scale as the month grid.
168
+ const index = ZOOM_MODES.indexOf(mode === 'agenda' ? 'month' : mode);
169
+ const nextMode = ZOOM_MODES[Math.max(0, Math.min(ZOOM_MODES.length - 1, index + Math.sign(zoomDelta)))]!;
170
+ zoomDelta = 0;
171
+ if (nextMode !== mode) {
172
+ lastZoomChange = now;
173
+ options.onSelectMode(nextMode);
174
+ }
175
+ return;
176
+ }
177
+ zoomDelta = 0;
178
+ if (!timeline.value || !event.shiftKey || !scroll.value) return;
179
+ event.preventDefault();
180
+ const delta = Math.abs(event.deltaX) > Math.abs(event.deltaY) ? event.deltaX : event.deltaY;
181
+ scroll.value.scrollLeft += delta * Math.max(1, timelineDayWidth.value / 360);
182
+ }
183
+
184
+ async function resizeTimeline() {
185
+ const container = scroll.value;
186
+ if (!timeline.value || !container) return;
187
+ const width = Math.max(90, (container.clientWidth - 64) / timelineVisibleCount.value);
188
+ if (Math.abs(width - timelineDayWidth.value) < 0.5) return;
189
+ const dayPosition = container.scrollLeft / timelineDayWidth.value;
190
+ positioningTimeline = true;
191
+ timelineDayWidth.value = width;
192
+ await nextTick();
193
+ container.scrollLeft = dayPosition * width;
194
+ positioningTimeline = false;
195
+ }
196
+
197
+ function fillWeeks(d: Date) {
198
+ const monday = weekDays(d)[0]!;
199
+ scrollingWeeks.value = Array.from({ length: 37 }, (_, index) => weekOffset(monday, index - 18));
200
+ }
201
+
202
+ function weekRow(d: Date) {
203
+ const key = weekKey(weekDays(d)[0]!);
204
+ return [...(scroll.value?.querySelectorAll<HTMLElement>('.calendar-month-week') ?? [])]
205
+ .find((row) => row.dataset.week === key);
206
+ }
207
+
208
+ async function scrollToWeek(d: Date) {
209
+ // Month navigation lands on the week holding the 1st, so the whole month is
210
+ // in view and the dominant-month check in onMonthScroll agrees with it.
211
+ const monthStart = new Date(d.getFullYear(), d.getMonth(), 1);
212
+ const key = weekKey(weekDays(monthStart)[0]!);
213
+ if (!scrollingWeeks.value.some((week) => weekKey(week) === key)) fillWeeks(monthStart);
214
+ await nextTick();
215
+ const container = scroll.value;
216
+ const row = weekRow(monthStart);
217
+ if (!container || !row) return;
218
+ container.scrollTop += row.getBoundingClientRect().top - container.getBoundingClientRect().top - 40;
219
+ }
220
+
221
+ async function extendWeeks(direction: -1 | 1) {
222
+ if (extendingWeeks || !scroll.value || !scrollingWeeks.value.length) return;
223
+ extendingWeeks = true;
224
+ const container = scroll.value;
225
+ const anchor = [...container.querySelectorAll<HTMLElement>('.calendar-month-week')]
226
+ .find((row) => row.getBoundingClientRect().bottom > container.getBoundingClientRect().top + 80);
227
+ const anchorKey = anchor?.dataset.week;
228
+ const anchorTop = anchor?.getBoundingClientRect().top;
229
+ const edge = direction < 0 ? scrollingWeeks.value[0]! : scrollingWeeks.value.at(-1)!;
230
+ const additions = Array.from({ length: 8 }, (_, index) => weekOffset(edge, direction * (index + 1)));
231
+ const expanded = direction < 0
232
+ ? [...additions.reverse(), ...scrollingWeeks.value]
233
+ : [...scrollingWeeks.value, ...additions];
234
+ scrollingWeeks.value = direction < 0 ? expanded.slice(0, 85) : expanded.slice(-85);
235
+ await nextTick();
236
+ const retained = [...container.querySelectorAll<HTMLElement>('.calendar-month-week')]
237
+ .find((row) => row.dataset.week === anchorKey);
238
+ if (retained && anchorTop !== undefined)
239
+ container.scrollTop += retained.getBoundingClientRect().top - anchorTop;
240
+ extendingWeeks = false;
241
+ }
242
+
243
+ function onMonthScroll() {
244
+ const container = scroll.value;
245
+ if (getMode() !== 'month' || !container || !scrollingWeeks.value.length || extendingWeeks) return;
246
+ const bounds = container.getBoundingClientRect();
247
+ const viewTop = bounds.top + (container.querySelector<HTMLElement>('.calendar-month-weekdays')?.offsetHeight ?? 0);
248
+ const area = new Map<string, { month: Date; size: number }>();
249
+ for (const row of container.querySelectorAll<HTMLElement>('.calendar-month-week')) {
250
+ const rect = row.getBoundingClientRect();
251
+ const size = Math.min(rect.bottom, bounds.bottom) - Math.max(rect.top, viewTop);
252
+ if (size <= 0) continue;
253
+ const week = scrollingWeeks.value.find((item) => weekKey(item) === row.dataset.week);
254
+ if (!week) continue;
255
+ for (const day of weekDays(week)) {
256
+ const key = monthKey(day);
257
+ const entry = area.get(key) ?? { month: day, size: 0 };
258
+ entry.size += size;
259
+ area.set(key, entry);
260
+ }
261
+ }
262
+ const current = getDate();
263
+ let visibleMonth: Date | undefined;
264
+ let best = (area.get(monthKey(current))?.size ?? 0) * 1.15;
265
+ for (const { month, size } of area.values())
266
+ if (size > best) { best = size; visibleMonth = month; }
267
+ if (visibleMonth && monthKey(visibleMonth) !== monthKey(current)) {
268
+ reportedMonthKey = monthKey(visibleMonth);
269
+ options.onVisibleMonth(new Date(visibleMonth.getFullYear(), visibleMonth.getMonth(), 1));
270
+ }
271
+ if (container.scrollTop < container.clientHeight)
272
+ void extendWeeks(-1);
273
+ else if (container.scrollHeight - container.scrollTop - container.clientHeight < container.clientHeight)
274
+ void extendWeeks(1);
275
+ }
276
+
277
+ function fillYears(d: Date) {
278
+ const year = d.getFullYear();
279
+ scrollingYears.value = [year - 1, year, year + 1];
280
+ }
281
+
282
+ function yearSection(year: number) {
283
+ return [...(scroll.value?.querySelectorAll<HTMLElement>('.calendar-year-section') ?? [])]
284
+ .find((section) => Number(section.dataset.year) === year);
285
+ }
286
+
287
+ async function scrollToYear(d: Date) {
288
+ const year = d.getFullYear();
289
+ positioningYear = true;
290
+ if (!scrollingYears.value.includes(year)) fillYears(d);
291
+ await nextTick();
292
+ const container = scroll.value;
293
+ const section = yearSection(year);
294
+ if (container && section)
295
+ container.scrollTop += section.getBoundingClientRect().top - container.getBoundingClientRect().top - 12;
296
+ positioningYear = false;
297
+ }
298
+
299
+ async function extendYears(direction: -1 | 1) {
300
+ if (extendingYears || !scroll.value || !scrollingYears.value.length) return;
301
+ extendingYears = true;
302
+ const container = scroll.value;
303
+ const anchor = [...container.querySelectorAll<HTMLElement>('.calendar-year-section')]
304
+ .find((section) => section.getBoundingClientRect().bottom > container.getBoundingClientRect().top + 60);
305
+ const anchorYear = Number(anchor?.dataset.year);
306
+ const anchorTop = anchor?.getBoundingClientRect().top;
307
+ const nextYear = direction < 0 ? scrollingYears.value[0]! - 1 : scrollingYears.value.at(-1)! + 1;
308
+ const expanded = direction < 0
309
+ ? [nextYear, ...scrollingYears.value]
310
+ : [...scrollingYears.value, nextYear];
311
+ scrollingYears.value = direction < 0 ? expanded.slice(0, 5) : expanded.slice(-5);
312
+ await nextTick();
313
+ const retained = yearSection(anchorYear);
314
+ if (retained && anchorTop !== undefined)
315
+ container.scrollTop += retained.getBoundingClientRect().top - anchorTop;
316
+ extendingYears = false;
317
+ }
318
+
319
+ function onYearScroll() {
320
+ const container = scroll.value;
321
+ if (getMode() !== 'year' || !container || !scrollingYears.value.length || extendingYears || positioningYear) return;
322
+ const marker = container.getBoundingClientRect().top + 60;
323
+ const section = [...container.querySelectorAll<HTMLElement>('.calendar-year-section')]
324
+ .find((element) => element.getBoundingClientRect().bottom > marker);
325
+ const year = Number(section?.dataset.year);
326
+ const current = getDate();
327
+ if (section && year !== current.getFullYear()) {
328
+ reportedYear = year;
329
+ options.onVisibleYear(shiftCalendarDate(current, 'year', year - current.getFullYear()));
330
+ }
331
+ const edgeDistance = Math.min(400, container.clientHeight / 2);
332
+ if (container.scrollTop < edgeDistance)
333
+ void extendYears(-1);
334
+ else if (container.scrollHeight - container.scrollTop - container.clientHeight < edgeDistance)
335
+ void extendYears(1);
336
+ }
337
+
338
+ function onCalendarScroll() {
339
+ options.onScrolled();
340
+ if (timeline.value) onTimelineScroll();
341
+ else if (getMode() === 'month') onMonthScroll();
342
+ else if (getMode() === 'year') onYearScroll();
343
+ }
344
+
345
+ async function positionTimeline() {
346
+ await nextTick();
347
+ if (!timeline.value && scroll.value) scroll.value.scrollLeft = 0;
348
+ const current = getDate();
349
+ if (timeline.value) {
350
+ const container = scroll.value;
351
+ if (!container) return;
352
+ timelineDayWidth.value = Math.max(90, (container.clientWidth - 64) / timelineVisibleCount.value);
353
+ fillTimelineDays(current);
354
+ await scrollToTimelineDate(current);
355
+ container.scrollTop = CALENDAR_HOUR_HEIGHT * 7;
356
+ } else if (getMode() === 'month') {
357
+ fillWeeks(current);
358
+ await scrollToWeek(current);
359
+ } else if (getMode() === 'year') {
360
+ fillYears(current);
361
+ await scrollToYear(current);
362
+ } else if (scroll.value) {
363
+ scroll.value.scrollTop = 0;
364
+ }
365
+ }
366
+
367
+ onMounted(() => {
368
+ void positionTimeline();
369
+ if (scroll.value && typeof ResizeObserverCtor !== 'undefined') {
370
+ timelineResizeObserver = new ResizeObserverCtor(() => { void resizeTimeline(); });
371
+ timelineResizeObserver.observe(scroll.value);
372
+ }
373
+ });
374
+
375
+ onUnmounted(() => {
376
+ timelineResizeObserver?.disconnect();
377
+ });
378
+
379
+ watch(getMode, () => {
380
+ options.onBeforeViewChange();
381
+ void positionTimeline();
382
+ });
383
+
384
+ watch(getDate, (nextDate) => {
385
+ options.onBeforeViewChange();
386
+ const mode = getMode();
387
+ if (mode === 'month') {
388
+ if (reportedMonthKey === monthKey(nextDate)) {
389
+ reportedMonthKey = '';
390
+ return;
391
+ }
392
+ void scrollToWeek(nextDate);
393
+ } else if (mode === 'year') {
394
+ if (reportedYear === nextDate.getFullYear()) {
395
+ reportedYear = undefined;
396
+ return;
397
+ }
398
+ void scrollToYear(nextDate);
399
+ } else if (timeline.value) {
400
+ const key = localDayKey(visibleCalendarDays(nextDate, mode)[0]!);
401
+ if (reportedTimelineKey === key) {
402
+ reportedTimelineKey = '';
403
+ return;
404
+ }
405
+ void scrollToTimelineDate(nextDate);
406
+ }
407
+ });
408
+
409
+ return {
410
+ timeline,
411
+ timelineDays,
412
+ timelineDayWidth,
413
+ timelineVisibleCount,
414
+ scrollingWeeks,
415
+ scrollingYears,
416
+ visibleWindow,
417
+ onCalendarScroll,
418
+ onCalendarWheel,
419
+ };
420
+ }
@@ -1,8 +1,10 @@
1
1
  <script setup lang="ts">
2
- import { computed, ref, watch } from 'vue';
2
+ import './plugin-center.css';
3
+ import { computed, inject, ref, watch } from 'vue';
3
4
  import { ArrowUpRight, Download, LoaderCircle, ShieldCheck } from 'lucide-vue-next';
4
5
  import { checkPluginCompatibility, type PluginMode } from '@tano/protocol';
5
6
  import { t } from '../../i18n/i18n';
7
+ import { workbenchPrefsKey } from '../../shell/workbench-context';
6
8
  import { useWorkspaceStore } from '../../stores/workspace';
7
9
  import { bundledPluginCatalog } from '../plugin-catalog';
8
10
  import { pluginPermissionLabels as permissionLabels } from '../plugin-permissions';
@@ -11,7 +13,9 @@ import { usePluginActions } from '../use-plugin-actions';
11
13
  import PluginIcon from './PluginIcon.vue';
12
14
  import PluginMaintenance from './PluginMaintenance.vue';
13
15
  import PluginSettingsForm from './PluginSettingsForm.vue';
14
- const props = defineProps<{ pluginId: string }>();
16
+ const props = defineProps<{ pluginId: string; developerMode?: boolean }>();
17
+ const workbench = inject(workbenchPrefsKey, null);
18
+ const isDeveloperMode = computed(() => props.developerMode ?? Boolean(workbench?.developerMode));
15
19
  const store = useWorkspaceStore();
16
20
  const detail = computed(
17
21
  () =>
@@ -280,7 +284,7 @@ const modeLabels: Record<PluginMode, string> = {
280
284
  >
281
285
  <h4>{{ t('全局插件设置') }}</h4>
282
286
  <p>{{ t('此插件为全局安装,跨工作区生效;设置保存在当前设备的应用数据中,不写入工作区文件。') }}</p>
283
- <PluginSettingsForm v-if="settingsSchema?.length" v-model="settingsText" :schema="settingsSchema" :disabled="busy" />
287
+ <PluginSettingsForm v-if="settingsSchema?.length" v-model="settingsText" :schema="settingsSchema" :disabled="busy" :developer-mode="isDeveloperMode" />
284
288
  <label v-else
285
289
  >{{ t('个人设置')
286
290
  }}<textarea
@@ -325,7 +329,7 @@ const modeLabels: Record<PluginMode, string> = {
325
329
  <option value="disabled">{{ t('禁止') }}</option>
326
330
  </select></label
327
331
  >
328
- <PluginSettingsForm v-if="settingsSchema?.length" v-model="settingsText" :schema="settingsSchema" :disabled="busy" />
332
+ <PluginSettingsForm v-if="settingsSchema?.length" v-model="settingsText" :schema="settingsSchema" :disabled="busy" :developer-mode="isDeveloperMode" />
329
333
  <label v-else
330
334
  >{{ t('共享设置')
331
335
  }}<textarea
@@ -345,7 +349,7 @@ const modeLabels: Record<PluginMode, string> = {
345
349
  spellcheck="false"
346
350
  />
347
351
  </label>
348
- <label v-if="detail.manifestVersion === 2"
352
+ <label v-if="detail.manifestVersion === 2 && isDeveloperMode"
349
353
  >{{ t('插件包 HTTPS 地址(可选)')
350
354
  }}<input v-model="sourceUrl" :aria-label="t('插件包下载地址')" type="url"
351
355
  /></label>
@@ -362,6 +366,7 @@ const modeLabels: Record<PluginMode, string> = {
362
366
  <PluginMaintenance
363
367
  v-if="selectedInstallation && !selectedInstallation.system && detail.manifestVersion === 2"
364
368
  :id="detail.id"
369
+ :developer-mode="isDeveloperMode"
365
370
  />
366
371
  <p class="detail-scope">
367
372
  <ShieldCheck :size="17" /><span
@@ -398,7 +403,6 @@ const modeLabels: Record<PluginMode, string> = {
398
403
  </section>
399
404
  </article>
400
405
  </template>
401
- <style scoped src="./plugin-center.css"></style>
402
406
  <style scoped>
403
407
  .plugin-detail-page {
404
408
  padding: 28px;
@@ -0,0 +1,192 @@
1
+ <script setup lang="ts">
2
+ import { ref, useSlots, watch } from 'vue';
3
+ import { Code2, Hammer, Send, Square, Upload } from 'lucide-vue-next';
4
+ import { t } from '../../i18n/i18n';
5
+ import { useWorkspaceStore } from '../../stores/workspace';
6
+ import PluginRepositoryStorage from './PluginRepositoryStorage.vue';
7
+
8
+ const props = defineProps<{
9
+ canPublish?: boolean;
10
+ initialSection?: 'tools' | 'forge' | 'publishing';
11
+ }>();
12
+ const emit = defineEmits<{
13
+ openImport: [];
14
+ }>();
15
+
16
+ const slots = useSlots();
17
+ const store = useWorkspaceStore();
18
+
19
+ type DevSection = 'tools' | 'forge' | 'publishing';
20
+ const section = ref<DevSection>(props.initialSection ?? 'tools');
21
+ const publishingOpened = ref(props.initialSection === 'publishing');
22
+
23
+ watch(
24
+ () => props.initialSection,
25
+ (next) => {
26
+ if (!next) return;
27
+ chooseSection(next);
28
+ },
29
+ );
30
+
31
+ function chooseSection(next: DevSection) {
32
+ if (next === 'forge' && !slots.forge) return;
33
+ if (next === 'publishing' && !slots.publishing) return;
34
+ if (next === 'publishing') publishingOpened.value = true;
35
+ section.value = next;
36
+ }
37
+
38
+ defineExpose({ chooseSection });
39
+ </script>
40
+
41
+ <template>
42
+ <section class="plugin-developer-area" :aria-label="t('插件开发者区')">
43
+ <nav v-if="$slots.forge || $slots.publishing" class="dev-subnav" :aria-label="t('开发者工具导航')">
44
+ <button
45
+ type="button"
46
+ :class="{ active: section === 'tools' }"
47
+ :aria-pressed="section === 'tools'"
48
+ @click="chooseSection('tools')"
49
+ >
50
+ <Code2 :size="14" aria-hidden="true" />{{ t('导入与调试') }}
51
+ </button>
52
+ <button
53
+ v-if="$slots.forge"
54
+ type="button"
55
+ :class="{ active: section === 'forge' }"
56
+ :aria-pressed="section === 'forge'"
57
+ @click="chooseSection('forge')"
58
+ >
59
+ <Hammer :size="14" aria-hidden="true" />{{ t('插件工坊') }}
60
+ </button>
61
+ <button
62
+ v-if="$slots.publishing"
63
+ type="button"
64
+ :class="{ active: section === 'publishing' }"
65
+ :aria-pressed="section === 'publishing'"
66
+ @click="chooseSection('publishing')"
67
+ >
68
+ <Send :size="14" aria-hidden="true" />{{ t('我的投稿') }}
69
+ </button>
70
+ </nav>
71
+
72
+ <div v-if="section === 'tools'" class="dev-tools-panel">
73
+ <div class="dev-card">
74
+ <div class="dev-card-copy">
75
+ <h3>{{ t('导入本地插件包') }}</h3>
76
+ <p>{{ t('导入 .tano-plugin.zip 归档包或声明式 JSON 清单,也可载入内置示例或仅缓存到当前设备用于调试。') }}</p>
77
+ </div>
78
+ <button type="button" class="pc-button pc-primary" :aria-label="t('导入插件')" @click="emit('openImport')">
79
+ <Upload :size="15" aria-hidden="true" />{{ t('导入插件包…') }}
80
+ </button>
81
+ </div>
82
+
83
+ <div v-if="store.pluginDevelopment.active" class="dev-card dev-watch-card" role="status">
84
+ <div class="dev-card-copy">
85
+ <h3>{{ t('本地开发监听运行中') }}</h3>
86
+ <p>
87
+ <code>{{ store.pluginDevelopment.pluginId }}</code> · {{ store.pluginDevelopment.message }}
88
+ </p>
89
+ </div>
90
+ <div class="dev-card-actions">
91
+ <button
92
+ v-if="store.pluginDevelopment.pluginId"
93
+ type="button"
94
+ class="pc-button pc-secondary"
95
+ @click="store.openPluginDetail(store.pluginDevelopment.pluginId)"
96
+ >
97
+ {{ t('查看详情') }}
98
+ </button>
99
+ <button
100
+ type="button"
101
+ class="pc-button pc-secondary"
102
+ @click="store.stopPluginDevelopment()"
103
+ >
104
+ <Square :size="13" aria-hidden="true" />{{ t('停止自动重载') }}
105
+ </button>
106
+ </div>
107
+ </div>
108
+
109
+ <PluginRepositoryStorage />
110
+ </div>
111
+
112
+ <div v-if="$slots.forge && section === 'forge'" class="dev-slot-panel">
113
+ <slot
114
+ name="forge"
115
+ :can-publish="Boolean(canPublish && $slots.publishing)"
116
+ :developer-mode="true"
117
+ :open-publishing="() => chooseSection('publishing')"
118
+ />
119
+ </div>
120
+
121
+ <div v-if="$slots.publishing && publishingOpened" v-show="section === 'publishing'" class="dev-slot-panel">
122
+ <slot name="publishing" :developer-mode="true" />
123
+ </div>
124
+ </section>
125
+ </template>
126
+
127
+ <style scoped>
128
+ .plugin-developer-area {
129
+ display: grid;
130
+ gap: 16px;
131
+ }
132
+ .dev-subnav {
133
+ display: flex;
134
+ flex-wrap: wrap;
135
+ gap: 8px;
136
+ }
137
+ .dev-subnav button {
138
+ display: inline-flex;
139
+ align-items: center;
140
+ gap: 6px;
141
+ padding: 6px 12px;
142
+ border: 1px solid var(--line);
143
+ border-radius: 999px;
144
+ background: var(--paper);
145
+ color: var(--muted);
146
+ font: inherit;
147
+ font-size: 12.5px;
148
+ cursor: pointer;
149
+ }
150
+ .dev-subnav button.active {
151
+ color: var(--text);
152
+ border-color: var(--text);
153
+ background: var(--surface);
154
+ font-weight: 500;
155
+ }
156
+ .dev-tools-panel {
157
+ display: grid;
158
+ gap: 12px;
159
+ }
160
+ .dev-card {
161
+ display: flex;
162
+ align-items: center;
163
+ justify-content: space-between;
164
+ gap: 16px;
165
+ flex-wrap: wrap;
166
+ padding: 16px 18px;
167
+ border: 1px solid var(--line);
168
+ border-radius: 10px;
169
+ background: var(--surface);
170
+ }
171
+ .dev-card-copy {
172
+ display: grid;
173
+ gap: 4px;
174
+ min-width: 0;
175
+ }
176
+ .dev-card-copy h3 {
177
+ margin: 0;
178
+ font-size: 14px;
179
+ font-weight: 600;
180
+ color: var(--text);
181
+ }
182
+ .dev-card-copy p {
183
+ margin: 0;
184
+ font-size: 12.5px;
185
+ color: var(--muted);
186
+ }
187
+ .dev-card-actions {
188
+ display: flex;
189
+ align-items: center;
190
+ gap: 8px;
191
+ }
192
+ </style>