electron-incremental-update 3.0.0-beta.6 → 3.0.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/README.md +45 -288
- package/dist/{zip-D1dbBzw4.cjs → crypto-BSky88mL.cjs} +39 -34
- package/dist/{zip-DUK3opmV.mjs → crypto-DZzMmoz2.mjs} +27 -22
- package/dist/{download-BjWmHHAu.d.cts → download-BVmLiAvB.d.cts} +2 -2
- package/dist/{download-BGaAyi1Z.mjs → download-BdX4fZYM.mjs} +13 -15
- package/dist/{download-DVWJfV3S.d.mts → download-GONr15zK.d.mts} +2 -2
- package/dist/{download-BYnkme_X.cjs → download-KySXUyWC.cjs} +14 -16
- package/dist/{electron-BInvFJ-W.mjs → electron-BrIF1urZ.mjs} +1 -1
- package/dist/{electron-D_8AbLQ5.cjs → electron-CaS0I3S2.cjs} +4 -4
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{local-s1cw_vwb.mjs → local-C5jw-7o5.mjs} +7 -7
- package/dist/{local-Daf8naRn.cjs → local-DbXBG1D9.cjs} +11 -11
- package/dist/provider.cjs +5 -5
- package/dist/provider.d.cts +9 -15
- package/dist/provider.d.mts +9 -15
- package/dist/provider.mjs +5 -5
- package/dist/{types-BOqQ_r5Q.d.mts → types-q78spjKB.d.cts} +17 -2
- package/dist/{types-BOqQ_r5Q.d.cts → types-q78spjKB.d.mts} +17 -2
- package/dist/utils.cjs +14 -14
- package/dist/utils.d.cts +6 -6
- package/dist/utils.d.mts +6 -6
- package/dist/utils.mjs +4 -4
- package/dist/vite.d.mts +14 -14
- package/dist/vite.mjs +38 -36
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -16,25 +16,15 @@ Lightweight incremental update tools for Electron applications built with Vite.
|
|
|
16
16
|
- [Plugin Options](#plugin-options)
|
|
17
17
|
- [Electron Builder](#electron-builder)
|
|
18
18
|
- [Runtime Usage](#runtime-usage)
|
|
19
|
-
- [Create The App](#create-the-app)
|
|
20
|
-
- [Updater API](#updater-api)
|
|
21
19
|
- [Providers](#providers)
|
|
22
|
-
- [
|
|
23
|
-
- [Default](#default)
|
|
24
|
-
- [Atom](#atom)
|
|
25
|
-
- [Api](#api)
|
|
26
|
-
- [URL Handling](#url-handling)
|
|
27
|
-
- [Local](#local)
|
|
28
|
-
- [Recommended Setup](#recommended-setup)
|
|
29
|
-
- [Custom Options](#custom-options)
|
|
30
|
-
- [Manual Provider](#manual-provider)
|
|
31
|
-
- [Testing The Local Flow](#testing-the-local-flow)
|
|
20
|
+
- [Testing The Local Flow](#testing-the-local-flow)
|
|
32
21
|
- [Update Artifacts](#update-artifacts)
|
|
33
22
|
- [Native Modules](#native-modules)
|
|
34
23
|
- [Result in app.asar](#result-in-appasar)
|
|
35
24
|
- [Bytecode Protection](#bytecode-protection)
|
|
36
25
|
- [Development Bundling](#development-bundling)
|
|
37
26
|
- [Utilities](#utilities)
|
|
27
|
+
- [API Reference](#api-reference)
|
|
38
28
|
- [Credits](#credits)
|
|
39
29
|
- [License](#license)
|
|
40
30
|
|
|
@@ -83,6 +73,8 @@ pnpm add -D electron-incremental-update @electron/asar @babel/core
|
|
|
83
73
|
yarn add -D electron-incremental-update @electron/asar @babel/core
|
|
84
74
|
```
|
|
85
75
|
|
|
76
|
+
> Upgrading from `3.0.0-beta.x`? See [MIGRATION.md](./MIGRATION.md).
|
|
77
|
+
|
|
86
78
|
## Quick Start
|
|
87
79
|
|
|
88
80
|
Recommended project layout:
|
|
@@ -202,7 +194,7 @@ export default defineElectronConfig({
|
|
|
202
194
|
minimumVersion: '0.0.0',
|
|
203
195
|
paths: {
|
|
204
196
|
asarOutputPath: 'release/my-app.asar',
|
|
205
|
-
|
|
197
|
+
compressedPath: 'release/my-app-1.0.0.asar.br',
|
|
206
198
|
versionPath: 'release/version.json',
|
|
207
199
|
},
|
|
208
200
|
},
|
|
@@ -242,7 +234,7 @@ export default defineConfig({
|
|
|
242
234
|
|
|
243
235
|
### Plugin Options
|
|
244
236
|
|
|
245
|
-
Common options:
|
|
237
|
+
Common options overview:
|
|
246
238
|
|
|
247
239
|
- `entry.files`: entry process input. Required.
|
|
248
240
|
- `main.files`: main process input. Required.
|
|
@@ -254,26 +246,10 @@ Common options:
|
|
|
254
246
|
- `external`: additional Vite/Rolldown externals. Use `true` to externalize `dependencies`.
|
|
255
247
|
- `buildVersionJson`: generates update JSON. Defaults to CI only.
|
|
256
248
|
- `localDevUpdate`: generates and serves a local update package during dev startup. Use `true`
|
|
257
|
-
for defaults, or pass `{ baseDir, packageJsonPath, chunkSize, chunkDelay }`. See [Local
|
|
249
|
+
for defaults, or pass `{ baseDir, packageJsonPath, chunkSize, chunkDelay }`. See [Testing The Local Flow](#testing-the-local-flow) for details.
|
|
258
250
|
- `updater.minimumVersion`: minimum supported entry asar version. Defaults to `0.0.0`.
|
|
259
251
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
- `updater.paths.asarOutputPath`: `release/${app.name}.asar`
|
|
263
|
-
- `updater.paths.gzipPath`: `release/${app.name}-${version}.asar.gz`
|
|
264
|
-
- `updater.paths.versionPath`: `release/version.json`
|
|
265
|
-
- `updater.paths.entryOutDir`: `dist-entry`
|
|
266
|
-
- `updater.paths.electronDistPath`: `dist-electron`
|
|
267
|
-
- `updater.paths.rendererDistPath`: `dist`
|
|
268
|
-
|
|
269
|
-
Signing keys:
|
|
270
|
-
|
|
271
|
-
- `updater.keys.privateKeyPath`: defaults to `keys/private.pem`
|
|
272
|
-
- `updater.keys.certPath`: defaults to `keys/cert.pem`
|
|
273
|
-
- `UPDATER_PK`: overrides `privateKeyPath`
|
|
274
|
-
- `UPDATER_CERT`: overrides `certPath`
|
|
275
|
-
|
|
276
|
-
The plugin creates a simple self-signed certificate when the key files are missing.
|
|
252
|
+
> 📖 See [API.md → Plugin Options](./API.md#plugin-options) for the complete reference including all types, defaults, paths, keys, and generator overrides.
|
|
277
253
|
|
|
278
254
|
## Electron Builder
|
|
279
255
|
|
|
@@ -316,231 +292,44 @@ module.exports = {
|
|
|
316
292
|
|
|
317
293
|
## Runtime Usage
|
|
318
294
|
|
|
319
|
-
### Create The App
|
|
320
|
-
|
|
321
295
|
```ts
|
|
322
296
|
import { createElectronApp } from 'electron-incremental-update'
|
|
297
|
+
import { GitHubProvider } from 'electron-incremental-update/provider'
|
|
323
298
|
|
|
324
299
|
createElectronApp({
|
|
325
300
|
updater: {
|
|
326
|
-
provider
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
onInstall(install, tempAsarPath, appNameAsarPath, logger) {
|
|
331
|
-
logger?.info(`Installing ${tempAsarPath} to ${appNameAsarPath}`)
|
|
332
|
-
install()
|
|
333
|
-
},
|
|
334
|
-
onStartError(error, logger) {
|
|
335
|
-
logger?.error('Failed to start app', error)
|
|
301
|
+
provider: new GitHubProvider({
|
|
302
|
+
user: 'your-github-user',
|
|
303
|
+
repo: 'your-repo',
|
|
304
|
+
}),
|
|
336
305
|
},
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
`updater` can also be an async factory:
|
|
341
|
-
|
|
342
|
-
```ts
|
|
343
|
-
createElectronApp({
|
|
344
|
-
updater: async () => {
|
|
345
|
-
const { Updater } = await import('electron-incremental-update')
|
|
346
|
-
return new Updater({ provider })
|
|
306
|
+
beforeStart(mainFilePath, logger) {
|
|
307
|
+
logger?.debug(`Starting app from ${mainFilePath}`)
|
|
347
308
|
},
|
|
348
309
|
})
|
|
349
310
|
```
|
|
350
311
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
```ts
|
|
354
|
-
updater.provider = provider
|
|
355
|
-
updater.receiveBeta = true
|
|
356
|
-
updater.logger = console
|
|
357
|
-
|
|
358
|
-
await updater.checkForUpdates()
|
|
359
|
-
await updater.downloadUpdate()
|
|
360
|
-
updater.cancel()
|
|
361
|
-
updater.quitAndInstall()
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
Events:
|
|
312
|
+
The full `Updater` API, `createElectronApp` options, `AppOption`, events, and error codes are documented in the API reference.
|
|
365
313
|
|
|
366
|
-
|
|
367
|
-
- `update-not-available`: emitted with a code, message, and optional update info.
|
|
368
|
-
- `download-progress`: emitted while downloading.
|
|
369
|
-
- `update-downloaded`: emitted after the temporary asar is ready.
|
|
370
|
-
- `update-cancelled`: emitted after cancellation.
|
|
371
|
-
- `error`: emitted with `UpdaterError`.
|
|
314
|
+
> 📖 See [API.md → Entry API](./API.md#entry-api) for the complete reference.
|
|
372
315
|
|
|
373
316
|
## Providers
|
|
374
317
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
GitHub providers read update metadata from a repository or release and download the generated
|
|
378
|
-
`{name}-{version}.asar.gz` artifact from GitHub Releases.
|
|
379
|
-
|
|
380
|
-
#### Default
|
|
381
|
-
|
|
382
|
-
Reads `version.json` from the repository branch and downloads the asar from GitHub Releases.
|
|
383
|
-
|
|
384
|
-
```ts
|
|
385
|
-
import { GitHubProvider } from 'electron-incremental-update/provider'
|
|
386
|
-
|
|
387
|
-
const provider = new GitHubProvider({
|
|
388
|
-
user: 'your-github-user',
|
|
389
|
-
repo: 'your-repo',
|
|
390
|
-
branch: 'HEAD',
|
|
391
|
-
})
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
Default URLs:
|
|
395
|
-
|
|
396
|
-
- update JSON: `https://github.com/{user}/{repo}/raw/{branch}/{versionPath}`
|
|
397
|
-
- asar: `https://github.com/{user}/{repo}/releases/download/v{version}/{name}-{version}.asar.gz`
|
|
398
|
-
|
|
399
|
-
#### Atom
|
|
400
|
-
|
|
401
|
-
Reads the latest release tag from `releases.atom`, then downloads the update JSON and asar from that release.
|
|
402
|
-
|
|
403
|
-
```ts
|
|
404
|
-
import { GitHubAtomProvider } from 'electron-incremental-update/provider'
|
|
405
|
-
|
|
406
|
-
const provider = new GitHubAtomProvider({
|
|
407
|
-
user: 'your-github-user',
|
|
408
|
-
repo: 'your-repo',
|
|
409
|
-
})
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
#### Api
|
|
413
|
-
|
|
414
|
-
Uses the GitHub Releases API and can use a token for private repositories or higher rate limits.
|
|
415
|
-
|
|
416
|
-
```ts
|
|
417
|
-
import { GitHubApiProvider } from 'electron-incremental-update/provider'
|
|
418
|
-
|
|
419
|
-
const provider = new GitHubApiProvider({
|
|
420
|
-
user: 'your-github-user',
|
|
421
|
-
repo: 'your-repo',
|
|
422
|
-
token: process.env.GITHUB_TOKEN,
|
|
423
|
-
})
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
#### URL Handling
|
|
427
|
-
|
|
428
|
-
GitHub providers support `urlHandler` for mirrors, custom gateways, or request rewriting.
|
|
429
|
-
|
|
430
|
-
```ts
|
|
431
|
-
const provider = new GitHubProvider({
|
|
432
|
-
user: 'your-github-user',
|
|
433
|
-
repo: 'your-repo',
|
|
434
|
-
urlHandler(url) {
|
|
435
|
-
url.hostname = 'mirror.example.com'
|
|
436
|
-
url.pathname = `https://github.com${url.pathname}`
|
|
437
|
-
return url
|
|
438
|
-
},
|
|
439
|
-
})
|
|
440
|
-
```
|
|
318
|
+
The package includes GitHub-based providers (file, atom, API) and a local development provider.
|
|
441
319
|
|
|
442
|
-
|
|
320
|
+
- **GitHubProvider** — reads `version.json` from a repository branch, downloads asar from Releases.
|
|
321
|
+
- **GitHubAtomProvider** — reads the latest release from `releases.atom`.
|
|
322
|
+
- **GitHubApiProvider** — uses the GitHub Releases API (supports tokens for private repos).
|
|
323
|
+
- **LocalDevProvider** — reads update artifacts from the local filesystem for dev testing.
|
|
443
324
|
|
|
444
|
-
|
|
445
|
-
`checkForUpdates()`, download progress, `update-downloaded`, and restart/install behavior without
|
|
446
|
-
publishing a GitHub release.
|
|
325
|
+
All GitHub providers support a `urlHandler` for mirrors and custom gateways.
|
|
447
326
|
|
|
448
|
-
|
|
449
|
-
`LocalDevProvider`.
|
|
327
|
+
See the [API reference](./API.md#providers) for the complete provider constructor options and method signatures.
|
|
450
328
|
|
|
451
|
-
|
|
329
|
+
### Testing The Local Flow
|
|
452
330
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
```ts
|
|
456
|
-
import { electronWithUpdater } from 'electron-incremental-update/vite'
|
|
457
|
-
import { defineConfig } from 'vite'
|
|
458
|
-
|
|
459
|
-
export default defineConfig({
|
|
460
|
-
plugins: [
|
|
461
|
-
electronWithUpdater({
|
|
462
|
-
entry: {
|
|
463
|
-
files: './electron/entry.ts',
|
|
464
|
-
},
|
|
465
|
-
main: {
|
|
466
|
-
files: './electron/main/index.ts',
|
|
467
|
-
},
|
|
468
|
-
preload: {
|
|
469
|
-
files: './electron/preload/index.ts',
|
|
470
|
-
},
|
|
471
|
-
localDevUpdate: true,
|
|
472
|
-
}),
|
|
473
|
-
],
|
|
474
|
-
})
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
When `localDevUpdate` is enabled in development:
|
|
478
|
-
|
|
479
|
-
- the Vite plugin creates a local update package before Electron starts
|
|
480
|
-
- `createElectronApp()` auto-configures `LocalDevProvider` when no explicit `updater.provider` is set
|
|
481
|
-
- dev-only `forceUpdate` is enabled so update checks are not skipped in development
|
|
482
|
-
- production builds keep the normal provider and signature behavior
|
|
483
|
-
|
|
484
|
-
The default generated files are:
|
|
485
|
-
|
|
486
|
-
- `release/local-update/release/version.json`
|
|
487
|
-
- `release/local-update/{name}-{version}.asar.gz`
|
|
488
|
-
- `DEV.asar`
|
|
489
|
-
- `DEV.asar.tmp` after `downloadUpdate()`
|
|
490
|
-
|
|
491
|
-
The generated update version is the next patch version from the installed local dev asar. For
|
|
492
|
-
example, if `DEV.asar` contains version `1.2.3`, the generated update is `1.2.4`.
|
|
493
|
-
|
|
494
|
-
#### Custom Options
|
|
495
|
-
|
|
496
|
-
```ts
|
|
497
|
-
export default defineConfig({
|
|
498
|
-
plugins: [
|
|
499
|
-
electronWithUpdater({
|
|
500
|
-
// ...
|
|
501
|
-
localDevUpdate: {
|
|
502
|
-
baseDir: 'release/local-update',
|
|
503
|
-
packageJsonPath: 'playground/package.json',
|
|
504
|
-
chunkSize: 32 * 1024,
|
|
505
|
-
chunkDelay: 50,
|
|
506
|
-
},
|
|
507
|
-
}),
|
|
508
|
-
],
|
|
509
|
-
})
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
Options:
|
|
513
|
-
|
|
514
|
-
- `baseDir`: directory for generated local update resources. Defaults to `release/local-update`.
|
|
515
|
-
- `packageJsonPath`: package metadata used for update name/version. Defaults to the project
|
|
516
|
-
`package.json`.
|
|
517
|
-
- `chunkSize`: bytes per simulated download progress chunk. Defaults to `64 * 1024`.
|
|
518
|
-
- `chunkDelay`: delay between progress chunks in milliseconds. Defaults to `30`.
|
|
519
|
-
|
|
520
|
-
`chunkSize` must be greater than `0`, and `chunkDelay` must be greater than or equal to `0`.
|
|
521
|
-
|
|
522
|
-
#### Manual Provider
|
|
523
|
-
|
|
524
|
-
Use `LocalDevProvider` directly only when you need to wire local artifacts yourself.
|
|
525
|
-
|
|
526
|
-
```ts
|
|
527
|
-
import { LocalDevProvider } from 'electron-incremental-update/provider'
|
|
528
|
-
|
|
529
|
-
const provider = new LocalDevProvider({
|
|
530
|
-
baseDir: 'release/local-update',
|
|
531
|
-
chunkSize: 32 * 1024,
|
|
532
|
-
chunkDelay: 50,
|
|
533
|
-
})
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
It reads:
|
|
537
|
-
|
|
538
|
-
- `{baseDir}/{versionPath}`
|
|
539
|
-
- `{baseDir}/{name}-{version}.asar.gz`
|
|
540
|
-
|
|
541
|
-
#### Testing The Local Flow
|
|
542
|
-
|
|
543
|
-
Use the [playground](./playground) as a complete local update test:
|
|
331
|
+
Prefer `localDevUpdate: true` in the Vite plugin over constructing `LocalDevProvider` manually.
|
|
332
|
+
See [playground](./playground) as a complete local update test:
|
|
544
333
|
|
|
545
334
|
```sh
|
|
546
335
|
bun run play
|
|
@@ -567,7 +356,7 @@ local provider setup is skipped.
|
|
|
567
356
|
The Vite plugin can generate:
|
|
568
357
|
|
|
569
358
|
- `${app.name}.asar`
|
|
570
|
-
- `${app.name}-${version}.asar.
|
|
359
|
+
- `${app.name}-${version}.asar.br`
|
|
571
360
|
- `version.json`
|
|
572
361
|
|
|
573
362
|
Default `version.json` shape:
|
|
@@ -589,6 +378,15 @@ Stable releases update both the top-level fields and `beta`. Prerelease versions
|
|
|
589
378
|
|
|
590
379
|
Set `buildVersionJson: true` if you need metadata during non-CI builds.
|
|
591
380
|
|
|
381
|
+
> [!NOTE]
|
|
382
|
+
> The **default** version parser supports `major.minor.patch[-prerelease[.number]]` (e.g. `1.0.0-beta.1`).
|
|
383
|
+
> Build metadata (`+build`) and complex semver prerelease identifiers (e.g. `1.0.0-beta.1.2`)
|
|
384
|
+
> are not supported by default.
|
|
385
|
+
>
|
|
386
|
+
> To use full semver or a custom version scheme, override
|
|
387
|
+
> [`provider.isLowerVersion`](#providers) with your own comparator
|
|
388
|
+
> (e.g. `semver.lt` from the `semver` package).
|
|
389
|
+
|
|
592
390
|
## Native Modules
|
|
593
391
|
|
|
594
392
|
To keep update packages small, put native modules and their native binaries in `app.asar`, then load them from the main process with `requireNative()` or `importNative()`.
|
|
@@ -676,7 +474,7 @@ module.exports = {
|
|
|
676
474
|
}
|
|
677
475
|
```
|
|
678
476
|
|
|
679
|
-
|
|
477
|
+
### Result in app.asar
|
|
680
478
|
|
|
681
479
|
Before: Redundant 🤮
|
|
682
480
|
|
|
@@ -785,56 +583,15 @@ electronWithUpdater({
|
|
|
785
583
|
|
|
786
584
|
## Utilities
|
|
787
585
|
|
|
788
|
-
Import from `electron-incremental-update/utils
|
|
586
|
+
Import from `electron-incremental-update/utils` for path helpers, platform checks, native module loading, crypto, compression, download, and version parsing utilities.
|
|
789
587
|
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
defaultIsLowerVersion,
|
|
796
|
-
defaultSignature,
|
|
797
|
-
defaultUnzipFile,
|
|
798
|
-
defaultVerifySignature,
|
|
799
|
-
defaultZipFile,
|
|
800
|
-
getAppVersion,
|
|
801
|
-
getEntryVersion,
|
|
802
|
-
getPathFromAppNameAsar,
|
|
803
|
-
getPathFromEntryAsar,
|
|
804
|
-
getPathFromMain,
|
|
805
|
-
getPathFromPreload,
|
|
806
|
-
getPathFromPublic,
|
|
807
|
-
handleUnexpectedErrors,
|
|
808
|
-
hashBuffer,
|
|
809
|
-
importNative,
|
|
810
|
-
isDev,
|
|
811
|
-
isLinux,
|
|
812
|
-
isMac,
|
|
813
|
-
isWin,
|
|
814
|
-
loadPage,
|
|
815
|
-
parseVersion,
|
|
816
|
-
requireNative,
|
|
817
|
-
restartApp,
|
|
818
|
-
setAppUserModelId,
|
|
819
|
-
setPortableDataPath,
|
|
820
|
-
singleInstance,
|
|
821
|
-
} from 'electron-incremental-update/utils'
|
|
822
|
-
```
|
|
588
|
+
> 📖 See [API.md → Utilities API](./API.md#utilities-api) for the complete function list with signatures and descriptions.
|
|
589
|
+
|
|
590
|
+
## API Reference
|
|
591
|
+
|
|
592
|
+
For the full API documentation including all types, options tables, provider constructors, and plugin configuration, see the standalone reference:
|
|
823
593
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
- `getPathFromAppNameAsar(...paths)`: path inside `${app.name}.asar`.
|
|
827
|
-
- `getPathFromEntryAsar(...paths)`: path inside `app.asar`.
|
|
828
|
-
- `getPathFromMain(...paths)`: path inside the built main directory.
|
|
829
|
-
- `getPathFromPreload(...paths)`: path inside the built preload directory.
|
|
830
|
-
- `getPathFromPublic(...paths)`: path inside `public` in dev or renderer output in production.
|
|
831
|
-
- `getAppVersion()`: current app version. In dev, returns the entry version.
|
|
832
|
-
- `getEntryVersion()`: version from Electron app metadata.
|
|
833
|
-
- `loadPage(win, htmlFilePath)`: loads `VITE_DEV_SERVER_URL` in dev or renderer HTML in production.
|
|
834
|
-
- `singleInstance(window)`: restores and focuses the window on `second-instance`.
|
|
835
|
-
- `setPortableDataPath(dirName, create)`: stores user data beside the executable for portable apps.
|
|
836
|
-
- `requireNative(moduleName)`: loads a CommonJS native helper from entry asar.
|
|
837
|
-
- `importNative(moduleName)`: imports an ES module native helper from entry asar.
|
|
594
|
+
> 📖 **[API.md](./API.md)** — Auto-generated JSDoc extraction + manual reference sections.
|
|
838
595
|
|
|
839
596
|
## Credits
|
|
840
597
|
|
|
@@ -20,14 +20,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
//#endregion
|
|
23
|
-
let node_crypto = require("node:crypto");
|
|
24
|
-
node_crypto = __toESM(node_crypto, 1);
|
|
25
23
|
let node_zlib = require("node:zlib");
|
|
26
24
|
node_zlib = __toESM(node_zlib, 1);
|
|
25
|
+
let node_crypto = require("node:crypto");
|
|
26
|
+
node_crypto = __toESM(node_crypto, 1);
|
|
27
27
|
//#region src/utils/version.ts
|
|
28
28
|
const REG_VERSION = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9]+)(?:\.(\d+))?)?$/i;
|
|
29
29
|
/**
|
|
30
30
|
* Parse version string to {@link Version}, like `0.2.0-beta.1`
|
|
31
|
+
*
|
|
32
|
+
* **Supported format**: `major.minor.patch[-stage[.stageVersion]]`
|
|
33
|
+
*
|
|
34
|
+
* Build metadata (`+build`) and complex semver prerelease identifiers
|
|
35
|
+
* (e.g. `1.0.0-beta.1.2`) are not supported yet.
|
|
31
36
|
* @param version version string
|
|
32
37
|
*/
|
|
33
38
|
function parseVersion(version) {
|
|
@@ -119,6 +124,26 @@ function defaultVersionJsonGenerator(existingJson, signature, version, minimumVe
|
|
|
119
124
|
return existingJson;
|
|
120
125
|
}
|
|
121
126
|
//#endregion
|
|
127
|
+
//#region src/utils/compress.ts
|
|
128
|
+
/**
|
|
129
|
+
* Default function to compress file using brotli
|
|
130
|
+
* @param buffer uncompressed file buffer
|
|
131
|
+
*/
|
|
132
|
+
async function defaultCompressFile(buffer) {
|
|
133
|
+
return new Promise((resolve, reject) => {
|
|
134
|
+
node_zlib.default.brotliCompress(buffer, (err, buffer) => err ? reject(err) : resolve(buffer));
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Default function to decompress file using brotli
|
|
139
|
+
* @param buffer compressed file buffer
|
|
140
|
+
*/
|
|
141
|
+
async function defaultDecompressFile(buffer) {
|
|
142
|
+
return new Promise((resolve, reject) => {
|
|
143
|
+
node_zlib.default.brotliDecompress(buffer, (err, buffer) => err ? reject(err) : resolve(buffer));
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
122
147
|
//#region src/utils/crypto.ts
|
|
123
148
|
function hashBuffer(data, length) {
|
|
124
149
|
const hash = node_crypto.default.createHash("SHA256").update(data).digest("binary");
|
|
@@ -160,26 +185,6 @@ function defaultVerifySignature(buffer, version, signature, cert) {
|
|
|
160
185
|
}
|
|
161
186
|
}
|
|
162
187
|
//#endregion
|
|
163
|
-
//#region src/utils/zip.ts
|
|
164
|
-
/**
|
|
165
|
-
* Default function to compress file using brotli
|
|
166
|
-
* @param buffer uncompressed file buffer
|
|
167
|
-
*/
|
|
168
|
-
async function defaultZipFile(buffer) {
|
|
169
|
-
return new Promise((resolve, reject) => {
|
|
170
|
-
node_zlib.default.brotliCompress(buffer, (err, buffer) => err ? reject(err) : resolve(buffer));
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Default function to decompress file using brotli
|
|
175
|
-
* @param buffer compressed file buffer
|
|
176
|
-
*/
|
|
177
|
-
async function defaultUnzipFile(buffer) {
|
|
178
|
-
return new Promise((resolve, reject) => {
|
|
179
|
-
node_zlib.default.brotliDecompress(buffer, (err, buffer) => err ? reject(err) : resolve(buffer));
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
//#endregion
|
|
183
188
|
Object.defineProperty(exports, "__toESM", {
|
|
184
189
|
enumerable: true,
|
|
185
190
|
get: function() {
|
|
@@ -198,40 +203,40 @@ Object.defineProperty(exports, "aesEncrypt", {
|
|
|
198
203
|
return aesEncrypt;
|
|
199
204
|
}
|
|
200
205
|
});
|
|
201
|
-
Object.defineProperty(exports, "
|
|
206
|
+
Object.defineProperty(exports, "defaultCompressFile", {
|
|
202
207
|
enumerable: true,
|
|
203
208
|
get: function() {
|
|
204
|
-
return
|
|
209
|
+
return defaultCompressFile;
|
|
205
210
|
}
|
|
206
211
|
});
|
|
207
|
-
Object.defineProperty(exports, "
|
|
212
|
+
Object.defineProperty(exports, "defaultDecompressFile", {
|
|
208
213
|
enumerable: true,
|
|
209
214
|
get: function() {
|
|
210
|
-
return
|
|
215
|
+
return defaultDecompressFile;
|
|
211
216
|
}
|
|
212
217
|
});
|
|
213
|
-
Object.defineProperty(exports, "
|
|
218
|
+
Object.defineProperty(exports, "defaultIsLowerVersion", {
|
|
214
219
|
enumerable: true,
|
|
215
220
|
get: function() {
|
|
216
|
-
return
|
|
221
|
+
return defaultIsLowerVersion;
|
|
217
222
|
}
|
|
218
223
|
});
|
|
219
|
-
Object.defineProperty(exports, "
|
|
224
|
+
Object.defineProperty(exports, "defaultSignature", {
|
|
220
225
|
enumerable: true,
|
|
221
226
|
get: function() {
|
|
222
|
-
return
|
|
227
|
+
return defaultSignature;
|
|
223
228
|
}
|
|
224
229
|
});
|
|
225
|
-
Object.defineProperty(exports, "
|
|
230
|
+
Object.defineProperty(exports, "defaultVerifySignature", {
|
|
226
231
|
enumerable: true,
|
|
227
232
|
get: function() {
|
|
228
|
-
return
|
|
233
|
+
return defaultVerifySignature;
|
|
229
234
|
}
|
|
230
235
|
});
|
|
231
|
-
Object.defineProperty(exports, "
|
|
236
|
+
Object.defineProperty(exports, "defaultVersionJsonGenerator", {
|
|
232
237
|
enumerable: true,
|
|
233
238
|
get: function() {
|
|
234
|
-
return
|
|
239
|
+
return defaultVersionJsonGenerator;
|
|
235
240
|
}
|
|
236
241
|
});
|
|
237
242
|
Object.defineProperty(exports, "hashBuffer", {
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import crypto from "node:crypto";
|
|
2
1
|
import zlib from "node:zlib";
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
3
|
//#region src/utils/version.ts
|
|
4
4
|
const REG_VERSION = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9]+)(?:\.(\d+))?)?$/i;
|
|
5
5
|
/**
|
|
6
6
|
* Parse version string to {@link Version}, like `0.2.0-beta.1`
|
|
7
|
+
*
|
|
8
|
+
* **Supported format**: `major.minor.patch[-stage[.stageVersion]]`
|
|
9
|
+
*
|
|
10
|
+
* Build metadata (`+build`) and complex semver prerelease identifiers
|
|
11
|
+
* (e.g. `1.0.0-beta.1.2`) are not supported yet.
|
|
7
12
|
* @param version version string
|
|
8
13
|
*/
|
|
9
14
|
function parseVersion(version) {
|
|
@@ -95,6 +100,26 @@ function defaultVersionJsonGenerator(existingJson, signature, version, minimumVe
|
|
|
95
100
|
return existingJson;
|
|
96
101
|
}
|
|
97
102
|
//#endregion
|
|
103
|
+
//#region src/utils/compress.ts
|
|
104
|
+
/**
|
|
105
|
+
* Default function to compress file using brotli
|
|
106
|
+
* @param buffer uncompressed file buffer
|
|
107
|
+
*/
|
|
108
|
+
async function defaultCompressFile(buffer) {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
zlib.brotliCompress(buffer, (err, buffer) => err ? reject(err) : resolve(buffer));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Default function to decompress file using brotli
|
|
115
|
+
* @param buffer compressed file buffer
|
|
116
|
+
*/
|
|
117
|
+
async function defaultDecompressFile(buffer) {
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
zlib.brotliDecompress(buffer, (err, buffer) => err ? reject(err) : resolve(buffer));
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
98
123
|
//#region src/utils/crypto.ts
|
|
99
124
|
function hashBuffer(data, length) {
|
|
100
125
|
const hash = crypto.createHash("SHA256").update(data).digest("binary");
|
|
@@ -136,24 +161,4 @@ function defaultVerifySignature(buffer, version, signature, cert) {
|
|
|
136
161
|
}
|
|
137
162
|
}
|
|
138
163
|
//#endregion
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Default function to compress file using brotli
|
|
142
|
-
* @param buffer uncompressed file buffer
|
|
143
|
-
*/
|
|
144
|
-
async function defaultZipFile(buffer) {
|
|
145
|
-
return new Promise((resolve, reject) => {
|
|
146
|
-
zlib.brotliCompress(buffer, (err, buffer) => err ? reject(err) : resolve(buffer));
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Default function to decompress file using brotli
|
|
151
|
-
* @param buffer compressed file buffer
|
|
152
|
-
*/
|
|
153
|
-
async function defaultUnzipFile(buffer) {
|
|
154
|
-
return new Promise((resolve, reject) => {
|
|
155
|
-
zlib.brotliDecompress(buffer, (err, buffer) => err ? reject(err) : resolve(buffer));
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
//#endregion
|
|
159
|
-
export { defaultSignature as a, defaultIsLowerVersion as c, parseVersion as d, aesEncrypt as i, defaultVersionJsonGenerator as l, defaultZipFile as n, defaultVerifySignature as o, aesDecrypt as r, hashBuffer as s, defaultUnzipFile as t, isUpdateJSON as u };
|
|
164
|
+
export { hashBuffer as a, defaultIsLowerVersion as c, parseVersion as d, defaultVerifySignature as i, defaultVersionJsonGenerator as l, aesEncrypt as n, defaultCompressFile as o, defaultSignature as r, defaultDecompressFile as s, aesDecrypt as t, isUpdateJSON as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as Arrayable, s as UpdateJSON, t as DownloadingInfo } from "./types-
|
|
1
|
+
import { p as Arrayable, s as UpdateJSON, t as DownloadingInfo } from "./types-q78spjKB.cjs";
|
|
2
2
|
import { ClientRequest, IncomingMessage } from "electron";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/download.d.ts
|
|
@@ -8,7 +8,7 @@ import { ClientRequest, IncomingMessage } from "electron";
|
|
|
8
8
|
* @param key target header key
|
|
9
9
|
*/
|
|
10
10
|
declare function getHeader(headers: Record<string, Arrayable<string>>, key: any): any;
|
|
11
|
-
declare function downloadUtil<T>(url: string, headers: Record<string, any>, onResponse: (req: ClientRequest, resp: IncomingMessage, resolve: (data: T) => void, reject: (e: any) => void) => void): Promise<T>;
|
|
11
|
+
declare function downloadUtil<T>(url: string, headers: Record<string, any>, onResponse: (req: ClientRequest, resp: IncomingMessage, resolve: (data: T) => void, reject: (e: any) => void) => void, signal?: AbortSignal): Promise<T>;
|
|
12
12
|
type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: any) => void) => void;
|
|
13
13
|
declare const resolveJson: ResolveDataFn;
|
|
14
14
|
/**
|