@doenet/doenetml-headless 0.0.0-stage → 0.7.27-dev.867
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 +257 -2
- package/cli.d.ts +25 -0
- package/cli.js +199 -0
- package/cli.js.map +1 -0
- package/gradeState-DgaD_akY.js +269100 -0
- package/gradeState-DgaD_akY.js.map +1 -0
- package/index.d.ts +520 -0
- package/index.js +405 -0
- package/index.js.map +1 -0
- package/lib_doenetml_worker_bg.wasm +0 -0
- package/package.json +31 -4
- package/sha256-8sXzDnE0-BnWUgPS4-Dmbjs5kC.js +228 -0
- package/sha256-8sXzDnE0-BnWUgPS4-Dmbjs5kC.js.map +1 -0
- package/sha256-8sXzDnE0-Cn67cg22.js +228 -0
- package/sha256-8sXzDnE0-Cn67cg22.js.map +1 -0
package/index.js
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import { d as defaultCoreFactory, H as HeadlessError } from "./gradeState-DgaD_akY.js";
|
|
2
|
+
import { R, c, g } from "./gradeState-DgaD_akY.js";
|
|
3
|
+
function createHeadlessCore({
|
|
4
|
+
coreFactory = defaultCoreFactory,
|
|
5
|
+
...options
|
|
6
|
+
}) {
|
|
7
|
+
return coreFactory.create(options);
|
|
8
|
+
}
|
|
9
|
+
const SETTABLE_COMPONENT_TYPES = [
|
|
10
|
+
"mathInput",
|
|
11
|
+
"textInput",
|
|
12
|
+
"booleanInput",
|
|
13
|
+
"choiceInput",
|
|
14
|
+
"fractionInput",
|
|
15
|
+
"matrixInput",
|
|
16
|
+
"point"
|
|
17
|
+
];
|
|
18
|
+
async function setValue(core, target, value) {
|
|
19
|
+
const component = await resolveValueTarget(core, target);
|
|
20
|
+
const where = describeTarget(target);
|
|
21
|
+
if (!SETTABLE_COMPONENT_TYPES.includes(
|
|
22
|
+
component.componentType
|
|
23
|
+
)) {
|
|
24
|
+
throw new HeadlessError(
|
|
25
|
+
"unsupportedTarget",
|
|
26
|
+
`${where} is a <${component.componentType}>, which setValue does not set. It sets ${SETTABLE_COMPONENT_TYPES.map((t) => `<${t}>`).join(", ")}.`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
await refuseIfDisabled(core, component, where);
|
|
30
|
+
switch (component.componentType) {
|
|
31
|
+
case "mathInput":
|
|
32
|
+
await typeMath(
|
|
33
|
+
core,
|
|
34
|
+
component.componentIdx,
|
|
35
|
+
expectString(value, where),
|
|
36
|
+
where
|
|
37
|
+
);
|
|
38
|
+
return;
|
|
39
|
+
case "textInput": {
|
|
40
|
+
const text = expectString(value, where);
|
|
41
|
+
const before = await readProperty(
|
|
42
|
+
core,
|
|
43
|
+
component.componentIdx,
|
|
44
|
+
"value"
|
|
45
|
+
);
|
|
46
|
+
const alreadyHas = same(text, before);
|
|
47
|
+
await send(
|
|
48
|
+
core,
|
|
49
|
+
where,
|
|
50
|
+
{
|
|
51
|
+
componentIdx: component.componentIdx,
|
|
52
|
+
actionName: "updateImmediateValue",
|
|
53
|
+
args: { text }
|
|
54
|
+
},
|
|
55
|
+
{ alreadyHas }
|
|
56
|
+
);
|
|
57
|
+
await send(
|
|
58
|
+
core,
|
|
59
|
+
where,
|
|
60
|
+
{
|
|
61
|
+
componentIdx: component.componentIdx,
|
|
62
|
+
actionName: "updateValue"
|
|
63
|
+
},
|
|
64
|
+
{ alreadyHas }
|
|
65
|
+
);
|
|
66
|
+
await expectTaken(
|
|
67
|
+
core,
|
|
68
|
+
component.componentIdx,
|
|
69
|
+
"value",
|
|
70
|
+
text,
|
|
71
|
+
before,
|
|
72
|
+
where
|
|
73
|
+
);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
case "booleanInput": {
|
|
77
|
+
if (typeof value !== "boolean") {
|
|
78
|
+
throw invalid(where, "a <booleanInput> takes true or false");
|
|
79
|
+
}
|
|
80
|
+
const before = await readProperty(
|
|
81
|
+
core,
|
|
82
|
+
component.componentIdx,
|
|
83
|
+
"value"
|
|
84
|
+
);
|
|
85
|
+
await send(
|
|
86
|
+
core,
|
|
87
|
+
where,
|
|
88
|
+
{
|
|
89
|
+
componentIdx: component.componentIdx,
|
|
90
|
+
actionName: "updateBoolean",
|
|
91
|
+
args: { boolean: value }
|
|
92
|
+
},
|
|
93
|
+
{ alreadyHas: same(value, before) }
|
|
94
|
+
);
|
|
95
|
+
await expectTaken(
|
|
96
|
+
core,
|
|
97
|
+
component.componentIdx,
|
|
98
|
+
"value",
|
|
99
|
+
value,
|
|
100
|
+
before,
|
|
101
|
+
where
|
|
102
|
+
);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
case "choiceInput":
|
|
106
|
+
await selectChoices(core, component, value, where);
|
|
107
|
+
return;
|
|
108
|
+
case "fractionInput":
|
|
109
|
+
await typeFraction(core, component, value, where);
|
|
110
|
+
return;
|
|
111
|
+
case "matrixInput":
|
|
112
|
+
await typeMatrix(core, component, value, where);
|
|
113
|
+
return;
|
|
114
|
+
case "point":
|
|
115
|
+
await movePoint(core, component, value, where);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function submit(core, target) {
|
|
120
|
+
const component = await resolveStable(core, target);
|
|
121
|
+
const actionName = component.componentType === "answer" || component.componentType === "pretzel" ? "submitAnswer" : "submitAllAnswers";
|
|
122
|
+
await core.dispatchAction({
|
|
123
|
+
componentIdx: component.componentIdx,
|
|
124
|
+
actionName
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async function resolveStable(core, path) {
|
|
128
|
+
const resolution = await core.resolvePath(path);
|
|
129
|
+
switch (resolution.status) {
|
|
130
|
+
case "resolved":
|
|
131
|
+
return resolution.component;
|
|
132
|
+
case "notFound":
|
|
133
|
+
throw new HeadlessError(
|
|
134
|
+
"notFound",
|
|
135
|
+
`Nothing in the document answers to "${path}".`
|
|
136
|
+
);
|
|
137
|
+
case "notUnique":
|
|
138
|
+
throw new HeadlessError(
|
|
139
|
+
"noStableKey",
|
|
140
|
+
`"${path}" names more than one component from the document root, so it is not a stable key and cannot be driven. Give the component (or a container on its path) a name that is unique from the root.`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async function resolveValueTarget(core, target) {
|
|
145
|
+
if (typeof target === "string") {
|
|
146
|
+
return resolveStable(core, target);
|
|
147
|
+
}
|
|
148
|
+
const { answer: answerPath, position } = target;
|
|
149
|
+
const answer = await resolveStable(core, answerPath);
|
|
150
|
+
if (answer.componentType !== "answer") {
|
|
151
|
+
throw new HeadlessError(
|
|
152
|
+
"notFound",
|
|
153
|
+
`"${answerPath}" is a <${answer.componentType}>, not an <answer>.`
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
const inputs = (await core.getAnswers()).find(
|
|
157
|
+
(a) => a.componentIdx === answer.componentIdx
|
|
158
|
+
)?.inputs ?? [];
|
|
159
|
+
if (!Number.isInteger(position) || position < 1 || position > inputs.length) {
|
|
160
|
+
throw new HeadlessError(
|
|
161
|
+
"notFound",
|
|
162
|
+
`The answer "${answerPath}" has ${inputs.length} input${inputs.length === 1 ? "" : "s"} of its own; there is none at position ${position}.`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
return inputs[position - 1];
|
|
166
|
+
}
|
|
167
|
+
function describeTarget(target) {
|
|
168
|
+
return typeof target === "string" ? `"${target}"` : `Input ${target.position} of the answer "${target.answer}"`;
|
|
169
|
+
}
|
|
170
|
+
function invalid(where, rule) {
|
|
171
|
+
return new HeadlessError("invalidValue", `${where}: ${rule}.`);
|
|
172
|
+
}
|
|
173
|
+
function expectString(value, where) {
|
|
174
|
+
if (typeof value !== "string") {
|
|
175
|
+
throw invalid(where, "this input takes a string");
|
|
176
|
+
}
|
|
177
|
+
return value;
|
|
178
|
+
}
|
|
179
|
+
async function refuseIfDisabled(core, component, where) {
|
|
180
|
+
const { disabled, fixed, fixLocation, draggable } = await core.readProperties(component.componentIdx, [
|
|
181
|
+
"disabled",
|
|
182
|
+
"fixed",
|
|
183
|
+
"fixLocation",
|
|
184
|
+
"draggable"
|
|
185
|
+
]);
|
|
186
|
+
if (component.componentType === "point") {
|
|
187
|
+
if (fixed === true || fixLocation === true || draggable === false) {
|
|
188
|
+
throw new HeadlessError(
|
|
189
|
+
"targetDisabled",
|
|
190
|
+
`${where} is a point that cannot be moved (fixed, its location fixed, or not draggable).`
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
} else if (disabled === true) {
|
|
194
|
+
throw new HeadlessError(
|
|
195
|
+
"targetDisabled",
|
|
196
|
+
`${where} is disabled (for example, its answer has no attempts left), so it does not take a value.`
|
|
197
|
+
);
|
|
198
|
+
} else if (fixed === true) {
|
|
199
|
+
throw new HeadlessError(
|
|
200
|
+
"targetDisabled",
|
|
201
|
+
`${where} is fixed, so it does not take a value.`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async function send(core, where, action, { alreadyHas = false } = {}) {
|
|
206
|
+
const { refusedChanges } = await core.dispatchAction(action);
|
|
207
|
+
const refusal = refusedChanges[0];
|
|
208
|
+
if (refusal && !alreadyHas) {
|
|
209
|
+
throw new HeadlessError(
|
|
210
|
+
"targetDisabled",
|
|
211
|
+
refusal.reason === "fixLocation" ? `${where} did not take the value: its location comes from a component whose location is fixed.` : `${where} did not take the value: it is bound to, or extends, a component that is fixed.`
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function same(a, b) {
|
|
216
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
217
|
+
}
|
|
218
|
+
async function readProperty(core, componentIdx, propertyName) {
|
|
219
|
+
return (await core.readProperties(componentIdx, [propertyName]))[propertyName];
|
|
220
|
+
}
|
|
221
|
+
async function expectTaken(core, componentIdx, propertyName, sent, before, where) {
|
|
222
|
+
const after = await readProperty(core, componentIdx, propertyName);
|
|
223
|
+
if (same(after, before) && !same(sent, before)) {
|
|
224
|
+
throw new HeadlessError(
|
|
225
|
+
"targetDisabled",
|
|
226
|
+
`${where} did not take the value: it kept ${JSON.stringify(after)}, so its value comes from something that did not change (for example, it is bound to a fixed component).`
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
async function typeMath(core, componentIdx, latex, where) {
|
|
231
|
+
const before = await readProperty(core, componentIdx, "value");
|
|
232
|
+
await send(core, where, {
|
|
233
|
+
componentIdx,
|
|
234
|
+
actionName: "updateRawValue",
|
|
235
|
+
args: { rawRendererValue: latex }
|
|
236
|
+
});
|
|
237
|
+
const typed = await readProperty(core, componentIdx, "immediateValue");
|
|
238
|
+
await send(
|
|
239
|
+
core,
|
|
240
|
+
where,
|
|
241
|
+
{ componentIdx, actionName: "updateValue" },
|
|
242
|
+
{ alreadyHas: same(typed, before) }
|
|
243
|
+
);
|
|
244
|
+
await expectTaken(core, componentIdx, "value", typed, before, where);
|
|
245
|
+
}
|
|
246
|
+
async function selectChoices(core, input, value, where) {
|
|
247
|
+
const selectedIndices = typeof value === "number" ? [value] : value;
|
|
248
|
+
const { numChoices, selectMultiple, choicesDisabled, inline } = await core.readProperties(input.componentIdx, [
|
|
249
|
+
"numChoices",
|
|
250
|
+
"selectMultiple",
|
|
251
|
+
"choicesDisabled",
|
|
252
|
+
"inline"
|
|
253
|
+
]);
|
|
254
|
+
if (!Array.isArray(selectedIndices) || !selectedIndices.every(
|
|
255
|
+
(index) => typeof index === "number" && Number.isInteger(index) && index >= 1 && (typeof numChoices !== "number" || index <= numChoices)
|
|
256
|
+
)) {
|
|
257
|
+
throw invalid(
|
|
258
|
+
where,
|
|
259
|
+
`a <choiceInput> takes the positions of the selected choices, whole numbers from 1 to ${numChoices}`
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
const indices = selectedIndices;
|
|
263
|
+
if (new Set(indices).size !== indices.length) {
|
|
264
|
+
throw invalid(where, "a <choiceInput> takes each choice at most once");
|
|
265
|
+
}
|
|
266
|
+
if (selectMultiple !== true && indices.length > 1) {
|
|
267
|
+
throw invalid(
|
|
268
|
+
where,
|
|
269
|
+
"this <choiceInput> selects one choice; it takes one position"
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
const disabledIndex = indices.find(
|
|
273
|
+
(index) => Array.isArray(choicesDisabled) && choicesDisabled[index - 1]
|
|
274
|
+
);
|
|
275
|
+
if (disabledIndex !== void 0) {
|
|
276
|
+
throw new HeadlessError(
|
|
277
|
+
"targetDisabled",
|
|
278
|
+
`${where}: choice ${disabledIndex} is disabled, so it cannot be selected.`
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
const sent = inline === true ? indices : [...indices].sort((a, b) => a - b);
|
|
282
|
+
const before = await readProperty(
|
|
283
|
+
core,
|
|
284
|
+
input.componentIdx,
|
|
285
|
+
"selectedIndices"
|
|
286
|
+
);
|
|
287
|
+
await send(
|
|
288
|
+
core,
|
|
289
|
+
where,
|
|
290
|
+
{
|
|
291
|
+
componentIdx: input.componentIdx,
|
|
292
|
+
actionName: "updateSelectedIndices",
|
|
293
|
+
args: { selectedIndices: sent }
|
|
294
|
+
},
|
|
295
|
+
{ alreadyHas: same(sent, before) }
|
|
296
|
+
);
|
|
297
|
+
await expectTaken(
|
|
298
|
+
core,
|
|
299
|
+
input.componentIdx,
|
|
300
|
+
"selectedIndices",
|
|
301
|
+
sent,
|
|
302
|
+
before,
|
|
303
|
+
where
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
async function typeFraction(core, input, value, where) {
|
|
307
|
+
if (typeof value !== "object" || value === null || Array.isArray(value) || typeof value.numerator !== "string" || typeof value.denominator !== "string") {
|
|
308
|
+
throw invalid(
|
|
309
|
+
where,
|
|
310
|
+
"a <fractionInput> takes { numerator, denominator }, each the LaTeX typed"
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
const [numerator, denominator] = await core.getChildren(input.componentIdx);
|
|
314
|
+
const isBox = (part) => part?.componentType === "_fractionInputComponent";
|
|
315
|
+
if (!isBox(numerator) || !isBox(denominator)) {
|
|
316
|
+
throw Error(
|
|
317
|
+
`${where}: the <fractionInput> does not have the two math inputs it is expected to.`
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
await typeMath(
|
|
321
|
+
core,
|
|
322
|
+
numerator.componentIdx,
|
|
323
|
+
value.numerator,
|
|
324
|
+
`${where} (its numerator)`
|
|
325
|
+
);
|
|
326
|
+
await typeMath(
|
|
327
|
+
core,
|
|
328
|
+
denominator.componentIdx,
|
|
329
|
+
value.denominator,
|
|
330
|
+
`${where} (its denominator)`
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
async function typeMatrix(core, input, value, where) {
|
|
334
|
+
const { numRows, numColumns } = await core.readProperties(
|
|
335
|
+
input.componentIdx,
|
|
336
|
+
["numRows", "numColumns"]
|
|
337
|
+
);
|
|
338
|
+
if (!Array.isArray(value) || value.length !== numRows || !value.every(
|
|
339
|
+
(row) => Array.isArray(row) && row.length === numColumns && row.every((cell) => typeof cell === "string")
|
|
340
|
+
)) {
|
|
341
|
+
throw invalid(
|
|
342
|
+
where,
|
|
343
|
+
`a <matrixInput> takes the LaTeX of each cell as ${numRows} rows of ${numColumns} strings, its current size`
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
const cells = await core.getChildren(input.componentIdx);
|
|
347
|
+
const rows = value;
|
|
348
|
+
for (const [rowInd, row] of rows.entries()) {
|
|
349
|
+
for (const [colInd, latex] of row.entries()) {
|
|
350
|
+
const cell = cells[colInd + numColumns * rowInd];
|
|
351
|
+
if (!cell) {
|
|
352
|
+
throw Error(
|
|
353
|
+
`${where}: the <matrixInput> has no cell (${rowInd + 1}, ${colInd + 1}).`
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
await typeMath(
|
|
357
|
+
core,
|
|
358
|
+
cell.componentIdx,
|
|
359
|
+
latex,
|
|
360
|
+
`${where} (its cell in row ${rowInd + 1}, column ${colInd + 1})`
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
async function movePoint(core, component, value, where) {
|
|
366
|
+
if (!Array.isArray(value) || value.length < 2 || value.length > 3 || !value.every((x2) => typeof x2 === "number" && Number.isFinite(x2))) {
|
|
367
|
+
throw invalid(
|
|
368
|
+
where,
|
|
369
|
+
"a <point> takes [x, y] or [x, y, z], finite numbers"
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
const { numDimensions, xs } = await core.readProperties(
|
|
373
|
+
component.componentIdx,
|
|
374
|
+
["numDimensions", "xs"]
|
|
375
|
+
);
|
|
376
|
+
if (typeof numDimensions === "number" && value.length !== numDimensions) {
|
|
377
|
+
throw invalid(
|
|
378
|
+
where,
|
|
379
|
+
`this <point> has ${numDimensions} coordinates; it takes ${numDimensions} numbers`
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
const [x, y, z] = value;
|
|
383
|
+
await send(
|
|
384
|
+
core,
|
|
385
|
+
where,
|
|
386
|
+
{
|
|
387
|
+
componentIdx: component.componentIdx,
|
|
388
|
+
actionName: "movePoint",
|
|
389
|
+
args: z === void 0 ? { x, y } : { x, y, z }
|
|
390
|
+
},
|
|
391
|
+
{ alreadyHas: same(value, xs) }
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
export {
|
|
395
|
+
HeadlessError,
|
|
396
|
+
R as RESOLVER_WASM_ENV,
|
|
397
|
+
SETTABLE_COMPONENT_TYPES,
|
|
398
|
+
c as check,
|
|
399
|
+
createHeadlessCore,
|
|
400
|
+
defaultCoreFactory,
|
|
401
|
+
g as gradeState,
|
|
402
|
+
setValue,
|
|
403
|
+
submit
|
|
404
|
+
};
|
|
405
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/createHeadlessCore.ts","../src/setValue.ts"],"sourcesContent":["import type {\n HeadlessCore,\n HeadlessCoreFactory,\n HeadlessCoreOptions,\n} from \"@doenet/utils\";\nimport { defaultCoreFactory } from \"./defaultCore\";\n\nexport type CreateHeadlessCoreOptions = HeadlessCoreOptions & {\n /** The core to run. Defaults to the JavaScript core. */\n coreFactory?: HeadlessCoreFactory;\n};\n\n/**\n * Create a core running `doenetML` without a browser.\n *\n * A `savedState` is applied as it is, without the checks `gradeState` makes;\n * use `gradeState` to grade one. Call `terminate()` on the core when done.\n */\nexport function createHeadlessCore({\n coreFactory = defaultCoreFactory,\n ...options\n}: CreateHeadlessCoreOptions): Promise<HeadlessCore> {\n return coreFactory.create(options);\n}\n","import type {\n HeadlessAction,\n HeadlessComponent,\n HeadlessCore,\n} from \"@doenet/utils\";\nimport { HeadlessError } from \"./errors\";\n\n/**\n * What `setValue` drives: either a path from the document root (`\"x\"`,\n * `\"$r[3].g.mi\"`), or an answer's path and the position of one of the\n * answer's own inputs, numbered from 1. The second form reaches an input that\n * has no name of its own, such as the one `<answer name=\"ans\">x</answer>`\n * makes for itself.\n *\n * Either way the path must reach exactly one component from the root, each\n * step resolving uniquely from the one before: that is the component's stable\n * key. A name that is not unique from the root is no key, so its component\n * cannot be driven, and neither can an input of an answer that has none.\n */\nexport type ValueTarget = string | { answer: string; position: number };\n\n/**\n * The raw value `setValue` gives a component, by its type: what a student\n * enters or drags to, not the response an answer makes of it.\n *\n * - `mathInput`: the LaTeX typed, a string.\n * - `textInput`: the text, a string.\n * - `booleanInput`: a boolean.\n * - `choiceInput`: the selected choices' positions, numbered from 1 (an array,\n * or one number), in the order the reader sees the choices: one unless the\n * input has `selectMultiple`, each at most once, none of a disabled choice.\n * A list of choices selects them in increasing position, as its checkboxes\n * do; an inline one in the order given, as its dropdown keeps the order\n * they were picked.\n * - `fractionInput`: `{ numerator, denominator }`, each the LaTeX typed.\n * - `matrixInput`: the LaTeX of each cell, as an array of rows; its shape must\n * be the matrix's.\n * - `point`: its coordinates, `[x, y]` or `[x, y, z]` as the point has,\n * moved as a drag does.\n */\nexport type ValueToSet =\n | string\n | boolean\n | number\n | number[]\n | string[][]\n | { numerator: string; denominator: string };\n\n/** The component types `setValue` sets: the inputs it knows, and `<point>`. */\nexport const SETTABLE_COMPONENT_TYPES = [\n \"mathInput\",\n \"textInput\",\n \"booleanInput\",\n \"choiceInput\",\n \"fractionInput\",\n \"matrixInput\",\n \"point\",\n] as const;\n\n/**\n * Give an input or a point a raw value, with the actions its renderer would\n * send, and wait for the document to settle.\n *\n * Refuses, with a `HeadlessError`, a target with no stable key (`noStableKey`)\n * or that names nothing (`notFound`), a component of a type it does not know\n * (`unsupportedTarget`, never a guess), a disabled or fixed input, a point that\n * cannot be moved, or a disabled choice (`targetDisabled`), and a value of the wrong\n * shape (`invalidValue`). Refuses as `targetDisabled`, too, a value that was\n * sent and not taken: an input bound to a fixed component keeps its value,\n * and a point that extends one with a fixed location stays put. A value the\n * target already has is not refused for coming from a fixed source. Where the\n * document refuses part of the\n * change, the rest of it may have been made. Not caught: a value the document\n * turns into exactly the value the input already has is refused, and a point\n * whose coordinates come from a fixed point stays put without a refusal (see\n * the README).\n */\nexport async function setValue(\n core: HeadlessCore,\n target: ValueTarget,\n value: ValueToSet,\n): Promise<void> {\n const component = await resolveValueTarget(core, target);\n const where = describeTarget(target);\n\n if (\n !(SETTABLE_COMPONENT_TYPES as readonly string[]).includes(\n component.componentType,\n )\n ) {\n throw new HeadlessError(\n \"unsupportedTarget\",\n `${where} is a <${component.componentType}>, which setValue does not set. It sets ${SETTABLE_COMPONENT_TYPES.map((t) => `<${t}>`).join(\", \")}.`,\n );\n }\n\n await refuseIfDisabled(core, component, where);\n\n switch (component.componentType) {\n case \"mathInput\":\n await typeMath(\n core,\n component.componentIdx,\n expectString(value, where),\n where,\n );\n return;\n case \"textInput\": {\n const text = expectString(value, where);\n const before = await readProperty(\n core,\n component.componentIdx,\n \"value\",\n );\n const alreadyHas = same(text, before);\n await send(\n core,\n where,\n {\n componentIdx: component.componentIdx,\n actionName: \"updateImmediateValue\",\n args: { text },\n },\n { alreadyHas },\n );\n await send(\n core,\n where,\n {\n componentIdx: component.componentIdx,\n actionName: \"updateValue\",\n },\n { alreadyHas },\n );\n await expectTaken(\n core,\n component.componentIdx,\n \"value\",\n text,\n before,\n where,\n );\n return;\n }\n case \"booleanInput\": {\n if (typeof value !== \"boolean\") {\n throw invalid(where, \"a <booleanInput> takes true or false\");\n }\n const before = await readProperty(\n core,\n component.componentIdx,\n \"value\",\n );\n await send(\n core,\n where,\n {\n componentIdx: component.componentIdx,\n actionName: \"updateBoolean\",\n args: { boolean: value },\n },\n { alreadyHas: same(value, before) },\n );\n await expectTaken(\n core,\n component.componentIdx,\n \"value\",\n value,\n before,\n where,\n );\n return;\n }\n case \"choiceInput\":\n await selectChoices(core, component, value, where);\n return;\n case \"fractionInput\":\n await typeFraction(core, component, value, where);\n return;\n case \"matrixInput\":\n await typeMatrix(core, component, value, where);\n return;\n case \"point\":\n await movePoint(core, component, value, where);\n return;\n }\n}\n\n/**\n * Submit an answer, a `<pretzel>`, or everything under a section-wide check\n * work (any component with a check-work button for what is inside it: a\n * `<section>`, the `<document>`, and so on), as its check-work button does.\n * `target` is a path from the root, with the same stable-key rule as\n * `setValue`.\n */\nexport async function submit(\n core: HeadlessCore,\n target: string,\n): Promise<void> {\n const component = await resolveStable(core, target);\n const actionName =\n component.componentType === \"answer\" ||\n component.componentType === \"pretzel\"\n ? \"submitAnswer\"\n : \"submitAllAnswers\";\n await core.dispatchAction({\n componentIdx: component.componentIdx,\n actionName,\n });\n}\n\nasync function resolveStable(\n core: HeadlessCore,\n path: string,\n): Promise<HeadlessComponent> {\n const resolution = await core.resolvePath(path);\n switch (resolution.status) {\n case \"resolved\":\n return resolution.component;\n case \"notFound\":\n throw new HeadlessError(\n \"notFound\",\n `Nothing in the document answers to \"${path}\".`,\n );\n case \"notUnique\":\n throw new HeadlessError(\n \"noStableKey\",\n `\"${path}\" names more than one component from the document root, so it is not a stable key and cannot be driven. Give the component (or a container on its path) a name that is unique from the root.`,\n );\n }\n}\n\nasync function resolveValueTarget(\n core: HeadlessCore,\n target: ValueTarget,\n): Promise<HeadlessComponent> {\n if (typeof target === \"string\") {\n return resolveStable(core, target);\n }\n const { answer: answerPath, position } = target;\n const answer = await resolveStable(core, answerPath);\n if (answer.componentType !== \"answer\") {\n throw new HeadlessError(\n \"notFound\",\n `\"${answerPath}\" is a <${answer.componentType}>, not an <answer>.`,\n );\n }\n const inputs =\n (await core.getAnswers()).find(\n (a) => a.componentIdx === answer.componentIdx,\n )?.inputs ?? [];\n if (\n !Number.isInteger(position) ||\n position < 1 ||\n position > inputs.length\n ) {\n throw new HeadlessError(\n \"notFound\",\n `The answer \"${answerPath}\" has ${inputs.length} input${inputs.length === 1 ? \"\" : \"s\"} of its own; there is none at position ${position}.`,\n );\n }\n return inputs[position - 1];\n}\n\nfunction describeTarget(target: ValueTarget) {\n return typeof target === \"string\"\n ? `\"${target}\"`\n : `Input ${target.position} of the answer \"${target.answer}\"`;\n}\n\nfunction invalid(where: string, rule: string) {\n return new HeadlessError(\"invalidValue\", `${where}: ${rule}.`);\n}\n\nfunction expectString(value: ValueToSet, where: string): string {\n if (typeof value !== \"string\") {\n throw invalid(where, \"this input takes a string\");\n }\n return value;\n}\n\nasync function refuseIfDisabled(\n core: HeadlessCore,\n component: HeadlessComponent,\n where: string,\n) {\n // An input or point that cannot change ignores the actions sent to it, so\n // a value set on one would silently not be there. A fixed input (`fixed`\n // on it or on a container) is one, though it is not disabled.\n const { disabled, fixed, fixLocation, draggable } =\n await core.readProperties(component.componentIdx, [\n \"disabled\",\n \"fixed\",\n \"fixLocation\",\n \"draggable\",\n ]);\n if (component.componentType === \"point\") {\n if (fixed === true || fixLocation === true || draggable === false) {\n throw new HeadlessError(\n \"targetDisabled\",\n `${where} is a point that cannot be moved (fixed, its location fixed, or not draggable).`,\n );\n }\n } else if (disabled === true) {\n throw new HeadlessError(\n \"targetDisabled\",\n `${where} is disabled (for example, its answer has no attempts left), so it does not take a value.`,\n );\n } else if (fixed === true) {\n throw new HeadlessError(\n \"targetDisabled\",\n `${where} is fixed, so it does not take a value.`,\n );\n }\n}\n\n/**\n * Send an action for `setValue`, and refuse (`targetDisabled`) if the core\n * refused a change it asked for because a component is `fixed` or has\n * `fixLocation`: the target itself, or one it is bound to or extends, such as\n * the location-fixed point a `<point extend>` takes its location from. When\n * the target `alreadyHas` the value sent, a refusal changes nothing, so it is\n * not refused.\n */\nasync function send(\n core: HeadlessCore,\n where: string,\n action: HeadlessAction,\n { alreadyHas = false }: { alreadyHas?: boolean } = {},\n) {\n const { refusedChanges } = await core.dispatchAction(action);\n const refusal = refusedChanges[0];\n if (refusal && !alreadyHas) {\n throw new HeadlessError(\n \"targetDisabled\",\n refusal.reason === \"fixLocation\"\n ? `${where} did not take the value: its location comes from a component whose location is fixed.`\n : `${where} did not take the value: it is bound to, or extends, a component that is fixed.`,\n );\n }\n}\n\nfunction same(a: unknown, b: unknown) {\n return JSON.stringify(a) === JSON.stringify(b);\n}\n\nasync function readProperty(\n core: HeadlessCore,\n componentIdx: number,\n propertyName: string,\n) {\n return (await core.readProperties(componentIdx, [propertyName]))[\n propertyName\n ];\n}\n\n/**\n * Refuse (`targetDisabled`) if an input did not take the value it was sent:\n * `propertyName` still has the value it had `before`, though the value sent\n * was another. An input whose value comes from a component that does not\n * change, such as one `bindValueTo` a fixed component, keeps that\n * component's value. An input whose value changed took the value, even if\n * the document made something else of it (a bound `<math simplify>`\n * simplifying it, or a bound `<number>` writing it its own way).\n */\nasync function expectTaken(\n core: HeadlessCore,\n componentIdx: number,\n propertyName: string,\n sent: unknown,\n before: unknown,\n where: string,\n) {\n const after = await readProperty(core, componentIdx, propertyName);\n if (same(after, before) && !same(sent, before)) {\n throw new HeadlessError(\n \"targetDisabled\",\n `${where} did not take the value: it kept ${JSON.stringify(after)}, so its value comes from something that did not change (for example, it is bound to a fixed component).`,\n );\n }\n}\n\nasync function typeMath(\n core: HeadlessCore,\n componentIdx: number,\n latex: string,\n where: string,\n) {\n const before = await readProperty(core, componentIdx, \"value\");\n await send(core, where, {\n componentIdx,\n actionName: \"updateRawValue\",\n args: { rawRendererValue: latex },\n });\n // What was typed, as the math the input makes of it\n const typed = await readProperty(core, componentIdx, \"immediateValue\");\n await send(\n core,\n where,\n { componentIdx, actionName: \"updateValue\" },\n { alreadyHas: same(typed, before) },\n );\n await expectTaken(core, componentIdx, \"value\", typed, before, where);\n}\n\nasync function selectChoices(\n core: HeadlessCore,\n input: HeadlessComponent,\n value: ValueToSet,\n where: string,\n) {\n const selectedIndices = typeof value === \"number\" ? [value] : value;\n const { numChoices, selectMultiple, choicesDisabled, inline } =\n await core.readProperties(input.componentIdx, [\n \"numChoices\",\n \"selectMultiple\",\n \"choicesDisabled\",\n \"inline\",\n ]);\n if (\n !Array.isArray(selectedIndices) ||\n !selectedIndices.every(\n (index) =>\n typeof index === \"number\" &&\n Number.isInteger(index) &&\n index >= 1 &&\n (typeof numChoices !== \"number\" || index <= numChoices),\n )\n ) {\n throw invalid(\n where,\n `a <choiceInput> takes the positions of the selected choices, whole numbers from 1 to ${numChoices}`,\n );\n }\n const indices = selectedIndices as number[];\n // What a reader can select: one choice at most unless the input selects\n // several, each once, and none that is disabled. The input itself would\n // take any list, and grade a selection no reader could make.\n if (new Set(indices).size !== indices.length) {\n throw invalid(where, \"a <choiceInput> takes each choice at most once\");\n }\n if (selectMultiple !== true && indices.length > 1) {\n throw invalid(\n where,\n \"this <choiceInput> selects one choice; it takes one position\",\n );\n }\n const disabledIndex = indices.find(\n (index) => Array.isArray(choicesDisabled) && choicesDisabled[index - 1],\n );\n if (disabledIndex !== undefined) {\n throw new HeadlessError(\n \"targetDisabled\",\n `${where}: choice ${disabledIndex} is disabled, so it cannot be selected.`,\n );\n }\n // A list of checkboxes sends the selected positions in increasing order;\n // an inline dropdown sends them in the order they were picked, so for it\n // the order given here is the order picked.\n const sent = inline === true ? indices : [...indices].sort((a, b) => a - b);\n const before = await readProperty(\n core,\n input.componentIdx,\n \"selectedIndices\",\n );\n await send(\n core,\n where,\n {\n componentIdx: input.componentIdx,\n actionName: \"updateSelectedIndices\",\n args: { selectedIndices: sent },\n },\n { alreadyHas: same(sent, before) },\n );\n await expectTaken(\n core,\n input.componentIdx,\n \"selectedIndices\",\n sent,\n before,\n where,\n );\n}\n\nasync function typeFraction(\n core: HeadlessCore,\n input: HeadlessComponent,\n value: ValueToSet,\n where: string,\n) {\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n typeof value.numerator !== \"string\" ||\n typeof value.denominator !== \"string\"\n ) {\n throw invalid(\n where,\n \"a <fractionInput> takes { numerator, denominator }, each the LaTeX typed\",\n );\n }\n const [numerator, denominator] = await core.getChildren(input.componentIdx);\n // Its two boxes are math inputs of an internal type of their own.\n const isBox = (part?: HeadlessComponent) =>\n part?.componentType === \"_fractionInputComponent\";\n if (!isBox(numerator) || !isBox(denominator)) {\n throw Error(\n `${where}: the <fractionInput> does not have the two math inputs it is expected to.`,\n );\n }\n await typeMath(\n core,\n numerator.componentIdx,\n value.numerator,\n `${where} (its numerator)`,\n );\n await typeMath(\n core,\n denominator.componentIdx,\n value.denominator,\n `${where} (its denominator)`,\n );\n}\n\nasync function typeMatrix(\n core: HeadlessCore,\n input: HeadlessComponent,\n value: ValueToSet,\n where: string,\n) {\n const { numRows, numColumns } = await core.readProperties(\n input.componentIdx,\n [\"numRows\", \"numColumns\"],\n );\n if (\n !Array.isArray(value) ||\n value.length !== numRows ||\n !value.every(\n (row) =>\n Array.isArray(row) &&\n row.length === numColumns &&\n row.every((cell) => typeof cell === \"string\"),\n )\n ) {\n throw invalid(\n where,\n `a <matrixInput> takes the LaTeX of each cell as ${numRows} rows of ${numColumns} strings, its current size`,\n );\n }\n const cells = await core.getChildren(input.componentIdx);\n const rows = value as string[][];\n for (const [rowInd, row] of rows.entries()) {\n for (const [colInd, latex] of row.entries()) {\n const cell = cells[colInd + (numColumns as number) * rowInd];\n if (!cell) {\n throw Error(\n `${where}: the <matrixInput> has no cell (${rowInd + 1}, ${colInd + 1}).`,\n );\n }\n await typeMath(\n core,\n cell.componentIdx,\n latex,\n `${where} (its cell in row ${rowInd + 1}, column ${colInd + 1})`,\n );\n }\n }\n}\n\nasync function movePoint(\n core: HeadlessCore,\n component: HeadlessComponent,\n value: ValueToSet,\n where: string,\n) {\n if (\n !Array.isArray(value) ||\n value.length < 2 ||\n value.length > 3 ||\n !value.every((x) => typeof x === \"number\" && Number.isFinite(x))\n ) {\n throw invalid(\n where,\n \"a <point> takes [x, y] or [x, y, z], finite numbers\",\n );\n }\n const { numDimensions, xs } = await core.readProperties(\n component.componentIdx,\n [\"numDimensions\", \"xs\"],\n );\n if (typeof numDimensions === \"number\" && value.length !== numDimensions) {\n // A drag moves every coordinate: a coordinate left out would keep its\n // value, and one past the point's dimensions would be dropped.\n throw invalid(\n where,\n `this <point> has ${numDimensions} coordinates; it takes ${numDimensions} numbers`,\n );\n }\n const [x, y, z] = value as number[];\n await send(\n core,\n where,\n {\n componentIdx: component.componentIdx,\n actionName: \"movePoint\",\n args: z === undefined ? { x, y } : { x, y, z },\n },\n { alreadyHas: same(value, xs) },\n );\n}\n"],"names":["x"],"mappings":";;AAkBO,SAAS,mBAAmB;AAAA,EAC/B,cAAc;AAAA,EACd,GAAG;AACP,GAAqD;AACjD,SAAO,YAAY,OAAO,OAAO;AACrC;AC0BO,MAAM,2BAA2B;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAoBA,eAAsB,SAClB,MACA,QACA,OACa;AACb,QAAM,YAAY,MAAM,mBAAmB,MAAM,MAAM;AACvD,QAAM,QAAQ,eAAe,MAAM;AAEnC,MACI,CAAE,yBAA+C;AAAA,IAC7C,UAAU;AAAA,EAAA,GAEhB;AACE,UAAM,IAAI;AAAA,MACN;AAAA,MACA,GAAG,KAAK,UAAU,UAAU,aAAa,2CAA2C,yBAAyB,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC;AAAA,IAAA;AAAA,EAEpJ;AAEA,QAAM,iBAAiB,MAAM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|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
"name": "@doenet/doenetml-headless",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "Run DoenetML without a browser: grade a saved state, check a document, drive its inputs",
|
|
5
|
+
"version": "0.7.27-dev.867",
|
|
6
|
+
"license": "AGPL-3.0-or-later",
|
|
7
|
+
"homepage": "https://github.com/Doenet/DoenetML#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Doenet/DoenetML.git"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"./"
|
|
20
|
+
],
|
|
21
|
+
"bin": {
|
|
22
|
+
"doenet-headless": "./cli.js"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./index.d.ts",
|
|
27
|
+
"import": "./index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"math-expressions": "^3.0.0-alpha.1"
|
|
32
|
+
}
|
|
6
33
|
}
|