types-mediawiki
Advanced tools
Comparing version 0.7.3 to 0.8.0
import "./Api"; | ||
import "./hook"; | ||
import "./html"; | ||
import "./language"; | ||
import "./util"; | ||
import "./user"; | ||
import "./loader"; | ||
import "./log"; | ||
import "./Map"; | ||
import "./message"; | ||
import "./notification"; | ||
import "./storage"; | ||
import "./Title"; | ||
import "./Uri"; | ||
import "./hook"; | ||
import "./storage"; | ||
import "./notification"; | ||
import "./message"; | ||
import "./user"; | ||
import "./util"; | ||
@@ -31,65 +34,58 @@ declare global { | ||
*/ | ||
const config: mw.Map; | ||
const config: mw.Map<{ | ||
debug: boolean; | ||
skin: string; | ||
stylepath: string; | ||
wgArticlePath: string; | ||
wgCaseSensitiveNamespaces: string[]; | ||
wgContentLanguage: string; | ||
wgContentNamespaces: number[]; | ||
wgDBname: string; | ||
wgEnableAPI: boolean; | ||
wgEnableWriteAPI: boolean; | ||
wgExtensionAssetsPath: string; | ||
wgFormattedNamespaces: Record<number, string>; | ||
wgNamespaceIds: Record<string, number>; | ||
wgScript: string; | ||
wgScriptPath: string; | ||
wgServer: string; | ||
wgSiteName: string; | ||
wgVariantArticlePath: string | false; | ||
wgVersion: string; | ||
wgAction: string; | ||
wgArticleId: number; | ||
wgCanonicalNamespace: string; | ||
wgCanonicalSpecialPageName: string | false; | ||
wgCategories: string[]; | ||
wgCurRevisionId: number; | ||
wgIsArticle: boolean; | ||
wgIsProbablyEditable: boolean; | ||
wgNamespaceNumber: number; | ||
wgPageContentLanguage: string; | ||
wgPageContentModel: string; | ||
wgPageName: string; | ||
wgRedirectedFrom: string; | ||
wgRelevantPageName: string; | ||
wgRelevantUserName: string; | ||
wgRelevantPageIsProbablyEditable: boolean; | ||
wgRestrictionEdit: string[]; | ||
wgRestrictionMove: string[]; | ||
wgRevisionId: number; | ||
wgSearchType: string; | ||
wgTitle: string; | ||
wgUserEditCount: number; | ||
wgUserGroups: string[]; | ||
wgUserId: number; | ||
wgUserLanguage: string; | ||
wgUserName: string; | ||
wgUserRegistration: number; | ||
wgIsMainPage: boolean; | ||
wgUserVariant: string; | ||
wgPostEdit: string; | ||
wgDiffOldId: number; | ||
wgDiffNewId: number; | ||
wgWikibaseItemId: string; | ||
[key: string]: unknown; // more config keys can be added by extensions | ||
}>; | ||
namespace html { | ||
function escape(s: string): string; | ||
function element(name: string, attrs?: any, contents?: string): string; | ||
} | ||
namespace log { | ||
function deprecate( | ||
obj: any, | ||
key: string, | ||
val: any, | ||
msg?: string, | ||
logName?: string | ||
): void; | ||
function error(...msg: any[]): void; | ||
function warn(...msg: string[]): void; | ||
} | ||
/** | ||
* Create an object that can be read from or written to via methods that allow interaction both | ||
* with single and multiple properties at once. | ||
* | ||
* **NOTE**: This is a private utility class for internal use by the framework. | ||
* Don't rely on its existence. | ||
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Map | ||
*/ | ||
class Map { | ||
/** | ||
* Get the value of one or more keys. | ||
* | ||
* If called with no arguments, all values are returned. | ||
* @param selection Key or array of keys to retrieve values for. | ||
* @param fallback Value for keys that don't exist. | ||
* @returns If selection was a string, returns the value, If selection was an array, returns | ||
* an object of key/values. If no selection is passed, a new object with all key/values is returned. | ||
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Map-method-get | ||
*/ | ||
get(selection: string | string[], fallback?: any): any; | ||
/** | ||
* Get the value of one or more keys. | ||
* | ||
* If called with no arguments, all values are returned. | ||
* @param selection Key to set value for, or object mapping keys to values | ||
* @param value Value to set (optional, only in use when key is a string) | ||
* @returns True on success, false on failure | ||
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Map-method-set | ||
*/ | ||
set(selection: string | Record<string, any>, value?: any): boolean; | ||
/** | ||
* Check if a given key exists in the map. | ||
* @param selection Key to check | ||
* @returns True if the key exists | ||
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Map-method-exists | ||
*/ | ||
exists(selection: string): boolean; | ||
} | ||
// types for mw.widgets are out of scope! | ||
@@ -96,0 +92,0 @@ const widgets: any; |
@@ -24,3 +24,3 @@ declare global { | ||
*/ | ||
constructor(map: mw.Map, key: string, parameters?: string[]); | ||
constructor(map: mw.Map<Record<string, string>>, key: string, parameters?: string[]); | ||
@@ -27,0 +27,0 @@ /** |
@@ -25,2 +25,5 @@ type title = string | mw.Title; | ||
title: string; | ||
namespace: number; | ||
static newFromText(title: string, namespace?: number): mw.Title | null; | ||
@@ -27,0 +30,0 @@ |
{ | ||
"name": "types-mediawiki", | ||
"version": "0.7.3", | ||
"version": "0.8.0", | ||
"description": "TypeScript definitions for MediaWiki JS interface", | ||
@@ -5,0 +5,0 @@ "types": "index.d.ts", |
@@ -9,3 +9,3 @@ [![NPM version](https://img.shields.io/npm/v/types-mediawiki.svg)](https://www.npmjs.com/package/types-mediawiki) | ||
This package covers the functions in the `mw` global object, as well a few jQuery plugins used in MediaWiki core. This is a work in progress. | ||
This package covers the functions and classes in the `mw` global object, as well a few jQuery plugins used in MediaWiki core. All commonly used parts of the interface are covered but as far as complete coverage is concerned, this is a work in progress. | ||
@@ -34,7 +34,21 @@ [![Download stats](https://nodei.co/npm/types-mediawiki.png?downloads=true&downloadRank=true)](https://nodei.co/npm/types-mediawiki/) | ||
### Action API parameters | ||
### mw.config | ||
This package also provides typings for API request parameters for the [MediaWiki Action API](https://www.mediawiki.org/wiki/API:Main_page). API endpoints defined in MediaWiki core and by a number of extensions (the ones enabled on English Wikipedia) are covered. These aren't exported to the global scope, however. For usage, you need to import them. For example: | ||
Types for mw.config are included: | ||
```ts | ||
let NS = mw.config.get('wgNamespaceNumber'); // NS gets type number | ||
let pageName = mw.config.get('wgPageName'); // pageName gets type string | ||
``` | ||
mw.config entries added by MediaWiki extensions can also be used but their type is not known, so they need to be explicitly cast: | ||
```ts | ||
let namespaces = mw.config.get('pageTriageNamespaces') as number[]; | ||
``` | ||
(`mw.config.get('pageTriageNamespaces')` gets the type `unknown` without a cast.) | ||
### MediaWiki API parameters | ||
This package also provides typings for API request parameters for the [MediaWiki Action API](https://www.mediawiki.org/wiki/API:Main_page). API endpoints defined in MediaWiki core and by a number of common extensions (the ones enabled on English Wikipedia) are covered. These aren't exported to the global scope, however. For usage, you need to import them. For example: | ||
```ts | ||
import type { ApiEditPageParams, ApiParseParams } from "types-mediawiki/api_params"; | ||
@@ -41,0 +55,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171824
22
5886
64