explico 0.8.0 → 0.11.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.
Files changed (230) hide show
  1. package/CHANGELOG.md +1257 -1
  2. package/README.md +60 -15
  3. package/dist/compiler/astro.d.ts +6 -1
  4. package/dist/compiler/cli.d.ts +46 -2
  5. package/dist/compiler/cli.js +70 -4
  6. package/dist/compiler/collections.d.ts +35 -2
  7. package/dist/compiler/collections.js +68 -5
  8. package/dist/compiler/course-config.d.ts +3 -194
  9. package/dist/compiler/course-config.js +78 -5
  10. package/dist/compiler/exports/standalone-html.d.ts +6 -1
  11. package/dist/compiler/knowledge-version.js +1 -1
  12. package/dist/compiler/lesson-derivation.d.ts +27 -10
  13. package/dist/compiler/lesson-derivation.js +23 -8
  14. package/dist/compiler/logging.d.ts +4 -1
  15. package/dist/compiler/logging.js +4 -1
  16. package/dist/compiler/manifest.d.ts +204 -31
  17. package/dist/compiler/manifest.js +270 -55
  18. package/dist/compiler/resolution-report.d.ts +6 -1
  19. package/dist/course-config-Dsnri9Tk.d.ts +464 -0
  20. package/dist/reference/base-accents.d.mts +26 -0
  21. package/dist/reference/base-accents.mjs +31 -0
  22. package/dist/reference/base-roman-labels.d.mts +2 -2
  23. package/dist/reference/base-roman-labels.mjs +2 -2
  24. package/dist/reference/consistency.d.ts +14 -2
  25. package/dist/reference/consistency.js +108 -4
  26. package/dist/reference/delimiter-size.d.ts +3 -2
  27. package/dist/reference/diagrams-validate.d.ts +7 -2
  28. package/dist/reference/diagrams-validate.js +9 -1
  29. package/dist/reference/equations-validate.d.ts +8 -5
  30. package/dist/reference/equations-validate.js +1 -0
  31. package/dist/reference/equations.d.mts +60 -31
  32. package/dist/reference/equations.mjs +83 -43
  33. package/dist/reference/examples-validate.d.ts +31 -0
  34. package/dist/reference/examples-validate.js +48 -0
  35. package/dist/reference/figures-validate.d.ts +1 -1
  36. package/dist/reference/figures-validate.js +4 -1
  37. package/dist/reference/folds-validate.d.ts +33 -0
  38. package/dist/reference/folds-validate.js +32 -0
  39. package/dist/reference/gate-abbreviations.d.ts +3 -1
  40. package/dist/reference/gate-abbreviations.js +1 -0
  41. package/dist/reference/gate-course-rules.d.ts +32 -0
  42. package/dist/reference/gate-course-rules.js +85 -0
  43. package/dist/reference/gate-heading-length.d.ts +5 -2
  44. package/dist/reference/gate-heading-length.js +45 -21
  45. package/dist/reference/gate-heading-structure.d.ts +41 -0
  46. package/dist/reference/gate-heading-structure.js +113 -0
  47. package/dist/reference/gate-math-punctuation.d.ts +71 -0
  48. package/dist/reference/gate-math-punctuation.js +251 -0
  49. package/dist/reference/gate-math.d.ts +22 -6
  50. package/dist/reference/gate-math.js +42 -8
  51. package/dist/reference/gate-part-pages.d.ts +50 -0
  52. package/dist/reference/gate-part-pages.js +118 -0
  53. package/dist/reference/gate-prose-notation.d.ts +21 -11
  54. package/dist/reference/gate-prose-notation.js +25 -7
  55. package/dist/reference/katex-delimiters.mjs +20 -7
  56. package/dist/reference/keyed-float-validate.d.ts +27 -10
  57. package/dist/reference/keyed-float-validate.js +15 -1
  58. package/dist/reference/keyed-jsx-floats.d.mts +11 -5
  59. package/dist/reference/keyed-jsx-floats.mjs +73 -20
  60. package/dist/reference/knowledge-checks-validate.d.ts +1 -1
  61. package/dist/reference/knowledge-checks.d.mts +3 -1
  62. package/dist/reference/knowledge-checks.mjs +9 -4
  63. package/dist/reference/lab-math-scope.d.ts +1 -0
  64. package/dist/reference/lab-math-slot.d.ts +34 -0
  65. package/dist/reference/lab-math-slot.js +6 -0
  66. package/dist/reference/math-glyphs.d.mts +80 -4
  67. package/dist/reference/math-glyphs.mjs +572 -37
  68. package/dist/reference/page-notation.d.ts +6 -1
  69. package/dist/reference/raw-floats-validate.js +1 -1
  70. package/dist/reference/raw-floats.mjs +1 -1
  71. package/dist/reference/rehype-heading-anchors.d.mts +14 -0
  72. package/dist/reference/rehype-heading-anchors.mjs +116 -17
  73. package/dist/reference/rehype-table-header-labels.d.mts +6 -1
  74. package/dist/reference/rehype-table-header-labels.mjs +21 -3
  75. package/dist/reference/remark-asides.d.mts +3 -0
  76. package/dist/reference/remark-asides.mjs +180 -0
  77. package/dist/reference/remark-memo.d.mts +3 -1
  78. package/dist/reference/remark-memo.mjs +42 -11
  79. package/dist/reference/remark-notation.d.mts +60 -10
  80. package/dist/reference/remark-notation.mjs +387 -36
  81. package/dist/reference/render-lab-math.d.ts +4 -26
  82. package/dist/reference/render-lab-math.js +4 -4
  83. package/dist/reference/sections-validate.d.ts +27 -0
  84. package/dist/reference/sections-validate.js +41 -0
  85. package/dist/reference/sections.d.mts +97 -0
  86. package/dist/reference/sections.mjs +306 -0
  87. package/dist/reference/tables-validate.d.ts +1 -1
  88. package/dist/reference/types.d.ts +17 -1
  89. package/dist/reference/unit-words.d.ts +37 -0
  90. package/dist/reference/unit-words.js +170 -0
  91. package/dist/rules/catalog.d.ts +176 -0
  92. package/dist/rules/catalog.js +983 -0
  93. package/dist/rules/course-rules.d.ts +115 -0
  94. package/dist/rules/course-rules.js +292 -0
  95. package/dist/rules/course-rules.schema.json +138 -0
  96. package/dist/rules/in-effect.d.ts +53 -0
  97. package/dist/rules/in-effect.js +142 -0
  98. package/dist/rules/rules.schema.json +1072 -0
  99. package/dist/rules/settings.d.ts +3 -0
  100. package/dist/rules/settings.js +290 -0
  101. package/dist/rules/waivers.d.ts +53 -0
  102. package/dist/rules/waivers.js +132 -0
  103. package/dist/session/PreferenceStore.d.ts +5 -0
  104. package/dist/session/PreferenceStore.js +9 -0
  105. package/docs/VERSIONING.md +5 -3
  106. package/docs/authoring/README.md +232 -40
  107. package/docs/authoring/agents.md +55 -9
  108. package/docs/authoring/components.md +178 -22
  109. package/docs/authoring/migrating.md +1152 -2
  110. package/docs/authoring/notation.md +576 -322
  111. package/docs/authoring/prose.md +551 -0
  112. package/docs/authoring/retired.md +35 -0
  113. package/docs/authoring/structure-rules.md +422 -40
  114. package/docs/authoring/structure.md +445 -62
  115. package/docs/authoring/versioning.md +20 -28
  116. package/docs/authoring/visualizations.md +142 -20
  117. package/package.json +2 -2
  118. package/src/compiler/cli.ts +116 -6
  119. package/src/compiler/collections.ts +111 -7
  120. package/src/compiler/course-config.ts +273 -34
  121. package/src/compiler/knowledge-version.ts +1 -1
  122. package/src/compiler/lesson-derivation.ts +54 -15
  123. package/src/compiler/logging.ts +8 -2
  124. package/src/compiler/manifest.ts +573 -104
  125. package/src/components/BlockHeading.astro +113 -0
  126. package/src/components/CourseContents.astro +221 -0
  127. package/src/components/CurriculumMap.astro +5 -6
  128. package/src/components/FloatIndex.astro +200 -0
  129. package/src/components/HoverPanel.astro +431 -79
  130. package/src/components/PartBridge.astro +27 -0
  131. package/src/components/PartOverview.astro +401 -0
  132. package/src/components/PartScope.astro +27 -0
  133. package/src/components/abbreviation/AbbreviationLayer.astro +49 -51
  134. package/src/components/assessments/AssessmentRunner.tsx +8 -5
  135. package/src/components/assessments/AssessmentSet.astro +23 -26
  136. package/src/components/block-heading.ts +146 -0
  137. package/src/components/card-arrow.ts +243 -0
  138. package/src/components/card-drag.ts +631 -0
  139. package/src/components/card-jump.ts +45 -0
  140. package/src/components/card-manager.ts +1589 -0
  141. package/src/components/card-memory.ts +177 -0
  142. package/src/components/card-placement.ts +504 -0
  143. package/src/components/card-side.ts +336 -0
  144. package/src/components/card-travel.ts +197 -0
  145. package/src/components/citation/CitationLayer.astro +77 -76
  146. package/src/components/diagram/Diagram.astro +161 -316
  147. package/src/components/disclosure/course-disclosure.ts +24 -0
  148. package/src/components/disclosure/hover-preview.ts +122 -42
  149. package/src/components/disclosure/persisted-disclosure.ts +3 -3
  150. package/src/components/disclosure/print-as-shown.ts +252 -0
  151. package/src/components/examples/CompactExample.astro +3 -1
  152. package/src/components/examples/CompactExamples.astro +101 -94
  153. package/src/components/figure/Figure.astro +174 -274
  154. package/src/components/figure/FloatCaption.astro +87 -0
  155. package/src/components/figure/figure-state.ts +58 -0
  156. package/src/components/figure/figure-tools.ts +87 -0
  157. package/src/components/float-name.ts +101 -0
  158. package/src/components/fold/Fold.astro +125 -0
  159. package/src/components/fold/fold-id.ts +40 -0
  160. package/src/components/memo/Memo.astro +162 -231
  161. package/src/components/memo/ShortNote.astro +6 -6
  162. package/src/components/notation/NotationFormula.astro +5 -1
  163. package/src/components/notation/NotationGlossary.astro +3 -4
  164. package/src/components/notation/NotationLayer.astro +169 -162
  165. package/src/components/notation/NotationMath.astro +10 -1
  166. package/src/components/reference/FloatRefLayer.astro +485 -423
  167. package/src/components/starlight/AboutPanel.astro +5 -4
  168. package/src/components/starlight/CollapsibleSections.astro +207 -93
  169. package/src/components/starlight/DiagramEnhancer.astro +15 -138
  170. package/src/components/starlight/HeadingAnchorEnhancer.astro +193 -1
  171. package/src/components/starlight/KeyedFloatEnhancer.astro +100 -9
  172. package/src/components/starlight/LayoutHeader.astro +298 -19
  173. package/src/components/starlight/LayoutPageSidebar.astro +99 -12
  174. package/src/components/starlight/LayoutPageTitle.astro +120 -0
  175. package/src/components/starlight/LayoutSidebar.astro +229 -11
  176. package/src/components/starlight/LessonExportActions.astro +53 -72
  177. package/src/components/starlight/LessonFooter.astro +26 -4
  178. package/src/components/starlight/section-parts.ts +15 -2
  179. package/src/components/starlight/section-summary.ts +181 -0
  180. package/src/components/table/Table.astro +95 -76
  181. package/src/components/table/TableOverflowExpander.astro +65 -28
  182. package/src/content-config.ts +40 -4
  183. package/src/reference/base-accents.mjs +31 -0
  184. package/src/reference/base-roman-labels.mjs +2 -2
  185. package/src/reference/consistency.ts +176 -5
  186. package/src/reference/delimiter-size.ts +3 -2
  187. package/src/reference/diagrams-validate.ts +17 -1
  188. package/src/reference/equations-validate.ts +10 -5
  189. package/src/reference/equations.mjs +83 -43
  190. package/src/reference/examples-validate.ts +97 -0
  191. package/src/reference/figures-validate.ts +6 -1
  192. package/src/reference/folds-validate.ts +65 -0
  193. package/src/reference/gate-abbreviations.ts +1 -0
  194. package/src/reference/gate-course-rules.ts +134 -0
  195. package/src/reference/gate-heading-length.ts +66 -35
  196. package/src/reference/gate-heading-structure.ts +193 -0
  197. package/src/reference/gate-math-punctuation.ts +381 -0
  198. package/src/reference/gate-math.ts +69 -10
  199. package/src/reference/gate-part-pages.ts +217 -0
  200. package/src/reference/gate-prose-notation.ts +59 -12
  201. package/src/reference/katex-delimiters.mjs +20 -7
  202. package/src/reference/keyed-float-validate.ts +45 -11
  203. package/src/reference/keyed-jsx-floats.mjs +73 -20
  204. package/src/reference/knowledge-checks-validate.ts +1 -1
  205. package/src/reference/knowledge-checks.mjs +9 -4
  206. package/src/reference/lab-math-slot.ts +36 -0
  207. package/src/reference/math-glyphs.mjs +572 -37
  208. package/src/reference/raw-floats-validate.ts +1 -1
  209. package/src/reference/raw-floats.mjs +1 -1
  210. package/src/reference/rehype-heading-anchors.mjs +116 -17
  211. package/src/reference/rehype-table-header-labels.mjs +21 -3
  212. package/src/reference/remark-asides.mjs +180 -0
  213. package/src/reference/remark-memo.mjs +42 -11
  214. package/src/reference/remark-notation.mjs +387 -36
  215. package/src/reference/render-lab-math.ts +16 -31
  216. package/src/reference/sections-validate.ts +81 -0
  217. package/src/reference/sections.mjs +306 -0
  218. package/src/reference/tables-validate.ts +2 -1
  219. package/src/reference/types.ts +17 -0
  220. package/src/reference/unit-words.ts +233 -0
  221. package/src/rules/catalog.ts +1298 -0
  222. package/src/rules/course-rules.ts +456 -0
  223. package/src/rules/in-effect.ts +235 -0
  224. package/src/rules/settings.ts +448 -0
  225. package/src/rules/waivers.ts +249 -0
  226. package/src/session/PreferenceStore.ts +15 -0
  227. package/src/styles/global.css +1467 -163
  228. package/src/styles/surfaces.css +182 -0
  229. package/src/components/hover-panel.ts +0 -339
  230. package/src/components/popup-stack.ts +0 -345
