API reference / @jsprismarine/script-host / shape/resolve
shape/resolve
Interfaces
ModuleDependency
Defined in: script-host/src/shape/resolve.ts:8
A pack's native module dependency, as its manifest writes it.
Properties
module_name
readonlymodule_name:string
Defined in: script-host/src/shape/resolve.ts:9
version
readonlyversion:string
Defined in: script-host/src/shape/resolve.ts:10
PackIdentity
Defined in: script-host/src/shape/resolve.ts:14
A pack as BDS's content log names it: its header name and version.
Properties
name
readonlyname:string
Defined in: script-host/src/shape/resolve.ts:15
version
readonlyversion:string
Defined in: script-host/src/shape/resolve.ts:16
ResolveOptions
Defined in: script-host/src/shape/resolve.ts:20
What a resolution needs besides the dependency.
Properties
allowedModules
readonlyallowedModules: readonlystring[]
Defined in: script-host/src/shape/resolve.ts:23
The world's allowed_modules, from permissions.json.
betaApis?
readonlyoptionalbetaApis?:boolean
Defined in: script-host/src/shape/resolve.ts:25
Whether the world turns on the Beta APIs experiment.
histories?
readonlyoptionalhistories?:Readonly<Record<string,ModuleHistory>>
Defined in: script-host/src/shape/resolve.ts:27
The module histories to resolve against. The generated ones when absent.
pack
readonlypack:PackIdentity
Defined in: script-host/src/shape/resolve.ts:21
Type Aliases
Resolution
Resolution = {
ok:true;requested:string;shape:ModuleShape; } | {message:string;ok:false;reason:ResolveFailure; }
Defined in: script-host/src/shape/resolve.ts:39
The API BDS serves for a dependency, or the content log line it refuses the pack with.
ResolveFailure
ResolveFailure =
"not-allowed"|"unknown-module"|"unknown-version"|"beta-disabled"|"internal"|"alpha"
Defined in: script-host/src/shape/resolve.ts:35
Why BDS refuses a dependency. BDS creates no context for a pack refused for an unknown module or version, and logs that beside the reason; the other refusals it logs alone. alpha is the one BDS does not make: it loads an alpha API that this server has no shape for.
Functions
currentBeta()
currentBeta(
history):string|undefined
Defined in: script-host/src/shape/resolve.ts:49
The beta a module's history serves: its newest beta version, which BDS calls the current one.
Parameters
history
Returns
string | undefined
resolveDependency()
resolveDependency(
dependency,options):Resolution
Defined in: script-host/src/shape/resolve.ts:71
Resolves a pack's native module dependency the way the pinned BDS does (section 2 of docs/research/bedrock-script-api.md):
- A module the world's
allowed_modulesleaves out is refused before BDS looks it up, so an unknown module that is also not allowed gets the not-allowed message. - A stable version gets the newest stable minor of its major version, so 2.0.0 gets 2.10.0 and 1.3.0 gets 1.19.0.
- A beta version,
-betaor the wordbeta, needs the Beta APIs experiment, which BDS checks before it checks the version. Beta versions do not follow semver: a pack gets the one beta BDS ships, and the wordbetanames it. - An alpha version,
-alphaor the wordalpha, loads on BDS without the experiment, but no metadata describes its API, so there is nothing to bind it to. It is refused with a message of this server's that says so, where BDS would load the pack (#3233). - Any other version is refused with the versions BDS ships. BDS's list also has a
0.1.0and an-alphaversion for each module, which the metadata does not describe, so this list leaves them out.