Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Windows ships two installers while the move to the MSI is in progress: the
# machine-wide MSI, which is the one that can replace the legacy .NET player and
# be deployed by Group Policy, and the existing per-user Squirrel .exe, which
# stays the supported method until the MSI has been proven in the field.
# Windows ships a single machine-wide MSI, which can be deployed by Group Policy
# and replaces the legacy .NET player in place.
#
# The job is deliberately split into package / sign / make / sign rather than a
# single `npm run make`. Windows verifies the signature on the file being run,
Expand Down Expand Up @@ -304,7 +302,7 @@ jobs:
signing-account-name: ${{ vars.AZURE_SIGNING_ACCOUNT }}
certificate-profile-name: ${{ vars.AZURE_SIGNING_PROFILE }}
files-folder: ${{ github.workspace }}\out\make
files-folder-filter: exe,msi
files-folder-filter: msi
files-folder-recurse: true
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
Expand All @@ -317,7 +315,7 @@ jobs:
- name: 'Verify Installer Signatures'
run: |
$installers = Get-ChildItem -Path "./out/make" -File -Recurse |
Where-Object { $_.Extension -match "^\.(exe|msi)$" }
Where-Object { $_.Extension -eq ".msi" }

$unsigned = @()
foreach ($installer in $installers) {
Expand All @@ -336,10 +334,10 @@ jobs:
if: env.PUBLISH == 'true'
run: |
$installers = Get-ChildItem -Path "./out/make" -File -Recurse |
Where-Object { $_.Extension -match "^\.(exe|msi)$" }
Where-Object { $_.Extension -eq ".msi" }

if ($installers.Count -eq 0) {
Write-Error "No installer file (.exe or .msi) found in ./out/make/"
Write-Error "No MSI installer found in ./out/make/"
exit 1
}

Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ There is no dedicated lint or test script. ESLint is configured in `.eslintrc.js

## Development Setup

This repo depends on `@xibosignage/xibo-layout-renderer` (XLR). In development, `electron.vite.config.js` aliases XLR to `../xibo-layout-renderer/src/index.ts`, so both repos must be cloned in the **same parent directory**. In production builds the alias is removed and the installed npm package is used.
This repo depends on `@xibosignage/xibo-layout-renderer` (XLR) and `@xibosignage/xibo-communication-framework`. In development, `electron.vite.config.js` aliases both to local clones at `../xibo-layout-renderer` and `../xibo-communication-framework`, which resolve to each package's built `dist/` output. All three repos must be cloned in the **same parent directory**, and each library must be built (`npm run build`) before the player picks up changes to it. In production builds the aliases are removed and the installed npm packages are used.

Runtime config files are stored outside the repo:
- Windows: `%APPDATA%\xibo-player\` (`config.json`, `cms_config.json`)
Expand Down
94 changes: 53 additions & 41 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ A practical guide for developers setting up and working with the Xibo Electron P
|------|---------|-------|
| Node.js | 22 or newer | Electron and `better-sqlite3` both require Node >= 22 |
| npm | bundled with Node | No Yarn/pnpm |
| Git | any recent | SSH key for cloning the companion repositories |
| Electron | auto-installed | Version pinned in `package.json` devDependencies |

No C++ compiler or Python is needed. `better-sqlite3` ships prebuilt Node-API binaries for every
platform it supports, and Node-API binaries load under Electron without being recompiled.

**Windows only**: the .NET SDK and the WiX toolset, if you build the MSI. See
[installer/windows/README.md](installer/windows/README.md).

**Linux only**: `snapcraft` is required if packaging Snap.

------|---------|-------|
| Node.js | 22 or newer | Electron and `better-sqlite3` both require Node >= 22 |
| npm | bundled with Node | No Yarn/pnpm |
| Git | any recent | SSH key required (XLR is a git dependency) |
| Electron | auto-installed | Version pinned in `package.json` devDependencies |
| Python | 3.6 or newer | Required to compile `better-sqlite3`. See below |
Expand All @@ -46,54 +60,52 @@ picks up the new `PATH`.

## 2. Repository Setup

This player depends on two repositories. Clone both into the **same parent directory** so the dev alias works correctly.
In development the player builds against local clones of two companion libraries rather than
the published npm packages. Clone all three into the **same parent directory** so the dev aliases
in `electron.vite.config.js` resolve.

```bash
# From your preferred workspace root (e.g. ~/dev/xibo/)
git clone git@github.com:xibosignage/electron-player.git
git clone git@github.com:xibosignage/xibo-layout-renderer.git
git clone git@github.com:xibosignage/xibo-communication-framework.git
```

Your directory structure should look like:

```
xibo/
├── electron-player/ ← this app
└── xibo-layout-renderer/ ← layout renderer library
├── electron-player/ ← this app
├── xibo-layout-renderer/ ← layout renderer library
└── xibo-communication-framework/ ← communication framework library
```

### Install dependencies

```bash
cd electron-player
npm install
npm run rebuild
```

Both steps are required. `npm install` also downloads the Electron binary via a `postinstall` hook,
since Electron no longer fetches it during a plain install.
`npm install` also downloads the Electron binary via a `postinstall` hook, since Electron no longer
fetches it during a plain install.

`npm run rebuild` compiles `better-sqlite3` against the current Electron version. It takes a few
minutes and prints compiler output, which is expected. Skipping it lets the app start and then fail
when it first opens the database, so run it after every `npm install` and after every Electron or
Node version change.
### Build the companion libraries (first time only)

If it fails with `Could not find any Python installation to use`, check
[Prerequisites](#1-prerequisites). If Python is installed and works in a fresh terminal but not in
your editor, fully quit and reopen the editor: it passes its own copy of `PATH` to integrated
terminals, and that copy is captured at launch.

### Build the layout renderer (first time only)

The renderer library must be built before the player can use it in dev mode:
Both libraries must be built before the player can use them in dev mode, since the aliases resolve
to each package's `dist/` output:

```bash
cd ../xibo-layout-renderer
npm install
npm run build # generates dist/

cd ../xibo-communication-framework
npm install
npm run build # generates dist/
```

You only need to redo this when you pull changes to `xibo-layout-renderer`.
Rebuild a library whenever you pull or make changes to it.

---

Expand All @@ -110,7 +122,7 @@ This starts `electron-vite dev` with:
- **Remote debugging** on port `9222` (attach Chrome DevTools at `chrome://inspect`)
- **Node inspector** on the main process (`--inspect src/main/index.ts`)

In dev mode, the alias `@xibosignage/xibo-layout-renderer` resolves to `../xibo-layout-renderer` (your local clone), so changes to the renderer library are picked up immediately after a rebuild.
In dev mode, `@xibosignage/xibo-layout-renderer` and `@xibosignage/xibo-communication-framework` resolve to your local clones in `../`, so changes to either library are picked up after rebuilding it.

### First launch

Expand All @@ -129,17 +141,18 @@ Or you can enter an activation code generated by the CMS.
| `npm run build` | Compiles all processes to `dist/` via electron-vite |
| `npm run start` | Previews the built output (no HMR) |
| `npm run package` | Build + Electron Forge package (creates unpacked app) |
| `npm run make` | Build + Electron Forge make (creates installer) |
| `npm run make:snap` | Builds a Snap package (Linux, requires snapcraft) |
| `npm run make` | Build + Electron Forge make (creates the installers for the current platform) |
| `npm run make:msi` | Build + the Windows MSI only (Windows, requires WiX) |
| `npm run make:snap` | Packs a Snap from the output of `package`/`make` (Linux, requires snapcraft) |

### Platform-specific make targets

Electron Forge is configured in `forge.config.cjs` with makers for:
- **Windows** — Squirrel installer (`.exe`/`.msi`)
- **Windows** — machine-wide MSI (WiX, see `installer/windows/README.md`)
- **Linux** — Debian package (`.deb`) + Snap
- **macOS** — ZIP archive

In production builds, `xibo-layout-renderer` is **bundled into the app** (not aliased to the local clone).
In production builds, the companion libraries come from the installed npm packages and are **bundled into the app** (not aliased to the local clones).

---

Expand Down Expand Up @@ -344,7 +357,7 @@ XLR: xibo-layout-renderer.ts
```
XLR emits layoutStart / widgetStart
→ renderer.ts catches event
→ sends stats message via BroadcastChannel ('xibo-stats')
→ sends stats message via BroadcastChannel ('statsBC')

Main process stats listener
→ receives BroadcastChannel message via IPC
Expand All @@ -362,23 +375,23 @@ Main process stats listener

```json
{
"version": "4.0.3",
"versionCode": 403
"version": "4.0.12",
"versionCode": 4012
}
```

`electron.vite.config.js` reads these at build time via `readFileSync` and injects them as compile-time constants available to all processes:

| Constant | Type | Value example |
|----------|------|---------------|
| `__APP_VERSION__` | `string` | `"4.0.3"` |
| `__APP_VERSION_CODE__` | `number` | `403` |
| `__APP_VERSION__` | `string` | `"4.0.12"` |
| `__APP_VERSION_CODE__` | `number` | `4012` |

These constants replace any runtime variable lookups — no `.env` files are needed for versioning.

`snap/snapcraft.yaml` is also kept in sync: `scripts/set-snap-version.cjs` runs automatically as part of `make:snap` and writes the `version` field from `package.json` into the YAML before `snapcraft pack` is invoked.

To bump the version, edit only `package.json`.
To bump the version, edit only `package.json`, keeping `versionCode` as the version digits run together (`4.0.12` → `4012`).

### Runtime config files (userData directory)

Expand Down Expand Up @@ -409,6 +422,9 @@ The Express server at `http://localhost:9696/files/` serves everything in this d

### Remote DevTools

DevTools are only available in development. Production builds disable them on every window, so
none of the steps below work against an installed player.

Attach Chrome DevTools to the **renderer** process:
1. Open `chrome://inspect` in any Chromium browser
2. Click **Configure** and add `localhost:9222`
Expand All @@ -422,7 +438,7 @@ The preload overrides `console.*` methods to forward all log output over IPC to

### Fault reporting

`Faults.ts` tracks and persists faults. The renderer initiates fault collection via `playerAPI.initFaults()` and reports faults back via BroadcastChannel (`xibo-faults`).
`Faults.ts` tracks and persists faults. The renderer initiates fault collection via `playerAPI.initFaults()` and reports faults back via BroadcastChannel (`player-faults-bc`).

### Useful IPC event names

Expand All @@ -446,7 +462,7 @@ Edit files in `../xibo-layout-renderer/src/`, then:
```bash
cd ../xibo-layout-renderer && npm run build
```
The dev server will pick up the rebuilt output automatically (the alias points to `dist/`). Restart `npm run dev` if HMR doesn't catch the change.
The dev server will pick up the rebuilt output automatically (the alias resolves to the package's `dist/` output). Restart `npm run dev` if HMR doesn't catch the change.

### Adding a new IPC event

Expand All @@ -463,7 +479,7 @@ The dev server will pick up the rebuilt output automatically (the alias points t

### Changing the file server port

The Express server port is hardcoded to `9696`. To change it, update the `port` constant in `src/main/express.ts` and the `appHost` option passed to `XiboLayoutRenderer` in `src/renderer/src/renderer.ts`.
The Express server port is hardcoded to `9696`. To change it, update the `port` constant in `src/main/express.ts` and the `APP_HOST` constant in `src/renderer/src/renderer.ts`, which is passed to XLR as `appHost`.

### Running a release build locally

Expand All @@ -488,7 +504,6 @@ Electron only supports the latest three major versions, so this needs doing peri
```bash
npm install electron@<major> # bump the version
npm install # required: see below
npm run rebuild # recompile better-sqlite3 for the new version
npm run build
```

Expand All @@ -498,10 +513,7 @@ downloading the new binary. The build then fails with `[vite:bytecode] Electron
gives no hint about the cause. A plain `npm install` afterwards triggers the hook. Running
`npx install-electron --no` directly has the same effect.

Two other things may need attention when moving to a new major:

- **`node-abi`**, overridden in `package.json`, maps Electron versions to build identifiers. If
`npm run rebuild` fails with `Could not detect abi for version <x> and runtime electron`, raise
that override to a version that lists the new release.
- **`better-sqlite3`** must support the V8 version Electron ships. If the rebuild fails with C++
errors referencing `v8::`, the library needs upgrading rather than the build fixing.
`better-sqlite3` does not need rebuilding: its prebuilt Node-API binaries are independent of the
Electron version. If you do run `npm run rebuild`, which compiles it from source and needs a C++
compiler and Python, the `node-abi` override in `package.json` must list the new Electron release,
or the rebuild fails with `Could not detect abi for version <x> and runtime electron`.
Loading
Loading