@chenchaolong/plugin-mineru 1.1.7 → 1.1.8
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer-mineru.strategy.d.ts","sourceRoot":"","sources":["../../src/lib/transformer-mineru.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAG/D,OAAO,EACL,aAAa,EAGb,oBAAoB,EACpB,4BAA4B,EAC5B,qBAAqB,EAEtB,MAAM,sBAAsB,CAAA;AAI7B,OAAO,EAAgB,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAInE,qBAEa,yBAA0B,YAAW,4BAA4B,CAAC,wBAAwB,CAAC;IAEtG,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA2B;IAGxD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAE7C,QAAQ,CAAC,WAAW,mDAWnB;IAED,QAAQ,CAAC,IAAI;;;;;;;;;;;kBAWM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAwE1B;IAED,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,kBAAkB,CACtB,SAAS,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,EACxC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"transformer-mineru.strategy.d.ts","sourceRoot":"","sources":["../../src/lib/transformer-mineru.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAG/D,OAAO,EACL,aAAa,EAGb,oBAAoB,EACpB,4BAA4B,EAC5B,qBAAqB,EAEtB,MAAM,sBAAsB,CAAA;AAI7B,OAAO,EAAgB,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAInE,qBAEa,yBAA0B,YAAW,4BAA4B,CAAC,wBAAwB,CAAC;IAEtG,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA2B;IAGxD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAE7C,QAAQ,CAAC,WAAW,mDAWnB;IAED,QAAQ,CAAC,IAAI;;;;;;;;;;;kBAWM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAwE1B;IAED,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,kBAAkB,CACtB,SAAS,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,EACxC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;CAsFzD"}
|
|
@@ -115,22 +115,20 @@ let MinerUTransformerStrategy = class MinerUTransformerStrategy {
|
|
|
115
115
|
const parsedResults = [];
|
|
116
116
|
for await (const document of documents) {
|
|
117
117
|
if (mineru.serverType === 'self-hosted') {
|
|
118
|
-
//
|
|
119
|
-
// download
|
|
118
|
+
// Resolve filePath for self-hosted mode
|
|
119
|
+
// Priority: 1) document.filePath, 2) download remote fileUrl, 3) resolve local fileUrl
|
|
120
120
|
let filePath = document.filePath;
|
|
121
|
-
if (!filePath && document.fileUrl
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// This handles cases where fileUrl might be a relative path
|
|
133
|
-
filePath = config.permissions.fileSystem.fullPath(document.fileUrl);
|
|
121
|
+
if (!filePath && document.fileUrl) {
|
|
122
|
+
if (isRemoteFile(document.fileUrl)) {
|
|
123
|
+
const tempDir = config.tempDir || '/tmp/';
|
|
124
|
+
const fileName = document.name || path.basename(document.fileUrl) || 'document.pdf';
|
|
125
|
+
const tempFilePath = path.join(tempDir, `mineru_${Date.now()}_${fileName}`);
|
|
126
|
+
await fsPromises.mkdir(path.dirname(tempFilePath), { recursive: true });
|
|
127
|
+
filePath = await downloadRemoteFile(document.fileUrl, tempFilePath);
|
|
128
|
+
}
|
|
129
|
+
else if (config.permissions?.fileSystem) {
|
|
130
|
+
filePath = config.permissions.fileSystem.fullPath(document.fileUrl);
|
|
131
|
+
}
|
|
134
132
|
}
|
|
135
133
|
if (!filePath) {
|
|
136
134
|
throw new Error('MinerU self-hosted mode requires filePath to be provided. ' +
|