@promptbook/pdf 0.85.0-4 → 0.85.0-6
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 +25 -7
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +34 -16
- 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.85.0-
|
|
3
|
+
"version": "0.85.0-6",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/pdf.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.85.0-
|
|
50
|
+
"@promptbook/core": "0.85.0-6"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"crypto": "^1.0.1",
|
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-pdf"] = {}, global.promises, global.spaceTrim, global.cryptoJs, global.hexEncoder, global.
|
|
5
|
-
})(this, (function (exports, promises, spaceTrim, cryptoJs, hexEncoder,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier'), require('prettier/parser-html'), require('rxjs'), require('crypto'), require('waitasecond'), require('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier', 'prettier/parser-html', 'rxjs', 'crypto', 'waitasecond', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-pdf"] = {}, global.promises, global.spaceTrim, global.cryptoJs, global.hexEncoder, global.path, global.prettier, global.parserHtml, global.rxjs, global.crypto, global.waitasecond, global.sha256, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, promises, spaceTrim, cryptoJs, hexEncoder, path, prettier, parserHtml, rxjs, crypto, waitasecond, sha256, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-
|
|
28
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-5';
|
|
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
|
|
@@ -869,7 +869,7 @@
|
|
|
869
869
|
value = value.replace(/\.html$/, '');
|
|
870
870
|
}
|
|
871
871
|
else if (isValidFilePath(value)) {
|
|
872
|
-
value =
|
|
872
|
+
value = path.basename(value);
|
|
873
873
|
// Note: Keeping extension in the name
|
|
874
874
|
}
|
|
875
875
|
value = value.split('/').join('-');
|
|
@@ -915,12 +915,12 @@
|
|
|
915
915
|
semanticName = normalizeToKebabCase(titleToName((sourceFilename || url || '').split('intermediate').join(''))).substring(0, 20);
|
|
916
916
|
pieces = ['intermediate', semanticName, hash].filter(function (piece) { return piece !== ''; });
|
|
917
917
|
name = pieces.join('-').split('--').join('-');
|
|
918
|
-
cacheFilename =
|
|
918
|
+
cacheFilename = path.join.apply(void 0, __spreadArray(__spreadArray([process.cwd(),
|
|
919
919
|
cacheDirname], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), [name], false)).split('\\')
|
|
920
920
|
.join('/') +
|
|
921
921
|
'.' +
|
|
922
922
|
extension;
|
|
923
|
-
return [4 /*yield*/, promises.mkdir(
|
|
923
|
+
return [4 /*yield*/, promises.mkdir(path.dirname(cacheFilename), { recursive: true })];
|
|
924
924
|
case 1:
|
|
925
925
|
_a.sent();
|
|
926
926
|
isDestroyed = true;
|
|
@@ -2531,6 +2531,24 @@
|
|
|
2531
2531
|
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2532
2532
|
partialResultSubject.next(newOngoingResult);
|
|
2533
2533
|
});
|
|
2534
|
+
finalResultPromise
|
|
2535
|
+
.catch(function (error) {
|
|
2536
|
+
// console.error('!!!!! Task failed:', error);
|
|
2537
|
+
partialResultSubject.error(error);
|
|
2538
|
+
})
|
|
2539
|
+
.then(function (value) {
|
|
2540
|
+
// console.error('!!!!! Task finished:', value);
|
|
2541
|
+
if (value) {
|
|
2542
|
+
try {
|
|
2543
|
+
assertsTaskSuccessful(value);
|
|
2544
|
+
partialResultSubject.next(value);
|
|
2545
|
+
}
|
|
2546
|
+
catch (error) {
|
|
2547
|
+
partialResultSubject.error(error);
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
partialResultSubject.complete();
|
|
2551
|
+
});
|
|
2534
2552
|
function asPromise(options) {
|
|
2535
2553
|
return __awaiter(this, void 0, void 0, function () {
|
|
2536
2554
|
var _a, isCrashedOnError, finalResult;
|
|
@@ -2541,7 +2559,9 @@
|
|
|
2541
2559
|
return [4 /*yield*/, finalResultPromise];
|
|
2542
2560
|
case 1:
|
|
2543
2561
|
finalResult = _b.sent();
|
|
2562
|
+
console.error('!!!!! finalResult:', finalResult);
|
|
2544
2563
|
if (isCrashedOnError) {
|
|
2564
|
+
console.error('!!!!! isCrashedOnError:', finalResult);
|
|
2545
2565
|
assertsTaskSuccessful(finalResult);
|
|
2546
2566
|
}
|
|
2547
2567
|
return [2 /*return*/, finalResult];
|
|
@@ -2554,9 +2574,7 @@
|
|
|
2554
2574
|
taskId: taskId,
|
|
2555
2575
|
asPromise: asPromise,
|
|
2556
2576
|
asObservable: function () {
|
|
2557
|
-
return
|
|
2558
|
-
isCrashedOnError: true,
|
|
2559
|
-
})));
|
|
2577
|
+
return partialResultSubject.asObservable();
|
|
2560
2578
|
},
|
|
2561
2579
|
get currentValue() {
|
|
2562
2580
|
return partialResultSubject.value;
|
|
@@ -3687,9 +3705,9 @@
|
|
|
3687
3705
|
}
|
|
3688
3706
|
basename = url.split('/').pop() || titleToName(url);
|
|
3689
3707
|
hash = sha256__default["default"](hexEncoder__default["default"].parse(url)).toString( /* hex */);
|
|
3690
|
-
rootDirname_1 =
|
|
3691
|
-
filepath =
|
|
3692
|
-
return [4 /*yield*/, tools.fs.mkdir(
|
|
3708
|
+
rootDirname_1 = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
3709
|
+
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), ".").concat(mimeTypeToExtension(mimeType))], false));
|
|
3710
|
+
return [4 /*yield*/, tools.fs.mkdir(path.dirname(path.join(rootDirname_1, filepath)), { recursive: true })];
|
|
3693
3711
|
case 2:
|
|
3694
3712
|
_h.sent();
|
|
3695
3713
|
_g = (_f = Buffer).from;
|
|
@@ -3699,7 +3717,7 @@
|
|
|
3699
3717
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
3700
3718
|
throw new LimitReachedError("File is too large (".concat(Math.round(fileContent.length / 1024 / 1024), "MB). Maximum allowed size is ").concat(Math.round(DEFAULT_MAX_FILE_SIZE / 1024 / 1024), "MB."));
|
|
3701
3719
|
}
|
|
3702
|
-
return [4 /*yield*/, tools.fs.writeFile(
|
|
3720
|
+
return [4 /*yield*/, tools.fs.writeFile(path.join(rootDirname_1, filepath), fileContent)];
|
|
3703
3721
|
case 4:
|
|
3704
3722
|
_h.sent();
|
|
3705
3723
|
// TODO: [💵] Check the file security
|
|
@@ -3715,7 +3733,7 @@
|
|
|
3715
3733
|
throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
|
|
3716
3734
|
// <- TODO: [🧠] What is the best error type here`
|
|
3717
3735
|
}
|
|
3718
|
-
filename_1 =
|
|
3736
|
+
filename_1 = path.join(rootDirname, knowledgeSourceContent).split('\\').join('/');
|
|
3719
3737
|
fileExtension = getFileExtension(filename_1);
|
|
3720
3738
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3721
3739
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|