@nakafa/aksara-contracts 8.13.0 → 8.14.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.
@@ -0,0 +1,87 @@
1
+ import { Schema } from "effect";
2
+ import { byIds, byPickedIds, cardFields, namesEach, TextSchema, } from "#contracts/visual/card";
3
+ import { answerAt, figure } from "#contracts/visual/entry";
4
+ /** A strictly positive finite setting for quantum physics sliders. */
5
+ const PositiveSchema = Schema.Finite.check(Schema.isGreaterThan(0));
6
+ /** A strictly positive slider whose minimum sits below its maximum. */
7
+ const PositiveSliderSchema = Schema.Struct({
8
+ max: PositiveSchema,
9
+ min: PositiveSchema,
10
+ value: PositiveSchema,
11
+ }).check(Schema.makeFilter(({ max, min, value }) => min < max && min <= value && value <= max, {
12
+ message: "Expected a positive slider range whose minimum is below its maximum, with the starting value between them.",
13
+ }));
14
+ const PARTICLES = ["electron", "proton", "neutron", "alpha"];
15
+ const RADIATION_MODELS = ["planck", "classical"];
16
+ /**
17
+ * Props of `DeBroglieMatterWaveLab`: a 3D electron-diffraction tube and
18
+ * standing matter-wave view linking accelerating voltage and particle mass to
19
+ * de Broglie wavelength and diffraction ring spacing. Wavelength and
20
+ * diffraction readouts are optional answer state.
21
+ */
22
+ function deBroglieMatterWaveLab(rich) {
23
+ return figure(Schema.Struct({
24
+ ...cardFields(rich),
25
+ labels: Schema.Struct({
26
+ diffraction: Schema.optionalKey(rich),
27
+ momentum: rich,
28
+ particle: TextSchema,
29
+ particles: byPickedIds(PARTICLES, TextSchema),
30
+ parts: byIds([
31
+ "electronGun",
32
+ "graphiteTarget",
33
+ "matterWave",
34
+ "diffractionRings",
35
+ "screen",
36
+ ], TextSchema),
37
+ view: TextSchema,
38
+ voltage: TextSchema,
39
+ wavelength: Schema.optionalKey(rich),
40
+ }),
41
+ particles: Schema.NonEmptyArray(Schema.Literals(PARTICLES)).check(Schema.isUnique()),
42
+ voltage: PositiveSliderSchema,
43
+ }).check(Schema.makeFilter(({ labels, particles }) => namesEach(particles, labels.particles), {
44
+ message: "Expected a name for every particle shown in the matter-wave lab, and no other.",
45
+ })), answerAt(["labels", "diffraction"], ["labels", "wavelength"]));
46
+ }
47
+ /**
48
+ * Props of `PlanckBlackbodyLab`: a 3D heated cavity radiator synchronized with
49
+ * Planck's quantized blackbody spectrum and the classical Rayleigh-Jeans curve
50
+ * across Kelvin temperature. Peak wavelength and photon energy readouts are
51
+ * optional answer state.
52
+ */
53
+ function planckBlackbodyLab(rich) {
54
+ return figure(Schema.Struct({
55
+ ...cardFields(rich),
56
+ labels: Schema.Struct({
57
+ model: TextSchema,
58
+ models: byPickedIds(RADIATION_MODELS, TextSchema),
59
+ parts: byIds([
60
+ "cavity",
61
+ "planckCurve",
62
+ "classicalCurve",
63
+ "visibleBand",
64
+ "peakMarker",
65
+ ], TextSchema),
66
+ peakWavelength: Schema.optionalKey(rich),
67
+ photonEnergy: Schema.optionalKey(rich),
68
+ spectrum: rich,
69
+ temperature: TextSchema,
70
+ view: TextSchema,
71
+ }),
72
+ models: Schema.NonEmptyArray(Schema.Literals(RADIATION_MODELS)).check(Schema.isUnique()),
73
+ temperature: PositiveSliderSchema,
74
+ }).check(Schema.makeFilter(({ labels, models }) => namesEach(models, labels.models), {
75
+ message: "Expected a name for every radiation model shown, and no other.",
76
+ })), answerAt(["labels", "peakWavelength"], ["labels", "photonEnergy"]));
77
+ }
78
+ /**
79
+ * Quantum physics labs covering de Broglie matter-wave diffraction and
80
+ * Planck blackbody quantization.
81
+ */
82
+ export function quantumVisuals(rich) {
83
+ return {
84
+ DeBroglieMatterWaveLab: deBroglieMatterWaveLab(rich),
85
+ PlanckBlackbodyLab: planckBlackbodyLab(rich),
86
+ };
87
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nakafa/aksara-contracts",
3
- "version": "8.13.0",
3
+ "version": "8.14.0",
4
4
  "description": "Schemas and verification contracts for Nakafa content releases.",
5
5
  "homepage": "https://github.com/nakafaai/aksara#readme",
6
6
  "license": "SEE LICENSE IN LICENSE",