@xiongtao.xt/tau-plugins 0.42.0 → 0.44.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/CHANGELOG.md +12 -0
- package/client/{chunk-XCKDPTLI.js → chunk-M3YEVDN4.js} +1 -0
- package/client/chunk-UTVEXGFI.js +30 -0
- package/client/{chunk-666OM7IO.js → chunk-X6MBLKAL.js} +1 -1
- package/client/{fuse-M2Z6NNAT.js → fuse-KWYBABFA.js} +2 -0
- package/docs/README.md +4 -1
- package/docs/ai.md +3 -0
- package/docs/api-support.md +10 -0
- package/docs/content-metrics.md +45 -0
- package/docs/editor.md +4 -0
- package/docs/getting-started.md +5 -1
- package/docs/plugin-basics.md +1 -0
- package/docs/portability.md +5 -1
- package/docs/providers/README.md +3 -1
- package/docs/providers/asr.md +41 -0
- package/docs/storage-and-network.md +4 -0
- package/docs/websocket.md +39 -0
- package/package.js +2 -1
- package/package.json +1 -1
- package/portable.js +3 -2
- package/publish-artifacts.js +116 -6
- package/publish-client.js +3 -1
- package/types/packages/asr/src/capture.d.ts +11 -0
- package/types/packages/asr/src/errors.d.ts +9 -0
- package/types/packages/asr/src/index.d.ts +8 -0
- package/types/packages/asr/src/input.d.ts +30 -0
- package/types/packages/asr/src/reducer.d.ts +14 -0
- package/types/packages/asr/src/refinement.d.ts +21 -0
- package/types/packages/asr/src/stream.d.ts +12 -0
- package/types/packages/asr/src/task.d.ts +2 -0
- package/types/packages/asr/src/types.d.ts +108 -0
- package/types/packages/db-schema/content-contracts.d.ts +80 -0
- package/types/packages/db-schema/content-metrics.d.ts +30 -0
- package/types/packages/db-schema/content-resources.d.ts +4 -0
- package/types/packages/editor/contracts.d.ts +2 -2
- package/types/packages/editor/source-contracts.d.ts +67 -3
- package/types/packages/editor/src/core/api/elementVersions.d.ts +12 -0
- package/types/packages/editor/src/core/api/extension.d.ts +15 -0
- package/types/packages/editor/src/core/api/index.d.ts +3 -0
- package/types/packages/editor/src/core/api/useTextFieldBinding.d.ts +9 -0
- package/types/packages/editor/src/core/kit/ExtensionAssembly.d.ts +5 -1
- package/types/packages/markdown/src/codec.d.ts +2 -0
- package/types/packages/markdown/src/index.d.ts +1 -0
- package/types/packages/markdown/src/markdown-helper.d.ts +3 -0
- package/types/packages/markdown/src/markdownSerializerRegistry.d.ts +8 -2
- package/types/packages/markdown/src/positionMapper.d.ts +1 -0
- package/types/packages/markdown/src/processor.d.ts +3 -0
- package/types/packages/markdown/src/unknownNode.d.ts +24 -0
- package/types/packages/plugins/src/ai.d.ts +3 -0
- package/types/packages/plugins/src/asr.d.ts +13 -0
- package/types/packages/plugins/src/contract.d.ts +7 -0
- package/types/packages/plugins/src/editor.d.ts +4 -0
- package/types/packages/plugins/src/index.d.ts +4 -2
- package/types/packages/plugins/src/permissions.d.ts +1 -1
- package/types/packages/plugins/src/rendering.d.ts +1 -1
- package/types/packages/plugins/src/settings.d.ts +6 -1
- package/types/packages/plugins/src/source-editor.d.ts +2 -0
- package/types/packages/plugins/src/websocket.d.ts +9 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ASREvent, ASRStreamSession, ASRTranscript } from "./types";
|
|
2
|
+
export interface SpeechInputSession {
|
|
3
|
+
result: Promise<ASRTranscript>;
|
|
4
|
+
stop(): Promise<void>;
|
|
5
|
+
cancel(): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export interface SpeechInputService {
|
|
8
|
+
start(options: {
|
|
9
|
+
signal: AbortSignal;
|
|
10
|
+
onPreview(text: string): void;
|
|
11
|
+
}): Promise<SpeechInputSession>;
|
|
12
|
+
}
|
|
13
|
+
export interface SpeechInputSetting {
|
|
14
|
+
active: "native" | "plugin";
|
|
15
|
+
language: string;
|
|
16
|
+
refinement?: import("./refinement").SpeechRefinementPreferences;
|
|
17
|
+
plugin: {
|
|
18
|
+
id: string;
|
|
19
|
+
configurations: Record<string, {
|
|
20
|
+
modelId: string;
|
|
21
|
+
config: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare function defaultSpeechInputSetting(): SpeechInputSetting;
|
|
26
|
+
export declare function createSpeechInputService(open: (taskId: string, signal: AbortSignal, onEvent: (event: ASREvent) => void) => Promise<{
|
|
27
|
+
session: ASRStreamSession;
|
|
28
|
+
format: import("./types").ASRAudioFormat;
|
|
29
|
+
release(): Promise<void>;
|
|
30
|
+
}>): SpeechInputService;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ASREvent, ASRSegment, ASRTranscript } from "./types";
|
|
2
|
+
export declare function validateTranscript(result: ASRTranscript): void;
|
|
3
|
+
export declare class ASRTranscriptReducer {
|
|
4
|
+
private readonly taskId;
|
|
5
|
+
private seq;
|
|
6
|
+
private revision;
|
|
7
|
+
private segments;
|
|
8
|
+
constructor(taskId: string);
|
|
9
|
+
getSnapshot(): {
|
|
10
|
+
revision: number;
|
|
11
|
+
segments: readonly ASRSegment[];
|
|
12
|
+
};
|
|
13
|
+
apply(event: ASREvent): boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ASRTranscript } from "./types";
|
|
2
|
+
export interface SpeechRefinementPreferences {
|
|
3
|
+
style: "light" | "paragraphs";
|
|
4
|
+
instructions: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const DEFAULT_SPEECH_REFINEMENT: SpeechRefinementPreferences;
|
|
7
|
+
export declare function validateSpeechRefinementPreferences(value: unknown): SpeechRefinementPreferences;
|
|
8
|
+
export type SpeechRefiner = (text: string, options: {
|
|
9
|
+
signal: AbortSignal;
|
|
10
|
+
onPreview(text: string): void;
|
|
11
|
+
}) => Promise<string>;
|
|
12
|
+
export interface SpeechRefinementResult {
|
|
13
|
+
original: ASRTranscript;
|
|
14
|
+
text: string;
|
|
15
|
+
status: "original" | "refined" | "fallback";
|
|
16
|
+
}
|
|
17
|
+
/** 整理与原始时间轴分开;取消整个会话不交付原文,其他失败才降级。 */
|
|
18
|
+
export declare function refineSpeechInput(transcript: ASRTranscript, refine: SpeechRefiner | undefined, options: {
|
|
19
|
+
signal: AbortSignal;
|
|
20
|
+
onPreview(text: string): void;
|
|
21
|
+
}, timeoutMs?: number): Promise<SpeechRefinementResult>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ASRAudioFormat, ASRAudioFrame, ASREventPayload, ASRRunOptions, ASRStreamSession, ASRTranscript } from "./types";
|
|
2
|
+
export declare function validateASRAudioFormat(format: ASRAudioFormat): void;
|
|
3
|
+
export interface ASRStreamDriver {
|
|
4
|
+
write(frame: ASRAudioFrame, signal: AbortSignal): Promise<void>;
|
|
5
|
+
finish(signal: AbortSignal, emit: (event: ASREventPayload) => void): Promise<ASRTranscript>;
|
|
6
|
+
dispose(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/** 驱动可在 write 中交付实时事件;finish 发送结束标记并等待最终结果。 */
|
|
9
|
+
export declare function createASRStreamSession(options: ASRRunOptions, format: ASRAudioFormat, connect: (signal: AbortSignal, emit: (event: ASREventPayload) => void) => Promise<ASRStreamDriver>, limits?: {
|
|
10
|
+
maxBufferedMs: number;
|
|
11
|
+
tailTimeoutMs: number;
|
|
12
|
+
}): ASRStreamSession;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export interface ASRWord {
|
|
2
|
+
text: string;
|
|
3
|
+
startMs: number;
|
|
4
|
+
endMs: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ASRSegment {
|
|
7
|
+
id: string;
|
|
8
|
+
text: string;
|
|
9
|
+
final: boolean;
|
|
10
|
+
startMs?: number;
|
|
11
|
+
endMs?: number;
|
|
12
|
+
speakerId?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ASRTranscript {
|
|
15
|
+
text: string;
|
|
16
|
+
segments?: readonly ASRSegment[];
|
|
17
|
+
words?: readonly ASRWord[];
|
|
18
|
+
language?: string;
|
|
19
|
+
durationMs?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ASRAudioFormat {
|
|
22
|
+
encoding: "pcm-s16le";
|
|
23
|
+
sampleRateHz: number;
|
|
24
|
+
channels: 1;
|
|
25
|
+
}
|
|
26
|
+
export interface ASRAudioFrame {
|
|
27
|
+
seq: number;
|
|
28
|
+
startSample: number;
|
|
29
|
+
data: Uint8Array;
|
|
30
|
+
}
|
|
31
|
+
export interface ASRAudioFile {
|
|
32
|
+
name: string;
|
|
33
|
+
mimeType: string;
|
|
34
|
+
sizeBytes: number;
|
|
35
|
+
open(signal: AbortSignal): Promise<ReadableStream<Uint8Array>>;
|
|
36
|
+
}
|
|
37
|
+
export interface ASRRequest {
|
|
38
|
+
language: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ASRFileRequest extends ASRRequest {
|
|
41
|
+
audio: ASRAudioFile;
|
|
42
|
+
}
|
|
43
|
+
export interface ASRStreamRequest extends ASRRequest {
|
|
44
|
+
format: ASRAudioFormat;
|
|
45
|
+
}
|
|
46
|
+
export interface ASRProbeRequest extends ASRRequest {
|
|
47
|
+
input: "file" | "stream";
|
|
48
|
+
}
|
|
49
|
+
export interface ASRAvailability {
|
|
50
|
+
state: "ready" | "needs-permission" | "needs-assets" | "needs-config" | "unavailable" | "unsupported";
|
|
51
|
+
reason?: string;
|
|
52
|
+
execution: "device" | "remote" | "unknown";
|
|
53
|
+
textUpdates: "partial" | "segments" | "final-only";
|
|
54
|
+
timestamps: "none" | "segment" | "word";
|
|
55
|
+
speakerLabels: boolean;
|
|
56
|
+
acceptedAudio?: {
|
|
57
|
+
streamFormats?: readonly ASRAudioFormat[];
|
|
58
|
+
fileMimeTypes?: readonly string[];
|
|
59
|
+
};
|
|
60
|
+
maxDurationMs?: number;
|
|
61
|
+
}
|
|
62
|
+
export type ASREventPayload = {
|
|
63
|
+
type: "segments";
|
|
64
|
+
baseRevision: number;
|
|
65
|
+
revision: number;
|
|
66
|
+
startIndex: number;
|
|
67
|
+
deleteCount: number;
|
|
68
|
+
segments: readonly ASRSegment[];
|
|
69
|
+
} | {
|
|
70
|
+
type: "progress";
|
|
71
|
+
stage: "uploading" | "recognizing";
|
|
72
|
+
fraction?: number;
|
|
73
|
+
message?: string;
|
|
74
|
+
};
|
|
75
|
+
export type ASREvent = {
|
|
76
|
+
taskId: string;
|
|
77
|
+
seq: number;
|
|
78
|
+
} & ASREventPayload;
|
|
79
|
+
export interface ASRRunOptions {
|
|
80
|
+
taskId: string;
|
|
81
|
+
signal: AbortSignal;
|
|
82
|
+
onEvent: (event: ASREvent) => void;
|
|
83
|
+
}
|
|
84
|
+
export interface ASRTask<T extends ASRTranscript = ASRTranscript> {
|
|
85
|
+
readonly result: Promise<T>;
|
|
86
|
+
/** 等待底层资源清理;完成后调用不会撤回已经交付的结果。 */
|
|
87
|
+
cancel(): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
export interface ASRStreamSession extends ASRTask {
|
|
90
|
+
write(frame: ASRAudioFrame): Promise<void>;
|
|
91
|
+
/** 停止接收并排空已接受帧;最终识别结果仍从 result 取得。 */
|
|
92
|
+
endInput(): Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
export interface ASRInstance {
|
|
95
|
+
probe(request: ASRProbeRequest, signal: AbortSignal): Promise<ASRAvailability>;
|
|
96
|
+
transcribeFile?(request: ASRFileRequest, options: ASRRunOptions): Promise<ASRTask>;
|
|
97
|
+
openStream?(request: ASRStreamRequest, options: ASRRunOptions): Promise<ASRStreamSession>;
|
|
98
|
+
}
|
|
99
|
+
export declare const MAC_NATIVE_ASR_DEFAULTS: Readonly<{
|
|
100
|
+
vad: "medium";
|
|
101
|
+
format: Readonly<{
|
|
102
|
+
encoding: "pcm-s16le";
|
|
103
|
+
sampleRateHz: 16000;
|
|
104
|
+
channels: 1;
|
|
105
|
+
}>;
|
|
106
|
+
tailTimeoutMs: 10000;
|
|
107
|
+
maxBufferedMs: 2000;
|
|
108
|
+
}>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type ContentResourceSpec } from "./content-resources";
|
|
2
|
+
export declare const CONTENT_CONTRACT_VERSION = 2;
|
|
3
|
+
export declare const NODE_CONTRACT_PROPERTY = "tauContract";
|
|
4
|
+
export declare const CONTENT_CONTRACT_LIMITS: Readonly<{
|
|
5
|
+
contracts: 1024;
|
|
6
|
+
fields: 32;
|
|
7
|
+
nameLength: 128;
|
|
8
|
+
contractBytes: number;
|
|
9
|
+
totalBytes: number;
|
|
10
|
+
}>;
|
|
11
|
+
export interface ContentCollaborationSpec {
|
|
12
|
+
textFields?: readonly string[];
|
|
13
|
+
structuredFields?: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
export interface ContentContractDefinition {
|
|
16
|
+
type: string;
|
|
17
|
+
dataVersion: number;
|
|
18
|
+
kind: "block" | "inline";
|
|
19
|
+
isVoid?: boolean;
|
|
20
|
+
collaboration?: ContentCollaborationSpec;
|
|
21
|
+
resources?: readonly ContentResourceSpec[];
|
|
22
|
+
}
|
|
23
|
+
export interface WhiteboardStructure {
|
|
24
|
+
geometry: "rect" | "opaque";
|
|
25
|
+
container: "none" | "free" | "layout";
|
|
26
|
+
canBeContained: boolean;
|
|
27
|
+
joins: readonly "layout"[];
|
|
28
|
+
text: "none" | "plain" | "richtext";
|
|
29
|
+
reference: "none" | "entity";
|
|
30
|
+
}
|
|
31
|
+
/** 宿主契约输入;结构由宿主注册入口生成,不是新增作者槽位语言。 */
|
|
32
|
+
export interface WhiteboardContractDefinition {
|
|
33
|
+
type: string;
|
|
34
|
+
dataVersion: number;
|
|
35
|
+
structure?: Partial<WhiteboardStructure>;
|
|
36
|
+
collaboration?: {
|
|
37
|
+
textFields?: readonly string[];
|
|
38
|
+
};
|
|
39
|
+
resources?: readonly ContentResourceSpec[];
|
|
40
|
+
}
|
|
41
|
+
interface ContractBase {
|
|
42
|
+
format: typeof CONTENT_CONTRACT_VERSION;
|
|
43
|
+
owner: string;
|
|
44
|
+
type: string;
|
|
45
|
+
dataVersion: number;
|
|
46
|
+
textFields: readonly string[];
|
|
47
|
+
structuredFields: readonly string[];
|
|
48
|
+
resources: readonly ContentResourceSpec[];
|
|
49
|
+
}
|
|
50
|
+
export interface ContentContract extends ContractBase {
|
|
51
|
+
domain: "editor-node";
|
|
52
|
+
kind: "block" | "inline";
|
|
53
|
+
isVoid: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface WhiteboardElementContract extends ContractBase {
|
|
56
|
+
domain: "whiteboard-element";
|
|
57
|
+
structure: Readonly<WhiteboardStructure>;
|
|
58
|
+
}
|
|
59
|
+
export type DataContract = ContentContract | WhiteboardElementContract;
|
|
60
|
+
export interface PreparedContentContract {
|
|
61
|
+
id: string;
|
|
62
|
+
contract: ContentContract;
|
|
63
|
+
}
|
|
64
|
+
export interface PreparedWhiteboardContract {
|
|
65
|
+
id: string;
|
|
66
|
+
contract: WhiteboardElementContract;
|
|
67
|
+
}
|
|
68
|
+
export type ContentContractDictionary = Readonly<Record<string, DataContract>>;
|
|
69
|
+
export declare function normalizeContentContract(owner: string, definition: ContentContractDefinition): ContentContract;
|
|
70
|
+
export declare function normalizeWhiteboardContract(owner: string, definition: WhiteboardContractDefinition): WhiteboardElementContract;
|
|
71
|
+
export declare function canonicalContractJson(value: unknown): string;
|
|
72
|
+
export declare function prepareContentContract(owner: string, definition: ContentContractDefinition): Promise<PreparedContentContract>;
|
|
73
|
+
export declare function prepareWhiteboardContract(owner: string, definition: WhiteboardContractDefinition): Promise<PreparedWhiteboardContract>;
|
|
74
|
+
export declare function contentContractChecks(value: unknown): readonly {
|
|
75
|
+
id: string;
|
|
76
|
+
contract: DataContract;
|
|
77
|
+
canonical: string;
|
|
78
|
+
}[];
|
|
79
|
+
export declare function validateContentContracts(value: unknown): Promise<ContentContractDictionary>;
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** 字段路径支持对象属性与数组项,例如 answers[].text。 */
|
|
2
|
+
export interface ContentMetricChildren {
|
|
3
|
+
path: string;
|
|
4
|
+
/** 仅在节点的该布尔字段为 true 时补充子树。 */
|
|
5
|
+
when?: string;
|
|
6
|
+
skip?: number;
|
|
7
|
+
/** 排除标识与当前节点指定字段相同的项。 */
|
|
8
|
+
exclude?: {
|
|
9
|
+
field: string;
|
|
10
|
+
equalsField: string;
|
|
11
|
+
};
|
|
12
|
+
childrenPath?: string;
|
|
13
|
+
}
|
|
14
|
+
/** 扩展只声明内容字段;计数算法与普通 children 遍历由宿主统一执行。 */
|
|
15
|
+
export interface ContentMetricRule {
|
|
16
|
+
type: string;
|
|
17
|
+
textFields: readonly string[];
|
|
18
|
+
additionalChildren?: readonly ContentMetricChildren[];
|
|
19
|
+
}
|
|
20
|
+
/** 在进程边界重新校验,并复制为不可变快照;不携带插件可执行代码。 */
|
|
21
|
+
export declare function normalizeContentMetricRules(value: unknown): readonly ContentMetricRule[];
|
|
22
|
+
export declare const countTextWords: (text: string) => number;
|
|
23
|
+
export declare function createContentMetrics(initialRules?: readonly ContentMetricRule[]): {
|
|
24
|
+
count: (content: readonly unknown[]) => number;
|
|
25
|
+
readonly revision: number;
|
|
26
|
+
readonly rules: readonly ContentMetricRule[];
|
|
27
|
+
setRules(next: readonly ContentMetricRule[]): void;
|
|
28
|
+
};
|
|
29
|
+
/** 自动清理只认空段落与空文本;图片、结构块和未知节点始终保留。 */
|
|
30
|
+
export declare function isContentEmpty(content: unknown): boolean;
|
|
@@ -43,6 +43,10 @@ export declare const BUILTIN_CONTENT_RESOURCES: {
|
|
|
43
43
|
readonly kind: "file";
|
|
44
44
|
}];
|
|
45
45
|
};
|
|
46
|
+
export declare const CONTENT_RESOURCE_LIMITS: Readonly<{
|
|
47
|
+
specs: 16;
|
|
48
|
+
pathLength: 128;
|
|
49
|
+
}>;
|
|
46
50
|
export declare function isContentResourceSpec(value: unknown): value is ContentResourceSpec;
|
|
47
51
|
/** 校验来自插件或其他设备的声明;形状不对时抛错 */
|
|
48
52
|
export declare function assertContentResourceSpecs(value: unknown): asserts value is readonly ContentResourceSpec[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** 无 React/DOM 运行时代码的声明入口,供应用 SDK 适配现有扩展协议。 */
|
|
2
|
-
export { defineExtension, defineElement } from "./src/core/api/extension";
|
|
3
|
-
export type { EditorExtension, ElementSpec, ElementRenderProps, ElementFrame, } from "./src/core/api/extension";
|
|
2
|
+
export { defineExtension, defineElement, assertElementVersions } from "./src/core/api/extension";
|
|
3
|
+
export type { EditorExtension, ElementSpec, ElementRenderProps, ElementFrame, ElementDataMigration, PreviousElementVersion, } from "./src/core/api/extension";
|
|
@@ -2,17 +2,79 @@ import type { MouseEvent, ReactNode, ReactElement } from "react";
|
|
|
2
2
|
import type { LucideIcon } from "lucide-react";
|
|
3
3
|
import type { Editor, Element, Path } from "slate";
|
|
4
4
|
import type { ElementBehaviors, ParagraphElement, BlockElement } from "./api";
|
|
5
|
-
export interface
|
|
5
|
+
export interface TextFieldSnapshot {
|
|
6
|
+
readonly value: string;
|
|
7
|
+
readonly revision: string;
|
|
8
|
+
}
|
|
9
|
+
export interface TextFieldDelta {
|
|
10
|
+
retain?: number;
|
|
11
|
+
delete?: number;
|
|
12
|
+
insert?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface EditorTextField {
|
|
15
|
+
getSnapshot(): TextFieldSnapshot;
|
|
16
|
+
subscribe(listener: (event: {
|
|
17
|
+
delta: readonly TextFieldDelta[];
|
|
18
|
+
local: boolean;
|
|
19
|
+
}) => void): () => void;
|
|
20
|
+
edit(change: {
|
|
21
|
+
offset: number;
|
|
22
|
+
remove: number;
|
|
23
|
+
text: string;
|
|
24
|
+
revision: string;
|
|
25
|
+
}): void;
|
|
26
|
+
editBatch(changes: readonly {
|
|
27
|
+
offset: number;
|
|
28
|
+
remove: number;
|
|
29
|
+
text: string;
|
|
30
|
+
}[], revision: string): void;
|
|
31
|
+
/** 本机观察版本保护;共享文档的异步整段替换须经宿主条件提交,不能据此声称服务端 CAS。 */
|
|
32
|
+
replace(value: string, revision: string): void;
|
|
33
|
+
undo(): void;
|
|
34
|
+
redo(): void;
|
|
35
|
+
dispose(): void;
|
|
36
|
+
}
|
|
37
|
+
export interface EditorTextFields {
|
|
38
|
+
open(editor: Editor, element: Element, field: string): EditorTextField;
|
|
39
|
+
}
|
|
40
|
+
export declare const IEditorTextFields: import("../shared/service-contract").ServiceIdentifier<EditorTextFields>;
|
|
41
|
+
export interface TextFieldEditor {
|
|
42
|
+
readonly value: string;
|
|
43
|
+
readonly revision: string;
|
|
44
|
+
readonly readOnly: boolean;
|
|
45
|
+
readonly ready: boolean;
|
|
46
|
+
readonly error: string | null;
|
|
47
|
+
edit(change: {
|
|
48
|
+
offset: number;
|
|
49
|
+
remove: number;
|
|
50
|
+
text: string;
|
|
51
|
+
}): void;
|
|
52
|
+
editBatch(changes: readonly {
|
|
53
|
+
offset: number;
|
|
54
|
+
remove: number;
|
|
55
|
+
text: string;
|
|
56
|
+
}[]): void;
|
|
57
|
+
undo(): void;
|
|
58
|
+
redo(): void;
|
|
59
|
+
}
|
|
60
|
+
interface SourceBlockEditorBaseProps {
|
|
6
61
|
mode: string;
|
|
7
62
|
title: string;
|
|
8
63
|
icon: LucideIcon;
|
|
9
|
-
initValue: string;
|
|
10
|
-
onChange(value: string): void;
|
|
11
64
|
element: Element;
|
|
12
65
|
center?: boolean;
|
|
13
66
|
extend?: boolean;
|
|
14
67
|
children?: ReactNode;
|
|
15
68
|
}
|
|
69
|
+
export type SourceBlockEditorProps = SourceBlockEditorBaseProps & ({
|
|
70
|
+
field: string;
|
|
71
|
+
initValue?: never;
|
|
72
|
+
onChange?: never;
|
|
73
|
+
} | {
|
|
74
|
+
field?: never;
|
|
75
|
+
initValue: string;
|
|
76
|
+
onChange(value: string): void;
|
|
77
|
+
});
|
|
16
78
|
export interface RuntimeStyleCompiler {
|
|
17
79
|
compile(request: {
|
|
18
80
|
source: string;
|
|
@@ -20,6 +82,7 @@ export interface RuntimeStyleCompiler {
|
|
|
20
82
|
}): Promise<string>;
|
|
21
83
|
}
|
|
22
84
|
export interface SourceEditorRuntime {
|
|
85
|
+
useTextField(element: Element, field: string): TextFieldEditor;
|
|
23
86
|
SourceBlockEditor(props: SourceBlockEditorProps): ReactElement;
|
|
24
87
|
useSourceBlock(element: Element): {
|
|
25
88
|
theme: {
|
|
@@ -85,3 +148,4 @@ export interface InlineSourceRuntime {
|
|
|
85
148
|
insertInlineSource(editor: Editor, element: Element): void;
|
|
86
149
|
InlineSourceBoundary(): ReactElement;
|
|
87
150
|
}
|
|
151
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Editor, Element } from "slate";
|
|
2
|
+
import type { ElementSpec } from "./extension";
|
|
3
|
+
export interface ElementVersionAccess {
|
|
4
|
+
element: ElementSpec;
|
|
5
|
+
access: "read" | "edit" | "none";
|
|
6
|
+
}
|
|
7
|
+
export type ElementVersionResolver = (element: Element) => ElementVersionAccess | undefined;
|
|
8
|
+
export declare function bindElementDefinitions(editor: Editor, elements: readonly ElementSpec[]): void;
|
|
9
|
+
export declare const currentElementDefinition: (editor: Editor, type: string) => ElementSpec | undefined;
|
|
10
|
+
export declare function setElementVersionResolver(editor: Editor, resolver: ElementVersionResolver | undefined): void;
|
|
11
|
+
export declare const getElementVersionResolver: (editor: Editor) => ElementVersionResolver | undefined;
|
|
12
|
+
export declare function canEditElement(editor: Editor, element: Element): boolean;
|
|
@@ -11,6 +11,15 @@ import type { ElementCopy } from "./copy";
|
|
|
11
11
|
import type { DecorationSpec, MarkSpec } from "./marks";
|
|
12
12
|
import type { InputRule } from "./inputRules";
|
|
13
13
|
import type { ContentResourceSpec } from "../../../../db-schema/content-resources";
|
|
14
|
+
import { type ContentCollaborationSpec } from "../../../../db-schema/content-contracts";
|
|
15
|
+
export interface ElementDataMigration {
|
|
16
|
+
from: number;
|
|
17
|
+
migrate(data: Readonly<Record<string, unknown>>): Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export interface PreviousElementVersion {
|
|
20
|
+
element: ElementSpec;
|
|
21
|
+
access: "read" | "edit" | "none";
|
|
22
|
+
}
|
|
14
23
|
/**
|
|
15
24
|
* 扩展 API v2(01 §5.1):声明式描述「这个扩展贡献了什么」,内核负责装配、隔离与分发。
|
|
16
25
|
* 所有扩展都是 defineExtension 的产物(旧 IExtension 适配层已删除,ER-019)。
|
|
@@ -50,6 +59,11 @@ export interface ElementFrame {
|
|
|
50
59
|
export interface ElementSpec<E extends Element = Element> {
|
|
51
60
|
/** 元素 type;内置类型沿用现有名字,兼容已有文档 */
|
|
52
61
|
type: string;
|
|
62
|
+
/** 数据结构与同步语义版本;无版本的旧声明不能进入新契约文档。 */
|
|
63
|
+
dataVersion?: number;
|
|
64
|
+
collaboration?: ContentCollaborationSpec;
|
|
65
|
+
previousVersions?: readonly PreviousElementVersion[];
|
|
66
|
+
migrations?: readonly ElementDataMigration[];
|
|
53
67
|
kind: "block" | "inline";
|
|
54
68
|
isVoid?: boolean;
|
|
55
69
|
/** 后代的方向键/退格导航由领域接管,核心不执行默认相邻块导航。 */
|
|
@@ -115,4 +129,5 @@ export type ExtensionDefinition = Omit<EditorExtension, "apiVersion"> & {
|
|
|
115
129
|
export declare function defineExtension(definition: ExtensionDefinition): EditorExtension;
|
|
116
130
|
/** 按元素类型收窄 render / behaviors 的参数类型;运行时原样返回 */
|
|
117
131
|
export declare function defineElement<E extends Element>(spec: ElementSpec<E>): ElementSpec;
|
|
132
|
+
export declare function assertElementVersions(spec: ElementSpec): void;
|
|
118
133
|
export declare const isEditorExtension: (value: unknown) => value is EditorExtension;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { EXTENSION_API_VERSION, defineExtension, defineElement, type EditorExtension, type ExtensionDefinition, type ElementSpec, type ElementFrame, type ElementEmptyContext, type ElementBehaviors, type ElementRenderProps, type ExtensionLayerProps, } from "./extension";
|
|
8
8
|
export type { AnyExtension } from "./legacy";
|
|
9
|
+
export { canEditElement, getElementVersionResolver, setElementVersionResolver, type ElementVersionAccess, type ElementVersionResolver, } from "./elementVersions";
|
|
9
10
|
export type { CopyDecision, CopyContext, ElementCopy } from "./copy";
|
|
10
11
|
export type { MarkSpec, MarkRenderProps, DecorationSpec } from "./marks";
|
|
11
12
|
export type { InputRule, MarkInputRule, InlineInputRule } from "./inputRules";
|
|
@@ -62,3 +63,5 @@ export { panAroundAnchor, pointFromCenter, type Point as ZoomPanPoint } from "..
|
|
|
62
63
|
export { FloatingToolbar, ToolbarDivider, ToolbarIconButton } from "../components/FloatingToolbar/index";
|
|
63
64
|
export { IElementEditingPolicy, type ElementEditingPolicy } from "../services/elementEditingPolicy";
|
|
64
65
|
export { IUnknownElementNotice, type UnknownElementNotice } from "../services/unknownElementNotice";
|
|
66
|
+
export type { EditorTextField } from "../../../source-contracts";
|
|
67
|
+
export { useTextFieldBinding } from "./useTextFieldBinding";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Element } from "slate";
|
|
2
|
+
import { type EditorTextField } from "../../../source-contracts";
|
|
3
|
+
export declare function useTextFieldBinding(element: Element | undefined, field: string): {
|
|
4
|
+
binding: EditorTextField | null;
|
|
5
|
+
value: string;
|
|
6
|
+
revision: string;
|
|
7
|
+
readOnly: boolean;
|
|
8
|
+
error: string | null;
|
|
9
|
+
};
|
|
@@ -2,7 +2,7 @@ import { type ReactElement } from "react";
|
|
|
2
2
|
import type { ContentResourceDeclarations } from "../../../../db-schema/content-resources";
|
|
3
3
|
import type { Editor } from "slate";
|
|
4
4
|
import type { RenderElementProps } from "slate-react";
|
|
5
|
-
import type { EditorExtension, ElementBehaviors } from "../api/extension";
|
|
5
|
+
import type { EditorExtension, ElementBehaviors, ElementSpec } from "../api/extension";
|
|
6
6
|
import { CommandRegistry, type EditorHotkey } from "../api/command";
|
|
7
7
|
import { type ElementDragSpec } from "../api/drag";
|
|
8
8
|
import type { ElementIngestSpec } from "../api/ingest";
|
|
@@ -24,6 +24,7 @@ export interface ExtensionPluginGroup {
|
|
|
24
24
|
export interface ElementBehaviorEntry {
|
|
25
25
|
readonly extension: string;
|
|
26
26
|
readonly behaviors: ElementBehaviors;
|
|
27
|
+
readonly own?: boolean;
|
|
27
28
|
}
|
|
28
29
|
/** 一个扩展的内容注入声明;owner 用于隔离熔断与日志 */
|
|
29
30
|
export interface IngestSource {
|
|
@@ -31,6 +32,8 @@ export interface IngestSource {
|
|
|
31
32
|
readonly files?: ElementIngestSpec["files"];
|
|
32
33
|
readonly text?: ElementIngestSpec["text"];
|
|
33
34
|
}
|
|
35
|
+
type ElementRenderer = (props: RenderElementProps) => ReactElement | undefined;
|
|
36
|
+
export declare const renderElementSpec: (spec: ElementSpec) => ElementRenderer;
|
|
34
37
|
/**
|
|
35
38
|
* 扩展的预计算结果:插件链、快捷键、悬浮工具条条目与 type → 渲染的分发表。
|
|
36
39
|
*
|
|
@@ -79,3 +82,4 @@ export declare class ExtensionAssembly {
|
|
|
79
82
|
/** 块菜单条目:每次打开菜单求值;单个扩展出错只丢它自己的条目 */
|
|
80
83
|
getBlockPanelItems(editor: Editor): IBlockPanelListItem[];
|
|
81
84
|
}
|
|
85
|
+
export {};
|
|
@@ -33,6 +33,8 @@ export interface MarkdownImportContext {
|
|
|
33
33
|
export interface MarkdownCodec {
|
|
34
34
|
/** 元素 type */
|
|
35
35
|
type: string;
|
|
36
|
+
/** 省略时归当前节点契约;历史版本只用于明确的导出分发。 */
|
|
37
|
+
dataVersion?: number;
|
|
36
38
|
/** 导入:按 directive 名解析(container / leaf / text 三种都查),优先于内置分支 */
|
|
37
39
|
directives?: Record<string, CustomDirectiveHandler>;
|
|
38
40
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { serializeUnknownBlock, serializeUnknownInline, isInlinePosition } from "./unknownNode";
|
|
1
2
|
export { createMarkdownProcessor, type MarkdownProcessor, type MarkdownProcessorOptions, type MarkdownCachePolicy, } from "./processor";
|
|
2
3
|
export type { MarkdownTextCodec, MarkdownTextRule, LeafSerializationResult } from "./textCodec";
|
|
3
4
|
export type { MarkdownCodec, CustomDirectiveHandler, MarkdownImportNode, MarkdownImportContext, } from "./codec";
|
|
@@ -3,6 +3,7 @@ import type { CustomElement } from "./types";
|
|
|
3
3
|
import type { MarkdownSerializerRegistry } from "./markdownSerializerRegistry";
|
|
4
4
|
import { PositionMapper } from "./positionMapper";
|
|
5
5
|
import type { MarkdownTextRegistry } from "./textCodec";
|
|
6
|
+
import type { MarkdownCodec } from "./codec";
|
|
6
7
|
/** 处理器级导出配置:注册表 + void 类型表 + 子元素接续表(内置 + 宿主 codec) */
|
|
7
8
|
export interface ExportConfig {
|
|
8
9
|
textRegistry: MarkdownTextRegistry;
|
|
@@ -10,6 +11,8 @@ export interface ExportConfig {
|
|
|
10
11
|
voidTypes: ReadonlySet<string>;
|
|
11
12
|
/** 元素类型的子块级接续符(列表 / 表格为 "\n",缺省 "\n\n") */
|
|
12
13
|
childSeparators: ReadonlyMap<string, "\n" | "\n\n">;
|
|
14
|
+
resolveCodec?: (element: CustomElement) => MarkdownCodec | undefined;
|
|
15
|
+
serializeUnknown?: (element: CustomElement, parent: CustomElement | null, error?: unknown) => string;
|
|
13
16
|
}
|
|
14
17
|
/** codec 的序列化器登记脚注(如 annotation 的 [^n]),由导出入口统一追加到文末 */
|
|
15
18
|
export declare const addExportFootnote: (content: string) => number;
|
|
@@ -36,13 +36,19 @@ export declare class MarkdownSerializerRegistry {
|
|
|
36
36
|
private blockTypes;
|
|
37
37
|
private footnoteCounter;
|
|
38
38
|
private footnoteDefinitions;
|
|
39
|
-
|
|
39
|
+
private readonly resolve?;
|
|
40
|
+
constructor(serializers?: MarkdownSerializer[], resolve?: (element: CustomElement) => MarkdownSerializer | undefined);
|
|
40
41
|
resetFootnotes(): void;
|
|
42
|
+
captureFootnotes(): {
|
|
43
|
+
counter: number;
|
|
44
|
+
definitions: Map<number, string>;
|
|
45
|
+
};
|
|
46
|
+
restoreFootnotes(snapshot: ReturnType<MarkdownSerializerRegistry["captureFootnotes"]>): void;
|
|
41
47
|
getFootnoteCount(): number;
|
|
42
48
|
addFootnote(content: string): number;
|
|
43
49
|
getFootnoteDefinitions(): string;
|
|
44
50
|
register(serializer: MarkdownSerializer): void;
|
|
45
51
|
registerMany(serializers: MarkdownSerializer[]): void;
|
|
46
|
-
getSerializer(type: string): MarkdownSerializer | undefined;
|
|
52
|
+
getSerializer(type: string, element?: CustomElement): MarkdownSerializer | undefined;
|
|
47
53
|
isBlock(element: CustomElement): boolean;
|
|
48
54
|
}
|
|
@@ -25,6 +25,9 @@ export interface MarkdownProcessorOptions {
|
|
|
25
25
|
/** 元素类型的编解码(各扩展的 markdown.ts 提供);处理器只认这里的类型,其余走 ER-006 兜底 */
|
|
26
26
|
codecs?: MarkdownCodec[];
|
|
27
27
|
textCodecs?: readonly MarkdownTextCodec[];
|
|
28
|
+
/** 宿主按节点携带的契约选择导出器;undefined 表示该节点需保真回退。 */
|
|
29
|
+
resolveCodec?: (element: CustomElement) => MarkdownCodec | undefined;
|
|
30
|
+
serializeUnknown?: (element: CustomElement, parent: CustomElement | null, error?: unknown) => string;
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
33
|
* 创建 Markdown 处理器(01 §8.2):框架不带任何元素类型,全部经 codecs 注入,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 未知节点的 Markdown 兜底语法(ER-006 / ER-P3):没有 codec 的元素整节点原样存成 JSON,导入时还原。
|
|
3
|
+
*
|
|
4
|
+
* - 块级:`:::tau-node{type="x"}` 容器包一段 json 代码围栏,围栏里是整个节点(含 children)。
|
|
5
|
+
* - 行内:`:tau-node[正文]{type="x" json="…"}`,方括号里的正文只供阅读,还原以 json 为准。
|
|
6
|
+
*
|
|
7
|
+
* 块级 / 行内按 Slate 的结构判断:父元素含文本子节点时,它的元素子节点必然是行内的。
|
|
8
|
+
*/
|
|
9
|
+
import type { Descendant } from "slate";
|
|
10
|
+
export declare const UNKNOWN_NODE_DIRECTIVE = "tau-node";
|
|
11
|
+
type NodeLike = {
|
|
12
|
+
type?: string;
|
|
13
|
+
text?: string;
|
|
14
|
+
children?: NodeLike[];
|
|
15
|
+
};
|
|
16
|
+
/** 该位置上的元素是否是行内的(父元素含文本子节点) */
|
|
17
|
+
export declare const isInlinePosition: (parent: NodeLike | null | undefined) => boolean;
|
|
18
|
+
export declare const serializeUnknownBlock: (element: NodeLike) => string;
|
|
19
|
+
export declare const serializeUnknownInline: (element: NodeLike) => string;
|
|
20
|
+
/** 元素沿用 children 协议,文本载体只接受基础 formatted 叶子。 */
|
|
21
|
+
export declare const parseUnknownNode: (json: string | undefined) => Descendant | null;
|
|
22
|
+
export declare const markRestored: <T extends object>(node: T) => T;
|
|
23
|
+
export declare const isRestoredNode: (node: unknown) => boolean;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ASRInstance } from "../../asr/src/index";
|
|
2
|
+
import type { Disposable, JsonValue } from "./contract";
|
|
3
|
+
export interface ASRProviderDefinition {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
/** 固定本次账号与模型,不在创建时联网或录音。 */
|
|
7
|
+
create(config: JsonValue, modelId: string): ASRInstance;
|
|
8
|
+
}
|
|
9
|
+
export interface PluginASR {
|
|
10
|
+
register(definition: ASRProviderDefinition): Disposable;
|
|
11
|
+
}
|
|
12
|
+
export type { ASRWord, ASRSegment, ASRTranscript, ASRAudioFormat, ASRAudioFrame, ASRAudioFile, ASRRequest, ASRFileRequest, ASRStreamRequest, ASRProbeRequest, ASRAvailability, ASREventPayload, ASREvent, ASRRunOptions, ASRTask, ASRStreamSession, ASRInstance, ASRStreamDriver, ASRErrorCode, } from "../../asr/src/index";
|
|
13
|
+
export { ASRError, createASRStreamSession, createASRTask, throwIfASRAborted } from "../../asr/src/index";
|