explico 0.4.0 → 0.5.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.
Files changed (143) hide show
  1. package/CHANGELOG.md +273 -1
  2. package/README.md +103 -8
  3. package/dist/compiler/astro.d.ts +9 -1
  4. package/dist/compiler/astro.js +182 -3
  5. package/dist/compiler/cli.d.ts +13 -0
  6. package/dist/compiler/cli.js +28 -4
  7. package/dist/compiler/collections.d.ts +3 -2
  8. package/dist/compiler/collections.js +28 -1
  9. package/dist/compiler/course-config.d.ts +58 -1
  10. package/dist/compiler/course-config.js +28 -1
  11. package/dist/compiler/exports/standalone-html.d.ts +34 -0
  12. package/dist/compiler/exports/standalone-html.js +803 -0
  13. package/dist/compiler/manifest.d.ts +90 -6
  14. package/dist/compiler/manifest.js +150 -17
  15. package/dist/compiler/resolution-report.d.ts +4 -0
  16. package/dist/reference/base-abbreviations.d.mts +30 -0
  17. package/dist/reference/base-abbreviations.mjs +60 -0
  18. package/dist/reference/base-operators.d.mts +15 -0
  19. package/dist/reference/base-operators.mjs +40 -0
  20. package/dist/reference/base-roman-labels.d.mts +35 -0
  21. package/dist/reference/base-roman-labels.mjs +43 -0
  22. package/dist/reference/consistency.d.ts +8 -2
  23. package/dist/reference/consistency.js +50 -3
  24. package/dist/reference/diagrams-validate.d.ts +21 -0
  25. package/dist/reference/diagrams-validate.js +13 -0
  26. package/dist/reference/equations.d.mts +10 -15
  27. package/dist/reference/equations.mjs +67 -14
  28. package/dist/reference/gate-abbreviations.d.ts +17 -0
  29. package/dist/reference/gate-abbreviations.js +64 -0
  30. package/dist/reference/gate-math.d.ts +28 -5
  31. package/dist/reference/gate-math.js +5 -2
  32. package/dist/reference/gate-prose-notation.d.ts +60 -0
  33. package/dist/reference/gate-prose-notation.js +125 -0
  34. package/dist/reference/keyed-float-validate.d.ts +5 -5
  35. package/dist/reference/keyed-jsx-floats.d.mts +7 -12
  36. package/dist/reference/keyed-jsx-floats.mjs +50 -25
  37. package/dist/reference/knowledge-checks-validate.d.ts +35 -0
  38. package/dist/reference/knowledge-checks-validate.js +78 -0
  39. package/dist/reference/knowledge-checks.d.mts +25 -0
  40. package/dist/reference/knowledge-checks.mjs +45 -0
  41. package/dist/reference/lab-math-scope.d.ts +9 -1
  42. package/dist/reference/lab-math-scope.js +32 -4
  43. package/dist/reference/math-glyphs.d.mts +30 -0
  44. package/dist/reference/math-glyphs.mjs +367 -0
  45. package/dist/reference/mdx-attributes.d.mts +13 -0
  46. package/dist/reference/mdx-attributes.mjs +38 -0
  47. package/dist/reference/mixed-content.d.ts +17 -0
  48. package/dist/reference/mixed-content.js +29 -0
  49. package/dist/reference/page-notation.d.ts +52 -0
  50. package/dist/reference/page-notation.js +171 -0
  51. package/dist/reference/raw-floats-validate.d.ts +18 -0
  52. package/dist/reference/raw-floats-validate.js +53 -0
  53. package/dist/reference/raw-floats.d.mts +18 -0
  54. package/dist/reference/raw-floats.mjs +129 -0
  55. package/dist/reference/rehype-heading-anchors.d.mts +1 -1
  56. package/dist/reference/rehype-heading-anchors.mjs +107 -1
  57. package/dist/reference/rehype-table-header-labels.d.mts +26 -0
  58. package/dist/reference/rehype-table-header-labels.mjs +152 -0
  59. package/dist/reference/remark-abbreviations.d.mts +7 -0
  60. package/dist/reference/remark-abbreviations.mjs +174 -0
  61. package/dist/reference/remark-memo.d.mts +16 -0
  62. package/dist/reference/remark-memo.mjs +339 -0
  63. package/dist/reference/remark-notation.d.mts +57 -9
  64. package/dist/reference/remark-notation.mjs +354 -42
  65. package/dist/reference/remark-short-note.d.mts +4 -0
  66. package/dist/reference/remark-short-note.mjs +237 -0
  67. package/dist/reference/types.d.ts +16 -1
  68. package/dist/reference/units-vocab.js +4 -0
  69. package/docs/VERSIONING.md +33 -4
  70. package/docs/authoring/README.md +8 -0
  71. package/docs/authoring/agents.md +17 -2
  72. package/docs/authoring/components.md +135 -0
  73. package/docs/authoring/migrating.md +92 -7
  74. package/docs/authoring/notation.md +560 -1
  75. package/docs/authoring/structure.md +120 -8
  76. package/docs/authoring/visualizations.md +36 -3
  77. package/package.json +5 -2
  78. package/src/compiler/astro.ts +208 -3
  79. package/src/compiler/cli.ts +29 -2
  80. package/src/compiler/collections.ts +45 -4
  81. package/src/compiler/course-config.ts +92 -0
  82. package/src/compiler/exports/standalone-html.ts +963 -0
  83. package/src/compiler/manifest.ts +268 -22
  84. package/src/components/HoverPanel.astro +45 -4
  85. package/src/components/abbreviation/AbbreviationGlossary.astro +70 -0
  86. package/src/components/abbreviation/AbbreviationLayer.astro +127 -0
  87. package/src/components/assessments/AssessmentRunner.tsx +52 -17
  88. package/src/components/assessments/AssessmentSet.astro +98 -14
  89. package/src/components/assessments/RenderedContent.tsx +55 -0
  90. package/src/components/assessments/assessment-randomization.ts +16 -0
  91. package/src/components/diagram/Diagram.astro +444 -83
  92. package/src/components/disclosure/hover-preview.ts +202 -0
  93. package/src/components/disclosure/persisted-disclosure.ts +66 -0
  94. package/src/components/examples/CompactExamples.astro +2 -0
  95. package/src/components/figure/Figure.astro +279 -10
  96. package/src/components/memo/Memo.astro +453 -0
  97. package/src/components/memo/ShortNote.astro +223 -0
  98. package/src/components/notation/NotationFormula.astro +18 -1
  99. package/src/components/notation/NotationLayer.astro +105 -8
  100. package/src/components/notation/render-notation-math.ts +39 -2
  101. package/src/components/notation/safe-math-to-react.ts +50 -0
  102. package/src/components/reference/FloatRefLayer.astro +233 -15
  103. package/src/components/starlight/CollapsibleSections.astro +461 -0
  104. package/src/components/starlight/DiagramEnhancer.astro +385 -0
  105. package/src/components/starlight/HeadingAnchorEnhancer.astro +5 -17
  106. package/src/components/starlight/KeyedFloatEnhancer.astro +81 -3
  107. package/src/components/starlight/LayoutHeader.astro +50 -0
  108. package/src/components/starlight/LayoutSocialIcons.astro +41 -2
  109. package/src/components/starlight/LessonExportActions.astro +436 -0
  110. package/src/components/starlight/LessonFooter.astro +27 -2
  111. package/src/components/starlight/section-parts.ts +31 -0
  112. package/src/components/table/Table.astro +293 -7
  113. package/src/components/table/TableOverflowExpander.astro +489 -0
  114. package/src/content-config.ts +20 -0
  115. package/src/reference/base-abbreviations.mjs +60 -0
  116. package/src/reference/base-operators.mjs +40 -0
  117. package/src/reference/base-roman-labels.mjs +43 -0
  118. package/src/reference/consistency.ts +73 -2
  119. package/src/reference/diagrams-validate.ts +40 -0
  120. package/src/reference/equations.mjs +67 -14
  121. package/src/reference/gate-abbreviations.ts +128 -0
  122. package/src/reference/gate-math.ts +27 -7
  123. package/src/reference/gate-prose-notation.ts +224 -0
  124. package/src/reference/keyed-float-validate.ts +5 -5
  125. package/src/reference/keyed-jsx-floats.mjs +50 -25
  126. package/src/reference/knowledge-checks-validate.ts +130 -0
  127. package/src/reference/knowledge-checks.mjs +45 -0
  128. package/src/reference/lab-math-scope.ts +45 -3
  129. package/src/reference/math-glyphs.mjs +367 -0
  130. package/src/reference/mdx-attributes.mjs +38 -0
  131. package/src/reference/mixed-content.ts +69 -0
  132. package/src/reference/page-notation.ts +252 -0
  133. package/src/reference/raw-floats-validate.ts +103 -0
  134. package/src/reference/raw-floats.mjs +129 -0
  135. package/src/reference/rehype-heading-anchors.mjs +107 -1
  136. package/src/reference/rehype-table-header-labels.mjs +152 -0
  137. package/src/reference/remark-abbreviations.mjs +174 -0
  138. package/src/reference/remark-memo.mjs +339 -0
  139. package/src/reference/remark-notation.mjs +354 -42
  140. package/src/reference/remark-short-note.mjs +237 -0
  141. package/src/reference/types.ts +16 -0
  142. package/src/reference/units-vocab.ts +4 -0
  143. package/src/styles/global.css +996 -50
