Skip to content

Commit 5643863

Browse files
authored
Update to MediaWiki 1.46 (#71)
- Added `labels` (3rd) optional parameter to `new mw.Api().watch()`. - Added `enableWatchlistLabels`, `indefBlockReasonOptions`, `SpecialEditWatchlistUrl`, `SpecialWatchlistLabelsTitle`, `SpecialWatchlistLabelsUrl`, `watchlistLabels`, `wgAutoCreateTempUserEnabled`, `wgCreateAccountUsernamePolicyPopoverMsgs`, and `wgErrorPageMessageKey` configuration values (see `mw.config`). - Added `mw.special.block.doBlockParamsReady` and `mw.special.block.formReset` hooks (see `mw.hook`). - Added `ariaText` to `mw.notification()` options. - Added `mw.util.adjustThumbWidthForSteps()` function. - Deprecated `foreignActionApi` argument from `mw.ForeignRest` constructor. - Moved `parseDom` method of `mw.Message` from `mediawiki.jqueryMsg` ResourceLoader module to `mediawiki.base`. - `mw.util.addSubtitle()` returns a boolean indicating whether the subtitle was updated.
1 parent 13194fa commit 5643863

14 files changed

Lines changed: 185 additions & 46 deletions

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v4
1616
- uses: actions/setup-node@v4
1717
with:
18-
node-version: '24.x'
18+
node-version: "24.x"
1919
registry-url: https://registry.npmjs.org/
2020
- run: npm ci
2121
- run: npm publish --provenance

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- uses: actions/setup-node@v4
1515
with:
16-
node-version: '24.x'
16+
node-version: "24.x"
1717
- run: npm ci
1818
- run: npm run test

CHANGELOG.md

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
11
## Unreleased
22

3-
- Updated to MediaWiki 1.45:
4-
* Added `notice` as valid type for `mw.notify()` options.
5-
* Added `blockCIDRLimit`, `wgParsoidHtmlVersion` configuration values.
6-
* Added `revisionsize` property to the `wgPageParseReport.limitreport` configuration value.
7-
- Added missing configuration values defined in MediaWiki core.
8-
- Fixed configuration value types:
9-
* `wgPageParseReport` and `wgRestrictionMove` can be undefined.
10-
* `wgPostEdit` can have a `+tempuser` suffix.
11-
* `wgUserRegistration` can be null.
3+
- Updated to MediaWiki 1.45:
4+
- Added `notice` as valid type for `mw.notify()` options.
5+
- Added `blockCIDRLimit`, `wgParsoidHtmlVersion` configuration values.
6+
- Added `revisionsize` property to the `wgPageParseReport.limitreport` configuration value.
7+
- Updated to MediaWiki 1.46:
8+
- Added `labels` (3rd) optional parameter to `new mw.Api().watch()`.
9+
- Added `enableWatchlistLabels`, `indefBlockReasonOptions`, `SpecialEditWatchlistUrl`, `SpecialWatchlistLabelsTitle`, `SpecialWatchlistLabelsUrl`, `watchlistLabels`, `wgAutoCreateTempUserEnabled`, `wgCreateAccountUsernamePolicyPopoverMsgs`, and `wgErrorPageMessageKey` configuration values (see `mw.config`).
10+
- Added `mw.special.block.doBlockParamsReady` and `mw.special.block.formReset` hooks (see `mw.hook`).
11+
- Added `ariaText` to `mw.notification()` options.
12+
- Added `mw.util.adjustThumbWidthForSteps()` function.
13+
- Deprecated `foreignActionApi` argument from `mw.ForeignRest` constructor.
14+
- Moved `parseDom` method of `mw.Message` from `mediawiki.jqueryMsg` ResourceLoader module to `mediawiki.base`.
15+
- `mw.util.addSubtitle()` returns a boolean indicating whether the subtitle was updated.
16+
- Added missing configuration values defined in MediaWiki core.
17+
- Fixed configuration value types:
18+
- `wgPageParseReport` and `wgRestrictionMove` can be undefined.
19+
- `wgPostEdit` can have a `+tempuser` suffix.
20+
- `wgUserRegistration` can be null.
1221

1322
## 2.0.0
1423

15-
- Types for MediaWiki API parameters have been moved to [types-mediawiki-api](https://github.com/wikimedia-gadgets/types-mediawiki-api).
16-
- Exports `ApiOptions`, `ForeignApiOptions`, `RestOptions`, and `UserInfo`, deprecated since 1.8.0, have been removed. Use the exposed `mw.Api.Options`, `mw.ForeignApi.Options`, `mw.Rest.Options`, and `mw.Api.UserInfo` instead.
17-
- `mw.Api.Promise.Upload`, deprecated since 1.10.0, has been removed. Use `mw.Upload.Promise` or `mw.Upload.AbortablePromise` instead.
18-
- Updated to MediaWiki 1.44:
19-
* Added `mw.Api.AbortController`.
20-
* Added `ajax.signal` and `userAgent` properties to `mw.Api` options.
21-
* Added `new mw.Api().prepareExtensibleApiRequest`.
22-
* Added an AJAX options argument to `new mw.Api().getToken`.
23-
* Added `mw.deflateAsync`.
24-
* Added `mw.hook(...).deprecate`.
25-
* Added `mw.language.convertGrammarMapping`.
26-
* Legacy token types are no longer deprecated.
27-
* `mw.deflate` is deprecated, in favor of `mw.deflateAsync`.
28-
* `mw.track` and `mw.trackSubscribe` accept multiple data arguments.
29-
* Updated Vue to 3.5.13.
30-
- Parameter types of `apisandbox.formatRequest` hook callback have been narrowed.
24+
- Types for MediaWiki API parameters have been moved to [types-mediawiki-api](https://github.com/wikimedia-gadgets/types-mediawiki-api).
25+
- Exports `ApiOptions`, `ForeignApiOptions`, `RestOptions`, and `UserInfo`, deprecated since 1.8.0, have been removed. Use the exposed `mw.Api.Options`, `mw.ForeignApi.Options`, `mw.Rest.Options`, and `mw.Api.UserInfo` instead.
26+
- `mw.Api.Promise.Upload`, deprecated since 1.10.0, has been removed. Use `mw.Upload.Promise` or `mw.Upload.AbortablePromise` instead.
27+
- Updated to MediaWiki 1.44:
28+
- Added `mw.Api.AbortController`.
29+
- Added `ajax.signal` and `userAgent` properties to `mw.Api` options.
30+
- Added `new mw.Api().prepareExtensibleApiRequest`.
31+
- Added an AJAX options argument to `new mw.Api().getToken`.
32+
- Added `mw.deflateAsync`.
33+
- Added `mw.hook(...).deprecate`.
34+
- Added `mw.language.convertGrammarMapping`.
35+
- Legacy token types are no longer deprecated.
36+
- `mw.deflate` is deprecated, in favor of `mw.deflateAsync`.
37+
- `mw.track` and `mw.trackSubscribe` accept multiple data arguments.
38+
- Updated Vue to 3.5.13.
39+
- Parameter types of `apisandbox.formatRequest` hook callback have been narrowed.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ let namespaces = mw.config.get("pageTriageNamespaces") as number[];
5151

5252
### MediaWiki API parameters
5353

54-
This package used to provide typings for API request parameters for the [MediaWiki Action API](https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page) till v1.10.1. These have since been moved to a separate package, [types-mediawiki-api](https://github.com/wikimedia-gadgets/types-mediawiki-api).
54+
This package used to provide typings for API request parameters for the [MediaWiki Action API](https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page) till v1.10.1. These have since been moved to a separate package, [types-mediawiki-api](https://github.com/wikimedia-gadgets/types-mediawiki-api).

mw/Api.d.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,13 @@ declare global {
385385
* Given an API response indicating an error, get a jQuery object containing a human-readable
386386
* error message that you can display somewhere on the page.
387387
*
388+
* This method handles the different error formats returned by the action API itself, and some
389+
* error conditions that may occur at other layers, e.g. user losing their network connection,
390+
* server being down, rate limits enforced by a proxy in front of MediaWiki, etc.
391+
*
392+
* Error messages, particularly for editing pages, may consist of multiple paragraphs of text.
393+
* Your user interface should have enough space for that.
394+
*
388395
* For better quality of error messages, it's recommended to use the following options in your
389396
* API queries:
390397
*
@@ -394,9 +401,6 @@ declare global {
394401
* errorsuselocal: true,
395402
* ```
396403
*
397-
* Error messages, particularly for editing pages, may consist of multiple paragraphs of text.
398-
* Your user interface should have enough space for that.
399-
*
400404
* @example
401405
* ```js
402406
* var api = new mw.Api();
@@ -789,18 +793,22 @@ declare global {
789793
* Convenience method for `action=watch`.
790794
*
791795
* @since 1.35 - expiry parameter can be passed when Watchlist Expiry is enabled.
796+
* @since 1.46 - labels parameter can be passed.
792797
* @param pages Full page name or instance of {@link mw.Title}, or an
793798
* array thereof. If an array is passed, the return value passed to the promise will also be an
794799
* array of appropriate objects.
795800
* @param expiry When the page should expire from the watchlist. If omitted, the
796801
* page will not expire.
802+
* @param labels Array of integer watchlist label IDs for labels to apply to the watched
803+
* pages. If the page is already watched, this will replace any existing labels.
797804
* @returns A promise that resolves with an object (or array of objects) describing each page that was passed in and its
798805
* current watched/unwatched status.
799806
* @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.Api.html#watch
800807
*/
801808
watch<P extends TypeOrArray<TitleLike>>(
802809
pages: P,
803-
expiry?: string
810+
expiry?: string,
811+
labels?: Array<number | string>
804812
): Api.AbortablePromise<[ReplaceValue<P, TitleLike, Api.WatchedPage>]>;
805813

806814
/**

mw/ForeignApi.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ declare global {
55
* an object like {@link mw.Api}, but automatically handle everything required to communicate
66
*
77
* The foreign wiki must be configured to accept requests from the current wiki.
8-
* For details, see {@link https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:$wgCrossSiteAJAXdomains $wgCrossSiteAJAXdomains}
9-
* and {@link https://www.mediawiki.org/wiki/Manual:$wgRestAllowCrossOriginCookieAuth $wgRestAllowCrossOriginCookieAuth}.
8+
* For details, see {@link https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:$wgCrossSiteAJAXdomains $wgCrossSiteAJAXdomains}.
109
*
1110
* ```js
1211
* const api = new mw.ForeignApi( 'https://commons.wikimedia.org/w/api.php' );

mw/ForeignRest.d.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ declare global {
66
* with another MediaWiki wiki via cross-origin requests (CORS).
77
*
88
* The foreign wiki must be configured to accept requests from the current wiki.
9-
* For details, see {@link https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:$wgCrossSiteAJAXdomains $wgCrossSiteAJAXdomains}
10-
* and {@link https://www.mediawiki.org/wiki/Manual:$wgRestAllowCrossOriginCookieAuth $wgRestAllowCrossOriginCookieAuth}.
9+
* For details, see {@link https://www.mediawiki.org/wiki/Manual:$wgRestAllowCrossOriginCookieAuth $wgRestAllowCrossOriginCookieAuth}.
1110
*
1211
* ```js
1312
* const api = new mw.ForeignRest( 'https://commons.wikimedia.org/w/rest.php' );
@@ -43,6 +42,17 @@ declare global {
4342
* @param url URL pointing to another wiki's `rest.php` endpoint.
4443
* @param foreignActionApi
4544
* @param options See {@link mw.Rest}.
45+
* @param optionsCompat No longer used, kept for compatibility.
46+
* @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.ForeignRest.html#ForeignRest
47+
*/
48+
constructor(url: string, options?: ForeignRest.Options);
49+
/**
50+
* Create an instance of {@link mw.ForeignRest}.
51+
*
52+
* @param url URL pointing to another wiki's `rest.php` endpoint.
53+
* @param foreignActionApi
54+
* @param options See {@link mw.Rest}.
55+
* @deprecated since 1.46, do not pass `foreignActionApi`.
4656
* @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.ForeignRest.html#ForeignRest
4757
*/
4858
constructor(url: string, foreignActionApi: ForeignApi, options?: ForeignRest.Options);

mw/Upload.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ declare global {
1010
* A simple example:
1111
*
1212
* ```js
13-
* var file = new OO.ui.SelectFileWidget(),
13+
* var file = new OO.ui.SelectFileInputWidget(),
1414
* button = new OO.ui.ButtonWidget( { label: 'Save' } ),
1515
* upload = new mw.Upload;
1616
*

mw/config.d.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ declare global {
6565
*/
6666
debug: boolean | number;
6767
debugInfo?: DebugInfo;
68+
/**
69+
* @since 1.46
70+
*/
71+
enableWatchlistLabels?: true;
72+
/**
73+
* @since 1.46
74+
*/
75+
indefBlockReasonOptions?: BlockReasonOption[];
6876
partialBlockActionOptions?: Record<`ipb-action-${string}`, string>;
6977
searchTerm?: string;
7078
/**
@@ -73,6 +81,18 @@ declare global {
7381
* @see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Interface/JavaScript#skin
7482
*/
7583
skin: string;
84+
/**
85+
* @since 1.46
86+
*/
87+
SpecialEditWatchlistUrl?: string;
88+
/**
89+
* @since 1.46
90+
*/
91+
SpecialWatchlistLabelsTitle?: string;
92+
/**
93+
* @since 1.46
94+
*/
95+
SpecialWatchlistLabelsUrl?: string;
7696
specUrl?: string | null;
7797
StructuredChangeFiltersDisplayConfig?: StructuredChangeFiltersDisplayConfig;
7898
/**
@@ -81,6 +101,10 @@ declare global {
81101
* @see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Interface/JavaScript#stylepath
82102
*/
83103
stylepath: string;
104+
/**
105+
* @since 1.46
106+
*/
107+
watchlistLabels?: WatchlistLabel[];
84108
/**
85109
* The action performed, e.g. "edit" for edit pages, or "view" for page views. See {@link https://www.mediawiki.org/wiki/Manual:Parameters_to_index.php#Actions Manual:Parameters to index.php}.
86110
*
@@ -101,6 +125,10 @@ declare global {
101125
* @see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Interface/JavaScript#wgArticlePath
102126
*/
103127
wgArticlePath: string;
128+
/**
129+
* @since 1.46
130+
*/
131+
wgAutoCreateTempUserEnabled?: boolean;
104132
wgBackendResponseTime: number;
105133
wgBreakFrames: boolean;
106134
/**
@@ -145,6 +173,10 @@ declare global {
145173
*/
146174
wgContentNamespaces: number[];
147175
wgCreateAccountDirty?: true;
176+
/**
177+
* @since 1.46
178+
*/
179+
wgCreateAccountUsernamePolicyPopoverMsgs?: PopoverMessages;
148180
/**
149181
* The top revision ID of the currently viewed page at the time the page was served. Also set on diff and history pages; zero for special pages.
150182
*
@@ -179,6 +211,10 @@ declare global {
179211
| "editingsection";
180212
wgEditRecoveryWasPosted?: boolean;
181213
wgEditSubmitButtonLabelPublish?: boolean;
214+
/**
215+
* @since 1.46
216+
*/
217+
wgErrorPageMessageKey?: string;
182218
/**
183219
* Root path used for extension static assets (e.g. images). Append '/' then the name of the extension to get the root path for a given extension.
184220
*
@@ -538,6 +574,16 @@ interface DebugInclude {
538574
size: string;
539575
}
540576

577+
interface WatchlistLabel {
578+
id: number;
579+
name: string;
580+
}
581+
582+
interface PopoverMessages {
583+
title: string;
584+
bulletsHtml: string;
585+
}
586+
541587
interface FileWarning {
542588
module: string;
543589
messages: FileWarningMessages;

mw/hook.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ApiBlockParams } from "types-mediawiki-api";
12
import { User } from "./user";
23

34
/**
@@ -155,6 +156,22 @@ declare global {
155156
*/
156157
function hook(name: "htmlform.enhance"): Hook<[document: JQuery]>;
157158

159+
/**
160+
* Create an instance of {@link Hook}.
161+
*
162+
* @since 1.46
163+
* @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.html#.hook
164+
*/
165+
function hook(name: "mw.special.block.doBlockParamsReady"): Hook<[params: ApiBlockParams]>;
166+
167+
/**
168+
* Create an instance of {@link Hook}, fired when the `Special:Block` form has been reset to default values.
169+
*
170+
* @since 1.46
171+
* @see https://doc.wikimedia.org/mediawiki-core/master/js/mw.html#.hook
172+
*/
173+
function hook(name: "mw.special.block.formReset"): Hook<[]>;
174+
158175
/**
159176
* Create an instance of {@link Hook}, fired after an edit was successfully saved.
160177
*

0 commit comments

Comments
 (0)