Skip to content

API reference / @jsprismarine/script-host / shape/format

shape/format ​

Interfaces ​

ArrayType ​

Defined in: script-host/src/shape/format.ts:73

An array of one element type.

Properties ​

element ​

readonly element: ShapeType

Defined in: script-host/src/shape/format.ts:75

kind ​

readonly kind: "array"

Defined in: script-host/src/shape/format.ts:74


ClassDeclaration ​

Defined in: script-host/src/shape/format.ts:209

A class. Its base is another class it extends.

Properties ​

base? ​

readonly optional base?: string | ExternalType

Defined in: script-host/src/shape/format.ts:211

conditions? ​

readonly optional conditions?: readonly string[]

Defined in: script-host/src/shape/format.ts:215

runtime_conditions: names of the conditions the class needs, such as Poi in a beta.

iterator? ​

readonly optional iterator?: object

Defined in: script-host/src/shape/format.ts:213

What the class's iterator yields, for a class a script can iterate.

throws? ​

readonly optional throws?: readonly ErrorReference[]

type ​

readonly type: ShapeType

kind ​

readonly kind: "class"

Defined in: script-host/src/shape/format.ts:210


ClosureType ​

Defined in: script-host/src/shape/format.ts:86

A function a script passes in, and the privilege it runs under when one is recorded.

Properties ​

arguments ​

readonly arguments: readonly ShapeType[]

Defined in: script-host/src/shape/format.ts:88

kind ​

readonly kind: "closure"

Defined in: script-host/src/shape/format.ts:87

privilege? ​

readonly optional privilege?: readonly Privilege[]

Defined in: script-host/src/shape/format.ts:90

returns ​

readonly returns: ShapeType

Defined in: script-host/src/shape/format.ts:89


ConstantDeclaration ​

Defined in: script-host/src/shape/format.ts:241

A module-level constant, such as TicksPerSecond.

Properties ​

kind ​

readonly kind: "constant"

Defined in: script-host/src/shape/format.ts:242

type ​

readonly type: ShapeType

Defined in: script-host/src/shape/format.ts:243

value ​

readonly value: string | number | boolean

Defined in: script-host/src/shape/format.ts:244


DeclarationHistory ​

Defined in: script-host/src/shape/format.ts:273

A declaration's history, and each member's.

Properties ​

members? ​

readonly optional members?: Readonly<Record<string, readonly Segment<ShapeMember>[]>>

Defined in: script-host/src/shape/format.ts:275

segments ​

readonly segments: readonly Segment<ShapeDeclaration>[]

Defined in: script-host/src/shape/format.ts:274


EnumDeclaration ​

Defined in: script-host/src/shape/format.ts:225

An enum: an object of constants.

Properties ​

kind ​

readonly kind: "enum"

Defined in: script-host/src/shape/format.ts:226


ErrorDeclaration ​

Defined in: script-host/src/shape/format.ts:230

An error class. Its members are its properties.

Properties ​

kind ​

readonly kind: "error"

Defined in: script-host/src/shape/format.ts:231


ExternalType ​

Defined in: script-host/src/shape/format.ts:46

A class, interface, enum or error of another module, such as @minecraft/common's EngineError.

Properties ​

kind ​

readonly kind: "external"

Defined in: script-host/src/shape/format.ts:47

module ​

readonly module: string

Defined in: script-host/src/shape/format.ts:48

name ​

readonly name: string

Defined in: script-host/src/shape/format.ts:49


FunctionDeclaration ​

Defined in: script-host/src/shape/format.ts:248

A module-level function.

Extends ​

  • ShapeCallable

Properties ​

arguments ​

readonly arguments: readonly ShapeArgument[]

Defined in: script-host/src/shape/format.ts:159

Inherited from ​

ShapeCallable.arguments

kind ​

readonly kind: "function"

Defined in: script-host/src/shape/format.ts:249

override? ​

readonly optional override?: string

Defined in: script-host/src/shape/format.ts:164

The id of the override in scripts/shape/overrides.mts that changed this entry.

Inherited from ​

ShapeCallable.override

privilege ​

readonly privilege: readonly Privilege[]

Defined in: script-host/src/shape/format.ts:158

Inherited from ​

ShapeCallable.privilege

returns ​

readonly returns: ShapeType

Defined in: script-host/src/shape/format.ts:250

script? ​

readonly optional script?: string

Defined in: script-host/src/shape/format.ts:162

raw_script_text: the TypeScript signature of a member the metadata cannot describe otherwise.

Inherited from ​

ShapeCallable.script

throws? ​

readonly optional throws?: readonly ErrorReference[]

Defined in: script-host/src/shape/format.ts:160

Inherited from ​

ShapeCallable.throws


GeneratorType ​

Defined in: script-host/src/shape/format.ts:100

A generator, as system.runJob takes one.

Properties ​

