@matrix-widget-toolkit/api 3.4.1 → 4.0.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.
- package/build/cjs/api/WidgetApiImpl.d.cts +179 -0
- package/build/cjs/api/WidgetApiImpl.test.d.cts +1 -0
- package/build/cjs/api/extras/capabilities.d.cts +12 -0
- package/build/cjs/api/extras/capabilities.test.d.cts +1 -0
- package/build/cjs/api/extras/displayName.d.cts +12 -0
- package/build/cjs/api/extras/displayName.test.d.cts +1 -0
- package/build/cjs/api/extras/events.d.cts +15 -0
- package/build/cjs/api/extras/events.test.d.cts +1 -0
- package/build/cjs/api/extras/index.d.cts +14 -0
- package/build/cjs/api/extras/navigateTo.d.cts +24 -0
- package/build/cjs/api/extras/navigateTo.test.d.cts +1 -0
- package/build/cjs/api/extras/originServerTs.d.cts +10 -0
- package/build/cjs/api/extras/originServerTs.test.d.cts +1 -0
- package/build/cjs/api/extras/powerLevel.d.cts +105 -0
- package/build/cjs/api/extras/powerLevel.test.d.cts +1 -0
- package/build/cjs/api/extras/redactions.d.cts +42 -0
- package/build/cjs/api/extras/redactions.test.d.cts +1 -0
- package/build/cjs/api/extras/relatesTo.d.cts +60 -0
- package/build/cjs/api/extras/relatesTo.test.d.cts +1 -0
- package/build/cjs/api/extras/roomMember.d.cts +35 -0
- package/build/cjs/api/extras/roomMember.test.d.cts +1 -0
- package/build/cjs/api/index.d.cts +8 -0
- package/build/cjs/api/parameters.d.cts +58 -0
- package/build/cjs/api/parameters.test.d.cts +1 -0
- package/build/cjs/api/registration.d.cts +33 -0
- package/build/cjs/api/registration.test.d.cts +1 -0
- package/build/cjs/api/types.d.cts +466 -0
- package/build/cjs/api/utils.d.cts +20 -0
- package/build/cjs/api/utils.test.d.cts +1 -0
- package/build/cjs/{index.js → index.cjs} +100 -48
- package/build/cjs/index.d.cts +5 -0
- package/build/esm/api/WidgetApiImpl.d.ts +179 -0
- package/build/esm/api/WidgetApiImpl.test.d.ts +1 -0
- package/build/esm/api/extras/capabilities.d.ts +12 -0
- package/build/esm/api/extras/capabilities.test.d.ts +1 -0
- package/build/esm/api/extras/displayName.d.ts +12 -0
- package/build/esm/api/extras/displayName.test.d.ts +1 -0
- package/build/esm/api/extras/events.d.ts +15 -0
- package/build/esm/api/extras/events.test.d.ts +1 -0
- package/build/esm/api/extras/index.d.ts +14 -0
- package/build/esm/api/extras/navigateTo.d.ts +24 -0
- package/build/esm/api/extras/navigateTo.test.d.ts +1 -0
- package/build/esm/api/extras/originServerTs.d.ts +10 -0
- package/build/esm/api/extras/originServerTs.test.d.ts +1 -0
- package/build/esm/api/extras/powerLevel.d.ts +105 -0
- package/build/esm/api/extras/powerLevel.test.d.ts +1 -0
- package/build/esm/api/extras/redactions.d.ts +42 -0
- package/build/esm/api/extras/redactions.test.d.ts +1 -0
- package/build/esm/api/extras/relatesTo.d.ts +60 -0
- package/build/esm/api/extras/relatesTo.test.d.ts +1 -0
- package/build/esm/api/extras/roomMember.d.ts +35 -0
- package/build/esm/api/extras/roomMember.test.d.ts +1 -0
- package/build/esm/api/index.d.ts +8 -0
- package/build/esm/api/parameters.d.ts +58 -0
- package/build/esm/api/parameters.test.d.ts +1 -0
- package/build/esm/api/registration.d.ts +33 -0
- package/build/esm/api/registration.test.d.ts +1 -0
- package/build/esm/api/types.d.ts +466 -0
- package/build/esm/api/utils.d.ts +20 -0
- package/build/esm/api/utils.test.d.ts +1 -0
- package/build/esm/index.d.ts +5 -0
- package/build/esm/index.js +99 -49
- package/build/index.d.ts +17 -2
- package/package.json +27 -15
package/build/esm/index.js
CHANGED
|
@@ -140,7 +140,7 @@ function isRoomEvent(event) {
|
|
|
140
140
|
* See the License for the specific language governing permissions and
|
|
141
141
|
* limitations under the License.
|
|
142
142
|
*/
|
|
143
|
-
var __awaiter$
|
|
143
|
+
var __awaiter$4 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
144
144
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
145
145
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
146
146
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -149,7 +149,7 @@ var __awaiter$3 = (undefined && undefined.__awaiter) || function (thisArg, _argu
|
|
|
149
149
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
150
150
|
});
|
|
151
151
|
};
|
|
152
|
-
var __generator$
|
|
152
|
+
var __generator$4 = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
153
153
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
154
154
|
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
155
155
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -190,10 +190,10 @@ var WIDGET_CAPABILITY_NAVIGATE = 'org.matrix.msc2931.navigate';
|
|
|
190
190
|
* @param opts - {@link NavigateToRoomOptions}
|
|
191
191
|
*/
|
|
192
192
|
function navigateToRoom(widgetApi_1, roomId_1) {
|
|
193
|
-
return __awaiter$
|
|
193
|
+
return __awaiter$4(this, arguments, void 0, function (widgetApi, roomId, opts) {
|
|
194
194
|
var _a, via, params, url;
|
|
195
195
|
if (opts === void 0) { opts = {}; }
|
|
196
|
-
return __generator$
|
|
196
|
+
return __generator$4(this, function (_b) {
|
|
197
197
|
switch (_b.label) {
|
|
198
198
|
case 0:
|
|
199
199
|
_a = opts.via, via = _a === void 0 ? [] : _a;
|
|
@@ -437,7 +437,7 @@ function calculateActionPowerLevel(powerLevelStateEvent, action) {
|
|
|
437
437
|
* See the License for the specific language governing permissions and
|
|
438
438
|
* limitations under the License.
|
|
439
439
|
*/
|
|
440
|
-
var __awaiter$
|
|
440
|
+
var __awaiter$3 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
441
441
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
442
442
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
443
443
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -446,7 +446,7 @@ var __awaiter$2 = (undefined && undefined.__awaiter) || function (thisArg, _argu
|
|
|
446
446
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
447
447
|
});
|
|
448
448
|
};
|
|
449
|
-
var __generator$
|
|
449
|
+
var __generator$3 = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
450
450
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
451
451
|
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
452
452
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -496,9 +496,9 @@ function isValidRedactionEvent(event) {
|
|
|
496
496
|
* @returns The redaction event that was send to the room.
|
|
497
497
|
*/
|
|
498
498
|
function redactEvent(widgetApi, eventId) {
|
|
499
|
-
return __awaiter$
|
|
499
|
+
return __awaiter$3(this, void 0, void 0, function () {
|
|
500
500
|
var result;
|
|
501
|
-
return __generator$
|
|
501
|
+
return __generator$3(this, function (_a) {
|
|
502
502
|
switch (_a.label) {
|
|
503
503
|
case 0: return [4 /*yield*/, widgetApi.sendRoomEvent(ROOM_EVENT_REDACTION, { redacts: eventId })];
|
|
504
504
|
case 1:
|
|
@@ -763,7 +763,7 @@ var __assign = (undefined && undefined.__assign) || function () {
|
|
|
763
763
|
};
|
|
764
764
|
return __assign.apply(this, arguments);
|
|
765
765
|
};
|
|
766
|
-
var __awaiter$
|
|
766
|
+
var __awaiter$2 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
767
767
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
768
768
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
769
769
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -772,7 +772,7 @@ var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _argu
|
|
|
772
772
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
773
773
|
});
|
|
774
774
|
};
|
|
775
|
-
var __generator$
|
|
775
|
+
var __generator$2 = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
776
776
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
777
777
|
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
778
778
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -871,10 +871,10 @@ var STATE_EVENT_WIDGETS = 'im.vector.modular.widgets';
|
|
|
871
871
|
* registration, like the display name of the widget.
|
|
872
872
|
*/
|
|
873
873
|
function repairWidgetRegistration(widgetApi_1) {
|
|
874
|
-
return __awaiter$
|
|
874
|
+
return __awaiter$2(this, arguments, void 0, function (widgetApi, registration) {
|
|
875
875
|
var readResult, url, name, type, data;
|
|
876
876
|
if (registration === void 0) { registration = {}; }
|
|
877
|
-
return __generator$
|
|
877
|
+
return __generator$2(this, function (_a) {
|
|
878
878
|
switch (_a.label) {
|
|
879
879
|
case 0: return [4 /*yield*/, widgetApi.requestCapabilities([
|
|
880
880
|
WidgetEventCapability.forStateEvent(EventDirection.Send, STATE_EVENT_WIDGETS, widgetApi.widgetId),
|
|
@@ -936,6 +936,42 @@ function repairWidgetRegistration(widgetApi_1) {
|
|
|
936
936
|
* See the License for the specific language governing permissions and
|
|
937
937
|
* limitations under the License.
|
|
938
938
|
*/
|
|
939
|
+
var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
940
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
941
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
942
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
943
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
944
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
945
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
946
|
+
});
|
|
947
|
+
};
|
|
948
|
+
var __generator$1 = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
949
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
950
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
951
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
952
|
+
function step(op) {
|
|
953
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
954
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
955
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
956
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
957
|
+
switch (op[0]) {
|
|
958
|
+
case 0: case 1: t = op; break;
|
|
959
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
960
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
961
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
962
|
+
default:
|
|
963
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
964
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
965
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
966
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
967
|
+
if (t[2]) _.ops.pop();
|
|
968
|
+
_.trys.pop(); continue;
|
|
969
|
+
}
|
|
970
|
+
op = body.call(thisArg, _);
|
|
971
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
972
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
973
|
+
}
|
|
974
|
+
};
|
|
939
975
|
function convertToRawCapabilities(rawCapabilities) {
|
|
940
976
|
return rawCapabilities.map(function (c) { return (typeof c === 'string' ? c : c.raw); });
|
|
941
977
|
}
|
|
@@ -962,6 +998,47 @@ function isInRoom(matrixEvent, currentRoomId, roomIds) {
|
|
|
962
998
|
}
|
|
963
999
|
return roomIds.includes(matrixEvent.room_id);
|
|
964
1000
|
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Create a state event from the arguments.
|
|
1003
|
+
*
|
|
1004
|
+
* @returns A state event with current timestamp origin_server_ts.
|
|
1005
|
+
*/
|
|
1006
|
+
function makeEventFromSendStateEventResult(type, stateKey, content, sender, sendResult) {
|
|
1007
|
+
if (sendResult.event_id === undefined) {
|
|
1008
|
+
throw new Error('Send state event did not return an event ID');
|
|
1009
|
+
}
|
|
1010
|
+
return {
|
|
1011
|
+
content: content,
|
|
1012
|
+
event_id: sendResult.event_id,
|
|
1013
|
+
origin_server_ts: Date.now(),
|
|
1014
|
+
room_id: sendResult.room_id,
|
|
1015
|
+
sender: sender,
|
|
1016
|
+
state_key: stateKey,
|
|
1017
|
+
type: type,
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Send a state event and resolve to a "virtual" state event.
|
|
1022
|
+
*
|
|
1023
|
+
* @returns Promise, that resolves to a state event with current timestamp origin_server_ts.
|
|
1024
|
+
*/
|
|
1025
|
+
function sendStateEventWithEventResult(widgetApi, type, stateKey, content) {
|
|
1026
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
1027
|
+
var response;
|
|
1028
|
+
return __generator$1(this, function (_a) {
|
|
1029
|
+
switch (_a.label) {
|
|
1030
|
+
case 0:
|
|
1031
|
+
if (widgetApi.widgetParameters.userId === undefined) {
|
|
1032
|
+
throw new Error('Own user ID is undefined');
|
|
1033
|
+
}
|
|
1034
|
+
return [4 /*yield*/, widgetApi.sendStateEvent(type, content, { stateKey: stateKey })];
|
|
1035
|
+
case 1:
|
|
1036
|
+
response = _a.sent();
|
|
1037
|
+
return [2 /*return*/, makeEventFromSendStateEventResult(type, stateKey, content, widgetApi.widgetParameters.userId, response)];
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
965
1042
|
|
|
966
1043
|
/*
|
|
967
1044
|
* Copyright 2022 Nordeck IT + Consulting GmbH
|
|
@@ -1332,36 +1409,9 @@ var WidgetApiImpl = /** @class */ (function () {
|
|
|
1332
1409
|
return concat(historyEvent$, futureEvent$);
|
|
1333
1410
|
};
|
|
1334
1411
|
/** {@inheritDoc WidgetApi.sendStateEvent} */
|
|
1335
|
-
WidgetApiImpl.prototype.sendStateEvent = function (
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
var _c = _a === void 0 ? {} : _a, roomId = _c.roomId, _d = _c.stateKey, stateKey = _d === void 0 ? '' : _d;
|
|
1339
|
-
return __generator(this, function (_e) {
|
|
1340
|
-
switch (_e.label) {
|
|
1341
|
-
case 0:
|
|
1342
|
-
subject = new ReplaySubject();
|
|
1343
|
-
subscription = this.events$.subscribe(function (e) { return subject.next(e); });
|
|
1344
|
-
_e.label = 1;
|
|
1345
|
-
case 1:
|
|
1346
|
-
_e.trys.push([1, , 4, 5]);
|
|
1347
|
-
return [4 /*yield*/, this.matrixWidgetApi.sendStateEvent(eventType, stateKey, content, roomId)];
|
|
1348
|
-
case 2:
|
|
1349
|
-
_b = _e.sent(), event_id_1 = _b.event_id, room_id_1 = _b.room_id;
|
|
1350
|
-
return [4 /*yield*/, firstValueFrom(subject.pipe(filter(function (event) {
|
|
1351
|
-
var matrixEvent = event.detail.data;
|
|
1352
|
-
return (matrixEvent.event_id === event_id_1 &&
|
|
1353
|
-
matrixEvent.room_id === room_id_1);
|
|
1354
|
-
}), map(function (event) { return event.detail.data; })))];
|
|
1355
|
-
case 3:
|
|
1356
|
-
event_1 = _e.sent();
|
|
1357
|
-
return [2 /*return*/, event_1];
|
|
1358
|
-
case 4:
|
|
1359
|
-
subscription.unsubscribe();
|
|
1360
|
-
return [7 /*endfinally*/];
|
|
1361
|
-
case 5: return [2 /*return*/];
|
|
1362
|
-
}
|
|
1363
|
-
});
|
|
1364
|
-
});
|
|
1412
|
+
WidgetApiImpl.prototype.sendStateEvent = function (eventType, content, _a) {
|
|
1413
|
+
var _b = _a === void 0 ? {} : _a, roomId = _b.roomId, _c = _b.stateKey, stateKey = _c === void 0 ? '' : _c;
|
|
1414
|
+
return this.matrixWidgetApi.sendStateEvent(eventType, stateKey, content, roomId);
|
|
1365
1415
|
};
|
|
1366
1416
|
/** {@inheritDoc WidgetApi.receiveRoomEvents} */
|
|
1367
1417
|
WidgetApiImpl.prototype.receiveRoomEvents = function (eventType_1) {
|
|
@@ -1398,7 +1448,7 @@ var WidgetApiImpl = /** @class */ (function () {
|
|
|
1398
1448
|
/** {@inheritDoc WidgetApi.sendRoomEvent} */
|
|
1399
1449
|
WidgetApiImpl.prototype.sendRoomEvent = function (eventType_1, content_1) {
|
|
1400
1450
|
return __awaiter(this, arguments, void 0, function (eventType, content, _a) {
|
|
1401
|
-
var subject, subscription, _b,
|
|
1451
|
+
var subject, subscription, _b, event_id_1, room_id_1, event_1;
|
|
1402
1452
|
var _c = _a === void 0 ? {} : _a, roomId = _c.roomId;
|
|
1403
1453
|
return __generator(this, function (_d) {
|
|
1404
1454
|
switch (_d.label) {
|
|
@@ -1410,15 +1460,15 @@ var WidgetApiImpl = /** @class */ (function () {
|
|
|
1410
1460
|
_d.trys.push([1, , 4, 5]);
|
|
1411
1461
|
return [4 /*yield*/, this.matrixWidgetApi.sendRoomEvent(eventType, content, roomId)];
|
|
1412
1462
|
case 2:
|
|
1413
|
-
_b = _d.sent(),
|
|
1463
|
+
_b = _d.sent(), event_id_1 = _b.event_id, room_id_1 = _b.room_id;
|
|
1414
1464
|
return [4 /*yield*/, firstValueFrom(subject.pipe(filter(function (event) {
|
|
1415
1465
|
var matrixEvent = event.detail.data;
|
|
1416
|
-
return (matrixEvent.event_id ===
|
|
1417
|
-
matrixEvent.room_id ===
|
|
1466
|
+
return (matrixEvent.event_id === event_id_1 &&
|
|
1467
|
+
matrixEvent.room_id === room_id_1);
|
|
1418
1468
|
}), map(function (event) { return event.detail.data; })))];
|
|
1419
1469
|
case 3:
|
|
1420
|
-
|
|
1421
|
-
return [2 /*return*/,
|
|
1470
|
+
event_1 = _d.sent();
|
|
1471
|
+
return [2 /*return*/, event_1];
|
|
1422
1472
|
case 4:
|
|
1423
1473
|
subscription.unsubscribe();
|
|
1424
1474
|
return [7 /*endfinally*/];
|
|
@@ -1694,4 +1744,4 @@ var WidgetApiImpl = /** @class */ (function () {
|
|
|
1694
1744
|
return WidgetApiImpl;
|
|
1695
1745
|
}());
|
|
1696
1746
|
|
|
1697
|
-
export { ROOM_EVENT_REDACTION, STATE_EVENT_POWER_LEVELS, STATE_EVENT_ROOM_MEMBER, WIDGET_CAPABILITY_NAVIGATE, WidgetApiImpl, calculateUserPowerLevel, compareOriginServerTS, extractRawWidgetParameters, extractWidgetApiParameters, extractWidgetParameters, generateRoomTimelineCapabilities, generateWidgetRegistrationUrl, getContent, getOriginalEventId, getRoomMemberDisplayName, hasActionPower, hasRequiredWidgetParameters, hasRoomEventPower, hasStateEventPower, isRoomEvent, isStateEvent, isValidEventWithRelatesTo, isValidPowerLevelStateEvent, isValidRedactionEvent, isValidRoomMemberStateEvent, navigateToRoom, observeRedactionEvents, parseWidgetId, redactEvent, repairWidgetRegistration };
|
|
1747
|
+
export { ROOM_EVENT_REDACTION, STATE_EVENT_POWER_LEVELS, STATE_EVENT_ROOM_MEMBER, WIDGET_CAPABILITY_NAVIGATE, WidgetApiImpl, calculateUserPowerLevel, compareOriginServerTS, extractRawWidgetParameters, extractWidgetApiParameters, extractWidgetParameters, generateRoomTimelineCapabilities, generateWidgetRegistrationUrl, getContent, getOriginalEventId, getRoomMemberDisplayName, hasActionPower, hasRequiredWidgetParameters, hasRoomEventPower, hasStateEventPower, isRoomEvent, isStateEvent, isValidEventWithRelatesTo, isValidPowerLevelStateEvent, isValidRedactionEvent, isValidRoomMemberStateEvent, makeEventFromSendStateEventResult, navigateToRoom, observeRedactionEvents, parseWidgetId, redactEvent, repairWidgetRegistration, sendStateEventWithEventResult };
|
package/build/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { IModalWidgetOpenRequestDataButton } from 'matrix-widget-api';
|
|
|
11
11
|
import { IModalWidgetReturnData } from 'matrix-widget-api';
|
|
12
12
|
import { IOpenIDCredentials } from 'matrix-widget-api';
|
|
13
13
|
import { IRoomEvent } from 'matrix-widget-api';
|
|
14
|
+
import { ISendEventFromWidgetResponseData } from 'matrix-widget-api';
|
|
14
15
|
import { IUploadFileActionFromWidgetResponseData } from 'matrix-widget-api';
|
|
15
16
|
import { IWidget } from 'matrix-widget-api';
|
|
16
17
|
import { IWidgetApiRequest } from 'matrix-widget-api';
|
|
@@ -214,6 +215,13 @@ export declare function isValidRedactionEvent(event: RoomEvent<unknown>): event
|
|
|
214
215
|
*/
|
|
215
216
|
export declare function isValidRoomMemberStateEvent(event: StateEvent<unknown>): event is StateEvent<RoomMemberStateEventContent>;
|
|
216
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Create a state event from the arguments.
|
|
220
|
+
*
|
|
221
|
+
* @returns A state event with current timestamp origin_server_ts.
|
|
222
|
+
*/
|
|
223
|
+
export declare function makeEventFromSendStateEventResult<T>(type: string, stateKey: string, content: T, sender: string, sendResult: ISendEventFromWidgetResponseData): StateEvent<T>;
|
|
224
|
+
|
|
217
225
|
/**
|
|
218
226
|
* The membership state of a user.
|
|
219
227
|
*/
|
|
@@ -380,6 +388,13 @@ export declare type RoomMemberStateEventContent = {
|
|
|
380
388
|
avatar_url?: string | null;
|
|
381
389
|
};
|
|
382
390
|
|
|
391
|
+
/**
|
|
392
|
+
* Send a state event and resolve to a "virtual" state event.
|
|
393
|
+
*
|
|
394
|
+
* @returns Promise, that resolves to a state event with current timestamp origin_server_ts.
|
|
395
|
+
*/
|
|
396
|
+
export declare function sendStateEventWithEventResult<T>(widgetApi: WidgetApi, type: string, stateKey: string, content: T): Promise<StateEvent<T>>;
|
|
397
|
+
|
|
383
398
|
/**
|
|
384
399
|
* The name of the power levels state event.
|
|
385
400
|
*/
|
|
@@ -542,7 +557,7 @@ export declare type WidgetApi = {
|
|
|
542
557
|
sendStateEvent<T>(eventType: string, content: T, options?: {
|
|
543
558
|
roomId?: string;
|
|
544
559
|
stateKey?: string;
|
|
545
|
-
}): Promise<
|
|
560
|
+
}): Promise<ISendEventFromWidgetResponseData>;
|
|
546
561
|
/**
|
|
547
562
|
* Receive all room events of a given type from the current room.
|
|
548
563
|
*
|
|
@@ -858,7 +873,7 @@ export declare class WidgetApiImpl implements WidgetApi {
|
|
|
858
873
|
sendStateEvent<T>(eventType: string, content: T, { roomId, stateKey }?: {
|
|
859
874
|
roomId?: string;
|
|
860
875
|
stateKey?: string;
|
|
861
|
-
}): Promise<
|
|
876
|
+
}): Promise<ISendEventFromWidgetResponseData>;
|
|
862
877
|
/** {@inheritDoc WidgetApi.receiveRoomEvents} */
|
|
863
878
|
receiveRoomEvents<T>(eventType: string, { messageType, roomIds, }?: {
|
|
864
879
|
messageType?: string;
|
package/package.json
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matrix-widget-toolkit/api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.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",
|
|
7
7
|
"source": "./src/index.ts",
|
|
8
|
-
"types": "./build/index.d.ts",
|
|
8
|
+
"types": "./build/esm/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
|
|
10
|
+
".": {
|
|
11
|
+
"module": "./build/esm/index.js",
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./build/esm/index.d.ts",
|
|
14
|
+
"default": "./build/esm/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./build/cjs/index.d.cts",
|
|
18
|
+
"default": "./build/cjs/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
12
22
|
},
|
|
13
23
|
"type": "module",
|
|
14
24
|
"devDependencies": {
|
|
15
|
-
"@rollup/plugin-commonjs": "
|
|
16
|
-
"@types/node": "
|
|
17
|
-
"@types/qs": "
|
|
18
|
-
"@vitest/coverage-v8": "
|
|
19
|
-
"typescript": "5.
|
|
20
|
-
"vite": "
|
|
21
|
-
"vitest": "
|
|
25
|
+
"@rollup/plugin-commonjs": "28.0.1",
|
|
26
|
+
"@types/node": "22.10.1",
|
|
27
|
+
"@types/qs": "6.9.17",
|
|
28
|
+
"@vitest/coverage-v8": "2.1.8",
|
|
29
|
+
"typescript": "5.7.2",
|
|
30
|
+
"vite": "5.4.11",
|
|
31
|
+
"vitest": "2.1.8"
|
|
22
32
|
},
|
|
23
33
|
"scripts": {
|
|
24
34
|
"build": "tsc && rollup --config ../../rollup.config.mjs",
|
|
@@ -33,9 +43,9 @@
|
|
|
33
43
|
"generate-api-report": "tsc && api-extractor run --verbose --local"
|
|
34
44
|
},
|
|
35
45
|
"dependencies": {
|
|
36
|
-
"matrix-widget-api": "
|
|
37
|
-
"qs": "
|
|
38
|
-
"rxjs": "
|
|
46
|
+
"matrix-widget-api": "1.10.0",
|
|
47
|
+
"qs": "6.13.1",
|
|
48
|
+
"rxjs": "7.8.1"
|
|
39
49
|
},
|
|
40
50
|
"repository": {
|
|
41
51
|
"type": "git",
|
|
@@ -49,5 +59,7 @@
|
|
|
49
59
|
"matrix",
|
|
50
60
|
"widget",
|
|
51
61
|
"matrix-widget-api"
|
|
52
|
-
]
|
|
62
|
+
],
|
|
63
|
+
"module": "./build/esm/index.js",
|
|
64
|
+
"main": "./build/cjs/index.cjs"
|
|
53
65
|
}
|