@ixo/editor 3.0.0-beta.25 → 3.0.0-beta.27
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/dist/{chunk-3RYZSIC2.mjs → chunk-SUFKRSSM.mjs} +89 -1
- package/dist/chunk-SUFKRSSM.mjs.map +1 -0
- package/dist/{chunk-TLYT3OAQ.mjs → chunk-WEEDXXFU.mjs} +580 -395
- package/dist/chunk-WEEDXXFU.mjs.map +1 -0
- package/dist/core/index.mjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/mantine/index.mjs +7 -6
- package/package.json +10 -3
- package/dist/chunk-3RYZSIC2.mjs.map +0 -1
- package/dist/chunk-TLYT3OAQ.mjs.map +0 -1
|
@@ -76,6 +76,62 @@ function buildServicesFromHandlers(handlers) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
// src/core/lib/matrixDm.ts
|
|
80
|
+
function getHomeserver(matrixClient) {
|
|
81
|
+
const userId = matrixClient.getUserId();
|
|
82
|
+
if (!userId) throw new Error("Matrix client has no user ID");
|
|
83
|
+
const idx = userId.indexOf(":");
|
|
84
|
+
if (idx === -1) throw new Error(`Invalid Matrix user ID: ${userId}`);
|
|
85
|
+
return userId.substring(idx + 1);
|
|
86
|
+
}
|
|
87
|
+
function didToMatrixUserId(did, homeserver) {
|
|
88
|
+
const localpart = did.replace(/:/g, "-");
|
|
89
|
+
return `@${localpart}:${homeserver}`;
|
|
90
|
+
}
|
|
91
|
+
async function findOrCreateDMRoom(matrixClient, targetUserId) {
|
|
92
|
+
try {
|
|
93
|
+
const directEvent = matrixClient.getAccountData("m.direct");
|
|
94
|
+
const directContent = directEvent?.getContent() || {};
|
|
95
|
+
const existingRooms = directContent[targetUserId];
|
|
96
|
+
if (existingRooms && existingRooms.length > 0) {
|
|
97
|
+
return existingRooms[0];
|
|
98
|
+
}
|
|
99
|
+
} catch {
|
|
100
|
+
}
|
|
101
|
+
const response = await matrixClient.createRoom({
|
|
102
|
+
is_direct: true,
|
|
103
|
+
invite: [targetUserId],
|
|
104
|
+
preset: "trusted_private_chat",
|
|
105
|
+
initial_state: []
|
|
106
|
+
});
|
|
107
|
+
const roomId = response.room_id;
|
|
108
|
+
try {
|
|
109
|
+
const directEvent = matrixClient.getAccountData("m.direct");
|
|
110
|
+
const directContent = directEvent?.getContent() || {};
|
|
111
|
+
const updatedContent = {
|
|
112
|
+
...directContent,
|
|
113
|
+
[targetUserId]: [...directContent[targetUserId] || [], roomId]
|
|
114
|
+
};
|
|
115
|
+
await matrixClient.setAccountData("m.direct", updatedContent);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.warn("[MatrixDM] Failed to update m.direct account data:", error);
|
|
118
|
+
}
|
|
119
|
+
return roomId;
|
|
120
|
+
}
|
|
121
|
+
async function sendMatrixMessage(matrixClient, roomId, message) {
|
|
122
|
+
await matrixClient.sendEvent(roomId, "m.room.message", {
|
|
123
|
+
msgtype: "m.text",
|
|
124
|
+
body: message
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async function sendDirectMessage(matrixClient, targetDid, message) {
|
|
128
|
+
const homeserver = getHomeserver(matrixClient);
|
|
129
|
+
const targetUserId = didToMatrixUserId(targetDid, homeserver);
|
|
130
|
+
const roomId = await findOrCreateDMRoom(matrixClient, targetUserId);
|
|
131
|
+
await sendMatrixMessage(matrixClient, roomId, message);
|
|
132
|
+
return { roomId };
|
|
133
|
+
}
|
|
134
|
+
|
|
79
135
|
// src/core/lib/actionRegistry/actions/httpRequest.ts
|
|
80
136
|
registerAction({
|
|
81
137
|
type: "http.request",
|
|
@@ -1458,6 +1514,34 @@ ${configJson}`
|
|
|
1458
1514
|
}
|
|
1459
1515
|
});
|
|
1460
1516
|
|
|
1517
|
+
// src/core/lib/actionRegistry/actions/matrixDm.ts
|
|
1518
|
+
registerAction({
|
|
1519
|
+
type: "matrix.dm",
|
|
1520
|
+
sideEffect: true,
|
|
1521
|
+
defaultRequiresConfirmation: false,
|
|
1522
|
+
outputSchema: [
|
|
1523
|
+
{ path: "roomId", displayName: "Room ID", type: "string", description: "The Matrix room ID used for the DM" },
|
|
1524
|
+
{ path: "sentAt", displayName: "Sent At", type: "string", description: "Timestamp when the message was sent" }
|
|
1525
|
+
],
|
|
1526
|
+
run: async (inputs, ctx) => {
|
|
1527
|
+
const matrixClient = ctx.editor?.getMatrixClient?.();
|
|
1528
|
+
if (!matrixClient) {
|
|
1529
|
+
throw new Error("Matrix client not available");
|
|
1530
|
+
}
|
|
1531
|
+
const targetDid = String(inputs.targetDid || "").trim();
|
|
1532
|
+
const message = String(inputs.message || "").trim();
|
|
1533
|
+
if (!targetDid) throw new Error("Recipient DID is required");
|
|
1534
|
+
if (!message) throw new Error("Message is required");
|
|
1535
|
+
const result = await sendDirectMessage(matrixClient, targetDid, message);
|
|
1536
|
+
return {
|
|
1537
|
+
output: {
|
|
1538
|
+
roomId: result.roomId,
|
|
1539
|
+
sentAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1540
|
+
}
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
|
|
1461
1545
|
// src/core/lib/ucanDelegationStore.ts
|
|
1462
1546
|
var ROOT_DELEGATION_KEY = "__root__";
|
|
1463
1547
|
var MIGRATION_VERSION_KEY = "__version__";
|
|
@@ -2997,6 +3081,10 @@ export {
|
|
|
2997
3081
|
buildGovernanceGroupLinkedEntities,
|
|
2998
3082
|
transformSurveyToCredentialSubject,
|
|
2999
3083
|
extractSurveyAnswersTemplate,
|
|
3084
|
+
getHomeserver,
|
|
3085
|
+
didToMatrixUserId,
|
|
3086
|
+
findOrCreateDMRoom,
|
|
3087
|
+
sendDirectMessage,
|
|
3000
3088
|
createUcanDelegationStore,
|
|
3001
3089
|
createMemoryUcanDelegationStore,
|
|
3002
3090
|
createInvocationStore,
|
|
@@ -3017,4 +3105,4 @@ export {
|
|
|
3017
3105
|
createUcanService,
|
|
3018
3106
|
SimpleUCANManager
|
|
3019
3107
|
};
|
|
3020
|
-
//# sourceMappingURL=chunk-
|
|
3108
|
+
//# sourceMappingURL=chunk-SUFKRSSM.mjs.map
|