kind ​

readonly kind: "generator"

Defined in: script-host/src/shape/format.ts:101

next ​

readonly next: ShapeType

Defined in: script-host/src/shape/format.ts:103

returns ​

readonly returns: ShapeType

Defined in: script-host/src/shape/format.ts:104

yield ​

readonly yield: ShapeType

Defined in: script-host/src/shape/format.ts:102


InterfaceDeclaration ​

Defined in: script-host/src/shape/format.ts:219

An interface: a plain object shape with no value at run time.

Properties ​

base? ​

readonly optional base?: string | ExternalType

Defined in: script-host/src/shape/format.ts:221

kind ​

readonly kind: "interface"

Defined in: script-host/src/shape/format.ts:220


MapType ​

Defined in: script-host/src/shape/format.ts:79

A plain object used as a map.

Properties ​

key ​

readonly key: ShapeType

Defined in: script-host/src/shape/format.ts:81

kind ​

readonly kind: "map"

Defined in: script-host/src/shape/format.ts:80

value ​

readonly value: ShapeType

Defined in: script-host/src/shape/format.ts:82


ModuleHistory ​

Defined in: script-host/src/shape/format.ts:294

The generated history of one module, the content of one file in src/generated/.

Properties ​

declarations ​

readonly declarations: Readonly<Record<string, DeclarationHistory>>

Defined in: script-host/src/shape/format.ts:304

module ​

readonly module: string

Defined in: script-host/src/shape/format.ts:295

resolves ​

readonly resolves: Readonly<Record<string, string>>

Defined in: script-host/src/shape/format.ts:303

The version BDS serves for each major version: the newest stable minor of that major, so a pack declaring 2.0.0 gets 2.10.0.

uuid ​

readonly uuid: string

Defined in: script-host/src/shape/format.ts:296

versions ​

readonly versions: readonly ModuleVersion[]

Defined in: script-host/src/shape/format.ts:298

Every version the file covers, oldest first. Segments refer to these.


ModuleVersion ​

Defined in: script-host/src/shape/format.ts:282

One published version of a module.

Properties ​

bindings? ​

readonly optional bindings?: string

Defined in: script-host/src/shape/format.ts:286

The module the stub names as its parentModule, which holds the API.

dependencies ​

readonly dependencies: Readonly<Record<string, string>>

Defined in: script-host/src/shape/format.ts:290

The version of each module this one depends on, from peer_dependencies without types_only.

stability ​

readonly stability: VersionStability

Defined in: script-host/src/shape/format.ts:284

version ​

readonly version: string

Defined in: script-host/src/shape/format.ts:283

wrapper? ​

readonly optional wrapper?: string

Defined in: script-host/src/shape/format.ts:288

The stub's wrapper_module.


ObjectDeclaration ​

Defined in: script-host/src/shape/format.ts:235

A module-level object, such as world, of a class in the module.

Properties ​

kind ​

readonly kind: "object"

Defined in: script-host/src/shape/format.ts:236

type ​

readonly type: ShapeType

Defined in: script-host/src/shape/format.ts:237


OptionalType ​

Defined in: script-host/src/shape/format.ts:61

A value that may be undefined.

Properties ​

kind ​

readonly kind: "optional"

Defined in: script-host/src/shape/format.ts:62

type ​

readonly type: ShapeType

Defined in: script-host/src/shape/format.ts:63


PromiseType ​

Defined in: script-host/src/shape/format.ts:94

A promise.

Properties ​

kind ​

readonly kind: "promise"

Defined in: script-host/src/shape/format.ts:95

type ​

readonly type: ShapeType

Defined in: script-host/src/shape/format.ts:96


RangedNumberType ​

Defined in: script-host/src/shape/format.ts:53

A number with a valid_range other than DEFAULT_VALID_RANGE.

Properties ​

kind ​

readonly kind: "number"

Defined in: script-host/src/shape/format.ts:54

max ​

readonly max: number

Defined in: script-host/src/shape/format.ts:57

min ​

readonly min: number

Defined in: script-host/src/shape/format.ts:56

type ​

readonly type: "int32" | "int8" | "uint8" | "int16" | "uint16" | "uint32" | "int64" | "uint64" | "float" | "double"

Defined in: script-host/src/shape/format.ts:55


ScriptTextType ​

Defined in: script-host/src/shape/format.ts:111

A TypeScript type the metadata spells out as text, such as BlockComponentReturnType<T> in a member with raw_script_text. Nothing validates it.

Properties ​

kind ​

readonly kind: "script"

Defined in: script-host/src/shape/format.ts:112

text ​

readonly text: string

Defined in: script-host/src/shape/format.ts:113


SegmentRange ​

Defined in: script-host/src/shape/format.ts:264

The versions a segment covers, by version string: from to to, or to the newest when to is absent.

Properties ​

from ​

