@matrix-widget-toolkit/api 3.3.2 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -842,6 +842,7 @@ function generateWidgetRegistrationUrl(options) {
842
842
  if (options === void 0) { options = {}; }
843
843
  var pathName = options.pathName, _j = options.includeParameters, includeParameters = _j === void 0 ? true : _j, widgetParameters = options.widgetParameters;
844
844
  // don't forward widgetId and parentUrl as they will be generated by the client
845
+ // eslint-disable-next-line
845
846
  var _k = extractRawWidgetParameters(); _k.widgetId; _k.parentUrl; var rawWidgetParameters = __rest(_k, ["widgetId", "parentUrl"]);
846
847
  var parameters = Object.entries(__assign(__assign({}, rawWidgetParameters), { theme: (_a = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.theme) !== null && _a !== void 0 ? _a : '$org.matrix.msc2873.client_theme', matrix_user_id: (_b = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.userId) !== null && _b !== void 0 ? _b : '$matrix_user_id', matrix_display_name: (_c = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.displayName) !== null && _c !== void 0 ? _c : '$matrix_display_name', matrix_avatar_url: (_d = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.avatarUrl) !== null && _d !== void 0 ? _d : '$matrix_avatar_url', matrix_room_id: (_e = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.roomId) !== null && _e !== void 0 ? _e : '$matrix_room_id', matrix_client_id: (_f = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.clientId) !== null && _f !== void 0 ? _f : '$org.matrix.msc2873.client_id', matrix_client_language: (_g = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.clientLanguage) !== null && _g !== void 0 ? _g : '$org.matrix.msc2873.client_language', matrix_base_url: (_h = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.baseUrl) !== null && _h !== void 0 ? _h : '$org.matrix.msc4039.matrix_base_url' }))
847
848
  .map(function (_a) {
@@ -1244,6 +1245,7 @@ var WidgetApiImpl = /** @class */ (function () {
1244
1245
  throw new Error("Capabilities rejected: ".concat(Array.from(missingSet).join(', ')));
1245
1246
  }
1246
1247
  }), rxjs.first());
1248
+ // eslint-disable-next-line no-async-promise-executor
1247
1249
  return [4 /*yield*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1248
1250
  var subscription, err_1;
1249
1251
  return __generator(this, function (_a) {
@@ -1271,6 +1273,7 @@ var WidgetApiImpl = /** @class */ (function () {
1271
1273
  });
1272
1274
  }); })];
1273
1275
  case 1:
1276
+ // eslint-disable-next-line no-async-promise-executor
1274
1277
  _a.sent();
1275
1278
  return [2 /*return*/];
1276
1279
  }
@@ -1679,6 +1682,17 @@ var WidgetApiImpl = /** @class */ (function () {
1679
1682
  });
1680
1683
  });
1681
1684
  };
1685
+ /** {@inheritdoc WidgetApi.downloadFile} */
1686
+ WidgetApiImpl.prototype.downloadFile = function (contentUrl) {
1687
+ return __awaiter(this, void 0, void 0, function () {
1688
+ return __generator(this, function (_a) {
1689
+ switch (_a.label) {
1690
+ case 0: return [4 /*yield*/, this.matrixWidgetApi.downloadFile(contentUrl)];
1691
+ case 1: return [2 /*return*/, _a.sent()];
1692
+ }
1693
+ });
1694
+ });
1695
+ };
1682
1696
  return WidgetApiImpl;
1683
1697
  }());
1684
1698
 
@@ -840,6 +840,7 @@ function generateWidgetRegistrationUrl(options) {
840
840
  if (options === void 0) { options = {}; }
841
841
  var pathName = options.pathName, _j = options.includeParameters, includeParameters = _j === void 0 ? true : _j, widgetParameters = options.widgetParameters;
842
842
  // don't forward widgetId and parentUrl as they will be generated by the client
843
+ // eslint-disable-next-line
843
844
  var _k = extractRawWidgetParameters(); _k.widgetId; _k.parentUrl; var rawWidgetParameters = __rest(_k, ["widgetId", "parentUrl"]);
844
845
  var parameters = Object.entries(__assign(__assign({}, rawWidgetParameters), { theme: (_a = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.theme) !== null && _a !== void 0 ? _a : '$org.matrix.msc2873.client_theme', matrix_user_id: (_b = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.userId) !== null && _b !== void 0 ? _b : '$matrix_user_id', matrix_display_name: (_c = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.displayName) !== null && _c !== void 0 ? _c : '$matrix_display_name', matrix_avatar_url: (_d = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.avatarUrl) !== null && _d !== void 0 ? _d : '$matrix_avatar_url', matrix_room_id: (_e = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.roomId) !== null && _e !== void 0 ? _e : '$matrix_room_id', matrix_client_id: (_f = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.clientId) !== null && _f !== void 0 ? _f : '$org.matrix.msc2873.client_id', matrix_client_language: (_g = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.clientLanguage) !== null && _g !== void 0 ? _g : '$org.matrix.msc2873.client_language', matrix_base_url: (_h = widgetParameters === null || widgetParameters === void 0 ? void 0 : widgetParameters.baseUrl) !== null && _h !== void 0 ? _h : '$org.matrix.msc4039.matrix_base_url' }))
845
846
  .map(function (_a) {
@@ -1242,6 +1243,7 @@ var WidgetApiImpl = /** @class */ (function () {
1242
1243
  throw new Error("Capabilities rejected: ".concat(Array.from(missingSet).join(', ')));
1243
1244
  }
1244
1245
  }), first());
1246
+ // eslint-disable-next-line no-async-promise-executor
1245
1247
  return [4 /*yield*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1246
1248
  var subscription, err_1;
1247
1249
  return __generator(this, function (_a) {
@@ -1269,6 +1271,7 @@ var WidgetApiImpl = /** @class */ (function () {
1269
1271
  });
1270
1272
  }); })];
