@superbuilders/incept-renderer 0.1.11 → 0.1.12
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 +200 -1
- package/dist/actions/index.d.ts +4 -1
- package/dist/actions/index.js +65 -6
- package/dist/actions/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -3
- package/dist/components/index.js +14 -1
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +6 -11
- package/dist/index.js +65 -1
- package/dist/index.js.map +1 -1
- package/dist/parser-B8n3iHSM.d.ts +29 -0
- package/dist/qti-stimulus-renderer-CSuLfoff.d.ts +178 -0
- package/dist/{schema-DZoGAQdF.d.ts → schema-DKduufCs.d.ts} +106 -128
- package/dist/styles/themes.css +217 -0
- package/dist/styles/themes.css.map +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types-B7YRTQKt.d.ts +0 -102
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { a as DisplayBlock,
|
|
1
|
+
export { C as ChoiceCorrectness, d as ContentBlockRenderer, a as ContentBlockRendererProps, e as QTIRenderer, Q as QTIRendererProps, f as QTIStimulusRenderer, b as QTIStimulusRendererProps, c as QTITheme, R as ResponseFeedback } from './qti-stimulus-renderer-CSuLfoff.js';
|
|
2
|
+
import { A as AssessmentItem } from './schema-DKduufCs.js';
|
|
3
|
+
export { c as AnyInteraction, n as AssessmentItemSchema, a as AssessmentStimulus, o as AssessmentStimulusSchema, C as ChoiceInteraction, e as DisplayBlock, f as DisplayChoice, g as DisplayChoiceInteraction, k as DisplayItem, F as FeedbackBlock, m as FormShape, R as ResponseDeclaration, d as ResponseProcessing, V as ValidateResult } from './schema-DKduufCs.js';
|
|
4
|
+
import { N as NormalizedNode } from './parser-B8n3iHSM.js';
|
|
5
|
+
export { p as parseAssessmentItemXml, a as parseAssessmentStimulusXml } from './parser-B8n3iHSM.js';
|
|
4
6
|
import 'react/jsx-runtime';
|
|
5
7
|
import 'zod';
|
|
6
8
|
|
|
@@ -9,13 +11,6 @@ import 'zod';
|
|
|
9
11
|
*/
|
|
10
12
|
declare function evaluateFeedbackIdentifiers(item: AssessmentItem, responses: Record<string, string | string[]>, responseResults: Record<string, boolean>): string[];
|
|
11
13
|
|
|
12
|
-
interface NormalizedNode {
|
|
13
|
-
tagName: string;
|
|
14
|
-
attrs: Record<string, unknown>;
|
|
15
|
-
children: Array<NormalizedNode | string>;
|
|
16
|
-
}
|
|
17
|
-
declare function parseAssessmentItemXml(xml: string): AssessmentItem;
|
|
18
|
-
|
|
19
14
|
/**
|
|
20
15
|
* Configuration for HTML sanitization.
|
|
21
16
|
* Defines allowed tags and attributes for safe rendering.
|
|
@@ -56,4 +51,4 @@ declare function serializeNode(node: NormalizedNode): string;
|
|
|
56
51
|
*/
|
|
57
52
|
declare function detectContentType(html: string): "mathml" | "html";
|
|
58
53
|
|
|
59
|
-
export { AssessmentItem, detectContentType, evaluateFeedbackIdentifiers,
|
|
54
|
+
export { AssessmentItem, detectContentType, evaluateFeedbackIdentifiers, sanitizeForDisplay, sanitizeHtml, serializeInner, serializeNode, serializeNodes };
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,13 @@ var DEFAULT_CONFIG = {
|
|
|
33
33
|
"div",
|
|
34
34
|
"br",
|
|
35
35
|
"hr",
|
|
36
|
+
// Headings
|
|
37
|
+
"h1",
|
|
38
|
+
"h2",
|
|
39
|
+
"h3",
|
|
40
|
+
"h4",
|
|
41
|
+
"h5",
|
|
42
|
+
"h6",
|
|
36
43
|
// Formatting
|
|
37
44
|
"b",
|
|
38
45
|
"i",
|
|
@@ -82,6 +89,9 @@ var DEFAULT_CONFIG = {
|
|
|
82
89
|
"figcaption",
|
|
83
90
|
"blockquote",
|
|
84
91
|
"cite",
|
|
92
|
+
// Interactive
|
|
93
|
+
"details",
|
|
94
|
+
"summary",
|
|
85
95
|
// Links
|
|
86
96
|
"a",
|
|
87
97
|
// Forms (for future interactive elements)
|
|
@@ -2540,6 +2550,9 @@ function QTIRenderer({
|
|
|
2540
2550
|
showFeedback && overallFeedback?.messageHtml && /* @__PURE__ */ jsx("div", { className: "qti-feedback mt-6 p-6", "data-correct": overallFeedback.isCorrect, children: /* @__PURE__ */ jsx(HTMLContent, { html: overallFeedback.messageHtml }) })
|
|
2541
2551
|
] });
|
|
2542
2552
|
}
|
|
2553
|
+
function QTIStimulusRenderer({ stimulus, className }) {
|
|
2554
|
+
return /* @__PURE__ */ jsx("article", { className: cn("qti-stimulus", className), lang: stimulus.xmlLang, "data-stimulus-id": stimulus.identifier, children: /* @__PURE__ */ jsx(HTMLContent, { html: stimulus.bodyHtml, className: "qti-stimulus-body" }) });
|
|
2555
|
+
}
|
|
2543
2556
|
function normalizeString(str, caseSensitive) {
|
|
2544
2557
|
const s = (str ?? "").trim();
|
|
2545
2558
|
return caseSensitive ? s : s.toLowerCase();
|
|
@@ -2958,6 +2971,16 @@ var AssessmentItemSchema = z.object({
|
|
|
2958
2971
|
itemBody: ItemBodySchema,
|
|
2959
2972
|
responseProcessing: ResponseProcessingSchema
|
|
2960
2973
|
});
|
|
2974
|
+
var AssessmentStimulusSchema = z.object({
|
|
2975
|
+
/** Unique identifier for the stimulus */
|
|
2976
|
+
identifier: z.string().min(1),
|
|
2977
|
+
/** Human-readable title */
|
|
2978
|
+
title: z.string().default(""),
|
|
2979
|
+
/** Language code (e.g., "en", "es") */
|
|
2980
|
+
xmlLang: z.string().default("en"),
|
|
2981
|
+
/** The HTML content of the stimulus body */
|
|
2982
|
+
bodyHtml: z.string()
|
|
2983
|
+
});
|
|
2961
2984
|
|
|
2962
2985
|
// src/parser.ts
|
|
2963
2986
|
function createXmlParser() {
|
|
@@ -3583,7 +3606,48 @@ function parseAssessmentItemXml(xml) {
|
|
|
3583
3606
|
}
|
|
3584
3607
|
return validation.data;
|
|
3585
3608
|
}
|
|
3609
|
+
function parseAssessmentStimulusXml(xml) {
|
|
3610
|
+
if (!xml || typeof xml !== "string") {
|
|
3611
|
+
throw errors.new("xml input must be a non-empty string");
|
|
3612
|
+
}
|
|
3613
|
+
const parser = createXmlParser();
|
|
3614
|
+
const parseResult = errors.trySync(() => {
|
|
3615
|
+
return parser.parse(xml, true);
|
|
3616
|
+
});
|
|
3617
|
+
if (parseResult.error) {
|
|
3618
|
+
throw errors.wrap(parseResult.error, "xml parse");
|
|
3619
|
+
}
|
|
3620
|
+
const raw = parseResult.data;
|
|
3621
|
+
if (!Array.isArray(raw)) {
|
|
3622
|
+
throw errors.new("expected xml parser to output an array for preserveOrder");
|
|
3623
|
+
}
|
|
3624
|
+
const normalizedTree = raw.map(normalizeNode).filter((n) => typeof n !== "string");
|
|
3625
|
+
const rootNode = normalizedTree.find(
|
|
3626
|
+
(n) => n.tagName === "qti-assessment-stimulus" || n.tagName.endsWith("assessment-stimulus")
|
|
3627
|
+
);
|
|
3628
|
+
if (!rootNode) {
|
|
3629
|
+
throw errors.new("qti assessment stimulus not found in xml document");
|
|
3630
|
+
}
|
|
3631
|
+
const rootChildren = rootNode.children.filter((c) => typeof c !== "string");
|
|
3632
|
+
const stimulusBodyNode = rootChildren.find((n) => n.tagName === "qti-stimulus-body");
|
|
3633
|
+
if (!stimulusBodyNode) {
|
|
3634
|
+
throw errors.new("qti-stimulus-body not found in stimulus document");
|
|
3635
|
+
}
|
|
3636
|
+
const bodyHtml = getInnerHtml(stimulusBodyNode);
|
|
3637
|
+
const normalizedStimulus = {
|
|
3638
|
+
identifier: coerceString(rootNode.attrs.identifier),
|
|
3639
|
+
title: coerceString(rootNode.attrs.title),
|
|
3640
|
+
xmlLang: coerceString(rootNode.attrs["xml:lang"]) || coerceString(rootNode.attrs["xml-lang"]) || "en",
|
|
3641
|
+
bodyHtml
|
|
3642
|
+
};
|
|
3643
|
+
const validation = AssessmentStimulusSchema.safeParse(normalizedStimulus);
|
|
3644
|
+
if (!validation.success) {
|
|
3645
|
+
const errorDetails = validation.error.issues.map((err) => `${err.path.join(".")}: ${err.message}`).join("; ");
|
|
3646
|
+
throw errors.new(`qti stimulus validation: ${errorDetails}`);
|
|
3647
|
+
}
|
|
3648
|
+
return validation.data;
|
|
3649
|
+
}
|
|
3586
3650
|
|
|
3587
|
-
export { AssessmentItemSchema, ContentBlockRenderer, QTIRenderer, detectContentType, evaluateFeedbackIdentifiers, parseAssessmentItemXml, sanitizeForDisplay, sanitizeHtml, serializeInner, serializeNode, serializeNodes };
|
|
3651
|
+
export { AssessmentItemSchema, AssessmentStimulusSchema, ContentBlockRenderer, QTIRenderer, QTIStimulusRenderer, detectContentType, evaluateFeedbackIdentifiers, parseAssessmentItemXml, parseAssessmentStimulusXml, sanitizeForDisplay, sanitizeHtml, serializeInner, serializeNode, serializeNodes };
|
|
3588
3652
|
//# sourceMappingURL=index.js.map
|
|
3589
3653
|
//# sourceMappingURL=index.js.map
|