@rpascene/web 0.30.8
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 +9 -0
- package/bin/midscene-playground +3 -0
- package/dist/es/bin.mjs +26 -0
- package/dist/es/bin.mjs.map +1 -0
- package/dist/es/bridge-mode/agent-cli-side.mjs +117 -0
- package/dist/es/bridge-mode/agent-cli-side.mjs.map +1 -0
- package/dist/es/bridge-mode/browser.mjs +2 -0
- package/dist/es/bridge-mode/common.mjs +37 -0
- package/dist/es/bridge-mode/common.mjs.map +1 -0
- package/dist/es/bridge-mode/index.mjs +4 -0
- package/dist/es/bridge-mode/io-client.mjs +101 -0
- package/dist/es/bridge-mode/io-client.mjs.map +1 -0
- package/dist/es/bridge-mode/io-server.mjs +208 -0
- package/dist/es/bridge-mode/io-server.mjs.map +1 -0
- package/dist/es/bridge-mode/page-browser-side.mjs +103 -0
- package/dist/es/bridge-mode/page-browser-side.mjs.map +1 -0
- package/dist/es/chrome-extension/agent.mjs +9 -0
- package/dist/es/chrome-extension/agent.mjs.map +1 -0
- package/dist/es/chrome-extension/cdpInput.mjs +174 -0
- package/dist/es/chrome-extension/cdpInput.mjs.LICENSE.txt +5 -0
- package/dist/es/chrome-extension/cdpInput.mjs.map +1 -0
- package/dist/es/chrome-extension/dynamic-scripts.mjs +37 -0
- package/dist/es/chrome-extension/dynamic-scripts.mjs.map +1 -0
- package/dist/es/chrome-extension/index.mjs +5 -0
- package/dist/es/chrome-extension/page.mjs +633 -0
- package/dist/es/chrome-extension/page.mjs.map +1 -0
- package/dist/es/index.mjs +6 -0
- package/dist/es/playwright/ai-fixture.mjs +325 -0
- package/dist/es/playwright/ai-fixture.mjs.map +1 -0
- package/dist/es/playwright/index.mjs +23 -0
- package/dist/es/playwright/index.mjs.map +1 -0
- package/dist/es/playwright/page.mjs +9 -0
- package/dist/es/playwright/page.mjs.map +1 -0
- package/dist/es/playwright/reporter/index.mjs +90 -0
- package/dist/es/playwright/reporter/index.mjs.map +1 -0
- package/dist/es/puppeteer/agent-launcher.mjs +132 -0
- package/dist/es/puppeteer/agent-launcher.mjs.map +1 -0
- package/dist/es/puppeteer/base-page.mjs +491 -0
- package/dist/es/puppeteer/base-page.mjs.map +1 -0
- package/dist/es/puppeteer/index.mjs +17 -0
- package/dist/es/puppeteer/index.mjs.map +1 -0
- package/dist/es/puppeteer/page.mjs +9 -0
- package/dist/es/puppeteer/page.mjs.map +1 -0
- package/dist/es/static/index.mjs +3 -0
- package/dist/es/static/static-agent.mjs +10 -0
- package/dist/es/static/static-agent.mjs.map +1 -0
- package/dist/es/static/static-page.mjs +132 -0
- package/dist/es/static/static-page.mjs.map +1 -0
- package/dist/es/web-element.mjs +96 -0
- package/dist/es/web-element.mjs.map +1 -0
- package/dist/es/web-page.mjs +206 -0
- package/dist/es/web-page.mjs.map +1 -0
- package/dist/lib/bin.js +54 -0
- package/dist/lib/bin.js.map +1 -0
- package/dist/lib/bridge-mode/agent-cli-side.js +154 -0
- package/dist/lib/bridge-mode/agent-cli-side.js.map +1 -0
- package/dist/lib/bridge-mode/browser.js +38 -0
- package/dist/lib/bridge-mode/browser.js.map +1 -0
- package/dist/lib/bridge-mode/common.js +95 -0
- package/dist/lib/bridge-mode/common.js.map +1 -0
- package/dist/lib/bridge-mode/index.js +46 -0
- package/dist/lib/bridge-mode/index.js.map +1 -0
- package/dist/lib/bridge-mode/io-client.js +135 -0
- package/dist/lib/bridge-mode/io-client.js.map +1 -0
- package/dist/lib/bridge-mode/io-server.js +245 -0
- package/dist/lib/bridge-mode/io-server.js.map +1 -0
- package/dist/lib/bridge-mode/page-browser-side.js +147 -0
- package/dist/lib/bridge-mode/page-browser-side.js.map +1 -0
- package/dist/lib/chrome-extension/agent.js +43 -0
- package/dist/lib/chrome-extension/agent.js.map +1 -0
- package/dist/lib/chrome-extension/cdpInput.js +208 -0
- package/dist/lib/chrome-extension/cdpInput.js.LICENSE.txt +5 -0
- package/dist/lib/chrome-extension/cdpInput.js.map +1 -0
- package/dist/lib/chrome-extension/dynamic-scripts.js +77 -0
- package/dist/lib/chrome-extension/dynamic-scripts.js.map +1 -0
- package/dist/lib/chrome-extension/index.js +60 -0
- package/dist/lib/chrome-extension/index.js.map +1 -0
- package/dist/lib/chrome-extension/page.js +667 -0
- package/dist/lib/chrome-extension/page.js.map +1 -0
- package/dist/lib/index.js +60 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/playwright/ai-fixture.js +362 -0
- package/dist/lib/playwright/ai-fixture.js.map +1 -0
- package/dist/lib/playwright/index.js +66 -0
- package/dist/lib/playwright/index.js.map +1 -0
- package/dist/lib/playwright/page.js +43 -0
- package/dist/lib/playwright/page.js.map +1 -0
- package/dist/lib/playwright/reporter/index.js +124 -0
- package/dist/lib/playwright/reporter/index.js.map +1 -0
- package/dist/lib/puppeteer/agent-launcher.js +194 -0
- package/dist/lib/puppeteer/agent-launcher.js.map +1 -0
- package/dist/lib/puppeteer/base-page.js +531 -0
- package/dist/lib/puppeteer/base-page.js.map +1 -0
- package/dist/lib/puppeteer/index.js +57 -0
- package/dist/lib/puppeteer/index.js.map +1 -0
- package/dist/lib/puppeteer/page.js +43 -0
- package/dist/lib/puppeteer/page.js.map +1 -0
- package/dist/lib/static/index.js +52 -0
- package/dist/lib/static/index.js.map +1 -0
- package/dist/lib/static/static-agent.js +44 -0
- package/dist/lib/static/static-agent.js.map +1 -0
- package/dist/lib/static/static-page.js +166 -0
- package/dist/lib/static/static-page.js.map +1 -0
- package/dist/lib/web-element.js +136 -0
- package/dist/lib/web-element.js.map +1 -0
- package/dist/lib/web-page.js +256 -0
- package/dist/lib/web-page.js.map +1 -0
- package/dist/types/bin.d.ts +1 -0
- package/dist/types/bridge-mode/agent-cli-side.d.ts +32 -0
- package/dist/types/bridge-mode/browser.d.ts +2 -0
- package/dist/types/bridge-mode/common.d.ts +60 -0
- package/dist/types/bridge-mode/index.d.ts +4 -0
- package/dist/types/bridge-mode/io-client.d.ts +10 -0
- package/dist/types/bridge-mode/io-server.d.ts +26 -0
- package/dist/types/bridge-mode/page-browser-side.d.ts +18 -0
- package/dist/types/chrome-extension/agent.d.ts +5 -0
- package/dist/types/chrome-extension/cdpInput.d.ts +52 -0
- package/dist/types/chrome-extension/dynamic-scripts.d.ts +3 -0
- package/dist/types/chrome-extension/index.d.ts +5 -0
- package/dist/types/chrome-extension/page.d.ts +95 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/playwright/ai-fixture.d.ts +117 -0
- package/dist/types/playwright/index.d.ts +12 -0
- package/dist/types/playwright/page.d.ts +6 -0
- package/dist/types/playwright/reporter/index.d.ts +18 -0
- package/dist/types/puppeteer/agent-launcher.d.ts +29 -0
- package/dist/types/puppeteer/base-page.d.ts +90 -0
- package/dist/types/puppeteer/index.d.ts +9 -0
- package/dist/types/puppeteer/page.d.ts +6 -0
- package/dist/types/static/index.d.ts +2 -0
- package/dist/types/static/static-agent.d.ts +5 -0
- package/dist/types/static/static-page.d.ts +52 -0
- package/dist/types/web-element.d.ts +51 -0
- package/dist/types/web-page.d.ts +59 -0
- package/package.json +164 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { assert } from "@rpascene/shared/utils";
|
|
2
|
+
import page from "../chrome-extension/page.mjs";
|
|
3
|
+
import { BridgeEvent, DefaultBridgeServerPort, KeyboardEvent, MouseEvent } from "./common.mjs";
|
|
4
|
+
import { BridgeClient } from "./io-client.mjs";
|
|
5
|
+
function _define_property(obj, key, value) {
|
|
6
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
7
|
+
value: value,
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true
|
|
11
|
+
});
|
|
12
|
+
else obj[key] = value;
|
|
13
|
+
return obj;
|
|
14
|
+
}
|
|
15
|
+
class ExtensionBridgePageBrowserSide extends page {
|
|
16
|
+
async setupBridgeClient() {
|
|
17
|
+
this.bridgeClient = new BridgeClient(`ws://localhost:${DefaultBridgeServerPort}`, async (method, args)=>{
|
|
18
|
+
console.log('bridge call from cli side', method, args);
|
|
19
|
+
if (method === BridgeEvent.ConnectNewTabWithUrl) return this.connectNewTabWithUrl.apply(this, args);
|
|
20
|
+
if (method === BridgeEvent.GetBrowserTabList) return this.getBrowserTabList.apply(this, args);
|
|
21
|
+
if (method === BridgeEvent.SetActiveTabId) return this.setActiveTabId.apply(this, args);
|
|
22
|
+
if (method === BridgeEvent.ConnectCurrentTab) return this.connectCurrentTab.apply(this, args);
|
|
23
|
+
if (method === BridgeEvent.UpdateAgentStatus) return this.onLogMessage(args[0], 'status');
|
|
24
|
+
const tabId = await this.getActiveTabId();
|
|
25
|
+
if (!tabId || 0 === tabId) throw new Error('no tab is connected');
|
|
26
|
+
if (method.startsWith(MouseEvent.PREFIX)) {
|
|
27
|
+
const actionName = method.split('.')[1];
|
|
28
|
+
return this.mouse[actionName].apply(this.mouse, args);
|
|
29
|
+
}
|
|
30
|
+
if (method.startsWith(KeyboardEvent.PREFIX)) {
|
|
31
|
+
const actionName = method.split('.')[1];
|
|
32
|
+
return this.keyboard[actionName].apply(this.keyboard, args);
|
|
33
|
+
}
|
|
34
|
+
if (!this[method]) return void console.warn('method not found', method);
|
|
35
|
+
try {
|
|
36
|
+
const result = await this[method](...args);
|
|
37
|
+
return result;
|
|
38
|
+
} catch (e) {
|
|
39
|
+
const errorMessage = e instanceof Error ? e.message : 'Unknown error';
|
|
40
|
+
console.error('error calling method', method, args, e);
|
|
41
|
+
this.onLogMessage(`Error calling method: ${method}, ${errorMessage}`, 'log');
|
|
42
|
+
throw new Error(errorMessage, {
|
|
43
|
+
cause: e
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}, ()=>this.destroy());
|
|
47
|
+
await this.bridgeClient.connect();
|
|
48
|
+
this.onLogMessage(`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v0.30.8`, 'log');
|
|
49
|
+
}
|
|
50
|
+
async connect() {
|
|
51
|
+
return await this.setupBridgeClient();
|
|
52
|
+
}
|
|
53
|
+
async connectNewTabWithUrl(url, options = {
|
|
54
|
+
forceSameTabNavigation: true
|
|
55
|
+
}) {
|
|
56
|
+
const tab = await chrome.tabs.create({
|
|
57
|
+
url
|
|
58
|
+
});
|
|
59
|
+
const tabId = tab.id;
|
|
60
|
+
assert(tabId, 'failed to get tabId after creating a new tab');
|
|
61
|
+
this.onLogMessage(`Creating new tab: ${url}`, 'log');
|
|
62
|
+
this.newlyCreatedTabIds.push(tabId);
|
|
63
|
+
if (null == options ? void 0 : options.forceSameTabNavigation) this.forceSameTabNavigation = true;
|
|
64
|
+
await this.setActiveTabId(tabId);
|
|
65
|
+
}
|
|
66
|
+
async connectCurrentTab(options = {
|
|
67
|
+
forceSameTabNavigation: true
|
|
68
|
+
}) {
|
|
69
|
+
var _tabs_, _tabs_1;
|
|
70
|
+
const tabs = await chrome.tabs.query({
|
|
71
|
+
active: true,
|
|
72
|
+
currentWindow: true
|
|
73
|
+
});
|
|
74
|
+
const tabId = null == (_tabs_ = tabs[0]) ? void 0 : _tabs_.id;
|
|
75
|
+
assert(tabId, 'failed to get tabId');
|
|
76
|
+
this.onLogMessage(`Connected to current tab: ${null == (_tabs_1 = tabs[0]) ? void 0 : _tabs_1.url}`, 'log');
|
|
77
|
+
if (null == options ? void 0 : options.forceSameTabNavigation) this.forceSameTabNavigation = true;
|
|
78
|
+
await this.setActiveTabId(tabId);
|
|
79
|
+
}
|
|
80
|
+
async setDestroyOptions(options) {
|
|
81
|
+
this.destroyOptions = options;
|
|
82
|
+
}
|
|
83
|
+
async destroy() {
|
|
84
|
+
var _this_destroyOptions;
|
|
85
|
+
if ((null == (_this_destroyOptions = this.destroyOptions) ? void 0 : _this_destroyOptions.closeTab) && this.newlyCreatedTabIds.length > 0) {
|
|
86
|
+
this.onLogMessage('Closing all newly created tabs by bridge...', 'log');
|
|
87
|
+
for (const tabId of this.newlyCreatedTabIds)await chrome.tabs.remove(tabId);
|
|
88
|
+
this.newlyCreatedTabIds = [];
|
|
89
|
+
}
|
|
90
|
+
await super.destroy();
|
|
91
|
+
if (this.bridgeClient) {
|
|
92
|
+
this.bridgeClient.disconnect();
|
|
93
|
+
this.bridgeClient = null;
|
|
94
|
+
this.onDisconnect();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
constructor(onDisconnect = ()=>{}, onLogMessage = ()=>{}, forceSameTabNavigation = true){
|
|
98
|
+
super(forceSameTabNavigation), _define_property(this, "onDisconnect", void 0), _define_property(this, "onLogMessage", void 0), _define_property(this, "bridgeClient", void 0), _define_property(this, "destroyOptions", void 0), _define_property(this, "newlyCreatedTabIds", void 0), this.onDisconnect = onDisconnect, this.onLogMessage = onLogMessage, this.bridgeClient = null, this.newlyCreatedTabIds = [];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export { ExtensionBridgePageBrowserSide };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=page-browser-side.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-mode\\page-browser-side.mjs","sources":["webpack://@rpascene/web/./src/bridge-mode/page-browser-side.ts"],"sourcesContent":["import { assert } from '@rpascene/shared/utils';\nimport ChromeExtensionProxyPage from '../chrome-extension/page';\nimport type {\n ChromePageDestroyOptions,\n KeyboardAction,\n MouseAction,\n} from '../web-page';\nimport {\n type BridgeConnectTabOptions,\n BridgeEvent,\n DefaultBridgeServerPort,\n KeyboardEvent,\n MouseEvent,\n} from './common';\nimport { BridgeClient } from './io-client';\n\ndeclare const __VERSION__: string;\n\nexport class ExtensionBridgePageBrowserSide extends ChromeExtensionProxyPage {\n public bridgeClient: BridgeClient | null = null;\n\n private destroyOptions?: ChromePageDestroyOptions;\n\n private newlyCreatedTabIds: number[] = [];\n\n constructor(\n public onDisconnect: () => void = () => { },\n public onLogMessage: (\n message: string,\n type: 'log' | 'status',\n ) => void = () => { },\n forceSameTabNavigation = true,\n ) {\n super(forceSameTabNavigation);\n }\n\n private async setupBridgeClient() {\n this.bridgeClient = new BridgeClient(\n `ws://localhost:${DefaultBridgeServerPort}`,\n async (method, args: any[]) => {\n console.log('bridge call from cli side', method, args);\n if (method === BridgeEvent.ConnectNewTabWithUrl) {\n return this.connectNewTabWithUrl.apply(\n this,\n args as unknown as [string],\n );\n }\n\n if (method === BridgeEvent.GetBrowserTabList) {\n return this.getBrowserTabList.apply(this, args as any);\n }\n\n if (method === BridgeEvent.SetActiveTabId) {\n return this.setActiveTabId.apply(this, args as any);\n }\n\n if (method === BridgeEvent.ConnectCurrentTab) {\n return this.connectCurrentTab.apply(this, args as any);\n }\n\n if (method === BridgeEvent.UpdateAgentStatus) {\n return this.onLogMessage(args[0] as string, 'status');\n }\n\n const tabId = await this.getActiveTabId();\n if (!tabId || tabId === 0) {\n throw new Error('no tab is connected');\n }\n\n // this.onLogMessage(`calling method: ${method}`);\n\n if (method.startsWith(MouseEvent.PREFIX)) {\n const actionName = method.split('.')[1] as keyof MouseAction;\n if (actionName === 'drag') {\n return this.mouse[actionName].apply(this.mouse, args as any);\n }\n return this.mouse[actionName].apply(this.mouse, args as any);\n }\n\n if (method.startsWith(KeyboardEvent.PREFIX)) {\n const actionName = method.split('.')[1] as keyof KeyboardAction;\n if (actionName === 'press') {\n return this.keyboard[actionName].apply(this.keyboard, args as any);\n }\n return this.keyboard[actionName].apply(this.keyboard, args as any);\n }\n\n if (!this[method as keyof ChromeExtensionProxyPage]) {\n console.warn('method not found', method);\n return undefined;\n }\n\n try {\n // @ts-expect-error\n const result = await this[method as keyof ChromeExtensionProxyPage](\n ...args,\n );\n return result;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : 'Unknown error';\n console.error('error calling method', method, args, e);\n this.onLogMessage(\n `Error calling method: ${method}, ${errorMessage}`,\n 'log',\n );\n throw new Error(errorMessage, { cause: e });\n }\n },\n // on disconnect\n () => {\n return this.destroy();\n },\n );\n await this.bridgeClient.connect();\n this.onLogMessage(\n `Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${__VERSION__}`,\n 'log',\n );\n }\n\n public async connect() {\n return await this.setupBridgeClient();\n }\n\n public async connectNewTabWithUrl(\n url: string,\n options: BridgeConnectTabOptions = {\n forceSameTabNavigation: true,\n },\n ) {\n const tab = await chrome.tabs.create({ url });\n const tabId = tab.id;\n assert(tabId, 'failed to get tabId after creating a new tab');\n\n // new tab\n this.onLogMessage(`Creating new tab: ${url}`, 'log');\n this.newlyCreatedTabIds.push(tabId);\n\n if (options?.forceSameTabNavigation) {\n this.forceSameTabNavigation = true;\n }\n\n await this.setActiveTabId(tabId);\n }\n\n public async connectCurrentTab(\n options: BridgeConnectTabOptions = {\n forceSameTabNavigation: true,\n },\n ) {\n const tabs = await chrome.tabs.query({ active: true, currentWindow: true });\n const tabId = tabs[0]?.id;\n assert(tabId, 'failed to get tabId');\n\n this.onLogMessage(`Connected to current tab: ${tabs[0]?.url}`, 'log');\n\n if (options?.forceSameTabNavigation) {\n this.forceSameTabNavigation = true;\n }\n\n await this.setActiveTabId(tabId);\n }\n\n public async setDestroyOptions(options: ChromePageDestroyOptions) {\n this.destroyOptions = options;\n }\n\n async destroy() {\n if (this.destroyOptions?.closeTab && this.newlyCreatedTabIds.length > 0) {\n this.onLogMessage('Closing all newly created tabs by bridge...', 'log');\n for (const tabId of this.newlyCreatedTabIds) {\n await chrome.tabs.remove(tabId);\n }\n this.newlyCreatedTabIds = [];\n }\n\n await super.destroy();\n\n if (this.bridgeClient) {\n this.bridgeClient.disconnect();\n this.bridgeClient = null;\n this.onDisconnect();\n }\n }\n}\n"],"names":["ExtensionBridgePageBrowserSide","ChromeExtensionProxyPage","BridgeClient","DefaultBridgeServerPort","method","args","console","BridgeEvent","tabId","Error","MouseEvent","actionName","KeyboardEvent","result","e","errorMessage","url","options","tab","chrome","assert","_tabs_","_tabs_1","tabs","_this_destroyOptions","onDisconnect","onLogMessage","forceSameTabNavigation"],"mappings":";;;;;;;;;;;;;;AAkBO,MAAMA,uCAAuCC;IAkBlD,MAAc,o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cAAAA,IAAAA,CACAC,YAAY,GAAZA,cAAAA,IAAAA,CARF,YAAY,GAAwB,WAInC,kBAAkB,GAAa,EAAE;IAWzC;AAsJF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chrome-extension\\agent.mjs","sources":["webpack://@rpascene/web/./src/chrome-extension/agent.ts"],"sourcesContent":["import { type AgentOpt, Agent as PageAgent } from '@rpascene/core/agent';\nimport type ChromeExtensionProxyPage from './page';\n\nexport class ChromeExtensionProxyPageAgent extends PageAgent {\n // biome-ignore lint/complexity/noUselessConstructor: <explanation>\n constructor(page: ChromeExtensionProxyPage, opts?: AgentOpt) {\n super(page, opts);\n }\n}\n"],"names":["ChromeExtensionProxyPageAgent","PageAgent","page","opts"],"mappings":";AAGO,MAAMA,sCAAsCC;IAEjD,YAAYC,IAA8B,EAAEC,IAAe,CAAE;QAC3D,KAAK,CAACD,MAAMC;IACd;AACF"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/*! For license information please see cdpInput.mjs.LICENSE.txt */
|
|
2
|
+
import { _keyDefinitions } from "@rpascene/shared/us-keyboard-layout";
|
|
3
|
+
import { assert } from "@rpascene/shared/utils";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2017 Google Inc.
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/ function _check_private_redeclaration(obj, privateCollection) {
|
|
9
|
+
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
10
|
+
}
|
|
11
|
+
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
12
|
+
if (descriptor.get) return descriptor.get.call(receiver);
|
|
13
|
+
return descriptor.value;
|
|
14
|
+
}
|
|
15
|
+
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
16
|
+
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
17
|
+
else {
|
|
18
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
19
|
+
descriptor.value = value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
23
|
+
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
24
|
+
return privateMap.get(receiver);
|
|
25
|
+
}
|
|
26
|
+
function _class_private_field_get(receiver, privateMap) {
|
|
27
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
28
|
+
return _class_apply_descriptor_get(receiver, descriptor);
|
|
29
|
+
}
|
|
30
|
+
function _class_private_field_init(obj, privateMap, value) {
|
|
31
|
+
_check_private_redeclaration(obj, privateMap);
|
|
32
|
+
privateMap.set(obj, value);
|
|
33
|
+
}
|
|
34
|
+
function _class_private_field_set(receiver, privateMap, value) {
|
|
35
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
36
|
+
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
function _class_private_method_get(receiver, privateSet, fn) {
|
|
40
|
+
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
41
|
+
return fn;
|
|
42
|
+
}
|
|
43
|
+
function _class_private_method_init(obj, privateSet) {
|
|
44
|
+
_check_private_redeclaration(obj, privateSet);
|
|
45
|
+
privateSet.add(obj);
|
|
46
|
+
}
|
|
47
|
+
function _define_property(obj, key, value) {
|
|
48
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
49
|
+
value: value,
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true
|
|
53
|
+
});
|
|
54
|
+
else obj[key] = value;
|
|
55
|
+
return obj;
|
|
56
|
+
}
|
|
57
|
+
var _pressedKeys = /*#__PURE__*/ new WeakMap(), _client = /*#__PURE__*/ new WeakMap(), _modifierBit = /*#__PURE__*/ new WeakSet(), _keyDescriptionForString = /*#__PURE__*/ new WeakSet();
|
|
58
|
+
class CdpKeyboard {
|
|
59
|
+
updateClient(client) {
|
|
60
|
+
_class_private_field_set(this, _client, client);
|
|
61
|
+
}
|
|
62
|
+
async down(key, options = {
|
|
63
|
+
text: void 0,
|
|
64
|
+
commands: []
|
|
65
|
+
}) {
|
|
66
|
+
const description = _class_private_method_get(this, _keyDescriptionForString, keyDescriptionForString).call(this, key);
|
|
67
|
+
const autoRepeat = _class_private_field_get(this, _pressedKeys).has(description.code);
|
|
68
|
+
_class_private_field_get(this, _pressedKeys).add(description.code);
|
|
69
|
+
this._modifiers |= _class_private_method_get(this, _modifierBit, modifierBit).call(this, description.key);
|
|
70
|
+
const text = void 0 === options.text ? description.text : options.text;
|
|
71
|
+
await _class_private_field_get(this, _client).send('Input.dispatchKeyEvent', {
|
|
72
|
+
type: text ? 'keyDown' : 'rawKeyDown',
|
|
73
|
+
modifiers: this._modifiers,
|
|
74
|
+
windowsVirtualKeyCode: description.keyCode,
|
|
75
|
+
code: description.code,
|
|
76
|
+
key: description.key,
|
|
77
|
+
text: text,
|
|
78
|
+
unmodifiedText: text,
|
|
79
|
+
autoRepeat,
|
|
80
|
+
location: description.location,
|
|
81
|
+
isKeypad: 3 === description.location,
|
|
82
|
+
commands: options.commands
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async up(key) {
|
|
86
|
+
const description = _class_private_method_get(this, _keyDescriptionForString, keyDescriptionForString).call(this, key);
|
|
87
|
+
this._modifiers &= ~_class_private_method_get(this, _modifierBit, modifierBit).call(this, description.key);
|
|
88
|
+
_class_private_field_get(this, _pressedKeys).delete(description.code);
|
|
89
|
+
await _class_private_field_get(this, _client).send('Input.dispatchKeyEvent', {
|
|
90
|
+
type: 'keyUp',
|
|
91
|
+
modifiers: this._modifiers,
|
|
92
|
+
key: description.key,
|
|
93
|
+
windowsVirtualKeyCode: description.keyCode,
|
|
94
|
+
code: description.code,
|
|
95
|
+
location: description.location
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async sendCharacter(char) {
|
|
99
|
+
await _class_private_field_get(this, _client).send('Input.insertText', {
|
|
100
|
+
text: char
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
charIsKey(char) {
|
|
104
|
+
return !!_keyDefinitions[char];
|
|
105
|
+
}
|
|
106
|
+
async type(text, options = {}) {
|
|
107
|
+
const delay = options.delay || void 0;
|
|
108
|
+
for (const char of text)if (this.charIsKey(char)) await this.press(char, {
|
|
109
|
+
delay
|
|
110
|
+
});
|
|
111
|
+
else {
|
|
112
|
+
if (delay) await new Promise((f)=>setTimeout(f, delay));
|
|
113
|
+
await this.sendCharacter(char);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async press(key, options = {}) {
|
|
117
|
+
const { delay = null } = options;
|
|
118
|
+
const keys = Array.isArray(key) ? key : [
|
|
119
|
+
key
|
|
120
|
+
];
|
|
121
|
+
for (const k of keys)await this.down(k, options);
|
|
122
|
+
if (delay) await new Promise((f)=>setTimeout(f, options.delay));
|
|
123
|
+
for (const k of [
|
|
124
|
+
...keys
|
|
125
|
+
].reverse())await this.up(k);
|
|
126
|
+
}
|
|
127
|
+
constructor(client){
|
|
128
|
+
_class_private_method_init(this, _modifierBit);
|
|
129
|
+
_class_private_method_init(this, _keyDescriptionForString);
|
|
130
|
+
_class_private_field_init(this, _pressedKeys, {
|
|
131
|
+
writable: true,
|
|
132
|
+
value: new Set()
|
|
133
|
+
});
|
|
134
|
+
_class_private_field_init(this, _client, {
|
|
135
|
+
writable: true,
|
|
136
|
+
value: void 0
|
|
137
|
+
});
|
|
138
|
+
_define_property(this, "_modifiers", 0);
|
|
139
|
+
_class_private_field_set(this, _client, client);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function modifierBit(key) {
|
|
143
|
+
if ('Alt' === key) return 1;
|
|
144
|
+
if ('Control' === key) return 2;
|
|
145
|
+
if ('Meta' === key) return 4;
|
|
146
|
+
if ('Shift' === key) return 8;
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
function keyDescriptionForString(keyString) {
|
|
150
|
+
const shift = 8 & this._modifiers;
|
|
151
|
+
const description = {
|
|
152
|
+
key: '',
|
|
153
|
+
keyCode: 0,
|
|
154
|
+
code: '',
|
|
155
|
+
text: '',
|
|
156
|
+
location: 0
|
|
157
|
+
};
|
|
158
|
+
const definition = _keyDefinitions[keyString];
|
|
159
|
+
assert(definition, `Unknown key: "${keyString}"`);
|
|
160
|
+
if (definition.key) description.key = definition.key;
|
|
161
|
+
if (shift && definition.shiftKey) description.key = definition.shiftKey;
|
|
162
|
+
if (definition.keyCode) description.keyCode = definition.keyCode;
|
|
163
|
+
if (shift && definition.shiftKeyCode) description.keyCode = definition.shiftKeyCode;
|
|
164
|
+
if (definition.code) description.code = definition.code;
|
|
165
|
+
if (definition.location) description.location = definition.location;
|
|
166
|
+
if (1 === description.key.length) description.text = description.key;
|
|
167
|
+
if (definition.text) description.text = definition.text;
|
|
168
|
+
if (shift && definition.shiftText) description.text = definition.shiftText;
|
|
169
|
+
if (-9 & this._modifiers) description.text = '';
|
|
170
|
+
return description;
|
|
171
|
+
}
|
|
172
|
+
export { CdpKeyboard };
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=cdpInput.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chrome-extension\\cdpInput.mjs","sources":["webpack://@rpascene/web/./src/chrome-extension/cdpInput.ts"],"sourcesContent":["// From https://github.com/puppeteer/puppeteer/blob/15abcc390862fd08cc3475532f2d9a11284aee6b/packages/puppeteer-core/src/cdp/Input.ts#L55\n// with some modifications to fit the session type\n/**\n * @license\n * Copyright 2017 Google Inc.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type KeyDefinition,\n type KeyInput,\n _keyDefinitions,\n} from '@rpascene/shared/us-keyboard-layout';\nimport { assert } from '@rpascene/shared/utils';\n\ntype KeyDescription = Required<\n Pick<KeyDefinition, 'keyCode' | 'key' | 'text' | 'code' | 'location'>\n>;\n\n/**\n * @public\n */\nexport interface KeyDownOptions {\n /**\n * @deprecated Do not use. This is automatically handled.\n */\n text?: string;\n /**\n * @deprecated Do not use. This is automatically handled.\n */\n commands?: string[];\n}\n\n/**\n * @public\n */\nexport interface KeyboardTypeOptions {\n /**\n * Time to wait between key presses in milliseconds\n * @default undefined\n */\n delay?: number;\n}\n\n/**\n * @public\n */\nexport type KeyPressOptions = KeyDownOptions & KeyboardTypeOptions;\n\ntype InternalCDPSession = {\n send: (command: string, params: any) => Promise<void>;\n};\n\n/**\n * @internal\n */\nexport class CdpKeyboard {\n #pressedKeys = new Set<string>();\n\n #client: InternalCDPSession;\n\n _modifiers = 0;\n\n constructor(client: InternalCDPSession) {\n this.#client = client;\n }\n\n updateClient(client: InternalCDPSession): void {\n this.#client = client;\n }\n\n async down(\n key: KeyInput,\n options: Readonly<KeyDownOptions> = {\n text: undefined,\n commands: [],\n },\n ): Promise<void> {\n const description = this.#keyDescriptionForString(key);\n\n const autoRepeat = this.#pressedKeys.has(description.code);\n this.#pressedKeys.add(description.code);\n this._modifiers |= this.#modifierBit(description.key);\n\n const text = options.text === undefined ? description.text : options.text;\n await this.#client.send('Input.dispatchKeyEvent', {\n type: text ? 'keyDown' : 'rawKeyDown',\n modifiers: this._modifiers,\n windowsVirtualKeyCode: description.keyCode,\n code: description.code,\n key: description.key,\n text: text,\n unmodifiedText: text,\n autoRepeat,\n location: description.location,\n isKeypad: description.location === 3,\n commands: options.commands,\n });\n }\n\n #modifierBit(key: string): number {\n if (key === 'Alt') {\n return 1;\n }\n if (key === 'Control') {\n return 2;\n }\n if (key === 'Meta') {\n return 4;\n }\n if (key === 'Shift') {\n return 8;\n }\n return 0;\n }\n\n #keyDescriptionForString(keyString: KeyInput): KeyDescription {\n const shift = this._modifiers & 8;\n const description = {\n key: '',\n keyCode: 0,\n code: '',\n text: '',\n location: 0,\n };\n\n const definition = _keyDefinitions[keyString];\n\n assert(definition, `Unknown key: \"${keyString}\"`);\n\n if (definition.key) {\n description.key = definition.key;\n }\n if (shift && definition.shiftKey) {\n description.key = definition.shiftKey;\n }\n\n if (definition.keyCode) {\n description.keyCode = definition.keyCode;\n }\n if (shift && definition.shiftKeyCode) {\n description.keyCode = definition.shiftKeyCode;\n }\n\n if (definition.code) {\n description.code = definition.code;\n }\n\n if (definition.location) {\n description.location = definition.location;\n }\n\n if (description.key.length === 1) {\n description.text = description.key;\n }\n\n if (definition.text) {\n description.text = definition.text;\n }\n if (shift && definition.shiftText) {\n description.text = definition.shiftText;\n }\n\n // if any modifiers besides shift are pressed, no text should be sent\n if (this._modifiers & ~8) {\n description.text = '';\n }\n\n return description;\n }\n\n async up(key: KeyInput): Promise<void> {\n const description = this.#keyDescriptionForString(key);\n\n this._modifiers &= ~this.#modifierBit(description.key);\n this.#pressedKeys.delete(description.code);\n await this.#client.send('Input.dispatchKeyEvent', {\n type: 'keyUp',\n modifiers: this._modifiers,\n key: description.key,\n windowsVirtualKeyCode: description.keyCode,\n code: description.code,\n location: description.location,\n });\n }\n\n async sendCharacter(char: string): Promise<void> {\n await this.#client.send('Input.insertText', { text: char });\n }\n\n private charIsKey(char: string): char is KeyInput {\n return !!_keyDefinitions[char as KeyInput];\n }\n\n async type(\n text: string,\n options: Readonly<KeyboardTypeOptions> = {},\n ): Promise<void> {\n const delay = options.delay || undefined;\n for (const char of text) {\n if (this.charIsKey(char)) {\n await this.press(char, { delay });\n } else {\n if (delay) {\n await new Promise((f) => {\n return setTimeout(f, delay);\n });\n }\n await this.sendCharacter(char);\n }\n }\n }\n\n async press(\n key: KeyInput | KeyInput[],\n options: Readonly<KeyPressOptions> = {},\n ): Promise<void> {\n const { delay = null } = options;\n const keys = Array.isArray(key) ? key : [key];\n\n for (const k of keys) {\n await this.down(k, options);\n }\n\n if (delay) {\n await new Promise((f) => {\n return setTimeout(f, options.delay);\n });\n }\n\n for (const k of [...keys].reverse()) {\n await this.up(k);\n }\n }\n}\n"],"names":["_pressedKeys","_client","modifierBit","keyDescriptionForString","CdpKeyboard","client","key","options","undefined","description","autoRepeat","text","char","_keyDefinitions","delay","Promise","f","setTimeout","keys","Array","k","Set","keyString","shift","definition","assert"],"mappings":";;;AAEA;;;;CAIC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmDCA,eAAAA,WAAAA,GAAAA,IAAAA,WAEAC,UAAAA,WAAAA,GAAAA,IAAAA,WAyCAC,eAAAA,WAAAA,GAAAA,IAAAA,WAgBAC,2BAAAA,WAAAA,GAAAA,IAAAA;AA5DK,MAAMC;IAWX,aAAaC,MAA0B,EAAQ;uCACxCJ,SAAUI;IACjB;IAEA,MAAM,KACJC,GAAa,EACbC,UAAoC;QAClC,MAAMC;QACN,UAAU,EAAE;IACd,CAAC,EACc;QACf,MAAMC,cAAc,8BAAI,EAACN,0BAAAA,yBAAAA,IAAAA,CAAL,IAAI,EAA0BG;QAElD,MAAMI,aAAa,6BAAI,EAACV,cAAa,GAAG,CAACS,YAAY,IAAI;QACzD,6BAAI,EAACT,cAAa,GAAG,CAACS,YAAY,IAAI;QACtC,IAAI,CAAC,UAAU,IAAI,8BAAI,EAACP,cAAAA,aAAAA,IAAAA,CAAL,IAAI,EAAcO,YAAY,GAAG;QAEpD,MAAME,OAAOJ,AAAiBC,WAAjBD,QAAQ,IAAI,GAAiBE,YAAY,IAAI,GAAGF,QAAQ,IAAI;QACzE,MAAM,6BAAI,EAACN,SAAQ,IAAI,CAAC,0BAA0B;YAChD,MAAMU,OAAO,YAAY;YACzB,WAAW,IAAI,CAAC,UAAU;YAC1B,uBAAuBF,YAAY,OAAO;YAC1C,MAAMA,YAAY,IAAI;YACtB,KAAKA,YAAY,GAAG;YACpB,MAAME;YACN,gBAAgBA;YAChBD;YACA,UAAUD,YAAY,QAAQ;YAC9B,UAAUA,AAAyB,MAAzBA,YAAY,QAAQ;YAC9B,UAAUF,QAAQ,QAAQ;QAC5B;IACF;IAyEA,MAAM,GAAGD,GAAa,EAAiB;QACrC,MAAMG,cAAc,8B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,QAAQ;IAG5C,IAAIf,AAA2B,MAA3BA,YAAY,GAAG,CAAC,MAAM,EACxBA,YAAY,IAAI,GAAGA,YAAY,GAAG;IAGpC,IAAIe,WAAW,IAAI,EACjBf,YAAY,IAAI,GAAGe,WAAW,IAAI;IAEpC,IAAID,SAASC,WAAW,SAAS,EAC/Bf,YAAY,IAAI,GAAGe,WAAW,SAAS;IAIzC,IAAI,AAAkB,KAAlB,IAAI,CAAC,UAAU,EACjBf,YAAY,IAAI,GAAG;IAGrB,OAAOA;AACT"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ifInBrowser, ifInWorker } from "@rpascene/shared/utils";
|
|
2
|
+
let scriptFileContentCache = null;
|
|
3
|
+
const getHtmlElementScript = async ()=>{
|
|
4
|
+
const scriptFileToRetrieve = chrome.runtime.getURL("scripts/htmlElement.js");
|
|
5
|
+
if (scriptFileContentCache) return scriptFileContentCache;
|
|
6
|
+
if (ifInBrowser || ifInWorker) {
|
|
7
|
+
const script = await fetch(scriptFileToRetrieve);
|
|
8
|
+
scriptFileContentCache = await script.text();
|
|
9
|
+
return scriptFileContentCache;
|
|
10
|
+
}
|
|
11
|
+
return '';
|
|
12
|
+
};
|
|
13
|
+
let waterFlowScriptFileContentCache = null;
|
|
14
|
+
const injectWaterFlowAnimation = async ()=>{
|
|
15
|
+
const waterFlowScriptFileToRetrieve = chrome.runtime.getURL("scripts/water-flow.js");
|
|
16
|
+
if (waterFlowScriptFileContentCache) return waterFlowScriptFileContentCache;
|
|
17
|
+
if (ifInBrowser || ifInWorker) {
|
|
18
|
+
const script = await fetch(waterFlowScriptFileToRetrieve);
|
|
19
|
+
waterFlowScriptFileContentCache = await script.text();
|
|
20
|
+
return waterFlowScriptFileContentCache;
|
|
21
|
+
}
|
|
22
|
+
return '';
|
|
23
|
+
};
|
|
24
|
+
let stopWaterFlowScriptFileContentCache = null;
|
|
25
|
+
const injectStopWaterFlowAnimation = async ()=>{
|
|
26
|
+
const stopWaterFlowScriptFileToRetrieve = chrome.runtime.getURL("scripts/stop-water-flow.js");
|
|
27
|
+
if (stopWaterFlowScriptFileContentCache) return stopWaterFlowScriptFileContentCache;
|
|
28
|
+
if (ifInBrowser || ifInWorker) {
|
|
29
|
+
const script = await fetch(stopWaterFlowScriptFileToRetrieve);
|
|
30
|
+
stopWaterFlowScriptFileContentCache = await script.text();
|
|
31
|
+
return stopWaterFlowScriptFileContentCache;
|
|
32
|
+
}
|
|
33
|
+
return '';
|
|
34
|
+
};
|
|
35
|
+
export { getHtmlElementScript, injectStopWaterFlowAnimation, injectWaterFlowAnimation };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=dynamic-scripts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chrome-extension\\dynamic-scripts.mjs","sources":["webpack://@rpascene/web/./src/chrome-extension/dynamic-scripts.ts"],"sourcesContent":["// import fs from 'node:fs';\nimport { ifInBrowser, ifInWorker } from '@rpascene/shared/utils';\n\n// remember to include this file into extension's package\n// extract html element from page\nlet scriptFileContentCache: string | null = null;\nexport const getHtmlElementScript = async () => {\n const scriptFileToRetrieve = chrome.runtime.getURL('scripts/htmlElement.js');\n if (scriptFileContentCache) return scriptFileContentCache;\n if (ifInBrowser || ifInWorker) {\n const script = await fetch(scriptFileToRetrieve);\n scriptFileContentCache = await script.text();\n return scriptFileContentCache;\n }\n return ''\n // return fs.readFileSync(scriptFileToRetrieve, 'utf8');\n};\n\n// inject water flow animation\nlet waterFlowScriptFileContentCache: string | null = null;\nexport const injectWaterFlowAnimation = async () => {\n const waterFlowScriptFileToRetrieve = chrome.runtime.getURL(\n 'scripts/water-flow.js',\n );\n if (waterFlowScriptFileContentCache) return waterFlowScriptFileContentCache;\n if (ifInBrowser || ifInWorker) {\n const script = await fetch(waterFlowScriptFileToRetrieve);\n waterFlowScriptFileContentCache = await script.text();\n return waterFlowScriptFileContentCache;\n }\n return ''\n // return fs.readFileSync(waterFlowScriptFileToRetrieve, 'utf8');\n};\n\n// inject stop water flow animation\nlet stopWaterFlowScriptFileContentCache: string | null = null;\nexport const injectStopWaterFlowAnimation = async () => {\n const stopWaterFlowScriptFileToRetrieve = chrome.runtime.getURL(\n 'scripts/stop-water-flow.js',\n );\n if (stopWaterFlowScriptFileContentCache)\n return stopWaterFlowScriptFileContentCache;\n if (ifInBrowser || ifInWorker) {\n const script = await fetch(stopWaterFlowScriptFileToRetrieve);\n stopWaterFlowScriptFileContentCache = await script.text();\n return stopWaterFlowScriptFileContentCache;\n }\n return ''\n // return fs.readFileSync(stopWaterFlowScriptFileToRetrieve, 'utf8');\n};\n"],"names":["scriptFileContentCache","getHtmlElementScript","scriptFileToRetrieve","chrome","ifInBrowser","ifInWorker","script","fetch","waterFlowScriptFileContentCache","injectWaterFlowAnimation","waterFlowScriptFileToRetrieve","stopWaterFlowScriptFileContentCache","injectStopWaterFlowAnimation","stopWaterFlowScriptFileToRetrieve"],"mappings":";AAKA,IAAIA,yBAAwC;AACrC,MAAMC,uBAAuB;IAClC,MAAMC,uBAAuBC,OAAO,OAAO,CAAC,MAAM,CAAC;IACnD,IAAIH,wBAAwB,OAAOA;IACnC,IAAII,eAAeC,YAAY;QAC7B,MAAMC,SAAS,MAAMC,MAAML;QAC3BF,yBAAyB,MAAMM,OAAO,IAAI;QAC1C,OAAON;IACT;IACA,OAAO;AAET;AAGA,IAAIQ,kCAAiD;AAC9C,MAAMC,2BAA2B;IACtC,MAAMC,gCAAgCP,OAAO,OAAO,CAAC,MAAM,CACzD;IAEF,IAAIK,iCAAiC,OAAOA;IAC5C,IAAIJ,eAAeC,YAAY;QAC7B,MAAMC,SAAS,MAAMC,MAAMG;QAC3BF,kCAAkC,MAAMF,OAAO,IAAI;QACnD,OAAOE;IACT;IACA,OAAO;AAET;AAGA,IAAIG,sCAAqD;AAClD,MAAMC,+BAA+B;IAC1C,MAAMC,oCAAoCV,OAAO,OAAO,CAAC,MAAM,CAC7D;IAEF,IAAIQ,qCACF,OAAOA;IACT,IAAIP,eAAeC,YAAY;QAC7B,MAAMC,SAAS,MAAMC,MAAMM;QAC3BF,sCAAsC,MAAML,OAAO,IAAI;QACvD,OAAOK;IACT;IACA,OAAO;AAET"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from "@rpascene/shared/common";
|
|
2
|
+
import { ChromeExtensionProxyPageAgent } from "./agent.mjs";
|
|
3
|
+
import page from "./page.mjs";
|
|
4
|
+
import { overrideAIConfig } from "@rpascene/shared/env";
|
|
5
|
+
export { page as ChromeExtensionProxyPage, ChromeExtensionProxyPageAgent, ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED, overrideAIConfig };
|