@davidnugent2425/manim-web-questions 0.1.0-dev.1 → 0.1.0-dev.3

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 CHANGED
@@ -1,45 +1,29 @@
1
1
  # manim-web-questions
2
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 `window.__test` hook for driving
21
- scenes deterministically in browser tests — on in dev builds, otherwise off unless a
22
- consumer opts in with `enableTestHook()`.
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:
3
+ Graded interactive [manim-web](https://github.com/maloyan/manim-web) scenes for the browser.
4
+ A scene renders to a `<canvas>`, the reader manipulates it (drag, click) to answer, and the
5
+ host grades it through a small typed API. No UI framework is required on either side, and
6
+ the only runtime dependency is `manim-web`.
7
+
8
+ ## Install
9
+
10
+ > Not on the public registry yet. Once it lands the install line becomes
11
+ > `npm install <FINAL_NPM_PACKAGE_NAME>` and the package page will live at
12
+ > `https://www.npmjs.com/package/<FINAL_NPM_PACKAGE_NAME>`.
13
+
14
+ Development prereleases are published under the `dev` dist-tag (there is no `latest` yet):
15
+
16
+ ```bash
17
+ npm install @davidnugent2425/manim-web-questions@dev
18
+ ```
19
+
20
+ Node 22 or newer (Node 20 reached end of life in April 2026). The published artifact is
21
+ `dist/` (ESM plus type declarations), so any bundler that understands ESM works.
22
+
23
+ ## Use it
24
+
25
+ Pick a scene family, hand it a spec, mount the returned function into an element, and drive
26
+ it through the returned `SceneApi`:
43
27
 
44
28
  ```ts
45
29
  import { createDragTargetScene, type SceneState } from '@davidnugent2425/manim-web-questions';
@@ -54,61 +38,56 @@ const mount = createDragTargetScene({
54
38
  createExtra: () => ({}),
55
39
  });
56
40
 
57
- const api = mount(document.getElementById('scene-container')!);
41
+ const api = mount(document.getElementById('scene')!);
42
+
58
43
  api.onState((state: SceneState) => {
59
- if (state.kind === 'graded') {
60
- showVerdict(state.result.ok); // wording/UI is the host's job
61
- }
44
+ if (state.kind === 'graded') showVerdict(state.result.ok); // wording is yours
62
45
  });
63
46
 
64
47
  checkButton.onclick = () => api.checkAnswer();
65
48
  resetButton.onclick = () => api.reset();
66
49
  ```
67
50
 
68
- ### Real-world example
51
+ That is the whole integration surface. A host supplies a container, controls that call
52
+ `checkAnswer()` / `reset()`, and verdict UI rendered from emitted state. The scene never
53
+ touches DOM outside its container and never decides wording, so grading results carry
54
+ correctness only.
69
55
 
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.
56
+ Three scene families ship today: dragging one vector onto a target, dragging î and ĵ to
57
+ perform a linear transformation, and dragging polygon corners. Canvas geometry, snapping
58
+ and drag limits are per-scene options, and colors, fonts and arrow styling come from a
59
+ package-wide theme that defaults to the familiar 3b1b look.
74
60
 
75
- ## Installing
61
+ [**Scene families, options and the interaction kit**](src/README.md) covers all of that in
62
+ detail, including a plain-HTML host and a Vue host you can copy.
63
+ [community-3b1b-quizzes](https://github.com/davidnugent2425/community-3b1b-quizzes) is a
64
+ full Vue host built on this package, with fourteen lessons of linear-algebra questions. Its
65
+ lesson list, and one of its questions running a scene from here:
76
66
 
77
- Only dev prereleases exist so far, published under the `dev` dist-tag (there is no
78
- `latest` yet):
67
+ | A host built on this package | One of its graded scenes |
68
+ | ------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
69
+ | ![The community-3b1b-quizzes lesson list, one row per chapter with a poster and a start link](docs/images/quizzes-lessons.webp) | ![The basis vectors dragged to shear a shaded parallelogram over a grid](docs/images/quizzes-interactive.webp) |
79
70
 
80
- ```bash
81
- pnpm add @davidnugent2425/manim-web-questions@dev
82
- ```
83
-
84
- ## Development
71
+ ## Develop
85
72
 
86
73
  ```bash
87
74
  pnpm install
88
75
  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
76
+ pnpm build
77
+ pnpm dev # plain HTML page mounting the fixture scenes, http://localhost:8080
93
78
  ```
94
79
 
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
80
+ `pnpm test:e2e` runs the browser suite in Chromium, see [e2e/README.md](e2e/README.md).
81
+ Dependency installs go through a 7-day release-age gate and a no-downgrade trust policy, and
82
+ skip auto-installing optional peers, all set in `pnpm-workspace.yaml`. CI runs everything above on every push. Publishing is maintainer-only, see
83
+ [RELEASING.md](RELEASING.md).
105
84
 
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.
85
+ [CONTRIBUTING.md](CONTRIBUTING.md) has the rules of the road for new scenes, and
86
+ [CONTEXT.md](CONTEXT.md) holds the shared vocabulary.
108
87
 
109
88
  ## Provenance
110
89
 
111
90
  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.
91
+ [community-3b1b-quizzes](https://github.com/davidnugent2425/community-3b1b-quizzes), where
92
+ the layer grew question by question. This repository keeps that full git history, so
93
+ `git log` and `git blame` reach back through the extraction.