readonly from: string

Defined in: script-host/src/shape/format.ts:265

to? ​

readonly optional to?: string

Defined in: script-host/src/shape/format.ts:266


ShapeArgument ​

Defined in: script-host/src/shape/format.ts:140

One argument of a method, a constructor or a module function.

Properties ​

default? ​

readonly optional default?: string | number | boolean | null

Defined in: script-host/src/shape/format.ts:147

details.default_value. Present means the argument may be left out. The metadata writes the string "null" for an argument with no default value, which the generator writes as null.

max? ​

readonly optional max?: number

Defined in: script-host/src/shape/format.ts:151

details.max_value.

maxLength? ​

readonly optional maxLength?: number

Defined in: script-host/src/shape/format.ts:153

details.max_length, for a string.

min? ​

readonly optional min?: number

Defined in: script-host/src/shape/format.ts:149

details.min_value.

name ​

readonly name: string

Defined in: script-host/src/shape/format.ts:141

type ​

readonly type: ShapeType

Defined in: script-host/src/shape/format.ts:142


ShapeConstant ​

Defined in: script-host/src/shape/format.ts:198

A constant of a class or an enum.

Properties ​

kind ​

readonly kind: "constant"

Defined in: script-host/src/shape/format.ts:199

static? ​

readonly optional static?: true

Defined in: script-host/src/shape/format.ts:200

type ​

readonly type: ShapeType

Defined in: script-host/src/shape/format.ts:201

value ​

readonly value: string | number | boolean

Defined in: script-host/src/shape/format.ts:202


ShapeConstructor ​

Defined in: script-host/src/shape/format.ts:175

A class's constructor. A class without one cannot be constructed by a script.

Extends ​

  • ShapeCallable

Properties ​

arguments ​

readonly arguments: readonly ShapeArgument[]

Defined in: script-host/src/shape/format.ts:159

Inherited from ​

ShapeCallable.arguments

kind ​

readonly kind: "constructor"

Defined in: script-host/src/shape/format.ts:176

override? ​

readonly optional override?: string

Defined in: script-host/src/shape/format.ts:164

The id of the override in scripts/shape/overrides.mts that changed this entry.

Inherited from ​

ShapeCallable.override

privilege ​

readonly privilege: readonly Privilege[]

Defined in: script-host/src/shape/format.ts:158

Inherited from ​

ShapeCallable.privilege

script? ​

readonly optional script?: string

Defined in: script-host/src/shape/format.ts:162

raw_script_text: the TypeScript signature of a member the metadata cannot describe otherwise.

Inherited from ​

ShapeCallable.script

throws? ​

readonly optional throws?: readonly ErrorReference[]

Defined in: script-host/src/shape/format.ts:160

Inherited from ​

ShapeCallable.throws


ShapeMethod ​

Defined in: script-host/src/shape/format.ts:168

A method of a class, or a static one.

Extends ​

  • ShapeCallable

Properties ​

arguments ​

readonly arguments: readonly ShapeArgument[]

Defined in: script-host/src/shape/format.ts:159

Inherited from ​

ShapeCallable.arguments

kind ​

readonly kind: "method"

Defined in: script-host/src/shape/format.ts:169

override? ​

readonly optional override?: string

Defined in: script-host/src/shape/format.ts:164

The id of the override in scripts/shape/overrides.mts that changed this entry.

Inherited from ​

ShapeCallable.override

privilege ​

readonly privilege: readonly Privilege[]

Defined in: script-host/src/shape/format.ts:158

Inherited from ​

ShapeCallable.privilege

returns ​

readonly returns: ShapeType

Defined in: script-host/src/shape/format.ts:171

script? ​

readonly optional script?: string

Defined in: script-host/src/shape/format.ts:162

raw_script_text: the TypeScript signature of a member the metadata cannot describe otherwise.

Inherited from ​

ShapeCallable.script

static? ​

readonly optional static?: true

Defined in: script-host/src/shape/format.ts:170

throws? ​

readonly optional throws?: readonly ErrorReference[]

Defined in: script-host/src/shape/format.ts:160

Inherited from ​

ShapeCallable.throws


ShapeProperty ​

Defined in: script-host/src/shape/format.ts:180

A property of a class, error or interface.

Properties ​

baked? ​

readonly optional baked?: true

Defined in: script-host/src/shape/format.ts:186

is_baked, which the metadata does not define.

get? ​

readonly optional get?: readonly Privilege[]

Defined in: script-host/src/shape/format.ts:187

kind ​

readonly kind: "property"

Defined in: script-host/src/shape/format.ts:181

max? ​

readonly optional max?: number

Defined in: script-host/src/shape/format.ts:192

max_value: the largest number the setter accepts.

min? ​

readonly optional min?: number

Defined in: script-host/src/shape/format.ts:190

min_value: the smallest number the setter accepts.

