explico 0.1.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 (113) hide show
  1. package/README.md +108 -0
  2. package/dist/analytics/AnalyticsEmitter.d.ts +22 -0
  3. package/dist/analytics/AnalyticsEmitter.js +5 -0
  4. package/dist/compiler/cli.d.ts +189 -0
  5. package/dist/compiler/cli.js +552 -0
  6. package/dist/compiler/collections.d.ts +70 -0
  7. package/dist/compiler/collections.js +383 -0
  8. package/dist/compiler/course-config.d.ts +31 -0
  9. package/dist/compiler/course-config.js +0 -0
  10. package/dist/compiler/lesson-derivation.d.ts +89 -0
  11. package/dist/compiler/lesson-derivation.js +91 -0
  12. package/dist/compiler/manifest.d.ts +178 -0
  13. package/dist/compiler/manifest.js +345 -0
  14. package/dist/compiler/resolution-report.d.ts +45 -0
  15. package/dist/compiler/resolution-report.js +97 -0
  16. package/dist/curriculum/validation.d.ts +76 -0
  17. package/dist/curriculum/validation.js +320 -0
  18. package/dist/progress/ProgressRepository.d.ts +53 -0
  19. package/dist/progress/ProgressRepository.js +12 -0
  20. package/dist/reference/base-library.mjs +27 -0
  21. package/dist/reference/citation-format.mjs +133 -0
  22. package/dist/reference/consistency.d.ts +64 -0
  23. package/dist/reference/consistency.js +234 -0
  24. package/dist/reference/curriculum-alignment.d.ts +7 -0
  25. package/dist/reference/curriculum-alignment.js +166 -0
  26. package/dist/reference/equations-validate.d.ts +50 -0
  27. package/dist/reference/equations-validate.js +90 -0
  28. package/dist/reference/equations.mjs +144 -0
  29. package/dist/reference/gate-math.d.ts +41 -0
  30. package/dist/reference/gate-math.js +151 -0
  31. package/dist/reference/katex-options.mjs +91 -0
  32. package/dist/reference/lab-math-scope.d.ts +21 -0
  33. package/dist/reference/lab-math-scope.js +28 -0
  34. package/dist/reference/label.d.ts +11 -0
  35. package/dist/reference/label.js +38 -0
  36. package/dist/reference/lint-ignore.d.ts +32 -0
  37. package/dist/reference/lint-ignore.js +39 -0
  38. package/dist/reference/math-glyphs.mjs +830 -0
  39. package/dist/reference/prose.d.ts +15 -0
  40. package/dist/reference/prose.js +12 -0
  41. package/dist/reference/references.d.ts +17 -0
  42. package/dist/reference/references.js +42 -0
  43. package/dist/reference/registry.d.ts +6 -0
  44. package/dist/reference/registry.js +548 -0
  45. package/dist/reference/rehype-fail-katex-errors.mjs +55 -0
  46. package/dist/reference/remark-citation.mjs +0 -0
  47. package/dist/reference/remark-notation.mjs +753 -0
  48. package/dist/reference/render-lab-math.d.ts +21 -0
  49. package/dist/reference/render-lab-math.js +58 -0
  50. package/dist/reference/types.d.ts +151 -0
  51. package/dist/reference/types.js +0 -0
  52. package/dist/reference/units-vocab.d.ts +26 -0
  53. package/dist/reference/units-vocab.js +119 -0
  54. package/dist/session/PreferenceStore.d.ts +28 -0
  55. package/dist/session/PreferenceStore.js +30 -0
  56. package/dist/session/user-context.d.ts +7 -0
  57. package/dist/session/user-context.js +10 -0
  58. package/dist/session/user.d.ts +21 -0
  59. package/dist/session/user.js +8 -0
  60. package/package.json +53 -0
  61. package/src/analytics/AnalyticsEmitter.ts +23 -0
  62. package/src/compiler/cli.ts +866 -0
  63. package/src/compiler/collections.ts +554 -0
  64. package/src/compiler/course-config.ts +32 -0
  65. package/src/compiler/lesson-derivation.ts +186 -0
  66. package/src/compiler/manifest.ts +601 -0
  67. package/src/compiler/resolution-report.ts +150 -0
  68. package/src/components/CurriculumMap.astro +208 -0
  69. package/src/components/HoverPanel.astro +67 -0
  70. package/src/components/assessments/AssessmentRunner.tsx +320 -0
  71. package/src/components/assessments/AssessmentSet.astro +54 -0
  72. package/src/components/citation/CitationLayer.astro +173 -0
  73. package/src/components/examples/CompactExample.astro +34 -0
  74. package/src/components/examples/CompactExamples.astro +253 -0
  75. package/src/components/hover-panel.ts +273 -0
  76. package/src/components/notation/NotationGlossary.astro +412 -0
  77. package/src/components/notation/NotationLayer.astro +594 -0
  78. package/src/components/notation/NotationMath.astro +24 -0
  79. package/src/components/notation/SafeMathNode.astro +23 -0
  80. package/src/components/notation/render-notation-math.ts +223 -0
  81. package/src/components/starlight/EquationEnhancer.astro +72 -0
  82. package/src/components/starlight/LayoutHeader.astro +102 -0
  83. package/src/components/starlight/LayoutPageSidebar.astro +33 -0
  84. package/src/components/starlight/LayoutSidebar.astro +29 -0
  85. package/src/components/starlight/LessonFooter.astro +58 -0
  86. package/src/content-config.ts +259 -0
  87. package/src/curriculum/validation.ts +481 -0
  88. package/src/progress/ProgressRepository.ts +64 -0
  89. package/src/reference/base-library.mjs +27 -0
  90. package/src/reference/citation-format.mjs +133 -0
  91. package/src/reference/consistency.ts +375 -0
  92. package/src/reference/curriculum-alignment.ts +228 -0
  93. package/src/reference/equations-validate.ts +167 -0
  94. package/src/reference/equations.mjs +144 -0
  95. package/src/reference/gate-math.ts +250 -0
  96. package/src/reference/katex-options.mjs +91 -0
  97. package/src/reference/lab-math-scope.ts +54 -0
  98. package/src/reference/label.ts +47 -0
  99. package/src/reference/lint-ignore.ts +75 -0
  100. package/src/reference/math-glyphs.mjs +830 -0
  101. package/src/reference/prose.ts +21 -0
  102. package/src/reference/references.ts +82 -0
  103. package/src/reference/registry.ts +723 -0
  104. package/src/reference/rehype-fail-katex-errors.mjs +55 -0
  105. package/src/reference/remark-citation.mjs +0 -0
  106. package/src/reference/remark-notation.mjs +753 -0
  107. package/src/reference/render-lab-math.ts +99 -0
  108. package/src/reference/types.ts +182 -0
  109. package/src/reference/units-vocab.ts +143 -0
  110. package/src/session/PreferenceStore.ts +54 -0
  111. package/src/session/user-context.ts +18 -0
  112. package/src/session/user.ts +24 -0
  113. package/src/styles/global.css +763 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Under-specification safeguard for notation `meaning` prose (Phase C1b).
