From aca5489122770357a12b60ceb902ab5ea4cdb3c2 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 28 Jan 2022 16:59:33 +0100 Subject: [PATCH] fix typos in typescript definition, reword some vars --- README.md | 2 +- webxdc.d.ts | 25 +++++++++++++------------ webxdc.js | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b666b05..985e7ff 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ just add these two lines to your javascript source files: ```js //@ts-check -/** @typedef {import('./webxdc').WEBxDC} WEBxDC */ +/** @typedef {import('./webxdc').Webxdc} WEBxDC */ ``` Without vscode you need to install typescript and then run the check manually. diff --git a/webxdc.d.ts b/webxdc.d.ts index b0a4fb4..d672413 100644 --- a/webxdc.d.ts +++ b/webxdc.d.ts @@ -1,6 +1,6 @@ //@ts-check -type SendingStateUpdate = { +type SendingStatusUpdate = { /** the payload, deserialized json: * any javascript primitive, array or object. */ payload: T; @@ -15,12 +15,12 @@ type SendingStateUpdate = { summary?: string; }; -type RecievedStateUpdate = { +type ReceivedStatusUpdate = { /** the payload, deserialized json */ payload: T; }; -interface WEBxDC { +interface Webxdc { /** Returns the peer's own address. * This is esp. useful if you want to differ between different peers - just send the address along with the payload, * and, if needed, compare the payload addresses against selfAddr() later on. */ @@ -28,31 +28,32 @@ interface WEBxDC { /** Returns the peer's own name. This is name chosen by the user in their settings, if there is nothing set, that defaults to the peer's address. */ selfName: string; /** - * set a listener for new state updates - * note that own state updates, that you send with {@link sendStateUpdate}, also trigger this method + * set a listener for new status updates + * note that own status updates, that you send with {@link sendUpdate}, also trigger this method * */ - setUpdateListener(cb: (stateUpdate: RecievedStateUpdate) => void): void; + setUpdateListener(cb: (statusUpdate: ReceivedStatusUpdate) => void): void; /** * In case your Webxdc was just started, - * you may want to reconstruct the state from the last run - and also incorporate updates that may have arrived while the app was not running. + * you may want to reconstruct the status from the last run - and also incorporate updates that may have arrived while the app was not running. */ - getAllUpdates(): Promise[]>; + getAllUpdates(): Promise[]>; /** - * Webxdc apps are usually shared in a chat and run independently on each peer. To get a shared state, the peers use sendUpdate() to send updates to each other. + * Webxdc apps are usually shared in a chat and run independently on each peer. To get a shared status, the peers use sendUpdate() to send updates to each other. + * @param update status update to send * @param description short, human-readable description what this update is about. this is shown eg. as a fallback text in an email program. */ - sendUpdate(update: SendingStateUpdate, description: string): void; + sendUpdate(update: SendingStatusUpdate, description: string): void; } ////////// ANCHOR: global declare global { interface Window { - webxdc: WEBxDC; + webxdc: Webxdc; } } ////////// ANCHOR_END: global -export { SendingStateUpdate, RecievedStateUpdate, WEBxDC }; +export { SendingStatusUpdate, ReceivedStatusUpdate, Webxdc }; /* Types for the Simulator */ declare global { diff --git a/webxdc.js b/webxdc.js index 09989c0..a0808d7 100644 --- a/webxdc.js +++ b/webxdc.js @@ -1,6 +1,6 @@ // debug friend: document.writeln(JSON.stringify(value)); //@ts-check -/** @type {import('./webxdc').WEBxDC} */ +/** @type {import('./webxdc').Webxdc} */ window.webxdc = (() => { var updateListener = (_) => {}; var updatesKey = "__xdcUpdatesKey__";