extension-develop 2.0.0-alpha.9 → 2.0.0-beta.0
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/ensure-hmr-for-scripts.js +2 -2
- package/dist/extensions/chrome-manager-extension/manifest.json +3 -3
- package/dist/extensions/{chromium-manager-extension → chromium-based-manager-extension}/manifest.json +3 -3
- package/dist/extensions/chromium-based-manager-extension/pages/welcome.html +49 -0
- package/dist/extensions/edge-manager-extension/manifest.json +3 -3
- package/dist/extensions/edge-manager-extension/pages/welcome.html +1 -1
- package/dist/extensions/firefox-manager-extension/manifest.json +3 -3
- package/dist/extensions/firefox-manager-extension/pages/welcome.html +1 -1
- package/dist/extensions/gecko-based-manager-extension/background.js +57 -0
- package/dist/extensions/gecko-based-manager-extension/define-initial-tab.js +62 -0
- package/dist/extensions/gecko-based-manager-extension/images/logo.png +0 -0
- package/dist/extensions/gecko-based-manager-extension/manifest.json +16 -0
- package/dist/extensions/gecko-based-manager-extension/pages/sakura-dark.css +268 -0
- package/dist/extensions/gecko-based-manager-extension/pages/sakura.css +267 -0
- package/dist/extensions/{chromium-manager-extension → gecko-based-manager-extension}/pages/welcome.html +1 -1
- package/dist/extensions/gecko-based-manager-extension/pages/welcome.js +34 -0
- package/dist/extensions/gecko-based-manager-extension/reload-service.js +130 -0
- package/dist/inject-chromium-client-loader.js +2 -2
- package/dist/inject-content-css-during-dev.js +3 -3
- package/dist/inject-firefox-client-loader.js +9 -2
- package/dist/module.d.ts +33 -6
- package/dist/module.js +99 -111
- package/dist/resolver-loader.js +1 -1
- package/dist/resolver-module.mjs +1 -0
- package/package.json +21 -25
- package/dist/add-query-param-to-imported-css.js +0 -1
- package/dist/resolver-module.js +0 -1
- /package/dist/extensions/chrome-manager-extension/{public → images}/logo.png +0 -0
- /package/dist/extensions/{chromium-manager-extension → chromium-based-manager-extension}/background.js +0 -0
- /package/dist/extensions/{chromium-manager-extension → chromium-based-manager-extension}/define-initial-tab.js +0 -0
- /package/dist/extensions/{chromium-manager-extension/public → chromium-based-manager-extension/images}/logo.png +0 -0
- /package/dist/extensions/{chromium-manager-extension → chromium-based-manager-extension}/pages/sakura-dark.css +0 -0
- /package/dist/extensions/{chromium-manager-extension → chromium-based-manager-extension}/pages/sakura.css +0 -0
- /package/dist/extensions/{chromium-manager-extension → chromium-based-manager-extension}/pages/welcome.js +0 -0
- /package/dist/extensions/{chromium-manager-extension → chromium-based-manager-extension}/reload-service.js +0 -0
- /package/dist/extensions/edge-manager-extension/{public → images}/logo.png +0 -0
- /package/dist/extensions/firefox-manager-extension/{public → images}/logo.png +0 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/* Sakura.css v1.5.0
|
|
2
|
+
* ================
|
|
3
|
+
* Minimal css theme.
|
|
4
|
+
* Project: https://github.com/oxalorg/sakura/
|
|
5
|
+
*/
|
|
6
|
+
/* Body */
|
|
7
|
+
html {
|
|
8
|
+
font-size: 62.5%;
|
|
9
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
|
10
|
+
'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
body {
|
|
14
|
+
font-size: 1.8rem;
|
|
15
|
+
line-height: 1.618;
|
|
16
|
+
max-width: 38em;
|
|
17
|
+
margin: auto;
|
|
18
|
+
color: #4a4a4a;
|
|
19
|
+
background-color: #f9f9f9;
|
|
20
|
+
padding: 13px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@media (max-width: 684px) {
|
|
24
|
+
body {
|
|
25
|
+
font-size: 1.53rem;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
@media (max-width: 382px) {
|
|
29
|
+
body {
|
|
30
|
+
font-size: 1.35rem;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
h1,
|
|
34
|
+
h2,
|
|
35
|
+
h3,
|
|
36
|
+
h4,
|
|
37
|
+
h5,
|
|
38
|
+
h6 {
|
|
39
|
+
line-height: 1.1;
|
|
40
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
|
41
|
+
'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
|
|
42
|
+
font-weight: 700;
|
|
43
|
+
margin-top: 3rem;
|
|
44
|
+
margin-bottom: 1.5rem;
|
|
45
|
+
overflow-wrap: break-word;
|
|
46
|
+
word-wrap: break-word;
|
|
47
|
+
-ms-word-break: break-all;
|
|
48
|
+
word-break: break-word;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
h1 {
|
|
52
|
+
font-size: 2.35em;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
h2 {
|
|
56
|
+
font-size: 2em;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
h3 {
|
|
60
|
+
font-size: 1.75em;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
h4 {
|
|
64
|
+
font-size: 1.5em;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
h5 {
|
|
68
|
+
font-size: 1.25em;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
h6 {
|
|
72
|
+
font-size: 1em;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
p {
|
|
76
|
+
margin-top: 0px;
|
|
77
|
+
margin-bottom: 2.5rem;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
small,
|
|
81
|
+
sub,
|
|
82
|
+
sup {
|
|
83
|
+
font-size: 75%;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
hr {
|
|
87
|
+
border-color: #1d7484;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
a {
|
|
91
|
+
text-decoration: none;
|
|
92
|
+
color: #1d7484;
|
|
93
|
+
}
|
|
94
|
+
a:visited {
|
|
95
|
+
color: #144f5a;
|
|
96
|
+
}
|
|
97
|
+
a:hover {
|
|
98
|
+
color: #982c61;
|
|
99
|
+
border-bottom: 2px solid #4a4a4a;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
ul {
|
|
103
|
+
padding-left: 1.4em;
|
|
104
|
+
margin-top: 0px;
|
|
105
|
+
margin-bottom: 2.5rem;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
li {
|
|
109
|
+
margin-bottom: 0.4em;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
blockquote {
|
|
113
|
+
margin-left: 0px;
|
|
114
|
+
margin-right: 0px;
|
|
115
|
+
padding-left: 1em;
|
|
116
|
+
padding-top: 0.8em;
|
|
117
|
+
padding-bottom: 0.8em;
|
|
118
|
+
padding-right: 0.8em;
|
|
119
|
+
border-left: 5px solid #1d7484;
|
|
120
|
+
margin-bottom: 2.5rem;
|
|
121
|
+
background-color: #f1f1f1;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
blockquote p {
|
|
125
|
+
margin-bottom: 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
img,
|
|
129
|
+
video {
|
|
130
|
+
height: auto;
|
|
131
|
+
max-width: 100%;
|
|
132
|
+
margin-top: 0px;
|
|
133
|
+
margin-bottom: 2.5rem;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Pre and Code */
|
|
137
|
+
pre {
|
|
138
|
+
background-color: #f1f1f1;
|
|
139
|
+
display: block;
|
|
140
|
+
padding: 1em;
|
|
141
|
+
overflow-x: auto;
|
|
142
|
+
margin-top: 0px;
|
|
143
|
+
margin-bottom: 2.5rem;
|
|
144
|
+
font-size: 0.9em;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
code,
|
|
148
|
+
kbd,
|
|
149
|
+
samp {
|
|
150
|
+
font-size: 0.9em;
|
|
151
|
+
padding: 0 0.5em;
|
|
152
|
+
background-color: #f1f1f1;
|
|
153
|
+
white-space: pre-wrap;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
pre > code {
|
|
157
|
+
padding: 0;
|
|
158
|
+
background-color: transparent;
|
|
159
|
+
white-space: pre;
|
|
160
|
+
font-size: 1em;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Tables */
|
|
164
|
+
table {
|
|
165
|
+
text-align: justify;
|
|
166
|
+
width: 100%;
|
|
167
|
+
border-collapse: collapse;
|
|
168
|
+
margin-bottom: 2rem;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
td,
|
|
172
|
+
th {
|
|
173
|
+
padding: 0.5em;
|
|
174
|
+
border-bottom: 1px solid #f1f1f1;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* Buttons, forms and input */
|
|
178
|
+
input,
|
|
179
|
+
textarea {
|
|
180
|
+
border: 1px solid #4a4a4a;
|
|
181
|
+
}
|
|
182
|
+
input:focus,
|
|
183
|
+
textarea:focus {
|
|
184
|
+
border: 1px solid #1d7484;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
textarea {
|
|
188
|
+
width: 100%;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.button,
|
|
192
|
+
button,
|
|
193
|
+
input[type='submit'],
|
|
194
|
+
input[type='reset'],
|
|
195
|
+
input[type='button'],
|
|
196
|
+
input[type='file']::file-selector-button {
|
|
197
|
+
display: inline-block;
|
|
198
|
+
padding: 5px 10px;
|
|
199
|
+
text-align: center;
|
|
200
|
+
text-decoration: none;
|
|
201
|
+
white-space: nowrap;
|
|
202
|
+
background-color: #1d7484;
|
|
203
|
+
color: #f9f9f9;
|
|
204
|
+
border-radius: 1px;
|
|
205
|
+
border: 1px solid #1d7484;
|
|
206
|
+
cursor: pointer;
|
|
207
|
+
box-sizing: border-box;
|
|
208
|
+
}
|
|
209
|
+
.button[disabled],
|
|
210
|
+
button[disabled],
|
|
211
|
+
input[type='submit'][disabled],
|
|
212
|
+
input[type='reset'][disabled],
|
|
213
|
+
input[type='button'][disabled],
|
|
214
|
+
input[type='file']::file-selector-button[disabled] {
|
|
215
|
+
cursor: default;
|
|
216
|
+
opacity: 0.5;
|
|
217
|
+
}
|
|
218
|
+
.button:hover,
|
|
219
|
+
button:hover,
|
|
220
|
+
input[type='submit']:hover,
|
|
221
|
+
input[type='reset']:hover,
|
|
222
|
+
input[type='button']:hover,
|
|
223
|
+
input[type='file']::file-selector-button:hover {
|
|
224
|
+
background-color: #982c61;
|
|
225
|
+
color: #f9f9f9;
|
|
226
|
+
outline: 0;
|
|
227
|
+
}
|
|
228
|
+
.button:focus-visible,
|
|
229
|
+
button:focus-visible,
|
|
230
|
+
input[type='submit']:focus-visible,
|
|
231
|
+
input[type='reset']:focus-visible,
|
|
232
|
+
input[type='button']:focus-visible,
|
|
233
|
+
input[type='file']::file-selector-button:focus-visible {
|
|
234
|
+
outline-style: solid;
|
|
235
|
+
outline-width: 2px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
textarea,
|
|
239
|
+
select,
|
|
240
|
+
input {
|
|
241
|
+
color: #4a4a4a;
|
|
242
|
+
padding: 6px 10px; /* The 6px vertically centers text on FF, ignored by Webkit */
|
|
243
|
+
margin-bottom: 10px;
|
|
244
|
+
background-color: #f1f1f1;
|
|
245
|
+
border: 1px solid #f1f1f1;
|
|
246
|
+
border-radius: 4px;
|
|
247
|
+
box-shadow: none;
|
|
248
|
+
box-sizing: border-box;
|
|
249
|
+
}
|
|
250
|
+
textarea:focus,
|
|
251
|
+
select:focus,
|
|
252
|
+
input:focus {
|
|
253
|
+
border: 1px solid #1d7484;
|
|
254
|
+
outline: 0;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
input[type='checkbox']:focus {
|
|
258
|
+
outline: 1px dotted #1d7484;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
label,
|
|
262
|
+
legend,
|
|
263
|
+
fieldset {
|
|
264
|
+
display: block;
|
|
265
|
+
margin-bottom: 0.5rem;
|
|
266
|
+
font-weight: 600;
|
|
267
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
async function getUserAddon() {
|
|
2
|
+
const allAddons = await browser.management.getAll()
|
|
3
|
+
|
|
4
|
+
return allAddons.filter((extension) => {
|
|
5
|
+
return (
|
|
6
|
+
// Do not include itself
|
|
7
|
+
extension.id !== browser.runtime.id &&
|
|
8
|
+
// Reload extension
|
|
9
|
+
extension.id !== 'reload@extension-js' &&
|
|
10
|
+
// Show only unpackaged extensions
|
|
11
|
+
extension.installType === 'development'
|
|
12
|
+
)
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function onStartup() {
|
|
17
|
+
const userExtension = await getUserAddon()
|
|
18
|
+
const extensionName = document.getElementById('extensionName')
|
|
19
|
+
const extensionDescription = document.getElementById('extensionDescription')
|
|
20
|
+
|
|
21
|
+
extensionName.innerText = userExtension[0].name
|
|
22
|
+
extensionName.title = `• Name: ${userExtension[0].name}
|
|
23
|
+
• ID: ${userExtension[0].id}
|
|
24
|
+
• Version: ${userExtension[0].version}`
|
|
25
|
+
|
|
26
|
+
extensionDescription.innerText = userExtension[0].description
|
|
27
|
+
|
|
28
|
+
const learnMore = document.getElementById('learnMore')
|
|
29
|
+
learnMore.addEventListener('click', () => {
|
|
30
|
+
browser.tabs.create({url: 'https://extension.js.org/'})
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
onStartup().catch(console.error)
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
let webSocket = null
|
|
2
|
+
|
|
3
|
+
export async function connect() {
|
|
4
|
+
if (webSocket) {
|
|
5
|
+
// If already connected, do nothing
|
|
6
|
+
return
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
webSocket = new WebSocket('wss://127.0.0.1:8002')
|
|
10
|
+
|
|
11
|
+
webSocket.onerror = (event) => {
|
|
12
|
+
console.error(`[Reload Service] Connection error: ${JSON.stringify(event)}`)
|
|
13
|
+
webSocket.close()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
webSocket.onopen = () => {
|
|
17
|
+
console.info(`[Reload Service] Connection opened.`)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
webSocket.onmessage = async (event) => {
|
|
21
|
+
const message = JSON.parse(event.data)
|
|
22
|
+
|
|
23
|
+
if (message.status === 'serverReady') {
|
|
24
|
+
console.info('[Reload Service] Connection ready.')
|
|
25
|
+
await requestInitialLoadData()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (message.changedFile) {
|
|
29
|
+
console.info(
|
|
30
|
+
`[Reload Service] Changes detected on ${message.changedFile}. Reloading extension...`
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
await messageAllExtensions(message.changedFile)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
webSocket.onclose = () => {
|
|
38
|
+
console.info('[Reload Service] Connection closed.')
|
|
39
|
+
webSocket = null
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function disconnect() {
|
|
44
|
+
if (webSocket) {
|
|
45
|
+
webSocket.close()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function getDevExtensions() {
|
|
50
|
+
const allExtensions = await browser.management.getAll()
|
|
51
|
+
|
|
52
|
+
return allExtensions.filter((extension) => {
|
|
53
|
+
return (
|
|
54
|
+
// Do not include itself
|
|
55
|
+
extension.id !== browser.runtime.id &&
|
|
56
|
+
// Manager extension
|
|
57
|
+
extension.name !== 'Add-On Manager' &&
|
|
58
|
+
// Show only unpackaged extensions
|
|
59
|
+
extension.installType === 'development'
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function messageAllExtensions(changedFile) {
|
|
65
|
+
// Check if the external extension is ready
|
|
66
|
+
const isExtensionReady = await checkExtensionReadiness()
|
|
67
|
+
|
|
68
|
+
if (isExtensionReady) {
|
|
69
|
+
const devExtensions = await getDevExtensions()
|
|
70
|
+
for (const extension of devExtensions) {
|
|
71
|
+
try {
|
|
72
|
+
await browser.runtime.sendMessage(extension.id, {changedFile})
|
|
73
|
+
console.info('[Reload Service] Add-On reloaded and ready.')
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error(
|
|
76
|
+
`Error sending message to ${extension.id}: ${error.message}`
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
console.info('[Reload Service] External extension is not ready.')
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function requestInitialLoadData() {
|
|
86
|
+
const devExtensions = await getDevExtensions()
|
|
87
|
+
|
|
88
|
+
const responses = await Promise.all(
|
|
89
|
+
devExtensions.map(async (extension) => {
|
|
90
|
+
try {
|
|
91
|
+
const result = await browser.runtime.sendMessage(extension.id, {
|
|
92
|
+
initialLoadData: true
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
return result
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error(
|
|
98
|
+
`Error sending message to ${extension.id}: ${error.message}`
|
|
99
|
+
)
|
|
100
|
+
return null
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
// We received the info from the use extension.
|
|
106
|
+
// All good, client is ready. Inform the server.
|
|
107
|
+
if (webSocket && webSocket.readyState === WebSocket.OPEN) {
|
|
108
|
+
const message = JSON.stringify({
|
|
109
|
+
status: 'clientReady',
|
|
110
|
+
data: responses.find((response) => response !== null)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
webSocket.send(message)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function checkExtensionReadiness() {
|
|
118
|
+
// Delay for 1 second
|
|
119
|
+
await delay(1000)
|
|
120
|
+
// Assume the extension is ready
|
|
121
|
+
return true
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function delay(ms) {
|
|
125
|
+
return await new Promise((resolve) => setTimeout(resolve, ms)).catch(
|
|
126
|
+
(error) => {
|
|
127
|
+
console.error(`Error delaying: ${error.message}`)
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var w=Object.create;var u=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var T=(e,n)=>{for(var t in n)u(e,t,{get:n[t],enumerable:!0})},x=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of M(n))!O.call(e,r)&&r!==t&&u(e,r,{get:()=>n[r],enumerable:!(i=j(n,r))||i.enumerable});return e};var c=(e,n,t)=>(t=e!=null?w(N(e)):{},x(n||!e||!e.__esModule?u(t,"default",{value:e,enumerable:!0}):t,e)),S=e=>x(u({},"__esModule",{value:!0}),e);var H={};T(H,{default:()=>W});module.exports=S(H);var p=c(require("path")),b=require("loader-utils"),E=require("schema-utils");var C=c(require("path")),P=c(require("fs")),U=require("child_process"),A=require("package-manager-detector");var _=c(require("path")),o=require("@colors/colors/safe");var y=c(require("path")),k=y.default.join(process.cwd(),"node_modules/extension-develop/dist/certs"),m=["chrome","edge"],R=["firefox"],z=[...m,...R];var D=require("console");function v(e,n){return JSON.parse(JSON.stringify(e),function(r,l){let s=r.indexOf(":");if(s===-1)return l;let a=r.substring(0,s);(a===n||a==="chromium"&&m.includes(n))&&(this[r.substring(s+1)]=l)})}var q={type:"object",properties:{test:{type:"string"},manifestPath:{type:"string"}}};function W(e){let n=this.getOptions(),t=n.manifestPath,i=n.browser,r=p.default.dirname(t),l=require(t),s=v(l,i);(0,E.validate)(q,n,{name:"reload:inject-background-client",baseDataPath:"options"});let a=(0,b.urlToRequest)(this.resourcePath),g=`
|
|
2
2
|
;chrome.runtime.onMessageExternal.addListener(
|
|
3
3
|
async (request, _sender, sendResponse) => {
|
|
4
4
|
const managementInfo = await new Promise((resolve) => {
|
|
@@ -49,4 +49,4 @@
|
|
|
49
49
|
return true
|
|
50
50
|
}
|
|
51
51
|
);
|
|
52
|
-
`,
|
|
52
|
+
`,f=s.background;if(f){let h=f?.scripts;if(h&&s.manifest_version===2)for(let d of[h[0]]){let F=p.default.resolve(r,d);if(a.includes(F))return`${g}${e}`}let $=f?.service_worker;if($&&s.manifest_version===3){let d=p.default.resolve(r,$);if(a.includes(d))return`${g}${e}`}}return e}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var k=Object.create;var m=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var L=(e,n)=>{for(var r in n)m(e,r,{get:n[r],enumerable:!0})},y=(e,n,r,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of D(n))!C.call(e,t)&&t!==r&&m(e,t,{get:()=>n[t],enumerable:!(i=I(n,t))||i.enumerable});return e};var a=(e,n,r)=>(r=e!=null?k(R(e)):{},y(n||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e)),A=e=>y(m({},"__esModule",{value:!0}),e);var X={};L(X,{default:()=>T});module.exports=A(X);var x=a(require("path")),S=require("loader-utils"),M=require("schema-utils");var g=a(require("path")),z=a(require("fs")),B=require("child_process"),J=require("package-manager-detector");var W=a(require("path")),o=require("@colors/colors/safe");var v=a(require("path")),U=v.default.join(process.cwd(),"node_modules/extension-develop/dist/certs"),b=["chrome","edge"],P=["firefox"],Z=[...b,...P];var H=require("console");function E(e){return e.replace(/\\/g,"/")}function h(e,n={}){if(!n)return!1;let r=g.default.normalize(E(e));return Object.values(n).some(t=>typeof t!="string"?!1:E(t).includes(r))}function F(e,n){let r=g.default.relative(g.default.dirname(e),n);return!r.startsWith(".")&&!r.startsWith("..")&&(r="./"+r),r}var $=a(require("fs")),j=a(require("path"));function w(e,n){return(Array.isArray(e)?e||[]:e?[e]:[]).filter(t=>{let l=$.default.existsSync(t)&&!h(t,n),s=j.default.extname(t);return l&&(s===".js"||s===".mjs"||s===".jsx"||s===".ts"||s===".tsx")})}function N(e,n){return(Array.isArray(e)?e||[]:e?[e]:[]).filter(t=>$.default.existsSync(t)&&!h(t,n)&&(t.endsWith(".css")||t.endsWith(".scss")||t.endsWith(".sass")||t.endsWith(".less")))}var G={type:"object",properties:{test:{type:"string"},manifestPath:{type:"string"},includeList:{type:"object"},excludeList:{type:"object"}}},K=`/**
|
|
2
2
|
* Welcome to to your content_scripts CSS file during development!
|
|
3
3
|
* To speed up the development process, your styles
|
|
4
4
|
* are being injected directly into the head of the webpage,
|
|
5
5
|
* and will be removed when you build your application, along
|
|
6
6
|
* with this file. If you are seeing this file in a production build,
|
|
7
7
|
* it means that something is wrong with your build configuration.
|
|
8
|
-
*/`;function T(e){let n=this.getOptions();(0,M.validate)(
|
|
9
|
-
`);this.emitFile(`${s}.css`,
|
|
8
|
+
*/`;function T(e){let n=this.getOptions();(0,M.validate)(G,n,{name:"scripts:inject-content-css-during-dev",baseDataPath:"options"});let r=n.includeList||{},i=[],t=Object.entries(r).filter(([s,u])=>s.startsWith("content")&&u);if(!t.length)return e;for(let s of t){let[u,d]=s,c=[...w(d,n.excludeList||{})],p=N(d,n.excludeList||{});if(p.length&&!c.length){let f=x.default.resolve(__dirname,"minimum-content-file.mjs");c.push(f)}i.push({feature:u,scriptPath:c[0],cssImports:p.map(f=>F(c[0],f))})}let l=(0,S.urlToRequest)(this.resourcePath);return i.forEach(({feature:s,scriptPath:u,cssImports:d})=>{if(l.includes(u)){let c=d.map(p=>{let[,f]=s.split("/"),O=f.split("-")[1],_=x.default.basename(p);return`import(/* webpackChunkName: "${`web_accessible_resources/resource-${O}/${_.replace(".","_")}`}" */ '${p}').then(css => console.info('content_script.css loaded', css)).catch(err => console.error(err));`}).join(`
|
|
9
|
+
`);this.emitFile(`${s}.css`,K),e=`${c}
|
|
10
10
|
${e}`}}),e}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var j=Object.create;var u=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var T=(e,n)=>{for(var r in n)u(e,r,{get:n[r],enumerable:!0})},g=(e,n,r,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of N(n))!S.call(e,o)&&o!==r&&u(e,o,{get:()=>n[o],enumerable:!(i=M(n,o))||i.enumerable});return e};var a=(e,n,r)=>(r=e!=null?j(O(e)):{},g(n||!e||!e.__esModule?u(r,"default",{value:e,enumerable:!0}):r,e)),k=e=>g(u({},"__esModule",{value:!0}),e);var B={};T(B,{default:()=>H});module.exports=k(B);var f=a(require("path")),b=require("loader-utils"),v=require("schema-utils");var P=a(require("path")),U=a(require("fs")),A=require("child_process"),L=require("package-manager-detector");var D=a(require("path")),t=require("@colors/colors/safe");var h=a(require("path")),_=h.default.join(process.cwd(),"node_modules/extension-develop/dist/certs"),p=["chrome","edge"],R=["firefox"],J=[...p,...R];var I=require("console");function C(e,n){return n==="error"?`${(0,t.bold)((0,t.red)("ERROR"))} in ${e} ${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`:n==="warn"?`${e} ${(0,t.brightYellow)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`:`${n==="info"?(0,t.cyan)("\u25BA\u25BA\u25BA"):(0,t.brightGreen)("\u25BA\u25BA\u25BA")} ${(0,t.cyan)(e)}`}function $(){return`${C("Firefox runner","error")} No Service Worker Support
|
|
2
|
+
|
|
3
|
+
Firefox does not support the ${(0,t.brightYellow)("background.service_worker")} field yet.
|
|
4
|
+
Update your manifest.json file to use ${(0,t.brightYellow)("background.scripts")} instead.
|
|
5
|
+
If you really need to keep the ${(0,t.brightYellow)("service_worker")} field, prefix it with
|
|
6
|
+
${(0,t.brightYellow)("chromium:")} so it can target only Chromium-based browsers.
|
|
7
|
+
|
|
8
|
+
Mozilla bug: ${(0,t.underline)("https://bugzilla.mozilla.org/show_bug.cgi?id=1573659")}.`}function y(e,n){return JSON.parse(JSON.stringify(e),function(o,c){let s=o.indexOf(":");if(s===-1)return c;let l=o.substring(0,s);(l===n||l==="chromium"&&p.includes(n))&&(this[o.substring(s+1)]=c)})}var W={type:"object",properties:{test:{type:"string"},manifestPath:{type:"string"}}};function H(e){let n=this.getOptions(),r=n.manifestPath,i=n.browser,o=f.default.dirname(r),c=require(r),s=y(c,i);(0,v.validate)(W,n,{name:"reload:inject-background-client",baseDataPath:"options"});let l=(0,b.urlToRequest)(this.resourcePath),w=`
|
|
2
9
|
;browser.runtime.onMessageExternal.addListener(async (request, _sender) => {
|
|
3
10
|
const managementInfo = await browser.management.getSelf()
|
|
4
11
|
|
|
@@ -40,4 +47,4 @@
|
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
return {reloaded: true}
|
|
43
|
-
});`,
|
|
50
|
+
});`,d=s.background;if(s.service_worker)return console.log($()),e;if(d){let m=d?.scripts;if(m)for(let E of[m[0]]){let F=f.default.resolve(o,E);if(l.includes(F))return`${w}${e}`}}return e}
|
package/dist/module.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Configuration } from 'webpack';
|
|
2
2
|
|
|
3
3
|
interface DevOptions {
|
|
4
|
-
browser: 'chrome' | 'edge' | 'firefox';
|
|
4
|
+
browser: 'chrome' | 'edge' | 'firefox' | 'chromium-based' | 'gecko-based';
|
|
5
5
|
mode: 'development' | 'production' | 'none' | undefined;
|
|
6
6
|
port?: number;
|
|
7
7
|
noOpen?: boolean;
|
|
@@ -11,6 +11,8 @@ interface DevOptions {
|
|
|
11
11
|
browserFlags?: string[];
|
|
12
12
|
startingUrl?: string;
|
|
13
13
|
polyfill?: boolean;
|
|
14
|
+
chromiumBinary?: string;
|
|
15
|
+
geckoBinary?: string;
|
|
14
16
|
}
|
|
15
17
|
declare function extensionDev(pathOrRemoteUrl: string | undefined, devOptions: DevOptions): Promise<void>;
|
|
16
18
|
|
|
@@ -23,9 +25,7 @@ interface BuildOptions {
|
|
|
23
25
|
}
|
|
24
26
|
declare function extensionBuild(pathOrRemoteUrl: string | undefined, buildOptions?: BuildOptions): Promise<void>;
|
|
25
27
|
|
|
26
|
-
interface PreviewOptions {
|
|
27
|
-
browser: DevOptions['browser'];
|
|
28
|
-
userDataDir?: string;
|
|
28
|
+
interface PreviewOptions extends DevOptions {
|
|
29
29
|
}
|
|
30
30
|
declare function extensionPreview(pathOrRemoteUrl: string | undefined, previewOptions: PreviewOptions): Promise<void>;
|
|
31
31
|
|
|
@@ -36,11 +36,38 @@ interface StartOptions {
|
|
|
36
36
|
noOpen?: boolean;
|
|
37
37
|
userDataDir?: string;
|
|
38
38
|
polyfill?: boolean;
|
|
39
|
+
chromiumBinary?: string;
|
|
40
|
+
geckoBinary?: string;
|
|
39
41
|
}
|
|
40
42
|
declare function extensionStart(pathOrRemoteUrl: string | undefined, startOptions: StartOptions): Promise<void>;
|
|
41
43
|
|
|
44
|
+
type BrowserConfig = Pick<DevOptions, 'noOpen' | 'profile' | 'preferences' | 'browserFlags' | 'startingUrl' | 'chromiumBinary' | 'geckoBinary'>;
|
|
42
45
|
interface FileConfig {
|
|
43
|
-
|
|
46
|
+
browser?: {
|
|
47
|
+
chrome?: BrowserConfig;
|
|
48
|
+
firefox?: BrowserConfig;
|
|
49
|
+
edge?: BrowserConfig;
|
|
50
|
+
'chromium-based'?: BrowserConfig;
|
|
51
|
+
'gecko-based'?: BrowserConfig;
|
|
52
|
+
};
|
|
53
|
+
commands?: {
|
|
54
|
+
dev?: Pick<DevOptions, 'browser' | 'profile' | 'preferences' | 'polyfill'>;
|
|
55
|
+
preview?: Pick<PreviewOptions, 'browser' | 'profile' | 'preferences' | 'polyfill'>;
|
|
56
|
+
build?: Pick<BuildOptions, 'browser' | 'zipFilename' | 'zip' | 'zipSource' | 'polyfill'>;
|
|
57
|
+
};
|
|
58
|
+
config?: (config: Configuration) => Configuration;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type ChromeManifest = Partial<chrome.runtime.ManifestV2> & Partial<chrome.runtime.ManifestV3> & {
|
|
62
|
+
browser_action?: {
|
|
63
|
+
theme_icons?: ThemeIcon[];
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
type Manifest = ChromeManifest;
|
|
67
|
+
interface ThemeIcon {
|
|
68
|
+
light: string;
|
|
69
|
+
dark: string;
|
|
70
|
+
size?: number;
|
|
44
71
|
}
|
|
45
72
|
|
|
46
|
-
export { type BuildOptions, type DevOptions, type FileConfig, type PreviewOptions, type StartOptions, extensionBuild, extensionDev, extensionPreview, extensionStart };
|
|
73
|
+
export { type BuildOptions, type DevOptions, type FileConfig, type Manifest, type PreviewOptions, type StartOptions, extensionBuild, extensionDev, extensionPreview, extensionStart };
|