@lessonkit/lxpack
v1.7.3
Published
LXPack export adapter for LessonKit courses (SCORM, standalone, xAPI, cmi5).
Maintainers
Readme
@lessonkit/lxpack
Package Vite SPAs for LMS delivery — SCORM 1.2/2004, standalone, xAPI, and cmi5. Bundles @lxpack/* as direct dependencies.
When to install
- Custom packaging pipelines without the CLI
- Validating
lessonkit.json/ course descriptors in CI - Programmatic LMS export from your own build tools
Most authors use lessonkit package (CLI) which calls this package internally.
Install
npm install @lessonkit/lxpackRequires Node.js 18+ minimum; 20.19+ recommended for CLI scaffold workflows.
Usage
import { packageLessonkitCourse, parseLessonkitManifest } from "@lessonkit/lxpack";
const manifest = parseLessonkitManifest(await readFile("lessonkit.json", "utf8"));
if (!manifest.ok) throw manifest.error;
const result = await packageLessonkitCourse({
descriptor: manifest.value,
outDir: ".lxpack/course",
spaDistDir: "dist",
target: "scorm12",
output: ".lxpack/out/course-scorm12.zip",
});
if (!result.ok) throw new Error("packaging failed");Prefer the CLI: lessonkit package --target scorm12 reads lessonkit.json and runs the same staged pipeline.
Layouts
| Layout | Use case |
| --- | --- |
| single-spa | One Vite SPA for the whole course (CLI default) |
| per-lesson-spa | One dist per lesson (advanced; see packaging reference) |
Portable interchange (1.6.0)
Export a .lkcourse archive for team handoff (not LMS upload):
import { exportLkcourse, validateLkcourse, importLkcourse } from "@lessonkit/lxpack";
await exportLkcourse({ projectRoot, manifest, includeBlockTree: true });
validateLkcourse("course.lkcourse");
await importLkcourse({ archivePath: "course.lkcourse", targetDir: "./restored" });Schemas: @lessonkit/lxpack/lkcourse-format.v1.json, @lessonkit/lxpack/block-tree.v1.json. See Portable interchange.
Browser bridge
When embedded in an LXPack iframe, @lessonkit/react forwards completion events to window.parent.lxpackBridge.v1:
import { forwardTelemetryToBridge } from "@lessonkit/lxpack/bridge";Production builds require allowedParentOrigins when bridge: "auto".
Common issues
| Symptom | Fix |
| --- | --- |
| React/manifest ID mismatch | Run strict parity validation; align IDs in App.tsx and lessonkit.json |
| xAPI/cmi5 validation failure | Set HTTPS activityIri in manifest |
| Empty dist/ | Run lessonkit build before package (or omit --no-build) |
Docs
5-minute guide · LMS Go-Live · Packaging reference · TypeDoc API index
License
Apache-2.0
