@lobehub/cli 0.0.3 → 0.0.4
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.js +486 -30691
- package/man/man1/lh.1 +4 -1
- package/package.json +16 -19
- package/dist/buffer-crc32-BlUV1nEz.js +0 -342
- package/dist/doc-CR0Zm5t8.js +0 -4144
- package/dist/docx-73xqMWN6.js +0 -33097
- package/dist/excel-3NB56vnT.js +0 -23451
- package/dist/node-BbXtxEF5.js +0 -48
- package/dist/pdf-B5Ukgxfs.js +0 -108386
- package/dist/pptx-DwZ8X2Hk.js +0 -9929
- package/dist/text-LU5pflEU.js +0 -59
package/dist/text-LU5pflEU.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { s as __toESM, t as require_src } from "./index.js";
|
|
3
|
-
import { readFile } from "node:fs/promises";
|
|
4
|
-
const log = (0, (/* @__PURE__ */ __toESM(require_src())).default)("file-loaders:text");
|
|
5
|
-
/**
|
|
6
|
-
* Loader for loading plain text files.
|
|
7
|
-
*/
|
|
8
|
-
var TextLoader = class {
|
|
9
|
-
async loadPages(filePath) {
|
|
10
|
-
log("Loading text file:", filePath);
|
|
11
|
-
try {
|
|
12
|
-
const fileContent = await readFile(filePath, "utf8");
|
|
13
|
-
log("Text file loaded successfully, size:", fileContent.length, "bytes");
|
|
14
|
-
const lineCount = fileContent.split("\n").length;
|
|
15
|
-
const charCount = fileContent.length;
|
|
16
|
-
log("Text file stats:", {
|
|
17
|
-
charCount,
|
|
18
|
-
lineCount
|
|
19
|
-
});
|
|
20
|
-
const page = {
|
|
21
|
-
charCount,
|
|
22
|
-
lineCount,
|
|
23
|
-
metadata: {
|
|
24
|
-
lineNumberEnd: lineCount,
|
|
25
|
-
lineNumberStart: 1
|
|
26
|
-
},
|
|
27
|
-
pageContent: fileContent
|
|
28
|
-
};
|
|
29
|
-
log("Text page created successfully");
|
|
30
|
-
return [page];
|
|
31
|
-
} catch (e) {
|
|
32
|
-
const error = e;
|
|
33
|
-
log("Error encountered while loading text file");
|
|
34
|
-
console.error(`Error loading text file ${filePath}: ${error.message}`);
|
|
35
|
-
const errorPage = {
|
|
36
|
-
charCount: 0,
|
|
37
|
-
lineCount: 0,
|
|
38
|
-
metadata: { error: `Failed to load text file: ${error.message}` },
|
|
39
|
-
pageContent: ""
|
|
40
|
-
};
|
|
41
|
-
log("Created error page for failed text file loading");
|
|
42
|
-
return [errorPage];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* For plain text, simply concatenate the content of all pages.
|
|
47
|
-
* (Although TextLoader typically has only one page, this maintains interface consistency)
|
|
48
|
-
* @param pages Array of pages
|
|
49
|
-
* @returns Aggregated content
|
|
50
|
-
*/
|
|
51
|
-
async aggregateContent(pages) {
|
|
52
|
-
log("Aggregating content from", pages.length, "text pages");
|
|
53
|
-
const result = pages.map((page) => page.pageContent).join("\n");
|
|
54
|
-
log("Content aggregated successfully, length:", result.length);
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
//#endregion
|
|
59
|
-
export { TextLoader };
|