@lxpack/runtime 0.1.0 → 0.1.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 ADDED
@@ -0,0 +1,112 @@
1
+ # @lxpack/runtime
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@lxpack/runtime)](https://www.npmjs.com/package/@lxpack/runtime)
4
+ [![CI](https://github.com/eddiethedean/lxpack/actions/workflows/ci.yml/badge.svg)](https://github.com/eddiethedean/lxpack/actions/workflows/ci.yml)
5
+ [![License](https://img.shields.io/github/license/eddiethedean/lxpack)](https://github.com/eddiethedean/lxpack/blob/main/LICENSE)
6
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D20-brightgreen)](https://nodejs.org/)
7
+
8
+ Browser runtime for LXPack courses — lesson navigation, markdown rendering, HTML interactions, assessments, progress tracking, and SCORM 1.2 integration.
9
+
10
+ Part of [LXPack](https://github.com/eddiethedean/lxpack) — an AI-native learning experience compiler and runtime.
11
+
12
+ | Related | Package |
13
+ |---------|---------|
14
+ | CLI / preview | [`@lxpack/cli`](../cli/README.md) |
15
+ | Validation & bundles | [`@lxpack/validators`](../validators/README.md) |
16
+ | Export shell | [`@lxpack/scorm`](../scorm/README.md) |
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install @lxpack/runtime
22
+ ```
23
+
24
+ Requires Node.js 20+ for the build toolchain. Published bundles run in modern browsers (ESM `client.js`).
25
+
26
+ ## Package exports
27
+
28
+ | Import | Description |
29
+ |--------|-------------|
30
+ | `@lxpack/runtime` | Node/build-time API (`LxpackRuntime`, SCORM helpers, progress serialization, types) |
31
+ | `@lxpack/runtime/client` | Self-contained browser bundle (`dist/client.js`) |
32
+ | `dist/styles.css` | Bundled with the client in SCORM/standalone exports |
33
+
34
+ ## Browser client
35
+
36
+ The CLI and SCORM packager embed `@lxpack/runtime/client` into exported courses. The client:
37
+
38
+ - Renders markdown lessons and HTML interaction folders
39
+ - Loads assessments from the embedded config (`assessments` + `answerKeys`); does not fetch author YAML in production exports
40
+ - Scores MCQ submissions with `scoreAssessment()`
41
+ - Tracks lesson completion and assessment scores
42
+ - Persists progress via SCORM `suspend_data` (compact JSON, 4096-char safe) or `localStorage` in preview mode
43
+
44
+ Config is injected by the packager using [`safeJsonForHtml`](../scorm/README.md) from `@lxpack/scorm`.
45
+
46
+ ## SCORM 1.2
47
+
48
+ ```ts
49
+ import {
50
+ findLmsApi,
51
+ createScormConnection,
52
+ installScormAPI,
53
+ Scorm12Adapter,
54
+ Scorm12Simulator,
55
+ SCORM_SUSPEND_DATA_MAX,
56
+ } from "@lxpack/runtime";
57
+ ```
58
+
59
+ | API | Description |
60
+ |-----|-------------|
61
+ | `findLmsApi()` | Walk parent/opener frames to locate the LMS SCORM 1.2 API |
62
+ | `createScormConnection(mode)` | LMS adapter (`scorm12`) or local simulator (`preview`) |
63
+ | `installScormAPI()` | Expose the simulator API on `window` for preview servers |
64
+ | `trimSuspendData(data)` | Truncate suspend data to `SCORM_SUSPEND_DATA_MAX` (4096) |
65
+
66
+ Progress uses a compact suspend-data format with legacy fallback parsing. Assessment submission updates completion status before persisting to the LMS.
67
+
68
+ ## Runtime class
69
+
70
+ ```ts
71
+ import { LxpackRuntime, type RuntimeConfig } from "@lxpack/runtime";
72
+
73
+ const runtime = new LxpackRuntime({
74
+ manifest,
75
+ mode: "scorm12", // or "preview"
76
+ defaultPassingScores: { quiz: 0.7 },
77
+ });
78
+
79
+ runtime.completeLesson("intro");
80
+ runtime.getAPI().submitAssessment("quiz", 0.85, 0.7);
81
+ runtime.getProgress();
82
+ ```
83
+
84
+ `LxpackAPI` methods include `track()`, `submitAssessment()`, `getProgress()`, and `terminate()` (guarded against double `LMSFinish`).
85
+
86
+ ## Build output
87
+
88
+ | Artifact | Role |
89
+ |----------|------|
90
+ | `dist/client.js` | Vite browser bundle (embedded in packages) |
91
+ | `dist/runtime.js` | Node/library entry |
92
+ | `dist/styles.css` | Runtime styles |
93
+ | `dist/*.d.ts` | Type declarations |
94
+
95
+ ## Development
96
+
97
+ From the monorepo root:
98
+
99
+ ```bash
100
+ pnpm --filter @lxpack/runtime build
101
+ pnpm --filter @lxpack/runtime test
102
+ pnpm --filter @lxpack/runtime typecheck
103
+ ```
104
+
105
+ ## Links
106
+
107
+ - [LXPack repository](https://github.com/eddiethedean/lxpack)
108
+ - [Changelog](https://github.com/eddiethedean/lxpack/blob/main/CHANGELOG.md)
109
+
110
+ ## License
111
+
112
+ Apache-2.0