@neplex/upserve-electron 0.0.0-stage → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # @neplex/upserve-electron
2
+
3
+ ## 0.1.0
4
+
5
+ Initial implementation of Upserve update distribution.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Neplex Technologies
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ # @neplex/upserve-electron
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Serve electron-builder manifests and assets for electron-updater generic feeds. This package does not implement Electron’s native Squirrel autoUpdater protocol.
4
+
5
+ ```sh
6
+ npm install @neplex/upserve @neplex/upserve-github @neplex/upserve-electron @hono/node-server
7
+ ```
8
+
9
+ Add `electron()` to your adapters and use `/editor/stable/electron/` as the generic feed. Publish original YAML, matching installers and existing blockmaps. Set `useMultipleRangeRequest: false` for GitHub delivery. Web installers and absolute external manifest asset URLs are unsupported.
10
+
11
+ Read the [guide](https://upserve.neplex.dev/docs/electron) for a complete example and supported behavior, or browse the [documentation source](https://github.com/neplextech/upserve/tree/main/apps/docs/content/docs). During initial private development, packages may not be published yet; use the repository checkout instructions in the quick start.
12
+
13
+ MIT licensed.
@@ -0,0 +1,17 @@
1
+ import * as _$_neplex_upserve0 from "@neplex/upserve";
2
+ import * as _$hono_types0 from "hono/types";
3
+ import * as _$hono from "hono";
4
+
5
+ //#region src/index.d.ts
6
+ /** Map channels to electron-builder prefixes; stable defaults to latest. */
7
+ interface ElectronOptions {
8
+ /** Named release selection predicates; defaults to stable and prerelease. */
9
+ channels?: Record<string, string>;
10
+ }
11
+ /** Serve original electron-builder YAML plus immutable release-relative artifacts. */
12
+ declare function electron(options?: ElectronOptions): {
13
+ name: string;
14
+ register(app: _$hono.Hono<_$hono_types0.BlankEnv, _$hono_types0.BlankSchema, "/">, services: _$_neplex_upserve0.AdapterServices): void;
15
+ };
16
+ //#endregion
17
+ export { ElectronOptions, electron };
package/dist/index.mjs ADDED
@@ -0,0 +1,48 @@
1
+ import { UpserveError, defineAdapter } from "@neplex/upserve";
2
+ import { parseDocument } from "yaml";
3
+ //#region src/index.ts
4
+ /** Serve original electron-builder YAML plus immutable release-relative artifacts. */
5
+ function electron(options = {}) {
6
+ return defineAdapter({
7
+ name: "electron",
8
+ register(app, services) {
9
+ app.on(["GET", "HEAD"], "/electron/:release/:file", async (c) => {
10
+ const release = (await services.releases(c.req.param("channel"))).find((r) => r.id === c.req.param("release"));
11
+ const asset = release?.assets.find((a) => a.name === c.req.param("file"));
12
+ if (!release || !asset) return c.notFound();
13
+ return services.deliver(c.req.raw, release, asset);
14
+ });
15
+ app.on(["GET", "HEAD"], "/electron/:file", async (c) => {
16
+ const name = c.req.param("file");
17
+ const releases = await services.releases(c.req.param("channel"));
18
+ const release = releases[0];
19
+ if (!release) return c.notFound();
20
+ if (!name.endsWith(".yml")) {
21
+ for (const r of releases) {
22
+ const a = r.assets.find((a) => a.name === name);
23
+ if (a) return services.deliver(c.req.raw, r, a);
24
+ }
25
+ return c.notFound();
26
+ }
27
+ const prefix = options.channels?.[c.req.param("channel")] ?? (c.req.param("channel") === "stable" ? "latest" : c.req.param("channel"));
28
+ if (!new RegExp("^" + prefix?.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "(?:-mac|-linux(?:-[a-z0-9_]+)?)?\\.yml$").test(name)) return c.notFound();
29
+ const raw = await services.manifest(release, name, (raw) => {
30
+ const doc = parseDocument(raw, { uniqueKeys: true });
31
+ if (doc.errors.length) throw new UpserveError("invalid", "Invalid Electron YAML");
32
+ const value = doc.toJS({ maxAliasCount: 0 });
33
+ if (!value || value.version !== release.version || !Array.isArray(value.files) || !value.files.length) throw new UpserveError("invalid", "Invalid Electron manifest");
34
+ for (const input of value.files) {
35
+ const file = input;
36
+ if (!file || typeof file.url !== "string" || !/^[A-Za-z0-9+/]{86}==$/.test(String(file.sha512)) || !Number.isSafeInteger(file.size) || Number(file.size) <= 0) throw new UpserveError("invalid", "Invalid Electron checksum or size");
37
+ if (!release.assets.find((a) => a.name === file.url && a.size === file.size) || /[/\\]|\.\./.test(file.url)) throw new UpserveError("invalid", "Missing Electron artifact");
38
+ }
39
+ if (value.packages || value.path && !release.assets.some((a) => a.name === value.path)) throw new UpserveError("invalid", "Unsupported Electron web installer or path");
40
+ return raw;
41
+ });
42
+ return new Response(c.req.method === "HEAD" ? null : raw, { headers: { "Content-Type": "application/yaml" } });
43
+ });
44
+ }
45
+ });
46
+ }
47
+ //#endregion
48
+ export { electron };
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@neplex/upserve-electron",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Composable application update distribution for Fetch runtimes",
5
+ "homepage": "https://upserve.neplex.dev",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/neplextech/upserve.git",
10
+ "directory": "packages/electron"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "README.md",
15
+ "LICENSE",
16
+ "CHANGELOG.md"
17
+ ],
18
+ "type": "module",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.mts",
22
+ "import": "./dist/index.mjs",
23
+ "default": "./dist/index.mjs"
24
+ }
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "dependencies": {
30
+ "hono": "^4.13.22",
31
+ "yaml": "^2.8.2",
32
+ "@neplex/upserve": "0.1.0"
33
+ },
34
+ "engines": {
35
+ "node": ">=22.13"
36
+ },
37
+ "scripts": {
38
+ "build": "tsdown"
39
+ }
6
40
  }