@opentabs-dev/browser-extension 0.0.34
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/background-log-state.d.ts +10 -0
- package/dist/background-log-state.d.ts.map +1 -0
- package/dist/background-log-state.js +11 -0
- package/dist/background-log-state.js.map +1 -0
- package/dist/background-message-handlers.d.ts +41 -0
- package/dist/background-message-handlers.d.ts.map +1 -0
- package/dist/background-message-handlers.js +214 -0
- package/dist/background-message-handlers.js.map +1 -0
- package/dist/background.d.ts +2 -0
- package/dist/background.d.ts.map +1 -0
- package/dist/background.js +3780 -0
- package/dist/background.js.map +1 -0
- package/dist/bg-log-state.d.ts +10 -0
- package/dist/bg-log-state.d.ts.map +1 -0
- package/dist/bg-log-state.js +11 -0
- package/dist/bg-log-state.js.map +1 -0
- package/dist/browser-commands/content-commands.d.ts +25 -0
- package/dist/browser-commands/content-commands.d.ts.map +1 -0
- package/dist/browser-commands/content-commands.js +166 -0
- package/dist/browser-commands/content-commands.js.map +1 -0
- package/dist/browser-commands/cookie-commands.d.ts +14 -0
- package/dist/browser-commands/cookie-commands.d.ts.map +1 -0
- package/dist/browser-commands/cookie-commands.js +99 -0
- package/dist/browser-commands/cookie-commands.js.map +1 -0
- package/dist/browser-commands/extension-commands.d.ts +12 -0
- package/dist/browser-commands/extension-commands.d.ts.map +1 -0
- package/dist/browser-commands/extension-commands.js +386 -0
- package/dist/browser-commands/extension-commands.js.map +1 -0
- package/dist/browser-commands/helpers.d.ts +35 -0
- package/dist/browser-commands/helpers.d.ts.map +1 -0
- package/dist/browser-commands/helpers.js +121 -0
- package/dist/browser-commands/helpers.js.map +1 -0
- package/dist/browser-commands/index.d.ts +11 -0
- package/dist/browser-commands/index.d.ts.map +1 -0
- package/dist/browser-commands/index.js +10 -0
- package/dist/browser-commands/index.js.map +1 -0
- package/dist/browser-commands/interaction-commands.d.ts +23 -0
- package/dist/browser-commands/interaction-commands.d.ts.map +1 -0
- package/dist/browser-commands/interaction-commands.js +353 -0
- package/dist/browser-commands/interaction-commands.js.map +1 -0
- package/dist/browser-commands/key-press-command.d.ts +2 -0
- package/dist/browser-commands/key-press-command.d.ts.map +1 -0
- package/dist/browser-commands/key-press-command.js +144 -0
- package/dist/browser-commands/key-press-command.js.map +1 -0
- package/dist/browser-commands/network-commands.d.ts +6 -0
- package/dist/browser-commands/network-commands.d.ts.map +1 -0
- package/dist/browser-commands/network-commands.js +69 -0
- package/dist/browser-commands/network-commands.js.map +1 -0
- package/dist/browser-commands/resource-commands.d.ts +37 -0
- package/dist/browser-commands/resource-commands.d.ts.map +1 -0
- package/dist/browser-commands/resource-commands.js +153 -0
- package/dist/browser-commands/resource-commands.js.map +1 -0
- package/dist/browser-commands/scroll-command.d.ts +2 -0
- package/dist/browser-commands/scroll-command.d.ts.map +1 -0
- package/dist/browser-commands/scroll-command.js +133 -0
- package/dist/browser-commands/scroll-command.js.map +1 -0
- package/dist/browser-commands/tab-commands.d.ts +33 -0
- package/dist/browser-commands/tab-commands.d.ts.map +1 -0
- package/dist/browser-commands/tab-commands.js +121 -0
- package/dist/browser-commands/tab-commands.js.map +1 -0
- package/dist/browser-commands.d.ts +36 -0
- package/dist/browser-commands.d.ts.map +1 -0
- package/dist/browser-commands.js +1931 -0
- package/dist/browser-commands.js.map +1 -0
- package/dist/confirmation-badge.d.ts +17 -0
- package/dist/confirmation-badge.d.ts.map +1 -0
- package/dist/confirmation-badge.js +64 -0
- package/dist/confirmation-badge.js.map +1 -0
- package/dist/constants.d.ts +79 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +79 -0
- package/dist/constants.js.map +1 -0
- package/dist/dispatch-helpers.d.ts +61 -0
- package/dist/dispatch-helpers.d.ts.map +1 -0
- package/dist/dispatch-helpers.js +149 -0
- package/dist/dispatch-helpers.js.map +1 -0
- package/dist/extension-messages.d.ts +146 -0
- package/dist/extension-messages.d.ts.map +1 -0
- package/dist/extension-messages.js +2 -0
- package/dist/extension-messages.js.map +1 -0
- package/dist/iife-injection.d.ts +55 -0
- package/dist/iife-injection.d.ts.map +1 -0
- package/dist/iife-injection.js +474 -0
- package/dist/iife-injection.js.map +1 -0
- package/dist/json-rpc-errors.d.ts +8 -0
- package/dist/json-rpc-errors.d.ts.map +1 -0
- package/dist/json-rpc-errors.js +8 -0
- package/dist/json-rpc-errors.js.map +1 -0
- package/dist/known-methods.d.ts +19 -0
- package/dist/known-methods.d.ts.map +1 -0
- package/dist/known-methods.js +68 -0
- package/dist/known-methods.js.map +1 -0
- package/dist/log-collector.d.ts +45 -0
- package/dist/log-collector.d.ts.map +1 -0
- package/dist/log-collector.js +99 -0
- package/dist/log-collector.js.map +1 -0
- package/dist/message-router.d.ts +28 -0
- package/dist/message-router.d.ts.map +1 -0
- package/dist/message-router.js +367 -0
- package/dist/message-router.js.map +1 -0
- package/dist/messaging.d.ts +15 -0
- package/dist/messaging.d.ts.map +1 -0
- package/dist/messaging.js +41 -0
- package/dist/messaging.js.map +1 -0
- package/dist/network-capture.d.ts +56 -0
- package/dist/network-capture.d.ts.map +1 -0
- package/dist/network-capture.js +374 -0
- package/dist/network-capture.js.map +1 -0
- package/dist/offscreen/index.d.ts +16 -0
- package/dist/offscreen/index.d.ts.map +1 -0
- package/dist/offscreen/index.js +549 -0
- package/dist/offscreen/index.js.map +1 -0
- package/dist/plugin-storage.d.ts +19 -0
- package/dist/plugin-storage.d.ts.map +1 -0
- package/dist/plugin-storage.js +100 -0
- package/dist/plugin-storage.js.map +1 -0
- package/dist/rate-limiter.d.ts +18 -0
- package/dist/rate-limiter.d.ts.map +1 -0
- package/dist/rate-limiter.js +53 -0
- package/dist/rate-limiter.js.map +1 -0
- package/dist/resource-prompt-dispatch.d.ts +14 -0
- package/dist/resource-prompt-dispatch.d.ts.map +1 -0
- package/dist/resource-prompt-dispatch.js +195 -0
- package/dist/resource-prompt-dispatch.js.map +1 -0
- package/dist/sanitize-error.d.ts +8 -0
- package/dist/sanitize-error.d.ts.map +1 -0
- package/dist/sanitize-error.js +25 -0
- package/dist/sanitize-error.js.map +1 -0
- package/dist/sanitize-svg.d.ts +20 -0
- package/dist/sanitize-svg.d.ts.map +1 -0
- package/dist/sanitize-svg.js +296 -0
- package/dist/sanitize-svg.js.map +1 -0
- package/dist/side-panel/App.d.ts +3 -0
- package/dist/side-panel/App.d.ts.map +1 -0
- package/dist/side-panel/App.js +147 -0
- package/dist/side-panel/App.js.map +1 -0
- package/dist/side-panel/bridge.d.ts +50 -0
- package/dist/side-panel/bridge.d.ts.map +1 -0
- package/dist/side-panel/bridge.js +113 -0
- package/dist/side-panel/bridge.js.map +1 -0
- package/dist/side-panel/components/ConfirmationDialog.d.ts +16 -0
- package/dist/side-panel/components/ConfirmationDialog.d.ts.map +1 -0
- package/dist/side-panel/components/ConfirmationDialog.js +39 -0
- package/dist/side-panel/components/ConfirmationDialog.js.map +1 -0
- package/dist/side-panel/components/EmptyStates.d.ts +8 -0
- package/dist/side-panel/components/EmptyStates.d.ts.map +1 -0
- package/dist/side-panel/components/EmptyStates.js +40 -0
- package/dist/side-panel/components/EmptyStates.js.map +1 -0
- package/dist/side-panel/components/ErrorBoundary.d.ts +23 -0
- package/dist/side-panel/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/side-panel/components/ErrorBoundary.js +28 -0
- package/dist/side-panel/components/ErrorBoundary.js.map +1 -0
- package/dist/side-panel/components/FailedPluginCard.d.ts +6 -0
- package/dist/side-panel/components/FailedPluginCard.d.ts.map +1 -0
- package/dist/side-panel/components/FailedPluginCard.js +9 -0
- package/dist/side-panel/components/FailedPluginCard.js.map +1 -0
- package/dist/side-panel/components/Footer.d.ts +3 -0
- package/dist/side-panel/components/Footer.d.ts.map +1 -0
- package/dist/side-panel/components/Footer.js +32 -0
- package/dist/side-panel/components/Footer.js.map +1 -0
- package/dist/side-panel/components/Header.d.ts +5 -0
- package/dist/side-panel/components/Header.d.ts.map +1 -0
- package/dist/side-panel/components/Header.js +6 -0
- package/dist/side-panel/components/Header.js.map +1 -0
- package/dist/side-panel/components/PluginCard.d.ts +10 -0
- package/dist/side-panel/components/PluginCard.d.ts.map +1 -0
- package/dist/side-panel/components/PluginCard.js +50 -0
- package/dist/side-panel/components/PluginCard.js.map +1 -0
- package/dist/side-panel/components/PluginIcon.d.ts +21 -0
- package/dist/side-panel/components/PluginIcon.d.ts.map +1 -0
- package/dist/side-panel/components/PluginIcon.js +48 -0
- package/dist/side-panel/components/PluginIcon.js.map +1 -0
- package/dist/side-panel/components/PluginList.d.ts +11 -0
- package/dist/side-panel/components/PluginList.d.ts.map +1 -0
- package/dist/side-panel/components/PluginList.js +17 -0
- package/dist/side-panel/components/PluginList.js.map +1 -0
- package/dist/side-panel/components/ToolIcon.d.ts +7 -0
- package/dist/side-panel/components/ToolIcon.d.ts.map +1 -0
- package/dist/side-panel/components/ToolIcon.js +8 -0
- package/dist/side-panel/components/ToolIcon.js.map +1 -0
- package/dist/side-panel/components/ToolRow.d.ts +11 -0
- package/dist/side-panel/components/ToolRow.d.ts.map +1 -0
- package/dist/side-panel/components/ToolRow.js +8 -0
- package/dist/side-panel/components/ToolRow.js.map +1 -0
- package/dist/side-panel/components/VersionMismatchBanner.d.ts +3 -0
- package/dist/side-panel/components/VersionMismatchBanner.d.ts.map +1 -0
- package/dist/side-panel/components/VersionMismatchBanner.js +5 -0
- package/dist/side-panel/components/VersionMismatchBanner.js.map +1 -0
- package/dist/side-panel/components/retro/Accordion.d.ts +8 -0
- package/dist/side-panel/components/retro/Accordion.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Accordion.js +15 -0
- package/dist/side-panel/components/retro/Accordion.js.map +1 -0
- package/dist/side-panel/components/retro/Alert.d.ts +25 -0
- package/dist/side-panel/components/retro/Alert.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Alert.js +33 -0
- package/dist/side-panel/components/retro/Alert.js.map +1 -0
- package/dist/side-panel/components/retro/Badge.d.ts +15 -0
- package/dist/side-panel/components/retro/Badge.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Badge.js +23 -0
- package/dist/side-panel/components/retro/Badge.js.map +1 -0
- package/dist/side-panel/components/retro/Button.d.ts +13 -0
- package/dist/side-panel/components/retro/Button.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Button.js +33 -0
- package/dist/side-panel/components/retro/Button.js.map +1 -0
- package/dist/side-panel/components/retro/Empty.d.ts +31 -0
- package/dist/side-panel/components/retro/Empty.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Empty.js +25 -0
- package/dist/side-panel/components/retro/Empty.js.map +1 -0
- package/dist/side-panel/components/retro/Input.d.ts +8 -0
- package/dist/side-panel/components/retro/Input.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Input.js +7 -0
- package/dist/side-panel/components/retro/Input.js.map +1 -0
- package/dist/side-panel/components/retro/Loader.d.ts +14 -0
- package/dist/side-panel/components/retro/Loader.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Loader.js +30 -0
- package/dist/side-panel/components/retro/Loader.js.map +1 -0
- package/dist/side-panel/components/retro/Menu.d.ts +9 -0
- package/dist/side-panel/components/retro/Menu.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Menu.js +17 -0
- package/dist/side-panel/components/retro/Menu.js.map +1 -0
- package/dist/side-panel/components/retro/NumberStepper.d.ts +18 -0
- package/dist/side-panel/components/retro/NumberStepper.d.ts.map +1 -0
- package/dist/side-panel/components/retro/NumberStepper.js +38 -0
- package/dist/side-panel/components/retro/NumberStepper.js.map +1 -0
- package/dist/side-panel/components/retro/Progress.d.ts +9 -0
- package/dist/side-panel/components/retro/Progress.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Progress.js +6 -0
- package/dist/side-panel/components/retro/Progress.js.map +1 -0
- package/dist/side-panel/components/retro/Switch.d.ts +4 -0
- package/dist/side-panel/components/retro/Switch.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Switch.js +6 -0
- package/dist/side-panel/components/retro/Switch.js.map +1 -0
- package/dist/side-panel/components/retro/Text.d.ts +11 -0
- package/dist/side-panel/components/retro/Text.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Text.js +28 -0
- package/dist/side-panel/components/retro/Text.js.map +1 -0
- package/dist/side-panel/components/retro/Tooltip.d.ts +12 -0
- package/dist/side-panel/components/retro/Tooltip.d.ts.map +1 -0
- package/dist/side-panel/components/retro/Tooltip.js +32 -0
- package/dist/side-panel/components/retro/Tooltip.js.map +1 -0
- package/dist/side-panel/constants.d.ts +5 -0
- package/dist/side-panel/constants.d.ts.map +1 -0
- package/dist/side-panel/constants.js +5 -0
- package/dist/side-panel/constants.js.map +1 -0
- package/dist/side-panel/hooks/useServerNotifications.d.ts +21 -0
- package/dist/side-panel/hooks/useServerNotifications.d.ts.map +1 -0
- package/dist/side-panel/hooks/useServerNotifications.js +93 -0
- package/dist/side-panel/hooks/useServerNotifications.js.map +1 -0
- package/dist/side-panel/hooks/useTheme.d.ts +8 -0
- package/dist/side-panel/hooks/useTheme.d.ts.map +1 -0
- package/dist/side-panel/hooks/useTheme.js +30 -0
- package/dist/side-panel/hooks/useTheme.js.map +1 -0
- package/dist/side-panel/index.d.ts +2 -0
- package/dist/side-panel/index.d.ts.map +1 -0
- package/dist/side-panel/index.js +12 -0
- package/dist/side-panel/index.js.map +1 -0
- package/dist/side-panel/lib/cn.d.ts +3 -0
- package/dist/side-panel/lib/cn.d.ts.map +1 -0
- package/dist/side-panel/lib/cn.js +4 -0
- package/dist/side-panel/lib/cn.js.map +1 -0
- package/dist/side-panel/lib/utils.d.ts +3 -0
- package/dist/side-panel/lib/utils.d.ts.map +1 -0
- package/dist/side-panel/lib/utils.js +4 -0
- package/dist/side-panel/lib/utils.js.map +1 -0
- package/dist/side-panel/side-panel.js +78034 -0
- package/dist/side-panel/styles.css +2 -0
- package/dist/side-panel-state.d.ts +11 -0
- package/dist/side-panel-state.d.ts.map +1 -0
- package/dist/side-panel-state.js +38 -0
- package/dist/side-panel-state.js.map +1 -0
- package/dist/side-panel-toggle.d.ts +3 -0
- package/dist/side-panel-toggle.d.ts.map +1 -0
- package/dist/side-panel-toggle.js +31 -0
- package/dist/side-panel-toggle.js.map +1 -0
- package/dist/tab-matching.d.ts +51 -0
- package/dist/tab-matching.d.ts.map +1 -0
- package/dist/tab-matching.js +160 -0
- package/dist/tab-matching.js.map +1 -0
- package/dist/tab-state.d.ts +56 -0
- package/dist/tab-state.d.ts.map +1 -0
- package/dist/tab-state.js +282 -0
- package/dist/tab-state.js.map +1 -0
- package/dist/tool-dispatch.d.ts +19 -0
- package/dist/tool-dispatch.d.ts.map +1 -0
- package/dist/tool-dispatch.js +336 -0
- package/dist/tool-dispatch.js.map +1 -0
- package/dist/types.d.ts +82 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/icons/icon-128.png +0 -0
- package/icons/icon-16.png +0 -0
- package/icons/icon-32.png +0 -0
- package/icons/icon-48.png +0 -0
- package/icons/icon.svg +6 -0
- package/manifest.json +38 -0
- package/offscreen/offscreen.html +10 -0
- package/package.json +49 -0
- package/side-panel/dark-mode.js +29 -0
- package/side-panel/fonts/archivo-black-latin.woff2 +0 -0
- package/side-panel/fonts/space-grotesk-latin.woff2 +0 -0
- package/side-panel/fonts/space-mono-400-latin.woff2 +0 -0
- package/side-panel/fonts/space-mono-700-latin.woff2 +0 -0
- package/side-panel/fonts.css +34 -0
- package/side-panel/side-panel.html +16 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { JSONRPC_ADAPTER_NOT_READY, JSONRPC_INTERNAL_ERROR, JSONRPC_NO_USABLE_TAB } from './json-rpc-errors.js';
|
|
2
|
+
import { sendToServer } from './messaging.js';
|
|
3
|
+
import { getPluginMeta } from './plugin-storage.js';
|
|
4
|
+
import { sanitizeErrorMessage } from './sanitize-error.js';
|
|
5
|
+
import { findAllMatchingTabs, urlMatchesPatterns } from './tab-matching.js';
|
|
6
|
+
import { toErrorMessage } from '@opentabs-dev/shared';
|
|
7
|
+
/**
|
|
8
|
+
* Whether a DispatchResult is an adapter-not-ready error (JSONRPC_ADAPTER_NOT_READY)
|
|
9
|
+
* that should trigger fallback to the next matching tab.
|
|
10
|
+
*/
|
|
11
|
+
const isAdapterNotReady = (result) => result.type === 'error' && result.code === JSONRPC_ADAPTER_NOT_READY;
|
|
12
|
+
/**
|
|
13
|
+
* Look up plugin metadata by name.
|
|
14
|
+
* Sends a JSONRPC_INTERNAL_ERROR via sendToServer if the plugin is not found.
|
|
15
|
+
* Returns the plugin metadata on success, or null on failure.
|
|
16
|
+
*/
|
|
17
|
+
const resolvePlugin = async (pluginName, id) => {
|
|
18
|
+
const plugin = await getPluginMeta(pluginName);
|
|
19
|
+
if (!plugin) {
|
|
20
|
+
sendToServer({
|
|
21
|
+
jsonrpc: '2.0',
|
|
22
|
+
error: { code: JSONRPC_INTERNAL_ERROR, message: `Plugin "${pluginName}" not found` },
|
|
23
|
+
id,
|
|
24
|
+
});
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return plugin;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Execute a chrome.scripting.executeScript call with a timeout and extract
|
|
31
|
+
* the first result. Returns a DispatchResult on success, or throws if the
|
|
32
|
+
* tab is inaccessible (e.g., closed).
|
|
33
|
+
*
|
|
34
|
+
* @param scriptPromise - The promise returned by chrome.scripting.executeScript
|
|
35
|
+
* @param timeoutMs - Timeout in milliseconds (defaults to SCRIPT_TIMEOUT_MS)
|
|
36
|
+
* @param fallbackMessage - Error message when no result is returned
|
|
37
|
+
*/
|
|
38
|
+
const executeWithTimeout = async (scriptPromise, timeoutMs, fallbackMessage) => {
|
|
39
|
+
let timeoutId;
|
|
40
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
41
|
+
timeoutId = setTimeout(() => {
|
|
42
|
+
reject(new Error(`Script execution timed out after ${timeoutMs}ms`));
|
|
43
|
+
}, timeoutMs);
|
|
44
|
+
});
|
|
45
|
+
let results;
|
|
46
|
+
try {
|
|
47
|
+
results = await Promise.race([scriptPromise, timeoutPromise]);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
clearTimeout(timeoutId);
|
|
51
|
+
}
|
|
52
|
+
const firstResult = results[0];
|
|
53
|
+
const result = firstResult?.result;
|
|
54
|
+
if (!result || typeof result !== 'object' || !('type' in result)) {
|
|
55
|
+
return { type: 'error', code: JSONRPC_INTERNAL_ERROR, message: fallbackMessage };
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Find matching tabs and iterate through them in ranked order, executing the
|
|
61
|
+
* given callback on each. Handles TOCTOU URL revalidation, adapter-not-ready
|
|
62
|
+
* fallback to the next tab, tab-gone detection, and error response routing.
|
|
63
|
+
*
|
|
64
|
+
* Sends the JSON-RPC response to the server and returns void.
|
|
65
|
+
*/
|
|
66
|
+
const dispatchWithTabFallback = async (config) => {
|
|
67
|
+
const { id, pluginName, plugin, operationName, executeOnTab } = config;
|
|
68
|
+
const matchingTabs = await findAllMatchingTabs(plugin);
|
|
69
|
+
if (matchingTabs.length === 0) {
|
|
70
|
+
sendToServer({
|
|
71
|
+
jsonrpc: '2.0',
|
|
72
|
+
error: { code: JSONRPC_NO_USABLE_TAB, message: `No matching tab for plugin "${pluginName}" (state: closed)` },
|
|
73
|
+
id,
|
|
74
|
+
});
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let firstError;
|
|
78
|
+
for (const tab of matchingTabs) {
|
|
79
|
+
if (tab.id === undefined)
|
|
80
|
+
continue;
|
|
81
|
+
// Re-validate tab URL to prevent TOCTOU race: the tab may have navigated
|
|
82
|
+
// between findAllMatchingTabs() and now.
|
|
83
|
+
try {
|
|
84
|
+
const currentTab = await chrome.tabs.get(tab.id);
|
|
85
|
+
if (!currentTab.url || !urlMatchesPatterns(currentTab.url, plugin.urlPatterns)) {
|
|
86
|
+
firstError ??= { code: JSONRPC_NO_USABLE_TAB, message: 'Tab navigated away from matching URL' };
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
firstError ??= { code: JSONRPC_NO_USABLE_TAB, message: `Tab closed before ${operationName}` };
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const result = await executeOnTab(tab.id);
|
|
96
|
+
if (result.type === 'success') {
|
|
97
|
+
sendToServer({ jsonrpc: '2.0', result: { output: result.output }, id });
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// Adapter-not-ready errors trigger fallback to the next matching tab
|
|
101
|
+
if (isAdapterNotReady(result) && matchingTabs.length > 1) {
|
|
102
|
+
firstError ??= { code: result.code, message: sanitizeErrorMessage(result.message) };
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
sendToServer({
|
|
106
|
+
jsonrpc: '2.0',
|
|
107
|
+
error: { code: result.code, message: sanitizeErrorMessage(result.message), data: result.data },
|
|
108
|
+
id,
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
const msg = toErrorMessage(err);
|
|
114
|
+
const isTabGone = msg.includes('No tab with id') || msg.includes('Cannot access');
|
|
115
|
+
if (isTabGone && matchingTabs.length > 1) {
|
|
116
|
+
firstError ??= { code: JSONRPC_NO_USABLE_TAB, message: `Tab closed before ${operationName}` };
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
sendToServer({
|
|
120
|
+
jsonrpc: '2.0',
|
|
121
|
+
error: {
|
|
122
|
+
code: isTabGone ? JSONRPC_NO_USABLE_TAB : JSONRPC_INTERNAL_ERROR,
|
|
123
|
+
message: isTabGone
|
|
124
|
+
? `Tab closed before ${operationName}`
|
|
125
|
+
: `Script execution failed: ${sanitizeErrorMessage(msg)}`,
|
|
126
|
+
},
|
|
127
|
+
id,
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// All matching tabs failed — return the error from the best-ranked tab
|
|
133
|
+
if (firstError) {
|
|
134
|
+
sendToServer({
|
|
135
|
+
jsonrpc: '2.0',
|
|
136
|
+
error: { code: firstError.code, message: firstError.message, data: firstError.data },
|
|
137
|
+
id,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
sendToServer({
|
|
142
|
+
jsonrpc: '2.0',
|
|
143
|
+
error: { code: JSONRPC_NO_USABLE_TAB, message: 'No usable tab found (all matching tabs have undefined IDs)' },
|
|
144
|
+
id,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
export { dispatchWithTabFallback, executeWithTimeout, resolvePlugin, isAdapterNotReady };
|
|
149
|
+
//# sourceMappingURL=dispatch-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch-helpers.js","sourceRoot":"","sources":["../src/dispatch-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAChH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAgBtD;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CAAC,MAAsB,EAAW,EAAE,CAC5D,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,KAAK,yBAAyB,CAAC;AAEvE;;;;GAIG;AACH,MAAM,aAAa,GAAG,KAAK,EAAE,UAAkB,EAAE,EAAmB,EAA8B,EAAE;IAClG,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,UAAU,CAAC,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AS;wBAChB,CAAC,CAAC,qBAAqB,aAAa,EAAE;wBACtC,CAAC,CAAC,4BAA4B,oBAAoB,CAAC,GAAG,CAAC,EAAE;iBAC5D;gBACD,EAAE;aACH,CAAC,CAAC;YACH,OAAO;QACT,CAAC;IACH,CAAC;IAED,uEAAuE;IACvE,IAAI,UAAU,EAAE,CAAC;QACf,YAAY,CAAC;YACX,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE;YACpF,EAAE;SACH,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,YAAY,CAAC;YACX,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,4DAA4D,EAAE;YAC7G,EAAE;SACH,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { TabState, TrustTier, WireToolDef } from '@opentabs-dev/shared';
|
|
2
|
+
/** Offscreen → Background: request the MCP server WebSocket URL */
|
|
3
|
+
export interface OffscreenGetUrlMessage {
|
|
4
|
+
type: 'offscreen:getUrl';
|
|
5
|
+
}
|
|
6
|
+
/** Reason the WebSocket disconnected — enables distinct error states in the side panel */
|
|
7
|
+
export type DisconnectReason = 'connection_refused' | 'auth_failed' | 'timeout';
|
|
8
|
+
/** Background → Offscreen: WebSocket connection state changed */
|
|
9
|
+
export interface WsStateMessage {
|
|
10
|
+
type: 'ws:state';
|
|
11
|
+
connected: boolean;
|
|
12
|
+
/** Present only when connected is false — indicates why the connection failed */
|
|
13
|
+
disconnectReason?: DisconnectReason;
|
|
14
|
+
}
|
|
15
|
+
/** Background/Offscreen: relay a JSON-RPC message from the MCP server */
|
|
16
|
+
export interface WsDataMessage {
|
|
17
|
+
type: 'ws:message';
|
|
18
|
+
data: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** Offscreen/Side panel → Background → Offscreen: send a JSON-RPC message to the MCP server */
|
|
21
|
+
export interface WsSendMessage {
|
|
22
|
+
type: 'ws:send';
|
|
23
|
+
data: unknown;
|
|
24
|
+
}
|
|
25
|
+
/** Background → Offscreen: query WebSocket connection state */
|
|
26
|
+
export interface WsGetStateMessage {
|
|
27
|
+
type: 'ws:getState';
|
|
28
|
+
}
|
|
29
|
+
/** Background → Offscreen: change the MCP server WebSocket URL */
|
|
30
|
+
export interface WsSetUrlMessage {
|
|
31
|
+
type: 'ws:setUrl';
|
|
32
|
+
url: string;
|
|
33
|
+
}
|
|
34
|
+
/** Side panel → Background: send a JSON-RPC message to the MCP server */
|
|
35
|
+
export interface BgSendMessage {
|
|
36
|
+
type: 'bg:send';
|
|
37
|
+
data: unknown;
|
|
38
|
+
}
|
|
39
|
+
/** Side panel → Background: query WebSocket connection state */
|
|
40
|
+
export interface BgGetConnectionStateMessage {
|
|
41
|
+
type: 'bg:getConnectionState';
|
|
42
|
+
}
|
|
43
|
+
/** Background → Offscreen: request log entries from the offscreen LogCollector */
|
|
44
|
+
export interface OffscreenGetLogsMessage {
|
|
45
|
+
type: 'offscreen:getLogs';
|
|
46
|
+
options?: {
|
|
47
|
+
level?: 'log' | 'warn' | 'error' | 'info';
|
|
48
|
+
source?: 'background' | 'offscreen' | 'side-panel';
|
|
49
|
+
since?: number;
|
|
50
|
+
limit?: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Background → Offscreen: force WebSocket disconnect and immediate reconnect */
|
|
54
|
+
export interface BgForceReconnectMessage {
|
|
55
|
+
type: 'bg:forceReconnect';
|
|
56
|
+
}
|
|
57
|
+
/** Background → Side panel: request current React state and rendered HTML */
|
|
58
|
+
export interface SpGetStateMessage {
|
|
59
|
+
type: 'sp:getState';
|
|
60
|
+
}
|
|
61
|
+
/** Background → Side panel: WebSocket connection state update */
|
|
62
|
+
export interface SpConnectionStateMessage {
|
|
63
|
+
type: 'sp:connectionState';
|
|
64
|
+
data: {
|
|
65
|
+
connected: boolean;
|
|
66
|
+
disconnectReason?: DisconnectReason;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Content script relay → Background: batched plugin log entries from adapter IIFE */
|
|
70
|
+
export interface PluginLogsMessage {
|
|
71
|
+
type: 'plugin:logs';
|
|
72
|
+
plugin: string;
|
|
73
|
+
entries: Array<{
|
|
74
|
+
level: string;
|
|
75
|
+
message: string;
|
|
76
|
+
data: unknown[];
|
|
77
|
+
ts: string;
|
|
78
|
+
}>;
|
|
79
|
+
}
|
|
80
|
+
/** Background → Side panel: forwarded JSON-RPC message from the MCP server */
|
|
81
|
+
export interface SpRelayMessage {
|
|
82
|
+
type: 'sp:serverMessage';
|
|
83
|
+
data: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
/** Content script relay → Background: tool progress notification from adapter IIFE */
|
|
86
|
+
export interface ToolProgressMessage {
|
|
87
|
+
type: 'tool:progress';
|
|
88
|
+
dispatchId: string;
|
|
89
|
+
progress: number;
|
|
90
|
+
total: number;
|
|
91
|
+
message?: string;
|
|
92
|
+
}
|
|
93
|
+
/** Background → Side panel: confirmation request from MCP server */
|
|
94
|
+
export interface SpConfirmationRequestMessage {
|
|
95
|
+
type: 'sp:confirmationRequest';
|
|
96
|
+
data: {
|
|
97
|
+
id: string;
|
|
98
|
+
tool: string;
|
|
99
|
+
domain: string | null;
|
|
100
|
+
tabId?: number;
|
|
101
|
+
paramsPreview: string;
|
|
102
|
+
timeoutMs: number;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** Side panel → Background: confirmation response from user */
|
|
106
|
+
export interface SpConfirmationResponseMessage {
|
|
107
|
+
type: 'sp:confirmationResponse';
|
|
108
|
+
data: {
|
|
109
|
+
id: string;
|
|
110
|
+
decision: 'allow_once' | 'allow_always' | 'deny';
|
|
111
|
+
scope?: 'tool_domain' | 'tool_all' | 'domain_all';
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** Side panel → Background: confirmation timed out without user response */
|
|
115
|
+
export interface SpConfirmationTimeoutMessage {
|
|
116
|
+
type: 'sp:confirmationTimeout';
|
|
117
|
+
id: string;
|
|
118
|
+
}
|
|
119
|
+
/** Side panel → Background → Offscreen: MCP server port changed */
|
|
120
|
+
export interface PortChangedMessage {
|
|
121
|
+
type: 'port-changed';
|
|
122
|
+
port: number;
|
|
123
|
+
}
|
|
124
|
+
/** All internal message types flowing through chrome.runtime.sendMessage */
|
|
125
|
+
export type InternalMessage = OffscreenGetUrlMessage | WsStateMessage | WsDataMessage | WsSendMessage | WsGetStateMessage | WsSetUrlMessage | BgSendMessage | BgGetConnectionStateMessage | OffscreenGetLogsMessage | BgForceReconnectMessage | PluginLogsMessage | ToolProgressMessage | SpGetStateMessage | SpConnectionStateMessage | SpRelayMessage | SpConfirmationRequestMessage | SpConfirmationResponseMessage | SpConfirmationTimeoutMessage | PortChangedMessage;
|
|
126
|
+
/** Tab state info for a single plugin — shared shape used by tab.stateChanged payloads */
|
|
127
|
+
export interface PluginTabStateInfo {
|
|
128
|
+
state: TabState;
|
|
129
|
+
tabId: number | null;
|
|
130
|
+
url: string | null;
|
|
131
|
+
}
|
|
132
|
+
/** Lightweight plugin metadata stored in the `plugins_meta` index (no IIFE content) */
|
|
133
|
+
export interface PluginMeta {
|
|
134
|
+
name: string;
|
|
135
|
+
version: string;
|
|
136
|
+
displayName: string;
|
|
137
|
+
urlPatterns: string[];
|
|
138
|
+
trustTier: TrustTier;
|
|
139
|
+
sourcePath?: string;
|
|
140
|
+
adapterHash?: string;
|
|
141
|
+
adapterFile?: string;
|
|
142
|
+
iconSvg?: string;
|
|
143
|
+
iconInactiveSvg?: string;
|
|
144
|
+
tools: WireToolDef[];
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=extension-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-messages.d.ts","sourceRoot":"","sources":["../src/extension-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAU7E,mEAAmE;AACnE,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED,0FAA0F;AAC1F,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,aAAa,GAAG,SAAS,CAAC;AAEhF,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,+FAA+F;AAC/F,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,gEAAgE;AAChE,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,uBAAuB,CAAC;CAC/B;AAED,kFAAkF;AAClF,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,CAAC,EAA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,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-messages.js","sourceRoot":"","sources":["../src/extension-messages.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
declare const isSafePluginName: (name: string) => boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Verify that the injected adapter reports the expected version.
|
|
4
|
+
* Returns true if versions match, false on mismatch or failure.
|
|
5
|
+
* Logs a warning on mismatch so the injection pipeline continues.
|
|
6
|
+
*/
|
|
7
|
+
declare const verifyAdapterVersion: (tabId: number, pluginName: string, expectedVersion: string) => Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Collect all unique tab IDs matching the given URL patterns.
|
|
10
|
+
* Queries each pattern independently and deduplicates by tab ID.
|
|
11
|
+
*/
|
|
12
|
+
declare const queryMatchingTabIds: (urlPatterns: string[]) => Promise<number[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Call an adapter's teardown() function in a tab via chrome.scripting.executeScript.
|
|
15
|
+
* Swallows errors — the injection pipeline continues regardless of teardown outcome.
|
|
16
|
+
*/
|
|
17
|
+
declare const teardownAdapterInTab: (tabId: number, pluginName: string) => Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Injects a plugin's adapter IIFE into all tabs matching its URL patterns.
|
|
20
|
+
*
|
|
21
|
+
* @param pluginName - The plugin's unique name (validated against reserved names)
|
|
22
|
+
* @param urlPatterns - Chrome match patterns identifying which tabs to inject into
|
|
23
|
+
* @param forceReinject - When `true`, re-inject even if the adapter is already
|
|
24
|
+
* present (used by plugin.update to overwrite stale adapter code). When `false`
|
|
25
|
+
* (default), tabs that already have the adapter are skipped.
|
|
26
|
+
* @param version - Expected adapter version string for post-injection verification
|
|
27
|
+
* @param adapterHash - Expected content hash for post-injection integrity check
|
|
28
|
+
* @param adapterFile - Relative path to the content-hashed adapter file (e.g., "adapters/my-plugin-a1b2c3d4.js")
|
|
29
|
+
* @returns Tab IDs where injection succeeded
|
|
30
|
+
*/
|
|
31
|
+
declare const injectPluginIntoMatchingTabs: (pluginName: string, urlPatterns: string[], forceReinject?: boolean, version?: string, adapterHash?: string, adapterFile?: string) => Promise<number[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Injects all stored plugins whose URL patterns match the given tab.
|
|
34
|
+
* Called on `chrome.tabs.onUpdated` (status=complete) so that tabs opened
|
|
35
|
+
* after `sync.full` still get their adapter files.
|
|
36
|
+
*
|
|
37
|
+
* @param tabId - The Chrome tab ID to inject adapters into
|
|
38
|
+
* @param tabUrl - The tab's current URL, used to filter plugins by URL pattern match
|
|
39
|
+
*/
|
|
40
|
+
declare const injectPluginsIntoTab: (tabId: number, tabUrl: string) => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Removes an injected adapter from all tabs matching the plugin's URL patterns.
|
|
43
|
+
* Calls the adapter's `teardown()` function and deletes it from `__openTabs.adapters`.
|
|
44
|
+
*
|
|
45
|
+
* @param pluginName - The plugin whose adapter should be removed
|
|
46
|
+
* @param urlPatterns - Chrome match patterns identifying which tabs to clean up
|
|
47
|
+
*/
|
|
48
|
+
declare const cleanupAdaptersInMatchingTabs: (pluginName: string, urlPatterns: string[]) => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Re-injects all stored plugins into their matching tabs on extension startup.
|
|
51
|
+
* Runs all plugin injections in parallel, logging warnings for any failures.
|
|
52
|
+
*/
|
|
53
|
+
declare const reinjectStoredPlugins: () => Promise<void>;
|
|
54
|
+
export { cleanupAdaptersInMatchingTabs, injectPluginIntoMatchingTabs, injectPluginsIntoTab, isSafePluginName, queryMatchingTabIds, reinjectStoredPlugins, teardownAdapterInTab, verifyAdapterVersion, };
|
|
55
|
+
//# sourceMappingURL=iife-injection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iife-injection.d.ts","sourceRoot":"","sources":["../src/iife-injection.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,OAA+D,CAAC;AAwBzG;;;;GAIG;AACH,QAAA,MAAM,oBAAoB,GAAU,OAAO,MAAM,EAAE,YAAY,MAAM,EAAE,iBAAiB,MAAM,KAAG,OAAO,CAAC,OAAO,CA0B/G,CAAC;AA0KF;;;GAGG;AACH,QAAA,MAAM,mBAAmB,GAAU,aAAa,MAAM,EAAE,KAAG,OAAO,CAAC,MAAM,EAAE,CAe1E,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,oBAAoB,GAAU,OAAO,MAAM,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAuBnF,CAAC;AA2DF;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,4BAA4B,GAChC,YAAY,MAAM,EAClB,aAAa,MAAM,EAAE,EACrB,uBAAqB,EACrB,UAAU,MAAM,EAChB,cAAc,MAAM,EACpB,cAAc,MAAM,KACnB,OAAO,CAAC,MAAM,EAAE,CAoClB,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,oBAAoB,GAAU,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,IAAI,CAqC/E,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,6BAA6B,GAAU,YAAY,MAAM,EAAE,aAAa,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAuDpG,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,qBAAqB,QAAa,OAAO,CAAC,IAAI,CAwBnD,CAAC;AAEF,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,GACrB,CAAC"}
|