3
+ *
4
+ * A page-local symbol must not get a glossary-style panel for a throwaway
5
+ * definition, so `meaning` has to be real prose: at least four words and not a
6
+ * placeholder phrase. Used by the content schema (`src/content.config.ts`) and
7
+ * the loader so a bad entry fails both `astro check` and `validate:content`.
8
+ */
9
+
10
+ /** Placeholder phrases that do not count as a substantive `meaning`. */
11
+ export const PLACEHOLDER_PROSE =
12
+ /^(?:a\s+(?:variable|value|quantity|constant|parameter|symbol)|tbd|todo|fixme|see\s+above|as\s+above|placeholder|n\/a)\.?$/i;
13
+
14
+ /** Minimum words for a `meaning` to read as a definition rather than a label. */
15
+ export const MEANING_MIN_WORDS = 4;
16
+
17
+ export function isSubstantiveMeaning(value: string): boolean {
18
+ const trimmed = value.trim();
19
+ if (PLACEHOLDER_PROSE.test(trimmed)) return false;
20
+ return trimmed.split(/\s+/).filter(Boolean).length >= MEANING_MIN_WORDS;
21
+ }
@@ -0,0 +1,82 @@
1
+ import type {
2
+ NotationDefinitionScope,
3
+ NotationDiagnostic,
4
+ SourceSpan,
5
+ } from './types';
6
+
7
+ export const NOTATION_KEY_PATTERN = /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;
8
+
9
+ export function isNotationKey(value: string): boolean {
10
+ return NOTATION_KEY_PATTERN.test(value);
11
+ }
12
+
13
+ export function sharedDefinitionId(key: string): string {
14
+ return `shared:${key}`;
15
+ }
16
+
17
+ export function localDefinitionId(lessonId: string, key: string): string {
18
+ return `page:${lessonId}:${key}`;
19
+ }
20
+
21
+ export function definitionId(
22
+ scope: NotationDefinitionScope,
23
+ key: string,
24
+ ): string {
25
+ return scope.kind === 'shared'
26
+ ? sharedDefinitionId(key)
27
+ : localDefinitionId(scope.lessonId, key);
28
+ }
29
+
30
+ /**
31
+ * Resolve by lexical scope. Page content and page-local definition bodies see
32
+ * local definitions first, then shared definitions. Shared definition bodies
33
+ * can only see shared definitions, so their meaning cannot change by caller.
34
+ */
35
+ export function resolveReferenceId(
36
+ key: string,
37
+ scope: NotationDefinitionScope,
38
+ availableDefinitionIds: ReadonlySet<string>,
39
+ ): string | undefined {
40
+ if (scope.kind === 'page') {
41
+ const localId = localDefinitionId(scope.lessonId, key);
42
+ if (availableDefinitionIds.has(localId)) return localId;
43
+ }
44
+
45
+ const sharedId = sharedDefinitionId(key);
46
+ return availableDefinitionIds.has(sharedId) ? sharedId : undefined;
47
+ }
48
+
49
+ export function compareSourceSpans(
50
+ left: SourceSpan | undefined,
51
+ right: SourceSpan | undefined,
52
+ ): number {
53
+ if (left === undefined) return right === undefined ? 0 : 1;
54
+ if (right === undefined) return -1;
55
+
56
+ return (
57
+ left.file.localeCompare(right.file) ||
58
+ (left.line ?? 0) - (right.line ?? 0) ||
59
+ (left.column ?? 0) - (right.column ?? 0) ||
60
+ (left.endLine ?? 0) - (right.endLine ?? 0) ||
61
+ (left.endColumn ?? 0) - (right.endColumn ?? 0)
62
+ );
63
+ }
64
+
65
+ export function compareDiagnostics(
66
+ left: NotationDiagnostic,
67
+ right: NotationDiagnostic,
68
+ ): number {
69
+ return (
70
+ severityRank(left.severity) - severityRank(right.severity) ||
71
+ left.code.localeCompare(right.code) ||
72
+ (left.lessonId ?? '').localeCompare(right.lessonId ?? '') ||
73
+ (left.key ?? '').localeCompare(right.key ?? '') ||
74
+ (left.definitionId ?? '').localeCompare(right.definitionId ?? '') ||
75
+ compareSourceSpans(left.source, right.source) ||
76
+ left.message.localeCompare(right.message)
77
+ );
78
+ }
79
+
80
+ function severityRank(severity: NotationDiagnostic['severity']): number {
81
+ return severity === 'error' ? 0 : 1;
82
+ }