@pie-qti/ims-cp-core 1.0.0-beta.0 → 1.0.0-beta.2
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/index.d.ts +14 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/localized-resources.d.ts +308 -0
- package/dist/localized-resources.js +410 -0
- package/dist/localized-resources.js.map +1 -0
- package/dist/manifest-parser.d.ts +82 -0
- package/dist/manifest-parser.js +213 -0
- package/dist/manifest-parser.js.map +1 -0
- package/dist/package-file-resolver.d.ts +48 -0
- package/dist/package-file-resolver.js +312 -0
- package/dist/package-file-resolver.js.map +1 -0
- package/dist/package-graph.d.ts +134 -0
- package/dist/package-graph.js +791 -0
- package/dist/package-graph.js.map +1 -0
- package/dist/package-path.d.ts +13 -0
- package/dist/package-path.js +90 -0
- package/dist/package-path.js.map +1 -0
- package/dist/passage-reusability.d.ts +99 -0
- package/dist/passage-reusability.js +170 -0
- package/dist/passage-reusability.js.map +1 -0
- package/dist/qti-heuristics.d.ts +119 -0
- package/dist/qti-heuristics.js +150 -0
- package/dist/qti-heuristics.js.map +1 -0
- package/dist/qti3-shared-content.d.ts +114 -0
- package/dist/qti3-shared-content.js +422 -0
- package/dist/qti3-shared-content.js.map +1 -0
- package/dist/security-parsing.d.ts +9 -0
- package/dist/security-parsing.js +74 -0
- package/dist/security-parsing.js.map +1 -0
- package/dist/utils/hash.d.ts +20 -0
- package/dist/utils/hash.js +33 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/qti-xml.d.ts +103 -0
- package/dist/utils/qti-xml.js +214 -0
- package/dist/utils/qti-xml.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-graph.js","sourceRoot":"","sources":["../src/package-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EACN,qBAAqB,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manifest-parser.js';\nimport {\n\tbuildPackageFileIndex,\n\ttype PackageFileIndex,\n\ttype PackageReferenceKind as ResolvablePackageReferenceKind,\n\ttype PackageReferenceResolutionStrategy,\n\tresolvePackageReference,\n} from './package-file-resolver.js';\nimport type { QtiHeuristicsConfig } from './qti-heuristics.js';\nimport {\n\tdirnamePackagePath,\n\tisExternalPackageHref,\n\tjoinPackagePath,\n\tresolveCheckedPackagePath,\n\tresolvePackagePath,\n} from './package-path.js';\nimport { decodeXmlAttribute, parseSrcsetCandidates } from './security-parsing.js';\n\nexport type PackageDiagnosticSeverity = 'info' | 'warning' | 'error';\n\nexport interface PackageDiagnostic {\n\tseverity: PackageDiagnosticSeverity;\n\tcode: string;\n\tmessage: string;\n\tresourceId?: string;\n\tsourcePath?: string;\n\treference?: string;\n}\n\nexport type QtiPackageVersion = '2.1' | '2.2' | '3.0' | 'unknown' | 'conflicting';\nexport type QtiVersionConfidence = 'high' | 'medium' | 'low' | 'none' | 'conflicting';\n\nexport interface QtiVersionSignal {\n\tsource: 'manifest' | 'qti_xml' | 'schema_location' | 'package_metadata';\n\tversion: Exclude<QtiPackageVersion, 'unknown' | 'conflicting'>;\n\tconfidence: Exclude<QtiVersionConfidence, 'none' | 'conflicting'>;\n\tevidence: string;\n\tresourceId?: string;\n\tsourcePath?: string;\n}\n\nexport interface QtiPackageVersionDiagnostic {\n\tversion: QtiPackageVersion;\n\tconfidence: QtiVersionConfidence;\n\tsignals: QtiVersionSignal[];\n\tdiagnostics: PackageDiagnostic[];\n}\n\nexport interface PackageFileAccess {\n\treadText(path: string): Promise<string | null | undefined> | string | null | undefined;\n\treadBuffer?(path: string): Promise<Uint8Array | null | undefined> | Uint8Array | null | undefined;\n\texists?(path: string): Promise<boolean> | boolean;\n\tlistFiles?(): Promise<string[]> | string[];\n\tresolvePreviewUrl?(path: string): Promise<string | null | undefined> | string | null | undefined;\n}\n\nexport type PackageResourceKind = 'item' | 'test' | 'passage' | 'asset' | 'webcontent' | 'other';\n\nexport interface PackageResourceNode {\n\tidentifier: string;\n\ttype: string;\n\tkind: PackageResourceKind;\n\thref?: string;\n\tresolvedHref?: string;\n\txmlBase?: string;\n\tfiles: string[];\n\tresolvedFiles: string[];\n\tdependencies: string[];\n\tmetadata?: ManifestResource['metadata'];\n}\n\nexport interface PackageReference {\n\tkind: 'manifest-dependency' | 'assessment-item-ref' | 'asset' | 'stylesheet' | 'object' | 'catalog' | 'stimulus';\n\trawHref: string;\n\tresolvedPath?: string;\n\tsourcePath?: string;\n\tsourceElement?: string;\n\tsourceAttribute?: string;\n\ttargetResourceId?: string;\n\tresolutionStrategy?: PackageReferenceResolutionStrategy;\n\theuristic?: boolean;\n\trenderHref?: string;\n}\n\nexport interface PackageAssetRef {\n\trawHref: string;\n\tresolvedPath: string;\n\tusage: 'image' | 'stylesheet' | 'audio' | 'video' | 'html' | 'catalog' | 'source-qti' | 'other';\n\townerResourceId?: string;\n\townerResourceIds?: string[];\n\tsourcePath?: string;\n\tsourcePaths?: string[];\n\tsourceElement?: string;\n\tsourceAttribute?: string;\n\tresolutionStrategy?: PackageReferenceResolutionStrategy;\n\theuristic?: boolean;\n\trenderHref?: string;\n}\n\nexport interface PackageResourceClosure {\n\tresourceId: string;\n\tresourceIds: string[];\n\tfilePaths: string[];\n\tassetPaths: string[];\n\tdiagnostics: PackageDiagnostic[];\n}\n\nexport interface PackageEntrypoint {\n\tresourceId: string;\n\tkind: 'item' | 'test' | 'passage';\n\thref?: string;\n}\n\nexport type PackageRelationshipKind =\n\t| 'manifest-dependency'\n\t| 'assessment-item-ref'\n\t| 'assessment-stimulus-ref'\n\t| 'shared-asset';\n\nexport interface PackageRelationshipHint {\n\tkind: PackageRelationshipKind;\n\tsourceResourceId?: string;\n\tsourceResourceIds?: string[];\n\ttargetResourceId?: string;\n\ttargetPath?: string;\n\trawHref?: string;\n\tsourcePath?: string;\n\tsourceElement?: string;\n\tsourceAttribute?: string;\n}\n\nexport interface AnalyzedContentPackage {\n\tpackageId: string;\n\tmanifest: ParsedManifest;\n\tresources: Map<string, PackageResourceNode>;\n\tentrypoints: PackageEntrypoint[];\n\treferences: Map<string, PackageReference[]>;\n\tclosures: Map<string, PackageResourceClosure>;\n\tassets: Map<string, PackageAssetRef>;\n\tqtiVersion: QtiPackageVersionDiagnostic;\n\tdiagnostics: PackageDiagnostic[];\n\tfiles: string[];\n}\n\nexport interface SerializedContentPackageEvidence {\n\tpackageId: string;\n\tmanifestIdentifier?: string;\n\tentrypoints: PackageEntrypoint[];\n\tresources: PackageResourceNode[];\n\treferences: Array<PackageReference & { resourceId: string }>;\n\tclosures: PackageResourceClosure[];\n\tassets: PackageAssetRef[];\n\trelationshipHints: PackageRelationshipHint[];\n\tqtiVersion: QtiPackageVersionDiagnostic;\n\tdiagnostics: PackageDiagnostic[];\n\tfiles: string[];\n}\n\nexport interface AnalyzeContentPackageInput {\n\tpackageId?: string;\n\tmanifestXml: string;\n\tbasePath?: string;\n\tfileAccess?: PackageFileAccess;\n\theuristicsConfig?: QtiHeuristicsConfig;\n}\n\nconst ASSET_EXTENSIONS: Record<string, PackageAssetRef['usage']> = {\n\t'.apng': 'image',\n\t'.avif': 'image',\n\t'.gif': 'image',\n\t'.jpg': 'image',\n\t'.jpeg': 'image',\n\t'.png': 'image',\n\t'.svg': 'image',\n\t'.webp': 'image',\n\t'.css': 'stylesheet',\n\t'.mp3': 'audio',\n\t'.m4a': 'audio',\n\t'.ogg': 'audio',\n\t'.wav': 'audio',\n\t'.mp4': 'video',\n\t'.mov': 'video',\n\t'.webm': 'video',\n\t'.html': 'html',\n\t'.htm': 'html',\n\t'.xml': 'source-qti',\n};\n\nexport async function analyzeContentPackage({\n\tpackageId,\n\tmanifestXml,\n\tbasePath,\n\tfileAccess,\n\theuristicsConfig,\n}: AnalyzeContentPackageInput): Promise<AnalyzedContentPackage> {\n\tconst manifest = parseManifest(manifestXml, basePath);\n\tconst diagnostics: PackageDiagnostic[] = [];\n\tconst resources = new Map<string, PackageResourceNode>();\n\tconst references = new Map<string, PackageReference[]>();\n\tconst assets = new Map<string, PackageAssetRef>();\n\tconst files = fileAccess?.listFiles ? await fileAccess.listFiles() : [];\n\tconst listedFiles = fileAccess?.listFiles ? new Set(files) : undefined;\n\tconst fileIndexPaths = new Set(files);\n\tconst versionSignals: QtiVersionSignal[] = [\n\t\t...detectManifestVersionSignals(manifestXml),\n\t\t...detectResourceTypeVersionSignals(manifest.resources.values()),\n\t];\n\n\tfor (const resource of manifest.resources.values()) {\n\t\tconst node = toResourceNode(resource, manifest);\n\t\tresources.set(node.identifier, node);\n\t\tdiagnostics.push(...unsafeManifestPathDiagnostics(resource, manifest));\n\t\tif (node.resolvedHref) {\n\t\t\tfileIndexPaths.add(node.resolvedHref);\n\t\t}\n\t\tfor (const filePath of node.resolvedFiles) {\n\t\t\tfileIndexPaths.add(filePath);\n\t\t\tmaybeRegisterAsset(assets, filePath, {\n\t\t\t\townerResourceId: node.identifier,\n\t\t\t\tsourcePath: node.resolvedHref,\n\t\t\t});\n\t\t\tif (fileAccess && !(await packagePathExists(filePath, fileAccess, listedFiles))) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tseverity: 'warning',\n\t\t\t\t\tcode: 'IMS_CP_MISSING_FILE',\n\t\t\t\t\tmessage: `Resource ${node.identifier} declares missing package file ${filePath}.`,\n\t\t\t\t\tresourceId: node.identifier,\n\t\t\t\t\tsourcePath: node.resolvedHref,\n\t\t\t\t\treference: filePath,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\tconst fileIndex = buildPackageFileIndex([...fileIndexPaths]);\n\tdiagnostics.push(...fileIndex.diagnostics);\n\tconst manifestEvidencePaths = new Set(\n\t\t[...resources.values()].flatMap((resource) => [\n\t\t\t...(resource.resolvedHref ? [resource.resolvedHref] : []),\n\t\t\t...resource.resolvedFiles,\n\t\t])\n\t);\n\n\tfor (const node of resources.values()) {\n\t\tconst resourceReferences: PackageReference[] = [];\n\t\tfor (const dependency of node.dependencies) {\n\t\t\tif (resources.has(dependency)) {\n\t\t\t\tresourceReferences.push({\n\t\t\t\t\tkind: 'manifest-dependency',\n\t\t\t\t\trawHref: dependency,\n\t\t\t\t\ttargetResourceId: dependency,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tseverity: 'warning',\n\t\t\t\t\tcode: 'IMS_CP_DANGLING_DEPENDENCY',\n\t\t\t\t\tmessage: `Resource ${node.identifier} depends on missing resource ${dependency}.`,\n\t\t\t\t\tresourceId: node.identifier,\n\t\t\t\t\treference: dependency,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (fileAccess && node.resolvedHref && isXmlLike(node.resolvedHref)) {\n\t\t\tconst xml = await fileAccess.readText(node.resolvedHref);\n\t\t\tif (xml) {\n\t\t\t\tversionSignals.push(...detectQtiXmlVersionSignals(xml, node));\n\t\t\t\tconst discovered = discoverReferences(xml, node, fileIndex, manifestEvidencePaths, heuristicsConfig);\n\t\t\t\tdiagnostics.push(\n\t\t\t\t\t...discovered.diagnostics.map((diagnostic) => ({\n\t\t\t\t\t\t...diagnostic,\n\t\t\t\t\t\tresourceId: node.identifier,\n\t\t\t\t\t}))\n\t\t\t\t);\n\t\t\t\tfor (const reference of discovered.references) {\n\t\t\t\t\tif ((reference.kind === 'assessment-item-ref' || reference.kind === 'stimulus') && reference.resolvedPath) {\n\t\t\t\t\t\tconst target = findResourceByResolvedHref(resources, reference.resolvedPath);\n\t\t\t\t\t\tif (target) {\n\t\t\t\t\t\t\treference.targetResourceId = target.identifier;\n\t\t\t\t\t\t} else if (!(await packagePathExists(reference.resolvedPath, fileAccess, listedFiles))) {\n\t\t\t\t\t\t\tdiagnostics.push({\n\t\t\t\t\t\t\t\tseverity: 'warning',\n\t\t\t\t\t\t\t\tcode: reference.kind === 'stimulus' ? 'IMS_CP_DANGLING_STIMULUS_REF' : 'IMS_CP_DANGLING_ITEM_REF',\n\t\t\t\t\t\t\t\tmessage: `Resource ${node.identifier} references missing ${\n\t\t\t\t\t\t\t\t\treference.kind === 'stimulus' ? 'assessment stimulus' : 'assessment item'\n\t\t\t\t\t\t\t\t} ${reference.rawHref}.`,\n\t\t\t\t\t\t\t\tresourceId: node.identifier,\n\t\t\t\t\t\t\t\tsourcePath: node.resolvedHref,\n\t\t\t\t\t\t\t\treference: reference.rawHref,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tresourceReferences.push(reference);\n\t\t\t\t}\n\t\t\t\tfor (const asset of discovered.assets) {\n\t\t\t\t\tregisterAsset(assets, asset);\n\t\t\t\t\tif (!(await packagePathExists(asset.resolvedPath, fileAccess, listedFiles))) {\n\t\t\t\t\t\tdiagnostics.push({\n\t\t\t\t\t\t\tseverity: 'warning',\n\t\t\t\t\t\t\tcode: 'IMS_CP_MISSING_ASSET',\n\t\t\t\t\t\t\tmessage: `Resource ${node.identifier} references missing package asset ${asset.resolvedPath}.`,\n\t\t\t\t\t\t\tresourceId: node.identifier,\n\t\t\t\t\t\t\tsourcePath: node.resolvedHref,\n\t\t\t\t\t\t\treference: asset.rawHref,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (!hasMissingFileDiagnostic(diagnostics, node.identifier, node.resolvedHref)) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tseverity: 'warning',\n\t\t\t\t\tcode: 'IMS_CP_MISSING_FILE',\n\t\t\t\t\tmessage: `Resource ${node.identifier} could not read package XML file ${node.resolvedHref}.`,\n\t\t\t\t\tresourceId: node.identifier,\n\t\t\t\t\tsourcePath: node.resolvedHref,\n\t\t\t\t\treference: node.resolvedHref,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treferences.set(node.identifier, resourceReferences);\n\t}\n\n\tconst closures = new Map<string, PackageResourceClosure>();\n\tfor (const entrypoint of [...manifest.tests, ...manifest.items, ...manifest.passages]) {\n\t\tclosures.set(entrypoint.identifier, buildClosure(entrypoint.identifier, resources, references, diagnostics));\n\t}\n\tconst qtiVersion = summarizeQtiVersion(versionSignals);\n\tconst packageDiagnostics = [...diagnostics, ...qtiVersion.diagnostics];\n\n\treturn {\n\t\tpackageId: packageId ?? manifest.identifier ?? 'qti-package',\n\t\tmanifest,\n\t\tresources,\n\t\tentrypoints: [\n\t\t\t...manifest.tests.map((resource) => toEntrypoint(resource, 'test')),\n\t\t\t...manifest.items.map((resource) => toEntrypoint(resource, 'item')),\n\t\t\t...manifest.passages.map((resource) => toEntrypoint(resource, 'passage')),\n\t\t],\n\t\treferences,\n\t\tclosures,\n\t\tassets,\n\t\tqtiVersion,\n\t\tdiagnostics: packageDiagnostics,\n\t\tfiles,\n\t};\n}\n\nexport function serializeContentPackageEvidence(\n\tpackageGraph: AnalyzedContentPackage\n): SerializedContentPackageEvidence {\n\tconst resources = [...packageGraph.resources.values()]\n\t\t.map((resource) => ({\n\t\t\t...resource,\n\t\t\tfiles: sortStrings(resource.files),\n\t\t\tresolvedFiles: sortStrings(resource.resolvedFiles),\n\t\t\tdependencies: sortStrings(resource.dependencies),\n\t\t}))\n\t\t.sort(compareBy((resource) => resource.identifier));\n\tconst references = [...packageGraph.references.entries()]\n\t\t.flatMap(([resourceId, resourceReferences]) =>\n\t\t\tresourceReferences.map((reference) => ({ resourceId, ...reference }))\n\t\t)\n\t\t.sort(compareReferenceEvidence);\n\tconst assets = [...packageGraph.assets.values()]\n\t\t.map((asset) => ({\n\t\t\t...asset,\n\t\t\townerResourceIds: asset.ownerResourceIds ? sortStrings(asset.ownerResourceIds) : undefined,\n\t\t\tsourcePaths: asset.sourcePaths ? sortStrings(asset.sourcePaths) : undefined,\n\t\t}))\n\t\t.sort(compareBy((asset) => asset.resolvedPath));\n\tconst closures = [...packageGraph.closures.values()]\n\t\t.map((closure) => ({\n\t\t\t...closure,\n\t\t\tresourceIds: sortStrings(closure.resourceIds),\n\t\t\tfilePaths: sortStrings(closure.filePaths),\n\t\t\tassetPaths: sortStrings(closure.assetPaths),\n\t\t\tdiagnostics: sortDiagnostics(closure.diagnostics),\n\t\t}))\n\t\t.sort(compareBy((closure) => closure.resourceId));\n\n\treturn {\n\t\tpackageId: packageGraph.packageId,\n\t\tmanifestIdentifier: packageGraph.manifest.identifier,\n\t\tentrypoints: [...packageGraph.entrypoints].sort(compareBy((entrypoint) => entrypoint.resourceId)),\n\t\tresources,\n\t\treferences,\n\t\tclosures,\n\t\tassets,\n\t\trelationshipHints: buildRelationshipHints(references, assets),\n\t\tqtiVersion: {\n\t\t\t...packageGraph.qtiVersion,\n\t\t\tsignals: [...packageGraph.qtiVersion.signals].sort(compareVersionSignal),\n\t\t\tdiagnostics: sortDiagnostics(packageGraph.qtiVersion.diagnostics),\n\t\t},\n\t\tdiagnostics: sortDiagnostics(packageGraph.diagnostics),\n\t\tfiles: sortStrings(packageGraph.files),\n\t};\n}\n\nfunction toResourceNode(resource: ManifestResource, manifest: ParsedManifest): PackageResourceNode {\n\tconst base = joinPackagePath(manifest.xmlBase, resource.xmlBase);\n\tconst resolvedHref = resource.href ? resolveCheckedPackagePath(base, resource.href) ?? undefined : undefined;\n\treturn {\n\t\tidentifier: resource.identifier,\n\t\ttype: resource.type,\n\t\tkind: classifyResource(resource),\n\t\thref: resource.href,\n\t\tresolvedHref,\n\t\txmlBase: resource.xmlBase,\n\t\tfiles: resource.files,\n\t\tresolvedFiles: resource.files.flatMap((file) => {\n\t\t\tconst resolved = resolveCheckedPackagePath(base, file);\n\t\t\treturn resolved ? [resolved] : [];\n\t\t}),\n\t\tdependencies: resource.dependencies,\n\t\tmetadata: resource.metadata,\n\t};\n}\n\nfunction unsafeManifestPathDiagnostics(resource: ManifestResource, manifest: ParsedManifest): PackageDiagnostic[] {\n\tconst base = joinPackagePath(manifest.xmlBase, resource.xmlBase);\n\tconst diagnostics: PackageDiagnostic[] = [];\n\tconst candidates = [\n\t\t...(manifest.xmlBase ? [{ href: manifest.xmlBase, kind: 'manifest xml:base', basePath: undefined }] : []),\n\t\t...(resource.xmlBase ? [{ href: resource.xmlBase, kind: 'resource xml:base', basePath: manifest.xmlBase }] : []),\n\t\t...(resource.href ? [{ href: resource.href, kind: 'resource href' }] : []),\n\t\t...resource.files.map((href) => ({ href, kind: 'file href' })),\n\t];\n\tfor (const candidate of candidates) {\n\t\tif (resolveCheckedPackagePath(candidate.basePath ?? base, candidate.href)) continue;\n\t\tdiagnostics.push({\n\t\t\tseverity: 'error',\n\t\t\tcode: 'IMS_CP_UNSAFE_MANIFEST_PATH',\n\t\t\tmessage: `Resource ${resource.identifier} declares unsafe manifest ${candidate.kind} ${candidate.href}.`,\n\t\t\tresourceId: resource.identifier,\n\t\t\treference: candidate.href,\n\t\t});\n\t}\n\treturn diagnostics;\n}\n\nfunction toEntrypoint(resource: ManifestResource, kind: PackageEntrypoint['kind']): PackageEntrypoint {\n\treturn {\n\t\tresourceId: resource.identifier,\n\t\tkind,\n\t\thref: resource.href,\n\t};\n}\n\nfunction classifyResource(resource: ManifestResource): PackageResourceKind {\n\tif (resource.type.includes('imsqti_item') || resource.type.includes('qti_item')) return 'item';\n\tif (resource.type.includes('test') || resource.type.includes('assessment')) return 'test';\n\tif (resource.type.includes('passage') || resource.type.includes('stimulus')) return 'passage';\n\tif (resource.type === 'webcontent') return 'webcontent';\n\tif (resource.files.some((file) => classifyAssetUsage(file) !== 'other')) return 'asset';\n\treturn 'other';\n}\n\nfunction discoverReferences(\n\txml: string,\n\towner: PackageResourceNode,\n\tfileIndex: PackageFileIndex,\n\tmanifestEvidencePaths: ReadonlySet<string>,\n\theuristicsConfig: QtiHeuristicsConfig | undefined\n): {\n\treferences: PackageReference[];\n\tassets: PackageAssetRef[];\n\tdiagnostics: PackageDiagnostic[];\n} {\n\tconst references: PackageReference[] = [];\n\tconst assets: PackageAssetRef[] = [];\n\tconst diagnostics: PackageDiagnostic[] = [];\n\tconst basePath = owner.resolvedHref ? dirnamePackagePath(owner.resolvedHref) : '';\n\n\tfor (const match of findAttributeReferences(xml)) {\n\t\tconst resolution = resolvePackageReference({\n\t\t\tfileIndex,\n\t\t\tsourcePath: owner.resolvedHref,\n\t\t\trawHref: match.rawHref,\n\t\t\treferenceKind: referenceKindForMatch(match.kind),\n\t\t\tmanifestEvidencePaths,\n\t\t\theuristicsConfig,\n\t\t});\n\t\tdiagnostics.push(...resolution.diagnostics);\n\t\tif (resolution.status === 'skipped') {\n\t\t\tcontinue;\n\t\t}\n\t\tif (resolution.status === 'unsafe' || resolution.status === 'ambiguous') {\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolvedPath = resolution.status === 'resolved'\n\t\t\t? resolution.resolvedPath\n\t\t\t: resolvePackagePath(basePath, match.rawHref);\n\t\tconst reference: PackageReference = {\n\t\t\tkind: match.kind,\n\t\t\trawHref: match.rawHref,\n\t\t\tresolvedPath,\n\t\t\tsourcePath: owner.resolvedHref,\n\t\t\tsourceElement: match.element,\n\t\t\tsourceAttribute: match.attribute,\n\t\t\t...(resolution.status === 'resolved'\n\t\t\t\t? {\n\t\t\t\t\t\tresolutionStrategy: resolution.strategy,\n\t\t\t\t\t\theuristic: resolution.heuristic,\n\t\t\t\t\t\trenderHref: resolution.renderHref,\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t};\n\t\treferences.push(reference);\n\t\tif (match.kind !== 'assessment-item-ref' && match.kind !== 'stimulus') {\n\t\t\tassets.push({\n\t\t\t\trawHref: match.rawHref,\n\t\t\t\tresolvedPath,\n\t\t\t\tusage: usageFromReference(match.kind, resolvedPath),\n\t\t\t\townerResourceId: owner.identifier,\n\t\t\t\tsourcePath: owner.resolvedHref,\n\t\t\t\tsourceElement: match.element,\n\t\t\t\tsourceAttribute: match.attribute,\n\t\t\t\t...(resolution.status === 'resolved'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tresolutionStrategy: resolution.strategy,\n\t\t\t\t\t\t\theuristic: resolution.heuristic,\n\t\t\t\t\t\t\trenderHref: resolution.renderHref,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t}\n\t}\n\n\treturn { references, assets, diagnostics };\n}\n\nfunction findAttributeReferences(xml: string): Array<{\n\tkind: PackageReference['kind'];\n\telement: string;\n\tattribute: string;\n\trawHref: string;\n}> {\n\tconst refs: Array<{\n\t\tkind: PackageReference['kind'];\n\t\telement: string;\n\t\tattribute: string;\n\t\trawHref: string;\n\t}> = [];\n\tconst pattern =\n\t\t/<(?<element>assessmentItemRef|qti-assessment-item-ref|assessmentStimulusRef|qti-assessment-stimulus-ref|img|object|audio|video|source|track|embed|stylesheet|qti-stylesheet|link|file|fileHref|qti-file-href)\\b(?<attrs>(?:[^>\"']+|\"[^\"]*\"|'[^']*')*)>/gi;\n\tfor (const match of xml.matchAll(pattern)) {\n\t\tconst element = match.groups?.element ?? '';\n\t\tconst attrs = match.groups?.attrs ?? '';\n\t\tfor (const attribute of referenceAttributesForElement(element)) {\n\t\t\tconst rawValue = readAttribute(attrs, attribute);\n\t\t\tif (!rawValue) continue;\n\t\t\tconst hrefs = attribute === 'srcset' ? parseSrcsetHrefs(rawValue) : [rawValue];\n\t\t\tfor (const rawHref of hrefs) {\n\t\t\t\tconst decodedHref = decodeXmlAttribute(rawHref);\n\t\t\t\tif (!decodedHref || isExternalPackageHref(decodedHref)) continue;\n\t\t\t\trefs.push({\n\t\t\t\t\tkind: kindFromElement(element),\n\t\t\t\t\telement,\n\t\t\t\t\tattribute,\n\t\t\t\t\trawHref: decodedHref,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\tconst catalogTextPattern = /<(?<element>fileHref|filehref|qti-file-href)\\b[^>]*>(?<rawHref>[^<]+)<\\/(?:fileHref|filehref|qti-file-href)>/gi;\n\tfor (const match of xml.matchAll(catalogTextPattern)) {\n\t\tconst element = match.groups?.element ?? '';\n\t\tconst rawHref = decodeXmlAttribute(match.groups?.rawHref?.trim() ?? '');\n\t\tif (!rawHref || isExternalPackageHref(rawHref)) continue;\n\t\trefs.push({\n\t\t\tkind: 'catalog',\n\t\t\telement,\n\t\t\tattribute: 'text',\n\t\t\trawHref,\n\t\t});\n\t}\n\treturn refs;\n}\n\nfunction referenceAttributesForElement(element: string): string[] {\n\tswitch (element.toLowerCase()) {\n\t\tcase 'object':\n\t\t\treturn ['data'];\n\t\tcase 'img':\n\t\t\treturn ['src', 'srcset'];\n\t\tcase 'video':\n\t\t\treturn ['src', 'poster'];\n\t\tcase 'audio':\n\t\tcase 'source':\n\t\tcase 'track':\n\t\tcase 'embed':\n\t\t\treturn ['src'];\n\t\tcase 'assessmentitemref':\n\t\tcase 'qti-assessment-item-ref':\n\t\tcase 'assessmentstimulusref':\n\t\tcase 'qti-assessment-stimulus-ref':\n\t\tcase 'stylesheet':\n\t\tcase 'qti-stylesheet':\n\t\tcase 'link':\n\t\tcase 'file':\n\t\t\treturn ['href', 'src'];\n\t\tcase 'filehref':\n\t\tcase 'qti-file-href':\n\t\t\treturn ['src', 'href'];\n\t\tdefault:\n\t\t\treturn ['href', 'src', 'poster'];\n\t}\n}\n\nfunction parseSrcsetHrefs(value: string): string[] {\n\treturn parseSrcsetCandidates(value).map((candidate) => candidate.url);\n}\n\nfunction kindFromElement(element: string): PackageReference['kind'] {\n\tswitch (element.toLowerCase()) {\n\t\tcase 'assessmentitemref':\n\t\tcase 'qti-assessment-item-ref':\n\t\t\treturn 'assessment-item-ref';\n\t\tcase 'stylesheet':\n\t\tcase 'qti-stylesheet':\n\t\tcase 'link':\n\t\t\treturn 'stylesheet';\n\t\tcase 'assessmentstimulusref':\n\t\tcase 'qti-assessment-stimulus-ref':\n\t\t\treturn 'stimulus';\n\t\tcase 'filehref':\n\t\tcase 'qti-file-href':\n\t\t\treturn 'catalog';\n\t\tcase 'object':\n\t\t\treturn 'object';\n\t\tdefault:\n\t\t\treturn 'asset';\n\t}\n}\n\nfunction referenceKindForMatch(kind: PackageReference['kind']): ResolvablePackageReferenceKind {\n\tswitch (kind) {\n\t\tcase 'assessment-item-ref':\n\t\tcase 'stimulus':\n\t\t\treturn 'source-xml';\n\t\tcase 'stylesheet':\n\t\t\treturn 'stylesheet';\n\t\tcase 'catalog':\n\t\t\treturn 'catalog-file';\n\t\tcase 'asset':\n\t\tcase 'object':\n\t\t\treturn 'media-asset';\n\t\tdefault:\n\t\t\treturn 'other-asset';\n\t}\n}\n\nfunction usageFromReference(kind: PackageReference['kind'], path: string): PackageAssetRef['usage'] {\n\tif (kind === 'stylesheet') return 'stylesheet';\n\tif (kind === 'catalog') return 'catalog';\n\treturn classifyAssetUsage(path);\n}\n\nfunction buildClosure(\n\tresourceId: string,\n\tresources: Map<string, PackageResourceNode>,\n\treferences: Map<string, PackageReference[]>,\n\tpackageDiagnostics: PackageDiagnostic[]\n): PackageResourceClosure {\n\tconst visited = new Set<string>();\n\tconst filePaths = new Set<string>();\n\tconst assetPaths = new Set<string>();\n\tconst diagnostics: PackageDiagnostic[] = [];\n\n\tfunction visit(id: string) {\n\t\tif (visited.has(id)) return;\n\t\tconst node = resources.get(id);\n\t\tif (!node) {\n\t\t\tdiagnostics.push({\n\t\t\t\tseverity: 'warning',\n\t\t\t\tcode: 'IMS_CP_MISSING_CLOSURE_RESOURCE',\n\t\t\t\tmessage: `Closure references missing resource ${id}.`,\n\t\t\t\tresourceId,\n\t\t\t\treference: id,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tvisited.add(id);\n\t\tif (node.resolvedHref) filePaths.add(node.resolvedHref);\n\t\tfor (const file of node.resolvedFiles) {\n\t\t\tfilePaths.add(file);\n\t\t\tif (classifyAssetUsage(file) !== 'source-qti') assetPaths.add(file);\n\t\t}\n\t\tfor (const reference of references.get(id) ?? []) {\n\t\t\tif (reference.targetResourceId) visit(reference.targetResourceId);\n\t\t\tif (reference.resolvedPath && reference.kind !== 'assessment-item-ref' && reference.kind !== 'stimulus') {\n\t\t\t\tassetPaths.add(reference.resolvedPath);\n\t\t\t\tfilePaths.add(reference.resolvedPath);\n\t\t\t} else if (reference.resolvedPath && !reference.targetResourceId) {\n\t\t\t\tfilePaths.add(reference.resolvedPath);\n\t\t\t}\n\t\t}\n\t}\n\n\tvisit(resourceId);\n\tconst visitedResourceIds = new Set(visited);\n\treturn {\n\t\tresourceId,\n\t\tresourceIds: [...visited],\n\t\tfilePaths: [...filePaths],\n\t\tassetPaths: [...assetPaths],\n\t\tdiagnostics: [\n\t\t\t...diagnostics,\n\t\t\t...packageDiagnostics.filter((diagnostic) => diagnostic.resourceId && visitedResourceIds.has(diagnostic.resourceId)),\n\t\t],\n\t};\n}\n\nfunction maybeRegisterAsset(\n\tassets: Map<string, PackageAssetRef>,\n\tpath: string,\n\tcontext: Pick<PackageAssetRef, 'ownerResourceId' | 'sourcePath'>\n) {\n\tconst usage = classifyAssetUsage(path);\n\tif (usage === 'source-qti' || usage === 'other') return;\n\tregisterAsset(assets, {\n\t\trawHref: path,\n\t\tresolvedPath: path,\n\t\tusage,\n\t\t...context,\n\t});\n}\n\nfunction registerAsset(assets: Map<string, PackageAssetRef>, asset: PackageAssetRef): void {\n\tconst existing = assets.get(asset.resolvedPath);\n\tif (!existing) {\n\t\tassets.set(asset.resolvedPath, {\n\t\t\t...asset,\n\t\t\townerResourceIds: asset.ownerResourceId ? [asset.ownerResourceId] : [],\n\t\t\tsourcePaths: asset.sourcePath ? [asset.sourcePath] : [],\n\t\t});\n\t\treturn;\n\t}\n\n\tconst ownerResourceIds = new Set([\n\t\t...(existing.ownerResourceIds ?? (existing.ownerResourceId ? [existing.ownerResourceId] : [])),\n\t\t...(asset.ownerResourceIds ?? (asset.ownerResourceId ? [asset.ownerResourceId] : [])),\n\t]);\n\tconst sourcePaths = new Set([\n\t\t...(existing.sourcePaths ?? (existing.sourcePath ? [existing.sourcePath] : [])),\n\t\t...(asset.sourcePaths ?? (asset.sourcePath ? [asset.sourcePath] : [])),\n\t]);\n\n\tassets.set(asset.resolvedPath, {\n\t\t...existing,\n\t\trawHref: existing.rawHref || asset.rawHref,\n\t\tusage: existing.usage === 'other' ? asset.usage : existing.usage,\n\t\townerResourceId: existing.ownerResourceId ?? asset.ownerResourceId,\n\t\townerResourceIds: [...ownerResourceIds],\n\t\tsourcePath: existing.sourcePath ?? asset.sourcePath,\n\t\tsourcePaths: [...sourcePaths],\n\t\tsourceElement: existing.sourceElement ?? asset.sourceElement,\n\t\tsourceAttribute: existing.sourceAttribute ?? asset.sourceAttribute,\n\t\tresolutionStrategy: existing.resolutionStrategy ?? asset.resolutionStrategy,\n\t\theuristic: existing.heuristic ?? asset.heuristic,\n\t\trenderHref: existing.renderHref ?? asset.renderHref,\n\t});\n}\n\nfunction findResourceByResolvedHref(\n\tresources: Map<string, PackageResourceNode>,\n\tresolvedHref: string\n): PackageResourceNode | undefined {\n\treturn [...resources.values()].find((resource) => resource.resolvedHref === resolvedHref);\n}\n\nfunction classifyAssetUsage(path: string): PackageAssetRef['usage'] {\n\tconst lower = path.toLowerCase();\n\tconst extension = Object.keys(ASSET_EXTENSIONS).find((candidate) => lower.endsWith(candidate));\n\treturn extension ? ASSET_EXTENSIONS[extension] : 'other';\n}\n\nfunction isXmlLike(path: string): boolean {\n\treturn path.toLowerCase().endsWith('.xml');\n}\n\nfunction readAttribute(attrs: string, name: string): string | undefined {\n\tconst match = attrs.match(new RegExp(`\\\\b${name}\\\\s*=\\\\s*[\"']([^\"']+)[\"']`, 'i'));\n\treturn match?.[1];\n}\n\nasync function packagePathExists(\n\tpath: string,\n\tfileAccess: PackageFileAccess,\n\tlistedFiles?: Set<string>\n): Promise<boolean> {\n\tif (listedFiles) return listedFiles.has(path);\n\tif (fileAccess.exists) return Boolean(await fileAccess.exists(path));\n\treturn true;\n}\n\nfunction hasMissingFileDiagnostic(\n\tdiagnostics: PackageDiagnostic[],\n\tresourceId: string,\n\tpath: string\n): boolean {\n\treturn diagnostics.some(\n\t\t(diagnostic) =>\n\t\t\tdiagnostic.code === 'IMS_CP_MISSING_FILE' &&\n\t\t\tdiagnostic.resourceId === resourceId &&\n\t\t\tdiagnostic.reference === path\n\t);\n}\n\nfunction detectManifestVersionSignals(manifestXml: string): QtiVersionSignal[] {\n\treturn [\n\t\t...detectVersionPatterns(manifestXml, {\n\t\t\tsource: 'schema_location',\n\t\t\tconfidence: 'medium',\n\t\t\tincludeResourceTypes: false,\n\t\t}),\n\t\t...detectVersionPatterns(manifestXml, {\n\t\t\tsource: 'package_metadata',\n\t\t\tconfidence: 'low',\n\t\t\tincludeResourceTypes: false,\n\t\t}),\n\t];\n}\n\nfunction detectResourceTypeVersionSignals(resources: Iterable<ManifestResource>): QtiVersionSignal[] {\n\tconst signals: QtiVersionSignal[] = [];\n\tfor (const resource of resources) {\n\t\tsignals.push(\n\t\t\t...detectVersionPatterns(resource.type, {\n\t\t\t\tsource: 'manifest',\n\t\t\t\tconfidence: 'high',\n\t\t\t\tresourceId: resource.identifier,\n\t\t\t})\n\t\t);\n\t}\n\treturn dedupeVersionSignals(signals);\n}\n\nfunction detectQtiXmlVersionSignals(xml: string, node: PackageResourceNode): QtiVersionSignal[] {\n\treturn dedupeVersionSignals(\n\t\tdetectVersionPatterns(xml, {\n\t\t\tsource: 'qti_xml',\n\t\t\tconfidence: 'high',\n\t\t\tresourceId: node.identifier,\n\t\t\tsourcePath: node.resolvedHref,\n\t\t})\n\t);\n}\n\nfunction detectVersionPatterns(\n\tvalue: string,\n\tcontext: {\n\t\tsource: QtiVersionSignal['source'];\n\t\tconfidence: QtiVersionSignal['confidence'];\n\t\tresourceId?: string;\n\t\tsourcePath?: string;\n\t\tincludeResourceTypes?: boolean;\n\t}\n): QtiVersionSignal[] {\n\tconst includeResourceTypes = context.includeResourceTypes ?? true;\n\tconst patterns: Array<{\n\t\tversion: Exclude<QtiPackageVersion, 'unknown' | 'conflicting'>;\n\t\tpatterns: RegExp[];\n\t}> = [\n\t\t{\n\t\t\tversion: '3.0',\n\t\t\tpatterns: [\n\t\t\t\t/imsqtiasi_v3p0/i,\n\t\t\t\t/imsqti_v3p0/i,\n\t\t\t\t/qti[_-]?v?3p0/i,\n\t\t\t\t/qti[_\\s-]?3\\.0/i,\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tversion: '2.2',\n\t\t\tpatterns: [\n\t\t\t\t/imsqti_v2p2/i,\n\t\t\t\t/qti[_-]?v?2p2/i,\n\t\t\t\t/qti[_\\s-]?2\\.2/i,\n\t\t\t\t...(includeResourceTypes ? [/xmlv2p2/i] : []),\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tversion: '2.1',\n\t\t\tpatterns: [\n\t\t\t\t/imsqti_v2p1/i,\n\t\t\t\t/qti[_-]?v?2p1/i,\n\t\t\t\t/qti[_\\s-]?2\\.1/i,\n\t\t\t\t...(includeResourceTypes ? [/xmlv2p1/i] : []),\n\t\t\t],\n\t\t},\n\t];\n\tconst signals: QtiVersionSignal[] = [];\n\tfor (const { version, patterns: versionPatterns } of patterns) {\n\t\tfor (const pattern of versionPatterns) {\n\t\t\tconst match = value.match(pattern);\n\t\t\tif (!match) continue;\n\t\t\tsignals.push({\n\t\t\t\tsource: context.source,\n\t\t\t\tversion,\n\t\t\t\tconfidence: context.confidence,\n\t\t\t\tevidence: match[0],\n\t\t\t\tresourceId: context.resourceId,\n\t\t\t\tsourcePath: context.sourcePath,\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn dedupeVersionSignals(signals);\n}\n\nfunction summarizeQtiVersion(signals: QtiVersionSignal[]): QtiPackageVersionDiagnostic {\n\tconst dedupedSignals = dedupeVersionSignals(signals);\n\tconst versions = [...new Set(dedupedSignals.map((signal) => signal.version))].sort();\n\tif (versions.length === 0) {\n\t\treturn {\n\t\t\tversion: 'unknown',\n\t\t\tconfidence: 'none',\n\t\t\tsignals: [],\n\t\t\tdiagnostics: [\n\t\t\t\t{\n\t\t\t\t\tseverity: 'warning',\n\t\t\t\t\tcode: 'QTI_VERSION_UNKNOWN',\n\t\t\t\t\tmessage: 'Could not determine the QTI package version from manifest, schema, metadata, or readable QTI XML.',\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\tif (versions.length > 1) {\n\t\treturn {\n\t\t\tversion: 'conflicting',\n\t\t\tconfidence: 'conflicting',\n\t\t\tsignals: dedupedSignals,\n\t\t\tdiagnostics: [\n\t\t\t\t{\n\t\t\t\t\tseverity: 'warning',\n\t\t\t\t\tcode: 'QTI_VERSION_CONFLICT',\n\t\t\t\t\tmessage: `Conflicting QTI package version signals were found: ${versions.join(', ')}.`,\n\t\t\t\t\treference: versions.join(','),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\treturn {\n\t\tversion: versions[0],\n\t\tconfidence: strongestConfidence(dedupedSignals),\n\t\tsignals: dedupedSignals,\n\t\tdiagnostics: [],\n\t};\n}\n\nfunction strongestConfidence(signals: QtiVersionSignal[]): QtiVersionConfidence {\n\tif (signals.some((signal) => signal.confidence === 'high')) return 'high';\n\tif (signals.some((signal) => signal.confidence === 'medium')) return 'medium';\n\tif (signals.some((signal) => signal.confidence === 'low')) return 'low';\n\treturn 'none';\n}\n\nfunction dedupeVersionSignals(signals: QtiVersionSignal[]): QtiVersionSignal[] {\n\tconst byKey = new Map<string, QtiVersionSignal>();\n\tfor (const signal of signals) {\n\t\tconst key = [\n\t\t\tsignal.source,\n\t\t\tsignal.version,\n\t\t\tsignal.confidence,\n\t\t\tsignal.resourceId ?? '',\n\t\t\tsignal.sourcePath ?? '',\n\t\t\tsignal.evidence,\n\t\t].join('|');\n\t\tbyKey.set(key, signal);\n\t}\n\treturn [...byKey.values()];\n}\n\nfunction buildRelationshipHints(\n\treferences: Array<PackageReference & { resourceId: string }>,\n\tassets: PackageAssetRef[]\n): PackageRelationshipHint[] {\n\tconst hints: PackageRelationshipHint[] = [];\n\tfor (const reference of references) {\n\t\tif (\n\t\t\treference.kind !== 'manifest-dependency' &&\n\t\t\treference.kind !== 'assessment-item-ref' &&\n\t\t\treference.kind !== 'stimulus'\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\thints.push({\n\t\t\tkind: reference.kind === 'stimulus' ? 'assessment-stimulus-ref' : reference.kind,\n\t\t\tsourceResourceId: reference.resourceId,\n\t\t\ttargetResourceId: reference.targetResourceId,\n\t\t\ttargetPath: reference.resolvedPath,\n\t\t\trawHref: reference.rawHref,\n\t\t\tsourcePath: reference.sourcePath,\n\t\t\tsourceElement: reference.sourceElement,\n\t\t\tsourceAttribute: reference.sourceAttribute,\n\t\t});\n\t}\n\tfor (const asset of assets) {\n\t\tconst ownerResourceIds = asset.ownerResourceIds ?? (asset.ownerResourceId ? [asset.ownerResourceId] : []);\n\t\tif (ownerResourceIds.length < 2) continue;\n\t\thints.push({\n\t\t\tkind: 'shared-asset',\n\t\t\tsourceResourceIds: sortStrings(ownerResourceIds),\n\t\t\ttargetPath: asset.resolvedPath,\n\t\t\trawHref: asset.rawHref,\n\t\t\tsourcePath: asset.sourcePath,\n\t\t\tsourceElement: asset.sourceElement,\n\t\t\tsourceAttribute: asset.sourceAttribute,\n\t\t});\n\t}\n\treturn hints.sort(compareRelationshipHint);\n}\n\nfunction sortStrings(values: string[]): string[] {\n\treturn [...values].sort((left, right) => left.localeCompare(right));\n}\n\nfunction sortDiagnostics(diagnostics: PackageDiagnostic[]): PackageDiagnostic[] {\n\treturn [...diagnostics].sort(\n\t\t(left, right) =>\n\t\t\tleft.severity.localeCompare(right.severity) ||\n\t\t\tleft.code.localeCompare(right.code) ||\n\t\t\t(left.resourceId ?? '').localeCompare(right.resourceId ?? '') ||\n\t\t\t(left.sourcePath ?? '').localeCompare(right.sourcePath ?? '') ||\n\t\t\t(left.reference ?? '').localeCompare(right.reference ?? '') ||\n\t\t\tleft.message.localeCompare(right.message)\n\t);\n}\n\nfunction compareBy<T>(select: (value: T) => string | undefined): (left: T, right: T) => number {\n\treturn (left, right) => (select(left) ?? '').localeCompare(select(right) ?? '');\n}\n\nfunction compareReferenceEvidence(\n\tleft: PackageReference & { resourceId: string },\n\tright: PackageReference & { resourceId: string }\n): number {\n\treturn (\n\t\tleft.resourceId.localeCompare(right.resourceId) ||\n\t\tleft.kind.localeCompare(right.kind) ||\n\t\t(left.targetResourceId ?? '').localeCompare(right.targetResourceId ?? '') ||\n\t\t(left.resolvedPath ?? '').localeCompare(right.resolvedPath ?? '') ||\n\t\tleft.rawHref.localeCompare(right.rawHref)\n\t);\n}\n\nfunction compareVersionSignal(left: QtiVersionSignal, right: QtiVersionSignal): number {\n\treturn (\n\t\tleft.version.localeCompare(right.version) ||\n\t\tleft.source.localeCompare(right.source) ||\n\t\t(left.resourceId ?? '').localeCompare(right.resourceId ?? '') ||\n\t\t(left.sourcePath ?? '').localeCompare(right.sourcePath ?? '') ||\n\t\tleft.evidence.localeCompare(right.evidence)\n\t);\n}\n\nfunction compareRelationshipHint(left: PackageRelationshipHint, right: PackageRelationshipHint): number {\n\treturn (\n\t\tleft.kind.localeCompare(right.kind) ||\n\t\t(left.sourceResourceId ?? '').localeCompare(right.sourceResourceId ?? '') ||\n\t\t(left.sourceResourceIds?.join(',') ?? '').localeCompare(right.sourceResourceIds?.join(',') ?? '') ||\n\t\t(left.targetResourceId ?? '').localeCompare(right.targetResourceId ?? '') ||\n\t\t(left.targetPath ?? '').localeCompare(right.targetPath ?? '') ||\n\t\t(left.rawHref ?? '').localeCompare(right.rawHref ?? '')\n\t);\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface PackagePathResolutionOptions {
|
|
2
|
+
rejectRootEscape?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function joinPackagePath(...parts: Array<string | undefined>): string;
|
|
5
|
+
export declare function dirnamePackagePath(path: string): string;
|
|
6
|
+
export declare function resolvePackagePath(basePath: string | undefined, href: string): string;
|
|
7
|
+
export declare function resolvePackagePathFromFile(baseHref: string, href: string): string;
|
|
8
|
+
export declare function resolveCheckedPackagePath(basePath: string | undefined, href: string): string | null;
|
|
9
|
+
export declare function resolveCheckedPackagePathFromFile(baseHref: string, href: string): string | null;
|
|
10
|
+
export declare function isPackageRelativeHref(href: string): boolean;
|
|
11
|
+
export declare function isExternalPackageHref(href: string): boolean;
|
|
12
|
+
/** True when href carries percent-encoded path separators/dots that survive repeated decoding. */
|
|
13
|
+
export declare function hasUnsafeEncodedPathToken(href: string): boolean;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export function joinPackagePath(...parts) {
|
|
2
|
+
return parts.filter(Boolean).join('/');
|
|
3
|
+
}
|
|
4
|
+
export function dirnamePackagePath(path) {
|
|
5
|
+
const normalized = path.replaceAll('\\', '/');
|
|
6
|
+
const index = normalized.lastIndexOf('/');
|
|
7
|
+
return index === -1 ? '' : normalized.slice(0, index);
|
|
8
|
+
}
|
|
9
|
+
export function resolvePackagePath(basePath, href) {
|
|
10
|
+
return resolvePackagePathInternal(basePath, href).path;
|
|
11
|
+
}
|
|
12
|
+
export function resolvePackagePathFromFile(baseHref, href) {
|
|
13
|
+
return resolvePackagePath(dirnamePackagePath(baseHref), href);
|
|
14
|
+
}
|
|
15
|
+
export function resolveCheckedPackagePath(basePath, href) {
|
|
16
|
+
if (!isPackageRelativeHref(href))
|
|
17
|
+
return null;
|
|
18
|
+
if (hasUnsafeEncodedPathToken(href))
|
|
19
|
+
return null;
|
|
20
|
+
if (!isSafePackageBasePath(basePath))
|
|
21
|
+
return null;
|
|
22
|
+
const result = resolvePackagePathInternal(basePath, href, { rejectRootEscape: true });
|
|
23
|
+
return result.escapedRoot ? null : result.path;
|
|
24
|
+
}
|
|
25
|
+
export function resolveCheckedPackagePathFromFile(baseHref, href) {
|
|
26
|
+
return resolveCheckedPackagePath(dirnamePackagePath(baseHref), href);
|
|
27
|
+
}
|
|
28
|
+
export function isPackageRelativeHref(href) {
|
|
29
|
+
const value = href.trim();
|
|
30
|
+
return Boolean(value) && !value.startsWith('/') && !value.startsWith('//') && !/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(value);
|
|
31
|
+
}
|
|
32
|
+
export function isExternalPackageHref(href) {
|
|
33
|
+
return /^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i.test(href);
|
|
34
|
+
}
|
|
35
|
+
function isSafePackageBasePath(basePath) {
|
|
36
|
+
if (!basePath)
|
|
37
|
+
return true;
|
|
38
|
+
if (!isPackageRelativeHref(basePath))
|
|
39
|
+
return false;
|
|
40
|
+
if (hasUnsafeEncodedPathToken(basePath))
|
|
41
|
+
return false;
|
|
42
|
+
return !resolvePackagePathInternal(undefined, basePath, { rejectRootEscape: true }).escapedRoot;
|
|
43
|
+
}
|
|
44
|
+
function resolvePackagePathInternal(basePath, href, options = {}) {
|
|
45
|
+
const raw = href.replaceAll('\\', '/');
|
|
46
|
+
const combined = raw.startsWith('/') ? raw.slice(1) : joinPackagePath(basePath, raw);
|
|
47
|
+
const normalized = [];
|
|
48
|
+
let escapedRoot = false;
|
|
49
|
+
for (const part of combined.split('/')) {
|
|
50
|
+
if (!part || part === '.')
|
|
51
|
+
continue;
|
|
52
|
+
if (part === '..') {
|
|
53
|
+
if (normalized.length === 0) {
|
|
54
|
+
escapedRoot = true;
|
|
55
|
+
if (options.rejectRootEscape)
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
normalized.pop();
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
normalized.push(part);
|
|
64
|
+
}
|
|
65
|
+
return { path: normalized.join('/'), escapedRoot };
|
|
66
|
+
}
|
|
67
|
+
/** True when href carries percent-encoded path separators/dots that survive repeated decoding. */
|
|
68
|
+
export function hasUnsafeEncodedPathToken(href) {
|
|
69
|
+
let current = href;
|
|
70
|
+
for (let i = 0; i < 3; i += 1) {
|
|
71
|
+
if (/%(?:2e|2f|5c)/i.test(current)) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
const decoded = safeDecodeURIComponent(current);
|
|
75
|
+
if (decoded === current) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
current = decoded;
|
|
79
|
+
}
|
|
80
|
+
return /%(?:2e|2f|5c)/i.test(current);
|
|
81
|
+
}
|
|
82
|
+
function safeDecodeURIComponent(value) {
|
|
83
|
+
try {
|
|
84
|
+
return decodeURIComponent(value);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=package-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-path.js","sourceRoot":"","sources":["../src/package-path.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,eAAe,CAAC,GAAG,KAAgC;IAClE,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAA4B,EAAE,IAAY;IAC5E,OAAO,0BAA0B,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,QAAgB,EAAE,IAAY;IACxE,OAAO,kBAAkB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,QAA4B,EAAE,IAAY;IACnF,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9C,IAAI,yBAAyB,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACjD,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAClD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;QACd,CAAC;QACD,OAAO,GAAG,OAAO,CAAC;IACnB,CAAC;IACD,OAAO,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAa;IAC5C,IAAI,CAAC;QACJ,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC","sourcesContent":["export interface PackagePathResolutionOptions {\n\trejectRootEscape?: boolean;\n}\n\nexport function joinPackagePath(...parts: Array<string | undefined>): string {\n\treturn parts.filter(Boolean).join('/');\n}\n\nexport function dirnamePackagePath(path: string): string {\n\tconst normalized = path.replaceAll('\\\\', '/');\n\tconst index = normalized.lastIndexOf('/');\n\treturn index === -1 ? '' : normalized.slice(0, index);\n}\n\nexport function resolvePackagePath(basePath: string | undefined, href: string): string {\n\treturn resolvePackagePathInternal(basePath, href).path;\n}\n\nexport function resolvePackagePathFromFile(baseHref: string, href: string): string {\n\treturn resolvePackagePath(dirnamePackagePath(baseHref), href);\n}\n\nexport function resolveCheckedPackagePath(basePath: string | undefined, href: string): string | null {\n\tif (!isPackageRelativeHref(href)) return null;\n\tif (hasUnsafeEncodedPathToken(href)) return null;\n\tif (!isSafePackageBasePath(basePath)) return null;\n\tconst result = resolvePackagePathInternal(basePath, href, { rejectRootEscape: true });\n\treturn result.escapedRoot ? null : result.path;\n}\n\nexport function resolveCheckedPackagePathFromFile(baseHref: string, href: string): string | null {\n\treturn resolveCheckedPackagePath(dirnamePackagePath(baseHref), href);\n}\n\nexport function isPackageRelativeHref(href: string): boolean {\n\tconst value = href.trim();\n\treturn Boolean(value) && !value.startsWith('/') && !value.startsWith('//') && !/^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(value);\n}\n\nexport function isExternalPackageHref(href: string): boolean {\n\treturn /^(?:[a-z][a-z0-9+.-]*:|\\/\\/|#)/i.test(href);\n}\n\nfunction isSafePackageBasePath(basePath: string | undefined): boolean {\n\tif (!basePath) return true;\n\tif (!isPackageRelativeHref(basePath)) return false;\n\tif (hasUnsafeEncodedPathToken(basePath)) return false;\n\treturn !resolvePackagePathInternal(undefined, basePath, { rejectRootEscape: true }).escapedRoot;\n}\n\nfunction resolvePackagePathInternal(\n\tbasePath: string | undefined,\n\thref: string,\n\toptions: PackagePathResolutionOptions = {}\n): { path: string; escapedRoot: boolean } {\n\tconst raw = href.replaceAll('\\\\', '/');\n\tconst combined = raw.startsWith('/') ? raw.slice(1) : joinPackagePath(basePath, raw);\n\tconst normalized: string[] = [];\n\tlet escapedRoot = false;\n\n\tfor (const part of combined.split('/')) {\n\t\tif (!part || part === '.') continue;\n\t\tif (part === '..') {\n\t\t\tif (normalized.length === 0) {\n\t\t\t\tescapedRoot = true;\n\t\t\t\tif (options.rejectRootEscape) continue;\n\t\t\t} else {\n\t\t\t\tnormalized.pop();\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tnormalized.push(part);\n\t}\n\n\treturn { path: normalized.join('/'), escapedRoot };\n}\n\n/** True when href carries percent-encoded path separators/dots that survive repeated decoding. */\nexport function hasUnsafeEncodedPathToken(href: string): boolean {\n\tlet current = href;\n\tfor (let i = 0; i < 3; i += 1) {\n\t\tif (/%(?:2e|2f|5c)/i.test(current)) {\n\t\t\treturn true;\n\t\t}\n\t\tconst decoded = safeDecodeURIComponent(current);\n\t\tif (decoded === current) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrent = decoded;\n\t}\n\treturn /%(?:2e|2f|5c)/i.test(current);\n}\n\nfunction safeDecodeURIComponent(value: string): string {\n\ttry {\n\t\treturn decodeURIComponent(value);\n\t} catch {\n\t\treturn value;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passage reusability detection and stable ID management
|
|
3
|
+
*
|
|
4
|
+
* QTI provides several mechanisms for reusable content:
|
|
5
|
+
* 1. Manifest <dependency> elements - explicit reusability declaration
|
|
6
|
+
* 2. Object <object data="..."> references - shared file paths
|
|
7
|
+
* 3. assessmentStimulus/assessmentPassage identifiers - stable IDs
|
|
8
|
+
*
|
|
9
|
+
* This module provides stable ID generation and reusability detection.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Generate stable ID for passage content
|
|
13
|
+
*
|
|
14
|
+
* Strategy (in priority order):
|
|
15
|
+
* 1. Use QTI identifier directly - QTI identifiers are designed to be globally unique
|
|
16
|
+
* across vendors and packages (e.g., "urn:example.com:passage:12345")
|
|
17
|
+
* 2. Use file path for object references - stable within a package
|
|
18
|
+
* 3. Use content hash for inline stimulus - ensures same content = same ID
|
|
19
|
+
*
|
|
20
|
+
* @param options Options for ID generation
|
|
21
|
+
* @returns Stable passage ID (async for content hashing)
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateStablePassageId(options: {
|
|
24
|
+
/** QTI identifier from assessmentStimulus or assessmentPassage - USE DIRECTLY */
|
|
25
|
+
qtiIdentifier?: string;
|
|
26
|
+
/** File path from object data attribute */
|
|
27
|
+
filePath?: string;
|
|
28
|
+
/** Content hash for inline stimulus */
|
|
29
|
+
content?: string;
|
|
30
|
+
/** Prefix for generated IDs (only used for hashed IDs) */
|
|
31
|
+
prefix?: string;
|
|
32
|
+
}): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Passage reference information
|
|
35
|
+
*/
|
|
36
|
+
export interface PassageReference {
|
|
37
|
+
/** Stable passage ID */
|
|
38
|
+
id: string;
|
|
39
|
+
/** Source of the passage */
|
|
40
|
+
source: 'inline' | 'file' | 'manifest' | 'qti-element';
|
|
41
|
+
/** Original QTI identifier if available */
|
|
42
|
+
qtiIdentifier?: string;
|
|
43
|
+
/** File path if from object reference */
|
|
44
|
+
filePath?: string;
|
|
45
|
+
/** Whether this passage is referenced by multiple items */
|
|
46
|
+
isReusable: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Track passage references across a package
|
|
50
|
+
* Used during batch transformation to detect reusable passages
|
|
51
|
+
*/
|
|
52
|
+
export declare class PassageRegistry {
|
|
53
|
+
private passages;
|
|
54
|
+
/**
|
|
55
|
+
* Register a passage reference
|
|
56
|
+
* @param itemId ID of the item referencing this passage
|
|
57
|
+
* @param reference Passage reference information
|
|
58
|
+
*/
|
|
59
|
+
registerReference(itemId: string, reference: PassageReference): void;
|
|
60
|
+
/**
|
|
61
|
+
* Store passage content for deduplication
|
|
62
|
+
* @param passageId Passage ID
|
|
63
|
+
* @param content Passage content
|
|
64
|
+
*/
|
|
65
|
+
storeContent(passageId: string, content: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* Get passage reference by ID
|
|
68
|
+
* @param passageId Passage ID
|
|
69
|
+
* @returns Passage reference with updated reusability flag
|
|
70
|
+
*/
|
|
71
|
+
getReference(passageId: string): PassageReference | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Get all items that reference a passage
|
|
74
|
+
* @param passageId Passage ID
|
|
75
|
+
* @returns Set of item IDs
|
|
76
|
+
*/
|
|
77
|
+
getReferencingItems(passageId: string): Set<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Get all registered passages
|
|
80
|
+
* @returns Array of passage references
|
|
81
|
+
*/
|
|
82
|
+
getAllPassages(): PassageReference[];
|
|
83
|
+
/**
|
|
84
|
+
* Get reusable passages (referenced by multiple items)
|
|
85
|
+
* @returns Array of reusable passage references
|
|
86
|
+
*/
|
|
87
|
+
getReusablePassages(): PassageReference[];
|
|
88
|
+
/**
|
|
89
|
+
* Detect duplicate content and merge passages
|
|
90
|
+
* This handles cases where same content appears with different IDs
|
|
91
|
+
*/
|
|
92
|
+
detectAndMergeDuplicates(): Promise<Map<string, string>>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Parse object tag to extract passage reference
|
|
96
|
+
* @param objectElement Object element from QTI
|
|
97
|
+
* @returns Passage reference or null
|
|
98
|
+
*/
|
|
99
|
+
export declare function parseObjectReference(objectElement: any): Promise<PassageReference | null>;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passage reusability detection and stable ID management
|
|
3
|
+
*
|
|
4
|
+
* QTI provides several mechanisms for reusable content:
|
|
5
|
+
* 1. Manifest <dependency> elements - explicit reusability declaration
|
|
6
|
+
* 2. Object <object data="..."> references - shared file paths
|
|
7
|
+
* 3. assessmentStimulus/assessmentPassage identifiers - stable IDs
|
|
8
|
+
*
|
|
9
|
+
* This module provides stable ID generation and reusability detection.
|
|
10
|
+
*/
|
|
11
|
+
import { sha256 } from './utils/hash.js';
|
|
12
|
+
/**
|
|
13
|
+
* Generate stable ID for passage content
|
|
14
|
+
*
|
|
15
|
+
* Strategy (in priority order):
|
|
16
|
+
* 1. Use QTI identifier directly - QTI identifiers are designed to be globally unique
|
|
17
|
+
* across vendors and packages (e.g., "urn:example.com:passage:12345")
|
|
18
|
+
* 2. Use file path for object references - stable within a package
|
|
19
|
+
* 3. Use content hash for inline stimulus - ensures same content = same ID
|
|
20
|
+
*
|
|
21
|
+
* @param options Options for ID generation
|
|
22
|
+
* @returns Stable passage ID (async for content hashing)
|
|
23
|
+
*/
|
|
24
|
+
export async function generateStablePassageId(options) {
|
|
25
|
+
const prefix = options.prefix || 'passage';
|
|
26
|
+
// Priority 1: Use QTI identifier DIRECTLY (no prefix)
|
|
27
|
+
// QTI identifiers are designed to be globally unique across vendors
|
|
28
|
+
// Examples: "urn:example.com:passage:12345", "stim-industrial-revolution"
|
|
29
|
+
if (options.qtiIdentifier) {
|
|
30
|
+
return options.qtiIdentifier;
|
|
31
|
+
}
|
|
32
|
+
// Priority 2: Use file path for object references
|
|
33
|
+
// Normalize path (remove leading ./ and ../) and use as-is with prefix
|
|
34
|
+
if (options.filePath) {
|
|
35
|
+
const normalizedPath = options.filePath
|
|
36
|
+
.replace(/^\.\//, '')
|
|
37
|
+
.replace(/\.\.\//g, '')
|
|
38
|
+
.replace(/\//g, '-')
|
|
39
|
+
.replace(/\.(xml|html|txt)$/, '');
|
|
40
|
+
return `${prefix}-${normalizedPath}`;
|
|
41
|
+
}
|
|
42
|
+
// Priority 3: Use content hash for inline stimulus (stable for same content)
|
|
43
|
+
if (options.content) {
|
|
44
|
+
const contentHash = await sha256(options.content.trim());
|
|
45
|
+
return `${prefix}-content-${contentHash.substring(0, 12)}`;
|
|
46
|
+
}
|
|
47
|
+
throw new Error('Must provide at least one of: qtiIdentifier, filePath, or content');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Track passage references across a package
|
|
51
|
+
* Used during batch transformation to detect reusable passages
|
|
52
|
+
*/
|
|
53
|
+
export class PassageRegistry {
|
|
54
|
+
passages = new Map();
|
|
55
|
+
/**
|
|
56
|
+
* Register a passage reference
|
|
57
|
+
* @param itemId ID of the item referencing this passage
|
|
58
|
+
* @param reference Passage reference information
|
|
59
|
+
*/
|
|
60
|
+
registerReference(itemId, reference) {
|
|
61
|
+
const existing = this.passages.get(reference.id);
|
|
62
|
+
if (existing) {
|
|
63
|
+
// Passage already registered, add this item as a reference
|
|
64
|
+
existing.referencedBy.add(itemId);
|
|
65
|
+
existing.reference.isReusable = existing.referencedBy.size > 1;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// First reference to this passage
|
|
69
|
+
this.passages.set(reference.id, {
|
|
70
|
+
reference: { ...reference, isReusable: false },
|
|
71
|
+
referencedBy: new Set([itemId]),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Store passage content for deduplication
|
|
77
|
+
* @param passageId Passage ID
|
|
78
|
+
* @param content Passage content
|
|
79
|
+
*/
|
|
80
|
+
storeContent(passageId, content) {
|
|
81
|
+
const entry = this.passages.get(passageId);
|
|
82
|
+
if (entry) {
|
|
83
|
+
entry.content = content;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get passage reference by ID
|
|
88
|
+
* @param passageId Passage ID
|
|
89
|
+
* @returns Passage reference with updated reusability flag
|
|
90
|
+
*/
|
|
91
|
+
getReference(passageId) {
|
|
92
|
+
return this.passages.get(passageId)?.reference;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get all items that reference a passage
|
|
96
|
+
* @param passageId Passage ID
|
|
97
|
+
* @returns Set of item IDs
|
|
98
|
+
*/
|
|
99
|
+
getReferencingItems(passageId) {
|
|
100
|
+
return this.passages.get(passageId)?.referencedBy || new Set();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get all registered passages
|
|
104
|
+
* @returns Array of passage references
|
|
105
|
+
*/
|
|
106
|
+
getAllPassages() {
|
|
107
|
+
return Array.from(this.passages.values()).map(entry => entry.reference);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get reusable passages (referenced by multiple items)
|
|
111
|
+
* @returns Array of reusable passage references
|
|
112
|
+
*/
|
|
113
|
+
getReusablePassages() {
|
|
114
|
+
return this.getAllPassages().filter(ref => ref.isReusable);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Detect duplicate content and merge passages
|
|
118
|
+
* This handles cases where same content appears with different IDs
|
|
119
|
+
*/
|
|
120
|
+
async detectAndMergeDuplicates() {
|
|
121
|
+
const contentMap = new Map(); // content hash -> primary ID
|
|
122
|
+
const mergeMap = new Map(); // old ID -> new ID
|
|
123
|
+
for (const [id, entry] of this.passages.entries()) {
|
|
124
|
+
if (!entry.content)
|
|
125
|
+
continue;
|
|
126
|
+
const contentHash = await sha256(entry.content.trim());
|
|
127
|
+
const existingId = contentMap.get(contentHash);
|
|
128
|
+
if (existingId && existingId !== id) {
|
|
129
|
+
// Duplicate content found - merge into existing
|
|
130
|
+
mergeMap.set(id, existingId);
|
|
131
|
+
const existingEntry = this.passages.get(existingId);
|
|
132
|
+
for (const itemId of entry.referencedBy) {
|
|
133
|
+
existingEntry.referencedBy.add(itemId);
|
|
134
|
+
}
|
|
135
|
+
existingEntry.reference.isReusable = existingEntry.referencedBy.size > 1;
|
|
136
|
+
this.passages.delete(id);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
contentMap.set(contentHash, id);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return mergeMap;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Parse object tag to extract passage reference
|
|
147
|
+
* @param objectElement Object element from QTI
|
|
148
|
+
* @returns Passage reference or null
|
|
149
|
+
*/
|
|
150
|
+
export async function parseObjectReference(objectElement) {
|
|
151
|
+
const dataAttr = objectElement.getAttribute?.('data');
|
|
152
|
+
const typeAttr = objectElement.getAttribute?.('type');
|
|
153
|
+
// Check if it's a passage reference (text/html, text/plain, or no type)
|
|
154
|
+
const isPassageType = !typeAttr ||
|
|
155
|
+
typeAttr === 'text/html' ||
|
|
156
|
+
typeAttr === 'text/plain' ||
|
|
157
|
+
typeAttr.startsWith('text/');
|
|
158
|
+
if (!dataAttr || !isPassageType) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
// Generate stable ID from file path
|
|
162
|
+
const id = await generateStablePassageId({ filePath: dataAttr });
|
|
163
|
+
return {
|
|
164
|
+
id,
|
|
165
|
+
source: 'file',
|
|
166
|
+
filePath: dataAttr,
|
|
167
|
+
isReusable: false, // Will be updated by registry
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=passage-reusability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passage-reusability.js","sourceRoot":"","sources":["../src/passage-reusability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAS7C;IACC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC;IAE3C,sDAAsD;IACtD,oEAAoE;IACpE,0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AAM,aAAa,GAAG,CAAC,QAAQ;QACT,QAAQ,KAAK,WAAW;QACxB,QAAQ,KAAK,YAAY;QACzB,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAEnD,IAAI,CAAC,QAAQ,IAAI,CAAC,aAAa,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oCAAoC;IACpC,MAAM,EAAE,GAAG,MAAM,uBAAuB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEjE,OAAO;QACL,EAAE;QACF,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,QAAQ;QAClB,UAAU,EAAE,KAAK,EAAE,8BAA8B;KAClD,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Passage reusability detection and stable ID management\n *\n * QTI provides several mechanisms for reusable content:\n * 1. Manifest <dependency> elements - explicit reusability declaration\n * 2. Object <object data=\"...\"> references - shared file paths\n * 3. assessmentStimulus/assessmentPassage identifiers - stable IDs\n *\n * This module provides stable ID generation and reusability detection.\n */\n\nimport { sha256 } from './utils/hash.js';\n\n/**\n * Generate stable ID for passage content\n *\n * Strategy (in priority order):\n * 1. Use QTI identifier directly - QTI identifiers are designed to be globally unique\n * across vendors and packages (e.g., \"urn:example.com:passage:12345\")\n * 2. Use file path for object references - stable within a package\n * 3. Use content hash for inline stimulus - ensures same content = same ID\n *\n * @param options Options for ID generation\n * @returns Stable passage ID (async for content hashing)\n */\nexport async function generateStablePassageId(options: {\n /** QTI identifier from assessmentStimulus or assessmentPassage - USE DIRECTLY */\n qtiIdentifier?: string;\n /** File path from object data attribute */\n filePath?: string;\n /** Content hash for inline stimulus */\n content?: string;\n /** Prefix for generated IDs (only used for hashed IDs) */\n prefix?: string;\n}): Promise<string> {\n const prefix = options.prefix || 'passage';\n\n // Priority 1: Use QTI identifier DIRECTLY (no prefix)\n // QTI identifiers are designed to be globally unique across vendors\n // Examples: \"urn:example.com:passage:12345\", \"stim-industrial-revolution\"\n if (options.qtiIdentifier) {\n return options.qtiIdentifier;\n }\n\n // Priority 2: Use file path for object references\n // Normalize path (remove leading ./ and ../) and use as-is with prefix\n if (options.filePath) {\n const normalizedPath = options.filePath\n .replace(/^\\.\\//, '')\n .replace(/\\.\\.\\//g, '')\n .replace(/\\//g, '-')\n .replace(/\\.(xml|html|txt)$/, '');\n return `${prefix}-${normalizedPath}`;\n }\n\n // Priority 3: Use content hash for inline stimulus (stable for same content)\n if (options.content) {\n const contentHash = await sha256(options.content.trim());\n return `${prefix}-content-${contentHash.substring(0, 12)}`;\n }\n\n throw new Error('Must provide at least one of: qtiIdentifier, filePath, or content');\n}\n\n/**\n * Passage reference information\n */\nexport interface PassageReference {\n /** Stable passage ID */\n id: string;\n /** Source of the passage */\n source: 'inline' | 'file' | 'manifest' | 'qti-element';\n /** Original QTI identifier if available */\n qtiIdentifier?: string;\n /** File path if from object reference */\n filePath?: string;\n /** Whether this passage is referenced by multiple items */\n isReusable: boolean;\n}\n\n/**\n * Track passage references across a package\n * Used during batch transformation to detect reusable passages\n */\nexport class PassageRegistry {\n private passages = new Map<string, {\n reference: PassageReference;\n referencedBy: Set<string>;\n content?: string;\n }>();\n\n /**\n * Register a passage reference\n * @param itemId ID of the item referencing this passage\n * @param reference Passage reference information\n */\n registerReference(itemId: string, reference: PassageReference): void {\n const existing = this.passages.get(reference.id);\n\n if (existing) {\n // Passage already registered, add this item as a reference\n existing.referencedBy.add(itemId);\n existing.reference.isReusable = existing.referencedBy.size > 1;\n } else {\n // First reference to this passage\n this.passages.set(reference.id, {\n reference: { ...reference, isReusable: false },\n referencedBy: new Set([itemId]),\n });\n }\n }\n\n /**\n * Store passage content for deduplication\n * @param passageId Passage ID\n * @param content Passage content\n */\n storeContent(passageId: string, content: string): void {\n const entry = this.passages.get(passageId);\n if (entry) {\n entry.content = content;\n }\n }\n\n /**\n * Get passage reference by ID\n * @param passageId Passage ID\n * @returns Passage reference with updated reusability flag\n */\n getReference(passageId: string): PassageReference | undefined {\n return this.passages.get(passageId)?.reference;\n }\n\n /**\n * Get all items that reference a passage\n * @param passageId Passage ID\n * @returns Set of item IDs\n */\n getReferencingItems(passageId: string): Set<string> {\n return this.passages.get(passageId)?.referencedBy || new Set();\n }\n\n /**\n * Get all registered passages\n * @returns Array of passage references\n */\n getAllPassages(): PassageReference[] {\n return Array.from(this.passages.values()).map(entry => entry.reference);\n }\n\n /**\n * Get reusable passages (referenced by multiple items)\n * @returns Array of reusable passage references\n */\n getReusablePassages(): PassageReference[] {\n return this.getAllPassages().filter(ref => ref.isReusable);\n }\n\n /**\n * Detect duplicate content and merge passages\n * This handles cases where same content appears with different IDs\n */\n async detectAndMergeDuplicates(): Promise<Map<string, string>> {\n const contentMap = new Map<string, string>(); // content hash -> primary ID\n const mergeMap = new Map<string, string>(); // old ID -> new ID\n\n for (const [id, entry] of this.passages.entries()) {\n if (!entry.content) continue;\n\n const contentHash = await sha256(entry.content.trim());\n\n const existingId = contentMap.get(contentHash);\n if (existingId && existingId !== id) {\n // Duplicate content found - merge into existing\n mergeMap.set(id, existingId);\n\n const existingEntry = this.passages.get(existingId)!;\n for (const itemId of entry.referencedBy) {\n existingEntry.referencedBy.add(itemId);\n }\n existingEntry.reference.isReusable = existingEntry.referencedBy.size > 1;\n\n this.passages.delete(id);\n } else {\n contentMap.set(contentHash, id);\n }\n }\n\n return mergeMap;\n }\n}\n\n/**\n * Parse object tag to extract passage reference\n * @param objectElement Object element from QTI\n * @returns Passage reference or null\n */\nexport async function parseObjectReference(objectElement: any): Promise<PassageReference | null> {\n const dataAttr = objectElement.getAttribute?.('data');\n const typeAttr = objectElement.getAttribute?.('type');\n\n // Check if it's a passage reference (text/html, text/plain, or no type)\n const isPassageType = !typeAttr ||\n typeAttr === 'text/html' ||\n typeAttr === 'text/plain' ||\n typeAttr.startsWith('text/');\n\n if (!dataAttr || !isPassageType) {\n return null;\n }\n\n // Generate stable ID from file path\n const id = await generateStablePassageId({ filePath: dataAttr });\n\n return {\n id,\n source: 'file',\n filePath: dataAttr,\n isReusable: false, // Will be updated by registry\n };\n}\n"]}
|