diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e31dd38..31d07c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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, @@ -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 @@ -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) { @@ -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 } diff --git a/CLAUDE.md b/CLAUDE.md index f58f718..bd8c9cd 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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`) diff --git a/DEVELOPER.md b/DEVELOPER.md index 85d60e3..af8cb6f 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -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 | @@ -46,20 +60,24 @@ 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 @@ -67,33 +85,27 @@ xibo/ ```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. --- @@ -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 @@ -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). --- @@ -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 @@ -362,8 +375,8 @@ Main process stats listener ```json { - "version": "4.0.3", - "versionCode": 403 + "version": "4.0.12", + "versionCode": 4012 } ``` @@ -371,14 +384,14 @@ Main process stats listener | 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) @@ -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` @@ -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 @@ -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 @@ -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 @@ -488,7 +504,6 @@ Electron only supports the latest three major versions, so this needs doing peri ```bash npm install electron@ # bump the version npm install # required: see below -npm run rebuild # recompile better-sqlite3 for the new version npm run build ``` @@ -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 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 and runtime electron`. diff --git a/README.md b/README.md index 17b101a..c868b18 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,15 @@ # Xibo Player Application for ElectronJS -A cross-platform desktop digital signage player builth with Electron and Vite, designed for running Xibo layouts using the **Xibo Layout Renderer (XLR)**. - -The application cleanly separates business logic and layout rendering, and supports package for **Windows** and **Linux** (DEB and Snap). - -### Features -- **Main-process-driven architecture** - - Centralized business logic - - Configuration management - - XMDS communication - - Scheduling and playback orchestration -- **Renderer powered by XLR** - - Uses the shared **Xibo Layout Renderer (XLR)** library - - Focused purely on layout rendering and playback - - No business logic leakage into the renderer -- **Modern tooling** - - Electron + Vite for fast development and optimized builds - - TypeScript-first codebase -- **Cross-platform packaging** - - Windows installer - - Linux - - `.deb` - - `.snap` +A cross-platform desktop digital signage player built with Electron and Vite, designed for running Xibo layouts using the **Xibo Layout Renderer (XLR)**. + +The application cleanly separates business logic and layout rendering, and is packaged for **Windows** (MSI) and **Linux** (DEB and Snap). + +### Documentation + +- [DEVELOPER.md](DEVELOPER.md) - development setup, architecture and common tasks +- [installer/windows/README.md](installer/windows/README.md) - building the Windows MSI +- [docs/UPGRADING-FROM-1.8.md](docs/UPGRADING-FROM-1.8.md) - migrating devices from the legacy Xibo Linux 1.8 player +- [docs/UPGRADING-FROM-WINDOWS.md](docs/UPGRADING-FROM-WINDOWS.md) - migrating devices from the legacy Xibo Windows player --- @@ -57,9 +45,9 @@ Responsibilities: ### Development #### Prerequisites -- Node.js (LTS recommended) +- Node.js 22 or newer - npm -- Linux or WIndows development environment +- Linux or Windows development environment #### Install Dependencies @@ -81,58 +69,72 @@ This starts: ### Building and Packaging -#### Build Application +Installers are built on the platform they target: the MSI on Windows, the DEB and Snap on Linux. -```shell -npm run build -``` +| Command | Output | +|---|---| +| `npm run build` | Compiled bundles in `dist/` | +| `npm run package` | Unpacked app in `out/xibo-player--x64/`, no installer | +| `npm run make` | Installers for the current platform: the MSI on Windows, the DEB on Linux | +| `npm run make:msi` | Windows MSI only, in `out/make/msi/x64/` | +| `npm run make:snap` | Snap package, in `out/make/snap/x64/` | -#### Package for Windows +#### Windows (MSI) ```shell -npm run package +npm run make:msi ``` -Generates: - -- Windows installer / executable +Needs the .NET SDK and the WiX 6 toolset with its UI extension. See [installer/windows/README.md](installer/windows/README.md) for setup and for what must not change in the installer. Local builds are unsigned; release builds are signed by the release workflow. -#### Package for Linux - -##### DEB Package +#### Linux (DEB) ```shell npm run make ``` -##### Snap Package +The `.deb` is written to `out/make/deb/x64/`. + +#### Linux (Snap) ```shell +npm run make npm run make:snap ``` +`make:snap` packs the app that `make` (or `package`) leaves in `out/xibo-player-linux-x64/`, so run that first. It needs `snapcraft`, and copies the version from `package.json` into `snap/snapcraft.yaml` before packing. + --- ### Configuration -There are two configuration files created used for Player and CMS. - -For the player it will be in, - -**Windows** - `%APPDATA%/config.json` and `%APPDATA%/cms_config.json` +The player keeps two configuration files, both created on first run: -**Linux** - `$HOME/.config/xibo-player/config.json` and `$HOME/.config/xibo-player/cms_config.json` +- `config.json` - the player's identity and connection: hardware key, CMS address and key, proxy +- `cms_config.json` - display name and the settings pushed by the CMS. It is overwritten on every collection, so do not edit it by hand -These configuration files are auto-generated on the first run. You can then edit/update the player config manually. +| Install | Location | +|---|---| +| Windows | `%APPDATA%\xibo-player\` | +| Linux (DEB) | `$HOME/.config/xibo-player/` | +| Linux (Snap) | `$HOME/snap/xibo-player/current/.config/xibo-player/` | +The CMS address and key are normally entered on the Configuration page. They can also be set in `config.json` while the player is stopped. Leave the other fields as they are: `hardwareKey` is how the CMS recognises this display, and changing it registers the player as a new display. ```json -// config.json { - "cmsUrl": "", - "cmsKey": "" + "hardwareKey": "…", + "xmrChannel": "…", + "cmsUrl": "https://cms.example.com", + "cmsKey": "yourserverkey", + "macAddress": "…", + "platform": "linux", + "pendingCmsTransfer": null, + "proxy": null } ``` +To route traffic through an HTTP proxy, set `proxy` to `{ "url": "http://proxy.example.com:8080", "username": "", "password": "" }`. The username and password are optional. + --- ### Screenshots on Linux (Wayland) @@ -165,166 +167,3 @@ Replacing the same file each time is recommended, rather than adding a new one, - Screenshots are excluded from the Local Player API file server and cannot be downloaded over the network When a screenshot is requested, if the folder is empty or the newest image has not been updated for some time, a fault is raised against the display in the CMS. - ---- - -### Local Player API - -The player runs a local HTTP server on port **9696** (configurable in Display Settings). Sources on the same device can reach it at `http://localhost:9696`. WAN connections can optionally be configured to allow access from other devices on the network; if not enabled, external requests are denied. - -The API follows the endpoint contract defined in [xibo-interactive-control](https://github.com/xibosignage/xibo-interactive-control). - -#### `GET /info` - -Returns basic, non-sensitive player information. - -**Response: `200 OK`** -```json -{ - "version": "4.0.0", - "displayName": "Lobby Display", - "hardwareKey": "xxxx", - "screenWidth": 1920, - "screenHeight": 1080, - "longitude": 0, - "latitude": 0, - "timeZone": "", - "currentLayoutId": 42, - "displayStatus": 1 -} -``` - ---- - -#### `POST /trigger` - -Passes a trigger code to the layout renderer. Optionally targets a specific widget by ID; omit `id` to apply the trigger globally. - -**Request body** -```json -{ "trigger": "my-trigger", "id": 123 } -``` - -| Field | Required | Description | -|-------|----------|-------------| -| `trigger` | Yes | Trigger code to pass to the layout renderer | -| `id` | No | Target widget ID. If omitted, the trigger applies globally | - -**Responses** -- `200 OK` — `{ "success": true }` -- `400 Bad Request` — `{ "success": false, "error": "trigger is required" }` - ---- - -#### `POST /duration/expire` - -Expires the specified widget immediately, advancing the region to the next media item. - -**Request body** -```json -{ "id": 1 } -``` - -**Response: `200 OK`** — `{ "success": true }` - ---- - -#### `POST /duration/extend` - -Adds seconds to the widget's remaining duration. - -**Request body** -```json -{ "id": 1, "duration": 30 } -``` - -| Field | Required | Description | -|-------|----------|-------------| -| `id` | Yes | Target widget ID | -| `duration` | Yes | Seconds to add to the remaining duration | - -**Response: `200 OK`** — `{ "success": true }` - ---- - -#### `POST /duration/set` - -Sets the widget's duration to the given value in seconds. - -**Request body** -```json -{ "id": 1, "duration": 60 } -``` - -| Field | Required | Description | -|-------|----------|-------------| -| `id` | Yes | Target widget ID | -| `duration` | Yes | New duration in seconds | - -**Response: `200 OK`** — `{ "success": true }` - ---- - -#### `GET /realtime` - -Returns data from the player's real-time data store for the given key. - -**Query parameter**: `?dataKey=myKey` - -**Responses** -- `200 OK` — JSON contents for the key, or empty body if no data exists for that key -- `400 Bad Request` — if `dataKey` is not provided - ---- - -#### `POST /setCriteria` - -Updates the schedule criteria used for dynamic layout selection. Sending the same metric again replaces the previous value. Expired entries are discarded and no longer affect schedule evaluation. - -**Request body** -```json -{ - "criteriaUpdates": [ - { "metric": "people", "value": "5", "ttl": 300 }, - { "metric": "temperature", "value": "28 °C", "ttl": 300 }, - { "metric": "emergency_alert_category", "value": "Geo", "ttl": 60 } - ] -} -``` - -| Field | Required | Description | -|-------|----------|-------------| -| `metric` | Yes | Name of the data point | -| `value` | Yes | Current value | -| `ttl` | No | Seconds before the value expires. Defaults to `300` | - -**Responses** -- `200 OK` — `{ "success": true, "updated": 3 }` -- `400 Bad Request` — `{ "success": false, "error": "metric and value are required" }` - ---- - -#### `POST /fault` - -Raises a player fault. Only accessible from localhost. - -If `key` contains `_`, the part after the underscore is parsed as the widget ID and the fault is raised with widget context. Otherwise the fault is raised without widget context. - -**Request body** -```json -{ - "code": 5001, - "key": "widget_123", - "reason": "Widget failed to load", - "ttl": 60 -} -``` - -| Field | Required | Description | -|-------|----------|-------------| -| `code` | Yes | Fault code (integer) | -| `key` | Yes | Fault key. If it contains `_`, the part after the underscore is the widget ID | -| `reason` | Yes | Human-readable description | -| `ttl` | Yes | Seconds before the fault expires | - -**Response: `200 OK`** — `{ "success": true }` diff --git a/docs/CLIENT-TYPE.md b/docs/CLIENT-TYPE.md deleted file mode 100644 index ce099aa..0000000 --- a/docs/CLIENT-TYPE.md +++ /dev/null @@ -1,80 +0,0 @@ -# `clientType` / display-profile type - -This documents what the `clientType` value sent in XMDS `RegisterDisplay` actually controls -on the CMS side, why the Electron player sends what it sends, and what was ruled out — -so the reasoning doesn't have to be re-derived next time this comes up. - -## Background - -`Config.getXmdsPlayerType()` (`src/main/config/config.ts`) supplies the `` field -in the `RegisterDisplay` SOAP request (`src/main/xmds/xmds.ts`). Until now this was hardcoded -to the literal string `'linux'` for **both** the Windows and Linux Electron builds — accurate -for neither, since the intent (per a leftover comment) had been to eventually send -`'electron-win'` / `'electron-linux'`. That was never enabled because those types don't exist -in the CMS. - -This was raised because seeing "Linux" against a Windows device in the CMS is confusing for -anyone administering the fleet. - -## What `clientType` actually controls (xibo-cms, `develop` branch) - -Researched by reading `xibosignage/xibo-cms` directly — not inferred from naming. It is **not** -cosmetic: - -- `Soap5::RegisterDisplay` (`lib/Xmds/Soap5.php`) stores whatever string the player sends into - `display.client_type` — a plain nullable `VARCHAR(20)`, no validation, no enum. Any string - ≤20 chars is accepted silently. -- That value selects the **default Display Profile "type"** for any display without an - explicit profile override (`Display::getDisplayProfile()` → - `DisplayProfileFactory::getDefaultByType($clientType)`), which determines the settings - schema and available Commands sent back in `RegisterDisplay`. -- CMS-recognized types today: `unknown, windows, android, linux, lg, sssp, chromeOS, hisense` - (`DisplayProfileFactory::loadForType()`). **`electron-win`/`electron-linux` do not exist - anywhere in the CMS repo.** Sending an unrecognized type doesn't error — it silently falls - back to the `unknown` profile: empty settings schema, no commands. -- Commercial-licence exemption is hardcoded to a literal-string list (`Soap5.php`): - `in_array($display->clientType, ['windows', 'linux'])` → `commercialLicence = 3` (not - applicable). Anything outside that list makes the CMS start evaluating real - commercial-licence logic against whatever the player's `RegisterDisplay` call reports. -- Websocket-vs-ZMQ XMR transport eligibility (`XmrClientTrait::isWebSocketXmrSupported()`) is - also a literal-string + `clientCode` branch: `linux` needs `clientCode >= 400`, `windows` - needs `clientCode >= 407`, `android` needs `>= 408`, `chromeOS` always qualifies. Our - `versionCode` is `409`, so either branch is satisfied today. -- **The one that actually bites:** `Soap5.php` PascalCases every setting element name in the - `RegisterDisplay` response (PHP `ucfirst()` — first letter only, e.g. `collectInterval` → - `CollectInterval`) *specifically when* `clientType === 'windows'` — a compatibility shim for - the legacy .NET client's XML deserializer. Our player's response parser - (`RegisterDisplay.getSetting()` in `src/main/xmds/response/registerDisplay.ts`) did an - exact-case property lookup expecting lowerCamelCase. Sending `'windows'` without fixing that - would have made every CMS-pushed setting — collection interval, log level, stats enabled, - aggregation level, XMR websocket address/key, adspace enablement, screen offset/size, - geo-location-on-POP — silently fall back to its local default. No error, just quiet - divergence from what the CMS thinks it configured. - -## Options considered - -| Option | Outcome | -|---|---| -| Keep `'linux'` for both platforms (status quo) | Functionally safest (dodges the PascalCase bug, keeps the licence exemption, lower XMR threshold), but every Windows device is mislabeled in the CMS. | -| Send `'windows'` on Windows builds, without other changes | Correct label, but silently breaks every CMS-pushed setting on Windows devices (the PascalCase issue above). Not viable as-is. | -| Send `'windows'` **and** fix the parser to tolerate both casings | Correct label, no CMS-side changes needed (`'windows'` already exists as a type), settings keep working. **Chosen.** | -| New CMS types `electron-win`/`electron-linux` | Cleanest long-term distinction — these would be genuinely ours rather than borrowed from either legacy client. Requires real CMS engineering: add both to `DisplayProfileFactory::loadForType()`, add them to the commercial-licence exemption list, add branches in `XmrClientTrait`. Can't be done from the player side alone; revisit if/when there's CMS-side appetite for it. | - -## What changed - -- `RegisterDisplay.resolveSettingKey()` (`src/main/xmds/response/registerDisplay.ts`) — looks - up a setting by its lowerCamelCase name first, then falls back to the capitalized (`ucfirst`) - variant, so `getSetting()` works regardless of which casing convention the CMS used for a - given response. -- `Config.getXmdsPlayerType()` (`src/main/config/config.ts`) — now returns `'windows'` on - `win32`, `'linux'` otherwise, instead of the `'linux'`-always hardcode. - -## If this needs revisiting - -The CMS-side facts above were read from `xibosignage/xibo-cms`'s `develop` branch and may have -moved on. Before relying on them again, re-check: -- `lib/Xmds/Soap5.php` — the `clientType`-gated PascalCasing and commercial-licence branches. -- `lib/Factory/DisplayProfileFactory.php::loadForType()` — the enumerated types and their - settings schemas. -- `lib/Entity/XmrClientTrait.php::isWebSocketXmrSupported()` — the per-type `clientCode` - thresholds. diff --git a/docs/UPGRADING-FROM-WINDOWS.md b/docs/UPGRADING-FROM-WINDOWS.md index 514d485..23f2669 100644 --- a/docs/UPGRADING-FROM-WINDOWS.md +++ b/docs/UPGRADING-FROM-WINDOWS.md @@ -3,11 +3,14 @@ This document covers moving existing devices running the legacy **Xibo Windows player** (`xibosignage/xibo-dotnetclient`, WPF/.NET) onto this Electron player. -Unlike the [Linux migration](./UPGRADING-FROM-1.8.md), there is no store-level trick (like a -snap refresh under a shared package name) that delivers this player to a device automatically. -**How the new installer actually reaches a device is a separate, unresolved decision** — see -"Delivery mechanism" below. This document only covers what happens once the new player starts on -a device that still has the legacy config sitting on disk, whichever way it got there. +The player ships as a machine-wide MSI that carries the legacy player's product identity, so +installing it **upgrades the legacy install in place**: Windows removes the legacy player and +installs this one as a newer version of the same product. See "Delivery" below. Unlike the +[Linux migration](./UPGRADING-FROM-1.8.md), nothing reaches a device by itself; the MSI still has +to be deployed, by hand or by a deployment tool. + +The rest of this document covers what happens once the new player starts on a device that still +has the legacy config on disk. The legacy player's on-disk config format has been stable across its releases — this migration was verified against both its `master` branch (current, `4 R407.2` at time of writing) and its @@ -80,8 +83,11 @@ A `ServerKey` equal to the shipped placeholder (`yourserverkey`) is treated as u means the device was never really configured beyond the shipped defaults, so there is no real identity to preserve. -**The legacy files are never modified.** Nothing is moved, rewritten or deleted, so the legacy -install is left intact if you need to roll back. +**The legacy config files are never modified.** Nothing is moved, rewritten or deleted. The MSI +upgrade does remove the legacy player's program files, so rolling back means uninstalling Xibo +Player and then reinstalling the legacy MSI, which finds its settings, library and hardware key as +it left them. Uninstall first: the two packages share an `UpgradeCode`, so the legacy MSI may +refuse to install over the newer version. --- @@ -89,46 +95,54 @@ install is left intact if you need to roll back. 1. **The real migration, against a real CMS.** Install the current published legacy MSI (e.g. `xibo-client-v4-R407.2-win32-x86.msi`) on a clean Windows VM, register it, confirm the display - appears. Then run the new Electron player against the same user profile and confirm **the - same display** comes back online — not a new one. + appears. Then install the new MSI over it, sign in as the same user, and confirm: + - only one "Xibo Player" entry remains in Add/Remove Programs + - **the same display** comes back online, not a new one 2. **Screensaver-mode devices.** If any fielded devices run the legacy player as `Xibo.scr` rather than the normal exe, confirm the `Xibo.xml` fallback picks up their settings. -3. **Autostart.** Reboot and confirm the player comes back — this player uses - `app.setLoginItemSettings({ openAtLogin: true })` (`src/main/common/watchdog.ts`), Electron's - wrapper around the Windows `Run` registry key. +3. **Autostart.** Reboot and confirm the player comes back, and that only one copy is running. + Two mechanisms start it: the MSI places a shortcut in the all-users Start-up folder, so the + player starts after a silent upgrade before it has ever run; and the player itself registers + an HKCU `Run` entry on first launch via `app.setLoginItemSettings({ openAtLogin: true })` + (`src/main/common/watchdog.ts`). 4. **Proxy, if any device in the fleet uses one.** Verify a proxied device reaches its CMS after migrating. The legacy player stores proxy domain and port as separate fields; this migration joins them into one URL the same way the Linux migration normalises its single `domain` field. 5. **A device with a placeholder or fallback hardware key**, if one exists in the fleet — confirm `legacy-config-incomplete` / an already-registered-under-the-fallback-value device both behave as expected (see the mapping notes above). -6. **Staged rollout.** However delivery ends up working (see below), roll it out to a small - device group first. +6. **Staged rollout.** Deploy the MSI to a small device group first. --- -## Delivery mechanism — open, not solved here +## Delivery + +The MSI is built from [installer/windows/](../installer/windows/README.md) and reuses the legacy +installer's `UpgradeCode`, product name and manufacturer. Windows Installer therefore treats it as +a newer version of the legacy product and performs a **major upgrade**: the legacy player is +removed and this one installed in a single transaction, under the same Add/Remove Programs entry. +A failure part way through rolls the whole upgrade back. + +The legacy package owns nothing outside its program folder, the Start menu and the Start-up +folder. Removing it leaves its settings in `%APPDATA%`, its library and its `hardwarekey` file in +place, which is what the migration above reads on the player's first launch. -The Linux migration works for free because the snap store publishes both players under the -identical package name — an in-place snap refresh *is* the delivery mechanism. There is no -Windows equivalent today: this player's `forge.config.cjs` uses `@electron-forge/maker-squirrel` -with no custom identity, so it installs as a brand-new Squirrel app (`xibo-player`) under -`%LocalAppData%\xibo-player` — a completely separate product, install path, and Add/Remove -Programs entry from the legacy WPF app (which ships its own MSI). +The MSI installs per machine and can be deployed silently, by hand or by Group Policy, SCCM, +Intune or any tool running as the computer: -Publishing this Electron build will **not** silently replace the legacy install. Achieving a -silent, same-identity swap needs one of: +``` +msiexec /i xibo-player-4.0.12-x64.msi /qn +``` -- **MSI major upgrade** — package the new player as an MSI that reuses the legacy installer's - `UpgradeCode`, so `msiexec` performs a true in-place upgrade and keeps the same Add/Remove - Programs entry. Requires the legacy installer/WiX project (not in the open-source - `xibo-dotnetclient` repo — likely a separate internal deployment pipeline). -- **Externally orchestrated replace** — RMM/GPO/SCCM silently uninstalls the legacy MSI and - installs the new Squirrel setup as two steps. The migration code in this repo doesn't care how - it got there, only that it runs before `config.load()` on first launch. +Two caveats: -This needs resolving with whoever owns Windows fleet deployment before a wide rollout — it -determines whether the migration path in this document ever actually runs in the field. +- **The upgrade has not yet been tested against a fielded legacy install.** See "Not done yet" in + the [installer README](../installer/windows/README.md). Run pre-flight check 1 before a wide + rollout. +- **Per-user Squirrel installs are not removed.** Earlier releases of this player shipped a + per-user `.exe` installer to `%LocalAppData%\xibo-player`. A device that received it keeps that + install after the MSI goes on, so the player is installed twice. Uninstall it from Add/Remove + Programs before or after deploying the MSI. --- diff --git a/forge.config.cjs b/forge.config.cjs index d5a6de7..add7009 100644 --- a/forge.config.cjs +++ b/forge.config.cjs @@ -80,16 +80,9 @@ module.exports = { }, rebuildConfig: {}, makers: [ - // The machine-wide installer, and the only one that can replace the legacy - // .NET player. See installer/windows/ and WINDOWS-PLAYER-PACKAGING.md. + // The machine-wide Windows installer, which also replaces the legacy .NET + // player in place. See installer/windows/. new MakerMsi({}, ['win32']), - // Squirrel installs for a single user and cannot be deployed by Group Policy - // or by any tool running as the computer. It stays the supported method until - // the MSI ships, and is then removed. No further work belongs on it. - { - name: '@electron-forge/maker-squirrel', - config: {}, - }, { name: '@electron-forge/maker-zip', platforms: ['darwin'], diff --git a/installer/windows/README.md b/installer/windows/README.md index b79dbe5..c0b1ee0 100644 --- a/installer/windows/README.md +++ b/installer/windows/README.md @@ -5,8 +5,10 @@ deployed the way customers already deploy software — Group Policy, SCCM and In running as the computer — and so it can replace the legacy .NET player in place rather than sitting beside it in Add/Remove Programs. -Background and the decisions behind it are in `WINDOWS-PLAYER-PACKAGING.md`; -signing is in `WINDOWS-PLAYER-CODE-SIGNING.md`. +Signing happens in the `build-windows` job of +[the release workflow](../../.github/workflows/release.yml). Migrating a device's +identity from the legacy player is covered in +[docs/UPGRADING-FROM-WINDOWS.md](../../docs/UPGRADING-FROM-WINDOWS.md). | File | Purpose | |---|---| @@ -35,8 +37,9 @@ Then, on Windows: npm run make:msi ``` -The result lands in `out/make/msi/x64/`. `npm run make` builds it alongside the -Squirrel `.exe`, which is still shipped until the MSI has been proven in the field. +The result lands in `out/make/msi/x64/`. On Windows, `npm run make` builds the +same MSI. It is the only Windows installer; the per-user Squirrel `.exe` that +earlier releases shipped is no longer built. ## Three things worth knowing before changing anything here @@ -74,12 +77,14 @@ replacing them needs a 493x58 and a 493x312 image and the `WixUIBannerBmp` and ## Not done yet -- **Removing a per-user Squirrel install.** A screen that received the interim - `.exe` installer keeps it after the MSI is installed, so the player would be - installed twice. A machine-wide MSI runs as SYSTEM and cannot reach a user's - `%LOCALAPPDATA%`, so this belongs in the player's own first-run migration rather - than in a custom action here. +- **Removing a per-user Squirrel install.** A screen that received the `.exe` + installer from an earlier release keeps it after the MSI is installed, so the + player would be installed twice. A machine-wide MSI runs as SYSTEM and cannot + reach a user's `%LOCALAPPDATA%`, so this belongs in the player's own first-run + migration rather than in a custom action here. - **Branded installer dialogs.** See above; the layout is WiX's stock one. - **The upgrade test.** Nothing here has been run against a fielded legacy install. - Section 7 of `WINDOWS-PLAYER-PACKAGING.md` describes the test that proves the - replacement, the version numbering and the display-identity migration together. + Pre-flight check 1 in + [docs/UPGRADING-FROM-WINDOWS.md](../../docs/UPGRADING-FROM-WINDOWS.md) is the test + that proves the replacement, the version numbering and the display-identity + migration together. diff --git a/installer/windows/xibo-player.wxs b/installer/windows/xibo-player.wxs index ea540e5..bf6b79f 100644 --- a/installer/windows/xibo-player.wxs +++ b/installer/windows/xibo-player.wxs @@ -112,15 +112,9 @@ - - - + diff --git a/package-lock.json b/package-lock.json index dea3882..3af978d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,6 @@ "dexie": "^4.2.0", "dotenv": "^17.2.3", "electron-build": "^0.0.3", - "electron-squirrel-startup": "^1.0.1", "express": "^5.2.1", "fflate": "^0.8.3", "he": "^1.2.0", @@ -46,7 +45,6 @@ "@electron-forge/maker-deb": "^7.8.3", "@electron-forge/maker-rpm": "^7.8.3", "@electron-forge/maker-snap": "^7.9.0", - "@electron-forge/maker-squirrel": "^7.8.3", "@electron-forge/maker-zip": "^7.8.3", "@electron-forge/plugin-auto-unpack-natives": "^7.8.3", "@electron-forge/plugin-fuses": "^7.8.3", @@ -615,24 +613,6 @@ "node": ">= 10.0.0" } }, - "node_modules/@electron-forge/maker-squirrel": { - "version": "7.9.0", - "resolved": "https://registry.npmjs.org/@electron-forge/maker-squirrel/-/maker-squirrel-7.9.0.tgz", - "integrity": "sha512-Ea3MrieWC1KRct1QSZeOBY+GIqHZO5bXj6xCuj81f6nz8JMCsXdgvKosdbfcJMSKu4SYZ52PtoweA6uAACfLww==", - "dev": true, - "license": "MIT", - "dependencies": { - "@electron-forge/maker-base": "7.9.0", - "@electron-forge/shared-types": "7.9.0", - "fs-extra": "^10.0.0" - }, - "engines": { - "node": ">= 16.4.0" - }, - "optionalDependencies": { - "electron-winstaller": "^5.3.0" - } - }, "node_modules/@electron-forge/maker-zip": { "version": "7.9.0", "resolved": "https://registry.npmjs.org/@electron-forge/maker-zip/-/maker-zip-7.9.0.tgz", @@ -5268,30 +5248,6 @@ "node": ">=10" } }, - "node_modules/electron-squirrel-startup": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/electron-squirrel-startup/-/electron-squirrel-startup-1.0.1.tgz", - "integrity": "sha512-sTfFIHGku+7PsHLJ7v0dRcZNkALrV+YEozINTW8X1nM//e5O3L+rfYuvSW00lmGHnYmUjARZulD8F2V8ISI9RA==", - "license": "Apache-2.0", - "dependencies": { - "debug": "^2.2.0" - } - }, - "node_modules/electron-squirrel-startup/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "license": "MIT", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/electron-squirrel-startup/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "license": "MIT" - }, "node_modules/electron-to-chromium": { "version": "1.5.222", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.222.tgz", @@ -5762,66 +5718,6 @@ "@esbuild/win32-x64": "0.25.12" } }, - "node_modules/electron-winstaller": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/electron-winstaller/-/electron-winstaller-5.4.0.tgz", - "integrity": "sha512-bO3y10YikuUwUuDUQRM4KfwNkKhnpVO7IPdbsrejwN9/AABJzzTQ4GeHwyzNSrVO+tEH3/Np255a3sVZpZDjvg==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "dependencies": { - "@electron/asar": "^3.2.1", - "debug": "^4.1.1", - "fs-extra": "^7.0.1", - "lodash": "^4.17.21", - "temp": "^0.9.0" - }, - "engines": { - "node": ">=8.0.0" - }, - "optionalDependencies": { - "@electron/windows-sign": "^1.1.2" - } - }, - "node_modules/electron-winstaller/node_modules/fs-extra": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", - "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/electron-winstaller/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, - "license": "MIT", - "optional": true, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/electron-winstaller/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/electron/node_modules/@electron/get": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/@electron/get/-/get-5.1.0.tgz", @@ -10795,50 +10691,6 @@ "dev": true, "license": "ISC" }, - "node_modules/temp": { - "version": "0.9.4", - "resolved": "https://registry.npmjs.org/temp/-/temp-0.9.4.tgz", - "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "mkdirp": "^0.5.1", - "rimraf": "~2.6.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/temp/node_modules/mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "minimist": "^1.2.6" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, - "node_modules/temp/node_modules/rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "deprecated": "Rimraf versions prior to v4 are no longer supported", - "dev": true, - "license": "ISC", - "optional": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", diff --git a/package.json b/package.json index faf2673..73c3611 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "@electron-forge/maker-deb": "^7.8.3", "@electron-forge/maker-rpm": "^7.8.3", "@electron-forge/maker-snap": "^7.9.0", - "@electron-forge/maker-squirrel": "^7.8.3", "@electron-forge/maker-zip": "^7.8.3", "@electron-forge/plugin-auto-unpack-natives": "^7.8.3", "@electron-forge/plugin-fuses": "^7.8.3", @@ -59,7 +58,6 @@ "dexie": "^4.2.0", "dotenv": "^17.2.3", "electron-build": "^0.0.3", - "electron-squirrel-startup": "^1.0.1", "express": "^5.2.1", "fflate": "^0.8.3", "he": "^1.2.0", diff --git a/src/main/config/config.ts b/src/main/config/config.ts index 962bc4d..ad4bb03 100644 --- a/src/main/config/config.ts +++ b/src/main/config/config.ts @@ -293,8 +293,8 @@ export class Config { getXmdsPlayerType(): string { // Reuses the CMS's existing 'windows'/'linux' display-profile types rather than - // registering new 'electron-*' ones — see docs/CLIENT-TYPE.md for why: the CMS has no - // 'electron-win'/'electron-linux' profile type today, and sending one would fall back + // registering new 'electron-*' ones. The CMS has no 'electron-win'/'electron-linux' + // profile type today, and sending one would fall back // to an empty "unknown" profile and drop the commercial-licence exemption. 'windows' // makes the CMS PascalCase every RegisterDisplay setting name, which // RegisterDisplay::resolveSettingKey() (src/main/xmds/response/registerDisplay.ts) diff --git a/src/main/index.ts b/src/main/index.ts index 8f8f9bb..04c7c69 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -18,8 +18,6 @@ * You should have received a copy of the GNU Affero General Public License * along with Xibo. If not, see . */ -if (require('electron-squirrel-startup')) app.quit(); - const fs = require('fs/promises'); const { readFileSync } = require('fs'); import { createHash } from 'crypto'; diff --git a/src/main/xmds/response/registerDisplay.ts b/src/main/xmds/response/registerDisplay.ts index 43ac24a..8836793 100644 --- a/src/main/xmds/response/registerDisplay.ts +++ b/src/main/xmds/response/registerDisplay.ts @@ -108,8 +108,8 @@ export class RegisterDisplay { * Find the actual response key for a setting name. The CMS capitalizes the first * letter of every setting element name (PHP's `ucfirst()`) when the display's * clientType is 'windows' — a compatibility shim for the legacy .NET client's XML - * deserializer. This player reports clientType 'windows' on Windows builds (see - * docs/CLIENT-TYPE.md), so responses may use either casing depending on CMS version; + * deserializer. This player reports clientType 'windows' on Windows builds + * (Config.getXmdsPlayerType()), so responses may use either casing depending on CMS version; * falling back to the capitalized variant keeps settings working either way. */ private resolveSettingKey(setting: string): string {