@searsuite/sear-foundation-platform
Host platforms
Platform is the injected contract for timing, events, view offsets, identifiers, and diagnostics. Reusable
packages depend on this contract so the same editor state and command logic can run in different hosts.
BrowserPlatform and HeadlessPlatform are concrete choices for their respective environments.
Use when: assembling an editor for a host or implementing a new host adapter. Supply one Platform instance to the editor-local composition root. Event listeners and timers acquired through it must be released when the editor is destroyed; a child editor must not dispose services borrowed from its parent.
File downloads, web requests, and XML evaluation are separate capabilities with abstract contracts and concrete Web or headless implementations. A feature receives the capability it needs; it does not read browser globals or choose the application's credentials, transport, and file-saving policy.
FileDownload illustrates the relationship: an export feature prepares data, while the host-provided adapter
decides how a file is saved. A headless host can use an unavailable implementation when saving is intentionally
unsupported. The document state does not change merely because a host performs this effect.
- classPlatform
-
constructor Platform(): Platformproperty readonly symbol: symbolstaticDI token for resolving Platform.
method addEventListener(target: unknown, type: string, listener: (event: unknown): void, options?: PlatformEventListenerOptions): (): voidAdds a platform event listener and returns its disposer.
method cancelAnimationFrame(handle: number): voidCancels a previously scheduled host animation frame.
method clearInterval(handle: number): voidCancels a repeating host timer.
method clearTimeout(handle: number): voidCancels a one-shot host timer.
method createId(prefix?: string): stringCreates a process- or session-unique identifier for runtime protocols.
method currentDateTime(): numberReturns the host wall-clock time as Unix milliseconds.
method now(): numberReturns the host's monotonic time in milliseconds.
method observeResize(target: unknown, callback: (size: { height: number; width: number }): void): (): voidObserves the CSS-pixel size of a platform render target.
method queueMicrotask(callback: (): void): voidSchedules a callback in the host microtask queue.
method readViewOffset(target: unknown): PlatformViewOffsetReads a render target's offset in host view coordinates.
method requestAnimationFrame(callback: PlatformFrameRequestCallback): numberSchedules a callback for the next host animation frame.
method setInterval(callback: (): void, ms: number): numberUpdates the interval.
method setTimeout(callback: (): void, ms: number): numberUpdates the timeout.
method toLowerCase(value: string): stringConverts text to lowercase without consulting the host's locale.
method warn(message: string, ...details: unknown[]): voidReports a non-fatal platform warning.
- classBrowserPlatform
-
class BrowserPlatform extends PlatformBrowser platform implementation that delegates to window / performance / queueMicrotask global APIs.
Instantiate only in browser environments. Other platforms such as Node, mini apps, and React Native should provide their own Platform implementations.
constructor BrowserPlatform(): BrowserPlatformproperty readonly symbol: symbolstaticDI token for resolving BrowserPlatform.
method addEventListener(target: unknown, type: string, listener: (event: unknown): void, options?: PlatformEventListenerOptions): (): voidRegisters a host event listener and returns an idempotent disposer.
method cancelAnimationFrame(handle: number): voidCancels a previously scheduled host animation frame.
method clearInterval(handle: number): voidCancels a repeating host timer.
method clearTimeout(handle: number): voidCancels a one-shot host timer.
method createId(prefix?: string): stringCreates a Web-platform client/runtime identifier.
method currentDateTime(): numberReturns the host wall-clock time as Unix milliseconds.
method now(): numberReturns the host's monotonic time in milliseconds.
method observeResize(target: unknown, callback: (size: { height: number; width: number }): void): (): voidObserves host-view size changes and returns an idempotent disposer.
method queueMicrotask(callback: (): void): voidSchedules a callback in the host microtask queue.
method readViewOffset(target: unknown): PlatformViewOffsetReads an element's document-relative viewport offset.
method requestAnimationFrame(callback: PlatformFrameRequestCallback): numberSchedules a callback for the next host animation frame.
method setInterval(callback: (): void, ms: number): numberUpdates the interval.
method setTimeout(callback: (): void, ms: number): numberUpdates the timeout.
method warn(message: string, ...details: unknown[]): voidReports a non-fatal diagnostic through the host warning channel.
- classHeadlessPlatform
-
class HeadlessPlatform extends PlatformPlatform adapter for Node and other environments without a UI surface.
constructor HeadlessPlatform(): HeadlessPlatformproperty readonly symbol: symbolstaticDI token for resolving HeadlessPlatform.
method addEventListener(_target: unknown, _type: string, _listener: (event: unknown): void): (): voidRegisters a host event listener and returns an idempotent disposer.
method cancelAnimationFrame(handle: number): voidCancels a previously scheduled host animation frame.
method clearInterval(handle: number): voidCancels a repeating host timer.
method clearTimeout(handle: number): voidCancels a one-shot host timer.
method createId(prefix?: string): stringCreates a deterministic process-local runtime identifier.
method currentDateTime(): numberReturns the host wall-clock time as Unix milliseconds.
method now(): numberReturns the host's monotonic time in milliseconds.
method observeResize(_target: unknown, _callback: (size: { height: number; width: number }): void): (): voidObserves host-view size changes and returns an idempotent disposer.
method queueMicrotask(callback: (): void): voidSchedules a callback in the host microtask queue.
method readViewOffset(_target: unknown): PlatformViewOffsetHeadless targets have no host-space offset.
method requestAnimationFrame(callback: PlatformFrameRequestCallback): numberSchedules a callback for the next host animation frame.
method setInterval(callback: (): void, ms: number): numberUpdates the interval.
method setTimeout(callback: (): void, ms: number): numberUpdates the timeout.
method warn(message: string, ...details: unknown[]): voidReports a non-fatal diagnostic through the host warning channel.
- interfacePlatformEventListenerOptions
-
Event-routing options supported by host adapters.
property readonly capture?: booleanReceives propagated events before target handlers can consume them.
- interfacePlatformViewOffset
-
property readonly x: numberproperty readonly y: number - typePlatformFrameRequestCallback
-
type PlatformFrameRequestCallback = (time: number): voidPlatform abstraction that narrows browser-specific APIs into injectable capabilities.
Each platform (browser, Node, mini app, React Native, etc.) provides its own implementation. Application code injects Platform through DI instead of calling global APIs directly.
- variablePlatformEventName
-
PlatformEventName: { Click: "click"; MouseDown: "mousedown"; MouseMove: "mousemove"; MouseUp: "mouseup" }Canonical event names understood by platform event adapters.
Network services
- classHeadlessWebServiceClient
-
class HeadlessWebServiceClient extends WebServiceClientNode/headless fetch adapter. Hosts remain responsible for SSRF and network policy.
constructor HeadlessWebServiceClient(): HeadlessWebServiceClientproperty readonly symbol: symbolstaticDI token for resolving the editor-local web-service adapter.
method request(url: string, options?: WebServiceRequestOptions): Promise<WebServiceResponse>Performs one request; callers own caching, cancellation, and invalidation.
- classWebFetchServiceClient
-
class WebFetchServiceClient extends WebServiceClientBrowser fetch adapter. CORS and host security policy remain browser-owned concerns.
constructor WebFetchServiceClient(): WebFetchServiceClientproperty readonly symbol: symbolstaticDI token for resolving the editor-local web-service adapter.
method request(url: string, options?: WebServiceRequestOptions): Promise<WebServiceResponse>Performs one request; callers own caching, cancellation, and invalidation.
- classWebServiceClient
-
Platform-neutral asynchronous HTTP boundary for service-backed formulas.
constructor WebServiceClient(): WebServiceClientproperty readonly symbol: symbolstaticDI token for resolving the editor-local web-service adapter.
method request(url: string, options?: WebServiceRequestOptions): Promise<WebServiceResponse>Performs one request; callers own caching, cancellation, and invalidation.
- classWebServiceError
-
class WebServiceError extends SearErrorPublic error raised by a web-service adapter.
constructor WebServiceError(message: string, details?: Readonly<Record<string, unknown>>): WebServiceErrorproperty readonly code: "WEB_SERVICE_REQUEST_FAILED"Stable machine-readable identifier for this error category.
Inherited members 9
Inherited from SearError.
- interfaceWebServiceCancellation
-
Host-neutral request cancellation.
- interfaceWebServiceRequestOptions
- interfaceWebServiceResponse
-
Fully consumed response; platform-native response objects never escape an adapter.
- typeWebServiceErrorCode
-
type WebServiceErrorCode = typeof WebServiceErrorCode[keyof typeof WebServiceErrorCode]WebServiceErrorCode: { RequestFailed: "WEB_SERVICE_REQUEST_FAILED" } - functionisHttpWebServiceUrl
-
isHttpWebServiceUrl(url: string): booleanValidates absolute HTTP(S) URL syntax without enforcing host-owned network access policy.
XML evaluation
- classWebXmlXPathEvaluator
-
class WebXmlXPathEvaluator extends XmlXPathEvaluatorBrowser-native XML/XPath adapter backed by DOMParser and XPathEvaluator.
constructor WebXmlXPathEvaluator(): WebXmlXPathEvaluatorproperty readonly symbol: symbolstaticDI token for resolving the editor-local XML/XPath adapter.
- classXmlXPathError
-
class XmlXPathError extends SearErrorPublic failure raised by XML/XPath adapters.
Inherited members 10
Inherited from SearError.
- classXmlXPathEvaluator
-
Platform-neutral XML/XPath execution boundary used by formula adapters.
constructor XmlXPathEvaluator(): XmlXPathEvaluatorproperty readonly symbol: symbolstaticDI token for resolving the editor-local XML/XPath adapter.
method evaluate(xml: string, xpath: string, options?: XmlXPathOptions): XmlXPathEvaluationEvaluates an XPath expression against one XML document.
- interfaceXmlXPathEvaluation
-
Result values in document order; selected nodes contribute their string values.
- interfaceXmlXPathOptions
-
Explicit prefix bindings used by an XPath expression.
- typeXmlXPathErrorCode
-
type XmlXPathErrorCode = typeof XmlXPathErrorCode[keyof typeof XmlXPathErrorCode]XmlXPathErrorCode: { InvalidXml: "XML_INVALID"; InvalidXPath: "XPATH_INVALID"; UnsupportedResult: "XPATH_UNSUPPORTED_RESULT" }
File downloads
FileDownload lets an export feature request a download without owning browser APIs.
- classFileDownload
-
Replaceable host capability for saving generated files.
constructor FileDownload(): FileDownloadproperty readonly symbol: typeof symbolstaticToken for host composition roots that register the capability through DI.
method destroy(): voidReleases pending host resources, idempotently.
method download(request: FileDownloadRequest): voidInitiates one host file save.
- classWebFileDownload
-
class WebFileDownload extends FileDownloadWeb file-save adapter; native elements and object URLs never enter the neutral contract.
constructor WebFileDownload(platform: Platform): WebFileDownloadReceives the owning host's timer adapter explicitly.
method destroy(): voidCancels pending release callbacks and revokes every retained object URL.
method download(request: FileDownloadRequest): voidInitiates a native file save and tracks its delayed resource release.
- interfaceFileDownloadRequest
-
Host-neutral request to save an in-memory file.
property readonly data: string | Uint8Array<ArrayBufferLike>Text or binary file contents.
property readonly mediaType: stringFile media type.
property readonly name: stringSuggested file name.
No matching API entries.