@bini-bar-labs/atomic-web-agent-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +153 -0
- package/dist/AWAgent/AWAgent.d.ts +35 -0
- package/dist/AWAgent/AWAgent.d.ts.map +1 -0
- package/dist/AWAgent/AWAgent.js +115 -0
- package/dist/AWAgent/AWAgent.js.map +1 -0
- package/dist/AWAgent/AWAgent.types.d.ts +3 -0
- package/dist/AWAgent/AWAgent.types.d.ts.map +1 -0
- package/dist/AWAgent/AWAgent.types.js +2 -0
- package/dist/AWAgent/AWAgent.types.js.map +1 -0
- package/dist/AWAgent/middlewares/logging-calls.middleware.d.ts +2 -0
- package/dist/AWAgent/middlewares/logging-calls.middleware.d.ts.map +1 -0
- package/dist/AWAgent/middlewares/logging-calls.middleware.js +17 -0
- package/dist/AWAgent/middlewares/logging-calls.middleware.js.map +1 -0
- package/dist/AWAgent/middlewares/trim-messages-history.middleware.d.ts +2 -0
- package/dist/AWAgent/middlewares/trim-messages-history.middleware.d.ts.map +1 -0
- package/dist/AWAgent/middlewares/trim-messages-history.middleware.js +11 -0
- package/dist/AWAgent/middlewares/trim-messages-history.middleware.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/click-by-element-id.tool.d.ts +14 -0
- package/dist/tools/click-by-element-id.tool.d.ts.map +1 -0
- package/dist/tools/click-by-element-id.tool.js +32 -0
- package/dist/tools/click-by-element-id.tool.js.map +1 -0
- package/dist/tools/click-by-position.tool.d.ts +17 -0
- package/dist/tools/click-by-position.tool.d.ts.map +1 -0
- package/dist/tools/click-by-position.tool.js +18 -0
- package/dist/tools/click-by-position.tool.js.map +1 -0
- package/dist/tools/click-by-selector.tool.d.ts +13 -0
- package/dist/tools/click-by-selector.tool.d.ts.map +1 -0
- package/dist/tools/click-by-selector.tool.js +17 -0
- package/dist/tools/click-by-selector.tool.js.map +1 -0
- package/dist/tools/get-DOM-snapshot.tool.d.ts +4 -0
- package/dist/tools/get-DOM-snapshot.tool.d.ts.map +1 -0
- package/dist/tools/get-DOM-snapshot.tool.js +26 -0
- package/dist/tools/get-DOM-snapshot.tool.js.map +1 -0
- package/dist/tools/get-page-screenshot.tool.d.ts +3 -0
- package/dist/tools/get-page-screenshot.tool.d.ts.map +1 -0
- package/dist/tools/get-page-screenshot.tool.js +13 -0
- package/dist/tools/get-page-screenshot.tool.js.map +1 -0
- package/dist/tools/input-by-element-id.tool.d.ts +18 -0
- package/dist/tools/input-by-element-id.tool.d.ts.map +1 -0
- package/dist/tools/input-by-element-id.tool.js +39 -0
- package/dist/tools/input-by-element-id.tool.js.map +1 -0
- package/dist/tools/input.tool.d.ts +17 -0
- package/dist/tools/input.tool.d.ts.map +1 -0
- package/dist/tools/input.tool.js +21 -0
- package/dist/tools/input.tool.js.map +1 -0
- package/dist/tools/navigate.tool.d.ts +10 -0
- package/dist/tools/navigate.tool.d.ts.map +1 -0
- package/dist/tools/navigate.tool.js +16 -0
- package/dist/tools/navigate.tool.js.map +1 -0
- package/dist/tools/print-to-console.tool.d.ts +12 -0
- package/dist/tools/print-to-console.tool.d.ts.map +1 -0
- package/dist/tools/print-to-console.tool.js +16 -0
- package/dist/tools/print-to-console.tool.js.map +1 -0
- package/dist/tools/utils/accessibility-snapshot.util.d.ts +34 -0
- package/dist/tools/utils/accessibility-snapshot.util.d.ts.map +1 -0
- package/dist/tools/utils/accessibility-snapshot.util.js +244 -0
- package/dist/tools/utils/accessibility-snapshot.util.js.map +1 -0
- package/dist/tools/utils/element-registry.util.d.ts +39 -0
- package/dist/tools/utils/element-registry.util.d.ts.map +1 -0
- package/dist/tools/utils/element-registry.util.js +55 -0
- package/dist/tools/utils/element-registry.util.js.map +1 -0
- package/dist/tools/utils/minimize-snapshot.util.d.ts +2 -0
- package/dist/tools/utils/minimize-snapshot.util.d.ts.map +1 -0
- package/dist/tools/utils/minimize-snapshot.util.js +43 -0
- package/dist/tools/utils/minimize-snapshot.util.js.map +1 -0
- package/dist/tools/wait.tool.d.ts +12 -0
- package/dist/tools/wait.tool.d.ts.map +1 -0
- package/dist/tools/wait.tool.js +16 -0
- package/dist/tools/wait.tool.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { tool } from "langchain";
|
|
2
|
+
import {} from "playwright";
|
|
3
|
+
export function getPageScreenShotTool(page) {
|
|
4
|
+
return tool(async () => {
|
|
5
|
+
console.log("Taking screenshot...");
|
|
6
|
+
const screenshot = await page.screenshot({ type: "jpeg" });
|
|
7
|
+
return screenshot;
|
|
8
|
+
}, {
|
|
9
|
+
name: "GetPageScreenShot",
|
|
10
|
+
description: "Take a screenshot of the current page and return it as a JPEG image.",
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=get-page-screenshot.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-page-screenshot.tool.js","sourceRoot":"","sources":["../../src/tools/get-page-screenshot.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAa,MAAM,YAAY,CAAC;AAEvC,MAAM,UAAU,qBAAqB,CAAC,IAAU;IAC9C,OAAO,IAAI,CACT,KAAK,IAAI,EAAE;QACT,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3D,OAAO,UAAU,CAAC;IACpB,CAAC,EACD;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EACT,sEAAsE;KACzE,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Page } from "playwright";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
import { type ElementLocatorRegistry } from "./utils/element-registry.util.js";
|
|
4
|
+
export declare const InputByElementIdToolSchema: z.ZodObject<{
|
|
5
|
+
elementId: z.ZodString;
|
|
6
|
+
text: z.ZodString;
|
|
7
|
+
}, z.z.core.$strip>;
|
|
8
|
+
export declare function inputByElementIdTool(_page: Page, elementRegistry: ElementLocatorRegistry): import("langchain").DynamicStructuredTool<z.ZodObject<{
|
|
9
|
+
elementId: z.ZodString;
|
|
10
|
+
text: z.ZodString;
|
|
11
|
+
}, z.z.core.$strip>, {
|
|
12
|
+
elementId: string;
|
|
13
|
+
text: string;
|
|
14
|
+
}, {
|
|
15
|
+
elementId: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}, string>;
|
|
18
|
+
//# sourceMappingURL=input-by-element-id.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-by-element-id.tool.d.ts","sourceRoot":"","sources":["../../src/tools/input-by-element-id.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE/E,eAAO,MAAM,0BAA0B;;;mBAKrC,CAAC;AAEH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,IAAI,EACX,eAAe,EAAE,sBAAsB;;;;;;;;;WAqCxC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { tool } from "langchain";
|
|
2
|
+
import {} from "playwright";
|
|
3
|
+
import z from "zod";
|
|
4
|
+
import {} from "./utils/element-registry.util.js";
|
|
5
|
+
export const InputByElementIdToolSchema = z.object({
|
|
6
|
+
elementId: z
|
|
7
|
+
.string()
|
|
8
|
+
.describe("The element ID from the accessibility snapshot to input text into"),
|
|
9
|
+
text: z.string().describe("The text to input into the element"),
|
|
10
|
+
});
|
|
11
|
+
export function inputByElementIdTool(_page, elementRegistry) {
|
|
12
|
+
return tool(async ({ elementId, text }) => {
|
|
13
|
+
console.log(`Inputting text into element: ${elementId}`);
|
|
14
|
+
const locator = elementRegistry.get(elementId);
|
|
15
|
+
if (!locator) {
|
|
16
|
+
throw new Error(`Element ID "${elementId}" not found in registry. Please take a fresh DOM snapshot first using GetDOMSnapshot tool.`);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
// Check if element is editable
|
|
20
|
+
const isEditable = await locator.isEditable().catch(() => false);
|
|
21
|
+
if (!isEditable) {
|
|
22
|
+
throw new Error(`Element ${elementId} is not editable`);
|
|
23
|
+
}
|
|
24
|
+
await locator.fill(text, { timeout: 5000 });
|
|
25
|
+
return `Successfully filled element ${elementId} with text: "${text}"`;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new Error(`Failed to input text into element ${elementId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
name: "InputByElementId",
|
|
32
|
+
description: `Input text into an element using its ID from the accessibility snapshot.
|
|
33
|
+
The element ID should come from the most recent GetDOMSnapshot result.
|
|
34
|
+
This is the recommended way to fill form fields instead of using CSS selectors.
|
|
35
|
+
Only works with editable elements like textboxes and search boxes.`,
|
|
36
|
+
schema: InputByElementIdToolSchema,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=input-by-element-id.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-by-element-id.tool.js","sourceRoot":"","sources":["../../src/tools/input-by-element-id.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAa,MAAM,YAAY,CAAC;AACvC,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAA+B,MAAM,kCAAkC,CAAC;AAE/E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,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QAC7D,MAAM,EAAE,0BAA0B;KACnC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Page } from "playwright";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
export declare const InputBySelectorToolSchema: z.ZodObject<{
|
|
4
|
+
selector: z.ZodString;
|
|
5
|
+
text: z.ZodString;
|
|
6
|
+
}, z.z.core.$strip>;
|
|
7
|
+
export declare function inputTool(page: Page): import("langchain").DynamicStructuredTool<z.ZodObject<{
|
|
8
|
+
selector: z.ZodString;
|
|
9
|
+
text: z.ZodString;
|
|
10
|
+
}, z.z.core.$strip>, {
|
|
11
|
+
selector: string;
|
|
12
|
+
text: string;
|
|
13
|
+
}, {
|
|
14
|
+
selector: string;
|
|
15
|
+
text: string;
|
|
16
|
+
}, void>;
|
|
17
|
+
//# sourceMappingURL=input.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.tool.d.ts","sourceRoot":"","sources":["../../src/tools/input.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,yBAAyB;;;mBAGpC,CAAC;AAEH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI;;;;;;;;;SAmBnC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { tool } from "langchain";
|
|
2
|
+
import {} from "playwright";
|
|
3
|
+
import { expect } from "playwright/test";
|
|
4
|
+
import z from "zod";
|
|
5
|
+
export const InputBySelectorToolSchema = z.object({
|
|
6
|
+
selector: z.string().describe("The CSS selector of the element to input"),
|
|
7
|
+
text: z.string().describe("The text to input into the element"),
|
|
8
|
+
});
|
|
9
|
+
export function inputTool(page) {
|
|
10
|
+
return tool(async ({ selector, text }) => {
|
|
11
|
+
console.log(`Inputting text into selector: ${selector} with text: ${text}`);
|
|
12
|
+
const element = page.locator(selector);
|
|
13
|
+
await expect(element, `Expected to find 1 element with selector ${selector}, got: ${await element.count()}`).toHaveCount(1);
|
|
14
|
+
return await element.fill(text, { timeout: 1000 });
|
|
15
|
+
}, {
|
|
16
|
+
name: "InputBySelector",
|
|
17
|
+
description: "Input text into an element with the given CSS selector",
|
|
18
|
+
schema: InputBySelectorToolSchema,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=input.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.tool.js","sourceRoot":"","sources":["../../src/tools/input.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAa,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IACzE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;CAChE,CAAC,CAAC;AAEH,MAAM,UAAU,SAAS,CAAC,IAAU;IAClC,OAAO,IAAI,CACT,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE;QAC3B,OAAO,CAAC,GAAG,CACT,iCAAiC,QAAQ,eAAe,IAAI,EAAE,CAC/D,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,MAAM,MAAM,CACV,OAAO,EACP,4CAA4C,QAAQ,UAAU,MAAM,OAAO,CAAC,KAAK,EAAE,EAAE,CACtF,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC,EACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,wDAAwD;QACrE,MAAM,EAAE,yBAAyB;KAClC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Page } from "playwright";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
export declare function navigateTool(page: Page): import("langchain").DynamicStructuredTool<z.ZodObject<{
|
|
4
|
+
url: z.ZodString;
|
|
5
|
+
}, z.z.core.$strip>, {
|
|
6
|
+
url: string;
|
|
7
|
+
}, {
|
|
8
|
+
url: string;
|
|
9
|
+
}, import("playwright").Response | null>;
|
|
10
|
+
//# sourceMappingURL=navigate.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigate.tool.d.ts","sourceRoot":"","sources":["../../src/tools/navigate.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI;;;;;;yCActC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { tool } from "langchain";
|
|
2
|
+
import {} from "playwright";
|
|
3
|
+
import z from "zod";
|
|
4
|
+
export function navigateTool(page) {
|
|
5
|
+
return tool(async ({ url }) => {
|
|
6
|
+
console.log(`Navigating to URL: ${url}`);
|
|
7
|
+
return await page.goto(url);
|
|
8
|
+
}, {
|
|
9
|
+
name: "NavigateToURL",
|
|
10
|
+
description: "Navigate to a specified URL",
|
|
11
|
+
schema: z.object({
|
|
12
|
+
url: z.string().url().describe("The URL to navigate to"),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=navigate.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigate.tool.js","sourceRoot":"","sources":["../../src/tools/navigate.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAa,MAAM,YAAY,CAAC;AACvC,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,UAAU,YAAY,CAAC,IAAU;IACrC,OAAO,IAAI,CACT,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QAChB,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,EAAE,CAAC,CAAC;QACzC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC,EACD;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,6BAA6B;QAC1C,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;YACf,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;SACzD,CAAC;KACH,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare const PrintToConsoleToolSchema: z.ZodObject<{
|
|
3
|
+
message: z.ZodString;
|
|
4
|
+
}, z.z.core.$strip>;
|
|
5
|
+
export declare function printToConsoleTool(): import("langchain").DynamicStructuredTool<z.ZodObject<{
|
|
6
|
+
message: z.ZodString;
|
|
7
|
+
}, z.z.core.$strip>, {
|
|
8
|
+
message: string;
|
|
9
|
+
}, {
|
|
10
|
+
message: string;
|
|
11
|
+
}, boolean>;
|
|
12
|
+
//# sourceMappingURL=print-to-console.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print-to-console.tool.d.ts","sourceRoot":"","sources":["../../src/tools/print-to-console.tool.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,wBAAwB;;mBAEnC,CAAC;AAEH,wBAAgB,kBAAkB;;;;;;YAYjC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { tool } from "langchain";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
export const PrintToConsoleToolSchema = z.object({
|
|
4
|
+
message: z.string().describe("The message to print to the console"),
|
|
5
|
+
});
|
|
6
|
+
export function printToConsoleTool() {
|
|
7
|
+
return tool(({ message }) => {
|
|
8
|
+
console.log(`[AI]: ${message}`);
|
|
9
|
+
return true;
|
|
10
|
+
}, {
|
|
11
|
+
name: "PrintToConsole",
|
|
12
|
+
description: "Print a message to the console.",
|
|
13
|
+
schema: PrintToConsoleToolSchema,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=print-to-console.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print-to-console.tool.js","sourceRoot":"","sources":["../../src/tools/print-to-console.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;CACpE,CAAC,CAAC;AAEH,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,CACT,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC,EACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,iCAAiC;QAC9C,MAAM,EAAE,wBAAwB;KACjC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Page, type Locator } from "playwright";
|
|
2
|
+
export interface ElementSnapshot {
|
|
3
|
+
id: string;
|
|
4
|
+
role: string;
|
|
5
|
+
name: string | undefined;
|
|
6
|
+
value: string | undefined;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
inViewport: boolean;
|
|
9
|
+
editable: boolean;
|
|
10
|
+
disabled: boolean | undefined;
|
|
11
|
+
checked: boolean | undefined;
|
|
12
|
+
required: boolean | undefined;
|
|
13
|
+
masked: boolean | undefined;
|
|
14
|
+
bbox: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
w: number;
|
|
18
|
+
h: number;
|
|
19
|
+
} | undefined;
|
|
20
|
+
children: ElementSnapshot[] | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface PageSnapshot {
|
|
23
|
+
url: string;
|
|
24
|
+
viewport: {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
};
|
|
28
|
+
elements: ElementSnapshot[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Generates an accessibility-based snapshot of the page with visual metadata
|
|
32
|
+
*/
|
|
33
|
+
export declare function generateAccessibilitySnapshot(page: Page, locatorMap: Map<string, Locator>): Promise<PageSnapshot>;
|
|
34
|
+
//# sourceMappingURL=accessibility-snapshot.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessibility-snapshot.util.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/accessibility-snapshot.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,IAAI,EACA;QACE,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,GACD,SAAS,CAAC;IACd,QAAQ,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;CACzC;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B;AAsGD;;GAEG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,YAAY,CAAC,CAsMvB"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import {} from "playwright";
|
|
2
|
+
let elementIdCounter = 0;
|
|
3
|
+
/**
|
|
4
|
+
* Generates a stable synthetic ID for an element
|
|
5
|
+
*/
|
|
6
|
+
function generateElementId(role) {
|
|
7
|
+
return `${role}_${elementIdCounter++}`;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Enriches element data with visual and interaction metadata using XPath locator
|
|
11
|
+
*/
|
|
12
|
+
async function enrichElement(page, elementData, locatorMap) {
|
|
13
|
+
const id = generateElementId(elementData.role);
|
|
14
|
+
try {
|
|
15
|
+
// Locate element using XPath
|
|
16
|
+
const locator = page.locator(`xpath=${elementData.xpath}`);
|
|
17
|
+
// Check if element exists
|
|
18
|
+
const count = await locator.count();
|
|
19
|
+
if (count === 0) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
// Use first matching element
|
|
23
|
+
const element = locator.first();
|
|
24
|
+
// Store locator for later use
|
|
25
|
+
locatorMap.set(id, element);
|
|
26
|
+
// Get visibility state
|
|
27
|
+
const isVisible = await element.isVisible().catch(() => false);
|
|
28
|
+
if (!isVisible) {
|
|
29
|
+
return null; // Filter out hidden elements
|
|
30
|
+
}
|
|
31
|
+
// Get bounding box
|
|
32
|
+
const boundingBox = await element.boundingBox().catch(() => null);
|
|
33
|
+
// Check if in viewport (approximation based on bounding box)
|
|
34
|
+
const viewport = page.viewportSize() || { width: 1280, height: 800 };
|
|
35
|
+
const isInViewport = boundingBox
|
|
36
|
+
? boundingBox.x >= 0 &&
|
|
37
|
+
boundingBox.y >= 0 &&
|
|
38
|
+
boundingBox.x + boundingBox.width <= viewport.width &&
|
|
39
|
+
boundingBox.y + boundingBox.height <= viewport.height
|
|
40
|
+
: false;
|
|
41
|
+
// Get editability state
|
|
42
|
+
const isEditable = await element.isEditable().catch(() => false);
|
|
43
|
+
// Build element snapshot
|
|
44
|
+
const snapshot = {
|
|
45
|
+
id,
|
|
46
|
+
role: elementData.role,
|
|
47
|
+
name: elementData.name || undefined,
|
|
48
|
+
value: elementData.value || undefined,
|
|
49
|
+
visible: isVisible,
|
|
50
|
+
inViewport: isInViewport,
|
|
51
|
+
editable: isEditable,
|
|
52
|
+
disabled: elementData.disabled ? true : undefined,
|
|
53
|
+
checked: elementData.checked ? true : undefined,
|
|
54
|
+
required: elementData.required ? true : undefined,
|
|
55
|
+
masked: elementData.type === "password" ? true : undefined,
|
|
56
|
+
bbox: boundingBox
|
|
57
|
+
? {
|
|
58
|
+
x: Math.round(boundingBox.x),
|
|
59
|
+
y: Math.round(boundingBox.y),
|
|
60
|
+
w: Math.round(boundingBox.width),
|
|
61
|
+
h: Math.round(boundingBox.height),
|
|
62
|
+
}
|
|
63
|
+
: undefined,
|
|
64
|
+
children: undefined,
|
|
65
|
+
};
|
|
66
|
+
return snapshot;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
// If we can't enrich this element, skip it
|
|
70
|
+
console.warn(`Failed to enrich element ${elementData.role}:`, error);
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Generates an accessibility-based snapshot of the page with visual metadata
|
|
76
|
+
*/
|
|
77
|
+
export async function generateAccessibilitySnapshot(page, locatorMap) {
|
|
78
|
+
// Reset counter for consistent IDs
|
|
79
|
+
elementIdCounter = 0;
|
|
80
|
+
// Clear previous locator map
|
|
81
|
+
locatorMap.clear();
|
|
82
|
+
// Extract all interactive elements with XPath locators
|
|
83
|
+
const elementsData = await page.evaluate(() => {
|
|
84
|
+
const results = [];
|
|
85
|
+
function getXPath(element) {
|
|
86
|
+
if (element.id) {
|
|
87
|
+
return `//*[@id="${element.id}"]`;
|
|
88
|
+
}
|
|
89
|
+
const parts = [];
|
|
90
|
+
let current = element;
|
|
91
|
+
while (current && current.nodeType === Node.ELEMENT_NODE) {
|
|
92
|
+
let index = 0;
|
|
93
|
+
let sibling = current.previousSibling;
|
|
94
|
+
while (sibling) {
|
|
95
|
+
if (sibling.nodeType === Node.ELEMENT_NODE &&
|
|
96
|
+
sibling.nodeName === current.nodeName) {
|
|
97
|
+
index++;
|
|
98
|
+
}
|
|
99
|
+
sibling = sibling.previousSibling;
|
|
100
|
+
}
|
|
101
|
+
const tagName = current.nodeName.toLowerCase();
|
|
102
|
+
const position = index > 0 ? `[${index + 1}]` : "";
|
|
103
|
+
parts.unshift(`${tagName}${position}`);
|
|
104
|
+
current = current.parentElement;
|
|
105
|
+
}
|
|
106
|
+
return `/${parts.join("/")}`;
|
|
107
|
+
}
|
|
108
|
+
function inferRole(element) {
|
|
109
|
+
const tagName = element.tagName.toLowerCase();
|
|
110
|
+
const explicitRole = element.getAttribute("role");
|
|
111
|
+
if (explicitRole)
|
|
112
|
+
return explicitRole;
|
|
113
|
+
if (tagName === "button")
|
|
114
|
+
return "button";
|
|
115
|
+
if (tagName === "a")
|
|
116
|
+
return "link";
|
|
117
|
+
if (tagName === "input") {
|
|
118
|
+
const type = element.type;
|
|
119
|
+
if (type === "text" || type === "email" || type === "password")
|
|
120
|
+
return "textbox";
|
|
121
|
+
if (type === "checkbox")
|
|
122
|
+
return "checkbox";
|
|
123
|
+
if (type === "radio")
|
|
124
|
+
return "radio";
|
|
125
|
+
if (type === "search")
|
|
126
|
+
return "searchbox";
|
|
127
|
+
if (type === "submit")
|
|
128
|
+
return "button";
|
|
129
|
+
}
|
|
130
|
+
if (tagName === "textarea")
|
|
131
|
+
return "textbox";
|
|
132
|
+
if (tagName === "select")
|
|
133
|
+
return "combobox";
|
|
134
|
+
if (tagName === "form")
|
|
135
|
+
return "form";
|
|
136
|
+
if (tagName === "nav")
|
|
137
|
+
return "navigation";
|
|
138
|
+
if (tagName === "main")
|
|
139
|
+
return "main";
|
|
140
|
+
if (tagName === "dialog")
|
|
141
|
+
return "dialog";
|
|
142
|
+
return "generic";
|
|
143
|
+
}
|
|
144
|
+
function getName(element) {
|
|
145
|
+
// Priority: aria-label > text content > placeholder > name attr
|
|
146
|
+
const ariaLabel = element.getAttribute("aria-label");
|
|
147
|
+
if (ariaLabel)
|
|
148
|
+
return ariaLabel.trim();
|
|
149
|
+
const placeholder = element.getAttribute("placeholder");
|
|
150
|
+
if (placeholder)
|
|
151
|
+
return placeholder.trim();
|
|
152
|
+
const nameAttr = element.getAttribute("name");
|
|
153
|
+
if (nameAttr)
|
|
154
|
+
return nameAttr.trim();
|
|
155
|
+
// For links and buttons, get text content
|
|
156
|
+
if (element instanceof HTMLButtonElement ||
|
|
157
|
+
element instanceof HTMLAnchorElement) {
|
|
158
|
+
return (element.textContent || "").trim().substring(0, 100);
|
|
159
|
+
}
|
|
160
|
+
// For inputs, use the value or label
|
|
161
|
+
if (element instanceof HTMLInputElement) {
|
|
162
|
+
const labels = document.querySelectorAll(`label[for="${element.id}"]`);
|
|
163
|
+
if (labels.length > 0) {
|
|
164
|
+
return (labels[0].textContent || "").trim();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return "";
|
|
168
|
+
}
|
|
169
|
+
// Find all interactive elements
|
|
170
|
+
const selectors = [
|
|
171
|
+
"button",
|
|
172
|
+
"a[href]",
|
|
173
|
+
"input",
|
|
174
|
+
"textarea",
|
|
175
|
+
"select",
|
|
176
|
+
"[role='button']",
|
|
177
|
+
"[role='link']",
|
|
178
|
+
"[role='textbox']",
|
|
179
|
+
"[role='checkbox']",
|
|
180
|
+
"[role='radio']",
|
|
181
|
+
"[role='combobox']",
|
|
182
|
+
"[onclick]",
|
|
183
|
+
];
|
|
184
|
+
const elements = document.querySelectorAll(selectors.join(", "));
|
|
185
|
+
elements.forEach((element) => {
|
|
186
|
+
const role = inferRole(element);
|
|
187
|
+
const name = getName(element);
|
|
188
|
+
const xpath = getXPath(element);
|
|
189
|
+
let value = "";
|
|
190
|
+
let checked = false;
|
|
191
|
+
let type = "";
|
|
192
|
+
if (element instanceof HTMLInputElement ||
|
|
193
|
+
element instanceof HTMLTextAreaElement) {
|
|
194
|
+
value = element.value;
|
|
195
|
+
type = element instanceof HTMLInputElement ? element.type : "textarea";
|
|
196
|
+
}
|
|
197
|
+
if (element instanceof HTMLInputElement && element.type === "checkbox") {
|
|
198
|
+
checked = element.checked;
|
|
199
|
+
}
|
|
200
|
+
const disabled = element instanceof HTMLButtonElement ||
|
|
201
|
+
element instanceof HTMLInputElement ||
|
|
202
|
+
element instanceof HTMLSelectElement ||
|
|
203
|
+
element instanceof HTMLTextAreaElement
|
|
204
|
+
? element.disabled
|
|
205
|
+
: false;
|
|
206
|
+
const required = element instanceof HTMLInputElement ||
|
|
207
|
+
element instanceof HTMLSelectElement ||
|
|
208
|
+
element instanceof HTMLTextAreaElement
|
|
209
|
+
? element.required
|
|
210
|
+
: false;
|
|
211
|
+
results.push({
|
|
212
|
+
xpath,
|
|
213
|
+
role,
|
|
214
|
+
name,
|
|
215
|
+
value,
|
|
216
|
+
disabled,
|
|
217
|
+
checked,
|
|
218
|
+
required,
|
|
219
|
+
tagName: element.tagName.toLowerCase(),
|
|
220
|
+
type,
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
return results;
|
|
224
|
+
});
|
|
225
|
+
// Get viewport size
|
|
226
|
+
const viewportSize = page.viewportSize() || { width: 1280, height: 800 };
|
|
227
|
+
// Enrich each element with visual metadata
|
|
228
|
+
const elements = [];
|
|
229
|
+
for (const elementData of elementsData) {
|
|
230
|
+
const enrichedElement = await enrichElement(page, elementData, locatorMap);
|
|
231
|
+
if (enrichedElement) {
|
|
232
|
+
elements.push(enrichedElement);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
url: page.url(),
|
|
237
|
+
viewport: {
|
|
238
|
+
width: viewportSize.width,
|
|
239
|
+
height: viewportSize.height,
|
|
240
|
+
},
|
|
241
|
+
elements,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=accessibility-snapshot.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessibility-snapshot.util.js","sourceRoot":"","sources":["../../../src/tools/utils/accessibility-snapshot.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,YAAY,CAAC;AA8CrD,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB;;GAEG;AACH,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO,GAAG,IAAI,IAAI,gBAAgB,EAAE,EAAE,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,aAAa,CAC1B,IAAU,EACV,WAAwB,EACxB,UAAgC;IAEhC,MAAM,EAAE,GAAG,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAE/C,IAAI,CAAC;QACH,6BAA6B;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,WAAW,CAAC,KAAK,EAAE,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C,OAAO,CAAC,WAAW,EAAE;gBACtC,IAAI;aACL,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,oBAAoB;IACpB,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IAEzE,2CAA2C;IAC3C,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,eAAe,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAC3E,IAAI,eAAe,EAAE,CAAC;YACpB,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE;QACf,QAAQ,EAAE;YACR,KAAK,EAAE,YAAY,CAAC,KAAK;YACzB,MAAM,EAAE,YAAY,CAAC,MAAM;SAC5B;QACD,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Locator } from "playwright";
|
|
2
|
+
/**
|
|
3
|
+
* Registry for managing element ID to Playwright Locator mappings
|
|
4
|
+
* This is used to translate synthetic element IDs from the accessibility snapshot
|
|
5
|
+
* into actual Playwright locators for performing actions
|
|
6
|
+
*/
|
|
7
|
+
export declare class ElementLocatorRegistry {
|
|
8
|
+
private locatorMap;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Gets the internal locator map (used by snapshot generation)
|
|
12
|
+
*/
|
|
13
|
+
getMap(): Map<string, Locator>;
|
|
14
|
+
/**
|
|
15
|
+
* Gets a locator by its element ID
|
|
16
|
+
*/
|
|
17
|
+
get(elementId: string): Locator | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Sets a locator for an element ID
|
|
20
|
+
*/
|
|
21
|
+
set(elementId: string, locator: Locator): void;
|
|
22
|
+
/**
|
|
23
|
+
* Clears all element mappings
|
|
24
|
+
*/
|
|
25
|
+
clear(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Gets all element IDs
|
|
28
|
+
*/
|
|
29
|
+
getAllIds(): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Gets the number of registered elements
|
|
32
|
+
*/
|
|
33
|
+
size(): number;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if an element ID exists in the registry
|
|
36
|
+
*/
|
|
37
|
+
has(elementId: string): boolean;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=element-registry.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-registry.util.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/element-registry.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;GAIG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,UAAU,CAAuB;;IAMzC;;OAEG;IACH,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAI9B;;OAEG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI3C;;OAEG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAI9C;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,SAAS,IAAI,MAAM,EAAE;IAIrB;;OAEG;IACH,IAAI,IAAI,MAAM;IAId;;OAEG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAGhC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {} from "playwright";
|
|
2
|
+
/**
|
|
3
|
+
* Registry for managing element ID to Playwright Locator mappings
|
|
4
|
+
* This is used to translate synthetic element IDs from the accessibility snapshot
|
|
5
|
+
* into actual Playwright locators for performing actions
|
|
6
|
+
*/
|
|
7
|
+
export class ElementLocatorRegistry {
|
|
8
|
+
locatorMap;
|
|
9
|
+
constructor() {
|
|
10
|
+
this.locatorMap = new Map();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Gets the internal locator map (used by snapshot generation)
|
|
14
|
+
*/
|
|
15
|
+
getMap() {
|
|
16
|
+
return this.locatorMap;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Gets a locator by its element ID
|
|
20
|
+
*/
|
|
21
|
+
get(elementId) {
|
|
22
|
+
return this.locatorMap.get(elementId);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sets a locator for an element ID
|
|
26
|
+
*/
|
|
27
|
+
set(elementId, locator) {
|
|
28
|
+
this.locatorMap.set(elementId, locator);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Clears all element mappings
|
|
32
|
+
*/
|
|
33
|
+
clear() {
|
|
34
|
+
this.locatorMap.clear();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Gets all element IDs
|
|
38
|
+
*/
|
|
39
|
+
getAllIds() {
|
|
40
|
+
return Array.from(this.locatorMap.keys());
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Gets the number of registered elements
|
|
44
|
+
*/
|
|
45
|
+
size() {
|
|
46
|
+
return this.locatorMap.size;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Checks if an element ID exists in the registry
|
|
50
|
+
*/
|
|
51
|
+
has(elementId) {
|
|
52
|
+
return this.locatorMap.has(elementId);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=element-registry.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-registry.util.js","sourceRoot":"","sources":["../../../src/tools/utils/element-registry.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,YAAY,CAAC;AAE1C;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IACzB,UAAU,CAAuB;IAEzC;QACE,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,SAAiB;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,SAAiB,EAAE,OAAgB;QACrC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,SAAiB;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimize-snapshot.util.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/minimize-snapshot.util.ts"],"names":[],"mappings":"AACA,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,UAoDnD"}
|