electron-incremental-update 0.8.5 → 0.8.7

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/vite.mjs CHANGED
@@ -1,14 +1,11 @@
1
1
  import {
2
+ isUpdateJSON,
2
3
  signature
3
- } from "./chunk-GXZSAUBR.mjs";
4
+ } from "./chunk-5BZLJPHJ.mjs";
4
5
  import {
5
6
  parseVersion,
6
7
  zipFile
7
- } from "./chunk-CR6HTU6P.mjs";
8
- import {
9
- isUpdateJSON
10
- } from "./chunk-2JVXVTC5.mjs";
11
- import "./chunk-ZFXKCRJC.mjs";
8
+ } from "./chunk-CMBFI77K.mjs";
12
9
 
13
10
  // src/vite.ts
14
11
  import { createLogger } from "vite";
@@ -143,7 +140,6 @@ function writeCertToMain(entryPath, cert) {
143
140
  !isMatched && lines.push(r);
144
141
  replaced = lines.join(eol);
145
142
  }
146
- console.log(JSON.stringify(replaced));
147
143
  writeFileSync(entryPath, replaced);
148
144
  }
149
145
  function parseKeys({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "author": "subframe7536",
4
- "version": "0.8.5",
4
+ "version": "0.8.7",
5
5
  "description": "electron incremental update tools, powered by vite",
6
6
  "scripts": {
7
7
  "build": "tsup && node fix-module.js",
@@ -1,9 +0,0 @@
1
- // src/updateJson.ts
2
- function isUpdateJSON(json) {
3
- const is = (j) => "signature" in j && "version" in j && "size" in j && "minimumVersion" in j;
4
- return is(json) && "beta" in json && is(json.beta);
5
- }
6
-
7
- export {
8
- isUpdateJSON
9
- };
@@ -1,170 +0,0 @@
1
- import {
2
- __require
3
- } from "./chunk-ZFXKCRJC.mjs";
4
-
5
- // src/utils.ts
6
- import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
7
- import { dirname, join } from "node:path";
8
- import { gunzip, gzip } from "node:zlib";
9
- import Electron from "electron";
10
- var info = {
11
- dev: !Electron.app?.isPackaged,
12
- platform: process.platform === "win32" ? "win" : process.platform === "darwin" ? "mac" : "linux",
13
- appPath: Electron.app?.getAppPath()
14
- };
15
- function getProductAsarPath(name) {
16
- return info.dev ? "dev.asar" : join(dirname(info.appPath), `${name}.asar`);
17
- }
18
- function getEntryVersion() {
19
- return Electron.app.getVersion();
20
- }
21
- function getProductVersion(name) {
22
- return info.dev ? getEntryVersion() : readFileSync(join(getProductAsarPath(name), "version"), "utf-8");
23
- }
24
- var NoSuchNativeModuleError = class extends Error {
25
- moduleName;
26
- constructor(moduleName) {
27
- super(`no such native module: ${moduleName}`);
28
- this.moduleName = moduleName;
29
- }
30
- };
31
- function requireNative(packageName) {
32
- const path = info.dev ? packageName : join(info.appPath, "node_modules", packageName);
33
- try {
34
- return __require(path);
35
- } catch (error) {
36
- throw new NoSuchNativeModuleError(packageName);
37
- }
38
- }
39
- function parseGithubCdnURL(repository, cdnPrefix, relativeFilePath) {
40
- if (!repository.startsWith("https://github.com/")) {
41
- throw new Error("url must start with https://github.com/");
42
- }
43
- repository = repository.trim().replace(/\/?$/, "/").trim();
44
- relativeFilePath = relativeFilePath.trim().replace(/^\/|\/?$/g, "").trim();
45
- cdnPrefix = cdnPrefix.trim().replace(/^\/?|\/?$/g, "").trim();
46
- return repository.replace("github.com", cdnPrefix) + relativeFilePath;
47
- }
48
- function getGithubFileCdnGroup() {
49
- return [
50
- { cdnPrefix: "cdn.jsdelivr.net/gh", source: "jsdelivr" },
51
- { cdnPrefix: "fastly.jsdelivr.net/gh", source: "jsdelivr-fastly" },
52
- { cdnPrefix: "cdn.statically.io/gh", source: "statically" },
53
- { cdnPrefix: "rawcdn.githack.com/gh", source: "githack" },
54
- { cdnPrefix: "raw.githack.com/gh", source: "githack-dev" }
55
- ];
56
- }
57
- function getGithubReleaseCdnGroup() {
58
- return [
59
- { cdnPrefix: "gh.gh2233.ml", source: "@X.I.U/XIU2" },
60
- { cdnPrefix: "ghproxy.com", source: "gh-proxy" },
61
- { cdnPrefix: "gh.ddlc.top", source: "@mtr-static-official" },
62
- { cdnPrefix: "ghdl.feizhuqwq.cf", source: "feizhuqwq.com" },
63
- { cdnPrefix: "slink.ltd", source: "\u77E5\u4E86\u5C0F\u7AD9" },
64
- { cdnPrefix: "git.xfj0.cn", source: "anonymous1" },
65
- { cdnPrefix: "gh.con.sh", source: "anonymous2" },
66
- { cdnPrefix: "ghps.cc", source: "anonymous3" },
67
- { cdnPrefix: "cors.isteed.cc/github.com", source: "Lufs's" },
68
- { cdnPrefix: "hub.gitmirror.com", source: "GitMirror" },
69
- { cdnPrefix: "js.xxooo.ml", source: "\u996D\u592A\u786C" },
70
- { cdnPrefix: "download.njuu.cf", source: "LibraryCloud-njuu" },
71
- { cdnPrefix: "download.yzuu.cf", source: "LibraryCloud-yzuu" },
72
- { cdnPrefix: "download.nuaa.cf", source: "LibraryCloud-nuaa" }
73
- ];
74
- }
75
- function restartApp() {
76
- Electron.app.relaunch();
77
- Electron.app.quit();
78
- }
79
- function waitAppReady(duration = 1e3) {
80
- return new Promise((resolve, reject) => {
81
- const timeout = setTimeout(() => {
82
- reject(new Error("app is not ready"));
83
- }, duration);
84
- Electron.app.whenReady().then(() => {
85
- clearTimeout(timeout);
86
- resolve();
87
- });
88
- });
89
- }
90
- async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
91
- if (!existsSync(gzipPath)) {
92
- throw new Error(`path to zipped file not exist: ${gzipPath}`);
93
- }
94
- const compressedBuffer = readFileSync(gzipPath);
95
- return new Promise((resolve, reject) => {
96
- gunzip(compressedBuffer, (err, buffer) => {
97
- rmSync(gzipPath);
98
- if (err) {
99
- reject(err);
100
- }
101
- writeFileSync(targetFilePath, buffer);
102
- resolve(null);
103
- });
104
- });
105
- }
106
- async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
107
- if (!existsSync(filePath)) {
108
- throw new Error(`path to be zipped not exist: ${filePath}`);
109
- }
110
- const buffer = readFileSync(filePath);
111
- return new Promise((resolve, reject) => {
112
- gzip(buffer, (err, buffer2) => {
113
- if (err) {
114
- reject(err);
115
- }
116
- writeFileSync(targetFilePath, buffer2);
117
- resolve(null);
118
- });
119
- });
120
- }
121
- function handleUnexpectedErrors(callback) {
122
- const listener = (err) => {
123
- const e = err instanceof Error ? err : new Error(typeof err === "string" ? err : JSON.stringify(err));
124
- callback(e);
125
- };
126
- process.on("uncaughtException", listener);
127
- process.on("unhandledRejection", listener);
128
- }
129
- function parseVersion(version) {
130
- const semver = /^(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9\.-]+))?/i;
131
- const match = semver.exec(version);
132
- if (!match) {
133
- throw new TypeError(`invalid version: ${version}`);
134
- }
135
- const [major, minor, patch] = match.slice(1, 4).map(Number);
136
- const ret = {
137
- major,
138
- minor,
139
- patch,
140
- stage: "",
141
- stageVersion: -1
142
- };
143
- if (match[4]) {
144
- let [stage, _v] = match[4].split(".");
145
- ret.stage = stage;
146
- ret.stageVersion = Number(_v) || -1;
147
- }
148
- if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) || Number.isNaN(ret.stageVersion)) {
149
- throw new TypeError(`invalid version: ${version}`);
150
- }
151
- return ret;
152
- }
153
-
154
- export {
155
- info,
156
- getProductAsarPath,
157
- getEntryVersion,
158
- getProductVersion,
159
- NoSuchNativeModuleError,
160
- requireNative,
161
- parseGithubCdnURL,
162
- getGithubFileCdnGroup,
163
- getGithubReleaseCdnGroup,
164
- restartApp,
165
- waitAppReady,
166
- unzipFile,
167
- zipFile,
168
- handleUnexpectedErrors,
169
- parseVersion
170
- };
@@ -1,11 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined")
5
- return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
-
9
- export {
10
- __require
11
- };
@@ -1,12 +0,0 @@
1
- type UpdateInfo = {
2
- signature: string;
3
- minimumVersion: string;
4
- version: string;
5
- size: number;
6
- };
7
- type UpdateJSON = UpdateInfo & {
8
- beta: UpdateInfo;
9
- };
10
- declare function isUpdateJSON(json: any): json is UpdateJSON;
11
-
12
- export { UpdateInfo, UpdateJSON, isUpdateJSON };
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/updateJson.ts
21
- var updateJson_exports = {};
22
- __export(updateJson_exports, {
23
- isUpdateJSON: () => isUpdateJSON
24
- });
25
- module.exports = __toCommonJS(updateJson_exports);
26
- function isUpdateJSON(json) {
27
- const is = (j) => "signature" in j && "version" in j && "size" in j && "minimumVersion" in j;
28
- return is(json) && "beta" in json && is(json.beta);
29
- }
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- isUpdateJSON
33
- });
@@ -1,7 +0,0 @@
1
- import {
2
- isUpdateJSON
3
- } from "./chunk-2JVXVTC5.mjs";
4
- import "./chunk-ZFXKCRJC.mjs";
5
- export {
6
- isUpdateJSON
7
- };