override? ​

readonly optional override?: string

Defined in: script-host/src/shape/format.ts:194

readOnly ​

readonly readOnly: boolean

Defined in: script-host/src/shape/format.ts:184

set? ​

readonly optional set?: readonly Privilege[]

Defined in: script-host/src/shape/format.ts:188

static? ​

readonly optional static?: true

Defined in: script-host/src/shape/format.ts:182

throws? ​

readonly optional throws?: readonly ErrorReference[]

Defined in: script-host/src/shape/format.ts:193

type ​

readonly type: ShapeType

Defined in: script-host/src/shape/format.ts:183


VariantType ​

Defined in: script-host/src/shape/format.ts:67

A value of any one of several types.

Properties ​

kind ​

readonly kind: "variant"

Defined in: script-host/src/shape/format.ts:68

types ​

readonly types: readonly ShapeType[]

Defined in: script-host/src/shape/format.ts:69

Type Aliases ​

ErrorReference ​

ErrorReference = string | ExternalType

Defined in: script-host/src/shape/format.ts:137

An error class a member may throw: a name in the same module, a type from another one, or Error, JavaScript's own.


NumberType ​

NumberType = typeof NUMBER_TYPES[number]

Defined in: script-host/src/shape/format.ts:29

One of NUMBER_TYPES.


PrimitiveType ​

PrimitiveType = NumberType | typeof OTHER_PRIMITIVE_TYPES[number]

Defined in: script-host/src/shape/format.ts:35

A type the metadata names without a declaration behind it.


Privilege ​

Privilege = "default" | "restricted_execution" | "early_execution"

Defined in: script-host/src/shape/format.ts:12

An execution privilege as the metadata names it.


Segment ​

Segment<Value> = SegmentRange & Value

Defined in: script-host/src/shape/format.ts:270

One stretch of versions over which a value stays the same.

Type Parameters ​

Value ​

Value


ShapeDeclaration ​

ShapeDeclaration = ClassDeclaration | InterfaceDeclaration | EnumDeclaration | ErrorDeclaration | ObjectDeclaration | ConstantDeclaration | FunctionDeclaration

Defined in: script-host/src/shape/format.ts:254

A name a module declares. Interfaces are the only ones with no value at run time.


ShapeMember ​

ShapeMember = ShapeMethod | ShapeConstructor | ShapeProperty | ShapeConstant

Defined in: script-host/src/shape/format.ts:206

Anything a declaration holds by name.


ShapeType ​

ShapeType = string | ExternalType | RangedNumberType | OptionalType | VariantType | ArrayType | MapType | ClosureType | PromiseType | GeneratorType | ScriptTextType

Defined in: script-host/src/shape/format.ts:120

A type in the shape. A string is a PrimitiveType or the name of a class, interface or enum in the same module; isPrimitiveType tells them apart.


VersionStability ​

VersionStability = "stable" | "beta"

Defined in: script-host/src/shape/format.ts:279

Whether a version is a stable release or a prerelease such as 2.11.0-beta.

Variables ​

DEFAULT_VALID_RANGE ​

const DEFAULT_VALID_RANGE: object

Defined in: script-host/src/shape/format.ts:43

The valid_range every numeric type in the pinned metadata carries, whatever its type: the int32 range. It says nothing about the type, and BDS does not enforce it on a double (section 3 of docs/research/bedrock-script-api.md), so the generator writes a range only when it differs from this one.

Type Declaration ​

max ​

readonly max: 2147483647 = 2147483647

min ​

readonly min: -2147483648 = -2147483648


NUMBER_TYPES ​

const NUMBER_TYPES: readonly ["int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", "uint64", "float", "double"]

Defined in: script-host/src/shape/format.ts:15

The numeric types the metadata uses. Every one crosses into a script as a JavaScript number.


OTHER_PRIMITIVE_TYPES ​

const OTHER_PRIMITIVE_TYPES: readonly ["boolean", "string", "undefined", "void", "any", "unknown", "error"]

Defined in: script-host/src/shape/format.ts:32

The non-numeric type names that are not a class, interface or enum of the API.

Functions ​

isNumberType() ​

isNumberType(name): name is "int32" | "int8" | "uint8" | "int16" | "uint16" | "uint32" | "int64" | "uint64" | "float" | "double"

Defined in: script-host/src/shape/format.ts:314

Whether a type name is one of the NUMBER_TYPES.

Parameters ​

name ​

string

Returns ​

name is "int32" | "int8" | "uint8" | "int16" | "uint16" | "uint32" | "int64" | "uint64" | "float" | "double"


isPrimitiveType() ​

isPrimitiveType(name): name is PrimitiveType

Defined in: script-host/src/shape/format.ts:311

Whether a type name is a PrimitiveType rather than a declaration of the module.

Parameters ​

name ​

string

Returns ​

name is PrimitiveType