@nexface/tools 0.1.15-alpha.2 → 0.1.15-alpha.4
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/browser/focus.d.ts +0 -1
- package/dist/browser/focus.js +1 -12
- package/dist/operation-lock.d.ts +1 -1
- package/dist/operation-lock.js +2 -19
- package/dist/operation-view.js +5 -6
- package/package.json +3 -3
package/dist/browser/focus.d.ts
CHANGED
package/dist/browser/focus.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
let focusingForAgent = false;
|
|
2
1
|
let activatingForAgent = false;
|
|
3
2
|
export function isAgentActivation() {
|
|
4
3
|
return activatingForAgent;
|
|
@@ -13,16 +12,6 @@ export function withAgentActivation(activate) {
|
|
|
13
12
|
activatingForAgent = previous;
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
|
-
export function isAgentFocus() {
|
|
17
|
-
return focusingForAgent;
|
|
18
|
-
}
|
|
19
15
|
export function focusForAgent(element) {
|
|
20
|
-
|
|
21
|
-
focusingForAgent = true;
|
|
22
|
-
try {
|
|
23
|
-
element.focus({ preventScroll: true });
|
|
24
|
-
}
|
|
25
|
-
finally {
|
|
26
|
-
focusingForAgent = previous;
|
|
27
|
-
}
|
|
16
|
+
element.focus({ preventScroll: true });
|
|
28
17
|
}
|
package/dist/operation-lock.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function isOperationSurfaceLocked(surface: HTMLElement): boolean;
|
|
2
2
|
/** Block user input inside the surface without hiding DOM from page tools. */
|
|
3
|
-
export declare function lockOperationSurface(surface: HTMLElement
|
|
3
|
+
export declare function lockOperationSurface(surface: HTMLElement): () => void;
|
package/dist/operation-lock.js
CHANGED
|
@@ -1,38 +1,21 @@
|
|
|
1
|
-
import { isAgentActivation
|
|
1
|
+
import { isAgentActivation } from "./browser/focus.js";
|
|
2
2
|
const lockedSurfaces = new WeakSet();
|
|
3
3
|
export function isOperationSurfaceLocked(surface) {
|
|
4
4
|
return lockedSurfaces.has(surface);
|
|
5
5
|
}
|
|
6
6
|
/** Block user input inside the surface without hiding DOM from page tools. */
|
|
7
|
-
export function lockOperationSurface(surface
|
|
7
|
+
export function lockOperationSurface(surface) {
|
|
8
8
|
const previousBusy = surface.getAttribute("aria-busy");
|
|
9
9
|
const block = (event) => {
|
|
10
10
|
if ((event.type === "submit" || event.type === "reset") && isAgentActivation())
|
|
11
11
|
return;
|
|
12
12
|
if (!event.isTrusted)
|
|
13
13
|
return;
|
|
14
|
-
if (event.type === "focus" || event.type === "focusin") {
|
|
15
|
-
if (isAgentFocus())
|
|
16
|
-
return;
|
|
17
|
-
event.stopImmediatePropagation();
|
|
18
|
-
if (event.target instanceof HTMLElement)
|
|
19
|
-
event.target.blur();
|
|
20
|
-
redirectFocus?.();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if (event.type === "keydown" && event.key === "Tab") {
|
|
24
|
-
event.preventDefault();
|
|
25
|
-
event.stopImmediatePropagation();
|
|
26
|
-
redirectFocus?.();
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
14
|
event.preventDefault();
|
|
30
15
|
event.stopImmediatePropagation();
|
|
31
16
|
};
|
|
32
17
|
// Wheel and touch defaults are blocked here: React delegates them passively.
|
|
33
18
|
const events = [
|
|
34
|
-
"focus",
|
|
35
|
-
"focusin",
|
|
36
19
|
"mouseenter",
|
|
37
20
|
"mouseleave",
|
|
38
21
|
"pointerenter",
|
package/dist/operation-view.js
CHANGED
|
@@ -139,7 +139,6 @@ export function OperationOverlayView({ operation, feedback, progressHistory = []
|
|
|
139
139
|
const [, setGeometry] = useState("");
|
|
140
140
|
const [historyOpen, setHistoryOpen] = useState(false);
|
|
141
141
|
const [historyId] = useState(() => `nexface-operation-history-${globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`}`);
|
|
142
|
-
const cancelButtonRef = useRef(null);
|
|
143
142
|
const controllerShouldBeVisible = operation.status !== "cancelled" &&
|
|
144
143
|
(running || humanHasControl || operation.status === "failed");
|
|
145
144
|
const [controllerVisibility, setControllerVisibility] = useState(controllerShouldBeVisible ? "visible" : undefined);
|
|
@@ -157,12 +156,13 @@ export function OperationOverlayView({ operation, feedback, progressHistory = []
|
|
|
157
156
|
if (!progressHistory.length)
|
|
158
157
|
setHistoryOpen(false);
|
|
159
158
|
}, [progressHistory.length]);
|
|
159
|
+
const agentControlsSurface = running && !humanHasControl;
|
|
160
160
|
useLayoutEffect(() => {
|
|
161
161
|
const surface = resolveSurface?.();
|
|
162
|
-
if (!surface || !
|
|
162
|
+
if (!surface || !agentControlsSurface)
|
|
163
163
|
return;
|
|
164
|
-
return lockOperationSurface(surface
|
|
165
|
-
}, [
|
|
164
|
+
return lockOperationSurface(surface);
|
|
165
|
+
}, [agentControlsSurface, resolveSurface]);
|
|
166
166
|
const readGeometry = useCallback(() => {
|
|
167
167
|
const surface = resolveSurface?.();
|
|
168
168
|
const resolvedTarget = feedback?.resolveTarget ? feedback.resolveTarget() : feedback?.target;
|
|
@@ -201,7 +201,6 @@ export function OperationOverlayView({ operation, feedback, progressHistory = []
|
|
|
201
201
|
const activeFeedback = !cancelling && !humanHasControl && !structuredTargetLost ? feedback : undefined;
|
|
202
202
|
const effect = activeFeedback?.effect;
|
|
203
203
|
const highlightedRect = effect === "navigate" || activeFeedback?.centered ? undefined : rect;
|
|
204
|
-
const agentControlsSurface = running && !humanHasControl;
|
|
205
204
|
const operationFeedbackActive = Boolean(activeFeedback);
|
|
206
205
|
const controllerMounted = Boolean(controllerVisibility);
|
|
207
206
|
const controllerExiting = controllerVisibility === "exiting";
|
|
@@ -268,5 +267,5 @@ export function OperationOverlayView({ operation, feedback, progressHistory = []
|
|
|
268
267
|
statusLabel ? (React.createElement("small", { className: "agent-operation__description" },
|
|
269
268
|
React.createElement("span", { className: "agent-operation__status" }, statusLabel))) : null),
|
|
270
269
|
(running || humanHasControl) && operation.status !== "cancelled" ? (React.createElement("span", { className: "agent-operation__compact-status", title: compactStatusLabel }, compactStatusLabel)) : null,
|
|
271
|
-
cancel && (running || humanHasControl) && operation.status !== "cancelled" ? (React.createElement("button", {
|
|
270
|
+
cancel && (running || humanHasControl) && operation.status !== "cancelled" ? (React.createElement("button", { className: "agent-operation__stop", type: "button", disabled: cancelling, onClick: cancel }, cancelling ? "正在终止" : "终止任务")) : null)) : null), document.body);
|
|
272
271
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexface/tools",
|
|
3
|
-
"version": "0.1.15-alpha.
|
|
3
|
+
"version": "0.1.15-alpha.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"use-sync-external-store": "1.7.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"react-dom": ">=
|
|
18
|
-
"react": ">=
|
|
17
|
+
"react-dom": ">=16.14.0",
|
|
18
|
+
"react": ">=16.14.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependenciesMeta": {
|
|
21
21
|
"react-dom": {
|