@@ -49,6 +49,39 @@ export interface CourseOperators {
49
49
  readonly deny?: readonly string[];
50
50
  }
51
51
 
52
+ /**
53
+ * A course's edits to the shipped roman-label baseline (`BASE_ROMAN_LABELS`),
54
+ * consumed by the `roman-label-explained` consistency check (rule N10). A
55
+ * `\mathrm{…}` multi-letter label a lesson uses is fine when it is on the
56
+ * baseline plus `allow` minus `deny`; otherwise it needs a notation entry the
57
+ * reader can hover. Same shape as {@link CourseOperators}, one level down:
58
+ * this governs `\mathrm{KE}`-style labels, not `\operatorname{Var}`-style
59
+ * operators.
60
+ */
61
+ export interface CourseRomanLabels {
62
+ /** Labels this course also treats as universal qualifiers (`eff`, `net`, …). */
63
+ readonly allow?: readonly string[];
64
+ /** Baseline labels this course wants explained anyway. */
65
+ readonly deny?: readonly string[];
66
+ }
67
+
68
+ /**
69
+ * A course's edits to the shipped abbreviation baseline (`BASE_ABBREVIATIONS`),
70
+ * consumed by the `abbreviation-explained` gate (rule N14). An abbreviation-
71
+ * shaped token — an all-caps acronym or a dotted form like `w.r.t.` — a
72
+ * lesson uses in prose is fine when it is on the baseline plus `allow` minus
73
+ * `deny`; otherwise it needs an entry in the `abbreviations` content
74
+ * collection, or — if it also names a math quantity — a notation entry the
75
+ * reader can hover. Same shape as {@link CourseOperators} / {@link
76
+ * CourseRomanLabels}.
77
+ */
78
+ export interface CourseAbbreviations {
79
+ /** Abbreviations this course also treats as universal (`GDP`, `CPU`, …). */
80
+ readonly allow?: readonly string[];
81
+ /** Baseline abbreviations this course wants explained anyway. */
82
+ readonly deny?: readonly string[];
83
+ }
84
+
52
85
  /** One person or team credited for the study material. */
