@duskmoon-dev/components 0.5.4 → 0.5.6

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.
@@ -0,0 +1,31 @@
1
+ import type { ComposerDocument, ComposerDraft, ComposerScope, ComposerSubmission } from "../Composer.types";
2
+ export type ComposerReadResult<T> = {
3
+ readonly status: "compatible";
4
+ readonly value: T;
5
+ readonly migrated: boolean;
6
+ } | {
7
+ readonly status: "incompatible";
8
+ readonly input: unknown;
9
+ readonly reason: string;
10
+ };
11
+ /** A legacy string always becomes exactly one editable text node, even if empty. */
12
+ export declare function migrateLegacyComposerDocument(text: string): ComposerDocument;
13
+ /** Unknown versions, fields and nodes remain available as the original input. */
14
+ export declare function readComposerDocument(input: unknown): ComposerReadResult<ComposerDocument>;
15
+ /** Snapshot before asynchronous work; never retain the caller's nested objects. */
16
+ export declare function snapshotComposerDocument(document: ComposerDocument): ComposerDocument;
17
+ export declare function readComposerDraft(input: unknown, legacy: {
18
+ readonly scope: ComposerScope;
19
+ readonly draftKey: string;
20
+ }): ComposerReadResult<ComposerDraft>;
21
+ export declare function snapshotComposerSubmission(submission: ComposerSubmission): ComposerSubmission;
22
+ /**
23
+ * Deterministic readable export, not reference resolution or a submission adapter.
24
+ * Text/Markdown source is unchanged; references use plainText. Quotes occupy
25
+ * ordered blocks: each line starts `> `, followed by `> — source.label` when set.
26
+ * Quote line endings normalize to LF; other text retains its original bytes.
27
+ * Command identity adds no text: the leading editable source already contains it.
28
+ */
29
+ export declare function exportComposerText(document: ComposerDocument): string;
30
+ /** Markdown stays editable source; quote blocks use the same readable projection. */
31
+ export declare const exportComposerMarkdown: typeof exportComposerText;
@@ -0,0 +1,24 @@
1
+ import type { ChatComposerCompletion, ChatComposerProps, ChatComposerSubmission } from "../Chat.types";
2
+ export interface AttachmentEntry {
3
+ file: File;
4
+ id: number;
5
+ }
6
+ /** Match each occurrence once; removing and reselecting a File creates a new ID. */
7
+ export declare function reconcileAttachments(previous: readonly AttachmentEntry[], files: readonly File[], nextId: number): {
8
+ entries: AttachmentEntry[];
9
+ nextId: number;
10
+ };
11
+ export declare function legacyEligibility({ value, attachments, allowAttachmentOnly, canSubmit, disabled, busy, submitting, }: Pick<ChatComposerProps, "value" | "attachments" | "allowAttachmentOnly" | "canSubmit" | "disabled" | "busy"> & {
12
+ submitting: boolean;
13
+ }): boolean;
14
+ export declare function legacyCompletion(candidates: readonly ChatComposerCompletion[], activeId?: string): {
15
+ enabled: ChatComposerCompletion[];
16
+ active: ChatComposerCompletion;
17
+ };
18
+ export declare function moveLegacyCompletion(enabled: readonly ChatComposerCompletion[], activeId: string | undefined, direction: 1 | -1): string | undefined;
19
+ export declare function legacySnapshot(value: string, files: readonly File[], revision: number, entries: readonly AttachmentEntry[]): {
20
+ submission: ChatComposerSubmission;
21
+ revision: number;
22
+ entryIds: Set<number>;
23
+ };
24
+ export declare function retainUnsubmittedAttachments(entries: readonly AttachmentEntry[], submittedIds: ReadonlySet<number>): AttachmentEntry[];
@@ -2,3 +2,6 @@ export * from "./Chat";
2
2
  export * from "./ChatComposer";
3
3
  export * from "./ChatPrimitives";
4
4
  export type * from "./Chat.types";
5
+ export type * from "./Composer.types";
6
+ export { readComposerDocument, readComposerDraft, snapshotComposerDocument, snapshotComposerSubmission, exportComposerText, exportComposerMarkdown, } from "./composer/document";
7
+ export type { ComposerReadResult } from "./composer/document";