Skip to content

Commit f57c7b5

Browse files
committedJul 18, 2022
Initial commit
0 parents  commit f57c7b5

File tree

6 files changed

+599
-0
lines changed

6 files changed

+599
-0
lines changed
 

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

‎.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# override .gitignore as we don't want `dist` to be checked in
2+
# but we *do* want it to be included when we publish. Without
3+
# an .nmpignore, npm will use .gitignore by default which is
4+
# what we don't want. node_modules is automatically ignored.
5+
# https://docs.npmjs.com/cli/v8/using-npm/developers#keeping-files-out-of-your-package
6+

‎package-lock.json

+498
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "webxdc-types",
3+
"version": "0.0.1",
4+
"description": "TypeScript type definitions for webxdc",
5+
"homepage": "https://github.com/webxdc/webxdc-types#readme",
6+
"keywords": [
7+
"webxdc",
8+
"deltachat"
9+
],
10+
"license": "unlicense",
11+
"contributors": [
12+
{
13+
"name": "Webxdc devs",
14+
"url": "https://webxdc.org"
15+
},
16+
{
17+
"name": "Martijn Faassen",
18+
"email": "faassen@startifact.com",
19+
"url": "http://blog.startifact.com"
20+
}
21+
],
22+
"types": "./dist/webxdc.d.ts",
23+
"files": [
24+
"dist"
25+
],
26+
"scripts": {
27+
"typecheck": "tsc --noEmit",
28+
"build": "npm run clean && tsc",
29+
"clean": "rimraf dist",
30+
"version": "version-changelog CHANGELOG.md && git add CHANGELOG.md",
31+
"prepublishOnly": "npm run build"
32+
},
33+
"devDependencies": {
34+
"@tsconfig/recommended": "^1.0.1",
35+
"prettier": "^2.7.1",
36+
"rimraf": "^3.0.2",
37+
"typescript": "^4.7.3",
38+
"version-changelog": "^3.1.1"
39+
},
40+
"dependencies": {}
41+
}

‎src/webxdc.ts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
type JsonObject = {
2+
[x: string]: JsonValue;
3+
};
4+
5+
export type JsonValue =
6+
| string
7+
| number
8+
| boolean
9+
| null
10+
| JsonObject
11+
| Array<JsonValue>;
12+
13+
export type Update<T> = {
14+
payload: T;
15+
info?: string;
16+
document?: string;
17+
summary?: string;
18+
};
19+
20+
export type ReceivedUpdate<T> = Update<T> & {
21+
serial: number;
22+
max_serial: number;
23+
};
24+
25+
export type UpdateListener<T> = (update: ReceivedUpdate<T>) => void;
26+
27+
export type SendUpdate<T> = (update: Update<T>, descr: string) => void;
28+
29+
export type SetUpdateListener<T> = (
30+
listener: UpdateListener<T>,
31+
serial: number
32+
) => Promise<void>;
33+
34+
export type WebXdc<T = JsonValue> = {
35+
sendUpdate: SendUpdate<T>;
36+
setUpdateListener: SetUpdateListener<T>;
37+
selfAddr: string;
38+
selfName: string;
39+
};

‎tsconfig.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "@tsconfig/recommended/tsconfig.json",
3+
"include": ["src"],
4+
"compilerOptions": {
5+
"target": "ES2016",
6+
"module": "commonjs",
7+
"outDir": "dist",
8+
"declaration": true,
9+
"emitDeclarationOnly": true,
10+
"declarationDir": "dist",
11+
"resolveJsonModule": true
12+
}
13+
}

0 commit comments

Comments
 (0)
Please sign in to comment.