@faynosync/electron 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/LICENSE +201 -0
- package/README.md +127 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/storage.d.ts +8 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +57 -0
- package/dist/storage.js.map +1 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/updater.d.ts +48 -0
- package/dist/updater.d.ts.map +1 -0
- package/dist/updater.js +402 -0
- package/dist/updater.js.map +1 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +34 -0
- package/dist/utils.js.map +1 -0
- package/package.json +52 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,128 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @faynosync/electron
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Drop-in auto-update for Electron apps served by [faynoSync](https://faynosync.com). It asks faynoSync whether an update exists (edge first, API fallback, telemetry included), then hands the electron-builder feed to `electron-updater` for download, differential download and install.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @faynosync/electron electron-updater
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`electron` and `electron-updater` are peer dependencies.
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { app, Menu } from 'electron';
|
|
17
|
+
import { initFaynoSync } from '@faynosync/electron';
|
|
18
|
+
|
|
19
|
+
const updater = initFaynoSync({
|
|
20
|
+
baseURL: 'https://faynosync.example.com',
|
|
21
|
+
edgeURL: 'https://cdn.example.com',
|
|
22
|
+
owner: 'admin',
|
|
23
|
+
appName: 'my-app',
|
|
24
|
+
channels: { stable: 'stable', beta: 'nightly' },
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
app.whenReady().then(() => {
|
|
28
|
+
Menu.setApplicationMenu(
|
|
29
|
+
Menu.buildFromTemplate([{ label: 'Updates', submenu: updater.menuItems() }])
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
That is all for the default native UI: a check on startup, a check when the main window gains focus (at most every 30 minutes), a confirmation dialog, a progress window and a restart prompt. Critical releases download without asking. Releases without an electron-builder feed open the installer download in the browser.
|
|
35
|
+
|
|
36
|
+
## Options
|
|
37
|
+
|
|
38
|
+
| Option | Default | Description |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `baseURL` | required | faynoSync API URL. |
|
|
41
|
+
| `edgeURL` | | CDN edge URL, tried before the API. |
|
|
42
|
+
| `owner`, `appName` | required | App owner and name in faynoSync. |
|
|
43
|
+
| `version` | `app.getVersion()` | Version reported to faynoSync. |
|
|
44
|
+
| `channels` | `{ stable: 'stable' }` | Channel names. Setting `beta` adds a "Beta Channel" checkbox to `menuItems()`; the choice is stored in `userData`. |
|
|
45
|
+
| `archOverrides` | | Arch to report per platform, e.g. `{ darwin: 'universal' }` for universal macOS builds. |
|
|
46
|
+
| `ui` | `'native'` | `'none'` shows nothing and only emits events. |
|
|
47
|
+
| `autoDownload` | `false` | Download without asking. |
|
|
48
|
+
| `checkOnStartup` | `true` | Check once the app is ready. |
|
|
49
|
+
| `focusCheckIntervalMs` | 30 minutes | Minimum gap between focus-triggered checks, counted from startup. `0` disables them. |
|
|
50
|
+
| `showProgressBar` | `true` | Native progress window during download. |
|
|
51
|
+
| `deviceId` | persisted UUID | Device id for telemetry and staged rollouts. |
|
|
52
|
+
| `getWindow` | | Main window: dialogs attach to it, its focus triggers checks, it shows dock/taskbar progress. |
|
|
53
|
+
| `onBeforeQuitAndInstall` | | Runs before the restart, e.g. to bypass a hide-on-close handler. |
|
|
54
|
+
| `productName` | `app.getName()` | Name used in dialogs. |
|
|
55
|
+
| `logger` | `console` | Any `{ info, warn, error }` logger, e.g. `electron-log`. |
|
|
56
|
+
| `timeoutMs` | `15000` | faynoSync request timeout. |
|
|
57
|
+
|
|
58
|
+
## Custom UI
|
|
59
|
+
|
|
60
|
+
Set `ui: 'none'` and drive your own UI from events:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
const updater = initFaynoSync({ ...options, ui: 'none', checkOnStartup: false });
|
|
64
|
+
|
|
65
|
+
updater.on('update-available', (info) => {
|
|
66
|
+
// info: { currentVersion, version, changelog, critical, source, downloadable, manualDownloadUrl }
|
|
67
|
+
// downloadable === false: the release has no feed, offer info.manualDownloadUrl instead.
|
|
68
|
+
});
|
|
69
|
+
updater.on('update-not-available', ({ manual }) => {});
|
|
70
|
+
updater.on('download-progress', ({ percent, transferred, total, bytesPerSecond }) => {});
|
|
71
|
+
updater.on('update-downloaded', ({ version }) => {});
|
|
72
|
+
updater.on('update-error', ({ error, phase, manual }) => {}); // phase: 'check' | 'download'
|
|
73
|
+
|
|
74
|
+
// Actions for your buttons:
|
|
75
|
+
updater.checkForUpdates(true); // true = user-initiated
|
|
76
|
+
updater.downloadUpdate();
|
|
77
|
+
updater.dismissUpdate(); // "Later"
|
|
78
|
+
updater.quitAndInstall();
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
With `checkOnStartup: false`, run the first check once your renderer listens, e.g. on `did-finish-load`.
|
|
82
|
+
|
|
83
|
+
An update the user has not decided on blocks background checks; a manual check re-emits `update-available`. A downloaded update is also installed when the app quits.
|
|
84
|
+
|
|
85
|
+
## Reports and device id
|
|
86
|
+
|
|
87
|
+
`updater.client` is the underlying `@faynosync/sdk-js` client, and `updater.getDeviceId()` returns the id sent with update checks. Use both for `reportEvent` so reports and checks count as the same device:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
await updater.client.reportEvent({ reportKey, deviceId: updater.getDeviceId(), ... });
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Build and upload requirements
|
|
94
|
+
|
|
95
|
+
- electron-builder must emit `latest.yml` / `latest-mac.yml`, which it does only with a `publish` config. The URL is not used, faynoSync provides the feed at runtime:
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
publish: { provider: 'generic', url: 'https://localhost' },
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- macOS needs the `zip` target next to `dmg` (Squirrel.Mac installs from the zip) and a signed app.
|
|
102
|
+
- Upload the installer, its `.blockmap` and the yml in one call with the `electron-builder` updater:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
faynosync upload --app my-app --version 1.2.3 --channel stable \
|
|
106
|
+
--platform darwin --arch universal --updater electron-builder --publish \
|
|
107
|
+
--file dist/my-app-1.2.3.dmg --file dist/my-app-1.2.3.zip \
|
|
108
|
+
--file dist/my-app-1.2.3.zip.blockmap --file dist/latest-mac.yml
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- Versions must be valid semver that grows with every build (e.g. `MAJOR.MINOR.BUILD_NUMBER`).
|
|
112
|
+
- Differential downloads need storage that answers multi-range requests with `multipart/byteranges` (S3 does). Otherwise electron-updater falls back to a full download.
|
|
113
|
+
|
|
114
|
+
## Bundled main process
|
|
115
|
+
|
|
116
|
+
If the packaged app ships only bundled output (electron-vite with `files: ['out/**']`), `node_modules` is not packaged and these packages must be bundled into the main process instead of externalized:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
externalizeDepsPlugin({
|
|
120
|
+
exclude: ['@faynosync/electron', '@faynosync/sdk-js', 'electron-updater', 'electron-progressbar'],
|
|
121
|
+
})
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Otherwise the app fails at startup with `ERR_MODULE_NOT_FOUND`.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
Apache-2.0
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FaynoSyncUpdater } from './updater';
|
|
2
|
+
import type { FaynoSyncUpdaterOptions } from './types';
|
|
3
|
+
export declare const initFaynoSync: (options: FaynoSyncUpdaterOptions) => FaynoSyncUpdater;
|
|
4
|
+
export { FaynoSyncUpdater } from './updater';
|
|
5
|
+
export type { CheckContext, DownloadProgress, FaynoSyncUpdaterEvents, FaynoSyncUpdaterOptions, Logger, UpdateChannels, UpdateErrorPhase, UpdateInfo, UpdaterUI, } from './types';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,eAAO,MAAM,aAAa,GAAI,SAAS,uBAAuB,KAAG,gBAIhE,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,SAAS,GACV,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FaynoSyncUpdater = exports.initFaynoSync = void 0;
|
|
4
|
+
const updater_1 = require("./updater");
|
|
5
|
+
const initFaynoSync = (options) => {
|
|
6
|
+
const updater = new updater_1.FaynoSyncUpdater(options);
|
|
7
|
+
updater.start();
|
|
8
|
+
return updater;
|
|
9
|
+
};
|
|
10
|
+
exports.initFaynoSync = initFaynoSync;
|
|
11
|
+
var updater_2 = require("./updater");
|
|
12
|
+
Object.defineProperty(exports, "FaynoSyncUpdater", { enumerable: true, get: function () { return updater_2.FaynoSyncUpdater; } });
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAA6C;AAGtC,MAAM,aAAa,GAAG,CAAC,OAAgC,EAAoB,EAAE;IAClF,MAAM,OAAO,GAAG,IAAI,0BAAgB,CAAC,OAAO,CAAC,CAAC;IAC9C,OAAO,CAAC,KAAK,EAAE,CAAC;IAChB,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAJW,QAAA,aAAa,iBAIxB;AAEF,qCAA6C;AAApC,2GAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Logger } from './types';
|
|
2
|
+
export interface UpdateSettings {
|
|
3
|
+
betaChannel: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const readSettings: (logger: Logger) => UpdateSettings;
|
|
6
|
+
export declare const writeSettings: (settings: UpdateSettings, logger: Logger) => void;
|
|
7
|
+
export declare const readDeviceId: (logger: Logger) => string;
|
|
8
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAMtC,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,OAAO,CAAC;CACtB;AAID,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,cAY7C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,UAAU,cAAc,EAAE,QAAQ,MAAM,KAAG,IAMxE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MAc7C,CAAC"}
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.readDeviceId = exports.writeSettings = exports.readSettings = void 0;
|
|
7
|
+
const electron_1 = require("electron");
|
|
8
|
+
const node_crypto_1 = require("node:crypto");
|
|
9
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
// File names match the original super-wallet implementation so migrating keeps the user's channel and device id.
|
|
12
|
+
const SETTINGS_FILE = 'update-settings.json';
|
|
13
|
+
const DEVICE_ID_FILE = '.device-id';
|
|
14
|
+
const userDataPath = (file) => node_path_1.default.join(electron_1.app.getPath('userData'), file);
|
|
15
|
+
const readSettings = (logger) => {
|
|
16
|
+
const settings = { betaChannel: false };
|
|
17
|
+
try {
|
|
18
|
+
const settingsPath = userDataPath(SETTINGS_FILE);
|
|
19
|
+
if (node_fs_1.default.existsSync(settingsPath)) {
|
|
20
|
+
const saved = JSON.parse(node_fs_1.default.readFileSync(settingsPath, 'utf-8'));
|
|
21
|
+
settings.betaChannel = saved.betaChannel === true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
logger.error('[faynoSync] unable to read update settings:', error);
|
|
26
|
+
}
|
|
27
|
+
return settings;
|
|
28
|
+
};
|
|
29
|
+
exports.readSettings = readSettings;
|
|
30
|
+
const writeSettings = (settings, logger) => {
|
|
31
|
+
try {
|
|
32
|
+
node_fs_1.default.writeFileSync(userDataPath(SETTINGS_FILE), JSON.stringify(settings));
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
logger.error('[faynoSync] unable to save update settings:', error);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.writeSettings = writeSettings;
|
|
39
|
+
const readDeviceId = (logger) => {
|
|
40
|
+
const deviceIdPath = userDataPath(DEVICE_ID_FILE);
|
|
41
|
+
try {
|
|
42
|
+
if (node_fs_1.default.existsSync(deviceIdPath)) {
|
|
43
|
+
const saved = node_fs_1.default.readFileSync(deviceIdPath, 'utf-8').trim();
|
|
44
|
+
if (saved)
|
|
45
|
+
return saved;
|
|
46
|
+
}
|
|
47
|
+
const deviceId = (0, node_crypto_1.randomUUID)();
|
|
48
|
+
node_fs_1.default.writeFileSync(deviceIdPath, deviceId);
|
|
49
|
+
return deviceId;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
logger.error('[faynoSync] unable to persist device id:', error);
|
|
53
|
+
return (0, node_crypto_1.randomUUID)();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.readDeviceId = readDeviceId;
|
|
57
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":";;;;;;AAAA,uCAA+B;AAC/B,6CAAyC;AACzC,sDAAyB;AACzB,0DAA6B;AAG7B,iHAAiH;AACjH,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAC7C,MAAM,cAAc,GAAG,YAAY,CAAC;AAMpC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,mBAAI,CAAC,IAAI,CAAC,cAAG,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC;AAEjF,MAAM,YA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AC5D,IAAI,KAAK;gBAAE,OAAO,KAAK,CAAC;QAC1B,CAAC;QACD,MAAM,QAAQ,GAAG,IAAA,wBAAU,GAAE,CAAC;QAC9B,iBAAE,CAAC,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;QAChE,OAAO,IAAA,wBAAU,GAAE,CAAC;IACtB,CAAC;AACH,CAAC,CAAC;AAdW,QAAA,YAAY,gBAcvB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { BrowserWindow } from 'electron';
|
|
2
|
+
import type { UpdateSource } from '@faynosync/sdk-js';
|
|
3
|
+
export interface Logger {
|
|
4
|
+
info(...args: unknown[]): void;
|
|
5
|
+
warn(...args: unknown[]): void;
|
|
6
|
+
error(...args: unknown[]): void;
|
|
7
|
+
debug?(...args: unknown[]): void;
|
|
8
|
+
}
|
|
9
|
+
export interface UpdateChannels {
|
|
10
|
+
readonly stable: string;
|
|
11
|
+
readonly beta?: string;
|
|
12
|
+
}
|
|
13
|
+
export type UpdaterUI = 'native' | 'none';
|
|
14
|
+
export interface FaynoSyncUpdaterOptions {
|
|
15
|
+
readonly baseURL: string;
|
|
16
|
+
readonly edgeURL?: string;
|
|
17
|
+
readonly owner: string;
|
|
18
|
+
readonly appName: string;
|
|
19
|
+
readonly version?: string;
|
|
20
|
+
readonly deviceId?: string;
|
|
21
|
+
readonly channels?: UpdateChannels;
|
|
22
|
+
readonly archOverrides?: Partial<Record<NodeJS.Platform, string>>;
|
|
23
|
+
readonly ui?: UpdaterUI;
|
|
24
|
+
readonly autoDownload?: boolean;
|
|
25
|
+
readonly focusCheckIntervalMs?: number;
|
|
26
|
+
readonly checkOnStartup?: boolean;
|
|
27
|
+
readonly showProgressBar?: boolean;
|
|
28
|
+
readonly productName?: string;
|
|
29
|
+
readonly timeoutMs?: number;
|
|
30
|
+
readonly logger?: Logger;
|
|
31
|
+
readonly getWindow?: () => BrowserWindow | null;
|
|
32
|
+
readonly onBeforeQuitAndInstall?: () => void;
|
|
33
|
+
}
|
|
34
|
+
export interface UpdateInfo {
|
|
35
|
+
readonly currentVersion: string;
|
|
36
|
+
readonly version?: string;
|
|
37
|
+
readonly changelog: string;
|
|
38
|
+
readonly critical: boolean;
|
|
39
|
+
readonly source: UpdateSource;
|
|
40
|
+
readonly downloadable: boolean;
|
|
41
|
+
readonly manualDownloadUrl: string | null;
|
|
42
|
+
}
|
|
43
|
+
export interface DownloadProgress {
|
|
44
|
+
readonly percent: number;
|
|
45
|
+
readonly transferred: number;
|
|
46
|
+
readonly total: number;
|
|
47
|
+
readonly bytesPerSecond: number;
|
|
48
|
+
}
|
|
49
|
+
export type UpdateErrorPhase = 'check' | 'download';
|
|
50
|
+
export interface CheckContext {
|
|
51
|
+
readonly manual: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface FaynoSyncUpdaterEvents {
|
|
54
|
+
checking: [CheckContext];
|
|
55
|
+
'update-available': [UpdateInfo];
|
|
56
|
+
'update-not-available': [CheckContext];
|
|
57
|
+
'download-progress': [DownloadProgress];
|
|
58
|
+
'update-downloaded': [{
|
|
59
|
+
readonly version: string;
|
|
60
|
+
}];
|
|
61
|
+
'update-error': [{
|
|
62
|
+
readonly error: Error;
|
|
63
|
+
readonly phase: UpdateErrorPhase;
|
|
64
|
+
readonly manual: boolean;
|
|
65
|
+
}];
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD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KAAE,CAAC,CAAC;IAEpD,cAAc,EAAE,CAAC;QAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACzG"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { type MenuItemConstructorOptions } from 'electron';
|
|
3
|
+
import { Client } from '@faynosync/sdk-js';
|
|
4
|
+
import type { FaynoSyncUpdaterEvents, FaynoSyncUpdaterOptions } from './types';
|
|
5
|
+
export declare class FaynoSyncUpdater extends EventEmitter<FaynoSyncUpdaterEvents> {
|
|
6
|
+
private readonly options;
|
|
7
|
+
readonly client: Client;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private readonly productName;
|
|
10
|
+
private readonly version;
|
|
11
|
+
private readonly nativeUI;
|
|
12
|
+
private deviceId;
|
|
13
|
+
private settings;
|
|
14
|
+
private state;
|
|
15
|
+
private isManualCheck;
|
|
16
|
+
private pendingResponse;
|
|
17
|
+
private availableInfo;
|
|
18
|
+
private downloadedVersion;
|
|
19
|
+
private progressBar;
|
|
20
|
+
private lastCheckAt;
|
|
21
|
+
private started;
|
|
22
|
+
constructor(options: FaynoSyncUpdaterOptions);
|
|
23
|
+
start: () => void;
|
|
24
|
+
getDeviceId: () => string;
|
|
25
|
+
isBetaChannel: () => boolean;
|
|
26
|
+
setBetaChannel: (enabled: boolean) => void;
|
|
27
|
+
menuItems: () => MenuItemConstructorOptions[];
|
|
28
|
+
checkForUpdates: (interactive?: boolean) => Promise<void>;
|
|
29
|
+
downloadUpdate: () => void;
|
|
30
|
+
dismissUpdate: () => void;
|
|
31
|
+
quitAndInstall: () => void;
|
|
32
|
+
private registerUpdaterEvents;
|
|
33
|
+
private onAppFocus;
|
|
34
|
+
private notAvailable;
|
|
35
|
+
private fail;
|
|
36
|
+
private reset;
|
|
37
|
+
private toUpdateInfo;
|
|
38
|
+
private createProgressBar;
|
|
39
|
+
private confirmDownload;
|
|
40
|
+
private promptInstall;
|
|
41
|
+
private promptManualDownload;
|
|
42
|
+
private showUpToDate;
|
|
43
|
+
private showMessage;
|
|
44
|
+
private getSettings;
|
|
45
|
+
private currentChannel;
|
|
46
|
+
private focusCheckIntervalMs;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=updater.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../src/updater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAKL,KAAK,0BAA0B,EAGhC,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAE,MAAM,EAAmD,MAAM,mBAAmB,CAAC;AAE5F,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EAIxB,MAAM,SAAS,CAAC;AAUjB,qBAAa,gBAAiB,SAAQ,YAAY,CAAC,sBAAsB,CAAC;IAkB5D,OAAO,CAAC,QAAQ,CAAC,OAAO;IAhBpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,OAAO,CAAS;gBAEK,OAAO,EAAE,uBAAuB;IAkB7D,KAAK,QAAO,IAAI,CAqBd;IAGF,WAAW,QAAO,MAAM,CAGtB;IAEF,aAAa,QAAO,OAAO,CAAmC;IAE9D,cAAc,GAAI,SAAS,OAAO,KAAG,IAAI,CAMvC;IAEF,SAAS,QAAO,0BAA0B,EAAE,CAa1C;IAEF,eAAe,GAAU,qBAAmB,KAAG,OAAO,CAAC,IAAI,CAAC,CAqF1D;IAIF,cAAc,QAAO,IAAI,CASvB;IAGF,aAAa,QAAO,IAAI,CAEtB;IAEF,cAAc,QAAO,IAAI,CAOvB;IAEF,OAAO,CAAC,qBAAqB,CAgD3B;IAEF,OAAO,CAAC,UAAU,CAKhB;IAEF,OAAO,CAAC,YAAY,CAKlB;IAEF,OAAO,CAAC,IAAI,CAcV;IAEF,OAAO,CAAC,KAAK,CAUX;IAEF,OAAO,CAAC,YAAY,CAQjB;IAEH,OAAO,CAAC,iBAAiB,CAmBvB;IAEF,OAAO,CAAC,eAAe,CAarB;IAEF,OAAO,CAAC,aAAa,CAanB;IAEF,OAAO,CAAC,oBAAoB,CAkB1B;IAEF,OAAO,CAAC,YAAY,CAKf;IAEL,OAAO,CAAC,WAAW,CAKjB;IAEF,OAAO,CAAC,WAAW,CAGjB;IAEF,OAAO,CAAC,cAAc,CAGpB;IAEF,OAAO,CAAC,oBAAoB,CAC2C;CACxE"}
|
package/dist/updater.js
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FaynoSyncUpdater = void 0;
|
|
7
|
+
const node_events_1 = require("node:events");
|
|
8
|
+
const electron_1 = require("electron");
|
|
9
|
+
// Named import keeps `autoUpdater` a lazy property access in the CJS output.
|
|
10
|
+
const electron_updater_1 = require("electron-updater");
|
|
11
|
+
const electron_progressbar_1 = __importDefault(require("electron-progressbar"));
|
|
12
|
+
const sdk_js_1 = require("@faynosync/sdk-js");
|
|
13
|
+
const storage_1 = require("./storage");
|
|
14
|
+
const utils_1 = require("./utils");
|
|
15
|
+
const DEFAULT_FOCUS_CHECK_INTERVAL_MS = 30 * 60 * 1000;
|
|
16
|
+
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
17
|
+
// Raised by Squirrel.Mac when a check races an install; not actionable for the user.
|
|
18
|
+
const IGNORED_ERROR = 'The command is disabled and cannot be executed';
|
|
19
|
+
class FaynoSyncUpdater extends node_events_1.EventEmitter {
|
|
20
|
+
options;
|
|
21
|
+
// Shared with the app so reportEvent and other calls reuse the same configuration.
|
|
22
|
+
client;
|
|
23
|
+
logger;
|
|
24
|
+
productName;
|
|
25
|
+
version;
|
|
26
|
+
nativeUI;
|
|
27
|
+
deviceId;
|
|
28
|
+
settings = null;
|
|
29
|
+
state = 'idle';
|
|
30
|
+
isManualCheck = false;
|
|
31
|
+
pendingResponse = null;
|
|
32
|
+
availableInfo = null;
|
|
33
|
+
downloadedVersion = null;
|
|
34
|
+
progressBar = null;
|
|
35
|
+
lastCheckAt = 0;
|
|
36
|
+
started = false;
|
|
37
|
+
constructor(options) {
|
|
38
|
+
super();
|
|
39
|
+
this.options = options;
|
|
40
|
+
if (!options.baseURL)
|
|
41
|
+
throw new Error('faynoSync: baseURL is required');
|
|
42
|
+
if (!options.owner)
|
|
43
|
+
throw new Error('faynoSync: owner is required');
|
|
44
|
+
if (!options.appName)
|
|
45
|
+
throw new Error('faynoSync: appName is required');
|
|
46
|
+
this.logger = options.logger ?? console;
|
|
47
|
+
this.productName = options.productName ?? electron_1.app.getName();
|
|
48
|
+
this.version = options.version ?? electron_1.app.getVersion();
|
|
49
|
+
this.nativeUI = (options.ui ?? 'native') === 'native';
|
|
50
|
+
this.deviceId = options.deviceId || null;
|
|
51
|
+
this.client = new sdk_js_1.Client({
|
|
52
|
+
baseURL: options.baseURL,
|
|
53
|
+
edgeURL: options.edgeURL,
|
|
54
|
+
timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
start = () => {
|
|
58
|
+
if (this.started)
|
|
59
|
+
return;
|
|
60
|
+
this.started = true;
|
|
61
|
+
electron_updater_1.autoUpdater.logger = this.logger;
|
|
62
|
+
electron_updater_1.autoUpdater.autoDownload = false;
|
|
63
|
+
electron_updater_1.autoUpdater.autoInstallOnAppQuit = true;
|
|
64
|
+
this.registerUpdaterEvents();
|
|
65
|
+
if (this.focusCheckIntervalMs() > 0) {
|
|
66
|
+
// The first window focus comes right after launch; the startup check (or the app's own) covers it.
|
|
67
|
+
this.lastCheckAt = Date.now();
|
|
68
|
+
electron_1.app.on('browser-window-focus', (_event, window) => {
|
|
69
|
+
const main = this.options.getWindow?.();
|
|
70
|
+
if (!main || window === main)
|
|
71
|
+
this.onAppFocus();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (this.options.checkOnStartup !== false) {
|
|
75
|
+
electron_1.app.whenReady().then(() => this.checkForUpdates());
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
// Use this id for reportEvent too, so update checks and reports count as the same device.
|
|
79
|
+
getDeviceId = () => {
|
|
80
|
+
if (!this.deviceId)
|
|
81
|
+
this.deviceId = (0, storage_1.readDeviceId)(this.logger);
|
|
82
|
+
return this.deviceId;
|
|
83
|
+
};
|
|
84
|
+
isBetaChannel = () => this.getSettings().betaChannel;
|
|
85
|
+
setBetaChannel = (enabled) => {
|
|
86
|
+
if (!this.options.channels?.beta || enabled === this.isBetaChannel())
|
|
87
|
+
return;
|
|
88
|
+
this.settings = { ...this.getSettings(), betaChannel: enabled };
|
|
89
|
+
(0, storage_1.writeSettings)(this.settings, this.logger);
|
|
90
|
+
if (this.state === 'downloaded')
|
|
91
|
+
this.reset();
|
|
92
|
+
this.checkForUpdates();
|
|
93
|
+
};
|
|
94
|
+
menuItems = () => {
|
|
95
|
+
const items = [
|
|
96
|
+
{ label: 'Check for Updates…', click: () => this.checkForUpdates(true) },
|
|
97
|
+
];
|
|
98
|
+
if (this.options.channels?.beta) {
|
|
99
|
+
items.push({
|
|
100
|
+
label: 'Beta Channel',
|
|
101
|
+
type: 'checkbox',
|
|
102
|
+
checked: this.isBetaChannel(),
|
|
103
|
+
click: (item) => this.setBetaChannel(item.checked),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return items;
|
|
107
|
+
};
|
|
108
|
+
checkForUpdates = async (interactive = false) => {
|
|
109
|
+
if (!electron_1.app.isPackaged) {
|
|
110
|
+
this.logger.info('[faynoSync] skipping check: app is not packaged');
|
|
111
|
+
if (interactive && this.nativeUI) {
|
|
112
|
+
await this.showMessage({
|
|
113
|
+
type: 'info',
|
|
114
|
+
message: 'Updates are only available in the installed application.',
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (this.state === 'downloaded' && this.downloadedVersion) {
|
|
120
|
+
this.emit('update-downloaded', { version: this.downloadedVersion });
|
|
121
|
+
if (this.nativeUI)
|
|
122
|
+
await this.promptInstall(this.downloadedVersion, false);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
// An announced update waits for the user's decision; a manual check only re-announces it.
|
|
126
|
+
if (this.state === 'available' && this.availableInfo) {
|
|
127
|
+
if (interactive)
|
|
128
|
+
this.emit('update-available', this.availableInfo);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (this.state === 'checking' || this.state === 'downloading') {
|
|
132
|
+
if (interactive && this.nativeUI) {
|
|
133
|
+
await this.showMessage({
|
|
134
|
+
type: 'info',
|
|
135
|
+
message: "An update is already in progress. Please wait until it's finished.",
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.state = 'checking';
|
|
141
|
+
this.isManualCheck = interactive;
|
|
142
|
+
this.lastCheckAt = Date.now();
|
|
143
|
+
this.emit('checking', { manual: interactive });
|
|
144
|
+
let response;
|
|
145
|
+
try {
|
|
146
|
+
response = await this.client.checkForUpdates({
|
|
147
|
+
owner: this.options.owner,
|
|
148
|
+
appName: this.options.appName,
|
|
149
|
+
version: this.version,
|
|
150
|
+
channel: this.currentChannel(),
|
|
151
|
+
platform: (0, sdk_js_1.systemPlatform)(),
|
|
152
|
+
arch: (0, utils_1.resolveArch)(process.platform, (0, sdk_js_1.systemArch)(), this.options.archOverrides),
|
|
153
|
+
deviceId: this.getDeviceId(),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
this.fail('check', error);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this.logger.info('[faynoSync] check result', {
|
|
161
|
+
updateAvailable: response.updateAvailable,
|
|
162
|
+
critical: response.critical,
|
|
163
|
+
source: response.source,
|
|
164
|
+
});
|
|
165
|
+
if (!response.updateAvailable) {
|
|
166
|
+
this.notAvailable();
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const feedURL = (0, utils_1.feedBaseURL)(response);
|
|
170
|
+
if (!feedURL) {
|
|
171
|
+
const info = this.toUpdateInfo(response, undefined, false);
|
|
172
|
+
this.reset();
|
|
173
|
+
this.emit('update-available', info);
|
|
174
|
+
if (this.nativeUI)
|
|
175
|
+
await this.promptManualDownload(info);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
this.pendingResponse = response;
|
|
179
|
+
electron_updater_1.autoUpdater.setFeedURL({ provider: 'generic', url: feedURL });
|
|
180
|
+
// The outcome is handled by the listeners in registerUpdaterEvents.
|
|
181
|
+
electron_updater_1.autoUpdater
|
|
182
|
+
.checkForUpdates()
|
|
183
|
+
.then((result) => {
|
|
184
|
+
// `null` means the updater is inactive and no event will follow.
|
|
185
|
+
if (!result)
|
|
186
|
+
this.reset();
|
|
187
|
+
})
|
|
188
|
+
.catch(() => undefined);
|
|
189
|
+
};
|
|
190
|
+
// Starts the download of an update announced by 'update-available'. Needed only when it was not started
|
|
191
|
+
// automatically (autoDownload, critical update or the native confirmation dialog).
|
|
192
|
+
downloadUpdate = () => {
|
|
193
|
+
if (this.state !== 'available') {
|
|
194
|
+
this.logger.warn(`[faynoSync] downloadUpdate ignored in state '${this.state}'`);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
this.state = 'downloading';
|
|
198
|
+
if (this.nativeUI)
|
|
199
|
+
this.createProgressBar();
|
|
200
|
+
// Failures are reported through the 'error' listener.
|
|
201
|
+
electron_updater_1.autoUpdater.downloadUpdate().catch(() => undefined);
|
|
202
|
+
};
|
|
203
|
+
// Drops an announced update the user postponed, so the next check starts clean.
|
|
204
|
+
dismissUpdate = () => {
|
|
205
|
+
if (this.state === 'available')
|
|
206
|
+
this.reset();
|
|
207
|
+
};
|
|
208
|
+
quitAndInstall = () => {
|
|
209
|
+
if (this.state !== 'downloaded') {
|
|
210
|
+
this.logger.warn(`[faynoSync] quitAndInstall ignored in state '${this.state}'`);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
this.options.onBeforeQuitAndInstall?.();
|
|
214
|
+
setImmediate(() => electron_updater_1.autoUpdater.quitAndInstall());
|
|
215
|
+
};
|
|
216
|
+
registerUpdaterEvents = () => {
|
|
217
|
+
electron_updater_1.autoUpdater.on('error', (error) => {
|
|
218
|
+
if (error.message.includes(IGNORED_ERROR)) {
|
|
219
|
+
this.logger.warn(`[faynoSync] ignoring '${IGNORED_ERROR}'`);
|
|
220
|
+
this.reset();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
this.fail(this.state === 'downloading' ? 'download' : 'check', error);
|
|
224
|
+
});
|
|
225
|
+
electron_updater_1.autoUpdater.on('update-available', async (updateInfo) => {
|
|
226
|
+
this.logger.info('[faynoSync] update-available', updateInfo.version);
|
|
227
|
+
if (!this.pendingResponse)
|
|
228
|
+
return;
|
|
229
|
+
const info = this.toUpdateInfo(this.pendingResponse, updateInfo.version, true);
|
|
230
|
+
this.state = 'available';
|
|
231
|
+
this.availableInfo = info;
|
|
232
|
+
this.emit('update-available', info);
|
|
233
|
+
if (info.critical || this.options.autoDownload) {
|
|
234
|
+
this.downloadUpdate();
|
|
235
|
+
}
|
|
236
|
+
else if (this.nativeUI) {
|
|
237
|
+
if (await this.confirmDownload(info))
|
|
238
|
+
this.downloadUpdate();
|
|
239
|
+
else
|
|
240
|
+
this.reset();
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
electron_updater_1.autoUpdater.on('update-not-available', () => {
|
|
244
|
+
this.logger.info('[faynoSync] update-not-available');
|
|
245
|
+
this.notAvailable();
|
|
246
|
+
});
|
|
247
|
+
electron_updater_1.autoUpdater.on('download-progress', ({ percent, transferred, total, bytesPerSecond }) => {
|
|
248
|
+
this.emit('download-progress', { percent, transferred, total, bytesPerSecond });
|
|
249
|
+
if (!this.nativeUI)
|
|
250
|
+
return;
|
|
251
|
+
this.options.getWindow?.()?.setProgressBar(percent / 100);
|
|
252
|
+
if (this.progressBar?.isInProgress())
|
|
253
|
+
this.progressBar.value = Math.round(percent);
|
|
254
|
+
});
|
|
255
|
+
electron_updater_1.autoUpdater.on('update-downloaded', (updateInfo) => {
|
|
256
|
+
this.logger.info('[faynoSync] update-downloaded', updateInfo.version);
|
|
257
|
+
this.progressBar?.setCompleted();
|
|
258
|
+
this.reset();
|
|
259
|
+
this.state = 'downloaded';
|
|
260
|
+
this.downloadedVersion = updateInfo.version;
|
|
261
|
+
this.emit('update-downloaded', { version: updateInfo.version });
|
|
262
|
+
if (this.nativeUI)
|
|
263
|
+
this.promptInstall(updateInfo.version, true);
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
onAppFocus = () => {
|
|
267
|
+
// Focus returns whenever an update dialog closes, so checking on every focus would re-prompt right after "Later".
|
|
268
|
+
if (this.state === 'downloaded')
|
|
269
|
+
return;
|
|
270
|
+
if (Date.now() - this.lastCheckAt < this.focusCheckIntervalMs())
|
|
271
|
+
return;
|
|
272
|
+
this.checkForUpdates();
|
|
273
|
+
};
|
|
274
|
+
notAvailable = () => {
|
|
275
|
+
const manual = this.isManualCheck;
|
|
276
|
+
this.reset();
|
|
277
|
+
this.emit('update-not-available', { manual });
|
|
278
|
+
if (manual && this.nativeUI)
|
|
279
|
+
this.showUpToDate();
|
|
280
|
+
};
|
|
281
|
+
fail = (phase, cause) => {
|
|
282
|
+
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
283
|
+
const manual = this.isManualCheck;
|
|
284
|
+
this.logger.error(`[faynoSync] ${phase} failed:`, error);
|
|
285
|
+
this.reset();
|
|
286
|
+
this.emit('update-error', { error, phase, manual });
|
|
287
|
+
if (!this.nativeUI)
|
|
288
|
+
return;
|
|
289
|
+
// A failed download is always reported: the user explicitly asked for it.
|
|
290
|
+
if (phase === 'download') {
|
|
291
|
+
electron_1.dialog.showErrorBox('Update failed', `The update could not be downloaded. Please try again.\n\n${error.message}`);
|
|
292
|
+
}
|
|
293
|
+
else if (manual) {
|
|
294
|
+
this.showMessage({ type: 'error', message: 'Unable to check for updates.', detail: error.message });
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
reset = () => {
|
|
298
|
+
// A completed bar closes itself once its finish animation is done.
|
|
299
|
+
if (this.progressBar && !this.progressBar.isCompleted())
|
|
300
|
+
this.progressBar.close();
|
|
301
|
+
this.progressBar = null;
|
|
302
|
+
this.state = 'idle';
|
|
303
|
+
this.isManualCheck = false;
|
|
304
|
+
this.pendingResponse = null;
|
|
305
|
+
this.availableInfo = null;
|
|
306
|
+
this.downloadedVersion = null;
|
|
307
|
+
if (this.nativeUI)
|
|
308
|
+
this.options.getWindow?.()?.setProgressBar(-1);
|
|
309
|
+
};
|
|
310
|
+
toUpdateInfo = (response, version, downloadable) => ({
|
|
311
|
+
currentVersion: this.version,
|
|
312
|
+
version,
|
|
313
|
+
changelog: response.changelog,
|
|
314
|
+
critical: response.critical,
|
|
315
|
+
source: response.source,
|
|
316
|
+
downloadable,
|
|
317
|
+
manualDownloadUrl: (0, utils_1.manualDownloadURL)(response, process.platform),
|
|
318
|
+
});
|
|
319
|
+
createProgressBar = () => {
|
|
320
|
+
if (this.options.showProgressBar === false)
|
|
321
|
+
return;
|
|
322
|
+
this.progressBar?.close();
|
|
323
|
+
const progressBar = new electron_progressbar_1.default({
|
|
324
|
+
indeterminate: false,
|
|
325
|
+
title: `${this.productName} update`,
|
|
326
|
+
text: 'Downloading update...',
|
|
327
|
+
detail: '0 %',
|
|
328
|
+
});
|
|
329
|
+
progressBar
|
|
330
|
+
.on('completed', () => {
|
|
331
|
+
progressBar.detail = 'Completed';
|
|
332
|
+
})
|
|
333
|
+
.on('progress', (value) => {
|
|
334
|
+
progressBar.detail = `${value} %`;
|
|
335
|
+
});
|
|
336
|
+
this.progressBar = progressBar;
|
|
337
|
+
};
|
|
338
|
+
confirmDownload = async (info) => {
|
|
339
|
+
const { response } = await this.showMessage({
|
|
340
|
+
type: 'info',
|
|
341
|
+
message: `${this.productName} ${info.version} is available.`,
|
|
342
|
+
detail: (0, utils_1.formatDetail)('Would you like to download it now? You will be asked to restart once it is ready.', info.changelog),
|
|
343
|
+
buttons: ['Download', 'Later'],
|
|
344
|
+
defaultId: 0,
|
|
345
|
+
cancelId: 1,
|
|
346
|
+
});
|
|
347
|
+
return response === 0;
|
|
348
|
+
};
|
|
349
|
+
promptInstall = async (version, justDownloaded) => {
|
|
350
|
+
const { response } = await this.showMessage({
|
|
351
|
+
type: 'info',
|
|
352
|
+
message: justDownloaded
|
|
353
|
+
? `${this.productName} ${version} has been downloaded.`
|
|
354
|
+
: `${this.productName} ${version} is ready to install.`,
|
|
355
|
+
detail: 'Restart the application to apply the update. Otherwise, it will be installed the next time you quit.',
|
|
356
|
+
buttons: ['Restart Now', 'Later'],
|
|
357
|
+
defaultId: 0,
|
|
358
|
+
cancelId: 1,
|
|
359
|
+
});
|
|
360
|
+
if (response === 0)
|
|
361
|
+
this.quitAndInstall();
|
|
362
|
+
};
|
|
363
|
+
promptManualDownload = async (info) => {
|
|
364
|
+
if (!info.manualDownloadUrl) {
|
|
365
|
+
this.logger.warn('[faynoSync] update is available but has no download URL');
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const { response } = await this.showMessage({
|
|
369
|
+
type: 'info',
|
|
370
|
+
message: `A new version of ${this.productName} is available.`,
|
|
371
|
+
detail: (0, utils_1.formatDetail)('This update has to be installed manually. Would you like to download it now?', info.changelog),
|
|
372
|
+
buttons: ['Download', 'Later'],
|
|
373
|
+
defaultId: 0,
|
|
374
|
+
cancelId: 1,
|
|
375
|
+
});
|
|
376
|
+
if (response === 0)
|
|
377
|
+
await electron_1.shell.openExternal(info.manualDownloadUrl);
|
|
378
|
+
};
|
|
379
|
+
showUpToDate = () => this.showMessage({
|
|
380
|
+
type: 'info',
|
|
381
|
+
message: "You're up to date!",
|
|
382
|
+
detail: `${this.productName} ${this.version} is the latest version.`,
|
|
383
|
+
});
|
|
384
|
+
showMessage = (options) => {
|
|
385
|
+
const win = this.options.getWindow?.();
|
|
386
|
+
const fullOptions = { title: this.productName, ...options };
|
|
387
|
+
// A sheet attached to a hidden window (macOS) would never be seen.
|
|
388
|
+
return win?.isVisible() ? electron_1.dialog.showMessageBox(win, fullOptions) : electron_1.dialog.showMessageBox(fullOptions);
|
|
389
|
+
};
|
|
390
|
+
getSettings = () => {
|
|
391
|
+
if (!this.settings)
|
|
392
|
+
this.settings = (0, storage_1.readSettings)(this.logger);
|
|
393
|
+
return this.settings;
|
|
394
|
+
};
|
|
395
|
+
currentChannel = () => {
|
|
396
|
+
const channels = this.options.channels ?? { stable: 'stable' };
|
|
397
|
+
return this.isBetaChannel() && channels.beta ? channels.beta : channels.stable;
|
|
398
|
+
};
|
|
399
|
+
focusCheckIntervalMs = () => this.options.focusCheckIntervalMs ?? DEFAULT_FOCUS_CHECK_INTERVAL_MS;
|
|
400
|
+
}
|
|
401
|
+
exports.FaynoSyncUpdater = FaynoSyncUpdater;
|
|
402
|
+
//# sourceMappingURL=updater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updater.js","sourceRoot":"","sources":["../src/updater.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA2C;AAC3C,uCAQkB;AAClB,6EAA6E;AAC7E,uDAA+C;AAC/C,gFAA+C;AAC/C,8CAA4F;AAC5F,uCAA2F;AAQ3F,mCAAoF;AAEpF,MAAM,+BAA+B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACvD,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,qFAAqF;AACrF,MAAM,aAAa,GAAG,gDAAgD,CAAC;AAIvE,MAAa,gBAAiB,SAAQ,0BAAoC;IAkB3C;IAjB7B,mFAAmF;IAC1E,MAAM,CAAS;IACP,MAAM,CAAS;IACf,WAAW,CAAS;IACpB,OAAO,CAAS;IAChB,QAAQ,CAAU;IAC3B,QAAQ,CAAgB;IACxB,QAAQ,GAA0B,IAAI,CAAC;IACvC,KAAK,GAAgB,MAAM,CAAC;IAC5B,aAAa,GAAG,KAAK,CAAC;IACtB,eAAe,GAA0B,IAAI,CAAC;IAC9C,aAAa,GAAsB,IAAI,CAAC;IACxC,iBAAiB,GAAkB,IAAI,CAAC;IACxC,WAAW,GAAuB,IAAI,CAAC;IACvC,WAAW,GAAG,CAAC,CAAC;IAChB,OAAO,GAAG,KAAK,CAAC;IAExB,YAA6B,OAAgC;QAC3D,KAAK,EAAE,CAAC;QADmB,YAAO,GAAP,OAAO,CAAyB;QAE3D,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACxE,IAAI,CAAC,OAAO,CAAC,KAAK;YAAE,MAAM,IAAI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C,iBAAM,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IACzG,CAAC,CAAC;IAEM,WAAW,GAAG,GAAmB,EAAE;QACzC,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,IAAI,CAAC,QAAQ,GAAG,IAAA,sBAAY,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC,CAAC;IAEM,cAAc,GAAG,GAAW,EAAE;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QAC/D,OAAO,IAAI,CAAC,aAAa,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;IACjF,CAAC,CAAC;IAEM,oBAAoB,GAAG,GAAW,EAAE,CAC1C,IAAI,CAAC,OAAO,CAAC,oBAAoB,IAAI,+BAA+B,CAAC;CACxE;AAnZD,4CAmZC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UpdateResponse } from '@faynosync/sdk-js';
|
|
2
|
+
export declare const resolveArch: (platform: NodeJS.Platform, arch: string, overrides?: Partial<Record<NodeJS.Platform, string>>) => string;
|
|
3
|
+
export declare const feedBaseURL: (response: UpdateResponse) => string | null;
|
|
4
|
+
export declare const manualDownloadURL: (response: UpdateResponse, platform: NodeJS.Platform) => string | null;
|
|
5
|
+
export declare const formatDetail: (text: string, changelog: string, maxLength?: number) => string;
|
|
6
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQxD,eAAO,MAAM,WAAW,GACtB,UAAU,MAAM,CAAC,QAAQ,EACzB,MAAM,MAAM,EACZ,YAAW,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAM,KACvD,MAAqC,CAAC;AAGzC,eAAO,MAAM,WAAW,GAAI,UAAU,cAAc,KAAG,MAAM,GAAG,IAG/D,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,UAAU,cAAc,EACxB,UAAU,MAAM,CAAC,QAAQ,KACxB,MAAM,GAAG,IAOX,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,WAAW,MAAM,EAAE,kBAAgB,KAAG,MAIhF,CAAC"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatDetail = exports.manualDownloadURL = exports.feedBaseURL = exports.resolveArch = void 0;
|
|
4
|
+
const MANUAL_DOWNLOAD_PACKAGES = {
|
|
5
|
+
darwin: ['dmg', 'zip'],
|
|
6
|
+
win32: ['exe'],
|
|
7
|
+
linux: ['deb', 'rpm', 'appimage'],
|
|
8
|
+
};
|
|
9
|
+
const resolveArch = (platform, arch, overrides = {}) => overrides[platform] ?? arch;
|
|
10
|
+
exports.resolveArch = resolveArch;
|
|
11
|
+
// electron-updater's generic provider appends latest(-mac).yml to this base.
|
|
12
|
+
const feedBaseURL = (response) => {
|
|
13
|
+
const feed = response.packageUrls.find(({ package: pkg }) => pkg === 'yml');
|
|
14
|
+
return feed ? new URL('.', feed.url).toString() : null;
|
|
15
|
+
};
|
|
16
|
+
exports.feedBaseURL = feedBaseURL;
|
|
17
|
+
const manualDownloadURL = (response, platform) => {
|
|
18
|
+
const preferred = MANUAL_DOWNLOAD_PACKAGES[platform] ?? [];
|
|
19
|
+
for (const ext of preferred) {
|
|
20
|
+
const match = response.packageUrls.find(({ package: pkg }) => pkg === ext);
|
|
21
|
+
if (match)
|
|
22
|
+
return match.url;
|
|
23
|
+
}
|
|
24
|
+
return response.updateUrl || null;
|
|
25
|
+
};
|
|
26
|
+
exports.manualDownloadURL = manualDownloadURL;
|
|
27
|
+
const formatDetail = (text, changelog, maxLength = 1000) => {
|
|
28
|
+
if (!changelog)
|
|
29
|
+
return text;
|
|
30
|
+
const trimmed = changelog.length > maxLength ? `${changelog.slice(0, maxLength)}…` : changelog;
|
|
31
|
+
return `${text}\n\n${trimmed}`;
|
|
32
|
+
};
|
|
33
|
+
exports.formatDetail = formatDetail;
|
|
34
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAEA,MAAM,wBAAwB,GAAwD;IACpF,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,KAAK,EAAE,CAAC,KAAK,CAAC;IACd,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC;CAClC,CAAC;AAEK,MAAM,WAAW,GAAG,CACzB,QAAyB,EACzB,IAAY,EACZ,YAAsD,EAAE,EAChD,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC;AAJ5B,QAAA,WAAW,eAIiB;AAEzC,6EAA6E;AACtE,MAAM,WAAW,GAAG,CAAC,QAAwB,EAAiB,EAAE;IACrE,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC;IAC5E,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACzD,CAAC,CAAC;AAHW,QAAA,WAAW,eAGtB;AAEK,MAAM,iBAAiB,GAAG,CAC/B,QAAwB,EACxB,QAAyB,EACV,EAAE;IACjB,MAAM,SAAS,GAAG,wBAAwB,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC3D,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;QAC3E,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IAC9B,CAAC;IACD,OAAO,QAAQ,CAAC,SAAS,IAAI,IAAI,CAAC;AACpC,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B;AAEK,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,SAAiB,EAAE,SAAS,GAAG,IAAI,EAAU,EAAE;IACxF,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAC5B,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/F,OAAO,GAAG,IAAI,OAAO,OAAO,EAAE,CAAC;AACjC,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faynosync/electron",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Drop-in Electron auto-update for faynoSync on top of electron-updater",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/ku9nov/faynosync-electron.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/ku9nov/faynosync-electron#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/ku9nov/faynosync-electron/issues"
|
|
12
|
+
},
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"electron",
|
|
16
|
+
"auto-update",
|
|
17
|
+
"electron-updater",
|
|
18
|
+
"faynosync"
|
|
19
|
+
],
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"test": "jest",
|
|
31
|
+
"lint": "tsc --project tsconfig.test.json"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@faynosync/sdk-js": "^0.8.1",
|
|
38
|
+
"electron-progressbar": "^2.2.1"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"electron": ">=28",
|
|
42
|
+
"electron-updater": ">=6"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/electron-progressbar": "^2.2.0",
|
|
46
|
+
"@types/jest": "^29.5.14",
|
|
47
|
+
"@types/node": "^20.17.0",
|
|
48
|
+
"electron": "^33.0.0",
|
|
49
|
+
"electron-updater": "^6.3.0",
|
|
50
|
+
"jest": "^29.7.0",
|
|
51
|
+
"ts-jest": "^29.2.0",
|
|
52
|
+
"typescript": "^5.7.0"
|
|
53
|
+
}
|
|
54
|
+
}
|