Skip to content

Commit fc1829f

Browse files
committed
update types
1 parent 81f079f commit fc1829f

File tree

5 files changed

+92
-14
lines changed

5 files changed

+92
-14
lines changed

v1-draft-0/typescript-definitions/README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,68 @@
11
# OGraf Typescript Definitions
22

3-
_This definition is intended to be derived from the Source Definitions_
3+
These are Typescript definitions for the OGraf API.
4+
5+
https://github.com/ebu/ograf
6+
7+
## Getting Started
8+
9+
```typescript
10+
11+
import { GraphicsAPI } from 'ograf';
12+
13+
14+
// Setup my OGraf graphic WebComponent:
15+
class MyOGrafGraphic extends HTMLElement implements GraphicsAPI.Graphic {
16+
connectedCallback() {
17+
// Called when the element is added to the DOM
18+
// Note: Don't paint any pixels at this point, wait for load() to be called
19+
}
20+
21+
async load(params) {
22+
if (params.renderType !== "realtime")
23+
throw new Error("Only realtime rendering is supported by this graphic");
24+
25+
const elText = document.createElement("p");
26+
elText.innerHTML = "Hello world!";
27+
this.appendChild(elText);
28+
29+
// When everything is loaded we can return:
30+
return {
31+
statusCode: 200,
32+
};
33+
}
34+
async dispose(_params) {
35+
this.innerHTML = "";
36+
}
37+
async getStatus(_params) {
38+
return {
39+
statusCode: 200,
40+
status: {
41+
// nothing
42+
},
43+
};
44+
}
45+
async updateAction(_params) {
46+
// No actions are implemented in this minimal example
47+
}
48+
async playAction(_params) {
49+
// No actions are implemented in this minimal example
50+
}
51+
async stopAction(_params) {
52+
// No actions are implemented in this minimal example
53+
}
54+
async customAction(params) {
55+
// No actions are implemented in this minimal example
56+
}
57+
async goToTime(_payload) {
58+
throw new Error("Non-realtime not supported!");
59+
}
60+
async setActionsSchedule(_payload) {
61+
throw new Error("Non-realtime not supported!");
62+
}
63+
}
64+
65+
```
466

567

668
## For Developers

v1-draft-0/typescript-definitions/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v1-draft-0/typescript-definitions/package.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
{
2-
"name": "html-graphics-definition",
3-
"version": "0.0.0",
2+
"name": "ograf",
3+
"version": "0.0.1",
44
"main": "dist/main.js",
5+
"typings": "dist/index.d.ts",
56
"license": "MIT",
7+
"description": "TypeScript definitions for Ograf graphics",
8+
"homepage": "https://github.com/ebu/ograf",
9+
"keywords": [
10+
"ograf",
11+
"types",
12+
"typescript",
13+
"ebu",
14+
"broadcast",
15+
"graphics"
16+
],
617
"scripts": {
718
"build": "tsc --build",
819
"watch": "tsc --watch",
9-
"generate-types": "node scripts/generate-types.js"
20+
"generate-types": "node scripts/generate-types.js",
21+
"do:publish": "npm run generate-types && npm run build && npm publish --access public"
1022
},
1123
"devDependencies": {
1224
"typescript": "^5.6.3",

v1-draft-0/typescript-definitions/scripts/generate-types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const path = require("path");
33
const fs = require("fs");
44

55
async function main() {
6+
7+
68
const outputPath = path.resolve("./src/generated");
79
const schemaPath = path.resolve("../specification/json-schemas/graphics");
810
const options = {

v1-draft-0/typescript-definitions/src/apis/graphicsAPI.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ import {
1515
*/
1616

1717
/**
18-
* Methods called on a GraphicInstance by the Renderer
18+
* This interface defines the methods that the Renderer can call on the Graphic.
19+
* @example class MyOGrafGraphic extends HTMLElement implements GraphicsAPI.Graphic {}
20+
*
1921
*/
20-
export interface GraphicsApi {
22+
export interface Graphic {
2123
/**
2224
* Called by the Renderer when the Graphic has been loaded into the DOM
2325
* @returns a Promise that resolves when the Graphic has finished loading it's resources.
@@ -90,19 +92,19 @@ export interface GraphicsApi {
9092
action:
9193
| ({
9294
type: "updateAction";
93-
params: Parameters<GraphicsApi["updateAction"]>[0];
95+
params: Parameters<Graphic["updateAction"]>[0];
9496
} & VendorExtend)
9597
| ({
9698
type: "playAction";
97-
params: Parameters<GraphicsApi["playAction"]>[0];
99+
params: Parameters<Graphic["playAction"]>[0];
98100
} & VendorExtend)
99101
| ({
100102
type: "stopAction";
101-
params: Parameters<GraphicsApi["stopAction"]>[0];
103+
params: Parameters<Graphic["stopAction"]>[0];
102104
} & VendorExtend)
103105
| ({
104106
type: "customAction";
105-
params: Parameters<GraphicsApi["customAction"]>[0];
107+
params: Parameters<Graphic["customAction"]>[0];
106108
} & VendorExtend);
107109
}[];
108110
} & VendorExtend

0 commit comments

Comments
 (0)