Members
(constant) _motionVectorOut :UV
A object reused to save on memory allocation returning u and v vector from motionVector.
Type:
- UV
(private) _RuntimeScriptCache
Exposed RuntimeScriptCache class used by integration in blocks.js.
(constant) _stackFrameFreeList :Array.<_StackFrame>
Recycle bin for empty stackFrame objects
Type:
- Array.<_StackFrame>
(constant) _videoMotionViewComponentsTmp :object
Temporary storage structure for returning values in VideoMotionView._components.
Type:
- object
(constant) ALTO_ID
An id for one of the voices.
(constant) AMOUNT_SCALE :number
A constant value to scale the magnitude of the x and y components called u and v. This creates the motionAmount value.
Old note: chosen empirically to give a range of roughly 0-100
Type:
- number
(constant) ARABIC_ID
Language ids. The value for each language id is a valid Scratch locale.
(constant) ArgumentType :string
Properties:
Name | Type | Description |
---|---|---|
ANGLE |
string | Numeric value with angle picker |
BOOLEAN |
string | Boolean value with hexagonal placeholder |
COLOR |
string | Numeric value with color picker |
NUMBER |
string | Numeric value with text field |
STRING |
string | String value with text field |
MATRIX |
string | String value with matrix field |
NOTE |
string | MIDI note number with note picker (piano) field |
IMAGE |
string | Inline image on block (as part of the label) |
Block argument types
Type:
- string
(constant) ArgumentTypeMap :object.<ArgumentType, {shadowType: string, fieldType: string}>
Information used for converting Scratch argument types into scratch-blocks data.
Type:
- object.<ArgumentType, {shadowType: string, fieldType: string}>
assetData :object
The instrument and drum sounds, loaded as static assets.
Type:
- object
(constant) AxisValues :string
Properties:
Name | Type | Description |
---|---|---|
X |
string | |
Y |
string | |
Z |
string |
Enum for axis menu options.
Type:
- string
(constant) BLEBatteryCheckInterval :number
A time interval to wait (in milliseconds) in between battery check calls.
Type:
- number
(constant) BLECharacteristic
Properties:
Name | Type | Description |
---|---|---|
ATTACHED_IO |
||
LOW_VOLTAGE_ALERT |
||
INPUT_VALUES |
||
INPUT_COMMAND |
||
OUTPUT_COMMAND |
A list of WeDo 2.0 BLE characteristic UUIDs.
Characteristics on DEVICE_SERVICE:
- ATTACHED_IO
Characteristics on IO_SERVICE:
- INPUT_VALUES
- INPUT_COMMAND
- OUTPUT_COMMAND
(constant) BLECommand :number
Properties:
Name | Type | Description |
---|---|---|
CMD_PIN_CONFIG |
number | |
CMD_DISPLAY_TEXT |
number | |
CMD_DISPLAY_LED |
number |
Enum for micro:bit BLE command protocol. https://github.com/LLK/scratch-microbit-firmware/blob/master/protocol.md
Type:
- number
(constant) BLEDataStoppedError :string
A string to report to the BLE socket when the micro:bit has stopped receiving data.
Type:
- string
(constant) BLEDataStoppedError :string
A string to report to the BLE socket when the GdxFor has stopped receiving data.
Type:
- string
(constant) BLESendInterval :number
A time interval to wait (in milliseconds) while a block that sends a BLE message is running.
Type:
- number
(constant) BLESendInterval :number
A time interval to wait (in milliseconds) while a block that sends a BLE message is running.
Type:
- number
(constant) BLESendRateMax :number
A maximum number of BLE message sends per second, to be enforced by the rate limiter.
Type:
- number
(constant) BLEService
Properties:
Name | Type | Description |
---|---|---|
DEVICE_SERVICE |
||
IO_SERVICE |
A list of WeDo 2.0 BLE service UUIDs.
(constant) BLETimeout
A time interval to wait (in milliseconds) before reporting to the BLE socket that data has stopped coming from the peripheral.
(constant) BLETimeout
A time interval to wait (in milliseconds) before reporting to the BLE socket that data has stopped coming from the peripheral.
(constant) BLEUUID :string
Properties:
Name | Type | Description |
---|---|---|
service |
string | |
rxChar |
string | |
txChar |
string |
Enum for micro:bit protocol. https://github.com/LLK/scratch-microbit-firmware/blob/master/protocol.md
Type:
- string
(constant) BLEUUID :string
Properties:
Name | Type | Description |
---|---|---|
service |
string | |
commandChar |
string | |
responseChar |
string |
Enum for Vernier godirect protocol.
Type:
- string
(constant) blockFunctionProfilerFrame :string
Profiler frame name for block functions.
Type:
- string
blockFunctionProfilerId :number
Profiler frame ID for 'blockFunction'.
Type:
- number
(constant) blockIconURI :string
Icon png to be displayed at the left edge of each extension block, encoded as a data URI.
Type:
- string
(constant) blockIconURI :string
Icon svg to be displayed at the left edge of each extension block, encoded as a data URI.
Type:
- string
(constant) blockIconURI :string
Icon svg to be displayed at the left edge of each extension block, encoded as a data URI.
Type:
- string
(constant) blockIconURI :string
Icon svg to be displayed at the left edge of each extension block, encoded as a data URI.
Type:
- string
(constant) blockIconURI :string
Icon svg to be displayed at the left edge of each extension block, encoded as a data URI.
Type:
- string
(constant) blockIconURI :string
Icon svg to be displayed at the left edge of each extension block, encoded as a data URI.
Type:
- string
(constant) blockIconURI :string
Icon svg to be displayed at the left edge of each extension block, encoded as a data URI.
Type:
- string
(constant) blockIconURI :string
Icon svg to be displayed at the left edge of each extension block, encoded as a data URI.
Type:
- string
(constant) blockIconURI :string
Icon png to be displayed at the left edge of each extension block, encoded as a data URI.
Type:
- string
(constant) BlockType :string
Properties:
Name | Type | Description |
---|---|---|
BOOLEAN |
string | Boolean reporter with hexagonal shape |
BUTTON |
string | A button (not an actual block) for some special action, like making a variable |
COMMAND |
string | Command block |
CONDITIONAL |
string | Specialized command block which may or may not run a child branch The thread continues with the next block whether or not a child branch ran. |
EVENT |
string | Specialized hat block with no implementation function This stack only runs if the corresponding event is emitted by other code. |
HAT |
string | Hat block which conditionally starts a block stack |
LOOP |
string | Specialized command block which may or may not run a child branch If a child branch runs, the thread evaluates the loop block again. |
REPORTER |
string | General reporter with numeric or string value |
Types of block
Type:
- string
(constant) blockUtility
Single BlockUtility instance reused by execute for every pritimive ran.
(constant) BoostBLE :string
Properties:
Name | Type | Description |
---|---|---|
service |
string | |
characteristic |
string | |
sendInterval |
string | |
sendRateMax |
string |
Boost BLE UUIDs.
Type:
- string
(constant) BoostColor :string
Properties:
Name | Type | Description |
---|---|---|
ANY |
string | |
NONE |
string | |
RED |
string | |
BLUE |
string | |
GREEN |
string | |
YELLOW |
string | |
WHITE |
string | |
BLACK |
string |
Ids for each color sensor value used by the extension.
Type:
- string
(constant) BoostColorIndex :number
Properties:
Name | Type | Description |
---|---|---|
"BoostColor.NONE" |
number | |
"BoostColor.RED" |
number | |
"BoostColor.BLUE" |
number | |
"BoostColor.GREEN" |
number | |
"BoostColor.YELLOW" |
number | |
"BoostColor.WHITE" |
number | |
"BoostColor.BLACK" |
number |
Enum for indices for each color sensed by the Boost vision sensor.
Type:
- number
(constant) BoostColorSampleSize :number
The number of continuous samples the color-sensor will evaluate color from.
Type:
- number
(constant) BoostHubProperty :number
Properties:
Name | Type | Description |
---|---|---|
ADVERTISEMENT_NAME |
number | |
BUTTON |
number | |
FW_VERSION |
number | |
HW_VERSION |
number | |
RSSI |
number | |
BATTERY_VOLTAGE |
number | |
BATTERY_TYPE |
number | |
MANUFACTURER_NAME |
number | |
RADIO_FW_VERSION |
number | |
LEGO_WP_VERSION |
number | |
SYSTEM_TYPE_ID |
number | |
HW_NETWORK_ID |
number | |
PRIMARY_MAC |
number | |
SECONDARY_MAC |
number | |
HW_NETWORK_FAMILY |
number |
Enum for Hub Property Types
Type:
- number
(constant) BoostHubPropertyOperation :number
Properties:
Name | Type | Description |
---|---|---|
SET |
number | |
ENABLE_UPDATES |
number | |
DISABLE_UPDATES |
number | |
RESET |
number | |
REQUEST_UPDATE |
number | |
UPDATE |
number |
Enum for Hub Property Operations
Type:
- number
(constant) BoostIO :number
Properties:
Name | Type | Description |
---|---|---|
MOTOR_WEDO |
number | |
MOTOR_SYSTEM |
number | |
BUTTON |
number | |
LIGHT |
number | |
VOLTAGE |
number | |
CURRENT |
number | |
PIEZO |
number | |
LED |
number | |
TILT_EXTERNAL |
number | |
MOTION_SENSOR |
number | |
COLOR |
number | |
MOTOREXT |
number | |
MOTORINT |
number | |
TILT |
number |
Enum for Boost sensor and actuator types.
Type:
- number
(constant) BoostIOEvent :number
Properties:
Name | Type | Description |
---|---|---|
ATTACHED |
number | |
DETACHED |
number | |
ATTACHED_VIRTUAL |
number |
Enum for when Boost IO's are attached/detached
Type:
- number
(constant) BoostMessage :number
Properties:
Name | Type | Description |
---|---|---|
HUB_PROPERTIES |
number | |
HUB_ACTIONS |
number | |
HUB_ALERTS |
number | |
HUB_ATTACHED_IO |
number | |
ERROR |
number | |
PORT_INPUT_FORMAT_SETUP_SINGLE |
number | |
PORT_INPUT_FORMAT_SETUP_COMBINED |
number | |
PORT_INFORMATION |
number | |
PORT_MODEINFORMATION |
number | |
PORT_VALUE |
number | |
PORT_VALUE_COMBINED |
number | |
PORT_INPUT_FORMAT |
number | |
PORT_INPUT_FORMAT_COMBINED |
number | |
OUTPUT |
number | |
PORT_FEEDBACK |
number |
Enum for Message Types
Type:
- number
(constant) BoostMode :number
Properties:
Name | Type | Description |
---|---|---|
TILT |
number | |
LED |
number | |
COLOR |
number | |
MOTOR_SENSOR |
number | |
UNKNOWN |
number |
Enum for selected sensor modes.
Type:
- number
(constant) BoostMotorDirection :string
Properties:
Name | Type | Description |
---|---|---|
FORWARD |
string | |
BACKWARD |
string | |
REVERSE |
string |
Enum for motor direction specification.
Type:
- string
(constant) BoostMotorEndState :number
Properties:
Name | Type | Description |
---|---|---|
FLOAT |
number | |
HOLD |
number | |
BRAKE |
number |
Enum for Boost Motor end states
Type:
- number
(constant) BoostMotorLabel :string
Properties:
Name | Type | Description |
---|---|---|
A |
string | |
B |
string | |
C |
string | |
D |
string | |
AB |
string | |
ALL |
string |
Enum for motor specification.
Type:
- string
(constant) BoostMotorMaxPowerAdd :number
Boost Motor Max Power Add. Defines how much more power than the target speed the motors may supply to reach the target speed faster. Lower number == softer, slower reached target speed. Higher number == harder, faster reached target speed.
Type:
- number
(constant) BoostMotorProfile :number
Properties:
Name | Type | Description |
---|---|---|
DO_NOT_USE |
number | |
ACCELERATION |
number | |
DECELERATION |
number |
Enum for Boost Motor acceleration/deceleration profiles
Type:
- number
(constant) BoostMotorState
Enum for Boost motor states.
(constant) BoostOutputExecution :number
Properties:
Name | Type | Description |
---|---|---|
BUFFER_IF_NECESSARY |
number | |
EXECUTE_IMMEDIATELY |
number | |
NO_ACTION |
number | |
COMMAND_FEEDBACK |
number |
Enum for Startup/Completion information for an output command. Startup and completion bytes must be OR'ed to be combined to a single byte.
Type:
- number
(constant) BoostOutputSubCommand :number
Properties:
Name | Type | Description |
---|---|---|
START_POWER |
number | |
START_POWER_PAIR |
number | |
SET_ACC_TIME |
number | |
SET_DEC_TIME |
number | |
START_SPEED |
number | |
START_SPEED_PAIR |
number | |
START_SPEED_FOR_TIME |
number | |
START_SPEED_FOR_TIME_PAIR |
number | |
START_SPEED_FOR_DEGREES |
number | |
START_SPEED_FOR_DEGREES_PAIR |
number | |
GO_TO_ABS_POSITION |
number | |
GO_TO_ABS_POSITION_PAIR |
number | |
PRESET_ENCODER |
number | |
WRITE_DIRECT_MODE_DATA |
number |
Enum for Motor Subcommands (for 0x81)
Type:
- number
(constant) BoostPingInterval :number
A time interval to wait (in milliseconds) in between battery check calls.
Type:
- number
(constant) BoostPort10000223OrOlder :number
Properties:
Name | Type | Description |
---|---|---|
A |
number | |
B |
number | |
C |
number | |
D |
number |
Enum for physical Boost Ports
Type:
- number
(constant) BoostPortFeedback :number
Properties:
Name | Type | Description |
---|---|---|
IN_PROGRESS |
number | |
COMPLETED |
number | |
DISCARDED |
number | |
IDLE |
number | |
BUSY_OR_FULL |
number |
Enum for ids for various output command feedback types on the Boost.
Type:
- number
(constant) BoostTiltDirection :string
Properties:
Name | Type | Description |
---|---|---|
UP |
string | |
DOWN |
string | |
LEFT |
string | |
RIGHT |
string | |
ANY |
string |
Enum for tilt sensor direction.
Type:
- string
(constant) BTSendRateMax :number
A maximum number of BT message sends per second, to be enforced by the rate limiter.
Type:
- number
(constant) ColorParam :string
Properties:
Name | Type | Description |
---|---|---|
COLOR |
string | |
SATURATION |
string | |
BRIGHTNESS |
string | |
TRANSPARENCY |
string |
Enum for pen color parameter values.
Type:
- string
(constant) Ev3Args :number
Properties:
Name | Type | Description |
---|---|---|
LAYER |
number | |
COAST |
number | |
BRAKE |
number | |
RAMP |
number | |
DO_NOT_CHANGE_TYPE |
number | |
MAX_DEVICES |
number |
Enum for Ev3 values used as arguments to various opcodes. Found in the 'EV3 Firmware Developer Kit', section4, page 10-onwards, at https://education.lego.com/en-us/support/mindstorms-ev3/developer-kits.
Type:
- number
(constant) Ev3Command :number
Properties:
Name | Type | Description |
---|---|---|
DIRECT_COMMAND_REPLY |
number | |
DIRECT_COMMAND_NO_REPLY |
number | |
DIRECT_REPLY |
number |
Enum for Ev3 direct command types. Found in the 'EV3 Communication Developer Kit', section 4, page 24, at https://education.lego.com/en-us/support/mindstorms-ev3/developer-kits.
Type:
- number
(constant) Ev3Device :string
Properties:
Name | Type | Description |
---|---|---|
29 |
string | |
30 |
string | |
32 |
string | |
16 |
string | |
8 |
string | |
7 |
string | |
126 |
string | |
125 |
string |
Enum for Ev3 device type numbers. Found in the 'EV3 Firmware Developer Kit', section 5, page 100, at https://education.lego.com/en-us/support/mindstorms-ev3/developer-kits.
Type:
- string
(constant) Ev3Encoding :number
Properties:
Name | Type | Description |
---|---|---|
ONE_BYTE |
number | |
TWO_BYTES |
number | |
FOUR_BYTES |
number | |
GLOBAL_VARIABLE_ONE_BYTE |
number | |
GLOBAL_CONSTANT_INDEX_0 |
number | |
GLOBAL_VARIABLE_INDEX_0 |
number |
Enum for Ev3 parameter encodings of various argument and return values. Found in the 'EV3 Firmware Developer Kit', section4, page 9, at https://education.lego.com/en-us/support/mindstorms-ev3/developer-kits.
The format for these values is: 0xxxxxxx for Short Format 1ttt-bbb for Long Format
Type:
- number
(constant) Ev3Label :string
Properties:
Name | Type | Description |
---|---|---|
touch |
string | |
color |
string | |
ultrasonic |
string |
Enum for Ev3 device labels used in the Scratch blocks/UI.
Type:
- string
(constant) Ev3Mode :number
Properties:
Name | Type | Description |
---|---|---|
touch |
number | |
color |
number | |
ultrasonic |
number | |
none |
number |
Enum for Ev3 device modes. Found in the 'EV3 Firmware Developer Kit', section 5, page 100, at https://education.lego.com/en-us/support/mindstorms-ev3/developer-kits.
Type:
- number
(constant) Ev3MotorMenu :string
Enum for motor port names. Note: if changed, will break compatibility with previously saved projects.
Type:
- string
(constant) Ev3Opcode :number
Properties:
Name | Type | Description |
---|---|---|
OPOUTPUT_STEP_SPEED |
number | |
OPOUTPUT_TIME_SPEED |
number | |
OPOUTPUT_STOP |
number | |
OPOUTPUT_RESET |
number | |
OPOUTPUT_STEP_SYNC |
number | |
OPOUTPUT_TIME_SYNC |
number | |
OPOUTPUT_GET_COUNT |
number | |
OPSOUND |
number | |
OPSOUND_CMD_TONE |
number | |
OPSOUND_CMD_STOP |
number | |
OPINPUT_DEVICE_LIST |
number | |
OPINPUT_READSI |
number |
Enum for Ev3 commands opcodes. Found in the 'EV3 Firmware Developer Kit', section 4, page 10, at https://education.lego.com/en-us/support/mindstorms-ev3/developer-kits.
Type:
- number
(constant) Ev3PairingPin
String with Ev3 expected pairing pin.
(constant) Ev3SensorMenu :string
Enum for sensor port names. Note: if changed, will break compatibility with previously saved projects.
Type:
- string
(constant) executeProfilerFrame :string
Profiler frame name for execute.
Type:
- string
executeProfilerId :number
Profiler frame ID for executeProfilerFrame.
Type:
- number
(constant) extensionWorker
Expose only specific parts of the worker to extensions.
(constant) FACING_THRESHOLD :number
Threshold for acceleration magnitude, to check if we are facing up.
Type:
- number
(constant) FACING_THRESHOLD_OFFSET :number
An offset for the facing threshold, used to check that we are no longer facing up.
Type:
- number
(constant) FEMALE_GIANT_RATE
Playback rate for the giant voice, for cases where we have only a female gender voice.
(constant) FEMALE_TENOR_RATE
Playback rate for the tenor voice, for cases where we have only a female gender voice.
(constant) finalResponseTimeoutDurationMs :int
The amount of time to wait between when we stop sending speech data to the server and when we expect the transcription result marked with isFinal: true to come back from the server.
Type:
- int
(constant) FORCE_THRESHOLD :number
Threshold for pushing and pulling force, for the whenForcePushedOrPulled hat block.
Type:
- number
(constant) FREEFALL_ROTATION_FACTOR :number
Factor used to account for influence of rotation during freefall.
Type:
- number
(constant) FREEFALL_THRESHOLD :number
Threshold for acceleration magnitude, below which we are in freefall.
Type:
- number
(constant) GDXFOR_SENSOR
Sensor ID numbers for the GDX-FOR.
(constant) GDXFOR_UPDATE_RATE
The update rate, in milliseconds, for sensor data input from the peripheral.
(constant) generateVariableIdGetter
Create a callback for assigning fixed IDs to imported variables Generator stores the global variable mapping in a closure
(constant) GestureValues :string
Properties:
Name | Type | Description |
---|---|---|
SHAKEN |
string | |
STARTED_FALLING |
string | |
TURNED_FACE_UP |
string | |
TURNED_FACE_DOWN |
string |
Enum for motion gesture menu options.
Type:
- string
(constant) GIANT_ID
An id for one of the voices.
(constant) GRAVITY :number
Acceleration due to gravity, in m/s^2.
Type:
- number
(constant) HEIGHT :number
The height of the intended resolution to analyze for motion.
Type:
- number
(constant) iconURI :string
Url of icon to be displayed at the left edge of each extension block.
Type:
- string
(constant) iconURI :string
Icon svg to be displayed at the left edge of each extension block, encoded as a data URI.
Type:
- string
(constant) iconURI :string
Icon svg to be displayed at the left edge of each extension block, encoded as a data URI.
Type:
- string
(constant) KEY_BUFFER_LENGTH :number
Length of the buffer to store key presses for the "when keys pressed in order" hat
Type:
- number
(constant) KEY_ID_DOWN
An id for the down arrow key on a keyboard.
(constant) KEY_ID_LEFT
An id for the left arrow key on a keyboard.
(constant) KEY_ID_RIGHT
An id for the right arrow key on a keyboard.
(constant) KEY_ID_SPACE
An id for the space key on a keyboard.
(constant) KEY_ID_UP
An id for the up arrow key on a keyboard.
(constant) KEY_NAME :string
Properties:
Name | Type | Description |
---|---|---|
SPACE |
string | |
LEFT |
string | |
UP |
string | |
RIGHT |
string | |
DOWN |
string | |
ENTER |
string |
Names used internally for keys used in scratch, also known as "scratch keys".
Type:
- string
(constant) KEY_NAME_LIST :Array.<string>
An array of the names of scratch keys.
Type:
- Array.<string>
(constant) KITTEN_ID
An id for one of the voices.
(constant) listenAndWaitBlockTimeoutMs :int
The max amount of time the Listen And Wait block will listen for. It may listen for less time if we get back results that are good and think the user is done talking. Currently set to 10sec. This should not exceed the speech api limit (60sec) without redoing how we stream the microphone data data.
Type:
- int
(constant) LOCAL_AMOUNT_SCALE :number
A constant value to scale the magnitude of the x and y components called u and v in the local motion derivative. This creates the motionAmount value on a target's motion state.
Old note: note 2e-4 * activePixelNum is an experimentally tuned threshold for my logitech Pro 9000 webcam - TTH
Type:
- number
(constant) LOCAL_MAX_AMOUNT :number
A ceiling for the motionAmount stored to a local target's motion state. The motionAmount is not allowed to be larger than LOCAL_MAX_AMOUNT.
Type:
- number
(constant) LOCAL_THRESHOLD :number
The motion amount for a target's local motion must be higher than the LOCAL_THRESHOLD to calculate a new direction value.
Type:
- number
(constant) menuIconURI :string
Icon svg to be displayed in the blocks category menu, encoded as a data URI.
Type:
- string
(constant) menuIconURI :string
Icon png to be displayed in the blocks category menu, encoded as a data URI.
Type:
- string
(constant) menuIconURI :string
Url of icon to be displayed in the toolbox menu for the extension category.
Type:
- string
(constant) menuIconURI :string
Icon svg to be displayed in the category menu, encoded as a data URI.
Type:
- string
(constant) menuIconURI :string
Icon svg to be displayed in the blocks category menu, encoded as a data URI.
Type:
- string
(constant) menuIconURI :string
Icon svg to be displayed in the blocks category menu, encoded as a data URI.
Type:
- string
(constant) MicroBitButtons :string
Properties:
Name | Type | Description |
---|---|---|
A |
string | |
B |
string | |
ANY |
string |
Enum for micro:bit buttons.
Type:
- string
(constant) MicroBitGestures :string
Properties:
Name | Type | Description |
---|---|---|
MOVED |
string | |
SHAKEN |
string | |
JUMPED |
string |
Enum for micro:bit gestures.
Type:
- string
(constant) MicroBitPinState :string
Properties:
Name | Type | Description |
---|---|---|
ON |
string | |
OFF |
string |
Enum for micro:bit pin states.
Type:
- string
(constant) MicroBitTiltDirection :string
Properties:
Name | Type | Description |
---|---|---|
FRONT |
string | |
BACK |
string | |
LEFT |
string | |
RIGHT |
string | |
ANY |
string |
Enum for tilt sensor direction.
Type:
- string
nextId :number
The next id returned for a new profile'd function.
Type:
- number
(constant) OUTPUT :object
Modes of debug output that can be rendered.
Type:
- object
(constant) performance :Performance
Stored reference to Performance instance provided by the Browser.
Type:
- Performance
(constant) profilerNames :Object.<string, number>
The mapping of names to ids.
Type:
- Object.<string, number>
(constant) PushPullValues :string
Properties:
Name | Type | Description |
---|---|---|
PUSHED |
string | |
PULLED |
string |
Enum for pushed and pulled menu options.
Type:
- string
rendererDrawProfilerId :number
Numeric ID for RenderWebGL.draw in Profiler instances.
Type:
- number
(constant) ReporterScope :string
Properties:
Name | Type | Description |
---|---|---|
GLOBAL |
string | This reporter's value is global and does not depend on context. |
TARGET |
string | This reporter's value is specific to a particular target/sprite. Another target may have a different value or may not even have a value. |
Indicate the scope for a reporter's value.
Type:
- string
(constant) RuntimeScriptCache :function
Cache class constructor for runtime. Used to consider what threads should start based on hat data.
Type:
- function
(constant) SCRATCH_KEY_NAME :string
Properties:
Name | Type | Description |
---|---|---|
KEY_ID_SPACE |
string | |
KEY_ID_LEFT |
string | |
KEY_ID_UP |
string | |
KEY_ID_RIGHT |
string | |
KEY_ID_DOWN |
string |
Names used by keyboard io for keys used in scratch.
Type:
- string
(constant) ScratchBlocksConstants :int
- To Do:
-
- find a way to require() these straight from scratch-blocks... maybe make a scratch-blocks/dist/constants.js?
Properties:
Name | Type | Description |
---|---|---|
OUTPUT_SHAPE_HEXAGONAL |
int | ENUM for output shape: hexagonal (booleans/predicates). |
OUTPUT_SHAPE_ROUND |
int | ENUM for output shape: rounded (numbers). |
OUTPUT_SHAPE_SQUARE |
int | ENUM for output shape: squared (any/all values; strings). |
These constants are copied from scratch-blocks/core/constants.js
Type:
- int
(constant) SensingAttribute :string
Properties:
Name | Type | Description |
---|---|---|
MOTION |
string | The amount of motion. |
DIRECTION |
string | The direction of the motion. |
Sensor attribute video sensor block should report.
Type:
- string
(constant) SensingSubject :string
Properties:
Name | Type | Description |
---|---|---|
STAGE |
string | The sensor traits of the whole stage. |
SPRITE |
string | The senosr traits of the area overlapped by this sprite. |
Subject video sensor block should report for.
Type:
- string
(constant) SEQUENCE_HAT_TIMEOUT :number
Timeout in milliseconds to reset the completed flag for a sequence.
Type:
- number
(constant) SERVER_HOST :string
The url of the synthesis server.
Type:
- string
(constant) SERVER_TIMEOUT :int
How long to wait in ms before timing out requests to synthesis server.
Type:
- int
(constant) serverTimeoutMs :int
How long to wait in ms before timing out requests to translate server.
Type:
- int
(constant) serverURL :string
The url of the speech server.
Type:
- string
(constant) serverURL :string
The url of the translate server.
Type:
- string
(constant) SHAKEN_THRESHOLD :number
Threshold for acceleration magnitude, for the "shaken" gesture.
Type:
- number
(private, constant) soup_
Legal characters for the unique ID. Should be all on a US keyboard. No XML special characters or control codes. Removed $ due to issue 251.
(constant) specMap :object.<SB2SpecMap_blockInfo>
Mapping of Scratch 2.0 opcode to Scratch 3.0 block metadata.
Type:
- object.<SB2SpecMap_blockInfo>
(constant) SPEECH_VOLUME :number
Volume for playback of speech sounds, as a percentage.
Type:
- number
spriteName
Present only if the monitor is sprite-specific, such as x position
(constant) SQUEAK_ID
An id for one of the voices.
(constant) START :number
The START event identifier in Profiler records.
Type:
- number
(constant) START_SIZE :number
The number of cells used in the records array by a START event.
Type:
- number
stepProfilerId :number
Numeric ID for Runtime._step in Profiler instances.
Type:
- number
(constant) stepThreadProfilerFrame :string
Profiler frame name for stepping a single thread.
Type:
- string
stepThreadProfilerId :number
Profiler frame ID for stepThreadProfilerFrame.
Type:
- number
(constant) stepThreadsInnerProfilerFrame :string
Profiler frame name for the inner loop of stepThreads.
Type:
- string
stepThreadsInnerProfilerId :number
Profiler frame ID for stepThreadsInnerProfilerFrame.
Type:
- number
stepThreadsProfilerId :number
Numeric ID for Sequencer.stepThreads in Profiler instances.
Type:
- number
(constant) STOP :number
The STOP event identifier in Profiler records.
Type:
- number
(constant) STOP_SIZE :number
The number of cells used in the records array by a STOP event.
Type:
- number
(constant) STORE_WAITING :boolean
Occluded boolean value to make its use more understandable.
Type:
- boolean
targetId
Present only if the monitor is sprite-specific, such as x position
(constant) TargetType :string
Properties:
Name | Type | Description |
---|---|---|
SPRITE |
string | Rendered target which can move, change costumes, etc. |
STAGE |
string | Rendered target which cannot move but can change backdrops |
Default types of Target supported by the VM
Type:
- string
(constant) TENOR_ID
An id for one of the voices.
(constant) THRESHOLD :number
The motion amount must be higher than the THRESHOLD to calculate a new direction value.
Type:
- number
(constant) TILT_THRESHOLD :number
Threshold in degrees for reporting that the sensor is tilted.
Type:
- number
(constant) TiltAxisValues :string
Properties:
Name | Type | Description |
---|---|---|
FRONT |
string | |
BACK |
string | |
LEFT |
string | |
RIGHT |
string | |
ANY |
string |
Enum for tilt axis menu options.
Type:
- string
(constant) TO_DEGREE :number
A constant value helping to transform a value in radians to degrees.
Type:
- number
(constant) VideoState :string
Properties:
Name | Type | Description |
---|---|---|
OFF |
string | Video turned off. |
ON |
string | Video turned on with default y axis mirroring. |
ON_FLIPPED |
string | Video turned on without default y axis mirroring. |
States the video sensing activity can be set to.
Type:
- string
(constant) WeDo2Command :number
Properties:
Name | Type | Description |
---|---|---|
MOTOR_POWER |
number | |
PLAY_TONE |
number | |
STOP_TONE |
number | |
WRITE_RGB |
number | |
SET_VOLUME |
number |
Enum for ids for various output commands on the WeDo 2.0.
Type:
- number
(constant) WeDo2ConnectID :number
Properties:
Name | Type | Description |
---|---|---|
LED |
number | |
PIEZO |
number |
Enum for connection/port ids assigned to internal WeDo 2.0 output devices.
Type:
- number
(constant) WeDo2Device :number
Properties:
Name | Type | Description |
---|---|---|
MOTOR |
number | |
PIEZO |
number | |
LED |
number | |
TILT |
number | |
DISTANCE |
number |
Enum for WeDo 2.0 sensor and output types.
Type:
- number
(constant) WeDo2Mode :number
Properties:
Name | Type | Description |
---|---|---|
TILT |
number | |
DISTANCE |
number | |
LED |
number |
Enum for modes for input sensors on the WeDo 2.0.
Type:
- number
(constant) WeDo2MotorDirection :string
Properties:
Name | Type | Description |
---|---|---|
FORWARD |
string | |
BACKWARD |
string | |
REVERSE |
string |
Enum for motor direction specification.
Type:
- string
(constant) WeDo2MotorLabel :string
Properties:
Name | Type | Description |
---|---|---|
DEFAULT |
string | |
A |
string | |
B |
string | |
ALL |
string |
Enum for motor specification.
Type:
- string
(constant) WeDo2TiltDirection :string
Properties:
Name | Type | Description |
---|---|---|
UP |
string | |
DOWN |
string | |
LEFT |
string | |
RIGHT |
string | |
ANY |
string |
Enum for tilt sensor direction.
Type:
- string
(constant) WeDo2Unit :number
Properties:
Name | Type | Description |
---|---|---|
TILT |
number | |
DISTANCE |
number | |
LED |
number |
Enum for units for input sensors on the WeDo 2.0.
0 = raw 1 = percent
Type:
- number
(constant) WIDTH :number
The width of the intended resolution to analyze for motion.
Type:
- number
(constant) WINSIZE :number
The size of the radius of the window of summarized values when considering the motion inside the full resolution of the sample.
Type:
- number
Methods
_prepareBlockProfiling(profiler, blockCached)
Initialize a BlockCached instance so its command/hat block and reporters can be profiled during execution.
Parameters:
Name | Type | Description |
---|---|---|
profiler |
Profiler | The profiler that is currently enabled. |
blockCached |
BlockCached | The blockCached instance to profile. |
adapter(e) → {Array.<object>}
Adapter between block creation events and block representation which can be used by the Scratch runtime.
Parameters:
Name | Type | Description |
---|---|---|
e |
object |
|
Returns:
List of blocks from this CREATE event.
- Type
- Array.<object>
addExtensionOp(sb2Extension, sb2Opcode, blockInfo)
Add to the specMap entries for an opcode from a Scratch 2.0 extension. Two entries will be made with the same metadata; this is done to support projects saved by both older and newer versions of the Scratch 2.0 editor.
Parameters:
Name | Type | Description |
---|---|---|
sb2Extension |
string | the Scratch 2.0 name of the extension |
sb2Opcode |
string | the Scratch 2.0 opcode |
blockInfo |
SB2SpecMap_blockInfo | the Scratch 3.0 block info |
cloudDataManager() → {CloudDataManager}
Creates and manages cloud variable limit in a project, and returns two functions to be used to add a new cloud variable (while checking that it can be added) and remove an existing cloud variable. These are to be called whenever attempting to create or delete a cloud variable.
Returns:
The functions to be used when adding or removing a cloud variable.
- Type
- CloudDataManager
compressInputTree(block, blocks) → {object}
Compresses the serialized inputs replacing block/shadow ids that refer to one of the primitives with the primitive itself. E.g.
blocks: { aUidForMyBlock: { inputs: { MYINPUT: [1, 'aUidForAnUnobscuredShadowPrimitive'] } }, aUidForAnUnobscuredShadowPrimitive: [4, 10] // the above is a primitive representing a 'math_number' with value 10 }
becomes:
blocks: { aUidForMyBlock: { inputs: { MYINPUT: [1, [4, 10]] } } } Note: this function modifies the given blocks object in place
Parameters:
Name | Type | Description |
---|---|---|
block |
object | The block with inputs to compress |
blocks |
objec | The object containing all the blocks currently getting serialized |
Returns:
The serialized block with compressed inputs
- Type
- object
defineMessages(messages) → {object.<MessageDescriptor>}
This is a hook for extracting messages from extension source files. This function simply returns the message descriptor map object that's passed in.
Parameters:
Name | Type | Description |
---|---|---|
messages |
object.<MessageDescriptor> | the messages to be defined |
Returns:
- the input, unprocessed
- Type
- object.<MessageDescriptor>
deserialize(json, runtime, zip, isSingleSprite) → {Promise.<ImportedProject>}
Deserialize the specified representation of a VM runtime and loads it into the provided runtime instance.
Parameters:
Name | Type | Description |
---|---|---|
json |
object | JSON representation of a VM runtime. |
runtime |
Runtime | Runtime instance |
zip |
JSZip | Sb3 file describing this project (to load assets from) |
isSingleSprite |
boolean | If true treat as single sprite, else treat as whole project |
Returns:
Promise that resolves to the list of targets after the project is deserialized
- Type
- Promise.<ImportedProject>
deserializeBlocks(blocks) → {object}
Covnert serialized INPUT and FIELD primitives back to hydrated block templates. Should be able to deserialize a format that has already been deserialized. The only "east" path to adding new targets/code requires going through deserialize, so it should work with pre-parsed deserialized blocks.
Parameters:
Name | Type | Description |
---|---|---|
blocks |
object | Serialized SB3 "blocks" property of a target. Will be mutated. |
Returns:
input is modified and returned
- Type
- object
deserializeCostume(costume, runtime, zip, assetFileName, textLayerFileName) → {Promise}
Deserializes costume from file into storage cache so that it can be loaded into the runtime.
Parameters:
Name | Type | Description |
---|---|---|
costume |
object | Descriptor for costume from sb3 file |
runtime |
Runtime | The runtime containing the storage to cache the costumes in |
zip |
JSZip | The zip containing the costume file being described by |
assetFileName |
string | Optional file name for the given asset (sb2 files have filenames of the form [int].[ext], sb3 files have filenames of the form [md5].[ext]) |
textLayerFileName |
string | Optional file name for the given asset's text layer (sb2 only; files have filenames of the form [int].png) |
Returns:
Promise that resolves after the described costume has been stored into the runtime storage cache, the costume was already stored, or an error has occurred.
- Type
- Promise
deserializeFields(fields) → {object}
Deserialize the given block fields.
Parameters:
Name | Type | Description |
---|---|---|
fields |
object | The fields to be deserialized |
Returns:
The deserialized and uncompressed block fields.
- Type
- object
deserializeInputDesc(inputDescOrId, parentId, isShadow, blocks) → {object}
Deserialize a block input descriptors. This is either a block id or a serialized primitive, e.g. an array (see serializePrimitiveBlock function).
Parameters:
Name | Type | Description |
---|---|---|
inputDescOrId |
string | array | The block input descriptor to be serialized. |
parentId |
string | The id of the parent block for this input block. |
isShadow |
boolean | Whether or not this input block is a shadow. |
blocks |
object | The entire blocks object currently in the process of getting serialized. |
Returns:
The deserialized input descriptor.
- Type
- object
deserializeInputs(inputs, parentId, blocks) → {object}
Deserialize the given block inputs.
Parameters:
Name | Type | Description |
---|---|---|
inputs |
object | The inputs to deserialize. |
parentId |
string | The block id of the parent block |
blocks |
object | The object representing the entire set of blocks currently in the process of getting deserialized. |
Returns:
The deserialized and uncompressed inputs.
- Type
- object
deserializeSound(sound, runtime, zip, assetFileName) → {Promise}
Deserializes sound from file into storage cache so that it can be loaded into the runtime.
Parameters:
Name | Type | Description |
---|---|---|
sound |
object | Descriptor for sound from sb3 file |
runtime |
Runtime | The runtime containing the storage to cache the sounds in |
zip |
JSZip | The zip containing the sound file being described by |
assetFileName |
string | Optional file name for the given asset (sb2 files have filenames of the form [int].[ext], sb3 files have filenames of the form [md5].[ext]) |
Returns:
Promise that resolves after the described sound has been stored into the runtime storage cache, the sound was already stored, or an error has occurred.
- Type
- Promise
domToBlock(blockDOM, blocks, isTopBlock, parentnullable) → {undefined}
Convert and an individual block DOM to the representation tree.
Based on Blockly's domToBlockHeadless_
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
blockDOM |
Element | DOM tree for an individual block. |
|
blocks |
object | Collection of blocks to add to. |
|
isTopBlock |
boolean | Whether blocks at this level are "top blocks." |
|
parent |
string |
<nullable> |
Parent block ID. |
Returns:
- Type
- undefined
domToBlocks(blocksDOM) → {Array.<object>}
Convert outer blocks DOM from a Blockly CREATE event
to a usable form for the Scratch runtime.
This structure is based on Blockly xml.js:domToWorkspace
and domToBlock
.
Parameters:
Name | Type | Description |
---|---|---|
blocksDOM |
Element | DOM tree for this event. |
Returns:
Usable list of blocks from this CREATE event.
- Type
- Array.<object>
execute(sequencernon-null, threadnon-null)
Execute a block.
Parameters:
Name | Type | Description |
---|---|---|
sequencer |
Sequencer | Which sequencer is executing. |
thread |
Thread | Thread which to read and execute. |
fetchBitmapCanvas_(costumenon-null, runtimenon-null, rotationCenternullable) → (nullable) {Promise}
Properties:
Name | Type | Description |
---|---|---|
costume.bitmapResolution |
number | the resolution scale for a bitmap costume. |
Return a promise to fetch a bitmap from storage and return it as a canvas If the costume has bitmapResolution 1, it will be converted to bitmapResolution 2 here (the standard for Scratch 3) If the costume has a text layer asset, which is a text part from Scratch 1.4, then this function will merge the two image assets. See the issue LLK/scratch-vm#672 for more information.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
costume |
object | the Scratch costume object. |
|
runtime |
Runtime | Scratch runtime, used to access the v2BitmapAdapter |
|
rotationCenter |
object |
<nullable> |
optionally passed in coordinates for the center of rotation for the image. If none is given, the rotation center of the costume will be set to the middle of the costume later on. |
Returns:
- a promise which will resolve to an object {canvas, rotationCenter, assetMatchesBase}, or reject on error. assetMatchesBase is true if the asset matches the base layer; false if it required adjustment
- Type
- Promise
flatten(blocks) → {Array.<object>}
Flatten a block tree into a block list.
Children are temporarily stored on the block.children
property.
Parameters:
Name | Type | Description |
---|---|---|
blocks |
Array.<object> | list generated by |
Returns:
Flattened list to be passed to blocks.createBlock
.
- Type
- Array.<object>
getAssetUrl(asset) → {string}
Parameters:
Name | Type | Description |
---|---|---|
asset |
Asset | calculate a URL for this asset. |
Returns:
a URL to download a project asset (PNG, WAV, etc.)
- Type
- string
getCached(blocks, blockId)
A private method shared with execute to build an object containing the block information execute needs and that is reset when other cached Blocks info is reset.
Parameters:
Name | Type | Description |
---|---|---|
blocks |
Blocks | Blocks containing the expected blockId |
blockId |
string | blockId for the desired execute cache |
getExtensionIdForOpcode(opcodenon-null) → (nullable) {string}
Get non-core extension ID for a given sb3 opcode.
Parameters:
Name | Type | Description |
---|---|---|
opcode |
string | The opcode to examine for extension. |
Returns:
The extension ID, if it exists and is not a core extension.
- Type
- string
getProjectUrl(asset) → {string}
Parameters:
Name | Type | Description |
---|---|---|
asset |
Asset | calculate a URL for this asset. |
Returns:
a URL to download a project file.
- Type
- string
getScripts(container, opcode)
Get an array of scripts from a block container prefiltered to match opcode.
Parameters:
Name | Type | Description |
---|---|---|
container |
Blocks | Container of blocks |
opcode |
string | Opcode to filter top blocks by |
handleReport(resolvedValue, sequencernon-null, threadnon-null, currentBlockIdnon-null, opcodenon-null, isHatnon-null)
Handle any reported value from the primitive, either directly returned or after a promise resolves.
Parameters:
Name | Type | Description |
---|---|---|
resolvedValue |
* | Value eventually returned from the primitive. |
sequencer |
Sequencer | Sequencer stepping the thread for the ran primitive. |
thread |
Thread | Thread containing the primitive. |
currentBlockId |
string | Id of the block in its thread for value from the primitive. |
opcode |
string | opcode used to identify a block function primitive. |
isHat |
boolean | Is the current block a hat? |
int32ArrayToNumber(array) → {number}
Helper function for converting a regular array to a Little Endian INT32-value
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | an array containing UInt8-values |
Returns:
- a number
- Type
- number
isPromise(value) → {boolean}
Utility function to determine if a value is a Promise.
Parameters:
Name | Type | Description |
---|---|---|
value |
* | Value to check for a Promise. |
Returns:
True if the value appears to be a Promise.
- Type
- boolean
loadCostume(md5extnon-null, costumenon-null, runtimenon-null, optVersionnullable) → (nullable) {Promise}
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
skinId |
int | the ID of the costume's render skin, once installed. |
|
rotationCenterX |
number | the X component of the costume's origin. |
|
rotationCenterY |
number | the Y component of the costume's origin. |
|
bitmapResolution |
number |
<optional> |
the resolution scale for a bitmap costume. |
Load a costume's asset into memory asynchronously. Do not call this unless there is a renderer attached.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
md5ext |
string | the MD5 and extension of the costume to be loaded. |
|
costume |
object | the Scratch costume object. |
|
runtime |
Runtime | Scratch runtime, used to access the storage module. |
|
optVersion |
int |
<nullable> |
Version of Scratch that the costume comes from. If this is set to 2, scratch 3 will perform an upgrade step to handle quirks in SVGs from Scratch 2.0. |
Returns:
- a promise which will resolve after skinId is set, or null on error.
- Type
- Promise
loadCostumeFromAsset(costumenon-null, runtimenon-null, optVersionnullable) → (nullable) {Promise}
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
skinId |
int | the ID of the costume's render skin, once installed. |
|
rotationCenterX |
number | the X component of the costume's origin. |
|
rotationCenterY |
number | the Y component of the costume's origin. |
|
bitmapResolution |
number |
<optional> |
the resolution scale for a bitmap costume. |
costume.asset |
Asset | the asset of the costume loaded from storage. |
Initialize a costume from an asset asynchronously. Do not call this unless there is a renderer attached.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
costume |
object | the Scratch costume object. |
|
runtime |
Runtime | Scratch runtime, used to access the storage module. |
|
optVersion |
int |
<nullable> |
Version of Scratch that the costume comes from. If this is set to 2, scratch 3 will perform an upgrade step to handle quirks in SVGs from Scratch 2.0. |
Returns:
- a promise which will resolve after skinId is set, or null on error.
- Type
- Promise
loadSound(soundnon-null, runtimenon-null, soundBank) → (non-null) {Promise}
Properties:
Name | Type | Description |
---|---|---|
md5 |
string | the MD5 and extension of the sound to be loaded. |
data |
Buffer | sound data will be written here once loaded. |
Load a sound's asset into memory asynchronously.
Parameters:
Name | Type | Description |
---|---|---|
sound |
object | the Scratch sound object. |
runtime |
Runtime | Scratch runtime, used to access the storage module. |
soundBank |
SoundBank | Scratch Audio SoundBank to add sounds to. |
Returns:
- a promise which will resolve to the sound when ready.
- Type
- Promise
loadSoundFromAsset(soundnon-null, soundAssetnon-null, runtimenon-null, soundBank) → (non-null) {Promise}
Properties:
Name | Type | Description |
---|---|---|
md5 |
string | the MD5 and extension of the sound to be loaded. |
data |
Buffer | sound data will be written here once loaded. |
Initialize a sound from an asset asynchronously.
Parameters:
Name | Type | Description |
---|---|---|
sound |
object | the Scratch sound object. |
soundAsset |
Asset | the asset loaded from storage. |
runtime |
Runtime | Scratch runtime, used to access the storage module. |
soundBank |
SoundBank | Scratch Audio SoundBank to add sounds to. |
Returns:
- a promise which will resolve to the sound when ready.
- Type
- Promise
maybeFormatMessage(maybeMessage, argsopt, localeopt) → {string|*}
Check if maybeMessage
looks like a message object, and if so pass it to formatMessage
.
Otherwise, return maybeMessage
as-is.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
maybeMessage |
* | something that might be a message descriptor object. |
|
args |
object |
<optional> |
the arguments to pass to |
locale |
string |
<optional> |
the locale to pass to |
Returns:
- the formatted message OR the original
maybeMessage
input.
- Type
- string | *
motionVector(A2, A1B2, B1, C2, C1, out) → {UV}
Determine a motion vector combinations of the color component difference on the x axis, y axis, and temporal axis.
Parameters:
Name | Type | Description |
---|---|---|
A2 |
number | a sum of x axis squared |
A1B2 |
number | a sum of x axis times y axis |
B1 |
number | a sum of y axis squared |
C2 |
number | a sum of x axis times temporal axis |
C1 |
number | a sum of y axis times temporal axis |
out |
UV | optional object to store return UV info in |
Returns:
a uv vector representing the motion for the given input
- Type
- UV
mutationAdpater(mutation) → {object}
Adapter between mutator XML or DOM and block representation which can be used by the Scratch runtime.
Parameters:
Name | Type | Description |
---|---|---|
mutation |
object | string | Mutation XML string or DOM. |
Returns:
Object representing the mutation.
- Type
- object
mutatorTagToObject(dom) → {object}
Convert a part of a mutation DOM to a mutation VM object, recursively.
Parameters:
Name | Type | Description |
---|---|---|
dom |
object | DOM object for mutation tag. |
Returns:
Object representing useful parts of this mutation.
- Type
- object
numberToInt32Array(number) → {array}
Helper function for converting a JavaScript number to an INT32-number
Parameters:
Name | Type | Description |
---|---|---|
number |
number | a number |
Returns:
- a 4-byte array of Int8-values representing an INT32-number
- Type
- array
parseBlock(sb2blocknon-null, addBroadcastMsg, getVariableId, extensions, parseState, comments, commentIndex) → {Array.<(object|int)>}
Parse a single SB2 JSON-formatted block and its children.
Parameters:
Name | Type | Description |
---|---|---|
sb2block |
object | SB2 JSON-formatted block. |
addBroadcastMsg |
function | function to update broadcast message name map |
getVariableId |
function | function to retrieve a variable's ID based on name |
extensions |
ImportedExtensionsInfo | (in/out) parsed extension information will be stored here. |
parseState |
ParseState | info on the state of parsing beyond the current block. |
comments |
object.<int, Comment> | Comments from sb2 project that need to be attached to blocks. They are indexed in this object by the sb2 flattened block list index indicating which block they should attach to. |
commentIndex |
int | The comment index for the block to be parsed if it were in a flattened list of all blocks for the target |
Returns:
Tuple where first item is the Scratch VM-format block (or null if unsupported object), and second item is the updated comment index (after this block and its children are parsed)
- Type
- Array.<(object|int)>
parseBlockList(blockList, addBroadcastMsg, getVariableId, extensions, parseState, comments, commentIndex) → {Array.<(Array.<object>|int)>}
Parse any list of blocks from SB2 JSON into a list of VM-format blocks. Could be used to parse a top-level script, a list of blocks in a branch (e.g., in forever), or a list of blocks in an argument (e.g., move [pick random...]).
Parameters:
Name | Type | Description |
---|---|---|
blockList |
Array.<object> | SB2 JSON-format block list. |
addBroadcastMsg |
function | function to update broadcast message name map |
getVariableId |
function | function to retreive a variable's ID based on name |
extensions |
ImportedExtensionsInfo | (in/out) parsed extension information will be stored here. |
parseState |
ParseState | info on the state of parsing beyond the current block. |
comments |
object.<int, Comment> | Comments from sb2 project that need to be attached to blocks. They are indexed in this object by the sb2 flattened block list index indicating which block they should attach to. |
commentIndex |
int | The current index of the top block in this list if it were in a flattened list of all blocks for the target |
Returns:
Tuple where first item is the Scratch VM-format block list, and second item is the updated comment index
- Type
- Array.<(Array.<object>|int)>
parseMonitorObject(objectnon-null, runtimenon-null, targetsnon-null, extensions)
Parse a single monitor object and create all its in-memory VM objects.
It is important that monitors are parsed last,
- after all sprite targets have finished parsing, and
- after the rest of the stage has finished parsing.
It is specifically important that all the scripts in the project have been parsed and all the relevant targets exist, have uids, and have their variables initialized. Calling this function before these things are true, will result in undefined behavior.
Parameters:
Name | Type | Description |
---|---|---|
object |
object | From-JSON "Monitor object" |
runtime |
Runtime | (in/out) Runtime object to load monitor info into. |
targets |
Array.<Target> | Targets have already been parsed. |
extensions |
ImportedExtensionsInfo | (in/out) parsed extension information will be stored here. |
parseProcedureArgIds(procCode) → {Array.<string>}
Generate a list of "argument IDs" for procdefs and caller mutations.
IDs just end up being input0
, input1
, ... which is good enough.
Parameters:
Name | Type | Description |
---|---|---|
procCode |
string | Scratch 2.0 procedure string. |
Returns:
Array of argument id strings.
- Type
- Array.<string>
parseProcedureArgMap(procCode) → {object}
Convert a Scratch 2.0 procedure string (e.g., "my_procedure %s %b %n") into an argument map. This allows us to provide the expected inputs to a mutated procedure call.
Parameters:
Name | Type | Description |
---|---|---|
procCode |
string | Scratch 2.0 procedure string. |
Returns:
Argument map compatible with those in sb2specmap.
- Type
- object
parseScratchAssets(objectnon-null, runtimenon-null, zip) → (nullable) {Object}
Parse the assets of a single "Scratch object" and load them. This preprocesses objects to support loading the data for those assets over a network while the objects are further processed into Blocks, Sprites, and a list of needed Extensions.
Parameters:
Name | Type | Description |
---|---|---|
object |
object | From-JSON "Scratch object:" sprite, stage, watcher. |
runtime |
Runtime | Runtime object to load all structures into. |
zip |
JSZip | Sb3 file describing this project (to load assets from) |
Returns:
Object of arrays of promises for asset objects used in Sprites. As well as a SoundBank for the sound assets. null for unsupported objects.
- Type
- Object
parseScratchAssets(objectnon-null, runtimenon-null, topLevel, zipnullable) → (nullable) {Object}
Parse the assets of a single "Scratch object" and load them. This preprocesses objects to support loading the data for those assets over a network while the objects are further processed into Blocks, Sprites, and a list of needed Extensions.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object |
object | From-JSON "Scratch object:" sprite, stage, watcher. |
|
runtime |
Runtime | Runtime object to load all structures into. |
|
topLevel |
boolean | Whether this is the top-level object (stage). |
|
zip |
object |
<nullable> |
Optional zipped assets for local file import |
Returns:
Object of arrays of promises and child objects for asset objects used in Sprites. As well as a SoundBank for the sound assets. null for unsupported objects.
- Type
- Object
parseScratchObject(objectnon-null, runtimenon-null, extensions, topLevel, zipnullable, assets) → (non-null) {Promise.<Array.<Target>>}
Parse a single "Scratch object" and create all its in-memory VM objects. TODO: parse the "info" section, especially "savedExtensions"
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object |
object | From-JSON "Scratch object:" sprite, stage, watcher. |
|
runtime |
Runtime | Runtime object to load all structures into. |
|
extensions |
ImportedExtensionsInfo | (in/out) parsed extension information will be stored here. |
|
topLevel |
boolean | Whether this is the top-level object (stage). |
|
zip |
object |
<nullable> |
Optional zipped assets for local file import |
assets |
object | Promises for assets of this scratch object grouped into costumes and sounds |
Returns:
Promise for the loaded targets when ready, or null for unsupported objects.
- Type
- Promise.<Array.<Target>>
parseScratchObject(objectnon-null, runtimenon-null, extensions, zip, assets) → (non-null) {Promise.<Target>}
Parse a single "Scratch object" and create all its in-memory VM objects.
Parameters:
Name | Type | Description |
---|---|---|
object |
object | From-JSON "Scratch object:" sprite, stage, watcher. |
runtime |
Runtime | Runtime object to load all structures into. |
extensions |
ImportedExtensionsInfo | (in/out) parsed extension information will be stored here. |
zip |
JSZip | Sb3 file describing this project (to load assets from) |
assets |
object | Promises for assets of this scratch object grouped into costumes and sounds |
Returns:
Promise for the target created (stage or sprite), or null for unsupported objects.
- Type
- Promise.<Target>
parseScripts(scriptsnon-null, blocksnon-null, addBroadcastMsg, getVariableId, extensions, comments)
Parse a Scratch object's scripts into VM blocks. This should only handle top-level scripts that include X, Y coordinates.
Parameters:
Name | Type | Description |
---|---|---|
scripts |
object | Scripts object from SB2 JSON. |
blocks |
Blocks | Blocks object to load parsed blocks into. |
addBroadcastMsg |
function | function to update broadcast message name map |
getVariableId |
function | function to retreive a variable's ID based on name |
extensions |
ImportedExtensionsInfo | (in/out) parsed extension information will be stored here. |
comments |
object | Comments that need to be attached to the blocks that need to be parsed |
renderBenchmarkData(json)
Render previously run benchmark data.
Parameters:
Name | Type | Description |
---|---|---|
json |
object | data from a previous benchmark run. |
runBenchmark()
Run the benchmark with given parameters in the location's hash field or using defaults.
sb2import(jsonnon-null, runtimenon-null, optForceSpriteopt, zipnullable) → {Promise.<ImportedProject>}
Top-level handler. Parse provided JSON, and process the top-level object (the stage object).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
json |
object | SB2-format JSON to load. |
|
runtime |
Runtime | Runtime object to load all structures into. |
|
optForceSprite |
boolean |
<optional> |
If set, treat as sprite (Sprite2). |
zip |
object |
<nullable> |
Optional zipped assets for local file import |
Returns:
Promise that resolves to the loaded targets when ready.
- Type
- Promise.<ImportedProject>
scratchAtan2(y, x) → {number}
Get the angle of the y and x component of a 2d vector in degrees in Scratch's coordinate plane.
Parameters:
Name | Type | Description |
---|---|---|
y |
number | the y component of a 2d vector |
x |
number | the x component of a 2d vector |
Returns:
angle in degrees in Scratch's coordinate plane
- Type
- number
scratchDegrees(degrees) → {number}
Translate an angle in degrees with the range -180 to 180 rotated to Scratch's reference angle.
Parameters:
Name | Type | Description |
---|---|---|
degrees |
number | angle in range -180 to 180 |
Returns:
angle from Scratch's reference angle
- Type
- number
serialize(runtimenon-null, targetIdopt) → {object}
Serializes the specified VM runtime.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
runtime |
Runtime | VM runtime instance to be serialized. |
|
targetId |
string |
<optional> |
Optional target id if serializing only a single target |
Returns:
Serialized runtime instance.
- Type
- object
serializeAssets(runtime, assetType, optTargetIdopt) → {Array.<object>}
Serialize all the assets of the given type ('sounds' or 'costumes') in the provided runtime into an array of file descriptors. A file descriptor is an object containing the name of the file to be written and the contents of the file, the serialized asset.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
runtime |
Runtime | The runtime with the assets to be serialized |
|
assetType |
string | The type of assets to be serialized: 'sounds' | 'costumes' |
|
optTargetId |
string |
<optional> |
Optional target id to serialize assets for |
Returns:
An array of file descriptors for each asset
- Type
- Array.<object>
serializeBlock(block) → {object|array}
Serialize the given block in the SB3 format with some compression of inputs, fields, and primitives.
Parameters:
Name | Type | Description |
---|---|---|
block |
object | The block to serialize |
Returns:
A serialized representation of the block. This is an array if the block is one of the primitive types described above or an object, if not.
- Type
- object | array
serializeBlocks(blocks) → {Array}
Serialize the given blocks object (representing all the blocks for the target currently being serialized.)
Parameters:
Name | Type | Description |
---|---|---|
blocks |
object | The blocks to be serialized |
Returns:
An array of the serialized blocks with compressed inputs and compressed primitives and the list of all extension IDs present in the serialized blocks.
- Type
- Array
serializeCostume(costume) → {object}
Serialize the given costume.
Parameters:
Name | Type | Description |
---|---|---|
costume |
object | The costume to be serialized. |
Returns:
A serialized representation of the costume.
- Type
- object
serializeCostumes(runtime, optTargetId) → {Array.<object>}
Serialize all the costumes in the provided runtime into an array of file descriptors. A file descriptor is an object containing the name of the file to be written and the contents of the file, the serialized costume.
Parameters:
Name | Type | Description |
---|---|---|
runtime |
Runtime | The runtime with the costumes to be serialized |
optTargetId |
string | Optional targetid for serializing costumes of a single target |
Returns:
An array of file descriptors for each costume
- Type
- Array.<object>
serializeFields(fields) → {object}
Serialize the fields of a block in a more compact form.
Parameters:
Name | Type | Description |
---|---|---|
fields |
object | The fields object to serialize |
Returns:
An object representing the serialized fields
- Type
- object
serializeInputs(inputs) → {object}
Serializes the inputs field of a block in a compact form using constants described above to represent the relationship between the inputs of this block (e.g. if there is an unobscured shadow, an obscured shadow -- a block plugged into a droppable input -- or, if there is just a block). Based on this relationship, serializes the ids of the block and shadow (if present)
Parameters:
Name | Type | Description |
---|---|---|
inputs |
object | The inputs to serialize |
Returns:
An object representing the serialized inputs
- Type
- object
serializePrimitiveBlock(block) → {array}
Serializes primitives described above into a more compact format
Parameters:
Name | Type | Description |
---|---|---|
block |
object | the block to serialize |
Returns:
An array representing the information in the block, or null if the given block is not one of the primitives described above.
- Type
- array
serializeSound(sound) → {object}
Serialize the given sound.
Parameters:
Name | Type | Description |
---|---|---|
sound |
object | The sound to be serialized. |
Returns:
A serialized representation of the sound.
- Type
- object
serializeSounds(runtime, optTargetIdopt) → {Array.<object>}
Serialize all the sounds in the provided runtime or, if a target id is provided, in the specified target into an array of file descriptors. A file descriptor is an object containing the name of the file to be written and the contents of the file, the serialized sound.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
runtime |
Runtime | The runtime with the sounds to be serialized |
|
optTargetId |
string |
<optional> |
Optional targetid for serializing sounds of a single target |
Returns:
An array of file descriptors for each sound
- Type
- Array.<object>
serializeTarget(target, extensions) → {object}
Serialize the given target. Only serialize properties that are necessary for saving and loading this target.
Parameters:
Name | Type | Description |
---|---|---|
target |
object | The target to be serialized. |
extensions |
Set | A set of extensions to add extension IDs to |
Returns:
A serialized representation of the given target.
- Type
- object
serializeVariables(variables) → {object}
Serialize the given variables object.
Parameters:
Name | Type | Description |
---|---|---|
variables |
object | The variables to be serialized. |
Returns:
A serialized representation of the variables. They get separated by type to compress the representation of each given variable and reduce duplicate information.
- Type
- object
specMapBlock(blocknon-null) → {object}
Given the sb2 block, inspect the specmap for a translation method or object.
Parameters:
Name | Type | Description |
---|---|---|
block |
object | a sb2 formatted block |
Returns:
specmap block to parse this opcode
- Type
- object
uid() → {string}
Generate a unique ID, from Blockly. This should be globally unique. 87 characters ^ 20 length > 128 bits (better than a UUID).
Returns:
A globally unique ID string.
- Type
- string
xmlEscape(unsafe) → {string}
Escape a string to be safe to use in XML content. CC-BY-SA: hgoebl https://stackoverflow.com/questions/7918868/ how-to-escape-xml-entities-in-javascript
Parameters:
Name | Type | Description |
---|---|---|
unsafe |
string | !Array.<string> | Unsafe string. |
Returns:
XML-escaped string, for use within an XML tag.
- Type
- string
Type Definitions
ArgumentInfo
Properties:
Name | Type | Description |
---|---|---|
type |
ArgumentType | the type of value this argument can take |
default |
* | undefined | the default value of this argument (default: blank) |
Information about an extension block argument
Type:
- object
BubbleState
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
onSpriteRight |
Boolean | tracks whether the bubble is right or left of the sprite. |
|
drawableId |
int |
<nullable> |
the ID of the associated bubble Drawable, null if none. |
text |
string | the text of the bubble. |
|
type |
string | the type of the bubble, "say" or "think" |
|
usageId |
string |
<nullable> |
ID indicating the most recent usage of the say/think bubble. Used for comparison when determining whether to clear a say/think bubble. |
the bubble state associated with a particular target.
Type:
- object
CategoryInfo
Properties:
Name | Type | Description |
---|---|---|
id |
string | the unique ID of this category |
name |
string | the human-readable name of this category |
blockIconURI |
string | undefined | optional URI for the block icon image |
color1 |
string | the primary color for this category, in '#rrggbb' format |
color2 |
string | the secondary color for this category, in '#rrggbb' format |
color3 |
string | the tertiary color for this category, in '#rrggbb' format |
blocks |
Array.<ConvertedBlockInfo> | the blocks, separators, etc. in this category |
menus |
Array.<object> | the menus provided by this category |
Information about a block category
Type:
- object
CloudDataManager
Properties:
Name | Type | Description |
---|---|---|
canAddCloudVariable |
function | A function to call to check that a cloud variable can be added. |
addCloudVariable |
function | A function to call to track a new cloud variable on the runtime. |
removeCloudVariable |
function | A function to call when removing an existing cloud variable. |
hasCloudVariables |
function | A function to call to check that the runtime has any cloud variables. |
A pair of functions used to manage the cloud variable limit, to be used when adding (or attempting to add) or removing a cloud variable.
Type:
- object
CloudIOData
Properties:
Name | Type | Description |
---|---|---|
varUpdate |
VarUpdateData | A VarUpdateData message indicating a cloud variable update |
A cloud io data post message.
Type:
- object
CloudProvider
Properties:
Name | Type | Description |
---|---|---|
updateVariable |
updateVariable | A function which sends a cloud variable update to the cloud data server. |
requestCloseConnection |
function | A function which closes the connection to the cloud data server. |
A cloud data provider, responsible for managing the connection to the cloud data server and for posting data about cloud data activity to this IO device.
Type:
- object
ConvertedBlockInfo
Properties:
Name | Type | Description |
---|---|---|
info |
ExtensionBlockMetadata | the raw block info |
json |
object | the scratch-blocks JSON definition for this block |
xml |
string | the scratch-blocks XML definition for this block |
Raw extension block data paired with processed data ready for scratch-blocks
Type:
- object
DispatchCallMessage
Properties:
Name | Type | Description |
---|---|---|
responseId |
* | send a response message with this response ID. See DispatchResponseMessage |
service |
string | the name of the service to be called |
method |
string | the name of the method to be called |
args |
Array | undefined | the arguments to be passed to the method |
a message to the dispatch system representing a service method call
Type:
- object
DispatchMessage
Any message to the dispatch system.
Type:
DispatchResponseMessage
Properties:
Name | Type | Description |
---|---|---|
responseId |
* | a copy of the response ID from the call which generated this response |
error |
* | undefined | if this is truthy, then it contains results from a failed call (such as an exception) |
result |
* | undefined | if error is not truthy, then this contains the return value of the call (if any) |
a message to the dispatch system representing the results of a call
Type:
- object
ExtensionArgumentMetadata
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
type |
ArgumentType | the type of the argument (number, string, etc.) |
|
defaultValue |
* |
<optional> |
the default value of this argument. |
menu |
string |
<optional> |
the name of the menu to use for this argument, if any. |
All the metadata needed to register an argument for an extension block.
Type:
- object
ExtensionBlockMetadata
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
opcode |
string | a unique alphanumeric identifier for this block. No special characters allowed. |
|
func |
string |
<optional> |
the name of the function implementing this block. Can be shared by other blocks/opcodes. |
blockType |
BlockType | the type of block (command, reporter, etc.) being described. |
|
text |
string | the text on the block, with [PLACEHOLDERS] for arguments. |
|
hideFromPalette |
Boolean |
<optional> |
true if this block should not appear in the block palette. |
isTerminal |
Boolean |
<optional> |
true if the block ends a stack - no blocks can be connected after it. |
disableMonitor |
Boolean |
<optional> |
true if this block is a reporter but should not allow a monitor. |
reporterScope |
ReporterScope |
<optional> |
if this block is a reporter, this is the scope/context for its value. |
isEdgeActivated |
Boolean |
<optional> |
sets whether a hat block is edge-activated. |
shouldRestartExistingThreads |
Boolean |
<optional> |
sets whether a hat/event block should restart existing threads. |
branchCount |
int |
<optional> |
for flow control blocks, the number of branches/substacks for this block. |
arguments |
Object.<ExtensionArgumentMetadata> |
<optional> |
map of argument placeholder to metadata about each arg. |
All the metadata needed to register an extension block.
Type:
- object
ExtensionDynamicMenu
- See:
-
- {ExtensionMenuItems} - the type of data expected to be returned by the specified function.
The string name of a function which returns menu items.
Type:
- string
ExtensionMenuItemComplex
Properties:
Name | Type | Description |
---|---|---|
value |
* | the value of the block argument when this menu item is selected. |
text |
string | the human-readable label of this menu item in the menu. |
A menu item for which the label and value can differ.
Type:
- object
ExtensionMenuItems
Items in an extension menu.
Type:
ExtensionMenuItemSimple
A menu item for which the label and value are identical strings.
Type:
- string
ExtensionMenuMetadata
All the metadata needed to register an extension drop-down menu.
Type:
ExtensionMetadata
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | a unique alphanumeric identifier for this extension. No special characters allowed. |
|
name |
string |
<optional> |
the human-readable name of this extension. |
blockIconURI |
string |
<optional> |
URI for an image to be placed on each block in this extension. Data URI ok. |
menuIconURI |
string |
<optional> |
URI for an image to be placed on this extension's category menu item. Data URI ok. |
docsURI |
string |
<optional> |
link to documentation content for this extension. |
blocks |
Array.<(ExtensionBlockMetadata|string)> | the blocks provided by this extension, plus separators. |
|
menus |
Object.<ExtensionMenuMetadata> |
<optional> |
map of menu name to metadata for each of this extension's menus. |
All the metadata needed to register an extension.
Type:
- object
FrameCallback(frame)
Callback handle called by Profiler for each frame it decodes from its records.
Parameters:
Name | Type | Description |
---|---|---|
frame |
ProfilerFrame |
HSVObject
Properties:
Name | Type | Description |
---|---|---|
h |
number | hue, in the range [0-359). |
s |
number | saturation, in the range [0,1]. |
v |
number | value, in the range [0,1]. |
An object representing a color in HSV format.
Type:
- object
ImportedExtensionsInfo
Properties:
Name | Type | Description |
---|---|---|
extensionIDs |
Set.<string> | the ID of each extension actually in use by blocks in this project. |
extensionURLs |
Map.<string, string> | map of ID => URL from project metadata. May not match extensionIDs. |
Type:
- object
ImportedProject
Properties:
Name | Type | Description |
---|---|---|
targets |
Array.<Target> | the imported Scratch 3.0 target objects. |
extensionsInfo |
ImportedExtensionsInfo | the ID of each extension actually used by this project. |
Type:
- object
MessageDescriptor
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | the translator-friendly unique ID of this message. |
|
default |
string | the message text in the default language (English). |
|
description |
string |
<optional> |
a description of this message to help translators understand the context. |
Type:
- object
PendingExtensionWorker
Properties:
Name | Type | Description |
---|---|---|
extensionURL |
string | the URL of the extension to be loaded by this worker |
resolve |
function | function to call on successful worker startup |
reject |
function | function to call on failed worker startup |
Information about an extension worker still initializing
Type:
- object
PenState
Properties:
Name | Type | Description |
---|---|---|
penDown |
Boolean | tracks whether the pen should draw for this target. |
color |
number | the current color (hue) of the pen. |
penAttributes |
PenAttributes | cached pen attributes for the renderer. This is the authoritative value for diameter but not for pen color. |
the pen state associated with a particular target.
Type:
- object
RGBObject
Properties:
Name | Type | Description |
---|---|---|
r |
number | the red component, in the range [0, 255]. |
g |
number | the green component, in the range [0, 255]. |
b |
number | the blue component, in the range [0, 255]. |
An object representing a color in RGB format.
Type:
- object
SB2SpecMap_argInfo
Properties:
Name | Type | Description |
---|---|---|
type |
string | the type of this arg (such as 'input' or 'field') |
inputOp |
string | the scratch-blocks shadow type for this arg |
inputName |
string | the name this argument will take when provided to the block implementation |
Type:
- object
SB2SpecMap_blockInfo
Properties:
Name | Type | Description |
---|---|---|
opcode |
string | the Scratch 3.0 block opcode. Use 'extensionID.opcode' for extension opcodes. |
argMap |
Array.<SB2SpecMap_argInfo> | metadata for this block's arguments. |
Type:
- object
updateVariable
VarUpdateData
Properties:
Name | Type | Description |
---|---|---|
name |
string | The name of the variable to update |
value |
number | string | The scalar value to update the variable with |
Part of a cloud io data post indicating a cloud variable update.
Type:
- object
VideoProvider
Properties:
Name | Type | Description |
---|---|---|
enableVideo |
function | Requests camera access from the user, and upon success, enables the video feed |
disableVideo |
function | Turns off the video feed |
getFrame |
function | Return frame data from the video feed in specified dimensions, format, and mirroring. |