Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

matrix-widget-api

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

matrix-widget-api - npm Package Compare versions

Comparing version 0.1.0-beta.6 to 0.1.0-beta.7

lib/interfaces/SetModalButtonEnabledAction.d.ts

1

lib/index.d.ts

@@ -29,2 +29,3 @@ export * from "./WidgetApi";

export * from "./interfaces/ModalWidgetActions";
export * from "./interfaces/SetModalButtonEnabledAction";
export * from "./interfaces/WidgetConfigAction";

@@ -31,0 +32,0 @@ export * from "./interfaces/SendEventAction";

@@ -343,2 +343,14 @@ "use strict";

var _SetModalButtonEnabledAction = require("./interfaces/SetModalButtonEnabledAction");
Object.keys(_SetModalButtonEnabledAction).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _SetModalButtonEnabledAction[key];
}
});
});
var _WidgetConfigAction = require("./interfaces/WidgetConfigAction");

@@ -345,0 +357,0 @@

@@ -6,2 +6,6 @@ import { IWidgetApiRequest, IWidgetApiRequestData } from "./IWidgetApiRequest";

import { ModalButtonKind } from "./ModalButtonKind";
export declare enum BuiltInModalButtonID {
Close = "m.close"
}
export declare type ModalButtonID = BuiltInModalButtonID | string;
export interface IModalWidgetCreateData extends IWidgetApiRequestData {

@@ -14,3 +18,3 @@ [key: string]: unknown;

export interface IModalWidgetOpenRequestDataButton {
id: "m.close" | string;
id: ModalButtonID;
label: string;

@@ -17,0 +21,0 @@ kind: ModalButtonKind | string;

@@ -1,1 +0,28 @@

"use strict";
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BuiltInModalButtonID = void 0;
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var BuiltInModalButtonID;
exports.BuiltInModalButtonID = BuiltInModalButtonID;
(function (BuiltInModalButtonID) {
BuiltInModalButtonID["Close"] = "m.close";
})(BuiltInModalButtonID || (exports.BuiltInModalButtonID = BuiltInModalButtonID = {}));

@@ -20,4 +20,5 @@ export declare enum WidgetApiToWidgetAction {

OpenModalWidget = "open_modal",
SetModalButtonEnabled = "set_button_enabled",
SendEvent = "send_event"
}
export declare type WidgetApiAction = WidgetApiToWidgetAction | WidgetApiFromWidgetAction | string;

@@ -49,3 +49,4 @@ "use strict";

WidgetApiFromWidgetAction["OpenModalWidget"] = "open_modal";
WidgetApiFromWidgetAction["SetModalButtonEnabled"] = "set_button_enabled";
WidgetApiFromWidgetAction["SendEvent"] = "send_event";
})(WidgetApiFromWidgetAction || (exports.WidgetApiFromWidgetAction = WidgetApiFromWidgetAction = {}));

@@ -7,3 +7,3 @@ import { EventEmitter } from "events";

import { WidgetType } from "./interfaces/WidgetType";
import { IModalWidgetCreateData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData } from "./interfaces/ModalWidgetActions";
import { IModalWidgetCreateData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData, ModalButtonID } from "./interfaces/ModalWidgetActions";
import { ISendEventFromWidgetResponseData } from "./interfaces/SendEventAction";

@@ -78,3 +78,17 @@ /**

setAlwaysOnScreen(value: boolean): Promise<boolean>;
/**
* Opens a modal widget.
* @param {string} url The URL to the modal widget.
* @param {string} name The name of the widget.
* @param {IModalWidgetOpenRequestDataButton[]} buttons The buttons to have on the widget.
* @param {IModalWidgetCreateData} data Data to supply to the modal widget.
* @param {WidgetType} type The type of modal widget.
* @returns {Promise<void>} Resolves when the modal widget has been opened.
*/
openModalWidget(url: string, name: string, buttons?: IModalWidgetOpenRequestDataButton[], data?: IModalWidgetCreateData, type?: WidgetType): Promise<void>;
/**
* Closes the modal widget. The widget's session will be terminated shortly after.
* @param {IModalWidgetReturnData} data Optional data to close the modal widget with.
* @returns {Promise<void>} Resolves when complete.
*/
closeModalWidget(data?: IModalWidgetReturnData): Promise<void>;

@@ -84,2 +98,10 @@ sendRoomEvent(eventType: string, content: unknown): Promise<ISendEventFromWidgetResponseData>;

