stage-browser 0.0.0-stage → 0.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/README.md +136 -2
- package/build/icon.icns +0 -0
- package/build/icon.png +0 -0
- package/dist/bin/stage.js +111 -0
- package/dist/main/cli-args.js +28 -0
- package/dist/main/context-menu.js +68 -0
- package/dist/main/context.js +2 -0
- package/dist/main/extensions.js +78 -0
- package/dist/main/ipc.js +90 -0
- package/dist/main/main.js +279 -0
- package/dist/main/menu.js +140 -0
- package/dist/main/reveal.js +155 -0
- package/dist/main/selftest.js +490 -0
- package/dist/main/store.js +85 -0
- package/dist/main/suggest.js +43 -0
- package/dist/main/tabs.js +324 -0
- package/dist/main/url.js +38 -0
- package/dist/main/window.js +68 -0
- package/dist/preload/extension-compat.js +163 -0
- package/dist/preload/ui-preload.js +33 -0
- package/dist/shared/contract.js +6 -0
- package/dist/ui/app.js +653 -0
- package/dist/ui/index.html +41 -0
- package/dist/ui/mock.js +479 -0
- package/dist/ui/newtab.html +69 -0
- package/dist/ui/styles.css +410 -0
- package/node_modules/@types/chrome/LICENSE +21 -0
- package/node_modules/@types/chrome/README.md +15 -0
- package/node_modules/@types/chrome/chrome-cast/index.d.ts +1156 -0
- package/node_modules/@types/chrome/har-format/index.d.ts +6 -0
- package/node_modules/@types/chrome/index.d.ts +13786 -0
- package/node_modules/@types/chrome/package.json +99 -0
- package/node_modules/@types/filesystem/LICENSE +21 -0
- package/node_modules/@types/filesystem/README.md +15 -0
- package/node_modules/@types/filesystem/index.d.ts +564 -0
- package/node_modules/@types/filesystem/package.json +26 -0
- package/node_modules/@types/filewriter/LICENSE +21 -0
- package/node_modules/@types/filewriter/README.md +15 -0
- package/node_modules/@types/filewriter/index.d.ts +166 -0
- package/node_modules/@types/filewriter/package.json +25 -0
- package/node_modules/@types/har-format/LICENSE +21 -0
- package/node_modules/@types/har-format/README.md +15 -0
- package/node_modules/@types/har-format/index.d.ts +938 -0
- package/node_modules/@types/har-format/package.json +31 -0
- package/node_modules/adm-zip/LICENSE +21 -0
- package/node_modules/adm-zip/README.md +90 -0
- package/node_modules/adm-zip/adm-zip.js +1020 -0
- package/node_modules/adm-zip/headers/entryHeader.js +396 -0
- package/node_modules/adm-zip/headers/index.js +2 -0
- package/node_modules/adm-zip/headers/mainHeader.js +177 -0
- package/node_modules/adm-zip/methods/deflater.js +33 -0
- package/node_modules/adm-zip/methods/index.js +3 -0
- package/node_modules/adm-zip/methods/inflater.js +64 -0
- package/node_modules/adm-zip/methods/zipcrypto.js +175 -0
- package/node_modules/adm-zip/package.json +56 -0
- package/node_modules/adm-zip/types.d.ts +223 -0
- package/node_modules/adm-zip/util/constants.js +142 -0
- package/node_modules/adm-zip/util/decoder.js +5 -0
- package/node_modules/adm-zip/util/errors.js +66 -0
- package/node_modules/adm-zip/util/fattr.js +76 -0
- package/node_modules/adm-zip/util/index.js +5 -0
- package/node_modules/adm-zip/util/utils.js +481 -0
- package/node_modules/adm-zip/zipEntry.js +415 -0
- package/node_modules/adm-zip/zipFile.js +466 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/electron-chrome-web-store/README.md +143 -0
- package/node_modules/electron-chrome-web-store/dist/chrome-web-store.preload.js +299 -0
- package/node_modules/electron-chrome-web-store/dist/cjs/browser/index.js +1674 -0
- package/node_modules/electron-chrome-web-store/dist/esm/browser/index.mjs +950 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/api.d.ts +2 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/crx3.d.ts +20 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/id.d.ts +9 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/index.d.ts +62 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/installer.d.ts +29 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/loader.d.ts +18 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/types.d.ts +21 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/updater.d.ts +6 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/utils.d.ts +4 -0
- package/node_modules/electron-chrome-web-store/dist/types/common/constants.d.ts +44 -0
- package/node_modules/electron-chrome-web-store/dist/types/renderer/chrome-web-store.preload.d.ts +1 -0
- package/node_modules/electron-chrome-web-store/package.json +43 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/pbf/LICENSE +27 -0
- package/node_modules/pbf/README.md +293 -0
- package/node_modules/pbf/bin/pbf +17 -0
- package/node_modules/pbf/compile.js +441 -0
- package/node_modules/pbf/dist/pbf-dev.js +838 -0
- package/node_modules/pbf/dist/pbf.js +1 -0
- package/node_modules/pbf/index.d.ts +206 -0
- package/node_modules/pbf/index.js +830 -0
- package/node_modules/pbf/package.json +63 -0
- package/node_modules/protocol-buffers-schema/.travis.yml +7 -0
- package/node_modules/protocol-buffers-schema/LICENSE +21 -0
- package/node_modules/protocol-buffers-schema/README.md +122 -0
- package/node_modules/protocol-buffers-schema/example.js +11 -0
- package/node_modules/protocol-buffers-schema/example.proto +13 -0
- package/node_modules/protocol-buffers-schema/index.js +6 -0
- package/node_modules/protocol-buffers-schema/package.json +31 -0
- package/node_modules/protocol-buffers-schema/parse.js +769 -0
- package/node_modules/protocol-buffers-schema/stringify.js +206 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/basic.json +90 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/basic.proto +11 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/comments.json +99 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/comments.proto +19 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/complex.json +125 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/complex.proto +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/enum.json +42 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/enum.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/escaped-quotes.json +32 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/escaped-quotes.proto +3 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/extend.json +167 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/extend.proto +19 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/import.json +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/import.proto +6 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/map.json +33 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/map.proto +3 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/no-tags.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/oneof.json +41 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/oneof.proto +6 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/option.json +364 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/option.proto +72 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/options.json +47 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/options.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/pheromon-trajectories.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/reserved.json +55 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/reserved.proto +17 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/search.json +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/search.proto +5 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/service.json +108 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/service.proto +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/valid-packed.proto +35 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/version.json +90 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/version.proto +13 -0
- package/node_modules/protocol-buffers-schema/test/index.js +157 -0
- package/node_modules/protocol-buffers-schema/tokenize.js +56 -0
- package/node_modules/resolve-protobuf-schema/.travis.yml +3 -0
- package/node_modules/resolve-protobuf-schema/LICENSE +21 -0
- package/node_modules/resolve-protobuf-schema/README.md +49 -0
- package/node_modules/resolve-protobuf-schema/index.js +50 -0
- package/node_modules/resolve-protobuf-schema/package.json +25 -0
- package/node_modules/resolve-protobuf-schema/test/a.proto +5 -0
- package/node_modules/resolve-protobuf-schema/test/b.proto +5 -0
- package/node_modules/resolve-protobuf-schema/test/c.proto +3 -0
- package/node_modules/resolve-protobuf-schema/test/index.js +49 -0
- package/package.json +64 -4
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module dependencies.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const tty = require('tty');
|
|
6
|
+
const util = require('util');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This is the Node.js implementation of `debug()`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
exports.init = init;
|
|
13
|
+
exports.log = log;
|
|
14
|
+
exports.formatArgs = formatArgs;
|
|
15
|
+
exports.save = save;
|
|
16
|
+
exports.load = load;
|
|
17
|
+
exports.useColors = useColors;
|
|
18
|
+
exports.destroy = util.deprecate(
|
|
19
|
+
() => {},
|
|
20
|
+
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Colors.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
|
31
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
32
|
+
const supportsColor = require('supports-color');
|
|
33
|
+
|
|
34
|
+
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
35
|
+
exports.colors = [
|
|
36
|
+
20,
|
|
37
|
+
21,
|
|
38
|
+
26,
|
|
39
|
+
27,
|
|
40
|
+
32,
|
|
41
|
+
33,
|
|
42
|
+
38,
|
|
43
|
+
39,
|
|
44
|
+
40,
|
|
45
|
+
41,
|
|
46
|
+
42,
|
|
47
|
+
43,
|
|
48
|
+
44,
|
|
49
|
+
45,
|
|
50
|
+
56,
|
|
51
|
+
57,
|
|
52
|
+
62,
|
|
53
|
+
63,
|
|
54
|
+
68,
|
|
55
|
+
69,
|
|
56
|
+
74,
|
|
57
|
+
75,
|
|
58
|
+
76,
|
|
59
|
+
77,
|
|
60
|
+
78,
|
|
61
|
+
79,
|
|
62
|
+
80,
|
|
63
|
+
81,
|
|
64
|
+
92,
|
|
65
|
+
93,
|
|
66
|
+
98,
|
|
67
|
+
99,
|
|
68
|
+
112,
|
|
69
|
+
113,
|
|
70
|
+
128,
|
|
71
|
+
129,
|
|
72
|
+
134,
|
|
73
|
+
135,
|
|
74
|
+
148,
|
|
75
|
+
149,
|
|
76
|
+
160,
|
|
77
|
+
161,
|
|
78
|
+
162,
|
|
79
|
+
163,
|
|
80
|
+
164,
|
|
81
|
+
165,
|
|
82
|
+
166,
|
|
83
|
+
167,
|
|
84
|
+
168,
|
|
85
|
+
169,
|
|
86
|
+
170,
|
|
87
|
+
171,
|
|
88
|
+
172,
|
|
89
|
+
173,
|
|
90
|
+
178,
|
|
91
|
+
179,
|
|
92
|
+
184,
|
|
93
|
+
185,
|
|
94
|
+
196,
|
|
95
|
+
197,
|
|
96
|
+
198,
|
|
97
|
+
199,
|
|
98
|
+
200,
|
|
99
|
+
201,
|
|
100
|
+
202,
|
|
101
|
+
203,
|
|
102
|
+
204,
|
|
103
|
+
205,
|
|
104
|
+
206,
|
|
105
|
+
207,
|
|
106
|
+
208,
|
|
107
|
+
209,
|
|
108
|
+
214,
|
|
109
|
+
215,
|
|
110
|
+
220,
|
|
111
|
+
221
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Build up the default `inspectOpts` object from the environment variables.
|
|
120
|
+
*
|
|
121
|
+
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
|
125
|
+
return /^debug_/i.test(key);
|
|
126
|
+
}).reduce((obj, key) => {
|
|
127
|
+
// Camel-case
|
|
128
|
+
const prop = key
|
|
129
|
+
.substring(6)
|
|
130
|
+
.toLowerCase()
|
|
131
|
+
.replace(/_([a-z])/g, (_, k) => {
|
|
132
|
+
return k.toUpperCase();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Coerce string value into JS value
|
|
136
|
+
let val = process.env[key];
|
|
137
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
138
|
+
val = true;
|
|
139
|
+
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
140
|
+
val = false;
|
|
141
|
+
} else if (val === 'null') {
|
|
142
|
+
val = null;
|
|
143
|
+
} else {
|
|
144
|
+
val = Number(val);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
obj[prop] = val;
|
|
148
|
+
return obj;
|
|
149
|
+
}, {});
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Is stdout a TTY? Colored output is enabled when `true`.
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
function useColors() {
|
|
156
|
+
return 'colors' in exports.inspectOpts ?
|
|
157
|
+
Boolean(exports.inspectOpts.colors) :
|
|
158
|
+
tty.isatty(process.stderr.fd);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Adds ANSI color escape codes if enabled.
|
|
163
|
+
*
|
|
164
|
+
* @api public
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
function formatArgs(args) {
|
|
168
|
+
const {namespace: name, useColors} = this;
|
|
169
|
+
|
|
170
|
+
if (useColors) {
|
|
171
|
+
const c = this.color;
|
|
172
|
+
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
|
173
|
+
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
|
174
|
+
|
|
175
|
+
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
|
176
|
+
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
|
177
|
+
} else {
|
|
178
|
+
args[0] = getDate() + name + ' ' + args[0];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function getDate() {
|
|
183
|
+
if (exports.inspectOpts.hideDate) {
|
|
184
|
+
return '';
|
|
185
|
+
}
|
|
186
|
+
return new Date().toISOString() + ' ';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
function log(...args) {
|
|
194
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Save `namespaces`.
|
|
199
|
+
*
|
|
200
|
+
* @param {String} namespaces
|
|
201
|
+
* @api private
|
|
202
|
+
*/
|
|
203
|
+
function save(namespaces) {
|
|
204
|
+
if (namespaces) {
|
|
205
|
+
process.env.DEBUG = namespaces;
|
|
206
|
+
} else {
|
|
207
|
+
// If you set a process.env field to null or undefined, it gets cast to the
|
|
208
|
+
// string 'null' or 'undefined'. Just delete instead.
|
|
209
|
+
delete process.env.DEBUG;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Load `namespaces`.
|
|
215
|
+
*
|
|
216
|
+
* @return {String} returns the previously persisted debug modes
|
|
217
|
+
* @api private
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
function load() {
|
|
221
|
+
return process.env.DEBUG;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Init logic for `debug` instances.
|
|
226
|
+
*
|
|
227
|
+
* Create a new `inspectOpts` object in case `useColors` is set
|
|
228
|
+
* differently for a particular `debug` instance.
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
function init(debug) {
|
|
232
|
+
debug.inspectOpts = {};
|
|
233
|
+
|
|
234
|
+
const keys = Object.keys(exports.inspectOpts);
|
|
235
|
+
for (let i = 0; i < keys.length; i++) {
|
|
236
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
module.exports = require('./common')(exports);
|
|
241
|
+
|
|
242
|
+
const {formatters} = module.exports;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Map %o to `util.inspect()`, all on a single line.
|
|
246
|
+
*/
|
|
247
|
+
|
|
248
|
+
formatters.o = function (v) {
|
|
249
|
+
this.inspectOpts.colors = this.useColors;
|
|
250
|
+
return util.inspect(v, this.inspectOpts)
|
|
251
|
+
.split('\n')
|
|
252
|
+
.map(str => str.trim())
|
|
253
|
+
.join(' ');
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
formatters.O = function (v) {
|
|
261
|
+
this.inspectOpts.colors = this.useColors;
|
|
262
|
+
return util.inspect(v, this.inspectOpts);
|
|
263
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# electron-chrome-web-store
|
|
2
|
+
|
|
3
|
+
Install and update Chrome extensions from the Chrome Web Store for Electron.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install electron-chrome-web-store
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> [!TIP]
|
|
12
|
+
> To enable full support for Chrome extensions in Electron, install [electron-chrome-extensions](https://www.npmjs.com/package/electron-chrome-extensions).
|
|
13
|
+
|
|
14
|
+
### Enable downloading extensions from the Chrome Web Store
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
const { app, BrowserWindow, session } = require('electron')
|
|
18
|
+
const { installChromeWebStore } = require('electron-chrome-web-store')
|
|
19
|
+
|
|
20
|
+
app.whenReady().then(async () => {
|
|
21
|
+
const browserSession = session.defaultSession
|
|
22
|
+
const browserWindow = new BrowserWindow({
|
|
23
|
+
webPreferences: {
|
|
24
|
+
session: browserSession,
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// Install Chrome web store and wait for extensions to load
|
|
29
|
+
await installChromeWebStore({ session: browserSession })
|
|
30
|
+
|
|
31
|
+
browserWindow.loadURL('https://chromewebstore.google.com/')
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Install and update extensions programmatically
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
const { app, session } = require('electron')
|
|
39
|
+
const { installExtension, updateExtensions } = require('electron-chrome-web-store')
|
|
40
|
+
|
|
41
|
+
app.whenReady().then(async () => {
|
|
42
|
+
// Install Dark Reader
|
|
43
|
+
await installExtension('eimadpbcbfnmbkopoojfekhnkhdbieeh')
|
|
44
|
+
|
|
45
|
+
// Install React Developer Tools with file:// access
|
|
46
|
+
await installExtension('fmkadmapgofadopljbjfkapdkoienihi', {
|
|
47
|
+
loadExtensionOptions: { allowFileAccess: true },
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// Install uBlock Origin Lite to custom session
|
|
51
|
+
await installExtension('ddkjiahejlhfcafbddmgiahcphecmpfh', {
|
|
52
|
+
session: session.fromPartition('persist:browser'),
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// Check and install updates for all loaded extensions
|
|
56
|
+
await updateExtensions()
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Packaging the preload script
|
|
61
|
+
|
|
62
|
+
This module uses a [preload script](https://www.electronjs.org/docs/latest/tutorial/tutorial-preload#what-is-a-preload-script).
|
|
63
|
+
When packaging your application, it's required that the preload script is included. This can be
|
|
64
|
+
handled in two ways:
|
|
65
|
+
|
|
66
|
+
1. Include `node_modules` in your packaged app. This allows `electron-chrome-web-store/preload` to
|
|
67
|
+
be resolved.
|
|
68
|
+
2. In the case of using JavaScript bundlers, you may need to copy the preload script next to your
|
|
69
|
+
app's entry point script. You can try using
|
|
70
|
+
[copy-webpack-plugin](https://github.com/webpack-contrib/copy-webpack-plugin),
|
|
71
|
+
[vite-plugin-static-copy](https://github.com/sapphi-red/vite-plugin-static-copy),
|
|
72
|
+
or [rollup-plugin-copy](https://github.com/vladshcherbin/rollup-plugin-copy) depending on your app's
|
|
73
|
+
configuration.
|
|
74
|
+
|
|
75
|
+
Here's an example for webpack configurations:
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
module.exports = {
|
|
79
|
+
entry: './index.js',
|
|
80
|
+
plugins: [
|
|
81
|
+
new CopyWebpackPlugin({
|
|
82
|
+
patterns: [require.resolve('electron-chrome-web-store/preload')],
|
|
83
|
+
}),
|
|
84
|
+
],
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## API
|
|
89
|
+
|
|
90
|
+
### `installChromeWebStore`
|
|
91
|
+
|
|
92
|
+
Installs Chrome Web Store support in the specified session.
|
|
93
|
+
|
|
94
|
+
- `options`
|
|
95
|
+
- `session`: The Electron session to enable the Chrome Web Store in. Defaults to `session.defaultSession`.
|
|
96
|
+
- `extensionsPath`: The path to the extensions directory. Defaults to 'Extensions/' in the app's userData path.
|
|
97
|
+
- `autoUpdate`: Whether to auto-update web store extensions at startup and once every 5 hours. Defaults to true.
|
|
98
|
+
- `loadExtensions`: A boolean indicating whether to load extensions installed by Chrome Web Store. Defaults to true.
|
|
99
|
+
- `allowUnpackedExtensions`: A boolean indicating whether to allow loading unpacked extensions. Only loads if `loadExtensions` is also enabled. Defaults to false.
|
|
100
|
+
- `allowlist`: An array of allowed extension IDs to install.
|
|
101
|
+
- `denylist`: An array of denied extension IDs to install.
|
|
102
|
+
- `beforeInstall`: A function which receives install details and returns a promise. Allows for prompting prior to install.
|
|
103
|
+
|
|
104
|
+
### `installExtension`
|
|
105
|
+
|
|
106
|
+
Installs Chrome extension from the Chrome Web Store.
|
|
107
|
+
|
|
108
|
+
- `extensionId`: The Chrome Web Store extension ID to install.
|
|
109
|
+
- `options`
|
|
110
|
+
- `session`: The Electron session to load extensions in. Defaults to `session.defaultSession`.
|
|
111
|
+
- `extensionsPath`: The path to the extensions directory. Defaults to 'Extensions/' in the app's userData path.
|
|
112
|
+
- `loadExtensionOptions`: Extension options passed into `session.extensions.loadExtension`.
|
|
113
|
+
|
|
114
|
+
### `uninstallExtension`
|
|
115
|
+
|
|
116
|
+
Uninstalls Chrome Web Store extension.
|
|
117
|
+
|
|
118
|
+
- `extensionId`: The Chrome Web Store extension ID to uninstall.
|
|
119
|
+
- `options`
|
|
120
|
+
- `session`: The Electron session where extensions are loaded. Defaults to `session.defaultSession`.
|
|
121
|
+
- `extensionsPath`: The path to the extensions directory. Defaults to 'Extensions/' in the app's userData path.
|
|
122
|
+
|
|
123
|
+
### `updateExtensions`
|
|
124
|
+
|
|
125
|
+
Checks loaded extensions for updates and installs any if available.
|
|
126
|
+
|
|
127
|
+
- `session`: The Electron session to load extensions in. Defaults to `session.defaultSession`.
|
|
128
|
+
|
|
129
|
+
### `loadAllExtensions`
|
|
130
|
+
|
|
131
|
+
Loads all extensions from the specified directory.
|
|
132
|
+
|
|
133
|
+
- `session`: The Electron session to load extensions in.
|
|
134
|
+
- `extensionsPath`: The path to the directory containing the extensions.
|
|
135
|
+
- `options`: An object with the following property:
|
|
136
|
+
- `allowUnpacked`: A boolean indicating whether to allow loading unpacked extensions. Defaults to false.
|
|
137
|
+
|
|
138
|
+
> [!NOTE]
|
|
139
|
+
> The `installChromeWebStore` API will automatically load web store extensions by default.
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
4
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
5
|
+
}) : x)(function(x) {
|
|
6
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// src/renderer/chrome-web-store.preload.ts
|
|
11
|
+
var import_electron = __require("electron");
|
|
12
|
+
|
|
13
|
+
// src/common/constants.ts
|
|
14
|
+
var ExtensionInstallStatus = {
|
|
15
|
+
BLACKLISTED: "blacklisted",
|
|
16
|
+
BLOCKED_BY_POLICY: "blocked_by_policy",
|
|
17
|
+
CAN_REQUEST: "can_request",
|
|
18
|
+
CORRUPTED: "corrupted",
|
|
19
|
+
CUSTODIAN_APPROVAL_REQUIRED: "custodian_approval_required",
|
|
20
|
+
CUSTODIAN_APPROVAL_REQUIRED_FOR_INSTALLATION: "custodian_approval_required_for_installation",
|
|
21
|
+
DEPRECATED_MANIFEST_VERSION: "deprecated_manifest_version",
|
|
22
|
+
DISABLED: "disabled",
|
|
23
|
+
ENABLED: "enabled",
|
|
24
|
+
FORCE_INSTALLED: "force_installed",
|
|
25
|
+
INSTALLABLE: "installable",
|
|
26
|
+
REQUEST_PENDING: "request_pending",
|
|
27
|
+
TERMINATED: "terminated"
|
|
28
|
+
};
|
|
29
|
+
var MV2DeprecationStatus = {
|
|
30
|
+
INACTIVE: "inactive",
|
|
31
|
+
SOFT_DISABLE: "soft_disable",
|
|
32
|
+
WARNING: "warning"
|
|
33
|
+
};
|
|
34
|
+
var Result = {
|
|
35
|
+
ALREADY_INSTALLED: "already_installed",
|
|
36
|
+
BLACKLISTED: "blacklisted",
|
|
37
|
+
BLOCKED_BY_POLICY: "blocked_by_policy",
|
|
38
|
+
BLOCKED_FOR_CHILD_ACCOUNT: "blocked_for_child_account",
|
|
39
|
+
FEATURE_DISABLED: "feature_disabled",
|
|
40
|
+
ICON_ERROR: "icon_error",
|
|
41
|
+
INSTALL_ERROR: "install_error",
|
|
42
|
+
INSTALL_IN_PROGRESS: "install_in_progress",
|
|
43
|
+
INVALID_ICON_URL: "invalid_icon_url",
|
|
44
|
+
INVALID_ID: "invalid_id",
|
|
45
|
+
LAUNCH_IN_PROGRESS: "launch_in_progress",
|
|
46
|
+
MANIFEST_ERROR: "manifest_error",
|
|
47
|
+
MISSING_DEPENDENCIES: "missing_dependencies",
|
|
48
|
+
SUCCESS: "success",
|
|
49
|
+
UNKNOWN_ERROR: "unknown_error",
|
|
50
|
+
UNSUPPORTED_EXTENSION_TYPE: "unsupported_extension_type",
|
|
51
|
+
USER_CANCELLED: "user_cancelled",
|
|
52
|
+
USER_GESTURE_REQUIRED: "user_gesture_required"
|
|
53
|
+
};
|
|
54
|
+
var WebGlStatus = {
|
|
55
|
+
WEBGL_ALLOWED: "webgl_allowed",
|
|
56
|
+
WEBGL_BLOCKED: "webgl_blocked"
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/renderer/chrome-web-store.preload.ts
|
|
60
|
+
function updateBranding(appName) {
|
|
61
|
+
const update = () => {
|
|
62
|
+
requestAnimationFrame(() => {
|
|
63
|
+
const chromeButtons = Array.from(document.querySelectorAll("span")).filter(
|
|
64
|
+
(node) => node.innerText.includes("Chrome")
|
|
65
|
+
);
|
|
66
|
+
for (const button of chromeButtons) {
|
|
67
|
+
button.innerText = button.innerText.replace("Chrome", appName);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
update();
|
|
72
|
+
setTimeout(update, 1e3 / 60);
|
|
73
|
+
}
|
|
74
|
+
function getUAProductVersion(userAgent, product) {
|
|
75
|
+
const regex = new RegExp(`${product}/([\\d.]+)`);
|
|
76
|
+
return userAgent.match(regex)?.[1];
|
|
77
|
+
}
|
|
78
|
+
function overrideUserAgent() {
|
|
79
|
+
const chromeVersion = getUAProductVersion(navigator.userAgent, "Chrome") || "133.0.6920.0";
|
|
80
|
+
const userAgent = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${chromeVersion} Safari/537.36`;
|
|
81
|
+
import_electron.webFrame.executeJavaScript(
|
|
82
|
+
`(${function(userAgent2) {
|
|
83
|
+
Object.defineProperty(navigator, "userAgent", { value: userAgent2 });
|
|
84
|
+
}})(${JSON.stringify(userAgent)});`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
var DEBUG = true;
|
|
88
|
+
function log(...args) {
|
|
89
|
+
if (!DEBUG) return;
|
|
90
|
+
console.debug(...args);
|
|
91
|
+
}
|
|
92
|
+
function setupChromeWebStoreApi() {
|
|
93
|
+
let appName;
|
|
94
|
+
const setAppName = (name) => {
|
|
95
|
+
appName = name;
|
|
96
|
+
updateBranding(appName);
|
|
97
|
+
};
|
|
98
|
+
const maybeUpdateBranding = () => {
|
|
99
|
+
if (appName) updateBranding(appName);
|
|
100
|
+
};
|
|
101
|
+
const setExtensionError = (message) => {
|
|
102
|
+
import_electron.webFrame.executeJavaScript(`
|
|
103
|
+
if (typeof chrome !== 'undefined') {
|
|
104
|
+
if (!chrome.extension) chrome.extension = {};
|
|
105
|
+
chrome.extension.lastError = ${JSON.stringify(message ? { message } : null)};
|
|
106
|
+
}
|
|
107
|
+
`);
|
|
108
|
+
};
|
|
109
|
+
const electronWebstore = {
|
|
110
|
+
ExtensionInstallStatus,
|
|
111
|
+
MV2DeprecationStatus,
|
|
112
|
+
Result,
|
|
113
|
+
WebGlStatus,
|
|
114
|
+
beginInstallWithManifest3: async (details, callback) => {
|
|
115
|
+
log("webstorePrivate.beginInstallWithManifest3", details);
|
|
116
|
+
const { result, message } = await import_electron.ipcRenderer.invoke("chromeWebstore.beginInstall", details);
|
|
117
|
+
log("webstorePrivate.beginInstallWithManifest3 result:", result);
|
|
118
|
+
setExtensionError(result === Result.SUCCESS ? null : message);
|
|
119
|
+
if (callback) callback(result);
|
|
120
|
+
return result;
|
|
121
|
+
},
|
|
122
|
+
completeInstall: async (id, callback) => {
|
|
123
|
+
log("webstorePrivate.completeInstall", id);
|
|
124
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.completeInstall", id);
|
|
125
|
+
log("webstorePrivate.completeInstall result:", result);
|
|
126
|
+
if (callback) callback(result);
|
|
127
|
+
maybeUpdateBranding();
|
|
128
|
+
return result;
|
|
129
|
+
},
|
|
130
|
+
enableAppLauncher: async (enable, callback) => {
|
|
131
|
+
log("webstorePrivate.enableAppLauncher", enable);
|
|
132
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.enableAppLauncher", enable);
|
|
133
|
+
log("webstorePrivate.enableAppLauncher result:", result);
|
|
134
|
+
if (callback) callback(result);
|
|
135
|
+
return result;
|
|
136
|
+
},
|
|
137
|
+
getBrowserLogin: async (callback) => {
|
|
138
|
+
log("webstorePrivate.getBrowserLogin called");
|
|
139
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.getBrowserLogin");
|
|
140
|
+
log("webstorePrivate.getBrowserLogin result:", result);
|
|
141
|
+
if (callback) callback(result);
|
|
142
|
+
return result;
|
|
143
|
+
},
|
|
144
|
+
getExtensionStatus: async (id, manifestJson, callback) => {
|
|
145
|
+
log("webstorePrivate.getExtensionStatus", id, { id, manifestJson, callback });
|
|
146
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.getExtensionStatus", id, manifestJson);
|
|
147
|
+
log("webstorePrivate.getExtensionStatus result:", id, result);
|
|
148
|
+
if (callback) callback(result);
|
|
149
|
+
maybeUpdateBranding();
|
|
150
|
+
return result;
|
|
151
|
+
},
|
|
152
|
+
getFullChromeVersion: async (callback) => {
|
|
153
|
+
log("webstorePrivate.getFullChromeVersion called");
|
|
154
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.getFullChromeVersion");
|
|
155
|
+
log("webstorePrivate.getFullChromeVersion result:", result);
|
|
156
|
+
if (result.app_name) {
|
|
157
|
+
setAppName(result.app_name);
|
|
158
|
+
delete result.app_name;
|
|
159
|
+
}
|
|
160
|
+
if (callback) callback(result);
|
|
161
|
+
return result;
|
|
162
|
+
},
|
|
163
|
+
getIsLauncherEnabled: async (callback) => {
|
|
164
|
+
log("webstorePrivate.getIsLauncherEnabled called");
|
|
165
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.getIsLauncherEnabled");
|
|
166
|
+
log("webstorePrivate.getIsLauncherEnabled result:", result);
|
|
167
|
+
if (callback) callback(result);
|
|
168
|
+
return result;
|
|
169
|
+
},
|
|
170
|
+
getMV2DeprecationStatus: async (callback) => {
|
|
171
|
+
log("webstorePrivate.getMV2DeprecationStatus called");
|
|
172
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.getMV2DeprecationStatus");
|
|
173
|
+
log("webstorePrivate.getMV2DeprecationStatus result:", result);
|
|
174
|
+
if (callback) callback(result);
|
|
175
|
+
return result;
|
|
176
|
+
},
|
|
177
|
+
getReferrerChain: async (callback) => {
|
|
178
|
+
log("webstorePrivate.getReferrerChain called");
|
|
179
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.getReferrerChain");
|
|
180
|
+
log("webstorePrivate.getReferrerChain result:", result);
|
|
181
|
+
if (callback) callback(result);
|
|
182
|
+
return result;
|
|
183
|
+
},
|
|
184
|
+
getStoreLogin: async (callback) => {
|
|
185
|
+
log("webstorePrivate.getStoreLogin called");
|
|
186
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.getStoreLogin");
|
|
187
|
+
log("webstorePrivate.getStoreLogin result:", result);
|
|
188
|
+
if (callback) callback(result);
|
|
189
|
+
return result;
|
|
190
|
+
},
|
|
191
|
+
getWebGLStatus: async (callback) => {
|
|
192
|
+
log("webstorePrivate.getWebGLStatus called");
|
|
193
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.getWebGLStatus");
|
|
194
|
+
log("webstorePrivate.getWebGLStatus result:", result);
|
|
195
|
+
if (callback) callback(result);
|
|
196
|
+
return result;
|
|
197
|
+
},
|
|
198
|
+
install: async (id, silentInstall, callback) => {
|
|
199
|
+
log("webstorePrivate.install", { id, silentInstall });
|
|
200
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.install", id, silentInstall);
|
|
201
|
+
log("webstorePrivate.install result:", result);
|
|
202
|
+
if (callback) callback(result);
|
|
203
|
+
return result;
|
|
204
|
+
},
|
|
205
|
+
isInIncognitoMode: async (callback) => {
|
|
206
|
+
log("webstorePrivate.isInIncognitoMode called");
|
|
207
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.isInIncognitoMode");
|
|
208
|
+
log("webstorePrivate.isInIncognitoMode result:", result);
|
|
209
|
+
if (callback) callback(result);
|
|
210
|
+
return result;
|
|
211
|
+
},
|
|
212
|
+
isPendingCustodianApproval: async (id, callback) => {
|
|
213
|
+
log("webstorePrivate.isPendingCustodianApproval", id);
|
|
214
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.isPendingCustodianApproval", id);
|
|
215
|
+
log("webstorePrivate.isPendingCustodianApproval result:", result);
|
|
216
|
+
if (callback) callback(result);
|
|
217
|
+
return result;
|
|
218
|
+
},
|
|
219
|
+
setStoreLogin: async (login, callback) => {
|
|
220
|
+
log("webstorePrivate.setStoreLogin", login);
|
|
221
|
+
const result = await import_electron.ipcRenderer.invoke("chromeWebstore.setStoreLogin", login);
|
|
222
|
+
log("webstorePrivate.setStoreLogin result:", result);
|
|
223
|
+
if (callback) callback(result);
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
import_electron.contextBridge.exposeInMainWorld("electronWebstore", electronWebstore);
|
|
228
|
+
const runtime = {
|
|
229
|
+
lastError: null,
|
|
230
|
+
getManifest: async () => {
|
|
231
|
+
log("chrome.runtime.getManifest called");
|
|
232
|
+
return {};
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
import_electron.contextBridge.exposeInMainWorld("electronRuntime", runtime);
|
|
236
|
+
const management = {
|
|
237
|
+
onInstalled: {
|
|
238
|
+
addListener: (callback) => {
|
|
239
|
+
log("chrome.management.onInstalled.addListener called");
|
|
240
|
+
import_electron.ipcRenderer.on("chrome.management.onInstalled", callback);
|
|
241
|
+
},
|
|
242
|
+
removeListener: (callback) => {
|
|
243
|
+
log("chrome.management.onInstalled.removeListener called");
|
|
244
|
+
import_electron.ipcRenderer.removeListener("chrome.management.onInstalled", callback);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
onUninstalled: {
|
|
248
|
+
addListener: (callback) => {
|
|
249
|
+
log("chrome.management.onUninstalled.addListener called");
|
|
250
|
+
import_electron.ipcRenderer.on("chrome.management.onUninstalled", callback);
|
|
251
|
+
},
|
|
252
|
+
removeListener: (callback) => {
|
|
253
|
+
log("chrome.management.onUninstalled.removeListener called");
|
|
254
|
+
import_electron.ipcRenderer.removeListener("chrome.management.onUninstalled", callback);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
getAll: (callback) => {
|
|
258
|
+
log("chrome.management.getAll called");
|
|
259
|
+
import_electron.ipcRenderer.invoke("chrome.management.getAll").then((result) => {
|
|
260
|
+
log("chrome.management.getAll result:", result);
|
|
261
|
+
callback(result);
|
|
262
|
+
});
|
|
263
|
+
},
|
|
264
|
+
setEnabled: async (id, enabled) => {
|
|
265
|
+
log("chrome.management.setEnabled", { id, enabled });
|
|
266
|
+
const result = await import_electron.ipcRenderer.invoke("chrome.management.setEnabled", id, enabled);
|
|
267
|
+
log("chrome.management.setEnabled result:", result);
|
|
268
|
+
return result;
|
|
269
|
+
},
|
|
270
|
+
uninstall: (id, options, callback) => {
|
|
271
|
+
log("chrome.management.uninstall", { id, options });
|
|
272
|
+
import_electron.ipcRenderer.invoke("chrome.management.uninstall", id, options).then((result) => {
|
|
273
|
+
log("chrome.management.uninstall result:", result);
|
|
274
|
+
if (callback) callback();
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
import_electron.contextBridge.exposeInMainWorld("electronManagement", management);
|
|
279
|
+
import_electron.webFrame.executeJavaScript(`
|
|
280
|
+
(function () {
|
|
281
|
+
chrome.webstorePrivate = globalThis.electronWebstore;
|
|
282
|
+
Object.assign(chrome.runtime, electronRuntime);
|
|
283
|
+
Object.assign(chrome.management, electronManagement);
|
|
284
|
+
void 0;
|
|
285
|
+
}());
|
|
286
|
+
`);
|
|
287
|
+
electronWebstore.getFullChromeVersion();
|
|
288
|
+
overrideUserAgent();
|
|
289
|
+
process.once("document-start", maybeUpdateBranding);
|
|
290
|
+
if ("navigation" in window) {
|
|
291
|
+
;
|
|
292
|
+
window.navigation.addEventListener("navigate", maybeUpdateBranding);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (location.href.startsWith("https://chromewebstore.google.com")) {
|
|
296
|
+
log("Injecting Chrome Web Store API");
|
|
297
|
+
setupChromeWebStoreApi();
|
|
298
|
+
}
|
|
299
|
+
})();
|