@astl/player 0.0.0-stage → 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.
Files changed (107) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENSE +202 -0
  3. package/README.md +36 -2
  4. package/dist/a11y.d.ts +41 -0
  5. package/dist/a11y.d.ts.map +1 -0
  6. package/dist/a11y.js +101 -0
  7. package/dist/a11y.js.map +1 -0
  8. package/dist/attempt/controller.d.ts +104 -0
  9. package/dist/attempt/controller.d.ts.map +1 -0
  10. package/dist/attempt/controller.js +325 -0
  11. package/dist/attempt/controller.js.map +1 -0
  12. package/dist/checker/http.d.ts +17 -0
  13. package/dist/checker/http.d.ts.map +1 -0
  14. package/dist/checker/http.js +115 -0
  15. package/dist/checker/http.js.map +1 -0
  16. package/dist/define.d.ts +35 -0
  17. package/dist/define.d.ts.map +1 -0
  18. package/dist/define.js +84 -0
  19. package/dist/define.js.map +1 -0
  20. package/dist/element/base.d.ts +83 -0
  21. package/dist/element/base.d.ts.map +1 -0
  22. package/dist/element/base.js +239 -0
  23. package/dist/element/base.js.map +1 -0
  24. package/dist/index.d.ts +14 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +8 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/interaction/index.d.ts +12 -0
  29. package/dist/interaction/index.d.ts.map +1 -0
  30. package/dist/interaction/index.js +4 -0
  31. package/dist/interaction/index.js.map +1 -0
  32. package/dist/interaction/keys.d.ts +11 -0
  33. package/dist/interaction/keys.d.ts.map +1 -0
  34. package/dist/interaction/keys.js +13 -0
  35. package/dist/interaction/keys.js.map +1 -0
  36. package/dist/interaction/pick-and-place.d.ts +120 -0
  37. package/dist/interaction/pick-and-place.d.ts.map +1 -0
  38. package/dist/interaction/pick-and-place.js +395 -0
  39. package/dist/interaction/pick-and-place.js.map +1 -0
  40. package/dist/interaction/roving-focus.d.ts +44 -0
  41. package/dist/interaction/roving-focus.d.ts.map +1 -0
  42. package/dist/interaction/roving-focus.js +115 -0
  43. package/dist/interaction/roving-focus.js.map +1 -0
  44. package/dist/messages/en.json +53 -0
  45. package/dist/messages/help/en.json +14 -0
  46. package/dist/messages/help/pl.json +14 -0
  47. package/dist/messages/pl.json +53 -0
  48. package/dist/messages.d.ts +7 -0
  49. package/dist/messages.d.ts.map +1 -0
  50. package/dist/messages.js +18 -0
  51. package/dist/messages.js.map +1 -0
  52. package/dist/player/book.d.ts +13 -0
  53. package/dist/player/book.d.ts.map +1 -0
  54. package/dist/player/book.js +65 -0
  55. package/dist/player/book.js.map +1 -0
  56. package/dist/player/help.d.ts +55 -0
  57. package/dist/player/help.d.ts.map +1 -0
  58. package/dist/player/help.js +484 -0
  59. package/dist/player/help.js.map +1 -0
  60. package/dist/player/player.d.ts +87 -0
  61. package/dist/player/player.d.ts.map +1 -0
  62. package/dist/player/player.js +1229 -0
  63. package/dist/player/player.js.map +1 -0
  64. package/dist/player/styled.d.ts +10 -0
  65. package/dist/player/styled.d.ts.map +1 -0
  66. package/dist/player/styled.js +213 -0
  67. package/dist/player/styled.js.map +1 -0
  68. package/dist/player/styles.d.ts +3 -0
  69. package/dist/player/styles.d.ts.map +1 -0
  70. package/dist/player/styles.js +355 -0
  71. package/dist/player/styles.js.map +1 -0
  72. package/dist/player/templates.d.ts +25 -0
  73. package/dist/player/templates.d.ts.map +1 -0
  74. package/dist/player/templates.js +101 -0
  75. package/dist/player/templates.js.map +1 -0
  76. package/dist/player/view.d.ts +44 -0
  77. package/dist/player/view.d.ts.map +1 -0
  78. package/dist/player/view.js +231 -0
  79. package/dist/player/view.js.map +1 -0
  80. package/dist/runtime.d.ts +45 -0
  81. package/dist/runtime.d.ts.map +1 -0
  82. package/dist/runtime.js +48 -0
  83. package/dist/runtime.js.map +1 -0
  84. package/package.json +45 -3
  85. package/src/a11y.ts +134 -0
  86. package/src/attempt/controller.ts +381 -0
  87. package/src/checker/http.ts +149 -0
  88. package/src/define.ts +114 -0
  89. package/src/element/base.ts +310 -0
  90. package/src/index.ts +18 -0
  91. package/src/interaction/index.ts +11 -0
  92. package/src/interaction/keys.ts +16 -0
  93. package/src/interaction/pick-and-place.ts +464 -0
  94. package/src/interaction/roving-focus.ts +133 -0
  95. package/src/messages/en.json +53 -0
  96. package/src/messages/help/en.json +14 -0
  97. package/src/messages/help/pl.json +14 -0
  98. package/src/messages/pl.json +53 -0
  99. package/src/messages.ts +21 -0
  100. package/src/player/book.ts +70 -0
  101. package/src/player/help.ts +585 -0
  102. package/src/player/player.ts +1368 -0
  103. package/src/player/styled.ts +247 -0
  104. package/src/player/styles.ts +355 -0
  105. package/src/player/templates.ts +142 -0
  106. package/src/player/view.ts +294 -0
  107. package/src/runtime.ts +95 -0
