@anscribe/core 0.1.0 → 1.0.1
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/README.md +22 -3
- package/dist/index.d.mts +11 -1
- package/dist/index.mjs +16 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
# @anscribe/core
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Framework-agnostic Capture model + `CaptureSink` registry. Peer dependency of every Anscribe adapter package.
|
|
4
4
|
|
|
5
|
-
You almost certainly want [`@anscribe/opentui`](https://www.npmjs.com/package/@anscribe/opentui).
|
|
5
|
+
You almost certainly want [`@anscribe/opentui`](https://www.npmjs.com/package/@anscribe/opentui) (`bun add @anscribe/opentui` pulls this in transitively).
|
|
6
6
|
|
|
7
|
-
This package
|
|
7
|
+
This package holds the Schema definitions (`Capture`, `CapturedTarget`, `TerminalCellBounds`, …), the framework-agnostic Capture Mode state machine, and the process-global `CaptureSink` registry that host adapters (`@anscribe/opentui`, future Ink/blessed adapters) read from and that sink producers (`@anscribe/mcp`) write into. Living here — and being a `peerDependencies` entry on every adapter — is what keeps the registry a single instance across packages.
|
|
8
|
+
|
|
9
|
+
## Public API for sink authors
|
|
10
|
+
|
|
11
|
+
Most users never import from `@anscribe/core` directly. The exception is anyone writing or wiring a custom `CaptureSink`:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { type CaptureSink, registerCaptureSink } from "@anscribe/core";
|
|
15
|
+
|
|
16
|
+
const webhookSink: CaptureSink = {
|
|
17
|
+
name: "webhook",
|
|
18
|
+
write: async (capture) => {
|
|
19
|
+
await fetch("https://example.com/captures", { method: "POST", body: JSON.stringify(capture) });
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
registerCaptureSink(webhookSink);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`readRegisteredCaptureSinks()` is provided for host adapters; `resetCaptureSinks()` is a test-only escape hatch.
|
|
8
27
|
|
|
9
28
|
## License
|
|
10
29
|
|
package/dist/index.d.mts
CHANGED
|
@@ -402,4 +402,14 @@ interface CaptureSink {
|
|
|
402
402
|
readonly close?: () => Promise<void>;
|
|
403
403
|
}
|
|
404
404
|
//#endregion
|
|
405
|
-
|
|
405
|
+
//#region src/sink-registry.d.ts
|
|
406
|
+
declare const registerCaptureSink: (sink: CaptureSink) => void;
|
|
407
|
+
declare const readRegisteredCaptureSinks: () => ReadonlyArray<CaptureSink>;
|
|
408
|
+
/**
|
|
409
|
+
* Test-only escape hatch. Production code should never call this — the
|
|
410
|
+
* registry is process-global so a stray reset between two consumers in the
|
|
411
|
+
* same process would silently break the second one.
|
|
412
|
+
*/
|
|
413
|
+
declare const resetCaptureSinks: () => void;
|
|
414
|
+
//#endregion
|
|
415
|
+
export { ANSCRIBE_OVERLAY, Capture, CaptureEnrichmentOutput, CaptureHostFailureReporter, CaptureId, CaptureInput, CaptureMetadata, CaptureMetadataEnricher, CaptureMetadataEnrichment, CaptureMode, CaptureModeDispatchError, CaptureModeDispatchResult, CaptureModeIntent, CaptureModeState, CapturePersistence, CapturePersistenceError, CaptureProjectResolutionError, CaptureSink, CaptureStatus, CaptureValidationError, CapturedTarget, CapturedTargetId, IsoTimestamp, type PickerState, ResolvedCaptureProject, SourceReference, TerminalCellBounds, captureStatusSchema, decodeAnscribeData, decodeAnscribeDataEffect, formatCaptureForClipboard, generateCaptureId, generateCapturedTargetId, initialState, isAnscribeOverlay, makeCapture, markAsOverlay, noCaptureEnrichment, parseIsoTimestampMillis, readRegisteredCaptureSinks, registerCaptureSink, resetCaptureSinks, resolveCaptureProjectBoundary, resolveTargetAtCell, selectCurrentTarget, transition };
|
package/dist/index.mjs
CHANGED
|
@@ -408,4 +408,19 @@ function formatSourceLocation(file, line) {
|
|
|
408
408
|
return line !== void 0 ? `${file}:${line}` : file;
|
|
409
409
|
}
|
|
410
410
|
//#endregion
|
|
411
|
-
|
|
411
|
+
//#region src/sink-registry.ts
|
|
412
|
+
const registeredSinks = /* @__PURE__ */ new Map();
|
|
413
|
+
const registerCaptureSink = (sink) => {
|
|
414
|
+
registeredSinks.set(sink.name, sink);
|
|
415
|
+
};
|
|
416
|
+
const readRegisteredCaptureSinks = () => Array.from(registeredSinks.values());
|
|
417
|
+
/**
|
|
418
|
+
* Test-only escape hatch. Production code should never call this — the
|
|
419
|
+
* registry is process-global so a stray reset between two consumers in the
|
|
420
|
+
* same process would silently break the second one.
|
|
421
|
+
*/
|
|
422
|
+
const resetCaptureSinks = () => {
|
|
423
|
+
registeredSinks.clear();
|
|
424
|
+
};
|
|
425
|
+
//#endregion
|
|
426
|
+
export { ANSCRIBE_OVERLAY, Capture, CaptureHostFailureReporter, CaptureId, CaptureMetadata, CaptureMetadataEnrichment, CaptureMode, CaptureModeIntent, CapturePersistence, CapturePersistenceError, CaptureProjectResolutionError, CaptureValidationError, CapturedTarget, CapturedTargetId, IsoTimestamp, SourceReference, TerminalCellBounds, captureStatusSchema, decodeAnscribeData, decodeAnscribeDataEffect, formatCaptureForClipboard, generateCaptureId, generateCapturedTargetId, initialState, isAnscribeOverlay, makeCapture, markAsOverlay, noCaptureEnrichment, parseIsoTimestampMillis, readRegisteredCaptureSinks, registerCaptureSink, resetCaptureSinks, resolveCaptureProjectBoundary, resolveTargetAtCell, selectCurrentTarget, transition };
|