API reference
@searsuite/sear-foundation-platform
Injectable timing, events, view geometry, identifiers, and host diagnostics.
28 exportsderived from source
Concept 1
Supply an environment through Platform
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.
Concept 2
Keep host effects at the boundary
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.
- classBrowserPlatformsource ↗
-
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.
constructorconstructor BrowserPlatform(): BrowserPlatformpropertysymbolstatic readonly symbol: symbolDI token for resolving BrowserPlatform.
methodaddEventListener addEventListener(target: unknown, type: string, listener: (event: unknown): void, options?: PlatformEventListenerOptions): (): voidRegisters a host event listener and returns an idempotent disposer.
target: unknowntype: stringlistener: (event: unknown): voidoptions: PlatformEventListenerOptions
methodcancelAnimationFrame cancelAnimationFrame(handle: number): voidCancels a previously scheduled host animation frame.
handle: number
methodclearInterval clearInterval(handle: number): voidCancels a repeating host timer.
handle: number
methodclearTimeout clearTimeout(handle: number): voidCancels a one-shot host timer.
handle: number
methodcreateId createId(prefix?: string): stringCreates a Web-platform client/runtime identifier.
prefix: string
methodcurrentDateTime currentDateTime(): numberReturns the host wall-clock time as Unix milliseconds.
methodnow now(): numberReturns the host's monotonic time in milliseconds.
methodobserveResize observeResize(target: unknown, callback: (size: { height: number; width: number }): void): (): voidObserves host-view size changes and returns an idempotent disposer.
target: unknowncallback: (size: { height: number; width: number }): void
methodqueueMicrotask queueMicrotask(callback: (): void): voidSchedules a callback in the host microtask queue.
callback: (): void
methodreadViewOffset readViewOffset(target: unknown): PlatformViewOffsetReads an element's document-relative viewport offset.
target: unknown
methodrequestAnimationFrame requestAnimationFrame(callback: PlatformFrameRequestCallback): numberSchedules a callback for the next host animation frame.
callback: PlatformFrameRequestCallback
methodsetInterval setInterval(callback: (): void, ms: number): numberUpdates the interval.
callback: (): voidms: number
methodsetTimeout setTimeout(callback: (): void, ms: number): numberUpdates the timeout.
callback: (): voidms: number
methodwarn warn(message: string, ...details: unknown[]): voidReports a non-fatal diagnostic through the host warning channel.
message: stringdetails: unknown[]
- classFileDownloadsource ↗
-
class FileDownloadReplaceable host capability for saving generated files.
constructorconstructor FileDownload(): FileDownloadpropertysymbolstatic readonly symbol: typeof symbolToken for host composition roots that register the capability through DI.
methoddestroy destroy(): voidReleases pending host resources, idempotently.
methoddownload download(request: FileDownloadRequest): voidInitiates one host file save.
request: FileDownloadRequest
- classHeadlessPlatformsource ↗
-
class HeadlessPlatform extends PlatformPlatform adapter for Node and other environments without a UI surface.
constructorconstructor HeadlessPlatform(): HeadlessPlatformpropertysymbolstatic readonly symbol: symbolDI token for resolving HeadlessPlatform.
methodaddEventListener addEventListener(_target: unknown, _type: string, _listener: (event: unknown): void): (): voidRegisters a host event listener and returns an idempotent disposer.
_target: unknown_type: string_listener: (event: unknown): void
methodcancelAnimationFrame cancelAnimationFrame(handle: number): voidCancels a previously scheduled host animation frame.
handle: number
methodclearInterval clearInterval(handle: number): voidCancels a repeating host timer.
handle: number
methodclearTimeout clearTimeout(handle: number): voidCancels a one-shot host timer.
handle: number
methodcreateId createId(prefix?: string): stringCreates a deterministic process-local runtime identifier.
prefix: string
methodcurrentDateTime currentDateTime(): numberReturns the host wall-clock time as Unix milliseconds.
methodnow now(): numberReturns the host's monotonic time in milliseconds.
methodobserveResize observeResize(_target: unknown, _callback: (size: { height: number; width: number }): void): (): voidObserves host-view size changes and returns an idempotent disposer.
_target: unknown_callback: (size: { height: number; width: number }): void
methodqueueMicrotask queueMicrotask(callback: (): void): voidSchedules a callback in the host microtask queue.
callback: (): void
methodreadViewOffset readViewOffset(_target: unknown): PlatformViewOffsetHeadless targets have no host-space offset.
_target: unknown
methodrequestAnimationFrame requestAnimationFrame(callback: PlatformFrameRequestCallback): numberSchedules a callback for the next host animation frame.
callback: PlatformFrameRequestCallback
methodsetInterval setInterval(callback: (): void, ms: number): numberUpdates the interval.
callback: (): voidms: number
methodsetTimeout setTimeout(callback: (): void, ms: number): numberUpdates the timeout.
callback: (): voidms: number
methodwarn warn(message: string, ...details: unknown[]): voidReports a non-fatal diagnostic through the host warning channel.
message: stringdetails: unknown[]
- classHeadlessWebServiceClientsource ↗
-
class HeadlessWebServiceClient extends WebServiceClientNode/headless fetch adapter. Hosts remain responsible for SSRF and network policy.
constructorconstructor HeadlessWebServiceClient(): HeadlessWebServiceClientpropertysymbolstatic readonly symbol: symbolDI token for resolving the editor-local web-service adapter.
methodrequest request(url: string, options?: WebServiceRequestOptions): Promise<WebServiceResponse>Performs one request; callers own caching, cancellation, and invalidation.
url: stringoptions: WebServiceRequestOptions
- classPlatformsource ↗
-
class Platformconstructorconstructor Platform(): Platformpropertysymbolstatic readonly symbol: symbolDI token for resolving Platform.
methodaddEventListener addEventListener(target: unknown, type: string, listener: (event: unknown): void, options?: PlatformEventListenerOptions): (): voidAdds a platform event listener and returns its disposer.
target: unknowntype: stringlistener: (event: unknown): voidoptions: PlatformEventListenerOptions
methodcancelAnimationFrame cancelAnimationFrame(handle: number): voidCancels a previously scheduled host animation frame.
handle: number
methodclearInterval clearInterval(handle: number): voidCancels a repeating host timer.
handle: number
methodclearTimeout clearTimeout(handle: number): voidCancels a one-shot host timer.
handle: number
methodcreateId createId(prefix?: string): stringCreates a process- or session-unique identifier for runtime protocols.
prefix: string
methodcurrentDateTime currentDateTime(): numberReturns the host wall-clock time as Unix milliseconds.
methodnow now(): numberReturns the host's monotonic time in milliseconds.
methodobserveResize observeResize(target: unknown, callback: (size: { height: number; width: number }): void): (): voidObserves the CSS-pixel size of a platform render target.
target: unknowncallback: (size: { height: number; width: number }): void
methodqueueMicrotask queueMicrotask(callback: (): void): voidSchedules a callback in the host microtask queue.
callback: (): void
methodreadViewOffset readViewOffset(target: unknown): PlatformViewOffsetReads a render target's offset in host view coordinates.
target: unknown
methodrequestAnimationFrame requestAnimationFrame(callback: PlatformFrameRequestCallback): numberSchedules a callback for the next host animation frame.
callback: PlatformFrameRequestCallback
methodsetInterval setInterval(callback: (): void, ms: number): numberUpdates the interval.
callback: (): voidms: number
methodsetTimeout setTimeout(callback: (): void, ms: number): numberUpdates the timeout.
callback: (): voidms: number
methodtoLowerCase toLowerCase(value: string): stringConverts text to lowercase without consulting the host's locale.
value: string
methodwarn warn(message: string, ...details: unknown[]): voidReports a non-fatal platform warning.
message: stringdetails: unknown[]
- classWebFetchServiceClientsource ↗
-
class WebFetchServiceClient extends WebServiceClientBrowser fetch adapter. CORS and host security policy remain browser-owned concerns.
constructorconstructor WebFetchServiceClient(): WebFetchServiceClientpropertysymbolstatic readonly symbol: symbolDI token for resolving the editor-local web-service adapter.
methodrequest request(url: string, options?: WebServiceRequestOptions): Promise<WebServiceResponse>Performs one request; callers own caching, cancellation, and invalidation.
url: stringoptions: WebServiceRequestOptions
- classWebFileDownloadsource ↗
-
class WebFileDownload extends FileDownloadWeb file-save adapter; native elements and object URLs never enter the neutral contract.
constructorconstructor WebFileDownload(platform: Platform): WebFileDownloadReceives the owning host's timer adapter explicitly.
platform: Platform
methoddestroy destroy(): voidCancels pending release callbacks and revokes every retained object URL.
methoddownload download(request: FileDownloadRequest): voidInitiates a native file save and tracks its delayed resource release.
request: FileDownloadRequest
- classWebServiceClientsource ↗
-
class WebServiceClientPlatform-neutral asynchronous HTTP boundary for service-backed formulas.
constructorconstructor WebServiceClient(): WebServiceClientpropertysymbolstatic readonly symbol: symbolDI token for resolving the editor-local web-service adapter.
methodrequest request(url: string, options?: WebServiceRequestOptions): Promise<WebServiceResponse>Performs one request; callers own caching, cancellation, and invalidation.
url: stringoptions: WebServiceRequestOptions
- classWebServiceErrorsource ↗
-
class WebServiceError extends SearErrorPublic error raised by a web-service adapter.
constructorconstructor WebServiceError(message: string, details?: Readonly<Record<string, unknown>>): WebServiceErrormessage: stringdetails: Readonly<Record<string, unknown>>
propertycode readonly code: "WEB_SERVICE_REQUEST_FAILED"Stable machine-readable identifier for this error category.
Inherited members 9
Inherited from SearError.
- classWebXmlXPathEvaluatorsource ↗
-
class WebXmlXPathEvaluator extends XmlXPathEvaluatorBrowser-native XML/XPath adapter backed by DOMParser and XPathEvaluator.
constructorconstructor WebXmlXPathEvaluator(): WebXmlXPathEvaluatorpropertysymbolstatic readonly symbol: symbolDI token for resolving the editor-local XML/XPath adapter.
- classXmlXPathErrorsource ↗
-
class XmlXPathError extends SearErrorPublic failure raised by XML/XPath adapters.
constructorconstructor XmlXPathError(code: XmlXPathErrorCode, message: string, details?: Readonly<Record<string, unknown>>): XmlXPathErrorcode: XmlXPathErrorCodemessage: stringdetails: Readonly<Record<string, unknown>>
Inherited members 10
Inherited from SearError.
- classXmlXPathEvaluatorsource ↗
-
class XmlXPathEvaluatorPlatform-neutral XML/XPath execution boundary used by formula adapters.
constructorconstructor XmlXPathEvaluator(): XmlXPathEvaluatorpropertysymbolstatic readonly symbol: symbolDI token for resolving the editor-local XML/XPath adapter.
methodevaluate evaluate(xml: string, xpath: string, options?: XmlXPathOptions): XmlXPathEvaluationEvaluates an XPath expression against one XML document.
xml: stringxpath: stringoptions: XmlXPathOptions
- interfaceFileDownloadRequestsource ↗
-
interface FileDownloadRequestHost-neutral request to save an in-memory file.
- interfacePlatformEventListenerOptionssource ↗
-
interface PlatformEventListenerOptionsEvent-routing options supported by host adapters.
propertycapture readonly capture?: booleanReceives propagated events before target handlers can consume them.
- interfacePlatformViewOffsetsource ↗
-
interface PlatformViewOffset - interfaceWebServiceCancellationsource ↗
-
interface WebServiceCancellationHost-neutral request cancellation.
- interfaceWebServiceRequestOptionssource ↗
-
interface WebServiceRequestOptionspropertycancellation readonly cancellation?: WebServiceCancellationpropertyheaders readonly headers?: Readonly<Record<string, string>> - interfaceWebServiceResponsesource ↗
-
interface WebServiceResponseFully consumed response; platform-native response objects never escape an adapter.
- interfaceXmlXPathEvaluationsource ↗
-
interface XmlXPathEvaluationResult values in document order; selected nodes contribute their string values.
propertyvalues readonly values: readonly string[] - interfaceXmlXPathOptionssource ↗
-
interface XmlXPathOptionsExplicit prefix bindings used by an XPath expression.
propertynamespaces readonly namespaces?: Readonly<Record<string, string>> - typePlatformFrameRequestCallbacksource ↗
-
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.
- typeWebServiceErrorCodesource ↗
-
type WebServiceErrorCode = typeof WebServiceErrorCode[keyof typeof WebServiceErrorCode] - typeXmlXPathErrorCodesource ↗
-
type XmlXPathErrorCode = typeof XmlXPathErrorCode[keyof typeof XmlXPathErrorCode] - variablePlatformEventNamesource ↗
-
PlatformEventName: { Click: "click"; MouseDown: "mousedown"; MouseMove: "mousemove"; MouseUp: "mouseup" }Canonical event names understood by platform event adapters.
- variableWebServiceErrorCodesource ↗
-
WebServiceErrorCode: { RequestFailed: "WEB_SERVICE_REQUEST_FAILED" } - variableXmlXPathErrorCodesource ↗
-
XmlXPathErrorCode: { InvalidXml: "XML_INVALID"; InvalidXPath: "XPATH_INVALID"; UnsupportedResult: "XPATH_UNSUPPORTED_RESULT" } - functionisHttpWebServiceUrlsource ↗
-
isHttpWebServiceUrl(url: string): booleanValidates absolute HTTP(S) URL syntax without enforcing host-owned network access policy.
url: string
No public exports match that search.