@xiongtao.xt/tau-plugins 0.59.0 → 0.61.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 (53) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/client/chunk-UGYIAPAN.js +869 -0
  3. package/docs/README.md +1 -0
  4. package/docs/backend.md +4 -10
  5. package/docs/blog-templates.md +7 -6
  6. package/docs/document-body.md +2 -0
  7. package/docs/editor-interactions.md +55 -0
  8. package/docs/getting-started.md +2 -14
  9. package/docs/plugin-basics.md +1 -1
  10. package/docs/portability.md +26 -2
  11. package/docs/skills.md +10 -12
  12. package/docs/task-data.md +338 -0
  13. package/docs/user-data.md +12 -17
  14. package/docs/whiteboard.md +1 -1
  15. package/package.js +1 -1
  16. package/package.json +5 -1
  17. package/portable.js +3 -2
  18. package/publish-artifacts.js +51 -27
  19. package/types/packages/collaboration/src/node-tree.d.ts +7 -0
  20. package/types/packages/collaboration/src/whiteboard-model.d.ts +33 -2
  21. package/types/packages/plugins/src/contract.d.ts +2 -0
  22. package/types/packages/plugins/src/data-changes.d.ts +51 -0
  23. package/types/packages/plugins/src/data.d.ts +112 -7
  24. package/types/packages/plugins/src/errors.d.ts +7 -0
  25. package/types/packages/plugins/src/index.d.ts +2 -1
  26. package/types/packages/plugins/src/package.d.ts +7 -2
  27. package/types/packages/plugins/src/portable.d.ts +5 -2
  28. package/types/packages/plugins/src/skills.d.ts +16 -0
  29. package/types/packages/plugins/src/template.d.ts +101 -0
  30. package/types/packages/plugins/src/text-decorations.d.ts +68 -0
  31. package/types/packages/plugins/src/unified.d.ts +60 -0
  32. package/types/packages/plugins/src/version.d.ts +5 -0
  33. package/types/packages/shared/src/task-assistant/contracts.d.ts +15 -0
  34. package/types/packages/shared/src/task-assistant/occurrence-state.d.ts +7 -0
  35. package/types/packages/shared/src/task-assistant/schema.d.ts +3 -0
  36. package/types/packages/shared/task-assistant.d.ts +1 -0
  37. package/types/packages/ui/src/hooks/useEdgeFade.d.ts +1 -1
  38. package/types/packages/ui/src/primitives/AnchoredPanel.d.ts +3 -1
  39. package/types/packages/ui/src/primitives/anchoredPosition.d.ts +8 -0
  40. package/types/packages/whiteboard/src/Board.d.ts +20 -6
  41. package/types/packages/whiteboard/src/chrome/index.d.ts +3 -1
  42. package/types/packages/whiteboard/src/constants/tools.d.ts +3 -0
  43. package/types/packages/whiteboard/src/context.d.ts +1 -2
  44. package/types/packages/whiteboard/src/extensions/api.d.ts +6 -1
  45. package/types/packages/whiteboard/src/hooks/useZoom.d.ts +6 -0
  46. package/types/packages/whiteboard/src/index.d.ts +1 -0
  47. package/types/packages/whiteboard/src/interactions/InteractionManager.d.ts +1 -0
  48. package/types/packages/whiteboard/src/plugins/MindPlugin.d.ts +1 -0
  49. package/types/packages/whiteboard/src/types/board.d.ts +2 -0
  50. package/types/packages/whiteboard/src/utils/GeometryUtil.d.ts +1 -1
  51. package/unified.js +21 -0
  52. package/client/chunk-6XAEU7BJ.js +0 -330
  53. package/client/chunk-PRE35AOA.js +0 -185
@@ -1,11 +1,9 @@
1
- import {
2
- PORTABLE_SHARED_MODULES,
3
- validatePortablePluginManifest
4
- } from "./client/chunk-PRE35AOA.js";
5
1
  import {
6
2
  PLUGIN_SHARED_MODULES,
7
- validatePluginManifest
8
- } from "./client/chunk-6XAEU7BJ.js";
3
+ PORTABLE_SHARED_MODULES,
4
+ isWebPluginManifest,
5
+ readApplicationPluginManifest
6
+ } from "./client/chunk-UGYIAPAN.js";
9
7
  import {
10
8
  __commonJS,
11
9
  __toESM
@@ -1629,7 +1627,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
1629
1627
  },
1630
1628
  [subscribe, value, getSnapshot]
1631
1629
  );
