tessera-learn 0.0.10 → 0.0.11
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/dist/plugin/cli.js +5 -3
- package/dist/plugin/cli.js.map +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +87 -131
- package/dist/plugin/index.js.map +1 -1
- package/dist/{validation-BxWAMMnJ.js → validation-D9DXlqNP.js} +77 -65
- package/dist/validation-D9DXlqNP.js.map +1 -0
- package/package.json +1 -1
- package/src/components/Audio.svelte +5 -2
- package/src/components/FillInTheBlank.svelte +60 -98
- package/src/components/Image.svelte +3 -8
- package/src/components/LockedBanner.svelte +3 -4
- package/src/components/MultipleChoice.svelte +53 -94
- package/src/components/Quiz.svelte +2 -1
- package/src/components/Video.svelte +4 -2
- package/src/components/util.ts +1 -0
- package/src/plugin/cli.ts +2 -7
- package/src/plugin/export.ts +23 -41
- package/src/plugin/index.ts +37 -66
- package/src/plugin/layout.ts +6 -51
- package/src/plugin/manifest.ts +31 -5
- package/src/plugin/override-plugin.ts +68 -0
- package/src/plugin/quiz.ts +9 -54
- package/src/plugin/validation.ts +38 -67
- package/src/runtime/App.svelte +9 -16
- package/src/runtime/adapters/cmi5.ts +13 -83
- package/src/runtime/adapters/format.ts +67 -0
- package/src/runtime/adapters/index.ts +28 -29
- package/src/runtime/adapters/retry.ts +0 -64
- package/src/runtime/adapters/scorm12.ts +1 -1
- package/src/runtime/adapters/scorm2004.ts +11 -16
- package/src/runtime/hooks.svelte.ts +4 -6
- package/src/runtime/navigation.svelte.ts +13 -40
- package/src/runtime/progress.svelte.ts +9 -0
- package/src/runtime/quiz-policy.ts +21 -178
- package/src/runtime/xapi/agent-rules.ts +7 -2
- package/src/runtime/xapi/publisher.ts +1 -11
- package/src/runtime/xapi/validation.ts +1 -1
- package/dist/validation-BxWAMMnJ.js.map +0 -1
package/dist/plugin/cli.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { n as validateProject, t as reportValidationIssues } from "../validation-D9DXlqNP.js";
|
|
3
3
|
//#region src/plugin/cli.ts
|
|
4
4
|
const { errors, warnings } = validateProject(process.cwd());
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
reportValidationIssues({
|
|
6
|
+
errors,
|
|
7
|
+
warnings
|
|
8
|
+
});
|
|
7
9
|
if (errors.length > 0) {
|
|
8
10
|
const summary = `Validation failed with ${errors.length} error(s)` + (warnings.length > 0 ? ` and ${warnings.length} warning(s)` : "") + ".";
|
|
9
11
|
console.error(`\n\x1b[31m${summary}\x1b[0m`);
|
package/dist/plugin/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../../src/plugin/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { validateProject } from './validation.js';\n\nconst projectRoot = process.cwd();\nconst { errors, warnings } = validateProject(projectRoot);\n\
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../../src/plugin/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { validateProject, reportValidationIssues } from './validation.js';\n\nconst projectRoot = process.cwd();\nconst { errors, warnings } = validateProject(projectRoot);\n\nreportValidationIssues({ errors, warnings });\n\nif (errors.length > 0) {\n const summary =\n `Validation failed with ${errors.length} error(s)` +\n (warnings.length > 0 ? ` and ${warnings.length} warning(s)` : '') +\n '.';\n console.error(`\\n\\x1b[31m${summary}\\x1b[0m`);\n process.exit(1);\n}\n\nif (warnings.length > 0) {\n console.log(\n `\\n\\x1b[33mValidation passed with ${warnings.length} warning(s).\\x1b[0m`\n );\n} else {\n console.log('\\x1b[32m[tessera]\\x1b[0m Validation passed — no issues found.');\n}\nprocess.exit(0);\n"],"mappings":";;;AAIA,MAAM,EAAE,QAAQ,aAAa,gBADT,QAAQ,KAC4B,CAAC;AAEzD,uBAAuB;CAAE;CAAQ;CAAU,CAAC;AAE5C,IAAI,OAAO,SAAS,GAAG;CACrB,MAAM,UACJ,0BAA0B,OAAO,OAAO,cACvC,SAAS,SAAS,IAAI,QAAQ,SAAS,OAAO,eAAe,MAC9D;CACF,QAAQ,MAAM,aAAa,QAAQ,SAAS;CAC5C,QAAQ,KAAK,EAAE;;AAGjB,IAAI,SAAS,SAAS,GACpB,QAAQ,IACN,oCAAoC,SAAS,OAAO,qBACrD;KAED,QAAQ,IAAI,gEAAgE;AAE9E,QAAQ,KAAK,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugin/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugin/index.ts"],"mappings":";;;iBA2BgB,aAAA,CAAA,IAAa,MAAA,QAAA,MAAA"}
|
package/dist/plugin/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { i as readCourseConfig, n as validateProject, r as generateManifest, t as reportValidationIssues } from "../validation-D9DXlqNP.js";
|
|
2
2
|
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { dirname, resolve } from "node:path";
|
|
5
|
-
import { cpSync, createWriteStream, existsSync, mkdirSync,
|
|
6
|
-
import JSON5 from "json5";
|
|
5
|
+
import { cpSync, createWriteStream, existsSync, mkdirSync, readdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
7
6
|
import { createHash } from "node:crypto";
|
|
8
7
|
import { ZipArchive } from "archiver";
|
|
8
|
+
import { normalizePath } from "vite";
|
|
9
9
|
//#region src/runtime/slugify.ts
|
|
10
10
|
/**
|
|
11
11
|
* Slugify a string for use as a URL-safe / filename-safe identifier.
|
|
@@ -151,77 +151,78 @@ function cleanOldZips(projectRoot, slug) {
|
|
|
151
151
|
} catch {}
|
|
152
152
|
} catch {}
|
|
153
153
|
}
|
|
154
|
+
/** Packaged (zipped) export targets: which manifest file to write and how. */
|
|
155
|
+
const PACKAGED_EXPORTS = {
|
|
156
|
+
scorm12: {
|
|
157
|
+
manifestFile: "imsmanifest.xml",
|
|
158
|
+
label: "SCORM 1.2",
|
|
159
|
+
generate: generateSCORM12Manifest
|
|
160
|
+
},
|
|
161
|
+
scorm2004: {
|
|
162
|
+
manifestFile: "imsmanifest.xml",
|
|
163
|
+
label: "SCORM 2004",
|
|
164
|
+
generate: generateSCORM2004Manifest
|
|
165
|
+
},
|
|
166
|
+
cmi5: {
|
|
167
|
+
manifestFile: "cmi5.xml",
|
|
168
|
+
label: "CMI5",
|
|
169
|
+
generate: (config) => generateCMI5Xml(config)
|
|
170
|
+
}
|
|
171
|
+
};
|
|
154
172
|
async function runExport(projectRoot, config) {
|
|
155
173
|
const distDir = resolve(projectRoot, "dist");
|
|
156
174
|
const standard = config.export?.standard || "web";
|
|
157
175
|
const slug = slugify(config.title || "tessera-course") || "tessera-course";
|
|
158
176
|
const zipName = `${slug}-${config.version || "1.0.0"}.zip`;
|
|
159
177
|
const zipPath = resolve(projectRoot, zipName);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
case "scorm12": {
|
|
169
|
-
const manifest = generateSCORM12Manifest(config, distDir);
|
|
170
|
-
writeFileSync(resolve(distDir, "imsmanifest.xml"), manifest, "utf-8");
|
|
171
|
-
cleanOldZips(projectRoot, slug);
|
|
172
|
-
const zipSize = await createZip(distDir, zipPath);
|
|
173
|
-
console.log(`✓ SCORM 1.2 export: ${zipName} (${formatSize(zipSize)})`);
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
case "scorm2004": {
|
|
177
|
-
const manifest = generateSCORM2004Manifest(config, distDir);
|
|
178
|
-
writeFileSync(resolve(distDir, "imsmanifest.xml"), manifest, "utf-8");
|
|
179
|
-
cleanOldZips(projectRoot, slug);
|
|
180
|
-
const zipSize = await createZip(distDir, zipPath);
|
|
181
|
-
console.log(`✓ SCORM 2004 export: ${zipName} (${formatSize(zipSize)})`);
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
case "cmi5": {
|
|
185
|
-
const xml = generateCMI5Xml(config);
|
|
186
|
-
writeFileSync(resolve(distDir, "cmi5.xml"), xml, "utf-8");
|
|
187
|
-
cleanOldZips(projectRoot, slug);
|
|
188
|
-
const zipSize = await createZip(distDir, zipPath);
|
|
189
|
-
console.log(`✓ CMI5 export: ${zipName} (${formatSize(zipSize)})`);
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
178
|
+
if (standard === "web") {
|
|
179
|
+
const files = collectFiles(distDir);
|
|
180
|
+
let totalSize = 0;
|
|
181
|
+
for (const f of files) totalSize += statSync(resolve(distDir, f)).size;
|
|
182
|
+
console.log(`✓ Web export: dist/ (${formatSize(totalSize)})`);
|
|
183
|
+
return;
|
|
192
184
|
}
|
|
185
|
+
const spec = PACKAGED_EXPORTS[standard];
|
|
186
|
+
if (!spec) return;
|
|
187
|
+
writeFileSync(resolve(distDir, spec.manifestFile), spec.generate(config, distDir), "utf-8");
|
|
188
|
+
cleanOldZips(projectRoot, slug);
|
|
189
|
+
const zipSize = await createZip(distDir, zipPath);
|
|
190
|
+
console.log(`✓ ${spec.label} export: ${zipName} (${formatSize(zipSize)})`);
|
|
193
191
|
}
|
|
194
192
|
//#endregion
|
|
195
|
-
//#region src/plugin/
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
193
|
+
//#region src/plugin/override-plugin.ts
|
|
194
|
+
/**
|
|
195
|
+
* A virtual module that resolves to a project-root override file when present,
|
|
196
|
+
* and to the built-in (or a null export) otherwise. Shared by the layout and
|
|
197
|
+
* quiz plugins — they differ only in the virtual id, file name, and built-in.
|
|
198
|
+
*/
|
|
199
|
+
function createOverridePlugin({ name, virtualId, projectFile, builtinFile }) {
|
|
200
|
+
const resolvedId = "\0" + virtualId;
|
|
201
|
+
const fallback = builtinFile ? `export { default } from '${normalizePath(builtinFile)}';` : "export default null;";
|
|
202
|
+
let filePath;
|
|
200
203
|
return {
|
|
201
|
-
name
|
|
204
|
+
name,
|
|
202
205
|
enforce: "pre",
|
|
203
206
|
configResolved(config) {
|
|
204
|
-
|
|
207
|
+
filePath = resolve(config.root, projectFile);
|
|
205
208
|
},
|
|
206
209
|
resolveId(id) {
|
|
207
|
-
if (id ===
|
|
210
|
+
if (id === virtualId) return resolvedId;
|
|
208
211
|
return null;
|
|
209
212
|
},
|
|
210
213
|
load(id) {
|
|
211
|
-
if (id !==
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return `export { default } from '${layoutPath.replace(/\\/g, "/")}';`;
|
|
214
|
+
if (id !== resolvedId) return null;
|
|
215
|
+
if (existsSync(filePath)) {
|
|
216
|
+
this.addWatchFile(filePath);
|
|
217
|
+
return `export { default } from '${normalizePath(filePath)}';`;
|
|
216
218
|
}
|
|
217
|
-
return
|
|
219
|
+
return fallback;
|
|
218
220
|
},
|
|
219
221
|
configureServer(server) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (filePath !== layoutPath) return;
|
|
222
|
+
server.watcher.on("all", (event, changed) => {
|
|
223
|
+
if (changed !== filePath) return;
|
|
223
224
|
if (event !== "add" && event !== "unlink") return;
|
|
224
|
-
const mod = server.moduleGraph.getModuleById(
|
|
225
|
+
const mod = server.moduleGraph.getModuleById(resolvedId);
|
|
225
226
|
if (mod) server.moduleGraph.invalidateModule(mod);
|
|
226
227
|
server.ws.send({ type: "full-reload" });
|
|
227
228
|
});
|
|
@@ -229,48 +230,24 @@ function tesseraLayoutPlugin() {
|
|
|
229
230
|
};
|
|
230
231
|
}
|
|
231
232
|
//#endregion
|
|
233
|
+
//#region src/plugin/layout.ts
|
|
234
|
+
function tesseraLayoutPlugin() {
|
|
235
|
+
return createOverridePlugin({
|
|
236
|
+
name: "tessera:layout",
|
|
237
|
+
virtualId: "virtual:tessera-layout",
|
|
238
|
+
projectFile: "layout.svelte"
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
//#endregion
|
|
232
242
|
//#region src/plugin/quiz.ts
|
|
233
|
-
const VIRTUAL_QUIZ_ID = "virtual:tessera-quiz";
|
|
234
|
-
const RESOLVED_QUIZ_ID = "\0" + VIRTUAL_QUIZ_ID;
|
|
235
243
|
const __dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
236
|
-
/**
|
|
237
|
-
* Resolve the project's quiz shell.
|
|
238
|
-
* `projectRoot/quiz.svelte` overrides the built-in `<Quiz>` if it exists,
|
|
239
|
-
* otherwise the built-in is used. Mirrors `tesseraLayoutPlugin` (Phase 3A).
|
|
240
|
-
*/
|
|
241
244
|
function tesseraQuizPlugin() {
|
|
242
|
-
|
|
243
|
-
const builtinQuiz = resolve(resolve(__dirname$1, "..", ".."), "src", "components", "Quiz.svelte");
|
|
244
|
-
return {
|
|
245
|
+
return createOverridePlugin({
|
|
245
246
|
name: "tessera:quiz",
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
resolveId(id) {
|
|
251
|
-
if (id === VIRTUAL_QUIZ_ID) return RESOLVED_QUIZ_ID;
|
|
252
|
-
return null;
|
|
253
|
-
},
|
|
254
|
-
load(id) {
|
|
255
|
-
if (id !== RESOLVED_QUIZ_ID) return null;
|
|
256
|
-
const userQuizPath = resolve(projectRoot, "quiz.svelte");
|
|
257
|
-
if (existsSync(userQuizPath)) {
|
|
258
|
-
this.addWatchFile(userQuizPath);
|
|
259
|
-
return `export { default } from '${userQuizPath.replace(/\\/g, "/")}';`;
|
|
260
|
-
}
|
|
261
|
-
return `export { default } from '${builtinQuiz.replace(/\\/g, "/")}';`;
|
|
262
|
-
},
|
|
263
|
-
configureServer(server) {
|
|
264
|
-
const userQuizPath = resolve(projectRoot, "quiz.svelte");
|
|
265
|
-
server.watcher.on("all", (event, filePath) => {
|
|
266
|
-
if (filePath !== userQuizPath) return;
|
|
267
|
-
if (event !== "add" && event !== "unlink") return;
|
|
268
|
-
const mod = server.moduleGraph.getModuleById(RESOLVED_QUIZ_ID);
|
|
269
|
-
if (mod) server.moduleGraph.invalidateModule(mod);
|
|
270
|
-
server.ws.send({ type: "full-reload" });
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
};
|
|
247
|
+
virtualId: "virtual:tessera-quiz",
|
|
248
|
+
projectFile: "quiz.svelte",
|
|
249
|
+
builtinFile: resolve(resolve(__dirname$1, "..", ".."), "src", "components", "Quiz.svelte")
|
|
250
|
+
});
|
|
274
251
|
}
|
|
275
252
|
//#endregion
|
|
276
253
|
//#region src/plugin/index.ts
|
|
@@ -421,6 +398,7 @@ function tesseraConfigPlugin() {
|
|
|
421
398
|
config(config) {
|
|
422
399
|
return {
|
|
423
400
|
base: "./",
|
|
401
|
+
build: { assetsDir: "tessera" },
|
|
424
402
|
resolve: { alias: { "$assets": resolve(config.root || process.cwd(), "assets") } },
|
|
425
403
|
optimizeDeps: { exclude: ["tessera-learn"] }
|
|
426
404
|
};
|
|
@@ -435,14 +413,9 @@ function tesseraConfigPlugin() {
|
|
|
435
413
|
load(id) {
|
|
436
414
|
if (id === RESOLVED_CONFIG_ID) {
|
|
437
415
|
const configPath = resolve(projectRoot, "course.config.js");
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
const objectStr = extractDefaultExportObjectLiteral(readFileSync(configPath, "utf-8"));
|
|
442
|
-
if (objectStr) try {
|
|
443
|
-
userConfig = JSON5.parse(objectStr);
|
|
444
|
-
} catch {}
|
|
445
|
-
}
|
|
416
|
+
if (existsSync(configPath)) this.addWatchFile(configPath);
|
|
417
|
+
const read = readCourseConfig(projectRoot);
|
|
418
|
+
const userConfig = read.ok ? read.config : {};
|
|
446
419
|
const { completion, passingScore } = completionDefaults(userConfig.completion?.mode);
|
|
447
420
|
const merged = {
|
|
448
421
|
title: userConfig.title || "Untitled Course",
|
|
@@ -517,12 +490,9 @@ function tesseraValidationPlugin() {
|
|
|
517
490
|
};
|
|
518
491
|
}
|
|
519
492
|
function runValidation(projectRoot) {
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
if (errors.length > 0) {
|
|
523
|
-
for (const error of errors) console.error(`\x1b[31m[tessera error]\x1b[0m ${error}`);
|
|
524
|
-
throw new Error(`Tessera validation failed with ${errors.length} error(s). Fix the errors above to continue.`);
|
|
525
|
-
}
|
|
493
|
+
const result = validateProject(projectRoot);
|
|
494
|
+
reportValidationIssues(result);
|
|
495
|
+
if (result.errors.length > 0) throw new Error(`Tessera validation failed with ${result.errors.length} error(s). Fix the errors above to continue.`);
|
|
526
496
|
}
|
|
527
497
|
function tesseraExportPlugin() {
|
|
528
498
|
let projectRoot;
|
|
@@ -536,17 +506,13 @@ function tesseraExportPlugin() {
|
|
|
536
506
|
},
|
|
537
507
|
async closeBundle() {
|
|
538
508
|
if (!isBuild) return;
|
|
539
|
-
const
|
|
540
|
-
if (!
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
try {
|
|
545
|
-
config = JSON5.parse(objectStr);
|
|
546
|
-
} catch (err) {
|
|
547
|
-
throw new Error(`[tessera:export] course.config.js: failed to parse export-default object literal — ${err.message}`);
|
|
509
|
+
const read = readCourseConfig(projectRoot);
|
|
510
|
+
if (!read.ok) {
|
|
511
|
+
if (read.reason === "missing") throw new Error("[tessera:export] course.config.js not found at closeBundle. The file must exist for the export step to run.");
|
|
512
|
+
if (read.reason === "no-export") throw new Error("[tessera:export] course.config.js: could not locate `export default { ... }`. Cannot determine export.standard.");
|
|
513
|
+
throw new Error(`[tessera:export] course.config.js: failed to parse export-default object literal — ${read.error.message}`);
|
|
548
514
|
}
|
|
549
|
-
await runExport(projectRoot, config);
|
|
515
|
+
await runExport(projectRoot, read.config);
|
|
550
516
|
}
|
|
551
517
|
};
|
|
552
518
|
}
|
|
@@ -620,14 +586,8 @@ function tesseraAdapterPlugin() {
|
|
|
620
586
|
if (id !== RESOLVED_ADAPTER_ID) return null;
|
|
621
587
|
if (!isBuild) return `export { createAdapter } from 'tessera-learn/runtime/adapters/index.js';`;
|
|
622
588
|
let standard = "web";
|
|
623
|
-
const
|
|
624
|
-
if (
|
|
625
|
-
const objectStr = extractDefaultExportObjectLiteral(readFileSync(configPath, "utf-8"));
|
|
626
|
-
if (objectStr) try {
|
|
627
|
-
const parsed = JSON5.parse(objectStr);
|
|
628
|
-
if (typeof parsed?.export?.standard === "string") standard = parsed.export.standard;
|
|
629
|
-
} catch {}
|
|
630
|
-
}
|
|
589
|
+
const read = readCourseConfig(projectRoot);
|
|
590
|
+
if (read.ok && typeof read.config.export?.standard === "string") standard = read.config.export.standard;
|
|
631
591
|
switch (standard) {
|
|
632
592
|
case "scorm12": return `
|
|
633
593
|
import { SCORM12Adapter } from 'tessera-learn/runtime/adapters/scorm12.js';
|
|
@@ -689,14 +649,10 @@ function tesseraXAPISetupPlugin() {
|
|
|
689
649
|
if (!isBuild) return `export { buildXAPIClient } from 'tessera-learn/runtime/xapi/setup.js';`;
|
|
690
650
|
let standard = "web";
|
|
691
651
|
let hasXapi = false;
|
|
692
|
-
const
|
|
693
|
-
if (
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
const parsed = JSON5.parse(objectStr);
|
|
697
|
-
if (typeof parsed?.export?.standard === "string") standard = parsed.export.standard;
|
|
698
|
-
hasXapi = parsed?.xapi != null;
|
|
699
|
-
} catch {}
|
|
652
|
+
const read = readCourseConfig(projectRoot);
|
|
653
|
+
if (read.ok) {
|
|
654
|
+
if (typeof read.config.export?.standard === "string") standard = read.config.export.standard;
|
|
655
|
+
hasXapi = read.config.xapi != null;
|
|
700
656
|
}
|
|
701
657
|
if (hasXapi || standard === "cmi5") return `export { buildXAPIClient } from 'tessera-learn/runtime/xapi/setup.js';`;
|
|
702
658
|
return `export async function buildXAPIClient() { return null; }`;
|
package/dist/plugin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["__dirname"],"sources":["../../src/runtime/slugify.ts","../../src/plugin/export.ts","../../src/plugin/layout.ts","../../src/plugin/quiz.ts","../../src/plugin/index.ts"],"sourcesContent":["/**\n * Slugify a string for use as a URL-safe / filename-safe identifier.\n * \"My Course Title\" → \"my-course-title\"\n *\n * Shared by the runtime (`WebAdapter` localStorage key) and the build-time\n * exporter (`runExport` zip filename). Both want identical, deterministic\n * output so a course's storage key matches its package name.\n */\nexport function slugify(text: string): string {\n return text\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/[\\s_]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '');\n}\n","import { existsSync, readdirSync, statSync, writeFileSync, unlinkSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { createWriteStream } from 'node:fs';\nimport { createHash } from 'node:crypto';\nimport { ZipArchive } from 'archiver';\nimport { slugify } from '../runtime/slugify.js';\n\n// ---------- Types ----------\n\ninterface ExportConfig {\n title: string;\n description?: string;\n version?: string;\n scoring?: { passingScore?: number };\n completion?: { mode?: 'quiz' | 'percentage' };\n export?: { standard?: string };\n}\n\n// ---------- Helpers ----------\n\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n}\n\n/**\n * Recursively collect all file paths relative to a directory.\n */\nfunction collectFiles(dir: string, base: string = ''): string[] {\n const files: string[] = [];\n if (!existsSync(dir)) return files;\n\n for (const entry of readdirSync(dir)) {\n const fullPath = resolve(dir, entry);\n const relPath = base ? `${base}/${entry}` : entry;\n if (statSync(fullPath).isDirectory()) {\n files.push(...collectFiles(fullPath, relPath));\n } else {\n files.push(relPath);\n }\n }\n return files;\n}\n\n/**\n * Derive a stable URN IRI from a seed string. cmi5 §13.1 / xs:anyURI\n * require course / AU ids to be IRIs — bare hex or UUID-shaped strings\n * (without correct version/variant bits) aren't conformant URNs and may\n * be rejected by strict LMS importers.\n *\n * Hash the seed so the id survives rebuilds, then format as\n * `urn:tessera:<kind>:<hex>`. The same seed always produces the same\n * IRI, so existing LRS records are not orphaned by re-export.\n */\nfunction stableUrn(kind: 'course' | 'au', seed: string): string {\n const h = createHash('sha256').update(seed).digest('hex');\n // 32 hex chars (128 bits of entropy) is plenty; trim to keep ids short.\n return `urn:tessera:${kind}:${h.slice(0, 32)}`;\n}\n\nfunction formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n// ---------- Manifest Generators ----------\n\n/** Per-version XML differences in imsmanifest.xml between SCORM 1.2 and 2004. */\ninterface ScormManifestDialect {\n rootNs: string;\n adlcpNs: string;\n schemaversion: string;\n /** Attribute name on <resource>: SCORM 1.2 uses lowercase, 2004 uses camelCase. */\n scormTypeAttr: 'scormtype' | 'scormType';\n /** Whitespace-separated namespace+XSD pairs for xsi:schemaLocation. */\n schemaLocation: string;\n}\n\nconst SCORM_DIALECTS: Record<'1.2' | '2004', ScormManifestDialect> = {\n '1.2': {\n rootNs: 'http://www.imsproject.org/xsd/imscp_rootv1p1p2',\n adlcpNs: 'http://www.adlnet.org/xsd/adlcp_rootv1p2',\n schemaversion: '1.2',\n scormTypeAttr: 'scormtype',\n schemaLocation:\n 'http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd ' +\n 'http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd ' +\n 'http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd',\n },\n '2004': {\n rootNs: 'http://www.imsglobal.org/xsd/imscp_v1p1',\n adlcpNs: 'http://www.adlnet.org/xsd/adlcp_v1p3',\n schemaversion: '2004 4th Edition',\n scormTypeAttr: 'scormType',\n schemaLocation:\n 'http://www.imsglobal.org/xsd/imscp_v1p1 imscp_v1p1.xsd ' +\n 'http://www.adlnet.org/xsd/adlcp_v1p3 adlcp_v1p3.xsd',\n },\n};\n\nexport function generateScormManifest(\n version: '1.2' | '2004',\n config: ExportConfig,\n distDir: string\n): string {\n const dialect = SCORM_DIALECTS[version];\n const title = escapeXml(config.title || 'Tessera Course');\n const files = collectFiles(distDir);\n const fileElements = files\n .map((f) => ` <file href=\"${escapeXml(f)}\" />`)\n .join('\\n');\n\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<manifest identifier=\"tessera-course\" version=\"1.0\"\n xmlns=\"${dialect.rootNs}\"\n xmlns:adlcp=\"${dialect.adlcpNs}\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"${dialect.schemaLocation}\">\n <metadata>\n <schema>ADL SCORM</schema>\n <schemaversion>${dialect.schemaversion}</schemaversion>\n </metadata>\n <organizations default=\"org-1\">\n <organization identifier=\"org-1\">\n <title>${title}</title>\n <item identifier=\"item-1\" identifierref=\"res-1\">\n <title>${title}</title>\n </item>\n </organization>\n </organizations>\n <resources>\n <resource identifier=\"res-1\" type=\"webcontent\" adlcp:${dialect.scormTypeAttr}=\"sco\" href=\"index.html\">\n${fileElements}\n </resource>\n </resources>\n</manifest>`;\n}\n\nexport function generateSCORM12Manifest(\n config: ExportConfig,\n distDir: string\n): string {\n return generateScormManifest('1.2', config, distDir);\n}\n\nexport function generateSCORM2004Manifest(\n config: ExportConfig,\n distDir: string\n): string {\n return generateScormManifest('2004', config, distDir);\n}\n\nexport function generateCMI5Xml(config: ExportConfig): string {\n const title = escapeXml(config.title || 'Tessera Course');\n const description = escapeXml(config.description || '');\n // Derive stable IDs from the course title so they survive rebuilds without\n // orphaning existing learner records in the LRS.\n const courseId = stableUrn('course', `tessera-course:${config.title || ''}`);\n const auId = stableUrn('au', `tessera-au:${config.title || ''}`);\n // cmi5 §10.2.4 caps masteryScore at 4 decimals; avoid float drift like 0.7000000000000001.\n const masteryScore = Number(\n ((config.scoring?.passingScore ?? 70) / 100).toFixed(4)\n );\n // cmi5 §13.1.4 — `moveOn` decides which verb(s) the LMS treats as\n // satisfying the AU. For graded courses (completion gated on a quiz)\n // a learner who completes without passing should NOT receive credit, so\n // the LMS needs both a Completed AND a Passed before satisfaction.\n // Percentage-mode courses don't surface pass/fail, so completion alone\n // is the right signal.\n const moveOn =\n config.completion?.mode === 'quiz' ? 'CompletedAndPassed' : 'Completed';\n\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<courseStructure xmlns=\"https://w3id.org/xapi/profiles/cmi5/v1/CourseStructure.xsd\">\n <course id=\"${courseId}\">\n <title><langstring lang=\"en-US\">${title}</langstring></title>\n <description><langstring lang=\"en-US\">${description}</langstring></description>\n </course>\n <au id=\"${auId}\" launchMethod=\"AnyWindow\" moveOn=\"${moveOn}\" masteryScore=\"${masteryScore}\">\n <title><langstring lang=\"en-US\">${title}</langstring></title>\n <description><langstring lang=\"en-US\">${description}</langstring></description>\n <url>index.html</url>\n </au>\n</courseStructure>`;\n}\n\n// ---------- ZIP Packaging ----------\n\nexport async function createZip(\n distDir: string,\n outputPath: string\n): Promise<number> {\n return new Promise((res, reject) => {\n const output = createWriteStream(outputPath);\n const archive = new ZipArchive({ zlib: { level: 9 } });\n\n output.on('close', () => {\n res(archive.pointer());\n });\n output.on('error', reject);\n archive.on('error', reject);\n\n archive.pipe(output);\n archive.directory(distDir, false);\n archive.finalize();\n });\n}\n\n// ---------- Main Export ----------\n\n/**\n * Run the export process after Vite build completes.\n * Writes manifest XML into dist/, then packages into ZIP if needed.\n */\n/** Remove any previously built zips for this package to prevent accumulation. */\nfunction cleanOldZips(projectRoot: string, slug: string): void {\n try {\n for (const f of readdirSync(projectRoot)) {\n if (f.startsWith(`${slug}-`) && f.endsWith('.zip')) {\n try { unlinkSync(resolve(projectRoot, f)); } catch {}\n }\n }\n } catch {}\n}\n\nexport async function runExport(\n projectRoot: string,\n config: ExportConfig\n): Promise<void> {\n const distDir = resolve(projectRoot, 'dist');\n const standard = config.export?.standard || 'web';\n const slug = slugify(config.title || 'tessera-course') || 'tessera-course';\n const version = config.version || '1.0.0';\n const zipName = `${slug}-${version}.zip`;\n const zipPath = resolve(projectRoot, zipName);\n\n switch (standard) {\n case 'web': {\n // Compute dist size\n const files = collectFiles(distDir);\n let totalSize = 0;\n for (const f of files) {\n totalSize += statSync(resolve(distDir, f)).size;\n }\n console.log(`✓ Web export: dist/ (${formatSize(totalSize)})`);\n break;\n }\n\n case 'scorm12': {\n const manifest = generateSCORM12Manifest(config, distDir);\n writeFileSync(resolve(distDir, 'imsmanifest.xml'), manifest, 'utf-8');\n cleanOldZips(projectRoot, slug);\n const zipSize = await createZip(distDir, zipPath);\n console.log(\n `✓ SCORM 1.2 export: ${zipName} (${formatSize(zipSize)})`\n );\n break;\n }\n\n case 'scorm2004': {\n const manifest = generateSCORM2004Manifest(config, distDir);\n writeFileSync(resolve(distDir, 'imsmanifest.xml'), manifest, 'utf-8');\n cleanOldZips(projectRoot, slug);\n const zipSize = await createZip(distDir, zipPath);\n console.log(\n `✓ SCORM 2004 export: ${zipName} (${formatSize(zipSize)})`\n );\n break;\n }\n\n case 'cmi5': {\n const xml = generateCMI5Xml(config);\n writeFileSync(resolve(distDir, 'cmi5.xml'), xml, 'utf-8');\n cleanOldZips(projectRoot, slug);\n const zipSize = await createZip(distDir, zipPath);\n console.log(`✓ CMI5 export: ${zipName} (${formatSize(zipSize)})`);\n break;\n }\n }\n}\n","import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite';\nimport { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\nconst VIRTUAL_LAYOUT_ID = 'virtual:tessera-layout';\nconst RESOLVED_LAYOUT_ID = '\\0' + VIRTUAL_LAYOUT_ID;\n\nexport function tesseraLayoutPlugin(): Plugin {\n let projectRoot: string;\n\n return {\n name: 'tessera:layout',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n },\n\n resolveId(id) {\n if (id === VIRTUAL_LAYOUT_ID) return RESOLVED_LAYOUT_ID;\n return null;\n },\n\n load(id) {\n if (id !== RESOLVED_LAYOUT_ID) return null;\n const layoutPath = resolve(projectRoot, 'layout.svelte');\n if (existsSync(layoutPath)) {\n // Register the file with Vite so edits trigger HMR / build --watch\n // re-runs. Only add when the file actually exists — calling\n // addWatchFile on a non-existent path makes Vite's importAnalysis\n // try to resolve it as a real import.\n this.addWatchFile(layoutPath);\n const normalized = layoutPath.replace(/\\\\/g, '/');\n return `export { default } from '${normalized}';`;\n }\n return `export default null;`;\n },\n\n configureServer(server: ViteDevServer) {\n const layoutPath = resolve(projectRoot, 'layout.svelte');\n // Only react to add/unlink: those flip the virtual module's load() output\n // between `export default null` and `export { default } from '...'`. A\n // `change` event leaves that output identical and is handled by Svelte's\n // own HMR for the underlying file — full-reloading on every edit would\n // wipe in-page state for no reason.\n server.watcher.on('all', (event, filePath) => {\n if (filePath !== layoutPath) return;\n if (event !== 'add' && event !== 'unlink') return;\n const mod = server.moduleGraph.getModuleById(RESOLVED_LAYOUT_ID);\n if (mod) server.moduleGraph.invalidateModule(mod);\n server.ws.send({ type: 'full-reload' });\n });\n },\n };\n}\n","import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite';\nimport { existsSync } from 'node:fs';\nimport { resolve, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst VIRTUAL_QUIZ_ID = 'virtual:tessera-quiz';\nconst RESOLVED_QUIZ_ID = '\\0' + VIRTUAL_QUIZ_ID;\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Resolve the project's quiz shell.\n * `projectRoot/quiz.svelte` overrides the built-in `<Quiz>` if it exists,\n * otherwise the built-in is used. Mirrors `tesseraLayoutPlugin` (Phase 3A).\n */\nexport function tesseraQuizPlugin(): Plugin {\n let projectRoot: string;\n // Resolve the built-in Quiz.svelte once. The plugin lives in\n // `dist/plugin/quiz.js` after build and `src/plugin/quiz.ts` in source —\n // both layouts put `Quiz.svelte` two levels up under `src/components/`.\n const packageRoot = resolve(__dirname, '..', '..');\n const builtinQuiz = resolve(packageRoot, 'src', 'components', 'Quiz.svelte');\n\n return {\n name: 'tessera:quiz',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n },\n\n resolveId(id) {\n if (id === VIRTUAL_QUIZ_ID) return RESOLVED_QUIZ_ID;\n return null;\n },\n\n load(id) {\n if (id !== RESOLVED_QUIZ_ID) return null;\n const userQuizPath = resolve(projectRoot, 'quiz.svelte');\n if (existsSync(userQuizPath)) {\n // Watch the user file so add/remove flips through HMR (see below).\n this.addWatchFile(userQuizPath);\n const normalized = userQuizPath.replace(/\\\\/g, '/');\n return `export { default } from '${normalized}';`;\n }\n const normalized = builtinQuiz.replace(/\\\\/g, '/');\n return `export { default } from '${normalized}';`;\n },\n\n configureServer(server: ViteDevServer) {\n const userQuizPath = resolve(projectRoot, 'quiz.svelte');\n // Only react to add/unlink — those flip the load() output between the\n // user quiz and the built-in. A `change` event leaves the resolved\n // module identical and is handled by Svelte's own HMR.\n server.watcher.on('all', (event, filePath) => {\n if (filePath !== userQuizPath) return;\n if (event !== 'add' && event !== 'unlink') return;\n const mod = server.moduleGraph.getModuleById(RESOLVED_QUIZ_ID);\n if (mod) server.moduleGraph.invalidateModule(mod);\n server.ws.send({ type: 'full-reload' });\n });\n },\n };\n}\n","import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite';\nimport { svelte } from '@sveltejs/vite-plugin-svelte';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, resolve } from 'node:path';\nimport { existsSync, readFileSync, readdirSync, statSync, writeFileSync, unlinkSync, cpSync, mkdirSync } from 'node:fs';\nimport { generateManifest, extractDefaultExportObjectLiteral } from './manifest.js';\nimport JSON5 from 'json5';\nimport type { Manifest } from './manifest.js';\nimport { validateProject } from './validation.js';\nimport { runExport } from './export.js';\nimport { tesseraLayoutPlugin } from './layout.js';\nimport { tesseraQuizPlugin } from './quiz.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Resolve the runtime directory where App.svelte lives\nfunction resolveRuntimeDir(): string {\n const packageRoot = resolve(__dirname, '..', '..');\n return resolve(packageRoot, 'src', 'runtime');\n}\n\n// Resolve the framework styles directory\nfunction resolveStylesDir(): string {\n const packageRoot = resolve(__dirname, '..', '..');\n return resolve(packageRoot, 'styles');\n}\n\nexport function tesseraPlugin() {\n const manifestRef: { current: Manifest | null; root: string } = { current: null, root: '' };\n return [\n svelte({\n compilerOptions: { css: 'external' },\n }),\n tesseraValidationPlugin(),\n tesseraEntryPlugin(),\n tesseraConfigPlugin(),\n tesseraPagesPlugin(),\n tesseraManifestPlugin(manifestRef),\n tesseraLayoutPlugin(),\n tesseraQuizPlugin(),\n tesseraAdapterPlugin(),\n tesseraXAPISetupPlugin(),\n tesseraFirstPagePreloadPlugin(manifestRef),\n tesseraExportPlugin(),\n ];\n}\n\n// ---------- Entry Plugin ----------\n\nconst VIRTUAL_ENTRY_ID = 'virtual:tessera-entry';\nconst RESOLVED_ENTRY_ID = '\\0' + VIRTUAL_ENTRY_ID;\nconst VIRTUAL_MAIN_ID = '/virtual:tessera-main';\nconst RESOLVED_MAIN_ID = '\\0virtual:tessera-main';\n\nfunction tesseraEntryPlugin(): Plugin {\n const runtimeDir = resolveRuntimeDir();\n const stylesDir = resolveStylesDir();\n const appSveltePath = resolve(runtimeDir, 'App.svelte');\n let projectRoot: string;\n let isBuild = false;\n\n return {\n name: 'tessera:entry',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n\n // For build mode: write index.html so Rollup can find it\n buildStart() {\n if (isBuild) {\n writeFileSync(resolve(projectRoot, 'index.html'), generateIndexHtml(), 'utf-8');\n }\n },\n\n // For build mode: clean up temporary index.html and copy assets\n closeBundle() {\n if (isBuild) {\n const htmlPath = resolve(projectRoot, 'index.html');\n if (existsSync(htmlPath)) {\n try { unlinkSync(htmlPath); } catch {}\n }\n\n // Copy assets/ directory to dist/assets/ so $assets/ references resolve\n const assetsDir = resolve(projectRoot, 'assets');\n const distAssetsDir = resolve(projectRoot, 'dist', 'assets');\n if (existsSync(assetsDir)) {\n mkdirSync(distAssetsDir, { recursive: true });\n cpSync(assetsDir, distAssetsDir, { recursive: true });\n }\n }\n },\n\n // Serve index.html for the dev server\n configureServer(server: ViteDevServer) {\n return () => {\n server.middlewares.use(async (req, res, next) => {\n if (req.url === '/' || req.url === '/index.html') {\n const html = generateIndexHtml();\n const transformed = await server.transformIndexHtml(req.url, html);\n res.setHeader('Content-Type', 'text/html');\n res.statusCode = 200;\n res.end(transformed);\n return;\n }\n next();\n });\n };\n },\n\n resolveId(id) {\n if (id === VIRTUAL_ENTRY_ID) return RESOLVED_ENTRY_ID;\n if (id === VIRTUAL_MAIN_ID || id === 'virtual:tessera-main') return RESOLVED_MAIN_ID;\n return null;\n },\n\n load(id) {\n if (id === RESOLVED_ENTRY_ID || id === RESOLVED_MAIN_ID) {\n return generateEntryScript(appSveltePath, stylesDir, projectRoot);\n }\n return null;\n },\n };\n}\n\nfunction generateIndexHtml(): string {\n return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Tessera Course</title>\n</head>\n<body>\n <div id=\"tessera-root\"></div>\n <script type=\"module\" src=\"/virtual:tessera-main\"></script>\n</body>\n</html>`;\n}\n\nfunction generateEntryScript(appSveltePath: string, frameworkStylesDir: string, projectRoot: string): string {\n const normalizedPath = appSveltePath.replace(/\\\\/g, '/');\n\n // Framework CSS imports (theme → base → layout)\n const frameworkCssOrder = ['theme.css', 'base.css', 'layout.css'];\n const frameworkImports = frameworkCssOrder\n .map(file => resolve(frameworkStylesDir, file).replace(/\\\\/g, '/'))\n .filter(path => existsSync(path))\n .map(path => `import '${path}';`)\n .join('\\n');\n\n // User CSS imports from project's styles/ directory\n const userStylesDir = resolve(projectRoot, 'styles');\n let userImports = '';\n if (existsSync(userStylesDir)) {\n const userCssFiles = readdirSync(userStylesDir)\n .filter(f => f.endsWith('.css'))\n .sort();\n userImports = userCssFiles\n .map(f => resolve(userStylesDir, f).replace(/\\\\/g, '/'))\n .map(path => `import '${path}';`)\n .join('\\n');\n }\n\n return `// Framework styles\n${frameworkImports}\n// User styles\n${userImports}\n\nimport { mount } from 'svelte';\nimport App from '${normalizedPath}';\n\nmount(App, {\n target: document.getElementById('tessera-root'),\n});\n`;\n}\n\n// ---------- Config Plugin ----------\n\nconst VIRTUAL_CONFIG_ID = 'virtual:tessera-config';\nconst RESOLVED_CONFIG_ID = '\\0' + VIRTUAL_CONFIG_ID;\n\nfunction completionDefaults(mode: string | undefined): {\n completion: Record<string, unknown>;\n passingScore: number;\n} {\n if (mode === 'manual') {\n return { completion: { mode: 'manual' }, passingScore: 0 };\n }\n return { completion: { mode: 'percentage', percentageThreshold: 100 }, passingScore: 70 };\n}\n\nfunction tesseraConfigPlugin(): Plugin {\n let projectRoot: string;\n\n return {\n name: 'tessera:config',\n enforce: 'pre',\n\n config(config) {\n const root = config.root || process.cwd();\n\n return {\n base: './',\n resolve: {\n alias: {\n '$assets': resolve(root, 'assets'),\n },\n },\n // tessera-learn ships .ts/.svelte.ts source; Vite's dep optimizer\n // doesn't run vite-plugin-svelte's preprocessor, so skip pre-bundling.\n optimizeDeps: {\n exclude: ['tessera-learn'],\n },\n };\n },\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n },\n\n resolveId(id) {\n if (id === VIRTUAL_CONFIG_ID) return RESOLVED_CONFIG_ID;\n return null;\n },\n\n load(id) {\n if (id === RESOLVED_CONFIG_ID) {\n const configPath = resolve(projectRoot, 'course.config.js');\n let userConfig: Record<string, any> = {};\n\n if (existsSync(configPath)) {\n this.addWatchFile(configPath);\n const objectStr = extractDefaultExportObjectLiteral(readFileSync(configPath, 'utf-8'));\n if (objectStr) {\n try { userConfig = JSON5.parse(objectStr); } catch {}\n }\n }\n\n const { completion, passingScore } = completionDefaults(userConfig.completion?.mode);\n const merged = {\n title: userConfig.title || 'Untitled Course',\n ...userConfig,\n navigation: { mode: 'free', ...userConfig.navigation },\n completion: { ...completion, ...userConfig.completion },\n scoring: { passingScore, ...userConfig.scoring },\n export: { standard: 'web', ...userConfig.export },\n };\n\n return `export default ${JSON.stringify(merged)};`;\n }\n return null;\n },\n };\n}\n\n// ---------- Manifest Watch Helpers ----------\n\n/** Register all _meta.js and .svelte files under pagesDir as watch files for build mode. */\nfunction addWatchFiles(ctx: { addWatchFile(id: string): void }, dir: string): void {\n if (!existsSync(dir)) return;\n for (const entry of readdirSync(dir)) {\n const full = resolve(dir, entry);\n if (statSync(full).isDirectory()) {\n addWatchFiles(ctx, full);\n } else if (entry.endsWith('.svelte') || entry === '_meta.js') {\n ctx.addWatchFile(full);\n }\n }\n}\n\n// ---------- Pages Plugin ----------\n\nconst VIRTUAL_PAGES_ID = 'virtual:tessera-pages';\nconst RESOLVED_PAGES_ID = '\\0' + VIRTUAL_PAGES_ID;\n\n/**\n * Provides a virtual module that exports an import.meta.glob map for all .svelte\n * pages. This runs in the user's project context so the glob resolves against their\n * pages/ directory, and Vite can statically analyze it for code splitting.\n */\nfunction tesseraPagesPlugin(): Plugin {\n return {\n name: 'tessera:pages',\n enforce: 'pre',\n\n resolveId(id) {\n if (id === VIRTUAL_PAGES_ID) return RESOLVED_PAGES_ID;\n return null;\n },\n\n load(id) {\n if (id === RESOLVED_PAGES_ID) {\n return `export default import.meta.glob('/pages/**/*.svelte');`;\n }\n return null;\n },\n };\n}\n\n// ---------- Validation Plugin ----------\n\nfunction tesseraValidationPlugin(): Plugin {\n let projectRoot: string;\n let isBuild = false;\n\n return {\n name: 'tessera:validation',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n // Run validation during dev (configResolved fires before server starts)\n if (!isBuild) {\n runValidation(projectRoot);\n }\n },\n\n buildStart() {\n // Run validation during build (buildStart fires once before bundling)\n if (isBuild) {\n runValidation(projectRoot);\n }\n },\n };\n}\n\nfunction runValidation(projectRoot: string): void {\n const { errors, warnings } = validateProject(projectRoot);\n\n for (const warning of warnings) {\n console.warn(`\\x1b[33m[tessera warning]\\x1b[0m ${warning}`);\n }\n\n if (errors.length > 0) {\n for (const error of errors) {\n console.error(`\\x1b[31m[tessera error]\\x1b[0m ${error}`);\n }\n throw new Error(\n `Tessera validation failed with ${errors.length} error(s). Fix the errors above to continue.`\n );\n }\n}\n\n// ---------- Export Plugin ----------\n\nfunction tesseraExportPlugin(): Plugin {\n let projectRoot: string;\n let isBuild = false;\n\n return {\n name: 'tessera:export',\n enforce: 'post',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n\n async closeBundle() {\n if (!isBuild) return;\n\n const configPath = resolve(projectRoot, 'course.config.js');\n if (!existsSync(configPath)) {\n // Validation already required course.config.js — getting here means\n // the file vanished mid-build. Surface that loudly rather than\n // shipping a bundle with no LMS export silently.\n throw new Error(\n '[tessera:export] course.config.js not found at closeBundle. The file must exist for the export step to run.'\n );\n }\n\n const objectStr = extractDefaultExportObjectLiteral(readFileSync(configPath, 'utf-8'));\n if (!objectStr) {\n throw new Error(\n '[tessera:export] course.config.js: could not locate `export default { ... }`. Cannot determine export.standard.'\n );\n }\n\n let config: any;\n try {\n config = JSON5.parse(objectStr);\n } catch (err) {\n throw new Error(\n `[tessera:export] course.config.js: failed to parse export-default object literal — ${(err as Error).message}`\n );\n }\n\n await runExport(projectRoot, config);\n },\n };\n}\n\n// ---------- Manifest Plugin ----------\n\nconst VIRTUAL_MANIFEST_ID = 'virtual:tessera-manifest';\nconst RESOLVED_MANIFEST_ID = '\\0' + VIRTUAL_MANIFEST_ID;\n\nfunction tesseraManifestPlugin(manifestRef: { current: Manifest | null; root: string }): Plugin {\n let projectRoot: string;\n let pagesDir: string;\n let server: ViteDevServer | null = null;\n\n function buildManifest(): Manifest {\n const m = generateManifest(pagesDir);\n manifestRef.current = m;\n return m;\n }\n\n return {\n name: 'tessera:manifest',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n pagesDir = resolve(projectRoot, 'pages');\n manifestRef.root = projectRoot;\n },\n\n configureServer(devServer: ViteDevServer) {\n server = devServer;\n\n // Watch the pages directory for changes\n devServer.watcher.on('all', (event, filePath) => {\n if (!filePath.startsWith(pagesDir)) return;\n\n // Rebuild manifest on relevant file changes\n const isRelevant =\n filePath.endsWith('.svelte') ||\n filePath.endsWith('_meta.js') ||\n event === 'addDir' ||\n event === 'unlinkDir';\n\n if (isRelevant) {\n manifestRef.current = null; // invalidate cache\n\n // Invalidate the virtual module to trigger HMR\n const mod = devServer.moduleGraph.getModuleById(RESOLVED_MANIFEST_ID);\n if (mod) {\n devServer.moduleGraph.invalidateModule(mod);\n devServer.ws.send({ type: 'full-reload' });\n }\n\n console.log(`[tessera] Manifest rebuilt (${event}: ${filePath.replace(projectRoot, '')})`);\n }\n });\n },\n\n buildStart() {\n buildManifest();\n },\n\n resolveId(id) {\n if (id === VIRTUAL_MANIFEST_ID) return RESOLVED_MANIFEST_ID;\n return null;\n },\n\n load(id) {\n if (id === RESOLVED_MANIFEST_ID) {\n if (!manifestRef.current) {\n buildManifest();\n }\n\n // Register watch files so Vite's built-in watcher (used in build --watch)\n // knows to re-trigger when pages/ content changes.\n addWatchFiles(this, pagesDir);\n\n // Encode as base64 to prevent Vite's import analysis from\n // scanning .svelte importPath strings as module imports.\n // Replace Infinity with 1e9 since JSON.stringify drops it.\n const json = JSON.stringify(manifestRef.current, (_key, value) =>\n value === Infinity ? 1e9 : value\n );\n const b64 = Buffer.from(json).toString('base64');\n return `export default JSON.parse(atob(\"${b64}\"));`;\n }\n return null;\n },\n };\n}\n\nconst VIRTUAL_ADAPTER_ID = 'virtual:tessera-adapter';\nconst RESOLVED_ADAPTER_ID = '\\0' + VIRTUAL_ADAPTER_ID;\n\nfunction tesseraAdapterPlugin(): Plugin {\n let projectRoot: string;\n let isBuild = false;\n\n return {\n name: 'tessera:adapter',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n\n resolveId(id) {\n if (id === VIRTUAL_ADAPTER_ID) return RESOLVED_ADAPTER_ID;\n return null;\n },\n\n load(id) {\n if (id !== RESOLVED_ADAPTER_ID) return null;\n\n // In dev, defer to the runtime selector so its WebAdapter fallback\n // for unreachable LMS APIs keeps working.\n if (!isBuild) {\n return `export { createAdapter } from 'tessera-learn/runtime/adapters/index.js';`;\n }\n\n let standard = 'web';\n const configPath = resolve(projectRoot, 'course.config.js');\n if (existsSync(configPath)) {\n const objectStr = extractDefaultExportObjectLiteral(readFileSync(configPath, 'utf-8'));\n if (objectStr) {\n try {\n const parsed = JSON5.parse(objectStr);\n if (typeof parsed?.export?.standard === 'string') standard = parsed.export.standard;\n } catch {}\n }\n }\n\n switch (standard) {\n case 'scorm12':\n return `\nimport { SCORM12Adapter } from 'tessera-learn/runtime/adapters/scorm12.js';\nimport { findSCORM12API } from 'tessera-learn/runtime/adapters/discovery.js';\nimport { LMSAdapterError } from 'tessera-learn/runtime/adapters/index.js';\nexport function createAdapter() {\n const api = findSCORM12API();\n if (!api) throw new LMSAdapterError('scorm12', 'Tessera: SCORM 1.2 API not found in window.parent/opener chain. Course must be launched from a SCORM 1.2 LMS.');\n return new SCORM12Adapter(api);\n}\n`;\n case 'scorm2004':\n return `\nimport { SCORM2004Adapter } from 'tessera-learn/runtime/adapters/scorm2004.js';\nimport { findSCORM2004API } from 'tessera-learn/runtime/adapters/discovery.js';\nimport { LMSAdapterError } from 'tessera-learn/runtime/adapters/index.js';\nexport function createAdapter() {\n const api = findSCORM2004API();\n if (!api) throw new LMSAdapterError('scorm2004', 'Tessera: SCORM 2004 API not found in window.parent/opener chain. Course must be launched from a SCORM 2004 LMS.');\n return new SCORM2004Adapter(api);\n}\n`;\n case 'cmi5':\n return `\nimport { CMI5Adapter } from 'tessera-learn/runtime/adapters/cmi5.js';\nimport { hasCMI5LaunchParams } from 'tessera-learn/runtime/adapters/discovery.js';\nimport { LMSAdapterError } from 'tessera-learn/runtime/adapters/index.js';\nexport function createAdapter() {\n if (!hasCMI5LaunchParams()) throw new LMSAdapterError('cmi5', 'Tessera: cmi5 launch parameters not present on URL. Course must be launched from a cmi5-compliant LMS.');\n return new CMI5Adapter();\n}\n`;\n default:\n return `\nimport { WebAdapter } from 'tessera-learn/runtime/adapters/web.js';\nexport function createAdapter(config) {\n return new WebAdapter(config);\n}\n`;\n }\n },\n };\n}\n\nconst VIRTUAL_XAPI_SETUP_ID = 'virtual:tessera-xapi-setup';\nconst RESOLVED_XAPI_SETUP_ID = '\\0' + VIRTUAL_XAPI_SETUP_ID;\n\nfunction tesseraXAPISetupPlugin(): Plugin {\n let projectRoot: string;\n let isBuild = false;\n\n return {\n name: 'tessera:xapi-setup',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n\n resolveId(id) {\n if (id === VIRTUAL_XAPI_SETUP_ID) return RESOLVED_XAPI_SETUP_ID;\n return null;\n },\n\n load(id) {\n if (id !== RESOLVED_XAPI_SETUP_ID) return null;\n\n if (!isBuild) {\n return `export { buildXAPIClient } from 'tessera-learn/runtime/xapi/setup.js';`;\n }\n\n let standard = 'web';\n let hasXapi = false;\n const configPath = resolve(projectRoot, 'course.config.js');\n if (existsSync(configPath)) {\n const objectStr = extractDefaultExportObjectLiteral(readFileSync(configPath, 'utf-8'));\n if (objectStr) {\n try {\n const parsed = JSON5.parse(objectStr);\n if (typeof parsed?.export?.standard === 'string') standard = parsed.export.standard;\n hasXapi = parsed?.xapi != null;\n } catch {}\n }\n }\n\n // cmi5 needs the publisher regardless of explicit xapi config (cmi5\n // adapter shares the publisher queue for its own LMS-required statements).\n if (hasXapi || standard === 'cmi5') {\n return `export { buildXAPIClient } from 'tessera-learn/runtime/xapi/setup.js';`;\n }\n\n return `export async function buildXAPIClient() { return null; }`;\n },\n };\n}\n\nfunction tesseraFirstPagePreloadPlugin(manifestRef: { current: Manifest | null; root: string }): Plugin {\n return {\n name: 'tessera:first-page-preload',\n apply: 'build',\n transformIndexHtml: {\n order: 'post',\n handler(_html, ctx) {\n const firstPagePath = manifestRef.current?.pages[0]?.importPath;\n if (!firstPagePath || !ctx.bundle) return;\n const normalized = resolve(manifestRef.root, firstPagePath.replace(/^\\//, '')).replace(/\\\\/g, '/');\n const chunk = Object.values(ctx.bundle).find(\n (c): c is import('vite').Rollup.OutputChunk =>\n c.type === 'chunk' && !!c.facadeModuleId && c.facadeModuleId.replace(/\\\\/g, '/') === normalized\n );\n if (!chunk) return;\n return [{\n tag: 'link',\n attrs: { rel: 'modulepreload', href: `./${chunk.fileName}` },\n injectTo: 'head',\n }];\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAQA,SAAgB,QAAQ,MAAsB;CAC5C,OAAO,KACJ,aAAa,CACb,MAAM,CACN,QAAQ,aAAa,GAAG,CACxB,QAAQ,WAAW,IAAI,CACvB,QAAQ,OAAO,IAAI,CACnB,QAAQ,UAAU,GAAG;;;;ACK1B,SAAS,UAAU,KAAqB;CACtC,OAAO,IACJ,QAAQ,MAAM,QAAQ,CACtB,QAAQ,MAAM,OAAO,CACrB,QAAQ,MAAM,OAAO,CACrB,QAAQ,MAAM,SAAS,CACvB,QAAQ,MAAM,SAAS;;;;;AAM5B,SAAS,aAAa,KAAa,OAAe,IAAc;CAC9D,MAAM,QAAkB,EAAE;CAC1B,IAAI,CAAC,WAAW,IAAI,EAAE,OAAO;CAE7B,KAAK,MAAM,SAAS,YAAY,IAAI,EAAE;EACpC,MAAM,WAAW,QAAQ,KAAK,MAAM;EACpC,MAAM,UAAU,OAAO,GAAG,KAAK,GAAG,UAAU;EAC5C,IAAI,SAAS,SAAS,CAAC,aAAa,EAClC,MAAM,K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C;;GAEL;EACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["__dirname"],"sources":["../../src/runtime/slugify.ts","../../src/plugin/export.ts","../../src/plugin/override-plugin.ts","../../src/plugin/layout.ts","../../src/plugin/quiz.ts","../../src/plugin/index.ts"],"sourcesContent":["/**\n * Slugify a string for use as a URL-safe / filename-safe identifier.\n * \"My Course Title\" → \"my-course-title\"\n *\n * Shared by the runtime (`WebAdapter` localStorage key) and the build-time\n * exporter (`runExport` zip filename). Both want identical, deterministic\n * output so a course's storage key matches its package name.\n */\nexport function slugify(text: string): string {\n return text\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/[\\s_]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '');\n}\n","import { existsSync, readdirSync, statSync, writeFileSync, unlinkSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { createWriteStream } from 'node:fs';\nimport { createHash } from 'node:crypto';\nimport { ZipArchive } from 'archiver';\nimport { slugify } from '../runtime/slugify.js';\n\n// ---------- Types ----------\n\ninterface ExportConfig {\n title: string;\n description?: string;\n version?: string;\n scoring?: { passingScore?: number };\n completion?: { mode?: 'quiz' | 'percentage' };\n export?: { standard?: string };\n}\n\n// ---------- Helpers ----------\n\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n}\n\n/**\n * Recursively collect all file paths relative to a directory.\n */\nfunction collectFiles(dir: string, base: string = ''): string[] {\n const files: string[] = [];\n if (!existsSync(dir)) return files;\n\n for (const entry of readdirSync(dir)) {\n const fullPath = resolve(dir, entry);\n const relPath = base ? `${base}/${entry}` : entry;\n if (statSync(fullPath).isDirectory()) {\n files.push(...collectFiles(fullPath, relPath));\n } else {\n files.push(relPath);\n }\n }\n return files;\n}\n\n/**\n * Derive a stable URN IRI from a seed string. cmi5 §13.1 / xs:anyURI\n * require course / AU ids to be IRIs — bare hex or UUID-shaped strings\n * (without correct version/variant bits) aren't conformant URNs and may\n * be rejected by strict LMS importers.\n *\n * Hash the seed so the id survives rebuilds, then format as\n * `urn:tessera:<kind>:<hex>`. The same seed always produces the same\n * IRI, so existing LRS records are not orphaned by re-export.\n */\nfunction stableUrn(kind: 'course' | 'au', seed: string): string {\n const h = createHash('sha256').update(seed).digest('hex');\n // 32 hex chars (128 bits of entropy) is plenty; trim to keep ids short.\n return `urn:tessera:${kind}:${h.slice(0, 32)}`;\n}\n\nfunction formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n// ---------- Manifest Generators ----------\n\n/** Per-version XML differences in imsmanifest.xml between SCORM 1.2 and 2004. */\ninterface ScormManifestDialect {\n rootNs: string;\n adlcpNs: string;\n schemaversion: string;\n /** Attribute name on <resource>: SCORM 1.2 uses lowercase, 2004 uses camelCase. */\n scormTypeAttr: 'scormtype' | 'scormType';\n /** Whitespace-separated namespace+XSD pairs for xsi:schemaLocation. */\n schemaLocation: string;\n}\n\nconst SCORM_DIALECTS: Record<'1.2' | '2004', ScormManifestDialect> = {\n '1.2': {\n rootNs: 'http://www.imsproject.org/xsd/imscp_rootv1p1p2',\n adlcpNs: 'http://www.adlnet.org/xsd/adlcp_rootv1p2',\n schemaversion: '1.2',\n scormTypeAttr: 'scormtype',\n schemaLocation:\n 'http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd ' +\n 'http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd ' +\n 'http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd',\n },\n '2004': {\n rootNs: 'http://www.imsglobal.org/xsd/imscp_v1p1',\n adlcpNs: 'http://www.adlnet.org/xsd/adlcp_v1p3',\n schemaversion: '2004 4th Edition',\n scormTypeAttr: 'scormType',\n schemaLocation:\n 'http://www.imsglobal.org/xsd/imscp_v1p1 imscp_v1p1.xsd ' +\n 'http://www.adlnet.org/xsd/adlcp_v1p3 adlcp_v1p3.xsd',\n },\n};\n\nexport function generateScormManifest(\n version: '1.2' | '2004',\n config: ExportConfig,\n distDir: string\n): string {\n const dialect = SCORM_DIALECTS[version];\n const title = escapeXml(config.title || 'Tessera Course');\n const files = collectFiles(distDir);\n const fileElements = files\n .map((f) => ` <file href=\"${escapeXml(f)}\" />`)\n .join('\\n');\n\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<manifest identifier=\"tessera-course\" version=\"1.0\"\n xmlns=\"${dialect.rootNs}\"\n xmlns:adlcp=\"${dialect.adlcpNs}\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"${dialect.schemaLocation}\">\n <metadata>\n <schema>ADL SCORM</schema>\n <schemaversion>${dialect.schemaversion}</schemaversion>\n </metadata>\n <organizations default=\"org-1\">\n <organization identifier=\"org-1\">\n <title>${title}</title>\n <item identifier=\"item-1\" identifierref=\"res-1\">\n <title>${title}</title>\n </item>\n </organization>\n </organizations>\n <resources>\n <resource identifier=\"res-1\" type=\"webcontent\" adlcp:${dialect.scormTypeAttr}=\"sco\" href=\"index.html\">\n${fileElements}\n </resource>\n </resources>\n</manifest>`;\n}\n\nexport function generateSCORM12Manifest(\n config: ExportConfig,\n distDir: string\n): string {\n return generateScormManifest('1.2', config, distDir);\n}\n\nexport function generateSCORM2004Manifest(\n config: ExportConfig,\n distDir: string\n): string {\n return generateScormManifest('2004', config, distDir);\n}\n\nexport function generateCMI5Xml(config: ExportConfig): string {\n const title = escapeXml(config.title || 'Tessera Course');\n const description = escapeXml(config.description || '');\n // Derive stable IDs from the course title so they survive rebuilds without\n // orphaning existing learner records in the LRS.\n const courseId = stableUrn('course', `tessera-course:${config.title || ''}`);\n const auId = stableUrn('au', `tessera-au:${config.title || ''}`);\n // cmi5 §10.2.4 caps masteryScore at 4 decimals; avoid float drift like 0.7000000000000001.\n const masteryScore = Number(\n ((config.scoring?.passingScore ?? 70) / 100).toFixed(4)\n );\n // cmi5 §13.1.4 — `moveOn` decides which verb(s) the LMS treats as\n // satisfying the AU. For graded courses (completion gated on a quiz)\n // a learner who completes without passing should NOT receive credit, so\n // the LMS needs both a Completed AND a Passed before satisfaction.\n // Percentage-mode courses don't surface pass/fail, so completion alone\n // is the right signal.\n const moveOn =\n config.completion?.mode === 'quiz' ? 'CompletedAndPassed' : 'Completed';\n\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<courseStructure xmlns=\"https://w3id.org/xapi/profiles/cmi5/v1/CourseStructure.xsd\">\n <course id=\"${courseId}\">\n <title><langstring lang=\"en-US\">${title}</langstring></title>\n <description><langstring lang=\"en-US\">${description}</langstring></description>\n </course>\n <au id=\"${auId}\" launchMethod=\"AnyWindow\" moveOn=\"${moveOn}\" masteryScore=\"${masteryScore}\">\n <title><langstring lang=\"en-US\">${title}</langstring></title>\n <description><langstring lang=\"en-US\">${description}</langstring></description>\n <url>index.html</url>\n </au>\n</courseStructure>`;\n}\n\n// ---------- ZIP Packaging ----------\n\nexport async function createZip(\n distDir: string,\n outputPath: string\n): Promise<number> {\n return new Promise((res, reject) => {\n const output = createWriteStream(outputPath);\n const archive = new ZipArchive({ zlib: { level: 9 } });\n\n output.on('close', () => {\n res(archive.pointer());\n });\n output.on('error', reject);\n archive.on('error', reject);\n\n archive.pipe(output);\n archive.directory(distDir, false);\n archive.finalize();\n });\n}\n\n// ---------- Main Export ----------\n\n/**\n * Run the export process after Vite build completes.\n * Writes manifest XML into dist/, then packages into ZIP if needed.\n */\n/** Remove any previously built zips for this package to prevent accumulation. */\nfunction cleanOldZips(projectRoot: string, slug: string): void {\n try {\n for (const f of readdirSync(projectRoot)) {\n if (f.startsWith(`${slug}-`) && f.endsWith('.zip')) {\n try { unlinkSync(resolve(projectRoot, f)); } catch {}\n }\n }\n } catch {}\n}\n\n/** Packaged (zipped) export targets: which manifest file to write and how. */\nconst PACKAGED_EXPORTS: Record<\n 'scorm12' | 'scorm2004' | 'cmi5',\n { manifestFile: string; label: string; generate: (config: ExportConfig, distDir: string) => string }\n> = {\n scorm12: { manifestFile: 'imsmanifest.xml', label: 'SCORM 1.2', generate: generateSCORM12Manifest },\n scorm2004: { manifestFile: 'imsmanifest.xml', label: 'SCORM 2004', generate: generateSCORM2004Manifest },\n cmi5: { manifestFile: 'cmi5.xml', label: 'CMI5', generate: (config) => generateCMI5Xml(config) },\n};\n\nexport async function runExport(\n projectRoot: string,\n config: ExportConfig\n): Promise<void> {\n const distDir = resolve(projectRoot, 'dist');\n const standard = config.export?.standard || 'web';\n const slug = slugify(config.title || 'tessera-course') || 'tessera-course';\n const version = config.version || '1.0.0';\n const zipName = `${slug}-${version}.zip`;\n const zipPath = resolve(projectRoot, zipName);\n\n if (standard === 'web') {\n const files = collectFiles(distDir);\n let totalSize = 0;\n for (const f of files) totalSize += statSync(resolve(distDir, f)).size;\n console.log(`✓ Web export: dist/ (${formatSize(totalSize)})`);\n return;\n }\n\n const spec = PACKAGED_EXPORTS[standard as keyof typeof PACKAGED_EXPORTS];\n if (!spec) return; // unknown standard — the validator rejects these upstream\n\n writeFileSync(resolve(distDir, spec.manifestFile), spec.generate(config, distDir), 'utf-8');\n cleanOldZips(projectRoot, slug);\n const zipSize = await createZip(distDir, zipPath);\n console.log(`✓ ${spec.label} export: ${zipName} (${formatSize(zipSize)})`);\n}\n","import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite';\nimport { normalizePath } from 'vite';\nimport { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\nexport interface OverridePluginOptions {\n name: string;\n virtualId: string;\n projectFile: string;\n /** Built-in re-exported when the project file is absent; null export otherwise. */\n builtinFile?: string;\n}\n\n/**\n * A virtual module that resolves to a project-root override file when present,\n * and to the built-in (or a null export) otherwise. Shared by the layout and\n * quiz plugins — they differ only in the virtual id, file name, and built-in.\n */\nexport function createOverridePlugin({\n name,\n virtualId,\n projectFile,\n builtinFile,\n}: OverridePluginOptions): Plugin {\n const resolvedId = '\\0' + virtualId;\n const fallback = builtinFile\n ? `export { default } from '${normalizePath(builtinFile)}';`\n : 'export default null;';\n let filePath: string;\n\n return {\n name,\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n filePath = resolve(config.root, projectFile);\n },\n\n resolveId(id) {\n if (id === virtualId) return resolvedId;\n return null;\n },\n\n load(id) {\n if (id !== resolvedId) return null;\n if (existsSync(filePath)) {\n // Only watch when it exists — addWatchFile on a missing path makes\n // Vite's importAnalysis try to resolve it as a real import.\n this.addWatchFile(filePath);\n return `export { default } from '${normalizePath(filePath)}';`;\n }\n return fallback;\n },\n\n configureServer(server: ViteDevServer) {\n // Only add/unlink flips load()'s output between the override and the\n // fallback; a `change` leaves it identical and Svelte's own HMR handles\n // the underlying file.\n server.watcher.on('all', (event, changed) => {\n if (changed !== filePath) return;\n if (event !== 'add' && event !== 'unlink') return;\n const mod = server.moduleGraph.getModuleById(resolvedId);\n if (mod) server.moduleGraph.invalidateModule(mod);\n server.ws.send({ type: 'full-reload' });\n });\n },\n };\n}\n","import type { Plugin } from 'vite';\nimport { createOverridePlugin } from './override-plugin.js';\n\nexport function tesseraLayoutPlugin(): Plugin {\n return createOverridePlugin({\n name: 'tessera:layout',\n virtualId: 'virtual:tessera-layout',\n projectFile: 'layout.svelte',\n });\n}\n","import type { Plugin } from 'vite';\nimport { resolve, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { createOverridePlugin } from './override-plugin.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nexport function tesseraQuizPlugin(): Plugin {\n // The plugin lives in `dist/plugin/quiz.js` after build and `src/plugin/quiz.ts`\n // in source — both put `Quiz.svelte` two levels up under `src/components/`.\n const packageRoot = resolve(__dirname, '..', '..');\n const builtinQuiz = resolve(packageRoot, 'src', 'components', 'Quiz.svelte');\n return createOverridePlugin({\n name: 'tessera:quiz',\n virtualId: 'virtual:tessera-quiz',\n projectFile: 'quiz.svelte',\n builtinFile: builtinQuiz,\n });\n}\n","import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite';\nimport { svelte } from '@sveltejs/vite-plugin-svelte';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, resolve } from 'node:path';\nimport { existsSync, readdirSync, statSync, writeFileSync, unlinkSync, cpSync, mkdirSync } from 'node:fs';\nimport { generateManifest, readCourseConfig } from './manifest.js';\nimport type { Manifest } from './manifest.js';\nimport { validateProject, reportValidationIssues } from './validation.js';\nimport { runExport } from './export.js';\nimport { tesseraLayoutPlugin } from './layout.js';\nimport { tesseraQuizPlugin } from './quiz.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Resolve the runtime directory where App.svelte lives\nfunction resolveRuntimeDir(): string {\n const packageRoot = resolve(__dirname, '..', '..');\n return resolve(packageRoot, 'src', 'runtime');\n}\n\n// Resolve the framework styles directory\nfunction resolveStylesDir(): string {\n const packageRoot = resolve(__dirname, '..', '..');\n return resolve(packageRoot, 'styles');\n}\n\nexport function tesseraPlugin() {\n const manifestRef: { current: Manifest | null; root: string } = { current: null, root: '' };\n return [\n svelte({\n compilerOptions: { css: 'external' },\n }),\n tesseraValidationPlugin(),\n tesseraEntryPlugin(),\n tesseraConfigPlugin(),\n tesseraPagesPlugin(),\n tesseraManifestPlugin(manifestRef),\n tesseraLayoutPlugin(),\n tesseraQuizPlugin(),\n tesseraAdapterPlugin(),\n tesseraXAPISetupPlugin(),\n tesseraFirstPagePreloadPlugin(manifestRef),\n tesseraExportPlugin(),\n ];\n}\n\n// ---------- Entry Plugin ----------\n\nconst VIRTUAL_ENTRY_ID = 'virtual:tessera-entry';\nconst RESOLVED_ENTRY_ID = '\\0' + VIRTUAL_ENTRY_ID;\nconst VIRTUAL_MAIN_ID = '/virtual:tessera-main';\nconst RESOLVED_MAIN_ID = '\\0virtual:tessera-main';\n\nfunction tesseraEntryPlugin(): Plugin {\n const runtimeDir = resolveRuntimeDir();\n const stylesDir = resolveStylesDir();\n const appSveltePath = resolve(runtimeDir, 'App.svelte');\n let projectRoot: string;\n let isBuild = false;\n\n return {\n name: 'tessera:entry',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n\n // For build mode: write index.html so Rollup can find it\n buildStart() {\n if (isBuild) {\n writeFileSync(resolve(projectRoot, 'index.html'), generateIndexHtml(), 'utf-8');\n }\n },\n\n // For build mode: clean up temporary index.html and copy assets\n closeBundle() {\n if (isBuild) {\n const htmlPath = resolve(projectRoot, 'index.html');\n if (existsSync(htmlPath)) {\n try { unlinkSync(htmlPath); } catch {}\n }\n\n // Copy assets/ directory to dist/assets/ so $assets/ references resolve\n const assetsDir = resolve(projectRoot, 'assets');\n const distAssetsDir = resolve(projectRoot, 'dist', 'assets');\n if (existsSync(assetsDir)) {\n mkdirSync(distAssetsDir, { recursive: true });\n cpSync(assetsDir, distAssetsDir, { recursive: true });\n }\n }\n },\n\n // Serve index.html for the dev server\n configureServer(server: ViteDevServer) {\n return () => {\n server.middlewares.use(async (req, res, next) => {\n if (req.url === '/' || req.url === '/index.html') {\n const html = generateIndexHtml();\n const transformed = await server.transformIndexHtml(req.url, html);\n res.setHeader('Content-Type', 'text/html');\n res.statusCode = 200;\n res.end(transformed);\n return;\n }\n next();\n });\n };\n },\n\n resolveId(id) {\n if (id === VIRTUAL_ENTRY_ID) return RESOLVED_ENTRY_ID;\n if (id === VIRTUAL_MAIN_ID || id === 'virtual:tessera-main') return RESOLVED_MAIN_ID;\n return null;\n },\n\n load(id) {\n if (id === RESOLVED_ENTRY_ID || id === RESOLVED_MAIN_ID) {\n return generateEntryScript(appSveltePath, stylesDir, projectRoot);\n }\n return null;\n },\n };\n}\n\nfunction generateIndexHtml(): string {\n return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Tessera Course</title>\n</head>\n<body>\n <div id=\"tessera-root\"></div>\n <script type=\"module\" src=\"/virtual:tessera-main\"></script>\n</body>\n</html>`;\n}\n\nfunction generateEntryScript(appSveltePath: string, frameworkStylesDir: string, projectRoot: string): string {\n const normalizedPath = appSveltePath.replace(/\\\\/g, '/');\n\n // Framework CSS imports (theme → base → layout)\n const frameworkCssOrder = ['theme.css', 'base.css', 'layout.css'];\n const frameworkImports = frameworkCssOrder\n .map(file => resolve(frameworkStylesDir, file).replace(/\\\\/g, '/'))\n .filter(path => existsSync(path))\n .map(path => `import '${path}';`)\n .join('\\n');\n\n // User CSS imports from project's styles/ directory\n const userStylesDir = resolve(projectRoot, 'styles');\n let userImports = '';\n if (existsSync(userStylesDir)) {\n const userCssFiles = readdirSync(userStylesDir)\n .filter(f => f.endsWith('.css'))\n .sort();\n userImports = userCssFiles\n .map(f => resolve(userStylesDir, f).replace(/\\\\/g, '/'))\n .map(path => `import '${path}';`)\n .join('\\n');\n }\n\n return `// Framework styles\n${frameworkImports}\n// User styles\n${userImports}\n\nimport { mount } from 'svelte';\nimport App from '${normalizedPath}';\n\nmount(App, {\n target: document.getElementById('tessera-root'),\n});\n`;\n}\n\n// ---------- Config Plugin ----------\n\nconst VIRTUAL_CONFIG_ID = 'virtual:tessera-config';\nconst RESOLVED_CONFIG_ID = '\\0' + VIRTUAL_CONFIG_ID;\n\nfunction completionDefaults(mode: string | undefined): {\n completion: Record<string, unknown>;\n passingScore: number;\n} {\n if (mode === 'manual') {\n return { completion: { mode: 'manual' }, passingScore: 0 };\n }\n return { completion: { mode: 'percentage', percentageThreshold: 100 }, passingScore: 70 };\n}\n\nfunction tesseraConfigPlugin(): Plugin {\n let projectRoot: string;\n\n return {\n name: 'tessera:config',\n enforce: 'pre',\n\n config(config) {\n const root = config.root || process.cwd();\n\n return {\n base: './',\n build: {\n assetsDir: 'tessera',\n },\n resolve: {\n alias: {\n '$assets': resolve(root, 'assets'),\n },\n },\n // tessera-learn ships .ts/.svelte.ts source; Vite's dep optimizer\n // doesn't run vite-plugin-svelte's preprocessor, so skip pre-bundling.\n optimizeDeps: {\n exclude: ['tessera-learn'],\n },\n };\n },\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n },\n\n resolveId(id) {\n if (id === VIRTUAL_CONFIG_ID) return RESOLVED_CONFIG_ID;\n return null;\n },\n\n load(id) {\n if (id === RESOLVED_CONFIG_ID) {\n const configPath = resolve(projectRoot, 'course.config.js');\n if (existsSync(configPath)) this.addWatchFile(configPath);\n const read = readCourseConfig(projectRoot);\n const userConfig: Record<string, any> = read.ok ? read.config : {};\n\n const { completion, passingScore } = completionDefaults(userConfig.completion?.mode);\n const merged = {\n title: userConfig.title || 'Untitled Course',\n ...userConfig,\n navigation: { mode: 'free', ...userConfig.navigation },\n completion: { ...completion, ...userConfig.completion },\n scoring: { passingScore, ...userConfig.scoring },\n export: { standard: 'web', ...userConfig.export },\n };\n\n return `export default ${JSON.stringify(merged)};`;\n }\n return null;\n },\n };\n}\n\n// ---------- Manifest Watch Helpers ----------\n\n/** Register all _meta.js and .svelte files under pagesDir as watch files for build mode. */\nfunction addWatchFiles(ctx: { addWatchFile(id: string): void }, dir: string): void {\n if (!existsSync(dir)) return;\n for (const entry of readdirSync(dir)) {\n const full = resolve(dir, entry);\n if (statSync(full).isDirectory()) {\n addWatchFiles(ctx, full);\n } else if (entry.endsWith('.svelte') || entry === '_meta.js') {\n ctx.addWatchFile(full);\n }\n }\n}\n\n// ---------- Pages Plugin ----------\n\nconst VIRTUAL_PAGES_ID = 'virtual:tessera-pages';\nconst RESOLVED_PAGES_ID = '\\0' + VIRTUAL_PAGES_ID;\n\n/**\n * Provides a virtual module that exports an import.meta.glob map for all .svelte\n * pages. This runs in the user's project context so the glob resolves against their\n * pages/ directory, and Vite can statically analyze it for code splitting.\n */\nfunction tesseraPagesPlugin(): Plugin {\n return {\n name: 'tessera:pages',\n enforce: 'pre',\n\n resolveId(id) {\n if (id === VIRTUAL_PAGES_ID) return RESOLVED_PAGES_ID;\n return null;\n },\n\n load(id) {\n if (id === RESOLVED_PAGES_ID) {\n return `export default import.meta.glob('/pages/**/*.svelte');`;\n }\n return null;\n },\n };\n}\n\n// ---------- Validation Plugin ----------\n\nfunction tesseraValidationPlugin(): Plugin {\n let projectRoot: string;\n let isBuild = false;\n\n return {\n name: 'tessera:validation',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n // Run validation during dev (configResolved fires before server starts)\n if (!isBuild) {\n runValidation(projectRoot);\n }\n },\n\n buildStart() {\n // Run validation during build (buildStart fires once before bundling)\n if (isBuild) {\n runValidation(projectRoot);\n }\n },\n };\n}\n\nfunction runValidation(projectRoot: string): void {\n const result = validateProject(projectRoot);\n reportValidationIssues(result);\n if (result.errors.length > 0) {\n throw new Error(\n `Tessera validation failed with ${result.errors.length} error(s). Fix the errors above to continue.`\n );\n }\n}\n\n// ---------- Export Plugin ----------\n\nfunction tesseraExportPlugin(): Plugin {\n let projectRoot: string;\n let isBuild = false;\n\n return {\n name: 'tessera:export',\n enforce: 'post',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n\n async closeBundle() {\n if (!isBuild) return;\n\n const read = readCourseConfig(projectRoot);\n if (!read.ok) {\n // Validation already required a parseable course.config.js — getting\n // here means it vanished or broke mid-build. Surface that loudly\n // rather than shipping a bundle with no LMS export silently.\n if (read.reason === 'missing') {\n throw new Error(\n '[tessera:export] course.config.js not found at closeBundle. The file must exist for the export step to run.'\n );\n }\n if (read.reason === 'no-export') {\n throw new Error(\n '[tessera:export] course.config.js: could not locate `export default { ... }`. Cannot determine export.standard.'\n );\n }\n throw new Error(\n `[tessera:export] course.config.js: failed to parse export-default object literal — ${(read.error as Error).message}`\n );\n }\n\n await runExport(projectRoot, read.config as Parameters<typeof runExport>[1]);\n },\n };\n}\n\n// ---------- Manifest Plugin ----------\n\nconst VIRTUAL_MANIFEST_ID = 'virtual:tessera-manifest';\nconst RESOLVED_MANIFEST_ID = '\\0' + VIRTUAL_MANIFEST_ID;\n\nfunction tesseraManifestPlugin(manifestRef: { current: Manifest | null; root: string }): Plugin {\n let projectRoot: string;\n let pagesDir: string;\n let server: ViteDevServer | null = null;\n\n function buildManifest(): Manifest {\n const m = generateManifest(pagesDir);\n manifestRef.current = m;\n return m;\n }\n\n return {\n name: 'tessera:manifest',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n pagesDir = resolve(projectRoot, 'pages');\n manifestRef.root = projectRoot;\n },\n\n configureServer(devServer: ViteDevServer) {\n server = devServer;\n\n // Watch the pages directory for changes\n devServer.watcher.on('all', (event, filePath) => {\n if (!filePath.startsWith(pagesDir)) return;\n\n // Rebuild manifest on relevant file changes\n const isRelevant =\n filePath.endsWith('.svelte') ||\n filePath.endsWith('_meta.js') ||\n event === 'addDir' ||\n event === 'unlinkDir';\n\n if (isRelevant) {\n manifestRef.current = null; // invalidate cache\n\n // Invalidate the virtual module to trigger HMR\n const mod = devServer.moduleGraph.getModuleById(RESOLVED_MANIFEST_ID);\n if (mod) {\n devServer.moduleGraph.invalidateModule(mod);\n devServer.ws.send({ type: 'full-reload' });\n }\n\n console.log(`[tessera] Manifest rebuilt (${event}: ${filePath.replace(projectRoot, '')})`);\n }\n });\n },\n\n buildStart() {\n buildManifest();\n },\n\n resolveId(id) {\n if (id === VIRTUAL_MANIFEST_ID) return RESOLVED_MANIFEST_ID;\n return null;\n },\n\n load(id) {\n if (id === RESOLVED_MANIFEST_ID) {\n if (!manifestRef.current) {\n buildManifest();\n }\n\n // Register watch files so Vite's built-in watcher (used in build --watch)\n // knows to re-trigger when pages/ content changes.\n addWatchFiles(this, pagesDir);\n\n // Encode as base64 to prevent Vite's import analysis from\n // scanning .svelte importPath strings as module imports.\n // Replace Infinity with 1e9 since JSON.stringify drops it.\n const json = JSON.stringify(manifestRef.current, (_key, value) =>\n value === Infinity ? 1e9 : value\n );\n const b64 = Buffer.from(json).toString('base64');\n return `export default JSON.parse(atob(\"${b64}\"));`;\n }\n return null;\n },\n };\n}\n\nconst VIRTUAL_ADAPTER_ID = 'virtual:tessera-adapter';\nconst RESOLVED_ADAPTER_ID = '\\0' + VIRTUAL_ADAPTER_ID;\n\nfunction tesseraAdapterPlugin(): Plugin {\n let projectRoot: string;\n let isBuild = false;\n\n return {\n name: 'tessera:adapter',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n\n resolveId(id) {\n if (id === VIRTUAL_ADAPTER_ID) return RESOLVED_ADAPTER_ID;\n return null;\n },\n\n load(id) {\n if (id !== RESOLVED_ADAPTER_ID) return null;\n\n // In dev, defer to the runtime selector so its WebAdapter fallback\n // for unreachable LMS APIs keeps working.\n if (!isBuild) {\n return `export { createAdapter } from 'tessera-learn/runtime/adapters/index.js';`;\n }\n\n let standard = 'web';\n const read = readCourseConfig(projectRoot);\n if (read.ok && typeof read.config.export?.standard === 'string') {\n standard = read.config.export.standard;\n }\n\n switch (standard) {\n case 'scorm12':\n return `\nimport { SCORM12Adapter } from 'tessera-learn/runtime/adapters/scorm12.js';\nimport { findSCORM12API } from 'tessera-learn/runtime/adapters/discovery.js';\nimport { LMSAdapterError } from 'tessera-learn/runtime/adapters/index.js';\nexport function createAdapter() {\n const api = findSCORM12API();\n if (!api) throw new LMSAdapterError('scorm12', 'Tessera: SCORM 1.2 API not found in window.parent/opener chain. Course must be launched from a SCORM 1.2 LMS.');\n return new SCORM12Adapter(api);\n}\n`;\n case 'scorm2004':\n return `\nimport { SCORM2004Adapter } from 'tessera-learn/runtime/adapters/scorm2004.js';\nimport { findSCORM2004API } from 'tessera-learn/runtime/adapters/discovery.js';\nimport { LMSAdapterError } from 'tessera-learn/runtime/adapters/index.js';\nexport function createAdapter() {\n const api = findSCORM2004API();\n if (!api) throw new LMSAdapterError('scorm2004', 'Tessera: SCORM 2004 API not found in window.parent/opener chain. Course must be launched from a SCORM 2004 LMS.');\n return new SCORM2004Adapter(api);\n}\n`;\n case 'cmi5':\n return `\nimport { CMI5Adapter } from 'tessera-learn/runtime/adapters/cmi5.js';\nimport { hasCMI5LaunchParams } from 'tessera-learn/runtime/adapters/discovery.js';\nimport { LMSAdapterError } from 'tessera-learn/runtime/adapters/index.js';\nexport function createAdapter() {\n if (!hasCMI5LaunchParams()) throw new LMSAdapterError('cmi5', 'Tessera: cmi5 launch parameters not present on URL. Course must be launched from a cmi5-compliant LMS.');\n return new CMI5Adapter();\n}\n`;\n default:\n return `\nimport { WebAdapter } from 'tessera-learn/runtime/adapters/web.js';\nexport function createAdapter(config) {\n return new WebAdapter(config);\n}\n`;\n }\n },\n };\n}\n\nconst VIRTUAL_XAPI_SETUP_ID = 'virtual:tessera-xapi-setup';\nconst RESOLVED_XAPI_SETUP_ID = '\\0' + VIRTUAL_XAPI_SETUP_ID;\n\nfunction tesseraXAPISetupPlugin(): Plugin {\n let projectRoot: string;\n let isBuild = false;\n\n return {\n name: 'tessera:xapi-setup',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n\n resolveId(id) {\n if (id === VIRTUAL_XAPI_SETUP_ID) return RESOLVED_XAPI_SETUP_ID;\n return null;\n },\n\n load(id) {\n if (id !== RESOLVED_XAPI_SETUP_ID) return null;\n\n if (!isBuild) {\n return `export { buildXAPIClient } from 'tessera-learn/runtime/xapi/setup.js';`;\n }\n\n let standard = 'web';\n let hasXapi = false;\n const read = readCourseConfig(projectRoot);\n if (read.ok) {\n if (typeof read.config.export?.standard === 'string') standard = read.config.export.standard;\n hasXapi = read.config.xapi != null;\n }\n\n // cmi5 needs the publisher regardless of explicit xapi config (cmi5\n // adapter shares the publisher queue for its own LMS-required statements).\n if (hasXapi || standard === 'cmi5') {\n return `export { buildXAPIClient } from 'tessera-learn/runtime/xapi/setup.js';`;\n }\n\n return `export async function buildXAPIClient() { return null; }`;\n },\n };\n}\n\nfunction tesseraFirstPagePreloadPlugin(manifestRef: { current: Manifest | null; root: string }): Plugin {\n return {\n name: 'tessera:first-page-preload',\n apply: 'build',\n transformIndexHtml: {\n order: 'post',\n handler(_html, ctx) {\n const firstPagePath = manifestRef.current?.pages[0]?.importPath;\n if (!firstPagePath || !ctx.bundle) return;\n const normalized = resolve(manifestRef.root, firstPagePath.replace(/^\\//, '')).replace(/\\\\/g, '/');\n const chunk = Object.values(ctx.bundle).find(\n (c): c is import('vite').Rollup.OutputChunk =>\n c.type === 'chunk' && !!c.facadeModuleId && c.facadeModuleId.replace(/\\\\/g, '/') === normalized\n );\n if (!chunk) return;\n return [{\n tag: 'link',\n attrs: { rel: 'modulepreload', href: `./${chunk.fileName}` },\n injectTo: 'head',\n }];\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAQA,SAAgB,QAAQ,MAAsB;CAC5C,OAAO,KACJ,aAAa,CACb,MAAM,CACN,QAAQ,aAAa,GAAG,CACxB,QAAQ,WAAW,IAAI,CACvB,QAAQ,OAAO,IAAI,CACnB,QAAQ,UAAU,GAAG;;;;ACK1B,SAAS,UAAU,KAAqB;CACtC,OAAO,IACJ,QAAQ,MAAM,QAAQ,CACtB,QAAQ,MAAM,OAAO,CACrB,QAAQ,MAAM,OAAO,CACrB,QAAQ,MAAM,SAAS,CACvB,QAAQ,MAAM,SAAS;;;;;AAM5B,SAAS,aAAa,KAAa,OAAe,IAAc;CAC9D,MAAM,QAAkB,EAAE;CAC1B,IAAI,CAAC,WAAW,IAAI,EAAE,OAAO;CAE7B,KAAK,MAAM,SAAS,YAAY,IAAI,EAAE;EACpC,MAAM,WAAW,QAAQ,KAAK,MAAM;EACpC,MAAM,UAAU,OAAO,GAAG,KAAK,GAAG,UAAU;EAC5C,IAAI,SAAS,SAAS,CAAC,aAAa,EAClC,MAAM,KAAK,GAAG,aAAa,UAAU,QAAQ,C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