@pie-players/pie-tool-dictionary 0.3.74 → 1.0.0-beta.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/README.md +5 -4
- package/custom-elements.json +187 -0
- package/dist/tool-dictionary.js +792 -963
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -6,7 +6,8 @@ Dictionary panel for the PIE assessment player. Registers
|
|
|
6
6
|
## Lookup is host-supplied
|
|
7
7
|
|
|
8
8
|
PIE ships no dictionary endpoint. The corpus behind a dictionary is licensed per
|
|
9
|
-
|
|
9
|
+
program, so a default here would bake one deployment into the package.
|
|
10
|
+
[Dictionary Languages And Services](../../docs/tools-and-accomodations/dictionary-languages-and-services.md) records where service selection, credentials and the lookup language sit.
|
|
10
11
|
|
|
11
12
|
Two ways to supply one, in precedence order:
|
|
12
13
|
|
|
@@ -28,7 +29,7 @@ that silently fails.
|
|
|
28
29
|
|
|
29
30
|
### Request
|
|
30
31
|
|
|
31
|
-
`POST` with `{ keyword, language?, max? }`. `keyword` is
|
|
32
|
+
`POST` with `{ keyword, language?, max? }`. `keyword` is normalized before it is
|
|
32
33
|
sent: whitespace collapsed, surrounding punctuation stripped, internal hyphens and
|
|
33
34
|
apostrophes kept. A selection longer than four words is refused without a request.
|
|
34
35
|
|
|
@@ -56,7 +57,7 @@ told their word is not real when the network is down.
|
|
|
56
57
|
|
|
57
58
|
The endpoint is called `same-origin`, so a route already behind the assessment's own
|
|
58
59
|
session answers with no further configuration — naming the endpoint is the whole
|
|
59
|
-
setup. A host
|
|
60
|
+
setup. A host authorizing some other way passes a `headers` function, read per request
|
|
60
61
|
so a short-lived token is fetched fresh rather than captured at mount, and one that
|
|
61
62
|
wants no ambient credentials at all passes `credentials: "omit"`. Both are properties
|
|
62
63
|
rather than attributes, and both are optional.
|
|
@@ -77,7 +78,7 @@ The two entry points have to coexist within one open panel, which is what
|
|
|
77
78
|
`termRequestId` is for. A requested term is reapplied on every sync, so the term alone
|
|
78
79
|
cannot distinguish a re-render from a fresh ask: without an id, reopening the panel
|
|
79
80
|
re-searches the term that opened it and discards whatever the learner typed since. A
|
|
80
|
-
host setting `term` directly can leave the id unset and gets term-identity
|
|
81
|
+
host setting `term` directly can leave the id unset and gets term-identity behavior,
|
|
81
82
|
which is enough to stop a re-render re-issuing.
|
|
82
83
|
|
|
83
84
|
## Properties
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "2.1.0",
|
|
3
|
+
"modules": [
|
|
4
|
+
{
|
|
5
|
+
"kind": "javascript-module",
|
|
6
|
+
"path": "dist/tool-dictionary.js",
|
|
7
|
+
"declarations": [
|
|
8
|
+
{
|
|
9
|
+
"kind": "class",
|
|
10
|
+
"description": "Dictionary panel body: a word-or-phrase field and the definitions found for it. Lookup is host-supplied, through a `lookup` function or a POST to `endpoint`, and with neither the panel says no service is configured. The toolbar shell that mounts it owns `visible` and the floating chrome, and a `term` set from a text selection opens the panel already searched.",
|
|
11
|
+
"name": "ToolDictionary",
|
|
12
|
+
"tagName": "pie-tool-dictionary",
|
|
13
|
+
"customElement": true,
|
|
14
|
+
"members": [
|
|
15
|
+
{
|
|
16
|
+
"kind": "field",
|
|
17
|
+
"name": "visible",
|
|
18
|
+
"type": {
|
|
19
|
+
"text": "boolean"
|
|
20
|
+
},
|
|
21
|
+
"default": "false",
|
|
22
|
+
"attribute": "visible"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"kind": "field",
|
|
26
|
+
"name": "toolId",
|
|
27
|
+
"type": {
|
|
28
|
+
"text": "string"
|
|
29
|
+
},
|
|
30
|
+
"default": "'dictionary'",
|
|
31
|
+
"attribute": "tool-id"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"kind": "field",
|
|
35
|
+
"name": "term",
|
|
36
|
+
"type": {
|
|
37
|
+
"text": "string"
|
|
38
|
+
},
|
|
39
|
+
"default": "''",
|
|
40
|
+
"attribute": "term"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"kind": "field",
|
|
44
|
+
"name": "termRequestId",
|
|
45
|
+
"type": {
|
|
46
|
+
"text": "string | number"
|
|
47
|
+
},
|
|
48
|
+
"description": "Identity of the current `term`, changing once per time it was asked for. Optional: a host assigning `term` directly need not mint one, and the panel falls back to the term itself. What it buys is a learner selecting the same word twice — a second request for `cat` has a new id, so it re-runs, where an unchanged `term` alone looks like a re-render.",
|
|
49
|
+
"attribute": "termrequestid"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"kind": "field",
|
|
53
|
+
"name": "endpoint",
|
|
54
|
+
"type": {
|
|
55
|
+
"text": "string"
|
|
56
|
+
},
|
|
57
|
+
"default": "''",
|
|
58
|
+
"attribute": "endpoint"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"kind": "field",
|
|
62
|
+
"name": "language",
|
|
63
|
+
"type": {
|
|
64
|
+
"text": "string"
|
|
65
|
+
},
|
|
66
|
+
"default": "''",
|
|
67
|
+
"attribute": "language"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"kind": "field",
|
|
71
|
+
"name": "lookup",
|
|
72
|
+
"type": {
|
|
73
|
+
"text": "DictionaryLookup"
|
|
74
|
+
},
|
|
75
|
+
"description": "Host-supplied resolver, preferred over `endpoint`. A property rather than an attribute because it is a function; a host with its own client passes it directly instead of routing through HTTP shaping this package guessed at.",
|
|
76
|
+
"attribute": "lookup"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"kind": "field",
|
|
80
|
+
"name": "headers",
|
|
81
|
+
"type": {
|
|
82
|
+
"text": "() => Promise<Record<string, string>> | Record<string, string>"
|
|
83
|
+
},
|
|
84
|
+
"description": "Extra request headers for the `endpoint` path, read per request so a short-lived token is fetched fresh rather than captured at mount. Only for a host whose route is not authorised by the assessment's own session: the endpoint is called `same-origin` by default, so a route behind that session needs nothing here.",
|
|
85
|
+
"attribute": "headers"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"kind": "field",
|
|
89
|
+
"name": "credentials",
|
|
90
|
+
"type": {
|
|
91
|
+
"text": "RequestCredentials"
|
|
92
|
+
},
|
|
93
|
+
"description": "Overrides the `same-origin` default for the `endpoint` path.",
|
|
94
|
+
"attribute": "credentials"
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"attributes": [
|
|
98
|
+
{
|
|
99
|
+
"name": "visible",
|
|
100
|
+
"type": {
|
|
101
|
+
"text": "boolean"
|
|
102
|
+
},
|
|
103
|
+
"default": "false",
|
|
104
|
+
"fieldName": "visible"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "tool-id",
|
|
108
|
+
"type": {
|
|
109
|
+
"text": "string"
|
|
110
|
+
},
|
|
111
|
+
"default": "'dictionary'",
|
|
112
|
+
"fieldName": "toolId"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "term",
|
|
116
|
+
"type": {
|
|
117
|
+
"text": "string"
|
|
118
|
+
},
|
|
119
|
+
"default": "''",
|
|
120
|
+
"fieldName": "term"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "termrequestid",
|
|
124
|
+
"type": {
|
|
125
|
+
"text": "string"
|
|
126
|
+
},
|
|
127
|
+
"description": "Identity of the current `term`, changing once per time it was asked for. Optional: a host assigning `term` directly need not mint one, and the panel falls back to the term itself. What it buys is a learner selecting the same word twice — a second request for `cat` has a new id, so it re-runs, where an unchanged `term` alone looks like a re-render.",
|
|
128
|
+
"fieldName": "termRequestId"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "endpoint",
|
|
132
|
+
"type": {
|
|
133
|
+
"text": "string"
|
|
134
|
+
},
|
|
135
|
+
"default": "''",
|
|
136
|
+
"fieldName": "endpoint"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "language",
|
|
140
|
+
"type": {
|
|
141
|
+
"text": "string"
|
|
142
|
+
},
|
|
143
|
+
"default": "''",
|
|
144
|
+
"fieldName": "language"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"name": "lookup",
|
|
148
|
+
"type": {
|
|
149
|
+
"text": "string"
|
|
150
|
+
},
|
|
151
|
+
"description": "Host-supplied resolver, preferred over `endpoint`. A property rather than an attribute because it is a function; a host with its own client passes it directly instead of routing through HTTP shaping this package guessed at.",
|
|
152
|
+
"fieldName": "lookup"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"name": "headers",
|
|
156
|
+
"type": {
|
|
157
|
+
"text": "string"
|
|
158
|
+
},
|
|
159
|
+
"description": "Extra request headers for the `endpoint` path, read per request so a short-lived token is fetched fresh rather than captured at mount. Only for a host whose route is not authorised by the assessment's own session: the endpoint is called `same-origin` by default, so a route behind that session needs nothing here.",
|
|
160
|
+
"fieldName": "headers"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"name": "credentials",
|
|
164
|
+
"type": {
|
|
165
|
+
"text": "string"
|
|
166
|
+
},
|
|
167
|
+
"description": "Overrides the `same-origin` default for the `endpoint` path.",
|
|
168
|
+
"fieldName": "credentials"
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
"x-pie": {
|
|
172
|
+
"shadow": "open"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
"exports": [
|
|
177
|
+
{
|
|
178
|
+
"kind": "custom-element-definition",
|
|
179
|
+
"name": "pie-tool-dictionary",
|
|
180
|
+
"declaration": {
|
|
181
|
+
"name": "ToolDictionary"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
}
|