@spotpatch/runtime 1.13.0 → 1.14.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.
@@ -0,0 +1,14 @@
1
+ // src/ui/contextual-ask-contract.ts
2
+ var CONTEXTUAL_ASK_EXTENSION_KEY = /* @__PURE__ */ Symbol.for("spotpatch.contextual-ask.v1");
3
+ function registerContextualAskExtension(extension) {
4
+ globalThis[CONTEXTUAL_ASK_EXTENSION_KEY] = extension;
5
+ }
6
+ function getContextualAskExtension() {
7
+ return globalThis[CONTEXTUAL_ASK_EXTENSION_KEY];
8
+ }
9
+
10
+ export {
11
+ registerContextualAskExtension,
12
+ getContextualAskExtension
13
+ };
14
+ //# sourceMappingURL=chunk-KIDHJQRG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui/contextual-ask-contract.ts"],"sourcesContent":["import type { SpotPatchLocale } from \"@spotpatch/shared\";\nimport type {\n AskAnswerResult,\n AskDraftOrigin,\n AskJobEvent,\n AskJobSnapshot,\n AskSourceReference,\n ContextualAskCapability,\n ErrorCode,\n} from \"@spotpatch/shared/contextual-ask-browser\";\nimport type { SelectionSnapshotTarget } from \"../state/selection-session.js\";\n\nimport type { ContextualAskApi } from \"../api/contextual-ask-api.js\";\nimport type { ClipboardWriter } from \"../controller/runtime-environment.js\";\nimport type { FloatingSurfaceProjection } from \"./motion-extension-contract.js\";\n\nexport interface ContextualAskSelectionPreview {\n readonly contextReady: boolean;\n readonly targetCount: number;\n readonly sourceCount: number;\n}\n\nexport interface ContextualAskSelectionDraft {\n readonly locale: SpotPatchLocale;\n readonly targets: readonly SelectionSnapshotTarget[];\n}\n\nexport interface ContextualAskPanel {\n readonly cancelButton: HTMLButtonElement;\n readonly consentCheckbox: HTMLInputElement;\n readonly convertButton: HTMLButtonElement;\n readonly copyButton: HTMLButtonElement;\n readonly executorSelect: HTMLSelectElement;\n readonly newQuestionButton: HTMLButtonElement;\n readonly questionInput: HTMLTextAreaElement;\n readonly root: HTMLElement;\n readonly styles: HTMLStyleElement;\n readonly submitButton: HTMLButtonElement;\n readonly clear: () => void;\n readonly dispose: () => void;\n readonly focusQuestion: () => void;\n readonly mode: () => \"ask\" | \"change\";\n readonly notify: (\n event: \"copied\" | \"copy-failed\" | \"converted\" | \"source-open-failed\",\n ) => void;\n readonly readConsent: () => boolean;\n readonly readExecutorId: () => string | undefined;\n readonly readQuestion: () => string;\n readonly renderAnswer: (result: AskAnswerResult, stale: boolean) => void;\n readonly renderCapability: (capability?: ContextualAskCapability) => void;\n readonly renderError: (code?: ErrorCode) => void;\n readonly renderEvent: (event: AskJobEvent) => void;\n readonly renderJob: (snapshot: AskJobSnapshot) => void;\n readonly selectedSourceId: (target: EventTarget | null) => string | undefined;\n readonly setBusy: (busy: boolean) => void;\n readonly setConsent: (granted: boolean) => void;\n readonly setMode: (mode: \"ask\" | \"change\") => void;\n readonly setOrigin: (origin?: AskDraftOrigin) => void;\n readonly setSelectionPreview: (preview: ContextualAskSelectionPreview) => void;\n readonly setSelectionVisible: (visible: boolean) => void;\n readonly sourceById: (sourceId: string) => AskSourceReference | undefined;\n readonly answerPlainText: () => string;\n}\n\nexport interface ContextualAskWorkflow {\n readonly beginSelection: () => void;\n readonly cancelPending: () => void;\n readonly dispose: () => void;\n readonly isBusy: () => boolean;\n readonly mount: () => void;\n readonly selectionChanged: () => void;\n}\n\nexport interface ContextualAskExtension {\n readonly createPanel: (\n input: Readonly<{\n document: Document;\n locale: () => SpotPatchLocale;\n subscribeLocale: (listener: () => void) => () => void;\n changeRoot: HTMLElement;\n changeActions: HTMLElement;\n announce: (message: string) => void;\n onModeChange: (mode: \"ask\" | \"change\", title: string, subtitle: string) => void;\n onExecutionChange: (projection?: FloatingSurfaceProjection) => void;\n onViewChange: () => void;\n }>,\n ) => ContextualAskPanel;\n readonly createWorkflow: (\n input: Readonly<{\n api?: ContextualAskApi;\n clipboard?: ClipboardWriter;\n createId: () => string;\n fetch: typeof globalThis.fetch;\n getSelection: () => ContextualAskSelectionDraft | undefined;\n onConvert: (origin: AskDraftOrigin) => void;\n onBusyChange: (busy: boolean) => void;\n onOpenSource: (source: AskSourceReference) => Promise<void>;\n panel: ContextualAskPanel;\n sessionToken: string;\n }>,\n ) => ContextualAskWorkflow;\n}\n\nconst CONTEXTUAL_ASK_EXTENSION_KEY = Symbol.for(\"spotpatch.contextual-ask.v1\");\ntype ExtensionStore = Partial<Record<symbol, ContextualAskExtension>>;\n\nexport function registerContextualAskExtension(\n extension: ContextualAskExtension,\n): void {\n (globalThis as ExtensionStore)[CONTEXTUAL_ASK_EXTENSION_KEY] = extension;\n}\n\nexport function getContextualAskExtension(): ContextualAskExtension | undefined {\n return (globalThis as ExtensionStore)[CONTEXTUAL_ASK_EXTENSION_KEY];\n}\n"],"mappings":";AAuGA,IAAM,+BAA+B,uBAAO,IAAI,6BAA6B;AAGtE,SAAS,+BACd,WACM;AACN,EAAC,WAA8B,4BAA4B,IAAI;AACjE;AAEO,SAAS,4BAAgE;AAC9E,SAAQ,WAA8B,4BAA4B;AACpE;","names":[]}