1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.createElectronFrameworkSupport = void 0;
|
7 |
|
8 | function _bluebirdLst() {
|
9 | const data = _interopRequireWildcard(require("bluebird-lst"));
|
10 |
|
11 | _bluebirdLst = function () {
|
12 | return data;
|
13 | };
|
14 |
|
15 | return data;
|
16 | }
|
17 |
|
18 | function _zipBin() {
|
19 | const data = require("7zip-bin");
|
20 |
|
21 | _zipBin = function () {
|
22 | return data;
|
23 | };
|
24 |
|
25 | return data;
|
26 | }
|
27 |
|
28 | function _builderUtil() {
|
29 | const data = require("builder-util");
|
30 |
|
31 | _builderUtil = function () {
|
32 | return data;
|
33 | };
|
34 |
|
35 | return data;
|
36 | }
|
37 |
|
38 | function _fs() {
|
39 | const data = require("builder-util/out/fs");
|
40 |
|
41 | _fs = function () {
|
42 | return data;
|
43 | };
|
44 |
|
45 | return data;
|
46 | }
|
47 |
|
48 | function _fsExtraP() {
|
49 | const data = require("fs-extra-p");
|
50 |
|
51 | _fsExtraP = function () {
|
52 | return data;
|
53 | };
|
54 |
|
55 | return data;
|
56 | }
|
57 |
|
58 | function _lazyVal() {
|
59 | const data = require("lazy-val");
|
60 |
|
61 | _lazyVal = function () {
|
62 | return data;
|
63 | };
|
64 |
|
65 | return data;
|
66 | }
|
67 |
|
68 | var path = _interopRequireWildcard(require("path"));
|
69 |
|
70 | function semver() {
|
71 | const data = _interopRequireWildcard(require("semver"));
|
72 |
|
73 | semver = function () {
|
74 | return data;
|
75 | };
|
76 |
|
77 | return data;
|
78 | }
|
79 |
|
80 | function _index() {
|
81 | const data = require("../index");
|
82 |
|
83 | _index = function () {
|
84 | return data;
|
85 | };
|
86 |
|
87 | return data;
|
88 | }
|
89 |
|
90 | function _electronDownload() {
|
91 | const data = require("./electron-download");
|
92 |
|
93 | _electronDownload = function () {
|
94 | return data;
|
95 | };
|
96 |
|
97 | return data;
|
98 | }
|
99 |
|
100 | function _electronMac() {
|
101 | const data = require("./electronMac");
|
102 |
|
103 | _electronMac = function () {
|
104 | return data;
|
105 | };
|
106 |
|
107 | return data;
|
108 | }
|
109 |
|
110 | function _electronVersion() {
|
111 | const data = require("./electronVersion");
|
112 |
|
113 | _electronVersion = function () {
|
114 | return data;
|
115 | };
|
116 |
|
117 | return data;
|
118 | }
|
119 |
|
120 | let beforeCopyExtraFiles = (() => {
|
121 | var _ref = (0, _bluebirdLst().coroutine)(function* (packager, appOutDir, asarIntegrity, isClearExecStack) {
|
122 | if (packager.platform === _index().Platform.LINUX) {
|
123 | const linuxPackager = packager;
|
124 | const executable = path.join(appOutDir, linuxPackager.executableName);
|
125 | yield (0, _fsExtraP().rename)(path.join(appOutDir, packager.electronDistExecutableName), executable);
|
126 |
|
127 | if (isClearExecStack) {
|
128 | try {
|
129 | yield (0, _builderUtil().executeAppBuilder)(["clear-exec-stack", "--input", executable]);
|
130 | } catch (e) {
|
131 | _builderUtil().log.debug({
|
132 | error: e
|
133 | }, "cannot clear exec stack");
|
134 | }
|
135 | }
|
136 | } else if (packager.platform === _index().Platform.WINDOWS) {
|
137 | const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`);
|
138 | yield (0, _fsExtraP().rename)(path.join(appOutDir, `${packager.electronDistExecutableName}.exe`), executable);
|
139 | } else {
|
140 | yield (0, _electronMac().createMacApp)(packager, appOutDir, asarIntegrity);
|
141 | const wantedLanguages = (0, _builderUtil().asArray)(packager.platformSpecificBuildOptions.electronLanguages);
|
142 |
|
143 | if (wantedLanguages.length === 0) {
|
144 | return;
|
145 | }
|
146 |
|
147 |
|
148 | const langFileExt = ".lproj";
|
149 | const resourcesDir = packager.getResourcesDir(appOutDir);
|
150 | yield _bluebirdLst().default.map((0, _fsExtraP().readdir)(resourcesDir), file => {
|
151 | if (!file.endsWith(langFileExt)) {
|
152 | return;
|
153 | }
|
154 |
|
155 | const language = file.substring(0, file.length - langFileExt.length);
|
156 |
|
157 | if (!wantedLanguages.includes(language)) {
|
158 | return (0, _fsExtraP().remove)(path.join(resourcesDir, file));
|
159 | }
|
160 |
|
161 | return;
|
162 | }, _fs().CONCURRENCY);
|
163 | }
|
164 | });
|
165 |
|
166 | return function beforeCopyExtraFiles(_x, _x2, _x3, _x4) {
|
167 | return _ref.apply(this, arguments);
|
168 | };
|
169 | })();
|
170 |
|
171 | let unpack = (() => {
|
172 | var _ref3 = (0, _bluebirdLst().coroutine)(function* (prepareOptions, options, distMacOsAppName) {
|
173 | const packager = prepareOptions.packager;
|
174 | const out = prepareOptions.appOutDir;
|
175 | let dist = packager.config.electronDist;
|
176 |
|
177 | if (dist != null) {
|
178 | const zipFile = `electron-v${options.version}-${prepareOptions.platformName}-${options.arch}.zip`;
|
179 | const resolvedDist = path.resolve(packager.projectDir, dist);
|
180 |
|
181 | if ((yield (0, _fs().statOrNull)(path.join(resolvedDist, zipFile))) != null) {
|
182 | options.cache = resolvedDist;
|
183 | dist = null;
|
184 | }
|
185 | }
|
186 |
|
187 | if (dist == null) {
|
188 | const zipPath = (yield Promise.all([(0, _electronDownload().downloadElectron)(options), (0, _fsExtraP().emptyDir)(out)]))[0];
|
189 |
|
190 | if (process.platform === "darwin" || (0, _builderUtil().isEnvTrue)(process.env.USE_UNZIP)) {
|
191 |
|
192 | yield (0, _builderUtil().exec)("unzip", ["-oqq", "-d", out, zipPath]);
|
193 | } else {
|
194 | yield (0, _builderUtil().spawn)(_zipBin().path7za, (0, _builderUtil().debug7zArgs)("x").concat(zipPath, "-aoa", `-o${out}`));
|
195 |
|
196 | if (prepareOptions.platformName === "linux") {
|
197 |
|
198 |
|
199 | yield Promise.all([(0, _fsExtraP().chmod)(path.join(out, "locales"), "0755"), (0, _fsExtraP().chmod)(path.join(out, "resources"), "0755")]);
|
200 | }
|
201 | }
|
202 | } else {
|
203 | const source = packager.getElectronSrcDir(dist);
|
204 | const destination = packager.getElectronDestinationDir(out);
|
205 |
|
206 | _builderUtil().log.info({
|
207 | source,
|
208 | destination
|
209 | }, "copying Electron");
|
210 |
|
211 | yield (0, _fsExtraP().emptyDir)(out);
|
212 | yield (0, _fs().copyDir)(source, destination, {
|
213 | isUseHardLink: _fs().DO_NOT_USE_HARD_LINKS
|
214 | });
|
215 | }
|
216 |
|
217 | yield cleanupAfterUnpack(prepareOptions, distMacOsAppName);
|
218 | });
|
219 |
|
220 | return function unpack(_x7, _x8, _x9) {
|
221 | return _ref3.apply(this, arguments);
|
222 | };
|
223 | })();
|
224 |
|
225 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
226 |
|
227 | function createDownloadOpts(opts, platform, arch, electronVersion) {
|
228 | return Object.assign({
|
229 | platform,
|
230 | arch,
|
231 | version: electronVersion
|
232 | }, opts.electronDownload);
|
233 | }
|
234 |
|
235 | let createElectronFrameworkSupport = (() => {
|
236 | var _ref2 = (0, _bluebirdLst().coroutine)(function* (configuration, packager) {
|
237 | if (configuration.muonVersion != null) {
|
238 | const distMacOsAppName = "Brave.app";
|
239 | return {
|
240 | name: "muon",
|
241 | isDefaultAppIconProvided: true,
|
242 | macOsDefaultTargets: ["zip", "dmg"],
|
243 | defaultAppIdPrefix: "com.electron.",
|
244 | version: configuration.muonVersion,
|
245 | distMacOsAppName,
|
246 | prepareApplicationStageDirectory: options => {
|
247 | return unpack(options, Object.assign({
|
248 | mirror: "https://github.com/brave/muon/releases/download/v",
|
249 | customFilename: `brave-v${options.version}-${options.platformName}-${options.arch}.zip`,
|
250 | isVerifyChecksum: false
|
251 | }, createDownloadOpts(options.packager.config, options.platformName, options.arch, options.version)), distMacOsAppName);
|
252 | },
|
253 | isNpmRebuildRequired: true,
|
254 | beforeCopyExtraFiles: (packager, appOutDir, asarIntegrity) => {
|
255 | return beforeCopyExtraFiles(packager, appOutDir, asarIntegrity, false);
|
256 | }
|
257 | };
|
258 | }
|
259 |
|
260 | let version = configuration.electronVersion;
|
261 |
|
262 | if (version == null) {
|
263 |
|
264 | if (packager.isPrepackedAppAsar) {
|
265 | version = yield (0, _electronVersion().getElectronVersionFromInstalled)(packager.projectDir);
|
266 |
|
267 | if (version == null) {
|
268 | throw new Error(`Cannot compute electron version for prepacked asar`);
|
269 | }
|
270 | } else {
|
271 | version = yield (0, _electronVersion().computeElectronVersion)(packager.projectDir, new (_lazyVal().Lazy)(() => Promise.resolve(packager.metadata)));
|
272 | }
|
273 |
|
274 | configuration.electronVersion = version;
|
275 | }
|
276 |
|
277 | const distMacOsAppName = "Electron.app";
|
278 | return {
|
279 | isDefaultAppIconProvided: true,
|
280 | macOsDefaultTargets: ["zip", "dmg"],
|
281 | defaultAppIdPrefix: "com.electron.",
|
282 | name: "electron",
|
283 | version,
|
284 | distMacOsAppName,
|
285 | isNpmRebuildRequired: true,
|
286 | prepareApplicationStageDirectory: options => unpack(options, createDownloadOpts(options.packager.config, options.platformName, options.arch, version), distMacOsAppName),
|
287 | beforeCopyExtraFiles: (packager, appOutDir, asarIntegrity) => {
|
288 | return beforeCopyExtraFiles(packager, appOutDir, asarIntegrity, semver().lte(version || "1.8.3", "1.8.3"));
|
289 | }
|
290 | };
|
291 | });
|
292 |
|
293 | return function createElectronFrameworkSupport(_x5, _x6) {
|
294 | return _ref2.apply(this, arguments);
|
295 | };
|
296 | })();
|
297 |
|
298 | exports.createElectronFrameworkSupport = createElectronFrameworkSupport;
|
299 |
|
300 | function cleanupAfterUnpack(prepareOptions, distMacOsAppName) {
|
301 | const out = prepareOptions.appOutDir;
|
302 |
|
303 | const isMac = prepareOptions.packager.platform === _index().Platform.MAC;
|
304 |
|
305 | const resourcesPath = isMac ? path.join(out, distMacOsAppName, "Contents", "Resources") : path.join(out, "resources");
|
306 | return Promise.all([(0, _fs().unlinkIfExists)(path.join(resourcesPath, "default_app.asar")), (0, _fs().unlinkIfExists)(path.join(out, "version")), isMac ? Promise.resolve() : (0, _fsExtraP().rename)(path.join(out, "LICENSE"), path.join(out, "LICENSE.electron.txt")).catch(() => {})]);
|
307 | }
|
308 |
|
\ | No newline at end of file |