File tree Expand file tree Collapse file tree 5 files changed +88
-0
lines changed Expand file tree Collapse file tree 5 files changed +88
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ import {
102102 IDownloadFileActionFromWidgetActionRequest ,
103103 IDownloadFileActionFromWidgetResponseData ,
104104} from "./interfaces/DownloadFileAction" ;
105+ import { IThemeChangeActionRequestData } from "./interfaces/ThemeChangeAction" ;
105106
106107/**
107108 * API handler for the client side of widgets. This raises events
@@ -896,6 +897,22 @@ export class ClientWidgetApi extends EventEmitter {
896897 }
897898 }
898899
900+ /**
901+ * Informs the widget that the client's theme has changed.
902+ * @param theme The theme data, as an object with arbitrary contents.
903+ */
904+ public updateTheme ( theme : IThemeChangeActionRequestData ) : Promise < IWidgetApiResponseData > {
905+ return this . transport . send ( WidgetApiToWidgetAction . ThemeChange , theme ) ;
906+ }
907+
908+ /**
909+ * Informs the widget that the client's language has changed.
910+ * @param lang The BCP 47 identifier representing the client's current language.
911+ */
912+ public updateLanguage ( lang : string ) : Promise < IWidgetApiResponseData > {
913+ return this . transport . send ( WidgetApiToWidgetAction . LanguageChange , { lang } ) ;
914+ }
915+
899916 /**
900917 * Takes a screenshot of the widget.
901918 * @returns Resolves to the widget's screenshot.
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export enum MatrixApiVersion {
2323export enum UnstableApiVersion {
2424 MSC2762 = "org.matrix.msc2762" ,
2525 MSC2871 = "org.matrix.msc2871" ,
26+ MSC2873 = "org.matrix.msc2873" ,
2627 MSC2931 = "org.matrix.msc2931" ,
2728 MSC2974 = "org.matrix.msc2974" ,
2829 MSC2876 = "org.matrix.msc2876" ,
@@ -41,6 +42,7 @@ export const CurrentApiVersions: ApiVersion[] = [
4142 //MatrixApiVersion.V010,
4243 UnstableApiVersion . MSC2762 ,
4344 UnstableApiVersion . MSC2871 ,
45+ UnstableApiVersion . MSC2873 ,
4446 UnstableApiVersion . MSC2931 ,
4547 UnstableApiVersion . MSC2974 ,
4648 UnstableApiVersion . MSC2876 ,
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 The Matrix.org Foundation C.I.C.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ import { IWidgetApiRequest , IWidgetApiRequestData } from "./IWidgetApiRequest" ;
18+ import { WidgetApiToWidgetAction } from "./WidgetApiAction" ;
19+ import { IWidgetApiAcknowledgeResponseData } from "./IWidgetApiResponse" ;
20+
21+ export interface ILanguageChangeActionRequestData extends IWidgetApiRequestData {
22+ /**
23+ * The BCP 47 identifier for the client's current language.
24+ */
25+ lang : string ;
26+ }
27+
28+ export interface ILanguageChangeActionRequest extends IWidgetApiRequest {
29+ action : WidgetApiToWidgetAction . LanguageChange ;
30+ data : ILanguageChangeActionRequestData ;
31+ }
32+
33+ export interface ILanguageChangeActionResponse extends ILanguageChangeActionRequest {
34+ response : IWidgetApiAcknowledgeResponseData ;
35+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 The Matrix.org Foundation C.I.C.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ import { IWidgetApiRequest , IWidgetApiRequestData } from "./IWidgetApiRequest" ;
18+ import { WidgetApiToWidgetAction } from "./WidgetApiAction" ;
19+ import { IWidgetApiAcknowledgeResponseData } from "./IWidgetApiResponse" ;
20+
21+ export interface IThemeChangeActionRequestData extends IWidgetApiRequestData {
22+ // The format of a theme is deliberately unstandardized
23+ }
24+
25+ export interface IThemeChangeActionRequest extends IWidgetApiRequest {
26+ action : WidgetApiToWidgetAction . ThemeChange ;
27+ data : IThemeChangeActionRequestData ;
28+ }
29+
30+ export interface IThemeChangeActionResponse extends IThemeChangeActionRequest {
31+ response : IWidgetApiAcknowledgeResponseData ;
32+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ export enum WidgetApiToWidgetAction {
1818 SupportedApiVersions = "supported_api_versions" ,
1919 Capabilities = "capabilities" ,
2020 NotifyCapabilities = "notify_capabilities" ,
21+ ThemeChange = "theme_change" ,
22+ LanguageChange = "language_change" ,
2123 TakeScreenshot = "screenshot" ,
2224 UpdateVisibility = "visibility" ,
2325 OpenIDCredentials = "openid_credentials" ,
You can’t perform that action at this time.
0 commit comments