@c4a/extract 0.6.0-alpha.6 → 0.6.0-beta.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/index.js +4 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -15731,11 +15731,13 @@ function sourceSpanHashMatches(refHash, fullSpanHash) {
|
|
|
15731
15731
|
}
|
|
15732
15732
|
function createDocumentSnapshotFileEntry(input) {
|
|
15733
15733
|
const path2 = normalizeSnapshotRelativePath(input.path);
|
|
15734
|
+
const sourcePath = input.source_path === undefined ? undefined : normalizeSnapshotRelativePath(input.source_path);
|
|
15734
15735
|
if ((input.title?.trim().length ?? 0) === 0 && (input.locator?.trim().length ?? 0) === 0) {
|
|
15735
15736
|
throw new TypeError(`snapshot file "${path2}" must include title or locator`);
|
|
15736
15737
|
}
|
|
15737
15738
|
return {
|
|
15738
15739
|
path: path2,
|
|
15740
|
+
...sourcePath !== undefined && sourcePath !== path2 ? { source_path: sourcePath } : {},
|
|
15739
15741
|
content_hash: computeDocumentContentHash(input.bytes),
|
|
15740
15742
|
line_count: countMarkdownLines(input.bytes),
|
|
15741
15743
|
...input.title !== undefined ? { title: input.title.trim() } : {},
|
|
@@ -15772,11 +15774,13 @@ function parseFileEntry(value, index) {
|
|
|
15772
15774
|
}
|
|
15773
15775
|
const title = typeof value.title === "string" && value.title.trim().length > 0 ? value.title.trim() : undefined;
|
|
15774
15776
|
const locator = typeof value.locator === "string" && value.locator.trim().length > 0 ? value.locator.trim() : undefined;
|
|
15777
|
+
const sourcePath = typeof value.source_path === "string" && value.source_path.trim().length > 0 ? normalizeSnapshotRelativePath(value.source_path) : undefined;
|
|
15775
15778
|
if (title === undefined && locator === undefined) {
|
|
15776
15779
|
throw new TypeError(`snapshot manifest files[${index}] must include title or locator`);
|
|
15777
15780
|
}
|
|
15778
15781
|
return {
|
|
15779
15782
|
path: normalizeSnapshotRelativePath(value.path),
|
|
15783
|
+
...sourcePath !== undefined ? { source_path: sourcePath } : {},
|
|
15780
15784
|
content_hash: normalizeHashId(value.content_hash),
|
|
15781
15785
|
line_count: value.line_count,
|
|
15782
15786
|
...title !== undefined ? { title } : {},
|