53
86
  export interface CourseAuthor {
54
87
  readonly name: string;
@@ -83,6 +116,26 @@ export interface CourseAbout {
83
116
  readonly changelogHref?: string;
84
117
  }
85
118
 
119
+ /** Optional, build-time lesson artifacts exposed to readers. */
120
+ export interface LessonExportsConfig {
121
+ /** Emit one self-contained, offline-capable HTML file per lesson. */
122
+ readonly standaloneHtml?: boolean;
123
+ /** Offer the browser's native print dialog with explico's lesson print layout. */
124
+ readonly print?: boolean;
125
+ /**
126
+ * Published course root used for links that intentionally leave the exported
127
+ * lesson. Required at export time when such a link is present.
128
+ */
129
+ readonly canonicalBaseUrl?: string;
130
+ }
131
+
132
+ /** The stable, non-optional export settings carried by the manifest. */
133
+ export interface NormalizedLessonExports {
134
+ readonly standaloneHtml: boolean;
135
+ readonly print: boolean;
136
+ readonly canonicalBaseUrl?: string;
137
+ }
138
+
86
139
  export interface CourseConfig {
87
140
  readonly title: string;
88
141
  readonly description: string;
@@ -103,6 +156,45 @@ export interface CourseConfig {
103
156
  readonly about: CourseAbout;
104
157
  /** Edits to the shipped named-operator baseline (rule N8). Optional. */
105
158
  readonly operators?: CourseOperators;
159
+ /** Edits to the shipped roman-label baseline (rule N10). Optional. */
160
+ readonly romanLabels?: CourseRomanLabels;
161
+ /** Edits to the shipped abbreviation baseline (rule N14). Optional. */
162
+ readonly abbreviations?: CourseAbbreviations;
163
+ /** Per-lesson export actions and downloadable artifacts. Disabled when omitted. */
164
+ readonly lessonExports?: LessonExportsConfig;
165
+ }
166
+
167
+ /** Validate and canonicalize the build-facing lesson-export configuration. */
168
+ export function normalizeLessonExports(
169
+ config: CourseConfig,
170
+ ): NormalizedLessonExports {
171
+ const standaloneHtml = config.lessonExports?.standaloneHtml === true;
172
+ const print = config.lessonExports?.print === true;
173
+ const rawBase = config.lessonExports?.canonicalBaseUrl;
174
+ if (rawBase === undefined) return { standaloneHtml, print };
175
+
176
+ let parsed: URL;
177
+ try {
178
+ parsed = new URL(rawBase);
179
+ } catch {
180
+ throw new Error(
181
+ `CourseConfig lessonExports.canonicalBaseUrl must be an absolute ` +
182
+ `http(s) URL; received ${JSON.stringify(rawBase)}.`,
183
+ );
184
+ }
185
+ if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
186
+ throw new Error(
187
+ `CourseConfig lessonExports.canonicalBaseUrl must use http(s); ` +
188
+ `received ${JSON.stringify(rawBase)}.`,
189
+ );
190
+ }
191
+ if (parsed.search || parsed.hash) {
192
+ throw new Error(
193
+ 'CourseConfig lessonExports.canonicalBaseUrl cannot contain a query or fragment.',
194
+ );
195
+ }
196
+ if (!parsed.pathname.endsWith('/')) parsed.pathname += '/';
197
+ return { standaloneHtml, print, canonicalBaseUrl: parsed.toString() };
106
198
  }
107
199
 
108
200
  /**