@@ -0,0 +1,142 @@
1
+ import { mkdirSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import {
4
+ ELEMENTS,
5
+ enforcementOf,
6
+ invariants,
7
+ rules as catalogRules
8
+ } from "./catalog.js";
9
+ import { courseRuleEntry } from "./course-rules.js";
10
+ import { isWaivable } from "./waivers.js";
11
+ const DOC_ROOT = "../node_modules/explico/docs/authoring";
12
+ function docLink(entry) {
13
+ return entry.kind === "rule" && entry.source === "course" ? entry.doc : `${DOC_ROOT}/${entry.doc}`;
14
+ }
15
+ function liveRules(input) {
16
+ return [...catalogRules(), ...input.rules.course.map(courseRuleEntry)];
17
+ }
18
+ function enforcementLabel(entry) {
19
+ return entry.kind === "rule" && entry.locked !== void 0 ? "locked" : enforcementOf(entry);
20
+ }
21
+ function matches(entry, filter) {
22
+ if (filter.elements && !entry.elements.some((e) => filter.elements.includes(e))) return false;
23
+ if (filter.enforcement && enforcementLabel(entry) !== filter.enforcement) return false;
24
+ return true;
25
+ }
26
+ function rulesInEffect(input, filter = {}) {
27
+ const off = new Set(input.rules.disabled);
28
+ const entries = [...liveRules(input), ...invariants()];
29
+ return entries.filter((entry) => matches(entry, filter)).map((entry) => ({
30
+ id: entry.id,
31
+ kind: entry.kind,
32
+ source: entry.kind === "rule" && entry.source === "course" ? "course" : "engine",
33
+ title: entry.title,
34
+ elements: entry.elements,
35
+ enforcement: enforcementLabel(entry),
36
+ enabled: !off.has(entry.id),
37
+ waivable: entry.kind === "rule" && isWaivable(entry),
38
+ codes: entry.checks.map((c) => c.code),
39
+ settings: entry.kind === "rule" ? input.rules.settings[entry.id] ?? {} : {},
40
+ summary: entry.summary,
41
+ doc: docLink(entry)
42
+ }));
43
+ }
44
+ function settingValue(value) {
45
+ if (!Array.isArray(value)) return JSON.stringify(value) ?? String(value);
46
+ if (value.length === 0) return "[]";
47
+ const items = value.map(
48
+ (item) => typeof item === "string" ? `\`${item}\`` : JSON.stringify(item)
49
+ );
50
+ return `[${items.join(", ")}]`;
51
+ }
52
+ function settingsText(rule, settings) {
53
+ const specs = rule.settings ?? [];
54
+ if (specs.length === 0) return "";
55
+ return ` (${specs.map((s) => `${s.key} = ${settingValue(settings[s.key])}`).join(", ")})`;
56
+ }
57
+ function ruleLine(rule, settings) {
58
+ const label = enforcementLabel(rule);
59
+ const codes = rule.checks.map((c) => `\`${c.code}\``).join(", ");
60
+ const head = [
61
+ `**${rule.id}**`,
62
+ rule.source === "course" ? "course" : "",
63
+ label,
64
+ codes,
65
+ isWaivable(rule) ? "waivable" : ""
66
+ ].filter(Boolean).join(" \xB7 ");
67
+ const also = rule.elements.length > 1 ? ` (also: ${rule.elements.slice(1).join(", ")})` : "";
68
+ const unchecked = rule.unchecked ? ` Not checked by the build: ${rule.unchecked}` : "";
69
+ return `- ${head}${also} \u2014 ${rule.summary}${settingsText(rule, settings)}${unchecked} \u2192 [${rule.doc}](${docLink(rule)})`;
70
+ }
71
+ function renderRulesInEffect(input, filter = {}) {
72
+ const off = new Set(input.rules.disabled);
73
+ const on = liveRules(input).filter((r) => !off.has(r.id));
74
+ const ours = on.filter((r) => r.source === "course").length;
75
+ const locked = on.filter((r) => r.locked !== void 0).map((r) => r.id);
76
+ const filtered = filter.elements || filter.enforcement;
77
+ const visible = on.filter((r) => matches(r, filter));
78
+ const lines = [];
79
+ lines.push(
80
+ `# Rules in effect \u2014 ${input.about.material.name} (knowledge ${input.about.knowledge.version}, ${input.about.engine.name} ${input.about.engine.version})`,
81
+ "",
82
+ "Generated by `pnpm validate:content` (and `pnpm content rules`) from the rule",
83
+ "catalog and `rules` / `courseRules` in `course.settings.json`. Do not edit. Read this before",
84
+ "drafting, and open a rule page only when it is listed here and you need the",
85
+ "example: a rule absent from this page is either off for this course or does",
86
+ "not exist, and is neither applied nor flagged in review.",
87
+ "",
88
+ `${on.length} rules on (${locked.length} locked${ours === 0 ? "" : `, ${ours} this course's own`}), ${off.size} off, ${invariants().length} invariants always on.` + (filtered ? ` Filtered: ${[
89
+ filter.elements ? `element ${filter.elements.join(", ")}` : "",
90
+ filter.enforcement ? `enforcement ${filter.enforcement}` : ""
91
+ ].filter(Boolean).join("; ")} \u2014 ${visible.length} shown.` : ""),
92
+ "",
93
+ "A line is `ID \xB7 enforcement \xB7 codes \u2014 what to do (settings in effect) \u2192 full",
94
+ "text`. **course**: this course wrote the rule in `courseRules` in",
95
+ "`course.settings.json`, where it can be edited; the `X` area is reserved for",
96
+ "them. **script**: the build reports every violation under those codes.",
97
+ "**partial**: the build reports the codes; the rest is on you. **guide**: nothing",
98
+ "runs; it is on you. **locked**: script, and the course cannot turn it off.",
99
+ "**waivable**: break it at one place with `{/* explico-allow <ID>[, <ID>]: <reason> */}`",
100
+ "on its own line above the block (a paragraph, heading, or tag; a blank line",
101
+ "ends it) \u2014 the reason is mandatory, and a waiver that silences nothing is a",
102
+ "warning. A finding without a line (a notation entry, a per-lesson count) is",
103
+ "silenced per key in `lint-ignore.yml` (`- <code>:<key> \u2014 <reason>`) instead."
104
+ );
105
+ for (const element of ELEMENTS) {
106
+ const here = visible.filter((r) => r.elements[0] === element);
107
+ if (here.length === 0) continue;
108
+ lines.push("", `## ${element}`, "");
109
+ for (const rule of here) lines.push(ruleLine(rule, input.rules.settings[rule.id] ?? {}));
110
+ }
111
+ const visibleInvariants = invariants().filter((i) => matches(i, filter));
112
+ lines.push("", "## Always on (invariants)", "");
113
+ if (visibleInvariants.length === 0) {
114
+ lines.push("- (none match the filter)");
115
+ }
116
+ for (const inv of visibleInvariants) {
117
+ const codes = inv.checks.map((c) => `\`${c.code}\``).join(", ");
118
+ lines.push(
119
+ `- **${inv.id}** (${inv.elements.join(", ")}) \u2014 ${inv.summary} Codes: ${codes}. \u2192 [${inv.doc}](${DOC_ROOT}/${inv.doc})`
120
+ );
121
+ }
122
+ lines.push("", "## Off", "");
123
+ lines.push(
124
+ off.size === 0 ? "- Nothing \u2014 every rule is on." : `- ${[...off].join(", ")} \u2014 turned off in \`course.settings.json\` (\`rules\`, or \`courseRules\` for an \`X\` rule). Do not apply them; do not flag them in review.`
125
+ );
126
+ lines.push("", "## Locked", "");
127
+ lines.push(`- ${locked.join(", ")} \u2014 cannot be turned off; listed above under their element.`);
128
+ return `${lines.join("\n")}
129
+ `;
130
+ }
131
+ function writeRulesInEffect(input, root = process.cwd()) {
132
+ const dir = join(root, "build");
133
+ mkdirSync(dir, { recursive: true });
134
+ const path = join(dir, "rules-in-effect.md");
135
+ writeFileSync(path, renderRulesInEffect(input));
136
+ return path;
137
+ }
138
+ export {
139
+ renderRulesInEffect,
140
+ rulesInEffect,
141
+ writeRulesInEffect
142
+ };