extension-develop 3.1.0-next.8 → 3.1.1
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/547.js +14 -14
- package/dist/content-script-wrapper.js +4 -1
- package/dist/ensure-hmr-for-scripts.js +2 -0
- package/dist/extension-js-devtools/chrome/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +4 -5
- package/dist/extension-js-devtools/chrome/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/chrome/pages/welcome.js +4 -4
- package/dist/extension-js-devtools/chromium/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +4 -5
- package/dist/extension-js-devtools/chromium/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/chromium/pages/welcome.js +4 -4
- package/dist/extension-js-devtools/edge/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/edge/pages/centralized-logger.js +4 -5
- package/dist/extension-js-devtools/edge/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/edge/pages/welcome.js +4 -4
- package/dist/extension-js-devtools/firefox/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +4 -5
- package/dist/extension-js-devtools/firefox/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/firefox/pages/welcome.js +4 -4
- package/dist/module.js +398 -103
- package/package.json +1 -1
- package/dist/add-centralized-logger-script-background.js +0 -220
- package/dist/add-centralized-logger-script-content.js +0 -172
- package/dist/add-centralized-logger-script.js +0 -323
- package/dist/extension-js-devtools/chrome/logo.png +0 -0
- package/dist/extension-js-devtools/chromium/logo.png +0 -0
- package/dist/extension-js-devtools/edge/logo.png +0 -0
- package/dist/extension-js-devtools/firefox/logo.png +0 -0
package/package.json
CHANGED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
default: ()=>logger_background
|
|
37
|
-
});
|
|
38
|
-
const external_fs_namespaceObject = require("fs");
|
|
39
|
-
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
40
|
-
const external_path_namespaceObject = require("path");
|
|
41
|
-
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
42
|
-
const external_schema_utils_namespaceObject = require("schema-utils");
|
|
43
|
-
function filterKeysForThisBrowser(manifest, browser) {
|
|
44
|
-
const CHROMIUM_BASED_BROWSERS = [
|
|
45
|
-
'chrome',
|
|
46
|
-
'edge'
|
|
47
|
-
];
|
|
48
|
-
const GECKO_BASED_BROWSERS = [
|
|
49
|
-
'firefox'
|
|
50
|
-
];
|
|
51
|
-
const isChromiumTarget = CHROMIUM_BASED_BROWSERS.includes(browser) || String(browser).includes('chromium');
|
|
52
|
-
const isGeckoTarget = GECKO_BASED_BROWSERS.includes(browser) || String(browser).includes('gecko');
|
|
53
|
-
const chromiumPrefixes = new Set([
|
|
54
|
-
'chromium',
|
|
55
|
-
'chrome',
|
|
56
|
-
'edge'
|
|
57
|
-
]);
|
|
58
|
-
const geckoPrefixes = new Set([
|
|
59
|
-
'gecko',
|
|
60
|
-
'firefox'
|
|
61
|
-
]);
|
|
62
|
-
const patchedManifest = JSON.parse(JSON.stringify(manifest), function(key, value) {
|
|
63
|
-
const indexOfColon = key.indexOf(':');
|
|
64
|
-
if (-1 === indexOfColon) return value;
|
|
65
|
-
const prefix = key.substring(0, indexOfColon);
|
|
66
|
-
if (prefix === browser || isChromiumTarget && chromiumPrefixes.has(prefix) || isGeckoTarget && geckoPrefixes.has(prefix)) this[key.substring(indexOfColon + 1)] = value;
|
|
67
|
-
});
|
|
68
|
-
return patchedManifest;
|
|
69
|
-
}
|
|
70
|
-
const schema = {
|
|
71
|
-
type: 'object',
|
|
72
|
-
properties: {
|
|
73
|
-
test: {
|
|
74
|
-
type: 'string'
|
|
75
|
-
},
|
|
76
|
-
manifestPath: {
|
|
77
|
-
type: 'string'
|
|
78
|
-
},
|
|
79
|
-
mode: {
|
|
80
|
-
type: 'string'
|
|
81
|
-
},
|
|
82
|
-
browser: {
|
|
83
|
-
type: 'string'
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
function logger_background(source) {
|
|
88
|
-
const options = this.getOptions();
|
|
89
|
-
const manifestPath = options.manifestPath;
|
|
90
|
-
const projectPath = external_path_default().dirname(manifestPath);
|
|
91
|
-
const rawManifest = JSON.parse(external_fs_default().readFileSync(manifestPath, 'utf-8'));
|
|
92
|
-
const browser = options.browser || 'chrome';
|
|
93
|
-
const manifest = filterKeysForThisBrowser(rawManifest, browser);
|
|
94
|
-
(0, external_schema_utils_namespaceObject.validate)(schema, options, {
|
|
95
|
-
name: "scripts:add-centralized-logger-script-background",
|
|
96
|
-
baseDataPath: 'options'
|
|
97
|
-
});
|
|
98
|
-
const resourceAbsPath = external_path_default().normalize(this.resourcePath);
|
|
99
|
-
const loggerBootstrap = `
|
|
100
|
-
/* centralized background logger bootstrap */
|
|
101
|
-
(function() {
|
|
102
|
-
var loggerPort;
|
|
103
|
-
var buffer = [];
|
|
104
|
-
function tryConnect() {
|
|
105
|
-
if (!(typeof chrome !== "undefined" && chrome.runtime && chrome.runtime.connect)) return;
|
|
106
|
-
var targetId = (function(){
|
|
107
|
-
if (typeof self !== 'undefined' && (self).__EXT_LOGGER_ID__) return String((self).__EXT_LOGGER_ID__);
|
|
108
|
-
try {
|
|
109
|
-
var u = new URL(typeof location !== 'undefined' ? String(location.href) : '');
|
|
110
|
-
var v = u.searchParams.get('loggerId');
|
|
111
|
-
if (v) return v;
|
|
112
|
-
} catch {}
|
|
113
|
-
return '';
|
|
114
|
-
})();
|
|
115
|
-
if (!loggerPort && targetId) {
|
|
116
|
-
try {
|
|
117
|
-
loggerPort = chrome.runtime.connect(targetId, { name: 'logger' });
|
|
118
|
-
flush();
|
|
119
|
-
attachDisconnect();
|
|
120
|
-
} catch (e) {}
|
|
121
|
-
}
|
|
122
|
-
// intentionally avoid local self-connection to prevent loops; only external connection should be used
|
|
123
|
-
if (!loggerPort && chrome.management && typeof chrome.management.getAll === 'function') {
|
|
124
|
-
chrome.management.getAll(function(list){
|
|
125
|
-
var found = (list||[]).find(function(it){ return it && typeof it.name === 'string' && it.name.toLowerCase().includes('centralized-logger'); });
|
|
126
|
-
if (found && found.id && !loggerPort) {
|
|
127
|
-
try {
|
|
128
|
-
loggerPort = chrome.runtime.connect(found.id, { name: 'logger' });
|
|
129
|
-
flush();
|
|
130
|
-
attachDisconnect();
|
|
131
|
-
} catch (e) {}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
} else {
|
|
135
|
-
attachDisconnect();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function flush(){
|
|
139
|
-
if (!loggerPort || !loggerPort.postMessage) return;
|
|
140
|
-
var q = buffer; buffer = [];
|
|
141
|
-
for (var i=0;i<q.length;i++) {
|
|
142
|
-
try { loggerPort.postMessage(q[i]); } catch (e) {}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
function attachDisconnect(){
|
|
146
|
-
if (loggerPort && loggerPort.onDisconnect && loggerPort.onDisconnect.addListener) {
|
|
147
|
-
loggerPort.onDisconnect.addListener(function(){ loggerPort = null; });
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (typeof chrome !== "undefined" && chrome.runtime && chrome.runtime.connect) {
|
|
152
|
-
tryConnect();
|
|
153
|
-
|
|
154
|
-
// Bridge: forward any internal ports named 'logger' (e.g., from content/UI) to centralized logger
|
|
155
|
-
if (chrome.runtime && chrome.runtime.onConnect && chrome.runtime.onConnect.addListener) {
|
|
156
|
-
chrome.runtime.onConnect.addListener(function(port) {
|
|
157
|
-
if (!port || port.name !== 'logger') return;
|
|
158
|
-
port.onMessage.addListener(function(msg){
|
|
159
|
-
if (!loggerPort) { tryConnect(); }
|
|
160
|
-
if (loggerPort && loggerPort.postMessage) { loggerPort.postMessage(msg); }
|
|
161
|
-
else { buffer.push(msg); }
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function safePost(msg) {
|
|
168
|
-
try {
|
|
169
|
-
if (!loggerPort) { tryConnect(); }
|
|
170
|
-
if (loggerPort && loggerPort.postMessage) { loggerPort.postMessage(msg); }
|
|
171
|
-
else { buffer.push(msg); }
|
|
172
|
-
} catch (e) {}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (typeof self !== "undefined" && self.addEventListener) {
|
|
176
|
-
self.addEventListener('error', function(e) {
|
|
177
|
-
safePost({ type: 'log', level: 'error', context: 'background', messageParts: [ String(e && e.message || ''), String(e && e.filename || ''), e && e.lineno, e && e.colno ] });
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
self.addEventListener('unhandledrejection', function(e) {
|
|
181
|
-
var reason = '';
|
|
182
|
-
if (e && typeof e.reason !== "undefined") {
|
|
183
|
-
try { reason = typeof e.reason === "string" ? e.reason : JSON.stringify(e.reason); } catch (_) { reason = String(e.reason); }
|
|
184
|
-
}
|
|
185
|
-
safePost({ type: 'log', level: 'error', context: 'background', messageParts: ['Unhandled Rejection', reason] });
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
['log','info','warn','error','debug'].forEach(function(lvl) {
|
|
190
|
-
if (typeof console !== "undefined" && typeof console[lvl] === "function") {
|
|
191
|
-
var orig = console[lvl].bind(console);
|
|
192
|
-
console[lvl] = function() {
|
|
193
|
-
var args = Array.prototype.slice.call(arguments);
|
|
194
|
-
safePost({ type: 'log', level: String(lvl), context: 'background', messageParts: args });
|
|
195
|
-
orig.apply(console, args);
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
})();
|
|
200
|
-
`;
|
|
201
|
-
if (manifest.background) {
|
|
202
|
-
if (manifest.background.scripts) for (const bgScript of manifest.background.scripts){
|
|
203
|
-
const absoluteUrl = external_path_default().resolve(projectPath, bgScript);
|
|
204
|
-
if (resourceAbsPath === external_path_default().normalize(absoluteUrl)) return `${loggerBootstrap}${source}`;
|
|
205
|
-
}
|
|
206
|
-
if (manifest.background.service_worker) {
|
|
207
|
-
const swPath = manifest.background.service_worker;
|
|
208
|
-
const absoluteSwPath = external_path_default().resolve(projectPath, swPath);
|
|
209
|
-
if (resourceAbsPath === external_path_default().normalize(absoluteSwPath)) return `${loggerBootstrap}${source}`;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return source;
|
|
213
|
-
}
|
|
214
|
-
exports["default"] = __webpack_exports__["default"];
|
|
215
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
216
|
-
"default"
|
|
217
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
218
|
-
Object.defineProperty(exports, '__esModule', {
|
|
219
|
-
value: true
|
|
220
|
-
});
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
default: ()=>logger_script
|
|
37
|
-
});
|
|
38
|
-
const external_fs_namespaceObject = require("fs");
|
|
39
|
-
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
40
|
-
const external_path_namespaceObject = require("path");
|
|
41
|
-
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
42
|
-
const external_schema_utils_namespaceObject = require("schema-utils");
|
|
43
|
-
function filterKeysForThisBrowser(manifest, browser) {
|
|
44
|
-
const CHROMIUM_BASED_BROWSERS = [
|
|
45
|
-
'chrome',
|
|
46
|
-
'edge'
|
|
47
|
-
];
|
|
48
|
-
const GECKO_BASED_BROWSERS = [
|
|
49
|
-
'firefox'
|
|
50
|
-
];
|
|
51
|
-
const isChromiumTarget = CHROMIUM_BASED_BROWSERS.includes(browser) || String(browser).includes('chromium');
|
|
52
|
-
const isGeckoTarget = GECKO_BASED_BROWSERS.includes(browser) || String(browser).includes('gecko');
|
|
53
|
-
const chromiumPrefixes = new Set([
|
|
54
|
-
'chromium',
|
|
55
|
-
'chrome',
|
|
56
|
-
'edge'
|
|
57
|
-
]);
|
|
58
|
-
const geckoPrefixes = new Set([
|
|
59
|
-
'gecko',
|
|
60
|
-
'firefox'
|
|
61
|
-
]);
|
|
62
|
-
const patchedManifest = JSON.parse(JSON.stringify(manifest), function(key, value) {
|
|
63
|
-
const indexOfColon = key.indexOf(':');
|
|
64
|
-
if (-1 === indexOfColon) return value;
|
|
65
|
-
const prefix = key.substring(0, indexOfColon);
|
|
66
|
-
if (prefix === browser || isChromiumTarget && chromiumPrefixes.has(prefix) || isGeckoTarget && geckoPrefixes.has(prefix)) this[key.substring(indexOfColon + 1)] = value;
|
|
67
|
-
});
|
|
68
|
-
return patchedManifest;
|
|
69
|
-
}
|
|
70
|
-
const schema = {
|
|
71
|
-
type: 'object',
|
|
72
|
-
properties: {
|
|
73
|
-
test: {
|
|
74
|
-
type: 'string'
|
|
75
|
-
},
|
|
76
|
-
manifestPath: {
|
|
77
|
-
type: 'string'
|
|
78
|
-
},
|
|
79
|
-
mode: {
|
|
80
|
-
type: 'string'
|
|
81
|
-
},
|
|
82
|
-
browser: {
|
|
83
|
-
type: 'string'
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
function logger_script(source) {
|
|
88
|
-
const options = this.getOptions();
|
|
89
|
-
const manifestPath = options.manifestPath;
|
|
90
|
-
const projectPath = external_path_default().dirname(manifestPath);
|
|
91
|
-
const rawManifest = JSON.parse(external_fs_default().readFileSync(manifestPath, 'utf-8'));
|
|
92
|
-
const browser = options.browser || 'chrome';
|
|
93
|
-
const manifest = filterKeysForThisBrowser(rawManifest, browser);
|
|
94
|
-
(0, external_schema_utils_namespaceObject.validate)(schema, options, {
|
|
95
|
-
name: "scripts:add-centralized-logger-script-content",
|
|
96
|
-
baseDataPath: 'options'
|
|
97
|
-
});
|
|
98
|
-
const resourceAbsPath = external_path_default().normalize(this.resourcePath);
|
|
99
|
-
const pageScriptName = 'content-logger.page.js';
|
|
100
|
-
const pageScriptContent = '(function(){\n function post(msg){ try { window.postMessage(msg, "*") } catch (_) {} }\n window.addEventListener("error", function(e){\n post({ __reactLogger: true, type: "log", level: "error",\n messageParts: [ String(e && e.message || ""), String(e && e.filename || ""), e && e.lineno, e && e.colno ],\n url: String(location && location.href || "") })\n })\n window.addEventListener("unhandledrejection", function(e){\n var reason; try { reason = typeof e.reason === "string" ? e.reason : JSON.stringify(e.reason) } catch (_) { reason = String(e.reason) }\n post({ __reactLogger: true, type: "log", level: "error", messageParts: ["Unhandled Rejection", reason], url: String(location && location.href || "") })\n })\n ["log","info","warn","error","debug","trace"].forEach(function(level){\n try {\n var original = console[level] && console[level].bind ? console[level].bind(console) : console[level]\n console[level] = function(){ var args = [].slice.call(arguments); post({ __reactLogger: true, type: "log", level: level, messageParts: args, url: String(location && location.href || "") }); try { return original && original.apply ? original.apply(console, args) : void 0 } catch (_) {} }\n } catch (_) {}\n })\n try {\n var oc = console.clear && console.clear.bind ? console.clear.bind(console) : console.clear; if (oc) console.clear = function(){ try { post({ __reactLogger: true, type: "log", level: "info", messageParts: ["console.clear"], url: String(location && location.href || ""), meta: { kind: "clear" } }) } catch (_) {} try { return oc.apply(console, arguments) } catch (_) {} }\n } catch (_) {}\n ;["group","groupCollapsed","groupEnd"].forEach(function(k){ try { var og = console[k] && console[k].bind ? console[k].bind(console) : console[k]; if (!og) return; console[k] = function(){ var args = [].slice.call(arguments); try { post({ __reactLogger: true, type: "log", level: "log", messageParts: args, url: String(location && location.href || ""), meta: { kind: k } }) } catch (_) {} try { return og.apply(console, args) } catch (_) {} } } catch (_) {} })\n ;["time","timeLog","timeEnd","count","countReset","table"].forEach(function(k){ try { var oo = console[k] && console[k].bind ? console[k].bind(console) : console[k]; if (!oo) return; console[k] = function(){ var args = [].slice.call(arguments); try { post({ __reactLogger: true, type: "log", level: "log", messageParts: args, url: String(location && location.href || ""), meta: { kind: k } }) } catch (_) {} try { return oo.apply(console, args) } catch (_) {} } } catch (_) {} })\n})()';
|
|
101
|
-
this.emitFile(pageScriptName, pageScriptContent);
|
|
102
|
-
const loggerBootstrap = `
|
|
103
|
-
/* centralized content logger bootstrap */
|
|
104
|
-
(function() {
|
|
105
|
-
var contextLabel = 'content'
|
|
106
|
-
var port
|
|
107
|
-
if (typeof chrome !== 'undefined' && chrome.runtime && chrome.runtime.connect) {
|
|
108
|
-
var targetId = (function(){
|
|
109
|
-
if (typeof window !== 'undefined' && (window).__EXT_LOGGER_ID__) return String((window).__EXT_LOGGER_ID__)
|
|
110
|
-
try { var u = new URL(typeof location !== 'undefined' ? String(location.href) : ''); var v = u.searchParams.get('loggerId'); if (v) return v } catch {}
|
|
111
|
-
return ''
|
|
112
|
-
})()
|
|
113
|
-
|
|
114
|
-
if (targetId) { try { port = chrome.runtime.connect(targetId, { name: 'logger' }) } catch (_) {} }
|
|
115
|
-
if (!port) { try { port = chrome.runtime.connect({ name: 'logger' }) } catch (_) {} }
|
|
116
|
-
|
|
117
|
-
if (!port && chrome.management && typeof chrome.management.getAll === 'function') {
|
|
118
|
-
chrome.management.getAll(function(list){
|
|
119
|
-
var found = (list||[]).find(function(it){ return it && typeof it.name === 'string' && it.name.toLowerCase().includes('centralized-logger') })
|
|
120
|
-
if (found && found.id) { try { port = chrome.runtime.connect(found.id, { name: 'logger' }) } catch (_) {} }
|
|
121
|
-
})
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function safePost(msg) { if (port && port.postMessage) { port.postMessage(msg) } }
|
|
126
|
-
|
|
127
|
-
window.addEventListener('message', function(event){
|
|
128
|
-
try {
|
|
129
|
-
var data = (event && event.data) || {}
|
|
130
|
-
if (!data || data.__reactLogger !== true || data.type !== 'log') return
|
|
131
|
-
var parts = Array.isArray(data.messageParts) ? data.messageParts : [data.messageParts]
|
|
132
|
-
var meta = (typeof data.meta === 'object' && data.meta) ? data.meta : undefined
|
|
133
|
-
safePost({ type: 'log', level: String(data.level || 'log'), context: 'page', messageParts: parts, url: data.url, meta: meta })
|
|
134
|
-
} catch (_) {}
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
var el = document.createElement('script')
|
|
138
|
-
try { el.src = chrome.runtime.getURL('${pageScriptName}') } catch (_) {}
|
|
139
|
-
(document.documentElement || document.head || document.body).appendChild(el)
|
|
140
|
-
|
|
141
|
-
;['log','info','warn','error','debug','trace'].forEach(function(level) {
|
|
142
|
-
if (typeof console !== 'undefined' && typeof console[level] === 'function') {
|
|
143
|
-
var original = console[level].bind(console)
|
|
144
|
-
console[level] = function() {
|
|
145
|
-
var args = Array.prototype.slice.call(arguments)
|
|
146
|
-
try { safePost({ type:'log', level:String(level), context: contextLabel, messageParts: args }) } catch (_) {}
|
|
147
|
-
original.apply(console, args)
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
})()
|
|
152
|
-
`;
|
|
153
|
-
const declaredContentJsAbsPaths = [];
|
|
154
|
-
const contentScripts = Array.isArray(manifest.content_scripts) ? manifest.content_scripts : [];
|
|
155
|
-
for (const cs of contentScripts){
|
|
156
|
-
const jsList = Array.isArray(cs?.js) ? cs.js : [];
|
|
157
|
-
for (const js of jsList){
|
|
158
|
-
const abs = external_path_default().resolve(projectPath, js);
|
|
159
|
-
declaredContentJsAbsPaths.push(abs);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const isDeclaredContentScript = declaredContentJsAbsPaths.some((abs)=>resourceAbsPath === external_path_default().normalize(abs));
|
|
163
|
-
if (isDeclaredContentScript) return `${loggerBootstrap}${source}`;
|
|
164
|
-
return source;
|
|
165
|
-
}
|
|
166
|
-
exports["default"] = __webpack_exports__["default"];
|
|
167
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
168
|
-
"default"
|
|
169
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
170
|
-
Object.defineProperty(exports, '__esModule', {
|
|
171
|
-
value: true
|
|
172
|
-
});
|