/**
* Sets a button as disabled or enabled on the modal widget. Buttons are enabled by default.
* @param {ModalButtonID} buttonId The button ID to enable/disable.
* @param {boolean} isEnabled Whether or not the button is enabled.
* @returns {Promise<void>} Resolves when complete.
* @throws Throws if the button cannot be disabled, or the client refuses to disable the button.
*/
setModalButtonEnabled(buttonId: ModalButtonID, isEnabled: boolean): Promise<void>;
/**
* Starts the communication channel. This should be done early to ensure

@@ -86,0 +108,0 @@ * that messages are not missed. Communication can only be stopped by the client.

@@ -22,2 +22,4 @@ "use strict";

var _ModalWidgetActions = require("./interfaces/ModalWidgetActions");
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

@@ -229,2 +231,12 @@

}
/**
* Opens a modal widget.
* @param {string} url The URL to the modal widget.
* @param {string} name The name of the widget.
* @param {IModalWidgetOpenRequestDataButton[]} buttons The buttons to have on the widget.
* @param {IModalWidgetCreateData} data Data to supply to the modal widget.
* @param {WidgetType} type The type of modal widget.
* @returns {Promise<void>} Resolves when the modal widget has been opened.
*/
}, {

@@ -244,2 +256,8 @@ key: "openModalWidget",

}
/**
* Closes the modal widget. The widget's session will be terminated shortly after.
* @param {IModalWidgetReturnData} data Optional data to close the modal widget with.
* @returns {Promise<void>} Resolves when complete.
*/
}, {

@@ -269,2 +287,22 @@ key: "closeModalWidget",

/**
* Sets a button as disabled or enabled on the modal widget. Buttons are enabled by default.
* @param {ModalButtonID} buttonId The button ID to enable/disable.
* @param {boolean} isEnabled Whether or not the button is enabled.
* @returns {Promise<void>} Resolves when complete.
* @throws Throws if the button cannot be disabled, or the client refuses to disable the button.
*/
}, {
key: "setModalButtonEnabled",
value: function setModalButtonEnabled(buttonId, isEnabled) {
if (buttonId === _ModalWidgetActions.BuiltInModalButtonID.Close) {
throw new Error("The close button cannot be disabled");
}
return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.SetModalButtonEnabled, {
button: buttonId,
enabled: isEnabled
}).then();
}
/**
* Starts the communication channel. This should be done early to ensure

@@ -271,0 +309,0 @@ * that messages are not missed. Communication can only be stopped by the client.

2

package.json
{
"name": "matrix-widget-api",
"version": "0.1.0-beta.6",
"version": "0.1.0-beta.7",
"description": "Matrix Widget API SDK",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -50,2 +50,3 @@ /*

export * from "./interfaces/ModalWidgetActions";
export * from "./interfaces/SetModalButtonEnabledAction";
export * from "./interfaces/WidgetConfigAction";

@@ -52,0 +53,0 @@ export * from "./interfaces/SendEventAction";

@@ -23,2 +23,7 @@ /*

export enum BuiltInModalButtonID {
Close = "m.close",
}
export type ModalButtonID = BuiltInModalButtonID | string;
export interface IModalWidgetCreateData extends IWidgetApiRequestData {

@@ -34,3 +39,3 @@ [key: string]: unknown;

export interface IModalWidgetOpenRequestDataButton {
id: "m.close" | string;
id: ModalButtonID;
label: string;

@@ -37,0 +42,0 @@ kind: ModalButtonKind | string;

@@ -37,2 +37,3 @@ /*

OpenModalWidget = "open_modal",
SetModalButtonEnabled = "set_button_enabled",
SendEvent = "send_event",

@@ -39,0 +40,0 @@ }

@@ -46,3 +46,6 @@ /*

IModalWidgetReturnData,
BuiltInModalButtonID,
ModalButtonID,
} from "./interfaces/ModalWidgetActions";
import { ISetModalButtonEnabledActionRequestData } from "./interfaces/SetModalButtonEnabledAction";
import { ISendEventFromWidgetRequestData, ISendEventFromWidgetResponseData } from "./interfaces/SendEventAction";

@@ -192,2 +195,11 @@

/**
* Opens a modal widget.
* @param {string} url The URL to the modal widget.
* @param {string} name The name of the widget.
* @param {IModalWidgetOpenRequestDataButton[]} buttons The buttons to have on the widget.
* @param {IModalWidgetCreateData} data Data to supply to the modal widget.
* @param {WidgetType} type The type of modal widget.
* @returns {Promise<void>} Resolves when the modal widget has been opened.
*/
public openModalWidget(

@@ -205,2 +217,7 @@ url: string,

/**
* Closes the modal widget. The widget's session will be terminated shortly after.
* @param {IModalWidgetReturnData} data Optional data to close the modal widget with.
* @returns {Promise<void>} Resolves when complete.
*/
public closeModalWidget(data: IModalWidgetReturnData = {}): Promise<void> {

@@ -229,2 +246,18 @@ return this.transport.send<IModalWidgetReturnData>(WidgetApiFromWidgetAction.CloseModalWidget, data).then();

/**
* Sets a button as disabled or enabled on the modal widget. Buttons are enabled by default.
* @param {ModalButtonID} buttonId The button ID to enable/disable.
* @param {boolean} isEnabled Whether or not the button is enabled.
* @returns {Promise<void>} Resolves when complete.
* @throws Throws if the button cannot be disabled, or the client refuses to disable the button.
*/
public setModalButtonEnabled(buttonId: ModalButtonID, isEnabled: boolean): Promise<void> {
if (buttonId === BuiltInModalButtonID.Close) {
throw new Error("The close button cannot be disabled");
}
return this.transport.send<ISetModalButtonEnabledActionRequestData>(
WidgetApiFromWidgetAction.SetModalButtonEnabled, {button: buttonId, enabled: isEnabled},
).then();
}
/**
* Starts the communication channel. This should be done early to ensure

@@ -231,0 +264,0 @@ * that messages are not missed. Communication can only be stopped by the client.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc