Skip to content

Commit

Permalink
Add generated types definitions
Browse files Browse the repository at this point in the history
- Generate types when running `make check`
- Check for uncommitted type changes
  • Loading branch information
jcbrand committed Mar 12, 2024
1 parent c07ca9b commit 4486ddb
Show file tree
Hide file tree
Showing 435 changed files with 11,201 additions and 8 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,21 @@ types:: node_modules
########################################################################
## Tests

.PHONY: check-git-clean
check-git-clean:
@if ! git diff-index --quiet HEAD src/types src/headless/types; then\
echo "Error: uncommitted type changes. Please include all type changes in your commit"\
exit 1;\
fi

.PHONY: eslint
eslint: node_modules
npm run lint

.PHONY: check
check: eslint | dist/converse.js dist/converse.css
npm run types
make check-git-clean
npm run test -- $(ARGS)

.PHONY: test
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "converse.js",
"version": "10.1.5",
"version": "10.1.7",
"description": "Browser based XMPP chat client",
"main": "src/index.js",
"browser": "dist/converse.js",
Expand Down Expand Up @@ -41,7 +41,7 @@
"serve": "http-server -c-1",
"devserver": "webpack serve --config webpack/webpack.serve.js",
"watch": "webpack --watch --config webpack/webpack.build.js --mode=development",
"types": "tsc --declaration --emitDeclarationOnly --allowJs",
"types": "tsc -p ./src/headless/tsconfig.json && tsc",
"check:types": "tsc --noEmit"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/headless/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@converse/headless",
"version": "10.1.5",
"version": "10.1.7",
"description": "Converse.js Headless build",
"author": "JC Brand <[email protected]>",
"contributors": [
Expand Down
46 changes: 46 additions & 0 deletions src/headless/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"include": [
"**/*"
],
"exclude": [
"**/tests/*",
"dist/",
"types/"
],
"compilerOptions": {
"target": "es2016",
"module": "esnext",

"types": [
"@types/webappsec-credential-management"
],

"lib": [
"ES2020",
"dom"
],

"allowJs": true,
"checkJs": true,

// Generate d.ts files
"declaration": true,
"emitDeclarationOnly": true,
"declarationMap": true,

"rootDir": "./",
"outDir": "./types/",
"baseUrl": "./",

"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,

"strict": false,
"noImplicitAny": false,

"skipLibCheck": true,

"moduleResolution": "node",
"resolveJsonModule": true
}
}
9 changes: 9 additions & 0 deletions src/headless/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default converse;
import api from "./shared/api/index.js";
import { converse } from "./shared/api/public.js";
import _converse from "./shared/_converse";
import i18n from "./shared/i18n";
import log from "./log.js";
import u from "./utils/index.js";
export { api, converse, _converse, i18n, log, u };
//# sourceMappingURL=index.d.ts.map
33 changes: 33 additions & 0 deletions src/headless/types/log.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export namespace LEVELS {
const debug: number;
const info: number;
const warn: number;
const error: number;
const fatal: number;
}
declare namespace _default {
/**
* The the log-level, which determines how verbose the logging is.
* @method log#setLogLevel
* @param {keyof LEVELS} level - The loglevel which allows for filtering of log messages
*/
function setLogLevel(level: "debug" | "error" | "info" | "warn" | "fatal"): void;
/**
* Logs messages to the browser's developer console.
* Available loglevels are 0 for 'debug', 1 for 'info', 2 for 'warn',
* 3 for 'error' and 4 for 'fatal'.
* When using the 'error' or 'warn' loglevels, a full stacktrace will be
* logged as well.
* @method log#log
* @param {string|Element|Error} message - The message to be logged
* @param {string} level - The loglevel which allows for filtering of log messages
*/
function log(message: string | Element | Error, level: string, style?: string): void;
function debug(message: any, style: any): void;
function error(message: any, style: any): void;
function info(message: any, style: any): void;
function warn(message: any, style: any): void;
function fatal(message: any, style: any): void;
}
export default _default;
//# sourceMappingURL=log.d.ts.map
41 changes: 41 additions & 0 deletions src/headless/types/plugins/adhoc/api.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
declare namespace _default {
namespace adhoc {
/**
* @method api.adhoc.getCommands
* @param { String } to_jid
*/
function getCommands(to_jid: string): Promise<any>;
/**
* @method api.adhoc.fetchCommandForm
*/
function fetchCommandForm(command: any): Promise<{
sessionid: any;
instructions: any;
fields: any;
actions: any[];
} | {
instructions: any;
fields: any[];
}>;
/**
* @method api.adhoc.runCommand
* @param { String } jid
* @param { String } sessionid
* @param { 'execute' | 'cancel' | 'prev' | 'next' | 'complete' } action
* @param { String } node
* @param { Array<{ [k:string]: string }> } inputs
*/
function runCommand(jid: string, sessionid: string, node: string, action: "cancel" | "execute" | "prev" | "next" | "complete", inputs: {
[k: string]: string;
}[]): Promise<{
note: any;
sessionid?: any;
instructions?: any;
fields?: any;
actions?: any[];
status: any;
}>;
}
}
export default _default;
//# sourceMappingURL=api.d.ts.map
2 changes: 2 additions & 0 deletions src/headless/types/plugins/adhoc/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=index.d.ts.map
8 changes: 8 additions & 0 deletions src/headless/types/plugins/adhoc/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function parseForCommands(stanza: any): any;
export function getCommandFields(iq: any, jid: any): {
sessionid: any;
instructions: any;
fields: any;
actions: any[];
};
//# sourceMappingURL=utils.d.ts.map
34 changes: 34 additions & 0 deletions src/headless/types/plugins/bookmarks/collection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export default Bookmarks;
declare class Bookmarks extends Collection {
constructor();
model: typeof Bookmark;
initialize(): Promise<void>;
fetched_flag: string;
/**
* @param {Bookmark} bookmark
*/
openBookmarkedRoom(bookmark: Bookmark): Promise<Bookmark>;
fetchBookmarks(): any;
createBookmark(options: any): void;
sendBookmarkStanza(): any;
onBookmarkError(iq: any, options: any): void;
fetchBookmarksFromServer(deferred: any): void;
/**
* @param {Bookmark} bookmark
*/
markRoomAsBookmarked(bookmark: Bookmark): void;
/**
* @param {Bookmark} bookmark
*/
markRoomAsUnbookmarked(bookmark: Bookmark): void;
/**
* @param {Element} stanza
*/
createBookmarksFromStanza(stanza: Element): void;
onBookmarksReceived(deferred: any, iq: any): any;
onBookmarksReceivedError(deferred: any, iq: any): any;
getUnopenedBookmarks(): Promise<any>;
}
import { Collection } from "@converse/skeletor";
import Bookmark from "./model.js";
//# sourceMappingURL=collection.d.ts.map
2 changes: 2 additions & 0 deletions src/headless/types/plugins/bookmarks/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=index.d.ts.map
6 changes: 6 additions & 0 deletions src/headless/types/plugins/bookmarks/model.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default Bookmark;
declare class Bookmark extends Model {
getDisplayName(): any;
}
import { Model } from "@converse/skeletor";
//# sourceMappingURL=model.d.ts.map
5 changes: 5 additions & 0 deletions src/headless/types/plugins/bookmarks/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function checkBookmarksSupport(): Promise<any>;
export function initBookmarks(): Promise<void>;
export function getNicknameFromBookmark(jid: any): any;
export function handleBookmarksPush(message: any): boolean;
//# sourceMappingURL=utils.d.ts.map
13 changes: 13 additions & 0 deletions src/headless/types/plugins/bosh/api.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
declare namespace _default {
namespace tokens {
/**
* @method api.tokens.get
* @param {string} [id] The type of token to return ('rid' or 'sid').
* @returns {string} A token, either the RID or SID token depending on what's asked for.
* @example _converse.api.tokens.get('rid');
*/
function get(id?: string): string;
}
}
export default _default;
//# sourceMappingURL=api.d.ts.map
2 changes: 2 additions & 0 deletions src/headless/types/plugins/bosh/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=index.d.ts.map
11 changes: 11 additions & 0 deletions src/headless/types/plugins/bosh/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function startNewPreboundBOSHSession(): void;
/**
* @param {unknown} _
* @param {LoginHookPayload} payload
*/
export function attemptPrebind(_: unknown, payload: any): Promise<any>;
export function saveJIDToSession(): void;
export function clearSession(): void;
export function restoreBOSHSession(): Promise<boolean>;
export type LoginHookPayload = any;
//# sourceMappingURL=utils.d.ts.map
2 changes: 2 additions & 0 deletions src/headless/types/plugins/caps/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=index.d.ts.map
9 changes: 9 additions & 0 deletions src/headless/types/plugins/caps/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Given a stanza, adds a XEP-0115 CAPS element
* @param {Strophe.Builder} stanza
*/
export function addCapsNode(stanza: any): Promise<any>;
export namespace Strophe {
type Builder = any;
}
//# sourceMappingURL=utils.d.ts.map
Loading

0 comments on commit 4486ddb

Please sign in to comment.