@astl/core 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/LICENSE +202 -0
- package/README.md +38 -0
- package/dist/answers.d.ts +29 -0
- package/dist/answers.d.ts.map +1 -0
- package/dist/answers.js +40 -0
- package/dist/answers.js.map +1 -0
- package/dist/ast.d.ts +25 -0
- package/dist/ast.d.ts.map +1 -0
- package/dist/ast.js +27 -0
- package/dist/ast.js.map +1 -0
- package/dist/authoring.d.ts +451 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +2 -0
- package/dist/authoring.js.map +1 -0
- package/dist/checker.d.ts +78 -0
- package/dist/checker.d.ts.map +1 -0
- package/dist/checker.js +10 -0
- package/dist/checker.js.map +1 -0
- package/dist/compiled.d.ts +94 -0
- package/dist/compiled.d.ts.map +1 -0
- package/dist/compiled.js +16 -0
- package/dist/compiled.js.map +1 -0
- package/dist/content.d.ts +72 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +128 -0
- package/dist/content.js.map +1 -0
- package/dist/declarations.d.ts +52 -0
- package/dist/declarations.d.ts.map +1 -0
- package/dist/declarations.js +358 -0
- package/dist/declarations.js.map +1 -0
- package/dist/definition.d.ts +106 -0
- package/dist/definition.d.ts.map +1 -0
- package/dist/definition.js +2 -0
- package/dist/definition.js.map +1 -0
- package/dist/engine.d.ts +95 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +2 -0
- package/dist/engine.js.map +1 -0
- package/dist/format.d.ts +29 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +55 -0
- package/dist/format.js.map +1 -0
- package/dist/help.d.ts +38 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +22 -0
- package/dist/help.js.map +1 -0
- package/dist/i18n/check.d.ts +11 -0
- package/dist/i18n/check.d.ts.map +1 -0
- package/dist/i18n/check.js +64 -0
- package/dist/i18n/check.js.map +1 -0
- package/dist/i18n/format.d.ts +40 -0
- package/dist/i18n/format.d.ts.map +1 -0
- package/dist/i18n/format.js +280 -0
- package/dist/i18n/format.js.map +1 -0
- package/dist/i18n/i18n.d.ts +14 -0
- package/dist/i18n/i18n.d.ts.map +1 -0
- package/dist/i18n/i18n.js +82 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/dist/i18n/types.d.ts +31 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +7 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/issues.d.ts +98 -0
- package/dist/issues.d.ts.map +1 -0
- package/dist/issues.js +74 -0
- package/dist/issues.js.map +1 -0
- package/dist/json.d.ts +7 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +2 -0
- package/dist/json.js.map +1 -0
- package/dist/manifest.d.ts +135 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +63 -0
- package/dist/manifest.js.map +1 -0
- package/dist/player.d.ts +129 -0
- package/dist/player.d.ts.map +1 -0
- package/dist/player.js +18 -0
- package/dist/player.js.map +1 -0
- package/dist/policy.d.ts +53 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +55 -0
- package/dist/policy.js.map +1 -0
- package/dist/protocol.d.ts +54 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +51 -0
- package/dist/protocol.js.map +1 -0
- package/dist/result.d.ts +44 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +5 -0
- package/dist/result.js.map +1 -0
- package/dist/scoring.d.ts +27 -0
- package/dist/scoring.d.ts.map +1 -0
- package/dist/scoring.js +6 -0
- package/dist/scoring.js.map +1 -0
- package/dist/slots.d.ts +47 -0
- package/dist/slots.d.ts.map +1 -0
- package/dist/slots.js +9 -0
- package/dist/slots.js.map +1 -0
- package/dist/snapshot.d.ts +23 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +22 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/style.d.ts +51 -0
- package/dist/style.d.ts.map +1 -0
- package/dist/style.js +36 -0
- package/dist/style.js.map +1 -0
- package/package.json +40 -4
- package/src/answers.ts +52 -0
- package/src/ast.ts +49 -0
- package/src/authoring.ts +475 -0
- package/src/checker.ts +91 -0
- package/src/compiled.ts +115 -0
- package/src/content.ts +156 -0
- package/src/declarations.ts +427 -0
- package/src/definition.ts +104 -0
- package/src/engine.ts +98 -0
- package/src/format.ts +67 -0
- package/src/help.ts +41 -0
- package/src/i18n/check.ts +67 -0
- package/src/i18n/format.ts +318 -0
- package/src/i18n/i18n.ts +92 -0
- package/src/i18n/types.ts +35 -0
- package/src/index.ts +201 -0
- package/src/issues.ts +107 -0
- package/src/json.ts +6 -0
- package/src/manifest.ts +193 -0
- package/src/player.ts +145 -0
- package/src/policy.ts +117 -0
- package/src/protocol.ts +65 -0
- package/src/result.ts +53 -0
- package/src/scoring.ts +31 -0
- package/src/slots.ts +57 -0
- package/src/snapshot.ts +40 -0
- package/src/style.ts +89 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { icuFormatter } from './format.js';
|
|
2
|
+
/**
|
|
3
|
+
* BCP 47 lookup (RFC 4647 section 3.4, extended): for each requested tag try the tag, then shorter prefixes
|
|
4
|
+
* (`pl-PL` -> `pl`), then any available tag with the same language (`pt` -> `pt-BR`). Case-insensitive.
|
|
5
|
+
*/
|
|
6
|
+
export function negotiateLocale(requested, available, fallback) {
|
|
7
|
+
const byLower = new Map(available.map((a) => [a.toLowerCase(), a]));
|
|
8
|
+
for (const tag of requested) {
|
|
9
|
+
const parts = tag.toLowerCase().split('-');
|
|
10
|
+
for (let n = parts.length; n > 0; n--) {
|
|
11
|
+
const hit = byLower.get(parts.slice(0, n).join('-'));
|
|
12
|
+
if (hit)
|
|
13
|
+
return hit;
|
|
14
|
+
}
|
|
15
|
+
const lang = parts[0];
|
|
16
|
+
const sameLanguage = available.find((a) => a.toLowerCase().split('-')[0] === lang);
|
|
17
|
+
if (sameLanguage)
|
|
18
|
+
return sameLanguage;
|
|
19
|
+
}
|
|
20
|
+
return fallback;
|
|
21
|
+
}
|
|
22
|
+
/** `pl-PL` -> [`pl-PL`, `pl`]. */
|
|
23
|
+
function chain(locale) {
|
|
24
|
+
const parts = locale.split('-');
|
|
25
|
+
const out = [];
|
|
26
|
+
for (let n = parts.length; n > 0; n--)
|
|
27
|
+
out.push(parts.slice(0, n).join('-').toLowerCase());
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
export function createI18n(options) {
|
|
31
|
+
const fallbackLocale = options.fallbackLocale ?? 'en';
|
|
32
|
+
const formatter = options.formatter ?? icuFormatter;
|
|
33
|
+
// namespace -> lowercased locale -> { locale, messages }
|
|
34
|
+
const table = new Map();
|
|
35
|
+
for (const c of options.catalogs) {
|
|
36
|
+
let byLocale = table.get(c.namespace);
|
|
37
|
+
if (!byLocale) {
|
|
38
|
+
byLocale = new Map();
|
|
39
|
+
table.set(c.namespace, byLocale);
|
|
40
|
+
}
|
|
41
|
+
const id = c.locale.toLowerCase();
|
|
42
|
+
const entry = byLocale.get(id) ?? {
|
|
43
|
+
locale: c.locale,
|
|
44
|
+
messages: Object.create(null),
|
|
45
|
+
};
|
|
46
|
+
Object.assign(entry.messages, c.messages);
|
|
47
|
+
byLocale.set(id, entry);
|
|
48
|
+
}
|
|
49
|
+
const t = (locale, namespace, key, params = {}) => {
|
|
50
|
+
const byLocale = table.get(namespace);
|
|
51
|
+
if (byLocale) {
|
|
52
|
+
for (const id of [...chain(locale), ...chain(fallbackLocale)]) {
|
|
53
|
+
const entry = byLocale.get(id);
|
|
54
|
+
const message = entry && Object.hasOwn(entry.messages, key) ? entry.messages[key] : undefined;
|
|
55
|
+
if (entry && message !== undefined)
|
|
56
|
+
return formatter.format(message, params, entry.locale);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return key;
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
fallbackLocale,
|
|
63
|
+
locales(namespace) {
|
|
64
|
+
const out = new Set();
|
|
65
|
+
for (const [ns, byLocale] of table) {
|
|
66
|
+
if (namespace !== undefined && ns !== namespace)
|
|
67
|
+
continue;
|
|
68
|
+
for (const entry of byLocale.values())
|
|
69
|
+
out.add(entry.locale);
|
|
70
|
+
}
|
|
71
|
+
return [...out];
|
|
72
|
+
},
|
|
73
|
+
t,
|
|
74
|
+
translator(locale, namespace) {
|
|
75
|
+
return (key, params) => t(locale, namespace, key, params);
|
|
76
|
+
},
|
|
77
|
+
with(catalogs) {
|
|
78
|
+
return createI18n({ ...options, catalogs: [...options.catalogs, ...catalogs] });
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/i18n/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,SAA4B,EAC5B,SAA4B,EAC5B,QAAgB;IAEhB,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3C,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,KA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AM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7F,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;IAEF,OAAO;QACL,cAAc;QACd,OAAO,CAAC,SAAkB;YACxB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;YAC9B,KAAK,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,KAAK,EAAE,CAAC;gBACnC,IAAI,SAAS,KAAK,SAAS,IAAI,EAAE,KAAK,SAAS;oBAAE,SAAS;gBAC1D,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE;oBAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC/D,CAAC;YACD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;QAClB,CAAC;QACD,CAAC;QACD,UAAU,CAAC,MAAc,EAAE,SAAiB;YAC1C,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,CAAC,QAAmC;YACtC,OAAO,UAAU,CAAC,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;QAClF,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* i18n contracts. Two axes are kept apart everywhere:
|
|
3
|
+
* - UI locale: chrome, labels, issue messages, announcements (the reader's choice);
|
|
4
|
+
* - content language: the `lang` of the exercise text, used for grading and rendering (the author's choice).
|
|
5
|
+
*/
|
|
6
|
+
export type MessageParams = Readonly<Record<string, string | number>>;
|
|
7
|
+
/** Messages of one namespace in one locale. Values are ICU MessageFormat 1 strings. */
|
|
8
|
+
export interface MessageCatalog {
|
|
9
|
+
/** e.g. `astl.player`, `astl.gap`. */
|
|
10
|
+
readonly namespace: string;
|
|
11
|
+
/** BCP 47, e.g. `pl`. */
|
|
12
|
+
readonly locale: string;
|
|
13
|
+
readonly messages: Readonly<Record<string, string>>;
|
|
14
|
+
}
|
|
15
|
+
/** Port for message formatting. The default is the ICU MessageFormat 1 subset in `format.ts`. */
|
|
16
|
+
export interface MessageFormatter {
|
|
17
|
+
format(message: string, params: MessageParams, locale: string): string;
|
|
18
|
+
}
|
|
19
|
+
export type Translate = (key: string, params?: MessageParams) => string;
|
|
20
|
+
export interface I18n {
|
|
21
|
+
readonly fallbackLocale: string;
|
|
22
|
+
/** Locales that have at least one catalog (for a namespace, if given). */
|
|
23
|
+
locales(namespace?: string): readonly string[];
|
|
24
|
+
/** Formats `namespace:key` in the best matching locale, then the fallback locale, else returns the key. */
|
|
25
|
+
t(locale: string, namespace: string, key: string, params?: MessageParams): string;
|
|
26
|
+
/** A translate function bound to one locale and namespace. */
|
|
27
|
+
translator(locale: string, namespace: string): Translate;
|
|
28
|
+
/** A new instance with more catalogs. Later catalogs override earlier keys of the same namespace and locale. */
|
|
29
|
+
with(catalogs: readonly MessageCatalog[]): I18n;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAEtE,uFAAuF;AACvF,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,yBAAyB;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD;AAED,iGAAiG;AACjG,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACxE;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;AAExE,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,0EAA0E;IAC1E,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAC/C,2GAA2G;IAC3G,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IAClF,8DAA8D;IAC9D,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACzD,gHAAgH;IAChH,IAAI,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,IAAI,CAAC;CACjD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* i18n contracts. Two axes are kept apart everywhere:
|
|
3
|
+
* - UI locale: chrome, labels, issue messages, announcements (the reader's choice);
|
|
4
|
+
* - content language: the `lang` of the exercise text, used for grading and rendering (the author's choice).
|
|
5
|
+
*/
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type { Answers, SlotId } from './answers.js';
|
|
2
|
+
export { FLAG_SELECTED, fitsAnswer, isAnswers, MAX_ANSWER_COUNT, MAX_ANSWER_LENGTH, MAX_OPEN_ANSWER_LENGTH, maxAnswerLength, OPEN_SLOT_KIND, } from './answers.js';
|
|
3
|
+
export type { ElementNode, Node, TextNode } from './ast.js';
|
|
4
|
+
export { childElements, element, isElement, text, textContent } from './ast.js';
|
|
5
|
+
export type { EditorAdapter, EditorBlockPlace, EditorDescriptor, EditorFormat, EditorFormatState, EditorInsertOptions, EditorLayoutEdit, EditorLayoutShape, EditorLayoutState, EditorSelection, EditorStyleChanges, EditorStyleRule, EditorStyleState, EditorStyles, EditorStyleTarget, EditorStyleTargetKind, EditorTemplate, EditorWrap, InspectorField, } from './authoring.js';
|
|
6
|
+
export type { Checker, CheckRequest, CheckResponse, HintRequest, HintResponse, ResultHelp, SubmitRequest, SubmitResponse, } from './checker.js';
|
|
7
|
+
export { CheckerError } from './checker.js';
|
|
8
|
+
export type { AnswerKey, Compilation, KeyHelp, KeyHint, KeySlot, Metadata, PageMetadata, } from './compiled.js';
|
|
9
|
+
export { isAnswerKey, KEY_FORMAT_VERSION } from './compiled.js';
|
|
10
|
+
export { BLOCK_TAGS, CAPTION_TAG, CLASS_ATTRIBUTE, COLUMN_TAG, COLUMNS_TAG, CONTENT_ATTRIBUTES, DEFAULT_DOC_KIND, DOC_ATTRIBUTES, DOC_KINDS, type DocKind, FIGURE_TAG, INERT_STYLE, INLINE_TAGS, inertStyles, isSafeUrl, MAX_ATTRIBUTES_PER_ELEMENT, MAX_COLUMNS, MAX_NESTING_DEPTH, MIN_COLUMNS, PAGE_ATTRIBUTES, REMOVED_WITH_CONTENT, STYLE_TAG, strictUrlPolicy, TAG_ATTRIBUTES, URL_ATTRIBUTES, } from './content.js';
|
|
11
|
+
export type { CompileContext, ComponentDefinition, GroupSpec, SlotSpec, ValidateContext, } from './definition.js';
|
|
12
|
+
export type { CompileOptions, CompileResult, Engine, EngineOptions, GradeOptions, GroundColors, UrlPolicy, ValidationReport, } from './engine.js';
|
|
13
|
+
export type { Direction } from './format.js';
|
|
14
|
+
export { BUILT_IN_PREFIX, DOC_TAG, directionOf, ELEMENT_TAG_PATTERN, FORMAT_VERSION, isOpaqueId, isSourceId, LANGUAGE_TAG_PATTERN, MAX_SOURCE_LENGTH, OPAQUE_ID_PATTERN, PAGE_TAG, SOURCE_ID_PATTERN, SUPPORTED_FORMATS, } from './format.js';
|
|
15
|
+
export type { ElementHelp, Feedback, FeedbackVariant } from './help.js';
|
|
16
|
+
export { EXPLANATION_TAG, FEEDBACK_TAG, FEEDBACK_VARIANTS, HELP_ATTRIBUTES, HELP_TAGS, HINT_TAG, } from './help.js';
|
|
17
|
+
export type { CatalogProblem } from './i18n/check.js';
|
|
18
|
+
export { checkCatalog, compareCatalogs } from './i18n/check.js';
|
|
19
|
+
export type { MessagePart } from './i18n/format.js';
|
|
20
|
+
export { icuFormatter, MessageSyntaxError, messageParams, parseMessage, pluralCategories, } from './i18n/format.js';
|
|
21
|
+
export type { CreateI18nOptions } from './i18n/i18n.js';
|
|
22
|
+
export { createI18n, negotiateLocale } from './i18n/i18n.js';
|
|
23
|
+
export type { I18n, MessageCatalog, MessageFormatter, MessageParams, Translate } from './i18n/types.js';
|
|
24
|
+
export type { EngineIssueCode, Issue, IssueLocation, IssueParams, Severity } from './issues.js';
|
|
25
|
+
export { ENGINE_NAMESPACE, EngineIssue, hasErrors } from './issues.js';
|
|
26
|
+
export type { JsonArray, JsonObject, JsonValue } from './json.js';
|
|
27
|
+
export type { AttributeSpec, AttributeType, ChildSpec, ComponentManifest, ScoringSpec, VariantSpec, Visibility, } from './manifest.js';
|
|
28
|
+
export { allAttributes, COMMON_ATTRIBUTES, childTagConflict, SCORING_ATTRIBUTES, sameChildSpec, variantAttribute, } from './manifest.js';
|
|
29
|
+
export type { AttemptState, ChangeDetail, ElementContext, ElementFeedback, ErrorDetail, PageDetail, PlayerElementApi, ReadyDetail, SourceCompiler, StateDetail, Units, } from './player.js';
|
|
30
|
+
export { PlayerEvent } from './player.js';
|
|
31
|
+
export type { AttemptMode, AttemptPolicy, CheckScope, HelpMoment, HelpPolicy, Reveal } from './policy.js';
|
|
32
|
+
export { helpPolicy, isAttemptPolicy, PRACTICE_POLICY, TEST_POLICY } from './policy.js';
|
|
33
|
+
export type { ProblemCodeValue, ProblemDetails } from './protocol.js';
|
|
34
|
+
export { isProblemDetails, JSON_MEDIA_TYPE, MAX_REQUEST_BYTES, PROBLEM_MEDIA_TYPE, PROTOCOL_VERSION, ProblemCode, ProtocolPath, } from './protocol.js';
|
|
35
|
+
export type { GradeResult, GroupResult, GroupVerdict, Score, SlotVerdict, Solution, VerdictCounts, } from './result.js';
|
|
36
|
+
export { roundScore } from './result.js';
|
|
37
|
+
export type { ScoringGroup, ScoringRule } from './scoring.js';
|
|
38
|
+
export { groupMax, SCORING_RULES } from './scoring.js';
|
|
39
|
+
export type { GradeContext, NormalisationProfile, SlotKind } from './slots.js';
|
|
40
|
+
export { DEFAULT_PROFILE } from './slots.js';
|
|
41
|
+
export type { Snapshot } from './snapshot.js';
|
|
42
|
+
export { isSnapshot, SNAPSHOT_FORMAT } from './snapshot.js';
|
|
43
|
+
export type { Declarations, StyleScope, StyleTemplate, TokenOverrides } from './style.js';
|
|
44
|
+
export { isStyleTemplate, STYLE_TEMPLATE_ATTRIBUTE, STYLE_TEMPLATE_NAME } from './style.js';
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,aAAa,EACb,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAA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C,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { FLAG_SELECTED, fitsAnswer, isAnswers, MAX_ANSWER_COUNT, MAX_ANSWER_LENGTH, MAX_OPEN_ANSWER_LENGTH, maxAnswerLength, OPEN_SLOT_KIND, } from './answers.js';
|
|
2
|
+
export { childElements, element, isElement, text, textContent } from './ast.js';
|
|
3
|
+
export { CheckerError } from './checker.js';
|
|
4
|
+
export { isAnswerKey, KEY_FORMAT_VERSION } from './compiled.js';
|
|
5
|
+
export { BLOCK_TAGS, CAPTION_TAG, CLASS_ATTRIBUTE, COLUMN_TAG, COLUMNS_TAG, CONTENT_ATTRIBUTES, DEFAULT_DOC_KIND, DOC_ATTRIBUTES, DOC_KINDS, FIGURE_TAG, INERT_STYLE, INLINE_TAGS, inertStyles, isSafeUrl, MAX_ATTRIBUTES_PER_ELEMENT, MAX_COLUMNS, MAX_NESTING_DEPTH, MIN_COLUMNS, PAGE_ATTRIBUTES, REMOVED_WITH_CONTENT, STYLE_TAG, strictUrlPolicy, TAG_ATTRIBUTES, URL_ATTRIBUTES, } from './content.js';
|
|
6
|
+
export { BUILT_IN_PREFIX, DOC_TAG, directionOf, ELEMENT_TAG_PATTERN, FORMAT_VERSION, isOpaqueId, isSourceId, LANGUAGE_TAG_PATTERN, MAX_SOURCE_LENGTH, OPAQUE_ID_PATTERN, PAGE_TAG, SOURCE_ID_PATTERN, SUPPORTED_FORMATS, } from './format.js';
|
|
7
|
+
export { EXPLANATION_TAG, FEEDBACK_TAG, FEEDBACK_VARIANTS, HELP_ATTRIBUTES, HELP_TAGS, HINT_TAG, } from './help.js';
|
|
8
|
+
export { checkCatalog, compareCatalogs } from './i18n/check.js';
|
|
9
|
+
export { icuFormatter, MessageSyntaxError, messageParams, parseMessage, pluralCategories, } from './i18n/format.js';
|
|
10
|
+
export { createI18n, negotiateLocale } from './i18n/i18n.js';
|
|
11
|
+
export { ENGINE_NAMESPACE, EngineIssue, hasErrors } from './issues.js';
|
|
12
|
+
export { allAttributes, COMMON_ATTRIBUTES, childTagConflict, SCORING_ATTRIBUTES, sameChildSpec, variantAttribute, } from './manifest.js';
|
|
13
|
+
export { PlayerEvent } from './player.js';
|
|
14
|
+
export { helpPolicy, isAttemptPolicy, PRACTICE_POLICY, TEST_POLICY } from './policy.js';
|
|
15
|
+
export { isProblemDetails, JSON_MEDIA_TYPE, MAX_REQUEST_BYTES, PROBLEM_MEDIA_TYPE, PROTOCOL_VERSION, ProblemCode, ProtocolPath, } from './protocol.js';
|
|
16
|
+
export { roundScore } from './result.js';
|
|
17
|
+
export { groupMax, SCORING_RULES } from './scoring.js';
|
|
18
|
+
export { DEFAULT_PROFILE } from './slots.js';
|
|
19
|
+
export { isSnapshot, SNAPSHOT_FORMAT } from './snapshot.js';
|
|
20
|
+
export { isStyleTemplate, STYLE_TEMPLATE_ATTRIBUTE, STYLE_TEMPLATE_NAME } from './style.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAgChF,OAAO,EAAE,YAAY,EAAE,MA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EAAE,MAAM,aAAa,CAAC;AAExF,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,YAAY,GACb,MAAM,eAAe,CAAC;AAUvB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/issues.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation issues. Codes + params, never English sentences: hosts render them with message catalogs
|
|
3
|
+
* (`<namespace>` of the reporting component, or `astl.engine` for document-level codes).
|
|
4
|
+
*/
|
|
5
|
+
export type Severity = 'error' | 'warning';
|
|
6
|
+
export type IssueParams = Readonly<Record<string, string | number>>;
|
|
7
|
+
export interface IssueLocation {
|
|
8
|
+
/** Source id of the page, or null for the implicit page / document level. */
|
|
9
|
+
readonly page: string | null;
|
|
10
|
+
/** Source id of the closest element that has one (the component), or null. */
|
|
11
|
+
readonly element: string | null;
|
|
12
|
+
/** Tag of the element the issue is about, or null for the document. */
|
|
13
|
+
readonly tag: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Readable path from the root, e.g. `astl-doc > astl-page#p1 > p[2] > astl-gap#g1`. Empty for issues raised before
|
|
16
|
+
* the document could be parsed (SOURCE_TOO_LARGE, DOC_ROOT_INVALID), whose `tag` is null.
|
|
17
|
+
*/
|
|
18
|
+
readonly path: string;
|
|
19
|
+
}
|
|
20
|
+
export interface Issue {
|
|
21
|
+
/** Stable UPPER_SNAKE code. Component codes start with the type, e.g. `CHOICE_CORRECT_MISSING`. */
|
|
22
|
+
readonly code: string;
|
|
23
|
+
/** Errors block compiling; warnings do not. */
|
|
24
|
+
readonly severity: Severity;
|
|
25
|
+
/** i18n namespace of the message (`astl.engine` or the manifest's `messages`). */
|
|
26
|
+
readonly namespace: string;
|
|
27
|
+
readonly params: IssueParams;
|
|
28
|
+
readonly at: IssueLocation;
|
|
29
|
+
}
|
|
30
|
+
/** i18n namespace of document-level issues reported by the engine. */
|
|
31
|
+
export declare const ENGINE_NAMESPACE = "astl.engine";
|
|
32
|
+
/** Document-level issue codes. Component codes are listed in each manifest's `issues`. */
|
|
33
|
+
export declare const EngineIssue: {
|
|
34
|
+
readonly SOURCE_TOO_LARGE: 'SOURCE_TOO_LARGE';
|
|
35
|
+
readonly SOURCE_TOO_DEEP: 'SOURCE_TOO_DEEP';
|
|
36
|
+
readonly SOURCE_TOO_COMPLEX: 'SOURCE_TOO_COMPLEX';
|
|
37
|
+
readonly DOC_ROOT_INVALID: 'DOC_ROOT_INVALID';
|
|
38
|
+
readonly DOC_FORMAT_UNSUPPORTED: 'DOC_FORMAT_UNSUPPORTED';
|
|
39
|
+
readonly DOC_LANG_MISSING: 'DOC_LANG_MISSING';
|
|
40
|
+
readonly DOC_LANG_INVALID: 'DOC_LANG_INVALID';
|
|
41
|
+
readonly DOC_EMPTY: 'DOC_EMPTY';
|
|
42
|
+
readonly DOC_MIXED_PAGES: 'DOC_MIXED_PAGES';
|
|
43
|
+
readonly NO_COMPONENTS: 'NO_COMPONENTS';
|
|
44
|
+
readonly PAGE_EMPTY: 'PAGE_EMPTY';
|
|
45
|
+
readonly PAGE_NESTED: 'PAGE_NESTED';
|
|
46
|
+
readonly ID_MISSING: 'ID_MISSING';
|
|
47
|
+
readonly ID_INVALID: 'ID_INVALID';
|
|
48
|
+
readonly ID_DUPLICATE: 'ID_DUPLICATE';
|
|
49
|
+
readonly ELEMENT_UNKNOWN: 'ELEMENT_UNKNOWN';
|
|
50
|
+
readonly ELEMENT_REMOVED: 'ELEMENT_REMOVED';
|
|
51
|
+
readonly ATTRIBUTE_REMOVED: 'ATTRIBUTE_REMOVED';
|
|
52
|
+
readonly ATTRIBUTE_INVALID: 'ATTRIBUTE_INVALID';
|
|
53
|
+
readonly ATTRIBUTE_REQUIRED: 'ATTRIBUTE_REQUIRED';
|
|
54
|
+
readonly CHILD_UNEXPECTED: 'CHILD_UNEXPECTED';
|
|
55
|
+
/** A child tag of a registered component outside that component (a word to select outside its passage). */
|
|
56
|
+
readonly CHILD_OUTSIDE: 'CHILD_OUTSIDE';
|
|
57
|
+
readonly CHILD_COUNT: 'CHILD_COUNT';
|
|
58
|
+
readonly PLACEMENT_INVALID: 'PLACEMENT_INVALID';
|
|
59
|
+
readonly COMPONENT_NESTED: 'COMPONENT_NESTED';
|
|
60
|
+
readonly URL_BLOCKED: 'URL_BLOCKED';
|
|
61
|
+
readonly IMG_ALT_MISSING: 'IMG_ALT_MISSING';
|
|
62
|
+
readonly FIGURE_INVALID: 'FIGURE_INVALID';
|
|
63
|
+
readonly SCORING_MODE_INVALID: 'SCORING_MODE_INVALID';
|
|
64
|
+
readonly POINTS_INVALID: 'POINTS_INVALID';
|
|
65
|
+
readonly VERSION_UNSUPPORTED: 'VERSION_UNSUPPORTED';
|
|
66
|
+
readonly STYLE_TEMPLATE_UNKNOWN: 'STYLE_TEMPLATE_UNKNOWN';
|
|
67
|
+
/** A declaration the `style` allow-list refuses (`declarations.ts`): it goes, the rest of the style stays. */
|
|
68
|
+
readonly STYLE_REMOVED: 'STYLE_REMOVED';
|
|
69
|
+
/** A `style` over MAX_STYLE_LENGTH: it goes whole. */
|
|
70
|
+
readonly STYLE_TOO_LONG: 'STYLE_TOO_LONG';
|
|
71
|
+
/** A class no `<astl-style>` defines. */
|
|
72
|
+
readonly STYLE_UNKNOWN: 'STYLE_UNKNOWN';
|
|
73
|
+
/** An `<astl-style>` that defines nothing usable: a bad or reserved `name`, an unknown `for`, or both or neither. */
|
|
74
|
+
readonly STYLE_NAME_INVALID: 'STYLE_NAME_INVALID';
|
|
75
|
+
/** More `<astl-style>` rules than MAX_STYLE_RULES. */
|
|
76
|
+
readonly STYLE_RULES_TOO_MANY: 'STYLE_RULES_TOO_MANY';
|
|
77
|
+
/** Inlining the rules would write more than MAX_INLINED_STYLES into the view. */
|
|
78
|
+
readonly STYLE_TOO_LARGE: 'STYLE_TOO_LARGE';
|
|
79
|
+
/** Text and background of an element too close to read: the author decides. */
|
|
80
|
+
readonly STYLE_LOW_CONTRAST: 'STYLE_LOW_CONTRAST';
|
|
81
|
+
/** Help (`astl-hint`, `astl-explanation`, `astl-feedback`) with nothing graded around it or on its page: it goes. */
|
|
82
|
+
readonly HELP_UNGRADED: 'HELP_UNGRADED';
|
|
83
|
+
/** Help without content: it goes. */
|
|
84
|
+
readonly HELP_EMPTY: 'HELP_EMPTY';
|
|
85
|
+
/** A hint `cost` that is not a number from 0 to 1. */
|
|
86
|
+
readonly HINT_COST_INVALID: 'HINT_COST_INVALID';
|
|
87
|
+
/** A feedback `when` that is not one of `correct`, `incorrect`, `partial`, `omitted`. */
|
|
88
|
+
readonly FEEDBACK_WHEN_INVALID: 'FEEDBACK_WHEN_INVALID';
|
|
89
|
+
/** Two feedback texts for one `when` in one interaction or page. */
|
|
90
|
+
readonly FEEDBACK_DUPLICATE: 'FEEDBACK_DUPLICATE';
|
|
91
|
+
/** Two explanations in one interaction or page. */
|
|
92
|
+
readonly EXPLANATION_DUPLICATE: 'EXPLANATION_DUPLICATE';
|
|
93
|
+
/** A layout of the wrong shape: `<astl-columns>` directly on a page, holding 2 to 4 `<astl-column>`, not nested. */
|
|
94
|
+
readonly COLUMNS_INVALID: 'COLUMNS_INVALID';
|
|
95
|
+
};
|
|
96
|
+
export type EngineIssueCode = (typeof EngineIssue)[keyof typeof EngineIssue];
|
|
97
|
+
export declare function hasErrors(issues: readonly Issue[]): boolean;
|
|
98
|
+
//# sourceMappingURL=issues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issues.d.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AM,OAAO,WAAW,CAAC,CAAC;AAE7E,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,OAAO,CAE3D"}
|
package/dist/issues.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation issues. Codes + params, never English sentences: hosts render them with message catalogs
|
|
3
|
+
* (`<namespace>` of the reporting component, or `astl.engine` for document-level codes).
|
|
4
|
+
*/
|
|
5
|
+
/** i18n namespace of document-level issues reported by the engine. */
|
|
6
|
+
export const ENGINE_NAMESPACE = 'astl.engine';
|
|
7
|
+
/** Document-level issue codes. Component codes are listed in each manifest's `issues`. */
|
|
8
|
+
export const EngineIssue = {
|
|
9
|
+
SOURCE_TOO_LARGE: 'SOURCE_TOO_LARGE',
|
|
10
|
+
SOURCE_TOO_DEEP: 'SOURCE_TOO_DEEP',
|
|
11
|
+
SOURCE_TOO_COMPLEX: 'SOURCE_TOO_COMPLEX',
|
|
12
|
+
DOC_ROOT_INVALID: 'DOC_ROOT_INVALID',
|
|
13
|
+
DOC_FORMAT_UNSUPPORTED: 'DOC_FORMAT_UNSUPPORTED',
|
|
14
|
+
DOC_LANG_MISSING: 'DOC_LANG_MISSING',
|
|
15
|
+
DOC_LANG_INVALID: 'DOC_LANG_INVALID',
|
|
16
|
+
DOC_EMPTY: 'DOC_EMPTY',
|
|
17
|
+
DOC_MIXED_PAGES: 'DOC_MIXED_PAGES',
|
|
18
|
+
NO_COMPONENTS: 'NO_COMPONENTS',
|
|
19
|
+
PAGE_EMPTY: 'PAGE_EMPTY',
|
|
20
|
+
PAGE_NESTED: 'PAGE_NESTED',
|
|
21
|
+
ID_MISSING: 'ID_MISSING',
|
|
22
|
+
ID_INVALID: 'ID_INVALID',
|
|
23
|
+
ID_DUPLICATE: 'ID_DUPLICATE',
|
|
24
|
+
ELEMENT_UNKNOWN: 'ELEMENT_UNKNOWN',
|
|
25
|
+
ELEMENT_REMOVED: 'ELEMENT_REMOVED',
|
|
26
|
+
ATTRIBUTE_REMOVED: 'ATTRIBUTE_REMOVED',
|
|
27
|
+
ATTRIBUTE_INVALID: 'ATTRIBUTE_INVALID',
|
|
28
|
+
ATTRIBUTE_REQUIRED: 'ATTRIBUTE_REQUIRED',
|
|
29
|
+
CHILD_UNEXPECTED: 'CHILD_UNEXPECTED',
|
|
30
|
+
/** A child tag of a registered component outside that component (a word to select outside its passage). */
|
|
31
|
+
CHILD_OUTSIDE: 'CHILD_OUTSIDE',
|
|
32
|
+
CHILD_COUNT: 'CHILD_COUNT',
|
|
33
|
+
PLACEMENT_INVALID: 'PLACEMENT_INVALID',
|
|
34
|
+
COMPONENT_NESTED: 'COMPONENT_NESTED',
|
|
35
|
+
URL_BLOCKED: 'URL_BLOCKED',
|
|
36
|
+
IMG_ALT_MISSING: 'IMG_ALT_MISSING',
|
|
37
|
+
FIGURE_INVALID: 'FIGURE_INVALID',
|
|
38
|
+
SCORING_MODE_INVALID: 'SCORING_MODE_INVALID',
|
|
39
|
+
POINTS_INVALID: 'POINTS_INVALID',
|
|
40
|
+
VERSION_UNSUPPORTED: 'VERSION_UNSUPPORTED',
|
|
41
|
+
STYLE_TEMPLATE_UNKNOWN: 'STYLE_TEMPLATE_UNKNOWN',
|
|
42
|
+
/** A declaration the `style` allow-list refuses (`declarations.ts`): it goes, the rest of the style stays. */
|
|
43
|
+
STYLE_REMOVED: 'STYLE_REMOVED',
|
|
44
|
+
/** A `style` over MAX_STYLE_LENGTH: it goes whole. */
|
|
45
|
+
STYLE_TOO_LONG: 'STYLE_TOO_LONG',
|
|
46
|
+
/** A class no `<astl-style>` defines. */
|
|
47
|
+
STYLE_UNKNOWN: 'STYLE_UNKNOWN',
|
|
48
|
+
/** An `<astl-style>` that defines nothing usable: a bad or reserved `name`, an unknown `for`, or both or neither. */
|
|
49
|
+
STYLE_NAME_INVALID: 'STYLE_NAME_INVALID',
|
|
50
|
+
/** More `<astl-style>` rules than MAX_STYLE_RULES. */
|
|
51
|
+
STYLE_RULES_TOO_MANY: 'STYLE_RULES_TOO_MANY',
|
|
52
|
+
/** Inlining the rules would write more than MAX_INLINED_STYLES into the view. */
|
|
53
|
+
STYLE_TOO_LARGE: 'STYLE_TOO_LARGE',
|
|
54
|
+
/** Text and background of an element too close to read: the author decides. */
|
|
55
|
+
STYLE_LOW_CONTRAST: 'STYLE_LOW_CONTRAST',
|
|
56
|
+
/** Help (`astl-hint`, `astl-explanation`, `astl-feedback`) with nothing graded around it or on its page: it goes. */
|
|
57
|
+
HELP_UNGRADED: 'HELP_UNGRADED',
|
|
58
|
+
/** Help without content: it goes. */
|
|
59
|
+
HELP_EMPTY: 'HELP_EMPTY',
|
|
60
|
+
/** A hint `cost` that is not a number from 0 to 1. */
|
|
61
|
+
HINT_COST_INVALID: 'HINT_COST_INVALID',
|
|
62
|
+
/** A feedback `when` that is not one of `correct`, `incorrect`, `partial`, `omitted`. */
|
|
63
|
+
FEEDBACK_WHEN_INVALID: 'FEEDBACK_WHEN_INVALID',
|
|
64
|
+
/** Two feedback texts for one `when` in one interaction or page. */
|
|
65
|
+
FEEDBACK_DUPLICATE: 'FEEDBACK_DUPLICATE',
|
|
66
|
+
/** Two explanations in one interaction or page. */
|
|
67
|
+
EXPLANATION_DUPLICATE: 'EXPLANATION_DUPLICATE',
|
|
68
|
+
/** A layout of the wrong shape: `<astl-columns>` directly on a page, holding 2 to 4 `<astl-column>`, not nested. */
|
|
69
|
+
COLUMNS_INVALID: 'COLUMNS_INVALID',
|
|
70
|
+
};
|
|
71
|
+
export function hasErrors(issues) {
|
|
72
|
+
return issues.some((i) => i.severity === 'error');
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=issues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issues.js","sourceRoot":"","sources":["../src/issues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+BH,sEAAsE;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE9C,0FAA0F;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ACrH,aAAa,EAAE,eAAe;IAC9B,qCAAqC;IACrC,UAAU,EAAE,YAAY;IACxB,sDAAsD;IACtD,iBAAiB,EAAE,mBAAmB;IACtC,yFAAyF;IACzF,qBAAqB,EAAE,uBAAuB;IAC9C,oEAAoE;IACpE,kBAAkB,EAAE,oBAAoB;IACxC,mDAAmD;IACnD,qBAAqB,EAAE,uBAAuB;IAC9C,oHAAoH;IACpH,eAAe,EAAE,iBAAiB;CAC1B,CAAC;AAIX,MAAM,UAAU,SAAS,CAAC,MAAwB;IAChD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/json.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** A JSON value. Every contract object that crosses a process boundary is made of these. */
|
|
2
|
+
export type JsonValue = string | number | boolean | null | JsonArray | JsonObject;
|
|
3
|
+
export type JsonArray = readonly JsonValue[];
|
|
4
|
+
export interface JsonObject {
|
|
5
|
+
readonly [key: string]: JsonValue;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,CAAC;AAClF,MAAM,MAAM,SAAS,GAAG,SAAS,SAAS,EAAE,CAAC;AAC7C,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC"}
|
package/dist/json.js
ADDED
package/dist/json.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ComponentManifest: the ONLY per-type schema. Plain data, shared by the engine (sanitiser allow-list, validation,
|
|
3
|
+
* view allow-list), the player (attribute parsing), the editor (node attributes, default inspector), docs, JSON Schema
|
|
4
|
+
* and agent tool schemas. Nothing else may restate a component's attributes.
|
|
5
|
+
*/
|
|
6
|
+
import type { ScoringRule } from './scoring.js';
|
|
7
|
+
/**
|
|
8
|
+
* - `public`: kept in the view as written.
|
|
9
|
+
* - `private`: kept only in the answer key / never leaves the server.
|
|
10
|
+
* - `derived`: computed by the definition's `toView`; authors cannot write it.
|
|
11
|
+
*/
|
|
12
|
+
export type Visibility = 'public' | 'private' | 'derived';
|
|
13
|
+
/**
|
|
14
|
+
* - `id`: a source id local to the component (e.g. an option id); replaced by an opaque id in the view.
|
|
15
|
+
* - `boolean`: HTML boolean attribute (present = true; `"false"` is invalid).
|
|
16
|
+
* - `url`: checked by the engine's UrlPolicy; a blocked URL is removed with a URL_BLOCKED warning.
|
|
17
|
+
*/
|
|
18
|
+
export type AttributeType = 'string' | 'boolean' | 'integer' | 'number' | 'enum' | 'id' | 'url';
|
|
19
|
+
export interface AttributeSpec {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly type: AttributeType;
|
|
22
|
+
readonly visibility: Visibility;
|
|
23
|
+
readonly required?: boolean;
|
|
24
|
+
/** Allowed values for `enum`. */
|
|
25
|
+
readonly values?: readonly string[];
|
|
26
|
+
/** Inclusive bounds for `integer` and `number`. */
|
|
27
|
+
readonly min?: number;
|
|
28
|
+
readonly max?: number;
|
|
29
|
+
/** Value used when the attribute is absent. Documented and shown by the editor. */
|
|
30
|
+
readonly default?: string | number | boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A child element type a component accepts, e.g. `<astl-option>` inside `<astl-choice>`.
|
|
34
|
+
* - `content: 'text'`: plain text only (e.g. an accepted alternative answer).
|
|
35
|
+
* - `content: 'inline'`: rich inline content (emphasis, `lang` spans, math).
|
|
36
|
+
*/
|
|
37
|
+
export interface ChildSpec {
|
|
38
|
+
readonly tag: string;
|
|
39
|
+
readonly visibility: 'public' | 'private';
|
|
40
|
+
readonly content: 'text' | 'inline';
|
|
41
|
+
readonly min: number;
|
|
42
|
+
/** null = unbounded. */
|
|
43
|
+
readonly max: number | null;
|
|
44
|
+
readonly attributes: readonly AttributeSpec[];
|
|
45
|
+
/**
|
|
46
|
+
* Only in a type with rich content (`content: 'flow'`). Absent: the child sits in that content's text (a word to
|
|
47
|
+
* select). `'lead'`: it stands before the content, as the element's first child, never in its text (a prompt).
|
|
48
|
+
*/
|
|
49
|
+
readonly place?: 'lead';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Scoring modes an author can pick with the `scoring` attribute, each mapped to one engine rule.
|
|
53
|
+
* Mode names speak the author's language (`all`, `per-option`); rules are the three engine rules.
|
|
54
|
+
*/
|
|
55
|
+
export interface ScoringSpec {
|
|
56
|
+
readonly default: string;
|
|
57
|
+
readonly modes: Readonly<Record<string, ScoringRule>>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Presentation variants, picked by authors with the public `variant` attribute: how the element looks and behaves for
|
|
61
|
+
* the student (a gap that grows while typing, a select with a search box), never what it grades or which answers
|
|
62
|
+
* exist, so every variant of a source grades the same. The engine validates the value (an enum of `values`), elements
|
|
63
|
+
* render it, the authoring kit offers it (labels: `editor.value.variant.<value>` in the manifest's namespace).
|
|
64
|
+
* Adding a variant is not a breaking change; removing one or changing the default is (bump `version`).
|
|
65
|
+
*/
|
|
66
|
+
export interface VariantSpec {
|
|
67
|
+
/** Used when the attribute is absent or unknown to an older player. */
|
|
68
|
+
readonly default: string;
|
|
69
|
+
/** Kebab-case names, `default` included. */
|
|
70
|
+
readonly values: readonly string[];
|
|
71
|
+
}
|
|
72
|
+
export interface ComponentManifest {
|
|
73
|
+
/** Custom element name. Built-ins use the `astl-` prefix; third parties use their own. */
|
|
74
|
+
readonly tag: string;
|
|
75
|
+
/** Element format version, written as `v="n"` in views. Bump on incompatible changes and add a migration. */
|
|
76
|
+
readonly version: number;
|
|
77
|
+
/** `inline` sits inside text (a gap); `block` stands between paragraphs (a multiple choice). */
|
|
78
|
+
readonly display: 'inline' | 'block';
|
|
79
|
+
/**
|
|
80
|
+
* Whether the type is scored. Graded types form one scoring group of graded slots. Ungraded types have no scoring
|
|
81
|
+
* and add nothing to the maximum: they produce no slots (flash cards, media), or only open slots (a long answer),
|
|
82
|
+
* whose answers are stored with the attempt for a teacher.
|
|
83
|
+
*/
|
|
84
|
+
readonly graded: boolean;
|
|
85
|
+
/** Type-specific attributes. The common ones (`id`, `v`, `scoring`, `points`) come from `COMMON_ATTRIBUTES`. */
|
|
86
|
+
readonly attributes: readonly AttributeSpec[];
|
|
87
|
+
/**
|
|
88
|
+
* Absent: the element holds its declared children only. `'flow'` (blocks only): it wraps rich content as a page
|
|
89
|
+
* holds it (paragraphs, headings, lists, quotes, figures, formatting, pictures; no components), and its declared
|
|
90
|
+
* children are inline children that sit in that content's text where an inline component may sit (a word to
|
|
91
|
+
* select in a passage), except those with `place: 'lead'`, which come first, before the content (a prompt);
|
|
92
|
+
* `min` and `max` count them wherever they are.
|
|
93
|
+
*/
|
|
94
|
+
readonly content?: 'flow';
|
|
95
|
+
readonly children: readonly ChildSpec[];
|
|
96
|
+
/** null for ungraded types. */
|
|
97
|
+
readonly scoring: ScoringSpec | null;
|
|
98
|
+
/** null for types with a single presentation. */
|
|
99
|
+
readonly variants: VariantSpec | null;
|
|
100
|
+
/**
|
|
101
|
+
* Slot kinds the definition produces; each must be registered with the engine. Graded types list graded kinds only,
|
|
102
|
+
* ungraded types ungraded ones only (`open`).
|
|
103
|
+
*/
|
|
104
|
+
readonly slotKinds: readonly string[];
|
|
105
|
+
/** Issue codes the definition may report (namespace = `messages`). */
|
|
106
|
+
readonly issues: readonly string[];
|
|
107
|
+
/** i18n namespace for this type's messages, e.g. `astl.gap`. */
|
|
108
|
+
readonly messages: string;
|
|
109
|
+
/** Accessibility contract, used by docs and conformance: ARIA pattern and the keys that operate it. */
|
|
110
|
+
readonly a11y: {
|
|
111
|
+
readonly pattern: string;
|
|
112
|
+
readonly keys: readonly string[];
|
|
113
|
+
};
|
|
114
|
+
/** `part` names the element exposes for `::part()` styling. Public theming API. */
|
|
115
|
+
readonly cssParts: readonly string[];
|
|
116
|
+
}
|
|
117
|
+
/** Attributes every component accepts. `scoring` and `points` only apply to graded types. */
|
|
118
|
+
export declare const COMMON_ATTRIBUTES: readonly AttributeSpec[];
|
|
119
|
+
export declare const SCORING_ATTRIBUTES: readonly AttributeSpec[];
|
|
120
|
+
/** The `variant` attribute of a type with variants: an enum of the manifest's variant names. */
|
|
121
|
+
export declare function variantAttribute(variants: VariantSpec): AttributeSpec;
|
|
122
|
+
/** Every attribute an element of this type may carry, common ones first. */
|
|
123
|
+
export declare function allAttributes(manifest: ComponentManifest): readonly AttributeSpec[];
|
|
124
|
+
/**
|
|
125
|
+
* Whether two child specs may share a tag: the same visibility and attributes (in any order), so the tag carries the
|
|
126
|
+
* same data and keeps the same things private in every type that declares it (`astl-prompt`, `astl-option`). Content
|
|
127
|
+
* and counts are each type's own: a select's options are plain text, a choice's options rich.
|
|
128
|
+
*/
|
|
129
|
+
export declare function sameChildSpec(a: ChildSpec, b: ChildSpec): boolean;
|
|
130
|
+
/** A child tag two of the manifests declare with specs that differ (see `sameChildSpec`), or null when none does. */
|
|
131
|
+
export declare function childTagConflict(manifests: readonly ComponentManifest[]): {
|
|
132
|
+
readonly tag: string;
|
|
133
|
+
readonly components: readonly [string, string];
|
|
134
|
+
} | null;
|
|
135
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD;;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