@@ -0,0 +1,14 @@
1
+ {
2
+ "help.label": "Pomoc do tego pytania",
3
+ "help.labelField": "Pomoc do pola {n}",
4
+ "help.labelPage": "Pomoc do tej strony",
5
+ "help.hint": "Podpowiedź ({n}/{total})",
6
+ "help.hintCost": "Kosztuje {percent}% punktów",
7
+ "help.hintItem": "Podpowiedź {n}",
8
+ "help.hintAnnounce": "Podpowiedź {n}: {text}",
9
+ "help.check": "to pytanie",
10
+ "help.checkField": "pole {n}",
11
+ "help.why": "Dlaczego?",
12
+ "error.hints_not_allowed": "W tym zadaniu nie ma podpowiedzi.",
13
+ "error.hints_exhausted": "Nie ma już więcej podpowiedzi."
14
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "loading": "Wczytywanie zadania…",
3
+ "page.heading": "Strona {n}",
4
+ "page.counter": "Strona {n} z {total}",
5
+ "page.counter.spread": "Strony {from}-{to} z {total}",
6
+ "progress.label": "Strony",
7
+ "progress.item": "Strona {n}, {state, select, done {wszystko uzupełnione} partial {częściowo uzupełniona} other {bez odpowiedzi}}",
8
+ "nav.previous": "Wstecz",
9
+ "nav.next": "Dalej",
10
+ "action.check": "Sprawdź",
11
+ "action.reset": "Zacznij od nowa",
12
+ "action.submit": "Oddaj",
13
+ "confirm.empty": "{count, plural, one {Masz # pustą odpowiedź.} few {Masz # puste odpowiedzi.} many {Masz # pustych odpowiedzi.} other {Masz # pustej odpowiedzi.}} Oddać mimo to?",
14
+ "confirm.submit": "Oddaj mimo to",
15
+ "confirm.cancel": "Wróć do odpowiedzi",
16
+ "checks.left": "{count, plural, =0 {Nie masz już sprawdzeń} one {Zostało # sprawdzenie} few {Zostały # sprawdzenia} many {Zostało # sprawdzeń} other {Zostało # sprawdzenia}}",
17
+ "result.title": "Wynik",
18
+ "result.score": "{score} z {max, plural, one {# punktu} few {# punktów} many {# punktów} other {# punktu}}",
19
+ "result.count": "{verdict}: {count}",
20
+ "result.passed": "Zaliczone",
21
+ "result.notPassed": "Jeszcze nie zaliczone",
22
+ "result.submitted": "Twoje odpowiedzi zostały oddane.",
23
+ "result.later": "Wyniki zobaczysz później.",
24
+ "result.teacher.sent": "Twoje odpowiedzi trafiły do nauczyciela.",
25
+ "result.teacher.count": "{count, plural, =0 {Żadna odpowiedź nie trafia do nauczyciela do oceny.} one {# odpowiedź trafia do nauczyciela do oceny.} few {# odpowiedzi trafiają do nauczyciela do oceny.} many {# odpowiedzi trafia do nauczyciela do oceny.} other {# odpowiedzi trafia do nauczyciela do oceny.}}",
26
+ "result.teacher.unchecked": "Odpowiedzi dla nauczyciela nie są tu sprawdzane.",
27
+ "result.practice": "Tylko do ćwiczeń: nic tu nie jest oceniane.",
28
+ "result.announce": "Wynik: {score}.",
29
+ "result.countAnnounce": "{verdict}: {count}.",
30
+ "verdict.correct": "Dobrze",
31
+ "verdict.partial": "Częściowo dobrze",
32
+ "verdict.incorrect": "Jeszcze nie",
33
+ "verdict.empty": "Brak odpowiedzi",
34
+ "timer.label": "Pozostały czas",
35
+ "timer.minutes": "{minutes, plural, one {Została # minuta} few {Zostały # minuty} many {Zostało # minut} other {Zostało # minuty}}",
36
+ "timer.expired": "Czas minął. Oddajemy twoje odpowiedzi.",
37
+ "unsupported": "Ta część zadania nie działa w tym odtwarzaczu.",
38
+ "error.invalid_request": "Nie udało się wysłać odpowiedzi. Spróbuj jeszcze raz.",
39
+ "error.unauthorized": "Nie udało się potwierdzić, kim jesteś. Zaloguj się i spróbuj jeszcze raz.",
40
+ "error.check_not_allowed": "W tym zadaniu nie można sprawdzać odpowiedzi.",
41
+ "error.checks_exhausted": "Nie masz już sprawdzeń.",
42
+ "error.not_found": "Nie znaleziono tego zadania.",
43
+ "error.method_not_allowed": "Serwer zadania odrzucił prośbę.",
44
+ "error.attempt_closed": "Te odpowiedzi zostały już oddane.",
45
+ "error.payload_too_large": "Odpowiedzi są za długie, żeby je wysłać.",
46
+ "error.internal_error": "Nie udało się połączyć z serwerem zadania. Spróbuj za chwilę.",
47
+ "error.no_checker": "Tego zadania nie można tu sprawdzić.",
48
+ "error.load_failed": "Nie udało się wczytać zadania.",
49
+ "error.view_invalid": "Plik zadania jest uszkodzony.",
50
+ "error.integrity_mismatch": "Plik zadania nie przeszedł weryfikacji, więc nie został otwarty.",
51
+ "error.source_needs_compiler": "To zadanie wymaga pełnej wersji skryptu Astrolabe.",
52
+ "error.source_invalid": "To zadanie nie jest poprawnie zapisane, więc nie da się go wyświetlić."
53
+ }
@@ -0,0 +1,7 @@
1
+ import type { I18n, MessageCatalog, Translate } from '@astl/core';
2
+ /** i18n namespace of the player chrome and of strings shared by all elements (verdict words). */
3
+ export declare const PLAYER_NAMESPACE = "astl.player";
4
+ export declare const playerMessages: readonly MessageCatalog[];
5
+ /** Looks a key up in `namespace` first, then in the shared player namespace, else returns the key. */
6
+ export declare function elementTranslator(i18n: I18n, locale: string, namespace: string): Translate;
7
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIlE,iGAAiG;AACjG,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C,eAAO,MAAM,cAAc,EAAE,SAAS,cAAc,EAGnD,CAAC;AAEF,sGAAsG;AACtG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAO1F"}
@@ -0,0 +1,18 @@
1
+ import en from './messages/en.json' with { type: 'json' };
2
+ import pl from './messages/pl.json' with { type: 'json' };
3
+ /** i18n namespace of the player chrome and of strings shared by all elements (verdict words). */
4
+ export const PLAYER_NAMESPACE = 'astl.player';
5
+ export const playerMessages = [
6
+ { namespace: PLAYER_NAMESPACE, locale: 'en', messages: en },
7
+ { namespace: PLAYER_NAMESPACE, locale: 'pl', messages: pl },
8
+ ];
9
+ /** Looks a key up in `namespace` first, then in the shared player namespace, else returns the key. */
10
+ export function elementTranslator(i18n, locale, namespace) {
11
+ return (key, params) => {
12
+ const own = i18n.t(locale, namespace, key, params);
13
+ return own !== key || namespace === PLAYER_NAMESPACE
14
+ ? own
15
+ : i18n.t(locale, PLAYER_NAMESPACE, key, params);
16
+ };
17
+ }
18
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1D,OAAO,EAAE,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAE1D,iGAAiG;AACjG,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE9C,MAAM,CAAC,MAAM,cAAc,GAA8B;IACvD,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3D,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;CAC5D,CAAC;AAEF,sGAAsG;AACtG,MAAM,UAAU,iBAAiB,CAAC,IAAU,EAAE,MAAc,EAAE,SAAiB;IAC7E,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACrB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACnD,OAAO,GAAG,KAAK,GAAG,IAAI,SAAS,KAAK,gBAAgB;YAClD,CAAC,CAAC,GAAG;YACL,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** Adopts the stylesheet of spreads in a player's root, once. */
2
+ export declare function adoptBookSheet(root: Node): void;
3
+ /**
4
+ * Tells `spread` whether `host` is wide enough for a spread (in the root font size), now and on every resize. The
5
+ * observer is the caller's to disconnect, and to observe `host` again when it is connected again.
6
+ */
7
+ export declare function watchSpread(host: HTMLElement, spread: (wide: boolean) => void): ResizeObserver;
8
+ /**
9
+ * The pages of a new spread come in from the side of travel (`direction` 1 forwards, mirrored right to left); they just
10
+ * appear with reduced motion or forced colours.
11
+ */
12
+ export declare function turn(pages: readonly HTMLElement[], direction: 1 | -1, rtl: boolean): void;
13
+ //# sourceMappingURL=book.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"book.d.ts","sourceRoot":"","sources":["../../src/player/book.ts"],"names":[],"mappings":"AA6BA,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAI/C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,cAAc,CAW9F;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI,CAYzF"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * A book (`kind="book"`) in the player, in a module of its own: a view that is no book never loads it. It says when the
3
+ * player is wide enough for a spread, two pages side by side, draws the spread and slides the pages of a new one in.
4
+ * Without it (or when its chunk fails) a book plays one page at a time, as an exercise.
5
+ */
6
+ import { css } from 'lit';
7
+ /** Narrowest player (rem) that shows a book a spread at a time; narrower, one page at a time. */
8
+ const SPREAD_MIN_REM = 56;
9
+ /** A spread's turn: its pages come in from the side of travel. */
10
+ const TURN_MS = 240;
11
+ const TURN_DISTANCE_REM = 1.5;
12
+ /** A spread: two pages side by side (the first on the start side), a line between them as the spine. */
13
+ const bookSheet = css `
14
+ .root[data-spread] > * {
15
+ max-inline-size: 1240px;
16
+ }
17
+ .root[data-spread] astl-doc {
18
+ display: grid;
19
+ grid-template-columns: repeat(2, minmax(0, 1fr));
20
+ column-gap: var(--astl-space-5);
21
+ }
22
+ .root[data-spread] astl-doc > astl-page:not([hidden]) + astl-page:not([hidden]) {
23
+ border-inline-start: var(--astl-outline-width) solid var(--astl-line);
24
+ padding-inline-start: var(--astl-space-5);
25
+ }
26
+ `.styleSheet;
27
+ /** Adopts the stylesheet of spreads in a player's root, once. */
28
+ export function adoptBookSheet(root) {
29
+ if (bookSheet !== undefined && root instanceof ShadowRoot && !root.adoptedStyleSheets.includes(bookSheet)) {
30
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, bookSheet];
31
+ }
32
+ }
33
+ /**
34
+ * Tells `spread` whether `host` is wide enough for a spread (in the root font size), now and on every resize. The
35
+ * observer is the caller's to disconnect, and to observe `host` again when it is connected again.
36
+ */
37
+ export function watchSpread(host, spread) {
38
+ const measure = (width) => {
39
+ const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
40
+ spread(width >= SPREAD_MIN_REM * rem);
41
+ };
42
+ const observer = new ResizeObserver(([entry]) => {
43
+ if (entry !== undefined)
44
+ measure(entry.contentRect.width);
45
+ });
46
+ observer.observe(host);
47
+ measure(host.clientWidth);
48
+ return observer;
49
+ }
50
+ /**
51
+ * The pages of a new spread come in from the side of travel (`direction` 1 forwards, mirrored right to left); they just
52
+ * appear with reduced motion or forced colours.
53
+ */
54
+ export function turn(pages, direction, rtl) {
55
+ if (matchMedia('(prefers-reduced-motion: reduce), (forced-colors: active)').matches)
56
+ return;
57
+ const offset = `translateX(${(rtl ? -direction : direction) * TURN_DISTANCE_REM}rem)`;
58
+ for (const page of pages) {
59
+ page.animate([
60
+ { opacity: 0, transform: offset },
61
+ { opacity: 1, transform: 'none' },
62
+ ], { duration: TURN_MS, easing: 'ease-out' });
63
+ }
64
+ }
65
+ //# sourceMappingURL=book.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"book.js","sourceRoot":"","sources":["../../src/player/book.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,iGAAiG;AACjG,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,kEAAkE;AAClE,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,wGAAwG;AACxG,MAAM,SAAS,GAAG,GAAG,CAAA;;;;;;;;;;;;;CAapB,CAAC,UAAU,CAAC;AAEb,iEAAiE;AACjE,MAAM,UAAU,cAAc,CAAC,IAAU;IACvC,IAAI,SAAS,KAAK,SAAS,IAAI,IAAI,YAAY,UAAU,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1G,IAAI,CAAC,kBAAkB,GAAG,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;IACpE,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAiB,EAAE,MAA+B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+ * without it (or when its chunk fails) the exercise plays without help.
4
+ *
5
+ * Under each graded interaction that offers help (after the block holding it, for one in a line of text), and at the
6
+ * foot of each page with help of its own, a row:
7
+ * - "Podpowiedź (1/2)", one hint at a time from the checker, the cost of the next one said before it is used;
8
+ * - "Sprawdź" for that interaction alone (practice with `checkScope: 'interaction'`), counted like any check;
9
+ * - the feedback text of the last verdict, in a box of the verdict's colour and edge;
10
+ * - "Dlaczego?", a disclosure with the explanation.
11
+ * The texts come with check and submit responses as the policy says (`helpShown` in the engine); the view only says
12
+ * what there is (`HELP_ATTRIBUTES`). A row next to a floated or placed interaction floats with it, below it.
13
+ *
14
+ * What a checker sends is read as hostile, like a view: counts are checked and the HTML is cleaned like view content.
15
+ */
16
+ import { type Checker, type ComponentManifest, type ElementHelp, type MessageCatalog, type PlayerElementApi, type UrlPolicy } from '@astl/core';
17
+ import type { AttemptController } from '../attempt/controller.js';
18
+ /** The help strings of the player namespace: in this module, so a view without help never loads them. */
19
+ export declare const helpMessages: readonly MessageCatalog[];
20
+ /** What the player gives the help module: the mounted attempt, and how to check, announce and show problems. */
21
+ export interface HelpHost {
22
+ readonly controller: AttemptController;
23
+ /** The mounted elements in view order, with their page index. */
24
+ readonly mounted: readonly {
25
+ readonly element: HTMLElement & PlayerElementApi;
26
+ readonly manifest: ComponentManifest;
27
+ readonly page: number;
28
+ }[];
29
+ /** The page elements, in order. */
30
+ readonly pages: readonly HTMLElement[];
31
+ /** The UI locale. */
32
+ readonly locale: string;
33
+ readonly urlPolicy: UrlPolicy;
34
+ /** The player's shadow root, for the module's stylesheet. */
35
+ readonly root: Node;
36
+ checker(): Checker | null;
37
+ /** Checks one interaction through the player, which shows a failure; resolves either way. */
38
+ check(id: string): Promise<unknown>;
39
+ announce(message: string): void;
40
+ }
41
+ export interface Help {
42
+ /** Removes the rows and stops listening. */
43
+ destroy(): void;
44
+ }
45
+ /** What a view element offers, from its `HELP_ATTRIBUTES`; null when nothing. Costs outside 0..1 are left out. */
46
+ export declare function readHelp(el: Element): ElementHelp | null;
47
+ /**
48
+ * Help content from a checker (rich text of format 1) as clean live DOM in a `div`: cleaned in an inert document like
49
+ * a view's content, without components or other custom elements, and without styles (the engine writes none into
50
+ * help; a `style` from elsewhere is parsed under its inert name, so a strict CSP reports nothing, and goes).
51
+ */
52
+ export declare function readContent(content: string, urlPolicy: UrlPolicy): HTMLElement;
53
+ /** Mounts the rows into a mounted view and keeps them in step with the attempt. */
54
+ export declare function mountHelp(host: HelpHost): Help;
55
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/player/help.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAEL,KAAK,OAAO,EAGZ,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EAOhB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAGrB,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAOlE,yGAAyG;AACzG,eAAO,MAAM,YAAY,EAAE,SAAS,cAAc,EAGjD,CAAC;AAEF,gHAAgH;AAChH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,SAAS;QACzB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,gBAAgB,CAAC;QACjD,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;QACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,EAAE,CAAC;IACJ,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IACvC,qBAAqB;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,6DAA6D;IAC7D,Q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