Skip to content

API reference / @jsprismarine/native-library / NativeLibrary

NativeLibrary ​

Classes ​

Interfaces ​

InstallOptions ​

Defined in: NativeLibrary.ts:52

How NativeLibrary.install finds and fetches the build; tests replace the network and the platform.

Properties ​

env? ​

readonly optional env?: ProcessEnv

Defined in: NativeLibrary.ts:55

fetch? ​

readonly optional fetch?: (url) => Promise<Response>

Defined in: NativeLibrary.ts:56

Parameters ​
url ​

string

Returns ​

Promise<Response>

manifest? ​

readonly optional manifest?: NativeManifest

Defined in: NativeLibrary.ts:59

packageDir ​

readonly packageDir: string

Defined in: NativeLibrary.ts:53

platform? ​

readonly optional platform?: string

Defined in: NativeLibrary.ts:54

wait? ​

readonly optional wait?: (milliseconds) => Promise<void>

Defined in: NativeLibrary.ts:58

Waits between download attempts; tests pass one that returns at once.

Parameters ​
milliseconds ​

number

Returns ​

Promise<void>


LocateOptions ​

Defined in: NativeLibrary.ts:36

How NativeLibrary.locate looks; tests replace each part.

Properties ​

env? ​

readonly optional env?: ProcessEnv

Defined in: NativeLibrary.ts:37

manifest? ​

readonly optional manifest?: NativeManifest

Defined in: NativeLibrary.ts:40

packageDir? ​

readonly optional packageDir?: string

Defined in: NativeLibrary.ts:38

platform? ​

readonly optional platform?: string

Defined in: NativeLibrary.ts:39


NativeLibraryOptions ​

Defined in: NativeLibrary.ts:13

What a package that ships a native library tells NativeLibrary about it.

Properties ​

buildScripts ​

readonly buildScripts: readonly string[]

Defined in: NativeLibrary.ts:32

The files outside native/ the package's build reads, which its source hash covers.

envPrefix ​

readonly envPrefix: string

Defined in: NativeLibrary.ts:23

The prefix of the package's environment variables, such as JSP_NATIVE_NETWORK: _LIBRARY names a library to load, _SKIP_DOWNLOAD skips the install's download, and _BASE_URL downloads from a mirror.

library ​

readonly library: string

Defined in: NativeLibrary.ts:17

The library's file name without its extension, such as libjsp_native_network.

manifest ​

readonly manifest: unknown

Defined in: NativeLibrary.ts:30

The package's native/manifest.json, as imported JSON. It is imported rather than read from disk, so a bundled executable carries it.

packageDir ​

readonly packageDir: string

Defined in: NativeLibrary.ts:25

The package's root, which holds native/ in a checkout and prebuilds/ once installed.

packageName ​

readonly packageName: string

Defined in: NativeLibrary.ts:15

The npm name, as the messages tell a user to approve or build it.

Type Aliases ​

InstallOutcome ​

InstallOutcome = { bytes: number; kind: "installed"; path: string; } | { kind: "present"; path: string; } | { kind: "no-build"; platform: string; } | { kind: "skipped"; } | { kind: "local-sources"; sourceHash: string; }

Defined in: NativeLibrary.ts:44

What an install did.

Functions ​

localBuildDigest() ​

localBuildDigest(path): string | undefined

Defined in: NativeLibrary.ts:86

The digest a local build recorded in the build.json beside it, which build:native writes.

Parameters ​

path ​

string

The library file.

Returns ​

string | undefined

The digest, or undefined when there is no readable record.


recordLocalBuild() ​

recordLocalBuild(path, digest): void

Defined in: NativeLibrary.ts:105

Records a library's digest in a build.json beside it, as build:native does, so that NativeLibrary.verify accepts the file. Only for bytes that were checked before they were written there, such as a library an executable embedded.

Parameters ​

path ​

string

The library file.

digest ​

string

Its SHA-256.

Returns ​

void