@astl/player 0.0.0 → 0.1.1
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 +57 -0
- package/LICENSE +202 -0
- package/README.md +37 -0
- package/dist/a11y.d.ts +41 -0
- package/dist/a11y.d.ts.map +1 -0
- package/dist/a11y.js +101 -0
- package/dist/a11y.js.map +1 -0
- package/dist/attempt/controller.d.ts +104 -0
- package/dist/attempt/controller.d.ts.map +1 -0
- package/dist/attempt/controller.js +325 -0
- package/dist/attempt/controller.js.map +1 -0
- package/dist/checker/http.d.ts +17 -0
- package/dist/checker/http.d.ts.map +1 -0
- package/dist/checker/http.js +115 -0
- package/dist/checker/http.js.map +1 -0
- package/dist/define.d.ts +35 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +84 -0
- package/dist/define.js.map +1 -0
- package/dist/element/base.d.ts +83 -0
- package/dist/element/base.d.ts.map +1 -0
- package/dist/element/base.js +239 -0
- package/dist/element/base.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction/index.d.ts +12 -0
- package/dist/interaction/index.d.ts.map +1 -0
- package/dist/interaction/index.js +4 -0
- package/dist/interaction/index.js.map +1 -0
- package/dist/interaction/keys.d.ts +11 -0
- package/dist/interaction/keys.d.ts.map +1 -0
- package/dist/interaction/keys.js +13 -0
- package/dist/interaction/keys.js.map +1 -0
- package/dist/interaction/pick-and-place.d.ts +120 -0
- package/dist/interaction/pick-and-place.d.ts.map +1 -0
- package/dist/interaction/pick-and-place.js +395 -0
- package/dist/interaction/pick-and-place.js.map +1 -0
- package/dist/interaction/roving-focus.d.ts +44 -0
- package/dist/interaction/roving-focus.d.ts.map +1 -0
- package/dist/interaction/roving-focus.js +115 -0
- package/dist/interaction/roving-focus.js.map +1 -0
- package/dist/messages/en.json +53 -0
- package/dist/messages/help/en.json +14 -0
- package/dist/messages/help/pl.json +14 -0
- package/dist/messages/pl.json +53 -0
- package/dist/messages.d.ts +7 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +18 -0
- package/dist/messages.js.map +1 -0
- package/dist/player/book.d.ts +13 -0
- package/dist/player/book.d.ts.map +1 -0
- package/dist/player/book.js +65 -0
- package/dist/player/book.js.map +1 -0
- package/dist/player/help.d.ts +55 -0
- package/dist/player/help.d.ts.map +1 -0
- package/dist/player/help.js +484 -0
- package/dist/player/help.js.map +1 -0
- package/dist/player/player.d.ts +87 -0
- package/dist/player/player.d.ts.map +1 -0
- package/dist/player/player.js +1229 -0
- package/dist/player/player.js.map +1 -0
- package/dist/player/styled.d.ts +10 -0
- package/dist/player/styled.d.ts.map +1 -0
- package/dist/player/styled.js +213 -0
- package/dist/player/styled.js.map +1 -0
- package/dist/player/styles.d.ts +3 -0
- package/dist/player/styles.d.ts.map +1 -0
- package/dist/player/styles.js +355 -0
- package/dist/player/styles.js.map +1 -0
- package/dist/player/templates.d.ts +25 -0
- package/dist/player/templates.d.ts.map +1 -0
- package/dist/player/templates.js +101 -0
- package/dist/player/templates.js.map +1 -0
- package/dist/player/view.d.ts +44 -0
- package/dist/player/view.d.ts.map +1 -0
- package/dist/player/view.js +231 -0
- package/dist/player/view.js.map +1 -0
- package/dist/runtime.d.ts +45 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +48 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +57 -4
- package/src/a11y.ts +134 -0
- package/src/attempt/controller.ts +381 -0
- package/src/checker/http.ts +149 -0
- package/src/define.ts +114 -0
- package/src/element/base.ts +310 -0
- package/src/index.ts +18 -0
- package/src/interaction/index.ts +11 -0
- package/src/interaction/keys.ts +16 -0
- package/src/interaction/pick-and-place.ts +464 -0
- package/src/interaction/roving-focus.ts +133 -0
- package/src/messages/en.json +53 -0
- package/src/messages/help/en.json +14 -0
- package/src/messages/help/pl.json +14 -0
- package/src/messages/pl.json +53 -0
- package/src/messages.ts +21 -0
- package/src/player/book.ts +70 -0
- package/src/player/help.ts +585 -0
- package/src/player/player.ts +1368 -0
- package/src/player/styled.ts +247 -0
- package/src/player/styles.ts +355 -0
- package/src/player/templates.ts +142 -0
- package/src/player/view.ts +294 -0
- package/src/runtime.ts +95 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @astl/player
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2f8247b: Shorter npm description for @astl/astrolabe and keywords for all packages.
|
|
8
|
+
- Updated dependencies [2f8247b]
|
|
9
|
+
- @astl/core@0.1.1
|
|
10
|
+
- @astl/tokens@0.1.1
|
|
11
|
+
|
|
12
|
+
## 0.1.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- 402924c: A document can be a book: `<astl-doc lang="en" kind="book">`. `kind` is how it shows, never how it grades: `exercise` (the default, as before) one page at a time; `book` two pages side by side (1-2, 3-4, ...) once the player is at least 56rem wide, where "Next" and "Back" turn a spread with a short slide (none under reduced motion or forced colours) and the counter says "Pages 1-2 of 5"; narrower, one page at a time. Another value is `ATTRIBUTE_INVALID`. The compiled view and `Metadata.kind` carry the kind only when it is not `exercise`, so views and metadata of existing content stay byte for byte as they were. `DOC_KINDS`, `DocKind` and `DEFAULT_DOC_KIND` are exported from `@astl/core`. Example: `examples/book`.
|
|
17
|
+
- 97e412c: Authors' own styles, column layouts and named styles in the content format.
|
|
18
|
+
|
|
19
|
+
- `style` on every element, checked by an allow-list (`cleanStyle`, `@astl/core/declarations`): what it refuses goes with
|
|
20
|
+
a warning, `STYLE_REMOVED`. `STYLE_LOW_CONTRAST` warns about text that is hard to read.
|
|
21
|
+
- `<astl-columns>` with 2 to 4 `<astl-column>` on a page, wrapping by themselves on a phone.
|
|
22
|
+
- `<astl-style>` first in `<astl-doc>`, by `name` (applied by `class`) or `for` a tag. The engine writes them into each
|
|
23
|
+
element: a view holds only `style`.
|
|
24
|
+
- The player draws them from a chunk that only such a view loads, through the CSSOM (a strict CSP allows it), following
|
|
25
|
+
the theme, and stays within the column on any screen.
|
|
26
|
+
- The TipTap surface keeps them on every node and mark, shows them, and keeps block moves, page breaks and
|
|
27
|
+
`EditorAdapter.insert` inside a column. A paste keeps what the allow-list allows, and only classes the document defines.
|
|
28
|
+
- ba91084: `<astl-editor>` is laid out by its host: columns, bands and two states for a frame; page titles are optional.
|
|
29
|
+
|
|
30
|
+
- The work row (`part="work"`) takes two host slots: `start`, a column before the surface, and `end`, a column after the surface and the side column. A column is there only while its slot has elements (no track, no gap); from 48rem they are columns, below it `start` is above the surface and `end` below it; in another view both are hidden. Like the side column they stay in view (`--astl-editor-sticky-top`, default `--astl-space-4`, which the side column uses too) and scroll on their own when taller than the window. `--astl-editor-layout-gap` is the space between the toolbar, the status line, the work row and the preview. New parts `work`, `start` and `end`.
|
|
31
|
+
- The toolbar's icon-only buttons also have the part `icon-button`, the view switch `views`, its options `view` and the rule between groups `separator` (an element now, not a border of the group; it is drawn the same), exported by `<astl-editor>` as `toolbar-icon-button`, `toolbar-views`, `toolbar-view` and `toolbar-separator`.
|
|
32
|
+
- Frames: the hooks `--astl-editor-frame-border-width`, `--astl-editor-frame-current-border-width` (the frame keeps its size when the cursor comes in), `--astl-editor-frame-tab-background`, `--astl-editor-frame-tab-ink` and `--astl-editor-frame-tab-border` draw a rest state and the cursor's; defaults are today's look, a frame with issues keeps its dashed colour, the tab with the cursor stays the accent. The frame with the cursor has `data-astl-current` in the light DOM, for a host that draws a line from it.
|
|
33
|
+
- Page titles are optional. A page without a label shows its number and a small "Add title" button before "Join with page n" and "Delete page"; it shows the field (placeholder "Page title", named "Title of page 2", no visible label) and focuses it, and an empty field goes again on blur without changing the document. With a label, the field has a "Remove title" button: one undo step, the focus moves to "Add title", the notice line says "Removed the title of page 2". New hooks `--astl-editor-page-number-{font-family,size,letter-spacing,text-transform}` and `--astl-editor-page-title-{font-family,size,weight}`. New messages `surface.pageAddTitle`, `surface.pageRemoveTitle`, `surface.pageTitleOf` and `surface.pageTitleRemoved`.
|
|
34
|
+
- The player's generated "Page n" heading (a page without a label in a view of several pages) is visually hidden, still a heading in the accessibility tree that takes the focus; labelled pages are unchanged.
|
|
35
|
+
- The inspector's header shows the type's icon and name, the `id` in a monospace chip and icon buttons "Move up", "Move down" and "Delete" (their texts are the names and tooltips); under it the element's own issues as banners (icon, severity word, the sentence its frame shows). Parts `header`, `issue`, `field`, `label` and `id`. `--astl-inspector-columns` (default 1): with 2, selects, numbers and short texts sit side by side and everything else spans the row.
|
|
36
|
+
|
|
37
|
+
Changed:
|
|
38
|
+
|
|
39
|
+
- The inspector's per-element look field is "Element style" ("Styl elementu", message `inspector.styleTemplate`), not "Look" ("Wygląd").
|
|
40
|
+
- On the surface the page head has no visible title label: `.astl-page-title` is gone and `.astl-page-field` is a `div` that holds the title field and "Remove title"; a page without a label has no title field until "Add title".
|
|
41
|
+
- 6a4f220: The first release on npm, under the scope `@astl`: `@astl/astrolabe` with everything on by default, and the single packages it is built from, all at one version.
|
|
42
|
+
- 64af38f: Help for students. Three elements of the content format, inside a graded component or on a page: `<astl-hint cost>` (hints on request, one at a time, each costing a share of the points), `<astl-explanation>` (under "Why?" after a check) and `<astl-feedback when="correct|incorrect|partial|omitted">` (a text by the verdict). Compiling moves them into the key (`AnswerKey.help`); the view keeps only what is offered (`hints`, `explanation`, `feedback`). `AttemptPolicy` gets optional `hints`, `checkScope`, `feedback` and `explanations`, whose defaults by mode (`helpPolicy`, `PRACTICE_POLICY`, `TEST_POLICY`) keep old hosts working. The protocol gets `check({ answers, element })` for one interaction, `feedback` and `explanations` on responses, and `POST /hint` (`Checker.hint`, `hints_not_allowed`, `hints_exhausted`); grading takes `hintsUsed`. The server binding serves all of it and records hints with `AttemptStore.recordHint`. The player loads its help module only for views with help: "Hint (1/2)" with the cost said first, "Check" of one interaction, a feedback box by the verdict, "Why?", a page's help at its foot. The editor's card has "Help for students" (hints with cost and order, the explanation, the four feedback texts), "Elements" has "Hint", "Explanation" and "Feedback", the surface shows labelled boxes, and the preview plays them in practice. New issues: `HINT_COST_INVALID`, `FEEDBACK_WHEN_INVALID`, `FEEDBACK_DUPLICATE`, `EXPLANATION_DUPLICATE`, `HELP_UNGRADED`, `HELP_EMPTY`.
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [402924c]
|
|
47
|
+
- Updated dependencies [97e412c]
|
|
48
|
+
- Updated dependencies [ec2a249]
|
|
49
|
+
- Updated dependencies [cfa6485]
|
|
50
|
+
- Updated dependencies [4611aeb]
|
|
51
|
+
- Updated dependencies [6a4f220]
|
|
52
|
+
- Updated dependencies [c500ae1]
|
|
53
|
+
- Updated dependencies [871b57a]
|
|
54
|
+
- Updated dependencies [3a4945c]
|
|
55
|
+
- Updated dependencies [64af38f]
|
|
56
|
+
- @astl/core@0.1.0
|
|
57
|
+
- @astl/tokens@0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @astl/player
|
|
2
|
+
|
|
3
|
+
`<astl-player>` runtime, element base classes, attempt controller, checkers and a11y helpers. Contains no answer
|
|
4
|
+
logic.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @astl/player @astl/components
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Use
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { builtInElements } from '@astl/components/elements';
|
|
16
|
+
import { definePlayer } from '@astl/player';
|
|
17
|
+
|
|
18
|
+
definePlayer({ elements: builtInElements }); // or only some of them
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<!-- A view compiled on your server and graded by its endpoint -->
|
|
23
|
+
<astl-player locale="en" src="/v/3b1f....html" integrity="3b1f..." endpoint="/api/attempts/123"></astl-player>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The elements load lazily, one chunk each, so a page downloads only the components it shows.
|
|
27
|
+
|
|
28
|
+
## This package or @astl/astrolabe
|
|
29
|
+
|
|
30
|
+
`definePlayer()` from `@astl/astrolabe/player` registers every built-in element, look and style template. Pick
|
|
31
|
+
`@astl/player` to register only the elements you use.
|
|
32
|
+
|
|
33
|
+
Documentation: <https://astrolabe.starship.education/reference/player/>
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
Apache-2.0, see [LICENSE](https://github.com/starship1337/astrolabe/blob/main/LICENSE).
|
package/dist/a11y.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessibility helpers shared by the player and component elements: a visually hidden class, the verdict
|
|
3
|
+
* renderer (icon + word + border style, never colour alone) and polite announcements.
|
|
4
|
+
*/
|
|
5
|
+
import type { GroupVerdict, Translate } from '@astl/core';
|
|
6
|
+
import { type CSSResult, type TemplateResult } from 'lit';
|
|
7
|
+
/** Slot verdicts (`correct`, `incorrect`) are a subset of group verdicts. */
|
|
8
|
+
export type Verdict = GroupVerdict;
|
|
9
|
+
/** `.astl-vh`: hidden on screen, still read by screen readers. */
|
|
10
|
+
export declare const visuallyHidden: CSSResult;
|
|
11
|
+
/**
|
|
12
|
+
* Verdict styling. `[data-verdict]` sets `--astl-verdict-color`, `--astl-verdict-soft` and `--astl-verdict-border`
|
|
13
|
+
* (solid = correct, double = partial, dashed = incorrect, dotted = empty) for borders of the element that carries it.
|
|
14
|
+
*/
|
|
15
|
+
export declare const verdictStyles: CSSResult;
|
|
16
|
+
/** A decorative icon per verdict (hidden from assistive technology: the word carries the meaning). */
|
|
17
|
+
export declare function verdictIcon(verdict: Verdict): TemplateResult;
|
|
18
|
+
export interface VerdictOptions {
|
|
19
|
+
/** Hide the word visually (it stays readable, e.g. through `aria-describedby`). */
|
|
20
|
+
readonly hiddenWord?: boolean;
|
|
21
|
+
/** id of the word element, for `aria-describedby`. */
|
|
22
|
+
readonly id?: string;
|
|
23
|
+
/** `part` name of the wrapper. */
|
|
24
|
+
readonly part?: string;
|
|
25
|
+
/**
|
|
26
|
+
* UI language and direction of the word. Pass the context locale: the word is UI text, and inside content of
|
|
27
|
+
* another language it would otherwise be read with the content's voice and bidi rules.
|
|
28
|
+
*/
|
|
29
|
+
readonly lang?: string;
|
|
30
|
+
readonly dir?: 'ltr' | 'rtl';
|
|
31
|
+
}
|
|
32
|
+
/** Icon + word (`verdict.*` messages, e.g. "Dobrze", "Jeszcze nie") inside a `[data-verdict]` wrapper. */
|
|
33
|
+
export declare function renderVerdict(verdict: Verdict, t: Translate, options?: VerdictOptions): TemplateResult;
|
|
34
|
+
/**
|
|
35
|
+
* Puts a message into a polite live region. The region is emptied first and filled in a later task, so screen
|
|
36
|
+
* readers also announce a message that repeats the previous one.
|
|
37
|
+
*/
|
|
38
|
+
export declare function announce(region: HTMLElement, message: string): void;
|
|
39
|
+
/** A shared polite live region in `document.body`, for elements used without a player. */
|
|
40
|
+
export declare function documentLiveRegion(): HTMLElement;
|
|
41
|
+
//# sourceMappingURL=a11y.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y.d.ts","sourceRoot":"","sources":["../src/a11y.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,KAAK,SAAS,EAAkB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAG1E,6EAA6E;AAC7E,MAAM,MAAM,OAAO,GAAG,YAAY,CAAC;AAEnC,kEAAkE;AAClE,eAAO,MAAM,cAAc,EAAE,SAY5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,SAiC3B,CAAC;AASF,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,CAE5D;AAED,MAAM,WAAW,cAAc;IAC7B,mFAAmF;IACnF,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,sDAAsD;IACtD,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;CAC9B;AAED,0GAA0G;AAC1G,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,GAAE,cAAmB,GAAG,cAAc,CAU1G;AAID;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CASnE;AAID,0FAA0F;AAC1F,wBAAgB,kBAAkB,IAAI,WAAW,CAQhD"}
|
package/dist/a11y.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { css, html, svg } from 'lit';
|
|
2
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
3
|
+
/** `.astl-vh`: hidden on screen, still read by screen readers. */
|
|
4
|
+
export const visuallyHidden = css `
|
|
5
|
+
.astl-vh {
|
|
6
|
+
position: absolute !important;
|
|
7
|
+
inline-size: 1px !important;
|
|
8
|
+
block-size: 1px !important;
|
|
9
|
+
margin: -1px !important;
|
|
10
|
+
padding: 0 !important;
|
|
11
|
+
border: 0 !important;
|
|
12
|
+
overflow: hidden !important;
|
|
13
|
+
clip-path: inset(50%) !important;
|
|
14
|
+
white-space: nowrap !important;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
/**
|
|
18
|
+
* Verdict styling. `[data-verdict]` sets `--astl-verdict-color`, `--astl-verdict-soft` and `--astl-verdict-border`
|
|
19
|
+
* (solid = correct, double = partial, dashed = incorrect, dotted = empty) for borders of the element that carries it.
|
|
20
|
+
*/
|
|
21
|
+
export const verdictStyles = css `
|
|
22
|
+
[data-verdict='correct'] {
|
|
23
|
+
--astl-verdict-color: var(--astl-success);
|
|
24
|
+
--astl-verdict-soft: var(--astl-success-soft);
|
|
25
|
+
--astl-verdict-border: solid;
|
|
26
|
+
}
|
|
27
|
+
[data-verdict='partial'] {
|
|
28
|
+
--astl-verdict-color: var(--astl-warning);
|
|
29
|
+
--astl-verdict-soft: var(--astl-warning-soft);
|
|
30
|
+
--astl-verdict-border: double;
|
|
31
|
+
}
|
|
32
|
+
[data-verdict='incorrect'] {
|
|
33
|
+
--astl-verdict-color: var(--astl-danger);
|
|
34
|
+
--astl-verdict-soft: var(--astl-danger-soft);
|
|
35
|
+
--astl-verdict-border: dashed;
|
|
36
|
+
}
|
|
37
|
+
[data-verdict='empty'] {
|
|
38
|
+
--astl-verdict-color: var(--astl-ink-muted);
|
|
39
|
+
--astl-verdict-soft: var(--astl-surface);
|
|
40
|
+
--astl-verdict-border: dotted;
|
|
41
|
+
}
|
|
42
|
+
.astl-verdict {
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: var(--astl-space-1);
|
|
46
|
+
color: var(--astl-verdict-color);
|
|
47
|
+
font-weight: 600;
|
|
48
|
+
}
|
|
49
|
+
.astl-verdict-icon {
|
|
50
|
+
inline-size: 1.1em;
|
|
51
|
+
block-size: 1.1em;
|
|
52
|
+
flex: none;
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
const ICONS = {
|
|
56
|
+
correct: svg `<path d="M4 10.5l4 4 8-9" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>`,
|
|
57
|
+
partial: svg `<circle cx="10" cy="10" r="7" fill="none" stroke="currentColor" stroke-width="2"/><path d="M10 3a7 7 0 0 0 0 14z" fill="currentColor"/>`,
|
|
58
|
+
incorrect: svg `<path d="M5.5 5.5l9 9m0-9l-9 9" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/>`,
|
|
59
|
+
empty: svg `<circle cx="10" cy="10" r="7" fill="none" stroke="currentColor" stroke-width="2" stroke-dasharray="3 3"/>`,
|
|
60
|
+
};
|
|
61
|
+
/** A decorative icon per verdict (hidden from assistive technology: the word carries the meaning). */
|
|
62
|
+
export function verdictIcon(verdict) {
|
|
63
|
+
return html `<svg class="astl-verdict-icon" viewBox="0 0 20 20" aria-hidden="true" focusable="false">${ICONS[verdict]}</svg>`;
|
|
64
|
+
}
|
|
65
|
+
/** Icon + word (`verdict.*` messages, e.g. "Dobrze", "Jeszcze nie") inside a `[data-verdict]` wrapper. */
|
|
66
|
+
export function renderVerdict(verdict, t, options = {}) {
|
|
67
|
+
return html `<span class="astl-verdict" data-verdict=${verdict} part=${ifDefined(options.part)}
|
|
68
|
+
>${verdictIcon(verdict)}<span
|
|
69
|
+
class=${options.hiddenWord ? 'astl-vh' : 'astl-verdict-word'}
|
|
70
|
+
id=${ifDefined(options.id)}
|
|
71
|
+
lang=${ifDefined(options.lang)}
|
|
72
|
+
dir=${ifDefined(options.dir)}
|
|
73
|
+
>${t(`verdict.${verdict}`)}</span
|
|
74
|
+
></span
|
|
75
|
+
>`;
|
|
76
|
+
}
|
|
77
|
+
const pending = new WeakMap();
|
|
78
|
+
/**
|
|
79
|
+
* Puts a message into a polite live region. The region is emptied first and filled in a later task, so screen
|
|
80
|
+
* readers also announce a message that repeats the previous one.
|
|
81
|
+
*/
|
|
82
|
+
export function announce(region, message) {
|
|
83
|
+
clearTimeout(pending.get(region));
|
|
84
|
+
region.textContent = '';
|
|
85
|
+
pending.set(region, setTimeout(() => {
|
|
86
|
+
region.textContent = message;
|
|
87
|
+
}, 60));
|
|
88
|
+
}
|
|
89
|
+
let fallback = null;
|
|
90
|
+
/** A shared polite live region in `document.body`, for elements used without a player. */
|
|
91
|
+
export function documentLiveRegion() {
|
|
92
|
+
if (fallback?.isConnected)
|
|
93
|
+
return fallback;
|
|
94
|
+
fallback = document.createElement('div');
|
|
95
|
+
fallback.setAttribute('aria-live', 'polite');
|
|
96
|
+
fallback.style.cssText =
|
|
97
|
+
'position:absolute;inline-size:1px;block-size:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap';
|
|
98
|
+
document.body.append(fallback);
|
|
99
|
+
return fallback;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=a11y.js.map
|
package/dist/a11y.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y.js","sourceRoot":"","sources":["../src/a11y.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,GAAG,EAAE,IAAI,EAAE,GAAG,EAAuB,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAKzD,kEAAkE;AAClE,MAAM,CAAC,MAAM,cAAc,GAAc,GAAG,CAAA;;;;;;;;;;;;CAY3C,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAc,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiC1C,CAAC;AAEF,MAAM,KAAK,GAA8C;IACvD,OAAO,EAAE,GAAG,CAAA,iIAAiI;IAC7I,OAAO,EAAE,GAAG,CAAA,yIAAyI;IACrJ,SAAS,EAAE,GAAG,CAAA,+GAA+G;IAC7H,KAAK,EAAE,GAAG,CAAA,2GAA2G;CACt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EAAE,QAAQ,CAAC,CAAC;IAC7C,QAAQ,CAAC,KAAK,CAAC,OAAO;QACpB,sHAAsH,CAAC;IACzH,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The attempt state machine, without DOM: answers, pages, checks and submission over a Checker.
|
|
3
|
+
* The player renders it; hosts and tests can drive it directly.
|
|
4
|
+
*/
|
|
5
|
+
import { type Answers, type AttemptPolicy, type AttemptState, type Checker, type CheckResponse, type GradeResult, type JsonValue, type Snapshot, type Solution, type SubmitResponse } from '@astl/core';
|
|
6
|
+
export interface AttemptPage {
|
|
7
|
+
/** View page id. */
|
|
8
|
+
readonly id: string;
|
|
9
|
+
/** Slots answered on this page, in reading order. */
|
|
10
|
+
readonly slotIds: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export interface AttemptControllerOptions {
|
|
13
|
+
readonly policy: AttemptPolicy;
|
|
14
|
+
readonly checker: Checker;
|
|
15
|
+
readonly pages: readonly AttemptPage[];
|
|
16
|
+
/** Restored when it is valid and its `viewHash` is null or equals `viewHash`. */
|
|
17
|
+
readonly snapshot?: Snapshot | null;
|
|
18
|
+
/** Hash of the view the attempt runs on; written into snapshots. */
|
|
19
|
+
readonly viewHash?: string | null;
|
|
20
|
+
/** Clock in milliseconds, for deadlines and `savedAt`. Default `Date.now`. */
|
|
21
|
+
readonly now?: () => number;
|
|
22
|
+
}
|
|
23
|
+
export type AttemptChange = {
|
|
24
|
+
readonly type: 'state';
|
|
25
|
+
readonly state: AttemptState;
|
|
26
|
+
readonly previous: AttemptState;
|
|
27
|
+
}
|
|
28
|
+
/** Only the slots that changed; `''` = cleared. */
|
|
29
|
+
| {
|
|
30
|
+
readonly type: 'answers';
|
|
31
|
+
readonly answers: Answers;
|
|
32
|
+
} | {
|
|
33
|
+
readonly type: 'page';
|
|
34
|
+
readonly index: number;
|
|
35
|
+
readonly previous: number;
|
|
36
|
+
} | {
|
|
37
|
+
readonly type: 'result';
|
|
38
|
+
readonly response: CheckResponse | SubmitResponse;
|
|
39
|
+
}
|
|
40
|
+
/** A check of one interaction (`checkElement`): its result only, the last whole result stays. */
|
|
41
|
+
| {
|
|
42
|
+
readonly type: 'element';
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly response: CheckResponse;
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: 'reset';
|
|
47
|
+
};
|
|
48
|
+
export type AttemptListener = (change: AttemptChange) => void;
|
|
49
|
+
export declare class AttemptController {
|
|
50
|
+
#private;
|
|
51
|
+
readonly policy: AttemptPolicy;
|
|
52
|
+
readonly pages: readonly AttemptPage[];
|
|
53
|
+
readonly viewHash: string | null;
|
|
54
|
+
/** Whether the snapshot passed in was applied. */
|
|
55
|
+
readonly restored: boolean;
|
|
56
|
+
/** The checker can be swapped at any time (e.g. a host sets it after the view). */
|
|
57
|
+
checker: Checker;
|
|
58
|
+
constructor(options: AttemptControllerOptions);
|
|
59
|
+
/** The snapshot when it is valid and belongs to the view (`viewHash` null or equal), else null. */
|
|
60
|
+
static restorable(snapshot: unknown, viewHash: string | null): Snapshot | null;
|
|
61
|
+
get state(): AttemptState;
|
|
62
|
+
get answers(): Answers;
|
|
63
|
+
/** 0-based index of the current page. */
|
|
64
|
+
get page(): number;
|
|
65
|
+
get pageCount(): number;
|
|
66
|
+
get checks(): number;
|
|
67
|
+
/** null = unlimited. */
|
|
68
|
+
get checksLeft(): number | null;
|
|
69
|
+
/** The last result (practice keeps it while the student goes on). */
|
|
70
|
+
get result(): GradeResult | null;
|
|
71
|
+
get solution(): Solution | null;
|
|
72
|
+
/** The last CheckResponse or SubmitResponse. */
|
|
73
|
+
get response(): CheckResponse | SubmitResponse | null;
|
|
74
|
+
/** Answers cannot change: review, submitting or submitted. */
|
|
75
|
+
get readOnly(): boolean;
|
|
76
|
+
canCheck(): boolean;
|
|
77
|
+
canSubmit(): boolean;
|
|
78
|
+
canGoTo(index: number): boolean;
|
|
79
|
+
subscribe(listener: AttemptListener): () => void;
|
|
80
|
+
/** `ready -> active`. Called implicitly by the first answer, check or submit. */
|
|
81
|
+
start(): void;
|
|
82
|
+
/** Applies a partial update (`''` deletes) and returns the slots that actually changed. Unknown ids are ignored. */
|
|
83
|
+
setAnswers(partial: Answers): Answers;
|
|
84
|
+
goTo(index: number): boolean;
|
|
85
|
+
next(): boolean;
|
|
86
|
+
previous(): boolean;
|
|
87
|
+
/** Practice only. Grades everything, or one view page. A second call while checking joins the first. */
|
|
88
|
+
check(page?: string): Promise<CheckResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* Practice with `checkScope: 'interaction'` only: grades one interaction (a view element id), counted like any
|
|
91
|
+
* check. The response comes as an `element` change; `result` and `response` keep the last whole check.
|
|
92
|
+
*/
|
|
93
|
+
checkElement(id: string): Promise<CheckResponse>;
|
|
94
|
+
/** Final. Waits for a running check first; a second call while submitting joins the first. */
|
|
95
|
+
submit(): Promise<SubmitResponse>;
|
|
96
|
+
/** Clears answers and the last result and goes back to the first page. Not after submitting. */
|
|
97
|
+
reset(): boolean;
|
|
98
|
+
snapshot(ui?: Readonly<Record<string, JsonValue>>): Snapshot;
|
|
99
|
+
/** Slot ids without an answer, on one page or on all of them. */
|
|
100
|
+
emptySlots(page?: number): string[];
|
|
101
|
+
/** Milliseconds to the policy deadline (0 when past it); null without a deadline. */
|
|
102
|
+
timeLeft(): number | null;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/attempt/controller.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,OAAO,EAEZ,KAAK,aAAa,EAClB,KAAK,WAAW,EAGhB,KAAK,SAAS,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