aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/qtart.ts
blob: 373daeae779f2af35236af380794ee5d61ce7edf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// @ts-ignore
import * as _qjsOsImp from "os";
// @ts-ignore
import * as _qjsStdImp from "std";

export interface QjsHttpResp {
  status: number;
  data: ArrayBuffer;
  headers?: string[];
}

export interface QjsHttpOptions {
  method: string;
  debug?: boolean;
  data?: ArrayBuffer;
  headers?: string[];
}

export interface QjsOsLib {
  fetchHttp(url: string, options?: QjsHttpOptions): {
    requestId: number,
    promise: Promise<QjsHttpResp>,
    cancelFn: (reqId: number) => number,
  };
  postMessageToHost(s: string): void;
  setMessageFromHostHandler(h: (s: string) => void): void;
  rename(oldPath: string, newPath: string): number;
  remove(path: string): number;
}

export interface QjsStdLib {
  writeFile(filename: string, contents: string): void;
  loadFile(filename: string): string;
}

// This is not the nodejs "os" module, but the qjs "os" module.
export const qjsOs: QjsOsLib = _qjsOsImp as any;

export const qjsStd: QjsStdLib = _qjsStdImp as any;