electron-incremental-update 2.0.0-beta.8 → 2.0.0-beta.9

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.
@@ -1,13 +1,29 @@
1
- import { I as IProvider, d as defaultIsLowerVersion, a as UpdateJSON, U as UpdateInfo, D as DownloadingInfo, c as URLHandler, O as OnDownloading } from './types-CItP6bL-.js';
1
+ import { d as defaultIsLowerVersion, U as UpdateJSON, a as UpdateInfo } from './version-DgfjJQUx.js';
2
+ import { I as IProvider, D as DownloadingInfo, U as URLHandler, O as OnDownloading } from './types-D7OK98ln.js';
2
3
  import { f as defaultVerifySignature, a as defaultUnzipFile } from './zip-DPF5IFkK.js';
3
4
  import { Arrayable } from '@subframe7536/type-utils';
4
5
 
5
6
  declare abstract class BaseProvider implements IProvider {
6
7
  name: string;
8
+ /**
9
+ * @inheritdoc
10
+ */
7
11
  isLowerVersion: typeof defaultIsLowerVersion;
12
+ /**
13
+ * @inheritdoc
14
+ */
8
15
  verifySignaure: typeof defaultVerifySignature;
16
+ /**
17
+ * @inheritdoc
18
+ */
9
19
  unzipFile: typeof defaultUnzipFile;
20
+ /**
21
+ * @inheritdoc
22
+ */
10
23
  abstract downloadJSON(versionPath: string): Promise<UpdateJSON>;
24
+ /**
25
+ * @inheritdoc
26
+ */
11
27
  abstract downloadAsar(name: string, info: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
12
28
  }
13
29
 
package/dist/provider.js CHANGED
@@ -14,8 +14,7 @@ function getHeader(response, headerKey) {
14
14
  async function downloadFn(url, headers, onResponse) {
15
15
  await app.whenReady();
16
16
  return new Promise((resolve, reject) => {
17
- const request = net.request({ url, method: "GET", redirect: "follow" });
18
- Object.keys(headers).forEach((key) => request.setHeader(key, headers[key]));
17
+ const request = net.request({ url, method: "GET", redirect: "follow", headers });
19
18
  request.on("response", (resp) => {
20
19
  resp.on("aborted", () => reject(new Error("aborted")));
21
20
  resp.on("error", () => reject(new Error("download error")));
@@ -70,8 +69,17 @@ async function defaultDownloadAsar(url, headers, onDownloading) {
70
69
  // src/provider/base.ts
71
70
  var BaseProvider = class {
72
71
  name = "BaseProvider";
72
+ /**
73
+ * @inheritdoc
74
+ */
73
75
  isLowerVersion = defaultIsLowerVersion;
76
+ /**
77
+ * @inheritdoc
78
+ */
74
79
  verifySignaure = defaultVerifySignature;
80
+ /**
81
+ * @inheritdoc
82
+ */
75
83
  unzipFile = defaultUnzipFile;
76
84
  };
77
85
 
@@ -90,6 +98,9 @@ var GitHubProvider = class extends BaseProvider {
90
98
  constructor(options) {
91
99
  super();
92
100
  this.options = options;
101
+ if (!options.branch) {
102
+ this.options.branch = "HEAD";
103
+ }
93
104
  }
94
105
  get urlHandler() {
95
106
  return this.options.urlHandler;
@@ -106,14 +117,14 @@ var GitHubProvider = class extends BaseProvider {
106
117
  }
107
118
  async downloadJSON(versionPath) {
108
119
  return await defaultDownloadUpdateJSON(
109
- await this.parseURL(false, `${this.options.branch ?? "HEAD"}/${versionPath}`),
110
- { accept: "application/json", ...this.options.extraHeaders }
120
+ await this.parseURL(false, `${this.options.branch}/${versionPath}`),
121
+ { Accept: "application/json", ...this.options.extraHeaders }
111
122
  );
112
123
  }
113
124
  async downloadAsar(name, info, onDownloading) {
114
125
  return await defaultDownloadAsar(
115
126
  await this.parseURL(true, `releases/download/v${info.version}/${name}-${info.version}.asar.gz`),
116
- { accept: "application/octet-stream", ...this.options.extraHeaders },
127
+ { Accept: "application/octet-stream", ...this.options.extraHeaders },
117
128
  onDownloading
118
129
  );
119
130
  }
@@ -1,30 +1,5 @@
1
1
  import { Promisable } from '@subframe7536/type-utils';
2
-
3
- interface Version {
4
- major: number;
5
- minor: number;
6
- patch: number;
7
- stage: string;
8
- stageVersion: number;
9
- }
10
- declare function parseVersion(version: string): Version;
11
- declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
12
- /**
13
- * update info json
14
- */
15
- type UpdateInfo = {
16
- signature: string;
17
- minimumVersion: string;
18
- version: string;
19
- };
20
- /**
21
- * {@link UpdateInfo} with beta
22
- */
23
- type UpdateJSON = UpdateInfo & {
24
- beta: UpdateInfo;
25
- };
26
- declare function isUpdateJSON(json: any): json is UpdateJSON;
27
- declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
2
+ import { U as UpdateJSON, a as UpdateInfo } from './version-DgfjJQUx.js';
28
3
 
29
4
  type URLHandler = (url: URL, isDownloadAsar: boolean) => Promisable<URL | string | undefined | null>;
30
5
  type OnDownloading = (progress: DownloadingInfo) => void;
@@ -68,7 +43,7 @@ interface IProvider {
68
43
  onDownloading?: OnDownloading;
69
44
  /**
70
45
  * download update json
71
- * @param versionPath parsed version path
46
+ * @param versionPath parsed version path in project
72
47
  */
73
48
  downloadJSON: (versionPath: string) => Promise<UpdateJSON>;
74
49
  /**
@@ -101,4 +76,4 @@ interface IProvider {
101
76
  verifySignaure: (buffer: Buffer, version: string, signature: string, cert: string) => Promisable<boolean>;
102
77
  }
103
78
 
104
- export { type DownloadingInfo as D, type IProvider as I, type OnDownloading as O, type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, type URLHandler as c, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
79
+ export type { DownloadingInfo as D, IProvider as I, OnDownloading as O, URLHandler as U };
@@ -1,30 +1,5 @@
1
1
  import { Promisable } from '@subframe7536/type-utils';
2
-
3
- interface Version {
4
- major: number;
5
- minor: number;
6
- patch: number;
7
- stage: string;
8
- stageVersion: number;
9
- }
10
- declare function parseVersion(version: string): Version;
11
- declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
12
- /**
13
- * update info json
14
- */
15
- type UpdateInfo = {
16
- signature: string;
17
- minimumVersion: string;
18
- version: string;
19
- };
20
- /**
21
- * {@link UpdateInfo} with beta
22
- */
23
- type UpdateJSON = UpdateInfo & {
24
- beta: UpdateInfo;
25
- };
26
- declare function isUpdateJSON(json: any): json is UpdateJSON;
27
- declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
2
+ import { U as UpdateJSON, a as UpdateInfo } from './version-DgfjJQUx.cjs';
28
3
 
29
4
  type URLHandler = (url: URL, isDownloadAsar: boolean) => Promisable<URL | string | undefined | null>;
30
5
  type OnDownloading = (progress: DownloadingInfo) => void;
@@ -68,7 +43,7 @@ interface IProvider {
68
43
  onDownloading?: OnDownloading;
69
44
  /**
70
45
  * download update json
71
- * @param versionPath parsed version path
46
+ * @param versionPath parsed version path in project
72
47
  */
73
48
  downloadJSON: (versionPath: string) => Promise<UpdateJSON>;
74
49
  /**
@@ -101,4 +76,4 @@ interface IProvider {
101
76
  verifySignaure: (buffer: Buffer, version: string, signature: string, cert: string) => Promisable<boolean>;
102
77
  }
103
78
 
104
- export { type DownloadingInfo as D, type IProvider as I, type OnDownloading as O, type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, type URLHandler as c, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
79
+ export type { DownloadingInfo as D, IProvider as I, OnDownloading as O, URLHandler as U };
package/dist/utils.cjs CHANGED
@@ -205,16 +205,8 @@ function defaultVerifySignature(buffer, version, signature, cert) {
205
205
  }
206
206
  }
207
207
 
208
- // src/utils/updater.ts
209
- async function autoUpdate(updater) {
210
- if (await updater.checkUpdate() && await updater.downloadUpdate()) {
211
- updater.quitAndInstall();
212
- }
213
- }
214
-
215
208
  exports.aesDecrypt = aesDecrypt;
216
209
  exports.aesEncrypt = aesEncrypt;
217
- exports.autoUpdate = autoUpdate;
218
210
  exports.defaultIsLowerVersion = defaultIsLowerVersion;
219
211
  exports.defaultSignature = defaultSignature;
220
212
  exports.defaultUnzipFile = defaultUnzipFile;
package/dist/utils.d.cts CHANGED
@@ -1,9 +1,6 @@
1
1
  import { BrowserWindow } from 'electron';
2
2
  export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerifySignature, d as defaultZipFile, h as hashBuffer } from './zip-DPF5IFkK.cjs';
3
- export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './types-CItP6bL-.cjs';
4
- import { U as Updater } from './core-ZUlLHadf.cjs';
5
- import '@subframe7536/type-utils';
6
- import 'node:events';
3
+ export { a as UpdateInfo, U as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './version-DgfjJQUx.cjs';
7
4
 
8
5
  /**
9
6
  * compile time dev check
@@ -72,9 +69,4 @@ declare function getPathFromEntryAsar(...paths: string[]): string;
72
69
  */
73
70
  declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
74
71
 
75
- /**
76
- * auto check update, download and install
77
- */
78
- declare function autoUpdate(updater: Updater): Promise<void>;
79
-
80
- export { autoUpdate, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
72
+ export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
package/dist/utils.d.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  import { BrowserWindow } from 'electron';
2
2
  export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerifySignature, d as defaultZipFile, h as hashBuffer } from './zip-DPF5IFkK.js';
3
- export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './types-CItP6bL-.js';
4
- import { U as Updater } from './core-DJdvtwvU.js';
5
- import '@subframe7536/type-utils';
6
- import 'node:events';
3
+ export { a as UpdateInfo, U as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './version-DgfjJQUx.js';
7
4
 
8
5
  /**
9
6
  * compile time dev check
@@ -72,9 +69,4 @@ declare function getPathFromEntryAsar(...paths: string[]): string;
72
69
  */
73
70
  declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
74
71
 
75
- /**
76
- * auto check update, download and install
77
- */
78
- declare function autoUpdate(updater: Updater): Promise<void>;
79
-
80
- export { autoUpdate, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
72
+ export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
package/dist/utils.js CHANGED
@@ -1,12 +1,3 @@
1
1
  export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-4MH6ZXCY.js';
2
2
  export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer } from './chunk-KZSYEXLO.js';
3
3
  export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-72ZAJ7AF.js';
4
-
5
- // src/utils/updater.ts
6
- async function autoUpdate(updater) {
7
- if (await updater.checkUpdate() && await updater.downloadUpdate()) {
8
- updater.quitAndInstall();
9
- }
10
- }
11
-
12
- export { autoUpdate };
@@ -0,0 +1,27 @@
1
+ interface Version {
2
+ major: number;
3
+ minor: number;
4
+ patch: number;
5
+ stage: string;
6
+ stageVersion: number;
7
+ }
8
+ declare function parseVersion(version: string): Version;
9
+ declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
10
+ /**
11
+ * update info json
12
+ */
13
+ type UpdateInfo = {
14
+ signature: string;
15
+ minimumVersion: string;
16
+ version: string;
17
+ };
18
+ /**
19
+ * {@link UpdateInfo} with beta
20
+ */
21
+ type UpdateJSON = UpdateInfo & {
22
+ beta: UpdateInfo;
23
+ };
24
+ declare function isUpdateJSON(json: any): json is UpdateJSON;
25
+ declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
26
+
27
+ export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
@@ -0,0 +1,27 @@
1
+ interface Version {
2
+ major: number;
3
+ minor: number;
4
+ patch: number;
5
+ stage: string;
6
+ stageVersion: number;
7
+ }
8
+ declare function parseVersion(version: string): Version;
9
+ declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
10
+ /**
11
+ * update info json
12
+ */
13
+ type UpdateInfo = {
14
+ signature: string;
15
+ minimumVersion: string;
16
+ version: string;
17
+ };
18
+ /**
19
+ * {@link UpdateInfo} with beta
20
+ */
21
+ type UpdateJSON = UpdateInfo & {
22
+ beta: UpdateInfo;
23
+ };
24
+ declare function isUpdateJSON(json: any): json is UpdateJSON;
25
+ declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
26
+
27
+ export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
package/dist/vite.js CHANGED
@@ -16,7 +16,7 @@ import zlib from 'node:zlib';
16
16
  import crypto from 'node:crypto';
17
17
  import { generate } from 'selfsigned';
18
18
 
19
- // src/vite.ts
19
+ // src/vite/index.ts
20
20
 
21
21
  // src/utils/version.ts
22
22
  function parseVersion(version) {
@@ -64,7 +64,7 @@ var bytecodeId = `${id}-bytecode`;
64
64
  var log = createLogger("info", { prefix: `[${id}]` });
65
65
  var bytecodeLog = createLogger("info", { prefix: `[${bytecodeId}]` });
66
66
 
67
- // src/build-plugins/bytecode/code.ts
67
+ // src/vite/bytecode/code.ts
68
68
  var bytecodeGeneratorScript = "const vm = require('vm')\nconst v8 = require('v8')\nconst wrap = require('module').wrap\nv8.setFlagsFromString('--no-lazy')\nv8.setFlagsFromString('--no-flush-bytecode')\nlet code = ''\nprocess.stdin.setEncoding('utf-8')\nprocess.stdin.on('readable', () => {\n const data = process.stdin.read()\n if (data !== null) {\n code += data\n }\n})\nprocess.stdin.on('end', () => {\n try {\n if (typeof code !== 'string') {\n throw new Error('javascript code must be string.')\n }\n const script = new vm.Script(wrap(code), { produceCachedData: true })\n const bytecodeBuffer = script.createCachedData()\n process.stdout.write(bytecodeBuffer)\n } catch (error) {\n console.error(error)\n }\n})\n";
69
69
  var bytecodeModuleLoaderCode = '"use strict";\nconst fs = require("fs");\nconst path = require("path");\nconst vm = require("vm");\nconst v8 = require("v8");\nconst Module = require("module");\nv8.setFlagsFromString("--no-lazy");\nv8.setFlagsFromString("--no-flush-bytecode");\nconst FLAG_HASH_OFFSET = 12;\nconst SOURCE_HASH_OFFSET = 8;\nlet dummyBytecode;\nfunction setFlagHashHeader(bytecodeBuffer) {\n if (!dummyBytecode) {\n const script = new vm.Script("", {\n produceCachedData: true\n });\n dummyBytecode = script.createCachedData();\n }\n dummyBytecode.slice(FLAG_HASH_OFFSET, FLAG_HASH_OFFSET + 4).copy(bytecodeBuffer, FLAG_HASH_OFFSET);\n};\nfunction getSourceHashHeader(bytecodeBuffer) {\n return bytecodeBuffer.slice(SOURCE_HASH_OFFSET, SOURCE_HASH_OFFSET + 4);\n};\nfunction buffer2Number(buffer) {\n let ret = 0;\n ret |= buffer[3] << 24;\n ret |= buffer[2] << 16;\n ret |= buffer[1] << 8;\n ret |= buffer[0];\n return ret;\n};\nModule._extensions[".jsc"] = Module._extensions[".cjsc"] = function (module, filename) {\n const bytecodeBuffer = fs.readFileSync(filename);\n if (!Buffer.isBuffer(bytecodeBuffer)) {\n throw new Error("BytecodeBuffer must be a buffer object.");\n }\n setFlagHashHeader(bytecodeBuffer);\n const length = buffer2Number(getSourceHashHeader(bytecodeBuffer));\n let dummyCode = "";\n if (length > 1) {\n dummyCode = "\\"" + "\\u200b".repeat(length - 2) + "\\"";\n }\n const script = new vm.Script(dummyCode, {\n filename: filename,\n lineOffset: 0,\n displayErrors: true,\n cachedData: bytecodeBuffer\n });\n if (script.cachedDataRejected) {\n throw new Error("Invalid or incompatible cached data (cachedDataRejected)");\n }\n const require = function (id) {\n return module.require(id);\n };\n require.resolve = function (request, options) {\n return Module._resolveFilename(request, module, false, options);\n };\n if (process.mainModule) {\n require.main = process.mainModule;\n }\n require.extensions = Module._extensions;\n require.cache = Module._cache;\n const compiledWrapper = script.runInThisContext({\n filename: filename,\n lineOffset: 0,\n columnOffset: 0,\n displayErrors: true\n });\n const dirname = path.dirname(filename);\n const args = [module.exports, require, module, filename, dirname, process, global];\n return compiledWrapper.apply(module.exports, args);\n};\n';
70
70
  var electronModulePath = getPackageInfoSync("electron")?.rootPath;
@@ -129,7 +129,7 @@ function compileToBytecode(code) {
129
129
  proc.on("exit", () => resolve(data));
130
130
  });
131
131
  }
132
- function convertArrowToFunction(code) {
132
+ function convertArrowFunctionAndTemplate(code) {
133
133
  const result = babel.transform(code, {
134
134
  plugins: ["@babel/plugin-transform-arrow-functions", "@babel/plugin-transform-template-literals"]
135
135
  });
@@ -199,7 +199,7 @@ function convertLiteral(code, sourcemap, offset) {
199
199
  };
200
200
  }
201
201
 
202
- // src/build-plugins/utils.ts
202
+ // src/vite/utils.ts
203
203
  function readableSize(size) {
204
204
  const units = ["B", "KB", "MB", "GB"];
205
205
  let i = 0;
@@ -210,7 +210,7 @@ function readableSize(size) {
210
210
  return `${size.toFixed(2)} ${units[i]}`;
211
211
  }
212
212
 
213
- // src/build-plugins/build.ts
213
+ // src/vite/build.ts
214
214
  async function buildAsar({
215
215
  version,
216
216
  asarOutputPath,
@@ -297,21 +297,15 @@ async function buildEntry({
297
297
  overrideEsbuildOptions ?? {}
298
298
  );
299
299
  const { metafile } = await build(option);
300
- if (!bytecodeOptions || !bytecodeOptions.enable) {
300
+ if (!bytecodeOptions?.enable) {
301
301
  return;
302
302
  }
303
- const filePaths = Object.keys(metafile?.outputs ?? []);
303
+ const filePaths = Object.keys(metafile?.outputs ?? []).filter((filePath) => filePath.endsWith("js"));
304
304
  for (const filePath of filePaths) {
305
305
  let code = fs3.readFileSync(filePath, "utf-8");
306
306
  const fileName = path5.basename(filePath);
307
307
  const isEntry = fileName.endsWith("entry.js");
308
- if (isEntry) {
309
- code = code.replace(
310
- /(`-----BEGIN CERTIFICATE-----[\s\S]*-----END CERTIFICATE-----\n`)/,
311
- (_, cert) => `"${cert.slice(1, -1).replace(/\n/g, "\\n")}"`
312
- );
313
- }
314
- let transformedCode = convertLiteral(convertArrowToFunction(code).code).code;
308
+ let transformedCode = convertLiteral(convertArrowFunctionAndTemplate(code).code).code;
315
309
  if (bytecodeOptions.beforeCompile) {
316
310
  const result = await bytecodeOptions.beforeCompile(transformedCode, filePath);
317
311
  if (result) {
@@ -400,7 +394,7 @@ function parseSubjects(subject) {
400
394
  return Object.entries(subject).filter(([_, value]) => !!value).map(([name, value]) => ({ name, value }));
401
395
  }
402
396
 
403
- // src/build-plugins/option.ts
397
+ // src/vite/option.ts
404
398
  function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
405
399
  const {
406
400
  minimumVersion = "0.0.0",
@@ -521,7 +515,7 @@ function bytecodePlugin(env, options) {
521
515
  }
522
516
  if (chunk.type === "chunk") {
523
517
  bytecodeRequired = true;
524
- return convertArrowToFunction(code);
518
+ return convertArrowFunctionAndTemplate(code);
525
519
  }
526
520
  return null;
527
521
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.8",
4
+ "version": "2.0.0-beta.9",
5
5
  "description": "electron incremental update tools, powered by vite",
6
6
  "author": "subframe7536",
7
7
  "license": "MIT",
@@ -1,134 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import { a as UpdateJSON, U as UpdateInfo, D as DownloadingInfo, I as IProvider, c as URLHandler } from './types-CItP6bL-.js';
3
-
4
- declare const ErrorInfo: {
5
- readonly download: "Download failed";
6
- readonly validate: "Validate failed";
7
- readonly param: "Missing params";
8
- readonly network: "Network error";
9
- };
10
- declare class UpdaterError extends Error {
11
- code: keyof typeof ErrorInfo;
12
- constructor(msg: keyof typeof ErrorInfo, info: string);
13
- }
14
- type CheckResult<T extends UpdateJSON> = {
15
- success: true;
16
- data: Omit<T, 'beta'>;
17
- } | {
18
- success: false;
19
- /**
20
- * minimal version that can update
21
- */
22
- data: string;
23
- } | {
24
- success: false;
25
- data: UpdaterError;
26
- };
27
- type DownloadResult = {
28
- success: true;
29
- } | {
30
- success: false;
31
- data: UpdaterError;
32
- };
33
- interface Logger {
34
- info: (msg: string) => void;
35
- debug: (msg: string) => void;
36
- warn: (msg: string) => void;
37
- error: (msg: string, e?: unknown) => void;
38
- }
39
- interface UpdaterOption {
40
- /**
41
- * public key of signature, which will be auto generated by plugin,
42
- * generate by `selfsigned` if not set
43
- */
44
- SIGNATURE_CERT?: string;
45
- /**
46
- * whether to receive beta update
47
- */
48
- receiveBeta?: boolean;
49
- logger?: Logger;
50
- }
51
-
52
- declare class Updater extends EventEmitter<{
53
- 'checking': any;
54
- 'update-available': [data: UpdateInfo];
55
- 'update-unavailable': [reason: string];
56
- 'error': [error: UpdaterError];
57
- 'download-progress': [info: DownloadingInfo];
58
- 'update-downloaded': any;
59
- }> {
60
- private CERT;
61
- private info?;
62
- private provider;
63
- /**
64
- * updater logger
65
- */
66
- logger?: Logger;
67
- /**
68
- * whether to receive beta update
69
- */
70
- receiveBeta?: boolean;
71
- /**
72
- * whether force update in DEV
73
- */
74
- forceUpdate?: boolean;
75
- /**
76
- * initialize incremental updater
77
- * @param provider update provider
78
- * @param option UpdaterOption
79
- */
80
- constructor(provider: IProvider, option?: UpdaterOption);
81
- /**
82
- * this function is used to parse download data.
83
- * - if format is `'json'`
84
- * - if data is `UpdateJSON`, return it
85
- * - if data is string or absent, download URL data and return it
86
- * - if format is `'buffer'`
87
- * - if data is `Buffer`, return it
88
- * - if data is string or absent, download URL data and return it
89
- * @param format 'json' or 'buffer'
90
- * @param data download URL or update json or buffer
91
- */
92
- private fetch;
93
- /**
94
- * handle error message and emit error event
95
- */
96
- private err;
97
- /**
98
- * check update info using default options
99
- */
100
- checkUpdate(): Promise<boolean>;
101
- /**
102
- * check update info using existing update json
103
- * @param data existing update json
104
- */
105
- checkUpdate(data: UpdateJSON): Promise<boolean>;
106
- /**
107
- * download update using default options
108
- */
109
- downloadUpdate(): Promise<boolean>;
110
- /**
111
- * download update using existing `asar.gz` buffer and signature
112
- * @param data existing `asar.gz` buffer
113
- * @param info update info
114
- */
115
- downloadUpdate(data: Uint8Array, info: Omit<UpdateInfo, 'minimumVersion'>): Promise<boolean>;
116
- /**
117
- * quit App and install
118
- */
119
- quitAndInstall(): void;
120
- /**
121
- * setup provider URL handler
122
- *
123
- * @example
124
- * updater.setURLHandler((url, isDownloadingAsar) => {
125
- * if (isDownloadingAsar) {
126
- * url.hostname = 'https://cdn.jsdelivr.net/gh'
127
- * return url
128
- * }
129
- * })
130
- */
131
- setURLHandler(handler: URLHandler): void;
132
- }
133
-
134
- export { type CheckResult as C, type DownloadResult as D, ErrorInfo as E, type Logger as L, Updater as U, type UpdaterOption as a, UpdaterError as b };