extension-develop 2.1.0 → 2.1.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/add-content-script-wrapper.js +24 -12
- package/dist/add-hmr-accept-code.js +1 -0
- package/dist/develop-lib/config-types.d.ts +1 -0
- package/dist/develop-lib/get-project-path.d.ts +1 -1
- package/dist/develop-lib/messages.d.ts +1 -0
- package/dist/extensions/chrome-manager-extension/background.js +40 -14
- package/dist/extensions/chrome-manager-extension/reload-service.js +24 -2
- package/dist/extensions/chromium-based-manager-extension/background.js +40 -14
- package/dist/extensions/chromium-based-manager-extension/reload-service.js +24 -2
- package/dist/extensions/edge-manager-extension/background.js +38 -14
- package/dist/extensions/edge-manager-extension/reload-service.js +24 -2
- package/dist/extensions/firefox-manager-extension/reload-service.js +12 -2
- package/dist/extensions/gecko-based-manager-extension/background.js +10 -0
- package/dist/extensions/gecko-based-manager-extension/reload-service.js +15 -2
- package/dist/module.js +74 -51
- package/package.json +3 -2
|
@@ -125,13 +125,17 @@ class ReactContentScriptWrapper {
|
|
|
125
125
|
// Create shadow root for style isolation
|
|
126
126
|
this.shadowRoot = this.rootElement.attachShadow({ mode: 'open' })
|
|
127
127
|
|
|
128
|
+
// Create a host element inside the shadow root for rendering
|
|
129
|
+
const host = document.createElement('div')
|
|
130
|
+
this.shadowRoot.appendChild(host)
|
|
131
|
+
|
|
128
132
|
// Inject styles FIRST
|
|
129
133
|
console.log('[Extension.js] About to inject styles')
|
|
130
134
|
await this.injectStyles()
|
|
131
135
|
|
|
132
136
|
// Render React content
|
|
133
137
|
console.log('[Extension.js] About to render React content')
|
|
134
|
-
const result = this.renderFunction(
|
|
138
|
+
const result = this.renderFunction(host)
|
|
135
139
|
if (typeof result === 'function') {
|
|
136
140
|
this.unmountFunction = result
|
|
137
141
|
}
|
|
@@ -198,8 +202,8 @@ class ReactContentScriptWrapper {
|
|
|
198
202
|
// Check if we have hardcoded content for this stylesheet
|
|
199
203
|
if (cssContentMap[stylesheet]) {
|
|
200
204
|
const cssContent = cssContentMap[stylesheet]
|
|
201
|
-
allCSS += cssContent + '
|
|
202
|
-
console.log(
|
|
205
|
+
allCSS += cssContent + '\n'
|
|
206
|
+
console.log('[Extension.js] Successfully injected React', stylesheet, 'content')
|
|
203
207
|
continue
|
|
204
208
|
}
|
|
205
209
|
|
|
@@ -208,7 +212,7 @@ class ReactContentScriptWrapper {
|
|
|
208
212
|
const response = await fetch(cssUrl)
|
|
209
213
|
const text = await response.text()
|
|
210
214
|
if (response.ok) {
|
|
211
|
-
allCSS += text + '
|
|
215
|
+
allCSS += text + '\n'
|
|
212
216
|
console.log('[Extension.js] Successfully fetched stylesheet:', stylesheet)
|
|
213
217
|
} else {
|
|
214
218
|
console.warn('[Extension.js] Failed to fetch CSS:', stylesheet)
|
|
@@ -405,13 +409,17 @@ class VueContentScriptWrapper {
|
|
|
405
409
|
// Create shadow root for style isolation
|
|
406
410
|
this.shadowRoot = this.rootElement.attachShadow({ mode: 'open' })
|
|
407
411
|
|
|
412
|
+
// Create a host element inside the shadow root for rendering
|
|
413
|
+
const host = document.createElement('div')
|
|
414
|
+
this.shadowRoot.appendChild(host)
|
|
415
|
+
|
|
408
416
|
// Inject styles FIRST
|
|
409
417
|
console.log('[Extension.js] About to inject styles')
|
|
410
418
|
await this.injectStyles()
|
|
411
419
|
|
|
412
420
|
// Render Vue content
|
|
413
421
|
console.log('[Extension.js] About to render Vue content')
|
|
414
|
-
const result = this.renderFunction(
|
|
422
|
+
const result = this.renderFunction(host)
|
|
415
423
|
if (typeof result === 'function') {
|
|
416
424
|
this.unmountFunction = result
|
|
417
425
|
}
|
|
@@ -478,8 +486,8 @@ class VueContentScriptWrapper {
|
|
|
478
486
|
// Check if we have hardcoded content for this stylesheet
|
|
479
487
|
if (cssContentMap[stylesheet]) {
|
|
480
488
|
const cssContent = cssContentMap[stylesheet]
|
|
481
|
-
allCSS += cssContent + '
|
|
482
|
-
console.log(
|
|
489
|
+
allCSS += cssContent + '\n'
|
|
490
|
+
console.log('[Extension.js] Successfully injected Vue', stylesheet, 'content')
|
|
483
491
|
continue
|
|
484
492
|
}
|
|
485
493
|
|
|
@@ -488,7 +496,7 @@ class VueContentScriptWrapper {
|
|
|
488
496
|
const response = await fetch(cssUrl)
|
|
489
497
|
const text = await response.text()
|
|
490
498
|
if (response.ok) {
|
|
491
|
-
allCSS += text + '
|
|
499
|
+
allCSS += text + '\n'
|
|
492
500
|
console.log('[Extension.js] Successfully fetched stylesheet:', stylesheet)
|
|
493
501
|
} else {
|
|
494
502
|
console.warn('[Extension.js] Failed to fetch CSS:', stylesheet)
|
|
@@ -683,13 +691,17 @@ class SvelteContentScriptWrapper {
|
|
|
683
691
|
// Create shadow root for style isolation
|
|
684
692
|
this.shadowRoot = this.rootElement.attachShadow({ mode: 'open' })
|
|
685
693
|
|
|
694
|
+
// Create a host element inside the shadow root for rendering
|
|
695
|
+
const host = document.createElement('div')
|
|
696
|
+
this.shadowRoot.appendChild(host)
|
|
697
|
+
|
|
686
698
|
// Inject styles FIRST
|
|
687
699
|
console.log('[Extension.js] About to inject styles')
|
|
688
700
|
await this.injectStyles()
|
|
689
701
|
|
|
690
702
|
// Render Svelte content
|
|
691
703
|
console.log('[Extension.js] About to render Svelte content')
|
|
692
|
-
const result = this.renderFunction(
|
|
704
|
+
const result = this.renderFunction(host)
|
|
693
705
|
if (typeof result === 'function') {
|
|
694
706
|
this.unmountFunction = result
|
|
695
707
|
}
|
|
@@ -756,8 +768,8 @@ class SvelteContentScriptWrapper {
|
|
|
756
768
|
// Check if we have hardcoded content for this stylesheet
|
|
757
769
|
if (cssContentMap[stylesheet]) {
|
|
758
770
|
const cssContent = cssContentMap[stylesheet]
|
|
759
|
-
allCSS += cssContent + '
|
|
760
|
-
console.log(
|
|
771
|
+
allCSS += cssContent + '\n'
|
|
772
|
+
console.log('[Extension.js] Successfully injected Svelte', stylesheet, 'content')
|
|
761
773
|
continue
|
|
762
774
|
}
|
|
763
775
|
|
|
@@ -766,7 +778,7 @@ class SvelteContentScriptWrapper {
|
|
|
766
778
|
const response = await fetch(cssUrl)
|
|
767
779
|
const text = await response.text()
|
|
768
780
|
if (response.ok) {
|
|
769
|
-
allCSS += text + '
|
|
781
|
+
allCSS += text + '\n'
|
|
770
782
|
console.log('[Extension.js] Successfully fetched stylesheet:', stylesheet)
|
|
771
783
|
} else {
|
|
772
784
|
console.warn('[Extension.js] Failed to fetch CSS:', stylesheet)
|
|
@@ -64,6 +64,7 @@ function add_hmr_accept_code(source) {
|
|
|
64
64
|
name: "scripts:add-hmr-accept-code",
|
|
65
65
|
baseDataPath: 'options'
|
|
66
66
|
});
|
|
67
|
+
if (source.includes('import.meta.webpackHot')) return source;
|
|
67
68
|
const url = (0, external_loader_utils_namespaceObject.urlToRequest)(this.resourcePath);
|
|
68
69
|
const reloadCode = `
|
|
69
70
|
// TODO: cezaraugusto re-visit this
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface ProjectStructure {
|
|
2
2
|
manifestPath: string;
|
|
3
|
-
packageJsonPath
|
|
3
|
+
packageJsonPath?: string;
|
|
4
4
|
}
|
|
5
5
|
export declare function getProjectPath(pathOrRemoteUrl: string | undefined): Promise<string>;
|
|
6
6
|
export declare function getProjectStructure(pathOrRemoteUrl: string | undefined): Promise<ProjectStructure>;
|
|
@@ -25,6 +25,7 @@ export declare function downloadingText(url: string): string;
|
|
|
25
25
|
export declare function unpackagingExtension(zipFilePath: string): string;
|
|
26
26
|
export declare function unpackagedSuccessfully(): string;
|
|
27
27
|
export declare function failedToDownloadOrExtractZIPFileError(error: any): string;
|
|
28
|
+
export declare function invalidRemoteZip(url: string, contentType: string): string;
|
|
28
29
|
export declare function isUsingExperimentalConfig(integration: any): string;
|
|
29
30
|
export declare function installingDependencies(): string;
|
|
30
31
|
export declare function installingDependenciesFailed(gitCommand: string, gitArgs: string[], code: number | null): string;
|
|
@@ -4,9 +4,14 @@ import {connect, disconnect, keepAlive} from './reload-service.js'
|
|
|
4
4
|
function bgGreen(str) {
|
|
5
5
|
return `background: transparent; color: #0971fe; ${str}`
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
async function initManagerUI() {
|
|
9
|
+
try {
|
|
10
|
+
chrome.tabs.query({active: true, currentWindow: true}, async (tabs) => {
|
|
11
|
+
const initialTab = Array.isArray(tabs) ? tabs[0] : undefined
|
|
12
|
+
|
|
13
|
+
console.log(
|
|
14
|
+
`%c
|
|
10
15
|
██████████████████████████████████████████████████████████
|
|
11
16
|
██████████████████████████████████████████████████████████
|
|
12
17
|
████████████████████████████ ██████████████████████████
|
|
@@ -32,22 +37,43 @@ chrome.tabs.query({active: true}, async ([initialTab]) => {
|
|
|
32
37
|
██████████████████████████████████████████████████████████
|
|
33
38
|
MIT (c) ${new Date().getFullYear()} - Cezar Augusto and the Extension.js Authors.
|
|
34
39
|
`,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
bgGreen('')
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
if (!initialTab) {
|
|
44
|
+
try {
|
|
45
|
+
await handleFirstRun()
|
|
46
|
+
} catch {
|
|
47
|
+
try {
|
|
48
|
+
chrome.tabs.create({url: 'chrome://extensions/'})
|
|
49
|
+
} catch {}
|
|
50
|
+
}
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
initialTab.url === 'chrome://newtab/' ||
|
|
56
|
+
initialTab.url === 'chrome://welcome/'
|
|
57
|
+
) {
|
|
58
|
+
await handleFirstRun()
|
|
59
|
+
} else {
|
|
60
|
+
createExtensionsPageTab(initialTab, 'chrome://extensions/')
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
} catch {}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Guard tab access and run after startup
|
|
67
|
+
chrome.runtime.onStartup.addListener(async () => {
|
|
68
|
+
await initManagerUI()
|
|
46
69
|
})
|
|
47
70
|
|
|
48
71
|
chrome.runtime.onInstalled.addListener(async () => {
|
|
49
72
|
let isConnected = false
|
|
50
73
|
|
|
74
|
+
// Ensure UI setup also runs on install (first run)
|
|
75
|
+
await initManagerUI()
|
|
76
|
+
|
|
51
77
|
if (isConnected) {
|
|
52
78
|
disconnect()
|
|
53
79
|
} else {
|
|
@@ -20,7 +20,12 @@ export async function connect() {
|
|
|
20
20
|
const maxBackoffMs = 5000
|
|
21
21
|
|
|
22
22
|
const establish = () => {
|
|
23
|
-
|
|
23
|
+
try {
|
|
24
|
+
webSocket = new WebSocket(`ws://127.0.0.1:${port}`)
|
|
25
|
+
} catch (err) {
|
|
26
|
+
webSocket = null
|
|
27
|
+
return
|
|
28
|
+
}
|
|
24
29
|
|
|
25
30
|
webSocket.onerror = (_event) => {
|
|
26
31
|
try {
|
|
@@ -37,7 +42,12 @@ export async function connect() {
|
|
|
37
42
|
|
|
38
43
|
let reloadDebounce
|
|
39
44
|
webSocket.onmessage = async (event) => {
|
|
40
|
-
|
|
45
|
+
let message = null
|
|
46
|
+
try {
|
|
47
|
+
message = JSON.parse(event.data)
|
|
48
|
+
} catch {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
41
51
|
|
|
42
52
|
// Only process messages for this instance
|
|
43
53
|
if (message.instanceId && message.instanceId !== instanceId) {
|
|
@@ -77,6 +87,18 @@ export function disconnect() {
|
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
89
|
|
|
90
|
+
// Ensure sockets are closed when the worker is suspended
|
|
91
|
+
try {
|
|
92
|
+
chrome.runtime.onSuspend.addListener(() => {
|
|
93
|
+
if (webSocket) {
|
|
94
|
+
try {
|
|
95
|
+
webSocket.close()
|
|
96
|
+
} catch {}
|
|
97
|
+
webSocket = null
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
} catch {}
|
|
101
|
+
|
|
80
102
|
async function requestInitialLoadData() {
|
|
81
103
|
const devExtensions = await getDevExtensions()
|
|
82
104
|
|
|
@@ -4,9 +4,14 @@ import {connect, disconnect, keepAlive} from './reload-service.js'
|
|
|
4
4
|
function bgGreen(str) {
|
|
5
5
|
return `background: transparent; color: #0971fe; ${str}`
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
async function initManagerUI() {
|
|
9
|
+
try {
|
|
10
|
+
chrome.tabs.query({active: true, currentWindow: true}, async (tabs) => {
|
|
11
|
+
const initialTab = Array.isArray(tabs) ? tabs[0] : undefined
|
|
12
|
+
|
|
13
|
+
console.log(
|
|
14
|
+
`%c
|
|
10
15
|
██████████████████████████████████████████████████████████
|
|
11
16
|
██████████████████████████████████████████████████████████
|
|
12
17
|
████████████████████████████ ██████████████████████████
|
|
@@ -32,22 +37,43 @@ chrome.tabs.query({active: true}, async ([initialTab]) => {
|
|
|
32
37
|
██████████████████████████████████████████████████████████
|
|
33
38
|
MIT (c) ${new Date().getFullYear()} - Cezar Augusto and the Extension.js Authors.
|
|
34
39
|
`,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
bgGreen('')
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
if (!initialTab) {
|
|
44
|
+
try {
|
|
45
|
+
await handleFirstRun()
|
|
46
|
+
} catch {
|
|
47
|
+
try {
|
|
48
|
+
chrome.tabs.create({url: 'chrome://extensions/'})
|
|
49
|
+
} catch {}
|
|
50
|
+
}
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
initialTab.url === 'chrome://newtab/' ||
|
|
56
|
+
initialTab.url === 'chrome://welcome/'
|
|
57
|
+
) {
|
|
58
|
+
await handleFirstRun()
|
|
59
|
+
} else {
|
|
60
|
+
createExtensionsPageTab(initialTab, 'chrome://extensions/')
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
} catch {}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Guard tab access and run after startup
|
|
67
|
+
chrome.runtime.onStartup.addListener(async () => {
|
|
68
|
+
await initManagerUI()
|
|
46
69
|
})
|
|
47
70
|
|
|
48
71
|
chrome.runtime.onInstalled.addListener(async () => {
|
|
49
72
|
let isConnected = false
|
|
50
73
|
|
|
74
|
+
// Ensure UI setup also runs on install (first run)
|
|
75
|
+
await initManagerUI()
|
|
76
|
+
|
|
51
77
|
if (isConnected) {
|
|
52
78
|
disconnect()
|
|
53
79
|
} else {
|
|
@@ -17,7 +17,12 @@ export async function connect() {
|
|
|
17
17
|
const maxBackoffMs = 5000
|
|
18
18
|
|
|
19
19
|
const establish = () => {
|
|
20
|
-
|
|
20
|
+
try {
|
|
21
|
+
webSocket = new WebSocket(`ws://127.0.0.1:${port}`)
|
|
22
|
+
} catch (err) {
|
|
23
|
+
webSocket = null
|
|
24
|
+
return
|
|
25
|
+
}
|
|
21
26
|
|
|
22
27
|
webSocket.onerror = (_event) => {
|
|
23
28
|
try {
|
|
@@ -34,7 +39,12 @@ export async function connect() {
|
|
|
34
39
|
|
|
35
40
|
let reloadDebounce
|
|
36
41
|
webSocket.onmessage = async (event) => {
|
|
37
|
-
|
|
42
|
+
let message = null
|
|
43
|
+
try {
|
|
44
|
+
message = JSON.parse(event.data)
|
|
45
|
+
} catch {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
38
48
|
|
|
39
49
|
if (message.status === 'serverReady') {
|
|
40
50
|
await requestInitialLoadData()
|
|
@@ -69,6 +79,18 @@ export function disconnect() {
|
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
|
|
82
|
+
// Ensure sockets are closed when the worker is suspended
|
|
83
|
+
try {
|
|
84
|
+
chrome.runtime.onSuspend.addListener(() => {
|
|
85
|
+
if (webSocket) {
|
|
86
|
+
try {
|
|
87
|
+
webSocket.close()
|
|
88
|
+
} catch {}
|
|
89
|
+
webSocket = null
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
} catch {}
|
|
93
|
+
|
|
72
94
|
async function getDevExtensions() {
|
|
73
95
|
const allExtensions = await new Promise((resolve) => {
|
|
74
96
|
chrome.management.getAll(resolve)
|
|
@@ -4,9 +4,14 @@ import {connect, disconnect, keepAlive} from './reload-service.js'
|
|
|
4
4
|
function bgGreen(str) {
|
|
5
5
|
return `background: transparent; color: #0971fe; ${str}`
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
async function initManagerUI() {
|
|
9
|
+
try {
|
|
10
|
+
chrome.tabs.query({active: true, currentWindow: true}, async (tabs) => {
|
|
11
|
+
const initialTab = Array.isArray(tabs) ? tabs[0] : undefined
|
|
12
|
+
|
|
13
|
+
console.log(
|
|
14
|
+
`%c
|
|
10
15
|
██████████████████████████████████████████████████████████
|
|
11
16
|
██████████████████████████████████████████████████████████
|
|
12
17
|
████████████████████████████ ██████████████████████████
|
|
@@ -32,22 +37,41 @@ chrome.tabs.query({active: true}, async ([initialTab]) => {
|
|
|
32
37
|
██████████████████████████████████████████████████████████
|
|
33
38
|
MIT (c) ${new Date().getFullYear()} - Cezar Augusto and the Extension.js Authors.
|
|
34
39
|
`,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
bgGreen('')
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
if (!initialTab) {
|
|
44
|
+
try {
|
|
45
|
+
await handleFirstRun()
|
|
46
|
+
} catch {
|
|
47
|
+
try {
|
|
48
|
+
chrome.tabs.create({url: 'chrome://extensions/'})
|
|
49
|
+
} catch {}
|
|
50
|
+
}
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
initialTab.url === 'chrome://newtab/' ||
|
|
56
|
+
initialTab.url === 'chrome://welcome/'
|
|
57
|
+
) {
|
|
58
|
+
await handleFirstRun()
|
|
59
|
+
} else {
|
|
60
|
+
createExtensionsPageTab(initialTab, 'chrome://extensions/')
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
} catch {}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
chrome.runtime.onStartup.addListener(async () => {
|
|
67
|
+
await initManagerUI()
|
|
46
68
|
})
|
|
47
69
|
|
|
48
70
|
chrome.runtime.onInstalled.addListener(async () => {
|
|
49
71
|
let isConnected = false
|
|
50
72
|
|
|
73
|
+
await initManagerUI()
|
|
74
|
+
|
|
51
75
|
if (isConnected) {
|
|
52
76
|
disconnect()
|
|
53
77
|
} else {
|
|
@@ -20,7 +20,12 @@ export async function connect() {
|
|
|
20
20
|
const maxBackoffMs = 5000
|
|
21
21
|
|
|
22
22
|
const establish = () => {
|
|
23
|
-
|
|
23
|
+
try {
|
|
24
|
+
webSocket = new WebSocket(`ws://127.0.0.1:${port}`)
|
|
25
|
+
} catch (err) {
|
|
26
|
+
webSocket = null
|
|
27
|
+
return
|
|
28
|
+
}
|
|
24
29
|
|
|
25
30
|
webSocket.onerror = (_event) => {
|
|
26
31
|
try {
|
|
@@ -37,7 +42,12 @@ export async function connect() {
|
|
|
37
42
|
|
|
38
43
|
let reloadDebounce
|
|
39
44
|
webSocket.onmessage = async (event) => {
|
|
40
|
-
|
|
45
|
+
let message = null
|
|
46
|
+
try {
|
|
47
|
+
message = JSON.parse(event.data)
|
|
48
|
+
} catch {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
41
51
|
|
|
42
52
|
// Only process messages for this instance
|
|
43
53
|
if (message.instanceId && message.instanceId !== instanceId) {
|
|
@@ -77,6 +87,18 @@ export function disconnect() {
|
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
89
|
|
|
90
|
+
// Ensure sockets are closed when the worker is suspended
|
|
91
|
+
try {
|
|
92
|
+
chrome.runtime.onSuspend.addListener(() => {
|
|
93
|
+
if (webSocket) {
|
|
94
|
+
try {
|
|
95
|
+
webSocket.close()
|
|
96
|
+
} catch {}
|
|
97
|
+
webSocket = null
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
} catch {}
|
|
101
|
+
|
|
80
102
|
async function requestInitialLoadData() {
|
|
81
103
|
const devExtensions = await getDevExtensions()
|
|
82
104
|
|
|
@@ -17,7 +17,12 @@ async function connect() {
|
|
|
17
17
|
const maxBackoffMs = 5000
|
|
18
18
|
|
|
19
19
|
const connectTo = (url) => {
|
|
20
|
-
|
|
20
|
+
try {
|
|
21
|
+
webSocket = new WebSocket(url)
|
|
22
|
+
} catch (err) {
|
|
23
|
+
webSocket = null
|
|
24
|
+
return
|
|
25
|
+
}
|
|
21
26
|
|
|
22
27
|
webSocket.onerror = (_event) => {
|
|
23
28
|
try {
|
|
@@ -38,7 +43,12 @@ async function connect() {
|
|
|
38
43
|
|
|
39
44
|
let reloadDebounce
|
|
40
45
|
webSocket.onmessage = async (event) => {
|
|
41
|
-
|
|
46
|
+
let message = null
|
|
47
|
+
try {
|
|
48
|
+
message = JSON.parse(event.data)
|
|
49
|
+
} catch {
|
|
50
|
+
return
|
|
51
|
+
}
|
|
42
52
|
|
|
43
53
|
// Only process messages for this instance
|
|
44
54
|
if (message.instanceId && message.instanceId !== instanceId) {
|
|
@@ -55,3 +55,13 @@ browser.runtime.onInstalled.addListener(async () => {
|
|
|
55
55
|
isConnected = true
|
|
56
56
|
}
|
|
57
57
|
})
|
|
58
|
+
|
|
59
|
+
// Also initialize on browser startup for parity with Chromium behavior
|
|
60
|
+
browser.runtime.onStartup.addListener(async () => {
|
|
61
|
+
try {
|
|
62
|
+
await handleTabOnExtensionLoad()
|
|
63
|
+
} catch {}
|
|
64
|
+
try {
|
|
65
|
+
await connect()
|
|
66
|
+
} catch {}
|
|
67
|
+
})
|
|
@@ -15,7 +15,12 @@ export async function connect() {
|
|
|
15
15
|
const maxBackoffMs = 5000
|
|
16
16
|
|
|
17
17
|
const connectTo = (url) => {
|
|
18
|
-
|
|
18
|
+
try {
|
|
19
|
+
webSocket = new WebSocket(url)
|
|
20
|
+
} catch (err) {
|
|
21
|
+
webSocket = null
|
|
22
|
+
return
|
|
23
|
+
}
|
|
19
24
|
|
|
20
25
|
webSocket.onerror = (_event) => {
|
|
21
26
|
try {
|
|
@@ -36,12 +41,20 @@ export async function connect() {
|
|
|
36
41
|
|
|
37
42
|
let reloadDebounce
|
|
38
43
|
webSocket.onmessage = async (event) => {
|
|
39
|
-
|
|
44
|
+
let message = null
|
|
45
|
+
try {
|
|
46
|
+
message = JSON.parse(event.data)
|
|
47
|
+
} catch {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
40
50
|
|
|
41
51
|
if (message.status === 'serverReady') {
|
|
42
52
|
console.info(
|
|
43
53
|
`[Extension.js] Server ready. Requesting initial load data...`
|
|
44
54
|
)
|
|
55
|
+
try {
|
|
56
|
+
await requestInitialLoadData()
|
|
57
|
+
} catch {}
|
|
45
58
|
}
|
|
46
59
|
|
|
47
60
|
if (message.changedFile) {
|
package/dist/module.js
CHANGED
|
@@ -77,7 +77,7 @@ var __webpack_modules__ = {
|
|
|
77
77
|
const extensionId = instance.managerExtensionId;
|
|
78
78
|
const instanceId = instance.instanceId;
|
|
79
79
|
const extensionName = "Extension.js DevTools";
|
|
80
|
-
const extensionDescription = `Extension.js built-in developer tools for instance ${instanceId.slice(0, 8)}
|
|
80
|
+
const extensionDescription = `Extension.js built-in developer tools for instance ${instanceId.slice(0, 8)}.`;
|
|
81
81
|
const baseManifest = await this.readBaseManifest(instance.browser);
|
|
82
82
|
const baseServiceWorker = await this.readBaseServiceWorker(instance.browser);
|
|
83
83
|
const manifest = {
|
|
@@ -86,7 +86,7 @@ var __webpack_modules__ = {
|
|
|
86
86
|
description: extensionDescription,
|
|
87
87
|
key: this.generateExtensionKey()
|
|
88
88
|
};
|
|
89
|
-
const serviceWorkerContent = baseServiceWorker.replace(/const\s+port\s*=\s*['"]
|
|
89
|
+
const serviceWorkerContent = baseServiceWorker.replace(/const\s+port\s*=\s*['"][^'"]+['"]/, `const port = '${instance.webSocketPort}'`).replace(/const\s+instanceId\s*=\s*['"][^'"]+['"]/, `const instanceId = '${instance.instanceId}'`);
|
|
90
90
|
const enhancedServiceWorker = `// Instance: ${instanceId}\n// Generated: ${new Date().toISOString()}\n// Cache-buster: ${Date.now()}\n\n${serviceWorkerContent}\n\n// Instance-specific logging\n${'development' === process.env.EXTENSION_ENV ? `console.log('[Extension.js DevTools] Instance ${instanceId} initialized on port ${instance.webSocketPort}');` : ''}\n`;
|
|
91
91
|
const extensionPath = path__WEBPACK_IMPORTED_MODULE_2__.join(this.userExtensionsPath, `${instance.browser}-manager-${instance.port}`);
|
|
92
92
|
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.mkdir(extensionPath, {
|
|
@@ -1517,11 +1517,8 @@ var __webpack_modules__ = {
|
|
|
1517
1517
|
'--disable-renderer-backgrounding',
|
|
1518
1518
|
'--disable-backgrounding-occluded-windows',
|
|
1519
1519
|
'--disable-features=TranslateUI',
|
|
1520
|
-
'--disable-ipc-flooding-protection',
|
|
1521
1520
|
'--disable-hang-monitor',
|
|
1522
1521
|
'--disable-prompt-on-repost',
|
|
1523
|
-
'--disable-web-security',
|
|
1524
|
-
'--disable-features=VizDisplayCompositor',
|
|
1525
1522
|
'--memory-pressure-off',
|
|
1526
1523
|
'--max_old_space_size=4096',
|
|
1527
1524
|
'--disable-dev-shm-usage'
|
|
@@ -3171,7 +3168,7 @@ var __webpack_modules__ = {
|
|
|
3171
3168
|
function boring(manifestName, duration, stats) {
|
|
3172
3169
|
let didShow = false;
|
|
3173
3170
|
if (!didShow) {
|
|
3174
|
-
const arrow = stats.hasErrors() ? pintor__WEBPACK_IMPORTED_MODULE_1___default().red("\u25BA\u25BA\u25BA") : pintor__WEBPACK_IMPORTED_MODULE_1___default().
|
|
3171
|
+
const arrow = stats.hasErrors() ? pintor__WEBPACK_IMPORTED_MODULE_1___default().red("\u25BA\u25BA\u25BA") : pintor__WEBPACK_IMPORTED_MODULE_1___default().green("\u25BA\u25BA\u25BA");
|
|
3175
3172
|
return `${arrow} ${manifestName} compiled ${stats.hasErrors() ? pintor__WEBPACK_IMPORTED_MODULE_1___default().red('with errors') : pintor__WEBPACK_IMPORTED_MODULE_1___default().green('successfully')} in ${duration} ms.`;
|
|
3176
3173
|
}
|
|
3177
3174
|
}
|
|
@@ -3428,7 +3425,7 @@ var __webpack_modules__ = {
|
|
|
3428
3425
|
module.exports = require("util");
|
|
3429
3426
|
},
|
|
3430
3427
|
"./package.json": function(module) {
|
|
3431
|
-
module.exports = JSON.parse('{"i8":"2.1.
|
|
3428
|
+
module.exports = JSON.parse('{"i8":"2.1.2","HO":{"@rspack/core":"^1.4.8","@rspack/dev-server":"^1.1.3","@swc/helpers":"^0.5.15","@types/webextension-polyfill":"0.12.3","@vue/compiler-sfc":"^3.5.13","adm-zip":"^0.5.16","axios":"^1.9.0","case-sensitive-paths-webpack-plugin":"^2.4.0","chokidar":"^4.0.1","chrome-location2":"2.0.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^16.4.7","dotenv-webpack":"^8.1.0","edge-location":"^1.1.1","firefox-location2":"1.0.0","firefox-profile":"^4.7.0","go-git-it":"^5.0.0","ignore":"^6.0.2","loader-utils":"^3.3.1","locate-path":"^7.2.0","micromatch":"^4.0.8","package-manager-detector":"^0.2.7","parse5":"^7.2.1","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"^8.4.49","preact":"^10.22.0","progress":"^2.0.3","schema-utils":"^4.2.0","slugify":"^1.6.6","tiny-glob":"^0.2.9","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.18.0"},"Lq":{"@prefresh/core":"^1.5.2","@prefresh/utils":"^1.2.0","@prefresh/webpack":"^4.0.1","@rspack/plugin-preact-refresh":"^1.1.2","@rspack/plugin-react-refresh":"^1.0.1","babel-loader":"^9.2.1","less-loader":"^12.2.0","postcss-loader":"^8.1.1","postcss-preset-env":"^10.1.1","react-refresh":"^0.14.2","sass-loader":"^16.0.4","svelte-loader":"^3.2.4","vue-loader":"^17.4.2","vue-style-loader":"^4.1.3"}}');
|
|
3432
3429
|
}
|
|
3433
3430
|
};
|
|
3434
3431
|
var __webpack_module_cache__ = {};
|
|
@@ -3719,13 +3716,18 @@ var __webpack_exports__ = {};
|
|
|
3719
3716
|
const matchedKey = null == matched ? void 0 : matched[0];
|
|
3720
3717
|
if (matchedKey && 'string' == typeof matchedKey) {
|
|
3721
3718
|
const unixKey = unixify(matchedKey);
|
|
3722
|
-
fileOutputpath = /^(?:\.\/)?public\//i.test(unixKey) ? unixKey.replace(/^(?:\.\/)?public\//i, '') : /^\/public\//i.test(unixKey) ? unixKey.replace(/^\/public\//i, '') : external_path_.normalize(filePath);
|
|
3719
|
+
fileOutputpath = /^(?:\.\/)?public\//i.test(unixKey) ? unixKey.replace(/^(?:\.\/)?public\//i, '') : /^\/public\//i.test(unixKey) ? unixKey.replace(/^\/public\//i, '') : /^\//.test(unixKey) ? unixKey.replace(/^\//, '') : external_path_.normalize(filePath);
|
|
3723
3720
|
}
|
|
3724
3721
|
}
|
|
3725
3722
|
if (!skipPathResolve && excludeList) {
|
|
3726
3723
|
const keys = Object.keys(excludeList);
|
|
3727
3724
|
const unixInput = unixify(filePath);
|
|
3728
|
-
|
|
3725
|
+
let matchKey = keys.find((k)=>unixify(k) === unixInput);
|
|
3726
|
+
if (!matchKey) {
|
|
3727
|
+
const stripPublicPrefix = (p)=>unixify(p).replace(/^\/(?:public\/)?/i, '').replace(/^(?:\.\/)?public\//i, '');
|
|
3728
|
+
const inputStripped = stripPublicPrefix(unixInput);
|
|
3729
|
+
matchKey = keys.find((k)=>stripPublicPrefix(k) === inputStripped);
|
|
3730
|
+
}
|
|
3729
3731
|
if (matchKey) {
|
|
3730
3732
|
const unixKey = unixify(matchKey);
|
|
3731
3733
|
fileOutputpath = /^(?:\.\/)?public\//i.test(unixKey) ? unixKey.replace(/^(?:\.\/)?public\//i, '') : /^\/public\//i.test(unixKey) ? unixKey.replace(/^\/public\//i, '') : unixKey;
|
|
@@ -5822,7 +5824,7 @@ var __webpack_exports__ = {};
|
|
|
5822
5824
|
return getLoggingPrefix(WS, 'error') + ` Failed to update instance with extension ID.\n${external_pintor_default().red(error)}`;
|
|
5823
5825
|
}
|
|
5824
5826
|
function webSocketServerForInstanceClosed(instanceId) {
|
|
5825
|
-
return getLoggingPrefix(WS, 'success') + ` for instance ${external_pintor_default().
|
|
5827
|
+
return getLoggingPrefix(WS, 'success') + ` for instance ${external_pintor_default().yellow(instanceId.slice(0, 8))} closed`;
|
|
5826
5828
|
}
|
|
5827
5829
|
function webSocketError(error) {
|
|
5828
5830
|
return getLoggingPrefix(WS, 'error') + ` WebSocket error.\n${external_pintor_default().red(String(error))}`;
|
|
@@ -6440,8 +6442,9 @@ var __webpack_exports__ = {};
|
|
|
6440
6442
|
}
|
|
6441
6443
|
class AddAssetsToCompilation {
|
|
6442
6444
|
normalizePublicPath(assetPath) {
|
|
6443
|
-
if (
|
|
6444
|
-
|
|
6445
|
+
if (assetPath.startsWith('Public/')) return assetPath.replace(/^Public\//, 'public/');
|
|
6446
|
+
if (assetPath.startsWith('PUBLIC/')) return assetPath.replace(/^PUBLIC\//, 'public/');
|
|
6447
|
+
return assetPath;
|
|
6445
6448
|
}
|
|
6446
6449
|
apply(compiler) {
|
|
6447
6450
|
compiler.hooks.thisCompilation.tap('html:add-assets-to-compilation', (compilation)=>{
|
|
@@ -7046,13 +7049,13 @@ var __webpack_exports__ = {};
|
|
|
7046
7049
|
includeList: this.includeList || {},
|
|
7047
7050
|
excludeList: this.excludeList || {}
|
|
7048
7051
|
}).apply(compiler);
|
|
7049
|
-
|
|
7052
|
+
compiler.options.module.rules.push({
|
|
7050
7053
|
test: /(\.m?[jt]sx?)$/,
|
|
7051
7054
|
include: [
|
|
7052
7055
|
external_path_.dirname(this.manifestPath)
|
|
7053
7056
|
],
|
|
7054
7057
|
exclude: [
|
|
7055
|
-
/[
|
|
7058
|
+
/[/\\]node_modules[/\\]/
|
|
7056
7059
|
],
|
|
7057
7060
|
use: [
|
|
7058
7061
|
{
|
|
@@ -7072,7 +7075,7 @@ var __webpack_exports__ = {};
|
|
|
7072
7075
|
external_path_.dirname(this.manifestPath)
|
|
7073
7076
|
],
|
|
7074
7077
|
exclude: [
|
|
7075
|
-
/[
|
|
7078
|
+
/[/\\]node_modules[/\\]/
|
|
7076
7079
|
],
|
|
7077
7080
|
use: [
|
|
7078
7081
|
{
|
|
@@ -7099,7 +7102,7 @@ var __webpack_exports__ = {};
|
|
|
7099
7102
|
external_path_.dirname(this.manifestPath)
|
|
7100
7103
|
],
|
|
7101
7104
|
exclude: [
|
|
7102
|
-
/[
|
|
7105
|
+
/[/\\]node_modules[/\\]/
|
|
7103
7106
|
],
|
|
7104
7107
|
use: [
|
|
7105
7108
|
{
|
|
@@ -8037,7 +8040,7 @@ var __webpack_exports__ = {};
|
|
|
8037
8040
|
console.error(webSocketConnectionCloseError(error));
|
|
8038
8041
|
}
|
|
8039
8042
|
webSocketServer.close(()=>{
|
|
8040
|
-
console.log(webSocketServerForInstanceClosed(instanceId.slice(0, 8)));
|
|
8043
|
+
if ('development' === process.env.EXTENSION_ENV) console.log(webSocketServerForInstanceClosed(instanceId.slice(0, 8)));
|
|
8041
8044
|
});
|
|
8042
8045
|
};
|
|
8043
8046
|
process.on('SIGINT', cleanup);
|
|
@@ -9611,7 +9614,7 @@ var __webpack_exports__ = {};
|
|
|
9611
9614
|
var _devOptions_output, _devOptions_output1;
|
|
9612
9615
|
const { manifestPath, packageJsonPath } = projectStructure;
|
|
9613
9616
|
const manifestDir = external_path_.dirname(manifestPath);
|
|
9614
|
-
const packageJsonDir = external_path_.dirname(packageJsonPath);
|
|
9617
|
+
const packageJsonDir = packageJsonPath ? external_path_.dirname(packageJsonPath) : manifestDir;
|
|
9615
9618
|
const manifest = filterKeysForThisBrowser(JSON.parse(external_fs_.readFileSync(manifestPath, 'utf-8')), devOptions.browser);
|
|
9616
9619
|
const userExtensionOutputPath = devOptions.output.path;
|
|
9617
9620
|
const managerExtensionOutputPath = external_path_.join(manifestDir, 'dist', 'extension-js', 'extensions', `${devOptions.browser}-manager`);
|
|
@@ -9639,10 +9642,13 @@ var __webpack_exports__ = {};
|
|
|
9639
9642
|
}
|
|
9640
9643
|
},
|
|
9641
9644
|
resolve: {
|
|
9642
|
-
modules: [
|
|
9645
|
+
modules: packageJsonPath ? [
|
|
9643
9646
|
'node_modules',
|
|
9644
9647
|
external_path_.join(packageJsonDir, 'node_modules'),
|
|
9645
9648
|
external_path_.join(process.cwd(), 'node_modules')
|
|
9649
|
+
] : [
|
|
9650
|
+
'node_modules',
|
|
9651
|
+
external_path_.join(process.cwd(), 'node_modules')
|
|
9646
9652
|
],
|
|
9647
9653
|
extensions: [
|
|
9648
9654
|
'.js',
|
|
@@ -9768,9 +9774,6 @@ var __webpack_exports__ = {};
|
|
|
9768
9774
|
function manifestNotFoundError(manifestPath) {
|
|
9769
9775
|
return `${messages_getLoggingPrefix('error')} Manifest file not found.\n${external_pintor_default().red('Ensure the path to your extension exists and try again.')}\n${external_pintor_default().red('NOT FOUND')}\n${external_pintor_default().gray('PATH')} ${external_pintor_default().underline(manifestPath)}`;
|
|
9770
9776
|
}
|
|
9771
|
-
function packageJsonNotFoundError(manifestPath) {
|
|
9772
|
-
return `${messages_getLoggingPrefix('error')} No valid package.json found for manifest.\n${external_pintor_default().red('Ensure there is a valid package.json file in the project or its parent directories.')}\n${external_pintor_default().red('MANIFEST')}\n${external_pintor_default().gray('PATH')} ${external_pintor_default().underline(manifestPath)}`;
|
|
9773
|
-
}
|
|
9774
9777
|
function runningInProduction(outputPath) {
|
|
9775
9778
|
const manifestPath = external_path_.join(outputPath, 'manifest.json');
|
|
9776
9779
|
const manifest = JSON.parse(external_fs_.readFileSync(manifestPath, 'utf-8'));
|
|
@@ -9860,6 +9863,9 @@ var __webpack_exports__ = {};
|
|
|
9860
9863
|
function failedToDownloadOrExtractZIPFileError(error) {
|
|
9861
9864
|
return `${messages_getLoggingPrefix('error')} Failed to download or extract ZIP file.\n${external_pintor_default().red(error)}`;
|
|
9862
9865
|
}
|
|
9866
|
+
function invalidRemoteZip(url, contentType) {
|
|
9867
|
+
return `${messages_getLoggingPrefix('error')} Remote URL does not appear to be a ZIP archive.\n${external_pintor_default().gray('URL')} ${external_pintor_default().underline(url)}\n${external_pintor_default().gray('Content-Type')} ${external_pintor_default().underline(contentType || 'unknown')}`;
|
|
9868
|
+
}
|
|
9863
9869
|
function capitalizedBrowserName(browser) {
|
|
9864
9870
|
const b = String(browser || '');
|
|
9865
9871
|
const cap = b.charAt(0).toUpperCase() + b.slice(1);
|
|
@@ -9908,7 +9914,7 @@ var __webpack_exports__ = {};
|
|
|
9908
9914
|
return `.\n${printTree(assetTree)}`;
|
|
9909
9915
|
}
|
|
9910
9916
|
function isUsingExperimentalConfig(integration) {
|
|
9911
|
-
return `${messages_getLoggingPrefix('info')} Using ${integration}.`;
|
|
9917
|
+
return `${messages_getLoggingPrefix('info')} Using ${external_pintor_default().yellow(integration)}.`;
|
|
9912
9918
|
}
|
|
9913
9919
|
function installingDependencies() {
|
|
9914
9920
|
return `${messages_getLoggingPrefix('info')} Installing project dependencies...`;
|
|
@@ -9937,10 +9943,16 @@ var __webpack_exports__ = {};
|
|
|
9937
9943
|
async function downloadAndExtractZip(url, targetPath) {
|
|
9938
9944
|
const urlNoSearchParams = url.split('?')[0];
|
|
9939
9945
|
try {
|
|
9946
|
+
var _response_headers;
|
|
9940
9947
|
console.log(downloadingText(urlNoSearchParams));
|
|
9941
9948
|
const response = await external_axios_default().get(url, {
|
|
9942
|
-
responseType: 'stream'
|
|
9949
|
+
responseType: 'stream',
|
|
9950
|
+
maxRedirects: 5
|
|
9943
9951
|
});
|
|
9952
|
+
const contentType = String((null == (_response_headers = response.headers) ? void 0 : _response_headers['content-type']) || '');
|
|
9953
|
+
const isZipExt = '.zip' === external_path_.extname(urlNoSearchParams).toLowerCase();
|
|
9954
|
+
const isZipType = /zip|octet-stream/i.test(contentType);
|
|
9955
|
+
if (!isZipExt && !isZipType) throw new Error(`${invalidRemoteZip(urlNoSearchParams, contentType)}`);
|
|
9944
9956
|
const extname = external_path_.extname(urlNoSearchParams);
|
|
9945
9957
|
const basename = external_path_.basename(urlNoSearchParams, extname);
|
|
9946
9958
|
const destinationPath = external_path_.join(targetPath, basename);
|
|
@@ -10007,15 +10019,22 @@ var __webpack_exports__ = {};
|
|
|
10007
10019
|
}
|
|
10008
10020
|
};
|
|
10009
10021
|
async function importUrlSourceFromGithub(pathOrRemoteUrl, text) {
|
|
10010
|
-
|
|
10022
|
+
const tempRoot = external_fs_.mkdtempSync(external_path_.join(external_os_.tmpdir(), 'extension-js-'));
|
|
10023
|
+
await external_go_git_it_default()(pathOrRemoteUrl, tempRoot, text);
|
|
10011
10024
|
const url = new URL(pathOrRemoteUrl);
|
|
10012
|
-
const
|
|
10013
|
-
const repoName =
|
|
10014
|
-
|
|
10025
|
+
const segments = url.pathname.split('/').filter(Boolean);
|
|
10026
|
+
const repoName = segments.length >= 2 ? segments[1] : segments[segments.length - 1];
|
|
10027
|
+
const candidates = external_fs_.readdirSync(tempRoot, {
|
|
10028
|
+
withFileTypes: true
|
|
10029
|
+
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
10030
|
+
const chosen = candidates.includes(repoName) ? repoName : candidates[0];
|
|
10031
|
+
const resolved = chosen ? external_path_.resolve(tempRoot, chosen) : tempRoot;
|
|
10032
|
+
return resolved;
|
|
10015
10033
|
}
|
|
10016
10034
|
async function importUrlSourceFromZip(pathOrRemoteUrl) {
|
|
10017
|
-
const
|
|
10018
|
-
|
|
10035
|
+
const tempRoot = external_fs_.mkdtempSync(external_path_.join(external_os_.tmpdir(), 'extension-js-'));
|
|
10036
|
+
const extractedPath = await downloadAndExtractZip(pathOrRemoteUrl, tempRoot);
|
|
10037
|
+
return extractedPath;
|
|
10019
10038
|
}
|
|
10020
10039
|
async function getProjectPath(pathOrRemoteUrl) {
|
|
10021
10040
|
if (!pathOrRemoteUrl) return process.cwd();
|
|
@@ -10060,7 +10079,9 @@ var __webpack_exports__ = {};
|
|
|
10060
10079
|
else throw new Error(manifestNotFoundError(manifestPath));
|
|
10061
10080
|
}
|
|
10062
10081
|
const packageJsonPath = await findNearestPackageJson(manifestPath);
|
|
10063
|
-
if (!packageJsonPath || !validatePackageJson(packageJsonPath))
|
|
10082
|
+
if (!packageJsonPath || !validatePackageJson(packageJsonPath)) return {
|
|
10083
|
+
manifestPath
|
|
10084
|
+
};
|
|
10064
10085
|
return {
|
|
10065
10086
|
manifestPath,
|
|
10066
10087
|
packageJsonPath
|
|
@@ -10314,7 +10335,7 @@ var __webpack_exports__ = {};
|
|
|
10314
10335
|
const configPath = candidates.find((p)=>external_fs_.existsSync(p));
|
|
10315
10336
|
if (configPath) {
|
|
10316
10337
|
if (!get_extension_config_userMessageDelivered) {
|
|
10317
|
-
console.log(isUsingExperimentalConfig('extension.config.js'));
|
|
10338
|
+
if ('development' === process.env.EXTENSION_ENV) console.log(isUsingExperimentalConfig('extension.config.js'));
|
|
10318
10339
|
get_extension_config_userMessageDelivered = true;
|
|
10319
10340
|
}
|
|
10320
10341
|
return true;
|
|
@@ -10408,8 +10429,8 @@ var __webpack_exports__ = {};
|
|
|
10408
10429
|
var _baseConfig_plugins;
|
|
10409
10430
|
const browser = (null == buildOptions ? void 0 : buildOptions.browser) || 'chrome';
|
|
10410
10431
|
const manifestDir = external_path_.dirname(projectStructure.manifestPath);
|
|
10411
|
-
const packageJsonDir = external_path_.dirname(projectStructure.packageJsonPath);
|
|
10412
|
-
assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, external_path_.dirname(projectStructure.manifestPath));
|
|
10432
|
+
const packageJsonDir = projectStructure.packageJsonPath ? external_path_.dirname(projectStructure.packageJsonPath) : manifestDir;
|
|
10433
|
+
if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, external_path_.dirname(projectStructure.manifestPath));
|
|
10413
10434
|
const baseConfig = webpackConfig(projectStructure, {
|
|
10414
10435
|
...buildOptions,
|
|
10415
10436
|
browser,
|
|
@@ -10431,10 +10452,12 @@ var __webpack_exports__ = {};
|
|
|
10431
10452
|
});
|
|
10432
10453
|
const compilerConfig = (0, external_webpack_merge_namespaceObject.merge)(userConfig);
|
|
10433
10454
|
const compiler = (0, core_namespaceObject.rspack)(compilerConfig);
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
|
|
10437
|
-
|
|
10455
|
+
if (projectStructure.packageJsonPath) {
|
|
10456
|
+
const nodeModulesPath = external_path_.join(packageJsonDir, 'node_modules');
|
|
10457
|
+
if (!external_fs_.existsSync(nodeModulesPath)) {
|
|
10458
|
+
console.log(installingDependencies());
|
|
10459
|
+
if ('true' !== process.env.VITEST) await installDependencies(packageJsonDir);
|
|
10460
|
+
}
|
|
10438
10461
|
}
|
|
10439
10462
|
await new Promise((resolve, reject)=>{
|
|
10440
10463
|
compiler.run(async (err, stats)=>{
|
|
@@ -10451,6 +10474,7 @@ var __webpack_exports__ = {};
|
|
|
10451
10474
|
console.log(stats.toString({
|
|
10452
10475
|
colors: true
|
|
10453
10476
|
}));
|
|
10477
|
+
if ((null == buildOptions ? void 0 : buildOptions.exitOnError) === false) return reject(new Error('Build failed with errors'));
|
|
10454
10478
|
process.exit(1);
|
|
10455
10479
|
} else {
|
|
10456
10480
|
console.log(buildSuccess());
|
|
@@ -10460,6 +10484,7 @@ var __webpack_exports__ = {};
|
|
|
10460
10484
|
});
|
|
10461
10485
|
} catch (error) {
|
|
10462
10486
|
if ('development' === process.env.EXTENSION_ENV) console.error(error);
|
|
10487
|
+
if ((null == buildOptions ? void 0 : buildOptions.exitOnError) === false) throw error;
|
|
10463
10488
|
process.exit(1);
|
|
10464
10489
|
}
|
|
10465
10490
|
}
|
|
@@ -10586,7 +10611,7 @@ var __webpack_exports__ = {};
|
|
|
10586
10611
|
var _process_removeAllListeners, _process, _process_removeAllListeners1, _process1, _process_removeAllListeners2, _process2, _process_removeAllListeners3, _process3;
|
|
10587
10612
|
const { manifestPath, packageJsonPath } = projectStructure;
|
|
10588
10613
|
const manifestDir = external_path_.dirname(manifestPath);
|
|
10589
|
-
const packageJsonDir = external_path_.dirname(packageJsonPath);
|
|
10614
|
+
const packageJsonDir = packageJsonPath ? external_path_.dirname(packageJsonPath) : manifestDir;
|
|
10590
10615
|
const commandConfig = await loadCommandConfig(manifestDir, 'dev');
|
|
10591
10616
|
const browserConfig = await loadBrowserConfig(manifestDir, devOptions.browser);
|
|
10592
10617
|
const portManager = new PortManager(devOptions.browser, packageJsonDir, 8080);
|
|
@@ -10640,11 +10665,7 @@ var __webpack_exports__ = {};
|
|
|
10640
10665
|
interval: 1000
|
|
10641
10666
|
}
|
|
10642
10667
|
},
|
|
10643
|
-
client:
|
|
10644
|
-
logging: 'none',
|
|
10645
|
-
progress: false,
|
|
10646
|
-
overlay: false
|
|
10647
|
-
},
|
|
10668
|
+
client: false,
|
|
10648
10669
|
headers: {
|
|
10649
10670
|
'Access-Control-Allow-Origin': '*'
|
|
10650
10671
|
},
|
|
@@ -10731,13 +10752,15 @@ var __webpack_exports__ = {};
|
|
|
10731
10752
|
const projectStructure = await getProjectStructure(pathOrRemoteUrl);
|
|
10732
10753
|
try {
|
|
10733
10754
|
const manifestDir = external_path_.dirname(projectStructure.manifestPath);
|
|
10734
|
-
const packageJsonDir = external_path_.dirname(projectStructure.packageJsonPath);
|
|
10755
|
+
const packageJsonDir = projectStructure.packageJsonPath ? external_path_.dirname(projectStructure.packageJsonPath) : manifestDir;
|
|
10735
10756
|
if (isUsingTypeScript(manifestDir)) await generateExtensionTypes(manifestDir);
|
|
10736
|
-
assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, external_path_.dirname(projectStructure.manifestPath));
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10757
|
+
if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, external_path_.dirname(projectStructure.manifestPath));
|
|
10758
|
+
if (projectStructure.packageJsonPath) {
|
|
10759
|
+
const nodeModulesPath = external_path_.join(packageJsonDir, 'node_modules');
|
|
10760
|
+
if (!external_fs_.existsSync(nodeModulesPath)) {
|
|
10761
|
+
console.log(installingDependencies());
|
|
10762
|
+
await installDependencies(packageJsonDir);
|
|
10763
|
+
}
|
|
10741
10764
|
}
|
|
10742
10765
|
await dev_server_devServer(projectStructure, {
|
|
10743
10766
|
...devOptions,
|
|
@@ -10751,7 +10774,7 @@ var __webpack_exports__ = {};
|
|
|
10751
10774
|
}
|
|
10752
10775
|
async function extensionPreview(pathOrRemoteUrl, previewOptions) {
|
|
10753
10776
|
const projectStructure = await getProjectStructure(pathOrRemoteUrl);
|
|
10754
|
-
assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, external_path_.dirname(projectStructure.manifestPath));
|
|
10777
|
+
if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, external_path_.dirname(projectStructure.manifestPath));
|
|
10755
10778
|
const manifestDir = external_path_.dirname(projectStructure.manifestPath);
|
|
10756
10779
|
const distPath = external_path_.join(manifestDir, 'dist', previewOptions.browser);
|
|
10757
10780
|
const outputPath = previewOptions.outputPath ? previewOptions.outputPath : external_fs_.existsSync(distPath) ? distPath : manifestDir;
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"name": "extension-develop",
|
|
24
|
-
"version": "2.1.
|
|
24
|
+
"version": "2.1.2",
|
|
25
25
|
"description": "The develop step of Extension.js",
|
|
26
26
|
"author": {
|
|
27
27
|
"name": "Cezar Augusto",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public",
|
|
33
|
-
"registry": "https://registry.npmjs.org"
|
|
33
|
+
"registry": "https://registry.npmjs.org",
|
|
34
|
+
"tag": "latest"
|
|
34
35
|
},
|
|
35
36
|
"keywords": [
|
|
36
37
|
"webextension",
|