extension-develop 3.1.0-next.8 → 3.2.0-next.2
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 +426 -132
- package/package.json +1 -2
- 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
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
default: ()=>addCentralizedLoggerScript
|
|
28
|
-
});
|
|
29
|
-
const external_path_namespaceObject = require("path");
|
|
30
|
-
const external_fs_namespaceObject = require("fs");
|
|
31
|
-
const external_schema_utils_namespaceObject = require("schema-utils");
|
|
32
|
-
const external_parse5_utilities_namespaceObject = require("parse5-utilities");
|
|
33
|
-
function isUrl(src) {
|
|
34
|
-
try {
|
|
35
|
-
new URL(src);
|
|
36
|
-
return true;
|
|
37
|
-
} catch (err) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function parseHtml(node, onResourceFound) {
|
|
42
|
-
if ('#comment' === node.nodeName || '#text' === node.nodeName) return;
|
|
43
|
-
if ("script" === node.nodeName) {
|
|
44
|
-
const src = node.attrs?.find((attr)=>'src' === attr.name)?.value;
|
|
45
|
-
if (!src) return;
|
|
46
|
-
if (isUrl(src)) return;
|
|
47
|
-
onResourceFound({
|
|
48
|
-
filePath: src,
|
|
49
|
-
childNode: node,
|
|
50
|
-
assetType: "script"
|
|
51
|
-
});
|
|
52
|
-
} else if ('link' === node.nodeName) {
|
|
53
|
-
const href = node.attrs?.find((attr)=>'href' === attr.name)?.value;
|
|
54
|
-
const rel = node.attrs?.find((attr)=>'rel' === attr.name)?.value;
|
|
55
|
-
if (!href) return;
|
|
56
|
-
if (isUrl(href)) return;
|
|
57
|
-
onResourceFound('dns-prefetch' === rel || 'icon' === rel || 'manifest' === rel || 'modulepreload' === rel || 'preconnect' === rel || 'prefetch' === rel || 'preload' === rel || 'prerender' === rel ? {
|
|
58
|
-
filePath: href,
|
|
59
|
-
childNode: node,
|
|
60
|
-
assetType: 'staticHref'
|
|
61
|
-
} : {
|
|
62
|
-
filePath: href,
|
|
63
|
-
childNode: node,
|
|
64
|
-
assetType: 'css'
|
|
65
|
-
});
|
|
66
|
-
} else if ('audio' === node.nodeName || 'embed' === node.nodeName || 'iframe' === node.nodeName || 'img' === node.nodeName || 'input' === node.nodeName || 'source' === node.nodeName || 'track' === node.nodeName || 'video' === node.nodeName) {
|
|
67
|
-
const src = node.attrs?.find((attr)=>'src' === attr.name)?.value;
|
|
68
|
-
if (!src) return;
|
|
69
|
-
if (isUrl(src)) return;
|
|
70
|
-
onResourceFound({
|
|
71
|
-
filePath: src,
|
|
72
|
-
childNode: node,
|
|
73
|
-
assetType: 'staticSrc'
|
|
74
|
-
});
|
|
75
|
-
const srcset = node.attrs?.find((attr)=>'srcset' === attr.name)?.value;
|
|
76
|
-
if (srcset) {
|
|
77
|
-
const candidates = srcset.split(',');
|
|
78
|
-
for (const candidate of candidates){
|
|
79
|
-
const parts = candidate.trim().split(/\s+/);
|
|
80
|
-
const url = parts[0];
|
|
81
|
-
if (!url) continue;
|
|
82
|
-
const { cleanPath } = cleanAssetUrl(url);
|
|
83
|
-
if (cleanPath && !isUrl(cleanPath)) onResourceFound({
|
|
84
|
-
filePath: cleanPath,
|
|
85
|
-
childNode: node,
|
|
86
|
-
assetType: 'staticSrc'
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if ('video' === node.nodeName) {
|
|
91
|
-
const poster = node.attrs?.find((attr)=>'poster' === attr.name)?.value;
|
|
92
|
-
if (poster && !isUrl(poster)) {
|
|
93
|
-
const { cleanPath } = cleanAssetUrl(poster);
|
|
94
|
-
if (cleanPath) onResourceFound({
|
|
95
|
-
filePath: cleanPath,
|
|
96
|
-
childNode: node,
|
|
97
|
-
assetType: 'staticSrc'
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
} else if ('link' === node.nodeName) {
|
|
102
|
-
const imagesrcset = node.attrs?.find((attr)=>'imagesrcset' === attr.name)?.value;
|
|
103
|
-
if (imagesrcset) {
|
|
104
|
-
const candidates = imagesrcset.split(',');
|
|
105
|
-
for (const candidate of candidates){
|
|
106
|
-
const parts = candidate.trim().split(/\s+/);
|
|
107
|
-
const url = parts[0];
|
|
108
|
-
if (!url) continue;
|
|
109
|
-
const { cleanPath } = cleanAssetUrl(url);
|
|
110
|
-
if (cleanPath && !isUrl(cleanPath)) onResourceFound({
|
|
111
|
-
filePath: cleanPath,
|
|
112
|
-
childNode: node,
|
|
113
|
-
assetType: 'staticHref'
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
const { childNodes = [] } = node;
|
|
119
|
-
for (const childNode of childNodes)if ('#comment' !== childNode.nodeName && '#text' !== childNode.nodeName) parseHtml(childNode, onResourceFound);
|
|
120
|
-
}
|
|
121
|
-
function getAssetsFromHtml(htmlFilePath, htmlContent, publicPath = 'public') {
|
|
122
|
-
const assets = {
|
|
123
|
-
css: [],
|
|
124
|
-
js: [],
|
|
125
|
-
static: []
|
|
126
|
-
};
|
|
127
|
-
if (!htmlFilePath) return assets;
|
|
128
|
-
try {
|
|
129
|
-
const htmlString = htmlContent || external_fs_namespaceObject.readFileSync(htmlFilePath, {
|
|
130
|
-
encoding: 'utf8'
|
|
131
|
-
});
|
|
132
|
-
if (!htmlString) return assets;
|
|
133
|
-
const htmlDocument = external_parse5_utilities_namespaceObject.parse(htmlString);
|
|
134
|
-
const baseHref = getBaseHref(htmlDocument);
|
|
135
|
-
const getAbsolutePath = (htmlFilePath, filePathWithParts)=>{
|
|
136
|
-
const { cleanPath } = cleanAssetUrl(filePathWithParts);
|
|
137
|
-
if (utils_isUrl(cleanPath)) return cleanPath;
|
|
138
|
-
if (cleanPath.startsWith('/')) return cleanPath;
|
|
139
|
-
const isBaseUrl = utils_isUrl(baseHref || '');
|
|
140
|
-
const baseJoin = baseHref && !isBaseUrl ? external_path_namespaceObject.join(external_path_namespaceObject.dirname(htmlFilePath), baseHref) : external_path_namespaceObject.dirname(htmlFilePath);
|
|
141
|
-
return external_path_namespaceObject.join(baseJoin, cleanPath);
|
|
142
|
-
};
|
|
143
|
-
parseHtml(htmlDocument, ({ filePath, assetType })=>{
|
|
144
|
-
const fileAbsolutePath = getAbsolutePath(htmlFilePath, filePath);
|
|
145
|
-
switch(assetType){
|
|
146
|
-
case "script":
|
|
147
|
-
assets.js?.push(fileAbsolutePath);
|
|
148
|
-
break;
|
|
149
|
-
case 'css':
|
|
150
|
-
assets.css?.push(fileAbsolutePath);
|
|
151
|
-
break;
|
|
152
|
-
case 'staticSrc':
|
|
153
|
-
case 'staticHref':
|
|
154
|
-
if (filePath.startsWith('#')) break;
|
|
155
|
-
assets.static?.push(fileAbsolutePath);
|
|
156
|
-
break;
|
|
157
|
-
default:
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
} catch (error) {}
|
|
162
|
-
return assets;
|
|
163
|
-
}
|
|
164
|
-
function utils_isUrl(src) {
|
|
165
|
-
try {
|
|
166
|
-
new URL(src);
|
|
167
|
-
return true;
|
|
168
|
-
} catch (err) {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
function cleanAssetUrl(url) {
|
|
173
|
-
const hashIndex = url.indexOf('#');
|
|
174
|
-
const queryIndex = url.indexOf('?');
|
|
175
|
-
let endIndex = url.length;
|
|
176
|
-
if (-1 !== hashIndex && -1 !== queryIndex) endIndex = Math.min(hashIndex, queryIndex);
|
|
177
|
-
else if (-1 !== hashIndex) endIndex = hashIndex;
|
|
178
|
-
else if (-1 !== queryIndex) endIndex = queryIndex;
|
|
179
|
-
const cleanPath = url.slice(0, endIndex);
|
|
180
|
-
const hash = -1 !== hashIndex ? url.slice(hashIndex) : '';
|
|
181
|
-
const search = -1 !== queryIndex ? url.slice(queryIndex, -1 !== hashIndex ? hashIndex : void 0) : '';
|
|
182
|
-
return {
|
|
183
|
-
cleanPath,
|
|
184
|
-
hash,
|
|
185
|
-
search
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function getBaseHref(htmlDocument) {
|
|
189
|
-
const htmlChildren = htmlDocument.childNodes || [];
|
|
190
|
-
for (const node of htmlChildren)if (node?.nodeName === 'html') {
|
|
191
|
-
for (const child of node.childNodes || [])if (child?.nodeName === 'head') {
|
|
192
|
-
for (const headChild of child.childNodes || [])if (headChild?.nodeName === 'base') {
|
|
193
|
-
const href = headChild.attrs?.find((a)=>'href' === a.name)?.value;
|
|
194
|
-
if (href) return href;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
const schema = {
|
|
200
|
-
type: 'object',
|
|
201
|
-
properties: {
|
|
202
|
-
test: {
|
|
203
|
-
type: 'string'
|
|
204
|
-
},
|
|
205
|
-
manifestPath: {
|
|
206
|
-
type: 'string'
|
|
207
|
-
},
|
|
208
|
-
includeList: {
|
|
209
|
-
type: 'object'
|
|
210
|
-
},
|
|
211
|
-
browser: {
|
|
212
|
-
type: 'string'
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
function addCentralizedLoggerScript(source) {
|
|
217
|
-
const options = this.getOptions();
|
|
218
|
-
const manifestPath = options.manifestPath;
|
|
219
|
-
const projectPath = external_path_namespaceObject.dirname(manifestPath);
|
|
220
|
-
try {
|
|
221
|
-
(0, external_schema_utils_namespaceObject.validate)(schema, options, {
|
|
222
|
-
name: "html:add-centralized-logger-script",
|
|
223
|
-
baseDataPath: 'options'
|
|
224
|
-
});
|
|
225
|
-
} catch (error) {
|
|
226
|
-
throw error;
|
|
227
|
-
}
|
|
228
|
-
const resourcePath = this.resourcePath || '';
|
|
229
|
-
const normalizedResource = external_path_namespaceObject.normalize(resourcePath);
|
|
230
|
-
const loggerPrelude = `
|
|
231
|
-
if (import.meta.webpackHot) { import.meta.webpackHot.accept() }
|
|
232
|
-
`;
|
|
233
|
-
if (source.includes('/* centralized ui logger bootstrap */')) return `${loggerPrelude}${source}`;
|
|
234
|
-
const includeList = options.includeList || {};
|
|
235
|
-
const featureToContext = (featureKey)=>{
|
|
236
|
-
const root = (featureKey || '').split('/')[0];
|
|
237
|
-
if ('action' === root || 'page_action' === root) return 'popup';
|
|
238
|
-
if ('options' === root || 'options_ui' === root || 'options_page' === root) return 'options';
|
|
239
|
-
if ('sidebar' === root || 'sidebar_action' === root || 'side_panel' === root) return 'sidebar';
|
|
240
|
-
if ('devtools' === root) return 'devtools';
|
|
241
|
-
return 'ui';
|
|
242
|
-
};
|
|
243
|
-
let matchedContext;
|
|
244
|
-
for (const [feature, htmlPath] of Object.entries(includeList)){
|
|
245
|
-
if (!htmlPath) continue;
|
|
246
|
-
if (!external_fs_namespaceObject.existsSync(htmlPath)) continue;
|
|
247
|
-
const assets = getAssetsFromHtml(htmlPath);
|
|
248
|
-
const jsAssets = assets?.js || [];
|
|
249
|
-
const absAssets = jsAssets.map((p)=>{
|
|
250
|
-
if (p.startsWith('/')) return external_path_namespaceObject.normalize(external_path_namespaceObject.join(projectPath, 'public', p.slice(1)));
|
|
251
|
-
return external_path_namespaceObject.normalize(p);
|
|
252
|
-
});
|
|
253
|
-
if (absAssets.some((p)=>p === normalizedResource)) {
|
|
254
|
-
matchedContext = featureToContext(feature);
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
if (matchedContext) {
|
|
259
|
-
const loggerBridge = `
|
|
260
|
-
/* centralized ui logger bootstrap */
|
|
261
|
-
(function() {
|
|
262
|
-
var ctx = ${JSON.stringify(matchedContext)};
|
|
263
|
-
var port;
|
|
264
|
-
if (typeof chrome !== "undefined" && chrome.runtime && chrome.runtime.connect) {
|
|
265
|
-
var targetId = (function(){
|
|
266
|
-
if (typeof window !== 'undefined' && (window).__EXT_LOGGER_ID__) return String((window).__EXT_LOGGER_ID__);
|
|
267
|
-
try {
|
|
268
|
-
var u = new URL(typeof location !== 'undefined' ? String(location.href) : '');
|
|
269
|
-
var v = u.searchParams.get('loggerId');
|
|
270
|
-
if (v) return v;
|
|
271
|
-
} catch {}
|
|
272
|
-
return '';
|
|
273
|
-
})();
|
|
274
|
-
|
|
275
|
-
if (targetId) {
|
|
276
|
-
try { port = chrome.runtime.connect(targetId, { name: 'logger' }); } catch (e) {}
|
|
277
|
-
}
|
|
278
|
-
if (!port) {
|
|
279
|
-
try { port = chrome.runtime.connect({ name: 'logger' }); } catch (e) {}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// Best-effort late resolution via management API (requires permission in sender)
|
|
283
|
-
if (!port && chrome.management && typeof chrome.management.getAll === 'function') {
|
|
284
|
-
chrome.management.getAll(function(list){
|
|
285
|
-
var found = (list||[]).find(function(it){ return it && typeof it.name === 'string' && it.name.toLowerCase().includes('centralized-logger'); });
|
|
286
|
-
if (found && found.id) {
|
|
287
|
-
try { port = chrome.runtime.connect(found.id, { name: 'logger' }); } catch (e) {}
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function safePost(msg) {
|
|
294
|
-
if (port && port.postMessage) { port.postMessage(msg); }
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
['log','info','warn','error','debug','trace'].forEach(function(lvl) {
|
|
298
|
-
if (typeof console !== "undefined" && typeof console[lvl] === "function") {
|
|
299
|
-
var orig = console[lvl].bind(console);
|
|
300
|
-
console[lvl] = function() {
|
|
301
|
-
var args = Array.prototype.slice.call(arguments);
|
|
302
|
-
safePost({ type:'log', level:String(lvl), context: ctx, messageParts: args });
|
|
303
|
-
orig.apply(console, args);
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
if (typeof console !== 'undefined' && typeof console.clear === 'function') {
|
|
308
|
-
var _clear = console.clear.bind(console);
|
|
309
|
-
console.clear = function(){ try { safePost({ type:'log', level:'info', context: ctx, messageParts:['console.clear'], meta: { kind: 'clear' } }) } catch (e) {} try { return _clear.apply(console, arguments) } catch (e) {} }
|
|
310
|
-
}
|
|
311
|
-
})();
|
|
312
|
-
`;
|
|
313
|
-
return `${loggerPrelude}${loggerBridge}${source}`;
|
|
314
|
-
}
|
|
315
|
-
return `${loggerPrelude}${source}`;
|
|
316
|
-
}
|
|
317
|
-
exports["default"] = __webpack_exports__["default"];
|
|
318
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
319
|
-
"default"
|
|
320
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
321
|
-
Object.defineProperty(exports, '__esModule', {
|
|
322
|
-
value: true
|
|
323
|
-
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|