@astl/core
Contracts and the i18n runtime. Every interface between the packages lives here; no runtime dependencies.
Classes
Section titled “Classes”CheckerError
Section titled “CheckerError”Thrown by checkers for protocol-level refusals, carrying the RFC 9457 problem document.
Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CheckerError(problem): CheckerError;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
problem |
ProblemDetails |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructorProperties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
problem |
readonly |
ProblemDetails |
MessageSyntaxError
Section titled “MessageSyntaxError”Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MessageSyntaxError(message, offset): MessageSyntaxError;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message |
string |
offset |
number |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructorProperties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
offset |
readonly |
number |
Interfaces
Section titled “Interfaces”AnswerKey
Section titled “AnswerKey”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
format |
readonly |
1 |
- |
groups |
readonly |
readonly ScoringGroup[] |
- |
help? |
readonly |
Readonly<Record<string, KeyHelp>> |
Help by view element id and view page id; absent when the source has none. |
lang |
readonly |
string |
Content language of the document. Slots inherit it unless their key says otherwise. |
pages |
readonly |
readonly string[] |
View page ids in order. |
slots |
readonly |
Readonly<Record<string, KeySlot>> |
- |
viewHash |
readonly |
string |
View hash this key belongs to. Hosts must store and serve them together. |
AttemptPolicy
Section titled “AttemptPolicy”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
checkScope? |
readonly |
CheckScope |
Practice only. |
deadline |
readonly |
string | null |
ISO 8601. The server auto-submits at the deadline; the player only shows the countdown. |
explanations? |
readonly |
HelpMoment |
- |
feedback? |
readonly |
HelpMoment |
- |
hints? |
readonly |
boolean |
Hints on request, one at a time from the checker (Checker.hint). Practice only. |
maxChecks |
readonly |
number | null |
Practice only. null = unlimited. |
mode |
readonly |
AttemptMode |
practice: check any time. test: no check, one submit. review: read-only, shows a submitted attempt. |
navigation |
readonly |
"free" | "linear" |
linear: no going back to earlier pages (tests). |
passMark |
readonly |
number | null |
Fraction of the maximum score needed to pass, 0..1. null = no pass mark. |
reveal |
readonly |
Reveal |
- |
seed |
readonly |
string | null |
Seed for per-attempt UI shuffles. null = keep the view order. |
AttributeSpec
Section titled “AttributeSpec”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
default? |
readonly |
string | number | boolean |
Value used when the attribute is absent. Documented and shown by the editor. |
max? |
readonly |
number |
- |
min? |
readonly |
number |
Inclusive bounds for integer and number. |
name |
readonly |
string |
- |
required? |
readonly |
boolean |
- |
type |
readonly |
AttributeType |
- |
values? |
readonly |
readonly string[] |
Allowed values for enum. |
visibility |
readonly |
Visibility |
- |
CatalogProblem
Section titled “CatalogProblem”Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
detail |
readonly |
string |
key |
readonly |
string |
kind |
readonly |
"missing" | "extra" | "syntax" | "params" | "plural" |
ChangeDetail
Section titled “ChangeDetail”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
answers |
readonly |
Answers |
Changed slots only; '' = cleared. |
Checker
Section titled “Checker”Extended by
Section titled “Extended by”Methods
Section titled “Methods”check()
Section titled “check()”check(request): Promise<CheckResponse>;Practice only. Rejects with CheckerError (check_not_allowed) under other policies.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
request |
CheckRequest |
Returns
Section titled “Returns”Promise<CheckResponse>
hint()?
Section titled “hint()?”optional hint(request): Promise<HintResponse>;The next hint, practice only; checkers without hints leave it out. Rejects with CheckerError hints_not_allowed
when the policy offers none, hints_exhausted when all are used, not_found for an unknown element.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
request |
HintRequest |
Returns
Section titled “Returns”Promise<HintResponse>
submit()
Section titled “submit()”submit(request): Promise<SubmitResponse>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
request |
SubmitRequest |
Returns
Section titled “Returns”Promise<SubmitResponse>
CheckPlan
Section titled “CheckPlan”What planChecks makes of a page's parts: the questions of each check, in the order of the checks.
Properties
Section titled “Properties”CheckRequest
Section titled “CheckRequest”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
answers |
readonly |
Answers |
- |
element? |
readonly |
string |
View element id: grade that interaction only, under a policy with checkScope: 'interaction'. It counts against maxChecks like any check. Never together with page. |
elements? |
readonly |
readonly string[] |
View element ids: grade those interactions at once (a Check element's questions, CHECK_TAG), under a policy with checkScope: 'interaction'. One check against maxChecks. Never together with page or element. |
page? |
readonly |
string |
View page id: grade only that page. Omit to grade everything. |
CheckResponse
Section titled “CheckResponse”Help that comes with a result when the policy shows it (the engine's helpShown), for what was graded: absent when there is
none, so responses without help stay as they were.
Extends
Section titled “Extends”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
checksLeft |
readonly |
number | null |
Checks left in this attempt; null = unlimited. |
explanations? |
readonly |
Readonly<Record<string, string>> |
HTML by view element id or view page id. |
feedback? |
readonly |
Readonly<Record<string, Feedback>> |
By view element id, and by view page id for a page's own feedback (picked by the page's score). |
result |
readonly |
GradeResult |
- |
CheckTree
Section titled “CheckTree”How checkParts reads a tree: the engine's and the authoring kit's (core AST), or the player's (DOM).
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Methods
Section titled “Methods”checkFor()
Section titled “checkFor()”checkFor(node): readonly string[] | null;A check's for: the ids it names, or null without the attribute.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
node |
T |
Returns
Section titled “Returns”readonly string[] | null
children()
Section titled “children()”children(node): readonly T[];Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
node |
T |
Returns
Section titled “Returns”readonly T[]
component()
Section titled “component()”component(node): | { block: boolean; graded: boolean; id: string | null;} | null;A component: its source id (view id in a view), whether it is a graded question, whether it is a block.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
node |
T |
Returns
Section titled “Returns”| {
block: boolean;
graded: boolean;
id: string | null;
}
| null
tag(node): string | null;An element's tag, or null for text.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
node |
T |
Returns
Section titled “Returns”string | null
taskCheck()?
Section titled “taskCheck()?”optional taskCheck(node): boolean;Whether a task has a Check of its own (check in a source). Absent: never, as in a view, where the engine has
written that Check as a Check element at the end of the task.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
node |
T |
Returns
Section titled “Returns”boolean
ChildSpec
Section titled “ChildSpec”A child element type a component accepts, e.g. <astl-option> inside <astl-choice>.
content: 'text': plain text only (e.g. an accepted alternative answer).content: 'inline': rich inline content (emphasis,langspans, math).
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
attributes |
readonly |
readonly AttributeSpec[] |
- |
content |
readonly |
"text" | "inline" |
- |
max |
readonly |
number | null |
null = unbounded. |
min |
readonly |
number |
- |
place? |
readonly |
"lead" |
Only in a type with rich content (content: 'flow'). Absent: the child sits in that content's text (a word to select). 'lead': it stands before the content, as the element's first child, never in its text (a prompt). |
tag |
readonly |
string |
- |
visibility |
readonly |
"public" | "private" |
- |
Compilation
Section titled “Compilation”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
key |
readonly |
AnswerKey |
- |
metadata |
readonly |
Metadata |
- |
view |
readonly |
string |
- |
viewHash |
readonly |
string |
Lowercase hex SHA-256 of the UTF-8 view. |
CompileContext
Section titled “CompileContext”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
dir |
readonly |
Direction |
- |
lang |
readonly |
string |
- |
profile |
readonly |
NormalisationProfile |
Engine-wide text comparison defaults; definitions apply their own attributes on top. |
Methods
Section titled “Methods”opaque()
Section titled “opaque()”opaque(localId?): string;Opaque id for the current element (no argument) or for a source id local to it, e.g. an option id. Deterministic for (secret, salt, element id, local id), so recompiling gives the same view.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
localId? |
string |
Returns
Section titled “Returns”string
opaqueOf()
Section titled “opaqueOf()”opaqueOf(id, localId?): string;The opaque id of another component (by source id) or of a source id local to it, as that component's view writes
it: what a drop's view and key need of its word bank. Throws for an id validate did not check (no such component,
or no such local id).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string |
localId? |
string |
Returns
Section titled “Returns”string
permute()
Section titled “permute()”permute<T>(items, options?): T[];Keyed permutation, a pure function of (element seed, salt, item count): calling it twice gives the same order,
so slots and toView agree. With avoidOriginal, 2+ items never come back in source order (use it when the
source order is the answer, e.g. ordering tasks). Use different salts for independent permutations.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
items |
readonly T[] |
options? |
{ avoidOriginal?: boolean; salt?: string; } |
options.avoidOriginal? |
boolean |
options.salt? |
string |
Returns
Section titled “Returns”T[]
CompileOptions
Section titled “CompileOptions”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
salt? |
readonly |
string |
Mixed into opaque ids and permutations, e.g. the exercise id, so two exercises never share ids. |
ComponentDefinition
Section titled “ComponentDefinition”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
manifest |
readonly |
ComponentManifest |
- |
messages? |
readonly |
readonly MessageCatalog[] |
Catalogs of the manifest's namespace; the engine uses them to describe this type's issues. |
migrations? |
readonly |
Readonly<Record<number, (element) => ElementNode>> |
migrations[n] upgrades a source element written for version n to n + 1. |
Methods
Section titled “Methods”example()?
Section titled “example()?”optional example(element): boolean;Whether the element shows a worked example (its example attribute): it is answered already, read-only, so it
has no slots and no scoring group, counts towards no score and needs no Check. Absent: never an example.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element |
ElementNode |
Returns
Section titled “Returns”boolean
groups()?
Section titled “groups()?”optional groups(element, context): readonly GroupSpec[] | null;The scoring groups of an element graded in parts (a crossword's words): each scores by the rule of the
element's scoring mode and gets its points, and together they hold every slot. Null or absent: one group, with
the element's id, of all its slots. Called for valid graded elements only, after slots.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element |
ElementNode |
context |
CompileContext |
Returns
Section titled “Returns”readonly GroupSpec[] | null
localIds()?
Section titled “localIds()?”optional localIds(element): readonly string[];Local ids of slots that no child stands for (a crossword's cells), read from the valid element. Each gets an
opaque id as a child's id does: context.opaque(localId), fixture ref <id>/<localId>. Start them with a digit,
so they never meet a child's id (source ids start with a letter). Absent: the children's ids only.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element |
ElementNode |
Returns
Section titled “Returns”readonly string[]
metadata()?
Section titled “metadata()?”optional metadata(element): Readonly<Record<string, number>>;Extra numbers for metadata (e.g. { words: 12 }), stored as <tag>.<name>.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element |
ElementNode |
Returns
Section titled “Returns”Readonly<Record<string, number>>
slots()
Section titled “slots()”slots(element, context): readonly SlotSpec[];Slots with their private keys, in reading order. Called only for valid elements.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element |
ElementNode |
context |
CompileContext |
Returns
Section titled “Returns”readonly SlotSpec[]
toView()
Section titled “toView()”toView(element, context): ElementNode;The public view element. Must not contain private attributes or private children; the engine enforces the manifest allow-list afterwards and fails the compile if a private value would leak.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element |
ElementNode |
context |
CompileContext |
Returns
Section titled “Returns”validate()
Section titled “validate()”validate(element, context): void;Type-specific checks on a sanitised element. The engine has already checked everything the manifest says
(attribute types, enums, required attributes, child tags and counts, id).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element |
ElementNode |
context |
ValidateContext |
Returns
Section titled “Returns”void
ComponentManifest
Section titled “ComponentManifest”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
a11y |
readonly |
object |
Accessibility contract, used by docs and conformance: ARIA pattern and the keys that operate it. |
a11y.keys |
readonly |
readonly string[] |
- |
a11y.pattern |
readonly |
string |
- |
attributes |
readonly |
readonly AttributeSpec[] |
Type-specific attributes. The common ones (id, v, scoring, points) come from COMMON_ATTRIBUTES. |
children |
readonly |
readonly ChildSpec[] |
- |
content? |
readonly |
"flow" |
Absent: the element holds its declared children only. 'flow' (blocks only): it wraps rich content as a page holds it (paragraphs, headings, lists, quotes, figures, formatting, pictures; no components), and its declared children are inline children that sit in that content's text where an inline component may sit (a word to select in a passage), except those with place: 'lead', which come first, before the content (a prompt); min and max count them wherever they are. |
cssParts |
readonly |
readonly string[] |
part names the element exposes for ::part() styling. Public theming API. |
display |
readonly |
"block" | "inline" |
inline sits inside text (a gap); block stands between paragraphs (a multiple choice). |
graded |
readonly |
boolean |
Whether the type is scored. Graded types form one scoring group of graded slots. Ungraded types have no scoring and add nothing to the maximum: they produce no slots (flash cards, media), or only open slots (a long answer), whose answers are stored with the attempt for a teacher. |
issues |
readonly |
readonly string[] |
Issue codes the definition may report (namespace = messages). |
messages |
readonly |
string |
i18n namespace for this type's messages, e.g. astl.gap. |
scoring |
readonly |
ScoringSpec | null |
null for ungraded types. |
slotKinds |
readonly |
readonly string[] |
Slot kinds the definition produces; each must be registered with the engine. Graded types list graded kinds only, ungraded types ungraded ones only (open). |
tag |
readonly |
string |
Custom element name. Built-ins use the astl- prefix; third parties use their own. |
variants |
readonly |
VariantSpec | null |
null for types with a single presentation. |
version |
readonly |
number |
Element format version, written as v="n" in views. Bump on incompatible changes and add a migration. |
CreateI18nOptions
Section titled “CreateI18nOptions”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
catalogs |
readonly |
readonly MessageCatalog[] |
- |
fallbackLocale? |
readonly |
string |
Default en. |
formatter? |
readonly |
MessageFormatter |
- |
EditorAdapter
Section titled “EditorAdapter”What a WYSIWYG integration must provide so the authoring kit can drive it. Everything is in source HTML
(the <astl-doc> format), so an adapter is free to use any internal model.
Extended by
Section titled “Extended by”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
editsSource? |
readonly |
boolean |
True when the editor shows and edits the source HTML as text (the textarea adapter, a code editor): <astl-editor> then names its view "HTML" and offers no HTML view of its own, which would show the same text. Absent: a visual editor. |
style? |
readonly |
EditorStyles |
Styles at the cursor, named styles and layouts. Absent: an editor of source text (the textarea), no controls. |
Methods
Section titled “Methods”addPage()?
Section titled “addPage()?”optional addPage(after?): string;Adds an empty page (one empty paragraph) after the page after, or after the last page when after is not the
id of one, and returns its id: fresh (page-<n>), without a label, lang or dir. The cursor goes into it. A
document without pages becomes its first page in the same step. One undo step.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
after? |
string |
Returns
Section titled “Returns”string
focus()?
Section titled “focus()?”optional focus(): void;Focuses the editor, its cursor where it was (after a toolbar press from the keyboard). An editor that has the focus is left as it is, so a click there a moment before keeps its cursor.
Returns
Section titled “Returns”void
format()?
Section titled “format()?”optional format(format, href?): boolean;Toggles a format on the selection and focuses the editor; returns whether the document changed. A mark goes on
all of the selected text, or off when all of it has it; link with an href links the selected text (or changes
the link at the cursor) and without one removes the link at the cursor; a text style sets the blocks of the
selection to it (heading or subheading again sets paragraph); a list wraps them in that list, turns the
other list into it, or lifts them out of it. One undo step. Absent (with formatState): no formatting commands.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
format |
EditorFormat |
href? |
string |
Returns
Section titled “Returns”boolean
formatState()?
Section titled “formatState()?”optional formatState(): EditorFormatState;The formats at the cursor and whether undo or redo can run. Present with format.
Returns
Section titled “Returns”getCursor()?
Section titled “getCursor()?”optional getCursor(): EditorBlockPlace | null;The block holding the cursor (in a document without pages: page null), or null while the editor has no cursor
in content. A host follows it to show the page being edited.
Returns
Section titled “Returns”EditorBlockPlace | null
getElement()
Section titled “getElement()”getElement(id): string | null;Source HTML of one component element, or null when the id is not in the document.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string |
Returns
Section titled “Returns”string | null
getSelection()
Section titled “getSelection()”getSelection(): EditorSelection | null;The component at the cursor, or null.
Returns
Section titled “Returns”EditorSelection | null
getSource()
Section titled “getSource()”getSource(): string;The whole document as source HTML.
Returns
Section titled “Returns”string
insert()
Section titled “insert()”insert(html, options?): void;Inserts a source snippet (an instantiated template) at the cursor, never into a component: after the component the
cursor is in. With replaceSelection, an inline snippet takes the place of the selected text. A rich-text editor
keeps the text whole: a snippet of blocks (a block component, a paragraph) goes after the element the cursor is in
directly on its page or column (a paragraph, a heading, a list), or in the place of that element when it is an
empty paragraph; a layout goes after the layout the cursor is in, as layouts do not nest. A source editor (the
textarea adapter) puts any snippet at the caret, as the author would type it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
html |
string |
options? |
EditorInsertOptions |
Returns
Section titled “Returns”void
mergePage()?
Section titled “mergePage()?”optional mergePage(id): boolean;Joins the page id to the page before it: its content follows that page's content, and that page keeps its id,
label, lang and dir. The cursor goes to the start of the joined content. Returns false, changing nothing, for
the first page or an id that is not a page's. One undo step.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string |
Returns
Section titled “Returns”boolean
moveBlock()?
Section titled “moveBlock()?”optional moveBlock(block, direction): boolean;Moves a block one place up or down within its page, the cursor with it; returns false, changing nothing, at the page's start or end or for a place that holds no block. One undo step. Absent: blocks do not move. A block in a column stays in its column; a block directly on the page moves past a whole layout, which itself never moves. A block next to a frame moves into it (its last place going up, its first going down), and a frame's first or last block out of it; a frame itself never moves.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
block |
EditorBlockPlace |
direction |
"up" | "down" |
Returns
Section titled “Returns”boolean
onChange()
Section titled “onChange()”onChange(listener): () => void;Subscribe to document changes. Returns an unsubscribe function.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
listener |
() => void |
Returns
Section titled “Returns”() => void
onCursorChange()?
Section titled “onCursorChange()?”optional onCursorChange(listener): () => void;Subscribe to every move of the cursor and every change of the document or its history: what getCursor and
formatState return may have changed. Returns an unsubscribe function. Present with either.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
listener |
() => void |
Returns
Section titled “Returns”() => void
onSelectionChange()
Section titled “onSelectionChange()”onSelectionChange(listener): () => void;Subscribe to selection changes. Returns an unsubscribe function.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
listener |
(selection) => void |
Returns
Section titled “Returns”() => void
redo()?
Section titled “redo()?”optional redo(): boolean;Redoes the last undone step and focuses the editor; returns whether the document changed.
Returns
Section titled “Returns”boolean
removeBlock()?
Section titled “removeBlock()?”optional removeBlock(block): boolean;Deletes a block: its component, or all of its text; a page, a column or a frame left without content keeps one empty paragraph. Returns false, changing nothing, for a place that holds no block. One undo step.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
block |
EditorBlockPlace |
Returns
Section titled “Returns”boolean
removePage()?
Section titled “removePage()?”optional removePage(id): boolean;Deletes the page id and everything on it. The cursor goes to the start of the page before it, or of the next
page when it was the first. Returns false, changing nothing, for the only page or an id that is not a page's. One
undo step.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string |
Returns
Section titled “Returns”boolean
replaceElement()
Section titled “replaceElement()”replaceElement(id, html): void;Replaces one component element in place (inspector edits); the rest of the document is untouched. A cursor inside the element stays inside it: the inspector follows the element at the cursor while it writes.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string |
html |
string |
Returns
Section titled “Returns”void
select()
Section titled “select()”select(id): void;Moves the cursor to an element by source id (a component or a page) and focuses the editor.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string |
Returns
Section titled “Returns”void
selectedText()?
Section titled “selectedText()?”optional selectedText(): string;The plain text of the selection when it lies within one text block (trimmed), else ''. A template's
{{selection}} takes it, and insert with replaceSelection puts the snippet in its place. Absent: ''.
Returns
Section titled “Returns”string
setPageCheck()?
Section titled “setPageCheck()?”optional setPageCheck(check, page?): boolean;Sets (check: true) or clears check on the page page, or on every page when it is left out: a page's own Check
in practice. A document without pages becomes one page with a fresh id (page-<n>) and check in the same step;
clearing keeps the pages as they are. Returns whether anything changed (false when it was so already, or for an id
that is not a page's). One undo step. Absent: the editor cannot set it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
check |
boolean |
page? |
string |
Returns
Section titled “Returns”boolean
setSource()
Section titled “setSource()”setSource(source): void;Replaces the whole document.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
source |
string |
Returns
Section titled “Returns”void
splitPage()?
Section titled “splitPage()?”optional splitPage(): string | null;A page break at the cursor (at the start of a selection, which stays): a new page from there on, whose id it
returns, or null when the cursor is in no page's content. In a paragraph or a heading directly on a page, the page
breaks at the cursor (at its start: before it; at its end: after it); anywhere else (a component, a rich block, a
list, a column of a layout) after the block directly on the page, which stays whole. A side left without content gets one empty
paragraph. The new page has a fresh id page-<n> (pages and components share one namespace), no label, and the
lang and dir of the page it comes from; the cursor goes to the start of its first line. A document without
pages becomes pages in the same step, the first with a fresh id too. One undo step. Absent: the editor cannot
split pages.
Returns
Section titled “Returns”string | null
undo()?
Section titled “undo()?”optional undo(): boolean;Undoes the last step and focuses the editor; returns whether the document changed. Absent: no history.
Returns
Section titled “Returns”boolean
wrap()?
Section titled “wrap()?”optional wrap(tag): boolean;Runs the wrap command of the type tag (EditorDescriptor.wrap) on the selection and focuses the editor;
returns whether the document changed. Absent: the editor offers no such command.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
tag |
string |
Returns
Section titled “Returns”boolean
EditorBlockPlace
Section titled “EditorBlockPlace”A block by its place. A page's content is a list of blocks: each block component (display: 'block') directly on
the page is one block, and so is each Check element (astl-check); the content between two of them (paragraphs,
headings, lists, quotes, pictures, with the inline components in their text) is one text block. The authoring kit's
outline lists the same blocks
(OutlinePage.blocks). The content format has no blocks: they are a way to show and move a page's content. A
layout is not a block either: the blocks in its columns are on the page's list, in reading order, and a column's
content divides as a page's does; nor is a frame: the blocks it holds are, its title and tag aside.
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
index |
readonly |
number |
The block's index on its page, from 0. |
page |
readonly |
string | null |
The page's source id, or null for the content of a document without pages. |
EditorDescriptor
Section titled “EditorDescriptor”How authors create and edit one component type. Plain data, so it can also feed agent tools and docs.
Message keys are looked up in the manifest's messages namespace.
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
companion? |
readonly |
object |
The element this type works with, such as the word bank of a gap: an insert writes into an empty attribute the id of the first tag element of the inserted template (a starter that brings one), else of the new element's page (pages play one at a time), and adds that tag's template at the end of the page when it has none. |
companion.attribute |
readonly |
string |
- |
companion.tag |
readonly |
string |
- |
description |
readonly |
string |
Message key of a one-line description for insert menus. |
fields? |
readonly |
readonly InspectorField[] |
Inspector fields. Absent = derived from the manifest by the authoring kit. |
icon |
readonly |
string |
Icon name in the host's icon set (Phosphor names recommended), e.g. text-t. |
idPrefix |
readonly |
string |
Prefix for generated ids: gap gives gap-1, gap-2, ... |
label |
readonly |
string |
Message key of the menu label, e.g. editor.label. |
manifest |
readonly |
ComponentManifest |
- |
messages? |
readonly |
readonly MessageCatalog[] |
Catalogs of the manifest's namespace (labels, help texts, template texts). |
template |
readonly |
string |
Source HTML that insert menus add. Placeholders: {{id}} = a fresh unique id, {{t:key}} = a message from the manifest's namespace in the author's UI locale (escaped), {{selection}} = the text the author selected (escaped, '' without one), which the snippet then replaces. Local child ids (option ids) stay as written. |
templates? |
readonly |
readonly EditorTemplate[] |
Named starters: whole exercises with sample content, listed apart from the default template (which stays what the type's own entry inserts). |
wrap? |
readonly |
EditorWrap |
A command on the author's selection, for a type that holds rich content (content: 'flow'). |
EditorFormatState
Section titled “EditorFormatState”The formats at the cursor (EditorAdapter.formatState), for a toolbar's pressed and disabled buttons.
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
active |
readonly |
readonly EditorFormat[] |
The formats in effect: each mark on all of the selected text (at a cursor: the text before it), the text style of the block at the cursor (an <h2> counts as heading) and the list it is in. |
enabled |
readonly |
readonly EditorFormat[] |
The formats that can be toggled here: none while a component is selected, marks only in text a component holds (an option, a word), all of them in a page's own text. |
href |
readonly |
string | null |
The address of the link at the cursor, or null. |
redo |
readonly |
boolean |
Whether redo would change the document. |
undo |
readonly |
boolean |
Whether undo would change the document. |
EditorFrameState
Section titled “EditorFrameState”The frame at the cursor (EditorStyles.frame).
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
empty |
readonly |
boolean |
Whether it holds nothing but empty paragraphs, with an empty title and tag: it can go without asking. |
look |
readonly |
Readonly<Partial<Record<EditorFrameAttribute, string>>> |
Its look as written, by attribute; an attribute it does not have is absent (the default). |
tag |
readonly |
boolean |
Whether it has a tag. |
EditorInsertOptions
Section titled “EditorInsertOptions”How EditorAdapter.insert places a snippet.
Properties
Section titled “Properties”EditorLayoutState
Section titled “EditorLayoutState”The layout at the cursor (EditorStyles.layout).
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
columns |
readonly |
number |
- |
empty |
readonly |
boolean |
Whether its columns hold nothing but empty paragraphs: it can go without asking. |
shape |
readonly |
| EditorLayoutShape | null |
Its shape, or null for one of none (four columns, other widths). |
EditorSelection
Section titled “EditorSelection”The component the cursor is in, by source id; a selected Check element is one too (tag: astl-check).
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
id |
readonly |
string |
tag |
readonly |
string |
EditorStyleRule
Section titled “EditorStyleRule”A rule of the document (<astl-style>): a named style (name, label), or the style of a tag (for).
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
for? |
readonly |
string |
label? |
readonly |
string |
name? |
readonly |
string |
style |
readonly |
string |
EditorStyles
Section titled “EditorStyles”The styling commands of an editor (EditorAdapter.style). Each is one undo step, keeps the cursor and leaves the
focus where it is, so a form beside the text can call them on every change.
Methods
Section titled “Methods”clear()
Section titled “clear()”clear(): boolean;Clears formatting: the marks and styles of the selected text (a language and a link stay), and the style and named style of the blocks it covers whole; with only a cursor, of its block.
Returns
Section titled “Returns”boolean
editFrame()?
Section titled “editFrame()?”optional editFrame(edit): boolean;Changes the frame the cursor is in, in one undo step: one of its look's attributes (BOX_ATTRIBUTES) to a value,
or to its default (null); its tag (astl-box-tag) added, the cursor in it, or taken away with its text; unwrap
removes the frame and keeps its content in place, its title a heading and its tag a paragraph before it; delete
removes it with its content (a host asks first when it holds any). Returns false, changing nothing, without a frame
at the cursor or for what it already has.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
edit |
EditorFrameEdit |
Returns
Section titled “Returns”boolean
editLayout()?
Section titled “editLayout()?”optional editLayout(edit): boolean;Changes the layout the cursor is in, in one undo step: unwrap removes the columns and keeps their content in
place, one column after another; delete removes it with its content (a host asks first when it holds any); a
shape gives it that many columns, the content kept: a column that goes gives its content to the last one left.
Returns false, changing nothing, without a layout at the cursor or for the shape it has.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
edit |
EditorLayoutEdit |
Returns
Section titled “Returns”boolean
editTable()?
Section titled “editTable()?”optional editTable(edit): boolean;Changes the table the cursor is in, at the cell with the cursor, in one undo step: a row above or below it, a
column before or after it, its row or column deleted (a merged cell across the line grows or shrinks, one that
starts on it moves on); the cell merged with the one after it or below it (their content joined), or split back
into single cells; the table's header row (its first row as th scope="col" in a thead) or header column (each
body row's first cell as th scope="row") on or off; its caption added, the cursor in it, or taken away with its
text; delete removes the table with its content (a host asks first when it holds any). Returns false, changing
nothing, without a table at the cursor or for an edit EditorTableState.can says no to.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
edit |
EditorTableEdit |
Returns
Section titled “Returns”boolean
frame()?
Section titled “frame()?”optional frame(): EditorFrameState | null;The frame (astl-box) the cursor is in, or null. Absent: the editor cannot change a frame once inserted.
Returns
Section titled “Returns”EditorFrameState | null
insertLayout()
Section titled “insertLayout()”insertLayout(html): boolean;Inserts a layout (source HTML, one <astl-columns>, one frame, <astl-box>, or one table) as insert does, the
cursor in its first empty block (a new frame's: its title; a table's: its first cell). A frame never goes into a
frame, nor a layout into a frame in a column, nor a table into a table: from inside one, it goes after it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
html |
string |
Returns
Section titled “Returns”boolean
layout()?
Section titled “layout()?”optional layout(): | EditorLayoutState | null;The layout the cursor is in, or null. Absent: the editor cannot change a layout once inserted.
Returns
Section titled “Returns”| EditorLayoutState
| null
removeRule()
Section titled “removeRule()”removeRule(rule): boolean;Deletes a rule; a named style's class goes from every element too. Returns false for an unknown rule.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
rule |
Pick<EditorStyleRule, "name" | "for"> |
Returns
Section titled “Returns”boolean
replaceTarget()
Section titled “replaceTarget()”replaceTarget(kind, style): boolean;Replaces the target's own style with what the allow-list keeps of style (the "Own CSS" field).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
kind |
EditorStyleTargetKind |
style |
string |
Returns
Section titled “Returns”boolean
rules()
Section titled “rules()”rules(): readonly EditorStyleRule[];The document's rules, in order.
Returns
Section titled “Returns”readonly EditorStyleRule[]
saveRule()
Section titled “saveRule()”saveRule(kind, label): string | null;Makes the target's own style a named style: a new rule labelled label, the target's style gone and its class
the new name, which it returns. Null, changing nothing, past the limit or without a target of this kind.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
kind |
EditorStyleTargetKind |
label |
string |
Returns
Section titled “Returns”string | null
setClass()
Section titled “setClass()”setClass( where, name, rule?): boolean;Sets the named style on the selected text (text) or a target, in the place of any other; null clears it. With
rule (a ready style: a named rule of the same name), a document without a rule of that name gets it in the same
undo step; a rule of the document's own by that name stays as it is. Returns false, changing nothing, for a rule
of another name or with for, a new rule past the limit, or a class that changes nothing (no target, or there).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
where |
| "text" | EditorStyleTargetKind |
name |
string | null |
rule? |
EditorStyleRule |
Returns
Section titled “Returns”boolean
setRule()
Section titled “setRule()”setRule(rule): boolean;Adds a rule, or changes the one with its name or for, in place. A tag's rule without declarations goes. Returns
false, changing nothing, for a name the format refuses, or a new rule past the limit.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
rule |
EditorStyleRule |
Returns
Section titled “Returns”boolean
setTarget()
Section titled “setTarget()”setTarget(kind, changes): boolean;Sets declarations on the target of this kind at the cursor; block: on each text block of the selection.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
kind |
EditorStyleTargetKind |
changes |
EditorStyleChanges |
Returns
Section titled “Returns”boolean
setText()
Section titled “setText()”setText(changes): boolean;Sets declarations on the selected text; with only a cursor, on what is typed next. Text ends up in one span, whose language and classes stay; a span left with nothing goes. Returns whether anything changed.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
changes |
EditorStyleChanges |
Returns
Section titled “Returns”boolean
state()
Section titled “state()”state(): EditorStyleState;Returns
Section titled “Returns”table()?
Section titled “table()?”optional table(): EditorTableState | null;The table the cursor is in, or null. Absent: the editor cannot change a table once inserted.
Returns
Section titled “Returns”EditorTableState | null
EditorStyleState
Section titled “EditorStyleState”The state at the cursor (EditorStyles.state), for a toolbar and a form.
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
hasSelection |
readonly |
boolean |
Text is selected; without it, only a cursor. |
mixed |
readonly |
readonly string[] |
The properties that differ across the selected text. |
targets |
readonly |
readonly EditorStyleTarget[] |
What the cursor is in, from the inside out. |
text |
readonly |
Readonly<Record<string, string>> |
The declarations all of the selected text has, or what typing would get at the cursor. |
textClass |
readonly |
string | null |
The named style on all of the selected text, or at the cursor; null: none, or not the same throughout. |
textEnabled |
readonly |
boolean |
Whether styles can go on text here: not with a component or a picture selected. |
EditorStyleTarget
Section titled “EditorStyleTarget”An element at the cursor that takes a style (EditorStyleState.targets).
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
className |
readonly |
string | null |
The named style on it (the first, for a source written by hand with more), or null. |
kind |
readonly |
EditorStyleTargetKind |
- |
style |
readonly |
string |
Its own style in the allow-list's normal form (name: value; name: value), '' without one. |
tag |
readonly |
string |
Its tag in the source: p, img, astl-choice. |
EditorTableState
Section titled “EditorTableState”The table at the cursor (EditorStyles.table).
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
can |
readonly |
Readonly<Record<EditorTableCommand | "headerRow" | "headerColumn", boolean>> |
Whether each command would change it now, at the cell with the cursor (a merge needs a neighbour of the same span, a split a merged cell, a deletion another row or column), and whether its header row and header column can switch (a cell that holds a question can never be a header). |
caption |
readonly |
boolean |
- |
columns |
readonly |
number |
- |
empty |
readonly |
boolean |
Whether its caption and cells hold nothing: it can go without asking. |
headerColumn |
readonly |
boolean |
- |
headerRow |
readonly |
boolean |
Whether its first row is a header row (a thead), each body row starts with a row header, it has a caption. |
rows |
readonly |
number |
Its rows, the header's among them, and its columns, as its cells and their spans make them. |
EditorTemplate
Section titled “EditorTemplate”A named starter of a type, inserted like its default template.
Properties
Section titled “Properties”EditorWrap
Section titled “EditorWrap”Wraps the selected words in an inline child (Mark word): the editor puts each selected word in a new child
element (a fresh local id, attributes as given) and the blocks around them in an element of this type when they
are in none (with a fresh id, joined to one right before or after); on words already in the child it removes the
child, keeping the text. Editors offer it as a button labelled label (EditorAdapter.wrap).
Properties
Section titled “Properties”ElementContext
Section titled “ElementContext”What the player gives each element when it mounts the view.
Properties
Section titled “Properties”Methods
Section titled “Methods”announce()
Section titled “announce()”announce(message): void;Polite announcement through the player's single live region.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message |
string |
Returns
Section titled “Returns”void
t(key, params?): string;Formats a message in the UI locale from the element type's namespace, falling back to the shared astl.player
namespace (verdict words such as verdict.correct, generic labels).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key |
string |
params? |
Readonly<Record<string, string | number>> |
Returns
Section titled “Returns”string
ElementFeedback
Section titled “ElementFeedback”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
explanation? |
readonly |
string | null |
- |
group |
readonly |
GroupVerdict | null |
Verdict of the element's scoring group; null when ungraded or graded in parts. |
groups? |
readonly |
Readonly<Record<string, GroupVerdict>> |
Verdicts of the groups an element graded in parts names in groupIds (a crossword's words), by group id. |
message? |
readonly |
Feedback | null |
The author's feedback for the element's verdict and its explanation (HTML), when the policy shows them. The player shows both under the element, so an element needs to do nothing with them. |
slots |
readonly |
Readonly<Record<SlotId, SlotVerdict>> |
Verdicts for this element's slots that the student may see. |
ElementHelp
Section titled “ElementHelp”What a view says about the help of an interaction or a page, so a player can offer it: never its text.
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
explanation |
readonly |
boolean |
- |
feedback |
readonly |
readonly FeedbackVariant[] |
The variants with a text, in FEEDBACK_VARIANTS order. |
hintPoints? |
readonly |
readonly number[] |
What each hint can take off in points (its cost times the points of the interaction, or of the page's questions), in order; absent in views compiled before 0.2. |
hints |
readonly |
readonly number[] |
The cost of each hint, in order (0: free). |
ElementNode
Section titled “ElementNode”The document tree the engine and component definitions work on. Produced by the engine's HTML parser (sources) and serialised back to HTML (views). Plain data: no DOM, no parent pointers.
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
attrs |
readonly |
Readonly<Record<string, string>> |
Attributes in source order. Values are already entity-decoded. |
children |
readonly |
readonly Node[] |
- |
tag |
readonly |
string |
Lowercase tag name, e.g. p, astl-gap. |
type |
readonly |
"element" |
- |
Engine
Section titled “Engine”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
manifests |
readonly |
readonly ComponentManifest[] |
Manifests of the registered components, in registration order. |
Methods
Section titled “Methods”compile()
Section titled “compile()”compile(source, options?): Promise<CompileResult>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
source |
string |
options? |
CompileOptions |
Returns
Section titled “Returns”Promise<CompileResult>
describe()
Section titled “describe()”describe(issue, locale): string;Renders an issue in the given UI locale (falls back to English, then to the code).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
issue |
Issue |
locale |
string |
Returns
Section titled “Returns”string
grade()
Section titled “grade()”grade( key, answers, options?): GradeResult;Pure and synchronous: safe to call per request. Malformed answers count as unanswered.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key |
AnswerKey |
answers |
Answers |
options? |
GradeOptions |
Returns
Section titled “Returns”solution()
Section titled “solution()”solution(key, options?): Solution;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key |
AnswerKey |
options? |
GradeOptions |
Returns
Section titled “Returns”validate()
Section titled “validate()”validate(source): ValidationReport;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
source |
string |
Returns
Section titled “Returns”EngineOptions
Section titled “EngineOptions”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
catalogs? |
readonly |
readonly MessageCatalog[] |
Extra or replacement message catalogs (e.g. more locales) for describe. |
components |
readonly |
readonly ComponentDefinition[] |
- |
groundColors? |
readonly |
GroundColors |
The colours a page shows text on (hex), for the warning STYLE_style is compared with these where nothing else is declared around it. Without them, only colours both declared are compared. |
profile? |
readonly |
Partial<NormalisationProfile> |
Overrides of the default text comparison profile. |
secret? |
readonly |
string | Uint8Array<ArrayBufferLike> |
HMAC secret for opaque ids and permutations, at least 16 bytes. Keep it stable: it decides every view. Only compile needs it and throws without one. There is no default: a known secret undoes the keyed option order. |
slotKinds? |
readonly |
readonly SlotKind<JsonObject>[] |
Added to the built-in slot kinds (text, number, choice, flag). Same kind twice = error. |
styleTemplates? |
readonly |
readonly StyleTemplate[] |
Style templates the hosts' players register, so style-template values can be checked: a name that is not registered, or not allowed at its scope or for its tag, gives the warning STYLE_ |
urlPolicy? |
readonly |
UrlPolicy |
Which URLs stay in sources and views (UrlPolicy). Default isSafeUrl. |
ErrorDetail
Section titled “ErrorDetail”Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
code |
readonly |
string |
message |
readonly |
string |
Feedback
Section titled “Feedback”A feedback text as a student gets it: the variant of the verdict and the author's text (HTML of format 1).
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
html |
readonly |
string |
- |
variant |
readonly |
FeedbackVariant |
The verdict's variant; its text is the incorrect one when a partial verdict has none of its own. |
GradeContext
Section titled “GradeContext”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
lang |
readonly |
string |
Content language of the slot (BCP 47), for locale-aware comparisons. |
GradeOptions
Section titled “GradeOptions”Properties
Section titled “Properties”GradeResult
Section titled “GradeResult”Extends
Section titled “Extends”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
correct |
readonly |
boolean |
True when every included group is correct; false when no group is included (empty key or unknown page). |
counts |
readonly |
VerdictCounts |
Counts over groups. |
groups |
readonly |
readonly GroupResult[] |
- |
max |
readonly |
number |
- |
pages |
readonly |
Readonly<Record<string, Score>> |
Score per view page id. |
score |
readonly |
number |
- |
slots |
readonly |
Readonly<Record<SlotId, SlotVerdict>> |
Per-slot verdicts the student may see: answered slots only, selected flags only, and nothing for slots of a multi-slot all-correct group that is wrong or grades one part of its component (those show only the group verdict). |
GroundColors
Section titled “GroundColors”The colours a page shows text on (hex or rgb()).
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
ink |
readonly |
string |
surface |
readonly |
string |
GroupResult
Section titled “GroupResult”Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
id |
readonly |
string |
max |
readonly |
number |
score |
readonly |
number |
verdict |
readonly |
GroupVerdict |
GroupSpec
Section titled “GroupSpec”A scoring group of an element graded in parts (see ComponentDefinition.groups).
Properties
Section titled “Properties”HelpPolicy
Section titled “HelpPolicy”The help fields of a policy, with every absent one taken from its mode's default policy.
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
checkScope |
readonly |
CheckScope |
explanations |
readonly |
HelpMoment |
feedback |
readonly |
HelpMoment |
hints |
readonly |
boolean |
HintRequest
Section titled “HintRequest”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
element |
readonly |
string |
View element id, or a view page id for the page's own hints. |
HintResponse
Section titled “HintResponse”The next hint of an interaction or page. Whoever grades records it: a hint's cost counts when it is used.
Properties
Section titled “Properties”Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
fallbackLocale |
readonly |
string |
Methods
Section titled “Methods”locales()
Section titled “locales()”locales(namespace?): readonly string[];Locales that have at least one catalog (for a namespace, if given).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
namespace? |
string |
Returns
Section titled “Returns”readonly string[]
t( locale, namespace, key, params?): string;Formats namespace:key in the best matching locale, then the fallback locale, else returns the key.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
locale |
string |
namespace |
string |
key |
string |
params? |
Readonly<Record<string, string | number>> |
Returns
Section titled “Returns”string
translator()
Section titled “translator()”translator(locale, namespace): Translate;A translate function bound to one locale and namespace.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
locale |
string |
namespace |
string |
Returns
Section titled “Returns”with()
Section titled “with()”with(catalogs): I18n;A new instance with more catalogs. Later catalogs override earlier keys of the same namespace and locale.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
catalogs |
readonly MessageCatalog[] |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
at |
readonly |
IssueLocation |
- |
code |
readonly |
string |
Stable UPPER_CHOICE_CORRECT_MISSING. |
namespace |
readonly |
string |
i18n namespace of the message (astl.engine or the manifest's messages). |
params |
readonly |
IssueParams |
- |
severity |
readonly |
Severity |
Errors block compiling; warnings do not. |
IssueLocation
Section titled “IssueLocation”Properties
Section titled “Properties”JsonObject
Section titled “JsonObject”Indexable
Section titled “Indexable”[key: string]: JsonValueKeyHelp
Section titled “KeyHelp”The help of one interaction or page (see help.ts): key-side, as it may give the answer away.
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
explanation |
readonly |
string | null |
HTML; null when there is none. |
feedback |
readonly |
Readonly<Partial<Record<FeedbackVariant, string>>> |
HTML by variant, only the variants written. |
hints |
readonly |
readonly KeyHint[] |
- |
KeyHint
Section titled “KeyHint”A hint as the key holds it: its content (HTML of format 1) and the fraction 0..1 of the points it costs.
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
cost |
readonly |
number |
html |
readonly |
string |
KeySlot
Section titled “KeySlot”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
group |
readonly |
string |
Opaque id of the component the slot belongs to, which is also the id of its scoring group, unless the component is graded in parts (ComponentDefinition.groups): then its groups list the slot. Open slots (an ungraded kind) belong to no group: no groups entry has this id or lists them. |
key |
readonly |
JsonObject |
- |
kind |
readonly |
string |
- |
page |
readonly |
string |
View page id. |
MessageCatalog
Section titled “MessageCatalog”Messages of one namespace in one locale. Values are ICU MessageFormat 1 strings.
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
locale |
readonly |
string |
BCP 47, e.g. pl. |
messages |
readonly |
Readonly<Record<string, string>> |
- |
namespace |
readonly |
string |
e.g. astl.player, astl.gap. |
MessageFormatter
Section titled “MessageFormatter”Port for message formatting. The default is the ICU MessageFormat 1 subset in format.ts.
Methods
Section titled “Methods”format()
Section titled “format()”format( message, params, locale): string;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message |
string |
params |
MessageParams |
locale |
string |
Returns
Section titled “Returns”string
Metadata
Section titled “Metadata”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
dir |
readonly |
"ltr" | "rtl" |
- |
elements |
readonly |
Readonly<Record<string, number>> |
Element counts by tag, e.g. { "astl-gap": 5 }. |
extra |
readonly |
Readonly<Record<string, number>> |
Numbers contributed by component metadata hooks, keyed tag.name. |
format |
readonly |
number |
- |
groups |
readonly |
number |
- |
kind? |
readonly |
"exercise" | "book" |
The document's kind when it is not exercise, the default: as in the view, the metadata of every exercise (and every conformance golden) stays as it was. Absent means exercise. |
lang |
readonly |
string |
- |
maxScore |
readonly |
number |
- |
open |
readonly |
readonly string[] |
Ids of the open slots (stored for a teacher, never graded), in reading order, so a server or a teacher's view can pick these answers out of a submission. They add nothing to maxScore. |
pages |
readonly |
readonly PageMetadata[] |
- |
slots |
readonly |
number |
Answer slots, open ones included: what a player's astl-ready counts. |
viewHash |
readonly |
string |
- |
words |
readonly |
number |
Words of running text, for reading-time estimates. |
NormalisationProfile
Section titled “NormalisationProfile”How typed text is compared. Resolved at compile time and stored inside each text key, so stored keys grade the same forever, whatever the defaults are later.
Properties
Section titled “Properties”PageDetail
Section titled “PageDetail”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
count |
readonly |
number |
- |
id |
readonly |
string |
View page id. |
index |
readonly |
number |
- |
PageMetadata
Section titled “PageMetadata”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
id |
readonly |
string |
View page id. |
label |
readonly |
string | null |
- |
maxScore |
readonly |
number |
- |
slots |
readonly |
number |
Answer slots on the page, open ones included. |
PlayerElementApi
Section titled “PlayerElementApi”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
disabled |
public |
boolean |
- |
feedback |
public |
ElementFeedback | null |
Shows verdicts; null clears them. Editing a slot clears its own verdict. |
groupIds? |
readonly |
readonly string[] |
The ids of the groups an element may be graded in (ComponentDefinition.groups), as its view names them: the player passes their verdicts in feedback.groups. Absent: one group, the element's id. |
slotIds |
readonly |
readonly string[] |
Slot ids this element answers, in reading order. Stable after the element connects. |
solution |
public |
Readonly<Record<string, string>> | null |
Shows the correct answers next to the student's; null hides them. |
Methods
Section titled “Methods”attach()
Section titled “attach()”attach(context): void;Called by the player once, before the first render. Elements must work with a default context too.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context |
ElementContext |
Returns
Section titled “Returns”void
getAnswers()
Section titled “getAnswers()”getAnswers(): Answers;Answered slots only.
Returns
Section titled “Returns”getUiState()?
Section titled “getUiState()?”optional getUiState(): JsonValue;Non-answer UI state worth restoring after a reload.
Returns
Section titled “Returns”setAnswers()
Section titled “setAnswers()”setAnswers(answers): void;Unknown ids are ignored; '' clears a slot. Does not fire a change event.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
answers |
Answers |
Returns
Section titled “Returns”void
setUiState()?
Section titled “setUiState()?”optional setUiState(state): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
state |
JsonValue |
Returns
Section titled “Returns”void
units()
Section titled “units()”units(): Units;Progress units, e.g. 3 of 5 cards placed.
Returns
Section titled “Returns”ProblemDetails
Section titled “ProblemDetails”Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
code |
readonly |
ProblemCodeValue |
detail? |
readonly |
string |
status |
readonly |
number |
title |
readonly |
string |
type |
readonly |
string |
ReadyDetail
Section titled “ReadyDetail”Detail of astl-ready.
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
pages |
readonly |
number |
Number of pages. |
slots |
readonly |
number |
Number of slots across all registered elements. |
viewHash |
readonly |
string |
- |
ResultHelp
Section titled “ResultHelp”Help that comes with a result when the policy shows it (the engine's helpShown), for what was graded: absent when there is
none, so responses without help stay as they were.
Extended by
Section titled “Extended by”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
explanations? |
readonly |
Readonly<Record<string, string>> |
HTML by view element id or view page id. |
feedback? |
readonly |
Readonly<Record<string, Feedback>> |
By view element id, and by view page id for a page's own feedback (picked by the page's score). |
Extended by
Section titled “Extended by”Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
max |
readonly |
number |
score |
readonly |
number |
ScoringGroup
Section titled “ScoringGroup”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
id |
readonly |
string |
- |
page |
readonly |
string |
View page id the group belongs to. |
points |
readonly |
number |
- |
rule |
readonly |
ScoringRule |
- |
slots |
readonly |
readonly string[] |
Slot ids in reading order. |
ScoringSpec
Section titled “ScoringSpec”Scoring modes an author can pick with the scoring attribute, each mapped to one engine rule.
Mode names speak the author's language (all, per-option); rules are the three engine rules.
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
default |
readonly |
string |
modes |
readonly |
Readonly<Record<string, ScoringRule>> |
SlotKind
Section titled “SlotKind”Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
TKey extends JsonObject |
JsonObject |
Properties
Section titled “Properties”Methods
Section titled “Methods”isCorrect()
Section titled “isCorrect()”isCorrect( key, answer, context): boolean;answer is never empty here: the engine handles unanswered slots before calling.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key |
TKey |
answer |
string |
context |
GradeContext |
Returns
Section titled “Returns”boolean
isKey()
Section titled “isKey()”isKey(key): key is TKey;Validates a stored key (compile output, or a key loaded from storage).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key |
JsonObject |
Returns
Section titled “Returns”key is TKey
solution()
Section titled “solution()”solution(key): string;The answer that shows the solution. '' = leave the slot empty (an unselected flag).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key |
TKey |
Returns
Section titled “Returns”string
SlotSpec
Section titled “SlotSpec”One graded unit produced by an element. key must satisfy the registered SlotKind's isKey.
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
id |
readonly |
string |
Opaque slot id, from context.opaque(...). |
key |
readonly |
JsonObject |
- |
kind |
readonly |
string |
- |
Snapshot
Section titled “Snapshot”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
answers |
readonly |
Answers |
- |
checks |
readonly |
number |
- |
format |
readonly |
1 |
- |
page |
readonly |
number |
0-based page index. |
savedAt |
readonly |
string |
ISO 8601. |
submitted |
readonly |
boolean |
- |
ui |
readonly |
Readonly<Record<string, JsonValue>> |
Non-answer UI state per element id (e.g. a flashcard index). |
viewHash |
readonly |
string | null |
View the snapshot was taken on. A player ignores snapshots of another view. |
StateDetail
Section titled “StateDetail”Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
previous |
readonly |
AttemptState |
state |
readonly |
AttemptState |
StyleTemplate
Section titled “StyleTemplate”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
catalogs? |
readonly |
readonly MessageCatalog[] |
Catalogs of that namespace. |
components? |
readonly |
readonly string[] |
Component tags it supports at the component scope; absent = every registered component. |
dark? |
readonly |
Readonly<Record<string, string>> |
Overrides on top of tokens for the dark theme only. |
light? |
readonly |
Readonly<Record<string, string>> |
Overrides on top of tokens for the light theme only. |
messages |
readonly |
string |
i18n namespace of its texts: label (picker label) and description (one line), e.g. astl.style.notebook. |
name |
readonly |
string |
What authors write in style-template. Matches STYLE_ |
parts? |
readonly |
Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, string>>>>>> |
::part() declarations by component tag, then part name (a name from the manifest's cssParts), e.g. { 'astl-choice': { option: { 'border-radius': 'var(--astl-radius-l)' } } }. Use tokens in values so the declarations follow the theme. |
scopes |
readonly |
readonly StyleScope[] |
Where the template may be used. |
tokens? |
readonly |
Readonly<Record<string, string>> |
Token overrides for the light and dark themes (never hc). |
version |
readonly |
number |
Bumped when the look changes visibly. Exercises keep referring to the name. |
SubmitRequest
Section titled “SubmitRequest”Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
answers |
readonly |
Answers |
SubmitResponse
Section titled “SubmitResponse”Help that comes with a result when the policy shows it (the engine's helpShown), for what was graded: absent when there is
none, so responses without help stay as they were.
Extends
Section titled “Extends”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
explanations? |
readonly |
Readonly<Record<string, string>> |
HTML by view element id or view page id. |
feedback? |
readonly |
Readonly<Record<string, Feedback>> |
By view element id, and by view page id for a page's own feedback (picked by the page's score). |
passed |
readonly |
boolean | null |
null when there is no pass mark or nothing is revealed. |
result |
readonly |
GradeResult | null |
null when the policy reveals nothing yet. |
solution |
readonly |
Readonly<Record<string, string>> | null |
Only when the policy reveals answers. |
submittedAt |
readonly |
string |
ISO 8601, set by whoever grades. |
TextNode
Section titled “TextNode”Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
type |
readonly |
"text" |
value |
readonly |
string |
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
answered |
readonly |
number |
total |
readonly |
number |
ValidateContext
Section titled “ValidateContext”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
lang |
readonly |
string |
Content language at this element (nearest lang, else the document's). |
profile |
readonly |
NormalisationProfile |
Engine-wide text comparison defaults (for duplicate checks); definitions apply their own attributes on top. |
Methods
Section titled “Methods”find()
Section titled “find()”find(id): ElementNode | undefined;Another component on the same page, by source id, sanitised as its own definition sees it (a drop names its word bank); undefined when the page has none. Pages are played one at a time, so elements that work together share a page. Definitions run once the whole document is read, so the element may come later in the source.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string |
Returns
Section titled “Returns”ElementNode | undefined
report()
Section titled “report()”report( code, params?, options?): void;Reports an issue on the current element, or on one of its children (for a precise path).
code must be listed in the manifest's issues. Default severity: error.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
code |
string |
params? |
Readonly<Record<string, string | number>> |
options? |
{ child?: ElementNode; severity?: Severity; } |
options.child? |
ElementNode |
options.severity? |
Severity |
Returns
Section titled “Returns”void
ValidationReport
Section titled “ValidationReport”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
issues |
readonly |
readonly Issue[] |
- |
ok |
readonly |
boolean |
True when there are no errors (warnings allowed). |
VariantSpec
Section titled “VariantSpec”Presentation variants, picked by authors with the public variant attribute: how the element looks and behaves for
the student (a gap that grows while typing, a select with a search box), never what it grades or which answers
exist, so every variant of a source grades the same. The engine validates the value (an enum of values), elements
render it, the authoring kit offers it (labels: editor.value.variant.<value> in the manifest's namespace).
Adding a variant is not a breaking change; removing one or changing the default is (bump version).
Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
default |
readonly |
string |
Used when the attribute is absent or unknown to an older player. |
values |
readonly |
readonly string[] |
Kebab-case names, default included. |
VerdictCounts
Section titled “VerdictCounts”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
correct |
readonly |
number |
- |
empty |
readonly |
number |
- |
incorrect |
readonly |
number |
- |
partial |
readonly |
number |
- |
total |
readonly |
number |
Number of groups counted. |
Type Aliases
Section titled “Type Aliases”Answers
Section titled “Answers”type Answers = Readonly<Record<SlotId, string>>;AttemptMode
Section titled “AttemptMode”type AttemptMode = "practice" | "test" | "review";Attempt policies. Practice, quiz and test are policies over the same content, not different content: a document's
kind (DOC_KINDS, exercise or book) is how it shows, never how it grades.
The server is authoritative: the player only reflects the policy it is given.
AttemptState
Section titled “AttemptState”type AttemptState = | "loading" | "ready" | "active" | "checking" | "submitting" | "submitted" | "review" | "error";AttributeType
Section titled “AttributeType”type AttributeType = "string" | "boolean" | "integer" | "number" | "enum" | "id" | "url";id: a source id local to the component (e.g. an option id); replaced by an opaque id in the view.boolean: HTML boolean attribute (present = true;"false"is invalid).url: checked by the engine's UrlPolicy; a blocked URL is removed with a URL_BLOCKED warning.
BadgeFill
Section titled “BadgeFill”type BadgeFill = typeof BADGE_FILLS[number];BadgeShape
Section titled “BadgeShape”type BadgeShape = typeof BADGE_SHAPES[number];CheckPart
Section titled “CheckPart”type CheckPart = | { kind: "text"; questions: readonly string[];} | { kind: "block"; question: string | null;} | { for: readonly string[] | null; kind: "check";} | { kind: "edge";};One part of a page for the check rule, in reading order. A run of text is what lies between two block components (paragraphs, lists, quotes, pictures), up to the next heading: its graded inline questions, in order. A heading starts a new run (it usually starts a new exercise). A block component is one part, a check another; an edge (where a layout or one of its columns starts or ends) ends a run.
CheckScope
Section titled “CheckScope”type CheckScope = "exercise" | "interaction";interaction: a check may cover one interaction too (CheckRequest.element), not only the exercise or a page.
CompileResult
Section titled “CompileResult”type CompileResult = | object & Compilation | { issues: readonly Issue[]; ok: false;};Declarations
Section titled “Declarations”type Declarations = Readonly<Record<string, string>>;CSS declarations by property name, e.g. { 'border-radius': 'var(--astl-radius-l)' }.
Direction
Section titled “Direction”type Direction = "ltr" | "rtl";DocKind
Section titled “DocKind”type DocKind = typeof DOC_KINDS[number];EditorFormat
Section titled “EditorFormat”type EditorFormat = | "bold" | "italic" | "underline" | "link" | "paragraph" | "heading" | "subheading" | "bulleted" | "numbered";A text format a toolbar toggles (EditorAdapter.format), each one of content format 1: the marks bold
(<strong> or <b>), italic (<em> or <i>), underline (<u>) and link (<a href>); the text styles
paragraph (<p>), heading (<h3>, below the page title the player shows as <h2>) and subheading (<h4>);
the lists bulleted (<ul>) and numbered (<ol>).
EditorFrameAttribute
Section titled “EditorFrameAttribute”type EditorFrameAttribute = "title-place" | "variant" | "icon" | "palette";An attribute of a frame's look (BOX_ATTRIBUTES).
EditorFrameEdit
Section titled “EditorFrameEdit”type EditorFrameEdit = | "unwrap" | "delete" | { attribute: EditorFrameAttribute; value: string | null;} | { tag: boolean;};What EditorStyles.editFrame does to the frame at the cursor.
EditorLayoutEdit
Section titled “EditorLayoutEdit”type EditorLayoutEdit = | "unwrap" | "delete" | EditorLayoutShape;What EditorStyles.editLayout does to the layout at the cursor.
EditorLayoutShape
Section titled “EditorLayoutShape”type EditorLayoutShape = "two" | "three" | "wide-narrow" | "narrow-wide";The shapes a layout can be changed to: two or three equal columns, or a wide and a narrow one.
EditorStyleChanges
Section titled “EditorStyleChanges”type EditorStyleChanges = Readonly<Record<string, string | null>>;Declarations to set; null removes one. Only what the style allow-list keeps is ever written.
EditorStyleTargetKind
Section titled “EditorStyleTargetKind”type EditorStyleTargetKind = | "picture" | "figure" | "block" | "component" | "column" | "layout" | "frame" | "rule" | "table";What takes a style besides the selected text (EditorStyles): a picture in text or in a figure, a figure, the text
block with the cursor (a paragraph, a heading, a caption, an option, a table's cell), a component, a column, a
layout, a frame (astl-box), a selected horizontal rule or a table.
EditorTableCommand
Section titled “EditorTableCommand”type EditorTableCommand = | "row-before" | "row-after" | "row-delete" | "column-before" | "column-after" | "column-delete" | "merge-right" | "merge-down" | "split" | "delete";A command on a table, at the cell with the cursor (EditorStyles.editTable).
EditorTableEdit
Section titled “EditorTableEdit”type EditorTableEdit = | EditorTableCommand | { headerRow: boolean;} | { headerColumn: boolean;} | { caption: boolean;};What EditorStyles.editTable does to the table at the cursor.
EngineIssueCode
Section titled “EngineIssueCode”type EngineIssueCode = typeof EngineIssue[keyof typeof EngineIssue];FeedbackVariant
Section titled “FeedbackVariant”type FeedbackVariant = "correct" | "incorrect" | "partial" | "omitted";The when of a feedback text: one per group verdict, omitted for empty.
GroupVerdict
Section titled “GroupVerdict”type GroupVerdict = "correct" | "partial" | "incorrect" | "empty";HelpMoment
Section titled “HelpMoment”type HelpMoment = "never" | "check" | "submit";When feedback texts or explanations come: never; check: after every check and the hand-in; submit: after the
hand-in only. At the hand-in they come only with the answers (reveal: 'answers'): they may give them away.
InspectorField
Section titled “InspectorField”type InspectorField = | { accept?: string; help?: string; kind: "attribute"; label: string; name: string; options?: { from?: string; tag: string; }; variants?: readonly string[];} | { help?: string; kind: "text-list"; label: string; multiline?: boolean; tag: string;} | { attribute: string; help?: string; kind: "child-flag" | "child-text"; label: string; tag: string;} | { attribute: string; help?: string; kind: "child-choice"; label: string; options?: string; tag: string;} | { columns: readonly object[]; help?: string; kind: "child-table"; label: string; tag: string;} | { alt?: string; help?: string; kind: "picture-regions" | "picture-points"; label: string; src: string; tag: string;};One inspector control:
attribute: an attribute of the element (control picked from the AttributeSpec type);text-list: repeated private text children (e.g. accepted alternatives<astl-alt>);child-flag: a boolean attribute on each child of a tag, listed by the child's text (e.g. which options are correct); its label and help messages getcount(children) andchecked(children with the flag);child-text: a free-text attribute on each child of a tag, listed by the child's text (e.g. the word each clue hides); an empty value removes the attribute;child-choice: one value of an attribute on each child of a tag, listed by the child's text: one of the attribute's enum values (e.g. whether each statement is true or false), or withoptions, the id of a child of another tag (e.g. the category of each card).child-table: the children of a tag as rows, each listed by its text, with a control for each ofcolumns(by the attribute's type: text, number or a select of its enum values) and a button that removes it; a button adds a row, a child with a fresh local id and a first value for each required attribute (e.g. a crossword's words).picture-regions: zones on the element's picture, one child oftageach, drawn with a pointer or typed in number fields. A zone hasid(local),shape(rect,circleorpolygon),xandy(rect: its top-left corner; circle: its centre),widthandheight(rect),r(circle, a share of the width),points(polygon:x,y x,y ...) and an optionallabel. Every coordinate is a percentage of the picture, which never mirrors: x of its width from the left edge, y of its height from the top.picture-points: pins on the picture, one child oftageach:id,xandy(percent) andlabel. Both show the picture of the element'surlattributesrc, which they set by upload or address; withalt, the element's attribute that holds the picture's alt text, a picture from the host that comes with alt text fills it in while it is empty. Rich content (prompts, option texts) is edited in the WYSIWYG itself. The children of a tag are found anywhere in the element, so the inline children of a type with rich content (content: 'flow') are listed too.
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ accept?: string; help?: string; kind: "attribute"; label: string; name: string; options?: { from?: string; tag: string; }; variants?: readonly string[];}| Name | Type | Description |
|---|---|---|
accept? |
string |
A url attribute: the files an author may upload for it with the host's uploadAsset (a file input's accept, e.g. video/mp4,video/webm). Absent, or without an upload, the address is typed. |
help? |
string |
Message key of help text, optional. |
kind |
"attribute" |
- |
label |
string |
Message key of the label. |
name |
string |
Attribute name, e.g. answer. |
options? |
object |
Choices in a select: the ids of the tag children of the element whose id is in this element's attribute from, listed by their text (e.g. the words of the bank a drop takes its words from); without from, of this element's own tag children (the option a select shows as its example). Without the document or that element, the attribute's own control. |
options.from? |
string |
- |
options.tag |
string |
- |
variants? |
readonly string[] |
Shown only while the element shows one of these variants (its valid variant, else the manifest's default), for an attribute that only one presentation reads (a dropdown's native). Absent: shown in every variant. |
Type Literal
Section titled “Type Literal”{ help?: string; kind: "text-list"; label: string; multiline?: boolean; tag: string;}| Name | Type | Description |
|---|---|---|
help? |
string |
- |
kind |
"text-list" |
- |
label |
string |
- |
multiline? |
boolean |
Each child in a text area that keeps its line breaks (a transcript), not on one line. |
tag |
string |
Child tag, e.g. astl-alt. |
Type Literal
Section titled “Type Literal”{ attribute: string; help?: string; kind: "child-flag" | "child-text"; label: string; tag: string;}| Name | Type | Description |
|---|---|---|
attribute |
string |
Attribute on each child: a boolean for child-flag (e.g. correct), a string for child-text. |
help? |
string |
- |
kind |
"child-flag" | "child-text" |
- |
label |
string |
- |
tag |
string |
Child tag, e.g. astl-option. |
Type Literal
Section titled “Type Literal”{ attribute: string; help?: string; kind: "child-choice"; label: string; options?: string; tag: string;}| Name | Type | Description |
|---|---|---|
attribute |
string |
Attribute on each child, e.g. answer or category. |
help? |
string |
- |
kind |
"child-choice" |
- |
label |
string |
- |
options? |
string |
Where the choices come from. Absent: the attribute's enum values (editor.value.<attribute>.<value>, e.g. true / false of each statement). A child tag: the ids of the element's children with that tag, listed by their text (e.g. astl-category for the category of each card). |
tag |
string |
Child tag, e.g. astl-statement or astl-card. |
Type Literal
Section titled “Type Literal”{ columns: readonly object[]; help?: string; kind: "child-table"; label: string; tag: string;}| Name | Type | Description |
|---|---|---|
columns |
readonly object[] |
The child's attributes edited in each row, in order, each with the message key of its label. |
help? |
string |
- |
kind |
"child-table" |
- |
label |
string |
- |
tag |
string |
Child tag, e.g. astl-crossword-word. |
Type Literal
Section titled “Type Literal”{ alt?: string; help?: string; kind: "picture-regions" | "picture-points"; label: string; src: string; tag: string;}| Name | Type | Description |
|---|---|---|
alt? |
string |
The element's attribute that holds the picture's alt text, e.g. alt: an uploaded or picked picture's UploadedAsset.alt fills it in while it is empty. Absent: nothing is filled in. |
help? |
string |
- |
kind |
"picture-regions" | "picture-points" |
- |
label |
string |
- |
src |
string |
The element's url attribute that holds the picture, e.g. src. |
tag |
string |
Child tag of a zone or a pin, e.g. astl-region. |
IssueParams
Section titled “IssueParams”type IssueParams = Readonly<Record<string, string | number>>;JsonArray
Section titled “JsonArray”type JsonArray = readonly JsonValue[];JsonValue
Section titled “JsonValue”type JsonValue = | string | number | boolean | null | JsonArray | JsonObject;A JSON value. Every contract object that crosses a process boundary is made of these.
MessageParams
Section titled “MessageParams”type MessageParams = Readonly<Record<string, string | number>>;i18n contracts. Two axes are kept apart everywhere:
- UI locale: chrome, labels, issue messages, announcements (the reader's choice);
- content language: the
langof the exercise text, used for grading and rendering (the author's choice).
MessagePart
Section titled “MessagePart”type MessagePart = | { type: "text"; value: string;} | { name: string; style: "plain" | "number" | "integer" | "percent"; type: "arg";} | { name: string; offset: number; options: Readonly<Record<string, readonly MessagePart[]>>; ordinal: boolean; type: "plural";} | { name: string; options: Readonly<Record<string, readonly MessagePart[]>>; type: "select";} | { type: "pound";};type Node = | ElementNode | TextNode;ProblemCodeValue
Section titled “ProblemCodeValue”type ProblemCodeValue = typeof ProblemCode[keyof typeof ProblemCode];Reveal
Section titled “Reveal”type Reveal = "nothing" | "score" | "answers";What a submit returns to the student:
nothing: just the confirmation (results released later by the host);score: score and verdicts;answers: score, verdicts and the solution.
ScoringRule
Section titled “ScoringRule”type ScoringRule = "all-correct" | "per-slot" | "proportional";Scoring groups. Every graded component forms one group by default (id = the component's opaque id), or one per
part when its definition grades it in parts (ComponentDefinition.groups, a crossword's words), where a slot may
sit in several groups.
Rules (n = slots in the group, c = correct slots, P = points):
all-correct: max P; score P when c = n, else 0. Feedback never shows which slot is wrong: a wrong group shows only its verdict, a right one marks every answered slot right too, unless it grades one part of its component.per-slot: max P x n; score P x c.proportional: max P; score P x c / n (exact, not rounded).
Selection slots (flags, e.g. options of a multiple-answer choice): an unselected flag gets no verdict, and a group
whose flags are all unselected scores 0 with verdict empty.
Severity
Section titled “Severity”type Severity = "error" | "warning";Validation issues. Codes + params, never English sentences: hosts render them with message catalogs
(<namespace> of the reporting component, or astl.engine for document-level codes).
SlotId
Section titled “SlotId”type SlotId = string;Answers on the wire. Strings only, so any backend in any language can store and grade them.
- A missing key or
''means unanswered. - Text and number slots: what the student typed.
- Choice slots: the picked value, an opaque option id or a fixed public value (
true/falseof a statement). - Flag slots (selection):
'true'when selected. - Open slots: what the student wrote, kept for a teacher.
SlotVerdict
Section titled “SlotVerdict”type SlotVerdict = "correct" | "incorrect";Solution
Section titled “Solution”type Solution = Readonly<Record<SlotId, string>>;Correct answers by slot, shown when the policy reveals them. '' entries are omitted.
SourceCompiler
Section titled “SourceCompiler”type SourceCompiler = (source, context) => Promise<{ checker: Checker; view: string;}>;Turns source HTML (with answers) into a view and a checker for it, for <astl-player> light-DOM sources. Registered
by bundles that ship the engine (the HTML-with-answers mode); the player itself never holds answer logic.
lang: content language of the source (filled from the page when the<astl-doc>has none);locale: UI locale of the asking player, for the messages of a failed compile. A failed compile throws; the Error message (plain text, one issue per line) is shown to the author.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
source |
string |
context |
{ lang: string; locale: string; } |
context.lang |
string |
context.locale |
string |
Returns
Section titled “Returns”Promise<{
checker: Checker;
view: string;
}>
StyleScope
Section titled “StyleScope”type StyleScope = "document" | "component";document: the whole exercise (the player's canvas and chrome). component: one element and its subtree.
TokenOverrides
Section titled “TokenOverrides”type TokenOverrides = Readonly<Record<string, string>>;Token values by token name without the --astl- prefix, e.g. { accent: '#7a3ff2', 'radius-m': '1rem' }.
Translate
Section titled “Translate”type Translate = (key, params?) => string;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key |
string |
params? |
MessageParams |
Returns
Section titled “Returns”string
UrlPolicy
Section titled “UrlPolicy”type UrlPolicy = (url, context) => boolean;Decides whether a URL in content may stay: asked with the element's tag and attribute (img and src for a
picture in text, a component's tag and its url attribute). Only true keeps it: engines, players and the
authoring kit treat a throw or any other answer as no (strictUrlPolicy). Default (isSafeUrl): absolute
http:, https: and mailto: URLs.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
url |
string |
context |
{ attribute: string; tag: string; } |
context.attribute |
string |
context.tag |
string |
Returns
Section titled “Returns”boolean
Visibility
Section titled “Visibility”type Visibility = "public" | "private" | "derived";public: kept in the view as written.private: kept only in the answer key / never leaves the server.derived: computed by the definition'stoView; authors cannot write it.
Variables
Section titled “Variables”BADGE_ATTRIBUTES
Section titled “BADGE_ATTRIBUTES”const BADGE_ATTRIBUTES: readonly string[];The look of a badge in a view; besides them it keeps lang, dir and style, as any element of rich text.
BADGE_FILLS
Section titled “BADGE_FILLS”const BADGE_FILLS: readonly ["solid", "soft", "outline"];BADGE_SHAPES
Section titled “BADGE_SHAPES”const BADGE_SHAPES: readonly ["pill", "circle", "square", "shield", "tag"];BADGE_TAG
Section titled “BADGE_TAG”const BADGE_TAG: "astl-badge" = 'astl-badge';A badge: a number or a short text in a shape (a lesson number in a shield, a level pill, a tag). Inline, in text as
an inline component sits there, outside the children of components and never in a link or another badge; a rich
block's content (a callout's) may hold one. It holds plain text, at most MAX_BADGE_LENGTH characters
(BADGE_TOO_LONG, a warning). Its id (required) is for editors: no view holds it. Its look: shape (default
pill), fill (default solid) and palette, 1 to 8 (the author palette; without it the look's accent).
BLOCK_TAGS
Section titled “BLOCK_TAGS”const BLOCK_TAGS: ReadonlySet<string>;BOX_ATTRIBUTES
Section titled “BOX_ATTRIBUTES”const BOX_ATTRIBUTES: readonly string[];The look of a frame in a view; besides them it keeps lang, dir and style, as any element of rich text.
BOX_ICONS
Section titled “BOX_ICONS”const BOX_ICONS: readonly ["info", "tip", "warning", "book", "pencil", "checklist", "star"];BOX_LABEL_TAG
Section titled “BOX_LABEL_TAG”const BOX_LABEL_TAG: "astl-box-tag" = 'astl-box-tag';BOX_TAG
Section titled “BOX_TAG”const BOX_TAG: "astl-box" = 'astl-box';A frame: a box that groups text and components under an optional title, directly on a page, in the document or in a
column, never in another frame (BOX_NESTED). astl-box-title (optional, first) holds inline text (formatting, a
badge, a picture, whose alt then names the frame); astl-box-tag (optional, right after the title or first) a
second, outlined part of it; then content as a page holds it: blocks, figures, block components, Check elements, and
a layout unless the frame stands in a column (two layout levels at most). Its questions grade as they would outside
it. Its look: title-place, variant, icon and palette 1 to 8.
BOX_TITLE_PLACES
Section titled “BOX_TITLE_PLACES”const BOX_TITLE_PLACES: readonly ["inside", "border", "pill", "tab"];Where the title stands: at the top inside (default), on the top border, in a pill across it, in a tab above it.
BOX_TITLE_TAG
Section titled “BOX_TITLE_TAG”const BOX_TITLE_TAG: "astl-box-title" = 'astl-box-title';BOX_VARIANTS
Section titled “BOX_VARIANTS”const BOX_VARIANTS: readonly ["outline", "soft", "card"];A border (default), a tint with no border, or a card with a soft shadow (for tinted pages).
BUILT_IN_PREFIX
Section titled “BUILT_IN_PREFIX”const BUILT_IN_PREFIX: "astl-" = 'astl-';Prefix reserved for built-in Astrolabe elements.
CAPTION_TAG
Section titled “CAPTION_TAG”const CAPTION_TAG: "figcaption" = 'figcaption';CHECK_ATTRIBUTES
Section titled “CHECK_ATTRIBUTES”const CHECK_ATTRIBUTES: readonly string[];The attributes of a check, in sources and views (with lang and dir); in a view id and for are opaque.
CHECK_FOR_ATTRIBUTE
Section titled “CHECK_FOR_ATTRIBUTE”const CHECK_FOR_ATTRIBUTE: "for" = 'for';CHECK_LABEL_ATTRIBUTE
Section titled “CHECK_LABEL_ATTRIBUTE”const CHECK_LABEL_ATTRIBUTE: "label" = 'label';CHECK_TAG
Section titled “CHECK_TAG”const CHECK_TAG: "astl-check" = 'astl-check';CLASS_ATTRIBUTE
Section titled “CLASS_ATTRIBUTE”const CLASS_ATTRIBUTE: "class" = 'class';A source attribute naming named styles (<astl-style name>); no view ever holds it.
COLUMN_TAG
Section titled “COLUMN_TAG”const COLUMN_TAG: "astl-column" = 'astl-column';One column of a layout: blocks, figures and block components, as a page holds them.
COLUMNS_TAG
Section titled “COLUMNS_TAG”const COLUMNS_TAG: "astl-columns" = 'astl-columns';A layout: 2 to 4 columns directly on a page or in the document, wrapping by themselves; no nesting.
COMMON_ATTRIBUTES
Section titled “COMMON_ATTRIBUTES”const COMMON_ATTRIBUTES: readonly AttributeSpec[];Attributes every component accepts. scoring and points only apply to graded types.
CONTENT_ATTRIBUTES
Section titled “CONTENT_ATTRIBUTES”const CONTENT_ATTRIBUTES: ReadonlySet<string>;Attributes allowed on every content element. style goes through the allow-list of declarations.ts at each side
that reads it. class is not here on purpose: it exists in sources only, and the engine inlines it.
DEFAULT_DOC_KIND
Section titled “DEFAULT_DOC_KIND”const DEFAULT_DOC_KIND: DocKind = 'exercise';DEFAULT_PROFILE
Section titled “DEFAULT_PROFILE”const DEFAULT_PROFILE: NormalisationProfile;DOC_ATTRIBUTES
Section titled “DOC_ATTRIBUTES”const DOC_ATTRIBUTES: readonly string[];Attributes the document and page elements may carry in a view.
DOC_KINDS
Section titled “DOC_KINDS”const DOC_KINDS: readonly ["exercise", "book"];What a document is, its kind: how it shows, never how it grades. An exercise (the default when absent) shows one
page at a time; a book shows two pages side by side (1-2, 3-4, ...) where the player is wide enough, turning them
a spread at a time. Practice and test are not kinds: they are policies over any kind (policy.ts).
DOC_TAG
Section titled “DOC_TAG”const DOC_TAG: "astl-doc" = 'astl-doc';ELEMENT_TAG_PATTERN
Section titled “ELEMENT_TAG_PATTERN”const ELEMENT_TAG_PATTERN: RegExp;Custom element names that components may use (HTML custom element rules, lowercase ASCII).
ENGINE_NAMESPACE
Section titled “ENGINE_NAMESPACE”const ENGINE_NAMESPACE: "astl.engine" = 'astl.engine';i18n namespace of document-level issues reported by the engine.
EngineIssue
Section titled “EngineIssue”const EngineIssue: object;Document-level issue codes. Component codes are listed in each manifest's issues.
Type Declaration
Section titled “Type Declaration”EXPLANATION_TAG
Section titled “EXPLANATION_TAG”const EXPLANATION_TAG: "astl-explanation" = 'astl-explanation';Why the answer is what it is; at most one per interaction or page.
FEEDBACK_TAG
Section titled “FEEDBACK_TAG”const FEEDBACK_TAG: "astl-feedback" = 'astl-feedback';The text for one verdict, picked by when; at most one per when.
FEEDBACK_VARIANTS
Section titled “FEEDBACK_VARIANTS”const FEEDBACK_VARIANTS: readonly FeedbackVariant[];FIGURE_TAG
Section titled “FIGURE_TAG”const FIGURE_TAG: "figure" = 'figure';A picture with a caption: a block directly in a page (or the document), holding exactly one img and at most one
figcaption (rich inline text), nothing else. A figcaption anywhere else is unwrapped.
FLAG_SELECTED
Section titled “FLAG_SELECTED”const FLAG_SELECTED: "true" = 'true';FORMAT_VERSION
Section titled “FORMAT_VERSION”const FORMAT_VERSION: 1 = 1;Current content format. Written as format="1" on <astl-doc> in sources and views.
HELP_ATTRIBUTES
Section titled “HELP_ATTRIBUTES”const HELP_ATTRIBUTES: readonly string[];The view attributes of ElementHelp, on a graded component or a page: hints="0 0.25" (the costs, space
separated), hint-points="0 0.5" (what each takes off in points), explanation (present when there is one) and
feedback="correct incorrect" (the variants with a text, in FEEDBACK_VARIANTS order). Only those with something
to say are written; sources never carry them. The engine writes them (compile), the player reads them.
HELP_TAGS
Section titled “HELP_TAGS”const HELP_TAGS: ReadonlySet<string>;HINT_TAG
Section titled “HINT_TAG”const HINT_TAG: "astl-hint" = 'astl-hint';One hint, rich content; hints come in source order. cost: the fraction 0..1 of the points it takes off.
icuFormatter
Section titled “icuFormatter”const icuFormatter: MessageFormatter;The default MessageFormatter. A message with a syntax error renders as its raw text instead of throwing.
INERT_STYLE
Section titled “INERT_STYLE”const INERT_STYLE: "data-astl-style" = 'data-astl-style';What inertStyles renames style to.
INLINE_TAGS
Section titled “INLINE_TAGS”const INLINE_TAGS: ReadonlySet<string>;img is a picture: inline, so it can sit in text, prompts, options and cards.
INSTRUCTION_TAG
Section titled “INSTRUCTION_TAG”const INSTRUCTION_TAG: "astl-instruction" = 'astl-instruction';JSON_MEDIA_TYPE
Section titled “JSON_MEDIA_TYPE”const JSON_MEDIA_TYPE: "application/json" = 'application/json';KEY_FORMAT_VERSION
Section titled “KEY_FORMAT_VERSION”const KEY_FORMAT_VERSION: 1 = 1;LANGUAGE_TAG_PATTERN
Section titled “LANGUAGE_TAG_PATTERN”const LANGUAGE_TAG_PATTERN: RegExp;Loose BCP 47 check: pl, pl-PL, zh-Hant-TW, sr-Latn.
MAX_ANSWER_COUNT
Section titled “MAX_ANSWER_COUNT”const MAX_ANSWER_COUNT: 2000 = 2000;Most slots one request may carry.
MAX_ANSWER_LENGTH
Section titled “MAX_ANSWER_LENGTH”const MAX_ANSWER_LENGTH: 500 = 500;Longest accepted answer per slot, in Unicode code points, for every slot kind but open. Longer values count as
unanswered (engine, servers, protocol 1).
MAX_ATTRIBUTES_PER_ELEMENT
Section titled “MAX_ATTRIBUTES_PER_ELEMENT”const MAX_ATTRIBUTES_PER_ELEMENT: 256 = 256;Most attributes one element may carry in a source (beyond it: SOURCE_TOO_COMPLEX, checked before parsing).
MAX_BADGE_LENGTH
Section titled “MAX_BADGE_LENGTH”const MAX_BADGE_LENGTH: 24 = 24;MAX_BADGE_PALETTE
Section titled “MAX_BADGE_PALETTE”const MAX_BADGE_PALETTE: 8 = 8;MAX_COLUMNS
Section titled “MAX_COLUMNS”const MAX_COLUMNS: 4 = 4;MAX_NESTING_DEPTH
Section titled “MAX_NESTING_DEPTH”const MAX_NESTING_DEPTH: 100 = 100;Deepest element nesting a source may have (beyond it: SOURCE_TOO_DEEP).
MAX_OPEN_ANSWER_LENGTH
Section titled “MAX_OPEN_ANSWER_LENGTH”const MAX_OPEN_ANSWER_LENGTH: 2000 = 2000;Longest open answer, in Unicode code points (so Polish and English letters count one each).
MAX_REQUEST_BYTES
Section titled “MAX_REQUEST_BYTES”const MAX_REQUEST_BYTES: number;Largest request body servers should accept, in bytes.
MAX_SOURCE_LENGTH
Section titled “MAX_SOURCE_LENGTH”const MAX_SOURCE_LENGTH: 1000000 = 1_000_000;Largest accepted source, in UTF-16 code units.
MAX_TABLE_COLUMNS
Section titled “MAX_TABLE_COLUMNS”const MAX_TABLE_COLUMNS: 12 = 12;MAX_TABLE_ROWS
Section titled “MAX_TABLE_ROWS”const MAX_TABLE_ROWS: 50 = 50;MAX_TASK_LABELS
Section titled “MAX_TASK_LABELS”const MAX_TASK_LABELS: 3 = 3;MAX_TASK_LEVEL
Section titled “MAX_TASK_LEVEL”const MAX_TASK_LEVEL: 3 = 3;MIN_COLUMNS
Section titled “MIN_COLUMNS”const MIN_COLUMNS: 2 = 2;OPAQUE_ID_PATTERN
Section titled “OPAQUE_ID_PATTERN”const OPAQUE_ID_PATTERN: RegExp;Opaque ids in views: k + 16 lowercase base32 characters (80 bits of an HMAC-SHA-256).
OPEN_SLOT_KIND
Section titled “OPEN_SLOT_KIND”const OPEN_SLOT_KIND: "open" = 'open';The built-in slot kind of open answers: stored with the attempt for a teacher, never graded.
PAGE_ATTRIBUTES
Section titled “PAGE_ATTRIBUTES”const PAGE_ATTRIBUTES: readonly string[];PAGE_CHECK_ATTRIBUTE
Section titled “PAGE_CHECK_ATTRIBUTE”const PAGE_CHECK_ATTRIBUTE: "check" = 'check';check (boolean): in practice the page has a Check of its own ("Check this page"), which checks all its questions at
once and then shows the page's help (its hints stay on offer from the start). A page with help and without it gets
that Check all the same, and a warning (PAGE_HELP_UNCHECKED).
PAGE_TAG
Section titled “PAGE_TAG”const PAGE_TAG: "astl-page" = 'astl-page';PlayerEvent
Section titled “PlayerEvent”const PlayerEvent: object;DOM events. All bubble and are composed (they cross shadow roots).
Type Declaration
Section titled “Type Declaration”PRACTICE_POLICY
Section titled “PRACTICE_POLICY”const PRACTICE_POLICY: AttemptPolicy;PROBLEM_MEDIA_TYPE
Section titled “PROBLEM_MEDIA_TYPE”const PROBLEM_MEDIA_TYPE: "application/problem+json" = 'application/problem+json';ProblemCode
Section titled “ProblemCode”const ProblemCode: object;Type Declaration
Section titled “Type Declaration”PROTOCOL_VERSION
Section titled “PROTOCOL_VERSION”const PROTOCOL_VERSION: 1 = 1;Grading protocol over HTTP. Any backend in any language can implement it:
POST {endpoint}/check body CheckRequest -> 200 CheckResponse POST {endpoint}/submit body SubmitRequest -> 200 SubmitResponse POST {endpoint}/hint body HintRequest -> 200 HintResponse
{endpoint} identifies one attempt (e.g. /api/attempts/123); how it is authorised is up to the host
(cookie, bearer token). Errors are application/problem+json (RFC 9457) with a code from ProblemCode.
ProtocolPath
Section titled “ProtocolPath”const ProtocolPath: object;Type Declaration
Section titled “Type Declaration”| Name | Type |
|---|---|
check |
"check" |
hint |
"hint" |
submit |
"submit" |
REMOVED_WITH_CONTENT
Section titled “REMOVED_WITH_CONTENT”const REMOVED_WITH_CONTENT: ReadonlySet<string>;Dropped together with their content: active content, embeds, media and form controls.
RULE_TAG
Section titled “RULE_TAG”const RULE_TAG: "hr" = 'hr';A horizontal rule: a block that holds nothing, read as a separator, wherever a paragraph may be. It is drawn as its
top border, so an author's border styles (colour, style, width), width and margin are its look.
SCORING_ATTRIBUTES
Section titled “SCORING_ATTRIBUTES”const SCORING_ATTRIBUTES: readonly AttributeSpec[];SCORING_RULES
Section titled “SCORING_RULES”const SCORING_RULES: readonly ScoringRule[];SNAPSHOT_FORMAT
Section titled “SNAPSHOT_FORMAT”const SNAPSHOT_FORMAT: 1 = 1;SOURCE_ID_PATTERN
Section titled “SOURCE_ID_PATTERN”const SOURCE_ID_PATTERN: RegExp;Author ids: a letter, then letters, digits, _ or -; at most 64 characters. Unique within one document.
STYLE_TAG
Section titled “STYLE_TAG”const STYLE_TAG: "astl-style" = 'astl-style';A rule, first in <astl-doc>: name and label (a named style, applied with class) or for (every element of
that tag), with its declarations in style. Sources only: the engine inlines it.
STYLE_TEMPLATE_ATTRIBUTE
Section titled “STYLE_TEMPLATE_ATTRIBUTE”const STYLE_TEMPLATE_ATTRIBUTE: "style-template" = 'style-template';The attribute that picks a template, on <astl-doc> and on every component.
STYLE_TEMPLATE_NAME
Section titled “STYLE_TEMPLATE_NAME”const STYLE_TEMPLATE_NAME: RegExp;Template names: lowercase kebab-case, 1 to 40 characters, starting with a letter.
SUBTASK_LEVELS
Section titled “SUBTASK_LEVELS”const SUBTASK_LEVELS: readonly ["A", "B", "C", "D"];SUBTASK_TAG
Section titled “SUBTASK_TAG”const SUBTASK_TAG: "astl-subtask" = 'astl-subtask';SUPPORTED_FORMATS
Section titled “SUPPORTED_FORMATS”const SUPPORTED_FORMATS: readonly number[];TABLE_BODY_TAG
Section titled “TABLE_BODY_TAG”const TABLE_BODY_TAG: "tbody" = 'tbody';TABLE_CAPTION_TAG
Section titled “TABLE_CAPTION_TAG”const TABLE_CAPTION_TAG: "caption" = 'caption';TABLE_CELL_TAG
Section titled “TABLE_CELL_TAG”const TABLE_CELL_TAG: "td" = 'td';TABLE_HEAD_TAG
Section titled “TABLE_HEAD_TAG”const TABLE_HEAD_TAG: "thead" = 'thead';TABLE_HEADER_CELL_TAG
Section titled “TABLE_HEADER_CELL_TAG”const TABLE_HEADER_CELL_TAG: "th" = 'th';TABLE_ROW_TAG
Section titled “TABLE_ROW_TAG”const TABLE_ROW_TAG: "tr" = 'tr';TABLE_SCOPES
Section titled “TABLE_SCOPES”const TABLE_SCOPES: readonly ["row", "col", "rowgroup", "colgroup"];What a header cell heads: scope.
TABLE_TAG
Section titled “TABLE_TAG”const TABLE_TAG: "table" = 'table';A table: a block wherever a figure may be (a page, the document, a column, a frame, a task, a rich block, help). Its
caption (optional, first) holds rich inline text; then rows (tr) in a head (thead, optional, once, before the
bodies) and bodies (tbody), or directly in the table as HTML allows; a row holds cells, th (a header: scope)
and td, both with colspan and rowspan. Cells hold inline content: text, formatting, pictures and inline
components. Every row covers the same columns, spans included, and no span reaches past the rows of its part
(TABLE_INVALID); at most MAX_TABLE_COLUMNS columns and MAX_TABLE_ROWS rows (TABLE_TOO_LARGE).
TABLE_TAGS
Section titled “TABLE_TAGS”const TABLE_TAGS: ReadonlySet<string>;Every tag of a table, the table's own included.
TAG_ATTRIBUTES
Section titled “TAG_ATTRIBUTES”const TAG_ATTRIBUTES: Readonly<Record<string, readonly string[]>>;Extra attributes allowed on specific rich-text elements. A picture: src and alt (required; alt="" marks
decoration), width and height (positive integers, so the layout does not jump while it loads). A badge: its look.
TASK_ATTRIBUTES
Section titled “TASK_ATTRIBUTES”const TASK_ATTRIBUTES: readonly string[];TASK_LABEL_ICONS
Section titled “TASK_LABEL_ICONS”const TASK_LABEL_ICONS: readonly ["pair", "group", "notebook"];TASK_LABEL_TAG
Section titled “TASK_LABEL_TAG”const TASK_LABEL_TAG: "astl-tag" = 'astl-tag';TASK_NUMBERING_ATTRIBUTE
Section titled “TASK_NUMBERING_ATTRIBUTE”const TASK_NUMBERING_ATTRIBUTE: "task-numbering" = 'task-numbering';TASK_NUMBERINGS
Section titled “TASK_NUMBERINGS”const TASK_NUMBERINGS: readonly ["page", "doc", "none"];How the tasks of a document are numbered (task-numbering on astl-doc): on each page anew, through it, or not.
TASK_TAG
Section titled “TASK_TAG”const TASK_TAG: "astl-task" = 'astl-task';A task: a numbered exercise of a page, directly on a page, in the document, in a column or in a frame, never in
another task (TASK_NESTED). astl-instruction (optional, first) holds inline text (formatting, a badge, a picture;
no component); up to MAX_TASK_LABELS astl-tags after it, each a short label with an optional icon; then content
as a page holds it, astl-subtasks among it (each a lettered part, a page's content in it, level A to D). Its id
is required: its Check (check, one for all its graded questions) is addressed by it. Its number comes from the
document's task-numbering (page, the default, doc or none), or its own number; the view always says the
number it shows. level 1 to MAX_TASK_LEVEL is a difficulty mark; palette 1 to 8 colours the number.
TEST_POLICY
Section titled “TEST_POLICY”const TEST_POLICY: AttemptPolicy;URL_ATTRIBUTES
Section titled “URL_ATTRIBUTES”const URL_ATTRIBUTES: Readonly<Record<string, string>>;The attribute of a rich-text element that holds a URL, checked by the URL policy.
Functions
Section titled “Functions”allAttributes()
Section titled “allAttributes()”function allAttributes(manifest): readonly AttributeSpec[];Every attribute an element of this type may carry, common ones first.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
manifest |
ComponentManifest |
Returns
Section titled “Returns”readonly AttributeSpec[]
checkCatalog()
Section titled “checkCatalog()”function checkCatalog(catalog): CatalogProblem[];Problems of catalog alone (syntax and plural coverage).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
catalog |
MessageCatalog |
Returns
Section titled “Returns”checkFor()
Section titled “checkFor()”function checkFor(value): string[];The ids a for names, in order, each once.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
string | null | undefined |
Returns
Section titled “Returns”string[]
checkNodes()
Section titled “checkNodes()”function checkNodes<T>(content, tree): T[];The Check elements of a page's content (or a document's without pages) in the order checkParts meets them, so the
nth is the one planChecks gives the nth targets: directly in the content, in its layouts' columns, in its frames
and in its tasks and their sub-tasks, and a task with a Check of its own (taskCheck) after what it holds.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
content |
readonly T[] |
tree |
Pick<CheckTree<T>, "tag" | "children" | "taskCheck"> |
Returns
Section titled “Returns”T[]
checkParts()
Section titled “checkParts()”function checkParts<T>(content, tree): CheckPart[];A page's content (or a document's without pages) as the parts of the check rule, in reading order: a layout's
columns in turn, each between edges, and a frame's content between edges too (its title holds no question); so is a
task's, each of its sub-tasks between edges, then its own Check when it has one (taskCheck), which names every
graded question in the task. What lies between block components, checks, headings and edges is one run of text: its
graded inline questions (none inside a component); a heading opens the next one.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
content |
readonly T[] |
tree |
CheckTree<T> |
Returns
Section titled “Returns”childElements()
Section titled “childElements()”function childElements(node, tag?): ElementNode[];Element children with the given tag, in order.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
node |
ElementNode |
tag? |
string |
Returns
Section titled “Returns”childTagConflict()
Section titled “childTagConflict()”function childTagConflict(manifests): | { components: readonly [string, string]; tag: string;} | null;A child tag two of the manifests declare with specs that differ (see sameChildSpec), or null when none does.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
manifests |
readonly ComponentManifest[] |
Returns
Section titled “Returns”| {
components: readonly [string, string];
tag: string;
}
| null
compareCatalogs()
Section titled “compareCatalogs()”function compareCatalogs(source, translation): CatalogProblem[];Problems of a translation compared with its source catalog (same namespace).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
source |
MessageCatalog |
translation |
MessageCatalog |
Returns
Section titled “Returns”createI18n()
Section titled “createI18n()”function createI18n(options): I18n;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
CreateI18nOptions |
Returns
Section titled “Returns”directionOf()
Section titled “directionOf()”function directionOf(lang): Direction;Writing direction for a BCP 47 tag, e.g. he -> rtl, pl-PL -> ltr. Script subtags win (az-Arab).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
lang |
string |
Returns
Section titled “Returns”element()
Section titled “element()”function element( tag, attrs?, children?): ElementNode;Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
tag |
string |
undefined |
attrs? |
Readonly<Record<string, string>> |
{} |
children? |
readonly Node[] |
[] |
Returns
Section titled “Returns”fitsAnswer()
Section titled “fitsAnswer()”function fitsAnswer(value, kind?): boolean;Whether value is within the length limit of a slot of kind, counted in Unicode code points.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
string |
kind? |
string |
Returns
Section titled “Returns”boolean
groupMax()
Section titled “groupMax()”function groupMax( rule, points, slotCount): number;Group maximum for a rule.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
rule |
ScoringRule |
points |
number |
slotCount |
number |
Returns
Section titled “Returns”number
hasErrors()
Section titled “hasErrors()”function hasErrors(issues): boolean;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
issues |
readonly Issue[] |
Returns
Section titled “Returns”boolean
helpPolicy()
Section titled “helpPolicy()”function helpPolicy(policy): HelpPolicy;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
policy |
AttemptPolicy |
Returns
Section titled “Returns”inertStyles()
Section titled “inertStyles()”function inertStyles(html): string;The HTML with every style attribute under another name, for parsing. Under a strict CSP any HTML parser reports a
style attribute as a violation the moment it meets one, in a template or a DOMParser document too (seen in Chromium
on all of them), though nothing in those documents is ever drawn. Only start tags change, never text or values.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
html |
string |
Returns
Section titled “Returns”string
isAnswerKey()
Section titled “isAnswerKey()”function isAnswerKey(value): value is AnswerKey;Narrow check for keys loaded from storage. Full validation happens in the engine.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
unknown |
Returns
Section titled “Returns”value is AnswerKey
isAnswers()
Section titled “isAnswers()”function isAnswers(value): value is Readonly<Record<string, string>>;Type guard for untrusted input (request bodies, storage).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
unknown |
Returns
Section titled “Returns”value is Readonly<Record<string, string>>
isAttemptPolicy()
Section titled “isAttemptPolicy()”function isAttemptPolicy(value): value is AttemptPolicy;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
unknown |
Returns
Section titled “Returns”value is AttemptPolicy
isCheckable()
Section titled “isCheckable()”function isCheckable(manifest): boolean;A graded question: what a check can check (a graded type with something to answer).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
manifest |
ComponentManifest |
Returns
Section titled “Returns”boolean
isElement()
Section titled “isElement()”function isElement(node, tag?): node is ElementNode;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
node |
Node | undefined |
tag? |
string |
Returns
Section titled “Returns”node is ElementNode
isOpaqueId()
Section titled “isOpaqueId()”function isOpaqueId(value): boolean;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
string |
Returns
Section titled “Returns”boolean
isProblemDetails()
Section titled “isProblemDetails()”function isProblemDetails(value): value is ProblemDetails;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
unknown |
Returns
Section titled “Returns”value is ProblemDetails
isSafeUrl()
Section titled “isSafeUrl()”function isSafeUrl(url): boolean;The default URL policy: absolute http:, https: and mailto: URLs (tabs and newlines ignored, as browsers do).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
url |
string |
Returns
Section titled “Returns”boolean
isSnapshot()
Section titled “isSnapshot()”function isSnapshot(value): value is Snapshot;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
unknown |
Returns
Section titled “Returns”value is Snapshot
isSourceId()
Section titled “isSourceId()”function isSourceId(value): boolean;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
string |
Returns
Section titled “Returns”boolean
isStyleTemplate()
Section titled “isStyleTemplate()”function isStyleTemplate(value): value is StyleTemplate;Whether value has the shape of a StyleTemplate: a valid name, a positive version, one or both scopes, string tags,
a namespace, and records of strings for tokens and parts. Registries use it for hosts without type checking.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
unknown |
Returns
Section titled “Returns”value is StyleTemplate
maxAnswerLength()
Section titled “maxAnswerLength()”function maxAnswerLength(kind): number;The longest answer a slot of kind accepts, in code points: 2000 for open slots, 500 for the others.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
kind |
string | undefined |
Returns
Section titled “Returns”number
messageParams()
Section titled “messageParams()”function messageParams(parts): Set<string>;Names of all arguments a message uses, including plural and select selectors.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
parts |
readonly MessagePart[] |
Returns
Section titled “Returns”Set<string>
negotiateLocale()
Section titled “negotiateLocale()”function negotiateLocale( requested, available, fallback): string;BCP 47 lookup (RFC 4647 section 3.4, extended): for each requested tag try the tag, then shorter prefixes
(pl-PL -> pl), then any available tag with the same language (pt -> pt-BR). Case-insensitive.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
requested |
readonly string[] |
available |
readonly string[] |
fallback |
string |
Returns
Section titled “Returns”string
parseMessage()
Section titled “parseMessage()”function parseMessage(message): MessagePart[];Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message |
string |
Returns
Section titled “Returns”planChecks()
Section titled “planChecks()”function planChecks(parts): CheckPlan;The one rule for which questions a check takes, shared by the engine (what a view's checks hold), the authoring kit (its outline, the editor's tags and cards) and the player (where it checks several questions at once).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
parts |
readonly CheckPart[] |
Returns
Section titled “Returns”pluralCategories()
Section titled “pluralCategories()”function pluralCategories(locale, ordinal?): readonly string[];Plural categories a locale needs, e.g. pl -> one, few, many, other.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
locale |
string |
undefined |
ordinal? |
boolean |
false |
Returns
Section titled “Returns”readonly string[]
roundScore()
Section titled “roundScore()”function roundScore(value): number;Rounds a score for display: at most 2 decimals, no trailing zeros.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
number |
Returns
Section titled “Returns”number
sameChildSpec()
Section titled “sameChildSpec()”function sameChildSpec(a, b): boolean;Whether two child specs may share a tag: the same visibility and attributes (in any order), so the tag carries the
same data and keeps the same things private in every type that declares it (astl-prompt, astl-option). Content
and counts are each type's own: a select's options are plain text, a choice's options rich.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
a |
ChildSpec |
b |
ChildSpec |
Returns
Section titled “Returns”boolean
strictUrlPolicy()
Section titled “strictUrlPolicy()”function strictUrlPolicy(policy): UrlPolicy;A host's URL policy as engines, players and the authoring kit use it: a URL passes only when the policy returns
true. A policy that throws, or returns anything else (the Promise of an async function, say), blocks the URL.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
policy |
UrlPolicy |
Returns
Section titled “Returns”text()
Section titled “text()”function text(value): TextNode;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
string |
Returns
Section titled “Returns”textContent()
Section titled “textContent()”function textContent(node): string;Concatenated text of a subtree, like DOM textContent.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
node |
Node |
Returns
Section titled “Returns”string
variantAttribute()
Section titled “variantAttribute()”function variantAttribute(variants): AttributeSpec;The variant attribute of a type with variants: an enum of the manifest's variant names.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
variants |
VariantSpec |