@davidnugent2425/manim-web-questions 0.1.0-dev.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.
- package/README.md +114 -0
- package/dist/index.js +877 -0
- package/dist/types/answer-reveal.d.ts +10 -0
- package/dist/types/arrow.d.ts +14 -0
- package/dist/types/basis-transform-scene.d.ts +37 -0
- package/dist/types/component-guides.d.ts +16 -0
- package/dist/types/coords.d.ts +32 -0
- package/dist/types/drag-target-scene.d.ts +82 -0
- package/dist/types/epoch.d.ts +9 -0
- package/dist/types/grab.d.ts +10 -0
- package/dist/types/grade.d.ts +5 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/interactive-scene.d.ts +26 -0
- package/dist/types/mathtex.d.ts +6 -0
- package/dist/types/matrix2.d.ts +27 -0
- package/dist/types/plane-scene.d.ts +33 -0
- package/dist/types/plane.d.ts +24 -0
- package/dist/types/polygon-drag-scene.d.ts +33 -0
- package/dist/types/question.d.ts +35 -0
- package/dist/types/rails.d.ts +6 -0
- package/dist/types/reference-vector.d.ts +19 -0
- package/dist/types/snapping.d.ts +14 -0
- package/dist/types/state.d.ts +8 -0
- package/dist/types/target.d.ts +2 -0
- package/dist/types/theme.d.ts +47 -0
- package/dist/types/vector-probes.d.ts +57 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# manim-web-questions
|
|
2
|
+
|
|
3
|
+
Graded interactive [manim-web](https://github.com/maloyan/manim-web) scenes: a
|
|
4
|
+
framework-agnostic mount/grade contract, reusable scene families, and an interaction
|
|
5
|
+
kit. A **scene** renders to a `<canvas>`, the user manipulates it (drag, click) to
|
|
6
|
+
answer, and the host grades it through a typed API — no UI framework required on either
|
|
7
|
+
side.
|
|
8
|
+
|
|
9
|
+
Published as **`@davidnugent2425/manim-web-questions`** (currently dev prereleases only;
|
|
10
|
+
see [Installing](#installing)).
|
|
11
|
+
|
|
12
|
+
## What's here
|
|
13
|
+
|
|
14
|
+
- **The scene contract** (`question.ts`) — the typed API an interactive exposes to any
|
|
15
|
+
host: `mount(container) → SceneApi` with `checkAnswer(): GradeResult | null`,
|
|
16
|
+
`reset()`, `dispose()`, and `getState()`/`onState(cb)` state subscription. A
|
|
17
|
+
`GradeResult` (`{ ok, correct? }`) carries correctness only — display wording stays
|
|
18
|
+
the host's choice.
|
|
19
|
+
- **The scene lifecycle factory** (`interactive-scene.ts`) — owns the build epoch, the
|
|
20
|
+
idle/not-ready/graded state machine, teardown, and a dev-only `window.__test` hook
|
|
21
|
+
(stripped from production builds) for driving scenes deterministically in browser
|
|
22
|
+
tests.
|
|
23
|
+
- **Three scene families**, one layer above the factory:
|
|
24
|
+
- `drag-target-scene.ts` — drag a vector onto a target (snap-on-release grid, margin
|
|
25
|
+
grading, answer reveal), with `decorate`/`reveal` hooks and predicate grading for
|
|
26
|
+
open-ended answers;
|
|
27
|
+
- `basis-transform-scene.ts` — drag î and ĵ to perform a linear transformation, with
|
|
28
|
+
opt-in labels, span parallelogram, and carried vector;
|
|
29
|
+
- `polygon-drag-scene.ts` — drag polygon corners, freely or along an L-shaped rail,
|
|
30
|
+
with per-corner margin grading.
|
|
31
|
+
- **The interaction kit** — the shared building blocks scenes compose: coordinate math,
|
|
32
|
+
snapping, grab forgiveness, arrows, async MathTex, rails, targets, answer reveal,
|
|
33
|
+
guides, and probes.
|
|
34
|
+
- **Pure helpers and the theme** — margin grading, 2×2 matrix math, the scene state
|
|
35
|
+
machine, build epochs, and the faithful 3b1b/manim palette (`theme.ts`).
|
|
36
|
+
|
|
37
|
+
[CONTEXT.md](CONTEXT.md) holds the module-by-module inventory. The only runtime
|
|
38
|
+
dependency is `manim-web`.
|
|
39
|
+
|
|
40
|
+
## Example
|
|
41
|
+
|
|
42
|
+
A minimal host mounts a scene and renders its own UI from emitted state:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { createDragTargetScene, type SceneState } from '@davidnugent2425/manim-web-questions';
|
|
46
|
+
|
|
47
|
+
const mount = createDragTargetScene({
|
|
48
|
+
question: 'drag-v-to-3-2',
|
|
49
|
+
start: [1, 1],
|
|
50
|
+
target: [3, 2],
|
|
51
|
+
labelLatex: '\\vec{v}',
|
|
52
|
+
labelPoint: (dot) => [dot.x + 0.4, dot.y + 0.4, 0],
|
|
53
|
+
gradedLabelPoint: (tip) => [tip[0] + 0.4, tip[1] + 0.4, 0],
|
|
54
|
+
createExtra: () => ({}),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const api = mount(document.getElementById('scene-container')!);
|
|
58
|
+
api.onState((state: SceneState) => {
|
|
59
|
+
if (state.kind === 'graded') {
|
|
60
|
+
showVerdict(state.result.ok); // wording/UI is the host's job
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
checkButton.onclick = () => api.checkAnswer();
|
|
65
|
+
resetButton.onclick = () => api.reset();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Real-world example
|
|
69
|
+
|
|
70
|
+
**[community-3b1b-quizzes](https://github.com/davidnugent2425/community-3b1b-quizzes)**
|
|
71
|
+
is the flagship consumer: a Vue 3 quiz shell with fourteen lessons of linear-algebra
|
|
72
|
+
comprehension questions for 3Blue1Brown's catalogue, whose interactive questions are all
|
|
73
|
+
built from this package's scene families.
|
|
74
|
+
|
|
75
|
+
## Installing
|
|
76
|
+
|
|
77
|
+
Only dev prereleases exist so far, published under the `dev` dist-tag (there is no
|
|
78
|
+
`latest` yet):
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pnpm add @davidnugent2425/manim-web-questions@dev
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Development
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pnpm install
|
|
88
|
+
pnpm typecheck && pnpm lint && pnpm format:check && pnpm test
|
|
89
|
+
pnpm build # dist/index.js + dist/types/
|
|
90
|
+
pnpm exec playwright install chromium # once
|
|
91
|
+
pnpm test:e2e # browser mechanics suite against the e2e/harness fixtures
|
|
92
|
+
npm pack --dry-run
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`pnpm dev` serves the e2e harness (a plain HTML page mounting the fixture scenes) on
|
|
96
|
+
http://localhost:8080 for interactive poking.
|
|
97
|
+
|
|
98
|
+
CI runs all of these on every push. Publishing is manual and maintainer-only, never CI:
|
|
99
|
+
dev prereleases (`0.1.0-dev.N`) go out with `npm publish --tag dev` so nothing lands on
|
|
100
|
+
`latest`, and every publish goes to the user-scoped `@davidnugent2425/manim-web-questions`
|
|
101
|
+
(the unscoped name is deliberately unclaimed). `prepack` rebuilds `dist/`, and
|
|
102
|
+
`publishConfig.access: "public"` is set, so no extra flags are needed.
|
|
103
|
+
|
|
104
|
+
## Supply chain
|
|
105
|
+
|
|
106
|
+
`pnpm-workspace.yaml` enforces a 7-day `minimumReleaseAge` on dependency versions and a
|
|
107
|
+
`no-downgrade` trust policy; see the comments there for the typia pin rationale.
|
|
108
|
+
|
|
109
|
+
## Provenance
|
|
110
|
+
|
|
111
|
+
Extracted from
|
|
112
|
+
[community-3b1b-quizzes](https://github.com/davidnugent2425/community-3b1b-quizzes),
|
|
113
|
+
where the layer was built question-by-question; this repository retains that full git
|
|
114
|
+
history, so `git log`/`git blame` reach back through the extraction.
|