curiouscorrelation e4adfd6e30 fix(desktop): http version deserialization | 1 день назад | |
---|---|---|
.. | ||
src | 1 день назад | |
README.md | 1 неделя назад | |
package.json | 1 неделя назад | |
tsconfig.base.json | 1 неделя назад | |
tsconfig.decl.json | 1 неделя назад | |
tsconfig.json | 1 неделя назад | |
vite.config.d.ts | 1 неделя назад | |
vite.config.ts | 1 неделя назад |
Cross-platform abstraction kernel for Hoppscotch, a unified interface between application logic and platform-specific implementations.
The kernel acts as a thin abstraction layer, mediating between high-level application logic and low-level platform implementations, similar to how operating system kernels abstract over hardware details. This helps the core Hoppscotch app be platform-agnostic while maintaining near native performance.
This codebase is minimal by design, providing just the building blocks for constructing features. If possible, always try composition before modifying the kernel directly.
File system and external resource handling:
interface IoV1 {
saveFileWithDialog(opts: SaveFileWithDialogOptions): Promise<SaveFileResponse>
openExternalLink(opts: OpenExternalLinkOptions): Promise<OpenExternalLinkResponse>
listen<T>(event: string, handler: EventCallback<T>): Promise<UnlistenFn>
}
Network operations with platform-specific optimizations:
interface RelayV1 {
readonly capabilities: RelayCapabilities
execute(request: RelayRequest): {
cancel: () => Promise<void>
emitter: RelayEventEmitter<RelayRequestEvents>
response: Promise<Either<RelayError, RelayResponse>>
}
}
Cross-platform persistence with encryption support:
interface StoreV1 {
readonly capabilities: Set<StoreCapability>
set(namespace: string, key: string, value: unknown, options?: StorageOptions): Promise<Either<StoreError, void>>
watch(namespace: string, key: string): StoreEventEmitter<StoreEvents>
}
import { initKernel } from '@hoppscotch/kernel'
// Platform-specific initialization
const kernel = initKernel('web' | 'desktop')
import { RelayRequest } from '@hoppscotch/kernel'
const request: RelayRequest = {
id: 1,
url: "https://api.example.com",
method: "GET",
version: "HTTP/1.1",
headers: {
"Content-Type": "application/json"
}
}
// Execute with capability checks
const { response, cancel } = kernel.relay.execute(request)
// Encrypted storage with compression
await kernel.store.set("collections", "team-a", data, {
encrypt: true,
compress: true
})
// Watch for changes
kernel.store.watch("collections", "team-a").on("change",
(update) => console.log("Collection updated:", update)
)
// Platform-agnostic file save
await kernel.io.saveFileWithDialog({
data: new Uint8Array([...]),
suggestedFilename: "export.json",
contentType: "application/json"
})