@playwright-repl/runner 0.21.6 → 0.21.7
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/chrome-extension/devtools/console.js +23 -7
- package/dist/chrome-extension/devtools/console.js.map +1 -1
- package/dist/chrome-extension/devtools/devtools.js +1 -1
- package/dist/chrome-extension/devtools/devtools.js.map +1 -1
- package/dist/chrome-extension/manifest.json +1 -1
- package/dist/chrome-extension/panel/panel.js +5 -5
- package/dist/chrome-extension/panel/panel.js.map +1 -1
- package/dist/chrome-extension/sw-debugger-core.js +1 -1
- package/dist/chrome-extension/sw-debugger-core.js.map +1 -1
- package/dist/pw-cli.js +0 -0
- package/package.json +37 -38
- package/LICENSE +0 -21
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
import "../modulepreload-polyfill.js";
|
|
2
2
|
import { c as clientExports, j as jsxRuntimeExports, r as reactExports } from "../index.js";
|
|
3
|
-
import { aa as panelReducer, ab as initialState,
|
|
3
|
+
import { aa as panelReducer, ab as initialState, ac as onConsoleEvent, a5 as Console, g as attachToTab } from "../index2.js";
|
|
4
4
|
import "../sw-debugger-core.js";
|
|
5
5
|
function DevToolsConsole() {
|
|
6
6
|
const [state, dispatch] = reactExports.useReducer(panelReducer, initialState);
|
|
7
7
|
reactExports.useEffect(() => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const inspectedTabId = chrome.devtools?.inspectedWindow?.tabId;
|
|
9
|
+
async function doAttach(tabId) {
|
|
10
|
+
const [res, tab] = await Promise.all([
|
|
11
|
+
attachToTab(tabId),
|
|
12
|
+
chrome.tabs.get(tabId).catch(() => null)
|
|
13
|
+
]);
|
|
14
|
+
if (res.ok && res.url) {
|
|
15
|
+
const idx = (tab?.index ?? 0) + 1;
|
|
16
|
+
dispatch({ type: "ATTACH_SUCCESS", url: res.url, tabId });
|
|
17
|
+
dispatch({ type: "ADD_LINE", line: { text: `Attached to tab ${idx}: ${res.url}`, type: "info" } });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (inspectedTabId) {
|
|
21
|
+
doAttach(inspectedTabId).catch((e) => console.warn("[pw-repl] auto-attach failed:", e));
|
|
14
22
|
}
|
|
23
|
+
const onActivated = (info) => {
|
|
24
|
+
if (!inspectedTabId || info.tabId !== inspectedTabId) return;
|
|
25
|
+
doAttach(inspectedTabId).catch((e) => console.warn("[pw-repl] re-attach failed:", e));
|
|
26
|
+
};
|
|
27
|
+
chrome.tabs.onActivated.addListener(onActivated);
|
|
28
|
+
return () => {
|
|
29
|
+
chrome.tabs.onActivated.removeListener(onActivated);
|
|
30
|
+
};
|
|
15
31
|
}, []);
|
|
16
32
|
reactExports.useEffect(() => {
|
|
17
33
|
onConsoleEvent((level, args) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.js","sources":["../../src/devtools/console.tsx"],"sourcesContent":["/**\r\n * DevTools REPL Console — mounts the Console component in a DevTools panel.\r\n */\r\nimport '../panel/panel.css';\r\nimport { createRoot } from 'react-dom/client';\r\nimport { useReducer, useEffect } from 'react';\r\nimport { panelReducer, initialState } from '../panel/reducer';\r\nimport { attachToTab } from '../panel/lib/bridge';\r\nimport { Console } from '../panel/components/Console';\r\nimport { onConsoleEvent } from '../panel/lib/sw-debugger';\r\n\r\nfunction DevToolsConsole() {\r\n const [state, dispatch] = useReducer(panelReducer, initialState);\r\n
|
|
1
|
+
{"version":3,"file":"console.js","sources":["../../src/devtools/console.tsx"],"sourcesContent":["/**\r\n * DevTools REPL Console — mounts the Console component in a DevTools panel.\r\n */\r\nimport '../panel/panel.css';\r\nimport { createRoot } from 'react-dom/client';\r\nimport { useReducer, useEffect } from 'react';\r\nimport { panelReducer, initialState } from '../panel/reducer';\r\nimport { attachToTab } from '../panel/lib/bridge';\r\nimport { Console } from '../panel/components/Console';\r\nimport { onConsoleEvent } from '../panel/lib/sw-debugger';\r\n\r\nfunction DevToolsConsole() {\r\n const [state, dispatch] = useReducer(panelReducer, initialState);\r\n // Auto-attach to the inspected tab, re-attach when user switches back\r\n useEffect(() => {\r\n const inspectedTabId = chrome.devtools?.inspectedWindow?.tabId;\r\n\r\n async function doAttach(tabId: number) {\r\n const [res, tab] = await Promise.all([\r\n attachToTab(tabId),\r\n chrome.tabs.get(tabId).catch(() => null),\r\n ]);\r\n if (res.ok && res.url) {\r\n const idx = (tab?.index ?? 0) + 1;\r\n dispatch({ type: 'ATTACH_SUCCESS', url: res.url, tabId });\r\n dispatch({ type: 'ADD_LINE', line: { text: `Attached to tab ${idx}: ${res.url}`, type: 'info' } });\r\n }\r\n }\r\n\r\n if (inspectedTabId) {\r\n doAttach(inspectedTabId).catch(e => console.warn('[pw-repl] auto-attach failed:', e));\r\n }\r\n\r\n const onActivated = (info: chrome.tabs.TabActiveInfo) => {\r\n if (!inspectedTabId || info.tabId !== inspectedTabId) return;\r\n doAttach(inspectedTabId).catch(e => console.warn('[pw-repl] re-attach failed:', e));\r\n };\r\n chrome.tabs.onActivated.addListener(onActivated);\r\n\r\n return () => {\r\n chrome.tabs.onActivated.removeListener(onActivated);\r\n };\r\n }, []);\r\n\r\n // Forward console.log/error from the page\r\n useEffect(() => {\r\n onConsoleEvent((level, args) => {\r\n for (const arg of args) {\r\n const type = level === 'error' ? 'error' : level === 'warn' ? 'info' : 'success';\r\n dispatch({ type: 'ADD_LINE', line: { text: '', type, value: arg } });\r\n }\r\n });\r\n return () => onConsoleEvent(null);\r\n }, [dispatch]);\r\n\r\n return <Console outputLines={state.outputLines} dispatch={dispatch} />;\r\n}\r\n\r\ncreateRoot(document.getElementById('root')!).render(<DevToolsConsole />);\r\n"],"names":["useReducer","useEffect","jsx","createRoot"],"mappings":";;;;AAWA,SAAS,kBAAkB;AACzB,QAAM,CAAC,OAAO,QAAQ,IAAIA,aAAAA,WAAW,cAAc,YAAY;AAE/DC,eAAAA,UAAU,MAAM;AACd,UAAM,iBAAiB,OA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,aAAa,UAAoB;AACtE;AAEAC,cAAAA,WAAW,SAAS,eAAe,MAAM,CAAE,EAAE,OAAOD,kCAAAA,IAAC,mBAAgB,CAAE;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.js","sources":["../../src/devtools/devtools.ts"],"sourcesContent":["/**\r\n * DevTools entry point — creates a \"REPL\" panel in Chrome DevTools.\r\n */\r\nchrome.devtools.panels.create(\r\n '
|
|
1
|
+
{"version":3,"file":"devtools.js","sources":["../../src/devtools/devtools.ts"],"sourcesContent":["/**\r\n * DevTools entry point — creates a \"REPL\" panel in Chrome DevTools.\r\n */\r\nchrome.devtools.panels.create(\r\n 'Playwright',\r\n 'icons/dramaturg_icon_16.png',\r\n 'devtools/console.html',\r\n);\r\n"],"names":[],"mappings":";AAGA,OAAO,SAAS,OAAO;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AACF;"}
|
|
@@ -118,10 +118,11 @@ function Toolbar({ editorContent, editorMode, stepLine, attachedUrl, attachedTab
|
|
|
118
118
|
const lines = reactExports.useMemo(() => editorContent.split("\n"), [editorContent]);
|
|
119
119
|
function isInternalUrl(url) {
|
|
120
120
|
if (!url) return true;
|
|
121
|
-
return url.startsWith("chrome://") || url.startsWith("chrome-extension://")
|
|
121
|
+
return url.startsWith("chrome://") || url.startsWith("chrome-extension://");
|
|
122
122
|
}
|
|
123
123
|
function getTabLabel(tab) {
|
|
124
124
|
try {
|
|
125
|
+
if (tab.url?.startsWith("about:")) return tab.url;
|
|
125
126
|
const url = new URL(tab.url);
|
|
126
127
|
if (url.protocol === "chrome:") return `chrome://${url.hostname}`;
|
|
127
128
|
return url.hostname;
|
|
@@ -134,7 +135,7 @@ function Toolbar({ editorContent, editorMode, stepLine, attachedUrl, attachedTab
|
|
|
134
135
|
const tabs = await chrome.tabs.query({});
|
|
135
136
|
const ownOrigin = `chrome-extension://${chrome.runtime.id}/`;
|
|
136
137
|
const panelUrl = `${ownOrigin}panel/panel.html`;
|
|
137
|
-
setAvailableTabs(tabs.filter((t) => t?.url && !t.url.startsWith(
|
|
138
|
+
setAvailableTabs(tabs.filter((t) => t?.url && !t.url.startsWith(panelUrl) && (!t.url.startsWith("chrome-extension://") || t.url.startsWith(ownOrigin))));
|
|
138
139
|
}
|
|
139
140
|
async function checkActiveTab() {
|
|
140
141
|
if (!chrome.tabs?.query) return;
|
|
@@ -2126,14 +2127,13 @@ function App() {
|
|
|
2126
2127
|
const tab = tabs[0];
|
|
2127
2128
|
const url = tab?.url ?? "";
|
|
2128
2129
|
const ownOrigin = `chrome-extension://${chrome.runtime.id}/`;
|
|
2129
|
-
if (tab?.id && !url.startsWith("chrome://") &&
|
|
2130
|
+
if (tab?.id && !url.startsWith("chrome://") && (!url.startsWith("chrome-extension://") || url.startsWith(ownOrigin))) {
|
|
2130
2131
|
doAttach(tab.id);
|
|
2131
2132
|
}
|
|
2132
2133
|
});
|
|
2133
2134
|
const onActivated = async (info) => {
|
|
2134
2135
|
const tab = await chrome.tabs.get(info.tabId).catch(() => null);
|
|
2135
2136
|
const url = tab?.url ?? "";
|
|
2136
|
-
if (url.startsWith("about:")) return;
|
|
2137
2137
|
if (url.startsWith("chrome-extension://") && !url.startsWith(`chrome-extension://${chrome.runtime.id}/`)) return;
|
|
2138
2138
|
if (url.startsWith("chrome://")) {
|
|
2139
2139
|
attachedTabRef.current = null;
|
|
@@ -2148,7 +2148,7 @@ function App() {
|
|
|
2148
2148
|
if (changeInfo.url) dispatch({ type: "UPDATE_URL", url: changeInfo.url });
|
|
2149
2149
|
return;
|
|
2150
2150
|
}
|
|
2151
|
-
if (changeInfo.url && !changeInfo.url.startsWith("chrome://") &&
|
|
2151
|
+
if (changeInfo.url && !changeInfo.url.startsWith("chrome://") && (!changeInfo.url.startsWith("chrome-extension://") || changeInfo.url.startsWith(`chrome-extension://${chrome.runtime.id}/`))) {
|
|
2152
2152
|
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
|
2153
2153
|
if (tabs[0]?.id === tabId) doAttach(tabId);
|
|
2154
2154
|
});
|