1271
1273
  case 1:
1274
+ // eslint-disable-next-line no-async-promise-executor
1272
1275
  _a.sent();
1273
1276
  return [2 /*return*/];
1274
1277
  }
@@ -1677,6 +1680,17 @@ var WidgetApiImpl = /** @class */ (function () {
1677
1680
  });
1678
1681
  });
1679
1682
  };
1683
+ /** {@inheritdoc WidgetApi.downloadFile} */
1684
+ WidgetApiImpl.prototype.downloadFile = function (contentUrl) {
1685
+ return __awaiter(this, void 0, void 0, function () {
1686
+ return __generator(this, function (_a) {
1687
+ switch (_a.label) {
1688
+ case 0: return [4 /*yield*/, this.matrixWidgetApi.downloadFile(contentUrl)];
1689
+ case 1: return [2 /*return*/, _a.sent()];
1690
+ }
1691
+ });
1692
+ });
1693
+ };
1680
1694
  return WidgetApiImpl;
1681
1695
  }());
1682
1696
 
package/build/index.d.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { Capability } from 'matrix-widget-api';
7
+ import { IDownloadFileActionFromWidgetResponseData } from 'matrix-widget-api';
7
8
  import { IGetMediaConfigActionFromWidgetResponseData } from 'matrix-widget-api';
8
9
  import { IModalWidgetCreateData } from 'matrix-widget-api';
9
10
  import { IModalWidgetOpenRequestDataButton } from 'matrix-widget-api';
@@ -758,6 +759,12 @@ export declare type WidgetApi = {
758
759
  * @returns Resolves to the location of the uploaded file.
759
760
  */
760
761
  uploadFile(file: XMLHttpRequestBodyInit): Promise<IUploadFileActionFromWidgetResponseData>;
762
+ /**
763
+ * Download a file to the media repository on the homeserver.
764
+ * @param contentUrl - MXC URI of the file to download
765
+ * @returns resolves to an object with: file - the file contents
766
+ */
767
+ downloadFile(contentUrl: string): Promise<IDownloadFileActionFromWidgetResponseData>;
761
768
  };
762
769
 
763
770
  /**
@@ -918,6 +925,8 @@ export declare class WidgetApiImpl implements WidgetApi {
918
925
  getMediaConfig(): Promise<IGetMediaConfigActionFromWidgetResponseData>;
919
926
  /** {@inheritdoc WidgetApi.uploadFile} */
920
927
  uploadFile(file: XMLHttpRequestBodyInit): Promise<IUploadFileActionFromWidgetResponseData>;
928
+ /** {@inheritdoc WidgetApi.downloadFile} */
929
+ downloadFile(contentUrl: string): Promise<IDownloadFileActionFromWidgetResponseData>;
921
930
  }
922
931
 
923
932
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matrix-widget-toolkit/api",
3
- "version": "3.3.2",
3
+ "version": "3.4.0",
4
4
  "description": "A simplified layer on top of matrix-widget-api to use build widgets.",
5
5
  "author": "Nordeck IT + Consulting GmbH",
6
6
  "license": "Apache-2.0",
@@ -28,8 +28,8 @@
28
28
  "generate-api-report": "tsc && api-extractor run --verbose --local"
29
29
  },
30
30
  "dependencies": {
31
- "matrix-widget-api": "^1.6.0",
32
- "qs": "^6.12.3",
31
+ "matrix-widget-api": "^1.9.0",
32
+ "qs": "^6.13.0",
33
33
  "rxjs": "^7.8.1"
34
34
  },
35
35
  "repository": {