@lxpack/scorm 0.2.2 → 0.3.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 CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  SCORM 1.2, SCORM 2004 (multi-SCO), and standalone HTML export for LXPack courses.
9
9
 
10
- Part of [LXPack](https://github.com/eddiethedean/lxpack) — an AI-native learning experience compiler and runtime (**v0.2.2**).
10
+ Part of [LXPack](https://github.com/eddiethedean/lxpack) — an AI-native learning experience compiler and runtime (**v0.3.0**).
11
11
 
12
12
  | Related | Package |
13
13
  |---------|---------|
package/dist/index.d.ts CHANGED
@@ -7,7 +7,8 @@ declare function generateImsManifest(manifest: CourseManifest, files: string[],
7
7
  interface BuildHtmlOptions {
8
8
  manifest: CourseManifest;
9
9
  runtimeCss: string;
10
- mode: "standalone" | "scorm12" | "scorm2004";
10
+ mode: "standalone" | "scorm12" | "scorm2004" | "xapi" | "cmi5";
11
+ activityIri?: string;
11
12
  activityId?: string;
12
13
  assessmentBundle?: RuntimeAssessmentBundle;
13
14
  componentsScript?: string;
@@ -27,7 +28,7 @@ interface PageTemplateOptions {
27
28
  }
28
29
  declare function buildLearnerPageHtml(options: PageTemplateOptions): string;
29
30
 
30
- type ExportTarget = "scorm12" | "scorm2004" | "standalone";
31
+ type ExportTarget = "scorm12" | "scorm2004" | "standalone" | "xapi" | "cmi5";
31
32
  interface PackageOptions {
32
33
  courseDir: string;
33
34
  manifest: CourseManifest;
package/dist/index.js CHANGED
@@ -83,11 +83,12 @@ function buildLearnerPageHtml(options) {
83
83
 
84
84
  // src/build-html.ts
85
85
  function buildRuntimeConfig(options) {
86
- const { manifest, mode, assessmentBundle, activityId } = options;
86
+ const { manifest, mode, assessmentBundle, activityId, activityIri } = options;
87
87
  return {
88
88
  manifest,
89
89
  baseUrl: activityId ? "../.." : ".",
90
90
  mode,
91
+ ...activityIri ? { activityIri } : {},
91
92
  ...activityId ? { activityId } : {},
92
93
  ...assessmentBundle ? {
93
94
  ...Object.keys(assessmentBundle.assessments).length ? { assessments: assessmentBundle.assessments } : {},
@@ -234,6 +235,9 @@ ${uniqueCourseFiles}
234
235
  }
235
236
 
236
237
  // src/package.ts
238
+ import { generateTincanXml } from "@lxpack/xapi";
239
+ import { generateCmi5Xml } from "@lxpack/cmi5";
240
+ import { getCourseActivityIri } from "@lxpack/validators";
237
241
  var SKIP_FILES = /* @__PURE__ */ new Set([
238
242
  "course.yaml",
239
243
  "lxpack.config.ts",
@@ -317,10 +321,65 @@ async function writeSingleScoArtifacts(options) {
317
321
  }
318
322
  return { fileCount };
319
323
  }
324
+ async function writeXapiOrCmi5Artifacts(options) {
325
+ const {
326
+ courseDir,
327
+ manifest,
328
+ target,
329
+ runtimeClientJs,
330
+ runtimeCss,
331
+ assessmentBundle,
332
+ componentsBundleJs,
333
+ writeFile: writeArtifact
334
+ } = options;
335
+ const courseIri = getCourseActivityIri(manifest);
336
+ if (!courseIri) {
337
+ throw new Error(
338
+ "tracking.xapi.activityIri is required for xapi/cmi5 export targets"
339
+ );
340
+ }
341
+ const courseFiles = await collectFiles(courseDir, courseDir);
342
+ let fileCount = 0;
343
+ for (const file of courseFiles) {
344
+ const content = await readFile(file.fullPath);
345
+ await writeArtifact(file.path, content);
346
+ fileCount++;
347
+ }
348
+ const indexHtml = buildIndexHtml({
349
+ manifest,
350
+ runtimeCss,
351
+ mode: target,
352
+ activityIri: courseIri,
353
+ assessmentBundle,
354
+ componentsScript: componentsBundleJs ? "./lxpack-components.js" : void 0
355
+ });
356
+ await writeArtifact("index.html", indexHtml);
357
+ await writeArtifact("lxpack-runtime.js", runtimeClientJs);
358
+ fileCount += 2;
359
+ if (componentsBundleJs) {
360
+ await writeArtifact("lxpack-components.js", componentsBundleJs);
361
+ fileCount++;
362
+ }
363
+ if (target === "xapi") {
364
+ await writeArtifact("tincan.xml", generateTincanXml(manifest, courseIri));
365
+ fileCount++;
366
+ } else {
367
+ await writeArtifact("cmi5.xml", generateCmi5Xml(manifest, courseIri));
368
+ fileCount++;
369
+ }
370
+ return { fileCount };
371
+ }
320
372
  async function assemblePackage(options, sink) {
321
373
  if (options.target === "scorm2004") {
322
374
  return writeScorm2004Artifacts({ ...options, writeFile: sink.writeFile });
323
375
  }
376
+ if (options.target === "xapi" || options.target === "cmi5") {
377
+ return writeXapiOrCmi5Artifacts({
378
+ ...options,
379
+ writeFile: sink.writeFile,
380
+ target: options.target
381
+ });
382
+ }
324
383
  return writeSingleScoArtifacts({ ...options, writeFile: sink.writeFile });
325
384
  }
326
385
  async function writeScorm2004Artifacts(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lxpack/scorm",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "SCORM and standalone HTML export for LXPack",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -39,7 +39,9 @@
39
39
  ],
40
40
  "dependencies": {
41
41
  "jszip": "^3.10.1",
42
- "@lxpack/validators": "0.2.2"
42
+ "@lxpack/cmi5": "0.3.0",
43
+ "@lxpack/validators": "0.3.0",
44
+ "@lxpack/xapi": "0.3.0"
43
45
  },
44
46
  "devDependencies": {
45
47
  "@types/node": "^22.13.10",