@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,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile outputs. A source compiles to three artefacts:
|
|
3
|
+
* - view: public HTML (no answers), cacheable on a CDN under its SHA-256;
|
|
4
|
+
* - key: private answer key, only for whoever grades;
|
|
5
|
+
* - metadata: public facts for catalogues and hosts.
|
|
6
|
+
*/
|
|
7
|
+
import type { DocKind } from './content.js';
|
|
8
|
+
import type { FeedbackVariant } from './help.js';
|
|
9
|
+
import type { JsonObject } from './json.js';
|
|
10
|
+
import type { ScoringGroup } from './scoring.js';
|
|
11
|
+
export declare const KEY_FORMAT_VERSION = 1;
|
|
12
|
+
export interface KeySlot {
|
|
13
|
+
readonly kind: string;
|
|
14
|
+
readonly key: JsonObject;
|
|
15
|
+
/**
|
|
16
|
+
* Opaque id of the component the slot belongs to, which is also the id of its scoring group, unless the component
|
|
17
|
+
* is graded in parts (`ComponentDefinition.groups`): then its groups list the slot. Open slots (an ungraded kind)
|
|
18
|
+
* belong to no group: no `groups` entry has this id or lists them.
|
|
19
|
+
*/
|
|
20
|
+
readonly group: string;
|
|
21
|
+
/** View page id. */
|
|
22
|
+
readonly page: string;
|
|
23
|
+
}
|
|
24
|
+
/** A hint as the key holds it: its content (HTML of format 1) and the fraction 0..1 of the points it costs. */
|
|
25
|
+
export interface KeyHint {
|
|
26
|
+
readonly html: string;
|
|
27
|
+
readonly cost: number;
|
|
28
|
+
}
|
|
29
|
+
/** The help of one interaction or page (see help.ts): key-side, as it may give the answer away. */
|
|
30
|
+
export interface KeyHelp {
|
|
31
|
+
readonly hints: readonly KeyHint[];
|
|
32
|
+
/** HTML; null when there is none. */
|
|
33
|
+
readonly explanation: string | null;
|
|
34
|
+
/** HTML by variant, only the variants written. */
|
|
35
|
+
readonly feedback: Readonly<Partial<Record<FeedbackVariant, string>>>;
|
|
36
|
+
}
|
|
37
|
+
export interface AnswerKey {
|
|
38
|
+
readonly format: typeof KEY_FORMAT_VERSION;
|
|
39
|
+
/** Content language of the document. Slots inherit it unless their key says otherwise. */
|
|
40
|
+
readonly lang: string;
|
|
41
|
+
/** View hash this key belongs to. Hosts must store and serve them together. */
|
|
42
|
+
readonly viewHash: string;
|
|
43
|
+
readonly slots: Readonly<Record<string, KeySlot>>;
|
|
44
|
+
readonly groups: readonly ScoringGroup[];
|
|
45
|
+
/** View page ids in order. */
|
|
46
|
+
readonly pages: readonly string[];
|
|
47
|
+
/** Help by view element id and view page id; absent when the source has none. */
|
|
48
|
+
readonly help?: Readonly<Record<string, KeyHelp>>;
|
|
49
|
+
}
|
|
50
|
+
export interface PageMetadata {
|
|
51
|
+
/** View page id. */
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly label: string | null;
|
|
54
|
+
/** Answer slots on the page, open ones included. */
|
|
55
|
+
readonly slots: number;
|
|
56
|
+
readonly maxScore: number;
|
|
57
|
+
}
|
|
58
|
+
export interface Metadata {
|
|
59
|
+
readonly format: number;
|
|
60
|
+
readonly lang: string;
|
|
61
|
+
readonly dir: 'ltr' | 'rtl';
|
|
62
|
+
/**
|
|
63
|
+
* The document's `kind` when it is not `exercise`, the default: as in the view, the metadata of every exercise (and
|
|
64
|
+
* every conformance golden) stays as it was. Absent means `exercise`.
|
|
65
|
+
*/
|
|
66
|
+
readonly kind?: DocKind;
|
|
67
|
+
readonly viewHash: string;
|
|
68
|
+
readonly pages: readonly PageMetadata[];
|
|
69
|
+
/** Element counts by tag, e.g. `{ "astl-gap": 5 }`. */
|
|
70
|
+
readonly elements: Readonly<Record<string, number>>;
|
|
71
|
+
/** Answer slots, open ones included: what a player's `astl-ready` counts. */
|
|
72
|
+
readonly slots: number;
|
|
73
|
+
/**
|
|
74
|
+
* Ids of the open slots (stored for a teacher, never graded), in reading order, so a server or a teacher's view can
|
|
75
|
+
* pick these answers out of a submission. They add nothing to `maxScore`.
|
|
76
|
+
*/
|
|
77
|
+
readonly open: readonly string[];
|
|
78
|
+
readonly groups: number;
|
|
79
|
+
readonly maxScore: number;
|
|
80
|
+
/** Words of running text, for reading-time estimates. */
|
|
81
|
+
readonly words: number;
|
|
82
|
+
/** Numbers contributed by component `metadata` hooks, keyed `tag.name`. */
|
|
83
|
+
readonly extra: Readonly<Record<string, number>>;
|
|
84
|
+
}
|
|
85
|
+
export interface Compilation {
|
|
86
|
+
readonly view: string;
|
|
87
|
+
/** Lowercase hex SHA-256 of the UTF-8 view. */
|
|
88
|
+
readonly viewHash: string;
|
|
89
|
+
readonly key: AnswerKey;
|
|
90
|
+
readonly metadata: Metadata;
|
|
91
|
+
}
|
|
92
|
+
/** Narrow check for keys loaded from storage. Full validation happens in the engine. */
|
|
93
|
+
export declare function isAnswerKey(value: unknown): value is AnswerKey;
|
|
94
|
+
//# sourceMappingURL=compiled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiled.d.ts","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,CAAC;IACvB,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAa9D"}
|
package/dist/compiled.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const KEY_FORMAT_VERSION = 1;
|
|
2
|
+
/** Narrow check for keys loaded from storage. Full validation happens in the engine. */
|
|
3
|
+
export function isAnswerKey(value) {
|
|
4
|
+
if (typeof value !== 'object' || value === null)
|
|
5
|
+
return false;
|
|
6
|
+
const v = value;
|
|
7
|
+
return (v.format === KEY_FORMAT_VERSION &&
|
|
8
|
+
typeof v.lang === 'string' &&
|
|
9
|
+
typeof v.viewHash === 'string' &&
|
|
10
|
+
typeof v.slots === 'object' &&
|
|
11
|
+
v.slots !== null &&
|
|
12
|
+
Array.isArray(v.groups) &&
|
|
13
|
+
Array.isArray(v.pages) &&
|
|
14
|
+
(v.help === undefined || (typeof v.help === 'object' && v.help !== null)));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=compiled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiled.js","sourceRoot":"","sources":["../src/compiled.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAyFpC,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,CAAC,GAAG,KAA2B,CAAC;IACtC,OAAO,CACL,CAAC,CAAC,MAAM,KAAK,kBAAkB;QAC/B,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ;QAC1B,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ;QAC9B,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ;QAC3B,CAAC,CAAC,KAAK,KAAK,IAAI;QAChB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QACtB,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAC1E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rich-text allow-list of content format 1, shared by the engine (sanitiser, view guard) and the player
|
|
3
|
+
* (defensive pass when mounting a view). One list, so both sides can never disagree.
|
|
4
|
+
*/
|
|
5
|
+
import type { UrlPolicy } from './engine.js';
|
|
6
|
+
export declare const BLOCK_TAGS: ReadonlySet<string>;
|
|
7
|
+
/** `img` is a picture: inline, so it can sit in text, prompts, options and cards. */
|
|
8
|
+
export declare const INLINE_TAGS: ReadonlySet<string>;
|
|
9
|
+
/**
|
|
10
|
+
* A picture with a caption: a block directly in a page (or the document), holding exactly one `img` and at most one
|
|
11
|
+
* `figcaption` (rich inline text), nothing else. A `figcaption` anywhere else is unwrapped.
|
|
12
|
+
*/
|
|
13
|
+
export declare const FIGURE_TAG = "figure";
|
|
14
|
+
export declare const CAPTION_TAG = "figcaption";
|
|
15
|
+
/** Dropped together with their content: active content, embeds, media and form controls. */
|
|
16
|
+
export declare const REMOVED_WITH_CONTENT: ReadonlySet<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Attributes allowed on every content element. `style` goes through the allow-list of `declarations.ts` at each side
|
|
19
|
+
* that reads it. `class` is not here on purpose: it exists in sources only, and the engine inlines it.
|
|
20
|
+
*/
|
|
21
|
+
export declare const CONTENT_ATTRIBUTES: ReadonlySet<string>;
|
|
22
|
+
/** A source attribute naming named styles (`<astl-style name>`); no view ever holds it. */
|
|
23
|
+
export declare const CLASS_ATTRIBUTE = "class";
|
|
24
|
+
/** What `inertStyles` renames `style` to. */
|
|
25
|
+
export declare const INERT_STYLE = "data-astl-style";
|
|
26
|
+
/**
|
|
27
|
+
* The HTML with every `style` attribute under another name, for parsing. Under a strict CSP any HTML parser reports a
|
|
28
|
+
* `style` attribute as a violation the moment it meets one, in a template or a DOMParser document too (seen in Chromium
|
|
29
|
+
* on all of them), though nothing in those documents is ever drawn. Only start tags change, never text or values.
|
|
30
|
+
*/
|
|
31
|
+
export declare const inertStyles: (html: string) => string;
|
|
32
|
+
/**
|
|
33
|
+
* A rule, first in `<astl-doc>`: `name` and `label` (a named style, applied with `class`) or `for` (every element of
|
|
34
|
+
* that tag), with its declarations in `style`. Sources only: the engine inlines it.
|
|
35
|
+
*/
|
|
36
|
+
export declare const STYLE_TAG = "astl-style";
|
|
37
|
+
/** A layout: 2 to 4 columns directly on a page or in the document, wrapping by themselves; no nesting. */
|
|
38
|
+
export declare const COLUMNS_TAG = "astl-columns";
|
|
39
|
+
/** One column of a layout: blocks, figures and block components, as a page holds them. */
|
|
40
|
+
export declare const COLUMN_TAG = "astl-column";
|
|
41
|
+
export declare const MIN_COLUMNS = 2;
|
|
42
|
+
export declare const MAX_COLUMNS = 4;
|
|
43
|
+
/**
|
|
44
|
+
* Extra attributes allowed on specific rich-text elements. A picture: `src` and `alt` (required; `alt=""` marks
|
|
45
|
+
* decoration), `width` and `height` (positive integers, so the layout does not jump while it loads).
|
|
46
|
+
*/
|
|
47
|
+
export declare const TAG_ATTRIBUTES: Readonly<Record<string, readonly string[]>>;
|
|
48
|
+
/** The attribute of a rich-text element that holds a URL, checked by the URL policy. */
|
|
49
|
+
export declare const URL_ATTRIBUTES: Readonly<Record<string, string>>;
|
|
50
|
+
/** Attributes the document and page elements may carry in a view. */
|
|
51
|
+
export declare const DOC_ATTRIBUTES: readonly string[];
|
|
52
|
+
/**
|
|
53
|
+
* What a document is, its `kind`: how it shows, never how it grades. An `exercise` (the default when absent) shows one
|
|
54
|
+
* page at a time; a `book` shows two pages side by side (1-2, 3-4, ...) where the player is wide enough, turning them
|
|
55
|
+
* a spread at a time. Practice and test are not kinds: they are policies over any kind (policy.ts).
|
|
56
|
+
*/
|
|
57
|
+
export declare const DOC_KINDS: readonly ['exercise', 'book'];
|
|
58
|
+
export type DocKind = (typeof DOC_KINDS)[number];
|
|
59
|
+
export declare const DEFAULT_DOC_KIND: DocKind;
|
|
60
|
+
export declare const PAGE_ATTRIBUTES: readonly string[];
|
|
61
|
+
/** Most attributes one element may carry in a source (beyond it: SOURCE_TOO_COMPLEX, checked before parsing). */
|
|
62
|
+
export declare const MAX_ATTRIBUTES_PER_ELEMENT = 256;
|
|
63
|
+
/** Deepest element nesting a source may have (beyond it: SOURCE_TOO_DEEP). */
|
|
64
|
+
export declare const MAX_NESTING_DEPTH = 100;
|
|
65
|
+
/** The default URL policy: absolute `http:`, `https:` and `mailto:` URLs (tabs and newlines ignored, as browsers do). */
|
|
66
|
+
export declare function isSafeUrl(url: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* A host's URL policy as engines, players and the authoring kit use it: a URL passes only when the policy returns
|
|
69
|
+
* `true`. A policy that throws, or returns anything else (the Promise of an async function, say), blocks the URL.
|
|
70
|
+
*/
|
|
71
|
+
export declare function strictUrlPolicy(policy: UrlPolicy): UrlPolicy;
|
|
72
|
+
//# sourceMappingURL=content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,K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AAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AACjD,eAAO,MAAM,gBAAgB,EAAE,OAAoB,CAAC;AACpD,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAA4C,CAAC;AAE1F,iHAAiH;AACjH,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,8EAA8E;AAC9E,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAIrC,yHAAyH;AACzH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG9C;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAS5D"}
|
package/dist/content.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export const BLOCK_TAGS = new Set([
|
|
2
|
+
'p',
|
|
3
|
+
'h2',
|
|
4
|
+
'h3',
|
|
5
|
+
'h4',
|
|
6
|
+
'ul',
|
|
7
|
+
'ol',
|
|
8
|
+
'li',
|
|
9
|
+
'blockquote',
|
|
10
|
+
]);
|
|
11
|
+
/** `img` is a picture: inline, so it can sit in text, prompts, options and cards. */
|
|
12
|
+
export const INLINE_TAGS = new Set([
|
|
13
|
+
'strong',
|
|
14
|
+
'em',
|
|
15
|
+
'b',
|
|
16
|
+
'i',
|
|
17
|
+
'u',
|
|
18
|
+
's',
|
|
19
|
+
'sub',
|
|
20
|
+
'sup',
|
|
21
|
+
'code',
|
|
22
|
+
'mark',
|
|
23
|
+
'span',
|
|
24
|
+
'a',
|
|
25
|
+
'br',
|
|
26
|
+
'img',
|
|
27
|
+
]);
|
|
28
|
+
/**
|
|
29
|
+
* A picture with a caption: a block directly in a page (or the document), holding exactly one `img` and at most one
|
|
30
|
+
* `figcaption` (rich inline text), nothing else. A `figcaption` anywhere else is unwrapped.
|
|
31
|
+
*/
|
|
32
|
+
export const FIGURE_TAG = 'figure';
|
|
33
|
+
export const CAPTION_TAG = 'figcaption';
|
|
34
|
+
/** Dropped together with their content: active content, embeds, media and form controls. */
|
|
35
|
+
export const REMOVED_WITH_CONTENT = new Set([
|
|
36
|
+
'script',
|
|
37
|
+
'style',
|
|
38
|
+
'template',
|
|
39
|
+
'iframe',
|
|
40
|
+
'object',
|
|
41
|
+
'embed',
|
|
42
|
+
'noscript',
|
|
43
|
+
'svg',
|
|
44
|
+
'math',
|
|
45
|
+
'video',
|
|
46
|
+
'audio',
|
|
47
|
+
'form',
|
|
48
|
+
'input',
|
|
49
|
+
'select',
|
|
50
|
+
'textarea',
|
|
51
|
+
'button',
|
|
52
|
+
]);
|
|
53
|
+
/**
|
|
54
|
+
* Attributes allowed on every content element. `style` goes through the allow-list of `declarations.ts` at each side
|
|
55
|
+
* that reads it. `class` is not here on purpose: it exists in sources only, and the engine inlines it.
|
|
56
|
+
*/
|
|
57
|
+
export const CONTENT_ATTRIBUTES = new Set(['lang', 'dir', 'style']);
|
|
58
|
+
/** A source attribute naming named styles (`<astl-style name>`); no view ever holds it. */
|
|
59
|
+
export const CLASS_ATTRIBUTE = 'class';
|
|
60
|
+
/** What `inertStyles` renames `style` to. */
|
|
61
|
+
export const INERT_STYLE = 'data-astl-style';
|
|
62
|
+
const START_TAG = /<[a-z](?:[^<>"']|"[^"]*"|'[^']*')*>/gi;
|
|
63
|
+
const STYLE_IN_TAG = /"[^"]*"|'[^']*'|(\s)style\s*=/gi;
|
|
64
|
+
/**
|
|
65
|
+
* The HTML with every `style` attribute under another name, for parsing. Under a strict CSP any HTML parser reports a
|
|
66
|
+
* `style` attribute as a violation the moment it meets one, in a template or a DOMParser document too (seen in Chromium
|
|
67
|
+
* on all of them), though nothing in those documents is ever drawn. Only start tags change, never text or values.
|
|
68
|
+
*/
|
|
69
|
+
export const inertStyles = (html) => html.replace(START_TAG, (tag) => tag.replace(STYLE_IN_TAG, (found, space) => space === undefined ? found : `${space}${INERT_STYLE}=`));
|
|
70
|
+
/**
|
|
71
|
+
* A rule, first in `<astl-doc>`: `name` and `label` (a named style, applied with `class`) or `for` (every element of
|
|
72
|
+
* that tag), with its declarations in `style`. Sources only: the engine inlines it.
|
|
73
|
+
*/
|
|
74
|
+
export const STYLE_TAG = 'astl-style';
|
|
75
|
+
/** A layout: 2 to 4 columns directly on a page or in the document, wrapping by themselves; no nesting. */
|
|
76
|
+
export const COLUMNS_TAG = 'astl-columns';
|
|
77
|
+
/** One column of a layout: blocks, figures and block components, as a page holds them. */
|
|
78
|
+
export const COLUMN_TAG = 'astl-column';
|
|
79
|
+
export const MIN_COLUMNS = 2;
|
|
80
|
+
export const MAX_COLUMNS = 4;
|
|
81
|
+
/**
|
|
82
|
+
* Extra attributes allowed on specific rich-text elements. A picture: `src` and `alt` (required; `alt=""` marks
|
|
83
|
+
* decoration), `width` and `height` (positive integers, so the layout does not jump while it loads).
|
|
84
|
+
*/
|
|
85
|
+
export const TAG_ATTRIBUTES = {
|
|
86
|
+
a: ['href'],
|
|
87
|
+
ol: ['start'],
|
|
88
|
+
img: ['src', 'alt', 'width', 'height'],
|
|
89
|
+
};
|
|
90
|
+
/** The attribute of a rich-text element that holds a URL, checked by the URL policy. */
|
|
91
|
+
export const URL_ATTRIBUTES = { a: 'href', img: 'src' };
|
|
92
|
+
/** Attributes the document and page elements may carry in a view. */
|
|
93
|
+
export const DOC_ATTRIBUTES = ['format', 'lang', 'dir', 'kind', 'style', 'style-template'];
|
|
94
|
+
/**
|
|
95
|
+
* What a document is, its `kind`: how it shows, never how it grades. An `exercise` (the default when absent) shows one
|
|
96
|
+
* page at a time; a `book` shows two pages side by side (1-2, 3-4, ...) where the player is wide enough, turning them
|
|
97
|
+
* a spread at a time. Practice and test are not kinds: they are policies over any kind (policy.ts).
|
|
98
|
+
*/
|
|
99
|
+
export const DOC_KINDS = ['exercise', 'book'];
|
|
100
|
+
export const DEFAULT_DOC_KIND = 'exercise';
|
|
101
|
+
export const PAGE_ATTRIBUTES = ['id', 'label', 'lang', 'dir', 'style'];
|
|
102
|
+
/** Most attributes one element may carry in a source (beyond it: SOURCE_TOO_COMPLEX, checked before parsing). */
|
|
103
|
+
export const MAX_ATTRIBUTES_PER_ELEMENT = 256;
|
|
104
|
+
/** Deepest element nesting a source may have (beyond it: SOURCE_TOO_DEEP). */
|
|
105
|
+
export const MAX_NESTING_DEPTH = 100;
|
|
106
|
+
const SAFE_SCHEMES = new Set(['http', 'https', 'mailto']);
|
|
107
|
+
/** The default URL policy: absolute `http:`, `https:` and `mailto:` URLs (tabs and newlines ignored, as browsers do). */
|
|
108
|
+
export function isSafeUrl(url) {
|
|
109
|
+
const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(url.replace(/[\t\n\r]/g, '').trim());
|
|
110
|
+
return scheme !== null && SAFE_SCHEMES.has((scheme[1] ?? '').toLowerCase());
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A host's URL policy as engines, players and the authoring kit use it: a URL passes only when the policy returns
|
|
114
|
+
* `true`. A policy that throws, or returns anything else (the Promise of an async function, say), blocks the URL.
|
|
115
|
+
*/
|
|
116
|
+
export function strictUrlPolicy(policy) {
|
|
117
|
+
if (policy === isSafeUrl)
|
|
118
|
+
return isSafeUrl;
|
|
119
|
+
return (url, context) => {
|
|
120
|
+
try {
|
|
121
|
+
return policy(url, context) === true;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC;IACrD,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,YAAY;CACb,CAAC,CAAC;AAEH,qFAAqF;AACrF,MAAM,CAAC,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAC;IACtD,QAAQ;IAC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MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,MAAM,MAAM,GAAG,wBAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAClF,OAAO,MAAM,KAAK,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QACtB,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QACvC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `style` allow-list of content format 1: which properties an author may set and what each may hold, value by
|
|
3
|
+
* value. The output is rebuilt from validated tokens only, so whatever a style hides (comments, escapes, `!important`,
|
|
4
|
+
* an unclosed parenthesis) never reaches a browser. Exercises play on public pages: nothing here can leave its box,
|
|
5
|
+
* cover other content, load anything or hide text.
|
|
6
|
+
*
|
|
7
|
+
* `@astl/core/declarations`, not in the main entry: every bundle re-exports that one, so this table would load with every
|
|
8
|
+
* player, and it is needed only by exercises that use styles.
|
|
9
|
+
*/
|
|
10
|
+
/** Longest `style` value read; a longer one is dropped whole. */
|
|
11
|
+
export declare const MAX_STYLE_LENGTH = 2000;
|
|
12
|
+
/** Most `<astl-style>` rules a document may have. */
|
|
13
|
+
export declare const MAX_STYLE_RULES = 100;
|
|
14
|
+
/** Most characters of `style` inlining may write in one view: rules are short, the elements they reach may be many. */
|
|
15
|
+
export declare const MAX_INLINED_STYLES = 1000000;
|
|
16
|
+
/** Whether `name` can name a style: the grammar, and none of the reserved prefixes `astl-`, `tiptap`, `prosemirror`. */
|
|
17
|
+
export declare function isStyleName(name: string): boolean;
|
|
18
|
+
/** A `class` value as an editing surface keeps it: the tokens that can name a style, each once. */
|
|
19
|
+
export declare function cleanClass(value: string): string;
|
|
20
|
+
/** One kept declaration: lowercase property, normalised value. */
|
|
21
|
+
export type StyleDeclaration = readonly [name: string, value: string];
|
|
22
|
+
export interface CleanedStyle {
|
|
23
|
+
/** The kept declarations as a `style` value: `name: value; name: value`, empty when none is left. */
|
|
24
|
+
readonly style: string;
|
|
25
|
+
readonly declarations: readonly StyleDeclaration[];
|
|
26
|
+
/** The property names refused, in order; for what is not a declaration at all, its first characters. */
|
|
27
|
+
readonly removed: readonly string[];
|
|
28
|
+
}
|
|
29
|
+
/** Red, green and blue (0 to 255) and alpha (0 to 1). */
|
|
30
|
+
export type StyleColor = readonly [red: number, green: number, blue: number, alpha: number];
|
|
31
|
+
/** A hex colour or `rgb()`, or null: what has a value of its own, as opposed to a palette token or a keyword. */
|
|
32
|
+
export declare function parseStyleColor(value: string): StyleColor | null;
|
|
33
|
+
/** Every property a `style` may set, as a host lists them (`background` is read as `background-color`). */
|
|
34
|
+
export declare const STYLE_PROPERTIES: readonly string[];
|
|
35
|
+
/** Declarations in order, the later of one property in the place of the earlier: what the cascade would keep. */
|
|
36
|
+
export declare function mergeStyles(...lists: readonly (readonly StyleDeclaration[])[]): StyleDeclaration[];
|
|
37
|
+
/** Declarations as a `style` value. */
|
|
38
|
+
export declare function styleText(declarations: readonly StyleDeclaration[]): string;
|
|
39
|
+
/**
|
|
40
|
+
* A `style` value through the allow-list: the declarations it may keep, and the names of those it may not. Refused:
|
|
41
|
+
* every property outside the table, and any declaration whose value is not exactly what the table allows (comments,
|
|
42
|
+
* escapes, `!important`, `url()`, custom properties, `var()` other than `--astl-palette-<n>` and its `-soft`, a size
|
|
43
|
+
* out of bounds). Idempotent, also on what browsers write back (`rgb(47, 86, 217)`, quoted font names, `0px`).
|
|
44
|
+
*/
|
|
45
|
+
export declare function cleanStyle(value: string): CleanedStyle;
|
|
46
|
+
/** The WCAG relative luminance of a colour, its alpha left out. */
|
|
47
|
+
export declare function styleLuminance(value: StyleColor): number;
|
|
48
|
+
/** `top` over `below`: what the eye sees of a colour with alpha. */
|
|
49
|
+
export declare function overStyleColor(top: StyleColor, below: StyleColor): StyleColor;
|
|
50
|
+
/** The WCAG contrast ratio of an opaque text colour and background, from 1 to 21. */
|
|
51
|
+
export declare function styleContrast(ink: StyleColor, ground: StyleColor): number;
|
|
52
|
+
//# sourceMappingURL=declarations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../src/declarations.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,iEAAiE;AACjE,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,qDAAqD;AACrD,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,uHAAuH;AACvH,eAAO,MAAM,kBAAkB,UAAY,CAAC;AAM5C,wHAAwH;AACxH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,mGAAmG;AACnG,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,kEAAkE;AAClE,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,qGAAqG;IACrG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACnD,wGAAwG;IACxG,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,yDAAyD;AACzD,MAAM,MAAM,UAA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