@lxpack/runtime 0.1.1 → 0.2.1
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 +67 -11
- package/dist/client.js +2250 -1673
- package/dist/core/completion-evaluator.d.ts +13 -0
- package/dist/core/completion-evaluator.d.ts.map +1 -0
- package/dist/core/progress-state.d.ts +20 -0
- package/dist/core/progress-state.d.ts.map +1 -0
- package/dist/flow-conditions.d.ts +4 -0
- package/dist/flow-conditions.d.ts.map +1 -0
- package/dist/flow.d.ts +14 -0
- package/dist/flow.d.ts.map +1 -0
- package/dist/lms/bridge.d.ts +11 -0
- package/dist/lms/bridge.d.ts.map +1 -0
- package/dist/lms/completion-state.d.ts +10 -0
- package/dist/lms/completion-state.d.ts.map +1 -0
- package/dist/lms/factory.d.ts +5 -0
- package/dist/lms/factory.d.ts.map +1 -0
- package/dist/lms/local-bridge.d.ts +15 -0
- package/dist/lms/local-bridge.d.ts.map +1 -0
- package/dist/lms/scorm12-bridge.d.ts +15 -0
- package/dist/lms/scorm12-bridge.d.ts.map +1 -0
- package/dist/lms/scorm2004-bridge.d.ts +15 -0
- package/dist/lms/scorm2004-bridge.d.ts.map +1 -0
- package/dist/{progress-persist.d.ts → progress/codec.d.ts} +2 -3
- package/dist/progress/codec.d.ts.map +1 -0
- package/dist/progress/constants.d.ts +3 -0
- package/dist/progress/constants.d.ts.map +1 -0
- package/dist/progress/size-policy.d.ts +4 -0
- package/dist/progress/size-policy.d.ts.map +1 -0
- package/dist/quiz/host.d.ts +9 -0
- package/dist/quiz/host.d.ts.map +1 -0
- package/dist/quiz/score.d.ts +6 -0
- package/dist/quiz/score.d.ts.map +1 -0
- package/dist/runtime.d.ts +13 -12
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +288 -377
- package/dist/scorm-api.d.ts +1 -1
- package/dist/scorm-api.d.ts.map +1 -1
- package/dist/scorm12-DpGWvsHb.js +375 -0
- package/dist/scorm12.d.ts +3 -0
- package/dist/scorm12.d.ts.map +1 -0
- package/dist/scorm12.js +11 -0
- package/dist/scorm2004-api.d.ts +57 -0
- package/dist/scorm2004-api.d.ts.map +1 -0
- package/dist/scorm2004.d.ts +2 -0
- package/dist/scorm2004.d.ts.map +1 -0
- package/dist/scorm2004.js +153 -0
- package/dist/types.d.ts +5 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/variables.d.ts +7 -0
- package/dist/variables.d.ts.map +1 -0
- package/package.json +11 -3
- package/dist/progress-persist.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
[](https://github.com/eddiethedean/lxpack/blob/main/LICENSE)
|
|
6
6
|
[](https://nodejs.org/)
|
|
7
7
|
|
|
8
|
-
Browser runtime for LXPack courses — lesson navigation, markdown
|
|
8
|
+
Browser runtime for LXPack courses — lesson navigation, markdown and HTML lessons, component widgets, branching flow, quiz engine, progress tracking, and SCORM 1.2 / 2004 integration.
|
|
9
9
|
|
|
10
|
-
Part of [LXPack](https://github.com/eddiethedean/lxpack) — an AI-native learning experience compiler and runtime.
|
|
10
|
+
Part of [LXPack](https://github.com/eddiethedean/lxpack) — an AI-native learning experience compiler and runtime (**v0.2.0**).
|
|
11
11
|
|
|
12
12
|
| Related | Package |
|
|
13
13
|
|---------|---------|
|
|
14
14
|
| CLI / preview | [`@lxpack/cli`](../cli/README.md) |
|
|
15
15
|
| Validation & bundles | [`@lxpack/validators`](../validators/README.md) |
|
|
16
16
|
| Export shell | [`@lxpack/scorm`](../scorm/README.md) |
|
|
17
|
+
| UI widgets | [`@lxpack/components`](../components/README.md) |
|
|
17
18
|
|
|
18
19
|
## Install
|
|
19
20
|
|
|
@@ -27,7 +28,7 @@ Requires Node.js 20+ for the build toolchain. Published bundles run in modern br
|
|
|
27
28
|
|
|
28
29
|
| Import | Description |
|
|
29
30
|
|--------|-------------|
|
|
30
|
-
| `@lxpack/runtime` | Node/build-time API (`LxpackRuntime`, SCORM helpers, progress serialization, types) |
|
|
31
|
+
| `@lxpack/runtime` | Node/build-time API (`LxpackRuntime`, flow, variables, SCORM helpers, progress serialization, types) |
|
|
31
32
|
| `@lxpack/runtime/client` | Self-contained browser bundle (`dist/client.js`) |
|
|
32
33
|
| `dist/styles.css` | Bundled with the client in SCORM/standalone exports |
|
|
33
34
|
|
|
@@ -35,14 +36,49 @@ Requires Node.js 20+ for the build toolchain. Published bundles run in modern br
|
|
|
35
36
|
|
|
36
37
|
The CLI and SCORM packager embed `@lxpack/runtime/client` into exported courses. The client:
|
|
37
38
|
|
|
38
|
-
- Renders markdown lessons
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
39
|
+
- Renders markdown lessons, HTML interaction folders, and `type: component` lessons (via `window.__LXPACK_COMPONENTS__`)
|
|
40
|
+
- Resolves **next/previous** navigation with the flow engine when `course.yaml` defines `flow`; otherwise linear lesson order
|
|
41
|
+
- Loads assessments from embedded config (`assessments`, `answerKeys`, `configs`, `feedback`); does not fetch author YAML in production exports
|
|
42
|
+
- Renders quizzes with `renderAssessment()` — retakes, choice shuffle, and feedback modes from per-assessment config
|
|
43
|
+
- Tracks lesson completion, manifest variables (`v:` prefix in suspend data), and assessment scores
|
|
44
|
+
- Persists progress via SCORM `suspend_data` / CMI (compact JSON, size-safe) or `localStorage` in preview mode
|
|
43
45
|
|
|
44
46
|
Config is injected by the packager using [`safeJsonForHtml`](../scorm/README.md) from `@lxpack/scorm`.
|
|
45
47
|
|
|
48
|
+
## Flow and variables
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import {
|
|
52
|
+
evaluateCondition,
|
|
53
|
+
resolveFlowGoto,
|
|
54
|
+
resolveNextActivityId,
|
|
55
|
+
initManifestVariables,
|
|
56
|
+
readManifestVariable,
|
|
57
|
+
writeManifestVariable,
|
|
58
|
+
} from "@lxpack/runtime";
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
| Module | Role |
|
|
62
|
+
|--------|------|
|
|
63
|
+
| `flow.ts` | Condition evaluation (`variable.eq`, `assessment.passed`, `interaction.done`, `all` / `any`) and `goto` resolution |
|
|
64
|
+
| `variables.ts` | Manifest variable defaults and `v:` namespaced storage in progress |
|
|
65
|
+
|
|
66
|
+
`LxpackRuntime` exposes `setVariable()` / `getVariable()` on the learner API when the manifest declares `variables`.
|
|
67
|
+
|
|
68
|
+
## Quiz module
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import {
|
|
72
|
+
renderAssessment,
|
|
73
|
+
scoreAssessmentForm,
|
|
74
|
+
getAttemptCount,
|
|
75
|
+
shuffleQuestions,
|
|
76
|
+
} from "@lxpack/runtime";
|
|
77
|
+
// Re-exported from client as scoreAssessment
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Supports `maxAttempts`, `shuffleChoices`, and `showFeedback` (`immediate` | `end` | `never`) from the build-time assessment bundle.
|
|
81
|
+
|
|
46
82
|
## SCORM 1.2
|
|
47
83
|
|
|
48
84
|
```ts
|
|
@@ -63,7 +99,24 @@ import {
|
|
|
63
99
|
| `installScormAPI()` | Expose the simulator API on `window` for preview servers |
|
|
64
100
|
| `trimSuspendData(data)` | Truncate suspend data to `SCORM_SUSPEND_DATA_MAX` (4096) |
|
|
65
101
|
|
|
66
|
-
|
|
102
|
+
## SCORM 2004
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import {
|
|
106
|
+
findScorm2004Api,
|
|
107
|
+
createScorm2004Connection,
|
|
108
|
+
Scorm2004Adapter,
|
|
109
|
+
Scorm2004Simulator,
|
|
110
|
+
} from "@lxpack/runtime";
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
| API | Description |
|
|
114
|
+
|-----|-------------|
|
|
115
|
+
| `findScorm2004Api()` | Locate `API_1484_11` in parent/opener frames |
|
|
116
|
+
| `createScorm2004Connection(mode)` | LMS adapter (`scorm2004`) or preview simulator |
|
|
117
|
+
| CMI mapping | Progress and completion mapped for multi-SCO packages |
|
|
118
|
+
|
|
119
|
+
Use `mode: "scorm2004"` in `RuntimeConfig` when embedding the runtime in SCORM 2004 launch pages.
|
|
67
120
|
|
|
68
121
|
## Runtime class
|
|
69
122
|
|
|
@@ -72,16 +125,17 @@ import { LxpackRuntime, type RuntimeConfig } from "@lxpack/runtime";
|
|
|
72
125
|
|
|
73
126
|
const runtime = new LxpackRuntime({
|
|
74
127
|
manifest,
|
|
75
|
-
mode: "scorm12", //
|
|
128
|
+
mode: "scorm12", // "scorm2004" | "preview"
|
|
76
129
|
defaultPassingScores: { quiz: 0.7 },
|
|
77
130
|
});
|
|
78
131
|
|
|
79
132
|
runtime.completeLesson("intro");
|
|
133
|
+
runtime.getAPI().setVariable("track", "advanced");
|
|
80
134
|
runtime.getAPI().submitAssessment("quiz", 0.85, 0.7);
|
|
81
135
|
runtime.getProgress();
|
|
82
136
|
```
|
|
83
137
|
|
|
84
|
-
`LxpackAPI` methods include `track()`, `submitAssessment()`, `getProgress()`, and `terminate()` (guarded against double
|
|
138
|
+
`LxpackAPI` methods include `track()`, `submitAssessment()`, `getProgress()`, `setVariable()` / `getVariable()`, and `terminate()` (guarded against double finish).
|
|
85
139
|
|
|
86
140
|
## Build output
|
|
87
141
|
|
|
@@ -105,6 +159,8 @@ pnpm --filter @lxpack/runtime typecheck
|
|
|
105
159
|
## Links
|
|
106
160
|
|
|
107
161
|
- [LXPack repository](https://github.com/eddiethedean/lxpack)
|
|
162
|
+
- [Documentation index](https://github.com/eddiethedean/lxpack/blob/main/docs/README.md)
|
|
163
|
+
- [Technical specification](https://github.com/eddiethedean/lxpack/blob/main/docs/SPEC.md)
|
|
108
164
|
- [Changelog](https://github.com/eddiethedean/lxpack/blob/main/CHANGELOG.md)
|
|
109
165
|
|
|
110
166
|
## License
|