@vforsh/argus 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/argus.js +3963 -2198
- package/dist/cli/defineCommand.d.ts +26 -0
- package/dist/cli/defineCommand.d.ts.map +1 -0
- package/dist/cli/defineCommand.js +55 -0
- package/dist/cli/defineCommand.js.map +1 -0
- package/dist/cli/defineWatcherCommand.d.ts +112 -0
- package/dist/cli/defineWatcherCommand.d.ts.map +1 -0
- package/dist/cli/defineWatcherCommand.js +89 -0
- package/dist/cli/defineWatcherCommand.js.map +1 -0
- package/dist/cli/plugins/pluginAliases.d.ts +6 -0
- package/dist/cli/plugins/pluginAliases.d.ts.map +1 -0
- package/dist/cli/plugins/pluginAliases.js +10 -0
- package/dist/cli/plugins/pluginAliases.js.map +1 -0
- package/dist/cli/plugins/pluginHost.d.ts +3 -0
- package/dist/cli/plugins/pluginHost.d.ts.map +1 -0
- package/dist/cli/plugins/pluginHost.js +30 -0
- package/dist/cli/plugins/pluginHost.js.map +1 -0
- package/dist/cli/plugins/registerPlugins.d.ts +32 -1
- package/dist/cli/plugins/registerPlugins.d.ts.map +1 -1
- package/dist/cli/plugins/registerPlugins.js +102 -12
- package/dist/cli/plugins/registerPlugins.js.map +1 -1
- package/dist/cli/program.d.ts.map +1 -1
- package/dist/cli/program.js +2 -0
- package/dist/cli/program.js.map +1 -1
- package/dist/cli/register/index.d.ts.map +1 -1
- package/dist/cli/register/index.js +8 -2
- package/dist/cli/register/index.js.map +1 -1
- package/dist/cli/register/registerAuth.d.ts.map +1 -1
- package/dist/cli/register/registerAuth.js +13 -8
- package/dist/cli/register/registerAuth.js.map +1 -1
- package/dist/cli/register/registerCode.d.ts.map +1 -1
- package/dist/cli/register/registerCode.js +19 -0
- package/dist/cli/register/registerCode.js.map +1 -1
- package/dist/cli/register/registerDom.d.ts.map +1 -1
- package/dist/cli/register/registerDom.js +3 -1
- package/dist/cli/register/registerDom.js.map +1 -1
- package/dist/cli/register/registerEval.d.ts.map +1 -1
- package/dist/cli/register/registerEval.js +13 -0
- package/dist/cli/register/registerEval.js.map +1 -1
- package/dist/cli/register/registerExtension.d.ts.map +1 -1
- package/dist/cli/register/registerExtension.js +12 -0
- package/dist/cli/register/registerExtension.js.map +1 -1
- package/dist/cli/register/registerNet.d.ts.map +1 -1
- package/dist/cli/register/registerNet.js +40 -6
- package/dist/cli/register/registerNet.js.map +1 -1
- package/dist/cli/register/registerPage.d.ts.map +1 -1
- package/dist/cli/register/registerPage.js +17 -0
- package/dist/cli/register/registerPage.js.map +1 -1
- package/dist/cli/register/registerPlugin.d.ts +3 -0
- package/dist/cli/register/registerPlugin.d.ts.map +1 -0
- package/dist/cli/register/registerPlugin.js +34 -0
- package/dist/cli/register/registerPlugin.js.map +1 -0
- package/dist/cli/register/registerSnapshot.d.ts.map +1 -1
- package/dist/cli/register/registerSnapshot.js +2 -1
- package/dist/cli/register/registerSnapshot.js.map +1 -1
- package/dist/cli/register/registerWatcher.d.ts.map +1 -1
- package/dist/cli/register/registerWatcher.js +19 -0
- package/dist/cli/register/registerWatcher.js.map +1 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +4 -9
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/authCookieSupport.d.ts.map +1 -1
- package/dist/commands/authCookieSupport.js +4 -6
- package/dist/commands/authCookieSupport.js.map +1 -1
- package/dist/commands/authCookies.d.ts +4 -4
- package/dist/commands/authCookies.d.ts.map +1 -1
- package/dist/commands/authCookies.js +85 -105
- package/dist/commands/authCookies.js.map +1 -1
- package/dist/commands/code.js +3 -25
- package/dist/commands/code.js.map +1 -1
- package/dist/commands/codeEdit.d.ts +9 -0
- package/dist/commands/codeEdit.d.ts.map +1 -0
- package/dist/commands/codeEdit.js +155 -0
- package/dist/commands/codeEdit.js.map +1 -0
- package/dist/commands/configInit.d.ts.map +1 -1
- package/dist/commands/configInit.js +1 -0
- package/dist/commands/configInit.js.map +1 -1
- package/dist/commands/dialog.d.ts +5 -5
- package/dist/commands/dialog.d.ts.map +1 -1
- package/dist/commands/dialog.js +36 -54
- package/dist/commands/dialog.js.map +1 -1
- package/dist/commands/domAdd.d.ts +1 -1
- package/dist/commands/domAdd.d.ts.map +1 -1
- package/dist/commands/domAdd.js +26 -30
- package/dist/commands/domAdd.js.map +1 -1
- package/dist/commands/domClick.d.ts +4 -1
- package/dist/commands/domClick.d.ts.map +1 -1
- package/dist/commands/domClick.js +83 -75
- package/dist/commands/domClick.js.map +1 -1
- package/dist/commands/domFill.d.ts +2 -2
- package/dist/commands/domFill.d.ts.map +1 -1
- package/dist/commands/domFill.js +56 -67
- package/dist/commands/domFill.js.map +1 -1
- package/dist/commands/domFocus.d.ts +1 -1
- package/dist/commands/domFocus.d.ts.map +1 -1
- package/dist/commands/domFocus.js +27 -35
- package/dist/commands/domFocus.js.map +1 -1
- package/dist/commands/domHover.d.ts +1 -1
- package/dist/commands/domHover.d.ts.map +1 -1
- package/dist/commands/domHover.js +27 -35
- package/dist/commands/domHover.js.map +1 -1
- package/dist/commands/domInfo.d.ts +1 -1
- package/dist/commands/domInfo.d.ts.map +1 -1
- package/dist/commands/domInfo.js +18 -23
- package/dist/commands/domInfo.js.map +1 -1
- package/dist/commands/domKeydown.d.ts +1 -1
- package/dist/commands/domKeydown.d.ts.map +1 -1
- package/dist/commands/domKeydown.js +22 -43
- package/dist/commands/domKeydown.js.map +1 -1
- package/dist/commands/domModify.js +27 -30
- package/dist/commands/domModify.js.map +1 -1
- package/dist/commands/domRemove.d.ts +1 -1
- package/dist/commands/domRemove.d.ts.map +1 -1
- package/dist/commands/domRemove.js +25 -34
- package/dist/commands/domRemove.js.map +1 -1
- package/dist/commands/domScroll.d.ts +2 -2
- package/dist/commands/domScroll.d.ts.map +1 -1
- package/dist/commands/domScroll.js +19 -25
- package/dist/commands/domScroll.js.map +1 -1
- package/dist/commands/domScrollTo.d.ts +1 -1
- package/dist/commands/domScrollTo.d.ts.map +1 -1
- package/dist/commands/domScrollTo.js +15 -24
- package/dist/commands/domScrollTo.js.map +1 -1
- package/dist/commands/domSetFile.d.ts +1 -1
- package/dist/commands/domSetFile.d.ts.map +1 -1
- package/dist/commands/domSetFile.js +24 -33
- package/dist/commands/domSetFile.js.map +1 -1
- package/dist/commands/domTree.d.ts +1 -1
- package/dist/commands/domTree.d.ts.map +1 -1
- package/dist/commands/domTree.js +18 -24
- package/dist/commands/domTree.js.map +1 -1
- package/dist/commands/eval.d.ts +4 -0
- package/dist/commands/eval.d.ts.map +1 -1
- package/dist/commands/eval.js +43 -56
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/evalPolling.d.ts +55 -0
- package/dist/commands/evalPolling.d.ts.map +1 -0
- package/dist/commands/evalPolling.js +59 -0
- package/dist/commands/evalPolling.js.map +1 -0
- package/dist/commands/evalShared.d.ts +24 -0
- package/dist/commands/evalShared.d.ts.map +1 -1
- package/dist/commands/evalShared.js +75 -7
- package/dist/commands/evalShared.js.map +1 -1
- package/dist/commands/evalUntil.d.ts +4 -0
- package/dist/commands/evalUntil.d.ts.map +1 -1
- package/dist/commands/evalUntil.js +47 -64
- package/dist/commands/evalUntil.js.map +1 -1
- package/dist/commands/extension/resolveExtensionWatcher.d.ts +20 -0
- package/dist/commands/extension/resolveExtensionWatcher.d.ts.map +1 -0
- package/dist/commands/extension/resolveExtensionWatcher.js +73 -0
- package/dist/commands/extension/resolveExtensionWatcher.js.map +1 -0
- package/dist/commands/extension/tabs.d.ts +8 -0
- package/dist/commands/extension/tabs.d.ts.map +1 -0
- package/dist/commands/extension/tabs.js +85 -0
- package/dist/commands/extension/tabs.js.map +1 -0
- package/dist/commands/locate.js +2 -2
- package/dist/commands/locate.js.map +1 -1
- package/dist/commands/logs.d.ts +1 -1
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +18 -27
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/net.d.ts +1 -1
- package/dist/commands/net.d.ts.map +1 -1
- package/dist/commands/net.js +14 -19
- package/dist/commands/net.js.map +1 -1
- package/dist/commands/netCapture.d.ts +10 -5
- package/dist/commands/netCapture.d.ts.map +1 -1
- package/dist/commands/netCapture.js +113 -15
- package/dist/commands/netCapture.js.map +1 -1
- package/dist/commands/netClear.d.ts +1 -1
- package/dist/commands/netClear.d.ts.map +1 -1
- package/dist/commands/netClear.js +7 -19
- package/dist/commands/netClear.js.map +1 -1
- package/dist/commands/netExport.d.ts +2 -7
- package/dist/commands/netExport.d.ts.map +1 -1
- package/dist/commands/netExport.js.map +1 -1
- package/dist/commands/netSse.d.ts +6 -0
- package/dist/commands/netSse.d.ts.map +1 -0
- package/dist/commands/netSse.js +26 -0
- package/dist/commands/netSse.js.map +1 -0
- package/dist/commands/netWatch.d.ts +2 -7
- package/dist/commands/netWatch.d.ts.map +1 -1
- package/dist/commands/netWatch.js.map +1 -1
- package/dist/commands/netWebSocket.d.ts +10 -0
- package/dist/commands/netWebSocket.d.ts.map +1 -0
- package/dist/commands/netWebSocket.js +58 -0
- package/dist/commands/netWebSocket.js.map +1 -0
- package/dist/commands/pageEmulation.d.ts +3 -3
- package/dist/commands/pageEmulation.d.ts.map +1 -1
- package/dist/commands/pageEmulation.js +72 -143
- package/dist/commands/pageEmulation.js.map +1 -1
- package/dist/commands/pageVisibility.d.ts +9 -0
- package/dist/commands/pageVisibility.d.ts.map +1 -0
- package/dist/commands/pageVisibility.js +24 -0
- package/dist/commands/pageVisibility.js.map +1 -0
- package/dist/commands/pluginConfig.d.ts +7 -0
- package/dist/commands/pluginConfig.d.ts.map +1 -0
- package/dist/commands/pluginConfig.js +199 -0
- package/dist/commands/pluginConfig.js.map +1 -0
- package/dist/commands/pluginList.d.ts +5 -0
- package/dist/commands/pluginList.d.ts.map +1 -0
- package/dist/commands/pluginList.js +26 -0
- package/dist/commands/pluginList.js.map +1 -0
- package/dist/commands/reload.d.ts +1 -1
- package/dist/commands/reload.d.ts.map +1 -1
- package/dist/commands/reload.js +8 -17
- package/dist/commands/reload.js.map +1 -1
- package/dist/commands/screenshot.d.ts +2 -1
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/commands/screenshot.js +45 -16
- package/dist/commands/screenshot.js.map +1 -1
- package/dist/commands/snapshot.d.ts +1 -1
- package/dist/commands/snapshot.d.ts.map +1 -1
- package/dist/commands/snapshot.js +26 -49
- package/dist/commands/snapshot.js.map +1 -1
- package/dist/commands/storage.d.ts.map +1 -1
- package/dist/commands/storage.js +26 -58
- package/dist/commands/storage.js.map +1 -1
- package/dist/commands/throttle.d.ts +6 -3
- package/dist/commands/throttle.d.ts.map +1 -1
- package/dist/commands/throttle.js +46 -118
- package/dist/commands/throttle.js.map +1 -1
- package/dist/commands/watcherStatus.d.ts +1 -1
- package/dist/commands/watcherStatus.d.ts.map +1 -1
- package/dist/commands/watcherStatus.js +8 -20
- package/dist/commands/watcherStatus.js.map +1 -1
- package/dist/config/argusConfig.d.ts +5 -0
- package/dist/config/argusConfig.d.ts.map +1 -1
- package/dist/config/argusConfig.js +33 -2
- package/dist/config/argusConfig.js.map +1 -1
- package/dist/eval/evalClient.d.ts +1 -0
- package/dist/eval/evalClient.d.ts.map +1 -1
- package/dist/eval/evalClient.js +2 -0
- package/dist/eval/evalClient.js.map +1 -1
- package/dist/output/net.d.ts +4 -1
- package/dist/output/net.d.ts.map +1 -1
- package/dist/output/net.js +59 -0
- package/dist/output/net.js.map +1 -1
- package/package.json +2 -2
- package/schemas/argus.config.schema.json +16 -0
- package/dist/cli/register/registerClick.d.ts +0 -3
- package/dist/cli/register/registerClick.d.ts.map +0 -1
- package/dist/cli/register/registerClick.js +0 -24
- package/dist/cli/register/registerClick.js.map +0 -1
package/dist/commands/dialog.js
CHANGED
|
@@ -1,60 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { requestWatcherAction } from '../watchers/requestWatcher.js';
|
|
1
|
+
import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
|
|
3
2
|
/** Execute `argus dialog status`. */
|
|
4
|
-
export const runDialogStatus =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const { dialog } = result.data;
|
|
19
|
-
if (!dialog) {
|
|
20
|
-
output.writeHuman(`no active dialog on ${result.watcher.id}`);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
for (const line of formatDialogLines(result.watcher.id, dialog)) {
|
|
24
|
-
output.writeHuman(line);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
3
|
+
export const runDialogStatus = defineWatcherCommand({
|
|
4
|
+
build: () => ({ path: '/dialog', timeoutMs: 2_000 }),
|
|
5
|
+
formatHuman: ({ dialog }, { output, watcher }) => {
|
|
6
|
+
if (!dialog) {
|
|
7
|
+
output.writeHuman(`no active dialog on ${watcher.id}`);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
for (const line of formatDialogLines(watcher.id, dialog)) {
|
|
11
|
+
output.writeHuman(line);
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
});
|
|
27
15
|
/** Execute `argus dialog accept`. */
|
|
28
|
-
export const runDialogAccept =
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
export const runDialogAccept = defineWatcherCommand({
|
|
17
|
+
build: () => buildDialogHandlePlan({ action: 'accept' }),
|
|
18
|
+
formatHuman: formatDialogHandle,
|
|
19
|
+
});
|
|
31
20
|
/** Execute `argus dialog dismiss`. */
|
|
32
|
-
export const runDialogDismiss =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (options.json) {
|
|
52
|
-
output.writeJson(result.data);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const verb = result.data.action === 'accept' ? 'accepted' : 'dismissed';
|
|
56
|
-
output.writeHuman(`${verb} ${result.data.dialog.type} on ${result.watcher.id}`);
|
|
57
|
-
};
|
|
21
|
+
export const runDialogDismiss = defineWatcherCommand({
|
|
22
|
+
build: () => buildDialogHandlePlan({ action: 'dismiss' }),
|
|
23
|
+
formatHuman: formatDialogHandle,
|
|
24
|
+
});
|
|
25
|
+
/** Execute `argus dialog prompt`. The prompt text is passed as a positional CLI argument. */
|
|
26
|
+
export const runDialogPrompt = defineWatcherCommand({
|
|
27
|
+
build: ([text]) => buildDialogHandlePlan({ action: 'accept', promptText: text }),
|
|
28
|
+
formatHuman: formatDialogHandle,
|
|
29
|
+
});
|
|
30
|
+
const buildDialogHandlePlan = (body) => ({
|
|
31
|
+
path: '/dialog',
|
|
32
|
+
method: 'POST',
|
|
33
|
+
body,
|
|
34
|
+
timeoutMs: 5_000,
|
|
35
|
+
});
|
|
36
|
+
function formatDialogHandle(response, { output, watcher }) {
|
|
37
|
+
const verb = response.action === 'accept' ? 'accepted' : 'dismissed';
|
|
38
|
+
output.writeHuman(`${verb} ${response.dialog.type} on ${watcher.id}`);
|
|
39
|
+
}
|
|
58
40
|
const formatDialogLines = (watcherId, dialog) => {
|
|
59
41
|
const lines = [`${dialog.type} dialog on ${watcherId}`, `message: ${dialog.message}`];
|
|
60
42
|
if (dialog.defaultPrompt != null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/commands/dialog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/commands/dialog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAuD,MAAM,gCAAgC,CAA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,MAAM,qBAAqB,GAAG,CAAC,IAAsB,EAAsB,EAAE,CAAC,CAAC;IAC9E,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,MAAM;IACd,IAAI;IACJ,SAAS,EAAE,KAAK;CAChB,CAAC,CAAA;AAEF,SAAS,kBAAkB,CAC1B,QAA8B,EAC9B,EAAE,MAAM,EAAE,OAAO,EAAmE;IAEpF,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAA;IACpE,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;AACtE,CAAC;AAED,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,MAAmD,EAAY,EAAE;IAC9G,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,cAAc,SAAS,EAAE,EAAE,YAAY,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;IAErF,IAAI,MAAM,CAAC,aAAa,IAAI,IAAI,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,aAAa,EAAE,CAAC,CAAA;IAC/C,CAAC;IACD,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QAChB,KAAK,CAAC,IAAI,CAAC,QAAQ,MAAM,CAAC,GAAG,EAAE,CAAC,CAAA;IACjC,CAAC;IACD,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;IACnC,CAAC;IAED,OAAO,KAAK,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -13,5 +13,5 @@ export type DomAddOptions = {
|
|
|
13
13
|
json?: boolean;
|
|
14
14
|
};
|
|
15
15
|
/** Execute the dom add command for a watcher id. */
|
|
16
|
-
export declare const runDomAdd: (
|
|
16
|
+
export declare const runDomAdd: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[], DomAddOptions>;
|
|
17
17
|
//# sourceMappingURL=domAdd.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domAdd.d.ts","sourceRoot":"","sources":["../../src/commands/domAdd.ts"],"names":[],"mappings":"AAQA,uCAAuC;AACvC,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"domAdd.d.ts","sourceRoot":"","sources":["../../src/commands/domAdd.ts"],"names":[],"mappings":"AAQA,uCAAuC;AACvC,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,SAAS,kFAcpB,CAAA"}
|
package/dist/commands/domAdd.js
CHANGED
|
@@ -1,54 +1,65 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { createOutput } from '../output/io.js';
|
|
3
2
|
import { formatError } from '../cli/parse.js';
|
|
3
|
+
import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
|
|
4
4
|
import { resolvePath } from '../utils/paths.js';
|
|
5
|
-
import { requestWatcherAction } from '../watchers/requestWatcher.js';
|
|
6
5
|
import { requireSelector, writeNoElementFound } from './dom/shared.js';
|
|
7
6
|
/** Execute the dom add command for a watcher id. */
|
|
8
|
-
export const runDomAdd =
|
|
9
|
-
|
|
7
|
+
export const runDomAdd = defineWatcherCommand({
|
|
8
|
+
build: (_args, options, output) => buildDomAddPlan(options, output),
|
|
9
|
+
formatHuman: (successResp, { output, options, watcher }) => {
|
|
10
|
+
const selector = options.selector;
|
|
11
|
+
const position = normalizePosition(options.position);
|
|
12
|
+
if (successResp.matches === 0) {
|
|
13
|
+
writeNoElementFound(selector, output, `Hint: run \`argus dom tree ${watcher.id} --selector "${selector}" --all\``);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const label = successResp.inserted === 1 ? 'element' : 'elements';
|
|
17
|
+
const prefix = watcher.id ? `${watcher.id}: ` : '';
|
|
18
|
+
output.writeHuman(`${prefix}Inserted at ${successResp.inserted}/${successResp.matches} ${label} (${position}) for selector: ${selector}`);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const buildDomAddPlan = async (options, output) => {
|
|
10
22
|
const selector = requireSelector(options, output);
|
|
11
23
|
if (!selector) {
|
|
12
|
-
return;
|
|
24
|
+
return null;
|
|
13
25
|
}
|
|
14
26
|
const position = normalizePosition(options.position);
|
|
15
27
|
if (!position) {
|
|
16
28
|
output.writeWarn('--position must be one of: beforebegin, afterbegin, beforeend, afterend (aliases: before, after, prepend, append)');
|
|
17
29
|
process.exitCode = 2;
|
|
18
|
-
return;
|
|
30
|
+
return null;
|
|
19
31
|
}
|
|
20
32
|
if (options.all && (options.nth != null || options.first)) {
|
|
21
33
|
output.writeWarn('Cannot combine --all with --nth or --first');
|
|
22
34
|
process.exitCode = 2;
|
|
23
|
-
return;
|
|
35
|
+
return null;
|
|
24
36
|
}
|
|
25
37
|
if (options.nth != null && options.first) {
|
|
26
38
|
output.writeWarn('Cannot combine --nth with --first');
|
|
27
39
|
process.exitCode = 2;
|
|
28
|
-
return;
|
|
40
|
+
return null;
|
|
29
41
|
}
|
|
30
42
|
const nth = options.first ? 0 : parseNonNegativeInt(options.nth, '--nth', output);
|
|
31
43
|
if (options.nth != null && nth == null) {
|
|
32
44
|
process.exitCode = 2;
|
|
33
|
-
return;
|
|
45
|
+
return null;
|
|
34
46
|
}
|
|
35
47
|
const expect = parseNonNegativeInt(options.expect, '--expect', output);
|
|
36
48
|
if (options.expect != null && expect == null) {
|
|
37
49
|
process.exitCode = 2;
|
|
38
|
-
return;
|
|
50
|
+
return null;
|
|
39
51
|
}
|
|
40
52
|
const html = await resolveHtmlInput(options, output);
|
|
41
53
|
if (html == null) {
|
|
42
54
|
process.exitCode = 2;
|
|
43
|
-
return;
|
|
55
|
+
return null;
|
|
44
56
|
}
|
|
45
57
|
if (!html) {
|
|
46
58
|
output.writeWarn('HTML content is empty. Provide non-empty --html, --html-file, or --html-stdin input.');
|
|
47
59
|
process.exitCode = 2;
|
|
48
|
-
return;
|
|
60
|
+
return null;
|
|
49
61
|
}
|
|
50
|
-
|
|
51
|
-
id,
|
|
62
|
+
return {
|
|
52
63
|
path: '/dom/add',
|
|
53
64
|
method: 'POST',
|
|
54
65
|
body: {
|
|
@@ -61,22 +72,7 @@ export const runDomAdd = async (id, options) => {
|
|
|
61
72
|
text: options.text ?? false,
|
|
62
73
|
},
|
|
63
74
|
timeoutMs: 30_000,
|
|
64
|
-
}
|
|
65
|
-
if (!result) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const successResp = result.data;
|
|
69
|
-
if (options.json) {
|
|
70
|
-
output.writeJson(successResp);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (successResp.matches === 0) {
|
|
74
|
-
writeNoElementFound(selector, output, `Hint: run \`argus dom tree${id ? ` ${id}` : ''} --selector "${selector}" --all\``);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const label = successResp.inserted === 1 ? 'element' : 'elements';
|
|
78
|
-
const prefix = result.watcher.id ? `${result.watcher.id}: ` : '';
|
|
79
|
-
output.writeHuman(`${prefix}Inserted at ${successResp.inserted}/${successResp.matches} ${label} (${position}) for selector: ${selector}`);
|
|
75
|
+
};
|
|
80
76
|
};
|
|
81
77
|
const normalizePosition = (value) => {
|
|
82
78
|
if (!value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domAdd.js","sourceRoot":"","sources":["../../src/commands/domAdd.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"domAdd.js","sourceRoot":"","sources":["../../src/commands/domAdd.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAA2B,MAAM,gCAAgC,CAAA;AAE9F,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAiBtE,oDAAoD;AACpD,MAAM,CAAC,MAAM,SAAS,GAAG,oBAAoB,CAAgC;IAC5E,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC;IACnE,WAAW,EAAE,CAAC,WAAW,EAAE,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MAAM,EAAE,CAAA;AACvB,CAAC,CAAC,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ArgusCommandDefinition } from '../cli/defineCommand.js';
|
|
1
2
|
/** Options for the dom click command. */
|
|
2
3
|
export type DomClickOptions = {
|
|
3
4
|
selector?: string;
|
|
@@ -9,6 +10,8 @@ export type DomClickOptions = {
|
|
|
9
10
|
wait?: string;
|
|
10
11
|
json?: boolean;
|
|
11
12
|
};
|
|
13
|
+
/** CLI definition for the top-level `argus click` command. */
|
|
14
|
+
export declare const domClickCommandDefinition: ArgusCommandDefinition;
|
|
12
15
|
/** Execute the dom click command for a watcher id. */
|
|
13
|
-
export declare const runDomClick: (
|
|
16
|
+
export declare const runDomClick: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[], DomClickOptions>;
|
|
14
17
|
//# sourceMappingURL=domClick.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domClick.d.ts","sourceRoot":"","sources":["../../src/commands/domClick.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"domClick.d.ts","sourceRoot":"","sources":["../../src/commands/domClick.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAMrE,yCAAyC;AACzC,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,8DAA8D;AAC9D,eAAO,MAAM,yBAAyB,EAAE,sBA6BvC,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,WAAW,oFAqBtB,CAAA"}
|
|
@@ -1,97 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { domClickRequestSchema } from '@vforsh/argus-core';
|
|
2
|
+
import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
|
|
3
3
|
import { describeElementTarget, parseWaitDuration, parseXY, requireElementTarget, writeNoElementFound } from './dom/shared.js';
|
|
4
|
+
import { resolveTestId } from './resolveTestId.js';
|
|
5
|
+
/** CLI definition for the top-level `argus click` command. */
|
|
6
|
+
export const domClickCommandDefinition = {
|
|
7
|
+
name: 'click',
|
|
8
|
+
description: 'Click at coordinates or on element(s) matching a CSS selector',
|
|
9
|
+
arguments: [{ flags: '[id]', description: 'Watcher id to query' }],
|
|
10
|
+
options: [
|
|
11
|
+
{ flags: '--selector <css>', description: 'CSS selector to match element(s)' },
|
|
12
|
+
{ flags: '--testid <id>', description: 'Shorthand for --selector "[data-testid=\'<id>\']"' },
|
|
13
|
+
{ flags: '--ref <elementRef>', description: 'Stable element ref from snapshot/locate output' },
|
|
14
|
+
{ flags: '--pos <x,y>', description: 'Viewport coordinates or offset from element top-left' },
|
|
15
|
+
{ flags: '--button <type>', description: 'Mouse button: left, middle, right (default: left)' },
|
|
16
|
+
{ flags: '--all', description: 'Allow multiple matches (default: error if >1 match)' },
|
|
17
|
+
{ flags: '--text <string>', description: 'Filter by textContent (trimmed). Supports /regex/flags syntax' },
|
|
18
|
+
{ flags: '--wait <duration>', description: 'Wait for selector to appear (e.g. 5s, 500ms)' },
|
|
19
|
+
{ flags: '--json', description: 'Output JSON for automation' },
|
|
20
|
+
],
|
|
21
|
+
examples: [
|
|
22
|
+
'argus click app --pos 100,200',
|
|
23
|
+
'argus click app --selector "#btn"',
|
|
24
|
+
'argus click app --testid "submit-btn"',
|
|
25
|
+
'argus click app --ref e5',
|
|
26
|
+
'argus click app --selector "#btn" --pos 10,5',
|
|
27
|
+
'argus click app --selector ".item" --all',
|
|
28
|
+
'argus click app --selector "#btn" --button right',
|
|
29
|
+
'argus click app --pos 100,200 --button middle',
|
|
30
|
+
],
|
|
31
|
+
action: async (id, options) => {
|
|
32
|
+
if (!resolveTestId(options))
|
|
33
|
+
return;
|
|
34
|
+
await runDomClick(id, options);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
4
37
|
/** Execute the dom click command for a watcher id. */
|
|
5
|
-
export const runDomClick =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (!hasSelectorTarget && !hasPos) {
|
|
15
|
-
output.writeWarn('--selector, --testid, --ref, or --pos is required');
|
|
16
|
-
process.exitCode = 2;
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
let x;
|
|
20
|
-
let y;
|
|
21
|
-
if (hasPos) {
|
|
22
|
-
const point = parseXY(options.pos);
|
|
23
|
-
if (!point) {
|
|
24
|
-
output.writeWarn('--pos must be in the format "x,y" (e.g. --pos 100,200)');
|
|
25
|
-
process.exitCode = 2;
|
|
38
|
+
export const runDomClick = defineWatcherCommand({
|
|
39
|
+
schema: domClickRequestSchema,
|
|
40
|
+
build: (_args, options, output) => buildClickPlan(options, output),
|
|
41
|
+
formatHuman: (response, { output, options }) => {
|
|
42
|
+
const target = hasElementTarget(options) ? { selector: options.selector, ref: options.ref } : null;
|
|
43
|
+
const xy = options.pos ? parseXY(options.pos) : null;
|
|
44
|
+
// Coordinate-only click (no selector/ref): build never set matches/clicked beyond 1.
|
|
45
|
+
if (!target) {
|
|
46
|
+
output.writeHuman(`Clicked at (${xy?.x}, ${xy?.y})`);
|
|
26
47
|
return;
|
|
27
48
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
if (response.matches === 0) {
|
|
50
|
+
writeNoElementFound(target.selector ?? target.ref, output);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const label = response.clicked === 1 ? 'element' : 'elements';
|
|
54
|
+
const desc = describeElementTarget(target);
|
|
55
|
+
const offset = xy ? ` at offset (${xy.x}, ${xy.y})` : '';
|
|
56
|
+
output.writeHuman(`Clicked ${response.clicked} ${label} for ${desc}${offset}`);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
const hasElementTarget = (options) => Boolean(options.selector?.trim() || options.ref?.trim());
|
|
60
|
+
/** Validate options and assemble the `/dom/click` request plan. */
|
|
61
|
+
const buildClickPlan = (options, output) => {
|
|
62
|
+
const target = hasElementTarget(options) ? requireElementTarget({ selector: options.selector, ref: options.ref }, output) : null;
|
|
63
|
+
if (hasElementTarget(options) && !target)
|
|
64
|
+
return null;
|
|
65
|
+
const xy = options.pos != null ? parseXY(options.pos) : undefined;
|
|
66
|
+
if (options.pos != null && !xy) {
|
|
67
|
+
output.writeWarn('--pos must be in the format "x,y" (e.g. --pos 100,200)');
|
|
68
|
+
process.exitCode = 2;
|
|
69
|
+
return null;
|
|
34
70
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!validButtons.includes(button)) {
|
|
38
|
-
output.writeWarn(`--button must be one of: ${validButtons.join(', ')}`);
|
|
71
|
+
if (!target && !xy) {
|
|
72
|
+
output.writeWarn('--selector, --testid, --ref, or --pos is required');
|
|
39
73
|
process.exitCode = 2;
|
|
40
|
-
return;
|
|
74
|
+
return null;
|
|
41
75
|
}
|
|
76
|
+
const waitMs = parseWaitDuration(options.wait, output);
|
|
77
|
+
if (waitMs == null)
|
|
78
|
+
return null;
|
|
42
79
|
const body = {};
|
|
43
80
|
if (target) {
|
|
44
|
-
if (target.selector)
|
|
81
|
+
if (target.selector)
|
|
45
82
|
body.selector = target.selector;
|
|
46
|
-
|
|
47
|
-
if (target.ref) {
|
|
83
|
+
if (target.ref)
|
|
48
84
|
body.ref = target.ref;
|
|
49
|
-
}
|
|
50
85
|
body.all = options.all ?? false;
|
|
51
|
-
if (options.text != null)
|
|
86
|
+
if (options.text != null)
|
|
52
87
|
body.text = options.text;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (hasPos) {
|
|
56
|
-
body.x = x;
|
|
57
|
-
body.y = y;
|
|
58
88
|
}
|
|
59
|
-
if (
|
|
60
|
-
body.
|
|
89
|
+
if (xy) {
|
|
90
|
+
body.x = xy.x;
|
|
91
|
+
body.y = xy.y;
|
|
61
92
|
}
|
|
62
|
-
if (
|
|
93
|
+
if (options.button)
|
|
94
|
+
body.button = options.button;
|
|
95
|
+
if (waitMs > 0)
|
|
63
96
|
body.wait = waitMs;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
id,
|
|
97
|
+
// `wait` may exceed 30s; bump request timeout proportionally so the watcher reply is not cut off.
|
|
98
|
+
return {
|
|
67
99
|
path: '/dom/click',
|
|
68
100
|
method: 'POST',
|
|
69
101
|
body,
|
|
70
102
|
timeoutMs: Math.max(30_000, waitMs + 5_000),
|
|
71
|
-
}
|
|
72
|
-
if (!result) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const successResp = result.data;
|
|
76
|
-
if (options.json) {
|
|
77
|
-
output.writeJson(successResp);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
// Coordinate-only click
|
|
81
|
-
if (!target) {
|
|
82
|
-
output.writeHuman(`Clicked at (${x}, ${y})`);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (successResp.matches === 0) {
|
|
86
|
-
writeNoElementFound(target.selector ?? target.ref, output);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const label = successResp.clicked === 1 ? 'element' : 'elements';
|
|
90
|
-
if (hasPos) {
|
|
91
|
-
output.writeHuman(`Clicked ${successResp.clicked} ${label} for ${describeElementTarget(target)} at offset (${x}, ${y})`);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
output.writeHuman(`Clicked ${successResp.clicked} ${label} for ${describeElementTarget(target)}`);
|
|
95
|
-
}
|
|
103
|
+
};
|
|
96
104
|
};
|
|
97
105
|
//# sourceMappingURL=domClick.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domClick.js","sourceRoot":"","sources":["../../src/commands/domClick.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"domClick.js","sourceRoot":"","sources":["../../src/commands/domClick.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,OAAO,EAAE,oBAAoB,EAA2B,MAAM,gCAAgC,CAAA;AAE9F,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC9H,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAclD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,yBAAyB,GAA2B;IAChE,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,+DAA+D;IAC5E,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;IAClE,OAAO,EAAE;QACR,EAAE,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,kCAAkC,EAAE;QAC9E,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,mDAAmD,EAAE;QAC5F,EAAE,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,gDAAgD,EAAE;QAC9F,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,sDAAsD,EAAE;QAC7F,EAAE,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,mDAAmD,EAAE;QAC9F,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,qDAAqD,EAAE;QACtF,EAAE,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,+DAA+D,EAAE;QAC1G,EAAE,KAAK,EAAE,mBAAmB,EAAE,WAAW,E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AA;IAElC,kGAAkG;IAClG,OAAO;QACN,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,MAAM;QACd,IAAI;QACJ,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;KAC3C,CAAA;AACF,CAAC,CAAA"}
|
|
@@ -10,6 +10,6 @@ export type DomFillOptions = {
|
|
|
10
10
|
wait?: string;
|
|
11
11
|
json?: boolean;
|
|
12
12
|
};
|
|
13
|
-
/** Execute the dom fill command for a watcher id. */
|
|
14
|
-
export declare const runDomFill: (
|
|
13
|
+
/** Execute the dom fill command for a watcher id. The first positional arg is the inline value. */
|
|
14
|
+
export declare const runDomFill: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[value: string | undefined], DomFillOptions>;
|
|
15
15
|
//# sourceMappingURL=domFill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domFill.d.ts","sourceRoot":"","sources":["../../src/commands/domFill.ts"],"names":[],"mappings":"AASA,wCAAwC;AACxC,MAAM,MAAM,cAAc,GAAG;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;
|
|
1
|
+
{"version":3,"file":"domFill.d.ts","sourceRoot":"","sources":["../../src/commands/domFill.ts"],"names":[],"mappings":"AASA,wCAAwC;AACxC,MAAM,MAAM,cAAc,GAAG;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,mGAAmG;AACnG,eAAO,MAAM,UAAU,4GAWrB,CAAA"}
|