Skip to content

1681-engine / electron / WebPatcher

Class: WebPatcher ​

Defined in: src/electron/webPatcher.ts:49

A desktop shell that patches its web file by file, the way a game launcher does: the web a build ships is its built-in copy, and every newer web is assembled beside it in <root>/<version>/ from the files already held plus only those whose content is new (<channel>/files/<sha256>, checked against their hash), then loaded in its place. A web is taken only by a shell of the same identity; any other change needs an installer. A web that never reports booting (markBooted, from the page) within maxTries starts is dropped, and the shell goes back to the last web that did — or the built-in one — so a broken release cannot lock a player out.

Use one per process: startEntry first (it decides which web this run loads), then the update calls.

Constructors ​

Constructor ​

ts
new WebPatcher(options): WebPatcher;

Defined in: src/electron/webPatcher.ts:59

Parameters ​

ParameterType
optionsWebPatcherOptions

Returns ​

WebPatcher

Accessors ​

shell ​

Get Signature ​

ts
get shell(): string;

Defined in: src/electron/webPatcher.ts:78

This shell's identity.

Returns ​

string

Methods ​

applyPending() ​

ts
applyPending(): string | null;

Defined in: src/electron/webPatcher.ts:205

Puts the pending web in use now and returns the page to load (reload every window from it), or null when there is none this shell may load. The switch counts as its first start, so a web that never boots is still dropped.

Returns ​

string | null


latest() ​

ts
latest(): Promise<LatestJson | null>;

Defined in: src/electron/webPatcher.ts:129

The channel's newest build, or null when the store cannot be read.

Returns ​

Promise<LatestJson | null>


markBooted() ​

ts
markBooted(): void;

Defined in: src/electron/webPatcher.ts:123

The page came up: the web it was loaded from is kept from now on. Call it from the page's own "booted" message.

Returns ​

void


patchable() ​

ts
patchable(l): boolean;

Defined in: src/electron/webPatcher.ts:141

Whether l's web can be patched in here rather than installed: newer than the web running, for this shell.

Parameters ​

ParameterType
lLatestJson

Returns ​

boolean


prepare() ​

ts
prepare(l, onProgress?): Promise<string>;

Defined in: src/electron/webPatcher.ts:150

Builds l's web beside the one running: the files held are copied, the rest downloaded and checked, into <version>.part/, which becomes <version>/ and the pending web once whole — a crash mid-way never leaves a folder that looks finished. onProgress gets 0–100. Resolves with the version built; throws on any failure.

Parameters ​

ParameterType
lLatestJson
onProgress(percent) => void

Returns ​

Promise<string>


startEntry() ​

ts
startEntry(): string;

Defined in: src/electron/webPatcher.ts:85

Where the window loads the page from: a patched web when there is a good one, else the built-in copy.

Returns ​

string


tidy() ​

ts
tidy(): Promise<void>;

Defined in: src/electron/webPatcher.ts:228

Removes every patched web but the active, pending and previous one, and any half-made folder. A call made while one is running waits for it and then runs once more, so two never delete the same folder at once.

Returns ​

Promise<void>


webVersion() ​

ts
webVersion(): string;

Defined in: src/electron/webPatcher.ts:118

The version of the web running now.

Returns ​

string

Released under the MIT License.