tessera-learn 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +11 -11
- package/dist/{audit-BA5o0ick.js → audit-BNrvFHq_.js} +49 -22
- package/dist/{audit-BA5o0ick.js.map → audit-BNrvFHq_.js.map} +1 -1
- package/dist/{build-commands-C0OnV-Vg.js → build-commands-BWnATKat.js} +2 -2
- package/dist/{build-commands-C0OnV-Vg.js.map → build-commands-BWnATKat.js.map} +1 -1
- package/dist/{inline-config-CroQ-_2Y.js → inline-config-Dudu5r8w.js} +2 -2
- package/dist/{inline-config-CroQ-_2Y.js.map → inline-config-Dudu5r8w.js.map} +1 -1
- package/dist/plugin/cli.js +3 -3
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +2 -2
- package/dist/{plugin-W_rk3Pit.js → plugin-diNZaDJK.js} +2 -2
- package/dist/{plugin-W_rk3Pit.js.map → plugin-diNZaDJK.js.map} +1 -1
- package/package.json +1 -1
- package/src/plugin/a11y/audit.ts +74 -18
- package/src/runtime/App.svelte +20 -1
- package/src/virtual.d.ts +6 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveTesseraConfig } from "./inline-config-
|
|
1
|
+
import { resolveTesseraConfig } from "./inline-config-Dudu5r8w.js";
|
|
2
2
|
//#region src/plugin/build-commands.ts
|
|
3
3
|
async function runDev(projectRoot, workspaceRoot) {
|
|
4
4
|
const vite = await import("vite");
|
|
@@ -24,4 +24,4 @@ async function runBuild(projectRoot, workspaceRoot) {
|
|
|
24
24
|
//#endregion
|
|
25
25
|
export { runBuild, runDev };
|
|
26
26
|
|
|
27
|
-
//# sourceMappingURL=build-commands-
|
|
27
|
+
//# sourceMappingURL=build-commands-BWnATKat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-commands-
|
|
1
|
+
{"version":3,"file":"build-commands-BWnATKat.js","names":[],"sources":["../src/plugin/build-commands.ts"],"sourcesContent":["import { resolveTesseraConfig } from './inline-config.js';\n\nexport async function runDev(\n projectRoot: string,\n workspaceRoot: string,\n): Promise<number> {\n const vite = await import('vite');\n const config = await resolveTesseraConfig(projectRoot, workspaceRoot, {\n command: 'serve',\n mode: 'development',\n });\n const server = await vite.createServer(config);\n await server.listen();\n server.printUrls();\n server.bindCLIShortcuts({ print: true });\n // Never resolve: the CLI wrapper would process.exit and kill the server.\n return new Promise<number>(() => {});\n}\n\nexport async function runBuild(\n projectRoot: string,\n workspaceRoot: string,\n): Promise<number> {\n const vite = await import('vite');\n const config = await resolveTesseraConfig(projectRoot, workspaceRoot, {\n command: 'build',\n mode: 'production',\n });\n await vite.build(config);\n return 0;\n}\n"],"mappings":";;AAEA,eAAsB,OACpB,aACA,eACiB;CACjB,MAAM,OAAO,MAAM,OAAO;CAC1B,MAAM,SAAS,MAAM,qBAAqB,aAAa,eAAe;EACpE,SAAS;EACT,MAAM;CACR,CAAC;CACD,MAAM,SAAS,MAAM,KAAK,aAAa,MAAM;CAC7C,MAAM,OAAO,OAAO;CACpB,OAAO,UAAU;CACjB,OAAO,iBAAiB,EAAE,OAAO,KAAK,CAAC;CAEvC,OAAO,IAAI,cAAsB,CAAC,CAAC;AACrC;AAEA,eAAsB,SACpB,aACA,eACiB;CACjB,MAAM,OAAO,MAAM,OAAO;CAC1B,MAAM,SAAS,MAAM,qBAAqB,aAAa,eAAe;EACpE,SAAS;EACT,MAAM;CACR,CAAC;CACD,MAAM,KAAK,MAAM,MAAM;CACvB,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as tesseraPlugin } from "./plugin-
|
|
1
|
+
import { t as tesseraPlugin } from "./plugin-diNZaDJK.js";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
@@ -28,4 +28,4 @@ async function resolveTesseraConfig(projectRoot, workspaceRoot, env) {
|
|
|
28
28
|
//#endregion
|
|
29
29
|
export { resolveTesseraConfig };
|
|
30
30
|
|
|
31
|
-
//# sourceMappingURL=inline-config-
|
|
31
|
+
//# sourceMappingURL=inline-config-Dudu5r8w.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-config-
|
|
1
|
+
{"version":3,"file":"inline-config-Dudu5r8w.js","names":[],"sources":["../src/plugin/inline-config.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { ConfigEnv, InlineConfig } from 'vite';\nimport { tesseraPlugin } from './index.js';\n\n// Base Vite config for every Tessera command (dev, export, a11y build).\n// configFile:false disables Vite's own discovery — there is no vite.config.js —\n// and tesseraPlugin() supplies the Svelte compiler, so this is the full plugin set.\n//\n// $shared points at the workspace-level design system, which lives outside the\n// per-course Vite root, so it is wired here (where workspaceRoot is known) rather\n// than next to $assets in the plugin. server.fs.allow must list workspaceRoot or\n// the dev server's fs.strict gate refuses to serve $shared files.\nexport function buildInlineConfig(\n projectRoot: string,\n workspaceRoot: string,\n): InlineConfig {\n return {\n root: projectRoot,\n configFile: false,\n plugins: [tesseraPlugin()],\n resolve: { alias: { $shared: resolve(workspaceRoot, 'shared') } },\n server: { fs: { allow: [workspaceRoot] } },\n };\n}\n\n// Optional author-owned escape hatch, never scaffolded or reconciled. A *partial*\n// Vite config the caller merges on top of buildInlineConfig(), so tesseraPlugin()\n// stays wired in and the author only writes the delta.\nexport async function loadUserConfig(\n projectRoot: string,\n env: ConfigEnv,\n): Promise<InlineConfig | null> {\n const configPath = resolve(projectRoot, 'tessera.config.js');\n if (!existsSync(configPath)) return null;\n const mod = await import(pathToFileURL(configPath).href);\n const config = mod.default ?? mod;\n // mergeConfig throws on a function, so resolve Vite's callback form first.\n return (\n typeof config === 'function' ? await config(env) : config\n ) as InlineConfig;\n}\n\nexport async function resolveTesseraConfig(\n projectRoot: string,\n workspaceRoot: string,\n env: ConfigEnv,\n): Promise<InlineConfig> {\n const vite = await import('vite');\n const base = buildInlineConfig(projectRoot, workspaceRoot);\n const user = await loadUserConfig(projectRoot, env);\n return user ? vite.mergeConfig(base, user) : base;\n}\n"],"mappings":";;;;;AAcA,SAAgB,kBACd,aACA,eACc;CACd,OAAO;EACL,MAAM;EACN,YAAY;EACZ,SAAS,CAAC,cAAc,CAAC;EACzB,SAAS,EAAE,OAAO,EAAE,SAAS,QAAQ,eAAe,QAAQ,EAAE,EAAE;EAChE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,aAAa,EAAE,EAAE;CAC3C;AACF;AAKA,eAAsB,eACpB,aACA,KAC8B;CAC9B,MAAM,aAAa,QAAQ,aAAa,mBAAmB;CAC3D,IAAI,CAAC,WAAW,UAAU,GAAG,OAAO;CACpC,MAAM,MAAM,MAAM,OAAO,cAAc,UAAU,EAAE;CACnD,MAAM,SAAS,IAAI,WAAW;CAE9B,OACE,OAAO,WAAW,aAAa,MAAM,OAAO,GAAG,IAAI;AAEvD;AAEA,eAAsB,qBACpB,aACA,eACA,KACuB;CACvB,MAAM,OAAO,MAAM,OAAO;CAC1B,MAAM,OAAO,kBAAkB,aAAa,aAAa;CACzD,MAAM,OAAO,MAAM,eAAe,aAAa,GAAG;CAClD,OAAO,OAAO,KAAK,YAAY,MAAM,IAAI,IAAI;AAC/C"}
|
package/dist/plugin/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as validateProject, n as runAudit, r as resolvePackageRoot, s as reportValidationIssues } from "../audit-
|
|
2
|
+
import { c as validateProject, n as runAudit, r as resolvePackageRoot, s as reportValidationIssues } from "../audit-BNrvFHq_.js";
|
|
3
3
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
4
4
|
import { copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
//#region src/plugin/validate-cli.ts
|
|
@@ -294,11 +294,11 @@ async function main(argv, cwd = process.cwd()) {
|
|
|
294
294
|
const { courseRoot, workspaceRoot } = resolved;
|
|
295
295
|
switch (sub) {
|
|
296
296
|
case "dev": {
|
|
297
|
-
const { runDev } = await import("../build-commands-
|
|
297
|
+
const { runDev } = await import("../build-commands-BWnATKat.js");
|
|
298
298
|
return runDev(courseRoot, workspaceRoot);
|
|
299
299
|
}
|
|
300
300
|
case "export": {
|
|
301
|
-
const { runBuild } = await import("../build-commands-
|
|
301
|
+
const { runBuild } = await import("../build-commands-BWnATKat.js");
|
|
302
302
|
return runBuild(courseRoot, workspaceRoot);
|
|
303
303
|
}
|
|
304
304
|
case "validate": return runValidate(courseRoot);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugin/a11y/audit.ts","../../src/plugin/index.ts"],"mappings":";;;UAKiB,YAAA;;EAEf,SAAA,GAAY,WAAW;EAFI;EAI3B,OAAA;AAAA;AAAA,KAGU,WAAA;;;AAAW;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugin/a11y/audit.ts","../../src/plugin/index.ts"],"mappings":";;;UAKiB,YAAA;;EAEf,SAAA,GAAY,WAAW;EAFI;EAI3B,OAAA;AAAA;AAAA,KAGU,WAAA;;;AAAW;AAqHvB;;iBAAsB,QAAA,CACpB,WAAA,UACA,aAAA,UACA,OAAA,GAAS,YAAA,GACR,OAAO;;;iBCjBM,aAAA,KAAa,MAAA,QAAA,MAAA"}
|
package/dist/plugin/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as runAudit } from "../audit-
|
|
2
|
-
import { t as tesseraPlugin } from "../plugin-
|
|
1
|
+
import { n as runAudit } from "../audit-BNrvFHq_.js";
|
|
2
|
+
import { t as tesseraPlugin } from "../plugin-diNZaDJK.js";
|
|
3
3
|
export { runAudit, tesseraPlugin };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isPlausibleLanguageTag, c as validateProject, i as isIgnored, l as generateManifest, o as normalizeA11y, r as resolvePackageRoot, s as reportValidationIssues, t as AUDIT_ENV_FLAG, u as readCourseConfig } from "./audit-
|
|
1
|
+
import { a as isPlausibleLanguageTag, c as validateProject, i as isIgnored, l as generateManifest, o as normalizeA11y, r as resolvePackageRoot, s as reportValidationIssues, t as AUDIT_ENV_FLAG, u as readCourseConfig } from "./audit-BNrvFHq_.js";
|
|
2
2
|
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
3
3
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
4
4
|
import { cpSync, createWriteStream, existsSync, mkdirSync, readdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -728,4 +728,4 @@ function tesseraFirstPagePreloadPlugin(manifestRef) {
|
|
|
728
728
|
//#endregion
|
|
729
729
|
export { tesseraPlugin as t };
|
|
730
730
|
|
|
731
|
-
//# sourceMappingURL=plugin-
|
|
731
|
+
//# sourceMappingURL=plugin-diNZaDJK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-W_rk3Pit.js","names":[],"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 {\n existsSync,\n readdirSync,\n statSync,\n writeFileSync,\n unlinkSync,\n} 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 void 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 {\n unlinkSync(resolve(projectRoot, f));\n } 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 {\n manifestFile: string;\n label: string;\n generate: (config: ExportConfig, distDir: string) => string;\n }\n> = {\n scorm12: {\n manifestFile: 'imsmanifest.xml',\n label: 'SCORM 1.2',\n generate: generateSCORM12Manifest,\n },\n scorm2004: {\n manifestFile: 'imsmanifest.xml',\n label: 'SCORM 2004',\n generate: generateSCORM2004Manifest,\n },\n cmi5: {\n manifestFile: 'cmi5.xml',\n label: 'CMI5',\n generate: (config) => generateCMI5Xml(config),\n },\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(\n resolve(distDir, spec.manifestFile),\n spec.generate(config, distDir),\n 'utf-8',\n );\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 } from 'node:path';\nimport { createOverridePlugin } from './override-plugin.js';\nimport { resolvePackageRoot } from './package-root.js';\n\nexport function tesseraQuizPlugin(): Plugin {\n const builtinQuiz = resolve(\n resolvePackageRoot(),\n 'src',\n 'components',\n 'Quiz.svelte',\n );\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 { resolve, relative, isAbsolute } from 'node:path';\nimport {\n existsSync,\n readdirSync,\n statSync,\n writeFileSync,\n unlinkSync,\n cpSync,\n mkdirSync,\n} from 'node:fs';\nimport { generateManifest, readCourseConfig } from './manifest.js';\nimport type { Manifest } from './manifest.js';\nimport type { CourseConfig } from '../runtime/types.js';\nimport {\n DEFAULT_PASSING_SCORE,\n DEFAULT_PERCENTAGE_THRESHOLD,\n} from '../runtime/defaults.js';\nimport {\n validateProject,\n reportValidationIssues,\n normalizeA11y,\n isPlausibleLanguageTag,\n isIgnored,\n type A11ySettings,\n} from './validation.js';\nimport { runExport } from './export.js';\nimport { tesseraLayoutPlugin } from './layout.js';\nimport { tesseraQuizPlugin } from './quiz.js';\nimport { resolvePackageRoot } from './package-root.js';\n\nimport { AUDIT_ENV_FLAG } from './a11y/audit.js';\n\nexport { runAudit } from './a11y/audit.js';\nexport type { AuditOptions, ImpactLevel } from './a11y/audit.js';\n\nfunction isAuditBuild(): boolean {\n return process.env[AUDIT_ENV_FLAG] === '1';\n}\n\n// Resolve the runtime directory where App.svelte lives\nfunction resolveRuntimeDir(): string {\n return resolve(resolvePackageRoot(), 'src', 'runtime');\n}\n\n// Resolve the framework styles directory\nfunction resolveStylesDir(): string {\n return resolve(resolvePackageRoot(), 'styles');\n}\n\n// Tier-1a state shared between the svelte() onwarn handler and the sibling\n// gate plugin. onwarn fires during transform (after the Tier-1b buildStart\n// gate), so a11y warnings are collected here and flushed/gated at buildEnd.\ninterface A11yCompilerState {\n warnings: string[];\n projectRoot: string;\n isBuild: boolean;\n settings: A11ySettings;\n}\n\n// Svelte's onwarn filename is relative to the vite root (e.g. `pages/x.svelte`)\n// in build and may be absolute or a virtual id elsewhere. Return the\n// project-relative path for a real author file, or null to skip framework /\n// node_modules / virtual modules — Tier 0 owns the framework's own warnings.\nfunction projectFileRel(\n filename: string | undefined,\n projectRoot: string,\n): string | null {\n if (!filename || !projectRoot) return null;\n if (\n filename.startsWith('\\0') ||\n filename.includes('virtual:') ||\n filename.includes('node_modules')\n ) {\n return null;\n }\n const abs = isAbsolute(filename) ? filename : resolve(projectRoot, filename);\n const rel = relative(projectRoot, abs);\n if (rel.startsWith('..') || isAbsolute(rel) || rel.includes('node_modules')) {\n return null;\n }\n return rel;\n}\n\ntype VirtualLoadCtx = { projectRoot: string; isBuild: boolean };\n\nfunction virtualModule(\n name: string,\n virtualId: string,\n load: (\n this: import('vite').Rollup.PluginContext,\n ctx: VirtualLoadCtx,\n ) => string | null,\n): Plugin {\n const resolvedId = '\\0' + virtualId;\n let projectRoot = '';\n let isBuild = false;\n return {\n name,\n enforce: 'pre',\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n resolveId(id) {\n return id === virtualId ? resolvedId : null;\n },\n load(id) {\n return id === resolvedId\n ? load.call(this, { projectRoot, isBuild })\n : null;\n },\n };\n}\n\nexport function tesseraPlugin() {\n const manifestRef: { current: Manifest | null; root: string } = {\n current: null,\n root: '',\n };\n const a11y: A11yCompilerState = {\n warnings: [],\n projectRoot: '',\n isBuild: false,\n settings: normalizeA11y(undefined),\n };\n return [\n svelte({\n compilerOptions: { css: 'external' },\n onwarn(warning, defaultHandler) {\n if (warning.code?.startsWith('a11y')) {\n const rel = projectFileRel(warning.filename, a11y.projectRoot);\n if (rel !== null) {\n const msg = `[${warning.code}] ${rel}: ${warning.message}`;\n if (a11y.isBuild) {\n a11y.warnings.push(msg);\n } else if (!a11y.settings.ignore.includes(warning.code)) {\n reportValidationIssues({ errors: [], warnings: [msg] });\n }\n }\n return; // suppress the raw Vite print; we re-emit via the reporter\n }\n defaultHandler?.(warning);\n },\n }),\n tesseraA11yCompilerPlugin(a11y),\n tesseraValidationPlugin(),\n tesseraEntryPlugin(),\n tesseraConfigDefaultsPlugin(),\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 outDir: 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 outDir = resolve(config.root, config.build.outDir);\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(\n resolve(projectRoot, 'index.html'),\n generateIndexHtml(readLanguage(projectRoot)),\n 'utf-8',\n );\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 {\n unlinkSync(htmlPath);\n } catch {}\n }\n\n // Copy assets/ into the build's assets/ so $assets/ references resolve\n const assetsDir = resolve(projectRoot, 'assets');\n const distAssetsDir = resolve(outDir, '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(readLanguage(projectRoot));\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')\n 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\n// 'en' fallback applied here: the config default-merge runs later than buildStart.\n// Only a validated BCP-47 tag is interpolated into <html lang>, so a malformed\n// value (caught separately as a warning) can't ship a broken attribute.\nfunction readLanguage(projectRoot: string): string {\n const read = readCourseConfig(projectRoot);\n const lang = read.ok ? read.config.language : undefined;\n return isPlausibleLanguageTag(lang) ? lang : 'en';\n}\n\nfunction generateIndexHtml(lang: string): string {\n return `<!DOCTYPE html>\n<html lang=\"${lang}\">\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(\n appSveltePath: string,\n frameworkStylesDir: string,\n projectRoot: string,\n): 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';\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 {\n completion: {\n mode: 'percentage',\n percentageThreshold: DEFAULT_PERCENTAGE_THRESHOLD,\n },\n passingScore: DEFAULT_PASSING_SCORE,\n };\n}\n\nfunction tesseraConfigDefaultsPlugin(): Plugin {\n return {\n name: 'tessera:config-defaults',\n enforce: 'pre',\n config(config) {\n const root = config.root || process.cwd();\n return {\n base: './',\n build: { assetsDir: 'tessera' },\n resolve: { alias: { $assets: resolve(root, 'assets') } },\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: { exclude: ['tessera-learn'] },\n };\n },\n };\n}\n\nfunction tesseraConfigPlugin(): Plugin {\n return virtualModule(\n 'tessera:config',\n VIRTUAL_CONFIG_ID,\n function ({ projectRoot }) {\n const configPath = resolve(projectRoot, 'course.config.js');\n if (existsSync(configPath)) this.addWatchFile(configPath);\n const read = readCourseConfig(projectRoot);\n const userConfig: Partial<CourseConfig> = read.ok ? read.config : {};\n const { completion, passingScore } = completionDefaults(\n userConfig.completion?.mode,\n );\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 return `export default ${JSON.stringify(merged)};`;\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(\n ctx: { addWatchFile(id: string): void },\n dir: string,\n): 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';\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 virtualModule('tessera:pages', VIRTUAL_PAGES_ID, () => {\n return `export default import.meta.glob('/pages/**/*.svelte');`;\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\n// Tier 1a: flush + gate the Svelte compiler's a11y warnings at buildEnd, after\n// every module is transformed. svelte() accepts `onwarn` but not arbitrary\n// Rollup hooks, so the gate lives here and shares the onwarn closure.\nfunction tesseraA11yCompilerPlugin(a11y: A11yCompilerState): Plugin {\n return {\n name: 'tessera:a11y-compiler',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n a11y.projectRoot = config.root;\n a11y.isBuild = config.command === 'build';\n const read = readCourseConfig(config.root);\n a11y.settings = normalizeA11y(read.ok ? read.config.a11y : undefined);\n },\n\n buildEnd() {\n if (!a11y.isBuild || a11y.warnings.length === 0) return;\n const ignored = new Set(a11y.settings.ignore);\n const warnings = a11y.warnings.filter((msg) => !isIgnored(msg, ignored));\n a11y.warnings = [];\n if (warnings.length === 0) return;\n if (a11y.settings.level === 'error') {\n reportValidationIssues({ errors: warnings, warnings: [] });\n throw new Error(\n `Tessera: ${warnings.length} a11y issue(s) with a11y.level: 'error'. Fix the errors above to continue.`,\n );\n }\n reportValidationIssues({ errors: [], warnings });\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 if (isAuditBuild()) 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(\n projectRoot,\n read.config as Parameters<typeof runExport>[1],\n );\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: {\n current: Manifest | null;\n root: string;\n}): Plugin {\n let projectRoot: string;\n let pagesDir: string;\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 // 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(\n `[tessera] Manifest rebuilt (${event}: ${filePath.replace(projectRoot, '')})`,\n );\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';\n\nfunction tesseraAdapterPlugin(): Plugin {\n return virtualModule(\n 'tessera:adapter',\n VIRTUAL_ADAPTER_ID,\n ({ projectRoot, isBuild }) => {\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 // The audit renders headless with no LMS in the frame chain; the SCORM/\n // cmi5 adapters throw when their API is absent, so render with WebAdapter.\n if (isAuditBuild()) standard = 'web';\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';\n\nfunction tesseraXAPISetupPlugin(): Plugin {\n return virtualModule(\n 'tessera:xapi-setup',\n VIRTUAL_XAPI_SETUP_ID,\n ({ projectRoot, isBuild }) => {\n if (!isBuild) {\n return `export { buildXAPIClient } from 'tessera-learn/runtime/xapi/setup.js';`;\n }\n\n // The audit runs offline — don't wire real LRS destinations into it.\n if (isAuditBuild()) {\n return `export async function buildXAPIClient() { return null; }`;\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')\n 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: {\n current: Manifest | null;\n root: string;\n}): 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(\n manifestRef.root,\n firstPagePath.replace(/^\\//, ''),\n ).replace(/\\\\/g, '/');\n const chunk = Object.values(ctx.bundle).find(\n (c): c is import('vite').Rollup.OutputChunk =>\n c.type === 'chunk' &&\n !!c.facadeModuleId &&\n c.facadeModuleId.replace(/\\\\/g, '/') === normalized,\n );\n if (!chunk) return;\n return [\n {\n tag: 'link',\n attrs: { rel: 'modulepreload', href: `./${chunk.fileName}` },\n injectTo: 'head',\n },\n ];\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAQA,SAAgB,QAAQ,MAAsB;CAC5C,OAAO,KACJ,YAAY,EACZ,KAAK,EACL,QAAQ,aAAa,EAAE,EACvB,QAAQ,WAAW,GAAG,EACtB,QAAQ,OAAO,GAAG,EAClB,QAAQ,UAAU,EAAE;AACzB;;;ACUA,SAAS,UAAU,KAAqB;CACtC,OAAO,IACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,QAAQ;AAC3B;;;;AAKA,SAAS,aAAa,KAAa,OA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K,OAAO,QAAQ;EAChC;EAIA,IAAI,WAAW,aAAa,QAC1B,OAAO;EAGT,OAAO;CACT,CACF;AACF;AAEA,SAAS,8BAA8B,aAG5B;CACT,OAAO;EACL,MAAM;EACN,OAAO;EACP,oBAAoB;GAClB,OAAO;GACP,QAAQ,OAAO,KAAK;IAClB,MAAM,gBAAgB,YAAY,SAAS,MAAM,IAAI;IACrD,IAAI,CAAC,iBAAiB,CAAC,IAAI,QAAQ;IACnC,MAAM,aAAa,QACjB,YAAY,MACZ,cAAc,QAAQ,OAAO,EAAE,CACjC,EAAE,QAAQ,OAAO,GAAG;IACpB,MAAM,QAAQ,OAAO,OAAO,IAAI,MAAM,EAAE,MACrC,MACC,EAAE,SAAS,WACX,CAAC,CAAC,EAAE,kBACJ,EAAE,eAAe,QAAQ,OAAO,GAAG,MAAM,UAC7C;IACA,IAAI,CAAC,OAAO;IACZ,OAAO,CACL;KACE,KAAK;KACL,OAAO;MAAE,KAAK;MAAiB,MAAM,KAAK,MAAM;KAAW;KAC3D,UAAU;IACZ,CACF;GACF;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"plugin-diNZaDJK.js","names":[],"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 {\n existsSync,\n readdirSync,\n statSync,\n writeFileSync,\n unlinkSync,\n} 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 void 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 {\n unlinkSync(resolve(projectRoot, f));\n } 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 {\n manifestFile: string;\n label: string;\n generate: (config: ExportConfig, distDir: string) => string;\n }\n> = {\n scorm12: {\n manifestFile: 'imsmanifest.xml',\n label: 'SCORM 1.2',\n generate: generateSCORM12Manifest,\n },\n scorm2004: {\n manifestFile: 'imsmanifest.xml',\n label: 'SCORM 2004',\n generate: generateSCORM2004Manifest,\n },\n cmi5: {\n manifestFile: 'cmi5.xml',\n label: 'CMI5',\n generate: (config) => generateCMI5Xml(config),\n },\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(\n resolve(distDir, spec.manifestFile),\n spec.generate(config, distDir),\n 'utf-8',\n );\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 } from 'node:path';\nimport { createOverridePlugin } from './override-plugin.js';\nimport { resolvePackageRoot } from './package-root.js';\n\nexport function tesseraQuizPlugin(): Plugin {\n const builtinQuiz = resolve(\n resolvePackageRoot(),\n 'src',\n 'components',\n 'Quiz.svelte',\n );\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 { resolve, relative, isAbsolute } from 'node:path';\nimport {\n existsSync,\n readdirSync,\n statSync,\n writeFileSync,\n unlinkSync,\n cpSync,\n mkdirSync,\n} from 'node:fs';\nimport { generateManifest, readCourseConfig } from './manifest.js';\nimport type { Manifest } from './manifest.js';\nimport type { CourseConfig } from '../runtime/types.js';\nimport {\n DEFAULT_PASSING_SCORE,\n DEFAULT_PERCENTAGE_THRESHOLD,\n} from '../runtime/defaults.js';\nimport {\n validateProject,\n reportValidationIssues,\n normalizeA11y,\n isPlausibleLanguageTag,\n isIgnored,\n type A11ySettings,\n} from './validation.js';\nimport { runExport } from './export.js';\nimport { tesseraLayoutPlugin } from './layout.js';\nimport { tesseraQuizPlugin } from './quiz.js';\nimport { resolvePackageRoot } from './package-root.js';\n\nimport { AUDIT_ENV_FLAG } from './a11y/audit.js';\n\nexport { runAudit } from './a11y/audit.js';\nexport type { AuditOptions, ImpactLevel } from './a11y/audit.js';\n\nfunction isAuditBuild(): boolean {\n return process.env[AUDIT_ENV_FLAG] === '1';\n}\n\n// Resolve the runtime directory where App.svelte lives\nfunction resolveRuntimeDir(): string {\n return resolve(resolvePackageRoot(), 'src', 'runtime');\n}\n\n// Resolve the framework styles directory\nfunction resolveStylesDir(): string {\n return resolve(resolvePackageRoot(), 'styles');\n}\n\n// Tier-1a state shared between the svelte() onwarn handler and the sibling\n// gate plugin. onwarn fires during transform (after the Tier-1b buildStart\n// gate), so a11y warnings are collected here and flushed/gated at buildEnd.\ninterface A11yCompilerState {\n warnings: string[];\n projectRoot: string;\n isBuild: boolean;\n settings: A11ySettings;\n}\n\n// Svelte's onwarn filename is relative to the vite root (e.g. `pages/x.svelte`)\n// in build and may be absolute or a virtual id elsewhere. Return the\n// project-relative path for a real author file, or null to skip framework /\n// node_modules / virtual modules — Tier 0 owns the framework's own warnings.\nfunction projectFileRel(\n filename: string | undefined,\n projectRoot: string,\n): string | null {\n if (!filename || !projectRoot) return null;\n if (\n filename.startsWith('\\0') ||\n filename.includes('virtual:') ||\n filename.includes('node_modules')\n ) {\n return null;\n }\n const abs = isAbsolute(filename) ? filename : resolve(projectRoot, filename);\n const rel = relative(projectRoot, abs);\n if (rel.startsWith('..') || isAbsolute(rel) || rel.includes('node_modules')) {\n return null;\n }\n return rel;\n}\n\ntype VirtualLoadCtx = { projectRoot: string; isBuild: boolean };\n\nfunction virtualModule(\n name: string,\n virtualId: string,\n load: (\n this: import('vite').Rollup.PluginContext,\n ctx: VirtualLoadCtx,\n ) => string | null,\n): Plugin {\n const resolvedId = '\\0' + virtualId;\n let projectRoot = '';\n let isBuild = false;\n return {\n name,\n enforce: 'pre',\n configResolved(config: ResolvedConfig) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n resolveId(id) {\n return id === virtualId ? resolvedId : null;\n },\n load(id) {\n return id === resolvedId\n ? load.call(this, { projectRoot, isBuild })\n : null;\n },\n };\n}\n\nexport function tesseraPlugin() {\n const manifestRef: { current: Manifest | null; root: string } = {\n current: null,\n root: '',\n };\n const a11y: A11yCompilerState = {\n warnings: [],\n projectRoot: '',\n isBuild: false,\n settings: normalizeA11y(undefined),\n };\n return [\n svelte({\n compilerOptions: { css: 'external' },\n onwarn(warning, defaultHandler) {\n if (warning.code?.startsWith('a11y')) {\n const rel = projectFileRel(warning.filename, a11y.projectRoot);\n if (rel !== null) {\n const msg = `[${warning.code}] ${rel}: ${warning.message}`;\n if (a11y.isBuild) {\n a11y.warnings.push(msg);\n } else if (!a11y.settings.ignore.includes(warning.code)) {\n reportValidationIssues({ errors: [], warnings: [msg] });\n }\n }\n return; // suppress the raw Vite print; we re-emit via the reporter\n }\n defaultHandler?.(warning);\n },\n }),\n tesseraA11yCompilerPlugin(a11y),\n tesseraValidationPlugin(),\n tesseraEntryPlugin(),\n tesseraConfigDefaultsPlugin(),\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 outDir: 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 outDir = resolve(config.root, config.build.outDir);\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(\n resolve(projectRoot, 'index.html'),\n generateIndexHtml(readLanguage(projectRoot)),\n 'utf-8',\n );\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 {\n unlinkSync(htmlPath);\n } catch {}\n }\n\n // Copy assets/ into the build's assets/ so $assets/ references resolve\n const assetsDir = resolve(projectRoot, 'assets');\n const distAssetsDir = resolve(outDir, '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(readLanguage(projectRoot));\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')\n 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\n// 'en' fallback applied here: the config default-merge runs later than buildStart.\n// Only a validated BCP-47 tag is interpolated into <html lang>, so a malformed\n// value (caught separately as a warning) can't ship a broken attribute.\nfunction readLanguage(projectRoot: string): string {\n const read = readCourseConfig(projectRoot);\n const lang = read.ok ? read.config.language : undefined;\n return isPlausibleLanguageTag(lang) ? lang : 'en';\n}\n\nfunction generateIndexHtml(lang: string): string {\n return `<!DOCTYPE html>\n<html lang=\"${lang}\">\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(\n appSveltePath: string,\n frameworkStylesDir: string,\n projectRoot: string,\n): 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';\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 {\n completion: {\n mode: 'percentage',\n percentageThreshold: DEFAULT_PERCENTAGE_THRESHOLD,\n },\n passingScore: DEFAULT_PASSING_SCORE,\n };\n}\n\nfunction tesseraConfigDefaultsPlugin(): Plugin {\n return {\n name: 'tessera:config-defaults',\n enforce: 'pre',\n config(config) {\n const root = config.root || process.cwd();\n return {\n base: './',\n build: { assetsDir: 'tessera' },\n resolve: { alias: { $assets: resolve(root, 'assets') } },\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: { exclude: ['tessera-learn'] },\n };\n },\n };\n}\n\nfunction tesseraConfigPlugin(): Plugin {\n return virtualModule(\n 'tessera:config',\n VIRTUAL_CONFIG_ID,\n function ({ projectRoot }) {\n const configPath = resolve(projectRoot, 'course.config.js');\n if (existsSync(configPath)) this.addWatchFile(configPath);\n const read = readCourseConfig(projectRoot);\n const userConfig: Partial<CourseConfig> = read.ok ? read.config : {};\n const { completion, passingScore } = completionDefaults(\n userConfig.completion?.mode,\n );\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 return `export default ${JSON.stringify(merged)};`;\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(\n ctx: { addWatchFile(id: string): void },\n dir: string,\n): 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';\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 virtualModule('tessera:pages', VIRTUAL_PAGES_ID, () => {\n return `export default import.meta.glob('/pages/**/*.svelte');`;\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\n// Tier 1a: flush + gate the Svelte compiler's a11y warnings at buildEnd, after\n// every module is transformed. svelte() accepts `onwarn` but not arbitrary\n// Rollup hooks, so the gate lives here and shares the onwarn closure.\nfunction tesseraA11yCompilerPlugin(a11y: A11yCompilerState): Plugin {\n return {\n name: 'tessera:a11y-compiler',\n enforce: 'pre',\n\n configResolved(config: ResolvedConfig) {\n a11y.projectRoot = config.root;\n a11y.isBuild = config.command === 'build';\n const read = readCourseConfig(config.root);\n a11y.settings = normalizeA11y(read.ok ? read.config.a11y : undefined);\n },\n\n buildEnd() {\n if (!a11y.isBuild || a11y.warnings.length === 0) return;\n const ignored = new Set(a11y.settings.ignore);\n const warnings = a11y.warnings.filter((msg) => !isIgnored(msg, ignored));\n a11y.warnings = [];\n if (warnings.length === 0) return;\n if (a11y.settings.level === 'error') {\n reportValidationIssues({ errors: warnings, warnings: [] });\n throw new Error(\n `Tessera: ${warnings.length} a11y issue(s) with a11y.level: 'error'. Fix the errors above to continue.`,\n );\n }\n reportValidationIssues({ errors: [], warnings });\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 if (isAuditBuild()) 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(\n projectRoot,\n read.config as Parameters<typeof runExport>[1],\n );\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: {\n current: Manifest | null;\n root: string;\n}): Plugin {\n let projectRoot: string;\n let pagesDir: string;\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 // 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(\n `[tessera] Manifest rebuilt (${event}: ${filePath.replace(projectRoot, '')})`,\n );\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';\n\nfunction tesseraAdapterPlugin(): Plugin {\n return virtualModule(\n 'tessera:adapter',\n VIRTUAL_ADAPTER_ID,\n ({ projectRoot, isBuild }) => {\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 // The audit renders headless with no LMS in the frame chain; the SCORM/\n // cmi5 adapters throw when their API is absent, so render with WebAdapter.\n if (isAuditBuild()) standard = 'web';\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';\n\nfunction tesseraXAPISetupPlugin(): Plugin {\n return virtualModule(\n 'tessera:xapi-setup',\n VIRTUAL_XAPI_SETUP_ID,\n ({ projectRoot, isBuild }) => {\n if (!isBuild) {\n return `export { buildXAPIClient } from 'tessera-learn/runtime/xapi/setup.js';`;\n }\n\n // The audit runs offline — don't wire real LRS destinations into it.\n if (isAuditBuild()) {\n return `export async function buildXAPIClient() { return null; }`;\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')\n 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: {\n current: Manifest | null;\n root: string;\n}): 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(\n manifestRef.root,\n firstPagePath.replace(/^\\//, ''),\n ).replace(/\\\\/g, '/');\n const chunk = Object.values(ctx.bundle).find(\n (c): c is import('vite').Rollup.OutputChunk =>\n c.type === 'chunk' &&\n !!c.facadeModuleId &&\n c.facadeModuleId.replace(/\\\\/g, '/') === normalized,\n );\n if (!chunk) return;\n return [\n {\n tag: 'link',\n attrs: { rel: 'modulepreload', href: `./${chunk.fileName}` },\n injectTo: 'head',\n },\n ];\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAQA,SAAgB,QAAQ,MAAsB;CAC5C,OAAO,KACJ,YAAY,EACZ,KAAK,EACL,QAAQ,aAAa,EAAE,EACvB,QAAQ,WAAW,GAAG,EACtB,QAAQ,OAAO,GAAG,EAClB,QAAQ,UAAU,EAAE;AACzB;;;ACUA,SAAS,UAAU,KAAqB;CACtC,OAAO,IACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,QAAQ;AAC3B;;;;AAKA,SAAS,aAA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,UAAU,KAAK,OAAO,QAAQ;EAChC;EAIA,IAAI,WAAW,aAAa,QAC1B,OAAO;EAGT,OAAO;CACT,CACF;AACF;AAEA,SAAS,8BAA8B,aAG5B;CACT,OAAO;EACL,MAAM;EACN,OAAO;EACP,oBAAoB;GAClB,OAAO;GACP,QAAQ,OAAO,KAAK;IAClB,MAAM,gBAAgB,YAAY,SAAS,MAAM,IAAI;IACrD,IAAI,CAAC,iBAAiB,CAAC,IAAI,QAAQ;IACnC,MAAM,aAAa,QACjB,YAAY,MACZ,cAAc,QAAQ,OAAO,EAAE,CACjC,EAAE,QAAQ,OAAO,GAAG;IACpB,MAAM,QAAQ,OAAO,OAAO,IAAI,MAAM,EAAE,MACrC,MACC,EAAE,SAAS,WACX,CAAC,CAAC,EAAE,kBACJ,EAAE,eAAe,QAAQ,OAAO,GAAG,MAAM,UAC7C;IACA,IAAI,CAAC,OAAO;IACZ,OAAO,CACL;KACE,KAAK;KACL,OAAO;MAAE,KAAK;MAAiB,MAAM,KAAK,MAAM;KAAW;KAC3D,UAAU;IACZ,CACF;GACF;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tessera-learn",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "LMS tracking runtime for interactive learning content. One adapter layer (SCORM 1.2, SCORM 2004 4th Edition, cmi5, static Web), your choice of components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelte",
|
package/src/plugin/a11y/audit.ts
CHANGED
|
@@ -35,12 +35,16 @@ interface PageAuditResult {
|
|
|
35
35
|
index: number;
|
|
36
36
|
title: string;
|
|
37
37
|
violations: AxeViolation[];
|
|
38
|
+
loadFailed?: boolean;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
interface AuditReport {
|
|
41
42
|
standard: A11ySettings['standard'];
|
|
42
43
|
threshold: ImpactLevel;
|
|
43
44
|
pages: PageAuditResult[];
|
|
45
|
+
pagesAudited: number;
|
|
46
|
+
totalPages: number;
|
|
47
|
+
pagesFailedToLoad: number;
|
|
44
48
|
totalViolations: number;
|
|
45
49
|
failingViolations: number;
|
|
46
50
|
passed: boolean;
|
|
@@ -236,29 +240,51 @@ export async function runAudit(
|
|
|
236
240
|
}));
|
|
237
241
|
};
|
|
238
242
|
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
243
|
+
const recordPage = async (
|
|
244
|
+
index: number,
|
|
245
|
+
title: string,
|
|
246
|
+
): Promise<PageAuditResult> => {
|
|
247
|
+
const loadFailed = await page.evaluate(
|
|
248
|
+
() =>
|
|
249
|
+
document.getElementById('tessera-app')?.dataset.tesseraPageError ===
|
|
250
|
+
'true',
|
|
251
|
+
);
|
|
252
|
+
if (loadFailed) return { index, title, violations: [], loadFailed };
|
|
253
|
+
return { index, title, violations: await scan() };
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const totalPages = manifest.pages.length;
|
|
257
|
+
const hasAuditHook = await page.evaluate(
|
|
258
|
+
() => typeof window.__tesseraAudit?.goToIndex === 'function',
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
if (!hasAuditHook) {
|
|
262
|
+
// No navigation hook — audit the entry only, but flag the reduced scope
|
|
263
|
+
// rather than passing it off as full coverage.
|
|
264
|
+
if (totalPages > 1) {
|
|
265
|
+
console.warn(
|
|
266
|
+
`\x1b[33m[tessera a11y]\x1b[0m Could not enumerate pages; auditing the entry page only ` +
|
|
267
|
+
`(1 of ${totalPages}). The report records the reduced scope.`,
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
pages.push(await recordPage(0, manifest.pages[0]?.title ?? '(entry)'));
|
|
247
271
|
} else {
|
|
248
|
-
for (let i = 0; i <
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
272
|
+
for (let i = 0; i < totalPages; i++) {
|
|
273
|
+
await page.evaluate(
|
|
274
|
+
(idx: number) => window.__tesseraAudit!.goToIndex(idx),
|
|
275
|
+
i,
|
|
276
|
+
);
|
|
252
277
|
await page.waitForFunction(
|
|
253
278
|
(idx: number) =>
|
|
254
|
-
document
|
|
255
|
-
.
|
|
256
|
-
[idx]?.getAttribute('aria-current') === 'page',
|
|
279
|
+
document.getElementById('tessera-app')?.dataset
|
|
280
|
+
.tesseraPageIndex === String(idx),
|
|
257
281
|
i,
|
|
258
282
|
{ timeout: 20_000 },
|
|
259
283
|
);
|
|
260
284
|
await page.waitForLoadState('networkidle');
|
|
261
|
-
pages.push(
|
|
285
|
+
pages.push(
|
|
286
|
+
await recordPage(i, manifest.pages[i]?.title ?? `Page ${i + 1}`),
|
|
287
|
+
);
|
|
262
288
|
}
|
|
263
289
|
}
|
|
264
290
|
} finally {
|
|
@@ -268,7 +294,9 @@ export async function runAudit(
|
|
|
268
294
|
const thresholdRank = IMPACT_RANK[threshold];
|
|
269
295
|
let totalViolations = 0;
|
|
270
296
|
let failingViolations = 0;
|
|
297
|
+
let pagesFailedToLoad = 0;
|
|
271
298
|
for (const p of pages) {
|
|
299
|
+
if (p.loadFailed) pagesFailedToLoad++;
|
|
272
300
|
for (const v of p.violations) {
|
|
273
301
|
totalViolations++;
|
|
274
302
|
if (isFailing(v, thresholdRank)) failingViolations++;
|
|
@@ -279,9 +307,12 @@ export async function runAudit(
|
|
|
279
307
|
standard: settings.standard,
|
|
280
308
|
threshold,
|
|
281
309
|
pages,
|
|
310
|
+
pagesAudited: pages.length,
|
|
311
|
+
totalPages: manifest.pages.length,
|
|
312
|
+
pagesFailedToLoad,
|
|
282
313
|
totalViolations,
|
|
283
314
|
failingViolations,
|
|
284
|
-
passed: failingViolations === 0,
|
|
315
|
+
passed: failingViolations === 0 && pagesFailedToLoad === 0,
|
|
285
316
|
};
|
|
286
317
|
const reportPath = resolve(projectRoot, 'a11y-report.json');
|
|
287
318
|
writeFileSync(reportPath, JSON.stringify(report, null, 2), 'utf-8');
|
|
@@ -305,6 +336,10 @@ export async function runAudit(
|
|
|
305
336
|
function printSummary(report: AuditReport, reportPath: string): void {
|
|
306
337
|
const thresholdRank = IMPACT_RANK[report.threshold];
|
|
307
338
|
for (const p of report.pages) {
|
|
339
|
+
if (p.loadFailed) {
|
|
340
|
+
console.log(`\x1b[31m ✗\x1b[0m ${p.title} — failed to load`);
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
308
343
|
if (p.violations.length === 0) {
|
|
309
344
|
console.log(`\x1b[32m ✓\x1b[0m ${p.title}`);
|
|
310
345
|
continue;
|
|
@@ -319,13 +354,34 @@ function printSummary(report: AuditReport, reportPath: string): void {
|
|
|
319
354
|
}
|
|
320
355
|
}
|
|
321
356
|
console.log(`\n[tessera a11y] Report written to ${reportPath}`);
|
|
357
|
+
if (report.pagesAudited < report.totalPages) {
|
|
358
|
+
console.log(
|
|
359
|
+
`\x1b[33m[tessera a11y] Covered ${report.pagesAudited} of ${report.totalPages} page(s)\x1b[0m — reduced scope, the rest were not audited.`,
|
|
360
|
+
);
|
|
361
|
+
} else if (report.pagesFailedToLoad > 0) {
|
|
362
|
+
const scanned = report.pagesAudited - report.pagesFailedToLoad;
|
|
363
|
+
console.log(
|
|
364
|
+
`[tessera a11y] Reached all ${report.totalPages} page(s); scanned ${scanned}, ${report.pagesFailedToLoad} failed to load.`,
|
|
365
|
+
);
|
|
366
|
+
} else {
|
|
367
|
+
console.log(`[tessera a11y] Covered all ${report.totalPages} page(s).`);
|
|
368
|
+
}
|
|
322
369
|
if (report.passed) {
|
|
323
370
|
console.log(
|
|
324
371
|
`\x1b[32m[tessera a11y] Passed\x1b[0m — ${report.totalViolations} total finding(s), none at/above "${report.threshold}".`,
|
|
325
372
|
);
|
|
326
373
|
} else {
|
|
374
|
+
const reasons: string[] = [];
|
|
375
|
+
if (report.failingViolations > 0) {
|
|
376
|
+
reasons.push(
|
|
377
|
+
`${report.failingViolations} finding(s) at/above "${report.threshold}" (of ${report.totalViolations} total)`,
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
if (report.pagesFailedToLoad > 0) {
|
|
381
|
+
reasons.push(`${report.pagesFailedToLoad} page(s) failed to load`);
|
|
382
|
+
}
|
|
327
383
|
console.log(
|
|
328
|
-
`\x1b[31m[tessera a11y] Failed\x1b[0m — ${
|
|
384
|
+
`\x1b[31m[tessera a11y] Failed\x1b[0m — ${reasons.join('; ')}.`,
|
|
329
385
|
);
|
|
330
386
|
}
|
|
331
387
|
}
|
package/src/runtime/App.svelte
CHANGED
|
@@ -48,6 +48,13 @@
|
|
|
48
48
|
);
|
|
49
49
|
const nav = new NavigationState(manifest, progress, config, auditMode);
|
|
50
50
|
nav.setPageModules(pageModules);
|
|
51
|
+
|
|
52
|
+
// Layout-independent navigation seam the Tier-2 auditor walks pages through.
|
|
53
|
+
if (auditMode) {
|
|
54
|
+
window.__tesseraAudit = {
|
|
55
|
+
goToIndex: (i) => nav.goToPage(i),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
51
58
|
let duration = $state(new DurationTracker(0));
|
|
52
59
|
|
|
53
60
|
const onIdle =
|
|
@@ -64,6 +71,9 @@
|
|
|
64
71
|
let pageLoading = $state(true);
|
|
65
72
|
let pageError = $state(null);
|
|
66
73
|
let retryKey = $state(0);
|
|
74
|
+
// Rendered page index, surfaced on #tessera-app so the auditor can wait for a
|
|
75
|
+
// requested navigation to settle before scanning.
|
|
76
|
+
let renderedPageIndex = $state(-1);
|
|
67
77
|
|
|
68
78
|
// ---- Page context (reactive, read by Quiz in Step 8) ----
|
|
69
79
|
let pageContext = $state({
|
|
@@ -130,6 +140,7 @@
|
|
|
130
140
|
pageError = new Error(`Page not found: ${page.importPath}`);
|
|
131
141
|
PageComponent = null;
|
|
132
142
|
pageLoading = false;
|
|
143
|
+
renderedPageIndex = index;
|
|
133
144
|
return;
|
|
134
145
|
}
|
|
135
146
|
|
|
@@ -140,6 +151,7 @@
|
|
|
140
151
|
pageContext.quiz = page.quiz;
|
|
141
152
|
PageComponent = mod.default;
|
|
142
153
|
pageLoading = false;
|
|
154
|
+
renderedPageIndex = index;
|
|
143
155
|
progress.markVisited(index);
|
|
144
156
|
if (
|
|
145
157
|
manifest.pages[index].completesOn === 'view' &&
|
|
@@ -154,6 +166,7 @@
|
|
|
154
166
|
console.error(`Tessera: Failed to load page ${index}`, err);
|
|
155
167
|
pageError = err;
|
|
156
168
|
pageLoading = false;
|
|
169
|
+
renderedPageIndex = index;
|
|
157
170
|
});
|
|
158
171
|
}
|
|
159
172
|
|
|
@@ -446,6 +459,7 @@
|
|
|
446
459
|
});
|
|
447
460
|
|
|
448
461
|
onDestroy(() => {
|
|
462
|
+
if (auditMode) delete window.__tesseraAudit;
|
|
449
463
|
window.removeEventListener('pagehide', handleExit);
|
|
450
464
|
window.removeEventListener('beforeunload', handleExit);
|
|
451
465
|
const appEl = document.getElementById('tessera-app');
|
|
@@ -474,7 +488,12 @@
|
|
|
474
488
|
{/if}
|
|
475
489
|
{/snippet}
|
|
476
490
|
|
|
477
|
-
<div
|
|
491
|
+
<div
|
|
492
|
+
id="tessera-app"
|
|
493
|
+
data-chrome={chromeMode}
|
|
494
|
+
data-tessera-page-index={auditMode ? renderedPageIndex : undefined}
|
|
495
|
+
data-tessera-page-error={auditMode && pageError ? 'true' : undefined}
|
|
496
|
+
>
|
|
478
497
|
<LoadingBar active={pageLoading} />
|
|
479
498
|
{#if UserLayout}
|
|
480
499
|
<UserLayout {page} />
|