1632
- useEffect24(
1630
+ useEffect25(
1633
1631
  function() {
1634
1632
  checkIfSnapshotChanged(inst) && forceUpdate({ inst });
1635
1633
  return subscribe(function() {
@@ -1655,7 +1653,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
1655
1653
  return getSnapshot();
1656
1654
  }
1657
1655
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1658
- var React6 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState34 = React6.useState, useEffect24 = React6.useEffect, useLayoutEffect9 = React6.useLayoutEffect, useDebugValue2 = React6.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
1656
+ var React6 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState34 = React6.useState, useEffect25 = React6.useEffect, useLayoutEffect9 = React6.useLayoutEffect, useDebugValue2 = React6.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
1659
1657
  exports.useSyncExternalStore = void 0 !== React6.useSyncExternalStore ? React6.useSyncExternalStore : shim;
1660
1658
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1661
1659
  })();
@@ -1683,7 +1681,7 @@ var require_with_selector_development = __commonJS({
1683
1681
  return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
1684
1682
  }
1685
1683
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1686
- var React6 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore2 = shim.useSyncExternalStore, useRef34 = React6.useRef, useEffect24 = React6.useEffect, useMemo8 = React6.useMemo, useDebugValue2 = React6.useDebugValue;
1684
+ var React6 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore2 = shim.useSyncExternalStore, useRef34 = React6.useRef, useEffect25 = React6.useEffect, useMemo8 = React6.useMemo, useDebugValue2 = React6.useDebugValue;
1687
1685
  exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual2) {
1688
1686
  var instRef = useRef34(null);
1689
1687
  if (null === instRef.current) {
@@ -1726,7 +1724,7 @@ var require_with_selector_development = __commonJS({
1726
1724
  [getSnapshot, getServerSnapshot, selector, isEqual2]
1727
1725
  );
1728
1726
  var value = useSyncExternalStore2(subscribe, instRef[0], instRef[1]);
1729
- useEffect24(
1727
+ useEffect25(
1730
1728
  function() {
1731
1729
  inst.hasValue = true;
1732
1730
  inst.value = value;
@@ -5395,7 +5393,7 @@ function useScrollState(el) {
5395
5393
  const resizeObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measureOnRaf);
5396
5394
  resizeObserver?.observe(el);
5397
5395
  const mutationObserver = typeof MutationObserver === "undefined" ? null : new MutationObserver(measureOnRaf);
5398
- mutationObserver?.observe(el, { childList: true, subtree: true });
5396
+ mutationObserver?.observe(el, { childList: true, subtree: true, characterData: true });
5399
5397
  return () => {
5400
5398
  cancelAnimationFrame(rafId);
5401
5399
  el.removeEventListener("scroll", measureSync);
@@ -7090,6 +7088,16 @@ var VIEWPORT_PAD = 8;
7090
7088
  var ARROW_MARGIN = 10;
7091
7089
  var ARROW_SIZE = 8;
7092
7090
  var ARROW_TIP_OFFSET = 5;
7091
+ function fitVerticalPreview(anchor, placement, viewportHeight, gap = 8) {
7092
+ if (!placement.startsWith("top") && !placement.startsWith("bottom")) return;
7093
+ const above = anchor.top - VIEWPORT_PAD - gap;
7094
+ const below = viewportHeight - VIEWPORT_PAD - gap - anchor.bottom;
7095
+ const side = above === below ? placement.split("-")[0] : above > below ? "top" : "bottom";
7096
+ return {
7097
+ placement: placement.replace(/^(top|bottom)/, side),
7098
+ maxHeight: Math.max(0, Math.floor(Math.max(above, below)))
7099
+ };
7100
+ }
7093
7101
  function computeAnchoredPosition(anchor, pop, placement, opts) {
7094
7102
  const GAP2 = opts?.gap ?? 8;
7095
7103
  const [side0, align = "center"] = placement.split("-");
@@ -7204,6 +7212,7 @@ function useAnchoredPosition({
7204
7212
  popRef,
7205
7213
  placement,
7206
7214
  gap,
7215
+ fitVerticalSpace = false,
7207
7216
  pollAnchor = false,
7208
7217
  onPlace
7209
7218
  }) {
@@ -7215,13 +7224,16 @@ function useAnchoredPosition({
7215
7224
  if (!open) return;
7216
7225
  const pop = popRef.current;
7217
7226
  if (!pop) return;
7227
+ const originalMaxHeight = pop.style.maxHeight;
7218
7228
  const place = () => {
7219
7229
  const anchor = getAnchorRef.current();
7220
7230
  if (!anchor) return;
7231
+ const fit = fitVerticalSpace && fitVerticalPreview(anchor, placement, window.innerHeight, gap);
7232
+ if (fit) pop.style.maxHeight = `${fit.maxHeight}px`;
7221
7233
  const pos = computeAnchoredPosition(
7222
7234
  anchor,
7223
7235
  pop,
7224
- placement,
7236
+ fit ? fit.placement : placement,
7225
7237
  gap !== void 0 ? { gap } : void 0
7226
7238
  );
7227
7239
  pop.style.left = `${pos.x}px`;
@@ -7230,12 +7242,11 @@ function useAnchoredPosition({
7230
7242
  };
7231
7243
  place();
7232
7244
  place();
7233
- let queued = false;
7245
+ let frame = 0;
7234
7246
  const schedule = () => {
7235
- if (queued) return;
7236
- queued = true;
7237
- requestAnimationFrame(() => {
7238
- queued = false;
7247
+ if (frame) return;
7248
+ frame = requestAnimationFrame(() => {
7249
+ frame = 0;
7239
7250
  place();
7240
7251
  });
7241
7252
  };
@@ -7261,9 +7272,11 @@ function useAnchoredPosition({
7261
7272
  window.removeEventListener("scroll", schedule, true);
7262
7273
  window.removeEventListener("resize", schedule);
7263
7274
  ro?.disconnect();
7275
+ cancelAnimationFrame(frame);
7276
+ if (fitVerticalSpace) pop.style.maxHeight = originalMaxHeight;
7264
7277
  cancelAnimationFrame(raf);
7265
7278
  };
7266
- }, [open, placement, gap, pollAnchor]);
7279
+ }, [open, placement, gap, pollAnchor, fitVerticalSpace]);
7267
7280
  }
7268
7281
 
7269
7282
  // packages/ui/src/primitives/Tooltip.tsx
@@ -7601,6 +7614,7 @@ function MenuSurface({
7601
7614
  "aria-activedescendant": nav.current ?? void 0,
7602
7615
  "data-open": open,
7603
7616
  onKeyDown,
7617
+ onClick: (e2) => e2.stopPropagation(),
7604
7618
  className: cn(
7605
7619
  "bg-surface border-line-1 shadow-float rounded-tau-lg border p-[6px]",
7606
7620
  "fixed left-0 top-0 z-[250] flex w-max min-w-[160px] max-w-[min(320px,calc(100vw-16px))] flex-col overflow-hidden",
@@ -7956,6 +7970,7 @@ var PanelHasHeaderContext = (0, import_react32.createContext)(null);
7956
7970
  function AnchoredPanel({
7957
7971
  anchor,
7958
7972
  placement = "bottom-start",
7973
+ fitVerticalSpace = false,
7959
7974
  open,
7960
7975
  arrow = false,
7961
7976
  className,
@@ -7971,6 +7986,7 @@ function AnchoredPanel({
7971
7986
  getAnchor: () => anchor?.getBoundingClientRect() ?? null,
7972
7987
  popRef,
7973
7988
  placement,
7989
+ fitVerticalSpace,
7974
7990
  onPlace: (pos, pop) => {
7975
7991
  pop.dataset.side = pos.side;
7976
7992
  if (arrow) applyArrowPosition(pos, pop);
@@ -7993,6 +8009,7 @@ function AnchoredPanel({
7993
8009
  !visible && "data-[side=top]:-translate-y-[4px]",
7994
8010
  !visible && "data-[side=left]:-translate-x-[4px]",
7995
8011
  !visible && "data-[side=right]:translate-x-[4px]",
8012
+ fitVerticalSpace && "overflow-y-auto",
7996
8013
  className
7997
8014
  ),
7998
8015
  children: [
@@ -8108,10 +8125,17 @@ function Popover({
8108
8125
  const card = cardRef.current;
8109
8126
  if (!card) return;
8110
8127
  const target = card.querySelector("[data-autofocus]") ?? card;
8111
- try {
8112
- target.focus({ preventScroll: true });
8113
- } catch {
8114
- }
8128
+ const focus = () => {
8129
+ try {
8130
+ target.focus({ preventScroll: true });
8131
+ } catch {
8132
+ }
8133
+ };
8134
+ focus();
8135
+ const raf = requestAnimationFrame(() => {
8136
+ if (card.ownerDocument.activeElement !== target) focus();
8137
+ });
8138
+ return () => cancelAnimationFrame(raf);
8115
8139
  }, [open]);
8116
8140
  const hasHeader = import_react36.Children.toArray(children).some(
8117
8141
  (c2) => (0, import_react36.isValidElement)(c2) && c2.type === PopoverHeader
@@ -9405,11 +9429,11 @@ function normalizePluginEditorExtension(extension) {
9405
9429
  // packages/plugins/src/rendering.ts
9406
9430
  var PLUGIN_RENDER_VERSION = 1;
9407
9431
  function readPublishedPluginManifest(value) {
9408
- return value?.formatVersion === 3 ? validatePortablePluginManifest(value) : validatePluginManifest(value);
9432
+ return readApplicationPluginManifest(value);
9409
9433
  }
9410
9434
  function evaluatePublishedPluginPackage(artifact, modules) {
9411
9435
  const manifest = readPublishedPluginManifest(artifact.manifest);
9412
- if (manifest.formatVersion !== 3)
9436
+ if (!isWebPluginManifest(manifest))
9413
9437
  return evaluatePluginPackage({ ...artifact, manifest }, modules);
9414
9438
  if (!manifest.targets.desktop) throw new Error("\u535A\u5BA2\u6E32\u67D3\u9700\u8981\u684C\u9762\u76EE\u6807");
9415
9439
  const definition = evaluateModule(manifest, artifact.code, modules, PORTABLE_SHARED_MODULES);
@@ -9421,7 +9445,7 @@ function evaluatePluginPackage(artifact, modules) {
9421
9445
  manifest,
9422
9446
  artifact.code,
9423
9447
  modules,
9424
- manifest.formatVersion === 3 ? PORTABLE_SHARED_MODULES : PLUGIN_SHARED_MODULES
9448
+ isWebPluginManifest(manifest) ? PORTABLE_SHARED_MODULES : PLUGIN_SHARED_MODULES
9425
9449
  );
9426
9450
  }
9427
9451
  function evaluateModule(manifest, code, modules, allowed) {
@@ -9446,9 +9470,9 @@ function evaluateModule(manifest, code, modules, allowed) {
9446
9470
  function validatePluginDefinition(manifest, definition) {
9447
9471
  if (!definition || typeof definition.create !== "function" || definition.id !== manifest.id || definition.name !== manifest.name || definition.version !== manifest.version || definition.apiVersion !== manifest.apiVersion)
9448
9472
  throw new Error("\u63D2\u4EF6\u5165\u53E3\u5B9A\u4E49\u4E0E\u6E05\u5355\u4E0D\u4E00\u81F4");
9449
- if (manifest.formatVersion !== 3 && Boolean(definition.editorExtensions?.length) !== Boolean(manifest.editor))
9473
+ if (manifest.formatVersion === 2 && Boolean(definition.editorExtensions?.length) !== Boolean(manifest.editor))
9450
9474
  throw new Error("\u7F16\u8F91\u5668\u8D21\u732E\u5FC5\u987B\u4E0E manifest.editor \u58F0\u660E\u4E00\u81F4");
9451
- if (manifest.formatVersion !== 3 && Boolean(definition.whiteboardExtensions?.length) !== Boolean(manifest.whiteboard))
9475
+ if (manifest.formatVersion === 2 && Boolean(definition.whiteboardExtensions?.length) !== Boolean(manifest.whiteboard))
9452
9476
  throw new Error("\u767D\u677F\u8D21\u732E\u5FC5\u987B\u4E0E manifest.whiteboard \u58F0\u660E\u4E00\u81F4");
9453
9477
  definition = {
9454
9478
  ...definition,
@@ -27,6 +27,13 @@ export interface TreeSpan {
27
27
  source: string | null;
28
28
  segment?: string;
29
29
  }
30
+ export interface NodeTextEdit {
31
+ nodeId: string;
32
+ offset: number;
33
+ text: string;
34
+ action: "insert" | "remove";
35
+ marks: Record<string, unknown>;
36
+ }
30
37
  export interface NodeTreeOptions {
31
38
  rootId?: string;
32
39
  }
@@ -1,9 +1,9 @@
1
1
  import { WhiteboardPresentations } from "./whiteboard-presentation";
2
2
  import * as Y from "yjs";
3
3
  import { type PreparedWhiteboardContract, type PreparedContentContract, type ContentContractDictionary, type DataContract } from "../../db-schema/content-contracts";
4
- import { NodeTree } from "./node-tree";
4
+ import { NodeTree, type NodeTextEdit } from "./node-tree";
5
5
  import { NodeTreeHistory, type NodeTreeHistoryOptions } from "./node-tree-history";
6
- import type { WhiteboardModelCommand, WhiteboardReference, WhiteboardSnapshot } from "./whiteboard-types";
6
+ import type { WhiteboardElementSnapshot, WhiteboardGeometry, WhiteboardModelCommand, WhiteboardReference, WhiteboardSnapshot } from "./whiteboard-types";
7
7
  /** 纯协作模型;宿主负责权限、耐久会话和插件版本保护,模型不连接画布。 */
8
8
  export declare class WhiteboardModel {
9
9
  readonly doc: Y.Doc;
@@ -21,7 +21,10 @@ export declare class WhiteboardModel {
21
21
  private readonly histories;
22
22
  private disposed;
23
23
  private revision;
24
+ private translationBudget?;
24
25
  private pending?;
26
+ /** 缺依赖期间复用已提交状态的编码,每份输入仍在独立候选上校验。 */
27
+ private pendingBase?;
25
28
  private queuedBytes;
26
29
  private incoming;
27
30
  private readonly changed;
@@ -48,15 +51,28 @@ export declare class WhiteboardModel {
48
51
  preflightHistory(history: NodeTreeHistory, direction: "undo" | "redo"): void;
49
52
  private preparedAdditions;
50
53
  withPreparedContracts(prepared: readonly (PreparedWhiteboardContract | PreparedContentContract)[], write: (model: WhiteboardModel) => void, origin: unknown): void;
54
+ /** 普通文本只修改已有段落的字符;结构变更、复杂标记与容量临界由完整候选处理。 */
55
+ tryLocalBodyEdit(target: string, edit: NodeTextEdit, origin: object): {
56
+ isolated: boolean;
57
+ } | undefined;
51
58
  /** 大批导入分段预检,最终以一个增量进入当前视图历史。 */
52
59
  submitChunks(commands: readonly WhiteboardModelCommand[], origin: unknown, prepared?: readonly (PreparedWhiteboardContract | PreparedContentContract)[], initialBodies?: readonly {
53
60
  id: string;
54
61
  preserveIds?: boolean;
55
62
  body: readonly import("./protocol").ContentNode[];
56
63
  }[]): void;
64
+ /** 为已打开的画布准备位置提交。无法证明基线有效时,调用方仍使用完整的隔离候选。 */
65
+ prepareLocalTranslations(): void;
66
+ /** 仅平移一个现有标量几何。返回 undefined 时没有写入,由调用方执行原有预检。 */
67
+ tryLocalTranslation(target: string, value: WhiteboardGeometry, origin: unknown): {
68
+ isolated: boolean;
69
+ } | undefined;
70
+ /** 笔迹只在页根创建父笔与分段。用同契约、同父级的小候选预演原命令。 */
71
+ private strokeTrial;
57
72
  /** 在隔离副本中验证整批及编码大小,失败不改变真实文档或撤销栈。 */
58
73
  submit(commands: readonly WhiteboardModelCommand[], origin: unknown, prepared?: readonly (PreparedWhiteboardContract | PreparedContentContract)[]): {
59
74
  readonly createdIds: readonly string[];
75
+ readonly isolatedStroke?: true;
60
76
  };
61
77
  private execute;
62
78
  private initialize;
@@ -69,8 +85,21 @@ export declare class WhiteboardModel {
69
85
  private erase;
70
86
  private edit;
71
87
  private executeOne;
88
+ private elementUsage;
72
89
  private assertBudget;
73
90
  private validateState;
91
+ private visiblePageReferences;
92
+ readElementIdentity(target: string): {
93
+ type: string;
94
+ contractId: string;
95
+ } | undefined;
96
+ readSummary(): {
97
+ title: string;
98
+ pageCount: number;
99
+ };
100
+ private snapshotElement;
101
+ /** 绑定在已隔离的追加事务后复用同一笔的前缀。 */
102
+ readAppendedStroke(id: string, segmentId: string, prefix: readonly WhiteboardElementSnapshot[]): WhiteboardElementSnapshot;
74
103
  read(): WhiteboardSnapshot;
75
104
  /** 服务端校验完整候选,已有记录的物理身份不能被普通更新替换。 */
76
105
  validate(previous?: WhiteboardModel): Promise<void>;
@@ -80,6 +109,8 @@ export declare class WhiteboardModel {
80
109
  }>;
81
110
  /** 将未接纳的缺依赖材料交还宿主保全;不能在接收仍进行时清空。 */
82
111
  takePendingUpdate(): Uint8Array | undefined;
112
+ /** 已有结构和删除均被覆盖时,增量不会改变文档。需要打开富文本根的校验仍使用隔离候选。 */
113
+ private isReadOnlyReplay;
83
114
  private receiveNow;
84
115
  private assertStableRecords;
85
116
  }
@@ -1,3 +1,4 @@
1
+ import type { PluginTextDecorations } from "./text-decorations";
1
2
  import type { PluginWindowDefinition, PluginWindows } from "./windows";
2
3
  import type { PluginPages } from "./pages";
3
4
  import type { PluginEnvironment } from "./environment";
@@ -83,6 +84,7 @@ export interface PluginContext {
83
84
  readonly home: PluginHome;
84
85
  /** 对象动作:卡片、文章、项目文档「⋯」菜单里的条目 */
85
86
  readonly actions: PluginActions;
87
+ readonly textDecorations?: PluginTextDecorations;
86
88
  /** 卡片、文章、项目文档详情里的区块 */
87
89
  readonly views: PluginViews;
88
90
  /** Notebook 的生成菜单里加产物;只在桌面主窗口 */
@@ -0,0 +1,51 @@
1
+ export declare const DATA_CHANGE_DOMAINS: readonly ["todo", "todo-list", "event", "calendar"];
2
+ export type PluginChangeDomain = (typeof DATA_CHANGE_DOMAINS)[number];
3
+ export interface PluginChangesQuery {
4
+ domains: PluginChangeDomain[];
5
+ /** 缺省只读独立待办;all 包含正文待办。 */
6
+ todoSource?: "todo" | "document" | "all";
7
+ cursor?: string;
8
+ limit?: number;
9
+ }
10
+ export interface PluginDataChange {
11
+ domain: PluginChangeDomain;
12
+ id: string;
13
+ operation: "upsert" | "delete";
14
+ }
15
+ export interface PluginChangesPage {
16
+ mode: "snapshot" | "changes";
17
+ items: PluginDataChange[];
18
+ cursor: string;
19
+ hasMore: boolean;
20
+ /** 只在本轮完整结束时提供;插件处理成功后才能保存。 */
21
+ checkpoint?: string;
22
+ }
23
+ /** 宿主数据层原语;每次调用在一个短事务内返回水位与分页结果。 */
24
+ export interface DataChangesReadRequest {
25
+ todoSource?: "todo" | "document" | "all";
26
+ phase: "snapshot" | "changes";
27
+ domains: PluginChangeDomain[];
28
+ afterDomain: string;
29
+ afterKey: number;
30
+ afterSeq: number;
31
+ through?: number;
32
+ limit: number;
33
+ }
34
+ export interface DataChangesReadPage {
35
+ todoSource?: "todo" | "document" | "all";
36
+ scope: string;
37
+ protocol: number;
38
+ head: number;
39
+ floor: number;
40
+ through: number;
41
+ items: (PluginDataChange & {
42
+ key?: number;
43
+ seq?: number;
44
+ })[];
45
+ hasMore: boolean;
46
+ }
47
+ export declare function normalizeChangesQuery(query: PluginChangesQuery): PluginChangesQuery & {
48
+ limit: number;
49
+ };
50
+ /** 两端共用状态机;SQL、连接、清理和本机代次由各自数据层负责。 */
51
+ export declare function queryDataChanges(query: PluginChangesQuery, ownerBinding: string, read: (request: DataChangesReadRequest) => Promise<DataChangesReadPage>): Promise<PluginChangesPage>;
@@ -1,8 +1,11 @@
1
+ import type { PluginChangesQuery, PluginChangesPage } from "./data-changes";
2
+ export type { PluginChangesQuery, PluginChangesPage, PluginDataChange, PluginChangeDomain, } from "./data-changes";
1
3
  /**
2
4
  * 业务数据接口。ID 与 ContentRef 都是不透明字符串:只用于传回宿主,不要解析其格式。
3
5
  * 每次调用前宿主按 manifest.permissions 与用户授权校验,未获准抛出 PluginPermissionError。
4
6
  * 修改与删除要传读到的 revision,数据已被别处修改时抛出 PluginConflictError。
5
7
  */
8
+ import type { TaskRecurrenceRule, TaskRecurrenceSegment, TaskOccurrenceState } from "../../shared/task-assistant";
6
9
  import type { Descendant } from "slate";
7
10
  import type { PluginContentInput } from "./content-input";
8
11
  import type { PluginEntityRef } from "./app";
@@ -223,12 +226,66 @@ export interface PluginEntityWriter<T, Input, Patch> extends PluginEntityReader<
223
226
  update(id: string, patch: Patch, options: PluginWriteOptions): Promise<T>;
224
227
  delete(id: string, options: PluginWriteOptions): Promise<void>;
225
228
  }
229
+ export interface PluginCreateOptions {
230
+ /** 同一插件内稳定的创建请求 ID;重试复用,同 ID 不得更换参数。 */
231
+ requestId?: string;
232
+ }
233
+ export interface PluginDirectoryQuery {
234
+ archived?: boolean;
235
+ limit?: number;
236
+ cursor?: string;
237
+ }
238
+ export interface PluginTodoList {
239
+ id: string;
240
+ revision: string;
241
+ title: string;
242
+ archived: boolean;
243
+ writable: boolean;
244
+ readonlyReason?: string;
245
+ }
246
+ export interface PluginCalendar extends PluginTodoList {
247
+ color: string;
248
+ visible: boolean;
249
+ }
250
+ export interface PluginReminder {
251
+ /** 基准时刻减提醒时刻,单位毫秒;全天日程的基准为当天零点。 */
252
+ offsetMs: number;
253
+ }
254
+ export type PluginTodoReminder = PluginReminder | {
255
+ at: string;
256
+ };
257
+ export interface PluginTodoRecurrenceChange {
258
+ effectiveFrom: string;
259
+ rule: TaskRecurrenceRule | null;
260
+ }
261
+ export interface PluginTodoOccurrencePatch {
262
+ completed?: boolean;
263
+ skipped?: boolean;
264
+ scheduledAt?: string | null;
265
+ }
266
+ export interface PluginTodoOccurrenceQuery {
267
+ taskId: string;
268
+ limit?: number;
269
+ cursor?: string;
270
+ }
271
+ export interface PluginTodoOccurrenceState {
272
+ taskId: string;
273
+ seriesId: string;
274
+ originalDate: string;
275
+ state: TaskOccurrenceState;
276
+ active: boolean;
277
+ }
278
+ export type PluginTodoOccurrencePage = PluginPage<PluginTodoOccurrenceState> & {
279
+ taskRevision: string;
280
+ };
226
281
  export interface PluginTodoQuery {
227
282
  /** tasks 返回系列/普通任务;occurrences 返回原始日期标识的周期实例,须给 start/end。 */
228
283
  view?: "tasks" | "occurrences";
229
284
  /** 缺省为全部:独立待办与正文里的勾选项 */
230
285
  source?: "all" | "todo" | "document";
231
286
  completed?: boolean;
287
+ archived?: boolean;
288
+ listId?: string;
232
289
  keyword?: string;
233
290
  /** YYYY-MM-DD,按截止日期筛选 */
234
291
  start?: string;
@@ -238,6 +295,20 @@ export interface PluginTodoQuery {
238
295
  cursor?: string;
239
296
  }
240
297
  export interface PluginTodo {
298
+ listId: string | null;
299
+ /** null 表示此来源尚未开放提醒列表;空数组才表示没有提醒。 */
300
+ reminders: PluginTodoReminder[] | null;
301
+ recurrence: {
302
+ segments: TaskRecurrenceSegment[];
303
+ } | null;
304
+ occurrence?: {
305
+ taskId: string;
306
+ seriesId: string;
307
+ originalDate: string;
308
+ state: TaskOccurrenceState;
309
+ };
310
+ writable: boolean;
311
+ readonlyReason?: string;
241
312
  id: string;
242
313
  revision: string;
243
314
  title: string;
@@ -253,14 +324,22 @@ export interface PluginTodo {
253
324
  };
254
325
  }
255
326
  export interface PluginCalendarQuery {
256
- /** YYYY-MM-DD 或带时区的 ISO 时间,必填 */
257
- start: string;
258
- end: string;
327
+ /** YYYY-MM-DD 或带时区的 ISO 时间;display 查询必填,stored 可省略。 */
328
+ start?: string;
329
+ end?: string;
330
+ /** display(默认)须给时间窗口;stored 只列真实持久日程,可不提供窗口。 */
331
+ view?: "display" | "stored";
332
+ calendarIds?: string[];
259
333
  /** 1–100,默认 50 */
260
334
  limit?: number;
261
335
  cursor?: string;
262
336
  }
263
337
  export interface PluginCalendarEvent {
338
+ reminders: PluginReminder[];
339
+ notesRef: PluginContentRef | null;
340
+ kind: "event" | "todo-schedule" | "virtual";
341
+ writable: boolean;
342
+ readonlyReason?: string;
264
343
  id: string;
265
344
  revision: string;
266
345
  title: string;
@@ -272,15 +351,22 @@ export interface PluginCalendarEvent {
272
351
  todoId?: string;
273
352
  }
274
353
  export interface PluginTodoInput {
354
+ recurrence?: TaskRecurrenceRule;
355
+ listId?: string;
356
+ reminders?: PluginTodoReminder[];
275
357
  title: string;
276
358
  /** YYYY-MM-DD 或带时区的 ISO 时间 */
277
359
  dueAt?: string | null;
278
360
  }
279
361
  export interface PluginTodoPatch {
362
+ listId?: string;
363
+ reminders?: PluginTodoReminder[];
280
364
  title?: string;
281
365
  dueAt?: string | null;
282
366
  }
283
367
  export interface PluginCalendarInput {
368
+ notes?: PluginContentInput;
369
+ reminders?: PluginReminder[];
284
370
  title: string;
285
371
  /** 全天日程用 YYYY-MM-DD,结束日期不含当天(当天全天的 end 为次日);定时日程用带时区的 ISO 时间 */
286
372
  start: string;
@@ -289,8 +375,11 @@ export interface PluginCalendarInput {
289
375
  /** 缺省为默认日历 */
290
376
  calendarId?: string;
291
377
  }
292
- export type PluginCalendarPatch = Partial<PluginCalendarInput>;
378
+ export type PluginCalendarPatch = Partial<Omit<PluginCalendarInput, "notes">>;
293
379
  export interface PluginData {
380
+ readonly changes: {
381
+ query(query: PluginChangesQuery): Promise<PluginChangesPage>;
382
+ };
294
383
  readonly cards: PluginEntityWriter<PluginCard, PluginCardInput, PluginCardPatch>;
295
384
  readonly articles: PluginEntityWriter<PluginArticle, PluginArticleInput, PluginArticlePatch>;
296
385
  /** 白板的信息;画板内容不开放读写,用户在 Tau 中编辑 */
@@ -328,17 +417,34 @@ export interface PluginData {
328
417
  readonly materials: PluginEntityReader<PluginMaterial>;
329
418
  /** AI 对话的信息,不含消息内容;query 不支持 tag */
330
419
  readonly chats: PluginEntityReader<PluginChatSession>;
420
+ readonly todoLists: {
421
+ get(id: string): Promise<PluginTodoList | null>;
422
+ query(query?: PluginDirectoryQuery): Promise<PluginPage<PluginTodoList>>;
423
+ };
424
+ readonly calendars: {
425
+ get(id: string): Promise<PluginCalendar | null>;
426
+ query(query?: PluginDirectoryQuery): Promise<PluginPage<PluginCalendar>>;
427
+ };
331
428
  readonly todos: {
429
+ setRecurrence(id: string, change: PluginTodoRecurrenceChange, options: PluginWriteOptions): Promise<PluginTodo>;
430
+ setOccurrenceState(id: string, patch: PluginTodoOccurrencePatch, options: PluginWriteOptions): Promise<PluginTodo>;
431
+ readonly occurrenceStates: {
432
+ query(query: PluginTodoOccurrenceQuery): Promise<PluginTodoOccurrencePage>;
433
+ };
434
+ get(id: string): Promise<PluginTodo | null>;
332
435
  query(query?: PluginTodoQuery): Promise<PluginPage<PluginTodo>>;
333
- create(input: PluginTodoInput): Promise<PluginTodo>;
436
+ create(input: PluginTodoInput, options?: PluginCreateOptions): Promise<PluginTodo>;
334
437
  update(id: string, patch: PluginTodoPatch, options: PluginWriteOptions): Promise<PluginTodo>;
335
438
  setCompleted(id: string, completed: boolean, options: PluginWriteOptions): Promise<PluginTodo>;
336
439
  /** 有子待办时拒绝删除 */
337
440
  delete(id: string, options: PluginWriteOptions): Promise<void>;
338
441
  };
339
442
  readonly calendar: {
443
+ /** 为尚无备注的日程建立空正文;已有备注保持原样。 */
444
+ ensureNotes(id: string, options: PluginWriteOptions): Promise<PluginCalendarEvent>;
445
+ get(id: string): Promise<PluginCalendarEvent | null>;
340
446
  query(query: PluginCalendarQuery): Promise<PluginPage<PluginCalendarEvent>>;
341
- create(input: PluginCalendarInput): Promise<PluginCalendarEvent>;
447
+ create(input: PluginCalendarInput, options?: PluginCreateOptions): Promise<PluginCalendarEvent>;
342
448
  update(id: string, patch: PluginCalendarPatch, options: PluginWriteOptions): Promise<PluginCalendarEvent>;
343
449
  delete(id: string, options: PluginWriteOptions): Promise<void>;
344
450
  };
@@ -391,4 +497,3 @@ export interface PluginContent {
391
497
  revision: string;
392
498
  }>;
393
499
  }
394
- export {};
@@ -3,3 +3,10 @@ export declare class PluginConflictError extends Error {
3
3
  readonly name = "PluginConflictError";
4
4
  constructor(message?: string);
5
5
  }
6
+ export type PluginSyncResetReason = "invalid-cursor" | "query-changed" | "scope-changed" | "history-expired" | "history-replaced" | "protocol-changed";
7
+ /** 游标不再覆盖当前数据范围;保留映射并重新全量,不能将失败当作空结果。 */
8
+ export declare class PluginSyncResetRequiredError extends Error {
9
+ readonly reason: PluginSyncResetReason;
10
+ readonly name = "PluginSyncResetRequiredError";
11
+ constructor(reason: PluginSyncResetReason);
12
+ }
@@ -28,6 +28,7 @@ export type * from "./sidebar";
28
28
  export { SIDEBAR_GROUPS } from "./sidebar";
29
29
  export type * from "./icons";
30
30
  export type * from "./home";
31
+ export type * from "./text-decorations";
31
32
  export type * from "./actions";
32
33
  export { PLUGIN_ACTION_TARGET_KINDS } from "./actions";
33
34
  export type * from "./views";
@@ -42,7 +43,7 @@ export type * from "./records";
42
43
  export type * from "./links";
43
44
  export type * from "./transaction";
44
45
  export type { PluginFieldCondition, PluginIndexes, PluginIndexType, PluginIndexValue, PluginOrderBy, PluginWhere, } from "./query";
45
- export { PluginConflictError } from "./errors";
46
+ export { PluginConflictError, PluginSyncResetRequiredError, type PluginSyncResetReason, } from "./errors";
46
47
  export { PLUGIN_ENTITY_KINDS, PLUGIN_ENTITY_READ_PERMISSIONS, PLUGIN_APP_ACTIONS, PLUGIN_EXPORT_FORMATS, PLUGIN_NOTEBOOK_FROM_KINDS, PLUGIN_CHAT_CONTEXT_KINDS, } from "./app";
47
48
  export type { PluginNotifications, PluginNotificationOptions, PluginNotificationMode, PluginNotificationAction, } from "./notifications";
48
49
  export type { PluginSpeech, PluginSpeechSession, PluginSpeechStartOptions } from "./speech";
@@ -8,7 +8,7 @@ export { PLUGIN_CATEGORIES, isPluginCategory, type PluginCategory } from "./cate
8
8
  export { PLUGIN_PERMISSIONS, isPluginPermission, type PluginPermission } from "./permissions";
9
9
  export { PLUGIN_AI_CAPABILITIES, isPluginAICapability } from "./ai";
10
10
  export declare const PLUGIN_SHARED_MODULES: readonly ["@tau/plugins", "@tau/plugins/whiteboard", "@tau/plugins/sync", "@tau/ui", "react", "react-dom", "react-dom/client", "react/jsx-runtime", "react/jsx-dev-runtime"];
11
- export interface PluginManifest {
11
+ export interface LegacyPluginManifest {
12
12
  formatVersion: 2;
13
13
  id: string;
14
14
  name: string;
@@ -33,6 +33,7 @@ export interface PluginManifest {
33
33
  skills?: readonly string[];
34
34
  integrity: Record<string, string>;
35
35
  }
36
+ export type PluginManifest = LegacyPluginManifest | import("./unified").UnifiedDesktopPluginManifest;
36
37
  /** 宿主内部传输的已读取产物,不属于作者运行时 API。 */
37
38
  export interface DevelopmentPluginPackage {
38
39
  manifest: PluginManifest | import("./portable").PortablePluginManifest;
@@ -42,4 +43,8 @@ export interface DevelopmentPluginPackage {
42
43
  /** 按实际使用的包字段解析身份、权限、入口和摘要。 */
43
44
  export declare function validatePluginManifest(value: unknown): PluginManifest;
44
45
  /** 静态内容贡献在启动时固定,启停与更新需要重启。 */
45
- export declare const isContentPlugin: (manifest: Pick<PluginManifest, "editor" | "whiteboard">) => boolean;
46
+ export declare const isContentPlugin: (manifest: {
47
+ id: string;
48
+ editor?: true;
49
+ whiteboard?: true;
50
+ }) => boolean;