@opentiny/webmcp-cli 0.0.3 → 0.0.6
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/README.md +1 -1
- package/dist/bin.cjs +364 -69
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +364 -69
- package/dist/bin.js.map +1 -1
- package/dist/index.cjs +257 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +257 -40
- package/dist/index.js.map +1 -1
- package/dist/inject-bundle.js +2704 -1420
- package/dist/webmcp-tools/creator.xiaohongshu.com.js +1 -1
- package/dist/webmcp-tools/editor.csdn.net.js +1 -1
- package/dist/webmcp-tools/excalidraw.com.js +4 -2
- package/dist/webmcp-tools/juejin.cn.js +132 -63
- package/dist/webmcp-tools/my.oschina.net.js +4 -2
- package/dist/webmcp-tools/segmentfault.com.js +856 -0
- package/dist/webmcp-tools/www.baidu.com.js +4 -2
- package/dist/webmcp-tools/xiaohongshu.com.js +1 -1
- package/dist/webmcp-tools/zhuanlan.zhihu.com.js +238 -0
- package/package.json +5 -4
package/dist/inject-bundle.js
CHANGED
|
@@ -3104,9 +3104,9 @@
|
|
|
3104
3104
|
}
|
|
3105
3105
|
});
|
|
3106
3106
|
|
|
3107
|
-
// ../../node_modules/.pnpm/fast-uri@3.1.
|
|
3107
|
+
// ../../node_modules/.pnpm/fast-uri@3.1.3/node_modules/fast-uri/lib/utils.js
|
|
3108
3108
|
var require_utils = __commonJS({
|
|
3109
|
-
"../../node_modules/.pnpm/fast-uri@3.1.
|
|
3109
|
+
"../../node_modules/.pnpm/fast-uri@3.1.3/node_modules/fast-uri/lib/utils.js"(exports, module) {
|
|
3110
3110
|
"use strict";
|
|
3111
3111
|
var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
3112
3112
|
var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
@@ -3417,9 +3417,9 @@
|
|
|
3417
3417
|
}
|
|
3418
3418
|
});
|
|
3419
3419
|
|
|
3420
|
-
// ../../node_modules/.pnpm/fast-uri@3.1.
|
|
3420
|
+
// ../../node_modules/.pnpm/fast-uri@3.1.3/node_modules/fast-uri/lib/schemes.js
|
|
3421
3421
|
var require_schemes = __commonJS({
|
|
3422
|
-
"../../node_modules/.pnpm/fast-uri@3.1.
|
|
3422
|
+
"../../node_modules/.pnpm/fast-uri@3.1.3/node_modules/fast-uri/lib/schemes.js"(exports, module) {
|
|
3423
3423
|
"use strict";
|
|
3424
3424
|
var { isUUID } = require_utils();
|
|
3425
3425
|
var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
|
|
@@ -3627,9 +3627,9 @@
|
|
|
3627
3627
|
}
|
|
3628
3628
|
});
|
|
3629
3629
|
|
|
3630
|
-
// ../../node_modules/.pnpm/fast-uri@3.1.
|
|
3630
|
+
// ../../node_modules/.pnpm/fast-uri@3.1.3/node_modules/fast-uri/index.js
|
|
3631
3631
|
var require_fast_uri = __commonJS({
|
|
3632
|
-
"../../node_modules/.pnpm/fast-uri@3.1.
|
|
3632
|
+
"../../node_modules/.pnpm/fast-uri@3.1.3/node_modules/fast-uri/index.js"(exports, module) {
|
|
3633
3633
|
"use strict";
|
|
3634
3634
|
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
3635
3635
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
@@ -3842,7 +3842,7 @@
|
|
|
3842
3842
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
3843
3843
|
if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
3844
3844
|
try {
|
|
3845
|
-
parsed.host = URL
|
|
3845
|
+
parsed.host = new URL("http://" + parsed.host).hostname;
|
|
3846
3846
|
} catch (e) {
|
|
3847
3847
|
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
3848
3848
|
}
|
|
@@ -9569,7 +9569,7 @@ gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
|
9569
9569
|
}
|
|
9570
9570
|
});
|
|
9571
9571
|
|
|
9572
|
-
// ../../node_modules/.pnpm/@page-agent+page-controller@1.
|
|
9572
|
+
// ../../node_modules/.pnpm/@page-agent+page-controller@1.12.1/node_modules/@page-agent/page-controller/dist/lib/SimulatorMask-BHVXyogh.js
|
|
9573
9573
|
var SimulatorMask_BHVXyogh_exports = {};
|
|
9574
9574
|
__export(SimulatorMask_BHVXyogh_exports, {
|
|
9575
9575
|
SimulatorMask: () => SimulatorMask
|
|
@@ -9673,7 +9673,7 @@ gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
|
9673
9673
|
}
|
|
9674
9674
|
var SimulatorMask_module_default, cursor_module_default, SimulatorMask;
|
|
9675
9675
|
var init_SimulatorMask_BHVXyogh = __esm({
|
|
9676
|
-
"../../node_modules/.pnpm/@page-agent+page-controller@1.
|
|
9676
|
+
"../../node_modules/.pnpm/@page-agent+page-controller@1.12.1/node_modules/@page-agent/page-controller/dist/lib/SimulatorMask-BHVXyogh.js"() {
|
|
9677
9677
|
init_Motion();
|
|
9678
9678
|
(function() {
|
|
9679
9679
|
try {
|
|
@@ -11104,7 +11104,7 @@ Known schemas:
|
|
|
11104
11104
|
}
|
|
11105
11105
|
};
|
|
11106
11106
|
|
|
11107
|
-
// ../../node_modules/.pnpm/@mcp-b+webmcp-polyfill@
|
|
11107
|
+
// ../../node_modules/.pnpm/@mcp-b+webmcp-polyfill@3.0.0/node_modules/@mcp-b/webmcp-polyfill/dist/index.js
|
|
11108
11108
|
var FAILED_TO_PARSE_INPUT_ARGUMENTS_MESSAGE = "Failed to parse input arguments";
|
|
11109
11109
|
var TOOL_INVOCATION_FAILED_MESSAGE = "Tool was executed but the invocation failed. For example, the script function threw an error";
|
|
11110
11110
|
var TOOL_CANCELLED_MESSAGE = "Tool was cancelled";
|
|
@@ -11117,15 +11117,17 @@ Known schemas:
|
|
|
11117
11117
|
var STANDARD_VALIDATOR_SYMBOL = Symbol("standardValidator");
|
|
11118
11118
|
var installState = {
|
|
11119
11119
|
installed: false,
|
|
11120
|
-
|
|
11121
|
-
|
|
11120
|
+
previousNavigatorModelContextDescriptor: void 0,
|
|
11121
|
+
previousNavigatorModelContextTestingDescriptor: void 0,
|
|
11122
|
+
previousDocumentModelContextDescriptor: void 0,
|
|
11123
|
+
installedNavigatorModelContext: false,
|
|
11124
|
+
installedNavigatorModelContextTesting: false,
|
|
11125
|
+
installedDocumentModelContext: false
|
|
11122
11126
|
};
|
|
11123
11127
|
var StrictWebMCPContext = class extends EventTarget {
|
|
11124
11128
|
tools = /* @__PURE__ */ new Map();
|
|
11125
11129
|
testingShim = null;
|
|
11126
11130
|
_ontoolchange = null;
|
|
11127
|
-
provideContextDeprecationWarned = false;
|
|
11128
|
-
clearContextDeprecationWarned = false;
|
|
11129
11131
|
unregisterToolDeprecationWarned = false;
|
|
11130
11132
|
get ontoolchange() {
|
|
11131
11133
|
return this._ontoolchange;
|
|
@@ -11133,21 +11135,6 @@ Known schemas:
|
|
|
11133
11135
|
set ontoolchange(handler) {
|
|
11134
11136
|
this._ontoolchange = handler;
|
|
11135
11137
|
}
|
|
11136
|
-
provideContext(options = {}) {
|
|
11137
|
-
this.warnProvideContextDeprecationOnce();
|
|
11138
|
-
const nextTools = /* @__PURE__ */ new Map();
|
|
11139
|
-
for (const tool of options.tools ?? []) {
|
|
11140
|
-
const normalized = normalizeToolDescriptor(tool, nextTools);
|
|
11141
|
-
nextTools.set(normalized.name, normalized);
|
|
11142
|
-
}
|
|
11143
|
-
this.tools = nextTools;
|
|
11144
|
-
this.notifyToolsChanged();
|
|
11145
|
-
}
|
|
11146
|
-
clearContext() {
|
|
11147
|
-
this.warnClearContextDeprecationOnce();
|
|
11148
|
-
this.tools.clear();
|
|
11149
|
-
this.notifyToolsChanged();
|
|
11150
|
-
}
|
|
11151
11138
|
registerTool(tool, options) {
|
|
11152
11139
|
const signal2 = options?.signal;
|
|
11153
11140
|
if (signal2?.aborted) {
|
|
@@ -11167,7 +11154,10 @@ Known schemas:
|
|
|
11167
11154
|
if (this.tools.delete(name)) this.notifyToolsChanged();
|
|
11168
11155
|
}
|
|
11169
11156
|
getTools() {
|
|
11170
|
-
return this.
|
|
11157
|
+
return Promise.resolve(this.getRegisteredToolInfos());
|
|
11158
|
+
}
|
|
11159
|
+
executeTool(tool, inputArgsJson, options) {
|
|
11160
|
+
return this.executeToolByName(tool.name, inputArgsJson, options, false);
|
|
11171
11161
|
}
|
|
11172
11162
|
getTestingShim() {
|
|
11173
11163
|
if (!this.testingShim) this.testingShim = new PolyfillTestingShim(this);
|
|
@@ -11176,21 +11166,36 @@ Known schemas:
|
|
|
11176
11166
|
/** @internal Used by PolyfillTestingShim */
|
|
11177
11167
|
getToolInfos() {
|
|
11178
11168
|
return [...this.tools.values()].map((tool) => {
|
|
11179
|
-
let
|
|
11169
|
+
let inputSchema2;
|
|
11180
11170
|
try {
|
|
11181
|
-
|
|
11171
|
+
inputSchema2 = JSON.stringify(tool.inputSchema ?? { type: "object" });
|
|
11182
11172
|
} catch {
|
|
11183
|
-
|
|
11173
|
+
inputSchema2 = '{"type":"object"}';
|
|
11184
11174
|
}
|
|
11185
11175
|
return {
|
|
11186
11176
|
name: tool.name,
|
|
11187
11177
|
description: tool.description,
|
|
11188
|
-
inputSchema
|
|
11178
|
+
inputSchema: inputSchema2
|
|
11179
|
+
};
|
|
11180
|
+
});
|
|
11181
|
+
}
|
|
11182
|
+
/** @internal Used by getTools() */
|
|
11183
|
+
getRegisteredToolInfos() {
|
|
11184
|
+
return this.getToolInfos().map((toolInfo) => {
|
|
11185
|
+
const tool = this.tools.get(toolInfo.name);
|
|
11186
|
+
return {
|
|
11187
|
+
...toolInfo,
|
|
11188
|
+
title: tool?.title ?? "",
|
|
11189
|
+
origin: globalThis.location?.origin ?? "",
|
|
11190
|
+
window: globalThis.window
|
|
11189
11191
|
};
|
|
11190
11192
|
});
|
|
11191
11193
|
}
|
|
11192
11194
|
/** @internal Used by PolyfillTestingShim */
|
|
11193
11195
|
async executeToolForTesting(toolName, inputArgsJson, options) {
|
|
11196
|
+
return this.executeToolByName(toolName, inputArgsJson, options, true);
|
|
11197
|
+
}
|
|
11198
|
+
async executeToolByName(toolName, inputArgsJson, options, normalizeResult) {
|
|
11194
11199
|
if (options?.signal?.aborted) throw createUnknownError(TOOL_CANCELLED_MESSAGE);
|
|
11195
11200
|
const tool = this.tools.get(toolName);
|
|
11196
11201
|
if (!tool) throw createUnknownError(`Tool not found: ${toolName}`);
|
|
@@ -11205,7 +11210,10 @@ Known schemas:
|
|
|
11205
11210
|
} };
|
|
11206
11211
|
try {
|
|
11207
11212
|
const execution = tool.execute(args, client);
|
|
11208
|
-
|
|
11213
|
+
const rawResult = await withAbortSignal(Promise.resolve(execution), options?.signal);
|
|
11214
|
+
if (normalizeResult) return toSerializedTestingResult(normalizeToolResponse(rawResult));
|
|
11215
|
+
const serialized = JSON.stringify(rawResult);
|
|
11216
|
+
return serialized === void 0 ? null : serialized;
|
|
11209
11217
|
} catch (error2) {
|
|
11210
11218
|
throw createUnknownError(error2 instanceof Error ? `${TOOL_INVOCATION_FAILED_MESSAGE}: ${error2.message}` : TOOL_INVOCATION_FAILED_MESSAGE);
|
|
11211
11219
|
} finally {
|
|
@@ -11224,16 +11232,6 @@ Known schemas:
|
|
|
11224
11232
|
this.testingShim?.dispatchToolChange();
|
|
11225
11233
|
});
|
|
11226
11234
|
}
|
|
11227
|
-
warnProvideContextDeprecationOnce() {
|
|
11228
|
-
if (this.provideContextDeprecationWarned) return;
|
|
11229
|
-
this.provideContextDeprecationWarned = true;
|
|
11230
|
-
console.warn("[WebMCPPolyfill] navigator.modelContext.provideContext() is deprecated and will be removed in the next major version. Register tools individually with registerTool() instead.");
|
|
11231
|
-
}
|
|
11232
|
-
warnClearContextDeprecationOnce() {
|
|
11233
|
-
if (this.clearContextDeprecationWarned) return;
|
|
11234
|
-
this.clearContextDeprecationWarned = true;
|
|
11235
|
-
console.warn("[WebMCPPolyfill] navigator.modelContext.clearContext() is deprecated and will be removed in the next major version. Unregister individual tools instead.");
|
|
11236
|
-
}
|
|
11237
11235
|
warnUnregisterToolDeprecationOnce() {
|
|
11238
11236
|
if (this.unregisterToolDeprecationWarned) return;
|
|
11239
11237
|
this.unregisterToolDeprecationWarned = true;
|
|
@@ -11346,34 +11344,34 @@ Known schemas:
|
|
|
11346
11344
|
}
|
|
11347
11345
|
throw new Error("Failed to convert Standard JSON Schema inputSchema to a JSON Schema object");
|
|
11348
11346
|
}
|
|
11349
|
-
function normalizeInputSchema(
|
|
11350
|
-
if (
|
|
11347
|
+
function normalizeInputSchema(inputSchema2) {
|
|
11348
|
+
if (inputSchema2 === void 0) {
|
|
11351
11349
|
const normalized = DEFAULT_INPUT_SCHEMA;
|
|
11352
11350
|
return {
|
|
11353
11351
|
inputSchema: normalized,
|
|
11354
11352
|
standardValidator: createStandardValidatorFromJsonSchema(normalized)
|
|
11355
11353
|
};
|
|
11356
11354
|
}
|
|
11357
|
-
if (isStandardInputJsonSchema(
|
|
11358
|
-
const converted = convertStandardInputSchema(
|
|
11355
|
+
if (isStandardInputJsonSchema(inputSchema2)) {
|
|
11356
|
+
const converted = convertStandardInputSchema(inputSchema2);
|
|
11359
11357
|
return {
|
|
11360
11358
|
inputSchema: converted,
|
|
11361
11359
|
standardValidator: createStandardValidatorFromJsonSchema(converted)
|
|
11362
11360
|
};
|
|
11363
11361
|
}
|
|
11364
|
-
if (isStandardInputValidatorSchema(
|
|
11362
|
+
if (isStandardInputValidatorSchema(inputSchema2)) return {
|
|
11365
11363
|
inputSchema: DEFAULT_INPUT_SCHEMA,
|
|
11366
|
-
standardValidator:
|
|
11364
|
+
standardValidator: inputSchema2
|
|
11367
11365
|
};
|
|
11368
|
-
validateInputSchema(
|
|
11369
|
-
if (Object.keys(
|
|
11366
|
+
validateInputSchema(inputSchema2);
|
|
11367
|
+
if (Object.keys(inputSchema2).length === 0) return {
|
|
11370
11368
|
inputSchema: DEFAULT_INPUT_SCHEMA,
|
|
11371
11369
|
standardValidator: createStandardValidatorFromJsonSchema(DEFAULT_INPUT_SCHEMA)
|
|
11372
11370
|
};
|
|
11373
|
-
const normalizedSchema =
|
|
11371
|
+
const normalizedSchema = inputSchema2.type === void 0 ? {
|
|
11374
11372
|
type: "object",
|
|
11375
|
-
...
|
|
11376
|
-
} :
|
|
11373
|
+
...inputSchema2
|
|
11374
|
+
} : inputSchema2;
|
|
11377
11375
|
return {
|
|
11378
11376
|
inputSchema: normalizedSchema,
|
|
11379
11377
|
standardValidator: createStandardValidatorFromJsonSchema(normalizedSchema)
|
|
@@ -11559,6 +11557,10 @@ Known schemas:
|
|
|
11559
11557
|
if (typeof navigator !== "undefined") return navigator;
|
|
11560
11558
|
return null;
|
|
11561
11559
|
}
|
|
11560
|
+
function getDocument() {
|
|
11561
|
+
if (typeof document !== "undefined") return document;
|
|
11562
|
+
return null;
|
|
11563
|
+
}
|
|
11562
11564
|
function defineNavigatorProperty(target, key, value) {
|
|
11563
11565
|
Object.defineProperty(target, key, {
|
|
11564
11566
|
configurable: true,
|
|
@@ -11567,37 +11569,90 @@ Known schemas:
|
|
|
11567
11569
|
value
|
|
11568
11570
|
});
|
|
11569
11571
|
}
|
|
11572
|
+
function defineDocumentModelContextProperty(target, value) {
|
|
11573
|
+
Object.defineProperty(target, "modelContext", {
|
|
11574
|
+
configurable: true,
|
|
11575
|
+
enumerable: true,
|
|
11576
|
+
writable: false,
|
|
11577
|
+
value
|
|
11578
|
+
});
|
|
11579
|
+
}
|
|
11580
|
+
var navigatorModelContextDeprecationWarned = false;
|
|
11581
|
+
function defineDeprecatedNavigatorModelContext(target, value) {
|
|
11582
|
+
Object.defineProperty(target, "modelContext", {
|
|
11583
|
+
configurable: true,
|
|
11584
|
+
enumerable: true,
|
|
11585
|
+
get() {
|
|
11586
|
+
if (!navigatorModelContextDeprecationWarned) {
|
|
11587
|
+
navigatorModelContextDeprecationWarned = true;
|
|
11588
|
+
console.warn("[WebMCPPolyfill] navigator.modelContext is deprecated. The May 27, 2026 WebMCP draft moved the modelContext getter from Navigator to Document \u2014 use document.modelContext instead. See https://github.com/webmachinelearning/webmcp/pull/184.");
|
|
11589
|
+
}
|
|
11590
|
+
return value;
|
|
11591
|
+
}
|
|
11592
|
+
});
|
|
11593
|
+
}
|
|
11570
11594
|
function initializeWebMCPPolyfill(options) {
|
|
11571
11595
|
const nav = getNavigator();
|
|
11572
|
-
|
|
11573
|
-
if (
|
|
11596
|
+
const doc = getDocument();
|
|
11597
|
+
if (!nav && !doc) return;
|
|
11598
|
+
const documentModelContext = doc?.modelContext;
|
|
11599
|
+
if (Boolean(documentModelContext)) return;
|
|
11600
|
+
const navigatorModelContext = nav?.modelContext;
|
|
11601
|
+
const hasNavigatorModelContext = Boolean(navigatorModelContext);
|
|
11574
11602
|
if (installState.installed) cleanupWebMCPPolyfill();
|
|
11603
|
+
if (doc && navigatorModelContext) {
|
|
11604
|
+
installState.previousDocumentModelContextDescriptor = Object.getOwnPropertyDescriptor(doc, "modelContext");
|
|
11605
|
+
defineDocumentModelContextProperty(doc, navigatorModelContext);
|
|
11606
|
+
installState.installedDocumentModelContext = true;
|
|
11607
|
+
installState.installed = true;
|
|
11608
|
+
return;
|
|
11609
|
+
}
|
|
11610
|
+
if (hasNavigatorModelContext) return;
|
|
11575
11611
|
const context = new StrictWebMCPContext();
|
|
11576
11612
|
const modelContext = context;
|
|
11577
11613
|
modelContext[POLYFILL_MARKER_PROPERTY] = true;
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11582
|
-
|
|
11583
|
-
if (
|
|
11614
|
+
if (doc) {
|
|
11615
|
+
installState.previousDocumentModelContextDescriptor = Object.getOwnPropertyDescriptor(doc, "modelContext");
|
|
11616
|
+
defineDocumentModelContextProperty(doc, modelContext);
|
|
11617
|
+
installState.installedDocumentModelContext = true;
|
|
11618
|
+
}
|
|
11619
|
+
if (nav) {
|
|
11620
|
+
installState.previousNavigatorModelContextDescriptor = Object.getOwnPropertyDescriptor(nav, "modelContext");
|
|
11621
|
+
installState.previousNavigatorModelContextTestingDescriptor = Object.getOwnPropertyDescriptor(nav, "modelContextTesting");
|
|
11622
|
+
navigatorModelContextDeprecationWarned = false;
|
|
11623
|
+
defineDeprecatedNavigatorModelContext(nav, modelContext);
|
|
11624
|
+
installState.installedNavigatorModelContext = true;
|
|
11625
|
+
const installTestingShim = options?.installTestingShim ?? "if-missing";
|
|
11626
|
+
const hasModelContextTesting = Boolean(nav.modelContextTesting);
|
|
11627
|
+
if (installTestingShim === "always" || (installTestingShim === true || installTestingShim === "if-missing") && !hasModelContextTesting) {
|
|
11628
|
+
defineNavigatorProperty(nav, "modelContextTesting", context.getTestingShim());
|
|
11629
|
+
installState.installedNavigatorModelContextTesting = true;
|
|
11630
|
+
}
|
|
11631
|
+
}
|
|
11584
11632
|
installState.installed = true;
|
|
11585
11633
|
}
|
|
11586
11634
|
function cleanupWebMCPPolyfill() {
|
|
11587
|
-
|
|
11588
|
-
|
|
11589
|
-
const restore = (key, previousDescriptor) => {
|
|
11635
|
+
if (!installState.installed) return;
|
|
11636
|
+
const restore = (target, key, previousDescriptor) => {
|
|
11590
11637
|
if (previousDescriptor) {
|
|
11591
|
-
Object.defineProperty(
|
|
11638
|
+
Object.defineProperty(target, key, previousDescriptor);
|
|
11592
11639
|
return;
|
|
11593
11640
|
}
|
|
11594
|
-
delete
|
|
11641
|
+
delete target[key];
|
|
11595
11642
|
};
|
|
11596
|
-
|
|
11597
|
-
|
|
11643
|
+
const nav = getNavigator();
|
|
11644
|
+
const doc = getDocument();
|
|
11645
|
+
if (doc && installState.installedDocumentModelContext) restore(doc, "modelContext", installState.previousDocumentModelContextDescriptor);
|
|
11646
|
+
if (nav && installState.installedNavigatorModelContext) restore(nav, "modelContext", installState.previousNavigatorModelContextDescriptor);
|
|
11647
|
+
if (nav && installState.installedNavigatorModelContextTesting) restore(nav, "modelContextTesting", installState.previousNavigatorModelContextTestingDescriptor);
|
|
11598
11648
|
installState.installed = false;
|
|
11599
|
-
installState.
|
|
11600
|
-
installState.
|
|
11649
|
+
installState.previousDocumentModelContextDescriptor = void 0;
|
|
11650
|
+
installState.previousNavigatorModelContextDescriptor = void 0;
|
|
11651
|
+
installState.previousNavigatorModelContextTestingDescriptor = void 0;
|
|
11652
|
+
installState.installedDocumentModelContext = false;
|
|
11653
|
+
installState.installedNavigatorModelContext = false;
|
|
11654
|
+
installState.installedNavigatorModelContextTesting = false;
|
|
11655
|
+
navigatorModelContextDeprecationWarned = false;
|
|
11601
11656
|
}
|
|
11602
11657
|
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
11603
11658
|
const options = window.__webMCPPolyfillOptions;
|
|
@@ -19551,7 +19606,7 @@ Known schemas:
|
|
|
19551
19606
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/external.js
|
|
19552
19607
|
config(en_default2());
|
|
19553
19608
|
|
|
19554
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.3_@cfworker+json-schema@4.1.1_hono@4.12.
|
|
19609
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.3_@cfworker+json-schema@4.1.1_hono@4.12.30_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
19555
19610
|
var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
19556
19611
|
var JSONRPC_VERSION = "2.0";
|
|
19557
19612
|
var AssertObjectSchema = custom2((v) => v !== null && (typeof v === "object" || typeof v === "function"));
|
|
@@ -22304,14 +22359,14 @@ Known schemas:
|
|
|
22304
22359
|
return combined;
|
|
22305
22360
|
};
|
|
22306
22361
|
|
|
22307
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.3_@cfworker+json-schema@4.1.1_hono@4.12.
|
|
22362
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.3_@cfworker+json-schema@4.1.1_hono@4.12.30_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
|
|
22308
22363
|
var import_ajv_formats = __toESM(require_dist(), 1);
|
|
22309
22364
|
|
|
22310
22365
|
// ../../node_modules/.pnpm/pkce-challenge@5.0.1/node_modules/pkce-challenge/dist/index.browser.js
|
|
22311
22366
|
var crypto2;
|
|
22312
22367
|
crypto2 = globalThis.crypto;
|
|
22313
22368
|
|
|
22314
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.3_@cfworker+json-schema@4.1.1_hono@4.12.
|
|
22369
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.3_@cfworker+json-schema@4.1.1_hono@4.12.30_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
|
|
22315
22370
|
var SafeUrlSchema = url().superRefine((val, ctx) => {
|
|
22316
22371
|
if (!URL.canParse(val)) {
|
|
22317
22372
|
ctx.addIssue({
|
|
@@ -22455,7 +22510,7 @@ Known schemas:
|
|
|
22455
22510
|
token_type_hint: string2().optional()
|
|
22456
22511
|
}).strip();
|
|
22457
22512
|
|
|
22458
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.3_@cfworker+json-schema@4.1.1_hono@4.12.
|
|
22513
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.3_@cfworker+json-schema@4.1.1_hono@4.12.30_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js
|
|
22459
22514
|
var OAuthError = class extends Error {
|
|
22460
22515
|
constructor(message, errorUri) {
|
|
22461
22516
|
super(message);
|
|
@@ -22550,7 +22605,7 @@ Known schemas:
|
|
|
22550
22605
|
[InvalidTargetError.errorCode]: InvalidTargetError
|
|
22551
22606
|
};
|
|
22552
22607
|
|
|
22553
|
-
// ../../node_modules/.pnpm/@opentiny+next@0.3.2_@cfworker+json-schema@4.1.1_hono@4.12.
|
|
22608
|
+
// ../../node_modules/.pnpm/@opentiny+next@0.3.2_@cfworker+json-schema@4.1.1_hono@4.12.30_zod@3.25.76/node_modules/@opentiny/next/index.js
|
|
22554
22609
|
var _0x4f2826 = _0xad7a;
|
|
22555
22610
|
(function(_0x5153c5, _0x3abbea) {
|
|
22556
22611
|
const _0x5f186f = _0xad7a, _0x3f8155 = _0xad7a, _0x5ad68c = _0x5153c5();
|
|
@@ -22874,25 +22929,13 @@ Known schemas:
|
|
|
22874
22929
|
}, _0x275e(_0x25fced, _0x3ae797);
|
|
22875
22930
|
}
|
|
22876
22931
|
|
|
22877
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.3_@cfworker+json-schema@4.1.1_hono@4.12.
|
|
22932
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.3_@cfworker+json-schema@4.1.1_hono@4.12.30_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
|
|
22878
22933
|
var COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
|
|
22879
22934
|
var McpZodTypeKind;
|
|
22880
22935
|
(function(McpZodTypeKind2) {
|
|
22881
22936
|
McpZodTypeKind2["Completable"] = "McpCompletable";
|
|
22882
22937
|
})(McpZodTypeKind || (McpZodTypeKind = {}));
|
|
22883
22938
|
|
|
22884
|
-
// ../next-sdk/utils/uuid.ts
|
|
22885
|
-
var randomUUID2 = () => {
|
|
22886
|
-
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
22887
|
-
return crypto.randomUUID();
|
|
22888
|
-
}
|
|
22889
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
22890
|
-
const r = Math.random() * 16 | 0;
|
|
22891
|
-
const v = c === "x" ? r : r & 3 | 8;
|
|
22892
|
-
return v.toString(16);
|
|
22893
|
-
});
|
|
22894
|
-
};
|
|
22895
|
-
|
|
22896
22939
|
// ../next-sdk/remoter/QrCode.ts
|
|
22897
22940
|
var import_qrcode = __toESM(require_browser(), 1);
|
|
22898
22941
|
|
|
@@ -22962,6 +23005,18 @@ Known schemas:
|
|
|
22962
23005
|
document.head.appendChild(style);
|
|
22963
23006
|
})();
|
|
22964
23007
|
|
|
23008
|
+
// ../next-sdk/utils/uuid.ts
|
|
23009
|
+
var randomUUID2 = () => {
|
|
23010
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
23011
|
+
return crypto.randomUUID();
|
|
23012
|
+
}
|
|
23013
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
23014
|
+
const r = Math.random() * 16 | 0;
|
|
23015
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
23016
|
+
return v.toString(16);
|
|
23017
|
+
});
|
|
23018
|
+
};
|
|
23019
|
+
|
|
22965
23020
|
// ../next-sdk/utils/env.ts
|
|
22966
23021
|
var isBrowser = () => {
|
|
22967
23022
|
return typeof window !== "undefined" && typeof navigator !== "undefined";
|
|
@@ -23364,9 +23419,9 @@ Known schemas:
|
|
|
23364
23419
|
}
|
|
23365
23420
|
var _registeredTools = /* @__PURE__ */ new Map();
|
|
23366
23421
|
function setupModelContextBridge() {
|
|
23367
|
-
if (typeof
|
|
23368
|
-
const
|
|
23369
|
-
const nativeCtx =
|
|
23422
|
+
if (typeof document === "undefined") return;
|
|
23423
|
+
const doc = document;
|
|
23424
|
+
const nativeCtx = doc.modelContext;
|
|
23370
23425
|
if (!nativeCtx || nativeCtx.__isNextSdkBridgeSetup) return;
|
|
23371
23426
|
if (isBrowser()) {
|
|
23372
23427
|
;
|
|
@@ -23375,9 +23430,15 @@ Known schemas:
|
|
|
23375
23430
|
const originalRegisterTool = nativeCtx.registerTool?.bind(nativeCtx);
|
|
23376
23431
|
const originalUnregisterTool = nativeCtx.unregisterTool?.bind(nativeCtx);
|
|
23377
23432
|
if (typeof originalRegisterTool === "function") {
|
|
23378
|
-
nativeCtx.registerTool = (config2) => {
|
|
23433
|
+
nativeCtx.registerTool = (config2, options) => {
|
|
23379
23434
|
const name = config2.name;
|
|
23380
23435
|
const toolConfig = { ...config2 };
|
|
23436
|
+
if (options?.signal) {
|
|
23437
|
+
options.signal.addEventListener("abort", () => {
|
|
23438
|
+
_registeredTools.delete(name);
|
|
23439
|
+
broadcastToolChange(MSG_TOOL_UNREGISTERED);
|
|
23440
|
+
});
|
|
23441
|
+
}
|
|
23381
23442
|
const routeConfig = toolConfig.routeConfig && typeof toolConfig.routeConfig === "object" && "route" in toolConfig.routeConfig ? toolConfig.routeConfig : null;
|
|
23382
23443
|
if (routeConfig) {
|
|
23383
23444
|
const normalizedRoute = normalizeRoute(routeConfig.route);
|
|
@@ -23393,23 +23454,24 @@ Known schemas:
|
|
|
23393
23454
|
inputSchema: config2.inputSchema
|
|
23394
23455
|
});
|
|
23395
23456
|
try {
|
|
23396
|
-
originalRegisterTool(toolConfig);
|
|
23457
|
+
originalRegisterTool(toolConfig, options);
|
|
23397
23458
|
broadcastToolChange(MSG_TOOL_REGISTERED);
|
|
23398
23459
|
} catch (err) {
|
|
23399
23460
|
_registeredTools.delete(name);
|
|
23400
23461
|
}
|
|
23401
23462
|
};
|
|
23402
23463
|
}
|
|
23403
|
-
|
|
23404
|
-
|
|
23405
|
-
|
|
23464
|
+
nativeCtx.unregisterTool = (name) => {
|
|
23465
|
+
try {
|
|
23466
|
+
if (typeof originalUnregisterTool === "function") {
|
|
23406
23467
|
originalUnregisterTool(name);
|
|
23407
|
-
_registeredTools.delete(name);
|
|
23408
|
-
broadcastToolChange(MSG_TOOL_UNREGISTERED);
|
|
23409
|
-
} catch (err) {
|
|
23410
23468
|
}
|
|
23411
|
-
}
|
|
23412
|
-
|
|
23469
|
+
} catch (err) {
|
|
23470
|
+
} finally {
|
|
23471
|
+
_registeredTools.delete(name);
|
|
23472
|
+
broadcastToolChange(MSG_TOOL_UNREGISTERED);
|
|
23473
|
+
}
|
|
23474
|
+
};
|
|
23413
23475
|
nativeCtx.__isNextSdkBridgeSetup = true;
|
|
23414
23476
|
}
|
|
23415
23477
|
|
|
@@ -23440,9 +23502,9 @@ Known schemas:
|
|
|
23440
23502
|
};
|
|
23441
23503
|
|
|
23442
23504
|
// query-loader:/home/runner/work/webmcp-sdk/webmcp-sdk/packages/next-sdk/page-tools/page-agent-prompt.md
|
|
23443
|
-
var page_agent_prompt_default = '## \u89D2\u8272\n\n\u4F60\u662F\u6D4F\u89C8\u5668\u9875\u9762\u7684\u64CD\u4F5C\u5DE5\u5177\uFF0C\u4F60\u62E5\u6709\u8BC6\u522B\u7F51\u9875\u5185\u5BB9\uFF0C\u70B9\u51FB\uFF0C\u586B\u5199\uFF0C\u9009\u62E9\u4E0B\u62C9\u6846\u548C\u6EDA\u52A8\u9875\u9762\u7B49\u529F\u80FD\u3002\n\n\u5728\u6267\u884C\u9875\u9762\u64CD\u4F5C\u4E4B\u524D\uFF0C\u4F60\u5FC5\u987B\u5148\u8C03\u7528`browserState`\u5DE5\u5177\u4E00\u6B21\uFF0C\u6839\u636E\u6700\u65B0\u7684\u7F51\u9875\u72B6\u6001\uFF0C\u518D\u8C03\u7528\u64CD\u4F5C\u52A8\u4F5C\uFF0C\u6BD4\u5982 \'click\',\'fill\',\'select\' \u7B49\u52A8\u4F5C\u3002\n\n<intro>\n\u4F60\u64C5\u957F\u4EE5\u4E0B\u4EFB\u52A1\uFF1A\n1. \u5BFC\u822A\u590D\u6742\u7F51\u7AD9\u5E76\u63D0\u53D6\u7CBE\u786E\u4FE1\u606F\n2. \u81EA\u52A8\u5316\u8868\u5355\u63D0\u4EA4\u548C\u4EA4\u4E92\u5F0F\u7F51\u9875\u64CD\u4F5C\n3. \u6536\u96C6\u548C\u4FDD\u5B58\u4FE1\u606F\n4. \u5728\u4EE3\u7406\u5FAA\u73AF\u4E2D\u6709\u6548\u8FD0\u884C\n5. \u9AD8\u6548\u6267\u884C\u591A\u6837\u5316\u7684\u7F51\u9875\u4EFB\u52A1\n</intro>\n\n<input>\n\u5728\u6BCF\u4E00\u6B65\uFF0C\u4F60\u7684\u8F93\u5165\u5C06\u5305\u62EC\uFF1A\n1. <agent_history>\uFF1A\u4E00\u4E2A\u6309\u65F6\u95F4\u987A\u5E8F\u6392\u5217\u7684\u4E8B\u4EF6\u6D41\uFF0C\u5305\u62EC\u4F60\u4E4B\u524D\u7684\u64CD\u4F5C\u53CA\u5176\u7ED3\u679C\u3002\n2. <agent_state>\uFF1A\u5F53\u524D\u7684 <user_request> \u548C <step_info>\u3002\n3. <browser_state>\uFF1A\u5F53\u524D URL\u3001\u9875\u9762\u6807\u9898\u3001\u53EF\u4EA4\u4E92\u5143\u7D20\u603B\u6570\u4EE5\u53CA\u8BED\u4E49\u5316 YAML \u6811\u3002\n</input>\n\n<browser_state>\n\n\u6D4F\u89C8\u5668\u72B6\u6001\u5305\u542B\u4EE5\u4E0B\u5185\u5BB9\uFF1A\n\n- url: \u5F53\u524D\u67E5\u770B\u9875\u9762\u7684 URL\u3002\n- title: \u5F53\u524D\u67E5\u770B\u9875\u9762\u7684\u6807\u9898\u3002\n- \u53EF\u4EA4\u4E92\u5143\u7D20\u603B\u6570\uFF1A\u5E26\u6709 `[ref=N]` \u6807\u8BB0\u7684\u5143\u7D20\u6570\u91CF\u3002\n- YAML \u6811\uFF1A\u9875\u9762\u7684\u8BED\u4E49\u5316\u7ED3\u6784\uFF0C\u683C\u5F0F\u5982\u4E0B\uFF1A\n\n```yaml\n- region:\n - main:\n - button [cursor=pointer] [ref=9]: \u4EA7\u54C1\u6587\u6863\n - button [selected] [cursor=pointer] [ref=47]: 40\u5143/\u6708 2\u6838CPU 2GB\u5185\u5B58\n - radio [checked] [cursor=pointer] [ref=53]: \u81EA\u52A8\u751F\u6210\u5BC6\u7801\n - button [cursor=pointer] [ref=74]: \u7ACB\u5373\u8D2D\u4E70\n```\n\n\u8282\u70B9\u683C\u5F0F\u8BF4\u660E\uFF1A\n- `- role [state1] [state2] [ref=N]: accessible name`\n- `role`\uFF1AARIA \u8BED\u4E49\u89D2\u8272\uFF08\u5982 button/link/radio/heading/list/listitem \u7B49\uFF09\n- `[state]`\uFF1A\u53EF\u9009\u72B6\u6001\u6807\u8BB0\uFF0C\u5982 `[checked]` `[selected]` `[disabled]` `[expanded]` `[cursor=pointer]`\n- `[ref=N]`\uFF1A\u53EF\u4EA4\u4E92\u5143\u7D20\u7684\u552F\u4E00\u64CD\u4F5C\u7D22\u5F15\uFF0C**\u53EA\u6709\u5E26 ref \u7684\u8282\u70B9\u624D\u80FD\u88AB\u64CD\u4F5C**\n- `accessible name`\uFF1A\u5143\u7D20\u7684\u8BED\u4E49\u5316\u540D\u79F0\uFF08\u901A\u8FC7 aria-label/aria-labelledby/innerText \u7B49\u8BA1\u7B97\u5F97\u51FA\uFF09\n- \u7F29\u8FDB\u8868\u793A\u7236\u5B50\u5173\u7CFB\n\n</browser_state>\n\n<browser_state_diff>\n\n\u5728\u4EA4\u4E92\u8FC7\u7A0B\u4E2D\uFF0C\u4E3A\u4E86\u63D0\u9AD8\u6548\u7387\u548C\u51CF\u5C11\u4E0A\u4E0B\u6587\u5360\u7528\uFF0C\u5DE5\u5177\u4F1A\u751F\u6210\u9875\u9762\u7684\u589E\u91CF\u5DEE\u5F02\uFF08Diff\uFF09\u4FE1\u606F\u3002\nDiff \u683C\u5F0F\u793A\u4F8B\u5982\u4E0B\uFF1A\n```diff\n- button [ref=9]: \u4EA7\u54C1\u6587\u6863\n+ button [ref=9]: \u4EA7\u54C1\u6587\u6863 (\u5DF2\u70B9\u51FB)\n```\n\u6216\u8005\uFF0C\u5F53\u9875\u9762\u7ED3\u6784\u53D1\u751F\u6539\u53D8\u65F6\uFF0C\u4F1A\u5C55\u793A\u65B0\u589E\u6216\u79FB\u9664\u7684\u8282\u70B9\u5DEE\u5F02\u3002\n\n### \u9875\u9762\u72B6\u6001\u83B7\u53D6\u56DB\u539F\u5219\uFF08\u91CD\u8981\uFF0C\u8BF7\u4E25\u683C\u9075\u5B88\uFF09\uFF1A\n\n> \u4E0E\u4E1A\u754C AI \u7F16\u8F91\u5668\uFF08Cursor / Windsurf\uFF09\u6309\u9700\u8BFB\u53D6\u6587\u4EF6\u800C\u975E\u5168\u91CF\u52A0\u8F7D\u7684\u7406\u5FF5\u5B8C\u5168\u4E00\u81F4\u2014\u2014**\u5148\u7CBE\u51C6\u641C\u7D22\uFF0C\u518D\u6309\u9700\u62C9\u53D6\u5168\u91CF**\uFF0C\u5C06\u53D1\u9001\u7ED9\u5927\u6A21\u578B\u7684 token \u964D\u81F3\u6700\u4F4E\u3002\n\n1. **\u6309\u5173\u952E\u8BCD\u7CBE\u51C6\u641C\u7D22\uFF08\u6700\u9AD8\u4F18\u5148\u7EA7\uFF09**\uFF1A\u5F53\u4F60\u5DF2\u77E5\u8981\u627E\u4EC0\u4E48\u7C7B\u578B\u7684\u5143\u7D20\uFF08\u5982\u6309\u94AE\u3001\u8F93\u5165\u6846\u3001\u7279\u5B9A\u540D\u79F0\u7684\u94FE\u63A5\uFF09\u65F6\uFF0C**\u4F18\u5148\u4F7F\u7528 `searchTree` \u52A8\u4F5C**\uFF0C\u4F20\u5165 role \u540D\u79F0\u3001\u5143\u7D20\u6587\u672C\u6216\u72B6\u6001\u5173\u952E\u8BCD\u641C\u7D22\u3002\u5B83\u53EA\u8FD4\u56DE\u547D\u4E2D\u884C\u548C\u4E0A\u4E0B\u6587\uFF0Ctoken \u6D88\u8017\u6BD4\u5168\u91CF\u6811\u51CF\u5C11 80%+ \u3002\n - \u793A\u4F8B\uFF1A\u67E5\u627E\u6240\u6709\u6309\u94AE \u2192 `{"action": "searchTree", "query": "button"}`\n - \u793A\u4F8B\uFF1A\u67E5\u627E\u542B"\u63D0\u4EA4"\u6587\u672C\u7684\u8282\u70B9 \u2192 `{"action": "searchTree", "query": "\u63D0\u4EA4"}`\n - \u793A\u4F8B\uFF1A\u67E5\u627E\u5DF2\u52FE\u9009\u7684\u590D\u9009\u6846 \u2192 `{"action": "searchTree", "query": "checked"}`\n - \u793A\u4F8B\uFF1A\u7CBE\u786E\u5B9A\u4F4D\u67D0\u4E2A ref \u2192 `{"action": "searchTree", "query": "#5"}`\n2. **\u9996\u6B21\u83B7\u53D6\u5168\u91CF**\uFF1A\u9996\u6B21\u8FDB\u5165\u9875\u9762\u3001\u9875\u9762\u53D1\u751F\u91CD\u5927\u5237\u65B0\u3001\u6216 `searchTree` \u65E0\u6CD5\u627E\u5230\u6240\u9700\u4FE1\u606F\u65F6\uFF0C\u8C03\u7528 `browserState` \u5E76\u6307\u5B9A `responseMode` \u4E3A `full` \u6216 `both` \u83B7\u53D6\u5B8C\u6574 A11y \u6811\u3002\n3. **\u589E\u91CF\u4F18\u5148**\uFF1A\u6267\u884C `click`\u3001`fill`\u3001`select`\u3001`scroll` \u64CD\u4F5C\u540E\uFF0C\u5DE5\u5177\u9ED8\u8BA4\u81EA\u52A8\u8FD4\u56DE `diff` \u589E\u91CF\u4FE1\u606F\u3002\u4F18\u5148\u9605\u8BFB\u8FD9\u4E9B Diff\uFF0C\u4EE5\u4FBF\u5FEB\u901F\u786E\u8BA4\u64CD\u4F5C\u662F\u5426\u751F\u6548\u3002\n4. **\u6309\u9700\u62C9\u53D6\u5168\u91CF**\uFF1A\u5982\u679C\u589E\u91CF Diff \u4E0D\u8DB3\u4EE5\u652F\u6301\u4E0B\u4E00\u6B65\u64CD\u4F5C\uFF0C\u6216\u9700\u8981\u5BFB\u627E\u4E0D\u5728 Diff \u4E2D\u7684 `[ref=N]` \u8282\u70B9\uFF0C\u4E14 `searchTree` \u4E5F\u65E0\u6CD5\u5B9A\u4F4D\u65F6\uFF0C\u518D\u663E\u5F0F\u8C03\u7528 `browserState` \u62C9\u53D6\u5B8C\u6574\u6811\u3002\n\n</browser_state_diff>\n\n\n\n<browser_rules>\n\u5728\u4F7F\u7528\u6D4F\u89C8\u5668\u548C\u6D4F\u89C8\u7F51\u9875\u65F6\u4E25\u683C\u9075\u5B88\u4EE5\u4E0B\u89C4\u5219\uFF1A\n\n- \u4EC5\u4E0E\u5206\u914D\u6709 `[ref=N]` \u7684\u5143\u7D20\u8FDB\u884C\u4EA4\u4E92\u3002\n- \u4EC5\u4F7F\u7528\u660E\u786E\u63D0\u4F9B\u7684 ref \u7D22\u5F15\u3002\n- \u6BCF\u6B21\u64CD\u4F5C\u540E ref \u7D22\u5F15\u4F1A\u91CD\u65B0\u5206\u914D\uFF0C\u4E0D\u8981\u4F7F\u7528\u65E7\u7684 ref \u7D22\u5F15\u3002\n- \u5982\u679C\u9875\u9762\u5728\u6267\u884C\u64CD\u4F5C\u540E\u53D1\u751F\u53D8\u5316\uFF08\u4F8B\u5982\u8F93\u5165\u6587\u672C\u64CD\u4F5C\uFF09\uFF0C\u5206\u6790\u662F\u5426\u9700\u8981\u4E0E\u65B0\u5143\u7D20\u8FDB\u884C\u4EA4\u4E92\uFF0C\u4F8B\u5982\u4ECE\u5217\u8868\u4E2D\u9009\u62E9\u6B63\u786E\u7684\u9009\u9879\u3002\n- \u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0C\u4EC5\u5217\u51FA\u53EF\u89C1\u89C6\u53E3\u4E2D\u7684\u5143\u7D20\u3002\u5982\u679C\u4F60\u6000\u7591\u9700\u8981\u4EA4\u4E92\u7684\u76F8\u5173\u5185\u5BB9\u5728\u5C4F\u5E55\u5916\uFF0C\u8BF7\u4F7F\u7528\u6EDA\u52A8\u64CD\u4F5C\u3002\u4EC5\u5728\u9875\u9762\u4E0B\u65B9\u6216\u4E0A\u65B9\u8FD8\u6709\u66F4\u591A\u50CF\u7D20\u65F6\u624D\u6EDA\u52A8\u3002\n- \u4F60\u53EF\u4EE5\u4F7F\u7528 num_pages \u53C2\u6570\u6EDA\u52A8\u7279\u5B9A\u9875\u6570\uFF08\u4F8B\u5982\uFF0C0.5 \u8868\u793A\u534A\u9875\uFF0C2.0 \u8868\u793A\u4E24\u9875\uFF09\u3002\n- \u5982\u679C\u51FA\u73B0\u9A8C\u8BC1\u7801\uFF0C\u544A\u8BC9\u7528\u6237\u4F60\u65E0\u6CD5\u89E3\u51B3\u9A8C\u8BC1\u7801\u3002\u5B8C\u6210\u4EFB\u52A1\u5E76\u8BF7\u7528\u6237\u89E3\u51B3\u5B83\u3002\n- \u5982\u679C\u7F3A\u5C11\u9884\u671F\u5143\u7D20\uFF0C\u5C1D\u8BD5\u6EDA\u52A8\u6216\u5BFC\u822A\u56DE\u9000\u3002\n- \u9664\u975E\u67D0\u4E9B\u6761\u4EF6\u53D1\u751F\u53D8\u5316\uFF0C\u5426\u5219\u4E0D\u8981\u91CD\u590D\u540C\u4E00\u64CD\u4F5C\u8D85\u8FC7 3 \u6B21\u3002\n- \u5982\u679C\u4F60\u5411\u8F93\u5165\u5B57\u6BB5\u586B\u5145\u6587\u672C\u4E14\u64CD\u4F5C\u5E8F\u5217\u88AB\u4E2D\u65AD\uFF0C\u901A\u5E38\u610F\u5473\u7740\u67D0\u4E9B\u5185\u5BB9\u53D1\u751F\u4E86\u53D8\u5316\uFF0C\u4F8B\u5982\u4E0B\u62C9\u5EFA\u8BAE\u5F39\u51FA\u3002\n- \u5982\u679C <user_request> \u5305\u542B\u7279\u5B9A\u7684\u9875\u9762\u4FE1\u606F\uFF0C\u5982\u4EA7\u54C1\u7C7B\u578B\u3001\u8BC4\u5206\u3001\u4EF7\u683C\u3001\u4F4D\u7F6E\u7B49\uFF0C\u5C1D\u8BD5\u5E94\u7528\u8FC7\u6EE4\u5668\u4EE5\u63D0\u9AD8\u6548\u7387\u3002\n- <user_request> \u662F\u6700\u7EC8\u76EE\u6807\u3002\u5982\u679C\u7528\u6237\u6307\u5B9A\u4E86\u660E\u786E\u7684\u6B65\u9AA4\uFF0C\u5B83\u4EEC\u59CB\u7EC8\u5177\u6709\u6700\u9AD8\u4F18\u5148\u7EA7\u3002\n- \u5982\u679C\u4F60\u5411\u5B57\u6BB5\u8F93\u5165\u6587\u672C\uFF0C\u53EF\u80FD\u9700\u8981\u6309\u56DE\u8F66\u952E\u3001\u70B9\u51FB\u641C\u7D22\u6309\u94AE\u6216\u4ECE\u4E0B\u62C9\u5217\u8868\u4E2D\u9009\u62E9\u4EE5\u5B8C\u6210\u64CD\u4F5C\u3002\n- \u5982\u679C\u4E0D\u9700\u8981\uFF0C\u4E0D\u8981\u767B\u5F55\u9875\u9762\u3002\u5982\u679C\u6CA1\u6709\u51ED\u636E\uFF0C\u4E0D\u8981\u767B\u5F55\u3002\n- \u6709\u4E24\u79CD\u7C7B\u578B\u7684\u4EFB\u52A1\uFF0C\u9996\u5148\u601D\u8003\u4F60\u6B63\u5728\u5904\u7406\u54EA\u79CD\u7C7B\u578B\u7684\u8BF7\u6C42\uFF1A\n\n1. \u975E\u5E38\u5177\u4F53\u7684\u9010\u6B65\u8BF4\u660E\uFF1A\n\n- \u975E\u5E38\u7CBE\u786E\u5730\u9075\u5FAA\u5B83\u4EEC\uFF0C\u4E0D\u8981\u8DF3\u8FC7\u6B65\u9AA4\u3002\u5C1D\u8BD5\u6309\u8981\u6C42\u5B8C\u6210\u6240\u6709\u5185\u5BB9\u3002\n\n2. \u5F00\u653E\u5F0F\u4EFB\u52A1\u3002\u81EA\u5DF1\u89C4\u5212\uFF0C\u5728\u5B9E\u73B0\u76EE\u6807\u65F6\u4FDD\u6301\u521B\u9020\u6027\u3002\n\n- \u5982\u679C\u5728\u5F00\u653E\u5F0F\u4EFB\u52A1\u4E2D\u9677\u5165\u56F0\u5883\uFF08\u4F8B\u5982\u767B\u5F55\u6216\u9A8C\u8BC1\u7801\uFF09\uFF0C\u53EF\u4EE5\u91CD\u65B0\u8BC4\u4F30\u4EFB\u52A1\u5E76\u5C1D\u8BD5\u66FF\u4EE3\u65B9\u6CD5\uFF0C\u4F8B\u5982\u6709\u65F6\u5373\u4F7F\u9875\u9762\u7684\u67D0\u4E9B\u90E8\u5206\u53EF\u8BBF\u95EE\u6216\u901A\u8FC7 Web \u641C\u7D22\u83B7\u53D6\u4E00\u4E9B\u4FE1\u606F\uFF0C\u4E5F\u4F1A\u610F\u5916\u5F39\u51FA\u767B\u5F55\u6846\u3002\n </browser_rules>\n\n<capability>\n- \u4F60\u53EA\u80FD\u5904\u7406\u5355\u9875\u5E94\u7528\u3002\u4E0D\u8981\u8DF3\u51FA\u5F53\u524D\u9875\u9762\u3002\n- \u5982\u679C\u94FE\u63A5\u5C06\u5728\u65B0\u9875\u9762\u4E2D\u6253\u5F00\uFF08\u4F8B\u5982\uFF0C<a target="_blank">\uFF09\uFF0C\u4E0D\u8981\u70B9\u51FB\u8BE5\u94FE\u63A5\u3002\n- \u4EFB\u52A1\u5931\u8D25\u662F\u53EF\u4EE5\u63A5\u53D7\u7684\u3002\n - \u7528\u6237\u53EF\u80FD\u662F\u9519\u7684\u3002\u5982\u679C\u7528\u6237\u7684\u8BF7\u6C42\u65E0\u6CD5\u5B9E\u73B0\u3001\u4E0D\u9002\u5F53\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u8DB3\u591F\u7684\u4FE1\u606F\u6216\u5DE5\u5177\u6765\u5B9E\u73B0\u5B83\u3002\u544A\u8BC9\u7528\u6237\u63D0\u51FA\u66F4\u597D\u7684\u8BF7\u6C42\u3002\n - \u7F51\u9875\u53EF\u80FD\u5DF2\u635F\u574F\u3002\u6240\u6709\u7F51\u9875\u6216\u5E94\u7528\u90FD\u6709 bug\u3002\u6709\u4E9B bug \u4F1A\u4F7F\u4F60\u7684\u5DE5\u4F5C\u53D8\u5F97\u56F0\u96BE\u3002\u9F13\u52B1\u4F60\u544A\u8BC9\u7528\u6237\u5F53\u524D\u9875\u9762\u7684\u95EE\u9898\u3002\u4F60\u7684\u53CD\u9988\uFF08\u5305\u62EC\u5931\u8D25\uFF09\u5BF9\u7528\u6237\u5F88\u6709\u4EF7\u503C\u3002\n - \u8FC7\u4E8E\u52AA\u529B\u53EF\u80FD\u6709\u5BB3\u3002\u6765\u56DE\u91CD\u590D\u67D0\u4E9B\u64CD\u4F5C\u6216\u5728\u77E5\u8BC6\u6709\u9650\u7684\u60C5\u51B5\u4E0B\u63A8\u52A8\u590D\u6742\u7A0B\u5E8F\u53EF\u80FD\u5BFC\u81F4\u4E0D\u826F\u7ED3\u679C\u548C\u6709\u5BB3\u526F\u4F5C\u7528\u3002\u7528\u6237\u5B81\u613F\u4F60\u4EE5\u5931\u8D25\u544A\u7EC8\u5B8C\u6210\u4EFB\u52A1\u3002\n- \u5982\u679C\u4F60\u5BF9\u5F53\u524D\u7F51\u9875\u6216\u4EFB\u52A1\u6CA1\u6709\u76F8\u5173\u77E5\u8BC6\u3002\u4F60\u5FC5\u987B\u8981\u6C42\u7528\u6237\u63D0\u4F9B\u5177\u4F53\u8BF4\u660E\u548C\u8BE6\u7EC6\u6B65\u9AA4\u3002\n</capability>\n\n<task_completion_rules>\n\u4F60\u5FC5\u987B\u5728\u4EE5\u4E0B\u60C5\u51B5\u65F6\u7ED3\u675F\u4EFB\u52A1\uFF1A\n\n- \u5F53\u4F60\u5B8C\u5168\u5B8C\u6210\u7528\u6237\u8BF7\u6C42\u65F6\u3002\n- \u5F53\u4F60\u611F\u5230\u56F0\u60D1\u6216\u65E0\u6CD5\u89E3\u51B3\u7528\u6237\u8BF7\u6C42\u65F6\u3002\u6216\u8005\u7528\u6237\u8BF7\u6C42\u4E0D\u6E05\u695A\u6216\u5305\u542B\u4E0D\u5F53\u5185\u5BB9\u3002\n- \u5982\u679C\u7EDD\u5BF9\u4E0D\u53EF\u80FD\u7EE7\u7EED\u3002\n\n</task_completion_rules>\n';
|
|
23505
|
+
var page_agent_prompt_default = '## \u89D2\u8272\n\n\u4F60\u662F\u6D4F\u89C8\u5668\u9875\u9762\u7684\u64CD\u4F5C\u5DE5\u5177\uFF0C\u4F60\u62E5\u6709\u8BC6\u522B\u7F51\u9875\u5185\u5BB9\uFF0C\u70B9\u51FB\uFF0C\u586B\u5199\uFF0C\u9009\u62E9\u4E0B\u62C9\u6846\u548C\u6EDA\u52A8\u9875\u9762\u7B49\u529F\u80FD\u3002\n\n\u5728\u6267\u884C\u9875\u9762\u64CD\u4F5C\u4E4B\u524D\uFF0C\u4F60\u5FC5\u987B\u5148\u8C03\u7528`browserState`\u5DE5\u5177\u4E00\u6B21\uFF0C\u6839\u636E\u6700\u65B0\u7684\u7F51\u9875\u72B6\u6001\uFF0C\u518D\u8C03\u7528\u64CD\u4F5C\u52A8\u4F5C\uFF0C\u6BD4\u5982 \'click\',\'fill\',\'select\' \u7B49\u52A8\u4F5C\u3002\n\n<intro>\n\u4F60\u64C5\u957F\u4EE5\u4E0B\u4EFB\u52A1\uFF1A\n1. \u5BFC\u822A\u590D\u6742\u7F51\u7AD9\u5E76\u63D0\u53D6\u7CBE\u786E\u4FE1\u606F\n2. \u81EA\u52A8\u5316\u8868\u5355\u63D0\u4EA4\u548C\u4EA4\u4E92\u5F0F\u7F51\u9875\u64CD\u4F5C\n3. \u6536\u96C6\u548C\u4FDD\u5B58\u4FE1\u606F\n4. \u5728\u4EE3\u7406\u5FAA\u73AF\u4E2D\u6709\u6548\u8FD0\u884C\n5. \u9AD8\u6548\u6267\u884C\u591A\u6837\u5316\u7684\u7F51\u9875\u4EFB\u52A1\n</intro>\n\n<input>\n\u5728\u6BCF\u4E00\u6B65\uFF0C\u4F60\u7684\u8F93\u5165\u5C06\u5305\u62EC\uFF1A\n1. <agent_history>\uFF1A\u4E00\u4E2A\u6309\u65F6\u95F4\u987A\u5E8F\u6392\u5217\u7684\u4E8B\u4EF6\u6D41\uFF0C\u5305\u62EC\u4F60\u4E4B\u524D\u7684\u64CD\u4F5C\u53CA\u5176\u7ED3\u679C\u3002\n2. <agent_state>\uFF1A\u5F53\u524D\u7684 <user_request> \u548C <step_info>\u3002\n3. <browser_state>\uFF1A\u5F53\u524D URL\u3001\u9875\u9762\u6807\u9898\u3001\u53EF\u4EA4\u4E92\u5143\u7D20\u603B\u6570\u4EE5\u53CA\u8BED\u4E49\u5316 YAML \u6811\u3002\n</input>\n\n<browser_state>\n\n\u6D4F\u89C8\u5668\u72B6\u6001\u5305\u542B\u4EE5\u4E0B\u5185\u5BB9\uFF1A\n\n- url: \u5F53\u524D\u67E5\u770B\u9875\u9762\u7684 URL\u3002\n- title: \u5F53\u524D\u67E5\u770B\u9875\u9762\u7684\u6807\u9898\u3002\n- \u53EF\u4EA4\u4E92\u5143\u7D20\u603B\u6570\uFF1A\u5E26\u6709 `#N` \u6807\u8BB0\u7684\u5143\u7D20\u6570\u91CF\u3002\n- YAML \u6811\uFF1A\u9875\u9762\u7684\u8BED\u4E49\u5316\u7ED3\u6784\uFF0C\u683C\u5F0F\u5982\u4E0B\uFF1A\n\n```yaml\n- region:\n - main:\n - button #9 [cursor=pointer] "\u4EA7\u54C1\u6587\u6863"\n - button #47 [selected] [cursor=pointer] "40\u5143/\u6708 2\u6838CPU 2GB\u5185\u5B58"\n - radio #53 [checked] [cursor=pointer] "\u81EA\u52A8\u751F\u6210\u5BC6\u7801"\n - button #74 [cursor=pointer] "\u7ACB\u5373\u8D2D\u4E70"\n - generic #6 [cf-uba="serviceList..Flexus\u4E91\u670D\u52A1"] "Flexus\u4E91\u670D\u52A1"\n```\n\n\u8282\u70B9\u683C\u5F0F\u8BF4\u660E\uFF1A\n- `- role #N [token1] [token2] "accessible name"`\n- `role`\uFF1AARIA \u8BED\u4E49\u89D2\u8272\uFF08\u5982 button/link/radio/heading/listitem/generic \u7B49\uFF09\n- `#N`\uFF1A\u53EF\u4EA4\u4E92\u5143\u7D20\u7684\u552F\u4E00\u64CD\u4F5C\u7D22\u5F15\uFF0C**\u53EA\u6709\u5E26 `#N` \u7684\u8282\u70B9\u624D\u80FD\u88AB\u64CD\u4F5C**\uFF0C\u64CD\u4F5C\u65F6\u5C06 N \u4F5C\u4E3A `index` \u53C2\u6570\u4F20\u5165\n- `[token]`\uFF1A\u53EF\u9009 token\uFF0C\u5305\u62EC\u72B6\u6001\u6807\u8BB0\uFF08\u5982 `[checked]` `[selected]` `[disabled]` `[cursor=pointer]`\uFF09\u548C\u5B9A\u5236\u5C5E\u6027\uFF08\u5982 `[cf-uba="..."]`\uFF09\n- `"accessible name"`\uFF1A\u5143\u7D20\u7684\u8BED\u4E49\u5316\u540D\u79F0\uFF0C**\u7528\u53CC\u5F15\u53F7\u5305\u88F9**\uFF08\u901A\u8FC7 aria-label/aria-labelledby/innerText \u7B49\u8BA1\u7B97\u5F97\u51FA\uFF09\uFF1B\u65E0\u540D\u79F0\u7684\u8282\u70B9\u6B64\u5B57\u6BB5\u7701\u7565\n- \u7F29\u8FDB\u8868\u793A\u7236\u5B50\u5173\u7CFB\n\n</browser_state>\n\n<responseMode>\n\n`page-agent-tool` \u652F\u6301 `responseMode` \u53C2\u6570\uFF0C\u7528\u4E8E\u63A7\u5236\u64CD\u4F5C\u540E\u8FD4\u56DE\u7684\u9875\u9762\u72B6\u6001\u5F62\u5F0F\uFF1A\n\n- **`diff`**\uFF08\u9ED8\u8BA4\uFF09\uFF1A\u4EC5\u8FD4\u56DE\u81EA\u4E0A\u4E00\u6B21\u72B6\u6001\u4EE5\u6765\u7684\u589E\u91CF DOM \u5DEE\u5F02\uFF0C\u6781\u5927\u8282\u7701 Token\u3002\n- **`full`**\uFF1A\u8FD4\u56DE\u5F53\u524D\u89C6\u53E3\u4E2D\u5B8C\u6574\u7684\u8BED\u4E49\u5316 ARIA YAML \u6811\u3002\n- **`both`**\uFF1A\u540C\u65F6\u8FD4\u56DE\u5168\u91CF\u6811\u548C\u589E\u91CF\u5DEE\u5F02\u3002\n\n\u6267\u884C `click`\u3001`fill`\u3001`select`\u3001`scroll` \u64CD\u4F5C\u540E\uFF0C\u5DE5\u5177\u9ED8\u8BA4\u81EA\u52A8\u4EE5 `diff` \u6A21\u5F0F\u8FD4\u56DE\u6700\u65B0\u9875\u9762\u72B6\u6001\uFF0C\u65E0\u9700\u518D\u6B21\u624B\u52A8\u8C03\u7528 `browserState`\u3002\n\n</responseMode>\n\n<browser_state_diff>\n\n\u5728\u4EA4\u4E92\u8FC7\u7A0B\u4E2D\uFF0C\u4E3A\u4E86\u63D0\u9AD8\u6548\u7387\u548C\u51CF\u5C11\u4E0A\u4E0B\u6587\u5360\u7528\uFF0C\u5DE5\u5177\u4F1A\u751F\u6210\u9875\u9762\u7684\u589E\u91CF\u5DEE\u5F02\uFF08Diff\uFF09\u4FE1\u606F\u3002\nDiff \u683C\u5F0F\u793A\u4F8B\u5982\u4E0B\uFF1A\n```diff\n- button #9: \u4EA7\u54C1\u6587\u6863\n+ button #9: \u4EA7\u54C1\u6587\u6863 (\u5DF2\u70B9\u51FB)\n```\n\u6216\u8005\uFF0C\u5F53\u9875\u9762\u7ED3\u6784\u53D1\u751F\u6539\u53D8\u65F6\uFF0C\u4F1A\u5C55\u793A\u65B0\u589E\u6216\u79FB\u9664\u7684\u8282\u70B9\u5DEE\u5F02\u3002\n\n### \u9875\u9762\u72B6\u6001\u83B7\u53D6\u56DB\u539F\u5219\uFF08\u91CD\u8981\uFF0C\u8BF7\u4E25\u683C\u9075\u5B88\uFF09\uFF1A\n\n> \u4E0E\u4E1A\u754C AI \u7F16\u8F91\u5668\uFF08Cursor / Windsurf\uFF09\u6309\u9700\u8BFB\u53D6\u6587\u4EF6\u800C\u975E\u5168\u91CF\u52A0\u8F7D\u7684\u7406\u5FF5\u5B8C\u5168\u4E00\u81F4\u2014\u2014**\u5148\u7CBE\u51C6\u641C\u7D22\uFF0C\u518D\u6309\u9700\u62C9\u53D6\u5168\u91CF**\uFF0C\u5C06\u53D1\u9001\u7ED9\u5927\u6A21\u578B\u7684 token \u964D\u81F3\u6700\u4F4E\u3002\n\n1. **\u6309\u5173\u952E\u8BCD\u7CBE\u51C6\u641C\u7D22\uFF08\u6700\u9AD8\u4F18\u5148\u7EA7\uFF09**\uFF1A\u5F53\u4F60\u5DF2\u77E5\u8981\u627E\u4EC0\u4E48\u7C7B\u578B\u7684\u5143\u7D20\uFF08\u5982\u6309\u94AE\u3001\u8F93\u5165\u6846\u3001\u7279\u5B9A\u540D\u79F0\u7684\u94FE\u63A5\uFF09\u65F6\uFF0C**\u4F18\u5148\u4F7F\u7528 `searchTree` \u52A8\u4F5C**\uFF0C\u4F20\u5165 role \u540D\u79F0\u3001\u5143\u7D20\u6587\u672C\u6216\u72B6\u6001\u5173\u952E\u8BCD\u641C\u7D22\u3002\u5B83\u53EA\u8FD4\u56DE\u547D\u4E2D\u884C\u548C\u4E0A\u4E0B\u6587\uFF0Ctoken \u6D88\u8017\u6BD4\u5168\u91CF\u6811\u51CF\u5C11 80%+\u3002\n - \u793A\u4F8B\uFF1A\u67E5\u627E\u6240\u6709\u6309\u94AE \u2192 `{"action": "searchTree", "query": "button"}`\n - \u793A\u4F8B\uFF1A\u67E5\u627E\u542B"\u63D0\u4EA4"\u6587\u672C\u7684\u8282\u70B9 \u2192 `{"action": "searchTree", "query": "\u63D0\u4EA4"}`\n - \u793A\u4F8B\uFF1A\u67E5\u627E\u5DF2\u52FE\u9009\u7684\u590D\u9009\u6846 \u2192 `{"action": "searchTree", "query": "checked"}`\n - \u793A\u4F8B\uFF1A\u7CBE\u786E\u5B9A\u4F4D\u67D0\u4E2A ref \u2192 `{"action": "searchTree", "query": "#5"}`\n2. **\u9996\u6B21\u83B7\u53D6\u5168\u91CF**\uFF1A\u9996\u6B21\u8FDB\u5165\u9875\u9762\u3001\u9875\u9762\u53D1\u751F\u91CD\u5927\u5237\u65B0\u3001\u6216 `searchTree` \u65E0\u6CD5\u627E\u5230\u6240\u9700\u4FE1\u606F\u65F6\uFF0C\u8C03\u7528 `browserState` \u5E76\u6307\u5B9A `responseMode` \u4E3A `full` \u6216 `both` \u83B7\u53D6\u5B8C\u6574 A11y \u6811\u3002\n3. **\u589E\u91CF\u4F18\u5148**\uFF1A\u6267\u884C `click`\u3001`fill`\u3001`select`\u3001`scroll` \u64CD\u4F5C\u540E\uFF0C\u5DE5\u5177\u9ED8\u8BA4\u81EA\u52A8\u8FD4\u56DE `diff` \u589E\u91CF\u4FE1\u606F\u3002\u4F18\u5148\u9605\u8BFB\u8FD9\u4E9B Diff\uFF0C\u4EE5\u4FBF\u5FEB\u901F\u786E\u8BA4\u64CD\u4F5C\u662F\u5426\u751F\u6548\u3002\n4. **\u6309\u9700\u62C9\u53D6\u5168\u91CF**\uFF1A\u5982\u679C\u589E\u91CF Diff \u4E0D\u8DB3\u4EE5\u652F\u6301\u4E0B\u4E00\u6B65\u64CD\u4F5C\uFF0C\u6216\u9700\u8981\u5BFB\u627E\u4E0D\u5728 Diff \u4E2D\u7684 `#N` \u8282\u70B9\uFF0C\u4E14 `searchTree` \u4E5F\u65E0\u6CD5\u5B9A\u4F4D\u65F6\uFF0C\u518D\u663E\u5F0F\u8C03\u7528 `browserState` \u62C9\u53D6\u5B8C\u6574\u6811\u3002\n\n</browser_state_diff>\n\n\n\n<browser_rules>\n\u5728\u4F7F\u7528\u6D4F\u89C8\u5668\u548C\u6D4F\u89C8\u7F51\u9875\u65F6\u4E25\u683C\u9075\u5B88\u4EE5\u4E0B\u89C4\u5219\uFF1A\n\n- \u4EC5\u4E0E\u5206\u914D\u6709 `#N` \u7D22\u5F15\u7684\u5143\u7D20\u8FDB\u884C\u4EA4\u4E92\uFF0C\u5C06 N \u4F5C\u4E3A `index` \u53C2\u6570\u4F20\u5165\u3002\n- \u4EC5\u4F7F\u7528\u660E\u786E\u51FA\u73B0\u5728\u6811\u4E2D\u7684 `#N` \u7D22\u5F15\uFF0C\u5207\u52FF\u731C\u6D4B\u6216\u6CBF\u7528\u8FC7\u671F\u7D22\u5F15\u3002\n- \u6BCF\u6B21\u64CD\u4F5C\u540E `#N` \u7D22\u5F15\u4F1A\u91CD\u65B0\u5206\u914D\uFF0C\u4E0D\u8981\u4F7F\u7528\u65E7\u7684\u7D22\u5F15\u3002\n- \u5982\u679C\u9875\u9762\u5728\u6267\u884C\u64CD\u4F5C\u540E\u53D1\u751F\u53D8\u5316\uFF08\u4F8B\u5982\u8F93\u5165\u6587\u672C\u64CD\u4F5C\uFF09\uFF0C\u5206\u6790\u662F\u5426\u9700\u8981\u4E0E\u65B0\u5143\u7D20\u8FDB\u884C\u4EA4\u4E92\uFF0C\u4F8B\u5982\u4ECE\u5217\u8868\u4E2D\u9009\u62E9\u6B63\u786E\u7684\u9009\u9879\u3002\n- \u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0C\u4EC5\u5217\u51FA\u53EF\u89C1\u89C6\u53E3\u4E2D\u7684\u5143\u7D20\u3002\u5982\u679C\u4F60\u6000\u7591\u9700\u8981\u4EA4\u4E92\u7684\u76F8\u5173\u5185\u5BB9\u5728\u5C4F\u5E55\u5916\uFF0C\u8BF7\u4F7F\u7528\u6EDA\u52A8\u64CD\u4F5C\u3002\u4EC5\u5728\u9875\u9762\u4E0B\u65B9\u6216\u4E0A\u65B9\u8FD8\u6709\u66F4\u591A\u50CF\u7D20\u65F6\u624D\u6EDA\u52A8\u3002\n- \u4F60\u53EF\u4EE5\u4F7F\u7528 num_pages \u53C2\u6570\u6EDA\u52A8\u7279\u5B9A\u9875\u6570\uFF08\u4F8B\u5982\uFF0C0.5 \u8868\u793A\u534A\u9875\uFF0C2.0 \u8868\u793A\u4E24\u9875\uFF09\u3002\n- \u5982\u679C\u51FA\u73B0\u9A8C\u8BC1\u7801\uFF0C\u544A\u8BC9\u7528\u6237\u4F60\u65E0\u6CD5\u89E3\u51B3\u9A8C\u8BC1\u7801\u3002\u5B8C\u6210\u4EFB\u52A1\u5E76\u8BF7\u7528\u6237\u89E3\u51B3\u5B83\u3002\n- \u5982\u679C\u7F3A\u5C11\u9884\u671F\u5143\u7D20\uFF0C\u5C1D\u8BD5\u6EDA\u52A8\u6216\u5BFC\u822A\u56DE\u9000\u3002\n- \u9664\u975E\u67D0\u4E9B\u6761\u4EF6\u53D1\u751F\u53D8\u5316\uFF0C\u5426\u5219\u4E0D\u8981\u91CD\u590D\u540C\u4E00\u64CD\u4F5C\u8D85\u8FC7 3 \u6B21\u3002\n- \u5982\u679C\u4F60\u5411\u8F93\u5165\u5B57\u6BB5\u586B\u5145\u6587\u672C\u4E14\u64CD\u4F5C\u5E8F\u5217\u88AB\u4E2D\u65AD\uFF0C\u901A\u5E38\u610F\u5473\u7740\u67D0\u4E9B\u5185\u5BB9\u53D1\u751F\u4E86\u53D8\u5316\uFF0C\u4F8B\u5982\u4E0B\u62C9\u5EFA\u8BAE\u5F39\u51FA\u3002\n- \u5982\u679C <user_request> \u5305\u542B\u7279\u5B9A\u7684\u9875\u9762\u4FE1\u606F\uFF0C\u5982\u4EA7\u54C1\u7C7B\u578B\u3001\u8BC4\u5206\u3001\u4EF7\u683C\u3001\u4F4D\u7F6E\u7B49\uFF0C\u5C1D\u8BD5\u5E94\u7528\u8FC7\u6EE4\u5668\u4EE5\u63D0\u9AD8\u6548\u7387\u3002\n- <user_request> \u662F\u6700\u7EC8\u76EE\u6807\u3002\u5982\u679C\u7528\u6237\u6307\u5B9A\u4E86\u660E\u786E\u7684\u6B65\u9AA4\uFF0C\u5B83\u4EEC\u59CB\u7EC8\u5177\u6709\u6700\u9AD8\u4F18\u5148\u7EA7\u3002\n- \u5982\u679C\u4F60\u5411\u5B57\u6BB5\u8F93\u5165\u6587\u672C\uFF0C\u53EF\u80FD\u9700\u8981\u6309\u56DE\u8F66\u952E\u3001\u70B9\u51FB\u641C\u7D22\u6309\u94AE\u6216\u4ECE\u4E0B\u62C9\u5217\u8868\u4E2D\u9009\u62E9\u4EE5\u5B8C\u6210\u64CD\u4F5C\u3002\n- **\u4E0D\u8981\u901A\u8FC7 executeJavascript \u5411\u9875\u9762\u63D2\u5165 DOM \u5143\u7D20**\uFF08\u5982\u521B\u5EFA div \u663E\u793A\u8C03\u8BD5\u4FE1\u606F\uFF09\u3002\u8FD9\u4F1A\u6C61\u67D3\u9875\u9762\u7ED3\u6784\u5E76\u5F71\u54CD\u540E\u7EED\u64CD\u4F5C\u3002\u5982\u9700\u8BFB\u53D6\u6570\u636E\uFF0C\u4F7F\u7528 return \u8BED\u53E5\u8FD4\u56DE\u7ED3\u679C\u5373\u53EF\u3002\n- \u5982\u679C\u64CD\u4F5C\u8FD4\u56DE\u4E2D\u51FA\u73B0 `[\u6821\u9A8C\u63D0\u793A]`\uFF0C\u8BF4\u660E\u9875\u9762\u6709\u8868\u5355\u6821\u9A8C\u9519\u8BEF\u672A\u901A\u8FC7\uFF0C\u8BF7\u5148\u6839\u636E\u63D0\u793A\u4FEE\u590D\u9519\u8BEF\u540E\u518D\u7EE7\u7EED\u64CD\u4F5C\u3002\n- \u5982\u679C\u64CD\u4F5C\u540E\u9875\u9762\u6CA1\u6709\u53D1\u751F\u9884\u671F\u53D8\u5316\uFF0C\u4F18\u5148\u68C0\u67E5\u662F\u5426\u6709 `[\u6821\u9A8C\u63D0\u793A]` \u6216 `[error]` token \u7684\u9519\u8BEF\u4FE1\u606F\uFF0C\u800C\u975E\u91CD\u590D\u64CD\u4F5C\u3002\n- \u5982\u679C\u4E0D\u9700\u8981\uFF0C\u4E0D\u8981\u767B\u5F55\u9875\u9762\u3002\u5982\u679C\u6CA1\u6709\u51ED\u636E\uFF0C\u4E0D\u8981\u767B\u5F55\u3002\n- \u6709\u4E24\u79CD\u7C7B\u578B\u7684\u4EFB\u52A1\uFF0C\u9996\u5148\u601D\u8003\u4F60\u6B63\u5728\u5904\u7406\u54EA\u79CD\u7C7B\u578B\u7684\u8BF7\u6C42\uFF1A\n\n1. \u975E\u5E38\u5177\u4F53\u7684\u9010\u6B65\u8BF4\u660E\uFF1A\n\n- \u975E\u5E38\u7CBE\u786E\u5730\u9075\u5FAA\u5B83\u4EEC\uFF0C\u4E0D\u8981\u8DF3\u8FC7\u6B65\u9AA4\u3002\u5C1D\u8BD5\u6309\u8981\u6C42\u5B8C\u6210\u6240\u6709\u5185\u5BB9\u3002\n\n2. \u5F00\u653E\u5F0F\u4EFB\u52A1\u3002\u81EA\u5DF1\u89C4\u5212\uFF0C\u5728\u5B9E\u73B0\u76EE\u6807\u65F6\u4FDD\u6301\u521B\u9020\u6027\u3002\n\n- \u5982\u679C\u5728\u5F00\u653E\u5F0F\u4EFB\u52A1\u4E2D\u9677\u5165\u56F0\u5883\uFF08\u4F8B\u5982\u767B\u5F55\u6216\u9A8C\u8BC1\u7801\uFF09\uFF0C\u53EF\u4EE5\u91CD\u65B0\u8BC4\u4F30\u4EFB\u52A1\u5E76\u5C1D\u8BD5\u66FF\u4EE3\u65B9\u6CD5\uFF0C\u4F8B\u5982\u6709\u65F6\u5373\u4F7F\u9875\u9762\u7684\u67D0\u4E9B\u90E8\u5206\u53EF\u8BBF\u95EE\u6216\u901A\u8FC7 Web \u641C\u7D22\u83B7\u53D6\u4E00\u4E9B\u4FE1\u606F\uFF0C\u4E5F\u4F1A\u610F\u5916\u5F39\u51FA\u767B\u5F55\u6846\u3002\n </browser_rules>\n\n<capability>\n- \u4F60\u53EA\u80FD\u5904\u7406\u5355\u9875\u5E94\u7528\u3002\u4E0D\u8981\u8DF3\u51FA\u5F53\u524D\u9875\u9762\u3002\n- \u5982\u679C\u94FE\u63A5\u5C06\u5728\u65B0\u9875\u9762\u4E2D\u6253\u5F00\uFF08\u4F8B\u5982\uFF0C<a target="_blank">\uFF09\uFF0C\u4E0D\u8981\u70B9\u51FB\u8BE5\u94FE\u63A5\u3002\n- \u4EFB\u52A1\u5931\u8D25\u662F\u53EF\u4EE5\u63A5\u53D7\u7684\u3002\n - \u7528\u6237\u53EF\u80FD\u662F\u9519\u7684\u3002\u5982\u679C\u7528\u6237\u7684\u8BF7\u6C42\u65E0\u6CD5\u5B9E\u73B0\u3001\u4E0D\u9002\u5F53\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u8DB3\u591F\u7684\u4FE1\u606F\u6216\u5DE5\u5177\u6765\u5B9E\u73B0\u5B83\u3002\u544A\u8BC9\u7528\u6237\u63D0\u51FA\u66F4\u597D\u7684\u8BF7\u6C42\u3002\n - \u7F51\u9875\u53EF\u80FD\u5DF2\u635F\u574F\u3002\u6240\u6709\u7F51\u9875\u6216\u5E94\u7528\u90FD\u6709 bug\u3002\u6709\u4E9B bug \u4F1A\u4F7F\u4F60\u7684\u5DE5\u4F5C\u53D8\u5F97\u56F0\u96BE\u3002\u9F13\u52B1\u4F60\u544A\u8BC9\u7528\u6237\u5F53\u524D\u9875\u9762\u7684\u95EE\u9898\u3002\u4F60\u7684\u53CD\u9988\uFF08\u5305\u62EC\u5931\u8D25\uFF09\u5BF9\u7528\u6237\u5F88\u6709\u4EF7\u503C\u3002\n - \u8FC7\u4E8E\u52AA\u529B\u53EF\u80FD\u6709\u5BB3\u3002\u6765\u56DE\u91CD\u590D\u67D0\u4E9B\u64CD\u4F5C\u6216\u5728\u77E5\u8BC6\u6709\u9650\u7684\u60C5\u51B5\u4E0B\u63A8\u52A8\u590D\u6742\u7A0B\u5E8F\u53EF\u80FD\u5BFC\u81F4\u4E0D\u826F\u7ED3\u679C\u548C\u6709\u5BB3\u526F\u4F5C\u7528\u3002\u7528\u6237\u5B81\u613F\u4F60\u4EE5\u5931\u8D25\u544A\u7EC8\u5B8C\u6210\u4EFB\u52A1\u3002\n- \u5982\u679C\u4F60\u5BF9\u5F53\u524D\u7F51\u9875\u6216\u4EFB\u52A1\u6CA1\u6709\u76F8\u5173\u77E5\u8BC6\u3002\u4F60\u5FC5\u987B\u8981\u6C42\u7528\u6237\u63D0\u4F9B\u5177\u4F53\u8BF4\u660E\u548C\u8BE6\u7EC6\u6B65\u9AA4\u3002\n</capability>\n\n<task_completion_rules>\n\u4F60\u5FC5\u987B\u5728\u4EE5\u4E0B\u60C5\u51B5\u65F6\u7ED3\u675F\u4EFB\u52A1\uFF1A\n\n- \u5F53\u4F60\u5B8C\u5168\u5B8C\u6210\u7528\u6237\u8BF7\u6C42\u65F6\u3002\n- \u5F53\u4F60\u611F\u5230\u56F0\u60D1\u6216\u65E0\u6CD5\u89E3\u51B3\u7528\u6237\u8BF7\u6C42\u65F6\u3002\u6216\u8005\u7528\u6237\u8BF7\u6C42\u4E0D\u6E05\u695A\u6216\u5305\u542B\u4E0D\u5F53\u5185\u5BB9\u3002\n- \u5982\u679C\u7EDD\u5BF9\u4E0D\u53EF\u80FD\u7EE7\u7EED\u3002\n\n</task_completion_rules>\n';
|
|
23444
23506
|
|
|
23445
|
-
// ../../node_modules/.pnpm/@page-agent+page-controller@1.
|
|
23507
|
+
// ../../node_modules/.pnpm/@page-agent+page-controller@1.12.1/node_modules/@page-agent/page-controller/dist/lib/page-controller.js
|
|
23446
23508
|
var __defProp2 = Object.defineProperty;
|
|
23447
23509
|
var __exportAll = (all, no_symbols) => {
|
|
23448
23510
|
let target = {};
|
|
@@ -23572,10 +23634,10 @@ Known schemas:
|
|
|
23572
23634
|
await waitFor(0.2);
|
|
23573
23635
|
}
|
|
23574
23636
|
async function inputTextElement(element, text) {
|
|
23575
|
-
const
|
|
23576
|
-
if (!isInputElement(element) && !isTextAreaElement(element) && !
|
|
23637
|
+
const isContentEditable3 = element.isContentEditable;
|
|
23638
|
+
if (!isInputElement(element) && !isTextAreaElement(element) && !isContentEditable3) throw new Error("Element is not an input, textarea, or contenteditable");
|
|
23577
23639
|
await clickElement(element);
|
|
23578
|
-
if (
|
|
23640
|
+
if (isContentEditable3) {
|
|
23579
23641
|
if (element.dispatchEvent(new InputEvent("beforeinput", {
|
|
23580
23642
|
bubbles: true,
|
|
23581
23643
|
cancelable: true,
|
|
@@ -23614,7 +23676,7 @@ Known schemas:
|
|
|
23614
23676
|
element.dispatchEvent(new Event("change", { bubbles: true }));
|
|
23615
23677
|
element.blur();
|
|
23616
23678
|
} else getNativeValueSetter(element).call(element, text);
|
|
23617
|
-
if (!
|
|
23679
|
+
if (!isContentEditable3) element.dispatchEvent(new Event("input", { bubbles: true }));
|
|
23618
23680
|
await waitFor(0.1);
|
|
23619
23681
|
blurLastClickedElement();
|
|
23620
23682
|
}
|
|
@@ -23840,7 +23902,7 @@ Known schemas:
|
|
|
23840
23902
|
}
|
|
23841
23903
|
const DOM_HASH_MAP = {};
|
|
23842
23904
|
const ID = { current: 0 };
|
|
23843
|
-
const
|
|
23905
|
+
const HIGHLIGHT_CONTAINER_ID2 = "playwright-highlight-container";
|
|
23844
23906
|
function highlightElement(element, index, parentIframe = null) {
|
|
23845
23907
|
if (!element) return index;
|
|
23846
23908
|
const overlays = [];
|
|
@@ -23849,10 +23911,10 @@ Known schemas:
|
|
|
23849
23911
|
let labelHeight = 16;
|
|
23850
23912
|
let cleanupFn = null;
|
|
23851
23913
|
try {
|
|
23852
|
-
let container = document.getElementById(
|
|
23914
|
+
let container = document.getElementById(HIGHLIGHT_CONTAINER_ID2);
|
|
23853
23915
|
if (!container) {
|
|
23854
23916
|
container = document.createElement("div");
|
|
23855
|
-
container.id =
|
|
23917
|
+
container.id = HIGHLIGHT_CONTAINER_ID2;
|
|
23856
23918
|
container.style.position = "fixed";
|
|
23857
23919
|
container.style.pointerEvents = "none";
|
|
23858
23920
|
container.style.top = "0";
|
|
@@ -23865,7 +23927,7 @@ Known schemas:
|
|
|
23865
23927
|
}
|
|
23866
23928
|
const rects = element.getClientRects();
|
|
23867
23929
|
if (!rects || rects.length === 0) return index;
|
|
23868
|
-
const
|
|
23930
|
+
const colors2 = [
|
|
23869
23931
|
"#FF0000",
|
|
23870
23932
|
"#00FF00",
|
|
23871
23933
|
"#0000FF",
|
|
@@ -23879,7 +23941,7 @@ Known schemas:
|
|
|
23879
23941
|
"#DC143C",
|
|
23880
23942
|
"#4682B4"
|
|
23881
23943
|
];
|
|
23882
|
-
let baseColor =
|
|
23944
|
+
let baseColor = colors2[index % colors2.length];
|
|
23883
23945
|
const backgroundColor = baseColor + Math.floor(highlightOpacity * 255).toString(16).padStart(2, "0");
|
|
23884
23946
|
baseColor = baseColor + Math.floor(highlightLabelOpacity * 255).toString(16).padStart(2, "0");
|
|
23885
23947
|
let iframeOffset = {
|
|
@@ -24462,8 +24524,8 @@ Known schemas:
|
|
|
24462
24524
|
return false;
|
|
24463
24525
|
}
|
|
24464
24526
|
function buildDomTree(node, parentIframe = null, isParentHighlighted = false) {
|
|
24465
|
-
if (!node || node.id ===
|
|
24466
|
-
if (!node || node.id ===
|
|
24527
|
+
if (!node || node.id === HIGHLIGHT_CONTAINER_ID2 || node.nodeType !== Node.ELEMENT_NODE && node.nodeType !== Node.TEXT_NODE) return null;
|
|
24528
|
+
if (!node || node.id === HIGHLIGHT_CONTAINER_ID2) return null;
|
|
24467
24529
|
if (node.dataset?.browserUseIgnore === "true" || node.dataset?.pageAgentIgnore === "true") return null;
|
|
24468
24530
|
if (node.getAttribute && node.getAttribute("aria-hidden") === "true") return null;
|
|
24469
24531
|
if (node === document.body) {
|
|
@@ -24931,8 +24993,8 @@ Known schemas:
|
|
|
24931
24993
|
initMask() {
|
|
24932
24994
|
if (this.maskReady !== null) return;
|
|
24933
24995
|
this.maskReady = (async () => {
|
|
24934
|
-
const { SimulatorMask:
|
|
24935
|
-
this.mask = new
|
|
24996
|
+
const { SimulatorMask: SimulatorMask3 } = await Promise.resolve().then(() => (init_SimulatorMask_BHVXyogh(), SimulatorMask_BHVXyogh_exports));
|
|
24997
|
+
this.mask = new SimulatorMask3();
|
|
24936
24998
|
})();
|
|
24937
24999
|
}
|
|
24938
25000
|
/**
|
|
@@ -25161,183 +25223,60 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
25161
25223
|
}
|
|
25162
25224
|
};
|
|
25163
25225
|
|
|
25164
|
-
//
|
|
25165
|
-
var
|
|
25166
|
-
|
|
25167
|
-
|
|
25168
|
-
|
|
25169
|
-
|
|
25170
|
-
|
|
25171
|
-
|
|
25172
|
-
|
|
25173
|
-
|
|
25174
|
-
|
|
25175
|
-
|
|
25176
|
-
|
|
25177
|
-
|
|
25178
|
-
|
|
25179
|
-
|
|
25180
|
-
|
|
25181
|
-
|
|
25182
|
-
|
|
25183
|
-
|
|
25184
|
-
|
|
25185
|
-
|
|
25186
|
-
|
|
25187
|
-
|
|
25188
|
-
|
|
25189
|
-
|
|
25190
|
-
|
|
25191
|
-
|
|
25192
|
-
|
|
25193
|
-
|
|
25194
|
-
|
|
25195
|
-
|
|
25196
|
-
|
|
25197
|
-
|
|
25198
|
-
|
|
25199
|
-
while (k < len) {
|
|
25200
|
-
kValue = items[k];
|
|
25201
|
-
if (mapFn) {
|
|
25202
|
-
A[k] = mapFn(kValue, k);
|
|
25203
|
-
} else {
|
|
25204
|
-
A[k] = kValue;
|
|
25205
|
-
}
|
|
25206
|
-
k += 1;
|
|
25207
|
-
}
|
|
25208
|
-
A.length = len;
|
|
25209
|
-
return A;
|
|
25210
|
-
}
|
|
25211
|
-
|
|
25212
|
-
// ../../node_modules/.pnpm/dom-accessibility-api@0.6.3/node_modules/dom-accessibility-api/dist/polyfills/SetLike.mjs
|
|
25213
|
-
function _typeof(o) {
|
|
25214
|
-
"@babel/helpers - typeof";
|
|
25215
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
25216
|
-
return typeof o2;
|
|
25217
|
-
} : function(o2) {
|
|
25218
|
-
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
25219
|
-
}, _typeof(o);
|
|
25220
|
-
}
|
|
25221
|
-
function _classCallCheck(instance, Constructor) {
|
|
25222
|
-
if (!(instance instanceof Constructor)) {
|
|
25223
|
-
throw new TypeError("Cannot call a class as a function");
|
|
25224
|
-
}
|
|
25225
|
-
}
|
|
25226
|
-
function _defineProperties(target, props) {
|
|
25227
|
-
for (var i = 0; i < props.length; i++) {
|
|
25228
|
-
var descriptor = props[i];
|
|
25229
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
25230
|
-
descriptor.configurable = true;
|
|
25231
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
25232
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
25233
|
-
}
|
|
25234
|
-
}
|
|
25235
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
25236
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
25237
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
25238
|
-
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
25239
|
-
return Constructor;
|
|
25240
|
-
}
|
|
25241
|
-
function _defineProperty(obj, key, value) {
|
|
25242
|
-
key = _toPropertyKey(key);
|
|
25243
|
-
if (key in obj) {
|
|
25244
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
25245
|
-
} else {
|
|
25246
|
-
obj[key] = value;
|
|
25247
|
-
}
|
|
25248
|
-
return obj;
|
|
25249
|
-
}
|
|
25250
|
-
function _toPropertyKey(arg) {
|
|
25251
|
-
var key = _toPrimitive(arg, "string");
|
|
25252
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
25253
|
-
}
|
|
25254
|
-
function _toPrimitive(input, hint) {
|
|
25255
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
25256
|
-
var prim = input[Symbol.toPrimitive];
|
|
25257
|
-
if (prim !== void 0) {
|
|
25258
|
-
var res = prim.call(input, hint || "default");
|
|
25259
|
-
if (_typeof(res) !== "object") return res;
|
|
25260
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
25261
|
-
}
|
|
25262
|
-
return (hint === "string" ? String : Number)(input);
|
|
25263
|
-
}
|
|
25264
|
-
var SetLike = /* @__PURE__ */ (function() {
|
|
25265
|
-
function SetLike2() {
|
|
25266
|
-
var items = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
25267
|
-
_classCallCheck(this, SetLike2);
|
|
25268
|
-
_defineProperty(this, "items", void 0);
|
|
25269
|
-
this.items = items;
|
|
25270
|
-
}
|
|
25271
|
-
_createClass(SetLike2, [{
|
|
25272
|
-
key: "add",
|
|
25273
|
-
value: function add(value) {
|
|
25274
|
-
if (this.has(value) === false) {
|
|
25275
|
-
this.items.push(value);
|
|
25276
|
-
}
|
|
25277
|
-
return this;
|
|
25278
|
-
}
|
|
25279
|
-
}, {
|
|
25280
|
-
key: "clear",
|
|
25281
|
-
value: function clear() {
|
|
25282
|
-
this.items = [];
|
|
25283
|
-
}
|
|
25284
|
-
}, {
|
|
25285
|
-
key: "delete",
|
|
25286
|
-
value: function _delete(value) {
|
|
25287
|
-
var previousLength = this.items.length;
|
|
25288
|
-
this.items = this.items.filter(function(item) {
|
|
25289
|
-
return item !== value;
|
|
25290
|
-
});
|
|
25291
|
-
return previousLength !== this.items.length;
|
|
25292
|
-
}
|
|
25293
|
-
}, {
|
|
25294
|
-
key: "forEach",
|
|
25295
|
-
value: function forEach(callbackfn) {
|
|
25296
|
-
var _this = this;
|
|
25297
|
-
this.items.forEach(function(item) {
|
|
25298
|
-
callbackfn(item, item, _this);
|
|
25299
|
-
});
|
|
25300
|
-
}
|
|
25301
|
-
}, {
|
|
25302
|
-
key: "has",
|
|
25303
|
-
value: function has(value) {
|
|
25304
|
-
return this.items.indexOf(value) !== -1;
|
|
25305
|
-
}
|
|
25306
|
-
}, {
|
|
25307
|
-
key: "size",
|
|
25308
|
-
get: function get() {
|
|
25309
|
-
return this.items.length;
|
|
25310
|
-
}
|
|
25311
|
-
}]);
|
|
25312
|
-
return SetLike2;
|
|
25313
|
-
})();
|
|
25314
|
-
var SetLike_default = typeof Set === "undefined" ? Set : SetLike;
|
|
25315
|
-
|
|
25316
|
-
// ../../node_modules/.pnpm/dom-accessibility-api@0.6.3/node_modules/dom-accessibility-api/dist/getRole.mjs
|
|
25317
|
-
function getLocalName(element) {
|
|
25318
|
-
var _element$localName;
|
|
25319
|
-
return (
|
|
25320
|
-
// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName
|
|
25321
|
-
(_element$localName = element.localName) !== null && _element$localName !== void 0 ? _element$localName : (
|
|
25322
|
-
// eslint-disable-next-line no-restricted-properties -- required for the fallback
|
|
25323
|
-
element.tagName.toLowerCase()
|
|
25324
|
-
)
|
|
25325
|
-
);
|
|
25326
|
-
}
|
|
25327
|
-
var localNameToRoleMappings = {
|
|
25226
|
+
// ../next-sdk/page-tools/a11y/constants.ts
|
|
25227
|
+
var DEFAULT_ERROR_SELECTORS = [
|
|
25228
|
+
'[role="alert"]',
|
|
25229
|
+
'[aria-invalid="true"]',
|
|
25230
|
+
".ti3-unifyvalid-error",
|
|
25231
|
+
".ti3-error",
|
|
25232
|
+
".ti-error",
|
|
25233
|
+
".lego-text-error",
|
|
25234
|
+
".lego-error",
|
|
25235
|
+
".el-form-item__error",
|
|
25236
|
+
".ant-form-item-explain-error",
|
|
25237
|
+
".is-invalid",
|
|
25238
|
+
".invalid-feedback",
|
|
25239
|
+
".ng-invalid",
|
|
25240
|
+
".error-msg",
|
|
25241
|
+
".error-message",
|
|
25242
|
+
".error-text",
|
|
25243
|
+
".field-error",
|
|
25244
|
+
".form-error",
|
|
25245
|
+
".is-error",
|
|
25246
|
+
".has-error",
|
|
25247
|
+
".validate-error",
|
|
25248
|
+
".valid-error"
|
|
25249
|
+
];
|
|
25250
|
+
var DEFAULT_WARNING_SELECTORS = [
|
|
25251
|
+
".ti3-warning",
|
|
25252
|
+
".ti-warning",
|
|
25253
|
+
".lego-text-warning",
|
|
25254
|
+
".warning-msg",
|
|
25255
|
+
".warning-text",
|
|
25256
|
+
".is-warning",
|
|
25257
|
+
".has-warning"
|
|
25258
|
+
];
|
|
25259
|
+
var TAG_ROLE_MAP = {
|
|
25260
|
+
a: "link",
|
|
25328
25261
|
article: "article",
|
|
25329
25262
|
aside: "complementary",
|
|
25330
25263
|
button: "button",
|
|
25264
|
+
caption: "caption",
|
|
25265
|
+
cell: "cell",
|
|
25266
|
+
checkbox: "checkbox",
|
|
25267
|
+
code: "code",
|
|
25268
|
+
columnheader: "columnheader",
|
|
25269
|
+
combobox: "combobox",
|
|
25331
25270
|
datalist: "listbox",
|
|
25332
25271
|
dd: "definition",
|
|
25333
25272
|
details: "group",
|
|
25334
25273
|
dialog: "dialog",
|
|
25335
25274
|
dt: "term",
|
|
25275
|
+
em: "emphasis",
|
|
25336
25276
|
fieldset: "group",
|
|
25337
25277
|
figure: "figure",
|
|
25338
|
-
// WARNING: Only with an accessible name
|
|
25339
|
-
form: "form",
|
|
25340
25278
|
footer: "contentinfo",
|
|
25279
|
+
form: "form",
|
|
25341
25280
|
h1: "heading",
|
|
25342
25281
|
h2: "heading",
|
|
25343
25282
|
h3: "heading",
|
|
@@ -25346,351 +25285,974 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
25346
25285
|
h6: "heading",
|
|
25347
25286
|
header: "banner",
|
|
25348
25287
|
hr: "separator",
|
|
25349
|
-
|
|
25350
|
-
|
|
25288
|
+
img: "img",
|
|
25289
|
+
input: "textbox",
|
|
25290
|
+
// 默认,具体 type 下面会覆盖
|
|
25351
25291
|
li: "listitem",
|
|
25352
|
-
|
|
25292
|
+
link: "link",
|
|
25353
25293
|
main: "main",
|
|
25294
|
+
mark: "mark",
|
|
25295
|
+
math: "math",
|
|
25354
25296
|
menu: "list",
|
|
25355
|
-
|
|
25297
|
+
menuitem: "menuitem",
|
|
25298
|
+
meter: "meter",
|
|
25299
|
+
nav: "navigation",
|
|
25356
25300
|
ol: "list",
|
|
25357
|
-
optgroup: "group",
|
|
25358
|
-
// WARNING: Only in certain context
|
|
25359
25301
|
option: "option",
|
|
25360
25302
|
output: "status",
|
|
25303
|
+
p: "paragraph",
|
|
25361
25304
|
progress: "progressbar",
|
|
25362
|
-
|
|
25305
|
+
rowheader: "rowheader",
|
|
25306
|
+
search: "search",
|
|
25363
25307
|
section: "region",
|
|
25308
|
+
select: "listbox",
|
|
25309
|
+
strong: "strong",
|
|
25364
25310
|
summary: "button",
|
|
25365
25311
|
table: "table",
|
|
25366
25312
|
tbody: "rowgroup",
|
|
25313
|
+
td: "cell",
|
|
25367
25314
|
textarea: "textbox",
|
|
25368
25315
|
tfoot: "rowgroup",
|
|
25369
|
-
// WARNING: Only in certain context
|
|
25370
|
-
td: "cell",
|
|
25371
25316
|
th: "columnheader",
|
|
25372
25317
|
thead: "rowgroup",
|
|
25318
|
+
time: "time",
|
|
25373
25319
|
tr: "row",
|
|
25374
25320
|
ul: "list"
|
|
25375
25321
|
};
|
|
25376
|
-
var
|
|
25377
|
-
|
|
25378
|
-
|
|
25379
|
-
|
|
25380
|
-
|
|
25381
|
-
|
|
25382
|
-
|
|
25383
|
-
|
|
25384
|
-
|
|
25385
|
-
|
|
25386
|
-
|
|
25387
|
-
|
|
25388
|
-
|
|
25322
|
+
var INPUT_TYPE_ROLE = {
|
|
25323
|
+
button: "button",
|
|
25324
|
+
checkbox: "checkbox",
|
|
25325
|
+
color: "textbox",
|
|
25326
|
+
email: "textbox",
|
|
25327
|
+
file: "textbox",
|
|
25328
|
+
image: "button",
|
|
25329
|
+
number: "spinbutton",
|
|
25330
|
+
radio: "radio",
|
|
25331
|
+
range: "slider",
|
|
25332
|
+
reset: "button",
|
|
25333
|
+
search: "searchbox",
|
|
25334
|
+
submit: "button",
|
|
25335
|
+
tel: "textbox",
|
|
25336
|
+
text: "textbox",
|
|
25337
|
+
url: "textbox"
|
|
25389
25338
|
};
|
|
25390
|
-
|
|
25391
|
-
|
|
25392
|
-
|
|
25393
|
-
|
|
25394
|
-
|
|
25395
|
-
|
|
25396
|
-
|
|
25397
|
-
|
|
25398
|
-
|
|
25399
|
-
|
|
25400
|
-
|
|
25401
|
-
|
|
25402
|
-
|
|
25403
|
-
|
|
25404
|
-
|
|
25405
|
-
|
|
25406
|
-
|
|
25407
|
-
|
|
25408
|
-
|
|
25409
|
-
|
|
25410
|
-
|
|
25411
|
-
|
|
25412
|
-
|
|
25413
|
-
"
|
|
25414
|
-
|
|
25415
|
-
|
|
25416
|
-
|
|
25339
|
+
|
|
25340
|
+
// ../../node_modules/.pnpm/tabbable@6.5.0/node_modules/tabbable/dist/index.esm.js
|
|
25341
|
+
var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "area[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"];
|
|
25342
|
+
var candidateSelector = /* @__PURE__ */ candidateSelectors.join(",");
|
|
25343
|
+
var NoElement = typeof Element === "undefined";
|
|
25344
|
+
var matches = NoElement ? function() {
|
|
25345
|
+
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
25346
|
+
var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
|
|
25347
|
+
var _element$getRootNode;
|
|
25348
|
+
return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
|
|
25349
|
+
} : function(element) {
|
|
25350
|
+
return element === null || element === void 0 ? void 0 : element.ownerDocument;
|
|
25351
|
+
};
|
|
25352
|
+
var isContentEditable = function isContentEditable2(node) {
|
|
25353
|
+
var _node$getAttribute2;
|
|
25354
|
+
var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable");
|
|
25355
|
+
return attValue === "" || attValue === "true";
|
|
25356
|
+
};
|
|
25357
|
+
var hasTabIndex = function hasTabIndex2(node) {
|
|
25358
|
+
return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
|
|
25359
|
+
};
|
|
25360
|
+
var getTabIndex = function getTabIndex2(node) {
|
|
25361
|
+
if (!node) {
|
|
25362
|
+
throw new Error("No node provided");
|
|
25363
|
+
}
|
|
25364
|
+
if (node.tabIndex < 0) {
|
|
25365
|
+
if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
|
|
25366
|
+
return 0;
|
|
25367
|
+
}
|
|
25368
|
+
}
|
|
25369
|
+
return node.tabIndex;
|
|
25370
|
+
};
|
|
25371
|
+
var isInput = function isInput2(node) {
|
|
25372
|
+
return node.tagName === "INPUT";
|
|
25373
|
+
};
|
|
25374
|
+
var isHiddenInput = function isHiddenInput2(node) {
|
|
25375
|
+
return isInput(node) && node.type === "hidden";
|
|
25376
|
+
};
|
|
25377
|
+
var isDetailsWithSummary = function isDetailsWithSummary2(node) {
|
|
25378
|
+
var r = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
|
|
25379
|
+
return child.tagName === "SUMMARY";
|
|
25417
25380
|
});
|
|
25418
|
-
|
|
25419
|
-
|
|
25420
|
-
|
|
25421
|
-
|
|
25422
|
-
|
|
25423
|
-
|
|
25424
|
-
if (explicitRole === null || presentationRoles.indexOf(explicitRole) !== -1) {
|
|
25425
|
-
var implicitRole = getImplicitRole(element);
|
|
25426
|
-
if (presentationRoles.indexOf(explicitRole || "") === -1 || ignorePresentationalRole(element, implicitRole || "")) {
|
|
25427
|
-
return implicitRole;
|
|
25381
|
+
return r;
|
|
25382
|
+
};
|
|
25383
|
+
var getCheckedRadio = function getCheckedRadio2(nodes, form) {
|
|
25384
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
25385
|
+
if (nodes[i].checked && nodes[i].form === form) {
|
|
25386
|
+
return nodes[i];
|
|
25428
25387
|
}
|
|
25429
25388
|
}
|
|
25430
|
-
|
|
25431
|
-
|
|
25432
|
-
|
|
25433
|
-
|
|
25434
|
-
if (mappedByTag !== void 0) {
|
|
25435
|
-
return mappedByTag;
|
|
25389
|
+
};
|
|
25390
|
+
var isTabbableRadio = function isTabbableRadio2(node) {
|
|
25391
|
+
if (!node.name) {
|
|
25392
|
+
return true;
|
|
25436
25393
|
}
|
|
25437
|
-
|
|
25438
|
-
|
|
25439
|
-
|
|
25440
|
-
|
|
25441
|
-
|
|
25442
|
-
|
|
25443
|
-
|
|
25444
|
-
|
|
25445
|
-
|
|
25446
|
-
|
|
25447
|
-
|
|
25448
|
-
|
|
25449
|
-
return
|
|
25450
|
-
case "input": {
|
|
25451
|
-
var _ref = element, type = _ref.type;
|
|
25452
|
-
switch (type) {
|
|
25453
|
-
case "button":
|
|
25454
|
-
case "image":
|
|
25455
|
-
case "reset":
|
|
25456
|
-
case "submit":
|
|
25457
|
-
return "button";
|
|
25458
|
-
case "checkbox":
|
|
25459
|
-
case "radio":
|
|
25460
|
-
return type;
|
|
25461
|
-
case "range":
|
|
25462
|
-
return "slider";
|
|
25463
|
-
case "email":
|
|
25464
|
-
case "tel":
|
|
25465
|
-
case "text":
|
|
25466
|
-
case "url":
|
|
25467
|
-
if (element.hasAttribute("list")) {
|
|
25468
|
-
return "combobox";
|
|
25469
|
-
}
|
|
25470
|
-
return "textbox";
|
|
25471
|
-
case "search":
|
|
25472
|
-
if (element.hasAttribute("list")) {
|
|
25473
|
-
return "combobox";
|
|
25474
|
-
}
|
|
25475
|
-
return "searchbox";
|
|
25476
|
-
case "number":
|
|
25477
|
-
return "spinbutton";
|
|
25478
|
-
default:
|
|
25479
|
-
return null;
|
|
25480
|
-
}
|
|
25394
|
+
var radioScope = node.form || getRootNode(node);
|
|
25395
|
+
var queryRadios = function queryRadios2(name) {
|
|
25396
|
+
return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
|
|
25397
|
+
};
|
|
25398
|
+
var radioSet;
|
|
25399
|
+
if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
|
|
25400
|
+
radioSet = queryRadios(window.CSS.escape(node.name));
|
|
25401
|
+
} else {
|
|
25402
|
+
try {
|
|
25403
|
+
radioSet = queryRadios(node.name);
|
|
25404
|
+
} catch (err) {
|
|
25405
|
+
console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
|
|
25406
|
+
return false;
|
|
25481
25407
|
}
|
|
25482
|
-
case "select":
|
|
25483
|
-
if (element.hasAttribute("multiple") || element.size > 1) {
|
|
25484
|
-
return "listbox";
|
|
25485
|
-
}
|
|
25486
|
-
return "combobox";
|
|
25487
25408
|
}
|
|
25488
|
-
|
|
25489
|
-
|
|
25490
|
-
|
|
25491
|
-
|
|
25492
|
-
|
|
25493
|
-
|
|
25494
|
-
|
|
25495
|
-
|
|
25409
|
+
var checked = getCheckedRadio(radioSet, node.form);
|
|
25410
|
+
return !checked || checked === node;
|
|
25411
|
+
};
|
|
25412
|
+
var isRadio = function isRadio2(node) {
|
|
25413
|
+
return isInput(node) && node.type === "radio";
|
|
25414
|
+
};
|
|
25415
|
+
var isNonTabbableRadio = function isNonTabbableRadio2(node) {
|
|
25416
|
+
return isRadio(node) && !isTabbableRadio(node);
|
|
25417
|
+
};
|
|
25418
|
+
var isNodeAttached = function isNodeAttached2(node) {
|
|
25419
|
+
var _nodeRoot;
|
|
25420
|
+
var nodeRoot = node && getRootNode(node);
|
|
25421
|
+
var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
|
|
25422
|
+
var attached = false;
|
|
25423
|
+
if (nodeRoot && nodeRoot !== node) {
|
|
25424
|
+
var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
|
|
25425
|
+
attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
|
|
25426
|
+
while (!attached && nodeRootHost) {
|
|
25427
|
+
var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
|
|
25428
|
+
nodeRoot = getRootNode(nodeRootHost);
|
|
25429
|
+
nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
|
|
25430
|
+
attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
|
|
25496
25431
|
}
|
|
25497
25432
|
}
|
|
25498
|
-
return
|
|
25499
|
-
}
|
|
25500
|
-
|
|
25501
|
-
|
|
25502
|
-
|
|
25503
|
-
|
|
25504
|
-
|
|
25505
|
-
|
|
25506
|
-
|
|
25507
|
-
|
|
25508
|
-
|
|
25509
|
-
|
|
25510
|
-
|
|
25511
|
-
|
|
25512
|
-
|
|
25513
|
-
|
|
25514
|
-
|
|
25515
|
-
|
|
25516
|
-
|
|
25517
|
-
|
|
25518
|
-
|
|
25519
|
-
|
|
25520
|
-
|
|
25521
|
-
|
|
25522
|
-
|
|
25523
|
-
}
|
|
25524
|
-
function safeWindow(node) {
|
|
25525
|
-
var _ref = node.ownerDocument === null ? node : node.ownerDocument, defaultView = _ref.defaultView;
|
|
25526
|
-
if (defaultView === null) {
|
|
25527
|
-
throw new TypeError("no window available");
|
|
25433
|
+
return attached;
|
|
25434
|
+
};
|
|
25435
|
+
var isZeroArea = function isZeroArea2(node) {
|
|
25436
|
+
var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
|
|
25437
|
+
return width === 0 && height === 0;
|
|
25438
|
+
};
|
|
25439
|
+
var isHidden = function isHidden2(node, _ref) {
|
|
25440
|
+
var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
|
|
25441
|
+
if (displayCheck === "full-native") {
|
|
25442
|
+
if ("checkVisibility" in node) {
|
|
25443
|
+
var visible = node.checkVisibility({
|
|
25444
|
+
// Checking opacity might be desirable for some use cases, but natively,
|
|
25445
|
+
// opacity zero elements _are_ focusable and tabbable.
|
|
25446
|
+
checkOpacity: false,
|
|
25447
|
+
opacityProperty: false,
|
|
25448
|
+
contentVisibilityAuto: true,
|
|
25449
|
+
visibilityProperty: true,
|
|
25450
|
+
// This is an alias for `visibilityProperty`. Contemporary browsers
|
|
25451
|
+
// support both. However, this alias has wider browser support (Chrome
|
|
25452
|
+
// >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
|
|
25453
|
+
// we include it anyway.
|
|
25454
|
+
checkVisibilityCSS: true
|
|
25455
|
+
});
|
|
25456
|
+
return !visible;
|
|
25457
|
+
}
|
|
25528
25458
|
}
|
|
25529
|
-
|
|
25530
|
-
|
|
25531
|
-
|
|
25532
|
-
|
|
25533
|
-
|
|
25534
|
-
|
|
25535
|
-
|
|
25536
|
-
|
|
25537
|
-
|
|
25538
|
-
|
|
25539
|
-
|
|
25540
|
-
|
|
25541
|
-
|
|
25542
|
-
|
|
25543
|
-
|
|
25544
|
-
|
|
25545
|
-
|
|
25546
|
-
|
|
25547
|
-
|
|
25548
|
-
|
|
25549
|
-
|
|
25550
|
-
|
|
25551
|
-
|
|
25552
|
-
|
|
25553
|
-
|
|
25554
|
-
|
|
25555
|
-
}).filter(
|
|
25556
|
-
function(element) {
|
|
25557
|
-
return element !== null;
|
|
25459
|
+
var _getComputedStyle = getComputedStyle(node), visibility = _getComputedStyle.visibility;
|
|
25460
|
+
if (visibility === "hidden" || visibility === "collapse") {
|
|
25461
|
+
return true;
|
|
25462
|
+
}
|
|
25463
|
+
var isDirectSummary = matches.call(node, "details>summary:first-of-type");
|
|
25464
|
+
var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
|
|
25465
|
+
if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
|
|
25466
|
+
return true;
|
|
25467
|
+
}
|
|
25468
|
+
if (!displayCheck || displayCheck === "full" || // full-native can run this branch when it falls through in case
|
|
25469
|
+
// Element#checkVisibility is unsupported
|
|
25470
|
+
displayCheck === "full-native" || displayCheck === "legacy-full") {
|
|
25471
|
+
if (typeof getShadowRoot === "function") {
|
|
25472
|
+
var originalNode = node;
|
|
25473
|
+
while (node) {
|
|
25474
|
+
var parentElement = node.parentElement;
|
|
25475
|
+
var rootNode = getRootNode(node);
|
|
25476
|
+
if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
|
|
25477
|
+
return isZeroArea(node);
|
|
25478
|
+
} else if (node.assignedSlot) {
|
|
25479
|
+
node = node.assignedSlot;
|
|
25480
|
+
} else if (!parentElement && rootNode !== node.ownerDocument) {
|
|
25481
|
+
node = rootNode.host;
|
|
25482
|
+
} else {
|
|
25483
|
+
node = parentElement;
|
|
25484
|
+
}
|
|
25558
25485
|
}
|
|
25559
|
-
|
|
25560
|
-
|
|
25486
|
+
node = originalNode;
|
|
25487
|
+
}
|
|
25488
|
+
if (isNodeAttached(node)) {
|
|
25489
|
+
return !node.getClientRects().length;
|
|
25490
|
+
}
|
|
25491
|
+
if (displayCheck !== "legacy-full") {
|
|
25492
|
+
return true;
|
|
25493
|
+
}
|
|
25494
|
+
} else if (displayCheck === "non-zero-area") {
|
|
25495
|
+
return isZeroArea(node);
|
|
25561
25496
|
}
|
|
25562
|
-
return
|
|
25563
|
-
}
|
|
25564
|
-
function
|
|
25565
|
-
if (
|
|
25566
|
-
|
|
25497
|
+
return false;
|
|
25498
|
+
};
|
|
25499
|
+
var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
|
|
25500
|
+
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
|
|
25501
|
+
var parentNode = node.parentElement;
|
|
25502
|
+
while (parentNode) {
|
|
25503
|
+
if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
|
|
25504
|
+
for (var i = 0; i < parentNode.children.length; i++) {
|
|
25505
|
+
var child = parentNode.children.item(i);
|
|
25506
|
+
if (child.tagName === "LEGEND") {
|
|
25507
|
+
return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
|
|
25508
|
+
}
|
|
25509
|
+
}
|
|
25510
|
+
return true;
|
|
25511
|
+
}
|
|
25512
|
+
parentNode = parentNode.parentElement;
|
|
25513
|
+
}
|
|
25567
25514
|
}
|
|
25568
25515
|
return false;
|
|
25569
|
-
}
|
|
25570
|
-
|
|
25571
|
-
|
|
25572
|
-
|
|
25573
|
-
return s.trim().replace(/\s\s+/g, " ");
|
|
25574
|
-
}
|
|
25575
|
-
function isHidden(node, getComputedStyleImplementation) {
|
|
25576
|
-
if (!isElement(node)) {
|
|
25516
|
+
};
|
|
25517
|
+
var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
|
|
25518
|
+
if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
|
|
25519
|
+
isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
|
|
25577
25520
|
return false;
|
|
25578
25521
|
}
|
|
25579
|
-
|
|
25580
|
-
|
|
25581
|
-
|
|
25582
|
-
|
|
25583
|
-
return style.getPropertyValue("display") === "none" || style.getPropertyValue("visibility") === "hidden";
|
|
25584
|
-
}
|
|
25585
|
-
function isControl(node) {
|
|
25586
|
-
return hasAnyConcreteRoles(node, ["button", "combobox", "listbox", "textbox"]) || hasAbstractRole(node, "range");
|
|
25587
|
-
}
|
|
25588
|
-
function hasAbstractRole(node, role) {
|
|
25589
|
-
if (!isElement(node)) {
|
|
25522
|
+
return true;
|
|
25523
|
+
};
|
|
25524
|
+
var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
|
|
25525
|
+
if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
|
|
25590
25526
|
return false;
|
|
25591
25527
|
}
|
|
25592
|
-
|
|
25593
|
-
|
|
25594
|
-
|
|
25595
|
-
|
|
25596
|
-
|
|
25528
|
+
return true;
|
|
25529
|
+
};
|
|
25530
|
+
var isTabbable = function isTabbable2(node, options) {
|
|
25531
|
+
options = options || {};
|
|
25532
|
+
if (!node) {
|
|
25533
|
+
throw new Error("No node provided");
|
|
25597
25534
|
}
|
|
25598
|
-
|
|
25599
|
-
|
|
25600
|
-
var elements = arrayFrom(element.querySelectorAll(selectors));
|
|
25601
|
-
queryIdRefs(element, "aria-owns").forEach(function(root) {
|
|
25602
|
-
elements.push.apply(elements, arrayFrom(root.querySelectorAll(selectors)));
|
|
25603
|
-
});
|
|
25604
|
-
return elements;
|
|
25605
|
-
}
|
|
25606
|
-
function querySelectedOptions(listbox) {
|
|
25607
|
-
if (isHTMLSelectElement(listbox)) {
|
|
25608
|
-
return listbox.selectedOptions || querySelectorAllSubtree(listbox, "[selected]");
|
|
25535
|
+
if (matches.call(node, candidateSelector) === false) {
|
|
25536
|
+
return false;
|
|
25609
25537
|
}
|
|
25610
|
-
return
|
|
25611
|
-
}
|
|
25612
|
-
|
|
25613
|
-
|
|
25614
|
-
|
|
25615
|
-
|
|
25616
|
-
|
|
25617
|
-
|
|
25618
|
-
function allowsNameFromContent(node) {
|
|
25619
|
-
return hasAnyConcreteRoles(node, ["button", "cell", "checkbox", "columnheader", "gridcell", "heading", "label", "legend", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "row", "rowheader", "switch", "tab", "tooltip", "treeitem"]);
|
|
25620
|
-
}
|
|
25621
|
-
function isDescendantOfNativeHostLanguageTextAlternativeElement(node) {
|
|
25622
|
-
return false;
|
|
25623
|
-
}
|
|
25624
|
-
function getValueOfTextbox(element) {
|
|
25625
|
-
if (isHTMLInputElement(element) || isHTMLTextAreaElement(element)) {
|
|
25626
|
-
return element.value;
|
|
25538
|
+
return isNodeMatchingSelectorTabbable(options, node);
|
|
25539
|
+
};
|
|
25540
|
+
|
|
25541
|
+
// ../next-sdk/page-tools/a11y/utils.ts
|
|
25542
|
+
function inferRole(el) {
|
|
25543
|
+
const explicit = el.getAttribute("role");
|
|
25544
|
+
if (explicit && explicit !== "presentation" && explicit !== "none") {
|
|
25545
|
+
return explicit;
|
|
25627
25546
|
}
|
|
25628
|
-
|
|
25629
|
-
|
|
25630
|
-
|
|
25631
|
-
|
|
25632
|
-
if (/^["'].*["']$/.test(content)) {
|
|
25633
|
-
return content.slice(1, -1);
|
|
25547
|
+
const tag = el.tagName.toLowerCase();
|
|
25548
|
+
if (tag === "input") {
|
|
25549
|
+
const inputType = el.type?.toLowerCase() ?? "text";
|
|
25550
|
+
return INPUT_TYPE_ROLE[inputType] ?? "textbox";
|
|
25634
25551
|
}
|
|
25635
|
-
return "";
|
|
25636
|
-
}
|
|
25637
|
-
function isLabelableElement(element) {
|
|
25638
|
-
var localName = getLocalName(element);
|
|
25639
|
-
return localName === "button" || localName === "input" && element.getAttribute("type") !== "hidden" || localName === "meter" || localName === "output" || localName === "progress" || localName === "select" || localName === "textarea";
|
|
25552
|
+
return TAG_ROLE_MAP[tag] ?? "generic";
|
|
25640
25553
|
}
|
|
25641
|
-
function
|
|
25642
|
-
|
|
25643
|
-
|
|
25644
|
-
|
|
25645
|
-
|
|
25646
|
-
|
|
25647
|
-
|
|
25648
|
-
|
|
25649
|
-
|
|
25650
|
-
|
|
25554
|
+
function getStateTokens(el, exposedAttributes, errorSelectors, warningSelectors) {
|
|
25555
|
+
const tokens = [];
|
|
25556
|
+
const aria = (k) => el.getAttribute(k);
|
|
25557
|
+
const ariaChecked = aria("aria-checked");
|
|
25558
|
+
if (ariaChecked === "true") {
|
|
25559
|
+
tokens.push("checked");
|
|
25560
|
+
} else if (ariaChecked === "false") {
|
|
25561
|
+
tokens.push("unchecked");
|
|
25562
|
+
} else {
|
|
25563
|
+
const elTag = el.tagName.toLowerCase();
|
|
25564
|
+
let nativeChecked;
|
|
25565
|
+
if (elTag === "input" && (el.type === "checkbox" || el.type === "radio")) {
|
|
25566
|
+
nativeChecked = el.checked;
|
|
25567
|
+
} else if (elTag === "label" && el.hasAttribute("for")) {
|
|
25568
|
+
const target = document.getElementById(el.getAttribute("for"));
|
|
25569
|
+
if (target instanceof HTMLInputElement && (target.type === "checkbox" || target.type === "radio")) {
|
|
25570
|
+
nativeChecked = target.checked;
|
|
25651
25571
|
}
|
|
25652
25572
|
}
|
|
25653
|
-
|
|
25654
|
-
|
|
25655
|
-
|
|
25656
|
-
function getControlOfLabel(label) {
|
|
25657
|
-
if (label.control !== void 0) {
|
|
25658
|
-
return label.control;
|
|
25573
|
+
if (nativeChecked !== void 0) {
|
|
25574
|
+
tokens.push(nativeChecked ? "checked" : "unchecked");
|
|
25575
|
+
}
|
|
25659
25576
|
}
|
|
25660
|
-
|
|
25661
|
-
|
|
25662
|
-
|
|
25577
|
+
if (aria("aria-selected") === "true") tokens.push("selected");
|
|
25578
|
+
const disabled = aria("aria-disabled") === "true" || el.disabled;
|
|
25579
|
+
if (disabled) tokens.push("disabled");
|
|
25580
|
+
const hasPopup = aria("aria-haspopup");
|
|
25581
|
+
if (hasPopup && hasPopup !== "false") tokens.push("hasPopup");
|
|
25582
|
+
if (aria("aria-expanded") === "true") tokens.push("expanded");
|
|
25583
|
+
const headingMatch = el.tagName.match(/^H([1-6])$/);
|
|
25584
|
+
if (headingMatch) tokens.push(`level=${headingMatch[1]}`);
|
|
25585
|
+
const ariaLevel = aria("aria-level");
|
|
25586
|
+
if (ariaLevel && !headingMatch) tokens.push(`level=${ariaLevel}`);
|
|
25587
|
+
try {
|
|
25588
|
+
const style = window.getComputedStyle(el);
|
|
25589
|
+
if (style.cursor === "pointer") tokens.push("cursor=pointer");
|
|
25590
|
+
} catch {
|
|
25663
25591
|
}
|
|
25664
|
-
|
|
25665
|
-
|
|
25666
|
-
|
|
25667
|
-
|
|
25668
|
-
|
|
25669
|
-
|
|
25592
|
+
const tag = el.tagName.toLowerCase();
|
|
25593
|
+
if (tag === "input" || tag === "textarea" || tag === "select") {
|
|
25594
|
+
const val = el.value;
|
|
25595
|
+
if (val !== void 0 && val !== "") {
|
|
25596
|
+
tokens.push(`value="${val}"`);
|
|
25597
|
+
}
|
|
25670
25598
|
}
|
|
25671
|
-
|
|
25672
|
-
|
|
25599
|
+
const valuenow = el.getAttribute("aria-valuenow");
|
|
25600
|
+
if (valuenow) {
|
|
25601
|
+
tokens.push(`valuenow="${valuenow}"`);
|
|
25673
25602
|
}
|
|
25674
|
-
if (
|
|
25675
|
-
|
|
25603
|
+
if (el.tagName.toLowerCase() === "a" && el.getAttribute("target") === "_blank") {
|
|
25604
|
+
tokens.push("opens-new-tab");
|
|
25605
|
+
}
|
|
25606
|
+
const cls = typeof el.className === "string" ? el.className : "";
|
|
25607
|
+
const ACTIVE_CLASS_PATTERNS = [
|
|
25608
|
+
"is-active",
|
|
25609
|
+
"isActive",
|
|
25610
|
+
"is-selected",
|
|
25611
|
+
"isSelected",
|
|
25612
|
+
"is-current",
|
|
25613
|
+
"isCurrent",
|
|
25614
|
+
"active-item",
|
|
25615
|
+
"activeItem",
|
|
25616
|
+
"tab-active",
|
|
25617
|
+
"tabActive",
|
|
25618
|
+
// 仅当作为独立 class 词或有连字符前缀时匹配 "active",避免误匹配 "interactive" 等
|
|
25619
|
+
/\bactive\b/,
|
|
25620
|
+
/\bselected\b/,
|
|
25621
|
+
/\bcurrent\b/
|
|
25622
|
+
];
|
|
25623
|
+
const hasActiveClass = ACTIVE_CLASS_PATTERNS.some(
|
|
25624
|
+
(p) => typeof p === "string" ? cls.split(/\s+/).includes(p) : p.test(cls)
|
|
25625
|
+
);
|
|
25626
|
+
const roleForActive = el.getAttribute("role") || el.tagName.toLowerCase();
|
|
25627
|
+
const roles = roleForActive.split(/\s+/);
|
|
25628
|
+
const isTabLike = roles.some((r) => ["button", "option", "a", "li", "generic"].includes(r) || r.startsWith("tab"));
|
|
25629
|
+
if (hasActiveClass && isTabLike && !tokens.includes("checked") && !tokens.includes("selected")) {
|
|
25630
|
+
tokens.push("active");
|
|
25631
|
+
}
|
|
25632
|
+
const errorSelector = Array.isArray(errorSelectors) ? errorSelectors.join(", ") : errorSelectors || DEFAULT_ERROR_SELECTORS.join(", ");
|
|
25633
|
+
const warningSelector = Array.isArray(warningSelectors) ? warningSelectors.join(", ") : warningSelectors || DEFAULT_WARNING_SELECTORS.join(", ");
|
|
25634
|
+
let errorAncestor = null;
|
|
25635
|
+
if (errorSelector) {
|
|
25636
|
+
try {
|
|
25637
|
+
errorAncestor = el.closest(errorSelector);
|
|
25638
|
+
} catch {
|
|
25639
|
+
}
|
|
25676
25640
|
}
|
|
25677
|
-
|
|
25678
|
-
|
|
25679
|
-
|
|
25680
|
-
|
|
25681
|
-
|
|
25682
|
-
|
|
25683
|
-
|
|
25684
|
-
|
|
25685
|
-
|
|
25641
|
+
if (errorAncestor) {
|
|
25642
|
+
tokens.push("error");
|
|
25643
|
+
} else {
|
|
25644
|
+
let warningAncestor = null;
|
|
25645
|
+
if (warningSelector) {
|
|
25646
|
+
try {
|
|
25647
|
+
warningAncestor = el.closest(warningSelector);
|
|
25648
|
+
} catch {
|
|
25649
|
+
}
|
|
25650
|
+
}
|
|
25651
|
+
if (warningAncestor) {
|
|
25652
|
+
tokens.push("warning");
|
|
25653
|
+
}
|
|
25686
25654
|
}
|
|
25687
|
-
|
|
25655
|
+
if (exposedAttributes) {
|
|
25656
|
+
for (const attr of exposedAttributes) {
|
|
25657
|
+
const val = el.getAttribute(attr);
|
|
25658
|
+
if (val !== null) {
|
|
25659
|
+
tokens.push(`${attr}="${val}"`);
|
|
25660
|
+
}
|
|
25661
|
+
}
|
|
25662
|
+
}
|
|
25663
|
+
return tokens;
|
|
25688
25664
|
}
|
|
25689
|
-
function
|
|
25690
|
-
|
|
25691
|
-
|
|
25692
|
-
|
|
25693
|
-
|
|
25665
|
+
function isHidden3(el) {
|
|
25666
|
+
if (el.getAttribute("aria-hidden") === "true") return true;
|
|
25667
|
+
if (el.hidden) return true;
|
|
25668
|
+
try {
|
|
25669
|
+
const style = window.getComputedStyle(el);
|
|
25670
|
+
if (style.display === "none" || style.visibility === "hidden") return true;
|
|
25671
|
+
if (style.opacity === "0") return true;
|
|
25672
|
+
const isClipX = style.overflowX !== "visible";
|
|
25673
|
+
const isClipY = style.overflowY !== "visible";
|
|
25674
|
+
if (parseFloat(style.width) === 0 && isClipX) return true;
|
|
25675
|
+
if (parseFloat(style.height) === 0 && isClipY) return true;
|
|
25676
|
+
} catch {
|
|
25677
|
+
}
|
|
25678
|
+
return false;
|
|
25679
|
+
}
|
|
25680
|
+
function collectDescendantText(el) {
|
|
25681
|
+
let text = "";
|
|
25682
|
+
const walk = (node) => {
|
|
25683
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
25684
|
+
text += (node.textContent ?? "") + " ";
|
|
25685
|
+
} else if (node.nodeType === Node.ELEMENT_NODE) {
|
|
25686
|
+
const element = node;
|
|
25687
|
+
if (isHidden3(element)) return;
|
|
25688
|
+
if (element !== el) {
|
|
25689
|
+
const tag = element.tagName.toLowerCase();
|
|
25690
|
+
const role = inferRole(element);
|
|
25691
|
+
const isInteractiveTag = ["button", "a", "input", "select", "textarea", "li", "option"].includes(tag);
|
|
25692
|
+
const isInteractiveRole = ["button", "link", "checkbox", "radio", "textbox", "listitem", "option", "combobox", "listbox"].includes(role);
|
|
25693
|
+
const isTrulyInteractive = isTabbable(element);
|
|
25694
|
+
let isCursorPointer = false;
|
|
25695
|
+
try {
|
|
25696
|
+
isCursorPointer = window.getComputedStyle(element).cursor === "pointer";
|
|
25697
|
+
} catch {
|
|
25698
|
+
}
|
|
25699
|
+
const isMeaningfullyInteractive = isTrulyInteractive && !(role === "generic" && !isCursorPointer);
|
|
25700
|
+
if (isMeaningfullyInteractive || isInteractiveTag || isInteractiveRole) {
|
|
25701
|
+
return;
|
|
25702
|
+
}
|
|
25703
|
+
}
|
|
25704
|
+
for (const child of Array.from(element.childNodes)) {
|
|
25705
|
+
walk(child);
|
|
25706
|
+
}
|
|
25707
|
+
}
|
|
25708
|
+
};
|
|
25709
|
+
walk(el);
|
|
25710
|
+
return text.trim().replace(/\s+/g, " ");
|
|
25711
|
+
}
|
|
25712
|
+
function getComposedChildren(el) {
|
|
25713
|
+
const source = el.shadowRoot ? el.shadowRoot.children : el.children;
|
|
25714
|
+
const result2 = [];
|
|
25715
|
+
for (const node of Array.from(source)) {
|
|
25716
|
+
if (node instanceof HTMLSlotElement) {
|
|
25717
|
+
const assigned = node.assignedElements({ flatten: true });
|
|
25718
|
+
result2.push(...assigned.length > 0 ? assigned : Array.from(node.children));
|
|
25719
|
+
} else {
|
|
25720
|
+
result2.push(node);
|
|
25721
|
+
}
|
|
25722
|
+
}
|
|
25723
|
+
return result2;
|
|
25724
|
+
}
|
|
25725
|
+
|
|
25726
|
+
// ../../node_modules/.pnpm/dom-accessibility-api@0.6.3/node_modules/dom-accessibility-api/dist/polyfills/array.from.mjs
|
|
25727
|
+
var toStr = Object.prototype.toString;
|
|
25728
|
+
function isCallable(fn) {
|
|
25729
|
+
return typeof fn === "function" || toStr.call(fn) === "[object Function]";
|
|
25730
|
+
}
|
|
25731
|
+
function toInteger(value) {
|
|
25732
|
+
var number4 = Number(value);
|
|
25733
|
+
if (isNaN(number4)) {
|
|
25734
|
+
return 0;
|
|
25735
|
+
}
|
|
25736
|
+
if (number4 === 0 || !isFinite(number4)) {
|
|
25737
|
+
return number4;
|
|
25738
|
+
}
|
|
25739
|
+
return (number4 > 0 ? 1 : -1) * Math.floor(Math.abs(number4));
|
|
25740
|
+
}
|
|
25741
|
+
var maxSafeInteger = Math.pow(2, 53) - 1;
|
|
25742
|
+
function toLength(value) {
|
|
25743
|
+
var len = toInteger(value);
|
|
25744
|
+
return Math.min(Math.max(len, 0), maxSafeInteger);
|
|
25745
|
+
}
|
|
25746
|
+
function arrayFrom(arrayLike, mapFn) {
|
|
25747
|
+
var C = Array;
|
|
25748
|
+
var items = Object(arrayLike);
|
|
25749
|
+
if (arrayLike == null) {
|
|
25750
|
+
throw new TypeError("Array.from requires an array-like object - not null or undefined");
|
|
25751
|
+
}
|
|
25752
|
+
if (typeof mapFn !== "undefined") {
|
|
25753
|
+
if (!isCallable(mapFn)) {
|
|
25754
|
+
throw new TypeError("Array.from: when provided, the second argument must be a function");
|
|
25755
|
+
}
|
|
25756
|
+
}
|
|
25757
|
+
var len = toLength(items.length);
|
|
25758
|
+
var A = isCallable(C) ? Object(new C(len)) : new Array(len);
|
|
25759
|
+
var k = 0;
|
|
25760
|
+
var kValue;
|
|
25761
|
+
while (k < len) {
|
|
25762
|
+
kValue = items[k];
|
|
25763
|
+
if (mapFn) {
|
|
25764
|
+
A[k] = mapFn(kValue, k);
|
|
25765
|
+
} else {
|
|
25766
|
+
A[k] = kValue;
|
|
25767
|
+
}
|
|
25768
|
+
k += 1;
|
|
25769
|
+
}
|
|
25770
|
+
A.length = len;
|
|
25771
|
+
return A;
|
|
25772
|
+
}
|
|
25773
|
+
|
|
25774
|
+
// ../../node_modules/.pnpm/dom-accessibility-api@0.6.3/node_modules/dom-accessibility-api/dist/polyfills/SetLike.mjs
|
|
25775
|
+
function _typeof(o) {
|
|
25776
|
+
"@babel/helpers - typeof";
|
|
25777
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
25778
|
+
return typeof o2;
|
|
25779
|
+
} : function(o2) {
|
|
25780
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
25781
|
+
}, _typeof(o);
|
|
25782
|
+
}
|
|
25783
|
+
function _classCallCheck(instance, Constructor) {
|
|
25784
|
+
if (!(instance instanceof Constructor)) {
|
|
25785
|
+
throw new TypeError("Cannot call a class as a function");
|
|
25786
|
+
}
|
|
25787
|
+
}
|
|
25788
|
+
function _defineProperties(target, props) {
|
|
25789
|
+
for (var i = 0; i < props.length; i++) {
|
|
25790
|
+
var descriptor = props[i];
|
|
25791
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
25792
|
+
descriptor.configurable = true;
|
|
25793
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
25794
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
25795
|
+
}
|
|
25796
|
+
}
|
|
25797
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
25798
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
25799
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
25800
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
25801
|
+
return Constructor;
|
|
25802
|
+
}
|
|
25803
|
+
function _defineProperty(obj, key, value) {
|
|
25804
|
+
key = _toPropertyKey(key);
|
|
25805
|
+
if (key in obj) {
|
|
25806
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
25807
|
+
} else {
|
|
25808
|
+
obj[key] = value;
|
|
25809
|
+
}
|
|
25810
|
+
return obj;
|
|
25811
|
+
}
|
|
25812
|
+
function _toPropertyKey(arg) {
|
|
25813
|
+
var key = _toPrimitive(arg, "string");
|
|
25814
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
25815
|
+
}
|
|
25816
|
+
function _toPrimitive(input, hint) {
|
|
25817
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
25818
|
+
var prim = input[Symbol.toPrimitive];
|
|
25819
|
+
if (prim !== void 0) {
|
|
25820
|
+
var res = prim.call(input, hint || "default");
|
|
25821
|
+
if (_typeof(res) !== "object") return res;
|
|
25822
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
25823
|
+
}
|
|
25824
|
+
return (hint === "string" ? String : Number)(input);
|
|
25825
|
+
}
|
|
25826
|
+
var SetLike = /* @__PURE__ */ (function() {
|
|
25827
|
+
function SetLike2() {
|
|
25828
|
+
var items = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
25829
|
+
_classCallCheck(this, SetLike2);
|
|
25830
|
+
_defineProperty(this, "items", void 0);
|
|
25831
|
+
this.items = items;
|
|
25832
|
+
}
|
|
25833
|
+
_createClass(SetLike2, [{
|
|
25834
|
+
key: "add",
|
|
25835
|
+
value: function add(value) {
|
|
25836
|
+
if (this.has(value) === false) {
|
|
25837
|
+
this.items.push(value);
|
|
25838
|
+
}
|
|
25839
|
+
return this;
|
|
25840
|
+
}
|
|
25841
|
+
}, {
|
|
25842
|
+
key: "clear",
|
|
25843
|
+
value: function clear() {
|
|
25844
|
+
this.items = [];
|
|
25845
|
+
}
|
|
25846
|
+
}, {
|
|
25847
|
+
key: "delete",
|
|
25848
|
+
value: function _delete(value) {
|
|
25849
|
+
var previousLength = this.items.length;
|
|
25850
|
+
this.items = this.items.filter(function(item) {
|
|
25851
|
+
return item !== value;
|
|
25852
|
+
});
|
|
25853
|
+
return previousLength !== this.items.length;
|
|
25854
|
+
}
|
|
25855
|
+
}, {
|
|
25856
|
+
key: "forEach",
|
|
25857
|
+
value: function forEach(callbackfn) {
|
|
25858
|
+
var _this = this;
|
|
25859
|
+
this.items.forEach(function(item) {
|
|
25860
|
+
callbackfn(item, item, _this);
|
|
25861
|
+
});
|
|
25862
|
+
}
|
|
25863
|
+
}, {
|
|
25864
|
+
key: "has",
|
|
25865
|
+
value: function has(value) {
|
|
25866
|
+
return this.items.indexOf(value) !== -1;
|
|
25867
|
+
}
|
|
25868
|
+
}, {
|
|
25869
|
+
key: "size",
|
|
25870
|
+
get: function get() {
|
|
25871
|
+
return this.items.length;
|
|
25872
|
+
}
|
|
25873
|
+
}]);
|
|
25874
|
+
return SetLike2;
|
|
25875
|
+
})();
|
|
25876
|
+
var SetLike_default = typeof Set === "undefined" ? Set : SetLike;
|
|
25877
|
+
|
|
25878
|
+
// ../../node_modules/.pnpm/dom-accessibility-api@0.6.3/node_modules/dom-accessibility-api/dist/getRole.mjs
|
|
25879
|
+
function getLocalName(element) {
|
|
25880
|
+
var _element$localName;
|
|
25881
|
+
return (
|
|
25882
|
+
// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName
|
|
25883
|
+
(_element$localName = element.localName) !== null && _element$localName !== void 0 ? _element$localName : (
|
|
25884
|
+
// eslint-disable-next-line no-restricted-properties -- required for the fallback
|
|
25885
|
+
element.tagName.toLowerCase()
|
|
25886
|
+
)
|
|
25887
|
+
);
|
|
25888
|
+
}
|
|
25889
|
+
var localNameToRoleMappings = {
|
|
25890
|
+
article: "article",
|
|
25891
|
+
aside: "complementary",
|
|
25892
|
+
button: "button",
|
|
25893
|
+
datalist: "listbox",
|
|
25894
|
+
dd: "definition",
|
|
25895
|
+
details: "group",
|
|
25896
|
+
dialog: "dialog",
|
|
25897
|
+
dt: "term",
|
|
25898
|
+
fieldset: "group",
|
|
25899
|
+
figure: "figure",
|
|
25900
|
+
// WARNING: Only with an accessible name
|
|
25901
|
+
form: "form",
|
|
25902
|
+
footer: "contentinfo",
|
|
25903
|
+
h1: "heading",
|
|
25904
|
+
h2: "heading",
|
|
25905
|
+
h3: "heading",
|
|
25906
|
+
h4: "heading",
|
|
25907
|
+
h5: "heading",
|
|
25908
|
+
h6: "heading",
|
|
25909
|
+
header: "banner",
|
|
25910
|
+
hr: "separator",
|
|
25911
|
+
html: "document",
|
|
25912
|
+
legend: "legend",
|
|
25913
|
+
li: "listitem",
|
|
25914
|
+
math: "math",
|
|
25915
|
+
main: "main",
|
|
25916
|
+
menu: "list",
|
|
25917
|
+
nav: "navigation",
|
|
25918
|
+
ol: "list",
|
|
25919
|
+
optgroup: "group",
|
|
25920
|
+
// WARNING: Only in certain context
|
|
25921
|
+
option: "option",
|
|
25922
|
+
output: "status",
|
|
25923
|
+
progress: "progressbar",
|
|
25924
|
+
// WARNING: Only with an accessible name
|
|
25925
|
+
section: "region",
|
|
25926
|
+
summary: "button",
|
|
25927
|
+
table: "table",
|
|
25928
|
+
tbody: "rowgroup",
|
|
25929
|
+
textarea: "textbox",
|
|
25930
|
+
tfoot: "rowgroup",
|
|
25931
|
+
// WARNING: Only in certain context
|
|
25932
|
+
td: "cell",
|
|
25933
|
+
th: "columnheader",
|
|
25934
|
+
thead: "rowgroup",
|
|
25935
|
+
tr: "row",
|
|
25936
|
+
ul: "list"
|
|
25937
|
+
};
|
|
25938
|
+
var prohibitedAttributes = {
|
|
25939
|
+
caption: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]),
|
|
25940
|
+
code: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]),
|
|
25941
|
+
deletion: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]),
|
|
25942
|
+
emphasis: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]),
|
|
25943
|
+
generic: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby", "aria-roledescription"]),
|
|
25944
|
+
insertion: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]),
|
|
25945
|
+
none: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]),
|
|
25946
|
+
paragraph: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]),
|
|
25947
|
+
presentation: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]),
|
|
25948
|
+
strong: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]),
|
|
25949
|
+
subscript: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]),
|
|
25950
|
+
superscript: /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"])
|
|
25951
|
+
};
|
|
25952
|
+
function hasGlobalAriaAttributes(element, role) {
|
|
25953
|
+
return [
|
|
25954
|
+
"aria-atomic",
|
|
25955
|
+
"aria-busy",
|
|
25956
|
+
"aria-controls",
|
|
25957
|
+
"aria-current",
|
|
25958
|
+
"aria-description",
|
|
25959
|
+
"aria-describedby",
|
|
25960
|
+
"aria-details",
|
|
25961
|
+
// "disabled",
|
|
25962
|
+
"aria-dropeffect",
|
|
25963
|
+
// "errormessage",
|
|
25964
|
+
"aria-flowto",
|
|
25965
|
+
"aria-grabbed",
|
|
25966
|
+
// "haspopup",
|
|
25967
|
+
"aria-hidden",
|
|
25968
|
+
// "invalid",
|
|
25969
|
+
"aria-keyshortcuts",
|
|
25970
|
+
"aria-label",
|
|
25971
|
+
"aria-labelledby",
|
|
25972
|
+
"aria-live",
|
|
25973
|
+
"aria-owns",
|
|
25974
|
+
"aria-relevant",
|
|
25975
|
+
"aria-roledescription"
|
|
25976
|
+
].some(function(attributeName) {
|
|
25977
|
+
var _prohibitedAttributes;
|
|
25978
|
+
return element.hasAttribute(attributeName) && !((_prohibitedAttributes = prohibitedAttributes[role]) !== null && _prohibitedAttributes !== void 0 && _prohibitedAttributes.has(attributeName));
|
|
25979
|
+
});
|
|
25980
|
+
}
|
|
25981
|
+
function ignorePresentationalRole(element, implicitRole) {
|
|
25982
|
+
return hasGlobalAriaAttributes(element, implicitRole);
|
|
25983
|
+
}
|
|
25984
|
+
function getRole(element) {
|
|
25985
|
+
var explicitRole = getExplicitRole(element);
|
|
25986
|
+
if (explicitRole === null || presentationRoles.indexOf(explicitRole) !== -1) {
|
|
25987
|
+
var implicitRole = getImplicitRole(element);
|
|
25988
|
+
if (presentationRoles.indexOf(explicitRole || "") === -1 || ignorePresentationalRole(element, implicitRole || "")) {
|
|
25989
|
+
return implicitRole;
|
|
25990
|
+
}
|
|
25991
|
+
}
|
|
25992
|
+
return explicitRole;
|
|
25993
|
+
}
|
|
25994
|
+
function getImplicitRole(element) {
|
|
25995
|
+
var mappedByTag = localNameToRoleMappings[getLocalName(element)];
|
|
25996
|
+
if (mappedByTag !== void 0) {
|
|
25997
|
+
return mappedByTag;
|
|
25998
|
+
}
|
|
25999
|
+
switch (getLocalName(element)) {
|
|
26000
|
+
case "a":
|
|
26001
|
+
case "area":
|
|
26002
|
+
case "link":
|
|
26003
|
+
if (element.hasAttribute("href")) {
|
|
26004
|
+
return "link";
|
|
26005
|
+
}
|
|
26006
|
+
break;
|
|
26007
|
+
case "img":
|
|
26008
|
+
if (element.getAttribute("alt") === "" && !ignorePresentationalRole(element, "img")) {
|
|
26009
|
+
return "presentation";
|
|
26010
|
+
}
|
|
26011
|
+
return "img";
|
|
26012
|
+
case "input": {
|
|
26013
|
+
var _ref = element, type = _ref.type;
|
|
26014
|
+
switch (type) {
|
|
26015
|
+
case "button":
|
|
26016
|
+
case "image":
|
|
26017
|
+
case "reset":
|
|
26018
|
+
case "submit":
|
|
26019
|
+
return "button";
|
|
26020
|
+
case "checkbox":
|
|
26021
|
+
case "radio":
|
|
26022
|
+
return type;
|
|
26023
|
+
case "range":
|
|
26024
|
+
return "slider";
|
|
26025
|
+
case "email":
|
|
26026
|
+
case "tel":
|
|
26027
|
+
case "text":
|
|
26028
|
+
case "url":
|
|
26029
|
+
if (element.hasAttribute("list")) {
|
|
26030
|
+
return "combobox";
|
|
26031
|
+
}
|
|
26032
|
+
return "textbox";
|
|
26033
|
+
case "search":
|
|
26034
|
+
if (element.hasAttribute("list")) {
|
|
26035
|
+
return "combobox";
|
|
26036
|
+
}
|
|
26037
|
+
return "searchbox";
|
|
26038
|
+
case "number":
|
|
26039
|
+
return "spinbutton";
|
|
26040
|
+
default:
|
|
26041
|
+
return null;
|
|
26042
|
+
}
|
|
26043
|
+
}
|
|
26044
|
+
case "select":
|
|
26045
|
+
if (element.hasAttribute("multiple") || element.size > 1) {
|
|
26046
|
+
return "listbox";
|
|
26047
|
+
}
|
|
26048
|
+
return "combobox";
|
|
26049
|
+
}
|
|
26050
|
+
return null;
|
|
26051
|
+
}
|
|
26052
|
+
function getExplicitRole(element) {
|
|
26053
|
+
var role = element.getAttribute("role");
|
|
26054
|
+
if (role !== null) {
|
|
26055
|
+
var explicitRole = role.trim().split(" ")[0];
|
|
26056
|
+
if (explicitRole.length > 0) {
|
|
26057
|
+
return explicitRole;
|
|
26058
|
+
}
|
|
26059
|
+
}
|
|
26060
|
+
return null;
|
|
26061
|
+
}
|
|
26062
|
+
|
|
26063
|
+
// ../../node_modules/.pnpm/dom-accessibility-api@0.6.3/node_modules/dom-accessibility-api/dist/util.mjs
|
|
26064
|
+
var presentationRoles = ["presentation", "none"];
|
|
26065
|
+
function isElement(node) {
|
|
26066
|
+
return node !== null && node.nodeType === node.ELEMENT_NODE;
|
|
26067
|
+
}
|
|
26068
|
+
function isHTMLTableCaptionElement(node) {
|
|
26069
|
+
return isElement(node) && getLocalName(node) === "caption";
|
|
26070
|
+
}
|
|
26071
|
+
function isHTMLInputElement(node) {
|
|
26072
|
+
return isElement(node) && getLocalName(node) === "input";
|
|
26073
|
+
}
|
|
26074
|
+
function isHTMLOptGroupElement(node) {
|
|
26075
|
+
return isElement(node) && getLocalName(node) === "optgroup";
|
|
26076
|
+
}
|
|
26077
|
+
function isHTMLSelectElement(node) {
|
|
26078
|
+
return isElement(node) && getLocalName(node) === "select";
|
|
26079
|
+
}
|
|
26080
|
+
function isHTMLTableElement(node) {
|
|
26081
|
+
return isElement(node) && getLocalName(node) === "table";
|
|
26082
|
+
}
|
|
26083
|
+
function isHTMLTextAreaElement(node) {
|
|
26084
|
+
return isElement(node) && getLocalName(node) === "textarea";
|
|
26085
|
+
}
|
|
26086
|
+
function safeWindow(node) {
|
|
26087
|
+
var _ref = node.ownerDocument === null ? node : node.ownerDocument, defaultView = _ref.defaultView;
|
|
26088
|
+
if (defaultView === null) {
|
|
26089
|
+
throw new TypeError("no window available");
|
|
26090
|
+
}
|
|
26091
|
+
return defaultView;
|
|
26092
|
+
}
|
|
26093
|
+
function isHTMLFieldSetElement(node) {
|
|
26094
|
+
return isElement(node) && getLocalName(node) === "fieldset";
|
|
26095
|
+
}
|
|
26096
|
+
function isHTMLLegendElement(node) {
|
|
26097
|
+
return isElement(node) && getLocalName(node) === "legend";
|
|
26098
|
+
}
|
|
26099
|
+
function isHTMLSlotElement(node) {
|
|
26100
|
+
return isElement(node) && getLocalName(node) === "slot";
|
|
26101
|
+
}
|
|
26102
|
+
function isSVGElement(node) {
|
|
26103
|
+
return isElement(node) && node.ownerSVGElement !== void 0;
|
|
26104
|
+
}
|
|
26105
|
+
function isSVGSVGElement(node) {
|
|
26106
|
+
return isElement(node) && getLocalName(node) === "svg";
|
|
26107
|
+
}
|
|
26108
|
+
function isSVGTitleElement(node) {
|
|
26109
|
+
return isSVGElement(node) && getLocalName(node) === "title";
|
|
26110
|
+
}
|
|
26111
|
+
function queryIdRefs(node, attributeName) {
|
|
26112
|
+
if (isElement(node) && node.hasAttribute(attributeName)) {
|
|
26113
|
+
var ids = node.getAttribute(attributeName).split(" ");
|
|
26114
|
+
var root = node.getRootNode ? node.getRootNode() : node.ownerDocument;
|
|
26115
|
+
return ids.map(function(id) {
|
|
26116
|
+
return root.getElementById(id);
|
|
26117
|
+
}).filter(
|
|
26118
|
+
function(element) {
|
|
26119
|
+
return element !== null;
|
|
26120
|
+
}
|
|
26121
|
+
// TODO: why does this not narrow?
|
|
26122
|
+
);
|
|
26123
|
+
}
|
|
26124
|
+
return [];
|
|
26125
|
+
}
|
|
26126
|
+
function hasAnyConcreteRoles(node, roles) {
|
|
26127
|
+
if (isElement(node)) {
|
|
26128
|
+
return roles.indexOf(getRole(node)) !== -1;
|
|
26129
|
+
}
|
|
26130
|
+
return false;
|
|
26131
|
+
}
|
|
26132
|
+
|
|
26133
|
+
// ../../node_modules/.pnpm/dom-accessibility-api@0.6.3/node_modules/dom-accessibility-api/dist/accessible-name-and-description.mjs
|
|
26134
|
+
function asFlatString(s) {
|
|
26135
|
+
return s.trim().replace(/\s\s+/g, " ");
|
|
26136
|
+
}
|
|
26137
|
+
function isHidden4(node, getComputedStyleImplementation) {
|
|
26138
|
+
if (!isElement(node)) {
|
|
26139
|
+
return false;
|
|
26140
|
+
}
|
|
26141
|
+
if (node.hasAttribute("hidden") || node.getAttribute("aria-hidden") === "true") {
|
|
26142
|
+
return true;
|
|
26143
|
+
}
|
|
26144
|
+
var style = getComputedStyleImplementation(node);
|
|
26145
|
+
return style.getPropertyValue("display") === "none" || style.getPropertyValue("visibility") === "hidden";
|
|
26146
|
+
}
|
|
26147
|
+
function isControl(node) {
|
|
26148
|
+
return hasAnyConcreteRoles(node, ["button", "combobox", "listbox", "textbox"]) || hasAbstractRole(node, "range");
|
|
26149
|
+
}
|
|
26150
|
+
function hasAbstractRole(node, role) {
|
|
26151
|
+
if (!isElement(node)) {
|
|
26152
|
+
return false;
|
|
26153
|
+
}
|
|
26154
|
+
switch (role) {
|
|
26155
|
+
case "range":
|
|
26156
|
+
return hasAnyConcreteRoles(node, ["meter", "progressbar", "scrollbar", "slider", "spinbutton"]);
|
|
26157
|
+
default:
|
|
26158
|
+
throw new TypeError("No knowledge about abstract role '".concat(role, "'. This is likely a bug :("));
|
|
26159
|
+
}
|
|
26160
|
+
}
|
|
26161
|
+
function querySelectorAllSubtree(element, selectors) {
|
|
26162
|
+
var elements = arrayFrom(element.querySelectorAll(selectors));
|
|
26163
|
+
queryIdRefs(element, "aria-owns").forEach(function(root) {
|
|
26164
|
+
elements.push.apply(elements, arrayFrom(root.querySelectorAll(selectors)));
|
|
26165
|
+
});
|
|
26166
|
+
return elements;
|
|
26167
|
+
}
|
|
26168
|
+
function querySelectedOptions(listbox) {
|
|
26169
|
+
if (isHTMLSelectElement(listbox)) {
|
|
26170
|
+
return listbox.selectedOptions || querySelectorAllSubtree(listbox, "[selected]");
|
|
26171
|
+
}
|
|
26172
|
+
return querySelectorAllSubtree(listbox, '[aria-selected="true"]');
|
|
26173
|
+
}
|
|
26174
|
+
function isMarkedPresentational(node) {
|
|
26175
|
+
return hasAnyConcreteRoles(node, presentationRoles);
|
|
26176
|
+
}
|
|
26177
|
+
function isNativeHostLanguageTextAlternativeElement(node) {
|
|
26178
|
+
return isHTMLTableCaptionElement(node);
|
|
26179
|
+
}
|
|
26180
|
+
function allowsNameFromContent(node) {
|
|
26181
|
+
return hasAnyConcreteRoles(node, ["button", "cell", "checkbox", "columnheader", "gridcell", "heading", "label", "legend", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "row", "rowheader", "switch", "tab", "tooltip", "treeitem"]);
|
|
26182
|
+
}
|
|
26183
|
+
function isDescendantOfNativeHostLanguageTextAlternativeElement(node) {
|
|
26184
|
+
return false;
|
|
26185
|
+
}
|
|
26186
|
+
function getValueOfTextbox(element) {
|
|
26187
|
+
if (isHTMLInputElement(element) || isHTMLTextAreaElement(element)) {
|
|
26188
|
+
return element.value;
|
|
26189
|
+
}
|
|
26190
|
+
return element.textContent || "";
|
|
26191
|
+
}
|
|
26192
|
+
function getTextualContent(declaration) {
|
|
26193
|
+
var content = declaration.getPropertyValue("content");
|
|
26194
|
+
if (/^["'].*["']$/.test(content)) {
|
|
26195
|
+
return content.slice(1, -1);
|
|
26196
|
+
}
|
|
26197
|
+
return "";
|
|
26198
|
+
}
|
|
26199
|
+
function isLabelableElement(element) {
|
|
26200
|
+
var localName = getLocalName(element);
|
|
26201
|
+
return localName === "button" || localName === "input" && element.getAttribute("type") !== "hidden" || localName === "meter" || localName === "output" || localName === "progress" || localName === "select" || localName === "textarea";
|
|
26202
|
+
}
|
|
26203
|
+
function findLabelableElement(element) {
|
|
26204
|
+
if (isLabelableElement(element)) {
|
|
26205
|
+
return element;
|
|
26206
|
+
}
|
|
26207
|
+
var labelableElement = null;
|
|
26208
|
+
element.childNodes.forEach(function(childNode) {
|
|
26209
|
+
if (labelableElement === null && isElement(childNode)) {
|
|
26210
|
+
var descendantLabelableElement = findLabelableElement(childNode);
|
|
26211
|
+
if (descendantLabelableElement !== null) {
|
|
26212
|
+
labelableElement = descendantLabelableElement;
|
|
26213
|
+
}
|
|
26214
|
+
}
|
|
26215
|
+
});
|
|
26216
|
+
return labelableElement;
|
|
26217
|
+
}
|
|
26218
|
+
function getControlOfLabel(label) {
|
|
26219
|
+
if (label.control !== void 0) {
|
|
26220
|
+
return label.control;
|
|
26221
|
+
}
|
|
26222
|
+
var htmlFor = label.getAttribute("for");
|
|
26223
|
+
if (htmlFor !== null) {
|
|
26224
|
+
return label.ownerDocument.getElementById(htmlFor);
|
|
26225
|
+
}
|
|
26226
|
+
return findLabelableElement(label);
|
|
26227
|
+
}
|
|
26228
|
+
function getLabels(element) {
|
|
26229
|
+
var labelsProperty = element.labels;
|
|
26230
|
+
if (labelsProperty === null) {
|
|
26231
|
+
return labelsProperty;
|
|
26232
|
+
}
|
|
26233
|
+
if (labelsProperty !== void 0) {
|
|
26234
|
+
return arrayFrom(labelsProperty);
|
|
26235
|
+
}
|
|
26236
|
+
if (!isLabelableElement(element)) {
|
|
26237
|
+
return null;
|
|
26238
|
+
}
|
|
26239
|
+
var document2 = element.ownerDocument;
|
|
26240
|
+
return arrayFrom(document2.querySelectorAll("label")).filter(function(label) {
|
|
26241
|
+
return getControlOfLabel(label) === element;
|
|
26242
|
+
});
|
|
26243
|
+
}
|
|
26244
|
+
function getSlotContents(slot) {
|
|
26245
|
+
var assignedNodes = slot.assignedNodes();
|
|
26246
|
+
if (assignedNodes.length === 0) {
|
|
26247
|
+
return arrayFrom(slot.childNodes);
|
|
26248
|
+
}
|
|
26249
|
+
return assignedNodes;
|
|
26250
|
+
}
|
|
26251
|
+
function computeTextAlternative(root) {
|
|
26252
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
26253
|
+
var consultedNodes = new SetLike_default();
|
|
26254
|
+
var window2 = safeWindow(root);
|
|
26255
|
+
var _options$compute = options.compute, compute = _options$compute === void 0 ? "name" : _options$compute, _options$computedStyl = options.computedStyleSupportsPseudoElements, computedStyleSupportsPseudoElements = _options$computedStyl === void 0 ? options.getComputedStyle !== void 0 : _options$computedStyl, _options$getComputedS = options.getComputedStyle, getComputedStyle2 = _options$getComputedS === void 0 ? window2.getComputedStyle.bind(window2) : _options$getComputedS, _options$hidden = options.hidden, hidden = _options$hidden === void 0 ? false : _options$hidden;
|
|
25694
26256
|
function computeMiscTextAlternative(node, context) {
|
|
25695
26257
|
var accumulatedText = "";
|
|
25696
26258
|
if (isElement(node) && computedStyleSupportsPseudoElements) {
|
|
@@ -25832,7 +26394,7 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
25832
26394
|
if (consultedNodes.has(current)) {
|
|
25833
26395
|
return "";
|
|
25834
26396
|
}
|
|
25835
|
-
if (!hidden &&
|
|
26397
|
+
if (!hidden && isHidden4(current, getComputedStyle2) && !context.isReferenced) {
|
|
25836
26398
|
consultedNodes.add(current);
|
|
25837
26399
|
return "";
|
|
25838
26400
|
}
|
|
@@ -25877,364 +26439,111 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
25877
26439
|
if (selectedOptions.length === 0) {
|
|
25878
26440
|
return isHTMLInputElement(current) ? current.value : "";
|
|
25879
26441
|
}
|
|
25880
|
-
return arrayFrom(selectedOptions).map(function(selectedOption) {
|
|
25881
|
-
return computeTextAlternative2(selectedOption, {
|
|
25882
|
-
isEmbeddedInLabel: context.isEmbeddedInLabel,
|
|
25883
|
-
isReferenced: false,
|
|
25884
|
-
recursion: true
|
|
25885
|
-
});
|
|
25886
|
-
}).join(" ");
|
|
25887
|
-
}
|
|
25888
|
-
if (hasAbstractRole(current, "range")) {
|
|
25889
|
-
consultedNodes.add(current);
|
|
25890
|
-
if (current.hasAttribute("aria-valuetext")) {
|
|
25891
|
-
return current.getAttribute("aria-valuetext");
|
|
25892
|
-
}
|
|
25893
|
-
if (current.hasAttribute("aria-valuenow")) {
|
|
25894
|
-
return current.getAttribute("aria-valuenow");
|
|
25895
|
-
}
|
|
25896
|
-
return current.getAttribute("value") || "";
|
|
25897
|
-
}
|
|
25898
|
-
if (hasAnyConcreteRoles(current, ["textbox"])) {
|
|
25899
|
-
consultedNodes.add(current);
|
|
25900
|
-
return getValueOfTextbox(current);
|
|
25901
|
-
}
|
|
25902
|
-
}
|
|
25903
|
-
if (allowsNameFromContent(current) || isElement(current) && context.isReferenced || isNativeHostLanguageTextAlternativeElement(current) || isDescendantOfNativeHostLanguageTextAlternativeElement(current)) {
|
|
25904
|
-
var accumulatedText2F = computeMiscTextAlternative(current, {
|
|
25905
|
-
isEmbeddedInLabel: context.isEmbeddedInLabel,
|
|
25906
|
-
isReferenced: false
|
|
25907
|
-
});
|
|
25908
|
-
if (accumulatedText2F !== "") {
|
|
25909
|
-
consultedNodes.add(current);
|
|
25910
|
-
return accumulatedText2F;
|
|
25911
|
-
}
|
|
25912
|
-
}
|
|
25913
|
-
if (current.nodeType === current.TEXT_NODE) {
|
|
25914
|
-
consultedNodes.add(current);
|
|
25915
|
-
return current.textContent || "";
|
|
25916
|
-
}
|
|
25917
|
-
if (context.recursion) {
|
|
25918
|
-
consultedNodes.add(current);
|
|
25919
|
-
return computeMiscTextAlternative(current, {
|
|
25920
|
-
isEmbeddedInLabel: context.isEmbeddedInLabel,
|
|
25921
|
-
isReferenced: false
|
|
25922
|
-
});
|
|
25923
|
-
}
|
|
25924
|
-
var tooltipAttributeValue = computeTooltipAttributeValue(current);
|
|
25925
|
-
if (tooltipAttributeValue !== null) {
|
|
25926
|
-
consultedNodes.add(current);
|
|
25927
|
-
return tooltipAttributeValue;
|
|
25928
|
-
}
|
|
25929
|
-
consultedNodes.add(current);
|
|
25930
|
-
return "";
|
|
25931
|
-
}
|
|
25932
|
-
return asFlatString(computeTextAlternative2(root, {
|
|
25933
|
-
isEmbeddedInLabel: false,
|
|
25934
|
-
// by spec computeAccessibleDescription starts with the referenced elements as roots
|
|
25935
|
-
isReferenced: compute === "description",
|
|
25936
|
-
recursion: false
|
|
25937
|
-
}));
|
|
25938
|
-
}
|
|
25939
|
-
|
|
25940
|
-
// ../../node_modules/.pnpm/dom-accessibility-api@0.6.3/node_modules/dom-accessibility-api/dist/accessible-name.mjs
|
|
25941
|
-
function prohibitsNaming(node) {
|
|
25942
|
-
return hasAnyConcreteRoles(node, ["caption", "code", "deletion", "emphasis", "generic", "insertion", "none", "paragraph", "presentation", "strong", "subscript", "superscript"]);
|
|
25943
|
-
}
|
|
25944
|
-
function computeAccessibleName(root) {
|
|
25945
|
-
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
25946
|
-
if (prohibitsNaming(root)) {
|
|
25947
|
-
return "";
|
|
25948
|
-
}
|
|
25949
|
-
return computeTextAlternative(root, options);
|
|
25950
|
-
}
|
|
25951
|
-
|
|
25952
|
-
// ../../node_modules/.pnpm/tabbable@6.5.0/node_modules/tabbable/dist/index.esm.js
|
|
25953
|
-
var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "area[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"];
|
|
25954
|
-
var NoElement = typeof Element === "undefined";
|
|
25955
|
-
var matches = NoElement ? function() {
|
|
25956
|
-
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
25957
|
-
var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
|
|
25958
|
-
var _element$getRootNode;
|
|
25959
|
-
return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
|
|
25960
|
-
} : function(element) {
|
|
25961
|
-
return element === null || element === void 0 ? void 0 : element.ownerDocument;
|
|
25962
|
-
};
|
|
25963
|
-
var isInput = function isInput2(node) {
|
|
25964
|
-
return node.tagName === "INPUT";
|
|
25965
|
-
};
|
|
25966
|
-
var isHiddenInput = function isHiddenInput2(node) {
|
|
25967
|
-
return isInput(node) && node.type === "hidden";
|
|
25968
|
-
};
|
|
25969
|
-
var isDetailsWithSummary = function isDetailsWithSummary2(node) {
|
|
25970
|
-
var r = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
|
|
25971
|
-
return child.tagName === "SUMMARY";
|
|
25972
|
-
});
|
|
25973
|
-
return r;
|
|
25974
|
-
};
|
|
25975
|
-
var isNodeAttached = function isNodeAttached2(node) {
|
|
25976
|
-
var _nodeRoot;
|
|
25977
|
-
var nodeRoot = node && getRootNode(node);
|
|
25978
|
-
var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
|
|
25979
|
-
var attached = false;
|
|
25980
|
-
if (nodeRoot && nodeRoot !== node) {
|
|
25981
|
-
var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
|
|
25982
|
-
attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
|
|
25983
|
-
while (!attached && nodeRootHost) {
|
|
25984
|
-
var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
|
|
25985
|
-
nodeRoot = getRootNode(nodeRootHost);
|
|
25986
|
-
nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
|
|
25987
|
-
attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
|
|
25988
|
-
}
|
|
25989
|
-
}
|
|
25990
|
-
return attached;
|
|
25991
|
-
};
|
|
25992
|
-
var isZeroArea = function isZeroArea2(node) {
|
|
25993
|
-
var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
|
|
25994
|
-
return width === 0 && height === 0;
|
|
25995
|
-
};
|
|
25996
|
-
var isHidden2 = function isHidden3(node, _ref) {
|
|
25997
|
-
var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
|
|
25998
|
-
if (displayCheck === "full-native") {
|
|
25999
|
-
if ("checkVisibility" in node) {
|
|
26000
|
-
var visible = node.checkVisibility({
|
|
26001
|
-
// Checking opacity might be desirable for some use cases, but natively,
|
|
26002
|
-
// opacity zero elements _are_ focusable and tabbable.
|
|
26003
|
-
checkOpacity: false,
|
|
26004
|
-
opacityProperty: false,
|
|
26005
|
-
contentVisibilityAuto: true,
|
|
26006
|
-
visibilityProperty: true,
|
|
26007
|
-
// This is an alias for `visibilityProperty`. Contemporary browsers
|
|
26008
|
-
// support both. However, this alias has wider browser support (Chrome
|
|
26009
|
-
// >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
|
|
26010
|
-
// we include it anyway.
|
|
26011
|
-
checkVisibilityCSS: true
|
|
26012
|
-
});
|
|
26013
|
-
return !visible;
|
|
26014
|
-
}
|
|
26015
|
-
}
|
|
26016
|
-
var _getComputedStyle = getComputedStyle(node), visibility = _getComputedStyle.visibility;
|
|
26017
|
-
if (visibility === "hidden" || visibility === "collapse") {
|
|
26018
|
-
return true;
|
|
26019
|
-
}
|
|
26020
|
-
var isDirectSummary = matches.call(node, "details>summary:first-of-type");
|
|
26021
|
-
var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
|
|
26022
|
-
if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
|
|
26023
|
-
return true;
|
|
26024
|
-
}
|
|
26025
|
-
if (!displayCheck || displayCheck === "full" || // full-native can run this branch when it falls through in case
|
|
26026
|
-
// Element#checkVisibility is unsupported
|
|
26027
|
-
displayCheck === "full-native" || displayCheck === "legacy-full") {
|
|
26028
|
-
if (typeof getShadowRoot === "function") {
|
|
26029
|
-
var originalNode = node;
|
|
26030
|
-
while (node) {
|
|
26031
|
-
var parentElement = node.parentElement;
|
|
26032
|
-
var rootNode = getRootNode(node);
|
|
26033
|
-
if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
|
|
26034
|
-
return isZeroArea(node);
|
|
26035
|
-
} else if (node.assignedSlot) {
|
|
26036
|
-
node = node.assignedSlot;
|
|
26037
|
-
} else if (!parentElement && rootNode !== node.ownerDocument) {
|
|
26038
|
-
node = rootNode.host;
|
|
26039
|
-
} else {
|
|
26040
|
-
node = parentElement;
|
|
26041
|
-
}
|
|
26442
|
+
return arrayFrom(selectedOptions).map(function(selectedOption) {
|
|
26443
|
+
return computeTextAlternative2(selectedOption, {
|
|
26444
|
+
isEmbeddedInLabel: context.isEmbeddedInLabel,
|
|
26445
|
+
isReferenced: false,
|
|
26446
|
+
recursion: true
|
|
26447
|
+
});
|
|
26448
|
+
}).join(" ");
|
|
26449
|
+
}
|
|
26450
|
+
if (hasAbstractRole(current, "range")) {
|
|
26451
|
+
consultedNodes.add(current);
|
|
26452
|
+
if (current.hasAttribute("aria-valuetext")) {
|
|
26453
|
+
return current.getAttribute("aria-valuetext");
|
|
26454
|
+
}
|
|
26455
|
+
if (current.hasAttribute("aria-valuenow")) {
|
|
26456
|
+
return current.getAttribute("aria-valuenow");
|
|
26457
|
+
}
|
|
26458
|
+
return current.getAttribute("value") || "";
|
|
26459
|
+
}
|
|
26460
|
+
if (hasAnyConcreteRoles(current, ["textbox"])) {
|
|
26461
|
+
consultedNodes.add(current);
|
|
26462
|
+
return getValueOfTextbox(current);
|
|
26042
26463
|
}
|
|
26043
|
-
node = originalNode;
|
|
26044
26464
|
}
|
|
26045
|
-
if (
|
|
26046
|
-
|
|
26465
|
+
if (allowsNameFromContent(current) || isElement(current) && context.isReferenced || isNativeHostLanguageTextAlternativeElement(current) || isDescendantOfNativeHostLanguageTextAlternativeElement(current)) {
|
|
26466
|
+
var accumulatedText2F = computeMiscTextAlternative(current, {
|
|
26467
|
+
isEmbeddedInLabel: context.isEmbeddedInLabel,
|
|
26468
|
+
isReferenced: false
|
|
26469
|
+
});
|
|
26470
|
+
if (accumulatedText2F !== "") {
|
|
26471
|
+
consultedNodes.add(current);
|
|
26472
|
+
return accumulatedText2F;
|
|
26473
|
+
}
|
|
26047
26474
|
}
|
|
26048
|
-
if (
|
|
26049
|
-
|
|
26475
|
+
if (current.nodeType === current.TEXT_NODE) {
|
|
26476
|
+
consultedNodes.add(current);
|
|
26477
|
+
return current.textContent || "";
|
|
26050
26478
|
}
|
|
26051
|
-
|
|
26052
|
-
|
|
26053
|
-
|
|
26054
|
-
|
|
26055
|
-
|
|
26056
|
-
|
|
26057
|
-
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
|
|
26058
|
-
var parentNode = node.parentElement;
|
|
26059
|
-
while (parentNode) {
|
|
26060
|
-
if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
|
|
26061
|
-
for (var i = 0; i < parentNode.children.length; i++) {
|
|
26062
|
-
var child = parentNode.children.item(i);
|
|
26063
|
-
if (child.tagName === "LEGEND") {
|
|
26064
|
-
return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
|
|
26065
|
-
}
|
|
26066
|
-
}
|
|
26067
|
-
return true;
|
|
26068
|
-
}
|
|
26069
|
-
parentNode = parentNode.parentElement;
|
|
26479
|
+
if (context.recursion) {
|
|
26480
|
+
consultedNodes.add(current);
|
|
26481
|
+
return computeMiscTextAlternative(current, {
|
|
26482
|
+
isEmbeddedInLabel: context.isEmbeddedInLabel,
|
|
26483
|
+
isReferenced: false
|
|
26484
|
+
});
|
|
26070
26485
|
}
|
|
26071
|
-
|
|
26072
|
-
|
|
26073
|
-
|
|
26074
|
-
|
|
26075
|
-
if (node.disabled || isHiddenInput(node) || isHidden2(node, options) || // For a details element with a summary, the summary element gets the focus
|
|
26076
|
-
isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
|
|
26077
|
-
return false;
|
|
26078
|
-
}
|
|
26079
|
-
return true;
|
|
26080
|
-
};
|
|
26081
|
-
var focusableCandidateSelector = /* @__PURE__ */ candidateSelectors.concat("iframe:not([inert]):not([inert] *)").join(",");
|
|
26082
|
-
var isFocusable = function isFocusable2(node, options) {
|
|
26083
|
-
options = options || {};
|
|
26084
|
-
if (!node) {
|
|
26085
|
-
throw new Error("No node provided");
|
|
26086
|
-
}
|
|
26087
|
-
if (matches.call(node, focusableCandidateSelector) === false) {
|
|
26088
|
-
return false;
|
|
26089
|
-
}
|
|
26090
|
-
return isNodeMatchingSelectorFocusable(options, node);
|
|
26091
|
-
};
|
|
26092
|
-
|
|
26093
|
-
// ../next-sdk/page-tools/a11y-tree.ts
|
|
26094
|
-
var TAG_ROLE_MAP = {
|
|
26095
|
-
a: "link",
|
|
26096
|
-
article: "article",
|
|
26097
|
-
aside: "complementary",
|
|
26098
|
-
button: "button",
|
|
26099
|
-
caption: "caption",
|
|
26100
|
-
cell: "cell",
|
|
26101
|
-
checkbox: "checkbox",
|
|
26102
|
-
code: "code",
|
|
26103
|
-
columnheader: "columnheader",
|
|
26104
|
-
combobox: "combobox",
|
|
26105
|
-
datalist: "listbox",
|
|
26106
|
-
dd: "definition",
|
|
26107
|
-
details: "group",
|
|
26108
|
-
dialog: "dialog",
|
|
26109
|
-
dt: "term",
|
|
26110
|
-
em: "emphasis",
|
|
26111
|
-
fieldset: "group",
|
|
26112
|
-
figure: "figure",
|
|
26113
|
-
footer: "contentinfo",
|
|
26114
|
-
form: "form",
|
|
26115
|
-
h1: "heading",
|
|
26116
|
-
h2: "heading",
|
|
26117
|
-
h3: "heading",
|
|
26118
|
-
h4: "heading",
|
|
26119
|
-
h5: "heading",
|
|
26120
|
-
h6: "heading",
|
|
26121
|
-
header: "banner",
|
|
26122
|
-
hr: "separator",
|
|
26123
|
-
img: "img",
|
|
26124
|
-
input: "textbox",
|
|
26125
|
-
// 默认,具体 type 下面会覆盖
|
|
26126
|
-
li: "listitem",
|
|
26127
|
-
link: "link",
|
|
26128
|
-
main: "main",
|
|
26129
|
-
mark: "mark",
|
|
26130
|
-
math: "math",
|
|
26131
|
-
menu: "list",
|
|
26132
|
-
menuitem: "menuitem",
|
|
26133
|
-
meter: "meter",
|
|
26134
|
-
nav: "navigation",
|
|
26135
|
-
ol: "list",
|
|
26136
|
-
option: "option",
|
|
26137
|
-
output: "status",
|
|
26138
|
-
p: "paragraph",
|
|
26139
|
-
progress: "progressbar",
|
|
26140
|
-
rowheader: "rowheader",
|
|
26141
|
-
search: "search",
|
|
26142
|
-
section: "region",
|
|
26143
|
-
select: "listbox",
|
|
26144
|
-
strong: "strong",
|
|
26145
|
-
summary: "button",
|
|
26146
|
-
table: "table",
|
|
26147
|
-
tbody: "rowgroup",
|
|
26148
|
-
td: "cell",
|
|
26149
|
-
tfoot: "rowgroup",
|
|
26150
|
-
th: "columnheader",
|
|
26151
|
-
thead: "rowgroup",
|
|
26152
|
-
time: "time",
|
|
26153
|
-
tr: "row",
|
|
26154
|
-
ul: "list"
|
|
26155
|
-
};
|
|
26156
|
-
var INPUT_TYPE_ROLE = {
|
|
26157
|
-
button: "button",
|
|
26158
|
-
checkbox: "checkbox",
|
|
26159
|
-
color: "textbox",
|
|
26160
|
-
email: "textbox",
|
|
26161
|
-
file: "textbox",
|
|
26162
|
-
image: "button",
|
|
26163
|
-
number: "spinbutton",
|
|
26164
|
-
radio: "radio",
|
|
26165
|
-
range: "slider",
|
|
26166
|
-
reset: "button",
|
|
26167
|
-
search: "searchbox",
|
|
26168
|
-
submit: "button",
|
|
26169
|
-
tel: "textbox",
|
|
26170
|
-
text: "textbox",
|
|
26171
|
-
url: "textbox"
|
|
26172
|
-
};
|
|
26173
|
-
function inferRole(el) {
|
|
26174
|
-
const explicit = el.getAttribute("role");
|
|
26175
|
-
if (explicit && explicit !== "presentation" && explicit !== "none") {
|
|
26176
|
-
return explicit;
|
|
26177
|
-
}
|
|
26178
|
-
const tag = el.tagName.toLowerCase();
|
|
26179
|
-
if (tag === "input") {
|
|
26180
|
-
const inputType = el.type?.toLowerCase() ?? "text";
|
|
26181
|
-
return INPUT_TYPE_ROLE[inputType] ?? "textbox";
|
|
26182
|
-
}
|
|
26183
|
-
return TAG_ROLE_MAP[tag] ?? "generic";
|
|
26184
|
-
}
|
|
26185
|
-
function getStateTokens(el) {
|
|
26186
|
-
const tokens = [];
|
|
26187
|
-
const aria = (k) => el.getAttribute(k);
|
|
26188
|
-
const checked = aria("aria-checked");
|
|
26189
|
-
if (checked === "true") tokens.push("checked");
|
|
26190
|
-
else if (checked === "false") tokens.push("unchecked");
|
|
26191
|
-
if (aria("aria-selected") === "true") tokens.push("selected");
|
|
26192
|
-
const disabled = aria("aria-disabled") === "true" || el.disabled;
|
|
26193
|
-
if (disabled) tokens.push("disabled");
|
|
26194
|
-
const hasPopup = aria("aria-haspopup");
|
|
26195
|
-
if (hasPopup && hasPopup !== "false") tokens.push("hasPopup");
|
|
26196
|
-
if (aria("aria-expanded") === "true") tokens.push("expanded");
|
|
26197
|
-
const headingMatch = el.tagName.match(/^H([1-6])$/);
|
|
26198
|
-
if (headingMatch) tokens.push(`level=${headingMatch[1]}`);
|
|
26199
|
-
const ariaLevel = aria("aria-level");
|
|
26200
|
-
if (ariaLevel && !headingMatch) tokens.push(`level=${ariaLevel}`);
|
|
26201
|
-
try {
|
|
26202
|
-
const style = window.getComputedStyle(el);
|
|
26203
|
-
if (style.cursor === "pointer") tokens.push("cursor=pointer");
|
|
26204
|
-
} catch {
|
|
26205
|
-
}
|
|
26206
|
-
const tag = el.tagName.toLowerCase();
|
|
26207
|
-
if (tag === "input" || tag === "textarea" || tag === "select") {
|
|
26208
|
-
const val = el.value;
|
|
26209
|
-
if (val !== void 0 && val !== "") {
|
|
26210
|
-
tokens.push(`value="${val}"`);
|
|
26486
|
+
var tooltipAttributeValue = computeTooltipAttributeValue(current);
|
|
26487
|
+
if (tooltipAttributeValue !== null) {
|
|
26488
|
+
consultedNodes.add(current);
|
|
26489
|
+
return tooltipAttributeValue;
|
|
26211
26490
|
}
|
|
26491
|
+
consultedNodes.add(current);
|
|
26492
|
+
return "";
|
|
26212
26493
|
}
|
|
26213
|
-
|
|
26214
|
-
|
|
26215
|
-
|
|
26216
|
-
|
|
26217
|
-
|
|
26494
|
+
return asFlatString(computeTextAlternative2(root, {
|
|
26495
|
+
isEmbeddedInLabel: false,
|
|
26496
|
+
// by spec computeAccessibleDescription starts with the referenced elements as roots
|
|
26497
|
+
isReferenced: compute === "description",
|
|
26498
|
+
recursion: false
|
|
26499
|
+
}));
|
|
26218
26500
|
}
|
|
26219
|
-
|
|
26220
|
-
|
|
26221
|
-
|
|
26222
|
-
|
|
26223
|
-
|
|
26224
|
-
|
|
26225
|
-
|
|
26501
|
+
|
|
26502
|
+
// ../../node_modules/.pnpm/dom-accessibility-api@0.6.3/node_modules/dom-accessibility-api/dist/accessible-name.mjs
|
|
26503
|
+
function prohibitsNaming(node) {
|
|
26504
|
+
return hasAnyConcreteRoles(node, ["caption", "code", "deletion", "emphasis", "generic", "insertion", "none", "paragraph", "presentation", "strong", "subscript", "superscript"]);
|
|
26505
|
+
}
|
|
26506
|
+
function computeAccessibleName(root) {
|
|
26507
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
26508
|
+
if (prohibitsNaming(root)) {
|
|
26509
|
+
return "";
|
|
26226
26510
|
}
|
|
26227
|
-
return
|
|
26511
|
+
return computeTextAlternative(root, options);
|
|
26228
26512
|
}
|
|
26229
|
-
|
|
26230
|
-
|
|
26513
|
+
|
|
26514
|
+
// ../next-sdk/page-tools/a11y/vnode.ts
|
|
26515
|
+
function buildVNode(el, refCounter, refMap, blacklistSet, whitelistSet, exposedAttributes, errorSelectors, warningSelectors, ancestorIsInteractive = false) {
|
|
26516
|
+
if (isHidden3(el) || blacklistSet.has(el)) return null;
|
|
26231
26517
|
const role = inferRole(el);
|
|
26232
|
-
const tokens = getStateTokens(el);
|
|
26233
|
-
|
|
26234
|
-
const isTrulyInteractive =
|
|
26518
|
+
const tokens = getStateTokens(el, exposedAttributes, errorSelectors, warningSelectors);
|
|
26519
|
+
let name = computeAccessibleName(el);
|
|
26520
|
+
const isTrulyInteractive = isTabbable(el);
|
|
26235
26521
|
const isVisuallyClickable = tokens.includes("cursor=pointer");
|
|
26236
|
-
const isWhitelisted = whitelistSet.has(el);
|
|
26237
|
-
const
|
|
26522
|
+
const isWhitelisted = whitelistSet.has(el) || (exposedAttributes?.some((attr) => el.hasAttribute(attr)) ?? false);
|
|
26523
|
+
const isLabelFor = el.tagName.toLowerCase() === "label" && el.hasAttribute("for");
|
|
26524
|
+
if (!name.trim()) {
|
|
26525
|
+
const tag = el.tagName.toLowerCase();
|
|
26526
|
+
const isDropdown = tag === "select" || role === "combobox" || role === "listbox";
|
|
26527
|
+
if (!isDropdown) {
|
|
26528
|
+
const isInteractiveTag = ["button", "a", "input", "textarea", "li", "label"].includes(tag);
|
|
26529
|
+
if (isTrulyInteractive || isWhitelisted || isVisuallyClickable || isInteractiveTag || role === "listitem" || role === "option") {
|
|
26530
|
+
name = collectDescendantText(el);
|
|
26531
|
+
}
|
|
26532
|
+
}
|
|
26533
|
+
}
|
|
26534
|
+
if (!name.trim()) {
|
|
26535
|
+
const hasElementChildren = getComposedChildren(el).length > 0;
|
|
26536
|
+
if (!hasElementChildren) {
|
|
26537
|
+
const text = collectDescendantText(el);
|
|
26538
|
+
if (text) {
|
|
26539
|
+
name = text;
|
|
26540
|
+
}
|
|
26541
|
+
}
|
|
26542
|
+
}
|
|
26543
|
+
const tagName = el.tagName.toLowerCase();
|
|
26544
|
+
const isSemanticInteractiveTag = tagName === "a" && el.hasAttribute("href") || ["button", "input", "select", "textarea"].includes(tagName) && !el.hasAttribute("disabled");
|
|
26545
|
+
const isMeaningfullyInteractive = isTrulyInteractive && !(role === "generic" && !isVisuallyClickable);
|
|
26546
|
+
const interactive = isMeaningfullyInteractive || isWhitelisted || isLabelFor || isSemanticInteractiveTag || !ancestorIsInteractive && isVisuallyClickable && (role !== "generic" || name !== "");
|
|
26238
26547
|
let ref;
|
|
26239
26548
|
if (interactive) {
|
|
26240
26549
|
ref = refCounter.value;
|
|
@@ -26242,8 +26551,19 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
26242
26551
|
refCounter.value++;
|
|
26243
26552
|
}
|
|
26244
26553
|
const children = [];
|
|
26245
|
-
for (const child of
|
|
26246
|
-
const childVNode = buildVNode(
|
|
26554
|
+
for (const child of getComposedChildren(el)) {
|
|
26555
|
+
const childVNode = buildVNode(
|
|
26556
|
+
child,
|
|
26557
|
+
refCounter,
|
|
26558
|
+
refMap,
|
|
26559
|
+
blacklistSet,
|
|
26560
|
+
whitelistSet,
|
|
26561
|
+
exposedAttributes,
|
|
26562
|
+
errorSelectors,
|
|
26563
|
+
warningSelectors,
|
|
26564
|
+
// 将当前节点的交互性向下传递,子节点据此决定是否抑制 cursor=pointer
|
|
26565
|
+
interactive || ancestorIsInteractive
|
|
26566
|
+
);
|
|
26247
26567
|
if (childVNode) children.push(childVNode);
|
|
26248
26568
|
}
|
|
26249
26569
|
return { role, name, tokens, ref, el, children };
|
|
@@ -26252,6 +26572,19 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
26252
26572
|
if (vnode.ref !== void 0 || vnode.name.trim() !== "") return true;
|
|
26253
26573
|
return vnode.children.some(hasValue);
|
|
26254
26574
|
}
|
|
26575
|
+
function hasInteractiveDescendant(vnode) {
|
|
26576
|
+
return vnode.children.some((c) => c.ref !== void 0 || hasInteractiveDescendant(c));
|
|
26577
|
+
}
|
|
26578
|
+
function findSingleRefDescendant(vnode) {
|
|
26579
|
+
const refs = [];
|
|
26580
|
+
const collect = (v) => {
|
|
26581
|
+
if (v.ref !== void 0) refs.push(v);
|
|
26582
|
+
if (refs.length > 1) return;
|
|
26583
|
+
v.children.forEach(collect);
|
|
26584
|
+
};
|
|
26585
|
+
vnode.children.forEach(collect);
|
|
26586
|
+
return refs.length === 1 ? refs[0] : null;
|
|
26587
|
+
}
|
|
26255
26588
|
function shouldPassThrough(vnode, opts) {
|
|
26256
26589
|
if (!opts.pruneUnnamed) return false;
|
|
26257
26590
|
if (opts.preserveRoles.includes(vnode.role)) return false;
|
|
@@ -26263,17 +26596,196 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
26263
26596
|
if (shouldPassThrough(vnode, opts)) {
|
|
26264
26597
|
return vnode.children.filter((c) => hasValue(c)).flatMap((c) => serializeVNode(c, depth, opts));
|
|
26265
26598
|
}
|
|
26266
|
-
const indent = " ".repeat(depth);
|
|
26267
|
-
const refStr = vnode.ref !== void 0 ? ` #${vnode.ref}` : "";
|
|
26268
|
-
const
|
|
26269
|
-
const
|
|
26270
|
-
|
|
26271
|
-
|
|
26272
|
-
|
|
26273
|
-
|
|
26599
|
+
const indent = " ".repeat(depth);
|
|
26600
|
+
const refStr = vnode.ref !== void 0 ? ` #${vnode.ref}` : "";
|
|
26601
|
+
const safeTokens = vnode.tokens.map((t) => t.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"'));
|
|
26602
|
+
const tokenStr = safeTokens.length > 0 ? ` [${safeTokens.join(" ")}]` : "";
|
|
26603
|
+
if (vnode.ref !== void 0) {
|
|
26604
|
+
if (!hasInteractiveDescendant(vnode)) {
|
|
26605
|
+
const safeName2 = vnode.name ? vnode.name.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"') : "";
|
|
26606
|
+
const nameStr2 = safeName2 ? ` "${safeName2}"` : "";
|
|
26607
|
+
return [`${indent}- ${vnode.role}${refStr}${tokenStr}${nameStr2}`];
|
|
26608
|
+
}
|
|
26609
|
+
const singleChild = findSingleRefDescendant(vnode);
|
|
26610
|
+
if (singleChild && singleChild.role === "generic" && !hasInteractiveDescendant(singleChild)) {
|
|
26611
|
+
const mergedName = (vnode.name.trim() || singleChild.name.trim()).replace(/[\r\n]+/g, " ").replace(/"/g, '\\"');
|
|
26612
|
+
const nameStr2 = mergedName ? ` "${mergedName}"` : "";
|
|
26613
|
+
return [`${indent}- ${vnode.role}${refStr}${tokenStr}${nameStr2}`];
|
|
26614
|
+
}
|
|
26615
|
+
}
|
|
26616
|
+
const safeName = vnode.name ? vnode.name.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"') : "";
|
|
26617
|
+
const nameStr = safeName ? ` "${safeName}"` : "";
|
|
26618
|
+
const line = `${indent}- ${vnode.role}${refStr}${tokenStr}${nameStr}`;
|
|
26619
|
+
const childLines = vnode.children.flatMap((c) => serializeVNode(c, depth + 1, opts));
|
|
26620
|
+
return [line, ...childLines];
|
|
26621
|
+
}
|
|
26622
|
+
|
|
26623
|
+
// ../next-sdk/page-tools/page-agent-highlight/index.ts
|
|
26624
|
+
var HIGHLIGHT_CONTAINER_ID = "webmcpcli-highlight-container";
|
|
26625
|
+
var HIGHLIGHT_CONTAINER_STYLE_ID = "webmcpcli-highlight-container-style";
|
|
26626
|
+
var colors = [
|
|
26627
|
+
"#FF0000",
|
|
26628
|
+
"#00FF00",
|
|
26629
|
+
"#0000FF",
|
|
26630
|
+
"#FFA500",
|
|
26631
|
+
"#800080",
|
|
26632
|
+
"#008080",
|
|
26633
|
+
"#FF69B4",
|
|
26634
|
+
"#4B0082",
|
|
26635
|
+
"#FF4500",
|
|
26636
|
+
"#2E8B57",
|
|
26637
|
+
"#DC143C",
|
|
26638
|
+
"#4682B4"
|
|
26639
|
+
];
|
|
26640
|
+
var opacity = Math.floor(0.3 * 255).toString(16).padStart(2, "0");
|
|
26641
|
+
var injectStyles = `
|
|
26642
|
+
#${HIGHLIGHT_CONTAINER_ID} {
|
|
26643
|
+
position: fixed;
|
|
26644
|
+
pointer-events: none;
|
|
26645
|
+
top: 0;
|
|
26646
|
+
left: 0;
|
|
26647
|
+
width: 100%;
|
|
26648
|
+
height: 100%;
|
|
26649
|
+
z-index: 2147483640;
|
|
26650
|
+
background-color: transparent;
|
|
26651
|
+
}
|
|
26652
|
+
|
|
26653
|
+
#${HIGHLIGHT_CONTAINER_ID} div {
|
|
26654
|
+
position: fixed;
|
|
26655
|
+
pointer-events: none;
|
|
26656
|
+
background-color: transparent;
|
|
26657
|
+
text-align: right;
|
|
26658
|
+
box-sizing: border-box;
|
|
26659
|
+
border-radius: 4px;
|
|
26660
|
+
}
|
|
26661
|
+
|
|
26662
|
+
#${HIGHLIGHT_CONTAINER_ID} div span {
|
|
26663
|
+
display: inline-block;
|
|
26664
|
+
color: #fff;
|
|
26665
|
+
padding: 0 2px;
|
|
26666
|
+
border-radius: 4px;
|
|
26667
|
+
}
|
|
26668
|
+
`;
|
|
26669
|
+
function isElementViewport(element) {
|
|
26670
|
+
const rect = element.getBoundingClientRect();
|
|
26671
|
+
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
|
|
26672
|
+
}
|
|
26673
|
+
var doHighlight = (refMap, parentIframe = null) => {
|
|
26674
|
+
if (!document.head.querySelector(`#${HIGHLIGHT_CONTAINER_STYLE_ID}`)) {
|
|
26675
|
+
const style = document.head.appendChild(document.createElement("style"));
|
|
26676
|
+
style.id = HIGHLIGHT_CONTAINER_STYLE_ID;
|
|
26677
|
+
style.textContent = injectStyles;
|
|
26678
|
+
document.head.appendChild(style);
|
|
26679
|
+
}
|
|
26680
|
+
let container = document.getElementById(HIGHLIGHT_CONTAINER_ID);
|
|
26681
|
+
if (!container) {
|
|
26682
|
+
container = document.createElement("div");
|
|
26683
|
+
container.id = HIGHLIGHT_CONTAINER_ID;
|
|
26684
|
+
document.body.appendChild(container);
|
|
26685
|
+
} else {
|
|
26686
|
+
container.innerHTML = "";
|
|
26687
|
+
}
|
|
26688
|
+
let iframeOffset = { x: 0, y: 0 };
|
|
26689
|
+
if (parentIframe) {
|
|
26690
|
+
const iframeRect = parentIframe.getBoundingClientRect();
|
|
26691
|
+
iframeOffset.x = iframeRect.left;
|
|
26692
|
+
iframeOffset.y = iframeRect.top;
|
|
26693
|
+
}
|
|
26694
|
+
const fragment = document.createDocumentFragment();
|
|
26695
|
+
const overlays = [];
|
|
26696
|
+
for (const [index, el] of refMap.entries()) {
|
|
26697
|
+
if (!isElementViewport(el)) continue;
|
|
26698
|
+
const color = colors[index % colors.length];
|
|
26699
|
+
const textColor = color + opacity;
|
|
26700
|
+
const rect = el.getBoundingClientRect();
|
|
26701
|
+
if (rect.width === 0 || rect.height === 0) continue;
|
|
26702
|
+
const overlay = document.createElement("div");
|
|
26703
|
+
overlay.style.border = `2px solid ${textColor}`;
|
|
26704
|
+
const top = rect.top + iframeOffset.y;
|
|
26705
|
+
const left = rect.left + iframeOffset.x;
|
|
26706
|
+
overlay.style.top = `${top}px`;
|
|
26707
|
+
overlay.style.left = `${left}px`;
|
|
26708
|
+
overlay.style.width = `${rect.width}px`;
|
|
26709
|
+
overlay.style.height = `${rect.height}px`;
|
|
26710
|
+
const text = document.createElement("span");
|
|
26711
|
+
text.style.backgroundColor = textColor;
|
|
26712
|
+
text.style.height = `${rect.height - 4}px`;
|
|
26713
|
+
text.style.lineHeight = `${rect.height - 4}px`;
|
|
26714
|
+
text.textContent = index.toString();
|
|
26715
|
+
overlay.appendChild(text);
|
|
26716
|
+
fragment.appendChild(overlay);
|
|
26717
|
+
overlays.push({ element: overlay, initialRect: rect });
|
|
26718
|
+
}
|
|
26719
|
+
container.appendChild(fragment);
|
|
26720
|
+
};
|
|
26721
|
+
var highlight = (refMap, parentIframe = null) => {
|
|
26722
|
+
doHighlight(refMap, parentIframe);
|
|
26723
|
+
const updatePositions = () => doHighlight(refMap, parentIframe);
|
|
26724
|
+
const throttleFunction = (func, delay) => {
|
|
26725
|
+
let lastCall = 0;
|
|
26726
|
+
return (...args) => {
|
|
26727
|
+
const now = performance.now();
|
|
26728
|
+
if (now - lastCall < delay) return;
|
|
26729
|
+
lastCall = now;
|
|
26730
|
+
return func(...args);
|
|
26731
|
+
};
|
|
26732
|
+
};
|
|
26733
|
+
const throttledUpdatePositions = throttleFunction(updatePositions, 16);
|
|
26734
|
+
window.addEventListener("scroll", throttledUpdatePositions, true);
|
|
26735
|
+
window.addEventListener("resize", throttledUpdatePositions);
|
|
26736
|
+
const cleanupFn = () => {
|
|
26737
|
+
window.removeEventListener("scroll", throttledUpdatePositions, true);
|
|
26738
|
+
window.removeEventListener("resize", throttledUpdatePositions);
|
|
26739
|
+
};
|
|
26740
|
+
const win = window;
|
|
26741
|
+
(win._highlightCleanupFunctions = win._highlightCleanupFunctions || []).push(cleanupFn);
|
|
26742
|
+
};
|
|
26743
|
+
var unhighlight = () => {
|
|
26744
|
+
document.getElementById(HIGHLIGHT_CONTAINER_ID)?.remove();
|
|
26745
|
+
const cleanupFunctions = window._highlightCleanupFunctions || [];
|
|
26746
|
+
for (const cleanup of cleanupFunctions) {
|
|
26747
|
+
if (typeof cleanup === "function") {
|
|
26748
|
+
cleanup();
|
|
26749
|
+
}
|
|
26750
|
+
}
|
|
26751
|
+
;
|
|
26752
|
+
window._highlightCleanupFunctions = [];
|
|
26753
|
+
};
|
|
26754
|
+
var globalRemoveListener = () => {
|
|
26755
|
+
if (window.__registerGlobalRemoveListener) return;
|
|
26756
|
+
window.__registerGlobalRemoveListener = true;
|
|
26757
|
+
window.addEventListener("popstate", () => {
|
|
26758
|
+
unhighlight();
|
|
26759
|
+
});
|
|
26760
|
+
window.addEventListener("hashchange", () => {
|
|
26761
|
+
unhighlight();
|
|
26762
|
+
});
|
|
26763
|
+
window.addEventListener("beforeunload", () => {
|
|
26764
|
+
unhighlight();
|
|
26765
|
+
});
|
|
26766
|
+
const navigation2 = window.navigation;
|
|
26767
|
+
if (navigation2 && typeof navigation2.addEventListener === "function") {
|
|
26768
|
+
navigation2.addEventListener("navigate", () => {
|
|
26769
|
+
unhighlight();
|
|
26770
|
+
});
|
|
26771
|
+
} else {
|
|
26772
|
+
let currentUrl = window.location.href;
|
|
26773
|
+
setInterval(() => {
|
|
26774
|
+
if (window.location.href !== currentUrl) {
|
|
26775
|
+
currentUrl = window.location.href;
|
|
26776
|
+
unhighlight();
|
|
26777
|
+
}
|
|
26778
|
+
}, 500);
|
|
26779
|
+
}
|
|
26780
|
+
};
|
|
26781
|
+
|
|
26782
|
+
// ../next-sdk/page-tools/a11y/build.ts
|
|
26274
26783
|
var DEFAULT_OPTIONS = {
|
|
26275
26784
|
pruneUnnamed: true,
|
|
26276
|
-
preserveRoles: []
|
|
26785
|
+
preserveRoles: [],
|
|
26786
|
+
exposedAttributes: [],
|
|
26787
|
+
errorSelectors: DEFAULT_ERROR_SELECTORS,
|
|
26788
|
+
warningSelectors: DEFAULT_WARNING_SELECTORS
|
|
26277
26789
|
};
|
|
26278
26790
|
function buildA11yTree(root = document.body, blacklist = [], whitelist = [], options) {
|
|
26279
26791
|
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
@@ -26282,8 +26794,18 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
26282
26794
|
const blacklistSet = new Set(blacklist);
|
|
26283
26795
|
const whitelistSet = new Set(whitelist);
|
|
26284
26796
|
const lines = [];
|
|
26285
|
-
|
|
26286
|
-
|
|
26797
|
+
blacklistSet.add(document.getElementById(HIGHLIGHT_CONTAINER_ID));
|
|
26798
|
+
for (const child of getComposedChildren(root)) {
|
|
26799
|
+
const vnode = buildVNode(
|
|
26800
|
+
child,
|
|
26801
|
+
refCounter,
|
|
26802
|
+
refMap,
|
|
26803
|
+
blacklistSet,
|
|
26804
|
+
whitelistSet,
|
|
26805
|
+
opts.exposedAttributes,
|
|
26806
|
+
opts.errorSelectors,
|
|
26807
|
+
opts.warningSelectors
|
|
26808
|
+
);
|
|
26287
26809
|
if (vnode) {
|
|
26288
26810
|
lines.push(...serializeVNode(vnode, 0, opts));
|
|
26289
26811
|
}
|
|
@@ -26296,6 +26818,8 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
26296
26818
|
lines
|
|
26297
26819
|
};
|
|
26298
26820
|
}
|
|
26821
|
+
|
|
26822
|
+
// ../next-sdk/page-tools/a11y/search.ts
|
|
26299
26823
|
function searchA11yTree(query, root = document.body, blacklist = [], whitelist = [], options) {
|
|
26300
26824
|
const {
|
|
26301
26825
|
contextLines = 2,
|
|
@@ -26303,7 +26827,9 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
26303
26827
|
maxMatches = 20,
|
|
26304
26828
|
...treeOptions
|
|
26305
26829
|
} = options ?? {};
|
|
26306
|
-
const
|
|
26830
|
+
const safeContextLines = Math.max(0, contextLines);
|
|
26831
|
+
const safeMaxMatches = Math.max(1, maxMatches);
|
|
26832
|
+
const { lines, refMap, yaml } = buildA11yTree(root, blacklist, whitelist, treeOptions);
|
|
26307
26833
|
const needle = caseInsensitive ? query.toLowerCase() : query;
|
|
26308
26834
|
const totalLines = lines.length;
|
|
26309
26835
|
const isRefQuery = /^#\d+$/.test(query);
|
|
@@ -26324,14 +26850,14 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
26324
26850
|
const mergedRanges = [];
|
|
26325
26851
|
let isTruncated = false;
|
|
26326
26852
|
for (const idx of hitIndices) {
|
|
26327
|
-
const start = Math.max(0, idx -
|
|
26328
|
-
const end = Math.min(totalLines - 1, idx +
|
|
26853
|
+
const start = Math.max(0, idx - safeContextLines);
|
|
26854
|
+
const end = Math.min(totalLines - 1, idx + safeContextLines);
|
|
26329
26855
|
const last = mergedRanges[mergedRanges.length - 1];
|
|
26330
26856
|
if (last && start <= last.end + 1) {
|
|
26331
26857
|
last.end = Math.max(last.end, end);
|
|
26332
26858
|
last.hits.push(idx);
|
|
26333
26859
|
} else {
|
|
26334
|
-
if (mergedRanges.length >=
|
|
26860
|
+
if (mergedRanges.length >= safeMaxMatches) {
|
|
26335
26861
|
isTruncated = true;
|
|
26336
26862
|
break;
|
|
26337
26863
|
}
|
|
@@ -26364,7 +26890,7 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
26364
26890
|
textParts.push("");
|
|
26365
26891
|
});
|
|
26366
26892
|
if (isTruncated) {
|
|
26367
|
-
textParts.push(`\u26A0\uFE0F \u547D\u4E2D\u8FC7\u591A\uFF0C\u5DF2\u622A\u65AD\u81F3\u524D ${
|
|
26893
|
+
textParts.push(`\u26A0\uFE0F \u547D\u4E2D\u8FC7\u591A\uFF0C\u5DF2\u622A\u65AD\u81F3\u524D ${safeMaxMatches} \u4E2A\u5206\u7EC4\uFF0C\u5EFA\u8BAE\u7F29\u5C0F\u641C\u7D22\u8303\u56F4`);
|
|
26368
26894
|
}
|
|
26369
26895
|
textParts.push(`\u63D0\u793A\uFF1A\u5982\u9700\u64CD\u4F5C\u547D\u4E2D\u5143\u7D20\uFF0C\u4F7F\u7528\u5176 #N \u7D22\u5F15\uFF1B\u5982\u9700\u67E5\u770B\u5B8C\u6574\u6811\uFF0C\u8BF7\u4F7F\u7528 browserState\u3002`);
|
|
26370
26896
|
}
|
|
@@ -26372,7 +26898,9 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
26372
26898
|
text: textParts.join("\n"),
|
|
26373
26899
|
matches: matches2,
|
|
26374
26900
|
totalLines,
|
|
26375
|
-
matchCount: hitIndices.length
|
|
26901
|
+
matchCount: hitIndices.length,
|
|
26902
|
+
refMap,
|
|
26903
|
+
yaml
|
|
26376
26904
|
};
|
|
26377
26905
|
}
|
|
26378
26906
|
|
|
@@ -26557,467 +27085,1265 @@ ${pi.pixels_above > 4 && viewportExpansion !== -1 ? `... ${pi.pixels_above} pixe
|
|
|
26557
27085
|
return changeObjects;
|
|
26558
27086
|
}
|
|
26559
27087
|
};
|
|
26560
|
-
function buildValues(diff2, lastComponent, newString, oldString, useLongestToken) {
|
|
26561
|
-
var components = [];
|
|
26562
|
-
var nextComponent;
|
|
26563
|
-
while (lastComponent) {
|
|
26564
|
-
components.push(lastComponent);
|
|
26565
|
-
nextComponent = lastComponent.previousComponent;
|
|
26566
|
-
delete lastComponent.previousComponent;
|
|
26567
|
-
lastComponent = nextComponent;
|
|
27088
|
+
function buildValues(diff2, lastComponent, newString, oldString, useLongestToken) {
|
|
27089
|
+
var components = [];
|
|
27090
|
+
var nextComponent;
|
|
27091
|
+
while (lastComponent) {
|
|
27092
|
+
components.push(lastComponent);
|
|
27093
|
+
nextComponent = lastComponent.previousComponent;
|
|
27094
|
+
delete lastComponent.previousComponent;
|
|
27095
|
+
lastComponent = nextComponent;
|
|
27096
|
+
}
|
|
27097
|
+
components.reverse();
|
|
27098
|
+
var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
|
|
27099
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
27100
|
+
var component = components[componentPos];
|
|
27101
|
+
if (!component.removed) {
|
|
27102
|
+
if (!component.added && useLongestToken) {
|
|
27103
|
+
var value = newString.slice(newPos, newPos + component.count);
|
|
27104
|
+
value = value.map(function(value2, i) {
|
|
27105
|
+
var oldValue = oldString[oldPos + i];
|
|
27106
|
+
return oldValue.length > value2.length ? oldValue : value2;
|
|
27107
|
+
});
|
|
27108
|
+
component.value = diff2.join(value);
|
|
27109
|
+
} else {
|
|
27110
|
+
component.value = diff2.join(newString.slice(newPos, newPos + component.count));
|
|
27111
|
+
}
|
|
27112
|
+
newPos += component.count;
|
|
27113
|
+
if (!component.added) {
|
|
27114
|
+
oldPos += component.count;
|
|
27115
|
+
}
|
|
27116
|
+
} else {
|
|
27117
|
+
component.value = diff2.join(oldString.slice(oldPos, oldPos + component.count));
|
|
27118
|
+
oldPos += component.count;
|
|
27119
|
+
}
|
|
27120
|
+
}
|
|
27121
|
+
return components;
|
|
27122
|
+
}
|
|
27123
|
+
var characterDiff = new Diff();
|
|
27124
|
+
function longestCommonPrefix(str1, str2) {
|
|
27125
|
+
var i;
|
|
27126
|
+
for (i = 0; i < str1.length && i < str2.length; i++) {
|
|
27127
|
+
if (str1[i] != str2[i]) {
|
|
27128
|
+
return str1.slice(0, i);
|
|
27129
|
+
}
|
|
27130
|
+
}
|
|
27131
|
+
return str1.slice(0, i);
|
|
27132
|
+
}
|
|
27133
|
+
function longestCommonSuffix(str1, str2) {
|
|
27134
|
+
var i;
|
|
27135
|
+
if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
|
|
27136
|
+
return "";
|
|
27137
|
+
}
|
|
27138
|
+
for (i = 0; i < str1.length && i < str2.length; i++) {
|
|
27139
|
+
if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
|
|
27140
|
+
return str1.slice(-i);
|
|
27141
|
+
}
|
|
27142
|
+
}
|
|
27143
|
+
return str1.slice(-i);
|
|
27144
|
+
}
|
|
27145
|
+
function replacePrefix(string4, oldPrefix, newPrefix) {
|
|
27146
|
+
if (string4.slice(0, oldPrefix.length) != oldPrefix) {
|
|
27147
|
+
throw Error("string ".concat(JSON.stringify(string4), " doesn't start with prefix ").concat(JSON.stringify(oldPrefix), "; this is a bug"));
|
|
27148
|
+
}
|
|
27149
|
+
return newPrefix + string4.slice(oldPrefix.length);
|
|
27150
|
+
}
|
|
27151
|
+
function replaceSuffix(string4, oldSuffix, newSuffix) {
|
|
27152
|
+
if (!oldSuffix) {
|
|
27153
|
+
return string4 + newSuffix;
|
|
27154
|
+
}
|
|
27155
|
+
if (string4.slice(-oldSuffix.length) != oldSuffix) {
|
|
27156
|
+
throw Error("string ".concat(JSON.stringify(string4), " doesn't end with suffix ").concat(JSON.stringify(oldSuffix), "; this is a bug"));
|
|
27157
|
+
}
|
|
27158
|
+
return string4.slice(0, -oldSuffix.length) + newSuffix;
|
|
27159
|
+
}
|
|
27160
|
+
function removePrefix(string4, oldPrefix) {
|
|
27161
|
+
return replacePrefix(string4, oldPrefix, "");
|
|
27162
|
+
}
|
|
27163
|
+
function removeSuffix(string4, oldSuffix) {
|
|
27164
|
+
return replaceSuffix(string4, oldSuffix, "");
|
|
27165
|
+
}
|
|
27166
|
+
function maximumOverlap(string1, string22) {
|
|
27167
|
+
return string22.slice(0, overlapCount(string1, string22));
|
|
27168
|
+
}
|
|
27169
|
+
function overlapCount(a, b) {
|
|
27170
|
+
var startA = 0;
|
|
27171
|
+
if (a.length > b.length) {
|
|
27172
|
+
startA = a.length - b.length;
|
|
27173
|
+
}
|
|
27174
|
+
var endB = b.length;
|
|
27175
|
+
if (a.length < b.length) {
|
|
27176
|
+
endB = a.length;
|
|
27177
|
+
}
|
|
27178
|
+
var map = Array(endB);
|
|
27179
|
+
var k = 0;
|
|
27180
|
+
map[0] = 0;
|
|
27181
|
+
for (var j = 1; j < endB; j++) {
|
|
27182
|
+
if (b[j] == b[k]) {
|
|
27183
|
+
map[j] = map[k];
|
|
27184
|
+
} else {
|
|
27185
|
+
map[j] = k;
|
|
27186
|
+
}
|
|
27187
|
+
while (k > 0 && b[j] != b[k]) {
|
|
27188
|
+
k = map[k];
|
|
27189
|
+
}
|
|
27190
|
+
if (b[j] == b[k]) {
|
|
27191
|
+
k++;
|
|
27192
|
+
}
|
|
27193
|
+
}
|
|
27194
|
+
k = 0;
|
|
27195
|
+
for (var i = startA; i < a.length; i++) {
|
|
27196
|
+
while (k > 0 && a[i] != b[k]) {
|
|
27197
|
+
k = map[k];
|
|
27198
|
+
}
|
|
27199
|
+
if (a[i] == b[k]) {
|
|
27200
|
+
k++;
|
|
27201
|
+
}
|
|
27202
|
+
}
|
|
27203
|
+
return k;
|
|
27204
|
+
}
|
|
27205
|
+
var extendedWordChars = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
|
|
27206
|
+
var tokenizeIncludingWhitespace = new RegExp("[".concat(extendedWordChars, "]+|\\s+|[^").concat(extendedWordChars, "]"), "ug");
|
|
27207
|
+
var wordDiff = new Diff();
|
|
27208
|
+
wordDiff.equals = function(left, right, options) {
|
|
27209
|
+
if (options.ignoreCase) {
|
|
27210
|
+
left = left.toLowerCase();
|
|
27211
|
+
right = right.toLowerCase();
|
|
27212
|
+
}
|
|
27213
|
+
return left.trim() === right.trim();
|
|
27214
|
+
};
|
|
27215
|
+
wordDiff.tokenize = function(value) {
|
|
27216
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
27217
|
+
var parts;
|
|
27218
|
+
if (options.intlSegmenter) {
|
|
27219
|
+
if (options.intlSegmenter.resolvedOptions().granularity != "word") {
|
|
27220
|
+
throw new Error('The segmenter passed must have a granularity of "word"');
|
|
27221
|
+
}
|
|
27222
|
+
parts = Array.from(options.intlSegmenter.segment(value), function(segment) {
|
|
27223
|
+
return segment.segment;
|
|
27224
|
+
});
|
|
27225
|
+
} else {
|
|
27226
|
+
parts = value.match(tokenizeIncludingWhitespace) || [];
|
|
27227
|
+
}
|
|
27228
|
+
var tokens = [];
|
|
27229
|
+
var prevPart = null;
|
|
27230
|
+
parts.forEach(function(part) {
|
|
27231
|
+
if (/\s/.test(part)) {
|
|
27232
|
+
if (prevPart == null) {
|
|
27233
|
+
tokens.push(part);
|
|
27234
|
+
} else {
|
|
27235
|
+
tokens.push(tokens.pop() + part);
|
|
27236
|
+
}
|
|
27237
|
+
} else if (/\s/.test(prevPart)) {
|
|
27238
|
+
if (tokens[tokens.length - 1] == prevPart) {
|
|
27239
|
+
tokens.push(tokens.pop() + part);
|
|
27240
|
+
} else {
|
|
27241
|
+
tokens.push(prevPart + part);
|
|
27242
|
+
}
|
|
27243
|
+
} else {
|
|
27244
|
+
tokens.push(part);
|
|
27245
|
+
}
|
|
27246
|
+
prevPart = part;
|
|
27247
|
+
});
|
|
27248
|
+
return tokens;
|
|
27249
|
+
};
|
|
27250
|
+
wordDiff.join = function(tokens) {
|
|
27251
|
+
return tokens.map(function(token, i) {
|
|
27252
|
+
if (i == 0) {
|
|
27253
|
+
return token;
|
|
27254
|
+
} else {
|
|
27255
|
+
return token.replace(/^\s+/, "");
|
|
27256
|
+
}
|
|
27257
|
+
}).join("");
|
|
27258
|
+
};
|
|
27259
|
+
wordDiff.postProcess = function(changes, options) {
|
|
27260
|
+
if (!changes || options.oneChangePerToken) {
|
|
27261
|
+
return changes;
|
|
27262
|
+
}
|
|
27263
|
+
var lastKeep = null;
|
|
27264
|
+
var insertion = null;
|
|
27265
|
+
var deletion = null;
|
|
27266
|
+
changes.forEach(function(change) {
|
|
27267
|
+
if (change.added) {
|
|
27268
|
+
insertion = change;
|
|
27269
|
+
} else if (change.removed) {
|
|
27270
|
+
deletion = change;
|
|
27271
|
+
} else {
|
|
27272
|
+
if (insertion || deletion) {
|
|
27273
|
+
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
|
|
27274
|
+
}
|
|
27275
|
+
lastKeep = change;
|
|
27276
|
+
insertion = null;
|
|
27277
|
+
deletion = null;
|
|
27278
|
+
}
|
|
27279
|
+
});
|
|
27280
|
+
if (insertion || deletion) {
|
|
27281
|
+
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
|
|
27282
|
+
}
|
|
27283
|
+
return changes;
|
|
27284
|
+
};
|
|
27285
|
+
function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
|
|
27286
|
+
if (deletion && insertion) {
|
|
27287
|
+
var oldWsPrefix = deletion.value.match(/^\s*/)[0];
|
|
27288
|
+
var oldWsSuffix = deletion.value.match(/\s*$/)[0];
|
|
27289
|
+
var newWsPrefix = insertion.value.match(/^\s*/)[0];
|
|
27290
|
+
var newWsSuffix = insertion.value.match(/\s*$/)[0];
|
|
27291
|
+
if (startKeep) {
|
|
27292
|
+
var commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
|
|
27293
|
+
startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
|
|
27294
|
+
deletion.value = removePrefix(deletion.value, commonWsPrefix);
|
|
27295
|
+
insertion.value = removePrefix(insertion.value, commonWsPrefix);
|
|
27296
|
+
}
|
|
27297
|
+
if (endKeep) {
|
|
27298
|
+
var commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
|
|
27299
|
+
endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
|
|
27300
|
+
deletion.value = removeSuffix(deletion.value, commonWsSuffix);
|
|
27301
|
+
insertion.value = removeSuffix(insertion.value, commonWsSuffix);
|
|
27302
|
+
}
|
|
27303
|
+
} else if (insertion) {
|
|
27304
|
+
if (startKeep) {
|
|
27305
|
+
insertion.value = insertion.value.replace(/^\s*/, "");
|
|
27306
|
+
}
|
|
27307
|
+
if (endKeep) {
|
|
27308
|
+
endKeep.value = endKeep.value.replace(/^\s*/, "");
|
|
27309
|
+
}
|
|
27310
|
+
} else if (startKeep && endKeep) {
|
|
27311
|
+
var newWsFull = endKeep.value.match(/^\s*/)[0], delWsStart = deletion.value.match(/^\s*/)[0], delWsEnd = deletion.value.match(/\s*$/)[0];
|
|
27312
|
+
var newWsStart = longestCommonPrefix(newWsFull, delWsStart);
|
|
27313
|
+
deletion.value = removePrefix(deletion.value, newWsStart);
|
|
27314
|
+
var newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
|
|
27315
|
+
deletion.value = removeSuffix(deletion.value, newWsEnd);
|
|
27316
|
+
endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
|
|
27317
|
+
startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
|
|
27318
|
+
} else if (endKeep) {
|
|
27319
|
+
var endKeepWsPrefix = endKeep.value.match(/^\s*/)[0];
|
|
27320
|
+
var deletionWsSuffix = deletion.value.match(/\s*$/)[0];
|
|
27321
|
+
var overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
|
|
27322
|
+
deletion.value = removeSuffix(deletion.value, overlap);
|
|
27323
|
+
} else if (startKeep) {
|
|
27324
|
+
var startKeepWsSuffix = startKeep.value.match(/\s*$/)[0];
|
|
27325
|
+
var deletionWsPrefix = deletion.value.match(/^\s*/)[0];
|
|
27326
|
+
var _overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
|
|
27327
|
+
deletion.value = removePrefix(deletion.value, _overlap);
|
|
27328
|
+
}
|
|
27329
|
+
}
|
|
27330
|
+
var wordWithSpaceDiff = new Diff();
|
|
27331
|
+
wordWithSpaceDiff.tokenize = function(value) {
|
|
27332
|
+
var regex2 = new RegExp("(\\r?\\n)|[".concat(extendedWordChars, "]+|[^\\S\\n\\r]+|[^").concat(extendedWordChars, "]"), "ug");
|
|
27333
|
+
return value.match(regex2) || [];
|
|
27334
|
+
};
|
|
27335
|
+
var lineDiff = new Diff();
|
|
27336
|
+
lineDiff.tokenize = function(value, options) {
|
|
27337
|
+
if (options.stripTrailingCr) {
|
|
27338
|
+
value = value.replace(/\r\n/g, "\n");
|
|
26568
27339
|
}
|
|
26569
|
-
|
|
26570
|
-
|
|
26571
|
-
|
|
26572
|
-
|
|
26573
|
-
|
|
26574
|
-
|
|
26575
|
-
|
|
26576
|
-
|
|
26577
|
-
var oldValue = oldString[oldPos + i];
|
|
26578
|
-
return oldValue.length > value2.length ? oldValue : value2;
|
|
26579
|
-
});
|
|
26580
|
-
component.value = diff2.join(value);
|
|
26581
|
-
} else {
|
|
26582
|
-
component.value = diff2.join(newString.slice(newPos, newPos + component.count));
|
|
26583
|
-
}
|
|
26584
|
-
newPos += component.count;
|
|
26585
|
-
if (!component.added) {
|
|
26586
|
-
oldPos += component.count;
|
|
26587
|
-
}
|
|
27340
|
+
var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
27341
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
27342
|
+
linesAndNewlines.pop();
|
|
27343
|
+
}
|
|
27344
|
+
for (var i = 0; i < linesAndNewlines.length; i++) {
|
|
27345
|
+
var line = linesAndNewlines[i];
|
|
27346
|
+
if (i % 2 && !options.newlineIsToken) {
|
|
27347
|
+
retLines[retLines.length - 1] += line;
|
|
26588
27348
|
} else {
|
|
26589
|
-
|
|
26590
|
-
oldPos += component.count;
|
|
27349
|
+
retLines.push(line);
|
|
26591
27350
|
}
|
|
26592
27351
|
}
|
|
26593
|
-
return
|
|
26594
|
-
}
|
|
26595
|
-
|
|
26596
|
-
|
|
26597
|
-
|
|
26598
|
-
|
|
26599
|
-
if (str1[i] != str2[i]) {
|
|
26600
|
-
return str1.slice(0, i);
|
|
27352
|
+
return retLines;
|
|
27353
|
+
};
|
|
27354
|
+
lineDiff.equals = function(left, right, options) {
|
|
27355
|
+
if (options.ignoreWhitespace) {
|
|
27356
|
+
if (!options.newlineIsToken || !left.includes("\n")) {
|
|
27357
|
+
left = left.trim();
|
|
26601
27358
|
}
|
|
26602
|
-
|
|
26603
|
-
|
|
26604
|
-
|
|
26605
|
-
|
|
26606
|
-
|
|
26607
|
-
|
|
26608
|
-
|
|
26609
|
-
|
|
26610
|
-
|
|
26611
|
-
if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
|
|
26612
|
-
return str1.slice(-i);
|
|
27359
|
+
if (!options.newlineIsToken || !right.includes("\n")) {
|
|
27360
|
+
right = right.trim();
|
|
27361
|
+
}
|
|
27362
|
+
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
27363
|
+
if (left.endsWith("\n")) {
|
|
27364
|
+
left = left.slice(0, -1);
|
|
27365
|
+
}
|
|
27366
|
+
if (right.endsWith("\n")) {
|
|
27367
|
+
right = right.slice(0, -1);
|
|
26613
27368
|
}
|
|
26614
27369
|
}
|
|
26615
|
-
return
|
|
27370
|
+
return Diff.prototype.equals.call(this, left, right, options);
|
|
27371
|
+
};
|
|
27372
|
+
function diffLines(oldStr, newStr, callback) {
|
|
27373
|
+
return lineDiff.diff(oldStr, newStr, callback);
|
|
26616
27374
|
}
|
|
26617
|
-
|
|
26618
|
-
|
|
26619
|
-
|
|
26620
|
-
|
|
26621
|
-
|
|
27375
|
+
var sentenceDiff = new Diff();
|
|
27376
|
+
sentenceDiff.tokenize = function(value) {
|
|
27377
|
+
return value.split(/(\S.+?[.!?])(?=\s+|$)/);
|
|
27378
|
+
};
|
|
27379
|
+
var cssDiff = new Diff();
|
|
27380
|
+
cssDiff.tokenize = function(value) {
|
|
27381
|
+
return value.split(/([{}:;,]|\s+)/);
|
|
27382
|
+
};
|
|
27383
|
+
function _typeof2(o) {
|
|
27384
|
+
"@babel/helpers - typeof";
|
|
27385
|
+
return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
27386
|
+
return typeof o2;
|
|
27387
|
+
} : function(o2) {
|
|
27388
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
27389
|
+
}, _typeof2(o);
|
|
26622
27390
|
}
|
|
26623
|
-
|
|
26624
|
-
|
|
26625
|
-
|
|
27391
|
+
var jsonDiff = new Diff();
|
|
27392
|
+
jsonDiff.useLongestToken = true;
|
|
27393
|
+
jsonDiff.tokenize = lineDiff.tokenize;
|
|
27394
|
+
jsonDiff.castInput = function(value, options) {
|
|
27395
|
+
var undefinedReplacement = options.undefinedReplacement, _options$stringifyRep = options.stringifyReplacer, stringifyReplacer = _options$stringifyRep === void 0 ? function(k, v) {
|
|
27396
|
+
return typeof v === "undefined" ? undefinedReplacement : v;
|
|
27397
|
+
} : _options$stringifyRep;
|
|
27398
|
+
return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, " ");
|
|
27399
|
+
};
|
|
27400
|
+
jsonDiff.equals = function(left, right, options) {
|
|
27401
|
+
return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
|
|
27402
|
+
};
|
|
27403
|
+
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
27404
|
+
stack = stack || [];
|
|
27405
|
+
replacementStack = replacementStack || [];
|
|
27406
|
+
if (replacer) {
|
|
27407
|
+
obj = replacer(key, obj);
|
|
26626
27408
|
}
|
|
26627
|
-
|
|
26628
|
-
|
|
27409
|
+
var i;
|
|
27410
|
+
for (i = 0; i < stack.length; i += 1) {
|
|
27411
|
+
if (stack[i] === obj) {
|
|
27412
|
+
return replacementStack[i];
|
|
27413
|
+
}
|
|
26629
27414
|
}
|
|
26630
|
-
|
|
26631
|
-
|
|
26632
|
-
|
|
26633
|
-
|
|
26634
|
-
|
|
26635
|
-
|
|
26636
|
-
|
|
26637
|
-
|
|
26638
|
-
|
|
26639
|
-
|
|
26640
|
-
|
|
26641
|
-
function overlapCount(a, b) {
|
|
26642
|
-
var startA = 0;
|
|
26643
|
-
if (a.length > b.length) {
|
|
26644
|
-
startA = a.length - b.length;
|
|
27415
|
+
var canonicalizedObj;
|
|
27416
|
+
if ("[object Array]" === Object.prototype.toString.call(obj)) {
|
|
27417
|
+
stack.push(obj);
|
|
27418
|
+
canonicalizedObj = new Array(obj.length);
|
|
27419
|
+
replacementStack.push(canonicalizedObj);
|
|
27420
|
+
for (i = 0; i < obj.length; i += 1) {
|
|
27421
|
+
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
|
|
27422
|
+
}
|
|
27423
|
+
stack.pop();
|
|
27424
|
+
replacementStack.pop();
|
|
27425
|
+
return canonicalizedObj;
|
|
26645
27426
|
}
|
|
26646
|
-
|
|
26647
|
-
|
|
26648
|
-
endB = a.length;
|
|
27427
|
+
if (obj && obj.toJSON) {
|
|
27428
|
+
obj = obj.toJSON();
|
|
26649
27429
|
}
|
|
26650
|
-
|
|
26651
|
-
|
|
26652
|
-
|
|
26653
|
-
|
|
26654
|
-
|
|
26655
|
-
|
|
26656
|
-
|
|
26657
|
-
|
|
26658
|
-
|
|
26659
|
-
while (k > 0 && b[j] != b[k]) {
|
|
26660
|
-
k = map[k];
|
|
27430
|
+
if (_typeof2(obj) === "object" && obj !== null) {
|
|
27431
|
+
stack.push(obj);
|
|
27432
|
+
canonicalizedObj = {};
|
|
27433
|
+
replacementStack.push(canonicalizedObj);
|
|
27434
|
+
var sortedKeys = [], _key;
|
|
27435
|
+
for (_key in obj) {
|
|
27436
|
+
if (Object.prototype.hasOwnProperty.call(obj, _key)) {
|
|
27437
|
+
sortedKeys.push(_key);
|
|
27438
|
+
}
|
|
26661
27439
|
}
|
|
26662
|
-
|
|
26663
|
-
|
|
27440
|
+
sortedKeys.sort();
|
|
27441
|
+
for (i = 0; i < sortedKeys.length; i += 1) {
|
|
27442
|
+
_key = sortedKeys[i];
|
|
27443
|
+
canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
|
|
26664
27444
|
}
|
|
27445
|
+
stack.pop();
|
|
27446
|
+
replacementStack.pop();
|
|
27447
|
+
} else {
|
|
27448
|
+
canonicalizedObj = obj;
|
|
26665
27449
|
}
|
|
26666
|
-
|
|
26667
|
-
|
|
26668
|
-
|
|
26669
|
-
|
|
26670
|
-
|
|
26671
|
-
|
|
26672
|
-
|
|
27450
|
+
return canonicalizedObj;
|
|
27451
|
+
}
|
|
27452
|
+
var arrayDiff = new Diff();
|
|
27453
|
+
arrayDiff.tokenize = function(value) {
|
|
27454
|
+
return value.slice();
|
|
27455
|
+
};
|
|
27456
|
+
arrayDiff.join = arrayDiff.removeEmpty = function(value) {
|
|
27457
|
+
return value;
|
|
27458
|
+
};
|
|
27459
|
+
|
|
27460
|
+
// ../next-sdk/page-tools/page-state-cache.ts
|
|
27461
|
+
var PageStateCache = class {
|
|
27462
|
+
constructor() {
|
|
27463
|
+
this.prev = null;
|
|
27464
|
+
}
|
|
27465
|
+
/** URL 变化或首次调用时,需要全量输出 */
|
|
27466
|
+
isFullRefresh(currentUrl) {
|
|
27467
|
+
return !this.prev || this.prev.url !== currentUrl;
|
|
27468
|
+
}
|
|
27469
|
+
/**
|
|
27470
|
+
* 更新缓存并返回 diff 结果
|
|
27471
|
+
* @param url 当前页面 URL
|
|
27472
|
+
* @param yaml 当前 YAML 树文本
|
|
27473
|
+
*/
|
|
27474
|
+
update(url2, yaml) {
|
|
27475
|
+
const isFullRefresh = this.isFullRefresh(url2);
|
|
27476
|
+
const prevUrl = this.prev?.url ?? "";
|
|
27477
|
+
let addedLines = 0;
|
|
27478
|
+
let removedLines = 0;
|
|
27479
|
+
let diffText = "";
|
|
27480
|
+
if (!isFullRefresh && this.prev) {
|
|
27481
|
+
const changes = diffLines(this.prev.yaml, yaml);
|
|
27482
|
+
const buf = [];
|
|
27483
|
+
changes.forEach((part) => {
|
|
27484
|
+
if (!part.added && !part.removed) return;
|
|
27485
|
+
const lines = part.value.split("\n").filter(Boolean);
|
|
27486
|
+
if (part.added) {
|
|
27487
|
+
addedLines += lines.length;
|
|
27488
|
+
lines.forEach((l) => buf.push(`+ ${l}`));
|
|
27489
|
+
} else {
|
|
27490
|
+
removedLines += lines.length;
|
|
27491
|
+
lines.forEach((l) => buf.push(`- ${l}`));
|
|
27492
|
+
}
|
|
27493
|
+
});
|
|
27494
|
+
diffText = buf.join("\n");
|
|
26673
27495
|
}
|
|
27496
|
+
this.prev = { url: url2, yaml };
|
|
27497
|
+
return { isFullRefresh, prevUrl, addedLines, removedLines, diffText };
|
|
26674
27498
|
}
|
|
26675
|
-
|
|
26676
|
-
|
|
26677
|
-
|
|
26678
|
-
var tokenizeIncludingWhitespace = new RegExp("[".concat(extendedWordChars, "]+|\\s+|[^").concat(extendedWordChars, "]"), "ug");
|
|
26679
|
-
var wordDiff = new Diff();
|
|
26680
|
-
wordDiff.equals = function(left, right, options) {
|
|
26681
|
-
if (options.ignoreCase) {
|
|
26682
|
-
left = left.toLowerCase();
|
|
26683
|
-
right = right.toLowerCase();
|
|
27499
|
+
/** 强制清空缓存(页面刷新 / 手动重置场景) */
|
|
27500
|
+
invalidate() {
|
|
27501
|
+
this.prev = null;
|
|
26684
27502
|
}
|
|
26685
|
-
return left.trim() === right.trim();
|
|
26686
27503
|
};
|
|
26687
|
-
|
|
26688
|
-
|
|
26689
|
-
|
|
26690
|
-
|
|
26691
|
-
|
|
26692
|
-
|
|
26693
|
-
|
|
26694
|
-
|
|
26695
|
-
|
|
26696
|
-
|
|
26697
|
-
|
|
26698
|
-
|
|
27504
|
+
|
|
27505
|
+
// ../next-sdk/page-tools/page-agent-mask/SimulatorMask.ts
|
|
27506
|
+
init_Motion();
|
|
27507
|
+
|
|
27508
|
+
// ../next-sdk/page-tools/page-agent-mask/checkDarkMode.ts
|
|
27509
|
+
function isPageDark2() {
|
|
27510
|
+
try {
|
|
27511
|
+
if (hasDarkModeClass2()) return true;
|
|
27512
|
+
if (hasDarkModeDataAttribute2()) return true;
|
|
27513
|
+
if (isColorSchemeDark2()) return true;
|
|
27514
|
+
if (isBackgroundDark2()) return true;
|
|
27515
|
+
if (isMainContentBackgroundDark2()) return true;
|
|
27516
|
+
if (isTextColorLight2()) return true;
|
|
27517
|
+
return false;
|
|
27518
|
+
} catch (error2) {
|
|
27519
|
+
console.warn("Error determining if page is dark:", error2);
|
|
27520
|
+
return false;
|
|
26699
27521
|
}
|
|
26700
|
-
|
|
26701
|
-
|
|
26702
|
-
|
|
26703
|
-
|
|
26704
|
-
|
|
26705
|
-
|
|
26706
|
-
|
|
26707
|
-
|
|
26708
|
-
}
|
|
26709
|
-
} else if (/\s/.test(prevPart)) {
|
|
26710
|
-
if (tokens[tokens.length - 1] == prevPart) {
|
|
26711
|
-
tokens.push(tokens.pop() + part);
|
|
26712
|
-
} else {
|
|
26713
|
-
tokens.push(prevPart + part);
|
|
26714
|
-
}
|
|
26715
|
-
} else {
|
|
26716
|
-
tokens.push(part);
|
|
26717
|
-
}
|
|
26718
|
-
prevPart = part;
|
|
26719
|
-
});
|
|
26720
|
-
return tokens;
|
|
26721
|
-
};
|
|
26722
|
-
wordDiff.join = function(tokens) {
|
|
26723
|
-
return tokens.map(function(token, i) {
|
|
26724
|
-
if (i == 0) {
|
|
26725
|
-
return token;
|
|
26726
|
-
} else {
|
|
26727
|
-
return token.replace(/^\s+/, "");
|
|
27522
|
+
}
|
|
27523
|
+
function hasDarkModeClass2() {
|
|
27524
|
+
const DEFAULT_DARK_MODE_CLASSES = ["dark", "dark-mode", "theme-dark", "night", "night-mode"];
|
|
27525
|
+
const htmlElement = document.documentElement;
|
|
27526
|
+
const bodyElement = document.body || document.documentElement;
|
|
27527
|
+
for (const className of DEFAULT_DARK_MODE_CLASSES) {
|
|
27528
|
+
if (htmlElement.classList.contains(className) || bodyElement?.classList.contains(className)) {
|
|
27529
|
+
return true;
|
|
26728
27530
|
}
|
|
26729
|
-
}).join("");
|
|
26730
|
-
};
|
|
26731
|
-
wordDiff.postProcess = function(changes, options) {
|
|
26732
|
-
if (!changes || options.oneChangePerToken) {
|
|
26733
|
-
return changes;
|
|
26734
27531
|
}
|
|
26735
|
-
|
|
26736
|
-
|
|
26737
|
-
|
|
26738
|
-
|
|
26739
|
-
|
|
26740
|
-
|
|
26741
|
-
|
|
26742
|
-
|
|
26743
|
-
|
|
26744
|
-
|
|
26745
|
-
|
|
26746
|
-
}
|
|
26747
|
-
lastKeep = change;
|
|
26748
|
-
insertion = null;
|
|
26749
|
-
deletion = null;
|
|
27532
|
+
return false;
|
|
27533
|
+
}
|
|
27534
|
+
function hasDarkModeDataAttribute2() {
|
|
27535
|
+
const htmlElement = document.documentElement;
|
|
27536
|
+
const bodyElement = document.body || document.documentElement;
|
|
27537
|
+
const dataAttrs = ["data-theme", "data-color-mode", "data-bs-theme", "data-mui-color-scheme"];
|
|
27538
|
+
for (const attr of dataAttrs) {
|
|
27539
|
+
const bodyValue = bodyElement?.getAttribute(attr);
|
|
27540
|
+
const htmlValue = htmlElement.getAttribute(attr);
|
|
27541
|
+
if (bodyValue?.toLowerCase() === "dark" || htmlValue?.toLowerCase() === "dark") {
|
|
27542
|
+
return true;
|
|
26750
27543
|
}
|
|
26751
|
-
});
|
|
26752
|
-
if (insertion || deletion) {
|
|
26753
|
-
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
|
|
26754
27544
|
}
|
|
26755
|
-
return
|
|
26756
|
-
}
|
|
26757
|
-
function
|
|
26758
|
-
|
|
26759
|
-
|
|
26760
|
-
|
|
26761
|
-
|
|
26762
|
-
|
|
26763
|
-
|
|
26764
|
-
|
|
26765
|
-
|
|
26766
|
-
|
|
26767
|
-
|
|
26768
|
-
|
|
26769
|
-
|
|
26770
|
-
|
|
26771
|
-
|
|
26772
|
-
|
|
26773
|
-
|
|
26774
|
-
}
|
|
26775
|
-
} else if (insertion) {
|
|
26776
|
-
if (startKeep) {
|
|
26777
|
-
insertion.value = insertion.value.replace(/^\s*/, "");
|
|
26778
|
-
}
|
|
26779
|
-
if (endKeep) {
|
|
26780
|
-
endKeep.value = endKeep.value.replace(/^\s*/, "");
|
|
26781
|
-
}
|
|
26782
|
-
} else if (startKeep && endKeep) {
|
|
26783
|
-
var newWsFull = endKeep.value.match(/^\s*/)[0], delWsStart = deletion.value.match(/^\s*/)[0], delWsEnd = deletion.value.match(/\s*$/)[0];
|
|
26784
|
-
var newWsStart = longestCommonPrefix(newWsFull, delWsStart);
|
|
26785
|
-
deletion.value = removePrefix(deletion.value, newWsStart);
|
|
26786
|
-
var newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
|
|
26787
|
-
deletion.value = removeSuffix(deletion.value, newWsEnd);
|
|
26788
|
-
endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
|
|
26789
|
-
startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
|
|
26790
|
-
} else if (endKeep) {
|
|
26791
|
-
var endKeepWsPrefix = endKeep.value.match(/^\s*/)[0];
|
|
26792
|
-
var deletionWsSuffix = deletion.value.match(/\s*$/)[0];
|
|
26793
|
-
var overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
|
|
26794
|
-
deletion.value = removeSuffix(deletion.value, overlap);
|
|
26795
|
-
} else if (startKeep) {
|
|
26796
|
-
var startKeepWsSuffix = startKeep.value.match(/\s*$/)[0];
|
|
26797
|
-
var deletionWsPrefix = deletion.value.match(/^\s*/)[0];
|
|
26798
|
-
var _overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
|
|
26799
|
-
deletion.value = removePrefix(deletion.value, _overlap);
|
|
27545
|
+
return false;
|
|
27546
|
+
}
|
|
27547
|
+
function isColorSchemeDark2() {
|
|
27548
|
+
const meta = document.querySelector('meta[name="color-scheme"]');
|
|
27549
|
+
const metaContent = meta?.content.toLowerCase();
|
|
27550
|
+
if (metaContent === "dark" || metaContent === "only dark") return true;
|
|
27551
|
+
const rootStyle = window.getComputedStyle(document.documentElement);
|
|
27552
|
+
const colorScheme = rootStyle.getPropertyValue("color-scheme").trim().toLowerCase();
|
|
27553
|
+
return colorScheme === "dark" || colorScheme === "only dark";
|
|
27554
|
+
}
|
|
27555
|
+
function isBackgroundDark2() {
|
|
27556
|
+
const htmlStyle = window.getComputedStyle(document.documentElement);
|
|
27557
|
+
const bodyStyle = window.getComputedStyle(document.body || document.documentElement);
|
|
27558
|
+
const htmlBgColor = htmlStyle.backgroundColor;
|
|
27559
|
+
const bodyBgColor = bodyStyle.backgroundColor;
|
|
27560
|
+
if (isColorDark2(bodyBgColor)) {
|
|
27561
|
+
return true;
|
|
27562
|
+
} else if (bodyBgColor === "transparent" || bodyBgColor.startsWith("rgba(0, 0, 0, 0)")) {
|
|
27563
|
+
return isColorDark2(htmlBgColor);
|
|
26800
27564
|
}
|
|
27565
|
+
return false;
|
|
26801
27566
|
}
|
|
26802
|
-
|
|
26803
|
-
|
|
26804
|
-
|
|
26805
|
-
|
|
26806
|
-
|
|
26807
|
-
|
|
26808
|
-
|
|
26809
|
-
|
|
26810
|
-
|
|
27567
|
+
function isTextColorLight2() {
|
|
27568
|
+
const LIGHT_TEXT_LUMINANCE = 200;
|
|
27569
|
+
const bodyStyle = window.getComputedStyle(document.body || document.documentElement);
|
|
27570
|
+
const luminance = getLuminance2(bodyStyle.color);
|
|
27571
|
+
return luminance !== null && luminance > LIGHT_TEXT_LUMINANCE;
|
|
27572
|
+
}
|
|
27573
|
+
function isMainContentBackgroundDark2() {
|
|
27574
|
+
const { innerWidth: vw, innerHeight: vh } = window;
|
|
27575
|
+
const minArea = vw * vh * 0.5;
|
|
27576
|
+
const selectors = ["#app", "#root", "#__next"];
|
|
27577
|
+
for (const selector of selectors) {
|
|
27578
|
+
const el = document.querySelector(selector);
|
|
27579
|
+
if (!el) continue;
|
|
27580
|
+
const rect = el.getBoundingClientRect();
|
|
27581
|
+
if (rect.width * rect.height < minArea) continue;
|
|
27582
|
+
if (isColorDark2(window.getComputedStyle(el).backgroundColor)) return true;
|
|
26811
27583
|
}
|
|
26812
|
-
|
|
26813
|
-
|
|
26814
|
-
|
|
27584
|
+
return false;
|
|
27585
|
+
}
|
|
27586
|
+
function parseRgbColor2(colorString) {
|
|
27587
|
+
const rgbMatch = /rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(colorString);
|
|
27588
|
+
if (!rgbMatch) {
|
|
27589
|
+
return null;
|
|
27590
|
+
}
|
|
27591
|
+
return {
|
|
27592
|
+
r: parseInt(rgbMatch[1]),
|
|
27593
|
+
g: parseInt(rgbMatch[2]),
|
|
27594
|
+
b: parseInt(rgbMatch[3])
|
|
27595
|
+
};
|
|
27596
|
+
}
|
|
27597
|
+
function getLuminance2(colorString) {
|
|
27598
|
+
if (!colorString || colorString === "transparent" || colorString.startsWith("rgba(0, 0, 0, 0)")) {
|
|
27599
|
+
return null;
|
|
27600
|
+
}
|
|
27601
|
+
const rgb = parseRgbColor2(colorString);
|
|
27602
|
+
if (!rgb) {
|
|
27603
|
+
return null;
|
|
27604
|
+
}
|
|
27605
|
+
return 0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b;
|
|
27606
|
+
}
|
|
27607
|
+
function isColorDark2(colorString, threshold = 128) {
|
|
27608
|
+
const luminance = getLuminance2(colorString);
|
|
27609
|
+
return luminance !== null && luminance < threshold;
|
|
27610
|
+
}
|
|
27611
|
+
|
|
27612
|
+
// ../next-sdk/page-tools/page-agent-mask/SimulatorMask.ts
|
|
27613
|
+
var injectStyles2 = `
|
|
27614
|
+
.webmcp-page-agent-cursor {
|
|
27615
|
+
position: absolute;
|
|
27616
|
+
width: var(--cursor-size, 75px);
|
|
27617
|
+
height: var(--cursor-size, 75px);
|
|
27618
|
+
pointer-events: none;
|
|
27619
|
+
z-index: 10000;
|
|
27620
|
+
}
|
|
27621
|
+
|
|
27622
|
+
.webmcp-page-agent-cursorBorder {
|
|
27623
|
+
position: absolute;
|
|
27624
|
+
width: 100%;
|
|
27625
|
+
height: 100%;
|
|
27626
|
+
background: linear-gradient(45deg, rgb(57, 182, 255), rgb(189, 69, 251));
|
|
27627
|
+
mask-image: url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");
|
|
27628
|
+
mask-size: 100% 100%;
|
|
27629
|
+
mask-repeat: no-repeat;
|
|
27630
|
+
|
|
27631
|
+
transform-origin: center;
|
|
27632
|
+
transform: rotate(-90deg) scale(0.8);
|
|
27633
|
+
margin-left: -10px;
|
|
27634
|
+
margin-top: -18px;
|
|
27635
|
+
}
|
|
27636
|
+
|
|
27637
|
+
.webmcp-page-agent-cursorFilling {
|
|
27638
|
+
position: absolute;
|
|
27639
|
+
width: 100%;
|
|
27640
|
+
height: 100%;
|
|
27641
|
+
background: url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3cdefs%3e%3c/defs%3e%3cg%20xmlns='http://www.w3.org/2000/svg'%20style='filter:%20drop-shadow(light-dark(rgba(0,%200,%200,%200.4),%20rgba(237,%20237,%20237,%200.4))%203px%204px%204px);'%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='%23ffffff'%20stroke='none'%20style='fill:%20%23ffffff;'/%3e%3c/g%3e%3c/svg%3e");
|
|
27642
|
+
background-size: 100% 100%;
|
|
27643
|
+
background-repeat: no-repeat;
|
|
27644
|
+
|
|
27645
|
+
transform-origin: center;
|
|
27646
|
+
transform: rotate(-90deg) scale(0.8);
|
|
27647
|
+
margin-left: -10px;
|
|
27648
|
+
margin-top: -18px;
|
|
27649
|
+
}
|
|
27650
|
+
|
|
27651
|
+
.webmcp-page-agent-cursorRipple {
|
|
27652
|
+
position: absolute;
|
|
27653
|
+
width: 100%;
|
|
27654
|
+
height: 100%;
|
|
27655
|
+
pointer-events: none;
|
|
27656
|
+
margin-left: -50%;
|
|
27657
|
+
margin-top: -50%;
|
|
27658
|
+
|
|
27659
|
+
&::after {
|
|
27660
|
+
content: '';
|
|
27661
|
+
opacity: 0;
|
|
27662
|
+
position: absolute;
|
|
27663
|
+
inset: 0;
|
|
27664
|
+
border: 4px solid rgba(57, 182, 255, 1);
|
|
27665
|
+
border-radius: 50%;
|
|
27666
|
+
}
|
|
27667
|
+
}
|
|
27668
|
+
|
|
27669
|
+
.webmcp-page-agent-cursor.clicking .webmcp-page-agent-cursorRipple::after {
|
|
27670
|
+
animation: webmcp-page-agent-cursor-ripple 300ms ease-out forwards;
|
|
27671
|
+
}
|
|
27672
|
+
|
|
27673
|
+
@keyframes webmcp-page-agent-cursor-ripple {
|
|
27674
|
+
0% {
|
|
27675
|
+
transform: scale(0);
|
|
27676
|
+
opacity: 1;
|
|
27677
|
+
}
|
|
27678
|
+
|
|
27679
|
+
100% {
|
|
27680
|
+
transform: scale(2);
|
|
27681
|
+
opacity: 0;
|
|
27682
|
+
}
|
|
27683
|
+
}
|
|
27684
|
+
|
|
27685
|
+
.webmcp-page-agent-wrapper {
|
|
27686
|
+
position: fixed;
|
|
27687
|
+
inset: 0;
|
|
27688
|
+
z-index: 2147483641;
|
|
27689
|
+
/* \u786E\u4FDD\u5728\u6240\u6709\u5143\u7D20\u4E4B\u4E0A\uFF0C\u9664\u4E86 panel */
|
|
27690
|
+
cursor: wait;
|
|
27691
|
+
overflow: hidden;
|
|
27692
|
+
|
|
27693
|
+
display: none;
|
|
27694
|
+
}
|
|
27695
|
+
|
|
27696
|
+
.webmcp-page-agent-wrapper.visible {
|
|
27697
|
+
display: block;
|
|
27698
|
+
}
|
|
27699
|
+
`;
|
|
27700
|
+
var SimulatorMask2 = class extends EventTarget {
|
|
27701
|
+
constructor() {
|
|
27702
|
+
super();
|
|
27703
|
+
this.shown = false;
|
|
27704
|
+
this.wrapper = document.createElement("div");
|
|
27705
|
+
this.motion = null;
|
|
27706
|
+
this.#disposed = false;
|
|
27707
|
+
this.#cursor = document.createElement("div");
|
|
27708
|
+
this.#currentCursorX = 0;
|
|
27709
|
+
this.#currentCursorY = 0;
|
|
27710
|
+
this.#targetCursorX = 0;
|
|
27711
|
+
this.#targetCursorY = 0;
|
|
27712
|
+
document.head.appendChild(document.createElement("style")).textContent = injectStyles2;
|
|
27713
|
+
this.wrapper.id = "page-agent-runtime_simulator-mask";
|
|
27714
|
+
this.wrapper.className = "webmcp-page-agent-wrapper";
|
|
27715
|
+
this.wrapper.setAttribute("data-browser-use-ignore", "true");
|
|
27716
|
+
this.wrapper.setAttribute("data-page-agent-ignore", "true");
|
|
27717
|
+
try {
|
|
27718
|
+
const motion = new Motion({
|
|
27719
|
+
mode: isPageDark2() ? "dark" : "light",
|
|
27720
|
+
styles: { position: "absolute", inset: "0" }
|
|
27721
|
+
});
|
|
27722
|
+
this.motion = motion;
|
|
27723
|
+
this.wrapper.appendChild(motion.element);
|
|
27724
|
+
motion.autoResize(this.wrapper);
|
|
27725
|
+
} catch (e) {
|
|
27726
|
+
console.warn("[SimulatorMask] Motion overlay unavailable:", e);
|
|
27727
|
+
}
|
|
27728
|
+
const stopEvent = (e) => {
|
|
27729
|
+
e.stopPropagation();
|
|
27730
|
+
e.preventDefault();
|
|
27731
|
+
};
|
|
27732
|
+
["click", "mousedown", "mouseup", "mousemove", "wheel", "keydown", "keyup"].forEach(
|
|
27733
|
+
(eventName) => this.wrapper.addEventListener(eventName, stopEvent)
|
|
27734
|
+
);
|
|
27735
|
+
this.#createCursor();
|
|
27736
|
+
document.body.appendChild(this.wrapper);
|
|
27737
|
+
this.#moveCursorToTarget();
|
|
27738
|
+
const movePointerToListener = (event) => {
|
|
27739
|
+
const { x, y } = event.detail;
|
|
27740
|
+
this.setCursorPosition(x, y);
|
|
27741
|
+
};
|
|
27742
|
+
const clickPointerListener = () => {
|
|
27743
|
+
this.triggerClickAnimation();
|
|
27744
|
+
};
|
|
27745
|
+
const enablePassThroughListener = () => {
|
|
27746
|
+
this.wrapper.style.pointerEvents = "none";
|
|
27747
|
+
};
|
|
27748
|
+
const disablePassThroughListener = () => {
|
|
27749
|
+
this.wrapper.style.pointerEvents = "auto";
|
|
27750
|
+
};
|
|
27751
|
+
window.addEventListener("PageAgent::MovePointerTo", movePointerToListener);
|
|
27752
|
+
window.addEventListener("PageAgent::ClickPointer", clickPointerListener);
|
|
27753
|
+
window.addEventListener("PageAgent::EnablePassThrough", enablePassThroughListener);
|
|
27754
|
+
window.addEventListener("PageAgent::DisablePassThrough", disablePassThroughListener);
|
|
27755
|
+
this.addEventListener("dispose", () => {
|
|
27756
|
+
window.removeEventListener("PageAgent::MovePointerTo", movePointerToListener);
|
|
27757
|
+
window.removeEventListener("PageAgent::ClickPointer", clickPointerListener);
|
|
27758
|
+
window.removeEventListener("PageAgent::EnablePassThrough", enablePassThroughListener);
|
|
27759
|
+
window.removeEventListener("PageAgent::DisablePassThrough", disablePassThroughListener);
|
|
27760
|
+
});
|
|
26815
27761
|
}
|
|
26816
|
-
|
|
26817
|
-
|
|
26818
|
-
|
|
26819
|
-
|
|
26820
|
-
|
|
26821
|
-
|
|
27762
|
+
#disposed;
|
|
27763
|
+
#cursor;
|
|
27764
|
+
#currentCursorX;
|
|
27765
|
+
#currentCursorY;
|
|
27766
|
+
#targetCursorX;
|
|
27767
|
+
#targetCursorY;
|
|
27768
|
+
#createCursor() {
|
|
27769
|
+
this.#cursor.className = "webmcp-page-agent-cursor";
|
|
27770
|
+
const rippleContainer = document.createElement("div");
|
|
27771
|
+
rippleContainer.className = "webmcp-page-agent-cursorRipple";
|
|
27772
|
+
this.#cursor.appendChild(rippleContainer);
|
|
27773
|
+
const fillingLayer = document.createElement("div");
|
|
27774
|
+
fillingLayer.className = "webmcp-page-agent-cursorFilling";
|
|
27775
|
+
this.#cursor.appendChild(fillingLayer);
|
|
27776
|
+
const borderLayer = document.createElement("div");
|
|
27777
|
+
borderLayer.className = "webmcp-page-agent-cursorBorder";
|
|
27778
|
+
this.#cursor.appendChild(borderLayer);
|
|
27779
|
+
this.wrapper.appendChild(this.#cursor);
|
|
27780
|
+
}
|
|
27781
|
+
#moveCursorToTarget() {
|
|
27782
|
+
if (this.#disposed) return;
|
|
27783
|
+
const newX = this.#currentCursorX + (this.#targetCursorX - this.#currentCursorX) * 0.2;
|
|
27784
|
+
const newY = this.#currentCursorY + (this.#targetCursorY - this.#currentCursorY) * 0.2;
|
|
27785
|
+
const xDistance = Math.abs(newX - this.#targetCursorX);
|
|
27786
|
+
if (xDistance > 0) {
|
|
27787
|
+
if (xDistance < 2) {
|
|
27788
|
+
this.#currentCursorX = this.#targetCursorX;
|
|
27789
|
+
} else {
|
|
27790
|
+
this.#currentCursorX = newX;
|
|
27791
|
+
}
|
|
27792
|
+
this.#cursor.style.left = `${this.#currentCursorX}px`;
|
|
26822
27793
|
}
|
|
27794
|
+
const yDistance = Math.abs(newY - this.#targetCursorY);
|
|
27795
|
+
if (yDistance > 0) {
|
|
27796
|
+
if (yDistance < 2) {
|
|
27797
|
+
this.#currentCursorY = this.#targetCursorY;
|
|
27798
|
+
} else {
|
|
27799
|
+
this.#currentCursorY = newY;
|
|
27800
|
+
}
|
|
27801
|
+
this.#cursor.style.top = `${this.#currentCursorY}px`;
|
|
27802
|
+
}
|
|
27803
|
+
requestAnimationFrame(() => this.#moveCursorToTarget());
|
|
27804
|
+
}
|
|
27805
|
+
setCursorPosition(x, y) {
|
|
27806
|
+
if (this.#disposed) return;
|
|
27807
|
+
this.#targetCursorX = x;
|
|
27808
|
+
this.#targetCursorY = y;
|
|
27809
|
+
}
|
|
27810
|
+
triggerClickAnimation() {
|
|
27811
|
+
if (this.#disposed) return;
|
|
27812
|
+
this.#cursor.classList.remove("clicking");
|
|
27813
|
+
void this.#cursor.offsetHeight;
|
|
27814
|
+
this.#cursor.classList.add("clicking");
|
|
27815
|
+
}
|
|
27816
|
+
show() {
|
|
27817
|
+
if (this.shown || this.#disposed) return;
|
|
27818
|
+
this.shown = true;
|
|
27819
|
+
this.motion?.start();
|
|
27820
|
+
this.motion?.fadeIn();
|
|
27821
|
+
this.wrapper.classList.add("visible");
|
|
27822
|
+
this.#currentCursorX = window.innerWidth / 2;
|
|
27823
|
+
this.#currentCursorY = window.innerHeight / 2;
|
|
27824
|
+
this.#targetCursorX = this.#currentCursorX;
|
|
27825
|
+
this.#targetCursorY = this.#currentCursorY;
|
|
27826
|
+
this.#cursor.style.left = `${this.#currentCursorX}px`;
|
|
27827
|
+
this.#cursor.style.top = `${this.#currentCursorY}px`;
|
|
27828
|
+
}
|
|
27829
|
+
hide() {
|
|
27830
|
+
if (!this.shown || this.#disposed) return;
|
|
27831
|
+
this.shown = false;
|
|
27832
|
+
this.motion?.fadeOut();
|
|
27833
|
+
this.motion?.pause();
|
|
27834
|
+
this.#cursor.classList.remove("clicking");
|
|
27835
|
+
setTimeout(() => {
|
|
27836
|
+
this.wrapper.classList.remove("visible");
|
|
27837
|
+
}, 800);
|
|
27838
|
+
}
|
|
27839
|
+
dispose() {
|
|
27840
|
+
this.#disposed = true;
|
|
27841
|
+
this.motion?.dispose();
|
|
27842
|
+
this.wrapper.remove();
|
|
27843
|
+
this.dispatchEvent(new Event("dispose"));
|
|
26823
27844
|
}
|
|
26824
|
-
return retLines;
|
|
26825
27845
|
};
|
|
26826
|
-
|
|
26827
|
-
|
|
26828
|
-
|
|
26829
|
-
|
|
26830
|
-
|
|
26831
|
-
|
|
26832
|
-
|
|
26833
|
-
|
|
26834
|
-
|
|
26835
|
-
|
|
26836
|
-
|
|
26837
|
-
|
|
26838
|
-
|
|
26839
|
-
|
|
27846
|
+
|
|
27847
|
+
// ../next-sdk/page-tools/constants.ts
|
|
27848
|
+
var DEFAULT_ERROR_SELECTORS2 = [
|
|
27849
|
+
// W3C ARIA 标准(最可靠,框架无关)
|
|
27850
|
+
'[role="alert"]',
|
|
27851
|
+
'[aria-invalid="true"]',
|
|
27852
|
+
// Tiny3 / Lego(华为云)
|
|
27853
|
+
".ti3-unifyvalid-error",
|
|
27854
|
+
".ti3-error",
|
|
27855
|
+
".ti-error",
|
|
27856
|
+
".lego-text-error",
|
|
27857
|
+
".lego-error",
|
|
27858
|
+
// Element UI / Element Plus
|
|
27859
|
+
".el-form-item__error",
|
|
27860
|
+
// Ant Design
|
|
27861
|
+
".ant-form-item-explain-error",
|
|
27862
|
+
// Bootstrap
|
|
27863
|
+
".is-invalid",
|
|
27864
|
+
".invalid-feedback",
|
|
27865
|
+
// Angular
|
|
27866
|
+
".ng-invalid",
|
|
27867
|
+
// 通用命名约定
|
|
27868
|
+
".error-msg",
|
|
27869
|
+
".error-message",
|
|
27870
|
+
".error-text",
|
|
27871
|
+
".field-error",
|
|
27872
|
+
".form-error",
|
|
27873
|
+
".is-error",
|
|
27874
|
+
".has-error",
|
|
27875
|
+
".validate-error",
|
|
27876
|
+
".valid-error"
|
|
27877
|
+
];
|
|
27878
|
+
var DEFAULT_DIALOG_SELECTORS = [
|
|
27879
|
+
// W3C ARIA 标准
|
|
27880
|
+
'[role="dialog"]',
|
|
27881
|
+
'[role="alertdialog"]',
|
|
27882
|
+
// Tiny3 / Lego(华为云)
|
|
27883
|
+
'[class*="ti3-modal"]',
|
|
27884
|
+
'[class*="ti3-message-box"]',
|
|
27885
|
+
// Element UI / Element Plus
|
|
27886
|
+
'[class*="el-dialog"]',
|
|
27887
|
+
'[class*="el-message-box"]',
|
|
27888
|
+
// Ant Design
|
|
27889
|
+
'[class*="ant-modal"]',
|
|
27890
|
+
// Bootstrap
|
|
27891
|
+
'[class*="modal-content"]',
|
|
27892
|
+
// Vuetify
|
|
27893
|
+
'[class*="v-dialog"]',
|
|
27894
|
+
// Naive UI
|
|
27895
|
+
'[class*="n-modal"]'
|
|
27896
|
+
];
|
|
27897
|
+
|
|
27898
|
+
// ../next-sdk/page-tools/schema.ts
|
|
27899
|
+
var inputSchema = external_exports.object({
|
|
27900
|
+
action: external_exports.enum(["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree"]).describe(`\u6267\u884C\u7684\u52A8\u4F5C\u540D\u79F0, \u6BCF\u4E00\u6B21\u6267\u884C 'click', 'fill', 'select'\u52A8\u4F5C\u4E4B\u524D\uFF0C**\u5FC5\u987B**\u8981\u5148\u8C03\u7528 'browserState' \u53BB\u83B7\u53D6\u9875\u9762\u7684\u6700\u65B0\u72B6\u6001\u3002
|
|
27901
|
+
browserState: '\u67E5\u8BE2\u6574\u4E2A\u9875\u9762\u7684\u6D4F\u89C8\u5668\u72B6\u6001;\u8FD4\u56DE\u9875\u9762\u7684\u6807\u9898\u3001URL\u3001YAML\u683C\u5F0F\u7684\u8BED\u4E49\u5316\u9875\u9762\u6811',
|
|
27902
|
+
click: '\u6839\u636E\u5143\u7D20\u7D22\u5F15\u70B9\u51FB;',
|
|
27903
|
+
fill: '\u6839\u636E\u5143\u7D20\u7D22\u5F15\u586B\u5199\u6587\u672C;';
|
|
27904
|
+
select: '\u6839\u636E\u5143\u7D20\u7D22\u5F15\u9009\u62E9\u4E0B\u62C9\u6846\u9009\u9879;';
|
|
27905
|
+
scroll: '\u6EDA\u52A8\u9875\u9762\u7684\u52A8\u4F5C\uFF0C\u53EF\u4EE5\u6307\u5B9A\u6C34\u5E73\u6EDA\u52A8\u8FD8\u662F\u4E0A\u4E0B\u6EDA\u52A8; \u4E0D\u5E26\u5143\u7D20\u7D22\u5F15\u65F6\uFF1A\u6EDA\u52A8\u6574\u4E2A\u6587\u6863\u3002\u5E26\u5143\u7D20\u7D22\u5F15\u65F6\uFF1A\u6EDA\u52A8\u8BE5\u7D22\u5F15\u5904\u7684\u5BB9\u5668\uFF08\u6216\u5176\u6700\u8FD1\u7684\u53EF\u6EDA\u52A8\u7956\u5148\u5143\u7D20\uFF09'
|
|
27906
|
+
executeJavascript: '\u6267\u884Cjavascript\u4EE3\u7801'
|
|
27907
|
+
searchTree: '\u6309\u5173\u952E\u8BCD\u641C\u7D22\u65E0\u969C\u788D\u6811\uFF0C\u8FD4\u56DE\u5E26\u884C\u53F7\u7684\u5339\u914D\u8282\u70B9\u53CA\u4E0A\u4E0B\u6587\uFF0C\u65E0\u9700\u83B7\u53D6\u5168\u91CF\u6811\u3002\u9002\u5408\u5FEB\u901F\u5B9A\u4F4D\u7279\u5B9A\u5143\u7D20\uFF08\u5982\u6240\u6709\u6309\u94AE\u3001\u7279\u5B9A\u540D\u79F0\u7684\u94FE\u63A5\u7B49\uFF09\uFF0C\u663E\u8457\u51CF\u5C11\u4E0A\u4E0B\u6587\u6D88\u8017\u3002\u5FC5\u987B\u63D0\u4F9B query \u53C2\u6570\u3002'
|
|
27908
|
+
`),
|
|
27909
|
+
index: external_exports.number().min(0).optional().describe("\u6267\u884C\u52A8\u4F5C of the element index, \u52A8\u4F5C\u4E3A click,fill,select\u65F6\uFF0C\u5FC5\u987B\u63D0\u4F9B\u5143\u7D20\u7D22\u5F15"),
|
|
27910
|
+
text: external_exports.string().optional().describe("\u6267\u884C\u52A8\u4F5C\u7684\u6587\u672C\u5185\u5BB9, \u52A8\u4F5C\u4E3A fill,select \u65F6\uFF0C\u5FC5\u987B\u63D0\u4F9B\u6587\u672C\u5185\u5BB9"),
|
|
27911
|
+
down: external_exports.boolean().optional().describe("\u6267\u884C\u4E0A\u4E0B\u6EDA\u52A8\u65F6\uFF0C\u5FC5\u987B\u63D0\u4F9Bdown\u53C2\u6570"),
|
|
27912
|
+
right: external_exports.boolean().optional().describe("\u6267\u884C\u6C34\u5E73\u6EDA\u52A8\u65B9\u5411, \u5FC5\u987B\u63D0\u4F9Bright\u53C2\u6570"),
|
|
27913
|
+
numPages: external_exports.number().optional().describe("\u6267\u884C\u52A8\u4F5C\u7684\u6EDA\u52A8\u9875\u6570, \u52A8\u4F5C\u4E3A scroll\u65F6\uFF0C\u53EF\u4EE5\u63D0\u4F9B\u6EDA\u52A8\u9875\u6570\uFF0C\u5EFA\u8BAE\u6BCF\u6B21\u6EDA\u52A80.1\u9875\uFF0C\u8BE5\u503C\u4E0D\u8981\u5927\u4E8E5."),
|
|
27914
|
+
pixels: external_exports.number().int().min(0).optional().describe("\u6267\u884C\u52A8\u4F5C\u7684\u6EDA\u52A8\u50CF\u7D20\u6570\uFF0C\u52A8\u4F5C\u4E3A scroll\u65F6\uFF0C\u53EF\u4EE5\u63D0\u4F9B\u6EDA\u52A8\u50CF\u7D20\u6570"),
|
|
27915
|
+
script: external_exports.string().optional().describe("\u6267\u884C\u7684javascript\u4EE3\u7801\uFF0C\u52A8\u4F5C\u4E3A executeJavascript\u65F6\uFF0C\u5FC5\u987B\u63D0\u4F9Bscript\u53C2\u6570"),
|
|
27916
|
+
query: external_exports.string().optional().describe(
|
|
27917
|
+
"\u641C\u7D22\u5173\u952E\u8BCD\uFF0C\u52A8\u4F5C\u4E3A searchTree \u65F6\u5FC5\u987B\u63D0\u4F9B\u3002\u652F\u6301\u6309 role\uFF08\u5982 button\u3001link\uFF09\u3001\u8282\u70B9\u540D\u79F0\u3001\u72B6\u6001\uFF08\u5982 checked\uFF09\u6216 ref \u7D22\u5F15\uFF08\u5982 #3\uFF09\u641C\u7D22"
|
|
27918
|
+
),
|
|
27919
|
+
contextLines: external_exports.number().int().min(0).max(10).default(2).describe("searchTree \u65F6\u6BCF\u4E2A\u547D\u4E2D\u884C\u524D\u540E\u4FDD\u7559\u7684\u4E0A\u4E0B\u6587\u884C\u6570\uFF0C\u9ED8\u8BA4 2"),
|
|
27920
|
+
maxMatches: external_exports.number().int().min(1).max(50).default(20).describe("searchTree \u65F6\u6700\u5927\u8FD4\u56DE\u5206\u7EC4\u6570\uFF0C\u9ED8\u8BA4 20"),
|
|
27921
|
+
responseMode: external_exports.enum(["full", "diff", "both"]).optional().default("diff").describe(
|
|
27922
|
+
"\u8FD4\u56DE\u6D4F\u89C8\u5668\u72B6\u6001\u7684\u6A21\u5F0F\u3002full: \u4EC5\u8FD4\u56DE\u5F53\u524D\u5168\u91CF A11y \u6811\uFF1Bdiff: \u4EC5\u8FD4\u56DE\u4E0E\u4E0A\u4E00\u6B21\u72B6\u6001\u7684\u589E\u91CF\u5DEE\u5F02\uFF1Bboth: \u540C\u65F6\u8FD4\u56DE\u5168\u91CF A11y \u6811\u4E0E\u589E\u91CF\u5DEE\u5F02\u3002\u9ED8\u8BA4\u503C\u4E3A diff\u3002"
|
|
27923
|
+
)
|
|
27924
|
+
});
|
|
27925
|
+
|
|
27926
|
+
// ../next-sdk/page-tools/utils/dom.ts
|
|
27927
|
+
function isInShadowDom(el) {
|
|
27928
|
+
return el.getRootNode() instanceof ShadowRoot;
|
|
27929
|
+
}
|
|
27930
|
+
function dispatchComposedEvents(el, ...types) {
|
|
27931
|
+
for (const type of types) {
|
|
27932
|
+
el.dispatchEvent(new Event(type, { bubbles: true, composed: true }));
|
|
27933
|
+
}
|
|
27934
|
+
}
|
|
27935
|
+
function deepQuerySelectorAll(selector, root = document) {
|
|
27936
|
+
const elements = Array.from(root.querySelectorAll(selector));
|
|
27937
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null);
|
|
27938
|
+
let currentNode = walker.currentNode;
|
|
27939
|
+
while (currentNode) {
|
|
27940
|
+
if (currentNode.shadowRoot) {
|
|
27941
|
+
elements.push(...deepQuerySelectorAll(selector, currentNode.shadowRoot));
|
|
26840
27942
|
}
|
|
27943
|
+
currentNode = walker.nextNode();
|
|
26841
27944
|
}
|
|
26842
|
-
return
|
|
26843
|
-
};
|
|
26844
|
-
function diffLines(oldStr, newStr, callback) {
|
|
26845
|
-
return lineDiff.diff(oldStr, newStr, callback);
|
|
27945
|
+
return elements;
|
|
26846
27946
|
}
|
|
26847
|
-
|
|
26848
|
-
|
|
26849
|
-
|
|
26850
|
-
|
|
26851
|
-
|
|
26852
|
-
|
|
26853
|
-
|
|
26854
|
-
|
|
26855
|
-
|
|
26856
|
-
|
|
26857
|
-
|
|
26858
|
-
|
|
26859
|
-
|
|
26860
|
-
|
|
26861
|
-
|
|
27947
|
+
function waitForDomSettled(timeout = 600, settleTime = 150) {
|
|
27948
|
+
return new Promise((resolve) => {
|
|
27949
|
+
let settled = false;
|
|
27950
|
+
let settleTimer;
|
|
27951
|
+
const finish = () => {
|
|
27952
|
+
if (settled) return;
|
|
27953
|
+
settled = true;
|
|
27954
|
+
observer.disconnect();
|
|
27955
|
+
if (settleTimer) clearTimeout(settleTimer);
|
|
27956
|
+
resolve();
|
|
27957
|
+
};
|
|
27958
|
+
const observer = new MutationObserver(() => {
|
|
27959
|
+
if (settleTimer) clearTimeout(settleTimer);
|
|
27960
|
+
settleTimer = setTimeout(finish, settleTime);
|
|
27961
|
+
});
|
|
27962
|
+
settleTimer = setTimeout(finish, settleTime);
|
|
27963
|
+
setTimeout(finish, timeout);
|
|
27964
|
+
observer.observe(document.body, {
|
|
27965
|
+
childList: true,
|
|
27966
|
+
subtree: true,
|
|
27967
|
+
attributes: true,
|
|
27968
|
+
attributeFilter: ["class", "style", "hidden"]
|
|
27969
|
+
});
|
|
27970
|
+
});
|
|
26862
27971
|
}
|
|
26863
|
-
|
|
26864
|
-
|
|
26865
|
-
|
|
26866
|
-
|
|
26867
|
-
|
|
26868
|
-
|
|
26869
|
-
|
|
26870
|
-
|
|
26871
|
-
|
|
26872
|
-
|
|
26873
|
-
|
|
26874
|
-
|
|
26875
|
-
|
|
26876
|
-
|
|
26877
|
-
|
|
26878
|
-
|
|
26879
|
-
|
|
27972
|
+
function detectPageDialog() {
|
|
27973
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27974
|
+
const dialogs = [];
|
|
27975
|
+
const selectors = window.__webmcpcli_dialogSelectors ?? DEFAULT_DIALOG_SELECTORS;
|
|
27976
|
+
for (const selector of selectors) {
|
|
27977
|
+
try {
|
|
27978
|
+
for (const el of deepQuerySelectorAll(selector)) {
|
|
27979
|
+
if (seen.has(el)) continue;
|
|
27980
|
+
if (el.id?.includes("page-agent-runtime")) continue;
|
|
27981
|
+
if (el.closest("#page-agent-runtime_simulator-mask")) continue;
|
|
27982
|
+
const rect = el.getBoundingClientRect();
|
|
27983
|
+
if (rect.width < 50 || rect.height < 50) continue;
|
|
27984
|
+
const style = window.getComputedStyle(el);
|
|
27985
|
+
if (style.display === "none" || style.visibility === "hidden") continue;
|
|
27986
|
+
const isFixed = style.position === "fixed" || style.position === "absolute";
|
|
27987
|
+
const zIndex = parseInt(style.zIndex || "0", 10);
|
|
27988
|
+
if (!isFixed || zIndex < 100) continue;
|
|
27989
|
+
const vw = window.innerWidth;
|
|
27990
|
+
const vh = window.innerHeight;
|
|
27991
|
+
const coversCenter = rect.left < vw * 0.6 && rect.right > vw * 0.4 && rect.top < vh * 0.6 && rect.bottom > vh * 0.4;
|
|
27992
|
+
if (!coversCenter) continue;
|
|
27993
|
+
seen.add(el);
|
|
27994
|
+
const text = (el.textContent || "").trim().replace(/\s+/g, " ");
|
|
27995
|
+
if (text.length > 5) {
|
|
27996
|
+
const btns = el.querySelectorAll('button, [role="button"], a');
|
|
27997
|
+
const btnTexts = Array.from(btns).map((b) => (b.textContent || "").trim()).filter((t) => t.length > 0 && t.length < 20).slice(0, 5);
|
|
27998
|
+
const btnInfo = btnTexts.length ? ` [\u53EF\u64CD\u4F5C\u6309\u94AE: ${btnTexts.join(" / ")}]` : "";
|
|
27999
|
+
dialogs.push(`${text.substring(0, 300)}${btnInfo}`);
|
|
28000
|
+
}
|
|
28001
|
+
}
|
|
28002
|
+
} catch {
|
|
28003
|
+
}
|
|
26880
28004
|
}
|
|
26881
|
-
|
|
26882
|
-
|
|
26883
|
-
|
|
26884
|
-
|
|
28005
|
+
if (dialogs.length === 0) return "";
|
|
28006
|
+
return `
|
|
28007
|
+
[\u9875\u9762\u5F39\u7A97\u68C0\u6D4B] \u68C0\u6D4B\u5230 ${dialogs.length} \u4E2A\u6A21\u6001\u5F39\u7A97\uFF0C\u8BF7\u4F18\u5148\u5904\u7406:
|
|
28008
|
+
${dialogs.map((d, i) => `${i + 1}. ${d}`).join("\n")}
|
|
28009
|
+
`;
|
|
28010
|
+
}
|
|
28011
|
+
function detectValidationErrors() {
|
|
28012
|
+
const seen = /* @__PURE__ */ new Set();
|
|
28013
|
+
const errors = [];
|
|
28014
|
+
const selectors = window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS2;
|
|
28015
|
+
for (const selector of selectors) {
|
|
28016
|
+
try {
|
|
28017
|
+
for (const el of deepQuerySelectorAll(selector)) {
|
|
28018
|
+
if (seen.has(el)) continue;
|
|
28019
|
+
if (Array.from(seen).some((s) => s.contains(el))) continue;
|
|
28020
|
+
const rect = el.getBoundingClientRect();
|
|
28021
|
+
if (rect.width < 1 || rect.height < 1) continue;
|
|
28022
|
+
const style = window.getComputedStyle(el);
|
|
28023
|
+
if (style.display === "none" || style.visibility === "hidden") continue;
|
|
28024
|
+
const text = (el.textContent || "").trim().replace(/\s+/g, " ");
|
|
28025
|
+
if (text.length > 2 && text.length < 200) {
|
|
28026
|
+
seen.add(el);
|
|
28027
|
+
errors.push(text);
|
|
28028
|
+
}
|
|
28029
|
+
}
|
|
28030
|
+
} catch {
|
|
26885
28031
|
}
|
|
26886
28032
|
}
|
|
26887
|
-
|
|
26888
|
-
|
|
26889
|
-
|
|
26890
|
-
|
|
26891
|
-
|
|
26892
|
-
|
|
26893
|
-
|
|
28033
|
+
if (errors.length === 0) return "";
|
|
28034
|
+
return `
|
|
28035
|
+
[\u6821\u9A8C\u63D0\u793A] \u68C0\u6D4B\u5230 ${errors.length} \u4E2A\u8868\u5355\u6821\u9A8C\u9519\u8BEF\uFF0C\u8BF7\u5148\u4FEE\u590D\u540E\u518D\u7EE7\u7EED:
|
|
28036
|
+
${errors.map((e, i) => `${i + 1}. ${e}`).join("\n")}
|
|
28037
|
+
`;
|
|
28038
|
+
}
|
|
28039
|
+
|
|
28040
|
+
// ../next-sdk/page-tools/handlers/browserState.ts
|
|
28041
|
+
async function handleBrowserState(args, ctx) {
|
|
28042
|
+
if (window.__webmcpcli_beforeGetBrowserState) {
|
|
28043
|
+
try {
|
|
28044
|
+
window.__webmcpcli_beforeGetBrowserState();
|
|
28045
|
+
} catch (e) {
|
|
28046
|
+
console.warn("__webmcpcli_beforeGetBrowserState error:", e);
|
|
26894
28047
|
}
|
|
26895
|
-
stack.pop();
|
|
26896
|
-
replacementStack.pop();
|
|
26897
|
-
return canonicalizedObj;
|
|
26898
28048
|
}
|
|
26899
|
-
|
|
26900
|
-
|
|
28049
|
+
return ctx.buildBrowserStateResponse(args.responseMode ?? "diff");
|
|
28050
|
+
}
|
|
28051
|
+
|
|
28052
|
+
// ../next-sdk/page-tools/handlers/click.ts
|
|
28053
|
+
async function handleClick(args, ctx) {
|
|
28054
|
+
const mode = args.responseMode ?? "diff";
|
|
28055
|
+
if (args.index === void 0) return ctx.errContent("\u70B9\u51FB\u7ED3\u679C: \u7F3A\u5C11\u5143\u7D20\u7D22\u5F15");
|
|
28056
|
+
const el = ctx.getRefMap().get(args.index);
|
|
28057
|
+
if (!el) return ctx.refreshOnStaleRef("\u70B9\u51FB", args.index);
|
|
28058
|
+
let targetEl = el;
|
|
28059
|
+
if (el.shadowRoot && !(el instanceof HTMLButtonElement) && !(el instanceof HTMLAnchorElement)) {
|
|
28060
|
+
const innerClickable = el.shadowRoot.querySelector(
|
|
28061
|
+
'button, a, [role="button"], [role="link"]'
|
|
28062
|
+
);
|
|
28063
|
+
if (innerClickable) {
|
|
28064
|
+
targetEl = innerClickable;
|
|
28065
|
+
}
|
|
26901
28066
|
}
|
|
26902
|
-
|
|
26903
|
-
|
|
26904
|
-
|
|
26905
|
-
|
|
26906
|
-
|
|
26907
|
-
|
|
26908
|
-
|
|
26909
|
-
|
|
28067
|
+
await clickElement(targetEl);
|
|
28068
|
+
await waitForDomSettled();
|
|
28069
|
+
return ctx.buildBrowserStateResponse(mode);
|
|
28070
|
+
}
|
|
28071
|
+
|
|
28072
|
+
// ../next-sdk/page-tools/handlers/fill.ts
|
|
28073
|
+
async function handleFill(args, ctx) {
|
|
28074
|
+
const mode = args.responseMode ?? "diff";
|
|
28075
|
+
if (args.index === void 0 || typeof args.text !== "string") return ctx.errContent("\u586B\u5199\u7ED3\u679C: \u7F3A\u5C11\u5143\u7D20\u7D22\u5F15\u6216\u6587\u672C\u5185\u5BB9");
|
|
28076
|
+
const el = ctx.getRefMap().get(args.index);
|
|
28077
|
+
if (!el) return ctx.refreshOnStaleRef("\u586B\u5199", args.index);
|
|
28078
|
+
let targetEl = el;
|
|
28079
|
+
if (!(targetEl instanceof HTMLInputElement) && !(targetEl instanceof HTMLTextAreaElement)) {
|
|
28080
|
+
const innerInput = el.querySelector("input, textarea") ?? el.shadowRoot?.querySelector("input, textarea");
|
|
28081
|
+
if (innerInput) {
|
|
28082
|
+
targetEl = innerInput;
|
|
28083
|
+
}
|
|
28084
|
+
}
|
|
28085
|
+
if (targetEl instanceof HTMLInputElement && targetEl.readOnly) {
|
|
28086
|
+
targetEl.value = args.text;
|
|
28087
|
+
dispatchComposedEvents(targetEl, "input", "change", "blur");
|
|
28088
|
+
} else {
|
|
28089
|
+
let fillSuccess = false;
|
|
28090
|
+
try {
|
|
28091
|
+
await inputTextElement(targetEl, args.text);
|
|
28092
|
+
fillSuccess = true;
|
|
28093
|
+
} catch (fillErr) {
|
|
28094
|
+
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
|
|
28095
|
+
(targetEl instanceof HTMLTextAreaElement ? HTMLTextAreaElement : HTMLInputElement).prototype,
|
|
28096
|
+
"value"
|
|
28097
|
+
)?.set;
|
|
28098
|
+
if (nativeInputValueSetter && (targetEl instanceof HTMLInputElement || targetEl instanceof HTMLTextAreaElement)) {
|
|
28099
|
+
nativeInputValueSetter.call(targetEl, args.text);
|
|
28100
|
+
targetEl.dispatchEvent(new Event("focus", { bubbles: true, composed: true }));
|
|
28101
|
+
targetEl.dispatchEvent(new Event("input", { bubbles: true, composed: true }));
|
|
28102
|
+
targetEl.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
|
|
28103
|
+
targetEl.dispatchEvent(new Event("blur", { bubbles: true, composed: true }));
|
|
28104
|
+
fillSuccess = true;
|
|
26910
28105
|
}
|
|
26911
28106
|
}
|
|
26912
|
-
|
|
26913
|
-
|
|
26914
|
-
|
|
26915
|
-
|
|
28107
|
+
if (!fillSuccess) {
|
|
28108
|
+
return ctx.errContent(`\u586B\u5199\u7ED3\u679C: \u65E0\u6CD5\u586B\u5199\u5143\u7D20 ${args.index}\uFF0C\u5143\u7D20\u4E0D\u662F input\u3001textarea \u6216 contenteditable`);
|
|
28109
|
+
}
|
|
28110
|
+
if (isInShadowDom(targetEl)) {
|
|
28111
|
+
dispatchComposedEvents(targetEl, "input", "change");
|
|
26916
28112
|
}
|
|
26917
|
-
stack.pop();
|
|
26918
|
-
replacementStack.pop();
|
|
26919
|
-
} else {
|
|
26920
|
-
canonicalizedObj = obj;
|
|
26921
28113
|
}
|
|
26922
|
-
|
|
28114
|
+
await waitForDomSettled();
|
|
28115
|
+
return ctx.buildBrowserStateResponse(mode);
|
|
26923
28116
|
}
|
|
26924
|
-
var arrayDiff = new Diff();
|
|
26925
|
-
arrayDiff.tokenize = function(value) {
|
|
26926
|
-
return value.slice();
|
|
26927
|
-
};
|
|
26928
|
-
arrayDiff.join = arrayDiff.removeEmpty = function(value) {
|
|
26929
|
-
return value;
|
|
26930
|
-
};
|
|
26931
28117
|
|
|
26932
|
-
// ../next-sdk/page-tools/
|
|
26933
|
-
|
|
26934
|
-
|
|
26935
|
-
|
|
28118
|
+
// ../next-sdk/page-tools/handlers/select.ts
|
|
28119
|
+
async function handleSelect(args, ctx) {
|
|
28120
|
+
const mode = args.responseMode ?? "diff";
|
|
28121
|
+
if (args.index === void 0 || typeof args.text !== "string") return ctx.errContent("\u9009\u62E9\u7ED3\u679C: \u7F3A\u5C11\u5143\u7D20\u7D22\u5F15\u6216\u6587\u672C\u5185\u5BB9");
|
|
28122
|
+
let el = ctx.getRefMap().get(args.index);
|
|
28123
|
+
if (!el) return ctx.refreshOnStaleRef("\u9009\u62E9", args.index);
|
|
28124
|
+
let targetSelect = null;
|
|
28125
|
+
if (el instanceof HTMLSelectElement) {
|
|
28126
|
+
targetSelect = el;
|
|
28127
|
+
} else {
|
|
28128
|
+
const innerSelect = el.querySelector("select") ?? el.shadowRoot?.querySelector("select");
|
|
28129
|
+
if (innerSelect) {
|
|
28130
|
+
targetSelect = innerSelect;
|
|
28131
|
+
}
|
|
26936
28132
|
}
|
|
26937
|
-
|
|
26938
|
-
|
|
26939
|
-
return !this.prev || this.prev.url !== currentUrl;
|
|
28133
|
+
if (!targetSelect) {
|
|
28134
|
+
return ctx.errContent(`\u9009\u62E9\u7ED3\u679C: \u65E0\u6CD5\u9009\u62E9\u5143\u7D20 ${args.index}\uFF0C\u672A\u627E\u5230\u5BF9\u5E94\u7684 <select> \u5143\u7D20`);
|
|
26940
28135
|
}
|
|
26941
|
-
|
|
26942
|
-
|
|
26943
|
-
|
|
26944
|
-
|
|
26945
|
-
|
|
26946
|
-
|
|
26947
|
-
|
|
26948
|
-
|
|
26949
|
-
|
|
26950
|
-
|
|
26951
|
-
|
|
26952
|
-
|
|
26953
|
-
|
|
26954
|
-
|
|
26955
|
-
|
|
26956
|
-
|
|
26957
|
-
|
|
26958
|
-
|
|
26959
|
-
|
|
26960
|
-
|
|
26961
|
-
|
|
26962
|
-
|
|
26963
|
-
|
|
26964
|
-
|
|
26965
|
-
|
|
26966
|
-
|
|
28136
|
+
await selectOptionElement(targetSelect, args.text);
|
|
28137
|
+
if (isInShadowDom(targetSelect)) {
|
|
28138
|
+
dispatchComposedEvents(targetSelect, "change");
|
|
28139
|
+
}
|
|
28140
|
+
await waitForDomSettled();
|
|
28141
|
+
return ctx.buildBrowserStateResponse(mode);
|
|
28142
|
+
}
|
|
28143
|
+
|
|
28144
|
+
// ../next-sdk/page-tools/utils/scroll.ts
|
|
28145
|
+
function getScrollInfo(target = window) {
|
|
28146
|
+
if (target === window) {
|
|
28147
|
+
const pageHeight = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
|
|
28148
|
+
const pageWidth = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);
|
|
28149
|
+
const scrollY = window.scrollY;
|
|
28150
|
+
const scrollX = window.scrollX;
|
|
28151
|
+
const pixelsBelow = Math.max(0, pageHeight - (window.innerHeight + scrollY));
|
|
28152
|
+
const pixelsRight = Math.max(0, pageWidth - (window.innerWidth + scrollX));
|
|
28153
|
+
return {
|
|
28154
|
+
scrollY,
|
|
28155
|
+
scrollX,
|
|
28156
|
+
pixelsAbove: scrollY,
|
|
28157
|
+
pixelsBelow,
|
|
28158
|
+
pixelsLeft: scrollX,
|
|
28159
|
+
pixelsRight,
|
|
28160
|
+
pagesAbove: window.innerHeight > 0 ? scrollY / window.innerHeight : 0,
|
|
28161
|
+
pagesBelow: window.innerHeight > 0 ? pixelsBelow / window.innerHeight : 0,
|
|
28162
|
+
atTop: scrollY <= 1,
|
|
28163
|
+
atBottom: pixelsBelow <= 1,
|
|
28164
|
+
atLeft: scrollX <= 1,
|
|
28165
|
+
atRight: pixelsRight <= 1
|
|
28166
|
+
};
|
|
28167
|
+
} else {
|
|
28168
|
+
const el = target;
|
|
28169
|
+
const scrollTop = el.scrollTop;
|
|
28170
|
+
const scrollLeft = el.scrollLeft;
|
|
28171
|
+
const pixelsBelow = el.scrollHeight - el.clientHeight - scrollTop;
|
|
28172
|
+
const pixelsRight = el.scrollWidth - el.clientWidth - scrollLeft;
|
|
28173
|
+
return {
|
|
28174
|
+
scrollY: scrollTop,
|
|
28175
|
+
scrollX: scrollLeft,
|
|
28176
|
+
pixelsAbove: scrollTop,
|
|
28177
|
+
pixelsBelow: Math.max(0, pixelsBelow),
|
|
28178
|
+
pixelsLeft: scrollLeft,
|
|
28179
|
+
pixelsRight: Math.max(0, pixelsRight),
|
|
28180
|
+
pagesAbove: el.clientHeight > 0 ? scrollTop / el.clientHeight : 0,
|
|
28181
|
+
pagesBelow: el.clientHeight > 0 ? Math.max(0, pixelsBelow) / el.clientHeight : 0,
|
|
28182
|
+
atTop: scrollTop <= 1,
|
|
28183
|
+
atBottom: pixelsBelow <= 1,
|
|
28184
|
+
atLeft: scrollLeft <= 1,
|
|
28185
|
+
atRight: pixelsRight <= 1
|
|
28186
|
+
};
|
|
28187
|
+
}
|
|
28188
|
+
}
|
|
28189
|
+
function waitForScrollEnd(target, timeout = 2e3) {
|
|
28190
|
+
return new Promise((resolve) => {
|
|
28191
|
+
let settled = false;
|
|
28192
|
+
const el = target === window ? document : target;
|
|
28193
|
+
const finish = () => {
|
|
28194
|
+
if (settled) return;
|
|
28195
|
+
settled = true;
|
|
28196
|
+
el.removeEventListener("scrollend", onScrollEnd);
|
|
28197
|
+
clearTimeout(timer);
|
|
28198
|
+
resolve();
|
|
28199
|
+
};
|
|
28200
|
+
const onScrollEnd = () => finish();
|
|
28201
|
+
const timer = setTimeout(finish, timeout);
|
|
28202
|
+
el.addEventListener("scrollend", onScrollEnd, { once: true });
|
|
28203
|
+
});
|
|
28204
|
+
}
|
|
28205
|
+
|
|
28206
|
+
// ../next-sdk/page-tools/handlers/scroll.ts
|
|
28207
|
+
async function handleScroll(args, ctx) {
|
|
28208
|
+
const mode = args.responseMode ?? "diff";
|
|
28209
|
+
if (args.down === void 0 && args.right === void 0) return ctx.errContent("\u6EDA\u52A8\u7ED3\u679C: \u7F3A\u5C11\u6EDA\u52A8\u65B9\u5411\u53C2\u6570");
|
|
28210
|
+
let scrollTarget = window;
|
|
28211
|
+
if (args.index !== void 0) {
|
|
28212
|
+
const el = ctx.getRefMap().get(args.index);
|
|
28213
|
+
if (!el) return ctx.refreshOnStaleRef("\u6EDA\u52A8", args.index);
|
|
28214
|
+
scrollTarget = el;
|
|
28215
|
+
}
|
|
28216
|
+
const before = getScrollInfo(scrollTarget);
|
|
28217
|
+
if (args.right !== void 0) {
|
|
28218
|
+
const pixels = args.pixels ?? 300;
|
|
28219
|
+
scrollTarget.scrollBy({ left: args.right ? pixels : -pixels, behavior: "smooth" });
|
|
28220
|
+
} else {
|
|
28221
|
+
const pixels = args.pixels ?? Math.round((args.numPages ?? 1) * window.innerHeight);
|
|
28222
|
+
scrollTarget.scrollBy({ top: args.down ? pixels : -pixels, behavior: "smooth" });
|
|
28223
|
+
}
|
|
28224
|
+
await waitForScrollEnd(scrollTarget);
|
|
28225
|
+
const after = getScrollInfo(scrollTarget);
|
|
28226
|
+
const deltaY = Math.round(after.scrollY - before.scrollY);
|
|
28227
|
+
const deltaX = Math.round(after.scrollX - before.scrollX);
|
|
28228
|
+
const isHorizontal = args.right !== void 0;
|
|
28229
|
+
let scrollMsg;
|
|
28230
|
+
if (Math.abs(deltaY) < 1 && Math.abs(deltaX) < 1) {
|
|
28231
|
+
if (isHorizontal) {
|
|
28232
|
+
scrollMsg = args.right ? "\u26A0\uFE0F \u5DF2\u5230\u8FBE\u53F3\u8FB9\u754C\uFF0C\u65E0\u6CD5\u7EE7\u7EED\u5411\u53F3\u6EDA\u52A8" : "\u26A0\uFE0F \u5DF2\u5230\u8FBE\u5DE6\u8FB9\u754C\uFF0C\u65E0\u6CD5\u7EE7\u7EED\u5411\u5DE6\u6EDA\u52A8";
|
|
28233
|
+
} else {
|
|
28234
|
+
scrollMsg = args.down ? "\u26A0\uFE0F \u5DF2\u5230\u8FBE\u5E95\u90E8\uFF0C\u65E0\u6CD5\u7EE7\u7EED\u5411\u4E0B\u6EDA\u52A8" : "\u26A0\uFE0F \u5DF2\u5230\u8FBE\u9876\u90E8\uFF0C\u65E0\u6CD5\u7EE7\u7EED\u5411\u4E0A\u6EDA\u52A8";
|
|
26967
28235
|
}
|
|
26968
|
-
|
|
26969
|
-
|
|
28236
|
+
} else {
|
|
28237
|
+
const axis = isHorizontal ? `\u6C34\u5E73\u6EDA\u52A8 ${deltaX}px` : `\u5782\u76F4\u6EDA\u52A8 ${deltaY}px`;
|
|
28238
|
+
let boundary = "";
|
|
28239
|
+
if (isHorizontal) {
|
|
28240
|
+
if (args.right && after.atRight) boundary = "\uFF0C\u5DF2\u5230\u8FBE\u53F3\u8FB9\u754C";
|
|
28241
|
+
else if (!args.right && after.atLeft) boundary = "\uFF0C\u5DF2\u5230\u8FBE\u5DE6\u8FB9\u754C";
|
|
28242
|
+
} else {
|
|
28243
|
+
if (args.down && after.atBottom) boundary = "\uFF0C\u5DF2\u5230\u8FBE\u5E95\u90E8";
|
|
28244
|
+
else if (!args.down && after.atTop) boundary = "\uFF0C\u5DF2\u5230\u8FBE\u9876\u90E8";
|
|
28245
|
+
}
|
|
28246
|
+
scrollMsg = `\u2705 ${axis}${boundary}`;
|
|
26970
28247
|
}
|
|
26971
|
-
|
|
26972
|
-
|
|
26973
|
-
|
|
28248
|
+
const posInfo = args.right !== void 0 ? `\u5F53\u524D\u6C34\u5E73\u6EDA\u52A8\u4F4D\u7F6E: scrollX=${Math.round(after.scrollX)}px\uFF0C\u5DE6\u4FA7 ${after.pagesAbove.toFixed(1)} \u5C4F\uFF0C\u53F3\u4FA7 ${after.pagesBelow.toFixed(1)} \u5C4F` : `\u5F53\u524D\u6EDA\u52A8\u4F4D\u7F6E: scrollY=${Math.round(after.scrollY)}px\uFF0C\u4E0A\u65B9 ${after.pagesAbove.toFixed(1)} \u5C4F\uFF0C\u4E0B\u65B9 ${after.pagesBelow.toFixed(1)} \u5C4F`;
|
|
28249
|
+
const scrollResult = `[\u6EDA\u52A8\u7ED3\u679C] ${scrollMsg}
|
|
28250
|
+
${posInfo}`;
|
|
28251
|
+
const stateResult = await ctx.buildBrowserStateResponse(mode);
|
|
28252
|
+
stateResult.content[0].text = `${scrollResult}
|
|
28253
|
+
|
|
28254
|
+
${stateResult.content[0].text}`;
|
|
28255
|
+
return stateResult;
|
|
28256
|
+
}
|
|
28257
|
+
|
|
28258
|
+
// ../next-sdk/page-tools/handlers/executeJavascript.ts
|
|
28259
|
+
async function handleExecuteJavascript(args, ctx) {
|
|
28260
|
+
if (!args.script) return ctx.errContent("\u811A\u672C\u6267\u884C\u5F02\u5E38: \u7F3A\u5C11javascript\u4EE3\u7801");
|
|
28261
|
+
let result2 = await new Function(`return (async () => { ${args.script} })()`)();
|
|
28262
|
+
if (result2 === void 0) {
|
|
28263
|
+
try {
|
|
28264
|
+
result2 = await new Function(`return (async () => (${args.script}))()`)();
|
|
28265
|
+
} catch {
|
|
28266
|
+
}
|
|
26974
28267
|
}
|
|
26975
|
-
|
|
28268
|
+
await ctx.pageController.hideMask();
|
|
28269
|
+
return {
|
|
28270
|
+
content: [{ type: "text", text: `\u811A\u672C\u6267\u884C\u7ED3\u679C: ${JSON.stringify(result2)}` }]
|
|
28271
|
+
};
|
|
28272
|
+
}
|
|
28273
|
+
|
|
28274
|
+
// ../next-sdk/page-tools/handlers/searchTree.ts
|
|
28275
|
+
async function handleSearchTree(args, ctx) {
|
|
28276
|
+
if (!args.query) return ctx.errContent("\u641C\u7D22\u5931\u8D25: \u7F3A\u5C11 query \u53C2\u6570");
|
|
28277
|
+
const blacklist = window.__webmcpcli_interactiveBlacklist ?? [];
|
|
28278
|
+
const whitelist = window.__webmcpcli_interactiveWhitelist ?? [];
|
|
28279
|
+
const exposedAttributes = window.__webmcpcli_exposedAttributes ?? [];
|
|
28280
|
+
const result2 = searchA11yTree(args.query, document.body, blacklist, whitelist, {
|
|
28281
|
+
contextLines: args.contextLines,
|
|
28282
|
+
maxMatches: args.maxMatches,
|
|
28283
|
+
exposedAttributes,
|
|
28284
|
+
errorSelectors: (window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS2).join(", ")
|
|
28285
|
+
});
|
|
28286
|
+
ctx.setRefMap(result2.refMap);
|
|
28287
|
+
ctx.stateCache.update(window.location.href, result2.yaml);
|
|
28288
|
+
await ctx.pageController.hideMask();
|
|
28289
|
+
const dialogAlert = detectPageDialog();
|
|
28290
|
+
const validationErrors = detectValidationErrors();
|
|
28291
|
+
const alerts = `${dialogAlert}${validationErrors}`;
|
|
28292
|
+
return {
|
|
28293
|
+
content: [{ type: "text", text: alerts ? `${alerts}
|
|
28294
|
+
${result2.text}` : result2.text }]
|
|
28295
|
+
};
|
|
28296
|
+
}
|
|
26976
28297
|
|
|
26977
28298
|
// ../next-sdk/page-tools/page-agent-tool.ts
|
|
26978
|
-
function registerPageAgentTool() {
|
|
28299
|
+
function registerPageAgentTool(options = {}) {
|
|
26979
28300
|
initializeBuiltinWebMCP();
|
|
26980
|
-
|
|
26981
|
-
|
|
26982
|
-
|
|
26983
|
-
|
|
28301
|
+
if (typeof options.enableHighlight === "undefined") {
|
|
28302
|
+
options.enableHighlight = true;
|
|
28303
|
+
}
|
|
28304
|
+
window.__webmcpcli_interactiveWhitelist = window.__webmcpcli_interactiveWhitelist || [];
|
|
28305
|
+
window.__webmcpcli_interactiveBlacklist = window.__webmcpcli_interactiveBlacklist || [];
|
|
28306
|
+
window.__webmcpcli_exposedAttributes = window.__webmcpcli_exposedAttributes || options?.exposedAttributes || [];
|
|
28307
|
+
window.__webmcpcli_beforeGetBrowserState = window.__webmcpcli_beforeGetBrowserState || null;
|
|
28308
|
+
window.__webmcpcli_errorSelectors = window.__webmcpcli_errorSelectors || DEFAULT_ERROR_SELECTORS2;
|
|
28309
|
+
window.__webmcpcli_dialogSelectors = window.__webmcpcli_dialogSelectors || DEFAULT_DIALOG_SELECTORS;
|
|
28310
|
+
const pageController = new PageController({ enableMask: false });
|
|
28311
|
+
pageController.maskReady = (async () => {
|
|
28312
|
+
pageController.mask = new SimulatorMask2();
|
|
28313
|
+
})();
|
|
26984
28314
|
const stateCache = new PageStateCache();
|
|
26985
28315
|
let currentRefMap = /* @__PURE__ */ new Map();
|
|
26986
|
-
const inputSchema = external_exports.object({
|
|
26987
|
-
action: external_exports.enum(["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree"]).describe(`\u6267\u884C\u7684\u52A8\u4F5C\u540D\u79F0, \u6BCF\u4E00\u6B21\u6267\u884C 'click', 'fill', 'select'\u52A8\u4F5C\u4E4B\u524D\uFF0C**\u5FC5\u987B**\u8981\u5148\u8C03\u7528 'browserState' \u53BB\u83B7\u53D6\u9875\u9762\u7684\u6700\u65B0\u72B6\u6001\u3002
|
|
26988
|
-
browserState: '\u67E5\u8BE2\u6574\u4E2A\u9875\u9762\u7684\u6D4F\u89C8\u5668\u72B6\u6001;\u8FD4\u56DE\u9875\u9762\u7684\u6807\u9898\u3001URL\u3001YAML\u683C\u5F0F\u7684\u8BED\u4E49\u5316\u9875\u9762\u6811',
|
|
26989
|
-
click: '\u6839\u636E\u5143\u7D20\u7D22\u5F15\u70B9\u51FB;',
|
|
26990
|
-
fill: '\u6839\u636E\u5143\u7D20\u7D22\u5F15\u586B\u5199\u6587\u672C;';
|
|
26991
|
-
select: '\u6839\u636E\u5143\u7D20\u7D22\u5F15\u9009\u62E9\u4E0B\u62C9\u6846\u9009\u9879;';
|
|
26992
|
-
scroll: '\u6EDA\u52A8\u9875\u9762\u7684\u52A8\u4F5C\uFF0C\u53EF\u4EE5\u6307\u5B9A\u6C34\u5E73\u6EDA\u52A8\u8FD8\u662F\u4E0A\u4E0B\u6EDA\u52A8; \u4E0D\u5E26\u5143\u7D20\u7D22\u5F15\u65F6\uFF1A\u6EDA\u52A8\u6574\u4E2A\u6587\u6863\u3002\u5E26\u5143\u7D20\u7D22\u5F15\u65F6\uFF1A\u6EDA\u52A8\u8BE5\u7D22\u5F15\u5904\u7684\u5BB9\u5668\uFF08\u6216\u5176\u6700\u8FD1\u7684\u53EF\u6EDA\u52A8\u7956\u5148\u5143\u7D20\uFF09'
|
|
26993
|
-
executeJavascript: '\u6267\u884Cjavascript\u4EE3\u7801'
|
|
26994
|
-
searchTree: '\u6309\u5173\u952E\u8BCD\u641C\u7D22\u65E0\u969C\u788D\u6811\uFF0C\u8FD4\u56DE\u5E26\u884C\u53F7\u7684\u5339\u914D\u8282\u70B9\u53CA\u4E0A\u4E0B\u6587\uFF0C\u65E0\u9700\u83B7\u53D6\u5168\u91CF\u6811\u3002\u9002\u5408\u5FEB\u901F\u5B9A\u4F4D\u7279\u5B9A\u5143\u7D20\uFF08\u5982\u6240\u6709\u6309\u94AE\u3001\u7279\u5B9A\u540D\u79F0\u7684\u94FE\u63A5\u7B49\uFF09\uFF0C\u663E\u8457\u51CF\u5C11\u4E0A\u4E0B\u6587\u6D88\u8017\u3002\u5FC5\u987B\u63D0\u4F9B query \u53C2\u6570\u3002'
|
|
26995
|
-
`),
|
|
26996
|
-
index: external_exports.number().min(0).optional().describe("\u6267\u884C\u52A8\u4F5C of the element index, \u52A8\u4F5C\u4E3A click,fill,select\u65F6\uFF0C\u5FC5\u987B\u63D0\u4F9B\u5143\u7D20\u7D22\u5F15"),
|
|
26997
|
-
text: external_exports.string().optional().describe("\u6267\u884C\u52A8\u4F5C\u7684\u6587\u672C\u5185\u5BB9, \u52A8\u4F5C\u4E3A fill,select \u65F6\uFF0C\u5FC5\u987B\u63D0\u4F9B\u6587\u672C\u5185\u5BB9"),
|
|
26998
|
-
down: external_exports.boolean().optional().describe("\u6267\u884C\u4E0A\u4E0B\u6EDA\u52A8\u65F6\uFF0C\u5FC5\u987B\u63D0\u4F9Bdown\u53C2\u6570"),
|
|
26999
|
-
right: external_exports.boolean().optional().describe("\u6267\u884C\u6C34\u5E73\u6EDA\u52A8\u65B9\u5411, \u5FC5\u987B\u63D0\u4F9Bright\u53C2\u6570"),
|
|
27000
|
-
numPages: external_exports.number().optional().describe("\u6267\u884C\u52A8\u4F5C\u7684\u6EDA\u52A8\u9875\u6570, \u52A8\u4F5C\u4E3A scroll\u65F6\uFF0C\u53EF\u4EE5\u63D0\u4F9B\u6EDA\u52A8\u9875\u6570\uFF0C\u5EFA\u8BAE\u6BCF\u6B21\u6EDA\u52A80.1\u9875\uFF0C\u8BE5\u503C\u4E0D\u8981\u5927\u4E8E5."),
|
|
27001
|
-
pixels: external_exports.number().int().min(0).optional().describe("\u6267\u884C\u52A8\u4F5C\u7684\u6EDA\u52A8\u50CF\u7D20\u6570\uFF0C\u52A8\u4F5C\u4E3A scroll\u65F6\uFF0C\u53EF\u4EE5\u63D0\u4F9B\u6EDA\u52A8\u50CF\u7D20\u6570"),
|
|
27002
|
-
script: external_exports.string().optional().describe("\u6267\u884C\u7684javascript\u4EE3\u7801\uFF0C\u52A8\u4F5C\u4E3A executeJavascript\u65F6\uFF0C\u5FC5\u987B\u63D0\u4F9Bscript\u53C2\u6570"),
|
|
27003
|
-
query: external_exports.string().optional().describe("\u641C\u7D22\u5173\u952E\u8BCD\uFF0C\u52A8\u4F5C\u4E3A searchTree \u65F6\u5FC5\u987B\u63D0\u4F9B\u3002\u652F\u6301\u6309 role\uFF08\u5982 button\u3001link\uFF09\u3001\u8282\u70B9\u540D\u79F0\u3001\u72B6\u6001\uFF08\u5982 checked\uFF09\u6216 ref \u7D22\u5F15\uFF08\u5982 #3\uFF09\u641C\u7D22"),
|
|
27004
|
-
contextLines: external_exports.number().int().min(0).max(10).default(2).describe("searchTree \u65F6\u6BCF\u4E2A\u547D\u4E2D\u884C\u524D\u540E\u4FDD\u7559\u7684\u4E0A\u4E0B\u6587\u884C\u6570\uFF0C\u9ED8\u8BA4 2"),
|
|
27005
|
-
maxMatches: external_exports.number().int().min(1).max(50).default(20).describe("searchTree \u65F6\u6700\u5927\u8FD4\u56DE\u5206\u7EC4\u6570\uFF0C\u9ED8\u8BA4 20"),
|
|
27006
|
-
responseMode: external_exports.enum(["full", "diff", "both"]).optional().default("diff").describe("\u8FD4\u56DE\u6D4F\u89C8\u5668\u72B6\u6001\u7684\u6A21\u5F0F\u3002full: \u4EC5\u8FD4\u56DE\u5F53\u524D\u5168\u91CF A11y \u6811\uFF1Bdiff: \u4EC5\u8FD4\u56DE\u4E0E\u4E0A\u4E00\u6B21\u72B6\u6001\u7684\u589E\u91CF\u5DEE\u5F02\uFF1Bboth: \u540C\u65F6\u8FD4\u56DE\u5168\u91CF A11y \u6811\u4E0E\u589E\u91CF\u5DEE\u5F02\u3002\u9ED8\u8BA4\u503C\u4E3A diff\u3002")
|
|
27007
|
-
});
|
|
27008
28316
|
async function errContent(msg) {
|
|
27009
28317
|
await pageController.hideMask();
|
|
27010
28318
|
return { content: [{ type: "text", text: msg }] };
|
|
27011
28319
|
}
|
|
28320
|
+
async function refreshOnStaleRef(action, index) {
|
|
28321
|
+
const refreshResult = await buildBrowserStateResponse("full");
|
|
28322
|
+
const warning = `\u26A0\uFE0F ${action}\u5931\u8D25: ref \u7D22\u5F15 ${index} \u5DF2\u5931\u6548\uFF08\u9875\u9762\u53EF\u80FD\u5DF2\u5237\u65B0\uFF09\uFF0C\u5DF2\u81EA\u52A8\u91CD\u65B0\u52A0\u8F7D\u9875\u9762\u72B6\u6001\uFF0C\u8BF7\u4F7F\u7528\u65B0\u7684 ref \u7D22\u5F15\u91CD\u8BD5\u3002
|
|
28323
|
+
`;
|
|
28324
|
+
return {
|
|
28325
|
+
content: [{ type: "text", text: warning + refreshResult.content[0].text }]
|
|
28326
|
+
};
|
|
28327
|
+
}
|
|
27012
28328
|
async function buildBrowserStateResponse(responseMode = "diff") {
|
|
27013
28329
|
const url2 = window.location.href;
|
|
27014
28330
|
const title = document.title;
|
|
27015
28331
|
const blacklist = window.__webmcpcli_interactiveBlacklist ?? [];
|
|
27016
28332
|
const whitelist = window.__webmcpcli_interactiveWhitelist ?? [];
|
|
27017
|
-
const
|
|
28333
|
+
const exposedAttributes = window.__webmcpcli_exposedAttributes ?? [];
|
|
28334
|
+
const { yaml, refMap } = buildA11yTree(document.body, blacklist, whitelist, {
|
|
28335
|
+
exposedAttributes,
|
|
28336
|
+
errorSelectors: (window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS2).join(", ")
|
|
28337
|
+
});
|
|
27018
28338
|
currentRefMap = refMap;
|
|
28339
|
+
if (options?.enableHighlight) {
|
|
28340
|
+
highlight(refMap);
|
|
28341
|
+
globalRemoveListener();
|
|
28342
|
+
}
|
|
27019
28343
|
const diff2 = stateCache.update(url2, yaml);
|
|
27020
28344
|
await pageController.hideMask();
|
|
28345
|
+
const dialogAlert = detectPageDialog();
|
|
28346
|
+
const validationErrors = detectValidationErrors();
|
|
27021
28347
|
let displayContent = "";
|
|
27022
28348
|
if (responseMode === "full") {
|
|
27023
28349
|
displayContent = yaml;
|
|
@@ -27035,92 +28361,46 @@ ${diff2.isFullRefresh ? "\uFF08\u9996\u6B21/\u5237\u65B0\uFF0C\u65E0\u589E\u91CF
|
|
|
27035
28361
|
title,
|
|
27036
28362
|
content: displayContent
|
|
27037
28363
|
};
|
|
27038
|
-
const text = `\u6D4F\u89C8\u5668\u72B6\u6001: ${JSON.stringify(stateObj)}`;
|
|
28364
|
+
const text = `\u6D4F\u89C8\u5668\u72B6\u6001: ${JSON.stringify(stateObj)}${dialogAlert}${validationErrors}`;
|
|
27039
28365
|
return { content: [{ type: "text", text }] };
|
|
27040
28366
|
}
|
|
27041
|
-
|
|
28367
|
+
const actionContext = {
|
|
28368
|
+
pageController,
|
|
28369
|
+
stateCache,
|
|
28370
|
+
getRefMap: () => currentRefMap,
|
|
28371
|
+
setRefMap: (map) => {
|
|
28372
|
+
currentRefMap = map;
|
|
28373
|
+
},
|
|
28374
|
+
buildBrowserStateResponse,
|
|
28375
|
+
refreshOnStaleRef,
|
|
28376
|
+
errContent
|
|
28377
|
+
};
|
|
28378
|
+
document.modelContext.registerTool({
|
|
27042
28379
|
name: "page-agent-tool",
|
|
27043
28380
|
description: page_agent_prompt_default,
|
|
27044
28381
|
// @ts-ignore
|
|
27045
28382
|
inputSchema: zodToJsonSchema(inputSchema),
|
|
27046
28383
|
async execute(args) {
|
|
27047
28384
|
await pageController.showMask();
|
|
27048
|
-
const mode = args.responseMode ?? "diff";
|
|
27049
28385
|
try {
|
|
27050
|
-
|
|
27051
|
-
|
|
27052
|
-
|
|
27053
|
-
|
|
27054
|
-
|
|
27055
|
-
|
|
27056
|
-
|
|
27057
|
-
|
|
27058
|
-
|
|
27059
|
-
|
|
27060
|
-
|
|
27061
|
-
|
|
27062
|
-
|
|
27063
|
-
|
|
27064
|
-
|
|
27065
|
-
|
|
27066
|
-
|
|
27067
|
-
|
|
27068
|
-
if (innerInput) {
|
|
27069
|
-
targetEl = innerInput;
|
|
27070
|
-
}
|
|
27071
|
-
}
|
|
27072
|
-
if (targetEl instanceof HTMLInputElement && targetEl.readOnly) {
|
|
27073
|
-
targetEl.value = args.text;
|
|
27074
|
-
targetEl.dispatchEvent(new Event("input", { bubbles: true }));
|
|
27075
|
-
targetEl.dispatchEvent(new Event("change", { bubbles: true }));
|
|
27076
|
-
targetEl.dispatchEvent(new Event("blur", { bubbles: true }));
|
|
27077
|
-
} else {
|
|
27078
|
-
await inputTextElement(targetEl, args.text);
|
|
27079
|
-
}
|
|
27080
|
-
return buildBrowserStateResponse(mode);
|
|
27081
|
-
} else if (args.action === "select") {
|
|
27082
|
-
if (args.index === void 0 || !args.text) return errContent("\u9009\u62E9\u7ED3\u679C: \u7F3A\u5C11\u5143\u7D20\u7D22\u5F15\u6216\u6587\u672C\u5185\u5BB9");
|
|
27083
|
-
const el = currentRefMap.get(args.index);
|
|
27084
|
-
if (!el) return errContent(`\u9009\u62E9\u7ED3\u679C: \u65E0\u6548\u7684 ref \u7D22\u5F15 ${args.index}\uFF0C\u8BF7\u5148\u8C03\u7528 browserState \u5237\u65B0\u9875\u9762\u72B6\u6001`);
|
|
27085
|
-
await selectOptionElement(el, args.text);
|
|
27086
|
-
return buildBrowserStateResponse(mode);
|
|
27087
|
-
} else if (args.action === "scroll") {
|
|
27088
|
-
if (!args.down && !args.right) return errContent("\u6EDA\u52A8\u7ED3\u679C: \u7F3A\u5C11\u6EDA\u52A8\u65B9\u5411\u53C2\u6570");
|
|
27089
|
-
const scrollTarget = args.index !== void 0 ? currentRefMap.get(args.index) ?? window : window;
|
|
27090
|
-
if (args.right) {
|
|
27091
|
-
const pixels = args.pixels ?? 300;
|
|
27092
|
-
scrollTarget.scrollBy({ left: args.right ? pixels : -pixels, behavior: "smooth" });
|
|
27093
|
-
} else {
|
|
27094
|
-
const pixels = args.pixels ?? Math.round((args.numPages ?? 1) * window.innerHeight);
|
|
27095
|
-
scrollTarget.scrollBy({ top: args.down ? pixels : -pixels, behavior: "smooth" });
|
|
27096
|
-
}
|
|
27097
|
-
await new Promise((r) => setTimeout(r, 400));
|
|
27098
|
-
return buildBrowserStateResponse(mode);
|
|
27099
|
-
} else if (args.action === "executeJavascript") {
|
|
27100
|
-
if (!args.script) return errContent("\u811A\u672C\u6267\u884C\u5F02\u5E38: \u7F3A\u5C11javascript\u4EE3\u7801");
|
|
27101
|
-
const result2 = await new Function(`return (async () => { ${args.script} })()`)();
|
|
27102
|
-
await pageController.hideMask();
|
|
27103
|
-
return {
|
|
27104
|
-
content: [{ type: "text", text: `\u811A\u672C\u6267\u884C\u7ED3\u679C: ${JSON.stringify(result2)}` }]
|
|
27105
|
-
};
|
|
27106
|
-
} else if (args.action === "searchTree") {
|
|
27107
|
-
if (!args.query) return errContent("\u641C\u7D22\u5931\u8D25: \u7F3A\u5C11 query \u53C2\u6570");
|
|
27108
|
-
const blacklist = window.__webmcpcli_interactiveBlacklist ?? [];
|
|
27109
|
-
const whitelist = window.__webmcpcli_interactiveWhitelist ?? [];
|
|
27110
|
-
const { text } = searchA11yTree(
|
|
27111
|
-
args.query,
|
|
27112
|
-
document.body,
|
|
27113
|
-
blacklist,
|
|
27114
|
-
whitelist,
|
|
27115
|
-
{
|
|
27116
|
-
contextLines: args.contextLines,
|
|
27117
|
-
maxMatches: args.maxMatches
|
|
27118
|
-
}
|
|
27119
|
-
);
|
|
27120
|
-
await pageController.hideMask();
|
|
27121
|
-
return {
|
|
27122
|
-
content: [{ type: "text", text }]
|
|
27123
|
-
};
|
|
28386
|
+
switch (args.action) {
|
|
28387
|
+
case "browserState":
|
|
28388
|
+
return await handleBrowserState(args, actionContext);
|
|
28389
|
+
case "click":
|
|
28390
|
+
return await handleClick(args, actionContext);
|
|
28391
|
+
case "fill":
|
|
28392
|
+
return await handleFill(args, actionContext);
|
|
28393
|
+
case "select":
|
|
28394
|
+
return await handleSelect(args, actionContext);
|
|
28395
|
+
case "scroll":
|
|
28396
|
+
return await handleScroll(args, actionContext);
|
|
28397
|
+
case "executeJavascript":
|
|
28398
|
+
return await handleExecuteJavascript(args, actionContext);
|
|
28399
|
+
case "searchTree":
|
|
28400
|
+
return await handleSearchTree(args, actionContext);
|
|
28401
|
+
default:
|
|
28402
|
+
await pageController.hideMask();
|
|
28403
|
+
return { content: [{ type: "text", text: `\u672A\u77E5\u64CD\u4F5C: ${args.action}` }] };
|
|
27124
28404
|
}
|
|
27125
28405
|
} catch (error2) {
|
|
27126
28406
|
await pageController.hideMask();
|
|
@@ -27132,9 +28412,9 @@ ${diff2.isFullRefresh ? "\uFF08\u9996\u6B21/\u5237\u65B0\uFF0C\u65E0\u589E\u91CF
|
|
|
27132
28412
|
|
|
27133
28413
|
// src/inject/page-init.ts
|
|
27134
28414
|
async function syncTools() {
|
|
27135
|
-
const ctx =
|
|
27136
|
-
if (ctx?.
|
|
27137
|
-
window.__webmcpcli_tools = await ctx.
|
|
28415
|
+
const ctx = document.modelContext;
|
|
28416
|
+
if (ctx?.getTools) {
|
|
28417
|
+
window.__webmcpcli_tools = await ctx.getTools();
|
|
27138
28418
|
}
|
|
27139
28419
|
}
|
|
27140
28420
|
function initWebMcpCliPage() {
|
|
@@ -27142,10 +28422,14 @@ ${diff2.isFullRefresh ? "\uFF08\u9996\u6B21/\u5237\u65B0\uFF0C\u65E0\u589E\u91CF
|
|
|
27142
28422
|
return;
|
|
27143
28423
|
}
|
|
27144
28424
|
initializeWebMCPPolyfill();
|
|
27145
|
-
registerPageAgentTool();
|
|
28425
|
+
registerPageAgentTool({ exposedAttributes: ["cf-uba"] });
|
|
27146
28426
|
window.__webmcpcli_tools = [];
|
|
27147
|
-
const ctx =
|
|
27148
|
-
if (ctx?.
|
|
28427
|
+
const ctx = document.modelContext;
|
|
28428
|
+
if (ctx?.addEventListener) {
|
|
28429
|
+
ctx.addEventListener("toolchange", () => {
|
|
28430
|
+
void syncTools();
|
|
28431
|
+
});
|
|
28432
|
+
} else if (ctx?.registerToolsChangedCallback) {
|
|
27149
28433
|
ctx.registerToolsChangedCallback(() => {
|
|
27150
28434
|
void syncTools();
|
|
27151
28435
|
});
|