@celljs/ta-changes 4.11.0 → 4.13.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/extension/index.mjs +51 -0
- package/package.json +10 -4
package/extension/index.mjs
CHANGED
|
@@ -5,20 +5,71 @@ var TaHostUtil;
|
|
|
5
5
|
TaHostUtil2.WAIT_MS = 1000;
|
|
6
6
|
function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
|
|
7
7
|
return new Promise((resolve) => {
|
|
8
|
+
let heard = false;
|
|
9
|
+
let answered = false;
|
|
8
10
|
const timer = setTimeout(() => resolve(undefined), waitMs);
|
|
9
11
|
const request = {
|
|
10
12
|
name,
|
|
13
|
+
heard: () => {
|
|
14
|
+
heard = true;
|
|
15
|
+
},
|
|
11
16
|
resolve: (answer) => {
|
|
17
|
+
answered = true;
|
|
12
18
|
clearTimeout(timer);
|
|
13
19
|
resolve(answer);
|
|
14
20
|
}
|
|
15
21
|
};
|
|
16
22
|
events.emit(TA_HOST_EVENT, request);
|
|
23
|
+
if (!heard && !answered) {
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
resolve(undefined);
|
|
26
|
+
}
|
|
17
27
|
});
|
|
18
28
|
}
|
|
19
29
|
TaHostUtil2.reach = reach;
|
|
20
30
|
})(TaHostUtil || (TaHostUtil = {}));
|
|
21
31
|
var TA_FILE_WRITE_EVENT = "ta:file-write";
|
|
32
|
+
var TA_ASK_ENTRY = "ta-ask";
|
|
33
|
+
var TaAskUtil;
|
|
34
|
+
(function(TaAskUtil2) {
|
|
35
|
+
const LENGTH = 120;
|
|
36
|
+
function entry(question) {
|
|
37
|
+
const line = question.replace(/\s+/g, " ").trim();
|
|
38
|
+
return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
|
|
39
|
+
}
|
|
40
|
+
TaAskUtil2.entry = entry;
|
|
41
|
+
function asking(entries) {
|
|
42
|
+
var _a;
|
|
43
|
+
for (let i = entries.length - 1;i >= 0; i--) {
|
|
44
|
+
const entry2 = entries[i];
|
|
45
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
|
|
49
|
+
return read(entry2);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
TaAskUtil2.asking = asking;
|
|
55
|
+
function next(asked, entry2) {
|
|
56
|
+
var _a;
|
|
57
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
|
|
61
|
+
}
|
|
62
|
+
TaAskUtil2.next = next;
|
|
63
|
+
function read(found) {
|
|
64
|
+
var _a;
|
|
65
|
+
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
66
|
+
if (typeof question !== "string" || !question.trim()) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
70
|
+
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
71
|
+
}
|
|
72
|
+
})(TaAskUtil || (TaAskUtil = {}));
|
|
22
73
|
|
|
23
74
|
// web-src/changes-protocol.ts
|
|
24
75
|
var NAME = "@celljs/ta-changes";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-changes",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"description": "A pi package for Ta: the files each reply changed, with their diffs, and a button that takes the changes of a reply back",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@celljs/ta-protocol": "4.
|
|
31
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-protocol": "4.13.0",
|
|
31
|
+
"@celljs/ta-web": "4.13.0",
|
|
32
32
|
"@types/react": "^19.3.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
@@ -50,6 +50,12 @@
|
|
|
50
50
|
"host": "./host/index.mjs",
|
|
51
51
|
"extensions": [
|
|
52
52
|
"./extension/index.mjs"
|
|
53
|
-
]
|
|
53
|
+
],
|
|
54
|
+
"permissions": {
|
|
55
|
+
"host": {
|
|
56
|
+
"latest": "chat.view",
|
|
57
|
+
"*": "settings.manage"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
61
|
}
|