@bitflow/core 0.5.4 → 0.7.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/dist/attempt.d.ts +67 -0
- package/dist/condition.d.ts +38 -0
- package/dist/engine.d.ts +190 -0
- package/dist/errors.d.ts +28 -0
- package/dist/i18n.d.ts +35 -0
- package/dist/id.d.ts +6 -0
- package/dist/image.d.ts +40 -0
- package/dist/index.d.ts +13 -11
- package/dist/index.js +1410 -0
- package/dist/registry.d.ts +118 -0
- package/dist/schema.d.ts +431 -0
- package/dist/score.d.ts +18 -0
- package/dist/styles.d.ts +14 -0
- package/dist/theme.css +451 -0
- package/dist/validate.d.ts +19 -0
- package/dist/validateCondition.d.ts +13 -0
- package/package.json +26 -24
- package/README.md +0 -9
- package/dist/bits.d.ts +0 -128
- package/dist/bitsSchema.d.ts +0 -150
- package/dist/do.d.ts +0 -37
- package/dist/doSchema.d.ts +0 -1478
- package/dist/findLast.d.ts +0 -1
- package/dist/flow.d.ts +0 -169
- package/dist/flowSchema.d.ts +0 -2520
- package/dist/groupBy.d.ts +0 -1
- package/dist/index.cjs.js +0 -732
- package/dist/index.cjs.js.map +0 -7
- package/dist/index.esm.mjs +0 -703
- package/dist/index.esm.mjs.map +0 -7
- package/dist/lerpColor.d.ts +0 -1
- package/dist/levenshtein.d.ts +0 -1
- package/dist/uuid.d.ts +0 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { Diagnostic } from "./errors";
|
|
3
|
+
import type { AttemptSnapshot, BitflowDocument, BitResult, Locale } from "./schema";
|
|
4
|
+
/**
|
|
5
|
+
* A component supplied by a bit package.
|
|
6
|
+
*
|
|
7
|
+
* Deliberately not typed as a React component: `@bitflow/core` must stay
|
|
8
|
+
* importable from Node and must not depend on React. A React function
|
|
9
|
+
* component is structurally assignable to this, and the React layer narrows it
|
|
10
|
+
* back with a cast at the one place it renders.
|
|
11
|
+
*/
|
|
12
|
+
export type BitComponent<Props = any> = (props: Props) => unknown;
|
|
13
|
+
/**
|
|
14
|
+
* What a bit is for, which is all the engine needs to know about it:
|
|
15
|
+
* - `start`/`end` bookend a run (`end` is terminal),
|
|
16
|
+
* - `task` accepts an answer and can be evaluated and scored,
|
|
17
|
+
* - `content` is shown and clicked past (titles, explanations, inputs).
|
|
18
|
+
*/
|
|
19
|
+
export declare const BIT_KINDS: readonly ["start", "content", "task", "end"];
|
|
20
|
+
export type BitKind = (typeof BIT_KINDS)[number];
|
|
21
|
+
export type EvaluateArgs<Data, Answer> = {
|
|
22
|
+
data: Data;
|
|
23
|
+
answer: Answer;
|
|
24
|
+
};
|
|
25
|
+
export type Evaluate<Data = any, Answer = any> = (args: EvaluateArgs<Data, Answer>) => BitResult | Promise<BitResult>;
|
|
26
|
+
export type BitInfo = {
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* What every bit's learner-facing `Task` component is handed. Declared here,
|
|
32
|
+
* without React, so a bit package can type its component against the contract
|
|
33
|
+
* the flow and the standalone element both honour.
|
|
34
|
+
*/
|
|
35
|
+
export type BitTaskProps<Data = any, Answer = any> = {
|
|
36
|
+
data: Data;
|
|
37
|
+
answer?: Answer;
|
|
38
|
+
/** Present once evaluated; the view switches to showing the outcome. */
|
|
39
|
+
result?: BitResult;
|
|
40
|
+
/** Answered already, or being reviewed — render, but accept no input. */
|
|
41
|
+
readonly?: boolean;
|
|
42
|
+
locale: Locale;
|
|
43
|
+
onAnswerChange: (answer: Answer) => void;
|
|
44
|
+
/**
|
|
45
|
+
* The run so far, when there is one. Only `end` bits have any use for it —
|
|
46
|
+
* they summarise the attempt the learner just finished. A bit rendered
|
|
47
|
+
* standalone has no attempt, so anything reading this must cope without it.
|
|
48
|
+
*/
|
|
49
|
+
attempt?: AttemptSnapshot;
|
|
50
|
+
/**
|
|
51
|
+
* The document being run, paired with `attempt`. An end bit needs it to turn
|
|
52
|
+
* the node ids in a snapshot back into tasks it can show. Absent for a bit
|
|
53
|
+
* rendered on its own.
|
|
54
|
+
*/
|
|
55
|
+
flow?: BitflowDocument;
|
|
56
|
+
};
|
|
57
|
+
/** What every bit's author-facing `Form` component is handed. */
|
|
58
|
+
export type BitFormProps<Data = any> = {
|
|
59
|
+
data: Data;
|
|
60
|
+
locale: Locale;
|
|
61
|
+
onChange: (data: Data) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Validation problems for this node's data, with `path` relative to `data`,
|
|
64
|
+
* so the form can put each message next to the field that caused it.
|
|
65
|
+
*/
|
|
66
|
+
errors?: Diagnostic[];
|
|
67
|
+
};
|
|
68
|
+
export type BitDefinition<Data = any, Answer = any> = {
|
|
69
|
+
/** Matches `BitNode.type`, e.g. `"task-choice"`. */
|
|
70
|
+
type: string;
|
|
71
|
+
kind: BitKind;
|
|
72
|
+
/** Validates `BitNode.data`. The envelope schema defers to this. */
|
|
73
|
+
schema: z.ZodType<Data>;
|
|
74
|
+
/** New-node data for the editor palette. Must satisfy `schema`. */
|
|
75
|
+
defaultData: () => Data;
|
|
76
|
+
/** Palette label and one-line help, per locale. */
|
|
77
|
+
info: (locale: Locale) => BitInfo;
|
|
78
|
+
/** Required for `kind: "task"`; how an answer becomes a result. */
|
|
79
|
+
evaluate?: Evaluate<Data, Answer>;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the learner may move on from this step yet.
|
|
82
|
+
*
|
|
83
|
+
* For a step that is not graded but still has to be *done* — agreeing to
|
|
84
|
+
* take part, saying who you are. A task expresses the same thing by simply
|
|
85
|
+
* not being answered; a content bit had no way to say it at all, so a
|
|
86
|
+
* consent screen was a checkbox anyone could walk straight past.
|
|
87
|
+
*
|
|
88
|
+
* Absent means "always", which is every existing bit. Returning `false` must
|
|
89
|
+
* be accompanied by the bit rendering what is missing: the runtime only
|
|
90
|
+
* disables Next, it does not know what to say.
|
|
91
|
+
*/
|
|
92
|
+
isComplete?: (args: EvaluateArgs<Data, Answer>) => boolean;
|
|
93
|
+
/** The learner-facing view. */
|
|
94
|
+
Task?: BitComponent;
|
|
95
|
+
/** Author-facing form for the bit's evaluation settings. */
|
|
96
|
+
Evaluation?: BitComponent;
|
|
97
|
+
/** Author-facing form for the bit's feedback settings. */
|
|
98
|
+
Feedback?: BitComponent;
|
|
99
|
+
/** Renders group statistics for this bit type. */
|
|
100
|
+
Statistic?: BitComponent;
|
|
101
|
+
/** Author-facing form for the bit's content. */
|
|
102
|
+
Form?: BitComponent;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Called by a bit package at module scope. Importing the package is the single
|
|
106
|
+
* action that makes its bit usable — inside a flow and as a standalone custom
|
|
107
|
+
* element alike.
|
|
108
|
+
*
|
|
109
|
+
* Re-registering the same type replaces the previous definition rather than
|
|
110
|
+
* throwing: two bundles on one page (say the editor and a standalone bit) may
|
|
111
|
+
* legitimately both load a bit, and the definitions are equivalent.
|
|
112
|
+
*/
|
|
113
|
+
export declare const registerBit: <Data, Answer>(definition: BitDefinition<Data, Answer>) => void;
|
|
114
|
+
export declare const getBit: (type: string) => BitDefinition | undefined;
|
|
115
|
+
export declare const hasBit: (type: string) => boolean;
|
|
116
|
+
export declare const listBits: () => BitDefinition[];
|
|
117
|
+
/** Test seam; not part of the public runtime story. */
|
|
118
|
+
export declare const clearBits: () => void;
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Version of the `.bitflow` document format. Bumped only for changes a reader
|
|
4
|
+
* of an older document cannot absorb; additive optional fields do not bump it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const FLOW_SCHEMA_VERSION = 1;
|
|
7
|
+
export declare const LOCALES: readonly ["en", "de", "fr", "nl", "es", "it", "pt", "tr"];
|
|
8
|
+
export declare const LocaleSchema: z.ZodEnum<{
|
|
9
|
+
de: "de";
|
|
10
|
+
en: "en";
|
|
11
|
+
es: "es";
|
|
12
|
+
fr: "fr";
|
|
13
|
+
it: "it";
|
|
14
|
+
nl: "nl";
|
|
15
|
+
pt: "pt";
|
|
16
|
+
tr: "tr";
|
|
17
|
+
}>;
|
|
18
|
+
export type Locale = z.infer<typeof LocaleSchema>;
|
|
19
|
+
/**
|
|
20
|
+
* How a task turned out. Declared here rather than with the rest of the result
|
|
21
|
+
* types because conditions count outcomes, and the vocabulary has to exist
|
|
22
|
+
* before they can name one.
|
|
23
|
+
*/
|
|
24
|
+
export declare const BIT_RESULT_STATES: readonly ["correct", "wrong",
|
|
25
|
+
/**
|
|
26
|
+
* Not scorable: skipped, or a task whose evaluation is switched off. There is
|
|
27
|
+
* deliberately no "awaiting a teacher" state — bitflow grades in the browser
|
|
28
|
+
* and has no server, so nothing here could ever resolve one.
|
|
29
|
+
*/
|
|
30
|
+
"unknown"];
|
|
31
|
+
export declare const BitResultStateSchema: z.ZodEnum<{
|
|
32
|
+
correct: "correct";
|
|
33
|
+
unknown: "unknown";
|
|
34
|
+
wrong: "wrong";
|
|
35
|
+
}>;
|
|
36
|
+
export type BitResultState = z.infer<typeof BitResultStateSchema>;
|
|
37
|
+
/**
|
|
38
|
+
* Which tasks a count or a score is taken over.
|
|
39
|
+
*
|
|
40
|
+
* Absent means the whole attempt, which is what a whole-assessment threshold
|
|
41
|
+
* wants. A scope is what makes adaptive routing expressible: "did they pass
|
|
42
|
+
* *this section*", "of the *last three*, how many were right".
|
|
43
|
+
*/
|
|
44
|
+
export declare const ScopeSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
45
|
+
kind: z.ZodLiteral<"section">;
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
|
+
kind: z.ZodLiteral<"nodes">;
|
|
49
|
+
nodeIds: z.ZodArray<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
51
|
+
kind: z.ZodLiteral<"last">;
|
|
52
|
+
count: z.ZodNumber;
|
|
53
|
+
}, z.core.$strip>]>;
|
|
54
|
+
export type Scope = z.infer<typeof ScopeSchema>;
|
|
55
|
+
/** A value pulled out of the running attempt for a condition to compare. */
|
|
56
|
+
export declare const ValueRefSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
57
|
+
kind: z.ZodLiteral<"answer">;
|
|
58
|
+
nodeId: z.ZodString;
|
|
59
|
+
path: z.ZodOptional<z.ZodString>;
|
|
60
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
61
|
+
kind: z.ZodLiteral<"result">;
|
|
62
|
+
nodeId: z.ZodString;
|
|
63
|
+
path: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
65
|
+
kind: z.ZodLiteral<"tries">;
|
|
66
|
+
nodeId: z.ZodString;
|
|
67
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
68
|
+
kind: z.ZodLiteral<"visits">;
|
|
69
|
+
nodeId: z.ZodString;
|
|
70
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
71
|
+
kind: z.ZodLiteral<"confidence">;
|
|
72
|
+
nodeId: z.ZodString;
|
|
73
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
74
|
+
kind: z.ZodLiteral<"timeSpent">;
|
|
75
|
+
nodeId: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
77
|
+
kind: z.ZodLiteral<"timeRemaining">;
|
|
78
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
79
|
+
kind: z.ZodLiteral<"score">;
|
|
80
|
+
scope: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
81
|
+
kind: z.ZodLiteral<"section">;
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
84
|
+
kind: z.ZodLiteral<"nodes">;
|
|
85
|
+
nodeIds: z.ZodArray<z.ZodString>;
|
|
86
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
87
|
+
kind: z.ZodLiteral<"last">;
|
|
88
|
+
count: z.ZodNumber;
|
|
89
|
+
}, z.core.$strip>]>>;
|
|
90
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
91
|
+
kind: z.ZodLiteral<"scoreRatio">;
|
|
92
|
+
scope: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
93
|
+
kind: z.ZodLiteral<"section">;
|
|
94
|
+
id: z.ZodString;
|
|
95
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
96
|
+
kind: z.ZodLiteral<"nodes">;
|
|
97
|
+
nodeIds: z.ZodArray<z.ZodString>;
|
|
98
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
99
|
+
kind: z.ZodLiteral<"last">;
|
|
100
|
+
count: z.ZodNumber;
|
|
101
|
+
}, z.core.$strip>]>>;
|
|
102
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
103
|
+
kind: z.ZodLiteral<"resultCount">;
|
|
104
|
+
state: z.ZodDefault<z.ZodEnum<{
|
|
105
|
+
correct: "correct";
|
|
106
|
+
unknown: "unknown";
|
|
107
|
+
wrong: "wrong";
|
|
108
|
+
}>>;
|
|
109
|
+
scope: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
110
|
+
kind: z.ZodLiteral<"section">;
|
|
111
|
+
id: z.ZodString;
|
|
112
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
113
|
+
kind: z.ZodLiteral<"nodes">;
|
|
114
|
+
nodeIds: z.ZodArray<z.ZodString>;
|
|
115
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
116
|
+
kind: z.ZodLiteral<"last">;
|
|
117
|
+
count: z.ZodNumber;
|
|
118
|
+
}, z.core.$strip>]>>;
|
|
119
|
+
}, z.core.$strip>]>;
|
|
120
|
+
export type ValueRef = z.infer<typeof ValueRefSchema>;
|
|
121
|
+
export declare const COMPARE_OPS: readonly ["eq", "ne", "gt", "gte", "lt", "lte", "in", "notIn", "isTrue"];
|
|
122
|
+
export declare const CompareOpSchema: z.ZodEnum<{
|
|
123
|
+
eq: "eq";
|
|
124
|
+
gt: "gt";
|
|
125
|
+
gte: "gte";
|
|
126
|
+
in: "in";
|
|
127
|
+
isTrue: "isTrue";
|
|
128
|
+
lt: "lt";
|
|
129
|
+
lte: "lte";
|
|
130
|
+
ne: "ne";
|
|
131
|
+
notIn: "notIn";
|
|
132
|
+
}>;
|
|
133
|
+
export type CompareOp = z.infer<typeof CompareOpSchema>;
|
|
134
|
+
declare const ComparableSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
135
|
+
export type Comparable = z.infer<typeof ComparableSchema>;
|
|
136
|
+
export type Condition = {
|
|
137
|
+
type: "always";
|
|
138
|
+
} | {
|
|
139
|
+
type: "compare";
|
|
140
|
+
left: ValueRef;
|
|
141
|
+
op: CompareOp;
|
|
142
|
+
right?: Comparable | Comparable[];
|
|
143
|
+
} | {
|
|
144
|
+
type: "and";
|
|
145
|
+
conditions: Condition[];
|
|
146
|
+
} | {
|
|
147
|
+
type: "or";
|
|
148
|
+
conditions: Condition[];
|
|
149
|
+
} | {
|
|
150
|
+
type: "not";
|
|
151
|
+
condition: Condition;
|
|
152
|
+
};
|
|
153
|
+
export declare const ConditionSchema: z.ZodType<Condition>;
|
|
154
|
+
export declare const PositionSchema: z.ZodObject<{
|
|
155
|
+
x: z.ZodNumber;
|
|
156
|
+
y: z.ZodNumber;
|
|
157
|
+
}, z.core.$strip>;
|
|
158
|
+
export type Position = z.infer<typeof PositionSchema>;
|
|
159
|
+
/**
|
|
160
|
+
* A node in the flow. `type` names a bit ("task-choice", "title-simple", …)
|
|
161
|
+
* and `data` is owned by that bit's own schema — the envelope deliberately
|
|
162
|
+
* does not look inside it, so a document round-trips through a host that has
|
|
163
|
+
* not loaded every bit package.
|
|
164
|
+
*/
|
|
165
|
+
export declare const BitNodeSchema: z.ZodObject<{
|
|
166
|
+
id: z.ZodString;
|
|
167
|
+
type: z.ZodString;
|
|
168
|
+
position: z.ZodObject<{
|
|
169
|
+
x: z.ZodNumber;
|
|
170
|
+
y: z.ZodNumber;
|
|
171
|
+
}, z.core.$strip>;
|
|
172
|
+
data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
173
|
+
pool: z.ZodOptional<z.ZodString>;
|
|
174
|
+
section: z.ZodOptional<z.ZodString>;
|
|
175
|
+
}, z.core.$strip>;
|
|
176
|
+
export type BitNode = z.infer<typeof BitNodeSchema>;
|
|
177
|
+
export declare const BitEdgeSchema: z.ZodObject<{
|
|
178
|
+
id: z.ZodString;
|
|
179
|
+
source: z.ZodString;
|
|
180
|
+
target: z.ZodString;
|
|
181
|
+
sourceHandle: z.ZodOptional<z.ZodString>;
|
|
182
|
+
targetHandle: z.ZodOptional<z.ZodString>;
|
|
183
|
+
label: z.ZodOptional<z.ZodString>;
|
|
184
|
+
condition: z.ZodOptional<z.ZodType<Condition, unknown, z.core.$ZodTypeInternals<Condition, unknown>>>;
|
|
185
|
+
resetTarget: z.ZodOptional<z.ZodEnum<{
|
|
186
|
+
answer: "answer";
|
|
187
|
+
result: "result";
|
|
188
|
+
}>>;
|
|
189
|
+
}, z.core.$strip>;
|
|
190
|
+
export type BitEdge = z.infer<typeof BitEdgeSchema>;
|
|
191
|
+
export declare const ViewportSchema: z.ZodObject<{
|
|
192
|
+
x: z.ZodNumber;
|
|
193
|
+
y: z.ZodNumber;
|
|
194
|
+
zoom: z.ZodNumber;
|
|
195
|
+
}, z.core.$strip>;
|
|
196
|
+
export type Viewport = z.infer<typeof ViewportSchema>;
|
|
197
|
+
export declare const BitflowMetaSchema: z.ZodObject<{
|
|
198
|
+
id: z.ZodString;
|
|
199
|
+
title: z.ZodDefault<z.ZodString>;
|
|
200
|
+
description: z.ZodOptional<z.ZodString>;
|
|
201
|
+
locale: z.ZodDefault<z.ZodEnum<{
|
|
202
|
+
de: "de";
|
|
203
|
+
en: "en";
|
|
204
|
+
es: "es";
|
|
205
|
+
fr: "fr";
|
|
206
|
+
it: "it";
|
|
207
|
+
nl: "nl";
|
|
208
|
+
pt: "pt";
|
|
209
|
+
tr: "tr";
|
|
210
|
+
}>>;
|
|
211
|
+
askConfidence: z.ZodDefault<z.ZodBoolean>;
|
|
212
|
+
askReasoning: z.ZodDefault<z.ZodBoolean>;
|
|
213
|
+
pools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
214
|
+
id: z.ZodString;
|
|
215
|
+
label: z.ZodDefault<z.ZodString>;
|
|
216
|
+
draw: z.ZodNumber;
|
|
217
|
+
shuffle: z.ZodDefault<z.ZodBoolean>;
|
|
218
|
+
}, z.core.$strip>>>;
|
|
219
|
+
sections: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
220
|
+
id: z.ZodString;
|
|
221
|
+
label: z.ZodDefault<z.ZodString>;
|
|
222
|
+
markdown: z.ZodDefault<z.ZodString>;
|
|
223
|
+
}, z.core.$strip>>>;
|
|
224
|
+
navigation: z.ZodDefault<z.ZodEnum<{
|
|
225
|
+
back: "back";
|
|
226
|
+
free: "free";
|
|
227
|
+
linear: "linear";
|
|
228
|
+
}>>;
|
|
229
|
+
allowSkip: z.ZodDefault<z.ZodBoolean>;
|
|
230
|
+
timeLimit: z.ZodOptional<z.ZodNumber>;
|
|
231
|
+
}, z.core.$strip>;
|
|
232
|
+
export type BitflowMeta = z.infer<typeof BitflowMetaSchema>;
|
|
233
|
+
export declare const BitflowDocumentSchema: z.ZodObject<{
|
|
234
|
+
version: z.ZodLiteral<1>;
|
|
235
|
+
meta: z.ZodObject<{
|
|
236
|
+
id: z.ZodString;
|
|
237
|
+
title: z.ZodDefault<z.ZodString>;
|
|
238
|
+
description: z.ZodOptional<z.ZodString>;
|
|
239
|
+
locale: z.ZodDefault<z.ZodEnum<{
|
|
240
|
+
de: "de";
|
|
241
|
+
en: "en";
|
|
242
|
+
es: "es";
|
|
243
|
+
fr: "fr";
|
|
244
|
+
it: "it";
|
|
245
|
+
nl: "nl";
|
|
246
|
+
pt: "pt";
|
|
247
|
+
tr: "tr";
|
|
248
|
+
}>>;
|
|
249
|
+
askConfidence: z.ZodDefault<z.ZodBoolean>;
|
|
250
|
+
askReasoning: z.ZodDefault<z.ZodBoolean>;
|
|
251
|
+
pools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
252
|
+
id: z.ZodString;
|
|
253
|
+
label: z.ZodDefault<z.ZodString>;
|
|
254
|
+
draw: z.ZodNumber;
|
|
255
|
+
shuffle: z.ZodDefault<z.ZodBoolean>;
|
|
256
|
+
}, z.core.$strip>>>;
|
|
257
|
+
sections: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
258
|
+
id: z.ZodString;
|
|
259
|
+
label: z.ZodDefault<z.ZodString>;
|
|
260
|
+
markdown: z.ZodDefault<z.ZodString>;
|
|
261
|
+
}, z.core.$strip>>>;
|
|
262
|
+
navigation: z.ZodDefault<z.ZodEnum<{
|
|
263
|
+
back: "back";
|
|
264
|
+
free: "free";
|
|
265
|
+
linear: "linear";
|
|
266
|
+
}>>;
|
|
267
|
+
allowSkip: z.ZodDefault<z.ZodBoolean>;
|
|
268
|
+
timeLimit: z.ZodOptional<z.ZodNumber>;
|
|
269
|
+
}, z.core.$strip>;
|
|
270
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
271
|
+
id: z.ZodString;
|
|
272
|
+
type: z.ZodString;
|
|
273
|
+
position: z.ZodObject<{
|
|
274
|
+
x: z.ZodNumber;
|
|
275
|
+
y: z.ZodNumber;
|
|
276
|
+
}, z.core.$strip>;
|
|
277
|
+
data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
278
|
+
pool: z.ZodOptional<z.ZodString>;
|
|
279
|
+
section: z.ZodOptional<z.ZodString>;
|
|
280
|
+
}, z.core.$strip>>;
|
|
281
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
282
|
+
id: z.ZodString;
|
|
283
|
+
source: z.ZodString;
|
|
284
|
+
target: z.ZodString;
|
|
285
|
+
sourceHandle: z.ZodOptional<z.ZodString>;
|
|
286
|
+
targetHandle: z.ZodOptional<z.ZodString>;
|
|
287
|
+
label: z.ZodOptional<z.ZodString>;
|
|
288
|
+
condition: z.ZodOptional<z.ZodType<Condition, unknown, z.core.$ZodTypeInternals<Condition, unknown>>>;
|
|
289
|
+
resetTarget: z.ZodOptional<z.ZodEnum<{
|
|
290
|
+
answer: "answer";
|
|
291
|
+
result: "result";
|
|
292
|
+
}>>;
|
|
293
|
+
}, z.core.$strip>>;
|
|
294
|
+
viewport: z.ZodOptional<z.ZodObject<{
|
|
295
|
+
x: z.ZodNumber;
|
|
296
|
+
y: z.ZodNumber;
|
|
297
|
+
zoom: z.ZodNumber;
|
|
298
|
+
}, z.core.$strip>>;
|
|
299
|
+
}, z.core.$strip>;
|
|
300
|
+
export type BitflowDocument = z.infer<typeof BitflowDocumentSchema>;
|
|
301
|
+
export declare const FeedbackMessageSchema: z.ZodObject<{
|
|
302
|
+
message: z.ZodString;
|
|
303
|
+
severity: z.ZodEnum<{
|
|
304
|
+
error: "error";
|
|
305
|
+
info: "info";
|
|
306
|
+
success: "success";
|
|
307
|
+
warning: "warning";
|
|
308
|
+
}>;
|
|
309
|
+
}, z.core.$strip>;
|
|
310
|
+
export type FeedbackMessage = z.infer<typeof FeedbackMessageSchema>;
|
|
311
|
+
/**
|
|
312
|
+
* Evaluation settings every task bit offers, so a teacher meets the same three
|
|
313
|
+
* questions — how is it graded, may they retry, do they see feedback — in every
|
|
314
|
+
* task editor.
|
|
315
|
+
*
|
|
316
|
+
* `mode` decides what submitting does: `auto` grades it in the browser, `skip`
|
|
317
|
+
* shows it but never grades or scores it.
|
|
318
|
+
*/
|
|
319
|
+
export declare const EvaluationSchema: z.ZodObject<{
|
|
320
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
321
|
+
auto: "auto";
|
|
322
|
+
skip: "skip";
|
|
323
|
+
}>>;
|
|
324
|
+
enableRetry: z.ZodDefault<z.ZodBoolean>;
|
|
325
|
+
showFeedback: z.ZodDefault<z.ZodBoolean>;
|
|
326
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
327
|
+
timeLimit: z.ZodOptional<z.ZodNumber>;
|
|
328
|
+
allowSkip: z.ZodOptional<z.ZodBoolean>;
|
|
329
|
+
}, z.core.$strip>;
|
|
330
|
+
export type Evaluation = z.infer<typeof EvaluationSchema>;
|
|
331
|
+
/**
|
|
332
|
+
* The grading settings a task starts with.
|
|
333
|
+
*
|
|
334
|
+
* Bits use this rather than writing the object out, so adding a setting here
|
|
335
|
+
* reaches every bit at once instead of breaking each one's defaults.
|
|
336
|
+
*/
|
|
337
|
+
export declare const defaultEvaluation: () => Evaluation;
|
|
338
|
+
export declare const BitResultSchema: z.ZodObject<{
|
|
339
|
+
state: z.ZodEnum<{
|
|
340
|
+
correct: "correct";
|
|
341
|
+
unknown: "unknown";
|
|
342
|
+
wrong: "wrong";
|
|
343
|
+
}>;
|
|
344
|
+
score: z.ZodOptional<z.ZodObject<{
|
|
345
|
+
earned: z.ZodNumber;
|
|
346
|
+
possible: z.ZodNumber;
|
|
347
|
+
}, z.core.$strip>>;
|
|
348
|
+
feedback: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
349
|
+
message: z.ZodString;
|
|
350
|
+
severity: z.ZodEnum<{
|
|
351
|
+
error: "error";
|
|
352
|
+
info: "info";
|
|
353
|
+
success: "success";
|
|
354
|
+
warning: "warning";
|
|
355
|
+
}>;
|
|
356
|
+
}, z.core.$strip>>>;
|
|
357
|
+
allowRetry: z.ZodOptional<z.ZodBoolean>;
|
|
358
|
+
detail: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
359
|
+
}, z.core.$strip>;
|
|
360
|
+
export type BitResult = z.infer<typeof BitResultSchema>;
|
|
361
|
+
/**
|
|
362
|
+
* Version of the attempt snapshot format, independent of the document format.
|
|
363
|
+
*/
|
|
364
|
+
export declare const ATTEMPT_SCHEMA_VERSION = 1;
|
|
365
|
+
export declare const ConfidenceSchema: z.ZodObject<{
|
|
366
|
+
level: z.ZodNumber;
|
|
367
|
+
}, z.core.$strip>;
|
|
368
|
+
export type Confidence = z.infer<typeof ConfidenceSchema>;
|
|
369
|
+
export declare const AttemptStatusSchema: z.ZodEnum<{
|
|
370
|
+
abandoned: "abandoned";
|
|
371
|
+
completed: "completed";
|
|
372
|
+
inProgress: "inProgress";
|
|
373
|
+
}>;
|
|
374
|
+
export type AttemptStatus = z.infer<typeof AttemptStatusSchema>;
|
|
375
|
+
/**
|
|
376
|
+
* Everything needed to resume a run. Serializable by construction: the host
|
|
377
|
+
* persists it verbatim (see `bitflow-statechange`) and hands it back later.
|
|
378
|
+
*
|
|
379
|
+
* `history`, `elapsedMs` and `enteredAt` are part of version 1 because
|
|
380
|
+
* "go back" and per-node timings cannot be reconstructed from the graph once
|
|
381
|
+
* branching is condition-driven.
|
|
382
|
+
*/
|
|
383
|
+
export declare const AttemptSnapshotSchema: z.ZodObject<{
|
|
384
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
385
|
+
flowId: z.ZodString;
|
|
386
|
+
flowSchemaVersion: z.ZodNumber;
|
|
387
|
+
attemptId: z.ZodString;
|
|
388
|
+
status: z.ZodEnum<{
|
|
389
|
+
abandoned: "abandoned";
|
|
390
|
+
completed: "completed";
|
|
391
|
+
inProgress: "inProgress";
|
|
392
|
+
}>;
|
|
393
|
+
currentNodeId: z.ZodString;
|
|
394
|
+
history: z.ZodArray<z.ZodString>;
|
|
395
|
+
answers: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
396
|
+
results: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
397
|
+
state: z.ZodEnum<{
|
|
398
|
+
correct: "correct";
|
|
399
|
+
unknown: "unknown";
|
|
400
|
+
wrong: "wrong";
|
|
401
|
+
}>;
|
|
402
|
+
score: z.ZodOptional<z.ZodObject<{
|
|
403
|
+
earned: z.ZodNumber;
|
|
404
|
+
possible: z.ZodNumber;
|
|
405
|
+
}, z.core.$strip>>;
|
|
406
|
+
feedback: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
407
|
+
message: z.ZodString;
|
|
408
|
+
severity: z.ZodEnum<{
|
|
409
|
+
error: "error";
|
|
410
|
+
info: "info";
|
|
411
|
+
success: "success";
|
|
412
|
+
warning: "warning";
|
|
413
|
+
}>;
|
|
414
|
+
}, z.core.$strip>>>;
|
|
415
|
+
allowRetry: z.ZodOptional<z.ZodBoolean>;
|
|
416
|
+
detail: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
417
|
+
}, z.core.$strip>>;
|
|
418
|
+
tries: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
419
|
+
elapsedMs: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
420
|
+
pools: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
421
|
+
confidence: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
422
|
+
level: z.ZodNumber;
|
|
423
|
+
}, z.core.$strip>>>;
|
|
424
|
+
reasoning: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
425
|
+
startedAt: z.ZodISODateTime;
|
|
426
|
+
updatedAt: z.ZodISODateTime;
|
|
427
|
+
enteredAt: z.ZodISODateTime;
|
|
428
|
+
completedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
429
|
+
}, z.core.$strip>;
|
|
430
|
+
export type AttemptSnapshot = z.infer<typeof AttemptSnapshotSchema>;
|
|
431
|
+
export {};
|
package/dist/score.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BitResult } from "./schema";
|
|
2
|
+
/**
|
|
3
|
+
* A bit's result may carry its own `score`. When it does not, the bit is worth
|
|
4
|
+
* one point, earned iff the state is `correct`. `unknown` contributes nothing
|
|
5
|
+
* to either side: it was never graded, so it must not drag the ratio down.
|
|
6
|
+
*
|
|
7
|
+
* Its own module rather than living in `engine.ts` because conditions score a
|
|
8
|
+
* scoped set of results, and `engine.ts` imports `condition.ts` — putting it
|
|
9
|
+
* here is what keeps that from becoming a cycle.
|
|
10
|
+
*/
|
|
11
|
+
export declare const scoreOf: (result: BitResult) => {
|
|
12
|
+
earned: number;
|
|
13
|
+
possible: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const totalScore: (results: Iterable<BitResult>) => {
|
|
16
|
+
earned: number;
|
|
17
|
+
possible: number;
|
|
18
|
+
};
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds a package's stylesheet to the document, once.
|
|
3
|
+
*
|
|
4
|
+
* Each package's CSS is bundled into its JavaScript as a string and injected
|
|
5
|
+
* on import, rather than shipped as a file the page has to remember to link.
|
|
6
|
+
* That is what makes "import the bit package" the single action that makes a
|
|
7
|
+
* bit usable: `<bitflow-flow>` resolves bits at runtime, so no page can know in
|
|
8
|
+
* advance which stylesheets to include, and a lazily loaded bit that arrives
|
|
9
|
+
* unstyled is not usable.
|
|
10
|
+
*
|
|
11
|
+
* `id` deduplicates: several bundles on one page inject the same shared
|
|
12
|
+
* stylesheet, and the first one is enough.
|
|
13
|
+
*/
|
|
14
|
+
export declare const injectStyles: (id: string, css: string) => void;
|