Skip to content

Modules Common Library / types

types ​

Classes ​

abstract glAnimation ​

Defined in: lib/modules-lib/src/types/index.ts:10

Represents an animation drawn using WebGL

Constructors ​

Constructor ​
ts
new glAnimation(duration, fps): glAnimation;

Defined in: lib/modules-lib/src/types/index.ts:11

Parameters ​
ParameterTypeDescription

duration

number

Duration of the animation in seconds

fps

number

Framerate in frames per second

Returns ​

glAnimation

Properties ​

PropertyModifierTypeDescriptionDefined in

duration

readonly

number

Duration of the animation in seconds

lib/modules-lib/src/types/index.ts:15

fps

readonly

number

Framerate in frames per second

lib/modules-lib/src/types/index.ts:19

Accessors ​

_anim_symbol ​
Get Signature ​
ts
get _anim_symbol(): typeof glAnimationSymbol;

Defined in: lib/modules-lib/src/types/index.ts:30

Because of the way bundles and tabs are built, the tab and the bundle might end up with two separate instances of @sourceacademy/modules-lib bundled. Then there are two instances of the glAnimation class, so using an instanceof check no longer works properly.

Instead, we hide a special symbol which should be the same no matter which instance of glAnimation to perform the isAnimation check.

Returns ​

typeof glAnimationSymbol

Methods ​

[hasInstance]() ​
ts
static hasInstance: boolean;

Defined in: lib/modules-lib/src/types/index.ts:40

Because of some quirks in the way tabs and bundles are built, an instanceof check might fail at runtime. So we need to rewrite the instanceof check

Parameters ​
ParameterType

constructor

unknown

Returns ​

boolean

getFrame() ​
ts
abstract getFrame(timestamp): AnimFrame;

Defined in: lib/modules-lib/src/types/index.ts:34

Parameters ​
ParameterType

timestamp

number

Returns ​

AnimFrame

isAnimation() ​
ts
static isAnimation(obj): obj is glAnimation;

Defined in: lib/modules-lib/src/types/index.ts:45

Parameters ​
ParameterType

obj

unknown

Returns ​

obj is glAnimation

Interfaces ​

AnimFrame ​

Defined in: lib/modules-lib/src/types/index.ts:50

Properties ​

PropertyTypeDefined in

draw

(canvas) => void

lib/modules-lib/src/types/index.ts:51


DebuggerContext ​

Defined in: lib/modules-lib/src/types/index.ts:61

DebuggerContext type used by frontend to assist typing information

Properties ​

PropertyTypeDefined in

code

string

lib/modules-lib/src/types/index.ts:64

context

Context

lib/modules-lib/src/types/index.ts:65

lastDebuggerResult

any

lib/modules-lib/src/types/index.ts:63

result

any

lib/modules-lib/src/types/index.ts:62

workspaceLocation?

any

lib/modules-lib/src/types/index.ts:66


ModuleSideContent ​

Defined in: lib/modules-lib/src/types/index.ts:77

Properties ​

PropertyTypeDescriptionDefined in

body

(context) => ReactNode

This function will be called to render the module tab in the side contents on Source Academy frontend.

lib/modules-lib/src/types/index.ts:97

iconName

BlueprintIcons_16Id

BlueprintJS IconName element's name, used to render the icon which will be displayed in the side contents panel.

See

https://blueprintjs.com/docs/#icons

lib/modules-lib/src/types/index.ts:83

label

string

The Tab's icon tooltip in the side contents on Source Academy frontend.

lib/modules-lib/src/types/index.ts:87

toSpawn?

(context) => boolean

This function will be called to determine if the component will be rendered

lib/modules-lib/src/types/index.ts:92


ReplResult ​

Defined in: lib/modules-lib/node_modules/js-slang/dist/types.d.ts:22

Interface that custom Source objects can implement to override the default toString behaviour

Properties ​

PropertyTypeDescriptionDefined in

toReplString

() => string

Internal

lib/modules-lib/node_modules/js-slang/dist/types.d.ts:26

Type Aliases ​

DeepPartial ​

ts
type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T;

Defined in: lib/modules-lib/src/types/index.ts:54

Type Parameters ​

Type Parameter

T


ModuleContexts ​

ts
type ModuleContexts = Context["moduleContexts"];

Defined in: lib/modules-lib/src/types/index.ts:69


ModuleTab ​

ts
type ModuleTab = (props) => React.ReactNode;

Defined in: lib/modules-lib/src/types/index.ts:75

Parameters ​

ParameterType

props

{ debuggerCtx: DebuggerContext; }

props.debuggerCtx

DebuggerContext

Returns ​

React.ReactNode