sqs-dsh-better-input 0.1.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 (40) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +218 -0
  3. package/assets/banner.png +0 -0
  4. package/cordis.patch.yml +6 -0
  5. package/lib/about.d.ts +65 -0
  6. package/lib/client/MicrophoneButton.d.ts +64 -0
  7. package/lib/client/OptimizeButton.d.ts +33 -0
  8. package/lib/client/VoiceRecognitionBar.d.ts +14 -0
  9. package/lib/client/index.d.ts +14 -0
  10. package/lib/client/settings-controller.d.ts +80 -0
  11. package/lib/client/settings.d.ts +15 -0
  12. package/lib/client/strings.d.ts +113 -0
  13. package/lib/client/templates-controller.d.ts +45 -0
  14. package/lib/client/templates-section.d.ts +17 -0
  15. package/lib/client/templates-source.d.ts +16 -0
  16. package/lib/client/voice-session.d.ts +35 -0
  17. package/lib/client/web-speech.d.ts +35 -0
  18. package/lib/client.d.ts +1 -0
  19. package/lib/client.js +2925 -0
  20. package/lib/client.js.map +1 -0
  21. package/lib/config.d.ts +100 -0
  22. package/lib/identity-CzaR1Taa.js +18 -0
  23. package/lib/identity-CzaR1Taa.js.map +1 -0
  24. package/lib/identity.d.ts +24 -0
  25. package/lib/index.d.ts +11 -0
  26. package/lib/index.js +920 -0
  27. package/lib/index.js.map +1 -0
  28. package/lib/polish/prompts.d.ts +37 -0
  29. package/lib/polish/service.d.ts +45 -0
  30. package/lib/remote-contract.d.ts +166 -0
  31. package/lib/remote.d.ts +56 -0
  32. package/lib/remote.js +226 -0
  33. package/lib/remote.js.map +1 -0
  34. package/lib/settings/store.d.ts +41 -0
  35. package/lib/templates/model.d.ts +30 -0
  36. package/lib/templates/store.d.ts +27 -0
  37. package/lib/typert.d.ts +107 -0
  38. package/lib/typert.js +468 -0
  39. package/lib/typert.js.map +1 -0
  40. package/package.json +116 -0
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Client-side store for the prompt template library. Mirrors the settings
3
+ * controller: an external-store class consumed via useSyncExternalStore,
4
+ * one sticky initial fetch (also kicked off by the `/` trigger warm hook),
5
+ * and optimistic list updates after save/remove so the menu and the settings
6
+ * section stay in sync without refetching.
7
+ */
8
+ import type { TemplateWire } from '../remote-contract.js';
9
+ import type { BetterInputRemote } from '../remote.js';
10
+ export type TemplatesSnapshot = {
11
+ readonly status: 'loading' | 'ready' | 'error';
12
+ readonly templates: readonly TemplateWire[];
13
+ readonly detail: string;
14
+ };
15
+ /** Form state: tags stay a raw comma-separated string until save. */
16
+ export type TemplateDraft = {
17
+ readonly id?: string;
18
+ readonly name: string;
19
+ readonly description: string;
20
+ readonly tags: string;
21
+ readonly content: string;
22
+ };
23
+ type Listener = () => void;
24
+ export declare class TemplatesController {
25
+ private readonly remote;
26
+ private snapshot;
27
+ private readonly listeners;
28
+ private disposed;
29
+ private loadPromise;
30
+ constructor(remote: BetterInputRemote);
31
+ readonly getSnapshot: () => TemplatesSnapshot;
32
+ readonly subscribe: (listener: Listener) => (() => void);
33
+ readonly byId: (id: string) => TemplateWire | undefined;
34
+ /** Kick off the one-time initial fetch; safe to call repeatedly. */
35
+ readonly ensureLoaded: () => void;
36
+ refresh(): Promise<void>;
37
+ /** Create or update one template; resolves false when the call failed. */
38
+ save(draft: TemplateDraft): Promise<boolean>;
39
+ /** Remove one template; resolves false when the call failed. */
40
+ remove(id: string): Promise<boolean>;
41
+ dispose(): void;
42
+ private emit;
43
+ }
44
+ export declare function useTemplatesSnapshot(controller: TemplatesController): TemplatesSnapshot;
45
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Settings section for the prompt template library: list saved templates,
3
+ * create/edit through an inline form, and delete with a two-step confirm.
4
+ * Mirrors the settings section conventions (framework-injected `t` + local
5
+ * frame/field components + dsw CSS variables).
6
+ */
7
+ import type { TranslateNS } from '@deepseek-ai/dsh-client-ui-slots';
8
+ import type { TemplatesController } from './templates-controller.js';
9
+ /** The framework-injected `t` seat for the BetterInput namespace. */
10
+ type Translate = TranslateNS<'better-input'>;
11
+ export type TemplatesSectionProps = {
12
+ readonly close: () => void;
13
+ readonly t: Translate;
14
+ readonly templatesController: TemplatesController;
15
+ };
16
+ export declare function TemplatesSection({ t, templatesController }: TemplatesSectionProps): import("react").JSX.Element;
17
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { InputTriggerSource } from '@deepseek-ai/dsh-client-ui-input-trigger/client';
2
+ import type { TemplatesController } from './templates-controller.js';
3
+ /** Unique source name on the `/` trigger (the menu group title). */
4
+ export declare const TEMPLATES_SOURCE_NAME = "better-input-templates";
5
+ /**
6
+ * The input-trigger source that inserts stored prompt templates as literal
7
+ * text on the `/` trigger.
8
+ *
9
+ * - `warm()` prefetches the template list when the input box mounts, so the
10
+ * first `/` keystroke already shows entries.
11
+ * - `candidates()` filters by name / description / tag substring.
12
+ * - `onPick()` returns `{ text: content }` — the trigger token span is
13
+ * replaced by the template body, so `/name` never persists in the draft
14
+ * and no lexicon/codec registration is needed.
15
+ */
16
+ export declare function createTemplatesSource(controller: TemplatesController): InputTriggerSource;
@@ -0,0 +1,35 @@
1
+ export type VoiceInputState = 'idle' | 'starting' | 'recording' | 'transcribing' | 'polishing' | 'error' | 'polish-error';
2
+ export type VoiceInputSessionSnapshot = {
3
+ readonly state: VoiceInputState;
4
+ readonly detail: string;
5
+ };
6
+ type Listener = () => void;
7
+ type StopListener = () => void;
8
+ export declare const VOICE_ERROR_DISMISS_MS = 2600;
9
+ /**
10
+ * Shared voice-input state for one session, written from scratch for
11
+ * sqs-dsh-better-input. The microphone button and the recognition bar both
12
+ * subscribe; the bar can request stop/cancel through the same instance.
13
+ */
14
+ export declare class VoiceInputSession {
15
+ private snapshot;
16
+ private readonly listeners;
17
+ private readonly stopListeners;
18
+ private readonly cancelListeners;
19
+ private epoch;
20
+ private errorTimer;
21
+ captureEpoch(): number;
22
+ isCurrentEpoch(epoch: number): boolean;
23
+ readonly getSnapshot: () => VoiceInputSessionSnapshot;
24
+ readonly subscribe: (listener: Listener) => (() => void);
25
+ readonly onStopRequested: (listener: StopListener) => (() => void);
26
+ readonly onCancelRequested: (listener: StopListener) => (() => void);
27
+ setState(state: VoiceInputState, detail?: string): void;
28
+ requestStop(): void;
29
+ requestCancel(): void;
30
+ dispose(): void;
31
+ private clearErrorTimer;
32
+ private emit;
33
+ }
34
+ export declare function useVoiceInputSession(session: VoiceInputSession): VoiceInputSessionSnapshot;
35
+ export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Browser Web Speech recognition session, written from scratch for
3
+ * sqs-dsh-better-input. Wraps SpeechRecognition / webkitSpeechRecognition with a
4
+ * small structural interface so no DOM lib augmentation is required.
5
+ */
6
+ export type WebSpeechState = 'starting' | 'recording' | 'stopped' | 'error';
7
+ export type WebSpeechSessionOptions = {
8
+ language: string;
9
+ onStart?: () => void;
10
+ onInterim: (text: string) => void;
11
+ onFinal: (text: string) => void;
12
+ onError: (error: Error) => void;
13
+ onEnd: (text: string) => void;
14
+ };
15
+ export declare function isWebSpeechAvailable(): boolean;
16
+ export declare class WebSpeechSession {
17
+ private readonly recognition;
18
+ private readonly options;
19
+ private active;
20
+ private stopping;
21
+ private finalText;
22
+ private lastHeard;
23
+ private ended;
24
+ private silent;
25
+ constructor(options: WebSpeechSessionOptions);
26
+ start(): void;
27
+ stop(): void;
28
+ abort(): void;
29
+ private handleResult;
30
+ private handleError;
31
+ private handleEnd;
32
+ private fail;
33
+ private endOnce;
34
+ }
35
+ export declare function appendSpeech(current: string, next: string): string;
@@ -0,0 +1 @@
1
+ export { apply, inject } from './client/index.js';