@promptbook/pdf 0.84.0-12 → 0.84.0-13
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/esm/index.es.js +49 -7
- package/esm/index.es.js.map +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +49 -7
- package/umd/index.umd.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/pdf",
|
|
3
|
-
"version": "0.84.0-
|
|
3
|
+
"version": "0.84.0-13",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"--note-0": " <- [🐊]",
|
|
6
6
|
"private": false,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"module": "./esm/index.es.js",
|
|
55
55
|
"typings": "./esm/typings/src/_packages/pdf.index.d.ts",
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@promptbook/core": "0.84.0-
|
|
57
|
+
"@promptbook/core": "0.84.0-13"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"crypto-js": "4.2.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.84.0-
|
|
28
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.84.0-12';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -3616,7 +3616,7 @@
|
|
|
3616
3616
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
3617
3617
|
var _a;
|
|
3618
3618
|
return __awaiter(this, void 0, void 0, function () {
|
|
3619
|
-
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url,
|
|
3619
|
+
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, _f, _g, _h, _j, _k, filename_1, fileExtension, mimeType;
|
|
3620
3620
|
return __generator(this, function (_l) {
|
|
3621
3621
|
switch (_l.label) {
|
|
3622
3622
|
case 0:
|
|
@@ -3632,19 +3632,61 @@
|
|
|
3632
3632
|
url = knowledgeSourceContent;
|
|
3633
3633
|
return [4 /*yield*/, fetch(url)];
|
|
3634
3634
|
case 1:
|
|
3635
|
-
|
|
3636
|
-
mimeType = ((_a =
|
|
3637
|
-
|
|
3635
|
+
response_1 = _l.sent();
|
|
3636
|
+
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
3637
|
+
if (tools.fs === undefined || !url.endsWith('.pdf')) {
|
|
3638
|
+
return [2 /*return*/, {
|
|
3639
|
+
source: name,
|
|
3640
|
+
filename: null,
|
|
3641
|
+
url: url,
|
|
3642
|
+
mimeType: mimeType,
|
|
3643
|
+
/*
|
|
3644
|
+
TODO: [🥽]
|
|
3645
|
+
> async asBlob() {
|
|
3646
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
3647
|
+
> const content = await response.blob();
|
|
3648
|
+
> return content;
|
|
3649
|
+
> },
|
|
3650
|
+
*/
|
|
3651
|
+
asJson: function () {
|
|
3652
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3653
|
+
var content;
|
|
3654
|
+
return __generator(this, function (_a) {
|
|
3655
|
+
switch (_a.label) {
|
|
3656
|
+
case 0: return [4 /*yield*/, response_1.json()];
|
|
3657
|
+
case 1:
|
|
3658
|
+
content = _a.sent();
|
|
3659
|
+
return [2 /*return*/, content];
|
|
3660
|
+
}
|
|
3661
|
+
});
|
|
3662
|
+
});
|
|
3663
|
+
},
|
|
3664
|
+
asText: function () {
|
|
3665
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3666
|
+
var content;
|
|
3667
|
+
return __generator(this, function (_a) {
|
|
3668
|
+
switch (_a.label) {
|
|
3669
|
+
case 0: return [4 /*yield*/, response_1.text()];
|
|
3670
|
+
case 1:
|
|
3671
|
+
content = _a.sent();
|
|
3672
|
+
return [2 /*return*/, content];
|
|
3673
|
+
}
|
|
3674
|
+
});
|
|
3675
|
+
});
|
|
3676
|
+
},
|
|
3677
|
+
}];
|
|
3678
|
+
}
|
|
3679
|
+
basename = url.split('/').pop() || titleToName(url);
|
|
3638
3680
|
hash = sha256__default["default"](hexEncoder__default["default"].parse(url)).toString( /* hex */);
|
|
3639
3681
|
rootDirname_1 = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
3640
|
-
filepath = path.join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(
|
|
3682
|
+
filepath = path.join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(basename.substring(0, MAX_FILENAME_LENGTH), ".pdf")], false));
|
|
3641
3683
|
return [4 /*yield*/, tools.fs.mkdir(path.dirname(path.join(rootDirname_1, filepath)), { recursive: true })];
|
|
3642
3684
|
case 2:
|
|
3643
3685
|
_l.sent();
|
|
3644
3686
|
_g = (_f = tools.fs).writeFile;
|
|
3645
3687
|
_h = [path.join(rootDirname_1, filepath)];
|
|
3646
3688
|
_k = (_j = Buffer).from;
|
|
3647
|
-
return [4 /*yield*/,
|
|
3689
|
+
return [4 /*yield*/, response_1.arrayBuffer()];
|
|
3648
3690
|
case 3: return [4 /*yield*/, _g.apply(_f, _h.concat([_k.apply(_j, [_l.sent()])]))];
|
|
3649
3691
|
case 4:
|
|
3650
3692
|
_l.sent();
|