@nextclaw/x-harness 0.2.53 → 0.2.54
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/SOURCE.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Corresponding source
|
|
2
2
|
|
|
3
|
-
Version 0.2.
|
|
3
|
+
Version 0.2.54, commit a9b2bb0d7399463a8dc259e433e3a2bd31dc9bc7.
|
|
4
4
|
|
|
5
|
-
Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/
|
|
5
|
+
Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/a9b2bb0d7399463a8dc259e433e3a2bd31dc9bc7
|
|
6
6
|
|
|
7
7
|
Clone this revision, run npm ci, npm run bootstrap and npm run release:build.
|
|
8
8
|
|
|
@@ -3,5 +3,6 @@ export declare class DOMSubmission {
|
|
|
3
3
|
#private;
|
|
4
4
|
constructor(dependencies: Pick<DOMDependencies, "submitAX" | "session" | "tab" | "observe" | "unique" | "locator">);
|
|
5
5
|
finishDOMAction(command: any, prepared: any, query: any, result: any): Promise<void>;
|
|
6
|
+
private waitSubmittedEditor;
|
|
6
7
|
}
|
|
7
8
|
export declare function createDOMSubmission(...args: ConstructorParameters<typeof DOMSubmission>): (command: any, prepared: any, query: any, result: any) => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { xURL } from "./platform-rules.js";
|
|
1
|
+
import { xURL, sameHandle, sameText } from "./platform-rules.js";
|
|
2
2
|
import { valueOf } from "./browser-common.js";
|
|
3
3
|
export class DOMSubmission {
|
|
4
4
|
#submitAX;
|
|
@@ -29,6 +29,7 @@ export class DOMSubmission {
|
|
|
29
29
|
: null;
|
|
30
30
|
let nativeSubmitIndex;
|
|
31
31
|
if (this.#submitAX &&
|
|
32
|
+
command.activation !== "keyboard" &&
|
|
32
33
|
["submitPost", "submitReply"].includes(command.operation)) {
|
|
33
34
|
const native = await this.#submitAX.observe({ mode: "composer" });
|
|
34
35
|
const editors = native.evidence?.filter((e) => /^(?:文本输入区(?:域)?|文本区域|文本栏) /.test(e.label)) ?? [];
|
|
@@ -88,7 +89,7 @@ export class DOMSubmission {
|
|
|
88
89
|
// Inline replies keep the editor mounted. Wait for this submitted text to clear before
|
|
89
90
|
// receipt navigation/reload can interrupt the actual submission request.
|
|
90
91
|
if (submittedEditor)
|
|
91
|
-
await
|
|
92
|
+
await this.waitSubmittedEditor(submittedEditor, result);
|
|
92
93
|
if (["submitPost", "submitReply"].includes(command.operation)) {
|
|
93
94
|
try {
|
|
94
95
|
await this.#tab.playwright.waitForLoadState({
|
|
@@ -104,6 +105,36 @@ export class DOMSubmission {
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
}
|
|
108
|
+
async waitSubmittedEditor(editor, submitted) {
|
|
109
|
+
const deadline = Date.now() + 10000;
|
|
110
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
111
|
+
const remaining = deadline - Date.now();
|
|
112
|
+
if (remaining <= 0)
|
|
113
|
+
throw Error("submitted-editor-clear-timeout");
|
|
114
|
+
try {
|
|
115
|
+
await editor.waitFor({ state: "hidden", timeoutMs: remaining });
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (!/timed out|timeout|deadline exceeded/i.test(error.message) ||
|
|
120
|
+
attempt === 3 ||
|
|
121
|
+
Date.now() >= deadline)
|
|
122
|
+
throw error;
|
|
123
|
+
// Resume only the wait, never the submission or a navigation that could interrupt it.
|
|
124
|
+
const current = await this.#observe({ view: "composer" });
|
|
125
|
+
if (current.alerts?.length ||
|
|
126
|
+
!current.accountHandle ||
|
|
127
|
+
!submitted.accountHandle ||
|
|
128
|
+
!sameHandle(current.accountHandle, submitted.accountHandle) ||
|
|
129
|
+
xURL(current.page).href !== xURL(submitted.page).href ||
|
|
130
|
+
(typeof current.editorText === "string" &&
|
|
131
|
+
current.editorText.trim() &&
|
|
132
|
+
(!sameText(current.editorText, submitted.editorText) ||
|
|
133
|
+
current.replyToId !== submitted.replyToId)))
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
107
138
|
}
|
|
108
139
|
export function createDOMSubmission(...args) {
|
|
109
140
|
return new DOMSubmission(...args).finishDOMAction;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/x-harness",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.54",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Typed X task harness with compact business results and explicit diagnostics.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "a9b2bb0d7399463a8dc259e433e3a2bd31dc9bc7"
|
|
46
46
|
}
|